@vigilbase/cli 0.2.1 → 0.2.2
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/CLOUDFLARE.md +8 -8
- package/COMMANDS.md +56 -13
- package/LOCAL.md +6 -3
- package/ONE.md +4 -3
- package/README.md +30 -20
- package/SECURITY.md +4 -2
- package/dist/cli.js +6 -3
- package/dist/commands/account.js +1 -1
- package/dist/commands/auth.js +2 -1
- package/dist/commands/cloudflare.d.ts +1 -1
- package/dist/commands/cloudflare.js +8 -3
- package/dist/commands/legacy-validation.d.ts +7 -1
- package/dist/commands/legacy-validation.js +15 -2
- package/dist/commands/local.js +2 -1
- package/dist/commands/one.js +33 -6
- package/dist/commands/public-tools.js +11 -11
- package/dist/commands/runs.js +1 -1
- package/dist/commands/security.d.ts +1 -1
- package/dist/commands/security.js +34 -22
- package/dist/lib/client.d.ts +5 -0
- package/dist/lib/client.js +7 -2
- package/dist/lib/cloudflare-client.js +1 -1
- package/dist/lib/help.d.ts +3 -0
- package/dist/lib/help.js +43 -5
- package/dist/lib/one-client.d.ts +2 -0
- package/dist/lib/one-client.js +6 -2
- package/dist/lib/one-error-hints.d.ts +19 -0
- package/dist/lib/one-error-hints.js +47 -0
- package/dist/local/cloudflare-checkup/errors.d.ts +2 -0
- package/dist/local/cloudflare-checkup/errors.js +2 -0
- package/dist/local/cloudflare-checkup/snapshot-file.js +5 -3
- package/package.json +1 -1
|
@@ -75,6 +75,8 @@ export const LOCAL_ERROR_HINTS = {
|
|
|
75
75
|
* hint names both ways out.
|
|
76
76
|
*/
|
|
77
77
|
export const ENV_TOKEN_AUTH_HINT = `Set ${CF_TOKEN_ENV} in this shell to a valid read-only Cloudflare API token (read -rs ${CF_TOKEN_ENV} && export ${CF_TOKEN_ENV}) and run the same command again, or unset it (or use --cf-auth profile) to sign in with your browser instead.`;
|
|
78
|
+
/** SNAPSHOT_INVALID for an `inspect` or `submit` path with no file: nothing to collect again, so how to make one. */
|
|
79
|
+
export const SNAPSHOT_MISSING_HINT = 'Check the file path. To collect a snapshot into a file, run `npx @vigilbase/cli cloudflare-checkup collect --out <file>`.';
|
|
78
80
|
/** CF_PERMISSION_DENIED in env mode: the token lacks a read permission; the browser sign-in is the other way out. */
|
|
79
81
|
export const ENV_TOKEN_PERMISSION_HINT = `The API token in ${CF_TOKEN_ENV} cannot read everything the checkup needs. Add the read permissions to it, or unset it (or use --cf-auth profile) to sign in with your browser instead, then run the same command again.`;
|
|
80
82
|
export class LocalCheckupError extends Error {
|
|
@@ -13,7 +13,7 @@ import { createHash, randomBytes } from 'node:crypto';
|
|
|
13
13
|
import { link, open, readFile, rename, rm, stat } from 'node:fs/promises';
|
|
14
14
|
import { basename, dirname, join } from 'node:path';
|
|
15
15
|
import { CloudflareCheckupSnapshotV1Schema, SNAPSHOT_LIMITS, SNAPSHOT_SCHEMA_VERSION, expandRuleRuns, snapshotIssueList, snapshotRejectReason, } from './contract.js';
|
|
16
|
-
import { LocalCheckupError } from './errors.js';
|
|
16
|
+
import { LocalCheckupError, SNAPSHOT_MISSING_HINT } from './errors.js';
|
|
17
17
|
export function sha256Hex(bytes) {
|
|
18
18
|
return createHash('sha256').update(bytes).digest('hex');
|
|
19
19
|
}
|
|
@@ -90,8 +90,10 @@ export function snapshotParseError(issues) {
|
|
|
90
90
|
/** Read, hash and validate a snapshot file against the vendored contract. */
|
|
91
91
|
export async function loadSnapshotFile(path) {
|
|
92
92
|
const info = await stat(path).catch(() => null);
|
|
93
|
-
if (!info
|
|
94
|
-
throw new LocalCheckupError('SNAPSHOT_INVALID', 'The snapshot file does not exist
|
|
93
|
+
if (!info)
|
|
94
|
+
throw new LocalCheckupError('SNAPSHOT_INVALID', 'The snapshot file does not exist.', { hint: SNAPSHOT_MISSING_HINT });
|
|
95
|
+
if (!info.isFile())
|
|
96
|
+
throw new LocalCheckupError('SNAPSHOT_INVALID', 'The snapshot path is not a file.', { hint: SNAPSHOT_MISSING_HINT });
|
|
95
97
|
if (info.size > SNAPSHOT_LIMITS.maxBytes) {
|
|
96
98
|
throw new LocalCheckupError('SNAPSHOT_TOO_LARGE', `The snapshot is larger than the ${SNAPSHOT_LIMITS.maxBytes / 1024 / 1024} MiB contract limit.`);
|
|
97
99
|
}
|