Skip to content

Commit 8cd532f

Browse files
committed
enhance: 增加预设 pre-plugins
1 parent 347e2ff commit 8cd532f

File tree

9 files changed

+13
-343
lines changed

9 files changed

+13
-343
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"bin": {
77
"micro-app": "bin/micro-app",
88
"micro-app-dev": "bin/micro-app-dev",
9+
"micro-app-serve": "bin/micro-app-serve",
910
"micro-app-start": "bin/micro-app-start",
1011
"micro-app-build": "./bin/micro-app-build"
1112
},
@@ -58,7 +59,7 @@
5859
"jest": "^24.9.0"
5960
},
6061
"dependencies": {
61-
"@micro-app/core": "^0.3.30",
62+
"@micro-app/core": "^0.4.0",
6263
"@zkochan/cmd-shim": "^4.3.0",
6364
"read-cmd-shim": "^2.0.0",
6465
"update-notifier": "^4.1.0"

src/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,16 @@ function createService(_argv) {
3131

3232
// 预加载插件
3333
// --pre-register-plugin
34+
// 约定默认配置为 microapp/preRegisterPlugin
35+
argv.preRegisterPlugin = argv.preRegisterPlugin || 'microapp/pre-plugins';
3436
if (argv.preRegisterPlugin && _.isString(argv.preRegisterPlugin)) {
3537
const preRegisterPluginPath = path.resolve(service.root, argv.preRegisterPlugin);
3638
if (fs.pathExistsSync(preRegisterPluginPath)) {
3739
const preRegisterPlugin = tryRequire(preRegisterPluginPath);
3840
if (_.isFunction(preRegisterPlugin)) {
3941
preRegisterPlugin(service);
42+
} else {
43+
logger.warn('[CLI]', '"--pre-register-plugin" must be return a function(service){}');
4044
}
4145
}
4246
}

src/plugins/commands/bootstrap/bootstrap.test.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/plugins/commands/bootstrap/index.js

Lines changed: 0 additions & 135 deletions
This file was deleted.

src/plugins/commands/bootstrap/initSymlinks.js

Lines changed: 0 additions & 90 deletions
This file was deleted.

src/plugins/commands/bootstrap/npmInstall.js

Lines changed: 0 additions & 98 deletions
This file was deleted.

src/plugins/commands/init/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ module.exports = function initCommand(api, opts) {
1111
// });
1212

1313
// api.addCommandInit({
14-
// abc: 'aa',
14+
// type: 'master',
15+
// });
16+
17+
// api.beforeCommandInit(({ args }) => {
18+
// console.warn(args);
1519
// });
1620
};
1721

src/plugins/extends/server/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ module.exports = function extendServer(api, opts) {
7878
'resolveShared',
7979
]);
8080
}), selfServerConfig);
81-
return Object.assign({}, mergeConfig);
81+
return Object.assign({}, mergeConfig, { root: api.root });
8282
});
8383

8484
};

0 commit comments

Comments
 (0)