@icebreakers/monorepo 2.0.9 → 2.0.11

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 CHANGED
@@ -33,10 +33,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
33
33
  ));
34
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
35
 
36
- // ../../node_modules/.pnpm/tsup@8.5.0_@microsoft+api-extractor@7.52.12_@types+node@24.7.2__jiti@2.6.1_postcss@8.5._3d4ae7d8e5b6f496c0110ecf5a7e8328/node_modules/tsup/assets/cjs_shims.js
36
+ // ../../node_modules/.pnpm/tsup@8.5.0_@microsoft+api-extractor@7.52.12_@types+node@24.8.0__jiti@2.6.1_postcss@8.5._ab94ebbbd28243190e5d9689f774411e/node_modules/tsup/assets/cjs_shims.js
37
37
  var getImportMetaUrl, importMetaUrl;
38
38
  var init_cjs_shims = __esm({
39
- "../../node_modules/.pnpm/tsup@8.5.0_@microsoft+api-extractor@7.52.12_@types+node@24.7.2__jiti@2.6.1_postcss@8.5._3d4ae7d8e5b6f496c0110ecf5a7e8328/node_modules/tsup/assets/cjs_shims.js"() {
39
+ "../../node_modules/.pnpm/tsup@8.5.0_@microsoft+api-extractor@7.52.12_@types+node@24.8.0__jiti@2.6.1_postcss@8.5._ab94ebbbd28243190e5d9689f774411e/node_modules/tsup/assets/cjs_shims.js"() {
40
40
  "use strict";
41
41
  getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
42
42
  importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
@@ -239,6 +239,7 @@ __export(index_exports, {
239
239
  getWorkspacePackages: () => getWorkspacePackages,
240
240
  init: () => init,
241
241
  isFileChanged: () => isFileChanged,
242
+ isGitignoreFile: () => isGitignoreFile,
242
243
  isIgnorableFsError: () => isIgnorableFsError,
243
244
  isMatch: () => isMatch,
244
245
  loadMonorepoConfig: () => loadMonorepoConfig,
@@ -251,6 +252,8 @@ __export(index_exports, {
251
252
  syncNpmMirror: () => syncNpmMirror,
252
253
  templateMap: () => templateMap,
253
254
  templatesDir: () => templatesDir,
255
+ toPublishGitignorePath: () => toPublishGitignorePath,
256
+ toWorkspaceGitignorePath: () => toWorkspaceGitignorePath,
254
257
  upgradeMonorepo: () => upgradeMonorepo,
255
258
  version: () => version
256
259
  });
@@ -638,7 +641,7 @@ var import_node_url = require("url");
638
641
 
639
642
  // package.json
640
643
  var name = "@icebreakers/monorepo";
641
- var version = "2.0.9";
644
+ var version = "2.0.11";
642
645
 
643
646
  // src/constants.ts
644
647
  var packageJsonPath = (0, import_node_url.fileURLToPath)(new URL("../package.json", importMetaUrl));
@@ -652,6 +655,88 @@ init_cjs_shims();
652
655
  var import_consola = require("consola");
653
656
  var logger = (0, import_consola.createConsola)();
654
657
 
658
+ // src/utils/fs.ts
659
+ init_cjs_shims();
660
+ function isIgnorableFsError(error) {
661
+ if (!error) {
662
+ return false;
663
+ }
664
+ const code = error.code;
665
+ return code === "ENOENT" || code === "EBUSY" || code === "EEXIST";
666
+ }
667
+
668
+ // src/utils/gitignore.ts
669
+ init_cjs_shims();
670
+ var publishBasename = "gitignore";
671
+ var workspaceBasename = ".gitignore";
672
+ function detectSeparator(input) {
673
+ if (input.includes("\\") && !input.includes("/")) {
674
+ return "\\";
675
+ }
676
+ return "/";
677
+ }
678
+ function replaceBasename(input, from, to) {
679
+ if (!input) {
680
+ return input;
681
+ }
682
+ const separator = detectSeparator(input);
683
+ const normalized = input.replace(/[\\/]/g, separator);
684
+ const hasTrailingSeparator = normalized.endsWith(separator);
685
+ const segments = normalized.split(separator);
686
+ if (hasTrailingSeparator && segments[segments.length - 1] === "") {
687
+ segments.pop();
688
+ }
689
+ const lastIndex = segments.length - 1;
690
+ if (lastIndex >= 0 && segments[lastIndex] === from) {
691
+ segments[lastIndex] = to;
692
+ const rebuilt = segments.join(separator);
693
+ return hasTrailingSeparator ? `${rebuilt}${separator}` : rebuilt;
694
+ }
695
+ return input;
696
+ }
697
+ function toPublishGitignorePath(input) {
698
+ return replaceBasename(input, workspaceBasename, publishBasename);
699
+ }
700
+ function toWorkspaceGitignorePath(input) {
701
+ return replaceBasename(input, publishBasename, workspaceBasename);
702
+ }
703
+ function isGitignoreFile(name2) {
704
+ return toPublishGitignorePath(name2) !== name2 || toWorkspaceGitignorePath(name2) !== name2;
705
+ }
706
+
707
+ // src/utils/hash.ts
708
+ init_cjs_shims();
709
+ var import_node_crypto = __toESM(require("crypto"), 1);
710
+ function getFileHash(data) {
711
+ const hashSum = import_node_crypto.default.createHash("md5");
712
+ hashSum.update(data);
713
+ return hashSum.digest("hex");
714
+ }
715
+ function isFileChanged(src, dest) {
716
+ try {
717
+ const currentHash = getFileHash(src);
718
+ const previousHash = getFileHash(dest);
719
+ return currentHash !== previousHash;
720
+ } catch (err) {
721
+ logger.error("Error calculating file hash:", err);
722
+ return false;
723
+ }
724
+ }
725
+
726
+ // src/utils/regexp.ts
727
+ init_cjs_shims();
728
+ function escapeStringRegexp(str) {
729
+ return str.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
730
+ }
731
+ function isMatch(str, arr) {
732
+ for (const reg of arr) {
733
+ if (reg.test(str)) {
734
+ return true;
735
+ }
736
+ }
737
+ return false;
738
+ }
739
+
655
740
  // src/commands/create.ts
656
741
  var templateMap = {
657
742
  "tsup": "packages/tsup-template",
@@ -711,7 +796,7 @@ async function createNewProject(options) {
711
796
  const shouldSkip = (src) => import_pathe4.default.basename(src) === ".DS_Store";
712
797
  const copyTasks = filelist.filter((filename) => filename !== "package.json").map(async (filename) => {
713
798
  const sourcePath = import_pathe4.default.resolve(from, filename);
714
- const targetPath = import_pathe4.default.resolve(to, filename === "gitignore" ? ".gitignore" : filename);
799
+ const targetPath = import_pathe4.default.resolve(to, toWorkspaceGitignorePath(filename));
715
800
  await import_fs_extra2.default.copy(sourcePath, targetPath, {
716
801
  filter(src) {
717
802
  if (shouldSkip(src)) {
@@ -1013,60 +1098,105 @@ ${Array.from(set7).map((x) => `- ${import_picocolors2.default.green(x ?? "")}`).
1013
1098
 
1014
1099
  // src/commands/upgrade/index.ts
1015
1100
  init_cjs_shims();
1016
- var import_node_buffer = require("buffer");
1017
1101
  var import_node_process2 = __toESM(require("process"), 1);
1018
- var import_checkbox2 = __toESM(require("@inquirer/checkbox"), 1);
1019
- var import_confirm = __toESM(require("@inquirer/confirm"), 1);
1020
- var import_fs_extra7 = __toESM(require("fs-extra"), 1);
1102
+ var import_checkbox3 = __toESM(require("@inquirer/checkbox"), 1);
1103
+ var import_fs_extra8 = __toESM(require("fs-extra"), 1);
1021
1104
  var import_klaw = __toESM(require("klaw"), 1);
1022
1105
  var import_pathe11 = __toESM(require("pathe"), 1);
1023
- var import_picocolors3 = __toESM(require("picocolors"), 1);
1024
- var import_semver = require("semver");
1025
1106
  var import_set_value6 = __toESM(require_set_value(), 1);
1026
1107
 
1027
- // src/utils/fs.ts
1108
+ // src/commands/upgrade/overwrite.ts
1028
1109
  init_cjs_shims();
1029
- function isIgnorableFsError(error) {
1030
- if (!error) {
1031
- return false;
1032
- }
1033
- const code = error.code;
1034
- return code === "ENOENT" || code === "EBUSY" || code === "EEXIST";
1035
- }
1036
-
1037
- // src/utils/hash.ts
1038
- init_cjs_shims();
1039
- var import_node_crypto = __toESM(require("crypto"), 1);
1040
- function getFileHash(data) {
1041
- const hashSum = import_node_crypto.default.createHash("md5");
1042
- hashSum.update(data);
1043
- return hashSum.digest("hex");
1110
+ var import_node_buffer = require("buffer");
1111
+ var import_checkbox2 = __toESM(require("@inquirer/checkbox"), 1);
1112
+ var import_fs_extra7 = __toESM(require("fs-extra"), 1);
1113
+ var import_picocolors3 = __toESM(require("picocolors"), 1);
1114
+ function asBuffer(data) {
1115
+ return typeof data === "string" ? import_node_buffer.Buffer.from(data) : data;
1044
1116
  }
1045
- function isFileChanged(src, dest) {
1117
+ async function evaluateWriteIntent(targetPath, options) {
1118
+ const { skipOverwrite, source } = options;
1119
+ const exists = await import_fs_extra7.default.pathExists(targetPath);
1120
+ if (!exists) {
1121
+ return {
1122
+ type: "write",
1123
+ reason: "missing"
1124
+ };
1125
+ }
1126
+ if (skipOverwrite) {
1127
+ return {
1128
+ type: "skip",
1129
+ reason: "skipOverwrite"
1130
+ };
1131
+ }
1132
+ const src = asBuffer(source);
1133
+ let destSize = 0;
1046
1134
  try {
1047
- const currentHash = getFileHash(src);
1048
- const previousHash = getFileHash(dest);
1049
- return currentHash !== previousHash;
1050
- } catch (err) {
1051
- logger.error("Error calculating file hash:", err);
1052
- return false;
1135
+ const stat = await import_fs_extra7.default.stat(targetPath);
1136
+ destSize = stat.size;
1137
+ } catch {
1138
+ return {
1139
+ type: "write",
1140
+ reason: "missing"
1141
+ };
1142
+ }
1143
+ if (destSize !== src.length) {
1144
+ return {
1145
+ type: "prompt",
1146
+ reason: "changed"
1147
+ };
1053
1148
  }
1149
+ const dest = await import_fs_extra7.default.readFile(targetPath);
1150
+ if (!isFileChanged(src, dest)) {
1151
+ return {
1152
+ type: "skip",
1153
+ reason: "identical"
1154
+ };
1155
+ }
1156
+ return {
1157
+ type: "prompt",
1158
+ reason: "changed"
1159
+ };
1054
1160
  }
1055
-
1056
- // src/utils/regexp.ts
1057
- init_cjs_shims();
1058
- function escapeStringRegexp(str) {
1059
- return str.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
1161
+ async function scheduleOverwrite(intent, options) {
1162
+ const { relPath, targetPath, action, pending } = options;
1163
+ if (intent.type === "write") {
1164
+ await action();
1165
+ return;
1166
+ }
1167
+ if (intent.type === "prompt") {
1168
+ pending.push({
1169
+ relPath,
1170
+ targetPath,
1171
+ action
1172
+ });
1173
+ }
1060
1174
  }
1061
- function isMatch(str, arr) {
1062
- for (const reg of arr) {
1063
- if (reg.test(str)) {
1064
- return true;
1175
+ async function flushPendingOverwrites(pending) {
1176
+ if (!pending.length) {
1177
+ return;
1178
+ }
1179
+ const selected = await (0, import_checkbox2.default)({
1180
+ message: "\u68C0\u6D4B\u5230\u4EE5\u4E0B\u6587\u4EF6\u5185\u5BB9\u4E0E\u5F53\u524D\u4ED3\u5E93\u4E0D\u540C\uFF0C\u9009\u62E9\u9700\u8981\u8986\u76D6\u7684\u6587\u4EF6",
1181
+ choices: pending.map((item) => ({
1182
+ name: import_picocolors3.default.greenBright(item.relPath),
1183
+ value: item.targetPath,
1184
+ checked: false
1185
+ })),
1186
+ loop: false
1187
+ });
1188
+ const selectedSet = new Set(selected);
1189
+ for (const item of pending) {
1190
+ if (selectedSet.has(item.targetPath)) {
1191
+ await item.action();
1065
1192
  }
1066
1193
  }
1067
- return false;
1068
1194
  }
1069
1195
 
1196
+ // src/commands/upgrade/pkg-json.ts
1197
+ init_cjs_shims();
1198
+ var import_semver = require("semver");
1199
+
1070
1200
  // src/commands/upgrade/scripts.ts
1071
1201
  init_cjs_shims();
1072
1202
  var scripts = {
@@ -1078,44 +1208,7 @@ var scripts = {
1078
1208
  };
1079
1209
  var scriptsEntries = Object.entries(scripts);
1080
1210
 
1081
- // src/commands/upgrade/targets.ts
1082
- init_cjs_shims();
1083
- function getAssetTargets(raw) {
1084
- const list = [
1085
- ".changeset",
1086
- ".husky",
1087
- ".vscode",
1088
- ".editorconfig",
1089
- ".gitattributes",
1090
- ".gitignore",
1091
- ".npmrc",
1092
- "commitlint.config.ts",
1093
- "eslint.config.js",
1094
- "lint-staged.config.js",
1095
- "stylelint.config.js",
1096
- "monorepo.config.ts",
1097
- "package.json",
1098
- // pnpm
1099
- "pnpm-workspace.yaml",
1100
- // base tsconfig
1101
- "tsconfig.json",
1102
- // turbo
1103
- "turbo.json",
1104
- // vitest
1105
- "vitest.config.ts",
1106
- // 'vitest.workspace.ts',
1107
- // #region docker
1108
- "Dockerfile",
1109
- ".dockerignore"
1110
- // #endregion
1111
- ];
1112
- if (!raw) {
1113
- list.push(".github", "LICENSE", "renovate.json", "SECURITY.md", "CODE_OF_CONDUCT.md", "CONTRIBUTING.md", "netlify.toml");
1114
- }
1115
- return list;
1116
- }
1117
-
1118
- // src/commands/upgrade/index.ts
1211
+ // src/commands/upgrade/pkg-json.ts
1119
1212
  function isWorkspace(version2) {
1120
1213
  if (typeof version2 === "string") {
1121
1214
  return version2.startsWith("workspace:");
@@ -1198,38 +1291,45 @@ function setPkgJson(sourcePkgJson, targetPkgJson, options) {
1198
1291
  targetPkgJson.scripts = scripts2;
1199
1292
  }
1200
1293
  }
1201
- function confirmOverwrite(filename) {
1202
- return (0, import_confirm.default)({ message: `${import_picocolors3.default.greenBright(filename)} \u6587\u4EF6\u5185\u5BB9\u53D1\u751F\u6539\u53D8,\u662F\u5426\u8986\u76D6?`, default: true });
1203
- }
1204
- function asBuffer(data) {
1205
- return typeof data === "string" ? import_node_buffer.Buffer.from(data) : data;
1206
- }
1207
- async function shouldWriteFile(targetPath, options) {
1208
- const { skipOverwrite, source, promptLabel } = options;
1209
- const exists = await import_fs_extra7.default.pathExists(targetPath);
1210
- if (!exists) {
1211
- return true;
1212
- }
1213
- if (skipOverwrite) {
1214
- return false;
1215
- }
1216
- const src = asBuffer(source);
1217
- let destSize = 0;
1218
- try {
1219
- const stat = await import_fs_extra7.default.stat(targetPath);
1220
- destSize = stat.size;
1221
- } catch {
1222
- return true;
1223
- }
1224
- if (destSize !== src.length) {
1225
- return confirmOverwrite(promptLabel);
1226
- }
1227
- const dest = await import_fs_extra7.default.readFile(targetPath);
1228
- if (!isFileChanged(src, dest)) {
1229
- return false;
1294
+
1295
+ // src/commands/upgrade/targets.ts
1296
+ init_cjs_shims();
1297
+ function getAssetTargets(raw) {
1298
+ const list = [
1299
+ ".changeset",
1300
+ ".husky",
1301
+ ".vscode",
1302
+ ".editorconfig",
1303
+ ".gitattributes",
1304
+ ".gitignore",
1305
+ ".npmrc",
1306
+ "commitlint.config.ts",
1307
+ "eslint.config.js",
1308
+ "lint-staged.config.js",
1309
+ "stylelint.config.js",
1310
+ "monorepo.config.ts",
1311
+ "package.json",
1312
+ // pnpm
1313
+ "pnpm-workspace.yaml",
1314
+ // base tsconfig
1315
+ "tsconfig.json",
1316
+ // turbo
1317
+ "turbo.json",
1318
+ // vitest
1319
+ "vitest.config.ts",
1320
+ // 'vitest.workspace.ts',
1321
+ // #region docker
1322
+ "Dockerfile",
1323
+ ".dockerignore"
1324
+ // #endregion
1325
+ ];
1326
+ if (!raw) {
1327
+ list.push(".github", "LICENSE", "renovate.json", "SECURITY.md", "CODE_OF_CONDUCT.md", "CONTRIBUTING.md", "netlify.toml");
1230
1328
  }
1231
- return confirmOverwrite(promptLabel);
1329
+ return list;
1232
1330
  }
1331
+
1332
+ // src/commands/upgrade/index.ts
1233
1333
  async function upgradeMonorepo(opts) {
1234
1334
  const cwd = opts.cwd ?? import_node_process2.default.cwd();
1235
1335
  const upgradeConfig = await resolveCommandConfig("upgrade", cwd);
@@ -1250,7 +1350,7 @@ async function upgradeMonorepo(opts) {
1250
1350
  const mergeTargets = upgradeConfig == null ? void 0 : upgradeConfig.mergeTargets;
1251
1351
  let targets = configTargets.length ? mergeTargets === false ? [...configTargets] : Array.from(/* @__PURE__ */ new Set([...baseTargets, ...configTargets])) : baseTargets;
1252
1352
  if (merged.interactive) {
1253
- targets = await (0, import_checkbox2.default)({
1353
+ targets = await (0, import_checkbox3.default)({
1254
1354
  message: "\u9009\u62E9\u4F60\u9700\u8981\u7684\u6587\u4EF6",
1255
1355
  choices: targets.map((x) => {
1256
1356
  return {
@@ -1266,62 +1366,89 @@ async function upgradeMonorepo(opts) {
1266
1366
  const skipChangesetMarkdown = (upgradeConfig == null ? void 0 : upgradeConfig.skipChangesetMarkdown) ?? true;
1267
1367
  const scriptOverrides = upgradeConfig == null ? void 0 : upgradeConfig.scripts;
1268
1368
  const skipOverwrite = merged.skipOverwrite;
1369
+ const pendingOverwrites = [];
1269
1370
  for await (const file of (0, import_klaw.default)(assetsDir, {
1270
1371
  filter(p) {
1271
- const str = import_pathe11.default.relative(assetsDir, p);
1272
- return isMatch(str, regexpArr);
1372
+ const rel = toWorkspaceGitignorePath(import_pathe11.default.relative(assetsDir, p));
1373
+ return isMatch(rel, regexpArr);
1273
1374
  }
1274
1375
  })) {
1275
1376
  if (!file.stats.isFile()) {
1276
1377
  continue;
1277
1378
  }
1278
- let relPath = import_pathe11.default.relative(assetsDir, file.path);
1279
- if (relPath === "gitignore") {
1280
- relPath = ".gitignore";
1281
- }
1379
+ const relPath = toWorkspaceGitignorePath(import_pathe11.default.relative(assetsDir, file.path));
1282
1380
  if (skipChangesetMarkdown && relPath.startsWith(".changeset/") && relPath.endsWith(".md")) {
1283
1381
  continue;
1284
1382
  }
1285
1383
  const targetPath = import_pathe11.default.resolve(absOutDir, relPath);
1286
1384
  try {
1287
1385
  if (relPath === "package.json") {
1288
- if (!await import_fs_extra7.default.pathExists(targetPath)) {
1386
+ if (!await import_fs_extra8.default.pathExists(targetPath)) {
1289
1387
  continue;
1290
1388
  }
1291
- const sourcePkgJson = await import_fs_extra7.default.readJson(file.path);
1292
- const targetPkgJson = await import_fs_extra7.default.readJson(targetPath);
1389
+ const sourcePkgJson = await import_fs_extra8.default.readJson(file.path);
1390
+ const targetPkgJson = await import_fs_extra8.default.readJson(targetPath);
1293
1391
  setPkgJson(sourcePkgJson, targetPkgJson, { scripts: scriptOverrides });
1294
1392
  const data = `${JSON.stringify(targetPkgJson, void 0, 2)}
1295
1393
  `;
1296
- if (await shouldWriteFile(targetPath, { skipOverwrite, source: data, promptLabel: relPath })) {
1297
- await import_fs_extra7.default.outputFile(targetPath, data, "utf8");
1394
+ const intent2 = await evaluateWriteIntent(targetPath, { skipOverwrite, source: data });
1395
+ const action2 = async () => {
1396
+ await import_fs_extra8.default.outputFile(targetPath, data, "utf8");
1298
1397
  logger.success(targetPath);
1299
- }
1398
+ };
1399
+ await scheduleOverwrite(intent2, {
1400
+ relPath,
1401
+ targetPath,
1402
+ action: action2,
1403
+ pending: pendingOverwrites
1404
+ });
1300
1405
  continue;
1301
1406
  }
1302
1407
  if (relPath === ".changeset/config.json" && repoName) {
1303
- const changesetJson = await import_fs_extra7.default.readJson(file.path);
1408
+ const changesetJson = await import_fs_extra8.default.readJson(file.path);
1304
1409
  (0, import_set_value6.default)(changesetJson, "changelog.1.repo", repoName);
1305
1410
  const data = `${JSON.stringify(changesetJson, void 0, 2)}
1306
1411
  `;
1307
- if (await shouldWriteFile(targetPath, { skipOverwrite, source: data, promptLabel: relPath })) {
1308
- await import_fs_extra7.default.outputFile(targetPath, data, "utf8");
1412
+ const intent2 = await evaluateWriteIntent(targetPath, { skipOverwrite, source: data });
1413
+ const action2 = async () => {
1414
+ await import_fs_extra8.default.outputFile(targetPath, data, "utf8");
1309
1415
  logger.success(targetPath);
1310
- }
1416
+ };
1417
+ await scheduleOverwrite(intent2, {
1418
+ relPath,
1419
+ targetPath,
1420
+ action: action2,
1421
+ pending: pendingOverwrites
1422
+ });
1311
1423
  continue;
1312
1424
  }
1313
1425
  if (relPath === "LICENSE") {
1314
- const source = await import_fs_extra7.default.readFile(file.path);
1315
- if (await shouldWriteFile(targetPath, { skipOverwrite: true, source, promptLabel: relPath })) {
1316
- await import_fs_extra7.default.copy(file.path, targetPath);
1426
+ const source2 = await import_fs_extra8.default.readFile(file.path);
1427
+ const intent2 = await evaluateWriteIntent(targetPath, { skipOverwrite: true, source: source2 });
1428
+ const action2 = async () => {
1429
+ await import_fs_extra8.default.outputFile(targetPath, source2);
1317
1430
  logger.success(targetPath);
1318
- }
1431
+ };
1432
+ await scheduleOverwrite(intent2, {
1433
+ relPath,
1434
+ targetPath,
1435
+ action: action2,
1436
+ pending: pendingOverwrites
1437
+ });
1319
1438
  continue;
1320
1439
  }
1321
- if (await shouldWriteFile(targetPath, { skipOverwrite, source: await import_fs_extra7.default.readFile(file.path), promptLabel: relPath })) {
1322
- await import_fs_extra7.default.copy(file.path, targetPath);
1440
+ const source = await import_fs_extra8.default.readFile(file.path);
1441
+ const intent = await evaluateWriteIntent(targetPath, { skipOverwrite, source });
1442
+ const action = async () => {
1443
+ await import_fs_extra8.default.outputFile(targetPath, source);
1323
1444
  logger.success(targetPath);
1324
- }
1445
+ };
1446
+ await scheduleOverwrite(intent, {
1447
+ relPath,
1448
+ targetPath,
1449
+ action,
1450
+ pending: pendingOverwrites
1451
+ });
1325
1452
  } catch (error) {
1326
1453
  if (isIgnorableFsError(error)) {
1327
1454
  continue;
@@ -1329,6 +1456,7 @@ async function upgradeMonorepo(opts) {
1329
1456
  throw error;
1330
1457
  }
1331
1458
  }
1459
+ await flushPendingOverwrites(pendingOverwrites);
1332
1460
  }
1333
1461
  // Annotate the CommonJS export names for ESM import in node:
1334
1462
  0 && (module.exports = {
@@ -1346,6 +1474,7 @@ async function upgradeMonorepo(opts) {
1346
1474
  getWorkspacePackages,
1347
1475
  init,
1348
1476
  isFileChanged,
1477
+ isGitignoreFile,
1349
1478
  isIgnorableFsError,
1350
1479
  isMatch,
1351
1480
  loadMonorepoConfig,
@@ -1358,6 +1487,8 @@ async function upgradeMonorepo(opts) {
1358
1487
  syncNpmMirror,
1359
1488
  templateMap,
1360
1489
  templatesDir,
1490
+ toPublishGitignorePath,
1491
+ toWorkspaceGitignorePath,
1361
1492
  upgradeMonorepo,
1362
1493
  version
1363
1494
  });
package/dist/index.d.cts CHANGED
@@ -269,7 +269,7 @@ declare function syncNpmMirror(cwd: string, options?: GetWorkspacePackagesOption
269
269
  declare function upgradeMonorepo(opts: CliOpts): Promise<void>;
270
270
 
271
271
  var name = "@icebreakers/monorepo";
272
- var version = "2.0.9";
272
+ var version = "2.0.11";
273
273
 
274
274
  /**
275
275
  * @icebreakers/monorepo 包的根目录,所有模板与资产目录都以此为基准。
@@ -328,6 +328,20 @@ declare const logger: consola.ConsolaInstance;
328
328
  */
329
329
  declare function isIgnorableFsError(error: unknown): error is NodeJS.ErrnoException;
330
330
 
331
+ /**
332
+ * Map a workspace path (containing `.gitignore`) to its packaged variant.
333
+ */
334
+ declare function toPublishGitignorePath(input: string): string;
335
+ /**
336
+ * Map a packaged path (containing `gitignore`) back to the workspace form.
337
+ */
338
+ declare function toWorkspaceGitignorePath(input: string): string;
339
+ /**
340
+ * Convenient helper to check whether a filename (with or without dot prefix)
341
+ * should be treated as a gitignore file.
342
+ */
343
+ declare function isGitignoreFile(name: string): boolean;
344
+
331
345
  /**
332
346
  * 生成给定二进制内容的 md5 摘要,用于快速比较文件内容。
333
347
  */
@@ -346,4 +360,4 @@ declare function escapeStringRegexp(str: string): string;
346
360
  */
347
361
  declare function isMatch(str: string, arr: RegExp[]): boolean;
348
362
 
349
- export { type CleanCommandConfig, type CliOpts, type Context, type CreateChoiceOption, type CreateCommandConfig, type CreateNewProjectOptions, type GetWorkspacePackagesOptions, GitClient, type InitCommandConfig, type MirrorCommandConfig, type MonorepoConfig, type SyncCommandConfig, type UpgradeCommandConfig, assetsDir, cleanProjects, createContext, createNewProject, defineMonorepoConfig, escapeStringRegexp, getCreateChoices, getFileHash, getTemplateMap, getWorkspaceData, getWorkspacePackages, init, isFileChanged, isIgnorableFsError, isMatch, loadMonorepoConfig, logger, name, packageDir, resolveCommandConfig, rootDir, setVscodeBinaryMirror, syncNpmMirror, templateMap, templatesDir, upgradeMonorepo, version };
363
+ export { type CleanCommandConfig, type CliOpts, type Context, type CreateChoiceOption, type CreateCommandConfig, type CreateNewProjectOptions, type GetWorkspacePackagesOptions, GitClient, type InitCommandConfig, type MirrorCommandConfig, type MonorepoConfig, type SyncCommandConfig, type UpgradeCommandConfig, assetsDir, cleanProjects, createContext, createNewProject, defineMonorepoConfig, escapeStringRegexp, getCreateChoices, getFileHash, getTemplateMap, getWorkspaceData, getWorkspacePackages, init, isFileChanged, isGitignoreFile, isIgnorableFsError, isMatch, loadMonorepoConfig, logger, name, packageDir, resolveCommandConfig, rootDir, setVscodeBinaryMirror, syncNpmMirror, templateMap, templatesDir, toPublishGitignorePath, toWorkspaceGitignorePath, upgradeMonorepo, version };
package/dist/index.d.ts CHANGED
@@ -269,7 +269,7 @@ declare function syncNpmMirror(cwd: string, options?: GetWorkspacePackagesOption
269
269
  declare function upgradeMonorepo(opts: CliOpts): Promise<void>;
270
270
 
271
271
  var name = "@icebreakers/monorepo";
272
- var version = "2.0.9";
272
+ var version = "2.0.11";
273
273
 
274
274
  /**
275
275
  * @icebreakers/monorepo 包的根目录,所有模板与资产目录都以此为基准。
@@ -328,6 +328,20 @@ declare const logger: consola.ConsolaInstance;
328
328
  */
329
329
  declare function isIgnorableFsError(error: unknown): error is NodeJS.ErrnoException;
330
330
 
331
+ /**
332
+ * Map a workspace path (containing `.gitignore`) to its packaged variant.
333
+ */
334
+ declare function toPublishGitignorePath(input: string): string;
335
+ /**
336
+ * Map a packaged path (containing `gitignore`) back to the workspace form.
337
+ */
338
+ declare function toWorkspaceGitignorePath(input: string): string;
339
+ /**
340
+ * Convenient helper to check whether a filename (with or without dot prefix)
341
+ * should be treated as a gitignore file.
342
+ */
343
+ declare function isGitignoreFile(name: string): boolean;
344
+
331
345
  /**
332
346
  * 生成给定二进制内容的 md5 摘要,用于快速比较文件内容。
333
347
  */
@@ -346,4 +360,4 @@ declare function escapeStringRegexp(str: string): string;
346
360
  */
347
361
  declare function isMatch(str: string, arr: RegExp[]): boolean;
348
362
 
349
- export { type CleanCommandConfig, type CliOpts, type Context, type CreateChoiceOption, type CreateCommandConfig, type CreateNewProjectOptions, type GetWorkspacePackagesOptions, GitClient, type InitCommandConfig, type MirrorCommandConfig, type MonorepoConfig, type SyncCommandConfig, type UpgradeCommandConfig, assetsDir, cleanProjects, createContext, createNewProject, defineMonorepoConfig, escapeStringRegexp, getCreateChoices, getFileHash, getTemplateMap, getWorkspaceData, getWorkspacePackages, init, isFileChanged, isIgnorableFsError, isMatch, loadMonorepoConfig, logger, name, packageDir, resolveCommandConfig, rootDir, setVscodeBinaryMirror, syncNpmMirror, templateMap, templatesDir, upgradeMonorepo, version };
363
+ export { type CleanCommandConfig, type CliOpts, type Context, type CreateChoiceOption, type CreateCommandConfig, type CreateNewProjectOptions, type GetWorkspacePackagesOptions, GitClient, type InitCommandConfig, type MirrorCommandConfig, type MonorepoConfig, type SyncCommandConfig, type UpgradeCommandConfig, assetsDir, cleanProjects, createContext, createNewProject, defineMonorepoConfig, escapeStringRegexp, getCreateChoices, getFileHash, getTemplateMap, getWorkspaceData, getWorkspacePackages, init, isFileChanged, isGitignoreFile, isIgnorableFsError, isMatch, loadMonorepoConfig, logger, name, packageDir, resolveCommandConfig, rootDir, setVscodeBinaryMirror, syncNpmMirror, templateMap, templatesDir, toPublishGitignorePath, toWorkspaceGitignorePath, upgradeMonorepo, version };
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ import {
14
14
  init,
15
15
  init_esm_shims,
16
16
  isFileChanged,
17
+ isGitignoreFile,
17
18
  isIgnorableFsError,
18
19
  isMatch,
19
20
  loadMonorepoConfig,
@@ -26,9 +27,11 @@ import {
26
27
  syncNpmMirror,
27
28
  templateMap,
28
29
  templatesDir,
30
+ toPublishGitignorePath,
31
+ toWorkspaceGitignorePath,
29
32
  upgradeMonorepo,
30
33
  version
31
- } from "./chunk-NHJHKD7Y.js";
34
+ } from "./chunk-T3OVPIEE.js";
32
35
 
33
36
  // src/index.ts
34
37
  init_esm_shims();
@@ -47,6 +50,7 @@ export {
47
50
  getWorkspacePackages,
48
51
  init,
49
52
  isFileChanged,
53
+ isGitignoreFile,
50
54
  isIgnorableFsError,
51
55
  isMatch,
52
56
  loadMonorepoConfig,
@@ -59,6 +63,8 @@ export {
59
63
  syncNpmMirror,
60
64
  templateMap,
61
65
  templatesDir,
66
+ toPublishGitignorePath,
67
+ toWorkspaceGitignorePath,
62
68
  upgradeMonorepo,
63
69
  version
64
70
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@icebreakers/monorepo",
3
3
  "type": "module",
4
- "version": "2.0.9",
4
+ "version": "2.0.11",
5
5
  "description": "The icebreaker's monorepo manager",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -35,7 +35,6 @@
35
35
  ],
36
36
  "dependencies": {
37
37
  "@inquirer/checkbox": "^4.3.0",
38
- "@inquirer/confirm": "^5.1.19",
39
38
  "@inquirer/input": "^4.2.5",
40
39
  "@inquirer/select": "^4.4.0",
41
40
  "@pnpm/find-workspace-dir": "^1000.1.3",