mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-22 13:18:09 +00:00
fix(docs): require sync provenance values
This commit is contained in:
@@ -170,7 +170,15 @@ const GENERATED_LOCALES = [
|
||||
},
|
||||
];
|
||||
|
||||
function parseArgs(argv) {
|
||||
function readOptionValue(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 args = {
|
||||
target: "",
|
||||
sourceRepo: "",
|
||||
@@ -185,27 +193,27 @@ function parseArgs(argv) {
|
||||
const part = argv[index];
|
||||
switch (part) {
|
||||
case "--target":
|
||||
args.target = argv[index + 1] ?? "";
|
||||
args.target = readOptionValue(argv, index, part);
|
||||
index += 1;
|
||||
break;
|
||||
case "--source-repo":
|
||||
args.sourceRepo = argv[index + 1] ?? "";
|
||||
args.sourceRepo = readOptionValue(argv, index, part);
|
||||
index += 1;
|
||||
break;
|
||||
case "--source-sha":
|
||||
args.sourceSha = argv[index + 1] ?? "";
|
||||
args.sourceSha = readOptionValue(argv, index, part);
|
||||
index += 1;
|
||||
break;
|
||||
case "--clawhub-repo":
|
||||
args.clawhubRepo = argv[index + 1] ?? "";
|
||||
args.clawhubRepo = readOptionValue(argv, index, part);
|
||||
index += 1;
|
||||
break;
|
||||
case "--clawhub-source-repo":
|
||||
args.clawhubSourceRepo = argv[index + 1] ?? "";
|
||||
args.clawhubSourceRepo = readOptionValue(argv, index, part);
|
||||
index += 1;
|
||||
break;
|
||||
case "--clawhub-source-sha":
|
||||
args.clawhubSourceSha = argv[index + 1] ?? "";
|
||||
args.clawhubSourceSha = readOptionValue(argv, index, part);
|
||||
index += 1;
|
||||
break;
|
||||
default:
|
||||
|
||||
46
test/scripts/docs-sync-publish.test.ts
Normal file
46
test/scripts/docs-sync-publish.test.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { parseArgs } from "../../scripts/docs-sync-publish.mjs";
|
||||
|
||||
describe("docs-sync-publish", () => {
|
||||
it("parses docs sync provenance args", () => {
|
||||
expect(
|
||||
parseArgs([
|
||||
"--target",
|
||||
"generated-docs",
|
||||
"--source-repo",
|
||||
"openclaw/openclaw",
|
||||
"--source-sha",
|
||||
"abc123",
|
||||
"--clawhub-repo",
|
||||
"../clawhub",
|
||||
"--clawhub-source-repo",
|
||||
"openclaw/clawhub",
|
||||
"--clawhub-source-sha",
|
||||
"def456",
|
||||
]),
|
||||
).toMatchObject({
|
||||
clawhubRepo: "../clawhub",
|
||||
clawhubSourceRepo: "openclaw/clawhub",
|
||||
clawhubSourceSha: "def456",
|
||||
sourceRepo: "openclaw/openclaw",
|
||||
sourceSha: "abc123",
|
||||
target: "generated-docs",
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects missing docs sync option values", () => {
|
||||
for (const flag of [
|
||||
"--target",
|
||||
"--source-repo",
|
||||
"--source-sha",
|
||||
"--clawhub-repo",
|
||||
"--clawhub-source-repo",
|
||||
"--clawhub-source-sha",
|
||||
]) {
|
||||
expect(() => parseArgs([flag])).toThrow(`${flag} requires a value`);
|
||||
expect(() => parseArgs([flag, "--target", "generated-docs"])).toThrow(
|
||||
`${flag} requires a value`,
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user