soustack 0.5.4 → 0.5.5

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/dist/bin/cli.js CHANGED
@@ -6271,20 +6271,93 @@ Profiles: ${supportedProfiles.join(", ")}`);
6271
6271
  console.log(" validate Validate recipe files against schema and conformance rules");
6272
6272
  console.log("--- COMMANDS END ---");
6273
6273
  }
6274
- function hasHelpFlag(args) {
6274
+ function wantsHelp(args) {
6275
6275
  return args.includes("--help") || args.includes("-h");
6276
6276
  }
6277
- function printCommandHelp(command, usage, description) {
6278
- console.log(`Usage: soustack ${usage}`);
6279
- if (description) {
6280
- console.log(`
6281
- ${description}`);
6277
+ function printCommandHelp(cmd) {
6278
+ switch (cmd) {
6279
+ case "check":
6280
+ console.log("Usage: soustack check <file> --json");
6281
+ console.log("\nGenerate JSON conformance report for a recipe file.");
6282
+ console.log("\nOptions:");
6283
+ console.log(" --json Output results as JSON");
6284
+ console.log("\nExample:");
6285
+ console.log(" soustack check recipe.soustack.json --json");
6286
+ break;
6287
+ case "validate":
6288
+ console.log("Usage: soustack validate <fileOrGlob> [options]");
6289
+ console.log("\nValidate recipe files against schema and conformance rules.");
6290
+ console.log("\nOptions:");
6291
+ console.log(" --profile <name> Validate against a specific profile");
6292
+ console.log(" --force-profile Override recipe profile with --profile value");
6293
+ console.log(" --schema-only Only validate against JSON schema");
6294
+ console.log(" --strict Treat warnings as errors");
6295
+ console.log(" --json Output results as JSON");
6296
+ console.log("\nExample:");
6297
+ console.log(' soustack validate "**/*.soustack.json" --profile scalable --strict');
6298
+ break;
6299
+ case "test":
6300
+ console.log("Usage: soustack test [options]");
6301
+ console.log("\nValidate all recipes in the repository.");
6302
+ console.log("\nOptions:");
6303
+ console.log(" --profile <name> Validate against a specific profile");
6304
+ console.log(" --force-profile Override recipe profile with --profile value");
6305
+ console.log(" --schema-only Only validate against JSON schema");
6306
+ console.log(" --strict Treat warnings as errors");
6307
+ console.log(" --json Output results as JSON");
6308
+ console.log("\nExample:");
6309
+ console.log(" soustack test --profile base --strict");
6310
+ break;
6311
+ case "convert":
6312
+ console.log("Usage: soustack convert --from <schemaorg|soustack> --to <schemaorg|soustack> <input> [-o <output>]");
6313
+ console.log("\nConvert between Schema.org and Soustack formats.");
6314
+ console.log("\nOptions:");
6315
+ console.log(" --from <format> Source format: schemaorg or soustack");
6316
+ console.log(" --to <format> Target format: schemaorg or soustack");
6317
+ console.log(" -o, --output <path> Output file path (default: stdout)");
6318
+ console.log("\nExample:");
6319
+ console.log(" soustack convert --from schemaorg --to soustack recipe.json -o recipe.soustack.json");
6320
+ break;
6321
+ case "import":
6322
+ console.log("Usage: soustack import --url <url> [-o <soustack.json>]");
6323
+ console.log("\nImport recipe from URL (alias for scrape).");
6324
+ console.log("\nOptions:");
6325
+ console.log(" --url <url> URL of the recipe to import");
6326
+ console.log(" -o, --output <path> Output file path (default: stdout)");
6327
+ console.log("\nExample:");
6328
+ console.log(" soustack import --url https://example.com/recipe -o recipe.soustack.json");
6329
+ break;
6330
+ case "ingest":
6331
+ console.log("Usage: soustack ingest <input> [--out <path>]");
6332
+ console.log("\nBulk pipeline for processing multiple recipes (requires @soustack/ingest).");
6333
+ console.log("\nOptions:");
6334
+ console.log(" --out <path> Output directory or file path");
6335
+ console.log("\nExample:");
6336
+ console.log(" soustack ingest recipes/ --out output/");
6337
+ break;
6338
+ case "scale":
6339
+ console.log("Usage: soustack scale <soustack.json> <multiplier>");
6340
+ console.log("\nScale a recipe by a multiplier.");
6341
+ console.log("\nArguments:");
6342
+ console.log(" <soustack.json> Path to the recipe file");
6343
+ console.log(" <multiplier> Scaling factor (e.g., 2 for double, 0.5 for half)");
6344
+ console.log("\nExample:");
6345
+ console.log(" soustack scale recipe.soustack.json 2");
6346
+ break;
6347
+ case "scrape":
6348
+ console.log("Usage: soustack scrape <url> [-o <soustack.json>]");
6349
+ console.log("\nScrape recipe from a URL (canonical URL ingestion).");
6350
+ console.log("\nOptions:");
6351
+ console.log(" -o, --output <path> Output file path (default: stdout)");
6352
+ console.log("\nExample:");
6353
+ console.log(" soustack scrape https://example.com/recipe -o recipe.soustack.json");
6354
+ break;
6282
6355
  }
6283
6356
  process.exitCode = 0;
6284
6357
  }
6285
6358
  async function handleCheck(args) {
6286
- if (hasHelpFlag(args)) {
6287
- printCommandHelp("check", "check <file> --json", "Generate JSON conformance report for a recipe file");
6359
+ if (wantsHelp(args)) {
6360
+ printCommandHelp("check");
6288
6361
  return;
6289
6362
  }
6290
6363
  const { target, json } = parseCheckArgs(args);
@@ -6309,12 +6382,8 @@ async function handleCheck(args) {
6309
6382
  }
6310
6383
  }
6311
6384
  async function handleValidate(args) {
6312
- if (hasHelpFlag(args)) {
6313
- printCommandHelp(
6314
- "validate",
6315
- "validate <fileOrGlob> [--profile <name>] [--force-profile] [--schema-only] [--strict] [--json]",
6316
- "Validate recipe files against schema and conformance rules"
6317
- );
6385
+ if (wantsHelp(args)) {
6386
+ printCommandHelp("validate");
6318
6387
  return;
6319
6388
  }
6320
6389
  const { target, profile, forceProfile, strict, json, mode } = parseValidateArgs(args);
@@ -6325,12 +6394,8 @@ async function handleValidate(args) {
6325
6394
  reportValidation(results, { strict, json});
6326
6395
  }
6327
6396
  async function handleTest(args) {
6328
- if (hasHelpFlag(args)) {
6329
- printCommandHelp(
6330
- "test",
6331
- "test [--profile <name>] [--force-profile] [--schema-only] [--strict] [--json]",
6332
- "Validate all recipes in the repository"
6333
- );
6397
+ if (wantsHelp(args)) {
6398
+ printCommandHelp("test");
6334
6399
  return;
6335
6400
  }
6336
6401
  const { profile, forceProfile, strict, json, mode } = parseValidationFlags(args);
@@ -6349,12 +6414,8 @@ async function handleTest(args) {
6349
6414
  reportValidation(results, { strict, json, context: "test" });
6350
6415
  }
6351
6416
  async function handleConvert(args) {
6352
- if (hasHelpFlag(args)) {
6353
- printCommandHelp(
6354
- "convert",
6355
- "convert --from <schemaorg|soustack> --to <schemaorg|soustack> <input> [-o <output>]",
6356
- "Convert between Schema.org and Soustack formats"
6357
- );
6417
+ if (wantsHelp(args)) {
6418
+ printCommandHelp("convert");
6358
6419
  return;
6359
6420
  }
6360
6421
  const { from, to, inputPath, outputPath } = parseConvertArgs(args);
@@ -6376,12 +6437,8 @@ async function handleConvert(args) {
6376
6437
  console.log(`\u2705 Converted ${fromKey} \u2192 ${toKey}${outputPath ? ` (${outputPath})` : ""}`);
6377
6438
  }
6378
6439
  async function handleImport(args) {
6379
- if (hasHelpFlag(args)) {
6380
- printCommandHelp(
6381
- "import",
6382
- "import --url <url> [-o <soustack.json>]",
6383
- "Import recipe from URL (alias for scrape)"
6384
- );
6440
+ if (wantsHelp(args)) {
6441
+ printCommandHelp("import");
6385
6442
  return;
6386
6443
  }
6387
6444
  const { url, outputPath } = parseImportArgs(args);
@@ -6394,12 +6451,8 @@ async function handleImport(args) {
6394
6451
  await handleScrape(scrapeArgs);
6395
6452
  }
6396
6453
  async function handleIngest(args) {
6397
- if (hasHelpFlag(args)) {
6398
- printCommandHelp(
6399
- "ingest",
6400
- "ingest <input> [--out <path>]",
6401
- "Bulk pipeline for processing multiple recipes (requires @soustack/ingest)"
6402
- );
6454
+ if (wantsHelp(args)) {
6455
+ printCommandHelp("ingest");
6403
6456
  return;
6404
6457
  }
6405
6458
  try {
@@ -6426,8 +6479,8 @@ async function handleIngest(args) {
6426
6479
  }
6427
6480
  }
6428
6481
  async function handleScale(args) {
6429
- if (hasHelpFlag(args)) {
6430
- printCommandHelp("scale", "scale <soustack.json> <multiplier>", "Scale a recipe by a multiplier");
6482
+ if (wantsHelp(args)) {
6483
+ printCommandHelp("scale");
6431
6484
  return;
6432
6485
  }
6433
6486
  const filePath = args[0];
@@ -6443,8 +6496,8 @@ async function handleScale(args) {
6443
6496
  console.log(JSON.stringify(result, null, 2));
6444
6497
  }
6445
6498
  async function handleScrape(args) {
6446
- if (hasHelpFlag(args)) {
6447
- printCommandHelp("scrape", "scrape <url> -o <soustack.json>", "Scrape recipe from a URL (canonical URL ingestion)");
6499
+ if (wantsHelp(args)) {
6500
+ printCommandHelp("scrape");
6448
6501
  return;
6449
6502
  }
6450
6503
  const url = args[0];