@supatype/cli 0.1.0-alpha.6 → 0.1.0-alpha.8
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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +208 -1
- package/.turbo/turbo-typecheck.log +1 -1
- package/dist/app/proxy-dev-app.d.ts +13 -0
- package/dist/app/proxy-dev-app.d.ts.map +1 -0
- package/dist/app/proxy-dev-app.js +53 -0
- package/dist/app/proxy-dev-app.js.map +1 -0
- package/dist/app-config.d.ts +7 -0
- package/dist/app-config.d.ts.map +1 -0
- package/dist/app-config.js +113 -0
- package/dist/app-config.js.map +1 -0
- package/dist/augmentation-generator.d.ts +2 -0
- package/dist/augmentation-generator.d.ts.map +1 -0
- package/dist/augmentation-generator.js +111 -0
- package/dist/augmentation-generator.js.map +1 -0
- package/dist/binary-cache.d.ts +94 -0
- package/dist/binary-cache.d.ts.map +1 -0
- package/dist/binary-cache.js +669 -0
- package/dist/binary-cache.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +13 -7
- package/dist/cli.js.map +1 -1
- package/dist/commands/admin.d.ts.map +1 -1
- package/dist/commands/admin.js +4 -3
- package/dist/commands/admin.js.map +1 -1
- package/dist/commands/app.d.ts.map +1 -1
- package/dist/commands/app.js +56 -209
- package/dist/commands/app.js.map +1 -1
- package/dist/commands/cache.d.ts +6 -0
- package/dist/commands/cache.d.ts.map +1 -0
- package/dist/commands/cache.js +105 -0
- package/dist/commands/cache.js.map +1 -0
- package/dist/commands/cloud.d.ts +20 -0
- package/dist/commands/cloud.d.ts.map +1 -1
- package/dist/commands/cloud.js +50 -52
- package/dist/commands/cloud.js.map +1 -1
- package/dist/commands/db.d.ts.map +1 -1
- package/dist/commands/db.js +47 -54
- package/dist/commands/db.js.map +1 -1
- package/dist/commands/deploy.d.ts +2 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +79 -52
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts +11 -0
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +759 -385
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/diff.d.ts.map +1 -1
- package/dist/commands/diff.js +30 -15
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/engine.d.ts +1 -3
- package/dist/commands/engine.d.ts.map +1 -1
- package/dist/commands/engine.js +13 -85
- package/dist/commands/engine.js.map +1 -1
- package/dist/commands/functions.d.ts.map +1 -1
- package/dist/commands/functions.js +92 -105
- package/dist/commands/functions.js.map +1 -1
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +22 -12
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +137 -410
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/migrate-from-v1.d.ts +5 -0
- package/dist/commands/migrate-from-v1.d.ts.map +1 -0
- package/dist/commands/migrate-from-v1.js +125 -0
- package/dist/commands/migrate-from-v1.js.map +1 -0
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +27 -23
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/pg.d.ts +8 -0
- package/dist/commands/pg.d.ts.map +1 -0
- package/dist/commands/pg.js +102 -0
- package/dist/commands/pg.js.map +1 -0
- package/dist/commands/pull.d.ts.map +1 -1
- package/dist/commands/pull.js +5 -66
- package/dist/commands/pull.js.map +1 -1
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +128 -38
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/seed.d.ts +2 -0
- package/dist/commands/seed.d.ts.map +1 -1
- package/dist/commands/seed.js +44 -11
- package/dist/commands/seed.js.map +1 -1
- package/dist/commands/self-host.d.ts +7 -1
- package/dist/commands/self-host.d.ts.map +1 -1
- package/dist/commands/self-host.js +272 -758
- package/dist/commands/self-host.js.map +1 -1
- package/dist/commands/self-update.d.ts +9 -0
- package/dist/commands/self-update.d.ts.map +1 -0
- package/dist/commands/self-update.js +33 -0
- package/dist/commands/self-update.js.map +1 -0
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +4 -3
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/types.d.ts +3 -0
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/types.js +62 -0
- package/dist/commands/types.js.map +1 -0
- package/dist/commands/update.d.ts +7 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +93 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/components.d.ts +5 -0
- package/dist/components.d.ts.map +1 -0
- package/dist/components.js +3 -0
- package/dist/components.js.map +1 -0
- package/dist/config.d.ts +10 -51
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +101 -33
- package/dist/config.js.map +1 -1
- package/dist/dev-compose.d.ts +17 -0
- package/dist/dev-compose.d.ts.map +1 -0
- package/dist/dev-compose.js +374 -0
- package/dist/dev-compose.js.map +1 -0
- package/dist/diff-output.d.ts +4 -0
- package/dist/diff-output.d.ts.map +1 -0
- package/dist/diff-output.js +12 -0
- package/dist/diff-output.js.map +1 -0
- package/dist/docker-postgres.d.ts +57 -0
- package/dist/docker-postgres.d.ts.map +1 -0
- package/dist/docker-postgres.js +208 -0
- package/dist/docker-postgres.js.map +1 -0
- package/dist/engine-client.d.ts +69 -0
- package/dist/engine-client.d.ts.map +1 -0
- package/dist/engine-client.js +157 -0
- package/dist/engine-client.js.map +1 -0
- package/dist/ensure-binary.d.ts +7 -0
- package/dist/ensure-binary.d.ts.map +1 -0
- package/dist/ensure-binary.js +17 -0
- package/dist/ensure-binary.js.map +1 -0
- package/dist/functions-router-gen.d.ts +14 -0
- package/dist/functions-router-gen.d.ts.map +1 -0
- package/dist/functions-router-gen.js +199 -0
- package/dist/functions-router-gen.js.map +1 -0
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/kong-config.d.ts +25 -0
- package/dist/kong-config.d.ts.map +1 -0
- package/dist/kong-config.js +71 -0
- package/dist/kong-config.js.map +1 -0
- package/dist/local-gateway.d.ts +7 -0
- package/dist/local-gateway.d.ts.map +1 -0
- package/dist/local-gateway.js +9 -0
- package/dist/local-gateway.js.map +1 -0
- package/dist/local-storage.d.ts +8 -0
- package/dist/local-storage.d.ts.map +1 -0
- package/dist/local-storage.js +14 -0
- package/dist/local-storage.js.map +1 -0
- package/dist/pgbouncer-userlist.d.ts +5 -0
- package/dist/pgbouncer-userlist.d.ts.map +1 -0
- package/dist/pgbouncer-userlist.js +14 -0
- package/dist/pgbouncer-userlist.js.map +1 -0
- package/dist/postgres-ctl.d.ts +44 -0
- package/dist/postgres-ctl.d.ts.map +1 -0
- package/dist/postgres-ctl.js +137 -0
- package/dist/postgres-ctl.js.map +1 -0
- package/dist/process-manager.d.ts +43 -0
- package/dist/process-manager.d.ts.map +1 -0
- package/dist/process-manager.js +135 -0
- package/dist/process-manager.js.map +1 -0
- package/dist/project-config.d.ts +235 -0
- package/dist/project-config.d.ts.map +1 -0
- package/dist/project-config.js +160 -0
- package/dist/project-config.js.map +1 -0
- package/dist/pull-utils.d.ts +15 -0
- package/dist/pull-utils.d.ts.map +1 -1
- package/dist/pull-utils.js +12 -0
- package/dist/pull-utils.js.map +1 -1
- package/dist/release-pins.d.ts +7 -0
- package/dist/release-pins.d.ts.map +1 -0
- package/dist/release-pins.js +27 -0
- package/dist/release-pins.js.map +1 -0
- package/dist/release-public-key.d.ts +8 -0
- package/dist/release-public-key.d.ts.map +1 -0
- package/dist/release-public-key.js +13 -0
- package/dist/release-public-key.js.map +1 -0
- package/dist/runtime-routes.d.ts +34 -0
- package/dist/runtime-routes.d.ts.map +1 -0
- package/dist/runtime-routes.js +252 -0
- package/dist/runtime-routes.js.map +1 -0
- package/dist/schema-ast-v2.d.ts +127 -0
- package/dist/schema-ast-v2.d.ts.map +1 -0
- package/dist/schema-ast-v2.js +226 -0
- package/dist/schema-ast-v2.js.map +1 -0
- package/dist/scripts/postinstall.d.ts +5 -6
- package/dist/scripts/postinstall.d.ts.map +1 -1
- package/dist/scripts/postinstall.js +36 -20
- package/dist/scripts/postinstall.js.map +1 -1
- package/dist/self-host-compose.d.ts +22 -0
- package/dist/self-host-compose.d.ts.map +1 -0
- package/dist/self-host-compose.js +347 -0
- package/dist/self-host-compose.js.map +1 -0
- package/dist/storage-provision.d.ts +24 -0
- package/dist/storage-provision.d.ts.map +1 -0
- package/dist/storage-provision.js +44 -0
- package/dist/storage-provision.js.map +1 -0
- package/dist/studio-admin-roles.d.ts +7 -0
- package/dist/studio-admin-roles.d.ts.map +1 -0
- package/dist/studio-admin-roles.js +14 -0
- package/dist/studio-admin-roles.js.map +1 -0
- package/dist/studio-dev-server.d.ts +22 -0
- package/dist/studio-dev-server.d.ts.map +1 -0
- package/dist/studio-dev-server.js +28 -0
- package/dist/studio-dev-server.js.map +1 -0
- package/dist/systemd.d.ts +26 -0
- package/dist/systemd.d.ts.map +1 -0
- package/dist/systemd.js +102 -0
- package/dist/systemd.js.map +1 -0
- package/dist/tsx-runner.d.ts.map +1 -1
- package/dist/tsx-runner.js +9 -2
- package/dist/tsx-runner.js.map +1 -1
- package/dist/type-extractor.d.ts +4 -0
- package/dist/type-extractor.d.ts.map +1 -0
- package/dist/type-extractor.js +1213 -0
- package/dist/type-extractor.js.map +1 -0
- package/dist/type-resolver.d.ts +33 -0
- package/dist/type-resolver.d.ts.map +1 -0
- package/dist/type-resolver.js +338 -0
- package/dist/type-resolver.js.map +1 -0
- package/package.json +4 -3
- package/releases/deno/VERSION +1 -0
- package/scripts/mirror-deno-release.sh +76 -0
- package/src/TYPE-RESOLUTION.md +294 -0
- package/src/app/proxy-dev-app.ts +67 -0
- package/src/app-config.ts +128 -0
- package/src/augmentation-generator.ts +126 -0
- package/src/binary-cache.ts +822 -0
- package/src/cli.ts +13 -8
- package/src/commands/admin.ts +4 -3
- package/src/commands/app.ts +67 -231
- package/src/commands/cache.ts +117 -0
- package/src/commands/cloud.ts +63 -64
- package/src/commands/db.ts +54 -63
- package/src/commands/deploy.ts +96 -62
- package/src/commands/dev.ts +933 -405
- package/src/commands/diff.ts +31 -29
- package/src/commands/engine.ts +13 -116
- package/src/commands/functions.ts +97 -115
- package/src/commands/generate.ts +23 -10
- package/src/commands/init.ts +149 -414
- package/src/commands/migrate-from-v1.ts +131 -0
- package/src/commands/migrate.ts +27 -23
- package/src/commands/pg.ts +133 -0
- package/src/commands/pull.ts +6 -85
- package/src/commands/push.ts +161 -56
- package/src/commands/seed.ts +54 -12
- package/src/commands/self-host.ts +312 -880
- package/src/commands/self-update.ts +45 -0
- package/src/commands/status.ts +4 -3
- package/src/commands/types.ts +76 -0
- package/src/commands/update.ts +109 -0
- package/src/components.ts +6 -0
- package/src/config.ts +127 -94
- package/src/dev-compose.ts +455 -0
- package/src/diff-output.ts +12 -0
- package/src/docker-postgres.ts +295 -0
- package/src/engine-client.ts +236 -0
- package/src/ensure-binary.ts +28 -0
- package/src/functions-router-gen.ts +224 -0
- package/src/index.ts +4 -12
- package/src/kong-config.ts +93 -0
- package/src/local-gateway.ts +9 -0
- package/src/local-storage.ts +14 -0
- package/src/pgbouncer-userlist.ts +15 -0
- package/src/postgres-ctl.ts +171 -0
- package/src/process-manager.ts +168 -0
- package/src/project-config.ts +386 -0
- package/src/pull-utils.ts +24 -0
- package/src/release-pins.ts +31 -0
- package/src/release-public-key.ts +12 -0
- package/src/runtime-routes.ts +291 -0
- package/src/schema-ast-v2.ts +324 -0
- package/src/scripts/postinstall.ts +36 -25
- package/src/self-host-compose.ts +389 -0
- package/src/storage-provision.ts +58 -0
- package/src/studio-admin-roles.ts +16 -0
- package/src/studio-dev-server.ts +53 -0
- package/src/systemd.ts +137 -0
- package/src/tsx-runner.ts +11 -1
- package/src/type-extractor.ts +1479 -0
- package/src/type-resolver.ts +457 -0
- package/tests/app-command.test.ts +54 -0
- package/tests/augmentation-generator.test.ts +59 -0
- package/tests/binary-cache-cloud-overrides.test.ts +123 -0
- package/tests/cached-artifact-format.test.ts +84 -0
- package/tests/cli-help.test.ts +40 -14
- package/tests/config.test.ts +171 -37
- package/tests/docker-postgres.test.ts +39 -0
- package/tests/engine-distribution.test.ts +3 -3
- package/tests/ensure-binary.test.ts +59 -0
- package/tests/init.test.ts +28 -86
- package/tests/migrate-from-v1.test.ts +29 -0
- package/tests/normalize-admin-config.test.ts +48 -0
- package/tests/pg-spawn-env.test.ts +18 -0
- package/tests/postgres-archive-tag.test.ts +9 -0
- package/tests/proxy-dev-app.test.ts +33 -0
- package/tests/pull-utils.test.ts +36 -1
- package/tests/release-pins.test.ts +28 -0
- package/tests/runtime-contract.test.ts +351 -0
- package/tests/seed-discover.test.ts +31 -0
- package/tests/studio-admin-roles.test.ts +27 -0
- package/tests/tsconfig.json +9 -0
- package/tests/type-extractor.test.ts +985 -0
- package/tests/type-resolver.test.ts +59 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/vitest.config.ts +12 -0
- package/dist/engine/cache.d.ts +0 -37
- package/dist/engine/cache.d.ts.map +0 -1
- package/dist/engine/cache.js +0 -121
- package/dist/engine/cache.js.map +0 -1
- package/dist/engine/download.d.ts +0 -19
- package/dist/engine/download.d.ts.map +0 -1
- package/dist/engine/download.js +0 -108
- package/dist/engine/download.js.map +0 -1
- package/dist/engine/platform.d.ts +0 -24
- package/dist/engine/platform.d.ts.map +0 -1
- package/dist/engine/platform.js +0 -50
- package/dist/engine/platform.js.map +0 -1
- package/dist/engine/resolve.d.ts +0 -37
- package/dist/engine/resolve.d.ts.map +0 -1
- package/dist/engine/resolve.js +0 -133
- package/dist/engine/resolve.js.map +0 -1
- package/dist/engine/update-notify.d.ts +0 -11
- package/dist/engine/update-notify.d.ts.map +0 -1
- package/dist/engine/update-notify.js +0 -43
- package/dist/engine/update-notify.js.map +0 -1
- package/dist/engine/verify.d.ts +0 -50
- package/dist/engine/verify.d.ts.map +0 -1
- package/dist/engine/verify.js +0 -161
- package/dist/engine/verify.js.map +0 -1
- package/dist/engine-version.d.ts +0 -35
- package/dist/engine-version.d.ts.map +0 -1
- package/dist/engine-version.js +0 -35
- package/dist/engine-version.js.map +0 -1
- package/dist/engine.d.ts +0 -34
- package/dist/engine.d.ts.map +0 -1
- package/dist/engine.js +0 -76
- package/dist/engine.js.map +0 -1
- package/src/engine/cache.ts +0 -135
- package/src/engine/download.ts +0 -143
- package/src/engine/platform.ts +0 -66
- package/src/engine/resolve.ts +0 -197
- package/src/engine/update-notify.ts +0 -50
- package/src/engine/verify.ts +0 -206
- package/src/engine-version.ts +0 -39
- package/src/engine.ts +0 -99
package/dist/engine/download.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Engine binary download with progress bar, retry, and proxy support.
|
|
3
|
-
*/
|
|
4
|
-
import { createWriteStream } from "node:fs";
|
|
5
|
-
import { Readable } from "node:stream";
|
|
6
|
-
import { pipeline } from "node:stream/promises";
|
|
7
|
-
const MAX_RETRIES = 3;
|
|
8
|
-
const RETRY_DELAYS = [1000, 3000, 10000];
|
|
9
|
-
/**
|
|
10
|
-
* Download a file with retry and optional progress bar.
|
|
11
|
-
* Respects HTTP_PROXY / HTTPS_PROXY environment variables.
|
|
12
|
-
*/
|
|
13
|
-
export async function downloadFile(options) {
|
|
14
|
-
const { url, dest, showProgress = false, label } = options;
|
|
15
|
-
let lastError;
|
|
16
|
-
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
|
17
|
-
try {
|
|
18
|
-
await doDownload(url, dest, showProgress, label);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
catch (err) {
|
|
22
|
-
lastError = err instanceof Error ? err : new Error(String(err));
|
|
23
|
-
if (attempt < MAX_RETRIES - 1) {
|
|
24
|
-
const delay = RETRY_DELAYS[attempt];
|
|
25
|
-
process.stderr.write(`Download failed. Retrying (${attempt + 2}/${MAX_RETRIES})...\n`);
|
|
26
|
-
await sleep(delay);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
throw new Error(`Failed to download after ${MAX_RETRIES} attempts: ${lastError?.message}`);
|
|
31
|
-
}
|
|
32
|
-
async function doDownload(url, dest, showProgress, label) {
|
|
33
|
-
const fetchOptions = buildFetchOptions(url);
|
|
34
|
-
const res = await fetch(url, fetchOptions);
|
|
35
|
-
if (!res.ok) {
|
|
36
|
-
throw new Error(`HTTP ${res.status} ${res.statusText}: ${url}`);
|
|
37
|
-
}
|
|
38
|
-
if (!res.body) {
|
|
39
|
-
throw new Error(`No response body: ${url}`);
|
|
40
|
-
}
|
|
41
|
-
const contentLength = Number(res.headers.get("content-length") || 0);
|
|
42
|
-
const out = createWriteStream(dest);
|
|
43
|
-
if (showProgress && contentLength > 0 && process.stderr.isTTY) {
|
|
44
|
-
const progressStream = createProgressStream(contentLength, label);
|
|
45
|
-
await pipeline(Readable.fromWeb(res.body), progressStream, out);
|
|
46
|
-
// Clear the progress line
|
|
47
|
-
process.stderr.write("\n");
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
if (showProgress && label) {
|
|
51
|
-
process.stderr.write(`${label}...\n`);
|
|
52
|
-
}
|
|
53
|
-
await pipeline(Readable.fromWeb(res.body), out);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Build fetch options respecting proxy env vars.
|
|
58
|
-
*/
|
|
59
|
-
function buildFetchOptions(url) {
|
|
60
|
-
const opts = {};
|
|
61
|
-
// Node.js 18+ fetch supports the proxy via undici dispatcher.
|
|
62
|
-
// For simplicity, we rely on the global-agent or undici proxy support.
|
|
63
|
-
// The user should set HTTPS_PROXY or HTTP_PROXY env vars.
|
|
64
|
-
// Node.js 22+ automatically respects these in fetch().
|
|
65
|
-
//
|
|
66
|
-
// For older Node.js, users can install global-agent or similar.
|
|
67
|
-
return opts;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Creates a Transform stream that logs download progress to stderr.
|
|
71
|
-
*/
|
|
72
|
-
function createProgressStream(totalBytes, label) {
|
|
73
|
-
const { Transform } = require("node:stream");
|
|
74
|
-
let downloaded = 0;
|
|
75
|
-
return new Transform({
|
|
76
|
-
transform(chunk, _encoding, callback) {
|
|
77
|
-
downloaded += chunk.length;
|
|
78
|
-
const percent = Math.round((downloaded / totalBytes) * 100);
|
|
79
|
-
const mb = (downloaded / (1024 * 1024)).toFixed(1);
|
|
80
|
-
const totalMb = (totalBytes / (1024 * 1024)).toFixed(1);
|
|
81
|
-
const barWidth = 30;
|
|
82
|
-
const filled = Math.round((percent / 100) * barWidth);
|
|
83
|
-
const bar = "=".repeat(filled) + " ".repeat(barWidth - filled);
|
|
84
|
-
const prefix = label || "Downloading";
|
|
85
|
-
process.stderr.write(`\r${prefix} ${mb}MB/${totalMb}MB [${bar}] ${percent}%`);
|
|
86
|
-
this.push(chunk);
|
|
87
|
-
callback();
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
function sleep(ms) {
|
|
92
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Fetch a JSON file from a URL. Returns undefined on failure.
|
|
96
|
-
*/
|
|
97
|
-
export async function fetchJson(url) {
|
|
98
|
-
try {
|
|
99
|
-
const res = await fetch(url);
|
|
100
|
-
if (!res.ok)
|
|
101
|
-
return undefined;
|
|
102
|
-
return (await res.json());
|
|
103
|
-
}
|
|
104
|
-
catch {
|
|
105
|
-
return undefined;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
//# sourceMappingURL=download.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"download.js","sourceRoot":"","sources":["../../src/engine/download.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,QAAQ,EA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,CAAA;YAChB,QAAQ,EAAE,CAAA;QACZ,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;AAC1D,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAI,GAAW;IAC5C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAA;QAC5B,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,OAAO,SAAS,CAAA;QAC7B,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAM,CAAA;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Platform detection for engine binary downloads.
|
|
3
|
-
* Maps Node.js platform/arch to the binary naming convention.
|
|
4
|
-
*/
|
|
5
|
-
export interface PlatformInfo {
|
|
6
|
-
os: "linux" | "darwin" | "win";
|
|
7
|
-
arch: "x64" | "arm64";
|
|
8
|
-
binaryName: string;
|
|
9
|
-
ext: string;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Detect the current platform and return the binary info.
|
|
13
|
-
* Throws on unsupported platforms with a helpful message.
|
|
14
|
-
*/
|
|
15
|
-
export declare function detectPlatform(): PlatformInfo;
|
|
16
|
-
/**
|
|
17
|
-
* Build the artifact filename for a given version and platform.
|
|
18
|
-
*/
|
|
19
|
-
export declare function getArtifactName(version: string, platform: PlatformInfo): string;
|
|
20
|
-
/**
|
|
21
|
-
* Build the CDN download URL for a given version and artifact.
|
|
22
|
-
*/
|
|
23
|
-
export declare function getCdnUrl(baseUrl: string, version: string, filename: string): string;
|
|
24
|
-
//# sourceMappingURL=platform.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/engine/platform.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAA;IAC9B,IAAI,EAAE,KAAK,GAAG,OAAO,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,GAAG,EAAE,MAAM,CAAA;CACZ;AAkBD;;;GAGG;AACH,wBAAgB,cAAc,IAAI,YAAY,CAmB7C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,MAAM,CAE/E;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpF"}
|
package/dist/engine/platform.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Platform detection for engine binary downloads.
|
|
3
|
-
* Maps Node.js platform/arch to the binary naming convention.
|
|
4
|
-
*/
|
|
5
|
-
const PLATFORM_MAP = {
|
|
6
|
-
"darwin-arm64": { os: "darwin", arch: "arm64" },
|
|
7
|
-
"darwin-x64": { os: "darwin", arch: "x64" },
|
|
8
|
-
"linux-arm64": { os: "linux", arch: "arm64" },
|
|
9
|
-
"linux-x64": { os: "linux", arch: "x64" },
|
|
10
|
-
"win32-x64": { os: "win", arch: "x64" },
|
|
11
|
-
};
|
|
12
|
-
const SUPPORTED_PLATFORMS = [
|
|
13
|
-
"linux-x64",
|
|
14
|
-
"linux-arm64",
|
|
15
|
-
"darwin-x64",
|
|
16
|
-
"darwin-arm64",
|
|
17
|
-
"win-x64",
|
|
18
|
-
];
|
|
19
|
-
/**
|
|
20
|
-
* Detect the current platform and return the binary info.
|
|
21
|
-
* Throws on unsupported platforms with a helpful message.
|
|
22
|
-
*/
|
|
23
|
-
export function detectPlatform() {
|
|
24
|
-
const key = `${process.platform}-${process.arch}`;
|
|
25
|
-
const mapped = PLATFORM_MAP[key];
|
|
26
|
-
if (!mapped) {
|
|
27
|
-
throw new Error(`Supatype engine is not available for ${process.platform}-${process.arch}.\n` +
|
|
28
|
-
`Supported platforms: ${SUPPORTED_PLATFORMS.join(", ")}`);
|
|
29
|
-
}
|
|
30
|
-
const ext = mapped.os === "win" ? ".exe" : "";
|
|
31
|
-
return {
|
|
32
|
-
os: mapped.os,
|
|
33
|
-
arch: mapped.arch,
|
|
34
|
-
binaryName: `supatype-engine${ext}`,
|
|
35
|
-
ext,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Build the artifact filename for a given version and platform.
|
|
40
|
-
*/
|
|
41
|
-
export function getArtifactName(version, platform) {
|
|
42
|
-
return `supatype-engine-${version}-${platform.os}-${platform.arch}${platform.ext}`;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Build the CDN download URL for a given version and artifact.
|
|
46
|
-
*/
|
|
47
|
-
export function getCdnUrl(baseUrl, version, filename) {
|
|
48
|
-
return `${baseUrl}/v${version}/${filename}`;
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=platform.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../../src/engine/platform.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,MAAM,YAAY,GAA2E;IAC3F,cAAc,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE;IAC/C,YAAY,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE;IAC3C,aAAa,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE;IAC7C,WAAW,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EA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
|
1
|
-
/**
|
|
2
|
-
* Engine resolver — orchestrates binary download, verification, and caching.
|
|
3
|
-
*
|
|
4
|
-
* Resolution flow:
|
|
5
|
-
* 1. Check local cache for the pinned version
|
|
6
|
-
* 2. If cached and valid, return cached path
|
|
7
|
-
* 3. If not cached, download from CDN (with GitHub Releases fallback)
|
|
8
|
-
* 4. Verify signature + checksum
|
|
9
|
-
* 5. Cache the verified binary
|
|
10
|
-
* 6. Return the cached path
|
|
11
|
-
*/
|
|
12
|
-
export interface ResolveResult {
|
|
13
|
-
binaryPath: string;
|
|
14
|
-
version: string;
|
|
15
|
-
fromCache: boolean;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Resolve the engine binary path, downloading if necessary.
|
|
19
|
-
*/
|
|
20
|
-
export declare function resolveEngine(version?: string): Promise<ResolveResult>;
|
|
21
|
-
/**
|
|
22
|
-
* Check for the latest engine version from CDN.
|
|
23
|
-
*/
|
|
24
|
-
export interface LatestVersionInfo {
|
|
25
|
-
version: string;
|
|
26
|
-
date: string;
|
|
27
|
-
}
|
|
28
|
-
export declare function checkLatestVersion(): Promise<LatestVersionInfo | undefined>;
|
|
29
|
-
/**
|
|
30
|
-
* Check version compatibility.
|
|
31
|
-
* Engine and CLI must share the same major version.
|
|
32
|
-
*/
|
|
33
|
-
export declare function checkVersionCompatibility(engineVersion: string, expectedVersion: string): {
|
|
34
|
-
compatible: boolean;
|
|
35
|
-
message?: string;
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/engine/resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAeH,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,OAAO,CAAA;CACnB;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,OAAO,GAAE,MAAuB,GAC/B,OAAO,CAAC,aAAa,CAAC,CAgFxB;AA0CD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;CACb;AAED,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAEjF;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,MAAM,EACrB,eAAe,EAAE,MAAM,GACtB;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAc3C"}
|
package/dist/engine/resolve.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Engine resolver — orchestrates binary download, verification, and caching.
|
|
3
|
-
*
|
|
4
|
-
* Resolution flow:
|
|
5
|
-
* 1. Check local cache for the pinned version
|
|
6
|
-
* 2. If cached and valid, return cached path
|
|
7
|
-
* 3. If not cached, download from CDN (with GitHub Releases fallback)
|
|
8
|
-
* 4. Verify signature + checksum
|
|
9
|
-
* 5. Cache the verified binary
|
|
10
|
-
* 6. Return the cached path
|
|
11
|
-
*/
|
|
12
|
-
import { chmodSync, existsSync } from "node:fs";
|
|
13
|
-
import { rename } from "node:fs/promises";
|
|
14
|
-
import { join } from "node:path";
|
|
15
|
-
import { detectPlatform, getArtifactName, getCdnUrl } from "./platform.js";
|
|
16
|
-
import { getCachedBinaryPath, hasCachedBinary, ensureCacheDir } from "./cache.js";
|
|
17
|
-
import { downloadFile, fetchJson } from "./download.js";
|
|
18
|
-
import { verifyBinary, verifyChecksumOnly } from "./verify.js";
|
|
19
|
-
import { ENGINE_VERSION, CDN_BASE_URL, GITHUB_RELEASES_FALLBACK_URL, } from "../engine-version.js";
|
|
20
|
-
/**
|
|
21
|
-
* Resolve the engine binary path, downloading if necessary.
|
|
22
|
-
*/
|
|
23
|
-
export async function resolveEngine(version = ENGINE_VERSION) {
|
|
24
|
-
const platform = detectPlatform();
|
|
25
|
-
// Check cache first
|
|
26
|
-
if (hasCachedBinary(version, platform)) {
|
|
27
|
-
return {
|
|
28
|
-
binaryPath: getCachedBinaryPath(version, platform),
|
|
29
|
-
version,
|
|
30
|
-
fromCache: true,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
// Not cached — need to download
|
|
34
|
-
const artifactName = getArtifactName(version, platform);
|
|
35
|
-
const cacheDir = ensureCacheDir(version);
|
|
36
|
-
const binaryDest = getCachedBinaryPath(version, platform);
|
|
37
|
-
const tempBinary = `${binaryDest}.tmp`;
|
|
38
|
-
const checksumDest = join(cacheDir, "checksums.sha256");
|
|
39
|
-
const signatureDest = join(cacheDir, "checksums.sha256.minisig");
|
|
40
|
-
// Try CDN first, then GitHub Releases fallback
|
|
41
|
-
let downloaded = false;
|
|
42
|
-
try {
|
|
43
|
-
downloaded = await downloadFromSource(CDN_BASE_URL, version, artifactName, tempBinary, checksumDest, signatureDest);
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
// CDN failed, try fallback
|
|
47
|
-
}
|
|
48
|
-
if (!downloaded) {
|
|
49
|
-
try {
|
|
50
|
-
downloaded = await downloadFromSource(GITHUB_RELEASES_FALLBACK_URL, version, artifactName, tempBinary, checksumDest, signatureDest);
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
// Fallback also failed
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (!downloaded) {
|
|
57
|
-
throw new Error("Cannot download Supatype engine. Check your internet connection.\n" +
|
|
58
|
-
"If this persists, report at https://github.com/supatype/supatype/issues");
|
|
59
|
-
}
|
|
60
|
-
// Verify the downloaded binary
|
|
61
|
-
if (existsSync(signatureDest)) {
|
|
62
|
-
// Full two-step verification: signature + checksum
|
|
63
|
-
await verifyBinary(tempBinary, checksumDest, signatureDest, artifactName);
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
// Checksum-only verification (GitHub Releases may not have .minisig)
|
|
67
|
-
await verifyChecksumOnly(tempBinary, checksumDest, artifactName);
|
|
68
|
-
}
|
|
69
|
-
// Move verified binary to final location
|
|
70
|
-
await rename(tempBinary, binaryDest);
|
|
71
|
-
// Set executable permission on Unix
|
|
72
|
-
if (process.platform !== "win32") {
|
|
73
|
-
chmodSync(binaryDest, 0o755);
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
binaryPath: binaryDest,
|
|
77
|
-
version,
|
|
78
|
-
fromCache: false,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
async function downloadFromSource(baseUrl, version, artifactName, binaryDest, checksumDest, signatureDest) {
|
|
82
|
-
const binaryUrl = getCdnUrl(baseUrl, version, artifactName);
|
|
83
|
-
const checksumUrl = getCdnUrl(baseUrl, version, "checksums.sha256");
|
|
84
|
-
const signatureUrl = getCdnUrl(baseUrl, version, "checksums.sha256.minisig");
|
|
85
|
-
// Download binary with progress
|
|
86
|
-
await downloadFile({
|
|
87
|
-
url: binaryUrl,
|
|
88
|
-
dest: binaryDest,
|
|
89
|
-
showProgress: true,
|
|
90
|
-
label: `Downloading Supatype engine v${version} for ${detectPlatform().os}-${detectPlatform().arch}`,
|
|
91
|
-
});
|
|
92
|
-
// Download checksum file
|
|
93
|
-
await downloadFile({
|
|
94
|
-
url: checksumUrl,
|
|
95
|
-
dest: checksumDest,
|
|
96
|
-
});
|
|
97
|
-
// Try to download signature file (may not exist for GitHub Releases)
|
|
98
|
-
try {
|
|
99
|
-
await downloadFile({
|
|
100
|
-
url: signatureUrl,
|
|
101
|
-
dest: signatureDest,
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
catch {
|
|
105
|
-
// Signature file optional for fallback sources
|
|
106
|
-
// But for CDN, we require it — verifyBinary will enforce this
|
|
107
|
-
}
|
|
108
|
-
return true;
|
|
109
|
-
}
|
|
110
|
-
export async function checkLatestVersion() {
|
|
111
|
-
return fetchJson(`${CDN_BASE_URL}/latest.json`);
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Check version compatibility.
|
|
115
|
-
* Engine and CLI must share the same major version.
|
|
116
|
-
*/
|
|
117
|
-
export function checkVersionCompatibility(engineVersion, expectedVersion) {
|
|
118
|
-
const engineMajor = parseMajor(engineVersion);
|
|
119
|
-
const expectedMajor = parseMajor(expectedVersion);
|
|
120
|
-
if (engineMajor !== expectedMajor) {
|
|
121
|
-
return {
|
|
122
|
-
compatible: false,
|
|
123
|
-
message: `Engine version ${engineVersion} is not compatible with CLI version ${expectedVersion}.\n` +
|
|
124
|
-
`Run: npm update @supatype/cli`,
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
return { compatible: true };
|
|
128
|
-
}
|
|
129
|
-
function parseMajor(version) {
|
|
130
|
-
const match = version.match(/^(\d+)/);
|
|
131
|
-
return match ? parseInt(match[1], 10) : 0;
|
|
132
|
-
}
|
|
133
|
-
//# sourceMappingURL=resolve.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/engine/resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAoB,MAAM,kBAAkB,CAAA;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC1E,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AACjF,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,EACL,cAAc,EACd,YAAY,EACZ,4BAA4B,GAC7B,MAAM,sBAAsB,CAAA;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CAAC;QACjB,GAAG,EAAE,WAAW;QAChB,IAAI,EAAE,YAAY;KACnB,CAAC,CAAA;IAEF,qEAAqE;IACrE,IAAI,CAAC;QACH,MAAM,YAAY,CAAC;YACjB,GAAG,EAAE,YAAY;YACjB,IAAI,EAAE,aAAa;SACpB,CAAC,CAAA;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,+CAA+C;QAC/C,8DAA8D;IAChE,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAUD,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACtC,OAAO,SAAS,CAAoB,GAAG,YAAY,cAAc,CAAC,CAAA;AACpE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CACvC,aAAqB,EACrB,eAAuB;IAEvB,MAAM,WAAW,GAAG,UAAU,CAAC,aAAa,CAAC,CAAA;IAC7C,MAAM,aAAa,GAAG,UAAU,CAAC,eAAe,CAAC,CAAA;IAEjD,IAAI,WAAW,KAAK,aAAa,EAAE,CAAC;QAClC,OAAO;YACL,UAAU,EAAE,KAAK;YACjB,OAAO,EACL,kBAAkB,aAAa,uCAAuC,eAAe,KAAK;gBAC1F,+BAA+B;SAClC,CAAA;IACH,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,CAAA;AAC7B,CAAC;AAED,SAAS,UAAU,CAAC,OAAe;IACjC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IACrC,OAAO,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC5C,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Non-blocking update notification shown after CLI commands.
|
|
3
|
-
* Checks once per 24 hours. Skips in CI environments.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Show an update notification if a newer engine version is available.
|
|
7
|
-
* This runs after every CLI command, but only actually checks the network
|
|
8
|
-
* once per 24 hours (throttled via ~/.supatype/update-check.json).
|
|
9
|
-
*/
|
|
10
|
-
export declare function showUpdateNotification(): Promise<void>;
|
|
11
|
-
//# sourceMappingURL=update-notify.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update-notify.d.ts","sourceRoot":"","sources":["../../src/engine/update-notify.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH;;;;GAIG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC,CAuB5D"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Non-blocking update notification shown after CLI commands.
|
|
3
|
-
* Checks once per 24 hours. Skips in CI environments.
|
|
4
|
-
*/
|
|
5
|
-
import { ENGINE_VERSION } from "../engine-version.js";
|
|
6
|
-
import { shouldCheckForUpdates, saveUpdateCheck, getLastKnownLatestVersion, } from "./cache.js";
|
|
7
|
-
import { checkLatestVersion } from "./resolve.js";
|
|
8
|
-
/**
|
|
9
|
-
* Show an update notification if a newer engine version is available.
|
|
10
|
-
* This runs after every CLI command, but only actually checks the network
|
|
11
|
-
* once per 24 hours (throttled via ~/.supatype/update-check.json).
|
|
12
|
-
*/
|
|
13
|
-
export async function showUpdateNotification() {
|
|
14
|
-
try {
|
|
15
|
-
const shouldCheck = await shouldCheckForUpdates();
|
|
16
|
-
if (shouldCheck) {
|
|
17
|
-
// Perform network check
|
|
18
|
-
const latest = await checkLatestVersion();
|
|
19
|
-
if (latest) {
|
|
20
|
-
await saveUpdateCheck(latest.version);
|
|
21
|
-
if (latest.version !== ENGINE_VERSION) {
|
|
22
|
-
printNotification(latest.version);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
// Use cached info from last check
|
|
28
|
-
const cachedLatest = await getLastKnownLatestVersion();
|
|
29
|
-
if (cachedLatest && cachedLatest !== ENGINE_VERSION) {
|
|
30
|
-
printNotification(cachedLatest);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
// Never fail the CLI command because of update check
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function printNotification(latestVersion) {
|
|
39
|
-
console.log();
|
|
40
|
-
console.log(`Supatype engine v${latestVersion} is available. ` +
|
|
41
|
-
`Run: npm update @supatype/cli`);
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=update-notify.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update-notify.js","sourceRoot":"","sources":["../../src/engine/update-notify.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,yBAAyB,GAC1B,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEjD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB;IAC1C,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,MAAM,qBAAqB,EAAE,CAAA;QAEjD,IAAI,WAAW,EAAE,CAAC;YAChB,wBAAwB;YACxB,MAAM,MAAM,GAAG,MAAM,kBAAkB,EAAE,CAAA;YACzC,IAAI,MAAM,EAAE,CAAC;gBACX,MAAM,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;gBACrC,IAAI,MAAM,CAAC,OAAO,KAAK,cAAc,EAAE,CAAC;oBACtC,iBAAiB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;gBACnC,CAAC;YACH,CAAC;QACH,CAAC;aAAM,CAAC;YACN,kCAAkC;YAClC,MAAM,YAAY,GAAG,MAAM,yBAAyB,EAAE,CAAA;YACtD,IAAI,YAAY,IAAI,YAAY,KAAK,cAAc,EAAE,CAAC;gBACpD,iBAAiB,CAAC,YAAY,CAAC,CAAA;YACjC,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,qDAAqD;IACvD,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,aAAqB;IAC9C,OAAO,CAAC,GAAG,EAAE,CAAA;IACb,OAAO,CAAC,GAAG,CACT,oBAAoB,aAAa,iBAAiB;QAClD,+BAA+B,CAChC,CAAA;AACH,CAAC"}
|
package/dist/engine/verify.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checksum and signature verification for engine binaries.
|
|
3
|
-
*
|
|
4
|
-
* Two-step verification:
|
|
5
|
-
* 1. Verify minisign signature on checksums.sha256 file
|
|
6
|
-
* 2. Verify SHA256 hash of binary against signed checksum file
|
|
7
|
-
*
|
|
8
|
-
* Both steps MUST pass before the CLI executes the binary.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Embedded minisign public key.
|
|
12
|
-
*
|
|
13
|
-
* This key is used to verify the signature on the checksum file.
|
|
14
|
-
* It ensures the checksum file was produced by Supatype's CI,
|
|
15
|
-
* not by an attacker who compromised the CDN.
|
|
16
|
-
*
|
|
17
|
-
* Generated with: minisign -G
|
|
18
|
-
* The corresponding private key is stored as a GitHub Actions secret.
|
|
19
|
-
*
|
|
20
|
-
* TODO: Replace with actual public key once generated.
|
|
21
|
-
*/
|
|
22
|
-
export declare const MINISIGN_PUBLIC_KEY = "RWS0000000000000000000000000000000000000000000000000";
|
|
23
|
-
/**
|
|
24
|
-
* Verify the minisign signature on a checksum file.
|
|
25
|
-
*
|
|
26
|
-
* Uses a pure-JS minisign verification (Ed25519).
|
|
27
|
-
* Returns true if the signature is valid, false otherwise.
|
|
28
|
-
*/
|
|
29
|
-
export declare function verifySignature(checksumPath: string, signaturePath: string, publicKey?: string): Promise<boolean>;
|
|
30
|
-
/**
|
|
31
|
-
* Verify the SHA256 checksum of a binary against a signed checksum file.
|
|
32
|
-
*
|
|
33
|
-
* The checksum file format follows sha256sum output:
|
|
34
|
-
* <hash> <filename>
|
|
35
|
-
*/
|
|
36
|
-
export declare function verifyChecksum(binaryPath: string, checksumPath: string, expectedFilename: string): Promise<boolean>;
|
|
37
|
-
/**
|
|
38
|
-
* Run the full two-step verification pipeline.
|
|
39
|
-
* Deletes the binary if verification fails.
|
|
40
|
-
*
|
|
41
|
-
* Step 1: Verify minisign signature on checksums.sha256
|
|
42
|
-
* Step 2: Verify SHA256 hash of binary against signed checksum
|
|
43
|
-
*/
|
|
44
|
-
export declare function verifyBinary(binaryPath: string, checksumPath: string, signaturePath: string, artifactName: string): Promise<void>;
|
|
45
|
-
/**
|
|
46
|
-
* Simple checksum-only verification (no signature).
|
|
47
|
-
* Used as a fallback when signature files are not available.
|
|
48
|
-
*/
|
|
49
|
-
export declare function verifyChecksumOnly(binaryPath: string, checksumPath: string, artifactName: string): Promise<void>;
|
|
50
|
-
//# sourceMappingURL=verify.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/engine/verify.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,yDAAyD,CAAA;AAEzF;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,SAAS,GAAE,MAA4B,GACtC,OAAO,CAAC,OAAO,CAAC,CAkElB;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,OAAO,CAAC,CA0BlB;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAsBf;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC,CAUf"}
|
package/dist/engine/verify.js
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checksum and signature verification for engine binaries.
|
|
3
|
-
*
|
|
4
|
-
* Two-step verification:
|
|
5
|
-
* 1. Verify minisign signature on checksums.sha256 file
|
|
6
|
-
* 2. Verify SHA256 hash of binary against signed checksum file
|
|
7
|
-
*
|
|
8
|
-
* Both steps MUST pass before the CLI executes the binary.
|
|
9
|
-
*/
|
|
10
|
-
import { createHash } from "node:crypto";
|
|
11
|
-
import { readFile, unlink } from "node:fs/promises";
|
|
12
|
-
/**
|
|
13
|
-
* Embedded minisign public key.
|
|
14
|
-
*
|
|
15
|
-
* This key is used to verify the signature on the checksum file.
|
|
16
|
-
* It ensures the checksum file was produced by Supatype's CI,
|
|
17
|
-
* not by an attacker who compromised the CDN.
|
|
18
|
-
*
|
|
19
|
-
* Generated with: minisign -G
|
|
20
|
-
* The corresponding private key is stored as a GitHub Actions secret.
|
|
21
|
-
*
|
|
22
|
-
* TODO: Replace with actual public key once generated.
|
|
23
|
-
*/
|
|
24
|
-
export const MINISIGN_PUBLIC_KEY = "RWS0000000000000000000000000000000000000000000000000";
|
|
25
|
-
/**
|
|
26
|
-
* Verify the minisign signature on a checksum file.
|
|
27
|
-
*
|
|
28
|
-
* Uses a pure-JS minisign verification (Ed25519).
|
|
29
|
-
* Returns true if the signature is valid, false otherwise.
|
|
30
|
-
*/
|
|
31
|
-
export async function verifySignature(checksumPath, signaturePath, publicKey = MINISIGN_PUBLIC_KEY) {
|
|
32
|
-
// Minisign signature format:
|
|
33
|
-
// Line 1: untrusted comment
|
|
34
|
-
// Line 2: base64-encoded signature
|
|
35
|
-
// Line 3 (optional): trusted comment
|
|
36
|
-
// Line 4 (optional): base64-encoded global signature
|
|
37
|
-
try {
|
|
38
|
-
const sigContent = await readFile(signaturePath, "utf8");
|
|
39
|
-
const checksumContent = await readFile(checksumPath);
|
|
40
|
-
const sigLines = sigContent.trim().split("\n");
|
|
41
|
-
if (sigLines.length < 2)
|
|
42
|
-
return false;
|
|
43
|
-
// Parse the signature (line 2 is the base64-encoded signature)
|
|
44
|
-
const sigBase64 = sigLines[1].trim();
|
|
45
|
-
const sigBytes = Buffer.from(sigBase64, "base64");
|
|
46
|
-
// Minisign signature: 2 bytes algorithm + 8 bytes key ID + 64 bytes Ed25519 sig
|
|
47
|
-
if (sigBytes.length < 74)
|
|
48
|
-
return false;
|
|
49
|
-
const algorithm = sigBytes.subarray(0, 2);
|
|
50
|
-
const keyId = sigBytes.subarray(2, 10);
|
|
51
|
-
const signature = sigBytes.subarray(10, 74);
|
|
52
|
-
// Parse public key
|
|
53
|
-
const pkBytes = Buffer.from(publicKey.slice(2), "base64"); // Skip "RW" prefix
|
|
54
|
-
if (pkBytes.length < 42)
|
|
55
|
-
return false;
|
|
56
|
-
// Public key: 2 bytes algorithm + 8 bytes key ID + 32 bytes Ed25519 pubkey
|
|
57
|
-
const pkKeyId = pkBytes.subarray(2, 10);
|
|
58
|
-
const pk = pkBytes.subarray(10, 42);
|
|
59
|
-
// Verify key IDs match
|
|
60
|
-
if (!keyId.equals(pkKeyId))
|
|
61
|
-
return false;
|
|
62
|
-
// Verify Ed25519 signature using Node.js crypto
|
|
63
|
-
const { verify, createPublicKey } = await import("node:crypto");
|
|
64
|
-
const publicKeyObj = createPublicKey({
|
|
65
|
-
key: Buffer.concat([
|
|
66
|
-
// Ed25519 public key DER prefix
|
|
67
|
-
Buffer.from("302a300506032b6570032100", "hex"),
|
|
68
|
-
pk,
|
|
69
|
-
]),
|
|
70
|
-
format: "der",
|
|
71
|
-
type: "spki",
|
|
72
|
-
});
|
|
73
|
-
const isValid = verify(null, checksumContent, publicKeyObj, signature);
|
|
74
|
-
// If there's a trusted comment (line 3-4), verify the global signature too
|
|
75
|
-
if (sigLines.length >= 4 && isValid) {
|
|
76
|
-
const trustedComment = sigLines[2]?.replace(/^trusted comment: ?/, "") || "";
|
|
77
|
-
const globalSigBase64 = sigLines[3].trim();
|
|
78
|
-
const globalSig = Buffer.from(globalSigBase64, "base64");
|
|
79
|
-
const globalMessage = Buffer.concat([signature, Buffer.from(trustedComment)]);
|
|
80
|
-
const globalValid = verify(null, globalMessage, publicKeyObj, globalSig);
|
|
81
|
-
return globalValid;
|
|
82
|
-
}
|
|
83
|
-
return isValid;
|
|
84
|
-
}
|
|
85
|
-
catch {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Verify the SHA256 checksum of a binary against a signed checksum file.
|
|
91
|
-
*
|
|
92
|
-
* The checksum file format follows sha256sum output:
|
|
93
|
-
* <hash> <filename>
|
|
94
|
-
*/
|
|
95
|
-
export async function verifyChecksum(binaryPath, checksumPath, expectedFilename) {
|
|
96
|
-
const checksumContent = await readFile(checksumPath, "utf8");
|
|
97
|
-
// Find the line matching our filename
|
|
98
|
-
const lines = checksumContent.trim().split("\n");
|
|
99
|
-
let expectedHash;
|
|
100
|
-
for (const line of lines) {
|
|
101
|
-
// Format: "<hash> <filename>" (two spaces)
|
|
102
|
-
const parts = line.trim().split(/\s+/);
|
|
103
|
-
if (parts.length >= 2 && parts[1] === expectedFilename) {
|
|
104
|
-
expectedHash = parts[0].toLowerCase();
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if (!expectedHash) {
|
|
109
|
-
throw new Error(`No checksum found for ${expectedFilename} in checksum file`);
|
|
110
|
-
}
|
|
111
|
-
const binaryData = await readFile(binaryPath);
|
|
112
|
-
const actualHash = createHash("sha256").update(binaryData).digest("hex");
|
|
113
|
-
return actualHash === expectedHash;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Run the full two-step verification pipeline.
|
|
117
|
-
* Deletes the binary if verification fails.
|
|
118
|
-
*
|
|
119
|
-
* Step 1: Verify minisign signature on checksums.sha256
|
|
120
|
-
* Step 2: Verify SHA256 hash of binary against signed checksum
|
|
121
|
-
*/
|
|
122
|
-
export async function verifyBinary(binaryPath, checksumPath, signaturePath, artifactName) {
|
|
123
|
-
// Step 1: Verify signature
|
|
124
|
-
const sigValid = await verifySignature(checksumPath, signaturePath);
|
|
125
|
-
if (!sigValid) {
|
|
126
|
-
await safeDelete(binaryPath);
|
|
127
|
-
throw new Error("Engine checksum signature verification failed.\n" +
|
|
128
|
-
"The checksum file may have been tampered with.\n" +
|
|
129
|
-
"If this persists, report at https://github.com/supatype/supatype/issues");
|
|
130
|
-
}
|
|
131
|
-
// Step 2: Verify checksum
|
|
132
|
-
const checksumValid = await verifyChecksum(binaryPath, checksumPath, artifactName);
|
|
133
|
-
if (!checksumValid) {
|
|
134
|
-
await safeDelete(binaryPath);
|
|
135
|
-
throw new Error("Engine binary checksum mismatch.\n" +
|
|
136
|
-
"This could indicate a corrupt download or a tampered binary.\n" +
|
|
137
|
-
"Try again or report at https://github.com/supatype/supatype/issues");
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Simple checksum-only verification (no signature).
|
|
142
|
-
* Used as a fallback when signature files are not available.
|
|
143
|
-
*/
|
|
144
|
-
export async function verifyChecksumOnly(binaryPath, checksumPath, artifactName) {
|
|
145
|
-
const valid = await verifyChecksum(binaryPath, checksumPath, artifactName);
|
|
146
|
-
if (!valid) {
|
|
147
|
-
await safeDelete(binaryPath);
|
|
148
|
-
throw new Error("Engine binary checksum mismatch.\n" +
|
|
149
|
-
"This could indicate a corrupt download or a tampered binary.\n" +
|
|
150
|
-
"Try again or report at https://github.com/supatype/supatype/issues");
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
async function safeDelete(path) {
|
|
154
|
-
try {
|
|
155
|
-
await unlink(path);
|
|
156
|
-
}
|
|
157
|
-
catch {
|
|
158
|
-
// Ignore deletion errors
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
//# sourceMappingURL=verify.js.map
|