ttmg-pack 0.3.6 → 0.3.8

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.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * ==========================================
3
3
  * @Description: ttmg pack
4
- * @Version: 0.3.6
4
+ * @Version: 0.3.8
5
5
  * @Author: zhanghongyang.mocha
6
- * @Date: 2026-02-28 16:23:17
6
+ * @Date: 2026-02-28 17:27:07
7
7
  * ==========================================
8
8
  */
9
9
  'use strict';
@@ -399,15 +399,13 @@ function getMainPkgSize({ entryDir }) {
399
399
  });
400
400
  }
401
401
  function getSubpackagesRoots(entryDir) {
402
- var _a;
402
+ var _a, _b;
403
403
  const originConfigPath = path.join(entryDir, GAME_ORIGIN_CONFIG_FILE_NAME);
404
404
  try {
405
405
  const originConfig = JSON.parse(fs.readFileSync(originConfigPath, 'utf8'));
406
- // 检查是否使用了小驼峰命名
407
- if (originConfig.subPackages) {
408
- throw new Error('Error: \'subPackages\' is found in game.json. Please use \'subpackages\' (all lowercase) instead.');
409
- }
406
+ // 优先使用小写的 subpackages,如果没有,再使用小驼峰的 subPackages
410
407
  const roots = ((_a = originConfig.subpackages) === null || _a === void 0 ? void 0 : _a.map((item) => item.root)) ||
408
+ ((_b = originConfig.subPackages) === null || _b === void 0 ? void 0 : _b.map((item) => item.root)) ||
411
409
  [];
412
410
  /**
413
411
  * 移除掉头和尾的 /
@@ -415,7 +413,7 @@ function getSubpackagesRoots(entryDir) {
415
413
  return roots.map(root => root.replace(/^\/|\/$/g, ''));
416
414
  }
417
415
  catch (e) {
418
- throw e;
416
+ return [];
419
417
  }
420
418
  }
421
419
 
@@ -911,7 +909,6 @@ function checkGameJson(config) {
911
909
  const errMsg = 'Can not find game.json in game source code, please check it';
912
910
  logger.error(errMsg);
913
911
  if ((_a = config === null || config === void 0 ? void 0 : config.dev) === null || _a === void 0 ? void 0 : _a.enable) {
914
- console.log('\x1b[1m\x1b[33m%s\x1b[0m', `❗️ ${errMsg}`);
915
912
  return Object.assign({ passed: false, msg: errMsg, type: 'config', level: 'error', file: GAME_ORIGIN_CONFIG_FILE_NAME, name: 'project' }, defaultCheckConfig$3);
916
913
  }
917
914
  else {
@@ -921,10 +918,9 @@ function checkGameJson(config) {
921
918
  else {
922
919
  const gameJson = JSON.parse(fs.readFileSync(gameJsonPath, 'utf-8'));
923
920
  if (gameJson.subPackages) {
924
- const errMsg = `Error: 'subPackages' is found in ${GAME_ORIGIN_CONFIG_FILE_NAME}. Please use 'subpackages' (all lowercase) instead.`;
921
+ const errMsg = `'subPackages' is found in ${GAME_ORIGIN_CONFIG_FILE_NAME}. Please use 'subpackages' (all lowercase) instead.`;
922
+ logger.error(errMsg);
925
923
  if ((_b = config === null || config === void 0 ? void 0 : config.dev) === null || _b === void 0 ? void 0 : _b.enable) {
926
- logger.error(errMsg);
927
- console.log('\x1b[1m\x1b[33m%s\x1b[0m', `❗️ ${errMsg}`);
928
924
  return Object.assign({ passed: false, msg: errMsg, type: 'config', name: 'project', level: 'error', file: GAME_ORIGIN_CONFIG_FILE_NAME }, defaultCheckConfig$3);
929
925
  }
930
926
  else {
@@ -953,7 +949,6 @@ function checkProjectSize(config) {
953
949
  const errMsg = `Check project size failed, size: ${gameSizeMB}MB, must not exceed ${limitMB}MB`;
954
950
  logger.error(errMsg);
955
951
  if (enableDev) {
956
- console.log('\x1b[1m\x1b[33m%s\x1b[0m', errMsg);
957
952
  return Object.assign({ passed: false, name: 'project', msg: errMsg, type: 'size', level: 'warning', size: gameSize }, defaultCheckConfig$3);
958
953
  }
959
954
  else {
@@ -990,7 +985,6 @@ function checkMainPackageSize(config) {
990
985
  const errMsg = `Check main package size failed, main package size ${mainPkgSizeMB}MB, must not exceed ${limitMB}MB`;
991
986
  logger.error(errMsg);
992
987
  if (dev === null || dev === void 0 ? void 0 : dev.enable) {
993
- console.log('\x1b[1m\x1b[33m%s\x1b[0m', `❗️ ${errMsg}`);
994
988
  return Object.assign({ passed: false, msg: errMsg, size: mainPkgSize, type: 'size', level: 'warning' }, defaultCheckConfig$2);
995
989
  }
996
990
  else {
@@ -1010,7 +1004,6 @@ function checkMainPackageEntry(config) {
1010
1004
  const errMsg = 'Check main package entry failed, game.js must exist in main package!';
1011
1005
  logger.error(errMsg);
1012
1006
  if ((_a = config.dev) === null || _a === void 0 ? void 0 : _a.enable) {
1013
- console.log('\x1b[1m\x1b[33m%s\x1b[0m', errMsg);
1014
1007
  return Object.assign({ passed: false, msg: errMsg, type: 'config', level: 'error', file: 'game.js' }, defaultCheckConfig$2);
1015
1008
  }
1016
1009
  }
@@ -1062,7 +1055,6 @@ function checkSubpackages(config) {
1062
1055
  const errMsg = 'Check subpackages config failed, the subpackages configuration in game.json is invalid: the root or name field in one or more subpackages is empty. Please ensure that all subpackages have non-empty root and name values.';
1063
1056
  logger.error(errMsg);
1064
1057
  if ((_a = config === null || config === void 0 ? void 0 : config.dev) === null || _a === void 0 ? void 0 : _a.enable) {
1065
- console.log('\x1b[1m\x1b[33m%s\x1b[0m', `❗️ ${errMsg}`);
1066
1058
  checkResults.push(Object.assign({ passed: false, msg: errMsg, type: 'config', level: 'error', file: GAME_ORIGIN_CONFIG_FILE_NAME }, defaultCheckConfig$1));
1067
1059
  }
1068
1060
  else {
@@ -1073,7 +1065,6 @@ function checkSubpackages(config) {
1073
1065
  const errMsg = `Check subpackages config failed, the subpackages configuration in game.json is invalid: the root field in subpackage<${sub.name}> is invalid. Your subpackage root contain invalid characters, only A-Za-z0-9 _ - . / \\ are allowed.`;
1074
1066
  logger.error(errMsg);
1075
1067
  if ((_b = config === null || config === void 0 ? void 0 : config.dev) === null || _b === void 0 ? void 0 : _b.enable) {
1076
- console.log('\x1b[1m\x1b[33m%s\x1b[0m', `❗️ ${errMsg}`);
1077
1068
  checkResults.push(Object.assign({ passed: false, msg: errMsg, type: 'config', level: 'error', file: GAME_ORIGIN_CONFIG_FILE_NAME }, defaultCheckConfig$1));
1078
1069
  }
1079
1070
  else {
@@ -1092,7 +1083,6 @@ function checkSubpackages(config) {
1092
1083
  const errMsg = `Check subpackage<${sub.name}> config failed, the subpackages configuration in game.json is invalid: can not find subpackage ${sub.name} entry dir, please check it`;
1093
1084
  logger.error(errMsg);
1094
1085
  if ((_c = config === null || config === void 0 ? void 0 : config.dev) === null || _c === void 0 ? void 0 : _c.enable) {
1095
- console.log('\x1b[1m\x1b[33m%s\x1b[0m', `❗️ ${errMsg}`);
1096
1086
  checkResults.push(Object.assign({ passed: false, msg: errMsg, type: 'config', level: 'error', file: GAME_ORIGIN_CONFIG_FILE_NAME }, defaultCheckConfig$1));
1097
1087
  }
1098
1088
  else {
@@ -1130,7 +1120,6 @@ function checkIndependentPackages(config) {
1130
1120
  const errMsg = 'Check independent subpackages config failed, the subpackages configuration in game.json is invalid: the root or name field in one or more independent subpackages is empty. Please ensure that all independent subpackages have non-empty root and name values.';
1131
1121
  logger.error(errMsg);
1132
1122
  if (isEnableDev) {
1133
- console.log('\x1b[1m\x1b[33m%s\x1b[0m', `❗️${errMsg}`);
1134
1123
  checkResults.push(Object.assign(Object.assign({}, defaultCheckConfig), { passed: false, msg: errMsg, type: 'config', level: 'error', file: GAME_ORIGIN_CONFIG_FILE_NAME, name: sub.name }));
1135
1124
  }
1136
1125
  else {
@@ -1149,7 +1138,6 @@ function checkIndependentPackages(config) {
1149
1138
  const errMsg = `Check independent package<${sub.name}> config failed, the subpackages configuration in game.json is invalid: can not find subpackage ${sub.name} entry dir, please check it`;
1150
1139
  logger.error(errMsg);
1151
1140
  if (isEnableDev) {
1152
- console.log('\x1b[1m\x1b[33m%s\x1b[0m', `❗️ ${errMsg}`);
1153
1141
  checkResults.push(Object.assign(Object.assign({}, defaultCheckConfig), { passed: false, msg: errMsg, type: 'config', level: 'error', file: GAME_ORIGIN_CONFIG_FILE_NAME, name: sub.name }));
1154
1142
  }
1155
1143
  else {
@@ -1182,9 +1170,7 @@ function checkIndependentPackages(config) {
1182
1170
  checkResults.push(checkSizeResult);
1183
1171
  logger.info(checkSizeResult.msg);
1184
1172
  if (!checkSizeResult.passed) {
1185
- if (isEnableDev) {
1186
- console.log('\x1b[1m\x1b[33m%s\x1b[0m', `❗️ ${checkSizeResult.msg}`);
1187
- }
1173
+ if (isEnableDev) ;
1188
1174
  else {
1189
1175
  throw new Error(checkSizeResult.msg);
1190
1176
  }
@@ -2131,7 +2117,7 @@ async function buildPkgs(config) {
2131
2117
  const { output: outputDir, build } = config;
2132
2118
  let startTime = Date.now();
2133
2119
  logger.init(outputDir, true);
2134
- logger.info(`TTMG_PACK_VERSION: ${"0.3.6"}`);
2120
+ logger.info(`TTMG_PACK_VERSION: ${"0.3.8"}`);
2135
2121
  logger.info(`pack start, startTime:${startTime}`);
2136
2122
  /**
2137
2123
  * 清理