2024-05-21 10:22:39 +00:00
|
|
|
/*\
|
|
|
|
title: $:/core/modules/utils/repository.js
|
|
|
|
type: application/javascript
|
|
|
|
module-type: utils
|
|
|
|
|
|
|
|
Utilities for working with the TiddlyWiki repository file structure
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/*
|
|
|
|
Get an object containing all the plugins as a hashmap by title of the JSON representation of the plugin
|
2024-05-23 15:28:08 +00:00
|
|
|
Options:
|
|
|
|
|
|
|
|
ignoreEnvironmentVariables: defaults to false
|
2024-05-21 10:22:39 +00:00
|
|
|
*/
|
2024-05-23 15:28:08 +00:00
|
|
|
exports.getAllPlugins = function(options) {
|
2024-05-23 15:34:24 +00:00
|
|
|
options = options || {};
|
2024-05-21 10:22:39 +00:00
|
|
|
var fs = require("fs"),
|
|
|
|
path = require("path"),
|
|
|
|
tiddlers = {};
|
|
|
|
// Collect up the library plugins
|
|
|
|
var collectPlugins = function(folder) {
|
|
|
|
var pluginFolders = $tw.utils.getSubdirectories(folder) || [];
|
|
|
|
for(var p=0; p<pluginFolders.length; p++) {
|
|
|
|
if(!$tw.boot.excludeRegExp.test(pluginFolders[p])) {
|
|
|
|
var pluginFields = $tw.loadPluginFolder(path.resolve(folder,"./" + pluginFolders[p]));
|
|
|
|
if(pluginFields && pluginFields.title) {
|
|
|
|
tiddlers[pluginFields.title] = pluginFields;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
collectPublisherPlugins = function(folder) {
|
|
|
|
var publisherFolders = $tw.utils.getSubdirectories(folder) || [];
|
|
|
|
for(var t=0; t<publisherFolders.length; t++) {
|
|
|
|
if(!$tw.boot.excludeRegExp.test(publisherFolders[t])) {
|
|
|
|
collectPlugins(path.resolve(folder,"./" + publisherFolders[t]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2024-05-23 15:47:28 +00:00
|
|
|
$tw.utils.each($tw.getLibraryItemSearchPaths($tw.config.pluginsPath,options.ignoreEnvironmentVariables ? undefined : $tw.config.pluginsEnvVar),collectPublisherPlugins);
|
|
|
|
$tw.utils.each($tw.getLibraryItemSearchPaths($tw.config.themesPath,options.ignoreEnvironmentVariables ? undefined : $tw.config.themesEnvVar),collectPublisherPlugins);
|
|
|
|
$tw.utils.each($tw.getLibraryItemSearchPaths($tw.config.languagesPath,options.ignoreEnvironmentVariables ? undefined : $tw.config.languagesEnvVar),collectPlugins);
|
2024-05-21 10:22:39 +00:00
|
|
|
return tiddlers;
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|