@icebreakers/monorepo 5.1.0 → 5.2.0
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/README.md +16 -209
- package/README.zh-CN.md +23 -0
- package/dist/cli.mjs +228 -207
- package/dist/{commands-BD9u8I6D.mjs → commands-BqUFCJA_.mjs} +552 -354
- package/dist/{create-flow-D_SecUxo.mjs → create-flow-BE4Nd902.mjs} +32 -32
- package/dist/{index-cBqxgIwY.d.mts → index-B0fwhqup.d.mts} +2 -2
- package/dist/index.d.mts +33 -3
- package/dist/index.mjs +4 -4
- package/dist/{tooling-Bn3XOfO0.mjs → tooling-CdZRpvYw.mjs} +3 -8
- package/dist/tooling-entry.d.mts +1 -1
- package/dist/tooling-entry.mjs +1 -1
- package/dist/types-BS9l6MOk.mjs +416 -0
- package/package.json +9 -9
- package/dist/types-S6igCe0w.mjs +0 -215
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
2
|
import { i as getWorkspacePackages, n as getWorkspaceData, r as getWorkspacePackageSummaries } from "./workspace-MCKewElu.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { b as isIgnorableFsError, c as devDependencies$1, d as localize, i as packageDir, m as logger, n as assetsDir, o as templatesDir, s as dependencies, t as initToolingTargets, u as version$1, y as fs$1 } from "./types-BS9l6MOk.mjs";
|
|
4
4
|
import { a as loadMonorepoConfig, c as resolveToolingConfig, i as getRepoctlConfigCandidates, o as loadMonorepoConfigDetails, s as resolveCommandConfig } from "./config-p842Knhq.mjs";
|
|
5
|
-
import { f as defineTsconfigConfig } from "./tooling-
|
|
5
|
+
import { f as defineTsconfigConfig } from "./tooling-CdZRpvYw.mjs";
|
|
6
6
|
import gitUrlParse from "git-url-parse";
|
|
7
7
|
import { simpleGit } from "simple-git";
|
|
8
8
|
import { findWorkspaceDir } from "@pnpm/find-workspace-dir";
|
|
9
9
|
import path from "pathe";
|
|
10
10
|
import process from "node:process";
|
|
11
|
-
import { access, readFile, readdir } from "node:fs/promises";
|
|
11
|
+
import { access, readFile, readdir, realpath } from "node:fs/promises";
|
|
12
12
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
13
13
|
import fs from "node:fs";
|
|
14
14
|
import path$1 from "node:path";
|
|
@@ -91,21 +91,21 @@ var GitClient = class {
|
|
|
91
91
|
//#endregion
|
|
92
92
|
//#region src/commands/ai.ts
|
|
93
93
|
const agenticSections = [
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"仓库路径",
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
"
|
|
94
|
+
["Goal and deliverables", "目标与产物"],
|
|
95
|
+
["Constraints (performance, style, compatibility, and protected scope)", "约束(性能、风格、兼容性和不可改动范围)"],
|
|
96
|
+
["Acceptance criteria (commands, expected output, and files)", "验收标准(命令、预期输出和文件)"],
|
|
97
|
+
["Repository paths", "仓库路径"],
|
|
98
|
+
["Allowed operations (file writes, commands, and network access)", "允许操作(文件写入、可运行命令和网络访问)"],
|
|
99
|
+
["Context (logs, files, modules, and related issues)", "上下文(日志、文件、模块和相关 issue)"],
|
|
100
|
+
["Milestones (root cause, design, implementation, and verification)", "里程碑(根因、设计、实现和验证)"]
|
|
101
101
|
];
|
|
102
102
|
const defaultAgenticBaseDir = "agentic/prompts";
|
|
103
103
|
function renderMarkdownTemplate() {
|
|
104
|
-
return `${agenticSections.map((
|
|
104
|
+
return `${agenticSections.map(([english, chinese]) => `## ${localize(english, chinese)}\n- `).join("\n\n")}\n`;
|
|
105
105
|
}
|
|
106
106
|
function renderJsonTemplate() {
|
|
107
107
|
const payload = {};
|
|
108
|
-
for (const
|
|
108
|
+
for (const [english] of agenticSections) payload[english] = "";
|
|
109
109
|
return `${JSON.stringify(payload, null, 2)}\n`;
|
|
110
110
|
}
|
|
111
111
|
function createTimestampFolderName(date = /* @__PURE__ */ new Date()) {
|
|
@@ -119,7 +119,7 @@ async function generateAgenticTemplate(options = {}) {
|
|
|
119
119
|
const cwd = options.cwd ?? process.cwd();
|
|
120
120
|
const format = options.format ?? "md";
|
|
121
121
|
const baseDir = options.baseDir ?? "agentic/prompts";
|
|
122
|
-
if (format !== "md" && format !== "json") throw new Error(`不支持的模板格式:${format}`);
|
|
122
|
+
if (format !== "md" && format !== "json") throw new Error(localize(`Unsupported template format: ${format}`, `不支持的模板格式:${format}`));
|
|
123
123
|
const template = format === "md" ? renderMarkdownTemplate() : renderJsonTemplate();
|
|
124
124
|
const ext = format === "json" ? "json" : "md";
|
|
125
125
|
let outputPath = options.output;
|
|
@@ -132,16 +132,16 @@ async function generateAgenticTemplate(options = {}) {
|
|
|
132
132
|
const targetDir = path.dirname(targetPath);
|
|
133
133
|
await fs$1.ensureDir(targetDir);
|
|
134
134
|
const exists = await fs$1.pathExists(targetPath);
|
|
135
|
-
if (exists && !options.force) throw new Error(`目标文件已存在:${path.relative(cwd, targetPath)}`);
|
|
135
|
+
if (exists && !options.force) throw new Error(localize(`Target file already exists: ${path.relative(cwd, targetPath)}`, `目标文件已存在:${path.relative(cwd, targetPath)}`));
|
|
136
136
|
await fs$1.outputFile(targetPath, template, "utf8");
|
|
137
|
-
const actionLabel = exists ? "已覆盖模板" : "已生成模板";
|
|
138
|
-
logger.success(`${actionLabel}
|
|
137
|
+
const actionLabel = exists ? localize("Overwrote template", "已覆盖模板") : localize("Generated template", "已生成模板");
|
|
138
|
+
logger.success(`${actionLabel}: ${path.relative(cwd, targetPath)}`);
|
|
139
139
|
return template;
|
|
140
140
|
}
|
|
141
141
|
async function loadAgenticTasks(filePath, cwd) {
|
|
142
142
|
const fullPath = path.resolve(cwd, filePath);
|
|
143
143
|
const tasks = await fs$1.readJson(fullPath);
|
|
144
|
-
if (!Array.isArray(tasks)) throw new TypeError("任务清单需要是数组");
|
|
144
|
+
if (!Array.isArray(tasks)) throw new TypeError(localize("The task list must be an array.", "任务清单需要是数组"));
|
|
145
145
|
return tasks;
|
|
146
146
|
}
|
|
147
147
|
async function generateAgenticTemplates(tasks, defaults = {}) {
|
|
@@ -383,11 +383,12 @@ async function verifyPrePush(options = {}) {
|
|
|
383
383
|
function verifyStagedTypecheck(stagedFiles, options = {}) {
|
|
384
384
|
const cwd = options.cwd ?? process.cwd();
|
|
385
385
|
const spawn = options.spawn ?? spawnSync;
|
|
386
|
-
|
|
386
|
+
let workspaceDirs = [...new Set(stagedFiles.filter((file) => {
|
|
387
387
|
const basename = path$1.basename(file);
|
|
388
388
|
return typecheckExtensions.has(path$1.extname(file)) || typecheckBasenames.has(basename);
|
|
389
389
|
}).map((file) => resolveTypecheckWorkspaceDir(file, cwd)))];
|
|
390
390
|
if (workspaceDirs.length === 0) return;
|
|
391
|
+
if (workspaceDirs.includes(cwd)) workspaceDirs = [cwd];
|
|
391
392
|
for (const workspaceDir of workspaceDirs) runPnpmCommand(cwd, `[lint-staged:typecheck] ${path$1.relative(cwd, workspaceDir) || "."}`, [
|
|
392
393
|
"--dir",
|
|
393
394
|
workspaceDir,
|
|
@@ -445,7 +446,7 @@ function resolveRecommendedCheckPlan(options) {
|
|
|
445
446
|
commands: [{
|
|
446
447
|
name: "commit-msg",
|
|
447
448
|
command: `repo verify commit-msg ${editFile}`,
|
|
448
|
-
description: "校验 commit message 文件是否符合提交规范。"
|
|
449
|
+
description: localize("Validate a commit message file.", "校验 commit message 文件是否符合提交规范。")
|
|
449
450
|
}]
|
|
450
451
|
};
|
|
451
452
|
if (full) return {
|
|
@@ -454,7 +455,7 @@ function resolveRecommendedCheckPlan(options) {
|
|
|
454
455
|
commands: [{
|
|
455
456
|
name: "pre-push",
|
|
456
457
|
command: "repo verify pre-push",
|
|
457
|
-
description: "执行完整 pre-push 校验,包含整仓 lint/typecheck,并按变更范围运行 build/test/tsd。"
|
|
458
|
+
description: localize("Run full pre-push verification with lint, typecheck, build, test, and tsd.", "执行完整 pre-push 校验,包含整仓 lint/typecheck,并按变更范围运行 build/test/tsd。")
|
|
458
459
|
}]
|
|
459
460
|
};
|
|
460
461
|
if (staged) return {
|
|
@@ -463,11 +464,11 @@ function resolveRecommendedCheckPlan(options) {
|
|
|
463
464
|
commands: [{
|
|
464
465
|
name: "pre-commit",
|
|
465
466
|
command: "repo verify pre-commit",
|
|
466
|
-
description: "执行 pre-commit 校验。"
|
|
467
|
+
description: localize("Run pre-commit verification.", "执行 pre-commit 校验。")
|
|
467
468
|
}, {
|
|
468
469
|
name: "staged-typecheck",
|
|
469
470
|
command: "repo verify staged-typecheck <staged files>",
|
|
470
|
-
description: "按暂存 TypeScript/Vue 文件所在 workspace 路由 typecheck。"
|
|
471
|
+
description: localize("Route typecheck to workspaces containing staged TypeScript or Vue files.", "按暂存 TypeScript/Vue 文件所在 workspace 路由 typecheck。")
|
|
471
472
|
}]
|
|
472
473
|
};
|
|
473
474
|
return {
|
|
@@ -476,7 +477,7 @@ function resolveRecommendedCheckPlan(options) {
|
|
|
476
477
|
commands: [{
|
|
477
478
|
name: "pre-commit",
|
|
478
479
|
command: "repo verify pre-commit",
|
|
479
|
-
description: "执行默认轻量本地校验。"
|
|
480
|
+
description: localize("Run the default lightweight local verification.", "执行默认轻量本地校验。")
|
|
480
481
|
}]
|
|
481
482
|
};
|
|
482
483
|
}
|
|
@@ -509,7 +510,7 @@ async function resolveFullWorkspaceCheckPlan(cwd) {
|
|
|
509
510
|
].filter((name) => hasRootScript({ scripts }, name)).map((name) => ({
|
|
510
511
|
name,
|
|
511
512
|
command: `pnpm ${name}`,
|
|
512
|
-
description: `运行根 package.json 的 ${name}
|
|
513
|
+
description: localize(`Run the ${name} script from the root package.json.`, `运行根 package.json 的 ${name} 脚本。`),
|
|
513
514
|
available: true
|
|
514
515
|
}))
|
|
515
516
|
};
|
|
@@ -715,11 +716,11 @@ async function syncSkills(options = {}) {
|
|
|
715
716
|
const cwd = options.cwd ?? process.cwd();
|
|
716
717
|
if (!await fs$1.pathExists(skillSourceDir)) {
|
|
717
718
|
const relative = path.relative(cwd, skillSourceDir);
|
|
718
|
-
throw new Error(`未找到技能目录:${relative || skillSourceDir}`);
|
|
719
|
+
throw new Error(localize(`Skill directory not found: ${relative || skillSourceDir}`, `未找到技能目录:${relative || skillSourceDir}`));
|
|
719
720
|
}
|
|
720
721
|
let targets = normalizeTargets(options.targets);
|
|
721
722
|
if (!targets?.length) targets = normalizeTargets(await checkbox({
|
|
722
|
-
message: "请选择需要同步的技能目标",
|
|
723
|
+
message: localize("Select skill synchronization targets", "请选择需要同步的技能目标"),
|
|
723
724
|
choices: skillTargets.map((target) => ({
|
|
724
725
|
name: target,
|
|
725
726
|
value: target,
|
|
@@ -767,7 +768,7 @@ async function cleanProjects(cwd, overrides) {
|
|
|
767
768
|
let cleanDirs = [];
|
|
768
769
|
if (cleanConfig?.autoConfirm) cleanDirs = filteredPackages.map((pkg) => pkg.rootDir);
|
|
769
770
|
else cleanDirs = await checkbox({
|
|
770
|
-
message: "请选择需要清理的目录",
|
|
771
|
+
message: localize("Select directories to remove", "请选择需要清理的目录"),
|
|
771
772
|
choices: filteredPackages.map((x) => {
|
|
772
773
|
const baseChoice = {
|
|
773
774
|
name: path.relative(workspaceDir, x.rootDir),
|
|
@@ -1061,7 +1062,7 @@ async function resolveCreateNewProjectPlan(options) {
|
|
|
1061
1062
|
if (!templateDefinitions[requestedTemplateName]) throw new Error(formatUnknownTemplateError(requestedTemplateName, availableTemplates));
|
|
1062
1063
|
const template = requestedTemplateName;
|
|
1063
1064
|
const templateDefinition = templateDefinitions[template];
|
|
1064
|
-
if (!templateDefinition) throw new Error(`未找到名为 ${template} 的模板,请检查 repoctl.config.ts`);
|
|
1065
|
+
if (!templateDefinition) throw new Error(localize(`Template ${template} was not found; check repoctl.config.ts.`, `未找到名为 ${template} 的模板,请检查 repoctl.config.ts`));
|
|
1065
1066
|
const sourceDir = path.join(templatesRoot, templateDefinition.source);
|
|
1066
1067
|
const targetName = name && name.length > 0 ? name : templateDefinition.target;
|
|
1067
1068
|
const targetDir = path.join(cwd, targetName);
|
|
@@ -1186,7 +1187,7 @@ async function updateWorkspaceManifest(workspaceDir, targetName) {
|
|
|
1186
1187
|
*/
|
|
1187
1188
|
async function createNewProject(options) {
|
|
1188
1189
|
const plan = await resolveCreateNewProjectPlan(options);
|
|
1189
|
-
if (plan.targetExists) throw new Error(`${pc.red("目标目录已存在")}: ${path.relative(plan.cwd, plan.targetDir)}`);
|
|
1190
|
+
if (plan.targetExists) throw new Error(`${pc.red(localize("Target directory already exists", "目标目录已存在"))}: ${path.relative(plan.cwd, plan.targetDir)}`);
|
|
1190
1191
|
await fs$1.ensureDir(plan.targetDir);
|
|
1191
1192
|
await scaffoldTemplate({
|
|
1192
1193
|
sourceDir: plan.sourceDir,
|
|
@@ -1203,7 +1204,89 @@ async function createNewProject(options) {
|
|
|
1203
1204
|
await fs$1.outputJson(path.resolve(plan.targetDir, plan.packageJsonFileName), sourceJson, { spaces: 2 });
|
|
1204
1205
|
}
|
|
1205
1206
|
await updateWorkspaceManifest(plan.cwd, plan.targetName);
|
|
1206
|
-
logger.success(`${pc.bgGreenBright(pc.white(`[${plan.template}]`))} ${plan.targetName} 项目创建成功!`);
|
|
1207
|
+
logger.success(localize(`${pc.bgGreenBright(pc.white(`[${plan.template}]`))} Created ${plan.targetName}.`, `${pc.bgGreenBright(pc.white(`[${plan.template}]`))} ${plan.targetName} 项目创建成功!`));
|
|
1208
|
+
}
|
|
1209
|
+
//#endregion
|
|
1210
|
+
//#region src/commands/doctor/helpers.ts
|
|
1211
|
+
function createCheck(check) {
|
|
1212
|
+
return check;
|
|
1213
|
+
}
|
|
1214
|
+
function summarizeChecks(checks) {
|
|
1215
|
+
return checks.reduce((summary, check) => {
|
|
1216
|
+
summary[check.status] += 1;
|
|
1217
|
+
return summary;
|
|
1218
|
+
}, {
|
|
1219
|
+
pass: 0,
|
|
1220
|
+
warn: 0,
|
|
1221
|
+
fail: 0
|
|
1222
|
+
});
|
|
1223
|
+
}
|
|
1224
|
+
function getWorkspacePatterns(manifest) {
|
|
1225
|
+
if (typeof manifest !== "object" || manifest === null) return [];
|
|
1226
|
+
const packages = manifest.packages;
|
|
1227
|
+
return Array.isArray(packages) ? packages.filter((item) => typeof item === "string") : [];
|
|
1228
|
+
}
|
|
1229
|
+
function isWorkspacePatternCovered(relativeDir, patterns) {
|
|
1230
|
+
const normalized = relativeDir.split("\\").join("/");
|
|
1231
|
+
return patterns.some((pattern) => {
|
|
1232
|
+
if (pattern.startsWith("!")) return false;
|
|
1233
|
+
if (pattern.endsWith("/*")) {
|
|
1234
|
+
const base = pattern.slice(0, -2);
|
|
1235
|
+
return normalized.startsWith(`${base}/`) && normalized.slice(base.length + 1).split("/").length === 1;
|
|
1236
|
+
}
|
|
1237
|
+
if (pattern.endsWith("/**")) return normalized.startsWith(`${pattern.slice(0, -3)}/`);
|
|
1238
|
+
return normalized === pattern;
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
//#endregion
|
|
1242
|
+
//#region src/commands/doctor/context.ts
|
|
1243
|
+
async function isRepoctlSourceWorkspace(workspaceDir) {
|
|
1244
|
+
const [hasMonorepoSource, hasRepoctlSource] = await Promise.all([fs$1.pathExists(`${workspaceDir}/packages/monorepo/src/tooling/index.ts`), fs$1.pathExists(`${workspaceDir}/packages/repoctl/src/tooling-entry.ts`)]);
|
|
1245
|
+
return hasMonorepoSource && hasRepoctlSource;
|
|
1246
|
+
}
|
|
1247
|
+
async function findWorkspacePackageDirs(workspaceDir) {
|
|
1248
|
+
const result = [];
|
|
1249
|
+
for (const baseDir of [
|
|
1250
|
+
"apps",
|
|
1251
|
+
"packages",
|
|
1252
|
+
"examples"
|
|
1253
|
+
]) {
|
|
1254
|
+
const absBaseDir = `${workspaceDir}/${baseDir}`;
|
|
1255
|
+
if (!await fs$1.pathExists(absBaseDir)) continue;
|
|
1256
|
+
const entries = await readdir(absBaseDir);
|
|
1257
|
+
await Promise.all(entries.map(async (entry) => {
|
|
1258
|
+
if (await fs$1.pathExists(`${absBaseDir}/${entry}/package.json`)) result.push(`${baseDir}/${entry}`);
|
|
1259
|
+
}));
|
|
1260
|
+
}
|
|
1261
|
+
return result.sort((left, right) => left.localeCompare(right));
|
|
1262
|
+
}
|
|
1263
|
+
async function collectDoctorContext(cwd) {
|
|
1264
|
+
const workspaceDir = await findWorkspaceDir(cwd) ?? cwd;
|
|
1265
|
+
const packageJsonPath = `${workspaceDir}/package.json`;
|
|
1266
|
+
const workspaceManifestPath = `${workspaceDir}/pnpm-workspace.yaml`;
|
|
1267
|
+
const [hasPackageJson, hasWorkspaceManifest, hasRepoctlConfig, hasLegacyMonorepoConfig, hasHuskyPreCommit, hasLintStagedConfig] = await Promise.all([
|
|
1268
|
+
fs$1.pathExists(packageJsonPath),
|
|
1269
|
+
fs$1.pathExists(workspaceManifestPath),
|
|
1270
|
+
fs$1.pathExists(`${workspaceDir}/repoctl.config.ts`),
|
|
1271
|
+
fs$1.pathExists(`${workspaceDir}/monorepo.config.ts`),
|
|
1272
|
+
fs$1.pathExists(`${workspaceDir}/.husky/pre-commit`),
|
|
1273
|
+
fs$1.pathExists(`${workspaceDir}/lint-staged.config.js`)
|
|
1274
|
+
]);
|
|
1275
|
+
return {
|
|
1276
|
+
cwd,
|
|
1277
|
+
workspaceDir,
|
|
1278
|
+
packageJson: hasPackageJson ? await fs$1.readJson(packageJsonPath) : {},
|
|
1279
|
+
packageCount: hasWorkspaceManifest ? (await getWorkspacePackages(workspaceDir, { ignorePrivatePackage: false })).length : 0,
|
|
1280
|
+
workspacePatterns: hasWorkspaceManifest ? getWorkspacePatterns(YAML.parse(await fs$1.readFile(workspaceManifestPath, "utf8"))) : [],
|
|
1281
|
+
workspacePackageDirs: hasWorkspaceManifest ? await findWorkspacePackageDirs(workspaceDir) : [],
|
|
1282
|
+
hasPackageJson,
|
|
1283
|
+
hasWorkspaceManifest,
|
|
1284
|
+
hasRepoctlConfig,
|
|
1285
|
+
hasLegacyMonorepoConfig,
|
|
1286
|
+
hasHuskyPreCommit,
|
|
1287
|
+
hasLintStagedConfig,
|
|
1288
|
+
isSourceWorkspace: await isRepoctlSourceWorkspace(workspaceDir)
|
|
1289
|
+
};
|
|
1207
1290
|
}
|
|
1208
1291
|
//#endregion
|
|
1209
1292
|
//#region src/commands/upgrade/release-migration.ts
|
|
@@ -1262,6 +1345,15 @@ function check(id, title, status, detail, fix) {
|
|
|
1262
1345
|
...fix ? { fix } : {}
|
|
1263
1346
|
};
|
|
1264
1347
|
}
|
|
1348
|
+
function minimumDependencyVersion(range) {
|
|
1349
|
+
const normalized = range?.startsWith("workspace:") ? range.slice(10) : range;
|
|
1350
|
+
if (!normalized || normalized === "*" || normalized === "^" || normalized === "~") return null;
|
|
1351
|
+
try {
|
|
1352
|
+
return minVersion(normalized);
|
|
1353
|
+
} catch {
|
|
1354
|
+
return null;
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1265
1357
|
async function collectReleaseChecks(workspaceDir, pkgJson) {
|
|
1266
1358
|
const workflowPath = path.join(workspaceDir, ".github/workflows/release.yml");
|
|
1267
1359
|
const [hasWorkflow, hasPreState, hasChangesetConfig] = await Promise.all([
|
|
@@ -1272,318 +1364,239 @@ async function collectReleaseChecks(workspaceDir, pkgJson) {
|
|
|
1272
1364
|
if (!hasWorkflow && !hasPreState && !hasChangesetConfig) return [];
|
|
1273
1365
|
const checks = [];
|
|
1274
1366
|
const workflowStatus = await classifyReleaseWorkflow(workspaceDir);
|
|
1275
|
-
if (workflowStatus === "managed") checks.push(check("release-workflow", "release workflow", "pass", `release workflow 已由 ${releaseWorkflowMarker} 管理。`));
|
|
1276
|
-
else if (workflowStatus === "legacy") checks.push(check("release-workflow", "release workflow", "warn", "检测到旧的 Changesets release workflow。", "首次迁移运行 pnpm dlx repoctl@latest upgrade --yes。"));
|
|
1277
|
-
else if (workflowStatus === "custom") checks.push(check("release-workflow", "release workflow", "warn", "release workflow 未包含 repoctl managed marker,可能存在自定义发布逻辑。", "确认内容后运行 repo upgrade --overwrite-release,或手动加入 repoctl-managed: release/v2。"));
|
|
1278
|
-
if (hasPreState) checks.push(check("release-prerelease-state", "prerelease state", "warn", "检测到旧的 .changeset/pre.json。", "运行 pnpm dlx repoctl@latest upgrade --yes 将其迁移为 pnpm versioning.lanes。"));
|
|
1279
|
-
if (hasChangesetConfig) checks.push(check("release-changeset-config", "changeset config", "warn", "检测到只属于 Changesets CLI 的 .changeset/config.json。", "运行 pnpm dlx repoctl@latest upgrade --yes 清理旧配置。"));
|
|
1367
|
+
if (workflowStatus === "managed") checks.push(check("release-workflow", "release workflow", "pass", localize(`The release workflow is managed by ${releaseWorkflowMarker}.`, `release workflow 已由 ${releaseWorkflowMarker} 管理。`)));
|
|
1368
|
+
else if (workflowStatus === "legacy") checks.push(check("release-workflow", "release workflow", "warn", localize("Found a legacy Changesets release workflow.", "检测到旧的 Changesets release workflow。"), localize("Run pnpm dlx repoctl@latest upgrade --yes for the initial migration.", "首次迁移运行 pnpm dlx repoctl@latest upgrade --yes。")));
|
|
1369
|
+
else if (workflowStatus === "custom") checks.push(check("release-workflow", "release workflow", "warn", localize("The release workflow has no repoctl managed marker and may contain custom logic.", "release workflow 未包含 repoctl managed marker,可能存在自定义发布逻辑。"), localize("Review it, then run repo upgrade --overwrite-release or add the managed marker manually.", "确认内容后运行 repo upgrade --overwrite-release,或手动加入 repoctl-managed: release/v2。")));
|
|
1370
|
+
if (hasPreState) checks.push(check("release-prerelease-state", "prerelease state", "warn", localize("Found legacy .changeset/pre.json prerelease state.", "检测到旧的 .changeset/pre.json。"), localize("Run pnpm dlx repoctl@latest upgrade --yes to migrate to pnpm versioning lanes.", "运行 pnpm dlx repoctl@latest upgrade --yes 将其迁移为 pnpm versioning.lanes。")));
|
|
1371
|
+
if (hasChangesetConfig) checks.push(check("release-changeset-config", "changeset config", "warn", localize("Found .changeset/config.json from the Changesets CLI.", "检测到只属于 Changesets CLI 的 .changeset/config.json。"), localize("Run pnpm dlx repoctl@latest upgrade --yes to remove legacy configuration.", "运行 pnpm dlx repoctl@latest upgrade --yes 清理旧配置。")));
|
|
1280
1372
|
if (hasWorkflow) {
|
|
1281
1373
|
const packageVersion = pkgJson.devDependencies?.["repoctl"] ?? pkgJson.dependencies?.["repoctl"];
|
|
1282
|
-
const parsed =
|
|
1283
|
-
if (!parsed || !gte(parsed, "5.1.0")) checks.push(check("release-cli-version", "release CLI version", "warn", `repoctl 版本 ${packageVersion ?? "missing"} 不保证支持 release ci
|
|
1284
|
-
else checks.push(check("release-cli-version", "release CLI version", "pass", `repoctl 版本 ${packageVersion} 支持 release ci。`));
|
|
1374
|
+
const parsed = minimumDependencyVersion(packageVersion);
|
|
1375
|
+
if (!parsed || !gte(parsed, "5.1.0")) checks.push(check("release-cli-version", "release CLI version", "warn", localize(`repoctl ${packageVersion ?? "missing"} does not guarantee release ci support.`, `repoctl 版本 ${packageVersion ?? "missing"} 不保证支持 release ci。`), localize(`Upgrade repoctl to >=${releaseCiMinimumVersion}.`, `运行 pnpm dlx repoctl@latest upgrade --yes,或将 repoctl 升级到 >=${releaseCiMinimumVersion}。`)));
|
|
1376
|
+
else checks.push(check("release-cli-version", "release CLI version", "pass", localize(`repoctl ${packageVersion} supports release ci.`, `repoctl 版本 ${packageVersion} 支持 release ci。`)));
|
|
1285
1377
|
try {
|
|
1286
1378
|
const workspace = YAML.parse(await readFile(path.join(workspaceDir, "pnpm-workspace.yaml"), "utf8"));
|
|
1287
1379
|
const hasFixed = Array.isArray(workspace.versioning?.fixed) && workspace.versioning.fixed.length > 0;
|
|
1288
1380
|
const hasRepositoryChangelog = workspace.versioning?.changelog?.storage === "repository";
|
|
1289
|
-
checks.push(hasFixed && hasRepositoryChangelog ? check("release-versioning-config", "release versioning config", "pass", "pnpm fixed group 与 repository changelog 配置完整。") : check("release-versioning-config", "release versioning config", "warn", "pnpm-workspace.yaml 缺少 release 所需的 fixed 或 repository changelog 配置。", "运行 repo upgrade --yes 同步 pnpm versioning 配置。"));
|
|
1381
|
+
checks.push(hasFixed && hasRepositoryChangelog ? check("release-versioning-config", "release versioning config", "pass", localize("pnpm fixed groups and repository changelog storage are configured.", "pnpm fixed group 与 repository changelog 配置完整。")) : check("release-versioning-config", "release versioning config", "warn", localize("pnpm-workspace.yaml is missing required fixed groups or repository changelog storage.", "pnpm-workspace.yaml 缺少 release 所需的 fixed 或 repository changelog 配置。"), localize("Run repo upgrade --yes to synchronize pnpm versioning configuration.", "运行 repo upgrade --yes 同步 pnpm versioning 配置。")));
|
|
1290
1382
|
} catch {
|
|
1291
|
-
checks.push(check("release-versioning-config", "release versioning config", "warn", "无法读取 pnpm-workspace.yaml 的 versioning 配置。", "运行 repo upgrade --yes 同步 pnpm versioning 配置。"));
|
|
1383
|
+
checks.push(check("release-versioning-config", "release versioning config", "warn", localize("Unable to read versioning configuration from pnpm-workspace.yaml.", "无法读取 pnpm-workspace.yaml 的 versioning 配置。"), localize("Run repo upgrade --yes to synchronize pnpm versioning configuration.", "运行 repo upgrade --yes 同步 pnpm versioning 配置。")));
|
|
1292
1384
|
}
|
|
1293
1385
|
}
|
|
1294
1386
|
return checks;
|
|
1295
1387
|
}
|
|
1296
1388
|
//#endregion
|
|
1297
|
-
//#region src/commands/doctor.ts
|
|
1389
|
+
//#region src/commands/doctor/tooling.ts
|
|
1298
1390
|
const recommendedRepoScripts = {
|
|
1299
1391
|
"repo:init": "repo init",
|
|
1300
1392
|
"repo:new": "repo new",
|
|
1301
1393
|
"repo:check": "repo check",
|
|
1302
1394
|
"repo:doctor": "repo doctor"
|
|
1303
1395
|
};
|
|
1304
|
-
function
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
function summarizeChecks(checks) {
|
|
1308
|
-
return checks.reduce((summary, check) => {
|
|
1309
|
-
summary[check.status] += 1;
|
|
1310
|
-
return summary;
|
|
1311
|
-
}, {
|
|
1312
|
-
pass: 0,
|
|
1313
|
-
warn: 0,
|
|
1314
|
-
fail: 0
|
|
1315
|
-
});
|
|
1316
|
-
}
|
|
1317
|
-
function resolveToolPackageName(pkgJson) {
|
|
1318
|
-
return [typeof pkgJson.devDependencies?.["repoctl"] === "string" ? {
|
|
1319
|
-
name: "repoctl",
|
|
1320
|
-
version: pkgJson.devDependencies["repoctl"]
|
|
1321
|
-
} : null, typeof pkgJson.dependencies?.["repoctl"] === "string" ? {
|
|
1396
|
+
function resolveToolPackage(pkgJson) {
|
|
1397
|
+
const version = pkgJson.devDependencies?.["repoctl"] ?? pkgJson.dependencies?.["repoctl"];
|
|
1398
|
+
return typeof version === "string" ? {
|
|
1322
1399
|
name: "repoctl",
|
|
1323
|
-
version
|
|
1324
|
-
} : null
|
|
1400
|
+
version
|
|
1401
|
+
} : null;
|
|
1325
1402
|
}
|
|
1326
1403
|
function hasScript(pkgJson, name) {
|
|
1327
1404
|
return typeof pkgJson.scripts?.[name] === "string" && pkgJson.scripts[name].length > 0;
|
|
1328
1405
|
}
|
|
1329
|
-
function
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
if (typeof manifest !== "object" || manifest === null) return [];
|
|
1337
|
-
const packages = manifest.packages;
|
|
1338
|
-
return Array.isArray(packages) ? packages.filter((item) => typeof item === "string") : [];
|
|
1339
|
-
}
|
|
1340
|
-
function isWorkspacePatternCovered(relativeDir, patterns) {
|
|
1341
|
-
const normalized = relativeDir.split("\\").join("/");
|
|
1342
|
-
return patterns.some((pattern) => {
|
|
1343
|
-
if (pattern.startsWith("!")) return false;
|
|
1344
|
-
if (pattern.endsWith("/*")) {
|
|
1345
|
-
const base = pattern.slice(0, -2);
|
|
1346
|
-
return normalized.startsWith(`${base}/`) && normalized.slice(base.length + 1).split("/").length === 1;
|
|
1347
|
-
}
|
|
1348
|
-
if (pattern.endsWith("/**")) return normalized.startsWith(`${pattern.slice(0, -3)}/`);
|
|
1349
|
-
return normalized === pattern;
|
|
1350
|
-
});
|
|
1351
|
-
}
|
|
1352
|
-
async function isRepoctlSourceWorkspace(workspaceDir) {
|
|
1353
|
-
const [hasMonorepoSource, hasRepoctlSource] = await Promise.all([fs$1.pathExists(`${workspaceDir}/packages/monorepo/src/tooling/index.ts`), fs$1.pathExists(`${workspaceDir}/packages/repoctl/src/tooling-entry.ts`)]);
|
|
1354
|
-
return hasMonorepoSource && hasRepoctlSource;
|
|
1355
|
-
}
|
|
1356
|
-
async function findWorkspacePackageDirs(workspaceDir) {
|
|
1357
|
-
const result = [];
|
|
1406
|
+
async function findLegacyToolingFiles(context) {
|
|
1407
|
+
const files = [...context.isSourceWorkspace ? [] : [
|
|
1408
|
+
"eslint.config.js",
|
|
1409
|
+
"stylelint.config.js",
|
|
1410
|
+
"lint-staged.config.js",
|
|
1411
|
+
"vitest.config.ts"
|
|
1412
|
+
]];
|
|
1358
1413
|
for (const baseDir of [
|
|
1359
1414
|
"apps",
|
|
1360
1415
|
"packages",
|
|
1361
1416
|
"examples"
|
|
1362
1417
|
]) {
|
|
1363
|
-
const
|
|
1364
|
-
if (!await fs$1.pathExists(
|
|
1365
|
-
const
|
|
1366
|
-
await Promise.all(entries.map(async (entry) => {
|
|
1367
|
-
const packageJsonPath = `${absBaseDir}/${entry}/package.json`;
|
|
1368
|
-
if (await fs$1.pathExists(packageJsonPath)) result.push(`${baseDir}/${entry}`);
|
|
1369
|
-
}));
|
|
1418
|
+
const absoluteBase = `${context.workspaceDir}/${baseDir}`;
|
|
1419
|
+
if (!await fs$1.pathExists(absoluteBase)) continue;
|
|
1420
|
+
for (const entry of await readdir(absoluteBase)) files.push(`${baseDir}/${entry}/eslint.config.js`, `${baseDir}/${entry}/vitest.config.ts`);
|
|
1370
1421
|
}
|
|
1371
|
-
|
|
1422
|
+
const legacyFiles = [];
|
|
1423
|
+
await Promise.all(files.map(async (file) => {
|
|
1424
|
+
const candidate = `${context.workspaceDir}/${file}`;
|
|
1425
|
+
if (await fs$1.pathExists(candidate) && hasLegacyToolingReference(await fs$1.readFile(candidate, "utf8"))) legacyFiles.push(file);
|
|
1426
|
+
}));
|
|
1427
|
+
return legacyFiles.sort((left, right) => left.localeCompare(right));
|
|
1372
1428
|
}
|
|
1373
|
-
async function
|
|
1374
|
-
const
|
|
1375
|
-
const
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
const
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1429
|
+
async function collectToolingChecks(context) {
|
|
1430
|
+
const checks = [];
|
|
1431
|
+
const toolPackage = resolveToolPackage(context.packageJson);
|
|
1432
|
+
checks.push(toolPackage ? createCheck({
|
|
1433
|
+
id: "tool-package",
|
|
1434
|
+
title: localize("repo CLI dependency", "repo CLI 依赖"),
|
|
1435
|
+
status: "pass",
|
|
1436
|
+
detail: localize(`Detected CLI dependency: ${toolPackage.name}@${toolPackage.version}`, `已检测到 CLI 依赖:${toolPackage.name}@${toolPackage.version}`)
|
|
1437
|
+
}) : createCheck({
|
|
1438
|
+
id: "tool-package",
|
|
1439
|
+
title: localize("repo CLI dependency", "repo CLI 依赖"),
|
|
1440
|
+
status: "fail",
|
|
1441
|
+
detail: localize("The root package.json does not contain a repoctl dependency.", "根 package.json 中没有 repoctl 依赖。"),
|
|
1442
|
+
fix: localize("Run repo init --yes or pnpm add -D repoctl.", "运行 repo init --yes,或执行 pnpm add -D repoctl。")
|
|
1443
|
+
}));
|
|
1444
|
+
const missing = Object.keys(recommendedRepoScripts).filter((name) => !hasScript(context.packageJson, name));
|
|
1445
|
+
const unexpected = Object.entries(recommendedRepoScripts).filter(([name, command]) => hasScript(context.packageJson, name) && context.packageJson.scripts?.[name] !== command).map(([name]) => name);
|
|
1446
|
+
checks.push(missing.length === 0 && unexpected.length === 0 ? createCheck({
|
|
1447
|
+
id: "root-scripts",
|
|
1448
|
+
title: localize("repo:* root scripts", "repo:* 根脚本"),
|
|
1449
|
+
status: "pass",
|
|
1450
|
+
detail: localize("Found repo:init, repo:new, repo:check, and repo:doctor root scripts.", "已检测到 repo:init、repo:new、repo:check 和 repo:doctor 根脚本。")
|
|
1451
|
+
}) : createCheck({
|
|
1452
|
+
id: "root-scripts",
|
|
1453
|
+
title: localize("repo:* root scripts", "repo:* 根脚本"),
|
|
1454
|
+
status: "warn",
|
|
1455
|
+
detail: localize(`Recommended root scripts need attention. Missing: ${missing.join(", ") || "none"}; unexpected: ${unexpected.join(", ") || "none"}.`, `推荐根脚本需要调整。缺少:${missing.join(", ") || "无"};命令不一致:${unexpected.join(", ") || "无"}。`),
|
|
1456
|
+
fix: localize("Run repo init --yes or update the scripts in package.json.", "运行 repo init --yes,或更新 package.json 中的脚本。")
|
|
1457
|
+
}));
|
|
1458
|
+
const legacyFiles = await findLegacyToolingFiles(context);
|
|
1459
|
+
checks.push(legacyFiles.length === 0 ? createCheck({
|
|
1460
|
+
id: "tooling-imports",
|
|
1461
|
+
title: localize("Tooling imports", "Tooling 导入"),
|
|
1462
|
+
status: "pass",
|
|
1463
|
+
detail: localize("Tooling configuration uses current repoctl entrypoints.", "Tooling 配置使用当前 repoctl 入口。")
|
|
1464
|
+
}) : createCheck({
|
|
1465
|
+
id: "tooling-imports",
|
|
1466
|
+
title: localize("Tooling imports", "Tooling 导入"),
|
|
1467
|
+
status: "warn",
|
|
1468
|
+
detail: localize(`These files reference legacy tooling entries: ${legacyFiles.join(", ")}.`, `以下文件引用旧 tooling 入口:${legacyFiles.join(", ")}。`),
|
|
1469
|
+
fix: localize("Run repo upgrade --yes to migrate to repoctl/tooling.", "运行 repo upgrade --yes 迁移到 repoctl/tooling。")
|
|
1470
|
+
}));
|
|
1471
|
+
return checks;
|
|
1472
|
+
}
|
|
1473
|
+
//#endregion
|
|
1474
|
+
//#region src/commands/doctor/workspace.ts
|
|
1475
|
+
function collectWorkspaceChecks(context) {
|
|
1476
|
+
const { hasPackageJson, hasWorkspaceManifest, hasRepoctlConfig, hasLegacyMonorepoConfig, hasHuskyPreCommit, hasLintStagedConfig, packageCount, packageJson, workspaceDir, workspacePackageDirs, workspacePatterns } = context;
|
|
1394
1477
|
const checks = [hasPackageJson ? createCheck({
|
|
1395
1478
|
id: "package-json",
|
|
1396
1479
|
title: "package.json",
|
|
1397
1480
|
status: "pass",
|
|
1398
|
-
detail: `已找到根 package.json:${
|
|
1481
|
+
detail: localize(`Found root package.json: ${workspaceDir}/package.json`, `已找到根 package.json:${workspaceDir}/package.json`)
|
|
1399
1482
|
}) : createCheck({
|
|
1400
1483
|
id: "package-json",
|
|
1401
1484
|
title: "package.json",
|
|
1402
1485
|
status: "fail",
|
|
1403
|
-
detail: "当前目录缺少根 package.json。",
|
|
1404
|
-
fix: "请在 monorepo
|
|
1486
|
+
detail: localize("The current directory does not contain a root package.json.", "当前目录缺少根 package.json。"),
|
|
1487
|
+
fix: localize("Run the command from the monorepo root or initialize the workspace first.", "请在 monorepo 根目录执行命令,或先完成工作区初始化。")
|
|
1405
1488
|
}), hasWorkspaceManifest ? createCheck({
|
|
1406
1489
|
id: "workspace-manifest",
|
|
1407
1490
|
title: "pnpm workspace",
|
|
1408
1491
|
status: "pass",
|
|
1409
|
-
detail: `已找到 pnpm workspace,当前识别到 ${packageCount} 个 workspace 包。`
|
|
1492
|
+
detail: localize(`Found a pnpm workspace with ${packageCount} package(s).`, `已找到 pnpm workspace,当前识别到 ${packageCount} 个 workspace 包。`)
|
|
1410
1493
|
}) : createCheck({
|
|
1411
1494
|
id: "workspace-manifest",
|
|
1412
1495
|
title: "pnpm workspace",
|
|
1413
1496
|
status: "fail",
|
|
1414
|
-
detail: "缺少 pnpm-workspace.yaml
|
|
1415
|
-
fix: "
|
|
1497
|
+
detail: localize("pnpm-workspace.yaml is missing; this directory is not a complete pnpm monorepo root.", "缺少 pnpm-workspace.yaml,当前目录不是完整的 pnpm monorepo 根目录。"),
|
|
1498
|
+
fix: localize("Run repo init --yes or switch to the workspace root.", "运行 repo init --yes,或切换到 workspace 根目录。")
|
|
1416
1499
|
})];
|
|
1417
|
-
const nodeRange =
|
|
1418
|
-
if (
|
|
1500
|
+
const nodeRange = packageJson.engines?.node;
|
|
1501
|
+
if (nodeRange) checks.push(satisfies(process.version, nodeRange) ? createCheck({
|
|
1419
1502
|
id: "node-version",
|
|
1420
|
-
title: "Node 版本",
|
|
1503
|
+
title: localize("Node version", "Node 版本"),
|
|
1421
1504
|
status: "pass",
|
|
1422
|
-
detail: `当前 Node 版本 ${process.version} 满足要求 ${nodeRange}。`
|
|
1505
|
+
detail: localize(`Node ${process.version} satisfies ${nodeRange}.`, `当前 Node 版本 ${process.version} 满足要求 ${nodeRange}。`)
|
|
1423
1506
|
}) : createCheck({
|
|
1424
1507
|
id: "node-version",
|
|
1425
|
-
title: "Node 版本",
|
|
1508
|
+
title: localize("Node version", "Node 版本"),
|
|
1426
1509
|
status: "fail",
|
|
1427
|
-
detail: `当前 Node 版本 ${process.version} 不满足要求 ${nodeRange}
|
|
1428
|
-
fix: "
|
|
1510
|
+
detail: localize(`Node ${process.version} does not satisfy ${nodeRange}.`, `当前 Node 版本 ${process.version} 不满足要求 ${nodeRange}。`),
|
|
1511
|
+
fix: localize("Switch to a version allowed by package.json engines.node before continuing.", "继续之前,请切换到 package.json engines.node 允许的版本。")
|
|
1429
1512
|
}));
|
|
1430
1513
|
else checks.push(createCheck({
|
|
1431
1514
|
id: "node-version",
|
|
1432
|
-
title: "Node 版本",
|
|
1515
|
+
title: localize("Node version", "Node 版本"),
|
|
1433
1516
|
status: "warn",
|
|
1434
|
-
detail: "根 package.json 未声明 engines.node
|
|
1435
|
-
fix: "
|
|
1436
|
-
}));
|
|
1437
|
-
const toolPackage = resolveToolPackageName(pkgJson);
|
|
1438
|
-
checks.push(toolPackage ? createCheck({
|
|
1439
|
-
id: "tool-package",
|
|
1440
|
-
title: "repo CLI 依赖",
|
|
1441
|
-
status: "pass",
|
|
1442
|
-
detail: `已检测到 CLI 工具依赖:${toolPackage.name}@${toolPackage.version}`
|
|
1443
|
-
}) : createCheck({
|
|
1444
|
-
id: "tool-package",
|
|
1445
|
-
title: "repo CLI 依赖",
|
|
1446
|
-
status: "fail",
|
|
1447
|
-
detail: "根 package.json 中未发现 repoctl 依赖。",
|
|
1448
|
-
fix: "运行 repo init --yes 添加 repoctl devDependency,或手动执行 pnpm add -D repoctl。"
|
|
1517
|
+
detail: localize("The root package.json does not declare engines.node.", "根 package.json 未声明 engines.node。"),
|
|
1518
|
+
fix: localize("Declare package.json engines.node to keep runtimes consistent.", "请声明 package.json engines.node 以保持运行时一致。")
|
|
1449
1519
|
}));
|
|
1450
|
-
const missingRepoScripts = getMissingScripts(pkgJson, recommendedRepoScripts);
|
|
1451
|
-
const unexpectedRepoScripts = getUnexpectedScripts(pkgJson, recommendedRepoScripts);
|
|
1452
|
-
if (missingRepoScripts.length === 0 && unexpectedRepoScripts.length === 0) checks.push(createCheck({
|
|
1453
|
-
id: "root-scripts",
|
|
1454
|
-
title: "repo:* 根脚本",
|
|
1455
|
-
status: "pass",
|
|
1456
|
-
detail: "已检测到 repo:init / repo:new / repo:check / repo:doctor,推荐使用 pnpm run repo:doctor -- --json 这类无冲突入口。"
|
|
1457
|
-
}));
|
|
1458
|
-
else {
|
|
1459
|
-
const details = [missingRepoScripts.length ? `缺少:${missingRepoScripts.join(", ")}` : null, unexpectedRepoScripts.length ? `命令不一致:${unexpectedRepoScripts.join(", ")}` : null].filter(Boolean).join(";");
|
|
1460
|
-
checks.push(createCheck({
|
|
1461
|
-
id: "root-scripts",
|
|
1462
|
-
title: "repo:* 根脚本",
|
|
1463
|
-
status: "warn",
|
|
1464
|
-
detail: `推荐的 repo:* 根脚本未完全就绪。${details}。`,
|
|
1465
|
-
fix: "运行 repo init --yes 同步推荐根脚本,或手动在 package.json 中补齐 repo:init / repo:new / repo:check / repo:doctor。"
|
|
1466
|
-
}));
|
|
1467
|
-
}
|
|
1468
1520
|
if (hasLegacyMonorepoConfig) checks.push(createCheck({
|
|
1469
1521
|
id: "config-file",
|
|
1470
|
-
title: "配置文件",
|
|
1522
|
+
title: localize("Configuration file", "配置文件"),
|
|
1471
1523
|
status: "fail",
|
|
1472
|
-
detail: "检测到已废弃的 monorepo.config.ts
|
|
1473
|
-
fix: "
|
|
1524
|
+
detail: localize("Found deprecated monorepo.config.ts; repoctl no longer loads it.", "检测到已废弃的 monorepo.config.ts;repoctl 不再加载该文件。"),
|
|
1525
|
+
fix: localize("Rename it to repoctl.config.ts and keep only the repoctl config.", "将其重命名为 repoctl.config.ts,并只保留 repoctl 配置。")
|
|
1474
1526
|
}));
|
|
1475
1527
|
else if (hasRepoctlConfig) checks.push(createCheck({
|
|
1476
1528
|
id: "config-file",
|
|
1477
|
-
title: "配置文件",
|
|
1529
|
+
title: localize("Configuration file", "配置文件"),
|
|
1478
1530
|
status: "pass",
|
|
1479
|
-
detail: "
|
|
1531
|
+
detail: localize("Found repoctl.config.ts.", "已检测到 repoctl.config.ts。")
|
|
1480
1532
|
}));
|
|
1481
1533
|
else checks.push(createCheck({
|
|
1482
1534
|
id: "config-file",
|
|
1483
|
-
title: "配置文件",
|
|
1535
|
+
title: localize("Configuration file", "配置文件"),
|
|
1484
1536
|
status: "warn",
|
|
1485
|
-
detail: "
|
|
1486
|
-
fix: "
|
|
1537
|
+
detail: localize("No custom configuration file was found; the CLI will use defaults.", "未找到自定义配置文件;CLI 将使用默认配置。"),
|
|
1538
|
+
fix: localize("Run repo upgrade --yes or add repoctl.config.ts manually.", "运行 repo upgrade --yes,或手动添加 repoctl.config.ts。")
|
|
1487
1539
|
}));
|
|
1488
1540
|
if (hasHuskyPreCommit && hasLintStagedConfig) checks.push(createCheck({
|
|
1489
1541
|
id: "commit-hooks",
|
|
1490
|
-
title: "
|
|
1542
|
+
title: localize("Commit hooks", "提交钩子"),
|
|
1491
1543
|
status: "pass",
|
|
1492
|
-
detail: "已检测到 .husky/pre-commit
|
|
1493
|
-
}));
|
|
1494
|
-
else if (hasHuskyPreCommit || hasLintStagedConfig) checks.push(createCheck({
|
|
1495
|
-
id: "commit-hooks",
|
|
1496
|
-
title: "提交链路",
|
|
1497
|
-
status: "warn",
|
|
1498
|
-
detail: "提交校验链路只配置了一半,Husky 与 lint-staged 没有同时就绪。",
|
|
1499
|
-
fix: "运行 repo upgrade --yes 同步 .husky/pre-commit 与 lint-staged.config.js。"
|
|
1544
|
+
detail: localize("Found .husky/pre-commit and lint-staged.config.js.", "已检测到 .husky/pre-commit 和 lint-staged.config.js。")
|
|
1500
1545
|
}));
|
|
1501
1546
|
else checks.push(createCheck({
|
|
1502
1547
|
id: "commit-hooks",
|
|
1503
|
-
title: "
|
|
1548
|
+
title: localize("Commit hooks", "提交钩子"),
|
|
1504
1549
|
status: "warn",
|
|
1505
|
-
detail: "
|
|
1506
|
-
fix: "
|
|
1550
|
+
detail: localize("Husky and lint-staged are not both configured.", "Husky 和 lint-staged 尚未同时配置。"),
|
|
1551
|
+
fix: localize("Run repo upgrade --yes to synchronize the default hooks.", "运行 repo upgrade --yes 同步默认钩子。")
|
|
1507
1552
|
}));
|
|
1508
|
-
const
|
|
1509
|
-
"eslint.config.js",
|
|
1510
|
-
"stylelint.config.js",
|
|
1511
|
-
"lint-staged.config.js",
|
|
1512
|
-
"vitest.config.ts"
|
|
1513
|
-
], ...[
|
|
1553
|
+
const missingPatterns = [
|
|
1514
1554
|
"apps",
|
|
1515
1555
|
"packages",
|
|
1516
1556
|
"examples"
|
|
1517
|
-
].
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
}))
|
|
1529
|
-
|
|
1530
|
-
}
|
|
1531
|
-
const
|
|
1532
|
-
|
|
1557
|
+
].filter((base) => workspacePackageDirs.some((dir) => dir.startsWith(`${base}/`))).map((base) => `${base}/*`).filter((pattern) => !workspacePatterns.includes(pattern));
|
|
1558
|
+
if (hasWorkspaceManifest) {
|
|
1559
|
+
checks.push(createCheck(missingPatterns.length === 0 ? {
|
|
1560
|
+
id: "workspace-patterns",
|
|
1561
|
+
title: localize("Workspace patterns", "Workspace 匹配规则"),
|
|
1562
|
+
status: "pass",
|
|
1563
|
+
detail: localize("pnpm-workspace.yaml includes the existing conventional workspace directories.", "pnpm-workspace.yaml 已包含现有的常规 workspace 目录。")
|
|
1564
|
+
} : {
|
|
1565
|
+
id: "workspace-patterns",
|
|
1566
|
+
title: localize("Workspace patterns", "Workspace 匹配规则"),
|
|
1567
|
+
status: "warn",
|
|
1568
|
+
detail: localize(`pnpm-workspace.yaml is missing: ${missingPatterns.join(", ")}.`, `pnpm-workspace.yaml 缺少:${missingPatterns.join(", ")}。`),
|
|
1569
|
+
fix: localize("Run repo init --yes to append missing workspace patterns.", "运行 repo init --yes 追加缺失的 workspace 匹配规则。")
|
|
1570
|
+
}));
|
|
1571
|
+
const uncovered = workspacePackageDirs.filter((dir) => !isWorkspacePatternCovered(dir, workspacePatterns));
|
|
1572
|
+
checks.push(createCheck(uncovered.length === 0 ? {
|
|
1573
|
+
id: "workspace-package-coverage",
|
|
1574
|
+
title: localize("Workspace package coverage", "Workspace 包覆盖"),
|
|
1575
|
+
status: "pass",
|
|
1576
|
+
detail: localize("Every package.json in a conventional workspace directory is covered.", "常规 workspace 目录中的 package.json 均已覆盖。")
|
|
1577
|
+
} : {
|
|
1578
|
+
id: "workspace-package-coverage",
|
|
1579
|
+
title: localize("Workspace package coverage", "Workspace 包覆盖"),
|
|
1580
|
+
status: "warn",
|
|
1581
|
+
detail: localize(`These packages are not covered by pnpm-workspace.yaml: ${uncovered.join(", ")}.`, `以下包未被 pnpm-workspace.yaml 覆盖:${uncovered.join(", ")}。`),
|
|
1582
|
+
fix: localize("Run repo init --yes to append missing workspace patterns.", "运行 repo init --yes 追加缺失的 workspace 匹配规则。")
|
|
1583
|
+
}));
|
|
1533
1584
|
}
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
fix: "运行 repo upgrade --yes 迁移为直接 import repoctl/tooling,并保留现有配置语义。"
|
|
1546
|
-
}));
|
|
1547
|
-
const missingCommonPatterns = (await Promise.all([
|
|
1548
|
-
"apps",
|
|
1549
|
-
"packages",
|
|
1550
|
-
"examples"
|
|
1551
|
-
].map(async (base) => ({
|
|
1552
|
-
base,
|
|
1553
|
-
exists: await fs$1.pathExists(`${workspaceDir}/${base}`)
|
|
1554
|
-
})))).filter((item) => item.exists).map((item) => item.base).map((base) => `${base}/*`).filter((pattern) => !workspacePatterns.includes(pattern));
|
|
1555
|
-
if (hasWorkspaceManifest && missingCommonPatterns.length === 0) checks.push(createCheck({
|
|
1556
|
-
id: "workspace-patterns",
|
|
1557
|
-
title: "workspace patterns",
|
|
1558
|
-
status: "pass",
|
|
1559
|
-
detail: "pnpm-workspace.yaml 已包含 apps/* / packages/* / examples/* 常见目录。"
|
|
1560
|
-
}));
|
|
1561
|
-
else if (hasWorkspaceManifest) checks.push(createCheck({
|
|
1562
|
-
id: "workspace-patterns",
|
|
1563
|
-
title: "workspace patterns",
|
|
1564
|
-
status: "warn",
|
|
1565
|
-
detail: `pnpm-workspace.yaml 缺少常见目录:${missingCommonPatterns.join(", ")}。`,
|
|
1566
|
-
fix: "运行 repo init --yes 追加缺失 workspace patterns。"
|
|
1567
|
-
}));
|
|
1568
|
-
const uncoveredWorkspacePackages = workspacePackageDirs.filter((dir) => !isWorkspacePatternCovered(dir, workspacePatterns));
|
|
1569
|
-
if (hasWorkspaceManifest && uncoveredWorkspacePackages.length === 0) checks.push(createCheck({
|
|
1570
|
-
id: "workspace-package-coverage",
|
|
1571
|
-
title: "workspace package coverage",
|
|
1572
|
-
status: "pass",
|
|
1573
|
-
detail: "常见 workspace 目录下的 package.json 都已被 pnpm-workspace.yaml 覆盖。"
|
|
1574
|
-
}));
|
|
1575
|
-
else if (hasWorkspaceManifest) checks.push(createCheck({
|
|
1576
|
-
id: "workspace-package-coverage",
|
|
1577
|
-
title: "workspace package coverage",
|
|
1578
|
-
status: "warn",
|
|
1579
|
-
detail: `以下 package.json 未被 pnpm-workspace.yaml 覆盖:${uncoveredWorkspacePackages.join(", ")}。`,
|
|
1580
|
-
fix: "运行 repo init --yes 追加缺失 workspace patterns。"
|
|
1581
|
-
}));
|
|
1582
|
-
checks.push(...await collectReleaseChecks(workspaceDir, pkgJson));
|
|
1585
|
+
return checks;
|
|
1586
|
+
}
|
|
1587
|
+
//#endregion
|
|
1588
|
+
//#region src/commands/doctor/index.ts
|
|
1589
|
+
async function runDoctor(cwd) {
|
|
1590
|
+
const context = await collectDoctorContext(cwd);
|
|
1591
|
+
const checks = [
|
|
1592
|
+
...collectWorkspaceChecks(context),
|
|
1593
|
+
...await collectToolingChecks(context),
|
|
1594
|
+
...await collectReleaseChecks(context.workspaceDir, context.packageJson)
|
|
1595
|
+
];
|
|
1583
1596
|
return {
|
|
1584
1597
|
cwd,
|
|
1585
|
-
workspaceDir,
|
|
1586
|
-
packageCount,
|
|
1598
|
+
workspaceDir: context.workspaceDir,
|
|
1599
|
+
packageCount: context.packageCount,
|
|
1587
1600
|
checks,
|
|
1588
1601
|
summary: summarizeChecks(checks)
|
|
1589
1602
|
};
|
|
@@ -1833,17 +1846,26 @@ var devDependencies = {
|
|
|
1833
1846
|
//#region src/commands/init/tooling/presets.ts
|
|
1834
1847
|
const packageDependencies = {
|
|
1835
1848
|
...{
|
|
1836
|
-
name: "
|
|
1849
|
+
name: "repoctl-workspace",
|
|
1837
1850
|
type: "module",
|
|
1838
1851
|
version: "0.0.0",
|
|
1839
1852
|
"private": true,
|
|
1840
|
-
packageManager: "pnpm@11.
|
|
1853
|
+
packageManager: "pnpm@11.22.0",
|
|
1854
|
+
description: "Source workspace for repoctl, a task-first CLI for pnpm and Turborepo monorepos",
|
|
1841
1855
|
author: "ice breaker <hi@sonofmagic.top>",
|
|
1856
|
+
homepage: "https://repo.icebreaker.top",
|
|
1842
1857
|
repository: {
|
|
1843
1858
|
"type": "git",
|
|
1844
|
-
"url": "git+https://github.com/sonofmagic/
|
|
1859
|
+
"url": "git+https://github.com/sonofmagic/repoctl.git"
|
|
1845
1860
|
},
|
|
1846
|
-
bugs: { "url": "https://github.com/sonofmagic/
|
|
1861
|
+
bugs: { "url": "https://github.com/sonofmagic/repoctl/issues" },
|
|
1862
|
+
keywords: [
|
|
1863
|
+
"repoctl",
|
|
1864
|
+
"monorepo",
|
|
1865
|
+
"pnpm",
|
|
1866
|
+
"turborepo",
|
|
1867
|
+
"typescript"
|
|
1868
|
+
],
|
|
1847
1869
|
engines: { "node": ">=22.12.0" },
|
|
1848
1870
|
scripts: {
|
|
1849
1871
|
"build": "turbo run build",
|
|
@@ -1894,7 +1916,7 @@ const packageDependencies = {
|
|
|
1894
1916
|
};
|
|
1895
1917
|
function getDependencyVersion(name) {
|
|
1896
1918
|
const version = packageDependencies[name];
|
|
1897
|
-
if (!version) throw new Error(`未找到依赖 ${name}
|
|
1919
|
+
if (!version) throw new Error(localize(`No version information was found for dependency ${name}.`, `未找到依赖 ${name} 的版本信息。`));
|
|
1898
1920
|
return version;
|
|
1899
1921
|
}
|
|
1900
1922
|
function getToolingPackageVersion() {
|
|
@@ -2014,7 +2036,7 @@ function resolveTargets(options) {
|
|
|
2014
2036
|
}
|
|
2015
2037
|
function normalizeInitToolingTargets(input) {
|
|
2016
2038
|
const unknown = input.filter((item) => !initToolingTargets.includes(item));
|
|
2017
|
-
if (unknown.length > 0) throw new Error(
|
|
2039
|
+
if (unknown.length > 0) throw new Error(localize(`Unknown init tooling target: ${unknown.join(", ")}`, `未知的 init tooling 目标:${unknown.join(", ")}`));
|
|
2018
2040
|
return input;
|
|
2019
2041
|
}
|
|
2020
2042
|
async function initTooling(cwd, options = {}) {
|
|
@@ -2026,7 +2048,7 @@ async function initTooling(cwd, options = {}) {
|
|
|
2026
2048
|
updatedPackageJson: false
|
|
2027
2049
|
};
|
|
2028
2050
|
const pkgJsonPath = path.resolve(cwd, "package.json");
|
|
2029
|
-
if (!await fs$1.pathExists(pkgJsonPath)) throw new Error(
|
|
2051
|
+
if (!await fs$1.pathExists(pkgJsonPath)) throw new Error(localize(`Cannot initialize tooling because package.json was not found: ${pkgJsonPath}`, `未找到 package.json,无法初始化 tooling:${pkgJsonPath}`));
|
|
2030
2052
|
const packageJson = await fs$1.readJson(pkgJsonPath);
|
|
2031
2053
|
const toolingPackageName = resolveToolingPackageName();
|
|
2032
2054
|
const toolingImportSource = resolveToolingImportSource();
|
|
@@ -2045,7 +2067,7 @@ async function initTooling(cwd, options = {}) {
|
|
|
2045
2067
|
}));
|
|
2046
2068
|
if (exists && !options.force) {
|
|
2047
2069
|
skippedFiles.push(preset.filepath);
|
|
2048
|
-
logger.info(`
|
|
2070
|
+
logger.info(localize(`Skipped existing init target: ${preset.filepath}`, `跳过已存在的初始化目标:${preset.filepath}`));
|
|
2049
2071
|
continue;
|
|
2050
2072
|
}
|
|
2051
2073
|
const content = await preset.getContent({
|
|
@@ -2284,6 +2306,9 @@ function uniqueCommits(commits) {
|
|
|
2284
2306
|
}
|
|
2285
2307
|
return [...merged.values()];
|
|
2286
2308
|
}
|
|
2309
|
+
function isAutomationContributor(value) {
|
|
2310
|
+
return /github-actions|dependabot|renovate|\[bot\]$/i.test(value);
|
|
2311
|
+
}
|
|
2287
2312
|
function buildPackageCompareUrl(release, metadata) {
|
|
2288
2313
|
if (!release.previousVersion || !metadata.repository || !/^[^/]+\/[^/]+$/.test(metadata.repository)) return;
|
|
2289
2314
|
const serverUrl = (metadata.serverUrl || "https://github.com").replace(/\/$/, "");
|
|
@@ -2305,6 +2330,8 @@ function parseReferences(commits, content) {
|
|
|
2305
2330
|
const pullRequests = /* @__PURE__ */ new Set();
|
|
2306
2331
|
const issues = /* @__PURE__ */ new Set();
|
|
2307
2332
|
for (const message of [...commits.map((commit) => [commit.subject, commit.body ?? ""].join("\n")), content]) {
|
|
2333
|
+
for (const match of message.matchAll(/\]\([^)]*\/pull\/(\d+)\)/g)) pullRequests.add(Number(match[1]));
|
|
2334
|
+
for (const match of message.matchAll(/\]\([^)]*\/issues\/(\d+)\)/g)) issues.add(Number(match[1]));
|
|
2308
2335
|
for (const match of message.matchAll(/\(#(\d+)\)/g)) pullRequests.add(Number(match[1]));
|
|
2309
2336
|
for (const match of message.matchAll(/(?:^|\W)#(\d+)\b/g)) {
|
|
2310
2337
|
const number = Number(match[1]);
|
|
@@ -2342,6 +2369,7 @@ function sourceCategory(commits) {
|
|
|
2342
2369
|
}
|
|
2343
2370
|
}
|
|
2344
2371
|
function classifyChange(heading, summary, commits) {
|
|
2372
|
+
if (/dependenc(?:y|ies)/i.test(heading)) return "maintenance";
|
|
2345
2373
|
const fromCommit = sourceCategory(commits);
|
|
2346
2374
|
if (fromCommit) return fromCommit;
|
|
2347
2375
|
const categoryHint = [heading, summary].join(" ").toLowerCase();
|
|
@@ -2384,6 +2412,35 @@ function readMarkdownEntries(content) {
|
|
|
2384
2412
|
summary: content.trim()
|
|
2385
2413
|
}];
|
|
2386
2414
|
}
|
|
2415
|
+
function normalizeMarkdownEntry(item) {
|
|
2416
|
+
const raw = item.summary.replace(/\r?\n/g, " ").replace(/\s+/g, " ").trim();
|
|
2417
|
+
const commitMatches = [...raw.matchAll(/\[{1,2}`?([0-9a-f]{7,40})`?\]\(([^)]+\/commit\/[^)]+)\)/gi)];
|
|
2418
|
+
const pullRequests = [...raw.matchAll(/\[#(\d+)\]\(([^)]+\/pull\/\d+)\)/gi)].map((match) => Number(match[1]));
|
|
2419
|
+
const issues = [...raw.matchAll(/\[#(\d+)\]\(([^)]+\/issues\/\d+)\)/gi)].map((match) => Number(match[1]));
|
|
2420
|
+
const authors = [...raw.matchAll(/\bby\s+(@?[\w-]+(?:\[bot\])?)/gi)].map((match) => match[1]);
|
|
2421
|
+
const arrowDependency = raw.match(/→\s*`([^`]+)`/)?.[1];
|
|
2422
|
+
const dependencyVersions = [...raw.matchAll(/(?:^|\s)((?:@[\w.-]+\/)?[\w.-]+@\d+\.\d+\.\d+(?:-[\w.-]+)?)/g)].map((match) => match[1]);
|
|
2423
|
+
const dependencyLabel = /\bdependenc(?:y|ies):/i.test(raw) ? raw.replace(/^.*?\bdependenc(?:y|ies):/i, "").trim().replace(/^[-*]\s*/, "").replace(/^`|`$/g, "") : void 0;
|
|
2424
|
+
const dependencyName = arrowDependency ?? (dependencyVersions.length ? [...new Set(dependencyVersions)].join(", ") : dependencyLabel);
|
|
2425
|
+
const hasDependency = /\bupdated\s+dependenc(?:y|ies)\b|Dependencies:|Dependency:|\*\*Dependencies\*\*|\*\*Dependency\*\*/i.test(raw) || Boolean(dependencyName);
|
|
2426
|
+
const summary = hasDependency && dependencyName ? dependencyVersions.length > 1 ? `Updated dependencies: ${[...new Set(dependencyVersions)].join(", ")}.` : `Updated dependency to ${dependencyName}.` : raw.replace(/\[{1,2}`?([0-9a-f]{7,40})`?\]\([^)]+\)/gi, "").replace(/\[#\d+\]\([^)]+\)/g, "").replace(/\bby\s+@?[\w-]+(?:\[bot\])?/gi, "").replace(/\*\*/g, "").replace(/`/g, "").replace(/^[-*]\s+/, "").replace(/^[^\p{L}\p{N}]+/u, "").replace(/\s+/g, " ").trim();
|
|
2427
|
+
const categoryHint = /🚨|breaking/i.test(raw) ? "🚨" : /🚀|✨/.test(raw) ? "🚀" : /🐛|🐞/.test(raw) ? "🐞" : hasDependency ? "Dependencies" : "";
|
|
2428
|
+
const commits = commitMatches.map((match) => ({
|
|
2429
|
+
sha: match[2]?.match(/\/commit\/([0-9a-f]{7,40})/i)?.[1] ?? match[1],
|
|
2430
|
+
subject: `${hasDependency ? "chore" : categoryHint === "🐞" ? "fix" : categoryHint === "🚀" ? "feat" : "chore"}: ${summary}`,
|
|
2431
|
+
...authors[0] ? { author: authors[0] } : {},
|
|
2432
|
+
summary
|
|
2433
|
+
}));
|
|
2434
|
+
return {
|
|
2435
|
+
heading: categoryHint ? `${item.heading} ${categoryHint}` : item.heading,
|
|
2436
|
+
summary,
|
|
2437
|
+
commits,
|
|
2438
|
+
pullRequests: [...new Set(pullRequests)],
|
|
2439
|
+
issues: [...new Set(issues)],
|
|
2440
|
+
authors: [...new Set(authors)],
|
|
2441
|
+
raw
|
|
2442
|
+
};
|
|
2443
|
+
}
|
|
2387
2444
|
function commitsForPackage(commits, packageName) {
|
|
2388
2445
|
return uniqueCommits(commits.filter((commit) => !commit.packages?.length || commit.packages.includes(packageName)));
|
|
2389
2446
|
}
|
|
@@ -2406,20 +2463,21 @@ function commitsForEntry(commits, summary) {
|
|
|
2406
2463
|
function buildEntries(release, commits) {
|
|
2407
2464
|
const packageCommits = commitsForPackage(commits, release.name);
|
|
2408
2465
|
return readMarkdownEntries(release.content).flatMap((item) => {
|
|
2409
|
-
const
|
|
2466
|
+
const normalized = normalizeMarkdownEntry(item);
|
|
2467
|
+
const summary = normalized.summary;
|
|
2410
2468
|
if (!summary) return [];
|
|
2411
|
-
const entryCommits = commitsForEntry(packageCommits, summary);
|
|
2412
|
-
const refs = parseReferences(entryCommits, summary);
|
|
2469
|
+
const entryCommits = uniqueCommits([...commitsForEntry(packageCommits, summary), ...normalized.commits]);
|
|
2470
|
+
const refs = parseReferences(entryCommits, [normalized.raw, summary].join("\n"));
|
|
2413
2471
|
return [{
|
|
2414
2472
|
packageName: release.name,
|
|
2415
2473
|
version: release.version,
|
|
2416
2474
|
...release.npmUrl ? { npmUrl: release.npmUrl } : {},
|
|
2417
|
-
category: classifyChange(
|
|
2475
|
+
category: classifyChange(normalized.heading, summary, entryCommits),
|
|
2418
2476
|
summary,
|
|
2419
2477
|
commits: entryCommits,
|
|
2420
|
-
pullRequests: refs.pullRequests,
|
|
2421
|
-
issues: refs.issues,
|
|
2422
|
-
authors: entryCommits.map((commit) => commit.author).filter((author) => Boolean(author))
|
|
2478
|
+
pullRequests: [.../* @__PURE__ */ new Set([...refs.pullRequests, ...normalized.pullRequests])].sort((a, b) => a - b),
|
|
2479
|
+
issues: [.../* @__PURE__ */ new Set([...refs.issues, ...normalized.issues])].sort((a, b) => a - b),
|
|
2480
|
+
authors: [.../* @__PURE__ */ new Set([...normalized.authors, ...entryCommits.map((commit) => commit.author).filter((author) => Boolean(author))])]
|
|
2423
2481
|
}];
|
|
2424
2482
|
});
|
|
2425
2483
|
}
|
|
@@ -2455,7 +2513,7 @@ function formatContributor(value) {
|
|
|
2455
2513
|
return /^[\w-]+$/.test(value) ? `@${value}` : value;
|
|
2456
2514
|
}
|
|
2457
2515
|
function formatContributors(contributors) {
|
|
2458
|
-
const unique = [...new Set(contributors.map((value) => value.trim()).filter(
|
|
2516
|
+
const unique = [...new Set(contributors.map((value) => value.trim()).filter((value) => value && !isAutomationContributor(value)))].sort((a, b) => a.localeCompare(b));
|
|
2459
2517
|
return unique.length ? [
|
|
2460
2518
|
"## ❤️ Contributors",
|
|
2461
2519
|
"",
|
|
@@ -2502,7 +2560,7 @@ function renderGitHubRelease(document, metadata = {}) {
|
|
|
2502
2560
|
const section = formatCategoryEntries(document.entries, category, metadata, 3, true);
|
|
2503
2561
|
if (section.length) sections.push(...sections.length ? ["", ...section] : section);
|
|
2504
2562
|
}
|
|
2505
|
-
const contributors = [...new Set(document.contributors)].sort((a, b) => a.localeCompare(b));
|
|
2563
|
+
const contributors = [...new Set(document.contributors)].filter((value) => !isAutomationContributor(value)).sort((a, b) => a.localeCompare(b));
|
|
2506
2564
|
if (contributors.length) sections.push("", "### ❤️ Contributors", "", `Thanks to ${contributors.map(formatContributor).join(" · ")}`);
|
|
2507
2565
|
if (document.compareUrls.length) sections.push("", `##### [View changes on GitHub](${document.compareUrls[0]})`);
|
|
2508
2566
|
return sections.join("\n");
|
|
@@ -2723,6 +2781,17 @@ function buildReleasePackage(release) {
|
|
|
2723
2781
|
...packageLinks
|
|
2724
2782
|
};
|
|
2725
2783
|
}
|
|
2784
|
+
function buildReleaseNoteDocumentFromReleases(releases, metadata) {
|
|
2785
|
+
const entries = releases.flatMap((release) => buildEntries(release, metadata.commits ?? []));
|
|
2786
|
+
const contributors = [.../* @__PURE__ */ new Set([...metadata.contributors ?? [], ...entries.flatMap((entry) => entry.authors)])].filter((value) => !isAutomationContributor(value));
|
|
2787
|
+
const compareUrls = releases.map((release) => buildPackageCompareUrl(release, metadata)).filter((url) => Boolean(url));
|
|
2788
|
+
return {
|
|
2789
|
+
packages: releases.map(buildReleasePackage),
|
|
2790
|
+
entries,
|
|
2791
|
+
contributors,
|
|
2792
|
+
compareUrls
|
|
2793
|
+
};
|
|
2794
|
+
}
|
|
2726
2795
|
async function buildReleaseNoteDocument(cwd, previousVersions, metadata = {}) {
|
|
2727
2796
|
const workspacePackages = await getWorkspacePackages(cwd);
|
|
2728
2797
|
const releases = [];
|
|
@@ -2745,15 +2814,18 @@ async function buildReleaseNoteDocument(cwd, previousVersions, metadata = {}) {
|
|
|
2745
2814
|
});
|
|
2746
2815
|
}
|
|
2747
2816
|
}
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2817
|
+
return buildReleaseNoteDocumentFromReleases(releases, metadata);
|
|
2818
|
+
}
|
|
2819
|
+
function buildGitHubReleaseBodyFromChangelog(packageName, packageVersion, changelog, metadata = {}) {
|
|
2820
|
+
const section = readVersionSection(changelog, packageVersion);
|
|
2821
|
+
if (!section?.content) return "No significant changes.";
|
|
2822
|
+
return renderGitHubRelease(buildReleaseNoteDocumentFromReleases([{
|
|
2823
|
+
name: packageName,
|
|
2824
|
+
version: packageVersion,
|
|
2825
|
+
...section.previousVersion ? { previousVersion: section.previousVersion } : {},
|
|
2826
|
+
npmUrl: buildNpmPackageUrl(packageName, packageVersion),
|
|
2827
|
+
content: section.content
|
|
2828
|
+
}], metadata), metadata);
|
|
2757
2829
|
}
|
|
2758
2830
|
//#endregion
|
|
2759
2831
|
//#region src/commands/release/github.ts
|
|
@@ -2894,6 +2966,23 @@ var GitHubClient = class {
|
|
|
2894
2966
|
return recovered.data;
|
|
2895
2967
|
}
|
|
2896
2968
|
}
|
|
2969
|
+
async listReleases() {
|
|
2970
|
+
const releases = [];
|
|
2971
|
+
for (let page = 1;; page++) {
|
|
2972
|
+
const pageReleases = (await this.request("GET", `/releases?per_page=100&page=${page}`)).data ?? [];
|
|
2973
|
+
releases.push(...pageReleases);
|
|
2974
|
+
if (pageReleases.length < 100) break;
|
|
2975
|
+
}
|
|
2976
|
+
return releases;
|
|
2977
|
+
}
|
|
2978
|
+
async updateRelease(options) {
|
|
2979
|
+
const response = await this.request("PATCH", `/releases/${options.id}`, {
|
|
2980
|
+
name: options.name,
|
|
2981
|
+
body: options.body
|
|
2982
|
+
});
|
|
2983
|
+
if (!response.data) throw new GitHubApiError(`GitHub did not return release ${options.id} after update`, response.status);
|
|
2984
|
+
return response.data;
|
|
2985
|
+
}
|
|
2897
2986
|
async enrichReleaseNote(document) {
|
|
2898
2987
|
try {
|
|
2899
2988
|
const commitAuthors = /* @__PURE__ */ new Map();
|
|
@@ -2923,7 +3012,7 @@ var GitHubClient = class {
|
|
|
2923
3012
|
...document.contributors,
|
|
2924
3013
|
...commitAuthors.values(),
|
|
2925
3014
|
...referenceAuthors
|
|
2926
|
-
])]
|
|
3015
|
+
])].filter((value) => !isAutomationContributor(value))
|
|
2927
3016
|
};
|
|
2928
3017
|
} catch (error) {
|
|
2929
3018
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -3069,8 +3158,14 @@ function resolveGitHub(options) {
|
|
|
3069
3158
|
function resolveTarget(options) {
|
|
3070
3159
|
return getReleaseEnv(options)["GITHUB_SHA"]?.trim() || capture("git", ["rev-parse", "HEAD"], options);
|
|
3071
3160
|
}
|
|
3161
|
+
function formatPublishedPackageSummary(packages) {
|
|
3162
|
+
return ["Published packages:", ...packages.length ? packages.map((pkg) => ` - ${pkg.name}@${pkg.version}`) : [" (none)"]].join("\n");
|
|
3163
|
+
}
|
|
3072
3164
|
async function publishMetadata(packages, options, prerelease = false) {
|
|
3073
|
-
if (!packages.length)
|
|
3165
|
+
if (!packages.length) {
|
|
3166
|
+
logger.success(formatPublishedPackageSummary(packages));
|
|
3167
|
+
return;
|
|
3168
|
+
}
|
|
3074
3169
|
const github = resolveGitHub(options);
|
|
3075
3170
|
const target = resolveTarget(options);
|
|
3076
3171
|
const releaseEnv = getReleaseEnv(options);
|
|
@@ -3132,6 +3227,7 @@ async function publishMetadata(packages, options, prerelease = false) {
|
|
|
3132
3227
|
body
|
|
3133
3228
|
});
|
|
3134
3229
|
}
|
|
3230
|
+
logger.success(formatPublishedPackageSummary(packages));
|
|
3135
3231
|
}
|
|
3136
3232
|
async function createReleasePullRequest(options) {
|
|
3137
3233
|
const branch = resolveBranch(options);
|
|
@@ -3252,6 +3348,105 @@ async function releaseCi(options) {
|
|
|
3252
3348
|
await publishMetadata(await readPublishSummary(options.cwd), options);
|
|
3253
3349
|
}
|
|
3254
3350
|
//#endregion
|
|
3351
|
+
//#region src/commands/release/repair.ts
|
|
3352
|
+
function parseReleaseTag(tag) {
|
|
3353
|
+
const separator = tag.lastIndexOf("@");
|
|
3354
|
+
if (separator <= 0) return;
|
|
3355
|
+
const packageName = tag.slice(0, separator);
|
|
3356
|
+
const version = tag.slice(separator + 1);
|
|
3357
|
+
if (!/^\d+\.\d+\.\d+(?:-[0-9a-z.-]+)?(?:\+[0-9a-z.-]+)?$/i.test(version)) return;
|
|
3358
|
+
return {
|
|
3359
|
+
packageName,
|
|
3360
|
+
version
|
|
3361
|
+
};
|
|
3362
|
+
}
|
|
3363
|
+
function packagePath(cwd, rootDir) {
|
|
3364
|
+
return path.relative(cwd, rootDir).replaceAll("\\", "/");
|
|
3365
|
+
}
|
|
3366
|
+
async function findTaggedPackageDirectory(tag, packageName, currentDirectories, options) {
|
|
3367
|
+
const currentDirectory = currentDirectories.get(packageName);
|
|
3368
|
+
if (currentDirectory) return currentDirectory;
|
|
3369
|
+
let packageFiles;
|
|
3370
|
+
try {
|
|
3371
|
+
packageFiles = capture("git", [
|
|
3372
|
+
"ls-tree",
|
|
3373
|
+
"-r",
|
|
3374
|
+
"--name-only",
|
|
3375
|
+
tag
|
|
3376
|
+
], options).split(/\r?\n/).filter((file) => file === "package.json" || file.endsWith("/package.json"));
|
|
3377
|
+
} catch {
|
|
3378
|
+
return;
|
|
3379
|
+
}
|
|
3380
|
+
for (const packageFile of packageFiles) try {
|
|
3381
|
+
if (JSON.parse(capture("git", ["show", `${tag}:${packageFile}`], options)).name === packageName) return packageFile === "package.json" ? "." : path.dirname(packageFile);
|
|
3382
|
+
} catch {}
|
|
3383
|
+
}
|
|
3384
|
+
async function readTagChangelog(tag, relativePackagePath, options) {
|
|
3385
|
+
const result = (options.spawn ?? spawnSync)("git", ["show", `${tag}:${relativePackagePath}/CHANGELOG.md`], {
|
|
3386
|
+
cwd: options.cwd,
|
|
3387
|
+
encoding: "utf8",
|
|
3388
|
+
shell: false,
|
|
3389
|
+
stdio: [
|
|
3390
|
+
"ignore",
|
|
3391
|
+
"pipe",
|
|
3392
|
+
"ignore"
|
|
3393
|
+
]
|
|
3394
|
+
});
|
|
3395
|
+
if (result.status !== 0) return;
|
|
3396
|
+
return result.stdout?.toString().trim() || void 0;
|
|
3397
|
+
}
|
|
3398
|
+
function releaseMetadata(options) {
|
|
3399
|
+
const env = getReleaseEnv(options);
|
|
3400
|
+
return {
|
|
3401
|
+
...env["GITHUB_REPOSITORY"] ? { repository: env["GITHUB_REPOSITORY"] } : {},
|
|
3402
|
+
...env["GITHUB_SERVER_URL"] ? { serverUrl: env["GITHUB_SERVER_URL"] } : {}
|
|
3403
|
+
};
|
|
3404
|
+
}
|
|
3405
|
+
async function repairReleaseNotes(options) {
|
|
3406
|
+
if (!options.all && !options.tag) throw new ReleaseCommandError("release notes repair requires --all or --tag <package@version>");
|
|
3407
|
+
const github = options.github ?? new GitHubClient();
|
|
3408
|
+
if (!github.listReleases || !github.updateRelease) throw new ReleaseCommandError("GitHub release repair requires listReleases and updateRelease operations");
|
|
3409
|
+
const releases = await github.listReleases();
|
|
3410
|
+
const selected = options.tag ? releases.filter((release) => release.tag_name === options.tag) : releases;
|
|
3411
|
+
const packages = await getWorkspacePackages(options.cwd);
|
|
3412
|
+
const workspaceRoot = await realpath(options.cwd);
|
|
3413
|
+
const packageDirectories = new Map(await Promise.all(packages.filter((pkg) => typeof pkg.manifest.name === "string").map(async (pkg) => {
|
|
3414
|
+
const rootDir = await realpath(pkg.rootDir);
|
|
3415
|
+
return [pkg.manifest.name, packagePath(workspaceRoot, rootDir)];
|
|
3416
|
+
})));
|
|
3417
|
+
const metadata = releaseMetadata(options);
|
|
3418
|
+
const repaired = [];
|
|
3419
|
+
const skipped = [];
|
|
3420
|
+
for (const release of selected) {
|
|
3421
|
+
const parsed = parseReleaseTag(release.tag_name);
|
|
3422
|
+
if (!parsed) {
|
|
3423
|
+
skipped.push(release.tag_name);
|
|
3424
|
+
continue;
|
|
3425
|
+
}
|
|
3426
|
+
let relativePath = await findTaggedPackageDirectory(release.tag_name, parsed.packageName, packageDirectories, options);
|
|
3427
|
+
let changelog = relativePath ? await readTagChangelog(release.tag_name, relativePath, options) : void 0;
|
|
3428
|
+
if (!changelog) {
|
|
3429
|
+
relativePath = await findTaggedPackageDirectory(release.tag_name, parsed.packageName, /* @__PURE__ */ new Map(), options);
|
|
3430
|
+
changelog = relativePath ? await readTagChangelog(release.tag_name, relativePath, options) : void 0;
|
|
3431
|
+
}
|
|
3432
|
+
if (!changelog) {
|
|
3433
|
+
skipped.push(release.tag_name);
|
|
3434
|
+
continue;
|
|
3435
|
+
}
|
|
3436
|
+
const body = buildGitHubReleaseBodyFromChangelog(parsed.packageName, parsed.version, changelog, metadata);
|
|
3437
|
+
if (!options.dryRun && (release.name !== release.tag_name || release.body !== body)) await github.updateRelease({
|
|
3438
|
+
id: release.id,
|
|
3439
|
+
name: release.tag_name,
|
|
3440
|
+
body
|
|
3441
|
+
});
|
|
3442
|
+
repaired.push(release.tag_name);
|
|
3443
|
+
}
|
|
3444
|
+
return {
|
|
3445
|
+
repaired,
|
|
3446
|
+
skipped
|
|
3447
|
+
};
|
|
3448
|
+
}
|
|
3449
|
+
//#endregion
|
|
3255
3450
|
//#region src/commands/templates.ts
|
|
3256
3451
|
async function collectFiles(rootDir) {
|
|
3257
3452
|
const files = [];
|
|
@@ -3305,27 +3500,27 @@ async function checkTemplates(options = {}) {
|
|
|
3305
3500
|
checks.push(sourceDuplicates.length ? {
|
|
3306
3501
|
id: "unique-source",
|
|
3307
3502
|
status: "fail",
|
|
3308
|
-
title: "模板 source 唯一性",
|
|
3309
|
-
detail: `存在重复 source:${sourceDuplicates.map(([value, first, second]) => `${value} (${first}, ${second})`).join(", ")}
|
|
3310
|
-
fix: "调整 template-data.mjs,确保每个模板 key 指向独立 source。"
|
|
3503
|
+
title: localize("Template source uniqueness", "模板 source 唯一性"),
|
|
3504
|
+
detail: localize(`Duplicate sources: ${sourceDuplicates.map(([value, first, second]) => `${value} (${first}, ${second})`).join(", ")}`, `存在重复 source:${sourceDuplicates.map(([value, first, second]) => `${value} (${first}, ${second})`).join(", ")}`),
|
|
3505
|
+
fix: localize("Update template-data.mjs so every template has a unique source.", "调整 template-data.mjs,确保每个模板 key 指向独立 source。")
|
|
3311
3506
|
} : {
|
|
3312
3507
|
id: "unique-source",
|
|
3313
3508
|
status: "pass",
|
|
3314
|
-
title: "模板 source 唯一性",
|
|
3315
|
-
detail: "所有模板 source 都是唯一的。"
|
|
3509
|
+
title: localize("Template source uniqueness", "模板 source 唯一性"),
|
|
3510
|
+
detail: localize("Every template source is unique.", "所有模板 source 都是唯一的。")
|
|
3316
3511
|
});
|
|
3317
3512
|
const targetDuplicates = checkDuplicates(choices, "target");
|
|
3318
3513
|
checks.push(targetDuplicates.length ? {
|
|
3319
3514
|
id: "unique-target",
|
|
3320
3515
|
status: "fail",
|
|
3321
|
-
title: "模板 target 唯一性",
|
|
3322
|
-
detail: `存在重复 target:${targetDuplicates.map(([value, first, second]) => `${value} (${first}, ${second})`).join(", ")}
|
|
3323
|
-
fix: "调整 template-data.mjs,避免多个模板默认写入同一目标目录。"
|
|
3516
|
+
title: localize("Template target uniqueness", "模板 target 唯一性"),
|
|
3517
|
+
detail: localize(`Duplicate targets: ${targetDuplicates.map(([value, first, second]) => `${value} (${first}, ${second})`).join(", ")}`, `存在重复 target:${targetDuplicates.map(([value, first, second]) => `${value} (${first}, ${second})`).join(", ")}`),
|
|
3518
|
+
fix: localize("Update template-data.mjs so every template has a unique target.", "调整 template-data.mjs,避免多个模板默认写入同一目标目录。")
|
|
3324
3519
|
} : {
|
|
3325
3520
|
id: "unique-target",
|
|
3326
3521
|
status: "pass",
|
|
3327
|
-
title: "模板 target 唯一性",
|
|
3328
|
-
detail: "所有模板 target 都是唯一的。"
|
|
3522
|
+
title: localize("Template target uniqueness", "模板 target 唯一性"),
|
|
3523
|
+
detail: localize("Every template target is unique.", "所有模板 target 都是唯一的。")
|
|
3329
3524
|
});
|
|
3330
3525
|
for (const choice of choices) {
|
|
3331
3526
|
const sourceDir = path.join(templatesDir$1, choice.source);
|
|
@@ -3335,43 +3530,43 @@ async function checkTemplates(options = {}) {
|
|
|
3335
3530
|
id: "source-dir",
|
|
3336
3531
|
template: choice.key,
|
|
3337
3532
|
status: "pass",
|
|
3338
|
-
title: "模板目录",
|
|
3339
|
-
detail: `${choice.key} source exists: ${path.relative(templatesDir$1, sourceDir)}`
|
|
3533
|
+
title: localize("Template directory", "模板目录"),
|
|
3534
|
+
detail: localize(`${choice.key} source exists: ${path.relative(templatesDir$1, sourceDir)}`, `${choice.key} 源目录存在:${path.relative(templatesDir$1, sourceDir)}`)
|
|
3340
3535
|
} : {
|
|
3341
3536
|
id: "source-dir",
|
|
3342
3537
|
template: choice.key,
|
|
3343
3538
|
status: "fail",
|
|
3344
|
-
title: "模板目录",
|
|
3345
|
-
detail: `${choice.key} 缺少 source 目录:${sourceDir}
|
|
3346
|
-
fix: "补齐模板目录,或修正 template-data.mjs 中的 source。"
|
|
3539
|
+
title: localize("Template directory", "模板目录"),
|
|
3540
|
+
detail: localize(`${choice.key} is missing source directory: ${sourceDir}`, `${choice.key} 缺少 source 目录:${sourceDir}`),
|
|
3541
|
+
fix: localize("Add the directory or correct template-data.mjs.", "补齐模板目录,或修正 template-data.mjs 中的 source。")
|
|
3347
3542
|
});
|
|
3348
3543
|
checks.push(await fs$1.pathExists(packageJsonPath) ? {
|
|
3349
3544
|
id: "package-json",
|
|
3350
3545
|
template: choice.key,
|
|
3351
3546
|
status: "pass",
|
|
3352
|
-
title: "模板 package.json",
|
|
3353
|
-
detail: `${choice.key} 包含 package.json。`
|
|
3547
|
+
title: localize("Template package.json", "模板 package.json"),
|
|
3548
|
+
detail: localize(`${choice.key} contains package.json.`, `${choice.key} 包含 package.json。`)
|
|
3354
3549
|
} : {
|
|
3355
3550
|
id: "package-json",
|
|
3356
3551
|
template: choice.key,
|
|
3357
3552
|
status: "fail",
|
|
3358
|
-
title: "模板 package.json",
|
|
3359
|
-
detail: `${choice.key} 缺少 package.json
|
|
3360
|
-
fix: "模板根目录应包含 package.json,脚手架会基于它重写 name/version/repository。"
|
|
3553
|
+
title: localize("Template package.json", "模板 package.json"),
|
|
3554
|
+
detail: localize(`${choice.key} is missing package.json.`, `${choice.key} 缺少 package.json。`),
|
|
3555
|
+
fix: localize("Template roots need package.json so scaffolding can rewrite metadata.", "模板根目录应包含 package.json,脚手架会基于它重写 name/version/repository。")
|
|
3361
3556
|
});
|
|
3362
3557
|
checks.push(choice.category && choice.description ? {
|
|
3363
3558
|
id: "metadata",
|
|
3364
3559
|
template: choice.key,
|
|
3365
3560
|
status: "pass",
|
|
3366
|
-
title: "模板元数据",
|
|
3367
|
-
detail: `${choice.key} 已声明 category 和 description。`
|
|
3561
|
+
title: localize("Template metadata", "模板元数据"),
|
|
3562
|
+
detail: localize(`${choice.key} declares category and description.`, `${choice.key} 已声明 category 和 description。`)
|
|
3368
3563
|
} : {
|
|
3369
3564
|
id: "metadata",
|
|
3370
3565
|
template: choice.key,
|
|
3371
3566
|
status: "warn",
|
|
3372
|
-
title: "模板元数据",
|
|
3373
|
-
detail: `${choice.key} 缺少 category 或 description
|
|
3374
|
-
fix: "补充 template-data.mjs 中的 category 和 description,方便 CLI 和文档展示。"
|
|
3567
|
+
title: localize("Template metadata", "模板元数据"),
|
|
3568
|
+
detail: localize(`${choice.key} is missing category or description.`, `${choice.key} 缺少 category 或 description。`),
|
|
3569
|
+
fix: localize("Add category and description in template-data.mjs.", "补充 template-data.mjs 中的 category 和 description,方便 CLI 和文档展示。")
|
|
3375
3570
|
});
|
|
3376
3571
|
if (!sourceExists) continue;
|
|
3377
3572
|
const skippedFiles = (await collectFiles(sourceDir)).filter((file) => shouldSkipTemplatePath(sourceDir, file)).map((file) => path.relative(sourceDir, file));
|
|
@@ -3379,15 +3574,15 @@ async function checkTemplates(options = {}) {
|
|
|
3379
3574
|
id: "filtered-files",
|
|
3380
3575
|
template: choice.key,
|
|
3381
3576
|
status: "fail",
|
|
3382
|
-
title: "模板临时文件",
|
|
3383
|
-
detail: `${choice.key} 包含会被脚手架过滤的文件:${skippedFiles.join(", ")}
|
|
3384
|
-
fix: "删除模板源目录里的临时、缓存或生成文件。"
|
|
3577
|
+
title: localize("Temporary template files", "模板临时文件"),
|
|
3578
|
+
detail: localize(`${choice.key} contains filtered files: ${skippedFiles.join(", ")}`, `${choice.key} 包含会被脚手架过滤的文件:${skippedFiles.join(", ")}`),
|
|
3579
|
+
fix: localize("Remove temporary, cache, or generated files from the template source.", "删除模板源目录里的临时、缓存或生成文件。")
|
|
3385
3580
|
} : {
|
|
3386
3581
|
id: "filtered-files",
|
|
3387
3582
|
template: choice.key,
|
|
3388
3583
|
status: "pass",
|
|
3389
|
-
title: "模板临时文件",
|
|
3390
|
-
detail: `${choice.key} 没有检测到会被过滤的临时文件。`
|
|
3584
|
+
title: localize("Temporary template files", "模板临时文件"),
|
|
3585
|
+
detail: localize(`${choice.key} contains no filtered temporary files.`, `${choice.key} 没有检测到会被过滤的临时文件。`)
|
|
3391
3586
|
});
|
|
3392
3587
|
}
|
|
3393
3588
|
return {
|
|
@@ -3549,7 +3744,7 @@ async function scheduleOverwrite(intent, options) {
|
|
|
3549
3744
|
async function flushPendingOverwrites(pending, options = {}) {
|
|
3550
3745
|
if (!pending.length) return;
|
|
3551
3746
|
if (options.noOverwrite) {
|
|
3552
|
-
for (const item of pending) logger.info(`
|
|
3747
|
+
for (const item of pending) logger.info(localize(`Skipped changed file: ${item.relPath}`, `跳过已变更文件:${item.relPath}`));
|
|
3553
3748
|
return;
|
|
3554
3749
|
}
|
|
3555
3750
|
if (options.yes || options.overwrite) {
|
|
@@ -3557,11 +3752,11 @@ async function flushPendingOverwrites(pending, options = {}) {
|
|
|
3557
3752
|
return;
|
|
3558
3753
|
}
|
|
3559
3754
|
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
3560
|
-
for (const item of pending) logger.info(`
|
|
3755
|
+
for (const item of pending) logger.info(localize(`Skipped changed file in non-interactive mode: ${item.relPath}`, `非交互模式下跳过已变更文件:${item.relPath}`));
|
|
3561
3756
|
return;
|
|
3562
3757
|
}
|
|
3563
3758
|
const selected = await checkbox({
|
|
3564
|
-
message: "
|
|
3759
|
+
message: localize("Select changed managed files to overwrite", "检测到以下文件内容与当前仓库不同,请选择要覆盖的文件"),
|
|
3565
3760
|
choices: pending.map((item) => ({
|
|
3566
3761
|
name: pc.greenBright(item.relPath),
|
|
3567
3762
|
value: item.targetPath,
|
|
@@ -3658,6 +3853,38 @@ function setPkgJson(sourcePkgJson, targetPkgJson, options) {
|
|
|
3658
3853
|
}
|
|
3659
3854
|
}
|
|
3660
3855
|
//#endregion
|
|
3856
|
+
//#region src/commands/upgrade/text/index.ts
|
|
3857
|
+
const crlfPattern = /\r\n/g;
|
|
3858
|
+
function normalizeEol(input) {
|
|
3859
|
+
return input.replace(crlfPattern, "\n");
|
|
3860
|
+
}
|
|
3861
|
+
function normalizeGitignoreLine(line) {
|
|
3862
|
+
const trimmed = line.trim();
|
|
3863
|
+
if (!trimmed) return "";
|
|
3864
|
+
if (trimmed.startsWith("#")) return `#${trimmed.slice(1).trim()}`;
|
|
3865
|
+
return trimmed;
|
|
3866
|
+
}
|
|
3867
|
+
function isTextEquivalent(left, right) {
|
|
3868
|
+
return normalizeEol(left).trimEnd() === normalizeEol(right).trimEnd();
|
|
3869
|
+
}
|
|
3870
|
+
function mergeGitignore(source, target) {
|
|
3871
|
+
const sourceLines = normalizeEol(source).split("\n");
|
|
3872
|
+
const result = normalizeEol(target).split("\n");
|
|
3873
|
+
const seen = new Set(result.map((line) => normalizeGitignoreLine(line)).filter(Boolean));
|
|
3874
|
+
for (const line of sourceLines) {
|
|
3875
|
+
const normalized = normalizeGitignoreLine(line);
|
|
3876
|
+
if (!normalized || seen.has(normalized)) continue;
|
|
3877
|
+
seen.add(normalized);
|
|
3878
|
+
result.push(line);
|
|
3879
|
+
}
|
|
3880
|
+
while (result.length) {
|
|
3881
|
+
const last = result.at(-1);
|
|
3882
|
+
if (last === void 0 || last.trim().length > 0) break;
|
|
3883
|
+
result.pop();
|
|
3884
|
+
}
|
|
3885
|
+
return `${result.join("\n")}\n`;
|
|
3886
|
+
}
|
|
3887
|
+
//#endregion
|
|
3661
3888
|
//#region src/commands/upgrade/workspace.ts
|
|
3662
3889
|
function isPlainObject(value) {
|
|
3663
3890
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -3714,36 +3941,6 @@ function mergeWorkspaceManifest(source, target) {
|
|
|
3714
3941
|
}
|
|
3715
3942
|
//#endregion
|
|
3716
3943
|
//#region src/commands/upgrade/index.ts
|
|
3717
|
-
const crlfPattern = /\r\n/g;
|
|
3718
|
-
function normalizeEol(input) {
|
|
3719
|
-
return input.replace(crlfPattern, "\n");
|
|
3720
|
-
}
|
|
3721
|
-
function normalizeGitignoreLine(line) {
|
|
3722
|
-
const trimmed = line.trim();
|
|
3723
|
-
if (!trimmed) return "";
|
|
3724
|
-
if (trimmed.startsWith("#")) return `#${trimmed.slice(1).trim()}`;
|
|
3725
|
-
return trimmed;
|
|
3726
|
-
}
|
|
3727
|
-
function isTextEquivalent(left, right) {
|
|
3728
|
-
return normalizeEol(left).trimEnd() === normalizeEol(right).trimEnd();
|
|
3729
|
-
}
|
|
3730
|
-
function mergeGitignore(source, target) {
|
|
3731
|
-
const sourceLines = normalizeEol(source).split("\n");
|
|
3732
|
-
const result = normalizeEol(target).split("\n");
|
|
3733
|
-
const seen = new Set(result.map((line) => normalizeGitignoreLine(line)).filter(Boolean));
|
|
3734
|
-
for (const line of sourceLines) {
|
|
3735
|
-
const normalized = normalizeGitignoreLine(line);
|
|
3736
|
-
if (!normalized || seen.has(normalized)) continue;
|
|
3737
|
-
seen.add(normalized);
|
|
3738
|
-
result.push(line);
|
|
3739
|
-
}
|
|
3740
|
-
while (result.length) {
|
|
3741
|
-
const last = result.at(-1);
|
|
3742
|
-
if (last === void 0 || last.trim().length > 0) break;
|
|
3743
|
-
result.pop();
|
|
3744
|
-
}
|
|
3745
|
-
return `${result.join("\n")}\n`;
|
|
3746
|
-
}
|
|
3747
3944
|
/**
|
|
3748
3945
|
* 将 assets 目录的模版文件同步到工程中,实现一键升级脚手架能力。
|
|
3749
3946
|
*/
|
|
@@ -3766,9 +3963,9 @@ async function upgradeMonorepo(opts) {
|
|
|
3766
3963
|
const configTargets = upgradeConfig?.targets ?? [];
|
|
3767
3964
|
const mergeTargets = upgradeConfig?.mergeTargets;
|
|
3768
3965
|
let targets = configTargets.length ? mergeTargets === false ? [...configTargets] : [.../* @__PURE__ */ new Set([...baseTargets, ...configTargets])] : baseTargets;
|
|
3769
|
-
if (merged.interactive) if (!process.stdin.isTTY || !process.stdout.isTTY) logger.info("
|
|
3966
|
+
if (merged.interactive) if (!process.stdin.isTTY || !process.stdout.isTTY) logger.info(localize("Skipped interactive target selection in non-interactive mode.", "非交互模式下跳过交互式目标选择。"));
|
|
3770
3967
|
else targets = await checkbox({
|
|
3771
|
-
message: "选择你需要的文件",
|
|
3968
|
+
message: localize("Select the files you need", "选择你需要的文件"),
|
|
3772
3969
|
choices: targets.map((x) => {
|
|
3773
3970
|
return {
|
|
3774
3971
|
value: x,
|
|
@@ -3798,7 +3995,7 @@ async function upgradeMonorepo(opts) {
|
|
|
3798
3995
|
const targetPath = path.resolve(absOutDir, relPath);
|
|
3799
3996
|
if (relPath === ".github/workflows/release.yml" && await fs$1.pathExists(targetPath)) {
|
|
3800
3997
|
if (await classifyReleaseWorkflow(absOutDir) === "custom" && !merged.overwriteRelease) {
|
|
3801
|
-
logger.warn("
|
|
3998
|
+
logger.warn(localize("Skipped custom release workflow; use repo upgrade --overwrite-release to replace it.", "已跳过自定义发布工作流;如需替换,请使用 repo upgrade --overwrite-release。"));
|
|
3802
3999
|
continue;
|
|
3803
4000
|
}
|
|
3804
4001
|
}
|
|
@@ -3981,6 +4178,7 @@ var commands_exports = /* @__PURE__ */ __exportAll({
|
|
|
3981
4178
|
releaseCi: () => releaseCi,
|
|
3982
4179
|
releasePrerelease: () => releasePrerelease,
|
|
3983
4180
|
releaseStable: () => releaseStable,
|
|
4181
|
+
repairReleaseNotes: () => repairReleaseNotes,
|
|
3984
4182
|
resolveCreateNewProjectPlan: () => resolveCreateNewProjectPlan,
|
|
3985
4183
|
resolveFullWorkspaceCheckPlan: () => resolveFullWorkspaceCheckPlan,
|
|
3986
4184
|
resolveRecommendedCheckPlan: () => resolveRecommendedCheckPlan,
|
|
@@ -3997,4 +4195,4 @@ var commands_exports = /* @__PURE__ */ __exportAll({
|
|
|
3997
4195
|
verifyStagedTypecheck: () => verifyStagedTypecheck
|
|
3998
4196
|
});
|
|
3999
4197
|
//#endregion
|
|
4000
|
-
export {
|
|
4198
|
+
export { verifyPreCommit as $, getCreateChoices as A, isMatch as B, collectEnvInfo as C, runDoctor as D, collectEnvSupportBundle as E, cleanProjects as F, toPublishGitignorePath as G, getFileHash as H, getSkillTargetPaths as I, getKnownRepoCheckCommands as J, toWorkspaceGitignorePath as K, skillTargets as L, resolveCreateNewProjectPlan as M, templateMap as N, createNewProject as O, inspectMonorepoConfig as P, verifyCommitMsg as Q, syncSkills as R, createContext as S, collectEnvSnapshot as T, isFileChanged as U, setByPath as V, isGitignoreFile as W, resolveRecommendedCheckPlan as X, resolveFullWorkspaceCheckPlan as Y, runRecommendedCheck as Z, setVscodeBinaryMirror as _, createReleasePullRequest as a, generateAgenticTemplates as at, initTooling as b, prepareStable as c, enterPrerelease as d, verifyPrePush as et, exitPrerelease as f, parsePublishSummary as g, GitHubClient as h, repairReleaseNotes as i, generateAgenticTemplate as it, getTemplateMap as j, defaultTemplate as k, publishStable as l, GitHubApiError as m, upgradeMonorepo as n, createTimestampFolderName as nt, recoverUnpublished as o, loadAgenticTasks as ot, releasePrerelease as p, updateIssueTemplateConfig as q, checkTemplates as r, defaultAgenticBaseDir as rt, releaseCi as s, GitClient as st, commands_exports as t, verifyStagedTypecheck as tt, releaseStable as u, init as v, collectEnvPaths as w, normalizeInitToolingTargets as x, initMetadata as y, escapeStringRegexp as z };
|