@tmsfe/tmskit 0.0.39 → 0.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -120,13 +120,13 @@ const succeed$2 = (message = '') => {
120
120
  const warn$2 = message => {
121
121
  console.log(`${moment$1().format('YYYY-MM-DD HH:mm:ss')}`, chalk$5.yellow(message));
122
122
  };
123
- const info$k = (...args) => console.log(`${moment$1().format('YYYY-MM-DD HH:mm:ss')}`, ...args);
123
+ const info$j = (...args) => console.log(`${moment$1().format('YYYY-MM-DD HH:mm:ss')}`, ...args);
124
124
  const infoNoTime$1 = (...args) => console.log(...args);
125
125
  var log$1 = {
126
126
  fail: fail$a,
127
127
  succeed: succeed$2,
128
128
  warn: warn$2,
129
- info: info$k,
129
+ info: info$j,
130
130
  infoNoTime: infoNoTime$1
131
131
  };
132
132
 
@@ -136,7 +136,7 @@ const fs$j = require$$0__default$1;
136
136
  const shelljs$7 = require$$0__default$2;
137
137
  const glob = require$$4__default;
138
138
  const {
139
- info: info$j
139
+ info: info$i
140
140
  } = log$1;
141
141
  const shelljsOptions = {
142
142
  slient: true,
@@ -145,7 +145,7 @@ const shelljsOptions = {
145
145
 
146
146
  // 获取当前目录
147
147
  const cwd = process.cwd();
148
- function resolve$k(...args) {
148
+ function resolve$j(...args) {
149
149
  return path$h.resolve(cwd, ...args);
150
150
  }
151
151
 
@@ -274,11 +274,11 @@ const cost = start => Date.now() - start;
274
274
  * @param {String} endText 任务结束后提示语
275
275
  * @returns {Undefined} 无需返回值
276
276
  */
277
- function createTask$7(task, startText, endText) {
277
+ function createTask$6(task, startText, endText) {
278
278
  return async (...args) => {
279
279
  const start = Date.now();
280
280
  const spinner = ora$2();
281
- info$j(startText);
281
+ info$i(startText);
282
282
  spinner.start();
283
283
  const result = await task(...args);
284
284
  endText && spinner.succeed(`${endText}, 耗时${cost(start) / 1000}s`);
@@ -336,7 +336,7 @@ function findFiles(globPath, filter = []) {
336
336
  // 获取绝对路径
337
337
  function getAbsolutePath$6(pathDir, cwd = '') {
338
338
  let newPath = pathDir;
339
- newPath = newPath.startsWith('/') ? newPath : resolve$k(cwd, newPath);
339
+ newPath = newPath.startsWith('/') ? newPath : resolve$j(cwd, newPath);
340
340
  newPath = newPath.endsWith('/') ? newPath.slice(0, newPath.length - 1) : newPath;
341
341
  return newPath;
342
342
  }
@@ -367,10 +367,10 @@ function getGitUser$2() {
367
367
  return res.stdout;
368
368
  }
369
369
  var widgets = {
370
- resolve: resolve$k,
370
+ resolve: resolve$j,
371
371
  isObject,
372
372
  isArray,
373
- createTask: createTask$7,
373
+ createTask: createTask$6,
374
374
  downloadRepoForGit: downloadRepoForGit$1,
375
375
  pullRepoForGit: pullRepoForGit$1,
376
376
  camelize,
@@ -842,7 +842,7 @@ var defaultTmsConfig = {
842
842
  const fs$i = require$$0__default$1;
843
843
  const path$f = require$$1__default$1;
844
844
  const {
845
- info: info$i
845
+ info: info$h
846
846
  } = log$1;
847
847
  const {
848
848
  relativeCwdPath
@@ -892,11 +892,11 @@ function diffContentCopyFile(originFile, destFile) {
892
892
  const depDestContent = fs$i.readFileSync(destFile, 'utf8');
893
893
  const depOriginContent = fs$i.readFileSync(originFile, 'utf8');
894
894
  if (depDestContent !== depOriginContent) {
895
- info$i(`拷贝${relativeCwdPath(originFile)}内容到${relativeCwdPath(destFile)}`);
895
+ info$h(`拷贝${relativeCwdPath(originFile)}内容到${relativeCwdPath(destFile)}`);
896
896
  copyFile(originFile, destFile);
897
897
  }
898
898
  } else {
899
- info$i(`拷贝${relativeCwdPath(originFile)}内容到${relativeCwdPath(destFile)}`);
899
+ info$h(`拷贝${relativeCwdPath(originFile)}内容到${relativeCwdPath(destFile)}`);
900
900
  copyFile(originFile, destFile);
901
901
  }
902
902
  }
@@ -989,7 +989,7 @@ var render_1 = render$1;
989
989
  const fs$h = require$$0__default$1;
990
990
  const inquirer$1 = require$$1__default$5;
991
991
  const {
992
- resolve: resolve$j
992
+ resolve: resolve$i
993
993
  } = widgets;
994
994
  const {
995
995
  TEMPLATE_TKIT_DIR: TEMPLATE_TKIT_DIR$1
@@ -1031,7 +1031,7 @@ const isQuestionType = result => {
1031
1031
  return true;
1032
1032
  };
1033
1033
  const ask$1 = templateDir => (files, metalsmith, next) => {
1034
- const prompts = parseTemplateQuestions(resolve$j(templateDir, TEMPLATE_TKIT_DIR$1));
1034
+ const prompts = parseTemplateQuestions(resolve$i(templateDir, TEMPLATE_TKIT_DIR$1));
1035
1035
  const metadata = metalsmith.metadata();
1036
1036
  const filteredPrompts = prompts.filter(prompt => {
1037
1037
  if (metadata[prompt.name] && `${metadata[prompt.name]}`.trim() !== '') {
@@ -1074,7 +1074,7 @@ const {
1074
1074
  getGitUser: getGitUser$1
1075
1075
  } = widgets;
1076
1076
  const apiUrl = 'https://tim.map.qq.com/basic/tmskit/upload';
1077
- const report$b = (name, attrs = {}) => {
1077
+ const report$a = (name, attrs = {}) => {
1078
1078
  try {
1079
1079
  const param = [];
1080
1080
  param[27] = name;
@@ -1096,7 +1096,7 @@ const report$b = (name, attrs = {}) => {
1096
1096
  // }
1097
1097
  } catch (e) {}
1098
1098
  };
1099
- var report_1 = report$b;
1099
+ var report_1 = report$a;
1100
1100
 
1101
1101
  const path$e = require$$1__default$1;
1102
1102
  const fs$g = require$$0__default$1;
@@ -1110,18 +1110,18 @@ const {
1110
1110
  CREATE_TEMPLATE_QUESTION
1111
1111
  } = constant;
1112
1112
  const {
1113
- resolve: resolve$i
1113
+ resolve: resolve$h
1114
1114
  } = widgets;
1115
1115
  const io$2 = io$3;
1116
1116
  const {
1117
1117
  fail: fail$9,
1118
1118
  succeed: succeed$1,
1119
- info: info$h
1119
+ info: info$g
1120
1120
  } = log$1;
1121
1121
  const generator = generator_1;
1122
1122
  const request = require$$0__default$6;
1123
1123
  const unzip = require$$10__default;
1124
- const report$a = report_1;
1124
+ const report$9 = report_1;
1125
1125
 
1126
1126
  /**
1127
1127
  * 如果该目录下面存在文件,换个名字
@@ -1180,7 +1180,7 @@ async function create(projectName) {
1180
1180
  const {
1181
1181
  projectType
1182
1182
  } = await inquirer.prompt(CREATE_TEMPLATE_QUESTION);
1183
- report$a('create-start', {
1183
+ report$9('create-start', {
1184
1184
  projectType
1185
1185
  });
1186
1186
 
@@ -1201,7 +1201,7 @@ async function create(projectName) {
1201
1201
  // 生成模板(1. 询问问题, 2. ejs生成模板 3.生成到目标目录)
1202
1202
  generator(path$e.join(TEMPLATE_DIR, TEMPLATE_NAME, projectType), targetDir).then(() => {
1203
1203
  shelljs$6.cd(projectName);
1204
- const hookFilePath = resolve$i(projectName, TEMPLATE_TKIT_DIR, 'hooks.js');
1204
+ const hookFilePath = resolve$h(projectName, TEMPLATE_TKIT_DIR, 'hooks.js');
1205
1205
  if (fs$g.existsSync(hookFilePath)) {
1206
1206
  const hooks = require(hookFilePath);
1207
1207
  if (hooks.afterCreate) {
@@ -1215,15 +1215,15 @@ async function create(projectName) {
1215
1215
  }
1216
1216
  });
1217
1217
  }
1218
- shelljs$6.rm('-rf', resolve$i(projectName, TEMPLATE_TKIT_DIR));
1218
+ shelljs$6.rm('-rf', resolve$h(projectName, TEMPLATE_TKIT_DIR));
1219
1219
  }
1220
- report$a('create-success', {
1220
+ report$9('create-success', {
1221
1221
  projectType
1222
1222
  });
1223
1223
  succeed$1('项目创建完成.');
1224
1224
  }).catch(err => {
1225
1225
  fail$9(err.message);
1226
- info$h('详细的错误信息:', err);
1226
+ info$g('详细的错误信息:', err);
1227
1227
  });
1228
1228
  }
1229
1229
  var create_1 = create;
@@ -1238,10 +1238,10 @@ const {
1238
1238
  EXTEND_CMD
1239
1239
  } = constant;
1240
1240
  const {
1241
- createTask: createTask$6
1241
+ createTask: createTask$5
1242
1242
  } = widgets;
1243
1243
  const {
1244
- info: info$g,
1244
+ info: info$f,
1245
1245
  fail: fail$8
1246
1246
  } = log$1;
1247
1247
 
@@ -1260,7 +1260,7 @@ async function installCmd(npmName, cmd) {
1260
1260
  }, null, 2));
1261
1261
  }
1262
1262
  shellJs$3.cd(EXTEND_CMD);
1263
- await createTask$6(npmName => new Promise((resolve, reject) => {
1263
+ await createTask$5(npmName => new Promise((resolve, reject) => {
1264
1264
  const registry = cmd.registry ? `--registry=${cmd.registry}` : '';
1265
1265
  shellJs$3.exec(`npm install --save ${npmName} ${registry}`, {
1266
1266
  cwd: EXTEND_CMD,
@@ -1274,7 +1274,7 @@ async function installCmd(npmName, cmd) {
1274
1274
  }), `开始下载${npmName}`, `下载${npmName}完成`)(npmName);
1275
1275
  } catch (e) {
1276
1276
  fail$8('构建出现错误:');
1277
- info$g(e);
1277
+ info$f(e);
1278
1278
  process.exit(1);
1279
1279
  }
1280
1280
  }
@@ -1336,7 +1336,7 @@ const {
1336
1336
  const {
1337
1337
  global: global$b
1338
1338
  } = global_1;
1339
- function handleError$9(error, isQuit = false) {
1339
+ function handleError$8(error, isQuit = false) {
1340
1340
  const errMsg = typeof error === 'object' ? error.message : error;
1341
1341
  if (isQuit) {
1342
1342
  fail$7(errMsg);
@@ -1351,7 +1351,7 @@ function handleError$9(error, isQuit = false) {
1351
1351
  }
1352
1352
  }
1353
1353
  var handleError_1 = {
1354
- handleError: handleError$9
1354
+ handleError: handleError$8
1355
1355
  };
1356
1356
 
1357
1357
  /**
@@ -1367,19 +1367,19 @@ const {
1367
1367
  } = tmsMpconfig.exports;
1368
1368
  const {
1369
1369
  fail: fail$6,
1370
- info: info$f
1370
+ info: info$e
1371
1371
  } = log$1;
1372
1372
  const {
1373
- resolve: resolve$h,
1373
+ resolve: resolve$g,
1374
1374
  filterField: filterField$7
1375
1375
  } = widgets;
1376
1376
  const {
1377
- handleError: handleError$8
1377
+ handleError: handleError$7
1378
1378
  } = handleError_1;
1379
1379
  const {
1380
1380
  global: global$a
1381
1381
  } = global_1;
1382
- const report$9 = report_1;
1382
+ const report$8 = report_1;
1383
1383
 
1384
1384
  /**
1385
1385
  * 更新appJson里面的主包配置
@@ -1496,7 +1496,7 @@ async function buildOutputAppJson$3(tmsConfig, modules) {
1496
1496
  // 获取所有的分包
1497
1497
  const subPackages = getSubPackages$3(modulesConfig);
1498
1498
  // 获取app.json的配置
1499
- let appJson = getAppJsonContent(resolve$h('./app.json'));
1499
+ let appJson = getAppJsonContent(resolve$g('./app.json'));
1500
1500
 
1501
1501
  // 更新app.json中的subpackages
1502
1502
  appJson.subpackages = subPackages;
@@ -1510,7 +1510,7 @@ async function buildOutputAppJson$3(tmsConfig, modules) {
1510
1510
  // 模板渲染:先将 app.json 转为字符串,然后通过 preprocess 渲染
1511
1511
  const appJsonStr = JSON.stringify(appJson, null, 2);
1512
1512
  const preprocessedStr = pp$1.preprocess(appJsonStr, tmsConfig.templateVars || {}, 'json');
1513
- fs$e.writeFileSync(resolve$h(`${tmsConfig.outputDir}/app.json`), preprocessedStr, 'utf8');
1513
+ fs$e.writeFileSync(resolve$g(`${tmsConfig.outputDir}/app.json`), preprocessedStr, 'utf8');
1514
1514
  appJson = JSON.parse(preprocessedStr);
1515
1515
  if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.updateAppJson) === 'function') {
1516
1516
  var _tmsConfig$hooks2;
@@ -1521,12 +1521,12 @@ async function buildOutputAppJson$3(tmsConfig, modules) {
1521
1521
  appJson,
1522
1522
  isDev: global$a.getData('isDev')
1523
1523
  }));
1524
- report$9('hooks:updateAppJson');
1524
+ report$8('hooks:updateAppJson');
1525
1525
  }
1526
1526
  return appJson;
1527
1527
  } catch (e) {
1528
- handleError$8(`生成app.json出现错误: ${e}`);
1529
- info$f(e);
1528
+ handleError$7(`生成app.json出现错误: ${e}`);
1529
+ info$e(e);
1530
1530
  }
1531
1531
  }
1532
1532
  var buildAppJson = {
@@ -1541,16 +1541,16 @@ const crypto$2 = require$$1__default$6;
1541
1541
  const {
1542
1542
  downloadRepoForGit,
1543
1543
  pullRepoForGit,
1544
- resolve: resolve$g
1544
+ resolve: resolve$f
1545
1545
  } = widgets;
1546
1546
  const {
1547
1547
  fail: fail$5,
1548
- info: info$e
1548
+ info: info$d
1549
1549
  } = log$1;
1550
1550
  const fs$d = require$$0__default$1;
1551
1551
  const shelljs$5 = require$$0__default$2;
1552
1552
  const {
1553
- handleError: handleError$7
1553
+ handleError: handleError$6
1554
1554
  } = handleError_1;
1555
1555
  const {
1556
1556
  global: global$9
@@ -1642,7 +1642,7 @@ async function cloneModules$1(sourceDir, targetDir, modules) {
1642
1642
  }) => fn(...Object.keys(cParams).map(key => cParams[key])));
1643
1643
  return Promise.all(callArr);
1644
1644
  }).catch(e => {
1645
- handleError$7(`下载代码${params.httpRepoUrl}出现错误:${e}`);
1645
+ handleError$6(`下载代码${params.httpRepoUrl}出现错误:${e}`);
1646
1646
  }));
1647
1647
  });
1648
1648
  await Promise.all(arrPromises);
@@ -1686,9 +1686,9 @@ function collectDownLoadTasksMap(sourceDir, targetDir, modules) {
1686
1686
  // 根据gitUrl与branch计算md5
1687
1687
  const md5Key = md5ByGitUrlBranch(gitUrl, branch);
1688
1688
  // git源码临时存在的源目录
1689
- const sourcePath = resolve$g(sourceDir, md5Key);
1689
+ const sourcePath = resolve$f(sourceDir, md5Key);
1690
1690
  // 模块源码要放到目标目录
1691
- const targetPath = resolve$g(targetDir, path);
1691
+ const targetPath = resolve$f(targetDir, path);
1692
1692
  // 从git源码仓库中找到模块源码路径 (一个仓库存在存放多个模块的情况)
1693
1693
  const sourceModulePath = gitPath ? `${sourcePath}/${gitPath}` : sourcePath;
1694
1694
 
@@ -1713,15 +1713,15 @@ function collectDownLoadTasksMap(sourceDir, targetDir, modules) {
1713
1713
  let promiseTask;
1714
1714
  if (fs$d.existsSync(sourcePath) && fs$d.existsSync(`${sourcePath}/.git`)) {
1715
1715
  promiseTask = (gitUrl, sourcePath, branch, httpRepoUrl) => {
1716
- info$e(`git pull:${httpRepoUrl} --branch: ${branch}`);
1716
+ info$d(`git pull:${httpRepoUrl} --branch: ${branch}`);
1717
1717
  return pullRepoForGit(sourcePath, branch).catch(e => {
1718
- info$e(`pull代码失败:${e}, 开始git clone: ${httpRepoUrl}:${branch}`);
1718
+ info$d(`pull代码失败:${e}, 开始git clone: ${httpRepoUrl}:${branch}`);
1719
1719
  return downloadRepoForGit(gitUrl, sourcePath, branch);
1720
1720
  });
1721
1721
  };
1722
1722
  } else {
1723
1723
  promiseTask = (gitUrl, sourcePath, branch, httpRepoUrl) => {
1724
- info$e(`git clone: ${httpRepoUrl}`);
1724
+ info$d(`git clone: ${httpRepoUrl}`);
1725
1725
  return downloadRepoForGit(gitUrl, sourcePath, branch);
1726
1726
  };
1727
1727
  }
@@ -1895,30 +1895,10 @@ const uploadMp = async (params = {}) => {
1895
1895
  onProgressUpdate: () => {}
1896
1896
  });
1897
1897
  };
1898
- const getDevSourceMap = async (params = {}) => {
1899
- const {
1900
- appId,
1901
- projectPath,
1902
- privateKey,
1903
- robot,
1904
- sourceMapSavePath
1905
- } = params;
1906
- const project = await getMpCi({
1907
- appId,
1908
- projectPath,
1909
- privateKey
1910
- });
1911
- return await ci.getDevSourceMap({
1912
- project,
1913
- robot,
1914
- sourceMapSavePath
1915
- });
1916
- };
1917
- var mpCi$3 = {
1898
+ var mpCi$2 = {
1918
1899
  buildMpNpm: buildMpNpm$1,
1919
1900
  previewMp,
1920
- uploadMp,
1921
- getDevSourceMap
1901
+ uploadMp
1922
1902
  };
1923
1903
 
1924
1904
  const fs$c = require$$0__default$1;
@@ -1972,7 +1952,7 @@ const {
1972
1952
  npmInstall: npmInstall$2
1973
1953
  } = widgets;
1974
1954
  const {
1975
- handleError: handleError$6
1955
+ handleError: handleError$5
1976
1956
  } = handleError_1;
1977
1957
  const {
1978
1958
  global: global$8
@@ -2094,7 +2074,7 @@ const npmInstallAll$1 = async (subPackages, contextDir, cacheDir) => {
2094
2074
  }) => fn(...Object.keys(cParams).map(key => cParams[key])));
2095
2075
  return Promise.all(callArr);
2096
2076
  }).catch(e => {
2097
- handleError$6(`npm install ${params.packageJsonPath}出现错误:${e}`, true);
2077
+ handleError$5(`npm install ${params.packageJsonPath}出现错误:${e}`, true);
2098
2078
  }));
2099
2079
  });
2100
2080
  await Promise.all(arrPromises);
@@ -2195,13 +2175,13 @@ var md5 = {
2195
2175
  const fs$9 = require$$0__default$1;
2196
2176
  const semver$1 = require$$1__default$8;
2197
2177
  const {
2198
- resolve: resolve$f,
2178
+ resolve: resolve$e,
2199
2179
  getAbsolutePath: getAbsolutePath$5
2200
2180
  } = widgets;
2201
2181
  const path$9 = require$$1__default$1;
2202
2182
  const shelljs$4 = require$$0__default$2;
2203
2183
  const {
2204
- handleError: handleError$5
2184
+ handleError: handleError$4
2205
2185
  } = handleError_1;
2206
2186
  const getLatestVersion = npmName => {
2207
2187
  const data = shelljs$4.exec(`npm view ${npmName} version`);
@@ -2217,7 +2197,7 @@ function collectPackageJson(subPackages, cwd, outputDir) {
2217
2197
  // 1.1根目录的package.json
2218
2198
  const packageArr = [{
2219
2199
  srcPackageDir: path$9.join(cwd, packageJsonName),
2220
- destNpmDir: resolve$f(outputDir, 'node_modules')
2200
+ destNpmDir: resolve$e(outputDir, 'node_modules')
2221
2201
  }];
2222
2202
  // 1.2模块的package.json
2223
2203
  subPackages.forEach(item => {
@@ -2225,7 +2205,7 @@ function collectPackageJson(subPackages, cwd, outputDir) {
2225
2205
  if (fs$9.existsSync(srcPackageDir)) {
2226
2206
  packageArr.push({
2227
2207
  srcPackageDir,
2228
- destNpmDir: resolve$f(outputDir, item.root, 'node_modules')
2208
+ destNpmDir: resolve$e(outputDir, item.root, 'node_modules')
2229
2209
  });
2230
2210
  }
2231
2211
  });
@@ -2240,7 +2220,7 @@ function readPackageDependencies(srcPackageDir) {
2240
2220
  const json = packageJson ? JSON.parse(packageJson) : {};
2241
2221
  dependencies = (json === null || json === void 0 ? void 0 : json.dependencies) || {};
2242
2222
  } catch (e) {
2243
- handleError$5(`解析${srcPackageDir}报错,请检查是否是正确的json配置项 ${e}`);
2223
+ handleError$4(`解析${srcPackageDir}报错,请检查是否是正确的json配置项 ${e}`);
2244
2224
  }
2245
2225
  return dependencies;
2246
2226
  }
@@ -2296,14 +2276,14 @@ const fs$8 = require$$0__default$1;
2296
2276
  const path$8 = require$$1__default$1;
2297
2277
  const io$1 = io$3;
2298
2278
  const {
2299
- createTask: createTask$5,
2300
- resolve: resolve$e,
2279
+ createTask: createTask$4,
2280
+ resolve: resolve$d,
2301
2281
  getAbsolutePath: getAbsolutePath$4,
2302
2282
  filterField: filterField$6
2303
2283
  } = widgets;
2304
2284
  const {
2305
2285
  buildMpNpm
2306
- } = mpCi$3;
2286
+ } = mpCi$2;
2307
2287
  const {
2308
2288
  global: global$7
2309
2289
  } = global_1;
@@ -2318,7 +2298,7 @@ const {
2318
2298
  npmInstallAll
2319
2299
  } = npm;
2320
2300
  const {
2321
- info: info$d
2301
+ info: info$c
2322
2302
  } = log$1;
2323
2303
  const {
2324
2304
  fileMd5
@@ -2332,41 +2312,41 @@ async function install$3(tmsConfig, subPackages, useCache = true) {
2332
2312
  // 加npm install之前的钩子
2333
2313
  if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforeNpmInstall) === 'function') {
2334
2314
  var _tmsConfig$hooks2;
2335
- info$d('—————— 执行beforeNpmInstall ————');
2315
+ info$c('—————— 执行beforeNpmInstall ————');
2336
2316
  await (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.beforeNpmInstall({
2337
2317
  tmsConfig: filterField$6(tmsConfig, ['gitAccount']),
2338
2318
  cmdOptions: global$7.getData('cmdOptions')
2339
2319
  }));
2340
- info$d('—————— 执行beforeNpmInstall 完成 ————');
2320
+ info$c('—————— 执行beforeNpmInstall 完成 ————');
2341
2321
  }
2342
- const npmInstallRes = await createTask$5(npmInstall$1, '小程序 开始npm install', '小程序npm install 完成')(tmsConfig, subPackages, useCache);
2322
+ const npmInstallRes = await createTask$4(npmInstall$1, '小程序 开始npm install', '小程序npm install 完成')(tmsConfig, subPackages, useCache);
2343
2323
 
2344
2324
  // 如果npm install 没有命中缓存,则说明node_module有更新,此时必须构建miniprogram_npm
2345
2325
  if (!npmInstallRes.isCache) {
2346
2326
  // 构建miniprogram_npm, 不使用缓存
2347
- await createTask$5(mpCiInstall, '开始构建miniprogram_npm', '构建miniprogram_npm 完成')(tmsConfig, subPackages, false);
2327
+ await createTask$4(mpCiInstall, '开始构建miniprogram_npm', '构建miniprogram_npm 完成')(tmsConfig, subPackages, false);
2348
2328
  } else {
2349
2329
  // 构建miniprogram_npm
2350
- await createTask$5(mpCiInstall, '开始构建miniprogram_npm', '构建miniprogram_npm 完成')(tmsConfig, subPackages, useCache);
2330
+ await createTask$4(mpCiInstall, '开始构建miniprogram_npm', '构建miniprogram_npm 完成')(tmsConfig, subPackages, useCache);
2351
2331
  }
2352
2332
  shelljs$3.cd(cwd);
2353
2333
  }
2354
2334
  async function npmInstall$1(tmsConfig, subPackages, useCache) {
2355
2335
  // 如果依赖没有更新和使用缓存数据(则命中缓存)
2356
- if (!isDependenciesUpdate(subPackages, resolve$e('./'), tmsConfig.outputDir) && useCache) {
2357
- info$d('node_modules命中缓存');
2336
+ if (!isDependenciesUpdate(subPackages, resolve$d('./'), tmsConfig.outputDir) && useCache) {
2337
+ info$c('node_modules命中缓存');
2358
2338
  return {
2359
2339
  isCache: true
2360
2340
  };
2361
2341
  }
2362
2342
  // 拷贝模块的package.json到编译输出目录
2363
2343
  subPackages.forEach(item => {
2364
- const outputModuleDir = resolve$e(`${tmsConfig.outputDir}/${item.root}`);
2344
+ const outputModuleDir = resolve$d(`${tmsConfig.outputDir}/${item.root}`);
2365
2345
  io$1.ensureDirExist(outputModuleDir);
2366
2346
  const modulePackagePath = `${getAbsolutePath$4(item.path)}/package.json`;
2367
2347
  if (fs$8.existsSync(modulePackagePath)) shelljs$3.cp('-Rf', modulePackagePath, outputModuleDir);
2368
2348
  });
2369
- await npmInstallAll(subPackages, resolve$e(tmsConfig.outputDir), NODE_MODULES_DIR$1);
2349
+ await npmInstallAll(subPackages, resolve$d(tmsConfig.outputDir), NODE_MODULES_DIR$1);
2370
2350
  return {
2371
2351
  isCache: false
2372
2352
  };
@@ -2375,12 +2355,12 @@ async function npmInstall$1(tmsConfig, subPackages, useCache) {
2375
2355
  // 构建miniprogram_npm
2376
2356
  async function mpCiInstall(tmsConfig, subPackages, useCache) {
2377
2357
  const packageJsonFiles = [];
2378
- const rootPackFile = resolve$e(`${tmsConfig.outputDir}/package.json`);
2358
+ const rootPackFile = resolve$d(`${tmsConfig.outputDir}/package.json`);
2379
2359
  if (fs$8.existsSync(rootPackFile)) {
2380
2360
  packageJsonFiles.push(rootPackFile);
2381
2361
  }
2382
2362
  subPackages.forEach(item => {
2383
- const packageJsonFile = resolve$e(`${tmsConfig.outputDir}/${item.root}/package.json`);
2363
+ const packageJsonFile = resolve$d(`${tmsConfig.outputDir}/${item.root}/package.json`);
2384
2364
  if (fs$8.existsSync(packageJsonFile)) {
2385
2365
  packageJsonFiles.push(packageJsonFile);
2386
2366
  }
@@ -2394,7 +2374,7 @@ async function mpCiInstall(tmsConfig, subPackages, useCache) {
2394
2374
  let flag = true;
2395
2375
  await Promise.all(packageJsonFiles.map(async item => {
2396
2376
  const packageDir = path$8.dirname(item);
2397
- const mpDir = resolve$e(`${packageDir}/miniprogram_npm`);
2377
+ const mpDir = resolve$d(`${packageDir}/miniprogram_npm`);
2398
2378
  const md5Value = await getMNPMd5(packageDir);
2399
2379
  const preCache = getCache(mpDir, 'miniprogram_npm');
2400
2380
  // console.log('miniprogram_npm', preCache, md5Value);
@@ -2406,14 +2386,14 @@ async function mpCiInstall(tmsConfig, subPackages, useCache) {
2406
2386
  isCache = flag;
2407
2387
  }
2408
2388
  if (isCache) {
2409
- info$d('miniprogram_npm命中缓存');
2389
+ info$c('miniprogram_npm命中缓存');
2410
2390
  return;
2411
2391
  }
2412
2392
 
2413
2393
  // 即将构建,在cache中标记开始
2414
2394
  await Promise.all(packageJsonFiles.map(async item => {
2415
2395
  const packageDir = path$8.dirname(item);
2416
- const mpDir = resolve$e(`${packageDir}/miniprogram_npm`);
2396
+ const mpDir = resolve$d(`${packageDir}/miniprogram_npm`);
2417
2397
  setCache(mpDir, 'miniprogram_npm', {
2418
2398
  md5: '',
2419
2399
  status: statusMap.doing
@@ -2421,14 +2401,14 @@ async function mpCiInstall(tmsConfig, subPackages, useCache) {
2421
2401
  }));
2422
2402
  await buildMpNpm({
2423
2403
  appId: tmsConfig.appId,
2424
- projectPath: resolve$e('./'),
2404
+ projectPath: resolve$d('./'),
2425
2405
  privateKey: tmsConfig.privateKey
2426
2406
  });
2427
2407
 
2428
2408
  // 构建成功后,计算md5写入cache
2429
2409
  await Promise.all(packageJsonFiles.map(async item => {
2430
2410
  const packageDir = path$8.dirname(item);
2431
- const mpDir = resolve$e(`${packageDir}/miniprogram_npm`);
2411
+ const mpDir = resolve$d(`${packageDir}/miniprogram_npm`);
2432
2412
  const md5Value = await getMNPMd5(packageDir);
2433
2413
  setCache(mpDir, 'miniprogram_npm', {
2434
2414
  md5: md5Value,
@@ -2462,8 +2442,8 @@ const shelljs$2 = require$$0__default$2;
2462
2442
  const fs$7 = require$$0__default$1;
2463
2443
  const io = io$3;
2464
2444
  const {
2465
- resolve: resolve$d,
2466
- createTask: createTask$4
2445
+ resolve: resolve$c,
2446
+ createTask: createTask$3
2467
2447
  } = widgets;
2468
2448
  const {
2469
2449
  buildOutputAppJson: buildOutputAppJson$2
@@ -2481,7 +2461,7 @@ const {
2481
2461
  } = tmsMpconfig.exports;
2482
2462
  const {
2483
2463
  fail: fail$4,
2484
- info: info$c
2464
+ info: info$b
2485
2465
  } = log$1;
2486
2466
  const install$2 = install_1;
2487
2467
 
@@ -2493,17 +2473,17 @@ const install$2 = install_1;
2493
2473
  * @returns
2494
2474
  */
2495
2475
  const cpFilesToOutput = function (tmsConfig, defaultFiles) {
2496
- const outputDir = resolve$d(tmsConfig.outputDir);
2476
+ const outputDir = resolve$c(tmsConfig.outputDir);
2497
2477
  io.ensureDirExist(outputDir);
2498
2478
  defaultFiles.forEach(item => {
2499
- if (fs$7.existsSync(resolve$d(item))) {
2500
- shelljs$2.cp('-rf', resolve$d(item), resolve$d(tmsConfig.outputDir, item));
2479
+ if (fs$7.existsSync(resolve$c(item))) {
2480
+ shelljs$2.cp('-rf', resolve$c(item), resolve$c(tmsConfig.outputDir, item));
2501
2481
  }
2502
2482
  });
2503
2483
  };
2504
2484
  async function task(tmsConfig, targetModules) {
2505
2485
  // 下载和移动代码
2506
- await createTask$4(cloneModules, '开始下载模块代码', '下载模块代码码完成')(MODULE_CODE_DIR$1, resolve$d('./'), targetModules);
2486
+ await createTask$3(cloneModules, '开始下载模块代码', '下载模块代码码完成')(MODULE_CODE_DIR$1, resolve$c('./'), targetModules);
2507
2487
 
2508
2488
  // 获取所有模块,合并模块依赖的模块
2509
2489
  const newModules = getModulesByMergeDepModules$2(tmsConfig, targetModules, true);
@@ -2511,13 +2491,13 @@ async function task(tmsConfig, targetModules) {
2511
2491
  const newSubPackages = getSubPackages$2(newModules);
2512
2492
 
2513
2493
  // 拷贝相关配置文件到输出目录
2514
- await createTask$4(cpFilesToOutput, '开始拷贝文件到编译输出目录', '拷贝文件到编译输出目录完成')(tmsConfig, DEFAULT_COPY_CONFIG$1);
2494
+ await createTask$3(cpFilesToOutput, '开始拷贝文件到编译输出目录', '拷贝文件到编译输出目录完成')(tmsConfig, DEFAULT_COPY_CONFIG$1);
2515
2495
 
2516
2496
  // install
2517
2497
  await install$2(tmsConfig, newSubPackages, true);
2518
2498
 
2519
2499
  // 动态生成编译后的app.json;
2520
- await createTask$4(buildOutputAppJson$2, '开始生成编译后的app.json', '生成编译后的app.json完成')(tmsConfig, newModules);
2500
+ await createTask$3(buildOutputAppJson$2, '开始生成编译后的app.json', '生成编译后的app.json完成')(tmsConfig, newModules);
2521
2501
  return {
2522
2502
  modules: newModules,
2523
2503
  subPackages: newSubPackages
@@ -2530,7 +2510,7 @@ async function init$3(tmsConfig, targetModules) {
2530
2510
  } catch (error) {
2531
2511
  const errMsg = typeof error === 'object' ? error.message : error;
2532
2512
  fail$4(`初始化流程出现错误: ${errMsg}`);
2533
- info$c('详细的错误信息', error);
2513
+ info$b('详细的错误信息', error);
2534
2514
  process.exit(1);
2535
2515
  }
2536
2516
  }
@@ -2656,15 +2636,15 @@ const minimatch = require$$2__default;
2656
2636
  const gulpif = require$$3__default$1;
2657
2637
  const mpProjectJson = mpProjectJson_1;
2658
2638
  const {
2659
- resolve: resolve$c
2639
+ resolve: resolve$b
2660
2640
  } = widgets;
2661
2641
  const through = require$$0__default$8;
2662
2642
  const {
2663
2643
  fail: fail$3
2664
2644
  } = log$1;
2665
2645
  const getTargetFile$2 = (sourceFile, module, outputDir) => {
2666
- const sourceFileRelativeModule = path$6.relative(resolve$c(module.from), sourceFile);
2667
- const targetFile = resolve$c(outputDir, module.to, sourceFileRelativeModule);
2646
+ const sourceFileRelativeModule = path$6.relative(resolve$b(module.from), sourceFile);
2647
+ const targetFile = resolve$b(outputDir, module.to, sourceFileRelativeModule);
2668
2648
  return targetFile;
2669
2649
  };
2670
2650
  const addPlugins = function (tmsConfig, srcPipe, pluginParams) {
@@ -2874,12 +2854,12 @@ const {
2874
2854
  series: series$2
2875
2855
  } = require$$0__default$9;
2876
2856
  const {
2877
- info: info$b,
2857
+ info: info$a,
2878
2858
  warn: warn$1,
2879
2859
  fail: fail$2
2880
2860
  } = log$1;
2881
2861
  const {
2882
- resolve: resolve$b,
2862
+ resolve: resolve$a,
2883
2863
  filterField: filterField$5
2884
2864
  } = widgets;
2885
2865
  const {
@@ -2888,7 +2868,7 @@ const {
2888
2868
  const {
2889
2869
  checkPackageVersion
2890
2870
  } = checkDependencies;
2891
- const report$8 = report_1;
2871
+ const report$7 = report_1;
2892
2872
  const TIP_MAP = {
2893
2873
  'package.json': {
2894
2874
  tip: '依赖版本有变动,请重新执行tmskit run dev',
@@ -2915,14 +2895,14 @@ const logTip = (fileName, sourceFile, targetFile, tipMap) => {
2915
2895
  return;
2916
2896
  }
2917
2897
  }
2918
- info$b(`${fileName}有更新`);
2898
+ info$a(`${fileName}有更新`);
2919
2899
  } catch (e) {
2920
2900
  fail$2(`${sourceFile}文件更新提示出现错误: ${e.message}`);
2921
2901
  }
2922
2902
  };
2923
2903
  const getTargetFile$1 = (sourceFile, module, outputDir) => {
2924
- const sourceFileRelativeModule = path$4.relative(resolve$b(module.from), sourceFile);
2925
- return resolve$b(outputDir, module.to, sourceFileRelativeModule);
2904
+ const sourceFileRelativeModule = path$4.relative(resolve$a(module.from), sourceFile);
2905
+ return resolve$a(outputDir, module.to, sourceFileRelativeModule);
2926
2906
  };
2927
2907
  var watch_1 = function (globValue, watchOptions, callback, module) {
2928
2908
  watch$2(globValue, {
@@ -2939,7 +2919,7 @@ var watch_1 = function (globValue, watchOptions, callback, module) {
2939
2919
  targetFile = path$4.join(module.to, filePath);
2940
2920
  }
2941
2921
  if (vinyl.event === 'unlink' || vinyl.event === 'unlinkDir') {
2942
- info$b(`删除${sourceFileName}`);
2922
+ info$a(`删除${sourceFileName}`);
2943
2923
  shellJs$2.rm('-rf', targetFile);
2944
2924
  updateFileHook(tmsConfig, sourceFile, targetFile, vinyl.event);
2945
2925
  return;
@@ -2988,7 +2968,7 @@ async function updateFileHook(tmsConfig, sourceFile, targetFile, type) {
2988
2968
  targetFile,
2989
2969
  type
2990
2970
  });
2991
- report$8('hooks:updateFile');
2971
+ report$7('hooks:updateFile');
2992
2972
  }
2993
2973
  }
2994
2974
 
@@ -3001,7 +2981,7 @@ const {
3001
2981
  series: series$1
3002
2982
  } = require$$0__default$9;
3003
2983
  const {
3004
- resolve: resolve$a,
2984
+ resolve: resolve$9,
3005
2985
  mergeMap,
3006
2986
  filterField: filterField$4,
3007
2987
  getAbsolutePath: getAbsolutePath$3
@@ -3015,9 +2995,9 @@ const {
3015
2995
  const compile = compile$1;
3016
2996
  const watch$1 = watch_1;
3017
2997
  const {
3018
- info: info$a
2998
+ info: info$9
3019
2999
  } = log$1;
3020
- const report$7 = report_1;
3000
+ const report$6 = report_1;
3021
3001
  const {
3022
3002
  global: global$5
3023
3003
  } = global_1;
@@ -3027,12 +3007,12 @@ var dev$4 = async (tmsConfig, modules, isDev = true) => {
3027
3007
 
3028
3008
  // 监听根目录的文件
3029
3009
  mergeMap(compileTasksMap, compile(tmsConfig, {
3030
- glob: DEFAULT_COPY_CONFIG.map(item => resolve$a(item)),
3010
+ glob: DEFAULT_COPY_CONFIG.map(item => resolve$9(item)),
3031
3011
  module: {
3032
- from: resolve$a(),
3033
- to: resolve$a(tmsConfig.outputDir)
3012
+ from: resolve$9(),
3013
+ to: resolve$9(tmsConfig.outputDir)
3034
3014
  },
3035
- destPath: resolve$a(tmsConfig.outputDir),
3015
+ destPath: resolve$9(tmsConfig.outputDir),
3036
3016
  srcOption: {
3037
3017
  allowEmpty: true
3038
3018
  },
@@ -3068,7 +3048,7 @@ var dev$4 = async (tmsConfig, modules, isDev = true) => {
3068
3048
  ...moduleItem
3069
3049
  };
3070
3050
  const srcModulePath = getAbsolutePath$3(moduleItem.path);
3071
- const buildModulePath = resolve$a(tmsConfig.outputDir, moduleItem.modulePath);
3051
+ const buildModulePath = resolve$9(tmsConfig.outputDir, moduleItem.modulePath);
3072
3052
  if (isDev) {
3073
3053
  // 监听模块配置文件
3074
3054
  watch$1([`${srcModulePath}/**/module.config.json`], {
@@ -3082,9 +3062,9 @@ var dev$4 = async (tmsConfig, modules, isDev = true) => {
3082
3062
  const newPath = getAbsolutePath$3(ePath, srcModulePath);
3083
3063
  const ext = path$3.extname(ePath).slice(1);
3084
3064
  if (ext) {
3085
- return `!${resolve$a(srcModulePath, newPath)}`;
3065
+ return `!${resolve$9(srcModulePath, newPath)}`;
3086
3066
  }
3087
- return `!${resolve$a(srcModulePath, newPath)}/**/*`;
3067
+ return `!${resolve$9(srcModulePath, newPath)}/**/*`;
3088
3068
  });
3089
3069
  const moduleConfigPath = `${srcModulePath}/**/module.config.json`;
3090
3070
  const moduleConfigGlob = tmsConfig.isKeepModuleConfig ? `${moduleConfigPath}` : `!${moduleConfigPath}`;
@@ -3133,7 +3113,7 @@ var dev$4 = async (tmsConfig, modules, isDev = true) => {
3133
3113
  let eTime;
3134
3114
  const spinner = ora$1();
3135
3115
  function start(cb) {
3136
- info$a('启动编译...');
3116
+ info$9('启动编译...');
3137
3117
  spinner.start();
3138
3118
  sTime = new Date().getTime();
3139
3119
  cb();
@@ -3142,12 +3122,12 @@ var dev$4 = async (tmsConfig, modules, isDev = true) => {
3142
3122
  var _tmsConfig$hooks;
3143
3123
  if (isDev) {
3144
3124
  // 监听app.json
3145
- watch$1([resolve$a('app.json')], {
3125
+ watch$1([resolve$9('app.json')], {
3146
3126
  ignoreInitial: false,
3147
3127
  events: watchEvents
3148
3128
  }, async () => await buildOutputAppJson$1(tmsConfig, modules, isDev), {
3149
- from: resolve$a(),
3150
- to: resolve$a(tmsConfig.outputDir)
3129
+ from: resolve$9(),
3130
+ to: resolve$9(tmsConfig.outputDir)
3151
3131
  });
3152
3132
  // 监听其他文件
3153
3133
  compileTasksMap.forEach(({
@@ -3171,7 +3151,7 @@ var dev$4 = async (tmsConfig, modules, isDev = true) => {
3171
3151
  modules,
3172
3152
  cmdOptions: global$5.getData('cmdOptions')
3173
3153
  }));
3174
- report$7('hooks:afterCompile');
3154
+ report$6('hooks:afterCompile');
3175
3155
  }
3176
3156
  spinner.succeed(chalk$3.green(`首次编译完成, 耗时${eTime / 1000}s, 微信开发者工具打开项目即可预览。`));
3177
3157
  spinner.stop();
@@ -3190,7 +3170,7 @@ var dev$4 = async (tmsConfig, modules, isDev = true) => {
3190
3170
  const shelljs$1 = require$$0__default$2;
3191
3171
  const compileDev = dev$4;
3192
3172
  const {
3193
- resolve: resolve$9,
3173
+ resolve: resolve$8,
3194
3174
  filterField: filterField$3
3195
3175
  } = widgets;
3196
3176
  const init$2 = init_1;
@@ -3202,7 +3182,7 @@ const {
3202
3182
  getSubPackages: getSubPackages$1
3203
3183
  } = tmsMpconfig.exports;
3204
3184
  const {
3205
- info: info$9
3185
+ info: info$8
3206
3186
  } = log$1;
3207
3187
  const {
3208
3188
  global: global$4
@@ -3211,7 +3191,7 @@ const {
3211
3191
  MODULE_CODE_DIR,
3212
3192
  NODE_MODULES_DIR
3213
3193
  } = constant;
3214
- const report$6 = report_1;
3194
+ const report$5 = report_1;
3215
3195
  // const { recommendVersion } = require('../../../core/recommendVersion');
3216
3196
 
3217
3197
  // 用户编译分包时,需要将dist中其他分包(主包不能删除)的内容删除,否则其他分包的内容混入到主包(导致主包的体积超2M)
@@ -3223,7 +3203,7 @@ function delOtherPackages(tmsConfig, targetSubPackages) {
3223
3203
  const targetSubPackagesName = targetSubPackages.map(item => item.name);
3224
3204
  allSubPackages.forEach(item => {
3225
3205
  if (item.root && targetSubPackagesName.indexOf(item.name) === -1) {
3226
- const moduleRootDir = resolve$9(`${tmsConfig.outputDir}/${item.root}`);
3206
+ const moduleRootDir = resolve$8(`${tmsConfig.outputDir}/${item.root}`);
3227
3207
  shelljs$1.rm('-rf', `${moduleRootDir}/*`, {
3228
3208
  silent: true
3229
3209
  });
@@ -3238,7 +3218,7 @@ async function dev$3(tmsConfig, targetModules) {
3238
3218
  noCache
3239
3219
  } = global$4.getData('cmdOptions');
3240
3220
  if (noCache) {
3241
- shelljs$1.rm('-rf', resolve$9(tmsConfig.outputDir));
3221
+ shelljs$1.rm('-rf', resolve$8(tmsConfig.outputDir));
3242
3222
  shelljs$1.rm('-rf', MODULE_CODE_DIR);
3243
3223
  shelljs$1.rm('-rf', NODE_MODULES_DIR);
3244
3224
  }
@@ -3253,7 +3233,7 @@ async function dev$3(tmsConfig, targetModules) {
3253
3233
 
3254
3234
  // 在启动开发环境前主动执行生成 app.json
3255
3235
  await buildOutputAppJson(tmsConfig, newModules);
3256
- info$9('当前dev启动的有效模块', newModules.map(item => item.moduleName).sort());
3236
+ info$8('当前dev启动的有效模块', newModules.map(item => item.moduleName).sort());
3257
3237
  if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforeFirstCompile) === 'function') {
3258
3238
  var _tmsConfig$hooks2;
3259
3239
  await (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.beforeFirstCompile({
@@ -3262,7 +3242,7 @@ async function dev$3(tmsConfig, targetModules) {
3262
3242
  modules: newModules,
3263
3243
  cmdOptions: global$4.getData('cmdOptions')
3264
3244
  }));
3265
- report$6('hooks:beforeCompile');
3245
+ report$5('hooks:beforeCompile');
3266
3246
  }
3267
3247
  delOtherPackages(tmsConfig, subPackages);
3268
3248
  compileDev(tmsConfig, newModules, true);
@@ -3276,26 +3256,26 @@ var build$2 = async (tmsConfig, newModules, isDev) => {
3276
3256
 
3277
3257
  const shelljs = require$$0__default$2;
3278
3258
  const {
3279
- resolve: resolve$8,
3259
+ resolve: resolve$7,
3280
3260
  filterField: filterField$2
3281
3261
  } = widgets;
3282
3262
  const init$1 = init_1;
3283
3263
  const {
3284
- info: info$8
3264
+ info: info$7
3285
3265
  } = log$1;
3286
3266
  const compileBuild = build$2;
3287
- const report$5 = report_1;
3267
+ const report$4 = report_1;
3288
3268
  const {
3289
3269
  global: global$3
3290
3270
  } = global_1;
3291
3271
  async function build$1(tmsConfig, targetModules) {
3292
3272
  var _tmsConfig$hooks;
3293
3273
  // 开始构建前,清理输出目录
3294
- await shelljs.rm('-rf', resolve$8(tmsConfig.outputDir));
3274
+ await shelljs.rm('-rf', resolve$7(tmsConfig.outputDir));
3295
3275
  const {
3296
3276
  modules: newModules
3297
3277
  } = await init$1(tmsConfig, targetModules);
3298
- info$8('当前build有效模块', newModules.map(item => item.moduleName).sort());
3278
+ info$7('当前build有效模块', newModules.map(item => item.moduleName).sort());
3299
3279
  const isDev = false;
3300
3280
  if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforeFirstCompile) === 'function') {
3301
3281
  var _tmsConfig$hooks2;
@@ -3305,7 +3285,7 @@ async function build$1(tmsConfig, targetModules) {
3305
3285
  modules: newModules,
3306
3286
  cmdOptions: global$3.getData('cmdOptions')
3307
3287
  }));
3308
- report$5('hooks:beforeCompile');
3288
+ report$4('hooks:beforeCompile');
3309
3289
  }
3310
3290
  compileBuild(tmsConfig, newModules, isDev);
3311
3291
  }
@@ -3331,7 +3311,7 @@ function getAllSize$2(data = {}) {
3331
3311
  }
3332
3312
  return allSize;
3333
3313
  }
3334
- const getDesc$3 = (desc = '') => {
3314
+ const getDesc$2 = (desc = '') => {
3335
3315
  const user = getGitUser();
3336
3316
  const date = moment().format('YYYY-MM-DD HH:mm:ss');
3337
3317
  return `构建描述:${desc}; 构建人: ${user}; 构建时间:${date}`;
@@ -3349,24 +3329,24 @@ const getDetaultVersion = () => {
3349
3329
  };
3350
3330
  var utils = {
3351
3331
  getAllSize: getAllSize$2,
3352
- getDesc: getDesc$3,
3332
+ getDesc: getDesc$2,
3353
3333
  outputInfo: outputInfo$2,
3354
3334
  getDetaultVersion
3355
3335
  };
3356
3336
 
3357
- const mpCi$2 = mpCi$3;
3337
+ const mpCi$1 = mpCi$2;
3358
3338
  const fs$4 = require$$0__default$1;
3359
3339
  const {
3360
- resolve: resolve$7,
3361
- createTask: createTask$3,
3340
+ resolve: resolve$6,
3341
+ createTask: createTask$2,
3362
3342
  getAbsolutePath: getAbsolutePath$1,
3363
3343
  filterField: filterField$1
3364
3344
  } = widgets;
3365
3345
  const {
3366
- handleError: handleError$4
3346
+ handleError: handleError$3
3367
3347
  } = handleError_1;
3368
3348
  const {
3369
- info: info$7
3349
+ info: info$6
3370
3350
  } = log$1;
3371
3351
  const {
3372
3352
  global: global$2
@@ -3374,10 +3354,10 @@ const {
3374
3354
  const {
3375
3355
  getAllSize: getAllSize$1,
3376
3356
  outputInfo: outputInfo$1,
3377
- getDesc: getDesc$2
3357
+ getDesc: getDesc$1
3378
3358
  } = utils;
3379
- const report$4 = report_1;
3380
- const handleParams$2 = (tmsConfig, cmdOptions) => {
3359
+ const report$3 = report_1;
3360
+ const handleParams$1 = (tmsConfig, cmdOptions) => {
3381
3361
  const params = {
3382
3362
  ...(tmsConfig.preview ? tmsConfig.preview : {}),
3383
3363
  ...cmdOptions
@@ -3385,10 +3365,10 @@ const handleParams$2 = (tmsConfig, cmdOptions) => {
3385
3365
  return {
3386
3366
  ...params,
3387
3367
  appId: params.appId || tmsConfig.appId,
3388
- projectPath: resolve$7(tmsConfig.outputDir),
3368
+ projectPath: resolve$6(tmsConfig.outputDir),
3389
3369
  privateKey: params.privateKey || tmsConfig.privateKey,
3390
3370
  robot: params.robot || 30,
3391
- desc: params.desc || getDesc$2(params.desc),
3371
+ desc: params.desc || getDesc$1(params.desc),
3392
3372
  qrcodeOutputDest: getAbsolutePath$1(params.qrcodeOutputDest || '')
3393
3373
  };
3394
3374
  };
@@ -3401,7 +3381,7 @@ const handleParams$2 = (tmsConfig, cmdOptions) => {
3401
3381
  async function preview$1(tmsConfig, cmdOptions) {
3402
3382
  try {
3403
3383
  var _tmsConfig$hooks;
3404
- const params = handleParams$2(tmsConfig, cmdOptions);
3384
+ const params = handleParams$1(tmsConfig, cmdOptions);
3405
3385
  if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforePreview) === 'function') {
3406
3386
  var _tmsConfig$hooks2;
3407
3387
  await (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.beforePreview({
@@ -3409,10 +3389,10 @@ async function preview$1(tmsConfig, cmdOptions) {
3409
3389
  cmdOptions: global$2.getData('cmdOptions'),
3410
3390
  params
3411
3391
  }));
3412
- report$4('hooks:beforePreview');
3392
+ report$3('hooks:beforePreview');
3413
3393
  }
3414
3394
  ;
3415
- const previewRes = await createTask$3(mpCi$2.previewMp, '正在构建预览码', '构建预览码完成')({
3395
+ const previewRes = await createTask$2(mpCi$1.previewMp, '正在构建预览码', '构建预览码完成')({
3416
3396
  ...params
3417
3397
  });
3418
3398
  const allSize = getAllSize$1(previewRes);
@@ -3427,25 +3407,25 @@ async function preview$1(tmsConfig, cmdOptions) {
3427
3407
  ...previewRes
3428
3408
  });
3429
3409
  }
3430
- info$7('预览包大小:', `${allSize}k`);
3410
+ info$6('预览包大小:', `${allSize}k`);
3431
3411
  } catch (e) {
3432
3412
  console.log('详细错误:', e);
3433
- handleError$4(`预览错误: ${e.message}`, true);
3413
+ handleError$3(`预览错误: ${e.message}`, true);
3434
3414
  }
3435
3415
  }
3436
3416
  var preview_1 = preview$1;
3437
3417
 
3438
- const mpCi$1 = mpCi$3;
3418
+ const mpCi = mpCi$2;
3439
3419
  const {
3440
- resolve: resolve$6,
3441
- createTask: createTask$2,
3420
+ resolve: resolve$5,
3421
+ createTask: createTask$1,
3442
3422
  filterField
3443
3423
  } = widgets;
3444
3424
  const {
3445
- handleError: handleError$3
3425
+ handleError: handleError$2
3446
3426
  } = handleError_1;
3447
3427
  const {
3448
- info: info$6
3428
+ info: info$5
3449
3429
  } = log$1;
3450
3430
  const {
3451
3431
  global: global$1
@@ -3453,10 +3433,10 @@ const {
3453
3433
  const {
3454
3434
  getAllSize,
3455
3435
  outputInfo,
3456
- getDesc: getDesc$1
3436
+ getDesc
3457
3437
  } = utils;
3458
- const report$3 = report_1;
3459
- const handleParams$1 = (tmsConfig, cmdOptions) => {
3438
+ const report$2 = report_1;
3439
+ const handleParams = (tmsConfig, cmdOptions) => {
3460
3440
  const params = {
3461
3441
  ...(tmsConfig.upload ? tmsConfig.upload : {}),
3462
3442
  ...cmdOptions
@@ -3467,10 +3447,10 @@ const handleParams$1 = (tmsConfig, cmdOptions) => {
3467
3447
  return {
3468
3448
  ...params,
3469
3449
  appId: params.appId || tmsConfig.appId,
3470
- projectPath: resolve$6(tmsConfig.outputDir),
3450
+ projectPath: resolve$5(tmsConfig.outputDir),
3471
3451
  privateKey: params.privateKey || tmsConfig.privateKey,
3472
3452
  robot: params.robot || 30,
3473
- desc: params.desc || getDesc$1(params.desc)
3453
+ desc: params.desc || getDesc(params.desc)
3474
3454
  };
3475
3455
  };
3476
3456
 
@@ -3482,7 +3462,7 @@ const handleParams$1 = (tmsConfig, cmdOptions) => {
3482
3462
  async function upload$1(tmsConfig, cmdOptions) {
3483
3463
  try {
3484
3464
  var _tmsConfig$hooks;
3485
- const params = handleParams$1(tmsConfig, cmdOptions);
3465
+ const params = handleParams(tmsConfig, cmdOptions);
3486
3466
  if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforeUpload) === 'function') {
3487
3467
  var _tmsConfig$hooks2;
3488
3468
  await (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.beforeUpload({
@@ -3490,10 +3470,10 @@ async function upload$1(tmsConfig, cmdOptions) {
3490
3470
  cmdOptions: global$1.getData('cmdOptions'),
3491
3471
  params
3492
3472
  }));
3493
- report$3('hooks:beforeUpload');
3473
+ report$2('hooks:beforeUpload');
3494
3474
  }
3495
3475
  ;
3496
- const uploadRes = await createTask$2(mpCi$1.uploadMp, '正在上传小程序代码', '上传小程序代码完成')({
3476
+ const uploadRes = await createTask$1(mpCi.uploadMp, '正在上传小程序代码', '上传小程序代码完成')({
3497
3477
  ...params
3498
3478
  });
3499
3479
  const allSize = getAllSize(uploadRes);
@@ -3503,65 +3483,14 @@ async function upload$1(tmsConfig, cmdOptions) {
3503
3483
  ...uploadRes
3504
3484
  });
3505
3485
  }
3506
- info$6(`上传包大小: ${allSize}k; 上传包版本: ${params.version}`);
3486
+ info$5(`上传包大小: ${allSize}k; 上传包版本: ${params.version}`);
3507
3487
  } catch (e) {
3508
3488
  console.log('详细错误:', e);
3509
- handleError$3(`上传错误: ${e.message}`, true);
3489
+ handleError$2(`上传错误: ${e.message}`, true);
3510
3490
  }
3511
3491
  }
3512
3492
  var upload_1 = upload$1;
3513
3493
 
3514
- const mpCi = mpCi$3;
3515
- const {
3516
- resolve: resolve$5,
3517
- createTask: createTask$1
3518
- } = widgets;
3519
- const {
3520
- handleError: handleError$2
3521
- } = handleError_1;
3522
- const {
3523
- info: info$5
3524
- } = log$1;
3525
- const {
3526
- getDesc
3527
- } = utils;
3528
- const report$2 = report_1;
3529
- const handleParams = (tmsConfig, cmdOptions) => {
3530
- const params = {
3531
- ...(tmsConfig.upload ? tmsConfig.upload : {}),
3532
- ...cmdOptions
3533
- };
3534
- return {
3535
- sourceMapSavePath: './sourcemap.zip',
3536
- ...params,
3537
- appId: params.appId || tmsConfig.appId,
3538
- projectPath: resolve$5(tmsConfig.outputDir),
3539
- privateKey: params.privateKey || tmsConfig.privateKey,
3540
- robot: params.robot || 30,
3541
- desc: params.desc || getDesc(params.desc)
3542
- };
3543
- };
3544
-
3545
- /**
3546
- * 获取sourcemap
3547
- * @param {object} tmsConfig
3548
- * @param {object} cmdOptions {version: '2022.28.5', desc: '', robot: 2, infoOutput: './a.txt' }
3549
- */
3550
- async function sourcemap$1(tmsConfig, cmdOptions) {
3551
- try {
3552
- const params = handleParams(tmsConfig, cmdOptions);
3553
- report$2('sourcemap');
3554
- await createTask$1(mpCi.getDevSourceMap, '正在获取小程序代码sourcemap', '获取小程序代码sourcemap完成')({
3555
- ...params
3556
- });
3557
- info$5(`sourcemap文件已保存到${params.sourceMapSavePath}`);
3558
- } catch (e) {
3559
- console.log('详细错误:', e);
3560
- handleError$2(`获取sourcemap错误: ${e.message}`, true);
3561
- }
3562
- }
3563
- var sourcemap_1 = sourcemap$1;
3564
-
3565
3494
  const {
3566
3495
  resolve: resolve$4,
3567
3496
  getAbsolutePath
@@ -3895,7 +3824,6 @@ const build = build_1;
3895
3824
  const install = install_1;
3896
3825
  const preview = preview_1;
3897
3826
  const upload = upload_1;
3898
- const sourcemap = sourcemap_1;
3899
3827
  const cloudLink = link;
3900
3828
  const cloudDev = dev$1;
3901
3829
  const {
@@ -4033,12 +3961,6 @@ function otherCommands(tmsConfig, commandName, cmdOptions) {
4033
3961
  appName: tmsConfig.appName
4034
3962
  });
4035
3963
  return;
4036
- case 'sourcemap':
4037
- sourcemap(tmsConfig);
4038
- report$1('run:sourcemap', {
4039
- appName: tmsConfig.appName
4040
- });
4041
- return;
4042
3964
  default:
4043
3965
  return;
4044
3966
  }
@@ -4098,13 +4020,6 @@ var entry = [{
4098
4020
  action: cmdOptions => {
4099
4021
  run_1('upload', cmdOptions);
4100
4022
  }
4101
- }, {
4102
- command: 'sourcemap',
4103
- description: '获取sourcemap',
4104
- options: [],
4105
- action: cmdOptions => {
4106
- run_1('sourcemap', cmdOptions);
4107
- }
4108
4023
  }, {
4109
4024
  command: 'cloud-dev',
4110
4025
  description: '云函数开发',
@@ -4128,7 +4043,7 @@ var entry = [{
4128
4043
 
4129
4044
  var require$$12 = {
4130
4045
  name: "@tmsfe/tmskit",
4131
- version: "0.0.39",
4046
+ version: "0.0.41",
4132
4047
  description: "tmskit",
4133
4048
  main: "dist/index.cjs",
4134
4049
  bin: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmsfe/tmskit",
3
- "version": "0.0.39",
3
+ "version": "0.0.41",
4
4
  "description": "tmskit",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {
package/src/core/mpCi.js CHANGED
@@ -114,22 +114,8 @@ const uploadMp = async (params = {}) => {
114
114
  });
115
115
  };
116
116
 
117
- const getDevSourceMap = async (params = {}) => {
118
- const { appId, projectPath, privateKey, robot, sourceMapSavePath } = params;
119
- const project = await getMpCi({
120
- appId,
121
- projectPath,
122
- privateKey,
123
- });
124
- return await ci.getDevSourceMap({
125
- project,
126
- robot,
127
- sourceMapSavePath,
128
- });
129
- };
130
117
  module.exports = {
131
118
  buildMpNpm,
132
119
  previewMp,
133
120
  uploadMp,
134
- getDevSourceMap,
135
121
  };
package/src/entry.js CHANGED
@@ -81,15 +81,6 @@ module.exports = [
81
81
  require('./scripts/run/index')('upload', cmdOptions);
82
82
  },
83
83
  },
84
- {
85
- command: 'sourcemap',
86
- description: '获取sourcemap',
87
- options: [
88
- ],
89
- action: (cmdOptions) => {
90
- require('./scripts/run/index')('sourcemap', cmdOptions);
91
- },
92
- },
93
84
  {
94
85
  command: 'cloud-dev',
95
86
  description: '云函数开发',
@@ -5,7 +5,6 @@ const build = require('./build/index');
5
5
  const install = require('./install/index');
6
6
  const preview = require('./preview/index');
7
7
  const upload = require('./upload/index');
8
- const sourcemap = require('./sourcemap/index');
9
8
  const cloudLink = require('./cloud/link');
10
9
  const cloudDev = require('./cloud/dev');
11
10
  const { fail, info } = require('../../utils/log');
@@ -122,10 +121,6 @@ function otherCommands(tmsConfig, commandName, cmdOptions) {
122
121
  upload(tmsConfig, cmdOptions);
123
122
  report('run:upload', { appName: tmsConfig.appName });
124
123
  return;
125
- case 'sourcemap':
126
- sourcemap(tmsConfig);
127
- report('run:sourcemap', { appName: tmsConfig.appName });
128
- return;
129
124
  default:
130
125
  return;
131
126
  }
@@ -1,48 +0,0 @@
1
- const mpCi = require('../../../core/mpCi');
2
- const { resolve, createTask } = require('../../../utils/widgets');
3
- const { handleError } = require('../../../core/handleError');
4
- const { info } = require('../../../utils/log');
5
- const { getDesc } = require('../preview/utils');
6
- const report = require('../../../core/report');
7
-
8
- const handleParams = (tmsConfig, cmdOptions) => {
9
- const params = {
10
- ...(tmsConfig.upload ? tmsConfig.upload : {}),
11
- ...cmdOptions,
12
- };
13
-
14
- return {
15
- sourceMapSavePath: './sourcemap.zip',
16
- ...params,
17
- appId: params.appId || tmsConfig.appId,
18
- projectPath: resolve(tmsConfig.outputDir),
19
- privateKey: params.privateKey || tmsConfig.privateKey,
20
- robot: params.robot || 30,
21
- desc: params.desc || getDesc(params.desc),
22
- };
23
- };
24
-
25
- /**
26
- * 获取sourcemap
27
- * @param {object} tmsConfig
28
- * @param {object} cmdOptions {version: '2022.28.5', desc: '', robot: 2, infoOutput: './a.txt' }
29
- */
30
- async function sourcemap(tmsConfig, cmdOptions) {
31
- try {
32
- const params = handleParams(tmsConfig, cmdOptions);
33
- report('sourcemap');
34
-
35
- await createTask(
36
- mpCi.getDevSourceMap,
37
- '正在获取小程序代码sourcemap',
38
- '获取小程序代码sourcemap完成',
39
- )({
40
- ...params,
41
- });
42
- info(`sourcemap文件已保存到${params.sourceMapSavePath}`);
43
- } catch (e) {
44
- console.log('详细错误:', e);
45
- handleError(`获取sourcemap错误: ${e.message}`, true);
46
- }
47
- }
48
- module.exports = sourcemap;