better-supabase 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/bin/better-supabase.js +4 -0
- package/dist/{base64-CQeB1eSf.js → base64-D2gsioCY.js} +2 -2
- package/dist/claims-BAf6c7is.js +48 -0
- package/dist/cli/_format-Cax5EsM9.js +101 -0
- package/dist/cli/bin.d.ts +1 -0
- package/dist/cli/bin.js +48 -0
- package/dist/cli/command-CK14fP91.js +502 -0
- package/dist/cli/compare-BmIWVEui.js +9 -0
- package/dist/cli/config-D9R0o1LH.js +1895 -0
- package/dist/cli/config-SSKSTUl2.js +2 -0
- package/dist/cli/db-DOBPt660.js +52 -0
- package/dist/cli/dist-B1MvLv-M.js +129 -0
- package/dist/cli/dist-CFgGknmZ.js +1112 -0
- package/dist/cli/dist-Du7VnEUG.js +621 -0
- package/dist/cli/doctor-BOym3mbL.js +2382 -0
- package/dist/cli/env-BZ0uy8XK.js +108 -0
- package/dist/cli/env-jIFUADLY.js +511 -0
- package/dist/cli/errors-4v4DTtda.js +56 -0
- package/dist/cli/fastest-levenshtein-CFN-lNDv.js +120 -0
- package/dist/cli/gen-Ccn_p90L.js +2008 -0
- package/dist/cli/gen-D5cLCULx.js +2 -0
- package/dist/cli/index.d.ts +493 -0
- package/dist/cli/index.js +184 -0
- package/dist/cli/init-ClnxRYBF.js +550 -0
- package/dist/cli/introspect-DxqfkVIv.js +81 -0
- package/dist/cli/io-k41_z-jT.js +24 -0
- package/dist/cli/json5-ChRycquj.js +787 -0
- package/dist/cli/jsonc-BUniUpOk.js +2 -0
- package/dist/cli/jsonc-D5Fu67jw.js +45 -0
- package/dist/cli/keys-ByKHnvP9.js +83 -0
- package/dist/cli/ohash-D7bG_EOb.js +277 -0
- package/dist/cli/openapi-8WHjxiTJ.js +66 -0
- package/dist/cli/project-B_GeXyHh.js +70 -0
- package/dist/cli/prompts-BNcNfAve.js +1142 -0
- package/dist/cli/prompts-BTYQGunc.js +2 -0
- package/dist/cli/read-sets-CMa29t9a.js +971 -0
- package/dist/cli/rolldown-runtime-BPOCksWG.js +24 -0
- package/dist/cli/run-CP20LKk_.js +347 -0
- package/dist/cli/seed-5J6eu_Xg.js +98 -0
- package/dist/cli/skills-LJJIhLFR.js +137 -0
- package/dist/cli/sql-D4VbqmXi.js +199 -0
- package/dist/cli/style-C0NFdJRL.js +29 -0
- package/dist/cli/toml-DB-MNnFs.js +424 -0
- package/dist/cli/version-5mW_8sY1.js +4 -0
- package/dist/cli/yaml-CYCbJ6et.js +2252 -0
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +13 -13
- package/dist/{compiler-2zqGzxVZ.d.ts → compiler-DB3aSFOA.d.ts} +2 -2
- package/dist/config/index.js +4 -4
- package/dist/{config-Be4GwsqI.js → config-BpxDfnbg.js} +1 -1
- package/dist/{config-DOsGYSiT.js → config-CbvFmGD8.js} +1 -1
- package/dist/{define-DF341GDj.js → define-Bh0AqTik.js} +160 -79
- package/dist/{define-DUbydmJa.d.ts → define-CRS2MRV3.d.ts} +32 -28
- package/dist/edge/index.d.ts +8 -12
- package/dist/edge/index.js +50 -24
- package/dist/{entitlements-DvJXoI02.d.ts → entitlements-Dm-FHpNH.d.ts} +2 -2
- package/dist/{errors-Bl3rkOzo.js → errors-L0xK41y_.js} +1 -1
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +4 -4
- package/dist/{events-Do8jXh4D.d.ts → events-B21UOhvP.d.ts} +4 -4
- package/dist/{executor-DynmIWhq.d.ts → executor-B5IoUxLE.d.ts} +1 -1
- package/dist/{executor-C57jx2pn.js → executor-CVt6dD0B.js} +3 -3
- package/dist/{executor-B26lgbHD.d.ts → executor-CZ7ImRiD.d.ts} +2 -2
- package/dist/hono/index.d.ts +16 -23
- package/dist/hono/index.js +10 -10
- package/dist/{index-CTTMS6_1.d.ts → index-528Ugmyp.d.ts} +12 -3
- package/dist/{index-CADlNHK-.d.ts → index-BAy4tsAP.d.ts} +5 -5
- package/dist/{index-BNsABq7P.d.ts → index-BBdvo-5d.d.ts} +23 -25
- package/dist/{index-qriRM9cZ.d.ts → index-BhHEC04r.d.ts} +3 -3
- package/dist/{index-GV77NpRP.d.ts → index-D5IfUIDh.d.ts} +3 -3
- package/dist/{index-CriFFJ_p.d.ts → index-DFmOpBGC.d.ts} +11 -11
- package/dist/{index-UJ-LUxtI.d.ts → index-RlLXd8dL.d.ts} +12 -12
- package/dist/index.d.ts +15 -15
- package/dist/index.js +13 -13
- package/dist/{invalidate-DbxuL2jL.js → invalidate-CgxmRamI.js} +7 -1
- package/dist/jobs/index.d.ts +10 -4
- package/dist/jobs/index.js +32 -16
- package/dist/{json-schema--aOXAGfU.js → json-schema-DP6V7cbr.js} +1 -1
- package/dist/list/index.d.ts +1 -1
- package/dist/list/index.js +3 -3
- package/dist/{live-QE3UPbGm.d.ts → live-BHakSWWo.d.ts} +12 -12
- package/dist/{live-D8rV1Ldw.js → live-CdJBOc4f.js} +13 -9
- package/dist/lookup-BaP5bI27.js +18 -0
- package/dist/mcp/index.d.ts +18 -18
- package/dist/mcp/index.js +23 -18
- package/dist/{mfa-x3V3vGh-.d.ts → mfa-C7MNQ1Ob.d.ts} +1 -1
- package/dist/{mfa-BxoR1RkN.js → mfa-byfjruR9.js} +118 -29
- package/dist/next/image/index.js +6 -3
- package/dist/next/index.d.ts +38 -35
- package/dist/next/index.js +41 -33
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.js +6 -6
- package/dist/orpc/index.d.ts +17 -20
- package/dist/orpc/index.js +11 -11
- package/dist/otel/index.d.ts +5 -5
- package/dist/otel/index.js +81 -62
- package/dist/{permdock-sql-Bta_G0v-.js → permdock-sql-C4KFzLc9.js} +1 -1
- package/dist/{plugin-DVRB8qNE.d.ts → plugin-bNhvJwRh.d.ts} +2 -2
- package/dist/plugins/actor/index.d.ts +1 -1
- package/dist/plugins/actor/index.js +1 -1
- package/dist/plugins/rules/index.d.ts +2 -2
- package/dist/plugins/rules/index.js +42 -12
- package/dist/plugins/soft-delete/index.d.ts +2 -2
- package/dist/plugins/soft-delete/index.js +2 -2
- package/dist/plugins/tenant/index.d.ts +2 -2
- package/dist/plugins/tenant/index.js +10 -4
- package/dist/plugins/timestamps/index.d.ts +1 -1
- package/dist/plugins/timestamps/index.js +1 -1
- package/dist/plugins/validation/index.d.ts +2 -2
- package/dist/plugins/validation/index.js +3 -3
- package/dist/{pool-B9qsLyFR.d.ts → pool-DFwEQwmN.d.ts} +11 -4
- package/dist/postgres/index.d.ts +5 -5
- package/dist/postgres/index.js +3 -2
- package/dist/{postgrest-DmBlevh-.d.ts → postgrest-Bc-0Xw62.d.ts} +1 -1
- package/dist/{problem-CGt1ADix.js → problem-BihjPR0t.js} +1 -1
- package/dist/{problem-Z2RTQjZD.d.ts → problem-U8UEKccv.d.ts} +1 -1
- package/dist/query/index.d.ts +2 -2
- package/dist/query/index.js +2 -2
- package/dist/{query-BdKLTPlj.js → query-BMMSWbI7.js} +18 -18
- package/dist/react/index.d.ts +6 -6
- package/dist/react/index.js +1 -1
- package/dist/react/server.d.ts +5 -5
- package/dist/react/server.js +3 -3
- package/dist/react/session.d.ts +4 -4
- package/dist/react/session.js +2 -2
- package/dist/{react-DNBYNazu.js → react-CQHMaESR.js} +39 -39
- package/dist/{read-set-D0qBcboM.js → read-set-FWK8qQ58.js} +50 -15
- package/dist/realtime/index.d.ts +1 -1
- package/dist/realtime/index.js +13 -12
- package/dist/{index-kpgopLNv.d.ts → refresh-BwYkyNOQ.d.ts} +6 -3
- package/dist/{resolve-BRciX2jK.d.ts → resolve-BAqQcwMW.d.ts} +15 -10
- package/dist/{resource-CwVgiI5q.d.ts → resource-BJcaIfxi.d.ts} +5 -5
- package/dist/{resource-D30rp0GN.js → resource-My_y-Syh.js} +6 -6
- package/dist/{respond-DAkPIdTH.d.ts → respond-DgIbdrt8.d.ts} +31 -12
- package/dist/{result-DWXatkd6.js → result-Bj6yt33D.js} +2 -2
- package/dist/{result-c2OYgCV2.d.ts → result-CqEsbgYs.d.ts} +3 -3
- package/dist/server/index.d.ts +14 -14
- package/dist/server/index.js +12 -12
- package/dist/{respond-C44EZAJo.js → server-BA75B0mT.js} +139 -100
- package/dist/{shared-_6-uPL7E.js → shared-DnoCdMDr.js} +4 -3
- package/dist/{simplify-LakqK1vH.js → simplify-Cqvfr9dj.js} +67 -24
- package/dist/sql/index.d.ts +1 -1
- package/dist/sql/index.js +7 -7
- package/dist/{sql-BIgk12ew.js → sql-B34HU2DI.js} +3 -2
- package/dist/ssr/index.d.ts +4 -4
- package/dist/ssr/index.js +2 -2
- package/dist/{standard-FUi3Z3-7.js → standard-BRyBGTtp.js} +2 -2
- package/dist/{standard-eudBiRk1.d.ts → standard-BsaCYQJc.d.ts} +1 -1
- package/dist/{stats-D78UQ8Yu.js → stats-C_YxA2r1.js} +33 -8
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.js +26 -8
- package/dist/{tables-Dhha3BXM.js → tables-Cb-3_VWc.js} +14 -0
- package/dist/{temporal-required-CMxeSVPo.js → temporal-required-CBNHT6ni.js} +1 -1
- package/dist/testing/index.d.ts +20 -21
- package/dist/testing/index.js +45 -45
- package/dist/{version-BfpG2gks.js → version-Bmf7_FzM.js} +1 -1
- package/dist/{view-3Po_PVlr.d.ts → view-B64o81wp.d.ts} +5 -5
- package/dist/{view-wZ-9qIUz.js → view-BrJI2LKp.js} +1 -1
- package/dist/webhooks/index.d.ts +3 -3
- package/dist/webhooks/index.js +1 -1
- package/dist/{webhooks-CAIFQSTM.js → webhooks-Bh_Jf_-l.js} +37 -18
- package/package.json +36 -4
- package/skills/better-supabase/SKILL.md +57 -10
- package/skills/better-supabase/references/plugins.md +7 -11
- package/skills/better-supabase/references/troubleshooting.md +24 -4
- package/skills/better-supabase-api/SKILL.md +66 -18
- package/skills/better-supabase-api/references/adapters.md +44 -26
- package/skills/better-supabase-auth/SKILL.md +146 -0
- package/skills/better-supabase-auth/references/permdock.md +55 -0
- package/skills/better-supabase-testing/SKILL.md +58 -4
- package/dist/claims-CoTobNC-.js +0 -25
package/README.md
CHANGED
|
@@ -12,18 +12,18 @@
|
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
pnpm add better-supabase @supabase/supabase-js
|
|
15
|
-
pnpm add -D
|
|
15
|
+
pnpm add -D pg
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
ESM only. The
|
|
18
|
+
ESM only. The package includes the `better-supabase` CLI, which needs Node 24 or later; the runtime entries run on every WinterTC runtime (Node, Deno, Bun, Workers, Supabase Edge Functions). TypeScript 6 and 7 are tested.
|
|
19
19
|
|
|
20
20
|
## Quick start
|
|
21
21
|
|
|
22
|
-
Or start with `npx
|
|
22
|
+
Or start with `npx better-supabase init`, which detects your frameworks and prints the install command.
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
25
|
supabase start
|
|
26
|
-
pnpm better-supabase init # config, src/lib/supabase.ts and framework glue
|
|
26
|
+
pnpm better-supabase init # config, src/lib/supabase/index.ts and framework glue
|
|
27
27
|
pnpm better-supabase gen # database.types.ts and generated.ts
|
|
28
28
|
```
|
|
29
29
|
|
|
@@ -33,9 +33,9 @@ import { defineSupabase } from "better-supabase";
|
|
|
33
33
|
|
|
34
34
|
import { schema } from "./lib/supabase/generated.ts";
|
|
35
35
|
|
|
36
|
-
export const
|
|
36
|
+
export const betterSupabase = defineSupabase(schema);
|
|
37
37
|
|
|
38
|
-
const db =
|
|
38
|
+
const db = betterSupabase.connect(createClient(url, publishableKey));
|
|
39
39
|
|
|
40
40
|
const result = await db.customers.findMany({
|
|
41
41
|
select: ["id", "name"],
|
|
@@ -53,6 +53,7 @@ if (!result.ok) return result; // DbError: kind, message, status, code
|
|
|
53
53
|
| ---------------------------------------------------------- | ------------------------------------------------------------------------ |
|
|
54
54
|
| `better-supabase` | `defineSupabase`, repositories, `Result`, `DbError`, `SPEC_PINS` |
|
|
55
55
|
| `better-supabase/config` | `defineConfig` and generators for `better-supabase.config.ts` |
|
|
56
|
+
| `better-supabase/cli` | `run`, `registerCommand` and codegen for scripts that drive the CLI |
|
|
56
57
|
| `better-supabase/client` | Browser repositories that follow the session |
|
|
57
58
|
| `better-supabase/react` | Provider, typed hooks and the server session |
|
|
58
59
|
| `better-supabase/query` | TanStack Query options with table-based invalidation |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/core/base64.ts
|
|
2
|
-
const encoder = new TextEncoder();
|
|
3
|
-
const decoder = new TextDecoder();
|
|
2
|
+
const encoder = /* @__PURE__ */ new TextEncoder();
|
|
3
|
+
const decoder = /* @__PURE__ */ new TextDecoder();
|
|
4
4
|
/** Standard base64 (RFC 4648 section 4) of `input`, with padding. */
|
|
5
5
|
function toBase64(input) {
|
|
6
6
|
const bytes = typeof input === "string" ? encoder.encode(input) : input;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//#region src/core/claims.ts
|
|
2
|
+
const DEFAULT_CLAIMS = {
|
|
3
|
+
tenant: "tenant_id",
|
|
4
|
+
scope: "tenant",
|
|
5
|
+
features: "features"
|
|
6
|
+
};
|
|
7
|
+
/** The configured claim names, with defaults for the ones codegen left out. */
|
|
8
|
+
function claimsOf(meta) {
|
|
9
|
+
if (!meta?.claims) return DEFAULT_CLAIMS;
|
|
10
|
+
let claims = claimsByMeta.get(meta);
|
|
11
|
+
if (!claims) {
|
|
12
|
+
claims = {
|
|
13
|
+
...DEFAULT_CLAIMS,
|
|
14
|
+
...meta.claims
|
|
15
|
+
};
|
|
16
|
+
claimsByMeta.set(meta, claims);
|
|
17
|
+
}
|
|
18
|
+
return claims;
|
|
19
|
+
}
|
|
20
|
+
const claimsByMeta = /* @__PURE__ */ new WeakMap();
|
|
21
|
+
/** Where the active tenant is read from: the top-level claim, then `app_metadata`. */
|
|
22
|
+
function tenantClaimPaths(tenant = DEFAULT_CLAIMS.tenant) {
|
|
23
|
+
let paths = tenantPaths.get(tenant);
|
|
24
|
+
if (!paths) {
|
|
25
|
+
paths = [tenant, `app_metadata.${tenant}`];
|
|
26
|
+
tenantPaths.set(tenant, paths);
|
|
27
|
+
}
|
|
28
|
+
return paths;
|
|
29
|
+
}
|
|
30
|
+
const tenantPaths = /* @__PURE__ */ new Map();
|
|
31
|
+
/** Claim paths come from configuration, so this stays small. */
|
|
32
|
+
const segmentsByPath = /* @__PURE__ */ new Map();
|
|
33
|
+
function segmentsOf(path) {
|
|
34
|
+
let segments = segmentsByPath.get(path);
|
|
35
|
+
if (!segments) {
|
|
36
|
+
segments = path.split(".");
|
|
37
|
+
if (segmentsByPath.size < 256) segmentsByPath.set(path, segments);
|
|
38
|
+
}
|
|
39
|
+
return segments;
|
|
40
|
+
}
|
|
41
|
+
/** The string at a dotted claim path, if any. */
|
|
42
|
+
function claimAt(claims, path) {
|
|
43
|
+
let value = claims;
|
|
44
|
+
for (const segment of segmentsOf(path)) value = typeof value === "object" && value !== null ? value[segment] : void 0;
|
|
45
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { tenantClaimPaths as i, claimAt as n, claimsOf as r, DEFAULT_CLAIMS as t };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/confbox@0.3.1/node_modules/confbox/dist/_chunks/libs/detect-indent.mjs
|
|
2
|
+
const e = /^(?:( )+|\t+)/;
|
|
3
|
+
const t$1 = `space`;
|
|
4
|
+
function n$1(e, n, r) {
|
|
5
|
+
return e && n === t$1 && r === 1;
|
|
6
|
+
}
|
|
7
|
+
function r$1(r, a) {
|
|
8
|
+
let o = /* @__PURE__ */ new Map(), s = 0, c, l;
|
|
9
|
+
for (let u of r.split(/\n/g)) {
|
|
10
|
+
if (!u) continue;
|
|
11
|
+
let r = u.match(e);
|
|
12
|
+
if (r === null) s = 0, c = ``;
|
|
13
|
+
else {
|
|
14
|
+
let e = r[0].length, u = r[1] ? t$1 : `tab`;
|
|
15
|
+
if (n$1(a, u, e)) continue;
|
|
16
|
+
u !== c && (s = 0), c = u;
|
|
17
|
+
let d = 1, f = 0, p = e - s;
|
|
18
|
+
if (s = e, p === 0) d = 0, f = 1;
|
|
19
|
+
else {
|
|
20
|
+
let e = Math.abs(p);
|
|
21
|
+
if (n$1(a, u, e)) continue;
|
|
22
|
+
l = i$1(u, e);
|
|
23
|
+
}
|
|
24
|
+
let m = o.get(l);
|
|
25
|
+
o.set(l, m === void 0 ? [1, 0] : [m[0] + d, m[1] + f]);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return o;
|
|
29
|
+
}
|
|
30
|
+
function i$1(e, n) {
|
|
31
|
+
return (e === t$1 ? `s` : `t`) + String(n);
|
|
32
|
+
}
|
|
33
|
+
function a$1(e) {
|
|
34
|
+
return {
|
|
35
|
+
type: e[0] === `s` ? t$1 : `tab`,
|
|
36
|
+
amount: Number(e.slice(1))
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function o$1(e) {
|
|
40
|
+
let t, n = 0, r = 0;
|
|
41
|
+
for (let [i, [a, o]] of e) (a > n || a === n && o > r) && (n = a, r = o, t = i);
|
|
42
|
+
return t;
|
|
43
|
+
}
|
|
44
|
+
function s$1(e, n) {
|
|
45
|
+
return (e === t$1 ? ` ` : ` `).repeat(n);
|
|
46
|
+
}
|
|
47
|
+
function c(e) {
|
|
48
|
+
if (typeof e != `string`) throw TypeError(`Expected a string`);
|
|
49
|
+
let t = r$1(e, !0);
|
|
50
|
+
t.size === 0 && (t = r$1(e, !1));
|
|
51
|
+
let n = o$1(t), i, c = 0, l = ``;
|
|
52
|
+
return n !== void 0 && ({type: i, amount: c} = a$1(n), l = s$1(i, c)), {
|
|
53
|
+
amount: c,
|
|
54
|
+
type: i,
|
|
55
|
+
indent: l
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region ../../node_modules/.pnpm/confbox@0.3.1/node_modules/confbox/dist/_chunks/_format.mjs
|
|
60
|
+
const t = Symbol.for(`__confbox_fmt__`);
|
|
61
|
+
const n = /^(\s+)/;
|
|
62
|
+
const r = /(\s+)$/;
|
|
63
|
+
function i(e) {
|
|
64
|
+
return e.charCodeAt(0) === 65279 ? e.slice(1) : e;
|
|
65
|
+
}
|
|
66
|
+
function a(e, t = {}) {
|
|
67
|
+
return {
|
|
68
|
+
sample: t.indent === void 0 && t.preserveIndentation !== !1 && i(e).slice(0, t?.sampleSize || 1024),
|
|
69
|
+
whiteSpace: t.preserveWhitespace === !1 ? void 0 : {
|
|
70
|
+
start: n.exec(e)?.[0] || ``,
|
|
71
|
+
end: r.exec(e)?.[0] || ``
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function o(e, n, r) {
|
|
76
|
+
!n || typeof n != `object` || Object.defineProperty(n, t, {
|
|
77
|
+
enumerable: !1,
|
|
78
|
+
configurable: !0,
|
|
79
|
+
writable: !0,
|
|
80
|
+
value: a(e, r)
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function s(n, r) {
|
|
84
|
+
if (!n || typeof n != `object` || !(t in n)) return {
|
|
85
|
+
indent: r?.indent ?? 2,
|
|
86
|
+
whitespace: {
|
|
87
|
+
start: ``,
|
|
88
|
+
end: ``
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
let i = n[t];
|
|
92
|
+
return {
|
|
93
|
+
indent: r?.indent || c(i.sample || ``).indent,
|
|
94
|
+
whitespace: i.whiteSpace || {
|
|
95
|
+
start: ``,
|
|
96
|
+
end: ``
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { o as n, s as r, i as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/cli/bin.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { i as run } from "./run-CP20LKk_.js";
|
|
3
|
+
import { t as colorEnabled } from "./style-C0NFdJRL.js";
|
|
4
|
+
import { text } from "node:stream/consumers";
|
|
5
|
+
//#region src/cli/bin.ts
|
|
6
|
+
const clack = () => import("./prompts-BTYQGunc.js").then((module) => module.clackPrompter);
|
|
7
|
+
const prompts = {
|
|
8
|
+
select: async (message, choices, initial) => (await clack()).select(message, choices, initial),
|
|
9
|
+
multiselect: async (message, choices, initial) => (await clack()).multiselect(message, choices, initial),
|
|
10
|
+
confirm: async (message) => (await clack()).confirm(message),
|
|
11
|
+
spinner: (message) => {
|
|
12
|
+
let stop;
|
|
13
|
+
let stopped = false;
|
|
14
|
+
clack().then((prompter) => {
|
|
15
|
+
if (!stopped) stop = prompter.spinner(message);
|
|
16
|
+
});
|
|
17
|
+
return () => {
|
|
18
|
+
stopped = true;
|
|
19
|
+
stop?.();
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const controller = new AbortController();
|
|
24
|
+
process.once("SIGINT", () => {
|
|
25
|
+
controller.abort();
|
|
26
|
+
});
|
|
27
|
+
process.once("SIGTERM", () => {
|
|
28
|
+
controller.abort();
|
|
29
|
+
});
|
|
30
|
+
const result = await run(process.argv.slice(2), {
|
|
31
|
+
cwd: process.cwd(),
|
|
32
|
+
env: process.env,
|
|
33
|
+
signal: controller.signal,
|
|
34
|
+
io: {
|
|
35
|
+
stdout: (chunk) => {
|
|
36
|
+
process.stdout.write(chunk);
|
|
37
|
+
},
|
|
38
|
+
stderr: (chunk) => {
|
|
39
|
+
process.stderr.write(chunk);
|
|
40
|
+
},
|
|
41
|
+
stdin: () => text(process.stdin),
|
|
42
|
+
color: colorEnabled(),
|
|
43
|
+
...process.stdin.isTTY && process.stdout.isTTY ? { prompts } : {}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
process.exitCode = controller.signal.aborted ? 130 : result.code;
|
|
47
|
+
//#endregion
|
|
48
|
+
export {};
|