@tmsfe/tmskit 0.0.26 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -1
- package/dist/index.cjs.js +744 -434
- package/package.json +1 -1
- package/src/config/defaultTmsConfig.js +3 -0
- package/src/entry.js +20 -11
- package/src/scripts/run/cloud/check.js +34 -0
- package/src/scripts/run/cloud/dev.js +146 -0
- package/src/scripts/run/cloud/getClouds.js +46 -0
- package/src/scripts/run/cloud/install.js +31 -0
- package/src/scripts/run/cloud/link.js +37 -0
- package/src/scripts/run/index.js +10 -4
- package/src/core/symbolicLink.js +0 -33
- package/src/scripts/run/cloud/index.js +0 -10
package/dist/index.cjs.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var require$$
|
|
3
|
+
var require$$3 = require('chalk');
|
|
4
4
|
var require$$1 = require('moment');
|
|
5
|
-
var require$$0
|
|
5
|
+
var require$$0 = require('ora');
|
|
6
6
|
var require$$1$1 = require('path');
|
|
7
|
-
var require$$0$
|
|
8
|
-
var require$$0$
|
|
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$
|
|
12
|
-
var require$$0$
|
|
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$
|
|
16
|
-
var require$$0$
|
|
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$
|
|
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$
|
|
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$
|
|
27
|
-
var require$$3$
|
|
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$$
|
|
42
|
+
var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);
|
|
43
43
|
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
44
|
-
var require$$0__default
|
|
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$
|
|
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$
|
|
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$
|
|
79
|
+
var src$3 = {};
|
|
80
80
|
|
|
81
|
-
const chalk$
|
|
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$
|
|
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$
|
|
124
|
+
console.log(`${moment$1().format('YYYY-MM-DD HH:mm:ss')}`, chalk$4.yellow(message));
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
-
const info$
|
|
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$
|
|
132
|
+
fail: fail$a,
|
|
133
133
|
succeed: succeed$2,
|
|
134
134
|
warn: warn$2,
|
|
135
|
-
info: info$
|
|
135
|
+
info: info$j,
|
|
136
136
|
infoNoTime: infoNoTime$1
|
|
137
137
|
};
|
|
138
138
|
|
|
139
|
-
const ora$
|
|
140
|
-
const path$
|
|
141
|
-
const fs$
|
|
142
|
-
const shelljs$7 = require$$0__default$
|
|
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$
|
|
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$
|
|
155
|
-
return path$
|
|
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$
|
|
190
|
-
shelljs$7.rm('-rf', path$
|
|
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$
|
|
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$
|
|
296
|
+
function createTask$6(task, startText, endText) {
|
|
297
297
|
return async (...args) => {
|
|
298
298
|
const start = Date.now();
|
|
299
|
-
const spinner = ora$
|
|
300
|
-
info$
|
|
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$
|
|
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$
|
|
360
|
+
function getAbsolutePath$6(pathDir, cwd = '') {
|
|
361
361
|
let newPath = pathDir;
|
|
362
|
-
newPath = newPath.startsWith('/') ? newPath : resolve$
|
|
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$
|
|
397
|
+
resolve: resolve$j,
|
|
398
398
|
isObject,
|
|
399
399
|
isArray,
|
|
400
|
-
createTask: createTask$
|
|
400
|
+
createTask: createTask$6,
|
|
401
401
|
downloadRepoForGit: downloadRepoForGit$1,
|
|
402
402
|
pullRepoForGit: pullRepoForGit$1,
|
|
403
403
|
camelize,
|
|
404
|
-
npmInstall: npmInstall$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
426
|
+
const VERSION_CACHE_FILE = path$f.resolve(CACHE_DIR, 'version_cache_file.json'); // npm缓存文件
|
|
427
427
|
|
|
428
|
-
const NPM_CACHE_FILE$1 = path$
|
|
428
|
+
const NPM_CACHE_FILE$1 = path$f.resolve(CACHE_DIR, 'npm_cache_file.json'); // 脚手架模板代码所在目录
|
|
429
429
|
|
|
430
|
-
const TEMPLATE_DIR$1 = path$
|
|
430
|
+
const TEMPLATE_DIR$1 = path$f.resolve(CACHE_DIR, 'template'); // 第三方模块源码存放的临时缓存目录
|
|
431
431
|
|
|
432
|
-
const MODULE_CODE_DIR$2 = path$
|
|
432
|
+
const MODULE_CODE_DIR$2 = path$f.resolve(CACHE_DIR, 'modules_code'); // 缓存分包node_modules的目录
|
|
433
433
|
|
|
434
|
-
const NODE_MODULES_DIR$2 = path$
|
|
434
|
+
const NODE_MODULES_DIR$2 = path$f.resolve(CACHE_DIR, 'node_modules'); // 扩展命令源码的存放处
|
|
435
435
|
|
|
436
|
-
const EXTEND_CMD$1 = path$
|
|
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$
|
|
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$
|
|
558
|
-
const fs = require$$0__default$
|
|
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$
|
|
871
|
-
const path$
|
|
873
|
+
const fs$i = require$$0__default$1;
|
|
874
|
+
const path$e = require$$1__default$1;
|
|
872
875
|
const {
|
|
873
|
-
info: info$
|
|
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$
|
|
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$
|
|
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$
|
|
902
|
-
if (!fs$
|
|
903
|
-
fs$
|
|
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$
|
|
912
|
-
fs$
|
|
914
|
+
if (fs$i.existsSync(dest)) {
|
|
915
|
+
fs$i.unlinkSync(dest);
|
|
913
916
|
}
|
|
914
917
|
|
|
915
|
-
const dir = path$
|
|
916
|
-
ensureDirExist$
|
|
917
|
-
fs$
|
|
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$
|
|
923
|
-
const depDestContent = fs$
|
|
924
|
-
const depOriginContent = fs$
|
|
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$
|
|
930
|
+
info$h(`拷贝${relativeCwdPath(originFile)}内容到${relativeCwdPath(destFile)}`);
|
|
928
931
|
copyFile(originFile, destFile);
|
|
929
932
|
}
|
|
930
933
|
} else {
|
|
931
|
-
info$
|
|
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$
|
|
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$
|
|
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$
|
|
974
|
+
if (!fs$i.existsSync(dir) || !fs$i.existsSync(file)) {
|
|
972
975
|
return false;
|
|
973
976
|
}
|
|
974
977
|
|
|
975
|
-
const relativePath = path$
|
|
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$
|
|
991
|
+
const arr = fs$i.readdirSync(dir);
|
|
989
992
|
arr.forEach(item => {
|
|
990
|
-
const fullPath = path$
|
|
991
|
-
const stats = fs$
|
|
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$
|
|
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$
|
|
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$
|
|
1040
|
+
const fs$h = require$$0__default$1;
|
|
1038
1041
|
const inquirer$1 = require$$1__default$4;
|
|
1039
1042
|
const {
|
|
1040
|
-
resolve: resolve$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
1167
|
-
const fs$
|
|
1168
|
-
const shelljs$6 = require$$0__default$
|
|
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$
|
|
1181
|
+
resolve: resolve$h
|
|
1179
1182
|
} = widgets;
|
|
1180
1183
|
const io$2 = io$3;
|
|
1181
1184
|
const {
|
|
1182
|
-
fail: fail$
|
|
1185
|
+
fail: fail$9,
|
|
1183
1186
|
succeed: succeed$1,
|
|
1184
|
-
info: info$
|
|
1187
|
+
info: info$g
|
|
1185
1188
|
} = log$1;
|
|
1186
1189
|
const generator = generator_1;
|
|
1187
|
-
const request = require$$0__default$
|
|
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$
|
|
1201
|
+
if (fs$g.existsSync(targetDir)) {
|
|
1199
1202
|
if (!(await io$2.isDirEmpty(targetDir))) {
|
|
1200
|
-
fail$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
1261
|
+
if (fs$g.existsSync(TEMPLATE_DIR)) {
|
|
1259
1262
|
shelljs$6.rm('-rf', TEMPLATE_DIR);
|
|
1260
1263
|
}
|
|
1261
1264
|
|
|
1262
|
-
fs$
|
|
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$
|
|
1271
|
+
generator(path$d.join(TEMPLATE_DIR, TEMPLATE_NAME, projectType), targetDir).then(() => {
|
|
1269
1272
|
shelljs$6.cd(projectName);
|
|
1270
|
-
const hookFilePath = resolve$
|
|
1273
|
+
const hookFilePath = resolve$h(projectName, TEMPLATE_TKIT_DIR, 'hooks.js');
|
|
1271
1274
|
|
|
1272
|
-
if (fs$
|
|
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$
|
|
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$
|
|
1296
|
-
info$
|
|
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$
|
|
1303
|
-
const path$
|
|
1304
|
-
const shellJs$
|
|
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$
|
|
1309
|
+
ensureDirExist: ensureDirExist$5
|
|
1307
1310
|
} = io$3;
|
|
1308
1311
|
const {
|
|
1309
1312
|
EXTEND_CMD
|
|
1310
1313
|
} = constant;
|
|
1311
1314
|
const {
|
|
1312
|
-
createTask: createTask$
|
|
1315
|
+
createTask: createTask$5
|
|
1313
1316
|
} = widgets;
|
|
1314
1317
|
const {
|
|
1315
|
-
info: info$
|
|
1316
|
-
fail: fail$
|
|
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$
|
|
1329
|
-
ensureDirExist$
|
|
1330
|
-
fs$
|
|
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$
|
|
1336
|
-
await createTask$
|
|
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$
|
|
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$
|
|
1351
|
-
info$
|
|
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$
|
|
1366
|
-
const content = fs$
|
|
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$
|
|
1376
|
+
const cmdConfig = path$c.join(cmdNpmDir, name, 'tms.config.js');
|
|
1374
1377
|
|
|
1375
|
-
if (fs$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
1436
|
+
fail$7(errMsg);
|
|
1434
1437
|
} else {
|
|
1435
|
-
fail$
|
|
1438
|
+
fail$7(errMsg);
|
|
1436
1439
|
process.exit(1);
|
|
1437
1440
|
}
|
|
1438
1441
|
}
|
|
1439
1442
|
|
|
1440
1443
|
var handleError_1 = {
|
|
1441
|
-
handleError: handleError$
|
|
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$
|
|
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$
|
|
1456
|
-
info: info$
|
|
1458
|
+
fail: fail$6,
|
|
1459
|
+
info: info$e
|
|
1457
1460
|
} = log$1;
|
|
1458
1461
|
const {
|
|
1459
|
-
resolve: resolve$
|
|
1462
|
+
resolve: resolve$g,
|
|
1460
1463
|
filterField: filterField$6
|
|
1461
1464
|
} = widgets;
|
|
1462
1465
|
const {
|
|
1463
|
-
handleError: handleError$
|
|
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$
|
|
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$
|
|
1513
|
-
fail$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
1622
|
-
info$
|
|
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$
|
|
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$
|
|
1641
|
+
resolve: resolve$f
|
|
1639
1642
|
} = widgets;
|
|
1640
1643
|
const {
|
|
1641
|
-
fail: fail$
|
|
1642
|
-
info: info$
|
|
1644
|
+
fail: fail$5,
|
|
1645
|
+
info: info$d
|
|
1643
1646
|
} = log$1;
|
|
1644
|
-
const fs$
|
|
1645
|
-
const shelljs$5 = require$$0__default$
|
|
1647
|
+
const fs$d = require$$0__default$1;
|
|
1648
|
+
const shelljs$5 = require$$0__default$2;
|
|
1646
1649
|
const {
|
|
1647
|
-
handleError: handleError$
|
|
1650
|
+
handleError: handleError$6
|
|
1648
1651
|
} = handleError_1;
|
|
1649
1652
|
const {
|
|
1650
1653
|
global: global$8
|
|
@@ -1684,7 +1687,7 @@ function replaceGitUrlAccount(httpRepoUrl, moduleName) {
|
|
|
1684
1687
|
|
|
1685
1688
|
|
|
1686
1689
|
function moveFile(sourceDir, targetDir, ignore = []) {
|
|
1687
|
-
if (fs$
|
|
1690
|
+
if (fs$d.existsSync(targetDir)) {
|
|
1688
1691
|
shelljs$5.rm('-rf', targetDir);
|
|
1689
1692
|
} // 删除不是文件夹的文件
|
|
1690
1693
|
|
|
@@ -1692,7 +1695,7 @@ function moveFile(sourceDir, targetDir, ignore = []) {
|
|
|
1692
1695
|
return new Promise((resolve, reject) => {
|
|
1693
1696
|
MetalSmith(__dirname).ignore(ignore).source(sourceDir).destination(targetDir).build(e => {
|
|
1694
1697
|
if (e) {
|
|
1695
|
-
fail$
|
|
1698
|
+
fail$5(`${sourceDir} moveFile ${targetDir}出现错误: ${e}`);
|
|
1696
1699
|
reject(e);
|
|
1697
1700
|
}
|
|
1698
1701
|
|
|
@@ -1741,7 +1744,7 @@ async function cloneModules$1(sourceDir, targetDir, modules) {
|
|
|
1741
1744
|
}) => fn(...Object.keys(cParams).map(key => cParams[key])));
|
|
1742
1745
|
return Promise.all(callArr);
|
|
1743
1746
|
}).catch(e => {
|
|
1744
|
-
handleError$
|
|
1747
|
+
handleError$6(`下载代码${params.httpRepoUrl}出现错误:${e}`);
|
|
1745
1748
|
}));
|
|
1746
1749
|
});
|
|
1747
1750
|
await Promise.all(arrPromises);
|
|
@@ -1786,9 +1789,9 @@ function collectDownLoadTasksMap(sourceDir, targetDir, modules) {
|
|
|
1786
1789
|
|
|
1787
1790
|
const md5Key = md5ByGitUrlBranch(gitUrl, branch); // git源码临时存在的源目录
|
|
1788
1791
|
|
|
1789
|
-
const sourcePath = resolve$
|
|
1792
|
+
const sourcePath = resolve$f(sourceDir, md5Key); // 模块源码要放到目标目录
|
|
1790
1793
|
|
|
1791
|
-
const targetPath = resolve$
|
|
1794
|
+
const targetPath = resolve$f(targetDir, path); // 从git源码仓库中找到模块源码路径 (一个仓库存在存放多个模块的情况)
|
|
1792
1795
|
|
|
1793
1796
|
const sourceModulePath = gitPath ? `${sourcePath}/${gitPath}` : sourcePath; // 下载完代码后,添加回调函数(主要将模块代码从临时目录移动代码到目标目录)
|
|
1794
1797
|
|
|
@@ -1798,7 +1801,7 @@ function collectDownLoadTasksMap(sourceDir, targetDir, modules) {
|
|
|
1798
1801
|
targetPath
|
|
1799
1802
|
},
|
|
1800
1803
|
fn: async (sourceModulePath, targetPath) => {
|
|
1801
|
-
if (fs$
|
|
1804
|
+
if (fs$d.existsSync(targetPath)) {
|
|
1802
1805
|
shelljs$5.rm('-rf', `${targetPath}/*`);
|
|
1803
1806
|
}
|
|
1804
1807
|
|
|
@@ -1813,14 +1816,14 @@ function collectDownLoadTasksMap(sourceDir, targetDir, modules) {
|
|
|
1813
1816
|
} else {
|
|
1814
1817
|
let promiseTask;
|
|
1815
1818
|
|
|
1816
|
-
if (fs$
|
|
1819
|
+
if (fs$d.existsSync(sourcePath) && fs$d.existsSync(`${sourcePath}/.git`)) {
|
|
1817
1820
|
promiseTask = (gitUrl, sourcePath, branch, httpRepoUrl) => {
|
|
1818
|
-
info$
|
|
1821
|
+
info$d(`git pull:${httpRepoUrl} --branch: ${branch}`);
|
|
1819
1822
|
return pullRepoForGit(sourcePath, branch);
|
|
1820
1823
|
};
|
|
1821
1824
|
} else {
|
|
1822
1825
|
promiseTask = (gitUrl, sourcePath, branch, httpRepoUrl) => {
|
|
1823
|
-
info$
|
|
1826
|
+
info$d(`git clone: ${httpRepoUrl}`);
|
|
1824
1827
|
return downloadRepoForGit(gitUrl, sourcePath, branch);
|
|
1825
1828
|
};
|
|
1826
1829
|
}
|
|
@@ -1861,7 +1864,7 @@ function checkRemoteModGitUrlBranch(sourceDir, moduleInfo) {
|
|
|
1861
1864
|
const gitUrl = replaceGitUrlAccount(httpRepoUrl, moduleName);
|
|
1862
1865
|
const md5Key = md5ByGitUrlBranch(gitUrl, buildGitTag);
|
|
1863
1866
|
|
|
1864
|
-
if (!fs$
|
|
1867
|
+
if (!fs$d.existsSync(`${sourceDir}/${md5Key}`)) {
|
|
1865
1868
|
return true;
|
|
1866
1869
|
}
|
|
1867
1870
|
}
|
|
@@ -1874,8 +1877,8 @@ var cloneModules_1 = {
|
|
|
1874
1877
|
checkRemoteModGitUrlBranch
|
|
1875
1878
|
};
|
|
1876
1879
|
|
|
1877
|
-
const ci = require$$0__default$
|
|
1878
|
-
const path$
|
|
1880
|
+
const ci = require$$0__default$7;
|
|
1881
|
+
const path$b = require$$1__default$1;
|
|
1879
1882
|
/**
|
|
1880
1883
|
* 获取小程序ci的Project对象
|
|
1881
1884
|
* @returns {Object} 小程序ci对象
|
|
@@ -1889,7 +1892,7 @@ const getMpCi = ({
|
|
|
1889
1892
|
}) => {
|
|
1890
1893
|
var _projectCg$packOption, _projectCg$packOption2;
|
|
1891
1894
|
|
|
1892
|
-
const projectCg = require(path$
|
|
1895
|
+
const projectCg = require(path$b.join(projectPath, 'project.config.json'));
|
|
1893
1896
|
|
|
1894
1897
|
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
1898
|
value
|
|
@@ -2016,13 +2019,13 @@ var mpCi$2 = {
|
|
|
2016
2019
|
uploadMp
|
|
2017
2020
|
};
|
|
2018
2021
|
|
|
2019
|
-
const fs$
|
|
2020
|
-
const path$
|
|
2022
|
+
const fs$c = require$$0__default$1;
|
|
2023
|
+
const path$a = require$$1__default$1;
|
|
2021
2024
|
const {
|
|
2022
2025
|
NPM_CACHE_FILE
|
|
2023
2026
|
} = constant;
|
|
2024
2027
|
const {
|
|
2025
|
-
ensureDirExist: ensureDirExist$
|
|
2028
|
+
ensureDirExist: ensureDirExist$4
|
|
2026
2029
|
} = io$3;
|
|
2027
2030
|
|
|
2028
2031
|
function getCache$1(projectDir, type) {
|
|
@@ -2030,7 +2033,7 @@ function getCache$1(projectDir, type) {
|
|
|
2030
2033
|
|
|
2031
2034
|
const filePath = NPM_CACHE_FILE;
|
|
2032
2035
|
|
|
2033
|
-
if (!fs$
|
|
2036
|
+
if (!fs$c.existsSync(filePath)) {
|
|
2034
2037
|
return null;
|
|
2035
2038
|
}
|
|
2036
2039
|
|
|
@@ -2042,10 +2045,10 @@ function getCache$1(projectDir, type) {
|
|
|
2042
2045
|
function setCache$1(projectDir, type = 'miniprogram_npm', data) {
|
|
2043
2046
|
const filePath = NPM_CACHE_FILE;
|
|
2044
2047
|
|
|
2045
|
-
if (!fs$
|
|
2046
|
-
const dir = path$
|
|
2047
|
-
ensureDirExist$
|
|
2048
|
-
fs$
|
|
2048
|
+
if (!fs$c.existsSync(filePath)) {
|
|
2049
|
+
const dir = path$a.dirname(filePath);
|
|
2050
|
+
ensureDirExist$4(dir);
|
|
2051
|
+
fs$c.writeFileSync(filePath, '{}');
|
|
2049
2052
|
}
|
|
2050
2053
|
|
|
2051
2054
|
const content = require(filePath);
|
|
@@ -2057,7 +2060,7 @@ function setCache$1(projectDir, type = 'miniprogram_npm', data) {
|
|
|
2057
2060
|
content[projectDir] = {
|
|
2058
2061
|
[type]: data
|
|
2059
2062
|
};
|
|
2060
|
-
fs$
|
|
2063
|
+
fs$c.writeFileSync(filePath, JSON.stringify(content, null, 2));
|
|
2061
2064
|
}
|
|
2062
2065
|
|
|
2063
2066
|
var cache = {
|
|
@@ -2068,17 +2071,17 @@ var cache = {
|
|
|
2068
2071
|
/**
|
|
2069
2072
|
* 本文件主要负责项目或者分包依赖的npm的安装
|
|
2070
2073
|
*/
|
|
2071
|
-
const fs$
|
|
2074
|
+
const fs$b = require$$0__default$1;
|
|
2072
2075
|
const fsExtra = require$$1__default$6;
|
|
2073
2076
|
const crypto$1 = require$$1__default$5;
|
|
2074
|
-
const path$
|
|
2075
|
-
const shell = require$$0__default$
|
|
2077
|
+
const path$9 = require$$1__default$1;
|
|
2078
|
+
const shell = require$$0__default$2;
|
|
2076
2079
|
const log = log$1;
|
|
2077
2080
|
const {
|
|
2078
|
-
npmInstall: npmInstall$
|
|
2081
|
+
npmInstall: npmInstall$2
|
|
2079
2082
|
} = widgets;
|
|
2080
2083
|
const {
|
|
2081
|
-
handleError: handleError$
|
|
2084
|
+
handleError: handleError$5
|
|
2082
2085
|
} = handleError_1;
|
|
2083
2086
|
const {
|
|
2084
2087
|
global: global$7
|
|
@@ -2105,7 +2108,7 @@ const collectNpmTasksMap = (packageJsonFiles, cacheDir) => {
|
|
|
2105
2108
|
const npmTasksMap = new Map();
|
|
2106
2109
|
|
|
2107
2110
|
for (const packageJsonPath of packageJsonFiles) {
|
|
2108
|
-
const packageContent = fs$
|
|
2111
|
+
const packageContent = fs$b.readFileSync(packageJsonPath);
|
|
2109
2112
|
let packageJson;
|
|
2110
2113
|
|
|
2111
2114
|
try {
|
|
@@ -2120,14 +2123,14 @@ const collectNpmTasksMap = (packageJsonFiles, cacheDir) => {
|
|
|
2120
2123
|
|
|
2121
2124
|
if (Object.keys(md5Obj.dependencies).length !== 0) {
|
|
2122
2125
|
const md5Key = crypto$1.createHash('md5').update(JSON.stringify(md5Obj)).digest('hex');
|
|
2123
|
-
const cacheNMPath = path$
|
|
2124
|
-
const cacheNMTarFile = path$
|
|
2126
|
+
const cacheNMPath = path$9.join(cacheDir, md5Key);
|
|
2127
|
+
const cacheNMTarFile = path$9.join(cacheNMPath, 'node_modules.tar.gz'); // 下载后,添加回调函数 (拷贝node_modules.tar.gz到编译目录并解压)
|
|
2125
2128
|
|
|
2126
2129
|
const callback = {
|
|
2127
2130
|
params: {
|
|
2128
2131
|
cacheNMPath,
|
|
2129
2132
|
cacheNMTarFile,
|
|
2130
|
-
packageJsonDir: path$
|
|
2133
|
+
packageJsonDir: path$9.dirname(packageJsonPath),
|
|
2131
2134
|
shell
|
|
2132
2135
|
},
|
|
2133
2136
|
fn: async (cacheNMPath, cacheNMTarFile, packageJsonDir, shell) => {
|
|
@@ -2157,7 +2160,7 @@ const collectNpmTasksMap = (packageJsonFiles, cacheDir) => {
|
|
|
2157
2160
|
shell.cp('-f', packageJsonPath, cacheNMPath);
|
|
2158
2161
|
log.info(`npm install: ${packageJsonPath}`);
|
|
2159
2162
|
const tmsConfig = global$7.getData('tmsConfig');
|
|
2160
|
-
return npmInstall$
|
|
2163
|
+
return npmInstall$2(cacheNMPath, tmsConfig.npm).then(() => {
|
|
2161
2164
|
const newShellJsOption = { ...shellJsOption,
|
|
2162
2165
|
cwd: cacheNMPath
|
|
2163
2166
|
};
|
|
@@ -2204,7 +2207,7 @@ const npmInstallAll$1 = async (subPackages, contextDir, cacheDir) => {
|
|
|
2204
2207
|
}) => fn(...Object.keys(cParams).map(key => cParams[key])));
|
|
2205
2208
|
return Promise.all(callArr);
|
|
2206
2209
|
}).catch(e => {
|
|
2207
|
-
handleError$
|
|
2210
|
+
handleError$5(`npm install ${params.packageJsonPath}出现错误:${e}`, true);
|
|
2208
2211
|
}));
|
|
2209
2212
|
});
|
|
2210
2213
|
await Promise.all(arrPromises);
|
|
@@ -2230,7 +2233,7 @@ const findFilesByFilter = (startPath, filter) => {
|
|
|
2230
2233
|
|
|
2231
2234
|
const find = (startPath, filter) => {
|
|
2232
2235
|
// 目录不存在
|
|
2233
|
-
if (!fs$
|
|
2236
|
+
if (!fs$b.existsSync(startPath)) {
|
|
2234
2237
|
log.fail(`${startPath}目录不存在`);
|
|
2235
2238
|
process.exit(-1);
|
|
2236
2239
|
return;
|
|
@@ -2243,10 +2246,10 @@ const findFilesByFilter = (startPath, filter) => {
|
|
|
2243
2246
|
return;
|
|
2244
2247
|
}
|
|
2245
2248
|
|
|
2246
|
-
const files = fs$
|
|
2249
|
+
const files = fs$b.readdirSync(startPath);
|
|
2247
2250
|
files.forEach(file => {
|
|
2248
|
-
const filename = path$
|
|
2249
|
-
const stat = fs$
|
|
2251
|
+
const filename = path$9.join(startPath, file);
|
|
2252
|
+
const stat = fs$b.lstatSync(filename); // 当前文件是文件夹类型,继续递归
|
|
2250
2253
|
|
|
2251
2254
|
if (stat.isDirectory()) {
|
|
2252
2255
|
find(filename, filter);
|
|
@@ -2272,10 +2275,10 @@ const findAllPackageJson = (subRoots = [], contextDir) => {
|
|
|
2272
2275
|
const packageJsonName = 'package.json'; // 查找文件名
|
|
2273
2276
|
|
|
2274
2277
|
const cwd = contextDir || dirPath;
|
|
2275
|
-
const result = [path$
|
|
2278
|
+
const result = [path$9.join(cwd, packageJsonName)]; // 默认填充根目录下的package.json
|
|
2276
2279
|
|
|
2277
2280
|
subRoots.forEach(subRoot => {
|
|
2278
|
-
const toppath = path$
|
|
2281
|
+
const toppath = path$9.join(cwd, subRoot.root); // 从该目录开始查找package.json文件
|
|
2279
2282
|
|
|
2280
2283
|
const list = findFilesByFilter(toppath, packageJsonName);
|
|
2281
2284
|
result.push(...list);
|
|
@@ -2290,12 +2293,12 @@ var npm = {
|
|
|
2290
2293
|
};
|
|
2291
2294
|
|
|
2292
2295
|
const crypto = require$$1__default$5;
|
|
2293
|
-
const fs$
|
|
2296
|
+
const fs$a = require$$0__default$1;
|
|
2294
2297
|
|
|
2295
2298
|
function fileMd5$1(filePath) {
|
|
2296
2299
|
return new Promise((resolve, reject) => {
|
|
2297
2300
|
const md5sum = crypto.createHash('md5');
|
|
2298
|
-
const stream = fs$
|
|
2301
|
+
const stream = fs$a.ReadStream(filePath);
|
|
2299
2302
|
stream.on('data', d => {
|
|
2300
2303
|
md5sum.update(d);
|
|
2301
2304
|
});
|
|
@@ -2313,16 +2316,16 @@ var md5 = {
|
|
|
2313
2316
|
fileMd5: fileMd5$1
|
|
2314
2317
|
};
|
|
2315
2318
|
|
|
2316
|
-
const fs$
|
|
2319
|
+
const fs$9 = require$$0__default$1;
|
|
2317
2320
|
const semver$1 = require$$1__default$7;
|
|
2318
2321
|
const {
|
|
2319
|
-
resolve: resolve$
|
|
2320
|
-
getAbsolutePath: getAbsolutePath$
|
|
2322
|
+
resolve: resolve$e,
|
|
2323
|
+
getAbsolutePath: getAbsolutePath$5
|
|
2321
2324
|
} = widgets;
|
|
2322
|
-
const path$
|
|
2323
|
-
const shelljs$4 = require$$0__default$
|
|
2325
|
+
const path$8 = require$$1__default$1;
|
|
2326
|
+
const shelljs$4 = require$$0__default$2;
|
|
2324
2327
|
const {
|
|
2325
|
-
handleError: handleError$
|
|
2328
|
+
handleError: handleError$4
|
|
2326
2329
|
} = handleError_1;
|
|
2327
2330
|
|
|
2328
2331
|
const getLatestVersion = npmName => {
|
|
@@ -2341,17 +2344,17 @@ function collectPackageJson(subPackages, cwd, outputDir) {
|
|
|
2341
2344
|
// 1.1根目录的package.json
|
|
2342
2345
|
|
|
2343
2346
|
const packageArr = [{
|
|
2344
|
-
srcPackageDir: path$
|
|
2345
|
-
destNpmDir: resolve$
|
|
2347
|
+
srcPackageDir: path$8.join(cwd, packageJsonName),
|
|
2348
|
+
destNpmDir: resolve$e(outputDir, 'node_modules')
|
|
2346
2349
|
}]; // 1.2模块的package.json
|
|
2347
2350
|
|
|
2348
2351
|
subPackages.forEach(item => {
|
|
2349
|
-
const srcPackageDir = `${getAbsolutePath$
|
|
2352
|
+
const srcPackageDir = `${getAbsolutePath$5(item.path)}/package.json`;
|
|
2350
2353
|
|
|
2351
|
-
if (fs$
|
|
2354
|
+
if (fs$9.existsSync(srcPackageDir)) {
|
|
2352
2355
|
packageArr.push({
|
|
2353
2356
|
srcPackageDir,
|
|
2354
|
-
destNpmDir: resolve$
|
|
2357
|
+
destNpmDir: resolve$e(outputDir, item.root, 'node_modules')
|
|
2355
2358
|
});
|
|
2356
2359
|
}
|
|
2357
2360
|
});
|
|
@@ -2360,14 +2363,14 @@ function collectPackageJson(subPackages, cwd, outputDir) {
|
|
|
2360
2363
|
|
|
2361
2364
|
|
|
2362
2365
|
function readPackageDependencies(srcPackageDir) {
|
|
2363
|
-
const packageJson = fs$
|
|
2366
|
+
const packageJson = fs$9.readFileSync(srcPackageDir, 'utf-8');
|
|
2364
2367
|
let dependencies = {};
|
|
2365
2368
|
|
|
2366
2369
|
try {
|
|
2367
2370
|
const json = packageJson ? JSON.parse(packageJson) : {};
|
|
2368
2371
|
dependencies = (json === null || json === void 0 ? void 0 : json.dependencies) || {};
|
|
2369
2372
|
} catch (e) {
|
|
2370
|
-
handleError$
|
|
2373
|
+
handleError$4(`解析${srcPackageDir}报错,请检查是否是正确的json配置项 ${e}`);
|
|
2371
2374
|
}
|
|
2372
2375
|
|
|
2373
2376
|
return dependencies;
|
|
@@ -2395,15 +2398,15 @@ const checkPackageVersion$1 = packageArr => {
|
|
|
2395
2398
|
const dependenciesKeys = Object.keys(dependencies);
|
|
2396
2399
|
|
|
2397
2400
|
for (const key of dependenciesKeys) {
|
|
2398
|
-
const depPath = path$
|
|
2401
|
+
const depPath = path$8.join(item.destNpmDir, key);
|
|
2399
2402
|
|
|
2400
|
-
if (!fs$
|
|
2403
|
+
if (!fs$9.existsSync(depPath)) {
|
|
2401
2404
|
return true;
|
|
2402
2405
|
}
|
|
2403
2406
|
|
|
2404
|
-
const depPackagePath = path$
|
|
2407
|
+
const depPackagePath = path$8.join(depPath, 'package.json');
|
|
2405
2408
|
|
|
2406
|
-
if (fs$
|
|
2409
|
+
if (fs$9.existsSync(depPackagePath)) {
|
|
2407
2410
|
const packageData = require(depPackagePath);
|
|
2408
2411
|
|
|
2409
2412
|
if (dependencies[key] === 'latest') {
|
|
@@ -2429,14 +2432,14 @@ var checkDependencies = {
|
|
|
2429
2432
|
checkPackageVersion: checkPackageVersion$1
|
|
2430
2433
|
};
|
|
2431
2434
|
|
|
2432
|
-
const shelljs$3 = require$$0__default$
|
|
2433
|
-
const fs$
|
|
2434
|
-
const path$
|
|
2435
|
+
const shelljs$3 = require$$0__default$2;
|
|
2436
|
+
const fs$8 = require$$0__default$1;
|
|
2437
|
+
const path$7 = require$$1__default$1;
|
|
2435
2438
|
const io$1 = io$3;
|
|
2436
2439
|
const {
|
|
2437
|
-
createTask: createTask$
|
|
2438
|
-
resolve: resolve$
|
|
2439
|
-
getAbsolutePath: getAbsolutePath$
|
|
2440
|
+
createTask: createTask$4,
|
|
2441
|
+
resolve: resolve$d,
|
|
2442
|
+
getAbsolutePath: getAbsolutePath$4
|
|
2440
2443
|
} = widgets;
|
|
2441
2444
|
const {
|
|
2442
2445
|
buildMpNpm
|
|
@@ -2452,7 +2455,7 @@ const {
|
|
|
2452
2455
|
npmInstallAll
|
|
2453
2456
|
} = npm;
|
|
2454
2457
|
const {
|
|
2455
|
-
info: info$
|
|
2458
|
+
info: info$c
|
|
2456
2459
|
} = log$1;
|
|
2457
2460
|
const {
|
|
2458
2461
|
fileMd5
|
|
@@ -2461,25 +2464,25 @@ const {
|
|
|
2461
2464
|
isDependenciesUpdate
|
|
2462
2465
|
} = checkDependencies;
|
|
2463
2466
|
|
|
2464
|
-
async function install$
|
|
2467
|
+
async function install$3(tmsConfig, subPackages, useCache = true) {
|
|
2465
2468
|
const cwd = process.cwd();
|
|
2466
|
-
const npmInstallRes = await createTask$
|
|
2469
|
+
const npmInstallRes = await createTask$4(npmInstall$1, '小程序 开始npm install', '小程序npm install 完成')(tmsConfig, subPackages, useCache); // 如果npm install 没有命中缓存,则说明node_module有更新,此时必须构建miniprogram_npm
|
|
2467
2470
|
|
|
2468
2471
|
if (!npmInstallRes.isCache) {
|
|
2469
2472
|
// 构建miniprogram_npm, 不使用缓存
|
|
2470
|
-
await createTask$
|
|
2473
|
+
await createTask$4(mpCiInstall, '开始构建miniprogram_npm', '构建miniprogram_npm 完成')(tmsConfig, subPackages, false);
|
|
2471
2474
|
} else {
|
|
2472
2475
|
// 构建miniprogram_npm
|
|
2473
|
-
await createTask$
|
|
2476
|
+
await createTask$4(mpCiInstall, '开始构建miniprogram_npm', '构建miniprogram_npm 完成')(tmsConfig, subPackages, useCache);
|
|
2474
2477
|
}
|
|
2475
2478
|
|
|
2476
2479
|
shelljs$3.cd(cwd);
|
|
2477
2480
|
}
|
|
2478
2481
|
|
|
2479
|
-
async function npmInstall(tmsConfig, subPackages, useCache) {
|
|
2482
|
+
async function npmInstall$1(tmsConfig, subPackages, useCache) {
|
|
2480
2483
|
// 如果依赖没有更新和使用缓存数据(则命中缓存)
|
|
2481
|
-
if (!isDependenciesUpdate(subPackages, resolve$
|
|
2482
|
-
info$
|
|
2484
|
+
if (!isDependenciesUpdate(subPackages, resolve$d('./'), tmsConfig.outputDir) && useCache) {
|
|
2485
|
+
info$c('node_modules命中缓存');
|
|
2483
2486
|
return {
|
|
2484
2487
|
isCache: true
|
|
2485
2488
|
};
|
|
@@ -2487,12 +2490,12 @@ async function npmInstall(tmsConfig, subPackages, useCache) {
|
|
|
2487
2490
|
|
|
2488
2491
|
|
|
2489
2492
|
subPackages.forEach(item => {
|
|
2490
|
-
const outputModuleDir = resolve$
|
|
2493
|
+
const outputModuleDir = resolve$d(`${tmsConfig.outputDir}/${item.root}`);
|
|
2491
2494
|
io$1.ensureDirExist(outputModuleDir);
|
|
2492
|
-
const modulePackagePath = `${getAbsolutePath$
|
|
2493
|
-
if (fs$
|
|
2495
|
+
const modulePackagePath = `${getAbsolutePath$4(item.path)}/package.json`;
|
|
2496
|
+
if (fs$8.existsSync(modulePackagePath)) shelljs$3.cp('-Rf', modulePackagePath, outputModuleDir);
|
|
2494
2497
|
});
|
|
2495
|
-
await npmInstallAll(subPackages, resolve$
|
|
2498
|
+
await npmInstallAll(subPackages, resolve$d(tmsConfig.outputDir), NODE_MODULES_DIR$1);
|
|
2496
2499
|
return {
|
|
2497
2500
|
isCache: false
|
|
2498
2501
|
};
|
|
@@ -2501,16 +2504,16 @@ async function npmInstall(tmsConfig, subPackages, useCache) {
|
|
|
2501
2504
|
|
|
2502
2505
|
async function mpCiInstall(tmsConfig, subPackages, useCache) {
|
|
2503
2506
|
const packageJsonFiles = [];
|
|
2504
|
-
const rootPackFile = resolve$
|
|
2507
|
+
const rootPackFile = resolve$d(`${tmsConfig.outputDir}/package.json`);
|
|
2505
2508
|
|
|
2506
|
-
if (fs$
|
|
2509
|
+
if (fs$8.existsSync(rootPackFile)) {
|
|
2507
2510
|
packageJsonFiles.push(rootPackFile);
|
|
2508
2511
|
}
|
|
2509
2512
|
|
|
2510
2513
|
subPackages.forEach(item => {
|
|
2511
|
-
const packageJsonFile = resolve$
|
|
2514
|
+
const packageJsonFile = resolve$d(`${tmsConfig.outputDir}/${item.root}/package.json`);
|
|
2512
2515
|
|
|
2513
|
-
if (fs$
|
|
2516
|
+
if (fs$8.existsSync(packageJsonFile)) {
|
|
2514
2517
|
packageJsonFiles.push(packageJsonFile);
|
|
2515
2518
|
}
|
|
2516
2519
|
});
|
|
@@ -2523,8 +2526,8 @@ async function mpCiInstall(tmsConfig, subPackages, useCache) {
|
|
|
2523
2526
|
if (useCache) {
|
|
2524
2527
|
let flag = true;
|
|
2525
2528
|
await Promise.all(packageJsonFiles.map(async item => {
|
|
2526
|
-
const packageDir = path$
|
|
2527
|
-
const mpDir = resolve$
|
|
2529
|
+
const packageDir = path$7.dirname(item);
|
|
2530
|
+
const mpDir = resolve$d(`${packageDir}/miniprogram_npm`);
|
|
2528
2531
|
const md5Value = await getMNPMd5(packageDir);
|
|
2529
2532
|
const preCache = getCache(mpDir, 'miniprogram_npm'); // console.log('miniprogram_npm', preCache, md5Value);
|
|
2530
2533
|
// 上一次构建成功 && 上次md5与当前本地的miniprogram_npm的md5 一致,才可以进入缓存
|
|
@@ -2537,14 +2540,14 @@ async function mpCiInstall(tmsConfig, subPackages, useCache) {
|
|
|
2537
2540
|
}
|
|
2538
2541
|
|
|
2539
2542
|
if (isCache) {
|
|
2540
|
-
info$
|
|
2543
|
+
info$c('miniprogram_npm命中缓存');
|
|
2541
2544
|
return;
|
|
2542
2545
|
} // 即将构建,在cache中标记开始
|
|
2543
2546
|
|
|
2544
2547
|
|
|
2545
2548
|
await Promise.all(packageJsonFiles.map(async item => {
|
|
2546
|
-
const packageDir = path$
|
|
2547
|
-
const mpDir = resolve$
|
|
2549
|
+
const packageDir = path$7.dirname(item);
|
|
2550
|
+
const mpDir = resolve$d(`${packageDir}/miniprogram_npm`);
|
|
2548
2551
|
setCache(mpDir, 'miniprogram_npm', {
|
|
2549
2552
|
md5: '',
|
|
2550
2553
|
status: statusMap.doing
|
|
@@ -2552,13 +2555,13 @@ async function mpCiInstall(tmsConfig, subPackages, useCache) {
|
|
|
2552
2555
|
}));
|
|
2553
2556
|
await buildMpNpm({
|
|
2554
2557
|
appId: tmsConfig.appId,
|
|
2555
|
-
projectPath: resolve$
|
|
2558
|
+
projectPath: resolve$d('./'),
|
|
2556
2559
|
privateKey: tmsConfig.privateKey
|
|
2557
2560
|
}); // 构建成功后,计算md5写入cache
|
|
2558
2561
|
|
|
2559
2562
|
await Promise.all(packageJsonFiles.map(async item => {
|
|
2560
|
-
const packageDir = path$
|
|
2561
|
-
const mpDir = resolve$
|
|
2563
|
+
const packageDir = path$7.dirname(item);
|
|
2564
|
+
const mpDir = resolve$d(`${packageDir}/miniprogram_npm`);
|
|
2562
2565
|
const md5Value = await getMNPMd5(packageDir);
|
|
2563
2566
|
setCache(mpDir, 'miniprogram_npm', {
|
|
2564
2567
|
md5: md5Value,
|
|
@@ -2575,12 +2578,12 @@ async function getMNPMd5(cwd) {
|
|
|
2575
2578
|
};
|
|
2576
2579
|
shelljs$3.cd(cwd);
|
|
2577
2580
|
|
|
2578
|
-
if (fs$
|
|
2581
|
+
if (fs$8.existsSync('miniprogram_npm')) {
|
|
2579
2582
|
shelljs$3.exec('tar -cvf ./miniprogram_npm.tar.gz ./miniprogram_npm', {
|
|
2580
2583
|
cwd,
|
|
2581
2584
|
...shellJsOption
|
|
2582
2585
|
});
|
|
2583
|
-
const tarDir = path$
|
|
2586
|
+
const tarDir = path$7.join(cwd, './miniprogram_npm.tar.gz');
|
|
2584
2587
|
const md5Value = await fileMd5(tarDir);
|
|
2585
2588
|
shelljs$3.rm('-rf', tarDir);
|
|
2586
2589
|
return md5Value;
|
|
@@ -2589,14 +2592,14 @@ async function getMNPMd5(cwd) {
|
|
|
2589
2592
|
return '';
|
|
2590
2593
|
}
|
|
2591
2594
|
|
|
2592
|
-
var install_1 = install$
|
|
2595
|
+
var install_1 = install$3;
|
|
2593
2596
|
|
|
2594
|
-
const shelljs$2 = require$$0__default$
|
|
2595
|
-
const fs$
|
|
2597
|
+
const shelljs$2 = require$$0__default$2;
|
|
2598
|
+
const fs$7 = require$$0__default$1;
|
|
2596
2599
|
const io = io$3;
|
|
2597
2600
|
const {
|
|
2598
|
-
resolve: resolve$
|
|
2599
|
-
createTask: createTask$
|
|
2601
|
+
resolve: resolve$c,
|
|
2602
|
+
createTask: createTask$3
|
|
2600
2603
|
} = widgets;
|
|
2601
2604
|
const {
|
|
2602
2605
|
buildOutputAppJson: buildOutputAppJson$1
|
|
@@ -2613,10 +2616,10 @@ const {
|
|
|
2613
2616
|
getSubPackages: getSubPackages$2
|
|
2614
2617
|
} = tmsMpconfig.exports;
|
|
2615
2618
|
const {
|
|
2616
|
-
fail: fail$
|
|
2617
|
-
info: info$
|
|
2619
|
+
fail: fail$4,
|
|
2620
|
+
info: info$b
|
|
2618
2621
|
} = log$1;
|
|
2619
|
-
const install$
|
|
2622
|
+
const install$2 = install_1;
|
|
2620
2623
|
/**
|
|
2621
2624
|
* 拷贝相关配置文件到编译输出目录
|
|
2622
2625
|
* @param { object } tmsConfig
|
|
@@ -2626,28 +2629,28 @@ const install$1 = install_1;
|
|
|
2626
2629
|
*/
|
|
2627
2630
|
|
|
2628
2631
|
const cpFilesToOutput = function (tmsConfig, defaultFiles) {
|
|
2629
|
-
const outputDir = resolve$
|
|
2632
|
+
const outputDir = resolve$c(tmsConfig.outputDir);
|
|
2630
2633
|
io.ensureDirExist(outputDir);
|
|
2631
2634
|
defaultFiles.forEach(item => {
|
|
2632
|
-
if (fs$
|
|
2633
|
-
shelljs$2.cp('-rf', resolve$
|
|
2635
|
+
if (fs$7.existsSync(resolve$c(item))) {
|
|
2636
|
+
shelljs$2.cp('-rf', resolve$c(item), resolve$c(tmsConfig.outputDir, item));
|
|
2634
2637
|
}
|
|
2635
2638
|
});
|
|
2636
2639
|
};
|
|
2637
2640
|
|
|
2638
2641
|
async function task(tmsConfig, targetModules) {
|
|
2639
2642
|
// 下载和移动代码
|
|
2640
|
-
await createTask$
|
|
2643
|
+
await createTask$3(cloneModules, '开始下载模块代码', '下载模块代码码完成')(MODULE_CODE_DIR$1, resolve$c('./'), targetModules); // 获取所有模块,合并模块依赖的模块
|
|
2641
2644
|
|
|
2642
2645
|
const newModules = getModulesByMergeDepModules$2(tmsConfig, targetModules, true); // 获取所有的分包
|
|
2643
2646
|
|
|
2644
2647
|
const newSubPackages = getSubPackages$2(newModules); // 拷贝相关配置文件到输出目录
|
|
2645
2648
|
|
|
2646
|
-
await createTask$
|
|
2649
|
+
await createTask$3(cpFilesToOutput, '开始拷贝文件到编译输出目录', '拷贝文件到编译输出目录完成')(tmsConfig, DEFAULT_COPY_CONFIG$1); // install
|
|
2647
2650
|
|
|
2648
|
-
await install$
|
|
2651
|
+
await install$2(tmsConfig, newSubPackages, true); // 动态生成编译后的app.json;
|
|
2649
2652
|
|
|
2650
|
-
await createTask$
|
|
2653
|
+
await createTask$3(buildOutputAppJson$1, '开始生成编译后的app.json', '生成编译后的app.json完成')(tmsConfig, newModules);
|
|
2651
2654
|
return {
|
|
2652
2655
|
modules: newModules,
|
|
2653
2656
|
subPackages: newSubPackages
|
|
@@ -2660,8 +2663,8 @@ async function init$3(tmsConfig, targetModules) {
|
|
|
2660
2663
|
return taskRes;
|
|
2661
2664
|
} catch (error) {
|
|
2662
2665
|
const errMsg = typeof error === 'object' ? error.message : error;
|
|
2663
|
-
fail$
|
|
2664
|
-
info$
|
|
2666
|
+
fail$4(`初始化流程出现错误: ${errMsg}`);
|
|
2667
|
+
info$b('详细的错误信息', error);
|
|
2665
2668
|
process.exit(1);
|
|
2666
2669
|
}
|
|
2667
2670
|
}
|
|
@@ -2688,24 +2691,24 @@ function mpProjectJson$1() {
|
|
|
2688
2691
|
var mpProjectJson_1 = mpProjectJson$1;
|
|
2689
2692
|
|
|
2690
2693
|
const {
|
|
2691
|
-
src: src$
|
|
2692
|
-
dest
|
|
2693
|
-
} = require$$0__default$
|
|
2694
|
-
const path$
|
|
2694
|
+
src: src$2,
|
|
2695
|
+
dest: dest$1
|
|
2696
|
+
} = require$$0__default$8;
|
|
2697
|
+
const path$6 = require$$1__default$1;
|
|
2695
2698
|
const minimatch = require$$2__default;
|
|
2696
|
-
const gulpif = require$$3__default;
|
|
2699
|
+
const gulpif = require$$3__default$1;
|
|
2697
2700
|
const mpProjectJson = mpProjectJson_1;
|
|
2698
2701
|
const {
|
|
2699
|
-
resolve: resolve$
|
|
2702
|
+
resolve: resolve$b
|
|
2700
2703
|
} = widgets;
|
|
2701
2704
|
const through = require$$6__default;
|
|
2702
2705
|
const {
|
|
2703
|
-
fail: fail$
|
|
2706
|
+
fail: fail$3
|
|
2704
2707
|
} = log$1;
|
|
2705
2708
|
|
|
2706
|
-
const getTargetFile$
|
|
2707
|
-
const sourceFileRelativeModule = path$
|
|
2708
|
-
const targetFile = resolve$
|
|
2709
|
+
const getTargetFile$2 = (sourceFile, module, outputDir) => {
|
|
2710
|
+
const sourceFileRelativeModule = path$6.relative(resolve$b(module.from), sourceFile);
|
|
2711
|
+
const targetFile = resolve$b(outputDir, module.to, sourceFileRelativeModule);
|
|
2709
2712
|
return targetFile;
|
|
2710
2713
|
};
|
|
2711
2714
|
|
|
@@ -2723,7 +2726,7 @@ const addPlugins = function (tmsConfig, srcPipe, pluginParams) {
|
|
|
2723
2726
|
tmsConfig,
|
|
2724
2727
|
sourceFile,
|
|
2725
2728
|
vinyl,
|
|
2726
|
-
targetFile: getTargetFile$
|
|
2729
|
+
targetFile: getTargetFile$2(sourceFile, pluginParams.module, tmsConfig.outputDir),
|
|
2727
2730
|
isDev: pluginParams.isDev,
|
|
2728
2731
|
next
|
|
2729
2732
|
});
|
|
@@ -2744,15 +2747,15 @@ var compile$1 = function (tmsConfig, {
|
|
|
2744
2747
|
taskFn: (sourceFile, targetPath) => {
|
|
2745
2748
|
const newGlobValue = Array.isArray(sourceFile) ? sourceFile : glob;
|
|
2746
2749
|
const newDestPath = targetPath ? targetPath : destPath;
|
|
2747
|
-
let srcPipe = src$
|
|
2750
|
+
let srcPipe = src$2(newGlobValue, { ...srcOption
|
|
2748
2751
|
});
|
|
2749
2752
|
const pluginParams = {
|
|
2750
2753
|
module,
|
|
2751
2754
|
isDev
|
|
2752
2755
|
};
|
|
2753
2756
|
srcPipe = addPlugins(tmsConfig, srcPipe, pluginParams);
|
|
2754
|
-
return srcPipe.pipe(dest(newDestPath)).on('error', err => {
|
|
2755
|
-
fail$
|
|
2757
|
+
return srcPipe.pipe(dest$1(newDestPath)).on('error', err => {
|
|
2758
|
+
fail$3(`编译报错${err}`);
|
|
2756
2759
|
});
|
|
2757
2760
|
}
|
|
2758
2761
|
});
|
|
@@ -2762,10 +2765,10 @@ var compile$1 = function (tmsConfig, {
|
|
|
2762
2765
|
/* eslint-disable */
|
|
2763
2766
|
// 该文件源于npm包 gulp-watch 但内部有bug, 故源码进行单独修改
|
|
2764
2767
|
|
|
2765
|
-
const assign = require$$0__default$
|
|
2766
|
-
const path$
|
|
2768
|
+
const assign = require$$0__default$9;
|
|
2769
|
+
const path$5 = require$$1__default$1;
|
|
2767
2770
|
const PluginError = require$$2__default$1;
|
|
2768
|
-
const fancyLog = require$$3__default$
|
|
2771
|
+
const fancyLog = require$$3__default$2;
|
|
2769
2772
|
const colors = require$$4__default$1;
|
|
2770
2773
|
const chokidar = require$$5__default;
|
|
2771
2774
|
const {
|
|
@@ -2794,7 +2797,7 @@ function normalizeGlobs(globs) {
|
|
|
2794
2797
|
return globs;
|
|
2795
2798
|
}
|
|
2796
2799
|
|
|
2797
|
-
function watch$
|
|
2800
|
+
function watch$3(globs, opts, cb) {
|
|
2798
2801
|
globs = normalizeGlobs(globs);
|
|
2799
2802
|
|
|
2800
2803
|
if (typeof opts === 'function') {
|
|
@@ -2802,16 +2805,16 @@ function watch$2(globs, opts, cb) {
|
|
|
2802
2805
|
opts = {};
|
|
2803
2806
|
}
|
|
2804
2807
|
|
|
2805
|
-
opts = assign({}, watch$
|
|
2808
|
+
opts = assign({}, watch$3._defaultOptions, opts);
|
|
2806
2809
|
|
|
2807
2810
|
cb = cb || function () {};
|
|
2808
2811
|
|
|
2809
2812
|
function resolveFilepath(filepath) {
|
|
2810
2813
|
if (pathIsAbsolute(filepath)) {
|
|
2811
|
-
return path$
|
|
2814
|
+
return path$5.normalize(filepath);
|
|
2812
2815
|
}
|
|
2813
2816
|
|
|
2814
|
-
return path$
|
|
2817
|
+
return path$5.resolve(opts.cwd || process.cwd(), filepath);
|
|
2815
2818
|
}
|
|
2816
2819
|
|
|
2817
2820
|
function resolveGlob(glob) {
|
|
@@ -2867,7 +2870,7 @@ function watch$2(globs, opts, cb) {
|
|
|
2867
2870
|
let glob;
|
|
2868
2871
|
let currentFilepath = filepath;
|
|
2869
2872
|
|
|
2870
|
-
while (!(glob = globs[anymatch(globs, currentFilepath, true)]) && currentFilepath !== (currentFilepath = path$
|
|
2873
|
+
while (!(glob = globs[anymatch(globs, currentFilepath, true)]) && currentFilepath !== (currentFilepath = path$5.dirname(currentFilepath))) {} // eslint-disable-line no-empty-blocks/no-empty-blocks
|
|
2871
2874
|
|
|
2872
2875
|
|
|
2873
2876
|
if (!glob) {
|
|
@@ -2876,7 +2879,7 @@ function watch$2(globs, opts, cb) {
|
|
|
2876
2879
|
}
|
|
2877
2880
|
|
|
2878
2881
|
if (!baseForced) {
|
|
2879
|
-
fileOpts.base = path$
|
|
2882
|
+
fileOpts.base = path$5.normalize(globParent(glob));
|
|
2880
2883
|
} // Do not stat deleted files
|
|
2881
2884
|
|
|
2882
2885
|
|
|
@@ -2927,27 +2930,27 @@ function watch$2(globs, opts, cb) {
|
|
|
2927
2930
|
// Avoid modifying gulp-watch's default options inside a library/reusable package, please.
|
|
2928
2931
|
|
|
2929
2932
|
|
|
2930
|
-
watch$
|
|
2933
|
+
watch$3._defaultOptions = {
|
|
2931
2934
|
events: ['add', 'change', 'unlink'],
|
|
2932
2935
|
ignoreInitial: true,
|
|
2933
2936
|
readDelay: 10
|
|
2934
2937
|
};
|
|
2935
|
-
var gulpWatch = watch$
|
|
2938
|
+
var gulpWatch = watch$3;
|
|
2936
2939
|
|
|
2937
2940
|
/* eslint-disable no-restricted-syntax */
|
|
2938
|
-
const watch$
|
|
2939
|
-
const path$
|
|
2940
|
-
const shellJs = require$$0__default$
|
|
2941
|
+
const watch$2 = gulpWatch;
|
|
2942
|
+
const path$4 = require$$1__default$1;
|
|
2943
|
+
const shellJs$2 = require$$0__default$2;
|
|
2941
2944
|
const {
|
|
2942
|
-
series: series$
|
|
2943
|
-
} = require$$0__default$
|
|
2945
|
+
series: series$2
|
|
2946
|
+
} = require$$0__default$8;
|
|
2944
2947
|
const {
|
|
2945
|
-
info: info$
|
|
2948
|
+
info: info$a,
|
|
2946
2949
|
warn: warn$1,
|
|
2947
|
-
fail: fail$
|
|
2950
|
+
fail: fail$2
|
|
2948
2951
|
} = log$1;
|
|
2949
2952
|
const {
|
|
2950
|
-
resolve: resolve$
|
|
2953
|
+
resolve: resolve$a,
|
|
2951
2954
|
filterField: filterField$5
|
|
2952
2955
|
} = widgets;
|
|
2953
2956
|
const {
|
|
@@ -2985,31 +2988,31 @@ const logTip = (fileName, sourceFile, targetFile, tipMap) => {
|
|
|
2985
2988
|
}
|
|
2986
2989
|
}
|
|
2987
2990
|
|
|
2988
|
-
info$
|
|
2991
|
+
info$a(`${fileName}有更新`);
|
|
2989
2992
|
} catch (e) {
|
|
2990
|
-
fail$
|
|
2993
|
+
fail$2(`${sourceFile}文件更新提示出现错误: ${e.message}`);
|
|
2991
2994
|
}
|
|
2992
2995
|
};
|
|
2993
2996
|
|
|
2994
|
-
const getTargetFile = (sourceFile, module, outputDir) => {
|
|
2995
|
-
const sourceFileRelativeModule = path$
|
|
2996
|
-
const targetFile = resolve$
|
|
2997
|
+
const getTargetFile$1 = (sourceFile, module, outputDir) => {
|
|
2998
|
+
const sourceFileRelativeModule = path$4.relative(resolve$a(module.from), sourceFile);
|
|
2999
|
+
const targetFile = resolve$a(outputDir, module.to, sourceFileRelativeModule);
|
|
2997
3000
|
return targetFile;
|
|
2998
3001
|
};
|
|
2999
3002
|
|
|
3000
3003
|
var watch_1 = function (globValue, watchOptions, callback, module) {
|
|
3001
|
-
watch$
|
|
3004
|
+
watch$2(globValue, { // readDelay: 100,
|
|
3002
3005
|
...watchOptions
|
|
3003
3006
|
}, vinyl => {
|
|
3004
3007
|
const sourceFile = vinyl.history[0];
|
|
3005
3008
|
const sourceFileDirArr = sourceFile.replace(/\\/g, '/').split('/');
|
|
3006
3009
|
const sourceFileName = sourceFileDirArr.slice(sourceFileDirArr.length - 2).join('/');
|
|
3007
3010
|
const tmsConfig = global$6.getData('tmsConfig');
|
|
3008
|
-
const targetFile = getTargetFile(sourceFile, module, tmsConfig.outputDir);
|
|
3011
|
+
const targetFile = getTargetFile$1(sourceFile, module, tmsConfig.outputDir);
|
|
3009
3012
|
|
|
3010
3013
|
if (vinyl.event === 'unlink' || vinyl.event === 'unlinkDir') {
|
|
3011
|
-
info$
|
|
3012
|
-
shellJs.rm('-rf', targetFile);
|
|
3014
|
+
info$a(`删除${sourceFileName}`);
|
|
3015
|
+
shellJs$2.rm('-rf', targetFile);
|
|
3013
3016
|
updateFileHook(tmsConfig, sourceFile, targetFile, vinyl.event);
|
|
3014
3017
|
return;
|
|
3015
3018
|
}
|
|
@@ -3036,13 +3039,13 @@ async function runCallback({
|
|
|
3036
3039
|
// callbacl.name === taskFn 代表进入gulp编译流程
|
|
3037
3040
|
// series为gulp编译串行执行,callback执行完毕后,执行updateFileHooks钩子
|
|
3038
3041
|
if (callback.name === 'taskFn') {
|
|
3039
|
-
series$
|
|
3042
|
+
series$2(callback.bind(null, [sourceFile], path$4.dirname(targetFile)), cb => {
|
|
3040
3043
|
cb();
|
|
3041
3044
|
updateFileHook(tmsConfig, sourceFile, targetFile, type);
|
|
3042
3045
|
})();
|
|
3043
3046
|
} else {
|
|
3044
3047
|
// 普通的callback函数
|
|
3045
|
-
await callback([sourceFile], path$
|
|
3048
|
+
await callback([sourceFile], path$4.dirname(targetFile));
|
|
3046
3049
|
await updateFileHook(tmsConfig, sourceFile, targetFile, type);
|
|
3047
3050
|
}
|
|
3048
3051
|
} // 执行源码文件更新的钩子
|
|
@@ -3063,19 +3066,19 @@ async function updateFileHook(tmsConfig, sourceFile, targetFile, type) {
|
|
|
3063
3066
|
}
|
|
3064
3067
|
}
|
|
3065
3068
|
|
|
3066
|
-
const path$
|
|
3067
|
-
const fs$
|
|
3068
|
-
const ora = require$$0__default
|
|
3069
|
-
const chalk$
|
|
3069
|
+
const path$3 = require$$1__default$1;
|
|
3070
|
+
const fs$6 = require$$0__default$1;
|
|
3071
|
+
const ora$1 = require$$0__default;
|
|
3072
|
+
const chalk$3 = require$$3__default;
|
|
3070
3073
|
const {
|
|
3071
|
-
parallel,
|
|
3072
|
-
series
|
|
3073
|
-
} = require$$0__default$
|
|
3074
|
+
parallel: parallel$1,
|
|
3075
|
+
series: series$1
|
|
3076
|
+
} = require$$0__default$8;
|
|
3074
3077
|
const {
|
|
3075
|
-
resolve: resolve$
|
|
3078
|
+
resolve: resolve$9,
|
|
3076
3079
|
mergeMap,
|
|
3077
3080
|
filterField: filterField$4,
|
|
3078
|
-
getAbsolutePath: getAbsolutePath$
|
|
3081
|
+
getAbsolutePath: getAbsolutePath$3
|
|
3079
3082
|
} = widgets;
|
|
3080
3083
|
const {
|
|
3081
3084
|
buildOutputAppJson
|
|
@@ -3084,9 +3087,9 @@ const {
|
|
|
3084
3087
|
DEFAULT_COPY_CONFIG
|
|
3085
3088
|
} = constant;
|
|
3086
3089
|
const compile = compile$1;
|
|
3087
|
-
const watch = watch_1;
|
|
3090
|
+
const watch$1 = watch_1;
|
|
3088
3091
|
const {
|
|
3089
|
-
info: info$
|
|
3092
|
+
info: info$9
|
|
3090
3093
|
} = log$1;
|
|
3091
3094
|
const report$6 = report_1;
|
|
3092
3095
|
const {
|
|
@@ -3094,16 +3097,16 @@ const {
|
|
|
3094
3097
|
} = global_1;
|
|
3095
3098
|
const watchEvents = ['add', 'change', 'unlink', 'addDir', 'unlinkDir'];
|
|
3096
3099
|
|
|
3097
|
-
var dev$
|
|
3100
|
+
var dev$4 = async (tmsConfig, modules, isDev = true) => {
|
|
3098
3101
|
const compileTasksMap = new Map(); // 监听根目录的文件
|
|
3099
3102
|
|
|
3100
3103
|
mergeMap(compileTasksMap, compile(tmsConfig, {
|
|
3101
|
-
glob: DEFAULT_COPY_CONFIG.map(item => resolve$
|
|
3104
|
+
glob: DEFAULT_COPY_CONFIG.map(item => resolve$9(item)),
|
|
3102
3105
|
module: {
|
|
3103
|
-
from: resolve$
|
|
3104
|
-
to: resolve$
|
|
3106
|
+
from: resolve$9(),
|
|
3107
|
+
to: resolve$9(tmsConfig.outputDir)
|
|
3105
3108
|
},
|
|
3106
|
-
destPath: resolve$
|
|
3109
|
+
destPath: resolve$9(tmsConfig.outputDir),
|
|
3107
3110
|
srcOption: {
|
|
3108
3111
|
allowEmpty: true
|
|
3109
3112
|
},
|
|
@@ -3117,12 +3120,12 @@ var dev$3 = async (tmsConfig, modules, isDev = true) => {
|
|
|
3117
3120
|
},
|
|
3118
3121
|
...moduleItem
|
|
3119
3122
|
};
|
|
3120
|
-
const srcModulePath = getAbsolutePath$
|
|
3121
|
-
const buildModulePath = resolve$
|
|
3123
|
+
const srcModulePath = getAbsolutePath$3(moduleItem.path);
|
|
3124
|
+
const buildModulePath = resolve$9(tmsConfig.outputDir, moduleItem.modulePath);
|
|
3122
3125
|
|
|
3123
3126
|
if (isDev) {
|
|
3124
3127
|
// 监听模块配置文件
|
|
3125
|
-
watch([`${srcModulePath}/**/module.config.json`], {
|
|
3128
|
+
watch$1([`${srcModulePath}/**/module.config.json`], {
|
|
3126
3129
|
events: watchEvents
|
|
3127
3130
|
}, () => buildOutputAppJson(tmsConfig, modules, isDev), {
|
|
3128
3131
|
from: srcModulePath,
|
|
@@ -3131,14 +3134,14 @@ var dev$3 = async (tmsConfig, modules, isDev = true) => {
|
|
|
3131
3134
|
}
|
|
3132
3135
|
|
|
3133
3136
|
const excludes = moduleItem.exclude.map(ePath => {
|
|
3134
|
-
const newPath = getAbsolutePath$
|
|
3135
|
-
const ext = path$
|
|
3137
|
+
const newPath = getAbsolutePath$3(ePath, srcModulePath);
|
|
3138
|
+
const ext = path$3.extname(ePath).slice(1);
|
|
3136
3139
|
|
|
3137
3140
|
if (ext) {
|
|
3138
|
-
return `!${resolve$
|
|
3141
|
+
return `!${resolve$9(srcModulePath, newPath)}`;
|
|
3139
3142
|
}
|
|
3140
3143
|
|
|
3141
|
-
return `!${resolve$
|
|
3144
|
+
return `!${resolve$9(srcModulePath, newPath)}/**/*`;
|
|
3142
3145
|
});
|
|
3143
3146
|
mergeMap(compileTasksMap, compile(tmsConfig, {
|
|
3144
3147
|
glob: [`${srcModulePath}/**/*`, `!${srcModulePath}/**/module.config.json`, ...excludes],
|
|
@@ -3157,10 +3160,10 @@ var dev$3 = async (tmsConfig, modules, isDev = true) => {
|
|
|
3157
3160
|
|
|
3158
3161
|
if (tmsConfig !== null && tmsConfig !== void 0 && tmsConfig.static && (tmsConfig === null || tmsConfig === void 0 ? void 0 : tmsConfig.static.length) > 0) {
|
|
3159
3162
|
for (const item of tmsConfig.static) {
|
|
3160
|
-
item.from = getAbsolutePath$
|
|
3161
|
-
item.to = getAbsolutePath$
|
|
3163
|
+
item.from = getAbsolutePath$3(item.from);
|
|
3164
|
+
item.to = getAbsolutePath$3(item.to);
|
|
3162
3165
|
let glob = {};
|
|
3163
|
-
const ext = path$
|
|
3166
|
+
const ext = path$3.extname(item.from).slice(1);
|
|
3164
3167
|
|
|
3165
3168
|
if (ext) {
|
|
3166
3169
|
glob = [item.from];
|
|
@@ -3168,7 +3171,7 @@ var dev$3 = async (tmsConfig, modules, isDev = true) => {
|
|
|
3168
3171
|
glob = [`${item.from}/**/*`];
|
|
3169
3172
|
}
|
|
3170
3173
|
|
|
3171
|
-
const from = fs$
|
|
3174
|
+
const from = fs$6.lstatSync(item.from).isFile() ? path$3.dirname(item.from) : item.from;
|
|
3172
3175
|
mergeMap(compileTasksMap, compile(tmsConfig, {
|
|
3173
3176
|
glob,
|
|
3174
3177
|
destPath: item.to,
|
|
@@ -3186,10 +3189,10 @@ var dev$3 = async (tmsConfig, modules, isDev = true) => {
|
|
|
3186
3189
|
|
|
3187
3190
|
let sTime;
|
|
3188
3191
|
let eTime;
|
|
3189
|
-
const spinner = ora();
|
|
3192
|
+
const spinner = ora$1();
|
|
3190
3193
|
|
|
3191
3194
|
function start(cb) {
|
|
3192
|
-
info$
|
|
3195
|
+
info$9('启动编译...');
|
|
3193
3196
|
spinner.start();
|
|
3194
3197
|
sTime = new Date().getTime();
|
|
3195
3198
|
cb();
|
|
@@ -3200,19 +3203,19 @@ var dev$3 = async (tmsConfig, modules, isDev = true) => {
|
|
|
3200
3203
|
|
|
3201
3204
|
if (isDev) {
|
|
3202
3205
|
// 监听app.json
|
|
3203
|
-
watch([resolve$
|
|
3206
|
+
watch$1([resolve$9('app.json')], {
|
|
3204
3207
|
ignoreInitial: false,
|
|
3205
3208
|
events: watchEvents
|
|
3206
3209
|
}, () => buildOutputAppJson(tmsConfig, modules, isDev), {
|
|
3207
|
-
from: resolve$
|
|
3208
|
-
to: resolve$
|
|
3210
|
+
from: resolve$9(),
|
|
3211
|
+
to: resolve$9(tmsConfig.outputDir)
|
|
3209
3212
|
}); // 监听其他文件
|
|
3210
3213
|
|
|
3211
3214
|
compileTasksMap.forEach(({
|
|
3212
3215
|
taskFn,
|
|
3213
3216
|
module
|
|
3214
3217
|
}, globValue) => {
|
|
3215
|
-
watch(globValue, {
|
|
3218
|
+
watch$1(globValue, {
|
|
3216
3219
|
ignoreInitial: true,
|
|
3217
3220
|
events: watchEvents
|
|
3218
3221
|
}, taskFn, module);
|
|
@@ -3235,7 +3238,7 @@ var dev$3 = async (tmsConfig, modules, isDev = true) => {
|
|
|
3235
3238
|
report$6('hooks:afterCompile');
|
|
3236
3239
|
}
|
|
3237
3240
|
|
|
3238
|
-
spinner.succeed(chalk$
|
|
3241
|
+
spinner.succeed(chalk$3.green(`首次编译完成, 耗时${eTime / 1000}s, 微信开发者工具打开项目即可预览。`));
|
|
3239
3242
|
spinner.stop();
|
|
3240
3243
|
cb();
|
|
3241
3244
|
}
|
|
@@ -3247,13 +3250,13 @@ var dev$3 = async (tmsConfig, modules, isDev = true) => {
|
|
|
3247
3250
|
compileTasks.push(taskFn);
|
|
3248
3251
|
}); // 一次性完成编译任务(编译完成后再添加watch任务-封装到end函数里面)
|
|
3249
3252
|
|
|
3250
|
-
series(start, parallel(...compileTasks), end)();
|
|
3253
|
+
series$1(start, parallel$1(...compileTasks), end)();
|
|
3251
3254
|
};
|
|
3252
3255
|
|
|
3253
|
-
const shelljs$1 = require$$0__default$
|
|
3254
|
-
const compileDev = dev$
|
|
3256
|
+
const shelljs$1 = require$$0__default$2;
|
|
3257
|
+
const compileDev = dev$4;
|
|
3255
3258
|
const {
|
|
3256
|
-
resolve: resolve$
|
|
3259
|
+
resolve: resolve$8,
|
|
3257
3260
|
filterField: filterField$3
|
|
3258
3261
|
} = widgets;
|
|
3259
3262
|
const init$2 = init_1;
|
|
@@ -3262,7 +3265,7 @@ const {
|
|
|
3262
3265
|
getSubPackages: getSubPackages$1
|
|
3263
3266
|
} = tmsMpconfig.exports;
|
|
3264
3267
|
const {
|
|
3265
|
-
info: info$
|
|
3268
|
+
info: info$8
|
|
3266
3269
|
} = log$1;
|
|
3267
3270
|
const {
|
|
3268
3271
|
global: global$4
|
|
@@ -3282,7 +3285,7 @@ function delOtherPackages(tmsConfig, targetSubPackages) {
|
|
|
3282
3285
|
const targetSubPackagesName = targetSubPackages.map(item => item.name);
|
|
3283
3286
|
allSubPackages.forEach(item => {
|
|
3284
3287
|
if (item.root && targetSubPackagesName.indexOf(item.name) === -1) {
|
|
3285
|
-
const moduleRootDir = resolve$
|
|
3288
|
+
const moduleRootDir = resolve$8(`${tmsConfig.outputDir}/${item.root}`);
|
|
3286
3289
|
shelljs$1.rm('-rf', `${moduleRootDir}/*`, {
|
|
3287
3290
|
silent: true
|
|
3288
3291
|
}); // 解决微信开发者工具(dist/app.json: ["subpackages"][0]["root"] 字段需为 目录)错误 - 提前创建该目录
|
|
@@ -3291,7 +3294,7 @@ function delOtherPackages(tmsConfig, targetSubPackages) {
|
|
|
3291
3294
|
});
|
|
3292
3295
|
}
|
|
3293
3296
|
|
|
3294
|
-
async function dev$
|
|
3297
|
+
async function dev$3(tmsConfig, targetModules) {
|
|
3295
3298
|
var _tmsConfig$hooks;
|
|
3296
3299
|
|
|
3297
3300
|
const {
|
|
@@ -3299,7 +3302,7 @@ async function dev$2(tmsConfig, targetModules) {
|
|
|
3299
3302
|
} = global$4.getData('cmdOptions');
|
|
3300
3303
|
|
|
3301
3304
|
if (noCache) {
|
|
3302
|
-
shelljs$1.rm('-rf', resolve$
|
|
3305
|
+
shelljs$1.rm('-rf', resolve$8(tmsConfig.outputDir));
|
|
3303
3306
|
shelljs$1.rm('-rf', MODULE_CODE_DIR);
|
|
3304
3307
|
shelljs$1.rm('-rf', NODE_MODULES_DIR);
|
|
3305
3308
|
} // 推荐tmskit的版本
|
|
@@ -3311,7 +3314,7 @@ async function dev$2(tmsConfig, targetModules) {
|
|
|
3311
3314
|
subPackages,
|
|
3312
3315
|
modules: newModules
|
|
3313
3316
|
} = await init$2(tmsConfig, targetModules);
|
|
3314
|
-
info$
|
|
3317
|
+
info$8('当前dev启动的有效模块', newModules.map(item => item.moduleName).sort());
|
|
3315
3318
|
|
|
3316
3319
|
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
3320
|
var _tmsConfig$hooks2;
|
|
@@ -3328,22 +3331,22 @@ async function dev$2(tmsConfig, targetModules) {
|
|
|
3328
3331
|
compileDev(tmsConfig, newModules, true);
|
|
3329
3332
|
}
|
|
3330
3333
|
|
|
3331
|
-
var dev_1 = dev$
|
|
3334
|
+
var dev_1 = dev$3;
|
|
3332
3335
|
|
|
3333
|
-
const dev$
|
|
3336
|
+
const dev$2 = dev$4;
|
|
3334
3337
|
|
|
3335
3338
|
var build$2 = async (tmsConfig, newModules, isDev) => {
|
|
3336
|
-
dev$
|
|
3339
|
+
dev$2(tmsConfig, newModules, isDev);
|
|
3337
3340
|
};
|
|
3338
3341
|
|
|
3339
|
-
const shelljs = require$$0__default$
|
|
3342
|
+
const shelljs = require$$0__default$2;
|
|
3340
3343
|
const {
|
|
3341
|
-
resolve: resolve$
|
|
3344
|
+
resolve: resolve$7,
|
|
3342
3345
|
filterField: filterField$2
|
|
3343
3346
|
} = widgets;
|
|
3344
3347
|
const init$1 = init_1;
|
|
3345
3348
|
const {
|
|
3346
|
-
info: info$
|
|
3349
|
+
info: info$7
|
|
3347
3350
|
} = log$1;
|
|
3348
3351
|
const compileBuild = build$2;
|
|
3349
3352
|
const report$4 = report_1;
|
|
@@ -3355,11 +3358,11 @@ async function build$1(tmsConfig, targetModules) {
|
|
|
3355
3358
|
var _tmsConfig$hooks;
|
|
3356
3359
|
|
|
3357
3360
|
// 开始构建前,清理输出目录
|
|
3358
|
-
await shelljs.rm('-rf', resolve$
|
|
3361
|
+
await shelljs.rm('-rf', resolve$7(tmsConfig.outputDir));
|
|
3359
3362
|
const {
|
|
3360
3363
|
modules: newModules
|
|
3361
3364
|
} = await init$1(tmsConfig, targetModules);
|
|
3362
|
-
info$
|
|
3365
|
+
info$7('当前build有效模块', newModules.map(item => item.moduleName).sort());
|
|
3363
3366
|
const isDev = false;
|
|
3364
3367
|
|
|
3365
3368
|
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 +3382,14 @@ async function build$1(tmsConfig, targetModules) {
|
|
|
3379
3382
|
var build_1 = build$1;
|
|
3380
3383
|
|
|
3381
3384
|
const moment = require$$1__default;
|
|
3382
|
-
const path$
|
|
3383
|
-
const fs$
|
|
3385
|
+
const path$2 = require$$1__default$1;
|
|
3386
|
+
const fs$5 = require$$0__default$1;
|
|
3384
3387
|
const {
|
|
3385
3388
|
getGitUser,
|
|
3386
|
-
getAbsolutePath: getAbsolutePath$
|
|
3389
|
+
getAbsolutePath: getAbsolutePath$2
|
|
3387
3390
|
} = widgets;
|
|
3388
3391
|
const {
|
|
3389
|
-
ensureDirExist: ensureDirExist$
|
|
3392
|
+
ensureDirExist: ensureDirExist$3
|
|
3390
3393
|
} = io$3;
|
|
3391
3394
|
|
|
3392
3395
|
function getAllSize$2(data = {}) {
|
|
@@ -3409,10 +3412,10 @@ const getDesc$2 = (desc = '') => {
|
|
|
3409
3412
|
};
|
|
3410
3413
|
|
|
3411
3414
|
const outputInfo$2 = (infoOutput, data) => {
|
|
3412
|
-
const outPath = getAbsolutePath$
|
|
3413
|
-
const dir = path$
|
|
3414
|
-
ensureDirExist$
|
|
3415
|
-
fs$
|
|
3415
|
+
const outPath = getAbsolutePath$2(infoOutput);
|
|
3416
|
+
const dir = path$2.dirname(outPath);
|
|
3417
|
+
ensureDirExist$3(dir);
|
|
3418
|
+
fs$5.writeFileSync(outPath, JSON.stringify(data, null, 2));
|
|
3416
3419
|
};
|
|
3417
3420
|
|
|
3418
3421
|
const getDetaultVersion = () => {
|
|
@@ -3429,18 +3432,18 @@ var utils = {
|
|
|
3429
3432
|
};
|
|
3430
3433
|
|
|
3431
3434
|
const mpCi$1 = mpCi$2;
|
|
3432
|
-
const fs$
|
|
3435
|
+
const fs$4 = require$$0__default$1;
|
|
3433
3436
|
const {
|
|
3434
|
-
resolve: resolve$
|
|
3435
|
-
createTask: createTask$
|
|
3436
|
-
getAbsolutePath,
|
|
3437
|
+
resolve: resolve$6,
|
|
3438
|
+
createTask: createTask$2,
|
|
3439
|
+
getAbsolutePath: getAbsolutePath$1,
|
|
3437
3440
|
filterField: filterField$1
|
|
3438
3441
|
} = widgets;
|
|
3439
3442
|
const {
|
|
3440
|
-
handleError: handleError$
|
|
3443
|
+
handleError: handleError$3
|
|
3441
3444
|
} = handleError_1;
|
|
3442
3445
|
const {
|
|
3443
|
-
info: info$
|
|
3446
|
+
info: info$6
|
|
3444
3447
|
} = log$1;
|
|
3445
3448
|
const {
|
|
3446
3449
|
global: global$2
|
|
@@ -3458,11 +3461,11 @@ const handleParams$1 = (tmsConfig, cmdOptions) => {
|
|
|
3458
3461
|
};
|
|
3459
3462
|
return { ...params,
|
|
3460
3463
|
appId: params.appId || tmsConfig.appId,
|
|
3461
|
-
projectPath: resolve$
|
|
3464
|
+
projectPath: resolve$6(tmsConfig.outputDir),
|
|
3462
3465
|
privateKey: params.privateKey || tmsConfig.privateKey,
|
|
3463
3466
|
robot: params.robot || 30,
|
|
3464
3467
|
desc: params.desc || getDesc$1(params.desc),
|
|
3465
|
-
qrcodeOutputDest: getAbsolutePath(params.qrcodeOutputDest || '')
|
|
3468
|
+
qrcodeOutputDest: getAbsolutePath$1(params.qrcodeOutputDest || '')
|
|
3466
3469
|
};
|
|
3467
3470
|
};
|
|
3468
3471
|
/**
|
|
@@ -3490,15 +3493,15 @@ async function preview$1(tmsConfig, cmdOptions) {
|
|
|
3490
3493
|
}
|
|
3491
3494
|
|
|
3492
3495
|
;
|
|
3493
|
-
const previewRes = await createTask$
|
|
3496
|
+
const previewRes = await createTask$2(mpCi$1.previewMp, '正在构建预览码', '构建预览码完成')({ ...params
|
|
3494
3497
|
});
|
|
3495
3498
|
const allSize = getAllSize$1(previewRes);
|
|
3496
3499
|
|
|
3497
3500
|
if (params.infoOutput) {
|
|
3498
3501
|
let qrcodeBase64 = '';
|
|
3499
3502
|
|
|
3500
|
-
if (params.qrcodeFormat === 'base64' && fs$
|
|
3501
|
-
qrcodeBase64 = fs$
|
|
3503
|
+
if (params.qrcodeFormat === 'base64' && fs$4.existsSync(params.qrcodeOutputDest)) {
|
|
3504
|
+
qrcodeBase64 = fs$4.readFileSync(params.qrcodeOutputDest, 'utf8');
|
|
3502
3505
|
}
|
|
3503
3506
|
|
|
3504
3507
|
outputInfo$1(params.infoOutput, {
|
|
@@ -3508,10 +3511,10 @@ async function preview$1(tmsConfig, cmdOptions) {
|
|
|
3508
3511
|
});
|
|
3509
3512
|
}
|
|
3510
3513
|
|
|
3511
|
-
info$
|
|
3514
|
+
info$6('预览包大小:', `${allSize}k`);
|
|
3512
3515
|
} catch (e) {
|
|
3513
3516
|
console.log('详细错误:', e);
|
|
3514
|
-
handleError$
|
|
3517
|
+
handleError$3(`预览错误: ${e.message}`, true);
|
|
3515
3518
|
}
|
|
3516
3519
|
}
|
|
3517
3520
|
|
|
@@ -3519,15 +3522,15 @@ var preview_1 = preview$1;
|
|
|
3519
3522
|
|
|
3520
3523
|
const mpCi = mpCi$2;
|
|
3521
3524
|
const {
|
|
3522
|
-
resolve: resolve$
|
|
3523
|
-
createTask,
|
|
3525
|
+
resolve: resolve$5,
|
|
3526
|
+
createTask: createTask$1,
|
|
3524
3527
|
filterField
|
|
3525
3528
|
} = widgets;
|
|
3526
3529
|
const {
|
|
3527
|
-
handleError: handleError$
|
|
3530
|
+
handleError: handleError$2
|
|
3528
3531
|
} = handleError_1;
|
|
3529
3532
|
const {
|
|
3530
|
-
info: info$
|
|
3533
|
+
info: info$5
|
|
3531
3534
|
} = log$1;
|
|
3532
3535
|
const {
|
|
3533
3536
|
global: global$1
|
|
@@ -3550,7 +3553,7 @@ const handleParams = (tmsConfig, cmdOptions) => {
|
|
|
3550
3553
|
|
|
3551
3554
|
return { ...params,
|
|
3552
3555
|
appId: params.appId || tmsConfig.appId,
|
|
3553
|
-
projectPath: resolve$
|
|
3556
|
+
projectPath: resolve$5(tmsConfig.outputDir),
|
|
3554
3557
|
privateKey: params.privateKey || tmsConfig.privateKey,
|
|
3555
3558
|
robot: params.robot || 30,
|
|
3556
3559
|
desc: params.desc || getDesc(params.desc)
|
|
@@ -3581,7 +3584,7 @@ async function upload$1(tmsConfig, cmdOptions) {
|
|
|
3581
3584
|
}
|
|
3582
3585
|
|
|
3583
3586
|
;
|
|
3584
|
-
const uploadRes = await createTask(mpCi.uploadMp, '正在上传小程序代码', '上传小程序代码完成')({ ...params
|
|
3587
|
+
const uploadRes = await createTask$1(mpCi.uploadMp, '正在上传小程序代码', '上传小程序代码完成')({ ...params
|
|
3585
3588
|
});
|
|
3586
3589
|
const allSize = getAllSize(uploadRes);
|
|
3587
3590
|
|
|
@@ -3592,70 +3595,358 @@ async function upload$1(tmsConfig, cmdOptions) {
|
|
|
3592
3595
|
});
|
|
3593
3596
|
}
|
|
3594
3597
|
|
|
3595
|
-
info$
|
|
3598
|
+
info$5(`上传包大小: ${allSize}k; 上传包版本: ${params.version}`);
|
|
3596
3599
|
} catch (e) {
|
|
3597
3600
|
console.log('详细错误:', e);
|
|
3598
|
-
handleError$
|
|
3601
|
+
handleError$2(`上传错误: ${e.message}`, true);
|
|
3599
3602
|
}
|
|
3600
3603
|
}
|
|
3601
3604
|
|
|
3602
3605
|
var upload_1 = upload$1;
|
|
3603
3606
|
|
|
3604
|
-
const fs$1 = require$$0__default$2;
|
|
3605
3607
|
const {
|
|
3606
|
-
resolve: resolve$
|
|
3608
|
+
resolve: resolve$4,
|
|
3609
|
+
getAbsolutePath
|
|
3610
|
+
} = widgets; // 处理tms.config.cloudModules的兼容数据
|
|
3611
|
+
|
|
3612
|
+
function getTmsCloudModules(tmsConfig) {
|
|
3613
|
+
const {
|
|
3614
|
+
cloudModules
|
|
3615
|
+
} = tmsConfig;
|
|
3616
|
+
|
|
3617
|
+
if (Array.isArray(tmsConfig.cloudModules)) {
|
|
3618
|
+
return {
|
|
3619
|
+
all: [...tmsConfig.cloudModules],
|
|
3620
|
+
include: []
|
|
3621
|
+
};
|
|
3622
|
+
}
|
|
3623
|
+
|
|
3624
|
+
return cloudModules;
|
|
3625
|
+
}
|
|
3626
|
+
/**
|
|
3627
|
+
* 获取需要监听的云函数
|
|
3628
|
+
* @param {*} tmsConfig {}
|
|
3629
|
+
* @param {*} cmdOptions eg:{clouds: 'aggrecarshop,car'}
|
|
3630
|
+
* @returns
|
|
3631
|
+
* [{ name: '', sourcePath: '', targetPath: ''}]
|
|
3632
|
+
*/
|
|
3633
|
+
|
|
3634
|
+
|
|
3635
|
+
function getCloudsOfListen$2(tmsConfig, cmdOptions) {
|
|
3636
|
+
var _cmdOptions$cloud;
|
|
3637
|
+
|
|
3638
|
+
// 获取tmsconfig配置的云函数的配置项
|
|
3639
|
+
const cloudModules = getTmsCloudModules(tmsConfig);
|
|
3640
|
+
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, 默认使用所有的数据云函数列表
|
|
3641
|
+
|
|
3642
|
+
if (includeClouds.length === 0) {
|
|
3643
|
+
includeClouds = cloudModules.all.map(item => item.name);
|
|
3644
|
+
}
|
|
3645
|
+
|
|
3646
|
+
const result = [];
|
|
3647
|
+
|
|
3648
|
+
for (const item of cloudModules.all) {
|
|
3649
|
+
if (includeClouds.includes(item.name)) {
|
|
3650
|
+
result.push({
|
|
3651
|
+
name: item.name,
|
|
3652
|
+
sourcePath: `${getAbsolutePath(item.path)}`,
|
|
3653
|
+
targetPath: resolve$4(tmsConfig.cloudDir, item.name)
|
|
3654
|
+
});
|
|
3655
|
+
}
|
|
3656
|
+
}
|
|
3657
|
+
|
|
3658
|
+
return result;
|
|
3659
|
+
}
|
|
3660
|
+
|
|
3661
|
+
var getClouds = getCloudsOfListen$2;
|
|
3662
|
+
|
|
3663
|
+
const fs$3 = require$$0__default$1;
|
|
3664
|
+
/**
|
|
3665
|
+
* 检查云函数的配置项
|
|
3666
|
+
* @param {*} tmsConfig
|
|
3667
|
+
*/
|
|
3668
|
+
|
|
3669
|
+
function checkCloudConfig$2(tmsConfig) {
|
|
3670
|
+
if (!tmsConfig.cloudModules) {
|
|
3671
|
+
return '你没有在tms.config.js的cloudModules注册云函数';
|
|
3672
|
+
}
|
|
3673
|
+
|
|
3674
|
+
if (!tmsConfig.cloudDir) {
|
|
3675
|
+
return '你没有在tms.config.js配置云函数编译目录cloudDir';
|
|
3676
|
+
}
|
|
3677
|
+
|
|
3678
|
+
return;
|
|
3679
|
+
}
|
|
3680
|
+
/**
|
|
3681
|
+
* 检查云函数源码目录是否存在
|
|
3682
|
+
* @param {Array} clouds [{name: '', sourcePath: '', targetPath: ''}]
|
|
3683
|
+
*/
|
|
3684
|
+
|
|
3685
|
+
|
|
3686
|
+
function checkSrcPathIsExist$1(clouds) {
|
|
3687
|
+
for (const item of clouds) {
|
|
3688
|
+
if (!fs$3.existsSync(item.sourcePath)) {
|
|
3689
|
+
return `${item.name}云函数的${item.sourcePath}目录不存在, 请检查tms.config.js>cloudModules>all云函数的配置目录`;
|
|
3690
|
+
}
|
|
3691
|
+
}
|
|
3692
|
+
|
|
3693
|
+
return;
|
|
3694
|
+
}
|
|
3695
|
+
|
|
3696
|
+
var check$2 = {
|
|
3697
|
+
checkCloudConfig: checkCloudConfig$2,
|
|
3698
|
+
checkSrcPathIsExist: checkSrcPathIsExist$1
|
|
3699
|
+
};
|
|
3700
|
+
|
|
3701
|
+
const fs$2 = require$$0__default$1;
|
|
3702
|
+
const {
|
|
3703
|
+
info: info$4
|
|
3704
|
+
} = log$1;
|
|
3705
|
+
const {
|
|
3706
|
+
resolve: resolve$3
|
|
3607
3707
|
} = widgets;
|
|
3608
3708
|
const {
|
|
3609
|
-
ensureDirExist
|
|
3709
|
+
ensureDirExist: ensureDirExist$2
|
|
3610
3710
|
} = io$3;
|
|
3611
3711
|
const {
|
|
3612
3712
|
warn,
|
|
3613
3713
|
succeed
|
|
3614
3714
|
} = log$1;
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3715
|
+
const getCloudsOfListen$1 = getClouds;
|
|
3716
|
+
const {
|
|
3717
|
+
handleError: handleError$1
|
|
3718
|
+
} = handleError_1;
|
|
3719
|
+
const {
|
|
3720
|
+
checkCloudConfig: checkCloudConfig$1
|
|
3721
|
+
} = check$2;
|
|
3619
3722
|
|
|
3620
|
-
|
|
3621
|
-
|
|
3723
|
+
var link = async (tmsConfig, cmdOptions) => {
|
|
3724
|
+
try {
|
|
3725
|
+
ensureDirExist$2(resolve$3(tmsConfig.cloudDir));
|
|
3726
|
+
checkCloudConfig$1(tmsConfig); // 获取需要监听的云函数列表
|
|
3622
3727
|
|
|
3623
|
-
|
|
3624
|
-
tmsConfig.cloudModules.forEach(item => {
|
|
3625
|
-
const sourcePath = resolve$1(item.path);
|
|
3626
|
-
const targetPath = resolve$1(tmsConfig.cloudDir, item.name);
|
|
3728
|
+
const clouds = getCloudsOfListen$1(tmsConfig, cmdOptions); // 打印启动云函数列表
|
|
3627
3729
|
|
|
3628
|
-
|
|
3629
|
-
|
|
3730
|
+
info$4('当前启动云函数列表:', clouds.map(item => item.name).sort());
|
|
3731
|
+
clouds.forEach(item => {
|
|
3732
|
+
if (!fs$2.existsSync(item.sourcePath)) {
|
|
3733
|
+
warn(`云函数${item.sourcePath}不存在`);
|
|
3630
3734
|
return;
|
|
3631
3735
|
}
|
|
3632
3736
|
|
|
3633
|
-
|
|
3634
|
-
|
|
3737
|
+
const stat = fs$2.lstatSync(item.targetPath);
|
|
3738
|
+
|
|
3739
|
+
if (!stat.isSymbolicLink()) {
|
|
3740
|
+
fs$2.symlinkSync(item.sourcePath, item.targetPath);
|
|
3635
3741
|
}
|
|
3636
3742
|
});
|
|
3637
3743
|
succeed('云函数创建软链成功');
|
|
3638
|
-
}
|
|
3639
|
-
|
|
3744
|
+
} catch (e) {
|
|
3745
|
+
info$4('创建软链详细错误', e);
|
|
3746
|
+
handleError$1(`创建软链错误: ${e}`, true);
|
|
3640
3747
|
}
|
|
3641
3748
|
};
|
|
3642
3749
|
|
|
3643
|
-
|
|
3644
|
-
|
|
3750
|
+
const shellJs$1 = require$$0__default$2;
|
|
3751
|
+
const fs$1 = require$$0__default$1;
|
|
3752
|
+
const {
|
|
3753
|
+
resolve: resolve$2,
|
|
3754
|
+
npmInstall
|
|
3755
|
+
} = widgets;
|
|
3756
|
+
const {
|
|
3757
|
+
ensureDirExist: ensureDirExist$1
|
|
3758
|
+
} = io$3;
|
|
3759
|
+
const {
|
|
3760
|
+
info: info$3
|
|
3761
|
+
} = log$1;
|
|
3762
|
+
/**
|
|
3763
|
+
* npm install
|
|
3764
|
+
* @param {array} clouds [{name: '', sourcePath: '', targetPath: ''}]
|
|
3765
|
+
*/
|
|
3766
|
+
|
|
3767
|
+
const runInstall$1 = async (clouds, tmsConfig) => {
|
|
3768
|
+
const promises = [];
|
|
3769
|
+
|
|
3770
|
+
for (const item of clouds) {
|
|
3771
|
+
ensureDirExist$1(item.targetPath);
|
|
3772
|
+
const packageFilePath = resolve$2(item.sourcePath, 'package.json');
|
|
3773
|
+
|
|
3774
|
+
if (fs$1.existsSync(packageFilePath)) {
|
|
3775
|
+
shellJs$1.cp('-Rf', resolve$2(packageFilePath), item.targetPath);
|
|
3776
|
+
promises.push(() => {
|
|
3777
|
+
info$3(`云函数${item.name}: npm install`);
|
|
3778
|
+
return npmInstall(item.targetPath, tmsConfig.npm);
|
|
3779
|
+
});
|
|
3780
|
+
}
|
|
3781
|
+
}
|
|
3782
|
+
await Promise.all(promises.map(item => item()));
|
|
3783
|
+
};
|
|
3784
|
+
|
|
3785
|
+
var install$1 = {
|
|
3786
|
+
runInstall: runInstall$1
|
|
3645
3787
|
};
|
|
3646
3788
|
|
|
3789
|
+
const shellJs = require$$0__default$2;
|
|
3790
|
+
const ora = require$$0__default;
|
|
3791
|
+
const path$1 = require$$1__default$1;
|
|
3792
|
+
const chalk$2 = require$$3__default;
|
|
3647
3793
|
const {
|
|
3648
|
-
|
|
3649
|
-
|
|
3794
|
+
resolve: resolve$1,
|
|
3795
|
+
createTask
|
|
3796
|
+
} = widgets;
|
|
3650
3797
|
const {
|
|
3651
3798
|
handleError
|
|
3652
3799
|
} = handleError_1;
|
|
3800
|
+
const {
|
|
3801
|
+
ensureDirExist
|
|
3802
|
+
} = io$3;
|
|
3803
|
+
const {
|
|
3804
|
+
src: src$1,
|
|
3805
|
+
dest,
|
|
3806
|
+
parallel,
|
|
3807
|
+
series
|
|
3808
|
+
} = require$$0__default$8;
|
|
3809
|
+
const watch = gulpWatch;
|
|
3810
|
+
const {
|
|
3811
|
+
info: info$2,
|
|
3812
|
+
fail: fail$1
|
|
3813
|
+
} = log$1;
|
|
3814
|
+
const getCloudsOfListen = getClouds;
|
|
3815
|
+
const {
|
|
3816
|
+
checkCloudConfig,
|
|
3817
|
+
checkSrcPathIsExist
|
|
3818
|
+
} = check$2;
|
|
3819
|
+
const {
|
|
3820
|
+
runInstall
|
|
3821
|
+
} = install$1;
|
|
3822
|
+
/**
|
|
3823
|
+
* 获取云函数的编译任务
|
|
3824
|
+
* @param {array} clouds [{name: '', sourcePath: '', targetPath: ''}]
|
|
3825
|
+
* @param {object} srcOption gulp.src的参数
|
|
3826
|
+
* @returns Map {'${sourcePath}': {taskFn: () => {}, targetPath: 'xxx'}}
|
|
3827
|
+
*/
|
|
3828
|
+
|
|
3829
|
+
const getCompileTasks = (clouds, srcOption) => {
|
|
3830
|
+
const compileTasksMap = new Map();
|
|
3831
|
+
clouds.forEach(item => {
|
|
3832
|
+
compileTasksMap.set(item.sourcePath, {
|
|
3833
|
+
targetPath: item.targetPath,
|
|
3834
|
+
taskFn: (sourceFile, targetPath) => {
|
|
3835
|
+
const newGlobValue = Array.isArray(sourceFile) ? sourceFile : `${item.sourcePath}/**/*`;
|
|
3836
|
+
const newDestPath = targetPath ? targetPath : item.targetPath;
|
|
3837
|
+
const srcPipe = src$1(newGlobValue, srcOption);
|
|
3838
|
+
return srcPipe.pipe(dest(newDestPath)).on('error', err => {
|
|
3839
|
+
fail$1(`监听报错${err}`);
|
|
3840
|
+
});
|
|
3841
|
+
}
|
|
3842
|
+
});
|
|
3843
|
+
});
|
|
3844
|
+
return compileTasksMap;
|
|
3845
|
+
};
|
|
3846
|
+
|
|
3847
|
+
const getTargetFile = (sourceFile, sourcePath, targetPath) => {
|
|
3848
|
+
const sourceFileRelativeModule = path$1.relative(sourcePath, sourceFile);
|
|
3849
|
+
const targetFile = resolve$1(targetPath, sourceFileRelativeModule);
|
|
3850
|
+
return targetFile;
|
|
3851
|
+
};
|
|
3852
|
+
/**
|
|
3853
|
+
* 开始启动编译
|
|
3854
|
+
* @param {Map} compileTasksMap {'${sourcePath}': {taskFn: () => {}, targetPath: 'xxx'}}
|
|
3855
|
+
*/
|
|
3856
|
+
|
|
3857
|
+
|
|
3858
|
+
const runCompile = (compileTasksMap, callback) => {
|
|
3859
|
+
async function end(next) {
|
|
3860
|
+
// 监听其他文件
|
|
3861
|
+
compileTasksMap.forEach(({
|
|
3862
|
+
taskFn,
|
|
3863
|
+
targetPath
|
|
3864
|
+
}, sourcePath) => {
|
|
3865
|
+
runWatch(sourcePath, {
|
|
3866
|
+
ignoreInitial: true,
|
|
3867
|
+
events: ['add', 'change', 'unlink', 'addDir', 'unlinkDir']
|
|
3868
|
+
}, taskFn, targetPath);
|
|
3869
|
+
});
|
|
3870
|
+
callback && callback();
|
|
3871
|
+
next();
|
|
3872
|
+
}
|
|
3873
|
+
|
|
3874
|
+
const compileTasksArr = [];
|
|
3875
|
+
compileTasksMap.forEach(({
|
|
3876
|
+
taskFn
|
|
3877
|
+
}) => {
|
|
3878
|
+
compileTasksArr.push(taskFn);
|
|
3879
|
+
}); // 一次性完成编译任务(编译完成后再添加watch任务-封装到end函数里面)
|
|
3880
|
+
|
|
3881
|
+
series(parallel(...compileTasksArr), end)();
|
|
3882
|
+
};
|
|
3883
|
+
/**
|
|
3884
|
+
* 监听文件变动
|
|
3885
|
+
* @param {*} sourcePath 云函数的源码目录
|
|
3886
|
+
* @param {*} watchOptions gulp-watch的参数
|
|
3887
|
+
* @param {*} callback 监听到变动的回调
|
|
3888
|
+
* @param {*} targetPath 云函数的编译目录
|
|
3889
|
+
*/
|
|
3890
|
+
|
|
3891
|
+
|
|
3892
|
+
const runWatch = (sourcePath, watchOptions, callback, targetPath) => {
|
|
3893
|
+
watch(sourcePath, { ...watchOptions
|
|
3894
|
+
}, vinyl => {
|
|
3895
|
+
const sourceFile = vinyl.history[0];
|
|
3896
|
+
const sourceFileDirArr = sourceFile.replace(/\\/g, '/').split('/');
|
|
3897
|
+
const sourceFileName = sourceFileDirArr.slice(sourceFileDirArr.length - 2).join('/');
|
|
3898
|
+
const targetFile = getTargetFile(sourceFile, sourcePath, targetPath);
|
|
3899
|
+
|
|
3900
|
+
if (vinyl.event === 'unlink' || vinyl.event === 'unlinkDir') {
|
|
3901
|
+
info$2(`删除${sourceFileName}`);
|
|
3902
|
+
shellJs.rm('-rf', targetFile);
|
|
3903
|
+
return;
|
|
3904
|
+
}
|
|
3905
|
+
|
|
3906
|
+
info$2(`${sourceFileName}有更新`);
|
|
3907
|
+
return callback([sourceFile], path$1.dirname(targetFile));
|
|
3908
|
+
});
|
|
3909
|
+
};
|
|
3653
3910
|
|
|
3654
|
-
var
|
|
3911
|
+
var dev$1 = async (tmsConfig, cmdOptions) => {
|
|
3655
3912
|
try {
|
|
3656
|
-
|
|
3913
|
+
const sTime = new Date().getTime();
|
|
3914
|
+
const spinner = ora();
|
|
3915
|
+
spinner.start(); // 检查云函数的配置项
|
|
3916
|
+
|
|
3917
|
+
const configErrMsg = checkCloudConfig(tmsConfig);
|
|
3918
|
+
|
|
3919
|
+
if (configErrMsg) {
|
|
3920
|
+
throw new Error(configErrMsg);
|
|
3921
|
+
} // 确保云函数的编译目录存在
|
|
3922
|
+
|
|
3923
|
+
|
|
3924
|
+
ensureDirExist(resolve$1(tmsConfig.cloudDir)); // 获取需要监听的云函数列表
|
|
3925
|
+
|
|
3926
|
+
const clouds = getCloudsOfListen(tmsConfig, cmdOptions); // 检查云函数源码目录是否存在
|
|
3927
|
+
|
|
3928
|
+
const srcNotExistErrMsg = checkSrcPathIsExist(clouds);
|
|
3929
|
+
|
|
3930
|
+
if (srcNotExistErrMsg) {
|
|
3931
|
+
throw new Error(srcNotExistErrMsg);
|
|
3932
|
+
} // 打印启动云函数列表
|
|
3933
|
+
|
|
3934
|
+
|
|
3935
|
+
info$2('当前启动云函数列表:', clouds.map(item => item.name).sort()); // npm install
|
|
3936
|
+
|
|
3937
|
+
await createTask(runInstall, '开始npm install', 'npm install完成')(clouds, tmsConfig); // 获取云函数列表的编译任务
|
|
3938
|
+
|
|
3939
|
+
const compileTasksMap = getCompileTasks(clouds, {
|
|
3940
|
+
allowEmpty: true
|
|
3941
|
+
});
|
|
3942
|
+
runCompile(compileTasksMap, () => {
|
|
3943
|
+
const eTime = new Date().getTime() - sTime;
|
|
3944
|
+
spinner.succeed(chalk$2.green(`首次编译完成, 耗时${eTime / 1000}s, 微信开发者工具打开项目即可预览。`));
|
|
3945
|
+
spinner.stop();
|
|
3946
|
+
});
|
|
3657
3947
|
} catch (e) {
|
|
3658
|
-
|
|
3948
|
+
info$2('编译出现详细错误', e);
|
|
3949
|
+
handleError(`编译出现错误: ${e}`, true);
|
|
3659
3950
|
}
|
|
3660
3951
|
};
|
|
3661
3952
|
|
|
@@ -3666,7 +3957,8 @@ const build = build_1;
|
|
|
3666
3957
|
const install = install_1;
|
|
3667
3958
|
const preview = preview_1;
|
|
3668
3959
|
const upload = upload_1;
|
|
3669
|
-
const
|
|
3960
|
+
const cloudLink = link;
|
|
3961
|
+
const cloudDev = dev$1;
|
|
3670
3962
|
const {
|
|
3671
3963
|
fail,
|
|
3672
3964
|
info: info$1
|
|
@@ -3736,9 +4028,17 @@ async function run(commandName, cmdOptions) {
|
|
|
3736
4028
|
tmsConfig
|
|
3737
4029
|
});
|
|
3738
4030
|
|
|
3739
|
-
if (commandName === 'cloud') {
|
|
3740
|
-
|
|
3741
|
-
report$1('run:cloud', {
|
|
4031
|
+
if (commandName === 'cloud-link') {
|
|
4032
|
+
cloudLink(tmsConfig, cmdOptions);
|
|
4033
|
+
report$1('run:cloud-link', {
|
|
4034
|
+
appName: tmsConfig === null || tmsConfig === void 0 ? void 0 : tmsConfig.appName
|
|
4035
|
+
});
|
|
4036
|
+
return;
|
|
4037
|
+
}
|
|
4038
|
+
|
|
4039
|
+
if (commandName === 'cloud-dev') {
|
|
4040
|
+
cloudDev(tmsConfig, cmdOptions);
|
|
4041
|
+
report$1('run:cloud-dev', {
|
|
3742
4042
|
appName: tmsConfig === null || tmsConfig === void 0 ? void 0 : tmsConfig.appName
|
|
3743
4043
|
});
|
|
3744
4044
|
return;
|
|
@@ -3852,13 +4152,6 @@ var entry = [{
|
|
|
3852
4152
|
action: cmdOptions => {
|
|
3853
4153
|
run_1('dev', cmdOptions);
|
|
3854
4154
|
}
|
|
3855
|
-
}, {
|
|
3856
|
-
command: 'cloud',
|
|
3857
|
-
description: '云函数开发',
|
|
3858
|
-
options: [['-m, --module [moduleName]', '模块名称'], ['-e, --env [env]', '环境变量']],
|
|
3859
|
-
action: cmdOptions => {
|
|
3860
|
-
run_1('cloud', cmdOptions);
|
|
3861
|
-
}
|
|
3862
4155
|
}, {
|
|
3863
4156
|
command: 'build',
|
|
3864
4157
|
description: 'prod 打包编译',
|
|
@@ -3880,12 +4173,29 @@ var entry = [{
|
|
|
3880
4173
|
action: cmdOptions => {
|
|
3881
4174
|
run_1('upload', cmdOptions);
|
|
3882
4175
|
}
|
|
3883
|
-
}
|
|
4176
|
+
}, {
|
|
4177
|
+
command: 'cloud-dev',
|
|
4178
|
+
description: '云函数开发',
|
|
4179
|
+
options: [['--cloud [cloud]', '模块名称']],
|
|
4180
|
+
action: cmdOptions => {
|
|
4181
|
+
run_1('cloud-dev', cmdOptions);
|
|
4182
|
+
}
|
|
4183
|
+
} // {
|
|
4184
|
+
// command: 'cloud-link',
|
|
4185
|
+
// description: '云函数开发',
|
|
4186
|
+
// options: [
|
|
4187
|
+
// ['--cloud [cloud]', '模块名称'],
|
|
4188
|
+
// ],
|
|
4189
|
+
// action: (cmdOptions) => {
|
|
4190
|
+
// require('./scripts/run/index')('cloud-link', cmdOptions);
|
|
4191
|
+
// },
|
|
4192
|
+
// },
|
|
4193
|
+
]
|
|
3884
4194
|
}];
|
|
3885
4195
|
|
|
3886
4196
|
var require$$12 = {
|
|
3887
4197
|
name: "@tmsfe/tmskit",
|
|
3888
|
-
version: "0.0.
|
|
4198
|
+
version: "0.0.27",
|
|
3889
4199
|
description: "tmskit",
|
|
3890
4200
|
main: "dist/index.cjs",
|
|
3891
4201
|
bin: {
|
|
@@ -3971,7 +4281,7 @@ var require$$12 = {
|
|
|
3971
4281
|
|
|
3972
4282
|
const semver = require$$1__default$7;
|
|
3973
4283
|
const packageJson = require$$12;
|
|
3974
|
-
const chalk$1 = require$$
|
|
4284
|
+
const chalk$1 = require$$3__default;
|
|
3975
4285
|
const {
|
|
3976
4286
|
info
|
|
3977
4287
|
} = log$1;
|
|
@@ -4006,10 +4316,10 @@ function check$1() {
|
|
|
4006
4316
|
var check_1 = check$1;
|
|
4007
4317
|
|
|
4008
4318
|
/* eslint-disable no-param-reassign */
|
|
4009
|
-
const chalk = require$$
|
|
4319
|
+
const chalk = require$$3__default;
|
|
4010
4320
|
const commander = require$$1__default$8;
|
|
4011
4321
|
const path = require$$1__default$1;
|
|
4012
|
-
const fs = require$$0__default$
|
|
4322
|
+
const fs = require$$0__default$1;
|
|
4013
4323
|
const {
|
|
4014
4324
|
resolve
|
|
4015
4325
|
} = widgets;
|
|
@@ -4113,6 +4423,6 @@ if (!process.argv.slice(2).length) {
|
|
|
4113
4423
|
}
|
|
4114
4424
|
|
|
4115
4425
|
program.parse(process.argv);
|
|
4116
|
-
var src = src$
|
|
4426
|
+
var src = src$3;
|
|
4117
4427
|
|
|
4118
4428
|
module.exports = src;
|