@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
|
@@ -1,26 +1,36 @@
|
|
|
1
|
-
import { existsSync, mkdirSync,
|
|
2
|
-
import { dirname, join, resolve, sep } from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
3
|
+
import { createInterface } from "node:readline";
|
|
4
|
+
import { FUNCTIONS_WORKER_DRAIN_MS, FUNCTIONS_WORKER_STOP_GRACE_SECONDS, SERVICE_ROLE_ROUTES_FILE } from "@supatype/shared";
|
|
5
|
+
import { composeHostPath } from "./compose-host-path.js";
|
|
6
|
+
export { composeHostPath } from "./compose-host-path.js";
|
|
7
|
+
import { ENGINE_SERVICE } from "./compose-engine-service.js";
|
|
8
|
+
import { requireDockerDaemon, requireDockerDaemonAsync } from "./docker-runtime.js";
|
|
9
|
+
import { askDocker, askDockerSync, NO_DOCKER_LIMIT, spawnDocker } from "./docker-exec.js";
|
|
5
10
|
import { fatalError } from "./ui/fatal.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
11
|
+
import { COMPOSE_DEV_KONG_PORT, defaultAppStaticDir, postgrestSchemaEnv, externalDatabaseUrl, hooksPathFromProject, preferredFunctionsPathFromProject, realtimeEnabled, serviceRoleRoutes, selfHostTlsEnabled, usesExternalDatabase, } from "./project-config.js";
|
|
12
|
+
import { hasStudioOverride, pinnedVersion, VERSION_PIN_LOCAL } from "./binary-cache.js";
|
|
13
|
+
import { assertEngineVersionSupported, engineImageVersion } from "./engine-floor.js";
|
|
9
14
|
import { buildKongDeclarative } from "./kong-config.js";
|
|
10
15
|
import { keyspaceInPostgres } from "./cache-provider.js";
|
|
11
|
-
import { postgresImageFor } from "./postgres-image.js";
|
|
16
|
+
import { postgresImageFor, runningPostgresImage } from "./postgres-image.js";
|
|
12
17
|
import { STUDIO_DEV_PORT } from "./studio-dev-server.js";
|
|
13
18
|
import { readEnvFile, readEnvValue } from "./env-file.js";
|
|
14
19
|
import { composeDbPublish, DB_PUBLIC_HOST_ENV, SELF_HOST_BIND } from "./db-port.js";
|
|
15
|
-
import { upKeepingKongCurrent } from "./compose-kong.js";
|
|
20
|
+
import { upKeepingKongCurrent, upKeepingKongCurrentAsync } from "./compose-kong.js";
|
|
21
|
+
import { addressPoolExhaustionHint } from "./docker-address-pool.js";
|
|
16
22
|
import { composeAuthProviderEnv } from "./auth-providers.js";
|
|
17
|
-
import { BUNDLED_DB_USER, CONTROL_PLANE_SECRET_ENV, SQL_EDITOR_PASSWORD_ENV, ensureControlPlaneSecret, } from "./local-secrets.js";
|
|
23
|
+
import { BUNDLED_DB_USER, CONTROL_PLANE_SECRET_ENV, ENV_FILE_OVER_SHELL, SQL_EDITOR_PASSWORD_ENV, ensureControlPlaneSecret, envFileOverridesShell, } from "./local-secrets.js";
|
|
18
24
|
import { fieldMaskingTierFromProject } from "./field-masking-tier.js";
|
|
19
25
|
import { readRecordedTier } from "./recorded-field-masking-tier.js";
|
|
20
26
|
import { projectHasVersionedModels } from "./model-versioning.js";
|
|
21
27
|
import { POSTGREST_IMAGE } from "./postgrest-release.js";
|
|
28
|
+
import { postgrestHookActorEnv } from "./hook-actor.js";
|
|
29
|
+
import { IN_REPO_IMAGE_ENV, RELEASE_IMAGES, unpinnedImagesNote } from "./release-images.js";
|
|
22
30
|
import { configMailerAutoconfirm } from "./mailer-autoconfirm.js";
|
|
31
|
+
import { MAILER_PASSTHROUGH_ENV, mailerUrlPathsEnv } from "./mailer-env.js";
|
|
23
32
|
import { studioRuntimeJson } from "./studio-auth-config.js";
|
|
33
|
+
import { patchRouteManifest } from "./route-manifest.js";
|
|
24
34
|
/**
|
|
25
35
|
* The control plane secret as the server and the control plane receive it, and nobody else.
|
|
26
36
|
*
|
|
@@ -34,16 +44,8 @@ export const COMPOSE_PINNED_IMAGE_ENV_KEYS = [
|
|
|
34
44
|
"SUPATYPE_SERVER_IMAGE",
|
|
35
45
|
"SUPATYPE_POSTGRES_IMAGE",
|
|
36
46
|
];
|
|
37
|
-
/**
|
|
38
|
-
|
|
39
|
-
...COMPOSE_PINNED_IMAGE_ENV_KEYS,
|
|
40
|
-
"SUPATYPE_CONTROL_PLANE_IMAGE",
|
|
41
|
-
"SUPATYPE_AUTH_IMAGE",
|
|
42
|
-
"SUPATYPE_STUDIO_IMAGE",
|
|
43
|
-
"SUPATYPE_STORAGE_IMAGE",
|
|
44
|
-
"SUPATYPE_FUNCTIONS_WORKER_IMAGE",
|
|
45
|
-
"SUPATYPE_SEAWEEDFS_IMAGE",
|
|
46
|
-
];
|
|
47
|
+
/** Kong's host port as compose interpolates it: `SUPATYPE_KONG_PORT`, else the default `dev` tries first. */
|
|
48
|
+
const KONG_HOST_PORT = `\${SUPATYPE_KONG_PORT:-${COMPOSE_DEV_KONG_PORT}}`;
|
|
47
49
|
/** Pinned by digest, because the registry this replaced proved a tag can be taken away. */
|
|
48
50
|
const SEAWEEDFS_IMAGE = "chrislusf/seaweedfs:4.46@sha256:08d516132314207d10c8e37cbffc1f32b147d870169688734cc61c6231625b62";
|
|
49
51
|
/**
|
|
@@ -76,7 +78,8 @@ export function dockerImageRef(component, version) {
|
|
|
76
78
|
}
|
|
77
79
|
/**
|
|
78
80
|
* When the user pins `versions` in config, sync matching SUPATYPE_*_IMAGE vars for Compose.
|
|
79
|
-
* Unpinned components are omitted so compose falls back to :
|
|
81
|
+
* Unpinned components are omitted so compose falls back to its defaults: the images this CLI
|
|
82
|
+
* release was tested with (`RELEASE_IMAGES`).
|
|
80
83
|
*
|
|
81
84
|
* `database.image` is written whether or not `versions.postgres` is pinned. It used to reach
|
|
82
85
|
* compose only through the pin, so without one compose ran `supatype/postgres:latest` while the
|
|
@@ -98,7 +101,10 @@ export function composeDockerImageEnv(config) {
|
|
|
98
101
|
}
|
|
99
102
|
return env;
|
|
100
103
|
}
|
|
101
|
-
/**
|
|
104
|
+
/**
|
|
105
|
+
* True when a Docker image tag is a semver/latest ref we expect `docker pull` to resolve. Any other
|
|
106
|
+
* tag may name an image built on this machine, which `update` keeps when no registry has it.
|
|
107
|
+
*/
|
|
102
108
|
export function isRegistryPullableImageRef(ref) {
|
|
103
109
|
const trimmed = ref.trim();
|
|
104
110
|
if (!trimmed)
|
|
@@ -112,42 +118,15 @@ export function isRegistryPullableImageRef(ref) {
|
|
|
112
118
|
return true;
|
|
113
119
|
return false;
|
|
114
120
|
}
|
|
115
|
-
export function hasLocalVersionPins(config) {
|
|
116
|
-
const versions = config.versions;
|
|
117
|
-
if (!versions)
|
|
118
|
-
return false;
|
|
119
|
-
return (versions.engine === VERSION_PIN_LOCAL ||
|
|
120
|
-
versions.server === VERSION_PIN_LOCAL ||
|
|
121
|
-
versions.postgres === VERSION_PIN_LOCAL ||
|
|
122
|
-
versions.deno === VERSION_PIN_LOCAL);
|
|
123
|
-
}
|
|
124
|
-
function readComposeImageEnvValues(cwd) {
|
|
125
|
-
const envPath = resolve(cwd, ".env");
|
|
126
|
-
if (!existsSync(envPath))
|
|
127
|
-
return [];
|
|
128
|
-
const text = readFileSync(envPath, "utf8");
|
|
129
|
-
const values = [];
|
|
130
|
-
for (const key of COMPOSE_IMAGE_ENV_KEYS) {
|
|
131
|
-
const match = text.match(new RegExp(`^${key}=(.+)$`, "m"));
|
|
132
|
-
if (match?.[1])
|
|
133
|
-
values.push(match[1].trim());
|
|
134
|
-
}
|
|
135
|
-
return values;
|
|
136
|
-
}
|
|
137
121
|
/**
|
|
138
|
-
*
|
|
139
|
-
*
|
|
122
|
+
* Say, before a stack starts, which in-repo images run from `:latest` because this CLI is not a
|
|
123
|
+
* release ({@link unpinnedImagesNote}). Read as compose reads them: the shell over `.env`.
|
|
140
124
|
*/
|
|
141
|
-
export function
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
125
|
+
export function noteUnpinnedImages(cwd) {
|
|
126
|
+
const note = unpinnedImagesNote({ ...readEnvFile(cwd), ...process.env });
|
|
127
|
+
if (note !== undefined)
|
|
128
|
+
console.log(`[supatype] ${note}`);
|
|
145
129
|
}
|
|
146
|
-
/**
|
|
147
|
-
* Schema-engine image for a one-off `docker compose run` when pushing schema.
|
|
148
|
-
* Uses config pin when set; otherwise CDN engine semver (Docker Hub `:latest` can lag).
|
|
149
|
-
* Does not touch `.env`, server/postgres still use compose `:latest` defaults.
|
|
150
|
-
*/
|
|
151
130
|
/**
|
|
152
131
|
* Whether this project's database is published to the host, and so needs a `DATABASE_URL` that
|
|
153
132
|
* points at it.
|
|
@@ -176,20 +155,25 @@ function composeDbPortsBlock(devLocal) {
|
|
|
176
155
|
* The engine image a compose push runs. An image named explicitly wins: `SUPATYPE_ENGINE_IMAGE` in
|
|
177
156
|
* the environment (as CI and a local engine build set it) or in the project's `.env` (the documented
|
|
178
157
|
* way to run a local build; the CLI writes it there only from a version pin). Otherwise the pinned
|
|
179
|
-
* version, or the
|
|
180
|
-
* every push ran the latest published engine whatever image a caller asked
|
|
158
|
+
* version, or the engine this CLI release was tested with. This used to set the variable over
|
|
159
|
+
* whatever was named, so every push ran the latest published engine whatever image a caller asked
|
|
160
|
+
* for; and unpinned, it asked the CDN for the latest engine, which moved under an unchanged CLI.
|
|
181
161
|
*/
|
|
182
162
|
export async function schemaEngineImageForPush(config, cwd, env = process.env) {
|
|
183
163
|
const named = env["SUPATYPE_ENGINE_IMAGE"]?.trim() || readEnvFile(cwd)["SUPATYPE_ENGINE_IMAGE"]?.trim();
|
|
184
164
|
if (named)
|
|
185
|
-
return named;
|
|
165
|
+
return supportedEngineImage(named, "SUPATYPE_ENGINE_IMAGE");
|
|
186
166
|
const pinned = pinnedVersion("engine", config);
|
|
187
167
|
if (pinned === VERSION_PIN_LOCAL)
|
|
188
168
|
return undefined;
|
|
189
169
|
if (pinned)
|
|
190
|
-
return dockerImageRef("engine", pinned);
|
|
191
|
-
|
|
192
|
-
|
|
170
|
+
return supportedEngineImage(dockerImageRef("engine", pinned), "versions.engine in supatype.config.ts");
|
|
171
|
+
return supportedEngineImage(RELEASE_IMAGES.engine, "the engine image this CLI build pins");
|
|
172
|
+
}
|
|
173
|
+
/** `image`, once its tag is known not to name an engine older than this CLI needs (engine-floor.ts). */
|
|
174
|
+
function supportedEngineImage(image, from) {
|
|
175
|
+
assertEngineVersionSupported(engineImageVersion(image), from, "image");
|
|
176
|
+
return image;
|
|
193
177
|
}
|
|
194
178
|
/**
|
|
195
179
|
* SeaweedFS reads its identities from a file, so the stack's credentials are a generated artifact
|
|
@@ -229,27 +213,14 @@ export function appUpstreamForCompose(config) {
|
|
|
229
213
|
const upstream = config.app.upstream?.trim();
|
|
230
214
|
return upstream && upstream.length > 0 ? upstream : undefined;
|
|
231
215
|
}
|
|
232
|
-
export function staticDirForCompose(config) {
|
|
233
|
-
if (config.app.mode !== "static")
|
|
234
|
-
return undefined;
|
|
235
|
-
const dir = config.app.static_dir?.trim();
|
|
236
|
-
return dir && dir.length > 0 ? dir : "./public";
|
|
237
|
-
}
|
|
238
216
|
/**
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
* without that flag against the compose file's own folder, `.supatype/self-host`. The CLI always
|
|
243
|
-
* passes the flag. Someone running `docker compose -f .supatype/self-host/docker-compose.yml` by
|
|
244
|
-
* hand does not, and the server came up with that folder as its project: no admin config, manifest,
|
|
245
|
-
* API config, functions or hooks, and an empty `.supatype/self-host/.supatype` left on the host
|
|
246
|
-
* (SA3). Every compose command renders the file again on this machine, so a project that moved is
|
|
247
|
-
* named at its new place the next time one runs. Forward slashes because Docker Desktop on Windows
|
|
248
|
-
* reads `C:/...` as a host path and YAML needs no escaping for them.
|
|
217
|
+
* The directory the app's static files are served from and deployed to: `app.static_dir`, else
|
|
218
|
+
* {@link defaultAppStaticDir}. The server and the control plane had a fallback each, ./public and
|
|
219
|
+
* ./dist, so a deploy could write where the server did not serve.
|
|
249
220
|
*/
|
|
250
|
-
export function
|
|
251
|
-
const
|
|
252
|
-
return
|
|
221
|
+
export function appStaticDir(config) {
|
|
222
|
+
const dir = config.app.static_dir?.trim();
|
|
223
|
+
return dir ? dir : defaultAppStaticDir(Boolean(config.app.vite_dev_url?.trim()));
|
|
253
224
|
}
|
|
254
225
|
/** One bind mount in compose's long syntax, where no colon in a host path can be misread. */
|
|
255
226
|
function bindMount(source, target, readOnly) {
|
|
@@ -267,11 +238,39 @@ function projectMounts(cwd) {
|
|
|
267
238
|
return {
|
|
268
239
|
projectReadOnly: bindMount(root, "/project", true),
|
|
269
240
|
projectWritable: bindMount(root, "/project", false),
|
|
241
|
+
engineProject: bindMount(root, ENGINE_SERVICE.projectDir, false),
|
|
270
242
|
projectState: bindMount(join(root, ".supatype"), "/project/.supatype", false),
|
|
271
243
|
kong: bindMount(paths.kongPath, "/etc/kong/kong.yml", true),
|
|
272
244
|
seaweed: bindMount(paths.s3ConfigPath, "/etc/seaweedfs/s3.json", true),
|
|
273
245
|
};
|
|
274
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* Where a directory of the project appears inside the stack, which mounts the project at /project.
|
|
249
|
+
* A directory outside the project is not in any container, so it is refused here rather than
|
|
250
|
+
* rendered as a path every service would answer 404 for.
|
|
251
|
+
*/
|
|
252
|
+
function containerProjectPath(cwd, hostPath, setting) {
|
|
253
|
+
const root = resolve(cwd);
|
|
254
|
+
const rel = relative(root, hostPath);
|
|
255
|
+
if (rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel)) {
|
|
256
|
+
throw new Error(`${setting} points at ${hostPath}, which is outside the project directory ${root}. ` +
|
|
257
|
+
"The self-host stack mounts only the project directory, at /project, so no service could read it. " +
|
|
258
|
+
"Move it inside the project.");
|
|
259
|
+
}
|
|
260
|
+
return rel === "" ? "/project" : `/project/${rel.split(sep).join("/")}`;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* PostgREST's pre-request lines, which mark each API write's transaction with its caller so
|
|
264
|
+
* after-hooks fed from the change log can tell it from a write made in SQL. Empty for a server
|
|
265
|
+
* older than the one whose migrations create the function (hook-actor.ts).
|
|
266
|
+
*/
|
|
267
|
+
function hookActorLines(config) {
|
|
268
|
+
const env = postgrestHookActorEnv(config);
|
|
269
|
+
if (!("PGRST_DB_PRE_REQUEST" in env))
|
|
270
|
+
return "";
|
|
271
|
+
return (" # Marks each API write's transaction with its caller, for after-hooks fed from the change log.\n" +
|
|
272
|
+
` PGRST_DB_PRE_REQUEST: ${env.PGRST_DB_PRE_REQUEST}\n`);
|
|
273
|
+
}
|
|
275
274
|
/**
|
|
276
275
|
* The DSN every service uses for the schema-owning role.
|
|
277
276
|
*
|
|
@@ -369,9 +368,16 @@ function roleDatabaseUrl(config, role, passwordVar) {
|
|
|
369
368
|
* a missing sign-in form rather than anything naming a port.
|
|
370
369
|
*/
|
|
371
370
|
export const COMPOSE_STUDIO_HOST_URL = `http://host.docker.internal:${STUDIO_DEV_PORT}`;
|
|
372
|
-
/**
|
|
371
|
+
/**
|
|
372
|
+
* Compose's reference to an in-repo image: the variable that names it (IN_REPO_IMAGE_ENV, which the
|
|
373
|
+
* `:latest` note reads too) when set, else this CLI's own.
|
|
374
|
+
*/
|
|
375
|
+
function inRepoImage(name) {
|
|
376
|
+
return `\${${IN_REPO_IMAGE_ENV[name]}:-${RELEASE_IMAGES[name]}}`;
|
|
377
|
+
}
|
|
378
|
+
/** Studio container: this release's Studio image unless SUPATYPE_STUDIO_IMAGE is set in .env. */
|
|
373
379
|
function studioServiceBlock() {
|
|
374
|
-
return ` image:
|
|
380
|
+
return ` image: ${inRepoImage("studio")}`;
|
|
375
381
|
}
|
|
376
382
|
/** Host dev app (Astro/Vite on the machine) as seen from inside compose services. */
|
|
377
383
|
function proxyUpstreamForCompose(upstream, devLocal) {
|
|
@@ -390,6 +396,12 @@ function proxyUpstreamForCompose(upstream, devLocal) {
|
|
|
390
396
|
}
|
|
391
397
|
return trimmed;
|
|
392
398
|
}
|
|
399
|
+
/** Environment entries as lines of a service's `environment:` block. */
|
|
400
|
+
function composeEnvLines(env) {
|
|
401
|
+
return Object.entries(env)
|
|
402
|
+
.map(([name, value]) => ` ${name}: ${value}`)
|
|
403
|
+
.join("\n");
|
|
404
|
+
}
|
|
393
405
|
/**
|
|
394
406
|
* The server's SUPATYPE_CORS_ALLOW_ORIGINS: `api.corsOrigins` first, then what `.env` adds. A
|
|
395
407
|
* trailing comma when `.env` adds nothing is harmless; the server drops empty entries.
|
|
@@ -403,7 +415,7 @@ function serverAppEnvForCompose(config, devLocal) {
|
|
|
403
415
|
const mode = config.app.mode ?? "none";
|
|
404
416
|
const lines = [` SUPATYPE_APP_MODE: ${mode}`];
|
|
405
417
|
if (mode === "static") {
|
|
406
|
-
const dir =
|
|
418
|
+
const dir = appStaticDir(config);
|
|
407
419
|
lines.push(` SUPATYPE_APP_STATIC_DIR: /project/${dir.replace(/^\.\//, "")}`);
|
|
408
420
|
}
|
|
409
421
|
else if (mode === "proxy" && config.app.upstream?.trim()) {
|
|
@@ -468,7 +480,8 @@ export function renderSelfHostCompose(config, cwd = process.cwd(), options) {
|
|
|
468
480
|
const tlsEnabled = selfHostTlsEnabled(config, devLocal);
|
|
469
481
|
const domain = config.server.domain?.trim() ?? "";
|
|
470
482
|
// When TLS is on, default external URLs to https://<domain> so auth links/redirects use HTTPS.
|
|
471
|
-
|
|
483
|
+
// Otherwise Kong's published port, which a fixed 18473 was not once SUPATYPE_KONG_PORT moved it.
|
|
484
|
+
const externalUrlFallback = tlsEnabled ? `https://${domain}` : `http://localhost:${KONG_HOST_PORT}`;
|
|
472
485
|
const siteUrlFallback = tlsEnabled ? `https://${domain}` : "http://localhost:3000";
|
|
473
486
|
// The project's public address, as a compose reference: API_EXTERNAL_URL, which `supatype dev`
|
|
474
487
|
// writes as the gateway's localhost address and a self-host operator sets to their domain. One
|
|
@@ -478,7 +491,12 @@ export function renderSelfHostCompose(config, cwd = process.cwd(), options) {
|
|
|
478
491
|
const authProviderEnv = composeAuthProviderEnv(config, publicApiUrl);
|
|
479
492
|
const studioHostDev = devLocal && hasStudioOverride(config);
|
|
480
493
|
const appEnv = serverAppEnvForCompose(config, devLocal);
|
|
481
|
-
const staticDir =
|
|
494
|
+
const staticDir = appStaticDir(config);
|
|
495
|
+
// functions.path and the project root, as the containers see them. These were hardcoded to
|
|
496
|
+
// /project/functions and /project/hooks, so a project keeping its functions anywhere else had every
|
|
497
|
+
// one of them answer 404 in the stack while native dev served them.
|
|
498
|
+
const functionsDir = containerProjectPath(cwd, preferredFunctionsPathFromProject(config, cwd), config.functions?.path !== undefined ? "functions.path" : "supatype.root");
|
|
499
|
+
const hooksDir = containerProjectPath(cwd, hooksPathFromProject(config, cwd), "supatype.root");
|
|
482
500
|
const composeProject = composeProjectName(config.project.name);
|
|
483
501
|
const studioService = studioServiceBlock();
|
|
484
502
|
const studioBlock = studioHostDev
|
|
@@ -561,7 +579,7 @@ ${seaweedPorts}`;
|
|
|
561
579
|
const kongPorts = tlsEnabled
|
|
562
580
|
? ` - "80:8000"
|
|
563
581
|
- "443:8443"`
|
|
564
|
-
: ` - "
|
|
582
|
+
: ` - "${KONG_HOST_PORT}:8000"`;
|
|
565
583
|
// The RESP server the response cache and Kong's ACME certificates use.
|
|
566
584
|
// Either a Valkey sidecar, or pg_keyspace inside the Postgres container --
|
|
567
585
|
// one stateful service instead of two.
|
|
@@ -627,7 +645,7 @@ ${dbDependencyClause} seaweedfs:
|
|
|
627
645
|
const realtime = realtimeEnabled(config);
|
|
628
646
|
const realtimeBlock = realtime
|
|
629
647
|
? ` realtime:
|
|
630
|
-
image:
|
|
648
|
+
image: ${inRepoImage("realtime")}
|
|
631
649
|
expose:
|
|
632
650
|
- "4000"
|
|
633
651
|
- "4001"
|
|
@@ -744,7 +762,7 @@ ${dbDependency}`
|
|
|
744
762
|
# database still needs (roles, extensions, wal_level for realtime).
|
|
745
763
|
`
|
|
746
764
|
: ` db:
|
|
747
|
-
image: \${SUPATYPE_POSTGRES_IMAGE:-${
|
|
765
|
+
image: \${SUPATYPE_POSTGRES_IMAGE:-${runningPostgresImage(config)}}
|
|
748
766
|
${functionsDb ? networksClause(["default", FUNCTIONS_DB_NETWORK]) : ""} environment:
|
|
749
767
|
POSTGRES_USER: \${POSTGRES_USER:-supatype_admin}
|
|
750
768
|
POSTGRES_PASSWORD: \${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is missing from .env}
|
|
@@ -800,9 +818,9 @@ ${dbServiceBlock} postgrest:
|
|
|
800
818
|
# views and never the base tables, and "public" otherwise. Decided by the same tier as above.
|
|
801
819
|
PGRST_DB_EXTRA_SEARCH_PATH: ${postgrestSchemas.PGRST_DB_EXTRA_SEARCH_PATH}
|
|
802
820
|
PGRST_DB_POOL: 3
|
|
803
|
-
${dbDependency}
|
|
821
|
+
${hookActorLines(config)}${dbDependency}
|
|
804
822
|
storage:
|
|
805
|
-
image:
|
|
823
|
+
image: ${inRepoImage("storage")}
|
|
806
824
|
expose:
|
|
807
825
|
- "5000"
|
|
808
826
|
environment:
|
|
@@ -814,20 +832,41 @@ ${dbDependency}
|
|
|
814
832
|
S3_ACCESS_KEY: ${OBJECT_STORE_ACCESS_KEY}
|
|
815
833
|
S3_SECRET_KEY: ${OBJECT_STORE_SECRET_KEY}
|
|
816
834
|
S3_FORCE_PATH_STYLE: "true"
|
|
835
|
+
# Bytes, -1 for unlimited. A self-hosted project has no plan, so it has no limits until .env
|
|
836
|
+
# sets one; the service on its own defaults to the free tier's 1 GiB quota and 50 MB files.
|
|
837
|
+
PROJECT_TIER: \${PROJECT_TIER:-enterprise}
|
|
838
|
+
STORAGE_QUOTA: \${STORAGE_QUOTA:--1}
|
|
839
|
+
TIER_MAX_UPLOAD_SIZE: \${TIER_MAX_UPLOAD_SIZE:--1}
|
|
840
|
+
MAX_UPLOAD_SIZE: \${MAX_UPLOAD_SIZE:--1}
|
|
817
841
|
${storageDependency}
|
|
818
842
|
functions-worker:
|
|
819
|
-
image:
|
|
843
|
+
image: ${inRepoImage("functions-worker")}
|
|
844
|
+
# An init as PID 1 passes the stop signal on: without one the worker ignored SIGTERM, and every
|
|
845
|
+
# restart a deploy made waited out the whole stop timeout.
|
|
846
|
+
init: true
|
|
847
|
+
# Time to drain the requests in flight before Docker kills it, above the worker's own drain: one
|
|
848
|
+
# Docker killed it 3 s after SIGTERM. The control plane's restart passes the same.
|
|
849
|
+
stop_grace_period: ${FUNCTIONS_WORKER_STOP_GRACE_SECONDS}s
|
|
820
850
|
expose:
|
|
821
851
|
- "8001"
|
|
822
852
|
${networksClause([FUNCTIONS_NETWORK, ...(functionsDb ? [FUNCTIONS_DB_NETWORK] : [])])} volumes:
|
|
823
853
|
${mounts.projectReadOnly}
|
|
824
854
|
environment:
|
|
825
|
-
|
|
826
|
-
|
|
855
|
+
# Deno colours an error's text whether or not it writes to a terminal, and a function's error
|
|
856
|
+
# reaches its caller as JSON (DENO_ENV in native-dev-env.ts).
|
|
857
|
+
NO_COLOR: "1"
|
|
858
|
+
SUPATYPE_FUNCTIONS_ROOT: ${functionsDir}
|
|
859
|
+
SUPATYPE_DENO_FUNCTIONS_DIR: ${functionsDir}
|
|
827
860
|
# Model hooks, served by this same worker under a hooks/ route the gateway refuses from
|
|
828
861
|
# outside. One worker rather than two: a second container would cost a pod per project on
|
|
829
862
|
# cloud, for isolation the route boundary already provides.
|
|
830
|
-
SUPATYPE_HOOKS_ROOT:
|
|
863
|
+
SUPATYPE_HOOKS_ROOT: ${hooksDir}
|
|
864
|
+
# What \`functions env set\` gives the project: the control plane writes it under the project it
|
|
865
|
+
# mounts at /project, and the worker reads it on every call.
|
|
866
|
+
SUPATYPE_FUNCTION_ENV_FILE: /project/.supatype/function-env.json
|
|
867
|
+
# How long requests in flight get to finish when the worker is stopped: under its stop grace
|
|
868
|
+
# above, so it exits by itself before Docker kills it. Its own default is dev's 4 s.
|
|
869
|
+
SUPATYPE_FUNCTIONS_DRAIN_MS: "${FUNCTIONS_WORKER_DRAIN_MS}"
|
|
831
870
|
# Every log line the worker writes carries this, and on cloud it is the label Loki indexes
|
|
832
871
|
# each project's logs under. Without it a line is collected and filed under no project, which
|
|
833
872
|
# is the same as losing it.
|
|
@@ -846,6 +885,12 @@ ${mounts.projectReadOnly}
|
|
|
846
885
|
# each one able to read past every access rule in the schema.
|
|
847
886
|
SUPATYPE_SERVICE_ROLE_KEY: \${SERVICE_ROLE_KEY:-}
|
|
848
887
|
SUPATYPE_SERVICE_ROLE_ROUTES: "${serviceRoleRoutes(config).join(",")}"
|
|
888
|
+
# The list every deploy writes (functions.serviceRole), read on every call, so a route taken off
|
|
889
|
+
# it loses the key on its next call; the list above applies until the first deploy writes it.
|
|
890
|
+
SUPATYPE_SERVICE_ROLE_ROUTES_FILE: /project/.supatype/${SERVICE_ROLE_ROUTES_FILE}
|
|
891
|
+
# The manifest the server reads: a hook route with no code is a 503 only when it names that
|
|
892
|
+
# hook, so a hook the server would call is never taken for one it would not.
|
|
893
|
+
SUPATYPE_MANIFEST_PATH: /project/.supatype/manifest.json
|
|
849
894
|
# A direct database connection for functions, off unless asked for.
|
|
850
895
|
#
|
|
851
896
|
# The worker reads SUPATYPE_DB_URL and exposes it as \`ctx.dbUrl\`, and nothing here ever set
|
|
@@ -864,7 +909,7 @@ ${mounts.projectReadOnly}
|
|
|
864
909
|
${dbDependency}
|
|
865
910
|
${realtimeBlock}
|
|
866
911
|
control-plane:
|
|
867
|
-
image:
|
|
912
|
+
image: ${inRepoImage("control-plane")}
|
|
868
913
|
expose:
|
|
869
914
|
- "8080"
|
|
870
915
|
volumes:
|
|
@@ -875,7 +920,9 @@ ${mounts.projectWritable}
|
|
|
875
920
|
SUPATYPE_PROJECT_REF: ${JSON.stringify(config.project.name)}
|
|
876
921
|
SUPATYPE_PROJECT_ROOT: /project
|
|
877
922
|
DATABASE_URL: "${ownerUrl}"
|
|
878
|
-
SUPATYPE_FUNCTIONS_ROOT:
|
|
923
|
+
SUPATYPE_FUNCTIONS_ROOT: ${functionsDir}
|
|
924
|
+
# Where \`push\` deploys hooks to (POST /projects/:ref/hooks/deploy): the worker's hooks root.
|
|
925
|
+
SUPATYPE_HOOKS_ROOT: ${hooksDir}
|
|
879
926
|
SUPATYPE_STATIC_ROOT: /project/${staticDir.replace(/^\.\//, "")}
|
|
880
927
|
SUPATYPE_DEPLOYMENTS_DIR: /project/.supatype/deployments
|
|
881
928
|
COMPOSE_PROJECT_NAME: ${composeProject}
|
|
@@ -887,7 +934,7 @@ ${mounts.projectWritable}
|
|
|
887
934
|
SUPATYPE_SERVICE_ROLE_KEY: \${SERVICE_ROLE_KEY:?SERVICE_ROLE_KEY is missing from .env}
|
|
888
935
|
${realtimeControlPlaneEnv}${dbDependency}
|
|
889
936
|
server:
|
|
890
|
-
image: \${SUPATYPE_SERVER_IMAGE:-\${SUPATYPE_AUTH_IMAGE
|
|
937
|
+
image: \${SUPATYPE_SERVER_IMAGE:-\${SUPATYPE_AUTH_IMAGE:-${RELEASE_IMAGES.server}}}
|
|
891
938
|
# host.docker.internal is a Docker Desktop name. On Linux it does not resolve unless it is
|
|
892
939
|
# mapped, so a project proxying the site or Studio to something on the host worked on macOS
|
|
893
940
|
# and Windows and failed on Linux with nothing reaching the app. host-gateway is Docker's own
|
|
@@ -931,7 +978,7 @@ ${mounts.projectState}
|
|
|
931
978
|
# back to it and uses it for role membership.
|
|
932
979
|
SUPATYPE_SQL_EDITOR_DATABASE_URL: "${sqlEditorUrl}"
|
|
933
980
|
${serverDbConnectEnv(config, devLocal)}
|
|
934
|
-
SUPATYPE_DENO_FUNCTIONS_DIR:
|
|
981
|
+
SUPATYPE_DENO_FUNCTIONS_DIR: ${functionsDir}
|
|
935
982
|
SUPATYPE_FUNCTIONS_WORKER_URL: http://functions-worker:8001
|
|
936
983
|
${realtimeServerEnv}
|
|
937
984
|
SUPATYPE_CONTROL_PLANE_URL: http://control-plane:8080
|
|
@@ -957,10 +1004,7 @@ ${appEnv}
|
|
|
957
1004
|
# Emailed links are SUPATYPE_API_EXTERNAL_URL plus these paths. The external URL is the
|
|
958
1005
|
# gateway's root, where / belongs to the app, so the server's default of /verify sent every
|
|
959
1006
|
# confirmation, magic-link and recovery link to a 404. The auth routes are under /auth/v1/.
|
|
960
|
-
|
|
961
|
-
SUPATYPE_MAILER_URLPATHS_INVITE: /auth/v1/verify
|
|
962
|
-
SUPATYPE_MAILER_URLPATHS_RECOVERY: /auth/v1/verify
|
|
963
|
-
SUPATYPE_MAILER_URLPATHS_EMAIL_CHANGE: /auth/v1/verify
|
|
1007
|
+
${composeEnvLines(mailerUrlPathsEnv())}
|
|
964
1008
|
# email.provider and email.smtp are config, and nothing used to carry
|
|
965
1009
|
# them here: with no provider and no SMTP host the auth service falls
|
|
966
1010
|
# through to its noop client, so every message was dropped in silence and
|
|
@@ -977,6 +1021,9 @@ ${appEnv}
|
|
|
977
1021
|
SUPATYPE_SMTP_PASS: \${SUPATYPE_SMTP_PASS:-}
|
|
978
1022
|
SUPATYPE_SMTP_ADMIN_EMAIL: \${SUPATYPE_SMTP_ADMIN_EMAIL:-}
|
|
979
1023
|
SUPATYPE_SMTP_SENDER_NAME: \${SUPATYPE_SMTP_SENDER_NAME:-}
|
|
1024
|
+
# Resend's key and sender, and SES's sender, from .env. Without these the server had no way
|
|
1025
|
+
# to get them and a resend or ses provider fell back to the noop mailer.
|
|
1026
|
+
${composeEnvLines(Object.fromEntries(MAILER_PASSTHROUGH_ENV.map((name) => [name, `\${${name}:-}`])))}
|
|
980
1027
|
SUPATYPE_DISABLE_SIGNUP: \${DISABLE_SIGNUP:-false}
|
|
981
1028
|
${authProviderEnv}
|
|
982
1029
|
depends_on:
|
|
@@ -991,12 +1038,12 @@ ${realtimeDependency} control-plane:
|
|
|
991
1038
|
|
|
992
1039
|
${objectStoreBlock}
|
|
993
1040
|
schema-engine:
|
|
994
|
-
image: \${
|
|
1041
|
+
image: \${${ENGINE_SERVICE.imageVariable}:-${ENGINE_SERVICE.defaultImage}}
|
|
995
1042
|
profiles: ["tools"]
|
|
996
|
-
entrypoint: ["
|
|
1043
|
+
entrypoint: ["${ENGINE_SERVICE.entrypoint}"]
|
|
997
1044
|
volumes:
|
|
998
|
-
${mounts.
|
|
999
|
-
working_dir:
|
|
1045
|
+
${mounts.engineProject}
|
|
1046
|
+
working_dir: ${ENGINE_SERVICE.projectDir}
|
|
1000
1047
|
${dbDependency}${studioBlock}${valkeyBlock}${tlsHintComment} kong:
|
|
1001
1048
|
image: kong:3.6
|
|
1002
1049
|
${gatewayNetworks} # host.docker.internal is a Docker Desktop name. On Linux it does not resolve unless it is
|
|
@@ -1026,6 +1073,12 @@ ${gatewayNetworks} # host.docker.internal is a Docker Desktop name. On Linux
|
|
|
1026
1073
|
# for host.docker.internal after a few seconds and Studio's dev server became unreachable
|
|
1027
1074
|
# (CE1). A recreated upstream is handled where the CLI recreates it: Kong is reloaded then
|
|
1028
1075
|
# (runDockerCompose, EXT-N1).
|
|
1076
|
+
#
|
|
1077
|
+
# SRV is not looked up. Kong 3.6 asks for SRV records first, Docker's DNS never answers them,
|
|
1078
|
+
# and each nginx worker's first upstream lookup waited about 4 s for the timeout: the first
|
|
1079
|
+
# realtime subscribe often took that long. A records still come from the hosts file first, so
|
|
1080
|
+
# host.docker.internal above resolves as before.
|
|
1081
|
+
KONG_DNS_ORDER: "LAST,A,CNAME"
|
|
1029
1082
|
${kongTlsEnv} volumes:
|
|
1030
1083
|
${mounts.kong}
|
|
1031
1084
|
ports:
|
|
@@ -1042,46 +1095,41 @@ function ensureComposeManifest(cwd, config) {
|
|
|
1042
1095
|
const manifestPath = join(cwd, ".supatype", "manifest.json");
|
|
1043
1096
|
mkdirSync(dirname(manifestPath), { recursive: true });
|
|
1044
1097
|
// The manifest is generated, not operator-authored, but `push` writes real values into it (the
|
|
1045
|
-
// schema, for one), so an existing file
|
|
1098
|
+
// schema, for one), so an existing file keeps every key but the routes below. Malformed, it is
|
|
1099
|
+
// left for the server to complain about rather than overwritten here.
|
|
1046
1100
|
if (existsSync(manifestPath)) {
|
|
1047
|
-
|
|
1101
|
+
patchRouteManifest(manifestPath, composeServiceRoutes(config), { keepMalformed: true });
|
|
1048
1102
|
return;
|
|
1049
1103
|
}
|
|
1050
|
-
|
|
1104
|
+
patchRouteManifest(manifestPath, {
|
|
1051
1105
|
schema: "public",
|
|
1052
1106
|
postgrest_url: "http://postgrest:3000",
|
|
1107
|
+
...composeServiceRoutes(config),
|
|
1108
|
+
});
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* Where the server finds each service of this stack, set on every render rather than only into a
|
|
1112
|
+
* new file. Native dev shares the manifest and records its own host ports for realtime, functions
|
|
1113
|
+
* and storage, so a project moved from native to Docker kept native's URLs and the server proxied
|
|
1114
|
+
* every subscription and every /storage/v1 call to a port nothing in the stack listened on (502).
|
|
1115
|
+
* An older CLI's `functions_enabled: false` is put right by the same write.
|
|
1116
|
+
*/
|
|
1117
|
+
function composeServiceRoutes(config) {
|
|
1118
|
+
return {
|
|
1119
|
+
// This file always generates a `storage` service, and native dev records its own storage
|
|
1120
|
+
// service on a host port.
|
|
1053
1121
|
storage_url: "http://storage:5000",
|
|
1054
1122
|
// Matches the compose file: a manifest advertising a service that was not generated is how
|
|
1055
|
-
// the server ends up proxying subscriptions to a host that does not resolve.
|
|
1123
|
+
// the server ends up proxying subscriptions to a host that does not resolve. Undefined drops
|
|
1124
|
+
// the key.
|
|
1056
1125
|
realtime_enabled: realtimeEnabled(config),
|
|
1057
|
-
|
|
1126
|
+
realtime_url: realtimeEnabled(config) ? "http://realtime:4000" : undefined,
|
|
1058
1127
|
// True because this file *always* generates a `functions-worker` service and hands the server
|
|
1059
1128
|
// `SUPATYPE_FUNCTIONS_WORKER_URL`. It said false, so the server answered 404 for every function
|
|
1060
1129
|
// in a stack that was running a worker for them, provisioned, then switched off.
|
|
1061
1130
|
functions_enabled: true,
|
|
1062
1131
|
functions_worker_url: COMPOSE_FUNCTIONS_WORKER_URL,
|
|
1063
1132
|
};
|
|
1064
|
-
writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, "utf8");
|
|
1065
|
-
}
|
|
1066
|
-
/**
|
|
1067
|
-
* Turn functions on in a manifest written by an older CLI, leaving every other key alone.
|
|
1068
|
-
*
|
|
1069
|
-
* Without this, only new projects get working functions: a stack generated before the flag was
|
|
1070
|
-
* corrected keeps `functions_enabled: false` on disk, and regenerating the compose file, the
|
|
1071
|
-
* obvious thing to try, does not fix it.
|
|
1072
|
-
*/
|
|
1073
|
-
function repairComposeFunctionsFlag(manifestPath) {
|
|
1074
|
-
// Malformed: leave it for the server to complain about rather than overwrite it here.
|
|
1075
|
-
const parsed = readJsonObjectFile(manifestPath);
|
|
1076
|
-
if (parsed === undefined)
|
|
1077
|
-
return;
|
|
1078
|
-
if (parsed["functions_enabled"] === true && parsed["functions_worker_url"] !== undefined)
|
|
1079
|
-
return;
|
|
1080
|
-
parsed["functions_enabled"] = true;
|
|
1081
|
-
if (parsed["functions_worker_url"] === undefined) {
|
|
1082
|
-
parsed["functions_worker_url"] = COMPOSE_FUNCTIONS_WORKER_URL;
|
|
1083
|
-
}
|
|
1084
|
-
writeFileSync(manifestPath, `${JSON.stringify(parsed, null, 2)}\n`, "utf8");
|
|
1085
1133
|
}
|
|
1086
1134
|
/**
|
|
1087
1135
|
* `POSTGRES_USER`, when the bundled database is in use and it names a role the image cannot run as.
|
|
@@ -1230,6 +1278,9 @@ function resolveDrafts(cwd, config, options) {
|
|
|
1230
1278
|
return projectHasVersionedModels(cwd, config);
|
|
1231
1279
|
}
|
|
1232
1280
|
export function writeSelfHostCompose(cwd, config, options) {
|
|
1281
|
+
// No URL-unsafe password check here: `supatype update` and the dev watcher write this file too,
|
|
1282
|
+
// and start nothing. up, render, restart and dev refuse before they start. push, diff and dev's
|
|
1283
|
+
// recovery only start the database, so they warn (startComposeDatabase in dev-compose.ts).
|
|
1233
1284
|
assertExternalUrlMatchesEnv(cwd, config);
|
|
1234
1285
|
assertBundledDbUser(cwd, config);
|
|
1235
1286
|
const tier = resolveFieldMaskingTier(cwd, config, options);
|
|
@@ -1280,51 +1331,152 @@ export function writeSelfHostCompose(cwd, config, options) {
|
|
|
1280
1331
|
export function exitComposeFailed(status, context, brand) {
|
|
1281
1332
|
fatalError(`docker compose failed (exit ${status}).`, [context, "Check logs: supatype self-host compose logs"], { ...(brand !== undefined && { brand }), exitCode: status === 0 ? 1 : status });
|
|
1282
1333
|
}
|
|
1283
|
-
|
|
1284
|
-
|
|
1334
|
+
/** The `docker` arguments for `docker compose <args>` on one project's file. */
|
|
1335
|
+
function composeInvocation(composePath, args, projectRoot, composeProject, quiet) {
|
|
1285
1336
|
const envFile = resolve(projectRoot, ".env");
|
|
1286
|
-
const composeArgs = ["compose"];
|
|
1287
|
-
if (options?.quiet) {
|
|
1288
|
-
composeArgs.push("--progress", "quiet");
|
|
1289
|
-
}
|
|
1337
|
+
const composeArgs = ["compose", ...(quiet ? ["--progress", "quiet"] : [])];
|
|
1290
1338
|
// Per-project name isolates containers/volumes/network so multiple Supatype
|
|
1291
1339
|
// projects on one machine never share a database (default would be the
|
|
1292
1340
|
// ".supatype/self-host" dir name, identical for every project).
|
|
1293
1341
|
if (composeProject)
|
|
1294
1342
|
composeArgs.push("-p", composeProject);
|
|
1295
1343
|
// Resolve ${VAR} in compose.yml from the project root .env (not .supatype/self-host/).
|
|
1296
|
-
composeArgs.push("--project-directory", projectRoot);
|
|
1297
|
-
|
|
1298
|
-
if (existsSync(envFile)) {
|
|
1344
|
+
composeArgs.push("--project-directory", projectRoot, "-f", composePath);
|
|
1345
|
+
if (existsSync(envFile))
|
|
1299
1346
|
composeArgs.push("--env-file", envFile);
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1347
|
+
return [...composeArgs, ...args];
|
|
1348
|
+
}
|
|
1349
|
+
/**
|
|
1350
|
+
* `docker compose <args>`, synchronously. Its many callers are synchronous, and so are the exit
|
|
1351
|
+
* paths that stop a stack. No limit: `up`, `pull` and `build` wait on registries and builds a
|
|
1352
|
+
* person watches and can stop, and a quiet run here is one of those too (docker-exec.ts).
|
|
1353
|
+
*/
|
|
1354
|
+
export function runDockerCompose(composePath, args, projectRoot = process.cwd(), composeProject, options) {
|
|
1355
|
+
requireDockerDaemon(options?.brand !== undefined ? { brand: options.brand } : undefined);
|
|
1356
|
+
const quiet = options?.quiet === true;
|
|
1357
|
+
const runCompose = () => askDockerSync(composeInvocation(composePath, args, projectRoot, composeProject, quiet), {
|
|
1358
|
+
stdio: quiet ? "pipe" : "inherit",
|
|
1308
1359
|
cwd: projectRoot,
|
|
1309
|
-
env,
|
|
1310
|
-
|
|
1360
|
+
env: composeProcessEnv(projectRoot, quiet),
|
|
1361
|
+
timeoutMs: NO_DOCKER_LIMIT,
|
|
1311
1362
|
});
|
|
1312
1363
|
// Whatever `up` created or recreated keeps its name but not its address, and a Kong that was
|
|
1313
1364
|
// already running would go on sending to the old one (EXT-N1), so that Kong is reloaded.
|
|
1314
1365
|
const result = args[0] === "up" && composeProject !== undefined
|
|
1315
1366
|
? upKeepingKongCurrent(projectRoot, { project: composeProject, composePath }, runCompose)
|
|
1316
1367
|
: runCompose();
|
|
1317
|
-
if (
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1368
|
+
if (result.status !== 0)
|
|
1369
|
+
reportComposeFailure(args, quiet ? capturedComposeOutput(result) : null);
|
|
1370
|
+
return result.status ?? 1;
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* {@link runDockerCompose} quietly and without blocking: while `up` pulls images and starts the
|
|
1374
|
+
* stack, which can take minutes, `supatype dev`'s dashboard keeps drawing and its spinner keeps
|
|
1375
|
+
* turning. The synchronous run froze the screen for all of it.
|
|
1376
|
+
*/
|
|
1377
|
+
export async function runDockerComposeQuietly(composePath, args, projectRoot, composeProject, brand) {
|
|
1378
|
+
const run = quietComposeRun(composePath, args, projectRoot, composeProject, brand);
|
|
1379
|
+
composeInFlight.add(run);
|
|
1380
|
+
try {
|
|
1381
|
+
return await run;
|
|
1382
|
+
}
|
|
1383
|
+
finally {
|
|
1384
|
+
composeInFlight.delete(run);
|
|
1325
1385
|
}
|
|
1386
|
+
}
|
|
1387
|
+
/**
|
|
1388
|
+
* Quiet compose runs still going. A Ctrl+C can reach dev while one runs, now that it does not block,
|
|
1389
|
+
* and a `down` that finished before an `up` still starting would leave the stack running after
|
|
1390
|
+
* dev said it had stopped it. A shutdown waits for these first ({@link settleComposeRuns}).
|
|
1391
|
+
*/
|
|
1392
|
+
const composeInFlight = new Set();
|
|
1393
|
+
/** Resolves once every quiet compose run under way has ended, however it ended. */
|
|
1394
|
+
export async function settleComposeRuns() {
|
|
1395
|
+
await Promise.allSettled([...composeInFlight]);
|
|
1396
|
+
}
|
|
1397
|
+
async function quietComposeRun(composePath, args, projectRoot, composeProject, brand) {
|
|
1398
|
+
await requireDockerDaemonAsync(brand !== undefined ? { brand } : undefined);
|
|
1399
|
+
const runCompose = () => askDockerCompose(composePath, args, projectRoot, composeProject, NO_DOCKER_LIMIT);
|
|
1400
|
+
// As in runDockerCompose: a Kong already running is reloaded when `up` moved what it routes to.
|
|
1401
|
+
const result = args[0] === "up"
|
|
1402
|
+
? await upKeepingKongCurrentAsync(projectRoot, { project: composeProject, composePath }, runCompose)
|
|
1403
|
+
: await runCompose();
|
|
1404
|
+
if (result.status !== 0)
|
|
1405
|
+
reportComposeFailure(args, capturedComposeOutput(result));
|
|
1326
1406
|
return result.status ?? 1;
|
|
1327
1407
|
}
|
|
1408
|
+
/** `docker compose <args>` quietly and asynchronously, within `timeoutMs`: for calls run side by side. */
|
|
1409
|
+
export function askDockerCompose(composePath, args, projectRoot, composeProject, timeoutMs) {
|
|
1410
|
+
const call = { cwd: projectRoot, env: composeProcessEnv(projectRoot, true), timeoutMs };
|
|
1411
|
+
return askDocker(composeInvocation(composePath, args, projectRoot, composeProject, true), call);
|
|
1412
|
+
}
|
|
1413
|
+
/** compose's closing line for an image it could not pull. */
|
|
1414
|
+
const DAEMON_PULL_ERROR = /^Error response from daemon: /;
|
|
1415
|
+
/**
|
|
1416
|
+
* compose's own line for one image's pull that failed, or that it stopped when another failed:
|
|
1417
|
+
* ` Image <ref> Error <why>` and ` Image <ref> Interrupted` (Compose v5), or the same with a status
|
|
1418
|
+
* mark and the service name before it (older Compose v2).
|
|
1419
|
+
*/
|
|
1420
|
+
const IMAGE_PULL_FAILED = /^\s*(?:\S\s+)?(?:Image\s+)?\S+\s+(?:Error|Interrupted)(?:\s|$)/;
|
|
1421
|
+
/**
|
|
1422
|
+
* Whether a line compose's pull writes is shown: its progress, but not its closing daemon errors,
|
|
1423
|
+
* its per-image errors or the pulls it interrupted. Each image whose pull did not finish is pulled
|
|
1424
|
+
* again on its own (compose-image-pull.ts), which says why when it fails, and one kept from this
|
|
1425
|
+
* machine is no failure; compose printed its errors for an image `update` then said it kept (local
|
|
1426
|
+
* test rounds 4 and 7).
|
|
1427
|
+
*/
|
|
1428
|
+
export function shownPullLine(line) {
|
|
1429
|
+
return !DAEMON_PULL_ERROR.test(line) && !IMAGE_PULL_FAILED.test(line);
|
|
1430
|
+
}
|
|
1431
|
+
/** `docker compose pull` for the project, its progress shown as it runs ({@link shownPullLine}); its exit status. */
|
|
1432
|
+
export function pullComposeImages(composePath, projectRoot, composeProject, report) {
|
|
1433
|
+
requireDockerDaemon(report);
|
|
1434
|
+
const child = spawnDocker(composeInvocation(composePath, ["pull"], projectRoot, composeProject, false), {
|
|
1435
|
+
cwd: projectRoot,
|
|
1436
|
+
env: composeProcessEnv(projectRoot, false),
|
|
1437
|
+
stdio: ["ignore", "inherit", "pipe"],
|
|
1438
|
+
windowsHide: true,
|
|
1439
|
+
});
|
|
1440
|
+
if (child.stderr !== null) {
|
|
1441
|
+
createInterface({ input: child.stderr }).on("line", (line) => {
|
|
1442
|
+
if (shownPullLine(line))
|
|
1443
|
+
process.stderr.write(`${line}\n`);
|
|
1444
|
+
});
|
|
1445
|
+
}
|
|
1446
|
+
return new Promise((resolve) => {
|
|
1447
|
+
child.on("error", () => resolve(1));
|
|
1448
|
+
child.on("close", (code) => resolve(code ?? 1));
|
|
1449
|
+
});
|
|
1450
|
+
}
|
|
1451
|
+
/** The environment compose runs with: the CLI's, less the shell's keys `.env` overrides. */
|
|
1452
|
+
function composeProcessEnv(projectRoot, quiet) {
|
|
1453
|
+
const env = { ...process.env, ...(quiet && { COMPOSE_PROGRESS: "quiet" }) };
|
|
1454
|
+
const fromFile = readEnvFile(projectRoot);
|
|
1455
|
+
for (const name of ENV_FILE_OVER_SHELL) {
|
|
1456
|
+
if (envFileOverridesShell(fromFile, name, env[name]))
|
|
1457
|
+
delete env[name];
|
|
1458
|
+
}
|
|
1459
|
+
return env;
|
|
1460
|
+
}
|
|
1461
|
+
/** What a quiet compose run printed, from the streams the CLI captured. */
|
|
1462
|
+
function capturedComposeOutput(result) {
|
|
1463
|
+
return [result.stderr, result.stdout]
|
|
1464
|
+
.filter((s) => typeof s === "string" && s.trim() !== "")
|
|
1465
|
+
.join("\n")
|
|
1466
|
+
.trim();
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1469
|
+
* Say what a failed compose run printed, when the CLI captured it, and any cause it recognises.
|
|
1470
|
+
* `captured` is null when the output already went to the terminal.
|
|
1471
|
+
*/
|
|
1472
|
+
function reportComposeFailure(args, captured) {
|
|
1473
|
+
if (captured)
|
|
1474
|
+
console.error(`[supatype] docker compose: ${captured}`);
|
|
1475
|
+
if (args[0] !== "up")
|
|
1476
|
+
return;
|
|
1477
|
+
for (const line of addressPoolExhaustionHint(captured))
|
|
1478
|
+
console.error(`[supatype] ${line}`);
|
|
1479
|
+
}
|
|
1328
1480
|
/** Compose project name for a Supatype project, isolates docker state per project. */
|
|
1329
1481
|
export function composeProjectName(projectName) {
|
|
1330
1482
|
const slug = projectName.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "");
|