@theholocron/cli 5.0.0-alpha.346 → 5.0.0-alpha.348
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 +5 -0
- package/dist/cli.mjs +44 -218
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +11 -27
- package/dist/index.mjs +10 -139
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -825,6 +825,11 @@ the local override exists to exempt.
|
|
|
825
825
|
The engine itself (the picker, argv and secret env, the dry-run preview, the spawn)
|
|
826
826
|
and the prompting pieces — `promptForPositionals`, `promptForOptions` — live in
|
|
827
827
|
`@theholocron/kyber` (`/menu`, `/prompts`), which has no knowledge of commands.
|
|
828
|
+
- `src/plugin/connection-probe/` — the `connectionProbe` a plugin offers, kyber's `connectionProbe` (`@theholocron/kyber/checks`)
|
|
829
|
+
typed as the plugin system's `Probe` with `verify` returning `VerifyTokenResult`; `monitoring check` runs its checks
|
|
830
|
+
with kyber's `runCheckAgainstUrl`.
|
|
831
|
+
- `src/commands/move-tag/` — the `package move-tag` yargs command, the registry entry and `runMoveTag`, which adds the
|
|
832
|
+
command-bound logger to kyber's `moveMajorTag` (`@theholocron/kyber/git`).
|
|
828
833
|
|
|
829
834
|
## Status
|
|
830
835
|
|
package/dist/cli.mjs
CHANGED
|
@@ -33,6 +33,8 @@ import { appManifestPage, buildAppManifest, convertAppManifest, serveAppManifest
|
|
|
33
33
|
import { access, copyFile, lstat, mkdir, open, readFile, readdir, realpath, rename, rm, stat, symlink, unlink, writeFile } from "node:fs/promises";
|
|
34
34
|
import { createHash, createHmac, randomBytes, randomUUID } from "node:crypto";
|
|
35
35
|
import { createServer } from "node:http";
|
|
36
|
+
import { runCheckAgainstUrl } from "@theholocron/kyber/checks";
|
|
37
|
+
import { moveMajorTag } from "@theholocron/kyber/git";
|
|
36
38
|
import { ADR_DIR, ADR_STATUSES, CLOSED_STATUSES, SPEC_DIRS, SPEC_STATUSES, WITHDRAWN_STATE, assignSpecIds, checkSpecs, classifySpecPath, discussionBody, discussionIdLine, discussionPrLine, discussionTitle, evaluateDocsPresence, isAddedDocComment, isFeat, packageOf, parseFrontmatter, parseSkipDocs, reconcileSpecStatus, specSummary, specTitle, updateFrontmatter } from "@theholocron/astromech/repo-validation";
|
|
37
39
|
import { fetchLatestFromNpm, runUpgradeNode } from "@theholocron/astromech/upgrade";
|
|
38
40
|
import { lintCommitMsgFile } from "@theholocron/astromech/lint";
|
|
@@ -790,110 +792,6 @@ var PluginLoader = class extends system.PluginLoader {
|
|
|
790
792
|
return found;
|
|
791
793
|
}
|
|
792
794
|
};
|
|
793
|
-
// src/plugin/run-check/run-check.ts
|
|
794
|
-
async function runCheckAgainstUrl(input, opts = {}) {
|
|
795
|
-
const doFetch = opts.fetch ?? fetch;
|
|
796
|
-
const url = resolveUrl(input.url, opts.url);
|
|
797
|
-
const method = input.method ?? "GET";
|
|
798
|
-
const hasBody = input.body !== void 0 && method !== "GET" && method !== "HEAD";
|
|
799
|
-
const needsBody = (input.assertions ?? []).some((a) => a.source === "body");
|
|
800
|
-
const start = Date.now();
|
|
801
|
-
let response;
|
|
802
|
-
let bodyText = "";
|
|
803
|
-
try {
|
|
804
|
-
response = await doFetch(url, {
|
|
805
|
-
method,
|
|
806
|
-
...hasBody ? { body: input.body } : {},
|
|
807
|
-
...opts.headers ? { headers: opts.headers } : {},
|
|
808
|
-
redirect: "manual",
|
|
809
|
-
signal: AbortSignal.timeout(opts.timeoutMs ?? 1e4)
|
|
810
|
-
});
|
|
811
|
-
if (needsBody) bodyText = await readBodyCapped(response, opts.maxBodyBytes ?? 1e6);
|
|
812
|
-
} catch (err) {
|
|
813
|
-
return {
|
|
814
|
-
passed: false,
|
|
815
|
-
failures: [],
|
|
816
|
-
requestError: requestErrorMessage(err)
|
|
817
|
-
};
|
|
818
|
-
}
|
|
819
|
-
const responseTimeMs = Date.now() - start;
|
|
820
|
-
const failures = [];
|
|
821
|
-
if (!input.shouldFail && response.status >= 400) failures.push(`HTTP ${response.status} (>= 400 counts as a failure unless \`shouldFail\` is set)`);
|
|
822
|
-
for (const assertion of input.assertions ?? []) {
|
|
823
|
-
const actual = extractActual(assertion, {
|
|
824
|
-
response,
|
|
825
|
-
bodyText,
|
|
826
|
-
responseTimeMs
|
|
827
|
-
});
|
|
828
|
-
if (!evaluate(assertion.comparison, actual, assertion.target)) failures.push(`${assertion.source} ${assertion.comparison} "${assertion.target ?? ""}" — got "${truncate(actual)}"`);
|
|
829
|
-
}
|
|
830
|
-
return {
|
|
831
|
-
passed: failures.length === 0,
|
|
832
|
-
status: response.status,
|
|
833
|
-
responseTimeMs,
|
|
834
|
-
failures
|
|
835
|
-
};
|
|
836
|
-
}
|
|
837
|
-
/** Swaps in `overrideUrl`'s origin, keeping `originalUrl`'s own path + query. */
|
|
838
|
-
function resolveUrl(originalUrl, overrideUrl) {
|
|
839
|
-
if (!overrideUrl) return originalUrl;
|
|
840
|
-
const original = new URL(originalUrl);
|
|
841
|
-
const resolved = new URL(overrideUrl);
|
|
842
|
-
resolved.pathname = original.pathname;
|
|
843
|
-
resolved.search = original.search;
|
|
844
|
-
return resolved.toString();
|
|
845
|
-
}
|
|
846
|
-
function requestErrorMessage(err) {
|
|
847
|
-
if (err instanceof Error) return err.name === "TimeoutError" ? `request timed out: ${err.message}` : err.message;
|
|
848
|
-
return String(err);
|
|
849
|
-
}
|
|
850
|
-
/** Reads up to `maxBytes` of the response body, discarding the rest — a large/unending body can't exhaust memory. */
|
|
851
|
-
async function readBodyCapped(response, maxBytes) {
|
|
852
|
-
if (!response.body) return "";
|
|
853
|
-
const reader = response.body.getReader();
|
|
854
|
-
const chunks = [];
|
|
855
|
-
let total = 0;
|
|
856
|
-
try {
|
|
857
|
-
for (;;) {
|
|
858
|
-
const { done, value } = await reader.read();
|
|
859
|
-
if (done) break;
|
|
860
|
-
const remaining = maxBytes - total;
|
|
861
|
-
if (remaining <= 0) break;
|
|
862
|
-
const stored = value.length > remaining ? value.slice(0, remaining) : value;
|
|
863
|
-
chunks.push(stored);
|
|
864
|
-
total += stored.length;
|
|
865
|
-
}
|
|
866
|
-
} finally {
|
|
867
|
-
await reader.cancel().catch(() => {});
|
|
868
|
-
}
|
|
869
|
-
return Buffer.concat(chunks.map((c) => Buffer.from(c))).toString("utf8");
|
|
870
|
-
}
|
|
871
|
-
/** Keeps a failure message readable when `actual` is a full HTML/JSON response body. */
|
|
872
|
-
function truncate(value, max = 200) {
|
|
873
|
-
return value.length > max ? `${value.slice(0, max)}…` : value;
|
|
874
|
-
}
|
|
875
|
-
function extractActual(assertion, ctx) {
|
|
876
|
-
switch (assertion.source) {
|
|
877
|
-
case "status_code": return String(ctx.response.status);
|
|
878
|
-
case "response_time": return String(ctx.responseTimeMs);
|
|
879
|
-
case "body": return ctx.bodyText;
|
|
880
|
-
case "header": {
|
|
881
|
-
const name = assertion.property ?? "";
|
|
882
|
-
return name ? ctx.response.headers.get(name) ?? "" : "";
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
function evaluate(comparison, actual, target) {
|
|
887
|
-
const t = target ?? "";
|
|
888
|
-
switch (comparison) {
|
|
889
|
-
case "equals": return actual === t;
|
|
890
|
-
case "not_equals": return actual !== t;
|
|
891
|
-
case "contains": return actual.includes(t);
|
|
892
|
-
case "not_contains": return !actual.includes(t);
|
|
893
|
-
case "greater_than": return Number(actual) > Number(t);
|
|
894
|
-
case "less_than": return Number(actual) < Number(t);
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
795
|
// src/plugin/verify-vercel-project/verify-vercel-project.ts
|
|
898
796
|
/**
|
|
899
797
|
* `true` only when Vercel's API confirms `url` resolves to a deployment
|
|
@@ -1430,7 +1328,7 @@ const doctorTokensCommand = {
|
|
|
1430
1328
|
*/
|
|
1431
1329
|
const COMMAND$8 = "auth export";
|
|
1432
1330
|
/** Plain code-unit order: the same on every machine, whatever its locale. The names it sorts are all different. */
|
|
1433
|
-
const compare
|
|
1331
|
+
const compare = (a, b) => a < b ? -1 : 1;
|
|
1434
1332
|
/** The file the lines go to on a terminal when none is named. */
|
|
1435
1333
|
const DEFAULT_FILE$1 = ".credentials";
|
|
1436
1334
|
/** What a variable can be called in a dotenv file and in a shell. */
|
|
@@ -1514,7 +1412,7 @@ async function runAuthExport(input) {
|
|
|
1514
1412
|
}
|
|
1515
1413
|
}
|
|
1516
1414
|
if (invalid.length > 0) return refuse("invalid", `not a variable name: ${invalid.join(", ")}`);
|
|
1517
|
-
if (unknown.length > 0) return refuse("unknown", `no token named ${unknown.join(", ")}`, `the names are: ${[...tokens.keys()].sort(compare
|
|
1415
|
+
if (unknown.length > 0) return refuse("unknown", `no token named ${unknown.join(", ")}`, `the names are: ${[...tokens.keys()].sort(compare).join(", ")}`, ...input.blank ? [] : ["or pass --blank to write a name that is no token as an empty placeholder"]);
|
|
1518
1416
|
for (const name of [...tokens.keys()]) if (!chosen.has(name)) tokens.delete(name);
|
|
1519
1417
|
for (const name of [...conflicts]) if (!chosen.has(name)) conflicts.delete(name);
|
|
1520
1418
|
}
|
|
@@ -1524,7 +1422,7 @@ async function runAuthExport(input) {
|
|
|
1524
1422
|
const missing = [];
|
|
1525
1423
|
const blank = [];
|
|
1526
1424
|
const unsupported = [];
|
|
1527
|
-
for (const [name, token] of [...tokens].sort(([a], [b]) => compare
|
|
1425
|
+
for (const [name, token] of [...tokens].sort(([a], [b]) => compare(a, b))) {
|
|
1528
1426
|
if (conflicts.has(name)) continue;
|
|
1529
1427
|
const written = input.vendorNames && token.vendorEnvName ? token.vendorEnvName : name;
|
|
1530
1428
|
const value = (input.fromEnv ? env.get(name) || (token.vendorEnvName ? env.get(token.vendorEnvName) : void 0) : void 0) || (input.org ? readToken(`${token.keyringKey}.${input.org}`) : null) || readToken(token.keyringKey);
|
|
@@ -1575,7 +1473,7 @@ async function runAuthExport(input) {
|
|
|
1575
1473
|
});
|
|
1576
1474
|
taken.add(name);
|
|
1577
1475
|
}
|
|
1578
|
-
entries.sort((x, y) => compare
|
|
1476
|
+
entries.sort((x, y) => compare(x.name, y.name));
|
|
1579
1477
|
const lines = entries.map((e) => e.line);
|
|
1580
1478
|
const onTerminal = input.only?.length ? "clipboard" : "file";
|
|
1581
1479
|
const target = input.to ?? (input.outKind === "terminal" ? onTerminal : void 0);
|
|
@@ -1612,12 +1510,12 @@ async function runAuthExport(input) {
|
|
|
1612
1510
|
for (const name of exported) print(` ${style.success(name)}`);
|
|
1613
1511
|
for (const name of blank) print(` ${style.dim("·")} ${name}${style.dim(" (written empty: fill it in)")}`);
|
|
1614
1512
|
for (const name of missing) print(` ${style.dim("·")} ${name}${tokens.get(name)?.optional ? style.dim(" (optional)") : ""}`);
|
|
1615
|
-
for (const name of [...conflicts].sort(compare
|
|
1513
|
+
for (const name of [...conflicts].sort(compare)) print(` ${style.fail(`${name} (listed by two plugins under different keyring entries, so not exported)`)}`);
|
|
1616
1514
|
for (const name of unsupported) print(` ${style.fail(`${name} (a value dotenv cannot carry unchanged, so add it by hand)`)}`);
|
|
1617
1515
|
if (unavailable.length > 0) {
|
|
1618
1516
|
print("");
|
|
1619
1517
|
print("could not load, so the tokens they take are not listed:");
|
|
1620
|
-
for (const pkg of [...unavailable].sort(compare
|
|
1518
|
+
for (const pkg of [...unavailable].sort(compare)) print(` ${style.fail(`${pkg} (${reasons.get(pkg)})`)}`);
|
|
1621
1519
|
}
|
|
1622
1520
|
if (destination === "clipboard" || destination === "file") print("");
|
|
1623
1521
|
if (destination === "clipboard") print("copied to the clipboard: paste it, then clear the clipboard");
|
|
@@ -1637,9 +1535,9 @@ async function runAuthExport(input) {
|
|
|
1637
1535
|
exported,
|
|
1638
1536
|
missing,
|
|
1639
1537
|
blank,
|
|
1640
|
-
conflicts: [...conflicts].sort(compare
|
|
1538
|
+
conflicts: [...conflicts].sort(compare),
|
|
1641
1539
|
unsupported,
|
|
1642
|
-
unavailable: [...unavailable].sort(compare
|
|
1540
|
+
unavailable: [...unavailable].sort(compare),
|
|
1643
1541
|
...destination ? { destination } : {},
|
|
1644
1542
|
...file ? { file } : {}
|
|
1645
1543
|
};
|
|
@@ -12994,112 +12892,17 @@ const notificationsCommand = {
|
|
|
12994
12892
|
handler: () => {}
|
|
12995
12893
|
};
|
|
12996
12894
|
// src/commands/move-tag/move-tag.ts
|
|
12997
|
-
|
|
12998
|
-
|
|
12999
|
-
|
|
13000
|
-
|
|
13001
|
-
|
|
13002
|
-
stdio: [
|
|
13003
|
-
"ignore",
|
|
13004
|
-
"pipe",
|
|
13005
|
-
"pipe"
|
|
13006
|
-
]
|
|
13007
|
-
}).trim();
|
|
13008
|
-
/** Orders stable versions, newest last. */
|
|
13009
|
-
function compare(a, b) {
|
|
13010
|
-
const [pa, pb] = [a, b].map((v) => STABLE.exec(v).slice(1).map(Number));
|
|
13011
|
-
return pa.reduce((diff, n, i) => diff || n - pb[i], 0);
|
|
13012
|
-
}
|
|
13013
|
-
/**
|
|
13014
|
-
* Moves a version group's major tag (`ci-v1`) to its latest stable release (`ci-v1.4.0`) and force-pushes it, so
|
|
13015
|
-
* a caller that pins `ci-v1` follows the group without changing its workflow files. Immutable tags
|
|
13016
|
-
* (`ci-v1.4.0`) are never touched. Run by the group's release (`publishCmd`) and by hand for a repair.
|
|
13017
|
-
*
|
|
13018
|
-
* A prerelease is refused: the major tag follows stable releases only.
|
|
12895
|
+
/**
|
|
12896
|
+
* Moves a version group's major tag (`ci-v1`) to its latest stable release (`ci-v1.4.0`) and force-pushes it, so a
|
|
12897
|
+
* caller that pins `ci-v1` follows the group without changing its workflow files. Immutable tags are never touched.
|
|
12898
|
+
* Run by the group's release (`publishCmd`) and by hand for a repair. The tag logic is kyber's `moveMajorTag`; this adds
|
|
12899
|
+
* the command-bound logger.
|
|
13019
12900
|
*/
|
|
13020
|
-
|
|
13021
|
-
|
|
13022
|
-
|
|
13023
|
-
|
|
13024
|
-
|
|
13025
|
-
const { group, dryRun = false, remote = "origin" } = input;
|
|
13026
|
-
const fail = (message) => {
|
|
13027
|
-
print(` ✗ ${message}`);
|
|
13028
|
-
logger.info({
|
|
13029
|
-
group,
|
|
13030
|
-
status: "fail"
|
|
13031
|
-
}, "package move-tag: done");
|
|
13032
|
-
return {
|
|
13033
|
-
status: "fail",
|
|
13034
|
-
message
|
|
13035
|
-
};
|
|
13036
|
-
};
|
|
13037
|
-
let version = input.version;
|
|
13038
|
-
try {
|
|
13039
|
-
if (version === void 0) {
|
|
13040
|
-
version = git([
|
|
13041
|
-
"tag",
|
|
13042
|
-
"--list",
|
|
13043
|
-
`${group}-v*`
|
|
13044
|
-
], cwd).split("\n").map((tag) => tag.slice(`${group}-v`.length)).filter((v) => STABLE.test(v)).sort(compare).at(-1);
|
|
13045
|
-
if (version === void 0) return fail(`no stable ${group}-v<version> tag to move ${group}-v<major> to`);
|
|
13046
|
-
}
|
|
13047
|
-
const parts = STABLE.exec(version);
|
|
13048
|
-
if (!parts) return fail(`${version} is not a stable version (x.y.z); the major tag follows stable releases only`);
|
|
13049
|
-
const target = `${group}-v${version}`;
|
|
13050
|
-
const tag = `${group}-v${parts[1]}`;
|
|
13051
|
-
print(`Moving ${tag} to ${target}${dryRun ? " (dry-run)" : ""}…`);
|
|
13052
|
-
logger.info({
|
|
13053
|
-
group,
|
|
13054
|
-
tag,
|
|
13055
|
-
target,
|
|
13056
|
-
dryRun: dryRun || void 0
|
|
13057
|
-
}, "package move-tag: start");
|
|
13058
|
-
let commit;
|
|
13059
|
-
try {
|
|
13060
|
-
commit = git([
|
|
13061
|
-
"rev-parse",
|
|
13062
|
-
"--verify",
|
|
13063
|
-
`refs/tags/${target}^{commit}`
|
|
13064
|
-
], cwd);
|
|
13065
|
-
} catch {
|
|
13066
|
-
return fail(`no tag ${target} in this clone; fetch the tags first (git fetch --tags)`);
|
|
13067
|
-
}
|
|
13068
|
-
if (dryRun) {
|
|
13069
|
-
print(` ~ ${tag} → ${commit.slice(0, 9)} (${target}), then push --force ${remote}`);
|
|
13070
|
-
return {
|
|
13071
|
-
status: "dry-run",
|
|
13072
|
-
tag,
|
|
13073
|
-
target
|
|
13074
|
-
};
|
|
13075
|
-
}
|
|
13076
|
-
git([
|
|
13077
|
-
"tag",
|
|
13078
|
-
"--force",
|
|
13079
|
-
tag,
|
|
13080
|
-
commit
|
|
13081
|
-
], cwd);
|
|
13082
|
-
git([
|
|
13083
|
-
"push",
|
|
13084
|
-
"--force",
|
|
13085
|
-
remote,
|
|
13086
|
-
`refs/tags/${tag}`
|
|
13087
|
-
], cwd);
|
|
13088
|
-
print(` ✓ ${tag} → ${commit.slice(0, 9)} (${target})`);
|
|
13089
|
-
logger.info({
|
|
13090
|
-
group,
|
|
13091
|
-
tag,
|
|
13092
|
-
target,
|
|
13093
|
-
status: "ok"
|
|
13094
|
-
}, "package move-tag: done");
|
|
13095
|
-
return {
|
|
13096
|
-
status: "ok",
|
|
13097
|
-
tag,
|
|
13098
|
-
target
|
|
13099
|
-
};
|
|
13100
|
-
} catch (error) {
|
|
13101
|
-
return fail(errorMessage(error));
|
|
13102
|
-
}
|
|
12901
|
+
function runMoveTag(input) {
|
|
12902
|
+
return moveMajorTag({
|
|
12903
|
+
...input,
|
|
12904
|
+
logger: input.logger ?? getLogger()
|
|
12905
|
+
});
|
|
13103
12906
|
}
|
|
13104
12907
|
// src/commands/move-tag/move-tag.args.ts
|
|
13105
12908
|
const moveTagArgs = (y) => y.positional("group", {
|
|
@@ -20780,6 +20583,29 @@ function secretRoutes(entries, environmentId) {
|
|
|
20780
20583
|
...entry.keys ? { keys: entry.keys } : {}
|
|
20781
20584
|
}));
|
|
20782
20585
|
}
|
|
20586
|
+
// src/commands/secrets-sync/restore-pem/restore-pem.ts
|
|
20587
|
+
/** A PEM block written on one line: the begin marker, the body, the end marker, with spaces between them. */
|
|
20588
|
+
const COLLAPSED = /^(-----BEGIN [A-Z0-9 ]+-----) ([\s\S]+?) (-----END [A-Z0-9 ]+-----)$/;
|
|
20589
|
+
/** Base64 lines in a PEM are 64 characters wide. */
|
|
20590
|
+
const LINE_WIDTH = 64;
|
|
20591
|
+
/**
|
|
20592
|
+
* Put a PEM back on its lines when its line breaks were turned into spaces. A key pasted into a single-line field
|
|
20593
|
+
* (a 1Password Environment variable, a form) arrives as `-----BEGIN ... KEY----- MIIE... -----END ... KEY-----`, which
|
|
20594
|
+
* Node's crypto, OpenSSL and `actions/create-github-app-token` refuse (`DECODER routines::unsupported`). The header and
|
|
20595
|
+
* footer go on their own lines and the body is cut into 64-character lines.
|
|
20596
|
+
*
|
|
20597
|
+
* Anything else is returned as it came: a PEM already on its lines, a value that is not a PEM, a block whose end marker
|
|
20598
|
+
* does not match its begin marker, and a legacy encrypted key (its body holds `Proc-Type:` header fields, whose own
|
|
20599
|
+
* line breaks cannot be rebuilt). Running it twice gives the same result as running it once.
|
|
20600
|
+
*/
|
|
20601
|
+
function restorePem(value) {
|
|
20602
|
+
const match = COLLAPSED.exec(value.trim());
|
|
20603
|
+
if (!match) return value;
|
|
20604
|
+
const [, begin, body, end] = match;
|
|
20605
|
+
if (begin.replace("BEGIN", "END") !== end || body.includes(":")) return value;
|
|
20606
|
+
const lines = body.replace(/\s+/g, "").match(new RegExp(`.{1,${LINE_WIDTH}}`, "g"));
|
|
20607
|
+
return lines ? `${begin}\n${lines.join("\n")}\n${end}\n` : value;
|
|
20608
|
+
}
|
|
20783
20609
|
// src/commands/secrets-sync/secrets-sync.ts
|
|
20784
20610
|
/**
|
|
20785
20611
|
* `holocron secrets sync` — vault → destinations.
|
|
@@ -20980,7 +20806,7 @@ async function pushRow(destination, scope, key, envVars, dryRun, body) {
|
|
|
20980
20806
|
status: "skip",
|
|
20981
20807
|
message: "blank in the vault environment"
|
|
20982
20808
|
};
|
|
20983
|
-
return runRow(destination, scope, key, dryRun, () => body(value));
|
|
20809
|
+
return runRow(destination, scope, key, dryRun, () => body(restorePem(value)));
|
|
20984
20810
|
}
|
|
20985
20811
|
async function runRow(destination, scope, key, dryRun, body) {
|
|
20986
20812
|
if (dryRun) return {
|