@tmsfe/tmskit 0.0.19 → 0.0.20
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 +6 -1
- package/dist/index.cjs.js +963 -812
- package/package.json +10 -8
- package/src/compile/build.js +2 -2
- package/src/compile/dev.js +30 -25
- package/src/compile/watch.js +31 -12
- package/src/config/constant.js +24 -3
- package/src/core/buildAppJson.js +14 -21
- package/src/core/checkDependencies.js +34 -17
- package/src/core/cloneModules.js +5 -7
- package/src/core/handleError.js +7 -1
- package/src/core/npm.js +7 -2
- package/src/core/tmsMpconfig.js +87 -74
- package/src/entry.js +3 -3
- package/src/scripts/create/generator.js +1 -2
- package/src/scripts/create/index.js +73 -32
- package/src/scripts/run/build/index.js +5 -4
- package/src/scripts/run/dev/index.js +14 -13
- package/src/scripts/run/index.js +68 -54
- package/src/scripts/run/init/index.js +13 -12
- package/src/scripts/run/install/index.js +4 -3
package/dist/index.cjs.js
CHANGED
|
@@ -13,6 +13,8 @@ var require$$0$4 = require('async');
|
|
|
13
13
|
var require$$1$3 = require('ejs');
|
|
14
14
|
var require$$1$4 = require('inquirer');
|
|
15
15
|
var require$$0$5 = require('metalsmith');
|
|
16
|
+
var require$$9 = require('request');
|
|
17
|
+
var require$$10 = require('unzipper');
|
|
16
18
|
var require$$0$6 = require('lodash');
|
|
17
19
|
var require$$1$5 = require('crypto');
|
|
18
20
|
var require$$0$7 = require('miniprogram-ci');
|
|
@@ -30,10 +32,10 @@ var require$$5 = require('chokidar');
|
|
|
30
32
|
var require$$6$1 = require('readable-stream');
|
|
31
33
|
var require$$7$1 = require('vinyl-file');
|
|
32
34
|
var require$$8 = require('vinyl');
|
|
33
|
-
var require$$9 = require('anymatch');
|
|
35
|
+
var require$$9$1 = require('anymatch');
|
|
34
36
|
var require$$11 = require('glob-parent');
|
|
35
37
|
var require$$2$1 = require('plugin-error');
|
|
36
|
-
var require$$10 = require('path-is-absolute');
|
|
38
|
+
var require$$10$1 = require('path-is-absolute');
|
|
37
39
|
var require$$12 = require('slash');
|
|
38
40
|
|
|
39
41
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
@@ -51,6 +53,8 @@ var require$$0__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$0$4);
|
|
|
51
53
|
var require$$1__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$1$3);
|
|
52
54
|
var require$$1__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$1$4);
|
|
53
55
|
var require$$0__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$0$5);
|
|
56
|
+
var require$$9__default = /*#__PURE__*/_interopDefaultLegacy(require$$9);
|
|
57
|
+
var require$$10__default = /*#__PURE__*/_interopDefaultLegacy(require$$10);
|
|
54
58
|
var require$$0__default$6 = /*#__PURE__*/_interopDefaultLegacy(require$$0$6);
|
|
55
59
|
var require$$1__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$1$5);
|
|
56
60
|
var require$$0__default$7 = /*#__PURE__*/_interopDefaultLegacy(require$$0$7);
|
|
@@ -68,10 +72,10 @@ var require$$5__default = /*#__PURE__*/_interopDefaultLegacy(require$$5);
|
|
|
68
72
|
var require$$6__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$6$1);
|
|
69
73
|
var require$$7__default = /*#__PURE__*/_interopDefaultLegacy(require$$7$1);
|
|
70
74
|
var require$$8__default = /*#__PURE__*/_interopDefaultLegacy(require$$8);
|
|
71
|
-
var require$$9__default = /*#__PURE__*/_interopDefaultLegacy(require$$9);
|
|
75
|
+
var require$$9__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$9$1);
|
|
72
76
|
var require$$11__default = /*#__PURE__*/_interopDefaultLegacy(require$$11);
|
|
73
77
|
var require$$2__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$2$1);
|
|
74
|
-
var require$$10__default = /*#__PURE__*/_interopDefaultLegacy(require$$10);
|
|
78
|
+
var require$$10__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$10$1);
|
|
75
79
|
var require$$12__default = /*#__PURE__*/_interopDefaultLegacy(require$$12);
|
|
76
80
|
|
|
77
81
|
function getAugmentedNamespace(n) {
|
|
@@ -91,7 +95,7 @@ function getAugmentedNamespace(n) {
|
|
|
91
95
|
|
|
92
96
|
var src$2 = {};
|
|
93
97
|
|
|
94
|
-
const chalk$
|
|
98
|
+
const chalk$4 = require$$0__default;
|
|
95
99
|
const moment = require$$1__default;
|
|
96
100
|
/**
|
|
97
101
|
* 本文件提供无依赖的在终端打印彩色文字的方法。
|
|
@@ -105,7 +109,7 @@ const resetCfg = decodeURIComponent('%1B%5B0m'); // \033[0m转义后的字符按
|
|
|
105
109
|
* @returns {undefined} 无
|
|
106
110
|
*/
|
|
107
111
|
|
|
108
|
-
const fail$
|
|
112
|
+
const fail$a = (message = '') => {
|
|
109
113
|
const redStyleConfig = decodeURIComponent('%1B%5B41%3B30m'); // \033[41;30m转义后的字符按,console时输出红色文字
|
|
110
114
|
|
|
111
115
|
const greenFontStyleConfig = decodeURIComponent('%1B%5B41%3B37m'); // \033[41;30m转义后的字符按,console时输出红底白色文字
|
|
@@ -134,29 +138,29 @@ const succeed$2 = (message = '') => {
|
|
|
134
138
|
|
|
135
139
|
|
|
136
140
|
const warn$2 = message => {
|
|
137
|
-
console.log(`${moment().format('YYYY-MM-DD HH:mm:ss')}`, chalk$
|
|
141
|
+
console.log(`${moment().format('YYYY-MM-DD HH:mm:ss')}`, chalk$4.yellow(message));
|
|
138
142
|
};
|
|
139
143
|
|
|
140
|
-
const info$
|
|
144
|
+
const info$d = (...args) => console.log(`${moment().format('YYYY-MM-DD HH:mm:ss')}`, ...args);
|
|
141
145
|
|
|
142
146
|
var log$1 = {
|
|
143
|
-
fail: fail$
|
|
147
|
+
fail: fail$a,
|
|
144
148
|
succeed: succeed$2,
|
|
145
149
|
warn: warn$2,
|
|
146
|
-
info: info$
|
|
150
|
+
info: info$d
|
|
147
151
|
};
|
|
148
152
|
|
|
149
153
|
const program$1 = require$$0__default$1;
|
|
150
154
|
const leven = require$$1__default$1;
|
|
151
|
-
const ora = require$$2__default;
|
|
152
|
-
const path$
|
|
155
|
+
const ora$1 = require$$2__default;
|
|
156
|
+
const path$e = require$$1__default$2;
|
|
153
157
|
const fs$g = require$$0__default$2;
|
|
154
158
|
const shelljs$7 = require$$0__default$3;
|
|
155
159
|
const glob$1 = require$$6__default;
|
|
156
160
|
const {
|
|
157
|
-
info: info$
|
|
161
|
+
info: info$c
|
|
158
162
|
} = log$1;
|
|
159
|
-
const chalk$
|
|
163
|
+
const chalk$3 = require$$0__default;
|
|
160
164
|
const shelljsOptions = {
|
|
161
165
|
slient: true,
|
|
162
166
|
async: false
|
|
@@ -165,7 +169,7 @@ const shelljsOptions = {
|
|
|
165
169
|
const cwd = process.cwd();
|
|
166
170
|
|
|
167
171
|
function resolve$f(...args) {
|
|
168
|
-
return path$
|
|
172
|
+
return path$e.resolve(cwd, ...args);
|
|
169
173
|
}
|
|
170
174
|
/**
|
|
171
175
|
* 用户输入命令时,进行提示
|
|
@@ -185,7 +189,7 @@ const suggestCommands$1 = unknownCommand => {
|
|
|
185
189
|
});
|
|
186
190
|
|
|
187
191
|
if (suggestion) {
|
|
188
|
-
info$
|
|
192
|
+
info$c(` ${chalk$3.red(`Did you mean ${chalk$3.yellow(suggestion)}?`)}`);
|
|
189
193
|
}
|
|
190
194
|
};
|
|
191
195
|
/**
|
|
@@ -195,7 +199,7 @@ const suggestCommands$1 = unknownCommand => {
|
|
|
195
199
|
*/
|
|
196
200
|
|
|
197
201
|
|
|
198
|
-
function isObject
|
|
202
|
+
function isObject(obj) {
|
|
199
203
|
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
200
204
|
}
|
|
201
205
|
/**
|
|
@@ -205,7 +209,7 @@ function isObject$2(obj) {
|
|
|
205
209
|
*/
|
|
206
210
|
|
|
207
211
|
|
|
208
|
-
function isArray
|
|
212
|
+
function isArray(obj) {
|
|
209
213
|
return Object.prototype.toString.call(obj) === '[object Array]';
|
|
210
214
|
}
|
|
211
215
|
/**
|
|
@@ -217,12 +221,12 @@ function isArray$1(obj) {
|
|
|
217
221
|
*/
|
|
218
222
|
|
|
219
223
|
|
|
220
|
-
function downloadRepoForGit$
|
|
224
|
+
function downloadRepoForGit$1(url, dest, branch) {
|
|
221
225
|
const cwd = process.cwd();
|
|
222
226
|
return new Promise((resolve, reject) => {
|
|
223
227
|
// 如果目标目录不存在
|
|
224
228
|
if (fs$g.existsSync(dest)) {
|
|
225
|
-
shelljs$7.rm('-rf', path$
|
|
229
|
+
shelljs$7.rm('-rf', path$e.join(dest));
|
|
226
230
|
}
|
|
227
231
|
|
|
228
232
|
shelljs$7.mkdir('-p', dest);
|
|
@@ -302,11 +306,11 @@ const cost = start => Date.now() - start;
|
|
|
302
306
|
*/
|
|
303
307
|
|
|
304
308
|
|
|
305
|
-
function createTask$
|
|
309
|
+
function createTask$2(task, startText, endText) {
|
|
306
310
|
return async (...args) => {
|
|
307
311
|
const start = Date.now();
|
|
308
|
-
const spinner = ora();
|
|
309
|
-
info$
|
|
312
|
+
const spinner = ora$1();
|
|
313
|
+
info$c(startText);
|
|
310
314
|
spinner.start();
|
|
311
315
|
const result = await task(...args);
|
|
312
316
|
endText && spinner.succeed(`${endText}, 耗时${cost(start) / 1000}s`);
|
|
@@ -322,7 +326,7 @@ function createTask$3(task, startText, endText) {
|
|
|
322
326
|
|
|
323
327
|
const camelize = str => str.replace(/-(\w)/g, (a, c) => c ? c.toUpperCase() : '');
|
|
324
328
|
|
|
325
|
-
const mergeMap = function (obj, src) {
|
|
329
|
+
const mergeMap$1 = function (obj, src) {
|
|
326
330
|
for (const [k, v] of src) {
|
|
327
331
|
if (obj.has(k)) {
|
|
328
332
|
obj.set(k, obj.get(k) + v);
|
|
@@ -335,7 +339,7 @@ const mergeMap = function (obj, src) {
|
|
|
335
339
|
};
|
|
336
340
|
|
|
337
341
|
const relativeCwdPath$1 = function (file) {
|
|
338
|
-
return path$
|
|
342
|
+
return path$e.relative(process.cwd(), file);
|
|
339
343
|
};
|
|
340
344
|
/**
|
|
341
345
|
* 从一个对象中,检索出去几个字段
|
|
@@ -345,7 +349,7 @@ const relativeCwdPath$1 = function (file) {
|
|
|
345
349
|
*/
|
|
346
350
|
|
|
347
351
|
|
|
348
|
-
const filterField$
|
|
352
|
+
const filterField$4 = (obj, filterNames = []) => {
|
|
349
353
|
const newObj = { ...obj
|
|
350
354
|
};
|
|
351
355
|
filterNames.forEach(name => {
|
|
@@ -371,58 +375,72 @@ function findFiles(globPath, filter = []) {
|
|
|
371
375
|
|
|
372
376
|
var widgets = {
|
|
373
377
|
resolve: resolve$f,
|
|
374
|
-
isObject
|
|
375
|
-
isArray
|
|
376
|
-
createTask: createTask$
|
|
377
|
-
downloadRepoForGit: downloadRepoForGit$
|
|
378
|
+
isObject,
|
|
379
|
+
isArray,
|
|
380
|
+
createTask: createTask$2,
|
|
381
|
+
downloadRepoForGit: downloadRepoForGit$1,
|
|
378
382
|
pullRepoForGit: pullRepoForGit$1,
|
|
379
383
|
suggestCommands: suggestCommands$1,
|
|
380
384
|
camelize,
|
|
381
385
|
npmInstall: npmInstall$2,
|
|
382
|
-
mergeMap,
|
|
386
|
+
mergeMap: mergeMap$1,
|
|
383
387
|
relativeCwdPath: relativeCwdPath$1,
|
|
384
|
-
filterField: filterField$
|
|
388
|
+
filterField: filterField$4,
|
|
385
389
|
findFiles
|
|
386
390
|
};
|
|
387
391
|
|
|
388
|
-
const path$
|
|
392
|
+
const path$d = require('path');
|
|
389
393
|
|
|
390
394
|
const os = require('os'); // 用户目录
|
|
391
395
|
|
|
392
396
|
|
|
393
397
|
const HOME_DIR = os.homedir(); // 所有文件的缓存目录
|
|
394
398
|
|
|
395
|
-
const CACHE_DIR$3 = path$
|
|
399
|
+
const CACHE_DIR$3 = path$d.resolve(HOME_DIR, '.tmskit'); // 缓存文件
|
|
396
400
|
|
|
397
401
|
const CACHE_FILE$1 = 'cache_file.json'; // 脚手架模板代码所在目录
|
|
398
402
|
|
|
399
|
-
const TEMPLATE_DIR$1 = path$
|
|
403
|
+
const TEMPLATE_DIR$1 = path$d.resolve(CACHE_DIR$3, 'template'); // 模板的名称
|
|
400
404
|
|
|
401
|
-
const
|
|
405
|
+
const TEMPLATE_NAME$1 = 'tmskit-template'; // 第三方模块源码存放的临时缓存目录
|
|
402
406
|
|
|
403
|
-
const
|
|
407
|
+
const MODULE_CODE_DIR$1 = path$d.resolve(CACHE_DIR$3, 'modules_code'); // 脚手架模板的远程地址
|
|
408
|
+
|
|
409
|
+
const TEMPLATE_URL$1 = 'https://tms-web-1g1czzwka2fd06f2-1301126013.tcloudbaseapp.com/tmskit-template/tmskit-template.zip'; // 脚手架的名称
|
|
404
410
|
|
|
405
411
|
const TMS_NAME$1 = 'tmskit'; // 脚手架的配置名称
|
|
406
412
|
|
|
407
|
-
const TMS_CONFIG_FILENAME
|
|
408
|
-
const TMS_PRIVATE_FILENAME
|
|
413
|
+
const TMS_CONFIG_FILENAME = 'tms.config.js';
|
|
414
|
+
const TMS_PRIVATE_FILENAME = 'tms.private.config.js'; // 模块代码的默认在modules子目录
|
|
409
415
|
|
|
410
416
|
const DEFAULT_MODULE_DIR = 'modules'; // 模块代码的默认在modules子目录
|
|
411
417
|
|
|
412
418
|
const DEFAULT_CLOUD_MODULE_DIR = './cloud'; // 模块的配置文件的名称
|
|
413
419
|
|
|
414
|
-
const MODULE_CONFIG_FILENAME
|
|
420
|
+
const MODULE_CONFIG_FILENAME = 'module.config.json'; // 默认的webpack entry
|
|
415
421
|
|
|
416
422
|
const DEFAULT_WEBPACK_ENTRY = {
|
|
417
|
-
app: path$
|
|
423
|
+
app: path$d.resolve(process.cwd(), 'app')
|
|
418
424
|
}; // 默认从源码拷贝到编译后的配置
|
|
419
425
|
|
|
420
|
-
const DEFAULT_COPY_CONFIG$
|
|
426
|
+
const DEFAULT_COPY_CONFIG$2 = ['package.json', 'sitemap.json'];
|
|
421
427
|
const ENV = {
|
|
422
428
|
dev: 'development',
|
|
423
429
|
prod: 'production'
|
|
424
430
|
};
|
|
425
431
|
const TEMPLATE_TKIT_DIR$2 = '_tmskit';
|
|
432
|
+
const CREATE_TEMPLATE_QUESTION$1 = [{
|
|
433
|
+
type: 'list',
|
|
434
|
+
name: 'projectType',
|
|
435
|
+
message: '选择你要创建的模板',
|
|
436
|
+
choices: [{
|
|
437
|
+
name: '小程序项目',
|
|
438
|
+
value: 'mp'
|
|
439
|
+
}, {
|
|
440
|
+
name: '小程序模块',
|
|
441
|
+
value: 'mp-module'
|
|
442
|
+
}]
|
|
443
|
+
}];
|
|
426
444
|
|
|
427
445
|
var constant = /*#__PURE__*/Object.freeze({
|
|
428
446
|
__proto__: null,
|
|
@@ -430,26 +448,28 @@ var constant = /*#__PURE__*/Object.freeze({
|
|
|
430
448
|
CACHE_DIR: CACHE_DIR$3,
|
|
431
449
|
CACHE_FILE: CACHE_FILE$1,
|
|
432
450
|
TEMPLATE_DIR: TEMPLATE_DIR$1,
|
|
433
|
-
|
|
451
|
+
TEMPLATE_NAME: TEMPLATE_NAME$1,
|
|
434
452
|
TMS_NAME: TMS_NAME$1,
|
|
435
|
-
TMS_CONFIG_FILENAME: TMS_CONFIG_FILENAME
|
|
436
|
-
TMS_PRIVATE_FILENAME: TMS_PRIVATE_FILENAME
|
|
453
|
+
TMS_CONFIG_FILENAME: TMS_CONFIG_FILENAME,
|
|
454
|
+
TMS_PRIVATE_FILENAME: TMS_PRIVATE_FILENAME,
|
|
437
455
|
DEFAULT_MODULE_DIR: DEFAULT_MODULE_DIR,
|
|
438
|
-
MODULE_CONFIG_FILENAME: MODULE_CONFIG_FILENAME
|
|
456
|
+
MODULE_CONFIG_FILENAME: MODULE_CONFIG_FILENAME,
|
|
439
457
|
DEFAULT_WEBPACK_ENTRY: DEFAULT_WEBPACK_ENTRY,
|
|
440
|
-
DEFAULT_COPY_CONFIG: DEFAULT_COPY_CONFIG$
|
|
458
|
+
DEFAULT_COPY_CONFIG: DEFAULT_COPY_CONFIG$2,
|
|
441
459
|
MODULE_CODE_DIR: MODULE_CODE_DIR$1,
|
|
442
460
|
ENV: ENV,
|
|
443
461
|
TEMPLATE_TKIT_DIR: TEMPLATE_TKIT_DIR$2,
|
|
444
|
-
DEFAULT_CLOUD_MODULE_DIR: DEFAULT_CLOUD_MODULE_DIR
|
|
462
|
+
DEFAULT_CLOUD_MODULE_DIR: DEFAULT_CLOUD_MODULE_DIR,
|
|
463
|
+
CREATE_TEMPLATE_QUESTION: CREATE_TEMPLATE_QUESTION$1,
|
|
464
|
+
TEMPLATE_URL: TEMPLATE_URL$1
|
|
445
465
|
});
|
|
446
466
|
|
|
447
467
|
var require$$4 = /*@__PURE__*/getAugmentedNamespace(constant);
|
|
448
468
|
|
|
449
469
|
const fs$f = require$$0__default$2;
|
|
450
|
-
const path$
|
|
470
|
+
const path$c = require$$1__default$2;
|
|
451
471
|
const {
|
|
452
|
-
info: info$
|
|
472
|
+
info: info$b
|
|
453
473
|
} = log$1;
|
|
454
474
|
const {
|
|
455
475
|
relativeCwdPath
|
|
@@ -491,7 +511,7 @@ const copyFile = function (src, dest) {
|
|
|
491
511
|
fs$f.unlinkSync(dest);
|
|
492
512
|
}
|
|
493
513
|
|
|
494
|
-
const dir = path$
|
|
514
|
+
const dir = path$c.dirname(dest);
|
|
495
515
|
ensureDirExist$2(dir);
|
|
496
516
|
fs$f.copyFileSync(src, dest);
|
|
497
517
|
}; // 判断文件内容是否一致,不一致再进行拷贝
|
|
@@ -503,11 +523,11 @@ function diffContentCopyFile$3(originFile, destFile) {
|
|
|
503
523
|
const depOriginContent = fs$f.readFileSync(originFile, 'utf8');
|
|
504
524
|
|
|
505
525
|
if (depDestContent !== depOriginContent) {
|
|
506
|
-
info$
|
|
526
|
+
info$b(`拷贝${relativeCwdPath(originFile)}内容到${relativeCwdPath(destFile)}`);
|
|
507
527
|
copyFile(originFile, destFile);
|
|
508
528
|
}
|
|
509
529
|
} else {
|
|
510
|
-
info$
|
|
530
|
+
info$b(`拷贝${relativeCwdPath(originFile)}内容到${relativeCwdPath(destFile)}`);
|
|
511
531
|
copyFile(originFile, destFile);
|
|
512
532
|
}
|
|
513
533
|
} // 添加后缀
|
|
@@ -551,7 +571,7 @@ const fileInDir$3 = (dir, file) => {
|
|
|
551
571
|
return false;
|
|
552
572
|
}
|
|
553
573
|
|
|
554
|
-
const relativePath = path$
|
|
574
|
+
const relativePath = path$c.relative(dir, file);
|
|
555
575
|
|
|
556
576
|
if (relativePath.startsWith('..')) {
|
|
557
577
|
return false;
|
|
@@ -566,7 +586,7 @@ function findAllFilesOfDir$1(dir) {
|
|
|
566
586
|
function listFile(dir) {
|
|
567
587
|
const arr = fs$f.readdirSync(dir);
|
|
568
588
|
arr.forEach(item => {
|
|
569
|
-
const fullPath = path$
|
|
589
|
+
const fullPath = path$c.join(dir, item);
|
|
570
590
|
const stats = fs$f.statSync(fullPath);
|
|
571
591
|
|
|
572
592
|
if (stats.isDirectory()) {
|
|
@@ -614,7 +634,7 @@ const render$1 = (files, metalsmith, next) => {
|
|
|
614
634
|
var render_1 = render$1;
|
|
615
635
|
|
|
616
636
|
const fs$e = require$$0__default$2;
|
|
617
|
-
const inquirer = require$$1__default$4;
|
|
637
|
+
const inquirer$1 = require$$1__default$4;
|
|
618
638
|
const {
|
|
619
639
|
resolve: resolve$e
|
|
620
640
|
} = widgets;
|
|
@@ -677,7 +697,7 @@ const ask$1 = templateDir => (files, metalsmith, next) => {
|
|
|
677
697
|
|
|
678
698
|
return true;
|
|
679
699
|
});
|
|
680
|
-
inquirer.prompt(filteredPrompts).then(res => {
|
|
700
|
+
inquirer$1.prompt(filteredPrompts).then(res => {
|
|
681
701
|
for (const prompt of filteredPrompts) {
|
|
682
702
|
metadata[prompt.name] = res[prompt.name];
|
|
683
703
|
}
|
|
@@ -698,7 +718,7 @@ const render = render_1;
|
|
|
698
718
|
const ask = ask_1;
|
|
699
719
|
const FILES_TO_IGNORE = ignoreFiles;
|
|
700
720
|
|
|
701
|
-
const generator$1 = (buildDir, distDir, preMetadata) => new Promise((resolve, reject) => {
|
|
721
|
+
const generator$1 = (buildDir, distDir, preMetadata = {}) => new Promise((resolve, reject) => {
|
|
702
722
|
Metalsmith(buildDir).metadata(preMetadata).ignore(FILES_TO_IGNORE).clean(false).use(ask(buildDir)).source('./').destination(distDir).use(render).build(err => {
|
|
703
723
|
if (err) {
|
|
704
724
|
reject(err);
|
|
@@ -710,91 +730,138 @@ const generator$1 = (buildDir, distDir, preMetadata) => new Promise((resolve, re
|
|
|
710
730
|
|
|
711
731
|
var generator_1 = generator$1;
|
|
712
732
|
|
|
713
|
-
const path$
|
|
733
|
+
const path$b = require$$1__default$2;
|
|
714
734
|
const fs$d = require$$0__default$2;
|
|
715
735
|
const shelljs$6 = require$$0__default$3;
|
|
736
|
+
const inquirer = require$$1__default$4;
|
|
716
737
|
const {
|
|
717
738
|
TEMPLATE_DIR,
|
|
718
|
-
|
|
719
|
-
|
|
739
|
+
TEMPLATE_URL,
|
|
740
|
+
TEMPLATE_NAME,
|
|
741
|
+
TEMPLATE_TKIT_DIR,
|
|
742
|
+
CREATE_TEMPLATE_QUESTION
|
|
720
743
|
} = require$$4;
|
|
721
744
|
const {
|
|
722
|
-
downloadRepoForGit: downloadRepoForGit$1,
|
|
723
|
-
createTask: createTask$2,
|
|
724
745
|
resolve: resolve$d
|
|
725
746
|
} = widgets;
|
|
726
747
|
const io$2 = io$3;
|
|
727
748
|
const {
|
|
728
|
-
fail: fail$
|
|
749
|
+
fail: fail$9,
|
|
729
750
|
succeed: succeed$1,
|
|
730
|
-
info: info$
|
|
751
|
+
info: info$a
|
|
731
752
|
} = log$1;
|
|
732
753
|
const generator = generator_1;
|
|
754
|
+
const request = require$$9__default;
|
|
755
|
+
const unzip = require$$10__default;
|
|
733
756
|
/**
|
|
734
757
|
* 如果该目录下面存在文件,换个名字
|
|
735
758
|
* @param { string } targetDir 当前文件夹
|
|
736
759
|
* @returns { undefined }
|
|
737
760
|
*/
|
|
738
761
|
|
|
739
|
-
async function
|
|
762
|
+
async function createProjectDir(targetDir) {
|
|
740
763
|
// 如果目录非空或者已经存在,提示用户,做选择
|
|
741
764
|
if (fs$d.existsSync(targetDir)) {
|
|
742
765
|
if (!(await io$2.isDirEmpty(targetDir))) {
|
|
743
|
-
fail$
|
|
766
|
+
fail$9('该目录名已经存在,换个项目名字吧~');
|
|
744
767
|
process.exit(1);
|
|
745
768
|
}
|
|
746
769
|
} else {
|
|
747
770
|
shelljs$6.mkdir('-p', targetDir);
|
|
748
771
|
}
|
|
749
772
|
}
|
|
773
|
+
/**
|
|
774
|
+
* 下载和解压远程的小程序模板
|
|
775
|
+
* @param {string} templateDir
|
|
776
|
+
* @param {string} templateUrl
|
|
777
|
+
* @param {string} templateName
|
|
778
|
+
* @returns
|
|
779
|
+
*/
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
function downloadAndUnZipTemplate(templateDir, templateUrl, templateName) {
|
|
783
|
+
return new Promise((resolve, reject) => {
|
|
784
|
+
const localZipPath = `${templateDir}/${templateName}.zip`;
|
|
785
|
+
const stream = fs$d.createWriteStream(localZipPath);
|
|
786
|
+
request(`${templateUrl}?v=${new Date().getTime()}`).pipe(stream).on('close', err => {
|
|
787
|
+
if (err) {
|
|
788
|
+
reject(err);
|
|
789
|
+
return;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
fs$d.createReadStream(localZipPath).pipe(unzip.Extract({
|
|
793
|
+
path: templateDir
|
|
794
|
+
})).on('close', err => {
|
|
795
|
+
if (err) {
|
|
796
|
+
reject(err);
|
|
797
|
+
return;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
resolve();
|
|
801
|
+
});
|
|
802
|
+
});
|
|
803
|
+
});
|
|
804
|
+
}
|
|
750
805
|
/**
|
|
751
806
|
* 创建本地小程序运行环境
|
|
752
|
-
* @param { string }
|
|
753
|
-
* @param { string }
|
|
807
|
+
* @param { string } projectType 项目类型
|
|
808
|
+
* @param { string } projectName 项目名称
|
|
754
809
|
*/
|
|
755
810
|
|
|
756
811
|
|
|
757
|
-
async function create(
|
|
812
|
+
async function create(projectName) {
|
|
758
813
|
const cwd = process.cwd();
|
|
759
|
-
const targetDir = path$
|
|
760
|
-
const
|
|
761
|
-
|
|
814
|
+
const targetDir = path$b.resolve(cwd, projectName);
|
|
815
|
+
const {
|
|
816
|
+
projectType
|
|
817
|
+
} = await inquirer.prompt(CREATE_TEMPLATE_QUESTION); // 创建项目目录
|
|
762
818
|
|
|
763
|
-
|
|
819
|
+
await createProjectDir(targetDir); // 新创建缓存目录
|
|
764
820
|
|
|
765
|
-
|
|
821
|
+
if (fs$d.existsSync(TEMPLATE_DIR)) {
|
|
822
|
+
shelljs$6.rm('-rf', TEMPLATE_DIR);
|
|
823
|
+
}
|
|
766
824
|
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
}).then(() => {
|
|
771
|
-
shelljs$6.cd(appName);
|
|
825
|
+
fs$d.mkdirSync(TEMPLATE_DIR, {
|
|
826
|
+
recursive: true
|
|
827
|
+
}); // 下载和解压模板
|
|
772
828
|
|
|
773
|
-
|
|
829
|
+
await downloadAndUnZipTemplate(TEMPLATE_DIR, TEMPLATE_URL, TEMPLATE_NAME); // 生成模板(1. 询问问题, 2. ejs生成模板 3.生成到目标目录)
|
|
774
830
|
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
831
|
+
generator(path$b.join(TEMPLATE_DIR, TEMPLATE_NAME, projectType), targetDir).then(() => {
|
|
832
|
+
shelljs$6.cd(projectName);
|
|
833
|
+
const hookFilePath = resolve$d(projectName, TEMPLATE_TKIT_DIR, 'hooks.js');
|
|
834
|
+
|
|
835
|
+
if (fs$d.existsSync(hookFilePath)) {
|
|
836
|
+
const hooks = require(hookFilePath);
|
|
837
|
+
|
|
838
|
+
if (hooks.afterCreate) {
|
|
839
|
+
hooks.afterCreate.forEach(item => {
|
|
840
|
+
if (typeof item === 'function') {
|
|
841
|
+
item.call(null, shelljs$6, {
|
|
842
|
+
projectName
|
|
843
|
+
});
|
|
844
|
+
} else {
|
|
845
|
+
shelljs$6.exec(item);
|
|
846
|
+
}
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
shelljs$6.rm('-rf', resolve$d(projectName, TEMPLATE_TKIT_DIR));
|
|
785
851
|
}
|
|
786
852
|
|
|
787
|
-
shelljs$6.rm('-rf', resolve$d(appName, TEMPLATE_TKIT_DIR));
|
|
788
853
|
succeed$1('项目创建完成.');
|
|
789
854
|
}).catch(err => {
|
|
790
|
-
fail$
|
|
791
|
-
info$
|
|
855
|
+
fail$9(err.message);
|
|
856
|
+
info$a('详细的错误信息:', err);
|
|
792
857
|
});
|
|
793
858
|
}
|
|
794
859
|
|
|
795
860
|
var create_1 = create;
|
|
796
861
|
|
|
797
|
-
var
|
|
862
|
+
var tmsMpconfig = {exports: {}};
|
|
863
|
+
|
|
864
|
+
var defaultTmsConfig = {
|
|
798
865
|
// 全局的环境配置项
|
|
799
866
|
envData: {},
|
|
800
867
|
// 模块配置信息
|
|
@@ -816,236 +883,249 @@ var defaultTmsConfig$1 = {
|
|
|
816
883
|
/**
|
|
817
884
|
* 用来读取处理tms.config.js与module.config.json字段
|
|
818
885
|
*/
|
|
819
|
-
const loadash$1 = require$$0__default$6;
|
|
820
|
-
const fs$c = require$$0__default$2;
|
|
821
|
-
const {
|
|
822
|
-
TMS_CONFIG_FILENAME,
|
|
823
|
-
MODULE_CONFIG_FILENAME: MODULE_CONFIG_FILENAME$1,
|
|
824
|
-
TMS_PRIVATE_FILENAME
|
|
825
|
-
} = require$$4;
|
|
826
|
-
const {
|
|
827
|
-
resolve: resolve$c,
|
|
828
|
-
isObject: isObject$1,
|
|
829
|
-
isArray
|
|
830
|
-
} = widgets;
|
|
831
|
-
const defaultTmsConfig = defaultTmsConfig$1;
|
|
832
|
-
const {
|
|
833
|
-
fail: fail$7
|
|
834
|
-
} = log$1;
|
|
835
|
-
/**
|
|
836
|
-
* 读取tms.config.js
|
|
837
|
-
* @param env {string} 环境变量
|
|
838
|
-
*/
|
|
839
|
-
|
|
840
|
-
const readTmsConfig$1 = function (env) {
|
|
841
|
-
const tmsConfigPath = resolve$c(TMS_CONFIG_FILENAME);
|
|
842
886
|
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
887
|
+
(function (module) {
|
|
888
|
+
/* eslint-disable no-param-reassign, no-nested-ternary */
|
|
889
|
+
const loadash = require$$0__default$6;
|
|
890
|
+
const fs = require$$0__default$2;
|
|
891
|
+
const {
|
|
892
|
+
TMS_CONFIG_FILENAME,
|
|
893
|
+
MODULE_CONFIG_FILENAME,
|
|
894
|
+
TMS_PRIVATE_FILENAME
|
|
895
|
+
} = require$$4;
|
|
896
|
+
const {
|
|
897
|
+
resolve,
|
|
898
|
+
isObject,
|
|
899
|
+
isArray
|
|
900
|
+
} = widgets;
|
|
901
|
+
const defaultTmsConfig$1 = defaultTmsConfig;
|
|
902
|
+
const {
|
|
903
|
+
fail
|
|
904
|
+
} = log$1;
|
|
905
|
+
/**
|
|
906
|
+
* 读取tms.config.js
|
|
907
|
+
* @param env {string} 环境变量
|
|
908
|
+
*/
|
|
847
909
|
|
|
848
|
-
const
|
|
910
|
+
const readTmsConfig = function (env) {
|
|
911
|
+
const tmsConfigPath = resolve(TMS_CONFIG_FILENAME);
|
|
849
912
|
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
913
|
+
if (!fs.existsSync(tmsConfigPath)) {
|
|
914
|
+
fail('当前执行目录没有tms.config.js的配置项,请进行配置');
|
|
915
|
+
process.exit(1);
|
|
916
|
+
}
|
|
853
917
|
|
|
854
|
-
|
|
855
|
-
};
|
|
856
|
-
/**
|
|
857
|
-
* 读取tms.private.config.js
|
|
858
|
-
*/
|
|
918
|
+
const tmsConfigFn = require(tmsConfigPath);
|
|
859
919
|
|
|
920
|
+
const tmsConfig = tmsConfigFn({
|
|
921
|
+
env
|
|
922
|
+
}); // 合并默认值
|
|
860
923
|
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
924
|
+
return loadash.mergeWith(defaultTmsConfig$1, tmsConfig);
|
|
925
|
+
};
|
|
926
|
+
/**
|
|
927
|
+
* 读取tms.private.config.js
|
|
928
|
+
*/
|
|
864
929
|
|
|
865
|
-
if (fs$c.existsSync(tmsPrivatePath)) {
|
|
866
|
-
tmsPrivateCf = require(tmsPrivatePath);
|
|
867
|
-
}
|
|
868
930
|
|
|
869
|
-
|
|
870
|
-
};
|
|
871
|
-
|
|
872
|
-
* 从tms.config.json中检索用户传入的有效modules
|
|
873
|
-
* @param { object } tmsConfig
|
|
874
|
-
* @param { array } modules
|
|
875
|
-
* @returns
|
|
876
|
-
*/
|
|
931
|
+
const readTmsPrivateCf = function () {
|
|
932
|
+
let tmsPrivateCf = {};
|
|
933
|
+
const tmsPrivatePath = resolve(TMS_PRIVATE_FILENAME);
|
|
877
934
|
|
|
935
|
+
if (fs.existsSync(tmsPrivatePath)) {
|
|
936
|
+
tmsPrivateCf = require(tmsPrivatePath);
|
|
937
|
+
}
|
|
878
938
|
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
939
|
+
return tmsPrivateCf;
|
|
940
|
+
};
|
|
941
|
+
/**
|
|
942
|
+
* 从tms.config.json中检索用户传入的有效modules
|
|
943
|
+
* @param { object } tmsConfig
|
|
944
|
+
* @param { array } modules
|
|
945
|
+
* @returns
|
|
946
|
+
*/
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
const checkModules = function (tmsConfig, modules, isQuit = false) {
|
|
950
|
+
const targetModules = [];
|
|
951
|
+
modules.forEach(moduleName => {
|
|
952
|
+
const module = tmsConfig.modules.all.find(module => module.moduleName === moduleName);
|
|
953
|
+
module && targetModules.push(module);
|
|
954
|
+
});
|
|
885
955
|
|
|
886
|
-
|
|
887
|
-
|
|
956
|
+
if (targetModules.length === 0) {
|
|
957
|
+
fail(`你启动的模块无效${modules.join(',')}无效,请检查tms.config.json>modules>${modules.join(',')}
|
|
888
958
|
>name字段与module.config.json的name字段是否一致`);
|
|
889
|
-
|
|
890
|
-
|
|
959
|
+
isQuit && process.exit(1);
|
|
960
|
+
}
|
|
891
961
|
|
|
892
|
-
|
|
893
|
-
};
|
|
894
|
-
/**
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
962
|
+
return targetModules;
|
|
963
|
+
};
|
|
964
|
+
/**
|
|
965
|
+
* 适配处理module.config.json的字段
|
|
966
|
+
* @param { object } fileContent module.config.json的内容
|
|
967
|
+
* @param { string } appName 小程序的名称
|
|
968
|
+
*/
|
|
899
969
|
|
|
900
970
|
|
|
901
|
-
function adaptMpCgContent(fileContent, appName) {
|
|
902
|
-
|
|
903
|
-
|
|
971
|
+
function adaptMpCgContent(fileContent, appName) {
|
|
972
|
+
const handleContent = function (appName, current) {
|
|
973
|
+
let res = current;
|
|
904
974
|
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
975
|
+
if (appName && current.mpConfig && current.mpConfig[appName]) {
|
|
976
|
+
res = { ...current,
|
|
977
|
+
...current.mpConfig[appName]
|
|
978
|
+
};
|
|
979
|
+
}
|
|
910
980
|
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
981
|
+
delete res.mpConfig;
|
|
982
|
+
delete res.isSubpackages;
|
|
983
|
+
return res;
|
|
984
|
+
};
|
|
915
985
|
|
|
916
|
-
|
|
986
|
+
let content = fileContent;
|
|
917
987
|
|
|
918
|
-
|
|
919
|
-
|
|
988
|
+
if (isArray(content)) {
|
|
989
|
+
let i = content.length - 1;
|
|
920
990
|
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
991
|
+
while (i >= 0) {
|
|
992
|
+
content[i] = handleContent(appName, content[i]);
|
|
993
|
+
i--; // eslint-disable-line
|
|
994
|
+
}
|
|
995
|
+
} else {
|
|
996
|
+
content = handleContent(appName, content);
|
|
924
997
|
}
|
|
925
|
-
|
|
926
|
-
|
|
998
|
+
|
|
999
|
+
return content;
|
|
927
1000
|
}
|
|
1001
|
+
/**
|
|
1002
|
+
* 获取模块module.config.json中的配置信息
|
|
1003
|
+
* @param {array} modules 用户要编译的模块列表
|
|
1004
|
+
* @param { string } appName 小程序的名称
|
|
1005
|
+
* @param {boolean} notFindIsQuit 找不到配置文件是否退出
|
|
1006
|
+
*/
|
|
1007
|
+
|
|
1008
|
+
|
|
1009
|
+
function getModulesConfig(modules = [], appName, notFindIsQuit) {
|
|
1010
|
+
const modulesConfig = [];
|
|
1011
|
+
modules.forEach(moduleItem => {
|
|
1012
|
+
if (!moduleItem.path) {
|
|
1013
|
+
throw new Error(`${moduleItem.moduleName}模块路径配置没有找到`);
|
|
1014
|
+
}
|
|
928
1015
|
|
|
929
|
-
|
|
930
|
-
}
|
|
931
|
-
/**
|
|
932
|
-
* 递归获取本地所有模块的配置信息
|
|
933
|
-
* @param {array} modules 用户要编译的模块列表
|
|
934
|
-
* @param { string } appName 小程序的名称
|
|
935
|
-
* @param { string } moduleConfigFilename moduleConfig的文件名
|
|
936
|
-
*/
|
|
1016
|
+
const moduleConfigPath = resolve(moduleItem.path, MODULE_CONFIG_FILENAME);
|
|
937
1017
|
|
|
1018
|
+
if (!fs.existsSync(moduleConfigPath)) {
|
|
1019
|
+
if (notFindIsQuit) {
|
|
1020
|
+
throw new Error(`${moduleItem.moduleName}模块的配置文件module.config.json在${moduleItem.path}目录下没有找到`);
|
|
1021
|
+
}
|
|
938
1022
|
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
modules.forEach(({
|
|
942
|
-
path
|
|
943
|
-
}) => {
|
|
944
|
-
const moduleConfigPath = resolve$c(path, moduleConfigFilename);
|
|
1023
|
+
return;
|
|
1024
|
+
}
|
|
945
1025
|
|
|
946
|
-
|
|
947
|
-
const content = fs$c.readFileSync(moduleConfigPath, 'utf-8');
|
|
948
|
-
modulesConfig[moduleConfigPath] = adaptMpCgContent(content, appName);
|
|
949
|
-
}
|
|
950
|
-
});
|
|
951
|
-
return modulesConfig;
|
|
952
|
-
}
|
|
953
|
-
/**
|
|
954
|
-
* tms.config.js的modules 合并 module.config.json的配置项
|
|
955
|
-
* @param {array} modules
|
|
956
|
-
* @param {string} appName
|
|
957
|
-
* @param {string} moduleDir
|
|
958
|
-
* @returns
|
|
959
|
-
*/
|
|
1026
|
+
let moduleConfig;
|
|
960
1027
|
|
|
1028
|
+
try {
|
|
1029
|
+
moduleConfig = JSON.parse(fs.readFileSync(moduleConfigPath, 'utf-8'));
|
|
1030
|
+
} catch (e) {
|
|
1031
|
+
throw new Error(`${moduleConfigPath}json解析报错: ${e}`);
|
|
1032
|
+
} // 兼容历史逻辑,后续可删除--- start
|
|
961
1033
|
|
|
962
|
-
const tmsModulesMergeLocalModuleCfg$3 = (modules, appName) => {
|
|
963
|
-
const newModules = [];
|
|
964
|
-
modules.forEach(({
|
|
965
|
-
path: relativePath,
|
|
966
|
-
name: moduleName
|
|
967
|
-
}, moduleIndex) => {
|
|
968
|
-
const moduleConfigPath = resolve$c(relativePath, MODULE_CONFIG_FILENAME$1);
|
|
969
1034
|
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
name
|
|
978
|
-
}, moduleContentArrIndex) => {
|
|
979
|
-
if (name === moduleName) {
|
|
980
|
-
findModule = true;
|
|
981
|
-
newModules.push({ ...modules[moduleIndex],
|
|
982
|
-
...moduleContentArr[moduleContentArrIndex]
|
|
983
|
-
});
|
|
984
|
-
}
|
|
985
|
-
});
|
|
1035
|
+
if (!moduleItem.moduleName) moduleItem.moduleName = moduleItem.name;
|
|
1036
|
+
delete moduleItem.name;
|
|
1037
|
+
let subPackages = isObject(moduleConfig) && moduleConfig.subPackages ? moduleConfig.subPackages : isObject(moduleConfig) ? [moduleConfig] : moduleConfig;
|
|
1038
|
+
subPackages = adaptMpCgContent(subPackages, appName);
|
|
1039
|
+
let dependencies = moduleConfig.dependencies || [];
|
|
1040
|
+
subPackages.forEach(item => {
|
|
1041
|
+
item.path = moduleItem.path;
|
|
986
1042
|
|
|
987
|
-
if (
|
|
988
|
-
|
|
989
|
-
process.exit(1);
|
|
1043
|
+
if (item.dependencies) {
|
|
1044
|
+
dependencies = dependencies.concat(item.dependencies);
|
|
990
1045
|
}
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
|
|
1046
|
+
});
|
|
1047
|
+
moduleItem.subPackages = subPackages;
|
|
1048
|
+
moduleItem.dependencies = dependencies; // 兼容逻辑--- end
|
|
1049
|
+
|
|
1050
|
+
modulesConfig.push(moduleItem);
|
|
1051
|
+
});
|
|
1052
|
+
return modulesConfig;
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* 获取分包内容 (读取module.config.json的配置项)
|
|
1056
|
+
* @param {array} modules
|
|
1057
|
+
* @returns
|
|
1058
|
+
*/
|
|
1059
|
+
|
|
1060
|
+
|
|
1061
|
+
const getSubPackages = modules => {
|
|
1062
|
+
const newSubPackages = [];
|
|
1063
|
+
modules.forEach(module => {
|
|
1064
|
+
(module.subPackages || []).forEach(item => {
|
|
1065
|
+
newSubPackages.push({
|
|
1066
|
+
path: module.path,
|
|
1067
|
+
...item
|
|
994
1068
|
});
|
|
995
|
-
}
|
|
996
|
-
} else {
|
|
997
|
-
newModules.push({ ...modules[moduleIndex]
|
|
998
1069
|
});
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
*/
|
|
1070
|
+
});
|
|
1071
|
+
return newSubPackages;
|
|
1072
|
+
};
|
|
1073
|
+
/**
|
|
1074
|
+
* 获取所有的模块,合并模块的依赖模块
|
|
1075
|
+
* @param { object } tmsConfig
|
|
1076
|
+
* @param {array} modules
|
|
1077
|
+
* @param {boolean} notFindIsQuit 找不到配置文件是否退出
|
|
1078
|
+
* @returns
|
|
1079
|
+
*/
|
|
1010
1080
|
|
|
1011
1081
|
|
|
1012
|
-
const
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1082
|
+
const getModulesByMergeDepModules = (tmsConfig, modules, notFindIsQuit = false) => {
|
|
1083
|
+
const allModules = new Map();
|
|
1084
|
+
|
|
1085
|
+
function dfs(tmsConfig, modules) {
|
|
1086
|
+
modules.forEach(moduleItem => {
|
|
1087
|
+
const [moduleConfig = {}] = getModulesConfig([moduleItem], tmsConfig.appName, notFindIsQuit);
|
|
1088
|
+
|
|
1089
|
+
if (!allModules.has(moduleItem.moduleName)) {
|
|
1090
|
+
allModules.set(moduleItem.moduleName, { ...moduleItem,
|
|
1091
|
+
...moduleConfig
|
|
1092
|
+
});
|
|
1093
|
+
const dependenciesModules = [];
|
|
1094
|
+
((moduleConfig === null || moduleConfig === void 0 ? void 0 : moduleConfig.dependencies) || []).forEach(dependenciesModule => {
|
|
1095
|
+
tmsConfig.modules.all.forEach(module => {
|
|
1096
|
+
if (dependenciesModule === module.moduleName) {
|
|
1097
|
+
dependenciesModules.push({ ...module
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
});
|
|
1101
|
+
});
|
|
1102
|
+
|
|
1103
|
+
if (dependenciesModules.length) {
|
|
1104
|
+
dfs(tmsConfig, dependenciesModules);
|
|
1105
|
+
}
|
|
1034
1106
|
}
|
|
1035
|
-
}
|
|
1036
|
-
}
|
|
1037
|
-
});
|
|
1038
|
-
return isOver ? mergeModules : subModulesMergeDepModules$2(tmsConfig, mergeModules);
|
|
1039
|
-
};
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1040
1109
|
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1110
|
+
dfs(tmsConfig, modules);
|
|
1111
|
+
const modulesArr = [];
|
|
1112
|
+
|
|
1113
|
+
for (const module of allModules.values()) {
|
|
1114
|
+
modulesArr.push(module);
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
return modulesArr;
|
|
1118
|
+
};
|
|
1119
|
+
|
|
1120
|
+
module.exports = {
|
|
1121
|
+
readTmsConfig,
|
|
1122
|
+
readTmsPrivateCf,
|
|
1123
|
+
getModulesConfig,
|
|
1124
|
+
checkModules,
|
|
1125
|
+
getSubPackages,
|
|
1126
|
+
getModulesByMergeDepModules
|
|
1127
|
+
};
|
|
1128
|
+
})(tmsMpconfig);
|
|
1049
1129
|
|
|
1050
1130
|
const global$6 = {
|
|
1051
1131
|
data: {},
|
|
@@ -1073,20 +1153,26 @@ var global_1 = {
|
|
|
1073
1153
|
};
|
|
1074
1154
|
|
|
1075
1155
|
const {
|
|
1076
|
-
fail: fail$
|
|
1156
|
+
fail: fail$8
|
|
1077
1157
|
} = log$1;
|
|
1078
1158
|
const {
|
|
1079
1159
|
global: global$5
|
|
1080
1160
|
} = global_1;
|
|
1081
1161
|
|
|
1082
|
-
function handleError$6(error) {
|
|
1162
|
+
function handleError$6(error, isQuit = false) {
|
|
1083
1163
|
const errMsg = typeof error === 'object' ? error.message : error;
|
|
1164
|
+
|
|
1165
|
+
if (isQuit) {
|
|
1166
|
+
fail$8(errMsg);
|
|
1167
|
+
process.exit(1);
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1084
1170
|
const isDev = global$5.getData('isDev');
|
|
1085
1171
|
|
|
1086
1172
|
if (isDev) {
|
|
1087
|
-
fail$
|
|
1173
|
+
fail$8(errMsg);
|
|
1088
1174
|
} else {
|
|
1089
|
-
fail$
|
|
1175
|
+
fail$8(errMsg);
|
|
1090
1176
|
process.exit(1);
|
|
1091
1177
|
}
|
|
1092
1178
|
}
|
|
@@ -1100,20 +1186,18 @@ var handleError_1 = {
|
|
|
1100
1186
|
*/
|
|
1101
1187
|
/* eslint-disable no-param-reassign */
|
|
1102
1188
|
|
|
1103
|
-
const fs$
|
|
1104
|
-
const {
|
|
1105
|
-
MODULE_CONFIG_FILENAME
|
|
1106
|
-
} = require$$4;
|
|
1189
|
+
const fs$c = require$$0__default$2;
|
|
1107
1190
|
const {
|
|
1108
|
-
|
|
1109
|
-
|
|
1191
|
+
getSubPackages: getSubPackages$3,
|
|
1192
|
+
getModulesConfig
|
|
1193
|
+
} = tmsMpconfig.exports;
|
|
1110
1194
|
const {
|
|
1111
|
-
fail: fail$
|
|
1195
|
+
fail: fail$7,
|
|
1196
|
+
info: info$9
|
|
1112
1197
|
} = log$1;
|
|
1113
1198
|
const {
|
|
1114
|
-
resolve: resolve$
|
|
1115
|
-
|
|
1116
|
-
filterField: filterField$2
|
|
1199
|
+
resolve: resolve$c,
|
|
1200
|
+
filterField: filterField$3
|
|
1117
1201
|
} = widgets;
|
|
1118
1202
|
const {
|
|
1119
1203
|
handleError: handleError$5
|
|
@@ -1139,7 +1223,7 @@ function updateMainPackages(appJson, mainPackages = []) {
|
|
|
1139
1223
|
|
|
1140
1224
|
foundMainPackages.forEach(subpackage => {
|
|
1141
1225
|
if (!subpackage.pages || !subpackage.pages.length) {
|
|
1142
|
-
fail$
|
|
1226
|
+
fail$7(`主包 ${subpackage} 不能没有 pages`);
|
|
1143
1227
|
process.exit(-1);
|
|
1144
1228
|
}
|
|
1145
1229
|
|
|
@@ -1164,33 +1248,17 @@ function updateMainPackages(appJson, mainPackages = []) {
|
|
|
1164
1248
|
|
|
1165
1249
|
|
|
1166
1250
|
const getAppJsonContent = sourceAppJsonPath => {
|
|
1167
|
-
if (!fs$
|
|
1168
|
-
fail$
|
|
1251
|
+
if (!fs$c.existsSync(sourceAppJsonPath)) {
|
|
1252
|
+
fail$7(`当前路径 ${sourceAppJsonPath} 没找到app.json`);
|
|
1169
1253
|
process.exit(1);
|
|
1170
1254
|
}
|
|
1171
1255
|
|
|
1172
|
-
const appJson = JSON.parse(fs$
|
|
1256
|
+
const appJson = JSON.parse(fs$c.readFileSync(sourceAppJsonPath), 'utf-8'); // 加入默认值
|
|
1173
1257
|
|
|
1174
1258
|
appJson.subpackages = [];
|
|
1175
1259
|
appJson.pages = [];
|
|
1176
1260
|
return appJson;
|
|
1177
1261
|
};
|
|
1178
|
-
/**
|
|
1179
|
-
* 更新app.json中的subpackages
|
|
1180
|
-
* @param {Object} appJson
|
|
1181
|
-
* @param {Object} modulesConfigs
|
|
1182
|
-
*/
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
const updateSubpackages = (appJson, modulesConfigs) => {
|
|
1186
|
-
// eslint-disable-next-line
|
|
1187
|
-
for (const modulePath in modulesConfigs) {
|
|
1188
|
-
const moduleInfo = isObject(modulesConfigs[modulePath]) ? [modulesConfigs[modulePath]] : modulesConfigs[modulePath];
|
|
1189
|
-
appJson.subpackages = appJson.subpackages.concat(moduleInfo);
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
appJson.subpackages.sort((item1, item2) => item1.name.localeCompare(item2.name));
|
|
1193
|
-
};
|
|
1194
1262
|
/**
|
|
1195
1263
|
* 处理合并subpackages后的appjson, 整理重复不合法的地方
|
|
1196
1264
|
* @param {Object} appJson appjson
|
|
@@ -1230,7 +1298,7 @@ const fixAppJson = appJson => {
|
|
|
1230
1298
|
appJson[key] = preloadRuleMap;
|
|
1231
1299
|
}
|
|
1232
1300
|
});
|
|
1233
|
-
return filterField$
|
|
1301
|
+
return filterField$3(subp, [...arrOfFileType, ...objOfFileType, 'dependencies', 'path']);
|
|
1234
1302
|
}); // 如果plugins重复,则错误提示
|
|
1235
1303
|
|
|
1236
1304
|
const pluginsErrMsg = Object.keys(pluginsMap).map(pk => {
|
|
@@ -1255,27 +1323,30 @@ const fixAppJson = appJson => {
|
|
|
1255
1323
|
*/
|
|
1256
1324
|
|
|
1257
1325
|
|
|
1258
|
-
function buildOutputAppJson$
|
|
1326
|
+
function buildOutputAppJson$2(tmsConfig, modules) {
|
|
1259
1327
|
try {
|
|
1260
1328
|
var _tmsConfig$hooks;
|
|
1261
1329
|
|
|
1262
|
-
//
|
|
1263
|
-
const
|
|
1330
|
+
// 获取所有模块,合并模块依赖的模块
|
|
1331
|
+
const modulesConfig = getModulesConfig(modules, tmsConfig.appName, false); // 获取所有的分包
|
|
1332
|
+
|
|
1333
|
+
const subPackages = getSubPackages$3(modulesConfig); // 获取app.json的配置
|
|
1264
1334
|
|
|
1265
|
-
const appJson = getAppJsonContent(resolve$
|
|
1335
|
+
const appJson = getAppJsonContent(resolve$c('./app.json')); // 更新app.json中的subpackages
|
|
1266
1336
|
|
|
1267
|
-
|
|
1337
|
+
appJson.subpackages = subPackages;
|
|
1338
|
+
appJson.subpackages.sort((item1, item2) => item1.name.localeCompare(item2.name)); // 处理appJson中重复||冲突的地方
|
|
1268
1339
|
|
|
1269
1340
|
fixAppJson(appJson); // 更新主包,需在subpackages处理完成后执行, pages/
|
|
1270
1341
|
|
|
1271
1342
|
updateMainPackages(appJson, tmsConfig.mainPackages);
|
|
1272
|
-
fs$
|
|
1343
|
+
fs$c.writeFileSync(resolve$c(`${tmsConfig.outputDir}/app.json`), JSON.stringify(appJson, null, 2), 'utf8');
|
|
1273
1344
|
|
|
1274
1345
|
if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.updateAppJson) === 'function') {
|
|
1275
1346
|
var _tmsConfig$hooks2;
|
|
1276
1347
|
|
|
1277
1348
|
tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.updateAppJson({
|
|
1278
|
-
tmsConfig: filterField$
|
|
1349
|
+
tmsConfig: filterField$3(tmsConfig, ['gitAccount']),
|
|
1279
1350
|
modules,
|
|
1280
1351
|
appJson,
|
|
1281
1352
|
isDev: global$4.getData('isDev')
|
|
@@ -1285,11 +1356,12 @@ function buildOutputAppJson$1(tmsConfig, modules) {
|
|
|
1285
1356
|
return appJson;
|
|
1286
1357
|
} catch (e) {
|
|
1287
1358
|
handleError$5(`生成app.json出现错误: ${e}`);
|
|
1359
|
+
info$9(e);
|
|
1288
1360
|
}
|
|
1289
1361
|
}
|
|
1290
1362
|
|
|
1291
1363
|
var buildAppJson = {
|
|
1292
|
-
buildOutputAppJson: buildOutputAppJson$
|
|
1364
|
+
buildOutputAppJson: buildOutputAppJson$2
|
|
1293
1365
|
};
|
|
1294
1366
|
|
|
1295
1367
|
/**
|
|
@@ -1300,13 +1372,13 @@ const crypto$2 = require$$1__default$5;
|
|
|
1300
1372
|
const {
|
|
1301
1373
|
downloadRepoForGit,
|
|
1302
1374
|
pullRepoForGit,
|
|
1303
|
-
resolve: resolve$
|
|
1375
|
+
resolve: resolve$b
|
|
1304
1376
|
} = widgets;
|
|
1305
1377
|
const {
|
|
1306
|
-
fail: fail$
|
|
1307
|
-
info: info$
|
|
1378
|
+
fail: fail$6,
|
|
1379
|
+
info: info$8
|
|
1308
1380
|
} = log$1;
|
|
1309
|
-
const fs$
|
|
1381
|
+
const fs$b = require$$0__default$2;
|
|
1310
1382
|
const shelljs$5 = require$$0__default$3;
|
|
1311
1383
|
const {
|
|
1312
1384
|
handleError: handleError$4
|
|
@@ -1322,7 +1394,7 @@ const {
|
|
|
1322
1394
|
*/
|
|
1323
1395
|
|
|
1324
1396
|
function replaceGitUrlAccount(httpRepoUrl, moduleName) {
|
|
1325
|
-
var _tmsConfig$
|
|
1397
|
+
var _tmsConfig$gitAccount;
|
|
1326
1398
|
|
|
1327
1399
|
// 用户本地的私有项目配置(用来配置环境\模块信息\账号信息)
|
|
1328
1400
|
const tmsConfig = global$3.getData('tmsConfig');
|
|
@@ -1330,7 +1402,7 @@ function replaceGitUrlAccount(httpRepoUrl, moduleName) {
|
|
|
1330
1402
|
const {
|
|
1331
1403
|
username = '',
|
|
1332
1404
|
pass = ''
|
|
1333
|
-
} = (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$
|
|
1405
|
+
} = (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$gitAccount = tmsConfig.gitAccount) === null || _tmsConfig$gitAccount === void 0 ? void 0 : _tmsConfig$gitAccount[moduleName]) || {};
|
|
1334
1406
|
const urlPrefixReg = /http(s)?:\/\//;
|
|
1335
1407
|
|
|
1336
1408
|
if (username && pass && urlPrefixReg.test(gitUrl)) {
|
|
@@ -1353,7 +1425,7 @@ function moveFile(sourceDir, targetDir, ignore = []) {
|
|
|
1353
1425
|
return new Promise((resolve, reject) => {
|
|
1354
1426
|
MetalSmith(__dirname).ignore(ignore).source(sourceDir).destination(targetDir).build(e => {
|
|
1355
1427
|
if (e) {
|
|
1356
|
-
fail$
|
|
1428
|
+
fail$6(`${sourceDir} moveFile ${targetDir}出现错误: ${e}`);
|
|
1357
1429
|
reject(e);
|
|
1358
1430
|
}
|
|
1359
1431
|
|
|
@@ -1440,16 +1512,16 @@ function collectDownLoadTasksMap(sourceDir, targetDir, modules) {
|
|
|
1440
1512
|
path: gitPath = ''
|
|
1441
1513
|
},
|
|
1442
1514
|
path,
|
|
1443
|
-
|
|
1515
|
+
moduleName
|
|
1444
1516
|
} = moduleInfo; // 处理仓库权限问题
|
|
1445
1517
|
|
|
1446
|
-
const gitUrl = replaceGitUrlAccount(httpRepoUrl,
|
|
1518
|
+
const gitUrl = replaceGitUrlAccount(httpRepoUrl, moduleName); // 根据gitUrl与branch计算md5
|
|
1447
1519
|
|
|
1448
1520
|
const md5Key = md5ByGitUrlBranch(gitUrl, branch); // git源码临时存在的源目录
|
|
1449
1521
|
|
|
1450
|
-
const sourcePath = resolve$
|
|
1522
|
+
const sourcePath = resolve$b(sourceDir, md5Key); // 模块源码要放到目标目录
|
|
1451
1523
|
|
|
1452
|
-
const targetPath = resolve$
|
|
1524
|
+
const targetPath = resolve$b(targetDir, path); // 从git源码仓库中找到模块源码路径 (一个仓库存在存放多个模块的情况)
|
|
1453
1525
|
|
|
1454
1526
|
const sourceModulePath = gitPath ? `${sourcePath}/${gitPath}` : sourcePath; // 下载完代码后,添加回调函数(主要将模块代码从临时目录移动代码到目标目录)
|
|
1455
1527
|
|
|
@@ -1459,7 +1531,7 @@ function collectDownLoadTasksMap(sourceDir, targetDir, modules) {
|
|
|
1459
1531
|
targetPath
|
|
1460
1532
|
},
|
|
1461
1533
|
fn: async (sourceModulePath, targetPath) => {
|
|
1462
|
-
if (fs$
|
|
1534
|
+
if (fs$b.existsSync(targetPath)) {
|
|
1463
1535
|
shelljs$5.rm('-rf', `${targetPath}/*`);
|
|
1464
1536
|
}
|
|
1465
1537
|
|
|
@@ -1474,14 +1546,14 @@ function collectDownLoadTasksMap(sourceDir, targetDir, modules) {
|
|
|
1474
1546
|
} else {
|
|
1475
1547
|
let promiseTask;
|
|
1476
1548
|
|
|
1477
|
-
if (fs$
|
|
1549
|
+
if (fs$b.existsSync(sourcePath) && fs$b.existsSync(`${sourcePath}/.git`)) {
|
|
1478
1550
|
promiseTask = (gitUrl, sourcePath, branch, httpRepoUrl) => {
|
|
1479
|
-
info$
|
|
1551
|
+
info$8(`git pull:${httpRepoUrl}`);
|
|
1480
1552
|
return pullRepoForGit(sourcePath, branch);
|
|
1481
1553
|
};
|
|
1482
1554
|
} else {
|
|
1483
1555
|
promiseTask = (gitUrl, sourcePath, branch, httpRepoUrl) => {
|
|
1484
|
-
info$
|
|
1556
|
+
info$8(`git clone: ${httpRepoUrl}`);
|
|
1485
1557
|
return downloadRepoForGit(gitUrl, sourcePath, branch);
|
|
1486
1558
|
};
|
|
1487
1559
|
}
|
|
@@ -1517,12 +1589,12 @@ function checkRemoteModGitUrlBranch(sourceDir, moduleInfo) {
|
|
|
1517
1589
|
buildGitTag,
|
|
1518
1590
|
httpRepoUrl
|
|
1519
1591
|
},
|
|
1520
|
-
|
|
1592
|
+
moduleName
|
|
1521
1593
|
} = moduleInfo;
|
|
1522
|
-
const gitUrl = replaceGitUrlAccount(httpRepoUrl,
|
|
1594
|
+
const gitUrl = replaceGitUrlAccount(httpRepoUrl, moduleName);
|
|
1523
1595
|
const md5Key = md5ByGitUrlBranch(gitUrl, buildGitTag);
|
|
1524
1596
|
|
|
1525
|
-
if (!fs$
|
|
1597
|
+
if (!fs$b.existsSync(`${sourceDir}/${md5Key}`)) {
|
|
1526
1598
|
return true;
|
|
1527
1599
|
}
|
|
1528
1600
|
}
|
|
@@ -1536,7 +1608,7 @@ var cloneModules_1 = {
|
|
|
1536
1608
|
};
|
|
1537
1609
|
|
|
1538
1610
|
const ci = require$$0__default$7;
|
|
1539
|
-
const path$
|
|
1611
|
+
const path$a = require$$1__default$2;
|
|
1540
1612
|
/**
|
|
1541
1613
|
* 获取小程序ci的Project对象
|
|
1542
1614
|
* @returns {Object} 小程序ci对象
|
|
@@ -1550,7 +1622,7 @@ const getMpCi = ({
|
|
|
1550
1622
|
}) => {
|
|
1551
1623
|
var _cfgJsonContent$packO;
|
|
1552
1624
|
|
|
1553
|
-
const cfgJsonContent = require(path$
|
|
1625
|
+
const cfgJsonContent = require(path$a.join(projectPath, 'project.config.json'));
|
|
1554
1626
|
|
|
1555
1627
|
const ignores = (cfgJsonContent === null || cfgJsonContent === void 0 ? void 0 : (_cfgJsonContent$packO = cfgJsonContent.packOptions) === null || _cfgJsonContent$packO === void 0 ? void 0 : _cfgJsonContent$packO.ignore.map(({
|
|
1556
1628
|
value
|
|
@@ -1616,8 +1688,8 @@ var mpCi = {
|
|
|
1616
1688
|
buildMpNpm: buildMpNpm$1
|
|
1617
1689
|
};
|
|
1618
1690
|
|
|
1619
|
-
const fs$
|
|
1620
|
-
const path$
|
|
1691
|
+
const fs$a = require$$0__default$2;
|
|
1692
|
+
const path$9 = require$$1__default$2;
|
|
1621
1693
|
const {
|
|
1622
1694
|
CACHE_FILE,
|
|
1623
1695
|
CACHE_DIR: CACHE_DIR$2
|
|
@@ -1631,7 +1703,7 @@ function getCache$1(projectDir, type) {
|
|
|
1631
1703
|
|
|
1632
1704
|
const filePath = `${CACHE_DIR$2}/${CACHE_FILE}`;
|
|
1633
1705
|
|
|
1634
|
-
if (!fs$
|
|
1706
|
+
if (!fs$a.existsSync(filePath)) {
|
|
1635
1707
|
return null;
|
|
1636
1708
|
}
|
|
1637
1709
|
|
|
@@ -1643,10 +1715,10 @@ function getCache$1(projectDir, type) {
|
|
|
1643
1715
|
function setCache$1(projectDir, type = 'miniprogram_npm', data) {
|
|
1644
1716
|
const filePath = `${CACHE_DIR$2}/${CACHE_FILE}`;
|
|
1645
1717
|
|
|
1646
|
-
if (!fs$
|
|
1647
|
-
const dir = path$
|
|
1718
|
+
if (!fs$a.existsSync(filePath)) {
|
|
1719
|
+
const dir = path$9.dirname(filePath);
|
|
1648
1720
|
ensureDirExist$1(dir);
|
|
1649
|
-
fs$
|
|
1721
|
+
fs$a.writeFileSync(filePath, '{}');
|
|
1650
1722
|
}
|
|
1651
1723
|
|
|
1652
1724
|
const content = require(filePath);
|
|
@@ -1658,7 +1730,7 @@ function setCache$1(projectDir, type = 'miniprogram_npm', data) {
|
|
|
1658
1730
|
content[projectDir] = {
|
|
1659
1731
|
[type]: data
|
|
1660
1732
|
};
|
|
1661
|
-
fs$
|
|
1733
|
+
fs$a.writeFileSync(filePath, JSON.stringify(content, null, 2));
|
|
1662
1734
|
}
|
|
1663
1735
|
|
|
1664
1736
|
var cache = {
|
|
@@ -1669,10 +1741,10 @@ var cache = {
|
|
|
1669
1741
|
/**
|
|
1670
1742
|
* 本文件主要负责项目或者分包依赖的npm的安装
|
|
1671
1743
|
*/
|
|
1672
|
-
const fs$
|
|
1744
|
+
const fs$9 = require$$0__default$2;
|
|
1673
1745
|
const fsExtra = require$$1__default$6;
|
|
1674
1746
|
const crypto$1 = require$$1__default$5;
|
|
1675
|
-
const path$
|
|
1747
|
+
const path$8 = require$$1__default$2;
|
|
1676
1748
|
const shell = require$$0__default$3;
|
|
1677
1749
|
const glob = require$$6__default;
|
|
1678
1750
|
const log = log$1;
|
|
@@ -1704,22 +1776,29 @@ const collectNpmTasksMap = (packageJsonFiles, cacheDir) => {
|
|
|
1704
1776
|
const npmTasksMap = new Map();
|
|
1705
1777
|
|
|
1706
1778
|
for (const packageJsonPath of packageJsonFiles) {
|
|
1707
|
-
const packageContent = fs$
|
|
1708
|
-
|
|
1779
|
+
const packageContent = fs$9.readFileSync(packageJsonPath);
|
|
1780
|
+
let packageJson;
|
|
1781
|
+
|
|
1782
|
+
try {
|
|
1783
|
+
packageJson = JSON.parse(packageContent);
|
|
1784
|
+
} catch (e) {
|
|
1785
|
+
throw new Error(`${packageJsonPath}json解析出现错误:${e}`);
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1709
1788
|
const md5Obj = {
|
|
1710
1789
|
dependencies: packageJson.dependencies || {}
|
|
1711
1790
|
};
|
|
1712
1791
|
|
|
1713
1792
|
if (Object.keys(md5Obj.dependencies).length !== 0) {
|
|
1714
1793
|
const md5Key = crypto$1.createHash('md5').update(JSON.stringify(md5Obj)).digest('hex');
|
|
1715
|
-
const cacheNMPath = path$
|
|
1716
|
-
const cacheNMTarFile = path$
|
|
1794
|
+
const cacheNMPath = path$8.join(cacheDir, md5Key);
|
|
1795
|
+
const cacheNMTarFile = path$8.join(cacheNMPath, 'node_modules.tar.gz'); // 下载后,添加回调函数 (拷贝node_modules.tar.gz到编译目录并解压)
|
|
1717
1796
|
|
|
1718
1797
|
const callback = {
|
|
1719
1798
|
params: {
|
|
1720
1799
|
cacheNMPath,
|
|
1721
1800
|
cacheNMTarFile,
|
|
1722
|
-
packageJsonDir: path$
|
|
1801
|
+
packageJsonDir: path$8.dirname(packageJsonPath),
|
|
1723
1802
|
shell
|
|
1724
1803
|
},
|
|
1725
1804
|
fn: async (cacheNMPath, cacheNMTarFile, packageJsonDir, shell) => {
|
|
@@ -1795,7 +1874,7 @@ const npmInstallAll$1 = async (modules, contextDir, cacheDir) => {
|
|
|
1795
1874
|
}) => fn(...Object.keys(cParams).map(key => cParams[key])));
|
|
1796
1875
|
return Promise.all(callArr);
|
|
1797
1876
|
}).catch(e => {
|
|
1798
|
-
handleError$3(`npm install ${params.packageJsonPath}出现错误:${e}
|
|
1877
|
+
handleError$3(`npm install ${params.packageJsonPath}出现错误:${e}`, true);
|
|
1799
1878
|
}));
|
|
1800
1879
|
});
|
|
1801
1880
|
await Promise.all(arrPromises);
|
|
@@ -1821,7 +1900,7 @@ const findFilesByFilter = (startPath, filter) => {
|
|
|
1821
1900
|
|
|
1822
1901
|
const find = (startPath, filter) => {
|
|
1823
1902
|
// 目录不存在
|
|
1824
|
-
if (!fs$
|
|
1903
|
+
if (!fs$9.existsSync(startPath)) {
|
|
1825
1904
|
log.fail(`${startPath}目录不存在`);
|
|
1826
1905
|
process.exit(-1);
|
|
1827
1906
|
return;
|
|
@@ -1834,10 +1913,10 @@ const findFilesByFilter = (startPath, filter) => {
|
|
|
1834
1913
|
return;
|
|
1835
1914
|
}
|
|
1836
1915
|
|
|
1837
|
-
const files = fs$
|
|
1916
|
+
const files = fs$9.readdirSync(startPath);
|
|
1838
1917
|
files.forEach(file => {
|
|
1839
|
-
const filename = path$
|
|
1840
|
-
const stat = fs$
|
|
1918
|
+
const filename = path$8.join(startPath, file);
|
|
1919
|
+
const stat = fs$9.lstatSync(filename); // 当前文件是文件夹类型,继续递归
|
|
1841
1920
|
|
|
1842
1921
|
if (stat.isDirectory()) {
|
|
1843
1922
|
find(filename, filter);
|
|
@@ -1863,7 +1942,7 @@ const findAllPackageJson = (subRoots = [], contextDir) => {
|
|
|
1863
1942
|
const packageJsonName = 'package.json'; // 查找文件名
|
|
1864
1943
|
|
|
1865
1944
|
const cwd = contextDir || dirPath;
|
|
1866
|
-
const result = [path$
|
|
1945
|
+
const result = [path$8.join(cwd, packageJsonName)]; // 默认填充根目录下的package.json
|
|
1867
1946
|
|
|
1868
1947
|
subRoots.forEach(subRoot => {
|
|
1869
1948
|
if (!subRoot.root) {
|
|
@@ -1871,7 +1950,7 @@ const findAllPackageJson = (subRoots = [], contextDir) => {
|
|
|
1871
1950
|
process.exit(1);
|
|
1872
1951
|
}
|
|
1873
1952
|
|
|
1874
|
-
const toppath = path$
|
|
1953
|
+
const toppath = path$8.join(cwd, subRoot.root); // 从该目录开始查找package.json文件
|
|
1875
1954
|
|
|
1876
1955
|
const list = findFilesByFilter(toppath, packageJsonName);
|
|
1877
1956
|
result.push(...list);
|
|
@@ -1887,7 +1966,7 @@ function cloudNpmInstall(contextDir) {
|
|
|
1887
1966
|
}
|
|
1888
1967
|
|
|
1889
1968
|
files.forEach(file => {
|
|
1890
|
-
const dir = path$
|
|
1969
|
+
const dir = path$8.dirname(file);
|
|
1891
1970
|
shell.cd(dir);
|
|
1892
1971
|
shell.exec('npx npm install --production --registry http://mirrors.tencent.com/npm/', {
|
|
1893
1972
|
silent: false
|
|
@@ -1905,12 +1984,12 @@ var npm = {
|
|
|
1905
1984
|
};
|
|
1906
1985
|
|
|
1907
1986
|
const crypto = require$$1__default$5;
|
|
1908
|
-
const fs$
|
|
1987
|
+
const fs$8 = require$$0__default$2;
|
|
1909
1988
|
|
|
1910
1989
|
function fileMd5$1(filePath) {
|
|
1911
1990
|
return new Promise((resolve, reject) => {
|
|
1912
1991
|
const md5sum = crypto.createHash('md5');
|
|
1913
|
-
const stream = fs$
|
|
1992
|
+
const stream = fs$8.ReadStream(filePath);
|
|
1914
1993
|
stream.on('data', d => {
|
|
1915
1994
|
md5sum.update(d);
|
|
1916
1995
|
});
|
|
@@ -1928,12 +2007,12 @@ var md5 = {
|
|
|
1928
2007
|
fileMd5: fileMd5$1
|
|
1929
2008
|
};
|
|
1930
2009
|
|
|
1931
|
-
const fs$
|
|
2010
|
+
const fs$7 = require$$0__default$2;
|
|
1932
2011
|
const semver$1 = require$$1__default$7;
|
|
1933
2012
|
const {
|
|
1934
|
-
resolve: resolve$
|
|
2013
|
+
resolve: resolve$a
|
|
1935
2014
|
} = widgets;
|
|
1936
|
-
const path$
|
|
2015
|
+
const path$7 = require$$1__default$2;
|
|
1937
2016
|
const shelljs$4 = require$$0__default$3;
|
|
1938
2017
|
const {
|
|
1939
2018
|
handleError: handleError$2
|
|
@@ -1942,60 +2021,77 @@ const {
|
|
|
1942
2021
|
const getLatestVersion = npmName => {
|
|
1943
2022
|
const data = shelljs$4.exec(`npm view ${npmName} version`);
|
|
1944
2023
|
return data.stdout || '0.0.0';
|
|
1945
|
-
};
|
|
1946
|
-
/**
|
|
1947
|
-
* 检查package.json的依赖大于node_module的版本,则返回true
|
|
1948
|
-
* @param {*} modules 模块
|
|
1949
|
-
* @param {*} cwd 待检查package.json所在的目录 (eg: 当前执行脚本的目录)
|
|
1950
|
-
* @param {*} outputDir 待检查node_modules存放的目录 (eg: dist/node_modules)
|
|
1951
|
-
* @returns
|
|
1952
|
-
*/
|
|
2024
|
+
}; // 收集package.json
|
|
1953
2025
|
|
|
1954
2026
|
|
|
1955
|
-
|
|
1956
|
-
// 步骤1. 收集package.json
|
|
2027
|
+
function collectHasPackageJson(modules, cwd, outputDir) {
|
|
1957
2028
|
const packageJsonName = 'package.json'; // 查找文件名
|
|
1958
2029
|
// 1.1根目录的package.json
|
|
1959
2030
|
|
|
1960
2031
|
const packageArr = [{
|
|
1961
|
-
srcPackageDir: path$
|
|
1962
|
-
destNpmDir: resolve$
|
|
2032
|
+
srcPackageDir: path$7.join(cwd, packageJsonName),
|
|
2033
|
+
destNpmDir: resolve$a(outputDir, 'node_modules')
|
|
1963
2034
|
}]; // 1.2模块的package.json
|
|
1964
2035
|
|
|
1965
2036
|
modules.forEach(item => {
|
|
1966
|
-
const srcPackageDir = path$
|
|
2037
|
+
const srcPackageDir = path$7.join(cwd, item.path, 'package.json');
|
|
1967
2038
|
|
|
1968
|
-
if (fs$
|
|
2039
|
+
if (fs$7.existsSync(srcPackageDir)) {
|
|
1969
2040
|
packageArr.push({
|
|
1970
2041
|
srcPackageDir,
|
|
1971
|
-
destNpmDir: resolve$
|
|
2042
|
+
destNpmDir: resolve$a(outputDir, item.root, 'node_modules')
|
|
1972
2043
|
});
|
|
1973
2044
|
}
|
|
1974
|
-
});
|
|
2045
|
+
});
|
|
2046
|
+
return packageArr;
|
|
2047
|
+
} // 读取package.json的依赖
|
|
1975
2048
|
|
|
1976
|
-
for (const item of packageArr) {
|
|
1977
|
-
const packageJson = fs$6.readFileSync(item.srcPackageDir, 'utf-8');
|
|
1978
|
-
let dependencies = {};
|
|
1979
2049
|
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
}
|
|
2050
|
+
function readPackageDependencies(srcPackageDir) {
|
|
2051
|
+
const packageJson = fs$7.readFileSync(srcPackageDir, 'utf-8');
|
|
2052
|
+
let dependencies = {};
|
|
2053
|
+
|
|
2054
|
+
try {
|
|
2055
|
+
const json = packageJson ? JSON.parse(packageJson) : {};
|
|
2056
|
+
dependencies = (json === null || json === void 0 ? void 0 : json.dependencies) || {};
|
|
2057
|
+
} catch (e) {
|
|
2058
|
+
handleError$2(`解析${srcPackageDir}报错,请检查是否是正确的json配置项 ${e}`);
|
|
2059
|
+
}
|
|
1986
2060
|
|
|
2061
|
+
return dependencies;
|
|
2062
|
+
}
|
|
2063
|
+
/**
|
|
2064
|
+
* 检查package.json的依赖大于node_module的版本,则返回true
|
|
2065
|
+
* @param {*} modules 模块
|
|
2066
|
+
* @param {*} cwd 待检查package.json所在的目录 (eg: 当前执行脚本的目录)
|
|
2067
|
+
* @param {*} outputDir 待检查node_modules存放的目录 (eg: dist/node_modules)
|
|
2068
|
+
* @returns
|
|
2069
|
+
*/
|
|
2070
|
+
|
|
2071
|
+
|
|
2072
|
+
const isDependenciesUpdate$1 = (modules, cwd, outputDir) => {
|
|
2073
|
+
// 步骤1. 收集package.json
|
|
2074
|
+
const packageArr = collectHasPackageJson(modules, cwd, outputDir); // 步骤2. 比较package.json的依赖与node_modules依赖的版本号
|
|
2075
|
+
|
|
2076
|
+
return checkPackageVersion$1(packageArr);
|
|
2077
|
+
}; // 比较package.json的依赖与node_modules依赖的版本号
|
|
2078
|
+
|
|
2079
|
+
|
|
2080
|
+
const checkPackageVersion$1 = packageArr => {
|
|
2081
|
+
for (const item of packageArr) {
|
|
2082
|
+
const dependencies = readPackageDependencies(item.srcPackageDir);
|
|
1987
2083
|
const dependenciesKeys = Object.keys(dependencies);
|
|
1988
2084
|
|
|
1989
2085
|
for (const key of dependenciesKeys) {
|
|
1990
|
-
const depPath = path$
|
|
2086
|
+
const depPath = path$7.join(item.destNpmDir, key);
|
|
1991
2087
|
|
|
1992
|
-
if (!fs$
|
|
2088
|
+
if (!fs$7.existsSync(depPath)) {
|
|
1993
2089
|
return true;
|
|
1994
2090
|
}
|
|
1995
2091
|
|
|
1996
|
-
const depPackagePath = path$
|
|
2092
|
+
const depPackagePath = path$7.join(depPath, 'package.json');
|
|
1997
2093
|
|
|
1998
|
-
if (fs$
|
|
2094
|
+
if (fs$7.existsSync(depPackagePath)) {
|
|
1999
2095
|
const packageData = require(depPackagePath);
|
|
2000
2096
|
|
|
2001
2097
|
if (dependencies[key] === 'latest') {
|
|
@@ -2017,16 +2113,17 @@ const isDependenciesUpdate$1 = (modules, cwd, outputDir) => {
|
|
|
2017
2113
|
};
|
|
2018
2114
|
|
|
2019
2115
|
var checkDependencies = {
|
|
2020
|
-
isDependenciesUpdate: isDependenciesUpdate$1
|
|
2116
|
+
isDependenciesUpdate: isDependenciesUpdate$1,
|
|
2117
|
+
checkPackageVersion: checkPackageVersion$1
|
|
2021
2118
|
};
|
|
2022
2119
|
|
|
2023
2120
|
const shelljs$3 = require$$0__default$3;
|
|
2024
|
-
const fs$
|
|
2025
|
-
const path$
|
|
2121
|
+
const fs$6 = require$$0__default$2;
|
|
2122
|
+
const path$6 = require$$1__default$2;
|
|
2026
2123
|
const io$1 = io$3;
|
|
2027
2124
|
const {
|
|
2028
2125
|
createTask: createTask$1,
|
|
2029
|
-
resolve: resolve$
|
|
2126
|
+
resolve: resolve$9
|
|
2030
2127
|
} = widgets;
|
|
2031
2128
|
const {
|
|
2032
2129
|
buildMpNpm
|
|
@@ -2042,8 +2139,8 @@ const {
|
|
|
2042
2139
|
npmInstallAll
|
|
2043
2140
|
} = npm;
|
|
2044
2141
|
const {
|
|
2045
|
-
fail: fail$
|
|
2046
|
-
info: info$
|
|
2142
|
+
fail: fail$5,
|
|
2143
|
+
info: info$7
|
|
2047
2144
|
} = log$1;
|
|
2048
2145
|
const {
|
|
2049
2146
|
fileMd5
|
|
@@ -2052,7 +2149,7 @@ const {
|
|
|
2052
2149
|
isDependenciesUpdate
|
|
2053
2150
|
} = checkDependencies;
|
|
2054
2151
|
|
|
2055
|
-
async function install$2(tmsConfig, modules,
|
|
2152
|
+
async function install$2(tmsConfig, modules, useCache = true) {
|
|
2056
2153
|
const cwd = process.cwd();
|
|
2057
2154
|
const npmInstallRes = await createTask$1(npmInstall, '小程序 开始npm install', '小程序npm install 完成')(tmsConfig, modules, useCache); // 如果npm install 没有命中缓存,则说明node_module有更新,此时必须构建miniprogram_npm
|
|
2058
2155
|
|
|
@@ -2069,8 +2166,8 @@ async function install$2(tmsConfig, modules, env, useCache = true) {
|
|
|
2069
2166
|
|
|
2070
2167
|
async function npmInstall(tmsConfig, modules, useCache) {
|
|
2071
2168
|
// 如果依赖没有更新和使用缓存数据(则命中缓存)
|
|
2072
|
-
if (!isDependenciesUpdate(modules, resolve$
|
|
2073
|
-
info$
|
|
2169
|
+
if (!isDependenciesUpdate(modules, resolve$9('./'), tmsConfig.outputDir) && useCache) {
|
|
2170
|
+
info$7('node_modules命中缓存');
|
|
2074
2171
|
return {
|
|
2075
2172
|
isCache: true
|
|
2076
2173
|
};
|
|
@@ -2078,18 +2175,18 @@ async function npmInstall(tmsConfig, modules, useCache) {
|
|
|
2078
2175
|
|
|
2079
2176
|
|
|
2080
2177
|
modules.forEach(item => {
|
|
2081
|
-
const outputModuleDir = resolve$
|
|
2178
|
+
const outputModuleDir = resolve$9(`${tmsConfig.outputDir}/${item.root}`);
|
|
2082
2179
|
|
|
2083
|
-
if (!fs$
|
|
2084
|
-
fail$
|
|
2180
|
+
if (!fs$6.existsSync(resolve$9(item.path))) {
|
|
2181
|
+
fail$5(`${item.path}模块代码路径不存在, 请检查tms.config.js的${item.name}模块的path`);
|
|
2085
2182
|
process.exit(1);
|
|
2086
2183
|
}
|
|
2087
2184
|
|
|
2088
2185
|
io$1.ensureDirExist(outputModuleDir);
|
|
2089
|
-
const modulePackagePath = resolve$
|
|
2090
|
-
if (fs$
|
|
2186
|
+
const modulePackagePath = resolve$9(item.path, 'package.json');
|
|
2187
|
+
if (fs$6.existsSync(modulePackagePath)) shelljs$3.cp('-Rf', modulePackagePath, outputModuleDir);
|
|
2091
2188
|
});
|
|
2092
|
-
await npmInstallAll(modules, resolve$
|
|
2189
|
+
await npmInstallAll(modules, resolve$9(tmsConfig.outputDir), `${CACHE_DIR$1}/node_modules`);
|
|
2093
2190
|
return {
|
|
2094
2191
|
isCache: false
|
|
2095
2192
|
};
|
|
@@ -2098,16 +2195,16 @@ async function npmInstall(tmsConfig, modules, useCache) {
|
|
|
2098
2195
|
|
|
2099
2196
|
async function mpCiInstall(tmsConfig, modules, useCache) {
|
|
2100
2197
|
const packageJsonFiles = [];
|
|
2101
|
-
const rootPackFile = resolve$
|
|
2198
|
+
const rootPackFile = resolve$9(`${tmsConfig.outputDir}/package.json`);
|
|
2102
2199
|
|
|
2103
|
-
if (fs$
|
|
2200
|
+
if (fs$6.existsSync(rootPackFile)) {
|
|
2104
2201
|
packageJsonFiles.push(rootPackFile);
|
|
2105
2202
|
}
|
|
2106
2203
|
|
|
2107
2204
|
modules.forEach(item => {
|
|
2108
|
-
const packageJsonFile = resolve$
|
|
2205
|
+
const packageJsonFile = resolve$9(`${tmsConfig.outputDir}/${item.root}/package.json`);
|
|
2109
2206
|
|
|
2110
|
-
if (fs$
|
|
2207
|
+
if (fs$6.existsSync(packageJsonFile)) {
|
|
2111
2208
|
packageJsonFiles.push(packageJsonFile);
|
|
2112
2209
|
}
|
|
2113
2210
|
});
|
|
@@ -2120,8 +2217,8 @@ async function mpCiInstall(tmsConfig, modules, useCache) {
|
|
|
2120
2217
|
if (useCache) {
|
|
2121
2218
|
let flag = true;
|
|
2122
2219
|
await Promise.all(packageJsonFiles.map(async item => {
|
|
2123
|
-
const packageDir = path$
|
|
2124
|
-
const mpDir = resolve$
|
|
2220
|
+
const packageDir = path$6.dirname(item);
|
|
2221
|
+
const mpDir = resolve$9(`${packageDir}/miniprogram_npm`);
|
|
2125
2222
|
const md5Value = await getMNPMd5(packageDir);
|
|
2126
2223
|
const preCache = getCache(mpDir, 'miniprogram_npm'); // console.log('miniprogram_npm', preCache, md5Value);
|
|
2127
2224
|
// 上一次构建成功 && 上次md5与当前本地的miniprogram_npm的md5 一致,才可以进入缓存
|
|
@@ -2134,14 +2231,14 @@ async function mpCiInstall(tmsConfig, modules, useCache) {
|
|
|
2134
2231
|
}
|
|
2135
2232
|
|
|
2136
2233
|
if (isCache) {
|
|
2137
|
-
info$
|
|
2234
|
+
info$7('miniprogram_npm命中缓存');
|
|
2138
2235
|
return;
|
|
2139
2236
|
} // 即将构建,在cache中标记开始
|
|
2140
2237
|
|
|
2141
2238
|
|
|
2142
2239
|
await Promise.all(packageJsonFiles.map(async item => {
|
|
2143
|
-
const packageDir = path$
|
|
2144
|
-
const mpDir = resolve$
|
|
2240
|
+
const packageDir = path$6.dirname(item);
|
|
2241
|
+
const mpDir = resolve$9(`${packageDir}/miniprogram_npm`);
|
|
2145
2242
|
setCache(mpDir, 'miniprogram_npm', {
|
|
2146
2243
|
md5: '',
|
|
2147
2244
|
status: statusMap.doing
|
|
@@ -2149,13 +2246,13 @@ async function mpCiInstall(tmsConfig, modules, useCache) {
|
|
|
2149
2246
|
}));
|
|
2150
2247
|
await buildMpNpm({
|
|
2151
2248
|
appId: tmsConfig.appId,
|
|
2152
|
-
projectPath: resolve$
|
|
2249
|
+
projectPath: resolve$9('./'),
|
|
2153
2250
|
privateKey: tmsConfig.privateKey
|
|
2154
2251
|
}); // 构建成功后,计算md5写入cache
|
|
2155
2252
|
|
|
2156
2253
|
await Promise.all(packageJsonFiles.map(async item => {
|
|
2157
|
-
const packageDir = path$
|
|
2158
|
-
const mpDir = resolve$
|
|
2254
|
+
const packageDir = path$6.dirname(item);
|
|
2255
|
+
const mpDir = resolve$9(`${packageDir}/miniprogram_npm`);
|
|
2159
2256
|
const md5Value = await getMNPMd5(packageDir);
|
|
2160
2257
|
setCache(mpDir, 'miniprogram_npm', {
|
|
2161
2258
|
md5: md5Value,
|
|
@@ -2172,13 +2269,14 @@ async function getMNPMd5(cwd) {
|
|
|
2172
2269
|
};
|
|
2173
2270
|
shelljs$3.cd(cwd);
|
|
2174
2271
|
|
|
2175
|
-
if (fs$
|
|
2272
|
+
if (fs$6.existsSync('miniprogram_npm')) {
|
|
2176
2273
|
shelljs$3.exec('tar -cvf ./miniprogram_npm.tar.gz ./miniprogram_npm', {
|
|
2177
2274
|
cwd,
|
|
2178
2275
|
...shellJsOption
|
|
2179
2276
|
});
|
|
2180
|
-
const
|
|
2181
|
-
|
|
2277
|
+
const tarDir = path$6.join(cwd, './miniprogram_npm.tar.gz');
|
|
2278
|
+
const md5Value = await fileMd5(tarDir);
|
|
2279
|
+
shelljs$3.rm('-rf', tarDir);
|
|
2182
2280
|
return md5Value;
|
|
2183
2281
|
}
|
|
2184
2282
|
|
|
@@ -2188,29 +2286,29 @@ async function getMNPMd5(cwd) {
|
|
|
2188
2286
|
var install_1 = install$2;
|
|
2189
2287
|
|
|
2190
2288
|
const shelljs$2 = require$$0__default$3;
|
|
2191
|
-
const fs$
|
|
2289
|
+
const fs$5 = require$$0__default$2;
|
|
2192
2290
|
const io = io$3;
|
|
2193
2291
|
const {
|
|
2194
|
-
resolve: resolve$
|
|
2292
|
+
resolve: resolve$8,
|
|
2195
2293
|
createTask
|
|
2196
2294
|
} = widgets;
|
|
2197
2295
|
const {
|
|
2198
|
-
buildOutputAppJson
|
|
2296
|
+
buildOutputAppJson: buildOutputAppJson$1
|
|
2199
2297
|
} = buildAppJson;
|
|
2200
2298
|
const {
|
|
2201
2299
|
MODULE_CODE_DIR,
|
|
2202
|
-
DEFAULT_COPY_CONFIG
|
|
2300
|
+
DEFAULT_COPY_CONFIG: DEFAULT_COPY_CONFIG$1
|
|
2203
2301
|
} = require$$4;
|
|
2204
2302
|
const {
|
|
2205
2303
|
cloneModules
|
|
2206
2304
|
} = cloneModules_1;
|
|
2207
2305
|
const {
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
} = tmsMpconfig;
|
|
2306
|
+
getModulesByMergeDepModules: getModulesByMergeDepModules$2,
|
|
2307
|
+
getSubPackages: getSubPackages$2
|
|
2308
|
+
} = tmsMpconfig.exports;
|
|
2211
2309
|
const {
|
|
2212
|
-
fail: fail$
|
|
2213
|
-
info: info$
|
|
2310
|
+
fail: fail$4,
|
|
2311
|
+
info: info$6
|
|
2214
2312
|
} = log$1;
|
|
2215
2313
|
const install$1 = install_1;
|
|
2216
2314
|
/**
|
|
@@ -2222,11 +2320,11 @@ const install$1 = install_1;
|
|
|
2222
2320
|
*/
|
|
2223
2321
|
|
|
2224
2322
|
const cpFilesToOutput = function (tmsConfig, defaultFiles) {
|
|
2225
|
-
const outputDir = resolve$
|
|
2323
|
+
const outputDir = resolve$8(tmsConfig.outputDir);
|
|
2226
2324
|
io.ensureDirExist(outputDir);
|
|
2227
2325
|
defaultFiles.forEach(item => {
|
|
2228
|
-
if (fs$
|
|
2229
|
-
shelljs$2.cp('-rf', resolve$
|
|
2326
|
+
if (fs$5.existsSync(resolve$8(item))) {
|
|
2327
|
+
shelljs$2.cp('-rf', resolve$8(item), resolve$8(tmsConfig.outputDir, item));
|
|
2230
2328
|
}
|
|
2231
2329
|
});
|
|
2232
2330
|
};
|
|
@@ -2244,7 +2342,7 @@ function checkConfig(targetModules) {
|
|
|
2244
2342
|
} // 判断源码目录是否有该模块
|
|
2245
2343
|
|
|
2246
2344
|
|
|
2247
|
-
if (item.path && !fs$
|
|
2345
|
+
if (item.path && !fs$5.existsSync(resolve$8(item.path))) {
|
|
2248
2346
|
throw new Error(`${item.path}模块代码路径不存在, 请检查tms.config.js的${item.name}模块的path`);
|
|
2249
2347
|
}
|
|
2250
2348
|
}
|
|
@@ -2254,39 +2352,38 @@ function checkConfig(targetModules) {
|
|
|
2254
2352
|
|
|
2255
2353
|
async function task(tmsConfig, targetModules) {
|
|
2256
2354
|
// 下载和移动代码
|
|
2257
|
-
await createTask(cloneModules, '开始下载模块代码', '下载模块代码码完成')(MODULE_CODE_DIR, resolve$
|
|
2355
|
+
await createTask(cloneModules, '开始下载模块代码', '下载模块代码码完成')(MODULE_CODE_DIR, resolve$8('./'), targetModules); // 获取所有模块,合并模块依赖的模块
|
|
2258
2356
|
|
|
2259
|
-
|
|
2357
|
+
const newModules = getModulesByMergeDepModules$2(tmsConfig, targetModules, true); // 获取所有的分包
|
|
2260
2358
|
|
|
2261
|
-
|
|
2262
|
-
checkConfig(
|
|
2359
|
+
const newSubPackages = getSubPackages$2(newModules);
|
|
2360
|
+
checkConfig(newSubPackages); // 拷贝相关配置文件到输出目录
|
|
2263
2361
|
|
|
2264
|
-
await createTask(cpFilesToOutput, '开始拷贝文件到编译输出目录', '拷贝文件到编译输出目录完成')(tmsConfig, DEFAULT_COPY_CONFIG); // install
|
|
2362
|
+
await createTask(cpFilesToOutput, '开始拷贝文件到编译输出目录', '拷贝文件到编译输出目录完成')(tmsConfig, DEFAULT_COPY_CONFIG$1); // install
|
|
2265
2363
|
|
|
2266
|
-
await install$1(tmsConfig,
|
|
2364
|
+
await install$1(tmsConfig, newSubPackages); // 动态生成编译后的app.json;
|
|
2267
2365
|
|
|
2268
|
-
await createTask(buildOutputAppJson, '开始生成编译后的app.json', '生成编译后的app.json完成')(tmsConfig, newModules);
|
|
2269
|
-
return
|
|
2366
|
+
await createTask(buildOutputAppJson$1, '开始生成编译后的app.json', '生成编译后的app.json完成')(tmsConfig, newModules);
|
|
2367
|
+
return {
|
|
2368
|
+
modules: newModules,
|
|
2369
|
+
subPackages: newSubPackages
|
|
2370
|
+
};
|
|
2270
2371
|
}
|
|
2271
2372
|
|
|
2272
2373
|
async function init$5(tmsConfig, targetModules) {
|
|
2273
2374
|
try {
|
|
2274
|
-
const
|
|
2275
|
-
return
|
|
2276
|
-
targetModules: newModules
|
|
2277
|
-
};
|
|
2375
|
+
const taskRes = await task(tmsConfig, targetModules);
|
|
2376
|
+
return taskRes;
|
|
2278
2377
|
} catch (error) {
|
|
2279
2378
|
const errMsg = typeof error === 'object' ? error.message : error;
|
|
2280
|
-
fail$
|
|
2281
|
-
info$
|
|
2379
|
+
fail$4(`初始化流程出现错误${errMsg}`);
|
|
2380
|
+
info$6('详细的错误信息', error);
|
|
2282
2381
|
process.exit(1);
|
|
2283
2382
|
}
|
|
2284
2383
|
}
|
|
2285
2384
|
|
|
2286
2385
|
var init_1 = init$5;
|
|
2287
2386
|
|
|
2288
|
-
var dev$3 = {exports: {}};
|
|
2289
|
-
|
|
2290
2387
|
/* eslint-disable no-param-reassign */
|
|
2291
2388
|
const strip = require$$0__default$8; // 匹配规则
|
|
2292
2389
|
|
|
@@ -2323,16 +2420,16 @@ var findCssImport = {
|
|
|
2323
2420
|
|
|
2324
2421
|
/* eslint-disable no-param-reassign */
|
|
2325
2422
|
const {
|
|
2326
|
-
fail: fail$
|
|
2423
|
+
fail: fail$3
|
|
2327
2424
|
} = log$1;
|
|
2328
2425
|
|
|
2329
2426
|
function pluginError$3(error, isWatch) {
|
|
2330
2427
|
const errMsg = error.message;
|
|
2331
2428
|
|
|
2332
2429
|
if (isWatch) {
|
|
2333
|
-
fail$
|
|
2430
|
+
fail$3(errMsg);
|
|
2334
2431
|
} else {
|
|
2335
|
-
fail$
|
|
2432
|
+
fail$3(errMsg);
|
|
2336
2433
|
process.exit(1);
|
|
2337
2434
|
}
|
|
2338
2435
|
}
|
|
@@ -2344,7 +2441,7 @@ var pluginError_1 = {
|
|
|
2344
2441
|
/* eslint-disable no-param-reassign */
|
|
2345
2442
|
const through$2 = require$$0__default$9;
|
|
2346
2443
|
const precinct = require$$1__default$8;
|
|
2347
|
-
const path$
|
|
2444
|
+
const path$5 = require$$1__default$2;
|
|
2348
2445
|
const {
|
|
2349
2446
|
findCssImports
|
|
2350
2447
|
} = findCssImport;
|
|
@@ -2354,9 +2451,9 @@ const {
|
|
|
2354
2451
|
diffContentCopyFile: diffContentCopyFile$2
|
|
2355
2452
|
} = io$3;
|
|
2356
2453
|
const {
|
|
2357
|
-
resolve: resolve$
|
|
2454
|
+
resolve: resolve$7
|
|
2358
2455
|
} = widgets;
|
|
2359
|
-
const fs$
|
|
2456
|
+
const fs$4 = require$$0__default$2;
|
|
2360
2457
|
const {
|
|
2361
2458
|
pluginError: pluginError$2
|
|
2362
2459
|
} = pluginError_1;
|
|
@@ -2369,16 +2466,16 @@ const dfsFindCommonDep$2 = function (anaFileOriginFile, anaFileDestFile, extensi
|
|
|
2369
2466
|
let contents = '';
|
|
2370
2467
|
|
|
2371
2468
|
try {
|
|
2372
|
-
contents = fs$
|
|
2469
|
+
contents = fs$4.readFileSync(anaFileOriginFile, 'utf8');
|
|
2373
2470
|
} catch (e) {
|
|
2374
2471
|
pluginError$2(e, isWatch);
|
|
2375
2472
|
}
|
|
2376
2473
|
|
|
2377
|
-
const deps = cssFilter.indexOf(path$
|
|
2474
|
+
const deps = cssFilter.indexOf(path$5.extname(anaFileOriginFile)) > -1 ? findCssImports(contents) : precinct(contents);
|
|
2378
2475
|
deps.forEach(depItem => {
|
|
2379
2476
|
if (depItem.startsWith('.')) {
|
|
2380
2477
|
// 被依赖文件的存在的绝对路径
|
|
2381
|
-
const depOriginPath = path$
|
|
2478
|
+
const depOriginPath = path$5.join(path$5.dirname(anaFileOriginFile), depItem); // 被依赖文件加上后缀
|
|
2382
2479
|
|
|
2383
2480
|
const {
|
|
2384
2481
|
ext: extAlias,
|
|
@@ -2386,12 +2483,12 @@ const dfsFindCommonDep$2 = function (anaFileOriginFile, anaFileDestFile, extensi
|
|
|
2386
2483
|
extPath
|
|
2387
2484
|
} = ext$2(depOriginPath, extensions);
|
|
2388
2485
|
|
|
2389
|
-
if (!fs$
|
|
2486
|
+
if (!fs$4.existsSync(depOriginFile)) {
|
|
2390
2487
|
pluginError$2(new Error(`${anaFileOriginFile}引用路径${depOriginFile}文件不存在, 请检查应用路径`), isWatch);
|
|
2391
2488
|
return;
|
|
2392
2489
|
}
|
|
2393
2490
|
|
|
2394
|
-
const depDestPath = resolve$
|
|
2491
|
+
const depDestPath = resolve$7(path$5.dirname(anaFileDestFile), depItem);
|
|
2395
2492
|
const depDestFile = depDestPath.endsWith(extAlias) ? depDestPath : depDestPath + extPath;
|
|
2396
2493
|
|
|
2397
2494
|
if (!resDep.has(depDestFile)) {
|
|
@@ -2415,19 +2512,19 @@ function mpCommonDep$1(tmsConfig, module, extensions = [], isWatch = true) {
|
|
|
2415
2512
|
const stream = through$2.obj(function (file, enc, cb) {
|
|
2416
2513
|
// 依赖分析的文件
|
|
2417
2514
|
const anaFileOriginFile = file.history[0];
|
|
2418
|
-
const anaFileRelativeModule = path$
|
|
2419
|
-
const anaFileDestFile = resolve$
|
|
2515
|
+
const anaFileRelativeModule = path$5.relative(resolve$7(module.from), anaFileOriginFile);
|
|
2516
|
+
const anaFileDestFile = resolve$7(tmsConfig.outputDir, module.to, anaFileRelativeModule);
|
|
2420
2517
|
|
|
2421
2518
|
if (file.isBuffer()) {
|
|
2422
2519
|
let contents = String(file.contents);
|
|
2423
|
-
const deps = cssFilter.indexOf(path$
|
|
2520
|
+
const deps = cssFilter.indexOf(path$5.extname(file.path)) > -1 ? findCssImports(contents) : precinct(contents);
|
|
2424
2521
|
const copyModules = new Map();
|
|
2425
2522
|
Object.keys(tmsConfig.dependencies).forEach(includeName => {
|
|
2426
2523
|
const includePath = tmsConfig.dependencies[includeName];
|
|
2427
2524
|
deps.forEach(depItem => {
|
|
2428
2525
|
if (depItem.indexOf(includeName) > -1) {
|
|
2429
2526
|
// 被依赖文件的存在的绝对路径 (eg: /User/thirdparty/loadsh)
|
|
2430
|
-
const depOriginPath = path$
|
|
2527
|
+
const depOriginPath = path$5.join(path$5.dirname(anaFileOriginFile), depItem); // 被依赖文件加上后缀
|
|
2431
2528
|
|
|
2432
2529
|
const {
|
|
2433
2530
|
ext: extAlias,
|
|
@@ -2445,7 +2542,7 @@ function mpCommonDep$1(tmsConfig, module, extensions = [], isWatch = true) {
|
|
|
2445
2542
|
const regRes = depItem.match(reg) || [];
|
|
2446
2543
|
|
|
2447
2544
|
if (regRes[2]) {
|
|
2448
|
-
const depDestPath = resolve$
|
|
2545
|
+
const depDestPath = resolve$7(tmsConfig.outputDir, module.to, includeName, regRes[2]);
|
|
2449
2546
|
const depDestFile = depDestPath.endsWith(extAlias) ? depDestPath : depDestPath + extPath;
|
|
2450
2547
|
|
|
2451
2548
|
if (!copyModules.has(depDestFile)) {
|
|
@@ -2453,7 +2550,7 @@ function mpCommonDep$1(tmsConfig, module, extensions = [], isWatch = true) {
|
|
|
2453
2550
|
depOriginFile,
|
|
2454
2551
|
depDestFile,
|
|
2455
2552
|
beforeDepPath: depItem,
|
|
2456
|
-
afterDepPath: path$
|
|
2553
|
+
afterDepPath: path$5.relative(path$5.dirname(anaFileDestFile), depDestPath).replace(/\\/g, '/')
|
|
2457
2554
|
});
|
|
2458
2555
|
}
|
|
2459
2556
|
}
|
|
@@ -2491,16 +2588,16 @@ var mpCommonDep_1 = {
|
|
|
2491
2588
|
|
|
2492
2589
|
/* eslint-disable no-param-reassign */
|
|
2493
2590
|
const through$1 = require$$0__default$9;
|
|
2494
|
-
const path$
|
|
2591
|
+
const path$4 = require$$1__default$2;
|
|
2495
2592
|
const {
|
|
2496
2593
|
ext: ext$1,
|
|
2497
2594
|
fileInDir: fileInDir$1,
|
|
2498
2595
|
diffContentCopyFile: diffContentCopyFile$1
|
|
2499
2596
|
} = io$3;
|
|
2500
2597
|
const {
|
|
2501
|
-
resolve: resolve$
|
|
2598
|
+
resolve: resolve$6
|
|
2502
2599
|
} = widgets;
|
|
2503
|
-
const fs$
|
|
2600
|
+
const fs$3 = require$$0__default$2;
|
|
2504
2601
|
const {
|
|
2505
2602
|
pluginError: pluginError$1
|
|
2506
2603
|
} = pluginError_1;
|
|
@@ -2512,8 +2609,8 @@ function mpJsonDep$1(tmsConfig, module, extensions = ['.json'], filesExt = ['.wx
|
|
|
2512
2609
|
const stream = through$1.obj(function (file, enc, cb) {
|
|
2513
2610
|
// 当前分析的文件的路径
|
|
2514
2611
|
const anaFileOriginFile = file.history[0];
|
|
2515
|
-
const anaFileRelativeModule = path$
|
|
2516
|
-
const anaFileDestFile = resolve$
|
|
2612
|
+
const anaFileRelativeModule = path$4.relative(resolve$6(module.from), anaFileOriginFile);
|
|
2613
|
+
const anaFileDestFile = resolve$6(tmsConfig.outputDir, module.to, anaFileRelativeModule);
|
|
2517
2614
|
|
|
2518
2615
|
if (file.isBuffer()) {
|
|
2519
2616
|
let contents = String(file.contents);
|
|
@@ -2533,7 +2630,7 @@ function mpJsonDep$1(tmsConfig, module, extensions = ['.json'], filesExt = ['.wx
|
|
|
2533
2630
|
const componentPath = contents.usingComponents[componentKey];
|
|
2534
2631
|
|
|
2535
2632
|
if (componentPath.indexOf(includeName) > -1) {
|
|
2536
|
-
const depOriginPath = path$
|
|
2633
|
+
const depOriginPath = path$4.join(path$4.dirname(anaFileOriginFile), componentPath); // 被依赖文件加上后缀
|
|
2537
2634
|
|
|
2538
2635
|
const {
|
|
2539
2636
|
ext: extAlias,
|
|
@@ -2552,7 +2649,7 @@ function mpJsonDep$1(tmsConfig, module, extensions = ['.json'], filesExt = ['.wx
|
|
|
2552
2649
|
const regRes = componentPath.match(reg) || [];
|
|
2553
2650
|
|
|
2554
2651
|
if (regRes[2]) {
|
|
2555
|
-
const depDestPath = resolve$
|
|
2652
|
+
const depDestPath = resolve$6(tmsConfig.outputDir, module.to, includeName, regRes[2]);
|
|
2556
2653
|
const depDestFile = depDestPath.endsWith(extAlias) ? depDestPath : depDestPath + extPath;
|
|
2557
2654
|
|
|
2558
2655
|
if (!copyModules.has(depDestFile)) {
|
|
@@ -2561,7 +2658,7 @@ function mpJsonDep$1(tmsConfig, module, extensions = ['.json'], filesExt = ['.wx
|
|
|
2561
2658
|
depOriginExt: extAlias,
|
|
2562
2659
|
depDestFile,
|
|
2563
2660
|
beforeDepPath: componentPath,
|
|
2564
|
-
afterDepPath: path$
|
|
2661
|
+
afterDepPath: path$4.relative(path$4.dirname(anaFileDestFile), depDestPath).replace(/\\/g, '/')
|
|
2565
2662
|
});
|
|
2566
2663
|
}
|
|
2567
2664
|
}
|
|
@@ -2586,7 +2683,7 @@ function mpJsonDep$1(tmsConfig, module, extensions = ['.json'], filesExt = ['.wx
|
|
|
2586
2683
|
const originFile = depOriginFile.replace(depOriginExt, extKey);
|
|
2587
2684
|
const destFile = depDestFile.replace(depOriginExt, extKey);
|
|
2588
2685
|
|
|
2589
|
-
if (fs$
|
|
2686
|
+
if (fs$3.existsSync(originFile)) {
|
|
2590
2687
|
diffContentCopyFile$1(originFile, destFile);
|
|
2591
2688
|
const extensionsFilter = ['.js', '.ts', '.wxss', '.less'];
|
|
2592
2689
|
|
|
@@ -2620,15 +2717,15 @@ var mpJsonDep_1 = {
|
|
|
2620
2717
|
/* eslint-disable no-param-reassign */
|
|
2621
2718
|
const through = require$$0__default$9;
|
|
2622
2719
|
const htmlparser2 = require$$1__default$9;
|
|
2623
|
-
const fs$
|
|
2624
|
-
const path$
|
|
2720
|
+
const fs$2 = require$$0__default$2;
|
|
2721
|
+
const path$3 = require$$1__default$2;
|
|
2625
2722
|
const {
|
|
2626
2723
|
diffContentCopyFile,
|
|
2627
2724
|
ext,
|
|
2628
2725
|
fileInDir
|
|
2629
2726
|
} = io$3;
|
|
2630
2727
|
const {
|
|
2631
|
-
resolve: resolve$
|
|
2728
|
+
resolve: resolve$5
|
|
2632
2729
|
} = widgets;
|
|
2633
2730
|
const {
|
|
2634
2731
|
dfsFindCommonDep
|
|
@@ -2667,7 +2764,7 @@ const dfsFindWxmlDep = function (anaFileOriginFile, anaFileDestFile, isWatch = t
|
|
|
2667
2764
|
let contents = '';
|
|
2668
2765
|
|
|
2669
2766
|
try {
|
|
2670
|
-
contents = fs$
|
|
2767
|
+
contents = fs$2.readFileSync(anaFileOriginFile, 'utf8');
|
|
2671
2768
|
} catch (e) {
|
|
2672
2769
|
pluginError(e, isWatch);
|
|
2673
2770
|
}
|
|
@@ -2677,7 +2774,7 @@ const dfsFindWxmlDep = function (anaFileOriginFile, anaFileDestFile, isWatch = t
|
|
|
2677
2774
|
var _attributes$src;
|
|
2678
2775
|
|
|
2679
2776
|
if (attributes !== null && attributes !== void 0 && (_attributes$src = attributes.src) !== null && _attributes$src !== void 0 && _attributes$src.startsWith('.')) {
|
|
2680
|
-
const depOriginPath = path$
|
|
2777
|
+
const depOriginPath = path$3.join(path$3.dirname(anaFileOriginFile), attributes.src); // 被依赖文件加上后缀
|
|
2681
2778
|
|
|
2682
2779
|
const {
|
|
2683
2780
|
ext,
|
|
@@ -2685,12 +2782,12 @@ const dfsFindWxmlDep = function (anaFileOriginFile, anaFileDestFile, isWatch = t
|
|
|
2685
2782
|
extPath
|
|
2686
2783
|
} = extFile(name, depOriginPath);
|
|
2687
2784
|
|
|
2688
|
-
if (!fs$
|
|
2785
|
+
if (!fs$2.existsSync(depOriginFile)) {
|
|
2689
2786
|
pluginError(new Error(`${anaFileOriginFile}引用的路径${depOriginFile}找不到应用文件,请检查引用路径`), isWatch);
|
|
2690
2787
|
return;
|
|
2691
2788
|
}
|
|
2692
2789
|
|
|
2693
|
-
const depDestPath = path$
|
|
2790
|
+
const depDestPath = path$3.join(path$3.dirname(anaFileDestFile), attributes.src);
|
|
2694
2791
|
const depDestFile = depDestPath.endsWith(ext) ? depDestPath : depDestPath + extPath; // 收集wxml依赖
|
|
2695
2792
|
|
|
2696
2793
|
if (['import', 'include'].indexOf(name) > -1) {
|
|
@@ -2742,8 +2839,8 @@ function mpWxmlDep$1(tmsConfig, module, isWatch) {
|
|
|
2742
2839
|
const stream = through.obj(function (file, enc, cb) {
|
|
2743
2840
|
// 依赖分析的文件
|
|
2744
2841
|
const anaFileOriginFile = file.history[0];
|
|
2745
|
-
const anaFileRelativeModule = path$
|
|
2746
|
-
const anaFileDestFile = resolve$
|
|
2842
|
+
const anaFileRelativeModule = path$3.relative(resolve$5(module.from), anaFileOriginFile);
|
|
2843
|
+
const anaFileDestFile = resolve$5(tmsConfig.outputDir, module.to, anaFileRelativeModule);
|
|
2747
2844
|
|
|
2748
2845
|
if (file.isBuffer()) {
|
|
2749
2846
|
let contents = String(file.contents);
|
|
@@ -2753,7 +2850,7 @@ function mpWxmlDep$1(tmsConfig, module, isWatch) {
|
|
|
2753
2850
|
const nameFilter = ['import', 'include', 'wxs'];
|
|
2754
2851
|
|
|
2755
2852
|
if (nameFilter.indexOf(name) > -1 && attributes.src) {
|
|
2756
|
-
const depOriginPath = path$
|
|
2853
|
+
const depOriginPath = path$3.join(path$3.dirname(anaFileOriginFile), attributes.src); // 处理后缀(源码引入依赖时,后缀不全的情况)
|
|
2757
2854
|
|
|
2758
2855
|
const {
|
|
2759
2856
|
ext,
|
|
@@ -2774,7 +2871,7 @@ function mpWxmlDep$1(tmsConfig, module, isWatch) {
|
|
|
2774
2871
|
const regRes = attributes.src.match(reg) || [];
|
|
2775
2872
|
|
|
2776
2873
|
if (regRes[2]) {
|
|
2777
|
-
const depDestPath = resolve$
|
|
2874
|
+
const depDestPath = resolve$5(tmsConfig.outputDir, module.to, includeName, regRes[2]);
|
|
2778
2875
|
const depDestFile = depDestPath.endsWith(ext) ? depDestPath : depDestPath + extPath;
|
|
2779
2876
|
|
|
2780
2877
|
if (!copyModules.has(depDestFile)) {
|
|
@@ -2782,7 +2879,7 @@ function mpWxmlDep$1(tmsConfig, module, isWatch) {
|
|
|
2782
2879
|
depOriginFile,
|
|
2783
2880
|
depDestFile,
|
|
2784
2881
|
beforeDepPath: attributes.src,
|
|
2785
|
-
afterDepPath: path$
|
|
2882
|
+
afterDepPath: path$3.relative(path$3.dirname(anaFileDestFile), depDestFile).replace(/\\/g, '/')
|
|
2786
2883
|
});
|
|
2787
2884
|
}
|
|
2788
2885
|
}
|
|
@@ -2801,7 +2898,7 @@ function mpWxmlDep$1(tmsConfig, module, isWatch) {
|
|
|
2801
2898
|
beforeDepPath,
|
|
2802
2899
|
afterDepPath
|
|
2803
2900
|
}) => {
|
|
2804
|
-
if (fs$
|
|
2901
|
+
if (fs$2.existsSync(depOriginFile)) {
|
|
2805
2902
|
diffContentCopyFile(depOriginFile, depDestFile);
|
|
2806
2903
|
const reg = new RegExp(`['"]${beforeDepPath}["']`, 'g');
|
|
2807
2904
|
contents = contents.replace(reg, `"${afterDepPath}"`);
|
|
@@ -2857,10 +2954,10 @@ const {
|
|
|
2857
2954
|
// const base64 = require('./plugins/postcss-font-base64');
|
|
2858
2955
|
|
|
2859
2956
|
const {
|
|
2860
|
-
fail
|
|
2957
|
+
fail: fail$2
|
|
2861
2958
|
} = log$1; // const since = task => file => (lastRun(task) > file.stat.ctime ? lastRun(task) : 0);
|
|
2862
2959
|
|
|
2863
|
-
var compile = function (tmsConfig, {
|
|
2960
|
+
var compile$1 = function (tmsConfig, {
|
|
2864
2961
|
glob,
|
|
2865
2962
|
destPath,
|
|
2866
2963
|
srcOption,
|
|
@@ -2882,11 +2979,11 @@ var compile = function (tmsConfig, {
|
|
|
2882
2979
|
});
|
|
2883
2980
|
return srcPipe // .pipe(replaceEnv(/process\.env(\.(\w*))?/g, tmsConfig.envData))
|
|
2884
2981
|
.pipe(mpCommonDep(tmsConfig, module, ['.js', '.ts', '.wxs', '.json'], isDev)).on('error', err => {
|
|
2885
|
-
fail(`mpCommonDep编译报错${err}`);
|
|
2982
|
+
fail$2(`mpCommonDep编译报错${err}`);
|
|
2886
2983
|
}).pipe(dest(newDestPath, {
|
|
2887
2984
|
overwrite: true
|
|
2888
2985
|
})).on('error', err => {
|
|
2889
|
-
fail(`js编译报错${err}`);
|
|
2986
|
+
fail$2(`js编译报错${err}`);
|
|
2890
2987
|
});
|
|
2891
2988
|
}
|
|
2892
2989
|
});
|
|
@@ -2901,7 +2998,7 @@ var compile = function (tmsConfig, {
|
|
|
2901
2998
|
const srcPipe = src$1(newGlobValue, { ...srcOption
|
|
2902
2999
|
});
|
|
2903
3000
|
return srcPipe.pipe(mpCommonDep(tmsConfig, module, ['.wxss', '.less'], isDev)).on('error', err => {
|
|
2904
|
-
fail(`mpCommonDep编译报错${err}`);
|
|
3001
|
+
fail$2(`mpCommonDep编译报错${err}`);
|
|
2905
3002
|
}) // .pipe(postcss([base64()]))
|
|
2906
3003
|
// .on('error', (err) => {
|
|
2907
3004
|
// fail(`postcss编译报错${err}`);
|
|
@@ -2911,7 +3008,7 @@ var compile = function (tmsConfig, {
|
|
|
2911
3008
|
// precision: 2, // 小数最大精度,默认为6
|
|
2912
3009
|
// }))
|
|
2913
3010
|
.pipe(dest(newDestPath)).on('error', err => {
|
|
2914
|
-
fail(`wxss编译报错${err}`);
|
|
3011
|
+
fail$2(`wxss编译报错${err}`);
|
|
2915
3012
|
});
|
|
2916
3013
|
}
|
|
2917
3014
|
});
|
|
@@ -2926,9 +3023,9 @@ var compile = function (tmsConfig, {
|
|
|
2926
3023
|
const srcPipe = src$1(newGlobValue, { ...srcOption
|
|
2927
3024
|
});
|
|
2928
3025
|
return srcPipe.pipe(mpJsonDep(tmsConfig, module, ['.json'], ['.wxml', '.json', '.js', '.ts', '.wxss', '.less'], isDev)).on('error', err => {
|
|
2929
|
-
fail(`mpJsonDep编译报错${err}`);
|
|
3026
|
+
fail$2(`mpJsonDep编译报错${err}`);
|
|
2930
3027
|
}).pipe(dest(newDestPath)).on('error', err => {
|
|
2931
|
-
fail(`json编译报错${err}`);
|
|
3028
|
+
fail$2(`json编译报错${err}`);
|
|
2932
3029
|
});
|
|
2933
3030
|
}
|
|
2934
3031
|
});
|
|
@@ -2943,9 +3040,9 @@ var compile = function (tmsConfig, {
|
|
|
2943
3040
|
const srcPipe = src$1(newGlobValue, { ...srcOption
|
|
2944
3041
|
});
|
|
2945
3042
|
return srcPipe.pipe(mpWxmlDep(tmsConfig, module, isDev)).on('error', err => {
|
|
2946
|
-
fail(`mpWxmlDep编译报错${err}`);
|
|
3043
|
+
fail$2(`mpWxmlDep编译报错${err}`);
|
|
2947
3044
|
}).pipe(dest(newDestPath)).on('error', err => {
|
|
2948
|
-
fail(`wxml编译报错${err}`);
|
|
3045
|
+
fail$2(`wxml编译报错${err}`);
|
|
2949
3046
|
});
|
|
2950
3047
|
}
|
|
2951
3048
|
});
|
|
@@ -2964,7 +3061,7 @@ var compile = function (tmsConfig, {
|
|
|
2964
3061
|
// fail(`image编译报错${err}`);
|
|
2965
3062
|
// })
|
|
2966
3063
|
.pipe(dest(newDestPath)).on('error', err => {
|
|
2967
|
-
fail(`image编译报错${err}`);
|
|
3064
|
+
fail$2(`image编译报错${err}`);
|
|
2968
3065
|
});
|
|
2969
3066
|
}
|
|
2970
3067
|
});
|
|
@@ -2979,7 +3076,7 @@ var compile = function (tmsConfig, {
|
|
|
2979
3076
|
const srcPipe = src$1(newGlobValue, { ...srcOption
|
|
2980
3077
|
});
|
|
2981
3078
|
return srcPipe.pipe(dest(newDestPath)).on('error', err => {
|
|
2982
|
-
fail(`编译报错${err}`);
|
|
3079
|
+
fail$2(`编译报错${err}`);
|
|
2983
3080
|
});
|
|
2984
3081
|
}
|
|
2985
3082
|
});
|
|
@@ -2993,7 +3090,7 @@ var compile = function (tmsConfig, {
|
|
|
2993
3090
|
// 该文件源于npm包 gulp-watch 但内部有bug, 故源码进行单独修改
|
|
2994
3091
|
|
|
2995
3092
|
const assign = require$$0__default$b;
|
|
2996
|
-
const path$
|
|
3093
|
+
const path$2 = require$$1__default$2;
|
|
2997
3094
|
const PluginError = require$$2__default$1;
|
|
2998
3095
|
const fancyLog = require$$3__default;
|
|
2999
3096
|
const colors = require$$4__default;
|
|
@@ -3003,8 +3100,8 @@ const {
|
|
|
3003
3100
|
} = require$$6__default$1;
|
|
3004
3101
|
const vinyl = require$$7__default;
|
|
3005
3102
|
const File = require$$8__default;
|
|
3006
|
-
const anymatch = require$$9__default;
|
|
3007
|
-
const pathIsAbsolute = require$$10__default;
|
|
3103
|
+
const anymatch = require$$9__default$1;
|
|
3104
|
+
const pathIsAbsolute = require$$10__default$1;
|
|
3008
3105
|
const globParent = require$$11__default;
|
|
3009
3106
|
const slash = require$$12__default;
|
|
3010
3107
|
|
|
@@ -3024,7 +3121,7 @@ function normalizeGlobs(globs) {
|
|
|
3024
3121
|
return globs;
|
|
3025
3122
|
}
|
|
3026
3123
|
|
|
3027
|
-
function watch$
|
|
3124
|
+
function watch$2(globs, opts, cb) {
|
|
3028
3125
|
globs = normalizeGlobs(globs);
|
|
3029
3126
|
|
|
3030
3127
|
if (typeof opts === 'function') {
|
|
@@ -3032,16 +3129,16 @@ function watch$1(globs, opts, cb) {
|
|
|
3032
3129
|
opts = {};
|
|
3033
3130
|
}
|
|
3034
3131
|
|
|
3035
|
-
opts = assign({}, watch$
|
|
3132
|
+
opts = assign({}, watch$2._defaultOptions, opts);
|
|
3036
3133
|
|
|
3037
3134
|
cb = cb || function () {};
|
|
3038
3135
|
|
|
3039
3136
|
function resolveFilepath(filepath) {
|
|
3040
3137
|
if (pathIsAbsolute(filepath)) {
|
|
3041
|
-
return path$
|
|
3138
|
+
return path$2.normalize(filepath);
|
|
3042
3139
|
}
|
|
3043
3140
|
|
|
3044
|
-
return path$
|
|
3141
|
+
return path$2.resolve(opts.cwd || process.cwd(), filepath);
|
|
3045
3142
|
}
|
|
3046
3143
|
|
|
3047
3144
|
function resolveGlob(glob) {
|
|
@@ -3097,7 +3194,7 @@ function watch$1(globs, opts, cb) {
|
|
|
3097
3194
|
let glob;
|
|
3098
3195
|
let currentFilepath = filepath;
|
|
3099
3196
|
|
|
3100
|
-
while (!(glob = globs[anymatch(globs, currentFilepath, true)]) && currentFilepath !== (currentFilepath = path$
|
|
3197
|
+
while (!(glob = globs[anymatch(globs, currentFilepath, true)]) && currentFilepath !== (currentFilepath = path$2.dirname(currentFilepath))) {} // eslint-disable-line no-empty-blocks/no-empty-blocks
|
|
3101
3198
|
|
|
3102
3199
|
|
|
3103
3200
|
if (!glob) {
|
|
@@ -3106,7 +3203,7 @@ function watch$1(globs, opts, cb) {
|
|
|
3106
3203
|
}
|
|
3107
3204
|
|
|
3108
3205
|
if (!baseForced) {
|
|
3109
|
-
fileOpts.base = path$
|
|
3206
|
+
fileOpts.base = path$2.normalize(globParent(glob));
|
|
3110
3207
|
} // Do not stat deleted files
|
|
3111
3208
|
|
|
3112
3209
|
|
|
@@ -3157,54 +3254,76 @@ function watch$1(globs, opts, cb) {
|
|
|
3157
3254
|
// Avoid modifying gulp-watch's default options inside a library/reusable package, please.
|
|
3158
3255
|
|
|
3159
3256
|
|
|
3160
|
-
watch$
|
|
3257
|
+
watch$2._defaultOptions = {
|
|
3161
3258
|
events: ['add', 'change', 'unlink'],
|
|
3162
3259
|
ignoreInitial: true,
|
|
3163
3260
|
readDelay: 10
|
|
3164
3261
|
};
|
|
3165
|
-
var gulpWatch = watch$
|
|
3262
|
+
var gulpWatch = watch$2;
|
|
3166
3263
|
|
|
3167
|
-
|
|
3168
|
-
const
|
|
3264
|
+
/* eslint-disable no-restricted-syntax */
|
|
3265
|
+
const watch$1 = gulpWatch;
|
|
3266
|
+
const path$1 = require$$1__default$2;
|
|
3169
3267
|
const shellJs = require$$0__default$3;
|
|
3170
3268
|
const {
|
|
3171
|
-
info: info$
|
|
3172
|
-
warn: warn$1
|
|
3269
|
+
info: info$5,
|
|
3270
|
+
warn: warn$1,
|
|
3271
|
+
fail: fail$1
|
|
3173
3272
|
} = log$1;
|
|
3174
3273
|
const {
|
|
3175
|
-
resolve: resolve$
|
|
3274
|
+
resolve: resolve$4
|
|
3176
3275
|
} = widgets;
|
|
3177
3276
|
const {
|
|
3178
3277
|
global: global$2
|
|
3179
3278
|
} = global_1;
|
|
3279
|
+
const {
|
|
3280
|
+
checkPackageVersion
|
|
3281
|
+
} = checkDependencies;
|
|
3180
3282
|
const {
|
|
3181
3283
|
findAllFilesOfDir
|
|
3182
3284
|
} = io$3;
|
|
3183
3285
|
const TIP_MAP = {
|
|
3184
|
-
'package.json':
|
|
3185
|
-
|
|
3286
|
+
'package.json': {
|
|
3287
|
+
tip: '依赖版本有变动,请重新执行tmskit run dev',
|
|
3288
|
+
check: (sourceFile, targetFile) => {
|
|
3289
|
+
const targetArr = targetFile.split('/');
|
|
3290
|
+
targetArr[targetArr.length - 1] = 'node_modules';
|
|
3291
|
+
const packageArr = [{
|
|
3292
|
+
srcPackageDir: sourceFile,
|
|
3293
|
+
destNpmDir: targetArr.join('/')
|
|
3294
|
+
}];
|
|
3295
|
+
return checkPackageVersion(packageArr);
|
|
3296
|
+
}
|
|
3297
|
+
},
|
|
3298
|
+
'module.config.json': {
|
|
3299
|
+
tip: '若dependencies字段有变动,请重新执行tmskit run dev才会生效',
|
|
3300
|
+
check: () => true
|
|
3301
|
+
}
|
|
3186
3302
|
};
|
|
3187
3303
|
|
|
3188
|
-
const logTip = (fileName, tipMap) => {
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3304
|
+
const logTip = (fileName, sourceFile, targetFile, tipMap) => {
|
|
3305
|
+
try {
|
|
3306
|
+
for (const item in tipMap) {
|
|
3307
|
+
if (fileName.indexOf(item) > -1 && tipMap[item].check(sourceFile, targetFile)) {
|
|
3308
|
+
warn$1(`${fileName}有更新, ${tipMap[item].tip}`);
|
|
3309
|
+
return;
|
|
3310
|
+
}
|
|
3194
3311
|
}
|
|
3195
|
-
}
|
|
3196
3312
|
|
|
3197
|
-
|
|
3313
|
+
info$5(`${fileName}有更新`);
|
|
3314
|
+
} catch (e) {
|
|
3315
|
+
fail$1(`${sourceFile}文件更新提示出现错误: ${e.message}`);
|
|
3316
|
+
}
|
|
3198
3317
|
};
|
|
3199
3318
|
|
|
3200
3319
|
const getTargetFile = (sourceFile, module, outputDir) => {
|
|
3201
|
-
const sourceFileRelativeModule = path.relative(resolve$
|
|
3202
|
-
const targetFile = resolve$
|
|
3320
|
+
const sourceFileRelativeModule = path$1.relative(resolve$4(module.from), sourceFile);
|
|
3321
|
+
const targetFile = resolve$4(outputDir, module.to, sourceFileRelativeModule);
|
|
3203
3322
|
return targetFile;
|
|
3204
3323
|
};
|
|
3205
3324
|
|
|
3206
3325
|
var watch_1 = function (globValue, watchOptions, callback, module) {
|
|
3207
|
-
watch(globValue, { // readDelay: 100,
|
|
3326
|
+
watch$1(globValue, { // readDelay: 100,
|
|
3208
3327
|
...watchOptions
|
|
3209
3328
|
}, vinyl => {
|
|
3210
3329
|
const sourceFile = vinyl.history[0];
|
|
@@ -3213,15 +3332,15 @@ var watch_1 = function (globValue, watchOptions, callback, module) {
|
|
|
3213
3332
|
const tmsConfig = global$2.getData('tmsConfig');
|
|
3214
3333
|
|
|
3215
3334
|
if (vinyl.event === 'addDir') {
|
|
3216
|
-
info$
|
|
3335
|
+
info$5(`更新${sourceFileName}目录`);
|
|
3217
3336
|
const files = findAllFilesOfDir(sourceFile);
|
|
3218
3337
|
|
|
3219
3338
|
for (const file of files) {
|
|
3220
3339
|
const fileDirArr = file.replace(/\\/g, '/').split('/');
|
|
3221
3340
|
const fileName = fileDirArr.slice(fileDirArr.length - 2).join('/');
|
|
3222
3341
|
const targetFile = getTargetFile(file, module, tmsConfig.outputDir);
|
|
3223
|
-
logTip(fileName, TIP_MAP);
|
|
3224
|
-
callback([file], path.dirname(targetFile));
|
|
3342
|
+
logTip(fileName, sourceFile, targetFile, TIP_MAP);
|
|
3343
|
+
callback([file], path$1.dirname(targetFile));
|
|
3225
3344
|
}
|
|
3226
3345
|
|
|
3227
3346
|
return;
|
|
@@ -3230,248 +3349,254 @@ var watch_1 = function (globValue, watchOptions, callback, module) {
|
|
|
3230
3349
|
const targetFile = getTargetFile(sourceFile, module, tmsConfig.outputDir);
|
|
3231
3350
|
|
|
3232
3351
|
if (vinyl.event === 'unlink' || vinyl.event === 'unlinkDir') {
|
|
3233
|
-
info$
|
|
3352
|
+
info$5(`删除${sourceFileName}`);
|
|
3234
3353
|
shellJs.rm('-rf', targetFile);
|
|
3235
3354
|
return;
|
|
3236
3355
|
}
|
|
3237
3356
|
|
|
3238
|
-
logTip(sourceFileName, TIP_MAP);
|
|
3239
|
-
return callback([sourceFile], path.dirname(targetFile));
|
|
3357
|
+
logTip(sourceFileName, sourceFile, targetFile, TIP_MAP);
|
|
3358
|
+
return callback([sourceFile], path$1.dirname(targetFile));
|
|
3240
3359
|
});
|
|
3241
3360
|
};
|
|
3242
3361
|
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
const watchEvents = ['add', 'change', 'unlink', 'addDir', 'unlinkDir'];
|
|
3269
|
-
|
|
3270
|
-
function excludeGlob(glob) {
|
|
3271
|
-
const otherArr = new Set();
|
|
3272
|
-
otherArr.add('!**/*.{ttf,otf,woff,eot}');
|
|
3273
|
-
Object.keys(glob).forEach(globKey => {
|
|
3274
|
-
if (typeof glob[globKey] === 'string') {
|
|
3275
|
-
const data = glob[globKey].startsWith('!') ? glob[globKey] : `!${glob[globKey]}`;
|
|
3276
|
-
otherArr.add(data);
|
|
3277
|
-
}
|
|
3362
|
+
const path = require$$1__default$2;
|
|
3363
|
+
const fs$1 = require$$0__default$2;
|
|
3364
|
+
const ora = require$$2__default;
|
|
3365
|
+
const chalk$2 = require$$0__default;
|
|
3366
|
+
const {
|
|
3367
|
+
parallel,
|
|
3368
|
+
series
|
|
3369
|
+
} = require$$0__default$a;
|
|
3370
|
+
const {
|
|
3371
|
+
resolve: resolve$3,
|
|
3372
|
+
mergeMap,
|
|
3373
|
+
filterField: filterField$2
|
|
3374
|
+
} = widgets;
|
|
3375
|
+
const {
|
|
3376
|
+
buildOutputAppJson
|
|
3377
|
+
} = buildAppJson;
|
|
3378
|
+
const {
|
|
3379
|
+
DEFAULT_COPY_CONFIG
|
|
3380
|
+
} = require$$4;
|
|
3381
|
+
const compile = compile$1;
|
|
3382
|
+
const watch = watch_1;
|
|
3383
|
+
const {
|
|
3384
|
+
info: info$4
|
|
3385
|
+
} = log$1;
|
|
3386
|
+
const watchEvents = ['add', 'change', 'unlink', 'addDir', 'unlinkDir'];
|
|
3278
3387
|
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
});
|
|
3288
|
-
return Array.from(otherArr);
|
|
3289
|
-
}
|
|
3388
|
+
function excludeGlob(glob) {
|
|
3389
|
+
const otherArr = new Set();
|
|
3390
|
+
otherArr.add('!**/*.{ttf,otf,woff,eot}');
|
|
3391
|
+
Object.keys(glob).forEach(globKey => {
|
|
3392
|
+
if (typeof glob[globKey] === 'string') {
|
|
3393
|
+
const data = glob[globKey].startsWith('!') ? glob[globKey] : `!${glob[globKey]}`;
|
|
3394
|
+
otherArr.add(data);
|
|
3395
|
+
}
|
|
3290
3396
|
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3397
|
+
if (Array.isArray(glob[globKey])) {
|
|
3398
|
+
glob[globKey].forEach(value => {
|
|
3399
|
+
if (typeof value === 'string') {
|
|
3400
|
+
const data = value.startsWith('!') ? value : `!${value}`;
|
|
3401
|
+
otherArr.add(data);
|
|
3402
|
+
}
|
|
3403
|
+
});
|
|
3404
|
+
}
|
|
3405
|
+
});
|
|
3406
|
+
return Array.from(otherArr);
|
|
3407
|
+
}
|
|
3408
|
+
|
|
3409
|
+
function adaptPath(pathDir, cwd = '') {
|
|
3410
|
+
let newPath = pathDir;
|
|
3411
|
+
newPath = newPath.startsWith('/') ? newPath : resolve$3(cwd, newPath);
|
|
3412
|
+
newPath = newPath.endsWith('/') ? newPath.slice(0, newPath.length - 1) : newPath;
|
|
3413
|
+
return newPath;
|
|
3414
|
+
}
|
|
3297
3415
|
|
|
3298
|
-
|
|
3299
|
-
|
|
3416
|
+
var dev$3 = async (tmsConfig, modules, subPackages, isDev = true) => {
|
|
3417
|
+
const compileTasksMap = new Map(); // 监听根目录的文件
|
|
3418
|
+
|
|
3419
|
+
mergeMap(compileTasksMap, compile(tmsConfig, {
|
|
3420
|
+
glob: {
|
|
3421
|
+
json: DEFAULT_COPY_CONFIG.map(item => resolve$3(item))
|
|
3422
|
+
},
|
|
3423
|
+
module: {
|
|
3424
|
+
from: resolve$3(),
|
|
3425
|
+
to: resolve$3(tmsConfig.outputDir)
|
|
3426
|
+
},
|
|
3427
|
+
destPath: resolve$3(tmsConfig.outputDir),
|
|
3428
|
+
srcOption: {
|
|
3429
|
+
allowEmpty: true
|
|
3430
|
+
},
|
|
3431
|
+
isDev
|
|
3432
|
+
})); // 监听模块的文件
|
|
3433
|
+
|
|
3434
|
+
for (let pkg of subPackages) {
|
|
3435
|
+
// 处理默认参数
|
|
3436
|
+
pkg = { ...{
|
|
3437
|
+
exclude: []
|
|
3438
|
+
},
|
|
3439
|
+
...pkg
|
|
3440
|
+
};
|
|
3441
|
+
const packagePath = adaptPath(pkg.path);
|
|
3442
|
+
|
|
3443
|
+
if (isDev) {
|
|
3444
|
+
// 监听模块配置文件
|
|
3445
|
+
watch([`${packagePath}/**/module.config.json`], {
|
|
3446
|
+
events: watchEvents
|
|
3447
|
+
}, () => buildOutputAppJson(tmsConfig, modules, isDev), {
|
|
3448
|
+
from: packagePath,
|
|
3449
|
+
to: packagePath
|
|
3450
|
+
});
|
|
3451
|
+
}
|
|
3300
3452
|
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
// js: ['app.js', 'app.ts'].map(item => resolve(item)),
|
|
3453
|
+
const excludes = pkg.exclude.map(ePath => {
|
|
3454
|
+
const newPath = adaptPath(ePath, packagePath);
|
|
3455
|
+
const ext = path.extname(ePath).slice(1);
|
|
3305
3456
|
|
|
3457
|
+
if (ext) {
|
|
3458
|
+
return `!${resolve$3(packagePath, newPath)}`;
|
|
3459
|
+
}
|
|
3460
|
+
|
|
3461
|
+
return `!${resolve$3(packagePath, newPath)}/**/*`;
|
|
3462
|
+
});
|
|
3463
|
+
const glob = {
|
|
3464
|
+
js: [`${packagePath}/**/*.{js,ts,wxs}`, ...excludes],
|
|
3465
|
+
json: [`${packagePath}/**/*.json`, `!${packagePath}/**/module.config.json`, ...excludes],
|
|
3466
|
+
wxss: [`${packagePath}/**/*.{less,wxss,scss,sass,styl}`, ...excludes],
|
|
3467
|
+
wxml: [`${packagePath}/**/*.wxml`, ...excludes],
|
|
3468
|
+
image: [`${packagePath}/**/*.{png,jpg,jpeg,gif,svg}`, ...excludes]
|
|
3469
|
+
};
|
|
3470
|
+
mergeMap(compileTasksMap, compile(tmsConfig, {
|
|
3471
|
+
glob: { ...glob,
|
|
3472
|
+
other: [`${packagePath}/**/*`, ...excludeGlob(glob)]
|
|
3306
3473
|
},
|
|
3474
|
+
destPath: resolve$3(tmsConfig.outputDir, pkg.root),
|
|
3307
3475
|
module: {
|
|
3308
|
-
from:
|
|
3309
|
-
to:
|
|
3476
|
+
from: pkg.path,
|
|
3477
|
+
to: pkg.root
|
|
3310
3478
|
},
|
|
3311
|
-
destPath: resolve(tmsConfig.outputDir),
|
|
3312
3479
|
srcOption: {
|
|
3313
3480
|
allowEmpty: true
|
|
3314
3481
|
},
|
|
3315
3482
|
isDev
|
|
3316
|
-
}));
|
|
3483
|
+
}));
|
|
3484
|
+
} // 静态资源目录-拷贝
|
|
3317
3485
|
|
|
3318
|
-
for (let module of newModules) {
|
|
3319
|
-
// 处理默认参数
|
|
3320
|
-
module = { ...{
|
|
3321
|
-
exclude: []
|
|
3322
|
-
},
|
|
3323
|
-
...module
|
|
3324
|
-
};
|
|
3325
|
-
const modulePath = adaptPath(module.path);
|
|
3326
3486
|
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3487
|
+
if (tmsConfig !== null && tmsConfig !== void 0 && tmsConfig.static && (tmsConfig === null || tmsConfig === void 0 ? void 0 : tmsConfig.static.length) > 0) {
|
|
3488
|
+
for (const item of tmsConfig.static) {
|
|
3489
|
+
item.from = adaptPath(item.from);
|
|
3490
|
+
item.to = adaptPath(item.to);
|
|
3491
|
+
let glob = {};
|
|
3492
|
+
const ext = path.extname(item.from).slice(1);
|
|
3493
|
+
|
|
3494
|
+
if (ext) {
|
|
3495
|
+
glob[ext] = [item.from];
|
|
3496
|
+
} else {
|
|
3497
|
+
glob = {
|
|
3498
|
+
js: [`${item.from}/**/*.{js,ts,wxs}`],
|
|
3499
|
+
json: [`${item.from}/**/*.json`],
|
|
3500
|
+
wxss: [`${item.from}/**/*.{less,wxss,scss,sass,styl}`],
|
|
3501
|
+
wxml: [`${item.from}/**/*.wxml`],
|
|
3502
|
+
image: [`${item.from}/**/*.{png,jpg,jpeg,gif,svg}`]
|
|
3503
|
+
};
|
|
3504
|
+
glob.other = [`${item.from}/**/*`, ...excludeGlob(glob)];
|
|
3335
3505
|
}
|
|
3336
3506
|
|
|
3337
|
-
const
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
wxss: [`${modulePath}/**/*.{less,wxss}`, ...excludes],
|
|
3342
|
-
wxml: [`${modulePath}/**/*.wxml`, ...excludes],
|
|
3343
|
-
image: [`${modulePath}/**/*.{png,jpg,jpeg,gif,svg}`, ...excludes]
|
|
3344
|
-
};
|
|
3345
|
-
mergeMap(compileTasksMap, compile$1(tmsConfig, {
|
|
3346
|
-
glob: { ...glob,
|
|
3347
|
-
other: [`${modulePath}/**/*`, ...excludeGlob(glob)]
|
|
3348
|
-
},
|
|
3349
|
-
destPath: resolve(tmsConfig.outputDir, module.root),
|
|
3507
|
+
const from = fs$1.lstatSync(item.from).isFile() ? path.dirname(item.from) : item.from;
|
|
3508
|
+
mergeMap(compileTasksMap, compile(tmsConfig, {
|
|
3509
|
+
glob,
|
|
3510
|
+
destPath: item.to,
|
|
3350
3511
|
module: {
|
|
3351
|
-
from
|
|
3352
|
-
to:
|
|
3512
|
+
from,
|
|
3513
|
+
to: item.to
|
|
3353
3514
|
},
|
|
3354
3515
|
srcOption: {
|
|
3355
3516
|
allowEmpty: true
|
|
3356
3517
|
},
|
|
3357
3518
|
isDev
|
|
3358
3519
|
}));
|
|
3359
|
-
} // 静态资源目录-拷贝
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
if (tmsConfig !== null && tmsConfig !== void 0 && tmsConfig.static && (tmsConfig === null || tmsConfig === void 0 ? void 0 : tmsConfig.static.length) > 0) {
|
|
3363
|
-
for (const item of tmsConfig.static) {
|
|
3364
|
-
item.from = adaptPath(item.from);
|
|
3365
|
-
item.to = adaptPath(item.to);
|
|
3366
|
-
let glob = {};
|
|
3367
|
-
const ext = path.extname(item.from).slice(1);
|
|
3368
|
-
|
|
3369
|
-
if (ext) {
|
|
3370
|
-
glob[ext] = [item.from];
|
|
3371
|
-
} else {
|
|
3372
|
-
glob = {
|
|
3373
|
-
js: [`${item.from}/**/*.{js,ts,wxs}`],
|
|
3374
|
-
json: [`${item.from}/**/*.json`],
|
|
3375
|
-
wxss: [`${item.from}/**/*.{less,wxss}`],
|
|
3376
|
-
wxml: [`${item.from}/**/*.wxml`],
|
|
3377
|
-
image: [`${item.from}/**/*.{png,jpg,jpeg,gif,svg}`]
|
|
3378
|
-
};
|
|
3379
|
-
glob.other = [`${item.from}/**/*`, ...excludeGlob(glob)];
|
|
3380
|
-
}
|
|
3381
|
-
|
|
3382
|
-
const from = fs.lstatSync(item.from).isFile() ? path.dirname(item.from) : item.from;
|
|
3383
|
-
mergeMap(compileTasksMap, compile$1(tmsConfig, {
|
|
3384
|
-
glob,
|
|
3385
|
-
destPath: item.to,
|
|
3386
|
-
module: {
|
|
3387
|
-
from,
|
|
3388
|
-
to: item.to
|
|
3389
|
-
},
|
|
3390
|
-
srcOption: {
|
|
3391
|
-
allowEmpty: true
|
|
3392
|
-
},
|
|
3393
|
-
isDev
|
|
3394
|
-
}));
|
|
3395
|
-
}
|
|
3396
3520
|
}
|
|
3521
|
+
}
|
|
3397
3522
|
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3523
|
+
let sTime;
|
|
3524
|
+
let eTime;
|
|
3525
|
+
const spinner = ora();
|
|
3401
3526
|
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3527
|
+
function start(cb) {
|
|
3528
|
+
info$4('启动编译...');
|
|
3529
|
+
spinner.start();
|
|
3530
|
+
sTime = new Date().getTime();
|
|
3531
|
+
cb();
|
|
3532
|
+
}
|
|
3408
3533
|
|
|
3409
|
-
|
|
3410
|
-
|
|
3534
|
+
async function end(cb) {
|
|
3535
|
+
var _tmsConfig$hooks;
|
|
3411
3536
|
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3537
|
+
if (isDev) {
|
|
3538
|
+
// 监听app.json
|
|
3539
|
+
watch([resolve$3('app.json')], {
|
|
3540
|
+
ignoreInitial: false,
|
|
3541
|
+
events: watchEvents
|
|
3542
|
+
}, () => buildOutputAppJson(tmsConfig, modules, isDev), {
|
|
3543
|
+
from: resolve$3(),
|
|
3544
|
+
to: resolve$3(tmsConfig.outputDir)
|
|
3545
|
+
}); // 监听其他文件
|
|
3546
|
+
|
|
3547
|
+
compileTasksMap.forEach(({
|
|
3548
|
+
taskFn,
|
|
3549
|
+
module
|
|
3550
|
+
}, globValue) => {
|
|
3551
|
+
watch(globValue, {
|
|
3552
|
+
ignoreInitial: true,
|
|
3416
3553
|
events: watchEvents
|
|
3417
|
-
},
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
compileTasksMap.forEach(({
|
|
3423
|
-
taskFn,
|
|
3424
|
-
module
|
|
3425
|
-
}, globValue) => {
|
|
3426
|
-
watch(globValue, {
|
|
3427
|
-
ignoreInitial: true,
|
|
3428
|
-
events: watchEvents
|
|
3429
|
-
}, taskFn, module);
|
|
3430
|
-
});
|
|
3431
|
-
} else {
|
|
3432
|
-
buildOutputAppJson(tmsConfig, newModules, isDev);
|
|
3433
|
-
}
|
|
3434
|
-
|
|
3435
|
-
eTime = new Date().getTime() - sTime;
|
|
3554
|
+
}, taskFn, module);
|
|
3555
|
+
});
|
|
3556
|
+
} else {
|
|
3557
|
+
buildOutputAppJson(tmsConfig, modules, isDev);
|
|
3558
|
+
}
|
|
3436
3559
|
|
|
3437
|
-
|
|
3438
|
-
var _tmsConfig$hooks2;
|
|
3560
|
+
eTime = new Date().getTime() - sTime;
|
|
3439
3561
|
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
tmsConfig: filterField(tmsConfig, ['gitAccount']),
|
|
3443
|
-
modules: newModules
|
|
3444
|
-
}));
|
|
3445
|
-
}
|
|
3562
|
+
if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.afterCompile) === 'function') {
|
|
3563
|
+
var _tmsConfig$hooks2;
|
|
3446
3564
|
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3565
|
+
await (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.afterCompile({
|
|
3566
|
+
isDev,
|
|
3567
|
+
tmsConfig: filterField$2(tmsConfig, ['gitAccount']),
|
|
3568
|
+
modules
|
|
3569
|
+
}));
|
|
3450
3570
|
}
|
|
3451
3571
|
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
compileTasks.push(taskFn);
|
|
3457
|
-
}); // 一次性完成编译任务(编译完成后再添加watch任务-封装到end函数里面)
|
|
3572
|
+
spinner.succeed(chalk$2.green(`首次编译完成, 耗时${eTime / 1000}s, 微信开发者工具打开项目即可预览。`));
|
|
3573
|
+
spinner.stop();
|
|
3574
|
+
cb();
|
|
3575
|
+
}
|
|
3458
3576
|
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3577
|
+
const compileTasks = [];
|
|
3578
|
+
compileTasksMap.forEach(({
|
|
3579
|
+
taskFn
|
|
3580
|
+
}) => {
|
|
3581
|
+
compileTasks.push(taskFn);
|
|
3582
|
+
}); // 一次性完成编译任务(编译完成后再添加watch任务-封装到end函数里面)
|
|
3583
|
+
|
|
3584
|
+
series(start, parallel(...compileTasks), end)();
|
|
3585
|
+
};
|
|
3462
3586
|
|
|
3463
3587
|
const shelljs$1 = require$$0__default$3;
|
|
3464
|
-
const compileDev = dev$3
|
|
3588
|
+
const compileDev = dev$3;
|
|
3465
3589
|
const {
|
|
3466
3590
|
resolve: resolve$2,
|
|
3467
3591
|
filterField: filterField$1
|
|
3468
3592
|
} = widgets;
|
|
3469
3593
|
const init$4 = init_1;
|
|
3470
3594
|
const {
|
|
3471
|
-
|
|
3472
|
-
|
|
3595
|
+
getModulesByMergeDepModules: getModulesByMergeDepModules$1,
|
|
3596
|
+
getSubPackages: getSubPackages$1
|
|
3597
|
+
} = tmsMpconfig.exports;
|
|
3473
3598
|
const {
|
|
3474
|
-
info: info$
|
|
3599
|
+
info: info$3
|
|
3475
3600
|
} = log$1;
|
|
3476
3601
|
const {
|
|
3477
3602
|
global: global$1
|
|
@@ -3480,11 +3605,14 @@ const {
|
|
|
3480
3605
|
CACHE_DIR
|
|
3481
3606
|
} = require$$4; // 用户编译分包时,需要将dist中其他分包(主包不能删除)的内容删除,否则其他分包的内容混入到主包(导致主包的体积超2M)
|
|
3482
3607
|
|
|
3483
|
-
function
|
|
3484
|
-
|
|
3485
|
-
const
|
|
3486
|
-
|
|
3487
|
-
|
|
3608
|
+
function delOtherPackages(tmsConfig, targetSubPackages) {
|
|
3609
|
+
// 获取所有模块,合并模块依赖的模块
|
|
3610
|
+
const allModules = getModulesByMergeDepModules$1(tmsConfig, tmsConfig.modules.all); // 获取所有的分包
|
|
3611
|
+
|
|
3612
|
+
const allSubPackages = getSubPackages$1(allModules);
|
|
3613
|
+
const targetSubPackagesName = targetSubPackages.map(item => item.name);
|
|
3614
|
+
allSubPackages.forEach(item => {
|
|
3615
|
+
if (item.root && targetSubPackagesName.indexOf(item.name) === -1) {
|
|
3488
3616
|
const moduleRootDir = resolve$2(`${tmsConfig.outputDir}/${item.root}`);
|
|
3489
3617
|
shelljs$1.rm('-rf', `${moduleRootDir}/*`, {
|
|
3490
3618
|
silent: true
|
|
@@ -3494,10 +3622,9 @@ function delOtherModule(tmsConfig, targetModules) {
|
|
|
3494
3622
|
});
|
|
3495
3623
|
}
|
|
3496
3624
|
|
|
3497
|
-
async function dev$2(tmsConfig, targetModules
|
|
3625
|
+
async function dev$2(tmsConfig, targetModules) {
|
|
3498
3626
|
var _tmsConfig$hooks;
|
|
3499
3627
|
|
|
3500
|
-
let newModules = targetModules;
|
|
3501
3628
|
const {
|
|
3502
3629
|
noCache
|
|
3503
3630
|
} = global$1.getData('cmd');
|
|
@@ -3508,9 +3635,11 @@ async function dev$2(tmsConfig, targetModules, env) {
|
|
|
3508
3635
|
} // 初始化操作
|
|
3509
3636
|
|
|
3510
3637
|
|
|
3511
|
-
const
|
|
3512
|
-
|
|
3513
|
-
|
|
3638
|
+
const {
|
|
3639
|
+
subPackages,
|
|
3640
|
+
modules: newModules
|
|
3641
|
+
} = await init$4(tmsConfig, targetModules);
|
|
3642
|
+
info$3('当前dev启动的有效模块', newModules.map(item => item.moduleName).sort());
|
|
3514
3643
|
|
|
3515
3644
|
if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforeCompile) === 'function') {
|
|
3516
3645
|
var _tmsConfig$hooks2;
|
|
@@ -3521,16 +3650,16 @@ async function dev$2(tmsConfig, targetModules, env) {
|
|
|
3521
3650
|
modules: newModules
|
|
3522
3651
|
}));
|
|
3523
3652
|
}
|
|
3524
|
-
|
|
3525
|
-
compileDev(tmsConfig, newModules,
|
|
3653
|
+
delOtherPackages(tmsConfig, subPackages);
|
|
3654
|
+
compileDev(tmsConfig, newModules, subPackages, true);
|
|
3526
3655
|
}
|
|
3527
3656
|
|
|
3528
3657
|
var dev_1 = dev$2;
|
|
3529
3658
|
|
|
3530
|
-
const dev$1 = dev$3
|
|
3659
|
+
const dev$1 = dev$3;
|
|
3531
3660
|
|
|
3532
|
-
var build$2 = async (tmsConfig, newModules) => {
|
|
3533
|
-
dev$1(tmsConfig, newModules,
|
|
3661
|
+
var build$2 = async (tmsConfig, newModules, subPackages, isDev) => {
|
|
3662
|
+
dev$1(tmsConfig, newModules, subPackages, isDev);
|
|
3534
3663
|
};
|
|
3535
3664
|
|
|
3536
3665
|
const shelljs = require$$0__default$3;
|
|
@@ -3541,25 +3670,27 @@ const {
|
|
|
3541
3670
|
const init$3 = init_1;
|
|
3542
3671
|
const compileBuild = build$2;
|
|
3543
3672
|
|
|
3544
|
-
async function build$1(tmsConfig, targetModules
|
|
3673
|
+
async function build$1(tmsConfig, targetModules) {
|
|
3545
3674
|
var _tmsConfig$hooks;
|
|
3546
3675
|
|
|
3547
3676
|
// 开始构建前,清理输出目录
|
|
3548
3677
|
await shelljs.rm('-rf', resolve$1(tmsConfig.outputDir));
|
|
3549
3678
|
const {
|
|
3550
|
-
|
|
3679
|
+
modules: newModules,
|
|
3680
|
+
subPackages
|
|
3551
3681
|
} = await init$3(tmsConfig, targetModules);
|
|
3682
|
+
const isDev = false;
|
|
3552
3683
|
|
|
3553
3684
|
if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforeCompile) === 'function') {
|
|
3554
3685
|
var _tmsConfig$hooks2;
|
|
3555
3686
|
|
|
3556
3687
|
await (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.beforeCompile({
|
|
3557
|
-
isDev
|
|
3688
|
+
isDev,
|
|
3558
3689
|
tmsConfig: filterField(tmsConfig, ['gitAccount']),
|
|
3559
3690
|
modules: newModules
|
|
3560
3691
|
}));
|
|
3561
3692
|
}
|
|
3562
|
-
compileBuild(tmsConfig, newModules,
|
|
3693
|
+
compileBuild(tmsConfig, newModules, subPackages, isDev);
|
|
3563
3694
|
}
|
|
3564
3695
|
|
|
3565
3696
|
var build_1 = build$1;
|
|
@@ -3636,6 +3767,10 @@ const dev = dev_1;
|
|
|
3636
3767
|
const build = build_1;
|
|
3637
3768
|
const install = install_1;
|
|
3638
3769
|
const cloud = cloud$1;
|
|
3770
|
+
const {
|
|
3771
|
+
fail,
|
|
3772
|
+
info: info$2
|
|
3773
|
+
} = log$1;
|
|
3639
3774
|
const {
|
|
3640
3775
|
global
|
|
3641
3776
|
} = global_1;
|
|
@@ -3643,9 +3778,9 @@ const {
|
|
|
3643
3778
|
readTmsConfig,
|
|
3644
3779
|
readTmsPrivateCf,
|
|
3645
3780
|
checkModules,
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
} = tmsMpconfig;
|
|
3781
|
+
getModulesByMergeDepModules,
|
|
3782
|
+
getSubPackages
|
|
3783
|
+
} = tmsMpconfig.exports;
|
|
3649
3784
|
|
|
3650
3785
|
const handleModuleArg = cmd => {
|
|
3651
3786
|
// 单模块或多模块开发-用户通过脚手架参数指定的模块
|
|
@@ -3680,15 +3815,22 @@ const getSpecificModules = (moduleArg, modules) => {
|
|
|
3680
3815
|
}
|
|
3681
3816
|
|
|
3682
3817
|
if ((exclude === null || exclude === void 0 ? void 0 : exclude.length) > 0) {
|
|
3683
|
-
return all.filter(module => !exclude.includes(module.
|
|
3818
|
+
return all.filter(module => !exclude.includes(module.moduleName)).map(item => item.moduleName);
|
|
3684
3819
|
}
|
|
3685
3820
|
|
|
3686
3821
|
if (blockRemote === true) {
|
|
3687
|
-
return all.filter(module => module.repoInfo === undefined).map(item => item.
|
|
3822
|
+
return all.filter(module => module.repoInfo === undefined).map(item => item.moduleName);
|
|
3688
3823
|
}
|
|
3689
3824
|
|
|
3690
|
-
return all.map(item => item.
|
|
3825
|
+
return all.map(item => item.moduleName);
|
|
3691
3826
|
};
|
|
3827
|
+
/**
|
|
3828
|
+
* 合并tms.config.js 与 tms.private.config.js的配置项
|
|
3829
|
+
* @param {*} tmsConfig
|
|
3830
|
+
* @param {*} tmsPrivateCf
|
|
3831
|
+
* @returns
|
|
3832
|
+
*/
|
|
3833
|
+
|
|
3692
3834
|
|
|
3693
3835
|
const mergeConfig = (tmsConfig, tmsPrivateCf) => {
|
|
3694
3836
|
const modules = {};
|
|
@@ -3708,62 +3850,69 @@ const mergeConfig = (tmsConfig, tmsPrivateCf) => {
|
|
|
3708
3850
|
};
|
|
3709
3851
|
|
|
3710
3852
|
async function run(commandName, cmd) {
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3853
|
+
try {
|
|
3854
|
+
// 用户本地的私有项目配置
|
|
3855
|
+
const tmsPrivateCf = readTmsPrivateCf();
|
|
3856
|
+
const {
|
|
3857
|
+
env = tmsPrivateCf === null || tmsPrivateCf === void 0 ? void 0 : tmsPrivateCf.env
|
|
3858
|
+
} = cmd;
|
|
3859
|
+
let tmsConfig = readTmsConfig(env);
|
|
3860
|
+
tmsConfig = mergeConfig(tmsConfig, tmsPrivateCf); // 处理module参数
|
|
3718
3861
|
|
|
3719
|
-
|
|
3720
|
-
|
|
3862
|
+
const specificModules = getSpecificModules(handleModuleArg(cmd), tmsConfig.modules);
|
|
3863
|
+
const modules = checkModules(tmsConfig, [...new Set([...tmsConfig.mainPackages, ...specificModules])], true); // 获取所有模块,合并模块依赖的模块
|
|
3721
3864
|
|
|
3722
|
-
|
|
3865
|
+
const newModules = getModulesByMergeDepModules(tmsConfig, modules); // 获取所有的分包
|
|
3723
3866
|
|
|
3724
|
-
|
|
3867
|
+
const subPackages = getSubPackages(newModules); // 缓存数据
|
|
3725
3868
|
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3869
|
+
global.setData({
|
|
3870
|
+
env,
|
|
3871
|
+
cmd,
|
|
3872
|
+
tmsConfig
|
|
3873
|
+
});
|
|
3731
3874
|
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3875
|
+
switch (commandName) {
|
|
3876
|
+
case 'init':
|
|
3877
|
+
init$2(tmsConfig, newModules);
|
|
3878
|
+
return;
|
|
3736
3879
|
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3880
|
+
case 'dev':
|
|
3881
|
+
global.setData('isDev', true);
|
|
3882
|
+
dev(tmsConfig, newModules);
|
|
3883
|
+
return;
|
|
3741
3884
|
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3885
|
+
case 'cloud':
|
|
3886
|
+
cloud(tmsConfig);
|
|
3887
|
+
return;
|
|
3745
3888
|
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3889
|
+
case 'install':
|
|
3890
|
+
install(tmsConfig, subPackages, false);
|
|
3891
|
+
return;
|
|
3749
3892
|
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3893
|
+
case 'build':
|
|
3894
|
+
global.setData('isDev', false);
|
|
3895
|
+
build(tmsConfig, newModules);
|
|
3896
|
+
return;
|
|
3754
3897
|
|
|
3755
|
-
|
|
3756
|
-
|
|
3898
|
+
default:
|
|
3899
|
+
return;
|
|
3900
|
+
}
|
|
3901
|
+
} catch (error) {
|
|
3902
|
+
const errMsg = typeof error === 'object' ? error.message : error;
|
|
3903
|
+
fail(`构建出现错误: ${errMsg}`);
|
|
3904
|
+
info$2('详细错误信息', error);
|
|
3905
|
+
process.exit(1);
|
|
3757
3906
|
}
|
|
3758
3907
|
}
|
|
3759
3908
|
|
|
3760
3909
|
var run_1 = run;
|
|
3761
3910
|
|
|
3762
3911
|
var entry = [{
|
|
3763
|
-
command: 'create <
|
|
3912
|
+
command: 'create <project-name>',
|
|
3764
3913
|
description: '创建新的应用',
|
|
3765
|
-
action:
|
|
3766
|
-
create_1(
|
|
3914
|
+
action: projectName => {
|
|
3915
|
+
create_1(projectName);
|
|
3767
3916
|
}
|
|
3768
3917
|
}, {
|
|
3769
3918
|
name: 'run',
|
|
@@ -3814,7 +3963,7 @@ var entry = [{
|
|
|
3814
3963
|
|
|
3815
3964
|
var require$$7 = {
|
|
3816
3965
|
name: "@tmsfe/tmskit",
|
|
3817
|
-
version: "0.0.
|
|
3966
|
+
version: "0.0.20",
|
|
3818
3967
|
description: "tmskit",
|
|
3819
3968
|
main: "dist/index.cjs",
|
|
3820
3969
|
bin: {
|
|
@@ -3855,21 +4004,16 @@ var require$$7 = {
|
|
|
3855
4004
|
dependencies: {
|
|
3856
4005
|
"ansi-colors": "1.1.0",
|
|
3857
4006
|
anymatch: "^1.3.0",
|
|
3858
|
-
"fancy-log": "1.3.2",
|
|
3859
|
-
"glob-parent": "^3.0.1",
|
|
3860
|
-
"path-is-absolute": "^1.0.1",
|
|
3861
|
-
"readable-stream": "^2.2.2",
|
|
3862
|
-
slash: "^1.0.0",
|
|
3863
|
-
vinyl: "^2.1.0",
|
|
3864
|
-
"vinyl-file": "^2.0.0",
|
|
3865
4007
|
async: "^3.2.2",
|
|
3866
4008
|
chalk: "^4.1.0",
|
|
3867
4009
|
chokidar: "^3.5.3",
|
|
3868
4010
|
commander: "^8.3.0",
|
|
3869
4011
|
"copy-webpack-plugin": "^9.1.0",
|
|
3870
4012
|
ejs: "^3.1.5",
|
|
4013
|
+
"fancy-log": "1.3.2",
|
|
3871
4014
|
"fs-extra": "^10.0.1",
|
|
3872
4015
|
"glob-ignore": "^1.0.2",
|
|
4016
|
+
"glob-parent": "^3.0.1",
|
|
3873
4017
|
gulp: "^4.0.2",
|
|
3874
4018
|
"gulp-watch": "^5.0.1",
|
|
3875
4019
|
htmlparser2: "^7.2.0",
|
|
@@ -3881,13 +4025,20 @@ var require$$7 = {
|
|
|
3881
4025
|
moment: "^2.29.2",
|
|
3882
4026
|
"object-assign": "^4.0.1",
|
|
3883
4027
|
ora: "^5.1.0",
|
|
4028
|
+
"path-is-absolute": "^1.0.1",
|
|
3884
4029
|
"plugin-error": "^1.0.0",
|
|
3885
4030
|
postcss: "^8.4.6",
|
|
3886
4031
|
precinct: "^8.3.1",
|
|
4032
|
+
"readable-stream": "^2.2.2",
|
|
3887
4033
|
"replace-ext": "^2.0.0",
|
|
4034
|
+
request: "^2.88.2",
|
|
3888
4035
|
shelljs: "^0.8.4",
|
|
4036
|
+
slash: "^1.0.0",
|
|
3889
4037
|
"strip-comments": "^2.0.1",
|
|
3890
4038
|
through2: "^4.0.2",
|
|
4039
|
+
unzipper: "^0.10.11",
|
|
4040
|
+
vinyl: "^2.1.0",
|
|
4041
|
+
"vinyl-file": "^2.0.0",
|
|
3891
4042
|
"vinyl-sourcemaps-apply": "^0.2.0"
|
|
3892
4043
|
},
|
|
3893
4044
|
engines: {
|