@@ -358,6 +358,28 @@ function readPackedPackageReadme(packageDir, files) {
|
358 | 358 | return fs.readFileSync(path.join(packageDir, readmePath), "utf8").trim(); |
359 | 359 | } |
360 | 360 | |
| 361 | +export function usage() { |
| 362 | +return "Usage: node scripts/verify-plugin-npm-published-runtime.mjs <package-spec>"; |
| 363 | +} |
| 364 | + |
| 365 | +export function parseVerifyPublishedPluginRuntimeArgs(argv) { |
| 366 | +const args = argv[0] === "--" ? argv.slice(1) : argv; |
| 367 | +const first = args[0]?.trim(); |
| 368 | +if (first === "--help" || first === "-h") { |
| 369 | +return { help: true, spec: "" }; |
| 370 | +} |
| 371 | +if (!first) { |
| 372 | +throw new Error(usage()); |
| 373 | +} |
| 374 | +if (first.startsWith("-")) { |
| 375 | +throw new Error(`Unknown plugin npm verifier option: ${first}`); |
| 376 | +} |
| 377 | +if (args.length > 1) { |
| 378 | +throw new Error(`Unexpected plugin npm verifier argument: ${args[1]}`); |
| 379 | +} |
| 380 | +return { help: false, spec: first }; |
| 381 | +} |
| 382 | + |
361 | 383 | export async function verifyPublishedPluginRuntime(spec) { |
362 | 384 | const workingDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-plugin-npm-runtime.")); |
363 | 385 | try { |
@@ -396,11 +418,12 @@ export async function verifyPublishedPluginRuntime(spec) {
|
396 | 418 | } |
397 | 419 | |
398 | 420 | async function main(argv) { |
399 | | -const spec = argv[0]?.trim(); |
400 | | -if (!spec) { |
401 | | -throw new Error("Usage: node scripts/verify-plugin-npm-published-runtime.mjs <package-spec>"); |
| 421 | +const args = parseVerifyPublishedPluginRuntimeArgs(argv); |
| 422 | +if (args.help) { |
| 423 | +console.log(usage()); |
| 424 | +return; |
402 | 425 | } |
403 | | -const result = await verifyPublishedPluginRuntime(spec); |
| 426 | +const result = await verifyPublishedPluginRuntime(args.spec); |
404 | 427 | console.log( |
405 | 428 | `plugin-npm-published-runtime-check: ${result.packageName}@${result.version} OK (${result.fileCount} files, ${result.readmeLength} readme chars)`, |
406 | 429 | ); |
|