drizzle-sybase 2.0.0 → 2.0.1
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/dist/native/sybase_native.darwin-arm64.node +0 -0
- package/dist/native/sybase_native.darwin-x64.node +0 -0
- package/dist/native/sybase_native.win32-x64.node +0 -0
- package/package.json +8 -8
- package/scripts/build.sh +0 -0
- package/scripts/clean.ts +81 -0
- package/scripts/verify-published.ts +331 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drizzle-sybase",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Drizzle ORM driver for Sybase ASE with built-in FreeTDS native bindings",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ase",
|
|
@@ -45,15 +45,15 @@
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@types/node": "^26.
|
|
48
|
+
"@types/node": "^26.6.3",
|
|
49
49
|
"concurrently": "^10.0.5",
|
|
50
50
|
"husky": "^9.1.7",
|
|
51
|
-
"node-gyp": "^13.0.
|
|
52
|
-
"oxfmt": "^0.
|
|
53
|
-
"oxlint": "^1.
|
|
51
|
+
"node-gyp": "^13.0.2",
|
|
52
|
+
"oxfmt": "^0.71.0",
|
|
53
|
+
"oxlint": "^1.86.0",
|
|
54
54
|
"oxlint-tsgolint": "latest",
|
|
55
55
|
"typescript": "^7.0.2",
|
|
56
|
-
"vitest": "^
|
|
56
|
+
"vitest": "^5.0.2"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"drizzle-orm": "^1.0.0-rc.4"
|
|
@@ -65,12 +65,12 @@
|
|
|
65
65
|
"install": "echo 'native addon is prebuilt — skip node-gyp'",
|
|
66
66
|
"build": "tsc -p tsconfig.build.json",
|
|
67
67
|
"build:native": "node-gyp rebuild",
|
|
68
|
-
"test": "vitest",
|
|
68
|
+
"test": "vitest run",
|
|
69
69
|
"type": "tsc --noEmit",
|
|
70
70
|
"lint": "oxlint",
|
|
71
71
|
"lint:fix": "oxlint --fix",
|
|
72
72
|
"format": "oxfmt",
|
|
73
73
|
"check": "npm run lint && npm run type",
|
|
74
|
-
"clean": "
|
|
74
|
+
"clean": "node scripts/clean.ts \"**/node_modules\" \"**/dist\" pnpm-lock.yaml && pnpm i"
|
|
75
75
|
}
|
|
76
76
|
}
|
package/scripts/build.sh
CHANGED
|
File without changes
|
package/scripts/clean.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-platform `rm -rf` with glob support — a dependency-free replacement for
|
|
3
|
+
* `pnpm dlx rimraf`. Targets come from the command line only; the project's
|
|
4
|
+
* default list lives in the `clean` script in `package.json`.
|
|
5
|
+
*
|
|
6
|
+
* node scripts/clean.ts "**\/dist" "**\/node_modules" # delete every match
|
|
7
|
+
* node scripts/clean.ts -n "**\/dist" # dry run: print the matches
|
|
8
|
+
*
|
|
9
|
+
* Globbing uses the built-in `fs.globSync` and deletion the built-in recursive
|
|
10
|
+
* `fs.rm`, so nothing has to be installed or fetched — this keeps working when
|
|
11
|
+
* `node_modules` is already gone or broken. Deletions run concurrently (I/O
|
|
12
|
+
* bound: ~1.7x faster than sequential on six node_modules trees).
|
|
13
|
+
*
|
|
14
|
+
* Note (glob semantics, same as rimraf/minimatch): `*` and `**` do not match
|
|
15
|
+
* dot-entries, so hidden targets must be named explicitly (e.g. `**\/.cache`).
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { globSync } from "fs";
|
|
19
|
+
import { rm } from "fs/promises";
|
|
20
|
+
import { relative, resolve, sep } from "path";
|
|
21
|
+
import { parseArgs } from "util";
|
|
22
|
+
|
|
23
|
+
const { values, positionals: patterns } = parseArgs({
|
|
24
|
+
allowPositionals: true,
|
|
25
|
+
options: { "dry-run": { type: "boolean", short: "n", default: false } }
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const strayFlag = patterns.find(pattern => pattern.startsWith("-"));
|
|
29
|
+
if (!patterns.length || strayFlag) {
|
|
30
|
+
console.error(
|
|
31
|
+
strayFlag
|
|
32
|
+
? `Unknown option "${strayFlag}" (options must come before patterns).`
|
|
33
|
+
: "No patterns given.",
|
|
34
|
+
"\n\nUsage: node scripts/clean.ts [-n|--dry-run] <pattern...>"
|
|
35
|
+
);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const root = process.cwd();
|
|
40
|
+
const dryRun = values["dry-run"];
|
|
41
|
+
|
|
42
|
+
// `.git` is never a valid target and excluding it keeps the walk cheap. A
|
|
43
|
+
// callback (rather than a `**/.git/**` pattern) keeps this separator-agnostic,
|
|
44
|
+
// since `globSync` reports Windows paths with backslashes.
|
|
45
|
+
const matches = globSync(patterns, {
|
|
46
|
+
cwd: root,
|
|
47
|
+
exclude: path => /(?:^|[\\/])\.git(?:[\\/]|$)/.test(path)
|
|
48
|
+
})
|
|
49
|
+
.map(match => relative(root, resolve(root, match)))
|
|
50
|
+
// Never delete the working directory itself, nor anything outside it.
|
|
51
|
+
.filter(match => match && match !== ".." && !match.startsWith(".." + sep))
|
|
52
|
+
.sort();
|
|
53
|
+
|
|
54
|
+
// Drop matches nested inside another match — deleting the parent removes them
|
|
55
|
+
// anyway, and the log should only list what this process really deletes.
|
|
56
|
+
// Sorted input makes comparing against the last kept path sufficient (O(n)).
|
|
57
|
+
const targets: string[] = [];
|
|
58
|
+
for (const match of matches) {
|
|
59
|
+
const parent = targets.at(-1);
|
|
60
|
+
if (parent && match.startsWith(parent + sep)) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
targets.push(match);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!dryRun) {
|
|
67
|
+
await Promise.all(
|
|
68
|
+
// `maxRetries` covers Windows EBUSY/EPERM when a watcher still holds a handle.
|
|
69
|
+
targets.map(target =>
|
|
70
|
+
rm(resolve(root, target), { recursive: true, force: true, maxRetries: 5, retryDelay: 100 })
|
|
71
|
+
)
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
for (const target of targets) {
|
|
76
|
+
console.log(`${dryRun ? "Would remove" : "Removed"} ${target}`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!targets.length) {
|
|
80
|
+
console.log("Nothing to clean.");
|
|
81
|
+
}
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A published version is not live until an anonymous reader can fetch it.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this needs a check, and why the previous one could not work
|
|
5
|
+
*
|
|
6
|
+
* `pnpm publish` prints `✅ Published` as soon as the registry accepts the
|
|
7
|
+
* tarball, which is earlier than the point at which anyone can install it. So
|
|
8
|
+
* the release workflow verifies the result rather than trusting that line — and
|
|
9
|
+
* the verification it used was structurally unable to pass:
|
|
10
|
+
*
|
|
11
|
+
* ```sh
|
|
12
|
+
* sleep 30
|
|
13
|
+
* npm view "${PACKAGE}@${VERSION}" version 2>/dev/null || echo NOT_FOUND
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* `npm view pkg@version` does not read a per-version document. It fetches the
|
|
17
|
+
* **packument** — the whole package metadata — and looks the version up inside
|
|
18
|
+
* it. That document is CDN-cached with `cache-control: public, max-age=300`, so
|
|
19
|
+
* a read taken any time in the five minutes after a publish can be served a copy
|
|
20
|
+
* that predates it, so a 30-second wait reports `NOT_FOUND` for a version that
|
|
21
|
+
* was in fact published — and only passes when it happens to win the race
|
|
22
|
+
* against a cache expiry.
|
|
23
|
+
*
|
|
24
|
+
* Three things follow, and this script does all three:
|
|
25
|
+
*
|
|
26
|
+
* 1. **Read the per-version document, not the packument.** `/<name>/<version>`
|
|
27
|
+
* is served `cf-cache-status: DYNAMIC` — uncached — so it answers about the
|
|
28
|
+
* registry's state rather than about a cached snapshot.
|
|
29
|
+
* 2. **Poll.** The registry is eventually consistent, so a single sample is the
|
|
30
|
+
* wrong instrument no matter how long the preceding sleep is.
|
|
31
|
+
* 3. **Distinguish the failures.** The old check collapsed every outcome into
|
|
32
|
+
* `NOT_FOUND` by discarding stderr, so "not indexed yet", "published
|
|
33
|
+
* restricted" and "network broke" were one message. A 403 means the version
|
|
34
|
+
* exists but is not public — retrying cannot fix it, and it is the exact
|
|
35
|
+
* failure `--access public` exists to prevent — so it fails immediately,
|
|
36
|
+
* while a 404 is retried.
|
|
37
|
+
*
|
|
38
|
+
* The request carries **no credentials**, deliberately: an authenticated read
|
|
39
|
+
* succeeds for a restricted package, which would hide the one problem this is
|
|
40
|
+
* most needed for. It also HEADs the tarball, because a version document naming
|
|
41
|
+
* an unfetchable tarball is not an installable release.
|
|
42
|
+
*
|
|
43
|
+
* Usage:
|
|
44
|
+
* node scripts/verify-published.ts drizzle-sybase@1.2.3 @scope/pkg@1.2.3
|
|
45
|
+
* node scripts/verify-published.ts --attempts 60 --interval-ms 15000 pkg@1.0.0
|
|
46
|
+
* node scripts/verify-published.ts --registry http://localhost:8080 pkg@1.0.0
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
import path from "node:path";
|
|
50
|
+
|
|
51
|
+
/** Where to look. Overridable so a test can point at a local server. */
|
|
52
|
+
const DEFAULT_REGISTRY = "https://registry.npmjs.org";
|
|
53
|
+
/**
|
|
54
|
+
* Polling budget. 60 × 15s is approximately 15 minutes. npm took more than nine
|
|
55
|
+
* minutes to expose one accepted canary through the per-version endpoint, so a
|
|
56
|
+
* five-minute budget still produced a false failure despite avoiding the cached
|
|
57
|
+
* packument.
|
|
58
|
+
*/
|
|
59
|
+
const DEFAULT_ATTEMPTS = 60;
|
|
60
|
+
const DEFAULT_INTERVAL_MS = 15_000;
|
|
61
|
+
|
|
62
|
+
export interface VerifyOptions {
|
|
63
|
+
readonly registry?: string;
|
|
64
|
+
readonly attempts?: number;
|
|
65
|
+
readonly intervalMs?: number;
|
|
66
|
+
readonly log?: (line: string) => void;
|
|
67
|
+
/** Injectable so a test does not wait in real time. */
|
|
68
|
+
readonly sleep?: (ms: number) => Promise<void>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface PackageSpec {
|
|
72
|
+
readonly name: string;
|
|
73
|
+
readonly version: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export type VerifyResult =
|
|
77
|
+
| { readonly ok: true; readonly attempts: number }
|
|
78
|
+
| { readonly ok: false; readonly problem: string };
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Split `name@version`, allowing for a scope.
|
|
82
|
+
*
|
|
83
|
+
* The separator is the *last* `@`, because `@scope/pkg@1.0.0` has two and
|
|
84
|
+
* the first belongs to the scope.
|
|
85
|
+
*/
|
|
86
|
+
export function parseSpec(spec: string): PackageSpec {
|
|
87
|
+
const at = spec.lastIndexOf("@");
|
|
88
|
+
if (at <= 0) {
|
|
89
|
+
throw new Error(`not a <name>@<version> spec: ${spec}`);
|
|
90
|
+
}
|
|
91
|
+
const name = spec.slice(0, at);
|
|
92
|
+
const version = spec.slice(at + 1);
|
|
93
|
+
if (name.length === 0 || version.length === 0) {
|
|
94
|
+
throw new Error(`not a <name>@<version> spec: ${spec}`);
|
|
95
|
+
}
|
|
96
|
+
return { name, version };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Encode the package name and version as complete registry path segments. */
|
|
100
|
+
function versionUrl(registry: string, spec: PackageSpec): string {
|
|
101
|
+
return `${registry.replace(/\/$/, "")}/${encodeURIComponent(spec.name)}/${encodeURIComponent(spec.version)}`;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Poll until an anonymous reader can fetch the version and its tarball.
|
|
106
|
+
*
|
|
107
|
+
* Returns rather than throws, so the CLI can report every spec instead of
|
|
108
|
+
* stopping at the first one.
|
|
109
|
+
*/
|
|
110
|
+
export async function verifyPublished(
|
|
111
|
+
spec: PackageSpec,
|
|
112
|
+
options: VerifyOptions = {}
|
|
113
|
+
): Promise<VerifyResult> {
|
|
114
|
+
const registry = options.registry ?? DEFAULT_REGISTRY;
|
|
115
|
+
const attempts = options.attempts ?? DEFAULT_ATTEMPTS;
|
|
116
|
+
const intervalMs = options.intervalMs ?? DEFAULT_INTERVAL_MS;
|
|
117
|
+
const log = options.log ?? ((line: string) => console.log(line));
|
|
118
|
+
const sleep =
|
|
119
|
+
options.sleep ?? ((ms: number) => new Promise<void>(resolve => setTimeout(resolve, ms)));
|
|
120
|
+
|
|
121
|
+
const url = versionUrl(registry, spec);
|
|
122
|
+
const label = `${spec.name}@${spec.version}`;
|
|
123
|
+
let last = "no attempt made";
|
|
124
|
+
|
|
125
|
+
for (let attempt = 1; attempt <= attempts; attempt += 1) {
|
|
126
|
+
let response: Response;
|
|
127
|
+
try {
|
|
128
|
+
response = await fetch(url, {
|
|
129
|
+
headers: { accept: "application/json", "cache-control": "no-cache" }
|
|
130
|
+
});
|
|
131
|
+
} catch (cause) {
|
|
132
|
+
last = `request failed: ${cause instanceof Error ? cause.message : String(cause)}`;
|
|
133
|
+
if (attempt < attempts) {
|
|
134
|
+
await sleep(intervalMs);
|
|
135
|
+
}
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (response.status === 401 || response.status === 403) {
|
|
140
|
+
// Not a propagation delay: the version is there and the registry is
|
|
141
|
+
// refusing to serve it anonymously. Retrying cannot change that.
|
|
142
|
+
return {
|
|
143
|
+
ok: false,
|
|
144
|
+
problem:
|
|
145
|
+
`${label} is published but not readable anonymously (HTTP ${response.status}). ` +
|
|
146
|
+
`It was almost certainly published restricted — check with ` +
|
|
147
|
+
`\`npm access get status ${spec.name}\` and republish with \`--access public\`.`
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (response.status === 404) {
|
|
152
|
+
last = "HTTP 404 — not indexed yet";
|
|
153
|
+
log(` ${label}: not there yet (attempt ${attempt}/${attempts})`);
|
|
154
|
+
if (attempt < attempts) {
|
|
155
|
+
await sleep(intervalMs);
|
|
156
|
+
}
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (!response.ok) {
|
|
161
|
+
last = `HTTP ${response.status}`;
|
|
162
|
+
log(` ${label}: ${last} (attempt ${attempt}/${attempts})`);
|
|
163
|
+
if (attempt < attempts) {
|
|
164
|
+
await sleep(intervalMs);
|
|
165
|
+
}
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const document = (await response.json()) as { version?: unknown; dist?: { tarball?: unknown } };
|
|
170
|
+
if (document.version !== spec.version) {
|
|
171
|
+
// The registry answered for a different version than the path asked for,
|
|
172
|
+
// which would make every later assertion meaningless.
|
|
173
|
+
return {
|
|
174
|
+
ok: false,
|
|
175
|
+
problem: `${label}: the registry returned version ${JSON.stringify(document.version)}`
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const tarball = document.dist?.tarball;
|
|
180
|
+
if (typeof tarball !== "string" || tarball.length === 0) {
|
|
181
|
+
return { ok: false, problem: `${label}: the version document names no tarball` };
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// A version document naming a tarball nobody can fetch is not a release.
|
|
185
|
+
const head = await fetch(tarball, { method: "HEAD" }).catch(() => undefined);
|
|
186
|
+
if (head === undefined || !head.ok) {
|
|
187
|
+
last = `tarball not fetchable (${head === undefined ? "request failed" : `HTTP ${head.status}`})`;
|
|
188
|
+
log(` ${label}: ${last} (attempt ${attempt}/${attempts})`);
|
|
189
|
+
if (attempt < attempts) {
|
|
190
|
+
await sleep(intervalMs);
|
|
191
|
+
}
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
log(`✓ ${label} is live and installable (attempt ${attempt}/${attempts})`);
|
|
196
|
+
return { ok: true, attempts: attempt };
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return {
|
|
200
|
+
ok: false,
|
|
201
|
+
problem:
|
|
202
|
+
`${label} did not become readable within ${attempts} attempt(s) ` +
|
|
203
|
+
`(last: ${last}). Anonymous reads only — if the package published ` +
|
|
204
|
+
`successfully, check that it is public: \`npm access get status ${spec.name}\`.`
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Does this exact version exist on the registry at all?
|
|
210
|
+
*
|
|
211
|
+
* Used by the publish steps' idempotency guard, which has the same stale-read
|
|
212
|
+
* problem as the verification above but a worse consequence: a guard that fails
|
|
213
|
+
* to see an already-published version makes the workflow publish over it, and
|
|
214
|
+
* npm answers that with `cannot publish over the previously published version`.
|
|
215
|
+
* That turns a re-run after a partial release — the case the guard exists for —
|
|
216
|
+
* into a hard failure.
|
|
217
|
+
*
|
|
218
|
+
* Unlike {@link verifyPublished} this makes one request, does not fetch the
|
|
219
|
+
* tarball, and treats 401/403 as **present**: the version is there and merely
|
|
220
|
+
* not readable anonymously, so republishing would be rejected. Anything
|
|
221
|
+
* indeterminate reports absent, which preserves the previous behaviour of
|
|
222
|
+
* attempting the publish and letting the registry arbitrate.
|
|
223
|
+
*/
|
|
224
|
+
export async function versionExists(
|
|
225
|
+
spec: PackageSpec,
|
|
226
|
+
options: Pick<VerifyOptions, "registry"> = {}
|
|
227
|
+
): Promise<boolean> {
|
|
228
|
+
const url = versionUrl(options.registry ?? DEFAULT_REGISTRY, spec);
|
|
229
|
+
try {
|
|
230
|
+
const response = await fetch(url, {
|
|
231
|
+
headers: { accept: "application/json", "cache-control": "no-cache" }
|
|
232
|
+
});
|
|
233
|
+
if (response.status === 401 || response.status === 403) {
|
|
234
|
+
return true;
|
|
235
|
+
}
|
|
236
|
+
if (!response.ok) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
const document = (await response.json()) as { version?: unknown };
|
|
240
|
+
return document.version === spec.version;
|
|
241
|
+
} catch {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
interface ParsedArgs {
|
|
247
|
+
readonly specs: readonly string[];
|
|
248
|
+
readonly exists: boolean;
|
|
249
|
+
readonly options: VerifyOptions;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function parseArgs(argv: readonly string[]): ParsedArgs {
|
|
253
|
+
const specs: string[] = [];
|
|
254
|
+
let registry: string | undefined;
|
|
255
|
+
let attempts: number | undefined;
|
|
256
|
+
let intervalMs: number | undefined;
|
|
257
|
+
let exists = false;
|
|
258
|
+
|
|
259
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
260
|
+
const arg = argv[index]!;
|
|
261
|
+
const next = (): string => {
|
|
262
|
+
const value = argv[index + 1];
|
|
263
|
+
if (value === undefined) {
|
|
264
|
+
throw new Error(`${arg} needs a value`);
|
|
265
|
+
}
|
|
266
|
+
index += 1;
|
|
267
|
+
return value;
|
|
268
|
+
};
|
|
269
|
+
if (arg === "--registry") {
|
|
270
|
+
registry = next();
|
|
271
|
+
} else if (arg === "--attempts") {
|
|
272
|
+
attempts = Number(next());
|
|
273
|
+
} else if (arg === "--interval-ms") {
|
|
274
|
+
intervalMs = Number(next());
|
|
275
|
+
} else if (arg === "--exists") {
|
|
276
|
+
exists = true;
|
|
277
|
+
} else if (arg.startsWith("--")) {
|
|
278
|
+
throw new Error(`unknown flag: ${arg}`);
|
|
279
|
+
} else {
|
|
280
|
+
specs.push(arg);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if (specs.length === 0) {
|
|
285
|
+
throw new Error("usage: node scripts/verify-published.ts [--exists] <name>@<version> [...]");
|
|
286
|
+
}
|
|
287
|
+
if (exists && specs.length !== 1) {
|
|
288
|
+
throw new Error("--exists takes exactly one <name>@<version>");
|
|
289
|
+
}
|
|
290
|
+
return {
|
|
291
|
+
specs,
|
|
292
|
+
exists,
|
|
293
|
+
options: {
|
|
294
|
+
...(registry === undefined ? {} : { registry }),
|
|
295
|
+
...(attempts === undefined ? {} : { attempts }),
|
|
296
|
+
...(intervalMs === undefined ? {} : { intervalMs })
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
async function main(): Promise<void> {
|
|
302
|
+
const { specs, exists, options } = parseArgs(process.argv.slice(2));
|
|
303
|
+
|
|
304
|
+
if (exists) {
|
|
305
|
+
const present = await versionExists(parseSpec(specs[0]!), options);
|
|
306
|
+
process.exitCode = present ? 0 : 1;
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const problems: string[] = [];
|
|
311
|
+
for (const spec of specs) {
|
|
312
|
+
const result = await verifyPublished(parseSpec(spec), options);
|
|
313
|
+
if (!result.ok) {
|
|
314
|
+
problems.push(result.problem);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (problems.length > 0) {
|
|
319
|
+
for (const problem of problems) {
|
|
320
|
+
console.error(`✗ ${problem}`);
|
|
321
|
+
}
|
|
322
|
+
process.exitCode = 1;
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
console.log(`✓ verify:published — ${specs.length} package version(s) live on the registry.`);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// Only run when invoked directly, so importing it for tests does not exit the process.
|
|
329
|
+
if (process.argv[1] && path.resolve(process.argv[1]) === path.resolve(import.meta.filename)) {
|
|
330
|
+
void main();
|
|
331
|
+
}
|