@canra/cli 0.6.0 → 0.7.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.
- package/README.md +2 -2
- package/canra.js +30 -8
- 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
|
@@ -645,6 +645,20 @@ function needsUpdate(row) {
|
|
|
645
645
|
return row.status === "outdated" || (row.status === "current" && Boolean(row.moved_to));
|
|
646
646
|
}
|
|
647
647
|
|
|
648
|
+
function isQuarantined(row) {
|
|
649
|
+
return row.status === "quarantined";
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
function warnQuarantined(results) {
|
|
653
|
+
const quarantined = results.filter(isQuarantined);
|
|
654
|
+
for (const r of quarantined) {
|
|
655
|
+
console.warn(
|
|
656
|
+
`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.`,
|
|
657
|
+
);
|
|
658
|
+
}
|
|
659
|
+
return quarantined.length;
|
|
660
|
+
}
|
|
661
|
+
|
|
648
662
|
async function cmdOutdated(args) {
|
|
649
663
|
const asJson = args.includes("--json");
|
|
650
664
|
const refs = scanLocalSpecs();
|
|
@@ -655,19 +669,22 @@ async function cmdOutdated(args) {
|
|
|
655
669
|
|
|
656
670
|
const results = await checkRemote(getRegistry(), refs);
|
|
657
671
|
const outdated = results.filter(needsUpdate).length;
|
|
672
|
+
const quarantined = results.filter(isQuarantined).length;
|
|
658
673
|
|
|
674
|
+
// --json prints no warnings, so the output stays machine-readable; the exit code carries the quarantine signal.
|
|
659
675
|
if (asJson) {
|
|
660
676
|
console.log(JSON.stringify(results, null, 2));
|
|
661
677
|
} else {
|
|
662
678
|
printOutdatedTable(results);
|
|
663
|
-
|
|
679
|
+
warnQuarantined(results);
|
|
680
|
+
if (outdated > 0) {
|
|
664
681
|
console.log(`\n${outdated} outdated spec${outdated !== 1 ? "s" : ""}.`);
|
|
665
682
|
console.log("Run canra update, then git diff .canra/ to review the changes.");
|
|
666
|
-
} else {
|
|
683
|
+
} else if (quarantined === 0) {
|
|
667
684
|
console.log("\nAll specs are up to date.");
|
|
668
685
|
}
|
|
669
686
|
}
|
|
670
|
-
if (outdated > 0) process.exitCode = 1;
|
|
687
|
+
if (outdated > 0 || quarantined > 0) process.exitCode = 1;
|
|
671
688
|
}
|
|
672
689
|
|
|
673
690
|
function deleteLocalSpec(owner, name) {
|
|
@@ -724,9 +741,12 @@ async function cmdUpdate(specArg) {
|
|
|
724
741
|
}
|
|
725
742
|
|
|
726
743
|
const registry = getRegistry();
|
|
727
|
-
const
|
|
744
|
+
const results = await checkRemote(registry, refs);
|
|
745
|
+
const quarantined = warnQuarantined(results);
|
|
746
|
+
const targets = results.filter(needsUpdate);
|
|
728
747
|
if (targets.length === 0) {
|
|
729
|
-
console.log("All specs are up to date.");
|
|
748
|
+
if (quarantined === 0) console.log("All specs are up to date.");
|
|
749
|
+
else process.exitCode = 1;
|
|
730
750
|
return;
|
|
731
751
|
}
|
|
732
752
|
|
|
@@ -761,7 +781,7 @@ async function cmdUpdate(specArg) {
|
|
|
761
781
|
}
|
|
762
782
|
}
|
|
763
783
|
if (updated > 0) console.log("\nRun git diff .canra/ to review the changes.");
|
|
764
|
-
if (failed > 0) process.exitCode = 1;
|
|
784
|
+
if (failed > 0 || quarantined > 0) process.exitCode = 1;
|
|
765
785
|
}
|
|
766
786
|
|
|
767
787
|
function cmdHelp() {
|
|
@@ -786,9 +806,11 @@ Commands:
|
|
|
786
806
|
whoami Print the user your saved token authenticates as
|
|
787
807
|
info <owner>/<name> Print spec metadata
|
|
788
808
|
outdated [--json] Check .canra/specs/ for newer versions; exits 1 if
|
|
789
|
-
any spec is outdated; --json prints
|
|
809
|
+
any spec is outdated or quarantined; --json prints
|
|
810
|
+
the results
|
|
790
811
|
update [<owner>/<name>] Re-fetch the latest version of every outdated spec
|
|
791
|
-
(or just the named one); review with git diff .canra
|
|
812
|
+
(or just the named one); review with git diff .canra/;
|
|
813
|
+
exits 1 if any spec is quarantined or fails
|
|
792
814
|
remove <owner>/<name> Delete a fetched spec from .canra/specs/
|
|
793
815
|
help Print this help message
|
|
794
816
|
version Print CLI version
|