@tmsfe/tmskit 0.0.12 → 0.0.13
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 +23 -0
- package/dist/index.cjs.js +385 -253
- package/main.js +0 -0
- package/package.json +2 -4
- package/src/compile/compile.js +109 -49
- package/src/compile/dev.js +51 -15
- package/src/compile/watch.js +29 -0
- package/src/core/cloneModules.js +7 -3
- package/src/core/isInIt.js +2 -6
- package/src/core/npm.js +7 -6
- package/src/core/tmsMpconfig.js +13 -8
- package/src/index.js +1 -4
- package/src/scripts/run/index.js +11 -6
- package/src/utils/io.js +3 -2
- package/src/utils/log.js +5 -4
- package/src/utils/widgets.js +19 -2
package/dist/index.cjs.js
CHANGED
|
@@ -1,58 +1,56 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var require$$0 = require('chalk');
|
|
4
|
+
var require$$1 = require('moment');
|
|
4
5
|
var require$$0$1 = require('commander');
|
|
5
|
-
var require$$1 = require('leven');
|
|
6
|
+
var require$$1$1 = require('leven');
|
|
6
7
|
var require$$2 = require('ora');
|
|
7
|
-
var require$$
|
|
8
|
+
var require$$1$2 = require('path');
|
|
8
9
|
var require$$0$2 = require('fs');
|
|
9
10
|
var require$$0$3 = require('shelljs');
|
|
10
11
|
var require$$0$4 = require('async');
|
|
11
|
-
var require$$1$
|
|
12
|
-
var require$$1$
|
|
12
|
+
var require$$1$3 = require('ejs');
|
|
13
|
+
var require$$1$4 = require('inquirer');
|
|
13
14
|
var require$$0$5 = require('metalsmith');
|
|
14
15
|
var require$$0$6 = require('lodash');
|
|
15
|
-
var require$$1$
|
|
16
|
+
var require$$1$5 = require('crypto');
|
|
16
17
|
var require$$0$7 = require('miniprogram-ci');
|
|
17
18
|
var require$$5 = require('glob-ignore');
|
|
18
|
-
var require$$1$
|
|
19
|
-
var require$$9 = require('console');
|
|
19
|
+
var require$$1$6 = require('fs-extra');
|
|
20
20
|
var require$$0$8 = require('strip-comments');
|
|
21
21
|
var require$$0$9 = require('through2');
|
|
22
|
-
var require$$1$
|
|
23
|
-
var require$$1$
|
|
22
|
+
var require$$1$7 = require('precinct');
|
|
23
|
+
var require$$1$8 = require('htmlparser2');
|
|
24
24
|
var require$$0$a = require('gulp');
|
|
25
|
-
var require$$
|
|
26
|
-
var require$$
|
|
27
|
-
var require$$1$8 = require('semver');
|
|
25
|
+
var require$$0$b = require('gulp-watch');
|
|
26
|
+
var require$$1$9 = require('semver');
|
|
28
27
|
|
|
29
28
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
30
29
|
|
|
31
30
|
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
32
|
-
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
|
|
33
31
|
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
32
|
+
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
|
|
33
|
+
var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1);
|
|
34
34
|
var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
|
|
35
|
-
var require$$
|
|
35
|
+
var require$$1__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$1$2);
|
|
36
36
|
var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
|
|
37
37
|
var require$$0__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$0$3);
|
|
38
38
|
var require$$0__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$0$4);
|
|
39
|
-
var require$$1__default$
|
|
40
|
-
var require$$1__default$
|
|
39
|
+
var require$$1__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$1$3);
|
|
40
|
+
var require$$1__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$1$4);
|
|
41
41
|
var require$$0__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$0$5);
|
|
42
42
|
var require$$0__default$6 = /*#__PURE__*/_interopDefaultLegacy(require$$0$6);
|
|
43
|
-
var require$$1__default$
|
|
43
|
+
var require$$1__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$1$5);
|
|
44
44
|
var require$$0__default$7 = /*#__PURE__*/_interopDefaultLegacy(require$$0$7);
|
|
45
45
|
var require$$5__default = /*#__PURE__*/_interopDefaultLegacy(require$$5);
|
|
46
|
-
var require$$1__default$
|
|
47
|
-
var require$$9__default = /*#__PURE__*/_interopDefaultLegacy(require$$9);
|
|
46
|
+
var require$$1__default$6 = /*#__PURE__*/_interopDefaultLegacy(require$$1$6);
|
|
48
47
|
var require$$0__default$8 = /*#__PURE__*/_interopDefaultLegacy(require$$0$8);
|
|
49
48
|
var require$$0__default$9 = /*#__PURE__*/_interopDefaultLegacy(require$$0$9);
|
|
50
|
-
var require$$1__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$1$5);
|
|
51
|
-
var require$$1__default$6 = /*#__PURE__*/_interopDefaultLegacy(require$$1$6);
|
|
52
|
-
var require$$0__default$a = /*#__PURE__*/_interopDefaultLegacy(require$$0$a);
|
|
53
49
|
var require$$1__default$7 = /*#__PURE__*/_interopDefaultLegacy(require$$1$7);
|
|
54
|
-
var require$$2__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$2$1);
|
|
55
50
|
var require$$1__default$8 = /*#__PURE__*/_interopDefaultLegacy(require$$1$8);
|
|
51
|
+
var require$$0__default$a = /*#__PURE__*/_interopDefaultLegacy(require$$0$a);
|
|
52
|
+
var require$$0__default$b = /*#__PURE__*/_interopDefaultLegacy(require$$0$b);
|
|
53
|
+
var require$$1__default$9 = /*#__PURE__*/_interopDefaultLegacy(require$$1$9);
|
|
56
54
|
|
|
57
55
|
function getAugmentedNamespace(n) {
|
|
58
56
|
if (n.__esModule) return n;
|
|
@@ -72,6 +70,7 @@ function getAugmentedNamespace(n) {
|
|
|
72
70
|
var src$2 = {};
|
|
73
71
|
|
|
74
72
|
const chalk$3 = require$$0__default;
|
|
73
|
+
const moment = require$$1__default;
|
|
75
74
|
/**
|
|
76
75
|
* 本文件提供无依赖的在终端打印彩色文字的方法。
|
|
77
76
|
*/
|
|
@@ -89,7 +88,7 @@ const fail$9 = (message = '') => {
|
|
|
89
88
|
|
|
90
89
|
const greenFontStyleConfig = decodeURIComponent('%1B%5B41%3B37m'); // \033[41;30m转义后的字符按,console时输出红底白色文字
|
|
91
90
|
|
|
92
|
-
console.log(`${redStyleConfig} ERROR ${greenFontStyleConfig} ${message}${resetCfg}`); // eslint-disable-line no-console
|
|
91
|
+
console.log(`\n${moment().format('YYYY-MM-DD HH:mm:ss')}`, `${redStyleConfig} ERROR ${greenFontStyleConfig} ${message}${resetCfg}`); // eslint-disable-line no-console
|
|
93
92
|
};
|
|
94
93
|
/**
|
|
95
94
|
* 打印绿底黑字格式的文字
|
|
@@ -103,7 +102,7 @@ const succeed$1 = (message = '') => {
|
|
|
103
102
|
|
|
104
103
|
const greenFontStyleConfig = decodeURIComponent('%1B%5B40%3B32m'); // \033[40;32m转义后的字符按,console时输出绿色文字
|
|
105
104
|
|
|
106
|
-
console.log(`${greenStyleConfig} Success ${greenFontStyleConfig} ${message}${resetCfg}`); // eslint-disable-line no-console
|
|
105
|
+
console.log(`\n${moment().format('YYYY-MM-DD HH:mm:ss')}`, `${greenStyleConfig} Success ${greenFontStyleConfig} ${message}${resetCfg}`); // eslint-disable-line no-console
|
|
107
106
|
};
|
|
108
107
|
/**
|
|
109
108
|
* 打印warn提示
|
|
@@ -113,10 +112,10 @@ const succeed$1 = (message = '') => {
|
|
|
113
112
|
|
|
114
113
|
|
|
115
114
|
const warn = message => {
|
|
116
|
-
console.log(chalk$3.yellow(message));
|
|
115
|
+
console.log(`\n${moment().format('YYYY-MM-DD HH:mm:ss')}`, chalk$3.yellow(message));
|
|
117
116
|
};
|
|
118
117
|
|
|
119
|
-
const info$9 = (...args) => console.log(...args);
|
|
118
|
+
const info$9 = (...args) => console.log(`\n${moment().format('YYYY-MM-DD HH:mm:ss')}`, ...args);
|
|
120
119
|
|
|
121
120
|
var log$1 = {
|
|
122
121
|
fail: fail$9,
|
|
@@ -126,9 +125,9 @@ var log$1 = {
|
|
|
126
125
|
};
|
|
127
126
|
|
|
128
127
|
const program$1 = require$$0__default$1;
|
|
129
|
-
const leven = require$$1__default;
|
|
128
|
+
const leven = require$$1__default$1;
|
|
130
129
|
const ora = require$$2__default;
|
|
131
|
-
const path$
|
|
130
|
+
const path$b = require$$1__default$2;
|
|
132
131
|
const fs$e = require$$0__default$2;
|
|
133
132
|
const shelljs$6 = require$$0__default$3;
|
|
134
133
|
const {
|
|
@@ -142,8 +141,8 @@ const shelljsOptions = {
|
|
|
142
141
|
|
|
143
142
|
const cwd = process.cwd();
|
|
144
143
|
|
|
145
|
-
function resolve$
|
|
146
|
-
return path$
|
|
144
|
+
function resolve$g(...args) {
|
|
145
|
+
return path$b.resolve(cwd, ...args);
|
|
147
146
|
}
|
|
148
147
|
/**
|
|
149
148
|
* 用户输入命令时,进行提示
|
|
@@ -200,7 +199,7 @@ function downloadRepoForGit$2(url, dest, branch) {
|
|
|
200
199
|
return new Promise((resolve, reject) => {
|
|
201
200
|
// 如果目标目录不存在
|
|
202
201
|
if (fs$e.existsSync(dest)) {
|
|
203
|
-
shelljs$6.rm('-rf', path$
|
|
202
|
+
shelljs$6.rm('-rf', path$b.join(dest));
|
|
204
203
|
}
|
|
205
204
|
|
|
206
205
|
shelljs$6.mkdir('-p', dest);
|
|
@@ -251,7 +250,7 @@ function pullRepoForGit$1(dest, branch) {
|
|
|
251
250
|
|
|
252
251
|
function npmInstall$1(dir) {
|
|
253
252
|
return new Promise((resolve, reject) => {
|
|
254
|
-
shelljs$6.exec('
|
|
253
|
+
shelljs$6.exec('npm install --production --registry http://mirrors.tencent.com/npm/', {
|
|
255
254
|
cwd: dir,
|
|
256
255
|
silent: true
|
|
257
256
|
}, (code, stdout, stderr) => {
|
|
@@ -285,7 +284,6 @@ function createTask$3(task, startText, endText) {
|
|
|
285
284
|
const start = Date.now();
|
|
286
285
|
const spinner = ora(startText);
|
|
287
286
|
spinner.start();
|
|
288
|
-
info$8('\n');
|
|
289
287
|
const result = await task(...args);
|
|
290
288
|
endText && spinner.succeed(`${endText}, ${cost(start)}ms`);
|
|
291
289
|
spinner.stop();
|
|
@@ -300,8 +298,24 @@ function createTask$3(task, startText, endText) {
|
|
|
300
298
|
|
|
301
299
|
const camelize = str => str.replace(/-(\w)/g, (a, c) => c ? c.toUpperCase() : '');
|
|
302
300
|
|
|
301
|
+
const mergeMap = function (obj, src) {
|
|
302
|
+
for (const [k, v] of src) {
|
|
303
|
+
if (obj.has(k)) {
|
|
304
|
+
obj.set(k, obj.get(k) + v);
|
|
305
|
+
} else {
|
|
306
|
+
obj.set(k, v);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return obj;
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
const relativeCwdPath$1 = function (file) {
|
|
314
|
+
return path$b.relative(process.cwd(), file);
|
|
315
|
+
};
|
|
316
|
+
|
|
303
317
|
var widgets = {
|
|
304
|
-
resolve: resolve$
|
|
318
|
+
resolve: resolve$g,
|
|
305
319
|
isObject: isObject$2,
|
|
306
320
|
isArray: isArray$1,
|
|
307
321
|
createTask: createTask$3,
|
|
@@ -309,25 +323,27 @@ var widgets = {
|
|
|
309
323
|
pullRepoForGit: pullRepoForGit$1,
|
|
310
324
|
suggestCommands: suggestCommands$1,
|
|
311
325
|
camelize,
|
|
312
|
-
npmInstall: npmInstall$1
|
|
326
|
+
npmInstall: npmInstall$1,
|
|
327
|
+
mergeMap,
|
|
328
|
+
relativeCwdPath: relativeCwdPath$1
|
|
313
329
|
};
|
|
314
330
|
|
|
315
|
-
const path$
|
|
331
|
+
const path$a = require('path');
|
|
316
332
|
|
|
317
333
|
const os = require('os'); // 用户目录
|
|
318
334
|
|
|
319
335
|
|
|
320
336
|
const HOME_DIR = os.homedir(); // 所有文件的缓存目录
|
|
321
337
|
|
|
322
|
-
const CACHE_DIR$1 = path$
|
|
338
|
+
const CACHE_DIR$1 = path$a.resolve(HOME_DIR, '.tmskit'); // 脚手架模板代码所在目录
|
|
323
339
|
|
|
324
|
-
const TEMPLATE_DIR$1 = path$
|
|
340
|
+
const TEMPLATE_DIR$1 = path$a.resolve(CACHE_DIR$1, 'template'); // 第三方模块源码存放的临时缓存目录
|
|
325
341
|
|
|
326
|
-
const MODULE_CODE_DIR$2 = path$
|
|
342
|
+
const MODULE_CODE_DIR$2 = path$a.resolve(CACHE_DIR$1, 'modules_code'); // 脚手架模板代码的具体路径
|
|
327
343
|
|
|
328
|
-
const TEMPLATE_PATH$1 = path$
|
|
344
|
+
const TEMPLATE_PATH$1 = path$a.resolve(TEMPLATE_DIR$1, 'tools/tms-cli-template'); // 脚手架的名称
|
|
329
345
|
|
|
330
|
-
const TMS_NAME$
|
|
346
|
+
const TMS_NAME$1 = 'tmskit'; // 脚手架的配置名称
|
|
331
347
|
|
|
332
348
|
const TMS_CONFIG_FILENAME$1 = 'tms.config.js';
|
|
333
349
|
const TMS_PRIVATE_FILENAME$1 = 'tms.private.config.js'; // 模块代码的默认在modules子目录
|
|
@@ -336,10 +352,10 @@ const DEFAULT_MODULE_DIR = 'modules'; // 模块代码的默认在modules子目
|
|
|
336
352
|
|
|
337
353
|
const DEFAULT_CLOUD_MODULE_DIR$1 = './cloud'; // 模块的配置文件的名称
|
|
338
354
|
|
|
339
|
-
const MODULE_CONFIG_FILENAME$
|
|
355
|
+
const MODULE_CONFIG_FILENAME$2 = 'module.config.json'; // 默认的webpack entry
|
|
340
356
|
|
|
341
357
|
const DEFAULT_WEBPACK_ENTRY = {
|
|
342
|
-
app: path$
|
|
358
|
+
app: path$a.resolve(process.cwd(), 'app')
|
|
343
359
|
}; // 默认从源码拷贝到编译后的配置
|
|
344
360
|
|
|
345
361
|
const DEFAULT_COPY_CONFIG$1 = ['package.json', 'sitemap.json'];
|
|
@@ -356,11 +372,11 @@ var constant = /*#__PURE__*/Object.freeze({
|
|
|
356
372
|
CACHE_DIR: CACHE_DIR$1,
|
|
357
373
|
TEMPLATE_DIR: TEMPLATE_DIR$1,
|
|
358
374
|
TEMPLATE_PATH: TEMPLATE_PATH$1,
|
|
359
|
-
TMS_NAME: TMS_NAME$
|
|
375
|
+
TMS_NAME: TMS_NAME$1,
|
|
360
376
|
TMS_CONFIG_FILENAME: TMS_CONFIG_FILENAME$1,
|
|
361
377
|
TMS_PRIVATE_FILENAME: TMS_PRIVATE_FILENAME$1,
|
|
362
378
|
DEFAULT_MODULE_DIR: DEFAULT_MODULE_DIR,
|
|
363
|
-
MODULE_CONFIG_FILENAME: MODULE_CONFIG_FILENAME$
|
|
379
|
+
MODULE_CONFIG_FILENAME: MODULE_CONFIG_FILENAME$2,
|
|
364
380
|
DEFAULT_WEBPACK_ENTRY: DEFAULT_WEBPACK_ENTRY,
|
|
365
381
|
DEFAULT_COPY_CONFIG: DEFAULT_COPY_CONFIG$1,
|
|
366
382
|
MODULE_CODE_DIR: MODULE_CODE_DIR$2,
|
|
@@ -373,10 +389,13 @@ var constant = /*#__PURE__*/Object.freeze({
|
|
|
373
389
|
var require$$4 = /*@__PURE__*/getAugmentedNamespace(constant);
|
|
374
390
|
|
|
375
391
|
const fs$d = require$$0__default$2;
|
|
376
|
-
const path$
|
|
392
|
+
const path$9 = require$$1__default$2;
|
|
377
393
|
const {
|
|
378
394
|
info: info$7
|
|
379
395
|
} = log$1;
|
|
396
|
+
const {
|
|
397
|
+
relativeCwdPath
|
|
398
|
+
} = widgets;
|
|
380
399
|
/**
|
|
381
400
|
* 判断目录是否为空
|
|
382
401
|
* @param {string} dirname 目录名
|
|
@@ -414,7 +433,7 @@ const copyFile = function (src, dest) {
|
|
|
414
433
|
fs$d.unlinkSync(dest);
|
|
415
434
|
}
|
|
416
435
|
|
|
417
|
-
const dir = path$
|
|
436
|
+
const dir = path$9.dirname(dest);
|
|
418
437
|
ensureDirExist(dir);
|
|
419
438
|
fs$d.copyFileSync(src, dest);
|
|
420
439
|
}; // 判断文件内容是否一致,不一致再进行拷贝
|
|
@@ -426,11 +445,11 @@ function diffContentCopyFile$3(originFile, destFile) {
|
|
|
426
445
|
const depOriginContent = fs$d.readFileSync(originFile, 'utf8');
|
|
427
446
|
|
|
428
447
|
if (depDestContent !== depOriginContent) {
|
|
429
|
-
info$7(`拷贝${originFile}内容到${destFile}`);
|
|
448
|
+
info$7(`拷贝${relativeCwdPath(originFile)}内容到${relativeCwdPath(destFile)}`);
|
|
430
449
|
copyFile(originFile, destFile);
|
|
431
450
|
}
|
|
432
451
|
} else {
|
|
433
|
-
info$7(`拷贝${originFile}内容到${destFile}`);
|
|
452
|
+
info$7(`拷贝${relativeCwdPath(originFile)}内容到${relativeCwdPath(destFile)}`);
|
|
434
453
|
copyFile(originFile, destFile);
|
|
435
454
|
}
|
|
436
455
|
} // 添加后缀
|
|
@@ -474,7 +493,7 @@ const fileInDir$3 = (dir, file) => {
|
|
|
474
493
|
return false;
|
|
475
494
|
}
|
|
476
495
|
|
|
477
|
-
const relativePath = path$
|
|
496
|
+
const relativePath = path$9.relative(dir, file);
|
|
478
497
|
|
|
479
498
|
if (relativePath.startsWith('..')) {
|
|
480
499
|
return false;
|
|
@@ -494,7 +513,7 @@ var io$2 = {
|
|
|
494
513
|
};
|
|
495
514
|
|
|
496
515
|
const async = require$$0__default$4;
|
|
497
|
-
const ejs = require$$1__default$
|
|
516
|
+
const ejs = require$$1__default$3;
|
|
498
517
|
|
|
499
518
|
const render$1 = (files, metalsmith, next) => {
|
|
500
519
|
const keys = Object.keys(files);
|
|
@@ -514,9 +533,9 @@ const render$1 = (files, metalsmith, next) => {
|
|
|
514
533
|
var render_1 = render$1;
|
|
515
534
|
|
|
516
535
|
const fs$c = require$$0__default$2;
|
|
517
|
-
const inquirer = require$$1__default$
|
|
536
|
+
const inquirer = require$$1__default$4;
|
|
518
537
|
const {
|
|
519
|
-
resolve: resolve$
|
|
538
|
+
resolve: resolve$f
|
|
520
539
|
} = widgets;
|
|
521
540
|
const {
|
|
522
541
|
TEMPLATE_TKIT_DIR: TEMPLATE_TKIT_DIR$1
|
|
@@ -568,7 +587,7 @@ const isQuestionType = result => {
|
|
|
568
587
|
};
|
|
569
588
|
|
|
570
589
|
const ask$1 = templateDir => (files, metalsmith, next) => {
|
|
571
|
-
const prompts = parseTemplateQuestions(resolve$
|
|
590
|
+
const prompts = parseTemplateQuestions(resolve$f(templateDir, TEMPLATE_TKIT_DIR$1));
|
|
572
591
|
const metadata = metalsmith.metadata();
|
|
573
592
|
const filteredPrompts = prompts.filter(prompt => {
|
|
574
593
|
if (metadata[prompt.name] && `${metadata[prompt.name]}`.trim() !== '') {
|
|
@@ -610,7 +629,7 @@ const generator$1 = (buildDir, distDir, preMetadata) => new Promise((resolve, re
|
|
|
610
629
|
|
|
611
630
|
var generator_1 = generator$1;
|
|
612
631
|
|
|
613
|
-
const path$
|
|
632
|
+
const path$8 = require$$1__default$2;
|
|
614
633
|
const fs$b = require$$0__default$2;
|
|
615
634
|
const shelljs$5 = require$$0__default$3;
|
|
616
635
|
const {
|
|
@@ -621,7 +640,7 @@ const {
|
|
|
621
640
|
const {
|
|
622
641
|
downloadRepoForGit: downloadRepoForGit$1,
|
|
623
642
|
createTask: createTask$2,
|
|
624
|
-
resolve: resolve$
|
|
643
|
+
resolve: resolve$e
|
|
625
644
|
} = widgets;
|
|
626
645
|
const io$1 = io$2;
|
|
627
646
|
const {
|
|
@@ -656,7 +675,7 @@ async function createAppDir(targetDir) {
|
|
|
656
675
|
|
|
657
676
|
async function create(appName) {
|
|
658
677
|
const cwd = process.cwd();
|
|
659
|
-
const targetDir = path$
|
|
678
|
+
const targetDir = path$8.resolve(cwd, appName);
|
|
660
679
|
const appType = 'mp';
|
|
661
680
|
await createAppDir(targetDir); // 创建缓存目录
|
|
662
681
|
|
|
@@ -664,13 +683,13 @@ async function create(appName) {
|
|
|
664
683
|
|
|
665
684
|
await createTask$2(downloadRepoForGit$1, '拉取模板仓库', '拉取模板仓库完成')('https://git.woa.com/tmsfe/tms-frontend.git', TEMPLATE_DIR, 'master'); // 生成模板(1. 询问问题, 2. ejs生成模板 3.生成到目标目录)
|
|
666
685
|
|
|
667
|
-
generator(path$
|
|
686
|
+
generator(path$8.join(TEMPLATE_PATH, appType), targetDir, {
|
|
668
687
|
appName,
|
|
669
688
|
appType
|
|
670
689
|
}).then(() => {
|
|
671
690
|
shelljs$5.cd(appName);
|
|
672
691
|
|
|
673
|
-
const hooks = require(resolve$
|
|
692
|
+
const hooks = require(resolve$e(appName, TEMPLATE_TKIT_DIR, 'hooks.js'));
|
|
674
693
|
|
|
675
694
|
if (hooks.afterCreate) {
|
|
676
695
|
hooks.afterCreate.forEach(item => {
|
|
@@ -684,7 +703,7 @@ async function create(appName) {
|
|
|
684
703
|
});
|
|
685
704
|
}
|
|
686
705
|
|
|
687
|
-
shelljs$5.rm('-rf', resolve$
|
|
706
|
+
shelljs$5.rm('-rf', resolve$e(appName, TEMPLATE_TKIT_DIR));
|
|
688
707
|
succeed('项目创建完成.');
|
|
689
708
|
}).catch(err => {
|
|
690
709
|
fail$8(err.message);
|
|
@@ -719,13 +738,12 @@ var defaultTmsConfig$1 = {
|
|
|
719
738
|
const loadash = require$$0__default$6;
|
|
720
739
|
const fs$a = require$$0__default$2;
|
|
721
740
|
const {
|
|
722
|
-
TMS_NAME: TMS_NAME$1,
|
|
723
741
|
TMS_CONFIG_FILENAME,
|
|
724
|
-
MODULE_CONFIG_FILENAME: MODULE_CONFIG_FILENAME$
|
|
742
|
+
MODULE_CONFIG_FILENAME: MODULE_CONFIG_FILENAME$1,
|
|
725
743
|
TMS_PRIVATE_FILENAME
|
|
726
744
|
} = require$$4;
|
|
727
745
|
const {
|
|
728
|
-
resolve: resolve$
|
|
746
|
+
resolve: resolve$d,
|
|
729
747
|
isObject: isObject$1,
|
|
730
748
|
isArray
|
|
731
749
|
} = widgets;
|
|
@@ -733,14 +751,14 @@ const defaultTmsConfig = defaultTmsConfig$1;
|
|
|
733
751
|
const {
|
|
734
752
|
fail: fail$7
|
|
735
753
|
} = log$1;
|
|
736
|
-
const path$
|
|
754
|
+
const path$7 = require$$1__default$2;
|
|
737
755
|
/**
|
|
738
756
|
* 读取tms.config.js
|
|
739
757
|
* @param env {string} 环境变量
|
|
740
758
|
*/
|
|
741
759
|
|
|
742
760
|
const readTmsConfig$1 = function (env) {
|
|
743
|
-
const tmsConfigPath = resolve$
|
|
761
|
+
const tmsConfigPath = resolve$d(TMS_CONFIG_FILENAME);
|
|
744
762
|
|
|
745
763
|
if (!fs$a.existsSync(tmsConfigPath)) {
|
|
746
764
|
fail$7('当前执行目录没有tms.config.js的配置项,请进行配置');
|
|
@@ -768,14 +786,14 @@ const convertModules = modules => {
|
|
|
768
786
|
if (typeof module === 'string') {
|
|
769
787
|
// 路径字符串
|
|
770
788
|
Object.assign(newModule, {
|
|
771
|
-
name: path$
|
|
789
|
+
name: path$7.basename(module),
|
|
772
790
|
path: module
|
|
773
791
|
});
|
|
774
792
|
} else if (typeof module === 'object') {
|
|
775
793
|
Object.assign(newModule, module);
|
|
776
794
|
|
|
777
795
|
if (module.name === undefined) {
|
|
778
|
-
newModule.name = path$
|
|
796
|
+
newModule.name = path$7.basename(module.path);
|
|
779
797
|
}
|
|
780
798
|
}
|
|
781
799
|
|
|
@@ -790,7 +808,7 @@ const convertModules = modules => {
|
|
|
790
808
|
|
|
791
809
|
const readTmsPrivateCf$1 = function () {
|
|
792
810
|
let tmsPrivateCf = {};
|
|
793
|
-
const tmsPrivatePath = resolve$
|
|
811
|
+
const tmsPrivatePath = resolve$d(TMS_PRIVATE_FILENAME);
|
|
794
812
|
|
|
795
813
|
if (fs$a.existsSync(tmsPrivatePath)) {
|
|
796
814
|
tmsPrivateCf = require(tmsPrivatePath);
|
|
@@ -813,7 +831,7 @@ const readTmsPrivateCf$1 = function () {
|
|
|
813
831
|
*/
|
|
814
832
|
|
|
815
833
|
|
|
816
|
-
const checkModules$1 = function (tmsConfig, modules) {
|
|
834
|
+
const checkModules$1 = function (tmsConfig, modules, isQuit = false) {
|
|
817
835
|
const targetModules = [];
|
|
818
836
|
modules.forEach(moduleName => {
|
|
819
837
|
const module = tmsConfig.modules.find(module => module.name === moduleName);
|
|
@@ -821,8 +839,9 @@ const checkModules$1 = function (tmsConfig, modules) {
|
|
|
821
839
|
});
|
|
822
840
|
|
|
823
841
|
if (targetModules.length === 0) {
|
|
824
|
-
fail$7(
|
|
825
|
-
|
|
842
|
+
fail$7(`你启动的模块无效${modules.join(',')}无效,请检查tms.config.json>modules>${modules.join(',')}
|
|
843
|
+
>name字段与module.config.json的name字段是否一致`);
|
|
844
|
+
isQuit && process.exit(1);
|
|
826
845
|
}
|
|
827
846
|
|
|
828
847
|
return targetModules;
|
|
@@ -883,7 +902,7 @@ function getModuleConfig$1(modules = [], appName, moduleConfigFilename) {
|
|
|
883
902
|
modules.forEach(({
|
|
884
903
|
path
|
|
885
904
|
}) => {
|
|
886
|
-
const moduleConfigPath = resolve$
|
|
905
|
+
const moduleConfigPath = resolve$d(path, moduleConfigFilename);
|
|
887
906
|
|
|
888
907
|
if (fs$a.existsSync(moduleConfigPath)) {
|
|
889
908
|
const content = fs$a.readFileSync(moduleConfigPath, 'utf-8');
|
|
@@ -907,7 +926,7 @@ const tmsModulesMergeLocalModuleCfg$3 = (modules, appName) => {
|
|
|
907
926
|
path: relativePath,
|
|
908
927
|
name: moduleName
|
|
909
928
|
}, moduleIndex) => {
|
|
910
|
-
const moduleConfigPath = resolve$
|
|
929
|
+
const moduleConfigPath = resolve$d(relativePath, MODULE_CONFIG_FILENAME$1);
|
|
911
930
|
|
|
912
931
|
if (fs$a.existsSync(moduleConfigPath)) {
|
|
913
932
|
try {
|
|
@@ -927,7 +946,7 @@ const tmsModulesMergeLocalModuleCfg$3 = (modules, appName) => {
|
|
|
927
946
|
});
|
|
928
947
|
|
|
929
948
|
if (!findModule) {
|
|
930
|
-
fail$7(`启动模块${moduleName}在${moduleConfigPath}
|
|
949
|
+
fail$7(`启动模块${moduleName}在${moduleConfigPath}没有找到或pages为空,请检查配置`);
|
|
931
950
|
process.exit(1);
|
|
932
951
|
}
|
|
933
952
|
} catch (e) {
|
|
@@ -967,10 +986,13 @@ const subModulesMergeDepModules$2 = (tmsConfig, modules) => {
|
|
|
967
986
|
// 如果所有模块的dep都在moduleNames内,则所有依赖都齐了
|
|
968
987
|
// 否则递归处理,根据name找到相关配置加到modules里
|
|
969
988
|
if (moduleNames.indexOf(item) === -1) {
|
|
970
|
-
isOver = false;
|
|
971
989
|
const tmpModules = checkModules$1(tmsConfig, [...new Set([item])]);
|
|
972
|
-
|
|
973
|
-
|
|
990
|
+
|
|
991
|
+
if (tmpModules.length > 0) {
|
|
992
|
+
isOver = false;
|
|
993
|
+
mergeModules = [...mergeModules, ...tmpModules];
|
|
994
|
+
mergeModules = tmsModulesMergeLocalModuleCfg$3(mergeModules, tmsConfig.appName);
|
|
995
|
+
}
|
|
974
996
|
}
|
|
975
997
|
});
|
|
976
998
|
});
|
|
@@ -987,7 +1009,7 @@ var tmsMpconfig = {
|
|
|
987
1009
|
subModulesMergeDepModules: subModulesMergeDepModules$2
|
|
988
1010
|
};
|
|
989
1011
|
|
|
990
|
-
const global$
|
|
1012
|
+
const global$6 = {
|
|
991
1013
|
data: {},
|
|
992
1014
|
|
|
993
1015
|
setData(...args) {
|
|
@@ -1009,19 +1031,19 @@ const global$5 = {
|
|
|
1009
1031
|
|
|
1010
1032
|
};
|
|
1011
1033
|
var global_1 = {
|
|
1012
|
-
global: global$
|
|
1034
|
+
global: global$6
|
|
1013
1035
|
};
|
|
1014
1036
|
|
|
1015
1037
|
const {
|
|
1016
1038
|
fail: fail$6
|
|
1017
1039
|
} = log$1;
|
|
1018
1040
|
const {
|
|
1019
|
-
global: global$
|
|
1041
|
+
global: global$5
|
|
1020
1042
|
} = global_1;
|
|
1021
1043
|
|
|
1022
1044
|
function handleError$5(error) {
|
|
1023
1045
|
const errMsg = typeof error === 'object' ? error.message : error;
|
|
1024
|
-
const isDev = global$
|
|
1046
|
+
const isDev = global$5.getData('isDev');
|
|
1025
1047
|
|
|
1026
1048
|
if (isDev) {
|
|
1027
1049
|
fail$6(errMsg);
|
|
@@ -1040,7 +1062,7 @@ var handleError_1 = {
|
|
|
1040
1062
|
*/
|
|
1041
1063
|
const fs$9 = require$$0__default$2;
|
|
1042
1064
|
const {
|
|
1043
|
-
MODULE_CONFIG_FILENAME
|
|
1065
|
+
MODULE_CONFIG_FILENAME,
|
|
1044
1066
|
MODULE_CONFIG_INVALID_KEY
|
|
1045
1067
|
} = require$$4;
|
|
1046
1068
|
const {
|
|
@@ -1051,7 +1073,7 @@ const {
|
|
|
1051
1073
|
fail: fail$5
|
|
1052
1074
|
} = log$1;
|
|
1053
1075
|
const {
|
|
1054
|
-
resolve: resolve$
|
|
1076
|
+
resolve: resolve$c,
|
|
1055
1077
|
isObject
|
|
1056
1078
|
} = widgets;
|
|
1057
1079
|
const {
|
|
@@ -1210,16 +1232,16 @@ const fixAppJson = appJson => {
|
|
|
1210
1232
|
function buildOutputAppJson$1(tmsConfig, modules) {
|
|
1211
1233
|
try {
|
|
1212
1234
|
// 获取当前 modules 下的所有子模块的配置内容
|
|
1213
|
-
const modulesConfig = getModuleConfig(modules, tmsConfig.appName, MODULE_CONFIG_FILENAME
|
|
1235
|
+
const modulesConfig = getModuleConfig(modules, tmsConfig.appName, MODULE_CONFIG_FILENAME); // 获取app.json的配置
|
|
1214
1236
|
|
|
1215
|
-
const appJson = getAppJsonContent(resolve$
|
|
1237
|
+
const appJson = getAppJsonContent(resolve$c('./app.json')); // 更新app.json中的subpackages
|
|
1216
1238
|
|
|
1217
1239
|
updateSubpackages(appJson, modulesConfig); // 处理appJson中重复||冲突的地方
|
|
1218
1240
|
|
|
1219
1241
|
fixAppJson(appJson); // 更新主包,需在subpackages处理完成后执行, pages/
|
|
1220
1242
|
|
|
1221
1243
|
updateMainPackages(appJson, tmsConfig.mainPackages);
|
|
1222
|
-
fs$9.writeFileSync(resolve$
|
|
1244
|
+
fs$9.writeFileSync(resolve$c(`${tmsConfig.outputDir}/app.json`), JSON.stringify(appJson, null, 2), 'utf8');
|
|
1223
1245
|
return appJson;
|
|
1224
1246
|
} catch (e) {
|
|
1225
1247
|
handleError$4(`生成app.json出现错误: ${e}`);
|
|
@@ -1232,7 +1254,7 @@ var buildAppJson = {
|
|
|
1232
1254
|
|
|
1233
1255
|
const fs$8 = require$$0__default$2;
|
|
1234
1256
|
const {
|
|
1235
|
-
resolve: resolve$
|
|
1257
|
+
resolve: resolve$b
|
|
1236
1258
|
} = widgets;
|
|
1237
1259
|
const {
|
|
1238
1260
|
handleError: handleError$3
|
|
@@ -1249,10 +1271,10 @@ const symLink$1 = tmsConfig => {
|
|
|
1249
1271
|
try {
|
|
1250
1272
|
if (tmsConfig.cloudModules) {
|
|
1251
1273
|
tmsConfig.cloudModules.forEach(item => {
|
|
1252
|
-
const path = resolve$
|
|
1274
|
+
const path = resolve$b(DEFAULT_CLOUD_MODULE_DIR, item.name);
|
|
1253
1275
|
fs$8.access(path, fs$8.constants.F_OK, res => {
|
|
1254
1276
|
if (res) {
|
|
1255
|
-
fs$8.symlinkSync(resolve$
|
|
1277
|
+
fs$8.symlinkSync(resolve$b(item.path), path);
|
|
1256
1278
|
}
|
|
1257
1279
|
});
|
|
1258
1280
|
});
|
|
@@ -1270,11 +1292,11 @@ var symbolicLink = {
|
|
|
1270
1292
|
* 下载第三方代码
|
|
1271
1293
|
*/
|
|
1272
1294
|
const MetalSmith = require$$0__default$5;
|
|
1273
|
-
const crypto$1 = require$$1__default$
|
|
1295
|
+
const crypto$1 = require$$1__default$5;
|
|
1274
1296
|
const {
|
|
1275
1297
|
downloadRepoForGit,
|
|
1276
1298
|
pullRepoForGit,
|
|
1277
|
-
resolve: resolve$
|
|
1299
|
+
resolve: resolve$a
|
|
1278
1300
|
} = widgets;
|
|
1279
1301
|
const {
|
|
1280
1302
|
fail: fail$4,
|
|
@@ -1286,7 +1308,7 @@ const {
|
|
|
1286
1308
|
handleError: handleError$2
|
|
1287
1309
|
} = handleError_1;
|
|
1288
1310
|
const {
|
|
1289
|
-
global: global$
|
|
1311
|
+
global: global$4
|
|
1290
1312
|
} = global_1;
|
|
1291
1313
|
/**
|
|
1292
1314
|
* 处理用户没有clone git仓库权限问题,拼接tms.private.config.js的账号信息
|
|
@@ -1296,15 +1318,15 @@ const {
|
|
|
1296
1318
|
*/
|
|
1297
1319
|
|
|
1298
1320
|
function replaceGitUrlAccount(httpRepoUrl, moduleName) {
|
|
1299
|
-
var _tmsPrivateCf$gitAcco;
|
|
1321
|
+
var _tmsPrivateCf$gitAcco, _tmsPrivateCf$gitAcco2;
|
|
1300
1322
|
|
|
1301
1323
|
// 用户本地的私有项目配置(用来配置环境\模块信息\账号信息)
|
|
1302
|
-
const tmsPrivateCf = global$
|
|
1324
|
+
const tmsPrivateCf = global$4.getData('tmsPrivateCf');
|
|
1303
1325
|
let gitUrl = httpRepoUrl;
|
|
1304
1326
|
const {
|
|
1305
1327
|
username = '',
|
|
1306
1328
|
pass = ''
|
|
1307
|
-
} = (tmsPrivateCf === null || tmsPrivateCf === void 0 ? void 0 : (_tmsPrivateCf$gitAcco = tmsPrivateCf.gitAccout) === null || _tmsPrivateCf$gitAcco === void 0 ? void 0 : _tmsPrivateCf$gitAcco[moduleName]) || {};
|
|
1329
|
+
} = (tmsPrivateCf === null || tmsPrivateCf === void 0 ? void 0 : (_tmsPrivateCf$gitAcco = tmsPrivateCf.gitAccout) === null || _tmsPrivateCf$gitAcco === void 0 ? void 0 : _tmsPrivateCf$gitAcco[moduleName]) || (tmsPrivateCf === null || tmsPrivateCf === void 0 ? void 0 : (_tmsPrivateCf$gitAcco2 = tmsPrivateCf.gitAccount) === null || _tmsPrivateCf$gitAcco2 === void 0 ? void 0 : _tmsPrivateCf$gitAcco2[moduleName]) || {};
|
|
1308
1330
|
const urlPrefixReg = /http(s)?:\/\//;
|
|
1309
1331
|
|
|
1310
1332
|
if (username && pass && urlPrefixReg.test(gitUrl)) {
|
|
@@ -1359,7 +1381,8 @@ function md5ByGitUrlBranch(gitUrl, branch) {
|
|
|
1359
1381
|
|
|
1360
1382
|
|
|
1361
1383
|
async function cloneModules$1(sourceDir, targetDir, modules) {
|
|
1362
|
-
// 收集下载模块代码的任务
|
|
1384
|
+
const cwd = process.cwd(); // 收集下载模块代码的任务
|
|
1385
|
+
|
|
1363
1386
|
const downloadTasksMap = collectDownLoadTasksMap(sourceDir, targetDir, modules); // 开始执行下载和移动代码的任务
|
|
1364
1387
|
|
|
1365
1388
|
const arrPromises = [];
|
|
@@ -1379,6 +1402,7 @@ async function cloneModules$1(sourceDir, targetDir, modules) {
|
|
|
1379
1402
|
}));
|
|
1380
1403
|
});
|
|
1381
1404
|
await Promise.all(arrPromises);
|
|
1405
|
+
shelljs$4.cd(cwd);
|
|
1382
1406
|
}
|
|
1383
1407
|
/**
|
|
1384
1408
|
* 收集下载模块代码的任务
|
|
@@ -1419,9 +1443,9 @@ function collectDownLoadTasksMap(sourceDir, targetDir, modules) {
|
|
|
1419
1443
|
|
|
1420
1444
|
const md5Key = md5ByGitUrlBranch(gitUrl, branch); // git源码临时存在的源目录
|
|
1421
1445
|
|
|
1422
|
-
const sourcePath = resolve$
|
|
1446
|
+
const sourcePath = resolve$a(sourceDir, md5Key); // 模块源码要放到目标目录
|
|
1423
1447
|
|
|
1424
|
-
const targetPath = resolve$
|
|
1448
|
+
const targetPath = resolve$a(targetDir, path); // 从git源码仓库中找到模块源码路径 (一个仓库存在存放多个模块的情况)
|
|
1425
1449
|
|
|
1426
1450
|
const sourceModulePath = gitPath ? `${sourcePath}/${gitPath}` : sourcePath; // 下载完代码后,添加回调函数(主要将模块代码从临时目录移动代码到目标目录)
|
|
1427
1451
|
|
|
@@ -1448,12 +1472,12 @@ function collectDownLoadTasksMap(sourceDir, targetDir, modules) {
|
|
|
1448
1472
|
|
|
1449
1473
|
if (fs$7.existsSync(sourcePath) && fs$7.existsSync(`${sourcePath}/.git`)) {
|
|
1450
1474
|
promiseTask = (gitUrl, sourcePath, branch, httpRepoUrl) => {
|
|
1451
|
-
info$5(`git pull
|
|
1475
|
+
info$5(`git pull:${httpRepoUrl}`);
|
|
1452
1476
|
return pullRepoForGit(sourcePath, branch);
|
|
1453
1477
|
};
|
|
1454
1478
|
} else {
|
|
1455
1479
|
promiseTask = (gitUrl, sourcePath, branch, httpRepoUrl) => {
|
|
1456
|
-
info$5(`git clone
|
|
1480
|
+
info$5(`git clone: ${httpRepoUrl}`);
|
|
1457
1481
|
return downloadRepoForGit(gitUrl, sourcePath, branch);
|
|
1458
1482
|
};
|
|
1459
1483
|
}
|
|
@@ -1508,7 +1532,7 @@ var cloneModules_1 = {
|
|
|
1508
1532
|
};
|
|
1509
1533
|
|
|
1510
1534
|
const ci = require$$0__default$7;
|
|
1511
|
-
const path$
|
|
1535
|
+
const path$6 = require$$1__default$2;
|
|
1512
1536
|
/**
|
|
1513
1537
|
* 获取小程序ci的Project对象
|
|
1514
1538
|
* @returns {Object} 小程序ci对象
|
|
@@ -1522,7 +1546,7 @@ const getMpCi = ({
|
|
|
1522
1546
|
}) => {
|
|
1523
1547
|
var _cfgJsonContent$packO;
|
|
1524
1548
|
|
|
1525
|
-
const cfgJsonContent = require(path$
|
|
1549
|
+
const cfgJsonContent = require(path$6.join(projectPath, 'project.config.json'));
|
|
1526
1550
|
|
|
1527
1551
|
const ignores = (cfgJsonContent === null || cfgJsonContent === void 0 ? void 0 : (_cfgJsonContent$packO = cfgJsonContent.packOptions) === null || _cfgJsonContent$packO === void 0 ? void 0 : _cfgJsonContent$packO.ignore.map(({
|
|
1528
1552
|
value
|
|
@@ -1592,9 +1616,9 @@ var mpCi = {
|
|
|
1592
1616
|
* 本文件主要负责项目或者分包依赖的npm的安装
|
|
1593
1617
|
*/
|
|
1594
1618
|
const fs$6 = require$$0__default$2;
|
|
1595
|
-
const fsExtra = require$$1__default$
|
|
1596
|
-
const crypto = require$$1__default$
|
|
1597
|
-
const path$
|
|
1619
|
+
const fsExtra = require$$1__default$6;
|
|
1620
|
+
const crypto = require$$1__default$5;
|
|
1621
|
+
const path$5 = require$$1__default$2;
|
|
1598
1622
|
const shell = require$$0__default$3;
|
|
1599
1623
|
const glob = require$$5__default;
|
|
1600
1624
|
const log = log$1;
|
|
@@ -1604,9 +1628,6 @@ const {
|
|
|
1604
1628
|
const {
|
|
1605
1629
|
handleError: handleError$1
|
|
1606
1630
|
} = handleError_1;
|
|
1607
|
-
const {
|
|
1608
|
-
info: info$4
|
|
1609
|
-
} = require$$9__default;
|
|
1610
1631
|
const shellJsOption = {
|
|
1611
1632
|
async: false,
|
|
1612
1633
|
silent: true
|
|
@@ -1637,14 +1658,14 @@ const collectNpmTasksMap = (packageJsonFiles, cacheDir) => {
|
|
|
1637
1658
|
|
|
1638
1659
|
if (Object.keys(md5Obj.dependencies).length !== 0) {
|
|
1639
1660
|
const md5Key = crypto.createHash('md5').update(JSON.stringify(md5Obj)).digest('hex');
|
|
1640
|
-
const cacheNMPath = path$
|
|
1641
|
-
const cacheNMTarFile = path$
|
|
1661
|
+
const cacheNMPath = path$5.join(cacheDir, md5Key);
|
|
1662
|
+
const cacheNMTarFile = path$5.join(cacheNMPath, 'node_modules.tar.gz'); // 下载后,添加回调函数 (拷贝node_modules.tar.gz到编译目录并解压)
|
|
1642
1663
|
|
|
1643
1664
|
const callback = {
|
|
1644
1665
|
params: {
|
|
1645
1666
|
cacheNMPath,
|
|
1646
1667
|
cacheNMTarFile,
|
|
1647
|
-
packageJsonDir: path$
|
|
1668
|
+
packageJsonDir: path$5.dirname(packageJsonPath),
|
|
1648
1669
|
shell
|
|
1649
1670
|
},
|
|
1650
1671
|
fn: async (cacheNMPath, cacheNMTarFile, packageJsonDir, shell) => {
|
|
@@ -1653,8 +1674,8 @@ const collectNpmTasksMap = (packageJsonFiles, cacheDir) => {
|
|
|
1653
1674
|
const newShellJsOption = { ...shellJsOption,
|
|
1654
1675
|
cwd: packageJsonDir
|
|
1655
1676
|
};
|
|
1656
|
-
shell.exec('tar -
|
|
1657
|
-
shell.
|
|
1677
|
+
shell.exec('tar -xvf ./node_modules.tar.gz -C ./', newShellJsOption);
|
|
1678
|
+
shell.rm('-rf', './node_modules');
|
|
1658
1679
|
}
|
|
1659
1680
|
};
|
|
1660
1681
|
|
|
@@ -1671,13 +1692,13 @@ const collectNpmTasksMap = (packageJsonFiles, cacheDir) => {
|
|
|
1671
1692
|
promiseTask = (packageJsonPath, cacheNMPath, shell) => {
|
|
1672
1693
|
fsExtra.emptydirSync(cacheNMPath);
|
|
1673
1694
|
shell.cp('-f', packageJsonPath, cacheNMPath);
|
|
1674
|
-
info
|
|
1695
|
+
log.info(`npm install: ${packageJsonPath}`);
|
|
1675
1696
|
return npmInstall(cacheNMPath).then(() => {
|
|
1676
1697
|
const newShellJsOption = { ...shellJsOption,
|
|
1677
1698
|
cwd: cacheNMPath
|
|
1678
1699
|
};
|
|
1679
|
-
shell.exec('tar -
|
|
1680
|
-
shell.
|
|
1700
|
+
shell.exec('tar -cvf ./node_modules.tar.gz ./node_modules', newShellJsOption);
|
|
1701
|
+
shell.rm('-rf', './node_modules');
|
|
1681
1702
|
});
|
|
1682
1703
|
};
|
|
1683
1704
|
}
|
|
@@ -1700,6 +1721,7 @@ const collectNpmTasksMap = (packageJsonFiles, cacheDir) => {
|
|
|
1700
1721
|
|
|
1701
1722
|
|
|
1702
1723
|
const mpNpmInstallAll$1 = async (modules, contextDir, cacheDir) => {
|
|
1724
|
+
const cwd = process.cwd();
|
|
1703
1725
|
const packageJsonFiles = await findAllPackageJson(modules, contextDir); // 收集npm install的任务
|
|
1704
1726
|
|
|
1705
1727
|
const npmTasksMap = collectNpmTasksMap(packageJsonFiles, cacheDir); // 开始执行npm install和回调(移动)的任务
|
|
@@ -1721,6 +1743,7 @@ const mpNpmInstallAll$1 = async (modules, contextDir, cacheDir) => {
|
|
|
1721
1743
|
}));
|
|
1722
1744
|
});
|
|
1723
1745
|
await Promise.all(arrPromises);
|
|
1746
|
+
shell.cd(cwd);
|
|
1724
1747
|
};
|
|
1725
1748
|
/**
|
|
1726
1749
|
* 递归查找指定条件的文件
|
|
@@ -1756,7 +1779,7 @@ const findFilesByFilter = (startPath, filter) => {
|
|
|
1756
1779
|
|
|
1757
1780
|
const files = fs$6.readdirSync(startPath);
|
|
1758
1781
|
files.forEach(file => {
|
|
1759
|
-
const filename = path$
|
|
1782
|
+
const filename = path$5.join(startPath, file);
|
|
1760
1783
|
const stat = fs$6.lstatSync(filename); // 当前文件是文件夹类型,继续递归
|
|
1761
1784
|
|
|
1762
1785
|
if (stat.isDirectory()) {
|
|
@@ -1783,7 +1806,7 @@ const findAllPackageJson = (subRoots = [], contextDir) => {
|
|
|
1783
1806
|
const packageJsonName = 'package.json'; // 查找文件名
|
|
1784
1807
|
|
|
1785
1808
|
const cwd = contextDir || dirPath;
|
|
1786
|
-
const result = [path$
|
|
1809
|
+
const result = [path$5.join(cwd, packageJsonName)]; // 默认填充根目录下的package.json
|
|
1787
1810
|
|
|
1788
1811
|
subRoots.forEach(subRoot => {
|
|
1789
1812
|
if (!subRoot.root) {
|
|
@@ -1791,7 +1814,7 @@ const findAllPackageJson = (subRoots = [], contextDir) => {
|
|
|
1791
1814
|
process.exit(1);
|
|
1792
1815
|
}
|
|
1793
1816
|
|
|
1794
|
-
const toppath = path$
|
|
1817
|
+
const toppath = path$5.join(cwd, subRoot.root); // 从该目录开始查找package.json文件
|
|
1795
1818
|
|
|
1796
1819
|
const list = findFilesByFilter(toppath, packageJsonName);
|
|
1797
1820
|
result.push(...list);
|
|
@@ -1807,7 +1830,7 @@ function cloudNpmInstall$1(contextDir) {
|
|
|
1807
1830
|
}
|
|
1808
1831
|
|
|
1809
1832
|
files.forEach(file => {
|
|
1810
|
-
const dir = path$
|
|
1833
|
+
const dir = path$5.dirname(file);
|
|
1811
1834
|
shell.cd(dir);
|
|
1812
1835
|
shell.exec('npx npm install --production --registry http://mirrors.tencent.com/npm/', {
|
|
1813
1836
|
silent: false
|
|
@@ -1826,7 +1849,7 @@ var npm = {
|
|
|
1826
1849
|
|
|
1827
1850
|
const {
|
|
1828
1851
|
createTask: createTask$1,
|
|
1829
|
-
resolve: resolve$
|
|
1852
|
+
resolve: resolve$9
|
|
1830
1853
|
} = widgets;
|
|
1831
1854
|
const {
|
|
1832
1855
|
buildMpNpm
|
|
@@ -1839,21 +1862,21 @@ const {
|
|
|
1839
1862
|
mpNpmInstallAll
|
|
1840
1863
|
} = npm;
|
|
1841
1864
|
const {
|
|
1842
|
-
global: global$
|
|
1865
|
+
global: global$3
|
|
1843
1866
|
} = global_1;
|
|
1844
1867
|
|
|
1845
1868
|
async function install$2(tmsConfig, modules, isCloud = false) {
|
|
1846
1869
|
// 小程序npm install
|
|
1847
|
-
await createTask$1(mpNpmInstallAll, '小程序 开始npm install', '小程序npm install 完成')(modules, resolve$
|
|
1848
|
-
const tmsPrivateCf = global$
|
|
1870
|
+
await createTask$1(mpNpmInstallAll, '小程序 开始npm install', '小程序npm install 完成')(modules, resolve$9(tmsConfig.outputDir), `${CACHE_DIR}/node_modules`);
|
|
1871
|
+
const tmsPrivateCf = global$3.getData('tmsPrivateCf'); // 构建miniprogram_npm
|
|
1849
1872
|
|
|
1850
1873
|
await createTask$1(buildMpNpm, '开始构建miniprogram_npm', '构建miniprogram_npm 完成')({
|
|
1851
1874
|
appId: tmsConfig.appId,
|
|
1852
|
-
projectPath: resolve$
|
|
1875
|
+
projectPath: resolve$9('./'),
|
|
1853
1876
|
privateKey: tmsPrivateCf.privateKey
|
|
1854
1877
|
}); // 安装云函数的
|
|
1855
1878
|
|
|
1856
|
-
isCloud && createTask$1(cloudNpmInstall, '云函数npm install', '云函数npm install安装完毕')(resolve$
|
|
1879
|
+
isCloud && createTask$1(cloudNpmInstall, '云函数npm install', '云函数npm install安装完毕')(resolve$9(tmsConfig.cloudDir));
|
|
1857
1880
|
}
|
|
1858
1881
|
|
|
1859
1882
|
var install_1 = install$2;
|
|
@@ -1862,7 +1885,7 @@ const shelljs$3 = require$$0__default$3;
|
|
|
1862
1885
|
const fs$5 = require$$0__default$2;
|
|
1863
1886
|
const io = io$2;
|
|
1864
1887
|
const {
|
|
1865
|
-
resolve: resolve$
|
|
1888
|
+
resolve: resolve$8,
|
|
1866
1889
|
createTask
|
|
1867
1890
|
} = widgets;
|
|
1868
1891
|
const {
|
|
@@ -1884,7 +1907,7 @@ const {
|
|
|
1884
1907
|
} = tmsMpconfig;
|
|
1885
1908
|
const {
|
|
1886
1909
|
fail: fail$3,
|
|
1887
|
-
info: info$
|
|
1910
|
+
info: info$4
|
|
1888
1911
|
} = log$1;
|
|
1889
1912
|
const install$1 = install_1;
|
|
1890
1913
|
/**
|
|
@@ -1896,31 +1919,31 @@ const install$1 = install_1;
|
|
|
1896
1919
|
*/
|
|
1897
1920
|
|
|
1898
1921
|
const cpFilesToOutput = function (tmsConfig, targetModules, defaultFiles) {
|
|
1899
|
-
const outputDir = resolve$
|
|
1922
|
+
const outputDir = resolve$8(tmsConfig.outputDir);
|
|
1900
1923
|
io.ensureDirExist(outputDir);
|
|
1901
1924
|
defaultFiles.forEach(item => {
|
|
1902
|
-
if (fs$5.existsSync(resolve$
|
|
1903
|
-
shelljs$3.cp('-rf', resolve$
|
|
1925
|
+
if (fs$5.existsSync(resolve$8(item))) {
|
|
1926
|
+
shelljs$3.cp('-rf', resolve$8(item), resolve$8(tmsConfig.outputDir, item));
|
|
1904
1927
|
}
|
|
1905
1928
|
}); // 拷贝模块的package.json到编译输出目录
|
|
1906
1929
|
|
|
1907
1930
|
targetModules.forEach(item => {
|
|
1908
|
-
const outputModuleDir = resolve$
|
|
1931
|
+
const outputModuleDir = resolve$8(`${tmsConfig.outputDir}/${item.root}`);
|
|
1909
1932
|
|
|
1910
|
-
if (!fs$5.existsSync(resolve$
|
|
1933
|
+
if (!fs$5.existsSync(resolve$8(item.path))) {
|
|
1911
1934
|
fail$3(`${item.path}模块代码路径不存在, 请检查tms.config.js的${item.name}模块的path`);
|
|
1912
1935
|
process.exit(1);
|
|
1913
1936
|
}
|
|
1914
1937
|
|
|
1915
1938
|
io.ensureDirExist(outputModuleDir);
|
|
1916
|
-
const modulePackagePath = resolve$
|
|
1939
|
+
const modulePackagePath = resolve$8(item.path, 'package.json');
|
|
1917
1940
|
if (fs$5.existsSync(modulePackagePath)) shelljs$3.cp('-Rf', modulePackagePath, outputModuleDir);
|
|
1918
1941
|
});
|
|
1919
1942
|
};
|
|
1920
1943
|
|
|
1921
1944
|
async function task(tmsConfig, targetModules) {
|
|
1922
1945
|
// 下载和移动代码
|
|
1923
|
-
await createTask(cloneModules, '开始下载模块代码', '下载模块代码码完成')(MODULE_CODE_DIR$1, resolve$
|
|
1946
|
+
await createTask(cloneModules, '开始下载模块代码', '下载模块代码码完成')(MODULE_CODE_DIR$1, resolve$8('./'), targetModules); // tms.config.js的modules 合并 module.config.json的配置项
|
|
1924
1947
|
|
|
1925
1948
|
let newModules = tmsModulesMergeLocalModuleCfg$2(targetModules, tmsConfig.appName); // A分包依赖了B分包的代码, merge B分包进行编译;
|
|
1926
1949
|
|
|
@@ -1944,7 +1967,7 @@ async function init$5(tmsConfig, targetModules) {
|
|
|
1944
1967
|
} catch (error) {
|
|
1945
1968
|
const errMsg = typeof error === 'object' ? error.message : error;
|
|
1946
1969
|
fail$3(`init流程出现错误${errMsg}`);
|
|
1947
|
-
info$
|
|
1970
|
+
info$4('详细的错误信息', error);
|
|
1948
1971
|
process.exit(1);
|
|
1949
1972
|
}
|
|
1950
1973
|
}
|
|
@@ -2009,8 +2032,8 @@ var pluginError_1 = {
|
|
|
2009
2032
|
|
|
2010
2033
|
/* eslint-disable no-param-reassign */
|
|
2011
2034
|
const through$2 = require$$0__default$9;
|
|
2012
|
-
const precinct = require$$1__default$
|
|
2013
|
-
const path$
|
|
2035
|
+
const precinct = require$$1__default$7;
|
|
2036
|
+
const path$4 = require$$1__default$2;
|
|
2014
2037
|
const {
|
|
2015
2038
|
findCssImports
|
|
2016
2039
|
} = findCssImport;
|
|
@@ -2020,7 +2043,7 @@ const {
|
|
|
2020
2043
|
diffContentCopyFile: diffContentCopyFile$2
|
|
2021
2044
|
} = io$2;
|
|
2022
2045
|
const {
|
|
2023
|
-
resolve: resolve$
|
|
2046
|
+
resolve: resolve$7
|
|
2024
2047
|
} = widgets;
|
|
2025
2048
|
const fs$4 = require$$0__default$2;
|
|
2026
2049
|
const {
|
|
@@ -2040,11 +2063,11 @@ const dfsFindCommonDep$2 = function (anaFileOriginFile, anaFileDestFile, extensi
|
|
|
2040
2063
|
pluginError$2(e, isWatch);
|
|
2041
2064
|
}
|
|
2042
2065
|
|
|
2043
|
-
const deps = cssFilter.indexOf(path$
|
|
2066
|
+
const deps = cssFilter.indexOf(path$4.extname(anaFileOriginFile)) > -1 ? findCssImports(contents) : precinct(contents);
|
|
2044
2067
|
deps.forEach(depItem => {
|
|
2045
2068
|
if (depItem.startsWith('.')) {
|
|
2046
2069
|
// 被依赖文件的存在的绝对路径
|
|
2047
|
-
const depOriginPath = path$
|
|
2070
|
+
const depOriginPath = path$4.join(path$4.dirname(anaFileOriginFile), depItem); // 被依赖文件加上后缀
|
|
2048
2071
|
|
|
2049
2072
|
const {
|
|
2050
2073
|
ext: extAlias,
|
|
@@ -2057,7 +2080,7 @@ const dfsFindCommonDep$2 = function (anaFileOriginFile, anaFileDestFile, extensi
|
|
|
2057
2080
|
return;
|
|
2058
2081
|
}
|
|
2059
2082
|
|
|
2060
|
-
const depDestPath = resolve$
|
|
2083
|
+
const depDestPath = resolve$7(path$4.dirname(anaFileDestFile), depItem);
|
|
2061
2084
|
const depDestFile = depDestPath.endsWith(extAlias) ? depDestPath : depDestPath + extPath;
|
|
2062
2085
|
|
|
2063
2086
|
if (!resDep.has(depDestFile)) {
|
|
@@ -2081,19 +2104,19 @@ function mpCommonDep$1(tmsConfig, module, extensions = [], isWatch = true) {
|
|
|
2081
2104
|
const stream = through$2.obj(function (file, enc, cb) {
|
|
2082
2105
|
// 依赖分析的文件
|
|
2083
2106
|
const anaFileOriginFile = file.history[0];
|
|
2084
|
-
const anaFileRelativeModule = path$
|
|
2085
|
-
const anaFileDestFile = resolve$
|
|
2107
|
+
const anaFileRelativeModule = path$4.relative(resolve$7(module.from), anaFileOriginFile);
|
|
2108
|
+
const anaFileDestFile = resolve$7(tmsConfig.outputDir, module.to, anaFileRelativeModule);
|
|
2086
2109
|
|
|
2087
2110
|
if (file.isBuffer()) {
|
|
2088
2111
|
let contents = String(file.contents);
|
|
2089
|
-
const deps = cssFilter.indexOf(path$
|
|
2112
|
+
const deps = cssFilter.indexOf(path$4.extname(file.path)) > -1 ? findCssImports(contents) : precinct(contents);
|
|
2090
2113
|
const copyModules = new Map();
|
|
2091
2114
|
Object.keys(tmsConfig.dependencies).forEach(includeName => {
|
|
2092
2115
|
const includePath = tmsConfig.dependencies[includeName];
|
|
2093
2116
|
deps.forEach(depItem => {
|
|
2094
2117
|
if (depItem.indexOf(includeName) > -1) {
|
|
2095
2118
|
// 被依赖文件的存在的绝对路径 (eg: /User/thirdparty/loadsh)
|
|
2096
|
-
const depOriginPath = path$
|
|
2119
|
+
const depOriginPath = path$4.join(path$4.dirname(anaFileOriginFile), depItem); // 被依赖文件加上后缀
|
|
2097
2120
|
|
|
2098
2121
|
const {
|
|
2099
2122
|
ext: extAlias,
|
|
@@ -2111,7 +2134,7 @@ function mpCommonDep$1(tmsConfig, module, extensions = [], isWatch = true) {
|
|
|
2111
2134
|
const regRes = depItem.match(reg) || [];
|
|
2112
2135
|
|
|
2113
2136
|
if (regRes[2]) {
|
|
2114
|
-
const depDestPath = resolve$
|
|
2137
|
+
const depDestPath = resolve$7(tmsConfig.outputDir, module.to, includeName, regRes[2]);
|
|
2115
2138
|
const depDestFile = depDestPath.endsWith(extAlias) ? depDestPath : depDestPath + extPath;
|
|
2116
2139
|
|
|
2117
2140
|
if (!copyModules.has(depDestFile)) {
|
|
@@ -2119,7 +2142,7 @@ function mpCommonDep$1(tmsConfig, module, extensions = [], isWatch = true) {
|
|
|
2119
2142
|
depOriginFile,
|
|
2120
2143
|
depDestFile,
|
|
2121
2144
|
beforeDepPath: depItem,
|
|
2122
|
-
afterDepPath: path$
|
|
2145
|
+
afterDepPath: path$4.relative(path$4.dirname(anaFileDestFile), depDestPath).replace(/\\/g, '/')
|
|
2123
2146
|
});
|
|
2124
2147
|
}
|
|
2125
2148
|
}
|
|
@@ -2157,14 +2180,14 @@ var mpCommonDep_1 = {
|
|
|
2157
2180
|
|
|
2158
2181
|
/* eslint-disable no-param-reassign */
|
|
2159
2182
|
const through$1 = require$$0__default$9;
|
|
2160
|
-
const path$
|
|
2183
|
+
const path$3 = require$$1__default$2;
|
|
2161
2184
|
const {
|
|
2162
2185
|
ext: ext$1,
|
|
2163
2186
|
fileInDir: fileInDir$1,
|
|
2164
2187
|
diffContentCopyFile: diffContentCopyFile$1
|
|
2165
2188
|
} = io$2;
|
|
2166
2189
|
const {
|
|
2167
|
-
resolve: resolve$
|
|
2190
|
+
resolve: resolve$6
|
|
2168
2191
|
} = widgets;
|
|
2169
2192
|
const fs$3 = require$$0__default$2;
|
|
2170
2193
|
const {
|
|
@@ -2178,8 +2201,8 @@ function mpJsonDep$1(tmsConfig, module, extensions = ['.json'], filesExt = ['.wx
|
|
|
2178
2201
|
const stream = through$1.obj(function (file, enc, cb) {
|
|
2179
2202
|
// 当前分析的文件的路径
|
|
2180
2203
|
const anaFileOriginFile = file.history[0];
|
|
2181
|
-
const anaFileRelativeModule = path$
|
|
2182
|
-
const anaFileDestFile = resolve$
|
|
2204
|
+
const anaFileRelativeModule = path$3.relative(resolve$6(module.from), anaFileOriginFile);
|
|
2205
|
+
const anaFileDestFile = resolve$6(tmsConfig.outputDir, module.to, anaFileRelativeModule);
|
|
2183
2206
|
|
|
2184
2207
|
if (file.isBuffer()) {
|
|
2185
2208
|
let contents = String(file.contents);
|
|
@@ -2199,7 +2222,7 @@ function mpJsonDep$1(tmsConfig, module, extensions = ['.json'], filesExt = ['.wx
|
|
|
2199
2222
|
const componentPath = contents.usingComponents[componentKey];
|
|
2200
2223
|
|
|
2201
2224
|
if (componentPath.indexOf(includeName) > -1) {
|
|
2202
|
-
const depOriginPath = path$
|
|
2225
|
+
const depOriginPath = path$3.join(path$3.dirname(anaFileOriginFile), componentPath); // 被依赖文件加上后缀
|
|
2203
2226
|
|
|
2204
2227
|
const {
|
|
2205
2228
|
ext: extAlias,
|
|
@@ -2218,7 +2241,7 @@ function mpJsonDep$1(tmsConfig, module, extensions = ['.json'], filesExt = ['.wx
|
|
|
2218
2241
|
const regRes = componentPath.match(reg) || [];
|
|
2219
2242
|
|
|
2220
2243
|
if (regRes[2]) {
|
|
2221
|
-
const depDestPath = resolve$
|
|
2244
|
+
const depDestPath = resolve$6(tmsConfig.outputDir, module.to, includeName, regRes[2]);
|
|
2222
2245
|
const depDestFile = depDestPath.endsWith(extAlias) ? depDestPath : depDestPath + extPath;
|
|
2223
2246
|
|
|
2224
2247
|
if (!copyModules.has(depDestFile)) {
|
|
@@ -2227,7 +2250,7 @@ function mpJsonDep$1(tmsConfig, module, extensions = ['.json'], filesExt = ['.wx
|
|
|
2227
2250
|
depOriginExt: extAlias,
|
|
2228
2251
|
depDestFile,
|
|
2229
2252
|
beforeDepPath: componentPath,
|
|
2230
|
-
afterDepPath: path$
|
|
2253
|
+
afterDepPath: path$3.relative(path$3.dirname(anaFileDestFile), depDestPath).replace(/\\/g, '/')
|
|
2231
2254
|
});
|
|
2232
2255
|
}
|
|
2233
2256
|
}
|
|
@@ -2285,16 +2308,16 @@ var mpJsonDep_1 = {
|
|
|
2285
2308
|
|
|
2286
2309
|
/* eslint-disable no-param-reassign */
|
|
2287
2310
|
const through = require$$0__default$9;
|
|
2288
|
-
const htmlparser2 = require$$1__default$
|
|
2311
|
+
const htmlparser2 = require$$1__default$8;
|
|
2289
2312
|
const fs$2 = require$$0__default$2;
|
|
2290
|
-
const path$
|
|
2313
|
+
const path$2 = require$$1__default$2;
|
|
2291
2314
|
const {
|
|
2292
2315
|
diffContentCopyFile,
|
|
2293
2316
|
ext,
|
|
2294
2317
|
fileInDir
|
|
2295
2318
|
} = io$2;
|
|
2296
2319
|
const {
|
|
2297
|
-
resolve: resolve$
|
|
2320
|
+
resolve: resolve$5
|
|
2298
2321
|
} = widgets;
|
|
2299
2322
|
const {
|
|
2300
2323
|
dfsFindCommonDep
|
|
@@ -2343,7 +2366,7 @@ const dfsFindWxmlDep = function (anaFileOriginFile, anaFileDestFile, isWatch = t
|
|
|
2343
2366
|
var _attributes$src;
|
|
2344
2367
|
|
|
2345
2368
|
if (attributes !== null && attributes !== void 0 && (_attributes$src = attributes.src) !== null && _attributes$src !== void 0 && _attributes$src.startsWith('.')) {
|
|
2346
|
-
const depOriginPath = path$
|
|
2369
|
+
const depOriginPath = path$2.join(path$2.dirname(anaFileOriginFile), attributes.src); // 被依赖文件加上后缀
|
|
2347
2370
|
|
|
2348
2371
|
const {
|
|
2349
2372
|
ext,
|
|
@@ -2356,7 +2379,7 @@ const dfsFindWxmlDep = function (anaFileOriginFile, anaFileDestFile, isWatch = t
|
|
|
2356
2379
|
return;
|
|
2357
2380
|
}
|
|
2358
2381
|
|
|
2359
|
-
const depDestPath = path$
|
|
2382
|
+
const depDestPath = path$2.join(path$2.dirname(anaFileDestFile), attributes.src);
|
|
2360
2383
|
const depDestFile = depDestPath.endsWith(ext) ? depDestPath : depDestPath + extPath; // 收集wxml依赖
|
|
2361
2384
|
|
|
2362
2385
|
if (['import', 'include'].indexOf(name) > -1) {
|
|
@@ -2408,8 +2431,8 @@ function mpWxmlDep$1(tmsConfig, module, isWatch) {
|
|
|
2408
2431
|
const stream = through.obj(function (file, enc, cb) {
|
|
2409
2432
|
// 依赖分析的文件
|
|
2410
2433
|
const anaFileOriginFile = file.history[0];
|
|
2411
|
-
const anaFileRelativeModule = path$
|
|
2412
|
-
const anaFileDestFile = resolve$
|
|
2434
|
+
const anaFileRelativeModule = path$2.relative(resolve$5(module.from), anaFileOriginFile);
|
|
2435
|
+
const anaFileDestFile = resolve$5(tmsConfig.outputDir, module.to, anaFileRelativeModule);
|
|
2413
2436
|
|
|
2414
2437
|
if (file.isBuffer()) {
|
|
2415
2438
|
let contents = String(file.contents);
|
|
@@ -2419,7 +2442,7 @@ function mpWxmlDep$1(tmsConfig, module, isWatch) {
|
|
|
2419
2442
|
const nameFilter = ['import', 'include', 'wxs'];
|
|
2420
2443
|
|
|
2421
2444
|
if (nameFilter.indexOf(name) > -1 && attributes.src) {
|
|
2422
|
-
const depOriginPath = path$
|
|
2445
|
+
const depOriginPath = path$2.join(path$2.dirname(anaFileOriginFile), attributes.src); // 处理后缀(源码引入依赖时,后缀不全的情况)
|
|
2423
2446
|
|
|
2424
2447
|
const {
|
|
2425
2448
|
ext,
|
|
@@ -2440,7 +2463,7 @@ function mpWxmlDep$1(tmsConfig, module, isWatch) {
|
|
|
2440
2463
|
const regRes = attributes.src.match(reg) || [];
|
|
2441
2464
|
|
|
2442
2465
|
if (regRes[2]) {
|
|
2443
|
-
const depDestPath = resolve$
|
|
2466
|
+
const depDestPath = resolve$5(tmsConfig.outputDir, module.to, includeName, regRes[2]);
|
|
2444
2467
|
const depDestFile = depDestPath.endsWith(ext) ? depDestPath : depDestPath + extPath;
|
|
2445
2468
|
|
|
2446
2469
|
if (!copyModules.has(depDestFile)) {
|
|
@@ -2448,7 +2471,7 @@ function mpWxmlDep$1(tmsConfig, module, isWatch) {
|
|
|
2448
2471
|
depOriginFile,
|
|
2449
2472
|
depDestFile,
|
|
2450
2473
|
beforeDepPath: attributes.src,
|
|
2451
|
-
afterDepPath: path$
|
|
2474
|
+
afterDepPath: path$2.relative(path$2.dirname(anaFileDestFile), depDestFile).replace(/\\/g, '/')
|
|
2452
2475
|
});
|
|
2453
2476
|
}
|
|
2454
2477
|
}
|
|
@@ -2505,11 +2528,9 @@ var mpWxmlDep_1 = {
|
|
|
2505
2528
|
|
|
2506
2529
|
const {
|
|
2507
2530
|
src: src$1,
|
|
2508
|
-
dest
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
const px2rpx = require$$1__default$7;
|
|
2512
|
-
const watch = require$$2__default$1; // const cache = require('gulp-cache');
|
|
2531
|
+
dest
|
|
2532
|
+
} = require$$0__default$a; // const px2rpx = require('gulp-px-to-rpx');
|
|
2533
|
+
// const cache = require('gulp-cache');
|
|
2513
2534
|
// const image = require('gulp-image');
|
|
2514
2535
|
// const replaceEnv = require('./plugins/replaceEnv');
|
|
2515
2536
|
|
|
@@ -2526,87 +2547,168 @@ const {
|
|
|
2526
2547
|
|
|
2527
2548
|
const {
|
|
2528
2549
|
fail: fail$1
|
|
2529
|
-
} = log$1;
|
|
2530
|
-
|
|
2531
|
-
const since = task => file => lastRun(task) > file.stat.ctime ? lastRun(task) : 0;
|
|
2550
|
+
} = log$1; // const since = task => file => (lastRun(task) > file.stat.ctime ? lastRun(task) : 0);
|
|
2532
2551
|
|
|
2533
2552
|
var compile = function (tmsConfig, {
|
|
2534
2553
|
glob,
|
|
2535
2554
|
destPath,
|
|
2536
2555
|
srcOption,
|
|
2537
2556
|
module,
|
|
2538
|
-
watchOption = {
|
|
2539
|
-
events: ['change', 'add', 'unlink']
|
|
2540
|
-
},
|
|
2541
2557
|
isWatch
|
|
2542
2558
|
}) {
|
|
2559
|
+
const compileTasksMap = new Map();
|
|
2543
2560
|
Object.keys(glob).forEach(globKey => {
|
|
2544
2561
|
const globValue = glob[globKey];
|
|
2545
2562
|
|
|
2546
|
-
const task = () => src$1(globValue, { ...srcOption,
|
|
2547
|
-
since: since(task)
|
|
2548
|
-
});
|
|
2549
|
-
|
|
2550
|
-
let srcPipe = task();
|
|
2551
|
-
|
|
2552
|
-
if (isWatch) {
|
|
2553
|
-
srcPipe = srcPipe.pipe(watch(globValue, watchOption));
|
|
2554
|
-
}
|
|
2555
|
-
|
|
2556
2563
|
switch (globKey) {
|
|
2557
2564
|
case 'js':
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2565
|
+
compileTasksMap.set(globValue, {
|
|
2566
|
+
module,
|
|
2567
|
+
taskFn: () => {
|
|
2568
|
+
// const srcTask = () => src(globValue, { ...srcOption, since: since(srcTask) });
|
|
2569
|
+
// const srcPipe = srcTask();
|
|
2570
|
+
const srcPipe = src$1(globValue, { ...srcOption
|
|
2571
|
+
});
|
|
2572
|
+
return srcPipe // .pipe(replaceEnv(/process\.env(\.(\w*))?/g, tmsConfig.envData))
|
|
2573
|
+
.pipe(mpCommonDep(tmsConfig, module, ['.js', '.ts', '.wxs', '.json'], isWatch)).pipe(dest(destPath)).on('error', err => {
|
|
2574
|
+
fail$1(`js编译报错${err}`);
|
|
2575
|
+
});
|
|
2576
|
+
}
|
|
2561
2577
|
});
|
|
2562
2578
|
break;
|
|
2563
2579
|
|
|
2564
2580
|
case 'wxss':
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2581
|
+
compileTasksMap.set(globValue, {
|
|
2582
|
+
module,
|
|
2583
|
+
taskFn: () => {
|
|
2584
|
+
// const srcTask = () => src(globValue, { ...srcOption, since: since(srcTask) });
|
|
2585
|
+
// const srcPipe = srcTask();
|
|
2586
|
+
const srcPipe = src$1(globValue, { ...srcOption
|
|
2587
|
+
});
|
|
2588
|
+
return srcPipe.pipe(mpCommonDep(tmsConfig, module, ['.wxss', '.less'], isWatch)).on('error', err => {
|
|
2589
|
+
fail$1(`mpCommonDep编译报错${err}`);
|
|
2590
|
+
}) // .pipe(postcss([base64()]))
|
|
2591
|
+
// .on('error', (err) => {
|
|
2592
|
+
// fail(`postcss编译报错${err}`);
|
|
2593
|
+
// })
|
|
2594
|
+
// .pipe(px2rpx({
|
|
2595
|
+
// designWidth: 375, // 设计稿宽度,默认为750
|
|
2596
|
+
// precision: 2, // 小数最大精度,默认为6
|
|
2597
|
+
// }))
|
|
2598
|
+
.pipe(dest(destPath));
|
|
2599
|
+
}
|
|
2600
|
+
});
|
|
2577
2601
|
break;
|
|
2578
2602
|
|
|
2579
2603
|
case 'json':
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2604
|
+
compileTasksMap.set(globValue, {
|
|
2605
|
+
module,
|
|
2606
|
+
taskFn: () => {
|
|
2607
|
+
// const srcTask = () => src(globValue, { ...srcOption, since: since(srcTask) });
|
|
2608
|
+
// const srcPipe = srcTask();
|
|
2609
|
+
const srcPipe = src$1(globValue, { ...srcOption
|
|
2610
|
+
});
|
|
2611
|
+
return srcPipe.pipe(mpJsonDep(tmsConfig, module, ['.json'], ['.wxml', '.json', '.js', '.ts', '.wxss', '.less'], isWatch)).on('error', err => {
|
|
2612
|
+
fail$1(`mpJsonDep编译报错${err}`);
|
|
2613
|
+
}).pipe(dest(destPath));
|
|
2614
|
+
}
|
|
2615
|
+
});
|
|
2583
2616
|
break;
|
|
2584
2617
|
|
|
2585
2618
|
case 'wxml':
|
|
2586
|
-
|
|
2619
|
+
compileTasksMap.set(globValue, {
|
|
2620
|
+
module,
|
|
2621
|
+
taskFn: () => {
|
|
2622
|
+
// const srcTask = () => src(globValue, { ...srcOption, since: since(srcTask) });
|
|
2623
|
+
// const srcPipe = srcTask();
|
|
2624
|
+
const srcPipe = src$1(globValue, { ...srcOption
|
|
2625
|
+
});
|
|
2626
|
+
return srcPipe.pipe(mpWxmlDep(tmsConfig, module, isWatch)).pipe(dest(destPath));
|
|
2627
|
+
}
|
|
2628
|
+
});
|
|
2587
2629
|
break;
|
|
2588
2630
|
|
|
2589
2631
|
case 'image':
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2632
|
+
compileTasksMap.set(globValue, {
|
|
2633
|
+
module,
|
|
2634
|
+
taskFn: () => {
|
|
2635
|
+
// const srcTask = () => src(globValue, { ...srcOption, since: since(srcTask) });
|
|
2636
|
+
// const srcPipe = srcTask();
|
|
2637
|
+
const srcPipe = src$1(globValue, { ...srcOption
|
|
2638
|
+
});
|
|
2639
|
+
return srcPipe // .pipe(cache(image()))
|
|
2640
|
+
// .on('error', (err) => {
|
|
2641
|
+
// fail(`image编译报错${err}`);
|
|
2642
|
+
// })
|
|
2643
|
+
.pipe(dest(destPath));
|
|
2644
|
+
}
|
|
2645
|
+
});
|
|
2595
2646
|
break;
|
|
2596
2647
|
|
|
2597
2648
|
case 'other':
|
|
2598
|
-
|
|
2649
|
+
compileTasksMap.set(globValue, {
|
|
2650
|
+
module,
|
|
2651
|
+
taskFn: () => {
|
|
2652
|
+
// const srcTask = () => src(globValue, { ...srcOption, since: since(srcTask) });
|
|
2653
|
+
// const srcPipe = srcTask();
|
|
2654
|
+
const srcPipe = src$1(globValue, { ...srcOption
|
|
2655
|
+
});
|
|
2656
|
+
return srcPipe.pipe(dest(destPath));
|
|
2657
|
+
}
|
|
2658
|
+
});
|
|
2599
2659
|
break;
|
|
2600
2660
|
}
|
|
2601
2661
|
});
|
|
2662
|
+
return compileTasksMap;
|
|
2663
|
+
};
|
|
2664
|
+
|
|
2665
|
+
const watch = require$$0__default$b;
|
|
2666
|
+
const path$1 = require$$1__default$2;
|
|
2667
|
+
const shellJs = require$$0__default$3;
|
|
2668
|
+
const {
|
|
2669
|
+
info: info$3
|
|
2670
|
+
} = log$1;
|
|
2671
|
+
const {
|
|
2672
|
+
resolve: resolve$4
|
|
2673
|
+
} = widgets;
|
|
2674
|
+
const {
|
|
2675
|
+
global: global$2
|
|
2676
|
+
} = global_1;
|
|
2677
|
+
|
|
2678
|
+
var watch_1 = function (glob, watchOptions, callback, module) {
|
|
2679
|
+
watch(glob, {
|
|
2680
|
+
readDelay: 100,
|
|
2681
|
+
...watchOptions
|
|
2682
|
+
}, vinyl => {
|
|
2683
|
+
const file = vinyl.history[0];
|
|
2684
|
+
const fileDirArr = file.replace(/\\/g, '/').split('/');
|
|
2685
|
+
const fileName = fileDirArr.slice(fileDirArr.length - 2).join('/');
|
|
2686
|
+
|
|
2687
|
+
if (vinyl.event === 'unlink' || vinyl.event === 'unlinkDir') {
|
|
2688
|
+
const tmsConfig = global$2.getData('tmsConfig');
|
|
2689
|
+
const anaFileRelativeModule = path$1.relative(resolve$4(module.from), file);
|
|
2690
|
+
const anaFileDestFile = resolve$4(tmsConfig.outputDir, module.to, anaFileRelativeModule);
|
|
2691
|
+
info$3(`删除${fileName}`);
|
|
2692
|
+
shellJs.rm('-rf', anaFileDestFile);
|
|
2693
|
+
return;
|
|
2694
|
+
}
|
|
2695
|
+
|
|
2696
|
+
info$3(`更新${fileName}`);
|
|
2697
|
+
return callback(vinyl);
|
|
2698
|
+
});
|
|
2602
2699
|
};
|
|
2603
2700
|
|
|
2604
2701
|
(function (module) {
|
|
2605
|
-
const path = require$$
|
|
2702
|
+
const path = require$$1__default$2;
|
|
2606
2703
|
const fs = require$$0__default$2;
|
|
2607
|
-
const
|
|
2704
|
+
const ora = require$$2__default;
|
|
2608
2705
|
const {
|
|
2609
|
-
|
|
2706
|
+
parallel,
|
|
2707
|
+
series
|
|
2708
|
+
} = require$$0__default$a;
|
|
2709
|
+
const {
|
|
2710
|
+
resolve,
|
|
2711
|
+
mergeMap
|
|
2610
2712
|
} = widgets;
|
|
2611
2713
|
const {
|
|
2612
2714
|
buildOutputAppJson
|
|
@@ -2615,6 +2717,11 @@ var compile = function (tmsConfig, {
|
|
|
2615
2717
|
DEFAULT_COPY_CONFIG
|
|
2616
2718
|
} = require$$4;
|
|
2617
2719
|
const compile$1 = compile;
|
|
2720
|
+
const watch = watch_1;
|
|
2721
|
+
const {
|
|
2722
|
+
info
|
|
2723
|
+
} = log$1;
|
|
2724
|
+
const watchEvents = ['add', 'change', 'unlink', 'unlinkDir'];
|
|
2618
2725
|
|
|
2619
2726
|
function excludeGlob(glob) {
|
|
2620
2727
|
const otherArr = new Set();
|
|
@@ -2645,20 +2752,19 @@ var compile = function (tmsConfig, {
|
|
|
2645
2752
|
}
|
|
2646
2753
|
|
|
2647
2754
|
module.exports = async (tmsConfig, newModules, isWatch = true) => {
|
|
2648
|
-
// 监听app.json
|
|
2755
|
+
const compileTasksMap = new Map(); // 监听app.json
|
|
2756
|
+
|
|
2649
2757
|
if (isWatch) {
|
|
2650
|
-
watch(resolve('app.json'), {
|
|
2758
|
+
watch([resolve('app.json')], {
|
|
2651
2759
|
ignoreInitial: false,
|
|
2652
|
-
events:
|
|
2653
|
-
}, () =>
|
|
2654
|
-
buildOutputAppJson(tmsConfig, newModules, isWatch);
|
|
2655
|
-
});
|
|
2760
|
+
events: watchEvents
|
|
2761
|
+
}, () => buildOutputAppJson(tmsConfig, newModules, isWatch));
|
|
2656
2762
|
} else {
|
|
2657
2763
|
buildOutputAppJson(tmsConfig, newModules, isWatch);
|
|
2658
2764
|
} // 监听根目录的文件
|
|
2659
2765
|
|
|
2660
2766
|
|
|
2661
|
-
compile$1(tmsConfig, {
|
|
2767
|
+
mergeMap(compileTasksMap, compile$1(tmsConfig, {
|
|
2662
2768
|
glob: {
|
|
2663
2769
|
json: DEFAULT_COPY_CONFIG.map(item => resolve(item)) // wxss: ['app.less', 'app.wxss'].map(item => resolve(item)),
|
|
2664
2770
|
// js: ['app.js', 'app.ts'].map(item => resolve(item)),
|
|
@@ -2673,7 +2779,7 @@ var compile = function (tmsConfig, {
|
|
|
2673
2779
|
allowEmpty: true
|
|
2674
2780
|
},
|
|
2675
2781
|
isWatch
|
|
2676
|
-
}); // 监听模块的文件
|
|
2782
|
+
})); // 监听模块的文件
|
|
2677
2783
|
|
|
2678
2784
|
for (let module of newModules) {
|
|
2679
2785
|
// 处理默认参数
|
|
@@ -2685,23 +2791,21 @@ var compile = function (tmsConfig, {
|
|
|
2685
2791
|
|
|
2686
2792
|
if (isWatch) {
|
|
2687
2793
|
// 监听模块配置文件
|
|
2688
|
-
watch(`${resolve(module.path)}/**/module.config.json
|
|
2689
|
-
events:
|
|
2690
|
-
}, () =>
|
|
2691
|
-
buildOutputAppJson(tmsConfig, newModules, isWatch);
|
|
2692
|
-
});
|
|
2794
|
+
watch([`${resolve(module.path)}/**/module.config.json`], {
|
|
2795
|
+
events: watchEvents
|
|
2796
|
+
}, () => buildOutputAppJson(tmsConfig, newModules, isWatch));
|
|
2693
2797
|
}
|
|
2694
2798
|
|
|
2695
2799
|
const excludes = module.exclude.map(key => `!${resolve(key)}`);
|
|
2696
2800
|
const modulePath = adaptPath(module.path);
|
|
2697
2801
|
const glob = {
|
|
2698
2802
|
js: [`${modulePath}/**/*.{js,ts,wxs}`, ...excludes],
|
|
2699
|
-
json: [`${modulePath}/**/*.json`, ...excludes],
|
|
2803
|
+
json: [`${modulePath}/**/*.json`, `!${modulePath}/**/module.config.json`, ...excludes],
|
|
2700
2804
|
wxss: [`${modulePath}/**/*.{less,wxss}`, ...excludes],
|
|
2701
2805
|
wxml: [`${modulePath}/**/*.wxml`, ...excludes],
|
|
2702
2806
|
image: [`${modulePath}/**/*.{png,jpg,jpeg,gif,svg}`, ...excludes]
|
|
2703
2807
|
};
|
|
2704
|
-
compile$1(tmsConfig, {
|
|
2808
|
+
mergeMap(compileTasksMap, compile$1(tmsConfig, {
|
|
2705
2809
|
glob: { ...glob,
|
|
2706
2810
|
other: [`${modulePath}/**/*`, ...excludeGlob(glob)]
|
|
2707
2811
|
},
|
|
@@ -2714,7 +2818,7 @@ var compile = function (tmsConfig, {
|
|
|
2714
2818
|
allowEmpty: true
|
|
2715
2819
|
},
|
|
2716
2820
|
isWatch
|
|
2717
|
-
});
|
|
2821
|
+
}));
|
|
2718
2822
|
} // 静态资源目录-拷贝
|
|
2719
2823
|
|
|
2720
2824
|
|
|
@@ -2739,7 +2843,7 @@ var compile = function (tmsConfig, {
|
|
|
2739
2843
|
}
|
|
2740
2844
|
|
|
2741
2845
|
const from = fs.lstatSync(item.from).isFile() ? path.dirname(item.from) : item.from;
|
|
2742
|
-
compile$1(tmsConfig, {
|
|
2846
|
+
mergeMap(compileTasksMap, compile$1(tmsConfig, {
|
|
2743
2847
|
glob,
|
|
2744
2848
|
destPath: item.to,
|
|
2745
2849
|
module: {
|
|
@@ -2750,18 +2854,56 @@ var compile = function (tmsConfig, {
|
|
|
2750
2854
|
allowEmpty: true
|
|
2751
2855
|
},
|
|
2752
2856
|
isWatch
|
|
2857
|
+
}));
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2860
|
+
|
|
2861
|
+
let sTime;
|
|
2862
|
+
let eTime;
|
|
2863
|
+
const spinner = ora();
|
|
2864
|
+
|
|
2865
|
+
function end(cb) {
|
|
2866
|
+
if (isWatch) {
|
|
2867
|
+
compileTasksMap.forEach(({
|
|
2868
|
+
taskFn,
|
|
2869
|
+
module
|
|
2870
|
+
}, globValue) => {
|
|
2871
|
+
watch(globValue, {
|
|
2872
|
+
ignoreInitial: true,
|
|
2873
|
+
events: watchEvents
|
|
2874
|
+
}, taskFn, module);
|
|
2753
2875
|
});
|
|
2754
2876
|
}
|
|
2877
|
+
|
|
2878
|
+
eTime = new Date().getTime() - sTime;
|
|
2879
|
+
spinner.succeed(`首次编译完成, 耗时${eTime / 1000}s, 微信开发者工具打开项目即刻预览。`);
|
|
2880
|
+
spinner.stop();
|
|
2881
|
+
cb();
|
|
2755
2882
|
}
|
|
2883
|
+
|
|
2884
|
+
function start(cb) {
|
|
2885
|
+
info('启动编译...');
|
|
2886
|
+
spinner.start();
|
|
2887
|
+
sTime = new Date().getTime();
|
|
2888
|
+
cb();
|
|
2889
|
+
}
|
|
2890
|
+
|
|
2891
|
+
const compileTasks = [];
|
|
2892
|
+
compileTasksMap.forEach(({
|
|
2893
|
+
taskFn
|
|
2894
|
+
}) => {
|
|
2895
|
+
compileTasks.push(taskFn);
|
|
2896
|
+
});
|
|
2897
|
+
series(start, parallel(...compileTasks), end)();
|
|
2756
2898
|
};
|
|
2757
2899
|
})(dev$3);
|
|
2758
2900
|
|
|
2759
2901
|
const fs$1 = require$$0__default$2;
|
|
2760
|
-
const semver$1 = require$$1__default$
|
|
2902
|
+
const semver$1 = require$$1__default$9;
|
|
2761
2903
|
const {
|
|
2762
2904
|
resolve: resolve$3
|
|
2763
2905
|
} = widgets;
|
|
2764
|
-
const path = require$$
|
|
2906
|
+
const path = require$$1__default$2;
|
|
2765
2907
|
const shelljs$2 = require$$0__default$3;
|
|
2766
2908
|
const {
|
|
2767
2909
|
handleError
|
|
@@ -2853,7 +2995,6 @@ const {
|
|
|
2853
2995
|
resolve: resolve$2
|
|
2854
2996
|
} = widgets;
|
|
2855
2997
|
const {
|
|
2856
|
-
MODULE_CONFIG_FILENAME,
|
|
2857
2998
|
MODULE_CODE_DIR
|
|
2858
2999
|
} = require$$4;
|
|
2859
3000
|
const {
|
|
@@ -2866,17 +3007,12 @@ const {
|
|
|
2866
3007
|
fail
|
|
2867
3008
|
} = log$1;
|
|
2868
3009
|
|
|
2869
|
-
function checkModule(targetModules
|
|
3010
|
+
function checkModule(targetModules) {
|
|
2870
3011
|
// 判断\源码\dist\是否存在用户指定的模块
|
|
2871
3012
|
for (const item of targetModules) {
|
|
2872
3013
|
// 此模块没有root字段(原因:没有merge到module.config.json的配置项。第三方模块的代码可能还没有下载)
|
|
2873
3014
|
if (!item.root) {
|
|
2874
3015
|
return true;
|
|
2875
|
-
} // 判断dist目录是否有该模块
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
if (!fs.existsSync(`${contextDir}/${item.root}/${MODULE_CONFIG_FILENAME}`)) {
|
|
2879
|
-
return true;
|
|
2880
3016
|
} // 判断第三方远程模块git地址与branch是否有更新
|
|
2881
3017
|
|
|
2882
3018
|
|
|
@@ -2916,7 +3052,7 @@ function isInit$1(tmsConfig, targetModules, contextDir) {
|
|
|
2916
3052
|
} // 判断模块信息
|
|
2917
3053
|
|
|
2918
3054
|
|
|
2919
|
-
if (checkModule(targetModules
|
|
3055
|
+
if (checkModule(targetModules)) {
|
|
2920
3056
|
return true;
|
|
2921
3057
|
} // 判断package.json的版本是否有新的版本
|
|
2922
3058
|
|
|
@@ -3071,7 +3207,7 @@ async function run(commandName, cmd) {
|
|
|
3071
3207
|
const tmsConfig = readTmsConfig(env); // 处理module参数
|
|
3072
3208
|
|
|
3073
3209
|
const specificModules = getSpecificModules(handleModuleArg(cmd), tmsPrivateCf.modules, tmsConfig.modules);
|
|
3074
|
-
const modules = checkModules(tmsConfig, [...new Set([...tmsConfig.mainPackages, ...specificModules])]); // tms.config.js的modules 合并 module.config.json的配置项
|
|
3210
|
+
const modules = checkModules(tmsConfig, [...new Set([...tmsConfig.mainPackages, ...specificModules])], true); // tms.config.js的modules 合并 module.config.json的配置项
|
|
3075
3211
|
|
|
3076
3212
|
let newModules = tmsModulesMergeLocalModuleCfg(modules, tmsConfig.appName); // A分包依赖了B分包的代码, merge B分包进行编译;
|
|
3077
3213
|
|
|
@@ -3080,7 +3216,8 @@ async function run(commandName, cmd) {
|
|
|
3080
3216
|
global.setData({
|
|
3081
3217
|
env,
|
|
3082
3218
|
cmd,
|
|
3083
|
-
tmsPrivateCf
|
|
3219
|
+
tmsPrivateCf,
|
|
3220
|
+
tmsConfig
|
|
3084
3221
|
});
|
|
3085
3222
|
|
|
3086
3223
|
switch (commandName) {
|
|
@@ -3157,7 +3294,7 @@ var entry = [{
|
|
|
3157
3294
|
|
|
3158
3295
|
var require$$7 = {
|
|
3159
3296
|
name: "@tmsfe/tmskit",
|
|
3160
|
-
version: "0.0.
|
|
3297
|
+
version: "0.0.13",
|
|
3161
3298
|
description: "tmskit",
|
|
3162
3299
|
main: "dist/index.cjs",
|
|
3163
3300
|
bin: {
|
|
@@ -3200,9 +3337,6 @@ var require$$7 = {
|
|
|
3200
3337
|
"fs-extra": "^10.0.1",
|
|
3201
3338
|
"glob-ignore": "^1.0.2",
|
|
3202
3339
|
gulp: "^4.0.2",
|
|
3203
|
-
"gulp-cache": "^1.1.3",
|
|
3204
|
-
"gulp-postcss": "^9.0.1",
|
|
3205
|
-
"gulp-px-to-rpx": "^1.0.7",
|
|
3206
3340
|
"gulp-watch": "^5.0.1",
|
|
3207
3341
|
htmlparser2: "^7.2.0",
|
|
3208
3342
|
inquirer: "^7.3.3",
|
|
@@ -3210,6 +3344,7 @@ var require$$7 = {
|
|
|
3210
3344
|
lodash: "^4.17.21",
|
|
3211
3345
|
metalsmith: "^2.3.0",
|
|
3212
3346
|
"miniprogram-ci": "1.4.13",
|
|
3347
|
+
moment: "^2.29.1",
|
|
3213
3348
|
"object-assign": "^4.0.1",
|
|
3214
3349
|
ora: "^5.1.0",
|
|
3215
3350
|
"plugin-error": "^1.0.0",
|
|
@@ -3229,7 +3364,7 @@ var require$$7 = {
|
|
|
3229
3364
|
}
|
|
3230
3365
|
};
|
|
3231
3366
|
|
|
3232
|
-
const semver = require$$1__default$
|
|
3367
|
+
const semver = require$$1__default$9;
|
|
3233
3368
|
const packageJson = require$$7;
|
|
3234
3369
|
const chalk$1 = require$$0__default;
|
|
3235
3370
|
const {
|
|
@@ -3305,15 +3440,12 @@ function registerCommand(program, commands) {
|
|
|
3305
3440
|
|
|
3306
3441
|
registerCommand(program, commands);
|
|
3307
3442
|
program.on('--help', () => {
|
|
3308
|
-
info();
|
|
3309
3443
|
info(` Run ${chalk.cyan(`${TMS_NAME} <command> --help`)} for detailed usage of given command.`);
|
|
3310
|
-
info();
|
|
3311
3444
|
}); // 捕获未注册的命令
|
|
3312
3445
|
|
|
3313
3446
|
program.arguments('<command>').action(cmd => {
|
|
3314
3447
|
program.outputHelp();
|
|
3315
|
-
info(`
|
|
3316
|
-
info();
|
|
3448
|
+
info(` ${chalk.red(`Unknown command ${chalk.yellow(cmd)}.`)}`);
|
|
3317
3449
|
suggestCommands(cmd);
|
|
3318
3450
|
process.exitCode = 1;
|
|
3319
3451
|
});
|