Add public files for plugins
This commit is contained in:
parent
048a272a61
commit
f163e20a93
@ -11,6 +11,7 @@ const fs = require("fs");
|
||||
const Utils = require("../../command-line/utils");
|
||||
|
||||
const stylesheets = [];
|
||||
const files = [];
|
||||
|
||||
const TIME_TO_LIVE = 15 * 60 * 1000; // 15 minutes, in milliseconds
|
||||
|
||||
@ -19,6 +20,7 @@ const cache = {
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getFiles,
|
||||
getStylesheets,
|
||||
getPackage,
|
||||
loadPackages,
|
||||
@ -30,6 +32,9 @@ const packageApis = function(packageName) {
|
||||
Stylesheets: {
|
||||
addFile: addStylesheet.bind(this, packageName),
|
||||
},
|
||||
PublicFiles: {
|
||||
add: addFile.bind(this, packageName),
|
||||
},
|
||||
Commands: {
|
||||
add: inputs.addPluginCommand,
|
||||
runAsUser: (command, targetId, client) =>
|
||||
@ -49,6 +54,14 @@ function getStylesheets() {
|
||||
return stylesheets;
|
||||
}
|
||||
|
||||
function addFile(packageName, filename) {
|
||||
files.push(packageName + "/" + filename);
|
||||
}
|
||||
|
||||
function getFiles() {
|
||||
return files.concat(stylesheets);
|
||||
}
|
||||
|
||||
function getPackage(name) {
|
||||
return packageMap.get(name);
|
||||
}
|
||||
@ -90,6 +103,10 @@ function loadPackages() {
|
||||
|
||||
if (packageInfo.type === "theme") {
|
||||
themes.addTheme(packageName, packageInfo);
|
||||
|
||||
if (packageInfo.files) {
|
||||
packageInfo.files.forEach((file) => addFile(packageName, file));
|
||||
}
|
||||
} else {
|
||||
anyPlugins = true;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ module.exports = function() {
|
||||
const fileName = req.params.filename;
|
||||
const packageFile = packages.getPackage(packageName);
|
||||
|
||||
if (!packageFile || !packages.getStylesheets().includes(`${packageName}/${fileName}`)) {
|
||||
if (!packageFile || !packages.getFiles().includes(`${packageName}/${fileName}`)) {
|
||||
return res.status(404).send("Not found");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user