@canra/cli 0.6.0 → 0.8.0

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.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/canra.js +30 -11
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -24,8 +24,8 @@ canra search json
24
24
  | `canra search <query>` | Search the registry |
25
25
  | `canra info <owner>/<name>` | Show a spec's metadata |
26
26
  | `canra fetch <owner>/<name>[@version]` | Download a spec (latest or a pinned version), verify its SHA-256, and save it to `.canra/specs/<owner>/<name>/` |
27
- | `canra outdated [--json]` | Check fetched specs for newer versions; exits 1 if any is outdated |
28
- | `canra update [<owner>/<name>]` | Re-fetch the latest version of every outdated spec (or the named one) |
27
+ | `canra outdated [--json]` | Check fetched specs for newer versions; exits 1 if any is outdated or quarantined |
28
+ | `canra update [<owner>/<name>]` | Re-fetch the latest version of every outdated spec (or the named one); exits 1 if any spec is quarantined or fails to update |
29
29
  | `canra remove <owner>/<name>` | Delete a fetched spec from `.canra/specs/` |
30
30
  | `canra login` | Save a registry URL and API token |
31
31
  | `canra whoami` | Show which account your saved token belongs to |
package/canra.js CHANGED
@@ -523,9 +523,6 @@ async function cmdInfo(specArg) {
523
523
  const spec = await res.json();
524
524
  console.log(`${ref.owner}/${ref.name}@${printable(spec.version)}`);
525
525
  if (spec.title) console.log(` Title: ${printable(spec.title)}`);
526
- if (spec.status) console.log(` Status: ${printable(spec.status)}`);
527
- if (spec.difficulty) console.log(` Difficulty: ${printable(spec.difficulty)}`);
528
- if (spec.tags?.length) console.log(` Tags: ${printable(spec.tags.join(", "))}`);
529
526
  if (spec.functions?.length) console.log(` Functions: ${printable(spec.functions.join(", "))}`);
530
527
  if (spec.types?.length) console.log(` Types: ${printable(spec.types.join(", "))}`);
531
528
  if (spec.test_vectors_inline) console.log(` Test vectors: ${printable(spec.test_vectors_inline)} inline`);
@@ -645,6 +642,20 @@ function needsUpdate(row) {
645
642
  return row.status === "outdated" || (row.status === "current" && Boolean(row.moved_to));
646
643
  }
647
644
 
645
+ function isQuarantined(row) {
646
+ return row.status === "quarantined";
647
+ }
648
+
649
+ function warnQuarantined(results) {
650
+ const quarantined = results.filter(isQuarantined);
651
+ for (const r of quarantined) {
652
+ console.warn(
653
+ `Warning: ${printable(r.owner)}/${printable(r.name)} is quarantined on the registry and cannot be updated. Remove it with canra remove, or wait for the registry to restore it.`,
654
+ );
655
+ }
656
+ return quarantined.length;
657
+ }
658
+
648
659
  async function cmdOutdated(args) {
649
660
  const asJson = args.includes("--json");
650
661
  const refs = scanLocalSpecs();
@@ -655,19 +666,22 @@ async function cmdOutdated(args) {
655
666
 
656
667
  const results = await checkRemote(getRegistry(), refs);
657
668
  const outdated = results.filter(needsUpdate).length;
669
+ const quarantined = results.filter(isQuarantined).length;
658
670
 
671
+ // --json prints no warnings, so the output stays machine-readable; the exit code carries the quarantine signal.
659
672
  if (asJson) {
660
673
  console.log(JSON.stringify(results, null, 2));
661
674
  } else {
662
675
  printOutdatedTable(results);
663
- if (results.some(needsUpdate)) {
676
+ warnQuarantined(results);
677
+ if (outdated > 0) {
664
678
  console.log(`\n${outdated} outdated spec${outdated !== 1 ? "s" : ""}.`);
665
679
  console.log("Run canra update, then git diff .canra/ to review the changes.");
666
- } else {
680
+ } else if (quarantined === 0) {
667
681
  console.log("\nAll specs are up to date.");
668
682
  }
669
683
  }
670
- if (outdated > 0) process.exitCode = 1;
684
+ if (outdated > 0 || quarantined > 0) process.exitCode = 1;
671
685
  }
672
686
 
673
687
  function deleteLocalSpec(owner, name) {
@@ -724,9 +738,12 @@ async function cmdUpdate(specArg) {
724
738
  }
725
739
 
726
740
  const registry = getRegistry();
727
- const targets = (await checkRemote(registry, refs)).filter(needsUpdate);
741
+ const results = await checkRemote(registry, refs);
742
+ const quarantined = warnQuarantined(results);
743
+ const targets = results.filter(needsUpdate);
728
744
  if (targets.length === 0) {
729
- console.log("All specs are up to date.");
745
+ if (quarantined === 0) console.log("All specs are up to date.");
746
+ else process.exitCode = 1;
730
747
  return;
731
748
  }
732
749
 
@@ -761,7 +778,7 @@ async function cmdUpdate(specArg) {
761
778
  }
762
779
  }
763
780
  if (updated > 0) console.log("\nRun git diff .canra/ to review the changes.");
764
- if (failed > 0) process.exitCode = 1;
781
+ if (failed > 0 || quarantined > 0) process.exitCode = 1;
765
782
  }
766
783
 
767
784
  function cmdHelp() {
@@ -786,9 +803,11 @@ Commands:
786
803
  whoami Print the user your saved token authenticates as
787
804
  info <owner>/<name> Print spec metadata
788
805
  outdated [--json] Check .canra/specs/ for newer versions; exits 1 if
789
- any spec is outdated; --json prints the results
806
+ any spec is outdated or quarantined; --json prints
807
+ the results
790
808
  update [<owner>/<name>] Re-fetch the latest version of every outdated spec
791
- (or just the named one); review with git diff .canra/
809
+ (or just the named one); review with git diff .canra/;
810
+ exits 1 if any spec is quarantined or fails
792
811
  remove <owner>/<name> Delete a fetched spec from .canra/specs/
793
812
  help Print this help message
794
813
  version Print CLI version
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canra/cli",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "CLI for Canra, the registry of machine-readable specs: fetch, search, and publish specs.",
5
5
  "keywords": [
6
6
  "canra",