@supatype/cli 0.1.0 → 0.1.1

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.
Files changed (59) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.turbo/turbo-test.log +96 -85
  3. package/.turbo/turbo-typecheck.log +1 -1
  4. package/dist/commands/admin.d.ts +28 -1
  5. package/dist/commands/admin.d.ts.map +1 -1
  6. package/dist/commands/admin.js +273 -111
  7. package/dist/commands/admin.js.map +1 -1
  8. package/dist/commands/dev.d.ts.map +1 -1
  9. package/dist/commands/dev.js +2 -0
  10. package/dist/commands/dev.js.map +1 -1
  11. package/dist/commands/init.d.ts +5 -0
  12. package/dist/commands/init.d.ts.map +1 -1
  13. package/dist/commands/init.js +70 -1
  14. package/dist/commands/init.js.map +1 -1
  15. package/dist/commands/push.js +3 -3
  16. package/dist/commands/push.js.map +1 -1
  17. package/dist/compose-rename.d.ts +10 -0
  18. package/dist/compose-rename.d.ts.map +1 -0
  19. package/dist/compose-rename.js +67 -0
  20. package/dist/compose-rename.js.map +1 -0
  21. package/dist/dev-compose.d.ts.map +1 -1
  22. package/dist/dev-compose.js +34 -50
  23. package/dist/dev-compose.js.map +1 -1
  24. package/dist/dev-ports.d.ts +27 -0
  25. package/dist/dev-ports.d.ts.map +1 -0
  26. package/dist/dev-ports.js +171 -0
  27. package/dist/dev-ports.js.map +1 -0
  28. package/dist/dev-session-lock.d.ts +25 -0
  29. package/dist/dev-session-lock.d.ts.map +1 -0
  30. package/dist/dev-session-lock.js +81 -0
  31. package/dist/dev-session-lock.js.map +1 -0
  32. package/dist/dev-shutdown.d.ts +18 -2
  33. package/dist/dev-shutdown.d.ts.map +1 -1
  34. package/dist/dev-shutdown.js +69 -5
  35. package/dist/dev-shutdown.js.map +1 -1
  36. package/dist/env-file.d.ts +5 -0
  37. package/dist/env-file.d.ts.map +1 -0
  38. package/dist/env-file.js +33 -0
  39. package/dist/env-file.js.map +1 -0
  40. package/dist/self-host-compose.d.ts.map +1 -1
  41. package/dist/self-host-compose.js +2 -1
  42. package/dist/self-host-compose.js.map +1 -1
  43. package/package.json +3 -1
  44. package/src/commands/admin.ts +361 -136
  45. package/src/commands/dev.ts +3 -0
  46. package/src/commands/init.ts +93 -1
  47. package/src/commands/push.ts +3 -3
  48. package/src/compose-rename.ts +76 -0
  49. package/src/dev-compose.ts +44 -50
  50. package/src/dev-ports.ts +212 -0
  51. package/src/dev-session-lock.ts +101 -0
  52. package/src/dev-shutdown.ts +98 -5
  53. package/src/env-file.ts +37 -0
  54. package/src/self-host-compose.ts +2 -1
  55. package/tests/admin-ensure.test.ts +59 -0
  56. package/tests/dev-ports.test.ts +41 -0
  57. package/tests/dev-session-lock.test.ts +54 -0
  58. package/tests/dev-ui.test.ts +24 -1
  59. package/tsconfig.tsbuildinfo +1 -1
@@ -1,4 +1,4 @@
1
1
 
2
- > @supatype/cli@0.1.0 build /home/runner/work/supatype/supatype/packages/cli
2
+ > @supatype/cli@0.1.1 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
 
@@ -1,5 +1,5 @@
1
1
 
2
- > @supatype/cli@0.1.0 test /home/runner/work/supatype/supatype/packages/cli
2
+ > @supatype/cli@0.1.1 test /home/runner/work/supatype/supatype/packages/cli
3
3
  > vitest run
4
4
 
5
5
 
@@ -276,9 +276,9 @@
276
276
  created public/.gitkeep
277
277
  created .gitignore
278
278
 
279
- ✓ tests/init.test.ts (25 tests) 170ms
280
- ✓ tests/type-extractor.test.ts (34 tests) 149ms
281
- ✓ tests/runtime-contract.test.ts (40 tests) 167ms
279
+ ✓ tests/init.test.ts (25 tests) 138ms
280
+ ✓ tests/type-extractor.test.ts (34 tests) 128ms
281
+ ✓ tests/runtime-contract.test.ts (40 tests) 106ms
282
282
  stdout | tests/docker-runtime.test.ts > requireDockerDaemon > exits when the daemon is unavailable
283
283
  
284
284
  Start the Docker daemon (e.g. sudo systemctl start docker), then try again.
@@ -287,15 +287,20 @@
287
287
 
288
288
  docker: daemon down
289
289
 
290
- ✓ tests/docker-runtime.test.ts (10 tests) 24ms
291
- ✓ tests/config.test.ts (18 tests) 4668ms
292
- ✓ loads a valid supatype.config.ts (plain export default, no package imports)  711ms
293
- ✓ normalizes shorthand schema string to { path, pg_schema }  541ms
294
- ✓ loads a supatype.config.js (plain ESM)  581ms
295
- ✓ loads config without a versions section (latest by default)  489ms
296
- ✓ prefers supatype.config.ts over supatype.config.js when both exist  559ms
297
- ✓ supports optional output field in config  550ms
298
- ✓ merges supatype.local.config.ts over base  1224ms
290
+ ✓ tests/docker-runtime.test.ts (10 tests) 13ms
291
+
292
+
293
+
294
+
295
+ ✓ tests/dev-ui.test.ts (16 tests) 96ms
296
+ ✓ tests/config.test.ts (18 tests) 3950ms
297
+ ✓ loads a valid supatype.config.ts (plain export default, no package imports)  554ms
298
+ ✓ normalizes shorthand schema string to { path, pg_schema }  471ms
299
+ ✓ loads a supatype.config.js (plain ESM)  508ms
300
+ ✓ loads config without a versions section (latest by default)  474ms
301
+ ✓ prefers supatype.config.ts over supatype.config.js when both exist  467ms
302
+ ✓ supports optional output field in config  491ms
303
+ ✓ merges supatype.local.config.ts over base  975ms
299
304
  stdout | tests/link.test.ts > link model > migrates cloud.json into link.json
300
305
   created package.json
301
306
  created supatype.config.ts
@@ -309,50 +314,62 @@
309
314
  stderr | tests/link.test.ts > link model > migrates cloud.json into link.json
310
315
  [supatype] Migrated .supatype/cloud.json → .supatype/link.json (legacy files kept; remove manually when ready).
311
316
 
312
- ✓ tests/link.test.ts (4 tests) 2795ms
313
- ✓ resolveTarget returns cloud mode with /api/v1 prefix  950ms
314
- ✓ resolveTarget returns self-host mode with /platform/v1 prefix  918ms
315
- ✓ targetSchemaRollback posts to /platform/v1 when linked  915ms
316
-
317
-
318
-
319
-
320
- ✓ tests/dev-ui.test.ts (15 tests) 66ms
321
-
317
+ ✓ tests/link.test.ts (4 tests) 2657ms
318
+ ✓ resolveTarget returns cloud mode with /api/v1 prefix  904ms
319
+ ✓ resolveTarget returns self-host mode with /platform/v1 prefix  875ms
320
+ ✓ targetSchemaRollback posts to /platform/v1 when linked  868ms
322
321
  ✓ tests/pull-utils.test.ts (49 tests) 11ms
323
- ✓ tests/schema-sources.test.ts (5 tests) 1150ms
324
- ✓ buildSchemaSourcesPayload includes manifest metadata  604ms
325
- ✓ restore overwrites modified local files  497ms
322
+ ✓ tests/schema-sources.test.ts (5 tests) 1051ms
323
+ ✓ buildSchemaSourcesPayload includes manifest metadata  500ms
324
+ ✓ restore overwrites modified local files  509ms
326
325
  stderr | tests/binary-cache-cloud-overrides.test.ts > isLinkedToCloudProject > is true when .supatype/cloud.json has projectSlug
327
326
  [supatype] Migrated .supatype/cloud.json → .supatype/link.json (legacy files kept; remove manually when ready).
328
327
 
329
- ✓ tests/binary-cache-cloud-overrides.test.ts (11 tests) 29ms
330
- ✓ tests/minisign.test.ts (5 tests) 26ms
328
+ ✓ tests/binary-cache-cloud-overrides.test.ts (11 tests) 18ms
329
+ ✓ tests/minisign.test.ts (5 tests) 14ms
331
330
  stdout | tests/storage-provision.test.ts > provisionBuckets > POSTs each bucket to the storage API
332
331
  [supatype] Storage bucket "photos" ready.
333
332
 
334
333
  stdout | tests/storage-provision.test.ts > provisionBuckets > POSTs each bucket to the storage API
335
334
  [supatype] Storage bucket "avatars" ready.
336
335
 
337
- ✓ tests/storage-provision.test.ts (6 tests) 9ms
338
- ✓ tests/cached-artifact-format.test.ts (7 tests) 13ms
336
+ ✓ tests/storage-provision.test.ts (6 tests) 12ms
337
+ ✓ tests/cached-artifact-format.test.ts (7 tests) 18ms
339
338
  ✓ tests/proxy-dev-app.test.ts (7 tests) 6ms
340
- ✓ tests/keys.test.ts (11 tests) 12562ms
341
- ✓ exits 0 with --secret  1104ms
342
- ✓ outputs ANON_KEY= line  1075ms
343
- ✓ outputs SERVICE_ROLE_KEY= line  1066ms
344
- ✓ ANON_KEY is a valid three-part JWT  1024ms
345
- ✓ SERVICE_ROLE_KEY payload has role: service_role  1088ms
346
- ✓ JWT has exp in the future  1030ms
347
- ✓ --exp-years changes the expiry window  2097ms
348
- ✓ reads JWT_SECRET from environment variable  998ms
349
- ✓ reads JWT_SECRET from .env file  1054ms
350
- ✓ exits non-zero when no secret is available  1029ms
351
- ✓ keys --help shows --secret and --exp-years options  992ms
352
- ✓ tests/augmentation-generator.test.ts (3 tests) 17ms
339
+ ✓ tests/keys.test.ts (11 tests) 11267ms
340
+ ✓ exits 0 with --secret  1124ms
341
+ ✓ outputs ANON_KEY= line  929ms
342
+ ✓ outputs SERVICE_ROLE_KEY= line  1013ms
343
+ ✓ ANON_KEY is a valid three-part JWT  939ms
344
+ ✓ SERVICE_ROLE_KEY payload has role: service_role  981ms
345
+ ✓ JWT has exp in the future  925ms
346
+ ✓ --exp-years changes the expiry window  1840ms
347
+ ✓ reads JWT_SECRET from environment variable  946ms
348
+ ✓ reads JWT_SECRET from .env file  886ms
349
+ ✓ exits non-zero when no secret is available  827ms
350
+ ✓ keys --help shows --secret and --exp-years options  850ms
351
+ ✓ tests/augmentation-generator.test.ts (3 tests) 28ms
353
352
  ✓ tests/type-resolver.test.ts (2 tests) 14ms
354
- ✓ tests/engine-push-output.test.ts (7 tests) 6ms
355
- ✓ tests/ui-messages.test.ts (5 tests) 7ms
353
+ ✓ tests/engine-push-output.test.ts (7 tests) 8ms
354
+ stdout | tests/admin-ensure.test.ts > init admin seed in .env > writes SUPATYPE_ADMIN_* when scaffold options include credentials
355
+  created package.json
356
+ created supatype.config.ts
357
+ created schema/index.ts
358
+ created .env
359
+ created seed.ts
360
+ created seeds/.gitkeep
361
+ created public/.gitkeep
362
+ created .gitignore
363
+
364
+ ✓ tests/admin-ensure.test.ts (3 tests) 111ms
365
+ ✓ tests/tsx-runner.test.ts (7 tests) 2571ms
366
+ ✓ evaluates a simple expression and returns stdout  371ms
367
+ ✓ evaluates TypeScript syntax (type annotations)  351ms
368
+ ✓ returns non-zero exit code on syntax error  354ms
369
+ ✓ returns non-zero exit code on runtime error  341ms
370
+ ✓ captures stderr separately from stdout  346ms
371
+ ✓ runs a .ts file and returns its stdout  525ms
372
+ ✓ tests/ui-messages.test.ts (5 tests) 8ms
356
373
  ✓ tests/ensure-binary.test.ts (2 tests) 10ms
357
374
  stdout | tests/app-command.test.ts > supatype app add --static > sets app.mode=static and static_dir in supatype.config.ts
358
375
   created package.json
@@ -364,16 +381,11 @@
364
381
  created public/.gitkeep
365
382
  created .gitignore
366
383
 
367
- ✓ tests/tsx-runner.test.ts (7 tests) 2937ms
368
- ✓ evaluates a simple expression and returns stdout  430ms
369
- ✓ evaluates TypeScript syntax (type annotations)  367ms
370
- ✓ can serialize a JSON object to stdout  459ms
371
- ✓ returns non-zero exit code on syntax error  379ms
372
- ✓ returns non-zero exit code on runtime error  370ms
373
- ✓ captures stderr separately from stdout  372ms
374
- ✓ runs a .ts file and returns its stdout  556ms
375
- ✓ tests/normalize-admin-config.test.ts (1 test) 7ms
376
- ✓ tests/ui-confirm.test.ts (3 tests) 8ms
384
+ ✓ tests/normalize-admin-config.test.ts (1 test) 6ms
385
+ ✓ tests/dev-session-lock.test.ts (2 tests) 3ms
386
+ ✓ tests/ui-confirm.test.ts (3 tests) 7ms
387
+ ✓ tests/docker-postgres.test.ts (5 tests) 3ms
388
+ ✓ tests/dev-ports.test.ts (3 tests) 5ms
377
389
  stdout | tests/app-command.test.ts > supatype app add --static > creates the static directory when missing
378
390
   created package.json
379
391
  created supatype.config.ts
@@ -384,36 +396,35 @@
384
396
  created public/.gitkeep
385
397
  created .gitignore
386
398
 
387
- ✓ tests/docker-postgres.test.ts (5 tests) 5ms
388
- ✓ tests/seed-discover.test.ts (2 tests) 14ms
399
+ ✓ tests/seed-discover.test.ts (2 tests) 11ms
389
400
  ✓ tests/studio-admin-roles.test.ts (3 tests) 4ms
390
- ✓ tests/app-command.test.ts (2 tests) 2183ms
391
- ✓ sets app.mode=static and static_dir in supatype.config.ts  1081ms
392
- ✓ creates the static directory when missing  1100ms
393
- ✓ tests/cli-help.test.ts (16 tests) 16526ms
394
- ✓ --help lists all top-level commands  1119ms
395
- ✓ --version prints a semver string  1022ms
396
- ✓ self-update --help describes the command  1026ms
397
- ✓ init --help describes the init command  986ms
398
- ✓ push --help describes the push command and --yes flag  960ms
399
- ✓ diff --help describes the diff command  1013ms
400
- ✓ pull --help describes scaffold pull command  1109ms
401
- ✓ doctor --help describes drift report command  1101ms
402
- ✓ introspect --help describes database introspection command  1111ms
403
- ✓ adopt --help describes adoption ceremony command  1031ms
404
- ✓ reset --help shows --yes flag  1054ms
405
- ✓ app --help describes the app command with add/remove subcommands  1001ms
406
- ✓ app add --help shows --static and --port options  981ms
407
- ✓ self-host --help shows compose only (legacy commands hidden)  997ms
408
- ✓ self-host compose --help shows compose subcommands  988ms
409
- ✓ unknown command exits non-zero  1019ms
410
- ✓ tests/pg-spawn-env.test.ts (2 tests) 3ms
401
+ ✓ tests/cli-help.test.ts (16 tests) 14952ms
402
+ ✓ --help lists all top-level commands  990ms
403
+ ✓ --version prints a semver string  962ms
404
+ ✓ self-update --help describes the command  969ms
405
+ ✓ init --help describes the init command  875ms
406
+ ✓ push --help describes the push command and --yes flag  929ms
407
+ ✓ diff --help describes the diff command  869ms
408
+ ✓ pull --help describes scaffold pull command  939ms
409
+ ✓ doctor --help describes drift report command  959ms
410
+ ✓ introspect --help describes database introspection command  957ms
411
+ ✓ adopt --help describes adoption ceremony command  973ms
412
+ ✓ reset --help shows --yes flag  910ms
413
+ ✓ app --help describes the app command with add/remove subcommands  957ms
414
+ ✓ app add --help shows --static and --port options  959ms
415
+ ✓ self-host --help shows compose only (legacy commands hidden)  950ms
416
+ ✓ self-host compose --help shows compose subcommands  911ms
417
+ ✓ unknown command exits non-zero  836ms
418
+ ✓ tests/app-command.test.ts (2 tests) 2024ms
419
+ ✓ sets app.mode=static and static_dir in supatype.config.ts  959ms
420
+ ✓ creates the static directory when missing  1063ms
411
421
  ✓ tests/release-pins.test.ts (2 tests) 4ms
412
- ✓ tests/postgres-archive-tag.test.ts (1 test) 3ms
413
- ✓ tests/migrate-from-v1.test.ts (1 test) 11ms
414
-
415
-  Test Files  32 passed (32)
416
-  Tests  311 passed (311)
417
-  Start at  07:36:07
418
-  Duration  20.09s (transform 3.26s, setup 0ms, import 9.33s, tests 43.60s, environment 6ms)
422
+ ✓ tests/pg-spawn-env.test.ts (2 tests) 4ms
423
+ ✓ tests/postgres-archive-tag.test.ts (1 test) 2ms
424
+ ✓ tests/migrate-from-v1.test.ts (1 test) 14ms
425
+
426
+  Test Files  35 passed (35)
427
+  Tests  320 passed (320)
428
+  Start at  17:52:40
429
+  Duration  19.16s (transform 4.06s, setup 0ms, import 10.97s, tests 39.28s, environment 6ms)
419
430
 
@@ -1,4 +1,4 @@
1
1
 
2
- > @supatype/cli@0.1.0 typecheck /home/runner/work/supatype/supatype/packages/cli
2
+ > @supatype/cli@0.1.1 typecheck /home/runner/work/supatype/supatype/packages/cli
3
3
  > tsc --project tsconfig.json --noEmit
4
4
 
@@ -1,4 +1,31 @@
1
1
  import type { Command } from "commander";
2
+ import { type SupatypeProjectConfig } from "../project-config.js";
3
+ export declare const ADMIN_EMAIL_ENV = "SUPATYPE_ADMIN_EMAIL";
4
+ export declare const ADMIN_PASSWORD_ENV = "SUPATYPE_ADMIN_PASSWORD";
5
+ export interface EnsureFirstAdminOptions {
6
+ email?: string;
7
+ password?: string;
8
+ cwd?: string;
9
+ role?: string;
10
+ connection?: string;
11
+ compose?: {
12
+ project: string;
13
+ composePath: string;
14
+ };
15
+ }
2
16
  export declare function registerAdmin(program: Command): void;
3
- export declare function promptFirstAdminUser(connection: string): Promise<void>;
17
+ /** @deprecated Use ensureFirstAdminUser */
18
+ export declare const promptFirstAdminUser: typeof ensureFirstAdminUser;
19
+ /**
20
+ * Ensure a first admin user exists (idempotent). Called from `dev` and `push`
21
+ * when auth.users is ready and no admin users exist yet.
22
+ */
23
+ export declare function ensureFirstAdminUser(connection: string, options?: EnsureFirstAdminOptions): Promise<void>;
24
+ /**
25
+ * Resolve DB access for the current project (host URL or compose exec when DB
26
+ * is not published to the host).
27
+ */
28
+ export declare function ensureFirstAdminUserForProject(cwd: string, config: SupatypeProjectConfig, options?: EnsureFirstAdminOptions): Promise<void>;
29
+ export declare function clearAdminSeedPassword(cwd: string): void;
30
+ export declare function hashPasswordForAuth(password: string): Promise<string>;
4
31
  //# 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;AAYxC,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA8NpD;AAKD,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CA0Ef"}
1
+ {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/commands/admin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAOxC,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,sBAAsB,CAAA;AAQ7B,eAAO,MAAM,eAAe,yBAAyB,CAAA;AACrD,eAAO,MAAM,kBAAkB,4BAA4B,CAAA;AAI3D,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;AAID,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAkKpD;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,CA0Bf;AAyED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAExD;AAED,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE3E"}