@tmsfe/tmskit 0.0.5-beta.5 → 0.0.7
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/README.md +27 -25
- package/dist/index.cjs.js +779 -664
- package/main.js +3 -3
- package/package.json +75 -69
- package/src/config/constant.js +71 -70
- package/src/config/defaultTmsConfig.js +16 -16
- package/src/entry.js +60 -60
- package/src/gulp/build.js +5 -8
- package/src/gulp/compile.js +81 -87
- package/src/gulp/dev.js +102 -108
- package/src/gulp/plugins/less.js +116 -116
- package/src/gulp/plugins/mpCommonDep.js +131 -131
- package/src/gulp/plugins/mpJsonDep.js +108 -108
- package/src/gulp/plugins/mpWxmlDep.js +194 -194
- package/src/gulp/plugins/postcss-font-base64.js +72 -72
- package/src/gulp/{replaceEnv.js → plugins/replaceEnv.js} +29 -29
- package/src/gulp/plugins/utils/pluginError.js +25 -25
- package/src/index.js +62 -62
- package/src/init.js +33 -33
- package/src/scripts/create/ask.js +63 -63
- package/src/scripts/create/generator.js +25 -25
- package/src/scripts/create/ignoreFiles.js +7 -7
- package/src/scripts/create/index.js +72 -72
- package/src/scripts/create/render.js +19 -19
- package/src/scripts/run/build/index.js +17 -16
- package/src/scripts/run/dev/index.js +84 -67
- package/src/scripts/run/index.js +68 -63
- package/src/scripts/run/init/index.js +87 -80
- package/src/scripts/run/install/index.js +29 -31
- package/src/utils/buildAppJson.js +221 -200
- package/src/utils/checkDependencies.js +77 -77
- package/src/utils/cliUtils.js +35 -35
- package/src/utils/cloneModules.js +116 -91
- package/src/utils/findCssImport.js +30 -30
- package/src/utils/global.js +36 -36
- package/src/utils/handleError.js +16 -0
- package/src/utils/io.js +106 -106
- package/src/utils/log.js +44 -44
- package/src/utils/mpCiUtils.js +73 -74
- package/src/utils/npmUtils.js +166 -148
- package/src/utils/tkitUtils.js +158 -84
- package/src/utils/widgets.js +167 -173
package/dist/index.cjs.js
CHANGED
|
@@ -3,29 +3,27 @@
|
|
|
3
3
|
var require$$0 = require('commander');
|
|
4
4
|
var require$$1 = require('leven');
|
|
5
5
|
var require$$2 = require('ora');
|
|
6
|
-
var require$$
|
|
6
|
+
var require$$3$1 = require('path');
|
|
7
7
|
var require$$0$1 = require('fs');
|
|
8
|
-
var require$$
|
|
8
|
+
var require$$4 = require('shelljs');
|
|
9
9
|
var require$$6$1 = require('download-git-repo');
|
|
10
10
|
var require$$0$2 = require('chalk');
|
|
11
11
|
var require$$0$3 = require('async');
|
|
12
|
-
var require$$1$
|
|
13
|
-
var require$$1$
|
|
12
|
+
var require$$1$1 = require('ejs');
|
|
13
|
+
var require$$1$2 = require('inquirer');
|
|
14
14
|
var require$$0$4 = require('metalsmith');
|
|
15
15
|
var require$$0$5 = require('lodash');
|
|
16
16
|
var require$$0$6 = require('miniprogram-ci');
|
|
17
|
-
var require$$
|
|
17
|
+
var require$$5 = require('glob-ignore');
|
|
18
|
+
var require$$1$3 = require('fs-extra');
|
|
19
|
+
var require$$2$1 = require('crypto');
|
|
18
20
|
var require$$0$7 = require('through2');
|
|
19
21
|
var require$$0$8 = require('strip-comments');
|
|
20
22
|
var require$$1$4 = require('precinct');
|
|
21
23
|
var require$$1$5 = require('htmlparser2');
|
|
22
|
-
var require$$0$9 = require('
|
|
23
|
-
var require$$0$a = require('gulp');
|
|
24
|
+
var require$$0$9 = require('gulp');
|
|
24
25
|
var require$$1$6 = require('gulp-px-to-rpx');
|
|
25
|
-
var require$$2$
|
|
26
|
-
var require$$3$2 = require('gulp-watch');
|
|
27
|
-
var require$$4 = require('gulp-cache');
|
|
28
|
-
var require$$5$1 = require('gulp-image');
|
|
26
|
+
var require$$2$2 = require('gulp-watch');
|
|
29
27
|
var require$$1$7 = require('semver');
|
|
30
28
|
|
|
31
29
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
@@ -33,29 +31,27 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
33
31
|
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
34
32
|
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
35
33
|
var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
|
|
36
|
-
var require$$
|
|
34
|
+
var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3$1);
|
|
37
35
|
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
|
|
38
|
-
var require$$
|
|
36
|
+
var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4);
|
|
39
37
|
var require$$6__default = /*#__PURE__*/_interopDefaultLegacy(require$$6$1);
|
|
40
38
|
var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
|
|
41
39
|
var require$$0__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$0$3);
|
|
40
|
+
var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1);
|
|
42
41
|
var require$$1__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$1$2);
|
|
43
|
-
var require$$1__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$1$3);
|
|
44
42
|
var require$$0__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$0$4);
|
|
45
43
|
var require$$0__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$0$5);
|
|
46
44
|
var require$$0__default$6 = /*#__PURE__*/_interopDefaultLegacy(require$$0$6);
|
|
47
|
-
var require$$
|
|
45
|
+
var require$$5__default = /*#__PURE__*/_interopDefaultLegacy(require$$5);
|
|
46
|
+
var require$$1__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$1$3);
|
|
47
|
+
var require$$2__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$2$1);
|
|
48
48
|
var require$$0__default$7 = /*#__PURE__*/_interopDefaultLegacy(require$$0$7);
|
|
49
49
|
var require$$0__default$8 = /*#__PURE__*/_interopDefaultLegacy(require$$0$8);
|
|
50
50
|
var require$$1__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$1$4);
|
|
51
51
|
var require$$1__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$1$5);
|
|
52
52
|
var require$$0__default$9 = /*#__PURE__*/_interopDefaultLegacy(require$$0$9);
|
|
53
|
-
var require$$0__default$a = /*#__PURE__*/_interopDefaultLegacy(require$$0$a);
|
|
54
53
|
var require$$1__default$6 = /*#__PURE__*/_interopDefaultLegacy(require$$1$6);
|
|
55
|
-
var require$$2__default$
|
|
56
|
-
var require$$3__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$3$2);
|
|
57
|
-
var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4);
|
|
58
|
-
var require$$5__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$5$1);
|
|
54
|
+
var require$$2__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$2$2);
|
|
59
55
|
var require$$1__default$7 = /*#__PURE__*/_interopDefaultLegacy(require$$1$7);
|
|
60
56
|
|
|
61
57
|
function getAugmentedNamespace(n) {
|
|
@@ -78,9 +74,9 @@ var src$2 = {};
|
|
|
78
74
|
const program$1 = require$$0__default;
|
|
79
75
|
const leven = require$$1__default;
|
|
80
76
|
const ora = require$$2__default;
|
|
81
|
-
const path$a = require$$
|
|
82
|
-
const fs$
|
|
83
|
-
const shelljs$6 = require$$
|
|
77
|
+
const path$a = require$$3__default;
|
|
78
|
+
const fs$d = require$$0__default$1;
|
|
79
|
+
const shelljs$6 = require$$4__default;
|
|
84
80
|
const download = require$$6__default;
|
|
85
81
|
const chalk$3 = require$$0__default$2;
|
|
86
82
|
const shelljsOptions = {
|
|
@@ -92,16 +88,16 @@ const cwd = process.cwd();
|
|
|
92
88
|
function resolve$d(...args) {
|
|
93
89
|
return path$a.resolve(cwd, ...args);
|
|
94
90
|
}
|
|
95
|
-
/**
|
|
96
|
-
* 封装logs
|
|
97
|
-
* @returns {Undefined} 无需返回值
|
|
91
|
+
/**
|
|
92
|
+
* 封装logs
|
|
93
|
+
* @returns {Undefined} 无需返回值
|
|
98
94
|
*/
|
|
99
95
|
|
|
100
96
|
const log$3 = (...args) => console.log(...args);
|
|
101
|
-
/**
|
|
102
|
-
* 用户输入命令时,进行提示
|
|
103
|
-
* @param {String} unknownCommand 非预期的命令
|
|
104
|
-
* @returns {Undefined} 无需返回值
|
|
97
|
+
/**
|
|
98
|
+
* 用户输入命令时,进行提示
|
|
99
|
+
* @param {String} unknownCommand 非预期的命令
|
|
100
|
+
* @returns {Undefined} 无需返回值
|
|
105
101
|
*/
|
|
106
102
|
|
|
107
103
|
|
|
@@ -120,31 +116,31 @@ const suggestCommands$1 = unknownCommand => {
|
|
|
120
116
|
log$3(` ${chalk$3.red(`Did you mean ${chalk$3.yellow(suggestion)}?`)}`);
|
|
121
117
|
}
|
|
122
118
|
};
|
|
123
|
-
/**
|
|
124
|
-
* 判断变量是否是一个数组
|
|
125
|
-
* @param { unknown } obj 变量
|
|
126
|
-
* @returns { boolean } 是否是一个数组
|
|
119
|
+
/**
|
|
120
|
+
* 判断变量是否是一个数组
|
|
121
|
+
* @param { unknown } obj 变量
|
|
122
|
+
* @returns { boolean } 是否是一个数组
|
|
127
123
|
*/
|
|
128
124
|
|
|
129
125
|
|
|
130
126
|
function isObject$2(obj) {
|
|
131
127
|
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
132
128
|
}
|
|
133
|
-
/**
|
|
134
|
-
* 判断变量是否是一个对象
|
|
135
|
-
* @param { unknown } obj 变量
|
|
136
|
-
* @returns { boolean } 是否是一个对象
|
|
129
|
+
/**
|
|
130
|
+
* 判断变量是否是一个对象
|
|
131
|
+
* @param { unknown } obj 变量
|
|
132
|
+
* @returns { boolean } 是否是一个对象
|
|
137
133
|
*/
|
|
138
134
|
|
|
139
135
|
|
|
140
136
|
function isArray$1(obj) {
|
|
141
137
|
return Object.prototype.toString.call(obj) === '[object Array]';
|
|
142
138
|
}
|
|
143
|
-
/**
|
|
144
|
-
* 下载模块到目标目录
|
|
145
|
-
* @param { string } dest 目标地址
|
|
146
|
-
* @param { object } downloadOptions 模块下载配置 { repoUrl-仓库地址, gitUrl-git地址, branch-分支或者tag }
|
|
147
|
-
* @returns { undefined } no return
|
|
139
|
+
/**
|
|
140
|
+
* 下载模块到目标目录
|
|
141
|
+
* @param { string } dest 目标地址
|
|
142
|
+
* @param { object } downloadOptions 模块下载配置 { repoUrl-仓库地址, gitUrl-git地址, branch-分支或者tag }
|
|
143
|
+
* @returns { undefined } no return
|
|
148
144
|
*/
|
|
149
145
|
|
|
150
146
|
|
|
@@ -159,7 +155,7 @@ function downloadRepo(dest, downloadOptions = {
|
|
|
159
155
|
branch
|
|
160
156
|
} = downloadOptions;
|
|
161
157
|
|
|
162
|
-
if (fs$
|
|
158
|
+
if (fs$d.existsSync(dest)) {
|
|
163
159
|
shelljs$6.rm('-rf', dest);
|
|
164
160
|
}
|
|
165
161
|
|
|
@@ -178,12 +174,12 @@ function downloadRepo(dest, downloadOptions = {
|
|
|
178
174
|
});
|
|
179
175
|
});
|
|
180
176
|
}
|
|
181
|
-
/**
|
|
182
|
-
* 下载模块到目标目录备用方案
|
|
183
|
-
* @param { string } url 模块地址
|
|
184
|
-
* @param { string } dest 目标地址
|
|
185
|
-
* @param { string } branch 分支名
|
|
186
|
-
* @returns { undefined } no return
|
|
177
|
+
/**
|
|
178
|
+
* 下载模块到目标目录备用方案
|
|
179
|
+
* @param { string } url 模块地址
|
|
180
|
+
* @param { string } dest 目标地址
|
|
181
|
+
* @param { string } branch 分支名
|
|
182
|
+
* @returns { undefined } no return
|
|
187
183
|
*/
|
|
188
184
|
|
|
189
185
|
|
|
@@ -191,7 +187,7 @@ function downloadRepoForGit$2(url, dest, branch) {
|
|
|
191
187
|
const cwd = process.cwd();
|
|
192
188
|
return new Promise((resolve, reject) => {
|
|
193
189
|
// 如果目标目录不存在
|
|
194
|
-
if (fs$
|
|
190
|
+
if (fs$d.existsSync(dest)) {
|
|
195
191
|
shelljs$6.rm('-rf', path$a.join(dest));
|
|
196
192
|
}
|
|
197
193
|
|
|
@@ -207,48 +203,39 @@ function downloadRepoForGit$2(url, dest, branch) {
|
|
|
207
203
|
resolve();
|
|
208
204
|
});
|
|
209
205
|
}
|
|
210
|
-
/**
|
|
211
|
-
* 计算各项任务耗时
|
|
212
|
-
* @param {Number} start 任务开始时间
|
|
213
|
-
* @returns {Undefined} 无需返回值
|
|
206
|
+
/**
|
|
207
|
+
* 计算各项任务耗时
|
|
208
|
+
* @param {Number} start 任务开始时间
|
|
209
|
+
* @returns {Undefined} 无需返回值
|
|
214
210
|
*/
|
|
215
211
|
|
|
216
212
|
|
|
217
213
|
const cost = start => Date.now() - start;
|
|
218
|
-
/**
|
|
219
|
-
* 创建构建子任务
|
|
220
|
-
* @param {Function} task 子任务执行函数
|
|
221
|
-
* @param {String} startText 任务开始前提示语
|
|
222
|
-
* @param {String} endText 任务结束后提示语
|
|
223
|
-
* @returns {Undefined} 无需返回值
|
|
214
|
+
/**
|
|
215
|
+
* 创建构建子任务
|
|
216
|
+
* @param {Function} task 子任务执行函数
|
|
217
|
+
* @param {String} startText 任务开始前提示语
|
|
218
|
+
* @param {String} endText 任务结束后提示语
|
|
219
|
+
* @returns {Undefined} 无需返回值
|
|
224
220
|
*/
|
|
225
221
|
|
|
226
222
|
|
|
227
223
|
function createTask$4(task, startText, endText) {
|
|
228
224
|
return async (...args) => {
|
|
229
225
|
const start = Date.now();
|
|
230
|
-
let result;
|
|
231
226
|
const spinner = ora(startText);
|
|
232
227
|
spinner.start();
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
result = e;
|
|
238
|
-
console.log(chalk$3.red(e));
|
|
239
|
-
process.exit(-1);
|
|
240
|
-
} finally {
|
|
241
|
-
endText && spinner.succeed(`${endText}, ${cost(start)}ms`);
|
|
242
|
-
spinner.stop();
|
|
243
|
-
}
|
|
244
|
-
|
|
228
|
+
console.log('\n');
|
|
229
|
+
const result = await task(...args);
|
|
230
|
+
endText && spinner.succeed(`${endText}, ${cost(start)}ms`);
|
|
231
|
+
spinner.stop();
|
|
245
232
|
return result;
|
|
246
233
|
};
|
|
247
234
|
}
|
|
248
|
-
/**
|
|
249
|
-
* 字符串驼峰化处理
|
|
250
|
-
* @param {String} str 需要处理的字符串
|
|
251
|
-
* @returns {String} 经过驼峰处理的字符串
|
|
235
|
+
/**
|
|
236
|
+
* 字符串驼峰化处理
|
|
237
|
+
* @param {String} str 需要处理的字符串
|
|
238
|
+
* @returns {String} 经过驼峰处理的字符串
|
|
252
239
|
*/
|
|
253
240
|
|
|
254
241
|
const camelize = str => str.replace(/-(\w)/g, (a, c) => c ? c.toUpperCase() : '');
|
|
@@ -280,11 +267,12 @@ const TEMPLATE_PATH$1 = path$9.resolve(TEMPLATE_DIR$1, 'tools/tms-cli-template')
|
|
|
280
267
|
|
|
281
268
|
const TMS_NAME$2 = 'tmskit'; // 脚手架的配置名称
|
|
282
269
|
|
|
283
|
-
const TMS_CONFIG_FILENAME$1 = 'tms.config.js';
|
|
270
|
+
const TMS_CONFIG_FILENAME$1 = 'tms.config.js';
|
|
271
|
+
const TMS_PRIVATE_FILENAME$1 = 'tms.private.config.js'; // 模块代码的默认在modules子目录
|
|
284
272
|
|
|
285
|
-
const DEFAULT_MODULE_DIR
|
|
273
|
+
const DEFAULT_MODULE_DIR = 'modules'; // 模块的配置文件的名称
|
|
286
274
|
|
|
287
|
-
const MODULE_CONFIG_FILENAME$
|
|
275
|
+
const MODULE_CONFIG_FILENAME$3 = 'module.config.json'; // 默认的webpack entry
|
|
288
276
|
|
|
289
277
|
const DEFAULT_WEBPACK_ENTRY = {
|
|
290
278
|
app: path$9.resolve(process.cwd(), 'app')
|
|
@@ -293,7 +281,6 @@ const DEFAULT_WEBPACK_ENTRY = {
|
|
|
293
281
|
const DEFAULT_COPY_CONFIG$1 = ['package.json', 'sitemap.json']; // 开发模式
|
|
294
282
|
|
|
295
283
|
const MODE$1 = {
|
|
296
|
-
main: 'tkitmain',
|
|
297
284
|
all: 'all',
|
|
298
285
|
multi: 'multi'
|
|
299
286
|
};
|
|
@@ -312,8 +299,9 @@ var constant = /*#__PURE__*/Object.freeze({
|
|
|
312
299
|
TEMPLATE_PATH: TEMPLATE_PATH$1,
|
|
313
300
|
TMS_NAME: TMS_NAME$2,
|
|
314
301
|
TMS_CONFIG_FILENAME: TMS_CONFIG_FILENAME$1,
|
|
315
|
-
|
|
316
|
-
|
|
302
|
+
TMS_PRIVATE_FILENAME: TMS_PRIVATE_FILENAME$1,
|
|
303
|
+
DEFAULT_MODULE_DIR: DEFAULT_MODULE_DIR,
|
|
304
|
+
MODULE_CONFIG_FILENAME: MODULE_CONFIG_FILENAME$3,
|
|
317
305
|
DEFAULT_WEBPACK_ENTRY: DEFAULT_WEBPACK_ENTRY,
|
|
318
306
|
DEFAULT_COPY_CONFIG: DEFAULT_COPY_CONFIG$1,
|
|
319
307
|
MODULE_CODE_DIR: MODULE_CODE_DIR$1,
|
|
@@ -325,34 +313,34 @@ var constant = /*#__PURE__*/Object.freeze({
|
|
|
325
313
|
|
|
326
314
|
var require$$3 = /*@__PURE__*/getAugmentedNamespace(constant);
|
|
327
315
|
|
|
328
|
-
const fs$
|
|
329
|
-
const path$8 = require$$
|
|
330
|
-
/**
|
|
331
|
-
* 判断目录是否为空
|
|
332
|
-
* @param {string} dirname 目录名
|
|
333
|
-
* @returns
|
|
316
|
+
const fs$c = require$$0__default$1;
|
|
317
|
+
const path$8 = require$$3__default;
|
|
318
|
+
/**
|
|
319
|
+
* 判断目录是否为空
|
|
320
|
+
* @param {string} dirname 目录名
|
|
321
|
+
* @returns
|
|
334
322
|
*/
|
|
335
323
|
|
|
336
|
-
const isDirEmpty = dirname => fs$
|
|
324
|
+
const isDirEmpty = dirname => fs$c.promises.readdir(dirname).then(files => files.length === 0); // 判断是否是文件
|
|
337
325
|
|
|
338
326
|
|
|
339
327
|
const isFile = pathName => {
|
|
340
328
|
try {
|
|
341
|
-
const stat = fs$
|
|
329
|
+
const stat = fs$c.lstatSync(pathName);
|
|
342
330
|
return stat.isFile();
|
|
343
331
|
} catch {
|
|
344
332
|
return false;
|
|
345
333
|
}
|
|
346
334
|
};
|
|
347
|
-
/**
|
|
348
|
-
* 确保目录存在,不存在就创建一个
|
|
349
|
-
* @param {*} dirname 目录名
|
|
335
|
+
/**
|
|
336
|
+
* 确保目录存在,不存在就创建一个
|
|
337
|
+
* @param {*} dirname 目录名
|
|
350
338
|
*/
|
|
351
339
|
|
|
352
340
|
|
|
353
341
|
const ensureDirExist = dirname => {
|
|
354
|
-
if (!fs$
|
|
355
|
-
fs$
|
|
342
|
+
if (!fs$c.existsSync(dirname)) {
|
|
343
|
+
fs$c.mkdirSync(dirname, {
|
|
356
344
|
recursive: true
|
|
357
345
|
});
|
|
358
346
|
}
|
|
@@ -360,20 +348,20 @@ const ensureDirExist = dirname => {
|
|
|
360
348
|
|
|
361
349
|
|
|
362
350
|
const copyFile = function (src, dest) {
|
|
363
|
-
if (fs$
|
|
364
|
-
fs$
|
|
351
|
+
if (fs$c.existsSync(dest)) {
|
|
352
|
+
fs$c.unlinkSync(dest);
|
|
365
353
|
}
|
|
366
354
|
|
|
367
|
-
const dir =
|
|
355
|
+
const dir = path$8.dirname(dest);
|
|
368
356
|
ensureDirExist(dir);
|
|
369
|
-
fs$
|
|
357
|
+
fs$c.copyFileSync(src, dest);
|
|
370
358
|
}; // 判断文件内容是否一致,不一致再进行拷贝
|
|
371
359
|
|
|
372
360
|
|
|
373
361
|
function diffContentCopyFile$3(originFile, destFile) {
|
|
374
|
-
if (fs$
|
|
375
|
-
const depDestContent = fs$
|
|
376
|
-
const depOriginContent = fs$
|
|
362
|
+
if (fs$c.existsSync(destFile)) {
|
|
363
|
+
const depDestContent = fs$c.readFileSync(destFile, 'utf8');
|
|
364
|
+
const depOriginContent = fs$c.readFileSync(originFile, 'utf8');
|
|
377
365
|
|
|
378
366
|
if (depDestContent !== depOriginContent) {
|
|
379
367
|
console.log(`拷贝${originFile}内容到${destFile}`);
|
|
@@ -391,7 +379,7 @@ function ext$3(filePath, extensions) {
|
|
|
391
379
|
let extPath = ''; // try catch需要包裹:用来处理'./lib/timer'没有后缀的情况
|
|
392
380
|
|
|
393
381
|
try {
|
|
394
|
-
const stat = fs$
|
|
382
|
+
const stat = fs$c.lstatSync(newFilePath);
|
|
395
383
|
|
|
396
384
|
if (stat.isDirectory()) {
|
|
397
385
|
extPath = newFilePath[newFilePath.length - 1] === '/' ? 'index' : '/index';
|
|
@@ -402,7 +390,7 @@ function ext$3(filePath, extensions) {
|
|
|
402
390
|
for (const ext of extensions) {
|
|
403
391
|
const file = newFilePath.endsWith(ext) ? newFilePath : newFilePath + ext;
|
|
404
392
|
|
|
405
|
-
if (fs$
|
|
393
|
+
if (fs$c.existsSync(file)) {
|
|
406
394
|
return {
|
|
407
395
|
ext,
|
|
408
396
|
extPath: extPath + ext,
|
|
@@ -420,7 +408,7 @@ function ext$3(filePath, extensions) {
|
|
|
420
408
|
|
|
421
409
|
|
|
422
410
|
const fileInDir$3 = (dir, file) => {
|
|
423
|
-
if (!fs$
|
|
411
|
+
if (!fs$c.existsSync(dir) || !fs$c.existsSync(file)) {
|
|
424
412
|
return false;
|
|
425
413
|
}
|
|
426
414
|
|
|
@@ -444,29 +432,29 @@ var io$2 = {
|
|
|
444
432
|
};
|
|
445
433
|
|
|
446
434
|
const chalk$2 = require$$0__default$2;
|
|
447
|
-
/**
|
|
448
|
-
* 本文件提供无依赖的在终端打印彩色文字的方法。
|
|
435
|
+
/**
|
|
436
|
+
* 本文件提供无依赖的在终端打印彩色文字的方法。
|
|
449
437
|
*/
|
|
450
438
|
|
|
451
439
|
const resetCfg = decodeURIComponent('%1B%5B0m'); // \033[0m转义后的字符按,用来还原属性
|
|
452
440
|
|
|
453
|
-
/**
|
|
454
|
-
* 打印红底黑字格式的文字
|
|
455
|
-
* @param {String} message 需要打印的文字信息
|
|
456
|
-
* @returns {undefined} 无
|
|
441
|
+
/**
|
|
442
|
+
* 打印红底黑字格式的文字
|
|
443
|
+
* @param {String} message 需要打印的文字信息
|
|
444
|
+
* @returns {undefined} 无
|
|
457
445
|
*/
|
|
458
446
|
|
|
459
|
-
const fail$
|
|
447
|
+
const fail$9 = (message = '') => {
|
|
460
448
|
const redStyleConfig = decodeURIComponent('%1B%5B41%3B30m'); // \033[41;30m转义后的字符按,console时输出红色文字
|
|
461
449
|
|
|
462
450
|
const greenFontStyleConfig = decodeURIComponent('%1B%5B41%3B37m'); // \033[41;30m转义后的字符按,console时输出红底白色文字
|
|
463
451
|
|
|
464
452
|
console.log(`${redStyleConfig} ERROR ${greenFontStyleConfig} ${message}${resetCfg}`); // eslint-disable-line no-console
|
|
465
453
|
};
|
|
466
|
-
/**
|
|
467
|
-
* 打印绿底黑字格式的文字
|
|
468
|
-
* @param {String} message 需要打印的文字信息
|
|
469
|
-
* @returns {undefined} 无
|
|
454
|
+
/**
|
|
455
|
+
* 打印绿底黑字格式的文字
|
|
456
|
+
* @param {String} message 需要打印的文字信息
|
|
457
|
+
* @returns {undefined} 无
|
|
470
458
|
*/
|
|
471
459
|
|
|
472
460
|
|
|
@@ -477,10 +465,10 @@ const succeed$1 = (message = '') => {
|
|
|
477
465
|
|
|
478
466
|
console.log(`${greenStyleConfig} Success ${greenFontStyleConfig} ${message}${resetCfg}`); // eslint-disable-line no-console
|
|
479
467
|
};
|
|
480
|
-
/**
|
|
481
|
-
* 打印warn提示
|
|
482
|
-
* @param {String} message 需要打印的文字信息
|
|
483
|
-
* @returns {undefined} 无
|
|
468
|
+
/**
|
|
469
|
+
* 打印warn提示
|
|
470
|
+
* @param {String} message 需要打印的文字信息
|
|
471
|
+
* @returns {undefined} 无
|
|
484
472
|
*/
|
|
485
473
|
|
|
486
474
|
|
|
@@ -489,13 +477,13 @@ const warn = message => {
|
|
|
489
477
|
};
|
|
490
478
|
|
|
491
479
|
var log$2 = {
|
|
492
|
-
fail: fail$
|
|
480
|
+
fail: fail$9,
|
|
493
481
|
succeed: succeed$1,
|
|
494
482
|
warn
|
|
495
483
|
};
|
|
496
484
|
|
|
497
485
|
const async = require$$0__default$3;
|
|
498
|
-
const ejs = require$$1__default$
|
|
486
|
+
const ejs = require$$1__default$1;
|
|
499
487
|
|
|
500
488
|
const render$1 = (files, metalsmith, next) => {
|
|
501
489
|
const keys = Object.keys(files);
|
|
@@ -514,29 +502,29 @@ const render$1 = (files, metalsmith, next) => {
|
|
|
514
502
|
|
|
515
503
|
var render_1 = render$1;
|
|
516
504
|
|
|
517
|
-
const fs$
|
|
518
|
-
const inquirer = require$$1__default$
|
|
505
|
+
const fs$b = require$$0__default$1;
|
|
506
|
+
const inquirer = require$$1__default$2;
|
|
519
507
|
const {
|
|
520
508
|
resolve: resolve$c
|
|
521
509
|
} = widgets;
|
|
522
510
|
const {
|
|
523
511
|
TEMPLATE_TKIT_DIR: TEMPLATE_TKIT_DIR$1
|
|
524
512
|
} = require$$3;
|
|
525
|
-
/**
|
|
526
|
-
* 获取模板内的问题
|
|
527
|
-
* @param {string} dir questions.json所在的目录
|
|
528
|
-
* @returns {Array} inquirer 问题数组
|
|
513
|
+
/**
|
|
514
|
+
* 获取模板内的问题
|
|
515
|
+
* @param {string} dir questions.json所在的目录
|
|
516
|
+
* @returns {Array} inquirer 问题数组
|
|
529
517
|
*/
|
|
530
518
|
|
|
531
519
|
const parseTemplateQuestions = dir => {
|
|
532
520
|
let prompts = [];
|
|
533
521
|
|
|
534
|
-
if (!fs$
|
|
522
|
+
if (!fs$b.existsSync(`${dir}/questions.json`)) {
|
|
535
523
|
return prompts;
|
|
536
524
|
}
|
|
537
525
|
|
|
538
526
|
try {
|
|
539
|
-
const json = JSON.parse(fs$
|
|
527
|
+
const json = JSON.parse(fs$b.readFileSync(`${dir}/questions.json`));
|
|
540
528
|
|
|
541
529
|
if (Array.isArray(json) && json.length > 0) {
|
|
542
530
|
json.forEach((item, index) => {
|
|
@@ -611,9 +599,9 @@ const generator$1 = (buildDir, distDir, preMetadata) => new Promise((resolve, re
|
|
|
611
599
|
|
|
612
600
|
var generator_1 = generator$1;
|
|
613
601
|
|
|
614
|
-
const path$7 = require$$
|
|
615
|
-
const fs$
|
|
616
|
-
const shelljs$5 = require$$
|
|
602
|
+
const path$7 = require$$3__default;
|
|
603
|
+
const fs$a = require$$0__default$1;
|
|
604
|
+
const shelljs$5 = require$$4__default;
|
|
617
605
|
const {
|
|
618
606
|
TEMPLATE_DIR,
|
|
619
607
|
TEMPLATE_PATH,
|
|
@@ -626,31 +614,31 @@ const {
|
|
|
626
614
|
} = widgets;
|
|
627
615
|
const io$1 = io$2;
|
|
628
616
|
const {
|
|
629
|
-
fail: fail$
|
|
617
|
+
fail: fail$8,
|
|
630
618
|
succeed
|
|
631
619
|
} = log$2;
|
|
632
620
|
const generator = generator_1;
|
|
633
|
-
/**
|
|
634
|
-
* 如果该目录下面存在文件,换个名字
|
|
635
|
-
* @param { string } targetDir 当前文件夹
|
|
636
|
-
* @returns { undefined }
|
|
621
|
+
/**
|
|
622
|
+
* 如果该目录下面存在文件,换个名字
|
|
623
|
+
* @param { string } targetDir 当前文件夹
|
|
624
|
+
* @returns { undefined }
|
|
637
625
|
*/
|
|
638
626
|
|
|
639
627
|
async function createAppDir(targetDir) {
|
|
640
628
|
// 如果目录非空或者已经存在,提示用户,做选择
|
|
641
|
-
if (fs$
|
|
629
|
+
if (fs$a.existsSync(targetDir)) {
|
|
642
630
|
if (!(await io$1.isDirEmpty(targetDir))) {
|
|
643
|
-
fail$
|
|
631
|
+
fail$8('该目录名已经存在,换个项目名字吧~');
|
|
644
632
|
process.exit(1);
|
|
645
633
|
}
|
|
646
634
|
} else {
|
|
647
635
|
shelljs$5.mkdir('-p', targetDir);
|
|
648
636
|
}
|
|
649
637
|
}
|
|
650
|
-
/**
|
|
651
|
-
* 创建本地小程序运行环境
|
|
652
|
-
* @param { string } appType 项目类型
|
|
653
|
-
* @param { string } appName 项目名称
|
|
638
|
+
/**
|
|
639
|
+
* 创建本地小程序运行环境
|
|
640
|
+
* @param { string } appType 项目类型
|
|
641
|
+
* @param { string } appName 项目名称
|
|
654
642
|
*/
|
|
655
643
|
|
|
656
644
|
|
|
@@ -687,46 +675,62 @@ async function create(appName) {
|
|
|
687
675
|
shelljs$5.rm('-rf', resolve$b(appName, TEMPLATE_TKIT_DIR));
|
|
688
676
|
succeed('项目创建完成.');
|
|
689
677
|
}).catch(err => {
|
|
690
|
-
fail$
|
|
678
|
+
fail$8(err.message);
|
|
691
679
|
console.log('详细的错误信息:', err);
|
|
692
680
|
});
|
|
693
681
|
}
|
|
694
682
|
|
|
695
683
|
var create_1 = create;
|
|
696
684
|
|
|
697
|
-
const fs$a = require$$0__default$1;
|
|
698
685
|
const {
|
|
699
|
-
|
|
700
|
-
|
|
686
|
+
fail: fail$7
|
|
687
|
+
} = log$2;
|
|
688
|
+
|
|
689
|
+
function handleError$3(error, isDev = false) {
|
|
690
|
+
const errMsg = typeof error === 'object' ? error.message : error;
|
|
691
|
+
|
|
692
|
+
if (isDev) {
|
|
693
|
+
fail$7(errMsg);
|
|
694
|
+
} else {
|
|
695
|
+
fail$7(errMsg);
|
|
696
|
+
process.exit(1);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
var handleError_1 = {
|
|
701
|
+
handleError: handleError$3
|
|
702
|
+
};
|
|
703
|
+
|
|
704
|
+
const fs$9 = require$$0__default$1;
|
|
705
|
+
const {
|
|
706
|
+
MODULE_CONFIG_FILENAME: MODULE_CONFIG_FILENAME$2,
|
|
701
707
|
MODULE_CONFIG_INVALID_KEY
|
|
702
708
|
} = require$$3;
|
|
703
709
|
const {
|
|
704
|
-
fail: fail$
|
|
710
|
+
fail: fail$6
|
|
705
711
|
} = log$2;
|
|
706
712
|
const {
|
|
707
713
|
resolve: resolve$a,
|
|
708
714
|
isObject: isObject$1,
|
|
709
715
|
isArray
|
|
710
716
|
} = widgets;
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
717
|
+
const {
|
|
718
|
+
handleError: handleError$2
|
|
719
|
+
} = handleError_1;
|
|
720
|
+
/**
|
|
721
|
+
* 获取每个模块下面的信息,并且收集,后续更新到appJson里面
|
|
722
|
+
* @param { object } file 操作目录下面所有的文件
|
|
723
|
+
* @param { string } appName 小程序的名称
|
|
715
724
|
*/
|
|
716
725
|
|
|
717
|
-
function setModuleConfig$1(file, appName
|
|
726
|
+
function setModuleConfig$1(file, appName) {
|
|
718
727
|
const content = file.contents ? JSON.parse(file.contents.toString()) : JSON.parse(file);
|
|
719
728
|
|
|
720
|
-
if (isObject$1(content)) {
|
|
721
|
-
content.root = content.root.indexOf(moduleDir) > -1 ? content.root : `${moduleDir}/${content.root}`;
|
|
722
|
-
}
|
|
723
|
-
|
|
724
729
|
if (isArray(content)) {
|
|
725
730
|
let i = content.length - 1;
|
|
726
731
|
|
|
727
732
|
while (i >= 0) {
|
|
728
733
|
let current = content[i];
|
|
729
|
-
current.root = current.root.indexOf(moduleDir) > -1 ? current.root : `${moduleDir}/${current.root}`;
|
|
730
734
|
|
|
731
735
|
if (appName && current.mpConfig && current.mpConfig[appName]) {
|
|
732
736
|
current = { ...current,
|
|
@@ -743,30 +747,30 @@ function setModuleConfig$1(file, appName, moduleDir) {
|
|
|
743
747
|
|
|
744
748
|
return content;
|
|
745
749
|
}
|
|
746
|
-
/**
|
|
747
|
-
* 递归获取本地所有模块的配置信息
|
|
750
|
+
/**
|
|
751
|
+
* 递归获取本地所有模块的配置信息
|
|
748
752
|
*/
|
|
749
753
|
|
|
750
754
|
|
|
751
|
-
function getLocalModuleConfig(modules = [], appName,
|
|
755
|
+
function getLocalModuleConfig(modules = [], appName, moduleConfigFilename) {
|
|
752
756
|
const modulesConfig = {};
|
|
753
757
|
modules.forEach(({
|
|
754
758
|
path
|
|
755
759
|
}) => {
|
|
756
760
|
const moduleConfigPath = resolve$a(path, moduleConfigFilename);
|
|
757
761
|
|
|
758
|
-
if (fs$
|
|
759
|
-
const content = fs$
|
|
760
|
-
modulesConfig[moduleConfigPath] = setModuleConfig$1(content, appName
|
|
762
|
+
if (fs$9.existsSync(moduleConfigPath)) {
|
|
763
|
+
const content = fs$9.readFileSync(moduleConfigPath, 'utf-8');
|
|
764
|
+
modulesConfig[moduleConfigPath] = setModuleConfig$1(content, appName);
|
|
761
765
|
}
|
|
762
766
|
});
|
|
763
767
|
return modulesConfig;
|
|
764
768
|
}
|
|
765
|
-
/**
|
|
766
|
-
* 更新appJson里面的首页配置
|
|
767
|
-
* @param { object } appJson appJson信息
|
|
768
|
-
* @param { array } mainPackages 小程序主包信息
|
|
769
|
-
* @returns { object } appJson小程序主页配置信息
|
|
769
|
+
/**
|
|
770
|
+
* 更新appJson里面的首页配置
|
|
771
|
+
* @param { object } appJson appJson信息
|
|
772
|
+
* @param { array } mainPackages 小程序主包信息
|
|
773
|
+
* @returns { object } appJson小程序主页配置信息
|
|
770
774
|
*/
|
|
771
775
|
|
|
772
776
|
|
|
@@ -781,7 +785,7 @@ function updateMainPackages(appJson, mainPackages = []) {
|
|
|
781
785
|
|
|
782
786
|
foundMainPackages.forEach(subpackage => {
|
|
783
787
|
if (!subpackage.pages || !subpackage.pages.length) {
|
|
784
|
-
fail$
|
|
788
|
+
fail$6(`主包 ${subpackage} 不能没有 pages`);
|
|
785
789
|
process.exit(-1);
|
|
786
790
|
}
|
|
787
791
|
|
|
@@ -799,20 +803,20 @@ function updateMainPackages(appJson, mainPackages = []) {
|
|
|
799
803
|
appJson.subpackages = appJson.subpackages.filter(subpackage => !foundMainPackageNames.includes(subpackage.name));
|
|
800
804
|
return appJson;
|
|
801
805
|
}
|
|
802
|
-
/**
|
|
803
|
-
* 获取app.json内容
|
|
804
|
-
* @param {string} sourceAppJsonPath
|
|
805
|
-
* @returns
|
|
806
|
+
/**
|
|
807
|
+
* 获取app.json内容
|
|
808
|
+
* @param {string} sourceAppJsonPath
|
|
809
|
+
* @returns
|
|
806
810
|
*/
|
|
807
811
|
|
|
808
812
|
|
|
809
813
|
const getAppJsonContent = sourceAppJsonPath => {
|
|
810
|
-
if (!fs$
|
|
811
|
-
fail$
|
|
814
|
+
if (!fs$9.existsSync(sourceAppJsonPath)) {
|
|
815
|
+
fail$6(`当前路径 ${sourceAppJsonPath} 没找到app.json`);
|
|
812
816
|
process.exit(1);
|
|
813
817
|
}
|
|
814
818
|
|
|
815
|
-
const appJson = JSON.parse(fs$
|
|
819
|
+
const appJson = JSON.parse(fs$9.readFileSync(sourceAppJsonPath), 'utf-8'); // 加入默认值
|
|
816
820
|
|
|
817
821
|
appJson.subpackages = [];
|
|
818
822
|
appJson.pages = []; // appJson.plugins = {};
|
|
@@ -820,24 +824,38 @@ const getAppJsonContent = sourceAppJsonPath => {
|
|
|
820
824
|
delete appJson.entranceDeclare;
|
|
821
825
|
return appJson;
|
|
822
826
|
};
|
|
823
|
-
/**
|
|
824
|
-
* 更新app.json中的subpackages
|
|
825
|
-
* @param {Object} appJson
|
|
826
|
-
* @param {Object} modulesConfig
|
|
827
|
+
/**
|
|
828
|
+
* 更新app.json中的subpackages
|
|
829
|
+
* @param {Object} appJson
|
|
830
|
+
* @param {Object} modulesConfig
|
|
827
831
|
*/
|
|
828
832
|
|
|
829
833
|
|
|
830
834
|
const updateSubpackages = (appJson, modulesConfig) => {
|
|
831
835
|
// eslint-disable-next-line
|
|
832
836
|
for (const name in modulesConfig) {
|
|
833
|
-
const moduleInfo = isObject$1(modulesConfig[name]) ? [modulesConfig[name]] : modulesConfig[name]; //
|
|
837
|
+
const moduleInfo = isObject$1(modulesConfig[name]) ? [modulesConfig[name]] : modulesConfig[name]; // 过滤 pages 为空的情况
|
|
834
838
|
|
|
835
|
-
|
|
839
|
+
const validModules = getValidModules$1(moduleInfo); // eslint-disable-next-line
|
|
840
|
+
|
|
841
|
+
appJson.subpackages = appJson.subpackages.concat(validModules);
|
|
836
842
|
}
|
|
837
843
|
};
|
|
838
|
-
/**
|
|
839
|
-
*
|
|
840
|
-
* @param {
|
|
844
|
+
/**
|
|
845
|
+
* 过滤页面为空的分包
|
|
846
|
+
* @param {Array} moduleCfg 模块配置内容
|
|
847
|
+
* @returns pages不为空的分包
|
|
848
|
+
*/
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
const getValidModules$1 = moduleCfg => {
|
|
852
|
+
// 过滤 pages 为空的情况
|
|
853
|
+
const validModules = moduleCfg.filter(item => item.pages.length > 0);
|
|
854
|
+
return validModules;
|
|
855
|
+
};
|
|
856
|
+
/**
|
|
857
|
+
* 处理合并subpackages后的appjson, 整理重复不合法的地方
|
|
858
|
+
* @param {Object} appJson appjson
|
|
841
859
|
*/
|
|
842
860
|
|
|
843
861
|
|
|
@@ -850,6 +868,12 @@ const processAppJson = appJson => {
|
|
|
850
868
|
const subps = subpackages.map(subp => {
|
|
851
869
|
const invalidKeys = [];
|
|
852
870
|
Object.keys(subp).forEach(key => {
|
|
871
|
+
if (key === 'dependencies') {
|
|
872
|
+
// eslint-disable-next-line
|
|
873
|
+
delete subp.dependencies;
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
|
|
853
877
|
if (key === 'plugins') {
|
|
854
878
|
Object.keys(subp.plugins).forEach(pk => {
|
|
855
879
|
pluginsMap[pk] ? pluginsMap[pk].push(`分包${subp.name}`) : pluginsMap[pk] = [`分包${subp.name}`];
|
|
@@ -874,7 +898,7 @@ const processAppJson = appJson => {
|
|
|
874
898
|
});
|
|
875
899
|
|
|
876
900
|
if (invalidKeys.length) {
|
|
877
|
-
fail$
|
|
901
|
+
fail$6(`不支持分包${subp === null || subp === void 0 ? void 0 : subp.name}配置${invalidKeys.join(',')}\n`);
|
|
878
902
|
} // eslint-disable-next-line
|
|
879
903
|
|
|
880
904
|
|
|
@@ -891,37 +915,42 @@ const processAppJson = appJson => {
|
|
|
891
915
|
}).reduce((pre, cur) => pre + cur, '');
|
|
892
916
|
|
|
893
917
|
if (pluginsErrMsg) {
|
|
894
|
-
fail$
|
|
918
|
+
fail$6(`plugins配置出现错误:${pluginsErrMsg}`);
|
|
895
919
|
} // eslint-disable-next-line
|
|
896
920
|
|
|
897
921
|
|
|
898
922
|
appJson.subpackages = subps;
|
|
899
923
|
};
|
|
900
|
-
/**
|
|
901
|
-
* 动态生成编译后的app.json
|
|
902
|
-
* @param {object} tmsConfig
|
|
903
|
-
* @param {array} modules
|
|
904
|
-
* @returns
|
|
924
|
+
/**
|
|
925
|
+
* 动态生成编译后的app.json
|
|
926
|
+
* @param {object} tmsConfig
|
|
927
|
+
* @param {array} modules
|
|
928
|
+
* @returns
|
|
905
929
|
*/
|
|
906
930
|
|
|
907
931
|
|
|
908
|
-
function buildOutputAppJson$1(tmsConfig, modules) {
|
|
909
|
-
|
|
910
|
-
|
|
932
|
+
function buildOutputAppJson$1(tmsConfig, modules, isDev) {
|
|
933
|
+
try {
|
|
934
|
+
// 获取当前 modules 下的所有子模块的配置内容
|
|
935
|
+
const modulesConfig = getLocalModuleConfig(modules, tmsConfig.appName, MODULE_CONFIG_FILENAME$2); // 获取app.json的配置
|
|
911
936
|
|
|
912
|
-
|
|
937
|
+
const appJson = getAppJsonContent(resolve$a('./app.json')); // 更新app.json中的subpackages
|
|
913
938
|
|
|
914
|
-
|
|
939
|
+
updateSubpackages(appJson, modulesConfig); // 处理appJson中重复||冲突的地方
|
|
915
940
|
|
|
916
|
-
|
|
941
|
+
processAppJson(appJson); // 更新主包,需在subpackages处理完成后执行, pages/
|
|
917
942
|
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
943
|
+
updateMainPackages(appJson, tmsConfig.mainPackages);
|
|
944
|
+
fs$9.writeFileSync(resolve$a(`${tmsConfig.outputDir}/app.json`), JSON.stringify(appJson, null, 2), 'utf8');
|
|
945
|
+
return appJson;
|
|
946
|
+
} catch (e) {
|
|
947
|
+
handleError$2(`生成app.json出现错误: ${e}`, isDev);
|
|
948
|
+
}
|
|
921
949
|
}
|
|
922
950
|
|
|
923
951
|
var buildAppJson = {
|
|
924
952
|
setModuleConfig: setModuleConfig$1,
|
|
953
|
+
getValidModules: getValidModules$1,
|
|
925
954
|
buildOutputAppJson: buildOutputAppJson$1
|
|
926
955
|
};
|
|
927
956
|
|
|
@@ -960,108 +989,6 @@ var global = {
|
|
|
960
989
|
getGlobalInstance: getGlobalInstance$1
|
|
961
990
|
};
|
|
962
991
|
|
|
963
|
-
const MetalSmith = require$$0__default$4;
|
|
964
|
-
const {
|
|
965
|
-
getGlobalInstance
|
|
966
|
-
} = global;
|
|
967
|
-
const {
|
|
968
|
-
downloadRepoForGit,
|
|
969
|
-
resolve: resolve$9
|
|
970
|
-
} = widgets;
|
|
971
|
-
const {
|
|
972
|
-
fail: fail$7
|
|
973
|
-
} = log$2;
|
|
974
|
-
const fs$9 = require$$0__default$1;
|
|
975
|
-
const shelljs$4 = require$$5__default;
|
|
976
|
-
/**
|
|
977
|
-
* 对克隆下来的模块进行相应的文件处理操作,比如收集处理模块信息,进行信息缓存等操作
|
|
978
|
-
* @param { string } sourceDir 缓存文件夹
|
|
979
|
-
* @param { string } targetDir 目标文件夹
|
|
980
|
-
* @param { arrary } ignore
|
|
981
|
-
* @returns { undefined } no return
|
|
982
|
-
*/
|
|
983
|
-
|
|
984
|
-
function moveFile(sourceDir, targetDir, ignore = []) {
|
|
985
|
-
// 删除不是文件夹的文件
|
|
986
|
-
return new Promise(resolve => {
|
|
987
|
-
MetalSmith(__dirname).ignore(ignore).source(sourceDir).destination(targetDir).build(e => {
|
|
988
|
-
if (e) {
|
|
989
|
-
fail$7(e); // eslint-disable-line
|
|
990
|
-
|
|
991
|
-
console.log('MetalSmith 详细的错误信息:', e);
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
resolve();
|
|
995
|
-
});
|
|
996
|
-
});
|
|
997
|
-
}
|
|
998
|
-
/**
|
|
999
|
-
* 下载目标模块
|
|
1000
|
-
* @param { string } sourceDir 缓存文件夹
|
|
1001
|
-
* @param { string } targetDir 目标文件夹
|
|
1002
|
-
* @returns { array } modules 描述模块的列表
|
|
1003
|
-
*/
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
async function cloneModules$1(sourceDir, targetDir, modules) {
|
|
1007
|
-
// 根据小程序的配置文件下载模块, 并且处理信息
|
|
1008
|
-
for (const moduleInfo of modules) {
|
|
1009
|
-
// eslint-disable-line
|
|
1010
|
-
if (moduleInfo.repoInfo) {
|
|
1011
|
-
await downLoadAndMoveModule(sourceDir, targetDir, moduleInfo);
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
/**
|
|
1016
|
-
* 下载模块信息并且将它移动到对应的位置
|
|
1017
|
-
* @param { string } sourceDir 代码缓存文件夹
|
|
1018
|
-
* @param { string } targetDir 代码要放到的目标文件夹
|
|
1019
|
-
* @returns { array } moduleInfo 描述模块的信息
|
|
1020
|
-
*/
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
async function downLoadAndMoveModule(sourceDir, targetDir, moduleInfo) {
|
|
1024
|
-
const {
|
|
1025
|
-
repoInfo: {
|
|
1026
|
-
buildGitTag,
|
|
1027
|
-
httpRepoUrl
|
|
1028
|
-
},
|
|
1029
|
-
path
|
|
1030
|
-
} = moduleInfo; // 源码临时存在的源目录
|
|
1031
|
-
|
|
1032
|
-
let sourcePath = resolve$9(sourceDir, path); // 源码要放到目标目录
|
|
1033
|
-
|
|
1034
|
-
const targetPath = resolve$9(targetDir, path); // 设置模块的构建分支
|
|
1035
|
-
|
|
1036
|
-
const cloneBranch = buildGitTag && typeof buildGitTag === 'string' ? buildGitTag : 'master'; // 检查缓存中有没有
|
|
1037
|
-
|
|
1038
|
-
const globalInstance = getGlobalInstance();
|
|
1039
|
-
const moduleInCache = globalInstance.getModuleCache(httpRepoUrl, cloneBranch);
|
|
1040
|
-
|
|
1041
|
-
try {
|
|
1042
|
-
if (!moduleInCache) {
|
|
1043
|
-
await downloadRepoForGit(httpRepoUrl, sourcePath, cloneBranch);
|
|
1044
|
-
globalInstance.setModuleCache(httpRepoUrl, cloneBranch, sourcePath);
|
|
1045
|
-
} else {
|
|
1046
|
-
sourcePath = globalInstance.getModuleCache(httpRepoUrl, cloneBranch).dest;
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
if (fs$9.existsSync(targetPath)) {
|
|
1050
|
-
shelljs$4.rm('-rf', targetPath);
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
await moveFile(sourcePath, targetPath, ['node_modules', '.git']);
|
|
1054
|
-
} catch (e) {
|
|
1055
|
-
fail$7(`downLoadAndMoveModule ${e}`); // eslint-disable-line
|
|
1056
|
-
|
|
1057
|
-
process.exit(-1);
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
var cloneModules_1 = {
|
|
1062
|
-
cloneModules: cloneModules$1
|
|
1063
|
-
};
|
|
1064
|
-
|
|
1065
992
|
var defaultTmsConfig$1 = {
|
|
1066
993
|
// 全局的环境配置项
|
|
1067
994
|
envData: {},
|
|
@@ -1086,29 +1013,32 @@ const fs$8 = require$$0__default$1;
|
|
|
1086
1013
|
const {
|
|
1087
1014
|
TMS_NAME: TMS_NAME$1,
|
|
1088
1015
|
TMS_CONFIG_FILENAME,
|
|
1089
|
-
MODULE_CONFIG_FILENAME
|
|
1016
|
+
MODULE_CONFIG_FILENAME: MODULE_CONFIG_FILENAME$1,
|
|
1017
|
+
TMS_PRIVATE_FILENAME
|
|
1090
1018
|
} = require$$3;
|
|
1091
1019
|
const {
|
|
1092
|
-
resolve: resolve$
|
|
1020
|
+
resolve: resolve$9,
|
|
1093
1021
|
isObject
|
|
1094
1022
|
} = widgets;
|
|
1095
1023
|
const {
|
|
1096
|
-
setModuleConfig
|
|
1024
|
+
setModuleConfig,
|
|
1025
|
+
getValidModules
|
|
1097
1026
|
} = buildAppJson;
|
|
1098
1027
|
const defaultTmsConfig = defaultTmsConfig$1;
|
|
1099
1028
|
const {
|
|
1100
|
-
fail: fail$
|
|
1029
|
+
fail: fail$5
|
|
1101
1030
|
} = log$2;
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
*
|
|
1031
|
+
const path$6 = require$$3__default;
|
|
1032
|
+
/**
|
|
1033
|
+
* 读取tms.config.js
|
|
1034
|
+
* @param env {string} 环境变量
|
|
1105
1035
|
*/
|
|
1106
1036
|
|
|
1107
1037
|
const readTmsConfig$1 = function (env) {
|
|
1108
|
-
const tmsConfigPath = resolve$
|
|
1038
|
+
const tmsConfigPath = resolve$9(TMS_CONFIG_FILENAME);
|
|
1109
1039
|
|
|
1110
1040
|
if (!fs$8.existsSync(tmsConfigPath)) {
|
|
1111
|
-
fail$
|
|
1041
|
+
fail$5('当前执行目录没有tms.config.js的配置项,请进行配置');
|
|
1112
1042
|
process.exit(1);
|
|
1113
1043
|
}
|
|
1114
1044
|
|
|
@@ -1118,14 +1048,56 @@ const readTmsConfig$1 = function (env) {
|
|
|
1118
1048
|
env
|
|
1119
1049
|
}); // 合并默认值
|
|
1120
1050
|
|
|
1121
|
-
loadash.mergeWith(tmsConfig, defaultTmsConfig);
|
|
1051
|
+
loadash.mergeWith(tmsConfig, defaultTmsConfig); // modules兼容处理
|
|
1052
|
+
|
|
1053
|
+
tmsConfig.modules = convertModules(tmsConfig.modules);
|
|
1122
1054
|
return tmsConfig;
|
|
1055
|
+
}; // convertModules 处理默认值
|
|
1056
|
+
|
|
1057
|
+
|
|
1058
|
+
const convertModules = modules => {
|
|
1059
|
+
const newModules = [];
|
|
1060
|
+
modules.forEach((module, index) => {
|
|
1061
|
+
const newModule = {};
|
|
1062
|
+
|
|
1063
|
+
if (typeof module === 'string') {
|
|
1064
|
+
// 路径字符串
|
|
1065
|
+
Object.assign(newModule, {
|
|
1066
|
+
name: path$6.basename(module),
|
|
1067
|
+
path: module
|
|
1068
|
+
});
|
|
1069
|
+
} else if (typeof module === 'object') {
|
|
1070
|
+
Object.assign(newModule, module);
|
|
1071
|
+
|
|
1072
|
+
if (module.name === undefined) {
|
|
1073
|
+
newModule.name = path$6.basename(module.path);
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
newModules.push(newModule);
|
|
1078
|
+
});
|
|
1079
|
+
return newModules;
|
|
1123
1080
|
};
|
|
1124
|
-
/**
|
|
1125
|
-
*
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1081
|
+
/**
|
|
1082
|
+
* 读取tms.private.js
|
|
1083
|
+
*/
|
|
1084
|
+
|
|
1085
|
+
|
|
1086
|
+
const readTmsPrivateCf$2 = function () {
|
|
1087
|
+
let tmsPrivateCg;
|
|
1088
|
+
const tmsPrivatePath = resolve$9(TMS_PRIVATE_FILENAME);
|
|
1089
|
+
|
|
1090
|
+
if (fs$8.existsSync(tmsPrivatePath)) {
|
|
1091
|
+
tmsPrivateCg = require(tmsPrivatePath);
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
return tmsPrivateCg;
|
|
1095
|
+
};
|
|
1096
|
+
/**
|
|
1097
|
+
* 从tms.config.json中检索用户传入的有效modules
|
|
1098
|
+
* @param { object } tmsConfig
|
|
1099
|
+
* @param { array } modules
|
|
1100
|
+
* @returns
|
|
1129
1101
|
*/
|
|
1130
1102
|
|
|
1131
1103
|
|
|
@@ -1137,42 +1109,48 @@ const checkModules$1 = function (tmsConfig, modules) {
|
|
|
1137
1109
|
});
|
|
1138
1110
|
|
|
1139
1111
|
if (targetModules.length === 0) {
|
|
1140
|
-
fail$
|
|
1112
|
+
fail$5(`你启动的模块无效,尝试 ${TMS_NAME$1} -m moduleName`);
|
|
1141
1113
|
process.exit(1);
|
|
1142
1114
|
}
|
|
1143
1115
|
|
|
1144
1116
|
return targetModules;
|
|
1145
1117
|
};
|
|
1146
|
-
/**
|
|
1147
|
-
* tms.config.js的modules 合并 module.config.json的配置项
|
|
1148
|
-
* @param {array} modules
|
|
1149
|
-
* @param {string} appName
|
|
1150
|
-
* @param {string} moduleDir
|
|
1151
|
-
* @returns
|
|
1118
|
+
/**
|
|
1119
|
+
* tms.config.js的modules 合并 module.config.json的配置项
|
|
1120
|
+
* @param {array} modules
|
|
1121
|
+
* @param {string} appName
|
|
1122
|
+
* @param {string} moduleDir
|
|
1123
|
+
* @returns
|
|
1152
1124
|
*/
|
|
1153
1125
|
|
|
1154
1126
|
|
|
1155
|
-
const tmsModulesMergeLocalModuleCfg$3 = (modules, appName
|
|
1127
|
+
const tmsModulesMergeLocalModuleCfg$3 = (modules, appName) => {
|
|
1156
1128
|
const newModules = [];
|
|
1157
1129
|
modules.forEach(({
|
|
1158
1130
|
path: relativePath,
|
|
1159
1131
|
name: moduleName
|
|
1160
1132
|
}, moduleIndex) => {
|
|
1161
|
-
const moduleConfigPath = resolve$
|
|
1133
|
+
const moduleConfigPath = resolve$9(relativePath, MODULE_CONFIG_FILENAME$1);
|
|
1162
1134
|
|
|
1163
1135
|
if (fs$8.existsSync(moduleConfigPath)) {
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
...
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1136
|
+
try {
|
|
1137
|
+
let moduleConfigContent = fs$8.readFileSync(moduleConfigPath, 'utf-8');
|
|
1138
|
+
moduleConfigContent = setModuleConfig(moduleConfigContent, appName);
|
|
1139
|
+
const moduleContentArr = isObject(moduleConfigContent) ? [moduleConfigContent] : moduleConfigContent;
|
|
1140
|
+
getValidModules(moduleContentArr).forEach(({
|
|
1141
|
+
name
|
|
1142
|
+
}, moduleContentArrIndex) => {
|
|
1143
|
+
if (name === moduleName) {
|
|
1144
|
+
newModules.push({ ...modules[moduleIndex],
|
|
1145
|
+
...moduleContentArr[moduleContentArrIndex]
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
});
|
|
1149
|
+
} catch (e) {
|
|
1150
|
+
fail$5(`${moduleConfigPath}配置错误: ${e}`);
|
|
1151
|
+
newModules.push({ ...modules[moduleIndex]
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1176
1154
|
} else {
|
|
1177
1155
|
newModules.push({ ...modules[moduleIndex]
|
|
1178
1156
|
});
|
|
@@ -1180,19 +1158,189 @@ const tmsModulesMergeLocalModuleCfg$3 = (modules, appName, moduleDir) => {
|
|
|
1180
1158
|
});
|
|
1181
1159
|
return newModules;
|
|
1182
1160
|
};
|
|
1161
|
+
/**
|
|
1162
|
+
* 分包依赖了分包的模块 合并所依赖的modules
|
|
1163
|
+
* @param { object } tmsConfig
|
|
1164
|
+
* @param {array} modules
|
|
1165
|
+
* @param {string} moduleDir
|
|
1166
|
+
* @returns
|
|
1167
|
+
*/
|
|
1168
|
+
|
|
1169
|
+
|
|
1170
|
+
const subModulesMergeDepModules$2 = (tmsConfig, modules) => {
|
|
1171
|
+
const moduleNames = [];
|
|
1172
|
+
modules.forEach(({
|
|
1173
|
+
name: moduleName
|
|
1174
|
+
}) => {
|
|
1175
|
+
moduleNames.push(moduleName);
|
|
1176
|
+
});
|
|
1177
|
+
let mergeModules = modules;
|
|
1178
|
+
let isOver = true;
|
|
1179
|
+
modules.forEach(({
|
|
1180
|
+
dependencies: dependencyModules
|
|
1181
|
+
}) => {
|
|
1182
|
+
dependencyModules === null || dependencyModules === void 0 ? void 0 : dependencyModules.forEach(item => {
|
|
1183
|
+
// 如果所有模块的dep都在moduleNames内,则所有依赖都齐了
|
|
1184
|
+
// 否则递归处理,根据name找到相关配置加到modules里
|
|
1185
|
+
if (moduleNames.indexOf(item) === -1) {
|
|
1186
|
+
isOver = false;
|
|
1187
|
+
const tmpModules = checkModules$1(tmsConfig, [...new Set([item])]);
|
|
1188
|
+
mergeModules = [...mergeModules, ...tmpModules];
|
|
1189
|
+
mergeModules = tmsModulesMergeLocalModuleCfg$3(mergeModules, tmsConfig.appName);
|
|
1190
|
+
}
|
|
1191
|
+
});
|
|
1192
|
+
});
|
|
1193
|
+
return isOver ? mergeModules : subModulesMergeDepModules$2(tmsConfig, mergeModules);
|
|
1194
|
+
};
|
|
1183
1195
|
|
|
1184
1196
|
var tkitUtils = {
|
|
1185
1197
|
readTmsConfig: readTmsConfig$1,
|
|
1198
|
+
readTmsPrivateCf: readTmsPrivateCf$2,
|
|
1186
1199
|
checkModules: checkModules$1,
|
|
1187
|
-
tmsModulesMergeLocalModuleCfg: tmsModulesMergeLocalModuleCfg$3
|
|
1200
|
+
tmsModulesMergeLocalModuleCfg: tmsModulesMergeLocalModuleCfg$3,
|
|
1201
|
+
subModulesMergeDepModules: subModulesMergeDepModules$2
|
|
1202
|
+
};
|
|
1203
|
+
|
|
1204
|
+
const MetalSmith = require$$0__default$4;
|
|
1205
|
+
const {
|
|
1206
|
+
getGlobalInstance
|
|
1207
|
+
} = global;
|
|
1208
|
+
const {
|
|
1209
|
+
downloadRepoForGit,
|
|
1210
|
+
resolve: resolve$8
|
|
1211
|
+
} = widgets;
|
|
1212
|
+
const {
|
|
1213
|
+
readTmsPrivateCf: readTmsPrivateCf$1
|
|
1214
|
+
} = tkitUtils;
|
|
1215
|
+
const {
|
|
1216
|
+
fail: fail$4
|
|
1217
|
+
} = log$2;
|
|
1218
|
+
const fs$7 = require$$0__default$1;
|
|
1219
|
+
const shelljs$4 = require$$4__default;
|
|
1220
|
+
const {
|
|
1221
|
+
handleError: handleError$1
|
|
1222
|
+
} = handleError_1;
|
|
1223
|
+
/**
|
|
1224
|
+
* 处理用户没有clone git仓库权限问题——拼接账号信息
|
|
1225
|
+
* @param {*} httpRepoUrl
|
|
1226
|
+
* @param {*} moduleName
|
|
1227
|
+
* @returns
|
|
1228
|
+
*/
|
|
1229
|
+
|
|
1230
|
+
function replaceGitUrlAccount(httpRepoUrl, moduleName, privateCf) {
|
|
1231
|
+
var _privateCf$gitAccout;
|
|
1232
|
+
|
|
1233
|
+
let gitUrl = httpRepoUrl;
|
|
1234
|
+
const {
|
|
1235
|
+
username = '',
|
|
1236
|
+
pass = ''
|
|
1237
|
+
} = (privateCf === null || privateCf === void 0 ? void 0 : (_privateCf$gitAccout = privateCf.gitAccout) === null || _privateCf$gitAccout === void 0 ? void 0 : _privateCf$gitAccout[moduleName]) || {};
|
|
1238
|
+
const urlPrefixReg = /http(s)?:\/\//;
|
|
1239
|
+
|
|
1240
|
+
if (username && pass && urlPrefixReg.test(gitUrl)) {
|
|
1241
|
+
gitUrl = gitUrl.replace(urlPrefixReg, val => `${val}${encodeURIComponent(username)}:${pass}@`);
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
return gitUrl;
|
|
1245
|
+
}
|
|
1246
|
+
/**
|
|
1247
|
+
* 对克隆下来的模块进行相应的文件处理操作,比如收集处理模块信息,进行信息缓存等操作
|
|
1248
|
+
* @param { string } sourceDir 缓存文件夹
|
|
1249
|
+
* @param { string } targetDir 目标文件夹
|
|
1250
|
+
* @param { arrary } ignore
|
|
1251
|
+
* @returns { undefined } no return
|
|
1252
|
+
*/
|
|
1253
|
+
|
|
1254
|
+
|
|
1255
|
+
function moveFile(sourceDir, targetDir, ignore = []) {
|
|
1256
|
+
// 删除不是文件夹的文件
|
|
1257
|
+
return new Promise((resolve, reject) => {
|
|
1258
|
+
MetalSmith(__dirname).ignore(ignore).source(sourceDir).destination(targetDir).build(e => {
|
|
1259
|
+
if (e) {
|
|
1260
|
+
fail$4(`${sourceDir} moveFile ${targetDir}出现错误: ${e}`);
|
|
1261
|
+
reject(e);
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
resolve();
|
|
1265
|
+
});
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
/**
|
|
1269
|
+
* 下载目标模块
|
|
1270
|
+
* @param { string } sourceDir 缓存文件夹
|
|
1271
|
+
* @param { string } targetDir 目标文件夹
|
|
1272
|
+
* @param { boolean } isDev 是否是dev
|
|
1273
|
+
* @returns { array } modules 描述模块的列表
|
|
1274
|
+
*/
|
|
1275
|
+
|
|
1276
|
+
|
|
1277
|
+
async function cloneModules$1(sourceDir, targetDir, modules, isDev) {
|
|
1278
|
+
// 用户本地的私有项目配置(用来配置环境\模块信息\账号信息)
|
|
1279
|
+
const privateCf = readTmsPrivateCf$1(); // 根据小程序的配置文件下载模块, 并且处理信息
|
|
1280
|
+
|
|
1281
|
+
for (const moduleInfo of modules) {
|
|
1282
|
+
if (moduleInfo.repoInfo) {
|
|
1283
|
+
await downLoadAndMoveModule(sourceDir, targetDir, moduleInfo, privateCf, isDev);
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
/**
|
|
1288
|
+
* 下载模块信息并且将它移动到对应的位置
|
|
1289
|
+
* @param { string } sourceDir 代码缓存文件夹
|
|
1290
|
+
* @param { string } targetDir 代码要放到的目标文件夹
|
|
1291
|
+
* @param { boolean } isDev 是否是dev
|
|
1292
|
+
* @returns { array } moduleInfo 描述模块的信息
|
|
1293
|
+
*/
|
|
1294
|
+
|
|
1295
|
+
|
|
1296
|
+
async function downLoadAndMoveModule(sourceDir, targetDir, moduleInfo, privateCf, isDev) {
|
|
1297
|
+
const {
|
|
1298
|
+
repoInfo: {
|
|
1299
|
+
buildGitTag,
|
|
1300
|
+
httpRepoUrl
|
|
1301
|
+
},
|
|
1302
|
+
path,
|
|
1303
|
+
name
|
|
1304
|
+
} = moduleInfo; // 源码临时存在的源目录
|
|
1305
|
+
|
|
1306
|
+
let sourcePath = resolve$8(sourceDir, name); // 源码要放到目标目录
|
|
1307
|
+
|
|
1308
|
+
const targetPath = resolve$8(targetDir, path); // 设置模块的构建分支
|
|
1309
|
+
|
|
1310
|
+
const cloneBranch = buildGitTag && typeof buildGitTag === 'string' ? buildGitTag : 'master'; // 检查缓存中有没有
|
|
1311
|
+
|
|
1312
|
+
const globalInstance = getGlobalInstance();
|
|
1313
|
+
const moduleInCache = globalInstance.getModuleCache(httpRepoUrl, cloneBranch);
|
|
1314
|
+
|
|
1315
|
+
try {
|
|
1316
|
+
if (!moduleInCache) {
|
|
1317
|
+
// 处理仓库权限问题
|
|
1318
|
+
const gitUrl = replaceGitUrlAccount(httpRepoUrl, name, privateCf);
|
|
1319
|
+
await downloadRepoForGit(gitUrl, sourcePath, cloneBranch);
|
|
1320
|
+
globalInstance.setModuleCache(httpRepoUrl, cloneBranch, sourcePath);
|
|
1321
|
+
} else {
|
|
1322
|
+
sourcePath = globalInstance.getModuleCache(httpRepoUrl, cloneBranch).dest;
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
if (fs$7.existsSync(targetPath)) {
|
|
1326
|
+
shelljs$4.rm('-rf', `${targetPath}/*`);
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
await moveFile(sourcePath, targetPath, ['node_modules', '.git']);
|
|
1330
|
+
} catch (e) {
|
|
1331
|
+
handleError$1(e, isDev);
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
var cloneModules_1 = {
|
|
1336
|
+
cloneModules: cloneModules$1
|
|
1188
1337
|
};
|
|
1189
1338
|
|
|
1190
|
-
/* eslint-disable require-jsdoc */
|
|
1191
1339
|
const ci = require$$0__default$6;
|
|
1192
|
-
const path$
|
|
1193
|
-
/**
|
|
1194
|
-
* 获取小程序ci的Project对象
|
|
1195
|
-
* @returns {Object} 小程序ci对象
|
|
1340
|
+
const path$5 = require$$3__default;
|
|
1341
|
+
/**
|
|
1342
|
+
* 获取小程序ci的Project对象
|
|
1343
|
+
* @returns {Object} 小程序ci对象
|
|
1196
1344
|
*/
|
|
1197
1345
|
|
|
1198
1346
|
const getMpCi = ({
|
|
@@ -1203,7 +1351,7 @@ const getMpCi = ({
|
|
|
1203
1351
|
}) => {
|
|
1204
1352
|
var _cfgJsonContent$packO;
|
|
1205
1353
|
|
|
1206
|
-
const cfgJsonContent = require(path$
|
|
1354
|
+
const cfgJsonContent = require(path$5.join(projectPath, 'project.config.json'));
|
|
1207
1355
|
|
|
1208
1356
|
const ignores = (cfgJsonContent === null || cfgJsonContent === void 0 ? void 0 : (_cfgJsonContent$packO = cfgJsonContent.packOptions) === null || _cfgJsonContent$packO === void 0 ? void 0 : _cfgJsonContent$packO.ignore.map(({
|
|
1209
1357
|
value
|
|
@@ -1223,10 +1371,10 @@ const packMpProject = async project => {
|
|
|
1223
1371
|
ignores: ['cloud/**/*']
|
|
1224
1372
|
});
|
|
1225
1373
|
};
|
|
1226
|
-
/**
|
|
1227
|
-
* 格式化构建npm结果信息
|
|
1228
|
-
* @param {Array<String>} warning 构建时的告警信息
|
|
1229
|
-
* @returns {String} npm构建错误信息
|
|
1374
|
+
/**
|
|
1375
|
+
* 格式化构建npm结果信息
|
|
1376
|
+
* @param {Array<String>} warning 构建时的告警信息
|
|
1377
|
+
* @returns {String} npm构建错误信息
|
|
1230
1378
|
*/
|
|
1231
1379
|
|
|
1232
1380
|
|
|
@@ -1239,9 +1387,9 @@ const formatPackNpmWarning = warning => {
|
|
|
1239
1387
|
\t@ ${it.jsPath}:${it.tips}`).join('---------------\n');
|
|
1240
1388
|
return result;
|
|
1241
1389
|
};
|
|
1242
|
-
/**
|
|
1243
|
-
* 构建miniprogram_npm
|
|
1244
|
-
* @returns {Object} 小程序ci对象
|
|
1390
|
+
/**
|
|
1391
|
+
* 构建miniprogram_npm
|
|
1392
|
+
* @returns {Object} 小程序ci对象
|
|
1245
1393
|
*/
|
|
1246
1394
|
|
|
1247
1395
|
|
|
@@ -1269,91 +1417,103 @@ var mpCiUtils = {
|
|
|
1269
1417
|
buildMpNpm: buildMpNpm$1
|
|
1270
1418
|
};
|
|
1271
1419
|
|
|
1272
|
-
/**
|
|
1273
|
-
* 本文件主要负责项目或者分包依赖的npm的安装
|
|
1420
|
+
/**
|
|
1421
|
+
* 本文件主要负责项目或者分包依赖的npm的安装
|
|
1274
1422
|
*/
|
|
1275
|
-
const fs$
|
|
1276
|
-
const
|
|
1277
|
-
const
|
|
1278
|
-
const
|
|
1423
|
+
const fs$6 = require$$0__default$1;
|
|
1424
|
+
const fsExtra = require$$1__default$3;
|
|
1425
|
+
const crypto = require$$2__default$1;
|
|
1426
|
+
const path$4 = require$$3__default;
|
|
1427
|
+
const shell = require$$4__default;
|
|
1428
|
+
const glob = require$$5__default;
|
|
1279
1429
|
const LOG = log$2;
|
|
1280
|
-
const
|
|
1281
|
-
|
|
1282
|
-
|
|
1430
|
+
const shellJsOption = {
|
|
1431
|
+
async: false,
|
|
1432
|
+
silent: true
|
|
1433
|
+
};
|
|
1434
|
+
const dirPath = process.cwd(); // 项目根目录
|
|
1435
|
+
|
|
1436
|
+
const install$3 = async (packageJsonPath = '', retry = true, cacheDir) => {
|
|
1437
|
+
const obj = {};
|
|
1438
|
+
const packageContent = fs$6.readFileSync(packageJsonPath);
|
|
1439
|
+
const packageJson = JSON.parse(packageContent);
|
|
1440
|
+
obj.dependencies = packageJson.dependencies || {}; // obj.devDependencies = packageJson.devDependencies || {};
|
|
1441
|
+
// dependencies和devDependencies字段为空,没有需要安装的npm包,直接return
|
|
1442
|
+
// if (Object.keys(obj.dependencies).length === 0 && Object.keys(obj.devDependencies).length === 0) {
|
|
1443
|
+
|
|
1444
|
+
if (Object.keys(obj.dependencies).length === 0) {
|
|
1445
|
+
return;
|
|
1446
|
+
} // 以package.json中dependencies字段stringify后的md5值作为缓存key
|
|
1447
|
+
// 任意包名或者版本号的差异,将导致md5后的差异,从而导致缓存失效,重新下载
|
|
1448
|
+
// 如此来保证npm缓存的准确性
|
|
1449
|
+
|
|
1450
|
+
|
|
1451
|
+
const str = JSON.stringify(obj);
|
|
1452
|
+
const key = crypto.createHash('md5').update(str).digest('hex');
|
|
1453
|
+
const keyPath = path$4.join(cacheDir, key);
|
|
1454
|
+
const tarFile = path$4.join(keyPath, 'node_modules.tar.gz'); // npm缓存路径不存在
|
|
1455
|
+
// 或者缓存的包大小小于512byte,认为缓存不合法
|
|
1456
|
+
// 清空缓存目录,重新下载npm包缓存
|
|
1457
|
+
|
|
1458
|
+
const missCache = !fsExtra.pathExistsSync(keyPath) || !fsExtra.existsSync(tarFile) || fsExtra.statSync(tarFile).size < 512;
|
|
1459
|
+
|
|
1460
|
+
if (missCache) {
|
|
1461
|
+
console.log(`未命中缓存,下载${packageJsonPath}依赖`);
|
|
1462
|
+
fsExtra.emptydirSync(keyPath);
|
|
1463
|
+
shell.cp('-f', packageJsonPath, keyPath);
|
|
1464
|
+
shell.cd(keyPath);
|
|
1283
1465
|
|
|
1466
|
+
try {
|
|
1467
|
+
shell.exec('npx yarn --production --registry http://mirrors.tencent.com/npm/', shellJsOption);
|
|
1468
|
+
} catch (err) {
|
|
1469
|
+
console.log('err', err);
|
|
1284
1470
|
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
}
|
|
1471
|
+
if (retry) {
|
|
1472
|
+
return await install$3(packageJsonPath, false);
|
|
1473
|
+
}
|
|
1289
1474
|
|
|
1290
|
-
|
|
1291
|
-
|
|
1475
|
+
throw err;
|
|
1476
|
+
}
|
|
1292
1477
|
|
|
1293
|
-
|
|
1294
|
-
shell.
|
|
1478
|
+
shell.exec('tar -zcvf ./node_modules.tar.gz ./node_modules', shellJsOption);
|
|
1479
|
+
shell.exec('rm -rf ./node_modules', shellJsOption);
|
|
1295
1480
|
}
|
|
1296
1481
|
|
|
1297
|
-
|
|
1298
|
-
shell.
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
const getNpmCache = function (targetDir, cacheDir) {
|
|
1306
|
-
const tarNpmFilename = getTarNpmFilename(targetDir);
|
|
1307
|
-
const tarNpmFilePath = `${cacheDir}/${tarNpmFilename}`;
|
|
1308
|
-
|
|
1309
|
-
if (fs$7.existsSync(tarNpmFilePath)) {
|
|
1310
|
-
const cmd = `tar -zxvf ${tarNpmFilePath} -C ./`;
|
|
1311
|
-
shell.exec(cmd, {
|
|
1312
|
-
async: false,
|
|
1313
|
-
silent: true
|
|
1314
|
-
});
|
|
1315
|
-
} // tar -zxvf /Users/odile/.tmskit/node_modules.tar.gz -C ./
|
|
1316
|
-
|
|
1482
|
+
shell.cp('-Rf', tarFile, `${path$4.dirname(packageJsonPath)}/`);
|
|
1483
|
+
shell.cd(path$4.dirname(packageJsonPath));
|
|
1484
|
+
shell.exec('tar -xzvf ./node_modules.tar.gz -C ./', shellJsOption);
|
|
1485
|
+
shell.exec('rm -rf ./node_modules.tar.gz', shellJsOption);
|
|
1486
|
+
return {
|
|
1487
|
+
missCache,
|
|
1488
|
+
key
|
|
1489
|
+
};
|
|
1317
1490
|
}; // 遍历安装指定目录下所有项目的npm依赖
|
|
1318
1491
|
|
|
1319
1492
|
|
|
1320
1493
|
const mpNpmInstallAll$1 = async (modules, contextDir, cacheDir) => {
|
|
1321
1494
|
const packageJsonFiles = await findAllPackageJson(modules, contextDir);
|
|
1322
|
-
await Promise.all(packageJsonFiles.map(file =>
|
|
1323
|
-
const dir = path$5.dirname(file);
|
|
1324
|
-
shell.cd(dir);
|
|
1325
|
-
|
|
1326
|
-
if (!fs$7.existsSync(`${dir}/node_modules`)) {
|
|
1327
|
-
getNpmCache(dir, cacheDir);
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
shell.exec('npx pnpm install --prod --registry http://mirrors.tencent.com/npm/', {
|
|
1331
|
-
silent: false
|
|
1332
|
-
});
|
|
1333
|
-
resolve();
|
|
1334
|
-
npmCache(dir, cacheDir);
|
|
1335
|
-
})));
|
|
1495
|
+
await Promise.all(packageJsonFiles.map(file => install$3(file, true, cacheDir)));
|
|
1336
1496
|
};
|
|
1337
|
-
/**
|
|
1338
|
-
* 递归查找指定条件的文件
|
|
1339
|
-
* @param {String} startPath 开始查找的根路径
|
|
1340
|
-
* @param {String} filter 匹配的字符串
|
|
1341
|
-
* @returns {Array<String>} 查找到的文件路径列表
|
|
1497
|
+
/**
|
|
1498
|
+
* 递归查找指定条件的文件
|
|
1499
|
+
* @param {String} startPath 开始查找的根路径
|
|
1500
|
+
* @param {String} filter 匹配的字符串
|
|
1501
|
+
* @returns {Array<String>} 查找到的文件路径列表
|
|
1342
1502
|
*/
|
|
1343
1503
|
|
|
1344
1504
|
|
|
1345
1505
|
const findFilesByFilter = (startPath, filter) => {
|
|
1346
1506
|
const result = [];
|
|
1347
|
-
/**
|
|
1348
|
-
* 根据指定的筛选器查找文件
|
|
1349
|
-
* @param {String} startPath 开始查找的文件夹路径
|
|
1350
|
-
* @param {String} filter 筛选器
|
|
1351
|
-
* @returns {Undefined} 无需返回值
|
|
1507
|
+
/**
|
|
1508
|
+
* 根据指定的筛选器查找文件
|
|
1509
|
+
* @param {String} startPath 开始查找的文件夹路径
|
|
1510
|
+
* @param {String} filter 筛选器
|
|
1511
|
+
* @returns {Undefined} 无需返回值
|
|
1352
1512
|
*/
|
|
1353
1513
|
|
|
1354
1514
|
const find = (startPath, filter) => {
|
|
1355
1515
|
// 目录不存在
|
|
1356
|
-
if (!fs$
|
|
1516
|
+
if (!fs$6.existsSync(startPath)) {
|
|
1357
1517
|
LOG.fail(`${startPath}目录不存在`);
|
|
1358
1518
|
process.exit(-1);
|
|
1359
1519
|
return;
|
|
@@ -1366,10 +1526,10 @@ const findFilesByFilter = (startPath, filter) => {
|
|
|
1366
1526
|
return;
|
|
1367
1527
|
}
|
|
1368
1528
|
|
|
1369
|
-
const files = fs$
|
|
1529
|
+
const files = fs$6.readdirSync(startPath);
|
|
1370
1530
|
files.forEach(file => {
|
|
1371
|
-
const filename = path$
|
|
1372
|
-
const stat = fs$
|
|
1531
|
+
const filename = path$4.join(startPath, file);
|
|
1532
|
+
const stat = fs$6.lstatSync(filename); // 当前文件是文件夹类型,继续递归
|
|
1373
1533
|
|
|
1374
1534
|
if (stat.isDirectory()) {
|
|
1375
1535
|
find(filename, filter);
|
|
@@ -1383,19 +1543,19 @@ const findFilesByFilter = (startPath, filter) => {
|
|
|
1383
1543
|
find(startPath, filter);
|
|
1384
1544
|
return result;
|
|
1385
1545
|
};
|
|
1386
|
-
/**
|
|
1387
|
-
* 找到项目中所有的package.json文件
|
|
1388
|
-
* @param {Array<String>} subRoots 需要安装npm依赖的路径
|
|
1389
|
-
* @param {String} contextDir 命令运行的目录
|
|
1390
|
-
* @returns {Array<String>} 找到的所有package.json文件的路径
|
|
1546
|
+
/**
|
|
1547
|
+
* 找到项目中所有的package.json文件
|
|
1548
|
+
* @param {Array<String>} subRoots 需要安装npm依赖的路径
|
|
1549
|
+
* @param {String} contextDir 命令运行的目录
|
|
1550
|
+
* @returns {Array<String>} 找到的所有package.json文件的路径
|
|
1391
1551
|
*/
|
|
1392
1552
|
|
|
1393
1553
|
|
|
1394
1554
|
const findAllPackageJson = (subRoots = [], contextDir) => {
|
|
1395
1555
|
const packageJsonName = 'package.json'; // 查找文件名
|
|
1396
1556
|
|
|
1397
|
-
const cwd = contextDir ||
|
|
1398
|
-
const result = [path$
|
|
1557
|
+
const cwd = contextDir || dirPath;
|
|
1558
|
+
const result = [path$4.join(cwd, packageJsonName)]; // 默认填充根目录下的package.json
|
|
1399
1559
|
|
|
1400
1560
|
subRoots.forEach(subRoot => {
|
|
1401
1561
|
if (!subRoot.root) {
|
|
@@ -1403,7 +1563,7 @@ const findAllPackageJson = (subRoots = [], contextDir) => {
|
|
|
1403
1563
|
process.exit(1);
|
|
1404
1564
|
}
|
|
1405
1565
|
|
|
1406
|
-
const toppath = path$
|
|
1566
|
+
const toppath = path$4.join(cwd, subRoot.root); // 从该目录开始查找package.json文件
|
|
1407
1567
|
|
|
1408
1568
|
const list = findFilesByFilter(toppath, packageJsonName);
|
|
1409
1569
|
result.push(...list);
|
|
@@ -1419,7 +1579,7 @@ function cloudNpmInstall$1(contextDir) {
|
|
|
1419
1579
|
}
|
|
1420
1580
|
|
|
1421
1581
|
files.forEach(file => {
|
|
1422
|
-
const dir = path$
|
|
1582
|
+
const dir = path$4.dirname(file);
|
|
1423
1583
|
shell.cd(dir);
|
|
1424
1584
|
shell.exec('npx npm install --production --registry http://mirrors.tencent.com/npm/', {
|
|
1425
1585
|
silent: false
|
|
@@ -1444,21 +1604,16 @@ const {
|
|
|
1444
1604
|
buildMpNpm
|
|
1445
1605
|
} = mpCiUtils;
|
|
1446
1606
|
const {
|
|
1447
|
-
CACHE_DIR
|
|
1448
|
-
DEFAULT_MODULE_DIR: DEFAULT_MODULE_DIR$2
|
|
1607
|
+
CACHE_DIR
|
|
1449
1608
|
} = require$$3;
|
|
1450
1609
|
const {
|
|
1451
1610
|
cloudNpmInstall,
|
|
1452
1611
|
mpNpmInstallAll
|
|
1453
1612
|
} = npmUtils;
|
|
1454
|
-
const {
|
|
1455
|
-
tmsModulesMergeLocalModuleCfg: tmsModulesMergeLocalModuleCfg$2
|
|
1456
|
-
} = tkitUtils;
|
|
1457
1613
|
|
|
1458
|
-
async function install$2(tmsConfig, modules, isCloud =
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
await createTask$2(mpNpmInstallAll, '小程序 开始npm install', '小程序npm install 完成')(newModules, resolve$7(tmsConfig.outputDir), `${CACHE_DIR}/node_modules`); // 构建miniprograme_npm
|
|
1614
|
+
async function install$2(tmsConfig, modules, isCloud = false) {
|
|
1615
|
+
// 小程序npm install
|
|
1616
|
+
await createTask$2(mpNpmInstallAll, '小程序 开始npm install', '小程序npm install 完成')(modules, resolve$7(tmsConfig.outputDir), `${CACHE_DIR}/node_modules`); // 构建miniprograme_npm
|
|
1462
1617
|
|
|
1463
1618
|
await createTask$2(buildMpNpm, '开始构建miniprograme_npm', '构建miniprograme_npm 完成')({
|
|
1464
1619
|
appId: tmsConfig.appId,
|
|
@@ -1471,8 +1626,8 @@ async function install$2(tmsConfig, modules, isCloud = true) {
|
|
|
1471
1626
|
|
|
1472
1627
|
var install_1 = install$2;
|
|
1473
1628
|
|
|
1474
|
-
const shelljs$3 = require$$
|
|
1475
|
-
const fs$
|
|
1629
|
+
const shelljs$3 = require$$4__default;
|
|
1630
|
+
const fs$5 = require$$0__default$1;
|
|
1476
1631
|
const io = io$2;
|
|
1477
1632
|
const {
|
|
1478
1633
|
resolve: resolve$6,
|
|
@@ -1483,32 +1638,32 @@ const {
|
|
|
1483
1638
|
} = buildAppJson;
|
|
1484
1639
|
const {
|
|
1485
1640
|
MODULE_CODE_DIR,
|
|
1486
|
-
DEFAULT_COPY_CONFIG
|
|
1487
|
-
DEFAULT_MODULE_DIR: DEFAULT_MODULE_DIR$1
|
|
1641
|
+
DEFAULT_COPY_CONFIG
|
|
1488
1642
|
} = require$$3;
|
|
1489
1643
|
const {
|
|
1490
1644
|
cloneModules
|
|
1491
1645
|
} = cloneModules_1;
|
|
1492
1646
|
const {
|
|
1493
|
-
tmsModulesMergeLocalModuleCfg: tmsModulesMergeLocalModuleCfg$
|
|
1647
|
+
tmsModulesMergeLocalModuleCfg: tmsModulesMergeLocalModuleCfg$2,
|
|
1648
|
+
subModulesMergeDepModules: subModulesMergeDepModules$1
|
|
1494
1649
|
} = tkitUtils;
|
|
1495
1650
|
const {
|
|
1496
|
-
fail: fail$
|
|
1651
|
+
fail: fail$3
|
|
1497
1652
|
} = log$2;
|
|
1498
1653
|
const install$1 = install_1;
|
|
1499
|
-
/**
|
|
1500
|
-
* 拷贝相关配置文件到编译输出目录
|
|
1501
|
-
* @param { object } tmsConfig
|
|
1502
|
-
* @param { array } modules
|
|
1503
|
-
* @param { array } defaultFiles 默认需要拷贝的配置项
|
|
1504
|
-
* @returns
|
|
1654
|
+
/**
|
|
1655
|
+
* 拷贝相关配置文件到编译输出目录
|
|
1656
|
+
* @param { object } tmsConfig
|
|
1657
|
+
* @param { array } modules
|
|
1658
|
+
* @param { array } defaultFiles 默认需要拷贝的配置项
|
|
1659
|
+
* @returns
|
|
1505
1660
|
*/
|
|
1506
1661
|
|
|
1507
1662
|
const cpFilesToOutput = function (tmsConfig, targetModules, defaultFiles) {
|
|
1508
1663
|
const outputDir = resolve$6(tmsConfig.outputDir);
|
|
1509
1664
|
io.ensureDirExist(outputDir);
|
|
1510
1665
|
defaultFiles.forEach(item => {
|
|
1511
|
-
if (fs$
|
|
1666
|
+
if (fs$5.existsSync(resolve$6(item))) {
|
|
1512
1667
|
shelljs$3.cp('-rf', resolve$6(item), resolve$6(tmsConfig.outputDir, item));
|
|
1513
1668
|
}
|
|
1514
1669
|
}); // 拷贝模块的package.json到编译输出目录
|
|
@@ -1516,37 +1671,44 @@ const cpFilesToOutput = function (tmsConfig, targetModules, defaultFiles) {
|
|
|
1516
1671
|
targetModules.forEach(item => {
|
|
1517
1672
|
const outputModuleDir = resolve$6(`${tmsConfig.outputDir}/${item.root}`);
|
|
1518
1673
|
|
|
1519
|
-
if (!fs$
|
|
1520
|
-
fail$
|
|
1674
|
+
if (!fs$5.existsSync(resolve$6(item.path))) {
|
|
1675
|
+
fail$3(`${item.path}模块代码路径不存在, 请检查tms.config.js的${item.name}模块的path`);
|
|
1521
1676
|
process.exit(1);
|
|
1522
1677
|
}
|
|
1523
1678
|
|
|
1524
1679
|
io.ensureDirExist(outputModuleDir);
|
|
1525
1680
|
const modulePackagePath = resolve$6(item.path, 'package.json');
|
|
1526
|
-
if (fs$
|
|
1681
|
+
if (fs$5.existsSync(modulePackagePath)) shelljs$3.cp('-Rf', modulePackagePath, outputModuleDir);
|
|
1527
1682
|
});
|
|
1528
1683
|
};
|
|
1529
1684
|
|
|
1530
|
-
async function task(tmsConfig, targetModules) {
|
|
1685
|
+
async function task(tmsConfig, targetModules, isDev) {
|
|
1531
1686
|
// 下载和移动代码
|
|
1532
|
-
await createTask$1(cloneModules, '开始下载模块代码完成', '下载模块代码码完成')(MODULE_CODE_DIR, resolve$6('./'), targetModules); // tms.config.js的modules 合并 module.config.json的配置项
|
|
1687
|
+
await createTask$1(cloneModules, '开始下载模块代码完成', '下载模块代码码完成')(MODULE_CODE_DIR, resolve$6('./'), targetModules, isDev); // tms.config.js的modules 合并 module.config.json的配置项
|
|
1533
1688
|
|
|
1534
|
-
|
|
1535
|
-
|
|
1689
|
+
let newModules = tmsModulesMergeLocalModuleCfg$2(targetModules, tmsConfig.appName); // A分包依赖了B分包的代码, merge B分包进行编译;
|
|
1690
|
+
|
|
1691
|
+
newModules = subModulesMergeDepModules$1(tmsConfig, newModules); // 拷贝相关配置文件到输出目录
|
|
1536
1692
|
|
|
1537
1693
|
await createTask$1(cpFilesToOutput, '开始拷贝文件到编译输出目录', '拷贝文件到编译输出目录完成')(tmsConfig, newModules, DEFAULT_COPY_CONFIG); // install
|
|
1538
1694
|
|
|
1539
1695
|
await install$1(tmsConfig, newModules, false); // 动态生成编译后的app.json;
|
|
1540
1696
|
|
|
1541
|
-
await createTask$1(buildOutputAppJson, '开始生成编译后的app.json', '生成编译后的app.json完成')(tmsConfig, newModules);
|
|
1697
|
+
await createTask$1(buildOutputAppJson, '开始生成编译后的app.json', '生成编译后的app.json完成')(tmsConfig, newModules, isDev);
|
|
1542
1698
|
return newModules;
|
|
1543
1699
|
}
|
|
1544
1700
|
|
|
1545
|
-
async function init$5(tmsConfig, targetModules) {
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1701
|
+
async function init$5(tmsConfig, targetModules, isDev) {
|
|
1702
|
+
try {
|
|
1703
|
+
const newModules = await task(tmsConfig, targetModules, isDev);
|
|
1704
|
+
return {
|
|
1705
|
+
targetModules: newModules
|
|
1706
|
+
};
|
|
1707
|
+
} catch (error) {
|
|
1708
|
+
const errMsg = typeof error === 'object' ? error.message : error;
|
|
1709
|
+
fail$3(`init流程出现错误${errMsg}`);
|
|
1710
|
+
process.exit(1);
|
|
1711
|
+
}
|
|
1550
1712
|
}
|
|
1551
1713
|
|
|
1552
1714
|
var init_1 = init$5;
|
|
@@ -1573,7 +1735,7 @@ function replaceEnv$1(reg = /process\.env(\.(\w*))?/g, envData) {
|
|
|
1573
1735
|
} // eslint-disable-next-line
|
|
1574
1736
|
|
|
1575
1737
|
|
|
1576
|
-
file.contents =
|
|
1738
|
+
file.contents = Buffer.from(contents);
|
|
1577
1739
|
}
|
|
1578
1740
|
|
|
1579
1741
|
this.push(file);
|
|
@@ -1588,10 +1750,10 @@ var replaceEnv_1 = replaceEnv$1;
|
|
|
1588
1750
|
const strip = require$$0__default$8; // 匹配规则
|
|
1589
1751
|
|
|
1590
1752
|
const MATCH_RULE = new RegExp(/@import *(?:url\(['"]?([^'")]+)['"]?\)|['"]([^'"]+)['"]);?/g);
|
|
1591
|
-
/**
|
|
1592
|
-
* 获取样式文件中的@import语句
|
|
1593
|
-
* @param code 代码片段
|
|
1594
|
-
* @returns 结果数组
|
|
1753
|
+
/**
|
|
1754
|
+
* 获取样式文件中的@import语句
|
|
1755
|
+
* @param code 代码片段
|
|
1756
|
+
* @returns 结果数组
|
|
1595
1757
|
*/
|
|
1596
1758
|
|
|
1597
1759
|
const findCssImports$1 = code => {
|
|
@@ -1620,16 +1782,16 @@ var findCssImport = {
|
|
|
1620
1782
|
|
|
1621
1783
|
/* eslint-disable no-param-reassign */
|
|
1622
1784
|
const {
|
|
1623
|
-
fail: fail$
|
|
1785
|
+
fail: fail$2
|
|
1624
1786
|
} = log$2;
|
|
1625
1787
|
|
|
1626
1788
|
function pluginError$3(error, isWatch) {
|
|
1627
1789
|
const errMsg = error.message;
|
|
1628
1790
|
|
|
1629
1791
|
if (isWatch) {
|
|
1630
|
-
fail$
|
|
1792
|
+
fail$2(errMsg);
|
|
1631
1793
|
} else {
|
|
1632
|
-
fail$
|
|
1794
|
+
fail$2(errMsg);
|
|
1633
1795
|
process.exit(1);
|
|
1634
1796
|
}
|
|
1635
1797
|
}
|
|
@@ -1641,7 +1803,7 @@ var pluginError_1 = {
|
|
|
1641
1803
|
/* eslint-disable no-param-reassign */
|
|
1642
1804
|
const through$2 = require$$0__default$7;
|
|
1643
1805
|
const precinct = require$$1__default$4;
|
|
1644
|
-
const path$
|
|
1806
|
+
const path$3 = require$$3__default;
|
|
1645
1807
|
const {
|
|
1646
1808
|
findCssImports
|
|
1647
1809
|
} = findCssImport;
|
|
@@ -1653,7 +1815,7 @@ const {
|
|
|
1653
1815
|
const {
|
|
1654
1816
|
resolve: resolve$5
|
|
1655
1817
|
} = widgets;
|
|
1656
|
-
const fs$
|
|
1818
|
+
const fs$4 = require$$0__default$1;
|
|
1657
1819
|
const {
|
|
1658
1820
|
pluginError: pluginError$2
|
|
1659
1821
|
} = pluginError_1;
|
|
@@ -1666,16 +1828,16 @@ const dfsFindCommonDep$2 = function (anaFileOriginFile, anaFileDestFile, extensi
|
|
|
1666
1828
|
let contents = '';
|
|
1667
1829
|
|
|
1668
1830
|
try {
|
|
1669
|
-
contents = fs$
|
|
1831
|
+
contents = fs$4.readFileSync(anaFileOriginFile, 'utf8');
|
|
1670
1832
|
} catch (e) {
|
|
1671
1833
|
pluginError$2(e, isWatch);
|
|
1672
1834
|
}
|
|
1673
1835
|
|
|
1674
|
-
const deps = cssFilter.indexOf(path$
|
|
1836
|
+
const deps = cssFilter.indexOf(path$3.extname(anaFileOriginFile)) > -1 ? findCssImports(contents) : precinct(contents);
|
|
1675
1837
|
deps.forEach(depItem => {
|
|
1676
1838
|
if (depItem.startsWith('.')) {
|
|
1677
1839
|
// 被依赖文件的存在的绝对路径
|
|
1678
|
-
const depOriginPath = path$
|
|
1840
|
+
const depOriginPath = path$3.join(path$3.dirname(anaFileOriginFile), depItem); // 被依赖文件加上后缀
|
|
1679
1841
|
|
|
1680
1842
|
const {
|
|
1681
1843
|
ext: extAlias,
|
|
@@ -1683,12 +1845,12 @@ const dfsFindCommonDep$2 = function (anaFileOriginFile, anaFileDestFile, extensi
|
|
|
1683
1845
|
extPath
|
|
1684
1846
|
} = ext$2(depOriginPath, extensions);
|
|
1685
1847
|
|
|
1686
|
-
if (!fs$
|
|
1848
|
+
if (!fs$4.existsSync(depOriginFile)) {
|
|
1687
1849
|
pluginError$2(new Error(`${anaFileOriginFile}引用路径${depOriginFile}文件不存在, 请检查应用路径`), isWatch);
|
|
1688
1850
|
return;
|
|
1689
1851
|
}
|
|
1690
1852
|
|
|
1691
|
-
const depDestPath = resolve$5(path$
|
|
1853
|
+
const depDestPath = resolve$5(path$3.dirname(anaFileDestFile), depItem);
|
|
1692
1854
|
const depDestFile = depDestPath.endsWith(extAlias) ? depDestPath : depDestPath + extPath;
|
|
1693
1855
|
|
|
1694
1856
|
if (!resDep.has(depDestFile)) {
|
|
@@ -1712,19 +1874,19 @@ function mpCommonDep$1(tmsConfig, module, extensions = [], isWatch = true) {
|
|
|
1712
1874
|
const stream = through$2.obj(function (file, enc, cb) {
|
|
1713
1875
|
// 依赖分析的文件
|
|
1714
1876
|
const anaFileOriginFile = file.history[0];
|
|
1715
|
-
const anaFileRelativeModule = path$
|
|
1877
|
+
const anaFileRelativeModule = path$3.relative(resolve$5(module.from), anaFileOriginFile);
|
|
1716
1878
|
const anaFileDestFile = resolve$5(tmsConfig.outputDir, module.to, anaFileRelativeModule);
|
|
1717
1879
|
|
|
1718
1880
|
if (file.isBuffer()) {
|
|
1719
1881
|
let contents = String(file.contents);
|
|
1720
|
-
const deps = cssFilter.indexOf(path$
|
|
1882
|
+
const deps = cssFilter.indexOf(path$3.extname(file.path)) > -1 ? findCssImports(contents) : precinct(contents);
|
|
1721
1883
|
const copyModules = new Map();
|
|
1722
1884
|
Object.keys(tmsConfig.dependencies).forEach(includeName => {
|
|
1723
1885
|
const includePath = tmsConfig.dependencies[includeName];
|
|
1724
1886
|
deps.forEach(depItem => {
|
|
1725
1887
|
if (depItem.indexOf(includeName) > -1) {
|
|
1726
1888
|
// 被依赖文件的存在的绝对路径 (eg: /User/thirdparty/loadsh)
|
|
1727
|
-
const depOriginPath = path$
|
|
1889
|
+
const depOriginPath = path$3.join(path$3.dirname(anaFileOriginFile), depItem); // 被依赖文件加上后缀
|
|
1728
1890
|
|
|
1729
1891
|
const {
|
|
1730
1892
|
ext: extAlias,
|
|
@@ -1750,7 +1912,7 @@ function mpCommonDep$1(tmsConfig, module, extensions = [], isWatch = true) {
|
|
|
1750
1912
|
depOriginFile,
|
|
1751
1913
|
depDestFile,
|
|
1752
1914
|
beforeDepPath: depItem,
|
|
1753
|
-
afterDepPath: path$
|
|
1915
|
+
afterDepPath: path$3.relative(path$3.dirname(anaFileDestFile), depDestPath).replace(/\\/g, '/')
|
|
1754
1916
|
});
|
|
1755
1917
|
}
|
|
1756
1918
|
}
|
|
@@ -1772,7 +1934,7 @@ function mpCommonDep$1(tmsConfig, module, extensions = [], isWatch = true) {
|
|
|
1772
1934
|
diffContentCopyFile$2(item.depOriginFile, item.depDestFile);
|
|
1773
1935
|
}); // console.log('mpCommonDep defs', defs);
|
|
1774
1936
|
});
|
|
1775
|
-
file.contents =
|
|
1937
|
+
file.contents = Buffer.from(contents);
|
|
1776
1938
|
}
|
|
1777
1939
|
|
|
1778
1940
|
this.push(file);
|
|
@@ -1788,7 +1950,7 @@ var mpCommonDep_1 = {
|
|
|
1788
1950
|
|
|
1789
1951
|
/* eslint-disable no-param-reassign */
|
|
1790
1952
|
const through$1 = require$$0__default$7;
|
|
1791
|
-
const path$
|
|
1953
|
+
const path$2 = require$$3__default;
|
|
1792
1954
|
const {
|
|
1793
1955
|
ext: ext$1,
|
|
1794
1956
|
fileInDir: fileInDir$1,
|
|
@@ -1797,7 +1959,7 @@ const {
|
|
|
1797
1959
|
const {
|
|
1798
1960
|
resolve: resolve$4
|
|
1799
1961
|
} = widgets;
|
|
1800
|
-
const fs$
|
|
1962
|
+
const fs$3 = require$$0__default$1;
|
|
1801
1963
|
const {
|
|
1802
1964
|
pluginError: pluginError$1
|
|
1803
1965
|
} = pluginError_1;
|
|
@@ -1809,7 +1971,7 @@ function mpJsonDep$1(tmsConfig, module, extensions = ['.json'], filesExt = ['.wx
|
|
|
1809
1971
|
const stream = through$1.obj(function (file, enc, cb) {
|
|
1810
1972
|
// 当前分析的文件的路径
|
|
1811
1973
|
const anaFileOriginFile = file.history[0];
|
|
1812
|
-
const anaFileRelativeModule = path$
|
|
1974
|
+
const anaFileRelativeModule = path$2.relative(resolve$4(module.from), anaFileOriginFile);
|
|
1813
1975
|
const anaFileDestFile = resolve$4(tmsConfig.outputDir, module.to, anaFileRelativeModule);
|
|
1814
1976
|
|
|
1815
1977
|
if (file.isBuffer()) {
|
|
@@ -1826,7 +1988,7 @@ function mpJsonDep$1(tmsConfig, module, extensions = ['.json'], filesExt = ['.wx
|
|
|
1826
1988
|
const componentPath = contents.usingComponents[componentKey];
|
|
1827
1989
|
|
|
1828
1990
|
if (componentPath.indexOf(includeName) > -1) {
|
|
1829
|
-
const depOriginPath = path$
|
|
1991
|
+
const depOriginPath = path$2.join(path$2.dirname(anaFileOriginFile), componentPath); // 被依赖文件加上后缀
|
|
1830
1992
|
|
|
1831
1993
|
const {
|
|
1832
1994
|
ext: extAlias,
|
|
@@ -1854,7 +2016,7 @@ function mpJsonDep$1(tmsConfig, module, extensions = ['.json'], filesExt = ['.wx
|
|
|
1854
2016
|
depOriginExt: extAlias,
|
|
1855
2017
|
depDestFile,
|
|
1856
2018
|
beforeDepPath: componentPath,
|
|
1857
|
-
afterDepPath: path$
|
|
2019
|
+
afterDepPath: path$2.relative(path$2.dirname(anaFileDestFile), depDestPath).replace(/\\/g, '/')
|
|
1858
2020
|
});
|
|
1859
2021
|
}
|
|
1860
2022
|
}
|
|
@@ -1879,7 +2041,7 @@ function mpJsonDep$1(tmsConfig, module, extensions = ['.json'], filesExt = ['.wx
|
|
|
1879
2041
|
const originFile = depOriginFile.replace(depOriginExt, extKey);
|
|
1880
2042
|
const destFile = depDestFile.replace(depOriginExt, extKey);
|
|
1881
2043
|
|
|
1882
|
-
if (fs$
|
|
2044
|
+
if (fs$3.existsSync(originFile)) {
|
|
1883
2045
|
diffContentCopyFile$1(originFile, destFile);
|
|
1884
2046
|
const extensionsFilter = ['.js', '.ts', '.wxss', '.less'];
|
|
1885
2047
|
|
|
@@ -1897,7 +2059,7 @@ function mpJsonDep$1(tmsConfig, module, extensions = ['.json'], filesExt = ['.wx
|
|
|
1897
2059
|
contents = contents.replace(reg, `"${afterDepPath}"`);
|
|
1898
2060
|
});
|
|
1899
2061
|
contents = typeof contents === 'object' ? JSON.stringify(contents, null, 2) : contents;
|
|
1900
|
-
file.contents =
|
|
2062
|
+
file.contents = Buffer.from(contents);
|
|
1901
2063
|
}
|
|
1902
2064
|
|
|
1903
2065
|
this.push(file);
|
|
@@ -1913,8 +2075,8 @@ var mpJsonDep_1 = {
|
|
|
1913
2075
|
/* eslint-disable no-param-reassign */
|
|
1914
2076
|
const through = require$$0__default$7;
|
|
1915
2077
|
const htmlparser2 = require$$1__default$5;
|
|
1916
|
-
const fs$
|
|
1917
|
-
const path$
|
|
2078
|
+
const fs$2 = require$$0__default$1;
|
|
2079
|
+
const path$1 = require$$3__default;
|
|
1918
2080
|
const {
|
|
1919
2081
|
diffContentCopyFile,
|
|
1920
2082
|
ext,
|
|
@@ -1960,7 +2122,7 @@ const dfsFindWxmlDep = function (anaFileOriginFile, anaFileDestFile, isWatch = t
|
|
|
1960
2122
|
let contents = '';
|
|
1961
2123
|
|
|
1962
2124
|
try {
|
|
1963
|
-
contents = fs$
|
|
2125
|
+
contents = fs$2.readFileSync(anaFileOriginFile, 'utf8');
|
|
1964
2126
|
} catch (e) {
|
|
1965
2127
|
pluginError(e, isWatch);
|
|
1966
2128
|
}
|
|
@@ -1970,7 +2132,7 @@ const dfsFindWxmlDep = function (anaFileOriginFile, anaFileDestFile, isWatch = t
|
|
|
1970
2132
|
var _attributes$src;
|
|
1971
2133
|
|
|
1972
2134
|
if (attributes !== null && attributes !== void 0 && (_attributes$src = attributes.src) !== null && _attributes$src !== void 0 && _attributes$src.startsWith('.')) {
|
|
1973
|
-
const depOriginPath = path$
|
|
2135
|
+
const depOriginPath = path$1.join(path$1.dirname(anaFileOriginFile), attributes.src); // 被依赖文件加上后缀
|
|
1974
2136
|
|
|
1975
2137
|
const {
|
|
1976
2138
|
ext,
|
|
@@ -1978,12 +2140,12 @@ const dfsFindWxmlDep = function (anaFileOriginFile, anaFileDestFile, isWatch = t
|
|
|
1978
2140
|
extPath
|
|
1979
2141
|
} = extFile(name, depOriginPath);
|
|
1980
2142
|
|
|
1981
|
-
if (!fs$
|
|
2143
|
+
if (!fs$2.existsSync(depOriginFile)) {
|
|
1982
2144
|
pluginError(new Error(`${anaFileOriginFile}引用的路径${depOriginFile}找不到应用文件,请检查引用路径`), isWatch);
|
|
1983
2145
|
return;
|
|
1984
2146
|
}
|
|
1985
2147
|
|
|
1986
|
-
const depDestPath = path$
|
|
2148
|
+
const depDestPath = path$1.join(path$1.dirname(anaFileDestFile), attributes.src);
|
|
1987
2149
|
const depDestFile = depDestPath.endsWith(ext) ? depDestPath : depDestPath + extPath; // 收集wxml依赖
|
|
1988
2150
|
|
|
1989
2151
|
if (['import', 'include'].indexOf(name) > -1) {
|
|
@@ -2035,7 +2197,7 @@ function mpWxmlDep$1(tmsConfig, module, isWatch) {
|
|
|
2035
2197
|
const stream = through.obj(function (file, enc, cb) {
|
|
2036
2198
|
// 依赖分析的文件
|
|
2037
2199
|
const anaFileOriginFile = file.history[0];
|
|
2038
|
-
const anaFileRelativeModule = path$
|
|
2200
|
+
const anaFileRelativeModule = path$1.relative(resolve$3(module.from), anaFileOriginFile);
|
|
2039
2201
|
const anaFileDestFile = resolve$3(tmsConfig.outputDir, module.to, anaFileRelativeModule);
|
|
2040
2202
|
|
|
2041
2203
|
if (file.isBuffer()) {
|
|
@@ -2046,7 +2208,7 @@ function mpWxmlDep$1(tmsConfig, module, isWatch) {
|
|
|
2046
2208
|
const nameFilter = ['import', 'include', 'wxs'];
|
|
2047
2209
|
|
|
2048
2210
|
if (nameFilter.indexOf(name) > -1 && attributes.src) {
|
|
2049
|
-
const depOriginPath = path$
|
|
2211
|
+
const depOriginPath = path$1.join(path$1.dirname(anaFileOriginFile), attributes.src); // 处理后缀(源码引入依赖时,后缀不全的情况)
|
|
2050
2212
|
|
|
2051
2213
|
const {
|
|
2052
2214
|
ext,
|
|
@@ -2075,7 +2237,7 @@ function mpWxmlDep$1(tmsConfig, module, isWatch) {
|
|
|
2075
2237
|
depOriginFile,
|
|
2076
2238
|
depDestFile,
|
|
2077
2239
|
beforeDepPath: attributes.src,
|
|
2078
|
-
afterDepPath: path$
|
|
2240
|
+
afterDepPath: path$1.relative(path$1.dirname(anaFileDestFile), depDestFile).replace(/\\/g, '/')
|
|
2079
2241
|
});
|
|
2080
2242
|
}
|
|
2081
2243
|
}
|
|
@@ -2094,7 +2256,7 @@ function mpWxmlDep$1(tmsConfig, module, isWatch) {
|
|
|
2094
2256
|
beforeDepPath,
|
|
2095
2257
|
afterDepPath
|
|
2096
2258
|
}) => {
|
|
2097
|
-
if (fs$
|
|
2259
|
+
if (fs$2.existsSync(depOriginFile)) {
|
|
2098
2260
|
diffContentCopyFile(depOriginFile, depDestFile);
|
|
2099
2261
|
const reg = new RegExp(`['"]${beforeDepPath}["']`, 'g');
|
|
2100
2262
|
contents = contents.replace(reg, `"${afterDepPath}"`);
|
|
@@ -2116,7 +2278,7 @@ function mpWxmlDep$1(tmsConfig, module, isWatch) {
|
|
|
2116
2278
|
});
|
|
2117
2279
|
}
|
|
2118
2280
|
});
|
|
2119
|
-
file.contents =
|
|
2281
|
+
file.contents = Buffer.from(contents);
|
|
2120
2282
|
}
|
|
2121
2283
|
|
|
2122
2284
|
this.push(file);
|
|
@@ -2130,83 +2292,15 @@ var mpWxmlDep_1 = {
|
|
|
2130
2292
|
dfsFindWxmlDep
|
|
2131
2293
|
};
|
|
2132
2294
|
|
|
2133
|
-
/* eslint-disable no-param-reassign */
|
|
2134
|
-
const postcss$1 = require$$0__default$9;
|
|
2135
|
-
const fs$2 = require$$0__default$1;
|
|
2136
|
-
const path$1 = require$$1__default$1;
|
|
2137
|
-
const {
|
|
2138
|
-
fail: fail$3
|
|
2139
|
-
} = log$2;
|
|
2140
|
-
var postcssFontBase64 = postcss$1.plugin('postcss-font-base64', options => {
|
|
2141
|
-
options = { ...options,
|
|
2142
|
-
...{
|
|
2143
|
-
match: {
|
|
2144
|
-
Scrabble: ['fakefont']
|
|
2145
|
-
},
|
|
2146
|
-
format: ['eot', 'woff', 'woff2', 'ttf']
|
|
2147
|
-
}
|
|
2148
|
-
};
|
|
2149
|
-
return function (css, result) {
|
|
2150
|
-
css.walkAtRules('font-face', fontFace => {
|
|
2151
|
-
const fileTypeRegex = getRegexStringForFileTypes(options.format);
|
|
2152
|
-
fontFace.replaceValues(new RegExp(`url\\(["']?.+\\.${fileTypeRegex}["']?\\)`), attr => {
|
|
2153
|
-
const fontRePath = attr.replace(/(url|'|"|\(|\)|\?#iefix)/g, '');
|
|
2154
|
-
const fontAbPath = path$1.join(path$1.dirname(result.opts.from), fontRePath);
|
|
2155
|
-
const res64 = base64Encode(fontAbPath);
|
|
2156
|
-
const newUrlStr = 'url(data:'.concat(getMimeType(attr)).concat(';charset=utf-8;base64,').concat(res64).concat(')');
|
|
2157
|
-
return res64 ? newUrlStr : attr;
|
|
2158
|
-
});
|
|
2159
|
-
});
|
|
2160
|
-
|
|
2161
|
-
function getRegexStringForFileTypes(fileTypes) {
|
|
2162
|
-
const regex = fileTypes.map(fileType => fileType === 'eot' ? fileType.concat('(\\?#iefix)?') : fileType).join('|');
|
|
2163
|
-
return regex ? `(${regex})` : '';
|
|
2164
|
-
} // helper functions
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
function getMimeType(attribute) {
|
|
2168
|
-
const formats = {
|
|
2169
|
-
'.woff': 'application/font-woff',
|
|
2170
|
-
'.woff2': 'font/woff2',
|
|
2171
|
-
'.ttf': 'application/font-sfnt',
|
|
2172
|
-
'.eot': 'application/vnd.ms-fontobject',
|
|
2173
|
-
'.otf': 'application/font-sfnt'
|
|
2174
|
-
};
|
|
2175
|
-
let match = '';
|
|
2176
|
-
const extension = attribute.match(/\.[a-z]{3,4}/)[0];
|
|
2177
|
-
|
|
2178
|
-
if (extension in formats) {
|
|
2179
|
-
match = formats[extension];
|
|
2180
|
-
}
|
|
2181
|
-
return match;
|
|
2182
|
-
}
|
|
2183
|
-
|
|
2184
|
-
function base64Encode(file) {
|
|
2185
|
-
if (fs$2.existsSync(file)) {
|
|
2186
|
-
return readAndEncodeFile(file);
|
|
2187
|
-
}
|
|
2188
|
-
|
|
2189
|
-
fail$3(`${file} does not exist.`);
|
|
2190
|
-
return '';
|
|
2191
|
-
}
|
|
2192
|
-
|
|
2193
|
-
function readAndEncodeFile(file) {
|
|
2194
|
-
const bitmap = fs$2.readFileSync(file);
|
|
2195
|
-
return new Buffer(bitmap).toString('base64');
|
|
2196
|
-
}
|
|
2197
|
-
};
|
|
2198
|
-
});
|
|
2199
|
-
|
|
2200
2295
|
const {
|
|
2201
2296
|
src: src$1,
|
|
2202
2297
|
dest,
|
|
2203
2298
|
lastRun
|
|
2204
|
-
} = require$$0__default$
|
|
2299
|
+
} = require$$0__default$9;
|
|
2205
2300
|
const px2rpx = require$$1__default$6;
|
|
2206
|
-
const
|
|
2207
|
-
const
|
|
2208
|
-
|
|
2209
|
-
const image = require$$5__default$1;
|
|
2301
|
+
const watch = require$$2__default$2; // const cache = require('gulp-cache');
|
|
2302
|
+
// const image = require('gulp-image');
|
|
2303
|
+
|
|
2210
2304
|
const replaceEnv = replaceEnv_1;
|
|
2211
2305
|
const {
|
|
2212
2306
|
mpCommonDep
|
|
@@ -2217,9 +2311,8 @@ const {
|
|
|
2217
2311
|
const {
|
|
2218
2312
|
mpWxmlDep
|
|
2219
2313
|
} = mpWxmlDep_1;
|
|
2220
|
-
const base64 = postcssFontBase64;
|
|
2221
2314
|
const {
|
|
2222
|
-
fail: fail$
|
|
2315
|
+
fail: fail$1
|
|
2223
2316
|
} = log$2;
|
|
2224
2317
|
|
|
2225
2318
|
const since = task => file => lastRun(task) > file.stat.ctime ? lastRun(task) : 0;
|
|
@@ -2250,14 +2343,12 @@ var compile = function (tmsConfig, {
|
|
|
2250
2343
|
switch (globKey) {
|
|
2251
2344
|
case 'js':
|
|
2252
2345
|
srcPipe.pipe(replaceEnv(/process\.env(\.(\w*))?/g, tmsConfig.envData)).pipe(mpCommonDep(tmsConfig, module, ['.js', '.ts', '.wxs', '.json'], isWatch)).pipe(dest(destPath)).on('error', err => {
|
|
2253
|
-
fail$
|
|
2346
|
+
fail$1(`js编译报错${err}`);
|
|
2254
2347
|
});
|
|
2255
2348
|
break;
|
|
2256
2349
|
|
|
2257
2350
|
case 'wxss':
|
|
2258
|
-
srcPipe.pipe(mpCommonDep(tmsConfig, module, ['.wxss', '.less'], isWatch)).pipe(
|
|
2259
|
-
fail$2(`postcss编译报错${err}`);
|
|
2260
|
-
}).pipe(px2rpx({
|
|
2351
|
+
srcPipe.pipe(mpCommonDep(tmsConfig, module, ['.wxss', '.less'], isWatch)).pipe(px2rpx({
|
|
2261
2352
|
designWidth: 375,
|
|
2262
2353
|
// 设计稿宽度,默认为750
|
|
2263
2354
|
precision: 2 // 小数最大精度,默认为6
|
|
@@ -2267,7 +2358,7 @@ var compile = function (tmsConfig, {
|
|
|
2267
2358
|
|
|
2268
2359
|
case 'json':
|
|
2269
2360
|
srcPipe.pipe(mpJsonDep(tmsConfig, module, ['.json'], ['.wxml', '.json', '.js', '.ts', '.wxss', '.less'], isWatch)).on('error', err => {
|
|
2270
|
-
fail$
|
|
2361
|
+
fail$1(`json编译报错${err}`);
|
|
2271
2362
|
}).pipe(dest(destPath));
|
|
2272
2363
|
break;
|
|
2273
2364
|
|
|
@@ -2276,9 +2367,11 @@ var compile = function (tmsConfig, {
|
|
|
2276
2367
|
break;
|
|
2277
2368
|
|
|
2278
2369
|
case 'image':
|
|
2279
|
-
srcPipe.pipe(cache(image()))
|
|
2280
|
-
|
|
2281
|
-
})
|
|
2370
|
+
srcPipe // .pipe(cache(image()))
|
|
2371
|
+
// .on('error', (err) => {
|
|
2372
|
+
// fail(`image编译报错${err}`);
|
|
2373
|
+
// })
|
|
2374
|
+
.pipe(dest(destPath));
|
|
2282
2375
|
break;
|
|
2283
2376
|
|
|
2284
2377
|
case 'other':
|
|
@@ -2289,7 +2382,7 @@ var compile = function (tmsConfig, {
|
|
|
2289
2382
|
};
|
|
2290
2383
|
|
|
2291
2384
|
(function (module) {
|
|
2292
|
-
const watch = require$$
|
|
2385
|
+
const watch = require$$2__default$2;
|
|
2293
2386
|
const {
|
|
2294
2387
|
resolve
|
|
2295
2388
|
} = widgets;
|
|
@@ -2329,10 +2422,10 @@ var compile = function (tmsConfig, {
|
|
|
2329
2422
|
ignoreInitial: false,
|
|
2330
2423
|
events: ['add', 'change']
|
|
2331
2424
|
}, () => {
|
|
2332
|
-
buildOutputAppJson(tmsConfig, newModules);
|
|
2425
|
+
buildOutputAppJson(tmsConfig, newModules, isWatch);
|
|
2333
2426
|
});
|
|
2334
2427
|
} else {
|
|
2335
|
-
buildOutputAppJson(tmsConfig, newModules);
|
|
2428
|
+
buildOutputAppJson(tmsConfig, newModules, isWatch);
|
|
2336
2429
|
} // 监听根目录的文件
|
|
2337
2430
|
|
|
2338
2431
|
|
|
@@ -2366,7 +2459,7 @@ var compile = function (tmsConfig, {
|
|
|
2366
2459
|
watch(`${resolve(module.path)}/**/module.config.json`, {
|
|
2367
2460
|
events: ['change']
|
|
2368
2461
|
}, () => {
|
|
2369
|
-
buildOutputAppJson(tmsConfig, newModules);
|
|
2462
|
+
buildOutputAppJson(tmsConfig, newModules, isWatch);
|
|
2370
2463
|
});
|
|
2371
2464
|
}
|
|
2372
2465
|
|
|
@@ -2392,23 +2485,18 @@ var compile = function (tmsConfig, {
|
|
|
2392
2485
|
},
|
|
2393
2486
|
isWatch
|
|
2394
2487
|
});
|
|
2395
|
-
} //
|
|
2488
|
+
} // 静态资源目录-拷贝
|
|
2396
2489
|
|
|
2397
2490
|
|
|
2398
2491
|
if (tmsConfig !== null && tmsConfig !== void 0 && tmsConfig.static && (tmsConfig === null || tmsConfig === void 0 ? void 0 : tmsConfig.static.length) > 0) {
|
|
2399
2492
|
for (const item of tmsConfig.static) {
|
|
2400
|
-
const
|
|
2401
|
-
|
|
2402
|
-
json: `${item.from}/**/*.json`,
|
|
2403
|
-
wxss: `${item.from}/**/*.{less,wxss}`,
|
|
2404
|
-
wxml: `${item.from}/**/*.wxml`,
|
|
2405
|
-
image: `${item.from}/**/*.{png,jpg,jpeg,gif,svg}`
|
|
2406
|
-
};
|
|
2493
|
+
const from = item !== null && item !== void 0 && item.from.startsWith('/') ? item.from : resolve(item.from);
|
|
2494
|
+
const to = item !== null && item !== void 0 && item.to.startsWith('/') ? item.to : resolve(item.to);
|
|
2407
2495
|
compile$1(tmsConfig, {
|
|
2408
|
-
glob: {
|
|
2409
|
-
other: [
|
|
2496
|
+
glob: {
|
|
2497
|
+
other: [from]
|
|
2410
2498
|
},
|
|
2411
|
-
destPath:
|
|
2499
|
+
destPath: to,
|
|
2412
2500
|
module: item,
|
|
2413
2501
|
srcOption: {
|
|
2414
2502
|
allowEmpty: true
|
|
@@ -2425,26 +2513,26 @@ const semver$1 = require$$1__default$7;
|
|
|
2425
2513
|
const {
|
|
2426
2514
|
resolve: resolve$2
|
|
2427
2515
|
} = widgets;
|
|
2428
|
-
const path = require$$
|
|
2516
|
+
const path = require$$3__default;
|
|
2517
|
+
const shelljs$2 = require$$4__default;
|
|
2429
2518
|
const {
|
|
2430
|
-
|
|
2431
|
-
} =
|
|
2432
|
-
const shelljs$2 = require$$5__default;
|
|
2519
|
+
handleError
|
|
2520
|
+
} = handleError_1;
|
|
2433
2521
|
|
|
2434
2522
|
const getLatestVersion = npmName => {
|
|
2435
2523
|
const data = shelljs$2.exec(`npm view ${npmName} version`);
|
|
2436
2524
|
return data.stdout || '0.0.0';
|
|
2437
2525
|
};
|
|
2438
|
-
/**
|
|
2439
|
-
* 检查package.json的依赖大于node_module的版本,则返回true
|
|
2440
|
-
* @param {*} modules 模块
|
|
2441
|
-
* @param {*} cwd 待检查package.json所在的目录 (eg: 当前执行脚本的目录)
|
|
2442
|
-
* @param {*} outputDir 待检查node_modules存放的目录 (eg: dist/node_modules)
|
|
2443
|
-
* @returns
|
|
2526
|
+
/**
|
|
2527
|
+
* 检查package.json的依赖大于node_module的版本,则返回true
|
|
2528
|
+
* @param {*} modules 模块
|
|
2529
|
+
* @param {*} cwd 待检查package.json所在的目录 (eg: 当前执行脚本的目录)
|
|
2530
|
+
* @param {*} outputDir 待检查node_modules存放的目录 (eg: dist/node_modules)
|
|
2531
|
+
* @returns
|
|
2444
2532
|
*/
|
|
2445
2533
|
|
|
2446
2534
|
|
|
2447
|
-
const checkDependencies$1 = (modules, cwd, outputDir) => {
|
|
2535
|
+
const checkDependencies$1 = (modules, cwd, outputDir, isDev) => {
|
|
2448
2536
|
// 步骤1. 收集package.json
|
|
2449
2537
|
const packageJsonName = 'package.json'; // 查找文件名
|
|
2450
2538
|
// 1.1根目录的package.json
|
|
@@ -2467,13 +2555,13 @@ const checkDependencies$1 = (modules, cwd, outputDir) => {
|
|
|
2467
2555
|
|
|
2468
2556
|
for (const item of packageArr) {
|
|
2469
2557
|
const packageJson = fs$1.readFileSync(item.srcPackageDir, 'utf-8');
|
|
2470
|
-
let dependencies;
|
|
2558
|
+
let dependencies = {};
|
|
2471
2559
|
|
|
2472
2560
|
try {
|
|
2473
|
-
|
|
2561
|
+
const json = JSON.parse(packageJson);
|
|
2562
|
+
dependencies = json !== null && json !== void 0 && json.dependencies ? json === null || json === void 0 ? void 0 : json.dependencies : {};
|
|
2474
2563
|
} catch (e) {
|
|
2475
|
-
|
|
2476
|
-
process.exit(1);
|
|
2564
|
+
handleError(`解析${item.srcPackageDir}报错,请检查是否是正确的json配置项`, isDev);
|
|
2477
2565
|
}
|
|
2478
2566
|
|
|
2479
2567
|
const dependenciesKeys = Object.keys(dependencies);
|
|
@@ -2519,10 +2607,10 @@ const {
|
|
|
2519
2607
|
} = widgets;
|
|
2520
2608
|
const init$4 = init_1;
|
|
2521
2609
|
const {
|
|
2522
|
-
|
|
2610
|
+
MODULE_CONFIG_FILENAME
|
|
2523
2611
|
} = require$$3;
|
|
2524
2612
|
const {
|
|
2525
|
-
tmsModulesMergeLocalModuleCfg
|
|
2613
|
+
tmsModulesMergeLocalModuleCfg: tmsModulesMergeLocalModuleCfg$1
|
|
2526
2614
|
} = tkitUtils;
|
|
2527
2615
|
const {
|
|
2528
2616
|
checkDependencies
|
|
@@ -2530,8 +2618,9 @@ const {
|
|
|
2530
2618
|
const {
|
|
2531
2619
|
fail
|
|
2532
2620
|
} = log$2;
|
|
2621
|
+
const shelljs$1 = require$$4__default; // const io = require('../../../utils/io');
|
|
2533
2622
|
|
|
2534
|
-
function isInit(tmsConfig, targetModules, contextDir) {
|
|
2623
|
+
function isInit(tmsConfig, targetModules, contextDir, isDev) {
|
|
2535
2624
|
// 判断是否存在dist目录
|
|
2536
2625
|
if (!fs.existsSync(contextDir)) {
|
|
2537
2626
|
return true;
|
|
@@ -2557,10 +2646,10 @@ function isInit(tmsConfig, targetModules, contextDir) {
|
|
|
2557
2646
|
// 此模块没有root字段(原因:没有merge到module.config.json的配置项。第三方模块的代码可能还没有下载)
|
|
2558
2647
|
if (!item.root) {
|
|
2559
2648
|
return true;
|
|
2560
|
-
} //
|
|
2649
|
+
} // 判断dist目录是否有该模块
|
|
2561
2650
|
|
|
2562
2651
|
|
|
2563
|
-
if (!fs.existsSync(`${contextDir}/${item.root}`)) {
|
|
2652
|
+
if (!fs.existsSync(`${contextDir}/${item.root}/${MODULE_CONFIG_FILENAME}`)) {
|
|
2564
2653
|
return true;
|
|
2565
2654
|
} // 判断源码目录是否有该模块
|
|
2566
2655
|
|
|
@@ -2572,34 +2661,48 @@ function isInit(tmsConfig, targetModules, contextDir) {
|
|
|
2572
2661
|
} // 判断package.json的版本是否有新的版本
|
|
2573
2662
|
|
|
2574
2663
|
|
|
2575
|
-
return checkDependencies(targetModules, resolve$1('./'), tmsConfig.outputDir);
|
|
2664
|
+
return checkDependencies(targetModules, resolve$1('./'), tmsConfig.outputDir, isDev);
|
|
2665
|
+
} // 用户编译分包时,需要将dist中其他分包(主包不能删除)的内容删除,否则其他分包的内容混入到主包(导致主包的体积超2M)
|
|
2666
|
+
|
|
2667
|
+
|
|
2668
|
+
function delOtherModule(tmsConfig, targetModules) {
|
|
2669
|
+
const modules = tmsModulesMergeLocalModuleCfg$1(tmsConfig.modules, tmsConfig.appName);
|
|
2670
|
+
const targetModulesName = targetModules.map(item => item.name);
|
|
2671
|
+
modules.forEach(item => {
|
|
2672
|
+
if (item.root && targetModulesName.indexOf(item.name) === -1) {
|
|
2673
|
+
const moduleRootDir = resolve$1(`dist/${item.root}`);
|
|
2674
|
+
shelljs$1.rm('-rf', `${moduleRootDir}/*`, {
|
|
2675
|
+
silent: true
|
|
2676
|
+
}); // 解决微信开发者工具(dist/app.json: ["subpackages"][0]["root"] 字段需为 目录)错误 - 提前创建该目录
|
|
2677
|
+
// io.ensureDirExist(moduleRootDir);
|
|
2678
|
+
}
|
|
2679
|
+
});
|
|
2576
2680
|
}
|
|
2577
2681
|
|
|
2578
2682
|
async function dev$2(tmsConfig, targetModules, env) {
|
|
2579
|
-
|
|
2580
|
-
|
|
2683
|
+
let newModules = targetModules;
|
|
2684
|
+
const isDev = true; // 判断是否进行init命令
|
|
2581
2685
|
|
|
2582
|
-
if (isInit(tmsConfig,
|
|
2583
|
-
// init
|
|
2584
|
-
const initData = await init$4(tmsConfig,
|
|
2686
|
+
if (isInit(tmsConfig, targetModules, resolve$1('dist'), isDev)) {
|
|
2687
|
+
// init函数 下载第三方代码后,会将最新的tms.config.js的modules 合并 module.config.json的配置项返回
|
|
2688
|
+
const initData = await init$4(tmsConfig, newModules, isDev);
|
|
2585
2689
|
newModules = initData.targetModules;
|
|
2586
2690
|
}
|
|
2587
2691
|
|
|
2588
|
-
console.log('当前dev启动的有效模块', newModules.map(item => item.name));
|
|
2692
|
+
console.log('当前dev启动的有效模块', newModules.map(item => item.name).sort());
|
|
2693
|
+
delOtherModule(tmsConfig, newModules);
|
|
2589
2694
|
gulpDev(tmsConfig, newModules, env);
|
|
2590
2695
|
}
|
|
2591
2696
|
|
|
2592
2697
|
var dev_1 = dev$2;
|
|
2593
2698
|
|
|
2594
|
-
const shelljs$1 = require$$5__default;
|
|
2595
2699
|
const dev$1 = dev$3.exports;
|
|
2596
2700
|
|
|
2597
2701
|
var build$2 = async (tmsConfig, newModules) => {
|
|
2598
|
-
shelljs$1.rm('-rf', tmsConfig.outputDir);
|
|
2599
2702
|
dev$1(tmsConfig, newModules, false);
|
|
2600
2703
|
};
|
|
2601
2704
|
|
|
2602
|
-
const shelljs = require$$
|
|
2705
|
+
const shelljs = require$$4__default;
|
|
2603
2706
|
const {
|
|
2604
2707
|
resolve
|
|
2605
2708
|
} = widgets;
|
|
@@ -2609,9 +2712,10 @@ const gulpBuild = build$2;
|
|
|
2609
2712
|
async function build$1(tmsConfig, targetModules, env) {
|
|
2610
2713
|
// 开始构建前,清理输出目录
|
|
2611
2714
|
await shelljs.rm('-rf', resolve(tmsConfig.outputDir));
|
|
2715
|
+
const isDev = false;
|
|
2612
2716
|
const {
|
|
2613
2717
|
targetModules: newModules
|
|
2614
|
-
} = await init$3(tmsConfig, targetModules);
|
|
2718
|
+
} = await init$3(tmsConfig, targetModules, isDev);
|
|
2615
2719
|
gulpBuild(tmsConfig, newModules, env);
|
|
2616
2720
|
}
|
|
2617
2721
|
|
|
@@ -2629,23 +2733,27 @@ const {
|
|
|
2629
2733
|
} = require$$3;
|
|
2630
2734
|
const {
|
|
2631
2735
|
readTmsConfig,
|
|
2736
|
+
readTmsPrivateCf,
|
|
2632
2737
|
checkModules
|
|
2633
2738
|
} = tkitUtils;
|
|
2739
|
+
const {
|
|
2740
|
+
tmsModulesMergeLocalModuleCfg,
|
|
2741
|
+
subModulesMergeDepModules
|
|
2742
|
+
} = tkitUtils;
|
|
2634
2743
|
|
|
2635
|
-
const handleModulesArg = cmd => {
|
|
2636
|
-
//
|
|
2637
|
-
if (cmd.module === MODE.main) {
|
|
2638
|
-
return MODE.main;
|
|
2639
|
-
} // 单模块 或 多模块开发
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
const {
|
|
2643
|
-
argv
|
|
2644
|
-
} = process;
|
|
2645
|
-
const reset = argv.indexOf('-m') > -1 ? argv.slice(argv.indexOf('-m') + 1) : [];
|
|
2646
|
-
|
|
2744
|
+
const handleModulesArg = (cmd, tmsPrivateCg) => {
|
|
2745
|
+
// 单模块或多模块开发-用户通过脚手架参数指定的模块
|
|
2647
2746
|
if (cmd.module) {
|
|
2747
|
+
const {
|
|
2748
|
+
argv
|
|
2749
|
+
} = process;
|
|
2750
|
+
const reset = argv.indexOf('-m') > -1 ? argv.slice(argv.indexOf('-m') + 1) : [];
|
|
2648
2751
|
return [cmd.module, ...reset];
|
|
2752
|
+
} // 单模块或多模块开发-用户在tms.private.js指定的模块
|
|
2753
|
+
|
|
2754
|
+
|
|
2755
|
+
if (tmsPrivateCg !== null && tmsPrivateCg !== void 0 && tmsPrivateCg.modules && (tmsPrivateCg === null || tmsPrivateCg === void 0 ? void 0 : tmsPrivateCg.modules.length) > 0) {
|
|
2756
|
+
return tmsPrivateCg === null || tmsPrivateCg === void 0 ? void 0 : tmsPrivateCg.modules;
|
|
2649
2757
|
} // 全量模块
|
|
2650
2758
|
|
|
2651
2759
|
|
|
@@ -2653,38 +2761,44 @@ const handleModulesArg = cmd => {
|
|
|
2653
2761
|
};
|
|
2654
2762
|
|
|
2655
2763
|
async function run(commandName, cmd) {
|
|
2656
|
-
|
|
2764
|
+
// 用户本地的私有项目配置(用来配置环境\模块信息\账号信息)
|
|
2765
|
+
const tmsPrivateCg = readTmsPrivateCf(); // 处理module参数
|
|
2766
|
+
|
|
2767
|
+
const moduleArg = handleModulesArg(cmd, tmsPrivateCg);
|
|
2657
2768
|
const {
|
|
2658
|
-
env
|
|
2769
|
+
env = tmsPrivateCg === null || tmsPrivateCg === void 0 ? void 0 : tmsPrivateCg.env
|
|
2659
2770
|
} = cmd;
|
|
2660
2771
|
const tmsConfig = await createTask(readTmsConfig, '开始读取脚手架的配置项', '读取脚手架的配置项完成')(env);
|
|
2661
|
-
let modules;
|
|
2772
|
+
let modules;
|
|
2662
2773
|
|
|
2663
|
-
if (moduleArg === MODE.
|
|
2664
|
-
modules = checkModules(tmsConfig, [...new Set([...tmsConfig.mainPackages])]);
|
|
2665
|
-
} else if (moduleArg === MODE.all) {
|
|
2774
|
+
if (moduleArg === MODE.all) {
|
|
2666
2775
|
// 全量模块
|
|
2667
2776
|
modules = tmsConfig.modules;
|
|
2668
2777
|
} else {
|
|
2669
2778
|
// 检查用户输入modules的有效性
|
|
2670
2779
|
modules = checkModules(tmsConfig, [...new Set([...tmsConfig.mainPackages, ...moduleArg])]);
|
|
2671
|
-
}
|
|
2780
|
+
} // tms.config.js的modules 合并 module.config.json的配置项
|
|
2781
|
+
|
|
2782
|
+
|
|
2783
|
+
let newModules = tmsModulesMergeLocalModuleCfg(modules, tmsConfig.appName); // A分包依赖了B分包的代码, merge B分包进行编译;
|
|
2784
|
+
|
|
2785
|
+
newModules = subModulesMergeDepModules(tmsConfig, newModules);
|
|
2672
2786
|
|
|
2673
2787
|
switch (commandName) {
|
|
2674
2788
|
case 'init':
|
|
2675
|
-
init$2(tmsConfig,
|
|
2789
|
+
init$2(tmsConfig, newModules, env);
|
|
2676
2790
|
return;
|
|
2677
2791
|
|
|
2678
2792
|
case 'dev':
|
|
2679
|
-
dev(tmsConfig,
|
|
2793
|
+
dev(tmsConfig, newModules, env);
|
|
2680
2794
|
return;
|
|
2681
2795
|
|
|
2682
2796
|
case 'install':
|
|
2683
|
-
install(tmsConfig,
|
|
2797
|
+
install(tmsConfig, newModules, env);
|
|
2684
2798
|
return;
|
|
2685
2799
|
|
|
2686
2800
|
case 'build':
|
|
2687
|
-
build(tmsConfig,
|
|
2801
|
+
build(tmsConfig, newModules, env);
|
|
2688
2802
|
return;
|
|
2689
2803
|
|
|
2690
2804
|
default:
|
|
@@ -2737,7 +2851,7 @@ var entry = [{
|
|
|
2737
2851
|
|
|
2738
2852
|
var require$$6 = {
|
|
2739
2853
|
name: "@tmsfe/tmskit",
|
|
2740
|
-
version: "0.0.
|
|
2854
|
+
version: "0.0.7",
|
|
2741
2855
|
description: "tmskit",
|
|
2742
2856
|
main: "main.js",
|
|
2743
2857
|
bin: {
|
|
@@ -2778,6 +2892,7 @@ var require$$6 = {
|
|
|
2778
2892
|
"copy-webpack-plugin": "^9.1.0",
|
|
2779
2893
|
"download-git-repo": "^3.0.2",
|
|
2780
2894
|
ejs: "^3.1.5",
|
|
2895
|
+
"fs-extra": "^10.0.1",
|
|
2781
2896
|
"glob-ignore": "^1.0.2",
|
|
2782
2897
|
gulp: "^4.0.2",
|
|
2783
2898
|
"gulp-cache": "^1.1.3",
|
|
@@ -2818,11 +2933,11 @@ const {
|
|
|
2818
2933
|
} = widgets;
|
|
2819
2934
|
const requiredVersion = packageJson.engines.node;
|
|
2820
2935
|
const packName = packageJson.name;
|
|
2821
|
-
/**
|
|
2822
|
-
* 检查node版本
|
|
2823
|
-
* @param {String} wanted 希望的node版本
|
|
2824
|
-
* @param {String} id 某node特性
|
|
2825
|
-
* @returns {Undefined} 无需返回值
|
|
2936
|
+
/**
|
|
2937
|
+
* 检查node版本
|
|
2938
|
+
* @param {String} wanted 希望的node版本
|
|
2939
|
+
* @param {String} id 某node特性
|
|
2940
|
+
* @returns {Undefined} 无需返回值
|
|
2826
2941
|
*/
|
|
2827
2942
|
|
|
2828
2943
|
const checkNodeVersion = (wanted, id) => {
|
|
@@ -2833,9 +2948,9 @@ const checkNodeVersion = (wanted, id) => {
|
|
|
2833
2948
|
process.exit(1);
|
|
2834
2949
|
}
|
|
2835
2950
|
};
|
|
2836
|
-
/**
|
|
2837
|
-
* 检查运行环境
|
|
2838
|
-
* @returns {Undefined} 无需返回值
|
|
2951
|
+
/**
|
|
2952
|
+
* 检查运行环境
|
|
2953
|
+
* @returns {Undefined} 无需返回值
|
|
2839
2954
|
*/
|
|
2840
2955
|
|
|
2841
2956
|
|