@theholocron/cli 5.0.0-alpha.392 → 5.0.0-alpha.394
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/dist/cli.mjs +64 -60
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +52 -52
- package/dist/index.mjs +14 -14
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -898,7 +898,7 @@ the local override exists to exempt.
|
|
|
898
898
|
(`@theholocron/kyber/plugins`: dynamic-imports plugins, resolves capability config packages,
|
|
899
899
|
builds the capability registry); Holocron's prefix, plugin options and the credentials / `.env`
|
|
900
900
|
step are passed in
|
|
901
|
-
- `src/cli.ts` — yargs entry, dispatches subcommands. `holocron run` / `ci` are
|
|
901
|
+
- `src/cli/cli.ts` — yargs entry, dispatches subcommands. `holocron run` / `ci` are
|
|
902
902
|
delegated to [`@theholocron/astromech`](../astromech) (`createAstromech`).
|
|
903
903
|
`holocron repo sync` / `holocron repo setup` write each repo's `.github/workflows/*.yml`
|
|
904
904
|
thin callers from `astromech.thinCallers()`; `holocron sync github` pushes the
|
|
@@ -921,7 +921,7 @@ the local override exists to exempt.
|
|
|
921
921
|
The engine itself (the picker, argv and secret env, the dry-run preview, the spawn)
|
|
922
922
|
and the prompting pieces — `promptForPositionals`, `promptForOptions` — live in
|
|
923
923
|
`@theholocron/kyber` (`/menu`, `/prompts`), which has no knowledge of commands.
|
|
924
|
-
- `src/plugin/connection-probe/` — the `connectionProbe` a plugin offers, kyber's `connectionProbe` (`@theholocron/kyber/checks`)
|
|
924
|
+
- `src/plugin/probes/connection-probe/` — the `connectionProbe` a plugin offers, kyber's `connectionProbe` (`@theholocron/kyber/checks`)
|
|
925
925
|
typed as the plugin system's `Probe` with `verify` returning `VerifyTokenResult`; `monitoring check` runs its checks
|
|
926
926
|
with kyber's `runCheckAgainstUrl`.
|
|
927
927
|
- `src/commands/move-tag/` — the `package move-tag` yargs command, the registry entry and `runMoveTag`, which adds the
|
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import { copyFileSync, existsSync, fstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
4
3
|
import { homedir, tmpdir } from "node:os";
|
|
5
4
|
import path, { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
6
5
|
import { PREFIX, createEnvLookup, firstEnv, holocronEnv } from "@theholocron/env-utils/lookup";
|
|
@@ -22,7 +21,9 @@ import { resolveAxiomFromEnv } from "@theholocron/observability/logger";
|
|
|
22
21
|
import { Entry, findCredentials } from "@napi-rs/keyring";
|
|
23
22
|
import { AuthError, DOTENV_FILE, copyToClipboard, createFeatureResolver, createKeyring, dotenvLine, findCredential, finishCredentialsFile, hasCredentials, isGitIgnored, readDotenvFile, resolveValue, resolveValue as resolveValue$2, setCredentials, writeCredentialsFile } from "@theholocron/kyber/secrets";
|
|
24
23
|
import { errorMessage } from "@theholocron/misc-utils";
|
|
25
|
-
import {
|
|
24
|
+
import { runCheckAgainstUrl } from "@theholocron/kyber/checks";
|
|
25
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
26
|
+
import { copyFileSync, existsSync, fstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
26
27
|
import { DRY_RUN_NOOP_EXIT_CODE, createCommandRegistry, createMenu, numeric } from "@theholocron/kyber/menu";
|
|
27
28
|
import { promptForPositionals } from "@theholocron/kyber/prompts";
|
|
28
29
|
import { Separator, checkbox, confirm, input, select } from "@inquirer/prompts";
|
|
@@ -34,7 +35,6 @@ import { access, copyFile, lstat, mkdir, open, readFile, readdir, realpath, rena
|
|
|
34
35
|
import { createHash, createHmac, randomBytes, randomUUID } from "node:crypto";
|
|
35
36
|
import { createGitHubClient, getApp, listAppInstallations } from "@theholocron/github-client";
|
|
36
37
|
import { createServer } from "node:http";
|
|
37
|
-
import { runCheckAgainstUrl } from "@theholocron/kyber/checks";
|
|
38
38
|
import { moveMajorTag } from "@theholocron/kyber/git";
|
|
39
39
|
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";
|
|
40
40
|
import { loadConfigPath } from "@theholocron/datapad";
|
|
@@ -660,7 +660,7 @@ system$1.defineConfig;
|
|
|
660
660
|
*/
|
|
661
661
|
const loadConfig = system$1.loadConfig;
|
|
662
662
|
system$1.compose;
|
|
663
|
-
// src/auth.ts
|
|
663
|
+
// src/auth/auth.ts
|
|
664
664
|
/**
|
|
665
665
|
* The CLI's credentials: the OS keyring every plugin's bootstrap token lives in, and the two token resolvers built on
|
|
666
666
|
* it. Both are public, so a plugin's `src/auth.ts` is a one-line call.
|
|
@@ -1121,41 +1121,6 @@ function actionsOf(plugin) {
|
|
|
1121
1121
|
...plugin.doctor ? { doctor: plugin.doctor } : {}
|
|
1122
1122
|
};
|
|
1123
1123
|
}
|
|
1124
|
-
// src/plugin/verify-vercel-project/verify-vercel-project.ts
|
|
1125
|
-
/**
|
|
1126
|
-
* `true` only when Vercel's API confirms `url` resolves to a deployment
|
|
1127
|
-
* whose `projectId` matches `expectedProjectId` exactly. `false` for any
|
|
1128
|
-
* other outcome — a non-matching project, a non-2xx response, a
|
|
1129
|
-
* malformed body, or a transport failure — never throws, since every one
|
|
1130
|
-
* of those outcomes means the same thing to a caller: don't attach the
|
|
1131
|
-
* credential.
|
|
1132
|
-
*/
|
|
1133
|
-
async function verifyVercelDeploymentProject(url, expectedProjectId, token, opts = {}) {
|
|
1134
|
-
const doFetch = opts.fetch ?? fetch;
|
|
1135
|
-
const baseUrl = opts.baseUrl ?? "https://api.vercel.com";
|
|
1136
|
-
let host;
|
|
1137
|
-
try {
|
|
1138
|
-
host = new URL(url).host;
|
|
1139
|
-
} catch {
|
|
1140
|
-
return false;
|
|
1141
|
-
}
|
|
1142
|
-
const params = new URLSearchParams({ url: host });
|
|
1143
|
-
if (opts.teamId) params.set("teamId", opts.teamId);
|
|
1144
|
-
let response;
|
|
1145
|
-
try {
|
|
1146
|
-
response = await doFetch(`${baseUrl}/v13/deployments/get?${params}`, { headers: { Authorization: `Bearer ${token}` } });
|
|
1147
|
-
} catch {
|
|
1148
|
-
return false;
|
|
1149
|
-
}
|
|
1150
|
-
if (!response.ok) return false;
|
|
1151
|
-
let body;
|
|
1152
|
-
try {
|
|
1153
|
-
body = await response.json();
|
|
1154
|
-
} catch {
|
|
1155
|
-
return false;
|
|
1156
|
-
}
|
|
1157
|
-
return (typeof body === "object" && body !== null && "projectId" in body ? body.projectId : void 0) === expectedProjectId;
|
|
1158
|
-
}
|
|
1159
1124
|
// src/commands/auth/auth.ts
|
|
1160
1125
|
/**
|
|
1161
1126
|
* `holocron auth <subcommand>` — manage bootstrap credentials in the
|
|
@@ -12106,22 +12071,42 @@ async function runMonitoringCheck(input) {
|
|
|
12106
12071
|
...input.runCheck ? { runCheck: input.runCheck } : {}
|
|
12107
12072
|
});
|
|
12108
12073
|
}
|
|
12109
|
-
// src/commands/monitoring-run-resolved/
|
|
12074
|
+
// src/commands/monitoring-run-resolved/verify-vercel-project/verify-vercel-project.ts
|
|
12110
12075
|
/**
|
|
12111
|
-
* `
|
|
12112
|
-
*
|
|
12113
|
-
*
|
|
12114
|
-
*
|
|
12115
|
-
*
|
|
12116
|
-
*
|
|
12117
|
-
* Safe to run with a credential present, since nothing here executes
|
|
12118
|
-
* PR-authored code — but a credential is only ever attached after
|
|
12119
|
-
* `verifyVercelDeploymentProject` confirms `url` actually belongs to
|
|
12120
|
-
* `vercelProject`: a URL merely ending in `.vercel.app` proves nothing,
|
|
12121
|
-
* since anyone can register their own Vercel project (sourcery review
|
|
12122
|
-
* on holocron#1032). No `vercelProject` given at all → the credential
|
|
12123
|
-
* is never attached, regardless of whether one is configured.
|
|
12076
|
+
* `true` only when Vercel's API confirms `url` resolves to a deployment
|
|
12077
|
+
* whose `projectId` matches `expectedProjectId` exactly. `false` for any
|
|
12078
|
+
* other outcome — a non-matching project, a non-2xx response, a
|
|
12079
|
+
* malformed body, or a transport failure — never throws, since every one
|
|
12080
|
+
* of those outcomes means the same thing to a caller: don't attach the
|
|
12081
|
+
* credential.
|
|
12124
12082
|
*/
|
|
12083
|
+
async function verifyVercelDeploymentProject(url, expectedProjectId, token, opts = {}) {
|
|
12084
|
+
const doFetch = opts.fetch ?? fetch;
|
|
12085
|
+
const baseUrl = opts.baseUrl ?? "https://api.vercel.com";
|
|
12086
|
+
let host;
|
|
12087
|
+
try {
|
|
12088
|
+
host = new URL(url).host;
|
|
12089
|
+
} catch {
|
|
12090
|
+
return false;
|
|
12091
|
+
}
|
|
12092
|
+
const params = new URLSearchParams({ url: host });
|
|
12093
|
+
if (opts.teamId) params.set("teamId", opts.teamId);
|
|
12094
|
+
let response;
|
|
12095
|
+
try {
|
|
12096
|
+
response = await doFetch(`${baseUrl}/v13/deployments/get?${params}`, { headers: { Authorization: `Bearer ${token}` } });
|
|
12097
|
+
} catch {
|
|
12098
|
+
return false;
|
|
12099
|
+
}
|
|
12100
|
+
if (!response.ok) return false;
|
|
12101
|
+
let body;
|
|
12102
|
+
try {
|
|
12103
|
+
body = await response.json();
|
|
12104
|
+
} catch {
|
|
12105
|
+
return false;
|
|
12106
|
+
}
|
|
12107
|
+
return (typeof body === "object" && body !== null && "projectId" in body ? body.projectId : void 0) === expectedProjectId;
|
|
12108
|
+
}
|
|
12109
|
+
// src/commands/monitoring-run-resolved/monitoring-run-resolved.ts
|
|
12125
12110
|
/**
|
|
12126
12111
|
* The shared gate every caller that might attach the Deployment
|
|
12127
12112
|
* Protection bypass header goes through — `monitoring check`'s direct
|
|
@@ -15025,7 +15010,7 @@ function workspaceFilterArgs(cwd, scope = {}) {
|
|
|
15025
15010
|
*
|
|
15026
15011
|
* $ pnpm install --frozen-lockfile
|
|
15027
15012
|
* $ pnpm build
|
|
15028
|
-
* $ pnpm exec tsx cli/cli/src/cli.ts package publish --initial
|
|
15013
|
+
* $ pnpm exec tsx cli/cli/src/cli/cli.ts package publish --initial
|
|
15029
15014
|
*
|
|
15030
15015
|
* `npm login --auth-type=web` runs automatically the first time — no
|
|
15031
15016
|
* separate manual step. `pnpm install` + `pnpm build` stay outside the
|
|
@@ -15179,7 +15164,7 @@ async function runPublish(input = {}) {
|
|
|
15179
15164
|
if (publish.stdout.includes("EOTP") || publish.stderr.includes("EOTP")) {
|
|
15180
15165
|
print("");
|
|
15181
15166
|
print(" → hint: your npm account requires 2FA for writes. Re-run with `--otp <code>`:");
|
|
15182
|
-
print(` pnpm exec tsx cli/cli/src/cli.ts package publish --initial --otp <6-digit-code>`);
|
|
15167
|
+
print(` pnpm exec tsx cli/cli/src/cli/cli.ts package publish --initial --otp <6-digit-code>`);
|
|
15183
15168
|
}
|
|
15184
15169
|
for (const entry of newEntries) print(statusRow("fail", [
|
|
15185
15170
|
pad(entry.name, nameWidth),
|
|
@@ -15431,7 +15416,8 @@ function parseJson(raw) {
|
|
|
15431
15416
|
*
|
|
15432
15417
|
* A package is skipped only when BOTH its bound file and its bound repository (compared
|
|
15433
15418
|
* case-insensitively) already match: a package folded in from another repo keeps its
|
|
15434
|
-
* filename but is still bound to the old repo (#1221). `--
|
|
15419
|
+
* filename but is still bound to the old repo (#1221). `--force` replaces a matching entry too, because npm
|
|
15420
|
+
* expires an entry that is not used for a publish soon after it is made and still lists it as matching. `--dry-run` does the same read-only
|
|
15435
15421
|
* `trust list` per package and reports what the real run would do, without revoking or creating.
|
|
15436
15422
|
*/
|
|
15437
15423
|
async function runSyncTrust(input) {
|
|
@@ -15440,6 +15426,7 @@ async function runSyncTrust(input) {
|
|
|
15440
15426
|
const cwd = input.cwd ?? process.cwd();
|
|
15441
15427
|
const repo = input.repo ?? HOLOCRON_REPO;
|
|
15442
15428
|
const dryRun = input.dryRun ?? false;
|
|
15429
|
+
const force = input.force ?? false;
|
|
15443
15430
|
const exec = input.exec ?? defaultExec$1;
|
|
15444
15431
|
const packageNames = input.packages ?? discoverPublicPackages(cwd, scopeOf(input));
|
|
15445
15432
|
const npm = "npx";
|
|
@@ -15505,7 +15492,7 @@ async function runSyncTrust(input) {
|
|
|
15505
15492
|
const entry = parsed ?? {};
|
|
15506
15493
|
const sameFile = entry.file === input.newFile;
|
|
15507
15494
|
const sameRepo = entry.repository?.toLowerCase() === repo.toLowerCase();
|
|
15508
|
-
if (sameFile && sameRepo) {
|
|
15495
|
+
if (sameFile && sameRepo && !force) {
|
|
15509
15496
|
print(` already on ${repo} / ${input.newFile}, skipping`);
|
|
15510
15497
|
results.push({
|
|
15511
15498
|
name,
|
|
@@ -15592,6 +15579,10 @@ const publishArgs = (y) => y.option("initial", {
|
|
|
15592
15579
|
}).option("sync-trust", {
|
|
15593
15580
|
type: "array",
|
|
15594
15581
|
describe: "Migrate npm Trusted Publisher config to a new workflow filename across every public package: --sync-trust <old-file> <new-file>. See issue #689 — npm requires fresh interactive 2FA per package; re-run after approving the printed authUrl if it stops early."
|
|
15582
|
+
}).option("force", {
|
|
15583
|
+
type: "boolean",
|
|
15584
|
+
default: false,
|
|
15585
|
+
describe: "--sync-trust only: revoke and recreate every package's Trusted Publisher entry even when its file and repository already match. npm expires an entry that is not used for a publish soon after it is made but still lists it as matching, so a plain run skips it."
|
|
15595
15586
|
}).option("repo", {
|
|
15596
15587
|
type: "string",
|
|
15597
15588
|
describe: `owner/repo for Trusted Publisher config (--sync-trust). Defaults to ${HOLOCRON_REPO}.`
|
|
@@ -15631,6 +15622,7 @@ const publishCommand = {
|
|
|
15631
15622
|
oldFile,
|
|
15632
15623
|
newFile,
|
|
15633
15624
|
dryRun: argv.dryRun,
|
|
15625
|
+
force: argv.force,
|
|
15634
15626
|
...argv.group ? { group: argv.group } : {},
|
|
15635
15627
|
...argv.excludeGroup?.length ? { excludeGroups: argv.excludeGroup } : {},
|
|
15636
15628
|
...argv.repo ? { repo: argv.repo } : {}
|
|
@@ -16909,7 +16901,7 @@ function docsCoverageProbes(repoRoot, typedoc = runTypedoc(repoRoot), diff = rea
|
|
|
16909
16901
|
* Workflow files that no task generates and that are not marked `# HAND-MAINTAINED`, so the check would take them for
|
|
16910
16902
|
* stale generated files. Each is intentional.
|
|
16911
16903
|
*/
|
|
16912
|
-
const UNMANAGED_WORKFLOWS = {
|
|
16904
|
+
const UNMANAGED_WORKFLOWS = {};
|
|
16913
16905
|
// src/commands/probe/generated/check-generated.ts
|
|
16914
16906
|
const WORKFLOWS_DIR = ".github/workflows/";
|
|
16915
16907
|
/** Where two texts first differ: the line number and both lines, cut to fit a terminal. */
|
|
@@ -24447,9 +24439,21 @@ const tunnelCommand = {
|
|
|
24447
24439
|
builder: (y) => y.command(tunnelUpCommand).command(groupMenu$1("tunnel")),
|
|
24448
24440
|
handler: () => {}
|
|
24449
24441
|
};
|
|
24450
|
-
// src/cli.ts
|
|
24442
|
+
// src/cli/own-package-json.ts
|
|
24443
|
+
/**
|
|
24444
|
+
* The `name` and `version` of the package that `moduleUrl` belongs to, from the nearest `package.json` above it.
|
|
24445
|
+
* That is the package root whether the CLI runs from source (`src/cli/cli.ts`, through tsx) or built (`dist/cli.mjs`),
|
|
24446
|
+
* which a fixed `../package.json` would not be: the entry sits one folder deeper in source than it does built.
|
|
24447
|
+
*/
|
|
24448
|
+
function ownPackageJson(moduleUrl) {
|
|
24449
|
+
const from = dirname(fileURLToPath(moduleUrl));
|
|
24450
|
+
const root = findRootSync(from, "package.json");
|
|
24451
|
+
if (!root) throw new Error(`no package.json found above ${from}`);
|
|
24452
|
+
return JSON.parse(readFileSync(join(root, "package.json"), "utf-8"));
|
|
24453
|
+
}
|
|
24454
|
+
// src/cli/cli.ts
|
|
24451
24455
|
const env = createEnvLookup();
|
|
24452
|
-
const { name: CLI_PACKAGE_NAME, version: CLI_VERSION } =
|
|
24456
|
+
const { name: CLI_PACKAGE_NAME, version: CLI_VERSION } = ownPackageJson(import.meta.url);
|
|
24453
24457
|
/**
|
|
24454
24458
|
* Error class names whose `.message` is a complete, actionable sentence: printed on its own, with no usage dump and no
|
|
24455
24459
|
* stack trace. Any other error is printed too, so a command that throws a plain `Error` is never silent.
|