Skip to content

Commit 51518bd

Browse files
authored
Merge pull request #10 from MicrosApp/develop
Develop
2 parents 22c71e5 + 6462274 commit 51518bd

24 files changed

+1177
-149
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 @micro-app
3+
Copyright (c) 2019-present, Zyao89
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,6 @@ or
123123
npx micro-app-dev
124124
```
125125

126-
### Build
127-
128-
```sh
129-
npx micro-app build
130-
```
131-
132-
or
133-
134-
```sh
135-
npx micro-app-build
136-
```
137-
138126
### 运行
139127

140128
```sh
@@ -215,8 +203,7 @@ npx micro-app show methods
215203
* onPluginInitDone ( System Build-in )
216204
* beforeMergeConfig ( System Build-in )
217205
* afterMergeConfig ( System Build-in )
218-
* beforeMergeServerConfig ( System Build-in )
219-
* afterMergeServerConfig ( System Build-in )
206+
* modifyDefaultServerConfig ( System Build-in )
220207
* onInitWillDone ( System Build-in )
221208
* onInitDone ( System Build-in )
222209
* modifyCommand ( System Build-in )
@@ -226,13 +213,14 @@ npx micro-app show methods
226213
* afterMergeWebpackConfig ( 合并 webpack 配置之后事件 )
227214
* modifyChainWebpcakConfig ( 合并之后提供 webpack-chain 进行再次修改事件 )
228215
* onChainWebpcakConfig ( 修改之后提供 webpack-chain 进行查看事件 )
216+
* modifyWebpackConfig ( 合并之后提供 webpack config 进行再次修改事件 )
229217
* onServerInit ( 服务初始化时事件 )
218+
* onServerInitWillDone ( 服务初始化即将完成事件 )
230219
* onServerInitDone ( 服务初始化完成事件 )
231220
* onServerRunSuccess ( 服务运行启动成功时事件 )
232221
* onServerRunFail ( 服务运行启动失败时事件 )
233222
* beforeServerEntry ( 服务进入业务逻辑前事件 )
234223
* afterServerEntry ( 服务从业务逻辑出来后事件 )
235-
* modifyWebpackConfig ( 对服务启动前对 webpack config 进行修改, 需要返回所有参数 )
236224
* beforeDevServer ( 开发服务创建前事件 )
237225
* afterDevServer ( 开发服务创建后事件 )
238226
* onBuildSuccess ( 构建成功时事件 )
File renamed without changes.
File renamed without changes.

micro-app.config.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ module.exports = {
4545

4646
strict: true,
4747

48-
// micros: [ 'test' ], // 被注册的容器
49-
// micros$$test: { // 单独配置
50-
// disabled: true, // 禁用入口
51-
// link: '', // 本地路径, 进行本地开发使用的软链接.
52-
// },
48+
micros: [ 'test', 'abab' ], // 被注册的容器
5349

5450
// 服务配置
5551
server: {
@@ -60,13 +56,13 @@ module.exports = {
6056
},
6157
},
6258

63-
// plugins: [
64-
// [{
65-
// id: 'test',
66-
// description: '这是test',
67-
// link: __dirname + '/test/testPlugin',
68-
// }, {
69-
// a: 1,
70-
// }],
71-
// ],
59+
plugins: [
60+
[{
61+
id: 'test',
62+
description: '这是test',
63+
link: __dirname + '/test/testPlugin',
64+
}, {
65+
a: 1,
66+
}],
67+
],
7268
};

package.json

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
{
22
"name": "@micro-app/cli",
3-
"version": "0.2.0-beta.1",
3+
"version": "0.2.0",
44
"description": "[CLI] Pluggable micro application framework.",
5+
"main": "bin/base.js",
56
"bin": {
6-
"micro-app": "./bin/micro-app.js",
7-
"micro-app-dev": "./bin/micro-app-dev.js",
8-
"micro-app-start": "./bin/micro-app-start.js"
7+
"micro-app": "bin/micro-app",
8+
"micro-app-dev": "bin/micro-app-dev",
9+
"micro-app-start": "bin/micro-app-start"
910
},
1011
"scripts": {
12+
"lint": "eslint .",
13+
"lint:fix": "npm run lint -- --fix",
1114
"test": "jest"
1215
},
1316
"homepage": "https://github.com/MicrosApp/MicroApp-CLI",
@@ -26,6 +29,7 @@
2629
"keywords": [
2730
"micro",
2831
"micro-app",
32+
"micro-application",
2933
"core",
3034
"cli"
3135
],
@@ -35,24 +39,24 @@
3539
},
3640
"license": "MIT",
3741
"devDependencies": {
38-
"@micro-app/core": "^0.1.7",
42+
"@micro-app/core": "^0.2.0",
3943
"@micro-app/plugin-koa-static-server": "^0.0.1",
40-
"@micro-app/plugin-koa-webpack-middleware": "^0.0.2",
41-
"@micro-app/plugin-webpack-adapter": "^0.0.5",
42-
"@types/jest": "^24.0.18",
44+
"@micro-app/plugin-koa-webpack-middleware": "^0.0.3",
45+
"@types/jest": "^24.0.19",
4346
"babel-eslint": "^10.0.3",
44-
"coveralls": "^3.0.6",
47+
"coveralls": "^3.0.7",
4548
"eslint": "^5.16.0",
4649
"eslint-config-2o3t": "^1.1.17",
50+
"husky": "^3.0.9",
4751
"jest": "^24.9.0",
52+
"lint-staged": "^9.4.2",
4853
"webpack": "^4.39.2"
4954
},
5055
"peerDependencies": {
51-
"@micro-app/core": ">=0.1.7",
52-
"@micro-app/plugin-webpack-adapter": "^0.0.5"
56+
"@micro-app/core": ">=0.2.0"
5357
},
5458
"dependencies": {
55-
"koa": "^2.8.1",
59+
"koa": "^2.10.0",
5660
"shelljs": "^0.8.3",
5761
"update-notifier": "^3.0.1",
5862
"yargs-parser": "^13.1.1"

plugins/commands/init/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Examples:
3535

3636
function initMicro(api, args) {
3737
const logger = api.logger;
38-
const config = api.self;
38+
const config = api.selfConfig;
3939
const micros = api.micros;
4040
const microsConfig = api.microsConfig;
4141

plugins/commands/serve/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ module.exports = function serveCommand(api, opts) {
99
const chalk = require('chalk');
1010

1111
api.beforeServer(params => {
12-
api.applyPluginHooks('beforeDevServer', params);
12+
return api.applyPluginHooks('beforeDevServer', params);
1313
});
1414

1515
api.afterServer(params => {
16-
api.applyPluginHooks('afterDevServer', params);
16+
return api.applyPluginHooks('afterDevServer', params);
1717
});
1818

1919
// serve
@@ -37,7 +37,7 @@ Examples:
3737
micro-app serve --type vusion --open-soft-link
3838
`.trim(),
3939
}, args => {
40-
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
40+
process.env.NODE_ENV = args.mode || process.env.NODE_ENV || 'development';
4141

4242
const runServe = require('../start/serve');
4343
return runServe(api, args, opts);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ describe('Command serve', () => {
5656
expect(app).not.toBeUndefined();
5757
expect(app).not.toBeNull();
5858
});
59+
plugin._api.onServerInitWillDone(({ args, app }) => {
60+
expect(args).not.toBeUndefined();
61+
expect(args).not.toBeNull();
62+
expect(app).not.toBeUndefined();
63+
expect(app).not.toBeNull();
64+
});
5965
plugin._api.onServerInitDone(({ args, app }) => {
6066
expect(args).not.toBeUndefined();
6167
expect(args).not.toBeNull();
@@ -130,4 +136,15 @@ describe('Command serve', () => {
130136

131137
});
132138

139+
it('global cmd config', async () => {
140+
141+
const { service } = require('../../../bin/base');
142+
143+
await service.run('serve', Object.assign({
144+
openSoftLink: true,
145+
openDisabledEntry: true,
146+
}, getArgvs()));
147+
148+
});
149+
133150
});

0 commit comments

Comments
 (0)