Skip to content

Commit 7c5adb1

Browse files
committed
🎨 更新优化逻辑及字段
1 parent 8b7717b commit 7c5adb1

File tree

14 files changed

+44
-39
lines changed

14 files changed

+44
-39
lines changed

libs/deploy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ module.exports = isHook => {
8686
const { dependencies = {}, devDependencies = {} } = pkg;
8787
const deps = Object.assign({}, dependencies, devDependencies);
8888

89-
const MICRO_APP_CONFIG_NAME = microAppConfig.name;
89+
const MICRO_APP_CONFIG_NAME = microAppConfig.packageName;
9090
if (deps[MICRO_APP_CONFIG_NAME]) {
9191
const gitp = deps[MICRO_APP_CONFIG_NAME];
9292
// update

libs/update.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = name => {
2121
}
2222

2323
const pkgInfo = microAppConfig.package;
24-
const gitPath = (pkgInfo.devDependencies && pkgInfo.devDependencies[microConfig.name]) || (pkgInfo.dependencies && pkgInfo.dependencies[microConfig.name]) || false;
24+
const gitPath = (pkgInfo.devDependencies && pkgInfo.devDependencies[microConfig.packageName]) || (pkgInfo.dependencies && pkgInfo.dependencies[microConfig.packageName]) || false;
2525
if (gitPath) {
2626
logger.logo(`${chalk.yellow('Delete')}: ${root}`);
2727
shelljs.rm('-rf', root);
@@ -44,7 +44,7 @@ module.exports = name => {
4444
}
4545

4646
const pkgInfo = microAppConfig.package;
47-
const gitPath = (pkgInfo.devDependencies && pkgInfo.devDependencies[microConfig.name]) || (pkgInfo.dependencies && pkgInfo.dependencies[microConfig.name]) || false;
47+
const gitPath = (pkgInfo.devDependencies && pkgInfo.devDependencies[microConfig.packageName]) || (pkgInfo.dependencies && pkgInfo.dependencies[microConfig.packageName]) || false;
4848
if (gitPath) {
4949
return {
5050
root, gitPath,

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@micro-app/cli",
3-
"version": "0.1.0",
3+
"version": "0.1.1-rc.1",
44
"description": "micro app cli",
55
"bin": {
66
"micro-app": "./bin/micro-app.js",
@@ -42,7 +42,7 @@
4242
"webpack": "^4.39.2"
4343
},
4444
"dependencies": {
45-
"@micro-app/core": "^0.1.0",
45+
"@micro-app/core": "^0.1.1-rc.1",
4646
"koa": "^2.8.1",
4747
"koa-static": "^5.0.0",
4848
"opn": "^5.5.0",

plugins/commands/deploy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function deployCommit(api, isHooks) {
126126
const { dependencies = {}, devDependencies = {} } = pkg;
127127
const deps = Object.assign({}, dependencies, devDependencies);
128128

129-
const MICRO_APP_CONFIG_NAME = microAppConfig.name;
129+
const MICRO_APP_CONFIG_NAME = microAppConfig.packageName;
130130
if (deps[MICRO_APP_CONFIG_NAME]) {
131131
const gitp = deps[MICRO_APP_CONFIG_NAME];
132132
// update

plugins/commands/update.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function updateMicro(api, name) {
5555
return;
5656
}
5757

58-
const gitPath = (currentPkgInfo.devDependencies && currentPkgInfo.devDependencies[microConfig.name]) || (currentPkgInfo.dependencies && currentPkgInfo.dependencies[microConfig.name]) || false;
58+
const gitPath = (currentPkgInfo.devDependencies && currentPkgInfo.devDependencies[microConfig.packageName]) || (currentPkgInfo.dependencies && currentPkgInfo.dependencies[microConfig.packageName]) || false;
5959
if (gitPath) {
6060
logger.logo(`${chalk.yellow('Delete')}: ${root}`);
6161
shelljs.rm('-rf', root);
@@ -77,7 +77,7 @@ function updateMicro(api, name) {
7777
return false;
7878
}
7979

80-
const gitPath = (currentPkgInfo.devDependencies && currentPkgInfo.devDependencies[microConfig.name]) || (currentPkgInfo.dependencies && currentPkgInfo.dependencies[microConfig.name]) || false;
80+
const gitPath = (currentPkgInfo.devDependencies && currentPkgInfo.devDependencies[microConfig.packageName]) || (currentPkgInfo.dependencies && currentPkgInfo.dependencies[microConfig.packageName]) || false;
8181
if (gitPath) {
8282
return {
8383
root, gitPath,

plugins/commands/version.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
'use strict';
22

3-
const chalk = require('chalk');
4-
53
module.exports = function versionCommand(api) {
6-
api.registerCommand('version', {
7-
description: 'show version',
8-
usage: 'micro-app version',
9-
}, () => {
10-
const pkg = require('../../package.json');
11-
const version = pkg.version;
124

13-
api.logger.logo();
14-
api.logger.logo(`${chalk.green('Version')}: ${chalk.yellow(version)}`);
15-
api.logger.logo();
16-
});
5+
const pkg = require('../../package.json');
6+
7+
api.addCommandVersion(pkg);
8+
179
};

src/adapter/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module.exports = function adapter(api, { type, isDev, progress }) {
3636
});
3737

3838
if (
39-
!_.isPlainObject(compiler) || !compiler
39+
!_.isObject(compiler) || !compiler
4040
||
4141
!_.isPlainObject(devOptions) || !devOptions
4242
||

src/adapter/vusion/build.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
const microApp = require('@micro-app/core');
44
const logger = microApp.logger;
5+
const CONSTANTS = microApp.CONSTANTS;
56
const tryRequire = require('try-require');
67
const path = require('path');
78

89
module.exports = function(wConfig) {
910

1011
let buildCompiler = tryRequire('vusion-cli/lib/build');
1112
if (!buildCompiler) {
12-
buildCompiler = tryRequire(path.join(process.cwd(), 'node_modules', 'vusion-cli/lib/build'));
13+
buildCompiler = tryRequire(path.join(CONSTANTS.ROOT, 'node_modules', 'vusion-cli/lib/build'));
1314
if (!buildCompiler) {
1415
logger.error('load vusion-cli error!');
1516
return null;

src/adapter/vusion/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
const microApp = require('@micro-app/core');
44
const logger = microApp.logger;
5+
const CONSTANTS = microApp.CONSTANTS;
56
const tryRequire = require('try-require');
67
const path = require('path');
78

89
module.exports = function(vusionConfig) {
910
let webpackConfig = tryRequire('vusion-cli/webpack/' + vusionConfig.type);
1011
if (!webpackConfig) {
11-
webpackConfig = tryRequire(path.join(process.cwd(), 'node_modules', 'vusion-cli/webpack/' + vusionConfig.type));
12+
webpackConfig = tryRequire(path.join(CONSTANTS.ROOT, 'node_modules', 'vusion-cli/webpack/' + vusionConfig.type));
1213
if (!webpackConfig) {
1314
logger.error('load vusion-cli error!');
1415
return null;

src/adapter/vusion/devHot.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,24 @@
22

33
const microApp = require('@micro-app/core');
44
const logger = microApp.logger;
5+
const CONSTANTS = microApp.CONSTANTS;
56
const tryRequire = require('try-require');
67
const path = require('path');
78

89
module.exports = function(wConfig) {
910
let devCompiler = tryRequire('vusion-cli/lib/dev');
1011
if (!devCompiler) {
11-
devCompiler = tryRequire(path.join(process.cwd(), 'node_modules', 'vusion-cli/lib/dev'));
12+
devCompiler = tryRequire(path.join(CONSTANTS.ROOT, 'node_modules', 'vusion-cli/lib/dev'));
1213
if (!devCompiler) {
1314
logger.error('load vusion-cli error!');
1415
return null;
1516
}
1617
}
1718

18-
const { compiler, devOptions, webpackConfig = wConfig } = devCompiler.prepare(wConfig);
19+
const { compiler, devOptions, webpackConfig } = devCompiler.prepare(wConfig);
20+
if (!webpackConfig) {
21+
logger.error('请升级 vusion-cli 版本 > 0.7.17 !!!');
22+
process.exit(1);
23+
}
1924
return { webpackConfig, compiler, devOptions };
2025
};

0 commit comments

Comments
 (0)