admin/plugins: explicitly call npm with a plugin version
parent
3c9bcf4c4b
commit
b858f5dd62
|
@ -62,7 +62,7 @@ exports.socketio = (hookName, args, cb) => {
|
|||
const currentVersion = pluginDefs.plugins[plugin].package.version;
|
||||
|
||||
return semver.gt(latestVersion, currentVersion);
|
||||
});
|
||||
}).map((plugin) => ({name: plugin, version: results[plugin].version}));
|
||||
|
||||
socket.emit('results:updatable', {updatable});
|
||||
} catch (err) {
|
||||
|
@ -98,8 +98,8 @@ exports.socketio = (hookName, args, cb) => {
|
|||
}
|
||||
});
|
||||
|
||||
socket.on('install', (pluginName) => {
|
||||
installer.install(pluginName, (err) => {
|
||||
socket.on('install', (pluginName, version) => {
|
||||
installer.install(pluginName, version, (err) => {
|
||||
if (err) console.warn(err.stack || err.toString());
|
||||
|
||||
socket.emit('finished:install', {
|
||||
|
|
|
@ -123,13 +123,17 @@ $(document).ready(() => {
|
|||
$('.do-install, .do-update').unbind('click').click(function (e) {
|
||||
const $row = $(e.target).closest('tr');
|
||||
const plugin = $row.data('plugin');
|
||||
const update = $row.find('input.do-update');
|
||||
// TODO dont store it here in DOM
|
||||
// version after update or after installing a new package
|
||||
const version = update.length !== 0 ? update.attr('version') : $row.find('.version').text();
|
||||
if ($(this).hasClass('do-install')) {
|
||||
$row.remove().appendTo('#installed-plugins');
|
||||
installed.progress.show(plugin, 'Installing');
|
||||
} else {
|
||||
installed.progress.show(plugin, 'Updating');
|
||||
}
|
||||
socket.emit('install', plugin);
|
||||
socket.emit('install', plugin, version);
|
||||
installed.messages.hide('nothing-installed');
|
||||
});
|
||||
|
||||
|
@ -217,11 +221,13 @@ $(document).ready(() => {
|
|||
});
|
||||
|
||||
socket.on('results:updatable', (data) => {
|
||||
data.updatable.forEach((pluginName) => {
|
||||
const actions = $(`#installed-plugins > tr.${pluginName} .actions`);
|
||||
data.updatable.forEach((plugin) => {
|
||||
const {name, version} = plugin;
|
||||
const actions = $(`#installed-plugins > tr.${name} .actions`);
|
||||
actions.find('.do-update').remove();
|
||||
// TODO dont store version here in DOM
|
||||
actions.append(
|
||||
$('<input>').addClass('do-update').attr('type', 'button').attr('value', 'Update'));
|
||||
$('<input>').addClass('do-update').attr('type', 'button').attr('version', version).attr('value', 'Update'));
|
||||
});
|
||||
updateHandlers();
|
||||
});
|
||||
|
|
|
@ -43,17 +43,17 @@ exports.uninstall = async (pluginName, cb = null) => {
|
|||
cb(null);
|
||||
};
|
||||
|
||||
exports.install = async (pluginName, cb = null) => {
|
||||
exports.install = async (pluginName, version, cb = null) => {
|
||||
cb = wrapTaskCb(cb);
|
||||
logger.info(`Installing plugin ${pluginName}...`);
|
||||
logger.info(`Installing plugin ${pluginName}@${version}...`);
|
||||
try {
|
||||
await runCmd(['npm', 'install', pluginName]);
|
||||
await runCmd(['npm', 'install', `${pluginName}@${version}`]);
|
||||
} catch (err) {
|
||||
logger.error(`Failed to install plugin ${pluginName}`);
|
||||
logger.error(`Failed to install plugin ${pluginName}@${version}`);
|
||||
cb(err || new Error(err));
|
||||
throw err;
|
||||
}
|
||||
logger.info(`Successfully installed plugin ${pluginName}`);
|
||||
logger.info(`Successfully installed plugin ${pluginName}@${version}`);
|
||||
await hooks.aCallAll('pluginInstall', {pluginName});
|
||||
await plugins.update();
|
||||
cb(null);
|
||||
|
|
Loading…
Reference in New Issue