@tarojs/service 3.4.4 → 3.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Kernel.d.ts +0 -1
- package/dist/Kernel.js +16 -18
- package/package.json +5 -5
- package/src/Kernel.ts +21 -15
package/dist/Kernel.d.ts
CHANGED
package/dist/Kernel.js
CHANGED
|
@@ -15,7 +15,6 @@ const lodash_1 = require("lodash");
|
|
|
15
15
|
const tapable_1 = require("tapable");
|
|
16
16
|
const helper_1 = require("@tarojs/helper");
|
|
17
17
|
const helper = require("@tarojs/helper");
|
|
18
|
-
const joi = require("@hapi/joi");
|
|
19
18
|
const constants_1 = require("./utils/constants");
|
|
20
19
|
const utils_1 = require("./utils");
|
|
21
20
|
const Plugin_1 = require("./Plugin");
|
|
@@ -23,7 +22,7 @@ const Config_1 = require("./Config");
|
|
|
23
22
|
class Kernel extends events_1.EventEmitter {
|
|
24
23
|
constructor(options) {
|
|
25
24
|
super();
|
|
26
|
-
this.debugger = helper_1.createDebug('Taro:Kernel');
|
|
25
|
+
this.debugger = process.env.DEBUG === 'Taro:Kernel' ? helper_1.createDebug('Taro:Kernel') : function () { };
|
|
27
26
|
this.appPath = options.appPath || process.cwd();
|
|
28
27
|
this.optsPresets = options.presets;
|
|
29
28
|
this.optsPlugins = options.plugins;
|
|
@@ -32,15 +31,8 @@ class Kernel extends events_1.EventEmitter {
|
|
|
32
31
|
this.commands = new Map();
|
|
33
32
|
this.platforms = new Map();
|
|
34
33
|
this.initHelper();
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
this.debugger('init');
|
|
39
|
-
this.initConfig();
|
|
40
|
-
this.initPaths();
|
|
41
|
-
this.initPresetsAndPlugins();
|
|
42
|
-
yield this.applyPlugins('onReady');
|
|
43
|
-
});
|
|
34
|
+
this.initConfig();
|
|
35
|
+
this.initPaths();
|
|
44
36
|
}
|
|
45
37
|
initConfig() {
|
|
46
38
|
this.config = new Config_1.default({
|
|
@@ -123,6 +115,7 @@ class Kernel extends events_1.EventEmitter {
|
|
|
123
115
|
if (typeof pluginCtx.optsSchema !== 'function') {
|
|
124
116
|
return;
|
|
125
117
|
}
|
|
118
|
+
const joi = require('@hapi/joi');
|
|
126
119
|
const schema = pluginCtx.optsSchema(joi);
|
|
127
120
|
if (!joi.isSchema(schema)) {
|
|
128
121
|
throw new Error(`插件${pluginCtx.id}中设置参数检查 schema 有误,请检查!`);
|
|
@@ -198,6 +191,9 @@ class Kernel extends events_1.EventEmitter {
|
|
|
198
191
|
throw new Error('调用失败,未传入正确的名称!');
|
|
199
192
|
}
|
|
200
193
|
const hooks = this.hooks.get(name) || [];
|
|
194
|
+
if (!hooks.length) {
|
|
195
|
+
return yield initialVal;
|
|
196
|
+
}
|
|
201
197
|
const waterfall = new tapable_1.AsyncSeriesWaterfallHook(['arg']);
|
|
202
198
|
if (hooks.length) {
|
|
203
199
|
const resArr = [];
|
|
@@ -261,7 +257,9 @@ class Kernel extends events_1.EventEmitter {
|
|
|
261
257
|
this.debugger('command:runOpts');
|
|
262
258
|
this.debugger(`command:runOpts:${JSON.stringify(opts, null, 2)}`);
|
|
263
259
|
this.setRunOpts(opts);
|
|
264
|
-
|
|
260
|
+
this.debugger('initPresetsAndPlugins');
|
|
261
|
+
this.initPresetsAndPlugins();
|
|
262
|
+
yield this.applyPlugins('onReady');
|
|
265
263
|
this.debugger('command:onStart');
|
|
266
264
|
yield this.applyPlugins('onStart');
|
|
267
265
|
if (!this.commands.has(name)) {
|
|
@@ -272,13 +270,13 @@ class Kernel extends events_1.EventEmitter {
|
|
|
272
270
|
}
|
|
273
271
|
if ((_a = opts === null || opts === void 0 ? void 0 : opts.options) === null || _a === void 0 ? void 0 : _a.platform) {
|
|
274
272
|
opts.config = this.runWithPlatform(opts.options.platform);
|
|
273
|
+
yield this.applyPlugins({
|
|
274
|
+
name: 'modifyRunnerOpts',
|
|
275
|
+
opts: {
|
|
276
|
+
opts: opts === null || opts === void 0 ? void 0 : opts.config
|
|
277
|
+
}
|
|
278
|
+
});
|
|
275
279
|
}
|
|
276
|
-
yield this.applyPlugins({
|
|
277
|
-
name: 'modifyRunnerOpts',
|
|
278
|
-
opts: {
|
|
279
|
-
opts: opts === null || opts === void 0 ? void 0 : opts.config
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
280
|
yield this.applyPlugins({
|
|
283
281
|
name,
|
|
284
282
|
opts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/service",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.5",
|
|
4
4
|
"description": "Taro Service",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
"homepage": "https://github.com/NervJS/taro#readme",
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@hapi/joi": "17.1.1",
|
|
37
|
-
"@tarojs/helper": "3.4.
|
|
38
|
-
"@tarojs/shared": "3.4.
|
|
39
|
-
"@tarojs/taro": "3.4.
|
|
37
|
+
"@tarojs/helper": "3.4.5",
|
|
38
|
+
"@tarojs/shared": "3.4.5",
|
|
39
|
+
"@tarojs/taro": "3.4.5",
|
|
40
40
|
"fs-extra": "^8.0.1",
|
|
41
41
|
"lodash": "^4.17.21",
|
|
42
42
|
"resolve": "^1.6.0",
|
|
43
43
|
"tapable": "^1.1.3",
|
|
44
44
|
"webpack-merge": "^4.2.2"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "789e873f7b9477124b44a900cd4f6a2810e4e06a"
|
|
47
47
|
}
|
package/src/Kernel.ts
CHANGED
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
createDebug
|
|
11
11
|
} from '@tarojs/helper'
|
|
12
12
|
import * as helper from '@tarojs/helper'
|
|
13
|
-
import * as joi from '@hapi/joi'
|
|
14
13
|
|
|
15
14
|
import {
|
|
16
15
|
IPreset,
|
|
@@ -58,7 +57,7 @@ export default class Kernel extends EventEmitter {
|
|
|
58
57
|
|
|
59
58
|
constructor (options: IKernelOptions) {
|
|
60
59
|
super()
|
|
61
|
-
this.debugger = createDebug('Taro:Kernel')
|
|
60
|
+
this.debugger = process.env.DEBUG === 'Taro:Kernel' ? createDebug('Taro:Kernel') : function () {}
|
|
62
61
|
this.appPath = options.appPath || process.cwd()
|
|
63
62
|
this.optsPresets = options.presets
|
|
64
63
|
this.optsPlugins = options.plugins
|
|
@@ -67,14 +66,8 @@ export default class Kernel extends EventEmitter {
|
|
|
67
66
|
this.commands = new Map()
|
|
68
67
|
this.platforms = new Map()
|
|
69
68
|
this.initHelper()
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async init () {
|
|
73
|
-
this.debugger('init')
|
|
74
69
|
this.initConfig()
|
|
75
70
|
this.initPaths()
|
|
76
|
-
this.initPresetsAndPlugins()
|
|
77
|
-
await this.applyPlugins('onReady')
|
|
78
71
|
}
|
|
79
72
|
|
|
80
73
|
initConfig () {
|
|
@@ -167,6 +160,7 @@ export default class Kernel extends EventEmitter {
|
|
|
167
160
|
if (typeof pluginCtx.optsSchema !== 'function') {
|
|
168
161
|
return
|
|
169
162
|
}
|
|
163
|
+
const joi = require('@hapi/joi')
|
|
170
164
|
const schema = pluginCtx.optsSchema(joi)
|
|
171
165
|
if (!joi.isSchema(schema)) {
|
|
172
166
|
throw new Error(`插件${pluginCtx.id}中设置参数检查 schema 有误,请检查!`)
|
|
@@ -243,6 +237,9 @@ export default class Kernel extends EventEmitter {
|
|
|
243
237
|
throw new Error('调用失败,未传入正确的名称!')
|
|
244
238
|
}
|
|
245
239
|
const hooks = this.hooks.get(name) || []
|
|
240
|
+
if (!hooks.length) {
|
|
241
|
+
return await initialVal
|
|
242
|
+
}
|
|
246
243
|
const waterfall = new AsyncSeriesWaterfallHook(['arg'])
|
|
247
244
|
if (hooks.length) {
|
|
248
245
|
const resArr: any[] = []
|
|
@@ -306,24 +303,33 @@ export default class Kernel extends EventEmitter {
|
|
|
306
303
|
this.debugger('command:runOpts')
|
|
307
304
|
this.debugger(`command:runOpts:${JSON.stringify(opts, null, 2)}`)
|
|
308
305
|
this.setRunOpts(opts)
|
|
309
|
-
|
|
306
|
+
|
|
307
|
+
this.debugger('initPresetsAndPlugins')
|
|
308
|
+
this.initPresetsAndPlugins()
|
|
309
|
+
|
|
310
|
+
await this.applyPlugins('onReady')
|
|
311
|
+
|
|
310
312
|
this.debugger('command:onStart')
|
|
311
313
|
await this.applyPlugins('onStart')
|
|
314
|
+
|
|
312
315
|
if (!this.commands.has(name)) {
|
|
313
316
|
throw new Error(`${name} 命令不存在`)
|
|
314
317
|
}
|
|
318
|
+
|
|
315
319
|
if (opts?.isHelp) {
|
|
316
320
|
return this.runHelp(name)
|
|
317
321
|
}
|
|
322
|
+
|
|
318
323
|
if (opts?.options?.platform) {
|
|
319
324
|
opts.config = this.runWithPlatform(opts.options.platform)
|
|
325
|
+
await this.applyPlugins({
|
|
326
|
+
name: 'modifyRunnerOpts',
|
|
327
|
+
opts: {
|
|
328
|
+
opts: opts?.config
|
|
329
|
+
}
|
|
330
|
+
})
|
|
320
331
|
}
|
|
321
|
-
|
|
322
|
-
name: 'modifyRunnerOpts',
|
|
323
|
-
opts: {
|
|
324
|
-
opts: opts?.config
|
|
325
|
-
}
|
|
326
|
-
})
|
|
332
|
+
|
|
327
333
|
await this.applyPlugins({
|
|
328
334
|
name,
|
|
329
335
|
opts
|