@tmsfe/tmskit 0.0.15-beta.4 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -5,25 +5,36 @@ var require$$1 = require('moment');
5
5
  var require$$0$1 = require('commander');
6
6
  var require$$1$1 = require('leven');
7
7
  var require$$2 = require('ora');
8
- var require$$3 = require('path');
8
+ var require$$1$2 = require('path');
9
9
  var require$$0$2 = require('fs');
10
10
  var require$$0$3 = require('shelljs');
11
11
  var require$$0$4 = require('async');
12
- var require$$1$2 = require('ejs');
13
- var require$$1$3 = require('inquirer');
12
+ var require$$1$3 = require('ejs');
13
+ var require$$1$4 = require('inquirer');
14
14
  var require$$0$5 = require('metalsmith');
15
15
  var require$$0$6 = require('lodash');
16
- var require$$1$4 = require('crypto');
16
+ var require$$1$5 = require('crypto');
17
17
  var require$$0$7 = require('miniprogram-ci');
18
18
  var require$$5 = require('glob-ignore');
19
- var require$$1$5 = require('fs-extra');
20
- var require$$1$6 = require('semver');
19
+ var require$$1$6 = require('fs-extra');
20
+ var require$$1$7 = require('semver');
21
21
  var require$$0$8 = require('strip-comments');
22
22
  var require$$0$9 = require('through2');
23
- var require$$1$7 = require('precinct');
24
- var require$$1$8 = require('htmlparser2');
23
+ var require$$1$8 = require('precinct');
24
+ var require$$1$9 = require('htmlparser2');
25
25
  var require$$0$a = require('gulp');
26
- var require$$0$b = require('gulp-watch');
26
+ var require$$0$b = require('object-assign');
27
+ var require$$3 = require('fancy-log');
28
+ var require$$4$1 = require('ansi-colors');
29
+ var require$$5$1 = require('chokidar');
30
+ var require$$6 = require('readable-stream');
31
+ var require$$7$1 = require('vinyl-file');
32
+ var require$$8 = require('vinyl');
33
+ var require$$9 = require('anymatch');
34
+ var require$$11 = require('glob-parent');
35
+ var require$$2$1 = require('plugin-error');
36
+ var require$$10 = require('path-is-absolute');
37
+ var require$$12 = require('slash');
27
38
 
28
39
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
29
40
 
@@ -32,25 +43,36 @@ var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
32
43
  var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
33
44
  var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1);
34
45
  var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
35
- var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);
46
+ var require$$1__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$1$2);
36
47
  var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
37
48
  var require$$0__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$0$3);
38
49
  var require$$0__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$0$4);
39
- var require$$1__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$1$2);
40
50
  var require$$1__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$1$3);
51
+ var require$$1__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$1$4);
41
52
  var require$$0__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$0$5);
42
53
  var require$$0__default$6 = /*#__PURE__*/_interopDefaultLegacy(require$$0$6);
43
- var require$$1__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$1$4);
54
+ var require$$1__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$1$5);
44
55
  var require$$0__default$7 = /*#__PURE__*/_interopDefaultLegacy(require$$0$7);
45
56
  var require$$5__default = /*#__PURE__*/_interopDefaultLegacy(require$$5);
46
- var require$$1__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$1$5);
47
57
  var require$$1__default$6 = /*#__PURE__*/_interopDefaultLegacy(require$$1$6);
58
+ var require$$1__default$7 = /*#__PURE__*/_interopDefaultLegacy(require$$1$7);
48
59
  var require$$0__default$8 = /*#__PURE__*/_interopDefaultLegacy(require$$0$8);
49
60
  var require$$0__default$9 = /*#__PURE__*/_interopDefaultLegacy(require$$0$9);
50
- var require$$1__default$7 = /*#__PURE__*/_interopDefaultLegacy(require$$1$7);
51
61
  var require$$1__default$8 = /*#__PURE__*/_interopDefaultLegacy(require$$1$8);
62
+ var require$$1__default$9 = /*#__PURE__*/_interopDefaultLegacy(require$$1$9);
52
63
  var require$$0__default$a = /*#__PURE__*/_interopDefaultLegacy(require$$0$a);
53
64
  var require$$0__default$b = /*#__PURE__*/_interopDefaultLegacy(require$$0$b);
65
+ var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);
66
+ var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4$1);
67
+ var require$$5__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$5$1);
68
+ var require$$6__default = /*#__PURE__*/_interopDefaultLegacy(require$$6);
69
+ var require$$7__default = /*#__PURE__*/_interopDefaultLegacy(require$$7$1);
70
+ var require$$8__default = /*#__PURE__*/_interopDefaultLegacy(require$$8);
71
+ var require$$9__default = /*#__PURE__*/_interopDefaultLegacy(require$$9);
72
+ var require$$11__default = /*#__PURE__*/_interopDefaultLegacy(require$$11);
73
+ var require$$2__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$2$1);
74
+ var require$$10__default = /*#__PURE__*/_interopDefaultLegacy(require$$10);
75
+ var require$$12__default = /*#__PURE__*/_interopDefaultLegacy(require$$12);
54
76
 
55
77
  function getAugmentedNamespace(n) {
56
78
  if (n.__esModule) return n;
@@ -83,7 +105,7 @@ const resetCfg = decodeURIComponent('%1B%5B0m'); // \033[0m转义后的字符按
83
105
  * @returns {undefined} 无
84
106
  */
85
107
 
86
- const fail$8 = (message = '') => {
108
+ const fail$9 = (message = '') => {
87
109
  const redStyleConfig = decodeURIComponent('%1B%5B41%3B30m'); // \033[41;30m转义后的字符按,console时输出红色文字
88
110
 
89
111
  const greenFontStyleConfig = decodeURIComponent('%1B%5B41%3B37m'); // \033[41;30m转义后的字符按,console时输出红底白色文字
@@ -118,7 +140,7 @@ const warn$1 = message => {
118
140
  const info$9 = (...args) => console.log(`${moment().format('YYYY-MM-DD HH:mm:ss')}`, ...args);
119
141
 
120
142
  var log$1 = {
121
- fail: fail$8,
143
+ fail: fail$9,
122
144
  succeed: succeed$1,
123
145
  warn: warn$1,
124
146
  info: info$9
@@ -127,9 +149,9 @@ var log$1 = {
127
149
  const program$1 = require$$0__default$1;
128
150
  const leven = require$$1__default$1;
129
151
  const ora = require$$2__default;
130
- const path$b = require$$3__default;
131
- const fs$c = require$$0__default$2;
132
- const shelljs$6 = require$$0__default$3;
152
+ const path$c = require$$1__default$2;
153
+ const fs$d = require$$0__default$2;
154
+ const shelljs$7 = require$$0__default$3;
133
155
  const {
134
156
  info: info$8
135
157
  } = log$1;
@@ -142,7 +164,7 @@ const shelljsOptions = {
142
164
  const cwd = process.cwd();
143
165
 
144
166
  function resolve$e(...args) {
145
- return path$b.resolve(cwd, ...args);
167
+ return path$c.resolve(cwd, ...args);
146
168
  }
147
169
  /**
148
170
  * 用户输入命令时,进行提示
@@ -198,20 +220,20 @@ function downloadRepoForGit$2(url, dest, branch) {
198
220
  const cwd = process.cwd();
199
221
  return new Promise((resolve, reject) => {
200
222
  // 如果目标目录不存在
201
- if (fs$c.existsSync(dest)) {
202
- shelljs$6.rm('-rf', path$b.join(dest));
223
+ if (fs$d.existsSync(dest)) {
224
+ shelljs$7.rm('-rf', path$c.join(dest));
203
225
  }
204
226
 
205
- shelljs$6.mkdir('-p', dest);
206
- shelljs$6.cd(dest);
207
- shelljs$6.exec(`git clone ${url} ${dest} --branch ${branch} --depth 1`, {
227
+ shelljs$7.mkdir('-p', dest);
228
+ shelljs$7.cd(dest);
229
+ shelljs$7.exec(`git clone ${url} ${dest} --branch ${branch} --depth 1`, {
208
230
  silent: true
209
231
  }, (code, stdout, stderr) => {
210
232
  if (code !== 0) {
211
233
  reject(stderr);
212
234
  }
213
235
 
214
- shelljs$6.cd(cwd);
236
+ shelljs$7.cd(cwd);
215
237
  resolve();
216
238
  });
217
239
  });
@@ -227,16 +249,16 @@ function downloadRepoForGit$2(url, dest, branch) {
227
249
  function pullRepoForGit$1(dest, branch) {
228
250
  const cwd = process.cwd();
229
251
  return new Promise((resolve, reject) => {
230
- shelljs$6.cd(dest);
231
- shelljs$6.exec('git config pull.rebase false', shelljsOptions);
232
- shelljs$6.exec(`git pull origin ${branch}`, {
252
+ shelljs$7.cd(dest);
253
+ shelljs$7.exec('git config pull.rebase false', shelljsOptions);
254
+ shelljs$7.exec(`git pull origin ${branch}`, {
233
255
  silent: true
234
256
  }, (code, stdout, stderr) => {
235
257
  if (code !== 0) {
236
258
  reject(stderr);
237
259
  }
238
260
 
239
- shelljs$6.cd(cwd);
261
+ shelljs$7.cd(cwd);
240
262
  resolve();
241
263
  });
242
264
  });
@@ -250,7 +272,7 @@ function pullRepoForGit$1(dest, branch) {
250
272
 
251
273
  function npmInstall$1(dir) {
252
274
  return new Promise((resolve, reject) => {
253
- shelljs$6.exec('npm install --production --registry http://mirrors.tencent.com/npm/', {
275
+ shelljs$7.exec('npm install --production --registry http://mirrors.tencent.com/npm/', {
254
276
  cwd: dir,
255
277
  silent: true
256
278
  }, (code, stdout, stderr) => {
@@ -312,7 +334,7 @@ const mergeMap = function (obj, src) {
312
334
  };
313
335
 
314
336
  const relativeCwdPath$1 = function (file) {
315
- return path$b.relative(process.cwd(), file);
337
+ return path$c.relative(process.cwd(), file);
316
338
  };
317
339
 
318
340
  var widgets = {
@@ -329,20 +351,20 @@ var widgets = {
329
351
  relativeCwdPath: relativeCwdPath$1
330
352
  };
331
353
 
332
- const path$a = require('path');
354
+ const path$b = require('path');
333
355
 
334
356
  const os = require('os'); // 用户目录
335
357
 
336
358
 
337
359
  const HOME_DIR = os.homedir(); // 所有文件的缓存目录
338
360
 
339
- const CACHE_DIR$2 = path$a.resolve(HOME_DIR, '.tmskit'); // 脚手架模板代码所在目录
361
+ const CACHE_DIR$2 = path$b.resolve(HOME_DIR, '.tmskit'); // 脚手架模板代码所在目录
340
362
 
341
- const TEMPLATE_DIR$1 = path$a.resolve(CACHE_DIR$2, 'template'); // 第三方模块源码存放的临时缓存目录
363
+ const TEMPLATE_DIR$1 = path$b.resolve(CACHE_DIR$2, 'template'); // 第三方模块源码存放的临时缓存目录
342
364
 
343
- const MODULE_CODE_DIR$1 = path$a.resolve(CACHE_DIR$2, 'modules_code'); // 脚手架模板代码的具体路径
365
+ const MODULE_CODE_DIR$1 = path$b.resolve(CACHE_DIR$2, 'modules_code'); // 脚手架模板代码的具体路径
344
366
 
345
- const TEMPLATE_PATH$1 = path$a.resolve(TEMPLATE_DIR$1, 'tools/tms-cli-template'); // 脚手架的名称
367
+ const TEMPLATE_PATH$1 = path$b.resolve(TEMPLATE_DIR$1, 'tools/tms-cli-template'); // 脚手架的名称
346
368
 
347
369
  const TMS_NAME$1 = 'tmskit'; // 脚手架的配置名称
348
370
 
@@ -356,7 +378,7 @@ const DEFAULT_CLOUD_MODULE_DIR = './cloud'; // 模块的配置文件的名称
356
378
  const MODULE_CONFIG_FILENAME$2 = 'module.config.json'; // 默认的webpack entry
357
379
 
358
380
  const DEFAULT_WEBPACK_ENTRY = {
359
- app: path$a.resolve(process.cwd(), 'app')
381
+ app: path$b.resolve(process.cwd(), 'app')
360
382
  }; // 默认从源码拷贝到编译后的配置
361
383
 
362
384
  const DEFAULT_COPY_CONFIG$1 = ['package.json', 'sitemap.json'];
@@ -389,8 +411,8 @@ var constant = /*#__PURE__*/Object.freeze({
389
411
 
390
412
  var require$$4 = /*@__PURE__*/getAugmentedNamespace(constant);
391
413
 
392
- const fs$b = require$$0__default$2;
393
- const path$9 = require$$3__default;
414
+ const fs$c = require$$0__default$2;
415
+ const path$a = require$$1__default$2;
394
416
  const {
395
417
  info: info$7
396
418
  } = log$1;
@@ -403,12 +425,12 @@ const {
403
425
  * @returns
404
426
  */
405
427
 
406
- const isDirEmpty = dirname => fs$b.promises.readdir(dirname).then(files => files.length === 0); // 判断是否是文件
428
+ const isDirEmpty = dirname => fs$c.promises.readdir(dirname).then(files => files.length === 0); // 判断是否是文件
407
429
 
408
430
 
409
431
  const isFile = pathName => {
410
432
  try {
411
- const stat = fs$b.lstatSync(pathName);
433
+ const stat = fs$c.lstatSync(pathName);
412
434
  return stat.isFile();
413
435
  } catch {
414
436
  return false;
@@ -421,8 +443,8 @@ const isFile = pathName => {
421
443
 
422
444
 
423
445
  const ensureDirExist = dirname => {
424
- if (!fs$b.existsSync(dirname)) {
425
- fs$b.mkdirSync(dirname, {
446
+ if (!fs$c.existsSync(dirname)) {
447
+ fs$c.mkdirSync(dirname, {
426
448
  recursive: true
427
449
  });
428
450
  }
@@ -430,20 +452,20 @@ const ensureDirExist = dirname => {
430
452
 
431
453
 
432
454
  const copyFile = function (src, dest) {
433
- if (fs$b.existsSync(dest)) {
434
- fs$b.unlinkSync(dest);
455
+ if (fs$c.existsSync(dest)) {
456
+ fs$c.unlinkSync(dest);
435
457
  }
436
458
 
437
- const dir = path$9.dirname(dest);
459
+ const dir = path$a.dirname(dest);
438
460
  ensureDirExist(dir);
439
- fs$b.copyFileSync(src, dest);
461
+ fs$c.copyFileSync(src, dest);
440
462
  }; // 判断文件内容是否一致,不一致再进行拷贝
441
463
 
442
464
 
443
465
  function diffContentCopyFile$3(originFile, destFile) {
444
- if (fs$b.existsSync(destFile)) {
445
- const depDestContent = fs$b.readFileSync(destFile, 'utf8');
446
- const depOriginContent = fs$b.readFileSync(originFile, 'utf8');
466
+ if (fs$c.existsSync(destFile)) {
467
+ const depDestContent = fs$c.readFileSync(destFile, 'utf8');
468
+ const depOriginContent = fs$c.readFileSync(originFile, 'utf8');
447
469
 
448
470
  if (depDestContent !== depOriginContent) {
449
471
  info$7(`拷贝${relativeCwdPath(originFile)}内容到${relativeCwdPath(destFile)}`);
@@ -461,7 +483,7 @@ function ext$3(filePath, extensions) {
461
483
  let extPath = ''; // try catch需要包裹:用来处理'./lib/timer'没有后缀的情况
462
484
 
463
485
  try {
464
- const stat = fs$b.lstatSync(newFilePath);
486
+ const stat = fs$c.lstatSync(newFilePath);
465
487
 
466
488
  if (stat.isDirectory()) {
467
489
  extPath = newFilePath[newFilePath.length - 1] === '/' ? 'index' : '/index';
@@ -472,7 +494,7 @@ function ext$3(filePath, extensions) {
472
494
  for (const ext of extensions) {
473
495
  const file = newFilePath.endsWith(ext) ? newFilePath : newFilePath + ext;
474
496
 
475
- if (fs$b.existsSync(file)) {
497
+ if (fs$c.existsSync(file)) {
476
498
  return {
477
499
  ext,
478
500
  extPath: extPath + ext,
@@ -490,11 +512,11 @@ function ext$3(filePath, extensions) {
490
512
 
491
513
 
492
514
  const fileInDir$3 = (dir, file) => {
493
- if (!fs$b.existsSync(dir) || !fs$b.existsSync(file)) {
515
+ if (!fs$c.existsSync(dir) || !fs$c.existsSync(file)) {
494
516
  return false;
495
517
  }
496
518
 
497
- const relativePath = path$9.relative(dir, file);
519
+ const relativePath = path$a.relative(dir, file);
498
520
 
499
521
  if (relativePath.startsWith('..')) {
500
522
  return false;
@@ -503,18 +525,41 @@ const fileInDir$3 = (dir, file) => {
503
525
  return true;
504
526
  };
505
527
 
506
- var io$2 = {
528
+ function findAllFilesOfDir$1(dir) {
529
+ const list = [];
530
+
531
+ function listFile(dir) {
532
+ const arr = fs$c.readdirSync(dir);
533
+ arr.forEach(item => {
534
+ const fullPath = path$a.join(dir, item);
535
+ const stats = fs$c.statSync(fullPath);
536
+
537
+ if (stats.isDirectory()) {
538
+ listFile(fullPath);
539
+ } else {
540
+ list.push(fullPath);
541
+ }
542
+ });
543
+ return list;
544
+ }
545
+
546
+ listFile(dir);
547
+ return list;
548
+ }
549
+
550
+ var io$3 = {
507
551
  isDirEmpty,
508
552
  copyFile,
509
553
  diffContentCopyFile: diffContentCopyFile$3,
510
554
  ensureDirExist,
511
555
  ext: ext$3,
512
556
  fileInDir: fileInDir$3,
513
- isFile
557
+ isFile,
558
+ findAllFilesOfDir: findAllFilesOfDir$1
514
559
  };
515
560
 
516
561
  const async = require$$0__default$4;
517
- const ejs = require$$1__default$2;
562
+ const ejs = require$$1__default$3;
518
563
 
519
564
  const render$1 = (files, metalsmith, next) => {
520
565
  const keys = Object.keys(files);
@@ -533,8 +578,8 @@ const render$1 = (files, metalsmith, next) => {
533
578
 
534
579
  var render_1 = render$1;
535
580
 
536
- const fs$a = require$$0__default$2;
537
- const inquirer = require$$1__default$3;
581
+ const fs$b = require$$0__default$2;
582
+ const inquirer = require$$1__default$4;
538
583
  const {
539
584
  resolve: resolve$d
540
585
  } = widgets;
@@ -550,12 +595,12 @@ const {
550
595
  const parseTemplateQuestions = dir => {
551
596
  let prompts = [];
552
597
 
553
- if (!fs$a.existsSync(`${dir}/questions.json`)) {
598
+ if (!fs$b.existsSync(`${dir}/questions.json`)) {
554
599
  return prompts;
555
600
  }
556
601
 
557
602
  try {
558
- const json = JSON.parse(fs$a.readFileSync(`${dir}/questions.json`));
603
+ const json = JSON.parse(fs$b.readFileSync(`${dir}/questions.json`));
559
604
 
560
605
  if (Array.isArray(json) && json.length > 0) {
561
606
  json.forEach((item, index) => {
@@ -630,9 +675,9 @@ const generator$1 = (buildDir, distDir, preMetadata) => new Promise((resolve, re
630
675
 
631
676
  var generator_1 = generator$1;
632
677
 
633
- const path$8 = require$$3__default;
634
- const fs$9 = require$$0__default$2;
635
- const shelljs$5 = require$$0__default$3;
678
+ const path$9 = require$$1__default$2;
679
+ const fs$a = require$$0__default$2;
680
+ const shelljs$6 = require$$0__default$3;
636
681
  const {
637
682
  TEMPLATE_DIR,
638
683
  TEMPLATE_PATH,
@@ -643,9 +688,9 @@ const {
643
688
  createTask: createTask$2,
644
689
  resolve: resolve$c
645
690
  } = widgets;
646
- const io$1 = io$2;
691
+ const io$2 = io$3;
647
692
  const {
648
- fail: fail$7,
693
+ fail: fail$8,
649
694
  succeed,
650
695
  info: info$6
651
696
  } = log$1;
@@ -658,13 +703,13 @@ const generator = generator_1;
658
703
 
659
704
  async function createAppDir(targetDir) {
660
705
  // 如果目录非空或者已经存在,提示用户,做选择
661
- if (fs$9.existsSync(targetDir)) {
662
- if (!(await io$1.isDirEmpty(targetDir))) {
663
- fail$7('该目录名已经存在,换个项目名字吧~');
706
+ if (fs$a.existsSync(targetDir)) {
707
+ if (!(await io$2.isDirEmpty(targetDir))) {
708
+ fail$8('该目录名已经存在,换个项目名字吧~');
664
709
  process.exit(1);
665
710
  }
666
711
  } else {
667
- shelljs$5.mkdir('-p', targetDir);
712
+ shelljs$6.mkdir('-p', targetDir);
668
713
  }
669
714
  }
670
715
  /**
@@ -676,38 +721,38 @@ async function createAppDir(targetDir) {
676
721
 
677
722
  async function create(appName) {
678
723
  const cwd = process.cwd();
679
- const targetDir = path$8.resolve(cwd, appName);
724
+ const targetDir = path$9.resolve(cwd, appName);
680
725
  const appType = 'mp';
681
726
  await createAppDir(targetDir); // 创建缓存目录
682
727
 
683
- io$1.ensureDirExist(TEMPLATE_DIR); // 拉取git模板
728
+ io$2.ensureDirExist(TEMPLATE_DIR); // 拉取git模板
684
729
 
685
730
  await createTask$2(downloadRepoForGit$1, '拉取模板仓库', '拉取模板仓库完成')('https://git.woa.com/tmsfe/tms-frontend.git', TEMPLATE_DIR, 'master'); // 生成模板(1. 询问问题, 2. ejs生成模板 3.生成到目标目录)
686
731
 
687
- generator(path$8.join(TEMPLATE_PATH, appType), targetDir, {
732
+ generator(path$9.join(TEMPLATE_PATH, appType), targetDir, {
688
733
  appName,
689
734
  appType
690
735
  }).then(() => {
691
- shelljs$5.cd(appName);
736
+ shelljs$6.cd(appName);
692
737
 
693
738
  const hooks = require(resolve$c(appName, TEMPLATE_TKIT_DIR, 'hooks.js'));
694
739
 
695
740
  if (hooks.afterCreate) {
696
741
  hooks.afterCreate.forEach(item => {
697
742
  if (typeof item === 'function') {
698
- item.call(null, shelljs$5, {
743
+ item.call(null, shelljs$6, {
699
744
  appName
700
745
  });
701
746
  } else {
702
- shelljs$5.exec(item);
747
+ shelljs$6.exec(item);
703
748
  }
704
749
  });
705
750
  }
706
751
 
707
- shelljs$5.rm('-rf', resolve$c(appName, TEMPLATE_TKIT_DIR));
752
+ shelljs$6.rm('-rf', resolve$c(appName, TEMPLATE_TKIT_DIR));
708
753
  succeed('项目创建完成.');
709
754
  }).catch(err => {
710
- fail$7(err.message);
755
+ fail$8(err.message);
711
756
  info$6('详细的错误信息:', err);
712
757
  });
713
758
  }
@@ -737,7 +782,7 @@ var defaultTmsConfig$1 = {
737
782
  * 用来读取处理tms.config.js与module.config.json字段
738
783
  */
739
784
  const loadash = require$$0__default$6;
740
- const fs$8 = require$$0__default$2;
785
+ const fs$9 = require$$0__default$2;
741
786
  const {
742
787
  TMS_CONFIG_FILENAME,
743
788
  MODULE_CONFIG_FILENAME: MODULE_CONFIG_FILENAME$1,
@@ -750,9 +795,9 @@ const {
750
795
  } = widgets;
751
796
  const defaultTmsConfig = defaultTmsConfig$1;
752
797
  const {
753
- fail: fail$6
798
+ fail: fail$7
754
799
  } = log$1;
755
- const path$7 = require$$3__default;
800
+ const path$8 = require$$1__default$2;
756
801
  /**
757
802
  * 读取tms.config.js
758
803
  * @param env {string} 环境变量
@@ -761,8 +806,8 @@ const path$7 = require$$3__default;
761
806
  const readTmsConfig$1 = function (env) {
762
807
  const tmsConfigPath = resolve$b(TMS_CONFIG_FILENAME);
763
808
 
764
- if (!fs$8.existsSync(tmsConfigPath)) {
765
- fail$6('当前执行目录没有tms.config.js的配置项,请进行配置');
809
+ if (!fs$9.existsSync(tmsConfigPath)) {
810
+ fail$7('当前执行目录没有tms.config.js的配置项,请进行配置');
766
811
  process.exit(1);
767
812
  }
768
813
 
@@ -787,14 +832,14 @@ const convertModules = modules => {
787
832
  if (typeof module === 'string') {
788
833
  // 路径字符串
789
834
  Object.assign(newModule, {
790
- name: path$7.basename(module),
835
+ name: path$8.basename(module),
791
836
  path: module
792
837
  });
793
838
  } else if (typeof module === 'object') {
794
839
  Object.assign(newModule, module);
795
840
 
796
841
  if (module.name === undefined) {
797
- newModule.name = path$7.basename(module.path);
842
+ newModule.name = path$8.basename(module.path);
798
843
  }
799
844
  }
800
845
 
@@ -811,7 +856,7 @@ const readTmsPrivateCf$1 = function () {
811
856
  let tmsPrivateCf = {};
812
857
  const tmsPrivatePath = resolve$b(TMS_PRIVATE_FILENAME);
813
858
 
814
- if (fs$8.existsSync(tmsPrivatePath)) {
859
+ if (fs$9.existsSync(tmsPrivatePath)) {
815
860
  tmsPrivateCf = require(tmsPrivatePath);
816
861
  } // 处理modules字段
817
862
 
@@ -840,7 +885,7 @@ const checkModules$1 = function (tmsConfig, modules, isQuit = false) {
840
885
  });
841
886
 
842
887
  if (targetModules.length === 0) {
843
- fail$6(`你启动的模块无效${modules.join(',')}无效,请检查tms.config.json>modules>${modules.join(',')}
888
+ fail$7(`你启动的模块无效${modules.join(',')}无效,请检查tms.config.json>modules>${modules.join(',')}
844
889
  >name字段与module.config.json的name字段是否一致`);
845
890
  isQuit && process.exit(1);
846
891
  }
@@ -905,8 +950,8 @@ function getModuleConfig$1(modules = [], appName, moduleConfigFilename) {
905
950
  }) => {
906
951
  const moduleConfigPath = resolve$b(path, moduleConfigFilename);
907
952
 
908
- if (fs$8.existsSync(moduleConfigPath)) {
909
- const content = fs$8.readFileSync(moduleConfigPath, 'utf-8');
953
+ if (fs$9.existsSync(moduleConfigPath)) {
954
+ const content = fs$9.readFileSync(moduleConfigPath, 'utf-8');
910
955
  modulesConfig[moduleConfigPath] = adaptMpCgContent(content, appName);
911
956
  }
912
957
  });
@@ -929,10 +974,10 @@ const tmsModulesMergeLocalModuleCfg$3 = (modules, appName) => {
929
974
  }, moduleIndex) => {
930
975
  const moduleConfigPath = resolve$b(relativePath, MODULE_CONFIG_FILENAME$1);
931
976
 
932
- if (fs$8.existsSync(moduleConfigPath)) {
977
+ if (fs$9.existsSync(moduleConfigPath)) {
933
978
  try {
934
979
  let findModule = false;
935
- let moduleConfigContent = fs$8.readFileSync(moduleConfigPath, 'utf-8');
980
+ let moduleConfigContent = fs$9.readFileSync(moduleConfigPath, 'utf-8');
936
981
  moduleConfigContent = adaptMpCgContent(moduleConfigContent, appName);
937
982
  const moduleContentArr = isObject$1(moduleConfigContent) ? [moduleConfigContent] : moduleConfigContent;
938
983
  getValidModules$1(moduleContentArr).forEach(({
@@ -947,11 +992,11 @@ const tmsModulesMergeLocalModuleCfg$3 = (modules, appName) => {
947
992
  });
948
993
 
949
994
  if (!findModule) {
950
- fail$6(`启动模块${moduleName}在${moduleConfigPath}没有找到或pages为空,请检查配置`);
995
+ fail$7(`启动模块${moduleName}在${moduleConfigPath}没有找到或pages为空,请检查配置`);
951
996
  process.exit(1);
952
997
  }
953
998
  } catch (e) {
954
- fail$6(`${moduleConfigPath}配置错误: ${e}`);
999
+ fail$7(`${moduleConfigPath}配置错误: ${e}`);
955
1000
  newModules.push({ ...modules[moduleIndex]
956
1001
  });
957
1002
  }
@@ -1036,7 +1081,7 @@ var global_1 = {
1036
1081
  };
1037
1082
 
1038
1083
  const {
1039
- fail: fail$5
1084
+ fail: fail$6
1040
1085
  } = log$1;
1041
1086
  const {
1042
1087
  global: global$5
@@ -1047,9 +1092,9 @@ function handleError$4(error) {
1047
1092
  const isDev = global$5.getData('isDev');
1048
1093
 
1049
1094
  if (isDev) {
1050
- fail$5(errMsg);
1095
+ fail$6(errMsg);
1051
1096
  } else {
1052
- fail$5(errMsg);
1097
+ fail$6(errMsg);
1053
1098
  process.exit(1);
1054
1099
  }
1055
1100
  }
@@ -1061,7 +1106,7 @@ var handleError_1 = {
1061
1106
  /**
1062
1107
  * 生成编译后的app.json
1063
1108
  */
1064
- const fs$7 = require$$0__default$2;
1109
+ const fs$8 = require$$0__default$2;
1065
1110
  const {
1066
1111
  MODULE_CONFIG_FILENAME,
1067
1112
  MODULE_CONFIG_INVALID_KEY
@@ -1071,7 +1116,7 @@ const {
1071
1116
  getValidModules
1072
1117
  } = tmsMpconfig;
1073
1118
  const {
1074
- fail: fail$4
1119
+ fail: fail$5
1075
1120
  } = log$1;
1076
1121
  const {
1077
1122
  resolve: resolve$a,
@@ -1098,7 +1143,7 @@ function updateMainPackages(appJson, mainPackages = []) {
1098
1143
 
1099
1144
  foundMainPackages.forEach(subpackage => {
1100
1145
  if (!subpackage.pages || !subpackage.pages.length) {
1101
- fail$4(`主包 ${subpackage} 不能没有 pages`);
1146
+ fail$5(`主包 ${subpackage} 不能没有 pages`);
1102
1147
  process.exit(-1);
1103
1148
  }
1104
1149
 
@@ -1124,12 +1169,12 @@ function updateMainPackages(appJson, mainPackages = []) {
1124
1169
 
1125
1170
 
1126
1171
  const getAppJsonContent = sourceAppJsonPath => {
1127
- if (!fs$7.existsSync(sourceAppJsonPath)) {
1128
- fail$4(`当前路径 ${sourceAppJsonPath} 没找到app.json`);
1172
+ if (!fs$8.existsSync(sourceAppJsonPath)) {
1173
+ fail$5(`当前路径 ${sourceAppJsonPath} 没找到app.json`);
1129
1174
  process.exit(1);
1130
1175
  }
1131
1176
 
1132
- const appJson = JSON.parse(fs$7.readFileSync(sourceAppJsonPath), 'utf-8'); // 加入默认值
1177
+ const appJson = JSON.parse(fs$8.readFileSync(sourceAppJsonPath), 'utf-8'); // 加入默认值
1133
1178
 
1134
1179
  appJson.subpackages = [];
1135
1180
  appJson.pages = []; // appJson.plugins = {};
@@ -1199,7 +1244,7 @@ const fixAppJson = appJson => {
1199
1244
  });
1200
1245
 
1201
1246
  if (invalidKeys.length) {
1202
- fail$4(`不支持分包${subp === null || subp === void 0 ? void 0 : subp.name}配置${invalidKeys.join(',')}\n`);
1247
+ fail$5(`不支持分包${subp === null || subp === void 0 ? void 0 : subp.name}配置${invalidKeys.join(',')}\n`);
1203
1248
  } // eslint-disable-next-line
1204
1249
 
1205
1250
 
@@ -1216,7 +1261,7 @@ const fixAppJson = appJson => {
1216
1261
  }).reduce((pre, cur) => pre + cur, '');
1217
1262
 
1218
1263
  if (pluginsErrMsg) {
1219
- fail$4(`plugins配置出现错误:${pluginsErrMsg}`);
1264
+ fail$5(`plugins配置出现错误:${pluginsErrMsg}`);
1220
1265
  } // eslint-disable-next-line
1221
1266
 
1222
1267
 
@@ -1244,7 +1289,7 @@ function buildOutputAppJson$1(tmsConfig, modules) {
1244
1289
  fixAppJson(appJson); // 更新主包,需在subpackages处理完成后执行, pages/
1245
1290
 
1246
1291
  updateMainPackages(appJson, tmsConfig.mainPackages);
1247
- fs$7.writeFileSync(resolve$a(`${tmsConfig.outputDir}/app.json`), JSON.stringify(appJson, null, 2), 'utf8');
1292
+ fs$8.writeFileSync(resolve$a(`${tmsConfig.outputDir}/app.json`), JSON.stringify(appJson, null, 2), 'utf8');
1248
1293
 
1249
1294
  if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.updateAppJson) === 'function') {
1250
1295
  var _tmsConfig$hooks2;
@@ -1266,18 +1311,18 @@ var buildAppJson = {
1266
1311
  * 下载第三方代码
1267
1312
  */
1268
1313
  const MetalSmith = require$$0__default$5;
1269
- const crypto$1 = require$$1__default$4;
1314
+ const crypto$1 = require$$1__default$5;
1270
1315
  const {
1271
1316
  downloadRepoForGit,
1272
1317
  pullRepoForGit,
1273
1318
  resolve: resolve$9
1274
1319
  } = widgets;
1275
1320
  const {
1276
- fail: fail$3,
1321
+ fail: fail$4,
1277
1322
  info: info$5
1278
1323
  } = log$1;
1279
- const fs$6 = require$$0__default$2;
1280
- const shelljs$4 = require$$0__default$3;
1324
+ const fs$7 = require$$0__default$2;
1325
+ const shelljs$5 = require$$0__default$3;
1281
1326
  const {
1282
1327
  handleError: handleError$2
1283
1328
  } = handleError_1;
@@ -1323,7 +1368,7 @@ function moveFile(sourceDir, targetDir, ignore = []) {
1323
1368
  return new Promise((resolve, reject) => {
1324
1369
  MetalSmith(__dirname).ignore(ignore).source(sourceDir).destination(targetDir).build(e => {
1325
1370
  if (e) {
1326
- fail$3(`${sourceDir} moveFile ${targetDir}出现错误: ${e}`);
1371
+ fail$4(`${sourceDir} moveFile ${targetDir}出现错误: ${e}`);
1327
1372
  reject(e);
1328
1373
  }
1329
1374
 
@@ -1376,7 +1421,7 @@ async function cloneModules$1(sourceDir, targetDir, modules) {
1376
1421
  }));
1377
1422
  });
1378
1423
  await Promise.all(arrPromises);
1379
- shelljs$4.cd(cwd);
1424
+ shelljs$5.cd(cwd);
1380
1425
  }
1381
1426
  /**
1382
1427
  * 收集下载模块代码的任务
@@ -1429,8 +1474,8 @@ function collectDownLoadTasksMap(sourceDir, targetDir, modules) {
1429
1474
  targetPath
1430
1475
  },
1431
1476
  fn: async (sourceModulePath, targetPath) => {
1432
- if (fs$6.existsSync(targetPath)) {
1433
- shelljs$4.rm('-rf', `${targetPath}/*`);
1477
+ if (fs$7.existsSync(targetPath)) {
1478
+ shelljs$5.rm('-rf', `${targetPath}/*`);
1434
1479
  }
1435
1480
 
1436
1481
  await moveFile(`${sourceModulePath}`, targetPath, ['node_modules', '.git']);
@@ -1444,7 +1489,7 @@ function collectDownLoadTasksMap(sourceDir, targetDir, modules) {
1444
1489
  } else {
1445
1490
  let promiseTask;
1446
1491
 
1447
- if (fs$6.existsSync(sourcePath) && fs$6.existsSync(`${sourcePath}/.git`)) {
1492
+ if (fs$7.existsSync(sourcePath) && fs$7.existsSync(`${sourcePath}/.git`)) {
1448
1493
  promiseTask = (gitUrl, sourcePath, branch, httpRepoUrl) => {
1449
1494
  info$5(`git pull:${httpRepoUrl}`);
1450
1495
  return pullRepoForGit(sourcePath, branch);
@@ -1492,7 +1537,7 @@ function checkRemoteModGitUrlBranch(sourceDir, moduleInfo) {
1492
1537
  const gitUrl = replaceGitUrlAccount(httpRepoUrl, name);
1493
1538
  const md5Key = md5ByGitUrlBranch(gitUrl, buildGitTag);
1494
1539
 
1495
- if (!fs$6.existsSync(`${sourceDir}/${md5Key}`)) {
1540
+ if (!fs$7.existsSync(`${sourceDir}/${md5Key}`)) {
1496
1541
  return true;
1497
1542
  }
1498
1543
  }
@@ -1506,7 +1551,7 @@ var cloneModules_1 = {
1506
1551
  };
1507
1552
 
1508
1553
  const ci = require$$0__default$7;
1509
- const path$6 = require$$3__default;
1554
+ const path$7 = require$$1__default$2;
1510
1555
  /**
1511
1556
  * 获取小程序ci的Project对象
1512
1557
  * @returns {Object} 小程序ci对象
@@ -1520,7 +1565,7 @@ const getMpCi = ({
1520
1565
  }) => {
1521
1566
  var _cfgJsonContent$packO;
1522
1567
 
1523
- const cfgJsonContent = require(path$6.join(projectPath, 'project.config.json'));
1568
+ const cfgJsonContent = require(path$7.join(projectPath, 'project.config.json'));
1524
1569
 
1525
1570
  const ignores = (cfgJsonContent === null || cfgJsonContent === void 0 ? void 0 : (_cfgJsonContent$packO = cfgJsonContent.packOptions) === null || _cfgJsonContent$packO === void 0 ? void 0 : _cfgJsonContent$packO.ignore.map(({
1526
1571
  value
@@ -1589,10 +1634,10 @@ var mpCi = {
1589
1634
  /**
1590
1635
  * 本文件主要负责项目或者分包依赖的npm的安装
1591
1636
  */
1592
- const fs$5 = require$$0__default$2;
1593
- const fsExtra = require$$1__default$5;
1594
- const crypto = require$$1__default$4;
1595
- const path$5 = require$$3__default;
1637
+ const fs$6 = require$$0__default$2;
1638
+ const fsExtra = require$$1__default$6;
1639
+ const crypto = require$$1__default$5;
1640
+ const path$6 = require$$1__default$2;
1596
1641
  const shell = require$$0__default$3;
1597
1642
  const glob = require$$5__default;
1598
1643
  const log = log$1;
@@ -1624,7 +1669,7 @@ const collectNpmTasksMap = (packageJsonFiles, cacheDir) => {
1624
1669
  const npmTasksMap = new Map();
1625
1670
 
1626
1671
  for (const packageJsonPath of packageJsonFiles) {
1627
- const packageContent = fs$5.readFileSync(packageJsonPath);
1672
+ const packageContent = fs$6.readFileSync(packageJsonPath);
1628
1673
  const packageJson = JSON.parse(packageContent);
1629
1674
  const md5Obj = {
1630
1675
  dependencies: packageJson.dependencies || {}
@@ -1632,14 +1677,14 @@ const collectNpmTasksMap = (packageJsonFiles, cacheDir) => {
1632
1677
 
1633
1678
  if (Object.keys(md5Obj.dependencies).length !== 0) {
1634
1679
  const md5Key = crypto.createHash('md5').update(JSON.stringify(md5Obj)).digest('hex');
1635
- const cacheNMPath = path$5.join(cacheDir, md5Key);
1636
- const cacheNMTarFile = path$5.join(cacheNMPath, 'node_modules.tar.gz'); // 下载后,添加回调函数 (拷贝node_modules.tar.gz到编译目录并解压)
1680
+ const cacheNMPath = path$6.join(cacheDir, md5Key);
1681
+ const cacheNMTarFile = path$6.join(cacheNMPath, 'node_modules.tar.gz'); // 下载后,添加回调函数 (拷贝node_modules.tar.gz到编译目录并解压)
1637
1682
 
1638
1683
  const callback = {
1639
1684
  params: {
1640
1685
  cacheNMPath,
1641
1686
  cacheNMTarFile,
1642
- packageJsonDir: path$5.dirname(packageJsonPath),
1687
+ packageJsonDir: path$6.dirname(packageJsonPath),
1643
1688
  shell
1644
1689
  },
1645
1690
  fn: async (cacheNMPath, cacheNMTarFile, packageJsonDir, shell) => {
@@ -1740,7 +1785,7 @@ const findFilesByFilter = (startPath, filter) => {
1740
1785
 
1741
1786
  const find = (startPath, filter) => {
1742
1787
  // 目录不存在
1743
- if (!fs$5.existsSync(startPath)) {
1788
+ if (!fs$6.existsSync(startPath)) {
1744
1789
  log.fail(`${startPath}目录不存在`);
1745
1790
  process.exit(-1);
1746
1791
  return;
@@ -1753,10 +1798,10 @@ const findFilesByFilter = (startPath, filter) => {
1753
1798
  return;
1754
1799
  }
1755
1800
 
1756
- const files = fs$5.readdirSync(startPath);
1801
+ const files = fs$6.readdirSync(startPath);
1757
1802
  files.forEach(file => {
1758
- const filename = path$5.join(startPath, file);
1759
- const stat = fs$5.lstatSync(filename); // 当前文件是文件夹类型,继续递归
1803
+ const filename = path$6.join(startPath, file);
1804
+ const stat = fs$6.lstatSync(filename); // 当前文件是文件夹类型,继续递归
1760
1805
 
1761
1806
  if (stat.isDirectory()) {
1762
1807
  find(filename, filter);
@@ -1782,7 +1827,7 @@ const findAllPackageJson = (subRoots = [], contextDir) => {
1782
1827
  const packageJsonName = 'package.json'; // 查找文件名
1783
1828
 
1784
1829
  const cwd = contextDir || dirPath;
1785
- const result = [path$5.join(cwd, packageJsonName)]; // 默认填充根目录下的package.json
1830
+ const result = [path$6.join(cwd, packageJsonName)]; // 默认填充根目录下的package.json
1786
1831
 
1787
1832
  subRoots.forEach(subRoot => {
1788
1833
  if (!subRoot.root) {
@@ -1790,7 +1835,7 @@ const findAllPackageJson = (subRoots = [], contextDir) => {
1790
1835
  process.exit(1);
1791
1836
  }
1792
1837
 
1793
- const toppath = path$5.join(cwd, subRoot.root); // 从该目录开始查找package.json文件
1838
+ const toppath = path$6.join(cwd, subRoot.root); // 从该目录开始查找package.json文件
1794
1839
 
1795
1840
  const list = findFilesByFilter(toppath, packageJsonName);
1796
1841
  result.push(...list);
@@ -1806,7 +1851,7 @@ function cloudNpmInstall(contextDir) {
1806
1851
  }
1807
1852
 
1808
1853
  files.forEach(file => {
1809
- const dir = path$5.dirname(file);
1854
+ const dir = path$6.dirname(file);
1810
1855
  shell.cd(dir);
1811
1856
  shell.exec('npx npm install --production --registry http://mirrors.tencent.com/npm/', {
1812
1857
  silent: false
@@ -1823,6 +1868,9 @@ var npm = {
1823
1868
  findAllPackageJson
1824
1869
  };
1825
1870
 
1871
+ const shelljs$4 = require$$0__default$3;
1872
+ const fs$5 = require$$0__default$2;
1873
+ const io$1 = io$3;
1826
1874
  const {
1827
1875
  createTask: createTask$1,
1828
1876
  resolve: resolve$8
@@ -1839,9 +1887,25 @@ const {
1839
1887
  const {
1840
1888
  global: global$3
1841
1889
  } = global_1;
1890
+ const {
1891
+ fail: fail$3
1892
+ } = log$1;
1842
1893
 
1843
1894
  async function install$2(tmsConfig, modules) {
1844
- // 小程序npm install
1895
+ // 拷贝模块的package.json到编译输出目录
1896
+ modules.forEach(item => {
1897
+ const outputModuleDir = resolve$8(`${tmsConfig.outputDir}/${item.root}`);
1898
+
1899
+ if (!fs$5.existsSync(resolve$8(item.path))) {
1900
+ fail$3(`${item.path}模块代码路径不存在, 请检查tms.config.js的${item.name}模块的path`);
1901
+ process.exit(1);
1902
+ }
1903
+
1904
+ io$1.ensureDirExist(outputModuleDir);
1905
+ const modulePackagePath = resolve$8(item.path, 'package.json');
1906
+ if (fs$5.existsSync(modulePackagePath)) shelljs$4.cp('-Rf', modulePackagePath, outputModuleDir);
1907
+ }); // 小程序npm install
1908
+
1845
1909
  await createTask$1(mpNpmInstallAll, '小程序 开始npm install', '小程序npm install 完成')(modules, resolve$8(tmsConfig.outputDir), `${CACHE_DIR$1}/node_modules`);
1846
1910
  const tmsPrivateCf = global$3.getData('tmsPrivateCf'); // 构建miniprogram_npm
1847
1911
 
@@ -1855,11 +1919,11 @@ async function install$2(tmsConfig, modules) {
1855
1919
  var install_1 = install$2;
1856
1920
 
1857
1921
  const fs$4 = require$$0__default$2;
1858
- const semver$1 = require$$1__default$6;
1922
+ const semver$1 = require$$1__default$7;
1859
1923
  const {
1860
1924
  resolve: resolve$7
1861
1925
  } = widgets;
1862
- const path$4 = require$$3__default;
1926
+ const path$5 = require$$1__default$2;
1863
1927
  const shelljs$3 = require$$0__default$3;
1864
1928
  const {
1865
1929
  handleError
@@ -1884,12 +1948,12 @@ const checkDependencies$1 = (modules, cwd, outputDir) => {
1884
1948
  // 1.1根目录的package.json
1885
1949
 
1886
1950
  const packageArr = [{
1887
- srcPackageDir: path$4.join(cwd, packageJsonName),
1951
+ srcPackageDir: path$5.join(cwd, packageJsonName),
1888
1952
  destNpmDir: resolve$7(outputDir, 'node_modules')
1889
1953
  }]; // 1.2模块的package.json
1890
1954
 
1891
1955
  modules.forEach(item => {
1892
- const srcPackageDir = path$4.join(cwd, item.path, 'package.json');
1956
+ const srcPackageDir = path$5.join(cwd, item.path, 'package.json');
1893
1957
 
1894
1958
  if (fs$4.existsSync(srcPackageDir)) {
1895
1959
  packageArr.push({
@@ -1913,13 +1977,13 @@ const checkDependencies$1 = (modules, cwd, outputDir) => {
1913
1977
  const dependenciesKeys = Object.keys(dependencies);
1914
1978
 
1915
1979
  for (const key of dependenciesKeys) {
1916
- const depPath = path$4.join(item.destNpmDir, key);
1980
+ const depPath = path$5.join(item.destNpmDir, key);
1917
1981
 
1918
1982
  if (!fs$4.existsSync(depPath)) {
1919
1983
  return true;
1920
1984
  }
1921
1985
 
1922
- const depPackagePath = path$4.join(depPath, 'package.json');
1986
+ const depPackagePath = path$5.join(depPath, 'package.json');
1923
1987
 
1924
1988
  if (fs$4.existsSync(depPackagePath)) {
1925
1989
  const packageData = require(depPackagePath);
@@ -1948,7 +2012,7 @@ var checkDependencies_1 = {
1948
2012
 
1949
2013
  const shelljs$2 = require$$0__default$3;
1950
2014
  const fs$3 = require$$0__default$2;
1951
- const io = io$2;
2015
+ const io = io$3;
1952
2016
  const {
1953
2017
  resolve: resolve$6,
1954
2018
  createTask
@@ -1983,26 +2047,13 @@ const {
1983
2047
  * @returns
1984
2048
  */
1985
2049
 
1986
- const cpFilesToOutput = function (tmsConfig, targetModules, defaultFiles) {
2050
+ const cpFilesToOutput = function (tmsConfig, defaultFiles) {
1987
2051
  const outputDir = resolve$6(tmsConfig.outputDir);
1988
2052
  io.ensureDirExist(outputDir);
1989
2053
  defaultFiles.forEach(item => {
1990
2054
  if (fs$3.existsSync(resolve$6(item))) {
1991
2055
  shelljs$2.cp('-rf', resolve$6(item), resolve$6(tmsConfig.outputDir, item));
1992
2056
  }
1993
- }); // 拷贝模块的package.json到编译输出目录
1994
-
1995
- targetModules.forEach(item => {
1996
- const outputModuleDir = resolve$6(`${tmsConfig.outputDir}/${item.root}`);
1997
-
1998
- if (!fs$3.existsSync(resolve$6(item.path))) {
1999
- fail$2(`${item.path}模块代码路径不存在, 请检查tms.config.js的${item.name}模块的path`);
2000
- process.exit(1);
2001
- }
2002
-
2003
- io.ensureDirExist(outputModuleDir);
2004
- const modulePackagePath = resolve$6(item.path, 'package.json');
2005
- if (fs$3.existsSync(modulePackagePath)) shelljs$2.cp('-Rf', modulePackagePath, outputModuleDir);
2006
2057
  });
2007
2058
  };
2008
2059
  /**
@@ -2036,7 +2087,7 @@ async function task(tmsConfig, targetModules) {
2036
2087
  newModules = subModulesMergeDepModules$1(tmsConfig, newModules);
2037
2088
  checkConfig(newModules); // 拷贝相关配置文件到输出目录
2038
2089
 
2039
- await createTask(cpFilesToOutput, '开始拷贝文件到编译输出目录', '拷贝文件到编译输出目录完成')(tmsConfig, newModules, DEFAULT_COPY_CONFIG); // install
2090
+ await createTask(cpFilesToOutput, '开始拷贝文件到编译输出目录', '拷贝文件到编译输出目录完成')(tmsConfig, DEFAULT_COPY_CONFIG); // install
2040
2091
 
2041
2092
  if (checkDependencies(newModules, resolve$6('./'), tmsConfig.outputDir)) {
2042
2093
  await install$1(tmsConfig, newModules);
@@ -2121,8 +2172,8 @@ var pluginError_1 = {
2121
2172
 
2122
2173
  /* eslint-disable no-param-reassign */
2123
2174
  const through$2 = require$$0__default$9;
2124
- const precinct = require$$1__default$7;
2125
- const path$3 = require$$3__default;
2175
+ const precinct = require$$1__default$8;
2176
+ const path$4 = require$$1__default$2;
2126
2177
  const {
2127
2178
  findCssImports
2128
2179
  } = findCssImport;
@@ -2130,7 +2181,7 @@ const {
2130
2181
  ext: ext$2,
2131
2182
  fileInDir: fileInDir$2,
2132
2183
  diffContentCopyFile: diffContentCopyFile$2
2133
- } = io$2;
2184
+ } = io$3;
2134
2185
  const {
2135
2186
  resolve: resolve$5
2136
2187
  } = widgets;
@@ -2152,11 +2203,11 @@ const dfsFindCommonDep$2 = function (anaFileOriginFile, anaFileDestFile, extensi
2152
2203
  pluginError$2(e, isWatch);
2153
2204
  }
2154
2205
 
2155
- const deps = cssFilter.indexOf(path$3.extname(anaFileOriginFile)) > -1 ? findCssImports(contents) : precinct(contents);
2206
+ const deps = cssFilter.indexOf(path$4.extname(anaFileOriginFile)) > -1 ? findCssImports(contents) : precinct(contents);
2156
2207
  deps.forEach(depItem => {
2157
2208
  if (depItem.startsWith('.')) {
2158
2209
  // 被依赖文件的存在的绝对路径
2159
- const depOriginPath = path$3.join(path$3.dirname(anaFileOriginFile), depItem); // 被依赖文件加上后缀
2210
+ const depOriginPath = path$4.join(path$4.dirname(anaFileOriginFile), depItem); // 被依赖文件加上后缀
2160
2211
 
2161
2212
  const {
2162
2213
  ext: extAlias,
@@ -2169,7 +2220,7 @@ const dfsFindCommonDep$2 = function (anaFileOriginFile, anaFileDestFile, extensi
2169
2220
  return;
2170
2221
  }
2171
2222
 
2172
- const depDestPath = resolve$5(path$3.dirname(anaFileDestFile), depItem);
2223
+ const depDestPath = resolve$5(path$4.dirname(anaFileDestFile), depItem);
2173
2224
  const depDestFile = depDestPath.endsWith(extAlias) ? depDestPath : depDestPath + extPath;
2174
2225
 
2175
2226
  if (!resDep.has(depDestFile)) {
@@ -2193,19 +2244,19 @@ function mpCommonDep$1(tmsConfig, module, extensions = [], isWatch = true) {
2193
2244
  const stream = through$2.obj(function (file, enc, cb) {
2194
2245
  // 依赖分析的文件
2195
2246
  const anaFileOriginFile = file.history[0];
2196
- const anaFileRelativeModule = path$3.relative(resolve$5(module.from), anaFileOriginFile);
2247
+ const anaFileRelativeModule = path$4.relative(resolve$5(module.from), anaFileOriginFile);
2197
2248
  const anaFileDestFile = resolve$5(tmsConfig.outputDir, module.to, anaFileRelativeModule);
2198
2249
 
2199
2250
  if (file.isBuffer()) {
2200
2251
  let contents = String(file.contents);
2201
- const deps = cssFilter.indexOf(path$3.extname(file.path)) > -1 ? findCssImports(contents) : precinct(contents);
2252
+ const deps = cssFilter.indexOf(path$4.extname(file.path)) > -1 ? findCssImports(contents) : precinct(contents);
2202
2253
  const copyModules = new Map();
2203
2254
  Object.keys(tmsConfig.dependencies).forEach(includeName => {
2204
2255
  const includePath = tmsConfig.dependencies[includeName];
2205
2256
  deps.forEach(depItem => {
2206
2257
  if (depItem.indexOf(includeName) > -1) {
2207
2258
  // 被依赖文件的存在的绝对路径 (eg: /User/thirdparty/loadsh)
2208
- const depOriginPath = path$3.join(path$3.dirname(anaFileOriginFile), depItem); // 被依赖文件加上后缀
2259
+ const depOriginPath = path$4.join(path$4.dirname(anaFileOriginFile), depItem); // 被依赖文件加上后缀
2209
2260
 
2210
2261
  const {
2211
2262
  ext: extAlias,
@@ -2231,7 +2282,7 @@ function mpCommonDep$1(tmsConfig, module, extensions = [], isWatch = true) {
2231
2282
  depOriginFile,
2232
2283
  depDestFile,
2233
2284
  beforeDepPath: depItem,
2234
- afterDepPath: path$3.relative(path$3.dirname(anaFileDestFile), depDestPath).replace(/\\/g, '/')
2285
+ afterDepPath: path$4.relative(path$4.dirname(anaFileDestFile), depDestPath).replace(/\\/g, '/')
2235
2286
  });
2236
2287
  }
2237
2288
  }
@@ -2269,12 +2320,12 @@ var mpCommonDep_1 = {
2269
2320
 
2270
2321
  /* eslint-disable no-param-reassign */
2271
2322
  const through$1 = require$$0__default$9;
2272
- const path$2 = require$$3__default;
2323
+ const path$3 = require$$1__default$2;
2273
2324
  const {
2274
2325
  ext: ext$1,
2275
2326
  fileInDir: fileInDir$1,
2276
2327
  diffContentCopyFile: diffContentCopyFile$1
2277
- } = io$2;
2328
+ } = io$3;
2278
2329
  const {
2279
2330
  resolve: resolve$4
2280
2331
  } = widgets;
@@ -2290,7 +2341,7 @@ function mpJsonDep$1(tmsConfig, module, extensions = ['.json'], filesExt = ['.wx
2290
2341
  const stream = through$1.obj(function (file, enc, cb) {
2291
2342
  // 当前分析的文件的路径
2292
2343
  const anaFileOriginFile = file.history[0];
2293
- const anaFileRelativeModule = path$2.relative(resolve$4(module.from), anaFileOriginFile);
2344
+ const anaFileRelativeModule = path$3.relative(resolve$4(module.from), anaFileOriginFile);
2294
2345
  const anaFileDestFile = resolve$4(tmsConfig.outputDir, module.to, anaFileRelativeModule);
2295
2346
 
2296
2347
  if (file.isBuffer()) {
@@ -2311,7 +2362,7 @@ function mpJsonDep$1(tmsConfig, module, extensions = ['.json'], filesExt = ['.wx
2311
2362
  const componentPath = contents.usingComponents[componentKey];
2312
2363
 
2313
2364
  if (componentPath.indexOf(includeName) > -1) {
2314
- const depOriginPath = path$2.join(path$2.dirname(anaFileOriginFile), componentPath); // 被依赖文件加上后缀
2365
+ const depOriginPath = path$3.join(path$3.dirname(anaFileOriginFile), componentPath); // 被依赖文件加上后缀
2315
2366
 
2316
2367
  const {
2317
2368
  ext: extAlias,
@@ -2339,7 +2390,7 @@ function mpJsonDep$1(tmsConfig, module, extensions = ['.json'], filesExt = ['.wx
2339
2390
  depOriginExt: extAlias,
2340
2391
  depDestFile,
2341
2392
  beforeDepPath: componentPath,
2342
- afterDepPath: path$2.relative(path$2.dirname(anaFileDestFile), depDestPath).replace(/\\/g, '/')
2393
+ afterDepPath: path$3.relative(path$3.dirname(anaFileDestFile), depDestPath).replace(/\\/g, '/')
2343
2394
  });
2344
2395
  }
2345
2396
  }
@@ -2397,14 +2448,14 @@ var mpJsonDep_1 = {
2397
2448
 
2398
2449
  /* eslint-disable no-param-reassign */
2399
2450
  const through = require$$0__default$9;
2400
- const htmlparser2 = require$$1__default$8;
2451
+ const htmlparser2 = require$$1__default$9;
2401
2452
  const fs = require$$0__default$2;
2402
- const path$1 = require$$3__default;
2453
+ const path$2 = require$$1__default$2;
2403
2454
  const {
2404
2455
  diffContentCopyFile,
2405
2456
  ext,
2406
2457
  fileInDir
2407
- } = io$2;
2458
+ } = io$3;
2408
2459
  const {
2409
2460
  resolve: resolve$3
2410
2461
  } = widgets;
@@ -2455,7 +2506,7 @@ const dfsFindWxmlDep = function (anaFileOriginFile, anaFileDestFile, isWatch = t
2455
2506
  var _attributes$src;
2456
2507
 
2457
2508
  if (attributes !== null && attributes !== void 0 && (_attributes$src = attributes.src) !== null && _attributes$src !== void 0 && _attributes$src.startsWith('.')) {
2458
- const depOriginPath = path$1.join(path$1.dirname(anaFileOriginFile), attributes.src); // 被依赖文件加上后缀
2509
+ const depOriginPath = path$2.join(path$2.dirname(anaFileOriginFile), attributes.src); // 被依赖文件加上后缀
2459
2510
 
2460
2511
  const {
2461
2512
  ext,
@@ -2468,7 +2519,7 @@ const dfsFindWxmlDep = function (anaFileOriginFile, anaFileDestFile, isWatch = t
2468
2519
  return;
2469
2520
  }
2470
2521
 
2471
- const depDestPath = path$1.join(path$1.dirname(anaFileDestFile), attributes.src);
2522
+ const depDestPath = path$2.join(path$2.dirname(anaFileDestFile), attributes.src);
2472
2523
  const depDestFile = depDestPath.endsWith(ext) ? depDestPath : depDestPath + extPath; // 收集wxml依赖
2473
2524
 
2474
2525
  if (['import', 'include'].indexOf(name) > -1) {
@@ -2520,7 +2571,7 @@ function mpWxmlDep$1(tmsConfig, module, isWatch) {
2520
2571
  const stream = through.obj(function (file, enc, cb) {
2521
2572
  // 依赖分析的文件
2522
2573
  const anaFileOriginFile = file.history[0];
2523
- const anaFileRelativeModule = path$1.relative(resolve$3(module.from), anaFileOriginFile);
2574
+ const anaFileRelativeModule = path$2.relative(resolve$3(module.from), anaFileOriginFile);
2524
2575
  const anaFileDestFile = resolve$3(tmsConfig.outputDir, module.to, anaFileRelativeModule);
2525
2576
 
2526
2577
  if (file.isBuffer()) {
@@ -2531,7 +2582,7 @@ function mpWxmlDep$1(tmsConfig, module, isWatch) {
2531
2582
  const nameFilter = ['import', 'include', 'wxs'];
2532
2583
 
2533
2584
  if (nameFilter.indexOf(name) > -1 && attributes.src) {
2534
- const depOriginPath = path$1.join(path$1.dirname(anaFileOriginFile), attributes.src); // 处理后缀(源码引入依赖时,后缀不全的情况)
2585
+ const depOriginPath = path$2.join(path$2.dirname(anaFileOriginFile), attributes.src); // 处理后缀(源码引入依赖时,后缀不全的情况)
2535
2586
 
2536
2587
  const {
2537
2588
  ext,
@@ -2560,7 +2611,7 @@ function mpWxmlDep$1(tmsConfig, module, isWatch) {
2560
2611
  depOriginFile,
2561
2612
  depDestFile,
2562
2613
  beforeDepPath: attributes.src,
2563
- afterDepPath: path$1.relative(path$1.dirname(anaFileDestFile), depDestFile).replace(/\\/g, '/')
2614
+ afterDepPath: path$2.relative(path$2.dirname(anaFileDestFile), depDestFile).replace(/\\/g, '/')
2564
2615
  });
2565
2616
  }
2566
2617
  }
@@ -2767,8 +2818,183 @@ var compile = function (tmsConfig, {
2767
2818
  return compileTasksMap;
2768
2819
  };
2769
2820
 
2770
- const watch = require$$0__default$b;
2771
- const path = require$$3__default;
2821
+ /* eslint-disable */
2822
+ // 该文件源于npm包 gulp-watch 但内部有bug, 故源码进行单独修改
2823
+
2824
+ const assign = require$$0__default$b;
2825
+ const path$1 = require$$1__default$2;
2826
+ const PluginError = require$$2__default$1;
2827
+ const fancyLog = require$$3__default;
2828
+ const colors = require$$4__default;
2829
+ const chokidar = require$$5__default$1;
2830
+ const {
2831
+ Duplex
2832
+ } = require$$6__default;
2833
+ const vinyl = require$$7__default;
2834
+ const File = require$$8__default;
2835
+ const anymatch = require$$9__default;
2836
+ const pathIsAbsolute = require$$10__default;
2837
+ const globParent = require$$11__default;
2838
+ const slash = require$$12__default;
2839
+
2840
+ function normalizeGlobs(globs) {
2841
+ if (!globs) {
2842
+ throw new PluginError('gulp-watch', 'glob argument required');
2843
+ }
2844
+
2845
+ if (typeof globs === 'string') {
2846
+ globs = [globs];
2847
+ }
2848
+
2849
+ if (!Array.isArray(globs)) {
2850
+ throw new PluginError('gulp-watch', `glob should be String or Array, not ${typeof globs}`);
2851
+ }
2852
+
2853
+ return globs;
2854
+ }
2855
+
2856
+ function watch$1(globs, opts, cb) {
2857
+ globs = normalizeGlobs(globs);
2858
+
2859
+ if (typeof opts === 'function') {
2860
+ cb = opts;
2861
+ opts = {};
2862
+ }
2863
+
2864
+ opts = assign({}, watch$1._defaultOptions, opts);
2865
+
2866
+ cb = cb || function () {};
2867
+
2868
+ function resolveFilepath(filepath) {
2869
+ if (pathIsAbsolute(filepath)) {
2870
+ return path$1.normalize(filepath);
2871
+ }
2872
+
2873
+ return path$1.resolve(opts.cwd || process.cwd(), filepath);
2874
+ }
2875
+
2876
+ function resolveGlob(glob) {
2877
+ let mod = '';
2878
+
2879
+ if (glob[0] === '!') {
2880
+ mod = glob[0];
2881
+ glob = glob.slice(1);
2882
+ }
2883
+
2884
+ return mod + slash(resolveFilepath(glob));
2885
+ }
2886
+
2887
+ globs = globs.map(resolveGlob);
2888
+ const baseForced = Boolean(opts.base);
2889
+ const outputStream = new Duplex({
2890
+ objectMode: true,
2891
+ allowHalfOpen: true
2892
+ });
2893
+
2894
+ outputStream._write = function _write(file, enc, done) {
2895
+ cb(file);
2896
+ this.push(file);
2897
+ done();
2898
+ };
2899
+
2900
+ outputStream._read = function _read() {};
2901
+
2902
+ const watcher = chokidar.watch(globs, opts);
2903
+ opts.events.forEach(ev => {
2904
+ watcher.on(ev, processEvent.bind(undefined, ev));
2905
+ });
2906
+ ['add', 'change', 'unlink', 'addDir', 'unlinkDir', 'error', 'ready', 'raw'].forEach(ev => {
2907
+ watcher.on(ev, outputStream.emit.bind(outputStream, ev));
2908
+ });
2909
+
2910
+ outputStream.add = function add(newGlobs) {
2911
+ newGlobs = normalizeGlobs(newGlobs).map(resolveGlob);
2912
+ watcher.add(newGlobs);
2913
+ globs.push.apply(globs, newGlobs);
2914
+ };
2915
+
2916
+ outputStream.unwatch = watcher.unwatch.bind(watcher);
2917
+
2918
+ outputStream.close = function () {
2919
+ watcher.close();
2920
+ this.emit('end');
2921
+ };
2922
+
2923
+ function processEvent(event, filepath) {
2924
+ filepath = resolveFilepath(filepath);
2925
+ const fileOpts = assign({}, opts);
2926
+ let glob;
2927
+ let currentFilepath = filepath;
2928
+
2929
+ while (!(glob = globs[anymatch(globs, currentFilepath, true)]) && currentFilepath !== (currentFilepath = path$1.dirname(currentFilepath))) {} // eslint-disable-line no-empty-blocks/no-empty-blocks
2930
+
2931
+
2932
+ if (!glob) {
2933
+ console.error('[gulp-watch]没有匹配到glob');
2934
+ return;
2935
+ }
2936
+
2937
+ if (!baseForced) {
2938
+ fileOpts.base = path$1.normalize(globParent(glob));
2939
+ } // Do not stat deleted files
2940
+
2941
+
2942
+ if (event === 'unlink' || event === 'unlinkDir' || event === 'addDir') {
2943
+ fileOpts.path = filepath;
2944
+ write(event, null, new File(fileOpts));
2945
+ return;
2946
+ } // Workaround for early read
2947
+
2948
+
2949
+ setTimeout(() => {
2950
+ vinyl.read(filepath, fileOpts).then(file => {
2951
+ write(event, null, file);
2952
+ });
2953
+ }, opts.readDelay);
2954
+ }
2955
+
2956
+ function write(event, err, file) {
2957
+ if (err) {
2958
+ outputStream.emit('error', err);
2959
+ return;
2960
+ }
2961
+
2962
+ if (opts.verbose) {
2963
+ log(event, file);
2964
+ }
2965
+
2966
+ file.event = event;
2967
+ outputStream.push(file);
2968
+ cb(file);
2969
+ }
2970
+
2971
+ function log(event, file) {
2972
+ event = event[event.length - 1] === 'e' ? `${event}d` : `${event}ed`;
2973
+ const msg = [colors.magenta(file.relative), 'was', event];
2974
+
2975
+ if (opts.name) {
2976
+ msg.unshift(`${colors.cyan(opts.name)} saw`);
2977
+ }
2978
+
2979
+ fancyLog.info.apply(null, msg);
2980
+ }
2981
+
2982
+ return outputStream;
2983
+ } // This is not part of the public API as that would lead to global state (singleton) pollution,
2984
+ // and allow unexpected interference between unrelated modules that make use of gulp-watch.
2985
+ // This can be useful for unit tests and root application configuration, though.
2986
+ // Avoid modifying gulp-watch's default options inside a library/reusable package, please.
2987
+
2988
+
2989
+ watch$1._defaultOptions = {
2990
+ events: ['add', 'change', 'unlink'],
2991
+ ignoreInitial: true,
2992
+ readDelay: 10
2993
+ };
2994
+ var gulpWatch = watch$1;
2995
+
2996
+ const watch = gulpWatch;
2997
+ const path = require$$1__default$2;
2772
2998
  const shellJs = require$$0__default$3;
2773
2999
  const {
2774
3000
  info: info$3,
@@ -2780,6 +3006,9 @@ const {
2780
3006
  const {
2781
3007
  global: global$2
2782
3008
  } = global_1;
3009
+ const {
3010
+ findAllFilesOfDir
3011
+ } = io$3;
2783
3012
  const TIP_MAP = {
2784
3013
  'package.json': '若依赖有变动,请重新执行tmskit run dev',
2785
3014
  'module.config.json': '若dependencies字段有变动,需要重新执行tmskit run dev才会生效'
@@ -2797,6 +3026,12 @@ const logTip = (fileName, tipMap) => {
2797
3026
  info$3(`${fileName}有更新`);
2798
3027
  };
2799
3028
 
3029
+ const getTargetFile = (sourceFile, module, outputDir) => {
3030
+ const sourceFileRelativeModule = path.relative(resolve$2(module.from), sourceFile);
3031
+ const targetFile = resolve$2(outputDir, module.to, sourceFileRelativeModule);
3032
+ return targetFile;
3033
+ };
3034
+
2800
3035
  var watch_1 = function (globValue, watchOptions, callback, module) {
2801
3036
  watch(globValue, { // readDelay: 100,
2802
3037
  ...watchOptions
@@ -2805,8 +3040,23 @@ var watch_1 = function (globValue, watchOptions, callback, module) {
2805
3040
  const sourceFileDirArr = sourceFile.replace(/\\/g, '/').split('/');
2806
3041
  const sourceFileName = sourceFileDirArr.slice(sourceFileDirArr.length - 2).join('/');
2807
3042
  const tmsConfig = global$2.getData('tmsConfig');
2808
- const sourceFileRelativeModule = path.relative(resolve$2(module.from), sourceFile);
2809
- const targetFile = resolve$2(tmsConfig.outputDir, module.to, sourceFileRelativeModule);
3043
+
3044
+ if (vinyl.event === 'addDir') {
3045
+ info$3(`更新${sourceFileName}目录`);
3046
+ const files = findAllFilesOfDir(sourceFile);
3047
+
3048
+ for (const file of files) {
3049
+ const fileDirArr = file.replace(/\\/g, '/').split('/');
3050
+ const fileName = fileDirArr.slice(fileDirArr.length - 2).join('/');
3051
+ const targetFile = getTargetFile(file, module, tmsConfig.outputDir);
3052
+ logTip(fileName, TIP_MAP);
3053
+ callback([file], path.dirname(targetFile));
3054
+ }
3055
+
3056
+ return;
3057
+ }
3058
+
3059
+ const targetFile = getTargetFile(sourceFile, module, tmsConfig.outputDir);
2810
3060
 
2811
3061
  if (vinyl.event === 'unlink' || vinyl.event === 'unlinkDir') {
2812
3062
  info$3(`删除${sourceFileName}`);
@@ -2820,7 +3070,7 @@ var watch_1 = function (globValue, watchOptions, callback, module) {
2820
3070
  };
2821
3071
 
2822
3072
  (function (module) {
2823
- const path = require$$3__default;
3073
+ const path = require$$1__default$2;
2824
3074
  const fs = require$$0__default$2;
2825
3075
  const ora = require$$2__default;
2826
3076
  const {
@@ -2842,7 +3092,7 @@ var watch_1 = function (globValue, watchOptions, callback, module) {
2842
3092
  const {
2843
3093
  info
2844
3094
  } = log$1;
2845
- const watchEvents = ['add', 'change', 'unlink', 'unlinkDir'];
3095
+ const watchEvents = ['add', 'change', 'unlink', 'addDir', 'unlinkDir'];
2846
3096
 
2847
3097
  function excludeGlob(glob) {
2848
3098
  const otherArr = new Set();
@@ -2996,7 +3246,7 @@ var watch_1 = function (globValue, watchOptions, callback, module) {
2996
3246
  cb();
2997
3247
  }
2998
3248
 
2999
- function end(cb) {
3249
+ async function end(cb) {
3000
3250
  var _tmsConfig$hooks;
3001
3251
 
3002
3252
  if (isDev) {
@@ -3016,11 +3266,11 @@ var watch_1 = function (globValue, watchOptions, callback, module) {
3016
3266
  if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.afterCompile) === 'function') {
3017
3267
  var _tmsConfig$hooks2;
3018
3268
 
3019
- tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.afterCompile({
3269
+ await (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.afterCompile({
3020
3270
  isDev,
3021
3271
  tmsConfig,
3022
3272
  modules: newModules
3023
- });
3273
+ }));
3024
3274
  }
3025
3275
 
3026
3276
  spinner.succeed(`首次编译完成, 耗时${eTime / 1000}s, 微信开发者工具打开项目即可预览。`);
@@ -3080,7 +3330,7 @@ async function dev$2(tmsConfig, targetModules, env) {
3080
3330
  } = global$1.getData('cmd');
3081
3331
 
3082
3332
  if (noCache) {
3083
- shelljs$1.rm('-rf', resolve$1('dist'));
3333
+ shelljs$1.rm('-rf', resolve$1(tmsConfig.outputDir));
3084
3334
  shelljs$1.rm('-rf', CACHE_DIR);
3085
3335
  } // 初始化操作
3086
3336
 
@@ -3092,11 +3342,11 @@ async function dev$2(tmsConfig, targetModules, env) {
3092
3342
  if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforeCompile) === 'function') {
3093
3343
  var _tmsConfig$hooks2;
3094
3344
 
3095
- tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.beforeCompile({
3345
+ await (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.beforeCompile({
3096
3346
  isDev: true,
3097
3347
  tmsConfig,
3098
3348
  modules: newModules
3099
- });
3349
+ }));
3100
3350
  }
3101
3351
  delOtherModule(tmsConfig, newModules);
3102
3352
  compileDev(tmsConfig, newModules, env);
@@ -3280,13 +3530,14 @@ var entry = [{
3280
3530
 
3281
3531
  var require$$7 = {
3282
3532
  name: "@tmsfe/tmskit",
3283
- version: "0.0.15-beta.4",
3533
+ version: "0.0.16",
3284
3534
  description: "tmskit",
3285
3535
  main: "dist/index.cjs",
3286
3536
  bin: {
3287
3537
  tmskit: "main.js"
3288
3538
  },
3289
3539
  files: [
3540
+ "build",
3290
3541
  "src",
3291
3542
  "dist",
3292
3543
  "main.js",
@@ -3297,8 +3548,7 @@ var require$$7 = {
3297
3548
  build: "rollup -c --environment TARGET:tmskit",
3298
3549
  "pub:patch": "sh build/publish.sh patch",
3299
3550
  "pub:minor": "sh build/publish.sh minor",
3300
- "pub:major": "sh build/publish.sh major",
3301
- postinstall: "cd ./node_modules/gulp-watch && npm install chokidar@3.5.3"
3551
+ "pub:major": "sh build/publish.sh major"
3302
3552
  },
3303
3553
  author: "tms·web",
3304
3554
  license: "ISC",
@@ -3319,8 +3569,18 @@ var require$$7 = {
3319
3569
  "rollup-plugin-typescript2": "0.27.0"
3320
3570
  },
3321
3571
  dependencies: {
3572
+ "ansi-colors": "1.1.0",
3573
+ anymatch: "^1.3.0",
3574
+ "fancy-log": "1.3.2",
3575
+ "glob-parent": "^3.0.1",
3576
+ "path-is-absolute": "^1.0.1",
3577
+ "readable-stream": "^2.2.2",
3578
+ slash: "^1.0.0",
3579
+ vinyl: "^2.1.0",
3580
+ "vinyl-file": "^2.0.0",
3322
3581
  async: "^3.2.2",
3323
3582
  chalk: "^4.1.0",
3583
+ chokidar: "^3.5.3",
3324
3584
  commander: "^8.3.0",
3325
3585
  "copy-webpack-plugin": "^9.1.0",
3326
3586
  ejs: "^3.1.5",
@@ -3337,7 +3597,6 @@ var require$$7 = {
3337
3597
  moment: "^2.29.1",
3338
3598
  "object-assign": "^4.0.1",
3339
3599
  ora: "^5.1.0",
3340
- "patch-package": "^6.4.7",
3341
3600
  "plugin-error": "^1.0.0",
3342
3601
  postcss: "^8.4.6",
3343
3602
  precinct: "^8.3.1",
@@ -3355,7 +3614,7 @@ var require$$7 = {
3355
3614
  }
3356
3615
  };
3357
3616
 
3358
- const semver = require$$1__default$6;
3617
+ const semver = require$$1__default$7;
3359
3618
  const packageJson = require$$7;
3360
3619
  const chalk$1 = require$$0__default;
3361
3620
  const {