Merge remote-tracking branch 'origin/main' into mac15/rule-import-renumber

This commit is contained in:
gitea committed 2026-10-13 11:30:28 +08:00
commit 75017ab49c
37 files changed
+2138 -604

No files matched your search

+32 -9
View File
@@ -4,15 +4,22 @@ import { runCapabilityResult } from "../helpers.js";
import { booleanOption, numberOption, stringOption } from "../parser.js";
import { outputOptions, printJson } from "../printer.js";
import { CliError, usageError } from "../../core/errors.js";
import { renderReportFile, saveReportMarkdown, validateReportFile } from "../../domains/seal/reports/files.js";
import type { MonthlyReportResult } from "../../domains/seal/reports/monthly.js";
import { loadReviews, reviewFilePath, writeReview } from "../../domains/seal/reports/review-store.js";
import {
exportReportPackage,
renderReportFile,
saveReportMarkdown,
validateReportFile,
loadReviews,
reviewFilePath,
writeReview,
type MonthlyReportResult
} from "../../domains/seal/reports/index.js";
import type { ParsedArgs } from "../types.js";
/** Tenant-free commands: dispatch these before resolving enterprise configuration or authentication. */
export async function handleLocalReportCommand(action: "validate" | "render", args: ParsedArgs) {
export async function handleLocalReportCommand(action: "validate" | "render" | "export", args: ParsedArgs) {
const file = args.command[2] ?? stringOption(args.options.file);
if (!file) throw usageError(`Usage: seal-use report ${action} <报告文件.md>${action === "render" ? " --out <产物路径词干>" : ""}`);
if (!file) throw usageError(`Usage: seal-use report ${action} <报告文件.md>${action === "render" ? " --out <产物路径词干>" : action === "export" ? " --out <目标文件夹>" : ""}`);
if ("python" in args.options) throw usageError("报告工具已移除 Python 依赖,请去掉 --python 参数。");
if (action === "validate") {
const result = await validateReportFile(file);
@@ -21,7 +28,16 @@ export async function handleLocalReportCommand(action: "validate" | "render", ar
return;
}
const out = stringOption(args.options.out) ?? stringOption(args.options.o);
if (!out) throw usageError("Usage: seal-use report render <报告文件.md> --out <产物路径词干>");
if (!out) throw usageError(`Usage: seal-use report ${action} <报告文件.md> --out <${action === "export" ? "目标文件夹" : "产物路径词干"}>`);
if (action === "export") {
const result = await exportReportPackage(file, {
out, format: stringOption(args.options.format), width: numberOption(args.options.width),
chrome: stringOption(args.options.chrome), overwrite: booleanOption(args.options.overwrite)
});
printJson(result, outputOptions(args.options));
if (!result.validation.valid) throw new CliError("报告校验未通过,未生成完整导出包。请按 validation.issues 修正后重试。", 1);
return;
}
const result = await renderReportFile(file, {
out, format: stringOption(args.options.format), width: numberOption(args.options.width),
chrome: stringOption(args.options.chrome), overwrite: booleanOption(args.options.overwrite)
@@ -55,13 +71,20 @@ export async function handleReportCommand(
) as MonthlyReportResult;
const out = stringOption(args.options.out) ?? stringOption(args.options.o);
if (out) {
const saved = saveReportMarkdown(result.content, result.templatePath, out, booleanOption(args.options.overwrite));
const saved = saveReportMarkdown(
result.content,
result.templatePath,
out,
booleanOption(args.options.overwrite),
result.dynamicAssets,
result.companionFiles
);
const quotedFile = `'${saved.file.replace(/'/g, "'\\''")}'`;
printJson({ ...result, content: undefined, ...saved, next: {
printJson({ ...result, content: undefined, dynamicAssets: undefined, companionFiles: undefined, ...saved, next: {
validate: `seal-use report validate ${quotedFile}`,
render: `seal-use report render ${quotedFile} --out build/report`
} }, outputOptions(args.options));
} else printJson(result, outputOptions(args.options));
} else printJson({ ...result, dynamicAssets: undefined, companionFiles: undefined }, outputOptions(args.options));
return;
}