Skip to content

Commit ebd8991

Browse files
committed
chore: update deps
1 parent 2850768 commit ebd8991

File tree

5 files changed

+106
-54
lines changed

5 files changed

+106
-54
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"webpack": "^4.42.1"
4646
},
4747
"dependencies": {
48-
"@micro-app/cli": "^0.3.12",
48+
"@micro-app/cli": "^0.3.13",
4949
"@micro-app/plugin-webpack": "^0.0.11"
5050
}
5151
}

src/index.js

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
11
'use strict';
22

33
const chainConfig = require('./service/chainConfig');
4-
const createService = require('./utils/createService');
4+
const silentService = require('./utils/silentService');
55
const { BUILT_IN } = require('./constants');
66

77
module.exports = function(api, vueConfig) {
8-
const service = createService();
9-
10-
// 注册插件
11-
service.registerPlugin({
12-
id: 'vue-cli-plugin:plugin-modifyVueConfig-apply',
13-
[BUILT_IN]: true,
14-
apply(_api) {
15-
// 修改默认配置
16-
_api.onInitDone(() => {
17-
const newVueConfig = _api.applyPluginHooks('modifyVueConfig', vueConfig);
18-
Object.assign(vueConfig, newVueConfig || {});
8+
if (api.__isMicroAppPluginAPI) { // micro-app plugin
9+
const registerMethod = require('./utils/registerMethod');
10+
registerMethod(api);
11+
} else { // vue-cli plugin
12+
const config = silentService(service => {
13+
// 注册插件
14+
service.registerPlugin({
15+
id: 'vue-cli-plugin:plugin-modifyVueConfig-apply',
16+
[BUILT_IN]: true,
17+
apply(_api) {
18+
// 修改默认配置
19+
_api.onInitDone(() => {
20+
const newVueConfig = _api.applyPluginHooks('modifyVueConfig', vueConfig);
21+
Object.assign(vueConfig, newVueConfig || {});
22+
});
23+
},
1924
});
20-
},
21-
});
2225

23-
// 加载获取所有配置
24-
service.initSync();
25-
const config = service.config;
26+
// 加载获取所有配置
27+
service.initSync();
28+
return service.config;
29+
});
2630

27-
return chainConfig(api, vueConfig, config);
31+
return chainConfig(api, vueConfig, config);
32+
}
2833
};
29-
30-
// 外部服务提前注册方法
31-
module.exports.registerMethod = require('./utils/registerMethod');

src/service/chainConfig.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

3-
const { _, tryRequire, fs } = require('@micro-app/shared-utils');
4-
const createService = require('../utils/createService');
3+
const { _, tryRequire, fs, logger } = require('@micro-app/shared-utils');
4+
const silentService = require('../utils/silentService');
55
const { BUILT_IN } = require('../constants');
66

77
// 以 vue-cli 配置为主
@@ -68,7 +68,7 @@ module.exports = function chainDefault(api, vueConfig, options) {
6868
};
6969
}) ]);
7070
} else {
71-
api.logger.warn('[webpack]', 'Not Found "copy-webpack-plugin"');
71+
logger.warn('[webpack]', 'Not Found "copy-webpack-plugin"');
7272
}
7373
}
7474

@@ -77,24 +77,24 @@ module.exports = function chainDefault(api, vueConfig, options) {
7777

7878
// webpack 所有配置合入
7979
api.chainWebpack(webpackChain => {
80-
const service = createService();
81-
80+
return silentService(service => {
8281
// 注册插件
83-
service.registerPlugin({
84-
id: 'vue-cli-plugin:plugin-command-return-webpack-chain',
85-
[BUILT_IN]: true,
86-
apply(_api) {
87-
_api.registerCommand('return-webpack-chain', {
88-
description: 'return config of webpack-chain.',
89-
usage: 'micro-app return-webpack-chain',
90-
}, () => {
91-
_api.createChainWebpackConfigInstance(webpackChain);
92-
return _api.resolveChainableWebpackConfig();
93-
});
94-
},
95-
});
82+
service.registerPlugin({
83+
id: 'vue-cli-plugin:plugin-command-return-webpack-chain',
84+
[BUILT_IN]: true,
85+
apply(_api) {
86+
_api.registerCommand('return-webpack-chain', {
87+
description: 'return config of webpack-chain.',
88+
usage: 'micro-app return-webpack-chain',
89+
}, () => {
90+
_api.createChainWebpackConfigInstance(webpackChain);
91+
return _api.resolveChainableWebpackConfig();
92+
});
93+
},
94+
});
9695

97-
// 同步扩充 webpack-chain config
98-
return service.runSync('return-webpack-chain');
96+
// 同步扩充 webpack-chain config
97+
return service.runSync('return-webpack-chain');
98+
});
9999
});
100100
};
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
'use strict';
22

3+
const { _, logger } = require('@micro-app/shared-utils');
34
const { createService } = require('@micro-app/cli');
45
const { SKIP_TARGET, BUILT_IN } = require('../constants');
56

6-
module.exports = function() {
7+
// 无日志服务
8+
module.exports = function silentService(cb) {
9+
// record
10+
const ORIGINAL_LEVEL = logger.level;
11+
logger.level = 'error';
12+
713
const service = createService({ target: SKIP_TARGET });
814

915
const WEBPACK_PLUGIN_ID = '@micro-app/plugin-webpack';
@@ -15,5 +21,9 @@ module.exports = function() {
1521
});
1622
}
1723

18-
return service;
24+
const result = _.isFunction(cb) && cb(service);
25+
26+
// recovery
27+
logger.level = ORIGINAL_LEVEL;
28+
return result;
1929
};

yarn.lock

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -323,22 +323,22 @@
323323
dependencies:
324324
sourcemap-codec "^1.4.4"
325325

326-
"@micro-app/cli@^0.3.12":
327-
version "0.3.12"
328-
resolved "https://registry.yarnpkg.com/@micro-app/cli/-/cli-0.3.12.tgz#6fde028d5aa0a66d6a84009ca80c922b61882f7f"
329-
integrity sha512-VR6m+abGKpsWwlVfbGqSG/gKD6xxSL9yRuNKvhYorIdIBOCaYb7ksNiq/9YFeLGVxlaKeBXl0fpSAGRIoD9DiA==
326+
"@micro-app/cli@^0.3.13":
327+
version "0.3.13"
328+
resolved "https://registry.yarnpkg.com/@micro-app/cli/-/cli-0.3.13.tgz#0459c31e738795272c3d3d136958b5aa38c9b1f5"
329+
integrity sha512-itUAu2OIccz/Cb/LNBfo1et5rEDRJRkd9gqhnhagdN5bbW/YHBdPZebWqtvIsJxvtXnRCzAJLTQwBR6ZnF/fyw==
330330
dependencies:
331-
"@micro-app/core" "^0.3.21"
331+
"@micro-app/core" "^0.3.22"
332332
"@zkochan/cmd-shim" "^4.3.0"
333333
read-cmd-shim "^2.0.0"
334334
update-notifier "^4.1.0"
335335

336-
"@micro-app/core@^0.3.21":
337-
version "0.3.21"
338-
resolved "https://registry.yarnpkg.com/@micro-app/core/-/core-0.3.21.tgz#43315fa1713580d7500900f5ef90e183b9455b56"
339-
integrity sha512-k7KOtQ6pxJbRAaMW8xF3jmuJxOQXjHXLCHtLNayU3ma1SNxOTGBbGbF7VyOBoo7V1sGlC40UjMaMJiqfvdE5lw==
336+
"@micro-app/core@^0.3.22":
337+
version "0.3.22"
338+
resolved "https://registry.yarnpkg.com/@micro-app/core/-/core-0.3.22.tgz#acbe705b363f754da81470cf33c4b92d1f8b5fc6"
339+
integrity sha512-Jr/eREz19m34ROb5e8a18MV02uI9mIz0WQStAucaK5Y4pZVh2+uN/IFpd11UudcCvPGAQoT8Z0f7Ov00dgYb4Q==
340340
dependencies:
341-
"@micro-app/shared-utils" "^0.1.16"
341+
"@micro-app/shared-utils" "^0.1.17"
342342
dotenv "^8.2.0"
343343
dotenv-expand "^5.1.0"
344344

@@ -423,6 +423,46 @@
423423
yargs-parser "^18.1.1"
424424
yargs-unparser "^1.5.0"
425425

426+
"@micro-app/shared-utils@^0.1.17":
427+
version "0.1.17"
428+
resolved "https://registry.yarnpkg.com/@micro-app/shared-utils/-/shared-utils-0.1.17.tgz#e99b9aa4385cf4eefe5f96f0f553162ab9342743"
429+
integrity sha512-XI1uFnvjPaFZvLLMoARZeUqUya2i2z4aJ1oT23bahQL+5dHgXj2p1o/1agJ7G0K1KStasLRjPXNuHEpBpK1Weg==
430+
dependencies:
431+
ajv "^6.10.2"
432+
ajv-keywords "^3.4.1"
433+
assert "^2.0.0"
434+
chalk "^3.0.0"
435+
cheerio "^1.0.0-rc.3"
436+
debug "^4.1.1"
437+
dedent "^0.7.0"
438+
execa "^3.4.0"
439+
fs-extra "^8.1.0"
440+
git-url-parse "^11.1.2"
441+
glob-parent "^5.1.0"
442+
globby "^10.0.2"
443+
hash-sum "^2.0.0"
444+
import-fresh "^3.2.1"
445+
inquirer "^7.1.0"
446+
is-glob "^4.0.1"
447+
lodash "^4.17.15"
448+
lru-cache "^5.1.1"
449+
multimatch "^4.0.0"
450+
npm-package-arg "^6.1.1"
451+
npmlog "^4.1.2"
452+
open "^7.0.3"
453+
ora "^3.4.0"
454+
parse-json "^5.0.0"
455+
semver "^6.3.0"
456+
semver-regex "^3.1.1"
457+
shelljs "^0.8.3"
458+
signal-exit "^3.0.2"
459+
stream-to-string "^1.2.0"
460+
stringify-object "^3.3.0"
461+
try-require "^1.2.1"
462+
yaml "^1.8.2"
463+
yargs-parser "^18.1.1"
464+
yargs-unparser "^1.5.0"
465+
426466
"@nodelib/[email protected]":
427467
version "2.1.3"
428468
resolved "https://registry.npm.taobao.org/@nodelib/fs.scandir/download/@nodelib/fs.scandir-2.1.3.tgz#3a582bdb53804c6ba6d146579c46e52130cf4a3b"

0 commit comments

Comments
 (0)