@tmsfe/tmskit 0.0.26 → 0.0.28

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
@@ -1,30 +1,30 @@
1
1
  'use strict';
2
2
 
3
- var require$$0 = require('chalk');
3
+ var require$$3 = require('chalk');
4
4
  var require$$1 = require('moment');
5
- var require$$0$1 = require('ora');
5
+ var require$$0 = require('ora');
6
6
  var require$$1$1 = require('path');
7
- var require$$0$2 = require('fs');
8
- var require$$0$3 = require('shelljs');
7
+ var require$$0$1 = require('fs');
8
+ var require$$0$2 = require('shelljs');
9
9
  var require$$4 = require('glob-ignore');
10
10
  var require$$1$2 = require('os');
11
- var require$$0$4 = require('lodash');
12
- var require$$0$5 = require('async');
11
+ var require$$0$3 = require('lodash');
12
+ var require$$0$4 = require('async');
13
13
  var require$$1$3 = require('ejs');
14
14
  var require$$1$4 = require('inquirer');
15
- var require$$0$6 = require('metalsmith');
16
- var require$$0$7 = require('request');
15
+ var require$$0$5 = require('metalsmith');
16
+ var require$$0$6 = require('request');
17
17
  var require$$10 = require('unzipper');
18
18
  var require$$1$5 = require('crypto');
19
- var require$$0$8 = require('miniprogram-ci');
19
+ var require$$0$7 = require('miniprogram-ci');
20
20
  var require$$1$6 = require('fs-extra');
21
21
  var require$$1$7 = require('semver');
22
- var require$$0$9 = require('gulp');
22
+ var require$$0$8 = require('gulp');
23
23
  var require$$2 = require('minimatch');
24
- var require$$3 = require('gulp-if');
24
+ var require$$3$1 = require('gulp-if');
25
25
  var require$$6 = require('through2');
26
- var require$$0$a = require('object-assign');
27
- var require$$3$1 = require('fancy-log');
26
+ var require$$0$9 = require('object-assign');
27
+ var require$$3$2 = require('fancy-log');
28
28
  var require$$4$1 = require('ansi-colors');
29
29
  var require$$5 = require('chokidar');
30
30
  var require$$6$1 = require('readable-stream');
@@ -39,31 +39,31 @@ var require$$1$8 = require('commander');
39
39
 
40
40
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
41
41
 
42
- var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
42
+ var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);
43
43
  var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
44
- var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
44
+ var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
45
45
  var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1);
46
+ var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
46
47
  var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
47
- var require$$0__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$0$3);
48
48
  var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4);
49
49
  var require$$1__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$1$2);
50
+ var require$$0__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$0$3);
50
51
  var require$$0__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$0$4);
51
- var require$$0__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$0$5);
52
52
  var require$$1__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$1$3);
53
53
  var require$$1__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$1$4);
54
+ var require$$0__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$0$5);
54
55
  var require$$0__default$6 = /*#__PURE__*/_interopDefaultLegacy(require$$0$6);
55
- var require$$0__default$7 = /*#__PURE__*/_interopDefaultLegacy(require$$0$7);
56
56
  var require$$10__default = /*#__PURE__*/_interopDefaultLegacy(require$$10);
57
57
  var require$$1__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$1$5);
58
- var require$$0__default$8 = /*#__PURE__*/_interopDefaultLegacy(require$$0$8);
58
+ var require$$0__default$7 = /*#__PURE__*/_interopDefaultLegacy(require$$0$7);
59
59
  var require$$1__default$6 = /*#__PURE__*/_interopDefaultLegacy(require$$1$6);
60
60
  var require$$1__default$7 = /*#__PURE__*/_interopDefaultLegacy(require$$1$7);
61
- var require$$0__default$9 = /*#__PURE__*/_interopDefaultLegacy(require$$0$9);
61
+ var require$$0__default$8 = /*#__PURE__*/_interopDefaultLegacy(require$$0$8);
62
62
  var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
63
- var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);
64
- var require$$6__default = /*#__PURE__*/_interopDefaultLegacy(require$$6);
65
- var require$$0__default$a = /*#__PURE__*/_interopDefaultLegacy(require$$0$a);
66
63
  var require$$3__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$3$1);
64
+ var require$$6__default = /*#__PURE__*/_interopDefaultLegacy(require$$6);
65
+ var require$$0__default$9 = /*#__PURE__*/_interopDefaultLegacy(require$$0$9);
66
+ var require$$3__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$3$2);
67
67
  var require$$4__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$4$1);
68
68
  var require$$5__default = /*#__PURE__*/_interopDefaultLegacy(require$$5);
69
69
  var require$$6__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$6$1);
@@ -76,9 +76,9 @@ var require$$10__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$10$1);
76
76
  var require$$12__default = /*#__PURE__*/_interopDefaultLegacy(require$$12$1);
77
77
  var require$$1__default$8 = /*#__PURE__*/_interopDefaultLegacy(require$$1$8);
78
78
 
79
- var src$2 = {};
79
+ var src$3 = {};
80
80
 
81
- const chalk$3 = require$$0__default;
81
+ const chalk$4 = require$$3__default;
82
82
  const moment$1 = require$$1__default;
83
83
  /**
84
84
  * 本文件提供无依赖的在终端打印彩色文字的方法。
@@ -92,7 +92,7 @@ const resetCfg = decodeURIComponent('%1B%5B0m'); // \033[0m转义后的字符按
92
92
  * @returns {undefined} 无
93
93
  */
94
94
 
95
- const fail$9 = (message = '') => {
95
+ const fail$a = (message = '') => {
96
96
  const redStyleConfig = decodeURIComponent('%1B%5B41%3B30m'); // \033[41;30m转义后的字符按,console时输出红色文字
97
97
 
98
98
  const greenFontStyleConfig = decodeURIComponent('%1B%5B41%3B37m'); // \033[41;30m转义后的字符按,console时输出红底白色文字
@@ -121,28 +121,28 @@ const succeed$2 = (message = '') => {
121
121
 
122
122
 
123
123
  const warn$2 = message => {
124
- console.log(`${moment$1().format('YYYY-MM-DD HH:mm:ss')}`, chalk$3.yellow(message));
124
+ console.log(`${moment$1().format('YYYY-MM-DD HH:mm:ss')}`, chalk$4.yellow(message));
125
125
  };
126
126
 
127
- const info$g = (...args) => console.log(`${moment$1().format('YYYY-MM-DD HH:mm:ss')}`, ...args);
127
+ const info$j = (...args) => console.log(`${moment$1().format('YYYY-MM-DD HH:mm:ss')}`, ...args);
128
128
 
129
129
  const infoNoTime$1 = (...args) => console.log(...args);
130
130
 
131
131
  var log$1 = {
132
- fail: fail$9,
132
+ fail: fail$a,
133
133
  succeed: succeed$2,
134
134
  warn: warn$2,
135
- info: info$g,
135
+ info: info$j,
136
136
  infoNoTime: infoNoTime$1
137
137
  };
138
138
 
139
- const ora$1 = require$$0__default$1;
140
- const path$f = require$$1__default$1;
141
- const fs$h = require$$0__default$2;
142
- const shelljs$7 = require$$0__default$3;
139
+ const ora$2 = require$$0__default;
140
+ const path$g = require$$1__default$1;
141
+ const fs$j = require$$0__default$1;
142
+ const shelljs$7 = require$$0__default$2;
143
143
  const glob = require$$4__default;
144
144
  const {
145
- info: info$f
145
+ info: info$i
146
146
  } = log$1;
147
147
  const shelljsOptions = {
148
148
  slient: true,
@@ -151,8 +151,8 @@ const shelljsOptions = {
151
151
 
152
152
  const cwd = process.cwd();
153
153
 
154
- function resolve$g(...args) {
155
- return path$f.resolve(cwd, ...args);
154
+ function resolve$j(...args) {
155
+ return path$g.resolve(cwd, ...args);
156
156
  }
157
157
  /**
158
158
  * 判断变量是否是一个数组
@@ -186,8 +186,8 @@ function downloadRepoForGit$1(url, dest, branch) {
186
186
  const cwd = process.cwd();
187
187
  return new Promise((resolve, reject) => {
188
188
  // 如果目标目录不存在
189
- if (fs$h.existsSync(dest)) {
190
- shelljs$7.rm('-rf', path$f.join(dest));
189
+ if (fs$j.existsSync(dest)) {
190
+ shelljs$7.rm('-rf', path$g.join(dest));
191
191
  }
192
192
 
193
193
  shelljs$7.mkdir('-p', dest);
@@ -237,7 +237,7 @@ function pullRepoForGit$1(dest, branch) {
237
237
  */
238
238
 
239
239
 
240
- function npmInstall$2(dir, npmConfig) {
240
+ function npmInstall$3(dir, npmConfig) {
241
241
  return new Promise((resolve, reject) => {
242
242
  const registry = getNpmRegistry(npmConfig);
243
243
  shelljs$7.exec(`npm install --production ${registry}`, {
@@ -293,11 +293,11 @@ const cost = start => Date.now() - start;
293
293
  */
294
294
 
295
295
 
296
- function createTask$5(task, startText, endText) {
296
+ function createTask$6(task, startText, endText) {
297
297
  return async (...args) => {
298
298
  const start = Date.now();
299
- const spinner = ora$1();
300
- info$f(startText);
299
+ const spinner = ora$2();
300
+ info$i(startText);
301
301
  spinner.start();
302
302
  const result = await task(...args);
303
303
  endText && spinner.succeed(`${endText}, 耗时${cost(start) / 1000}s`);
@@ -322,7 +322,7 @@ const mergeMap$1 = function (obj, src) {
322
322
  };
323
323
 
324
324
  const relativeCwdPath$1 = function (file) {
325
- return path$f.relative(process.cwd(), file);
325
+ return path$g.relative(process.cwd(), file);
326
326
  };
327
327
  /**
328
328
  * 从一个对象中,检索出去几个字段
@@ -357,9 +357,9 @@ function findFiles(globPath, filter = []) {
357
357
  } // 获取绝对路径
358
358
 
359
359
 
360
- function getAbsolutePath$5(pathDir, cwd = '') {
360
+ function getAbsolutePath$6(pathDir, cwd = '') {
361
361
  let newPath = pathDir;
362
- newPath = newPath.startsWith('/') ? newPath : resolve$g(cwd, newPath);
362
+ newPath = newPath.startsWith('/') ? newPath : resolve$j(cwd, newPath);
363
363
  newPath = newPath.endsWith('/') ? newPath.slice(0, newPath.length - 1) : newPath;
364
364
  return newPath;
365
365
  } // 版本比较 => 1(大于), 0(等于), -1(小于)
@@ -394,19 +394,19 @@ function getGitUser$2() {
394
394
  }
395
395
 
396
396
  var widgets = {
397
- resolve: resolve$g,
397
+ resolve: resolve$j,
398
398
  isObject,
399
399
  isArray,
400
- createTask: createTask$5,
400
+ createTask: createTask$6,
401
401
  downloadRepoForGit: downloadRepoForGit$1,
402
402
  pullRepoForGit: pullRepoForGit$1,
403
403
  camelize,
404
- npmInstall: npmInstall$2,
404
+ npmInstall: npmInstall$3,
405
405
  mergeMap: mergeMap$1,
406
406
  relativeCwdPath: relativeCwdPath$1,
407
407
  filterField: filterField$7,
408
408
  findFiles,
409
- getAbsolutePath: getAbsolutePath$5,
409
+ getAbsolutePath: getAbsolutePath$6,
410
410
  getNpmRegistry,
411
411
  versionCompare,
412
412
  getGitUser: getGitUser$2
@@ -414,26 +414,26 @@ var widgets = {
414
414
 
415
415
  var tmsMpconfig = {exports: {}};
416
416
 
417
- const path$e = require$$1__default$1;
417
+ const path$f = require$$1__default$1;
418
418
  const os = require$$1__default$2; // 用户目录
419
419
 
420
420
  const HOME_DIR = os.homedir(); // 所有文件的缓存目录
421
421
 
422
- const CACHE_DIR = path$e.resolve(HOME_DIR, '.tmskit'); // 版本管理的CDN地址
422
+ const CACHE_DIR = path$f.resolve(HOME_DIR, '.tmskit'); // 版本管理的CDN地址
423
423
 
424
424
  const VERSION_URL = 'https://tms-web-1g1czzwka2fd06f2-1301126013.tcloudbaseapp.com/tmskit-template/version.json'; // version缓存文件
425
425
 
426
- const VERSION_CACHE_FILE = path$e.resolve(CACHE_DIR, 'version_cache_file.json'); // npm缓存文件
426
+ const VERSION_CACHE_FILE = path$f.resolve(CACHE_DIR, 'version_cache_file.json'); // npm缓存文件
427
427
 
428
- const NPM_CACHE_FILE$1 = path$e.resolve(CACHE_DIR, 'npm_cache_file.json'); // 脚手架模板代码所在目录
428
+ const NPM_CACHE_FILE$1 = path$f.resolve(CACHE_DIR, 'npm_cache_file.json'); // 脚手架模板代码所在目录
429
429
 
430
- const TEMPLATE_DIR$1 = path$e.resolve(CACHE_DIR, 'template'); // 第三方模块源码存放的临时缓存目录
430
+ const TEMPLATE_DIR$1 = path$f.resolve(CACHE_DIR, 'template'); // 第三方模块源码存放的临时缓存目录
431
431
 
432
- const MODULE_CODE_DIR$2 = path$e.resolve(CACHE_DIR, 'modules_code'); // 缓存分包node_modules的目录
432
+ const MODULE_CODE_DIR$2 = path$f.resolve(CACHE_DIR, 'modules_code'); // 缓存分包node_modules的目录
433
433
 
434
- const NODE_MODULES_DIR$2 = path$e.resolve(CACHE_DIR, 'node_modules'); // 扩展命令源码的存放处
434
+ const NODE_MODULES_DIR$2 = path$f.resolve(CACHE_DIR, 'node_modules'); // 扩展命令源码的存放处
435
435
 
436
- const EXTEND_CMD$1 = path$e.resolve(CACHE_DIR, 'cmd'); // 创建模板的名称
436
+ const EXTEND_CMD$1 = path$f.resolve(CACHE_DIR, 'cmd'); // 创建模板的名称
437
437
 
438
438
  const TEMPLATE_NAME$1 = 'tmskit-template'; // 脚手架模板的远程地址
439
439
 
@@ -451,7 +451,7 @@ const DEFAULT_CLOUD_MODULE_DIR = './cloud'; // 模块的配置文件的名称
451
451
  const MODULE_CONFIG_FILENAME = 'module.config.json'; // 默认的webpack entry
452
452
 
453
453
  const DEFAULT_WEBPACK_ENTRY = {
454
- app: path$e.resolve(process.cwd(), 'app')
454
+ app: path$f.resolve(process.cwd(), 'app')
455
455
  }; // 默认从源码拷贝到编译后的配置
456
456
 
457
457
  const DEFAULT_COPY_CONFIG$2 = ['package.json', 'sitemap.json', 'project.config.json'];
@@ -545,6 +545,9 @@ var defaultTmsConfig = {
545
545
  minifyWXSS: true,
546
546
  autoPrefixWXSS: true
547
547
  }
548
+ },
549
+ npm: {
550
+ registry: 'https://registry.npmjs.org/'
548
551
  }
549
552
  };
550
553
 
@@ -554,8 +557,8 @@ var defaultTmsConfig = {
554
557
 
555
558
  (function (module) {
556
559
  /* eslint-disable no-param-reassign, no-nested-ternary */
557
- const loadash = require$$0__default$4;
558
- const fs = require$$0__default$2;
560
+ const loadash = require$$0__default$3;
561
+ const fs = require$$0__default$1;
559
562
  const path = require$$1__default$1;
560
563
  const {
561
564
  TMS_CONFIG_FILENAME,
@@ -867,10 +870,10 @@ var defaultTmsConfig = {
867
870
  };
868
871
  })(tmsMpconfig);
869
872
 
870
- const fs$g = require$$0__default$2;
871
- const path$d = require$$1__default$1;
873
+ const fs$i = require$$0__default$1;
874
+ const path$e = require$$1__default$1;
872
875
  const {
873
- info: info$e
876
+ info: info$h
874
877
  } = log$1;
875
878
  const {
876
879
  relativeCwdPath
@@ -881,12 +884,12 @@ const {
881
884
  * @returns
882
885
  */
883
886
 
884
- const isDirEmpty = dirname => fs$g.promises.readdir(dirname).then(files => files.length === 0); // 判断是否是文件
887
+ const isDirEmpty = dirname => fs$i.promises.readdir(dirname).then(files => files.length === 0); // 判断是否是文件
885
888
 
886
889
 
887
890
  const isFile = pathName => {
888
891
  try {
889
- const stat = fs$g.lstatSync(pathName);
892
+ const stat = fs$i.lstatSync(pathName);
890
893
  return stat.isFile();
891
894
  } catch {
892
895
  return false;
@@ -898,9 +901,9 @@ const isFile = pathName => {
898
901
  */
899
902
 
900
903
 
901
- const ensureDirExist$4 = dirname => {
902
- if (!fs$g.existsSync(dirname)) {
903
- fs$g.mkdirSync(dirname, {
904
+ const ensureDirExist$6 = dirname => {
905
+ if (!fs$i.existsSync(dirname)) {
906
+ fs$i.mkdirSync(dirname, {
904
907
  recursive: true
905
908
  });
906
909
  }
@@ -908,27 +911,27 @@ const ensureDirExist$4 = dirname => {
908
911
 
909
912
 
910
913
  const copyFile = function (src, dest) {
911
- if (fs$g.existsSync(dest)) {
912
- fs$g.unlinkSync(dest);
914
+ if (fs$i.existsSync(dest)) {
915
+ fs$i.unlinkSync(dest);
913
916
  }
914
917
 
915
- const dir = path$d.dirname(dest);
916
- ensureDirExist$4(dir);
917
- fs$g.copyFileSync(src, dest);
918
+ const dir = path$e.dirname(dest);
919
+ ensureDirExist$6(dir);
920
+ fs$i.copyFileSync(src, dest);
918
921
  }; // 判断文件内容是否一致,不一致再进行拷贝
919
922
 
920
923
 
921
924
  function diffContentCopyFile(originFile, destFile) {
922
- if (fs$g.existsSync(destFile)) {
923
- const depDestContent = fs$g.readFileSync(destFile, 'utf8');
924
- const depOriginContent = fs$g.readFileSync(originFile, 'utf8');
925
+ if (fs$i.existsSync(destFile)) {
926
+ const depDestContent = fs$i.readFileSync(destFile, 'utf8');
927
+ const depOriginContent = fs$i.readFileSync(originFile, 'utf8');
925
928
 
926
929
  if (depDestContent !== depOriginContent) {
927
- info$e(`拷贝${relativeCwdPath(originFile)}内容到${relativeCwdPath(destFile)}`);
930
+ info$h(`拷贝${relativeCwdPath(originFile)}内容到${relativeCwdPath(destFile)}`);
928
931
  copyFile(originFile, destFile);
929
932
  }
930
933
  } else {
931
- info$e(`拷贝${relativeCwdPath(originFile)}内容到${relativeCwdPath(destFile)}`);
934
+ info$h(`拷贝${relativeCwdPath(originFile)}内容到${relativeCwdPath(destFile)}`);
932
935
  copyFile(originFile, destFile);
933
936
  }
934
937
  } // 添加后缀
@@ -939,7 +942,7 @@ function ext(filePath, extensions) {
939
942
  let extPath = ''; // try catch需要包裹:用来处理'./lib/timer'没有后缀的情况
940
943
 
941
944
  try {
942
- const stat = fs$g.lstatSync(newFilePath);
945
+ const stat = fs$i.lstatSync(newFilePath);
943
946
 
944
947
  if (stat.isDirectory()) {
945
948
  extPath = newFilePath[newFilePath.length - 1] === '/' ? 'index' : '/index';
@@ -950,7 +953,7 @@ function ext(filePath, extensions) {
950
953
  for (const ext of extensions) {
951
954
  const file = newFilePath.endsWith(ext) ? newFilePath : newFilePath + ext;
952
955
 
953
- if (fs$g.existsSync(file)) {
956
+ if (fs$i.existsSync(file)) {
954
957
  return {
955
958
  ext,
956
959
  extPath: extPath + ext,
@@ -968,11 +971,11 @@ function ext(filePath, extensions) {
968
971
 
969
972
 
970
973
  const fileInDir = (dir, file) => {
971
- if (!fs$g.existsSync(dir) || !fs$g.existsSync(file)) {
974
+ if (!fs$i.existsSync(dir) || !fs$i.existsSync(file)) {
972
975
  return false;
973
976
  }
974
977
 
975
- const relativePath = path$d.relative(dir, file);
978
+ const relativePath = path$e.relative(dir, file);
976
979
 
977
980
  if (relativePath.startsWith('..')) {
978
981
  return false;
@@ -985,10 +988,10 @@ function findAllFilesOfDir(dir) {
985
988
  const list = [];
986
989
 
987
990
  function listFile(dir) {
988
- const arr = fs$g.readdirSync(dir);
991
+ const arr = fs$i.readdirSync(dir);
989
992
  arr.forEach(item => {
990
- const fullPath = path$d.join(dir, item);
991
- const stats = fs$g.statSync(fullPath);
993
+ const fullPath = path$e.join(dir, item);
994
+ const stats = fs$i.statSync(fullPath);
992
995
 
993
996
  if (stats.isDirectory()) {
994
997
  listFile(fullPath);
@@ -1007,14 +1010,14 @@ var io$3 = {
1007
1010
  isDirEmpty,
1008
1011
  copyFile,
1009
1012
  diffContentCopyFile,
1010
- ensureDirExist: ensureDirExist$4,
1013
+ ensureDirExist: ensureDirExist$6,
1011
1014
  ext,
1012
1015
  fileInDir,
1013
1016
  isFile,
1014
1017
  findAllFilesOfDir
1015
1018
  };
1016
1019
 
1017
- const async = require$$0__default$5;
1020
+ const async = require$$0__default$4;
1018
1021
  const ejs = require$$1__default$3;
1019
1022
 
1020
1023
  const render$1 = (files, metalsmith, next) => {
@@ -1034,10 +1037,10 @@ const render$1 = (files, metalsmith, next) => {
1034
1037
 
1035
1038
  var render_1 = render$1;
1036
1039
 
1037
- const fs$f = require$$0__default$2;
1040
+ const fs$h = require$$0__default$1;
1038
1041
  const inquirer$1 = require$$1__default$4;
1039
1042
  const {
1040
- resolve: resolve$f
1043
+ resolve: resolve$i
1041
1044
  } = widgets;
1042
1045
  const {
1043
1046
  TEMPLATE_TKIT_DIR: TEMPLATE_TKIT_DIR$1
@@ -1051,12 +1054,12 @@ const {
1051
1054
  const parseTemplateQuestions = dir => {
1052
1055
  let prompts = [];
1053
1056
 
1054
- if (!fs$f.existsSync(`${dir}/questions.json`)) {
1057
+ if (!fs$h.existsSync(`${dir}/questions.json`)) {
1055
1058
  return prompts;
1056
1059
  }
1057
1060
 
1058
1061
  try {
1059
- const json = JSON.parse(fs$f.readFileSync(`${dir}/questions.json`));
1062
+ const json = JSON.parse(fs$h.readFileSync(`${dir}/questions.json`));
1060
1063
 
1061
1064
  if (Array.isArray(json) && json.length > 0) {
1062
1065
  json.forEach((item, index) => {
@@ -1089,7 +1092,7 @@ const isQuestionType = result => {
1089
1092
  };
1090
1093
 
1091
1094
  const ask$1 = templateDir => (files, metalsmith, next) => {
1092
- const prompts = parseTemplateQuestions(resolve$f(templateDir, TEMPLATE_TKIT_DIR$1));
1095
+ const prompts = parseTemplateQuestions(resolve$i(templateDir, TEMPLATE_TKIT_DIR$1));
1093
1096
  const metadata = metalsmith.metadata();
1094
1097
  const filteredPrompts = prompts.filter(prompt => {
1095
1098
  if (metadata[prompt.name] && `${metadata[prompt.name]}`.trim() !== '') {
@@ -1114,7 +1117,7 @@ var ask_1 = ask$1;
1114
1117
  const FILES_TO_IGNORE$1 = ['node_modules'];
1115
1118
  var ignoreFiles = FILES_TO_IGNORE$1;
1116
1119
 
1117
- const Metalsmith = require$$0__default$6;
1120
+ const Metalsmith = require$$0__default$5;
1118
1121
  const render = render_1;
1119
1122
  const ask = ask_1;
1120
1123
  const FILES_TO_IGNORE = ignoreFiles;
@@ -1131,7 +1134,7 @@ const generator$1 = (buildDir, distDir, preMetadata = {}) => new Promise((resolv
1131
1134
 
1132
1135
  var generator_1 = generator$1;
1133
1136
 
1134
- const request$1 = require$$0__default$7;
1137
+ const request$1 = require$$0__default$6;
1135
1138
  const {
1136
1139
  getGitUser: getGitUser$1
1137
1140
  } = widgets;
@@ -1163,9 +1166,9 @@ const report$a = (name, attrs = {}) => {
1163
1166
 
1164
1167
  var report_1 = report$a;
1165
1168
 
1166
- const path$c = require$$1__default$1;
1167
- const fs$e = require$$0__default$2;
1168
- const shelljs$6 = require$$0__default$3;
1169
+ const path$d = require$$1__default$1;
1170
+ const fs$g = require$$0__default$1;
1171
+ const shelljs$6 = require$$0__default$2;
1169
1172
  const inquirer = require$$1__default$4;
1170
1173
  const {
1171
1174
  TEMPLATE_DIR,
@@ -1175,16 +1178,16 @@ const {
1175
1178
  CREATE_TEMPLATE_QUESTION
1176
1179
  } = constant;
1177
1180
  const {
1178
- resolve: resolve$e
1181
+ resolve: resolve$h
1179
1182
  } = widgets;
1180
1183
  const io$2 = io$3;
1181
1184
  const {
1182
- fail: fail$8,
1185
+ fail: fail$9,
1183
1186
  succeed: succeed$1,
1184
- info: info$d
1187
+ info: info$g
1185
1188
  } = log$1;
1186
1189
  const generator = generator_1;
1187
- const request = require$$0__default$7;
1190
+ const request = require$$0__default$6;
1188
1191
  const unzip = require$$10__default;
1189
1192
  const report$9 = report_1;
1190
1193
  /**
@@ -1195,9 +1198,9 @@ const report$9 = report_1;
1195
1198
 
1196
1199
  async function createProjectDir(targetDir) {
1197
1200
  // 如果目录非空或者已经存在,提示用户,做选择
1198
- if (fs$e.existsSync(targetDir)) {
1201
+ if (fs$g.existsSync(targetDir)) {
1199
1202
  if (!(await io$2.isDirEmpty(targetDir))) {
1200
- fail$8('该目录名已经存在,换个项目名字吧~');
1203
+ fail$9('该目录名已经存在,换个项目名字吧~');
1201
1204
  process.exit(1);
1202
1205
  }
1203
1206
  } else {
@@ -1216,14 +1219,14 @@ async function createProjectDir(targetDir) {
1216
1219
  function downloadAndUnZipTemplate(templateDir, templateUrl, templateName) {
1217
1220
  return new Promise((resolve, reject) => {
1218
1221
  const localZipPath = `${templateDir}/${templateName}.zip`;
1219
- const stream = fs$e.createWriteStream(localZipPath);
1222
+ const stream = fs$g.createWriteStream(localZipPath);
1220
1223
  request(`${templateUrl}?v=${new Date().getTime()}`).pipe(stream).on('close', err => {
1221
1224
  if (err) {
1222
1225
  reject(err);
1223
1226
  return;
1224
1227
  }
1225
1228
 
1226
- fs$e.createReadStream(localZipPath).pipe(unzip.Extract({
1229
+ fs$g.createReadStream(localZipPath).pipe(unzip.Extract({
1227
1230
  path: templateDir
1228
1231
  })).on('close', err => {
1229
1232
  if (err) {
@@ -1245,7 +1248,7 @@ function downloadAndUnZipTemplate(templateDir, templateUrl, templateName) {
1245
1248
 
1246
1249
  async function create(projectName) {
1247
1250
  const cwd = process.cwd();
1248
- const targetDir = path$c.resolve(cwd, projectName);
1251
+ const targetDir = path$d.resolve(cwd, projectName);
1249
1252
  const {
1250
1253
  projectType
1251
1254
  } = await inquirer.prompt(CREATE_TEMPLATE_QUESTION);
@@ -1255,21 +1258,21 @@ async function create(projectName) {
1255
1258
 
1256
1259
  await createProjectDir(targetDir); // 新创建缓存目录
1257
1260
 
1258
- if (fs$e.existsSync(TEMPLATE_DIR)) {
1261
+ if (fs$g.existsSync(TEMPLATE_DIR)) {
1259
1262
  shelljs$6.rm('-rf', TEMPLATE_DIR);
1260
1263
  }
1261
1264
 
1262
- fs$e.mkdirSync(TEMPLATE_DIR, {
1265
+ fs$g.mkdirSync(TEMPLATE_DIR, {
1263
1266
  recursive: true
1264
1267
  }); // 下载和解压模板
1265
1268
 
1266
1269
  await downloadAndUnZipTemplate(TEMPLATE_DIR, TEMPLATE_URL, TEMPLATE_NAME); // 生成模板(1. 询问问题, 2. ejs生成模板 3.生成到目标目录)
1267
1270
 
1268
- generator(path$c.join(TEMPLATE_DIR, TEMPLATE_NAME, projectType), targetDir).then(() => {
1271
+ generator(path$d.join(TEMPLATE_DIR, TEMPLATE_NAME, projectType), targetDir).then(() => {
1269
1272
  shelljs$6.cd(projectName);
1270
- const hookFilePath = resolve$e(projectName, TEMPLATE_TKIT_DIR, 'hooks.js');
1273
+ const hookFilePath = resolve$h(projectName, TEMPLATE_TKIT_DIR, 'hooks.js');
1271
1274
 
1272
- if (fs$e.existsSync(hookFilePath)) {
1275
+ if (fs$g.existsSync(hookFilePath)) {
1273
1276
  const hooks = require(hookFilePath);
1274
1277
 
1275
1278
  if (hooks.afterCreate) {
@@ -1284,7 +1287,7 @@ async function create(projectName) {
1284
1287
  });
1285
1288
  }
1286
1289
 
1287
- shelljs$6.rm('-rf', resolve$e(projectName, TEMPLATE_TKIT_DIR));
1290
+ shelljs$6.rm('-rf', resolve$h(projectName, TEMPLATE_TKIT_DIR));
1288
1291
  }
1289
1292
 
1290
1293
  report$9('create-success', {
@@ -1292,28 +1295,28 @@ async function create(projectName) {
1292
1295
  });
1293
1296
  succeed$1('项目创建完成.');
1294
1297
  }).catch(err => {
1295
- fail$8(err.message);
1296
- info$d('详细的错误信息:', err);
1298
+ fail$9(err.message);
1299
+ info$g('详细的错误信息:', err);
1297
1300
  });
1298
1301
  }
1299
1302
 
1300
1303
  var create_1 = create;
1301
1304
 
1302
- const fs$d = require$$0__default$2;
1303
- const path$b = require$$1__default$1;
1304
- const shellJs$1 = require$$0__default$3;
1305
+ const fs$f = require$$0__default$1;
1306
+ const path$c = require$$1__default$1;
1307
+ const shellJs$3 = require$$0__default$2;
1305
1308
  const {
1306
- ensureDirExist: ensureDirExist$3
1309
+ ensureDirExist: ensureDirExist$5
1307
1310
  } = io$3;
1308
1311
  const {
1309
1312
  EXTEND_CMD
1310
1313
  } = constant;
1311
1314
  const {
1312
- createTask: createTask$4
1315
+ createTask: createTask$5
1313
1316
  } = widgets;
1314
1317
  const {
1315
- info: info$c,
1316
- fail: fail$7
1318
+ info: info$f,
1319
+ fail: fail$8
1317
1320
  } = log$1;
1318
1321
  /**
1319
1322
  * 下载扩展命令的npm包
@@ -1325,17 +1328,17 @@ async function installCmd(npmName, cmd) {
1325
1328
  try {
1326
1329
  const cmdPackageJson = `${EXTEND_CMD}/package.json`;
1327
1330
 
1328
- if (!fs$d.existsSync(cmdPackageJson)) {
1329
- ensureDirExist$3(EXTEND_CMD);
1330
- fs$d.writeFileSync(cmdPackageJson, JSON.stringify({
1331
+ if (!fs$f.existsSync(cmdPackageJson)) {
1332
+ ensureDirExist$5(EXTEND_CMD);
1333
+ fs$f.writeFileSync(cmdPackageJson, JSON.stringify({
1331
1334
  dependencies: {}
1332
1335
  }, null, 2));
1333
1336
  }
1334
1337
 
1335
- shellJs$1.cd(EXTEND_CMD);
1336
- await createTask$4(npmName => new Promise((resolve, reject) => {
1338
+ shellJs$3.cd(EXTEND_CMD);
1339
+ await createTask$5(npmName => new Promise((resolve, reject) => {
1337
1340
  const registry = cmd.registry ? `--registry=${cmd.registry}` : '';
1338
- shellJs$1.exec(`npm install --save ${npmName} ${registry}`, {
1341
+ shellJs$3.exec(`npm install --save ${npmName} ${registry}`, {
1339
1342
  cwd: EXTEND_CMD,
1340
1343
  silent: true
1341
1344
  }, (code, stdout, stderr) => {
@@ -1347,8 +1350,8 @@ async function installCmd(npmName, cmd) {
1347
1350
  });
1348
1351
  }), `开始下载${npmName}`, `下载${npmName}完成`)(npmName);
1349
1352
  } catch (e) {
1350
- fail$7('构建出现错误:');
1351
- info$c(e);
1353
+ fail$8('构建出现错误:');
1354
+ info$f(e);
1352
1355
  process.exit(1);
1353
1356
  }
1354
1357
  }
@@ -1362,17 +1365,17 @@ function loadExtendCmd$1() {
1362
1365
  const cmdPackageJson = `${EXTEND_CMD}/package.json`;
1363
1366
  const cmdNpmDir = `${EXTEND_CMD}/node_modules`;
1364
1367
 
1365
- if (fs$d.existsSync(cmdPackageJson)) {
1366
- const content = fs$d.readFileSync(cmdPackageJson, 'utf8');
1368
+ if (fs$f.existsSync(cmdPackageJson)) {
1369
+ const content = fs$f.readFileSync(cmdPackageJson, 'utf8');
1367
1370
  const json = JSON.parse(content);
1368
1371
  const deps = json.dependencies || {};
1369
1372
  const cmdConfigs = [];
1370
1373
  Object.keys(deps).forEach(name => {
1371
1374
  // 检索cmd的npm包
1372
1375
  if (!/^tmskit-cmd-|^@[^/]+\/tmskit-cmd-/.test(name)) return false;
1373
- const cmdConfig = path$b.join(cmdNpmDir, name, 'tms.config.js');
1376
+ const cmdConfig = path$c.join(cmdNpmDir, name, 'tms.config.js');
1374
1377
 
1375
- if (fs$d.existsSync(cmdConfig)) {
1378
+ if (fs$f.existsSync(cmdConfig)) {
1376
1379
  cmdConfigs.push(cmdConfig);
1377
1380
  }
1378
1381
  });
@@ -1413,32 +1416,32 @@ var global_1 = {
1413
1416
  };
1414
1417
 
1415
1418
  const {
1416
- fail: fail$6
1419
+ fail: fail$7
1417
1420
  } = log$1;
1418
1421
  const {
1419
1422
  global: global$a
1420
1423
  } = global_1;
1421
1424
 
1422
- function handleError$7(error, isQuit = false) {
1425
+ function handleError$8(error, isQuit = false) {
1423
1426
  const errMsg = typeof error === 'object' ? error.message : error;
1424
1427
 
1425
1428
  if (isQuit) {
1426
- fail$6(errMsg);
1429
+ fail$7(errMsg);
1427
1430
  process.exit(1);
1428
1431
  }
1429
1432
 
1430
1433
  const isDev = global$a.getData('isDev');
1431
1434
 
1432
1435
  if (isDev) {
1433
- fail$6(errMsg);
1436
+ fail$7(errMsg);
1434
1437
  } else {
1435
- fail$6(errMsg);
1438
+ fail$7(errMsg);
1436
1439
  process.exit(1);
1437
1440
  }
1438
1441
  }
1439
1442
 
1440
1443
  var handleError_1 = {
1441
- handleError: handleError$7
1444
+ handleError: handleError$8
1442
1445
  };
1443
1446
 
1444
1447
  /**
@@ -1446,21 +1449,21 @@ var handleError_1 = {
1446
1449
  */
1447
1450
  /* eslint-disable no-param-reassign */
1448
1451
 
1449
- const fs$c = require$$0__default$2;
1452
+ const fs$e = require$$0__default$1;
1450
1453
  const {
1451
1454
  getSubPackages: getSubPackages$3,
1452
1455
  getModulesConfig
1453
1456
  } = tmsMpconfig.exports;
1454
1457
  const {
1455
- fail: fail$5,
1456
- info: info$b
1458
+ fail: fail$6,
1459
+ info: info$e
1457
1460
  } = log$1;
1458
1461
  const {
1459
- resolve: resolve$d,
1462
+ resolve: resolve$g,
1460
1463
  filterField: filterField$6
1461
1464
  } = widgets;
1462
1465
  const {
1463
- handleError: handleError$6
1466
+ handleError: handleError$7
1464
1467
  } = handleError_1;
1465
1468
  const {
1466
1469
  global: global$9
@@ -1484,7 +1487,7 @@ function updateMainPackages(appJson, mainPackages = []) {
1484
1487
 
1485
1488
  foundMainPackages.forEach(subpackage => {
1486
1489
  if (!subpackage.pages || !subpackage.pages.length) {
1487
- fail$5(`主包 ${subpackage} 不能没有 pages`);
1490
+ fail$6(`主包 ${subpackage} 不能没有 pages`);
1488
1491
  process.exit(-1);
1489
1492
  }
1490
1493
 
@@ -1509,12 +1512,12 @@ function updateMainPackages(appJson, mainPackages = []) {
1509
1512
 
1510
1513
 
1511
1514
  const getAppJsonContent = sourceAppJsonPath => {
1512
- if (!fs$c.existsSync(sourceAppJsonPath)) {
1513
- fail$5(`当前路径 ${sourceAppJsonPath} 没找到app.json`);
1515
+ if (!fs$e.existsSync(sourceAppJsonPath)) {
1516
+ fail$6(`当前路径 ${sourceAppJsonPath} 没找到app.json`);
1514
1517
  process.exit(1);
1515
1518
  }
1516
1519
 
1517
- const appJson = JSON.parse(fs$c.readFileSync(sourceAppJsonPath), 'utf-8'); // 加入默认值
1520
+ const appJson = JSON.parse(fs$e.readFileSync(sourceAppJsonPath), 'utf-8'); // 加入默认值
1518
1521
 
1519
1522
  appJson.subpackages = [];
1520
1523
  appJson.pages = [];
@@ -1593,7 +1596,7 @@ function buildOutputAppJson$2(tmsConfig, modules) {
1593
1596
 
1594
1597
  const subPackages = getSubPackages$3(modulesConfig); // 获取app.json的配置
1595
1598
 
1596
- const appJson = getAppJsonContent(resolve$d('./app.json')); // 更新app.json中的subpackages
1599
+ const appJson = getAppJsonContent(resolve$g('./app.json')); // 更新app.json中的subpackages
1597
1600
 
1598
1601
  appJson.subpackages = subPackages;
1599
1602
  appJson.subpackages.sort((item1, item2) => item1.name.localeCompare(item2.name)); // 处理appJson中重复||冲突的地方
@@ -1601,7 +1604,7 @@ function buildOutputAppJson$2(tmsConfig, modules) {
1601
1604
  fixAppJson(appJson); // 更新主包,需在subpackages处理完成后执行, pages/
1602
1605
 
1603
1606
  updateMainPackages(appJson, tmsConfig.mainPackages);
1604
- fs$c.writeFileSync(resolve$d(`${tmsConfig.outputDir}/app.json`), JSON.stringify(appJson, null, 2), 'utf8');
1607
+ fs$e.writeFileSync(resolve$g(`${tmsConfig.outputDir}/app.json`), JSON.stringify(appJson, null, 2), 'utf8');
1605
1608
 
1606
1609
  if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.updateAppJson) === 'function') {
1607
1610
  var _tmsConfig$hooks2;
@@ -1618,8 +1621,8 @@ function buildOutputAppJson$2(tmsConfig, modules) {
1618
1621
 
1619
1622
  return appJson;
1620
1623
  } catch (e) {
1621
- handleError$6(`生成app.json出现错误: ${e}`);
1622
- info$b(e);
1624
+ handleError$7(`生成app.json出现错误: ${e}`);
1625
+ info$e(e);
1623
1626
  }
1624
1627
  }
1625
1628
 
@@ -1630,21 +1633,21 @@ var buildAppJson = {
1630
1633
  /**
1631
1634
  * 下载第三方代码
1632
1635
  */
1633
- const MetalSmith = require$$0__default$6;
1636
+ const MetalSmith = require$$0__default$5;
1634
1637
  const crypto$2 = require$$1__default$5;
1635
1638
  const {
1636
1639
  downloadRepoForGit,
1637
1640
  pullRepoForGit,
1638
- resolve: resolve$c
1641
+ resolve: resolve$f
1639
1642
  } = widgets;
1640
1643
  const {
1641
- fail: fail$4,
1642
- info: info$a
1644
+ fail: fail$5,
1645
+ info: info$d
1643
1646
  } = log$1;
1644
- const fs$b = require$$0__default$2;
1645
- const shelljs$5 = require$$0__default$3;
1647
+ const fs$d = require$$0__default$1;
1648
+ const shelljs$5 = require$$0__default$2;
1646
1649
  const {
1647
- handleError: handleError$5
1650
+ handleError: handleError$6
1648
1651
  } = handleError_1;
1649
1652
  const {
1650
1653
  global: global$8
@@ -1657,15 +1660,17 @@ const {
1657
1660
  */
1658
1661
 
1659
1662
  function replaceGitUrlAccount(httpRepoUrl, moduleName) {
1660
- var _tmsConfig$gitAccount, _tmsConfig$gitAccount2;
1663
+ var _tmsConfig$gitAccount, _tmsConfig$gitAccount2, _tmsConfig$gitAccount3;
1661
1664
 
1662
1665
  // 用户本地的私有项目配置(用来配置环境\模块信息\账号信息)
1663
1666
  const tmsConfig = global$8.getData('tmsConfig');
1664
1667
  let gitUrl = httpRepoUrl;
1668
+ const gitGroupReg = /http(s)?:\/\/[^/]+\/[^/]+/;
1669
+ const group = gitUrl.match(gitGroupReg)[0];
1665
1670
  const {
1666
1671
  username = '',
1667
1672
  pass = ''
1668
- } = (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$gitAccount = tmsConfig.gitAccount) === null || _tmsConfig$gitAccount === void 0 ? void 0 : _tmsConfig$gitAccount[moduleName]) || (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$gitAccount2 = tmsConfig.gitAccount) === null || _tmsConfig$gitAccount2 === void 0 ? void 0 : _tmsConfig$gitAccount2[httpRepoUrl]) || {};
1673
+ } = (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$gitAccount = tmsConfig.gitAccount) === null || _tmsConfig$gitAccount === void 0 ? void 0 : _tmsConfig$gitAccount[moduleName]) || (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$gitAccount2 = tmsConfig.gitAccount) === null || _tmsConfig$gitAccount2 === void 0 ? void 0 : _tmsConfig$gitAccount2[httpRepoUrl]) || (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$gitAccount3 = tmsConfig.gitAccount) === null || _tmsConfig$gitAccount3 === void 0 ? void 0 : _tmsConfig$gitAccount3[group]) || {};
1669
1674
  const urlPrefixReg = /http(s)?:\/\//;
1670
1675
 
1671
1676
  if (username && pass && urlPrefixReg.test(gitUrl)) {
@@ -1684,7 +1689,7 @@ function replaceGitUrlAccount(httpRepoUrl, moduleName) {
1684
1689
 
1685
1690
 
1686
1691
  function moveFile(sourceDir, targetDir, ignore = []) {
1687
- if (fs$b.existsSync(targetDir)) {
1692
+ if (fs$d.existsSync(targetDir)) {
1688
1693
  shelljs$5.rm('-rf', targetDir);
1689
1694
  } // 删除不是文件夹的文件
1690
1695
 
@@ -1692,7 +1697,7 @@ function moveFile(sourceDir, targetDir, ignore = []) {
1692
1697
  return new Promise((resolve, reject) => {
1693
1698
  MetalSmith(__dirname).ignore(ignore).source(sourceDir).destination(targetDir).build(e => {
1694
1699
  if (e) {
1695
- fail$4(`${sourceDir} moveFile ${targetDir}出现错误: ${e}`);
1700
+ fail$5(`${sourceDir} moveFile ${targetDir}出现错误: ${e}`);
1696
1701
  reject(e);
1697
1702
  }
1698
1703
 
@@ -1741,7 +1746,7 @@ async function cloneModules$1(sourceDir, targetDir, modules) {
1741
1746
  }) => fn(...Object.keys(cParams).map(key => cParams[key])));
1742
1747
  return Promise.all(callArr);
1743
1748
  }).catch(e => {
1744
- handleError$5(`下载代码${params.httpRepoUrl}出现错误:${e}`);
1749
+ handleError$6(`下载代码${params.httpRepoUrl}出现错误:${e}`);
1745
1750
  }));
1746
1751
  });
1747
1752
  await Promise.all(arrPromises);
@@ -1786,9 +1791,9 @@ function collectDownLoadTasksMap(sourceDir, targetDir, modules) {
1786
1791
 
1787
1792
  const md5Key = md5ByGitUrlBranch(gitUrl, branch); // git源码临时存在的源目录
1788
1793
 
1789
- const sourcePath = resolve$c(sourceDir, md5Key); // 模块源码要放到目标目录
1794
+ const sourcePath = resolve$f(sourceDir, md5Key); // 模块源码要放到目标目录
1790
1795
 
1791
- const targetPath = resolve$c(targetDir, path); // 从git源码仓库中找到模块源码路径 (一个仓库存在存放多个模块的情况)
1796
+ const targetPath = resolve$f(targetDir, path); // 从git源码仓库中找到模块源码路径 (一个仓库存在存放多个模块的情况)
1792
1797
 
1793
1798
  const sourceModulePath = gitPath ? `${sourcePath}/${gitPath}` : sourcePath; // 下载完代码后,添加回调函数(主要将模块代码从临时目录移动代码到目标目录)
1794
1799
 
@@ -1798,7 +1803,7 @@ function collectDownLoadTasksMap(sourceDir, targetDir, modules) {
1798
1803
  targetPath
1799
1804
  },
1800
1805
  fn: async (sourceModulePath, targetPath) => {
1801
- if (fs$b.existsSync(targetPath)) {
1806
+ if (fs$d.existsSync(targetPath)) {
1802
1807
  shelljs$5.rm('-rf', `${targetPath}/*`);
1803
1808
  }
1804
1809
 
@@ -1813,14 +1818,17 @@ function collectDownLoadTasksMap(sourceDir, targetDir, modules) {
1813
1818
  } else {
1814
1819
  let promiseTask;
1815
1820
 
1816
- if (fs$b.existsSync(sourcePath) && fs$b.existsSync(`${sourcePath}/.git`)) {
1821
+ if (fs$d.existsSync(sourcePath) && fs$d.existsSync(`${sourcePath}/.git`)) {
1817
1822
  promiseTask = (gitUrl, sourcePath, branch, httpRepoUrl) => {
1818
- info$a(`git pull:${httpRepoUrl} --branch: ${branch}`);
1819
- return pullRepoForGit(sourcePath, branch);
1823
+ info$d(`git pull:${httpRepoUrl} --branch: ${branch}`);
1824
+ return pullRepoForGit(sourcePath, branch).catch(e => {
1825
+ info$d(`pull代码失败:${e}, 开始git clone: ${httpRepoUrl}:${branch}`);
1826
+ return downloadRepoForGit(gitUrl, sourcePath, branch);
1827
+ });
1820
1828
  };
1821
1829
  } else {
1822
1830
  promiseTask = (gitUrl, sourcePath, branch, httpRepoUrl) => {
1823
- info$a(`git clone: ${httpRepoUrl}`);
1831
+ info$d(`git clone: ${httpRepoUrl}`);
1824
1832
  return downloadRepoForGit(gitUrl, sourcePath, branch);
1825
1833
  };
1826
1834
  }
@@ -1861,7 +1869,7 @@ function checkRemoteModGitUrlBranch(sourceDir, moduleInfo) {
1861
1869
  const gitUrl = replaceGitUrlAccount(httpRepoUrl, moduleName);
1862
1870
  const md5Key = md5ByGitUrlBranch(gitUrl, buildGitTag);
1863
1871
 
1864
- if (!fs$b.existsSync(`${sourceDir}/${md5Key}`)) {
1872
+ if (!fs$d.existsSync(`${sourceDir}/${md5Key}`)) {
1865
1873
  return true;
1866
1874
  }
1867
1875
  }
@@ -1874,8 +1882,8 @@ var cloneModules_1 = {
1874
1882
  checkRemoteModGitUrlBranch
1875
1883
  };
1876
1884
 
1877
- const ci = require$$0__default$8;
1878
- const path$a = require$$1__default$1;
1885
+ const ci = require$$0__default$7;
1886
+ const path$b = require$$1__default$1;
1879
1887
  /**
1880
1888
  * 获取小程序ci的Project对象
1881
1889
  * @returns {Object} 小程序ci对象
@@ -1889,7 +1897,7 @@ const getMpCi = ({
1889
1897
  }) => {
1890
1898
  var _projectCg$packOption, _projectCg$packOption2;
1891
1899
 
1892
- const projectCg = require(path$a.join(projectPath, 'project.config.json'));
1900
+ const projectCg = require(path$b.join(projectPath, 'project.config.json'));
1893
1901
 
1894
1902
  const ignores = (projectCg === null || projectCg === void 0 ? void 0 : (_projectCg$packOption = projectCg.packOptions) === null || _projectCg$packOption === void 0 ? void 0 : (_projectCg$packOption2 = _projectCg$packOption.ignore) === null || _projectCg$packOption2 === void 0 ? void 0 : _projectCg$packOption2.map(({
1895
1903
  value
@@ -2016,13 +2024,13 @@ var mpCi$2 = {
2016
2024
  uploadMp
2017
2025
  };
2018
2026
 
2019
- const fs$a = require$$0__default$2;
2020
- const path$9 = require$$1__default$1;
2027
+ const fs$c = require$$0__default$1;
2028
+ const path$a = require$$1__default$1;
2021
2029
  const {
2022
2030
  NPM_CACHE_FILE
2023
2031
  } = constant;
2024
2032
  const {
2025
- ensureDirExist: ensureDirExist$2
2033
+ ensureDirExist: ensureDirExist$4
2026
2034
  } = io$3;
2027
2035
 
2028
2036
  function getCache$1(projectDir, type) {
@@ -2030,7 +2038,7 @@ function getCache$1(projectDir, type) {
2030
2038
 
2031
2039
  const filePath = NPM_CACHE_FILE;
2032
2040
 
2033
- if (!fs$a.existsSync(filePath)) {
2041
+ if (!fs$c.existsSync(filePath)) {
2034
2042
  return null;
2035
2043
  }
2036
2044
 
@@ -2042,10 +2050,10 @@ function getCache$1(projectDir, type) {
2042
2050
  function setCache$1(projectDir, type = 'miniprogram_npm', data) {
2043
2051
  const filePath = NPM_CACHE_FILE;
2044
2052
 
2045
- if (!fs$a.existsSync(filePath)) {
2046
- const dir = path$9.dirname(filePath);
2047
- ensureDirExist$2(dir);
2048
- fs$a.writeFileSync(filePath, '{}');
2053
+ if (!fs$c.existsSync(filePath)) {
2054
+ const dir = path$a.dirname(filePath);
2055
+ ensureDirExist$4(dir);
2056
+ fs$c.writeFileSync(filePath, '{}');
2049
2057
  }
2050
2058
 
2051
2059
  const content = require(filePath);
@@ -2057,7 +2065,7 @@ function setCache$1(projectDir, type = 'miniprogram_npm', data) {
2057
2065
  content[projectDir] = {
2058
2066
  [type]: data
2059
2067
  };
2060
- fs$a.writeFileSync(filePath, JSON.stringify(content, null, 2));
2068
+ fs$c.writeFileSync(filePath, JSON.stringify(content, null, 2));
2061
2069
  }
2062
2070
 
2063
2071
  var cache = {
@@ -2068,17 +2076,17 @@ var cache = {
2068
2076
  /**
2069
2077
  * 本文件主要负责项目或者分包依赖的npm的安装
2070
2078
  */
2071
- const fs$9 = require$$0__default$2;
2079
+ const fs$b = require$$0__default$1;
2072
2080
  const fsExtra = require$$1__default$6;
2073
2081
  const crypto$1 = require$$1__default$5;
2074
- const path$8 = require$$1__default$1;
2075
- const shell = require$$0__default$3;
2082
+ const path$9 = require$$1__default$1;
2083
+ const shell = require$$0__default$2;
2076
2084
  const log = log$1;
2077
2085
  const {
2078
- npmInstall: npmInstall$1
2086
+ npmInstall: npmInstall$2
2079
2087
  } = widgets;
2080
2088
  const {
2081
- handleError: handleError$4
2089
+ handleError: handleError$5
2082
2090
  } = handleError_1;
2083
2091
  const {
2084
2092
  global: global$7
@@ -2105,7 +2113,7 @@ const collectNpmTasksMap = (packageJsonFiles, cacheDir) => {
2105
2113
  const npmTasksMap = new Map();
2106
2114
 
2107
2115
  for (const packageJsonPath of packageJsonFiles) {
2108
- const packageContent = fs$9.readFileSync(packageJsonPath);
2116
+ const packageContent = fs$b.readFileSync(packageJsonPath);
2109
2117
  let packageJson;
2110
2118
 
2111
2119
  try {
@@ -2120,14 +2128,14 @@ const collectNpmTasksMap = (packageJsonFiles, cacheDir) => {
2120
2128
 
2121
2129
  if (Object.keys(md5Obj.dependencies).length !== 0) {
2122
2130
  const md5Key = crypto$1.createHash('md5').update(JSON.stringify(md5Obj)).digest('hex');
2123
- const cacheNMPath = path$8.join(cacheDir, md5Key);
2124
- const cacheNMTarFile = path$8.join(cacheNMPath, 'node_modules.tar.gz'); // 下载后,添加回调函数 (拷贝node_modules.tar.gz到编译目录并解压)
2131
+ const cacheNMPath = path$9.join(cacheDir, md5Key);
2132
+ const cacheNMTarFile = path$9.join(cacheNMPath, 'node_modules.tar.gz'); // 下载后,添加回调函数 (拷贝node_modules.tar.gz到编译目录并解压)
2125
2133
 
2126
2134
  const callback = {
2127
2135
  params: {
2128
2136
  cacheNMPath,
2129
2137
  cacheNMTarFile,
2130
- packageJsonDir: path$8.dirname(packageJsonPath),
2138
+ packageJsonDir: path$9.dirname(packageJsonPath),
2131
2139
  shell
2132
2140
  },
2133
2141
  fn: async (cacheNMPath, cacheNMTarFile, packageJsonDir, shell) => {
@@ -2157,7 +2165,7 @@ const collectNpmTasksMap = (packageJsonFiles, cacheDir) => {
2157
2165
  shell.cp('-f', packageJsonPath, cacheNMPath);
2158
2166
  log.info(`npm install: ${packageJsonPath}`);
2159
2167
  const tmsConfig = global$7.getData('tmsConfig');
2160
- return npmInstall$1(cacheNMPath, tmsConfig.npm).then(() => {
2168
+ return npmInstall$2(cacheNMPath, tmsConfig.npm).then(() => {
2161
2169
  const newShellJsOption = { ...shellJsOption,
2162
2170
  cwd: cacheNMPath
2163
2171
  };
@@ -2204,7 +2212,7 @@ const npmInstallAll$1 = async (subPackages, contextDir, cacheDir) => {
2204
2212
  }) => fn(...Object.keys(cParams).map(key => cParams[key])));
2205
2213
  return Promise.all(callArr);
2206
2214
  }).catch(e => {
2207
- handleError$4(`npm install ${params.packageJsonPath}出现错误:${e}`, true);
2215
+ handleError$5(`npm install ${params.packageJsonPath}出现错误:${e}`, true);
2208
2216
  }));
2209
2217
  });
2210
2218
  await Promise.all(arrPromises);
@@ -2230,7 +2238,7 @@ const findFilesByFilter = (startPath, filter) => {
2230
2238
 
2231
2239
  const find = (startPath, filter) => {
2232
2240
  // 目录不存在
2233
- if (!fs$9.existsSync(startPath)) {
2241
+ if (!fs$b.existsSync(startPath)) {
2234
2242
  log.fail(`${startPath}目录不存在`);
2235
2243
  process.exit(-1);
2236
2244
  return;
@@ -2243,10 +2251,10 @@ const findFilesByFilter = (startPath, filter) => {
2243
2251
  return;
2244
2252
  }
2245
2253
 
2246
- const files = fs$9.readdirSync(startPath);
2254
+ const files = fs$b.readdirSync(startPath);
2247
2255
  files.forEach(file => {
2248
- const filename = path$8.join(startPath, file);
2249
- const stat = fs$9.lstatSync(filename); // 当前文件是文件夹类型,继续递归
2256
+ const filename = path$9.join(startPath, file);
2257
+ const stat = fs$b.lstatSync(filename); // 当前文件是文件夹类型,继续递归
2250
2258
 
2251
2259
  if (stat.isDirectory()) {
2252
2260
  find(filename, filter);
@@ -2272,10 +2280,10 @@ const findAllPackageJson = (subRoots = [], contextDir) => {
2272
2280
  const packageJsonName = 'package.json'; // 查找文件名
2273
2281
 
2274
2282
  const cwd = contextDir || dirPath;
2275
- const result = [path$8.join(cwd, packageJsonName)]; // 默认填充根目录下的package.json
2283
+ const result = [path$9.join(cwd, packageJsonName)]; // 默认填充根目录下的package.json
2276
2284
 
2277
2285
  subRoots.forEach(subRoot => {
2278
- const toppath = path$8.join(cwd, subRoot.root); // 从该目录开始查找package.json文件
2286
+ const toppath = path$9.join(cwd, subRoot.root); // 从该目录开始查找package.json文件
2279
2287
 
2280
2288
  const list = findFilesByFilter(toppath, packageJsonName);
2281
2289
  result.push(...list);
@@ -2290,12 +2298,12 @@ var npm = {
2290
2298
  };
2291
2299
 
2292
2300
  const crypto = require$$1__default$5;
2293
- const fs$8 = require$$0__default$2;
2301
+ const fs$a = require$$0__default$1;
2294
2302
 
2295
2303
  function fileMd5$1(filePath) {
2296
2304
  return new Promise((resolve, reject) => {
2297
2305
  const md5sum = crypto.createHash('md5');
2298
- const stream = fs$8.ReadStream(filePath);
2306
+ const stream = fs$a.ReadStream(filePath);
2299
2307
  stream.on('data', d => {
2300
2308
  md5sum.update(d);
2301
2309
  });
@@ -2313,16 +2321,16 @@ var md5 = {
2313
2321
  fileMd5: fileMd5$1
2314
2322
  };
2315
2323
 
2316
- const fs$7 = require$$0__default$2;
2324
+ const fs$9 = require$$0__default$1;
2317
2325
  const semver$1 = require$$1__default$7;
2318
2326
  const {
2319
- resolve: resolve$b,
2320
- getAbsolutePath: getAbsolutePath$4
2327
+ resolve: resolve$e,
2328
+ getAbsolutePath: getAbsolutePath$5
2321
2329
  } = widgets;
2322
- const path$7 = require$$1__default$1;
2323
- const shelljs$4 = require$$0__default$3;
2330
+ const path$8 = require$$1__default$1;
2331
+ const shelljs$4 = require$$0__default$2;
2324
2332
  const {
2325
- handleError: handleError$3
2333
+ handleError: handleError$4
2326
2334
  } = handleError_1;
2327
2335
 
2328
2336
  const getLatestVersion = npmName => {
@@ -2341,17 +2349,17 @@ function collectPackageJson(subPackages, cwd, outputDir) {
2341
2349
  // 1.1根目录的package.json
2342
2350
 
2343
2351
  const packageArr = [{
2344
- srcPackageDir: path$7.join(cwd, packageJsonName),
2345
- destNpmDir: resolve$b(outputDir, 'node_modules')
2352
+ srcPackageDir: path$8.join(cwd, packageJsonName),
2353
+ destNpmDir: resolve$e(outputDir, 'node_modules')
2346
2354
  }]; // 1.2模块的package.json
2347
2355
 
2348
2356
  subPackages.forEach(item => {
2349
- const srcPackageDir = `${getAbsolutePath$4(item.path)}/package.json`;
2357
+ const srcPackageDir = `${getAbsolutePath$5(item.path)}/package.json`;
2350
2358
 
2351
- if (fs$7.existsSync(srcPackageDir)) {
2359
+ if (fs$9.existsSync(srcPackageDir)) {
2352
2360
  packageArr.push({
2353
2361
  srcPackageDir,
2354
- destNpmDir: resolve$b(outputDir, item.root, 'node_modules')
2362
+ destNpmDir: resolve$e(outputDir, item.root, 'node_modules')
2355
2363
  });
2356
2364
  }
2357
2365
  });
@@ -2360,14 +2368,14 @@ function collectPackageJson(subPackages, cwd, outputDir) {
2360
2368
 
2361
2369
 
2362
2370
  function readPackageDependencies(srcPackageDir) {
2363
- const packageJson = fs$7.readFileSync(srcPackageDir, 'utf-8');
2371
+ const packageJson = fs$9.readFileSync(srcPackageDir, 'utf-8');
2364
2372
  let dependencies = {};
2365
2373
 
2366
2374
  try {
2367
2375
  const json = packageJson ? JSON.parse(packageJson) : {};
2368
2376
  dependencies = (json === null || json === void 0 ? void 0 : json.dependencies) || {};
2369
2377
  } catch (e) {
2370
- handleError$3(`解析${srcPackageDir}报错,请检查是否是正确的json配置项 ${e}`);
2378
+ handleError$4(`解析${srcPackageDir}报错,请检查是否是正确的json配置项 ${e}`);
2371
2379
  }
2372
2380
 
2373
2381
  return dependencies;
@@ -2395,15 +2403,15 @@ const checkPackageVersion$1 = packageArr => {
2395
2403
  const dependenciesKeys = Object.keys(dependencies);
2396
2404
 
2397
2405
  for (const key of dependenciesKeys) {
2398
- const depPath = path$7.join(item.destNpmDir, key);
2406
+ const depPath = path$8.join(item.destNpmDir, key);
2399
2407
 
2400
- if (!fs$7.existsSync(depPath)) {
2408
+ if (!fs$9.existsSync(depPath)) {
2401
2409
  return true;
2402
2410
  }
2403
2411
 
2404
- const depPackagePath = path$7.join(depPath, 'package.json');
2412
+ const depPackagePath = path$8.join(depPath, 'package.json');
2405
2413
 
2406
- if (fs$7.existsSync(depPackagePath)) {
2414
+ if (fs$9.existsSync(depPackagePath)) {
2407
2415
  const packageData = require(depPackagePath);
2408
2416
 
2409
2417
  if (dependencies[key] === 'latest') {
@@ -2429,14 +2437,14 @@ var checkDependencies = {
2429
2437
  checkPackageVersion: checkPackageVersion$1
2430
2438
  };
2431
2439
 
2432
- const shelljs$3 = require$$0__default$3;
2433
- const fs$6 = require$$0__default$2;
2434
- const path$6 = require$$1__default$1;
2440
+ const shelljs$3 = require$$0__default$2;
2441
+ const fs$8 = require$$0__default$1;
2442
+ const path$7 = require$$1__default$1;
2435
2443
  const io$1 = io$3;
2436
2444
  const {
2437
- createTask: createTask$3,
2438
- resolve: resolve$a,
2439
- getAbsolutePath: getAbsolutePath$3
2445
+ createTask: createTask$4,
2446
+ resolve: resolve$d,
2447
+ getAbsolutePath: getAbsolutePath$4
2440
2448
  } = widgets;
2441
2449
  const {
2442
2450
  buildMpNpm
@@ -2452,7 +2460,7 @@ const {
2452
2460
  npmInstallAll
2453
2461
  } = npm;
2454
2462
  const {
2455
- info: info$9
2463
+ info: info$c
2456
2464
  } = log$1;
2457
2465
  const {
2458
2466
  fileMd5
@@ -2461,25 +2469,25 @@ const {
2461
2469
  isDependenciesUpdate
2462
2470
  } = checkDependencies;
2463
2471
 
2464
- async function install$2(tmsConfig, subPackages, useCache = true) {
2472
+ async function install$3(tmsConfig, subPackages, useCache = true) {
2465
2473
  const cwd = process.cwd();
2466
- const npmInstallRes = await createTask$3(npmInstall, '小程序 开始npm install', '小程序npm install 完成')(tmsConfig, subPackages, useCache); // 如果npm install 没有命中缓存,则说明node_module有更新,此时必须构建miniprogram_npm
2474
+ const npmInstallRes = await createTask$4(npmInstall$1, '小程序 开始npm install', '小程序npm install 完成')(tmsConfig, subPackages, useCache); // 如果npm install 没有命中缓存,则说明node_module有更新,此时必须构建miniprogram_npm
2467
2475
 
2468
2476
  if (!npmInstallRes.isCache) {
2469
2477
  // 构建miniprogram_npm, 不使用缓存
2470
- await createTask$3(mpCiInstall, '开始构建miniprogram_npm', '构建miniprogram_npm 完成')(tmsConfig, subPackages, false);
2478
+ await createTask$4(mpCiInstall, '开始构建miniprogram_npm', '构建miniprogram_npm 完成')(tmsConfig, subPackages, false);
2471
2479
  } else {
2472
2480
  // 构建miniprogram_npm
2473
- await createTask$3(mpCiInstall, '开始构建miniprogram_npm', '构建miniprogram_npm 完成')(tmsConfig, subPackages, useCache);
2481
+ await createTask$4(mpCiInstall, '开始构建miniprogram_npm', '构建miniprogram_npm 完成')(tmsConfig, subPackages, useCache);
2474
2482
  }
2475
2483
 
2476
2484
  shelljs$3.cd(cwd);
2477
2485
  }
2478
2486
 
2479
- async function npmInstall(tmsConfig, subPackages, useCache) {
2487
+ async function npmInstall$1(tmsConfig, subPackages, useCache) {
2480
2488
  // 如果依赖没有更新和使用缓存数据(则命中缓存)
2481
- if (!isDependenciesUpdate(subPackages, resolve$a('./'), tmsConfig.outputDir) && useCache) {
2482
- info$9('node_modules命中缓存');
2489
+ if (!isDependenciesUpdate(subPackages, resolve$d('./'), tmsConfig.outputDir) && useCache) {
2490
+ info$c('node_modules命中缓存');
2483
2491
  return {
2484
2492
  isCache: true
2485
2493
  };
@@ -2487,12 +2495,12 @@ async function npmInstall(tmsConfig, subPackages, useCache) {
2487
2495
 
2488
2496
 
2489
2497
  subPackages.forEach(item => {
2490
- const outputModuleDir = resolve$a(`${tmsConfig.outputDir}/${item.root}`);
2498
+ const outputModuleDir = resolve$d(`${tmsConfig.outputDir}/${item.root}`);
2491
2499
  io$1.ensureDirExist(outputModuleDir);
2492
- const modulePackagePath = `${getAbsolutePath$3(item.path)}/package.json`;
2493
- if (fs$6.existsSync(modulePackagePath)) shelljs$3.cp('-Rf', modulePackagePath, outputModuleDir);
2500
+ const modulePackagePath = `${getAbsolutePath$4(item.path)}/package.json`;
2501
+ if (fs$8.existsSync(modulePackagePath)) shelljs$3.cp('-Rf', modulePackagePath, outputModuleDir);
2494
2502
  });
2495
- await npmInstallAll(subPackages, resolve$a(tmsConfig.outputDir), NODE_MODULES_DIR$1);
2503
+ await npmInstallAll(subPackages, resolve$d(tmsConfig.outputDir), NODE_MODULES_DIR$1);
2496
2504
  return {
2497
2505
  isCache: false
2498
2506
  };
@@ -2501,16 +2509,16 @@ async function npmInstall(tmsConfig, subPackages, useCache) {
2501
2509
 
2502
2510
  async function mpCiInstall(tmsConfig, subPackages, useCache) {
2503
2511
  const packageJsonFiles = [];
2504
- const rootPackFile = resolve$a(`${tmsConfig.outputDir}/package.json`);
2512
+ const rootPackFile = resolve$d(`${tmsConfig.outputDir}/package.json`);
2505
2513
 
2506
- if (fs$6.existsSync(rootPackFile)) {
2514
+ if (fs$8.existsSync(rootPackFile)) {
2507
2515
  packageJsonFiles.push(rootPackFile);
2508
2516
  }
2509
2517
 
2510
2518
  subPackages.forEach(item => {
2511
- const packageJsonFile = resolve$a(`${tmsConfig.outputDir}/${item.root}/package.json`);
2519
+ const packageJsonFile = resolve$d(`${tmsConfig.outputDir}/${item.root}/package.json`);
2512
2520
 
2513
- if (fs$6.existsSync(packageJsonFile)) {
2521
+ if (fs$8.existsSync(packageJsonFile)) {
2514
2522
  packageJsonFiles.push(packageJsonFile);
2515
2523
  }
2516
2524
  });
@@ -2523,8 +2531,8 @@ async function mpCiInstall(tmsConfig, subPackages, useCache) {
2523
2531
  if (useCache) {
2524
2532
  let flag = true;
2525
2533
  await Promise.all(packageJsonFiles.map(async item => {
2526
- const packageDir = path$6.dirname(item);
2527
- const mpDir = resolve$a(`${packageDir}/miniprogram_npm`);
2534
+ const packageDir = path$7.dirname(item);
2535
+ const mpDir = resolve$d(`${packageDir}/miniprogram_npm`);
2528
2536
  const md5Value = await getMNPMd5(packageDir);
2529
2537
  const preCache = getCache(mpDir, 'miniprogram_npm'); // console.log('miniprogram_npm', preCache, md5Value);
2530
2538
  // 上一次构建成功 && 上次md5与当前本地的miniprogram_npm的md5 一致,才可以进入缓存
@@ -2537,14 +2545,14 @@ async function mpCiInstall(tmsConfig, subPackages, useCache) {
2537
2545
  }
2538
2546
 
2539
2547
  if (isCache) {
2540
- info$9('miniprogram_npm命中缓存');
2548
+ info$c('miniprogram_npm命中缓存');
2541
2549
  return;
2542
2550
  } // 即将构建,在cache中标记开始
2543
2551
 
2544
2552
 
2545
2553
  await Promise.all(packageJsonFiles.map(async item => {
2546
- const packageDir = path$6.dirname(item);
2547
- const mpDir = resolve$a(`${packageDir}/miniprogram_npm`);
2554
+ const packageDir = path$7.dirname(item);
2555
+ const mpDir = resolve$d(`${packageDir}/miniprogram_npm`);
2548
2556
  setCache(mpDir, 'miniprogram_npm', {
2549
2557
  md5: '',
2550
2558
  status: statusMap.doing
@@ -2552,13 +2560,13 @@ async function mpCiInstall(tmsConfig, subPackages, useCache) {
2552
2560
  }));
2553
2561
  await buildMpNpm({
2554
2562
  appId: tmsConfig.appId,
2555
- projectPath: resolve$a('./'),
2563
+ projectPath: resolve$d('./'),
2556
2564
  privateKey: tmsConfig.privateKey
2557
2565
  }); // 构建成功后,计算md5写入cache
2558
2566
 
2559
2567
  await Promise.all(packageJsonFiles.map(async item => {
2560
- const packageDir = path$6.dirname(item);
2561
- const mpDir = resolve$a(`${packageDir}/miniprogram_npm`);
2568
+ const packageDir = path$7.dirname(item);
2569
+ const mpDir = resolve$d(`${packageDir}/miniprogram_npm`);
2562
2570
  const md5Value = await getMNPMd5(packageDir);
2563
2571
  setCache(mpDir, 'miniprogram_npm', {
2564
2572
  md5: md5Value,
@@ -2575,12 +2583,12 @@ async function getMNPMd5(cwd) {
2575
2583
  };
2576
2584
  shelljs$3.cd(cwd);
2577
2585
 
2578
- if (fs$6.existsSync('miniprogram_npm')) {
2586
+ if (fs$8.existsSync('miniprogram_npm')) {
2579
2587
  shelljs$3.exec('tar -cvf ./miniprogram_npm.tar.gz ./miniprogram_npm', {
2580
2588
  cwd,
2581
2589
  ...shellJsOption
2582
2590
  });
2583
- const tarDir = path$6.join(cwd, './miniprogram_npm.tar.gz');
2591
+ const tarDir = path$7.join(cwd, './miniprogram_npm.tar.gz');
2584
2592
  const md5Value = await fileMd5(tarDir);
2585
2593
  shelljs$3.rm('-rf', tarDir);
2586
2594
  return md5Value;
@@ -2589,14 +2597,14 @@ async function getMNPMd5(cwd) {
2589
2597
  return '';
2590
2598
  }
2591
2599
 
2592
- var install_1 = install$2;
2600
+ var install_1 = install$3;
2593
2601
 
2594
- const shelljs$2 = require$$0__default$3;
2595
- const fs$5 = require$$0__default$2;
2602
+ const shelljs$2 = require$$0__default$2;
2603
+ const fs$7 = require$$0__default$1;
2596
2604
  const io = io$3;
2597
2605
  const {
2598
- resolve: resolve$9,
2599
- createTask: createTask$2
2606
+ resolve: resolve$c,
2607
+ createTask: createTask$3
2600
2608
  } = widgets;
2601
2609
  const {
2602
2610
  buildOutputAppJson: buildOutputAppJson$1
@@ -2613,10 +2621,10 @@ const {
2613
2621
  getSubPackages: getSubPackages$2
2614
2622
  } = tmsMpconfig.exports;
2615
2623
  const {
2616
- fail: fail$3,
2617
- info: info$8
2624
+ fail: fail$4,
2625
+ info: info$b
2618
2626
  } = log$1;
2619
- const install$1 = install_1;
2627
+ const install$2 = install_1;
2620
2628
  /**
2621
2629
  * 拷贝相关配置文件到编译输出目录
2622
2630
  * @param { object } tmsConfig
@@ -2626,28 +2634,28 @@ const install$1 = install_1;
2626
2634
  */
2627
2635
 
2628
2636
  const cpFilesToOutput = function (tmsConfig, defaultFiles) {
2629
- const outputDir = resolve$9(tmsConfig.outputDir);
2637
+ const outputDir = resolve$c(tmsConfig.outputDir);
2630
2638
  io.ensureDirExist(outputDir);
2631
2639
  defaultFiles.forEach(item => {
2632
- if (fs$5.existsSync(resolve$9(item))) {
2633
- shelljs$2.cp('-rf', resolve$9(item), resolve$9(tmsConfig.outputDir, item));
2640
+ if (fs$7.existsSync(resolve$c(item))) {
2641
+ shelljs$2.cp('-rf', resolve$c(item), resolve$c(tmsConfig.outputDir, item));
2634
2642
  }
2635
2643
  });
2636
2644
  };
2637
2645
 
2638
2646
  async function task(tmsConfig, targetModules) {
2639
2647
  // 下载和移动代码
2640
- await createTask$2(cloneModules, '开始下载模块代码', '下载模块代码码完成')(MODULE_CODE_DIR$1, resolve$9('./'), targetModules); // 获取所有模块,合并模块依赖的模块
2648
+ await createTask$3(cloneModules, '开始下载模块代码', '下载模块代码码完成')(MODULE_CODE_DIR$1, resolve$c('./'), targetModules); // 获取所有模块,合并模块依赖的模块
2641
2649
 
2642
2650
  const newModules = getModulesByMergeDepModules$2(tmsConfig, targetModules, true); // 获取所有的分包
2643
2651
 
2644
2652
  const newSubPackages = getSubPackages$2(newModules); // 拷贝相关配置文件到输出目录
2645
2653
 
2646
- await createTask$2(cpFilesToOutput, '开始拷贝文件到编译输出目录', '拷贝文件到编译输出目录完成')(tmsConfig, DEFAULT_COPY_CONFIG$1); // install
2654
+ await createTask$3(cpFilesToOutput, '开始拷贝文件到编译输出目录', '拷贝文件到编译输出目录完成')(tmsConfig, DEFAULT_COPY_CONFIG$1); // install
2647
2655
 
2648
- await install$1(tmsConfig, newSubPackages, true); // 动态生成编译后的app.json;
2656
+ await install$2(tmsConfig, newSubPackages, true); // 动态生成编译后的app.json;
2649
2657
 
2650
- await createTask$2(buildOutputAppJson$1, '开始生成编译后的app.json', '生成编译后的app.json完成')(tmsConfig, newModules);
2658
+ await createTask$3(buildOutputAppJson$1, '开始生成编译后的app.json', '生成编译后的app.json完成')(tmsConfig, newModules);
2651
2659
  return {
2652
2660
  modules: newModules,
2653
2661
  subPackages: newSubPackages
@@ -2660,8 +2668,8 @@ async function init$3(tmsConfig, targetModules) {
2660
2668
  return taskRes;
2661
2669
  } catch (error) {
2662
2670
  const errMsg = typeof error === 'object' ? error.message : error;
2663
- fail$3(`初始化流程出现错误: ${errMsg}`);
2664
- info$8('详细的错误信息', error);
2671
+ fail$4(`初始化流程出现错误: ${errMsg}`);
2672
+ info$b('详细的错误信息', error);
2665
2673
  process.exit(1);
2666
2674
  }
2667
2675
  }
@@ -2688,24 +2696,24 @@ function mpProjectJson$1() {
2688
2696
  var mpProjectJson_1 = mpProjectJson$1;
2689
2697
 
2690
2698
  const {
2691
- src: src$1,
2692
- dest
2693
- } = require$$0__default$9;
2694
- const path$5 = require$$1__default$1;
2699
+ src: src$2,
2700
+ dest: dest$1
2701
+ } = require$$0__default$8;
2702
+ const path$6 = require$$1__default$1;
2695
2703
  const minimatch = require$$2__default;
2696
- const gulpif = require$$3__default;
2704
+ const gulpif = require$$3__default$1;
2697
2705
  const mpProjectJson = mpProjectJson_1;
2698
2706
  const {
2699
- resolve: resolve$8
2707
+ resolve: resolve$b
2700
2708
  } = widgets;
2701
2709
  const through = require$$6__default;
2702
2710
  const {
2703
- fail: fail$2
2711
+ fail: fail$3
2704
2712
  } = log$1;
2705
2713
 
2706
- const getTargetFile$1 = (sourceFile, module, outputDir) => {
2707
- const sourceFileRelativeModule = path$5.relative(resolve$8(module.from), sourceFile);
2708
- const targetFile = resolve$8(outputDir, module.to, sourceFileRelativeModule);
2714
+ const getTargetFile$2 = (sourceFile, module, outputDir) => {
2715
+ const sourceFileRelativeModule = path$6.relative(resolve$b(module.from), sourceFile);
2716
+ const targetFile = resolve$b(outputDir, module.to, sourceFileRelativeModule);
2709
2717
  return targetFile;
2710
2718
  };
2711
2719
 
@@ -2723,7 +2731,7 @@ const addPlugins = function (tmsConfig, srcPipe, pluginParams) {
2723
2731
  tmsConfig,
2724
2732
  sourceFile,
2725
2733
  vinyl,
2726
- targetFile: getTargetFile$1(sourceFile, pluginParams.module, tmsConfig.outputDir),
2734
+ targetFile: getTargetFile$2(sourceFile, pluginParams.module, tmsConfig.outputDir),
2727
2735
  isDev: pluginParams.isDev,
2728
2736
  next
2729
2737
  });
@@ -2744,15 +2752,15 @@ var compile$1 = function (tmsConfig, {
2744
2752
  taskFn: (sourceFile, targetPath) => {
2745
2753
  const newGlobValue = Array.isArray(sourceFile) ? sourceFile : glob;
2746
2754
  const newDestPath = targetPath ? targetPath : destPath;
2747
- let srcPipe = src$1(newGlobValue, { ...srcOption
2755
+ let srcPipe = src$2(newGlobValue, { ...srcOption
2748
2756
  });
2749
2757
  const pluginParams = {
2750
2758
  module,
2751
2759
  isDev
2752
2760
  };
2753
2761
  srcPipe = addPlugins(tmsConfig, srcPipe, pluginParams);
2754
- return srcPipe.pipe(dest(newDestPath)).on('error', err => {
2755
- fail$2(`编译报错${err}`);
2762
+ return srcPipe.pipe(dest$1(newDestPath)).on('error', err => {
2763
+ fail$3(`编译报错${err}`);
2756
2764
  });
2757
2765
  }
2758
2766
  });
@@ -2762,10 +2770,10 @@ var compile$1 = function (tmsConfig, {
2762
2770
  /* eslint-disable */
2763
2771
  // 该文件源于npm包 gulp-watch 但内部有bug, 故源码进行单独修改
2764
2772
 
2765
- const assign = require$$0__default$a;
2766
- const path$4 = require$$1__default$1;
2773
+ const assign = require$$0__default$9;
2774
+ const path$5 = require$$1__default$1;
2767
2775
  const PluginError = require$$2__default$1;
2768
- const fancyLog = require$$3__default$1;
2776
+ const fancyLog = require$$3__default$2;
2769
2777
  const colors = require$$4__default$1;
2770
2778
  const chokidar = require$$5__default;
2771
2779
  const {
@@ -2794,7 +2802,7 @@ function normalizeGlobs(globs) {
2794
2802
  return globs;
2795
2803
  }
2796
2804
 
2797
- function watch$2(globs, opts, cb) {
2805
+ function watch$3(globs, opts, cb) {
2798
2806
  globs = normalizeGlobs(globs);
2799
2807
 
2800
2808
  if (typeof opts === 'function') {
@@ -2802,16 +2810,16 @@ function watch$2(globs, opts, cb) {
2802
2810
  opts = {};
2803
2811
  }
2804
2812
 
2805
- opts = assign({}, watch$2._defaultOptions, opts);
2813
+ opts = assign({}, watch$3._defaultOptions, opts);
2806
2814
 
2807
2815
  cb = cb || function () {};
2808
2816
 
2809
2817
  function resolveFilepath(filepath) {
2810
2818
  if (pathIsAbsolute(filepath)) {
2811
- return path$4.normalize(filepath);
2819
+ return path$5.normalize(filepath);
2812
2820
  }
2813
2821
 
2814
- return path$4.resolve(opts.cwd || process.cwd(), filepath);
2822
+ return path$5.resolve(opts.cwd || process.cwd(), filepath);
2815
2823
  }
2816
2824
 
2817
2825
  function resolveGlob(glob) {
@@ -2867,7 +2875,7 @@ function watch$2(globs, opts, cb) {
2867
2875
  let glob;
2868
2876
  let currentFilepath = filepath;
2869
2877
 
2870
- while (!(glob = globs[anymatch(globs, currentFilepath, true)]) && currentFilepath !== (currentFilepath = path$4.dirname(currentFilepath))) {} // eslint-disable-line no-empty-blocks/no-empty-blocks
2878
+ while (!(glob = globs[anymatch(globs, currentFilepath, true)]) && currentFilepath !== (currentFilepath = path$5.dirname(currentFilepath))) {} // eslint-disable-line no-empty-blocks/no-empty-blocks
2871
2879
 
2872
2880
 
2873
2881
  if (!glob) {
@@ -2876,7 +2884,7 @@ function watch$2(globs, opts, cb) {
2876
2884
  }
2877
2885
 
2878
2886
  if (!baseForced) {
2879
- fileOpts.base = path$4.normalize(globParent(glob));
2887
+ fileOpts.base = path$5.normalize(globParent(glob));
2880
2888
  } // Do not stat deleted files
2881
2889
 
2882
2890
 
@@ -2927,27 +2935,27 @@ function watch$2(globs, opts, cb) {
2927
2935
  // Avoid modifying gulp-watch's default options inside a library/reusable package, please.
2928
2936
 
2929
2937
 
2930
- watch$2._defaultOptions = {
2938
+ watch$3._defaultOptions = {
2931
2939
  events: ['add', 'change', 'unlink'],
2932
2940
  ignoreInitial: true,
2933
2941
  readDelay: 10
2934
2942
  };
2935
- var gulpWatch = watch$2;
2943
+ var gulpWatch = watch$3;
2936
2944
 
2937
2945
  /* eslint-disable no-restricted-syntax */
2938
- const watch$1 = gulpWatch;
2939
- const path$3 = require$$1__default$1;
2940
- const shellJs = require$$0__default$3;
2946
+ const watch$2 = gulpWatch;
2947
+ const path$4 = require$$1__default$1;
2948
+ const shellJs$2 = require$$0__default$2;
2941
2949
  const {
2942
- series: series$1
2943
- } = require$$0__default$9;
2950
+ series: series$2
2951
+ } = require$$0__default$8;
2944
2952
  const {
2945
- info: info$7,
2953
+ info: info$a,
2946
2954
  warn: warn$1,
2947
- fail: fail$1
2955
+ fail: fail$2
2948
2956
  } = log$1;
2949
2957
  const {
2950
- resolve: resolve$7,
2958
+ resolve: resolve$a,
2951
2959
  filterField: filterField$5
2952
2960
  } = widgets;
2953
2961
  const {
@@ -2985,31 +2993,31 @@ const logTip = (fileName, sourceFile, targetFile, tipMap) => {
2985
2993
  }
2986
2994
  }
2987
2995
 
2988
- info$7(`${fileName}有更新`);
2996
+ info$a(`${fileName}有更新`);
2989
2997
  } catch (e) {
2990
- fail$1(`${sourceFile}文件更新提示出现错误: ${e.message}`);
2998
+ fail$2(`${sourceFile}文件更新提示出现错误: ${e.message}`);
2991
2999
  }
2992
3000
  };
2993
3001
 
2994
- const getTargetFile = (sourceFile, module, outputDir) => {
2995
- const sourceFileRelativeModule = path$3.relative(resolve$7(module.from), sourceFile);
2996
- const targetFile = resolve$7(outputDir, module.to, sourceFileRelativeModule);
3002
+ const getTargetFile$1 = (sourceFile, module, outputDir) => {
3003
+ const sourceFileRelativeModule = path$4.relative(resolve$a(module.from), sourceFile);
3004
+ const targetFile = resolve$a(outputDir, module.to, sourceFileRelativeModule);
2997
3005
  return targetFile;
2998
3006
  };
2999
3007
 
3000
3008
  var watch_1 = function (globValue, watchOptions, callback, module) {
3001
- watch$1(globValue, { // readDelay: 100,
3009
+ watch$2(globValue, { // readDelay: 100,
3002
3010
  ...watchOptions
3003
3011
  }, vinyl => {
3004
3012
  const sourceFile = vinyl.history[0];
3005
3013
  const sourceFileDirArr = sourceFile.replace(/\\/g, '/').split('/');
3006
3014
  const sourceFileName = sourceFileDirArr.slice(sourceFileDirArr.length - 2).join('/');
3007
3015
  const tmsConfig = global$6.getData('tmsConfig');
3008
- const targetFile = getTargetFile(sourceFile, module, tmsConfig.outputDir);
3016
+ const targetFile = getTargetFile$1(sourceFile, module, tmsConfig.outputDir);
3009
3017
 
3010
3018
  if (vinyl.event === 'unlink' || vinyl.event === 'unlinkDir') {
3011
- info$7(`删除${sourceFileName}`);
3012
- shellJs.rm('-rf', targetFile);
3019
+ info$a(`删除${sourceFileName}`);
3020
+ shellJs$2.rm('-rf', targetFile);
3013
3021
  updateFileHook(tmsConfig, sourceFile, targetFile, vinyl.event);
3014
3022
  return;
3015
3023
  }
@@ -3036,13 +3044,13 @@ async function runCallback({
3036
3044
  // callbacl.name === taskFn 代表进入gulp编译流程
3037
3045
  // series为gulp编译串行执行,callback执行完毕后,执行updateFileHooks钩子
3038
3046
  if (callback.name === 'taskFn') {
3039
- series$1(callback.bind(null, [sourceFile], path$3.dirname(targetFile)), cb => {
3047
+ series$2(callback.bind(null, [sourceFile], path$4.dirname(targetFile)), cb => {
3040
3048
  cb();
3041
3049
  updateFileHook(tmsConfig, sourceFile, targetFile, type);
3042
3050
  })();
3043
3051
  } else {
3044
3052
  // 普通的callback函数
3045
- await callback([sourceFile], path$3.dirname(targetFile));
3053
+ await callback([sourceFile], path$4.dirname(targetFile));
3046
3054
  await updateFileHook(tmsConfig, sourceFile, targetFile, type);
3047
3055
  }
3048
3056
  } // 执行源码文件更新的钩子
@@ -3063,19 +3071,19 @@ async function updateFileHook(tmsConfig, sourceFile, targetFile, type) {
3063
3071
  }
3064
3072
  }
3065
3073
 
3066
- const path$2 = require$$1__default$1;
3067
- const fs$4 = require$$0__default$2;
3068
- const ora = require$$0__default$1;
3069
- const chalk$2 = require$$0__default;
3074
+ const path$3 = require$$1__default$1;
3075
+ const fs$6 = require$$0__default$1;
3076
+ const ora$1 = require$$0__default;
3077
+ const chalk$3 = require$$3__default;
3070
3078
  const {
3071
- parallel,
3072
- series
3073
- } = require$$0__default$9;
3079
+ parallel: parallel$1,
3080
+ series: series$1
3081
+ } = require$$0__default$8;
3074
3082
  const {
3075
- resolve: resolve$6,
3083
+ resolve: resolve$9,
3076
3084
  mergeMap,
3077
3085
  filterField: filterField$4,
3078
- getAbsolutePath: getAbsolutePath$2
3086
+ getAbsolutePath: getAbsolutePath$3
3079
3087
  } = widgets;
3080
3088
  const {
3081
3089
  buildOutputAppJson
@@ -3084,9 +3092,9 @@ const {
3084
3092
  DEFAULT_COPY_CONFIG
3085
3093
  } = constant;
3086
3094
  const compile = compile$1;
3087
- const watch = watch_1;
3095
+ const watch$1 = watch_1;
3088
3096
  const {
3089
- info: info$6
3097
+ info: info$9
3090
3098
  } = log$1;
3091
3099
  const report$6 = report_1;
3092
3100
  const {
@@ -3094,16 +3102,16 @@ const {
3094
3102
  } = global_1;
3095
3103
  const watchEvents = ['add', 'change', 'unlink', 'addDir', 'unlinkDir'];
3096
3104
 
3097
- var dev$3 = async (tmsConfig, modules, isDev = true) => {
3105
+ var dev$4 = async (tmsConfig, modules, isDev = true) => {
3098
3106
  const compileTasksMap = new Map(); // 监听根目录的文件
3099
3107
 
3100
3108
  mergeMap(compileTasksMap, compile(tmsConfig, {
3101
- glob: DEFAULT_COPY_CONFIG.map(item => resolve$6(item)),
3109
+ glob: DEFAULT_COPY_CONFIG.map(item => resolve$9(item)),
3102
3110
  module: {
3103
- from: resolve$6(),
3104
- to: resolve$6(tmsConfig.outputDir)
3111
+ from: resolve$9(),
3112
+ to: resolve$9(tmsConfig.outputDir)
3105
3113
  },
3106
- destPath: resolve$6(tmsConfig.outputDir),
3114
+ destPath: resolve$9(tmsConfig.outputDir),
3107
3115
  srcOption: {
3108
3116
  allowEmpty: true
3109
3117
  },
@@ -3117,12 +3125,12 @@ var dev$3 = async (tmsConfig, modules, isDev = true) => {
3117
3125
  },
3118
3126
  ...moduleItem
3119
3127
  };
3120
- const srcModulePath = getAbsolutePath$2(moduleItem.path);
3121
- const buildModulePath = resolve$6(tmsConfig.outputDir, moduleItem.modulePath);
3128
+ const srcModulePath = getAbsolutePath$3(moduleItem.path);
3129
+ const buildModulePath = resolve$9(tmsConfig.outputDir, moduleItem.modulePath);
3122
3130
 
3123
3131
  if (isDev) {
3124
3132
  // 监听模块配置文件
3125
- watch([`${srcModulePath}/**/module.config.json`], {
3133
+ watch$1([`${srcModulePath}/**/module.config.json`], {
3126
3134
  events: watchEvents
3127
3135
  }, () => buildOutputAppJson(tmsConfig, modules, isDev), {
3128
3136
  from: srcModulePath,
@@ -3131,14 +3139,14 @@ var dev$3 = async (tmsConfig, modules, isDev = true) => {
3131
3139
  }
3132
3140
 
3133
3141
  const excludes = moduleItem.exclude.map(ePath => {
3134
- const newPath = getAbsolutePath$2(ePath, srcModulePath);
3135
- const ext = path$2.extname(ePath).slice(1);
3142
+ const newPath = getAbsolutePath$3(ePath, srcModulePath);
3143
+ const ext = path$3.extname(ePath).slice(1);
3136
3144
 
3137
3145
  if (ext) {
3138
- return `!${resolve$6(srcModulePath, newPath)}`;
3146
+ return `!${resolve$9(srcModulePath, newPath)}`;
3139
3147
  }
3140
3148
 
3141
- return `!${resolve$6(srcModulePath, newPath)}/**/*`;
3149
+ return `!${resolve$9(srcModulePath, newPath)}/**/*`;
3142
3150
  });
3143
3151
  mergeMap(compileTasksMap, compile(tmsConfig, {
3144
3152
  glob: [`${srcModulePath}/**/*`, `!${srcModulePath}/**/module.config.json`, ...excludes],
@@ -3157,10 +3165,10 @@ var dev$3 = async (tmsConfig, modules, isDev = true) => {
3157
3165
 
3158
3166
  if (tmsConfig !== null && tmsConfig !== void 0 && tmsConfig.static && (tmsConfig === null || tmsConfig === void 0 ? void 0 : tmsConfig.static.length) > 0) {
3159
3167
  for (const item of tmsConfig.static) {
3160
- item.from = getAbsolutePath$2(item.from);
3161
- item.to = getAbsolutePath$2(item.to);
3168
+ item.from = getAbsolutePath$3(item.from);
3169
+ item.to = getAbsolutePath$3(item.to);
3162
3170
  let glob = {};
3163
- const ext = path$2.extname(item.from).slice(1);
3171
+ const ext = path$3.extname(item.from).slice(1);
3164
3172
 
3165
3173
  if (ext) {
3166
3174
  glob = [item.from];
@@ -3168,7 +3176,7 @@ var dev$3 = async (tmsConfig, modules, isDev = true) => {
3168
3176
  glob = [`${item.from}/**/*`];
3169
3177
  }
3170
3178
 
3171
- const from = fs$4.lstatSync(item.from).isFile() ? path$2.dirname(item.from) : item.from;
3179
+ const from = fs$6.lstatSync(item.from).isFile() ? path$3.dirname(item.from) : item.from;
3172
3180
  mergeMap(compileTasksMap, compile(tmsConfig, {
3173
3181
  glob,
3174
3182
  destPath: item.to,
@@ -3186,10 +3194,10 @@ var dev$3 = async (tmsConfig, modules, isDev = true) => {
3186
3194
 
3187
3195
  let sTime;
3188
3196
  let eTime;
3189
- const spinner = ora();
3197
+ const spinner = ora$1();
3190
3198
 
3191
3199
  function start(cb) {
3192
- info$6('启动编译...');
3200
+ info$9('启动编译...');
3193
3201
  spinner.start();
3194
3202
  sTime = new Date().getTime();
3195
3203
  cb();
@@ -3200,19 +3208,19 @@ var dev$3 = async (tmsConfig, modules, isDev = true) => {
3200
3208
 
3201
3209
  if (isDev) {
3202
3210
  // 监听app.json
3203
- watch([resolve$6('app.json')], {
3211
+ watch$1([resolve$9('app.json')], {
3204
3212
  ignoreInitial: false,
3205
3213
  events: watchEvents
3206
3214
  }, () => buildOutputAppJson(tmsConfig, modules, isDev), {
3207
- from: resolve$6(),
3208
- to: resolve$6(tmsConfig.outputDir)
3215
+ from: resolve$9(),
3216
+ to: resolve$9(tmsConfig.outputDir)
3209
3217
  }); // 监听其他文件
3210
3218
 
3211
3219
  compileTasksMap.forEach(({
3212
3220
  taskFn,
3213
3221
  module
3214
3222
  }, globValue) => {
3215
- watch(globValue, {
3223
+ watch$1(globValue, {
3216
3224
  ignoreInitial: true,
3217
3225
  events: watchEvents
3218
3226
  }, taskFn, module);
@@ -3235,7 +3243,7 @@ var dev$3 = async (tmsConfig, modules, isDev = true) => {
3235
3243
  report$6('hooks:afterCompile');
3236
3244
  }
3237
3245
 
3238
- spinner.succeed(chalk$2.green(`首次编译完成, 耗时${eTime / 1000}s, 微信开发者工具打开项目即可预览。`));
3246
+ spinner.succeed(chalk$3.green(`首次编译完成, 耗时${eTime / 1000}s, 微信开发者工具打开项目即可预览。`));
3239
3247
  spinner.stop();
3240
3248
  cb();
3241
3249
  }
@@ -3247,13 +3255,13 @@ var dev$3 = async (tmsConfig, modules, isDev = true) => {
3247
3255
  compileTasks.push(taskFn);
3248
3256
  }); // 一次性完成编译任务(编译完成后再添加watch任务-封装到end函数里面)
3249
3257
 
3250
- series(start, parallel(...compileTasks), end)();
3258
+ series$1(start, parallel$1(...compileTasks), end)();
3251
3259
  };
3252
3260
 
3253
- const shelljs$1 = require$$0__default$3;
3254
- const compileDev = dev$3;
3261
+ const shelljs$1 = require$$0__default$2;
3262
+ const compileDev = dev$4;
3255
3263
  const {
3256
- resolve: resolve$5,
3264
+ resolve: resolve$8,
3257
3265
  filterField: filterField$3
3258
3266
  } = widgets;
3259
3267
  const init$2 = init_1;
@@ -3262,7 +3270,7 @@ const {
3262
3270
  getSubPackages: getSubPackages$1
3263
3271
  } = tmsMpconfig.exports;
3264
3272
  const {
3265
- info: info$5
3273
+ info: info$8
3266
3274
  } = log$1;
3267
3275
  const {
3268
3276
  global: global$4
@@ -3282,7 +3290,7 @@ function delOtherPackages(tmsConfig, targetSubPackages) {
3282
3290
  const targetSubPackagesName = targetSubPackages.map(item => item.name);
3283
3291
  allSubPackages.forEach(item => {
3284
3292
  if (item.root && targetSubPackagesName.indexOf(item.name) === -1) {
3285
- const moduleRootDir = resolve$5(`${tmsConfig.outputDir}/${item.root}`);
3293
+ const moduleRootDir = resolve$8(`${tmsConfig.outputDir}/${item.root}`);
3286
3294
  shelljs$1.rm('-rf', `${moduleRootDir}/*`, {
3287
3295
  silent: true
3288
3296
  }); // 解决微信开发者工具(dist/app.json: ["subpackages"][0]["root"] 字段需为 目录)错误 - 提前创建该目录
@@ -3291,7 +3299,7 @@ function delOtherPackages(tmsConfig, targetSubPackages) {
3291
3299
  });
3292
3300
  }
3293
3301
 
3294
- async function dev$2(tmsConfig, targetModules) {
3302
+ async function dev$3(tmsConfig, targetModules) {
3295
3303
  var _tmsConfig$hooks;
3296
3304
 
3297
3305
  const {
@@ -3299,7 +3307,7 @@ async function dev$2(tmsConfig, targetModules) {
3299
3307
  } = global$4.getData('cmdOptions');
3300
3308
 
3301
3309
  if (noCache) {
3302
- shelljs$1.rm('-rf', resolve$5(tmsConfig.outputDir));
3310
+ shelljs$1.rm('-rf', resolve$8(tmsConfig.outputDir));
3303
3311
  shelljs$1.rm('-rf', MODULE_CODE_DIR);
3304
3312
  shelljs$1.rm('-rf', NODE_MODULES_DIR);
3305
3313
  } // 推荐tmskit的版本
@@ -3311,7 +3319,7 @@ async function dev$2(tmsConfig, targetModules) {
3311
3319
  subPackages,
3312
3320
  modules: newModules
3313
3321
  } = await init$2(tmsConfig, targetModules);
3314
- info$5('当前dev启动的有效模块', newModules.map(item => item.moduleName).sort());
3322
+ info$8('当前dev启动的有效模块', newModules.map(item => item.moduleName).sort());
3315
3323
 
3316
3324
  if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforeFirstCompile) === 'function') {
3317
3325
  var _tmsConfig$hooks2;
@@ -3328,22 +3336,22 @@ async function dev$2(tmsConfig, targetModules) {
3328
3336
  compileDev(tmsConfig, newModules, true);
3329
3337
  }
3330
3338
 
3331
- var dev_1 = dev$2;
3339
+ var dev_1 = dev$3;
3332
3340
 
3333
- const dev$1 = dev$3;
3341
+ const dev$2 = dev$4;
3334
3342
 
3335
3343
  var build$2 = async (tmsConfig, newModules, isDev) => {
3336
- dev$1(tmsConfig, newModules, isDev);
3344
+ dev$2(tmsConfig, newModules, isDev);
3337
3345
  };
3338
3346
 
3339
- const shelljs = require$$0__default$3;
3347
+ const shelljs = require$$0__default$2;
3340
3348
  const {
3341
- resolve: resolve$4,
3349
+ resolve: resolve$7,
3342
3350
  filterField: filterField$2
3343
3351
  } = widgets;
3344
3352
  const init$1 = init_1;
3345
3353
  const {
3346
- info: info$4
3354
+ info: info$7
3347
3355
  } = log$1;
3348
3356
  const compileBuild = build$2;
3349
3357
  const report$4 = report_1;
@@ -3355,11 +3363,11 @@ async function build$1(tmsConfig, targetModules) {
3355
3363
  var _tmsConfig$hooks;
3356
3364
 
3357
3365
  // 开始构建前,清理输出目录
3358
- await shelljs.rm('-rf', resolve$4(tmsConfig.outputDir));
3366
+ await shelljs.rm('-rf', resolve$7(tmsConfig.outputDir));
3359
3367
  const {
3360
3368
  modules: newModules
3361
3369
  } = await init$1(tmsConfig, targetModules);
3362
- info$4('当前build有效模块', newModules.map(item => item.moduleName).sort());
3370
+ info$7('当前build有效模块', newModules.map(item => item.moduleName).sort());
3363
3371
  const isDev = false;
3364
3372
 
3365
3373
  if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforeFirstCompile) === 'function') {
@@ -3379,14 +3387,14 @@ async function build$1(tmsConfig, targetModules) {
3379
3387
  var build_1 = build$1;
3380
3388
 
3381
3389
  const moment = require$$1__default;
3382
- const path$1 = require$$1__default$1;
3383
- const fs$3 = require$$0__default$2;
3390
+ const path$2 = require$$1__default$1;
3391
+ const fs$5 = require$$0__default$1;
3384
3392
  const {
3385
3393
  getGitUser,
3386
- getAbsolutePath: getAbsolutePath$1
3394
+ getAbsolutePath: getAbsolutePath$2
3387
3395
  } = widgets;
3388
3396
  const {
3389
- ensureDirExist: ensureDirExist$1
3397
+ ensureDirExist: ensureDirExist$3
3390
3398
  } = io$3;
3391
3399
 
3392
3400
  function getAllSize$2(data = {}) {
@@ -3409,10 +3417,10 @@ const getDesc$2 = (desc = '') => {
3409
3417
  };
3410
3418
 
3411
3419
  const outputInfo$2 = (infoOutput, data) => {
3412
- const outPath = getAbsolutePath$1(infoOutput);
3413
- const dir = path$1.dirname(outPath);
3414
- ensureDirExist$1(dir);
3415
- fs$3.writeFileSync(outPath, JSON.stringify(data, null, 2));
3420
+ const outPath = getAbsolutePath$2(infoOutput);
3421
+ const dir = path$2.dirname(outPath);
3422
+ ensureDirExist$3(dir);
3423
+ fs$5.writeFileSync(outPath, JSON.stringify(data, null, 2));
3416
3424
  };
3417
3425
 
3418
3426
  const getDetaultVersion = () => {
@@ -3429,18 +3437,18 @@ var utils = {
3429
3437
  };
3430
3438
 
3431
3439
  const mpCi$1 = mpCi$2;
3432
- const fs$2 = require$$0__default$2;
3440
+ const fs$4 = require$$0__default$1;
3433
3441
  const {
3434
- resolve: resolve$3,
3435
- createTask: createTask$1,
3436
- getAbsolutePath,
3442
+ resolve: resolve$6,
3443
+ createTask: createTask$2,
3444
+ getAbsolutePath: getAbsolutePath$1,
3437
3445
  filterField: filterField$1
3438
3446
  } = widgets;
3439
3447
  const {
3440
- handleError: handleError$2
3448
+ handleError: handleError$3
3441
3449
  } = handleError_1;
3442
3450
  const {
3443
- info: info$3
3451
+ info: info$6
3444
3452
  } = log$1;
3445
3453
  const {
3446
3454
  global: global$2
@@ -3458,11 +3466,11 @@ const handleParams$1 = (tmsConfig, cmdOptions) => {
3458
3466
  };
3459
3467
  return { ...params,
3460
3468
  appId: params.appId || tmsConfig.appId,
3461
- projectPath: resolve$3(tmsConfig.outputDir),
3469
+ projectPath: resolve$6(tmsConfig.outputDir),
3462
3470
  privateKey: params.privateKey || tmsConfig.privateKey,
3463
3471
  robot: params.robot || 30,
3464
3472
  desc: params.desc || getDesc$1(params.desc),
3465
- qrcodeOutputDest: getAbsolutePath(params.qrcodeOutputDest || '')
3473
+ qrcodeOutputDest: getAbsolutePath$1(params.qrcodeOutputDest || '')
3466
3474
  };
3467
3475
  };
3468
3476
  /**
@@ -3490,15 +3498,15 @@ async function preview$1(tmsConfig, cmdOptions) {
3490
3498
  }
3491
3499
 
3492
3500
  ;
3493
- const previewRes = await createTask$1(mpCi$1.previewMp, '正在构建预览码', '构建预览码完成')({ ...params
3501
+ const previewRes = await createTask$2(mpCi$1.previewMp, '正在构建预览码', '构建预览码完成')({ ...params
3494
3502
  });
3495
3503
  const allSize = getAllSize$1(previewRes);
3496
3504
 
3497
3505
  if (params.infoOutput) {
3498
3506
  let qrcodeBase64 = '';
3499
3507
 
3500
- if (params.qrcodeFormat === 'base64' && fs$2.existsSync(params.qrcodeOutputDest)) {
3501
- qrcodeBase64 = fs$2.readFileSync(params.qrcodeOutputDest, 'utf8');
3508
+ if (params.qrcodeFormat === 'base64' && fs$4.existsSync(params.qrcodeOutputDest)) {
3509
+ qrcodeBase64 = fs$4.readFileSync(params.qrcodeOutputDest, 'utf8');
3502
3510
  }
3503
3511
 
3504
3512
  outputInfo$1(params.infoOutput, {
@@ -3508,10 +3516,10 @@ async function preview$1(tmsConfig, cmdOptions) {
3508
3516
  });
3509
3517
  }
3510
3518
 
3511
- info$3('预览包大小:', `${allSize}k`);
3519
+ info$6('预览包大小:', `${allSize}k`);
3512
3520
  } catch (e) {
3513
3521
  console.log('详细错误:', e);
3514
- handleError$2(`预览错误: ${e.message}`, true);
3522
+ handleError$3(`预览错误: ${e.message}`, true);
3515
3523
  }
3516
3524
  }
3517
3525
 
@@ -3519,15 +3527,15 @@ var preview_1 = preview$1;
3519
3527
 
3520
3528
  const mpCi = mpCi$2;
3521
3529
  const {
3522
- resolve: resolve$2,
3523
- createTask,
3530
+ resolve: resolve$5,
3531
+ createTask: createTask$1,
3524
3532
  filterField
3525
3533
  } = widgets;
3526
3534
  const {
3527
- handleError: handleError$1
3535
+ handleError: handleError$2
3528
3536
  } = handleError_1;
3529
3537
  const {
3530
- info: info$2
3538
+ info: info$5
3531
3539
  } = log$1;
3532
3540
  const {
3533
3541
  global: global$1
@@ -3550,7 +3558,7 @@ const handleParams = (tmsConfig, cmdOptions) => {
3550
3558
 
3551
3559
  return { ...params,
3552
3560
  appId: params.appId || tmsConfig.appId,
3553
- projectPath: resolve$2(tmsConfig.outputDir),
3561
+ projectPath: resolve$5(tmsConfig.outputDir),
3554
3562
  privateKey: params.privateKey || tmsConfig.privateKey,
3555
3563
  robot: params.robot || 30,
3556
3564
  desc: params.desc || getDesc(params.desc)
@@ -3581,7 +3589,7 @@ async function upload$1(tmsConfig, cmdOptions) {
3581
3589
  }
3582
3590
 
3583
3591
  ;
3584
- const uploadRes = await createTask(mpCi.uploadMp, '正在上传小程序代码', '上传小程序代码完成')({ ...params
3592
+ const uploadRes = await createTask$1(mpCi.uploadMp, '正在上传小程序代码', '上传小程序代码完成')({ ...params
3585
3593
  });
3586
3594
  const allSize = getAllSize(uploadRes);
3587
3595
 
@@ -3592,70 +3600,358 @@ async function upload$1(tmsConfig, cmdOptions) {
3592
3600
  });
3593
3601
  }
3594
3602
 
3595
- info$2(`上传包大小: ${allSize}k; 上传包版本: ${params.version}`);
3603
+ info$5(`上传包大小: ${allSize}k; 上传包版本: ${params.version}`);
3596
3604
  } catch (e) {
3597
3605
  console.log('详细错误:', e);
3598
- handleError$1(`上传错误: ${e.message}`, true);
3606
+ handleError$2(`上传错误: ${e.message}`, true);
3599
3607
  }
3600
3608
  }
3601
3609
 
3602
3610
  var upload_1 = upload$1;
3603
3611
 
3604
- const fs$1 = require$$0__default$2;
3605
3612
  const {
3606
- resolve: resolve$1
3613
+ resolve: resolve$4,
3614
+ getAbsolutePath
3615
+ } = widgets; // 处理tms.config.cloudModules的兼容数据
3616
+
3617
+ function getTmsCloudModules(tmsConfig) {
3618
+ const {
3619
+ cloudModules
3620
+ } = tmsConfig;
3621
+
3622
+ if (Array.isArray(tmsConfig.cloudModules)) {
3623
+ return {
3624
+ all: [...tmsConfig.cloudModules],
3625
+ include: []
3626
+ };
3627
+ }
3628
+
3629
+ return cloudModules;
3630
+ }
3631
+ /**
3632
+ * 获取需要监听的云函数
3633
+ * @param {*} tmsConfig {}
3634
+ * @param {*} cmdOptions eg:{clouds: 'aggrecarshop,car'}
3635
+ * @returns
3636
+ * [{ name: '', sourcePath: '', targetPath: ''}]
3637
+ */
3638
+
3639
+
3640
+ function getCloudsOfListen$2(tmsConfig, cmdOptions) {
3641
+ var _cmdOptions$cloud;
3642
+
3643
+ // 获取tmsconfig配置的云函数的配置项
3644
+ const cloudModules = getTmsCloudModules(tmsConfig);
3645
+ let includeClouds = (cmdOptions === null || cmdOptions === void 0 ? void 0 : (_cmdOptions$cloud = cmdOptions.cloud) === null || _cmdOptions$cloud === void 0 ? void 0 : _cmdOptions$cloud.split(',')) || cloudModules.include || []; // 如果没有配置include, 默认使用所有的数据云函数列表
3646
+
3647
+ if (includeClouds.length === 0) {
3648
+ includeClouds = cloudModules.all.map(item => item.name);
3649
+ }
3650
+
3651
+ const result = [];
3652
+
3653
+ for (const item of cloudModules.all) {
3654
+ if (includeClouds.includes(item.name)) {
3655
+ result.push({
3656
+ name: item.name,
3657
+ sourcePath: `${getAbsolutePath(item.path)}`,
3658
+ targetPath: resolve$4(tmsConfig.cloudDir, item.name)
3659
+ });
3660
+ }
3661
+ }
3662
+
3663
+ return result;
3664
+ }
3665
+
3666
+ var getClouds = getCloudsOfListen$2;
3667
+
3668
+ const fs$3 = require$$0__default$1;
3669
+ /**
3670
+ * 检查云函数的配置项
3671
+ * @param {*} tmsConfig
3672
+ */
3673
+
3674
+ function checkCloudConfig$2(tmsConfig) {
3675
+ if (!tmsConfig.cloudModules) {
3676
+ return '你没有在tms.config.js的cloudModules注册云函数';
3677
+ }
3678
+
3679
+ if (!tmsConfig.cloudDir) {
3680
+ return '你没有在tms.config.js配置云函数编译目录cloudDir';
3681
+ }
3682
+
3683
+ return;
3684
+ }
3685
+ /**
3686
+ * 检查云函数源码目录是否存在
3687
+ * @param {Array} clouds [{name: '', sourcePath: '', targetPath: ''}]
3688
+ */
3689
+
3690
+
3691
+ function checkSrcPathIsExist$1(clouds) {
3692
+ for (const item of clouds) {
3693
+ if (!fs$3.existsSync(item.sourcePath)) {
3694
+ return `${item.name}云函数的${item.sourcePath}目录不存在, 请检查tms.config.js>cloudModules>all云函数的配置目录`;
3695
+ }
3696
+ }
3697
+
3698
+ return;
3699
+ }
3700
+
3701
+ var check$2 = {
3702
+ checkCloudConfig: checkCloudConfig$2,
3703
+ checkSrcPathIsExist: checkSrcPathIsExist$1
3704
+ };
3705
+
3706
+ const fs$2 = require$$0__default$1;
3707
+ const {
3708
+ info: info$4
3709
+ } = log$1;
3710
+ const {
3711
+ resolve: resolve$3
3607
3712
  } = widgets;
3608
3713
  const {
3609
- ensureDirExist
3714
+ ensureDirExist: ensureDirExist$2
3610
3715
  } = io$3;
3611
3716
  const {
3612
3717
  warn,
3613
3718
  succeed
3614
3719
  } = log$1;
3615
- /**
3616
- * 根据相关配置创建软链接
3617
- * @param { object } tmsConfig
3618
- */
3720
+ const getCloudsOfListen$1 = getClouds;
3721
+ const {
3722
+ handleError: handleError$1
3723
+ } = handleError_1;
3724
+ const {
3725
+ checkCloudConfig: checkCloudConfig$1
3726
+ } = check$2;
3619
3727
 
3620
- const symLink$1 = tmsConfig => {
3621
- ensureDirExist(resolve$1(tmsConfig.cloudDir));
3728
+ var link = async (tmsConfig, cmdOptions) => {
3729
+ try {
3730
+ ensureDirExist$2(resolve$3(tmsConfig.cloudDir));
3731
+ checkCloudConfig$1(tmsConfig); // 获取需要监听的云函数列表
3622
3732
 
3623
- if (tmsConfig.cloudModules) {
3624
- tmsConfig.cloudModules.forEach(item => {
3625
- const sourcePath = resolve$1(item.path);
3626
- const targetPath = resolve$1(tmsConfig.cloudDir, item.name);
3733
+ const clouds = getCloudsOfListen$1(tmsConfig, cmdOptions); // 打印启动云函数列表
3627
3734
 
3628
- if (!fs$1.existsSync(sourcePath)) {
3629
- warn(`云函数${sourcePath}不存在`);
3735
+ info$4('当前启动云函数列表:', clouds.map(item => item.name).sort());
3736
+ clouds.forEach(item => {
3737
+ if (!fs$2.existsSync(item.sourcePath)) {
3738
+ warn(`云函数${item.sourcePath}不存在`);
3630
3739
  return;
3631
3740
  }
3632
3741
 
3633
- if (!fs$1.existsSync(targetPath)) {
3634
- fs$1.symlinkSync(sourcePath, targetPath);
3742
+ const stat = fs$2.lstatSync(item.targetPath);
3743
+
3744
+ if (!stat.isSymbolicLink()) {
3745
+ fs$2.symlinkSync(item.sourcePath, item.targetPath);
3635
3746
  }
3636
3747
  });
3637
3748
  succeed('云函数创建软链成功');
3638
- } else {
3639
- warn('你没有在tms.config.js的cloudModules注册云函数');
3749
+ } catch (e) {
3750
+ info$4('创建软链详细错误', e);
3751
+ handleError$1(`创建软链错误: ${e}`, true);
3640
3752
  }
3641
3753
  };
3642
3754
 
3643
- var symbolicLink = {
3644
- symLink: symLink$1
3755
+ const shellJs$1 = require$$0__default$2;
3756
+ const fs$1 = require$$0__default$1;
3757
+ const {
3758
+ resolve: resolve$2,
3759
+ npmInstall
3760
+ } = widgets;
3761
+ const {
3762
+ ensureDirExist: ensureDirExist$1
3763
+ } = io$3;
3764
+ const {
3765
+ info: info$3
3766
+ } = log$1;
3767
+ /**
3768
+ * npm install
3769
+ * @param {array} clouds [{name: '', sourcePath: '', targetPath: ''}]
3770
+ */
3771
+
3772
+ const runInstall$1 = async (clouds, tmsConfig) => {
3773
+ const promises = [];
3774
+
3775
+ for (const item of clouds) {
3776
+ ensureDirExist$1(item.targetPath);
3777
+ const packageFilePath = resolve$2(item.sourcePath, 'package.json');
3778
+
3779
+ if (fs$1.existsSync(packageFilePath)) {
3780
+ shellJs$1.cp('-Rf', resolve$2(packageFilePath), item.targetPath);
3781
+ promises.push(() => {
3782
+ info$3(`云函数${item.name}: npm install`);
3783
+ return npmInstall(item.targetPath, tmsConfig.npm);
3784
+ });
3785
+ }
3786
+ }
3787
+ await Promise.all(promises.map(item => item()));
3788
+ };
3789
+
3790
+ var install$1 = {
3791
+ runInstall: runInstall$1
3645
3792
  };
3646
3793
 
3794
+ const shellJs = require$$0__default$2;
3795
+ const ora = require$$0__default;
3796
+ const path$1 = require$$1__default$1;
3797
+ const chalk$2 = require$$3__default;
3647
3798
  const {
3648
- symLink
3649
- } = symbolicLink;
3799
+ resolve: resolve$1,
3800
+ createTask
3801
+ } = widgets;
3650
3802
  const {
3651
3803
  handleError
3652
3804
  } = handleError_1;
3805
+ const {
3806
+ ensureDirExist
3807
+ } = io$3;
3808
+ const {
3809
+ src: src$1,
3810
+ dest,
3811
+ parallel,
3812
+ series
3813
+ } = require$$0__default$8;
3814
+ const watch = gulpWatch;
3815
+ const {
3816
+ info: info$2,
3817
+ fail: fail$1
3818
+ } = log$1;
3819
+ const getCloudsOfListen = getClouds;
3820
+ const {
3821
+ checkCloudConfig,
3822
+ checkSrcPathIsExist
3823
+ } = check$2;
3824
+ const {
3825
+ runInstall
3826
+ } = install$1;
3827
+ /**
3828
+ * 获取云函数的编译任务
3829
+ * @param {array} clouds [{name: '', sourcePath: '', targetPath: ''}]
3830
+ * @param {object} srcOption gulp.src的参数
3831
+ * @returns Map {'${sourcePath}': {taskFn: () => {}, targetPath: 'xxx'}}
3832
+ */
3833
+
3834
+ const getCompileTasks = (clouds, srcOption) => {
3835
+ const compileTasksMap = new Map();
3836
+ clouds.forEach(item => {
3837
+ compileTasksMap.set(item.sourcePath, {
3838
+ targetPath: item.targetPath,
3839
+ taskFn: (sourceFile, targetPath) => {
3840
+ const newGlobValue = Array.isArray(sourceFile) ? sourceFile : `${item.sourcePath}/**/*`;
3841
+ const newDestPath = targetPath ? targetPath : item.targetPath;
3842
+ const srcPipe = src$1(newGlobValue, srcOption);
3843
+ return srcPipe.pipe(dest(newDestPath)).on('error', err => {
3844
+ fail$1(`监听报错${err}`);
3845
+ });
3846
+ }
3847
+ });
3848
+ });
3849
+ return compileTasksMap;
3850
+ };
3851
+
3852
+ const getTargetFile = (sourceFile, sourcePath, targetPath) => {
3853
+ const sourceFileRelativeModule = path$1.relative(sourcePath, sourceFile);
3854
+ const targetFile = resolve$1(targetPath, sourceFileRelativeModule);
3855
+ return targetFile;
3856
+ };
3857
+ /**
3858
+ * 开始启动编译
3859
+ * @param {Map} compileTasksMap {'${sourcePath}': {taskFn: () => {}, targetPath: 'xxx'}}
3860
+ */
3861
+
3862
+
3863
+ const runCompile = (compileTasksMap, callback) => {
3864
+ async function end(next) {
3865
+ // 监听其他文件
3866
+ compileTasksMap.forEach(({
3867
+ taskFn,
3868
+ targetPath
3869
+ }, sourcePath) => {
3870
+ runWatch(sourcePath, {
3871
+ ignoreInitial: true,
3872
+ events: ['add', 'change', 'unlink', 'addDir', 'unlinkDir']
3873
+ }, taskFn, targetPath);
3874
+ });
3875
+ callback && callback();
3876
+ next();
3877
+ }
3878
+
3879
+ const compileTasksArr = [];
3880
+ compileTasksMap.forEach(({
3881
+ taskFn
3882
+ }) => {
3883
+ compileTasksArr.push(taskFn);
3884
+ }); // 一次性完成编译任务(编译完成后再添加watch任务-封装到end函数里面)
3885
+
3886
+ series(parallel(...compileTasksArr), end)();
3887
+ };
3888
+ /**
3889
+ * 监听文件变动
3890
+ * @param {*} sourcePath 云函数的源码目录
3891
+ * @param {*} watchOptions gulp-watch的参数
3892
+ * @param {*} callback 监听到变动的回调
3893
+ * @param {*} targetPath 云函数的编译目录
3894
+ */
3895
+
3896
+
3897
+ const runWatch = (sourcePath, watchOptions, callback, targetPath) => {
3898
+ watch(sourcePath, { ...watchOptions
3899
+ }, vinyl => {
3900
+ const sourceFile = vinyl.history[0];
3901
+ const sourceFileDirArr = sourceFile.replace(/\\/g, '/').split('/');
3902
+ const sourceFileName = sourceFileDirArr.slice(sourceFileDirArr.length - 2).join('/');
3903
+ const targetFile = getTargetFile(sourceFile, sourcePath, targetPath);
3904
+
3905
+ if (vinyl.event === 'unlink' || vinyl.event === 'unlinkDir') {
3906
+ info$2(`删除${sourceFileName}`);
3907
+ shellJs.rm('-rf', targetFile);
3908
+ return;
3909
+ }
3910
+
3911
+ info$2(`${sourceFileName}有更新`);
3912
+ return callback([sourceFile], path$1.dirname(targetFile));
3913
+ });
3914
+ };
3653
3915
 
3654
- var cloud$1 = async tmsConfig => {
3916
+ var dev$1 = async (tmsConfig, cmdOptions) => {
3655
3917
  try {
3656
- await symLink(tmsConfig);
3918
+ const sTime = new Date().getTime();
3919
+ const spinner = ora();
3920
+ spinner.start(); // 检查云函数的配置项
3921
+
3922
+ const configErrMsg = checkCloudConfig(tmsConfig);
3923
+
3924
+ if (configErrMsg) {
3925
+ throw new Error(configErrMsg);
3926
+ } // 确保云函数的编译目录存在
3927
+
3928
+
3929
+ ensureDirExist(resolve$1(tmsConfig.cloudDir)); // 获取需要监听的云函数列表
3930
+
3931
+ const clouds = getCloudsOfListen(tmsConfig, cmdOptions); // 检查云函数源码目录是否存在
3932
+
3933
+ const srcNotExistErrMsg = checkSrcPathIsExist(clouds);
3934
+
3935
+ if (srcNotExistErrMsg) {
3936
+ throw new Error(srcNotExistErrMsg);
3937
+ } // 打印启动云函数列表
3938
+
3939
+
3940
+ info$2('当前启动云函数列表:', clouds.map(item => item.name).sort()); // npm install
3941
+
3942
+ await createTask(runInstall, '开始npm install', 'npm install完成')(clouds, tmsConfig); // 获取云函数列表的编译任务
3943
+
3944
+ const compileTasksMap = getCompileTasks(clouds, {
3945
+ allowEmpty: true
3946
+ });
3947
+ runCompile(compileTasksMap, () => {
3948
+ const eTime = new Date().getTime() - sTime;
3949
+ spinner.succeed(chalk$2.green(`首次编译完成, 耗时${eTime / 1000}s, 微信开发者工具打开项目即可预览。`));
3950
+ spinner.stop();
3951
+ });
3657
3952
  } catch (e) {
3658
- handleError(`创建软链错误: ${e}`, true);
3953
+ info$2('编译出现详细错误', e);
3954
+ handleError(`编译出现错误: ${e}`, true);
3659
3955
  }
3660
3956
  };
3661
3957
 
@@ -3666,7 +3962,8 @@ const build = build_1;
3666
3962
  const install = install_1;
3667
3963
  const preview = preview_1;
3668
3964
  const upload = upload_1;
3669
- const cloud = cloud$1;
3965
+ const cloudLink = link;
3966
+ const cloudDev = dev$1;
3670
3967
  const {
3671
3968
  fail,
3672
3969
  info: info$1
@@ -3736,9 +4033,17 @@ async function run(commandName, cmdOptions) {
3736
4033
  tmsConfig
3737
4034
  });
3738
4035
 
3739
- if (commandName === 'cloud') {
3740
- cloud(tmsConfig);
3741
- report$1('run:cloud', {
4036
+ if (commandName === 'cloud-link') {
4037
+ cloudLink(tmsConfig, cmdOptions);
4038
+ report$1('run:cloud-link', {
4039
+ appName: tmsConfig === null || tmsConfig === void 0 ? void 0 : tmsConfig.appName
4040
+ });
4041
+ return;
4042
+ }
4043
+
4044
+ if (commandName === 'cloud-dev') {
4045
+ cloudDev(tmsConfig, cmdOptions);
4046
+ report$1('run:cloud-dev', {
3742
4047
  appName: tmsConfig === null || tmsConfig === void 0 ? void 0 : tmsConfig.appName
3743
4048
  });
3744
4049
  return;
@@ -3852,13 +4157,6 @@ var entry = [{
3852
4157
  action: cmdOptions => {
3853
4158
  run_1('dev', cmdOptions);
3854
4159
  }
3855
- }, {
3856
- command: 'cloud',
3857
- description: '云函数开发',
3858
- options: [['-m, --module [moduleName]', '模块名称'], ['-e, --env [env]', '环境变量']],
3859
- action: cmdOptions => {
3860
- run_1('cloud', cmdOptions);
3861
- }
3862
4160
  }, {
3863
4161
  command: 'build',
3864
4162
  description: 'prod 打包编译',
@@ -3880,12 +4178,29 @@ var entry = [{
3880
4178
  action: cmdOptions => {
3881
4179
  run_1('upload', cmdOptions);
3882
4180
  }
3883
- }]
4181
+ }, {
4182
+ command: 'cloud-dev',
4183
+ description: '云函数开发',
4184
+ options: [['--cloud [cloud]', '模块名称']],
4185
+ action: cmdOptions => {
4186
+ run_1('cloud-dev', cmdOptions);
4187
+ }
4188
+ } // {
4189
+ // command: 'cloud-link',
4190
+ // description: '云函数开发',
4191
+ // options: [
4192
+ // ['--cloud [cloud]', '模块名称'],
4193
+ // ],
4194
+ // action: (cmdOptions) => {
4195
+ // require('./scripts/run/index')('cloud-link', cmdOptions);
4196
+ // },
4197
+ // },
4198
+ ]
3884
4199
  }];
3885
4200
 
3886
4201
  var require$$12 = {
3887
4202
  name: "@tmsfe/tmskit",
3888
- version: "0.0.26",
4203
+ version: "0.0.28",
3889
4204
  description: "tmskit",
3890
4205
  main: "dist/index.cjs",
3891
4206
  bin: {
@@ -3971,7 +4286,7 @@ var require$$12 = {
3971
4286
 
3972
4287
  const semver = require$$1__default$7;
3973
4288
  const packageJson = require$$12;
3974
- const chalk$1 = require$$0__default;
4289
+ const chalk$1 = require$$3__default;
3975
4290
  const {
3976
4291
  info
3977
4292
  } = log$1;
@@ -4006,10 +4321,10 @@ function check$1() {
4006
4321
  var check_1 = check$1;
4007
4322
 
4008
4323
  /* eslint-disable no-param-reassign */
4009
- const chalk = require$$0__default;
4324
+ const chalk = require$$3__default;
4010
4325
  const commander = require$$1__default$8;
4011
4326
  const path = require$$1__default$1;
4012
- const fs = require$$0__default$2;
4327
+ const fs = require$$0__default$1;
4013
4328
  const {
4014
4329
  resolve
4015
4330
  } = widgets;
@@ -4113,6 +4428,6 @@ if (!process.argv.slice(2).length) {
4113
4428
  }
4114
4429
 
4115
4430
  program.parse(process.argv);
4116
- var src = src$2;
4431
+ var src = src$3;
4117
4432
 
4118
4433
  module.exports = src;