/*\ title: $:/plugins/tiddlywiki/multiwikiserver/commands/mws-load-plugin-bags.js type: application/javascript module-type: command Command to create and load a bag for each plugin in the repo \*/ (function(){ /*jslint node: true, browser: true */ /*global $tw: false */ "use strict"; exports.info = { name: "mws-load-plugin-bags", synchronous: true }; var Command = function(params,commander,callback) { this.params = params; this.commander = commander; this.callback = callback; }; Command.prototype.execute = function() { var self = this; loadPluginBags(); return null; }; function loadPluginBags() { const path = require("path"), fs = require("fs"); // Copy plugins var makePluginBagName = function(type,publisher,name) { return "$:/" + type + "/" + (publisher ? publisher + "/" : "") + name; }, savePlugin = function(pluginFields,type,publisher,name) { const bagName = makePluginBagName(type,publisher,name); const result = $tw.mws.store.createBag(bagName,pluginFields.description || "(no description)",{allowPrivilegedCharacters: true}); if(result) { console.log(`Error creating plugin bag ${bagname}: ${JSON.stringify(result)}`); } $tw.mws.store.saveBagTiddler(pluginFields,bagName); }, collectPlugins = function(folder,type,publisher) { var pluginFolders = $tw.utils.getSubdirectories(folder) || []; for(var p=0; p