@icebreakers/monorepo 2.0.9 → 2.0.10
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/{chunk-NHJHKD7Y.js → chunk-3TJYHDE6.js} +180 -91
- package/dist/cli.cjs +182 -93
- package/dist/cli.js +1 -1
- package/dist/index.cjs +182 -93
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -2
- package/templates/apps/client/package.json +1 -1
- package/templates/apps/client/wrangler.jsonc +1 -1
- package/templates/apps/server/wrangler.jsonc +1 -1
- package/templates/packages/vue-lib-template/package.json +1 -1
|
@@ -578,7 +578,7 @@ async function cleanProjects(cwd) {
|
|
|
578
578
|
|
|
579
579
|
// package.json
|
|
580
580
|
var name = "@icebreakers/monorepo";
|
|
581
|
-
var version = "2.0.
|
|
581
|
+
var version = "2.0.10";
|
|
582
582
|
|
|
583
583
|
// src/constants.ts
|
|
584
584
|
init_esm_shims();
|
|
@@ -1006,14 +1006,102 @@ function isMatch(str, arr) {
|
|
|
1006
1006
|
// src/commands/upgrade/index.ts
|
|
1007
1007
|
init_esm_shims();
|
|
1008
1008
|
var import_set_value6 = __toESM(require_set_value(), 1);
|
|
1009
|
-
import { Buffer as Buffer2 } from "buffer";
|
|
1010
1009
|
import process2 from "process";
|
|
1011
|
-
import
|
|
1012
|
-
import
|
|
1013
|
-
import fs7 from "fs-extra";
|
|
1010
|
+
import checkbox3 from "@inquirer/checkbox";
|
|
1011
|
+
import fs8 from "fs-extra";
|
|
1014
1012
|
import klaw from "klaw";
|
|
1015
1013
|
import path13 from "pathe";
|
|
1014
|
+
|
|
1015
|
+
// src/commands/upgrade/overwrite.ts
|
|
1016
|
+
init_esm_shims();
|
|
1017
|
+
import { Buffer as Buffer2 } from "buffer";
|
|
1018
|
+
import checkbox2 from "@inquirer/checkbox";
|
|
1019
|
+
import fs7 from "fs-extra";
|
|
1016
1020
|
import pc3 from "picocolors";
|
|
1021
|
+
function asBuffer(data) {
|
|
1022
|
+
return typeof data === "string" ? Buffer2.from(data) : data;
|
|
1023
|
+
}
|
|
1024
|
+
async function evaluateWriteIntent(targetPath, options) {
|
|
1025
|
+
const { skipOverwrite, source } = options;
|
|
1026
|
+
const exists = await fs7.pathExists(targetPath);
|
|
1027
|
+
if (!exists) {
|
|
1028
|
+
return {
|
|
1029
|
+
type: "write",
|
|
1030
|
+
reason: "missing"
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1033
|
+
if (skipOverwrite) {
|
|
1034
|
+
return {
|
|
1035
|
+
type: "skip",
|
|
1036
|
+
reason: "skipOverwrite"
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
const src = asBuffer(source);
|
|
1040
|
+
let destSize = 0;
|
|
1041
|
+
try {
|
|
1042
|
+
const stat = await fs7.stat(targetPath);
|
|
1043
|
+
destSize = stat.size;
|
|
1044
|
+
} catch {
|
|
1045
|
+
return {
|
|
1046
|
+
type: "write",
|
|
1047
|
+
reason: "missing"
|
|
1048
|
+
};
|
|
1049
|
+
}
|
|
1050
|
+
if (destSize !== src.length) {
|
|
1051
|
+
return {
|
|
1052
|
+
type: "prompt",
|
|
1053
|
+
reason: "changed"
|
|
1054
|
+
};
|
|
1055
|
+
}
|
|
1056
|
+
const dest = await fs7.readFile(targetPath);
|
|
1057
|
+
if (!isFileChanged(src, dest)) {
|
|
1058
|
+
return {
|
|
1059
|
+
type: "skip",
|
|
1060
|
+
reason: "identical"
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1063
|
+
return {
|
|
1064
|
+
type: "prompt",
|
|
1065
|
+
reason: "changed"
|
|
1066
|
+
};
|
|
1067
|
+
}
|
|
1068
|
+
async function scheduleOverwrite(intent, options) {
|
|
1069
|
+
const { relPath, targetPath, action, pending } = options;
|
|
1070
|
+
if (intent.type === "write") {
|
|
1071
|
+
await action();
|
|
1072
|
+
return;
|
|
1073
|
+
}
|
|
1074
|
+
if (intent.type === "prompt") {
|
|
1075
|
+
pending.push({
|
|
1076
|
+
relPath,
|
|
1077
|
+
targetPath,
|
|
1078
|
+
action
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
async function flushPendingOverwrites(pending) {
|
|
1083
|
+
if (!pending.length) {
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
const selected = await checkbox2({
|
|
1087
|
+
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",
|
|
1088
|
+
choices: pending.map((item) => ({
|
|
1089
|
+
name: pc3.greenBright(item.relPath),
|
|
1090
|
+
value: item.targetPath,
|
|
1091
|
+
checked: false
|
|
1092
|
+
})),
|
|
1093
|
+
loop: false
|
|
1094
|
+
});
|
|
1095
|
+
const selectedSet = new Set(selected);
|
|
1096
|
+
for (const item of pending) {
|
|
1097
|
+
if (selectedSet.has(item.targetPath)) {
|
|
1098
|
+
await item.action();
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
// src/commands/upgrade/pkg-json.ts
|
|
1104
|
+
init_esm_shims();
|
|
1017
1105
|
import { coerce, gte, minVersion } from "semver";
|
|
1018
1106
|
|
|
1019
1107
|
// src/commands/upgrade/scripts.ts
|
|
@@ -1027,44 +1115,7 @@ var scripts = {
|
|
|
1027
1115
|
};
|
|
1028
1116
|
var scriptsEntries = Object.entries(scripts);
|
|
1029
1117
|
|
|
1030
|
-
// src/commands/upgrade/
|
|
1031
|
-
init_esm_shims();
|
|
1032
|
-
function getAssetTargets(raw) {
|
|
1033
|
-
const list = [
|
|
1034
|
-
".changeset",
|
|
1035
|
-
".husky",
|
|
1036
|
-
".vscode",
|
|
1037
|
-
".editorconfig",
|
|
1038
|
-
".gitattributes",
|
|
1039
|
-
".gitignore",
|
|
1040
|
-
".npmrc",
|
|
1041
|
-
"commitlint.config.ts",
|
|
1042
|
-
"eslint.config.js",
|
|
1043
|
-
"lint-staged.config.js",
|
|
1044
|
-
"stylelint.config.js",
|
|
1045
|
-
"monorepo.config.ts",
|
|
1046
|
-
"package.json",
|
|
1047
|
-
// pnpm
|
|
1048
|
-
"pnpm-workspace.yaml",
|
|
1049
|
-
// base tsconfig
|
|
1050
|
-
"tsconfig.json",
|
|
1051
|
-
// turbo
|
|
1052
|
-
"turbo.json",
|
|
1053
|
-
// vitest
|
|
1054
|
-
"vitest.config.ts",
|
|
1055
|
-
// 'vitest.workspace.ts',
|
|
1056
|
-
// #region docker
|
|
1057
|
-
"Dockerfile",
|
|
1058
|
-
".dockerignore"
|
|
1059
|
-
// #endregion
|
|
1060
|
-
];
|
|
1061
|
-
if (!raw) {
|
|
1062
|
-
list.push(".github", "LICENSE", "renovate.json", "SECURITY.md", "CODE_OF_CONDUCT.md", "CONTRIBUTING.md", "netlify.toml");
|
|
1063
|
-
}
|
|
1064
|
-
return list;
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
// src/commands/upgrade/index.ts
|
|
1118
|
+
// src/commands/upgrade/pkg-json.ts
|
|
1068
1119
|
function isWorkspace(version2) {
|
|
1069
1120
|
if (typeof version2 === "string") {
|
|
1070
1121
|
return version2.startsWith("workspace:");
|
|
@@ -1147,38 +1198,45 @@ function setPkgJson(sourcePkgJson, targetPkgJson, options) {
|
|
|
1147
1198
|
targetPkgJson.scripts = scripts2;
|
|
1148
1199
|
}
|
|
1149
1200
|
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
function
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1201
|
+
|
|
1202
|
+
// src/commands/upgrade/targets.ts
|
|
1203
|
+
init_esm_shims();
|
|
1204
|
+
function getAssetTargets(raw) {
|
|
1205
|
+
const list = [
|
|
1206
|
+
".changeset",
|
|
1207
|
+
".husky",
|
|
1208
|
+
".vscode",
|
|
1209
|
+
".editorconfig",
|
|
1210
|
+
".gitattributes",
|
|
1211
|
+
".gitignore",
|
|
1212
|
+
".npmrc",
|
|
1213
|
+
"commitlint.config.ts",
|
|
1214
|
+
"eslint.config.js",
|
|
1215
|
+
"lint-staged.config.js",
|
|
1216
|
+
"stylelint.config.js",
|
|
1217
|
+
"monorepo.config.ts",
|
|
1218
|
+
"package.json",
|
|
1219
|
+
// pnpm
|
|
1220
|
+
"pnpm-workspace.yaml",
|
|
1221
|
+
// base tsconfig
|
|
1222
|
+
"tsconfig.json",
|
|
1223
|
+
// turbo
|
|
1224
|
+
"turbo.json",
|
|
1225
|
+
// vitest
|
|
1226
|
+
"vitest.config.ts",
|
|
1227
|
+
// 'vitest.workspace.ts',
|
|
1228
|
+
// #region docker
|
|
1229
|
+
"Dockerfile",
|
|
1230
|
+
".dockerignore"
|
|
1231
|
+
// #endregion
|
|
1232
|
+
];
|
|
1233
|
+
if (!raw) {
|
|
1234
|
+
list.push(".github", "LICENSE", "renovate.json", "SECURITY.md", "CODE_OF_CONDUCT.md", "CONTRIBUTING.md", "netlify.toml");
|
|
1179
1235
|
}
|
|
1180
|
-
return
|
|
1236
|
+
return list;
|
|
1181
1237
|
}
|
|
1238
|
+
|
|
1239
|
+
// src/commands/upgrade/index.ts
|
|
1182
1240
|
async function upgradeMonorepo(opts) {
|
|
1183
1241
|
const cwd = opts.cwd ?? process2.cwd();
|
|
1184
1242
|
const upgradeConfig = await resolveCommandConfig("upgrade", cwd);
|
|
@@ -1199,7 +1257,7 @@ async function upgradeMonorepo(opts) {
|
|
|
1199
1257
|
const mergeTargets = upgradeConfig == null ? void 0 : upgradeConfig.mergeTargets;
|
|
1200
1258
|
let targets = configTargets.length ? mergeTargets === false ? [...configTargets] : Array.from(/* @__PURE__ */ new Set([...baseTargets, ...configTargets])) : baseTargets;
|
|
1201
1259
|
if (merged.interactive) {
|
|
1202
|
-
targets = await
|
|
1260
|
+
targets = await checkbox3({
|
|
1203
1261
|
message: "\u9009\u62E9\u4F60\u9700\u8981\u7684\u6587\u4EF6",
|
|
1204
1262
|
choices: targets.map((x) => {
|
|
1205
1263
|
return {
|
|
@@ -1215,6 +1273,7 @@ async function upgradeMonorepo(opts) {
|
|
|
1215
1273
|
const skipChangesetMarkdown = (upgradeConfig == null ? void 0 : upgradeConfig.skipChangesetMarkdown) ?? true;
|
|
1216
1274
|
const scriptOverrides = upgradeConfig == null ? void 0 : upgradeConfig.scripts;
|
|
1217
1275
|
const skipOverwrite = merged.skipOverwrite;
|
|
1276
|
+
const pendingOverwrites = [];
|
|
1218
1277
|
for await (const file of klaw(assetsDir, {
|
|
1219
1278
|
filter(p) {
|
|
1220
1279
|
const str = path13.relative(assetsDir, p);
|
|
@@ -1234,43 +1293,72 @@ async function upgradeMonorepo(opts) {
|
|
|
1234
1293
|
const targetPath = path13.resolve(absOutDir, relPath);
|
|
1235
1294
|
try {
|
|
1236
1295
|
if (relPath === "package.json") {
|
|
1237
|
-
if (!await
|
|
1296
|
+
if (!await fs8.pathExists(targetPath)) {
|
|
1238
1297
|
continue;
|
|
1239
1298
|
}
|
|
1240
|
-
const sourcePkgJson = await
|
|
1241
|
-
const targetPkgJson = await
|
|
1299
|
+
const sourcePkgJson = await fs8.readJson(file.path);
|
|
1300
|
+
const targetPkgJson = await fs8.readJson(targetPath);
|
|
1242
1301
|
setPkgJson(sourcePkgJson, targetPkgJson, { scripts: scriptOverrides });
|
|
1243
1302
|
const data = `${JSON.stringify(targetPkgJson, void 0, 2)}
|
|
1244
1303
|
`;
|
|
1245
|
-
|
|
1246
|
-
|
|
1304
|
+
const intent2 = await evaluateWriteIntent(targetPath, { skipOverwrite, source: data });
|
|
1305
|
+
const action2 = async () => {
|
|
1306
|
+
await fs8.outputFile(targetPath, data, "utf8");
|
|
1247
1307
|
logger.success(targetPath);
|
|
1248
|
-
}
|
|
1308
|
+
};
|
|
1309
|
+
await scheduleOverwrite(intent2, {
|
|
1310
|
+
relPath,
|
|
1311
|
+
targetPath,
|
|
1312
|
+
action: action2,
|
|
1313
|
+
pending: pendingOverwrites
|
|
1314
|
+
});
|
|
1249
1315
|
continue;
|
|
1250
1316
|
}
|
|
1251
1317
|
if (relPath === ".changeset/config.json" && repoName) {
|
|
1252
|
-
const changesetJson = await
|
|
1318
|
+
const changesetJson = await fs8.readJson(file.path);
|
|
1253
1319
|
(0, import_set_value6.default)(changesetJson, "changelog.1.repo", repoName);
|
|
1254
1320
|
const data = `${JSON.stringify(changesetJson, void 0, 2)}
|
|
1255
1321
|
`;
|
|
1256
|
-
|
|
1257
|
-
|
|
1322
|
+
const intent2 = await evaluateWriteIntent(targetPath, { skipOverwrite, source: data });
|
|
1323
|
+
const action2 = async () => {
|
|
1324
|
+
await fs8.outputFile(targetPath, data, "utf8");
|
|
1258
1325
|
logger.success(targetPath);
|
|
1259
|
-
}
|
|
1326
|
+
};
|
|
1327
|
+
await scheduleOverwrite(intent2, {
|
|
1328
|
+
relPath,
|
|
1329
|
+
targetPath,
|
|
1330
|
+
action: action2,
|
|
1331
|
+
pending: pendingOverwrites
|
|
1332
|
+
});
|
|
1260
1333
|
continue;
|
|
1261
1334
|
}
|
|
1262
1335
|
if (relPath === "LICENSE") {
|
|
1263
|
-
const
|
|
1264
|
-
|
|
1265
|
-
|
|
1336
|
+
const source2 = await fs8.readFile(file.path);
|
|
1337
|
+
const intent2 = await evaluateWriteIntent(targetPath, { skipOverwrite: true, source: source2 });
|
|
1338
|
+
const action2 = async () => {
|
|
1339
|
+
await fs8.outputFile(targetPath, source2);
|
|
1266
1340
|
logger.success(targetPath);
|
|
1267
|
-
}
|
|
1341
|
+
};
|
|
1342
|
+
await scheduleOverwrite(intent2, {
|
|
1343
|
+
relPath,
|
|
1344
|
+
targetPath,
|
|
1345
|
+
action: action2,
|
|
1346
|
+
pending: pendingOverwrites
|
|
1347
|
+
});
|
|
1268
1348
|
continue;
|
|
1269
1349
|
}
|
|
1270
|
-
|
|
1271
|
-
|
|
1350
|
+
const source = await fs8.readFile(file.path);
|
|
1351
|
+
const intent = await evaluateWriteIntent(targetPath, { skipOverwrite, source });
|
|
1352
|
+
const action = async () => {
|
|
1353
|
+
await fs8.outputFile(targetPath, source);
|
|
1272
1354
|
logger.success(targetPath);
|
|
1273
|
-
}
|
|
1355
|
+
};
|
|
1356
|
+
await scheduleOverwrite(intent, {
|
|
1357
|
+
relPath,
|
|
1358
|
+
targetPath,
|
|
1359
|
+
action,
|
|
1360
|
+
pending: pendingOverwrites
|
|
1361
|
+
});
|
|
1274
1362
|
} catch (error) {
|
|
1275
1363
|
if (isIgnorableFsError(error)) {
|
|
1276
1364
|
continue;
|
|
@@ -1278,6 +1366,7 @@ async function upgradeMonorepo(opts) {
|
|
|
1278
1366
|
throw error;
|
|
1279
1367
|
}
|
|
1280
1368
|
}
|
|
1369
|
+
await flushPendingOverwrites(pendingOverwrites);
|
|
1281
1370
|
}
|
|
1282
1371
|
|
|
1283
1372
|
// src/commands/index.ts
|
package/dist/cli.cjs
CHANGED
|
@@ -605,7 +605,7 @@ var import_node_url = require("url");
|
|
|
605
605
|
|
|
606
606
|
// package.json
|
|
607
607
|
var name = "@icebreakers/monorepo";
|
|
608
|
-
var version = "2.0.
|
|
608
|
+
var version = "2.0.10";
|
|
609
609
|
|
|
610
610
|
// src/constants.ts
|
|
611
611
|
var packageJsonPath = (0, import_node_url.fileURLToPath)(new URL("../package.json", importMetaUrl));
|
|
@@ -980,15 +980,11 @@ ${Array.from(set7).map((x) => `- ${import_picocolors2.default.green(x ?? "")}`).
|
|
|
980
980
|
|
|
981
981
|
// src/commands/upgrade/index.ts
|
|
982
982
|
init_cjs_shims();
|
|
983
|
-
var import_node_buffer = require("buffer");
|
|
984
983
|
var import_node_process2 = __toESM(require("process"), 1);
|
|
985
|
-
var
|
|
986
|
-
var
|
|
987
|
-
var import_fs_extra7 = __toESM(require("fs-extra"), 1);
|
|
984
|
+
var import_checkbox3 = __toESM(require("@inquirer/checkbox"), 1);
|
|
985
|
+
var import_fs_extra8 = __toESM(require("fs-extra"), 1);
|
|
988
986
|
var import_klaw = __toESM(require("klaw"), 1);
|
|
989
987
|
var import_pathe11 = __toESM(require("pathe"), 1);
|
|
990
|
-
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
991
|
-
var import_semver = require("semver");
|
|
992
988
|
var import_set_value6 = __toESM(require_set_value(), 1);
|
|
993
989
|
|
|
994
990
|
// src/utils/fs.ts
|
|
@@ -1034,6 +1030,98 @@ function isMatch(str, arr) {
|
|
|
1034
1030
|
return false;
|
|
1035
1031
|
}
|
|
1036
1032
|
|
|
1033
|
+
// src/commands/upgrade/overwrite.ts
|
|
1034
|
+
init_cjs_shims();
|
|
1035
|
+
var import_node_buffer = require("buffer");
|
|
1036
|
+
var import_checkbox2 = __toESM(require("@inquirer/checkbox"), 1);
|
|
1037
|
+
var import_fs_extra7 = __toESM(require("fs-extra"), 1);
|
|
1038
|
+
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
1039
|
+
function asBuffer(data) {
|
|
1040
|
+
return typeof data === "string" ? import_node_buffer.Buffer.from(data) : data;
|
|
1041
|
+
}
|
|
1042
|
+
async function evaluateWriteIntent(targetPath, options) {
|
|
1043
|
+
const { skipOverwrite, source } = options;
|
|
1044
|
+
const exists = await import_fs_extra7.default.pathExists(targetPath);
|
|
1045
|
+
if (!exists) {
|
|
1046
|
+
return {
|
|
1047
|
+
type: "write",
|
|
1048
|
+
reason: "missing"
|
|
1049
|
+
};
|
|
1050
|
+
}
|
|
1051
|
+
if (skipOverwrite) {
|
|
1052
|
+
return {
|
|
1053
|
+
type: "skip",
|
|
1054
|
+
reason: "skipOverwrite"
|
|
1055
|
+
};
|
|
1056
|
+
}
|
|
1057
|
+
const src = asBuffer(source);
|
|
1058
|
+
let destSize = 0;
|
|
1059
|
+
try {
|
|
1060
|
+
const stat = await import_fs_extra7.default.stat(targetPath);
|
|
1061
|
+
destSize = stat.size;
|
|
1062
|
+
} catch {
|
|
1063
|
+
return {
|
|
1064
|
+
type: "write",
|
|
1065
|
+
reason: "missing"
|
|
1066
|
+
};
|
|
1067
|
+
}
|
|
1068
|
+
if (destSize !== src.length) {
|
|
1069
|
+
return {
|
|
1070
|
+
type: "prompt",
|
|
1071
|
+
reason: "changed"
|
|
1072
|
+
};
|
|
1073
|
+
}
|
|
1074
|
+
const dest = await import_fs_extra7.default.readFile(targetPath);
|
|
1075
|
+
if (!isFileChanged(src, dest)) {
|
|
1076
|
+
return {
|
|
1077
|
+
type: "skip",
|
|
1078
|
+
reason: "identical"
|
|
1079
|
+
};
|
|
1080
|
+
}
|
|
1081
|
+
return {
|
|
1082
|
+
type: "prompt",
|
|
1083
|
+
reason: "changed"
|
|
1084
|
+
};
|
|
1085
|
+
}
|
|
1086
|
+
async function scheduleOverwrite(intent, options) {
|
|
1087
|
+
const { relPath, targetPath, action, pending } = options;
|
|
1088
|
+
if (intent.type === "write") {
|
|
1089
|
+
await action();
|
|
1090
|
+
return;
|
|
1091
|
+
}
|
|
1092
|
+
if (intent.type === "prompt") {
|
|
1093
|
+
pending.push({
|
|
1094
|
+
relPath,
|
|
1095
|
+
targetPath,
|
|
1096
|
+
action
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
async function flushPendingOverwrites(pending) {
|
|
1101
|
+
if (!pending.length) {
|
|
1102
|
+
return;
|
|
1103
|
+
}
|
|
1104
|
+
const selected = await (0, import_checkbox2.default)({
|
|
1105
|
+
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",
|
|
1106
|
+
choices: pending.map((item) => ({
|
|
1107
|
+
name: import_picocolors3.default.greenBright(item.relPath),
|
|
1108
|
+
value: item.targetPath,
|
|
1109
|
+
checked: false
|
|
1110
|
+
})),
|
|
1111
|
+
loop: false
|
|
1112
|
+
});
|
|
1113
|
+
const selectedSet = new Set(selected);
|
|
1114
|
+
for (const item of pending) {
|
|
1115
|
+
if (selectedSet.has(item.targetPath)) {
|
|
1116
|
+
await item.action();
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
// src/commands/upgrade/pkg-json.ts
|
|
1122
|
+
init_cjs_shims();
|
|
1123
|
+
var import_semver = require("semver");
|
|
1124
|
+
|
|
1037
1125
|
// src/commands/upgrade/scripts.ts
|
|
1038
1126
|
init_cjs_shims();
|
|
1039
1127
|
var scripts = {
|
|
@@ -1045,44 +1133,7 @@ var scripts = {
|
|
|
1045
1133
|
};
|
|
1046
1134
|
var scriptsEntries = Object.entries(scripts);
|
|
1047
1135
|
|
|
1048
|
-
// src/commands/upgrade/
|
|
1049
|
-
init_cjs_shims();
|
|
1050
|
-
function getAssetTargets(raw) {
|
|
1051
|
-
const list = [
|
|
1052
|
-
".changeset",
|
|
1053
|
-
".husky",
|
|
1054
|
-
".vscode",
|
|
1055
|
-
".editorconfig",
|
|
1056
|
-
".gitattributes",
|
|
1057
|
-
".gitignore",
|
|
1058
|
-
".npmrc",
|
|
1059
|
-
"commitlint.config.ts",
|
|
1060
|
-
"eslint.config.js",
|
|
1061
|
-
"lint-staged.config.js",
|
|
1062
|
-
"stylelint.config.js",
|
|
1063
|
-
"monorepo.config.ts",
|
|
1064
|
-
"package.json",
|
|
1065
|
-
// pnpm
|
|
1066
|
-
"pnpm-workspace.yaml",
|
|
1067
|
-
// base tsconfig
|
|
1068
|
-
"tsconfig.json",
|
|
1069
|
-
// turbo
|
|
1070
|
-
"turbo.json",
|
|
1071
|
-
// vitest
|
|
1072
|
-
"vitest.config.ts",
|
|
1073
|
-
// 'vitest.workspace.ts',
|
|
1074
|
-
// #region docker
|
|
1075
|
-
"Dockerfile",
|
|
1076
|
-
".dockerignore"
|
|
1077
|
-
// #endregion
|
|
1078
|
-
];
|
|
1079
|
-
if (!raw) {
|
|
1080
|
-
list.push(".github", "LICENSE", "renovate.json", "SECURITY.md", "CODE_OF_CONDUCT.md", "CONTRIBUTING.md", "netlify.toml");
|
|
1081
|
-
}
|
|
1082
|
-
return list;
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1085
|
-
// src/commands/upgrade/index.ts
|
|
1136
|
+
// src/commands/upgrade/pkg-json.ts
|
|
1086
1137
|
function isWorkspace(version2) {
|
|
1087
1138
|
if (typeof version2 === "string") {
|
|
1088
1139
|
return version2.startsWith("workspace:");
|
|
@@ -1165,38 +1216,45 @@ function setPkgJson(sourcePkgJson, targetPkgJson, options) {
|
|
|
1165
1216
|
targetPkgJson.scripts = scripts2;
|
|
1166
1217
|
}
|
|
1167
1218
|
}
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
function
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1219
|
+
|
|
1220
|
+
// src/commands/upgrade/targets.ts
|
|
1221
|
+
init_cjs_shims();
|
|
1222
|
+
function getAssetTargets(raw) {
|
|
1223
|
+
const list = [
|
|
1224
|
+
".changeset",
|
|
1225
|
+
".husky",
|
|
1226
|
+
".vscode",
|
|
1227
|
+
".editorconfig",
|
|
1228
|
+
".gitattributes",
|
|
1229
|
+
".gitignore",
|
|
1230
|
+
".npmrc",
|
|
1231
|
+
"commitlint.config.ts",
|
|
1232
|
+
"eslint.config.js",
|
|
1233
|
+
"lint-staged.config.js",
|
|
1234
|
+
"stylelint.config.js",
|
|
1235
|
+
"monorepo.config.ts",
|
|
1236
|
+
"package.json",
|
|
1237
|
+
// pnpm
|
|
1238
|
+
"pnpm-workspace.yaml",
|
|
1239
|
+
// base tsconfig
|
|
1240
|
+
"tsconfig.json",
|
|
1241
|
+
// turbo
|
|
1242
|
+
"turbo.json",
|
|
1243
|
+
// vitest
|
|
1244
|
+
"vitest.config.ts",
|
|
1245
|
+
// 'vitest.workspace.ts',
|
|
1246
|
+
// #region docker
|
|
1247
|
+
"Dockerfile",
|
|
1248
|
+
".dockerignore"
|
|
1249
|
+
// #endregion
|
|
1250
|
+
];
|
|
1251
|
+
if (!raw) {
|
|
1252
|
+
list.push(".github", "LICENSE", "renovate.json", "SECURITY.md", "CODE_OF_CONDUCT.md", "CONTRIBUTING.md", "netlify.toml");
|
|
1197
1253
|
}
|
|
1198
|
-
return
|
|
1254
|
+
return list;
|
|
1199
1255
|
}
|
|
1256
|
+
|
|
1257
|
+
// src/commands/upgrade/index.ts
|
|
1200
1258
|
async function upgradeMonorepo(opts) {
|
|
1201
1259
|
const cwd2 = opts.cwd ?? import_node_process2.default.cwd();
|
|
1202
1260
|
const upgradeConfig = await resolveCommandConfig("upgrade", cwd2);
|
|
@@ -1217,7 +1275,7 @@ async function upgradeMonorepo(opts) {
|
|
|
1217
1275
|
const mergeTargets = upgradeConfig == null ? void 0 : upgradeConfig.mergeTargets;
|
|
1218
1276
|
let targets = configTargets.length ? mergeTargets === false ? [...configTargets] : Array.from(/* @__PURE__ */ new Set([...baseTargets, ...configTargets])) : baseTargets;
|
|
1219
1277
|
if (merged.interactive) {
|
|
1220
|
-
targets = await (0,
|
|
1278
|
+
targets = await (0, import_checkbox3.default)({
|
|
1221
1279
|
message: "\u9009\u62E9\u4F60\u9700\u8981\u7684\u6587\u4EF6",
|
|
1222
1280
|
choices: targets.map((x) => {
|
|
1223
1281
|
return {
|
|
@@ -1233,6 +1291,7 @@ async function upgradeMonorepo(opts) {
|
|
|
1233
1291
|
const skipChangesetMarkdown = (upgradeConfig == null ? void 0 : upgradeConfig.skipChangesetMarkdown) ?? true;
|
|
1234
1292
|
const scriptOverrides = upgradeConfig == null ? void 0 : upgradeConfig.scripts;
|
|
1235
1293
|
const skipOverwrite = merged.skipOverwrite;
|
|
1294
|
+
const pendingOverwrites = [];
|
|
1236
1295
|
for await (const file of (0, import_klaw.default)(assetsDir, {
|
|
1237
1296
|
filter(p) {
|
|
1238
1297
|
const str = import_pathe11.default.relative(assetsDir, p);
|
|
@@ -1252,43 +1311,72 @@ async function upgradeMonorepo(opts) {
|
|
|
1252
1311
|
const targetPath = import_pathe11.default.resolve(absOutDir, relPath);
|
|
1253
1312
|
try {
|
|
1254
1313
|
if (relPath === "package.json") {
|
|
1255
|
-
if (!await
|
|
1314
|
+
if (!await import_fs_extra8.default.pathExists(targetPath)) {
|
|
1256
1315
|
continue;
|
|
1257
1316
|
}
|
|
1258
|
-
const sourcePkgJson = await
|
|
1259
|
-
const targetPkgJson = await
|
|
1317
|
+
const sourcePkgJson = await import_fs_extra8.default.readJson(file.path);
|
|
1318
|
+
const targetPkgJson = await import_fs_extra8.default.readJson(targetPath);
|
|
1260
1319
|
setPkgJson(sourcePkgJson, targetPkgJson, { scripts: scriptOverrides });
|
|
1261
1320
|
const data = `${JSON.stringify(targetPkgJson, void 0, 2)}
|
|
1262
1321
|
`;
|
|
1263
|
-
|
|
1264
|
-
|
|
1322
|
+
const intent2 = await evaluateWriteIntent(targetPath, { skipOverwrite, source: data });
|
|
1323
|
+
const action2 = async () => {
|
|
1324
|
+
await import_fs_extra8.default.outputFile(targetPath, data, "utf8");
|
|
1265
1325
|
logger.success(targetPath);
|
|
1266
|
-
}
|
|
1326
|
+
};
|
|
1327
|
+
await scheduleOverwrite(intent2, {
|
|
1328
|
+
relPath,
|
|
1329
|
+
targetPath,
|
|
1330
|
+
action: action2,
|
|
1331
|
+
pending: pendingOverwrites
|
|
1332
|
+
});
|
|
1267
1333
|
continue;
|
|
1268
1334
|
}
|
|
1269
1335
|
if (relPath === ".changeset/config.json" && repoName) {
|
|
1270
|
-
const changesetJson = await
|
|
1336
|
+
const changesetJson = await import_fs_extra8.default.readJson(file.path);
|
|
1271
1337
|
(0, import_set_value6.default)(changesetJson, "changelog.1.repo", repoName);
|
|
1272
1338
|
const data = `${JSON.stringify(changesetJson, void 0, 2)}
|
|
1273
1339
|
`;
|
|
1274
|
-
|
|
1275
|
-
|
|
1340
|
+
const intent2 = await evaluateWriteIntent(targetPath, { skipOverwrite, source: data });
|
|
1341
|
+
const action2 = async () => {
|
|
1342
|
+
await import_fs_extra8.default.outputFile(targetPath, data, "utf8");
|
|
1276
1343
|
logger.success(targetPath);
|
|
1277
|
-
}
|
|
1344
|
+
};
|
|
1345
|
+
await scheduleOverwrite(intent2, {
|
|
1346
|
+
relPath,
|
|
1347
|
+
targetPath,
|
|
1348
|
+
action: action2,
|
|
1349
|
+
pending: pendingOverwrites
|
|
1350
|
+
});
|
|
1278
1351
|
continue;
|
|
1279
1352
|
}
|
|
1280
1353
|
if (relPath === "LICENSE") {
|
|
1281
|
-
const
|
|
1282
|
-
|
|
1283
|
-
|
|
1354
|
+
const source2 = await import_fs_extra8.default.readFile(file.path);
|
|
1355
|
+
const intent2 = await evaluateWriteIntent(targetPath, { skipOverwrite: true, source: source2 });
|
|
1356
|
+
const action2 = async () => {
|
|
1357
|
+
await import_fs_extra8.default.outputFile(targetPath, source2);
|
|
1284
1358
|
logger.success(targetPath);
|
|
1285
|
-
}
|
|
1359
|
+
};
|
|
1360
|
+
await scheduleOverwrite(intent2, {
|
|
1361
|
+
relPath,
|
|
1362
|
+
targetPath,
|
|
1363
|
+
action: action2,
|
|
1364
|
+
pending: pendingOverwrites
|
|
1365
|
+
});
|
|
1286
1366
|
continue;
|
|
1287
1367
|
}
|
|
1288
|
-
|
|
1289
|
-
|
|
1368
|
+
const source = await import_fs_extra8.default.readFile(file.path);
|
|
1369
|
+
const intent = await evaluateWriteIntent(targetPath, { skipOverwrite, source });
|
|
1370
|
+
const action = async () => {
|
|
1371
|
+
await import_fs_extra8.default.outputFile(targetPath, source);
|
|
1290
1372
|
logger.success(targetPath);
|
|
1291
|
-
}
|
|
1373
|
+
};
|
|
1374
|
+
await scheduleOverwrite(intent, {
|
|
1375
|
+
relPath,
|
|
1376
|
+
targetPath,
|
|
1377
|
+
action,
|
|
1378
|
+
pending: pendingOverwrites
|
|
1379
|
+
});
|
|
1292
1380
|
} catch (error) {
|
|
1293
1381
|
if (isIgnorableFsError(error)) {
|
|
1294
1382
|
continue;
|
|
@@ -1296,6 +1384,7 @@ async function upgradeMonorepo(opts) {
|
|
|
1296
1384
|
throw error;
|
|
1297
1385
|
}
|
|
1298
1386
|
}
|
|
1387
|
+
await flushPendingOverwrites(pendingOverwrites);
|
|
1299
1388
|
}
|
|
1300
1389
|
|
|
1301
1390
|
// src/cli/program.ts
|
package/dist/cli.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -638,7 +638,7 @@ var import_node_url = require("url");
|
|
|
638
638
|
|
|
639
639
|
// package.json
|
|
640
640
|
var name = "@icebreakers/monorepo";
|
|
641
|
-
var version = "2.0.
|
|
641
|
+
var version = "2.0.10";
|
|
642
642
|
|
|
643
643
|
// src/constants.ts
|
|
644
644
|
var packageJsonPath = (0, import_node_url.fileURLToPath)(new URL("../package.json", importMetaUrl));
|
|
@@ -1013,15 +1013,11 @@ ${Array.from(set7).map((x) => `- ${import_picocolors2.default.green(x ?? "")}`).
|
|
|
1013
1013
|
|
|
1014
1014
|
// src/commands/upgrade/index.ts
|
|
1015
1015
|
init_cjs_shims();
|
|
1016
|
-
var import_node_buffer = require("buffer");
|
|
1017
1016
|
var import_node_process2 = __toESM(require("process"), 1);
|
|
1018
|
-
var
|
|
1019
|
-
var
|
|
1020
|
-
var import_fs_extra7 = __toESM(require("fs-extra"), 1);
|
|
1017
|
+
var import_checkbox3 = __toESM(require("@inquirer/checkbox"), 1);
|
|
1018
|
+
var import_fs_extra8 = __toESM(require("fs-extra"), 1);
|
|
1021
1019
|
var import_klaw = __toESM(require("klaw"), 1);
|
|
1022
1020
|
var import_pathe11 = __toESM(require("pathe"), 1);
|
|
1023
|
-
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
1024
|
-
var import_semver = require("semver");
|
|
1025
1021
|
var import_set_value6 = __toESM(require_set_value(), 1);
|
|
1026
1022
|
|
|
1027
1023
|
// src/utils/fs.ts
|
|
@@ -1067,6 +1063,98 @@ function isMatch(str, arr) {
|
|
|
1067
1063
|
return false;
|
|
1068
1064
|
}
|
|
1069
1065
|
|
|
1066
|
+
// src/commands/upgrade/overwrite.ts
|
|
1067
|
+
init_cjs_shims();
|
|
1068
|
+
var import_node_buffer = require("buffer");
|
|
1069
|
+
var import_checkbox2 = __toESM(require("@inquirer/checkbox"), 1);
|
|
1070
|
+
var import_fs_extra7 = __toESM(require("fs-extra"), 1);
|
|
1071
|
+
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
1072
|
+
function asBuffer(data) {
|
|
1073
|
+
return typeof data === "string" ? import_node_buffer.Buffer.from(data) : data;
|
|
1074
|
+
}
|
|
1075
|
+
async function evaluateWriteIntent(targetPath, options) {
|
|
1076
|
+
const { skipOverwrite, source } = options;
|
|
1077
|
+
const exists = await import_fs_extra7.default.pathExists(targetPath);
|
|
1078
|
+
if (!exists) {
|
|
1079
|
+
return {
|
|
1080
|
+
type: "write",
|
|
1081
|
+
reason: "missing"
|
|
1082
|
+
};
|
|
1083
|
+
}
|
|
1084
|
+
if (skipOverwrite) {
|
|
1085
|
+
return {
|
|
1086
|
+
type: "skip",
|
|
1087
|
+
reason: "skipOverwrite"
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
const src = asBuffer(source);
|
|
1091
|
+
let destSize = 0;
|
|
1092
|
+
try {
|
|
1093
|
+
const stat = await import_fs_extra7.default.stat(targetPath);
|
|
1094
|
+
destSize = stat.size;
|
|
1095
|
+
} catch {
|
|
1096
|
+
return {
|
|
1097
|
+
type: "write",
|
|
1098
|
+
reason: "missing"
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
if (destSize !== src.length) {
|
|
1102
|
+
return {
|
|
1103
|
+
type: "prompt",
|
|
1104
|
+
reason: "changed"
|
|
1105
|
+
};
|
|
1106
|
+
}
|
|
1107
|
+
const dest = await import_fs_extra7.default.readFile(targetPath);
|
|
1108
|
+
if (!isFileChanged(src, dest)) {
|
|
1109
|
+
return {
|
|
1110
|
+
type: "skip",
|
|
1111
|
+
reason: "identical"
|
|
1112
|
+
};
|
|
1113
|
+
}
|
|
1114
|
+
return {
|
|
1115
|
+
type: "prompt",
|
|
1116
|
+
reason: "changed"
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
async function scheduleOverwrite(intent, options) {
|
|
1120
|
+
const { relPath, targetPath, action, pending } = options;
|
|
1121
|
+
if (intent.type === "write") {
|
|
1122
|
+
await action();
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
if (intent.type === "prompt") {
|
|
1126
|
+
pending.push({
|
|
1127
|
+
relPath,
|
|
1128
|
+
targetPath,
|
|
1129
|
+
action
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
async function flushPendingOverwrites(pending) {
|
|
1134
|
+
if (!pending.length) {
|
|
1135
|
+
return;
|
|
1136
|
+
}
|
|
1137
|
+
const selected = await (0, import_checkbox2.default)({
|
|
1138
|
+
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",
|
|
1139
|
+
choices: pending.map((item) => ({
|
|
1140
|
+
name: import_picocolors3.default.greenBright(item.relPath),
|
|
1141
|
+
value: item.targetPath,
|
|
1142
|
+
checked: false
|
|
1143
|
+
})),
|
|
1144
|
+
loop: false
|
|
1145
|
+
});
|
|
1146
|
+
const selectedSet = new Set(selected);
|
|
1147
|
+
for (const item of pending) {
|
|
1148
|
+
if (selectedSet.has(item.targetPath)) {
|
|
1149
|
+
await item.action();
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
// src/commands/upgrade/pkg-json.ts
|
|
1155
|
+
init_cjs_shims();
|
|
1156
|
+
var import_semver = require("semver");
|
|
1157
|
+
|
|
1070
1158
|
// src/commands/upgrade/scripts.ts
|
|
1071
1159
|
init_cjs_shims();
|
|
1072
1160
|
var scripts = {
|
|
@@ -1078,44 +1166,7 @@ var scripts = {
|
|
|
1078
1166
|
};
|
|
1079
1167
|
var scriptsEntries = Object.entries(scripts);
|
|
1080
1168
|
|
|
1081
|
-
// src/commands/upgrade/
|
|
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
|
|
1169
|
+
// src/commands/upgrade/pkg-json.ts
|
|
1119
1170
|
function isWorkspace(version2) {
|
|
1120
1171
|
if (typeof version2 === "string") {
|
|
1121
1172
|
return version2.startsWith("workspace:");
|
|
@@ -1198,38 +1249,45 @@ function setPkgJson(sourcePkgJson, targetPkgJson, options) {
|
|
|
1198
1249
|
targetPkgJson.scripts = scripts2;
|
|
1199
1250
|
}
|
|
1200
1251
|
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
function
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1252
|
+
|
|
1253
|
+
// src/commands/upgrade/targets.ts
|
|
1254
|
+
init_cjs_shims();
|
|
1255
|
+
function getAssetTargets(raw) {
|
|
1256
|
+
const list = [
|
|
1257
|
+
".changeset",
|
|
1258
|
+
".husky",
|
|
1259
|
+
".vscode",
|
|
1260
|
+
".editorconfig",
|
|
1261
|
+
".gitattributes",
|
|
1262
|
+
".gitignore",
|
|
1263
|
+
".npmrc",
|
|
1264
|
+
"commitlint.config.ts",
|
|
1265
|
+
"eslint.config.js",
|
|
1266
|
+
"lint-staged.config.js",
|
|
1267
|
+
"stylelint.config.js",
|
|
1268
|
+
"monorepo.config.ts",
|
|
1269
|
+
"package.json",
|
|
1270
|
+
// pnpm
|
|
1271
|
+
"pnpm-workspace.yaml",
|
|
1272
|
+
// base tsconfig
|
|
1273
|
+
"tsconfig.json",
|
|
1274
|
+
// turbo
|
|
1275
|
+
"turbo.json",
|
|
1276
|
+
// vitest
|
|
1277
|
+
"vitest.config.ts",
|
|
1278
|
+
// 'vitest.workspace.ts',
|
|
1279
|
+
// #region docker
|
|
1280
|
+
"Dockerfile",
|
|
1281
|
+
".dockerignore"
|
|
1282
|
+
// #endregion
|
|
1283
|
+
];
|
|
1284
|
+
if (!raw) {
|
|
1285
|
+
list.push(".github", "LICENSE", "renovate.json", "SECURITY.md", "CODE_OF_CONDUCT.md", "CONTRIBUTING.md", "netlify.toml");
|
|
1230
1286
|
}
|
|
1231
|
-
return
|
|
1287
|
+
return list;
|
|
1232
1288
|
}
|
|
1289
|
+
|
|
1290
|
+
// src/commands/upgrade/index.ts
|
|
1233
1291
|
async function upgradeMonorepo(opts) {
|
|
1234
1292
|
const cwd = opts.cwd ?? import_node_process2.default.cwd();
|
|
1235
1293
|
const upgradeConfig = await resolveCommandConfig("upgrade", cwd);
|
|
@@ -1250,7 +1308,7 @@ async function upgradeMonorepo(opts) {
|
|
|
1250
1308
|
const mergeTargets = upgradeConfig == null ? void 0 : upgradeConfig.mergeTargets;
|
|
1251
1309
|
let targets = configTargets.length ? mergeTargets === false ? [...configTargets] : Array.from(/* @__PURE__ */ new Set([...baseTargets, ...configTargets])) : baseTargets;
|
|
1252
1310
|
if (merged.interactive) {
|
|
1253
|
-
targets = await (0,
|
|
1311
|
+
targets = await (0, import_checkbox3.default)({
|
|
1254
1312
|
message: "\u9009\u62E9\u4F60\u9700\u8981\u7684\u6587\u4EF6",
|
|
1255
1313
|
choices: targets.map((x) => {
|
|
1256
1314
|
return {
|
|
@@ -1266,6 +1324,7 @@ async function upgradeMonorepo(opts) {
|
|
|
1266
1324
|
const skipChangesetMarkdown = (upgradeConfig == null ? void 0 : upgradeConfig.skipChangesetMarkdown) ?? true;
|
|
1267
1325
|
const scriptOverrides = upgradeConfig == null ? void 0 : upgradeConfig.scripts;
|
|
1268
1326
|
const skipOverwrite = merged.skipOverwrite;
|
|
1327
|
+
const pendingOverwrites = [];
|
|
1269
1328
|
for await (const file of (0, import_klaw.default)(assetsDir, {
|
|
1270
1329
|
filter(p) {
|
|
1271
1330
|
const str = import_pathe11.default.relative(assetsDir, p);
|
|
@@ -1285,43 +1344,72 @@ async function upgradeMonorepo(opts) {
|
|
|
1285
1344
|
const targetPath = import_pathe11.default.resolve(absOutDir, relPath);
|
|
1286
1345
|
try {
|
|
1287
1346
|
if (relPath === "package.json") {
|
|
1288
|
-
if (!await
|
|
1347
|
+
if (!await import_fs_extra8.default.pathExists(targetPath)) {
|
|
1289
1348
|
continue;
|
|
1290
1349
|
}
|
|
1291
|
-
const sourcePkgJson = await
|
|
1292
|
-
const targetPkgJson = await
|
|
1350
|
+
const sourcePkgJson = await import_fs_extra8.default.readJson(file.path);
|
|
1351
|
+
const targetPkgJson = await import_fs_extra8.default.readJson(targetPath);
|
|
1293
1352
|
setPkgJson(sourcePkgJson, targetPkgJson, { scripts: scriptOverrides });
|
|
1294
1353
|
const data = `${JSON.stringify(targetPkgJson, void 0, 2)}
|
|
1295
1354
|
`;
|
|
1296
|
-
|
|
1297
|
-
|
|
1355
|
+
const intent2 = await evaluateWriteIntent(targetPath, { skipOverwrite, source: data });
|
|
1356
|
+
const action2 = async () => {
|
|
1357
|
+
await import_fs_extra8.default.outputFile(targetPath, data, "utf8");
|
|
1298
1358
|
logger.success(targetPath);
|
|
1299
|
-
}
|
|
1359
|
+
};
|
|
1360
|
+
await scheduleOverwrite(intent2, {
|
|
1361
|
+
relPath,
|
|
1362
|
+
targetPath,
|
|
1363
|
+
action: action2,
|
|
1364
|
+
pending: pendingOverwrites
|
|
1365
|
+
});
|
|
1300
1366
|
continue;
|
|
1301
1367
|
}
|
|
1302
1368
|
if (relPath === ".changeset/config.json" && repoName) {
|
|
1303
|
-
const changesetJson = await
|
|
1369
|
+
const changesetJson = await import_fs_extra8.default.readJson(file.path);
|
|
1304
1370
|
(0, import_set_value6.default)(changesetJson, "changelog.1.repo", repoName);
|
|
1305
1371
|
const data = `${JSON.stringify(changesetJson, void 0, 2)}
|
|
1306
1372
|
`;
|
|
1307
|
-
|
|
1308
|
-
|
|
1373
|
+
const intent2 = await evaluateWriteIntent(targetPath, { skipOverwrite, source: data });
|
|
1374
|
+
const action2 = async () => {
|
|
1375
|
+
await import_fs_extra8.default.outputFile(targetPath, data, "utf8");
|
|
1309
1376
|
logger.success(targetPath);
|
|
1310
|
-
}
|
|
1377
|
+
};
|
|
1378
|
+
await scheduleOverwrite(intent2, {
|
|
1379
|
+
relPath,
|
|
1380
|
+
targetPath,
|
|
1381
|
+
action: action2,
|
|
1382
|
+
pending: pendingOverwrites
|
|
1383
|
+
});
|
|
1311
1384
|
continue;
|
|
1312
1385
|
}
|
|
1313
1386
|
if (relPath === "LICENSE") {
|
|
1314
|
-
const
|
|
1315
|
-
|
|
1316
|
-
|
|
1387
|
+
const source2 = await import_fs_extra8.default.readFile(file.path);
|
|
1388
|
+
const intent2 = await evaluateWriteIntent(targetPath, { skipOverwrite: true, source: source2 });
|
|
1389
|
+
const action2 = async () => {
|
|
1390
|
+
await import_fs_extra8.default.outputFile(targetPath, source2);
|
|
1317
1391
|
logger.success(targetPath);
|
|
1318
|
-
}
|
|
1392
|
+
};
|
|
1393
|
+
await scheduleOverwrite(intent2, {
|
|
1394
|
+
relPath,
|
|
1395
|
+
targetPath,
|
|
1396
|
+
action: action2,
|
|
1397
|
+
pending: pendingOverwrites
|
|
1398
|
+
});
|
|
1319
1399
|
continue;
|
|
1320
1400
|
}
|
|
1321
|
-
|
|
1322
|
-
|
|
1401
|
+
const source = await import_fs_extra8.default.readFile(file.path);
|
|
1402
|
+
const intent = await evaluateWriteIntent(targetPath, { skipOverwrite, source });
|
|
1403
|
+
const action = async () => {
|
|
1404
|
+
await import_fs_extra8.default.outputFile(targetPath, source);
|
|
1323
1405
|
logger.success(targetPath);
|
|
1324
|
-
}
|
|
1406
|
+
};
|
|
1407
|
+
await scheduleOverwrite(intent, {
|
|
1408
|
+
relPath,
|
|
1409
|
+
targetPath,
|
|
1410
|
+
action,
|
|
1411
|
+
pending: pendingOverwrites
|
|
1412
|
+
});
|
|
1325
1413
|
} catch (error) {
|
|
1326
1414
|
if (isIgnorableFsError(error)) {
|
|
1327
1415
|
continue;
|
|
@@ -1329,6 +1417,7 @@ async function upgradeMonorepo(opts) {
|
|
|
1329
1417
|
throw error;
|
|
1330
1418
|
}
|
|
1331
1419
|
}
|
|
1420
|
+
await flushPendingOverwrites(pendingOverwrites);
|
|
1332
1421
|
}
|
|
1333
1422
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1334
1423
|
0 && (module.exports = {
|
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.
|
|
272
|
+
var version = "2.0.10";
|
|
273
273
|
|
|
274
274
|
/**
|
|
275
275
|
* @icebreakers/monorepo 包的根目录,所有模板与资产目录都以此为基准。
|
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.
|
|
272
|
+
var version = "2.0.10";
|
|
273
273
|
|
|
274
274
|
/**
|
|
275
275
|
* @icebreakers/monorepo 包的根目录,所有模板与资产目录都以此为基准。
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icebreakers/monorepo",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.10",
|
|
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",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "./node_modules/wrangler/config-schema.json",
|
|
3
3
|
"name": "monorepo-client",
|
|
4
|
-
"compatibility_date": "2025-
|
|
4
|
+
"compatibility_date": "2025-10-16",
|
|
5
5
|
"main": "./worker/fetch-entry.ts",
|
|
6
6
|
"assets": {
|
|
7
7
|
"not_found_handling": "single-page-application"
|