@supatype/cli 0.1.0-alpha.6
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 +4 -0
- package/.turbo/turbo-test.log +7 -0
- package/.turbo/turbo-typecheck.log +4 -0
- package/bin/dev-entry.ts +2 -0
- package/bin/supatype.js +5 -0
- package/dist/app/framework.d.ts +44 -0
- package/dist/app/framework.d.ts.map +1 -0
- package/dist/app/framework.js +200 -0
- package/dist/app/framework.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +55 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/admin.d.ts +4 -0
- package/dist/commands/admin.d.ts.map +1 -0
- package/dist/commands/admin.js +270 -0
- package/dist/commands/admin.js.map +1 -0
- package/dist/commands/app.d.ts +3 -0
- package/dist/commands/app.d.ts.map +1 -0
- package/dist/commands/app.js +235 -0
- package/dist/commands/app.js.map +1 -0
- package/dist/commands/cloud.d.ts +3 -0
- package/dist/commands/cloud.d.ts.map +1 -0
- package/dist/commands/cloud.js +256 -0
- package/dist/commands/cloud.js.map +1 -0
- package/dist/commands/db.d.ts +8 -0
- package/dist/commands/db.d.ts.map +1 -0
- package/dist/commands/db.js +123 -0
- package/dist/commands/db.js.map +1 -0
- package/dist/commands/deploy-types.d.ts +14 -0
- package/dist/commands/deploy-types.d.ts.map +1 -0
- package/dist/commands/deploy-types.js +38 -0
- package/dist/commands/deploy-types.js.map +1 -0
- package/dist/commands/deploy.d.ts +14 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +295 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/dev.d.ts +3 -0
- package/dist/commands/dev.d.ts.map +1 -0
- package/dist/commands/dev.js +428 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/commands/diff.d.ts +3 -0
- package/dist/commands/diff.d.ts.map +1 -0
- package/dist/commands/diff.js +39 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/engine.d.ts +9 -0
- package/dist/commands/engine.d.ts.map +1 -0
- package/dist/commands/engine.js +99 -0
- package/dist/commands/engine.js.map +1 -0
- package/dist/commands/functions.d.ts +3 -0
- package/dist/commands/functions.d.ts.map +1 -0
- package/dist/commands/functions.js +762 -0
- package/dist/commands/functions.js.map +1 -0
- package/dist/commands/generate.d.ts +3 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +28 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/init.d.ts +7 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +515 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/keys.d.ts +4 -0
- package/dist/commands/keys.d.ts.map +1 -0
- package/dist/commands/keys.js +57 -0
- package/dist/commands/keys.js.map +1 -0
- package/dist/commands/logs.d.ts +6 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +52 -0
- package/dist/commands/logs.js.map +1 -0
- package/dist/commands/migrate.d.ts +3 -0
- package/dist/commands/migrate.d.ts.map +1 -0
- package/dist/commands/migrate.js +71 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/plugins.d.ts +3 -0
- package/dist/commands/plugins.d.ts.map +1 -0
- package/dist/commands/plugins.js +431 -0
- package/dist/commands/plugins.js.map +1 -0
- package/dist/commands/pull.d.ts +3 -0
- package/dist/commands/pull.d.ts.map +1 -0
- package/dist/commands/pull.js +73 -0
- package/dist/commands/pull.js.map +1 -0
- package/dist/commands/push.d.ts +3 -0
- package/dist/commands/push.d.ts.map +1 -0
- package/dist/commands/push.js +87 -0
- package/dist/commands/push.js.map +1 -0
- package/dist/commands/seed.d.ts +3 -0
- package/dist/commands/seed.d.ts.map +1 -0
- package/dist/commands/seed.js +22 -0
- package/dist/commands/seed.js.map +1 -0
- package/dist/commands/self-host.d.ts +3 -0
- package/dist/commands/self-host.d.ts.map +1 -0
- package/dist/commands/self-host.js +796 -0
- package/dist/commands/self-host.js.map +1 -0
- package/dist/commands/status.d.ts +6 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +69 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/config.d.ts +106 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +66 -0
- package/dist/config.js.map +1 -0
- package/dist/engine/cache.d.ts +37 -0
- package/dist/engine/cache.d.ts.map +1 -0
- package/dist/engine/cache.js +121 -0
- package/dist/engine/cache.js.map +1 -0
- package/dist/engine/download.d.ts +19 -0
- package/dist/engine/download.d.ts.map +1 -0
- package/dist/engine/download.js +108 -0
- package/dist/engine/download.js.map +1 -0
- package/dist/engine/platform.d.ts +24 -0
- package/dist/engine/platform.d.ts.map +1 -0
- package/dist/engine/platform.js +50 -0
- package/dist/engine/platform.js.map +1 -0
- package/dist/engine/resolve.d.ts +37 -0
- package/dist/engine/resolve.d.ts.map +1 -0
- package/dist/engine/resolve.js +133 -0
- package/dist/engine/resolve.js.map +1 -0
- package/dist/engine/update-notify.d.ts +11 -0
- package/dist/engine/update-notify.d.ts.map +1 -0
- package/dist/engine/update-notify.js +43 -0
- package/dist/engine/update-notify.js.map +1 -0
- package/dist/engine/verify.d.ts +50 -0
- package/dist/engine/verify.d.ts.map +1 -0
- package/dist/engine/verify.js +161 -0
- package/dist/engine/verify.js.map +1 -0
- package/dist/engine-version.d.ts +35 -0
- package/dist/engine-version.d.ts.map +1 -0
- package/dist/engine-version.js +35 -0
- package/dist/engine-version.js.map +1 -0
- package/dist/engine.d.ts +34 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +76 -0
- package/dist/engine.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/jwt.d.ts +3 -0
- package/dist/jwt.d.ts.map +1 -0
- package/dist/jwt.js +13 -0
- package/dist/jwt.js.map +1 -0
- package/dist/pull-utils.d.ts +16 -0
- package/dist/pull-utils.d.ts.map +1 -0
- package/dist/pull-utils.js +65 -0
- package/dist/pull-utils.js.map +1 -0
- package/dist/scripts/postinstall.d.ts +12 -0
- package/dist/scripts/postinstall.d.ts.map +1 -0
- package/dist/scripts/postinstall.js +31 -0
- package/dist/scripts/postinstall.js.map +1 -0
- package/dist/tsx-runner.d.ts +18 -0
- package/dist/tsx-runner.d.ts.map +1 -0
- package/dist/tsx-runner.js +62 -0
- package/dist/tsx-runner.js.map +1 -0
- package/package.json +36 -0
- package/src/app/framework.ts +249 -0
- package/src/cli.ts +58 -0
- package/src/commands/admin.ts +371 -0
- package/src/commands/app.ts +261 -0
- package/src/commands/cloud.ts +326 -0
- package/src/commands/db.ts +145 -0
- package/src/commands/deploy-types.ts +49 -0
- package/src/commands/deploy.ts +366 -0
- package/src/commands/dev.ts +477 -0
- package/src/commands/diff.ts +61 -0
- package/src/commands/engine.ts +133 -0
- package/src/commands/functions.ts +919 -0
- package/src/commands/generate.ts +31 -0
- package/src/commands/init.ts +532 -0
- package/src/commands/keys.ts +66 -0
- package/src/commands/logs.ts +58 -0
- package/src/commands/migrate.ts +83 -0
- package/src/commands/plugins.ts +508 -0
- package/src/commands/pull.ts +96 -0
- package/src/commands/push.ts +119 -0
- package/src/commands/seed.ts +26 -0
- package/src/commands/self-host.ts +932 -0
- package/src/commands/status.ts +83 -0
- package/src/config.ts +190 -0
- package/src/engine/cache.ts +135 -0
- package/src/engine/download.ts +143 -0
- package/src/engine/platform.ts +66 -0
- package/src/engine/resolve.ts +197 -0
- package/src/engine/update-notify.ts +50 -0
- package/src/engine/verify.ts +206 -0
- package/src/engine-version.ts +39 -0
- package/src/engine.ts +99 -0
- package/src/index.ts +19 -0
- package/src/jwt.ts +14 -0
- package/src/pull-utils.ts +57 -0
- package/src/scripts/postinstall.ts +40 -0
- package/src/tsx-runner.ts +79 -0
- package/tests/cli-help.test.ts +107 -0
- package/tests/config.test.ts +117 -0
- package/tests/engine-distribution.test.ts +418 -0
- package/tests/init.test.ts +184 -0
- package/tests/keys.test.ts +160 -0
- package/tests/pull-utils.test.ts +115 -0
- package/tests/tsx-runner.test.ts +66 -0
- package/tsconfig.json +10 -0
- package/tsconfig.tsbuildinfo +1 -0
package/dist/engine.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locates the engine binary (from cache) and provides a helper to invoke it.
|
|
3
|
+
*
|
|
4
|
+
* The engine binary is cached at ~/.supatype/engine/{version}/supatype-engine[.exe].
|
|
5
|
+
* On first use, it's automatically downloaded, verified, and cached.
|
|
6
|
+
*/
|
|
7
|
+
export interface EngineResult {
|
|
8
|
+
stdout: string;
|
|
9
|
+
stderr: string;
|
|
10
|
+
exitCode: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Get the path to the engine binary, downloading if needed.
|
|
14
|
+
* This is the async version — use when you can await.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getEnginePathAsync(): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Get the path to the engine binary (sync).
|
|
19
|
+
* Throws if the binary is not cached — caller must ensure it's downloaded first.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getEnginePath(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Ensure the engine binary is available, downloading if necessary.
|
|
24
|
+
* Call this before invokeEngine() in command handlers.
|
|
25
|
+
*/
|
|
26
|
+
export declare function ensureEngine(): Promise<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Invoke the engine binary with the given arguments.
|
|
29
|
+
* Input JSON is passed via stdin.
|
|
30
|
+
*
|
|
31
|
+
* The caller must call ensureEngine() first to guarantee the binary exists.
|
|
32
|
+
*/
|
|
33
|
+
export declare function invokeEngine(args: string[], input?: string): EngineResult;
|
|
34
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,CAW1D;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,MAAM,CActC;AAED;;;GAGG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CAepD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,CAAC,EAAE,MAAM,GACb,YAAY,CAYd"}
|
package/dist/engine.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locates the engine binary (from cache) and provides a helper to invoke it.
|
|
3
|
+
*
|
|
4
|
+
* The engine binary is cached at ~/.supatype/engine/{version}/supatype-engine[.exe].
|
|
5
|
+
* On first use, it's automatically downloaded, verified, and cached.
|
|
6
|
+
*/
|
|
7
|
+
import { spawnSync } from "node:child_process";
|
|
8
|
+
import { ENGINE_VERSION } from "./engine-version.js";
|
|
9
|
+
import { detectPlatform } from "./engine/platform.js";
|
|
10
|
+
import { getCachedBinaryPath, hasCachedBinary } from "./engine/cache.js";
|
|
11
|
+
import { resolveEngine, checkVersionCompatibility } from "./engine/resolve.js";
|
|
12
|
+
/**
|
|
13
|
+
* Get the path to the engine binary, downloading if needed.
|
|
14
|
+
* This is the async version — use when you can await.
|
|
15
|
+
*/
|
|
16
|
+
export async function getEnginePathAsync() {
|
|
17
|
+
const platform = detectPlatform();
|
|
18
|
+
// Fast path: binary already cached
|
|
19
|
+
if (hasCachedBinary(ENGINE_VERSION, platform)) {
|
|
20
|
+
return getCachedBinaryPath(ENGINE_VERSION, platform);
|
|
21
|
+
}
|
|
22
|
+
// Need to download
|
|
23
|
+
const result = await resolveEngine(ENGINE_VERSION);
|
|
24
|
+
return result.binaryPath;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get the path to the engine binary (sync).
|
|
28
|
+
* Throws if the binary is not cached — caller must ensure it's downloaded first.
|
|
29
|
+
*/
|
|
30
|
+
export function getEnginePath() {
|
|
31
|
+
const platform = detectPlatform();
|
|
32
|
+
const path = getCachedBinaryPath(ENGINE_VERSION, platform);
|
|
33
|
+
if (!hasCachedBinary(ENGINE_VERSION, platform)) {
|
|
34
|
+
throw new Error(`Supatype engine binary not found in cache.\n` +
|
|
35
|
+
`Expected: ${path}\n` +
|
|
36
|
+
`Run any supatype command to trigger automatic download,\n` +
|
|
37
|
+
`or run: npx supatype engine version`);
|
|
38
|
+
}
|
|
39
|
+
return path;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Ensure the engine binary is available, downloading if necessary.
|
|
43
|
+
* Call this before invokeEngine() in command handlers.
|
|
44
|
+
*/
|
|
45
|
+
export async function ensureEngine() {
|
|
46
|
+
const result = await resolveEngine(ENGINE_VERSION);
|
|
47
|
+
if (!result.fromCache) {
|
|
48
|
+
// Just downloaded — version is correct
|
|
49
|
+
return result.binaryPath;
|
|
50
|
+
}
|
|
51
|
+
// Cached — check compatibility
|
|
52
|
+
const compat = checkVersionCompatibility(ENGINE_VERSION, ENGINE_VERSION);
|
|
53
|
+
if (!compat.compatible) {
|
|
54
|
+
throw new Error(compat.message);
|
|
55
|
+
}
|
|
56
|
+
return result.binaryPath;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Invoke the engine binary with the given arguments.
|
|
60
|
+
* Input JSON is passed via stdin.
|
|
61
|
+
*
|
|
62
|
+
* The caller must call ensureEngine() first to guarantee the binary exists.
|
|
63
|
+
*/
|
|
64
|
+
export function invokeEngine(args, input) {
|
|
65
|
+
const enginePath = getEnginePath();
|
|
66
|
+
const result = spawnSync(enginePath, args, {
|
|
67
|
+
input: input ? Buffer.from(input, "utf8") : undefined,
|
|
68
|
+
maxBuffer: 50 * 1024 * 1024, // 50MB
|
|
69
|
+
});
|
|
70
|
+
return {
|
|
71
|
+
stdout: result.stdout?.toString("utf8") ?? "",
|
|
72
|
+
stderr: result.stderr?.toString("utf8") ?? "",
|
|
73
|
+
exitCode: result.status ?? 1,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAyB,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAQ9E;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACtC,MAAM,QAAQ,GAAG,cAAc,EAAE,CAAA;IAEjC,mCAAmC;IACnC,IAAI,eAAe,CAAC,cAAc,EAAE,QAAQ,CAAC,EAAE,CAAC;QAC9C,OAAO,mBAAmB,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAA;IACtD,CAAC;IAED,mBAAmB;IACnB,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,cAAc,CAAC,CAAA;IAClD,OAAO,MAAM,CAAC,UAAU,CAAA;AAC1B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,QAAQ,GAAG,cAAc,EAAE,CAAA;IACjC,MAAM,IAAI,GAAG,mBAAmB,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAA;IAE1D,IAAI,CAAC,eAAe,CAAC,cAAc,EAAE,QAAQ,CAAC,EAAE,CAAC;QAC/C,M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.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @supatype/cli — programmatic API for invoking the engine.
|
|
3
|
+
*
|
|
4
|
+
* For CLI usage: use the `supatype` binary.
|
|
5
|
+
*/
|
|
6
|
+
export { invokeEngine, getEnginePath, ensureEngine, getEnginePathAsync } from "./engine.js";
|
|
7
|
+
export { ENGINE_VERSION, ENGINE_REPO, ENGINE_DOWNLOAD_BASE, CDN_BASE_URL, ENGINE_RELEASES_REPO, GITHUB_RELEASES_FALLBACK_URL, } from "./engine-version.js";
|
|
8
|
+
export { defineConfig, loadConfig, loadSchemaAst } from "./config.js";
|
|
9
|
+
export type { SupatypeConfig } from "./config.js";
|
|
10
|
+
export { detectPlatform } from "./engine/platform.js";
|
|
11
|
+
export type { PlatformInfo } from "./engine/platform.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAC3F,OAAO,EACL,cAAc,EACd,WAAW,EACX,oBAAoB,EACpB,YAAY,EACZ,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AACrE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @supatype/cli — programmatic API for invoking the engine.
|
|
3
|
+
*
|
|
4
|
+
* For CLI usage: use the `supatype` binary.
|
|
5
|
+
*/
|
|
6
|
+
export { invokeEngine, getEnginePath, ensureEngine, getEnginePathAsync } from "./engine.js";
|
|
7
|
+
export { ENGINE_VERSION, ENGINE_REPO, ENGINE_DOWNLOAD_BASE, CDN_BASE_URL, ENGINE_RELEASES_REPO, GITHUB_RELEASES_FALLBACK_URL, } from "./engine-version.js";
|
|
8
|
+
export { defineConfig, loadConfig, loadSchemaAst } from "./config.js";
|
|
9
|
+
export { detectPlatform } from "./engine/platform.js";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAC3F,OAAO,EACL,cAAc,EACd,WAAW,EACX,oBAAoB,EACpB,YAAY,EACZ,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAErE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA"}
|
package/dist/jwt.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../src/jwt.ts"],"names":[],"mappings":"AAEA,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAOhF;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C"}
|
package/dist/jwt.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createHmac } from "node:crypto";
|
|
2
|
+
export function signJwt(payload, secret) {
|
|
3
|
+
const header = base64url(JSON.stringify({ alg: "HS256", typ: "JWT" }));
|
|
4
|
+
const body = base64url(JSON.stringify(payload));
|
|
5
|
+
const sig = createHmac("sha256", secret)
|
|
6
|
+
.update(`${header}.${body}`)
|
|
7
|
+
.digest("base64url");
|
|
8
|
+
return `${header}.${body}.${sig}`;
|
|
9
|
+
}
|
|
10
|
+
export function base64url(str) {
|
|
11
|
+
return Buffer.from(str, "utf8").toString("base64url");
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=jwt.js.map
|
package/dist/jwt.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt.js","sourceRoot":"","sources":["../src/jwt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,MAAM,UAAU,OAAO,CAAC,OAAgC,EAAE,MAAc;IACtE,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAA;IACtE,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;IAC/C,MAAM,GAAG,GAAG,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC;SACrC,MAAM,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,CAAC;SAC3B,MAAM,CAAC,WAAW,CAAC,CAAA;IACtB,OAAO,GAAG,MAAM,IAAI,IAAI,IAAI,GAAG,EAAE,CAAA;AACnC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;AACvD,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for the `pull` command — extracted for unit testability.
|
|
3
|
+
*/
|
|
4
|
+
export interface ColumnInfo {
|
|
5
|
+
name: string;
|
|
6
|
+
pgType: string;
|
|
7
|
+
nullable: boolean;
|
|
8
|
+
isPrimary: boolean;
|
|
9
|
+
isUnique: boolean;
|
|
10
|
+
hasDefault: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** Map a Postgres column type to the corresponding field.X() call string. */
|
|
13
|
+
export declare function pgTypeToField(col: ColumnInfo): string;
|
|
14
|
+
/** Convert snake_case table name to PascalCase model export name. */
|
|
15
|
+
export declare function toCamelCase(s: string): string;
|
|
16
|
+
//# sourceMappingURL=pull-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pull-utils.d.ts","sourceRoot":"","sources":["../src/pull-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,OAAO,CAAA;IACjB,SAAS,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,OAAO,CAAA;CACpB;AAED,6EAA6E;AAC7E,wBAAgB,aAAa,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAmCrD;AAED,qEAAqE;AACrE,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAI7C"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for the `pull` command — extracted for unit testability.
|
|
3
|
+
*/
|
|
4
|
+
/** Map a Postgres column type to the corresponding field.X() call string. */
|
|
5
|
+
export function pgTypeToField(col) {
|
|
6
|
+
const opts = { required: !col.nullable };
|
|
7
|
+
if (col.isPrimary)
|
|
8
|
+
opts["primaryKey"] = true;
|
|
9
|
+
if (col.isUnique && !col.isPrimary)
|
|
10
|
+
opts["unique"] = true;
|
|
11
|
+
const optsStr = JSON.stringify(opts);
|
|
12
|
+
const type = col.pgType.toLowerCase();
|
|
13
|
+
if (type.includes("uuid"))
|
|
14
|
+
return `field.uuid(${optsStr})`;
|
|
15
|
+
if (type.includes("text") || type.includes("varchar") || type.includes("char"))
|
|
16
|
+
return `field.text(${optsStr})`;
|
|
17
|
+
if (type.includes("int8") || type.includes("bigint"))
|
|
18
|
+
return `field.bigInt(${optsStr})`;
|
|
19
|
+
if (type.includes("int2") || type.includes("smallint"))
|
|
20
|
+
return `field.smallInt(${optsStr})`;
|
|
21
|
+
if (type.includes("interval"))
|
|
22
|
+
return `field.interval(${optsStr})`;
|
|
23
|
+
if (type.includes("int") || type.includes("serial"))
|
|
24
|
+
return `field.integer(${optsStr})`;
|
|
25
|
+
if (type.includes("float") || type.includes("double") || type.includes("real"))
|
|
26
|
+
return `field.float(${optsStr})`;
|
|
27
|
+
if (type.includes("numeric") || type.includes("decimal"))
|
|
28
|
+
return `field.decimal(${optsStr})`;
|
|
29
|
+
if (type.includes("bool"))
|
|
30
|
+
return `field.boolean(${optsStr})`;
|
|
31
|
+
if (type.includes("timestamptz") || type.includes("timestamp with time zone"))
|
|
32
|
+
return `field.datetime(${optsStr})`;
|
|
33
|
+
if (type.includes("timestamp"))
|
|
34
|
+
return `field.timestamp(${optsStr})`;
|
|
35
|
+
if (type.includes("date"))
|
|
36
|
+
return `field.date(${optsStr})`;
|
|
37
|
+
if (type.includes("jsonb"))
|
|
38
|
+
return `field.json({ ...${optsStr}, jsonb: true })`;
|
|
39
|
+
if (type.includes("json"))
|
|
40
|
+
return `field.json(${optsStr})`;
|
|
41
|
+
if (type.includes("inet"))
|
|
42
|
+
return `field.ip(${optsStr})`;
|
|
43
|
+
if (type.includes("cidr"))
|
|
44
|
+
return `field.cidr(${optsStr})`;
|
|
45
|
+
if (type.includes("macaddr"))
|
|
46
|
+
return `field.macaddr(${optsStr})`;
|
|
47
|
+
if (type.includes("bytea"))
|
|
48
|
+
return `field.bytea(${optsStr})`;
|
|
49
|
+
if (type.includes("money"))
|
|
50
|
+
return `field.money(${optsStr})`;
|
|
51
|
+
if (type.includes("xml"))
|
|
52
|
+
return `field.xml(${optsStr})`;
|
|
53
|
+
if (type.includes("tsvector"))
|
|
54
|
+
return `field.tsvector(${optsStr})`;
|
|
55
|
+
if (type.includes("tsquery"))
|
|
56
|
+
return `field.tsquery(${optsStr})`;
|
|
57
|
+
return `field.text({ ...${optsStr} }) /* TODO: ${col.pgType} */`;
|
|
58
|
+
}
|
|
59
|
+
/** Convert snake_case table name to PascalCase model export name. */
|
|
60
|
+
export function toCamelCase(s) {
|
|
61
|
+
return s
|
|
62
|
+
.replace(/_([a-z])/g, (_, c) => c.toUpperCase())
|
|
63
|
+
.replace(/^([a-z])/, (c) => c.toUpperCase());
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=pull-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pull-utils.js","sourceRoot":"","sources":["../src/pull-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH,6EAA6E;AAC7E,MAAM,UAAU,aAAa,CAAC,GAAe;IAC3C,MAAM,IAAI,GAA4B,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAA;IACjE,IAAI,GAAG,CAAC,SAAS;QAAE,IAAI,CAAC,YAAY,CAAC,GAAG,IAAI,CAAA;IAC5C,IAAI,GAAG,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,SAAS;QAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAA;IACzD,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IAEpC,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,CAAA;IAErC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,cAAc,OAAO,GAAG,CAAA;IAC1D,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC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AAA;AACxD,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Postinstall script — downloads the correct engine binary for the current
|
|
3
|
+
* platform and caches it at ~/.supatype/engine/{version}/supatype-engine[.exe].
|
|
4
|
+
*
|
|
5
|
+
* Pattern: same as Prisma, esbuild, SWC, Turbo.
|
|
6
|
+
*
|
|
7
|
+
* The binary is verified via:
|
|
8
|
+
* 1. Minisign signature on checksums.sha256 (proves checksum file is authentic)
|
|
9
|
+
* 2. SHA256 checksum of binary (proves binary matches signed checksum)
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=postinstall.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postinstall.d.ts","sourceRoot":"","sources":["../../src/scripts/postinstall.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Postinstall script — downloads the correct engine binary for the current
|
|
3
|
+
* platform and caches it at ~/.supatype/engine/{version}/supatype-engine[.exe].
|
|
4
|
+
*
|
|
5
|
+
* Pattern: same as Prisma, esbuild, SWC, Turbo.
|
|
6
|
+
*
|
|
7
|
+
* The binary is verified via:
|
|
8
|
+
* 1. Minisign signature on checksums.sha256 (proves checksum file is authentic)
|
|
9
|
+
* 2. SHA256 checksum of binary (proves binary matches signed checksum)
|
|
10
|
+
*/
|
|
11
|
+
import { ENGINE_VERSION } from "../engine-version.js";
|
|
12
|
+
import { detectPlatform } from "../engine/platform.js";
|
|
13
|
+
import { hasCachedBinary } from "../engine/cache.js";
|
|
14
|
+
import { resolveEngine } from "../engine/resolve.js";
|
|
15
|
+
async function main() {
|
|
16
|
+
const platform = detectPlatform();
|
|
17
|
+
// Skip if already cached at the right version
|
|
18
|
+
if (hasCachedBinary(ENGINE_VERSION, platform)) {
|
|
19
|
+
console.log(`[supatype] Engine v${ENGINE_VERSION} already cached.`);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
console.log(`[supatype] Downloading engine v${ENGINE_VERSION} for ${platform.os}-${platform.arch}...`);
|
|
23
|
+
const result = await resolveEngine(ENGINE_VERSION);
|
|
24
|
+
console.log(`[supatype] Engine installed at ${result.binaryPath}`);
|
|
25
|
+
}
|
|
26
|
+
main().catch((err) => {
|
|
27
|
+
console.error("[supatype] Engine download failed:", err.message);
|
|
28
|
+
console.error("[supatype] You can still use the CLI — the engine will be downloaded on first use.");
|
|
29
|
+
// Don't exit(1) — let npm install succeed even if binary download fails.
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=postinstall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postinstall.js","sourceRoot":"","sources":["../../src/scripts/postinstall.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEpD,KAAK,UAAU,IAAI;IACjB,MAAM,QAAQ,GAAG,cAAc,EAAE,CAAA;IAEjC,8CAA8C;IAC9C,IAAI,eAAe,CAAC,cAAc,EAAE,QAAQ,CAAC,EAAE,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,sBAAsB,cAAc,kBAAkB,CAAC,CAAA;QACnE,OAAM;IACR,CAAC;IAED,OAAO,CAAC,GAAG,CACT,kCAAkC,cAAc,QAAQ,QAAQ,CAAC,EAAE,IAAI,QAAQ,CAAC,IAAI,KAAK,CAC1F,CAAA;IAED,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,cAAc,CAAC,CAAA;IAClD,OAAO,CAAC,GAAG,CAAC,kCAAkC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAA;AACpE,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IAChE,OAAO,CAAC,KAAK,CACX,oFAAoF,CACrF,CAAA;IACD,yEAAyE;AAC3E,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locates the tsx binary shipped with this package and provides a helper
|
|
3
|
+
* to run TypeScript files at runtime.
|
|
4
|
+
*/
|
|
5
|
+
import { type SpawnSyncOptions } from "node:child_process";
|
|
6
|
+
export interface RunResult {
|
|
7
|
+
stdout: string;
|
|
8
|
+
stderr: string;
|
|
9
|
+
exitCode: number;
|
|
10
|
+
}
|
|
11
|
+
/** Run a TypeScript file with tsx and capture output. */
|
|
12
|
+
export declare function runTsFile(filePath: string, opts?: SpawnSyncOptions): RunResult;
|
|
13
|
+
/**
|
|
14
|
+
* Evaluate an ESM TypeScript snippet via tsx and return its stdout.
|
|
15
|
+
* The snippet should write JSON to process.stdout.
|
|
16
|
+
*/
|
|
17
|
+
export declare function evalTsSnippet(snippet: string, opts?: SpawnSyncOptions): RunResult;
|
|
18
|
+
//# sourceMappingURL=tsx-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsx-runner.d.ts","sourceRoot":"","sources":["../src/tsx-runner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AA+BrE,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,yDAAyD;AACzD,wBAAgB,SAAS,CACvB,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,gBAAqB,GAC1B,SAAS,CAWX;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,gBAAqB,GAC1B,SAAS,CAYX"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locates the tsx binary shipped with this package and provides a helper
|
|
3
|
+
* to run TypeScript files at runtime.
|
|
4
|
+
*/
|
|
5
|
+
import { spawnSync } from "node:child_process";
|
|
6
|
+
import { readFileSync } from "node:fs";
|
|
7
|
+
import { resolve, dirname } from "node:path";
|
|
8
|
+
import { createRequire } from "node:module";
|
|
9
|
+
import { writeFileSync, unlinkSync } from "node:fs";
|
|
10
|
+
import { tmpdir } from "node:os";
|
|
11
|
+
const _require = createRequire(import.meta.url);
|
|
12
|
+
/**
|
|
13
|
+
* Resolve the absolute path to the tsx CLI entry point.
|
|
14
|
+
* tsx is a direct dependency so this will always succeed after `npm install`.
|
|
15
|
+
*/
|
|
16
|
+
function findTsxBin() {
|
|
17
|
+
try {
|
|
18
|
+
const pkgPath = _require.resolve("tsx/package.json");
|
|
19
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
20
|
+
const binRelative = typeof pkg.bin === "string"
|
|
21
|
+
? pkg.bin
|
|
22
|
+
: (pkg.bin?.["tsx"] ?? "./dist/cli.mjs");
|
|
23
|
+
return resolve(dirname(pkgPath), binRelative);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return "tsx"; // last-resort: hope it's on PATH
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const TSX_BIN = findTsxBin();
|
|
30
|
+
/** Run a TypeScript file with tsx and capture output. */
|
|
31
|
+
export function runTsFile(filePath, opts = {}) {
|
|
32
|
+
const result = spawnSync(process.execPath, [TSX_BIN, filePath], {
|
|
33
|
+
encoding: "utf8",
|
|
34
|
+
maxBuffer: 50 * 1024 * 1024,
|
|
35
|
+
...opts,
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
stdout: String(result.stdout ?? ""),
|
|
39
|
+
stderr: String(result.stderr ?? ""),
|
|
40
|
+
exitCode: result.status ?? 1,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Evaluate an ESM TypeScript snippet via tsx and return its stdout.
|
|
45
|
+
* The snippet should write JSON to process.stdout.
|
|
46
|
+
*/
|
|
47
|
+
export function evalTsSnippet(snippet, opts = {}) {
|
|
48
|
+
const tmpFile = resolve(tmpdir(), `supatype-eval-${Date.now()}.mts`);
|
|
49
|
+
writeFileSync(tmpFile, snippet, "utf8");
|
|
50
|
+
try {
|
|
51
|
+
return runTsFile(tmpFile, opts);
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
try {
|
|
55
|
+
unlinkSync(tmpFile);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// ignore cleanup errors
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=tsx-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsx-runner.js","sourceRoot":"","sources":["../src/tsx-runner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAyB,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAc,YAAY,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhC,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAE/C;;;GAGG;AACH,SAAS,UAAU;IACjB,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAA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AI,CAAC;QACH,OAAO,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IACjC,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YACH,UAAU,CAAC,OAAO,CAAC,CAAA;QACrB,CAAC;QAAC,MAAM,CAAC;YACP,wBAAwB;QAC1B,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@supatype/cli",
|
|
3
|
+
"version": "0.1.0-alpha.6",
|
|
4
|
+
"description": "Supatype CLI — schema push, introspect, generate",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"supatype": "./bin/supatype.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"commander": "^12.1.0",
|
|
19
|
+
"tsx": "^4.19.2",
|
|
20
|
+
"@supatype/schema": "0.1.0-alpha.6"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/node": "^22",
|
|
24
|
+
"@types/pg": "^8",
|
|
25
|
+
"typescript": "^5",
|
|
26
|
+
"vitest": "^4.0.18"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc --project tsconfig.json",
|
|
30
|
+
"dev": "tsc --project tsconfig.json --watch",
|
|
31
|
+
"typecheck": "tsc --project tsconfig.json --noEmit",
|
|
32
|
+
"postinstall": "node --input-type=module --eval \"import{existsSync}from'node:fs';import{resolve}from'node:path';import{pathToFileURL}from'node:url';const f=resolve(process.cwd(),'dist/scripts/postinstall.js');if(existsSync(f))await import(pathToFileURL(f).href)\"",
|
|
33
|
+
"test": "vitest run",
|
|
34
|
+
"clean": "rm -rf dist *.tsbuildinfo"
|
|
35
|
+
}
|
|
36
|
+
}
|