@supatype/cli 0.1.2 → 0.1.4
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 +111 -108
- package/.turbo/turbo-typecheck.log +1 -1
- package/dist/commands/admin.d.ts +12 -0
- package/dist/commands/admin.d.ts.map +1 -1
- package/dist/commands/admin.js +97 -23
- package/dist/commands/admin.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +287 -182
- package/dist/commands/init.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +12 -1
- package/dist/config.js.map +1 -1
- package/dist/dev-compose.js +3 -3
- package/dist/dev-compose.js.map +1 -1
- package/dist/dev-log-bus.d.ts +1 -1
- package/dist/dev-log-bus.d.ts.map +1 -1
- package/dist/dev-log-bus.js +5 -3
- package/dist/dev-log-bus.js.map +1 -1
- package/dist/dev-ready-panel.d.ts +2 -0
- package/dist/dev-ready-panel.d.ts.map +1 -1
- package/dist/dev-ready-panel.js +18 -0
- package/dist/dev-ready-panel.js.map +1 -1
- package/dist/init-project-detect.d.ts +14 -0
- package/dist/init-project-detect.d.ts.map +1 -0
- package/dist/init-project-detect.js +89 -0
- package/dist/init-project-detect.js.map +1 -0
- package/dist/type-extractor.js +44 -0
- package/dist/type-extractor.js.map +1 -1
- package/dist/ui/dev/DevDashboard.d.ts.map +1 -1
- package/dist/ui/dev/DevDashboard.js +11 -4
- package/dist/ui/dev/DevDashboard.js.map +1 -1
- package/dist/ui/dev/DevReadyPanelView.d.ts +2 -1
- package/dist/ui/dev/DevReadyPanelView.d.ts.map +1 -1
- package/dist/ui/dev/DevReadyPanelView.js +21 -2
- package/dist/ui/dev/DevReadyPanelView.js.map +1 -1
- package/dist/ui/flows/FlowApp.d.ts.map +1 -1
- package/dist/ui/flows/FlowApp.js +3 -1
- package/dist/ui/flows/FlowApp.js.map +1 -1
- package/dist/ui/flows/prompt-fields.d.ts.map +1 -1
- package/dist/ui/flows/prompt-fields.js +9 -5
- package/dist/ui/flows/prompt-fields.js.map +1 -1
- package/dist/ui/runtime/run-clack-flow.d.ts.map +1 -1
- package/dist/ui/runtime/run-clack-flow.js +15 -3
- package/dist/ui/runtime/run-clack-flow.js.map +1 -1
- package/dist/ui/runtime/stdin-after-ink.d.ts +3 -0
- package/dist/ui/runtime/stdin-after-ink.d.ts.map +1 -0
- package/dist/ui/runtime/stdin-after-ink.js +16 -0
- package/dist/ui/runtime/stdin-after-ink.js.map +1 -0
- package/package.json +1 -1
- package/src/commands/admin.ts +135 -26
- package/src/commands/init.ts +360 -213
- package/src/config.ts +13 -1
- package/src/dev-compose.ts +4 -4
- package/src/dev-log-bus.ts +5 -3
- package/src/dev-ready-panel.ts +17 -0
- package/src/init-project-detect.ts +99 -0
- package/src/type-extractor.ts +57 -0
- package/src/ui/dev/DevDashboard.tsx +14 -4
- package/src/ui/dev/DevReadyPanelView.tsx +76 -9
- package/src/ui/flows/FlowApp.tsx +3 -1
- package/src/ui/flows/prompt-fields.tsx +13 -7
- package/src/ui/runtime/run-clack-flow.tsx +16 -3
- package/src/ui/runtime/stdin-after-ink.ts +18 -0
- package/tests/admin-ensure.test.ts +80 -0
- package/tests/config.test.ts +19 -0
- package/tests/dev-ready-panel.test.ts +18 -1
- package/tests/init-project-detect.test.ts +53 -0
- package/tests/stdin-after-ink.test.ts +8 -0
- package/tests/type-extractor.test.ts +101 -0
- package/tsconfig.tsbuildinfo +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @supatype/cli@0.1.
|
|
2
|
+
> @supatype/cli@0.1.4 build /home/runner/work/supatype/supatype/packages/cli
|
|
3
3
|
> tsc --project tsconfig.json && node --input-type=module -e "import{cpSync,mkdirSync}from'node:fs';const a='dist/assets';mkdirSync(a,{recursive:true});cpSync('assets/supatype-logo-wordmark.ascii.txt',a+'/supatype-logo-wordmark.ascii.txt')"
|
|
4
4
|
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
|
|
2
|
-
> @supatype/cli@0.1.
|
|
2
|
+
> @supatype/cli@0.1.4 test /home/runner/work/supatype/supatype/packages/cli
|
|
3
3
|
> vitest run
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
[1m[46m RUN [49m[22m [36mv4.0.18 [39m[90m/home/runner/work/supatype/supatype/packages/cli[39m
|
|
7
7
|
|
|
8
|
-
[32m✓[39m tests/type-extractor.test.ts [2m([22m[
|
|
9
|
-
[32m✓[39m tests/runtime-contract.test.ts [2m([22m[2m41 tests[22m[2m)[22m[32m
|
|
8
|
+
[32m✓[39m tests/type-extractor.test.ts [2m([22m[2m36 tests[22m[2m)[22m[32m 229[2mms[22m[39m
|
|
9
|
+
[32m✓[39m tests/runtime-contract.test.ts [2m([22m[2m41 tests[22m[2m)[22m[32m 131[2mms[22m[39m
|
|
10
10
|
[90mstdout[2m | tests/init.test.ts[2m > [22m[2mscaffold()[2m > [22m[2mcreates all expected files
|
|
11
11
|
[22m[39m created package.json
|
|
12
12
|
created supatype.config.ts
|
|
@@ -291,7 +291,11 @@
|
|
|
291
291
|
created public/.gitkeep
|
|
292
292
|
created .gitignore
|
|
293
293
|
|
|
294
|
-
[32m✓[39m tests/init.test.ts [2m([22m[2m26 tests[22m[2m)[22m[32m
|
|
294
|
+
[32m✓[39m tests/init.test.ts [2m([22m[2m26 tests[22m[2m)[22m[32m 95[2mms[22m[39m
|
|
295
|
+
|
|
296
|
+
[32m✓[39m tests/dev-ui.test.ts [2m([22m[2m21 tests[22m[2m)[22m[32m 108[2mms[22m[39m
|
|
297
|
+
|
|
298
|
+
[supatype] Shutting down…
|
|
295
299
|
[90mstdout[2m | tests/docker-runtime.test.ts[2m > [22m[2mrequireDockerDaemon[2m > [22m[2mexits when the daemon is unavailable
|
|
296
300
|
[22m[39m
|
|
297
301
|
Start the Docker daemon (e.g. sudo systemctl start docker), then try again.
|
|
@@ -300,22 +304,21 @@
|
|
|
300
304
|
|
|
301
305
|
docker: daemon down
|
|
302
306
|
|
|
303
|
-
[32m✓[39m tests/docker-runtime.test.ts [2m([22m[2m10 tests[22m[2m)[22m[32m
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
[supatype
|
|
308
|
-
|
|
309
|
-
[33m[2m✓[22m[39m
|
|
310
|
-
[33m[2m✓[22m[39m
|
|
311
|
-
[33m[2m✓[22m[39m
|
|
312
|
-
[33m[2m✓[22m[39m loads
|
|
313
|
-
|
|
314
|
-
[33m[2m✓[22m[39m supports optional output field in config [33m 559[2mms[22m[39m
|
|
315
|
-
[33m[2m✓[22m[39m merges supatype.local.config.ts over base [33m 1016[2mms[22m[39m
|
|
316
|
-
[32m✓[39m tests/command-chrome-coverage.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 17[2mms[22m[39m
|
|
307
|
+
[32m✓[39m tests/docker-runtime.test.ts [2m([22m[2m10 tests[22m[2m)[22m[32m 17[2mms[22m[39m
|
|
308
|
+
[32m✓[39m tests/config.test.ts [2m([22m[2m19 tests[22m[2m)[22m[33m 5201[2mms[22m[39m
|
|
309
|
+
[33m[2m✓[22m[39m loads a valid supatype.config.ts (plain export default, no package imports) [33m 515[2mms[22m[39m
|
|
310
|
+
[33m[2m✓[22m[39m normalizes shorthand schema string to { path, pg_schema } [33m 598[2mms[22m[39m
|
|
311
|
+
[33m[2m✓[22m[39m loads a supatype.config.js (plain ESM) [33m 563[2mms[22m[39m
|
|
312
|
+
[33m[2m✓[22m[39m loads config without a versions section (latest by default) [33m 502[2mms[22m[39m
|
|
313
|
+
[33m[2m✓[22m[39m prefers supatype.config.ts over supatype.config.js when both exist [33m 484[2mms[22m[39m
|
|
314
|
+
[33m[2m✓[22m[39m supports optional output field in config [33m 599[2mms[22m[39m
|
|
315
|
+
[33m[2m✓[22m[39m merges supatype.local.config.ts over base [33m 1065[2mms[22m[39m
|
|
316
|
+
[33m[2m✓[22m[39m loads defineConfig import before @supatype/cli is installed (init scaffold) [33m 863[2mms[22m[39m
|
|
317
|
+
[32m✓[39m tests/command-chrome-coverage.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 12[2mms[22m[39m
|
|
317
318
|
[90mstdout[2m | tests/link.test.ts[2m > [22m[2mlink model[2m > [22m[2mmigrates cloud.json into link.json
|
|
318
319
|
[22m[39m created package.json
|
|
320
|
+
[90mstderr[2m | tests/link.test.ts[2m > [22m[2mlink model[2m > [22m[2mmigrates cloud.json into link.json
|
|
321
|
+
[22m[39m[supatype] Migrated .supatype/cloud.json → .supatype/link.json (legacy files kept; remove manually when ready).
|
|
319
322
|
created supatype.config.ts
|
|
320
323
|
created schema/index.ts
|
|
321
324
|
created .env
|
|
@@ -324,57 +327,11 @@
|
|
|
324
327
|
created public/.gitkeep
|
|
325
328
|
created .gitignore
|
|
326
329
|
|
|
327
|
-
[90mstderr[2m | tests/link.test.ts[2m > [22m[2mlink model[2m > [22m[2mmigrates cloud.json into link.json
|
|
328
|
-
[22m[39m[supatype] Migrated .supatype/cloud.json → .supatype/link.json (legacy files kept; remove manually when ready).
|
|
329
|
-
|
|
330
|
-
[32m✓[39m tests/link.test.ts [2m([22m[2m4 tests[22m[2m)[22m[33m 2778[2mms[22m[39m
|
|
331
|
-
[33m[2m✓[22m[39m resolveTarget returns cloud mode with /api/v1 prefix [33m 895[2mms[22m[39m
|
|
332
|
-
[33m[2m✓[22m[39m resolveTarget returns self-host mode with /platform/v1 prefix [33m 894[2mms[22m[39m
|
|
333
|
-
[33m[2m✓[22m[39m targetSchemaRollback posts to /platform/v1 when linked [33m 981[2mms[22m[39m
|
|
334
|
-
[32m✓[39m tests/pull-utils.test.ts [2m([22m[2m49 tests[22m[2m)[22m[32m 11[2mms[22m[39m
|
|
335
|
-
[32m✓[39m tests/schema-sources.test.ts [2m([22m[2m5 tests[22m[2m)[22m[33m 1117[2mms[22m[39m
|
|
336
|
-
[33m[2m✓[22m[39m buildSchemaSourcesPayload includes manifest metadata [33m 524[2mms[22m[39m
|
|
337
|
-
[33m[2m✓[22m[39m restore overwrites modified local files [33m 543[2mms[22m[39m
|
|
338
|
-
[90mstderr[2m | tests/binary-cache-cloud-overrides.test.ts[2m > [22m[2misLinkedToCloudProject[2m > [22m[2mis true when .supatype/cloud.json has projectSlug
|
|
339
|
-
[22m[39m[supatype] Migrated .supatype/cloud.json → .supatype/link.json (legacy files kept; remove manually when ready).
|
|
340
|
-
|
|
341
|
-
[32m✓[39m tests/binary-cache-cloud-overrides.test.ts [2m([22m[2m11 tests[22m[2m)[22m[32m 22[2mms[22m[39m
|
|
342
|
-
[32m✓[39m tests/minisign.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m 13[2mms[22m[39m
|
|
343
|
-
[90mstdout[2m | tests/storage-provision.test.ts[2m > [22m[2mprovisionBuckets[2m > [22m[2mPOSTs each bucket to the storage API
|
|
344
|
-
[22m[39m[supatype] Storage bucket "photos" ready.
|
|
345
|
-
|
|
346
|
-
[90mstdout[2m | tests/storage-provision.test.ts[2m > [22m[2mprovisionBuckets[2m > [22m[2mPOSTs each bucket to the storage API
|
|
347
|
-
[22m[39m[supatype] Storage bucket "avatars" ready.
|
|
348
330
|
|
|
349
|
-
[32m✓[39m tests/
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
[32m✓[39m tests/tsx-runner.test.ts [2m([22m[2m7 tests[22m[2m)[22m[33m 2856[2mms[22m[39m
|
|
354
|
-
[33m[2m✓[22m[39m evaluates a simple expression and returns stdout [33m 351[2mms[22m[39m
|
|
355
|
-
[33m[2m✓[22m[39m evaluates TypeScript syntax (type annotations) [33m 369[2mms[22m[39m
|
|
356
|
-
[33m[2m✓[22m[39m can serialize a JSON object to stdout [33m 399[2mms[22m[39m
|
|
357
|
-
[33m[2m✓[22m[39m returns non-zero exit code on syntax error [33m 393[2mms[22m[39m
|
|
358
|
-
[33m[2m✓[22m[39m returns non-zero exit code on runtime error [33m 387[2mms[22m[39m
|
|
359
|
-
[33m[2m✓[22m[39m captures stderr separately from stdout [33m 402[2mms[22m[39m
|
|
360
|
-
[33m[2m✓[22m[39m runs a .ts file and returns its stdout [33m 551[2mms[22m[39m
|
|
361
|
-
[32m✓[39m tests/augmentation-generator.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 12[2mms[22m[39m
|
|
362
|
-
[32m✓[39m tests/keys.test.ts [2m([22m[2m11 tests[22m[2m)[22m[33m 16973[2mms[22m[39m
|
|
363
|
-
[33m[2m✓[22m[39m exits 0 with --secret [33m 1455[2mms[22m[39m
|
|
364
|
-
[33m[2m✓[22m[39m outputs ANON_KEY= line [33m 1401[2mms[22m[39m
|
|
365
|
-
[33m[2m✓[22m[39m outputs SERVICE_ROLE_KEY= line [33m 1425[2mms[22m[39m
|
|
366
|
-
[33m[2m✓[22m[39m ANON_KEY is a valid three-part JWT [33m 1343[2mms[22m[39m
|
|
367
|
-
[33m[2m✓[22m[39m SERVICE_ROLE_KEY payload has role: service_role [33m 1477[2mms[22m[39m
|
|
368
|
-
[33m[2m✓[22m[39m JWT has exp in the future [33m 1476[2mms[22m[39m
|
|
369
|
-
[33m[2m✓[22m[39m --exp-years changes the expiry window [33m 2796[2mms[22m[39m
|
|
370
|
-
[33m[2m✓[22m[39m reads JWT_SECRET from environment variable [33m 1383[2mms[22m[39m
|
|
371
|
-
[33m[2m✓[22m[39m reads JWT_SECRET from .env file [33m 1398[2mms[22m[39m
|
|
372
|
-
[33m[2m✓[22m[39m exits non-zero when no secret is available [33m 1399[2mms[22m[39m
|
|
373
|
-
[33m[2m✓[22m[39m keys --help shows --secret and --exp-years options [33m 1415[2mms[22m[39m
|
|
374
|
-
[32m✓[39m tests/engine-push-output.test.ts [2m([22m[2m7 tests[22m[2m)[22m[32m 7[2mms[22m[39m
|
|
375
|
-
[32m✓[39m tests/type-resolver.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 16[2mms[22m[39m
|
|
376
|
-
[32m✓[39m tests/command-chrome-wrap.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 7[2mms[22m[39m
|
|
377
|
-
[32m✓[39m tests/ensure-binary.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 10[2mms[22m[39m
|
|
331
|
+
[32m✓[39m tests/link.test.ts [2m([22m[2m4 tests[22m[2m)[22m[33m 2930[2mms[22m[39m
|
|
332
|
+
[33m[2m✓[22m[39m resolveTarget returns cloud mode with /api/v1 prefix [33m 1014[2mms[22m[39m
|
|
333
|
+
[33m[2m✓[22m[39m resolveTarget returns self-host mode with /platform/v1 prefix [33m 964[2mms[22m[39m
|
|
334
|
+
[33m[2m✓[22m[39m targetSchemaRollback posts to /platform/v1 when linked [33m 941[2mms[22m[39m
|
|
378
335
|
[90mstdout[2m | tests/admin-ensure.test.ts[2m > [22m[2minit admin seed in .env[2m > [22m[2mwrites SUPATYPE_ADMIN_* when scaffold options include credentials
|
|
379
336
|
[22m[39m created package.json
|
|
380
337
|
created supatype.config.ts
|
|
@@ -385,10 +342,55 @@
|
|
|
385
342
|
created public/.gitkeep
|
|
386
343
|
created .gitignore
|
|
387
344
|
|
|
388
|
-
[32m✓[39m tests/admin-ensure.test.ts [2m([22m[
|
|
389
|
-
[32m✓[39m tests/
|
|
345
|
+
[32m✓[39m tests/admin-ensure.test.ts [2m([22m[2m10 tests[22m[2m)[22m[32m 196[2mms[22m[39m
|
|
346
|
+
[32m✓[39m tests/pull-utils.test.ts [2m([22m[2m49 tests[22m[2m)[22m[32m 14[2mms[22m[39m
|
|
347
|
+
[32m✓[39m tests/schema-sources.test.ts [2m([22m[2m5 tests[22m[2m)[22m[33m 1185[2mms[22m[39m
|
|
348
|
+
[33m[2m✓[22m[39m buildSchemaSourcesPayload includes manifest metadata [33m 584[2mms[22m[39m
|
|
349
|
+
[33m[2m✓[22m[39m restore overwrites modified local files [33m 555[2mms[22m[39m
|
|
350
|
+
[90mstderr[2m | tests/binary-cache-cloud-overrides.test.ts[2m > [22m[2misLinkedToCloudProject[2m > [22m[2mis true when .supatype/cloud.json has projectSlug
|
|
351
|
+
[22m[39m[supatype] Migrated .supatype/cloud.json → .supatype/link.json (legacy files kept; remove manually when ready).
|
|
352
|
+
|
|
353
|
+
[32m✓[39m tests/binary-cache-cloud-overrides.test.ts [2m([22m[2m11 tests[22m[2m)[22m[32m 21[2mms[22m[39m
|
|
354
|
+
[32m✓[39m tests/minisign.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m 15[2mms[22m[39m
|
|
355
|
+
[90mstdout[2m | tests/storage-provision.test.ts[2m > [22m[2mprovisionBuckets[2m > [22m[2mPOSTs each bucket to the storage API
|
|
356
|
+
[22m[39m[supatype] Storage bucket "photos" ready.
|
|
357
|
+
|
|
358
|
+
[90mstdout[2m | tests/storage-provision.test.ts[2m > [22m[2mprovisionBuckets[2m > [22m[2mPOSTs each bucket to the storage API
|
|
359
|
+
[22m[39m[supatype] Storage bucket "avatars" ready.
|
|
360
|
+
|
|
361
|
+
[32m✓[39m tests/storage-provision.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 14[2mms[22m[39m
|
|
362
|
+
[32m✓[39m tests/cached-artifact-format.test.ts [2m([22m[2m7 tests[22m[2m)[22m[32m 10[2mms[22m[39m
|
|
363
|
+
[32m✓[39m tests/proxy-dev-app.test.ts [2m([22m[2m7 tests[22m[2m)[22m[32m 5[2mms[22m[39m
|
|
364
|
+
[32m✓[39m tests/init-dependency-versions.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 40[2mms[22m[39m
|
|
365
|
+
[32m✓[39m tests/keys.test.ts [2m([22m[2m11 tests[22m[2m)[22m[33m 17122[2mms[22m[39m
|
|
366
|
+
[33m[2m✓[22m[39m exits 0 with --secret [33m 1522[2mms[22m[39m
|
|
367
|
+
[33m[2m✓[22m[39m outputs ANON_KEY= line [33m 1453[2mms[22m[39m
|
|
368
|
+
[33m[2m✓[22m[39m outputs SERVICE_ROLE_KEY= line [33m 1442[2mms[22m[39m
|
|
369
|
+
[33m[2m✓[22m[39m ANON_KEY is a valid three-part JWT [33m 1502[2mms[22m[39m
|
|
370
|
+
[33m[2m✓[22m[39m SERVICE_ROLE_KEY payload has role: service_role [33m 1494[2mms[22m[39m
|
|
371
|
+
[33m[2m✓[22m[39m JWT has exp in the future [33m 1371[2mms[22m[39m
|
|
372
|
+
[33m[2m✓[22m[39m --exp-years changes the expiry window [33m 2798[2mms[22m[39m
|
|
373
|
+
[33m[2m✓[22m[39m reads JWT_SECRET from environment variable [33m 1349[2mms[22m[39m
|
|
374
|
+
[33m[2m✓[22m[39m reads JWT_SECRET from .env file [33m 1454[2mms[22m[39m
|
|
375
|
+
[33m[2m✓[22m[39m exits non-zero when no secret is available [33m 1351[2mms[22m[39m
|
|
376
|
+
[33m[2m✓[22m[39m keys --help shows --secret and --exp-years options [33m 1380[2mms[22m[39m
|
|
377
|
+
[32m✓[39m tests/augmentation-generator.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 11[2mms[22m[39m
|
|
378
|
+
[32m✓[39m tests/type-resolver.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 18[2mms[22m[39m
|
|
379
|
+
[32m✓[39m tests/engine-push-output.test.ts [2m([22m[2m7 tests[22m[2m)[22m[32m 5[2mms[22m[39m
|
|
380
|
+
[32m✓[39m tests/command-chrome-wrap.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 8[2mms[22m[39m
|
|
381
|
+
[32m✓[39m tests/tsx-runner.test.ts [2m([22m[2m7 tests[22m[2m)[22m[33m 2945[2mms[22m[39m
|
|
382
|
+
[33m[2m✓[22m[39m evaluates a simple expression and returns stdout [33m 425[2mms[22m[39m
|
|
383
|
+
[33m[2m✓[22m[39m evaluates TypeScript syntax (type annotations) [33m 342[2mms[22m[39m
|
|
384
|
+
[33m[2m✓[22m[39m can serialize a JSON object to stdout [33m 368[2mms[22m[39m
|
|
385
|
+
[33m[2m✓[22m[39m returns non-zero exit code on syntax error [33m 437[2mms[22m[39m
|
|
386
|
+
[33m[2m✓[22m[39m returns non-zero exit code on runtime error [33m 357[2mms[22m[39m
|
|
387
|
+
[33m[2m✓[22m[39m captures stderr separately from stdout [33m 417[2mms[22m[39m
|
|
388
|
+
[33m[2m✓[22m[39m runs a .ts file and returns its stdout [33m 593[2mms[22m[39m
|
|
389
|
+
[32m✓[39m tests/ensure-binary.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 11[2mms[22m[39m
|
|
390
|
+
[32m✓[39m tests/init-project-detect.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 12[2mms[22m[39m
|
|
391
|
+
[32m✓[39m tests/ui-messages.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m 8[2mms[22m[39m
|
|
390
392
|
[32m✓[39m tests/required-host-components.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 7[2mms[22m[39m
|
|
391
|
-
[32m✓[39m tests/normalize-admin-config.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m
|
|
393
|
+
[32m✓[39m tests/normalize-admin-config.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 5[2mms[22m[39m
|
|
392
394
|
[90mstdout[2m | tests/app-command.test.ts[2m > [22m[2msupatype app add --static[2m > [22m[2msets app.mode=static and static_dir in supatype.config.ts
|
|
393
395
|
[22m[39m created package.json
|
|
394
396
|
created supatype.config.ts
|
|
@@ -399,11 +401,10 @@
|
|
|
399
401
|
created public/.gitkeep
|
|
400
402
|
created .gitignore
|
|
401
403
|
|
|
402
|
-
[32m✓[39m tests/dev-session-lock.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m
|
|
403
|
-
[32m✓[39m tests/ui-confirm.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m
|
|
404
|
+
[32m✓[39m tests/dev-session-lock.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 6[2mms[22m[39m
|
|
405
|
+
[32m✓[39m tests/ui-confirm.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 8[2mms[22m[39m
|
|
404
406
|
[32m✓[39m tests/docker-postgres.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m 5[2mms[22m[39m
|
|
405
|
-
[32m✓[39m tests/binary-download-lock.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m
|
|
406
|
-
[32m✓[39m tests/dev-ports.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 6[2mms[22m[39m
|
|
407
|
+
[32m✓[39m tests/binary-download-lock.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 8[2mms[22m[39m
|
|
407
408
|
[90mstdout[2m | tests/app-command.test.ts[2m > [22m[2msupatype app add --static[2m > [22m[2mcreates the static directory when missing
|
|
408
409
|
[22m[39m created package.json
|
|
409
410
|
created supatype.config.ts
|
|
@@ -414,41 +415,43 @@
|
|
|
414
415
|
created public/.gitkeep
|
|
415
416
|
created .gitignore
|
|
416
417
|
|
|
417
|
-
[32m✓[39m tests/
|
|
418
|
-
[32m✓[39m tests/
|
|
419
|
-
|
|
420
|
-
[33m[2m✓[22m[39m --
|
|
421
|
-
[33m[2m✓[22m[39m --
|
|
422
|
-
[33m[2m✓[22m[39m
|
|
423
|
-
[33m[2m✓[22m[39m
|
|
424
|
-
[33m[2m✓[22m[39m
|
|
425
|
-
[33m[2m✓[22m[39m
|
|
426
|
-
[33m[2m✓[22m[39m
|
|
427
|
-
[33m[2m✓[22m[39m
|
|
428
|
-
[33m[2m✓[22m[39m
|
|
429
|
-
[33m[2m✓[22m[39m
|
|
430
|
-
[33m[2m✓[22m[39m
|
|
431
|
-
[33m[2m✓[22m[39m app --help
|
|
432
|
-
[33m[2m✓[22m[39m
|
|
433
|
-
[33m[2m✓[22m[39m self-host --help shows compose
|
|
434
|
-
[33m[2m✓[22m[39m
|
|
435
|
-
|
|
436
|
-
[32m✓[39m tests/
|
|
418
|
+
[32m✓[39m tests/dev-ports.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 7[2mms[22m[39m
|
|
419
|
+
[32m✓[39m tests/cli-help.test.ts [2m([22m[2m16 tests[22m[2m)[22m[33m 22108[2mms[22m[39m
|
|
420
|
+
[33m[2m✓[22m[39m --help lists all top-level commands [33m 1433[2mms[22m[39m
|
|
421
|
+
[33m[2m✓[22m[39m --version prints package.json version [33m 1339[2mms[22m[39m
|
|
422
|
+
[33m[2m✓[22m[39m self-update --help describes the command [33m 1410[2mms[22m[39m
|
|
423
|
+
[33m[2m✓[22m[39m init --help describes the init command [33m 1366[2mms[22m[39m
|
|
424
|
+
[33m[2m✓[22m[39m push --help describes the push command and --yes flag [33m 1476[2mms[22m[39m
|
|
425
|
+
[33m[2m✓[22m[39m diff --help describes the diff command [33m 1376[2mms[22m[39m
|
|
426
|
+
[33m[2m✓[22m[39m pull --help describes scaffold pull command [33m 1374[2mms[22m[39m
|
|
427
|
+
[33m[2m✓[22m[39m doctor --help describes drift report command [33m 1246[2mms[22m[39m
|
|
428
|
+
[33m[2m✓[22m[39m introspect --help describes database introspection command [33m 1412[2mms[22m[39m
|
|
429
|
+
[33m[2m✓[22m[39m adopt --help describes adoption ceremony command [33m 1344[2mms[22m[39m
|
|
430
|
+
[33m[2m✓[22m[39m reset --help shows --yes flag [33m 1291[2mms[22m[39m
|
|
431
|
+
[33m[2m✓[22m[39m app --help describes the app command with add/remove subcommands [33m 1455[2mms[22m[39m
|
|
432
|
+
[33m[2m✓[22m[39m app add --help shows --static and --port options [33m 1401[2mms[22m[39m
|
|
433
|
+
[33m[2m✓[22m[39m self-host --help shows compose only (legacy commands hidden) [33m 1380[2mms[22m[39m
|
|
434
|
+
[33m[2m✓[22m[39m self-host compose --help shows compose subcommands [33m 1467[2mms[22m[39m
|
|
435
|
+
[33m[2m✓[22m[39m unknown command exits non-zero [33m 1331[2mms[22m[39m
|
|
436
|
+
[32m✓[39m tests/dev-ready-panel.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 4[2mms[22m[39m
|
|
437
|
+
[32m✓[39m tests/studio-admin-roles.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 4[2mms[22m[39m
|
|
438
|
+
[32m✓[39m tests/release-pins.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 4[2mms[22m[39m
|
|
439
|
+
[32m✓[39m tests/seed-discover.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 13[2mms[22m[39m
|
|
440
|
+
[32m✓[39m tests/app-command.test.ts [2m([22m[2m2 tests[22m[2m)[22m[33m 2875[2mms[22m[39m
|
|
441
|
+
[33m[2m✓[22m[39m sets app.mode=static and static_dir in supatype.config.ts [33m 1454[2mms[22m[39m
|
|
442
|
+
[33m[2m✓[22m[39m creates the static directory when missing [33m 1419[2mms[22m[39m
|
|
437
443
|
[32m✓[39m tests/ensure-dev-api-config.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 5[2mms[22m[39m
|
|
438
|
-
[32m✓[39m tests/app-command.test.ts [2m([22m[2m2 tests[22m[2m)[22m[33m 2894[2mms[22m[39m
|
|
439
|
-
[33m[2m✓[22m[39m sets app.mode=static and static_dir in supatype.config.ts [33m 1541[2mms[22m[39m
|
|
440
|
-
[33m[2m✓[22m[39m creates the static directory when missing [33m 1350[2mms[22m[39m
|
|
441
444
|
[32m✓[39m tests/rest-cache-admin.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 48[2mms[22m[39m
|
|
442
|
-
[32m✓[39m tests/resolve-api-url.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 4[2mms[22m[39m
|
|
443
445
|
[32m✓[39m tests/init-package-json.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 4[2mms[22m[39m
|
|
444
|
-
[32m✓[39m tests/
|
|
446
|
+
[32m✓[39m tests/resolve-api-url.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 4[2mms[22m[39m
|
|
445
447
|
[32m✓[39m tests/pg-spawn-env.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 5[2mms[22m[39m
|
|
446
|
-
[32m✓[39m tests/
|
|
447
|
-
[32m✓[39m tests/
|
|
448
|
-
[32m✓[39m tests/
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
[2m
|
|
452
|
-
[2m
|
|
453
|
-
[2m
|
|
448
|
+
[32m✓[39m tests/migrate-from-v1.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 18[2mms[22m[39m
|
|
449
|
+
[32m✓[39m tests/cli-package-version.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 3[2mms[22m[39m
|
|
450
|
+
[32m✓[39m tests/postgres-archive-tag.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 2[2mms[22m[39m
|
|
451
|
+
[32m✓[39m tests/stdin-after-ink.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 3[2mms[22m[39m
|
|
452
|
+
|
|
453
|
+
[2m Test Files [22m [1m[32m48 passed[39m[22m[90m (48)[39m
|
|
454
|
+
[2m Tests [22m [1m[32m364 passed[39m[22m[90m (364)[39m
|
|
455
|
+
[2m Start at [22m 07:44:14
|
|
456
|
+
[2m Duration [22m 28.86s[2m (transform 3.82s, setup 0ms, import 21.76s, tests 55.51s, environment 9ms)[22m
|
|
454
457
|
|
package/dist/commands/admin.d.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import type { Command } from "commander";
|
|
2
|
+
import type { QueryResult } from "pg";
|
|
2
3
|
import { type SupatypeProjectConfig } from "../project-config.js";
|
|
3
4
|
export declare const ADMIN_EMAIL_ENV = "SUPATYPE_ADMIN_EMAIL";
|
|
4
5
|
export declare const ADMIN_PASSWORD_ENV = "SUPATYPE_ADMIN_PASSWORD";
|
|
6
|
+
/** GoTrue scopes users to the nil instance id in single-tenant/self-host mode. */
|
|
7
|
+
export declare const GOTRUE_NIL_INSTANCE_ID = "00000000-0000-0000-0000-000000000000";
|
|
8
|
+
/** Audience claim used by GoTrue when looking up users (matches GOTRUE_JWT_AUD in compose). */
|
|
9
|
+
export declare function gotrueJwtAud(cwd: string): string;
|
|
10
|
+
type DbQuery = (sql: string, params?: unknown[]) => Promise<QueryResult>;
|
|
11
|
+
type AuthConfirmedColumn = "email_confirmed_at" | "confirmed_at";
|
|
12
|
+
/** Prefer GoTrue's column when migrated; fall back to postgres init `confirmed_at`. */
|
|
13
|
+
export declare function resolveAuthConfirmedAtColumn(query: DbQuery): Promise<AuthConfirmedColumn>;
|
|
5
14
|
export interface EnsureFirstAdminOptions {
|
|
6
15
|
email?: string;
|
|
7
16
|
password?: string;
|
|
@@ -28,4 +37,7 @@ export declare function ensureFirstAdminUser(connection: string, options?: Ensur
|
|
|
28
37
|
export declare function ensureFirstAdminUserForProject(cwd: string, config: SupatypeProjectConfig, options?: EnsureFirstAdminOptions): Promise<void>;
|
|
29
38
|
export declare function clearAdminSeedPassword(cwd: string): void;
|
|
30
39
|
export declare function hashPasswordForAuth(password: string): Promise<string>;
|
|
40
|
+
/** Postgres password for compose `exec psql` (db is not published to the host). */
|
|
41
|
+
export declare function composePostgresPassword(cwd: string): string;
|
|
42
|
+
export {};
|
|
31
43
|
//# sourceMappingURL=admin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/commands/admin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/commands/admin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKxC,OAAO,KAAK,EAAQ,WAAW,EAAE,MAAM,IAAI,CAAA;AAE3C,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,sBAAsB,CAAA;AAa7B,eAAO,MAAM,eAAe,yBAAyB,CAAA;AACrD,eAAO,MAAM,kBAAkB,4BAA4B,CAAA;AAI3D,kFAAkF;AAClF,eAAO,MAAM,sBAAsB,yCAAyC,CAAA;AAE5E,+FAA+F;AAC/F,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,KAAK,OAAO,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,WAAW,CAAC,CAAA;AACxE,KAAK,mBAAmB,GAAG,oBAAoB,GAAG,cAAc,CAAA;AAEhE,uFAAuF;AACvF,wBAAsB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAc/F;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAA;CACnD;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA+KpD;AAED,2CAA2C;AAC3C,eAAO,MAAM,oBAAoB,6BAAuB,CAAA;AAExD;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,IAAI,CAAC,CAaf;AAED;;;GAGG;AACH,wBAAsB,8BAA8B,CAClD,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,qBAAqB,EAC7B,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,IAAI,CAAC,CA2Bf;AA2FD,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAExD;AAED,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE3E;AAsHD,mFAAmF;AACnF,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3D"}
|
package/dist/commands/admin.js
CHANGED
|
@@ -10,6 +10,8 @@ import { loadConfig } from "../config.js";
|
|
|
10
10
|
import { connectionString, resolveRuntimeProvider, } from "../project-config.js";
|
|
11
11
|
import { readEnvValue, upsertEnvFile } from "../env-file.js";
|
|
12
12
|
import { hasEngineOverride } from "../binary-cache.js";
|
|
13
|
+
import { readDevSessionLock } from "../dev-session-lock.js";
|
|
14
|
+
import { composeProjectName } from "../self-host-compose.js";
|
|
13
15
|
import { confirm as uiConfirm } from "../ui/confirm.js";
|
|
14
16
|
import { error, info, plain } from "../ui/messages.js";
|
|
15
17
|
import { promptPassword, promptText } from "../ui/prompts.js";
|
|
@@ -18,6 +20,27 @@ import { getActiveDevSession, } from "../dev-session.js";
|
|
|
18
20
|
export const ADMIN_EMAIL_ENV = "SUPATYPE_ADMIN_EMAIL";
|
|
19
21
|
export const ADMIN_PASSWORD_ENV = "SUPATYPE_ADMIN_PASSWORD";
|
|
20
22
|
const BCRYPT_ROUNDS = 10;
|
|
23
|
+
/** GoTrue scopes users to the nil instance id in single-tenant/self-host mode. */
|
|
24
|
+
export const GOTRUE_NIL_INSTANCE_ID = "00000000-0000-0000-0000-000000000000";
|
|
25
|
+
/** Audience claim used by GoTrue when looking up users (matches GOTRUE_JWT_AUD in compose). */
|
|
26
|
+
export function gotrueJwtAud(cwd) {
|
|
27
|
+
return readEnvValue(cwd, "GOTRUE_JWT_AUD", "authenticated");
|
|
28
|
+
}
|
|
29
|
+
/** Prefer GoTrue's column when migrated; fall back to postgres init `confirmed_at`. */
|
|
30
|
+
export async function resolveAuthConfirmedAtColumn(query) {
|
|
31
|
+
const result = await query(`SELECT column_name
|
|
32
|
+
FROM information_schema.columns
|
|
33
|
+
WHERE table_schema = 'auth'
|
|
34
|
+
AND table_name = 'users'
|
|
35
|
+
AND column_name IN ('email_confirmed_at', 'confirmed_at')
|
|
36
|
+
ORDER BY CASE column_name WHEN 'email_confirmed_at' THEN 0 ELSE 1 END
|
|
37
|
+
LIMIT 1`);
|
|
38
|
+
const row = result.rows[0];
|
|
39
|
+
const name = row?.column_name ?? row?.value;
|
|
40
|
+
if (name === "email_confirmed_at" || name === "confirmed_at")
|
|
41
|
+
return name;
|
|
42
|
+
return "confirmed_at";
|
|
43
|
+
}
|
|
21
44
|
export function registerAdmin(program) {
|
|
22
45
|
const adminCmd = program
|
|
23
46
|
.command("admin")
|
|
@@ -45,11 +68,22 @@ export function registerAdmin(program) {
|
|
|
45
68
|
}
|
|
46
69
|
const role = opts.role;
|
|
47
70
|
info(`Creating admin user: ${email} (role: ${role})...`);
|
|
48
|
-
const
|
|
49
|
-
const pool = new pg.Pool({ connectionString: connection, max: 2 });
|
|
71
|
+
const compose = opts.connection === undefined ? resolveDockerComposeContext(cwd, config) : null;
|
|
50
72
|
try {
|
|
51
|
-
|
|
52
|
-
|
|
73
|
+
if (compose) {
|
|
74
|
+
await createAdminUser((sql, params) => composeExecQuery(cwd, compose, sql, params), email, password, role, { cwd });
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
const pg = await importPg();
|
|
78
|
+
const pool = new pg.Pool({ connectionString: connection, max: 2 });
|
|
79
|
+
try {
|
|
80
|
+
await ensureAuthUsersTable(pool);
|
|
81
|
+
await createAdminUser(pool, email, password, role, { cwd });
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
await pool.end();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
53
87
|
info("This user can now log in to the admin panel at /admin");
|
|
54
88
|
}
|
|
55
89
|
catch (err) {
|
|
@@ -57,9 +91,6 @@ export function registerAdmin(program) {
|
|
|
57
91
|
error(`Failed to create admin user: ${message}`);
|
|
58
92
|
process.exit(1);
|
|
59
93
|
}
|
|
60
|
-
finally {
|
|
61
|
-
await pool.end();
|
|
62
|
-
}
|
|
63
94
|
});
|
|
64
95
|
adminCmd
|
|
65
96
|
.command("set-role")
|
|
@@ -170,8 +201,9 @@ export async function ensureFirstAdminUserForProject(cwd, config, options = {})
|
|
|
170
201
|
try {
|
|
171
202
|
await ensureFirstAdminWithQuery((sql, params) => composeExecQuery(root, merged.compose, sql, params), merged);
|
|
172
203
|
}
|
|
173
|
-
catch {
|
|
174
|
-
|
|
204
|
+
catch (err) {
|
|
205
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
206
|
+
error(`Could not ensure first admin user: ${message}`);
|
|
175
207
|
}
|
|
176
208
|
return;
|
|
177
209
|
}
|
|
@@ -196,7 +228,10 @@ async function ensureFirstAdminWithQuery(query, options) {
|
|
|
196
228
|
}
|
|
197
229
|
const role = options.role ?? "admin";
|
|
198
230
|
try {
|
|
199
|
-
await createAdminUser(query, credentials.email, credentials.password, role, {
|
|
231
|
+
await createAdminUser(query, credentials.email, credentials.password, role, {
|
|
232
|
+
quiet: true,
|
|
233
|
+
cwd,
|
|
234
|
+
});
|
|
200
235
|
}
|
|
201
236
|
catch (err) {
|
|
202
237
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -260,9 +295,12 @@ async function createAdminUser(db, email, password, role, opts = {}) {
|
|
|
260
295
|
? (sql, params) => db.query(sql, params)
|
|
261
296
|
: db;
|
|
262
297
|
const normalized = email.toLowerCase();
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
|
|
298
|
+
const aud = opts.aud ?? (opts.cwd ? gotrueJwtAud(opts.cwd) : "authenticated");
|
|
299
|
+
const existing = await query(`SELECT id FROM auth.users
|
|
300
|
+
WHERE instance_id = $1::uuid
|
|
301
|
+
AND LOWER(email) = $2
|
|
302
|
+
AND aud = $3
|
|
303
|
+
AND is_sso_user = false`, [GOTRUE_NIL_INSTANCE_ID, normalized, aud]);
|
|
266
304
|
if (existing.rows.length > 0) {
|
|
267
305
|
throw new Error(`User with email "${email}" already exists.`);
|
|
268
306
|
}
|
|
@@ -273,15 +311,24 @@ async function createAdminUser(db, email, password, role, opts = {}) {
|
|
|
273
311
|
providers: ["email"],
|
|
274
312
|
});
|
|
275
313
|
const userMetadata = JSON.stringify({});
|
|
314
|
+
const confirmedCol = await resolveAuthConfirmedAtColumn(query);
|
|
276
315
|
const result = await query(`INSERT INTO auth.users (
|
|
277
|
-
|
|
316
|
+
instance_id, id, aud, role, email, encrypted_password,
|
|
278
317
|
raw_app_meta_data, raw_user_meta_data,
|
|
279
|
-
|
|
318
|
+
${confirmedCol},
|
|
319
|
+
confirmation_token, recovery_token,
|
|
320
|
+
email_change_token_new, email_change, email_change_token_current,
|
|
321
|
+
phone_change, phone_change_token, reauthentication_token,
|
|
322
|
+
is_sso_user, is_anonymous,
|
|
323
|
+
created_at, updated_at
|
|
280
324
|
) VALUES (
|
|
281
|
-
gen_random_uuid(), $
|
|
282
|
-
$
|
|
283
|
-
now(),
|
|
284
|
-
|
|
325
|
+
$1::uuid, gen_random_uuid(), $2, 'authenticated', $3, $4,
|
|
326
|
+
$5::jsonb, $6::jsonb,
|
|
327
|
+
now(),
|
|
328
|
+
'', '', '', '', '', '', '', '',
|
|
329
|
+
false, false,
|
|
330
|
+
now(), now()
|
|
331
|
+
) RETURNING id, email`, [GOTRUE_NIL_INSTANCE_ID, aud, normalized, passwordHash, appMetadata, userMetadata]);
|
|
285
332
|
const user = result.rows[0];
|
|
286
333
|
if (!opts.quiet) {
|
|
287
334
|
info("Admin user created successfully.");
|
|
@@ -297,7 +344,7 @@ async function ensureAuthUsersTable(pool) {
|
|
|
297
344
|
|
|
298
345
|
CREATE TABLE IF NOT EXISTS auth.users (
|
|
299
346
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
300
|
-
instance_id UUID,
|
|
347
|
+
instance_id UUID DEFAULT '00000000-0000-0000-0000-000000000000'::uuid,
|
|
301
348
|
aud TEXT DEFAULT 'authenticated',
|
|
302
349
|
role TEXT DEFAULT 'authenticated',
|
|
303
350
|
email TEXT UNIQUE,
|
|
@@ -310,7 +357,13 @@ async function ensureAuthUsersTable(pool) {
|
|
|
310
357
|
confirmation_token TEXT DEFAULT '',
|
|
311
358
|
recovery_token TEXT DEFAULT '',
|
|
312
359
|
email_change_token_new TEXT DEFAULT '',
|
|
313
|
-
|
|
360
|
+
email_change_token_current TEXT DEFAULT '',
|
|
361
|
+
email_change TEXT DEFAULT '',
|
|
362
|
+
phone_change TEXT DEFAULT '',
|
|
363
|
+
phone_change_token TEXT DEFAULT '',
|
|
364
|
+
reauthentication_token TEXT DEFAULT '',
|
|
365
|
+
is_sso_user BOOLEAN NOT NULL DEFAULT false,
|
|
366
|
+
is_anonymous BOOLEAN NOT NULL DEFAULT false
|
|
314
367
|
);
|
|
315
368
|
`);
|
|
316
369
|
}
|
|
@@ -328,9 +381,30 @@ async function hasAdminUsers(query) {
|
|
|
328
381
|
const count = adminCount.rows[0]?.count ?? 0;
|
|
329
382
|
return count > 0;
|
|
330
383
|
}
|
|
384
|
+
/** Postgres password for compose `exec psql` (db is not published to the host). */
|
|
385
|
+
export function composePostgresPassword(cwd) {
|
|
386
|
+
return readEnvValue(cwd, "POSTGRES_PASSWORD", "postgres");
|
|
387
|
+
}
|
|
388
|
+
function resolveDockerComposeContext(cwd, config) {
|
|
389
|
+
if (resolveRuntimeProvider(config) !== "docker" || hasEngineOverride(config)) {
|
|
390
|
+
return null;
|
|
391
|
+
}
|
|
392
|
+
const session = readDevSessionLock(cwd);
|
|
393
|
+
if (session?.composeProject && session.composePath && existsSync(session.composePath)) {
|
|
394
|
+
return { project: session.composeProject, composePath: session.composePath };
|
|
395
|
+
}
|
|
396
|
+
const composePath = resolve(cwd, ".supatype/self-host/docker-compose.yml");
|
|
397
|
+
if (!existsSync(composePath))
|
|
398
|
+
return null;
|
|
399
|
+
return {
|
|
400
|
+
project: composeProjectName(config.project?.name ?? "project"),
|
|
401
|
+
composePath,
|
|
402
|
+
};
|
|
403
|
+
}
|
|
331
404
|
function composeExecQuery(cwd, compose, sql, params = []) {
|
|
332
405
|
const db = readEnvValue(cwd, "POSTGRES_DB", "supatype");
|
|
333
406
|
const user = readEnvValue(cwd, "POSTGRES_USER", "supatype_admin");
|
|
407
|
+
const pgPassword = composePostgresPassword(cwd);
|
|
334
408
|
const envFile = join(cwd, ".env");
|
|
335
409
|
const composeDir = dirname(compose.composePath);
|
|
336
410
|
const args = [
|
|
@@ -345,7 +419,7 @@ function composeExecQuery(cwd, compose, sql, params = []) {
|
|
|
345
419
|
if (existsSync(envFile))
|
|
346
420
|
args.push("--env-file", envFile);
|
|
347
421
|
if (params.length === 0) {
|
|
348
|
-
args.push("exec", "-T", "db", "psql", "-U", user, "-d", db, "-tAc", sql);
|
|
422
|
+
args.push("exec", "-T", "-e", `PGPASSWORD=${pgPassword}`, "db", "psql", "-U", user, "-d", db, "-tAc", sql);
|
|
349
423
|
const result = spawnSync("docker", args, { cwd: composeDir, encoding: "utf8" });
|
|
350
424
|
if (result.status !== 0) {
|
|
351
425
|
throw new Error((result.stderr ?? result.stdout ?? "compose psql failed").trim());
|
|
@@ -368,7 +442,7 @@ function composeExecQuery(cwd, compose, sql, params = []) {
|
|
|
368
442
|
fields: [],
|
|
369
443
|
});
|
|
370
444
|
}
|
|
371
|
-
args.push("exec", "-T", "db", "psql", "-U", user, "-d", db, "-v", "ON_ERROR_STOP=1", "-c", interpolateSql(sql, params));
|
|
445
|
+
args.push("exec", "-T", "-e", `PGPASSWORD=${pgPassword}`, "db", "psql", "-U", user, "-d", db, "-v", "ON_ERROR_STOP=1", "-c", interpolateSql(sql, params));
|
|
372
446
|
const result = spawnSync("docker", args, { cwd: composeDir, encoding: "utf8" });
|
|
373
447
|
if (result.status !== 0) {
|
|
374
448
|
throw new Error((result.stderr ?? result.stdout ?? "compose psql failed").trim());
|