@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
package/dist/dev-shutdown.js
CHANGED
|
@@ -8,7 +8,20 @@ import { endDevSession } from "./dev-session.js";
|
|
|
8
8
|
import { clearDevSessionLock } from "./dev-session-lock.js";
|
|
9
9
|
import { runDockerCompose } from "./self-host-compose.js";
|
|
10
10
|
import { watchParent, windowsParentOf } from "./parent-watch.js";
|
|
11
|
+
import { STOP_SIGNALS } from "./stop-signals.js";
|
|
11
12
|
let shutdownWork = null;
|
|
13
|
+
/** The services dev's start began, undone together by an interrupted start or by the shutdown. */
|
|
14
|
+
const serviceUndo = [];
|
|
15
|
+
/** What the services use (native Postgres), undone after them, last first. */
|
|
16
|
+
const lastUndo = [];
|
|
17
|
+
/**
|
|
18
|
+
* Docker containers dev's start began (native dev's Valkey sidecar): undone beside everything else,
|
|
19
|
+
* since nothing else waits for them, and named if a forced quit leaves them running.
|
|
20
|
+
*/
|
|
21
|
+
const containerUndo = [];
|
|
22
|
+
const containersStarted = [];
|
|
23
|
+
/** Undos recorded once the shutdown had begun: run at once, and waited for before the process ends. */
|
|
24
|
+
const lateUndo = [];
|
|
12
25
|
let composeFallback = null;
|
|
13
26
|
let shutdownCwd = null;
|
|
14
27
|
let shuttingDown = false;
|
|
@@ -40,14 +53,10 @@ export function ensureDevShutdownHooks() {
|
|
|
40
53
|
if (hooksRegistered)
|
|
41
54
|
return;
|
|
42
55
|
hooksRegistered = true;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
process.on("SIGHUP", onSignal);
|
|
48
|
-
if (process.platform === "win32") {
|
|
49
|
-
process.on("SIGBREAK", onSignal);
|
|
50
|
-
}
|
|
56
|
+
// SIGHUP included: a closed terminal, unheard, killed dev with no shutdown and left the whole
|
|
57
|
+
// stack running (C5).
|
|
58
|
+
for (const signal of STOP_SIGNALS)
|
|
59
|
+
process.on(signal, onSignal);
|
|
51
60
|
process.on("exit", onProcessExit);
|
|
52
61
|
watchForOrphaning();
|
|
53
62
|
if (process.stdin.isTTY) {
|
|
@@ -87,6 +96,90 @@ export function registerDevShutdown(work, opts) {
|
|
|
87
96
|
shutdownCwd = opts?.cwd ?? opts?.compose?.cwd ?? null;
|
|
88
97
|
ensureDevShutdownHooks();
|
|
89
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Records the undo of a service dev's start has just spawned (realtime, storage, the server, the
|
|
101
|
+
* Valkey container), the moment it is spawned, before it reports ready. An interrupted start undoes
|
|
102
|
+
* them all, and so does the shutdown dev registers once it is up, after its own work.
|
|
103
|
+
*/
|
|
104
|
+
export function pushStartUndo(undo, opts = {}) {
|
|
105
|
+
if (opts.container !== undefined)
|
|
106
|
+
containersStarted.push(opts.container);
|
|
107
|
+
if (shuttingDown)
|
|
108
|
+
return runLate(undo);
|
|
109
|
+
(opts.container !== undefined ? containerUndo : serviceUndo).push(undo);
|
|
110
|
+
ensureDevShutdownHooks();
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Records the undo of what the services use, native Postgres, the moment it starts: undone after
|
|
114
|
+
* every service has stopped. Ctrl+C during the auth migrations left Postgres running.
|
|
115
|
+
*/
|
|
116
|
+
export function pushStartUndoLast(undo) {
|
|
117
|
+
if (shuttingDown)
|
|
118
|
+
return runLate(undo);
|
|
119
|
+
lastUndo.push(undo);
|
|
120
|
+
ensureDevShutdownHooks();
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* An undo recorded after the shutdown began, while the start was still running: the lists may
|
|
124
|
+
* already be emptied, so it runs now, and the drain waits for it.
|
|
125
|
+
*/
|
|
126
|
+
function runLate(undo) {
|
|
127
|
+
lateUndo.push(Promise.resolve().then(undo).then(() => undefined, (err) => err));
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Never settles once the shutdown has begun, so a start still running stops before it begins
|
|
131
|
+
* anything more; the shutdown ends the process. Called between dev's start steps.
|
|
132
|
+
*/
|
|
133
|
+
export async function haltIfStopping() {
|
|
134
|
+
if (shuttingDown)
|
|
135
|
+
await new Promise(() => undefined);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* `work`, and under SUPATYPE_DEBUG=1 how long it took, so where a shutdown's time goes can be read
|
|
139
|
+
* from a run rather than guessed (round 6b, C10).
|
|
140
|
+
*/
|
|
141
|
+
async function timed(phase, work) {
|
|
142
|
+
if (process.env["SUPATYPE_DEBUG"] !== "1")
|
|
143
|
+
return work();
|
|
144
|
+
const start = Date.now();
|
|
145
|
+
try {
|
|
146
|
+
return await work();
|
|
147
|
+
}
|
|
148
|
+
finally {
|
|
149
|
+
process.stderr.write(`[supatype] shutdown: ${phase} took ${Date.now() - start} ms\n`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/** Runs `undos` together; the errors of those that failed. */
|
|
153
|
+
async function undoTogether(undos) {
|
|
154
|
+
const settled = await Promise.allSettled(undos.map((undo) => Promise.resolve().then(undo)));
|
|
155
|
+
return settled.flatMap((result) => (result.status === "rejected" ? [result.reason] : []));
|
|
156
|
+
}
|
|
157
|
+
/** The services' undos together, then what they use one at a time, last first. */
|
|
158
|
+
async function undoServicesThenLast() {
|
|
159
|
+
const errors = await timed("services", () => undoTogether(serviceUndo.splice(0)));
|
|
160
|
+
await timed("Postgres and what else the services use", async () => {
|
|
161
|
+
for (let undo = lastUndo.pop(); undo !== undefined; undo = lastUndo.pop()) {
|
|
162
|
+
await Promise.resolve().then(undo).catch((err) => errors.push(err));
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
return errors;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Runs every recorded undo: the services' together, then the rest one at a time, last first, with
|
|
169
|
+
* the containers' beside them all (a `docker rm -f` is about a second on Docker Desktop, and
|
|
170
|
+
* Postgres's stop waited for it). Returns the errors of those that failed; a failed one stops
|
|
171
|
+
* nothing after it.
|
|
172
|
+
*/
|
|
173
|
+
export async function drainStartUndo() {
|
|
174
|
+
const [chain, containers] = await Promise.all([undoServicesThenLast(), timed("containers", () => undoTogether(containerUndo.splice(0)))]);
|
|
175
|
+
const errors = [...chain, ...containers];
|
|
176
|
+
while (lateUndo.length > 0) {
|
|
177
|
+
for (const failed of await Promise.all(lateUndo.splice(0)))
|
|
178
|
+
if (failed !== undefined)
|
|
179
|
+
errors.push(failed);
|
|
180
|
+
}
|
|
181
|
+
return errors;
|
|
182
|
+
}
|
|
90
183
|
/**
|
|
91
184
|
* Keep `supatype dev` running until a signal (or the TUI) shuts it down. Never resolves.
|
|
92
185
|
*
|
|
@@ -109,12 +202,59 @@ export function requestDevShutdown() {
|
|
|
109
202
|
ignoreSigintUntil = Date.now() + 400;
|
|
110
203
|
void runDevShutdown();
|
|
111
204
|
}
|
|
205
|
+
/** How long a failed start step waits for a Ctrl+C that reached its child too. */
|
|
206
|
+
const INTERRUPT_SETTLE_MS = 250;
|
|
207
|
+
/**
|
|
208
|
+
* `action`, ending quietly when it failed because of a Ctrl+C. Ctrl+C reaches a start step's child
|
|
209
|
+
* (pg_ctl, the server's migrations) as well, which then fails, and the signal reaches this process
|
|
210
|
+
* just after. So when the action fails, this waits a moment, and when a shutdown began, never
|
|
211
|
+
* settles: the shutdown ends the process with one line, and the child's failure is not reported.
|
|
212
|
+
* A failure for any other reason undoes what the start began, then is reported: it left Postgres
|
|
213
|
+
* and the services running.
|
|
214
|
+
*/
|
|
215
|
+
export function stopQuietlyDuringStart(action) {
|
|
216
|
+
return async (...args) => {
|
|
217
|
+
try {
|
|
218
|
+
await action(...args);
|
|
219
|
+
}
|
|
220
|
+
catch (err) {
|
|
221
|
+
await haltIfInterrupted();
|
|
222
|
+
await drainStartUndo();
|
|
223
|
+
throw err;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
/** Waits for a Ctrl+C that may be on its way after a child failed, and never settles if one came. */
|
|
228
|
+
async function haltIfInterrupted() {
|
|
229
|
+
await new Promise((resolve) => setTimeout(resolve, INTERRUPT_SETTLE_MS));
|
|
230
|
+
await haltIfStopping();
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* `report`, said only when no shutdown began. A push the Ctrl+C also reached fails, and dev catches
|
|
234
|
+
* that failure itself, so `stopQuietlyDuringStart` never sees it: without this, its message came
|
|
235
|
+
* before `Stopped during start.`.
|
|
236
|
+
*/
|
|
237
|
+
export function reportUnlessStopping(report) {
|
|
238
|
+
return async (err) => {
|
|
239
|
+
await haltIfInterrupted();
|
|
240
|
+
report(err);
|
|
241
|
+
};
|
|
242
|
+
}
|
|
112
243
|
export function isDevShuttingDown() {
|
|
113
244
|
return shuttingDown;
|
|
114
245
|
}
|
|
246
|
+
/** Whether dev's own Ctrl+C handling is in place (ensureDevShutdownHooks), so a Ctrl+C is dev's to take. */
|
|
247
|
+
export function devShutdownHooksRegistered() {
|
|
248
|
+
return hooksRegistered;
|
|
249
|
+
}
|
|
115
250
|
/** @internal Tests: reset module state between cases. */
|
|
116
251
|
export function resetDevShutdownForTests() {
|
|
117
252
|
shutdownWork = null;
|
|
253
|
+
serviceUndo.length = 0;
|
|
254
|
+
lastUndo.length = 0;
|
|
255
|
+
containerUndo.length = 0;
|
|
256
|
+
containersStarted.length = 0;
|
|
257
|
+
lateUndo.length = 0;
|
|
118
258
|
composeFallback = null;
|
|
119
259
|
shutdownCwd = null;
|
|
120
260
|
shuttingDown = false;
|
|
@@ -125,33 +265,66 @@ export function resetDevShutdownForTests() {
|
|
|
125
265
|
parentWatch?.stop();
|
|
126
266
|
parentWatch = null;
|
|
127
267
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
268
|
+
/**
|
|
269
|
+
* Ctrl+C before dev registered its shutdown: dev was still starting. Undoes what the start began
|
|
270
|
+
* (pushStartUndo, pushStartUndoLast), says so in one line, and exits 130. A failed undo is not reported over that
|
|
271
|
+
* line: there is nothing more to do about it here.
|
|
272
|
+
*/
|
|
273
|
+
async function stopDuringStart() {
|
|
274
|
+
process.stderr.write("\n[supatype] Stopped during start.\n");
|
|
275
|
+
await drainStartUndo();
|
|
276
|
+
if (shutdownCwd)
|
|
277
|
+
clearDevSessionLock(shutdownCwd);
|
|
278
|
+
process.exit(130);
|
|
279
|
+
}
|
|
280
|
+
/** The registered work, then what the start began, last first; throws the first failure. */
|
|
281
|
+
async function runShutdownWork(work) {
|
|
282
|
+
const failed = await Promise.resolve().then(work).then(() => [], (err) => [err]);
|
|
283
|
+
const [first] = [...failed, ...(await drainStartUndo())];
|
|
284
|
+
if (first !== undefined)
|
|
285
|
+
throw first;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* What a forced quit may leave running: the compose stack's containers, or the containers native
|
|
289
|
+
* dev started; undefined when there are none, and a forced quit leaves nothing behind.
|
|
290
|
+
*/
|
|
291
|
+
function leftByForcedQuit() {
|
|
292
|
+
if (composeFallback !== null)
|
|
293
|
+
return "Docker containers";
|
|
294
|
+
return containersStarted.length > 0 ? containersStarted.join(", ") : undefined;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* A Ctrl+C while the shutdown runs. Where containers could be left running, the first one only says
|
|
298
|
+
* so and the next forces the exit; with none (native dev without a Valkey sidecar) it forces the
|
|
299
|
+
* exit at once (round 6b, C10).
|
|
300
|
+
*/
|
|
301
|
+
function interruptShutdown() {
|
|
302
|
+
const left = leftByForcedQuit();
|
|
303
|
+
if (left !== undefined && !forceQuitRequested) {
|
|
304
|
+
forceQuitRequested = true;
|
|
305
|
+
process.stderr.write("\n[supatype] Still shutting down… press Ctrl+C again to force quit.\n");
|
|
306
|
+
return;
|
|
144
307
|
}
|
|
308
|
+
try {
|
|
309
|
+
endDevSession();
|
|
310
|
+
}
|
|
311
|
+
catch {
|
|
312
|
+
// best-effort terminal restore
|
|
313
|
+
}
|
|
314
|
+
process.stderr.write(left === undefined ? "\n[supatype] Forced quit.\n" : `\n[supatype] Forced quit: ${left} may still be running.\n`);
|
|
315
|
+
process.stdout.write("\n");
|
|
316
|
+
process.exit(130);
|
|
317
|
+
}
|
|
318
|
+
async function runDevShutdown() {
|
|
319
|
+
if (shuttingDown)
|
|
320
|
+
return interruptShutdown();
|
|
145
321
|
shuttingDown = true;
|
|
146
322
|
try {
|
|
147
323
|
endDevSession();
|
|
324
|
+
if (!shutdownWork)
|
|
325
|
+
return await stopDuringStart();
|
|
148
326
|
process.stderr.write("\n[supatype] Shutting down…\n");
|
|
149
|
-
|
|
150
|
-
if (shutdownCwd)
|
|
151
|
-
clearDevSessionLock(shutdownCwd);
|
|
152
|
-
process.exit(130);
|
|
153
|
-
}
|
|
154
|
-
await shutdownWork();
|
|
327
|
+
await runShutdownWork(shutdownWork);
|
|
155
328
|
shutdownCompleted = true;
|
|
156
329
|
if (shutdownCwd)
|
|
157
330
|
clearDevSessionLock(shutdownCwd);
|
|
@@ -159,7 +332,9 @@ async function runDevShutdown() {
|
|
|
159
332
|
}
|
|
160
333
|
catch (err) {
|
|
161
334
|
process.stderr.write(`[supatype] Shutdown failed: ${errorMessage(err)}\n`);
|
|
162
|
-
|
|
335
|
+
if (composeFallback !== null) {
|
|
336
|
+
process.stderr.write("[supatype] Docker containers may still be running, try: supatype self-host compose down\n");
|
|
337
|
+
}
|
|
163
338
|
syncComposeDownFallback();
|
|
164
339
|
shutdownCompleted = true;
|
|
165
340
|
process.exit(1);
|
package/dist/dev-shutdown.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-shutdown.js","sourceRoot":"","sources":["../src/dev-shutdown.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAoB,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"dev-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;YAAE,mBAAmB,CAAC,WAAW,CAAC,CAAA;QACjD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAC1E,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;YAC7B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,2FAA2F,CAAC,CAAA;QACnH,CAAC;QACD,uBAAuB,EAAE,CAAA;QACzB,iBAAiB,GAAG,IAAI,CAAA;QACxB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,0BAA0B;IACxC,OAAO,eAAe,KAAK,IAAI,IAAI,UAAU,CAAC,eAAe,CAAC,WAAW,CAAC,CAAA;AAC5E,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Docker running out of network address pools, recognised and explained.
|
|
3
|
+
*
|
|
4
|
+
* Every compose project gets its own network, carved from a fixed set of pools. With enough stacks
|
|
5
|
+
* left behind, `compose up` fails with "all predefined address pools have been fully subnetted",
|
|
6
|
+
* which names neither the cause nor the fix.
|
|
7
|
+
*/
|
|
8
|
+
/** One docker invocation's outcome. Injected so the decisions here are testable without Docker. */
|
|
9
|
+
export type DockerRun = (args: readonly string[]) => {
|
|
10
|
+
status: number | null;
|
|
11
|
+
stdout: string;
|
|
12
|
+
stderr: string;
|
|
13
|
+
};
|
|
14
|
+
/** Whether docker or compose output says the address pools are exhausted. */
|
|
15
|
+
export declare function isAddressPoolExhausted(output: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The lines to print after a failed `compose up` when the cause was exhausted address pools, or none.
|
|
18
|
+
*
|
|
19
|
+
* `output` is what compose printed, when the CLI captured it. Null means it went to the terminal,
|
|
20
|
+
* and Docker is asked directly instead.
|
|
21
|
+
*/
|
|
22
|
+
export declare function addressPoolExhaustionHint(output: string | null, run?: DockerRun): string[];
|
|
23
|
+
//# sourceMappingURL=docker-address-pool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docker-address-pool.d.ts","sourceRoot":"","sources":["../src/docker-address-pool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,mGAAmG;AACnG,MAAM,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,KAAK;IAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAK9G,6EAA6E;AAC7E,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE9D;AA4BD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,GAAE,SAAqB,GAAG,MAAM,EAAE,CAQrG"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Docker running out of network address pools, recognised and explained.
|
|
3
|
+
*
|
|
4
|
+
* Every compose project gets its own network, carved from a fixed set of pools. With enough stacks
|
|
5
|
+
* left behind, `compose up` fails with "all predefined address pools have been fully subnetted",
|
|
6
|
+
* which names neither the cause nor the fix.
|
|
7
|
+
*/
|
|
8
|
+
import { askDockerSync, DOCKER_QUERY_TIMEOUT_MS } from "./docker-exec.js";
|
|
9
|
+
/** Synchronous: the hint is printed from `runDockerCompose`'s failure report, which is synchronous. */
|
|
10
|
+
const dockerRun = (args) => askDockerSync(args, { timeoutMs: DOCKER_QUERY_TIMEOUT_MS });
|
|
11
|
+
/** Whether docker or compose output says the address pools are exhausted. */
|
|
12
|
+
export function isAddressPoolExhausted(output) {
|
|
13
|
+
return /all predefined address pools have been fully subnetted/i.test(output);
|
|
14
|
+
}
|
|
15
|
+
/** How many networks Docker has for Supatype compose projects, or null when it cannot say. */
|
|
16
|
+
function supatypeNetworkCount(run) {
|
|
17
|
+
const result = run(["network", "ls", "--filter", "name=supatype-", "-q"]);
|
|
18
|
+
if (result.status !== 0)
|
|
19
|
+
return null;
|
|
20
|
+
return result.stdout.split("\n").filter((line) => line.trim() !== "").length;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Whether Docker cannot create a network now. For a failed `up` whose output went to the terminal
|
|
24
|
+
* rather than through the CLI. The probe network is removed again when it was created.
|
|
25
|
+
*/
|
|
26
|
+
function poolExhaustedNow(run) {
|
|
27
|
+
const name = `supatype-address-pool-probe-${process.pid}`;
|
|
28
|
+
const created = run(["network", "create", name]);
|
|
29
|
+
if (created.status === 0) {
|
|
30
|
+
run(["network", "rm", name]);
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return isAddressPoolExhausted(`${created.stderr}\n${created.stdout}`);
|
|
34
|
+
}
|
|
35
|
+
function networkCountLine(count) {
|
|
36
|
+
if (count === null)
|
|
37
|
+
return [];
|
|
38
|
+
return [`There ${count === 1 ? "is 1 Supatype network" : `are ${count} Supatype networks`} on this machine.`];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The lines to print after a failed `compose up` when the cause was exhausted address pools, or none.
|
|
42
|
+
*
|
|
43
|
+
* `output` is what compose printed, when the CLI captured it. Null means it went to the terminal,
|
|
44
|
+
* and Docker is asked directly instead.
|
|
45
|
+
*/
|
|
46
|
+
export function addressPoolExhaustionHint(output, run = dockerRun) {
|
|
47
|
+
const exhausted = output === null ? poolExhaustedNow(run) : isAddressPoolExhausted(output);
|
|
48
|
+
if (!exhausted)
|
|
49
|
+
return [];
|
|
50
|
+
return [
|
|
51
|
+
"Docker has no network addresses left for a new compose project: every predefined address pool is in use.",
|
|
52
|
+
...networkCountLine(supatypeNetworkCount(run)),
|
|
53
|
+
"`docker network prune` removes the networks no container is using, including those of stopped stacks.",
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=docker-address-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docker-address-pool.js","sourceRoot":"","sources":["../src/docker-address-pool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAKzE,uGAAuG;AACvG,MAAM,SAAS,GAAc,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC,CAAA;AAElG,6EAA6E;AAC7E,MAAM,UAAU,sBAAsB,CAAC,MAAc;IACnD,OAAO,yDAAyD,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AAC/E,CAAC;AAED,8FAA8F;AAC9F,SAAS,oBAAoB,CAAC,GAAc;IAC1C,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAC,CAAA;IACzE,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IACpC,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAA;AAC9E,CAAC;AAED;;;GAGG;AACH,SAAS,gBAAgB,CAAC,GAAc;IACtC,MAAM,IAAI,GAAG,+BAA+B,OAAO,CAAC,GAAG,EAAE,CAAA;IACzD,MAAM,OAAO,GAAG,GAAG,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAA;IAChD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,GAAG,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;QAC5B,OAAO,KAAK,CAAA;IACd,CAAC;IACD,OAAO,sBAAsB,CAAC,GAAG,OAAO,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;AACvE,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAoB;IAC5C,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,EAAE,CAAA;IAC7B,OAAO,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,OAAO,KAAK,oBAAoB,mBAAmB,CAAC,CAAA;AAC/G,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAAC,MAAqB,EAAE,MAAiB,SAAS;IACzF,MAAM,SAAS,GAAG,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAA;IAC1F,IAAI,CAAC,SAAS;QAAE,OAAO,EAAE,CAAA;IACzB,OAAO;QACL,0GAA0G;QAC1G,GAAG,gBAAgB,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;QAC9C,uGAAuG;KACxG,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every call the CLI makes to the Docker CLI, each with a limit on how long it may take.
|
|
3
|
+
*
|
|
4
|
+
* `init -y` asked Docker four things one after another (`ps`, `inspect`, `version`, `info`), each a
|
|
5
|
+
* blocking spawn with no limit: on a loaded machine `docker info` alone took 14 seconds, and a
|
|
6
|
+
* paused Docker Desktop can leave it hanging. The rest of the CLI spawned Docker the same way from
|
|
7
|
+
* some thirty places, most with no limit, so one hung daemon held whichever command met it first.
|
|
8
|
+
*
|
|
9
|
+
* So nothing outside this file spawns `docker`. {@link askDocker} is the default: asynchronous, and
|
|
10
|
+
* given up on after its limit. {@link askDockerSync} is for a caller that cannot wait on a promise,
|
|
11
|
+
* with the same limit enforced by the spawn. {@link spawnDocker} is for the two calls meant to
|
|
12
|
+
* outlive any limit, each ended by its owner: `logs --follow`, and the psql session that holds the
|
|
13
|
+
* schema-push lock. A call a person watches and can stop, `compose up` or `docker build`, may pass
|
|
14
|
+
* {@link NO_DOCKER_LIMIT}: a slow image pull is not a hang, and killing the client mid-pull leaves
|
|
15
|
+
* the daemon pulling anyway.
|
|
16
|
+
*/
|
|
17
|
+
import { type ChildProcess, type SpawnOptions } from "node:child_process";
|
|
18
|
+
/** What one `docker` call answered. */
|
|
19
|
+
export interface DockerAnswer {
|
|
20
|
+
/** Exit status; null when the call did not finish (timed out, or could not start). */
|
|
21
|
+
status: number | null;
|
|
22
|
+
stdout: string;
|
|
23
|
+
stderr: string;
|
|
24
|
+
/** True when the limit ran out first. */
|
|
25
|
+
timedOut: boolean;
|
|
26
|
+
/** True when there is no `docker` to run. */
|
|
27
|
+
missing: boolean;
|
|
28
|
+
/** Why the spawn itself failed, when it did. */
|
|
29
|
+
error?: string;
|
|
30
|
+
}
|
|
31
|
+
/** No limit: only for a call a person watches and can stop, or one its owner ends (module comment). */
|
|
32
|
+
export declare const NO_DOCKER_LIMIT = "none";
|
|
33
|
+
/** How long a call may take: milliseconds, or {@link NO_DOCKER_LIMIT}. */
|
|
34
|
+
export type DockerLimit = number | typeof NO_DOCKER_LIMIT;
|
|
35
|
+
/** How long `init` waits on any one Docker question. */
|
|
36
|
+
export declare const DOCKER_PROBE_TIMEOUT_MS = 5000;
|
|
37
|
+
/** A question Docker answers from its own state: `ps`, `inspect`, `volume`, `network`, `config`, `rm`, `stop`, `logs --tail`. */
|
|
38
|
+
export declare const DOCKER_QUERY_TIMEOUT_MS = 15000;
|
|
39
|
+
/** A command run in a container that already exists: `exec psql`, `pg_isready`. */
|
|
40
|
+
export declare const DOCKER_EXEC_TIMEOUT_MS = 60000;
|
|
41
|
+
/** A call that may pull an image first: `run`, a `pull` of one service, `manifest inspect` against a slow registry. */
|
|
42
|
+
export declare const DOCKER_PULL_TIMEOUT_MS = 600000;
|
|
43
|
+
/** Where and how a call runs. */
|
|
44
|
+
export interface DockerCall {
|
|
45
|
+
cwd?: string;
|
|
46
|
+
env?: NodeJS.ProcessEnv;
|
|
47
|
+
/** Written to the call's stdin. */
|
|
48
|
+
input?: string;
|
|
49
|
+
/** Through a shell: Docker Desktop's shim on Windows is found only that way. */
|
|
50
|
+
shell?: boolean;
|
|
51
|
+
timeoutMs?: DockerLimit;
|
|
52
|
+
}
|
|
53
|
+
/** Runs `docker <args>` within `timeoutMs`; injectable so tests can stand in a Docker that hangs. */
|
|
54
|
+
export type DockerRunner = (args: readonly string[], call: DockerCall & {
|
|
55
|
+
shell: boolean;
|
|
56
|
+
timeoutMs: DockerLimit;
|
|
57
|
+
}) => Promise<DockerAnswer>;
|
|
58
|
+
/** What to run for `docker`: the program, and whether it needs a shell. */
|
|
59
|
+
export interface DockerProgram {
|
|
60
|
+
file: string;
|
|
61
|
+
shell: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The program a call runs. On Windows a call asks for a shell because Docker Desktop's `docker`
|
|
65
|
+
* was found only that way, but at a limit the shell is what gets killed, and docker.exe ran on
|
|
66
|
+
* holding what it had open. When docker.exe is on PATH it is run directly, so the limit ends it;
|
|
67
|
+
* the shell is kept only when it is not (a shim that only the shell finds).
|
|
68
|
+
*/
|
|
69
|
+
export declare function dockerProgram(shell: boolean, env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): DockerProgram;
|
|
70
|
+
/**
|
|
71
|
+
* `docker <args>`, answered within its limit (by default {@link DOCKER_PROBE_TIMEOUT_MS}) or reported
|
|
72
|
+
* as timed out. The limit is kept here, not left to the runner, so a runner that never settles
|
|
73
|
+
* cannot hold the caller either.
|
|
74
|
+
*/
|
|
75
|
+
export declare function askDocker(args: readonly string[], opts?: DockerCall & {
|
|
76
|
+
runner?: DockerRunner;
|
|
77
|
+
}): Promise<DockerAnswer>;
|
|
78
|
+
/** How a synchronous call's output is handled: captured, streamed to the terminal, or dropped. */
|
|
79
|
+
export type DockerStdio = "pipe" | "inherit" | "ignore";
|
|
80
|
+
/** {@link askDocker} for a caller that cannot wait on a promise; the limit is required. */
|
|
81
|
+
export declare function askDockerSync(args: readonly string[], call: DockerCall & {
|
|
82
|
+
timeoutMs: DockerLimit;
|
|
83
|
+
stdio?: DockerStdio;
|
|
84
|
+
}): DockerAnswer;
|
|
85
|
+
/**
|
|
86
|
+
* A `docker` process its caller owns and ends: `logs --follow`, or the session holding the
|
|
87
|
+
* schema-push lock. No limit, by design: each runs until its owner stops it (module comment).
|
|
88
|
+
*/
|
|
89
|
+
export declare function spawnDocker(args: readonly string[], options: SpawnOptions): ChildProcess;
|
|
90
|
+
/** Whether Docker has `image` on this machine. */
|
|
91
|
+
export declare function dockerHasImage(image: string): boolean;
|
|
92
|
+
//# sourceMappingURL=docker-exec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docker-exec.d.ts","sourceRoot":"","sources":["../src/docker-exec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAA8B,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAIrG,uCAAuC;AACvC,MAAM,WAAW,YAAY;IAC3B,sFAAsF;IACtF,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,yCAAyC;IACzC,QAAQ,EAAE,OAAO,CAAA;IACjB,6CAA6C;IAC7C,OAAO,EAAE,OAAO,CAAA;IAChB,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,uGAAuG;AACvG,eAAO,MAAM,eAAe,SAAS,CAAA;AAErC,0EAA0E;AAC1E,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,eAAe,CAAA;AAEzD,wDAAwD;AACxD,eAA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AAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,GAAG;IAAE,SAAS,EAAE,WAAW,CAAC;IAAC,KAAK,CAAC,EAAE,WAAW,CAAA;CAAE,GAAG,YAAY,CAqBvI;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,YAAY,GAAG,YAAY,CAExF;AAED,kDAAkD;AAClD,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAErD"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every call the CLI makes to the Docker CLI, each with a limit on how long it may take.
|
|
3
|
+
*
|
|
4
|
+
* `init -y` asked Docker four things one after another (`ps`, `inspect`, `version`, `info`), each a
|
|
5
|
+
* blocking spawn with no limit: on a loaded machine `docker info` alone took 14 seconds, and a
|
|
6
|
+
* paused Docker Desktop can leave it hanging. The rest of the CLI spawned Docker the same way from
|
|
7
|
+
* some thirty places, most with no limit, so one hung daemon held whichever command met it first.
|
|
8
|
+
*
|
|
9
|
+
* So nothing outside this file spawns `docker`. {@link askDocker} is the default: asynchronous, and
|
|
10
|
+
* given up on after its limit. {@link askDockerSync} is for a caller that cannot wait on a promise,
|
|
11
|
+
* with the same limit enforced by the spawn. {@link spawnDocker} is for the two calls meant to
|
|
12
|
+
* outlive any limit, each ended by its owner: `logs --follow`, and the psql session that holds the
|
|
13
|
+
* schema-push lock. A call a person watches and can stop, `compose up` or `docker build`, may pass
|
|
14
|
+
* {@link NO_DOCKER_LIMIT}: a slow image pull is not a hang, and killing the client mid-pull leaves
|
|
15
|
+
* the daemon pulling anyway.
|
|
16
|
+
*/
|
|
17
|
+
import { execFile, spawn, spawnSync } from "node:child_process";
|
|
18
|
+
import { existsSync } from "node:fs";
|
|
19
|
+
import { join } from "node:path";
|
|
20
|
+
/** No limit: only for a call a person watches and can stop, or one its owner ends (module comment). */
|
|
21
|
+
export const NO_DOCKER_LIMIT = "none";
|
|
22
|
+
/** How long `init` waits on any one Docker question. */
|
|
23
|
+
export const DOCKER_PROBE_TIMEOUT_MS = 5_000;
|
|
24
|
+
/** A question Docker answers from its own state: `ps`, `inspect`, `volume`, `network`, `config`, `rm`, `stop`, `logs --tail`. */
|
|
25
|
+
export const DOCKER_QUERY_TIMEOUT_MS = 15_000;
|
|
26
|
+
/** A command run in a container that already exists: `exec psql`, `pg_isready`. */
|
|
27
|
+
export const DOCKER_EXEC_TIMEOUT_MS = 60_000;
|
|
28
|
+
/** A call that may pull an image first: `run`, a `pull` of one service, `manifest inspect` against a slow registry. */
|
|
29
|
+
export const DOCKER_PULL_TIMEOUT_MS = 600_000;
|
|
30
|
+
/**
|
|
31
|
+
* The program a call runs. On Windows a call asks for a shell because Docker Desktop's `docker`
|
|
32
|
+
* was found only that way, but at a limit the shell is what gets killed, and docker.exe ran on
|
|
33
|
+
* holding what it had open. When docker.exe is on PATH it is run directly, so the limit ends it;
|
|
34
|
+
* the shell is kept only when it is not (a shim that only the shell finds).
|
|
35
|
+
*/
|
|
36
|
+
export function dockerProgram(shell, env = process.env, platform = process.platform) {
|
|
37
|
+
if (!shell || platform !== "win32")
|
|
38
|
+
return { file: "docker", shell };
|
|
39
|
+
const found = windowsPath(env).map((dir) => join(dir, "docker.exe")).find((path) => existsSync(path));
|
|
40
|
+
return found === undefined ? { file: "docker", shell: true } : { file: found, shell: false };
|
|
41
|
+
}
|
|
42
|
+
/** The directories on Windows' PATH, which the environment may spell `Path`. */
|
|
43
|
+
function windowsPath(env) {
|
|
44
|
+
const value = Object.entries(env).find(([key]) => key.toUpperCase() === "PATH")?.[1] ?? "";
|
|
45
|
+
return value.split(";").map((dir) => dir.trim().replace(/^"|"$/g, "")).filter((dir) => dir !== "");
|
|
46
|
+
}
|
|
47
|
+
/** The errno code a spawn failed with, when it did. */
|
|
48
|
+
function errnoCode(err) {
|
|
49
|
+
return err !== null && err !== undefined && "code" in err && typeof err.code === "string" ? err.code : undefined;
|
|
50
|
+
}
|
|
51
|
+
/** The working directory and environment of a call, as spawn options. */
|
|
52
|
+
function callPlace(call) {
|
|
53
|
+
return { ...(call.cwd !== undefined && { cwd: call.cwd }), ...(call.env !== undefined && { env: call.env }) };
|
|
54
|
+
}
|
|
55
|
+
const runDocker = (args, call) => new Promise((resolve) => {
|
|
56
|
+
const program = dockerProgram(call.shell, call.env);
|
|
57
|
+
const options = { encoding: "utf8", windowsHide: true, shell: program.shell, maxBuffer: 64 * 1024 * 1024, ...callPlace(call) };
|
|
58
|
+
const child = execFile(program.file, [...args], options, (err, stdout, stderr) => {
|
|
59
|
+
if (timer !== undefined)
|
|
60
|
+
clearTimeout(timer);
|
|
61
|
+
const code = err !== null && "code" in err ? err.code : undefined;
|
|
62
|
+
resolve({
|
|
63
|
+
status: err === null ? 0 : typeof code === "number" ? code : null,
|
|
64
|
+
stdout,
|
|
65
|
+
stderr,
|
|
66
|
+
timedOut: false,
|
|
67
|
+
missing: code === "ENOENT",
|
|
68
|
+
...(err !== null && typeof code !== "number" && { error: err.message }),
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
if (call.input !== undefined)
|
|
72
|
+
child.stdin?.end(call.input);
|
|
73
|
+
const timer = call.timeoutMs === NO_DOCKER_LIMIT ? undefined : setTimeout(() => abandon(child), call.timeoutMs);
|
|
74
|
+
timer?.unref();
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* Past its limit a call is abandoned, and nothing of it may keep the CLI from exiting: under a
|
|
78
|
+
* shell, killing the shell can leave docker holding the pipes open.
|
|
79
|
+
*/
|
|
80
|
+
function abandon(child) {
|
|
81
|
+
child.kill();
|
|
82
|
+
child.stdout?.destroy();
|
|
83
|
+
child.stderr?.destroy();
|
|
84
|
+
child.unref();
|
|
85
|
+
}
|
|
86
|
+
const TIMED_OUT = { status: null, stdout: "", stderr: "", timedOut: true, missing: false };
|
|
87
|
+
/**
|
|
88
|
+
* `docker <args>`, answered within its limit (by default {@link DOCKER_PROBE_TIMEOUT_MS}) or reported
|
|
89
|
+
* as timed out. The limit is kept here, not left to the runner, so a runner that never settles
|
|
90
|
+
* cannot hold the caller either.
|
|
91
|
+
*/
|
|
92
|
+
export function askDocker(args, opts = {}) {
|
|
93
|
+
const { runner, ...call } = opts;
|
|
94
|
+
const timeoutMs = call.timeoutMs ?? DOCKER_PROBE_TIMEOUT_MS;
|
|
95
|
+
const answer = (runner ?? runDocker)(args, { ...call, shell: call.shell ?? false, timeoutMs });
|
|
96
|
+
if (timeoutMs === NO_DOCKER_LIMIT)
|
|
97
|
+
return answer;
|
|
98
|
+
let timer;
|
|
99
|
+
const timedOut = new Promise((resolve) => {
|
|
100
|
+
timer = setTimeout(() => resolve(TIMED_OUT), timeoutMs);
|
|
101
|
+
timer.unref();
|
|
102
|
+
});
|
|
103
|
+
return Promise.race([answer, timedOut]).finally(() => clearTimeout(timer));
|
|
104
|
+
}
|
|
105
|
+
/** {@link askDocker} for a caller that cannot wait on a promise; the limit is required. */
|
|
106
|
+
export function askDockerSync(args, call) {
|
|
107
|
+
const program = dockerProgram(call.shell === true, call.env);
|
|
108
|
+
const result = spawnSync(program.file, [...args], {
|
|
109
|
+
encoding: "utf8",
|
|
110
|
+
windowsHide: true,
|
|
111
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
112
|
+
stdio: call.stdio ?? "pipe",
|
|
113
|
+
...callPlace(call),
|
|
114
|
+
...(program.shell && { shell: true }),
|
|
115
|
+
...(call.input !== undefined && { input: call.input }),
|
|
116
|
+
...(call.timeoutMs !== NO_DOCKER_LIMIT && { timeout: call.timeoutMs, killSignal: "SIGKILL" }),
|
|
117
|
+
});
|
|
118
|
+
const code = errnoCode(result.error);
|
|
119
|
+
return {
|
|
120
|
+
status: result.status,
|
|
121
|
+
stdout: result.stdout ?? "",
|
|
122
|
+
stderr: result.stderr ?? "",
|
|
123
|
+
timedOut: code === "ETIMEDOUT",
|
|
124
|
+
missing: code === "ENOENT",
|
|
125
|
+
...(result.error !== undefined && { error: result.error.message }),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* A `docker` process its caller owns and ends: `logs --follow`, or the session holding the
|
|
130
|
+
* schema-push lock. No limit, by design: each runs until its owner stops it (module comment).
|
|
131
|
+
*/
|
|
132
|
+
export function spawnDocker(args, options) {
|
|
133
|
+
return spawn("docker", [...args], options);
|
|
134
|
+
}
|
|
135
|
+
/** Whether Docker has `image` on this machine. */
|
|
136
|
+
export function dockerHasImage(image) {
|
|
137
|
+
return askDockerSync(["image", "inspect", image], { stdio: "ignore", timeoutMs: DOCKER_QUERY_TIMEOUT_MS }).status === 0;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=docker-exec.js.map
|