@modern-js/plugin-swc 2.0.0-beta.2 → 2.0.0-beta.4
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/CHANGELOG.md +72 -0
- package/package.json +10 -10
- package/dist/bin.d.ts +0 -2
- package/dist/bin.js +0 -38
- package/dist/config/createLoadedConfig.d.ts +0 -6
- package/dist/config/createLoadedConfig.js +0 -35
- package/dist/config/createResolvedConfig.d.ts +0 -3
- package/dist/config/createResolvedConfig.js +0 -91
- package/dist/config/defaults.d.ts +0 -29
- package/dist/config/defaults.js +0 -110
- package/dist/config/index.d.ts +0 -2
- package/dist/config/index.js +0 -18
- package/dist/config/mergeConfig.d.ts +0 -32
- package/dist/config/mergeConfig.js +0 -39
- package/dist/config/schema/deploy.d.ts +0 -16
- package/dist/config/schema/deploy.js +0 -16
- package/dist/config/schema/index.d.ts +0 -499
- package/dist/config/schema/index.js +0 -94
- package/dist/config/schema/output.d.ts +0 -146
- package/dist/config/schema/output.js +0 -68
- package/dist/config/schema/server.d.ts +0 -194
- package/dist/config/schema/server.js +0 -111
- package/dist/config/schema/source.d.ts +0 -64
- package/dist/config/schema/source.js +0 -38
- package/dist/config/schema/tools.d.ts +0 -51
- package/dist/config/schema/tools.js +0 -24
- package/dist/config/types/electron.d.ts +0 -13
- package/dist/config/types/electron.js +0 -2
- package/dist/config/types/index.d.ts +0 -260
- package/dist/config/types/index.js +0 -2
- package/dist/config/types/less.d.ts +0 -12
- package/dist/config/types/less.js +0 -2
- package/dist/config/types/postcss.d.ts +0 -28
- package/dist/config/types/postcss.js +0 -2
- package/dist/config/types/sass.d.ts +0 -10
- package/dist/config/types/sass.js +0 -2
- package/dist/config/types/ssg.d.ts +0 -15
- package/dist/config/types/ssg.js +0 -2
- package/dist/config/types/test.d.ts +0 -14
- package/dist/config/types/test.js +0 -2
- package/dist/config/types/ts-loader.d.ts +0 -23
- package/dist/config/types/ts-loader.js +0 -2
- package/dist/context.d.ts +0 -34
- package/dist/context.js +0 -60
- package/dist/initWatcher.d.ts +0 -3
- package/dist/initWatcher.js +0 -66
- package/dist/load-configs/index.d.ts +0 -34
- package/dist/load-configs/index.js +0 -124
- package/dist/loadEnv.d.ts +0 -1
- package/dist/loadEnv.js +0 -21
- package/dist/loadPlugins.d.ts +0 -16
- package/dist/loadPlugins.js +0 -60
- package/dist/manager.d.ts +0 -87
- package/dist/manager.js +0 -24
- package/dist/pluginAPI.d.ts +0 -13
- package/dist/pluginAPI.js +0 -16
- package/dist/schema/patchSchema.d.ts +0 -19
- package/dist/schema/patchSchema.js +0 -57
- package/dist/schema/source.d.ts +0 -9
- package/dist/schema/source.js +0 -10
- package/dist/schema/testing.d.ts +0 -13
- package/dist/schema/testing.js +0 -11
- package/dist/schema/traverseSchema.d.ts +0 -2
- package/dist/schema/traverseSchema.js +0 -20
- package/dist/types/cli.d.ts +0 -59
- package/dist/types/cli.js +0 -2
- package/dist/types/config/index.d.ts +0 -41
- package/dist/types/config/index.js +0 -2
- package/dist/types/config/testing.d.ts +0 -15
- package/dist/types/config/testing.js +0 -2
- package/dist/types/context.d.ts +0 -26
- package/dist/types/context.js +0 -2
- package/dist/types/hooks.d.ts +0 -26
- package/dist/types/hooks.js +0 -2
- package/dist/types/index.d.ts +0 -10
- package/dist/types/index.js +0 -21
- package/dist/types/plugin.d.ts +0 -26
- package/dist/types/plugin.js +0 -2
- package/dist/types/pluginAPI.d.ts +0 -18
- package/dist/types/pluginAPI.js +0 -2
- package/dist/utils/commander.d.ts +0 -4
- package/dist/utils/commander.js +0 -20
- package/dist/utils/mergeConfig.d.ts +0 -2
- package/dist/utils/mergeConfig.js +0 -32
- package/dist/utils/repeatKeyWarning.d.ts +0 -3
- package/dist/utils/repeatKeyWarning.js +0 -22
|
@@ -1,499 +0,0 @@
|
|
|
1
|
-
import type { JSONSchemaType } from '@modern-js/utils/ajv';
|
|
2
|
-
export interface PluginValidateSchema {
|
|
3
|
-
target: string;
|
|
4
|
-
schema: JSONSchemaType<any>;
|
|
5
|
-
}
|
|
6
|
-
export declare const patchSchema: (pluginSchemas: Array<PluginValidateSchema | PluginValidateSchema[]>) => {
|
|
7
|
-
type: string;
|
|
8
|
-
additionalProperties: boolean;
|
|
9
|
-
properties: {
|
|
10
|
-
source: {
|
|
11
|
-
type: string;
|
|
12
|
-
additionalProperties: boolean;
|
|
13
|
-
properties: {
|
|
14
|
-
entries: {
|
|
15
|
-
type: string;
|
|
16
|
-
patternProperties: {
|
|
17
|
-
"^[a-zA-Z0-9_-]+$": {
|
|
18
|
-
if: {
|
|
19
|
-
type: string;
|
|
20
|
-
};
|
|
21
|
-
then: {
|
|
22
|
-
required: string[];
|
|
23
|
-
properties: {
|
|
24
|
-
entry: {
|
|
25
|
-
type: string[];
|
|
26
|
-
};
|
|
27
|
-
disableMount: {
|
|
28
|
-
type: string;
|
|
29
|
-
};
|
|
30
|
-
enableFileSystemRoutes: {
|
|
31
|
-
type: string;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
additionalProperties: boolean;
|
|
35
|
-
};
|
|
36
|
-
else: {
|
|
37
|
-
type: string[];
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
preEntry: {
|
|
43
|
-
type: string[];
|
|
44
|
-
};
|
|
45
|
-
alias: {
|
|
46
|
-
typeof: string[];
|
|
47
|
-
};
|
|
48
|
-
enableAsyncEntry: {
|
|
49
|
-
type: string;
|
|
50
|
-
};
|
|
51
|
-
disableDefaultEntries: {
|
|
52
|
-
type: string;
|
|
53
|
-
};
|
|
54
|
-
envVars: {
|
|
55
|
-
type: string;
|
|
56
|
-
};
|
|
57
|
-
globalVars: {
|
|
58
|
-
type: string;
|
|
59
|
-
};
|
|
60
|
-
moduleScopes: {
|
|
61
|
-
instanceof: string[];
|
|
62
|
-
};
|
|
63
|
-
entriesDir: {
|
|
64
|
-
type: string;
|
|
65
|
-
};
|
|
66
|
-
configDir: {
|
|
67
|
-
type: string;
|
|
68
|
-
};
|
|
69
|
-
include: {
|
|
70
|
-
type: string[];
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
output: {
|
|
75
|
-
type: string;
|
|
76
|
-
additionalProperties: boolean;
|
|
77
|
-
properties: {
|
|
78
|
-
assetPrefix: {
|
|
79
|
-
type: string;
|
|
80
|
-
};
|
|
81
|
-
path: {
|
|
82
|
-
type: string;
|
|
83
|
-
};
|
|
84
|
-
jsPath: {
|
|
85
|
-
type: string;
|
|
86
|
-
};
|
|
87
|
-
cssPath: {
|
|
88
|
-
type: string;
|
|
89
|
-
};
|
|
90
|
-
htmlPath: {
|
|
91
|
-
type: string;
|
|
92
|
-
};
|
|
93
|
-
mediaPath: {
|
|
94
|
-
type: string;
|
|
95
|
-
};
|
|
96
|
-
mountId: {
|
|
97
|
-
type: string;
|
|
98
|
-
};
|
|
99
|
-
favicon: {
|
|
100
|
-
type: string;
|
|
101
|
-
};
|
|
102
|
-
faviconByEntries: {
|
|
103
|
-
type: string;
|
|
104
|
-
patternProperties: {
|
|
105
|
-
"^[a-zA-Z0-9_-]+$": {
|
|
106
|
-
type: string;
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
title: {
|
|
111
|
-
type: string;
|
|
112
|
-
};
|
|
113
|
-
titleByEntries: {
|
|
114
|
-
type: string;
|
|
115
|
-
patternProperties: {
|
|
116
|
-
"^[a-zA-Z0-9_-]+$": {
|
|
117
|
-
type: string;
|
|
118
|
-
};
|
|
119
|
-
};
|
|
120
|
-
};
|
|
121
|
-
meta: {
|
|
122
|
-
type: string;
|
|
123
|
-
};
|
|
124
|
-
metaByEntries: {
|
|
125
|
-
type: string;
|
|
126
|
-
patternProperties: {
|
|
127
|
-
"^[a-zA-Z0-9_-]+$": {
|
|
128
|
-
type: string;
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
};
|
|
132
|
-
inject: {
|
|
133
|
-
enum: (string | boolean)[];
|
|
134
|
-
};
|
|
135
|
-
injectByEntries: {
|
|
136
|
-
type: string;
|
|
137
|
-
patternProperties: {
|
|
138
|
-
"^[a-zA-Z0-9_-]+$": {
|
|
139
|
-
enum: (string | boolean)[];
|
|
140
|
-
};
|
|
141
|
-
};
|
|
142
|
-
};
|
|
143
|
-
copy: {
|
|
144
|
-
type: string;
|
|
145
|
-
};
|
|
146
|
-
scriptExt: {
|
|
147
|
-
type: string;
|
|
148
|
-
};
|
|
149
|
-
disableTsChecker: {
|
|
150
|
-
type: string;
|
|
151
|
-
};
|
|
152
|
-
disableHtmlFolder: {
|
|
153
|
-
type: string;
|
|
154
|
-
};
|
|
155
|
-
disableCssModuleExtension: {
|
|
156
|
-
type: string;
|
|
157
|
-
};
|
|
158
|
-
disableCssExtract: {
|
|
159
|
-
type: string;
|
|
160
|
-
};
|
|
161
|
-
enableCssModuleTSDeclaration: {
|
|
162
|
-
type: string;
|
|
163
|
-
};
|
|
164
|
-
disableMinimize: {
|
|
165
|
-
type: string;
|
|
166
|
-
};
|
|
167
|
-
enableInlineStyles: {
|
|
168
|
-
type: string;
|
|
169
|
-
};
|
|
170
|
-
enableInlineScripts: {
|
|
171
|
-
type: string;
|
|
172
|
-
};
|
|
173
|
-
disableSourceMap: {
|
|
174
|
-
type: string;
|
|
175
|
-
};
|
|
176
|
-
disableInlineRuntimeChunk: {
|
|
177
|
-
type: string;
|
|
178
|
-
};
|
|
179
|
-
disableAssetsCache: {
|
|
180
|
-
type: string;
|
|
181
|
-
};
|
|
182
|
-
enableLatestDecorators: {
|
|
183
|
-
type: string;
|
|
184
|
-
};
|
|
185
|
-
enableTsLoader: {
|
|
186
|
-
type: string;
|
|
187
|
-
};
|
|
188
|
-
dataUriLimit: {
|
|
189
|
-
type: string;
|
|
190
|
-
};
|
|
191
|
-
templateParameters: {
|
|
192
|
-
type: string;
|
|
193
|
-
};
|
|
194
|
-
templateParametersByEntries: {
|
|
195
|
-
type: string;
|
|
196
|
-
patternProperties: {
|
|
197
|
-
"^[a-zA-Z0-9_-]+$": {
|
|
198
|
-
type: string;
|
|
199
|
-
};
|
|
200
|
-
};
|
|
201
|
-
};
|
|
202
|
-
polyfill: {
|
|
203
|
-
type: string;
|
|
204
|
-
enum: string[];
|
|
205
|
-
};
|
|
206
|
-
cssModuleLocalIdentName: {
|
|
207
|
-
type: string;
|
|
208
|
-
};
|
|
209
|
-
federation: {
|
|
210
|
-
type: string;
|
|
211
|
-
};
|
|
212
|
-
disableNodePolyfill: {
|
|
213
|
-
type: string;
|
|
214
|
-
};
|
|
215
|
-
enableModernMode: {
|
|
216
|
-
type: string;
|
|
217
|
-
};
|
|
218
|
-
};
|
|
219
|
-
};
|
|
220
|
-
server: {
|
|
221
|
-
type: string;
|
|
222
|
-
additionalProperties: boolean;
|
|
223
|
-
properties: {
|
|
224
|
-
port: {
|
|
225
|
-
type: string;
|
|
226
|
-
};
|
|
227
|
-
ssr: {
|
|
228
|
-
if: {
|
|
229
|
-
type: string;
|
|
230
|
-
};
|
|
231
|
-
then: {
|
|
232
|
-
properties: {
|
|
233
|
-
disableLoadable: {
|
|
234
|
-
type: string;
|
|
235
|
-
};
|
|
236
|
-
disableHelmet: {
|
|
237
|
-
type: string;
|
|
238
|
-
};
|
|
239
|
-
disableRedirect: {
|
|
240
|
-
type: string;
|
|
241
|
-
};
|
|
242
|
-
enableAsyncData: {
|
|
243
|
-
type: string;
|
|
244
|
-
};
|
|
245
|
-
enableProductWarning: {
|
|
246
|
-
type: string;
|
|
247
|
-
};
|
|
248
|
-
timeout: {
|
|
249
|
-
type: string;
|
|
250
|
-
};
|
|
251
|
-
asyncDataTimeout: {
|
|
252
|
-
type: string;
|
|
253
|
-
};
|
|
254
|
-
};
|
|
255
|
-
};
|
|
256
|
-
else: {
|
|
257
|
-
type: string;
|
|
258
|
-
};
|
|
259
|
-
};
|
|
260
|
-
ssrByEntries: {
|
|
261
|
-
type: string;
|
|
262
|
-
patternProperties: {
|
|
263
|
-
"^[a-zA-Z0-9_-]+$": {
|
|
264
|
-
if: {
|
|
265
|
-
type: string;
|
|
266
|
-
};
|
|
267
|
-
then: {
|
|
268
|
-
properties: {
|
|
269
|
-
disableLoadable: {
|
|
270
|
-
type: string;
|
|
271
|
-
};
|
|
272
|
-
disableHelmet: {
|
|
273
|
-
type: string;
|
|
274
|
-
};
|
|
275
|
-
disableRedirect: {
|
|
276
|
-
type: string;
|
|
277
|
-
};
|
|
278
|
-
enableProductWarning: {
|
|
279
|
-
type: string;
|
|
280
|
-
};
|
|
281
|
-
enableAsyncData: {
|
|
282
|
-
type: string;
|
|
283
|
-
};
|
|
284
|
-
timeout: {
|
|
285
|
-
type: string;
|
|
286
|
-
};
|
|
287
|
-
asyncDataTimeout: {
|
|
288
|
-
type: string;
|
|
289
|
-
};
|
|
290
|
-
};
|
|
291
|
-
additionalProperties: boolean;
|
|
292
|
-
};
|
|
293
|
-
else: {
|
|
294
|
-
type: string;
|
|
295
|
-
};
|
|
296
|
-
};
|
|
297
|
-
};
|
|
298
|
-
};
|
|
299
|
-
routes: {
|
|
300
|
-
type: string;
|
|
301
|
-
patternProperties: {
|
|
302
|
-
"^[a-zA-Z0-9_-]+$": {
|
|
303
|
-
if: {
|
|
304
|
-
type: string;
|
|
305
|
-
};
|
|
306
|
-
then: {
|
|
307
|
-
properties: {
|
|
308
|
-
route: {
|
|
309
|
-
oneOf: ({
|
|
310
|
-
type: string;
|
|
311
|
-
properties: {
|
|
312
|
-
path: {
|
|
313
|
-
type: string;
|
|
314
|
-
};
|
|
315
|
-
headers: {
|
|
316
|
-
type: string;
|
|
317
|
-
};
|
|
318
|
-
};
|
|
319
|
-
additionalProperties: boolean;
|
|
320
|
-
} | {
|
|
321
|
-
type: string;
|
|
322
|
-
items?: undefined;
|
|
323
|
-
} | {
|
|
324
|
-
type: string;
|
|
325
|
-
items: {
|
|
326
|
-
oneOf: ({
|
|
327
|
-
type: string;
|
|
328
|
-
properties: {
|
|
329
|
-
path: {
|
|
330
|
-
type: string;
|
|
331
|
-
};
|
|
332
|
-
headers: {
|
|
333
|
-
type: string;
|
|
334
|
-
};
|
|
335
|
-
};
|
|
336
|
-
additionalProperties: boolean;
|
|
337
|
-
} | {
|
|
338
|
-
type: string;
|
|
339
|
-
})[];
|
|
340
|
-
};
|
|
341
|
-
})[];
|
|
342
|
-
};
|
|
343
|
-
disableSpa: {
|
|
344
|
-
type: string;
|
|
345
|
-
};
|
|
346
|
-
resHeaders: {
|
|
347
|
-
type: string;
|
|
348
|
-
};
|
|
349
|
-
};
|
|
350
|
-
additionalProperties: boolean;
|
|
351
|
-
};
|
|
352
|
-
else: {
|
|
353
|
-
oneOf: ({
|
|
354
|
-
type: string;
|
|
355
|
-
items?: undefined;
|
|
356
|
-
} | {
|
|
357
|
-
type: string;
|
|
358
|
-
items: {
|
|
359
|
-
type: string;
|
|
360
|
-
};
|
|
361
|
-
})[];
|
|
362
|
-
};
|
|
363
|
-
};
|
|
364
|
-
};
|
|
365
|
-
};
|
|
366
|
-
publicRoutes: {
|
|
367
|
-
type: string;
|
|
368
|
-
patternProperties: {
|
|
369
|
-
"^[a-zA-Z0-9_-]+$": {
|
|
370
|
-
type: string[];
|
|
371
|
-
};
|
|
372
|
-
};
|
|
373
|
-
};
|
|
374
|
-
baseUrl: {
|
|
375
|
-
oneOf: ({
|
|
376
|
-
type: string;
|
|
377
|
-
items?: undefined;
|
|
378
|
-
} | {
|
|
379
|
-
type: string;
|
|
380
|
-
items: {
|
|
381
|
-
type: string;
|
|
382
|
-
}[];
|
|
383
|
-
})[];
|
|
384
|
-
};
|
|
385
|
-
middleware: {
|
|
386
|
-
instanceof: string[];
|
|
387
|
-
};
|
|
388
|
-
renderHook: {
|
|
389
|
-
instanceof: string;
|
|
390
|
-
};
|
|
391
|
-
logger: {
|
|
392
|
-
type: string[];
|
|
393
|
-
};
|
|
394
|
-
metrics: {
|
|
395
|
-
type: string[];
|
|
396
|
-
};
|
|
397
|
-
proxy: {
|
|
398
|
-
type: string;
|
|
399
|
-
};
|
|
400
|
-
enableMicroFrontendDebug: {
|
|
401
|
-
type: string;
|
|
402
|
-
};
|
|
403
|
-
disableFrameworkExt: {
|
|
404
|
-
type: string;
|
|
405
|
-
};
|
|
406
|
-
watchOptions: {
|
|
407
|
-
type: string;
|
|
408
|
-
};
|
|
409
|
-
compiler: {
|
|
410
|
-
type: string;
|
|
411
|
-
};
|
|
412
|
-
};
|
|
413
|
-
};
|
|
414
|
-
deploy: {
|
|
415
|
-
type: string;
|
|
416
|
-
properties: {
|
|
417
|
-
domain: {
|
|
418
|
-
type: string[];
|
|
419
|
-
};
|
|
420
|
-
domainByEntries: {
|
|
421
|
-
type: string;
|
|
422
|
-
patternProperties: {
|
|
423
|
-
"^[a-zA-Z0-9_-]+$": {
|
|
424
|
-
type: string[];
|
|
425
|
-
};
|
|
426
|
-
};
|
|
427
|
-
};
|
|
428
|
-
};
|
|
429
|
-
};
|
|
430
|
-
plugins: {
|
|
431
|
-
type: string;
|
|
432
|
-
additionalProperties: boolean;
|
|
433
|
-
};
|
|
434
|
-
dev: {
|
|
435
|
-
type: string;
|
|
436
|
-
properties: {
|
|
437
|
-
assetPrefix: {
|
|
438
|
-
type: string[];
|
|
439
|
-
};
|
|
440
|
-
https: {
|
|
441
|
-
type: string;
|
|
442
|
-
};
|
|
443
|
-
};
|
|
444
|
-
additionalProperties: boolean;
|
|
445
|
-
};
|
|
446
|
-
tools: {
|
|
447
|
-
type: string;
|
|
448
|
-
additionalProperties: boolean;
|
|
449
|
-
properties: {
|
|
450
|
-
webpack: {
|
|
451
|
-
typeof: string[];
|
|
452
|
-
};
|
|
453
|
-
webpackChain: {
|
|
454
|
-
typeof: string[];
|
|
455
|
-
};
|
|
456
|
-
babel: {
|
|
457
|
-
typeof: string[];
|
|
458
|
-
};
|
|
459
|
-
postcss: {
|
|
460
|
-
typeof: string[];
|
|
461
|
-
};
|
|
462
|
-
lodash: {
|
|
463
|
-
typeof: string[];
|
|
464
|
-
};
|
|
465
|
-
devServer: {
|
|
466
|
-
type: string;
|
|
467
|
-
};
|
|
468
|
-
tsLoader: {
|
|
469
|
-
typeof: string[];
|
|
470
|
-
};
|
|
471
|
-
autoprefixer: {
|
|
472
|
-
typeof: string[];
|
|
473
|
-
};
|
|
474
|
-
terser: {
|
|
475
|
-
typeof: string[];
|
|
476
|
-
};
|
|
477
|
-
minifyCss: {
|
|
478
|
-
typeof: string[];
|
|
479
|
-
};
|
|
480
|
-
styledComponents: {
|
|
481
|
-
typeof: string[];
|
|
482
|
-
};
|
|
483
|
-
htmlPlugin: {
|
|
484
|
-
typeof: string[];
|
|
485
|
-
};
|
|
486
|
-
esbuild: {
|
|
487
|
-
type: string;
|
|
488
|
-
};
|
|
489
|
-
sass: {
|
|
490
|
-
typeof: string[];
|
|
491
|
-
};
|
|
492
|
-
less: {
|
|
493
|
-
typeof: string[];
|
|
494
|
-
};
|
|
495
|
-
};
|
|
496
|
-
};
|
|
497
|
-
};
|
|
498
|
-
};
|
|
499
|
-
export declare const traverseSchema: (schema: ReturnType<typeof patchSchema>) => string[];
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.traverseSchema = exports.patchSchema = void 0;
|
|
4
|
-
const utils_1 = require("@modern-js/utils");
|
|
5
|
-
const lodash_1 = require("@modern-js/utils/lodash");
|
|
6
|
-
const source_1 = require("./source");
|
|
7
|
-
const output_1 = require("./output");
|
|
8
|
-
const server_1 = require("./server");
|
|
9
|
-
const deploy_1 = require("./deploy");
|
|
10
|
-
const tools_1 = require("./tools");
|
|
11
|
-
const debug = (0, utils_1.createDebugger)('validate-schema');
|
|
12
|
-
const plugins = {
|
|
13
|
-
type: 'array',
|
|
14
|
-
additionalProperties: false,
|
|
15
|
-
};
|
|
16
|
-
const dev = {
|
|
17
|
-
type: 'object',
|
|
18
|
-
properties: {
|
|
19
|
-
assetPrefix: { type: ['boolean', 'string'] },
|
|
20
|
-
https: {
|
|
21
|
-
type: 'boolean',
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
additionalProperties: false,
|
|
25
|
-
};
|
|
26
|
-
const patchSchema = (pluginSchemas) => {
|
|
27
|
-
const finalSchema = (0, lodash_1.cloneDeep)({
|
|
28
|
-
type: 'object',
|
|
29
|
-
additionalProperties: false,
|
|
30
|
-
properties: {
|
|
31
|
-
source: source_1.source,
|
|
32
|
-
output: output_1.output,
|
|
33
|
-
server: server_1.server,
|
|
34
|
-
deploy: deploy_1.deploy,
|
|
35
|
-
plugins,
|
|
36
|
-
dev,
|
|
37
|
-
tools: tools_1.tools,
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
const findTargetNode = (props) => {
|
|
41
|
-
let node = finalSchema.properties;
|
|
42
|
-
for (const prop of props) {
|
|
43
|
-
node = node[prop];
|
|
44
|
-
if (!node || !(0, utils_1.isObject)(node)) {
|
|
45
|
-
throw new Error(`add schema ${props.join('.')} error`);
|
|
46
|
-
}
|
|
47
|
-
node.properties = node.hasOwnProperty('properties')
|
|
48
|
-
? node.properties
|
|
49
|
-
: {};
|
|
50
|
-
node = node.properties;
|
|
51
|
-
}
|
|
52
|
-
return node;
|
|
53
|
-
};
|
|
54
|
-
const finalPluginSchemas = [];
|
|
55
|
-
pluginSchemas.forEach(item => {
|
|
56
|
-
if (Array.isArray(item)) {
|
|
57
|
-
finalPluginSchemas.push(...item);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
finalPluginSchemas.push(item);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
for (const { target, schema } of finalPluginSchemas) {
|
|
64
|
-
if (!target) {
|
|
65
|
-
throw new Error(`should return target property in plugin schema.`);
|
|
66
|
-
}
|
|
67
|
-
const props = target.split('.');
|
|
68
|
-
const mountProperty = props.pop();
|
|
69
|
-
const targetNode = findTargetNode(props);
|
|
70
|
-
if (!targetNode.hasOwnProperty(mountProperty)) {
|
|
71
|
-
targetNode[mountProperty] = (0, lodash_1.cloneDeep)(schema);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
debug(`final validate schema: %o`, finalSchema);
|
|
75
|
-
return finalSchema;
|
|
76
|
-
};
|
|
77
|
-
exports.patchSchema = patchSchema;
|
|
78
|
-
const traverseSchema = (schema) => {
|
|
79
|
-
const keys = [];
|
|
80
|
-
const traverse = ({ properties }, old = []) => {
|
|
81
|
-
for (const key of Object.keys(properties)) {
|
|
82
|
-
const current = [...old, key];
|
|
83
|
-
if (properties[key].type === 'object' && properties[key].properties) {
|
|
84
|
-
traverse(properties[key], current);
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
keys.push(current.join('.'));
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
traverse(schema);
|
|
92
|
-
return keys;
|
|
93
|
-
};
|
|
94
|
-
exports.traverseSchema = traverseSchema;
|