@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.
- package/README.md +16 -209
- package/README.zh-CN.md +23 -0
- package/dist/cli.mjs +219 -209
- package/dist/{commands-DwvtvWjz.mjs → commands-BqUFCJA_.mjs} +356 -332
- package/dist/{create-flow-D-_VjRtz.mjs → create-flow-BE4Nd902.mjs} +32 -32
- package/dist/{index-cBqxgIwY.d.mts → index-B0fwhqup.d.mts} +2 -2
- package/dist/index.d.mts +8 -3
- package/dist/index.mjs +3 -3
- 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-CLzhRYdV.mjs +0 -215
package/dist/cli.mjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { d as logger,
|
|
1
|
+
import { d as localize, f as message, m as logger, p as supportedLocales, r as cliName, t as initToolingTargets, u as version, y as fs } from "./types-BS9l6MOk.mjs";
|
|
2
2
|
import path from "pathe";
|
|
3
3
|
import process from "node:process";
|
|
4
|
+
import path$1 from "node:path";
|
|
4
5
|
import os from "node:os";
|
|
5
6
|
import pc from "picocolors";
|
|
6
|
-
import { Command } from "commander";
|
|
7
|
+
import { Command, Option } from "commander";
|
|
7
8
|
//#region src/cli/commands/ai.ts
|
|
8
9
|
async function handleAiPromptCreate(cwd, opts) {
|
|
9
10
|
const [{ input }, { createTimestampFolderName, defaultAgenticBaseDir, generateAgenticTemplate, generateAgenticTemplates, loadAgenticTasks }, { resolveCommandConfig }] = await Promise.all([
|
|
10
11
|
import("@icebreakers/monorepo-templates"),
|
|
11
|
-
import("./commands-
|
|
12
|
+
import("./commands-BqUFCJA_.mjs").then((n) => n.t),
|
|
12
13
|
import("./config-p842Knhq.mjs").then((n) => n.n)
|
|
13
14
|
]);
|
|
14
15
|
const aiConfig = await resolveCommandConfig("ai", cwd);
|
|
@@ -19,7 +20,7 @@ async function handleAiPromptCreate(cwd, opts) {
|
|
|
19
20
|
const tasksFile = opts.tasks ?? aiConfig?.tasksFile;
|
|
20
21
|
const templateName = opts.name;
|
|
21
22
|
if (Boolean(tasksFile && !opts.output && !opts.name)) {
|
|
22
|
-
if (!tasksFile) throw new Error("tasks file path is required when using tasks mode");
|
|
23
|
+
if (!tasksFile) throw new Error(localize("A tasks file path is required when using tasks mode.", "使用 tasks 模式时必须提供任务文件路径。"));
|
|
23
24
|
await generateAgenticTemplates(await loadAgenticTasks(tasksFile, cwd), {
|
|
24
25
|
cwd,
|
|
25
26
|
baseDir,
|
|
@@ -32,7 +33,7 @@ async function handleAiPromptCreate(cwd, opts) {
|
|
|
32
33
|
if (!output && !templateName) {
|
|
33
34
|
const generated = createTimestampFolderName();
|
|
34
35
|
folderName = ((await input({
|
|
35
|
-
message: "提示词将写入哪个文件夹?(可回车确认或自定义)",
|
|
36
|
+
message: localize("Which folder should contain the prompt?", "提示词将写入哪个文件夹?(可回车确认或自定义)"),
|
|
36
37
|
default: generated
|
|
37
38
|
}))?.trim?.() ?? generated) || generated;
|
|
38
39
|
}
|
|
@@ -48,7 +49,7 @@ async function handleAiPromptCreate(cwd, opts) {
|
|
|
48
49
|
await generateAgenticTemplate(templateOptions);
|
|
49
50
|
}
|
|
50
51
|
function registerAiCommands(program, cwd) {
|
|
51
|
-
program.command("ai").description("AI 助手工具集").command("prompt").alias("p").description("Prompt 模板命令").command("create").alias("new").description("生成 Agentic 任务提示词模板").option("-o, --output <path>", "输出到指定文件").option("-f, --force", "允许覆盖已存在文件").option("--format <md|json>", "模板格式,默认 md").option("-d, --dir <path>", "默认输出目录(默认 agentic/prompts,下级自动创建时间文件夹),配合 --name / --tasks 使用").option("-n, --name <name>", "使用名称快速生成文件,自动添加后缀").option("-t, --tasks <file>", "从 JSON 数组批量生成模板").action(async (opts) => {
|
|
52
|
+
program.command("ai").description(localize("AI assistant commands", "AI 助手工具集")).command("prompt").alias("p").description(localize("Prompt template commands", "Prompt 模板命令")).command("create").alias("new").description(localize("Generate an agentic task prompt template", "生成 Agentic 任务提示词模板")).option("-o, --output <path>", localize("Write to a specific file", "输出到指定文件")).option("-f, --force", localize("Overwrite an existing file", "允许覆盖已存在文件")).option("--format <md|json>", localize("Template format; defaults to md", "模板格式,默认 md")).option("-d, --dir <path>", localize("Base output directory used with --name or --tasks", "默认输出目录(默认 agentic/prompts,下级自动创建时间文件夹),配合 --name / --tasks 使用")).option("-n, --name <name>", localize("Generate a named file with the correct extension", "使用名称快速生成文件,自动添加后缀")).option("-t, --tasks <file>", localize("Generate templates from a JSON task array", "从 JSON 数组批量生成模板")).action(async (opts) => {
|
|
52
53
|
await handleAiPromptCreate(cwd, opts);
|
|
53
54
|
});
|
|
54
55
|
}
|
|
@@ -58,16 +59,16 @@ function formatConfigInspection(inspection) {
|
|
|
58
59
|
const commandKeys = Object.keys(inspection.config.commands ?? {});
|
|
59
60
|
const toolingKeys = Object.keys(inspection.config.tooling ?? {});
|
|
60
61
|
return [
|
|
61
|
-
`cwd: ${inspection.cwd}`,
|
|
62
|
-
`file: ${inspection.file ?? "-"}`,
|
|
63
|
-
`commands: ${commandKeys.length > 0 ? commandKeys.join(", ") : "-"}`,
|
|
64
|
-
`tooling: ${toolingKeys.length > 0 ? toolingKeys.join(", ") : "-"}`
|
|
62
|
+
localize(`cwd: ${inspection.cwd}`, `当前目录:${inspection.cwd}`),
|
|
63
|
+
localize(`file: ${inspection.file ?? "-"}`, `文件:${inspection.file ?? "-"}`),
|
|
64
|
+
localize(`commands: ${commandKeys.length > 0 ? commandKeys.join(", ") : "-"}`, `命令:${commandKeys.length > 0 ? commandKeys.join(", ") : "-"}`),
|
|
65
|
+
localize(`tooling: ${toolingKeys.length > 0 ? toolingKeys.join(", ") : "-"}`, `Tooling:${toolingKeys.length > 0 ? toolingKeys.join(", ") : "-"}`)
|
|
65
66
|
].join("\n");
|
|
66
67
|
}
|
|
67
68
|
function formatMarkdownTable$5(rows) {
|
|
68
69
|
const formatCell = (value) => String(value ?? "-").split("|").join("\\|").split("\n").join("<br>");
|
|
69
70
|
return [
|
|
70
|
-
"| Field | Value |",
|
|
71
|
+
localize("| Field | Value |", "| 字段 | 值 |"),
|
|
71
72
|
"| --- | --- |",
|
|
72
73
|
...rows.map(([label, value]) => `| ${label} | ${formatCell(value)} |`)
|
|
73
74
|
].join("\n");
|
|
@@ -76,7 +77,7 @@ function formatConfigInspectionMarkdown(inspection) {
|
|
|
76
77
|
const commandKeys = Object.keys(inspection.config.commands ?? {});
|
|
77
78
|
const toolingKeys = Object.keys(inspection.config.tooling ?? {});
|
|
78
79
|
return [
|
|
79
|
-
"# Repo config inspection",
|
|
80
|
+
localize("# Repo config inspection", "# Repo 配置检查"),
|
|
80
81
|
"",
|
|
81
82
|
formatMarkdownTable$5([
|
|
82
83
|
["cwd", inspection.cwd],
|
|
@@ -85,11 +86,11 @@ function formatConfigInspectionMarkdown(inspection) {
|
|
|
85
86
|
["tooling", toolingKeys.length]
|
|
86
87
|
]),
|
|
87
88
|
"",
|
|
88
|
-
"## Commands",
|
|
89
|
+
localize("## Commands", "## 命令"),
|
|
89
90
|
"",
|
|
90
91
|
...commandKeys.length > 0 ? commandKeys.map((key) => `- ${key}`) : ["- -"],
|
|
91
92
|
"",
|
|
92
|
-
"## Tooling",
|
|
93
|
+
localize("## Tooling", "## Tooling 配置"),
|
|
93
94
|
"",
|
|
94
95
|
...toolingKeys.length > 0 ? toolingKeys.map((key) => `- ${key}`) : ["- -"]
|
|
95
96
|
].join("\n");
|
|
@@ -119,11 +120,11 @@ async function emitConfigInspection(inspection, opts, cwd) {
|
|
|
119
120
|
}
|
|
120
121
|
const outFile = path.resolve(cwd, opts.out);
|
|
121
122
|
await fs.outputFile(outFile, `${content}\n`, "utf8");
|
|
122
|
-
logger.success(`
|
|
123
|
+
logger.success(localize(`Wrote ${path.relative(cwd, outFile)}`, `已写入 ${path.relative(cwd, outFile)}`));
|
|
123
124
|
}
|
|
124
125
|
function registerConfigCommands(program, cwd) {
|
|
125
|
-
program.command("config").alias("cfg").description("配置命令").command("inspect").description("输出当前 repoctl 配置文件和已解析配置").alias("i").option("--json", "输出 JSON,方便脚本消费").option("--markdown", "输出 Markdown,方便粘贴到 issue 或 PR").option("--out <file>", "把当前输出写入文件").option("--redact", "脱敏 cwd/configDir/home 绝对路径后再输出").action(async (opts) => {
|
|
126
|
-
const { inspectMonorepoConfig } = await import("./commands-
|
|
126
|
+
program.command("config").alias("cfg").description(localize("Configuration commands", "配置命令")).command("inspect").description(localize("Show the active repoctl config file and resolved configuration", "输出当前 repoctl 配置文件和已解析配置")).alias("i").option("--json", localize("Output JSON for scripts", "输出 JSON,方便脚本消费")).option("--markdown", localize("Output Markdown", "输出 Markdown,方便粘贴到 issue 或 PR")).option("--out <file>", localize("Write output to a file", "把当前输出写入文件")).option("--redact", localize("Redact cwd, configDir, and home paths", "脱敏 cwd/configDir/home 绝对路径后再输出")).action(async (opts) => {
|
|
127
|
+
const { inspectMonorepoConfig } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
127
128
|
await emitConfigInspection(await inspectMonorepoConfig(cwd), opts, cwd);
|
|
128
129
|
});
|
|
129
130
|
}
|
|
@@ -132,7 +133,7 @@ function registerConfigCommands(program, cwd) {
|
|
|
132
133
|
function formatMarkdownTable$4(rows) {
|
|
133
134
|
const formatCell = (value) => String(value ?? "-").split("|").join("\\|").split("\n").join("<br>");
|
|
134
135
|
return [
|
|
135
|
-
"| Field | Value |",
|
|
136
|
+
localize("| Field | Value |", "| 字段 | 值 |"),
|
|
136
137
|
"| --- | --- |",
|
|
137
138
|
...rows.map(([label, value]) => `| ${label} | ${formatCell(value)} |`)
|
|
138
139
|
].join("\n");
|
|
@@ -150,7 +151,7 @@ function formatEnvInfo$1(info) {
|
|
|
150
151
|
}
|
|
151
152
|
function formatEnvInfoMarkdown(info) {
|
|
152
153
|
return [
|
|
153
|
-
"# Repo environment",
|
|
154
|
+
localize("# Repo environment", "# Repo 环境"),
|
|
154
155
|
"",
|
|
155
156
|
formatMarkdownTable$4([
|
|
156
157
|
["cwd", info.cwd],
|
|
@@ -164,7 +165,7 @@ function formatEnvInfoMarkdown(info) {
|
|
|
164
165
|
].join("\n");
|
|
165
166
|
}
|
|
166
167
|
function formatEnvPathEntry(label, entry) {
|
|
167
|
-
return `${label}: ${entry.relativePath} (${entry.exists ? "exists" : "missing"})
|
|
168
|
+
return localize(`${label}: ${entry.relativePath} (${entry.exists ? "exists" : "missing"})`, `${label}:${entry.relativePath}(${entry.exists ? "存在" : "缺失"})`);
|
|
168
169
|
}
|
|
169
170
|
function formatEnvPaths(paths) {
|
|
170
171
|
return [
|
|
@@ -185,15 +186,15 @@ function formatEnvPaths(paths) {
|
|
|
185
186
|
}
|
|
186
187
|
function formatEnvPathsMarkdown(paths) {
|
|
187
188
|
return [
|
|
188
|
-
"# Repo paths",
|
|
189
|
+
localize("# Repo paths", "# Repo 路径"),
|
|
189
190
|
"",
|
|
190
191
|
formatMarkdownTable$4([["cwd", paths.cwd], ["workspace", paths.workspaceDir]]),
|
|
191
192
|
"",
|
|
192
|
-
"## Files",
|
|
193
|
+
localize("## Files", "## 文件"),
|
|
193
194
|
"",
|
|
194
|
-
"| Path | Relative path | Status |",
|
|
195
|
+
localize("| Path | Relative path | Status |", "| 路径 | 相对路径 | 状态 |"),
|
|
195
196
|
"| --- | --- | --- |",
|
|
196
|
-
...Object.entries(paths.paths).flatMap(([label, value]) => Array.isArray(value) ? value.map((entry) => [label, entry]) : [[label, value]]).map(([label, entry]) => `| ${label} | ${entry.relativePath} | ${entry.exists ? "exists" : "missing"} |`)
|
|
197
|
+
...Object.entries(paths.paths).flatMap(([label, value]) => Array.isArray(value) ? value.map((entry) => [label, entry]) : [[label, value]]).map(([label, entry]) => `| ${label} | ${entry.relativePath} | ${entry.exists ? localize("exists", "存在") : localize("missing", "缺失")} |`)
|
|
197
198
|
].join("\n");
|
|
198
199
|
}
|
|
199
200
|
function formatEnvSnapshot(snapshot) {
|
|
@@ -210,11 +211,11 @@ function formatEnvSnapshot(snapshot) {
|
|
|
210
211
|
function formatEnvSnapshotMarkdown(snapshot) {
|
|
211
212
|
const warningsAndFailures = snapshot.doctor.checks.filter((check) => check.status !== "pass");
|
|
212
213
|
return [
|
|
213
|
-
"# Repo environment snapshot",
|
|
214
|
+
localize("# Repo environment snapshot", "# Repo 环境快照"),
|
|
214
215
|
"",
|
|
215
|
-
`Generated at: ${snapshot.generatedAt}`,
|
|
216
|
+
localize(`Generated at: ${snapshot.generatedAt}`, `生成时间:${snapshot.generatedAt}`),
|
|
216
217
|
"",
|
|
217
|
-
"## Environment",
|
|
218
|
+
localize("## Environment", "## 环境"),
|
|
218
219
|
"",
|
|
219
220
|
formatMarkdownTable$4([
|
|
220
221
|
["cwd", snapshot.env.cwd],
|
|
@@ -226,7 +227,7 @@ function formatEnvSnapshotMarkdown(snapshot) {
|
|
|
226
227
|
["platform", `${snapshot.env.platform}/${snapshot.env.arch}`]
|
|
227
228
|
]),
|
|
228
229
|
"",
|
|
229
|
-
"## Diagnostics",
|
|
230
|
+
localize("## Diagnostics", "## 诊断"),
|
|
230
231
|
"",
|
|
231
232
|
formatMarkdownTable$4([
|
|
232
233
|
["doctor pass", snapshot.doctor.summary.pass],
|
|
@@ -236,12 +237,12 @@ function formatEnvSnapshotMarkdown(snapshot) {
|
|
|
236
237
|
]),
|
|
237
238
|
"",
|
|
238
239
|
...warningsAndFailures.length > 0 ? [
|
|
239
|
-
"## Doctor findings",
|
|
240
|
+
localize("## Doctor findings", "## Doctor 问题"),
|
|
240
241
|
"",
|
|
241
|
-
...warningsAndFailures.map((check) => `- ${check.status}: ${check.title}${check.fix ? ` (fix: ${check.fix})` : ""}`),
|
|
242
|
+
...warningsAndFailures.map((check) => localize(`- ${check.status}: ${check.title}${check.fix ? ` (fix: ${check.fix})` : ""}`, `- ${check.status}: ${check.title}${check.fix ? `(修复:${check.fix})` : ""}`)),
|
|
242
243
|
""
|
|
243
244
|
] : [],
|
|
244
|
-
"## Check plan",
|
|
245
|
+
localize("## Check plan", "## 检查计划"),
|
|
245
246
|
"",
|
|
246
247
|
...snapshot.checkPlan.commands.map((command) => `- \`${command.command}\` - ${command.description}`)
|
|
247
248
|
].join("\n");
|
|
@@ -321,7 +322,7 @@ function formatEnvSupportBundle(bundle) {
|
|
|
321
322
|
function formatMarkdownTable$3(rows) {
|
|
322
323
|
const formatCell = (value) => String(value ?? "-").split("|").join("\\|").split("\n").join("<br>");
|
|
323
324
|
return [
|
|
324
|
-
"| Field | Value |",
|
|
325
|
+
localize("| Field | Value |", "| 字段 | 值 |"),
|
|
325
326
|
"| --- | --- |",
|
|
326
327
|
...rows.map(([label, value]) => `| ${label} | ${formatCell(value)} |`)
|
|
327
328
|
].join("\n");
|
|
@@ -329,11 +330,11 @@ function formatMarkdownTable$3(rows) {
|
|
|
329
330
|
function formatSupportBundleMarkdown(bundle) {
|
|
330
331
|
const warningsAndFailures = bundle.doctor.checks.filter((check) => check.status !== "pass");
|
|
331
332
|
return [
|
|
332
|
-
"# Repo support bundle",
|
|
333
|
+
localize("# Repo support bundle", "# Repo 支持信息包"),
|
|
333
334
|
"",
|
|
334
|
-
`Generated at: ${bundle.generatedAt}`,
|
|
335
|
+
localize(`Generated at: ${bundle.generatedAt}`, `生成时间:${bundle.generatedAt}`),
|
|
335
336
|
"",
|
|
336
|
-
"## Environment",
|
|
337
|
+
localize("## Environment", "## 环境"),
|
|
337
338
|
"",
|
|
338
339
|
formatMarkdownTable$3([
|
|
339
340
|
["cwd", bundle.env.cwd],
|
|
@@ -345,7 +346,7 @@ function formatSupportBundleMarkdown(bundle) {
|
|
|
345
346
|
["platform", `${bundle.env.platform}/${bundle.env.arch}`]
|
|
346
347
|
]),
|
|
347
348
|
"",
|
|
348
|
-
"## Diagnostics",
|
|
349
|
+
localize("## Diagnostics", "## 诊断"),
|
|
349
350
|
"",
|
|
350
351
|
formatMarkdownTable$3([
|
|
351
352
|
["doctor pass", bundle.doctor.summary.pass],
|
|
@@ -356,16 +357,16 @@ function formatSupportBundleMarkdown(bundle) {
|
|
|
356
357
|
]),
|
|
357
358
|
"",
|
|
358
359
|
...warningsAndFailures.length > 0 ? [
|
|
359
|
-
"## Doctor findings",
|
|
360
|
+
localize("## Doctor findings", "## Doctor 问题"),
|
|
360
361
|
"",
|
|
361
|
-
...warningsAndFailures.map((check) => `- ${check.status}: ${check.title}${check.fix ? ` (fix: ${check.fix})` : ""}`),
|
|
362
|
+
...warningsAndFailures.map((check) => localize(`- ${check.status}: ${check.title}${check.fix ? ` (fix: ${check.fix})` : ""}`, `- ${check.status}: ${check.title}${check.fix ? `(修复:${check.fix})` : ""}`)),
|
|
362
363
|
""
|
|
363
364
|
] : [],
|
|
364
|
-
"## Check plan",
|
|
365
|
+
localize("## Check plan", "## 检查计划"),
|
|
365
366
|
"",
|
|
366
367
|
...bundle.checkPlan.commands.map((command) => `- \`${command.command}\` - ${command.description}`),
|
|
367
368
|
"",
|
|
368
|
-
"## Report paths",
|
|
369
|
+
localize("## Report paths", "## 报告路径"),
|
|
369
370
|
"",
|
|
370
371
|
formatMarkdownTable$3([
|
|
371
372
|
["doctor", bundle.paths.paths.doctorReport.relativePath],
|
|
@@ -408,7 +409,7 @@ async function emitEnvInfo(info, opts, cwd) {
|
|
|
408
409
|
}
|
|
409
410
|
const outFile = path.resolve(cwd, opts.out);
|
|
410
411
|
await fs.outputFile(outFile, `${content}\n`, "utf8");
|
|
411
|
-
logger.success(`
|
|
412
|
+
logger.success(localize(`Wrote ${path.relative(cwd, outFile)}`, `已写入 ${path.relative(cwd, outFile)}`));
|
|
412
413
|
}
|
|
413
414
|
async function emitEnvPaths(paths, opts, cwd) {
|
|
414
415
|
const content = createEnvPathsOutput(paths, opts);
|
|
@@ -418,7 +419,7 @@ async function emitEnvPaths(paths, opts, cwd) {
|
|
|
418
419
|
}
|
|
419
420
|
const outFile = path.resolve(cwd, opts.out);
|
|
420
421
|
await fs.outputFile(outFile, `${content}\n`, "utf8");
|
|
421
|
-
logger.success(`
|
|
422
|
+
logger.success(localize(`Wrote ${path.relative(cwd, outFile)}`, `已写入 ${path.relative(cwd, outFile)}`));
|
|
422
423
|
}
|
|
423
424
|
async function emitEnvSnapshot(snapshot, opts, cwd) {
|
|
424
425
|
const content = createEnvSnapshotOutput(snapshot, opts);
|
|
@@ -426,7 +427,7 @@ async function emitEnvSnapshot(snapshot, opts, cwd) {
|
|
|
426
427
|
else {
|
|
427
428
|
const outFile = path.resolve(cwd, opts.out);
|
|
428
429
|
await fs.outputFile(outFile, `${content}\n`, "utf8");
|
|
429
|
-
logger.success(`
|
|
430
|
+
logger.success(localize(`Wrote ${path.relative(cwd, outFile)}`, `已写入 ${path.relative(cwd, outFile)}`));
|
|
430
431
|
}
|
|
431
432
|
if (opts.strict && hasStrictEnvSnapshotIssues(snapshot)) process.exitCode = 1;
|
|
432
433
|
}
|
|
@@ -436,39 +437,39 @@ async function emitEnvSupportBundle(bundle, opts, cwd) {
|
|
|
436
437
|
else {
|
|
437
438
|
const outFile = path.resolve(cwd, opts.out);
|
|
438
439
|
await fs.outputFile(outFile, `${content}\n`, "utf8");
|
|
439
|
-
logger.success(`
|
|
440
|
+
logger.success(localize(`Wrote ${path.relative(cwd, outFile)}`, `已写入 ${path.relative(cwd, outFile)}`));
|
|
440
441
|
}
|
|
441
442
|
if (opts.strict && hasStrictSupportBundleIssues(bundle)) process.exitCode = 1;
|
|
442
443
|
}
|
|
443
444
|
function registerEnvCommands(program, cwd) {
|
|
444
|
-
const envCommand = program.command("env").alias("e").description("环境命令");
|
|
445
|
-
envCommand.command("info").description("输出当前仓库环境信息").alias("i").option("--json", "输出 JSON,方便脚本消费").option("--markdown", "输出 Markdown,方便粘贴到 issue 或 PR").option("--out <file>", "把当前输出写入文件").option("--redact", "脱敏 workspace/cwd/home 绝对路径后再输出").action(async (opts) => {
|
|
446
|
-
const { collectEnvInfo } = await import("./commands-
|
|
445
|
+
const envCommand = program.command("env").alias("e").description(localize("Environment and support commands", "环境命令"));
|
|
446
|
+
envCommand.command("info").description(localize("Show environment information for the current repository", "输出当前仓库环境信息")).alias("i").option("--json", localize("Output JSON for scripts", "输出 JSON,方便脚本消费")).option("--markdown", localize("Output Markdown", "输出 Markdown,方便粘贴到 issue 或 PR")).option("--out <file>", localize("Write output to a file", "把当前输出写入文件")).option("--redact", localize("Redact workspace, cwd, and home paths", "脱敏 workspace/cwd/home 绝对路径后再输出")).action(async (opts) => {
|
|
447
|
+
const { collectEnvInfo } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
447
448
|
await emitEnvInfo(await collectEnvInfo(cwd), opts, cwd);
|
|
448
449
|
});
|
|
449
|
-
envCommand.command("snapshot").description("输出排障快照,包含环境、doctor 和 check 计划").alias("s").option("--json", "输出 JSON,方便脚本消费").option("--markdown", "输出 Markdown,方便粘贴到 issue 或 PR").option("--out <file>", "把当前输出写入文件").option("--redact", "脱敏 workspace/cwd/home 绝对路径后再输出").option("--strict", "输出快照后,如果 doctor 有 fail 或 warn 则返回失败码").action(async (opts) => {
|
|
450
|
-
const { collectEnvSnapshot } = await import("./commands-
|
|
450
|
+
envCommand.command("snapshot").description(localize("Create a support snapshot with environment, doctor, and check data", "输出排障快照,包含环境、doctor 和 check 计划")).alias("s").option("--json", localize("Output JSON for scripts", "输出 JSON,方便脚本消费")).option("--markdown", localize("Output Markdown", "输出 Markdown,方便粘贴到 issue 或 PR")).option("--out <file>", localize("Write output to a file", "把当前输出写入文件")).option("--redact", localize("Redact workspace, cwd, and home paths", "脱敏 workspace/cwd/home 绝对路径后再输出")).option("--strict", localize("Fail when doctor reports a failure or warning", "输出快照后,如果 doctor 有 fail 或 warn 则返回失败码")).action(async (opts) => {
|
|
451
|
+
const { collectEnvSnapshot } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
451
452
|
await emitEnvSnapshot(await collectEnvSnapshot(cwd), opts, cwd);
|
|
452
453
|
});
|
|
453
|
-
envCommand.command("paths").description("输出当前仓库关键路径和报告建议位置").alias("p").option("--json", "输出 JSON,方便脚本消费").option("--markdown", "输出 Markdown,方便粘贴到 issue 或 PR").option("--out <file>", "把当前输出写入文件").option("--redact", "脱敏 workspace/cwd/home 绝对路径后再输出").action(async (opts) => {
|
|
454
|
-
const { collectEnvPaths } = await import("./commands-
|
|
454
|
+
envCommand.command("paths").description(localize("Show important repository and report paths", "输出当前仓库关键路径和报告建议位置")).alias("p").option("--json", localize("Output JSON for scripts", "输出 JSON,方便脚本消费")).option("--markdown", localize("Output Markdown", "输出 Markdown,方便粘贴到 issue 或 PR")).option("--out <file>", localize("Write output to a file", "把当前输出写入文件")).option("--redact", localize("Redact workspace, cwd, and home paths", "脱敏 workspace/cwd/home 绝对路径后再输出")).action(async (opts) => {
|
|
455
|
+
const { collectEnvPaths } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
455
456
|
await emitEnvPaths(await collectEnvPaths(cwd), opts, cwd);
|
|
456
457
|
});
|
|
457
|
-
envCommand.command("support").description("输出完整排障包,包含环境、路径、配置、doctor 和 check 计划").alias("b").option("--json", "输出 JSON,方便脚本消费").option("--markdown", "输出 Markdown,方便粘贴到 issue 或 PR").option("--out <file>", "把当前输出写入文件").option("--redact", "脱敏 workspace/cwd/home 绝对路径后再输出").option("--strict", "输出排障包后,如果 doctor 有 fail 或 warn 则返回失败码").action(async (opts) => {
|
|
458
|
-
const { collectEnvSupportBundle } = await import("./commands-
|
|
458
|
+
envCommand.command("support").description(localize("Create a complete support bundle", "输出完整排障包,包含环境、路径、配置、doctor 和 check 计划")).alias("b").option("--json", localize("Output JSON for scripts", "输出 JSON,方便脚本消费")).option("--markdown", localize("Output Markdown", "输出 Markdown,方便粘贴到 issue 或 PR")).option("--out <file>", localize("Write output to a file", "把当前输出写入文件")).option("--redact", localize("Redact workspace, cwd, and home paths", "脱敏 workspace/cwd/home 绝对路径后再输出")).option("--strict", localize("Fail when doctor reports a failure or warning", "输出排障包后,如果 doctor 有 fail 或 warn 则返回失败码")).action(async (opts) => {
|
|
459
|
+
const { collectEnvSupportBundle } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
459
460
|
await emitEnvSupportBundle(await collectEnvSupportBundle(cwd), opts, cwd);
|
|
460
461
|
});
|
|
461
|
-
envCommand.command("mirror").description("设置 VS Code binary mirror").alias("m").action(async () => {
|
|
462
|
-
const { setVscodeBinaryMirror } = await import("./commands-
|
|
462
|
+
envCommand.command("mirror").description(localize("Configure the VS Code binary mirror", "设置 VS Code binary mirror")).alias("m").action(async () => {
|
|
463
|
+
const { setVscodeBinaryMirror } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
463
464
|
await setVscodeBinaryMirror(cwd);
|
|
464
|
-
logger.success("
|
|
465
|
+
logger.success(localize("Environment mirror finished.", "环境镜像完成。"));
|
|
465
466
|
});
|
|
466
467
|
}
|
|
467
468
|
//#endregion
|
|
468
469
|
//#region src/cli/commands/package.ts
|
|
469
470
|
function registerPackageCommands(program, cwd) {
|
|
470
|
-
program.command("package").alias("pkg").description("子包命令").command("create").description("创建一个新的子包").alias("new").argument("[name]").option("-t, --template <template>", "直接使用指定模板,跳过模板选择").option("--dry-run", "预览将要创建的目录与 package 信息,不写入文件").option("--json", "以 JSON 输出创建预览,隐含 --dry-run").option("--out <file>", "把创建预览写入文件,隐含 --dry-run").action(async (inputName, opts) => {
|
|
471
|
-
const { runCreateFlow } = await import("./create-flow-
|
|
471
|
+
program.command("package").alias("pkg").description(localize("Package commands", "子包命令")).command("create").description(localize("Create a new workspace package", "创建一个新的子包")).alias("new").argument("[name]").option("-t, --template <template>", localize("Use a template key without prompting", "直接使用指定模板,跳过模板选择")).option("--dry-run", localize("Preview without writing files", "预览将要创建的目录与 package 信息,不写入文件")).option("--json", localize("Output JSON; implies --dry-run", "以 JSON 输出创建预览,隐含 --dry-run")).option("--out <file>", localize("Write the preview to a file; implies --dry-run", "把创建预览写入文件,隐含 --dry-run")).action(async (inputName, opts) => {
|
|
472
|
+
const { runCreateFlow } = await import("./create-flow-BE4Nd902.mjs");
|
|
472
473
|
const result = await runCreateFlow(cwd, inputName, {
|
|
473
474
|
...opts.template !== void 0 ? { template: opts.template } : {},
|
|
474
475
|
...opts.dryRun || opts.json || opts.out ? { dryRun: true } : {},
|
|
@@ -476,7 +477,7 @@ function registerPackageCommands(program, cwd) {
|
|
|
476
477
|
...opts.out !== void 0 ? { out: opts.out } : {}
|
|
477
478
|
});
|
|
478
479
|
if (result.dryRun || result.failed) return;
|
|
479
|
-
logger.success("
|
|
480
|
+
logger.success(localize("Package creation finished.", "包创建完成。"));
|
|
480
481
|
});
|
|
481
482
|
}
|
|
482
483
|
//#endregion
|
|
@@ -490,71 +491,72 @@ async function runReleaseAction(action) {
|
|
|
490
491
|
}
|
|
491
492
|
}
|
|
492
493
|
function registerReleaseCommands(program, cwd) {
|
|
493
|
-
const releaseCommand = program.command("release").description("发布与 pnpm versioning 工具集");
|
|
494
|
-
releaseCommand.command("ci").description("在 CI 中自动准备、发布和恢复版本").option("--mode <mode>", "auto / prepare / publish / publish-unpublished", "auto").option("--package <name>", "publish-unpublished 使用的 package").option("--version <version>", "publish-unpublished 使用的版本").action(async (opts) => {
|
|
494
|
+
const releaseCommand = program.command("release").description(localize("Release and pnpm versioning commands", "发布与 pnpm versioning 工具集"));
|
|
495
|
+
releaseCommand.command("ci").description(localize("Prepare, publish, or recover versions in CI", "在 CI 中自动准备、发布和恢复版本")).option("--mode <mode>", localize("auto / prepare / publish / publish-unpublished", "auto / prepare / publish / publish-unpublished"), "auto").option("--package <name>", localize("Package used by publish-unpublished mode", "publish-unpublished 使用的 package")).option("--version <version>", localize("Version used by publish-unpublished mode", "publish-unpublished 使用的版本")).action(async (opts) => {
|
|
495
496
|
await runReleaseAction(async () => {
|
|
496
|
-
const { releaseCi } = await import("./commands-
|
|
497
|
+
const { releaseCi } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
497
498
|
await releaseCi({
|
|
498
499
|
cwd,
|
|
499
500
|
...opts.mode ? { mode: opts.mode } : {},
|
|
500
501
|
...opts.package ? { packageName: opts.package } : {},
|
|
501
502
|
...opts.version ? { packageVersion: opts.version } : {}
|
|
502
503
|
});
|
|
504
|
+
logger.success(localize("Release CI finished.", "Release CI 完成。"));
|
|
503
505
|
});
|
|
504
506
|
});
|
|
505
|
-
releaseCommand.command("notes").description("维护 GitHub Release 正文").command("repair").description("按每个发布 tag 对应的 changelog 重建 GitHub Release 正文").option("--all", "修复所有可识别的 GitHub Release").option("--tag <package@version>", "只修复指定 package@version").option("--dry-run", "只生成并统计,不更新 GitHub Release").action(async (opts) => {
|
|
507
|
+
releaseCommand.command("notes").description(localize("Manage GitHub Release notes", "维护 GitHub Release 正文")).command("repair").description(localize("Rebuild GitHub Release notes from the changelog for each release tag", "按每个发布 tag 对应的 changelog 重建 GitHub Release 正文")).option("--all", localize("Repair every recognized GitHub Release", "修复所有可识别的 GitHub Release")).option("--tag <package@version>", localize("Repair only the specified package@version", "只修复指定 package@version")).option("--dry-run", localize("Generate and summarize without updating GitHub Releases", "只生成并统计,不更新 GitHub Release")).action(async (opts) => {
|
|
506
508
|
await runReleaseAction(async () => {
|
|
507
|
-
const { repairReleaseNotes } = await import("./commands-
|
|
509
|
+
const { repairReleaseNotes } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
508
510
|
const result = await repairReleaseNotes({
|
|
509
511
|
cwd,
|
|
510
512
|
...opts.all ? { all: true } : {},
|
|
511
513
|
...opts.tag ? { tag: opts.tag } : {},
|
|
512
514
|
...opts.dryRun ? { dryRun: true } : {}
|
|
513
515
|
});
|
|
514
|
-
logger.success(`
|
|
516
|
+
logger.success(localize(`Release notes repaired: ${result.repaired.length}; skipped: ${result.skipped.length}`, `Release 正文已修复:${result.repaired.length};已跳过:${result.skipped.length}`));
|
|
515
517
|
});
|
|
516
518
|
});
|
|
517
|
-
const stableCommand = releaseCommand.command("stable").description("在 main 分支执行正式发布").action(async () => {
|
|
519
|
+
const stableCommand = releaseCommand.command("stable").description(localize("Run a stable release from main", "在 main 分支执行正式发布")).action(async () => {
|
|
518
520
|
await runReleaseAction(async () => {
|
|
519
|
-
const { releaseStable } = await import("./commands-
|
|
521
|
+
const { releaseStable } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
520
522
|
await releaseStable({ cwd });
|
|
521
|
-
logger.success("
|
|
523
|
+
logger.success(localize("Stable release finished.", "稳定版发布完成。"));
|
|
522
524
|
});
|
|
523
525
|
});
|
|
524
|
-
stableCommand.command("prepare").description("消费 pnpm change intents 并准备 Release PR").action(async () => {
|
|
526
|
+
stableCommand.command("prepare").description(localize("Consume pnpm change intents and prepare a Release PR", "消费 pnpm change intents 并准备 Release PR")).action(async () => {
|
|
525
527
|
await runReleaseAction(async () => {
|
|
526
|
-
const { prepareStable } = await import("./commands-
|
|
528
|
+
const { prepareStable } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
527
529
|
await prepareStable({ cwd });
|
|
528
|
-
logger.success("
|
|
530
|
+
logger.success(localize("Stable release preparation finished.", "稳定版发布准备完成。"));
|
|
529
531
|
});
|
|
530
532
|
});
|
|
531
|
-
stableCommand.command("publish").description("发布 main 分支上尚未发布的包").action(async () => {
|
|
533
|
+
stableCommand.command("publish").description(localize("Publish versions on main that are not yet on npm", "发布 main 分支上尚未发布的包")).action(async () => {
|
|
532
534
|
await runReleaseAction(async () => {
|
|
533
|
-
const { publishStable } = await import("./commands-
|
|
535
|
+
const { publishStable } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
534
536
|
await publishStable({ cwd });
|
|
535
|
-
logger.success("
|
|
537
|
+
logger.success(localize("Stable package publish finished.", "稳定版包发布完成。"));
|
|
536
538
|
});
|
|
537
539
|
});
|
|
538
|
-
const preCommand = releaseCommand.command("pre").description("执行或管理 prerelease 发布");
|
|
539
|
-
preCommand.command("publish").alias("run").description("在 alpha/beta/rc/next 分支发布 prerelease").action(async () => {
|
|
540
|
+
const preCommand = releaseCommand.command("pre").description(localize("Run or manage prereleases", "执行或管理 prerelease 发布"));
|
|
541
|
+
preCommand.command("publish").alias("run").description(localize("Publish a prerelease from an alpha, beta, rc, or next lane", "在 alpha/beta/rc/next 分支发布 prerelease")).action(async () => {
|
|
540
542
|
await runReleaseAction(async () => {
|
|
541
|
-
const { releasePrerelease } = await import("./commands-
|
|
543
|
+
const { releasePrerelease } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
542
544
|
await releasePrerelease({ cwd });
|
|
543
|
-
logger.success("
|
|
545
|
+
logger.success(localize("Prerelease finished.", "预发布完成。"));
|
|
544
546
|
});
|
|
545
547
|
});
|
|
546
|
-
preCommand.command("enter").description("进入 pnpm prerelease lane").argument("<tag>", "alpha / beta / rc / next").action(async (tag) => {
|
|
548
|
+
preCommand.command("enter").description(localize("Enter a pnpm prerelease lane", "进入 pnpm prerelease lane")).argument("<tag>", localize("alpha / beta / rc / next", "alpha / beta / rc / next")).action(async (tag) => {
|
|
547
549
|
await runReleaseAction(async () => {
|
|
548
|
-
const { enterPrerelease } = await import("./commands-
|
|
550
|
+
const { enterPrerelease } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
549
551
|
await enterPrerelease(tag, { cwd });
|
|
550
|
-
logger.success(`
|
|
552
|
+
logger.success(localize(`Entered ${tag} prerelease mode.`, `已进入 ${tag} 预发布模式。`));
|
|
551
553
|
});
|
|
552
554
|
});
|
|
553
|
-
preCommand.command("exit").description("退出 pnpm prerelease lane").action(async () => {
|
|
555
|
+
preCommand.command("exit").description(localize("Exit the pnpm prerelease lane", "退出 pnpm prerelease lane")).action(async () => {
|
|
554
556
|
await runReleaseAction(async () => {
|
|
555
|
-
const { exitPrerelease } = await import("./commands-
|
|
557
|
+
const { exitPrerelease } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
556
558
|
await exitPrerelease({ cwd });
|
|
557
|
-
logger.success("
|
|
559
|
+
logger.success(localize("Exited prerelease mode.", "已退出预发布模式。"));
|
|
558
560
|
});
|
|
559
561
|
});
|
|
560
562
|
}
|
|
@@ -562,8 +564,8 @@ function registerReleaseCommands(program, cwd) {
|
|
|
562
564
|
//#region src/cli/commands/skills.ts
|
|
563
565
|
const skillTargets = ["codex", "claude"];
|
|
564
566
|
function registerSkillsCommands(program, cwd) {
|
|
565
|
-
program.command("skills").alias("sk").description("技能工具集").command("sync").description("同步 resources/skills/icebreakers-monorepo-cli 到全局目录").alias("s").option("--codex", "同步到 ~/.codex/skills").option("--claude", "同步到 ~/.claude/skills").option("--all", "同步全部目标").action(async (opts) => {
|
|
566
|
-
const { syncSkills } = await import("./commands-
|
|
567
|
+
program.command("skills").alias("sk").description(localize("AI skill commands", "技能工具集")).command("sync").description(localize("Synchronize the repoctl skill to global agent directories", "同步 resources/skills/icebreakers-monorepo-cli 到全局目录")).alias("s").option("--codex", localize("Synchronize to ~/.codex/skills", "同步到 ~/.codex/skills")).option("--claude", localize("Synchronize to ~/.claude/skills", "同步到 ~/.claude/skills")).option("--all", localize("Synchronize every target", "同步全部目标")).action(async (opts) => {
|
|
568
|
+
const { syncSkills } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
567
569
|
const selected = /* @__PURE__ */ new Set();
|
|
568
570
|
if (opts.all) for (const target of skillTargets) selected.add(target);
|
|
569
571
|
else {
|
|
@@ -575,11 +577,11 @@ function registerSkillsCommands(program, cwd) {
|
|
|
575
577
|
targets: [...selected]
|
|
576
578
|
} : { cwd });
|
|
577
579
|
if (!results.length) {
|
|
578
|
-
logger.info("未选择任何目标,已跳过同步。");
|
|
580
|
+
logger.info(localize("No target selected; synchronization skipped.", "未选择任何目标,已跳过同步。"));
|
|
579
581
|
return;
|
|
580
582
|
}
|
|
581
|
-
logger.info(
|
|
582
|
-
logger.success("
|
|
583
|
+
logger.info(`${localize("[synchronized targets]", "[已同步的目标]")}:\n${results.map((item) => `- ${item.target}: ${item.dest}`).join("\n")}\n`);
|
|
584
|
+
logger.success(localize("Skill synchronization finished.", "Skill 同步完成。"));
|
|
583
585
|
});
|
|
584
586
|
}
|
|
585
587
|
//#endregion
|
|
@@ -593,9 +595,9 @@ function formatTemplateTable(choices) {
|
|
|
593
595
|
}));
|
|
594
596
|
const headers = {
|
|
595
597
|
key: "key",
|
|
596
|
-
category: "category",
|
|
597
|
-
target: "target",
|
|
598
|
-
description: "description"
|
|
598
|
+
category: localize("category", "分类"),
|
|
599
|
+
target: localize("target", "目标"),
|
|
600
|
+
description: localize("description", "说明")
|
|
599
601
|
};
|
|
600
602
|
const widths = {
|
|
601
603
|
key: Math.max(headers.key.length, ...rows.map((row) => row.key.length)),
|
|
@@ -611,11 +613,11 @@ function formatTemplateTable(choices) {
|
|
|
611
613
|
function formatTemplateDetail(choice) {
|
|
612
614
|
return [
|
|
613
615
|
`key: ${choice.key}`,
|
|
614
|
-
`label: ${choice.label}`,
|
|
615
|
-
`category: ${choice.category ?? "-"}`,
|
|
616
|
-
`source: templates/${choice.source}`,
|
|
617
|
-
`default target: ${choice.target}`,
|
|
618
|
-
`description: ${choice.description ?? "-"}`
|
|
616
|
+
localize(`label: ${choice.label}`, `标签:${choice.label}`),
|
|
617
|
+
localize(`category: ${choice.category ?? "-"}`, `分类:${choice.category ?? "-"}`),
|
|
618
|
+
localize(`source: templates/${choice.source}`, `源目录:templates/${choice.source}`),
|
|
619
|
+
localize(`default target: ${choice.target}`, `默认目标:${choice.target}`),
|
|
620
|
+
localize(`description: ${choice.description ?? "-"}`, `说明:${choice.description ?? "-"}`)
|
|
619
621
|
].join("\n");
|
|
620
622
|
}
|
|
621
623
|
function escapeMarkdownTableCell(value) {
|
|
@@ -623,7 +625,7 @@ function escapeMarkdownTableCell(value) {
|
|
|
623
625
|
}
|
|
624
626
|
function formatTemplateMarkdownTable(choices) {
|
|
625
627
|
return [
|
|
626
|
-
"| Key | Category | Source | Default target | Description |",
|
|
628
|
+
localize("| Key | Category | Source | Default target | Description |", "| Key | 分类 | 源目录 | 默认目标 | 说明 |"),
|
|
627
629
|
"| --- | --- | --- | --- | --- |",
|
|
628
630
|
...choices.map((choice) => [
|
|
629
631
|
`\`${choice.key}\``,
|
|
@@ -640,12 +642,12 @@ function formatTemplateMarkdownDetail(choice) {
|
|
|
640
642
|
"",
|
|
641
643
|
choice.description ?? "",
|
|
642
644
|
"",
|
|
643
|
-
"| Field | Value |",
|
|
645
|
+
localize("| Field | Value |", "| 字段 | 值 |"),
|
|
644
646
|
"| --- | --- |",
|
|
645
|
-
`| Label | ${escapeMarkdownTableCell(choice.label)} |`,
|
|
646
|
-
`| Category | ${escapeMarkdownTableCell(choice.category ?? "-")} |`,
|
|
647
|
-
`| Source | \`templates/${escapeMarkdownTableCell(choice.source)}\` |`,
|
|
648
|
-
`| Default target | \`${escapeMarkdownTableCell(choice.target)}\` |`
|
|
647
|
+
localize(`| Label | ${escapeMarkdownTableCell(choice.label)} |`, `| 标签 | ${escapeMarkdownTableCell(choice.label)} |`),
|
|
648
|
+
localize(`| Category | ${escapeMarkdownTableCell(choice.category ?? "-")} |`, `| 分类 | ${escapeMarkdownTableCell(choice.category ?? "-")} |`),
|
|
649
|
+
localize(`| Source | \`templates/${escapeMarkdownTableCell(choice.source)}\` |`, `| 源目录 | \`templates/${escapeMarkdownTableCell(choice.source)}\` |`),
|
|
650
|
+
localize(`| Default target | \`${escapeMarkdownTableCell(choice.target)}\` |`, `| 默认目标 | \`${escapeMarkdownTableCell(choice.target)}\` |`)
|
|
649
651
|
].join("\n");
|
|
650
652
|
}
|
|
651
653
|
function formatTemplateHealthStatus(status) {
|
|
@@ -656,18 +658,18 @@ function formatTemplateHealthStatus(status) {
|
|
|
656
658
|
function formatTemplateHealthReport(report, color = false) {
|
|
657
659
|
const status = color ? formatTemplateHealthStatus : (value) => value.toUpperCase();
|
|
658
660
|
const lines = [
|
|
659
|
-
`templates: ${report.templatesDir}`,
|
|
660
|
-
`count: ${report.templateCount}`,
|
|
661
|
+
localize(`templates: ${report.templatesDir}`, `模板目录:${report.templatesDir}`),
|
|
662
|
+
localize(`count: ${report.templateCount}`, `数量:${report.templateCount}`),
|
|
661
663
|
""
|
|
662
664
|
];
|
|
663
665
|
for (const check of report.checks) {
|
|
664
666
|
const prefix = check.template ? `${check.template}: ` : "";
|
|
665
667
|
lines.push(`[${status(check.status)}] ${prefix}${check.title}`);
|
|
666
668
|
lines.push(` ${check.detail}`);
|
|
667
|
-
if (check.fix) lines.push(` fix: ${check.fix}`);
|
|
669
|
+
if (check.fix) lines.push(localize(` fix: ${check.fix}`, ` 修复:${check.fix}`));
|
|
668
670
|
}
|
|
669
671
|
lines.push("");
|
|
670
|
-
lines.push(color ? `summary: ${pc.green(String(report.summary.pass))} pass, ${pc.yellow(String(report.summary.warn))} warn, ${pc.red(String(report.summary.fail))} fail
|
|
672
|
+
lines.push(color ? localize(`summary: ${pc.green(String(report.summary.pass))} pass, ${pc.yellow(String(report.summary.warn))} warn, ${pc.red(String(report.summary.fail))} fail`, `摘要:${pc.green(String(report.summary.pass))} 通过,${pc.yellow(String(report.summary.warn))} 警告,${pc.red(String(report.summary.fail))} 失败`) : localize(`summary: ${report.summary.pass} pass, ${report.summary.warn} warn, ${report.summary.fail} fail`, `摘要:${report.summary.pass} 通过,${report.summary.warn} 警告,${report.summary.fail} 失败`));
|
|
671
673
|
return lines.join("\n");
|
|
672
674
|
}
|
|
673
675
|
async function emitTemplateOutput(content, options) {
|
|
@@ -677,13 +679,13 @@ async function emitTemplateOutput(content, options) {
|
|
|
677
679
|
}
|
|
678
680
|
const outFile = path.resolve(process.cwd(), options.out);
|
|
679
681
|
await fs.outputFile(outFile, `${content}\n`, "utf8");
|
|
680
|
-
logger.success(`
|
|
682
|
+
logger.success(localize(`Wrote ${path.relative(process.cwd(), outFile)}`, `已写入 ${path.relative(process.cwd(), outFile)}`));
|
|
681
683
|
}
|
|
682
684
|
function registerTemplatesCommands(program) {
|
|
683
|
-
program.command("templates").alias("tpl").description("列出可用的内置模板").argument("[key]", "查看指定模板详情").option("-c, --category <category>", "按模板分类过滤:library / app / service / docs / tool").option("--check", "检查内置模板元数据、目录和临时文件").option("--json", "输出 JSON,方便脚本消费").option("--markdown", "输出 Markdown,方便同步文档").option("--out <file>", "把当前输出写入文件").action(async (key, opts) => {
|
|
685
|
+
program.command("templates").alias("tpl").description(localize("List the built-in templates", "列出可用的内置模板")).argument("[key]", localize("Show details for a template key", "查看指定模板详情")).option("-c, --category <category>", localize("Filter by library, app, service, docs, or tool", "按模板分类过滤:library / app / service / docs / tool")).option("--check", localize("Check built-in template metadata and directories", "检查内置模板元数据、目录和临时文件")).option("--json", localize("Output JSON for scripts", "输出 JSON,方便脚本消费")).option("--markdown", localize("Output Markdown for documentation", "输出 Markdown,方便同步文档")).option("--out <file>", localize("Write output to a file", "把当前输出写入文件")).action(async (key, opts) => {
|
|
684
686
|
const { getTemplateChoice, getTemplateChoices, isTemplateCategory, suggestTemplateKey, templateCategories } = await import("@icebreakers/monorepo-templates");
|
|
685
687
|
if (opts.check) {
|
|
686
|
-
const { checkTemplates } = await import("./commands-
|
|
688
|
+
const { checkTemplates } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
687
689
|
const report = await checkTemplates();
|
|
688
690
|
if (opts.json) await emitTemplateOutput(JSON.stringify(report, null, 2), opts);
|
|
689
691
|
else await emitTemplateOutput(formatTemplateHealthReport(report, !opts.out), opts);
|
|
@@ -693,10 +695,10 @@ function registerTemplatesCommands(program) {
|
|
|
693
695
|
if (key) {
|
|
694
696
|
const choice = getTemplateChoice(key);
|
|
695
697
|
if (!choice) {
|
|
696
|
-
logger.error(`
|
|
698
|
+
logger.error(localize(`Unknown template: ${key}`, `未知模板:${key}`));
|
|
697
699
|
const suggestion = suggestTemplateKey(key);
|
|
698
|
-
if (suggestion) logger.info(`
|
|
699
|
-
logger.info("
|
|
700
|
+
if (suggestion) logger.info(localize(`Did you mean \`${suggestion}\`?`, `你是否想使用 \`${suggestion}\`?`));
|
|
701
|
+
logger.info(localize("Run `repo templates` to list available templates.", "运行 `repo templates` 查看可用模板。"));
|
|
700
702
|
process.exitCode = 1;
|
|
701
703
|
return;
|
|
702
704
|
}
|
|
@@ -708,15 +710,15 @@ function registerTemplatesCommands(program) {
|
|
|
708
710
|
await emitTemplateOutput(formatTemplateMarkdownDetail(choice), opts);
|
|
709
711
|
return;
|
|
710
712
|
}
|
|
711
|
-
await emitTemplateOutput(`Template detail:\n${formatTemplateDetail(choice)}`, opts);
|
|
712
|
-
if (!opts.out) logger.info(`
|
|
713
|
+
await emitTemplateOutput(localize(`Template detail:\n${formatTemplateDetail(choice)}`, `模板详情:\n${formatTemplateDetail(choice)}`), opts);
|
|
714
|
+
if (!opts.out) logger.info(localize(`Next: run \`repo new <name> --template ${choice.key}\`.`, `下一步:运行 \`repo new <name> --template ${choice.key}\`。`));
|
|
713
715
|
return;
|
|
714
716
|
}
|
|
715
717
|
let category;
|
|
716
718
|
if (opts.category) {
|
|
717
719
|
if (!isTemplateCategory(opts.category)) {
|
|
718
|
-
logger.error(`
|
|
719
|
-
logger.info(`
|
|
720
|
+
logger.error(localize(`Unknown template category: ${opts.category}`, `未知模板分类:${opts.category}`));
|
|
721
|
+
logger.info(localize(`Available categories: ${templateCategories.join(", ")}`, `可用分类:${templateCategories.join(", ")}`));
|
|
720
722
|
process.exitCode = 1;
|
|
721
723
|
return;
|
|
722
724
|
}
|
|
@@ -731,8 +733,8 @@ function registerTemplatesCommands(program) {
|
|
|
731
733
|
await emitTemplateOutput(formatTemplateMarkdownTable(choices), opts);
|
|
732
734
|
return;
|
|
733
735
|
}
|
|
734
|
-
await emitTemplateOutput(`Available templates:\n${formatTemplateTable(choices)}`, opts);
|
|
735
|
-
if (!opts.out) logger.info("
|
|
736
|
+
await emitTemplateOutput(localize(`Available templates:\n${formatTemplateTable(choices)}`, `可用模板:\n${formatTemplateTable(choices)}`), opts);
|
|
737
|
+
if (!opts.out) logger.info(localize("Next: run `repo new <name> --template <key>`.", "下一步:运行 `repo new <name> --template <key>`。"));
|
|
736
738
|
});
|
|
737
739
|
}
|
|
738
740
|
//#endregion
|
|
@@ -754,29 +756,29 @@ function normalizeCleanOptions(opts) {
|
|
|
754
756
|
function normalizeToolingTargets(tooling) {
|
|
755
757
|
if (!tooling.length) return;
|
|
756
758
|
const unknown = tooling.filter((item) => !initToolingTargets.includes(item));
|
|
757
|
-
if (unknown.length > 0) throw new Error(`未知的 init tooling 目标: ${unknown.join(", ")}`);
|
|
759
|
+
if (unknown.length > 0) throw new Error(localize(`Unknown init tooling target: ${unknown.join(", ")}`, `未知的 init tooling 目标: ${unknown.join(", ")}`));
|
|
758
760
|
return tooling;
|
|
759
761
|
}
|
|
760
762
|
//#endregion
|
|
761
763
|
//#region src/cli/commands/tooling.ts
|
|
762
764
|
function registerToolingCommands(program, cwd) {
|
|
763
|
-
program.command("tooling").alias("tg").description("工程化配置命令").command("init").description(`生成 tooling 配置(可选值:${initToolingTargets.join(", ")})`).alias("i").argument("[tooling...]").option("-a, --all", "生成全部 tooling 配置").option("-f, --force", "覆盖已存在的 tooling 配置文件").action(async (tooling = [], opts) => {
|
|
765
|
+
program.command("tooling").alias("tg").description(localize("Tooling configuration commands", "工程化配置命令")).command("init").description(localize(`Generate tooling configuration (${initToolingTargets.join(", ")})`, `生成 tooling 配置(可选值:${initToolingTargets.join(", ")})`)).alias("i").argument("[tooling...]").option("-a, --all", localize("Generate every tooling configuration", "生成全部 tooling 配置")).option("-f, --force", localize("Overwrite existing tooling configuration files", "覆盖已存在的 tooling 配置文件")).action(async (tooling = [], opts) => {
|
|
764
766
|
const normalizedTooling = normalizeToolingTargets(tooling);
|
|
765
|
-
const { initTooling } = await import("./commands-
|
|
767
|
+
const { initTooling } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
766
768
|
await initTooling(cwd, {
|
|
767
769
|
...normalizedTooling ? { targets: normalizedTooling } : {},
|
|
768
770
|
...opts.all !== void 0 ? { all: opts.all } : {},
|
|
769
771
|
...opts.force !== void 0 ? { force: opts.force } : {}
|
|
770
772
|
});
|
|
771
|
-
logger.success("
|
|
773
|
+
logger.success(localize("Tooling initialization finished.", "Tooling 初始化完成。"));
|
|
772
774
|
});
|
|
773
775
|
}
|
|
774
776
|
//#endregion
|
|
775
777
|
//#region src/cli/commands/check/output.ts
|
|
776
778
|
function formatCheckPlan(plan) {
|
|
777
779
|
const lines = [
|
|
778
|
-
`cwd: ${plan.cwd}`,
|
|
779
|
-
`mode: ${plan.mode}`,
|
|
780
|
+
localize(`cwd: ${plan.cwd}`, `当前目录:${plan.cwd}`),
|
|
781
|
+
localize(`mode: ${plan.mode}`, `模式:${plan.mode}`),
|
|
780
782
|
""
|
|
781
783
|
];
|
|
782
784
|
for (const command of plan.commands) {
|
|
@@ -788,14 +790,14 @@ function formatCheckPlan(plan) {
|
|
|
788
790
|
function formatMarkdownTable$2(rows) {
|
|
789
791
|
const formatCell = (value) => String(value ?? "-").split("|").join("\\|").split("\n").join("<br>");
|
|
790
792
|
return [
|
|
791
|
-
"| Field | Value |",
|
|
793
|
+
localize("| Field | Value |", "| 字段 | 值 |"),
|
|
792
794
|
"| --- | --- |",
|
|
793
795
|
...rows.map(([label, value]) => `| ${label} | ${formatCell(value)} |`)
|
|
794
796
|
].join("\n");
|
|
795
797
|
}
|
|
796
798
|
function formatCheckPlanMarkdown(plan) {
|
|
797
799
|
return [
|
|
798
|
-
"# Repo check plan",
|
|
800
|
+
localize("# Repo check plan", "# Repo 检查计划"),
|
|
799
801
|
"",
|
|
800
802
|
formatMarkdownTable$2([
|
|
801
803
|
["cwd", plan.cwd],
|
|
@@ -803,7 +805,7 @@ function formatCheckPlanMarkdown(plan) {
|
|
|
803
805
|
["commands", plan.commands.length]
|
|
804
806
|
]),
|
|
805
807
|
"",
|
|
806
|
-
"## Commands",
|
|
808
|
+
localize("## Commands", "## 命令"),
|
|
807
809
|
"",
|
|
808
810
|
...plan.commands.map((command) => `- \`${command.command}\` - ${command.description}`)
|
|
809
811
|
].join("\n");
|
|
@@ -836,23 +838,23 @@ function formatDoctorStatus(status) {
|
|
|
836
838
|
function formatDoctorReport(report, color = false) {
|
|
837
839
|
const status = color ? formatDoctorStatus : (value) => value.toUpperCase();
|
|
838
840
|
const lines = [
|
|
839
|
-
`workspace: ${report.workspaceDir}`,
|
|
840
|
-
`packages: ${report.packageCount}`,
|
|
841
|
+
localize(`workspace: ${report.workspaceDir}`, `工作区:${report.workspaceDir}`),
|
|
842
|
+
localize(`packages: ${report.packageCount}`, `包数量:${report.packageCount}`),
|
|
841
843
|
""
|
|
842
844
|
];
|
|
843
845
|
for (const check of report.checks) {
|
|
844
846
|
lines.push(`[${status(check.status)}] ${check.title}`);
|
|
845
847
|
lines.push(` ${check.detail}`);
|
|
846
|
-
if (check.fix) lines.push(` fix: ${check.fix}`);
|
|
848
|
+
if (check.fix) lines.push(localize(` fix: ${check.fix}`, ` 修复:${check.fix}`));
|
|
847
849
|
}
|
|
848
850
|
lines.push("");
|
|
849
|
-
lines.push(color ? `summary: ${pc.green(String(report.summary.pass))} pass, ${pc.yellow(String(report.summary.warn))} warn, ${pc.red(String(report.summary.fail))} fail
|
|
851
|
+
lines.push(color ? localize(`summary: ${pc.green(String(report.summary.pass))} pass, ${pc.yellow(String(report.summary.warn))} warn, ${pc.red(String(report.summary.fail))} fail`, `摘要:${pc.green(String(report.summary.pass))} 通过,${pc.yellow(String(report.summary.warn))} 警告,${pc.red(String(report.summary.fail))} 失败`) : localize(`summary: ${report.summary.pass} pass, ${report.summary.warn} warn, ${report.summary.fail} fail`, `摘要:${report.summary.pass} 通过,${report.summary.warn} 警告,${report.summary.fail} 失败`));
|
|
850
852
|
return lines.join("\n");
|
|
851
853
|
}
|
|
852
854
|
function formatMarkdownTable$1(rows) {
|
|
853
855
|
const formatCell = (value) => String(value ?? "-").split("|").join("\\|").split("\n").join("<br>");
|
|
854
856
|
return [
|
|
855
|
-
"| Field | Value |",
|
|
857
|
+
localize("| Field | Value |", "| 字段 | 值 |"),
|
|
856
858
|
"| --- | --- |",
|
|
857
859
|
...rows.map(([label, value]) => `| ${label} | ${formatCell(value)} |`)
|
|
858
860
|
].join("\n");
|
|
@@ -860,7 +862,7 @@ function formatMarkdownTable$1(rows) {
|
|
|
860
862
|
function formatDoctorMarkdown(report) {
|
|
861
863
|
const warningsAndFailures = report.checks.filter((check) => check.status !== "pass");
|
|
862
864
|
return [
|
|
863
|
-
"# Repo doctor report",
|
|
865
|
+
localize("# Repo doctor report", "# Repo doctor 诊断报告"),
|
|
864
866
|
"",
|
|
865
867
|
formatMarkdownTable$1([
|
|
866
868
|
["workspace", report.workspaceDir],
|
|
@@ -871,12 +873,12 @@ function formatDoctorMarkdown(report) {
|
|
|
871
873
|
]),
|
|
872
874
|
"",
|
|
873
875
|
...warningsAndFailures.length > 0 ? [
|
|
874
|
-
"## Findings",
|
|
876
|
+
localize("## Findings", "## 问题"),
|
|
875
877
|
"",
|
|
876
|
-
...warningsAndFailures.map((check) => `- ${check.status}: ${check.title}${check.fix ? ` (fix: ${check.fix})` : ""}`),
|
|
878
|
+
...warningsAndFailures.map((check) => localize(`- ${check.status}: ${check.title}${check.fix ? ` (fix: ${check.fix})` : ""}`, `- ${check.status}: ${check.title}${check.fix ? `(修复:${check.fix})` : ""}`)),
|
|
877
879
|
""
|
|
878
880
|
] : [],
|
|
879
|
-
"## Checks",
|
|
881
|
+
localize("## Checks", "## 检查项"),
|
|
880
882
|
"",
|
|
881
883
|
...report.checks.map((check) => `- ${check.status}: ${check.title}`)
|
|
882
884
|
].join("\n");
|
|
@@ -919,7 +921,7 @@ async function emitDoctorReport(report, opts, cwd) {
|
|
|
919
921
|
}
|
|
920
922
|
const outFile = path.resolve(cwd, opts.out);
|
|
921
923
|
await fs.outputFile(outFile, `${content}\n`, "utf8");
|
|
922
|
-
logger.success(`
|
|
924
|
+
logger.success(localize(`Wrote ${path.relative(cwd, outFile)}`, `已写入 ${path.relative(cwd, outFile)}`));
|
|
923
925
|
}
|
|
924
926
|
async function emitCheckPlan(plan, opts, cwd) {
|
|
925
927
|
const content = createCheckPlanOutput(plan, opts);
|
|
@@ -929,22 +931,22 @@ async function emitCheckPlan(plan, opts, cwd) {
|
|
|
929
931
|
}
|
|
930
932
|
const outFile = path.resolve(cwd, opts.out);
|
|
931
933
|
await fs.outputFile(outFile, `${content}\n`, "utf8");
|
|
932
|
-
logger.success(`
|
|
934
|
+
logger.success(localize(`Wrote ${path.relative(cwd, outFile)}`, `已写入 ${path.relative(cwd, outFile)}`));
|
|
933
935
|
}
|
|
934
936
|
function registerTopLevelCommands(program, cwd) {
|
|
935
|
-
program.command("init").description("初始化当前 workspace,并生成推荐配置").option("--preset <preset>", "初始化预设:minimal / standard", "standard").option("-f, --force", "覆盖已存在的 tooling 配置文件").option("--overwrite", "
|
|
936
|
-
const { init } = await import("./commands-
|
|
937
|
+
program.command("init").description(localize("Initialize the current workspace with recommended configuration", "初始化当前 workspace,并生成推荐配置")).option("--preset <preset>", localize("Initialization preset: minimal or standard", "初始化预设:minimal / standard"), "standard").option("-f, --force", localize("Overwrite existing tooling configuration files", "覆盖已存在的 tooling 配置文件")).option("--overwrite", localize("Overwrite existing managed files", "覆盖受管的已存在文件")).option("-y, --yes", localize("Use defaults without prompting; suitable for CI", "使用默认值跳过所有交互,适合 CI")).action(async (opts) => {
|
|
938
|
+
const { init } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
937
939
|
await init(cwd, {
|
|
938
940
|
...opts.preset !== void 0 ? { preset: opts.preset } : {},
|
|
939
941
|
...opts.force !== void 0 ? { force: opts.force } : {},
|
|
940
942
|
...opts.overwrite !== void 0 ? { overwrite: opts.overwrite } : {},
|
|
941
943
|
...opts.yes !== void 0 ? { yes: opts.yes } : {}
|
|
942
944
|
});
|
|
943
|
-
logger.success("
|
|
944
|
-
logger.info("
|
|
945
|
+
logger.success(localize("Initialization finished.", "初始化完成。"));
|
|
946
|
+
logger.info(localize("Next: run `pnpm install` and `pnpm build`.", "下一步:运行 `pnpm install` 和 `pnpm build`。"));
|
|
945
947
|
});
|
|
946
|
-
program.command("new").description("创建新的 package / app").argument("[name]").option("-t, --template <template>", "直接使用指定模板,跳过模板选择").option("--dry-run", "预览将要创建的目录与 package 信息,不写入文件").option("--json", "以 JSON 输出创建预览,隐含 --dry-run").option("--out <file>", "把创建预览写入文件,隐含 --dry-run").action(async (inputName, opts) => {
|
|
947
|
-
const { runCreateFlow } = await import("./create-flow-
|
|
948
|
+
program.command("new").description(localize("Create a new package or application", "创建新的 package / app")).argument("[name]").option("-t, --template <template>", localize("Use a template key without prompting", "直接使用指定模板,跳过模板选择")).option("--dry-run", localize("Preview directories and package metadata without writing", "预览将要创建的目录与 package 信息,不写入文件")).option("--json", localize("Output the creation preview as JSON; implies --dry-run", "以 JSON 输出创建预览,隐含 --dry-run")).option("--out <file>", localize("Write the creation preview to a file; implies --dry-run", "把创建预览写入文件,隐含 --dry-run")).action(async (inputName, opts) => {
|
|
949
|
+
const { runCreateFlow } = await import("./create-flow-BE4Nd902.mjs");
|
|
948
950
|
const result = await runCreateFlow(cwd, inputName, {
|
|
949
951
|
...opts.template !== void 0 ? { template: opts.template } : {},
|
|
950
952
|
...opts.dryRun || opts.json || opts.out ? { dryRun: true } : {},
|
|
@@ -952,20 +954,20 @@ function registerTopLevelCommands(program, cwd) {
|
|
|
952
954
|
...opts.out !== void 0 ? { out: opts.out } : {}
|
|
953
955
|
});
|
|
954
956
|
if (result.dryRun || result.failed) return;
|
|
955
|
-
logger.success("
|
|
956
|
-
logger.info("
|
|
957
|
+
logger.success(localize("Package creation finished.", "包创建完成。"));
|
|
958
|
+
logger.info(localize("Next: run `pnpm install` and start the new workspace package.", "下一步:运行 `pnpm install`,然后启动新 workspace 包。"));
|
|
957
959
|
});
|
|
958
|
-
program.command("check").description("执行推荐的本地校验").option("--full", "执行完整校验").option("--staged", "仅执行 staged 相关校验").option("--edit-file <file>", "执行 commit message 校验").option("--dry-run", "预览将要执行的校验,不实际运行").option("--json", "以 JSON 输出校验计划,隐含 --dry-run").option("--markdown", "以 Markdown 输出校验计划,隐含 --dry-run").option("--out <file>", "把校验计划写入文件,隐含 --dry-run").option("--redact", "脱敏 cwd/home 绝对路径后再输出").action(async (opts) => {
|
|
960
|
+
program.command("check").description(localize("Run the recommended local verification", "执行推荐的本地校验")).option("--full", localize("Run full verification", "执行完整校验")).option("--staged", localize("Run staged-file verification", "仅执行 staged 相关校验")).option("--edit-file <file>", localize("Validate a commit message file", "执行 commit message 校验")).option("--dry-run", localize("Preview checks without running them", "预览将要执行的校验,不实际运行")).option("--json", localize("Output the check plan as JSON; implies --dry-run", "以 JSON 输出校验计划,隐含 --dry-run")).option("--markdown", localize("Output the check plan as Markdown; implies --dry-run", "以 Markdown 输出校验计划,隐含 --dry-run")).option("--out <file>", localize("Write the check plan to a file; implies --dry-run", "把校验计划写入文件,隐含 --dry-run")).option("--redact", localize("Redact cwd and home paths", "脱敏 cwd/home 绝对路径后再输出")).action(async (opts) => {
|
|
959
961
|
const options = {
|
|
960
962
|
cwd,
|
|
961
963
|
...opts.full !== void 0 ? { full: opts.full } : {},
|
|
962
964
|
...opts.staged !== void 0 ? { staged: opts.staged } : {},
|
|
963
965
|
...opts.editFile !== void 0 ? { editFile: opts.editFile } : {}
|
|
964
966
|
};
|
|
965
|
-
const { resolveRecommendedCheckPlan, runRecommendedCheck } = await import("./commands-
|
|
967
|
+
const { resolveRecommendedCheckPlan, runRecommendedCheck } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
966
968
|
if (opts.dryRun || opts.json || opts.markdown || opts.out) {
|
|
967
969
|
if (opts.full) {
|
|
968
|
-
const { resolveFullWorkspaceCheckPlan } = await import("./commands-
|
|
970
|
+
const { resolveFullWorkspaceCheckPlan } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
969
971
|
await emitCheckPlan(await resolveFullWorkspaceCheckPlan(cwd), opts, cwd);
|
|
970
972
|
return;
|
|
971
973
|
}
|
|
@@ -973,10 +975,10 @@ function registerTopLevelCommands(program, cwd) {
|
|
|
973
975
|
return;
|
|
974
976
|
}
|
|
975
977
|
await runRecommendedCheck(options);
|
|
976
|
-
logger.success("
|
|
978
|
+
logger.success(localize("Checks finished.", "检查完成。"));
|
|
977
979
|
});
|
|
978
|
-
program.command("doctor").description("诊断当前仓库是否适合直接开始使用").option("--json", "输出 JSON 报告,方便 CI 或脚本消费").option("--markdown", "输出 Markdown 报告,方便粘贴到 issue 或 PR").option("--out <file>", "把诊断报告写入文件").option("--redact", "脱敏 workspace/cwd/home 绝对路径后再输出").option("--strict", "把 warning 也视为失败,适合 CI 门禁").action(async (opts) => {
|
|
979
|
-
const { runDoctor } = await import("./commands-
|
|
980
|
+
program.command("doctor").description(localize("Diagnose whether the current repository is ready to use", "诊断当前仓库是否适合直接开始使用")).option("--json", localize("Output JSON for CI or scripts", "输出 JSON 报告,方便 CI 或脚本消费")).option("--markdown", localize("Output Markdown for an issue or pull request", "输出 Markdown 报告,方便粘贴到 issue 或 PR")).option("--out <file>", localize("Write the diagnostic report to a file", "把诊断报告写入文件")).option("--redact", localize("Redact workspace, cwd, and home paths", "脱敏 workspace/cwd/home 绝对路径后再输出")).option("--strict", localize("Treat warnings as failures", "把 warning 也视为失败,适合 CI 门禁")).action(async (opts) => {
|
|
981
|
+
const { runDoctor } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
980
982
|
const report = await runDoctor(cwd);
|
|
981
983
|
await emitDoctorReport(report, opts, cwd);
|
|
982
984
|
if (opts.out || opts.json || opts.markdown) {
|
|
@@ -984,47 +986,47 @@ function registerTopLevelCommands(program, cwd) {
|
|
|
984
986
|
return;
|
|
985
987
|
}
|
|
986
988
|
if (report.summary.fail > 0) {
|
|
987
|
-
logger.error(`
|
|
989
|
+
logger.error(localize(`Doctor found ${report.summary.fail} blocking issue(s).`, `Doctor 发现 ${report.summary.fail} 个阻断问题。`));
|
|
988
990
|
process.exitCode = 1;
|
|
989
991
|
return;
|
|
990
992
|
}
|
|
991
993
|
if (report.summary.warn > 0) {
|
|
992
994
|
if (opts.strict) {
|
|
993
|
-
logger.error(`
|
|
995
|
+
logger.error(localize(`Doctor found ${report.summary.warn} warning(s) in strict mode.`, `严格模式下 doctor 发现 ${report.summary.warn} 个警告。`));
|
|
994
996
|
process.exitCode = 1;
|
|
995
997
|
return;
|
|
996
998
|
}
|
|
997
|
-
logger.warn(`
|
|
999
|
+
logger.warn(localize(`Doctor found ${report.summary.warn} suggestion(s).`, `Doctor 提供了 ${report.summary.warn} 条建议。`));
|
|
998
1000
|
}
|
|
999
|
-
logger.success("
|
|
1001
|
+
logger.success(localize("Doctor finished.", "Doctor 诊断完成。"));
|
|
1000
1002
|
});
|
|
1001
|
-
program.command("upgrade").description("同步仓库标准资产与脚本").option("-i,--interactive").option("-c,--core", "仅同步核心配置,跳过 GitHub 相关资产").option("--outDir <dir>", "Output directory").option("-s,--skip-overwrite", "
|
|
1002
|
-
const { upgradeMonorepo } = await import("./commands-
|
|
1003
|
+
program.command("upgrade").description(localize("Synchronize standard repository assets and scripts", "同步仓库标准资产与脚本")).option("-i,--interactive", localize("Select managed files interactively", "交互式选择受管文件")).option("-c,--core", localize("Synchronize core configuration without GitHub assets", "仅同步核心配置,跳过 GitHub 相关资产")).option("--outDir <dir>", localize("Output directory", "输出目录")).option("-s,--skip-overwrite", localize("Preserve existing files", "保留已存在文件")).option("-y, --yes", localize("Skip prompts and overwrite drifted managed assets", "跳过交互并覆盖 drifted 标准资产")).option("--overwrite", localize("Overwrite drifted managed assets", "覆盖 drifted 标准资产")).option("--no-overwrite", localize("Preserve drifted managed assets", "不覆盖 drifted 标准资产")).option("--overwrite-release", localize("Overwrite an unmarked custom release workflow", "覆盖未标记的自定义 release workflow")).action(async (opts) => {
|
|
1004
|
+
const { upgradeMonorepo } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
1003
1005
|
await upgradeMonorepo(normalizeCliOpts(cwd, opts));
|
|
1004
|
-
logger.success("
|
|
1006
|
+
logger.success(localize("Upgrade finished.", "升级完成。"));
|
|
1005
1007
|
});
|
|
1006
1008
|
}
|
|
1007
1009
|
//#endregion
|
|
1008
1010
|
//#region src/cli/commands/verify.ts
|
|
1009
1011
|
function registerVerifyCommands(program, cwd) {
|
|
1010
|
-
const verifyCommand = program.command("verify").alias("v").description("本地校验工具集");
|
|
1011
|
-
verifyCommand.command("pre-push").description("按推送变更范围执行 build/test/tsd 校验").alias("push").action(async () => {
|
|
1012
|
-
const { verifyPrePush } = await import("./commands-
|
|
1012
|
+
const verifyCommand = program.command("verify").alias("v").description(localize("Local verification commands", "本地校验工具集"));
|
|
1013
|
+
verifyCommand.command("pre-push").description(localize("Run build, test, and tsd checks for pushed changes", "按推送变更范围执行 build/test/tsd 校验")).alias("push").action(async () => {
|
|
1014
|
+
const { verifyPrePush } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
1013
1015
|
await verifyPrePush({ cwd });
|
|
1014
1016
|
});
|
|
1015
|
-
verifyCommand.command("pre-commit").description("执行 lint-staged 校验").alias("commit").action(async () => {
|
|
1016
|
-
const { verifyPreCommit } = await import("./commands-
|
|
1017
|
+
verifyCommand.command("pre-commit").description(localize("Run lint-staged verification", "执行 lint-staged 校验")).alias("commit").action(async () => {
|
|
1018
|
+
const { verifyPreCommit } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
1017
1019
|
await verifyPreCommit({ cwd });
|
|
1018
1020
|
});
|
|
1019
|
-
verifyCommand.command("commit-msg").description("执行 commitlint 校验").alias("msg").argument("<edit-file>").action(async (editFile) => {
|
|
1020
|
-
const { verifyCommitMsg } = await import("./commands-
|
|
1021
|
+
verifyCommand.command("commit-msg").description(localize("Run commitlint verification", "执行 commitlint 校验")).alias("msg").argument("<edit-file>").action(async (editFile) => {
|
|
1022
|
+
const { verifyCommitMsg } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
1021
1023
|
await verifyCommitMsg({
|
|
1022
1024
|
cwd,
|
|
1023
1025
|
editFile
|
|
1024
1026
|
});
|
|
1025
1027
|
});
|
|
1026
|
-
verifyCommand.command("staged-typecheck").description("按暂存文件所在 workspace 执行 typecheck").alias("tc").argument("[files...]").action(async (files = []) => {
|
|
1027
|
-
const { verifyStagedTypecheck } = await import("./commands-
|
|
1028
|
+
verifyCommand.command("staged-typecheck").description(localize("Run typecheck in workspaces containing staged files", "按暂存文件所在 workspace 执行 typecheck")).alias("tc").argument("[files...]").action(async (files = []) => {
|
|
1029
|
+
const { verifyStagedTypecheck } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
1028
1030
|
verifyStagedTypecheck(files, { cwd });
|
|
1029
1031
|
});
|
|
1030
1032
|
}
|
|
@@ -1034,10 +1036,10 @@ function collectValues(value, previous = []) {
|
|
|
1034
1036
|
return [...previous, value];
|
|
1035
1037
|
}
|
|
1036
1038
|
function formatWorkspaceList(result) {
|
|
1037
|
-
const lines = [`workspace: ${result.workspaceDir}`, `packages: ${result.packages.length}`];
|
|
1039
|
+
const lines = [localize(`workspace: ${result.workspaceDir}`, `工作区:${result.workspaceDir}`), localize(`packages: ${result.packages.length}`, `包数量:${result.packages.length}`)];
|
|
1038
1040
|
for (const pkg of result.packages) {
|
|
1039
|
-
const name = pkg.name ?? "(unnamed)";
|
|
1040
|
-
const privateMark = pkg.private ? " private" : "";
|
|
1041
|
+
const name = pkg.name ?? localize("(unnamed)", "(未命名)");
|
|
1042
|
+
const privateMark = pkg.private ? localize(" private", " 私有") : "";
|
|
1041
1043
|
lines.push(`- ${name} ${pkg.relativeDir}${privateMark}`);
|
|
1042
1044
|
}
|
|
1043
1045
|
return lines.join("\n");
|
|
@@ -1047,14 +1049,14 @@ function formatMarkdownCell(value) {
|
|
|
1047
1049
|
}
|
|
1048
1050
|
function formatMarkdownTable(rows) {
|
|
1049
1051
|
return [
|
|
1050
|
-
"| Field | Value |",
|
|
1052
|
+
localize("| Field | Value |", "| 字段 | 值 |"),
|
|
1051
1053
|
"| --- | --- |",
|
|
1052
1054
|
...rows.map(([label, value]) => `| ${label} | ${formatMarkdownCell(value)} |`)
|
|
1053
1055
|
].join("\n");
|
|
1054
1056
|
}
|
|
1055
1057
|
function formatWorkspaceListMarkdown(result) {
|
|
1056
1058
|
return [
|
|
1057
|
-
"# Repo workspaces",
|
|
1059
|
+
localize("# Repo workspaces", "# Repo 工作区"),
|
|
1058
1060
|
"",
|
|
1059
1061
|
formatMarkdownTable([
|
|
1060
1062
|
["cwd", result.cwd],
|
|
@@ -1062,14 +1064,14 @@ function formatWorkspaceListMarkdown(result) {
|
|
|
1062
1064
|
["packages", result.packages.length]
|
|
1063
1065
|
]),
|
|
1064
1066
|
"",
|
|
1065
|
-
"## Packages",
|
|
1067
|
+
localize("## Packages", "## 包"),
|
|
1066
1068
|
"",
|
|
1067
|
-
"| Name | Path | Private | Description |",
|
|
1069
|
+
localize("| Name | Path | Private | Description |", "| 名称 | 路径 | 私有 | 说明 |"),
|
|
1068
1070
|
"| --- | --- | --- | --- |",
|
|
1069
1071
|
...result.packages.map((pkg) => {
|
|
1070
|
-
const name = pkg.name ?? "(unnamed)";
|
|
1072
|
+
const name = pkg.name ?? localize("(unnamed)", "(未命名)");
|
|
1071
1073
|
const description = pkg.description ?? "-";
|
|
1072
|
-
return `| ${formatMarkdownCell(name)} | ${formatMarkdownCell(pkg.relativeDir)} | ${pkg.private ? "yes" : "no"} | ${formatMarkdownCell(description)} |`;
|
|
1074
|
+
return `| ${formatMarkdownCell(name)} | ${formatMarkdownCell(pkg.relativeDir)} | ${pkg.private ? localize("yes", "是") : localize("no", "否")} | ${formatMarkdownCell(description)} |`;
|
|
1073
1075
|
})
|
|
1074
1076
|
].join("\n");
|
|
1075
1077
|
}
|
|
@@ -1098,21 +1100,21 @@ async function emitWorkspaceList(result, opts) {
|
|
|
1098
1100
|
}
|
|
1099
1101
|
const outFile = path.resolve(process.cwd(), opts.out);
|
|
1100
1102
|
await fs.outputFile(outFile, `${content}\n`, "utf8");
|
|
1101
|
-
logger.success(`
|
|
1103
|
+
logger.success(localize(`Wrote ${path.relative(process.cwd(), outFile)}`, `已写入 ${path.relative(process.cwd(), outFile)}`));
|
|
1102
1104
|
}
|
|
1103
1105
|
function registerWorkspaceCommands(program, cwd) {
|
|
1104
|
-
const workspaceCommand = program.command("workspace").alias("ws").description("工作区命令");
|
|
1105
|
-
workspaceCommand.command("upgrade").description("升级/同步 monorepo 相关包").alias("up").option("-i,--interactive").option("-c,--core", "仅同步核心配置,跳过 GitHub 相关资产").option("--outDir <dir>", "Output directory").option("-s,--skip-overwrite", "
|
|
1106
|
-
const { upgradeMonorepo } = await import("./commands-
|
|
1106
|
+
const workspaceCommand = program.command("workspace").alias("ws").description(localize("Workspace commands", "工作区命令"));
|
|
1107
|
+
workspaceCommand.command("upgrade").description(localize("Upgrade or synchronize monorepo packages", "升级/同步 monorepo 相关包")).alias("up").option("-i,--interactive", localize("Select managed files interactively", "交互式选择受管文件")).option("-c,--core", localize("Synchronize core configuration without GitHub assets", "仅同步核心配置,跳过 GitHub 相关资产")).option("--outDir <dir>", localize("Output directory", "输出目录")).option("-s,--skip-overwrite", localize("Preserve existing files", "保留已存在文件")).option("-y, --yes", localize("Skip prompts and overwrite drifted managed assets", "跳过交互并覆盖 drifted 标准资产")).option("--overwrite", localize("Overwrite drifted managed assets", "覆盖 drifted 标准资产")).option("--no-overwrite", localize("Preserve drifted managed assets", "不覆盖 drifted 标准资产")).option("--overwrite-release", localize("Overwrite an unmarked custom release workflow", "覆盖未标记的自定义 release workflow")).action(async (opts) => {
|
|
1108
|
+
const { upgradeMonorepo } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
1107
1109
|
await upgradeMonorepo(normalizeCliOpts(cwd, opts));
|
|
1108
|
-
logger.success("
|
|
1110
|
+
logger.success(localize("Workspace upgrade finished.", "Workspace 升级完成。"));
|
|
1109
1111
|
});
|
|
1110
|
-
workspaceCommand.command("init").description("初始化工作区元信息(README、package.json、pnpm intent、issue template)").alias("i").action(async () => {
|
|
1111
|
-
const { initMetadata } = await import("./commands-
|
|
1112
|
+
workspaceCommand.command("init").description(localize("Initialize workspace metadata and repository files", "初始化工作区元信息(README、package.json、pnpm intent、issue template)")).alias("i").action(async () => {
|
|
1113
|
+
const { initMetadata } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
1112
1114
|
await initMetadata(cwd);
|
|
1113
|
-
logger.success("
|
|
1115
|
+
logger.success(localize("Workspace initialization finished.", "Workspace 初始化完成。"));
|
|
1114
1116
|
});
|
|
1115
|
-
workspaceCommand.command("list").description("列出 workspace 包").alias("ls").option("--json", "输出 JSON").option("--markdown", "输出 Markdown,方便粘贴到 issue 或 PR").option("--redact", "脱敏 workspace/cwd/home 绝对路径后再输出").option("--include-private", "包含 private 包").option("--include-root", "包含 workspace 根包").option("-p, --pattern <glob>", "追加自定义 workspace glob,可重复", collectValues).option("--out <file>", "把当前列表输出写入文件").action(async (opts) => {
|
|
1117
|
+
workspaceCommand.command("list").description(localize("List workspace packages", "列出 workspace 包")).alias("ls").option("--json", localize("Output JSON", "输出 JSON")).option("--markdown", localize("Output Markdown", "输出 Markdown,方便粘贴到 issue 或 PR")).option("--redact", localize("Redact workspace, cwd, and home paths", "脱敏 workspace/cwd/home 绝对路径后再输出")).option("--include-private", localize("Include private packages", "包含 private 包")).option("--include-root", localize("Include the workspace root package", "包含 workspace 根包")).option("-p, --pattern <glob>", localize("Append a workspace glob; repeatable", "追加自定义 workspace glob,可重复"), collectValues).option("--out <file>", localize("Write the package list to a file", "把当前列表输出写入文件")).action(async (opts) => {
|
|
1116
1118
|
const { getWorkspacePackageSummaries } = await import("./workspace-MCKewElu.mjs").then((n) => n.a);
|
|
1117
1119
|
await emitWorkspaceList(await getWorkspacePackageSummaries(cwd, {
|
|
1118
1120
|
ignorePrivatePackage: !opts.includePrivate,
|
|
@@ -1120,17 +1122,41 @@ function registerWorkspaceCommands(program, cwd) {
|
|
|
1120
1122
|
...opts.pattern?.length ? { patterns: opts.pattern } : {}
|
|
1121
1123
|
}), opts);
|
|
1122
1124
|
});
|
|
1123
|
-
workspaceCommand.command("clean").description("清除选中的包").alias("rm").option("-y, --yes", "跳过交互直接清理(等价 autoConfirm)").option("--include-private", "包含 private 包").option("--pinned-version <version>", "覆盖写入的 repoctl 版本").action(async (opts) => {
|
|
1124
|
-
const { cleanProjects } = await import("./commands-
|
|
1125
|
+
workspaceCommand.command("clean").description(localize("Remove selected workspace packages", "清除选中的包")).alias("rm").option("-y, --yes", localize("Skip prompts and clean immediately", "跳过交互直接清理(等价 autoConfirm)")).option("--include-private", localize("Include private packages", "包含 private 包")).option("--pinned-version <version>", localize("Override the repoctl version written to the root package", "覆盖写入的 repoctl 版本")).action(async (opts) => {
|
|
1126
|
+
const { cleanProjects } = await import("./commands-BqUFCJA_.mjs").then((n) => n.t);
|
|
1125
1127
|
await cleanProjects(cwd, normalizeCleanOptions(opts));
|
|
1126
|
-
logger.success("
|
|
1128
|
+
logger.success(localize("Workspace cleanup finished.", "Workspace 清理完成。"));
|
|
1127
1129
|
});
|
|
1128
1130
|
}
|
|
1129
1131
|
//#endregion
|
|
1130
1132
|
//#region src/cli/program.ts
|
|
1131
1133
|
const cwd = process.cwd();
|
|
1132
1134
|
const program = new Command();
|
|
1133
|
-
|
|
1135
|
+
const activeCliName = path$1.basename(process.argv[1] ?? "", path$1.extname(process.argv[1] ?? "")) === "repoctl" ? "repoctl" : cliName;
|
|
1136
|
+
function localizeHelpMetadata(value) {
|
|
1137
|
+
return value.replaceAll("choices:", message("choicesLabel")).replaceAll("default:", message("defaultLabel")).replaceAll("preset:", message("presetLabel")).replaceAll("env:", message("envLabel"));
|
|
1138
|
+
}
|
|
1139
|
+
function localizeCommanderError(value) {
|
|
1140
|
+
return value.replaceAll("Did you mean one of", message("commanderDidYouMeanOneOf")).replaceAll("Did you mean", message("commanderDidYouMean")).replaceAll("Allowed choices are", message("commanderAllowedChoices")).replaceAll("missing required argument", message("commanderMissingRequiredArgument")).replaceAll("required option", message("commanderRequiredOption")).replaceAll("argument missing", message("commanderArgumentMissing")).replaceAll("not specified", message("commanderNotSpecified")).replaceAll("too many arguments", message("commanderTooManyArguments")).replaceAll("unknown command", message("commanderUnknownCommand")).replaceAll("unknown option", message("commanderUnknownOption")).replace(/^error:/, message("commanderErrorPrefix"));
|
|
1141
|
+
}
|
|
1142
|
+
function configureLocalizedHelp(command) {
|
|
1143
|
+
const defaultHelp = command.createHelp();
|
|
1144
|
+
const titles = {
|
|
1145
|
+
"Arguments:": message("argumentsTitle"),
|
|
1146
|
+
"Commands:": message("commandsTitle"),
|
|
1147
|
+
"Global Options:": message("globalOptionsTitle"),
|
|
1148
|
+
"Options:": message("optionsTitle"),
|
|
1149
|
+
"Usage:": message("usageTitle")
|
|
1150
|
+
};
|
|
1151
|
+
command.helpOption("-h, --help", message("helpOption")).configureOutput({ outputError: (value, write) => write(localizeCommanderError(value)) }).configureHelp({
|
|
1152
|
+
argumentDescription: (argument) => localizeHelpMetadata(defaultHelp.argumentDescription(argument)),
|
|
1153
|
+
optionDescription: (option) => localizeHelpMetadata(defaultHelp.optionDescription(option)),
|
|
1154
|
+
styleTitle: (title) => titles[title] ?? title
|
|
1155
|
+
});
|
|
1156
|
+
if (command.commands.length) command.addHelpCommand("help [command]", message("helpCommand"));
|
|
1157
|
+
command.commands.forEach(configureLocalizedHelp);
|
|
1158
|
+
}
|
|
1159
|
+
program.name(activeCliName).version(version, "-V, --version", message("versionOption")).description(message("cliDescription")).addOption(new Option("--lang <locale>", message("languageOption")).choices([...supportedLocales]));
|
|
1134
1160
|
registerTopLevelCommands(program, cwd);
|
|
1135
1161
|
registerTemplatesCommands(program);
|
|
1136
1162
|
registerWorkspaceCommands(program, cwd);
|
|
@@ -1142,24 +1168,8 @@ registerSkillsCommands(program, cwd);
|
|
|
1142
1168
|
registerVerifyCommands(program, cwd);
|
|
1143
1169
|
registerAiCommands(program, cwd);
|
|
1144
1170
|
registerPackageCommands(program, cwd);
|
|
1145
|
-
program
|
|
1146
|
-
|
|
1147
|
-
Existing repo:
|
|
1148
|
-
$ ${cliName} init
|
|
1149
|
-
$ ${cliName} doctor
|
|
1150
|
-
$ ${cliName} templates
|
|
1151
|
-
$ ${cliName} new my-package
|
|
1152
|
-
$ ${cliName} check
|
|
1153
|
-
|
|
1154
|
-
Faster in generated repos:
|
|
1155
|
-
$ pnpm run repo:init
|
|
1156
|
-
$ pnpm run repo:doctor
|
|
1157
|
-
$ pnpm run repo:new -- my-package
|
|
1158
|
-
$ pnpm run repo:check
|
|
1159
|
-
|
|
1160
|
-
Keep the repo current:
|
|
1161
|
-
$ ${cliName} upgrade
|
|
1162
|
-
`);
|
|
1171
|
+
configureLocalizedHelp(program);
|
|
1172
|
+
program.addHelpText("after", message("quickStart", { cliName: activeCliName }));
|
|
1163
1173
|
//#endregion
|
|
1164
1174
|
//#region src/cli.ts
|
|
1165
1175
|
if (process.argv.length <= 2) program.outputHelp();
|