@supatype/cli 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +360 -0
- package/dist/app/proxy-dev-app.d.ts +13 -3
- package/dist/app/proxy-dev-app.d.ts.map +1 -1
- package/dist/app/proxy-dev-app.js +58 -62
- package/dist/app/proxy-dev-app.js.map +1 -1
- package/dist/auth-providers.d.ts +5 -4
- package/dist/auth-providers.d.ts.map +1 -1
- package/dist/auth-providers.js +3 -12
- package/dist/auth-providers.js.map +1 -1
- package/dist/build-spawn.d.ts +35 -0
- package/dist/build-spawn.d.ts.map +1 -0
- package/dist/build-spawn.js +75 -0
- package/dist/build-spawn.js.map +1 -0
- package/dist/cli-version-embedded.js +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +4 -0
- package/dist/cli.js.map +1 -1
- package/dist/cloud-credentials.d.ts.map +1 -1
- package/dist/cloud-credentials.js +3 -1
- package/dist/cloud-credentials.js.map +1 -1
- package/dist/commands/admin.d.ts.map +1 -1
- package/dist/commands/admin.js +6 -4
- package/dist/commands/admin.js.map +1 -1
- package/dist/commands/adopt.js +1 -1
- package/dist/commands/adopt.js.map +1 -1
- package/dist/commands/build.d.ts +29 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +69 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/cache.d.ts.map +1 -1
- package/dist/commands/cache.js +5 -0
- package/dist/commands/cache.js.map +1 -1
- package/dist/commands/db.d.ts.map +1 -1
- package/dist/commands/db.js +46 -23
- package/dist/commands/db.js.map +1 -1
- package/dist/commands/deploy.d.ts +14 -0
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +67 -52
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +23 -19
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/diff.d.ts +3 -0
- package/dist/commands/diff.d.ts.map +1 -1
- package/dist/commands/diff.js +28 -34
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/doctor.js +1 -1
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/functions.d.ts.map +1 -1
- package/dist/commands/functions.js +21 -16
- package/dist/commands/functions.js.map +1 -1
- package/dist/commands/init.d.ts +10 -3
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +127 -57
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/internal.d.ts.map +1 -1
- package/dist/commands/internal.js +27 -7
- package/dist/commands/internal.js.map +1 -1
- package/dist/commands/introspect.d.ts.map +1 -1
- package/dist/commands/introspect.js +3 -0
- package/dist/commands/introspect.js.map +1 -1
- package/dist/commands/keys-print.d.ts +20 -0
- package/dist/commands/keys-print.d.ts.map +1 -0
- package/dist/commands/keys-print.js +47 -0
- package/dist/commands/keys-print.js.map +1 -0
- package/dist/commands/keys.d.ts.map +1 -1
- package/dist/commands/keys.js +16 -12
- package/dist/commands/keys.js.map +1 -1
- package/dist/commands/link-helpers.d.ts.map +1 -1
- package/dist/commands/link-helpers.js +27 -5
- package/dist/commands/link-helpers.js.map +1 -1
- package/dist/commands/migrate.d.ts +5 -2
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +34 -36
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/pull.d.ts.map +1 -1
- package/dist/commands/pull.js +6 -5
- package/dist/commands/pull.js.map +1 -1
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +27 -18
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/rename.js +1 -1
- package/dist/commands/rename.js.map +1 -1
- package/dist/commands/seed.d.ts +2 -11
- package/dist/commands/seed.d.ts.map +1 -1
- package/dist/commands/seed.js +11 -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 +74 -12
- package/dist/commands/self-host.js.map +1 -1
- package/dist/commands/sso.d.ts +26 -0
- package/dist/commands/sso.d.ts.map +1 -0
- package/dist/commands/sso.js +362 -0
- package/dist/commands/sso.js.map +1 -0
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +25 -8
- package/dist/commands/status.js.map +1 -1
- package/dist/component-launch.d.ts.map +1 -1
- package/dist/component-launch.js +2 -1
- package/dist/component-launch.js.map +1 -1
- package/dist/compose-db-roles.d.ts +4 -4
- package/dist/compose-db-roles.d.ts.map +1 -1
- package/dist/compose-db-roles.js +11 -10
- package/dist/compose-db-roles.js.map +1 -1
- package/dist/compose-engine-run.d.ts +9 -2
- package/dist/compose-engine-run.d.ts.map +1 -1
- package/dist/compose-engine-run.js +30 -13
- package/dist/compose-engine-run.js.map +1 -1
- package/dist/compose-services.d.ts +18 -0
- package/dist/compose-services.d.ts.map +1 -1
- package/dist/compose-services.js +47 -22
- package/dist/compose-services.js.map +1 -1
- package/dist/config-mailer-env.d.ts +27 -0
- package/dist/config-mailer-env.d.ts.map +1 -0
- package/dist/config-mailer-env.js +47 -0
- package/dist/config-mailer-env.js.map +1 -0
- package/dist/db-rows.d.ts +3 -2
- package/dist/db-rows.d.ts.map +1 -1
- package/dist/db-rows.js +19 -4
- package/dist/db-rows.js.map +1 -1
- package/dist/dev-compose.d.ts +62 -7
- package/dist/dev-compose.d.ts.map +1 -1
- package/dist/dev-compose.js +202 -151
- package/dist/dev-compose.js.map +1 -1
- package/dist/dev-ports.d.ts +6 -4
- package/dist/dev-ports.d.ts.map +1 -1
- package/dist/dev-ports.js +80 -46
- package/dist/dev-ports.js.map +1 -1
- package/dist/dev-schema-watch.d.ts +8 -2
- package/dist/dev-schema-watch.d.ts.map +1 -1
- package/dist/dev-schema-watch.js +24 -13
- package/dist/dev-schema-watch.js.map +1 -1
- package/dist/dev-session.d.ts +13 -2
- package/dist/dev-session.d.ts.map +1 -1
- package/dist/dev-session.js +22 -5
- package/dist/dev-session.js.map +1 -1
- package/dist/dev-shutdown.d.ts.map +1 -1
- package/dist/dev-shutdown.js +4 -1
- package/dist/dev-shutdown.js.map +1 -1
- package/dist/diff-access.d.ts +10 -0
- package/dist/diff-access.d.ts.map +1 -0
- package/dist/diff-access.js +69 -0
- package/dist/diff-access.js.map +1 -0
- package/dist/diff-output.d.ts.map +1 -1
- package/dist/diff-output.js +2 -1
- package/dist/diff-output.js.map +1 -1
- package/dist/docker-exec.d.ts.map +1 -1
- package/dist/docker-exec.js +4 -4
- package/dist/docker-exec.js.map +1 -1
- package/dist/docker-runtime.d.ts +8 -2
- package/dist/docker-runtime.d.ts.map +1 -1
- package/dist/docker-runtime.js +64 -23
- package/dist/docker-runtime.js.map +1 -1
- package/dist/engine-answers.d.ts +2 -1
- package/dist/engine-answers.d.ts.map +1 -1
- package/dist/engine-answers.js +11 -0
- package/dist/engine-answers.js.map +1 -1
- package/dist/engine-client.d.ts +20 -0
- package/dist/engine-client.d.ts.map +1 -1
- package/dist/engine-client.js +9 -8
- package/dist/engine-client.js.map +1 -1
- package/dist/engine-floor.d.ts +3 -2
- package/dist/engine-floor.d.ts.map +1 -1
- package/dist/engine-floor.js +2 -2
- package/dist/engine-floor.js.map +1 -1
- package/dist/engine-push-output.d.ts +8 -1
- package/dist/engine-push-output.d.ts.map +1 -1
- package/dist/engine-push-output.js +8 -1
- package/dist/engine-push-output.js.map +1 -1
- package/dist/env-file.d.ts +5 -0
- package/dist/env-file.d.ts.map +1 -1
- package/dist/env-file.js +51 -33
- package/dist/env-file.js.map +1 -1
- package/dist/env-lines.d.ts +3 -2
- package/dist/env-lines.d.ts.map +1 -1
- package/dist/env-lines.js +5 -2
- package/dist/env-lines.js.map +1 -1
- package/dist/env-value.d.ts +15 -0
- package/dist/env-value.d.ts.map +1 -0
- package/dist/env-value.js +34 -0
- package/dist/env-value.js.map +1 -0
- package/dist/error-message.d.ts +20 -0
- package/dist/error-message.d.ts.map +1 -1
- package/dist/error-message.js +42 -0
- package/dist/error-message.js.map +1 -1
- package/dist/frontend-env.d.ts +10 -2
- package/dist/frontend-env.d.ts.map +1 -1
- package/dist/frontend-env.js +24 -4
- package/dist/frontend-env.js.map +1 -1
- package/dist/frontend-values-linked.d.ts +22 -0
- package/dist/frontend-values-linked.d.ts.map +1 -0
- package/dist/frontend-values-linked.js +143 -0
- package/dist/frontend-values-linked.js.map +1 -0
- package/dist/frontend-values.d.ts +90 -0
- package/dist/frontend-values.d.ts.map +1 -0
- package/dist/frontend-values.js +208 -0
- package/dist/frontend-values.js.map +1 -0
- package/dist/functions-env-local.d.ts +13 -0
- package/dist/functions-env-local.d.ts.map +1 -0
- package/dist/functions-env-local.js +20 -0
- package/dist/functions-env-local.js.map +1 -0
- package/dist/generated/release-images.d.ts +4 -4
- package/dist/generated/release-images.js +2 -2
- package/dist/generated/release-images.js.map +1 -1
- package/dist/generated/typescript-libs.d.ts +4 -0
- package/dist/generated/typescript-libs.d.ts.map +1 -0
- package/dist/generated/typescript-libs.js +64 -0
- package/dist/generated/typescript-libs.js.map +1 -0
- package/dist/host-database.d.ts +10 -10
- package/dist/host-database.d.ts.map +1 -1
- package/dist/host-database.js +18 -15
- package/dist/host-database.js.map +1 -1
- package/dist/init-answers.d.ts +18 -0
- package/dist/init-answers.d.ts.map +1 -0
- package/dist/init-answers.js +46 -0
- package/dist/init-answers.js.map +1 -0
- package/dist/init-next-runtime-env.d.ts +30 -0
- package/dist/init-next-runtime-env.d.ts.map +1 -0
- package/dist/init-next-runtime-env.js +180 -0
- package/dist/init-next-runtime-env.js.map +1 -0
- package/dist/jwt.d.ts +5 -0
- package/dist/jwt.d.ts.map +1 -1
- package/dist/jwt.js +16 -0
- package/dist/jwt.js.map +1 -1
- package/dist/local-secrets.d.ts +22 -0
- package/dist/local-secrets.d.ts.map +1 -1
- package/dist/local-secrets.js +36 -0
- package/dist/local-secrets.js.map +1 -1
- package/dist/local-stack-guard.d.ts +37 -0
- package/dist/local-stack-guard.d.ts.map +1 -0
- package/dist/local-stack-guard.js +84 -0
- package/dist/local-stack-guard.js.map +1 -0
- package/dist/mailer-env.d.ts +4 -0
- package/dist/mailer-env.d.ts.map +1 -1
- package/dist/mailer-env.js +12 -1
- package/dist/mailer-env.js.map +1 -1
- package/dist/node-executable.d.ts +6 -0
- package/dist/node-executable.d.ts.map +1 -0
- package/dist/node-executable.js +43 -0
- package/dist/node-executable.js.map +1 -0
- package/dist/parent-watch.d.ts +8 -3
- package/dist/parent-watch.d.ts.map +1 -1
- package/dist/parent-watch.js +8 -3
- package/dist/parent-watch.js.map +1 -1
- package/dist/postgres-ctl.d.ts +2 -0
- package/dist/postgres-ctl.d.ts.map +1 -1
- package/dist/postgres-ctl.js +11 -5
- package/dist/postgres-ctl.js.map +1 -1
- package/dist/process-manager.d.ts +37 -5
- package/dist/process-manager.d.ts.map +1 -1
- package/dist/process-manager.js +127 -65
- package/dist/process-manager.js.map +1 -1
- package/dist/project-config.d.ts +27 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +18 -0
- package/dist/project-config.js.map +1 -1
- package/dist/push-audit.d.ts +4 -1
- package/dist/push-audit.d.ts.map +1 -1
- package/dist/push-audit.js +33 -4
- package/dist/push-audit.js.map +1 -1
- package/dist/recorded-field-masking-tier.d.ts +2 -2
- package/dist/recorded-field-masking-tier.d.ts.map +1 -1
- package/dist/recorded-field-masking-tier.js +6 -6
- package/dist/recorded-field-masking-tier.js.map +1 -1
- package/dist/rename-journal.d.ts +1 -1
- package/dist/rename-journal.d.ts.map +1 -1
- package/dist/resolve-api-url.d.ts +2 -0
- package/dist/resolve-api-url.d.ts.map +1 -1
- package/dist/resolve-api-url.js +5 -1
- package/dist/resolve-api-url.js.map +1 -1
- package/dist/resolve-target.d.ts +16 -1
- package/dist/resolve-target.d.ts.map +1 -1
- package/dist/resolve-target.js +20 -11
- package/dist/resolve-target.js.map +1 -1
- package/dist/run-captured.d.ts +31 -0
- package/dist/run-captured.d.ts.map +1 -0
- package/dist/run-captured.js +36 -0
- package/dist/run-captured.js.map +1 -0
- package/dist/saml-config.d.ts +53 -0
- package/dist/saml-config.d.ts.map +1 -0
- package/dist/saml-config.js +177 -0
- package/dist/saml-config.js.map +1 -0
- package/dist/saml-key-rotation.d.ts +5 -0
- package/dist/saml-key-rotation.d.ts.map +1 -0
- package/dist/saml-key-rotation.js +26 -0
- package/dist/saml-key-rotation.js.map +1 -0
- package/dist/saml-sp-certificate.d.ts +15 -0
- package/dist/saml-sp-certificate.d.ts.map +1 -0
- package/dist/saml-sp-certificate.js +34 -0
- package/dist/saml-sp-certificate.js.map +1 -0
- package/dist/schema-reset.d.ts +41 -0
- package/dist/schema-reset.d.ts.map +1 -0
- package/dist/schema-reset.js +98 -0
- package/dist/schema-reset.js.map +1 -0
- package/dist/seed-child.d.ts +25 -0
- package/dist/seed-child.d.ts.map +1 -0
- package/dist/seed-child.js +61 -0
- package/dist/seed-child.js.map +1 -0
- package/dist/seed-runner.d.ts +3 -5
- package/dist/seed-runner.d.ts.map +1 -1
- package/dist/seed-runner.js +20 -42
- package/dist/seed-runner.js.map +1 -1
- package/dist/self-host-compose.d.ts +9 -1
- package/dist/self-host-compose.d.ts.map +1 -1
- package/dist/self-host-compose.js +47 -14
- package/dist/self-host-compose.js.map +1 -1
- package/dist/serial-runs.d.ts +7 -0
- package/dist/serial-runs.d.ts.map +1 -0
- package/dist/serial-runs.js +29 -0
- package/dist/serial-runs.js.map +1 -0
- package/dist/sso-admin.d.ts +114 -0
- package/dist/sso-admin.d.ts.map +1 -0
- package/dist/sso-admin.js +256 -0
- package/dist/sso-admin.js.map +1 -0
- package/dist/stack-engine.d.ts +28 -0
- package/dist/stack-engine.d.ts.map +1 -0
- package/dist/stack-engine.js +59 -0
- package/dist/stack-engine.js.map +1 -0
- package/dist/stack-exit-watch.d.ts +37 -0
- package/dist/stack-exit-watch.d.ts.map +1 -0
- package/dist/stack-exit-watch.js +70 -0
- package/dist/stack-exit-watch.js.map +1 -0
- package/dist/stack-setting-warnings.d.ts +8 -0
- package/dist/stack-setting-warnings.d.ts.map +1 -0
- package/dist/stack-setting-warnings.js +14 -0
- package/dist/stack-setting-warnings.js.map +1 -0
- package/dist/studio-dev-server.d.ts.map +1 -1
- package/dist/studio-dev-server.js +2 -1
- package/dist/studio-dev-server.js.map +1 -1
- package/dist/target-client.d.ts +12 -2
- package/dist/target-client.d.ts.map +1 -1
- package/dist/target-client.js +14 -1
- package/dist/target-client.js.map +1 -1
- package/dist/tsx-runner.d.ts +5 -0
- package/dist/tsx-runner.d.ts.map +1 -1
- package/dist/tsx-runner.js +16 -16
- package/dist/tsx-runner.js.map +1 -1
- package/dist/type-generation.d.ts +1 -1
- package/dist/type-generation.d.ts.map +1 -1
- package/dist/type-generation.js +2 -4
- package/dist/type-generation.js.map +1 -1
- package/dist/type-resolver.d.ts.map +1 -1
- package/dist/type-resolver.js +31 -12
- package/dist/type-resolver.js.map +1 -1
- package/dist/ui/clack-api.d.ts.map +1 -1
- package/dist/ui/clack-api.js +45 -23
- package/dist/ui/clack-api.js.map +1 -1
- package/dist/ui/components/LineInput.d.ts +26 -0
- package/dist/ui/components/LineInput.d.ts.map +1 -0
- package/dist/ui/components/LineInput.js +60 -0
- package/dist/ui/components/LineInput.js.map +1 -0
- package/dist/ui/flows/FlowApp.d.ts +3 -1
- package/dist/ui/flows/FlowApp.d.ts.map +1 -1
- package/dist/ui/flows/FlowApp.js +14 -5
- package/dist/ui/flows/FlowApp.js.map +1 -1
- package/dist/ui/flows/prompt-fields.d.ts +3 -1
- package/dist/ui/flows/prompt-fields.d.ts.map +1 -1
- package/dist/ui/flows/prompt-fields.js +10 -5
- package/dist/ui/flows/prompt-fields.js.map +1 -1
- package/dist/ui/flows/types.d.ts +5 -1
- package/dist/ui/flows/types.d.ts.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/flow-transcript.d.ts +17 -0
- package/dist/ui/runtime/flow-transcript.d.ts.map +1 -0
- package/dist/ui/runtime/flow-transcript.js +38 -0
- package/dist/ui/runtime/flow-transcript.js.map +1 -0
- package/dist/ui/runtime/run-clack-flow.d.ts +7 -0
- package/dist/ui/runtime/run-clack-flow.d.ts.map +1 -1
- package/dist/ui/runtime/run-clack-flow.js +131 -17
- package/dist/ui/runtime/run-clack-flow.js.map +1 -1
- package/package.json +4 -5
package/dist/dev-compose.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
5
5
|
import { projectOutputPaths, writeAstDerivedOutputs, writeSeedBuilder } from "./type-generation.js";
|
|
6
6
|
import { errorMessage } from "./error-message.js";
|
|
7
|
+
import { printRoleAccess } from "./diff-access.js";
|
|
7
8
|
import { warn } from "./ui/messages.js";
|
|
8
9
|
import { FRONTEND_URL_KEYS, frontendEnv, writeFrontendEnv } from "./frontend-env.js";
|
|
9
10
|
import { withPublishing } from "./model-versioning.js";
|
|
@@ -26,7 +27,7 @@ import { ensureDevDbPort, ensureKongPort } from "./dev-ports.js";
|
|
|
26
27
|
import { applyForThisRun, splitShellPortUpdates } from "./shell-ports.js";
|
|
27
28
|
import { handleComposeProjectRename } from "./compose-rename.js";
|
|
28
29
|
import { devSessionLockFor, recoverStaleDevSession, writeDevSessionLock } from "./dev-session-lock.js";
|
|
29
|
-
import { endDevSession, showDevStep, startDevSession } from "./dev-session.js";
|
|
30
|
+
import { endDevSession, showDevStep, startDevSession, withSavePushOutput } from "./dev-session.js";
|
|
30
31
|
import { ensureDevApiConfig } from "./ensure-dev-api-config.js";
|
|
31
32
|
import { cacheSeedingNotes } from "./api-config-cache.js";
|
|
32
33
|
import { restartComposeFunctionsWorker, watchFunctionSources } from "./dev-functions-watch.js";
|
|
@@ -41,6 +42,7 @@ import { auditFlags, auditWhenSupported } from "./push-audit.js";
|
|
|
41
42
|
import { consentRefusal, reportDevPushFailure } from "./push-refusal.js";
|
|
42
43
|
import { COMPOSE_PINNED_IMAGE_ENV_KEYS, composeDockerImageEnv, composeProjectName, exitComposeFailed, noteUnpinnedImages, publishesDbToHost, runDockerCompose, runDockerComposeQuietly, settleComposeRuns, schemaEngineImageForPush, writeSelfHostCompose, composeFieldMaskingTier, selfHostComposePaths, } from "./self-host-compose.js";
|
|
43
44
|
import { composeServiceIsRunning } from "./compose-kong.js";
|
|
45
|
+
import { requireStackDatabase } from "./local-stack-guard.js";
|
|
44
46
|
import { hasEngineOverride } from "./binary-cache.js";
|
|
45
47
|
import { STUDIO_DEV_PORT, startStudioViteDevServer } from "./studio-dev-server.js";
|
|
46
48
|
import { ensureLocalServerDockerImage, usesLocalServerImage, LOCAL_SERVER_DOCKER_IMAGE, } from "./compose-local-server-image.js";
|
|
@@ -48,7 +50,7 @@ import { ensureEngine, enginePush, engineRequest } from "./engine-client.js";
|
|
|
48
50
|
import { isAdoptOutcome, isAnyAnswer, isDiffResult, isEnginePushResult, isGenerateAnswer, } from "./engine-answers.js";
|
|
49
51
|
import { writeSchemaSourcePushArtifacts } from "./schema-sources.js";
|
|
50
52
|
import { readEnvFile, readEnvValue, upsertEnvFile } from "./env-file.js";
|
|
51
|
-
import {
|
|
53
|
+
import { warnMissingStackSettings } from "./stack-setting-warnings.js";
|
|
52
54
|
import { devDatabaseIdentity, devDatabaseUrl, seedMissingDatabaseIdentity, seedMissingLocalSecrets, } from "./local-secrets.js";
|
|
53
55
|
import { writeLocalEnvironment } from "./link.js";
|
|
54
56
|
import { registerDevShutdown, waitForDevShutdown } from "./dev-shutdown.js";
|
|
@@ -65,15 +67,15 @@ import { adoptKeysNeed, assertSupported, engineCapabilities, identityColumnsNeed
|
|
|
65
67
|
import { devPushConsentingToDrift } from "./drift-consent.js";
|
|
66
68
|
import { capabilitiesCache, rememberCapabilitiesSync } from "@supatype/shared";
|
|
67
69
|
import { waitForDatabaseAfterUp } from "./dev-db-ready.js";
|
|
68
|
-
import { DERIVED_DSN_SOURCE, hostComposeDbUrl, requireRunningStack, resolveHostDatabaseUrl, stackHostDbUrl, } from "./host-database.js";
|
|
70
|
+
import { DERIVED_DSN_SOURCE, hostComposeDbUrl, NoStackRunning, requireRunningStack, resolveHostDatabaseUrl, stackHostDbUrl, } from "./host-database.js";
|
|
69
71
|
import { studioUrlAt } from "./local-stack.js";
|
|
70
72
|
import { grantAuthSchemaAccess, privatizeTableDefaults, reconcileAuthenticatorPassword, reconcileSqlEditorPassword, } from "./compose-db-roles.js";
|
|
71
|
-
import { spawnComposeEngine } from "./compose-engine-run.js";
|
|
73
|
+
import { spawnComposeEngine, spawnComposeEngineSync } from "./compose-engine-run.js";
|
|
72
74
|
import { waitForRestReady } from "./rest-ready.js";
|
|
73
|
-
import { claimDevRenderMode, composeRenderMode, composeRenderOptions } from "./compose-render-mode.js";
|
|
74
|
-
import {
|
|
75
|
-
import { mailerProviderEnv } from "./mailer-env.js";
|
|
75
|
+
import { claimDevRenderMode, composeRenderMode, composeRenderOptions, runningStackMode } from "./compose-render-mode.js";
|
|
76
|
+
import { configMailerEnv } from "./config-mailer-env.js";
|
|
76
77
|
import { fetchWithin } from "./fetch-within.js";
|
|
78
|
+
import { composeStackWatch, exitedServiceFailure } from "./stack-exit-watch.js";
|
|
77
79
|
import { assertEngineVersionSupported, engineImageVersion } from "./engine-floor.js";
|
|
78
80
|
/**
|
|
79
81
|
* The image pins config asks for, once the engine's is known not to be older than this CLI needs.
|
|
@@ -116,10 +118,14 @@ function projectDatabaseUrl(cwd, config, inNetwork = false) {
|
|
|
116
118
|
return inNetwork ? composeDbUrl(cwd) : stackHostDbUrl(cwd, config.project.name);
|
|
117
119
|
}
|
|
118
120
|
/**
|
|
119
|
-
* When `provider: docker` and `overrides.engine` is set
|
|
120
|
-
* on the host
|
|
121
|
+
* When `provider: docker` and `overrides.engine` is set: the stack's Postgres, which the local
|
|
122
|
+
* engine binary reaches on the host port the compose file publishes. Every layout publishes `db`
|
|
123
|
+
* ({@link publishesDbToHost}), dev on SUPATYPE_DEV_DB_PORT and standalone on SUPATYPE_DB_PORT, so
|
|
124
|
+
* on a running stack it is already there. Nothing is started (issue 46): this ran `up -d db`, and
|
|
125
|
+
* on a dev stack moved the dev port first, under a database that was already up. A stack that is
|
|
126
|
+
* not running, or whose `db` container is not, is refused instead.
|
|
121
127
|
*/
|
|
122
|
-
export
|
|
128
|
+
export function ensureDockerDbPublishedForHostEngine(cwd, config, command) {
|
|
123
129
|
if (resolveRuntimeProvider(config) !== "docker") {
|
|
124
130
|
throw new Error("ensureDockerDbPublishedForHostEngine requires provider: docker");
|
|
125
131
|
}
|
|
@@ -127,15 +133,9 @@ export async function ensureDockerDbPublishedForHostEngine(cwd, config, brand) {
|
|
|
127
133
|
throw new Error("This project uses an external database, so there is no Docker Postgres to publish. " +
|
|
128
134
|
"Point DATABASE_URL at it, or pass --connection.");
|
|
129
135
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
// the URL the engine is handed cannot be derived, so refuse before starting anything (M1b).
|
|
134
|
-
const mode = requireRunningStack(cwd, config.project.name);
|
|
135
|
-
if (mode === "dev")
|
|
136
|
-
await prepareDevComposeEnv(cwd, config, project, await resolveKongPort(cwd, project));
|
|
137
|
-
const paths = writeSelfHostCompose(cwd, config, { devLocal: mode === "dev" });
|
|
138
|
-
await startComposeDatabase(config, paths, cwd, project, brand);
|
|
136
|
+
// With no stack running the URL the engine is handed cannot be derived (M1b).
|
|
137
|
+
requireRunningStack(cwd, config.project.name);
|
|
138
|
+
requireStackDatabase(cwd, config, command);
|
|
139
139
|
}
|
|
140
140
|
/**
|
|
141
141
|
* True when CLI should publish local Compose Postgres for the host-side engine
|
|
@@ -161,10 +161,10 @@ export async function resolveHostEngineDatabaseUrl(cwd, config, explicit) {
|
|
|
161
161
|
// The URL comes from the one resolver every host-side command uses. It is resolved first so a
|
|
162
162
|
// derived URL with no stack running refuses before anything starts (M1b), and a DATABASE_URL
|
|
163
163
|
// someone set is used without one. Then, when it is this project's local docker Postgres, the
|
|
164
|
-
// database is
|
|
164
|
+
// stack's database is checked to be running, which is what the URL reaches.
|
|
165
165
|
const resolved = resolveHostDatabaseUrl(cwd, config, { connection: explicit, allowDerived: true });
|
|
166
166
|
if (resolved.source === DERIVED_DSN_SOURCE && usesLocalDockerEngineDb(config, explicit)) {
|
|
167
|
-
|
|
167
|
+
ensureDockerDbPublishedForHostEngine(cwd, config);
|
|
168
168
|
}
|
|
169
169
|
return resolved.dsn;
|
|
170
170
|
}
|
|
@@ -222,6 +222,7 @@ async function startComposeDatabase(config, paths, cwd, project, brand, timeoutM
|
|
|
222
222
|
export function upsertDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPort, devDbPort) {
|
|
223
223
|
const apiUrl = `http://localhost:${kongPort}`;
|
|
224
224
|
const imagePins = checkedImagePins(config);
|
|
225
|
+
const mailer = configMailerEnv(cwd, config);
|
|
225
226
|
// `POSTGRES_PASSWORD` and `JWT_SECRET` are deliberately absent.
|
|
226
227
|
//
|
|
227
228
|
// They used to be pinned here to published constants on every `dev` run, against the same
|
|
@@ -247,12 +248,10 @@ export function upsertDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPo
|
|
|
247
248
|
SUPATYPE_KONG_PORT: String(kongPort),
|
|
248
249
|
API_EXTERNAL_URL: apiUrl,
|
|
249
250
|
SITE_URL: apiUrl,
|
|
250
|
-
//
|
|
251
|
-
|
|
252
|
-
//
|
|
253
|
-
|
|
254
|
-
// service's noop client and no message at all.
|
|
255
|
-
...mailerProviderEnv(config.email),
|
|
251
|
+
// auth.email.enableConfirmations (unless the developer set their own in .env), email.provider
|
|
252
|
+
// and its settings, which the compose file passes to the server. The compose path used to carry
|
|
253
|
+
// none of them, so a project that asked for smtp, Resend or SES got the noop mailer.
|
|
254
|
+
...mailer.updates,
|
|
256
255
|
...imagePins,
|
|
257
256
|
};
|
|
258
257
|
// Never for an external database: this URL describes the `db` container, which that project does
|
|
@@ -284,8 +283,8 @@ export function upsertDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPo
|
|
|
284
283
|
applyForThisRun(runOnly);
|
|
285
284
|
const { urlsKept, rest } = takeFrontendUrls(persist);
|
|
286
285
|
upsertEnvFile(cwd, rest, {
|
|
287
|
-
removeManaged: removeImageKeys,
|
|
288
|
-
managed: [...managedImageKeys,
|
|
286
|
+
removeManaged: [...removeImageKeys, ...mailer.removeManaged],
|
|
287
|
+
managed: [...managedImageKeys, ...mailer.managed],
|
|
289
288
|
remove: [...retiredKeys, ...staleLocalServerImage(dotEnv["SUPATYPE_SERVER_IMAGE"], wantsLocalServer, imagePins)],
|
|
290
289
|
});
|
|
291
290
|
// The front end's copies go where a development build reads them, not .env, which a production
|
|
@@ -446,34 +445,49 @@ async function reportUnhealthyStack(composePath, cwd, project) {
|
|
|
446
445
|
}
|
|
447
446
|
console.error("");
|
|
448
447
|
}
|
|
449
|
-
|
|
448
|
+
/** One look at the gateway's two health routes: whether both answer OK, and what each said. */
|
|
449
|
+
async function gatewayHealth(base) {
|
|
450
|
+
try {
|
|
451
|
+
const [auth, realtime] = await Promise.all([
|
|
452
|
+
fetchWithin(`${base}/auth/v1/health`, 2000),
|
|
453
|
+
fetchWithin(`${base}/realtime/v1/health`, 2000),
|
|
454
|
+
]);
|
|
455
|
+
return { ready: auth.ok && realtime.ok, auth: `HTTP ${auth.status}`, realtime: `HTTP ${realtime.status}` };
|
|
456
|
+
}
|
|
457
|
+
catch (err) {
|
|
458
|
+
return { ready: false, auth: errorMessage(err), realtime: errorMessage(err) };
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Wait for the gateway at `kongPort`, watching `stack`'s essential services as it goes: one that
|
|
463
|
+
* has exited will not come back, so the wait stops there and prints its exit code and last log
|
|
464
|
+
* lines before the caller's cleanup removes them (issue 38). Either failure ends dev's dashboard
|
|
465
|
+
* first, so what it prints reaches the terminal rather than a screen that is about to close.
|
|
466
|
+
*/
|
|
467
|
+
export async function waitKongReady(kongPort, maxSec, stack) {
|
|
450
468
|
const base = loopbackBase(kongPort);
|
|
469
|
+
const watched = stack === undefined ? undefined : { watch: stack.watch ?? composeStackWatch(stack), cwd: stack.cwd };
|
|
451
470
|
// Remembered so the failure can name the unhealthy upstream. Blaming "the
|
|
452
471
|
// Kong gateway" sent more than one investigation after Kong when Kong was
|
|
453
472
|
// fine and a service behind it was not.
|
|
454
|
-
let
|
|
455
|
-
let lastRealtime = "no response";
|
|
473
|
+
let last = { auth: "no response", realtime: "no response" };
|
|
456
474
|
for (let i = 0; i < maxSec; i++) {
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
if (auth.ok && realtime.ok)
|
|
465
|
-
return;
|
|
466
|
-
}
|
|
467
|
-
catch (err) {
|
|
468
|
-
lastAuth = lastRealtime = errorMessage(err);
|
|
475
|
+
const [health, exited] = await Promise.all([gatewayHealth(base), watched?.watch.exited().catch(() => undefined)]);
|
|
476
|
+
if (health.ready)
|
|
477
|
+
return;
|
|
478
|
+
last = health;
|
|
479
|
+
if (exited !== undefined && watched !== undefined) {
|
|
480
|
+
endDevSession();
|
|
481
|
+
throw await exitedServiceFailure(exited, watched);
|
|
469
482
|
}
|
|
470
483
|
await sleep(1000);
|
|
471
484
|
}
|
|
472
485
|
if (stack !== undefined) {
|
|
486
|
+
endDevSession();
|
|
473
487
|
await reportUnhealthyStack(stack.composePath, stack.cwd, stack.project);
|
|
474
488
|
}
|
|
475
489
|
throw new Error(`Gateway at ${base} did not become ready within ${maxSec}s ` +
|
|
476
|
-
`(auth/v1/health: ${
|
|
490
|
+
`(auth/v1/health: ${last.auth}, realtime/v1/health: ${last.realtime})`);
|
|
477
491
|
}
|
|
478
492
|
/** Kong may be up while server → storage is still starting (503 or upstream errors). */
|
|
479
493
|
async function waitStorageApiReady(kongPort, serviceRoleKey, maxSec) {
|
|
@@ -680,6 +694,8 @@ export async function runComposeSchemaPush(cwd, config, paths, schemaPath, compo
|
|
|
680
694
|
// asked by `engineRequest`).
|
|
681
695
|
if (!hasEngineOverride(config))
|
|
682
696
|
await requireDockerFeatures(cwd, config, identityColumnsNeed(ast));
|
|
697
|
+
if (opts.access === "plan")
|
|
698
|
+
await printPlannedAccess(cwd, config);
|
|
683
699
|
try {
|
|
684
700
|
if (hasEngineOverride(config))
|
|
685
701
|
await applyViaHostEngine(cwd, config, ast, opts);
|
|
@@ -693,9 +709,27 @@ export async function runComposeSchemaPush(cwd, config, paths, schemaPath, compo
|
|
|
693
709
|
_lastPushedAst = astJson;
|
|
694
710
|
_lastFailedAst = null;
|
|
695
711
|
if (astRelatesToAuthUsers(ast))
|
|
696
|
-
grantAuthSchemaAccess(paths, cwd, composeProject);
|
|
712
|
+
await grantAuthSchemaAccess(paths, cwd, composeProject);
|
|
697
713
|
await refreshSchemaArtifacts(cwd, config, ast);
|
|
698
714
|
}
|
|
715
|
+
/**
|
|
716
|
+
* Each API role's access as the push about to apply leaves it, from a diff of the AST just written.
|
|
717
|
+
* Only a preview: a diff that fails says so and the push goes on, to report what is wrong itself.
|
|
718
|
+
*/
|
|
719
|
+
async function printPlannedAccess(cwd, config) {
|
|
720
|
+
try {
|
|
721
|
+
const diff = await dockerDiff(cwd, config);
|
|
722
|
+
if (diff !== undefined)
|
|
723
|
+
printRoleAccess(diff);
|
|
724
|
+
}
|
|
725
|
+
catch (err) {
|
|
726
|
+
console.log(`[supatype] Could not read each role's access before the push: ${errorMessage(err)}`);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
/** What a push reports of each role's access once applied: only `changes` prints anything. */
|
|
730
|
+
function appliedAccess(opts) {
|
|
731
|
+
return opts.access === undefined || opts.access === "changes" ? "changes" : "quiet";
|
|
732
|
+
}
|
|
699
733
|
/** The schema on disk as a push sends it, and that AST serialized for comparing pushes. */
|
|
700
734
|
function readSchemaToPush(schemaPath, cwd, config) {
|
|
701
735
|
const ast = withPublishing(loadSchemaAst(schemaPath, cwd), config);
|
|
@@ -738,7 +772,7 @@ async function applyViaHostEngine(cwd, config, ast, opts) {
|
|
|
738
772
|
schema_sources_manifest: sources.payload.manifest,
|
|
739
773
|
}),
|
|
740
774
|
};
|
|
741
|
-
reportAppliedPush(await enginePush(cwd, body, isEnginePushResult));
|
|
775
|
+
reportAppliedPush(await enginePush(cwd, body, isEnginePushResult), appliedAccess(opts));
|
|
742
776
|
}
|
|
743
777
|
/** Apply the AST on disk with the stack's schema-engine container. Throws when it is not applied. */
|
|
744
778
|
async function applyViaComposeEngine(cwd, config, stack, opts) {
|
|
@@ -777,7 +811,7 @@ async function runComposeSchemaPushQueued(cwd, config, paths, schemaPath, compos
|
|
|
777
811
|
_composePushQueued = false;
|
|
778
812
|
await runDevSchemaPush(cwd, config, paths, schemaPath, composeProject, opts);
|
|
779
813
|
} while (_composePushQueued);
|
|
780
|
-
followRecordedTier(cwd, config, { recreate: true });
|
|
814
|
+
await followRecordedTier(cwd, config, { recreate: true });
|
|
781
815
|
}
|
|
782
816
|
finally {
|
|
783
817
|
_composePushInFlight = false;
|
|
@@ -791,13 +825,13 @@ async function runComposeSchemaPushQueued(cwd, config, paths, schemaPath, compos
|
|
|
791
825
|
* recreated so a running stack serves the new search path now; a caller about to run
|
|
792
826
|
* `compose up -d` leaves that to it.
|
|
793
827
|
*/
|
|
794
|
-
export function followRecordedTier(cwd, config, opts) {
|
|
828
|
+
export async function followRecordedTier(cwd, config, opts) {
|
|
795
829
|
if (usesExternalDatabase(config))
|
|
796
830
|
return;
|
|
797
831
|
const project = composeProjectName(config.project.name);
|
|
798
832
|
const paths = selfHostComposePaths(cwd);
|
|
799
833
|
const served = composeFieldMaskingTier(cwd, config);
|
|
800
|
-
const recorded = recordDatabaseTier(cwd, { project, composePath: paths.composePath });
|
|
834
|
+
const recorded = await recordDatabaseTier(cwd, { project, composePath: paths.composePath });
|
|
801
835
|
if (recorded === undefined || sameApiSurface(config, served, recorded))
|
|
802
836
|
return;
|
|
803
837
|
writeSelfHostCompose(cwd, config, composeRenderOptions(cwd, config.project.name));
|
|
@@ -858,7 +892,7 @@ async function runComposeEnginePush(paths, cwd, composeProject, config, sources,
|
|
|
858
892
|
const pushResult = parseEnginePushOutput(output);
|
|
859
893
|
if (exitStatus === 0) {
|
|
860
894
|
if (pushResult) {
|
|
861
|
-
reportAppliedPush(pushResult);
|
|
895
|
+
reportAppliedPush(pushResult, appliedAccess(opts));
|
|
862
896
|
}
|
|
863
897
|
else {
|
|
864
898
|
console.log("[supatype] Schema applied.");
|
|
@@ -879,7 +913,7 @@ export async function dockerEngineCapabilities(cwd, config) {
|
|
|
879
913
|
const paths = writeSelfHostCompose(cwd, config, composeRenderOptions(cwd, config.project.name));
|
|
880
914
|
const target = { cwd, project: composeProjectName(config.project.name), composePath: paths.composePath, engineImage };
|
|
881
915
|
return checkedCapabilities((args) => {
|
|
882
|
-
const run =
|
|
916
|
+
const run = spawnComposeEngineSync(target, args, { runFlags: ["--no-deps"] });
|
|
883
917
|
return { status: run.status, stdout: run.stdout, stderr: run.error ?? run.stderr };
|
|
884
918
|
});
|
|
885
919
|
};
|
|
@@ -959,7 +993,7 @@ async function runComposeEngineCommand(paths, cwd, composeProject, config, comma
|
|
|
959
993
|
async function runComposeEngine(paths, cwd, composeProject, config, engineArgs) {
|
|
960
994
|
const engineImage = await schemaEngineImageForPush(config, cwd);
|
|
961
995
|
const target = { cwd, project: composeProject, composePath: paths.composePath, engineImage };
|
|
962
|
-
const result = spawnComposeEngine(target, engineArgs, {
|
|
996
|
+
const result = await spawnComposeEngine(target, engineArgs, {
|
|
963
997
|
secrets: { DATABASE_URL: projectDatabaseUrl(cwd, config, true) },
|
|
964
998
|
});
|
|
965
999
|
return {
|
|
@@ -1004,7 +1038,7 @@ export async function adoptSchemaDocker(cwd, config, yes, keys) {
|
|
|
1004
1038
|
if (keys !== undefined)
|
|
1005
1039
|
await requireDockerFeatures(cwd, config, [adoptKeysNeed(keys)]);
|
|
1006
1040
|
if (hasEngineOverride(config)) {
|
|
1007
|
-
|
|
1041
|
+
ensureDockerDbPublishedForHostEngine(cwd, config, "adopt");
|
|
1008
1042
|
await ensureEngine();
|
|
1009
1043
|
return engineRequest("/adopt", {
|
|
1010
1044
|
ast: withPublishing(loadSchemaAst(schemaPathFromProject(config, cwd), cwd), config),
|
|
@@ -1029,60 +1063,30 @@ export async function adoptSchemaDocker(cwd, config, yes, keys) {
|
|
|
1029
1063
|
* `overrides.engine` is set: then Postgres is published to the host and diff runs
|
|
1030
1064
|
* through the local engine binary.
|
|
1031
1065
|
*
|
|
1032
|
-
*
|
|
1033
|
-
*
|
|
1066
|
+
* Only against a stack that is running (issue 41): a stopped one is refused, not started. The diff
|
|
1067
|
+
* used to start Postgres itself, and stop it again afterwards.
|
|
1034
1068
|
*/
|
|
1035
1069
|
export async function diffSchemaDocker(cwd, config) {
|
|
1036
1070
|
if (resolveRuntimeProvider(config) !== "docker") {
|
|
1037
1071
|
throw new Error("diffSchemaDocker requires provider: docker");
|
|
1038
1072
|
}
|
|
1039
1073
|
const project = composeProjectName(config.project.name);
|
|
1040
|
-
const brand = { intro: "Schema diff" };
|
|
1041
1074
|
if (hasEngineOverride(config)) {
|
|
1042
|
-
|
|
1075
|
+
ensureDockerDbPublishedForHostEngine(cwd, config, "diff");
|
|
1076
|
+
return diffWithHostEngine(cwd, config);
|
|
1043
1077
|
}
|
|
1078
|
+
const running = runningStackMode(cwd, config.project.name);
|
|
1079
|
+
if (running === undefined && !usesExternalDatabase(config))
|
|
1080
|
+
throw new NoStackRunning("diff");
|
|
1044
1081
|
// A diff of a standalone stack must not write dev values over the operator's .env (SH1). A dev
|
|
1045
|
-
// stack's is brought up to date as push does: compose interpolates the whole file
|
|
1046
|
-
|
|
1047
|
-
const mode = composeRenderMode(cwd, config.project.name);
|
|
1082
|
+
// stack's is brought up to date as push does: compose interpolates the whole file.
|
|
1083
|
+
const mode = running ?? "standalone";
|
|
1048
1084
|
if (mode === "dev") {
|
|
1049
1085
|
const { anonKey, serviceRoleKey } = devApiKeys(cwd);
|
|
1050
1086
|
ensureDevComposeEnv(cwd, config, anonKey, serviceRoleKey, await resolveKongPort(cwd, project), undefined);
|
|
1051
1087
|
}
|
|
1052
1088
|
const paths = writeSelfHostCompose(cwd, config, { devLocal: mode === "dev" });
|
|
1053
|
-
return
|
|
1054
|
-
}
|
|
1055
|
-
/**
|
|
1056
|
-
* `run` with the stack's database up, `start` bringing it up, then stopped again when it was not
|
|
1057
|
-
* running before. One that a `supatype dev` session or a running stack is using is left as it was.
|
|
1058
|
-
*/
|
|
1059
|
-
async function withComposeDatabaseStarted(cwd, config, project, start, run) {
|
|
1060
|
-
const stack = { project, composePath: selfHostComposePaths(cwd).composePath };
|
|
1061
|
-
// An external database is not the stack's to start or stop.
|
|
1062
|
-
const wasStopped = !usesExternalDatabase(config) && !composeServiceIsRunning(cwd, stack, "db");
|
|
1063
|
-
let started = false;
|
|
1064
|
-
try {
|
|
1065
|
-
await start();
|
|
1066
|
-
started = true;
|
|
1067
|
-
return await run();
|
|
1068
|
-
}
|
|
1069
|
-
finally {
|
|
1070
|
-
// A start that failed after `up -d db` (its health wait, the host publish) has still brought
|
|
1071
|
-
// the container up; one refused before it (no stack running) has started nothing to stop.
|
|
1072
|
-
if (wasStopped && (started || composeServiceIsRunning(cwd, stack, "db")))
|
|
1073
|
-
stopComposeDatabase(cwd, stack);
|
|
1074
|
-
}
|
|
1075
|
-
}
|
|
1076
|
-
/** Stop the stack's database, saying so rather than failing the command whose result is already in hand. */
|
|
1077
|
-
function stopComposeDatabase(cwd, stack) {
|
|
1078
|
-
try {
|
|
1079
|
-
const status = runDockerCompose(stack.composePath, ["stop", "db"], cwd, stack.project, { quiet: true });
|
|
1080
|
-
if (status !== 0)
|
|
1081
|
-
warn("Could not stop the Postgres container this command started. Stop it with `supatype self-host compose stop db`.");
|
|
1082
|
-
}
|
|
1083
|
-
catch (err) {
|
|
1084
|
-
warn(`Could not stop the Postgres container this command started: ${errorMessage(err)}`);
|
|
1085
|
-
}
|
|
1089
|
+
return diffWithComposeEngine(cwd, config, paths, project);
|
|
1086
1090
|
}
|
|
1087
1091
|
/** The diff from the host engine binary, against the database published to the host. */
|
|
1088
1092
|
async function diffWithHostEngine(cwd, config) {
|
|
@@ -1125,40 +1129,62 @@ function unparsedDiffError(rawOutput) {
|
|
|
1125
1129
|
* `supatype push` when `provider: docker`. Uses in-compose schema-engine unless
|
|
1126
1130
|
* `overrides.engine` is set: then Postgres is published to the host and push runs
|
|
1127
1131
|
* through the local engine binary (AST v2, contributor builds).
|
|
1132
|
+
*
|
|
1133
|
+
* Only to a stack that is running (issue 41): a stopped one is refused, not started. The push used
|
|
1134
|
+
* to start Postgres, apply, then start the rest of the stack, and exited 1 with the schema applied
|
|
1135
|
+
* when that start failed. An external database is applied to with no stack running, and then no
|
|
1136
|
+
* stack is started.
|
|
1128
1137
|
*/
|
|
1129
1138
|
export async function pushSchemaDocker(cwd, config, opts = {}) {
|
|
1130
1139
|
if (resolveRuntimeProvider(config) !== "docker") {
|
|
1131
1140
|
throw new Error("pushSchemaDocker requires provider: docker");
|
|
1132
1141
|
}
|
|
1133
1142
|
const project = composeProjectName(config.project.name);
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
// engine is handed the database derived from the running stack, so with none running it refuses
|
|
1137
|
-
// before anything starts (M1b).
|
|
1138
|
-
const hostEngineDerivesDb = hasEngineOverride(config) && !usesExternalDatabase(config);
|
|
1139
|
-
const mode = hostEngineDerivesDb
|
|
1140
|
-
? requireRunningStack(cwd, config.project.name)
|
|
1141
|
-
: composeRenderMode(cwd, config.project.name);
|
|
1143
|
+
const running = pushStackMode(cwd, config);
|
|
1144
|
+
const mode = running ?? "standalone";
|
|
1142
1145
|
const kongPort = await resolveKongPort(cwd, project);
|
|
1143
1146
|
if (mode === "dev")
|
|
1144
1147
|
await prepareDevComposeEnv(cwd, config, project, kongPort);
|
|
1145
|
-
const gatewayPort = composeGatewayHostPort(config, mode, kongPort);
|
|
1146
|
-
const { anonKey, serviceRoleKey } = devApiKeys(cwd);
|
|
1147
1148
|
const paths = writeSelfHostCompose(cwd, config, { devLocal: mode === "dev" });
|
|
1148
|
-
const
|
|
1149
|
-
await startComposeDatabase(config, paths, cwd, project, pushBrand);
|
|
1149
|
+
const stack = { paths, project, gatewayPort: composeGatewayHostPort(config, mode, kongPort), brand: { intro: "Push schema" } };
|
|
1150
1150
|
if (!usesExternalDatabase(config))
|
|
1151
|
-
privatizeTableDefaults(paths, cwd, project);
|
|
1151
|
+
await privatizeTableDefaults(paths, cwd, project);
|
|
1152
1152
|
const schemaPath = schemaPathFromProject(config, cwd);
|
|
1153
1153
|
const ast = withPublishing(loadSchemaAst(schemaPath, cwd), config);
|
|
1154
1154
|
await runComposeSchemaPush(cwd, config, paths, schemaPath, project, opts);
|
|
1155
1155
|
// `up -d` below recreates PostgREST when the tier changed its environment.
|
|
1156
|
-
followRecordedTier(cwd, config, { recreate: false });
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1156
|
+
await followRecordedTier(cwd, config, { recreate: false });
|
|
1157
|
+
if (running === undefined) {
|
|
1158
|
+
console.log("[supatype] Schema pushed. The local stack isn't running, so nothing else was started.");
|
|
1159
|
+
return;
|
|
1160
|
+
}
|
|
1161
|
+
await bringUpAfterApply(() => bringPushedStackUp(cwd, config, stack, ast, devApiKeys(cwd)));
|
|
1162
|
+
}
|
|
1163
|
+
/**
|
|
1164
|
+
* The mode of the stack a push goes to, or undefined for an external database with no stack
|
|
1165
|
+
* running. A stopped stack with its own database is refused ({@link NoStackRunning}). The stack's
|
|
1166
|
+
* own mode, never dev by default: a push to a production stack used to render it as dev and
|
|
1167
|
+
* recreate it that way, and write dev values over the operator's .env (SH1).
|
|
1168
|
+
*/
|
|
1169
|
+
function pushStackMode(cwd, config) {
|
|
1170
|
+
const running = runningStackMode(cwd, config.project.name);
|
|
1171
|
+
if (running === undefined && !usesExternalDatabase(config))
|
|
1172
|
+
throw new NoStackRunning("push");
|
|
1173
|
+
return running;
|
|
1174
|
+
}
|
|
1175
|
+
/**
|
|
1176
|
+
* What a push does on a running stack after it applied: `up -d` for what the schema changed, then
|
|
1177
|
+
* the buckets, the first admin and the REST wait. The schema is in by then, so a step that fails
|
|
1178
|
+
* does not fail the push (issue 41): it is warned about, and the push exits 0.
|
|
1179
|
+
*/
|
|
1180
|
+
async function bringUpAfterApply(bringUp) {
|
|
1181
|
+
try {
|
|
1182
|
+
await bringUp();
|
|
1183
|
+
console.log("[supatype] Schema pushed.");
|
|
1184
|
+
}
|
|
1185
|
+
catch (err) {
|
|
1186
|
+
warn(`The schema was applied, but a step after it failed: ${errorMessage(err)}`);
|
|
1187
|
+
}
|
|
1162
1188
|
}
|
|
1163
1189
|
/**
|
|
1164
1190
|
* The host port the stack's gateway answers plain HTTP on. A standalone stack with TLS publishes
|
|
@@ -1168,6 +1194,28 @@ export async function pushSchemaDocker(cwd, config, opts = {}) {
|
|
|
1168
1194
|
export function composeGatewayHostPort(config, mode, kongPort) {
|
|
1169
1195
|
return selfHostTlsEnabled(config, mode === "dev") ? 80 : kongPort;
|
|
1170
1196
|
}
|
|
1197
|
+
/** A stack `up` started that never answered through its gateway: not up, whatever `up` said (issue 57). */
|
|
1198
|
+
export class StackNotServing extends Error {
|
|
1199
|
+
name = "StackNotServing";
|
|
1200
|
+
}
|
|
1201
|
+
/**
|
|
1202
|
+
* What a started stack needs once it answers: the gateway and storage waited for, then the schema's
|
|
1203
|
+
* declared buckets and the first admin user. A push to a running stack runs it after its `up -d`,
|
|
1204
|
+
* and `self-host compose up` after its own, so no command depends on a push to start the stack and
|
|
1205
|
+
* create them (issue 41).
|
|
1206
|
+
*/
|
|
1207
|
+
export async function provisionStartedStack(cwd, config, stack, ast, serviceRoleKey) {
|
|
1208
|
+
const { composePath, project, gatewayPort } = stack;
|
|
1209
|
+
try {
|
|
1210
|
+
await waitKongReady(gatewayPort, 120, { composePath, cwd, project });
|
|
1211
|
+
}
|
|
1212
|
+
catch (err) {
|
|
1213
|
+
throw new StackNotServing(errorMessage(err), { cause: err });
|
|
1214
|
+
}
|
|
1215
|
+
await waitStorageApiReady(gatewayPort, serviceRoleKey, 90);
|
|
1216
|
+
await provisionDockerStorageBuckets(ast, gatewayPort, serviceRoleKey);
|
|
1217
|
+
await ensureFirstAdminUserForProject(cwd, config, { compose: { project, composePath } });
|
|
1218
|
+
}
|
|
1171
1219
|
/**
|
|
1172
1220
|
* After a compose push: the rest of the stack up, then what the schema asks of it once it answers
|
|
1173
1221
|
* (buckets, the first admin), then REST, which is the last to catch up with the new schema.
|
|
@@ -1175,15 +1223,10 @@ export function composeGatewayHostPort(config, mode, kongPort) {
|
|
|
1175
1223
|
async function bringPushedStackUp(cwd, config, stack, ast, keys) {
|
|
1176
1224
|
const { paths, project, gatewayPort, brand } = stack;
|
|
1177
1225
|
const upGateway = runDockerCompose(paths.composePath, ["up", "-d"], cwd, project, { quiet: true, brand });
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
await
|
|
1182
|
-
await waitStorageApiReady(gatewayPort, keys.serviceRoleKey, 90);
|
|
1183
|
-
await provisionDockerStorageBuckets(ast, gatewayPort, keys.serviceRoleKey);
|
|
1184
|
-
await ensureFirstAdminUserForProject(cwd, config, {
|
|
1185
|
-
compose: { project, composePath: paths.composePath },
|
|
1186
|
-
});
|
|
1226
|
+
// Thrown, not exited: the schema is applied by now (bringUpAfterApply).
|
|
1227
|
+
if (upGateway !== 0)
|
|
1228
|
+
throw new Error(`docker compose up exited with status ${upGateway}`);
|
|
1229
|
+
await provisionStartedStack(cwd, config, { composePath: paths.composePath, project, gatewayPort }, ast, keys.serviceRoleKey);
|
|
1187
1230
|
// Last, so the admin user and the buckets are not held up by it. `supatype dev` never comes
|
|
1188
1231
|
// through here: it pushes before PostgREST starts, so PostgREST finds the schemas on its first try.
|
|
1189
1232
|
await waitForRestReady(loopbackBase(gatewayPort), keys.anonKey);
|
|
@@ -1230,6 +1273,26 @@ async function devStackDbPort(cwd, config, project) {
|
|
|
1230
1273
|
await offerToSaveShellDbPort(cwd);
|
|
1231
1274
|
return port;
|
|
1232
1275
|
}
|
|
1276
|
+
/** Stop the watchers and processes dev started, then bring the compose stack down. */
|
|
1277
|
+
export async function stopDevComposeStack(state, stack, cwd) {
|
|
1278
|
+
state.schemaWatcher?.close();
|
|
1279
|
+
state.schemaWatcher = null;
|
|
1280
|
+
state.functionsWatcher?.close();
|
|
1281
|
+
state.functionsWatcher = null;
|
|
1282
|
+
console.log("[supatype] Shutting down compose...");
|
|
1283
|
+
await state.studioProc?.stop();
|
|
1284
|
+
await state.appProc?.stop();
|
|
1285
|
+
await settleComposeRuns();
|
|
1286
|
+
// Docker was answering a moment ago, so the daemon probe is skipped: a slow `docker info` made it
|
|
1287
|
+
// report the daemon down and exit before `down` ran (issue 33).
|
|
1288
|
+
const downStatus = runDockerCompose(stack.composePath, ["down"], cwd, stack.project, { quiet: true, skipDaemonProbe: true });
|
|
1289
|
+
if (downStatus === 0) {
|
|
1290
|
+
console.log("[supatype] Compose stack stopped.");
|
|
1291
|
+
}
|
|
1292
|
+
else {
|
|
1293
|
+
console.warn(`[supatype] Compose down exited with status ${downStatus}.`);
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1233
1296
|
export async function runDevCompose(cwd, config, opts) {
|
|
1234
1297
|
if (resolveRuntimeProvider(config) !== "docker") {
|
|
1235
1298
|
throw new Error("runDevCompose requires provider: docker");
|
|
@@ -1253,7 +1316,7 @@ export async function runDevCompose(cwd, config, opts) {
|
|
|
1253
1316
|
const devBrand = { intro: "Local development" };
|
|
1254
1317
|
const localServerImage = await ensureLocalServerDockerImage(cwd, config, devBrand);
|
|
1255
1318
|
ensureDevComposeEnv(cwd, config, anonKey, serviceRoleKey, kongPort, devDbPort);
|
|
1256
|
-
|
|
1319
|
+
warnMissingStackSettings(cwd, config);
|
|
1257
1320
|
console.log(`[supatype] provider docker, starting self-host Compose stack (project ${project}, gateway :${kongPort})...`);
|
|
1258
1321
|
await showDevStep("Preparing the Docker stack");
|
|
1259
1322
|
noteUnpinnedImages(cwd);
|
|
@@ -1267,23 +1330,7 @@ export async function runDevCompose(cwd, config, opts) {
|
|
|
1267
1330
|
schemaWatcher: null,
|
|
1268
1331
|
functionsWatcher: null,
|
|
1269
1332
|
};
|
|
1270
|
-
registerDevShutdown(
|
|
1271
|
-
shutdownState.schemaWatcher?.close();
|
|
1272
|
-
shutdownState.schemaWatcher = null;
|
|
1273
|
-
shutdownState.functionsWatcher?.close();
|
|
1274
|
-
shutdownState.functionsWatcher = null;
|
|
1275
|
-
console.log("[supatype] Shutting down compose...");
|
|
1276
|
-
await shutdownState.studioProc?.stop();
|
|
1277
|
-
await shutdownState.appProc?.stop();
|
|
1278
|
-
await settleComposeRuns();
|
|
1279
|
-
const downStatus = runDockerCompose(paths.composePath, ["down"], cwd, project, { quiet: true });
|
|
1280
|
-
if (downStatus === 0) {
|
|
1281
|
-
console.log("[supatype] Compose stack stopped.");
|
|
1282
|
-
}
|
|
1283
|
-
else {
|
|
1284
|
-
console.warn(`[supatype] Compose down exited with status ${downStatus}.`);
|
|
1285
|
-
}
|
|
1286
|
-
}, {
|
|
1333
|
+
registerDevShutdown(() => stopDevComposeStack(shutdownState, { project, composePath: paths.composePath }, cwd), {
|
|
1287
1334
|
cwd,
|
|
1288
1335
|
compose: { cwd, composePath: paths.composePath, composeProject: project },
|
|
1289
1336
|
});
|
|
@@ -1310,9 +1357,9 @@ export async function runDevCompose(cwd, config, opts) {
|
|
|
1310
1357
|
// With the stack's database up, so a hand-written URL naming it is not reported as silent.
|
|
1311
1358
|
await warnIfHandWrittenUrlSilent(cwd);
|
|
1312
1359
|
if (!usesExternalDatabase(config)) {
|
|
1313
|
-
reconcileAuthenticatorPassword(paths, cwd, project);
|
|
1314
|
-
reconcileSqlEditorPassword(paths, cwd, project);
|
|
1315
|
-
privatizeTableDefaults(paths, cwd, project);
|
|
1360
|
+
await reconcileAuthenticatorPassword(paths, cwd, project);
|
|
1361
|
+
await reconcileSqlEditorPassword(paths, cwd, project);
|
|
1362
|
+
await privatizeTableDefaults(paths, cwd, project);
|
|
1316
1363
|
}
|
|
1317
1364
|
// A: apply schema before realtime (and the rest of the stack) starts decoding WAL.
|
|
1318
1365
|
const schemaPath = schemaPathFromProject(config, cwd);
|
|
@@ -1321,7 +1368,7 @@ export async function runDevCompose(cwd, config, opts) {
|
|
|
1321
1368
|
await showDevStep("Applying the schema");
|
|
1322
1369
|
const schemaApplied = await applyInitialSchema(cwd, config, paths, schemaPath, project, devBrand, pushOptions);
|
|
1323
1370
|
// Before the stack starts, so PostgREST comes up on the tier the push actually produced.
|
|
1324
|
-
followRecordedTier(cwd, config, { recreate: false });
|
|
1371
|
+
await followRecordedTier(cwd, config, { recreate: false });
|
|
1325
1372
|
console.log("[supatype] Bringing up Docker Compose services...");
|
|
1326
1373
|
await showDevStep("Starting services (the first start downloads their images)");
|
|
1327
1374
|
const upStatus = await runDockerComposeQuietly(paths.composePath, ["up", "-d"], cwd, project, devBrand);
|
|
@@ -1446,14 +1493,18 @@ export async function runDevCompose(cwd, config, opts) {
|
|
|
1446
1493
|
shutdownState.schemaWatcher = watchDevSchema({
|
|
1447
1494
|
dir: schemaDir,
|
|
1448
1495
|
changedSinceLastPush: () => schemaChangedSinceLastPush(schemaPath, cwd, config),
|
|
1496
|
+
// The failure is reported inside the scope too, so its hints reach the dashboard.
|
|
1449
1497
|
push: (why) => {
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1498
|
+
void withSavePushOutput(async () => {
|
|
1499
|
+
console.log(`\n[supatype] ${why}, pushing schema...`);
|
|
1500
|
+
try {
|
|
1501
|
+
await runComposeSchemaPushQueued(cwd, config, paths, schemaPath, project, pushOptions);
|
|
1502
|
+
await provisionDockerStorageBuckets(loadSchemaAst(schemaPath, cwd), kongPort, serviceRoleKey);
|
|
1503
|
+
}
|
|
1504
|
+
catch (err) {
|
|
1505
|
+
reportDevPushFailure(err);
|
|
1506
|
+
}
|
|
1507
|
+
});
|
|
1457
1508
|
},
|
|
1458
1509
|
});
|
|
1459
1510
|
// The worker imports its handlers once; without this an edited function kept its old code.
|