@icebreakers/monorepo 5.6.0 → 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.
- package/README.md +2 -0
- package/dist/baseline-DPfotf4y.mjs +146 -0
- package/dist/bundle-B9vRch4R.mjs +49 -0
- package/dist/catalog-CDEyc1uA.mjs +299 -0
- package/dist/cli.mjs +1487 -156
- package/dist/commands-TS8ABFdP.mjs +13820 -0
- package/dist/config-C38c_Q8L.mjs +66 -0
- package/dist/{create-flow-CXRhfGbb.mjs → create-flow-CCr2hfSY.mjs} +90 -24
- package/dist/deps-CUdI2DaB.mjs +47 -0
- package/dist/execute-PX1hT0qv.mjs +68 -0
- package/dist/execute-Vi4qHe-D.mjs +663 -0
- package/dist/format-DZ7L34rf.mjs +28 -0
- package/dist/index-CoCTFWZJ.d.mts +2150 -0
- package/dist/index.d.mts +1738 -112
- package/dist/index.mjs +60 -7
- package/dist/inputs-_xIVONmB.mjs +50 -0
- package/dist/npm-B25nrSyz.mjs +82 -0
- package/dist/plan-B5aE_WNF.mjs +75 -0
- package/dist/run-Lu7y1bNf.mjs +165 -0
- package/dist/save-CdCf630Z.mjs +79 -0
- package/dist/scan-4nboHNXP.mjs +293 -0
- package/dist/template-drift-BBhnrHY1.mjs +2740 -0
- package/dist/tooling-entry.d.mts +1 -1
- package/dist/tooling-entry.mjs +2 -2
- package/dist/transaction-DAhY8EpG.mjs +168 -0
- package/dist/tsconfig-CGntrzBM.mjs +1483 -0
- package/dist/{vitest-Blzbh8xZ.mjs → vitest-DkGh4Ygo.mjs} +1 -1
- package/dist/workspace-tasks-CnB8kkS0.mjs +4435 -0
- package/package.json +22 -4
- package/resources/api-report/runner.cjs +76 -0
- package/resources/devcontainer/setup.mjs +36 -0
- package/resources/knip/reporter.mjs +46 -0
- package/resources/maintenance/migration-lanes.mjs +141 -0
- package/resources/maintenance/migration-lock.mjs +119 -0
- package/resources/maintenance/migrations.mjs +215 -0
- package/resources/maintenance/presets.mjs +130 -0
- package/resources/maintenance/validate.mjs +233 -0
- package/resources/maintenance/workflow.yml +151 -0
- package/resources/skills/repoctl/SKILL.md +2 -0
- package/resources/skills/repoctl/references/commands.md +224 -13
- package/resources/skills/repoctl/references/config.md +70 -6
- package/resources/skills/repoctl/references/dependencies.md +37 -0
- package/resources/skills/repoctl/references/knip.md +34 -0
- package/resources/skills/repoctl/references/templates.md +23 -0
- package/dist/commands-D4xZQ5t-.mjs +0 -5685
- package/dist/config-p842Knhq.mjs +0 -114
- package/dist/index-Bl_PB2Ch.d.mts +0 -1039
- package/dist/tsconfig-BrjI_5yI.mjs +0 -75
- package/dist/types-MAUIQpfp.mjs +0 -499
- 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,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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 {
|
|
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
|
{
|
|
@@ -15,7 +16,7 @@ const createIntentChoices = [
|
|
|
15
16
|
{
|
|
16
17
|
value: "web-app",
|
|
17
18
|
name: "Web App",
|
|
18
|
-
description: localize("Create a
|
|
19
|
+
description: localize("Create a Vue or React web application", "创建 Vue 或 React Web 应用"),
|
|
19
20
|
defaultTemplate: "vue-hono"
|
|
20
21
|
},
|
|
21
22
|
{
|
|
@@ -38,6 +39,48 @@ const createIntentChoices = [
|
|
|
38
39
|
}
|
|
39
40
|
];
|
|
40
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
|
|
41
84
|
//#region src/cli/commands/package/create-flow.ts
|
|
42
85
|
function normalizeTargetName(name, baseDir) {
|
|
43
86
|
if (name.includes("/")) return name;
|
|
@@ -66,11 +109,12 @@ function printCreatePlan(plan) {
|
|
|
66
109
|
logger.log(localize(` package: ${plan.packageName}`, ` 包名:${plan.packageName}`));
|
|
67
110
|
logger.log(localize(` package json: ${plan.hasPackageJson ? plan.packageJsonFileName : "not included in template"}`, ` package json:${plan.hasPackageJson ? plan.packageJsonFileName : "模板中未包含"}`));
|
|
68
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));
|
|
69
113
|
logger.log("");
|
|
70
114
|
logger.info(localize("Dry run only; no files were written.", "仅执行预览;未写入任何文件。"));
|
|
71
115
|
}
|
|
72
116
|
function printCreatePlanJson(plan) {
|
|
73
|
-
|
|
117
|
+
process.stdout.write(`${JSON.stringify(plan, null, 2)}\n`);
|
|
74
118
|
}
|
|
75
119
|
function formatCreatePlan(plan) {
|
|
76
120
|
return [
|
|
@@ -81,6 +125,7 @@ function formatCreatePlan(plan) {
|
|
|
81
125
|
localize(` package: ${plan.packageName}`, ` 包名:${plan.packageName}`),
|
|
82
126
|
localize(` package json: ${plan.hasPackageJson ? plan.packageJsonFileName : "not included in template"}`, ` package json:${plan.hasPackageJson ? plan.packageJsonFileName : "模板中未包含"}`),
|
|
83
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)] : [],
|
|
84
129
|
"",
|
|
85
130
|
localize("Dry run only; no files were written.", "仅执行预览;未写入任何文件。")
|
|
86
131
|
].join("\n");
|
|
@@ -96,12 +141,12 @@ async function emitCreatePlan(plan, options, cwd) {
|
|
|
96
141
|
}
|
|
97
142
|
const content = options.json ? JSON.stringify(plan, null, 2) : formatCreatePlan(plan);
|
|
98
143
|
const outFile = path.resolve(cwd, options.out);
|
|
99
|
-
await fs.outputFile(outFile, `${content}\n`, "utf8");
|
|
144
|
+
await fs$1.outputFile(outFile, `${content}\n`, "utf8");
|
|
100
145
|
logger.success(localize(`Wrote ${path.relative(cwd, outFile)}`, `已写入 ${path.relative(cwd, outFile)}`));
|
|
101
146
|
}
|
|
102
147
|
function handleCreateFlowError(error, json = false) {
|
|
103
148
|
const message = error instanceof Error ? error.message : String(error);
|
|
104
|
-
if (json)
|
|
149
|
+
if (json) process.stdout.write(`${JSON.stringify({ error: message }, null, 2)}\n`);
|
|
105
150
|
else logger.error(message);
|
|
106
151
|
process.exitCode = 1;
|
|
107
152
|
return {
|
|
@@ -111,13 +156,32 @@ function handleCreateFlowError(error, json = false) {
|
|
|
111
156
|
}
|
|
112
157
|
async function runCreateFlow(cwd, inputName, options = {}) {
|
|
113
158
|
try {
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
const
|
|
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
|
+
}
|
|
117
180
|
let packageName = inputName;
|
|
118
181
|
if (!explicitTemplate && !canPrompt()) {
|
|
119
182
|
const type = defaultTemplate;
|
|
120
183
|
const createOptions = {
|
|
184
|
+
...sourceOptions,
|
|
121
185
|
name: normalizeNameForTemplate(packageName ?? createConfig?.name ?? "my-package", type, templates),
|
|
122
186
|
cwd,
|
|
123
187
|
type
|
|
@@ -142,20 +206,21 @@ async function runCreateFlow(cwd, inputName, options = {}) {
|
|
|
142
206
|
default: "my-module"
|
|
143
207
|
});
|
|
144
208
|
let type = intentChoice.defaultTemplate;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
default:
|
|
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
|
|
157
221
|
});
|
|
158
222
|
const createOptions = {
|
|
223
|
+
...sourceOptions,
|
|
159
224
|
name: normalizeNameForTemplate(packageName, type, templates),
|
|
160
225
|
cwd,
|
|
161
226
|
...type !== void 0 ? { type } : {}
|
|
@@ -174,10 +239,11 @@ async function runCreateFlow(cwd, inputName, options = {}) {
|
|
|
174
239
|
});
|
|
175
240
|
const type = explicitTemplate ?? await select({
|
|
176
241
|
message: localize("Select a template type", "请选择模板类型"),
|
|
177
|
-
choices:
|
|
242
|
+
choices: catalog.choices,
|
|
178
243
|
default: "tsdown"
|
|
179
244
|
});
|
|
180
245
|
const createOptions = {
|
|
246
|
+
...sourceOptions,
|
|
181
247
|
name: normalizeNameForTemplate(packageName, type, templates),
|
|
182
248
|
cwd,
|
|
183
249
|
...type !== void 0 ? { type } : {}
|
|
@@ -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 };
|