Skip to content

Commit

Permalink
feat: check upgrade and force update when not compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
cpselvis committed Nov 9, 2017
1 parent fd2038b commit 529568d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class Feflow {

// Init client and load external plugins
return Promise.each([
'initClient',
'upgrade',
'initClient',
'loadPlugins'
], function (name) {
return require('./' + name)(self);
Expand Down
18 changes: 10 additions & 8 deletions lib/core/upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ class Upgrade {
const registry = config && config.registry;

log.debug('正在检查更新...');
pkgJson('feflow-cli', 'latest', registry).then(json => {
return pkgJson('feflow-cli', 'latest', registry).then(json => {
const version = pkg.version;
//const compatibleVersion = json.configs && json.configs.compatiableVersion;
const compatibleVersion = '>=0.10.0';
const configs = json.configs;
const ltsVersion = configs && configs.version;
const compatibleVersion = configs && configs.compatibleVersion;
log.debug(`本地版本: ${version}, 兼容版本 ${compatibleVersion}`);

// If local installed felfow version not compatible with remote, it will be force update to latest version.
if (!semver.satisfies(version, compatibleVersion)) {
log.info(`您当前使用的feflow版本 ${version}, feflow要求使用的版本为 ${compatibleVersion}, 将会使用全量更新策略`);
Expand All @@ -30,14 +33,17 @@ class Upgrade {
return self.execNpmCommand('install', 'feflow-cli').then(function (result) {
if (!result.code) {
loading.success();
log.info(`已经自动升级到feflow的最新版本`);
log.info(`已经自动升级到feflow的最新版本${ltsVersion}`);
} else {
const err = `feflow-cli安装失败,失败码为${result.code},错误日志为${result.data}`;
loading.fail(err);
log.error(err);
}
});
} else {
log.debug(`当前安装的版本 ${version} 和最新版本 ${ltsVersion} 兼容`);
}
return false;
});
}

Expand Down Expand Up @@ -75,10 +81,6 @@ class Upgrade {
});
});
}

forceUpdate() {

}
}

module.exports = function (ctx) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "feflow-cli",
"version": "0.9.0",
"version": "0.11.0",
"description": "A command line tool aims to improve front-end engineer workflow.",
"main": "lib/index.js",
"scripts": {
Expand Down

0 comments on commit 529568d

Please sign in to comment.