mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-22 10:08:15 +00:00
fix(report): require ownership markdown path
This commit is contained in:
@@ -397,7 +397,15 @@ function printTextReport(report) {
|
||||
process.stdout.write(renderTextReport(report));
|
||||
}
|
||||
|
||||
function parseArgs(argv) {
|
||||
function readArtifactPath(argv, index, optionName) {
|
||||
const value = argv[index + 1];
|
||||
if (value === undefined || value === "" || value.startsWith("--")) {
|
||||
throw new Error(`${optionName} requires a value`);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
export function parseArgs(argv) {
|
||||
const options = {
|
||||
asJson: false,
|
||||
check: false,
|
||||
@@ -421,7 +429,8 @@ function parseArgs(argv) {
|
||||
continue;
|
||||
}
|
||||
if (arg === "--markdown") {
|
||||
options.markdownPath = argv[++index];
|
||||
options.markdownPath = readArtifactPath(argv, index, arg);
|
||||
index += 1;
|
||||
continue;
|
||||
}
|
||||
throw new Error(`Unsupported argument: ${arg}`);
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
collectDependencyOwnershipSurfaceCheckErrors,
|
||||
collectDependencyOwnershipSurfaceReport,
|
||||
packageNameFromLockKey,
|
||||
parseArgs,
|
||||
renderDependencyOwnershipSurfaceMarkdownReport,
|
||||
} from "../../scripts/dependency-ownership-surface-report.mjs";
|
||||
|
||||
@@ -37,6 +38,25 @@ describe("packageNameFromLockKey", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("parseArgs", () => {
|
||||
it("rejects missing markdown artifact paths", () => {
|
||||
expect(() => parseArgs(["--markdown"])).toThrow("--markdown requires a value");
|
||||
expect(() => parseArgs(["--markdown", "--json"])).toThrow("--markdown requires a value");
|
||||
expect(() => parseArgs(["--markdown", ""])).toThrow("--markdown requires a value");
|
||||
});
|
||||
|
||||
it("keeps json as a boolean or optional artifact path", () => {
|
||||
expect(parseArgs(["--json"])).toMatchObject({
|
||||
asJson: true,
|
||||
jsonPath: null,
|
||||
});
|
||||
expect(parseArgs(["--json", "report.json"])).toMatchObject({
|
||||
asJson: true,
|
||||
jsonPath: "report.json",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("collectDependencyOwnershipSurfaceReport", () => {
|
||||
it("reports root dependency reachability, install-surface packages, and ownership metadata gaps", () => {
|
||||
const repoRoot = makeTempRepo();
|
||||
|
||||
Reference in New Issue
Block a user