@tmsfe/tmskit 0.0.11 → 0.0.14
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/README.md +6 -1
- package/dist/index.cjs.js +413 -316
- package/main.js +0 -0
- package/package.json +6 -5
- 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/mpCi.js +1 -1
- package/src/core/npm.js +9 -6
- package/src/core/symbolicLink.js +13 -7
- package/src/core/tmsMpconfig.js +13 -8
- package/src/index.js +1 -4
- package/src/scripts/run/index.js +11 -6
- package/src/scripts/run/init/index.js +0 -7
- 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,10 +125,10 @@ 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$
|
|
132
|
-
const fs$
|
|
130
|
+
const path$b = require$$1__default$2;
|
|
131
|
+
const fs$d = require$$0__default$2;
|
|
133
132
|
const shelljs$6 = require$$0__default$3;
|
|
134
133
|
const {
|
|
135
134
|
info: info$8
|
|
@@ -143,7 +142,7 @@ const shelljsOptions = {
|
|
|
143
142
|
const cwd = process.cwd();
|
|
144
143
|
|
|
145
144
|
function resolve$f(...args) {
|
|
146
|
-
return path$
|
|
145
|
+
return path$b.resolve(cwd, ...args);
|
|
147
146
|
}
|
|
148
147
|
/**
|
|
149
148
|
* 用户输入命令时,进行提示
|
|
@@ -199,8 +198,8 @@ function downloadRepoForGit$2(url, dest, branch) {
|
|
|
199
198
|
const cwd = process.cwd();
|
|
200
199
|
return new Promise((resolve, reject) => {
|
|
201
200
|
// 如果目标目录不存在
|
|
202
|
-
if (fs$
|
|
203
|
-
shelljs$6.rm('-rf', path$
|
|
201
|
+
if (fs$d.existsSync(dest)) {
|
|
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,6 +298,22 @@ 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
318
|
resolve: resolve$f,
|
|
305
319
|
isObject: isObject$2,
|
|
@@ -309,37 +323,39 @@ 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子目录
|
|
334
350
|
|
|
335
351
|
const DEFAULT_MODULE_DIR = 'modules'; // 模块代码的默认在modules子目录
|
|
336
352
|
|
|
337
|
-
const DEFAULT_CLOUD_MODULE_DIR
|
|
353
|
+
const DEFAULT_CLOUD_MODULE_DIR = './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,39 +372,42 @@ 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,
|
|
367
383
|
ENV: ENV,
|
|
368
384
|
TEMPLATE_TKIT_DIR: TEMPLATE_TKIT_DIR$2,
|
|
369
385
|
MODULE_CONFIG_INVALID_KEY: MODULE_CONFIG_INVALID_KEY$1,
|
|
370
|
-
DEFAULT_CLOUD_MODULE_DIR: DEFAULT_CLOUD_MODULE_DIR
|
|
386
|
+
DEFAULT_CLOUD_MODULE_DIR: DEFAULT_CLOUD_MODULE_DIR
|
|
371
387
|
});
|
|
372
388
|
|
|
373
389
|
var require$$4 = /*@__PURE__*/getAugmentedNamespace(constant);
|
|
374
390
|
|
|
375
|
-
const fs$
|
|
376
|
-
const path$
|
|
391
|
+
const fs$c = require$$0__default$2;
|
|
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 目录名
|
|
383
402
|
* @returns
|
|
384
403
|
*/
|
|
385
404
|
|
|
386
|
-
const isDirEmpty = dirname => fs$
|
|
405
|
+
const isDirEmpty = dirname => fs$c.promises.readdir(dirname).then(files => files.length === 0); // 判断是否是文件
|
|
387
406
|
|
|
388
407
|
|
|
389
408
|
const isFile = pathName => {
|
|
390
409
|
try {
|
|
391
|
-
const stat = fs$
|
|
410
|
+
const stat = fs$c.lstatSync(pathName);
|
|
392
411
|
return stat.isFile();
|
|
393
412
|
} catch {
|
|
394
413
|
return false;
|
|
@@ -401,8 +420,8 @@ const isFile = pathName => {
|
|
|
401
420
|
|
|
402
421
|
|
|
403
422
|
const ensureDirExist = dirname => {
|
|
404
|
-
if (!fs$
|
|
405
|
-
fs$
|
|
423
|
+
if (!fs$c.existsSync(dirname)) {
|
|
424
|
+
fs$c.mkdirSync(dirname, {
|
|
406
425
|
recursive: true
|
|
407
426
|
});
|
|
408
427
|
}
|
|
@@ -410,27 +429,27 @@ const ensureDirExist = dirname => {
|
|
|
410
429
|
|
|
411
430
|
|
|
412
431
|
const copyFile = function (src, dest) {
|
|
413
|
-
if (fs$
|
|
414
|
-
fs$
|
|
432
|
+
if (fs$c.existsSync(dest)) {
|
|
433
|
+
fs$c.unlinkSync(dest);
|
|
415
434
|
}
|
|
416
435
|
|
|
417
|
-
const dir = path$
|
|
436
|
+
const dir = path$9.dirname(dest);
|
|
418
437
|
ensureDirExist(dir);
|
|
419
|
-
fs$
|
|
438
|
+
fs$c.copyFileSync(src, dest);
|
|
420
439
|
}; // 判断文件内容是否一致,不一致再进行拷贝
|
|
421
440
|
|
|
422
441
|
|
|
423
442
|
function diffContentCopyFile$3(originFile, destFile) {
|
|
424
|
-
if (fs$
|
|
425
|
-
const depDestContent = fs$
|
|
426
|
-
const depOriginContent = fs$
|
|
443
|
+
if (fs$c.existsSync(destFile)) {
|
|
444
|
+
const depDestContent = fs$c.readFileSync(destFile, 'utf8');
|
|
445
|
+
const depOriginContent = fs$c.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
|
} // 添加后缀
|
|
@@ -441,7 +460,7 @@ function ext$3(filePath, extensions) {
|
|
|
441
460
|
let extPath = ''; // try catch需要包裹:用来处理'./lib/timer'没有后缀的情况
|
|
442
461
|
|
|
443
462
|
try {
|
|
444
|
-
const stat = fs$
|
|
463
|
+
const stat = fs$c.lstatSync(newFilePath);
|
|
445
464
|
|
|
446
465
|
if (stat.isDirectory()) {
|
|
447
466
|
extPath = newFilePath[newFilePath.length - 1] === '/' ? 'index' : '/index';
|
|
@@ -452,7 +471,7 @@ function ext$3(filePath, extensions) {
|
|
|
452
471
|
for (const ext of extensions) {
|
|
453
472
|
const file = newFilePath.endsWith(ext) ? newFilePath : newFilePath + ext;
|
|
454
473
|
|
|
455
|
-
if (fs$
|
|
474
|
+
if (fs$c.existsSync(file)) {
|
|
456
475
|
return {
|
|
457
476
|
ext,
|
|
458
477
|
extPath: extPath + ext,
|
|
@@ -470,11 +489,11 @@ function ext$3(filePath, extensions) {
|
|
|
470
489
|
|
|
471
490
|
|
|
472
491
|
const fileInDir$3 = (dir, file) => {
|
|
473
|
-
if (!fs$
|
|
492
|
+
if (!fs$c.existsSync(dir) || !fs$c.existsSync(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);
|
|
@@ -513,8 +532,8 @@ const render$1 = (files, metalsmith, next) => {
|
|
|
513
532
|
|
|
514
533
|
var render_1 = render$1;
|
|
515
534
|
|
|
516
|
-
const fs$
|
|
517
|
-
const inquirer = require$$1__default$
|
|
535
|
+
const fs$b = require$$0__default$2;
|
|
536
|
+
const inquirer = require$$1__default$4;
|
|
518
537
|
const {
|
|
519
538
|
resolve: resolve$e
|
|
520
539
|
} = widgets;
|
|
@@ -530,12 +549,12 @@ const {
|
|
|
530
549
|
const parseTemplateQuestions = dir => {
|
|
531
550
|
let prompts = [];
|
|
532
551
|
|
|
533
|
-
if (!fs$
|
|
552
|
+
if (!fs$b.existsSync(`${dir}/questions.json`)) {
|
|
534
553
|
return prompts;
|
|
535
554
|
}
|
|
536
555
|
|
|
537
556
|
try {
|
|
538
|
-
const json = JSON.parse(fs$
|
|
557
|
+
const json = JSON.parse(fs$b.readFileSync(`${dir}/questions.json`));
|
|
539
558
|
|
|
540
559
|
if (Array.isArray(json) && json.length > 0) {
|
|
541
560
|
json.forEach((item, index) => {
|
|
@@ -610,8 +629,8 @@ const generator$1 = (buildDir, distDir, preMetadata) => new Promise((resolve, re
|
|
|
610
629
|
|
|
611
630
|
var generator_1 = generator$1;
|
|
612
631
|
|
|
613
|
-
const path$
|
|
614
|
-
const fs$
|
|
632
|
+
const path$8 = require$$1__default$2;
|
|
633
|
+
const fs$a = require$$0__default$2;
|
|
615
634
|
const shelljs$5 = require$$0__default$3;
|
|
616
635
|
const {
|
|
617
636
|
TEMPLATE_DIR,
|
|
@@ -638,7 +657,7 @@ const generator = generator_1;
|
|
|
638
657
|
|
|
639
658
|
async function createAppDir(targetDir) {
|
|
640
659
|
// 如果目录非空或者已经存在,提示用户,做选择
|
|
641
|
-
if (fs$
|
|
660
|
+
if (fs$a.existsSync(targetDir)) {
|
|
642
661
|
if (!(await io$1.isDirEmpty(targetDir))) {
|
|
643
662
|
fail$8('该目录名已经存在,换个项目名字吧~');
|
|
644
663
|
process.exit(1);
|
|
@@ -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,7 +683,7 @@ 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(() => {
|
|
@@ -717,11 +736,10 @@ var defaultTmsConfig$1 = {
|
|
|
717
736
|
* 用来读取处理tms.config.js与module.config.json字段
|
|
718
737
|
*/
|
|
719
738
|
const loadash = require$$0__default$6;
|
|
720
|
-
const fs$
|
|
739
|
+
const fs$9 = 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 {
|
|
@@ -733,7 +751,7 @@ 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} 环境变量
|
|
@@ -742,7 +760,7 @@ const path$6 = require$$3__default;
|
|
|
742
760
|
const readTmsConfig$1 = function (env) {
|
|
743
761
|
const tmsConfigPath = resolve$c(TMS_CONFIG_FILENAME);
|
|
744
762
|
|
|
745
|
-
if (!fs$
|
|
763
|
+
if (!fs$9.existsSync(tmsConfigPath)) {
|
|
746
764
|
fail$7('当前执行目录没有tms.config.js的配置项,请进行配置');
|
|
747
765
|
process.exit(1);
|
|
748
766
|
}
|
|
@@ -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
|
|
|
@@ -792,7 +810,7 @@ const readTmsPrivateCf$1 = function () {
|
|
|
792
810
|
let tmsPrivateCf = {};
|
|
793
811
|
const tmsPrivatePath = resolve$c(TMS_PRIVATE_FILENAME);
|
|
794
812
|
|
|
795
|
-
if (fs$
|
|
813
|
+
if (fs$9.existsSync(tmsPrivatePath)) {
|
|
796
814
|
tmsPrivateCf = require(tmsPrivatePath);
|
|
797
815
|
} // 处理modules字段
|
|
798
816
|
|
|
@@ -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;
|
|
@@ -885,8 +904,8 @@ function getModuleConfig$1(modules = [], appName, moduleConfigFilename) {
|
|
|
885
904
|
}) => {
|
|
886
905
|
const moduleConfigPath = resolve$c(path, moduleConfigFilename);
|
|
887
906
|
|
|
888
|
-
if (fs$
|
|
889
|
-
const content = fs$
|
|
907
|
+
if (fs$9.existsSync(moduleConfigPath)) {
|
|
908
|
+
const content = fs$9.readFileSync(moduleConfigPath, 'utf-8');
|
|
890
909
|
modulesConfig[moduleConfigPath] = adaptMpCgContent(content, appName);
|
|
891
910
|
}
|
|
892
911
|
});
|
|
@@ -907,12 +926,12 @@ const tmsModulesMergeLocalModuleCfg$3 = (modules, appName) => {
|
|
|
907
926
|
path: relativePath,
|
|
908
927
|
name: moduleName
|
|
909
928
|
}, moduleIndex) => {
|
|
910
|
-
const moduleConfigPath = resolve$c(relativePath, MODULE_CONFIG_FILENAME$
|
|
929
|
+
const moduleConfigPath = resolve$c(relativePath, MODULE_CONFIG_FILENAME$1);
|
|
911
930
|
|
|
912
|
-
if (fs$
|
|
931
|
+
if (fs$9.existsSync(moduleConfigPath)) {
|
|
913
932
|
try {
|
|
914
933
|
let findModule = false;
|
|
915
|
-
let moduleConfigContent = fs$
|
|
934
|
+
let moduleConfigContent = fs$9.readFileSync(moduleConfigPath, 'utf-8');
|
|
916
935
|
moduleConfigContent = adaptMpCgContent(moduleConfigContent, appName);
|
|
917
936
|
const moduleContentArr = isObject$1(moduleConfigContent) ? [moduleConfigContent] : moduleConfigContent;
|
|
918
937
|
getValidModules$1(moduleContentArr).forEach(({
|
|
@@ -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
|
-
function handleError$
|
|
1044
|
+
function handleError$4(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);
|
|
@@ -1032,15 +1054,15 @@ function handleError$5(error) {
|
|
|
1032
1054
|
}
|
|
1033
1055
|
|
|
1034
1056
|
var handleError_1 = {
|
|
1035
|
-
handleError: handleError$
|
|
1057
|
+
handleError: handleError$4
|
|
1036
1058
|
};
|
|
1037
1059
|
|
|
1038
1060
|
/**
|
|
1039
1061
|
* 生成编译后的app.json
|
|
1040
1062
|
*/
|
|
1041
|
-
const fs$
|
|
1063
|
+
const fs$8 = 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 {
|
|
@@ -1055,7 +1077,7 @@ const {
|
|
|
1055
1077
|
isObject
|
|
1056
1078
|
} = widgets;
|
|
1057
1079
|
const {
|
|
1058
|
-
handleError: handleError$
|
|
1080
|
+
handleError: handleError$3
|
|
1059
1081
|
} = handleError_1;
|
|
1060
1082
|
/**
|
|
1061
1083
|
* 更新appJson里面的主包配置
|
|
@@ -1101,12 +1123,12 @@ function updateMainPackages(appJson, mainPackages = []) {
|
|
|
1101
1123
|
|
|
1102
1124
|
|
|
1103
1125
|
const getAppJsonContent = sourceAppJsonPath => {
|
|
1104
|
-
if (!fs$
|
|
1126
|
+
if (!fs$8.existsSync(sourceAppJsonPath)) {
|
|
1105
1127
|
fail$5(`当前路径 ${sourceAppJsonPath} 没找到app.json`);
|
|
1106
1128
|
process.exit(1);
|
|
1107
1129
|
}
|
|
1108
1130
|
|
|
1109
|
-
const appJson = JSON.parse(fs$
|
|
1131
|
+
const appJson = JSON.parse(fs$8.readFileSync(sourceAppJsonPath), 'utf-8'); // 加入默认值
|
|
1110
1132
|
|
|
1111
1133
|
appJson.subpackages = [];
|
|
1112
1134
|
appJson.pages = []; // appJson.plugins = {};
|
|
@@ -1210,7 +1232,7 @@ 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
1237
|
const appJson = getAppJsonContent(resolve$b('./app.json')); // 更新app.json中的subpackages
|
|
1216
1238
|
|
|
@@ -1219,10 +1241,10 @@ function buildOutputAppJson$1(tmsConfig, modules) {
|
|
|
1219
1241
|
fixAppJson(appJson); // 更新主包,需在subpackages处理完成后执行, pages/
|
|
1220
1242
|
|
|
1221
1243
|
updateMainPackages(appJson, tmsConfig.mainPackages);
|
|
1222
|
-
fs$
|
|
1244
|
+
fs$8.writeFileSync(resolve$b(`${tmsConfig.outputDir}/app.json`), JSON.stringify(appJson, null, 2), 'utf8');
|
|
1223
1245
|
return appJson;
|
|
1224
1246
|
} catch (e) {
|
|
1225
|
-
handleError$
|
|
1247
|
+
handleError$3(`生成app.json出现错误: ${e}`);
|
|
1226
1248
|
}
|
|
1227
1249
|
}
|
|
1228
1250
|
|
|
@@ -1230,51 +1252,15 @@ var buildAppJson = {
|
|
|
1230
1252
|
buildOutputAppJson: buildOutputAppJson$1
|
|
1231
1253
|
};
|
|
1232
1254
|
|
|
1233
|
-
const fs$8 = require$$0__default$2;
|
|
1234
|
-
const {
|
|
1235
|
-
resolve: resolve$a
|
|
1236
|
-
} = widgets;
|
|
1237
|
-
const {
|
|
1238
|
-
handleError: handleError$3
|
|
1239
|
-
} = handleError_1;
|
|
1240
|
-
const {
|
|
1241
|
-
DEFAULT_CLOUD_MODULE_DIR
|
|
1242
|
-
} = require$$4;
|
|
1243
|
-
/**
|
|
1244
|
-
* 根据相关配置创建软链接
|
|
1245
|
-
* @param { object } tmsConfig
|
|
1246
|
-
*/
|
|
1247
|
-
|
|
1248
|
-
const symLink$1 = tmsConfig => {
|
|
1249
|
-
try {
|
|
1250
|
-
if (tmsConfig.cloudModules) {
|
|
1251
|
-
tmsConfig.cloudModules.forEach(item => {
|
|
1252
|
-
const path = resolve$a(DEFAULT_CLOUD_MODULE_DIR, item.name);
|
|
1253
|
-
fs$8.access(path, fs$8.constants.F_OK, res => {
|
|
1254
|
-
if (res) {
|
|
1255
|
-
fs$8.symlinkSync(resolve$a(item.path), path);
|
|
1256
|
-
}
|
|
1257
|
-
});
|
|
1258
|
-
});
|
|
1259
|
-
}
|
|
1260
|
-
} catch (e) {
|
|
1261
|
-
handleError$3(`创建软链错误: ${e}`);
|
|
1262
|
-
}
|
|
1263
|
-
};
|
|
1264
|
-
|
|
1265
|
-
var symbolicLink = {
|
|
1266
|
-
symLink: symLink$1
|
|
1267
|
-
};
|
|
1268
|
-
|
|
1269
1255
|
/**
|
|
1270
1256
|
* 下载第三方代码
|
|
1271
1257
|
*/
|
|
1272
1258
|
const MetalSmith = require$$0__default$5;
|
|
1273
|
-
const crypto$1 = require$$1__default$
|
|
1259
|
+
const crypto$1 = require$$1__default$5;
|
|
1274
1260
|
const {
|
|
1275
1261
|
downloadRepoForGit,
|
|
1276
1262
|
pullRepoForGit,
|
|
1277
|
-
resolve: resolve$
|
|
1263
|
+
resolve: resolve$a
|
|
1278
1264
|
} = widgets;
|
|
1279
1265
|
const {
|
|
1280
1266
|
fail: fail$4,
|
|
@@ -1286,7 +1272,7 @@ const {
|
|
|
1286
1272
|
handleError: handleError$2
|
|
1287
1273
|
} = handleError_1;
|
|
1288
1274
|
const {
|
|
1289
|
-
global: global$
|
|
1275
|
+
global: global$4
|
|
1290
1276
|
} = global_1;
|
|
1291
1277
|
/**
|
|
1292
1278
|
* 处理用户没有clone git仓库权限问题,拼接tms.private.config.js的账号信息
|
|
@@ -1296,15 +1282,15 @@ const {
|
|
|
1296
1282
|
*/
|
|
1297
1283
|
|
|
1298
1284
|
function replaceGitUrlAccount(httpRepoUrl, moduleName) {
|
|
1299
|
-
var _tmsPrivateCf$gitAcco;
|
|
1285
|
+
var _tmsPrivateCf$gitAcco, _tmsPrivateCf$gitAcco2;
|
|
1300
1286
|
|
|
1301
1287
|
// 用户本地的私有项目配置(用来配置环境\模块信息\账号信息)
|
|
1302
|
-
const tmsPrivateCf = global$
|
|
1288
|
+
const tmsPrivateCf = global$4.getData('tmsPrivateCf');
|
|
1303
1289
|
let gitUrl = httpRepoUrl;
|
|
1304
1290
|
const {
|
|
1305
1291
|
username = '',
|
|
1306
1292
|
pass = ''
|
|
1307
|
-
} = (tmsPrivateCf === null || tmsPrivateCf === void 0 ? void 0 : (_tmsPrivateCf$gitAcco = tmsPrivateCf.gitAccout) === null || _tmsPrivateCf$gitAcco === void 0 ? void 0 : _tmsPrivateCf$gitAcco[moduleName]) || {};
|
|
1293
|
+
} = (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
1294
|
const urlPrefixReg = /http(s)?:\/\//;
|
|
1309
1295
|
|
|
1310
1296
|
if (username && pass && urlPrefixReg.test(gitUrl)) {
|
|
@@ -1359,7 +1345,8 @@ function md5ByGitUrlBranch(gitUrl, branch) {
|
|
|
1359
1345
|
|
|
1360
1346
|
|
|
1361
1347
|
async function cloneModules$1(sourceDir, targetDir, modules) {
|
|
1362
|
-
// 收集下载模块代码的任务
|
|
1348
|
+
const cwd = process.cwd(); // 收集下载模块代码的任务
|
|
1349
|
+
|
|
1363
1350
|
const downloadTasksMap = collectDownLoadTasksMap(sourceDir, targetDir, modules); // 开始执行下载和移动代码的任务
|
|
1364
1351
|
|
|
1365
1352
|
const arrPromises = [];
|
|
@@ -1379,6 +1366,7 @@ async function cloneModules$1(sourceDir, targetDir, modules) {
|
|
|
1379
1366
|
}));
|
|
1380
1367
|
});
|
|
1381
1368
|
await Promise.all(arrPromises);
|
|
1369
|
+
shelljs$4.cd(cwd);
|
|
1382
1370
|
}
|
|
1383
1371
|
/**
|
|
1384
1372
|
* 收集下载模块代码的任务
|
|
@@ -1419,9 +1407,9 @@ function collectDownLoadTasksMap(sourceDir, targetDir, modules) {
|
|
|
1419
1407
|
|
|
1420
1408
|
const md5Key = md5ByGitUrlBranch(gitUrl, branch); // git源码临时存在的源目录
|
|
1421
1409
|
|
|
1422
|
-
const sourcePath = resolve$
|
|
1410
|
+
const sourcePath = resolve$a(sourceDir, md5Key); // 模块源码要放到目标目录
|
|
1423
1411
|
|
|
1424
|
-
const targetPath = resolve$
|
|
1412
|
+
const targetPath = resolve$a(targetDir, path); // 从git源码仓库中找到模块源码路径 (一个仓库存在存放多个模块的情况)
|
|
1425
1413
|
|
|
1426
1414
|
const sourceModulePath = gitPath ? `${sourcePath}/${gitPath}` : sourcePath; // 下载完代码后,添加回调函数(主要将模块代码从临时目录移动代码到目标目录)
|
|
1427
1415
|
|
|
@@ -1448,12 +1436,12 @@ function collectDownLoadTasksMap(sourceDir, targetDir, modules) {
|
|
|
1448
1436
|
|
|
1449
1437
|
if (fs$7.existsSync(sourcePath) && fs$7.existsSync(`${sourcePath}/.git`)) {
|
|
1450
1438
|
promiseTask = (gitUrl, sourcePath, branch, httpRepoUrl) => {
|
|
1451
|
-
info$5(`git pull
|
|
1439
|
+
info$5(`git pull:${httpRepoUrl}`);
|
|
1452
1440
|
return pullRepoForGit(sourcePath, branch);
|
|
1453
1441
|
};
|
|
1454
1442
|
} else {
|
|
1455
1443
|
promiseTask = (gitUrl, sourcePath, branch, httpRepoUrl) => {
|
|
1456
|
-
info$5(`git clone
|
|
1444
|
+
info$5(`git clone: ${httpRepoUrl}`);
|
|
1457
1445
|
return downloadRepoForGit(gitUrl, sourcePath, branch);
|
|
1458
1446
|
};
|
|
1459
1447
|
}
|
|
@@ -1508,7 +1496,7 @@ var cloneModules_1 = {
|
|
|
1508
1496
|
};
|
|
1509
1497
|
|
|
1510
1498
|
const ci = require$$0__default$7;
|
|
1511
|
-
const path$
|
|
1499
|
+
const path$6 = require$$1__default$2;
|
|
1512
1500
|
/**
|
|
1513
1501
|
* 获取小程序ci的Project对象
|
|
1514
1502
|
* @returns {Object} 小程序ci对象
|
|
@@ -1522,7 +1510,7 @@ const getMpCi = ({
|
|
|
1522
1510
|
}) => {
|
|
1523
1511
|
var _cfgJsonContent$packO;
|
|
1524
1512
|
|
|
1525
|
-
const cfgJsonContent = require(path$
|
|
1513
|
+
const cfgJsonContent = require(path$6.join(projectPath, 'project.config.json'));
|
|
1526
1514
|
|
|
1527
1515
|
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
1516
|
value
|
|
@@ -1532,7 +1520,7 @@ const getMpCi = ({
|
|
|
1532
1520
|
privateKey,
|
|
1533
1521
|
type,
|
|
1534
1522
|
projectPath,
|
|
1535
|
-
ignores: ['node_modules/**/*', ...ignores]
|
|
1523
|
+
ignores: ['node_modules/**/*', 'cloud/**/*', ...ignores]
|
|
1536
1524
|
});
|
|
1537
1525
|
}; // 用小程序ci工具构建小程序
|
|
1538
1526
|
|
|
@@ -1592,9 +1580,9 @@ var mpCi = {
|
|
|
1592
1580
|
* 本文件主要负责项目或者分包依赖的npm的安装
|
|
1593
1581
|
*/
|
|
1594
1582
|
const fs$6 = require$$0__default$2;
|
|
1595
|
-
const fsExtra = require$$1__default$
|
|
1596
|
-
const crypto = require$$1__default$
|
|
1597
|
-
const path$
|
|
1583
|
+
const fsExtra = require$$1__default$6;
|
|
1584
|
+
const crypto = require$$1__default$5;
|
|
1585
|
+
const path$5 = require$$1__default$2;
|
|
1598
1586
|
const shell = require$$0__default$3;
|
|
1599
1587
|
const glob = require$$5__default;
|
|
1600
1588
|
const log = log$1;
|
|
@@ -1604,9 +1592,6 @@ const {
|
|
|
1604
1592
|
const {
|
|
1605
1593
|
handleError: handleError$1
|
|
1606
1594
|
} = handleError_1;
|
|
1607
|
-
const {
|
|
1608
|
-
info: info$4
|
|
1609
|
-
} = require$$9__default;
|
|
1610
1595
|
const shellJsOption = {
|
|
1611
1596
|
async: false,
|
|
1612
1597
|
silent: true
|
|
@@ -1637,14 +1622,14 @@ const collectNpmTasksMap = (packageJsonFiles, cacheDir) => {
|
|
|
1637
1622
|
|
|
1638
1623
|
if (Object.keys(md5Obj.dependencies).length !== 0) {
|
|
1639
1624
|
const md5Key = crypto.createHash('md5').update(JSON.stringify(md5Obj)).digest('hex');
|
|
1640
|
-
const cacheNMPath = path$
|
|
1641
|
-
const cacheNMTarFile = path$
|
|
1625
|
+
const cacheNMPath = path$5.join(cacheDir, md5Key);
|
|
1626
|
+
const cacheNMTarFile = path$5.join(cacheNMPath, 'node_modules.tar.gz'); // 下载后,添加回调函数 (拷贝node_modules.tar.gz到编译目录并解压)
|
|
1642
1627
|
|
|
1643
1628
|
const callback = {
|
|
1644
1629
|
params: {
|
|
1645
1630
|
cacheNMPath,
|
|
1646
1631
|
cacheNMTarFile,
|
|
1647
|
-
packageJsonDir: path$
|
|
1632
|
+
packageJsonDir: path$5.dirname(packageJsonPath),
|
|
1648
1633
|
shell
|
|
1649
1634
|
},
|
|
1650
1635
|
fn: async (cacheNMPath, cacheNMTarFile, packageJsonDir, shell) => {
|
|
@@ -1653,8 +1638,9 @@ const collectNpmTasksMap = (packageJsonFiles, cacheDir) => {
|
|
|
1653
1638
|
const newShellJsOption = { ...shellJsOption,
|
|
1654
1639
|
cwd: packageJsonDir
|
|
1655
1640
|
};
|
|
1656
|
-
shell.
|
|
1657
|
-
shell.exec('
|
|
1641
|
+
shell.cd(packageJsonDir);
|
|
1642
|
+
shell.exec('tar -xvf ./node_modules.tar.gz -C ./', newShellJsOption);
|
|
1643
|
+
shell.rm('-rf', './node_modules.tar.gz');
|
|
1658
1644
|
}
|
|
1659
1645
|
};
|
|
1660
1646
|
|
|
@@ -1671,13 +1657,14 @@ const collectNpmTasksMap = (packageJsonFiles, cacheDir) => {
|
|
|
1671
1657
|
promiseTask = (packageJsonPath, cacheNMPath, shell) => {
|
|
1672
1658
|
fsExtra.emptydirSync(cacheNMPath);
|
|
1673
1659
|
shell.cp('-f', packageJsonPath, cacheNMPath);
|
|
1674
|
-
info
|
|
1660
|
+
log.info(`npm install: ${packageJsonPath}`);
|
|
1675
1661
|
return npmInstall(cacheNMPath).then(() => {
|
|
1676
1662
|
const newShellJsOption = { ...shellJsOption,
|
|
1677
1663
|
cwd: cacheNMPath
|
|
1678
1664
|
};
|
|
1679
|
-
shell.
|
|
1680
|
-
shell.exec('
|
|
1665
|
+
shell.cd(cacheNMPath);
|
|
1666
|
+
shell.exec('tar -cvf ./node_modules.tar.gz ./node_modules', newShellJsOption);
|
|
1667
|
+
shell.rm('-rf', './node_modules');
|
|
1681
1668
|
});
|
|
1682
1669
|
};
|
|
1683
1670
|
}
|
|
@@ -1700,6 +1687,7 @@ const collectNpmTasksMap = (packageJsonFiles, cacheDir) => {
|
|
|
1700
1687
|
|
|
1701
1688
|
|
|
1702
1689
|
const mpNpmInstallAll$1 = async (modules, contextDir, cacheDir) => {
|
|
1690
|
+
const cwd = process.cwd();
|
|
1703
1691
|
const packageJsonFiles = await findAllPackageJson(modules, contextDir); // 收集npm install的任务
|
|
1704
1692
|
|
|
1705
1693
|
const npmTasksMap = collectNpmTasksMap(packageJsonFiles, cacheDir); // 开始执行npm install和回调(移动)的任务
|
|
@@ -1721,6 +1709,7 @@ const mpNpmInstallAll$1 = async (modules, contextDir, cacheDir) => {
|
|
|
1721
1709
|
}));
|
|
1722
1710
|
});
|
|
1723
1711
|
await Promise.all(arrPromises);
|
|
1712
|
+
shell.cd(cwd);
|
|
1724
1713
|
};
|
|
1725
1714
|
/**
|
|
1726
1715
|
* 递归查找指定条件的文件
|
|
@@ -1756,7 +1745,7 @@ const findFilesByFilter = (startPath, filter) => {
|
|
|
1756
1745
|
|
|
1757
1746
|
const files = fs$6.readdirSync(startPath);
|
|
1758
1747
|
files.forEach(file => {
|
|
1759
|
-
const filename = path$
|
|
1748
|
+
const filename = path$5.join(startPath, file);
|
|
1760
1749
|
const stat = fs$6.lstatSync(filename); // 当前文件是文件夹类型,继续递归
|
|
1761
1750
|
|
|
1762
1751
|
if (stat.isDirectory()) {
|
|
@@ -1783,7 +1772,7 @@ const findAllPackageJson = (subRoots = [], contextDir) => {
|
|
|
1783
1772
|
const packageJsonName = 'package.json'; // 查找文件名
|
|
1784
1773
|
|
|
1785
1774
|
const cwd = contextDir || dirPath;
|
|
1786
|
-
const result = [path$
|
|
1775
|
+
const result = [path$5.join(cwd, packageJsonName)]; // 默认填充根目录下的package.json
|
|
1787
1776
|
|
|
1788
1777
|
subRoots.forEach(subRoot => {
|
|
1789
1778
|
if (!subRoot.root) {
|
|
@@ -1791,7 +1780,7 @@ const findAllPackageJson = (subRoots = [], contextDir) => {
|
|
|
1791
1780
|
process.exit(1);
|
|
1792
1781
|
}
|
|
1793
1782
|
|
|
1794
|
-
const toppath = path$
|
|
1783
|
+
const toppath = path$5.join(cwd, subRoot.root); // 从该目录开始查找package.json文件
|
|
1795
1784
|
|
|
1796
1785
|
const list = findFilesByFilter(toppath, packageJsonName);
|
|
1797
1786
|
result.push(...list);
|
|
@@ -1807,7 +1796,7 @@ function cloudNpmInstall$1(contextDir) {
|
|
|
1807
1796
|
}
|
|
1808
1797
|
|
|
1809
1798
|
files.forEach(file => {
|
|
1810
|
-
const dir = path$
|
|
1799
|
+
const dir = path$5.dirname(file);
|
|
1811
1800
|
shell.cd(dir);
|
|
1812
1801
|
shell.exec('npx npm install --production --registry http://mirrors.tencent.com/npm/', {
|
|
1813
1802
|
silent: false
|
|
@@ -1826,7 +1815,7 @@ var npm = {
|
|
|
1826
1815
|
|
|
1827
1816
|
const {
|
|
1828
1817
|
createTask: createTask$1,
|
|
1829
|
-
resolve: resolve$
|
|
1818
|
+
resolve: resolve$9
|
|
1830
1819
|
} = widgets;
|
|
1831
1820
|
const {
|
|
1832
1821
|
buildMpNpm
|
|
@@ -1839,21 +1828,21 @@ const {
|
|
|
1839
1828
|
mpNpmInstallAll
|
|
1840
1829
|
} = npm;
|
|
1841
1830
|
const {
|
|
1842
|
-
global: global$
|
|
1831
|
+
global: global$3
|
|
1843
1832
|
} = global_1;
|
|
1844
1833
|
|
|
1845
1834
|
async function install$2(tmsConfig, modules, isCloud = false) {
|
|
1846
1835
|
// 小程序npm install
|
|
1847
|
-
await createTask$1(mpNpmInstallAll, '小程序 开始npm install', '小程序npm install 完成')(modules, resolve$
|
|
1848
|
-
const tmsPrivateCf = global$
|
|
1836
|
+
await createTask$1(mpNpmInstallAll, '小程序 开始npm install', '小程序npm install 完成')(modules, resolve$9(tmsConfig.outputDir), `${CACHE_DIR}/node_modules`);
|
|
1837
|
+
const tmsPrivateCf = global$3.getData('tmsPrivateCf'); // 构建miniprogram_npm
|
|
1849
1838
|
|
|
1850
1839
|
await createTask$1(buildMpNpm, '开始构建miniprogram_npm', '构建miniprogram_npm 完成')({
|
|
1851
1840
|
appId: tmsConfig.appId,
|
|
1852
|
-
projectPath: resolve$
|
|
1841
|
+
projectPath: resolve$9('./'),
|
|
1853
1842
|
privateKey: tmsPrivateCf.privateKey
|
|
1854
1843
|
}); // 安装云函数的
|
|
1855
1844
|
|
|
1856
|
-
isCloud && createTask$1(cloudNpmInstall, '云函数npm install', '云函数npm install安装完毕')(resolve$
|
|
1845
|
+
isCloud && createTask$1(cloudNpmInstall, '云函数npm install', '云函数npm install安装完毕')(resolve$9(tmsConfig.cloudDir));
|
|
1857
1846
|
}
|
|
1858
1847
|
|
|
1859
1848
|
var install_1 = install$2;
|
|
@@ -1862,15 +1851,12 @@ const shelljs$3 = require$$0__default$3;
|
|
|
1862
1851
|
const fs$5 = require$$0__default$2;
|
|
1863
1852
|
const io = io$2;
|
|
1864
1853
|
const {
|
|
1865
|
-
resolve: resolve$
|
|
1854
|
+
resolve: resolve$8,
|
|
1866
1855
|
createTask
|
|
1867
1856
|
} = widgets;
|
|
1868
1857
|
const {
|
|
1869
1858
|
buildOutputAppJson
|
|
1870
1859
|
} = buildAppJson;
|
|
1871
|
-
const {
|
|
1872
|
-
symLink
|
|
1873
|
-
} = symbolicLink;
|
|
1874
1860
|
const {
|
|
1875
1861
|
MODULE_CODE_DIR: MODULE_CODE_DIR$1,
|
|
1876
1862
|
DEFAULT_COPY_CONFIG
|
|
@@ -1884,7 +1870,7 @@ const {
|
|
|
1884
1870
|
} = tmsMpconfig;
|
|
1885
1871
|
const {
|
|
1886
1872
|
fail: fail$3,
|
|
1887
|
-
info: info$
|
|
1873
|
+
info: info$4
|
|
1888
1874
|
} = log$1;
|
|
1889
1875
|
const install$1 = install_1;
|
|
1890
1876
|
/**
|
|
@@ -1896,31 +1882,31 @@ const install$1 = install_1;
|
|
|
1896
1882
|
*/
|
|
1897
1883
|
|
|
1898
1884
|
const cpFilesToOutput = function (tmsConfig, targetModules, defaultFiles) {
|
|
1899
|
-
const outputDir = resolve$
|
|
1885
|
+
const outputDir = resolve$8(tmsConfig.outputDir);
|
|
1900
1886
|
io.ensureDirExist(outputDir);
|
|
1901
1887
|
defaultFiles.forEach(item => {
|
|
1902
|
-
if (fs$5.existsSync(resolve$
|
|
1903
|
-
shelljs$3.cp('-rf', resolve$
|
|
1888
|
+
if (fs$5.existsSync(resolve$8(item))) {
|
|
1889
|
+
shelljs$3.cp('-rf', resolve$8(item), resolve$8(tmsConfig.outputDir, item));
|
|
1904
1890
|
}
|
|
1905
1891
|
}); // 拷贝模块的package.json到编译输出目录
|
|
1906
1892
|
|
|
1907
1893
|
targetModules.forEach(item => {
|
|
1908
|
-
const outputModuleDir = resolve$
|
|
1894
|
+
const outputModuleDir = resolve$8(`${tmsConfig.outputDir}/${item.root}`);
|
|
1909
1895
|
|
|
1910
|
-
if (!fs$5.existsSync(resolve$
|
|
1896
|
+
if (!fs$5.existsSync(resolve$8(item.path))) {
|
|
1911
1897
|
fail$3(`${item.path}模块代码路径不存在, 请检查tms.config.js的${item.name}模块的path`);
|
|
1912
1898
|
process.exit(1);
|
|
1913
1899
|
}
|
|
1914
1900
|
|
|
1915
1901
|
io.ensureDirExist(outputModuleDir);
|
|
1916
|
-
const modulePackagePath = resolve$
|
|
1902
|
+
const modulePackagePath = resolve$8(item.path, 'package.json');
|
|
1917
1903
|
if (fs$5.existsSync(modulePackagePath)) shelljs$3.cp('-Rf', modulePackagePath, outputModuleDir);
|
|
1918
1904
|
});
|
|
1919
1905
|
};
|
|
1920
1906
|
|
|
1921
1907
|
async function task(tmsConfig, targetModules) {
|
|
1922
1908
|
// 下载和移动代码
|
|
1923
|
-
await createTask(cloneModules, '开始下载模块代码', '下载模块代码码完成')(MODULE_CODE_DIR$1, resolve$
|
|
1909
|
+
await createTask(cloneModules, '开始下载模块代码', '下载模块代码码完成')(MODULE_CODE_DIR$1, resolve$8('./'), targetModules); // tms.config.js的modules 合并 module.config.json的配置项
|
|
1924
1910
|
|
|
1925
1911
|
let newModules = tmsModulesMergeLocalModuleCfg$2(targetModules, tmsConfig.appName); // A分包依赖了B分包的代码, merge B分包进行编译;
|
|
1926
1912
|
|
|
@@ -1931,7 +1917,6 @@ async function task(tmsConfig, targetModules) {
|
|
|
1931
1917
|
await install$1(tmsConfig, newModules, false); // 动态生成编译后的app.json;
|
|
1932
1918
|
|
|
1933
1919
|
await createTask(buildOutputAppJson, '开始生成编译后的app.json', '生成编译后的app.json完成')(tmsConfig, newModules);
|
|
1934
|
-
await createTask(symLink, '开始创建软链接', '创建软链接完成')(tmsConfig);
|
|
1935
1920
|
return newModules;
|
|
1936
1921
|
}
|
|
1937
1922
|
|
|
@@ -1944,7 +1929,7 @@ async function init$5(tmsConfig, targetModules) {
|
|
|
1944
1929
|
} catch (error) {
|
|
1945
1930
|
const errMsg = typeof error === 'object' ? error.message : error;
|
|
1946
1931
|
fail$3(`init流程出现错误${errMsg}`);
|
|
1947
|
-
info$
|
|
1932
|
+
info$4('详细的错误信息', error);
|
|
1948
1933
|
process.exit(1);
|
|
1949
1934
|
}
|
|
1950
1935
|
}
|
|
@@ -2009,8 +1994,8 @@ var pluginError_1 = {
|
|
|
2009
1994
|
|
|
2010
1995
|
/* eslint-disable no-param-reassign */
|
|
2011
1996
|
const through$2 = require$$0__default$9;
|
|
2012
|
-
const precinct = require$$1__default$
|
|
2013
|
-
const path$
|
|
1997
|
+
const precinct = require$$1__default$7;
|
|
1998
|
+
const path$4 = require$$1__default$2;
|
|
2014
1999
|
const {
|
|
2015
2000
|
findCssImports
|
|
2016
2001
|
} = findCssImport;
|
|
@@ -2020,7 +2005,7 @@ const {
|
|
|
2020
2005
|
diffContentCopyFile: diffContentCopyFile$2
|
|
2021
2006
|
} = io$2;
|
|
2022
2007
|
const {
|
|
2023
|
-
resolve: resolve$
|
|
2008
|
+
resolve: resolve$7
|
|
2024
2009
|
} = widgets;
|
|
2025
2010
|
const fs$4 = require$$0__default$2;
|
|
2026
2011
|
const {
|
|
@@ -2040,11 +2025,11 @@ const dfsFindCommonDep$2 = function (anaFileOriginFile, anaFileDestFile, extensi
|
|
|
2040
2025
|
pluginError$2(e, isWatch);
|
|
2041
2026
|
}
|
|
2042
2027
|
|
|
2043
|
-
const deps = cssFilter.indexOf(path$
|
|
2028
|
+
const deps = cssFilter.indexOf(path$4.extname(anaFileOriginFile)) > -1 ? findCssImports(contents) : precinct(contents);
|
|
2044
2029
|
deps.forEach(depItem => {
|
|
2045
2030
|
if (depItem.startsWith('.')) {
|
|
2046
2031
|
// 被依赖文件的存在的绝对路径
|
|
2047
|
-
const depOriginPath = path$
|
|
2032
|
+
const depOriginPath = path$4.join(path$4.dirname(anaFileOriginFile), depItem); // 被依赖文件加上后缀
|
|
2048
2033
|
|
|
2049
2034
|
const {
|
|
2050
2035
|
ext: extAlias,
|
|
@@ -2057,7 +2042,7 @@ const dfsFindCommonDep$2 = function (anaFileOriginFile, anaFileDestFile, extensi
|
|
|
2057
2042
|
return;
|
|
2058
2043
|
}
|
|
2059
2044
|
|
|
2060
|
-
const depDestPath = resolve$
|
|
2045
|
+
const depDestPath = resolve$7(path$4.dirname(anaFileDestFile), depItem);
|
|
2061
2046
|
const depDestFile = depDestPath.endsWith(extAlias) ? depDestPath : depDestPath + extPath;
|
|
2062
2047
|
|
|
2063
2048
|
if (!resDep.has(depDestFile)) {
|
|
@@ -2081,19 +2066,19 @@ function mpCommonDep$1(tmsConfig, module, extensions = [], isWatch = true) {
|
|
|
2081
2066
|
const stream = through$2.obj(function (file, enc, cb) {
|
|
2082
2067
|
// 依赖分析的文件
|
|
2083
2068
|
const anaFileOriginFile = file.history[0];
|
|
2084
|
-
const anaFileRelativeModule = path$
|
|
2085
|
-
const anaFileDestFile = resolve$
|
|
2069
|
+
const anaFileRelativeModule = path$4.relative(resolve$7(module.from), anaFileOriginFile);
|
|
2070
|
+
const anaFileDestFile = resolve$7(tmsConfig.outputDir, module.to, anaFileRelativeModule);
|
|
2086
2071
|
|
|
2087
2072
|
if (file.isBuffer()) {
|
|
2088
2073
|
let contents = String(file.contents);
|
|
2089
|
-
const deps = cssFilter.indexOf(path$
|
|
2074
|
+
const deps = cssFilter.indexOf(path$4.extname(file.path)) > -1 ? findCssImports(contents) : precinct(contents);
|
|
2090
2075
|
const copyModules = new Map();
|
|
2091
2076
|
Object.keys(tmsConfig.dependencies).forEach(includeName => {
|
|
2092
2077
|
const includePath = tmsConfig.dependencies[includeName];
|
|
2093
2078
|
deps.forEach(depItem => {
|
|
2094
2079
|
if (depItem.indexOf(includeName) > -1) {
|
|
2095
2080
|
// 被依赖文件的存在的绝对路径 (eg: /User/thirdparty/loadsh)
|
|
2096
|
-
const depOriginPath = path$
|
|
2081
|
+
const depOriginPath = path$4.join(path$4.dirname(anaFileOriginFile), depItem); // 被依赖文件加上后缀
|
|
2097
2082
|
|
|
2098
2083
|
const {
|
|
2099
2084
|
ext: extAlias,
|
|
@@ -2111,7 +2096,7 @@ function mpCommonDep$1(tmsConfig, module, extensions = [], isWatch = true) {
|
|
|
2111
2096
|
const regRes = depItem.match(reg) || [];
|
|
2112
2097
|
|
|
2113
2098
|
if (regRes[2]) {
|
|
2114
|
-
const depDestPath = resolve$
|
|
2099
|
+
const depDestPath = resolve$7(tmsConfig.outputDir, module.to, includeName, regRes[2]);
|
|
2115
2100
|
const depDestFile = depDestPath.endsWith(extAlias) ? depDestPath : depDestPath + extPath;
|
|
2116
2101
|
|
|
2117
2102
|
if (!copyModules.has(depDestFile)) {
|
|
@@ -2119,7 +2104,7 @@ function mpCommonDep$1(tmsConfig, module, extensions = [], isWatch = true) {
|
|
|
2119
2104
|
depOriginFile,
|
|
2120
2105
|
depDestFile,
|
|
2121
2106
|
beforeDepPath: depItem,
|
|
2122
|
-
afterDepPath: path$
|
|
2107
|
+
afterDepPath: path$4.relative(path$4.dirname(anaFileDestFile), depDestPath).replace(/\\/g, '/')
|
|
2123
2108
|
});
|
|
2124
2109
|
}
|
|
2125
2110
|
}
|
|
@@ -2157,14 +2142,14 @@ var mpCommonDep_1 = {
|
|
|
2157
2142
|
|
|
2158
2143
|
/* eslint-disable no-param-reassign */
|
|
2159
2144
|
const through$1 = require$$0__default$9;
|
|
2160
|
-
const path$
|
|
2145
|
+
const path$3 = require$$1__default$2;
|
|
2161
2146
|
const {
|
|
2162
2147
|
ext: ext$1,
|
|
2163
2148
|
fileInDir: fileInDir$1,
|
|
2164
2149
|
diffContentCopyFile: diffContentCopyFile$1
|
|
2165
2150
|
} = io$2;
|
|
2166
2151
|
const {
|
|
2167
|
-
resolve: resolve$
|
|
2152
|
+
resolve: resolve$6
|
|
2168
2153
|
} = widgets;
|
|
2169
2154
|
const fs$3 = require$$0__default$2;
|
|
2170
2155
|
const {
|
|
@@ -2178,8 +2163,8 @@ function mpJsonDep$1(tmsConfig, module, extensions = ['.json'], filesExt = ['.wx
|
|
|
2178
2163
|
const stream = through$1.obj(function (file, enc, cb) {
|
|
2179
2164
|
// 当前分析的文件的路径
|
|
2180
2165
|
const anaFileOriginFile = file.history[0];
|
|
2181
|
-
const anaFileRelativeModule = path$
|
|
2182
|
-
const anaFileDestFile = resolve$
|
|
2166
|
+
const anaFileRelativeModule = path$3.relative(resolve$6(module.from), anaFileOriginFile);
|
|
2167
|
+
const anaFileDestFile = resolve$6(tmsConfig.outputDir, module.to, anaFileRelativeModule);
|
|
2183
2168
|
|
|
2184
2169
|
if (file.isBuffer()) {
|
|
2185
2170
|
let contents = String(file.contents);
|
|
@@ -2199,7 +2184,7 @@ function mpJsonDep$1(tmsConfig, module, extensions = ['.json'], filesExt = ['.wx
|
|
|
2199
2184
|
const componentPath = contents.usingComponents[componentKey];
|
|
2200
2185
|
|
|
2201
2186
|
if (componentPath.indexOf(includeName) > -1) {
|
|
2202
|
-
const depOriginPath = path$
|
|
2187
|
+
const depOriginPath = path$3.join(path$3.dirname(anaFileOriginFile), componentPath); // 被依赖文件加上后缀
|
|
2203
2188
|
|
|
2204
2189
|
const {
|
|
2205
2190
|
ext: extAlias,
|
|
@@ -2218,7 +2203,7 @@ function mpJsonDep$1(tmsConfig, module, extensions = ['.json'], filesExt = ['.wx
|
|
|
2218
2203
|
const regRes = componentPath.match(reg) || [];
|
|
2219
2204
|
|
|
2220
2205
|
if (regRes[2]) {
|
|
2221
|
-
const depDestPath = resolve$
|
|
2206
|
+
const depDestPath = resolve$6(tmsConfig.outputDir, module.to, includeName, regRes[2]);
|
|
2222
2207
|
const depDestFile = depDestPath.endsWith(extAlias) ? depDestPath : depDestPath + extPath;
|
|
2223
2208
|
|
|
2224
2209
|
if (!copyModules.has(depDestFile)) {
|
|
@@ -2227,7 +2212,7 @@ function mpJsonDep$1(tmsConfig, module, extensions = ['.json'], filesExt = ['.wx
|
|
|
2227
2212
|
depOriginExt: extAlias,
|
|
2228
2213
|
depDestFile,
|
|
2229
2214
|
beforeDepPath: componentPath,
|
|
2230
|
-
afterDepPath: path$
|
|
2215
|
+
afterDepPath: path$3.relative(path$3.dirname(anaFileDestFile), depDestPath).replace(/\\/g, '/')
|
|
2231
2216
|
});
|
|
2232
2217
|
}
|
|
2233
2218
|
}
|
|
@@ -2285,16 +2270,16 @@ var mpJsonDep_1 = {
|
|
|
2285
2270
|
|
|
2286
2271
|
/* eslint-disable no-param-reassign */
|
|
2287
2272
|
const through = require$$0__default$9;
|
|
2288
|
-
const htmlparser2 = require$$1__default$
|
|
2273
|
+
const htmlparser2 = require$$1__default$8;
|
|
2289
2274
|
const fs$2 = require$$0__default$2;
|
|
2290
|
-
const path$
|
|
2275
|
+
const path$2 = require$$1__default$2;
|
|
2291
2276
|
const {
|
|
2292
2277
|
diffContentCopyFile,
|
|
2293
2278
|
ext,
|
|
2294
2279
|
fileInDir
|
|
2295
2280
|
} = io$2;
|
|
2296
2281
|
const {
|
|
2297
|
-
resolve: resolve$
|
|
2282
|
+
resolve: resolve$5
|
|
2298
2283
|
} = widgets;
|
|
2299
2284
|
const {
|
|
2300
2285
|
dfsFindCommonDep
|
|
@@ -2343,7 +2328,7 @@ const dfsFindWxmlDep = function (anaFileOriginFile, anaFileDestFile, isWatch = t
|
|
|
2343
2328
|
var _attributes$src;
|
|
2344
2329
|
|
|
2345
2330
|
if (attributes !== null && attributes !== void 0 && (_attributes$src = attributes.src) !== null && _attributes$src !== void 0 && _attributes$src.startsWith('.')) {
|
|
2346
|
-
const depOriginPath = path$
|
|
2331
|
+
const depOriginPath = path$2.join(path$2.dirname(anaFileOriginFile), attributes.src); // 被依赖文件加上后缀
|
|
2347
2332
|
|
|
2348
2333
|
const {
|
|
2349
2334
|
ext,
|
|
@@ -2356,7 +2341,7 @@ const dfsFindWxmlDep = function (anaFileOriginFile, anaFileDestFile, isWatch = t
|
|
|
2356
2341
|
return;
|
|
2357
2342
|
}
|
|
2358
2343
|
|
|
2359
|
-
const depDestPath = path$
|
|
2344
|
+
const depDestPath = path$2.join(path$2.dirname(anaFileDestFile), attributes.src);
|
|
2360
2345
|
const depDestFile = depDestPath.endsWith(ext) ? depDestPath : depDestPath + extPath; // 收集wxml依赖
|
|
2361
2346
|
|
|
2362
2347
|
if (['import', 'include'].indexOf(name) > -1) {
|
|
@@ -2408,8 +2393,8 @@ function mpWxmlDep$1(tmsConfig, module, isWatch) {
|
|
|
2408
2393
|
const stream = through.obj(function (file, enc, cb) {
|
|
2409
2394
|
// 依赖分析的文件
|
|
2410
2395
|
const anaFileOriginFile = file.history[0];
|
|
2411
|
-
const anaFileRelativeModule = path$
|
|
2412
|
-
const anaFileDestFile = resolve$
|
|
2396
|
+
const anaFileRelativeModule = path$2.relative(resolve$5(module.from), anaFileOriginFile);
|
|
2397
|
+
const anaFileDestFile = resolve$5(tmsConfig.outputDir, module.to, anaFileRelativeModule);
|
|
2413
2398
|
|
|
2414
2399
|
if (file.isBuffer()) {
|
|
2415
2400
|
let contents = String(file.contents);
|
|
@@ -2419,7 +2404,7 @@ function mpWxmlDep$1(tmsConfig, module, isWatch) {
|
|
|
2419
2404
|
const nameFilter = ['import', 'include', 'wxs'];
|
|
2420
2405
|
|
|
2421
2406
|
if (nameFilter.indexOf(name) > -1 && attributes.src) {
|
|
2422
|
-
const depOriginPath = path$
|
|
2407
|
+
const depOriginPath = path$2.join(path$2.dirname(anaFileOriginFile), attributes.src); // 处理后缀(源码引入依赖时,后缀不全的情况)
|
|
2423
2408
|
|
|
2424
2409
|
const {
|
|
2425
2410
|
ext,
|
|
@@ -2440,7 +2425,7 @@ function mpWxmlDep$1(tmsConfig, module, isWatch) {
|
|
|
2440
2425
|
const regRes = attributes.src.match(reg) || [];
|
|
2441
2426
|
|
|
2442
2427
|
if (regRes[2]) {
|
|
2443
|
-
const depDestPath = resolve$
|
|
2428
|
+
const depDestPath = resolve$5(tmsConfig.outputDir, module.to, includeName, regRes[2]);
|
|
2444
2429
|
const depDestFile = depDestPath.endsWith(ext) ? depDestPath : depDestPath + extPath;
|
|
2445
2430
|
|
|
2446
2431
|
if (!copyModules.has(depDestFile)) {
|
|
@@ -2448,7 +2433,7 @@ function mpWxmlDep$1(tmsConfig, module, isWatch) {
|
|
|
2448
2433
|
depOriginFile,
|
|
2449
2434
|
depDestFile,
|
|
2450
2435
|
beforeDepPath: attributes.src,
|
|
2451
|
-
afterDepPath: path$
|
|
2436
|
+
afterDepPath: path$2.relative(path$2.dirname(anaFileDestFile), depDestFile).replace(/\\/g, '/')
|
|
2452
2437
|
});
|
|
2453
2438
|
}
|
|
2454
2439
|
}
|
|
@@ -2505,11 +2490,9 @@ var mpWxmlDep_1 = {
|
|
|
2505
2490
|
|
|
2506
2491
|
const {
|
|
2507
2492
|
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');
|
|
2493
|
+
dest
|
|
2494
|
+
} = require$$0__default$a; // const px2rpx = require('gulp-px-to-rpx');
|
|
2495
|
+
// const cache = require('gulp-cache');
|
|
2513
2496
|
// const image = require('gulp-image');
|
|
2514
2497
|
// const replaceEnv = require('./plugins/replaceEnv');
|
|
2515
2498
|
|
|
@@ -2526,87 +2509,168 @@ const {
|
|
|
2526
2509
|
|
|
2527
2510
|
const {
|
|
2528
2511
|
fail: fail$1
|
|
2529
|
-
} = log$1;
|
|
2530
|
-
|
|
2531
|
-
const since = task => file => lastRun(task) > file.stat.ctime ? lastRun(task) : 0;
|
|
2512
|
+
} = log$1; // const since = task => file => (lastRun(task) > file.stat.ctime ? lastRun(task) : 0);
|
|
2532
2513
|
|
|
2533
2514
|
var compile = function (tmsConfig, {
|
|
2534
2515
|
glob,
|
|
2535
2516
|
destPath,
|
|
2536
2517
|
srcOption,
|
|
2537
2518
|
module,
|
|
2538
|
-
watchOption = {
|
|
2539
|
-
events: ['change', 'add', 'unlink']
|
|
2540
|
-
},
|
|
2541
2519
|
isWatch
|
|
2542
2520
|
}) {
|
|
2521
|
+
const compileTasksMap = new Map();
|
|
2543
2522
|
Object.keys(glob).forEach(globKey => {
|
|
2544
2523
|
const globValue = glob[globKey];
|
|
2545
2524
|
|
|
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
2525
|
switch (globKey) {
|
|
2557
2526
|
case 'js':
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2527
|
+
compileTasksMap.set(globValue, {
|
|
2528
|
+
module,
|
|
2529
|
+
taskFn: () => {
|
|
2530
|
+
// const srcTask = () => src(globValue, { ...srcOption, since: since(srcTask) });
|
|
2531
|
+
// const srcPipe = srcTask();
|
|
2532
|
+
const srcPipe = src$1(globValue, { ...srcOption
|
|
2533
|
+
});
|
|
2534
|
+
return srcPipe // .pipe(replaceEnv(/process\.env(\.(\w*))?/g, tmsConfig.envData))
|
|
2535
|
+
.pipe(mpCommonDep(tmsConfig, module, ['.js', '.ts', '.wxs', '.json'], isWatch)).pipe(dest(destPath)).on('error', err => {
|
|
2536
|
+
fail$1(`js编译报错${err}`);
|
|
2537
|
+
});
|
|
2538
|
+
}
|
|
2561
2539
|
});
|
|
2562
2540
|
break;
|
|
2563
2541
|
|
|
2564
2542
|
case 'wxss':
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2543
|
+
compileTasksMap.set(globValue, {
|
|
2544
|
+
module,
|
|
2545
|
+
taskFn: () => {
|
|
2546
|
+
// const srcTask = () => src(globValue, { ...srcOption, since: since(srcTask) });
|
|
2547
|
+
// const srcPipe = srcTask();
|
|
2548
|
+
const srcPipe = src$1(globValue, { ...srcOption
|
|
2549
|
+
});
|
|
2550
|
+
return srcPipe.pipe(mpCommonDep(tmsConfig, module, ['.wxss', '.less'], isWatch)).on('error', err => {
|
|
2551
|
+
fail$1(`mpCommonDep编译报错${err}`);
|
|
2552
|
+
}) // .pipe(postcss([base64()]))
|
|
2553
|
+
// .on('error', (err) => {
|
|
2554
|
+
// fail(`postcss编译报错${err}`);
|
|
2555
|
+
// })
|
|
2556
|
+
// .pipe(px2rpx({
|
|
2557
|
+
// designWidth: 375, // 设计稿宽度,默认为750
|
|
2558
|
+
// precision: 2, // 小数最大精度,默认为6
|
|
2559
|
+
// }))
|
|
2560
|
+
.pipe(dest(destPath));
|
|
2561
|
+
}
|
|
2562
|
+
});
|
|
2577
2563
|
break;
|
|
2578
2564
|
|
|
2579
2565
|
case 'json':
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2566
|
+
compileTasksMap.set(globValue, {
|
|
2567
|
+
module,
|
|
2568
|
+
taskFn: () => {
|
|
2569
|
+
// const srcTask = () => src(globValue, { ...srcOption, since: since(srcTask) });
|
|
2570
|
+
// const srcPipe = srcTask();
|
|
2571
|
+
const srcPipe = src$1(globValue, { ...srcOption
|
|
2572
|
+
});
|
|
2573
|
+
return srcPipe.pipe(mpJsonDep(tmsConfig, module, ['.json'], ['.wxml', '.json', '.js', '.ts', '.wxss', '.less'], isWatch)).on('error', err => {
|
|
2574
|
+
fail$1(`mpJsonDep编译报错${err}`);
|
|
2575
|
+
}).pipe(dest(destPath));
|
|
2576
|
+
}
|
|
2577
|
+
});
|
|
2583
2578
|
break;
|
|
2584
2579
|
|
|
2585
2580
|
case 'wxml':
|
|
2586
|
-
|
|
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(mpWxmlDep(tmsConfig, module, isWatch)).pipe(dest(destPath));
|
|
2589
|
+
}
|
|
2590
|
+
});
|
|
2587
2591
|
break;
|
|
2588
2592
|
|
|
2589
2593
|
case 'image':
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2594
|
+
compileTasksMap.set(globValue, {
|
|
2595
|
+
module,
|
|
2596
|
+
taskFn: () => {
|
|
2597
|
+
// const srcTask = () => src(globValue, { ...srcOption, since: since(srcTask) });
|
|
2598
|
+
// const srcPipe = srcTask();
|
|
2599
|
+
const srcPipe = src$1(globValue, { ...srcOption
|
|
2600
|
+
});
|
|
2601
|
+
return srcPipe // .pipe(cache(image()))
|
|
2602
|
+
// .on('error', (err) => {
|
|
2603
|
+
// fail(`image编译报错${err}`);
|
|
2604
|
+
// })
|
|
2605
|
+
.pipe(dest(destPath));
|
|
2606
|
+
}
|
|
2607
|
+
});
|
|
2595
2608
|
break;
|
|
2596
2609
|
|
|
2597
2610
|
case 'other':
|
|
2598
|
-
|
|
2611
|
+
compileTasksMap.set(globValue, {
|
|
2612
|
+
module,
|
|
2613
|
+
taskFn: () => {
|
|
2614
|
+
// const srcTask = () => src(globValue, { ...srcOption, since: since(srcTask) });
|
|
2615
|
+
// const srcPipe = srcTask();
|
|
2616
|
+
const srcPipe = src$1(globValue, { ...srcOption
|
|
2617
|
+
});
|
|
2618
|
+
return srcPipe.pipe(dest(destPath));
|
|
2619
|
+
}
|
|
2620
|
+
});
|
|
2599
2621
|
break;
|
|
2600
2622
|
}
|
|
2601
2623
|
});
|
|
2624
|
+
return compileTasksMap;
|
|
2625
|
+
};
|
|
2626
|
+
|
|
2627
|
+
const watch = require$$0__default$b;
|
|
2628
|
+
const path$1 = require$$1__default$2;
|
|
2629
|
+
const shellJs = require$$0__default$3;
|
|
2630
|
+
const {
|
|
2631
|
+
info: info$3
|
|
2632
|
+
} = log$1;
|
|
2633
|
+
const {
|
|
2634
|
+
resolve: resolve$4
|
|
2635
|
+
} = widgets;
|
|
2636
|
+
const {
|
|
2637
|
+
global: global$2
|
|
2638
|
+
} = global_1;
|
|
2639
|
+
|
|
2640
|
+
var watch_1 = function (glob, watchOptions, callback, module) {
|
|
2641
|
+
watch(glob, {
|
|
2642
|
+
readDelay: 100,
|
|
2643
|
+
...watchOptions
|
|
2644
|
+
}, vinyl => {
|
|
2645
|
+
const file = vinyl.history[0];
|
|
2646
|
+
const fileDirArr = file.replace(/\\/g, '/').split('/');
|
|
2647
|
+
const fileName = fileDirArr.slice(fileDirArr.length - 2).join('/');
|
|
2648
|
+
|
|
2649
|
+
if (vinyl.event === 'unlink' || vinyl.event === 'unlinkDir') {
|
|
2650
|
+
const tmsConfig = global$2.getData('tmsConfig');
|
|
2651
|
+
const anaFileRelativeModule = path$1.relative(resolve$4(module.from), file);
|
|
2652
|
+
const anaFileDestFile = resolve$4(tmsConfig.outputDir, module.to, anaFileRelativeModule);
|
|
2653
|
+
info$3(`删除${fileName}`);
|
|
2654
|
+
shellJs.rm('-rf', anaFileDestFile);
|
|
2655
|
+
return;
|
|
2656
|
+
}
|
|
2657
|
+
|
|
2658
|
+
info$3(`更新${fileName}`);
|
|
2659
|
+
return callback(vinyl);
|
|
2660
|
+
});
|
|
2602
2661
|
};
|
|
2603
2662
|
|
|
2604
2663
|
(function (module) {
|
|
2605
|
-
const path = require$$
|
|
2664
|
+
const path = require$$1__default$2;
|
|
2606
2665
|
const fs = require$$0__default$2;
|
|
2607
|
-
const
|
|
2666
|
+
const ora = require$$2__default;
|
|
2608
2667
|
const {
|
|
2609
|
-
|
|
2668
|
+
parallel,
|
|
2669
|
+
series
|
|
2670
|
+
} = require$$0__default$a;
|
|
2671
|
+
const {
|
|
2672
|
+
resolve,
|
|
2673
|
+
mergeMap
|
|
2610
2674
|
} = widgets;
|
|
2611
2675
|
const {
|
|
2612
2676
|
buildOutputAppJson
|
|
@@ -2615,6 +2679,11 @@ var compile = function (tmsConfig, {
|
|
|
2615
2679
|
DEFAULT_COPY_CONFIG
|
|
2616
2680
|
} = require$$4;
|
|
2617
2681
|
const compile$1 = compile;
|
|
2682
|
+
const watch = watch_1;
|
|
2683
|
+
const {
|
|
2684
|
+
info
|
|
2685
|
+
} = log$1;
|
|
2686
|
+
const watchEvents = ['add', 'change', 'unlink', 'unlinkDir'];
|
|
2618
2687
|
|
|
2619
2688
|
function excludeGlob(glob) {
|
|
2620
2689
|
const otherArr = new Set();
|
|
@@ -2645,20 +2714,19 @@ var compile = function (tmsConfig, {
|
|
|
2645
2714
|
}
|
|
2646
2715
|
|
|
2647
2716
|
module.exports = async (tmsConfig, newModules, isWatch = true) => {
|
|
2648
|
-
// 监听app.json
|
|
2717
|
+
const compileTasksMap = new Map(); // 监听app.json
|
|
2718
|
+
|
|
2649
2719
|
if (isWatch) {
|
|
2650
|
-
watch(resolve('app.json'), {
|
|
2720
|
+
watch([resolve('app.json')], {
|
|
2651
2721
|
ignoreInitial: false,
|
|
2652
|
-
events:
|
|
2653
|
-
}, () =>
|
|
2654
|
-
buildOutputAppJson(tmsConfig, newModules, isWatch);
|
|
2655
|
-
});
|
|
2722
|
+
events: watchEvents
|
|
2723
|
+
}, () => buildOutputAppJson(tmsConfig, newModules, isWatch));
|
|
2656
2724
|
} else {
|
|
2657
2725
|
buildOutputAppJson(tmsConfig, newModules, isWatch);
|
|
2658
2726
|
} // 监听根目录的文件
|
|
2659
2727
|
|
|
2660
2728
|
|
|
2661
|
-
compile$1(tmsConfig, {
|
|
2729
|
+
mergeMap(compileTasksMap, compile$1(tmsConfig, {
|
|
2662
2730
|
glob: {
|
|
2663
2731
|
json: DEFAULT_COPY_CONFIG.map(item => resolve(item)) // wxss: ['app.less', 'app.wxss'].map(item => resolve(item)),
|
|
2664
2732
|
// js: ['app.js', 'app.ts'].map(item => resolve(item)),
|
|
@@ -2673,7 +2741,7 @@ var compile = function (tmsConfig, {
|
|
|
2673
2741
|
allowEmpty: true
|
|
2674
2742
|
},
|
|
2675
2743
|
isWatch
|
|
2676
|
-
}); // 监听模块的文件
|
|
2744
|
+
})); // 监听模块的文件
|
|
2677
2745
|
|
|
2678
2746
|
for (let module of newModules) {
|
|
2679
2747
|
// 处理默认参数
|
|
@@ -2685,23 +2753,21 @@ var compile = function (tmsConfig, {
|
|
|
2685
2753
|
|
|
2686
2754
|
if (isWatch) {
|
|
2687
2755
|
// 监听模块配置文件
|
|
2688
|
-
watch(`${resolve(module.path)}/**/module.config.json
|
|
2689
|
-
events:
|
|
2690
|
-
}, () =>
|
|
2691
|
-
buildOutputAppJson(tmsConfig, newModules, isWatch);
|
|
2692
|
-
});
|
|
2756
|
+
watch([`${resolve(module.path)}/**/module.config.json`], {
|
|
2757
|
+
events: watchEvents
|
|
2758
|
+
}, () => buildOutputAppJson(tmsConfig, newModules, isWatch));
|
|
2693
2759
|
}
|
|
2694
2760
|
|
|
2695
2761
|
const excludes = module.exclude.map(key => `!${resolve(key)}`);
|
|
2696
2762
|
const modulePath = adaptPath(module.path);
|
|
2697
2763
|
const glob = {
|
|
2698
2764
|
js: [`${modulePath}/**/*.{js,ts,wxs}`, ...excludes],
|
|
2699
|
-
json: [`${modulePath}/**/*.json`, ...excludes],
|
|
2765
|
+
json: [`${modulePath}/**/*.json`, `!${modulePath}/**/module.config.json`, ...excludes],
|
|
2700
2766
|
wxss: [`${modulePath}/**/*.{less,wxss}`, ...excludes],
|
|
2701
2767
|
wxml: [`${modulePath}/**/*.wxml`, ...excludes],
|
|
2702
2768
|
image: [`${modulePath}/**/*.{png,jpg,jpeg,gif,svg}`, ...excludes]
|
|
2703
2769
|
};
|
|
2704
|
-
compile$1(tmsConfig, {
|
|
2770
|
+
mergeMap(compileTasksMap, compile$1(tmsConfig, {
|
|
2705
2771
|
glob: { ...glob,
|
|
2706
2772
|
other: [`${modulePath}/**/*`, ...excludeGlob(glob)]
|
|
2707
2773
|
},
|
|
@@ -2714,7 +2780,7 @@ var compile = function (tmsConfig, {
|
|
|
2714
2780
|
allowEmpty: true
|
|
2715
2781
|
},
|
|
2716
2782
|
isWatch
|
|
2717
|
-
});
|
|
2783
|
+
}));
|
|
2718
2784
|
} // 静态资源目录-拷贝
|
|
2719
2785
|
|
|
2720
2786
|
|
|
@@ -2739,7 +2805,7 @@ var compile = function (tmsConfig, {
|
|
|
2739
2805
|
}
|
|
2740
2806
|
|
|
2741
2807
|
const from = fs.lstatSync(item.from).isFile() ? path.dirname(item.from) : item.from;
|
|
2742
|
-
compile$1(tmsConfig, {
|
|
2808
|
+
mergeMap(compileTasksMap, compile$1(tmsConfig, {
|
|
2743
2809
|
glob,
|
|
2744
2810
|
destPath: item.to,
|
|
2745
2811
|
module: {
|
|
@@ -2750,18 +2816,56 @@ var compile = function (tmsConfig, {
|
|
|
2750
2816
|
allowEmpty: true
|
|
2751
2817
|
},
|
|
2752
2818
|
isWatch
|
|
2819
|
+
}));
|
|
2820
|
+
}
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2823
|
+
let sTime;
|
|
2824
|
+
let eTime;
|
|
2825
|
+
const spinner = ora();
|
|
2826
|
+
|
|
2827
|
+
function end(cb) {
|
|
2828
|
+
if (isWatch) {
|
|
2829
|
+
compileTasksMap.forEach(({
|
|
2830
|
+
taskFn,
|
|
2831
|
+
module
|
|
2832
|
+
}, globValue) => {
|
|
2833
|
+
watch(globValue, {
|
|
2834
|
+
ignoreInitial: true,
|
|
2835
|
+
events: watchEvents
|
|
2836
|
+
}, taskFn, module);
|
|
2753
2837
|
});
|
|
2754
2838
|
}
|
|
2839
|
+
|
|
2840
|
+
eTime = new Date().getTime() - sTime;
|
|
2841
|
+
spinner.succeed(`首次编译完成, 耗时${eTime / 1000}s, 微信开发者工具打开项目即刻预览。`);
|
|
2842
|
+
spinner.stop();
|
|
2843
|
+
cb();
|
|
2755
2844
|
}
|
|
2845
|
+
|
|
2846
|
+
function start(cb) {
|
|
2847
|
+
info('启动编译...');
|
|
2848
|
+
spinner.start();
|
|
2849
|
+
sTime = new Date().getTime();
|
|
2850
|
+
cb();
|
|
2851
|
+
}
|
|
2852
|
+
|
|
2853
|
+
const compileTasks = [];
|
|
2854
|
+
compileTasksMap.forEach(({
|
|
2855
|
+
taskFn
|
|
2856
|
+
}) => {
|
|
2857
|
+
compileTasks.push(taskFn);
|
|
2858
|
+
});
|
|
2859
|
+
series(start, parallel(...compileTasks), end)();
|
|
2756
2860
|
};
|
|
2757
2861
|
})(dev$3);
|
|
2758
2862
|
|
|
2759
2863
|
const fs$1 = require$$0__default$2;
|
|
2760
|
-
const semver$1 = require$$1__default$
|
|
2864
|
+
const semver$1 = require$$1__default$9;
|
|
2761
2865
|
const {
|
|
2762
2866
|
resolve: resolve$3
|
|
2763
2867
|
} = widgets;
|
|
2764
|
-
const path = require$$
|
|
2868
|
+
const path = require$$1__default$2;
|
|
2765
2869
|
const shelljs$2 = require$$0__default$3;
|
|
2766
2870
|
const {
|
|
2767
2871
|
handleError
|
|
@@ -2853,7 +2957,6 @@ const {
|
|
|
2853
2957
|
resolve: resolve$2
|
|
2854
2958
|
} = widgets;
|
|
2855
2959
|
const {
|
|
2856
|
-
MODULE_CONFIG_FILENAME,
|
|
2857
2960
|
MODULE_CODE_DIR
|
|
2858
2961
|
} = require$$4;
|
|
2859
2962
|
const {
|
|
@@ -2866,17 +2969,12 @@ const {
|
|
|
2866
2969
|
fail
|
|
2867
2970
|
} = log$1;
|
|
2868
2971
|
|
|
2869
|
-
function checkModule(targetModules
|
|
2972
|
+
function checkModule(targetModules) {
|
|
2870
2973
|
// 判断\源码\dist\是否存在用户指定的模块
|
|
2871
2974
|
for (const item of targetModules) {
|
|
2872
2975
|
// 此模块没有root字段(原因:没有merge到module.config.json的配置项。第三方模块的代码可能还没有下载)
|
|
2873
2976
|
if (!item.root) {
|
|
2874
2977
|
return true;
|
|
2875
|
-
} // 判断dist目录是否有该模块
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
if (!fs.existsSync(`${contextDir}/${item.root}/${MODULE_CONFIG_FILENAME}`)) {
|
|
2879
|
-
return true;
|
|
2880
2978
|
} // 判断第三方远程模块git地址与branch是否有更新
|
|
2881
2979
|
|
|
2882
2980
|
|
|
@@ -2916,7 +3014,7 @@ function isInit$1(tmsConfig, targetModules, contextDir) {
|
|
|
2916
3014
|
} // 判断模块信息
|
|
2917
3015
|
|
|
2918
3016
|
|
|
2919
|
-
if (checkModule(targetModules
|
|
3017
|
+
if (checkModule(targetModules)) {
|
|
2920
3018
|
return true;
|
|
2921
3019
|
} // 判断package.json的版本是否有新的版本
|
|
2922
3020
|
|
|
@@ -3071,7 +3169,7 @@ async function run(commandName, cmd) {
|
|
|
3071
3169
|
const tmsConfig = readTmsConfig(env); // 处理module参数
|
|
3072
3170
|
|
|
3073
3171
|
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的配置项
|
|
3172
|
+
const modules = checkModules(tmsConfig, [...new Set([...tmsConfig.mainPackages, ...specificModules])], true); // tms.config.js的modules 合并 module.config.json的配置项
|
|
3075
3173
|
|
|
3076
3174
|
let newModules = tmsModulesMergeLocalModuleCfg(modules, tmsConfig.appName); // A分包依赖了B分包的代码, merge B分包进行编译;
|
|
3077
3175
|
|
|
@@ -3080,7 +3178,8 @@ async function run(commandName, cmd) {
|
|
|
3080
3178
|
global.setData({
|
|
3081
3179
|
env,
|
|
3082
3180
|
cmd,
|
|
3083
|
-
tmsPrivateCf
|
|
3181
|
+
tmsPrivateCf,
|
|
3182
|
+
tmsConfig
|
|
3084
3183
|
});
|
|
3085
3184
|
|
|
3086
3185
|
switch (commandName) {
|
|
@@ -3157,7 +3256,7 @@ var entry = [{
|
|
|
3157
3256
|
|
|
3158
3257
|
var require$$7 = {
|
|
3159
3258
|
name: "@tmsfe/tmskit",
|
|
3160
|
-
version: "0.0.
|
|
3259
|
+
version: "0.0.14",
|
|
3161
3260
|
description: "tmskit",
|
|
3162
3261
|
main: "dist/index.cjs",
|
|
3163
3262
|
bin: {
|
|
@@ -3171,7 +3270,10 @@ var require$$7 = {
|
|
|
3171
3270
|
],
|
|
3172
3271
|
scripts: {
|
|
3173
3272
|
dev: "rollup -wc --environment TARGET:tmskit",
|
|
3174
|
-
build: "rollup -c --environment TARGET:tmskit"
|
|
3273
|
+
build: "rollup -c --environment TARGET:tmskit",
|
|
3274
|
+
"pub:patch": "sh build/publish.sh patch",
|
|
3275
|
+
"pub:minor": "sh build/publish.sh minor",
|
|
3276
|
+
"pub:major": "sh build/publish.sh major"
|
|
3175
3277
|
},
|
|
3176
3278
|
author: "tms·web",
|
|
3177
3279
|
license: "ISC",
|
|
@@ -3200,9 +3302,6 @@ var require$$7 = {
|
|
|
3200
3302
|
"fs-extra": "^10.0.1",
|
|
3201
3303
|
"glob-ignore": "^1.0.2",
|
|
3202
3304
|
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
3305
|
"gulp-watch": "^5.0.1",
|
|
3207
3306
|
htmlparser2: "^7.2.0",
|
|
3208
3307
|
inquirer: "^7.3.3",
|
|
@@ -3210,6 +3309,7 @@ var require$$7 = {
|
|
|
3210
3309
|
lodash: "^4.17.21",
|
|
3211
3310
|
metalsmith: "^2.3.0",
|
|
3212
3311
|
"miniprogram-ci": "1.4.13",
|
|
3312
|
+
moment: "^2.29.1",
|
|
3213
3313
|
"object-assign": "^4.0.1",
|
|
3214
3314
|
ora: "^5.1.0",
|
|
3215
3315
|
"plugin-error": "^1.0.0",
|
|
@@ -3229,7 +3329,7 @@ var require$$7 = {
|
|
|
3229
3329
|
}
|
|
3230
3330
|
};
|
|
3231
3331
|
|
|
3232
|
-
const semver = require$$1__default$
|
|
3332
|
+
const semver = require$$1__default$9;
|
|
3233
3333
|
const packageJson = require$$7;
|
|
3234
3334
|
const chalk$1 = require$$0__default;
|
|
3235
3335
|
const {
|
|
@@ -3305,15 +3405,12 @@ function registerCommand(program, commands) {
|
|
|
3305
3405
|
|
|
3306
3406
|
registerCommand(program, commands);
|
|
3307
3407
|
program.on('--help', () => {
|
|
3308
|
-
info();
|
|
3309
3408
|
info(` Run ${chalk.cyan(`${TMS_NAME} <command> --help`)} for detailed usage of given command.`);
|
|
3310
|
-
info();
|
|
3311
3409
|
}); // 捕获未注册的命令
|
|
3312
3410
|
|
|
3313
3411
|
program.arguments('<command>').action(cmd => {
|
|
3314
3412
|
program.outputHelp();
|
|
3315
|
-
info(`
|
|
3316
|
-
info();
|
|
3413
|
+
info(` ${chalk.red(`Unknown command ${chalk.yellow(cmd)}.`)}`);
|
|
3317
3414
|
suggestCommands(cmd);
|
|
3318
3415
|
process.exitCode = 1;
|
|
3319
3416
|
});
|