@tmsfe/tmskit 0.0.41 → 0.0.42

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里面的主包配置
@@ -1440,23 +1440,35 @@ const fixAppJson = appJson => {
1440
1440
  const {
1441
1441
  subpackages
1442
1442
  } = appJson;
1443
+ // 创建插件映射,用于检测插件配置冲突
1443
1444
  const pluginsMap = {};
1445
+ // 记录app.json顶层的插件配置
1444
1446
  Object.keys(appJson.plugins || {}).forEach(key => pluginsMap[key] = ['app.json']);
1447
+
1448
+ // 处理每个分包的配置
1445
1449
  const subps = subpackages.map(subp => {
1450
+ // 需要从分包提取到app.json顶层的数组类型字段
1446
1451
  const arrOfFileType = ['requiredBackgroundModes', 'embeddedAppIdList'];
1452
+ // 需要从分包提取到app.json顶层的对象类型字段
1447
1453
  const objOfFileType = ['preloadRule'];
1454
+
1455
+ // 遍历分包中的每个配置项
1448
1456
  Object.keys(subp).forEach(key => {
1457
+ // 处理插件配置,检查是否有重复配置的插件
1449
1458
  if (key === 'plugins') {
1450
1459
  Object.keys(subp.plugins).forEach(pk => {
1460
+ // 记录每个插件被哪些地方配置
1451
1461
  pluginsMap[pk] ? pluginsMap[pk].push(`分包${subp.name}`) : pluginsMap[pk] = [`分包${subp.name}`];
1452
1462
  });
1453
1463
  }
1454
- // 分包里数组类型字段,提到appjson最上层
1464
+
1465
+ // 处理数组类型字段(如requiredBackgroundModes),合并到app.json顶层并去重
1455
1466
  if (arrOfFileType.indexOf(key) > -1) {
1456
1467
  const preVal = appJson[key];
1457
1468
  preVal ? appJson[key] = Array.from(new Set(preVal.slice(0).concat(subp[key]))) : appJson[key] = subp[key].slice(0);
1458
1469
  }
1459
- // 分包里对象类型字段,提到appjson最上层
1470
+
1471
+ // 处理对象类型字段(如preloadRule),合并到app.json顶层,已存在的键值不覆盖
1460
1472
  if (objOfFileType.indexOf(key) > -1) {
1461
1473
  const preloadRuleMap = appJson[key] || {};
1462
1474
  subp[key] && Object.keys(subp[key]).forEach(page => {
@@ -1467,9 +1479,12 @@ const fixAppJson = appJson => {
1467
1479
  appJson[key] = preloadRuleMap;
1468
1480
  }
1469
1481
  });
1482
+
1483
+ // 从分包配置中移除已提取到顶层的字段以及一些构建相关的内部字段
1470
1484
  return filterField$7(subp, [...arrOfFileType, ...objOfFileType, 'dependencies', 'path']);
1471
1485
  });
1472
- // 如果plugins重复,则错误提示
1486
+
1487
+ // 检查插件配置冲突,如果同一个插件在多处配置则报错
1473
1488
  const pluginsErrMsg = Object.keys(pluginsMap).map(pk => {
1474
1489
  if (pluginsMap[pk].length > 1) {
1475
1490
  return `${pluginsMap[pk].join(',')}重复配置plugin(${pk});`;
@@ -1479,9 +1494,44 @@ const fixAppJson = appJson => {
1479
1494
  if (pluginsErrMsg) {
1480
1495
  throw new Error(`plugins配置出现错误:${pluginsErrMsg}`);
1481
1496
  }
1497
+
1498
+ // 用处理后的分包配置更新app.json的subpackages字段
1482
1499
  appJson.subpackages = subps;
1483
1500
  };
1484
1501
 
1502
+ /**
1503
+ * 合并分包配置,保留已有分包,添加新分包
1504
+ * @param {Array} existingPackages 现有的分包配置
1505
+ * @param {Array} newPackages 新的分包配置
1506
+ * @returns {Array} 合并后的分包配置
1507
+ */
1508
+ function mergeSubPackages(existingPackages, newPackages) {
1509
+ // 创建结果数组和root到索引的映射
1510
+ const resultPackages = [...existingPackages];
1511
+ const rootMap = {};
1512
+
1513
+ // 建立现有分包的root映射
1514
+ existingPackages.forEach((pkg, index) => {
1515
+ if (pkg.root) {
1516
+ rootMap[pkg.root] = index;
1517
+ }
1518
+ });
1519
+
1520
+ // 合并新分包
1521
+ newPackages.forEach(newPkg => {
1522
+ if (!newPkg.root) return; // 忽略没有root的分包
1523
+
1524
+ if (rootMap[newPkg.root] !== undefined) {
1525
+ // 如果已存在相同root的分包,则不覆盖保留原有配置
1526
+ info$f(`保留已有分包配置, root: ${newPkg.root}, name: ${newPkg.name || '未命名'}`);
1527
+ } else {
1528
+ // 如果不存在,则添加新分包
1529
+ resultPackages.push(newPkg);
1530
+ }
1531
+ });
1532
+ return resultPackages;
1533
+ }
1534
+
1485
1535
  /**
1486
1536
  * 动态生成编译后的app.json
1487
1537
  * @param {object} tmsConfig
@@ -1494,13 +1544,14 @@ async function buildOutputAppJson$3(tmsConfig, modules) {
1494
1544
  // 获取所有模块,合并模块依赖的模块
1495
1545
  const modulesConfig = getModulesConfig(modules, tmsConfig, false);
1496
1546
  // 获取所有的分包
1497
- const subPackages = getSubPackages$3(modulesConfig);
1547
+ const newSubPackages = getSubPackages$3(modulesConfig);
1498
1548
  // 获取app.json的配置
1499
- let appJson = getAppJsonContent(resolve$g('./app.json'));
1549
+ let appJson = getAppJsonContent(resolve$h('./app.json'));
1500
1550
 
1501
- // 更新app.json中的subpackages
1502
- appJson.subpackages = subPackages;
1503
- appJson.subpackages.sort((item1, item2) => item1.name.localeCompare(item2.name));
1551
+ // 保留已有分包配置,合并新的分包配置
1552
+ const existingSubpackages = appJson.subpackages || [];
1553
+ appJson.subpackages = mergeSubPackages(existingSubpackages, newSubPackages);
1554
+ appJson.subpackages.sort((item1, item2) => item1.root.localeCompare(item2.root));
1504
1555
 
1505
1556
  // 处理appJson中重复||冲突的地方
1506
1557
  fixAppJson(appJson);
@@ -1510,7 +1561,7 @@ async function buildOutputAppJson$3(tmsConfig, modules) {
1510
1561
  // 模板渲染:先将 app.json 转为字符串,然后通过 preprocess 渲染
1511
1562
  const appJsonStr = JSON.stringify(appJson, null, 2);
1512
1563
  const preprocessedStr = pp$1.preprocess(appJsonStr, tmsConfig.templateVars || {}, 'json');
1513
- fs$e.writeFileSync(resolve$g(`${tmsConfig.outputDir}/app.json`), preprocessedStr, 'utf8');
1564
+ fs$e.writeFileSync(resolve$h(`${tmsConfig.outputDir}/app.json`), preprocessedStr, 'utf8');
1514
1565
  appJson = JSON.parse(preprocessedStr);
1515
1566
  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
1567
  var _tmsConfig$hooks2;
@@ -1521,12 +1572,12 @@ async function buildOutputAppJson$3(tmsConfig, modules) {
1521
1572
  appJson,
1522
1573
  isDev: global$a.getData('isDev')
1523
1574
  }));
1524
- report$8('hooks:updateAppJson');
1575
+ report$9('hooks:updateAppJson');
1525
1576
  }
1526
1577
  return appJson;
1527
1578
  } catch (e) {
1528
- handleError$7(`生成app.json出现错误: ${e}`);
1529
- info$e(e);
1579
+ handleError$8(`生成app.json出现错误: ${e}`);
1580
+ info$f(e);
1530
1581
  }
1531
1582
  }
1532
1583
  var buildAppJson = {
@@ -1541,16 +1592,16 @@ const crypto$2 = require$$1__default$6;
1541
1592
  const {
1542
1593
  downloadRepoForGit,
1543
1594
  pullRepoForGit,
1544
- resolve: resolve$f
1595
+ resolve: resolve$g
1545
1596
  } = widgets;
1546
1597
  const {
1547
1598
  fail: fail$5,
1548
- info: info$d
1599
+ info: info$e
1549
1600
  } = log$1;
1550
1601
  const fs$d = require$$0__default$1;
1551
1602
  const shelljs$5 = require$$0__default$2;
1552
1603
  const {
1553
- handleError: handleError$6
1604
+ handleError: handleError$7
1554
1605
  } = handleError_1;
1555
1606
  const {
1556
1607
  global: global$9
@@ -1642,7 +1693,7 @@ async function cloneModules$1(sourceDir, targetDir, modules) {
1642
1693
  }) => fn(...Object.keys(cParams).map(key => cParams[key])));
1643
1694
  return Promise.all(callArr);
1644
1695
  }).catch(e => {
1645
- handleError$6(`下载代码${params.httpRepoUrl}出现错误:${e}`);
1696
+ handleError$7(`下载代码${params.httpRepoUrl}出现错误:${e}`);
1646
1697
  }));
1647
1698
  });
1648
1699
  await Promise.all(arrPromises);
@@ -1686,9 +1737,9 @@ function collectDownLoadTasksMap(sourceDir, targetDir, modules) {
1686
1737
  // 根据gitUrl与branch计算md5
1687
1738
  const md5Key = md5ByGitUrlBranch(gitUrl, branch);
1688
1739
  // git源码临时存在的源目录
1689
- const sourcePath = resolve$f(sourceDir, md5Key);
1740
+ const sourcePath = resolve$g(sourceDir, md5Key);
1690
1741
  // 模块源码要放到目标目录
1691
- const targetPath = resolve$f(targetDir, path);
1742
+ const targetPath = resolve$g(targetDir, path);
1692
1743
  // 从git源码仓库中找到模块源码路径 (一个仓库存在存放多个模块的情况)
1693
1744
  const sourceModulePath = gitPath ? `${sourcePath}/${gitPath}` : sourcePath;
1694
1745
 
@@ -1713,15 +1764,15 @@ function collectDownLoadTasksMap(sourceDir, targetDir, modules) {
1713
1764
  let promiseTask;
1714
1765
  if (fs$d.existsSync(sourcePath) && fs$d.existsSync(`${sourcePath}/.git`)) {
1715
1766
  promiseTask = (gitUrl, sourcePath, branch, httpRepoUrl) => {
1716
- info$d(`git pull:${httpRepoUrl} --branch: ${branch}`);
1767
+ info$e(`git pull:${httpRepoUrl} --branch: ${branch}`);
1717
1768
  return pullRepoForGit(sourcePath, branch).catch(e => {
1718
- info$d(`pull代码失败:${e}, 开始git clone: ${httpRepoUrl}:${branch}`);
1769
+ info$e(`pull代码失败:${e}, 开始git clone: ${httpRepoUrl}:${branch}`);
1719
1770
  return downloadRepoForGit(gitUrl, sourcePath, branch);
1720
1771
  });
1721
1772
  };
1722
1773
  } else {
1723
1774
  promiseTask = (gitUrl, sourcePath, branch, httpRepoUrl) => {
1724
- info$d(`git clone: ${httpRepoUrl}`);
1775
+ info$e(`git clone: ${httpRepoUrl}`);
1725
1776
  return downloadRepoForGit(gitUrl, sourcePath, branch);
1726
1777
  };
1727
1778
  }
@@ -1895,10 +1946,30 @@ const uploadMp = async (params = {}) => {
1895
1946
  onProgressUpdate: () => {}
1896
1947
  });
1897
1948
  };
1898
- var mpCi$2 = {
1949
+ const getDevSourceMap = async (params = {}) => {
1950
+ const {
1951
+ appId,
1952
+ projectPath,
1953
+ privateKey,
1954
+ robot,
1955
+ sourceMapSavePath
1956
+ } = params;
1957
+ const project = await getMpCi({
1958
+ appId,
1959
+ projectPath,
1960
+ privateKey
1961
+ });
1962
+ return await ci.getDevSourceMap({
1963
+ project,
1964
+ robot,
1965
+ sourceMapSavePath
1966
+ });
1967
+ };
1968
+ var mpCi$3 = {
1899
1969
  buildMpNpm: buildMpNpm$1,
1900
1970
  previewMp,
1901
- uploadMp
1971
+ uploadMp,
1972
+ getDevSourceMap
1902
1973
  };
1903
1974
 
1904
1975
  const fs$c = require$$0__default$1;
@@ -1952,7 +2023,7 @@ const {
1952
2023
  npmInstall: npmInstall$2
1953
2024
  } = widgets;
1954
2025
  const {
1955
- handleError: handleError$5
2026
+ handleError: handleError$6
1956
2027
  } = handleError_1;
1957
2028
  const {
1958
2029
  global: global$8
@@ -2074,7 +2145,7 @@ const npmInstallAll$1 = async (subPackages, contextDir, cacheDir) => {
2074
2145
  }) => fn(...Object.keys(cParams).map(key => cParams[key])));
2075
2146
  return Promise.all(callArr);
2076
2147
  }).catch(e => {
2077
- handleError$5(`npm install ${params.packageJsonPath}出现错误:${e}`, true);
2148
+ handleError$6(`npm install ${params.packageJsonPath}出现错误:${e}`, true);
2078
2149
  }));
2079
2150
  });
2080
2151
  await Promise.all(arrPromises);
@@ -2175,13 +2246,13 @@ var md5 = {
2175
2246
  const fs$9 = require$$0__default$1;
2176
2247
  const semver$1 = require$$1__default$8;
2177
2248
  const {
2178
- resolve: resolve$e,
2249
+ resolve: resolve$f,
2179
2250
  getAbsolutePath: getAbsolutePath$5
2180
2251
  } = widgets;
2181
2252
  const path$9 = require$$1__default$1;
2182
2253
  const shelljs$4 = require$$0__default$2;
2183
2254
  const {
2184
- handleError: handleError$4
2255
+ handleError: handleError$5
2185
2256
  } = handleError_1;
2186
2257
  const getLatestVersion = npmName => {
2187
2258
  const data = shelljs$4.exec(`npm view ${npmName} version`);
@@ -2197,7 +2268,7 @@ function collectPackageJson(subPackages, cwd, outputDir) {
2197
2268
  // 1.1根目录的package.json
2198
2269
  const packageArr = [{
2199
2270
  srcPackageDir: path$9.join(cwd, packageJsonName),
2200
- destNpmDir: resolve$e(outputDir, 'node_modules')
2271
+ destNpmDir: resolve$f(outputDir, 'node_modules')
2201
2272
  }];
2202
2273
  // 1.2模块的package.json
2203
2274
  subPackages.forEach(item => {
@@ -2205,7 +2276,7 @@ function collectPackageJson(subPackages, cwd, outputDir) {
2205
2276
  if (fs$9.existsSync(srcPackageDir)) {
2206
2277
  packageArr.push({
2207
2278
  srcPackageDir,
2208
- destNpmDir: resolve$e(outputDir, item.root, 'node_modules')
2279
+ destNpmDir: resolve$f(outputDir, item.root, 'node_modules')
2209
2280
  });
2210
2281
  }
2211
2282
  });
@@ -2220,7 +2291,7 @@ function readPackageDependencies(srcPackageDir) {
2220
2291
  const json = packageJson ? JSON.parse(packageJson) : {};
2221
2292
  dependencies = (json === null || json === void 0 ? void 0 : json.dependencies) || {};
2222
2293
  } catch (e) {
2223
- handleError$4(`解析${srcPackageDir}报错,请检查是否是正确的json配置项 ${e}`);
2294
+ handleError$5(`解析${srcPackageDir}报错,请检查是否是正确的json配置项 ${e}`);
2224
2295
  }
2225
2296
  return dependencies;
2226
2297
  }
@@ -2276,14 +2347,14 @@ const fs$8 = require$$0__default$1;
2276
2347
  const path$8 = require$$1__default$1;
2277
2348
  const io$1 = io$3;
2278
2349
  const {
2279
- createTask: createTask$4,
2280
- resolve: resolve$d,
2350
+ createTask: createTask$5,
2351
+ resolve: resolve$e,
2281
2352
  getAbsolutePath: getAbsolutePath$4,
2282
2353
  filterField: filterField$6
2283
2354
  } = widgets;
2284
2355
  const {
2285
2356
  buildMpNpm
2286
- } = mpCi$2;
2357
+ } = mpCi$3;
2287
2358
  const {
2288
2359
  global: global$7
2289
2360
  } = global_1;
@@ -2298,7 +2369,7 @@ const {
2298
2369
  npmInstallAll
2299
2370
  } = npm;
2300
2371
  const {
2301
- info: info$c
2372
+ info: info$d
2302
2373
  } = log$1;
2303
2374
  const {
2304
2375
  fileMd5
@@ -2312,41 +2383,41 @@ async function install$3(tmsConfig, subPackages, useCache = true) {
2312
2383
  // 加npm install之前的钩子
2313
2384
  if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforeNpmInstall) === 'function') {
2314
2385
  var _tmsConfig$hooks2;
2315
- info$c('—————— 执行beforeNpmInstall ————');
2386
+ info$d('—————— 执行beforeNpmInstall ————');
2316
2387
  await (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.beforeNpmInstall({
2317
2388
  tmsConfig: filterField$6(tmsConfig, ['gitAccount']),
2318
2389
  cmdOptions: global$7.getData('cmdOptions')
2319
2390
  }));
2320
- info$c('—————— 执行beforeNpmInstall 完成 ————');
2391
+ info$d('—————— 执行beforeNpmInstall 完成 ————');
2321
2392
  }
2322
- const npmInstallRes = await createTask$4(npmInstall$1, '小程序 开始npm install', '小程序npm install 完成')(tmsConfig, subPackages, useCache);
2393
+ const npmInstallRes = await createTask$5(npmInstall$1, '小程序 开始npm install', '小程序npm install 完成')(tmsConfig, subPackages, useCache);
2323
2394
 
2324
2395
  // 如果npm install 没有命中缓存,则说明node_module有更新,此时必须构建miniprogram_npm
2325
2396
  if (!npmInstallRes.isCache) {
2326
2397
  // 构建miniprogram_npm, 不使用缓存
2327
- await createTask$4(mpCiInstall, '开始构建miniprogram_npm', '构建miniprogram_npm 完成')(tmsConfig, subPackages, false);
2398
+ await createTask$5(mpCiInstall, '开始构建miniprogram_npm', '构建miniprogram_npm 完成')(tmsConfig, subPackages, false);
2328
2399
  } else {
2329
2400
  // 构建miniprogram_npm
2330
- await createTask$4(mpCiInstall, '开始构建miniprogram_npm', '构建miniprogram_npm 完成')(tmsConfig, subPackages, useCache);
2401
+ await createTask$5(mpCiInstall, '开始构建miniprogram_npm', '构建miniprogram_npm 完成')(tmsConfig, subPackages, useCache);
2331
2402
  }
2332
2403
  shelljs$3.cd(cwd);
2333
2404
  }
2334
2405
  async function npmInstall$1(tmsConfig, subPackages, useCache) {
2335
2406
  // 如果依赖没有更新和使用缓存数据(则命中缓存)
2336
- if (!isDependenciesUpdate(subPackages, resolve$d('./'), tmsConfig.outputDir) && useCache) {
2337
- info$c('node_modules命中缓存');
2407
+ if (!isDependenciesUpdate(subPackages, resolve$e('./'), tmsConfig.outputDir) && useCache) {
2408
+ info$d('node_modules命中缓存');
2338
2409
  return {
2339
2410
  isCache: true
2340
2411
  };
2341
2412
  }
2342
2413
  // 拷贝模块的package.json到编译输出目录
2343
2414
  subPackages.forEach(item => {
2344
- const outputModuleDir = resolve$d(`${tmsConfig.outputDir}/${item.root}`);
2415
+ const outputModuleDir = resolve$e(`${tmsConfig.outputDir}/${item.root}`);
2345
2416
  io$1.ensureDirExist(outputModuleDir);
2346
2417
  const modulePackagePath = `${getAbsolutePath$4(item.path)}/package.json`;
2347
2418
  if (fs$8.existsSync(modulePackagePath)) shelljs$3.cp('-Rf', modulePackagePath, outputModuleDir);
2348
2419
  });
2349
- await npmInstallAll(subPackages, resolve$d(tmsConfig.outputDir), NODE_MODULES_DIR$1);
2420
+ await npmInstallAll(subPackages, resolve$e(tmsConfig.outputDir), NODE_MODULES_DIR$1);
2350
2421
  return {
2351
2422
  isCache: false
2352
2423
  };
@@ -2355,12 +2426,12 @@ async function npmInstall$1(tmsConfig, subPackages, useCache) {
2355
2426
  // 构建miniprogram_npm
2356
2427
  async function mpCiInstall(tmsConfig, subPackages, useCache) {
2357
2428
  const packageJsonFiles = [];
2358
- const rootPackFile = resolve$d(`${tmsConfig.outputDir}/package.json`);
2429
+ const rootPackFile = resolve$e(`${tmsConfig.outputDir}/package.json`);
2359
2430
  if (fs$8.existsSync(rootPackFile)) {
2360
2431
  packageJsonFiles.push(rootPackFile);
2361
2432
  }
2362
2433
  subPackages.forEach(item => {
2363
- const packageJsonFile = resolve$d(`${tmsConfig.outputDir}/${item.root}/package.json`);
2434
+ const packageJsonFile = resolve$e(`${tmsConfig.outputDir}/${item.root}/package.json`);
2364
2435
  if (fs$8.existsSync(packageJsonFile)) {
2365
2436
  packageJsonFiles.push(packageJsonFile);
2366
2437
  }
@@ -2374,7 +2445,7 @@ async function mpCiInstall(tmsConfig, subPackages, useCache) {
2374
2445
  let flag = true;
2375
2446
  await Promise.all(packageJsonFiles.map(async item => {
2376
2447
  const packageDir = path$8.dirname(item);
2377
- const mpDir = resolve$d(`${packageDir}/miniprogram_npm`);
2448
+ const mpDir = resolve$e(`${packageDir}/miniprogram_npm`);
2378
2449
  const md5Value = await getMNPMd5(packageDir);
2379
2450
  const preCache = getCache(mpDir, 'miniprogram_npm');
2380
2451
  // console.log('miniprogram_npm', preCache, md5Value);
@@ -2386,14 +2457,14 @@ async function mpCiInstall(tmsConfig, subPackages, useCache) {
2386
2457
  isCache = flag;
2387
2458
  }
2388
2459
  if (isCache) {
2389
- info$c('miniprogram_npm命中缓存');
2460
+ info$d('miniprogram_npm命中缓存');
2390
2461
  return;
2391
2462
  }
2392
2463
 
2393
2464
  // 即将构建,在cache中标记开始
2394
2465
  await Promise.all(packageJsonFiles.map(async item => {
2395
2466
  const packageDir = path$8.dirname(item);
2396
- const mpDir = resolve$d(`${packageDir}/miniprogram_npm`);
2467
+ const mpDir = resolve$e(`${packageDir}/miniprogram_npm`);
2397
2468
  setCache(mpDir, 'miniprogram_npm', {
2398
2469
  md5: '',
2399
2470
  status: statusMap.doing
@@ -2401,14 +2472,14 @@ async function mpCiInstall(tmsConfig, subPackages, useCache) {
2401
2472
  }));
2402
2473
  await buildMpNpm({
2403
2474
  appId: tmsConfig.appId,
2404
- projectPath: resolve$d('./'),
2475
+ projectPath: resolve$e('./'),
2405
2476
  privateKey: tmsConfig.privateKey
2406
2477
  });
2407
2478
 
2408
2479
  // 构建成功后,计算md5写入cache
2409
2480
  await Promise.all(packageJsonFiles.map(async item => {
2410
2481
  const packageDir = path$8.dirname(item);
2411
- const mpDir = resolve$d(`${packageDir}/miniprogram_npm`);
2482
+ const mpDir = resolve$e(`${packageDir}/miniprogram_npm`);
2412
2483
  const md5Value = await getMNPMd5(packageDir);
2413
2484
  setCache(mpDir, 'miniprogram_npm', {
2414
2485
  md5: md5Value,
@@ -2442,8 +2513,8 @@ const shelljs$2 = require$$0__default$2;
2442
2513
  const fs$7 = require$$0__default$1;
2443
2514
  const io = io$3;
2444
2515
  const {
2445
- resolve: resolve$c,
2446
- createTask: createTask$3
2516
+ resolve: resolve$d,
2517
+ createTask: createTask$4
2447
2518
  } = widgets;
2448
2519
  const {
2449
2520
  buildOutputAppJson: buildOutputAppJson$2
@@ -2461,7 +2532,7 @@ const {
2461
2532
  } = tmsMpconfig.exports;
2462
2533
  const {
2463
2534
  fail: fail$4,
2464
- info: info$b
2535
+ info: info$c
2465
2536
  } = log$1;
2466
2537
  const install$2 = install_1;
2467
2538
 
@@ -2473,17 +2544,17 @@ const install$2 = install_1;
2473
2544
  * @returns
2474
2545
  */
2475
2546
  const cpFilesToOutput = function (tmsConfig, defaultFiles) {
2476
- const outputDir = resolve$c(tmsConfig.outputDir);
2547
+ const outputDir = resolve$d(tmsConfig.outputDir);
2477
2548
  io.ensureDirExist(outputDir);
2478
2549
  defaultFiles.forEach(item => {
2479
- if (fs$7.existsSync(resolve$c(item))) {
2480
- shelljs$2.cp('-rf', resolve$c(item), resolve$c(tmsConfig.outputDir, item));
2550
+ if (fs$7.existsSync(resolve$d(item))) {
2551
+ shelljs$2.cp('-rf', resolve$d(item), resolve$d(tmsConfig.outputDir, item));
2481
2552
  }
2482
2553
  });
2483
2554
  };
2484
2555
  async function task(tmsConfig, targetModules) {
2485
2556
  // 下载和移动代码
2486
- await createTask$3(cloneModules, '开始下载模块代码', '下载模块代码码完成')(MODULE_CODE_DIR$1, resolve$c('./'), targetModules);
2557
+ await createTask$4(cloneModules, '开始下载模块代码', '下载模块代码码完成')(MODULE_CODE_DIR$1, resolve$d('./'), targetModules);
2487
2558
 
2488
2559
  // 获取所有模块,合并模块依赖的模块
2489
2560
  const newModules = getModulesByMergeDepModules$2(tmsConfig, targetModules, true);
@@ -2491,13 +2562,13 @@ async function task(tmsConfig, targetModules) {
2491
2562
  const newSubPackages = getSubPackages$2(newModules);
2492
2563
 
2493
2564
  // 拷贝相关配置文件到输出目录
2494
- await createTask$3(cpFilesToOutput, '开始拷贝文件到编译输出目录', '拷贝文件到编译输出目录完成')(tmsConfig, DEFAULT_COPY_CONFIG$1);
2565
+ await createTask$4(cpFilesToOutput, '开始拷贝文件到编译输出目录', '拷贝文件到编译输出目录完成')(tmsConfig, DEFAULT_COPY_CONFIG$1);
2495
2566
 
2496
2567
  // install
2497
2568
  await install$2(tmsConfig, newSubPackages, true);
2498
2569
 
2499
2570
  // 动态生成编译后的app.json;
2500
- await createTask$3(buildOutputAppJson$2, '开始生成编译后的app.json', '生成编译后的app.json完成')(tmsConfig, newModules);
2571
+ await createTask$4(buildOutputAppJson$2, '开始生成编译后的app.json', '生成编译后的app.json完成')(tmsConfig, newModules);
2501
2572
  return {
2502
2573
  modules: newModules,
2503
2574
  subPackages: newSubPackages
@@ -2510,7 +2581,7 @@ async function init$3(tmsConfig, targetModules) {
2510
2581
  } catch (error) {
2511
2582
  const errMsg = typeof error === 'object' ? error.message : error;
2512
2583
  fail$4(`初始化流程出现错误: ${errMsg}`);
2513
- info$b('详细的错误信息', error);
2584
+ info$c('详细的错误信息', error);
2514
2585
  process.exit(1);
2515
2586
  }
2516
2587
  }
@@ -2636,15 +2707,15 @@ const minimatch = require$$2__default;
2636
2707
  const gulpif = require$$3__default$1;
2637
2708
  const mpProjectJson = mpProjectJson_1;
2638
2709
  const {
2639
- resolve: resolve$b
2710
+ resolve: resolve$c
2640
2711
  } = widgets;
2641
2712
  const through = require$$0__default$8;
2642
2713
  const {
2643
2714
  fail: fail$3
2644
2715
  } = log$1;
2645
2716
  const getTargetFile$2 = (sourceFile, module, outputDir) => {
2646
- const sourceFileRelativeModule = path$6.relative(resolve$b(module.from), sourceFile);
2647
- const targetFile = resolve$b(outputDir, module.to, sourceFileRelativeModule);
2717
+ const sourceFileRelativeModule = path$6.relative(resolve$c(module.from), sourceFile);
2718
+ const targetFile = resolve$c(outputDir, module.to, sourceFileRelativeModule);
2648
2719
  return targetFile;
2649
2720
  };
2650
2721
  const addPlugins = function (tmsConfig, srcPipe, pluginParams) {
@@ -2854,12 +2925,12 @@ const {
2854
2925
  series: series$2
2855
2926
  } = require$$0__default$9;
2856
2927
  const {
2857
- info: info$a,
2928
+ info: info$b,
2858
2929
  warn: warn$1,
2859
2930
  fail: fail$2
2860
2931
  } = log$1;
2861
2932
  const {
2862
- resolve: resolve$a,
2933
+ resolve: resolve$b,
2863
2934
  filterField: filterField$5
2864
2935
  } = widgets;
2865
2936
  const {
@@ -2868,7 +2939,7 @@ const {
2868
2939
  const {
2869
2940
  checkPackageVersion
2870
2941
  } = checkDependencies;
2871
- const report$7 = report_1;
2942
+ const report$8 = report_1;
2872
2943
  const TIP_MAP = {
2873
2944
  'package.json': {
2874
2945
  tip: '依赖版本有变动,请重新执行tmskit run dev',
@@ -2895,14 +2966,14 @@ const logTip = (fileName, sourceFile, targetFile, tipMap) => {
2895
2966
  return;
2896
2967
  }
2897
2968
  }
2898
- info$a(`${fileName}有更新`);
2969
+ info$b(`${fileName}有更新`);
2899
2970
  } catch (e) {
2900
2971
  fail$2(`${sourceFile}文件更新提示出现错误: ${e.message}`);
2901
2972
  }
2902
2973
  };
2903
2974
  const getTargetFile$1 = (sourceFile, module, outputDir) => {
2904
- const sourceFileRelativeModule = path$4.relative(resolve$a(module.from), sourceFile);
2905
- return resolve$a(outputDir, module.to, sourceFileRelativeModule);
2975
+ const sourceFileRelativeModule = path$4.relative(resolve$b(module.from), sourceFile);
2976
+ return resolve$b(outputDir, module.to, sourceFileRelativeModule);
2906
2977
  };
2907
2978
  var watch_1 = function (globValue, watchOptions, callback, module) {
2908
2979
  watch$2(globValue, {
@@ -2919,7 +2990,7 @@ var watch_1 = function (globValue, watchOptions, callback, module) {
2919
2990
  targetFile = path$4.join(module.to, filePath);
2920
2991
  }
2921
2992
  if (vinyl.event === 'unlink' || vinyl.event === 'unlinkDir') {
2922
- info$a(`删除${sourceFileName}`);
2993
+ info$b(`删除${sourceFileName}`);
2923
2994
  shellJs$2.rm('-rf', targetFile);
2924
2995
  updateFileHook(tmsConfig, sourceFile, targetFile, vinyl.event);
2925
2996
  return;
@@ -2968,7 +3039,7 @@ async function updateFileHook(tmsConfig, sourceFile, targetFile, type) {
2968
3039
  targetFile,
2969
3040
  type
2970
3041
  });
2971
- report$7('hooks:updateFile');
3042
+ report$8('hooks:updateFile');
2972
3043
  }
2973
3044
  }
2974
3045
 
@@ -2981,7 +3052,7 @@ const {
2981
3052
  series: series$1
2982
3053
  } = require$$0__default$9;
2983
3054
  const {
2984
- resolve: resolve$9,
3055
+ resolve: resolve$a,
2985
3056
  mergeMap,
2986
3057
  filterField: filterField$4,
2987
3058
  getAbsolutePath: getAbsolutePath$3
@@ -2995,9 +3066,9 @@ const {
2995
3066
  const compile = compile$1;
2996
3067
  const watch$1 = watch_1;
2997
3068
  const {
2998
- info: info$9
3069
+ info: info$a
2999
3070
  } = log$1;
3000
- const report$6 = report_1;
3071
+ const report$7 = report_1;
3001
3072
  const {
3002
3073
  global: global$5
3003
3074
  } = global_1;
@@ -3007,12 +3078,12 @@ var dev$4 = async (tmsConfig, modules, isDev = true) => {
3007
3078
 
3008
3079
  // 监听根目录的文件
3009
3080
  mergeMap(compileTasksMap, compile(tmsConfig, {
3010
- glob: DEFAULT_COPY_CONFIG.map(item => resolve$9(item)),
3081
+ glob: DEFAULT_COPY_CONFIG.map(item => resolve$a(item)),
3011
3082
  module: {
3012
- from: resolve$9(),
3013
- to: resolve$9(tmsConfig.outputDir)
3083
+ from: resolve$a(),
3084
+ to: resolve$a(tmsConfig.outputDir)
3014
3085
  },
3015
- destPath: resolve$9(tmsConfig.outputDir),
3086
+ destPath: resolve$a(tmsConfig.outputDir),
3016
3087
  srcOption: {
3017
3088
  allowEmpty: true
3018
3089
  },
@@ -3048,7 +3119,7 @@ var dev$4 = async (tmsConfig, modules, isDev = true) => {
3048
3119
  ...moduleItem
3049
3120
  };
3050
3121
  const srcModulePath = getAbsolutePath$3(moduleItem.path);
3051
- const buildModulePath = resolve$9(tmsConfig.outputDir, moduleItem.modulePath);
3122
+ const buildModulePath = resolve$a(tmsConfig.outputDir, moduleItem.modulePath);
3052
3123
  if (isDev) {
3053
3124
  // 监听模块配置文件
3054
3125
  watch$1([`${srcModulePath}/**/module.config.json`], {
@@ -3062,9 +3133,9 @@ var dev$4 = async (tmsConfig, modules, isDev = true) => {
3062
3133
  const newPath = getAbsolutePath$3(ePath, srcModulePath);
3063
3134
  const ext = path$3.extname(ePath).slice(1);
3064
3135
  if (ext) {
3065
- return `!${resolve$9(srcModulePath, newPath)}`;
3136
+ return `!${resolve$a(srcModulePath, newPath)}`;
3066
3137
  }
3067
- return `!${resolve$9(srcModulePath, newPath)}/**/*`;
3138
+ return `!${resolve$a(srcModulePath, newPath)}/**/*`;
3068
3139
  });
3069
3140
  const moduleConfigPath = `${srcModulePath}/**/module.config.json`;
3070
3141
  const moduleConfigGlob = tmsConfig.isKeepModuleConfig ? `${moduleConfigPath}` : `!${moduleConfigPath}`;
@@ -3113,7 +3184,7 @@ var dev$4 = async (tmsConfig, modules, isDev = true) => {
3113
3184
  let eTime;
3114
3185
  const spinner = ora$1();
3115
3186
  function start(cb) {
3116
- info$9('启动编译...');
3187
+ info$a('启动编译...');
3117
3188
  spinner.start();
3118
3189
  sTime = new Date().getTime();
3119
3190
  cb();
@@ -3122,12 +3193,12 @@ var dev$4 = async (tmsConfig, modules, isDev = true) => {
3122
3193
  var _tmsConfig$hooks;
3123
3194
  if (isDev) {
3124
3195
  // 监听app.json
3125
- watch$1([resolve$9('app.json')], {
3196
+ watch$1([resolve$a('app.json')], {
3126
3197
  ignoreInitial: false,
3127
3198
  events: watchEvents
3128
3199
  }, async () => await buildOutputAppJson$1(tmsConfig, modules, isDev), {
3129
- from: resolve$9(),
3130
- to: resolve$9(tmsConfig.outputDir)
3200
+ from: resolve$a(),
3201
+ to: resolve$a(tmsConfig.outputDir)
3131
3202
  });
3132
3203
  // 监听其他文件
3133
3204
  compileTasksMap.forEach(({
@@ -3151,7 +3222,7 @@ var dev$4 = async (tmsConfig, modules, isDev = true) => {
3151
3222
  modules,
3152
3223
  cmdOptions: global$5.getData('cmdOptions')
3153
3224
  }));
3154
- report$6('hooks:afterCompile');
3225
+ report$7('hooks:afterCompile');
3155
3226
  }
3156
3227
  spinner.succeed(chalk$3.green(`首次编译完成, 耗时${eTime / 1000}s, 微信开发者工具打开项目即可预览。`));
3157
3228
  spinner.stop();
@@ -3170,7 +3241,7 @@ var dev$4 = async (tmsConfig, modules, isDev = true) => {
3170
3241
  const shelljs$1 = require$$0__default$2;
3171
3242
  const compileDev = dev$4;
3172
3243
  const {
3173
- resolve: resolve$8,
3244
+ resolve: resolve$9,
3174
3245
  filterField: filterField$3
3175
3246
  } = widgets;
3176
3247
  const init$2 = init_1;
@@ -3182,7 +3253,7 @@ const {
3182
3253
  getSubPackages: getSubPackages$1
3183
3254
  } = tmsMpconfig.exports;
3184
3255
  const {
3185
- info: info$8
3256
+ info: info$9
3186
3257
  } = log$1;
3187
3258
  const {
3188
3259
  global: global$4
@@ -3191,7 +3262,7 @@ const {
3191
3262
  MODULE_CODE_DIR,
3192
3263
  NODE_MODULES_DIR
3193
3264
  } = constant;
3194
- const report$5 = report_1;
3265
+ const report$6 = report_1;
3195
3266
  // const { recommendVersion } = require('../../../core/recommendVersion');
3196
3267
 
3197
3268
  // 用户编译分包时,需要将dist中其他分包(主包不能删除)的内容删除,否则其他分包的内容混入到主包(导致主包的体积超2M)
@@ -3203,7 +3274,7 @@ function delOtherPackages(tmsConfig, targetSubPackages) {
3203
3274
  const targetSubPackagesName = targetSubPackages.map(item => item.name);
3204
3275
  allSubPackages.forEach(item => {
3205
3276
  if (item.root && targetSubPackagesName.indexOf(item.name) === -1) {
3206
- const moduleRootDir = resolve$8(`${tmsConfig.outputDir}/${item.root}`);
3277
+ const moduleRootDir = resolve$9(`${tmsConfig.outputDir}/${item.root}`);
3207
3278
  shelljs$1.rm('-rf', `${moduleRootDir}/*`, {
3208
3279
  silent: true
3209
3280
  });
@@ -3218,7 +3289,7 @@ async function dev$3(tmsConfig, targetModules) {
3218
3289
  noCache
3219
3290
  } = global$4.getData('cmdOptions');
3220
3291
  if (noCache) {
3221
- shelljs$1.rm('-rf', resolve$8(tmsConfig.outputDir));
3292
+ shelljs$1.rm('-rf', resolve$9(tmsConfig.outputDir));
3222
3293
  shelljs$1.rm('-rf', MODULE_CODE_DIR);
3223
3294
  shelljs$1.rm('-rf', NODE_MODULES_DIR);
3224
3295
  }
@@ -3233,7 +3304,7 @@ async function dev$3(tmsConfig, targetModules) {
3233
3304
 
3234
3305
  // 在启动开发环境前主动执行生成 app.json
3235
3306
  await buildOutputAppJson(tmsConfig, newModules);
3236
- info$8('当前dev启动的有效模块', newModules.map(item => item.moduleName).sort());
3307
+ info$9('当前dev启动的有效模块', newModules.map(item => item.moduleName).sort());
3237
3308
  if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforeFirstCompile) === 'function') {
3238
3309
  var _tmsConfig$hooks2;
3239
3310
  await (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.beforeFirstCompile({
@@ -3242,7 +3313,7 @@ async function dev$3(tmsConfig, targetModules) {
3242
3313
  modules: newModules,
3243
3314
  cmdOptions: global$4.getData('cmdOptions')
3244
3315
  }));
3245
- report$5('hooks:beforeCompile');
3316
+ report$6('hooks:beforeCompile');
3246
3317
  }
3247
3318
  delOtherPackages(tmsConfig, subPackages);
3248
3319
  compileDev(tmsConfig, newModules, true);
@@ -3256,26 +3327,26 @@ var build$2 = async (tmsConfig, newModules, isDev) => {
3256
3327
 
3257
3328
  const shelljs = require$$0__default$2;
3258
3329
  const {
3259
- resolve: resolve$7,
3330
+ resolve: resolve$8,
3260
3331
  filterField: filterField$2
3261
3332
  } = widgets;
3262
3333
  const init$1 = init_1;
3263
3334
  const {
3264
- info: info$7
3335
+ info: info$8
3265
3336
  } = log$1;
3266
3337
  const compileBuild = build$2;
3267
- const report$4 = report_1;
3338
+ const report$5 = report_1;
3268
3339
  const {
3269
3340
  global: global$3
3270
3341
  } = global_1;
3271
3342
  async function build$1(tmsConfig, targetModules) {
3272
3343
  var _tmsConfig$hooks;
3273
3344
  // 开始构建前,清理输出目录
3274
- await shelljs.rm('-rf', resolve$7(tmsConfig.outputDir));
3345
+ await shelljs.rm('-rf', resolve$8(tmsConfig.outputDir));
3275
3346
  const {
3276
3347
  modules: newModules
3277
3348
  } = await init$1(tmsConfig, targetModules);
3278
- info$7('当前build有效模块', newModules.map(item => item.moduleName).sort());
3349
+ info$8('当前build有效模块', newModules.map(item => item.moduleName).sort());
3279
3350
  const isDev = false;
3280
3351
  if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforeFirstCompile) === 'function') {
3281
3352
  var _tmsConfig$hooks2;
@@ -3285,7 +3356,7 @@ async function build$1(tmsConfig, targetModules) {
3285
3356
  modules: newModules,
3286
3357
  cmdOptions: global$3.getData('cmdOptions')
3287
3358
  }));
3288
- report$4('hooks:beforeCompile');
3359
+ report$5('hooks:beforeCompile');
3289
3360
  }
3290
3361
  compileBuild(tmsConfig, newModules, isDev);
3291
3362
  }
@@ -3311,7 +3382,7 @@ function getAllSize$2(data = {}) {
3311
3382
  }
3312
3383
  return allSize;
3313
3384
  }
3314
- const getDesc$2 = (desc = '') => {
3385
+ const getDesc$3 = (desc = '') => {
3315
3386
  const user = getGitUser();
3316
3387
  const date = moment().format('YYYY-MM-DD HH:mm:ss');
3317
3388
  return `构建描述:${desc}; 构建人: ${user}; 构建时间:${date}`;
@@ -3329,24 +3400,24 @@ const getDetaultVersion = () => {
3329
3400
  };
3330
3401
  var utils = {
3331
3402
  getAllSize: getAllSize$2,
3332
- getDesc: getDesc$2,
3403
+ getDesc: getDesc$3,
3333
3404
  outputInfo: outputInfo$2,
3334
3405
  getDetaultVersion
3335
3406
  };
3336
3407
 
3337
- const mpCi$1 = mpCi$2;
3408
+ const mpCi$2 = mpCi$3;
3338
3409
  const fs$4 = require$$0__default$1;
3339
3410
  const {
3340
- resolve: resolve$6,
3341
- createTask: createTask$2,
3411
+ resolve: resolve$7,
3412
+ createTask: createTask$3,
3342
3413
  getAbsolutePath: getAbsolutePath$1,
3343
3414
  filterField: filterField$1
3344
3415
  } = widgets;
3345
3416
  const {
3346
- handleError: handleError$3
3417
+ handleError: handleError$4
3347
3418
  } = handleError_1;
3348
3419
  const {
3349
- info: info$6
3420
+ info: info$7
3350
3421
  } = log$1;
3351
3422
  const {
3352
3423
  global: global$2
@@ -3354,10 +3425,10 @@ const {
3354
3425
  const {
3355
3426
  getAllSize: getAllSize$1,
3356
3427
  outputInfo: outputInfo$1,
3357
- getDesc: getDesc$1
3428
+ getDesc: getDesc$2
3358
3429
  } = utils;
3359
- const report$3 = report_1;
3360
- const handleParams$1 = (tmsConfig, cmdOptions) => {
3430
+ const report$4 = report_1;
3431
+ const handleParams$2 = (tmsConfig, cmdOptions) => {
3361
3432
  const params = {
3362
3433
  ...(tmsConfig.preview ? tmsConfig.preview : {}),
3363
3434
  ...cmdOptions
@@ -3365,10 +3436,10 @@ const handleParams$1 = (tmsConfig, cmdOptions) => {
3365
3436
  return {
3366
3437
  ...params,
3367
3438
  appId: params.appId || tmsConfig.appId,
3368
- projectPath: resolve$6(tmsConfig.outputDir),
3439
+ projectPath: resolve$7(tmsConfig.outputDir),
3369
3440
  privateKey: params.privateKey || tmsConfig.privateKey,
3370
3441
  robot: params.robot || 30,
3371
- desc: params.desc || getDesc$1(params.desc),
3442
+ desc: params.desc || getDesc$2(params.desc),
3372
3443
  qrcodeOutputDest: getAbsolutePath$1(params.qrcodeOutputDest || '')
3373
3444
  };
3374
3445
  };
@@ -3381,7 +3452,7 @@ const handleParams$1 = (tmsConfig, cmdOptions) => {
3381
3452
  async function preview$1(tmsConfig, cmdOptions) {
3382
3453
  try {
3383
3454
  var _tmsConfig$hooks;
3384
- const params = handleParams$1(tmsConfig, cmdOptions);
3455
+ const params = handleParams$2(tmsConfig, cmdOptions);
3385
3456
  if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforePreview) === 'function') {
3386
3457
  var _tmsConfig$hooks2;
3387
3458
  await (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.beforePreview({
@@ -3389,10 +3460,10 @@ async function preview$1(tmsConfig, cmdOptions) {
3389
3460
  cmdOptions: global$2.getData('cmdOptions'),
3390
3461
  params
3391
3462
  }));
3392
- report$3('hooks:beforePreview');
3463
+ report$4('hooks:beforePreview');
3393
3464
  }
3394
3465
  ;
3395
- const previewRes = await createTask$2(mpCi$1.previewMp, '正在构建预览码', '构建预览码完成')({
3466
+ const previewRes = await createTask$3(mpCi$2.previewMp, '正在构建预览码', '构建预览码完成')({
3396
3467
  ...params
3397
3468
  });
3398
3469
  const allSize = getAllSize$1(previewRes);
@@ -3407,25 +3478,25 @@ async function preview$1(tmsConfig, cmdOptions) {
3407
3478
  ...previewRes
3408
3479
  });
3409
3480
  }
3410
- info$6('预览包大小:', `${allSize}k`);
3481
+ info$7('预览包大小:', `${allSize}k`);
3411
3482
  } catch (e) {
3412
3483
  console.log('详细错误:', e);
3413
- handleError$3(`预览错误: ${e.message}`, true);
3484
+ handleError$4(`预览错误: ${e.message}`, true);
3414
3485
  }
3415
3486
  }
3416
3487
  var preview_1 = preview$1;
3417
3488
 
3418
- const mpCi = mpCi$2;
3489
+ const mpCi$1 = mpCi$3;
3419
3490
  const {
3420
- resolve: resolve$5,
3421
- createTask: createTask$1,
3491
+ resolve: resolve$6,
3492
+ createTask: createTask$2,
3422
3493
  filterField
3423
3494
  } = widgets;
3424
3495
  const {
3425
- handleError: handleError$2
3496
+ handleError: handleError$3
3426
3497
  } = handleError_1;
3427
3498
  const {
3428
- info: info$5
3499
+ info: info$6
3429
3500
  } = log$1;
3430
3501
  const {
3431
3502
  global: global$1
@@ -3433,10 +3504,10 @@ const {
3433
3504
  const {
3434
3505
  getAllSize,
3435
3506
  outputInfo,
3436
- getDesc
3507
+ getDesc: getDesc$1
3437
3508
  } = utils;
3438
- const report$2 = report_1;
3439
- const handleParams = (tmsConfig, cmdOptions) => {
3509
+ const report$3 = report_1;
3510
+ const handleParams$1 = (tmsConfig, cmdOptions) => {
3440
3511
  const params = {
3441
3512
  ...(tmsConfig.upload ? tmsConfig.upload : {}),
3442
3513
  ...cmdOptions
@@ -3447,10 +3518,10 @@ const handleParams = (tmsConfig, cmdOptions) => {
3447
3518
  return {
3448
3519
  ...params,
3449
3520
  appId: params.appId || tmsConfig.appId,
3450
- projectPath: resolve$5(tmsConfig.outputDir),
3521
+ projectPath: resolve$6(tmsConfig.outputDir),
3451
3522
  privateKey: params.privateKey || tmsConfig.privateKey,
3452
3523
  robot: params.robot || 30,
3453
- desc: params.desc || getDesc(params.desc)
3524
+ desc: params.desc || getDesc$1(params.desc)
3454
3525
  };
3455
3526
  };
3456
3527
 
@@ -3462,7 +3533,7 @@ const handleParams = (tmsConfig, cmdOptions) => {
3462
3533
  async function upload$1(tmsConfig, cmdOptions) {
3463
3534
  try {
3464
3535
  var _tmsConfig$hooks;
3465
- const params = handleParams(tmsConfig, cmdOptions);
3536
+ const params = handleParams$1(tmsConfig, cmdOptions);
3466
3537
  if (typeof (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks = tmsConfig.hooks) === null || _tmsConfig$hooks === void 0 ? void 0 : _tmsConfig$hooks.beforeUpload) === 'function') {
3467
3538
  var _tmsConfig$hooks2;
3468
3539
  await (tmsConfig === null || tmsConfig === void 0 ? void 0 : (_tmsConfig$hooks2 = tmsConfig.hooks) === null || _tmsConfig$hooks2 === void 0 ? void 0 : _tmsConfig$hooks2.beforeUpload({
@@ -3470,10 +3541,10 @@ async function upload$1(tmsConfig, cmdOptions) {
3470
3541
  cmdOptions: global$1.getData('cmdOptions'),
3471
3542
  params
3472
3543
  }));
3473
- report$2('hooks:beforeUpload');
3544
+ report$3('hooks:beforeUpload');
3474
3545
  }
3475
3546
  ;
3476
- const uploadRes = await createTask$1(mpCi.uploadMp, '正在上传小程序代码', '上传小程序代码完成')({
3547
+ const uploadRes = await createTask$2(mpCi$1.uploadMp, '正在上传小程序代码', '上传小程序代码完成')({
3477
3548
  ...params
3478
3549
  });
3479
3550
  const allSize = getAllSize(uploadRes);
@@ -3483,14 +3554,65 @@ async function upload$1(tmsConfig, cmdOptions) {
3483
3554
  ...uploadRes
3484
3555
  });
3485
3556
  }
3486
- info$5(`上传包大小: ${allSize}k; 上传包版本: ${params.version}`);
3557
+ info$6(`上传包大小: ${allSize}k; 上传包版本: ${params.version}`);
3487
3558
  } catch (e) {
3488
3559
  console.log('详细错误:', e);
3489
- handleError$2(`上传错误: ${e.message}`, true);
3560
+ handleError$3(`上传错误: ${e.message}`, true);
3490
3561
  }
3491
3562
  }
3492
3563
  var upload_1 = upload$1;
3493
3564
 
3565
+ const mpCi = mpCi$3;
3566
+ const {
3567
+ resolve: resolve$5,
3568
+ createTask: createTask$1
3569
+ } = widgets;
3570
+ const {
3571
+ handleError: handleError$2
3572
+ } = handleError_1;
3573
+ const {
3574
+ info: info$5
3575
+ } = log$1;
3576
+ const {
3577
+ getDesc
3578
+ } = utils;
3579
+ const report$2 = report_1;
3580
+ const handleParams = (tmsConfig, cmdOptions) => {
3581
+ const params = {
3582
+ ...(tmsConfig.upload ? tmsConfig.upload : {}),
3583
+ ...cmdOptions
3584
+ };
3585
+ return {
3586
+ sourceMapSavePath: './sourcemap.zip',
3587
+ ...params,
3588
+ appId: params.appId || tmsConfig.appId,
3589
+ projectPath: resolve$5(tmsConfig.outputDir),
3590
+ privateKey: params.privateKey || tmsConfig.privateKey,
3591
+ robot: params.robot || 30,
3592
+ desc: params.desc || getDesc(params.desc)
3593
+ };
3594
+ };
3595
+
3596
+ /**
3597
+ * 获取sourcemap
3598
+ * @param {object} tmsConfig
3599
+ * @param {object} cmdOptions {version: '2022.28.5', desc: '', robot: 2, infoOutput: './a.txt' }
3600
+ */
3601
+ async function sourcemap$1(tmsConfig, cmdOptions) {
3602
+ try {
3603
+ const params = handleParams(tmsConfig, cmdOptions);
3604
+ report$2('sourcemap');
3605
+ await createTask$1(mpCi.getDevSourceMap, '正在获取小程序代码sourcemap', '获取小程序代码sourcemap完成')({
3606
+ ...params
3607
+ });
3608
+ info$5(`sourcemap文件已保存到${params.sourceMapSavePath}`);
3609
+ } catch (e) {
3610
+ console.log('详细错误:', e);
3611
+ handleError$2(`获取sourcemap错误: ${e.message}`, true);
3612
+ }
3613
+ }
3614
+ var sourcemap_1 = sourcemap$1;
3615
+
3494
3616
  const {
3495
3617
  resolve: resolve$4,
3496
3618
  getAbsolutePath
@@ -3824,6 +3946,7 @@ const build = build_1;
3824
3946
  const install = install_1;
3825
3947
  const preview = preview_1;
3826
3948
  const upload = upload_1;
3949
+ const sourcemap = sourcemap_1;
3827
3950
  const cloudLink = link;
3828
3951
  const cloudDev = dev$1;
3829
3952
  const {
@@ -3961,6 +4084,12 @@ function otherCommands(tmsConfig, commandName, cmdOptions) {
3961
4084
  appName: tmsConfig.appName
3962
4085
  });
3963
4086
  return;
4087
+ case 'sourcemap':
4088
+ sourcemap(tmsConfig);
4089
+ report$1('run:sourcemap', {
4090
+ appName: tmsConfig.appName
4091
+ });
4092
+ return;
3964
4093
  default:
3965
4094
  return;
3966
4095
  }
@@ -4020,6 +4149,13 @@ var entry = [{
4020
4149
  action: cmdOptions => {
4021
4150
  run_1('upload', cmdOptions);
4022
4151
  }
4152
+ }, {
4153
+ command: 'sourcemap',
4154
+ description: '获取sourcemap',
4155
+ options: [],
4156
+ action: cmdOptions => {
4157
+ run_1('sourcemap', cmdOptions);
4158
+ }
4023
4159
  }, {
4024
4160
  command: 'cloud-dev',
4025
4161
  description: '云函数开发',
@@ -4043,7 +4179,7 @@ var entry = [{
4043
4179
 
4044
4180
  var require$$12 = {
4045
4181
  name: "@tmsfe/tmskit",
4046
- version: "0.0.41",
4182
+ version: "0.0.42",
4047
4183
  description: "tmskit",
4048
4184
  main: "dist/index.cjs",
4049
4185
  bin: {