feat: add ./nodebb install <plugin_name>

will install the suggested version for current nodebb closes #11060
This commit is contained in:
Barış Soner Uşaklı
2022-11-24 11:17:06 -05:00
parent 8abea39389
commit 6fe8797525
3 changed files with 49 additions and 5 deletions

View File

@@ -87,6 +87,15 @@ module.exports = function (Plugins) {
throw new Error('[[error:plugin-not-whitelisted]]');
};
Plugins.suggest = async function (pluginId, nbbVersion) {
const body = await request({
method: 'GET',
url: `https://packages.nodebb.org/api/v1/suggest?package=${encodeURIComponent(pluginId)}&version=${encodeURIComponent(nbbVersion)}`,
json: true,
});
return body;
};
Plugins.toggleInstall = async function (id, version) {
pubsub.publish('plugins:toggleInstall', { hostname: os.hostname(), id: id, version: version });
return await toggleInstall(id, version);