Skip to content

Commit 4168097

Browse files
committed
feat: support dependencies option
1 parent e19bc73 commit 4168097

3 files changed

Lines changed: 213 additions & 378 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@
4848
}
4949
},
5050
"peerDependencies": {
51-
"@micro-app/core": "^0.3.16"
51+
"@micro-app/core": "^0.3.18"
5252
},
5353
"devDependencies": {
5454
"@babel/core": "^7.9.0",
5555
"@babel/preset-env": "^7.9.0",
56-
"@micro-app/cli": "^0.3.8",
56+
"@micro-app/cli": "^0.3.9",
5757
"@micro-app/plugin-compatible": "0.0.3",
5858
"@micro-app/plugin-deploy": "^0.0.6",
5959
"@types/jest": "^24.9.1",

src/index.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const commands = [
1919
'inspect',
2020
];
2121

22-
const SKIP_TARGET = [ 'pure' ];
22+
const SKIP_TARGET = [ 'pure' ]; // target
23+
const DEPENDENCIES_PLUGIN = [ '@micro-app/cli' ]; // dependencies
2324

2425
// 只能通过集中初始化去实现, 不可进行插件注册(registerPlugins). 否则顺序不可控.
2526
module.exports = [
@@ -45,9 +46,21 @@ module.exports = [
4546

4647
...commands.map(name => {
4748
const item = require(`./commands/${name}`);
48-
if (item.configuration && !item.configuration.alias) {
49+
if (!item.configuration) {
50+
item.configuration = {};
51+
}
52+
if (!item.configuration.alias) {
4953
item.configuration.alias = `commands-${name.replace(/\//, '_')}`;
5054
}
55+
// dependencies
56+
if (!name.startsWith('inspect')) {
57+
if (!item.configuration.dependencies) {
58+
item.configuration.dependencies = [];
59+
}
60+
item.configuration.dependencies.push( // 除了 inspect,所有 command 都需要依赖 cli 的方法
61+
...DEPENDENCIES_PLUGIN
62+
);
63+
}
5164
return item;
5265
}),
5366
];

0 commit comments

Comments
 (0)