@tmsfe/tmskit 0.0.38 → 0.0.39

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$j = (...args) => console.log(`${moment$1().format('YYYY-MM-DD HH:mm:ss')}`, ...args);
123
+ const info$k = (...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$j,
129
+ info: info$k,
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$i
139
+ info: info$j
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$j(...args) {
148
+ function resolve$k(...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$6(task, startText, endText) {
277
+ function createTask$7(task, startText, endText) {
278
278
  return async (...args) => {
279
279
  const start = Date.now();
280
280
  const spinner = ora$2();
281
- info$i(startText);
281
+ info$j(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$j(cwd, newPath);
339
+ newPath = newPath.startsWith('/') ? newPath : resolve$k(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$j,
370
+ resolve: resolve$k,
371
371
  isObject,
372
372
  isArray,
373
- createTask: createTask$6,
373
+ createTask: createTask$7,
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$h
845
+ info: info$i
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$h(`拷贝${relativeCwdPath(originFile)}内容到${relativeCwdPath(destFile)}`);
895
+ info$i(`拷贝${relativeCwdPath(originFile)}内容到${relativeCwdPath(destFile)}`);
896
896
  copyFile(originFile, destFile);
897
897
  }
898
898
  } else {
899
- info$h(`拷贝${relativeCwdPath(originFile)}内容到${relativeCwdPath(destFile)}`);
899
+ info$i(`拷贝${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$i
992
+ resolve: resolve$j
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$i(templateDir, TEMPLATE_TKIT_DIR$1));
1034
+ const prompts = parseTemplateQuestions(resolve$j(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$a = (name, attrs = {}) => {
1077
+ const report$b = (name, attrs = {}) => {
1078
1078
  try {
1079
1079
  const param = [];
1080
1080
  param[27] = name;
@@ -1096,7 +1096,7 @@ const report$a = (name, attrs = {}) => {
1096
1096
  // }
1097
1097
  } catch (e) {}
1098
1098
  };
1099
- var report_1 = report$a;
1099
+ var report_1 = report$b;
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$h
1113
+ resolve: resolve$i
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$g
1119
+ info: info$h
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$9 = report_1;
1124
+ const report$a = 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$9('create-start', {
1183
+ report$a('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$h(projectName, TEMPLATE_TKIT_DIR, 'hooks.js');
1204
+ const hookFilePath = resolve$i(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$h(projectName, TEMPLATE_TKIT_DIR));
1218
+ shelljs$6.rm('-rf', resolve$i(projectName, TEMPLATE_TKIT_DIR));
1219
1219
  }
1220
- report$9('create-success', {
1220
+ report$a('create-success', {
1221
1221
  projectType
1222
1222
  });
1223
1223
  succeed$1('项目创建完成.');
1224
1224
  }).catch(err => {
1225
1225
  fail$9(err.message);
1226
- info$g('详细的错误信息:', err);
1226
+ info$h('详细的错误信息:', 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$5
1241
+ createTask: createTask$6
1242
1242
  } = widgets;
1243
1243
  const {
1244
- info: info$f,
1244
+ info: info$g,
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$5(npmName => new Promise((resolve, reject) => {
1263
+ await createTask$6(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$f(e);
1277
+ info$g(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$8(error, isQuit = false) {
1339
+ function handleError$9(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$8(error, isQuit = false) {
1351
1351
  }
1352
1352
  }
1353
1353
  var handleError_1 = {
1354
- handleError: handleError$8
1354
+ handleError: handleError$9
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$e
1370
+ info: info$f
1371
1371
  } = log$1;
1372
1372
  const {
1373
- resolve: resolve$g,
1373
+ resolve: resolve$h,
1374
1374
  filterField: filterField$7
1375
1375
  } = widgets;
1376
1376
  const {
1377
- handleError: handleError$7
1377
+ handleError: handleError$8
1378
1378
  } = handleError_1;
1379
1379
  const {
1380
1380
  global: global$a
1381
1381
  } = global_1;
1382
- const report$8 = report_1;
1382
+ const report$9 = report_1;
1383
1383
 
1384
1384
  /**
1385
1385
  * 更新appJson里面的主包配置
@@ -1400,7 +1400,10 @@ function updateMainPackages(appJson, mainPackages = []) {
1400
1400
  process.exit(-1);
1401
1401
  }
1402
1402
  subpackage.pages.forEach(page => {
1403
- appJson.pages.push(`${subpackage.root}/${page}`);
1403
+ const pagePath = `${subpackage.root}/${page}`;
1404
+ if (!appJson.pages.includes(pagePath)) {
1405
+ appJson.pages.push(pagePath);
1406
+ }
1404
1407
  });
1405
1408
  if (subpackage.plugins) {
1406
1409
  Object.assign(appJson.plugins, subpackage.plugins);
@@ -1493,7 +1496,7 @@ async function buildOutputAppJson$3(tmsConfig, modules) {
1493
1496
  // 获取所有的分包
1494
1497
  const subPackages = getSubPackages$3(modulesConfig);
1495
1498
  // 获取app.json的配置
1496
- let appJson = getAppJsonContent(resolve$g('./app.json'));
1499
+ let appJson = getAppJsonContent(resolve$h('./app.json'));
1497
1500
 
1498
1501
  // 更新app.json中的subpackages
1499
1502
  appJson.subpackages = subPackages;
@@ -1507,7 +1510,7 @@ async function buildOutputAppJson$3(tmsConfig, modules) {
1507
1510
  // 模板渲染:先将 app.json 转为字符串,然后通过 preprocess 渲染
1508
1511
  const appJsonStr = JSON.stringify(appJson, null, 2);
1509
1512
  const preprocessedStr = pp$1.preprocess(appJsonStr, tmsConfig.templateVars || {}, 'json');
1510
- fs$e.writeFileSync(resolve$g(`${tmsConfig.outputDir}/app.json`), preprocessedStr, 'utf8');
1513
+ fs$e.writeFileSync(resolve$h(`${tmsConfig.outputDir}/app.json`), preprocessedStr, 'utf8');
1511
1514
  appJson = JSON.parse(preprocessedStr);
1512
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') {
1513
1516
  var _tmsConfig$hooks2;
@@ -1518,12 +1521,12 @@ async function buildOutputAppJson$3(tmsConfig, modules) {
1518
1521
  appJson,
1519
1522
  isDev: global$a.getData('isDev')
1520
1523
  }));
1521
- report$8('hooks:updateAppJson');
1524
+ report$9('hooks:updateAppJson');
1522
1525
  }
1523
1526
  return appJson;
1524
1527
  } catch (e) {
1525
- handleError$7(`生成app.json出现错误: ${e}`);
1526
- info$e(e);
1528
+ handleError$8(`生成app.json出现错误: ${e}`);
1529
+ info$f(e);
1527
1530
  }
1528
1531
  }
1529
1532
  var buildAppJson = {
@@ -1538,16 +1541,16 @@ const crypto$2 = require$$1__default$6;
1538
1541
  const {
1539
1542
  downloadRepoForGit,
1540
1543
  pullRepoForGit,
1541
- resolve: resolve$f
1544
+ resolve: resolve$g
1542
1545
  } = widgets;
1543
1546
  const {
1544
1547
  fail: fail$5,
1545
- info: info$d
1548
+ info: info$e
1546
1549
  } = log$1;
1547
1550
  const fs$d = require$$0__default$1;
1548
1551
  const shelljs$5 = require$$0__default$2;
1549
1552
  const {
1550
- handleError: handleError$6
1553
+ handleError: handleError$7
1551
1554
  } = handleError_1;
1552
1555
  const {
1553
1556
  global: global$9
@@ -1639,7 +1642,7 @@ async function cloneModules$1(sourceDir, targetDir, modules) {
1639
1642
  }) => fn(...Object.keys(cParams).map(key => cParams[key])));
1640
1643
  return Promise.all(callArr);
1641
1644
  }).catch(e => {
1642
- handleError$6(`下载代码${params.httpRepoUrl}出现错误:${e}`);
1645
+ handleError$7(`下载代码${params.httpRepoUrl}出现错误:${e}`);
1643
1646
  }));
1644
1647
  });
1645
1648
  await Promise.all(arrPromises);
@@ -1683,9 +1686,9 @@ function collectDownLoadTasksMap(sourceDir, targetDir, modules) {
1683
1686
  // 根据gitUrl与branch计算md5
1684
1687
  const md5Key = md5ByGitUrlBranch(gitUrl, branch);
1685
1688
  // git源码临时存在的源目录
1686
- const sourcePath = resolve$f(sourceDir, md5Key);
1689
+ const sourcePath = resolve$g(sourceDir, md5Key);
1687
1690
  // 模块源码要放到目标目录
1688
- const targetPath = resolve$f(targetDir, path);
1691
+ const targetPath = resolve$g(targetDir, path);
1689
1692
  // 从git源码仓库中找到模块源码路径 (一个仓库存在存放多个模块的情况)
1690
1693
  const sourceModulePath = gitPath ? `${sourcePath}/${gitPath}` : sourcePath;
1691
1694
 
@@ -1710,15 +1713,15 @@ function collectDownLoadTasksMap(sourceDir, targetDir, modules) {
1710
1713
  let promiseTask;
1711
1714
  if (fs$d.existsSync(sourcePath) && fs$d.existsSync(`${sourcePath}/.git`)) {
1712
1715
  promiseTask = (gitUrl, sourcePath, branch, httpRepoUrl) => {
1713
- info$d(`git pull:${httpRepoUrl} --branch: ${branch}`);
1716
+ info$e(`git pull:${httpRepoUrl} --branch: ${branch}`);
1714
1717
  return pullRepoForGit(sourcePath, branch).catch(e => {
1715
- info$d(`pull代码失败:${e}, 开始git clone: ${httpRepoUrl}:${branch}`);
1718
+ info$e(`pull代码失败:${e}, 开始git clone: ${httpRepoUrl}:${branch}`);
1716
1719
  return downloadRepoForGit(gitUrl, sourcePath, branch);
1717
1720
  });
1718
1721
  };
1719
1722
  } else {
1720
1723
  promiseTask = (gitUrl, sourcePath, branch, httpRepoUrl) => {
1721
- info$d(`git clone: ${httpRepoUrl}`);
1724
+ info$e(`git clone: ${httpRepoUrl}`);
1722
1725
  return downloadRepoForGit(gitUrl, sourcePath, branch);
1723
1726
  };
1724
1727
  }
@@ -1892,10 +1895,30 @@ const uploadMp = async (params = {}) => {
1892
1895
  onProgressUpdate: () => {}
1893
1896
  });
1894
1897
  };
1895
- var mpCi$2 = {
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 = {
1896
1918
  buildMpNpm: buildMpNpm$1,
1897
1919
  previewMp,
1898
- uploadMp
1920
+ uploadMp,
1921
+ getDevSourceMap
1899
1922
  };
1900
1923
 
1901
1924
  const fs$c = require$$0__default$1;
@@ -1949,7 +1972,7 @@ const {
1949
1972
  npmInstall: npmInstall$2
1950
1973
  } = widgets;
1951
1974
  const {
1952
- handleError: handleError$5
1975
+ handleError: handleError$6
1953
1976
  } = handleError_1;
1954
1977
  const {
1955
1978
  global: global$8
@@ -2071,7 +2094,7 @@ const npmInstallAll$1 = async (subPackages, contextDir, cacheDir) => {
2071
2094
  }) => fn(...Object.keys(cParams).map(key => cParams[key])));
2072
2095
  return Promise.all(callArr);
2073
2096
  }).catch(e => {
2074
- handleError$5(`npm install ${params.packageJsonPath}出现错误:${e}`, true);
2097
+ handleError$6(`npm install ${params.packageJsonPath}出现错误:${e}`, true);
2075
2098
  }));
2076
2099
  });
2077
2100
  await Promise.all(arrPromises);
@@ -2172,13 +2195,13 @@ var md5 = {
2172
2195
  const fs$9 = require$$0__default$1;
2173
2196
  const semver$1 = require$$1__default$8;
2174
2197
  const {
2175
- resolve: resolve$e,
2198
+ resolve: resolve$f,
2176
2199
  getAbsolutePath: getAbsolutePath$5
2177
2200
  } = widgets;
2178
2201
  const path$9 = require$$1__default$1;
2179
2202
  const shelljs$4 = require$$0__default$2;
2180
2203
  const {
2181
- handleError: handleError$4
2204
+ handleError: handleError$5
2182
2205
  } = handleError_1;
2183
2206
  const getLatestVersion = npmName => {
2184
2207
  const data = shelljs$4.exec(`npm view ${npmName} version`);
@@ -2194,7 +2217,7 @@ function collectPackageJson(subPackages, cwd, outputDir) {
2194
2217
  // 1.1根目录的package.json
2195
2218
  const packageArr = [{
2196
2219
  srcPackageDir: path$9.join(cwd, packageJsonName),
2197
- destNpmDir: resolve$e(outputDir, 'node_modules')
2220
+ destNpmDir: resolve$f(outputDir, 'node_modules')
2198
2221
  }];
2199
2222
  // 1.2模块的package.json
2200
2223
  subPackages.forEach(item => {
@@ -2202,7 +2225,7 @@ function collectPackageJson(subPackages, cwd, outputDir) {
2202
2225
  if (fs$9.existsSync(srcPackageDir)) {
2203
2226
  packageArr.push({
2204
2227
  srcPackageDir,
2205
- destNpmDir: resolve$e(outputDir, item.root, 'node_modules')
2228
+ destNpmDir: resolve$f(outputDir, item.root, 'node_modules')
2206
2229
  });
2207
2230
  }
2208
2231
  });
@@ -2217,7 +2240,7 @@ function readPackageDependencies(srcPackageDir) {
2217
2240
  const json = packageJson ? JSON.parse(packageJson) : {};
2218
2241
  dependencies = (json === null || json === void 0 ? void 0 : json.dependencies) || {};
2219
2242
  } catch (e) {
2220
- handleError$4(`解析${srcPackageDir}报错,请检查是否是正确的json配置项 ${e}`);
2243
+ handleError$5(`解析${srcPackageDir}报错,请检查是否是正确的json配置项 ${e}`);
2221
2244
  }
2222
2245
  return dependencies;
2223
2246
  }
@@ -2273,14 +2296,14 @@ const fs$8 = require$$0__default$1;
2273
2296
  const path$8 = require$$1__default$1;
2274
2297
  const io$1 = io$3;
2275
2298
  const {
2276
- createTask: createTask$4,
2277
- resolve: resolve$d,
2299
+ createTask: createTask$5,
2300
+ resolve: resolve$e,
2278
2301
  getAbsolutePath: getAbsolutePath$4,
2279
2302
  filterField: filterField$6
2280
2303
  } = widgets;
2281
2304
  const {
2282
2305
  buildMpNpm
2283
- } = mpCi$2;
2306
+ } = mpCi$3;
2284
2307
  const {
2285
2308
  global: global$7
2286
2309
  } = global_1;
@@ -2295,7 +2318,7 @@ const {
2295
2318
  npmInstallAll
2296
2319
  } = npm;
2297
2320
  const {
2298
- info: info$c
2321
+ info: info$d
2299
2322
  } = log$1;
2300
2323
  const {
2301
2324
  fileMd5
@@ -2309,41 +2332,41 @@ async function install$3(tmsConfig, subPackages, useCache = true) {
2309
2332
  // 加npm install之前的钩子
2310
2333
  if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforeNpmInstall) === 'function') {
2311
2334
  var _tmsConfig$hooks2;
2312
- info$c('—————— 执行beforeNpmInstall ————');
2335
+ info$d('—————— 执行beforeNpmInstall ————');
2313
2336
  await (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.beforeNpmInstall({
2314
2337
  tmsConfig: filterField$6(tmsConfig, ['gitAccount']),
2315
2338
  cmdOptions: global$7.getData('cmdOptions')
2316
2339
  }));
2317
- info$c('—————— 执行beforeNpmInstall 完成 ————');
2340
+ info$d('—————— 执行beforeNpmInstall 完成 ————');
2318
2341
  }
2319
- const npmInstallRes = await createTask$4(npmInstall$1, '小程序 开始npm install', '小程序npm install 完成')(tmsConfig, subPackages, useCache);
2342
+ const npmInstallRes = await createTask$5(npmInstall$1, '小程序 开始npm install', '小程序npm install 完成')(tmsConfig, subPackages, useCache);
2320
2343
 
2321
2344
  // 如果npm install 没有命中缓存,则说明node_module有更新,此时必须构建miniprogram_npm
2322
2345
  if (!npmInstallRes.isCache) {
2323
2346
  // 构建miniprogram_npm, 不使用缓存
2324
- await createTask$4(mpCiInstall, '开始构建miniprogram_npm', '构建miniprogram_npm 完成')(tmsConfig, subPackages, false);
2347
+ await createTask$5(mpCiInstall, '开始构建miniprogram_npm', '构建miniprogram_npm 完成')(tmsConfig, subPackages, false);
2325
2348
  } else {
2326
2349
  // 构建miniprogram_npm
2327
- await createTask$4(mpCiInstall, '开始构建miniprogram_npm', '构建miniprogram_npm 完成')(tmsConfig, subPackages, useCache);
2350
+ await createTask$5(mpCiInstall, '开始构建miniprogram_npm', '构建miniprogram_npm 完成')(tmsConfig, subPackages, useCache);
2328
2351
  }
2329
2352
  shelljs$3.cd(cwd);
2330
2353
  }
2331
2354
  async function npmInstall$1(tmsConfig, subPackages, useCache) {
2332
2355
  // 如果依赖没有更新和使用缓存数据(则命中缓存)
2333
- if (!isDependenciesUpdate(subPackages, resolve$d('./'), tmsConfig.outputDir) && useCache) {
2334
- info$c('node_modules命中缓存');
2356
+ if (!isDependenciesUpdate(subPackages, resolve$e('./'), tmsConfig.outputDir) && useCache) {
2357
+ info$d('node_modules命中缓存');
2335
2358
  return {
2336
2359
  isCache: true
2337
2360
  };
2338
2361
  }
2339
2362
  // 拷贝模块的package.json到编译输出目录
2340
2363
  subPackages.forEach(item => {
2341
- const outputModuleDir = resolve$d(`${tmsConfig.outputDir}/${item.root}`);
2364
+ const outputModuleDir = resolve$e(`${tmsConfig.outputDir}/${item.root}`);
2342
2365
  io$1.ensureDirExist(outputModuleDir);
2343
2366
  const modulePackagePath = `${getAbsolutePath$4(item.path)}/package.json`;
2344
2367
  if (fs$8.existsSync(modulePackagePath)) shelljs$3.cp('-Rf', modulePackagePath, outputModuleDir);
2345
2368
  });
2346
- await npmInstallAll(subPackages, resolve$d(tmsConfig.outputDir), NODE_MODULES_DIR$1);
2369
+ await npmInstallAll(subPackages, resolve$e(tmsConfig.outputDir), NODE_MODULES_DIR$1);
2347
2370
  return {
2348
2371
  isCache: false
2349
2372
  };
@@ -2352,12 +2375,12 @@ async function npmInstall$1(tmsConfig, subPackages, useCache) {
2352
2375
  // 构建miniprogram_npm
2353
2376
  async function mpCiInstall(tmsConfig, subPackages, useCache) {
2354
2377
  const packageJsonFiles = [];
2355
- const rootPackFile = resolve$d(`${tmsConfig.outputDir}/package.json`);
2378
+ const rootPackFile = resolve$e(`${tmsConfig.outputDir}/package.json`);
2356
2379
  if (fs$8.existsSync(rootPackFile)) {
2357
2380
  packageJsonFiles.push(rootPackFile);
2358
2381
  }
2359
2382
  subPackages.forEach(item => {
2360
- const packageJsonFile = resolve$d(`${tmsConfig.outputDir}/${item.root}/package.json`);
2383
+ const packageJsonFile = resolve$e(`${tmsConfig.outputDir}/${item.root}/package.json`);
2361
2384
  if (fs$8.existsSync(packageJsonFile)) {
2362
2385
  packageJsonFiles.push(packageJsonFile);
2363
2386
  }
@@ -2371,7 +2394,7 @@ async function mpCiInstall(tmsConfig, subPackages, useCache) {
2371
2394
  let flag = true;
2372
2395
  await Promise.all(packageJsonFiles.map(async item => {
2373
2396
  const packageDir = path$8.dirname(item);
2374
- const mpDir = resolve$d(`${packageDir}/miniprogram_npm`);
2397
+ const mpDir = resolve$e(`${packageDir}/miniprogram_npm`);
2375
2398
  const md5Value = await getMNPMd5(packageDir);
2376
2399
  const preCache = getCache(mpDir, 'miniprogram_npm');
2377
2400
  // console.log('miniprogram_npm', preCache, md5Value);
@@ -2383,14 +2406,14 @@ async function mpCiInstall(tmsConfig, subPackages, useCache) {
2383
2406
  isCache = flag;
2384
2407
  }
2385
2408
  if (isCache) {
2386
- info$c('miniprogram_npm命中缓存');
2409
+ info$d('miniprogram_npm命中缓存');
2387
2410
  return;
2388
2411
  }
2389
2412
 
2390
2413
  // 即将构建,在cache中标记开始
2391
2414
  await Promise.all(packageJsonFiles.map(async item => {
2392
2415
  const packageDir = path$8.dirname(item);
2393
- const mpDir = resolve$d(`${packageDir}/miniprogram_npm`);
2416
+ const mpDir = resolve$e(`${packageDir}/miniprogram_npm`);
2394
2417
  setCache(mpDir, 'miniprogram_npm', {
2395
2418
  md5: '',
2396
2419
  status: statusMap.doing
@@ -2398,14 +2421,14 @@ async function mpCiInstall(tmsConfig, subPackages, useCache) {
2398
2421
  }));
2399
2422
  await buildMpNpm({
2400
2423
  appId: tmsConfig.appId,
2401
- projectPath: resolve$d('./'),
2424
+ projectPath: resolve$e('./'),
2402
2425
  privateKey: tmsConfig.privateKey
2403
2426
  });
2404
2427
 
2405
2428
  // 构建成功后,计算md5写入cache
2406
2429
  await Promise.all(packageJsonFiles.map(async item => {
2407
2430
  const packageDir = path$8.dirname(item);
2408
- const mpDir = resolve$d(`${packageDir}/miniprogram_npm`);
2431
+ const mpDir = resolve$e(`${packageDir}/miniprogram_npm`);
2409
2432
  const md5Value = await getMNPMd5(packageDir);
2410
2433
  setCache(mpDir, 'miniprogram_npm', {
2411
2434
  md5: md5Value,
@@ -2439,8 +2462,8 @@ const shelljs$2 = require$$0__default$2;
2439
2462
  const fs$7 = require$$0__default$1;
2440
2463
  const io = io$3;
2441
2464
  const {
2442
- resolve: resolve$c,
2443
- createTask: createTask$3
2465
+ resolve: resolve$d,
2466
+ createTask: createTask$4
2444
2467
  } = widgets;
2445
2468
  const {
2446
2469
  buildOutputAppJson: buildOutputAppJson$2
@@ -2458,7 +2481,7 @@ const {
2458
2481
  } = tmsMpconfig.exports;
2459
2482
  const {
2460
2483
  fail: fail$4,
2461
- info: info$b
2484
+ info: info$c
2462
2485
  } = log$1;
2463
2486
  const install$2 = install_1;
2464
2487
 
@@ -2470,17 +2493,17 @@ const install$2 = install_1;
2470
2493
  * @returns
2471
2494
  */
2472
2495
  const cpFilesToOutput = function (tmsConfig, defaultFiles) {
2473
- const outputDir = resolve$c(tmsConfig.outputDir);
2496
+ const outputDir = resolve$d(tmsConfig.outputDir);
2474
2497
  io.ensureDirExist(outputDir);
2475
2498
  defaultFiles.forEach(item => {
2476
- if (fs$7.existsSync(resolve$c(item))) {
2477
- shelljs$2.cp('-rf', resolve$c(item), resolve$c(tmsConfig.outputDir, item));
2499
+ if (fs$7.existsSync(resolve$d(item))) {
2500
+ shelljs$2.cp('-rf', resolve$d(item), resolve$d(tmsConfig.outputDir, item));
2478
2501
  }
2479
2502
  });
2480
2503
  };
2481
2504
  async function task(tmsConfig, targetModules) {
2482
2505
  // 下载和移动代码
2483
- await createTask$3(cloneModules, '开始下载模块代码', '下载模块代码码完成')(MODULE_CODE_DIR$1, resolve$c('./'), targetModules);
2506
+ await createTask$4(cloneModules, '开始下载模块代码', '下载模块代码码完成')(MODULE_CODE_DIR$1, resolve$d('./'), targetModules);
2484
2507
 
2485
2508
  // 获取所有模块,合并模块依赖的模块
2486
2509
  const newModules = getModulesByMergeDepModules$2(tmsConfig, targetModules, true);
@@ -2488,13 +2511,13 @@ async function task(tmsConfig, targetModules) {
2488
2511
  const newSubPackages = getSubPackages$2(newModules);
2489
2512
 
2490
2513
  // 拷贝相关配置文件到输出目录
2491
- await createTask$3(cpFilesToOutput, '开始拷贝文件到编译输出目录', '拷贝文件到编译输出目录完成')(tmsConfig, DEFAULT_COPY_CONFIG$1);
2514
+ await createTask$4(cpFilesToOutput, '开始拷贝文件到编译输出目录', '拷贝文件到编译输出目录完成')(tmsConfig, DEFAULT_COPY_CONFIG$1);
2492
2515
 
2493
2516
  // install
2494
2517
  await install$2(tmsConfig, newSubPackages, true);
2495
2518
 
2496
2519
  // 动态生成编译后的app.json;
2497
- await createTask$3(buildOutputAppJson$2, '开始生成编译后的app.json', '生成编译后的app.json完成')(tmsConfig, newModules);
2520
+ await createTask$4(buildOutputAppJson$2, '开始生成编译后的app.json', '生成编译后的app.json完成')(tmsConfig, newModules);
2498
2521
  return {
2499
2522
  modules: newModules,
2500
2523
  subPackages: newSubPackages
@@ -2507,7 +2530,7 @@ async function init$3(tmsConfig, targetModules) {
2507
2530
  } catch (error) {
2508
2531
  const errMsg = typeof error === 'object' ? error.message : error;
2509
2532
  fail$4(`初始化流程出现错误: ${errMsg}`);
2510
- info$b('详细的错误信息', error);
2533
+ info$c('详细的错误信息', error);
2511
2534
  process.exit(1);
2512
2535
  }
2513
2536
  }
@@ -2633,15 +2656,15 @@ const minimatch = require$$2__default;
2633
2656
  const gulpif = require$$3__default$1;
2634
2657
  const mpProjectJson = mpProjectJson_1;
2635
2658
  const {
2636
- resolve: resolve$b
2659
+ resolve: resolve$c
2637
2660
  } = widgets;
2638
2661
  const through = require$$0__default$8;
2639
2662
  const {
2640
2663
  fail: fail$3
2641
2664
  } = log$1;
2642
2665
  const getTargetFile$2 = (sourceFile, module, outputDir) => {
2643
- const sourceFileRelativeModule = path$6.relative(resolve$b(module.from), sourceFile);
2644
- const targetFile = resolve$b(outputDir, module.to, sourceFileRelativeModule);
2666
+ const sourceFileRelativeModule = path$6.relative(resolve$c(module.from), sourceFile);
2667
+ const targetFile = resolve$c(outputDir, module.to, sourceFileRelativeModule);
2645
2668
  return targetFile;
2646
2669
  };
2647
2670
  const addPlugins = function (tmsConfig, srcPipe, pluginParams) {
@@ -2851,12 +2874,12 @@ const {
2851
2874
  series: series$2
2852
2875
  } = require$$0__default$9;
2853
2876
  const {
2854
- info: info$a,
2877
+ info: info$b,
2855
2878
  warn: warn$1,
2856
2879
  fail: fail$2
2857
2880
  } = log$1;
2858
2881
  const {
2859
- resolve: resolve$a,
2882
+ resolve: resolve$b,
2860
2883
  filterField: filterField$5
2861
2884
  } = widgets;
2862
2885
  const {
@@ -2865,7 +2888,7 @@ const {
2865
2888
  const {
2866
2889
  checkPackageVersion
2867
2890
  } = checkDependencies;
2868
- const report$7 = report_1;
2891
+ const report$8 = report_1;
2869
2892
  const TIP_MAP = {
2870
2893
  'package.json': {
2871
2894
  tip: '依赖版本有变动,请重新执行tmskit run dev',
@@ -2892,14 +2915,14 @@ const logTip = (fileName, sourceFile, targetFile, tipMap) => {
2892
2915
  return;
2893
2916
  }
2894
2917
  }
2895
- info$a(`${fileName}有更新`);
2918
+ info$b(`${fileName}有更新`);
2896
2919
  } catch (e) {
2897
2920
  fail$2(`${sourceFile}文件更新提示出现错误: ${e.message}`);
2898
2921
  }
2899
2922
  };
2900
2923
  const getTargetFile$1 = (sourceFile, module, outputDir) => {
2901
- const sourceFileRelativeModule = path$4.relative(resolve$a(module.from), sourceFile);
2902
- return resolve$a(outputDir, module.to, sourceFileRelativeModule);
2924
+ const sourceFileRelativeModule = path$4.relative(resolve$b(module.from), sourceFile);
2925
+ return resolve$b(outputDir, module.to, sourceFileRelativeModule);
2903
2926
  };
2904
2927
  var watch_1 = function (globValue, watchOptions, callback, module) {
2905
2928
  watch$2(globValue, {
@@ -2916,7 +2939,7 @@ var watch_1 = function (globValue, watchOptions, callback, module) {
2916
2939
  targetFile = path$4.join(module.to, filePath);
2917
2940
  }
2918
2941
  if (vinyl.event === 'unlink' || vinyl.event === 'unlinkDir') {
2919
- info$a(`删除${sourceFileName}`);
2942
+ info$b(`删除${sourceFileName}`);
2920
2943
  shellJs$2.rm('-rf', targetFile);
2921
2944
  updateFileHook(tmsConfig, sourceFile, targetFile, vinyl.event);
2922
2945
  return;
@@ -2965,7 +2988,7 @@ async function updateFileHook(tmsConfig, sourceFile, targetFile, type) {
2965
2988
  targetFile,
2966
2989
  type
2967
2990
  });
2968
- report$7('hooks:updateFile');
2991
+ report$8('hooks:updateFile');
2969
2992
  }
2970
2993
  }
2971
2994
 
@@ -2978,7 +3001,7 @@ const {
2978
3001
  series: series$1
2979
3002
  } = require$$0__default$9;
2980
3003
  const {
2981
- resolve: resolve$9,
3004
+ resolve: resolve$a,
2982
3005
  mergeMap,
2983
3006
  filterField: filterField$4,
2984
3007
  getAbsolutePath: getAbsolutePath$3
@@ -2992,9 +3015,9 @@ const {
2992
3015
  const compile = compile$1;
2993
3016
  const watch$1 = watch_1;
2994
3017
  const {
2995
- info: info$9
3018
+ info: info$a
2996
3019
  } = log$1;
2997
- const report$6 = report_1;
3020
+ const report$7 = report_1;
2998
3021
  const {
2999
3022
  global: global$5
3000
3023
  } = global_1;
@@ -3004,12 +3027,12 @@ var dev$4 = async (tmsConfig, modules, isDev = true) => {
3004
3027
 
3005
3028
  // 监听根目录的文件
3006
3029
  mergeMap(compileTasksMap, compile(tmsConfig, {
3007
- glob: DEFAULT_COPY_CONFIG.map(item => resolve$9(item)),
3030
+ glob: DEFAULT_COPY_CONFIG.map(item => resolve$a(item)),
3008
3031
  module: {
3009
- from: resolve$9(),
3010
- to: resolve$9(tmsConfig.outputDir)
3032
+ from: resolve$a(),
3033
+ to: resolve$a(tmsConfig.outputDir)
3011
3034
  },
3012
- destPath: resolve$9(tmsConfig.outputDir),
3035
+ destPath: resolve$a(tmsConfig.outputDir),
3013
3036
  srcOption: {
3014
3037
  allowEmpty: true
3015
3038
  },
@@ -3045,7 +3068,7 @@ var dev$4 = async (tmsConfig, modules, isDev = true) => {
3045
3068
  ...moduleItem
3046
3069
  };
3047
3070
  const srcModulePath = getAbsolutePath$3(moduleItem.path);
3048
- const buildModulePath = resolve$9(tmsConfig.outputDir, moduleItem.modulePath);
3071
+ const buildModulePath = resolve$a(tmsConfig.outputDir, moduleItem.modulePath);
3049
3072
  if (isDev) {
3050
3073
  // 监听模块配置文件
3051
3074
  watch$1([`${srcModulePath}/**/module.config.json`], {
@@ -3059,9 +3082,9 @@ var dev$4 = async (tmsConfig, modules, isDev = true) => {
3059
3082
  const newPath = getAbsolutePath$3(ePath, srcModulePath);
3060
3083
  const ext = path$3.extname(ePath).slice(1);
3061
3084
  if (ext) {
3062
- return `!${resolve$9(srcModulePath, newPath)}`;
3085
+ return `!${resolve$a(srcModulePath, newPath)}`;
3063
3086
  }
3064
- return `!${resolve$9(srcModulePath, newPath)}/**/*`;
3087
+ return `!${resolve$a(srcModulePath, newPath)}/**/*`;
3065
3088
  });
3066
3089
  const moduleConfigPath = `${srcModulePath}/**/module.config.json`;
3067
3090
  const moduleConfigGlob = tmsConfig.isKeepModuleConfig ? `${moduleConfigPath}` : `!${moduleConfigPath}`;
@@ -3110,7 +3133,7 @@ var dev$4 = async (tmsConfig, modules, isDev = true) => {
3110
3133
  let eTime;
3111
3134
  const spinner = ora$1();
3112
3135
  function start(cb) {
3113
- info$9('启动编译...');
3136
+ info$a('启动编译...');
3114
3137
  spinner.start();
3115
3138
  sTime = new Date().getTime();
3116
3139
  cb();
@@ -3119,12 +3142,12 @@ var dev$4 = async (tmsConfig, modules, isDev = true) => {
3119
3142
  var _tmsConfig$hooks;
3120
3143
  if (isDev) {
3121
3144
  // 监听app.json
3122
- watch$1([resolve$9('app.json')], {
3145
+ watch$1([resolve$a('app.json')], {
3123
3146
  ignoreInitial: false,
3124
3147
  events: watchEvents
3125
3148
  }, async () => await buildOutputAppJson$1(tmsConfig, modules, isDev), {
3126
- from: resolve$9(),
3127
- to: resolve$9(tmsConfig.outputDir)
3149
+ from: resolve$a(),
3150
+ to: resolve$a(tmsConfig.outputDir)
3128
3151
  });
3129
3152
  // 监听其他文件
3130
3153
  compileTasksMap.forEach(({
@@ -3148,7 +3171,7 @@ var dev$4 = async (tmsConfig, modules, isDev = true) => {
3148
3171
  modules,
3149
3172
  cmdOptions: global$5.getData('cmdOptions')
3150
3173
  }));
3151
- report$6('hooks:afterCompile');
3174
+ report$7('hooks:afterCompile');
3152
3175
  }
3153
3176
  spinner.succeed(chalk$3.green(`首次编译完成, 耗时${eTime / 1000}s, 微信开发者工具打开项目即可预览。`));
3154
3177
  spinner.stop();
@@ -3167,7 +3190,7 @@ var dev$4 = async (tmsConfig, modules, isDev = true) => {
3167
3190
  const shelljs$1 = require$$0__default$2;
3168
3191
  const compileDev = dev$4;
3169
3192
  const {
3170
- resolve: resolve$8,
3193
+ resolve: resolve$9,
3171
3194
  filterField: filterField$3
3172
3195
  } = widgets;
3173
3196
  const init$2 = init_1;
@@ -3179,7 +3202,7 @@ const {
3179
3202
  getSubPackages: getSubPackages$1
3180
3203
  } = tmsMpconfig.exports;
3181
3204
  const {
3182
- info: info$8
3205
+ info: info$9
3183
3206
  } = log$1;
3184
3207
  const {
3185
3208
  global: global$4
@@ -3188,7 +3211,7 @@ const {
3188
3211
  MODULE_CODE_DIR,
3189
3212
  NODE_MODULES_DIR
3190
3213
  } = constant;
3191
- const report$5 = report_1;
3214
+ const report$6 = report_1;
3192
3215
  // const { recommendVersion } = require('../../../core/recommendVersion');
3193
3216
 
3194
3217
  // 用户编译分包时,需要将dist中其他分包(主包不能删除)的内容删除,否则其他分包的内容混入到主包(导致主包的体积超2M)
@@ -3200,7 +3223,7 @@ function delOtherPackages(tmsConfig, targetSubPackages) {
3200
3223
  const targetSubPackagesName = targetSubPackages.map(item => item.name);
3201
3224
  allSubPackages.forEach(item => {
3202
3225
  if (item.root && targetSubPackagesName.indexOf(item.name) === -1) {
3203
- const moduleRootDir = resolve$8(`${tmsConfig.outputDir}/${item.root}`);
3226
+ const moduleRootDir = resolve$9(`${tmsConfig.outputDir}/${item.root}`);
3204
3227
  shelljs$1.rm('-rf', `${moduleRootDir}/*`, {
3205
3228
  silent: true
3206
3229
  });
@@ -3215,7 +3238,7 @@ async function dev$3(tmsConfig, targetModules) {
3215
3238
  noCache
3216
3239
  } = global$4.getData('cmdOptions');
3217
3240
  if (noCache) {
3218
- shelljs$1.rm('-rf', resolve$8(tmsConfig.outputDir));
3241
+ shelljs$1.rm('-rf', resolve$9(tmsConfig.outputDir));
3219
3242
  shelljs$1.rm('-rf', MODULE_CODE_DIR);
3220
3243
  shelljs$1.rm('-rf', NODE_MODULES_DIR);
3221
3244
  }
@@ -3230,7 +3253,7 @@ async function dev$3(tmsConfig, targetModules) {
3230
3253
 
3231
3254
  // 在启动开发环境前主动执行生成 app.json
3232
3255
  await buildOutputAppJson(tmsConfig, newModules);
3233
- info$8('当前dev启动的有效模块', newModules.map(item => item.moduleName).sort());
3256
+ info$9('当前dev启动的有效模块', newModules.map(item => item.moduleName).sort());
3234
3257
  if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforeFirstCompile) === 'function') {
3235
3258
  var _tmsConfig$hooks2;
3236
3259
  await (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.beforeFirstCompile({
@@ -3239,7 +3262,7 @@ async function dev$3(tmsConfig, targetModules) {
3239
3262
  modules: newModules,
3240
3263
  cmdOptions: global$4.getData('cmdOptions')
3241
3264
  }));
3242
- report$5('hooks:beforeCompile');
3265
+ report$6('hooks:beforeCompile');
3243
3266
  }
3244
3267
  delOtherPackages(tmsConfig, subPackages);
3245
3268
  compileDev(tmsConfig, newModules, true);
@@ -3253,26 +3276,26 @@ var build$2 = async (tmsConfig, newModules, isDev) => {
3253
3276
 
3254
3277
  const shelljs = require$$0__default$2;
3255
3278
  const {
3256
- resolve: resolve$7,
3279
+ resolve: resolve$8,
3257
3280
  filterField: filterField$2
3258
3281
  } = widgets;
3259
3282
  const init$1 = init_1;
3260
3283
  const {
3261
- info: info$7
3284
+ info: info$8
3262
3285
  } = log$1;
3263
3286
  const compileBuild = build$2;
3264
- const report$4 = report_1;
3287
+ const report$5 = report_1;
3265
3288
  const {
3266
3289
  global: global$3
3267
3290
  } = global_1;
3268
3291
  async function build$1(tmsConfig, targetModules) {
3269
3292
  var _tmsConfig$hooks;
3270
3293
  // 开始构建前,清理输出目录
3271
- await shelljs.rm('-rf', resolve$7(tmsConfig.outputDir));
3294
+ await shelljs.rm('-rf', resolve$8(tmsConfig.outputDir));
3272
3295
  const {
3273
3296
  modules: newModules
3274
3297
  } = await init$1(tmsConfig, targetModules);
3275
- info$7('当前build有效模块', newModules.map(item => item.moduleName).sort());
3298
+ info$8('当前build有效模块', newModules.map(item => item.moduleName).sort());
3276
3299
  const isDev = false;
3277
3300
  if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforeFirstCompile) === 'function') {
3278
3301
  var _tmsConfig$hooks2;
@@ -3282,7 +3305,7 @@ async function build$1(tmsConfig, targetModules) {
3282
3305
  modules: newModules,
3283
3306
  cmdOptions: global$3.getData('cmdOptions')
3284
3307
  }));
3285
- report$4('hooks:beforeCompile');
3308
+ report$5('hooks:beforeCompile');
3286
3309
  }
3287
3310
  compileBuild(tmsConfig, newModules, isDev);
3288
3311
  }
@@ -3308,7 +3331,7 @@ function getAllSize$2(data = {}) {
3308
3331
  }
3309
3332
  return allSize;
3310
3333
  }
3311
- const getDesc$2 = (desc = '') => {
3334
+ const getDesc$3 = (desc = '') => {
3312
3335
  const user = getGitUser();
3313
3336
  const date = moment().format('YYYY-MM-DD HH:mm:ss');
3314
3337
  return `构建描述:${desc}; 构建人: ${user}; 构建时间:${date}`;
@@ -3326,24 +3349,24 @@ const getDetaultVersion = () => {
3326
3349
  };
3327
3350
  var utils = {
3328
3351
  getAllSize: getAllSize$2,
3329
- getDesc: getDesc$2,
3352
+ getDesc: getDesc$3,
3330
3353
  outputInfo: outputInfo$2,
3331
3354
  getDetaultVersion
3332
3355
  };
3333
3356
 
3334
- const mpCi$1 = mpCi$2;
3357
+ const mpCi$2 = mpCi$3;
3335
3358
  const fs$4 = require$$0__default$1;
3336
3359
  const {
3337
- resolve: resolve$6,
3338
- createTask: createTask$2,
3360
+ resolve: resolve$7,
3361
+ createTask: createTask$3,
3339
3362
  getAbsolutePath: getAbsolutePath$1,
3340
3363
  filterField: filterField$1
3341
3364
  } = widgets;
3342
3365
  const {
3343
- handleError: handleError$3
3366
+ handleError: handleError$4
3344
3367
  } = handleError_1;
3345
3368
  const {
3346
- info: info$6
3369
+ info: info$7
3347
3370
  } = log$1;
3348
3371
  const {
3349
3372
  global: global$2
@@ -3351,10 +3374,10 @@ const {
3351
3374
  const {
3352
3375
  getAllSize: getAllSize$1,
3353
3376
  outputInfo: outputInfo$1,
3354
- getDesc: getDesc$1
3377
+ getDesc: getDesc$2
3355
3378
  } = utils;
3356
- const report$3 = report_1;
3357
- const handleParams$1 = (tmsConfig, cmdOptions) => {
3379
+ const report$4 = report_1;
3380
+ const handleParams$2 = (tmsConfig, cmdOptions) => {
3358
3381
  const params = {
3359
3382
  ...(tmsConfig.preview ? tmsConfig.preview : {}),
3360
3383
  ...cmdOptions
@@ -3362,10 +3385,10 @@ const handleParams$1 = (tmsConfig, cmdOptions) => {
3362
3385
  return {
3363
3386
  ...params,
3364
3387
  appId: params.appId || tmsConfig.appId,
3365
- projectPath: resolve$6(tmsConfig.outputDir),
3388
+ projectPath: resolve$7(tmsConfig.outputDir),
3366
3389
  privateKey: params.privateKey || tmsConfig.privateKey,
3367
3390
  robot: params.robot || 30,
3368
- desc: params.desc || getDesc$1(params.desc),
3391
+ desc: params.desc || getDesc$2(params.desc),
3369
3392
  qrcodeOutputDest: getAbsolutePath$1(params.qrcodeOutputDest || '')
3370
3393
  };
3371
3394
  };
@@ -3378,7 +3401,7 @@ const handleParams$1 = (tmsConfig, cmdOptions) => {
3378
3401
  async function preview$1(tmsConfig, cmdOptions) {
3379
3402
  try {
3380
3403
  var _tmsConfig$hooks;
3381
- const params = handleParams$1(tmsConfig, cmdOptions);
3404
+ const params = handleParams$2(tmsConfig, cmdOptions);
3382
3405
  if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforePreview) === 'function') {
3383
3406
  var _tmsConfig$hooks2;
3384
3407
  await (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.beforePreview({
@@ -3386,10 +3409,10 @@ async function preview$1(tmsConfig, cmdOptions) {
3386
3409
  cmdOptions: global$2.getData('cmdOptions'),
3387
3410
  params
3388
3411
  }));
3389
- report$3('hooks:beforePreview');
3412
+ report$4('hooks:beforePreview');
3390
3413
  }
3391
3414
  ;
3392
- const previewRes = await createTask$2(mpCi$1.previewMp, '正在构建预览码', '构建预览码完成')({
3415
+ const previewRes = await createTask$3(mpCi$2.previewMp, '正在构建预览码', '构建预览码完成')({
3393
3416
  ...params
3394
3417
  });
3395
3418
  const allSize = getAllSize$1(previewRes);
@@ -3404,25 +3427,25 @@ async function preview$1(tmsConfig, cmdOptions) {
3404
3427
  ...previewRes
3405
3428
  });
3406
3429
  }
3407
- info$6('预览包大小:', `${allSize}k`);
3430
+ info$7('预览包大小:', `${allSize}k`);
3408
3431
  } catch (e) {
3409
3432
  console.log('详细错误:', e);
3410
- handleError$3(`预览错误: ${e.message}`, true);
3433
+ handleError$4(`预览错误: ${e.message}`, true);
3411
3434
  }
3412
3435
  }
3413
3436
  var preview_1 = preview$1;
3414
3437
 
3415
- const mpCi = mpCi$2;
3438
+ const mpCi$1 = mpCi$3;
3416
3439
  const {
3417
- resolve: resolve$5,
3418
- createTask: createTask$1,
3440
+ resolve: resolve$6,
3441
+ createTask: createTask$2,
3419
3442
  filterField
3420
3443
  } = widgets;
3421
3444
  const {
3422
- handleError: handleError$2
3445
+ handleError: handleError$3
3423
3446
  } = handleError_1;
3424
3447
  const {
3425
- info: info$5
3448
+ info: info$6
3426
3449
  } = log$1;
3427
3450
  const {
3428
3451
  global: global$1
@@ -3430,10 +3453,10 @@ const {
3430
3453
  const {
3431
3454
  getAllSize,
3432
3455
  outputInfo,
3433
- getDesc
3456
+ getDesc: getDesc$1
3434
3457
  } = utils;
3435
- const report$2 = report_1;
3436
- const handleParams = (tmsConfig, cmdOptions) => {
3458
+ const report$3 = report_1;
3459
+ const handleParams$1 = (tmsConfig, cmdOptions) => {
3437
3460
  const params = {
3438
3461
  ...(tmsConfig.upload ? tmsConfig.upload : {}),
3439
3462
  ...cmdOptions
@@ -3444,10 +3467,10 @@ const handleParams = (tmsConfig, cmdOptions) => {
3444
3467
  return {
3445
3468
  ...params,
3446
3469
  appId: params.appId || tmsConfig.appId,
3447
- projectPath: resolve$5(tmsConfig.outputDir),
3470
+ projectPath: resolve$6(tmsConfig.outputDir),
3448
3471
  privateKey: params.privateKey || tmsConfig.privateKey,
3449
3472
  robot: params.robot || 30,
3450
- desc: params.desc || getDesc(params.desc)
3473
+ desc: params.desc || getDesc$1(params.desc)
3451
3474
  };
3452
3475
  };
3453
3476
 
@@ -3459,7 +3482,7 @@ const handleParams = (tmsConfig, cmdOptions) => {
3459
3482
  async function upload$1(tmsConfig, cmdOptions) {
3460
3483
  try {
3461
3484
  var _tmsConfig$hooks;
3462
- const params = handleParams(tmsConfig, cmdOptions);
3485
+ const params = handleParams$1(tmsConfig, cmdOptions);
3463
3486
  if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforeUpload) === 'function') {
3464
3487
  var _tmsConfig$hooks2;
3465
3488
  await (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.beforeUpload({
@@ -3467,10 +3490,10 @@ async function upload$1(tmsConfig, cmdOptions) {
3467
3490
  cmdOptions: global$1.getData('cmdOptions'),
3468
3491
  params
3469
3492
  }));
3470
- report$2('hooks:beforeUpload');
3493
+ report$3('hooks:beforeUpload');
3471
3494
  }
3472
3495
  ;
3473
- const uploadRes = await createTask$1(mpCi.uploadMp, '正在上传小程序代码', '上传小程序代码完成')({
3496
+ const uploadRes = await createTask$2(mpCi$1.uploadMp, '正在上传小程序代码', '上传小程序代码完成')({
3474
3497
  ...params
3475
3498
  });
3476
3499
  const allSize = getAllSize(uploadRes);
@@ -3480,14 +3503,65 @@ async function upload$1(tmsConfig, cmdOptions) {
3480
3503
  ...uploadRes
3481
3504
  });
3482
3505
  }
3483
- info$5(`上传包大小: ${allSize}k; 上传包版本: ${params.version}`);
3506
+ info$6(`上传包大小: ${allSize}k; 上传包版本: ${params.version}`);
3484
3507
  } catch (e) {
3485
3508
  console.log('详细错误:', e);
3486
- handleError$2(`上传错误: ${e.message}`, true);
3509
+ handleError$3(`上传错误: ${e.message}`, true);
3487
3510
  }
3488
3511
  }
3489
3512
  var upload_1 = upload$1;
3490
3513
 
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
+
3491
3565
  const {
3492
3566
  resolve: resolve$4,
3493
3567
  getAbsolutePath
@@ -3821,6 +3895,7 @@ const build = build_1;
3821
3895
  const install = install_1;
3822
3896
  const preview = preview_1;
3823
3897
  const upload = upload_1;
3898
+ const sourcemap = sourcemap_1;
3824
3899
  const cloudLink = link;
3825
3900
  const cloudDev = dev$1;
3826
3901
  const {
@@ -3958,6 +4033,12 @@ function otherCommands(tmsConfig, commandName, cmdOptions) {
3958
4033
  appName: tmsConfig.appName
3959
4034
  });
3960
4035
  return;
4036
+ case 'sourcemap':
4037
+ sourcemap(tmsConfig);
4038
+ report$1('run:sourcemap', {
4039
+ appName: tmsConfig.appName
4040
+ });
4041
+ return;
3961
4042
  default:
3962
4043
  return;
3963
4044
  }
@@ -4017,6 +4098,13 @@ var entry = [{
4017
4098
  action: cmdOptions => {
4018
4099
  run_1('upload', cmdOptions);
4019
4100
  }
4101
+ }, {
4102
+ command: 'sourcemap',
4103
+ description: '获取sourcemap',
4104
+ options: [],
4105
+ action: cmdOptions => {
4106
+ run_1('sourcemap', cmdOptions);
4107
+ }
4020
4108
  }, {
4021
4109
  command: 'cloud-dev',
4022
4110
  description: '云函数开发',
@@ -4040,7 +4128,7 @@ var entry = [{
4040
4128
 
4041
4129
  var require$$12 = {
4042
4130
  name: "@tmsfe/tmskit",
4043
- version: "0.0.38",
4131
+ version: "0.0.39",
4044
4132
  description: "tmskit",
4045
4133
  main: "dist/index.cjs",
4046
4134
  bin: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmsfe/tmskit",
3
- "version": "0.0.38",
3
+ "version": "0.0.39",
4
4
  "description": "tmskit",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {
@@ -31,7 +31,10 @@ function updateMainPackages(appJson, mainPackages = []) {
31
31
  process.exit(-1);
32
32
  }
33
33
  subpackage.pages.forEach((page) => {
34
- appJson.pages.push(`${subpackage.root}/${page}`);
34
+ const pagePath = `${subpackage.root}/${page}`;
35
+ if (!appJson.pages.includes(pagePath)) {
36
+ appJson.pages.push(pagePath);
37
+ }
35
38
  });
36
39
  if (subpackage.plugins) {
37
40
  Object.assign(appJson.plugins, subpackage.plugins);
package/src/core/mpCi.js CHANGED
@@ -114,8 +114,22 @@ 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
+ };
117
130
  module.exports = {
118
131
  buildMpNpm,
119
132
  previewMp,
120
133
  uploadMp,
134
+ getDevSourceMap,
121
135
  };
package/src/entry.js CHANGED
@@ -81,6 +81,15 @@ 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
+ },
84
93
  {
85
94
  command: 'cloud-dev',
86
95
  description: '云函数开发',
@@ -5,6 +5,7 @@ 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');
8
9
  const cloudLink = require('./cloud/link');
9
10
  const cloudDev = require('./cloud/dev');
10
11
  const { fail, info } = require('../../utils/log');
@@ -121,6 +122,10 @@ function otherCommands(tmsConfig, commandName, cmdOptions) {
121
122
  upload(tmsConfig, cmdOptions);
122
123
  report('run:upload', { appName: tmsConfig.appName });
123
124
  return;
125
+ case 'sourcemap':
126
+ sourcemap(tmsConfig);
127
+ report('run:sourcemap', { appName: tmsConfig.appName });
128
+ return;
124
129
  default:
125
130
  return;
126
131
  }
@@ -0,0 +1,48 @@
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;