@supatype/cli 0.1.2 → 0.1.3
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 +108 -105
- 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/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/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/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.3 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.3 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[2m34 tests[22m[2m)[22m[32m
|
|
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[2m34 tests[22m[2m)[22m[32m 211[2mms[22m[39m
|
|
9
|
+
[32m✓[39m tests/runtime-contract.test.ts [2m([22m[2m41 tests[22m[2m)[22m[32m 141[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,9 @@
|
|
|
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 74[2mms[22m[39m
|
|
295
|
+
|
|
296
|
+
[32m✓[39m tests/dev-ui.test.ts [2m([22m[2m21 tests[22m[2m)[22m[32m 106[2mms[22m[39m
|
|
295
297
|
[90mstdout[2m | tests/docker-runtime.test.ts[2m > [22m[2mrequireDockerDaemon[2m > [22m[2mexits when the daemon is unavailable
|
|
296
298
|
[22m[39m
|
|
297
299
|
Start the Docker daemon (e.g. sudo systemctl start docker), then try again.
|
|
@@ -300,95 +302,95 @@
|
|
|
300
302
|
|
|
301
303
|
docker: daemon down
|
|
302
304
|
|
|
303
|
-
[32m✓[39m tests/docker-runtime.test.ts [2m([22m[2m10 tests[22m[2m)[22m[32m 13[2mms[22m[39m
|
|
304
|
-
|
|
305
|
-
[32m✓[39m tests/dev-ui.test.ts [2m([22m[2m21 tests[22m[2m)[22m[32m 102[2mms[22m[39m
|
|
306
305
|
|
|
307
306
|
[supatype] Shutting down…
|
|
308
|
-
[32m✓[39m tests/
|
|
309
|
-
|
|
310
|
-
[33m[2m✓[22m[39m
|
|
311
|
-
[33m[2m✓[22m[39m
|
|
312
|
-
[33m[2m✓[22m[39m loads
|
|
313
|
-
[33m[2m✓[22m[39m
|
|
314
|
-
[33m[2m✓[22m[39m
|
|
315
|
-
[33m[2m✓[22m[39m
|
|
316
|
-
|
|
307
|
+
[32m✓[39m tests/docker-runtime.test.ts [2m([22m[2m10 tests[22m[2m)[22m[32m 13[2mms[22m[39m
|
|
308
|
+
[32m✓[39m tests/config.test.ts [2m([22m[2m19 tests[22m[2m)[22m[33m 5120[2mms[22m[39m
|
|
309
|
+
[33m[2m✓[22m[39m loads a valid supatype.config.ts (plain export default, no package imports) [33m 591[2mms[22m[39m
|
|
310
|
+
[33m[2m✓[22m[39m normalizes shorthand schema string to { path, pg_schema } [33m 533[2mms[22m[39m
|
|
311
|
+
[33m[2m✓[22m[39m loads a supatype.config.js (plain ESM) [33m 533[2mms[22m[39m
|
|
312
|
+
[33m[2m✓[22m[39m loads config without a versions section (latest by default) [33m 451[2mms[22m[39m
|
|
313
|
+
[33m[2m✓[22m[39m prefers supatype.config.ts over supatype.config.js when both exist [33m 491[2mms[22m[39m
|
|
314
|
+
[33m[2m✓[22m[39m supports optional output field in config [33m 552[2mms[22m[39m
|
|
315
|
+
[33m[2m✓[22m[39m merges supatype.local.config.ts over base [33m 1019[2mms[22m[39m
|
|
316
|
+
[33m[2m✓[22m[39m loads defineConfig import before @supatype/cli is installed (init scaffold) [33m 938[2mms[22m[39m
|
|
317
|
+
[32m✓[39m tests/command-chrome-coverage.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 14[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
|
|
319
321
|
created supatype.config.ts
|
|
320
322
|
created schema/index.ts
|
|
323
|
+
[22m[39m[supatype] Migrated .supatype/cloud.json → .supatype/link.json (legacy files kept; remove manually when ready).
|
|
321
324
|
created .env
|
|
322
325
|
created seed.ts
|
|
323
326
|
created seeds/.gitkeep
|
|
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
|
|
|
330
|
-
[32m✓[39m tests/link.test.ts [2m([22m[2m4 tests[22m[2m)[22m[33m
|
|
331
|
-
[33m[2m✓[22m[39m resolveTarget returns cloud mode with /api/v1 prefix [33m
|
|
332
|
-
[33m[2m✓[22m[39m resolveTarget returns self-host mode with /platform/v1 prefix [33m
|
|
333
|
-
[33m[2m✓[22m[39m targetSchemaRollback posts to /platform/v1 when linked [33m
|
|
331
|
+
[32m✓[39m tests/link.test.ts [2m([22m[2m4 tests[22m[2m)[22m[33m 2602[2mms[22m[39m
|
|
332
|
+
[33m[2m✓[22m[39m resolveTarget returns cloud mode with /api/v1 prefix [33m 909[2mms[22m[39m
|
|
333
|
+
[33m[2m✓[22m[39m resolveTarget returns self-host mode with /platform/v1 prefix [33m 849[2mms[22m[39m
|
|
334
|
+
[33m[2m✓[22m[39m targetSchemaRollback posts to /platform/v1 when linked [33m 834[2mms[22m[39m
|
|
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
|
|
336
|
+
[22m[39m created package.json
|
|
337
|
+
created supatype.config.ts
|
|
338
|
+
created schema/index.ts
|
|
339
|
+
created .env
|
|
340
|
+
created seed.ts
|
|
341
|
+
created seeds/.gitkeep
|
|
342
|
+
created public/.gitkeep
|
|
343
|
+
created .gitignore
|
|
344
|
+
|
|
345
|
+
[32m✓[39m tests/admin-ensure.test.ts [2m([22m[2m10 tests[22m[2m)[22m[32m 158[2mms[22m[39m
|
|
334
346
|
[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
|
|
336
|
-
[33m[2m✓[22m[39m buildSchemaSourcesPayload includes manifest metadata [33m
|
|
337
|
-
[33m[2m✓[22m[39m restore overwrites modified local files [33m
|
|
347
|
+
[32m✓[39m tests/schema-sources.test.ts [2m([22m[2m5 tests[22m[2m)[22m[33m 1160[2mms[22m[39m
|
|
348
|
+
[33m[2m✓[22m[39m buildSchemaSourcesPayload includes manifest metadata [33m 503[2mms[22m[39m
|
|
349
|
+
[33m[2m✓[22m[39m restore overwrites modified local files [33m 608[2mms[22m[39m
|
|
338
350
|
[90mstderr[2m | tests/binary-cache-cloud-overrides.test.ts[2m > [22m[2misLinkedToCloudProject[2m > [22m[2mis true when .supatype/cloud.json has projectSlug
|
|
339
351
|
[22m[39m[supatype] Migrated .supatype/cloud.json → .supatype/link.json (legacy files kept; remove manually when ready).
|
|
340
352
|
|
|
341
|
-
[32m✓[39m tests/binary-cache-cloud-overrides.test.ts [2m([22m[2m11 tests[22m[2m)[22m[32m
|
|
342
|
-
[32m✓[39m tests/minisign.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m
|
|
353
|
+
[32m✓[39m tests/binary-cache-cloud-overrides.test.ts [2m([22m[2m11 tests[22m[2m)[22m[32m 19[2mms[22m[39m
|
|
354
|
+
[32m✓[39m tests/minisign.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m 14[2mms[22m[39m
|
|
343
355
|
[90mstdout[2m | tests/storage-provision.test.ts[2m > [22m[2mprovisionBuckets[2m > [22m[2mPOSTs each bucket to the storage API
|
|
344
356
|
[22m[39m[supatype] Storage bucket "photos" ready.
|
|
345
357
|
|
|
346
358
|
[90mstdout[2m | tests/storage-provision.test.ts[2m > [22m[2mprovisionBuckets[2m > [22m[2mPOSTs each bucket to the storage API
|
|
347
359
|
[22m[39m[supatype] Storage bucket "avatars" ready.
|
|
348
360
|
|
|
349
|
-
[32m✓[39m tests/storage-provision.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m
|
|
350
|
-
[32m✓[39m tests/cached-artifact-format.test.ts [2m([22m[2m7 tests[22m[2m)[22m[32m
|
|
351
|
-
[32m✓[39m tests/proxy-dev-app.test.ts [2m([22m[2m7 tests[22m[2m)[22m[32m
|
|
352
|
-
[32m✓[39m tests/init-dependency-versions.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m
|
|
353
|
-
[32m✓[39m tests/
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
[33m[2m✓[22m[39m exits
|
|
364
|
-
[33m[2m✓[22m[39m
|
|
365
|
-
|
|
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
|
|
361
|
+
[32m✓[39m tests/storage-provision.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 11[2mms[22m[39m
|
|
362
|
+
[32m✓[39m tests/cached-artifact-format.test.ts [2m([22m[2m7 tests[22m[2m)[22m[32m 24[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 39[2mms[22m[39m
|
|
365
|
+
[32m✓[39m tests/keys.test.ts [2m([22m[2m11 tests[22m[2m)[22m[33m 16241[2mms[22m[39m
|
|
366
|
+
[33m[2m✓[22m[39m exits 0 with --secret [33m 1443[2mms[22m[39m
|
|
367
|
+
[33m[2m✓[22m[39m outputs ANON_KEY= line [33m 1398[2mms[22m[39m
|
|
368
|
+
[33m[2m✓[22m[39m outputs SERVICE_ROLE_KEY= line [33m 1314[2mms[22m[39m
|
|
369
|
+
[33m[2m✓[22m[39m ANON_KEY is a valid three-part JWT [33m 1369[2mms[22m[39m
|
|
370
|
+
[33m[2m✓[22m[39m SERVICE_ROLE_KEY payload has role: service_role [33m 1397[2mms[22m[39m
|
|
371
|
+
[33m[2m✓[22m[39m JWT has exp in the future [33m 1411[2mms[22m[39m
|
|
372
|
+
[33m[2m✓[22m[39m --exp-years changes the expiry window [33m 2752[2mms[22m[39m
|
|
373
|
+
[33m[2m✓[22m[39m reads JWT_SECRET from environment variable [33m 1240[2mms[22m[39m
|
|
374
|
+
[33m[2m✓[22m[39m reads JWT_SECRET from .env file [33m 1296[2mms[22m[39m
|
|
375
|
+
[33m[2m✓[22m[39m exits non-zero when no secret is available [33m 1318[2mms[22m[39m
|
|
376
|
+
[33m[2m✓[22m[39m keys --help shows --secret and --exp-years options [33m 1299[2mms[22m[39m
|
|
377
|
+
[32m✓[39m tests/augmentation-generator.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 17[2mms[22m[39m
|
|
375
378
|
[32m✓[39m tests/type-resolver.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 16[2mms[22m[39m
|
|
376
|
-
[32m✓[39m tests/
|
|
377
|
-
[32m✓[39m tests/
|
|
378
|
-
[
|
|
379
|
-
[22m[39m
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
[32m✓[39m tests/
|
|
389
|
-
[32m✓[39m tests/
|
|
390
|
-
[32m✓[39m tests/
|
|
391
|
-
[32m✓[39m tests/normalize-admin-config.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 6[2mms[22m[39m
|
|
379
|
+
[32m✓[39m tests/engine-push-output.test.ts [2m([22m[2m7 tests[22m[2m)[22m[32m 6[2mms[22m[39m
|
|
380
|
+
[32m✓[39m tests/tsx-runner.test.ts [2m([22m[2m7 tests[22m[2m)[22m[33m 2720[2mms[22m[39m
|
|
381
|
+
[33m[2m✓[22m[39m evaluates a simple expression and returns stdout [33m 400[2mms[22m[39m
|
|
382
|
+
[33m[2m✓[22m[39m evaluates TypeScript syntax (type annotations) [33m 368[2mms[22m[39m
|
|
383
|
+
[33m[2m✓[22m[39m can serialize a JSON object to stdout [33m 337[2mms[22m[39m
|
|
384
|
+
[33m[2m✓[22m[39m returns non-zero exit code on syntax error [33m 342[2mms[22m[39m
|
|
385
|
+
[33m[2m✓[22m[39m returns non-zero exit code on runtime error [33m 387[2mms[22m[39m
|
|
386
|
+
[33m[2m✓[22m[39m captures stderr separately from stdout [33m 342[2mms[22m[39m
|
|
387
|
+
[33m[2m✓[22m[39m runs a .ts file and returns its stdout [33m 541[2mms[22m[39m
|
|
388
|
+
[32m✓[39m tests/command-chrome-wrap.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 6[2mms[22m[39m
|
|
389
|
+
[32m✓[39m tests/init-project-detect.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 9[2mms[22m[39m
|
|
390
|
+
[32m✓[39m tests/ensure-binary.test.ts [2m([22m[2m2 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 7[2mms[22m[39m
|
|
392
|
+
[32m✓[39m tests/required-host-components.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 5[2mms[22m[39m
|
|
393
|
+
[32m✓[39m tests/normalize-admin-config.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 7[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,9 +401,9 @@
|
|
|
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/docker-postgres.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m
|
|
404
|
+
[32m✓[39m tests/dev-session-lock.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 4[2mms[22m[39m
|
|
405
|
+
[32m✓[39m tests/ui-confirm.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 8[2mms[22m[39m
|
|
406
|
+
[32m✓[39m tests/docker-postgres.test.ts [2m([22m[2m5 tests[22m[2m)[22m[32m 4[2mms[22m[39m
|
|
405
407
|
[32m✓[39m tests/binary-download-lock.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 7[2mms[22m[39m
|
|
406
408
|
[32m✓[39m tests/dev-ports.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 6[2mms[22m[39m
|
|
407
409
|
[90mstdout[2m | tests/app-command.test.ts[2m > [22m[2msupatype app add --static[2m > [22m[2mcreates the static directory when missing
|
|
@@ -414,41 +416,42 @@
|
|
|
414
416
|
created public/.gitkeep
|
|
415
417
|
created .gitignore
|
|
416
418
|
|
|
417
|
-
[32m✓[39m tests/
|
|
419
|
+
[32m✓[39m tests/dev-ready-panel.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 4[2mms[22m[39m
|
|
420
|
+
[32m✓[39m tests/cli-help.test.ts [2m([22m[2m16 tests[22m[2m)[22m[33m 21614[2mms[22m[39m
|
|
421
|
+
[33m[2m✓[22m[39m --help lists all top-level commands [33m 1439[2mms[22m[39m
|
|
422
|
+
[33m[2m✓[22m[39m --version prints package.json version [33m 1284[2mms[22m[39m
|
|
423
|
+
[33m[2m✓[22m[39m self-update --help describes the command [33m 1331[2mms[22m[39m
|
|
424
|
+
[33m[2m✓[22m[39m init --help describes the init command [33m 1443[2mms[22m[39m
|
|
425
|
+
[33m[2m✓[22m[39m push --help describes the push command and --yes flag [33m 1272[2mms[22m[39m
|
|
426
|
+
[33m[2m✓[22m[39m diff --help describes the diff command [33m 1335[2mms[22m[39m
|
|
427
|
+
[33m[2m✓[22m[39m pull --help describes scaffold pull command [33m 1398[2mms[22m[39m
|
|
428
|
+
[33m[2m✓[22m[39m doctor --help describes drift report command [33m 1280[2mms[22m[39m
|
|
429
|
+
[33m[2m✓[22m[39m introspect --help describes database introspection command [33m 1370[2mms[22m[39m
|
|
430
|
+
[33m[2m✓[22m[39m adopt --help describes adoption ceremony command [33m 1316[2mms[22m[39m
|
|
431
|
+
[33m[2m✓[22m[39m reset --help shows --yes flag [33m 1428[2mms[22m[39m
|
|
432
|
+
[33m[2m✓[22m[39m app --help describes the app command with add/remove subcommands [33m 1330[2mms[22m[39m
|
|
433
|
+
[33m[2m✓[22m[39m app add --help shows --static and --port options [33m 1395[2mms[22m[39m
|
|
434
|
+
[33m[2m✓[22m[39m self-host --help shows compose only (legacy commands hidden) [33m 1328[2mms[22m[39m
|
|
435
|
+
[33m[2m✓[22m[39m self-host compose --help shows compose subcommands [33m 1274[2mms[22m[39m
|
|
436
|
+
[33m[2m✓[22m[39m unknown command exits non-zero [33m 1383[2mms[22m[39m
|
|
418
437
|
[32m✓[39m tests/studio-admin-roles.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 5[2mms[22m[39m
|
|
419
|
-
[32m✓[39m tests/
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
[33m[2m✓[22m[39m
|
|
423
|
-
[33m[2m✓[22m[39m
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
[33m[2m✓[22m[39m doctor --help describes drift report command [33m 1293[2mms[22m[39m
|
|
428
|
-
[33m[2m✓[22m[39m introspect --help describes database introspection command [33m 1298[2mms[22m[39m
|
|
429
|
-
[33m[2m✓[22m[39m adopt --help describes adoption ceremony command [33m 1462[2mms[22m[39m
|
|
430
|
-
[33m[2m✓[22m[39m reset --help shows --yes flag [33m 1360[2mms[22m[39m
|
|
431
|
-
[33m[2m✓[22m[39m app --help describes the app command with add/remove subcommands [33m 1388[2mms[22m[39m
|
|
432
|
-
[33m[2m✓[22m[39m app add --help shows --static and --port options [33m 1371[2mms[22m[39m
|
|
433
|
-
[33m[2m✓[22m[39m self-host --help shows compose only (legacy commands hidden) [33m 1315[2mms[22m[39m
|
|
434
|
-
[33m[2m✓[22m[39m self-host compose --help shows compose subcommands [33m 1354[2mms[22m[39m
|
|
435
|
-
[33m[2m✓[22m[39m unknown command exits non-zero [33m 1427[2mms[22m[39m
|
|
436
|
-
[32m✓[39m tests/release-pins.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 5[2mms[22m[39m
|
|
437
|
-
[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
|
-
[32m✓[39m tests/rest-cache-admin.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 48[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/ensure-dev-api-config.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 4[2mms[22m[39m
|
|
440
|
+
[32m✓[39m tests/app-command.test.ts [2m([22m[2m2 tests[22m[2m)[22m[33m 2786[2mms[22m[39m
|
|
441
|
+
[33m[2m✓[22m[39m sets app.mode=static and static_dir in supatype.config.ts [33m 1429[2mms[22m[39m
|
|
442
|
+
[33m[2m✓[22m[39m creates the static directory when missing [33m 1355[2mms[22m[39m
|
|
443
|
+
[32m✓[39m tests/seed-discover.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 20[2mms[22m[39m
|
|
444
|
+
[32m✓[39m tests/rest-cache-admin.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 44[2mms[22m[39m
|
|
445
|
+
[32m✓[39m tests/init-package-json.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 3[2mms[22m[39m
|
|
442
446
|
[32m✓[39m tests/resolve-api-url.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 4[2mms[22m[39m
|
|
443
|
-
[32m✓[39m tests/
|
|
444
|
-
[32m✓[39m tests/migrate-from-v1.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m
|
|
445
|
-
[32m✓[39m tests/pg-spawn-env.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 5[2mms[22m[39m
|
|
447
|
+
[32m✓[39m tests/pg-spawn-env.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 4[2mms[22m[39m
|
|
448
|
+
[32m✓[39m tests/migrate-from-v1.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 17[2mms[22m[39m
|
|
446
449
|
[32m✓[39m tests/cli-package-version.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 4[2mms[22m[39m
|
|
447
|
-
[32m✓[39m tests/postgres-archive-tag.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m
|
|
448
|
-
[32m✓[39m tests/
|
|
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
|
|
449
452
|
|
|
450
|
-
[2m Test Files [22m [1m[
|
|
451
|
-
[2m Tests [22m [1m[
|
|
452
|
-
[2m Start at [22m
|
|
453
|
-
[2m Duration [22m
|
|
453
|
+
[2m Test Files [22m [1m[32m48 passed[39m[22m[90m (48)[39m
|
|
454
|
+
[2m Tests [22m [1m[32m362 passed[39m[22m[90m (362)[39m
|
|
455
|
+
[2m Start at [22m 23:33:06
|
|
456
|
+
[2m Duration [22m 27.66s[2m (transform 4.07s, setup 0ms, import 21.16s, tests 53.31s, 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());
|