need latest version from api
v1.18.x
barisusakli 10 years ago
parent 206b54c35d
commit cb934acb5d

@ -640,19 +640,18 @@ var fs = require('fs'),
async.each(installedPlugins, function(plugin, next) {
pluginMap[plugin.id] = pluginMap[plugin.id] || {};
pluginMap[plugin.id].id = pluginMap[plugin.id].id || plugin.id;
pluginMap[plugin.id].name = pluginMap[plugin.id].name || plugin.id;
pluginMap[plugin.id].description = plugin.description;
pluginMap[plugin.id].url = pluginMap[plugin.id].url || plugin.url;
pluginMap[plugin.id].installed = true;
Plugins.isActive(plugin.id, function(err, active) {
if (err) {
return next(err);
}
pluginMap[plugin.id].active = active;
pluginMap[plugin.name] = pluginMap[plugin.name] || {};
pluginMap[plugin.name].id = pluginMap[plugin.name].id || plugin.name;
pluginMap[plugin.name].name = pluginMap[plugin.name].name || plugin.name;
pluginMap[plugin.name].description = plugin.description;
pluginMap[plugin.name].url = pluginMap[plugin.name].url || plugin.url;
pluginMap[plugin.name].installed = true;
pluginMap[plugin.name].active = plugin.active;
pluginMap[plugin.name].version = plugin.version;
getVersion(plugin.name, function(err, version) {
pluginMap[plugin.name].latest = version;
pluginMap[plugin.name].outdated = version !== pluginMap[plugin.name].version;
next();
});
}, function(err) {
@ -683,6 +682,19 @@ var fs = require('fs'),
});
};
function getVersion(name, callback) {
var npm = require('npm');
npm.load({}, function() {
npm.commands.show([name, 'version'], true, function(err, version) {
if (err || !version) {
return callback(null, 'no version');
}
var obj = Object.keys(version);
callback(null, Array.isArray(obj) && obj.length ? obj[0] : 'no version');
});
});
}
Plugins.isInstalled = function(id, callback) {
var pluginDir = path.join(__dirname, '../node_modules', id);
@ -725,7 +737,7 @@ var fs = require('fs'),
async.waterfall([
function(next) {
fs.readFile(path.join(file, 'plugin.json'), next);
fs.readFile(path.join(file, 'package.json'), next);
},
function(configJSON, next) {
var config;
@ -737,13 +749,12 @@ var fs = require('fs'),
return next(err, null);
}
Plugins.isActive(config.id, function(err, active) {
Plugins.isActive(config.name, function(err, active) {
if (err) {
next(new Error('no-active-state'));
}
delete config.library;
delete config.hooks;
config.active = active;
config.installed = true;

@ -18,6 +18,7 @@
<!-- IF plugins.description -->
<p>{plugins.description}</p>
<!-- ENDIF plugins.description -->
<!-- IF plugins.outdated --><i class="fa fa-exclamation-triangle text-danger"></i> <!-- ENDIF plugins.outdated --><small>Installed <strong>{plugins.version}</strong> | Latest <strong>{plugins.latest}</strong></small>
<!-- IF plugins.url -->
<p>For more information: <a href="{plugins.url}">{plugins.url}</a></p>
<!-- ENDIF plugins.url -->

Loading…
Cancel
Save