@icebreakers/monorepo 5.5.10 → 5.7.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.
Files changed (49) hide show
  1. package/README.md +2 -0
  2. package/dist/baseline-DPfotf4y.mjs +146 -0
  3. package/dist/bundle-B9vRch4R.mjs +49 -0
  4. package/dist/catalog-CDEyc1uA.mjs +299 -0
  5. package/dist/cli.mjs +1487 -156
  6. package/dist/commands-TS8ABFdP.mjs +13820 -0
  7. package/dist/config-C38c_Q8L.mjs +66 -0
  8. package/dist/{create-flow-C811m80z.mjs → create-flow-CCr2hfSY.mjs} +103 -40
  9. package/dist/deps-CUdI2DaB.mjs +47 -0
  10. package/dist/execute-PX1hT0qv.mjs +68 -0
  11. package/dist/execute-Vi4qHe-D.mjs +663 -0
  12. package/dist/format-DZ7L34rf.mjs +28 -0
  13. package/dist/index-CoCTFWZJ.d.mts +2150 -0
  14. package/dist/index.d.mts +1741 -111
  15. package/dist/index.mjs +60 -6
  16. package/dist/inputs-_xIVONmB.mjs +50 -0
  17. package/dist/npm-B25nrSyz.mjs +82 -0
  18. package/dist/plan-B5aE_WNF.mjs +75 -0
  19. package/dist/run-Lu7y1bNf.mjs +165 -0
  20. package/dist/save-CdCf630Z.mjs +79 -0
  21. package/dist/scan-4nboHNXP.mjs +293 -0
  22. package/dist/template-drift-BBhnrHY1.mjs +2740 -0
  23. package/dist/tooling-entry.d.mts +1 -1
  24. package/dist/tooling-entry.mjs +2 -1
  25. package/dist/transaction-DAhY8EpG.mjs +168 -0
  26. package/dist/tsconfig-CGntrzBM.mjs +1483 -0
  27. package/dist/{tooling-BfXlmCi-.mjs → vitest-DkGh4Ygo.mjs} +108 -167
  28. package/dist/workspace-tasks-CnB8kkS0.mjs +4435 -0
  29. package/package.json +25 -7
  30. package/resources/api-report/runner.cjs +76 -0
  31. package/resources/devcontainer/setup.mjs +36 -0
  32. package/resources/knip/reporter.mjs +46 -0
  33. package/resources/maintenance/migration-lanes.mjs +141 -0
  34. package/resources/maintenance/migration-lock.mjs +119 -0
  35. package/resources/maintenance/migrations.mjs +215 -0
  36. package/resources/maintenance/presets.mjs +130 -0
  37. package/resources/maintenance/validate.mjs +233 -0
  38. package/resources/maintenance/workflow.yml +151 -0
  39. package/resources/skills/repoctl/SKILL.md +4 -2
  40. package/resources/skills/repoctl/references/commands.md +224 -13
  41. package/resources/skills/repoctl/references/config.md +70 -6
  42. package/resources/skills/repoctl/references/dependencies.md +37 -0
  43. package/resources/skills/repoctl/references/knip.md +34 -0
  44. package/resources/skills/repoctl/references/templates.md +26 -2
  45. package/dist/commands-CIzCAxyY.mjs +0 -5672
  46. package/dist/config-p842Knhq.mjs +0 -114
  47. package/dist/index-DDQKKYet.d.mts +0 -1025
  48. package/dist/types-m8JLwKzl.mjs +0 -499
  49. package/dist/workspace-MCKewElu.mjs +0 -123
@@ -0,0 +1,66 @@
1
+ import { Ht as clearWorkspaceCache, Wt as getWorkspacePackageSummaries, rt as hash } from "./workspace-tasks-CnB8kkS0.mjs";
2
+ import { t as knipConfigurationInputs } from "./inputs-_xIVONmB.mjs";
3
+ import { knipRoot } from "./plan-B5aE_WNF.mjs";
4
+ //#region src/commands/check/knip/config.ts
5
+ /** Return native settings for manual merging; existing Knip config always remains authoritative. */
6
+ async function getKnipConfigurationSuggestions(cwd) {
7
+ const root = await knipRoot(cwd);
8
+ const inputs = await knipConfigurationInputs(root, null);
9
+ clearWorkspaceCache();
10
+ const packages = await getWorkspacePackageSummaries(root, {
11
+ ignoreRootPackage: false,
12
+ ignorePrivatePackage: false
13
+ });
14
+ const extensions = "{js,mjs,cjs,jsx,ts,tsx,mts,cts}";
15
+ return {
16
+ schemaVersion: 1,
17
+ workspaceDir: root,
18
+ existing: inputs.configuration.filter((item) => !item.path.endsWith("#packages") && (item.path !== "package.json#knip" || item.hash !== hash("null"))).map((item) => item.path),
19
+ suggested: {
20
+ $schema: "https://unpkg.com/knip@6/schema.json",
21
+ ignore: [
22
+ "**/dist/**",
23
+ "**/coverage/**",
24
+ "**/.turbo/**",
25
+ "**/.vitepress/cache/**",
26
+ "**/.vitepress/dist/**",
27
+ "**/.astro/**",
28
+ "**/worker-configuration.d.ts"
29
+ ],
30
+ workspaces: Object.fromEntries(packages.packages.map((pkg) => [pkg.relativeDir, {
31
+ entry: [
32
+ `{index,cli,main}.${extensions}`,
33
+ `src/{index,cli,main}.${extensions}`,
34
+ `bin/**/*.${extensions}`,
35
+ `test-d/**/*.test-d.ts`,
36
+ ...pkg.relativeDir === "." ? [`scripts/**/*.${extensions}`, `.github/**/*.${extensions}`] : []
37
+ ],
38
+ project: [`**/*.${extensions}`]
39
+ }]))
40
+ },
41
+ guidance: [
42
+ {
43
+ key: "workspaces",
44
+ reason: "Keep native pnpm workspace discovery and framework plugins. These entries cover repoctl library/CLI/app templates and type-test entrypoints; merge them into existing native settings instead of replacing user entries."
45
+ },
46
+ {
47
+ key: "ignore",
48
+ reason: "Generated build, coverage, framework-cache and Worker type files are excluded explicitly; review generated patterns for your repository."
49
+ },
50
+ {
51
+ key: "entry",
52
+ reason: "Add dynamically loaded modules and framework-specific entrypoints explicitly when their native plugin cannot infer them."
53
+ },
54
+ {
55
+ key: "ignoreFiles / ignoreIssues",
56
+ reason: "Exclude reviewed example/fixture files or selected issue types using native Knip patterns. Examples are not silently ignored by this recommendation."
57
+ },
58
+ {
59
+ key: "rules",
60
+ reason: "Use native rules such as { exports: \"warn\", unlisted: \"error\" }; repoctl preserves these severities and does not turn warnings into errors."
61
+ }
62
+ ]
63
+ };
64
+ }
65
+ //#endregion
66
+ export { getKnipConfigurationSuggestions };
@@ -1,59 +1,98 @@
1
- import { A as defaultTemplate, N as resolveCreateNewProjectPlan, j as getCreateChoices, k as createNewProject } from "./commands-CIzCAxyY.mjs";
2
- import { m as logger, u as localize, y as fs } from "./types-m8JLwKzl.mjs";
3
- import { s as resolveCommandConfig } from "./config-p842Knhq.mjs";
1
+ import { St as localize, jt as fs$1 } from "./workspace-tasks-CnB8kkS0.mjs";
2
+ import { f as logger } from "./execute-Vi4qHe-D.mjs";
3
+ import { Dt as createTemplateCatalog, St as resolveCreateNewProjectPlan, bt as createNewProject, kt as loadTemplateCatalogContext, xt as defaultTemplate } from "./commands-TS8ABFdP.mjs";
4
4
  import path from "pathe";
5
5
  import process from "node:process";
6
- import { input, select } from "@icebreakers/monorepo-templates";
6
+ import { readFile } from "node:fs/promises";
7
+ import { input, password, select } from "@icebreakers/monorepo-templates";
7
8
  //#region src/cli/commands/package/intents.ts
8
9
  const createIntentChoices = [
9
10
  {
10
11
  value: "library",
11
12
  name: "Library",
12
13
  description: localize("Create a publishable library package", "创建一个可发布的库包"),
13
- defaultTemplate: "tsdown",
14
- defaultBaseDir: "packages"
14
+ defaultTemplate: "tsdown"
15
15
  },
16
16
  {
17
17
  value: "web-app",
18
18
  name: "Web App",
19
- description: localize("Create a full-stack web application", "创建一个前后端一体的 Web 应用"),
20
- defaultTemplate: "vue-hono",
21
- defaultBaseDir: "apps"
19
+ description: localize("Create a Vue or React web application", "创建 Vue 或 React Web 应用"),
20
+ defaultTemplate: "vue-hono"
22
21
  },
23
22
  {
24
23
  value: "api-service",
25
24
  name: "API Service",
26
25
  description: localize("Create a Hono API service", "创建一个 Hono API 服务"),
27
- defaultTemplate: "hono-server",
28
- defaultBaseDir: "apps"
26
+ defaultTemplate: "hono-server"
29
27
  },
30
28
  {
31
29
  value: "docs-site",
32
30
  name: "Docs Site",
33
31
  description: localize("Create a documentation site", "创建一个文档站点"),
34
- defaultTemplate: "vitepress",
35
- defaultBaseDir: "apps"
32
+ defaultTemplate: "nimbus"
36
33
  },
37
34
  {
38
35
  value: "cli-tool",
39
36
  name: "CLI Tool",
40
37
  description: localize("Create a command-line tool", "创建一个命令行工具"),
41
- defaultTemplate: "cli",
42
- defaultBaseDir: "apps"
38
+ defaultTemplate: "cli"
43
39
  }
44
40
  ];
45
41
  //#endregion
42
+ //#region src/cli/commands/package/parameter-input.ts
43
+ async function readParameterData(cwd, filename) {
44
+ if (!filename) return;
45
+ const contents = await readFile(path.resolve(cwd, filename));
46
+ if (contents.length > 1048576) throw new Error("Template parameter data exceeds 1 MiB.");
47
+ try {
48
+ return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(contents));
49
+ } catch {
50
+ throw new Error("Template parameter data must contain valid UTF-8 JSON.");
51
+ }
52
+ }
53
+ const promptParameter = async (name, definition) => {
54
+ const message = definition.description ?? name;
55
+ if (definition.type === "boolean") return select({
56
+ message,
57
+ choices: [{
58
+ name: "true",
59
+ value: true
60
+ }, {
61
+ name: "false",
62
+ value: false
63
+ }],
64
+ ...definition.default !== void 0 ? { default: definition.default } : {}
65
+ });
66
+ if (definition.type === "enum") return select({
67
+ message,
68
+ choices: definition.options.map((value) => ({
69
+ name: value,
70
+ value
71
+ })),
72
+ ...definition.default !== void 0 ? { default: definition.default } : {}
73
+ });
74
+ const value = definition.sensitive ? await password({
75
+ message,
76
+ mask: "*"
77
+ }) : await input({
78
+ message,
79
+ ...definition.default !== void 0 ? { default: definition.default } : {}
80
+ });
81
+ return value === "" && !definition.required ? void 0 : value;
82
+ };
83
+ //#endregion
46
84
  //#region src/cli/commands/package/create-flow.ts
47
85
  function normalizeTargetName(name, baseDir) {
48
86
  if (name.includes("/")) return name;
49
87
  return `${baseDir}/${name}`;
50
88
  }
51
- function resolveBaseDirFromTemplate(type) {
52
- return createIntentChoices.find((item) => item.defaultTemplate === type)?.defaultBaseDir;
89
+ function resolveBaseDirFromTemplate(type, templates) {
90
+ const baseDir = (type ? templates[type]?.target : void 0)?.split("/")[0];
91
+ return baseDir === "apps" || baseDir === "packages" ? baseDir : void 0;
53
92
  }
54
- function normalizeNameForTemplate(name, type) {
93
+ function normalizeNameForTemplate(name, type, templates) {
55
94
  if (!type) return name;
56
- const baseDir = resolveBaseDirFromTemplate(type);
95
+ const baseDir = resolveBaseDirFromTemplate(type, templates);
57
96
  if (!baseDir) return name;
58
97
  return normalizeTargetName(name, baseDir);
59
98
  }
@@ -70,11 +109,12 @@ function printCreatePlan(plan) {
70
109
  logger.log(localize(` package: ${plan.packageName}`, ` 包名:${plan.packageName}`));
71
110
  logger.log(localize(` package json: ${plan.hasPackageJson ? plan.packageJsonFileName : "not included in template"}`, ` package json:${plan.hasPackageJson ? plan.packageJsonFileName : "模板中未包含"}`));
72
111
  logger.log(localize(` workspace manifest: pnpm-workspace.yaml will include ${plan.targetName.includes("/") ? `${plan.targetName.split("/")[0]}/*` : "packages/*"}`, ` workspace 清单:pnpm-workspace.yaml 将包含 ${plan.targetName.includes("/") ? `${plan.targetName.split("/")[0]}/*` : "packages/*"}`));
112
+ if (plan.parameterization) logger.log(JSON.stringify(plan.parameterization, null, 2));
73
113
  logger.log("");
74
114
  logger.info(localize("Dry run only; no files were written.", "仅执行预览;未写入任何文件。"));
75
115
  }
76
116
  function printCreatePlanJson(plan) {
77
- logger.log(JSON.stringify(plan, null, 2));
117
+ process.stdout.write(`${JSON.stringify(plan, null, 2)}\n`);
78
118
  }
79
119
  function formatCreatePlan(plan) {
80
120
  return [
@@ -85,6 +125,7 @@ function formatCreatePlan(plan) {
85
125
  localize(` package: ${plan.packageName}`, ` 包名:${plan.packageName}`),
86
126
  localize(` package json: ${plan.hasPackageJson ? plan.packageJsonFileName : "not included in template"}`, ` package json:${plan.hasPackageJson ? plan.packageJsonFileName : "模板中未包含"}`),
87
127
  localize(` workspace manifest: pnpm-workspace.yaml will include ${plan.targetName.includes("/") ? `${plan.targetName.split("/")[0]}/*` : "packages/*"}`, ` workspace 清单:pnpm-workspace.yaml 将包含 ${plan.targetName.includes("/") ? `${plan.targetName.split("/")[0]}/*` : "packages/*"}`),
128
+ ...plan.parameterization ? [JSON.stringify(plan.parameterization, null, 2)] : [],
88
129
  "",
89
130
  localize("Dry run only; no files were written.", "仅执行预览;未写入任何文件。")
90
131
  ].join("\n");
@@ -100,12 +141,12 @@ async function emitCreatePlan(plan, options, cwd) {
100
141
  }
101
142
  const content = options.json ? JSON.stringify(plan, null, 2) : formatCreatePlan(plan);
102
143
  const outFile = path.resolve(cwd, options.out);
103
- await fs.outputFile(outFile, `${content}\n`, "utf8");
144
+ await fs$1.outputFile(outFile, `${content}\n`, "utf8");
104
145
  logger.success(localize(`Wrote ${path.relative(cwd, outFile)}`, `已写入 ${path.relative(cwd, outFile)}`));
105
146
  }
106
147
  function handleCreateFlowError(error, json = false) {
107
148
  const message = error instanceof Error ? error.message : String(error);
108
- if (json) logger.log(JSON.stringify({ error: message }, null, 2));
149
+ if (json) process.stdout.write(`${JSON.stringify({ error: message }, null, 2)}\n`);
109
150
  else logger.error(message);
110
151
  process.exitCode = 1;
111
152
  return {
@@ -115,13 +156,33 @@ function handleCreateFlowError(error, json = false) {
115
156
  }
116
157
  async function runCreateFlow(cwd, inputName, options = {}) {
117
158
  try {
118
- const createConfig = await resolveCommandConfig("create", cwd);
119
- const explicitTemplate = options.template ?? createConfig?.type ?? createConfig?.defaultTemplate;
159
+ const context = await loadTemplateCatalogContext({ cwd });
160
+ const createConfig = context.createConfig;
161
+ const parameterValues = await readParameterData(cwd, options.data);
162
+ const sourceOptions = {
163
+ ...parameterValues !== void 0 ? { parameters: parameterValues } : {},
164
+ ...canPrompt() && !options.json ? { parameterPrompt: promptParameter } : {},
165
+ ...options.offline !== void 0 ? { offline: options.offline } : {},
166
+ ...options.cacheDir ? { cacheDir: options.cacheDir } : {}
167
+ };
168
+ const catalog = createTemplateCatalog(context);
169
+ const templates = Object.fromEntries(catalog.entries.map((entry) => [entry.key, entry]));
170
+ let explicitTemplate = options.template ?? createConfig?.type ?? createConfig?.defaultTemplate;
171
+ if (!explicitTemplate && canPrompt() && (catalog.entries.some((entry) => entry.origin === "custom") || createConfig.choices?.length)) {
172
+ const enabled = catalog.choices.filter((choice) => !choice.disabled);
173
+ if (!enabled.length) throw new Error(localize("No enabled templates are available; check commands.create.choices.", "没有可选模板,请检查 commands.create.choices。"));
174
+ explicitTemplate = await select({
175
+ message: localize("Select a template type", "请选择模板类型"),
176
+ choices: catalog.choices,
177
+ default: enabled.find((choice) => choice.value === "tsdown")?.value ?? enabled[0].value
178
+ });
179
+ }
120
180
  let packageName = inputName;
121
181
  if (!explicitTemplate && !canPrompt()) {
122
182
  const type = defaultTemplate;
123
183
  const createOptions = {
124
- name: normalizeNameForTemplate(packageName ?? createConfig?.name ?? "my-package", type),
184
+ ...sourceOptions,
185
+ name: normalizeNameForTemplate(packageName ?? createConfig?.name ?? "my-package", type, templates),
125
186
  cwd,
126
187
  type
127
188
  };
@@ -145,21 +206,22 @@ async function runCreateFlow(cwd, inputName, options = {}) {
145
206
  default: "my-module"
146
207
  });
147
208
  let type = intentChoice.defaultTemplate;
148
- if (intent === "library") type = await select({
149
- message: localize("Select a library template", "请选择库模板"),
150
- choices: [{
151
- name: "TypeScript Library",
152
- value: "tsdown",
153
- description: localize("General-purpose TypeScript library", "通用 TypeScript 库")
154
- }, {
155
- name: "Vue Component Library",
156
- value: "vue-lib",
157
- description: localize("Vue component library", "Vue 组件库")
158
- }],
159
- default: "tsdown"
209
+ const categories = {
210
+ "library": "library",
211
+ "web-app": "app",
212
+ "api-service": "service",
213
+ "docs-site": "docs",
214
+ "cli-tool": "tool"
215
+ };
216
+ const choices = catalog.choices.filter((choice) => catalog.entries.find((entry) => entry.key === choice.value)?.category === categories[intent]);
217
+ if ((intent === "library" || intent === "web-app") && choices.length > 1) type = await select({
218
+ message: localize("Select a template type", "请选择模板类型"),
219
+ choices,
220
+ default: intentChoice.defaultTemplate
160
221
  });
161
222
  const createOptions = {
162
- name: normalizeTargetName(packageName, intentChoice.defaultBaseDir),
223
+ ...sourceOptions,
224
+ name: normalizeNameForTemplate(packageName, type, templates),
163
225
  cwd,
164
226
  ...type !== void 0 ? { type } : {}
165
227
  };
@@ -177,11 +239,12 @@ async function runCreateFlow(cwd, inputName, options = {}) {
177
239
  });
178
240
  const type = explicitTemplate ?? await select({
179
241
  message: localize("Select a template type", "请选择模板类型"),
180
- choices: getCreateChoices(createConfig?.choices),
242
+ choices: catalog.choices,
181
243
  default: "tsdown"
182
244
  });
183
245
  const createOptions = {
184
- name: normalizeNameForTemplate(packageName, type),
246
+ ...sourceOptions,
247
+ name: normalizeNameForTemplate(packageName, type, templates),
185
248
  cwd,
186
249
  ...type !== void 0 ? { type } : {}
187
250
  };
@@ -0,0 +1,47 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
2
+ import { Ht as clearWorkspaceCache, St as localize } from "./workspace-tasks-CnB8kkS0.mjs";
3
+ import { t as scanDependencies } from "./scan-4nboHNXP.mjs";
4
+ import { a as prepareDependencyFix, i as dependencyNextSteps, n as inspectDependencyPlanInputs, o as dependencyReport, r as validateDependencyPlan, t as writeDependencyTransaction } from "./transaction-DAhY8EpG.mjs";
5
+ import { isDeepStrictEqual } from "node:util";
6
+ //#region src/commands/deps/apply.ts
7
+ async function applyDependencyFixPlan(cwd, plan) {
8
+ validateDependencyPlan(plan);
9
+ const scan = await scanDependencies(cwd);
10
+ if (inspectDependencyPlanInputs(scan, plan)) return {
11
+ status: "unchanged",
12
+ changed: [],
13
+ nextSteps: [...dependencyNextSteps]
14
+ };
15
+ const prepared = prepareDependencyFix(scan, plan.selection);
16
+ if (!isDeepStrictEqual(prepared.plan.files, plan.files)) throw new Error(localize("The proposed changes no longer match the selected dependency policy.", "计划中的变更不再符合所选依赖策略。"));
17
+ if (!prepared.updates.length) return {
18
+ status: "unchanged",
19
+ changed: [],
20
+ nextSteps: [...dependencyNextSteps]
21
+ };
22
+ try {
23
+ await writeDependencyTransaction(scan.workspaceDir, prepared.updates);
24
+ } finally {
25
+ clearWorkspaceCache();
26
+ }
27
+ return {
28
+ status: "applied",
29
+ changed: plan.files.map((file) => file.path),
30
+ nextSteps: [...dependencyNextSteps]
31
+ };
32
+ }
33
+ //#endregion
34
+ //#region src/commands/deps/index.ts
35
+ var deps_exports = /* @__PURE__ */ __exportAll({
36
+ applyDependencyFixPlan: () => applyDependencyFixPlan,
37
+ checkDependencies: () => checkDependencies,
38
+ planDependencyFix: () => planDependencyFix
39
+ });
40
+ async function checkDependencies(cwd) {
41
+ return dependencyReport(await scanDependencies(cwd));
42
+ }
43
+ async function planDependencyFix(cwd, options) {
44
+ return prepareDependencyFix(await scanDependencies(cwd), options).plan;
45
+ }
46
+ //#endregion
47
+ export { applyDependencyFixPlan as i, deps_exports as n, planDependencyFix as r, checkDependencies as t };
@@ -0,0 +1,68 @@
1
+ import { St as localize, jt as fs } from "./workspace-tasks-CnB8kkS0.mjs";
2
+ import { f as logger, t as runCheckWithReport } from "./execute-Vi4qHe-D.mjs";
3
+ import { t as formatAffectedCheckPlan } from "./cli.mjs";
4
+ import path from "pathe";
5
+ import process from "node:process";
6
+ import os from "node:os";
7
+ //#region src/cli/commands/check/report.ts
8
+ function createCheckReportOutput(report, format, redact = false) {
9
+ let serialized = JSON.stringify(report);
10
+ if (redact) {
11
+ const replacements = [[report.cwd, "<cwd>"], [os.homedir(), "<home>"]];
12
+ for (const [value, replacement] of replacements.sort(([a], [b]) => b.length - a.length)) if (value) serialized = serialized.split(JSON.stringify(value).slice(1, -1)).join(replacement);
13
+ }
14
+ const output = JSON.parse(serialized);
15
+ if (format === "json") return JSON.stringify(output, null, 2);
16
+ const cell = (value) => String(value ?? "-").replaceAll("|", "\\|").replaceAll("\n", "<br>");
17
+ return [
18
+ "# Repo check execution report",
19
+ "",
20
+ `- Mode: ${output.mode}`,
21
+ `- Status: ${output.status}`,
22
+ `- Directory: ${output.cwd}`,
23
+ `- Started: ${output.startedAt}`,
24
+ `- Ended: ${output.endedAt}`,
25
+ `- Duration: ${output.durationMs.toFixed(1)} ms`,
26
+ `- Exit code: ${output.exitCode}`,
27
+ "",
28
+ "| Task | Command | Status | Duration (ms) | Exit code | Signal | Reason |",
29
+ "| --- | --- | --- | ---: | ---: | --- | --- |",
30
+ ...output.tasks.map((task) => `| ${[
31
+ task.name,
32
+ [task.executable, ...task.args].join(" "),
33
+ task.status,
34
+ task.durationMs.toFixed(1),
35
+ task.exitCode,
36
+ task.signal,
37
+ task.reason ?? task.errorCode
38
+ ].map(cell).join(" | ")} |`),
39
+ ...output.affectedPlan ? ["", formatAffectedCheckPlan(output.affectedPlan, true)] : []
40
+ ].join("\n");
41
+ }
42
+ //#endregion
43
+ //#region src/cli/commands/check/execute.ts
44
+ async function runCheckExecution(options, reportFile, format = "json", redact) {
45
+ const controller = new AbortController();
46
+ const onInterrupt = () => controller.abort("SIGINT");
47
+ const onTerminate = () => controller.abort("SIGTERM");
48
+ const outFile = reportFile ? path.resolve(options.cwd, reportFile) : void 0;
49
+ process.on("SIGINT", onInterrupt);
50
+ process.on("SIGTERM", onTerminate);
51
+ try {
52
+ const report = await runCheckWithReport({
53
+ ...options,
54
+ signal: controller.signal
55
+ });
56
+ if (outFile) {
57
+ await fs.outputFile(outFile, `${createCheckReportOutput(report, format, redact)}\n`, "utf8");
58
+ logger.info(localize(`Wrote ${path.relative(options.cwd, outFile)}`, `已写入 ${path.relative(options.cwd, outFile)}`));
59
+ }
60
+ process.exitCode = report.exitCode;
61
+ if (report.status === "success") logger.success(localize("Checks finished.", "检查完成。"));
62
+ } finally {
63
+ process.removeListener("SIGINT", onInterrupt);
64
+ process.removeListener("SIGTERM", onTerminate);
65
+ }
66
+ }
67
+ //#endregion
68
+ export { runCheckExecution };