2014-07-12 08:09:36 +00:00
|
|
|
/*\
|
|
|
|
title: $:/core/modules/commands/makelibrary.js
|
|
|
|
type: application/javascript
|
|
|
|
module-type: command
|
|
|
|
|
|
|
|
Command to pack all of the plugins in the library into a plugin tiddler of type "library"
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
exports.info = {
|
|
|
|
name: "makelibrary",
|
|
|
|
synchronous: true
|
|
|
|
};
|
|
|
|
|
|
|
|
var UPGRADE_LIBRARY_TITLE = "$:/UpgradeLibrary";
|
|
|
|
|
|
|
|
var Command = function(params,commander,callback) {
|
|
|
|
this.params = params;
|
|
|
|
this.commander = commander;
|
|
|
|
this.callback = callback;
|
|
|
|
};
|
|
|
|
|
|
|
|
Command.prototype.execute = function() {
|
|
|
|
var wiki = this.commander.wiki,
|
|
|
|
fs = require("fs"),
|
|
|
|
path = require("path"),
|
|
|
|
upgradeLibraryTitle = this.params[0] || UPGRADE_LIBRARY_TITLE,
|
|
|
|
tiddlers = {};
|
|
|
|
// Collect up the library plugins
|
|
|
|
var collectPlugins = function(folder) {
|
2020-04-20 11:58:27 +00:00
|
|
|
var pluginFolders = $tw.utils.getSubdirectories(folder) || [];
|
2014-07-12 08:09:36 +00:00
|
|
|
for(var p=0; p<pluginFolders.length; p++) {
|
|
|
|
if(!$tw.boot.excludeRegExp.test(pluginFolders[p])) {
|
|
|
|
pluginFields = $tw.loadPluginFolder(path.resolve(folder,"./" + pluginFolders[p]));
|
|
|
|
if(pluginFields && pluginFields.title) {
|
|
|
|
tiddlers[pluginFields.title] = pluginFields;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
collectPublisherPlugins = function(folder) {
|
2020-04-20 11:58:27 +00:00
|
|
|
var publisherFolders = $tw.utils.getSubdirectories(folder) || [];
|
2014-07-12 08:09:36 +00:00
|
|
|
for(var t=0; t<publisherFolders.length; t++) {
|
|
|
|
if(!$tw.boot.excludeRegExp.test(publisherFolders[t])) {
|
|
|
|
collectPlugins(path.resolve(folder,"./" + publisherFolders[t]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2020-04-14 11:08:15 +00:00
|
|
|
$tw.utils.each($tw.getLibraryItemSearchPaths($tw.config.pluginsPath,$tw.config.pluginsEnvVar),collectPublisherPlugins);
|
|
|
|
$tw.utils.each($tw.getLibraryItemSearchPaths($tw.config.themesPath,$tw.config.themesEnvVar),collectPublisherPlugins);
|
|
|
|
$tw.utils.each($tw.getLibraryItemSearchPaths($tw.config.languagesPath,$tw.config.languagesEnvVar),collectPlugins);
|
2014-07-12 08:09:36 +00:00
|
|
|
// Save the upgrade library tiddler
|
|
|
|
var pluginFields = {
|
|
|
|
title: upgradeLibraryTitle,
|
|
|
|
type: "application/json",
|
|
|
|
"plugin-type": "library",
|
2019-09-16 11:15:39 +00:00
|
|
|
"text": JSON.stringify({tiddlers: tiddlers})
|
2014-07-12 08:09:36 +00:00
|
|
|
};
|
|
|
|
wiki.addTiddler(new $tw.Tiddler(pluginFields));
|
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.Command = Command;
|
|
|
|
|
|
|
|
})();
|