@supatype/cli 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +314 -0
- package/bin/supatype.js +40 -4
- package/deno.d.ts +1 -1
- package/dist/admin-prompt-state.d.ts +13 -0
- package/dist/admin-prompt-state.d.ts.map +1 -0
- package/dist/admin-prompt-state.js +30 -0
- package/dist/admin-prompt-state.js.map +1 -0
- package/dist/adopt-columns.d.ts.map +1 -1
- package/dist/adopt-columns.js +13 -17
- package/dist/adopt-columns.js.map +1 -1
- package/dist/after-hooks-health.d.ts +19 -0
- package/dist/after-hooks-health.d.ts.map +1 -0
- package/dist/after-hooks-health.js +69 -0
- package/dist/after-hooks-health.js.map +1 -0
- package/dist/app-config.d.ts +1 -1
- package/dist/app-config.d.ts.map +1 -1
- package/dist/app-config.js +103 -144
- package/dist/app-config.js.map +1 -1
- package/dist/app-vite-env.d.ts +5 -1
- package/dist/app-vite-env.d.ts.map +1 -1
- package/dist/app-vite-env.js +9 -15
- package/dist/app-vite-env.js.map +1 -1
- package/dist/applied-ast-artifacts.d.ts +16 -0
- package/dist/applied-ast-artifacts.d.ts.map +1 -0
- package/dist/applied-ast-artifacts.js +37 -0
- package/dist/applied-ast-artifacts.js.map +1 -0
- package/dist/archive-extract.d.ts +3 -0
- package/dist/archive-extract.d.ts.map +1 -0
- package/dist/archive-extract.js +19 -0
- package/dist/archive-extract.js.map +1 -0
- package/dist/augmentation-generator.d.ts +5 -0
- package/dist/augmentation-generator.d.ts.map +1 -1
- package/dist/augmentation-generator.js +13 -4
- package/dist/augmentation-generator.js.map +1 -1
- package/dist/binary-cache.d.ts +27 -3
- package/dist/binary-cache.d.ts.map +1 -1
- package/dist/binary-cache.js +117 -85
- package/dist/binary-cache.js.map +1 -1
- package/dist/binary-download-lock.d.ts.map +1 -1
- package/dist/binary-download-lock.js +1 -3
- package/dist/binary-download-lock.js.map +1 -1
- package/dist/byo-preflight.d.ts.map +1 -1
- package/dist/byo-preflight.js +2 -10
- package/dist/byo-preflight.js.map +1 -1
- package/dist/byte-size.d.ts +9 -0
- package/dist/byte-size.d.ts.map +1 -0
- package/dist/byte-size.js +36 -0
- package/dist/byte-size.js.map +1 -0
- package/dist/cache-clean.d.ts +0 -2
- package/dist/cache-clean.d.ts.map +1 -1
- package/dist/cache-clean.js +1 -27
- package/dist/cache-clean.js.map +1 -1
- package/dist/cache-pins.d.ts.map +1 -1
- package/dist/cache-pins.js +3 -20
- package/dist/cache-pins.js.map +1 -1
- package/dist/cache-root.d.ts +7 -0
- package/dist/cache-root.d.ts.map +1 -0
- package/dist/cache-root.js +11 -0
- package/dist/cache-root.js.map +1 -0
- package/dist/cli-artifacts.d.ts.map +1 -1
- package/dist/cli-artifacts.js +2 -1
- package/dist/cli-artifacts.js.map +1 -1
- package/dist/cli-install-method.d.ts.map +1 -1
- package/dist/cli-install-method.js +7 -1
- package/dist/cli-install-method.js.map +1 -1
- package/dist/cli-launcher.d.ts +21 -0
- package/dist/cli-launcher.d.ts.map +1 -0
- package/dist/cli-launcher.js +112 -0
- package/dist/cli-launcher.js.map +1 -0
- package/dist/cli-old-versions.d.ts +44 -0
- package/dist/cli-old-versions.d.ts.map +1 -0
- package/dist/cli-old-versions.js +83 -0
- package/dist/cli-old-versions.js.map +1 -0
- package/dist/cli-program-path.d.ts +20 -0
- package/dist/cli-program-path.d.ts.map +1 -0
- package/dist/cli-program-path.js +41 -0
- package/dist/cli-program-path.js.map +1 -0
- package/dist/cli-standalone.d.ts +2 -3
- package/dist/cli-standalone.d.ts.map +1 -1
- package/dist/cli-standalone.js +51 -24
- package/dist/cli-standalone.js.map +1 -1
- package/dist/cli-version-embedded.js +1 -1
- package/dist/cloud-credentials.d.ts +6 -0
- package/dist/cloud-credentials.d.ts.map +1 -1
- package/dist/cloud-credentials.js +13 -0
- package/dist/cloud-credentials.js.map +1 -1
- package/dist/commands/admin.d.ts.map +1 -1
- package/dist/commands/admin.js +18 -18
- package/dist/commands/admin.js.map +1 -1
- package/dist/commands/app.d.ts.map +1 -1
- package/dist/commands/app.js +27 -8
- package/dist/commands/app.js.map +1 -1
- package/dist/commands/cache.d.ts.map +1 -1
- package/dist/commands/cache.js +37 -11
- package/dist/commands/cache.js.map +1 -1
- package/dist/commands/cloud.js +2 -4
- package/dist/commands/cloud.js.map +1 -1
- package/dist/commands/db.d.ts.map +1 -1
- package/dist/commands/db.js +116 -106
- package/dist/commands/db.js.map +1 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +3 -3
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts +50 -4
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +276 -267
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/doctor.d.ts +32 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +66 -1
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/functions.d.ts +30 -0
- package/dist/commands/functions.d.ts.map +1 -1
- package/dist/commands/functions.js +503 -507
- package/dist/commands/functions.js.map +1 -1
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +11 -8
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/hooks.d.ts.map +1 -1
- package/dist/commands/hooks.js +46 -23
- package/dist/commands/hooks.js.map +1 -1
- package/dist/commands/init.d.ts +37 -4
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +509 -386
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/internal.d.ts.map +1 -1
- package/dist/commands/internal.js +2 -1
- package/dist/commands/internal.js.map +1 -1
- package/dist/commands/keys.d.ts +46 -20
- package/dist/commands/keys.d.ts.map +1 -1
- package/dist/commands/keys.js +196 -156
- package/dist/commands/keys.js.map +1 -1
- package/dist/commands/link-helpers.d.ts.map +1 -1
- package/dist/commands/link-helpers.js +30 -11
- package/dist/commands/link-helpers.js.map +1 -1
- package/dist/commands/logs.d.ts.map +1 -1
- package/dist/commands/logs.js +5 -4
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/migrate.js +1 -1
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/pg.js +2 -0
- package/dist/commands/pg.js.map +1 -1
- package/dist/commands/plugins.d.ts.map +1 -1
- package/dist/commands/plugins.js +17 -7
- package/dist/commands/plugins.js.map +1 -1
- package/dist/commands/push.d.ts +39 -0
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +221 -77
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/seed.d.ts +35 -0
- package/dist/commands/seed.d.ts.map +1 -1
- package/dist/commands/seed.js +72 -38
- package/dist/commands/seed.js.map +1 -1
- package/dist/commands/self-host.d.ts.map +1 -1
- package/dist/commands/self-host.js +71 -42
- package/dist/commands/self-host.js.map +1 -1
- package/dist/commands/self-update.d.ts.map +1 -1
- package/dist/commands/self-update.js +9 -3
- package/dist/commands/self-update.js.map +1 -1
- package/dist/commands/status.js +5 -5
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/types.js +2 -5
- package/dist/commands/types.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +212 -101
- package/dist/commands/update.js.map +1 -1
- package/dist/component-launch.d.ts +11 -0
- package/dist/component-launch.d.ts.map +1 -0
- package/dist/component-launch.js +35 -0
- package/dist/component-launch.js.map +1 -0
- package/dist/components.d.ts +7 -2
- package/dist/components.d.ts.map +1 -1
- package/dist/components.js +7 -2
- package/dist/components.js.map +1 -1
- package/dist/compose-db-roles.d.ts.map +1 -1
- package/dist/compose-db-roles.js +5 -14
- package/dist/compose-db-roles.js.map +1 -1
- package/dist/compose-engine-run.d.ts +6 -5
- package/dist/compose-engine-run.d.ts.map +1 -1
- package/dist/compose-engine-run.js +44 -37
- package/dist/compose-engine-run.js.map +1 -1
- package/dist/compose-engine-service.d.ts +10 -0
- package/dist/compose-engine-service.d.ts.map +1 -0
- package/dist/compose-engine-service.js +16 -0
- package/dist/compose-engine-service.js.map +1 -0
- package/dist/compose-host-path.d.ts +14 -0
- package/dist/compose-host-path.d.ts.map +1 -0
- package/dist/compose-host-path.js +18 -0
- package/dist/compose-host-path.js.map +1 -0
- package/dist/compose-image-pull.d.ts +43 -0
- package/dist/compose-image-pull.d.ts.map +1 -0
- package/dist/compose-image-pull.js +27 -0
- package/dist/compose-image-pull.js.map +1 -0
- package/dist/compose-kong.d.ts +4 -0
- package/dist/compose-kong.d.ts.map +1 -1
- package/dist/compose-kong.js +23 -9
- package/dist/compose-kong.js.map +1 -1
- package/dist/compose-local-server-image.d.ts.map +1 -1
- package/dist/compose-local-server-image.js +7 -3
- package/dist/compose-local-server-image.js.map +1 -1
- package/dist/compose-render-mode.d.ts.map +1 -1
- package/dist/compose-render-mode.js +7 -4
- package/dist/compose-render-mode.js.map +1 -1
- package/dist/compose-services.d.ts +12 -2
- package/dist/compose-services.d.ts.map +1 -1
- package/dist/compose-services.js +27 -12
- package/dist/compose-services.js.map +1 -1
- package/dist/config-snapshot.d.ts +6 -0
- package/dist/config-snapshot.d.ts.map +1 -0
- package/dist/config-snapshot.js +23 -0
- package/dist/config-snapshot.js.map +1 -0
- package/dist/config.d.ts +11 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +20 -3
- package/dist/config.js.map +1 -1
- package/dist/database-url-owner.d.ts +59 -0
- package/dist/database-url-owner.d.ts.map +1 -0
- package/dist/database-url-owner.js +133 -0
- package/dist/database-url-owner.js.map +1 -0
- package/dist/db-port-offer.d.ts +18 -0
- package/dist/db-port-offer.d.ts.map +1 -0
- package/dist/db-port-offer.js +68 -0
- package/dist/db-port-offer.js.map +1 -0
- package/dist/db-port.d.ts +42 -18
- package/dist/db-port.d.ts.map +1 -1
- package/dist/db-port.js +34 -32
- package/dist/db-port.js.map +1 -1
- package/dist/db-preflight.d.ts +37 -0
- package/dist/db-preflight.d.ts.map +1 -1
- package/dist/db-preflight.js +219 -77
- package/dist/db-preflight.js.map +1 -1
- package/dist/db-rows.d.ts +11 -0
- package/dist/db-rows.d.ts.map +1 -1
- package/dist/db-rows.js +27 -0
- package/dist/db-rows.js.map +1 -1
- package/dist/debounce.d.ts +11 -0
- package/dist/debounce.d.ts.map +1 -0
- package/dist/debounce.js +23 -0
- package/dist/debounce.js.map +1 -0
- package/dist/dev-api-keys.d.ts +12 -2
- package/dist/dev-api-keys.d.ts.map +1 -1
- package/dist/dev-api-keys.js +33 -17
- package/dist/dev-api-keys.js.map +1 -1
- package/dist/dev-compose.d.ts +10 -12
- package/dist/dev-compose.d.ts.map +1 -1
- package/dist/dev-compose.js +252 -288
- package/dist/dev-compose.js.map +1 -1
- package/dist/dev-db-ready.d.ts.map +1 -1
- package/dist/dev-db-ready.js +2 -1
- package/dist/dev-db-ready.js.map +1 -1
- package/dist/dev-db-reset.d.ts.map +1 -1
- package/dist/dev-db-reset.js +5 -4
- package/dist/dev-db-reset.js.map +1 -1
- package/dist/dev-functions-watch.d.ts.map +1 -1
- package/dist/dev-functions-watch.js +5 -16
- package/dist/dev-functions-watch.js.map +1 -1
- package/dist/dev-log-bus.d.ts +8 -0
- package/dist/dev-log-bus.d.ts.map +1 -1
- package/dist/dev-log-bus.js +13 -0
- package/dist/dev-log-bus.js.map +1 -1
- package/dist/dev-ports.d.ts +27 -7
- package/dist/dev-ports.d.ts.map +1 -1
- package/dist/dev-ports.js +68 -41
- package/dist/dev-ports.js.map +1 -1
- package/dist/dev-schema-watch.d.ts.map +1 -1
- package/dist/dev-schema-watch.js +7 -12
- package/dist/dev-schema-watch.js.map +1 -1
- package/dist/dev-session-lock.js +4 -3
- package/dist/dev-session-lock.js.map +1 -1
- package/dist/dev-session.d.ts +15 -0
- package/dist/dev-session.d.ts.map +1 -1
- package/dist/dev-session.js +27 -1
- package/dist/dev-session.js.map +1 -1
- package/dist/dev-shutdown.d.ts +45 -0
- package/dist/dev-shutdown.d.ts.map +1 -1
- package/dist/dev-shutdown.js +221 -33
- package/dist/dev-shutdown.js.map +1 -1
- package/dist/diff-output.d.ts +7 -1
- package/dist/diff-output.d.ts.map +1 -1
- package/dist/diff-output.js +91 -2
- package/dist/diff-output.js.map +1 -1
- package/dist/docker-address-pool.d.ts +23 -0
- package/dist/docker-address-pool.d.ts.map +1 -0
- package/dist/docker-address-pool.js +56 -0
- package/dist/docker-address-pool.js.map +1 -0
- package/dist/docker-exec.d.ts +92 -0
- package/dist/docker-exec.d.ts.map +1 -0
- package/dist/docker-exec.js +139 -0
- package/dist/docker-exec.js.map +1 -0
- package/dist/docker-postgres.d.ts +1 -6
- package/dist/docker-postgres.d.ts.map +1 -1
- package/dist/docker-postgres.js +67 -85
- package/dist/docker-postgres.js.map +1 -1
- package/dist/docker-runtime.d.ts +14 -1
- package/dist/docker-runtime.d.ts.map +1 -1
- package/dist/docker-runtime.js +55 -24
- package/dist/docker-runtime.js.map +1 -1
- package/dist/dotenv-parse.d.ts +22 -0
- package/dist/dotenv-parse.d.ts.map +1 -0
- package/dist/dotenv-parse.js +63 -0
- package/dist/dotenv-parse.js.map +1 -0
- package/dist/engine-answers.d.ts +0 -2
- package/dist/engine-answers.d.ts.map +1 -1
- package/dist/engine-answers.js +4 -3
- package/dist/engine-answers.js.map +1 -1
- package/dist/engine-client.d.ts.map +1 -1
- package/dist/engine-client.js +13 -12
- package/dist/engine-client.js.map +1 -1
- package/dist/engine-floor.d.ts +29 -0
- package/dist/engine-floor.d.ts.map +1 -1
- package/dist/engine-floor.js +56 -0
- package/dist/engine-floor.js.map +1 -1
- package/dist/engine-ownership-gate.d.ts +13 -1
- package/dist/engine-ownership-gate.d.ts.map +1 -1
- package/dist/engine-ownership-gate.js +36 -6
- package/dist/engine-ownership-gate.js.map +1 -1
- package/dist/ensure-binary.d.ts +9 -0
- package/dist/ensure-binary.d.ts.map +1 -1
- package/dist/ensure-binary.js +38 -5
- package/dist/ensure-binary.js.map +1 -1
- package/dist/ensure-component-binaries.d.ts.map +1 -1
- package/dist/ensure-component-binaries.js +2 -1
- package/dist/ensure-component-binaries.js.map +1 -1
- package/dist/env-file.d.ts +30 -8
- package/dist/env-file.d.ts.map +1 -1
- package/dist/env-file.js +84 -57
- package/dist/env-file.js.map +1 -1
- package/dist/env-lines.d.ts +11 -0
- package/dist/env-lines.d.ts.map +1 -0
- package/dist/env-lines.js +36 -0
- package/dist/env-lines.js.map +1 -0
- package/dist/error-message.d.ts +34 -1
- package/dist/error-message.d.ts.map +1 -1
- package/dist/error-message.js +102 -2
- package/dist/error-message.js.map +1 -1
- package/dist/fetch-within.d.ts +10 -0
- package/dist/fetch-within.d.ts.map +1 -0
- package/dist/fetch-within.js +12 -0
- package/dist/fetch-within.js.map +1 -0
- package/dist/field-masking-tier.d.ts.map +1 -1
- package/dist/field-masking-tier.js +7 -5
- package/dist/field-masking-tier.js.map +1 -1
- package/dist/frontend-env.d.ts +43 -0
- package/dist/frontend-env.d.ts.map +1 -0
- package/dist/frontend-env.js +81 -0
- package/dist/frontend-env.js.map +1 -0
- package/dist/functions-context-refresh.d.ts +6 -2
- package/dist/functions-context-refresh.d.ts.map +1 -1
- package/dist/functions-context-refresh.js +11 -3
- package/dist/functions-context-refresh.js.map +1 -1
- package/dist/functions-deno-types.d.ts.map +1 -1
- package/dist/functions-deno-types.js +9 -2
- package/dist/functions-deno-types.js.map +1 -1
- package/dist/{functions-router-gen.d.ts → functions-discovery.d.ts} +8 -10
- package/dist/functions-discovery.d.ts.map +1 -0
- package/dist/functions-discovery.js +87 -0
- package/dist/functions-discovery.js.map +1 -0
- package/dist/functions-template.d.ts.map +1 -1
- package/dist/functions-template.js +20 -12
- package/dist/functions-template.js.map +1 -1
- package/dist/functions-worker-files.d.ts +55 -0
- package/dist/functions-worker-files.d.ts.map +1 -0
- package/dist/functions-worker-files.js +149 -0
- package/dist/functions-worker-files.js.map +1 -0
- package/dist/generated/functions-worker-source.d.ts +2 -0
- package/dist/generated/functions-worker-source.d.ts.map +1 -0
- package/dist/generated/functions-worker-source.js +12 -0
- package/dist/generated/functions-worker-source.js.map +1 -0
- package/dist/generated/release-images.d.ts +18 -0
- package/dist/generated/release-images.d.ts.map +1 -0
- package/dist/generated/release-images.js +8 -0
- package/dist/generated/release-images.js.map +1 -0
- package/dist/generated-files-engine.d.ts +33 -0
- package/dist/generated-files-engine.d.ts.map +1 -0
- package/dist/generated-files-engine.js +45 -0
- package/dist/generated-files-engine.js.map +1 -0
- package/dist/hook-actor.d.ts +17 -0
- package/dist/hook-actor.d.ts.map +1 -0
- package/dist/hook-actor.js +37 -0
- package/dist/hook-actor.js.map +1 -0
- package/dist/hook-columns.d.ts +30 -0
- package/dist/hook-columns.d.ts.map +1 -0
- package/dist/hook-columns.js +77 -0
- package/dist/hook-columns.js.map +1 -0
- package/dist/hook-events.d.ts +11 -0
- package/dist/hook-events.d.ts.map +1 -0
- package/dist/hook-events.js +11 -0
- package/dist/hook-events.js.map +1 -0
- package/dist/hook-upload.d.ts +29 -15
- package/dist/hook-upload.d.ts.map +1 -1
- package/dist/hook-upload.js +88 -59
- package/dist/hook-upload.js.map +1 -1
- package/dist/hooks-generator.d.ts +5 -0
- package/dist/hooks-generator.d.ts.map +1 -1
- package/dist/hooks-generator.js +92 -21
- package/dist/hooks-generator.js.map +1 -1
- package/dist/host-database.d.ts.map +1 -1
- package/dist/host-database.js +31 -4
- package/dist/host-database.js.map +1 -1
- package/dist/init-dependency-versions.d.ts +3 -1
- package/dist/init-dependency-versions.d.ts.map +1 -1
- package/dist/init-dependency-versions.js +32 -6
- package/dist/init-dependency-versions.js.map +1 -1
- package/dist/init-example.d.ts +48 -0
- package/dist/init-example.d.ts.map +1 -0
- package/dist/init-example.js +110 -0
- package/dist/init-example.js.map +1 -0
- package/dist/init-package-json.d.ts +38 -1
- package/dist/init-package-json.d.ts.map +1 -1
- package/dist/init-package-json.js +150 -37
- package/dist/init-package-json.js.map +1 -1
- package/dist/init-setup-steps.d.ts +37 -0
- package/dist/init-setup-steps.d.ts.map +1 -0
- package/dist/init-setup-steps.js +118 -0
- package/dist/init-setup-steps.js.map +1 -0
- package/dist/jwt-secret-length.d.ts +5 -13
- package/dist/jwt-secret-length.d.ts.map +1 -1
- package/dist/jwt-secret-length.js +7 -22
- package/dist/jwt-secret-length.js.map +1 -1
- package/dist/jwt-secret-rules.d.ts +24 -0
- package/dist/jwt-secret-rules.d.ts.map +1 -0
- package/dist/jwt-secret-rules.js +46 -0
- package/dist/jwt-secret-rules.js.map +1 -0
- package/dist/local-gateway.d.ts +3 -6
- package/dist/local-gateway.d.ts.map +1 -1
- package/dist/local-gateway.js +7 -9
- package/dist/local-gateway.js.map +1 -1
- package/dist/local-secrets.d.ts +95 -11
- package/dist/local-secrets.d.ts.map +1 -1
- package/dist/local-secrets.js +153 -18
- package/dist/local-secrets.js.map +1 -1
- package/dist/local-stack.d.ts.map +1 -1
- package/dist/local-stack.js +2 -7
- package/dist/local-stack.js.map +1 -1
- package/dist/local-storage.d.ts +7 -2
- package/dist/local-storage.d.ts.map +1 -1
- package/dist/local-storage.js +11 -3
- package/dist/local-storage.js.map +1 -1
- package/dist/mailer-env.d.ts +37 -0
- package/dist/mailer-env.d.ts.map +1 -0
- package/dist/mailer-env.js +98 -0
- package/dist/mailer-env.js.map +1 -0
- package/dist/model-cache.d.ts +4 -8
- package/dist/model-cache.d.ts.map +1 -1
- package/dist/model-cache.js.map +1 -1
- package/dist/model-hooks.d.ts +21 -7
- package/dist/model-hooks.d.ts.map +1 -1
- package/dist/model-hooks.js +62 -39
- package/dist/model-hooks.js.map +1 -1
- package/dist/native-dev-env.d.ts +37 -1
- package/dist/native-dev-env.d.ts.map +1 -1
- package/dist/native-dev-env.js +64 -2
- package/dist/native-dev-env.js.map +1 -1
- package/dist/native-functions-watch.d.ts +56 -5
- package/dist/native-functions-watch.d.ts.map +1 -1
- package/dist/native-functions-watch.js +119 -38
- package/dist/native-functions-watch.js.map +1 -1
- package/dist/native-keyspace.d.ts.map +1 -1
- package/dist/native-keyspace.js +2 -2
- package/dist/native-keyspace.js.map +1 -1
- package/dist/native-realtime.d.ts +11 -3
- package/dist/native-realtime.d.ts.map +1 -1
- package/dist/native-realtime.js +162 -10
- package/dist/native-realtime.js.map +1 -1
- package/dist/native-roles-sql.d.ts +14 -0
- package/dist/native-roles-sql.d.ts.map +1 -1
- package/dist/native-roles-sql.js +82 -1
- package/dist/native-roles-sql.js.map +1 -1
- package/dist/native-storage-import.d.ts +19 -0
- package/dist/native-storage-import.d.ts.map +1 -0
- package/dist/native-storage-import.js +327 -0
- package/dist/native-storage-import.js.map +1 -0
- package/dist/native-storage.d.ts +45 -0
- package/dist/native-storage.d.ts.map +1 -0
- package/dist/native-storage.js +140 -0
- package/dist/native-storage.js.map +1 -0
- package/dist/native-worker.d.ts +26 -0
- package/dist/native-worker.d.ts.map +1 -0
- package/dist/native-worker.js +63 -0
- package/dist/native-worker.js.map +1 -0
- package/dist/owner-default.d.ts +9 -1
- package/dist/owner-default.d.ts.map +1 -1
- package/dist/owner-default.js +17 -4
- package/dist/owner-default.js.map +1 -1
- package/dist/post-apply.d.ts +3 -0
- package/dist/post-apply.d.ts.map +1 -0
- package/dist/post-apply.js +17 -0
- package/dist/post-apply.js.map +1 -0
- package/dist/postgres-ctl.d.ts +98 -7
- package/dist/postgres-ctl.d.ts.map +1 -1
- package/dist/postgres-ctl.js +273 -40
- package/dist/postgres-ctl.js.map +1 -1
- package/dist/postgres-image.d.ts +15 -3
- package/dist/postgres-image.d.ts.map +1 -1
- package/dist/postgres-image.js +18 -15
- package/dist/postgres-image.js.map +1 -1
- package/dist/postgrest-release.d.ts +9 -0
- package/dist/postgrest-release.d.ts.map +1 -1
- package/dist/postgrest-release.js +23 -0
- package/dist/postgrest-release.js.map +1 -1
- package/dist/process-manager.d.ts.map +1 -1
- package/dist/process-manager.js +3 -1
- package/dist/process-manager.js.map +1 -1
- package/dist/project-config.d.ts +44 -7
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +48 -4
- package/dist/project-config.js.map +1 -1
- package/dist/pull-utils.d.ts +15 -0
- package/dist/pull-utils.d.ts.map +1 -1
- package/dist/pull-utils.js +149 -23
- package/dist/pull-utils.js.map +1 -1
- package/dist/push-refusal.d.ts.map +1 -1
- package/dist/push-refusal.js +3 -2
- package/dist/push-refusal.js.map +1 -1
- package/dist/realtime-launch.d.ts +2 -5
- package/dist/realtime-launch.d.ts.map +1 -1
- package/dist/realtime-launch.js +6 -23
- package/dist/realtime-launch.js.map +1 -1
- package/dist/recorded-field-masking-tier.d.ts.map +1 -1
- package/dist/recorded-field-masking-tier.js +4 -3
- package/dist/recorded-field-masking-tier.js.map +1 -1
- package/dist/release-images.d.ts +31 -0
- package/dist/release-images.d.ts.map +1 -0
- package/dist/release-images.js +90 -0
- package/dist/release-images.js.map +1 -0
- package/dist/required-host-components.d.ts.map +1 -1
- package/dist/required-host-components.js +4 -0
- package/dist/required-host-components.js.map +1 -1
- package/dist/resolve-api-url.d.ts +17 -3
- package/dist/resolve-api-url.d.ts.map +1 -1
- package/dist/resolve-api-url.js +71 -30
- package/dist/resolve-api-url.js.map +1 -1
- package/dist/resolve-target.d.ts +64 -0
- package/dist/resolve-target.d.ts.map +1 -1
- package/dist/resolve-target.js +75 -27
- package/dist/resolve-target.js.map +1 -1
- package/dist/rest-ready.d.ts.map +1 -1
- package/dist/rest-ready.js +2 -1
- package/dist/rest-ready.js.map +1 -1
- package/dist/route-manifest.d.ts +25 -2
- package/dist/route-manifest.d.ts.map +1 -1
- package/dist/route-manifest.js +48 -4
- package/dist/route-manifest.js.map +1 -1
- package/dist/run-until-stopped.d.ts +12 -0
- package/dist/run-until-stopped.d.ts.map +1 -0
- package/dist/run-until-stopped.js +42 -0
- package/dist/run-until-stopped.js.map +1 -0
- package/dist/schema-ast-v2.d.ts +2 -1
- package/dist/schema-ast-v2.d.ts.map +1 -1
- package/dist/schema-ast-v2.js.map +1 -1
- package/dist/schema-push-lock.d.ts.map +1 -1
- package/dist/schema-push-lock.js +59 -46
- package/dist/schema-push-lock.js.map +1 -1
- package/dist/schema-sources.d.ts +19 -4
- package/dist/schema-sources.d.ts.map +1 -1
- package/dist/schema-sources.js +56 -35
- package/dist/schema-sources.js.map +1 -1
- package/dist/seed-auth-connect.d.ts +14 -0
- package/dist/seed-auth-connect.d.ts.map +1 -0
- package/dist/seed-auth-connect.js +97 -0
- package/dist/seed-auth-connect.js.map +1 -0
- package/dist/seed-runner.d.ts.map +1 -1
- package/dist/seed-runner.js +22 -1
- package/dist/seed-runner.js.map +1 -1
- package/dist/seed.d.ts +6 -3
- package/dist/seed.d.ts.map +1 -1
- package/dist/self-host-compose.d.ts +44 -29
- package/dist/self-host-compose.d.ts.map +1 -1
- package/dist/self-host-compose.js +311 -159
- package/dist/self-host-compose.js.map +1 -1
- package/dist/service-role-key-file.d.ts +32 -0
- package/dist/service-role-key-file.d.ts.map +1 -0
- package/dist/service-role-key-file.js +90 -0
- package/dist/service-role-key-file.js.map +1 -0
- package/dist/shell-ports.d.ts +13 -2
- package/dist/shell-ports.d.ts.map +1 -1
- package/dist/shell-ports.js +20 -15
- package/dist/shell-ports.js.map +1 -1
- package/dist/stop-signals.d.ts +7 -0
- package/dist/stop-signals.d.ts.map +1 -0
- package/dist/stop-signals.js +12 -0
- package/dist/stop-signals.js.map +1 -0
- package/dist/storage-launch.d.ts +11 -0
- package/dist/storage-launch.d.ts.map +1 -0
- package/dist/storage-launch.js +41 -0
- package/dist/storage-launch.js.map +1 -0
- package/dist/storage-provision.d.ts +50 -5
- package/dist/storage-provision.d.ts.map +1 -1
- package/dist/storage-provision.js +101 -33
- package/dist/storage-provision.js.map +1 -1
- package/dist/systemd.d.ts +1 -1
- package/dist/systemd.d.ts.map +1 -1
- package/dist/systemd.js +26 -11
- package/dist/systemd.js.map +1 -1
- package/dist/tar-reader.d.ts +29 -0
- package/dist/tar-reader.d.ts.map +1 -0
- package/dist/tar-reader.js +99 -0
- package/dist/tar-reader.js.map +1 -0
- package/dist/target-client.d.ts +14 -1
- package/dist/target-client.d.ts.map +1 -1
- package/dist/target-client.js +134 -23
- package/dist/target-client.js.map +1 -1
- package/dist/target-request.d.ts +25 -0
- package/dist/target-request.d.ts.map +1 -0
- package/dist/target-request.js +33 -0
- package/dist/target-request.js.map +1 -0
- package/dist/target-warning.d.ts +7 -0
- package/dist/target-warning.d.ts.map +1 -0
- package/dist/target-warning.js +12 -0
- package/dist/target-warning.js.map +1 -0
- package/dist/tsx-runner.d.ts.map +1 -1
- package/dist/tsx-runner.js +2 -1
- package/dist/tsx-runner.js.map +1 -1
- package/dist/type-extractor.d.ts +6 -0
- package/dist/type-extractor.d.ts.map +1 -1
- package/dist/type-extractor.js +138 -70
- package/dist/type-extractor.js.map +1 -1
- package/dist/ui/clack.d.ts.map +1 -1
- package/dist/ui/clack.js +11 -1
- package/dist/ui/clack.js.map +1 -1
- package/dist/ui/dev/DevDashboard.d.ts.map +1 -1
- package/dist/ui/dev/DevDashboard.js +13 -5
- package/dist/ui/dev/DevDashboard.js.map +1 -1
- package/dist/ui/fatal.d.ts.map +1 -1
- package/dist/ui/fatal.js +6 -7
- package/dist/ui/fatal.js.map +1 -1
- package/dist/ui/flows/FlowApp.d.ts.map +1 -1
- package/dist/ui/flows/FlowApp.js +16 -1
- package/dist/ui/flows/FlowApp.js.map +1 -1
- package/dist/ui/flows/prompt-fields.d.ts +16 -6
- package/dist/ui/flows/prompt-fields.d.ts.map +1 -1
- package/dist/ui/flows/prompt-fields.js +19 -9
- package/dist/ui/flows/prompt-fields.js.map +1 -1
- package/dist/ui/messages.d.ts +6 -0
- package/dist/ui/messages.d.ts.map +1 -1
- package/dist/ui/messages.js +17 -0
- package/dist/ui/messages.js.map +1 -1
- package/dist/ui/progress.d.ts +7 -0
- package/dist/ui/progress.d.ts.map +1 -1
- package/dist/ui/progress.js +22 -8
- package/dist/ui/progress.js.map +1 -1
- package/dist/ui/runtime/command-chrome.d.ts.map +1 -1
- package/dist/ui/runtime/command-chrome.js +2 -0
- package/dist/ui/runtime/command-chrome.js.map +1 -1
- package/dist/ui/runtime/prompt-interrupt.d.ts +10 -0
- package/dist/ui/runtime/prompt-interrupt.d.ts.map +1 -0
- package/dist/ui/runtime/prompt-interrupt.js +24 -0
- package/dist/ui/runtime/prompt-interrupt.js.map +1 -0
- package/dist/ui/runtime/run-clack-flow.d.ts.map +1 -1
- package/dist/ui/runtime/run-clack-flow.js +5 -2
- package/dist/ui/runtime/run-clack-flow.js.map +1 -1
- package/dist/ui/runtime/stdin-after-ink.d.ts +14 -1
- package/dist/ui/runtime/stdin-after-ink.d.ts.map +1 -1
- package/dist/ui/runtime/stdin-after-ink.js +44 -3
- package/dist/ui/runtime/stdin-after-ink.js.map +1 -1
- package/dist/url-safe-passwords.d.ts +25 -0
- package/dist/url-safe-passwords.d.ts.map +1 -0
- package/dist/url-safe-passwords.js +70 -0
- package/dist/url-safe-passwords.js.map +1 -0
- package/dist/valkey-sidecar.d.ts +33 -6
- package/dist/valkey-sidecar.d.ts.map +1 -1
- package/dist/valkey-sidecar.js +90 -61
- package/dist/valkey-sidecar.js.map +1 -1
- package/dist/worker-module-files.d.ts +3 -0
- package/dist/worker-module-files.d.ts.map +1 -0
- package/dist/worker-module-files.js +18 -0
- package/dist/worker-module-files.js.map +1 -0
- package/package.json +22 -16
- package/dist/functions-router-gen.d.ts.map +0 -1
- package/dist/functions-router-gen.js +0 -302
- package/dist/functions-router-gen.js.map +0 -1
package/dist/dev-compose.js
CHANGED
|
@@ -1,47 +1,53 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `supatype dev` when `provider: docker`, full self-host Compose stack (Kong gateway).
|
|
3
3
|
*/
|
|
4
|
+
import { setTimeout as sleep } from "node:timers/promises";
|
|
4
5
|
import { projectOutputPaths, writeAstDerivedOutputs, writeSeedBuilder } from "./type-generation.js";
|
|
5
6
|
import { errorMessage } from "./error-message.js";
|
|
7
|
+
import { warn } from "./ui/messages.js";
|
|
8
|
+
import { FRONTEND_URL_KEYS, frontendEnv, writeFrontendEnv } from "./frontend-env.js";
|
|
6
9
|
import { withPublishing } from "./model-versioning.js";
|
|
7
10
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
8
11
|
import { homedir } from "node:os";
|
|
9
12
|
import { dirname, join } from "node:path";
|
|
10
|
-
import {
|
|
13
|
+
import { askDocker, askDockerSync, DOCKER_EXEC_TIMEOUT_MS, DOCKER_QUERY_TIMEOUT_MS } from "./docker-exec.js";
|
|
11
14
|
import { startProxyDevApp, resolveProxyDevScript } from "./app/proxy-dev-app.js";
|
|
12
15
|
import { loadSchemaAst, projectNameInFile } from "./config.js";
|
|
13
16
|
import { withComposeSchemaPushLock } from "./schema-push-lock.js";
|
|
14
17
|
import { recordDatabaseTier, sameApiSurface } from "./recorded-field-masking-tier.js";
|
|
15
|
-
import { connectionString, pgSchema, projectRootFromConfig, resolveRuntimeProvider,
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
+
import { connectionString, pgSchema, projectRootFromConfig, resolveRuntimeProvider, schemaPathFromProject, selfHostTlsEnabled, usesExternalDatabase, } from "./project-config.js";
|
|
19
|
+
import { rowCacheChangeNote } from "./model-cache.js";
|
|
20
|
+
import { writeAppliedAstArtifacts } from "./applied-ast-artifacts.js";
|
|
18
21
|
import { anonKeyEnvUpdates } from "./commands/keys.js";
|
|
19
22
|
import { devApiKeys } from "./dev-api-keys.js";
|
|
23
|
+
import { warnUrlUnsafeComposePasswords } from "./url-safe-passwords.js";
|
|
20
24
|
import { astRelatesToAuthUsers } from "./byo-preflight.js";
|
|
21
25
|
import { ensureDevDbPort, ensureKongPort } from "./dev-ports.js";
|
|
22
26
|
import { applyForThisRun, splitShellPortUpdates } from "./shell-ports.js";
|
|
23
27
|
import { handleComposeProjectRename } from "./compose-rename.js";
|
|
24
28
|
import { devSessionLockFor, recoverStaleDevSession, writeDevSessionLock } from "./dev-session-lock.js";
|
|
25
|
-
import { endDevSession, startDevSession } from "./dev-session.js";
|
|
29
|
+
import { endDevSession, showDevStep, startDevSession } from "./dev-session.js";
|
|
26
30
|
import { ensureDevApiConfig } from "./ensure-dev-api-config.js";
|
|
27
31
|
import { cacheSeedingNotes } from "./api-config-cache.js";
|
|
28
|
-
import { refreshFunctionsContext } from "./functions-context-refresh.js";
|
|
29
32
|
import { restartComposeFunctionsWorker, watchFunctionSources } from "./dev-functions-watch.js";
|
|
30
33
|
import { watchDevSchema } from "./dev-schema-watch.js";
|
|
31
|
-
import {
|
|
34
|
+
import { offerToSaveShellDbPort } from "./db-port-offer.js";
|
|
35
|
+
import { databaseUrlSyncMessage } from "./db-port.js";
|
|
36
|
+
import { databaseUrlState, setCliDatabaseUrlForRun, syncDatabaseUrlPort, warnIfHandWrittenUrlSilent, writeCliDatabaseUrl, } from "./database-url-owner.js";
|
|
32
37
|
import { degraded } from "./strict.js";
|
|
38
|
+
import { ENGINE_FALLBACK, generatedFilesEngine } from "./generated-files-engine.js";
|
|
33
39
|
import { DEV_DESTRUCTIVE_POLICY, consentDepsFromDiff, pushConsentingToDestructive } from "./destructive-consent.js";
|
|
34
40
|
import { auditFlags, auditWhenSupported } from "./push-audit.js";
|
|
35
41
|
import { consentRefusal, reportDevPushFailure } from "./push-refusal.js";
|
|
36
|
-
import { COMPOSE_PINNED_IMAGE_ENV_KEYS, composeDockerImageEnv, composeProjectName, exitComposeFailed, publishesDbToHost, runDockerCompose, schemaEngineImageForPush, writeSelfHostCompose, composeFieldMaskingTier, selfHostComposePaths, } from "./self-host-compose.js";
|
|
42
|
+
import { COMPOSE_PINNED_IMAGE_ENV_KEYS, composeDockerImageEnv, composeProjectName, exitComposeFailed, noteUnpinnedImages, publishesDbToHost, runDockerCompose, runDockerComposeQuietly, settleComposeRuns, schemaEngineImageForPush, writeSelfHostCompose, composeFieldMaskingTier, selfHostComposePaths, } from "./self-host-compose.js";
|
|
37
43
|
import { composeServiceIsRunning } from "./compose-kong.js";
|
|
38
44
|
import { hasEngineOverride } from "./binary-cache.js";
|
|
39
45
|
import { STUDIO_DEV_PORT, startStudioViteDevServer } from "./studio-dev-server.js";
|
|
40
46
|
import { ensureLocalServerDockerImage, usesLocalServerImage, LOCAL_SERVER_DOCKER_IMAGE, } from "./compose-local-server-image.js";
|
|
41
47
|
import { ensureEngine, enginePush, engineRequest } from "./engine-client.js";
|
|
42
|
-
import { isAdoptOutcome, isAnyAnswer, isDiffResult, isEnginePushResult, isGenerateAnswer,
|
|
48
|
+
import { isAdoptOutcome, isAnyAnswer, isDiffResult, isEnginePushResult, isGenerateAnswer, } from "./engine-answers.js";
|
|
43
49
|
import { writeSchemaSourcePushArtifacts } from "./schema-sources.js";
|
|
44
|
-
import { readEnvValue, upsertEnvFile } from "./env-file.js";
|
|
50
|
+
import { readEnvFile, readEnvValue, upsertEnvFile } from "./env-file.js";
|
|
45
51
|
import { warnProjectAuthProviderSecrets } from "./auth-providers.js";
|
|
46
52
|
import { devDatabaseIdentity, devDatabaseUrl, seedMissingDatabaseIdentity, seedMissingLocalSecrets, } from "./local-secrets.js";
|
|
47
53
|
import { writeLocalEnvironment } from "./link.js";
|
|
@@ -49,13 +55,13 @@ import { registerDevShutdown, waitForDevShutdown } from "./dev-shutdown.js";
|
|
|
49
55
|
import { filterComposeNoise, parseEngineJsonOutput, parseEnginePushOutput, reportAppliedPush, } from "./engine-push-output.js";
|
|
50
56
|
import { withAdminRoles } from "./studio-admin-roles.js";
|
|
51
57
|
import { restoreSystemRelationTargets } from "./restore-system-relation-targets.js";
|
|
52
|
-
import { provisionBucketsFromAst } from "./storage-provision.js";
|
|
58
|
+
import { provisionBucketsFromAst, unprovisionedBuckets } from "./storage-provision.js";
|
|
53
59
|
import { ensureFirstAdminUserForProject } from "./commands/admin.js";
|
|
54
60
|
import { demoDataHint, publishDevReady } from "./dev-ready-panel.js";
|
|
55
61
|
import { pushInitialSchema, settleInitialPush } from "./dev-initial-push.js";
|
|
56
62
|
import { offerAdoption, targetAdoptionSteps } from "./adopt-walkthrough.js";
|
|
57
63
|
import { resetDevDatabase } from "./dev-db-reset.js";
|
|
58
|
-
import { adoptKeysNeed, assertSupported, engineCapabilities, identityColumnsNeed, OVERWRITE_DRIFT_NEED,
|
|
64
|
+
import { adoptKeysNeed, assertSupported, engineCapabilities, identityColumnsNeed, OVERWRITE_DRIFT_NEED, checkedCapabilities, } from "./engine-ownership-gate.js";
|
|
59
65
|
import { devPushConsentingToDrift } from "./drift-consent.js";
|
|
60
66
|
import { capabilitiesCache, rememberCapabilitiesSync } from "@supatype/shared";
|
|
61
67
|
import { waitForDatabaseAfterUp } from "./dev-db-ready.js";
|
|
@@ -66,9 +72,24 @@ import { spawnComposeEngine } from "./compose-engine-run.js";
|
|
|
66
72
|
import { waitForRestReady } from "./rest-ready.js";
|
|
67
73
|
import { claimDevRenderMode, composeRenderMode, composeRenderOptions } from "./compose-render-mode.js";
|
|
68
74
|
import { devMailerAutoconfirmUpdate, MAILER_AUTOCONFIRM_ENV } from "./mailer-autoconfirm.js";
|
|
75
|
+
import { mailerProviderEnv } from "./mailer-env.js";
|
|
76
|
+
import { fetchWithin } from "./fetch-within.js";
|
|
77
|
+
import { assertEngineVersionSupported, engineImageVersion } from "./engine-floor.js";
|
|
78
|
+
/**
|
|
79
|
+
* The image pins config asks for, once the engine's is known not to be older than this CLI needs.
|
|
80
|
+
* Checked before `.env` is written: a push refused the engine after writing its pin there as a
|
|
81
|
+
* managed line, and `.env` stayed pinned to the refused engine (local test round 6).
|
|
82
|
+
*/
|
|
83
|
+
function checkedImagePins(config) {
|
|
84
|
+
const pins = composeDockerImageEnv(config);
|
|
85
|
+
const engine = pins["SUPATYPE_ENGINE_IMAGE"];
|
|
86
|
+
if (engine !== undefined)
|
|
87
|
+
assertEngineVersionSupported(engineImageVersion(engine), "versions.engine in supatype.config.ts", "image");
|
|
88
|
+
return pins;
|
|
89
|
+
}
|
|
69
90
|
/** Sync optional Docker image pins from config into `.env` (no JWT rotation). */
|
|
70
91
|
export function syncComposeImagePins(cwd, config) {
|
|
71
|
-
const imagePins =
|
|
92
|
+
const imagePins = checkedImagePins(config);
|
|
72
93
|
// Clean up only what a previous run wrote from config. A hand-written image tag in `.env` is the
|
|
73
94
|
// documented way to run a local build, and this used to delete it on every compose run.
|
|
74
95
|
const removeImageKeys = COMPOSE_PINNED_IMAGE_ENV_KEYS.filter((key) => !(key in imagePins));
|
|
@@ -170,39 +191,6 @@ export async function projectComposeEngine(cwd, config) {
|
|
|
170
191
|
capabilities: () => dockerEngineCapabilities(cwd, config),
|
|
171
192
|
};
|
|
172
193
|
}
|
|
173
|
-
/**
|
|
174
|
-
* `email.provider` and `email.smtp` for the compose server service.
|
|
175
|
-
*
|
|
176
|
-
* The native dev path has mapped these since it existed; the compose path never
|
|
177
|
-
* did, so a project that asked for smtp got the auth service's noop client and
|
|
178
|
-
* no message at all. Console is the documented default, and it at least says
|
|
179
|
-
* that a message would have been sent.
|
|
180
|
-
*/
|
|
181
|
-
function composeMailerEnv(config) {
|
|
182
|
-
const email = config.email;
|
|
183
|
-
const out = {
|
|
184
|
-
// Mailer.MailerProvider, so the doubled word is the real name.
|
|
185
|
-
SUPATYPE_MAILER_MAILER_PROVIDER: email?.provider ?? "console",
|
|
186
|
-
};
|
|
187
|
-
const smtp = email?.smtp;
|
|
188
|
-
if (email?.provider !== "smtp" || smtp === undefined)
|
|
189
|
-
return out;
|
|
190
|
-
if (smtp.host !== undefined && smtp.host !== "")
|
|
191
|
-
out.SUPATYPE_SMTP_HOST = smtp.host;
|
|
192
|
-
if (smtp.port !== undefined)
|
|
193
|
-
out.SUPATYPE_SMTP_PORT = String(smtp.port);
|
|
194
|
-
if (smtp.user !== undefined && smtp.user !== "")
|
|
195
|
-
out.SUPATYPE_SMTP_USER = smtp.user;
|
|
196
|
-
if (smtp.pass !== undefined && smtp.pass !== "")
|
|
197
|
-
out.SUPATYPE_SMTP_PASS = smtp.pass;
|
|
198
|
-
if (smtp.admin_email !== undefined && smtp.admin_email !== "") {
|
|
199
|
-
out.SUPATYPE_SMTP_ADMIN_EMAIL = smtp.admin_email;
|
|
200
|
-
}
|
|
201
|
-
if (smtp.sender_name !== undefined && smtp.sender_name !== "") {
|
|
202
|
-
out.SUPATYPE_SMTP_SENDER_NAME = smtp.sender_name;
|
|
203
|
-
}
|
|
204
|
-
return out;
|
|
205
|
-
}
|
|
206
194
|
async function resolveKongPort(cwd, composeProject) {
|
|
207
195
|
// The compose project is passed so an already-running stack of *this* project counts as
|
|
208
196
|
// available rather than as a collision.
|
|
@@ -215,14 +203,16 @@ async function resolveKongPort(cwd, composeProject) {
|
|
|
215
203
|
* already running, and its readiness is the operator's, `supatype db check` is what reports on it.
|
|
216
204
|
* Four call sites did this inline, so an external project hit `compose up -d db` against a compose
|
|
217
205
|
* file that deliberately has no `db`.
|
|
206
|
+
*
|
|
207
|
+
* Warns rather than refuses about a URL-unsafe password. dev has refused before it gets here, and
|
|
208
|
+
* push and diff are not stopped over a database that starts either way: the warning names the
|
|
209
|
+
* cause before any connection failure it leads to.
|
|
218
210
|
*/
|
|
219
211
|
async function startComposeDatabase(config, paths, cwd, project, brand, timeoutMs = 120_000, onFailure) {
|
|
220
212
|
if (usesExternalDatabase(config))
|
|
221
213
|
return;
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
...(brand !== undefined && { brand }),
|
|
225
|
-
});
|
|
214
|
+
warnUrlUnsafeComposePasswords(cwd, config);
|
|
215
|
+
const up = await runDockerComposeQuietly(paths.composePath, ["up", "-d", "db"], cwd, project, brand);
|
|
226
216
|
if (up !== 0) {
|
|
227
217
|
onFailure?.();
|
|
228
218
|
exitComposeFailed(up, "Could not start Postgres (compose db service).", brand);
|
|
@@ -231,7 +221,7 @@ async function startComposeDatabase(config, paths, cwd, project, brand, timeoutM
|
|
|
231
221
|
}
|
|
232
222
|
export function upsertDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPort, devDbPort) {
|
|
233
223
|
const apiUrl = `http://localhost:${kongPort}`;
|
|
234
|
-
const imagePins =
|
|
224
|
+
const imagePins = checkedImagePins(config);
|
|
235
225
|
// `POSTGRES_PASSWORD` and `JWT_SECRET` are deliberately absent.
|
|
236
226
|
//
|
|
237
227
|
// They used to be pinned here to published constants on every `dev` run, against the same
|
|
@@ -251,19 +241,18 @@ export function upsertDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPo
|
|
|
251
241
|
...seedMissingLocalSecrets(cwd, config),
|
|
252
242
|
// Project configuration, seeded not overwritten, see seedMissingDatabaseIdentity.
|
|
253
243
|
...seedMissingDatabaseIdentity(cwd, config),
|
|
254
|
-
// Shared with `supatype keys --write`, so a
|
|
255
|
-
//
|
|
256
|
-
|
|
257
|
-
// This list used to live here as well, and the two had already drifted: `dev` wrote
|
|
258
|
-
// PUBLIC_ and EXPO_PUBLIC_ URLs and no VITE_SUPATYPE_URL, so a Vite app whose `.env` had only
|
|
259
|
-
// ever been touched by `supatype dev` built against an empty string.
|
|
260
|
-
...anonKeyEnvUpdates(anonKey, serviceRoleKey, apiUrl),
|
|
244
|
+
// Shared with `supatype keys --write`, so a name cannot be written by one and forgotten by the
|
|
245
|
+
// other. See `anonKeyEnvUpdates`. The front end's copies are written below, not here.
|
|
246
|
+
...anonKeyEnvUpdates(anonKey, serviceRoleKey),
|
|
261
247
|
SUPATYPE_KONG_PORT: String(kongPort),
|
|
262
248
|
API_EXTERNAL_URL: apiUrl,
|
|
263
249
|
SITE_URL: apiUrl,
|
|
264
250
|
// From auth.email.enableConfirmations, unless the developer set their own in .env.
|
|
265
251
|
...devMailerAutoconfirmUpdate(cwd, config),
|
|
266
|
-
|
|
252
|
+
// email.provider and its settings, which the compose file passes to the server. The compose
|
|
253
|
+
// path used to carry none of them, so a project that asked for smtp, Resend or SES got the auth
|
|
254
|
+
// service's noop client and no message at all.
|
|
255
|
+
...mailerProviderEnv(config.email),
|
|
267
256
|
...imagePins,
|
|
268
257
|
};
|
|
269
258
|
// Never for an external database: this URL describes the `db` container, which that project does
|
|
@@ -271,13 +260,8 @@ export function upsertDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPo
|
|
|
271
260
|
// every CLI command reads, with a DSN pointing at a database that does not exist. Found by
|
|
272
261
|
// rehearsing a push against a real external Postgres, where the compose guard then refused to
|
|
273
262
|
// proceed because .env and the config disagreed. They disagreed because of this line.
|
|
274
|
-
if (devDbPort !== undefined && !usesExternalDatabase(config))
|
|
263
|
+
if (devDbPort !== undefined && !usesExternalDatabase(config))
|
|
275
264
|
updates.SUPATYPE_DEV_DB_PORT = String(devDbPort);
|
|
276
|
-
// User and database from the project, not hardcoded, same reason as
|
|
277
|
-
// `seedMissingDatabaseIdentity`: a project not named "supatype" had this URL pointing at a
|
|
278
|
-
// database that does not exist.
|
|
279
|
-
updates.DATABASE_URL = hostComposeDbUrl(cwd, devDbPort);
|
|
280
|
-
}
|
|
281
265
|
// `SUPATYPE_SERVER_IMAGE` is written here, not passed in, and it is deliberately *not* marked
|
|
282
266
|
// managed. The managed marker means "this value came from `versions` in the config and is mine to
|
|
283
267
|
// clean up when the pin goes away". The locally built image comes from `overrides`, so removing
|
|
@@ -294,21 +278,52 @@ export function upsertDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPo
|
|
|
294
278
|
// write is removed: an operator's own GOTRUE_ variable is theirs, and the server's error names it
|
|
295
279
|
// and its replacement precisely enough to fix by hand.
|
|
296
280
|
const retiredKeys = ["GOTRUE_MAILER_AUTOCONFIRM"];
|
|
297
|
-
// A port the shell gave for this run is the run's, not the project's (DR9).
|
|
298
|
-
const
|
|
281
|
+
// A port the shell gave for this run is the run's, not the project's (DR9), unless `.env` holds it too.
|
|
282
|
+
const dotEnv = readEnvFile(cwd);
|
|
283
|
+
const { persist, runOnly } = splitShellPortUpdates({ ...updates, ...frontendEnv({ apiUrl }) }, process.env, dotEnv);
|
|
299
284
|
applyForThisRun(runOnly);
|
|
300
|
-
|
|
285
|
+
const { urlsKept, rest } = takeFrontendUrls(persist);
|
|
286
|
+
upsertEnvFile(cwd, rest, {
|
|
301
287
|
removeManaged: removeImageKeys,
|
|
302
288
|
managed: [...managedImageKeys, MAILER_AUTOCONFIRM_ENV],
|
|
303
|
-
|
|
304
|
-
// compose at a stale build, and it carries no marker for `removeManaged` to act on.
|
|
305
|
-
remove: [
|
|
306
|
-
...retiredKeys,
|
|
307
|
-
...(!wantsLocalServer && !("SUPATYPE_SERVER_IMAGE" in imagePins)
|
|
308
|
-
? ["SUPATYPE_SERVER_IMAGE"]
|
|
309
|
-
: []),
|
|
310
|
-
],
|
|
289
|
+
remove: [...retiredKeys, ...staleLocalServerImage(dotEnv["SUPATYPE_SERVER_IMAGE"], wantsLocalServer, imagePins)],
|
|
311
290
|
});
|
|
291
|
+
// The front end's copies go where a development build reads them, not .env, which a production
|
|
292
|
+
// build reads (frontend-env.ts). The URL only when it is the project's port, not the shell's.
|
|
293
|
+
writeFrontendEnv(cwd, { anonKey, ...(urlsKept && { apiUrl }) }, { local: true });
|
|
294
|
+
if (devDbPort !== undefined && !usesExternalDatabase(config)) {
|
|
295
|
+
writeDevStackDatabaseUrl(cwd, devDbPort, runOnly.SUPATYPE_DEV_DB_PORT !== undefined);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
/** `persist` less the front-end URL names, and whether they were among what is kept. */
|
|
299
|
+
function takeFrontendUrls(persist) {
|
|
300
|
+
const names = new Set(FRONTEND_URL_KEYS);
|
|
301
|
+
const rest = Object.fromEntries(Object.entries(persist).filter(([key]) => !names.has(key)));
|
|
302
|
+
return { urlsKept: FRONTEND_URL_KEYS.every((key) => key in persist), rest };
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* `SUPATYPE_SERVER_IMAGE` to remove from `.env`: the local-dev image this CLI wrote, once the project
|
|
306
|
+
* stops asking for a local build and pins no server. It carries no marker for `removeManaged` to act
|
|
307
|
+
* on, and left behind it would keep pointing compose at a stale build. Any other value was set by
|
|
308
|
+
* hand, `supatype/server:it-r3` for instance, and is kept (local test round 3, N1).
|
|
309
|
+
*/
|
|
310
|
+
function staleLocalServerImage(current, wantsLocalServer, imagePins) {
|
|
311
|
+
if (wantsLocalServer || "SUPATYPE_SERVER_IMAGE" in imagePins)
|
|
312
|
+
return [];
|
|
313
|
+
return current?.trim() === LOCAL_SERVER_DOCKER_IMAGE ? ["SUPATYPE_SERVER_IMAGE"] : [];
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Docker dev's DATABASE_URL: the stack's database at `devDbPort`, with the project's own user and
|
|
317
|
+
* database, not hardcoded ones, which on a project not named "supatype" named a database that does
|
|
318
|
+
* not exist. Written over a URL the CLI owns, for this run only when the port is the shell's; one
|
|
319
|
+
* that is yours always wins (database-url-owner.ts).
|
|
320
|
+
*/
|
|
321
|
+
function writeDevStackDatabaseUrl(cwd, devDbPort, runOnly) {
|
|
322
|
+
const url = hostComposeDbUrl(cwd, devDbPort);
|
|
323
|
+
if (runOnly)
|
|
324
|
+
setCliDatabaseUrlForRun(databaseUrlState(cwd), url);
|
|
325
|
+
else
|
|
326
|
+
writeCliDatabaseUrl(cwd, url);
|
|
312
327
|
}
|
|
313
328
|
/** Keep compose + Studio on the same freshly signed dev JWTs; sync optional image pins from config. */
|
|
314
329
|
function ensureDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPort, devDbPort) {
|
|
@@ -339,7 +354,7 @@ async function waitComposeHealthy(paths, cwd, maxMs, composeProject) {
|
|
|
339
354
|
baseArgs.push("--env-file", envFile);
|
|
340
355
|
const deadline = Date.now() + maxMs;
|
|
341
356
|
while (Date.now() < deadline) {
|
|
342
|
-
const ready =
|
|
357
|
+
const ready = await askDocker(
|
|
343
358
|
// Over TCP, deliberately, not the Unix socket.
|
|
344
359
|
//
|
|
345
360
|
// On a first run the Postgres entrypoint starts a temporary server with `listen_addresses=''`
|
|
@@ -352,10 +367,10 @@ async function waitComposeHealthy(paths, cwd, maxMs, composeProject) {
|
|
|
352
367
|
[
|
|
353
368
|
...baseArgs, "exec", "-T", "db",
|
|
354
369
|
"pg_isready", "-h", "127.0.0.1", "-U", devDatabaseIdentity(cwd).user,
|
|
355
|
-
], { cwd: composeDir,
|
|
370
|
+
], { cwd: composeDir, timeoutMs: DOCKER_EXEC_TIMEOUT_MS });
|
|
356
371
|
if (ready.status === 0)
|
|
357
372
|
return;
|
|
358
|
-
await
|
|
373
|
+
await sleep(2000);
|
|
359
374
|
}
|
|
360
375
|
throw new Error("Compose db service did not become healthy in time");
|
|
361
376
|
}
|
|
@@ -373,12 +388,9 @@ function dumpComposeDbLogs(paths, cwd, composeProject, reason) {
|
|
|
373
388
|
if (existsSync(envFile))
|
|
374
389
|
args.push("--env-file", envFile);
|
|
375
390
|
args.push("logs", "--no-color", "--timestamps", "--tail", "800", "db");
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
maxBuffer: 10 * 1024 * 1024,
|
|
380
|
-
});
|
|
381
|
-
const body = `${result.stdout ?? ""}${result.stderr ?? ""}`.trim();
|
|
391
|
+
// Synchronous: called from the failure paths that then exit.
|
|
392
|
+
const result = askDockerSync(args, { cwd, timeoutMs: DOCKER_QUERY_TIMEOUT_MS });
|
|
393
|
+
const body = `${result.stdout}${result.stderr}`.trim();
|
|
382
394
|
const content = body || `(empty, docker compose logs db exit ${result.status ?? "?"})\n`;
|
|
383
395
|
try {
|
|
384
396
|
writeFileSync(logPath, content);
|
|
@@ -405,17 +417,6 @@ function dumpComposeDbLogs(paths, cwd, composeProject, reason) {
|
|
|
405
417
|
function loopbackBase(port) {
|
|
406
418
|
return `http://127.0.0.1:${port}`;
|
|
407
419
|
}
|
|
408
|
-
/**
|
|
409
|
-
* `fetch` with a deadline, because the built-in has none.
|
|
410
|
-
*
|
|
411
|
-
* A poll loop bounded by `maxSec` iterations is only bounded if each attempt can end. Against a
|
|
412
|
-
* socket that accepts and never responds, an un-timed `fetch` never settles, the loop never reaches
|
|
413
|
-
* its second iteration, and a wait advertised as 120 seconds runs until someone kills it. That is
|
|
414
|
-
* how `supatype push` came to hang indefinitely after reporting the schema applied.
|
|
415
|
-
*/
|
|
416
|
-
async function fetchWithin(url, ms, init) {
|
|
417
|
-
return await fetch(url, { ...init, signal: AbortSignal.timeout(ms) });
|
|
418
|
-
}
|
|
419
420
|
/**
|
|
420
421
|
* Print what the stack is doing when the gateway never comes up.
|
|
421
422
|
*
|
|
@@ -424,21 +425,19 @@ async function fetchWithin(url, ms, init) {
|
|
|
424
425
|
* That sends people to look at Kong, which is almost never the problem, and in
|
|
425
426
|
* CI the containers are gone by the time anything else can inspect them.
|
|
426
427
|
*/
|
|
427
|
-
function reportUnhealthyStack(composePath, cwd, project) {
|
|
428
|
-
const capture = (args) => {
|
|
429
|
-
const
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
});
|
|
433
|
-
return `${result.stdout ?? ""}${result.stderr ?? ""}`.trim();
|
|
428
|
+
async function reportUnhealthyStack(composePath, cwd, project) {
|
|
429
|
+
const capture = async (args) => {
|
|
430
|
+
const call = { cwd, timeoutMs: DOCKER_QUERY_TIMEOUT_MS };
|
|
431
|
+
const result = await askDocker(["compose", "-p", project, "--project-directory", cwd, "-f", composePath, ...args], call);
|
|
432
|
+
return `${result.stdout}${result.stderr}`.trim();
|
|
434
433
|
};
|
|
435
434
|
console.error("");
|
|
436
435
|
console.error("[supatype] The gateway is up but a service behind it is not. Container state:");
|
|
437
|
-
const state = capture(["ps", "-a"]);
|
|
436
|
+
const state = await capture(["ps", "-a"]);
|
|
438
437
|
console.error(state === "" ? " (no containers)" : state);
|
|
439
438
|
// The two the gateway health check depends on, and db because both need it.
|
|
440
439
|
for (const service of ["server", "realtime", "db"]) {
|
|
441
|
-
const logs = capture(["logs", "--no-color", "--tail", "40", service]);
|
|
440
|
+
const logs = await capture(["logs", "--no-color", "--tail", "40", service]);
|
|
442
441
|
if (logs === "")
|
|
443
442
|
continue;
|
|
444
443
|
console.error("");
|
|
@@ -466,12 +465,12 @@ async function waitKongReady(kongPort, maxSec, stack) {
|
|
|
466
465
|
return;
|
|
467
466
|
}
|
|
468
467
|
catch (err) {
|
|
469
|
-
lastAuth = lastRealtime =
|
|
468
|
+
lastAuth = lastRealtime = errorMessage(err);
|
|
470
469
|
}
|
|
471
|
-
await
|
|
470
|
+
await sleep(1000);
|
|
472
471
|
}
|
|
473
472
|
if (stack !== undefined) {
|
|
474
|
-
reportUnhealthyStack(stack.composePath, stack.cwd, stack.project);
|
|
473
|
+
await reportUnhealthyStack(stack.composePath, stack.cwd, stack.project);
|
|
475
474
|
}
|
|
476
475
|
throw new Error(`Gateway at ${base} did not become ready within ${maxSec}s ` +
|
|
477
476
|
`(auth/v1/health: ${lastAuth}, realtime/v1/health: ${lastRealtime})`);
|
|
@@ -495,12 +494,19 @@ async function waitStorageApiReady(kongPort, serviceRoleKey, maxSec) {
|
|
|
495
494
|
catch {
|
|
496
495
|
/* retry */
|
|
497
496
|
}
|
|
498
|
-
await
|
|
497
|
+
await sleep(1000);
|
|
499
498
|
}
|
|
500
499
|
console.warn(`[supatype] Storage API at ${url} did not become ready within ${maxSec}s, bucket provisioning may fail.`);
|
|
501
500
|
}
|
|
501
|
+
/**
|
|
502
|
+
* The schema's buckets on the dev stack. One the service did not take is said in one line, with what
|
|
503
|
+
* it means: dev carries on, and only uploads to that bucket fail. They were dropped without a word
|
|
504
|
+
* past each bucket's own warning.
|
|
505
|
+
*/
|
|
502
506
|
async function provisionDockerStorageBuckets(ast, kongPort, serviceRoleKey) {
|
|
503
|
-
await provisionBucketsFromAst(ast, `${loopbackBase(kongPort)}/storage/v1`, serviceRoleKey);
|
|
507
|
+
const left = unprovisionedBuckets(await provisionBucketsFromAst(ast, `${loopbackBase(kongPort)}/storage/v1`, serviceRoleKey));
|
|
508
|
+
if (left !== null)
|
|
509
|
+
console.warn(`[supatype] ⚠ ${left}; uploads to them fail until a later push takes them.`);
|
|
504
510
|
}
|
|
505
511
|
let _lastPushedAst = null;
|
|
506
512
|
let _lastFailedAst = null;
|
|
@@ -511,24 +517,25 @@ let _composePushQueued = false;
|
|
|
511
517
|
/**
|
|
512
518
|
* Regenerate everything derived from the schema once a push has applied it: the AST-derived files,
|
|
513
519
|
* then the types and admin config from the engine. Never called for a push that was refused or
|
|
514
|
-
* failed.
|
|
515
|
-
*
|
|
516
|
-
* fetched.
|
|
520
|
+
* failed. The engine is the one `supatype generate` uses, the host program, with the project's
|
|
521
|
+
* image only when that cannot be fetched (generated-files-engine.ts).
|
|
517
522
|
*/
|
|
518
523
|
async function refreshSchemaArtifacts(cwd, config, ast) {
|
|
519
524
|
writeAstDerivedArtifacts(cwd, config, ast);
|
|
520
|
-
|
|
521
|
-
|
|
525
|
+
// The client and augmentation need no engine, so no engine problem keeps them from being written.
|
|
526
|
+
writeDevAstOutputs(cwd, ast, config, "");
|
|
527
|
+
let choice;
|
|
522
528
|
try {
|
|
523
|
-
|
|
529
|
+
choice = await generatedFilesEngine(cwd, config);
|
|
524
530
|
}
|
|
525
531
|
catch (err) {
|
|
526
|
-
degraded("
|
|
532
|
+
degraded("No engine could write the admin config and types, so they were not refreshed", errorMessage(err));
|
|
527
533
|
return;
|
|
528
534
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
535
|
+
await writeEngineArtifacts(cwd, config, ast, join(cwd, ".supatype", "admin-config.json"), choice.engine);
|
|
536
|
+
// Said after writing, so SUPATYPE_STRICT fails the run with the files written and the true reason.
|
|
537
|
+
if (choice.fellBack !== undefined)
|
|
538
|
+
degraded(ENGINE_FALLBACK, choice.fellBack);
|
|
532
539
|
}
|
|
533
540
|
/** The files read straight off the applied AST, written whatever happens with the generator afterwards. */
|
|
534
541
|
function writeAstDerivedArtifacts(cwd, config, ast) {
|
|
@@ -540,21 +547,11 @@ function writeAstDerivedArtifacts(cwd, config, ast) {
|
|
|
540
547
|
// Every project running on Compose therefore had a manifest with no `hooks` and no `validators`
|
|
541
548
|
// key, and the server, having nothing to call, ran neither. A hook silently not firing is bad; a
|
|
542
549
|
// validator silently not firing means a write the schema says is checked is accepted with a 201.
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
// received one: its handlers had no `FunctionContext` to import.
|
|
549
|
-
if (refreshFunctionsContext(cwd, config)) {
|
|
550
|
-
console.log("[supatype] Function context type written to functions/_shared/context.ts");
|
|
551
|
-
}
|
|
552
|
-
if (syncManifestHooks(cwd, ast)) {
|
|
553
|
-
console.log("[supatype] Hook and validator maps written to .supatype/manifest.json");
|
|
554
|
-
}
|
|
555
|
-
// Written before the stack comes up, so a first run with a row cache declared starts with it on
|
|
556
|
-
// rather than needing a second `supatype dev`.
|
|
557
|
-
const rowCache = syncRowCacheEnv(cwd, ast);
|
|
550
|
+
// The row cache is written before the stack comes up, so a first run with a row cache declared
|
|
551
|
+
// starts with it on rather than needing a second `supatype dev`.
|
|
552
|
+
const { lines, rowCache } = writeAppliedAstArtifacts(cwd, config, ast, { rowCacheEnv: true });
|
|
553
|
+
for (const line of lines)
|
|
554
|
+
console.log(`[supatype] ${line}`);
|
|
558
555
|
if (rowCache !== null) {
|
|
559
556
|
console.log(`[supatype] ${rowCacheChangeNote(rowCache)}`);
|
|
560
557
|
}
|
|
@@ -575,50 +572,14 @@ function writeAstDerivedArtifacts(cwd, config, ast) {
|
|
|
575
572
|
* on `npm run seed` with ECONNREFUSED against a port nothing was listening on. The layout is the
|
|
576
573
|
* stack's own (dev while a dev session holds it, otherwise self-host), so a self-host push in a
|
|
577
574
|
* project that once ran dev keeps the self-host port, and the message names the variable it read.
|
|
575
|
+
* Only a URL the CLI owns moves: one that is yours is left as it is, for this run too.
|
|
578
576
|
*/
|
|
579
577
|
function syncDatabaseUrlToStack(cwd, config) {
|
|
580
|
-
const
|
|
581
|
-
if (
|
|
582
|
-
|
|
583
|
-
console.log(`[supatype] ${databaseUrlSyncMessage(dbPort)}`);
|
|
578
|
+
const sync = syncDatabaseUrlPort(cwd, composeRenderMode(cwd, config.project.name) === "dev");
|
|
579
|
+
if (sync !== null)
|
|
580
|
+
console.log(`[supatype] ${databaseUrlSyncMessage(sync)}`);
|
|
584
581
|
}
|
|
585
|
-
/**
|
|
586
|
-
* True when the host engine binary is ready. When it is not, the in-compose engine writes the
|
|
587
|
-
* admin config and types instead and this answers false, having said which happened.
|
|
588
|
-
*/
|
|
589
|
-
async function hostEngineOrComposeFallback(cwd, config, ast, adminConfigPath) {
|
|
590
|
-
try {
|
|
591
|
-
await ensureEngine();
|
|
592
|
-
return true;
|
|
593
|
-
}
|
|
594
|
-
catch (err) {
|
|
595
|
-
// A project that named its engine gets that engine or an error, never a stand-in.
|
|
596
|
-
if (hasEngineOverride(config)) {
|
|
597
|
-
degraded("overrides.engine could not be used, admin config and types not refreshed", errorMessage(err));
|
|
598
|
-
return false;
|
|
599
|
-
}
|
|
600
|
-
// The host engine is a CDN download and this machine could not complete it. The schema is
|
|
601
|
-
// already applied, so fall back to the engine in compose rather than giving up: without
|
|
602
|
-
// admin-config.json Studio reports "No schema has been pushed yet" on a stack whose schema is
|
|
603
|
-
// entirely live, which reads as a failed push rather than a missing binary.
|
|
604
|
-
const paths = selfHostComposePaths(cwd);
|
|
605
|
-
const composeProject = composeProjectName(config.project.name);
|
|
606
|
-
const wrote = await generateViaComposeEngine(paths, cwd, composeProject, config, ast, adminConfigPath)
|
|
607
|
-
.catch(() => false);
|
|
608
|
-
// Reported through `degraded` rather than warned, so a run that takes this path says so where
|
|
609
|
-
// CI looks, rather than in a line that scrolls past.
|
|
610
|
-
const message = errorMessage(err);
|
|
611
|
-
if (wrote) {
|
|
612
|
-
degraded("Host engine unavailable, used the in-compose engine instead", message);
|
|
613
|
-
}
|
|
614
|
-
else {
|
|
615
|
-
degraded("Host engine unavailable, admin config and types not refreshed", `${message}\n[supatype] Studio will report no schema until this succeeds, even though the ` +
|
|
616
|
-
"schema is applied. Retry with the stack up, or run `supatype push`.");
|
|
617
|
-
}
|
|
618
|
-
return false;
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
/** The types, the AST outputs and the admin config, from `engine` (the host binary when undefined). */
|
|
582
|
+
/** The types, the seed builder and the admin config, from `engine` (the host binary when undefined). */
|
|
622
583
|
async function writeEngineArtifacts(cwd, config, ast, adminConfigPath, engine) {
|
|
623
584
|
// At the default paths when `output` is not set, which is every project `init` made before it
|
|
624
585
|
// wrote one: gated on `output.types`, a renamed field left the typed client on the old name.
|
|
@@ -635,7 +596,6 @@ async function writeEngineArtifacts(cwd, config, ast, adminConfigPath, engine) {
|
|
|
635
596
|
catch (err) {
|
|
636
597
|
console.warn(`[supatype] Type generation failed: ${errorMessage(err)}`);
|
|
637
598
|
}
|
|
638
|
-
writeDevAstOutputs(cwd, ast, config, "");
|
|
639
599
|
await writeDevSeedBuilder(cwd, config, ast, engine);
|
|
640
600
|
try {
|
|
641
601
|
const admin = withAdminRoles(await engineRequest("/admin", { ast }, isAnyAnswer, engine), config);
|
|
@@ -765,13 +725,14 @@ function writeSchemaAstFile(cwd, astJson) {
|
|
|
765
725
|
*/
|
|
766
726
|
async function applyViaHostEngine(cwd, config, ast, opts) {
|
|
767
727
|
await ensureEngine();
|
|
768
|
-
const sources = writeSchemaSourcePushArtifacts(cwd);
|
|
728
|
+
const sources = writeSchemaSourcePushArtifacts(cwd, opts.snapshotOptional === true);
|
|
769
729
|
const body = {
|
|
770
730
|
ast,
|
|
771
731
|
database_url: projectDatabaseUrl(cwd, config),
|
|
772
732
|
schema: pgSchema(config),
|
|
773
733
|
force: opts.force === true,
|
|
774
734
|
...(opts.overwriteDrift === true && { overwrite_drift: true }),
|
|
735
|
+
...(opts.runHooks === true && { run_hooks: true }),
|
|
775
736
|
...(sources !== null && {
|
|
776
737
|
schema_sources_gz_base64: sources.payload.dataBase64,
|
|
777
738
|
schema_sources_manifest: sources.payload.manifest,
|
|
@@ -782,7 +743,7 @@ async function applyViaHostEngine(cwd, config, ast, opts) {
|
|
|
782
743
|
/** Apply the AST on disk with the stack's schema-engine container. Throws when it is not applied. */
|
|
783
744
|
async function applyViaComposeEngine(cwd, config, stack, opts) {
|
|
784
745
|
const { paths, composeProject } = stack;
|
|
785
|
-
const sources = writeSchemaSourcePushArtifacts(cwd);
|
|
746
|
+
const sources = writeSchemaSourcePushArtifacts(cwd, opts.snapshotOptional === true);
|
|
786
747
|
const audit = opts.audit ?? (await composeAuditArgs(cwd, config));
|
|
787
748
|
const pushOnce = () => runComposeEnginePush(paths, cwd, composeProject, config, sources, { ...opts, audit });
|
|
788
749
|
const runPush = async () => {
|
|
@@ -791,7 +752,7 @@ async function applyViaComposeEngine(cwd, config, stack, opts) {
|
|
|
791
752
|
// engine's considered answer, not a lagging mount, and running it again only repeats it.
|
|
792
753
|
if (first.status === 0 || consentRefusal(first.output) !== null)
|
|
793
754
|
return first;
|
|
794
|
-
await
|
|
755
|
+
await sleep(250);
|
|
795
756
|
return pushOnce();
|
|
796
757
|
};
|
|
797
758
|
// B: only hold the advisory lock when realtime is already decoding, first-boot
|
|
@@ -857,7 +818,13 @@ export function followRecordedTier(cwd, config, opts) {
|
|
|
857
818
|
*/
|
|
858
819
|
async function runDevSchemaPush(cwd, config, paths, schemaPath, composeProject, opts) {
|
|
859
820
|
const audit = opts.audit ?? (hasEngineOverride(config) ? [] : await composeAuditArgs(cwd, config));
|
|
860
|
-
const once = (overwriteDrift) => pushConsentingToDestructive((force) => runComposeSchemaPush(cwd, config, paths, schemaPath, composeProject, {
|
|
821
|
+
const once = (overwriteDrift) => pushConsentingToDestructive((force) => runComposeSchemaPush(cwd, config, paths, schemaPath, composeProject, {
|
|
822
|
+
...opts,
|
|
823
|
+
audit,
|
|
824
|
+
overwriteDrift,
|
|
825
|
+
force,
|
|
826
|
+
snapshotOptional: true,
|
|
827
|
+
}), DEV_DESTRUCTIVE_POLICY, consentDepsFromDiff(cwd, () => dockerDiff(cwd, config)));
|
|
861
828
|
return devPushConsentingToDrift(once, opts.overwriteDrift === true, {
|
|
862
829
|
beforeOverwrite: () => requireDockerFeatures(cwd, config, [OVERWRITE_DRIFT_NEED]),
|
|
863
830
|
});
|
|
@@ -911,12 +878,12 @@ export async function dockerEngineCapabilities(cwd, config) {
|
|
|
911
878
|
const probe = () => {
|
|
912
879
|
const paths = writeSelfHostCompose(cwd, config, composeRenderOptions(cwd, config.project.name));
|
|
913
880
|
const target = { cwd, project: composeProjectName(config.project.name), composePath: paths.composePath, engineImage };
|
|
914
|
-
return
|
|
881
|
+
return checkedCapabilities((args) => {
|
|
915
882
|
const run = spawnComposeEngine(target, args, { runFlags: ["--no-deps"] });
|
|
916
|
-
return { status: run.status, stdout: run.stdout
|
|
883
|
+
return { status: run.status, stdout: run.stdout, stderr: run.error ?? run.stderr };
|
|
917
884
|
});
|
|
918
885
|
};
|
|
919
|
-
const imageId = engineImage === undefined ? "compose-default" : localImageId(engineImage);
|
|
886
|
+
const imageId = engineImage === undefined ? "compose-default" : await localImageId(engineImage);
|
|
920
887
|
// Not pulled yet: the probe pulls it, and the next call keys on the ID it then has.
|
|
921
888
|
if (imageId === undefined)
|
|
922
889
|
return probe();
|
|
@@ -926,8 +893,8 @@ export async function dockerEngineCapabilities(cwd, config) {
|
|
|
926
893
|
* The local image's ID, or undefined when Docker does not have it. The answer is keyed on it, so
|
|
927
894
|
* a tag that now names another image (a pull, a rebuild) is asked again, and nothing else is.
|
|
928
895
|
*/
|
|
929
|
-
function localImageId(image) {
|
|
930
|
-
const inspect =
|
|
896
|
+
async function localImageId(image) {
|
|
897
|
+
const inspect = await askDocker(["image", "inspect", "--format", "{{.Id}}", image], { timeoutMs: DOCKER_QUERY_TIMEOUT_MS });
|
|
931
898
|
const id = inspect.status === 0 ? inspect.stdout.trim() : "";
|
|
932
899
|
return id === "" ? undefined : id;
|
|
933
900
|
}
|
|
@@ -953,6 +920,8 @@ export function composeEnginePushArgs(sources, opts = {}) {
|
|
|
953
920
|
// Only when asked: an engine older than the ledger rejects the flag.
|
|
954
921
|
if (opts.overwriteDrift === true)
|
|
955
922
|
args.push("--overwrite-drift");
|
|
923
|
+
if (opts.runHooks === true)
|
|
924
|
+
args.push("--run-hooks");
|
|
956
925
|
if (sources) {
|
|
957
926
|
args.push("--schema-sources-gz", sources.dockerGzPath, "--schema-sources-manifest", sources.dockerManifestPath);
|
|
958
927
|
}
|
|
@@ -1059,57 +1028,98 @@ export async function adoptSchemaDocker(cwd, config, yes, keys) {
|
|
|
1059
1028
|
* `supatype diff` when `provider: docker`. Uses in-compose schema-engine unless
|
|
1060
1029
|
* `overrides.engine` is set: then Postgres is published to the host and diff runs
|
|
1061
1030
|
* through the local engine binary.
|
|
1031
|
+
*
|
|
1032
|
+
* A dry run leaves the machine as it found it: a database the diff had to start is stopped again
|
|
1033
|
+
* afterwards. It used to be left running.
|
|
1062
1034
|
*/
|
|
1063
1035
|
export async function diffSchemaDocker(cwd, config) {
|
|
1064
1036
|
if (resolveRuntimeProvider(config) !== "docker") {
|
|
1065
1037
|
throw new Error("diffSchemaDocker requires provider: docker");
|
|
1066
1038
|
}
|
|
1067
1039
|
const project = composeProjectName(config.project.name);
|
|
1040
|
+
const brand = { intro: "Schema diff" };
|
|
1068
1041
|
if (hasEngineOverride(config)) {
|
|
1069
|
-
|
|
1070
|
-
await ensureDockerDbPublishedForHostEngine(cwd, config, brand);
|
|
1071
|
-
const schemaPath = schemaPathFromProject(config, cwd);
|
|
1072
|
-
const ast = withPublishing(loadSchemaAst(schemaPath, cwd), config);
|
|
1073
|
-
await ensureEngine();
|
|
1074
|
-
return engineRequest("/diff", { ast, database_url: projectDatabaseUrl(cwd, config), schema: pgSchema(config) }, isDiffResult);
|
|
1042
|
+
return withComposeDatabaseStarted(cwd, config, project, () => ensureDockerDbPublishedForHostEngine(cwd, config, brand), () => diffWithHostEngine(cwd, config));
|
|
1075
1043
|
}
|
|
1076
|
-
// A diff of a standalone stack must not write dev values over the operator's .env (SH1).
|
|
1044
|
+
// A diff of a standalone stack must not write dev values over the operator's .env (SH1). A dev
|
|
1045
|
+
// stack's is brought up to date as push does: compose interpolates the whole file, so a project
|
|
1046
|
+
// that has not yet run `dev` can lack values `up -d db` needs.
|
|
1077
1047
|
const mode = composeRenderMode(cwd, config.project.name);
|
|
1078
1048
|
if (mode === "dev") {
|
|
1079
1049
|
const { anonKey, serviceRoleKey } = devApiKeys(cwd);
|
|
1080
1050
|
ensureDevComposeEnv(cwd, config, anonKey, serviceRoleKey, await resolveKongPort(cwd, project), undefined);
|
|
1081
1051
|
}
|
|
1082
1052
|
const paths = writeSelfHostCompose(cwd, config, { devLocal: mode === "dev" });
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1053
|
+
return withComposeDatabaseStarted(cwd, config, project, () => startComposeDatabase(config, paths, cwd, project, brand), () => diffWithComposeEngine(cwd, config, paths, project));
|
|
1054
|
+
}
|
|
1055
|
+
/**
|
|
1056
|
+
* `run` with the stack's database up, `start` bringing it up, then stopped again when it was not
|
|
1057
|
+
* running before. One that a `supatype dev` session or a running stack is using is left as it was.
|
|
1058
|
+
*/
|
|
1059
|
+
async function withComposeDatabaseStarted(cwd, config, project, start, run) {
|
|
1060
|
+
const stack = { project, composePath: selfHostComposePaths(cwd).composePath };
|
|
1061
|
+
// An external database is not the stack's to start or stop.
|
|
1062
|
+
const wasStopped = !usesExternalDatabase(config) && !composeServiceIsRunning(cwd, stack, "db");
|
|
1063
|
+
let started = false;
|
|
1064
|
+
try {
|
|
1065
|
+
await start();
|
|
1066
|
+
started = true;
|
|
1067
|
+
return await run();
|
|
1068
|
+
}
|
|
1069
|
+
finally {
|
|
1070
|
+
// A start that failed after `up -d db` (its health wait, the host publish) has still brought
|
|
1071
|
+
// the container up; one refused before it (no stack running) has started nothing to stop.
|
|
1072
|
+
if (wasStopped && (started || composeServiceIsRunning(cwd, stack, "db")))
|
|
1073
|
+
stopComposeDatabase(cwd, stack);
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
/** Stop the stack's database, saying so rather than failing the command whose result is already in hand. */
|
|
1077
|
+
function stopComposeDatabase(cwd, stack) {
|
|
1078
|
+
try {
|
|
1079
|
+
const status = runDockerCompose(stack.composePath, ["stop", "db"], cwd, stack.project, { quiet: true });
|
|
1080
|
+
if (status !== 0)
|
|
1081
|
+
warn("Could not stop the Postgres container this command started. Stop it with `supatype self-host compose stop db`.");
|
|
1082
|
+
}
|
|
1083
|
+
catch (err) {
|
|
1084
|
+
warn(`Could not stop the Postgres container this command started: ${errorMessage(err)}`);
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
/** The diff from the host engine binary, against the database published to the host. */
|
|
1088
|
+
async function diffWithHostEngine(cwd, config) {
|
|
1089
|
+
const ast = withPublishing(loadSchemaAst(schemaPathFromProject(config, cwd), cwd), config);
|
|
1090
|
+
await ensureEngine();
|
|
1091
|
+
return engineRequest("/diff", { ast, database_url: projectDatabaseUrl(cwd, config), schema: pgSchema(config) }, isDiffResult);
|
|
1092
|
+
}
|
|
1093
|
+
/** The diff from the compose schema-engine, which reads the AST written beside the compose file. */
|
|
1094
|
+
async function diffWithComposeEngine(cwd, config, paths, project) {
|
|
1095
|
+
const ast = withPublishing(loadSchemaAst(schemaPathFromProject(config, cwd), cwd), config);
|
|
1087
1096
|
await requireDockerFeatures(cwd, config, identityColumnsNeed(ast));
|
|
1088
1097
|
const supatypeDir = join(cwd, ".supatype");
|
|
1089
1098
|
mkdirSync(supatypeDir, { recursive: true });
|
|
1090
|
-
|
|
1091
|
-
writeFileSync(astPath, JSON.stringify(ast));
|
|
1099
|
+
writeFileSync(join(supatypeDir, "schema.ast.json"), JSON.stringify(ast));
|
|
1092
1100
|
let result = await runComposeEngineDiff(paths, cwd, project, config);
|
|
1093
1101
|
// Windows Docker bind mounts can lag briefly after the host write.
|
|
1094
1102
|
if (result.status !== 0) {
|
|
1095
|
-
await
|
|
1103
|
+
await sleep(250);
|
|
1096
1104
|
result = await runComposeEngineDiff(paths, cwd, project, config);
|
|
1097
1105
|
}
|
|
1098
1106
|
if (result.status !== 0) {
|
|
1099
1107
|
const detail = filterComposeNoise(result.output) || result.output;
|
|
1100
1108
|
throw new Error(detail || `Engine schema diff failed (exit ${result.status})`);
|
|
1101
1109
|
}
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1110
|
+
return result.diff ?? unparsedDiffError(result.output);
|
|
1111
|
+
}
|
|
1112
|
+
/**
|
|
1113
|
+
* The engine exited 0 and produced nothing this could parse, which is a different failure from the
|
|
1114
|
+
* engine exiting non-zero and is the harder one to act on. "Engine diff returned no result" named
|
|
1115
|
+
* only the symptom, and running the same compose command by hand gave a clear error in one go, so
|
|
1116
|
+
* the message was the only thing standing between the reader and the answer.
|
|
1117
|
+
*/
|
|
1118
|
+
function unparsedDiffError(rawOutput) {
|
|
1119
|
+
const output = (filterComposeNoise(rawOutput) || rawOutput || "").trim();
|
|
1120
|
+
throw new Error(output === ""
|
|
1121
|
+
? "The schema engine exited 0 and printed nothing. Run `supatype self-host compose run --rm schema-engine diff` to see what it does."
|
|
1122
|
+
: `The schema engine exited 0 but its output could not be parsed as a diff:\n${output}`);
|
|
1113
1123
|
}
|
|
1114
1124
|
/**
|
|
1115
1125
|
* `supatype push` when `provider: docker`. Uses in-compose schema-engine unless
|
|
@@ -1187,7 +1197,7 @@ async function applyInitialSchema(cwd, config, paths, schemaPath, project, brand
|
|
|
1187
1197
|
push: () => runDevSchemaPush(cwd, config, paths, schemaPath, project, opts),
|
|
1188
1198
|
recoverDatabase: () => startComposeDatabase(config, paths, cwd, project, brand, undefined, endDevSession),
|
|
1189
1199
|
dumpLogs: (reason) => dumpComposeDbLogs(paths, cwd, project, reason),
|
|
1190
|
-
sleep: (ms) =>
|
|
1200
|
+
sleep: (ms) => sleep(ms),
|
|
1191
1201
|
};
|
|
1192
1202
|
const outcome = await adoptingOnRefusal(await pushInitialSchema(steps), steps, cwd, config);
|
|
1193
1203
|
// Ending the session before an exit, so its message reaches the real terminal rather than a TUI
|
|
@@ -1208,6 +1218,18 @@ async function adoptingOnRefusal(outcome, steps, cwd, config) {
|
|
|
1208
1218
|
});
|
|
1209
1219
|
return adopted === "adopted" ? pushInitialSchema(steps) : outcome;
|
|
1210
1220
|
}
|
|
1221
|
+
/**
|
|
1222
|
+
* The dev stack's database port, moved off one something else holds, or undefined for an external
|
|
1223
|
+
* database. A port only the shell gives is offered to `.env` before anything else reads the URL
|
|
1224
|
+
* (db-port-offer.ts), so a yes is what the rest of the run sees.
|
|
1225
|
+
*/
|
|
1226
|
+
async function devStackDbPort(cwd, config, project) {
|
|
1227
|
+
if (!publishesDbToHost(config))
|
|
1228
|
+
return undefined;
|
|
1229
|
+
const port = await ensureDevDbPort(cwd, { composeProject: project, mayMove: true });
|
|
1230
|
+
await offerToSaveShellDbPort(cwd);
|
|
1231
|
+
return port;
|
|
1232
|
+
}
|
|
1211
1233
|
export async function runDevCompose(cwd, config, opts) {
|
|
1212
1234
|
if (resolveRuntimeProvider(config) !== "docker") {
|
|
1213
1235
|
throw new Error("runDevCompose requires provider: docker");
|
|
@@ -1226,15 +1248,15 @@ export async function runDevCompose(cwd, config, opts) {
|
|
|
1226
1248
|
// `overrides.engine` while the compose file published unconditionally is what left a project
|
|
1227
1249
|
// with a database on 54329 and a URL still saying 5432.
|
|
1228
1250
|
// Only dev moves the port off something else that holds it.
|
|
1229
|
-
const devDbPort =
|
|
1230
|
-
? await ensureDevDbPort(cwd, { composeProject: project, mayMove: true })
|
|
1231
|
-
: undefined;
|
|
1251
|
+
const devDbPort = await devStackDbPort(cwd, config, project);
|
|
1232
1252
|
const { anonKey, serviceRoleKey } = devApiKeys(cwd);
|
|
1233
1253
|
const devBrand = { intro: "Local development" };
|
|
1234
1254
|
const localServerImage = await ensureLocalServerDockerImage(cwd, config, devBrand);
|
|
1235
1255
|
ensureDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPort, devDbPort);
|
|
1236
1256
|
warnProjectAuthProviderSecrets(cwd, config);
|
|
1237
1257
|
console.log(`[supatype] provider docker, starting self-host Compose stack (project ${project}, gateway :${kongPort})...`);
|
|
1258
|
+
await showDevStep("Preparing the Docker stack");
|
|
1259
|
+
noteUnpinnedImages(cwd);
|
|
1238
1260
|
const paths = writeSelfHostCompose(cwd, config, composeRenderOptions(cwd, config.project.name));
|
|
1239
1261
|
if (ensureDevApiConfig(cwd)) {
|
|
1240
1262
|
console.log("[supatype] API config written to .supatype/api-config.json");
|
|
@@ -1253,6 +1275,7 @@ export async function runDevCompose(cwd, config, opts) {
|
|
|
1253
1275
|
console.log("[supatype] Shutting down compose...");
|
|
1254
1276
|
await shutdownState.studioProc?.stop();
|
|
1255
1277
|
await shutdownState.appProc?.stop();
|
|
1278
|
+
await settleComposeRuns();
|
|
1256
1279
|
const downStatus = runDockerCompose(paths.composePath, ["down"], cwd, project, { quiet: true });
|
|
1257
1280
|
if (downStatus === 0) {
|
|
1258
1281
|
console.log("[supatype] Compose stack stopped.");
|
|
@@ -1279,10 +1302,13 @@ export async function runDevCompose(cwd, config, opts) {
|
|
|
1279
1302
|
}
|
|
1280
1303
|
if (!usesExternalDatabase(config)) {
|
|
1281
1304
|
console.log("[supatype] Bringing up Postgres (compose db)...");
|
|
1305
|
+
await showDevStep("Starting Postgres");
|
|
1282
1306
|
}
|
|
1283
1307
|
await startComposeDatabase(config, paths, cwd, project, devBrand, 180_000, endDevSession);
|
|
1284
1308
|
// Settle before DDL: pg_isready can pass slightly before the instance is stable.
|
|
1285
|
-
await
|
|
1309
|
+
await sleep(3000);
|
|
1310
|
+
// With the stack's database up, so a hand-written URL naming it is not reported as silent.
|
|
1311
|
+
await warnIfHandWrittenUrlSilent(cwd);
|
|
1286
1312
|
if (!usesExternalDatabase(config)) {
|
|
1287
1313
|
reconcileAuthenticatorPassword(paths, cwd, project);
|
|
1288
1314
|
reconcileSqlEditorPassword(paths, cwd, project);
|
|
@@ -1292,21 +1318,21 @@ export async function runDevCompose(cwd, config, opts) {
|
|
|
1292
1318
|
const schemaPath = schemaPathFromProject(config, cwd);
|
|
1293
1319
|
// `dev --overwrite-drift`, already checked against this engine before the session began.
|
|
1294
1320
|
const pushOptions = { overwriteDrift: opts.overwriteDrift === true };
|
|
1321
|
+
await showDevStep("Applying the schema");
|
|
1295
1322
|
const schemaApplied = await applyInitialSchema(cwd, config, paths, schemaPath, project, devBrand, pushOptions);
|
|
1296
1323
|
// Before the stack starts, so PostgREST comes up on the tier the push actually produced.
|
|
1297
1324
|
followRecordedTier(cwd, config, { recreate: false });
|
|
1298
1325
|
console.log("[supatype] Bringing up Docker Compose services...");
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
brand: devBrand,
|
|
1302
|
-
});
|
|
1326
|
+
await showDevStep("Starting services (the first start downloads their images)");
|
|
1327
|
+
const upStatus = await runDockerComposeQuietly(paths.composePath, ["up", "-d"], cwd, project, devBrand);
|
|
1303
1328
|
if (upStatus !== 0) {
|
|
1304
1329
|
endDevSession();
|
|
1305
1330
|
exitComposeFailed(upStatus, "Could not start the local Compose stack.", devBrand);
|
|
1306
1331
|
}
|
|
1307
1332
|
if (localServerImage !== undefined) {
|
|
1308
1333
|
console.log("[supatype] Recreating server with local image...");
|
|
1309
|
-
|
|
1334
|
+
await showDevStep("Recreating the server");
|
|
1335
|
+
const recreateStatus = await runDockerComposeQuietly(paths.composePath, ["up", "-d", "--force-recreate", "--no-deps", "server"], cwd, project, devBrand);
|
|
1310
1336
|
if (recreateStatus !== 0) {
|
|
1311
1337
|
endDevSession();
|
|
1312
1338
|
exitComposeFailed(recreateStatus, "Could not recreate the server container with the local image.", devBrand);
|
|
@@ -1323,7 +1349,8 @@ export async function runDevCompose(cwd, config, opts) {
|
|
|
1323
1349
|
if (readEnvValue(cwd, variable, "").trim() === "")
|
|
1324
1350
|
continue;
|
|
1325
1351
|
console.log(`[supatype] Recreating ${service} with pinned image...`);
|
|
1326
|
-
|
|
1352
|
+
await showDevStep(`Recreating ${service}`);
|
|
1353
|
+
const status = await runDockerComposeQuietly(paths.composePath, ["up", "-d", "--force-recreate", "--no-deps", service], cwd, project, devBrand);
|
|
1327
1354
|
if (status !== 0) {
|
|
1328
1355
|
endDevSession();
|
|
1329
1356
|
exitComposeFailed(status, `Could not recreate the ${service} container.`, devBrand);
|
|
@@ -1343,9 +1370,12 @@ export async function runDevCompose(cwd, config, opts) {
|
|
|
1343
1370
|
});
|
|
1344
1371
|
}
|
|
1345
1372
|
console.log("[supatype] Waiting for API gateway...");
|
|
1373
|
+
await showDevStep("Waiting for the API gateway");
|
|
1346
1374
|
await waitKongReady(kongPort, 120, { composePath: paths.composePath, cwd, project });
|
|
1347
1375
|
console.log("[supatype] Waiting for storage API...");
|
|
1376
|
+
await showDevStep("Waiting for storage");
|
|
1348
1377
|
await waitStorageApiReady(kongPort, serviceRoleKey, 90);
|
|
1378
|
+
await showDevStep("Checking for an admin user");
|
|
1349
1379
|
await ensureFirstAdminUserForProject(cwd, config, {
|
|
1350
1380
|
compose: { project, composePath: paths.composePath },
|
|
1351
1381
|
});
|
|
@@ -1433,70 +1463,4 @@ export async function runDevCompose(cwd, config, opts) {
|
|
|
1433
1463
|
// Until Ctrl+C or a signal: the shutdown hook takes the stack down and exits.
|
|
1434
1464
|
await waitForDevShutdown();
|
|
1435
1465
|
}
|
|
1436
|
-
/**
|
|
1437
|
-
* Run one read-only generator in the in-compose schema-engine and return its stdout.
|
|
1438
|
-
*
|
|
1439
|
-
* The same image and the same bind mount the push just used, so if the schema could be applied
|
|
1440
|
-
* this can run. It exists because the host engine is a separate binary fetched from a CDN, and a
|
|
1441
|
-
* machine that cannot fetch it is not a machine that cannot generate: the schema is already
|
|
1442
|
-
* applied, the AST is already on disk, and the container that did it is one `docker compose run`
|
|
1443
|
-
* away.
|
|
1444
|
-
*/
|
|
1445
|
-
async function runComposeEngineGenerator(paths, cwd, composeProject, config, args) {
|
|
1446
|
-
const engineImage = await schemaEngineImageForPush(config, cwd);
|
|
1447
|
-
const target = { cwd, project: composeProject, composePath: paths.composePath, engineImage };
|
|
1448
|
-
const result = spawnComposeEngine(target, [...args, "-i", COMPOSE_SCHEMA_AST], {
|
|
1449
|
-
runFlags: ["-T"],
|
|
1450
|
-
maxBuffer: 20 * 1024 * 1024,
|
|
1451
|
-
});
|
|
1452
|
-
if ((result.status ?? 1) !== 0)
|
|
1453
|
-
return null;
|
|
1454
|
-
return String(result.stdout ?? "");
|
|
1455
|
-
}
|
|
1456
|
-
/**
|
|
1457
|
-
* The in-compose engine as {@link engineRequest} takes it, for generating only. No database URL:
|
|
1458
|
-
* `/generate` reads the AST alone and runs without starting the database.
|
|
1459
|
-
*/
|
|
1460
|
-
async function composeGeneratorEngine(paths, cwd, composeProject, config) {
|
|
1461
|
-
const engineImage = await schemaEngineImageForPush(config, cwd);
|
|
1462
|
-
return {
|
|
1463
|
-
target: { cwd, project: composeProject, composePath: paths.composePath, engineImage },
|
|
1464
|
-
databaseUrl: "",
|
|
1465
|
-
capabilities: () => dockerEngineCapabilities(cwd, config),
|
|
1466
|
-
};
|
|
1467
|
-
}
|
|
1468
|
-
/**
|
|
1469
|
-
* Write `admin-config.json` and the generated types using the in-compose engine.
|
|
1470
|
-
*
|
|
1471
|
-
* The fallback for a host engine that could not be fetched. Without it, a `supatype dev` that
|
|
1472
|
-
* applied the schema perfectly well still left no `admin-config.json`, and Studio reads that file
|
|
1473
|
-
* to decide whether a schema exists: the stack came up, every table was live, the API served them,
|
|
1474
|
-
* and Studio said **"No schema has been pushed yet."** The warning that preceded it named the
|
|
1475
|
-
* download, not the consequence, so nothing connected the two.
|
|
1476
|
-
*
|
|
1477
|
-
* Returns true when the admin config was written, which is the file Studio actually needs.
|
|
1478
|
-
*/
|
|
1479
|
-
export async function generateViaComposeEngine(paths, cwd, composeProject, config, ast, adminConfigPath) {
|
|
1480
|
-
const { typesPath } = projectOutputPaths(config.output);
|
|
1481
|
-
const out = await runComposeEngineGenerator(paths, cwd, composeProject, config, ["generate"]);
|
|
1482
|
-
if (writeEngineTypes(cwd, typesPath, out ?? undefined)) {
|
|
1483
|
-
console.log(`[supatype] Types written to ${typesPath} (in-compose engine).`);
|
|
1484
|
-
}
|
|
1485
|
-
// The same AST-derived files as the host path. This is the fallback used when the host engine
|
|
1486
|
-
// could not be fetched, and these need no engine at all, so there is no reason for a project on
|
|
1487
|
-
// this path to end up with fewer generated files than one on the other.
|
|
1488
|
-
writeDevAstOutputs(cwd, ast, config, " (in-compose engine).");
|
|
1489
|
-
await writeDevSeedBuilder(cwd, config, ast, await composeGeneratorEngine(paths, cwd, composeProject, config));
|
|
1490
|
-
const adminOut = await runComposeEngineGenerator(paths, cwd, composeProject, config, ["admin"]);
|
|
1491
|
-
if (!adminOut)
|
|
1492
|
-
return false;
|
|
1493
|
-
const parsed = parseEngineJsonOutput(adminOut, isObjectAnswer);
|
|
1494
|
-
if (parsed === null)
|
|
1495
|
-
return false;
|
|
1496
|
-
const admin = withAdminRoles(parsed, config);
|
|
1497
|
-
restoreSystemRelationTargets(admin, ast);
|
|
1498
|
-
writeFileSync(adminConfigPath, `${JSON.stringify(admin, null, 2)}\n`);
|
|
1499
|
-
console.log("[supatype] Admin config written to .supatype/admin-config.json (in-compose engine).");
|
|
1500
|
-
return true;
|
|
1501
|
-
}
|
|
1502
1466
|
//# sourceMappingURL=dev-compose.js.map
|