@icebreakers/monorepo 5.1.1 → 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.
@@ -1,8 +1,8 @@
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 { _ as isIgnorableFsError, c as devDependencies$1, d as logger, g as fs$1, i as packageDir, n as assetsDir, o as templatesDir, s as dependencies, t as initToolingTargets, u as version$1 } from "./types-CLzhRYdV.mjs";
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-Bn3XOfO0.mjs";
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";
@@ -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
- "上下文线索(日志/文件/模块/相关 issue)",
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((title) => `## ${title}\n- `).join("\n\n")}\n`;
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 title of agenticSections) payload[title] = "";
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}:${path.relative(cwd, targetPath)}`);
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
- const workspaceDirs = [...new Set(stagedFiles.filter((file) => {
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 = minVersion(packageVersion ?? "");
1283
- if (!parsed || !gte(parsed, "5.1.0")) checks.push(check("release-cli-version", "release CLI version", "warn", `repoctl 版本 ${packageVersion ?? "missing"} 不保证支持 release ci。`, `运行 pnpm dlx repoctl@latest upgrade --yes,或将 repoctl 升级到 >=${releaseCiMinimumVersion}。`));
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 createCheck(check) {
1305
- return check;
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" ? {
1396
+ function resolveToolPackage(pkgJson) {
1397
+ const version = pkgJson.devDependencies?.["repoctl"] ?? pkgJson.dependencies?.["repoctl"];
1398
+ return typeof version === "string" ? {
1319
1399
  name: "repoctl",
1320
- version: pkgJson.devDependencies["repoctl"]
1321
- } : null, typeof pkgJson.dependencies?.["repoctl"] === "string" ? {
1322
- name: "repoctl",
1323
- version: pkgJson.dependencies["repoctl"]
1324
- } : null].find((value) => value !== null) ?? 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 getMissingScripts(pkgJson, expected) {
1330
- return Object.keys(expected).filter((scriptName) => !hasScript(pkgJson, scriptName));
1331
- }
1332
- function getUnexpectedScripts(pkgJson, expected) {
1333
- return Object.entries(expected).filter(([scriptName, expectedCommand]) => hasScript(pkgJson, scriptName) && pkgJson.scripts?.[scriptName] !== expectedCommand).map(([scriptName]) => scriptName);
1334
- }
1335
- function getWorkspacePatterns(manifest) {
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 absBaseDir = `${workspaceDir}/${baseDir}`;
1364
- if (!await fs$1.pathExists(absBaseDir)) continue;
1365
- const entries = await readdir(absBaseDir);
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
- return result.sort((left, right) => left.localeCompare(right));
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 runDoctor(cwd) {
1374
- const workspaceDir = await findWorkspaceDir(cwd) ?? cwd;
1375
- const packageJsonPath = `${workspaceDir}/package.json`;
1376
- const workspaceManifestPath = `${workspaceDir}/pnpm-workspace.yaml`;
1377
- const repoctlConfigPath = `${workspaceDir}/repoctl.config.ts`;
1378
- const legacyMonorepoConfigPath = `${workspaceDir}/monorepo.config.ts`;
1379
- const huskyPreCommitPath = `${workspaceDir}/.husky/pre-commit`;
1380
- const lintStagedConfigPath = `${workspaceDir}/lint-staged.config.js`;
1381
- const [hasPackageJson, hasWorkspaceManifest, hasRepoctlConfig, hasLegacyMonorepoConfig, hasHuskyPreCommit, hasLintStagedConfig] = await Promise.all([
1382
- fs$1.pathExists(packageJsonPath),
1383
- fs$1.pathExists(workspaceManifestPath),
1384
- fs$1.pathExists(repoctlConfigPath),
1385
- fs$1.pathExists(legacyMonorepoConfigPath),
1386
- fs$1.pathExists(huskyPreCommitPath),
1387
- fs$1.pathExists(lintStagedConfigPath)
1388
- ]);
1389
- const pkgJson = hasPackageJson ? await fs$1.readJson(packageJsonPath) : {};
1390
- const packageCount = hasWorkspaceManifest ? (await getWorkspacePackages(workspaceDir, { ignorePrivatePackage: false })).length : 0;
1391
- const workspacePatterns = hasWorkspaceManifest ? getWorkspacePatterns(YAML.parse(await fs$1.readFile(workspaceManifestPath, "utf8"))) : [];
1392
- const workspacePackageDirs = hasWorkspaceManifest ? await findWorkspacePackageDirs(workspaceDir) : [];
1393
- const isSourceWorkspace = await isRepoctlSourceWorkspace(workspaceDir);
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:${packageJsonPath}`
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,当前目录不像一个完整的 pnpm monorepo 根目录。",
1415
- fix: "运行 repo init --yes 补充 pnpm-workspace.yaml,或确认你当前就在仓库根目录。"
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 = pkgJson.engines?.node;
1418
- if (typeof nodeRange === "string" && nodeRange.length > 0) checks.push(satisfies(process.version, nodeRange) ? createCheck({
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: "切换到 package.json -> engines.node 要求的版本后再执行 install / build / check。"
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,无法自动校验 Node 版本。",
1435
- fix: "建议补充 package.json -> engines.node,避免团队成员使用不一致的运行时。"
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 以保持运行时一致。")
1436
1519
  }));
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。"
1449
- }));
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,repoctl 不再加载该文件。",
1473
- fix: "将 monorepo.config.ts 改名为 repoctl.config.ts,并确认根配置只保留 repoctl.config.ts。"
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: "已检测到配置文件:repoctl.config.ts"
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: "当前仓库没有自定义配置文件,CLI 会完全使用默认行为。",
1486
- fix: "运行 repo upgrade --yes 同步默认 repoctl.config.ts,或手动添加 repoctl.config.ts。"
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 与 lint-staged.config.js,提交前校验链路完整。"
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: "当前仓库未检测到 Husky / lint-staged 提交校验入口。",
1506
- fix: "运行 repo upgrade --yes 同步 Husky 与 lint-staged 默认配置。"
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 configFiles = [...isSourceWorkspace ? [] : [
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
- ].flatMap((dir) => [`${dir}/*/eslint.config.js`, `${dir}/*/vitest.config.ts`])];
1518
- const legacyToolingFiles = [];
1519
- for (const filePattern of configFiles) {
1520
- if (filePattern.includes("*")) {
1521
- const [baseDir, rest] = filePattern.split("/*/");
1522
- const absBaseDir = `${workspaceDir}/${baseDir}`;
1523
- if (!await fs$1.pathExists(absBaseDir)) continue;
1524
- const entries = await readdir(absBaseDir);
1525
- await Promise.all(entries.map(async (entry) => {
1526
- const candidate = `${absBaseDir}/${entry}/${rest}`;
1527
- if (await fs$1.pathExists(candidate) && hasLegacyToolingReference(await fs$1.readFile(candidate, "utf8"))) legacyToolingFiles.push(`${baseDir}/${entry}/${rest}`);
1528
- }));
1529
- continue;
1530
- }
1531
- const candidate = `${workspaceDir}/${filePattern}`;
1532
- if (await fs$1.pathExists(candidate) && hasLegacyToolingReference(await fs$1.readFile(candidate, "utf8"))) legacyToolingFiles.push(filePattern);
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
- if (legacyToolingFiles.length === 0) checks.push(createCheck({
1535
- id: "tooling-imports",
1536
- title: "tooling imports",
1537
- status: "pass",
1538
- detail: "tooling 配置未引用本地源码仓库 loader 或旧 @icebreakers/*-config wrapper。"
1539
- }));
1540
- else checks.push(createCheck({
1541
- id: "tooling-imports",
1542
- title: "tooling imports",
1543
- status: "warn",
1544
- detail: `以下配置引用了旧 tooling 入口:${legacyToolingFiles.join(", ")}。`,
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: "monorepo-template",
1849
+ name: "repoctl-workspace",
1837
1850
  type: "module",
1838
1851
  version: "0.0.0",
1839
1852
  "private": true,
1840
- packageManager: "pnpm@11.21.0",
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/monorepo-template.git"
1859
+ "url": "git+https://github.com/sonofmagic/repoctl.git"
1845
1860
  },
1846
- bugs: { "url": "https://github.com/sonofmagic/monorepo-template/issues" },
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(`未知的 init tooling 目标: ${unknown.join(", ")}`);
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(`未找到 package.json,无法初始化 tooling: ${pkgJsonPath}`);
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(`skip existing init target: ${preset.filepath}`);
2070
+ logger.info(localize(`Skipped existing init target: ${preset.filepath}`, `跳过已存在的初始化目标:${preset.filepath}`));
2049
2071
  continue;
2050
2072
  }
2051
2073
  const content = await preset.getContent({
@@ -3478,27 +3500,27 @@ async function checkTemplates(options = {}) {
3478
3500
  checks.push(sourceDuplicates.length ? {
3479
3501
  id: "unique-source",
3480
3502
  status: "fail",
3481
- title: "模板 source 唯一性",
3482
- detail: `存在重复 source:${sourceDuplicates.map(([value, first, second]) => `${value} (${first}, ${second})`).join(", ")}`,
3483
- 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。")
3484
3506
  } : {
3485
3507
  id: "unique-source",
3486
3508
  status: "pass",
3487
- title: "模板 source 唯一性",
3488
- detail: "所有模板 source 都是唯一的。"
3509
+ title: localize("Template source uniqueness", "模板 source 唯一性"),
3510
+ detail: localize("Every template source is unique.", "所有模板 source 都是唯一的。")
3489
3511
  });
3490
3512
  const targetDuplicates = checkDuplicates(choices, "target");
3491
3513
  checks.push(targetDuplicates.length ? {
3492
3514
  id: "unique-target",
3493
3515
  status: "fail",
3494
- title: "模板 target 唯一性",
3495
- detail: `存在重复 target:${targetDuplicates.map(([value, first, second]) => `${value} (${first}, ${second})`).join(", ")}`,
3496
- 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,避免多个模板默认写入同一目标目录。")
3497
3519
  } : {
3498
3520
  id: "unique-target",
3499
3521
  status: "pass",
3500
- title: "模板 target 唯一性",
3501
- detail: "所有模板 target 都是唯一的。"
3522
+ title: localize("Template target uniqueness", "模板 target 唯一性"),
3523
+ detail: localize("Every template target is unique.", "所有模板 target 都是唯一的。")
3502
3524
  });
3503
3525
  for (const choice of choices) {
3504
3526
  const sourceDir = path.join(templatesDir$1, choice.source);
@@ -3508,43 +3530,43 @@ async function checkTemplates(options = {}) {
3508
3530
  id: "source-dir",
3509
3531
  template: choice.key,
3510
3532
  status: "pass",
3511
- title: "模板目录",
3512
- 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)}`)
3513
3535
  } : {
3514
3536
  id: "source-dir",
3515
3537
  template: choice.key,
3516
3538
  status: "fail",
3517
- title: "模板目录",
3518
- detail: `${choice.key} 缺少 source 目录:${sourceDir}`,
3519
- 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。")
3520
3542
  });
3521
3543
  checks.push(await fs$1.pathExists(packageJsonPath) ? {
3522
3544
  id: "package-json",
3523
3545
  template: choice.key,
3524
3546
  status: "pass",
3525
- title: "模板 package.json",
3526
- 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。`)
3527
3549
  } : {
3528
3550
  id: "package-json",
3529
3551
  template: choice.key,
3530
3552
  status: "fail",
3531
- title: "模板 package.json",
3532
- detail: `${choice.key} 缺少 package.json。`,
3533
- 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。")
3534
3556
  });
3535
3557
  checks.push(choice.category && choice.description ? {
3536
3558
  id: "metadata",
3537
3559
  template: choice.key,
3538
3560
  status: "pass",
3539
- title: "模板元数据",
3540
- detail: `${choice.key} 已声明 category 和 description。`
3561
+ title: localize("Template metadata", "模板元数据"),
3562
+ detail: localize(`${choice.key} declares category and description.`, `${choice.key} 已声明 category 和 description。`)
3541
3563
  } : {
3542
3564
  id: "metadata",
3543
3565
  template: choice.key,
3544
3566
  status: "warn",
3545
- title: "模板元数据",
3546
- detail: `${choice.key} 缺少 category 或 description。`,
3547
- 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 和文档展示。")
3548
3570
  });
3549
3571
  if (!sourceExists) continue;
3550
3572
  const skippedFiles = (await collectFiles(sourceDir)).filter((file) => shouldSkipTemplatePath(sourceDir, file)).map((file) => path.relative(sourceDir, file));
@@ -3552,15 +3574,15 @@ async function checkTemplates(options = {}) {
3552
3574
  id: "filtered-files",
3553
3575
  template: choice.key,
3554
3576
  status: "fail",
3555
- title: "模板临时文件",
3556
- detail: `${choice.key} 包含会被脚手架过滤的文件:${skippedFiles.join(", ")}`,
3557
- 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.", "删除模板源目录里的临时、缓存或生成文件。")
3558
3580
  } : {
3559
3581
  id: "filtered-files",
3560
3582
  template: choice.key,
3561
3583
  status: "pass",
3562
- title: "模板临时文件",
3563
- detail: `${choice.key} 没有检测到会被过滤的临时文件。`
3584
+ title: localize("Temporary template files", "模板临时文件"),
3585
+ detail: localize(`${choice.key} contains no filtered temporary files.`, `${choice.key} 没有检测到会被过滤的临时文件。`)
3564
3586
  });
3565
3587
  }
3566
3588
  return {
@@ -3722,7 +3744,7 @@ async function scheduleOverwrite(intent, options) {
3722
3744
  async function flushPendingOverwrites(pending, options = {}) {
3723
3745
  if (!pending.length) return;
3724
3746
  if (options.noOverwrite) {
3725
- for (const item of pending) logger.info(`skip changed file: ${item.relPath}`);
3747
+ for (const item of pending) logger.info(localize(`Skipped changed file: ${item.relPath}`, `跳过已变更文件:${item.relPath}`));
3726
3748
  return;
3727
3749
  }
3728
3750
  if (options.yes || options.overwrite) {
@@ -3730,11 +3752,11 @@ async function flushPendingOverwrites(pending, options = {}) {
3730
3752
  return;
3731
3753
  }
3732
3754
  if (!process.stdin.isTTY || !process.stdout.isTTY) {
3733
- for (const item of pending) logger.info(`skip changed file in non-interactive mode: ${item.relPath}`);
3755
+ for (const item of pending) logger.info(localize(`Skipped changed file in non-interactive mode: ${item.relPath}`, `非交互模式下跳过已变更文件:${item.relPath}`));
3734
3756
  return;
3735
3757
  }
3736
3758
  const selected = await checkbox({
3737
- message: "检测到以下文件内容与当前仓库不同,选择需要覆盖的文件",
3759
+ message: localize("Select changed managed files to overwrite", "检测到以下文件内容与当前仓库不同,请选择要覆盖的文件"),
3738
3760
  choices: pending.map((item) => ({
3739
3761
  name: pc.greenBright(item.relPath),
3740
3762
  value: item.targetPath,
@@ -3831,6 +3853,38 @@ function setPkgJson(sourcePkgJson, targetPkgJson, options) {
3831
3853
  }
3832
3854
  }
3833
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
3834
3888
  //#region src/commands/upgrade/workspace.ts
3835
3889
  function isPlainObject(value) {
3836
3890
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -3887,36 +3941,6 @@ function mergeWorkspaceManifest(source, target) {
3887
3941
  }
3888
3942
  //#endregion
3889
3943
  //#region src/commands/upgrade/index.ts
3890
- const crlfPattern = /\r\n/g;
3891
- function normalizeEol(input) {
3892
- return input.replace(crlfPattern, "\n");
3893
- }
3894
- function normalizeGitignoreLine(line) {
3895
- const trimmed = line.trim();
3896
- if (!trimmed) return "";
3897
- if (trimmed.startsWith("#")) return `#${trimmed.slice(1).trim()}`;
3898
- return trimmed;
3899
- }
3900
- function isTextEquivalent(left, right) {
3901
- return normalizeEol(left).trimEnd() === normalizeEol(right).trimEnd();
3902
- }
3903
- function mergeGitignore(source, target) {
3904
- const sourceLines = normalizeEol(source).split("\n");
3905
- const result = normalizeEol(target).split("\n");
3906
- const seen = new Set(result.map((line) => normalizeGitignoreLine(line)).filter(Boolean));
3907
- for (const line of sourceLines) {
3908
- const normalized = normalizeGitignoreLine(line);
3909
- if (!normalized || seen.has(normalized)) continue;
3910
- seen.add(normalized);
3911
- result.push(line);
3912
- }
3913
- while (result.length) {
3914
- const last = result.at(-1);
3915
- if (last === void 0 || last.trim().length > 0) break;
3916
- result.pop();
3917
- }
3918
- return `${result.join("\n")}\n`;
3919
- }
3920
3944
  /**
3921
3945
  * 将 assets 目录的模版文件同步到工程中,实现一键升级脚手架能力。
3922
3946
  */
@@ -3939,9 +3963,9 @@ async function upgradeMonorepo(opts) {
3939
3963
  const configTargets = upgradeConfig?.targets ?? [];
3940
3964
  const mergeTargets = upgradeConfig?.mergeTargets;
3941
3965
  let targets = configTargets.length ? mergeTargets === false ? [...configTargets] : [.../* @__PURE__ */ new Set([...baseTargets, ...configTargets])] : baseTargets;
3942
- if (merged.interactive) if (!process.stdin.isTTY || !process.stdout.isTTY) logger.info("skip interactive target selection in non-interactive mode");
3966
+ if (merged.interactive) if (!process.stdin.isTTY || !process.stdout.isTTY) logger.info(localize("Skipped interactive target selection in non-interactive mode.", "非交互模式下跳过交互式目标选择。"));
3943
3967
  else targets = await checkbox({
3944
- message: "选择你需要的文件",
3968
+ message: localize("Select the files you need", "选择你需要的文件"),
3945
3969
  choices: targets.map((x) => {
3946
3970
  return {
3947
3971
  value: x,
@@ -3971,7 +3995,7 @@ async function upgradeMonorepo(opts) {
3971
3995
  const targetPath = path.resolve(absOutDir, relPath);
3972
3996
  if (relPath === ".github/workflows/release.yml" && await fs$1.pathExists(targetPath)) {
3973
3997
  if (await classifyReleaseWorkflow(absOutDir) === "custom" && !merged.overwriteRelease) {
3974
- logger.warn("skip custom release workflow; use repo upgrade --overwrite-release to replace it");
3998
+ logger.warn(localize("Skipped custom release workflow; use repo upgrade --overwrite-release to replace it.", "已跳过自定义发布工作流;如需替换,请使用 repo upgrade --overwrite-release。"));
3975
3999
  continue;
3976
4000
  }
3977
4001
  }