@tmsfe/tmskit 0.0.5-beta.0 → 0.0.5-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -16,12 +16,17 @@ var require$$0$5 = require('lodash');
16
16
  var require$$0$6 = require('miniprogram-ci');
17
17
  var require$$3$1 = require('glob-ignore');
18
18
  var require$$0$7 = require('through2');
19
- var require$$1$4 = require('gulp');
20
- var require$$2$1 = require('gulp-px-to-rpx');
21
- var require$$3$2 = require('gulp-less');
22
- var require$$4 = require('gulp-rename');
23
- var require$$5$1 = require('gulp-watch');
24
- var require$$1$5 = require('semver');
19
+ var require$$0$8 = require('strip-comments');
20
+ var require$$1$4 = require('precinct');
21
+ var require$$1$5 = require('htmlparser2');
22
+ var require$$0$9 = require('postcss');
23
+ var require$$0$a = require('gulp');
24
+ var require$$1$6 = require('gulp-px-to-rpx');
25
+ var require$$2$1 = require('gulp-postcss');
26
+ var require$$3$2 = require('gulp-watch');
27
+ var require$$4 = require('gulp-cache');
28
+ var require$$5$1 = require('gulp-image');
29
+ var require$$1$7 = require('semver');
25
30
 
26
31
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
27
32
 
@@ -41,12 +46,17 @@ var require$$0__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$0$5);
41
46
  var require$$0__default$6 = /*#__PURE__*/_interopDefaultLegacy(require$$0$6);
42
47
  var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3$1);
43
48
  var require$$0__default$7 = /*#__PURE__*/_interopDefaultLegacy(require$$0$7);
49
+ var require$$0__default$8 = /*#__PURE__*/_interopDefaultLegacy(require$$0$8);
44
50
  var require$$1__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$1$4);
51
+ var require$$1__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$1$5);
52
+ var require$$0__default$9 = /*#__PURE__*/_interopDefaultLegacy(require$$0$9);
53
+ var require$$0__default$a = /*#__PURE__*/_interopDefaultLegacy(require$$0$a);
54
+ var require$$1__default$6 = /*#__PURE__*/_interopDefaultLegacy(require$$1$6);
45
55
  var require$$2__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$2$1);
46
56
  var require$$3__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$3$2);
47
57
  var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4);
48
58
  var require$$5__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$5$1);
49
- var require$$1__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$1$5);
59
+ var require$$1__default$7 = /*#__PURE__*/_interopDefaultLegacy(require$$1$7);
50
60
 
51
61
  function getAugmentedNamespace(n) {
52
62
  if (n.__esModule) return n;
@@ -63,14 +73,14 @@ function getAugmentedNamespace(n) {
63
73
  return a;
64
74
  }
65
75
 
66
- var src$1 = {};
76
+ var src$2 = {};
67
77
 
68
78
  const program$1 = require$$0__default;
69
79
  const leven = require$$1__default;
70
80
  const ora = require$$2__default;
71
- const path$5 = require$$1__default$1;
72
- const fs$a = require$$0__default$1;
73
- const shelljs$5 = require$$5__default;
81
+ const path$a = require$$1__default$1;
82
+ const fs$e = require$$0__default$1;
83
+ const shelljs$6 = require$$5__default;
74
84
  const download = require$$6__default;
75
85
  const chalk$3 = require$$0__default$2;
76
86
  const shelljsOptons = {
@@ -79,8 +89,8 @@ const shelljsOptons = {
79
89
 
80
90
  const cwd = process.cwd();
81
91
 
82
- function resolve$a(...args) {
83
- return path$5.resolve(cwd, ...args);
92
+ function resolve$d(...args) {
93
+ return path$a.resolve(cwd, ...args);
84
94
  }
85
95
  /**
86
96
  * 封装logs
@@ -149,11 +159,11 @@ function downloadRepo(dest, downloadOptions = {
149
159
  branch
150
160
  } = downloadOptions;
151
161
 
152
- if (fs$a.existsSync(dest)) {
153
- shelljs$5.rm('-rf', dest);
162
+ if (fs$e.existsSync(dest)) {
163
+ shelljs$6.rm('-rf', dest);
154
164
  }
155
165
 
156
- shelljs$5.mkdir('-p', dest);
166
+ shelljs$6.mkdir('-p', dest);
157
167
  return new Promise(resolve => {
158
168
  download(`${repoUrl}#${branch}`, dest, {
159
169
  clone: true
@@ -181,14 +191,14 @@ function downloadRepoForGit$2(url, dest, branch) {
181
191
  const cwd = process.cwd();
182
192
  return new Promise(resolve => {
183
193
  // 如果目标目录不存在
184
- if (fs$a.existsSync(dest)) {
185
- shelljs$5.rm('-rf', path$5.join(dest));
194
+ if (fs$e.existsSync(dest)) {
195
+ shelljs$6.rm('-rf', path$a.join(dest));
186
196
  }
187
197
 
188
- shelljs$5.mkdir('-p', dest);
189
- shelljs$5.cd(dest);
190
- shelljs$5.exec(`git clone ${url} ${dest} --branch ${branch} --depth 1`, shelljsOptons);
191
- shelljs$5.cd(cwd);
198
+ shelljs$6.mkdir('-p', dest);
199
+ shelljs$6.cd(dest);
200
+ shelljs$6.exec(`git clone ${url} ${dest} --branch ${branch} --depth 1`, shelljsOptons);
201
+ shelljs$6.cd(cwd);
192
202
  resolve();
193
203
  });
194
204
  }
@@ -239,7 +249,7 @@ function createTask$4(task, startText, endText) {
239
249
  const camelize = str => str.replace(/-(\w)/g, (a, c) => c ? c.toUpperCase() : '');
240
250
 
241
251
  var widgets = {
242
- resolve: resolve$a,
252
+ resolve: resolve$d,
243
253
  log: log$3,
244
254
  isObject: isObject$2,
245
255
  isArray: isArray$1,
@@ -250,18 +260,18 @@ var widgets = {
250
260
  camelize
251
261
  };
252
262
 
253
- const path$4 = require('path'); // 用户目录
263
+ const path$9 = require('path'); // 用户目录
254
264
 
255
265
 
256
266
  const HOME_DIR = process.env.HOME; // 所有文件的缓存目录
257
267
 
258
- const CACHE_DIR$1 = path$4.resolve(HOME_DIR, '.tmskit'); // 脚手架模板代码所在目录
268
+ const CACHE_DIR$1 = path$9.resolve(HOME_DIR, '.tmskit'); // 脚手架模板代码所在目录
259
269
 
260
- const TEMPLATE_DIR$1 = path$4.resolve(CACHE_DIR$1, 'template'); // 第三方模块源码存放的临时缓存目录
270
+ const TEMPLATE_DIR$1 = path$9.resolve(CACHE_DIR$1, 'template'); // 第三方模块源码存放的临时缓存目录
261
271
 
262
- const MODULE_CODE_DIR$1 = path$4.resolve(CACHE_DIR$1, 'modules_code'); // 脚手架模板代码的具体路径
272
+ const MODULE_CODE_DIR$1 = path$9.resolve(CACHE_DIR$1, 'modules_code'); // 脚手架模板代码的具体路径
263
273
 
264
- const TEMPLATE_PATH$1 = path$4.resolve(TEMPLATE_DIR$1, 'tools/tms-cli-template'); // 脚手架的名称
274
+ const TEMPLATE_PATH$1 = path$9.resolve(TEMPLATE_DIR$1, 'tools/tms-cli-template'); // 脚手架的名称
265
275
 
266
276
  const TMS_NAME$2 = 'tmskit'; // 脚手架的配置名称
267
277
 
@@ -272,7 +282,7 @@ const DEFAULT_MODULE_DIR$4 = 'modules'; // 模块的配置文件的名称
272
282
  const MODULE_CONFIG_FILENAME$2 = 'module.config.json'; // 默认的webpack entry
273
283
 
274
284
  const DEFAULT_WEBPACK_ENTRY = {
275
- app: path$4.resolve(process.cwd(), 'app')
285
+ app: path$9.resolve(process.cwd(), 'app')
276
286
  }; // 默认从源码拷贝到编译后的配置
277
287
 
278
288
  const DEFAULT_COPY_CONFIG$1 = ['package.json', 'sitemap.json']; // 开发模式
@@ -287,6 +297,7 @@ const ENV = {
287
297
  prod: 'production'
288
298
  };
289
299
  const TEMPLATE_TKIT_DIR$2 = '_tmskit';
300
+ const MODULE_CONFIG_INVALID_KEY$1 = ['entranceDeclare', 'entryPagePath'];
290
301
 
291
302
  var constant = /*#__PURE__*/Object.freeze({
292
303
  __proto__: null,
@@ -303,19 +314,31 @@ var constant = /*#__PURE__*/Object.freeze({
303
314
  MODULE_CODE_DIR: MODULE_CODE_DIR$1,
304
315
  MODE: MODE$1,
305
316
  ENV: ENV,
306
- TEMPLATE_TKIT_DIR: TEMPLATE_TKIT_DIR$2
317
+ TEMPLATE_TKIT_DIR: TEMPLATE_TKIT_DIR$2,
318
+ MODULE_CONFIG_INVALID_KEY: MODULE_CONFIG_INVALID_KEY$1
307
319
  });
308
320
 
309
321
  var require$$3 = /*@__PURE__*/getAugmentedNamespace(constant);
310
322
 
311
- const fs$9 = require$$0__default$1;
323
+ const fs$d = require$$0__default$1;
324
+ const path$8 = require$$1__default$1;
312
325
  /**
313
326
  * 判断目录是否为空
314
327
  * @param {string} dirname 目录名
315
328
  * @returns
316
329
  */
317
330
 
318
- const isDirEmpty = dirname => fs$9.promises.readdir(dirname).then(files => files.length === 0);
331
+ const isDirEmpty = dirname => fs$d.promises.readdir(dirname).then(files => files.length === 0); // 判断是否是文件
332
+
333
+
334
+ const isFile = pathName => {
335
+ try {
336
+ const stat = fs$d.lstatSync(pathName);
337
+ return stat.isFile();
338
+ } catch {
339
+ return false;
340
+ }
341
+ };
319
342
  /**
320
343
  * 确保目录存在,不存在就创建一个
321
344
  * @param {*} dirname 目录名
@@ -323,16 +346,96 @@ const isDirEmpty = dirname => fs$9.promises.readdir(dirname).then(files => files
323
346
 
324
347
 
325
348
  const ensureDirExist = dirname => {
326
- if (!fs$9.existsSync(dirname)) {
327
- fs$9.mkdirSync(dirname, {
349
+ if (!fs$d.existsSync(dirname)) {
350
+ fs$d.mkdirSync(dirname, {
328
351
  recursive: true
329
352
  });
330
353
  }
354
+ }; // 复制文件
355
+
356
+
357
+ const copyFile = function (src, dest) {
358
+ if (fs$d.existsSync(dest)) {
359
+ fs$d.unlinkSync(dest);
360
+ }
361
+
362
+ const dir = dest.substr(0, dest.lastIndexOf('/'));
363
+ ensureDirExist(dir);
364
+ fs$d.copyFileSync(src, dest);
365
+ }; // 判断文件内容是否一致,不一致再进行拷贝
366
+
367
+
368
+ function diffContentCopyFile$3(originFile, destFile) {
369
+ if (fs$d.existsSync(destFile)) {
370
+ const depDestContent = fs$d.readFileSync(destFile, 'utf8');
371
+ const depOriginContent = fs$d.readFileSync(originFile, 'utf8');
372
+
373
+ if (depDestContent !== depOriginContent) {
374
+ console.log(`拷贝${originFile}内容到${destFile}`);
375
+ copyFile(originFile, destFile);
376
+ }
377
+ } else {
378
+ console.log(`拷贝${originFile}内容到${destFile}`);
379
+ copyFile(originFile, destFile);
380
+ }
381
+ } // 添加后缀
382
+
383
+
384
+ function ext$3(filePath, extensions) {
385
+ let newFilePath = filePath;
386
+ let extPath = ''; // try catch需要包裹:用来处理'./lib/timer'没有后缀的情况
387
+
388
+ try {
389
+ const stat = fs$d.lstatSync(newFilePath);
390
+
391
+ if (stat.isDirectory()) {
392
+ extPath = newFilePath[newFilePath.length - 1] === '/' ? 'index' : '/index';
393
+ newFilePath += extPath;
394
+ }
395
+ } catch (e) {}
396
+
397
+ for (const ext of extensions) {
398
+ const file = newFilePath.endsWith(ext) ? newFilePath : newFilePath + ext;
399
+
400
+ if (fs$d.existsSync(file)) {
401
+ return {
402
+ ext,
403
+ extPath: extPath + ext,
404
+ file
405
+ };
406
+ }
407
+ }
408
+
409
+ return {
410
+ ext: '',
411
+ extPath,
412
+ file: filePath
413
+ };
414
+ } // 判断文件是否在某个目录
415
+
416
+
417
+ const fileInDir$3 = (dir, file) => {
418
+ if (!fs$d.existsSync(dir) || !fs$d.existsSync(file)) {
419
+ return false;
420
+ }
421
+
422
+ const relativePath = path$8.relative(dir, file);
423
+
424
+ if (relativePath.startsWith('..')) {
425
+ return false;
426
+ }
427
+
428
+ return true;
331
429
  };
332
430
 
333
431
  var io$2 = {
334
432
  isDirEmpty,
335
- ensureDirExist
433
+ copyFile,
434
+ diffContentCopyFile: diffContentCopyFile$3,
435
+ ensureDirExist,
436
+ ext: ext$3,
437
+ fileInDir: fileInDir$3,
438
+ isFile
336
439
  };
337
440
 
338
441
  const chalk$2 = require$$0__default$2;
@@ -348,7 +451,7 @@ const resetCfg = decodeURIComponent('%1B%5B0m'); // \033[0m转义后的字符按
348
451
  * @returns {undefined} 无
349
452
  */
350
453
 
351
- const fail$7 = (message = '') => {
454
+ const fail$a = (message = '') => {
352
455
  const redStyleConfig = decodeURIComponent('%1B%5B41%3B30m'); // \033[41;30m转义后的字符按,console时输出红色文字
353
456
 
354
457
  const greenFontStyleConfig = decodeURIComponent('%1B%5B41%3B37m'); // \033[41;30m转义后的字符按,console时输出红底白色文字
@@ -381,7 +484,7 @@ const warn = message => {
381
484
  };
382
485
 
383
486
  var log$2 = {
384
- fail: fail$7,
487
+ fail: fail$a,
385
488
  succeed: succeed$1,
386
489
  warn
387
490
  };
@@ -406,10 +509,10 @@ const render$1 = (files, metalsmith, next) => {
406
509
 
407
510
  var render_1 = render$1;
408
511
 
409
- const fs$8 = require$$0__default$1;
512
+ const fs$c = require$$0__default$1;
410
513
  const inquirer = require$$1__default$3;
411
514
  const {
412
- resolve: resolve$9
515
+ resolve: resolve$c
413
516
  } = widgets;
414
517
  const {
415
518
  TEMPLATE_TKIT_DIR: TEMPLATE_TKIT_DIR$1
@@ -423,12 +526,12 @@ const {
423
526
  const parseTemplateQuestions = dir => {
424
527
  let prompts = [];
425
528
 
426
- if (!fs$8.existsSync(`${dir}/questions.json`)) {
529
+ if (!fs$c.existsSync(`${dir}/questions.json`)) {
427
530
  return prompts;
428
531
  }
429
532
 
430
533
  try {
431
- const json = JSON.parse(fs$8.readFileSync(`${dir}/questions.json`));
534
+ const json = JSON.parse(fs$c.readFileSync(`${dir}/questions.json`));
432
535
 
433
536
  if (Array.isArray(json) && json.length > 0) {
434
537
  json.forEach((item, index) => {
@@ -461,7 +564,7 @@ const isQuestionType = result => {
461
564
  };
462
565
 
463
566
  const ask$1 = templateDir => (files, metalsmith, next) => {
464
- const prompts = parseTemplateQuestions(resolve$9(templateDir, TEMPLATE_TKIT_DIR$1));
567
+ const prompts = parseTemplateQuestions(resolve$c(templateDir, TEMPLATE_TKIT_DIR$1));
465
568
  const metadata = metalsmith.metadata();
466
569
  const filteredPrompts = prompts.filter(prompt => {
467
570
  if (metadata[prompt.name] && `${metadata[prompt.name]}`.trim() !== '') {
@@ -503,9 +606,9 @@ const generator$1 = (buildDir, distDir, preMetadata) => new Promise((resolve, re
503
606
 
504
607
  var generator_1 = generator$1;
505
608
 
506
- const path$3 = require$$1__default$1;
507
- const fs$7 = require$$0__default$1;
508
- const shelljs$4 = require$$5__default;
609
+ const path$7 = require$$1__default$1;
610
+ const fs$b = require$$0__default$1;
611
+ const shelljs$5 = require$$5__default;
509
612
  const {
510
613
  TEMPLATE_DIR,
511
614
  TEMPLATE_PATH,
@@ -514,11 +617,11 @@ const {
514
617
  const {
515
618
  downloadRepoForGit: downloadRepoForGit$1,
516
619
  createTask: createTask$3,
517
- resolve: resolve$8
620
+ resolve: resolve$b
518
621
  } = widgets;
519
622
  const io$1 = io$2;
520
623
  const {
521
- fail: fail$6,
624
+ fail: fail$9,
522
625
  succeed
523
626
  } = log$2;
524
627
  const generator = generator_1;
@@ -530,13 +633,13 @@ const generator = generator_1;
530
633
 
531
634
  async function createAppDir(targetDir) {
532
635
  // 如果目录非空或者已经存在,提示用户,做选择
533
- if (fs$7.existsSync(targetDir)) {
636
+ if (fs$b.existsSync(targetDir)) {
534
637
  if (!(await io$1.isDirEmpty(targetDir))) {
535
- fail$6('该目录名已经存在,换个项目名字吧~');
638
+ fail$9('该目录名已经存在,换个项目名字吧~');
536
639
  process.exit(1);
537
640
  }
538
641
  } else {
539
- shelljs$4.mkdir('-p', targetDir);
642
+ shelljs$5.mkdir('-p', targetDir);
540
643
  }
541
644
  }
542
645
  /**
@@ -548,7 +651,7 @@ async function createAppDir(targetDir) {
548
651
 
549
652
  async function create(appName) {
550
653
  const cwd = process.cwd();
551
- const targetDir = path$3.resolve(cwd, appName);
654
+ const targetDir = path$7.resolve(cwd, appName);
552
655
  const appType = 'mp';
553
656
  await createAppDir(targetDir); // 创建缓存目录
554
657
 
@@ -556,46 +659,47 @@ async function create(appName) {
556
659
 
557
660
  await createTask$3(downloadRepoForGit$1, '拉取模板仓库', '拉取模板仓库完成')('https://git.woa.com/tmsfe/tms-frontend.git', TEMPLATE_DIR, 'master'); // 生成模板(1. 询问问题, 2. ejs生成模板 3.生成到目标目录)
558
661
 
559
- generator(path$3.join(TEMPLATE_PATH, appType), targetDir, {
662
+ generator(path$7.join(TEMPLATE_PATH, appType), targetDir, {
560
663
  appName,
561
664
  appType
562
665
  }).then(() => {
563
- shelljs$4.cd(appName);
666
+ shelljs$5.cd(appName);
564
667
 
565
- const hooks = require(resolve$8(appName, TEMPLATE_TKIT_DIR, 'hooks.js'));
668
+ const hooks = require(resolve$b(appName, TEMPLATE_TKIT_DIR, 'hooks.js'));
566
669
 
567
670
  if (hooks.afterCreate) {
568
671
  hooks.afterCreate.forEach(item => {
569
672
  if (typeof item === 'function') {
570
- item.call(null, shelljs$4, {
673
+ item.call(null, shelljs$5, {
571
674
  appName
572
675
  });
573
676
  } else {
574
- shelljs$4.exec(item);
677
+ shelljs$5.exec(item);
575
678
  }
576
679
  });
577
680
  }
578
681
 
579
- shelljs$4.rm('-rf', resolve$8(appName, TEMPLATE_TKIT_DIR));
682
+ shelljs$5.rm('-rf', resolve$b(appName, TEMPLATE_TKIT_DIR));
580
683
  succeed('项目创建完成.');
581
684
  }).catch(err => {
582
- fail$6(err.message);
685
+ fail$9(err.message);
583
686
  console.log('详细的错误信息:', err);
584
687
  });
585
688
  }
586
689
 
587
690
  var create_1 = create;
588
691
 
589
- const fs$6 = require$$0__default$1;
692
+ const fs$a = require$$0__default$1;
590
693
  const {
591
694
  DEFAULT_MODULE_DIR: DEFAULT_MODULE_DIR$3,
592
- MODULE_CONFIG_FILENAME: MODULE_CONFIG_FILENAME$1
695
+ MODULE_CONFIG_FILENAME: MODULE_CONFIG_FILENAME$1,
696
+ MODULE_CONFIG_INVALID_KEY
593
697
  } = require$$3;
594
698
  const {
595
- fail: fail$5
699
+ fail: fail$8
596
700
  } = log$2;
597
701
  const {
598
- resolve: resolve$7,
702
+ resolve: resolve$a,
599
703
  isObject: isObject$1,
600
704
  isArray
601
705
  } = widgets;
@@ -644,10 +748,10 @@ function getLocalModuleConfig(modules = [], appName, moduleDir, moduleConfigFile
644
748
  modules.forEach(({
645
749
  path
646
750
  }) => {
647
- const moduleConfigPath = resolve$7(path, moduleConfigFilename);
751
+ const moduleConfigPath = resolve$a(path, moduleConfigFilename);
648
752
 
649
- if (fs$6.existsSync(moduleConfigPath)) {
650
- const content = fs$6.readFileSync(moduleConfigPath, 'utf-8');
753
+ if (fs$a.existsSync(moduleConfigPath)) {
754
+ const content = fs$a.readFileSync(moduleConfigPath, 'utf-8');
651
755
  modulesConfig[moduleConfigPath] = setModuleConfig$1(content, appName, moduleDir);
652
756
  }
653
757
  });
@@ -672,7 +776,7 @@ function updateMainPackages(appJson, mainPackages = []) {
672
776
 
673
777
  foundMainPackages.forEach(subpackage => {
674
778
  if (!subpackage.pages || !subpackage.pages.length) {
675
- fail$5(`主包 ${subpackage} 不能没有 pages`);
779
+ fail$8(`主包 ${subpackage} 不能没有 pages`);
676
780
  process.exit(-1);
677
781
  }
678
782
 
@@ -698,16 +802,16 @@ function updateMainPackages(appJson, mainPackages = []) {
698
802
 
699
803
 
700
804
  const getAppJsonContent = sourceAppJsonPath => {
701
- if (!fs$6.existsSync(sourceAppJsonPath)) {
702
- fail$5(`当前路径 ${sourceAppJsonPath} 没找到app.json`);
805
+ if (!fs$a.existsSync(sourceAppJsonPath)) {
806
+ fail$8(`当前路径 ${sourceAppJsonPath} 没找到app.json`);
703
807
  process.exit(1);
704
808
  }
705
809
 
706
- const appJson = JSON.parse(fs$6.readFileSync(sourceAppJsonPath), 'utf-8'); // 加入默认值
810
+ const appJson = JSON.parse(fs$a.readFileSync(sourceAppJsonPath), 'utf-8'); // 加入默认值
707
811
 
708
812
  appJson.subpackages = [];
709
- appJson.pages = [];
710
- appJson.plugins = {};
813
+ appJson.pages = []; // appJson.plugins = {};
814
+
711
815
  delete appJson.entranceDeclare;
712
816
  return appJson;
713
817
  };
@@ -726,6 +830,68 @@ const updateSubpackages = (appJson, modulesConfig) => {
726
830
  appJson.subpackages = appJson.subpackages.concat(moduleInfo);
727
831
  }
728
832
  };
833
+ /**
834
+ * 处理合并subpackages后的appjson, 整理重复不合法的地方
835
+ * @param {Object} appJson appjson
836
+ */
837
+
838
+
839
+ const processAppJson = appJson => {
840
+ const {
841
+ subpackages
842
+ } = appJson;
843
+ const pluginsMap = {};
844
+ Object.keys(appJson.plugins || {}).forEach(key => pluginsMap[key] = ['app.json']);
845
+ const subps = subpackages.map(subp => {
846
+ const invalidKeys = [];
847
+ Object.keys(subp).forEach(key => {
848
+ if (key === 'plugins') {
849
+ Object.keys(subp.plugins).forEach(pk => {
850
+ pluginsMap[pk] ? pluginsMap[pk].push(`分包${subp.name}`) : pluginsMap[pk] = [`分包${subp.name}`];
851
+ });
852
+ return;
853
+ }
854
+
855
+ if (MODULE_CONFIG_INVALID_KEY.indexOf(key) > -1) {
856
+ // 如果分包配置中有不支持的key,则错误提醒
857
+ invalidKeys.push(key);
858
+ return;
859
+ }
860
+
861
+ if (['requiredBackgroundModes', 'embeddedAppIdList'].indexOf(key) > -1) {
862
+ // 提到appjson最上层处理
863
+ const preVal = appJson[key]; // eslint-disable-next-line
864
+
865
+ preVal ? appJson[key] = Array.from(new Set(preVal // eslint-disable-next-line
866
+ .slice(0).concat(subp[key]))) : appJson[key] = subp[key].slice(0);
867
+ return;
868
+ }
869
+ });
870
+
871
+ if (invalidKeys.length) {
872
+ fail$8(`不支持分包${subp === null || subp === void 0 ? void 0 : subp.name}配置${invalidKeys.join(',')}\n`);
873
+ } // eslint-disable-next-line
874
+
875
+
876
+ invalidKeys.concat(['requiredBackgroundModes', 'embeddedAppIdList']).forEach(k => delete subp[k]);
877
+ return subp;
878
+ }); // 如果plugins重复,则错误提示
879
+
880
+ const pluginsErrMsg = Object.keys(pluginsMap).map(pk => {
881
+ if (pluginsMap[pk].length > 1) {
882
+ return `${pluginsMap[pk].join(',')}重复配置plugin(${pk});`;
883
+ }
884
+
885
+ return '';
886
+ }).reduce((pre, cur) => pre + cur, '');
887
+
888
+ if (pluginsErrMsg) {
889
+ fail$8(pluginsErrMsg);
890
+ } // eslint-disable-next-line
891
+
892
+
893
+ appJson.subpackages = subps;
894
+ };
729
895
  /**
730
896
  * 动态生成编译后的app.json
731
897
  * @param {object} tmsConfig
@@ -738,12 +904,14 @@ function buildOutputAppJson$1(tmsConfig, modules) {
738
904
  // 获取当前 modules 下的所有子模块的配置内容
739
905
  const modulesConfig = getLocalModuleConfig(modules, tmsConfig.appName, DEFAULT_MODULE_DIR$3, MODULE_CONFIG_FILENAME$1); // 获取app.json的配置
740
906
 
741
- const appJson = getAppJsonContent(resolve$7('./app.json')); // 更新app.json中的subpackages
907
+ const appJson = getAppJsonContent(resolve$a('./app.json')); // 更新app.json中的subpackages
908
+
909
+ updateSubpackages(appJson, modulesConfig); // 处理appJson中重复||冲突的地方
742
910
 
743
- updateSubpackages(appJson, modulesConfig); // 更新主包,需在subpackages处理完成后执行, pages/
911
+ processAppJson(appJson); // 更新主包,需在subpackages处理完成后执行, pages/
744
912
 
745
913
  updateMainPackages(appJson, tmsConfig.mainPackages);
746
- fs$6.writeFileSync(resolve$7(`${tmsConfig.gulp.outputDir}/app.json`), JSON.stringify(appJson, null, 2), 'utf8');
914
+ fs$a.writeFileSync(resolve$a(`${tmsConfig.gulp.outputDir}/app.json`), JSON.stringify(appJson, null, 2), 'utf8');
747
915
  return appJson;
748
916
  }
749
917
 
@@ -793,13 +961,13 @@ const {
793
961
  } = global;
794
962
  const {
795
963
  downloadRepoForGit,
796
- resolve: resolve$6
964
+ resolve: resolve$9
797
965
  } = widgets;
798
966
  const {
799
- fail: fail$4
967
+ fail: fail$7
800
968
  } = log$2;
801
- const fs$5 = require$$0__default$1;
802
- const shelljs$3 = require$$5__default;
969
+ const fs$9 = require$$0__default$1;
970
+ const shelljs$4 = require$$5__default;
803
971
  /**
804
972
  * 对克隆下来的模块进行相应的文件处理操作,比如收集处理模块信息,进行信息缓存等操作
805
973
  * @param { string } sourceDir 缓存文件夹
@@ -813,7 +981,7 @@ function moveFile(sourceDir, targetDir, ignore = []) {
813
981
  return new Promise(resolve => {
814
982
  MetalSmith(__dirname).ignore(ignore).source(sourceDir).destination(targetDir).build(e => {
815
983
  if (e) {
816
- fail$4(e); // eslint-disable-line
984
+ fail$7(e); // eslint-disable-line
817
985
 
818
986
  console.log('MetalSmith 详细的错误信息:', e);
819
987
  }
@@ -856,9 +1024,9 @@ async function downLoadAndMoveModule(sourceDir, targetDir, moduleInfo) {
856
1024
  path
857
1025
  } = moduleInfo; // 源码临时存在的源目录
858
1026
 
859
- let sourcePath = resolve$6(sourceDir, path); // 源码要放到目标目录
1027
+ let sourcePath = resolve$9(sourceDir, path); // 源码要放到目标目录
860
1028
 
861
- const targetPath = resolve$6(targetDir, path); // 设置模块的构建分支
1029
+ const targetPath = resolve$9(targetDir, path); // 设置模块的构建分支
862
1030
 
863
1031
  const cloneBranch = buildGitTag && typeof buildGitTag === 'string' ? buildGitTag : 'master'; // 检查缓存中有没有
864
1032
 
@@ -873,13 +1041,13 @@ async function downLoadAndMoveModule(sourceDir, targetDir, moduleInfo) {
873
1041
  sourcePath = globalInstance.getModuleCache(httpRepoUrl, cloneBranch).dest;
874
1042
  }
875
1043
 
876
- if (fs$5.existsSync(targetPath)) {
877
- shelljs$3.rm('-rf', targetPath);
1044
+ if (fs$9.existsSync(targetPath)) {
1045
+ shelljs$4.rm('-rf', targetPath);
878
1046
  }
879
1047
 
880
1048
  await moveFile(sourcePath, targetPath, ['node_modules', '.git']);
881
1049
  } catch (e) {
882
- fail$4(`downLoadAndMoveModule ${e}`); // eslint-disable-line
1050
+ fail$7(`downLoadAndMoveModule ${e}`); // eslint-disable-line
883
1051
 
884
1052
  process.exit(-1);
885
1053
  }
@@ -896,26 +1064,29 @@ var defaultTmsConfig$1 = {
896
1064
  modules: [],
897
1065
  cloudDir: 'cloud',
898
1066
  gulp: {
1067
+ // 第三方依赖代码需要拷贝到本项目的
1068
+ dependencies: {},
1069
+
899
1070
  /** 编译输出文件夹位置 */
900
1071
  outputDir: 'dist',
901
1072
 
902
1073
  /** 源码监听路径 */
903
1074
  sourceDir: './',
904
1075
 
905
- /** 源码Map */
906
- copyDir: []
1076
+ /** 静态资源目录 */
1077
+ static: []
907
1078
  }
908
1079
  };
909
1080
 
910
1081
  const loadash = require$$0__default$5;
911
- const fs$4 = require$$0__default$1;
1082
+ const fs$8 = require$$0__default$1;
912
1083
  const {
913
1084
  TMS_NAME: TMS_NAME$1,
914
1085
  TMS_CONFIG_FILENAME,
915
1086
  MODULE_CONFIG_FILENAME
916
1087
  } = require$$3;
917
1088
  const {
918
- resolve: resolve$5,
1089
+ resolve: resolve$8,
919
1090
  isObject
920
1091
  } = widgets;
921
1092
  const {
@@ -923,7 +1094,7 @@ const {
923
1094
  } = buildAppJson;
924
1095
  const defaultTmsConfig = defaultTmsConfig$1;
925
1096
  const {
926
- fail: fail$3
1097
+ fail: fail$6
927
1098
  } = log$2;
928
1099
  /**
929
1100
  * 读取tms.config.json
@@ -931,10 +1102,10 @@ const {
931
1102
  */
932
1103
 
933
1104
  const readTmsConfig$1 = function (env) {
934
- const tmsConfigPath = resolve$5(TMS_CONFIG_FILENAME);
1105
+ const tmsConfigPath = resolve$8(TMS_CONFIG_FILENAME);
935
1106
 
936
- if (!fs$4.existsSync(tmsConfigPath)) {
937
- fail$3('当前执行目录没有tms.config.js的配置项,请进行配置');
1107
+ if (!fs$8.existsSync(tmsConfigPath)) {
1108
+ fail$6('当前执行目录没有tms.config.js的配置项,请进行配置');
938
1109
  process.exit(1);
939
1110
  }
940
1111
 
@@ -963,7 +1134,7 @@ const checkModules$1 = function (tmsConfig, modules) {
963
1134
  });
964
1135
 
965
1136
  if (targetModules.length === 0) {
966
- fail$3(`你启动的模块无效,尝试 ${TMS_NAME$1} -m moduleName`);
1137
+ fail$6(`你启动的模块无效,尝试 ${TMS_NAME$1} -m moduleName`);
967
1138
  process.exit(1);
968
1139
  }
969
1140
 
@@ -984,10 +1155,10 @@ const tmsModulesMergeLocalModuleCfg$3 = (modules, appName, moduleDir) => {
984
1155
  path: relativePath,
985
1156
  name: moduleName
986
1157
  }, moduleIndex) => {
987
- const moduleConfigPath = resolve$5(relativePath, MODULE_CONFIG_FILENAME);
1158
+ const moduleConfigPath = resolve$8(relativePath, MODULE_CONFIG_FILENAME);
988
1159
 
989
- if (fs$4.existsSync(moduleConfigPath)) {
990
- let moduleConfigContent = fs$4.readFileSync(moduleConfigPath, 'utf-8');
1160
+ if (fs$8.existsSync(moduleConfigPath)) {
1161
+ let moduleConfigContent = fs$8.readFileSync(moduleConfigPath, 'utf-8');
991
1162
  moduleConfigContent = setModuleConfig(moduleConfigContent, appName, moduleDir);
992
1163
  const moduleContentArr = isObject(moduleConfigContent) ? [moduleConfigContent] : moduleConfigContent;
993
1164
  moduleContentArr.forEach(({
@@ -1015,7 +1186,7 @@ var tkitUtils = {
1015
1186
 
1016
1187
  /* eslint-disable require-jsdoc */
1017
1188
  const ci = require$$0__default$6;
1018
- const path$2 = require$$1__default$1;
1189
+ const path$6 = require$$1__default$1;
1019
1190
  /**
1020
1191
  * 获取小程序ci的Project对象
1021
1192
  * @returns {Object} 小程序ci对象
@@ -1029,7 +1200,7 @@ const getMpCi = ({
1029
1200
  }) => {
1030
1201
  var _cfgJsonContent$packO;
1031
1202
 
1032
- const cfgJsonContent = require(path$2.join(projectPath, 'project.config.json'));
1203
+ const cfgJsonContent = require(path$6.join(projectPath, 'project.config.json'));
1033
1204
 
1034
1205
  const ignores = (cfgJsonContent === null || cfgJsonContent === void 0 ? void 0 : (_cfgJsonContent$packO = cfgJsonContent.packOptions) === null || _cfgJsonContent$packO === void 0 ? void 0 : _cfgJsonContent$packO.ignore.map(({
1035
1206
  value
@@ -1098,8 +1269,8 @@ var mpCiUtils = {
1098
1269
  /**
1099
1270
  * 本文件主要负责项目或者分包依赖的npm的安装
1100
1271
  */
1101
- const fs$3 = require$$0__default$1;
1102
- const path$1 = require$$1__default$1;
1272
+ const fs$7 = require$$0__default$1;
1273
+ const path$5 = require$$1__default$1;
1103
1274
  const shell = require$$5__default;
1104
1275
  const glob = require$$3__default;
1105
1276
  const LOG = log$2;
@@ -1109,14 +1280,14 @@ const getTarNpmFilename = targetDir => `${targetDir.replace(/\//g, '-')}.tar.gz`
1109
1280
 
1110
1281
 
1111
1282
  const npmCache = function (targetDir, cacheDir) {
1112
- if (!fs$3.existsSync(cacheDir)) {
1113
- fs$3.mkdirSync(cacheDir);
1283
+ if (!fs$7.existsSync(cacheDir)) {
1284
+ fs$7.mkdirSync(cacheDir);
1114
1285
  }
1115
1286
 
1116
1287
  const tarNpmFilename = getTarNpmFilename(targetDir);
1117
1288
  const tarNpmFilePath = `${cacheDir}/${tarNpmFilename}`;
1118
1289
 
1119
- if (fs$3.existsSync(tarNpmFilePath)) {
1290
+ if (fs$7.existsSync(tarNpmFilePath)) {
1120
1291
  shell.rm('-rf', tarNpmFilePath);
1121
1292
  }
1122
1293
 
@@ -1132,7 +1303,7 @@ const getNpmCache = function (targetDir, cacheDir) {
1132
1303
  const tarNpmFilename = getTarNpmFilename(targetDir);
1133
1304
  const tarNpmFilePath = `${cacheDir}/${tarNpmFilename}`;
1134
1305
 
1135
- if (fs$3.existsSync(tarNpmFilePath)) {
1306
+ if (fs$7.existsSync(tarNpmFilePath)) {
1136
1307
  const cmd = `tar -zxvf ${tarNpmFilePath} -C ./`;
1137
1308
  shell.exec(cmd, {
1138
1309
  async: false,
@@ -1146,10 +1317,10 @@ const getNpmCache = function (targetDir, cacheDir) {
1146
1317
  const mpNpmInstallAll$1 = async (modules, contextDir, cacheDir) => {
1147
1318
  const packageJsonFiles = await findAllPackageJson(modules, contextDir);
1148
1319
  await Promise.all(packageJsonFiles.map(file => new Promise(resolve => {
1149
- const dir = path$1.dirname(file);
1320
+ const dir = path$5.dirname(file);
1150
1321
  shell.cd(dir);
1151
1322
 
1152
- if (!fs$3.existsSync(`${dir}/node_modules`)) {
1323
+ if (!fs$7.existsSync(`${dir}/node_modules`)) {
1153
1324
  getNpmCache(dir, cacheDir);
1154
1325
  }
1155
1326
 
@@ -1179,7 +1350,7 @@ const findFilesByFilter = (startPath, filter) => {
1179
1350
 
1180
1351
  const find = (startPath, filter) => {
1181
1352
  // 目录不存在
1182
- if (!fs$3.existsSync(startPath)) {
1353
+ if (!fs$7.existsSync(startPath)) {
1183
1354
  LOG.fail(`${startPath}目录不存在`);
1184
1355
  process.exit(-1);
1185
1356
  return;
@@ -1192,10 +1363,10 @@ const findFilesByFilter = (startPath, filter) => {
1192
1363
  return;
1193
1364
  }
1194
1365
 
1195
- const files = fs$3.readdirSync(startPath);
1366
+ const files = fs$7.readdirSync(startPath);
1196
1367
  files.forEach(file => {
1197
- const filename = path$1.join(startPath, file);
1198
- const stat = fs$3.lstatSync(filename); // 当前文件是文件夹类型,继续递归
1368
+ const filename = path$5.join(startPath, file);
1369
+ const stat = fs$7.lstatSync(filename); // 当前文件是文件夹类型,继续递归
1199
1370
 
1200
1371
  if (stat.isDirectory()) {
1201
1372
  find(filename, filter);
@@ -1221,11 +1392,15 @@ const findAllPackageJson = (subRoots = [], contextDir) => {
1221
1392
  const packageJsonName = 'package.json'; // 查找文件名
1222
1393
 
1223
1394
  const cwd = contextDir || dirpath;
1224
- const result = [path$1.join(cwd, packageJsonName)]; // 默认填充根目录下的package.json
1395
+ const result = [path$5.join(cwd, packageJsonName)]; // 默认填充根目录下的package.json
1225
1396
 
1226
1397
  subRoots.forEach(subRoot => {
1227
- console.log('>>>>>>>>>>>>', subRoot);
1228
- const toppath = path$1.join(cwd, subRoot.root); // 从该目录开始查找package.json文件
1398
+ if (!subRoot.root) {
1399
+ LOG.fail(`请检查${subRoot.name}的module.config.json是否有root字段`);
1400
+ process.exit(1);
1401
+ }
1402
+
1403
+ const toppath = path$5.join(cwd, subRoot.root); // 从该目录开始查找package.json文件
1229
1404
 
1230
1405
  const list = findFilesByFilter(toppath, packageJsonName);
1231
1406
  result.push(...list);
@@ -1241,7 +1416,7 @@ function cloudNpmInstall$1(contextDir) {
1241
1416
  }
1242
1417
 
1243
1418
  files.forEach(file => {
1244
- const dir = path$1.dirname(file);
1419
+ const dir = path$5.dirname(file);
1245
1420
  shell.cd(dir);
1246
1421
  shell.exec('npx npm install --production --registry http://mirrors.tencent.com/npm/', {
1247
1422
  silent: false
@@ -1260,7 +1435,7 @@ var npmUtils = {
1260
1435
 
1261
1436
  const {
1262
1437
  createTask: createTask$2,
1263
- resolve: resolve$4
1438
+ resolve: resolve$7
1264
1439
  } = widgets;
1265
1440
  const {
1266
1441
  buildMpNpm
@@ -1280,24 +1455,24 @@ const {
1280
1455
  async function install$2(tmsConfig, modules, isCloud = true) {
1281
1456
  const newModules = tmsModulesMergeLocalModuleCfg$2(modules, tmsConfig.appName, DEFAULT_MODULE_DIR$2); // 小程序npm install
1282
1457
 
1283
- await createTask$2(mpNpmInstallAll, '小程序 开始npm install', '小程序npm install 完成')(newModules, resolve$4(tmsConfig.gulp.outputDir), `${CACHE_DIR}/node_modules`); // 构建miniprograme_npm
1458
+ await createTask$2(mpNpmInstallAll, '小程序 开始npm install', '小程序npm install 完成')(newModules, resolve$7(tmsConfig.gulp.outputDir), `${CACHE_DIR}/node_modules`); // 构建miniprograme_npm
1284
1459
 
1285
1460
  await createTask$2(buildMpNpm, '开始构建miniprograme_npm', '构建miniprograme_npm 完成')({
1286
1461
  appId: tmsConfig.appId,
1287
- projectPath: resolve$4('./'),
1462
+ projectPath: resolve$7('./'),
1288
1463
  privateKey: tmsConfig.privateKey
1289
1464
  }); // 安装云函数的
1290
1465
 
1291
- isCloud && createTask$2(cloudNpmInstall, '云函数npm install', '云函数npm install安装完毕')(resolve$4(tmsConfig.cloudDir));
1466
+ isCloud && createTask$2(cloudNpmInstall, '云函数npm install', '云函数npm install安装完毕')(resolve$7(tmsConfig.cloudDir));
1292
1467
  }
1293
1468
 
1294
1469
  var install_1 = install$2;
1295
1470
 
1296
- const shelljs$2 = require$$5__default;
1297
- const fs$2 = require$$0__default$1;
1471
+ const shelljs$3 = require$$5__default;
1472
+ const fs$6 = require$$0__default$1;
1298
1473
  const io = io$2;
1299
1474
  const {
1300
- resolve: resolve$3,
1475
+ resolve: resolve$6,
1301
1476
  createTask: createTask$1
1302
1477
  } = widgets;
1303
1478
  const {
@@ -1315,7 +1490,7 @@ const {
1315
1490
  tmsModulesMergeLocalModuleCfg: tmsModulesMergeLocalModuleCfg$1
1316
1491
  } = tkitUtils;
1317
1492
  const {
1318
- fail: fail$2
1493
+ fail: fail$5
1319
1494
  } = log$2;
1320
1495
  const install$1 = install_1;
1321
1496
  /**
@@ -1327,31 +1502,31 @@ const install$1 = install_1;
1327
1502
  */
1328
1503
 
1329
1504
  const cpFilesToOutput = function (tmsConfig, targetModules, defaultFiles) {
1330
- const outputDir = resolve$3(tmsConfig.gulp.outputDir);
1505
+ const outputDir = resolve$6(tmsConfig.gulp.outputDir);
1331
1506
  io.ensureDirExist(outputDir);
1332
1507
  defaultFiles.forEach(item => {
1333
- if (fs$2.existsSync(resolve$3(item))) {
1334
- shelljs$2.cp('-rf', resolve$3(item), resolve$3(tmsConfig.gulp.outputDir, item));
1508
+ if (fs$6.existsSync(resolve$6(item))) {
1509
+ shelljs$3.cp('-rf', resolve$6(item), resolve$6(tmsConfig.gulp.outputDir, item));
1335
1510
  }
1336
1511
  }); // 拷贝模块的package.json到编译输出目录
1337
1512
 
1338
1513
  targetModules.forEach(item => {
1339
- const outputModuleDir = resolve$3(`${tmsConfig.gulp.outputDir}/${item.root}`);
1514
+ const outputModuleDir = resolve$6(`${tmsConfig.gulp.outputDir}/${item.root}`);
1340
1515
 
1341
- if (!fs$2.existsSync(resolve$3(item.path))) {
1342
- fail$2(`${item.path}模块代码路径不存在, 请检查tms.config.js的${item.name}模块的path`);
1516
+ if (!fs$6.existsSync(resolve$6(item.path))) {
1517
+ fail$5(`${item.path}模块代码路径不存在, 请检查tms.config.js的${item.name}模块的path`);
1343
1518
  process.exit(1);
1344
1519
  }
1345
1520
 
1346
1521
  io.ensureDirExist(outputModuleDir);
1347
- const modulePackagePath = resolve$3(item.path, 'package.json');
1348
- if (fs$2.existsSync(modulePackagePath)) shelljs$2.cp('-Rf', modulePackagePath, outputModuleDir);
1522
+ const modulePackagePath = resolve$6(item.path, 'package.json');
1523
+ if (fs$6.existsSync(modulePackagePath)) shelljs$3.cp('-Rf', modulePackagePath, outputModuleDir);
1349
1524
  });
1350
1525
  };
1351
1526
 
1352
1527
  async function task(tmsConfig, targetModules) {
1353
1528
  // 下载和移动代码
1354
- await createTask$1(cloneModules, '开始下载模块代码完成', '下载模块代码码完成')(MODULE_CODE_DIR, resolve$3('./'), targetModules); // tms.config.js的modules 合并 module.config.json的配置项
1529
+ await createTask$1(cloneModules, '开始下载模块代码完成', '下载模块代码码完成')(MODULE_CODE_DIR, resolve$6('./'), targetModules); // tms.config.js的modules 合并 module.config.json的配置项
1355
1530
 
1356
1531
  const newModules = tmsModulesMergeLocalModuleCfg$1(targetModules, tmsConfig.appName, DEFAULT_MODULE_DIR$1);
1357
1532
  console.log('当前init的有效模块', newModules.map(item => item.name)); // 拷贝相关配置文件到输出目录
@@ -1373,12 +1548,12 @@ async function bootstrap(tmsConfig, targetModules) {
1373
1548
 
1374
1549
  var init$5 = bootstrap;
1375
1550
 
1376
- var dev$2 = {exports: {}};
1551
+ var dev$3 = {exports: {}};
1377
1552
 
1378
- const through = require$$0__default$7;
1553
+ const through$3 = require$$0__default$7;
1379
1554
 
1380
- function replaceEnv(reg = /process\.env(\.(\w*))?/g, envData) {
1381
- const stream = through.obj(function (file, enc, cb) {
1555
+ function replaceEnv$1(reg = /process\.env(\.(\w*))?/g, envData) {
1556
+ const stream = through$3.obj(function (file, enc, cb) {
1382
1557
  if (file.isBuffer()) {
1383
1558
  let contents = String(file.contents);
1384
1559
  let resReg; // eslint-disable-next-line
@@ -1404,18 +1579,714 @@ function replaceEnv(reg = /process\.env(\.(\w*))?/g, envData) {
1404
1579
  return stream;
1405
1580
  }
1406
1581
 
1407
- var replaceEnv_1 = replaceEnv;
1582
+ var replaceEnv_1 = replaceEnv$1;
1583
+
1584
+ /* eslint-disable no-param-reassign */
1585
+ const strip = require$$0__default$8; // 匹配规则
1586
+
1587
+ const MATCH_RULE = new RegExp(/@import *(?:url\(['"]?([^'")]+)['"]?\)|['"]([^'"]+)['"]);?/g);
1588
+ /**
1589
+ * 获取样式文件中的@import语句
1590
+ * @param code 代码片段
1591
+ * @returns 结果数组
1592
+ */
1593
+
1594
+ const findCssImports$1 = code => {
1595
+ // 将buffer转成字符串
1596
+ code = code.toString(); // 去除注释
1597
+
1598
+ code = strip.block(code); // 定义最后返回的结果
1599
+
1600
+ const result = [];
1601
+ let matchList; // 循环遍历代码段,直至匹配结果为空
1602
+
1603
+ while (matchList = MATCH_RULE.exec(code)) {
1604
+ var _matchList, _matchList2;
1605
+
1606
+ // 存入结果数组
1607
+ result.push(((_matchList = matchList) === null || _matchList === void 0 ? void 0 : _matchList[1]) || ((_matchList2 = matchList) === null || _matchList2 === void 0 ? void 0 : _matchList2[2]));
1608
+ } // 返回结果
1609
+
1610
+
1611
+ return result;
1612
+ };
1613
+
1614
+ var findCssImport = {
1615
+ findCssImports: findCssImports$1
1616
+ };
1617
+
1618
+ /* eslint-disable no-param-reassign */
1619
+ const {
1620
+ fail: fail$4
1621
+ } = log$2;
1622
+
1623
+ function pluginError$3(error, isWatch) {
1624
+ const errMsg = error.message;
1625
+
1626
+ if (isWatch) {
1627
+ fail$4(errMsg);
1628
+ } else {
1629
+ fail$4(errMsg);
1630
+ process.exit(1);
1631
+ }
1632
+ }
1633
+
1634
+ var pluginError_1 = {
1635
+ pluginError: pluginError$3
1636
+ };
1637
+
1638
+ /* eslint-disable no-param-reassign */
1639
+ const through$2 = require$$0__default$7;
1640
+ const precinct = require$$1__default$4;
1641
+ const path$4 = require$$1__default$1;
1642
+ const {
1643
+ findCssImports
1644
+ } = findCssImport;
1645
+ const {
1646
+ ext: ext$2,
1647
+ fileInDir: fileInDir$2,
1648
+ diffContentCopyFile: diffContentCopyFile$2
1649
+ } = io$2;
1650
+ const {
1651
+ resolve: resolve$5
1652
+ } = widgets;
1653
+ const fs$5 = require$$0__default$1;
1654
+ const {
1655
+ pluginError: pluginError$2
1656
+ } = pluginError_1;
1657
+ const cssFilter = ['.less', '.wxss'];
1658
+
1659
+ const dfsFindCommonDep$2 = function (anaFileOriginFile, anaFileDestFile, extensions, isWatch = true) {
1660
+ const resDep = new Map();
1661
+
1662
+ function dfs(anaFileOriginFile, anaFileDestFile, extensions) {
1663
+ let contents = '';
1664
+
1665
+ try {
1666
+ contents = fs$5.readFileSync(anaFileOriginFile, 'utf8');
1667
+ } catch (e) {
1668
+ pluginError$2(e, isWatch);
1669
+ }
1670
+
1671
+ const deps = cssFilter.indexOf(path$4.extname(anaFileOriginFile)) > -1 ? findCssImports(contents) : precinct(contents);
1672
+ deps.forEach(depItem => {
1673
+ if (depItem.startsWith('.')) {
1674
+ // 被依赖文件的存在的绝对路径
1675
+ const depOriginPath = path$4.join(path$4.dirname(anaFileOriginFile), depItem); // 被依赖文件加上后缀
1676
+
1677
+ const {
1678
+ ext: extAlias,
1679
+ file: depOriginFile,
1680
+ extPath
1681
+ } = ext$2(depOriginPath, extensions);
1682
+
1683
+ if (!fs$5.existsSync(depOriginFile)) {
1684
+ pluginError$2(new Error(`${anaFileOriginFile}引用路径${depOriginFile}文件不存在, 请检查应用路径`), isWatch);
1685
+ return;
1686
+ }
1687
+
1688
+ const depDestPath = resolve$5(path$4.dirname(anaFileDestFile), depItem);
1689
+ const depDestFile = depDestPath.endsWith(extAlias) ? depDestPath : depDestPath + extPath;
1690
+
1691
+ if (!resDep.has(depDestFile)) {
1692
+ resDep.set(depDestFile, {
1693
+ anaFileOriginFile,
1694
+ anaFileDestFile,
1695
+ depDestFile,
1696
+ depOriginFile
1697
+ });
1698
+ dfs(depOriginFile, depDestFile, extensions);
1699
+ }
1700
+ }
1701
+ });
1702
+ }
1703
+
1704
+ dfs(anaFileOriginFile, anaFileDestFile, extensions);
1705
+ return resDep;
1706
+ };
1707
+
1708
+ function mpCommonDep$1(tmsConfig, module, extensions = [], isWatch = true) {
1709
+ const stream = through$2.obj(function (file, enc, cb) {
1710
+ // 依赖分析的文件
1711
+ const anaFileOriginFile = file.history[0];
1712
+ const anaFileRelativeModule = path$4.relative(resolve$5(module.from), anaFileOriginFile);
1713
+ const anaFileDestFile = resolve$5(tmsConfig.gulp.outputDir, module.to, anaFileRelativeModule);
1714
+
1715
+ if (file.isBuffer()) {
1716
+ let contents = String(file.contents);
1717
+ const deps = cssFilter.indexOf(path$4.extname(file.path)) > -1 ? findCssImports(contents) : precinct(contents);
1718
+ const copyModules = new Map();
1719
+ Object.keys(tmsConfig.gulp.dependencies).forEach(includeName => {
1720
+ const includePath = tmsConfig.gulp.dependencies[includeName];
1721
+ deps.forEach(depItem => {
1722
+ if (depItem.indexOf(includeName) > -1) {
1723
+ // 被依赖文件的存在的绝对路径 (eg: /User/thirdparty/loadsh)
1724
+ const depOriginPath = path$4.join(path$4.dirname(anaFileOriginFile), depItem); // 被依赖文件加上后缀
1725
+
1726
+ const {
1727
+ ext: extAlias,
1728
+ file: depOriginFile,
1729
+ extPath
1730
+ } = ext$2(depOriginPath, extensions);
1731
+
1732
+ if (!fileInDir$2(includePath, depOriginFile)) {
1733
+ pluginError$2(new Error(`${anaFileOriginFile}引用路径${depOriginFile}不在${includePath}不在文件夹内, 请检查应用路径`), isWatch);
1734
+ return;
1735
+ } // eslint-disable-next-line
1736
+
1737
+
1738
+ const reg = new RegExp(`^(\.\.\/)+.*\/${includeName}\/(.*)`);
1739
+ const regRes = depItem.match(reg) || [];
1740
+
1741
+ if (regRes[2]) {
1742
+ const depDestPath = resolve$5(tmsConfig.gulp.outputDir, module.to, includeName, regRes[2]);
1743
+ const depDestFile = depDestPath.endsWith(extAlias) ? depDestPath : depDestPath + extPath;
1744
+
1745
+ if (!copyModules.has(depDestFile)) {
1746
+ copyModules.set(depDestFile, {
1747
+ depOriginFile,
1748
+ depDestFile,
1749
+ beforeDepPath: depItem,
1750
+ afterDepPath: path$4.relative(path$4.dirname(anaFileDestFile), depDestPath)
1751
+ });
1752
+ }
1753
+ }
1754
+ }
1755
+ });
1756
+ }); // console.log('mpCommonDep copyModules', copyModules);
1757
+
1758
+ copyModules.forEach(({
1759
+ depOriginFile,
1760
+ depDestFile,
1761
+ beforeDepPath,
1762
+ afterDepPath
1763
+ }) => {
1764
+ diffContentCopyFile$2(depOriginFile, depDestFile);
1765
+ const reg = new RegExp(`['"]${beforeDepPath}["']`, 'g');
1766
+ contents = contents.replace(reg, `"${afterDepPath}"`);
1767
+ const defs = dfsFindCommonDep$2(depOriginFile, depDestFile, extensions, isWatch);
1768
+ defs.forEach(item => {
1769
+ diffContentCopyFile$2(item.depOriginFile, item.depDestFile);
1770
+ }); // console.log('mpCommonDep defs', defs);
1771
+ });
1772
+ file.contents = new Buffer(contents);
1773
+ }
1774
+
1775
+ this.push(file);
1776
+ cb();
1777
+ });
1778
+ return stream;
1779
+ }
1780
+
1781
+ var mpCommonDep_1 = {
1782
+ mpCommonDep: mpCommonDep$1,
1783
+ dfsFindCommonDep: dfsFindCommonDep$2
1784
+ };
1785
+
1786
+ /* eslint-disable no-param-reassign */
1787
+ const through$1 = require$$0__default$7;
1788
+ const path$3 = require$$1__default$1;
1789
+ const {
1790
+ ext: ext$1,
1791
+ fileInDir: fileInDir$1,
1792
+ diffContentCopyFile: diffContentCopyFile$1
1793
+ } = io$2;
1794
+ const {
1795
+ resolve: resolve$4
1796
+ } = widgets;
1797
+ const fs$4 = require$$0__default$1;
1798
+ const {
1799
+ pluginError: pluginError$1
1800
+ } = pluginError_1;
1801
+ const {
1802
+ dfsFindCommonDep: dfsFindCommonDep$1
1803
+ } = mpCommonDep_1;
1804
+
1805
+ function mpJsonDep$1(tmsConfig, module, extensions = ['.json'], filesExt = ['.wxml', '.json', '.js', '.ts', '.wxss', '.less'], isWatch) {
1806
+ const stream = through$1.obj(function (file, enc, cb) {
1807
+ // 当前分析的文件的路径
1808
+ const anaFileOriginFile = file.history[0];
1809
+ const anaFileRelativeModule = path$3.relative(resolve$4(module.from), anaFileOriginFile);
1810
+ const anaFileDestFile = resolve$4(tmsConfig.gulp.outputDir, module.to, anaFileRelativeModule);
1811
+
1812
+ if (file.isBuffer()) {
1813
+ const copyModules = new Map();
1814
+ let contents = String(file.contents);
1815
+
1816
+ try {
1817
+ contents = JSON.parse(contents);
1818
+
1819
+ if (contents.usingComponents) {
1820
+ Object.keys(tmsConfig.gulp.dependencies).forEach(includeName => {
1821
+ const includePath = tmsConfig.gulp.dependencies[includeName];
1822
+ Object.keys(contents.usingComponents).forEach(componentKey => {
1823
+ const componentPath = contents.usingComponents[componentKey];
1824
+
1825
+ if (componentPath.indexOf(includeName) > -1) {
1826
+ const depOriginPath = path$3.join(path$3.dirname(anaFileOriginFile), componentPath); // 被依赖文件加上后缀
1827
+
1828
+ const {
1829
+ ext: extAlias,
1830
+ file: depOriginFile,
1831
+ extPath
1832
+ } = ext$1(depOriginPath, extensions);
1833
+ const isFileInDir = fileInDir$1(includePath, depOriginFile);
1834
+
1835
+ if (!isFileInDir) {
1836
+ pluginError$1(new Error(`${anaFileOriginFile}引用的路径${depOriginFile}不在${includePath}不在文件夹内, 请检查应用路径`), isWatch);
1837
+ return;
1838
+ } // eslint-disable-next-line
1839
+
1840
+
1841
+ const reg = new RegExp(`^(\.\.\/)+.*\/${includeName}\/(.*)`);
1842
+ const regRes = componentPath.match(reg) || [];
1843
+
1844
+ if (regRes[2]) {
1845
+ const depDestPath = resolve$4(tmsConfig.gulp.outputDir, module.to, includeName, regRes[2]);
1846
+ const depDestFile = depDestPath.endsWith(extAlias) ? depDestPath : depDestPath + extPath;
1847
+
1848
+ if (!copyModules.has(depDestFile)) {
1849
+ copyModules.set(depDestFile, {
1850
+ depOriginFile,
1851
+ depOriginExt: extAlias,
1852
+ depDestFile,
1853
+ beforeDepPath: componentPath,
1854
+ afterDepPath: path$3.relative(path$3.dirname(anaFileDestFile), depDestPath)
1855
+ });
1856
+ }
1857
+ }
1858
+ }
1859
+ });
1860
+ });
1861
+ }
1862
+ } catch (e) {
1863
+ pluginError$1(e, isWatch);
1864
+ } // console.log('json copyModules', copyModules);
1865
+
1866
+
1867
+ copyModules.forEach(({
1868
+ depOriginFile,
1869
+ depOriginExt,
1870
+ depDestFile,
1871
+ beforeDepPath,
1872
+ afterDepPath
1873
+ }) => {
1874
+ // 拷贝当前依赖组件几个部分 wxml、wxss、wxs、json
1875
+ filesExt.forEach(extKey => {
1876
+ const originFile = depOriginFile.replace(depOriginExt, extKey);
1877
+ const destFile = depDestFile.replace(depOriginExt, extKey);
1878
+
1879
+ if (fs$4.existsSync(originFile)) {
1880
+ diffContentCopyFile$1(originFile, destFile);
1881
+ const extensionsFilter = ['.js', '.ts', '.wxss', '.less'];
1882
+
1883
+ if (extensionsFilter.indexOf(extKey) > -1) {
1884
+ const defs = dfsFindCommonDep$1(originFile, destFile, extensionsFilter); // console.log('json defs', defs);
1885
+
1886
+ defs.forEach(item => {
1887
+ diffContentCopyFile$1(item.depOriginFile, item.depDestFile);
1888
+ });
1889
+ }
1890
+ }
1891
+ });
1892
+ contents = typeof contents === 'object' ? JSON.stringify(contents, null, 2) : contents;
1893
+ const reg = new RegExp(`['"]${beforeDepPath}["']`, 'g');
1894
+ contents = contents.replace(reg, `"${afterDepPath}"`);
1895
+ });
1896
+ contents = typeof contents === 'object' ? JSON.stringify(contents, null, 2) : contents;
1897
+ file.contents = new Buffer(contents);
1898
+ }
1899
+
1900
+ this.push(file);
1901
+ cb();
1902
+ });
1903
+ return stream;
1904
+ }
1905
+
1906
+ var mpJsonDep_1 = {
1907
+ mpJsonDep: mpJsonDep$1
1908
+ };
1909
+
1910
+ /* eslint-disable no-param-reassign */
1911
+ const through = require$$0__default$7;
1912
+ const htmlparser2 = require$$1__default$5;
1913
+ const fs$3 = require$$0__default$1;
1914
+ const path$2 = require$$1__default$1;
1915
+ const {
1916
+ diffContentCopyFile,
1917
+ ext,
1918
+ fileInDir
1919
+ } = io$2;
1920
+ const {
1921
+ resolve: resolve$3
1922
+ } = widgets;
1923
+ const {
1924
+ dfsFindCommonDep
1925
+ } = mpCommonDep_1;
1926
+ const {
1927
+ pluginError
1928
+ } = pluginError_1; // 处理后缀(源码引入依赖时,不带后缀的情况)
1929
+
1930
+ const extFile = function (name, file) {
1931
+ const extMap = {
1932
+ import: '.wxml',
1933
+ include: '.wxml',
1934
+ wxs: '.wxs'
1935
+ };
1936
+ let extObj = {};
1937
+
1938
+ if (Object.keys(extMap).indexOf(name) > -1 && !file.endsWith(extMap[name])) {
1939
+ extObj = ext(file, [extMap[name]]);
1940
+ }
1941
+
1942
+ return {
1943
+ extPath: extObj.extPath || '',
1944
+ ext: extObj.ext || '',
1945
+ file: extObj.file || file
1946
+ };
1947
+ };
1948
+
1949
+ const dfsFindWxmlDep = function (anaFileOriginFile, anaFileDestFile, isWatch = true) {
1950
+ const resDep = {
1951
+ image: new Map(),
1952
+ wxml: new Map(),
1953
+ wxs: new Map()
1954
+ };
1955
+
1956
+ function dfs(anaFileOriginFile, anaFileDestFile) {
1957
+ let contents = '';
1958
+
1959
+ try {
1960
+ contents = fs$3.readFileSync(anaFileOriginFile, 'utf8');
1961
+ } catch (e) {
1962
+ pluginError(e, isWatch);
1963
+ }
1964
+
1965
+ const parser = new htmlparser2.Parser({
1966
+ onopentag(name, attributes) {
1967
+ var _attributes$src;
1968
+
1969
+ if (attributes !== null && attributes !== void 0 && (_attributes$src = attributes.src) !== null && _attributes$src !== void 0 && _attributes$src.startsWith('.')) {
1970
+ const depOriginPath = path$2.join(path$2.dirname(anaFileOriginFile), attributes.src); // 被依赖文件加上后缀
1971
+
1972
+ const {
1973
+ ext,
1974
+ file: depOriginFile,
1975
+ extPath
1976
+ } = extFile(name, depOriginPath);
1977
+
1978
+ if (!fs$3.existsSync(depOriginFile)) {
1979
+ pluginError(new Error(`${anaFileOriginFile}引用的路径${depOriginFile}找不到应用文件,请检查引用路径`), isWatch);
1980
+ return;
1981
+ }
1982
+
1983
+ const depDestPath = path$2.join(path$2.dirname(anaFileDestFile), attributes.src);
1984
+ const depDestFile = depDestPath.endsWith(ext) ? depDestPath : depDestPath + extPath; // 收集wxml依赖
1985
+
1986
+ if (['import', 'include'].indexOf(name) > -1) {
1987
+ resDep.wxml.set(depDestFile, {
1988
+ anaFileOriginFile,
1989
+ anaFileDestFile,
1990
+ depDestFile,
1991
+ depOriginFile
1992
+ });
1993
+ dfs(depOriginFile, depDestFile);
1994
+ } // 收集image依赖
1995
+ // if (name === 'image') {
1996
+ // resDep.image.set(attributes.src, {
1997
+ // anaFileOriginFile,
1998
+ // anaFileDestFile,
1999
+ // depDestFile,
2000
+ // depOriginFile,
2001
+ // });
2002
+ // dfs(depOriginFile, depDestFile);
2003
+ // }
2004
+ // 收集wxs依赖
2005
+
2006
+
2007
+ if (name === 'wxs') {
2008
+ resDep.wxs.set(depDestFile, {
2009
+ anaFileOriginFile,
2010
+ anaFileDestFile,
2011
+ depDestFile,
2012
+ depOriginFile
2013
+ });
2014
+ const defs = dfsFindCommonDep(depOriginFile, depDestFile, ['.wxs']);
2015
+ defs.forEach((item, key) => {
2016
+ resDep.wxs.set(key, item);
2017
+ });
2018
+ }
2019
+ }
2020
+ }
2021
+
2022
+ });
2023
+ parser.write(contents);
2024
+ parser.end();
2025
+ }
2026
+
2027
+ dfs(anaFileOriginFile, anaFileDestFile);
2028
+ return resDep;
2029
+ };
2030
+
2031
+ function mpWxmlDep$1(tmsConfig, module, isWatch) {
2032
+ const stream = through.obj(function (file, enc, cb) {
2033
+ // 依赖分析的文件
2034
+ const anaFileOriginFile = file.history[0];
2035
+ const anaFileRelativeModule = path$2.relative(resolve$3(module.from), anaFileOriginFile);
2036
+ const anaFileDestFile = resolve$3(tmsConfig.gulp.outputDir, module.to, anaFileRelativeModule);
2037
+
2038
+ if (file.isBuffer()) {
2039
+ let contents = String(file.contents);
2040
+ const copyModules = new Map();
2041
+ const parser = new htmlparser2.Parser({
2042
+ onopentag(name, attributes) {
2043
+ const nameFilter = ['import', 'include', 'wxs'];
2044
+
2045
+ if (nameFilter.indexOf(name) > -1 && attributes.src) {
2046
+ const depOriginPath = path$2.join(path$2.dirname(anaFileOriginFile), attributes.src); // 处理后缀(源码引入依赖时,后缀不全的情况)
2047
+
2048
+ const {
2049
+ ext,
2050
+ file: depOriginFile,
2051
+ extPath
2052
+ } = extFile(name, depOriginPath);
2053
+ Object.keys(tmsConfig.gulp.dependencies).forEach(includeName => {
2054
+ if (attributes.src.indexOf(includeName) > -1) {
2055
+ const includePath = tmsConfig.gulp.dependencies[includeName];
2056
+
2057
+ if (!fileInDir(includePath, depOriginFile)) {
2058
+ pluginError(new Error(`${anaFileOriginFile}引用路径${depOriginFile}不在${includePath}不在文件夹内, 请检查应用路径`), isWatch);
2059
+ return;
2060
+ } // eslint-disable-next-line
2061
+
2062
+
2063
+ const reg = new RegExp(`^(\.\.\/)+.*\/${includeName}\/(.*)`);
2064
+ const regRes = attributes.src.match(reg) || [];
2065
+
2066
+ if (regRes[2]) {
2067
+ const depDestPath = resolve$3(tmsConfig.gulp.outputDir, module.to, includeName, regRes[2]);
2068
+ const depDestFile = depDestPath.endsWith(ext) ? depDestPath : depDestPath + extPath;
2069
+
2070
+ if (!copyModules.has(depDestFile)) {
2071
+ copyModules.set(depDestFile, {
2072
+ depOriginFile,
2073
+ depDestFile,
2074
+ beforeDepPath: attributes.src,
2075
+ afterDepPath: path$2.relative(path$2.dirname(anaFileDestFile), depDestFile)
2076
+ });
2077
+ }
2078
+ }
2079
+ }
2080
+ });
2081
+ }
2082
+ }
2083
+
2084
+ });
2085
+ parser.write(contents);
2086
+ parser.end(); // console.log('wxml copyModules', copyModules);
2087
+
2088
+ copyModules.forEach(({
2089
+ depOriginFile,
2090
+ depDestFile,
2091
+ beforeDepPath,
2092
+ afterDepPath
2093
+ }) => {
2094
+ if (fs$3.existsSync(depOriginFile)) {
2095
+ diffContentCopyFile(depOriginFile, depDestFile);
2096
+ const reg = new RegExp(`['"]${beforeDepPath}["']`, 'g');
2097
+ contents = contents.replace(reg, `"${afterDepPath}"`);
2098
+ }
2099
+
2100
+ if (depOriginFile.endsWith('.wxml')) {
2101
+ const defs = dfsFindWxmlDep(depOriginFile, depDestFile, isWatch); // console.log('wxml defs', defs);
2102
+
2103
+ [...defs.wxml, ...defs.wxs].forEach(([, item]) => {
2104
+ diffContentCopyFile(item.depOriginFile, item.depDestFile);
2105
+ });
2106
+ }
2107
+
2108
+ if (depOriginFile.endsWith('.wxs')) {
2109
+ const defs = dfsFindCommonDep(depOriginFile, depDestFile, ['.wxs'], isWatch); // console.log('wxs defs', defs);
2110
+
2111
+ defs.forEach(item => {
2112
+ diffContentCopyFile(item.depOriginFile, item.depDestFile);
2113
+ });
2114
+ }
2115
+ });
2116
+ file.contents = new Buffer(contents);
2117
+ }
2118
+
2119
+ this.push(file);
2120
+ cb();
2121
+ });
2122
+ return stream;
2123
+ }
2124
+
2125
+ var mpWxmlDep_1 = {
2126
+ mpWxmlDep: mpWxmlDep$1,
2127
+ dfsFindWxmlDep
2128
+ };
2129
+
2130
+ /* eslint-disable no-param-reassign */
2131
+ const postcss$1 = require$$0__default$9;
2132
+ const fs$2 = require$$0__default$1;
2133
+ const path$1 = require$$1__default$1;
2134
+ const {
2135
+ fail: fail$3
2136
+ } = log$2;
2137
+ var postcssFontBase64 = postcss$1.plugin('postcss-font-base64', options => {
2138
+ options = { ...options,
2139
+ ...{
2140
+ match: {
2141
+ Scrabble: ['fakefont']
2142
+ },
2143
+ format: ['eot', 'woff', 'woff2', 'ttf']
2144
+ }
2145
+ };
2146
+ return function (css, result) {
2147
+ css.walkAtRules('font-face', fontFace => {
2148
+ const fileTypeRegex = getRegexStringForFileTypes(options.format);
2149
+ fontFace.replaceValues(new RegExp(`url\\(["']?.+\\.${fileTypeRegex}["']?\\)`), attr => {
2150
+ const fontRePath = attr.replace(/(url|'|"|\(|\)|\?#iefix)/g, '');
2151
+ const fontAbPath = path$1.join(path$1.dirname(result.opts.from), fontRePath);
2152
+ const res64 = base64Encode(fontAbPath);
2153
+ const newUrlStr = 'url(data:'.concat(getMimeType(attr)).concat(';charset=utf-8;base64,').concat(res64).concat(')');
2154
+ return res64 ? newUrlStr : attr;
2155
+ });
2156
+ });
2157
+
2158
+ function getRegexStringForFileTypes(fileTypes) {
2159
+ const regex = fileTypes.map(fileType => fileType === 'eot' ? fileType.concat('(\\?#iefix)?') : fileType).join('|');
2160
+ return regex ? `(${regex})` : '';
2161
+ } // helper functions
2162
+
2163
+
2164
+ function getMimeType(attribute) {
2165
+ const formats = {
2166
+ '.woff': 'application/font-woff',
2167
+ '.woff2': 'font/woff2',
2168
+ '.ttf': 'application/font-sfnt',
2169
+ '.eot': 'application/vnd.ms-fontobject',
2170
+ '.otf': 'application/font-sfnt'
2171
+ };
2172
+ let match = '';
2173
+ const extension = attribute.match(/\.[a-z]{3,4}/)[0];
2174
+
2175
+ if (extension in formats) {
2176
+ match = formats[extension];
2177
+ }
2178
+ return match;
2179
+ }
2180
+
2181
+ function base64Encode(file) {
2182
+ if (fs$2.existsSync(file)) {
2183
+ return readAndEncodeFile(file);
2184
+ }
2185
+
2186
+ fail$3(`${file} does not exist.`);
2187
+ return '';
2188
+ }
2189
+
2190
+ function readAndEncodeFile(file) {
2191
+ const bitmap = fs$2.readFileSync(file);
2192
+ return new Buffer(bitmap).toString('base64');
2193
+ }
2194
+ };
2195
+ });
2196
+
2197
+ const {
2198
+ src: src$1,
2199
+ dest,
2200
+ lastRun
2201
+ } = require$$0__default$a;
2202
+ const px2rpx = require$$1__default$6;
2203
+ const postcss = require$$2__default$1;
2204
+ const watch = require$$3__default$1;
2205
+ const cache = require$$4__default;
2206
+ const image = require$$5__default$1;
2207
+ const replaceEnv = replaceEnv_1;
2208
+ const {
2209
+ mpCommonDep
2210
+ } = mpCommonDep_1;
2211
+ const {
2212
+ mpJsonDep
2213
+ } = mpJsonDep_1;
2214
+ const {
2215
+ mpWxmlDep
2216
+ } = mpWxmlDep_1;
2217
+ const base64 = postcssFontBase64;
2218
+ const {
2219
+ fail: fail$2
2220
+ } = log$2;
2221
+
2222
+ const since = task => file => lastRun(task) > file.stat.ctime ? lastRun(task) : 0;
2223
+
2224
+ var compile = function (tmsConfig, {
2225
+ glob,
2226
+ destPath,
2227
+ srcOption,
2228
+ module,
2229
+ watchOption = {
2230
+ events: ['change', 'add', 'unlink']
2231
+ },
2232
+ isWatch
2233
+ }) {
2234
+ Object.keys(glob).forEach(globKey => {
2235
+ const globValue = glob[globKey];
2236
+
2237
+ const task = () => src$1(globValue, { ...srcOption,
2238
+ since: since(task)
2239
+ });
2240
+
2241
+ let srcPipe = task();
2242
+
2243
+ if (isWatch) {
2244
+ srcPipe = srcPipe.pipe(watch(globValue, watchOption));
2245
+ }
2246
+
2247
+ switch (globKey) {
2248
+ case 'js':
2249
+ srcPipe.pipe(replaceEnv(/process\.env(\.(\w*))?/g, tmsConfig.envData)).pipe(mpCommonDep(tmsConfig, module, ['.js', '.ts', '.wxs', '.json'], isWatch)).pipe(dest(destPath)).on('error', err => {
2250
+ fail$2(`js编译报错${err}`);
2251
+ });
2252
+ break;
2253
+
2254
+ case 'wxss':
2255
+ srcPipe.pipe(mpCommonDep(tmsConfig, module, ['.wxss', '.less'], isWatch)).pipe(postcss([base64()])).on('error', err => {
2256
+ fail$2(`postcss编译报错${err}`);
2257
+ }).pipe(px2rpx({
2258
+ designWidth: 375,
2259
+ // 设计稿宽度,默认为750
2260
+ precision: 2 // 小数最大精度,默认为6
2261
+
2262
+ })).pipe(dest(destPath));
2263
+ break;
2264
+
2265
+ case 'json':
2266
+ srcPipe.pipe(mpJsonDep(tmsConfig, module, ['.json'], ['.wxml', '.json', '.js', '.ts', '.wxss', '.less'], isWatch)).on('error', err => {
2267
+ fail$2(`json编译报错${err}`);
2268
+ }).pipe(dest(destPath));
2269
+ break;
2270
+
2271
+ case 'wxml':
2272
+ srcPipe.pipe(mpWxmlDep(tmsConfig, module, isWatch)).pipe(dest(destPath));
2273
+ break;
2274
+
2275
+ case 'image':
2276
+ srcPipe.pipe(cache(image())).on('error', err => {
2277
+ fail$2(`image编译报错${err}`);
2278
+ }).pipe(dest(destPath));
2279
+ break;
2280
+
2281
+ case 'other':
2282
+ srcPipe.pipe(dest(destPath));
2283
+ break;
2284
+ }
2285
+ });
2286
+ };
1408
2287
 
1409
2288
  (function (module) {
1410
- const fs = require$$0__default$1;
1411
- const {
1412
- src,
1413
- dest
1414
- } = require$$1__default$4;
1415
- const px2rpx = require$$2__default$1;
1416
- const less = require$$3__default$1;
1417
- const rename = require$$4__default;
1418
- const watch = require$$5__default$1;
2289
+ const watch = require$$3__default$1;
1419
2290
  const {
1420
2291
  resolve
1421
2292
  } = widgets;
@@ -1425,91 +2296,133 @@ var replaceEnv_1 = replaceEnv;
1425
2296
  const {
1426
2297
  DEFAULT_COPY_CONFIG
1427
2298
  } = require$$3;
1428
- const replaceEnv = replaceEnv_1;
1429
-
1430
- module.exports = async (tmsConfig, newModules) => {
1431
- var _tmsConfig$gulp;
1432
-
1433
- // 监听app.json
1434
- watch(resolve('app.json'), {
1435
- ignoreInitial: false,
1436
- events: ['add', 'change']
1437
- }, () => {
1438
- buildOutputAppJson(tmsConfig, newModules);
1439
- }); // 监听根目录的文件
2299
+ const compile$1 = compile;
2300
+
2301
+ function excludeGlob(glob) {
2302
+ const otherArr = new Set();
2303
+ otherArr.add('!**/*.{ttf,otf,woff,eot}');
2304
+ Object.keys(glob).forEach(globKey => {
2305
+ if (typeof glob[globKey] === 'string') {
2306
+ const data = glob[globKey].startsWith('!') ? glob[globKey] : `!${glob[globKey]}`;
2307
+ otherArr.add(data);
2308
+ }
1440
2309
 
1441
- DEFAULT_COPY_CONFIG.forEach(item => {
1442
- if (fs.existsSync(resolve(item))) {
1443
- src(resolve(item)).pipe(watch(resolve(item), {
1444
- events: ['change']
1445
- })).pipe(dest(resolve(tmsConfig.gulp.outputDir)));
2310
+ if (Array.isArray(glob[globKey])) {
2311
+ glob[globKey].forEach(value => {
2312
+ if (typeof value === 'string') {
2313
+ const data = value.startsWith('!') ? value : `!${value}`;
2314
+ otherArr.add(data);
2315
+ }
2316
+ });
1446
2317
  }
1447
2318
  });
1448
- src([resolve('app.less'), resolve('app.wxss')], {
1449
- allowEmpty: true
1450
- }).pipe(watch(`${resolve()}/(app.less|app.wxss)`, {
1451
- events: ['change']
1452
- })).pipe(less()).pipe(px2rpx({
1453
- designWidth: 375,
1454
- // 设计稿宽度,默认为750
1455
- precision: 2 // 小数最大精度,默认为6
1456
-
1457
- })).pipe(rename({
1458
- extname: '.wxss'
1459
- })).pipe(dest(resolve(tmsConfig.gulp.outputDir)));
1460
- src([resolve('app.js'), resolve('app.ts')], {
1461
- allowEmpty: true
1462
- }).pipe(watch(`${resolve()}/(app.js|app.ts)`, {
1463
- events: ['change']
1464
- })).pipe(replaceEnv(/process\.env(\.(\w*))?/g, tmsConfig.envData)).pipe(dest(resolve(tmsConfig.gulp.outputDir))); // 监听模块的文件
1465
-
1466
- for (const module of newModules) {
1467
- // 监听模块js文件
1468
- src([`${resolve(module.path)}/**/*.js`, `${resolve(module.path)}/**/*.ts`, `${resolve(module.path)}/**/*.wxs`]).pipe(watch(`${resolve(module.path)}/**/(*.js|*.ts|*.wxs)`, {
1469
- events: ['add', 'change']
1470
- })).pipe(replaceEnv(/process\.env(\.(\w*))?/g, tmsConfig.envData)).pipe(dest(resolve(tmsConfig.gulp.outputDir, module.root))); // 监听json文件
1471
-
1472
- src([`${resolve(module.path)}/**/*.json`]).pipe(watch(`${resolve(module.path)}/**/*.json`, {
1473
- events: ['add', 'change']
1474
- })).pipe(dest(resolve(tmsConfig.gulp.outputDir, module.root))); // 监听css文件
1475
-
1476
- src([`${resolve(module.path)}/**/*.less`, `${resolve(module.path)}/**/*.wxss`]).pipe(watch(`${resolve(module.path)}/**/(*.less|*.wxss)`, {
1477
- events: ['add', 'change']
1478
- })).pipe(less()).pipe(px2rpx({
1479
- designWidth: 375,
1480
- // 设计稿宽度,默认为750
1481
- precision: 2 // 小数最大精度,默认为6
2319
+ return Array.from(otherArr);
2320
+ }
1482
2321
 
1483
- })).pipe(rename({
1484
- extname: '.wxss'
1485
- })).pipe(dest(resolve(tmsConfig.gulp.outputDir, module.root))); // 监听wxml文件
2322
+ module.exports = async (tmsConfig, newModules, isWatch = true) => {
2323
+ var _tmsConfig$gulp, _tmsConfig$gulp2;
1486
2324
 
1487
- src([`${resolve(module.path)}/**/*.wxml`]).pipe(watch(`${resolve(module.path)}/**/*.wxml`, {
2325
+ // 监听app.json
2326
+ if (isWatch) {
2327
+ watch(resolve('app.json'), {
2328
+ ignoreInitial: false,
1488
2329
  events: ['add', 'change']
1489
- })).pipe(dest(resolve(tmsConfig.gulp.outputDir, module.root))); // 监听模块配置文件
1490
-
1491
- watch(`${resolve(module.path)}/**/module.config.json`, {
1492
- events: ['change']
1493
2330
  }, () => {
1494
2331
  buildOutputAppJson(tmsConfig, newModules);
1495
2332
  });
2333
+ } else {
2334
+ buildOutputAppJson(tmsConfig, newModules);
2335
+ } // 监听根目录的文件
2336
+
2337
+
2338
+ compile$1(tmsConfig, {
2339
+ glob: {
2340
+ json: DEFAULT_COPY_CONFIG.map(item => resolve(item)),
2341
+ wxss: ['app.less', 'app.wxss'].map(item => resolve(item)),
2342
+ js: ['app.js', 'app.ts'].map(item => resolve(item))
2343
+ },
2344
+ module: {
2345
+ from: '',
2346
+ to: ''
2347
+ },
2348
+ destPath: resolve(tmsConfig.gulp.outputDir),
2349
+ srcOption: {
2350
+ allowEmpty: true
2351
+ },
2352
+ isWatch
2353
+ }); // 监听模块的文件
2354
+
2355
+ for (let module of newModules) {
2356
+ // 处理默认参数
2357
+ module = { ...{
2358
+ exclude: []
2359
+ },
2360
+ ...module
2361
+ };
2362
+
2363
+ if (isWatch) {
2364
+ // 监听模块配置文件
2365
+ watch(`${resolve(module.path)}/**/module.config.json`, {
2366
+ events: ['change']
2367
+ }, () => {
2368
+ buildOutputAppJson(tmsConfig, newModules);
2369
+ });
2370
+ }
2371
+
2372
+ const excludes = module.exclude.map(key => `!${resolve(key)}`);
2373
+ const glob = {
2374
+ js: [`${resolve(module.path)}/**/*.{js,ts,wxs}`, ...excludes],
2375
+ json: [`${resolve(module.path)}/**/*.json`, ...excludes],
2376
+ wxss: [`${resolve(module.path)}/**/*.{less,wxss}`, ...excludes],
2377
+ wxml: [`${resolve(module.path)}/**/*.wxml`, ...excludes],
2378
+ image: [`${resolve(module.path)}/**/*.{png,jpg,jpeg,gif,svg}`, ...excludes]
2379
+ };
2380
+ compile$1(tmsConfig, {
2381
+ glob: { ...glob,
2382
+ other: [`${resolve(module.path)}/**/*`, ...excludeGlob(glob)]
2383
+ },
2384
+ destPath: resolve(tmsConfig.gulp.outputDir, module.root),
2385
+ module: {
2386
+ from: module.path,
2387
+ to: module.root
2388
+ },
2389
+ srcOption: {
2390
+ allowEmpty: true
2391
+ },
2392
+ isWatch
2393
+ });
1496
2394
  } // 监听copy模块
1497
2395
 
1498
2396
 
1499
- if ((tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$gulp = tmsConfig.gulp) === null || _tmsConfig$gulp === void 0 ? void 0 : _tmsConfig$gulp.copyDir.length) > 0) {
1500
- for (const item of (_tmsConfig$gulp2 = tmsConfig.gulp) === null || _tmsConfig$gulp2 === void 0 ? void 0 : _tmsConfig$gulp2.copyDir) {
1501
- var _tmsConfig$gulp2;
2397
+ if (tmsConfig !== null && tmsConfig !== void 0 && (_tmsConfig$gulp = tmsConfig.gulp) !== null && _tmsConfig$gulp !== void 0 && _tmsConfig$gulp.static && (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$gulp2 = tmsConfig.gulp) === null || _tmsConfig$gulp2 === void 0 ? void 0 : _tmsConfig$gulp2.static.length) > 0) {
2398
+ for (const item of (_tmsConfig$gulp3 = tmsConfig.gulp) === null || _tmsConfig$gulp3 === void 0 ? void 0 : _tmsConfig$gulp3.static) {
2399
+ var _tmsConfig$gulp3;
1502
2400
 
1503
- src([item.from]).pipe(watch(item.from, {
1504
- events: ['add', 'change']
1505
- })).pipe(dest(item.to));
2401
+ const glob = {
2402
+ js: `${item.from}/**/*.{js,ts,wxs}`,
2403
+ json: `${item.from}/**/*.json`,
2404
+ wxss: `${item.from}/**/*.{less,wxss}`,
2405
+ wxml: `${item.from}/**/*.wxml`,
2406
+ image: `${item.from}/**/*.{png,jpg,jpeg,gif,svg}`
2407
+ };
2408
+ compile$1(tmsConfig, {
2409
+ glob: { ...glob,
2410
+ other: [`${item.from}/**/*`, ...excludeGlob(glob)]
2411
+ },
2412
+ destPath: item.to,
2413
+ module: item,
2414
+ srcOption: {
2415
+ allowEmpty: true
2416
+ },
2417
+ isWatch
2418
+ });
1506
2419
  }
1507
2420
  }
1508
2421
  };
1509
- })(dev$2);
2422
+ })(dev$3);
1510
2423
 
1511
2424
  const fs$1 = require$$0__default$1;
1512
- const semver$1 = require$$1__default$5;
2425
+ const semver$1 = require$$1__default$7;
1513
2426
  const {
1514
2427
  resolve: resolve$2
1515
2428
  } = widgets;
@@ -1517,10 +2430,10 @@ const path = require$$1__default$1;
1517
2430
  const {
1518
2431
  fail: fail$1
1519
2432
  } = log$2;
1520
- const shelljs$1 = require$$5__default;
2433
+ const shelljs$2 = require$$5__default;
1521
2434
 
1522
2435
  const getLatestVersion = npmName => {
1523
- const data = shelljs$1.exec(`npm view ${npmName} version`);
2436
+ const data = shelljs$2.exec(`npm view ${npmName} version`);
1524
2437
  return data.stdout || '0.0.0';
1525
2438
  };
1526
2439
  /**
@@ -1600,7 +2513,7 @@ var checkDependencies_1 = {
1600
2513
  checkDependencies: checkDependencies$1
1601
2514
  };
1602
2515
 
1603
- const gulpDev = dev$2.exports;
2516
+ const gulpDev = dev$3.exports;
1604
2517
  const fs = require$$0__default$1;
1605
2518
  const {
1606
2519
  resolve: resolve$1
@@ -1663,7 +2576,7 @@ function isInit(tmsConfig, targetModules, contextDir) {
1663
2576
  return checkDependencies(targetModules, resolve$1('./'), tmsConfig.gulp.outputDir);
1664
2577
  }
1665
2578
 
1666
- async function dev$1(tmsConfig, targetModules, env) {
2579
+ async function dev$2(tmsConfig, targetModules, env) {
1667
2580
  // tms.config.js的modules 合并 module.config.json的配置项
1668
2581
  let newModules = tmsModulesMergeLocalModuleCfg(targetModules, tmsConfig.appName, DEFAULT_MODULE_DIR); // 判断是否进行init命令
1669
2582
 
@@ -1677,90 +2590,22 @@ async function dev$1(tmsConfig, targetModules, env) {
1677
2590
  gulpDev(tmsConfig, newModules, env);
1678
2591
  }
1679
2592
 
1680
- var dev_1 = dev$1;
1681
-
1682
- var build$2 = {exports: {}};
1683
-
1684
- (function (module) {
1685
- const fs = require$$0__default$1;
1686
- const {
1687
- src,
1688
- dest
1689
- } = require$$1__default$4;
1690
- const px2rpx = require$$2__default$1;
1691
- const less = require$$3__default$1;
1692
- const rename = require$$4__default;
1693
- const {
1694
- resolve
1695
- } = widgets;
1696
- const {
1697
- buildOutputAppJson
1698
- } = buildAppJson;
1699
- const {
1700
- DEFAULT_COPY_CONFIG
1701
- } = require$$3;
1702
- const replaceEnv = replaceEnv_1;
1703
-
1704
- module.exports = async (tmsConfig, newModules) => {
1705
- var _tmsConfig$gulp;
2593
+ var dev_1 = dev$2;
1706
2594
 
1707
- // app.json
1708
- buildOutputAppJson(tmsConfig, newModules); // 监听根目录的文件
1709
-
1710
- DEFAULT_COPY_CONFIG.forEach(item => {
1711
- if (fs.existsSync(resolve(item))) {
1712
- src(resolve(item)).pipe(dest(resolve(tmsConfig.gulp.outputDir)));
1713
- }
1714
- });
1715
- src([resolve('app.less'), resolve('app.wxss')], {
1716
- allowEmpty: true
1717
- }).pipe(less()).pipe(px2rpx({
1718
- designWidth: 375,
1719
- // 设计稿宽度,默认为750
1720
- precision: 2 // 小数最大精度,默认为6
1721
-
1722
- })).pipe(rename({
1723
- extname: '.wxss'
1724
- })).pipe(dest(resolve(tmsConfig.gulp.outputDir)));
1725
- src([resolve('app.js'), resolve('app.ts')], {
1726
- allowEmpty: true
1727
- }).pipe(replaceEnv(/process\.env(\.(\w*))?/g, tmsConfig.envData)).pipe(dest(resolve(tmsConfig.gulp.outputDir))); // 监听模块的文件
1728
-
1729
- for (const module of newModules) {
1730
- // 监听模块js文件
1731
- src([`${resolve(module.path)}/**/*.js`, `${resolve(module.path)}/**/*.ts`, `${resolve(module.path)}/**/*.wxs`]).pipe(replaceEnv(/process\.env(\.(\w*))?/g, tmsConfig.envData)).pipe(dest(resolve(tmsConfig.gulp.outputDir, module.root))); // 监听json文件
1732
-
1733
- src([`${resolve(module.path)}/**/*.json`]).pipe(dest(resolve(tmsConfig.gulp.outputDir, module.root))); // 监听css文件
1734
-
1735
- src([`${resolve(module.path)}/**/*.less`, `${resolve(module.path)}/**/*.wxss`]).pipe(less()).pipe(px2rpx({
1736
- designWidth: 375,
1737
- // 设计稿宽度,默认为750
1738
- precision: 2 // 小数最大精度,默认为6
1739
-
1740
- })).pipe(rename({
1741
- extname: '.wxss'
1742
- })).pipe(dest(resolve(tmsConfig.gulp.outputDir, module.root))); // 监听wxml文件
1743
-
1744
- src([`${resolve(module.path)}/**/*.wxml`]).pipe(dest(resolve(tmsConfig.gulp.outputDir, module.root)));
1745
- } // 监听copy模块
1746
-
1747
-
1748
- if ((tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$gulp = tmsConfig.gulp) === null || _tmsConfig$gulp === void 0 ? void 0 : _tmsConfig$gulp.copyDir.length) > 0) {
1749
- for (const item of (_tmsConfig$gulp2 = tmsConfig.gulp) === null || _tmsConfig$gulp2 === void 0 ? void 0 : _tmsConfig$gulp2.copyDir) {
1750
- var _tmsConfig$gulp2;
2595
+ const shelljs$1 = require$$5__default;
2596
+ const dev$1 = dev$3.exports;
1751
2597
 
1752
- src([item.from]).pipe(dest(item.to));
1753
- }
1754
- }
1755
- };
1756
- })(build$2);
2598
+ var build$2 = async (tmsConfig, newModules) => {
2599
+ shelljs$1.rm('-rf', tmsConfig.gulp.outputDir);
2600
+ dev$1(tmsConfig, newModules, false);
2601
+ };
1757
2602
 
1758
2603
  const shelljs = require$$5__default;
1759
2604
  const {
1760
2605
  resolve
1761
2606
  } = widgets;
1762
2607
  const init$3 = init$5;
1763
- const gulpBuild = build$2.exports;
2608
+ const gulpBuild = build$2;
1764
2609
 
1765
2610
  async function build$1(tmsConfig, targetModules, env) {
1766
2611
  // 开始构建前,清理输出目录
@@ -1893,12 +2738,18 @@ var entry = [{
1893
2738
 
1894
2739
  var require$$6 = {
1895
2740
  name: "@tmsfe/tmskit",
1896
- version: "0.0.5-beta.0",
2741
+ version: "0.0.5-beta.4",
1897
2742
  description: "tmskit",
1898
2743
  main: "main.js",
1899
2744
  bin: {
1900
2745
  tmskit: "main.js"
1901
2746
  },
2747
+ files: [
2748
+ "src",
2749
+ "dist",
2750
+ "main.js",
2751
+ "package.json"
2752
+ ],
1902
2753
  scripts: {
1903
2754
  dev: "rollup -wc --environment TARGET:tmskit",
1904
2755
  build: "rollup -c --environment TARGET:tmskit"
@@ -1930,30 +2781,37 @@ var require$$6 = {
1930
2781
  ejs: "^3.1.5",
1931
2782
  "glob-ignore": "^1.0.2",
1932
2783
  gulp: "^4.0.2",
1933
- "gulp-less": "^5.0.0",
2784
+ "gulp-cache": "^1.1.3",
2785
+ "gulp-image": "^5.1.0",
2786
+ "gulp-postcss": "^9.0.1",
1934
2787
  "gulp-px-to-rpx": "^1.0.7",
1935
- "gulp-rename": "^2.0.0",
1936
2788
  "gulp-watch": "^5.0.1",
2789
+ htmlparser2: "^7.2.0",
1937
2790
  inquirer: "^7.3.3",
1938
2791
  leven: "3.1.0",
1939
2792
  lodash: "^4.17.21",
1940
2793
  metalsmith: "^2.3.0",
1941
2794
  "miniprogram-ci": "1.4.13",
2795
+ "object-assign": "^4.0.1",
1942
2796
  ora: "^5.1.0",
2797
+ "plugin-error": "^1.0.0",
2798
+ postcss: "^8.4.6",
1943
2799
  precinct: "^8.3.1",
1944
2800
  "replace-ext": "^2.0.0",
1945
2801
  shelljs: "^0.8.4",
1946
- through2: "^4.0.2"
2802
+ "strip-comments": "^2.0.1",
2803
+ through2: "^4.0.2",
2804
+ "vinyl-sourcemaps-apply": "^0.2.0"
1947
2805
  },
1948
2806
  engines: {
1949
- node: "^12.17.0 || >= 14.0.0"
2807
+ node: "^12.17.0 || >= 14.13.1"
1950
2808
  },
1951
2809
  jest: {
1952
2810
  testEnvironment: "jest-environment-node"
1953
2811
  }
1954
2812
  };
1955
2813
 
1956
- const semver = require$$1__default$5;
2814
+ const semver = require$$1__default$7;
1957
2815
  const packageJson = require$$6;
1958
2816
  const chalk$1 = require$$0__default$2;
1959
2817
  const {
@@ -2046,6 +2904,6 @@ if (!process.argv.slice(2).length) {
2046
2904
  }
2047
2905
 
2048
2906
  program.parse(process.argv);
2049
- var src = src$1;
2907
+ var src = src$2;
2050
2908
 
2051
2909
  module.exports = src;