@supatype/cli 0.7.0 → 0.8.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 +259 -0
- package/bin/supatype.js +25 -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/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/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/binary-cache.d.ts +25 -2
- package/dist/binary-cache.d.ts.map +1 -1
- package/dist/binary-cache.js +115 -81
- 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/cache-pins.d.ts.map +1 -1
- package/dist/cache-pins.js +2 -2
- package/dist/cache-pins.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 +5 -4
- 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 +2 -2
- 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 +262 -266
- package/dist/commands/dev.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.js +26 -11
- package/dist/commands/hooks.js.map +1 -1
- package/dist/commands/init.d.ts +16 -2
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +237 -143
- 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 +36 -10
- package/dist/commands/keys.d.ts.map +1 -1
- package/dist/commands/keys.js +168 -128
- 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 -9
- 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 +37 -0
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +188 -73
- 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 +61 -29
- package/dist/commands/self-host.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.map +1 -1
- package/dist/compose-kong.js +10 -6
- 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 +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -1
- package/dist/database-url-owner.d.ts +57 -0
- package/dist/database-url-owner.d.ts.map +1 -0
- package/dist/database-url-owner.js +130 -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 +40 -18
- package/dist/db-port.d.ts.map +1 -1
- package/dist/db-port.js +33 -31
- package/dist/db-port.js.map +1 -1
- package/dist/db-preflight.d.ts +8 -0
- package/dist/db-preflight.d.ts.map +1 -1
- package/dist/db-preflight.js +18 -1
- 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 +5 -12
- package/dist/dev-compose.d.ts.map +1 -1
- package/dist/dev-compose.js +153 -245
- 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-ports.d.ts +22 -7
- package/dist/dev-ports.d.ts.map +1 -1
- package/dist/dev-ports.js +61 -38
- 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.map +1 -1
- package/dist/dev-session.js +3 -0
- 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 +206 -31
- package/dist/dev-shutdown.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 +12 -1
- package/dist/docker-runtime.d.ts.map +1 -1
- package/dist/docker-runtime.js +48 -23
- 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 +10 -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 +10 -0
- package/dist/engine-ownership-gate.d.ts.map +1 -1
- package/dist/engine-ownership-gate.js +31 -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 +28 -8
- package/dist/env-file.d.ts.map +1 -1
- package/dist/env-file.js +80 -53
- 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/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-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 +7 -2
- 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 +22 -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.map +1 -1
- package/dist/init-package-json.js +2 -0
- 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 +17 -7
- package/dist/model-hooks.d.ts.map +1 -1
- package/dist/model-hooks.js +52 -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 +40 -7
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +42 -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 +62 -0
- package/dist/resolve-target.d.ts.map +1 -1
- package/dist/resolve-target.js +68 -23
- 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 +32 -30
- package/dist/self-host-compose.d.ts.map +1 -1
- package/dist/self-host-compose.js +252 -152
- 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 +18 -7
- 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/type-extractor.d.ts +6 -0
- package/dist/type-extractor.d.ts.map +1 -1
- package/dist/type-extractor.js +118 -59
- 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 +4 -2
- 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 +5 -0
- package/dist/ui/flows/prompt-fields.d.ts.map +1 -1
- package/dist/ui/flows/prompt-fields.js +8 -1
- 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 +9 -6
- 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,35 @@
|
|
|
1
|
-
import { existsSync, mkdirSync,
|
|
2
|
-
import { dirname, join, resolve, sep } from "node:path";
|
|
3
|
-
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";
|
|
4
8
|
import { requireDockerDaemon } 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, 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
20
|
import { upKeepingKongCurrent } 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 { IN_REPO_IMAGE_ENV, RELEASE_IMAGES, unpinnedImagesNote } from "./release-images.js";
|
|
22
29
|
import { configMailerAutoconfirm } from "./mailer-autoconfirm.js";
|
|
30
|
+
import { MAILER_PASSTHROUGH_ENV, mailerUrlPathsEnv } from "./mailer-env.js";
|
|
23
31
|
import { studioRuntimeJson } from "./studio-auth-config.js";
|
|
32
|
+
import { patchRouteManifest } from "./route-manifest.js";
|
|
24
33
|
/**
|
|
25
34
|
* The control plane secret as the server and the control plane receive it, and nobody else.
|
|
26
35
|
*
|
|
@@ -34,16 +43,8 @@ export const COMPOSE_PINNED_IMAGE_ENV_KEYS = [
|
|
|
34
43
|
"SUPATYPE_SERVER_IMAGE",
|
|
35
44
|
"SUPATYPE_POSTGRES_IMAGE",
|
|
36
45
|
];
|
|
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
|
-
];
|
|
46
|
+
/** Kong's host port as compose interpolates it: `SUPATYPE_KONG_PORT`, else the default `dev` tries first. */
|
|
47
|
+
const KONG_HOST_PORT = `\${SUPATYPE_KONG_PORT:-${COMPOSE_DEV_KONG_PORT}}`;
|
|
47
48
|
/** Pinned by digest, because the registry this replaced proved a tag can be taken away. */
|
|
48
49
|
const SEAWEEDFS_IMAGE = "chrislusf/seaweedfs:4.46@sha256:08d516132314207d10c8e37cbffc1f32b147d870169688734cc61c6231625b62";
|
|
49
50
|
/**
|
|
@@ -76,7 +77,8 @@ export function dockerImageRef(component, version) {
|
|
|
76
77
|
}
|
|
77
78
|
/**
|
|
78
79
|
* When the user pins `versions` in config, sync matching SUPATYPE_*_IMAGE vars for Compose.
|
|
79
|
-
* Unpinned components are omitted so compose falls back to :
|
|
80
|
+
* Unpinned components are omitted so compose falls back to its defaults: the images this CLI
|
|
81
|
+
* release was tested with (`RELEASE_IMAGES`).
|
|
80
82
|
*
|
|
81
83
|
* `database.image` is written whether or not `versions.postgres` is pinned. It used to reach
|
|
82
84
|
* compose only through the pin, so without one compose ran `supatype/postgres:latest` while the
|
|
@@ -98,7 +100,10 @@ export function composeDockerImageEnv(config) {
|
|
|
98
100
|
}
|
|
99
101
|
return env;
|
|
100
102
|
}
|
|
101
|
-
/**
|
|
103
|
+
/**
|
|
104
|
+
* True when a Docker image tag is a semver/latest ref we expect `docker pull` to resolve. Any other
|
|
105
|
+
* tag may name an image built on this machine, which `update` keeps when no registry has it.
|
|
106
|
+
*/
|
|
102
107
|
export function isRegistryPullableImageRef(ref) {
|
|
103
108
|
const trimmed = ref.trim();
|
|
104
109
|
if (!trimmed)
|
|
@@ -112,42 +117,15 @@ export function isRegistryPullableImageRef(ref) {
|
|
|
112
117
|
return true;
|
|
113
118
|
return false;
|
|
114
119
|
}
|
|
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
120
|
/**
|
|
138
|
-
*
|
|
139
|
-
*
|
|
121
|
+
* Say, before a stack starts, which in-repo images run from `:latest` because this CLI is not a
|
|
122
|
+
* release ({@link unpinnedImagesNote}). Read as compose reads them: the shell over `.env`.
|
|
140
123
|
*/
|
|
141
|
-
export function
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
124
|
+
export function noteUnpinnedImages(cwd) {
|
|
125
|
+
const note = unpinnedImagesNote({ ...readEnvFile(cwd), ...process.env });
|
|
126
|
+
if (note !== undefined)
|
|
127
|
+
console.log(`[supatype] ${note}`);
|
|
145
128
|
}
|
|
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
129
|
/**
|
|
152
130
|
* Whether this project's database is published to the host, and so needs a `DATABASE_URL` that
|
|
153
131
|
* points at it.
|
|
@@ -176,20 +154,25 @@ function composeDbPortsBlock(devLocal) {
|
|
|
176
154
|
* The engine image a compose push runs. An image named explicitly wins: `SUPATYPE_ENGINE_IMAGE` in
|
|
177
155
|
* the environment (as CI and a local engine build set it) or in the project's `.env` (the documented
|
|
178
156
|
* 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
|
|
157
|
+
* version, or the engine this CLI release was tested with. This used to set the variable over
|
|
158
|
+
* whatever was named, so every push ran the latest published engine whatever image a caller asked
|
|
159
|
+
* for; and unpinned, it asked the CDN for the latest engine, which moved under an unchanged CLI.
|
|
181
160
|
*/
|
|
182
161
|
export async function schemaEngineImageForPush(config, cwd, env = process.env) {
|
|
183
162
|
const named = env["SUPATYPE_ENGINE_IMAGE"]?.trim() || readEnvFile(cwd)["SUPATYPE_ENGINE_IMAGE"]?.trim();
|
|
184
163
|
if (named)
|
|
185
|
-
return named;
|
|
164
|
+
return supportedEngineImage(named, "SUPATYPE_ENGINE_IMAGE");
|
|
186
165
|
const pinned = pinnedVersion("engine", config);
|
|
187
166
|
if (pinned === VERSION_PIN_LOCAL)
|
|
188
167
|
return undefined;
|
|
189
168
|
if (pinned)
|
|
190
|
-
return dockerImageRef("engine", pinned);
|
|
191
|
-
|
|
192
|
-
|
|
169
|
+
return supportedEngineImage(dockerImageRef("engine", pinned), "versions.engine in supatype.config.ts");
|
|
170
|
+
return supportedEngineImage(RELEASE_IMAGES.engine, "the engine image this CLI build pins");
|
|
171
|
+
}
|
|
172
|
+
/** `image`, once its tag is known not to name an engine older than this CLI needs (engine-floor.ts). */
|
|
173
|
+
function supportedEngineImage(image, from) {
|
|
174
|
+
assertEngineVersionSupported(engineImageVersion(image), from, "image");
|
|
175
|
+
return image;
|
|
193
176
|
}
|
|
194
177
|
/**
|
|
195
178
|
* SeaweedFS reads its identities from a file, so the stack's credentials are a generated artifact
|
|
@@ -235,22 +218,6 @@ export function staticDirForCompose(config) {
|
|
|
235
218
|
const dir = config.app.static_dir?.trim();
|
|
236
219
|
return dir && dir.length > 0 ? dir : "./public";
|
|
237
220
|
}
|
|
238
|
-
/**
|
|
239
|
-
* A host path as the generated compose file names it: absolute, with forward slashes.
|
|
240
|
-
*
|
|
241
|
-
* Absolute because compose resolves a relative bind source against `--project-directory`, and
|
|
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.
|
|
249
|
-
*/
|
|
250
|
-
export function composeHostPath(path) {
|
|
251
|
-
const absolute = resolve(path);
|
|
252
|
-
return sep === "\\" ? absolute.replace(/\\/g, "/") : absolute;
|
|
253
|
-
}
|
|
254
221
|
/** One bind mount in compose's long syntax, where no colon in a host path can be misread. */
|
|
255
222
|
function bindMount(source, target, readOnly) {
|
|
256
223
|
return [
|
|
@@ -267,11 +234,27 @@ function projectMounts(cwd) {
|
|
|
267
234
|
return {
|
|
268
235
|
projectReadOnly: bindMount(root, "/project", true),
|
|
269
236
|
projectWritable: bindMount(root, "/project", false),
|
|
237
|
+
engineProject: bindMount(root, ENGINE_SERVICE.projectDir, false),
|
|
270
238
|
projectState: bindMount(join(root, ".supatype"), "/project/.supatype", false),
|
|
271
239
|
kong: bindMount(paths.kongPath, "/etc/kong/kong.yml", true),
|
|
272
240
|
seaweed: bindMount(paths.s3ConfigPath, "/etc/seaweedfs/s3.json", true),
|
|
273
241
|
};
|
|
274
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* Where a directory of the project appears inside the stack, which mounts the project at /project.
|
|
245
|
+
* A directory outside the project is not in any container, so it is refused here rather than
|
|
246
|
+
* rendered as a path every service would answer 404 for.
|
|
247
|
+
*/
|
|
248
|
+
function containerProjectPath(cwd, hostPath, setting) {
|
|
249
|
+
const root = resolve(cwd);
|
|
250
|
+
const rel = relative(root, hostPath);
|
|
251
|
+
if (rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel)) {
|
|
252
|
+
throw new Error(`${setting} points at ${hostPath}, which is outside the project directory ${root}. ` +
|
|
253
|
+
"The self-host stack mounts only the project directory, at /project, so no service could read it. " +
|
|
254
|
+
"Move it inside the project.");
|
|
255
|
+
}
|
|
256
|
+
return rel === "" ? "/project" : `/project/${rel.split(sep).join("/")}`;
|
|
257
|
+
}
|
|
275
258
|
/**
|
|
276
259
|
* The DSN every service uses for the schema-owning role.
|
|
277
260
|
*
|
|
@@ -369,9 +352,16 @@ function roleDatabaseUrl(config, role, passwordVar) {
|
|
|
369
352
|
* a missing sign-in form rather than anything naming a port.
|
|
370
353
|
*/
|
|
371
354
|
export const COMPOSE_STUDIO_HOST_URL = `http://host.docker.internal:${STUDIO_DEV_PORT}`;
|
|
372
|
-
/**
|
|
355
|
+
/**
|
|
356
|
+
* Compose's reference to an in-repo image: the variable that names it (IN_REPO_IMAGE_ENV, which the
|
|
357
|
+
* `:latest` note reads too) when set, else this CLI's own.
|
|
358
|
+
*/
|
|
359
|
+
function inRepoImage(name) {
|
|
360
|
+
return `\${${IN_REPO_IMAGE_ENV[name]}:-${RELEASE_IMAGES[name]}}`;
|
|
361
|
+
}
|
|
362
|
+
/** Studio container: this release's Studio image unless SUPATYPE_STUDIO_IMAGE is set in .env. */
|
|
373
363
|
function studioServiceBlock() {
|
|
374
|
-
return ` image:
|
|
364
|
+
return ` image: ${inRepoImage("studio")}`;
|
|
375
365
|
}
|
|
376
366
|
/** Host dev app (Astro/Vite on the machine) as seen from inside compose services. */
|
|
377
367
|
function proxyUpstreamForCompose(upstream, devLocal) {
|
|
@@ -390,6 +380,12 @@ function proxyUpstreamForCompose(upstream, devLocal) {
|
|
|
390
380
|
}
|
|
391
381
|
return trimmed;
|
|
392
382
|
}
|
|
383
|
+
/** Environment entries as lines of a service's `environment:` block. */
|
|
384
|
+
function composeEnvLines(env) {
|
|
385
|
+
return Object.entries(env)
|
|
386
|
+
.map(([name, value]) => ` ${name}: ${value}`)
|
|
387
|
+
.join("\n");
|
|
388
|
+
}
|
|
393
389
|
/**
|
|
394
390
|
* The server's SUPATYPE_CORS_ALLOW_ORIGINS: `api.corsOrigins` first, then what `.env` adds. A
|
|
395
391
|
* trailing comma when `.env` adds nothing is harmless; the server drops empty entries.
|
|
@@ -468,7 +464,8 @@ export function renderSelfHostCompose(config, cwd = process.cwd(), options) {
|
|
|
468
464
|
const tlsEnabled = selfHostTlsEnabled(config, devLocal);
|
|
469
465
|
const domain = config.server.domain?.trim() ?? "";
|
|
470
466
|
// When TLS is on, default external URLs to https://<domain> so auth links/redirects use HTTPS.
|
|
471
|
-
|
|
467
|
+
// Otherwise Kong's published port, which a fixed 18473 was not once SUPATYPE_KONG_PORT moved it.
|
|
468
|
+
const externalUrlFallback = tlsEnabled ? `https://${domain}` : `http://localhost:${KONG_HOST_PORT}`;
|
|
472
469
|
const siteUrlFallback = tlsEnabled ? `https://${domain}` : "http://localhost:3000";
|
|
473
470
|
// The project's public address, as a compose reference: API_EXTERNAL_URL, which `supatype dev`
|
|
474
471
|
// writes as the gateway's localhost address and a self-host operator sets to their domain. One
|
|
@@ -479,6 +476,11 @@ export function renderSelfHostCompose(config, cwd = process.cwd(), options) {
|
|
|
479
476
|
const studioHostDev = devLocal && hasStudioOverride(config);
|
|
480
477
|
const appEnv = serverAppEnvForCompose(config, devLocal);
|
|
481
478
|
const staticDir = staticDirForCompose(config) ?? "./dist";
|
|
479
|
+
// functions.path and the project root, as the containers see them. These were hardcoded to
|
|
480
|
+
// /project/functions and /project/hooks, so a project keeping its functions anywhere else had every
|
|
481
|
+
// one of them answer 404 in the stack while native dev served them.
|
|
482
|
+
const functionsDir = containerProjectPath(cwd, preferredFunctionsPathFromProject(config, cwd), config.functions?.path !== undefined ? "functions.path" : "supatype.root");
|
|
483
|
+
const hooksDir = containerProjectPath(cwd, hooksPathFromProject(config, cwd), "supatype.root");
|
|
482
484
|
const composeProject = composeProjectName(config.project.name);
|
|
483
485
|
const studioService = studioServiceBlock();
|
|
484
486
|
const studioBlock = studioHostDev
|
|
@@ -561,7 +563,7 @@ ${seaweedPorts}`;
|
|
|
561
563
|
const kongPorts = tlsEnabled
|
|
562
564
|
? ` - "80:8000"
|
|
563
565
|
- "443:8443"`
|
|
564
|
-
: ` - "
|
|
566
|
+
: ` - "${KONG_HOST_PORT}:8000"`;
|
|
565
567
|
// The RESP server the response cache and Kong's ACME certificates use.
|
|
566
568
|
// Either a Valkey sidecar, or pg_keyspace inside the Postgres container --
|
|
567
569
|
// one stateful service instead of two.
|
|
@@ -627,7 +629,7 @@ ${dbDependencyClause} seaweedfs:
|
|
|
627
629
|
const realtime = realtimeEnabled(config);
|
|
628
630
|
const realtimeBlock = realtime
|
|
629
631
|
? ` realtime:
|
|
630
|
-
image:
|
|
632
|
+
image: ${inRepoImage("realtime")}
|
|
631
633
|
expose:
|
|
632
634
|
- "4000"
|
|
633
635
|
- "4001"
|
|
@@ -744,7 +746,7 @@ ${dbDependency}`
|
|
|
744
746
|
# database still needs (roles, extensions, wal_level for realtime).
|
|
745
747
|
`
|
|
746
748
|
: ` db:
|
|
747
|
-
image: \${SUPATYPE_POSTGRES_IMAGE:-${
|
|
749
|
+
image: \${SUPATYPE_POSTGRES_IMAGE:-${runningPostgresImage(config)}}
|
|
748
750
|
${functionsDb ? networksClause(["default", FUNCTIONS_DB_NETWORK]) : ""} environment:
|
|
749
751
|
POSTGRES_USER: \${POSTGRES_USER:-supatype_admin}
|
|
750
752
|
POSTGRES_PASSWORD: \${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is missing from .env}
|
|
@@ -802,7 +804,7 @@ ${dbServiceBlock} postgrest:
|
|
|
802
804
|
PGRST_DB_POOL: 3
|
|
803
805
|
${dbDependency}
|
|
804
806
|
storage:
|
|
805
|
-
image:
|
|
807
|
+
image: ${inRepoImage("storage")}
|
|
806
808
|
expose:
|
|
807
809
|
- "5000"
|
|
808
810
|
environment:
|
|
@@ -814,20 +816,41 @@ ${dbDependency}
|
|
|
814
816
|
S3_ACCESS_KEY: ${OBJECT_STORE_ACCESS_KEY}
|
|
815
817
|
S3_SECRET_KEY: ${OBJECT_STORE_SECRET_KEY}
|
|
816
818
|
S3_FORCE_PATH_STYLE: "true"
|
|
819
|
+
# Bytes, -1 for unlimited. A self-hosted project has no plan, so it has no limits until .env
|
|
820
|
+
# sets one; the service on its own defaults to the free tier's 1 GiB quota and 50 MB files.
|
|
821
|
+
PROJECT_TIER: \${PROJECT_TIER:-enterprise}
|
|
822
|
+
STORAGE_QUOTA: \${STORAGE_QUOTA:--1}
|
|
823
|
+
TIER_MAX_UPLOAD_SIZE: \${TIER_MAX_UPLOAD_SIZE:--1}
|
|
824
|
+
MAX_UPLOAD_SIZE: \${MAX_UPLOAD_SIZE:--1}
|
|
817
825
|
${storageDependency}
|
|
818
826
|
functions-worker:
|
|
819
|
-
image:
|
|
827
|
+
image: ${inRepoImage("functions-worker")}
|
|
828
|
+
# An init as PID 1 passes the stop signal on: without one the worker ignored SIGTERM, and every
|
|
829
|
+
# restart a deploy made waited out the whole stop timeout.
|
|
830
|
+
init: true
|
|
831
|
+
# Time to drain the requests in flight before Docker kills it, above the worker's own drain: one
|
|
832
|
+
# Docker killed it 3 s after SIGTERM. The control plane's restart passes the same.
|
|
833
|
+
stop_grace_period: ${FUNCTIONS_WORKER_STOP_GRACE_SECONDS}s
|
|
820
834
|
expose:
|
|
821
835
|
- "8001"
|
|
822
836
|
${networksClause([FUNCTIONS_NETWORK, ...(functionsDb ? [FUNCTIONS_DB_NETWORK] : [])])} volumes:
|
|
823
837
|
${mounts.projectReadOnly}
|
|
824
838
|
environment:
|
|
825
|
-
|
|
826
|
-
|
|
839
|
+
# Deno colours an error's text whether or not it writes to a terminal, and a function's error
|
|
840
|
+
# reaches its caller as JSON (DENO_ENV in native-dev-env.ts).
|
|
841
|
+
NO_COLOR: "1"
|
|
842
|
+
SUPATYPE_FUNCTIONS_ROOT: ${functionsDir}
|
|
843
|
+
SUPATYPE_DENO_FUNCTIONS_DIR: ${functionsDir}
|
|
827
844
|
# Model hooks, served by this same worker under a hooks/ route the gateway refuses from
|
|
828
845
|
# outside. One worker rather than two: a second container would cost a pod per project on
|
|
829
846
|
# cloud, for isolation the route boundary already provides.
|
|
830
|
-
SUPATYPE_HOOKS_ROOT:
|
|
847
|
+
SUPATYPE_HOOKS_ROOT: ${hooksDir}
|
|
848
|
+
# What \`functions env set\` gives the project: the control plane writes it under the project it
|
|
849
|
+
# mounts at /project, and the worker reads it on every call.
|
|
850
|
+
SUPATYPE_FUNCTION_ENV_FILE: /project/.supatype/function-env.json
|
|
851
|
+
# How long requests in flight get to finish when the worker is stopped: under its stop grace
|
|
852
|
+
# above, so it exits by itself before Docker kills it. Its own default is dev's 4 s.
|
|
853
|
+
SUPATYPE_FUNCTIONS_DRAIN_MS: "${FUNCTIONS_WORKER_DRAIN_MS}"
|
|
831
854
|
# Every log line the worker writes carries this, and on cloud it is the label Loki indexes
|
|
832
855
|
# each project's logs under. Without it a line is collected and filed under no project, which
|
|
833
856
|
# is the same as losing it.
|
|
@@ -846,6 +869,12 @@ ${mounts.projectReadOnly}
|
|
|
846
869
|
# each one able to read past every access rule in the schema.
|
|
847
870
|
SUPATYPE_SERVICE_ROLE_KEY: \${SERVICE_ROLE_KEY:-}
|
|
848
871
|
SUPATYPE_SERVICE_ROLE_ROUTES: "${serviceRoleRoutes(config).join(",")}"
|
|
872
|
+
# The list every deploy writes (functions.serviceRole), read on every call, so a route taken off
|
|
873
|
+
# it loses the key on its next call; the list above applies until the first deploy writes it.
|
|
874
|
+
SUPATYPE_SERVICE_ROLE_ROUTES_FILE: /project/.supatype/${SERVICE_ROLE_ROUTES_FILE}
|
|
875
|
+
# The manifest the server reads: a hook route with no code is a 503 only when it names that
|
|
876
|
+
# hook, so a hook the server would call is never taken for one it would not.
|
|
877
|
+
SUPATYPE_MANIFEST_PATH: /project/.supatype/manifest.json
|
|
849
878
|
# A direct database connection for functions, off unless asked for.
|
|
850
879
|
#
|
|
851
880
|
# The worker reads SUPATYPE_DB_URL and exposes it as \`ctx.dbUrl\`, and nothing here ever set
|
|
@@ -864,7 +893,7 @@ ${mounts.projectReadOnly}
|
|
|
864
893
|
${dbDependency}
|
|
865
894
|
${realtimeBlock}
|
|
866
895
|
control-plane:
|
|
867
|
-
image:
|
|
896
|
+
image: ${inRepoImage("control-plane")}
|
|
868
897
|
expose:
|
|
869
898
|
- "8080"
|
|
870
899
|
volumes:
|
|
@@ -875,7 +904,9 @@ ${mounts.projectWritable}
|
|
|
875
904
|
SUPATYPE_PROJECT_REF: ${JSON.stringify(config.project.name)}
|
|
876
905
|
SUPATYPE_PROJECT_ROOT: /project
|
|
877
906
|
DATABASE_URL: "${ownerUrl}"
|
|
878
|
-
SUPATYPE_FUNCTIONS_ROOT:
|
|
907
|
+
SUPATYPE_FUNCTIONS_ROOT: ${functionsDir}
|
|
908
|
+
# Where \`push\` deploys hooks to (POST /projects/:ref/hooks/deploy): the worker's hooks root.
|
|
909
|
+
SUPATYPE_HOOKS_ROOT: ${hooksDir}
|
|
879
910
|
SUPATYPE_STATIC_ROOT: /project/${staticDir.replace(/^\.\//, "")}
|
|
880
911
|
SUPATYPE_DEPLOYMENTS_DIR: /project/.supatype/deployments
|
|
881
912
|
COMPOSE_PROJECT_NAME: ${composeProject}
|
|
@@ -887,7 +918,7 @@ ${mounts.projectWritable}
|
|
|
887
918
|
SUPATYPE_SERVICE_ROLE_KEY: \${SERVICE_ROLE_KEY:?SERVICE_ROLE_KEY is missing from .env}
|
|
888
919
|
${realtimeControlPlaneEnv}${dbDependency}
|
|
889
920
|
server:
|
|
890
|
-
image: \${SUPATYPE_SERVER_IMAGE:-\${SUPATYPE_AUTH_IMAGE
|
|
921
|
+
image: \${SUPATYPE_SERVER_IMAGE:-\${SUPATYPE_AUTH_IMAGE:-${RELEASE_IMAGES.server}}}
|
|
891
922
|
# host.docker.internal is a Docker Desktop name. On Linux it does not resolve unless it is
|
|
892
923
|
# mapped, so a project proxying the site or Studio to something on the host worked on macOS
|
|
893
924
|
# and Windows and failed on Linux with nothing reaching the app. host-gateway is Docker's own
|
|
@@ -931,7 +962,7 @@ ${mounts.projectState}
|
|
|
931
962
|
# back to it and uses it for role membership.
|
|
932
963
|
SUPATYPE_SQL_EDITOR_DATABASE_URL: "${sqlEditorUrl}"
|
|
933
964
|
${serverDbConnectEnv(config, devLocal)}
|
|
934
|
-
SUPATYPE_DENO_FUNCTIONS_DIR:
|
|
965
|
+
SUPATYPE_DENO_FUNCTIONS_DIR: ${functionsDir}
|
|
935
966
|
SUPATYPE_FUNCTIONS_WORKER_URL: http://functions-worker:8001
|
|
936
967
|
${realtimeServerEnv}
|
|
937
968
|
SUPATYPE_CONTROL_PLANE_URL: http://control-plane:8080
|
|
@@ -957,10 +988,7 @@ ${appEnv}
|
|
|
957
988
|
# Emailed links are SUPATYPE_API_EXTERNAL_URL plus these paths. The external URL is the
|
|
958
989
|
# gateway's root, where / belongs to the app, so the server's default of /verify sent every
|
|
959
990
|
# 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
|
|
991
|
+
${composeEnvLines(mailerUrlPathsEnv())}
|
|
964
992
|
# email.provider and email.smtp are config, and nothing used to carry
|
|
965
993
|
# them here: with no provider and no SMTP host the auth service falls
|
|
966
994
|
# through to its noop client, so every message was dropped in silence and
|
|
@@ -977,6 +1005,9 @@ ${appEnv}
|
|
|
977
1005
|
SUPATYPE_SMTP_PASS: \${SUPATYPE_SMTP_PASS:-}
|
|
978
1006
|
SUPATYPE_SMTP_ADMIN_EMAIL: \${SUPATYPE_SMTP_ADMIN_EMAIL:-}
|
|
979
1007
|
SUPATYPE_SMTP_SENDER_NAME: \${SUPATYPE_SMTP_SENDER_NAME:-}
|
|
1008
|
+
# Resend's key and sender, and SES's sender, from .env. Without these the server had no way
|
|
1009
|
+
# to get them and a resend or ses provider fell back to the noop mailer.
|
|
1010
|
+
${composeEnvLines(Object.fromEntries(MAILER_PASSTHROUGH_ENV.map((name) => [name, `\${${name}:-}`])))}
|
|
980
1011
|
SUPATYPE_DISABLE_SIGNUP: \${DISABLE_SIGNUP:-false}
|
|
981
1012
|
${authProviderEnv}
|
|
982
1013
|
depends_on:
|
|
@@ -991,12 +1022,12 @@ ${realtimeDependency} control-plane:
|
|
|
991
1022
|
|
|
992
1023
|
${objectStoreBlock}
|
|
993
1024
|
schema-engine:
|
|
994
|
-
image: \${
|
|
1025
|
+
image: \${${ENGINE_SERVICE.imageVariable}:-${ENGINE_SERVICE.defaultImage}}
|
|
995
1026
|
profiles: ["tools"]
|
|
996
|
-
entrypoint: ["
|
|
1027
|
+
entrypoint: ["${ENGINE_SERVICE.entrypoint}"]
|
|
997
1028
|
volumes:
|
|
998
|
-
${mounts.
|
|
999
|
-
working_dir:
|
|
1029
|
+
${mounts.engineProject}
|
|
1030
|
+
working_dir: ${ENGINE_SERVICE.projectDir}
|
|
1000
1031
|
${dbDependency}${studioBlock}${valkeyBlock}${tlsHintComment} kong:
|
|
1001
1032
|
image: kong:3.6
|
|
1002
1033
|
${gatewayNetworks} # host.docker.internal is a Docker Desktop name. On Linux it does not resolve unless it is
|
|
@@ -1026,6 +1057,12 @@ ${gatewayNetworks} # host.docker.internal is a Docker Desktop name. On Linux
|
|
|
1026
1057
|
# for host.docker.internal after a few seconds and Studio's dev server became unreachable
|
|
1027
1058
|
# (CE1). A recreated upstream is handled where the CLI recreates it: Kong is reloaded then
|
|
1028
1059
|
# (runDockerCompose, EXT-N1).
|
|
1060
|
+
#
|
|
1061
|
+
# SRV is not looked up. Kong 3.6 asks for SRV records first, Docker's DNS never answers them,
|
|
1062
|
+
# and each nginx worker's first upstream lookup waited about 4 s for the timeout: the first
|
|
1063
|
+
# realtime subscribe often took that long. A records still come from the hosts file first, so
|
|
1064
|
+
# host.docker.internal above resolves as before.
|
|
1065
|
+
KONG_DNS_ORDER: "LAST,A,CNAME"
|
|
1029
1066
|
${kongTlsEnv} volumes:
|
|
1030
1067
|
${mounts.kong}
|
|
1031
1068
|
ports:
|
|
@@ -1042,46 +1079,41 @@ function ensureComposeManifest(cwd, config) {
|
|
|
1042
1079
|
const manifestPath = join(cwd, ".supatype", "manifest.json");
|
|
1043
1080
|
mkdirSync(dirname(manifestPath), { recursive: true });
|
|
1044
1081
|
// The manifest is generated, not operator-authored, but `push` writes real values into it (the
|
|
1045
|
-
// schema, for one), so an existing file
|
|
1082
|
+
// schema, for one), so an existing file keeps every key but the routes below. Malformed, it is
|
|
1083
|
+
// left for the server to complain about rather than overwritten here.
|
|
1046
1084
|
if (existsSync(manifestPath)) {
|
|
1047
|
-
|
|
1085
|
+
patchRouteManifest(manifestPath, composeServiceRoutes(config), { keepMalformed: true });
|
|
1048
1086
|
return;
|
|
1049
1087
|
}
|
|
1050
|
-
|
|
1088
|
+
patchRouteManifest(manifestPath, {
|
|
1051
1089
|
schema: "public",
|
|
1052
1090
|
postgrest_url: "http://postgrest:3000",
|
|
1091
|
+
...composeServiceRoutes(config),
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
/**
|
|
1095
|
+
* Where the server finds each service of this stack, set on every render rather than only into a
|
|
1096
|
+
* new file. Native dev shares the manifest and records its own host ports for realtime, functions
|
|
1097
|
+
* and storage, so a project moved from native to Docker kept native's URLs and the server proxied
|
|
1098
|
+
* every subscription and every /storage/v1 call to a port nothing in the stack listened on (502).
|
|
1099
|
+
* An older CLI's `functions_enabled: false` is put right by the same write.
|
|
1100
|
+
*/
|
|
1101
|
+
function composeServiceRoutes(config) {
|
|
1102
|
+
return {
|
|
1103
|
+
// This file always generates a `storage` service, and native dev records its own storage
|
|
1104
|
+
// service on a host port.
|
|
1053
1105
|
storage_url: "http://storage:5000",
|
|
1054
1106
|
// 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.
|
|
1107
|
+
// the server ends up proxying subscriptions to a host that does not resolve. Undefined drops
|
|
1108
|
+
// the key.
|
|
1056
1109
|
realtime_enabled: realtimeEnabled(config),
|
|
1057
|
-
|
|
1110
|
+
realtime_url: realtimeEnabled(config) ? "http://realtime:4000" : undefined,
|
|
1058
1111
|
// True because this file *always* generates a `functions-worker` service and hands the server
|
|
1059
1112
|
// `SUPATYPE_FUNCTIONS_WORKER_URL`. It said false, so the server answered 404 for every function
|
|
1060
1113
|
// in a stack that was running a worker for them, provisioned, then switched off.
|
|
1061
1114
|
functions_enabled: true,
|
|
1062
1115
|
functions_worker_url: COMPOSE_FUNCTIONS_WORKER_URL,
|
|
1063
1116
|
};
|
|
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
1117
|
}
|
|
1086
1118
|
/**
|
|
1087
1119
|
* `POSTGRES_USER`, when the bundled database is in use and it names a role the image cannot run as.
|
|
@@ -1230,6 +1262,9 @@ function resolveDrafts(cwd, config, options) {
|
|
|
1230
1262
|
return projectHasVersionedModels(cwd, config);
|
|
1231
1263
|
}
|
|
1232
1264
|
export function writeSelfHostCompose(cwd, config, options) {
|
|
1265
|
+
// No URL-unsafe password check here: `supatype update` and the dev watcher write this file too,
|
|
1266
|
+
// and start nothing. up, render, restart and dev refuse before they start. push, diff and dev's
|
|
1267
|
+
// recovery only start the database, so they warn (startComposeDatabase in dev-compose.ts).
|
|
1233
1268
|
assertExternalUrlMatchesEnv(cwd, config);
|
|
1234
1269
|
assertBundledDbUser(cwd, config);
|
|
1235
1270
|
const tier = resolveFieldMaskingTier(cwd, config, options);
|
|
@@ -1280,51 +1315,116 @@ export function writeSelfHostCompose(cwd, config, options) {
|
|
|
1280
1315
|
export function exitComposeFailed(status, context, brand) {
|
|
1281
1316
|
fatalError(`docker compose failed (exit ${status}).`, [context, "Check logs: supatype self-host compose logs"], { ...(brand !== undefined && { brand }), exitCode: status === 0 ? 1 : status });
|
|
1282
1317
|
}
|
|
1283
|
-
|
|
1284
|
-
|
|
1318
|
+
/** The `docker` arguments for `docker compose <args>` on one project's file. */
|
|
1319
|
+
function composeInvocation(composePath, args, projectRoot, composeProject, quiet) {
|
|
1285
1320
|
const envFile = resolve(projectRoot, ".env");
|
|
1286
|
-
const composeArgs = ["compose"];
|
|
1287
|
-
if (options?.quiet) {
|
|
1288
|
-
composeArgs.push("--progress", "quiet");
|
|
1289
|
-
}
|
|
1321
|
+
const composeArgs = ["compose", ...(quiet ? ["--progress", "quiet"] : [])];
|
|
1290
1322
|
// Per-project name isolates containers/volumes/network so multiple Supatype
|
|
1291
1323
|
// projects on one machine never share a database (default would be the
|
|
1292
1324
|
// ".supatype/self-host" dir name, identical for every project).
|
|
1293
1325
|
if (composeProject)
|
|
1294
1326
|
composeArgs.push("-p", composeProject);
|
|
1295
1327
|
// 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)) {
|
|
1328
|
+
composeArgs.push("--project-directory", projectRoot, "-f", composePath);
|
|
1329
|
+
if (existsSync(envFile))
|
|
1299
1330
|
composeArgs.push("--env-file", envFile);
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1331
|
+
return [...composeArgs, ...args];
|
|
1332
|
+
}
|
|
1333
|
+
/**
|
|
1334
|
+
* `docker compose <args>`, synchronously. Its many callers are synchronous, and so are the exit
|
|
1335
|
+
* paths that stop a stack. No limit: `up`, `pull` and `build` wait on registries and builds a
|
|
1336
|
+
* person watches and can stop, and a quiet run here is one of those too (docker-exec.ts).
|
|
1337
|
+
*/
|
|
1338
|
+
export function runDockerCompose(composePath, args, projectRoot = process.cwd(), composeProject, options) {
|
|
1339
|
+
requireDockerDaemon(options?.brand !== undefined ? { brand: options.brand } : undefined);
|
|
1340
|
+
const quiet = options?.quiet === true;
|
|
1341
|
+
const runCompose = () => askDockerSync(composeInvocation(composePath, args, projectRoot, composeProject, quiet), {
|
|
1342
|
+
stdio: quiet ? "pipe" : "inherit",
|
|
1308
1343
|
cwd: projectRoot,
|
|
1309
|
-
env,
|
|
1310
|
-
|
|
1344
|
+
env: composeProcessEnv(projectRoot, quiet),
|
|
1345
|
+
timeoutMs: NO_DOCKER_LIMIT,
|
|
1311
1346
|
});
|
|
1312
1347
|
// Whatever `up` created or recreated keeps its name but not its address, and a Kong that was
|
|
1313
1348
|
// already running would go on sending to the old one (EXT-N1), so that Kong is reloaded.
|
|
1314
1349
|
const result = args[0] === "up" && composeProject !== undefined
|
|
1315
1350
|
? upKeepingKongCurrent(projectRoot, { project: composeProject, composePath }, runCompose)
|
|
1316
1351
|
: runCompose();
|
|
1317
|
-
if (
|
|
1318
|
-
|
|
1319
|
-
.filter((s) => typeof s === "string" && s.trim() !== "")
|
|
1320
|
-
.join("\n")
|
|
1321
|
-
.trim();
|
|
1322
|
-
if (detail) {
|
|
1323
|
-
console.error(`[supatype] docker compose: ${detail}`);
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1352
|
+
if (result.status !== 0)
|
|
1353
|
+
reportComposeFailure(args, quiet ? capturedComposeOutput(result) : null);
|
|
1326
1354
|
return result.status ?? 1;
|
|
1327
1355
|
}
|
|
1356
|
+
/** `docker compose <args>` quietly and asynchronously, within `timeoutMs`: for calls run side by side. */
|
|
1357
|
+
export function askDockerCompose(composePath, args, projectRoot, composeProject, timeoutMs) {
|
|
1358
|
+
const call = { cwd: projectRoot, env: composeProcessEnv(projectRoot, true), timeoutMs };
|
|
1359
|
+
return askDocker(composeInvocation(composePath, args, projectRoot, composeProject, true), call);
|
|
1360
|
+
}
|
|
1361
|
+
/** compose's closing line for an image it could not pull. */
|
|
1362
|
+
const DAEMON_PULL_ERROR = /^Error response from daemon: /;
|
|
1363
|
+
/**
|
|
1364
|
+
* compose's own line for one image's pull that failed, or that it stopped when another failed:
|
|
1365
|
+
* ` Image <ref> Error <why>` and ` Image <ref> Interrupted` (Compose v5), or the same with a status
|
|
1366
|
+
* mark and the service name before it (older Compose v2).
|
|
1367
|
+
*/
|
|
1368
|
+
const IMAGE_PULL_FAILED = /^\s*(?:\S\s+)?(?:Image\s+)?\S+\s+(?:Error|Interrupted)(?:\s|$)/;
|
|
1369
|
+
/**
|
|
1370
|
+
* Whether a line compose's pull writes is shown: its progress, but not its closing daemon errors,
|
|
1371
|
+
* its per-image errors or the pulls it interrupted. Each image whose pull did not finish is pulled
|
|
1372
|
+
* again on its own (compose-image-pull.ts), which says why when it fails, and one kept from this
|
|
1373
|
+
* machine is no failure; compose printed its errors for an image `update` then said it kept (local
|
|
1374
|
+
* test rounds 4 and 7).
|
|
1375
|
+
*/
|
|
1376
|
+
export function shownPullLine(line) {
|
|
1377
|
+
return !DAEMON_PULL_ERROR.test(line) && !IMAGE_PULL_FAILED.test(line);
|
|
1378
|
+
}
|
|
1379
|
+
/** `docker compose pull` for the project, its progress shown as it runs ({@link shownPullLine}); its exit status. */
|
|
1380
|
+
export function pullComposeImages(composePath, projectRoot, composeProject, report) {
|
|
1381
|
+
requireDockerDaemon(report);
|
|
1382
|
+
const child = spawnDocker(composeInvocation(composePath, ["pull"], projectRoot, composeProject, false), {
|
|
1383
|
+
cwd: projectRoot,
|
|
1384
|
+
env: composeProcessEnv(projectRoot, false),
|
|
1385
|
+
stdio: ["ignore", "inherit", "pipe"],
|
|
1386
|
+
windowsHide: true,
|
|
1387
|
+
});
|
|
1388
|
+
if (child.stderr !== null) {
|
|
1389
|
+
createInterface({ input: child.stderr }).on("line", (line) => {
|
|
1390
|
+
if (shownPullLine(line))
|
|
1391
|
+
process.stderr.write(`${line}\n`);
|
|
1392
|
+
});
|
|
1393
|
+
}
|
|
1394
|
+
return new Promise((resolve) => {
|
|
1395
|
+
child.on("error", () => resolve(1));
|
|
1396
|
+
child.on("close", (code) => resolve(code ?? 1));
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
/** The environment compose runs with: the CLI's, less the shell's keys `.env` overrides. */
|
|
1400
|
+
function composeProcessEnv(projectRoot, quiet) {
|
|
1401
|
+
const env = { ...process.env, ...(quiet && { COMPOSE_PROGRESS: "quiet" }) };
|
|
1402
|
+
const fromFile = readEnvFile(projectRoot);
|
|
1403
|
+
for (const name of ENV_FILE_OVER_SHELL) {
|
|
1404
|
+
if (envFileOverridesShell(fromFile, name, env[name]))
|
|
1405
|
+
delete env[name];
|
|
1406
|
+
}
|
|
1407
|
+
return env;
|
|
1408
|
+
}
|
|
1409
|
+
/** What a quiet compose run printed, from the streams the CLI captured. */
|
|
1410
|
+
function capturedComposeOutput(result) {
|
|
1411
|
+
return [result.stderr, result.stdout]
|
|
1412
|
+
.filter((s) => typeof s === "string" && s.trim() !== "")
|
|
1413
|
+
.join("\n")
|
|
1414
|
+
.trim();
|
|
1415
|
+
}
|
|
1416
|
+
/**
|
|
1417
|
+
* Say what a failed compose run printed, when the CLI captured it, and any cause it recognises.
|
|
1418
|
+
* `captured` is null when the output already went to the terminal.
|
|
1419
|
+
*/
|
|
1420
|
+
function reportComposeFailure(args, captured) {
|
|
1421
|
+
if (captured)
|
|
1422
|
+
console.error(`[supatype] docker compose: ${captured}`);
|
|
1423
|
+
if (args[0] !== "up")
|
|
1424
|
+
return;
|
|
1425
|
+
for (const line of addressPoolExhaustionHint(captured))
|
|
1426
|
+
console.error(`[supatype] ${line}`);
|
|
1427
|
+
}
|
|
1328
1428
|
/** Compose project name for a Supatype project, isolates docker state per project. */
|
|
1329
1429
|
export function composeProjectName(projectName) {
|
|
1330
1430
|
const slug = projectName.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "");
|