@supatype/cli 0.8.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 +415 -0
- package/bin/supatype.js +16 -1
- package/dist/after-hooks-health.d.ts +19 -0
- package/dist/after-hooks-health.d.ts.map +1 -0
- package/dist/after-hooks-health.js +69 -0
- package/dist/after-hooks-health.js.map +1 -0
- package/dist/app/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/app-vite-env.d.ts +5 -1
- package/dist/app-vite-env.d.ts.map +1 -1
- package/dist/app-vite-env.js +9 -15
- package/dist/app-vite-env.js.map +1 -1
- package/dist/augmentation-generator.d.ts +5 -0
- package/dist/augmentation-generator.d.ts.map +1 -1
- package/dist/augmentation-generator.js +13 -4
- package/dist/augmentation-generator.js.map +1 -1
- package/dist/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/binary-cache.d.ts +2 -1
- package/dist/binary-cache.d.ts.map +1 -1
- package/dist/binary-cache.js +2 -4
- package/dist/binary-cache.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/byte-size.d.ts +9 -0
- package/dist/byte-size.d.ts.map +1 -0
- package/dist/byte-size.js +36 -0
- package/dist/byte-size.js.map +1 -0
- package/dist/cache-clean.d.ts +0 -2
- package/dist/cache-clean.d.ts.map +1 -1
- package/dist/cache-clean.js +1 -27
- package/dist/cache-clean.js.map +1 -1
- package/dist/cache-pins.d.ts.map +1 -1
- package/dist/cache-pins.js +1 -18
- package/dist/cache-pins.js.map +1 -1
- package/dist/cache-root.d.ts +7 -0
- package/dist/cache-root.d.ts.map +1 -0
- package/dist/cache-root.js +11 -0
- package/dist/cache-root.js.map +1 -0
- package/dist/cli-artifacts.d.ts.map +1 -1
- package/dist/cli-artifacts.js +2 -1
- package/dist/cli-artifacts.js.map +1 -1
- package/dist/cli-install-method.d.ts.map +1 -1
- package/dist/cli-install-method.js +7 -1
- package/dist/cli-install-method.js.map +1 -1
- package/dist/cli-launcher.d.ts +21 -0
- package/dist/cli-launcher.d.ts.map +1 -0
- package/dist/cli-launcher.js +112 -0
- package/dist/cli-launcher.js.map +1 -0
- package/dist/cli-old-versions.d.ts +44 -0
- package/dist/cli-old-versions.d.ts.map +1 -0
- package/dist/cli-old-versions.js +83 -0
- package/dist/cli-old-versions.js.map +1 -0
- package/dist/cli-program-path.d.ts +20 -0
- package/dist/cli-program-path.d.ts.map +1 -0
- package/dist/cli-program-path.js +41 -0
- package/dist/cli-program-path.js.map +1 -0
- package/dist/cli-standalone.d.ts +2 -3
- package/dist/cli-standalone.d.ts.map +1 -1
- package/dist/cli-standalone.js +51 -24
- package/dist/cli-standalone.js.map +1 -1
- package/dist/cli-version-embedded.js +1 -1
- package/dist/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 +37 -7
- 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 +68 -53
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +36 -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.d.ts +32 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +67 -2
- 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/hooks.d.ts.map +1 -1
- package/dist/commands/hooks.js +23 -15
- package/dist/commands/hooks.js.map +1 -1
- package/dist/commands/init.d.ts +33 -7
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +432 -333
- 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 +10 -10
- package/dist/commands/keys.d.ts.map +1 -1
- package/dist/commands/keys.js +47 -43
- 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 -7
- 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 +2 -0
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +64 -26
- 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 +88 -29
- package/dist/commands/self-host.js.map +1 -1
- package/dist/commands/self-update.d.ts.map +1 -1
- package/dist/commands/self-update.js +9 -3
- package/dist/commands/self-update.js.map +1 -1
- package/dist/commands/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-kong.d.ts +4 -0
- package/dist/compose-kong.d.ts.map +1 -1
- package/dist/compose-kong.js +13 -3
- package/dist/compose-kong.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/config.d.ts +9 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +18 -3
- package/dist/config.js.map +1 -1
- package/dist/database-url-owner.d.ts +5 -3
- package/dist/database-url-owner.d.ts.map +1 -1
- package/dist/database-url-owner.js +7 -4
- package/dist/database-url-owner.js.map +1 -1
- package/dist/db-port.d.ts +2 -0
- package/dist/db-port.d.ts.map +1 -1
- package/dist/db-port.js +1 -1
- package/dist/db-port.js.map +1 -1
- package/dist/db-preflight.d.ts +32 -3
- package/dist/db-preflight.d.ts.map +1 -1
- package/dist/db-preflight.js +211 -86
- package/dist/db-preflight.js.map +1 -1
- 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 +65 -5
- package/dist/dev-compose.d.ts.map +1 -1
- package/dist/dev-compose.js +262 -155
- package/dist/dev-compose.js.map +1 -1
- package/dist/dev-log-bus.d.ts +8 -0
- package/dist/dev-log-bus.d.ts.map +1 -1
- package/dist/dev-log-bus.js +13 -0
- package/dist/dev-log-bus.js.map +1 -1
- package/dist/dev-ports.d.ts +11 -4
- package/dist/dev-ports.d.ts.map +1 -1
- package/dist/dev-ports.js +87 -49
- 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 +27 -1
- package/dist/dev-session.d.ts.map +1 -1
- package/dist/dev-session.js +44 -4
- package/dist/dev-session.js.map +1 -1
- package/dist/dev-shutdown.d.ts.map +1 -1
- package/dist/dev-shutdown.js +19 -3
- 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 +7 -1
- package/dist/diff-output.d.ts.map +1 -1
- package/dist/diff-output.js +93 -3
- 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 +10 -2
- package/dist/docker-runtime.d.ts.map +1 -1
- package/dist/docker-runtime.js +70 -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 +12 -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-ownership-gate.d.ts +3 -1
- package/dist/engine-ownership-gate.d.ts.map +1 -1
- package/dist/engine-ownership-gate.js +5 -0
- package/dist/engine-ownership-gate.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 +9 -2
- package/dist/env-file.d.ts.map +1 -1
- package/dist/env-file.js +56 -38
- 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 +51 -0
- package/dist/frontend-env.d.ts.map +1 -0
- package/dist/frontend-env.js +101 -0
- package/dist/frontend-env.js.map +1 -0
- 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/hook-actor.d.ts +17 -0
- package/dist/hook-actor.d.ts.map +1 -0
- package/dist/hook-actor.js +37 -0
- package/dist/hook-actor.js.map +1 -0
- package/dist/hook-columns.d.ts +30 -0
- package/dist/hook-columns.d.ts.map +1 -0
- package/dist/hook-columns.js +77 -0
- package/dist/hook-columns.js.map +1 -0
- package/dist/hook-events.d.ts +11 -0
- package/dist/hook-events.d.ts.map +1 -0
- package/dist/hook-events.js +11 -0
- package/dist/hook-events.js.map +1 -0
- package/dist/hooks-generator.d.ts.map +1 -1
- package/dist/hooks-generator.js +87 -21
- package/dist/hooks-generator.js.map +1 -1
- 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-dependency-versions.d.ts.map +1 -1
- package/dist/init-dependency-versions.js +11 -1
- package/dist/init-dependency-versions.js.map +1 -1
- 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/init-package-json.d.ts +38 -1
- package/dist/init-package-json.d.ts.map +1 -1
- package/dist/init-package-json.js +150 -39
- package/dist/init-package-json.js.map +1 -1
- 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/model-hooks.d.ts +5 -1
- package/dist/model-hooks.d.ts.map +1 -1
- package/dist/model-hooks.js +12 -2
- package/dist/model-hooks.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 +31 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +24 -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 +18 -1
- package/dist/resolve-target.d.ts.map +1 -1
- package/dist/resolve-target.js +28 -16
- 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 +25 -4
- package/dist/self-host-compose.d.ts.map +1 -1
- package/dist/self-host-compose.js +108 -23
- 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/shell-ports.d.ts.map +1 -1
- package/dist/shell-ports.js +2 -8
- package/dist/shell-ports.js.map +1 -1
- 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 +18 -17
- package/dist/tsx-runner.js.map +1 -1
- package/dist/type-extractor.d.ts.map +1 -1
- package/dist/type-extractor.js +20 -11
- package/dist/type-extractor.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/dev/DevDashboard.d.ts.map +1 -1
- package/dist/ui/dev/DevDashboard.js +9 -3
- package/dist/ui/dev/DevDashboard.js.map +1 -1
- 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 +14 -7
- package/dist/ui/flows/prompt-fields.d.ts.map +1 -1
- package/dist/ui/flows/prompt-fields.js +20 -12
- 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 +16 -14
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The checks on what init is told, typed at a prompt or given as a flag, before any of it is
|
|
3
|
+
* written. Manual test #37: a pasted email with carriage returns in it went into `.env` as it was,
|
|
4
|
+
* and the server, reading each piece as a line, refused to start and logged the admin password.
|
|
5
|
+
*/
|
|
6
|
+
import { portNumber } from "./env-file.js";
|
|
7
|
+
import { hasControlCharacter } from "./env-value.js";
|
|
8
|
+
import { p } from "./ui/clack.js";
|
|
9
|
+
import { ensureNotCancelled } from "./ui/prompts.js";
|
|
10
|
+
export const CONTROL_CHARACTER_PROBLEM = "That has a line break or another control character in it, from a paste perhaps. Type it on one line.";
|
|
11
|
+
/** Why `value` cannot be an answer at all, or undefined when it can. */
|
|
12
|
+
export function answerProblem(value) {
|
|
13
|
+
return hasControlCharacter(value) ? CONTROL_CHARACTER_PROBLEM : undefined;
|
|
14
|
+
}
|
|
15
|
+
/** One address: something, one `@`, something, with no whitespace or control characters. */
|
|
16
|
+
const ONE_ADDRESS = /^[^\s@]+@[^\s@]+$/;
|
|
17
|
+
/** Why `value` is not one email address, or undefined when it is. Never repeats the value. */
|
|
18
|
+
export function adminEmailProblem(value) {
|
|
19
|
+
const email = value.trim();
|
|
20
|
+
if (email === "")
|
|
21
|
+
return "Email is required.";
|
|
22
|
+
if (hasControlCharacter(email))
|
|
23
|
+
return CONTROL_CHARACTER_PROBLEM;
|
|
24
|
+
return ONE_ADDRESS.test(email) ? undefined : "Enter one email address, like you@example.com.";
|
|
25
|
+
}
|
|
26
|
+
/** A text prompt whose answer is refused while it holds a control character, then by `validate`. */
|
|
27
|
+
export async function askText(options) {
|
|
28
|
+
const { validate } = options;
|
|
29
|
+
const answer = await p.text({ ...options, validate: (value) => answerProblem(value) ?? validate?.(value) });
|
|
30
|
+
return ensureNotCancelled(answer);
|
|
31
|
+
}
|
|
32
|
+
/** Why `value` is not an SMTP host, or undefined when it is: one name, no spaces. */
|
|
33
|
+
export function smtpHostProblem(value) {
|
|
34
|
+
const host = value.trim();
|
|
35
|
+
if (host === "")
|
|
36
|
+
return "A host is required: without one no email is sent.";
|
|
37
|
+
return /\s/.test(host) ? "Enter one host name, like smtp.example.com." : undefined;
|
|
38
|
+
}
|
|
39
|
+
/** Why `value` is not a port, or undefined when it is one or is empty (the default then applies). */
|
|
40
|
+
export function smtpPortProblem(value) {
|
|
41
|
+
const port = value.trim();
|
|
42
|
+
if (port === "")
|
|
43
|
+
return undefined;
|
|
44
|
+
return /^\d+$/.test(port) && portNumber(port) !== null ? undefined : "Enter a port from 1 to 65535.";
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=init-answers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-answers.js","sourceRoot":"","sources":["../src/init-answers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAA;AAEjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEpD,MAAM,CAAC,MAAM,yBAAyB,GACpC,sGAAsG,CAAA;AAExG,wEAAwE;AACxE,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,SAAS,CAAA;AAC3E,CAAC;AAED,4FAA4F;AAC5F,MAAM,WAAW,GAAG,mBAAmB,CAAA;AAEvC,8FAA8F;AAC9F,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;IAC1B,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,oBAAoB,CAAA;IAC7C,IAAI,mBAAmB,CAAC,KAAK,CAAC;QAAE,OAAO,yBAAyB,CAAA;IAChE,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,gDAAgD,CAAA;AAC/F,CAAC;AAED,oGAAoG;AACpG,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,OAAyB;IACrD,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAA;IAC5B,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IAC3G,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAA;AACnC,CAAC;AAQD,qFAAqF;AACrF,MAAM,UAAU,eAAe,CAAC,KAAa;IAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;IACzB,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO,mDAAmD,CAAA;IAC3E,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,6CAA6C,CAAC,CAAC,CAAC,SAAS,CAAA;AACpF,CAAC;AAED,qGAAqG;AACrG,MAAM,UAAU,eAAe,CAAC,KAAa;IAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;IACzB,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO,SAAS,CAAA;IACjC,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,+BAA+B,CAAA;AACtG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-dependency-versions.d.ts","sourceRoot":"","sources":["../src/init-dependency-versions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init-dependency-versions.d.ts","sourceRoot":"","sources":["../src/init-dependency-versions.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,+EAA+E;IAC/E,MAAM,EAAE,MAAM,CAAA;CACf;AAaD,mEAAmE;AACnE,wBAAgB,8BAA8B,IAAI,sBAAsB,CAGvE;AAiDD;;;;GAIG;AACH,wBAAsB,6BAA6B,IAAI,OAAO,CAAC,sBAAsB,CAAC,CAiBrF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { cliPackageVersion } from "./cli-package-version.js";
|
|
2
|
+
import semver from "semver";
|
|
2
3
|
import { isRecordOf, isShape, isString, isUnknown, optional } from "@supatype/shared";
|
|
3
4
|
/** The part of an npm registry document read here. */
|
|
4
5
|
const isNpmRegistryPackage = isShape({
|
|
@@ -70,7 +71,16 @@ export async function resolveInitDependencyVersions() {
|
|
|
70
71
|
return {
|
|
71
72
|
cli: resolvePackageVersion(cliMeta, runningCli),
|
|
72
73
|
types: resolvePackageVersion(typesMeta, runningCli),
|
|
73
|
-
client: resolvePackageVersion(clientMeta, runningCli),
|
|
74
|
+
client: notOlderThan(resolvePackageVersion(clientMeta, runningCli), runningCli),
|
|
74
75
|
};
|
|
75
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* The client carries `supatype-prepare`, the scaffold's `prepare`, and is released with the CLI,
|
|
79
|
+
* so one older than the running CLI may predate it. npm's latest is such a client while this CLI's
|
|
80
|
+
* own release is still publishing, or failed to: then this CLI's version, which npm will not have
|
|
81
|
+
* yet, fails the install on that version, where npm's latest failed it on a missing command.
|
|
82
|
+
*/
|
|
83
|
+
function notOlderThan(version, floor) {
|
|
84
|
+
return semver.valid(version) !== null && semver.valid(floor) !== null && semver.lt(version, floor) ? floor : version;
|
|
85
|
+
}
|
|
76
86
|
//# sourceMappingURL=init-dependency-versions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-dependency-versions.js","sourceRoot":"","sources":["../src/init-dependency-versions.ts"],"names":[],"m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GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAA;IACzC,IAAI,MAAM;QAAE,OAAO,MAAM,CAAA;IACzB,OAAO,SAAS,CAAA;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B;IACjD,MAAM,UAAU,GAAG,iBAAiB,EAAE,CAAA;IACtC,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,UAAU,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACzD,eAAe,CAAC,eAAe,CAAC;QAChC,eAAe,CAAC,iBAAiB,CAAC;QAClC,eAAe,CAAC,kBAAkB,CAAC;KACpC,CAAC,CAAA;IAEF,IAAI,CAAC,OAAO,IAAI,CAAC,SAAS,IAAI,CAAC,UAAU,EAAE,CAAC;QAC1C,OAAO,8BAA8B,EAAE,CAAA;IACzC,CAAC;IAED,OAAO;QACL,GAAG,EAAE,qBAAqB,CAAC,OAAO,EAAE,UAAU,CAAC;QAC/C,KAAK,EAAE,qBAAqB,CAAC,SAAS,EAAE,UAAU,CAAC;QACnD,MAAM,EAAE,YAAY,CAAC,qBAAqB,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,UAAU,CAAC;KAChF,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,YAAY,CAAC,OAAe,EAAE,KAAa;IAClD,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAA;AACtH,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/supatype-env.js` in a Next.js app: the route that serves it, and the root layout's script.
|
|
3
|
+
*
|
|
4
|
+
* `next build` prerenders the static pages without the deployment's values, so init has the app
|
|
5
|
+
* serve them when a page loads instead. The route, `@supatype/ssr/next`'s `GET`, answers with
|
|
6
|
+
* `SUPATYPE_URL` and `SUPATYPE_ANON_KEY` as the running server has them; the root layout loads it
|
|
7
|
+
* with `next/script`'s `beforeInteractive`, which Next runs before it requires any of the app's
|
|
8
|
+
* modules, so the client has the values by its first request.
|
|
9
|
+
*
|
|
10
|
+
* The App Router only: route handlers live in `app/`. A Pages Router app is told what to add, since
|
|
11
|
+
* init would have to create an `app/` directory beside it and edit `pages/_document`, which it does
|
|
12
|
+
* not own. A layout init cannot edit safely is left as it is, and the two lines are printed instead.
|
|
13
|
+
*/
|
|
14
|
+
/** The route file. The segment config is written in it: Next's build does not recognize a re-exported one. */
|
|
15
|
+
export declare const NEXT_RUNTIME_ENV_ROUTE: string;
|
|
16
|
+
type Write = (rel: string, content: string) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Serve `/supatype-env.js` from a Next.js app in `dir`, and load it in its root layout. Does
|
|
19
|
+
* nothing for an app that is not Next.js. `ssrRange` is the version range `@supatype/ssr` is added
|
|
20
|
+
* at, when the app does not list it.
|
|
21
|
+
*/
|
|
22
|
+
export declare function scaffoldNextRuntimeEnv(dir: string, write: Write, ssrRange: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* `source` with the script as the first thing in its one `<body>`, importing `next/script` when it
|
|
25
|
+
* does not already. Undefined when that cannot be done without guessing: no `<body>` or more than
|
|
26
|
+
* one, a `<body>` whose attributes hold a `>`, or a `Script` that is something else.
|
|
27
|
+
*/
|
|
28
|
+
export declare function withRuntimeEnvScript(source: string): string | undefined;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=init-next-runtime-env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-next-runtime-env.d.ts","sourceRoot":"","sources":["../src/init-next-runtime-env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAaH,8GAA8G;AAC9G,eAAO,MAAM,sBAAsB,QAOvB,CAAA;AAmCZ,KAAK,KAAK,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;AAEnD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAiBxF;AAuBD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAcvE"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/supatype-env.js` in a Next.js app: the route that serves it, and the root layout's script.
|
|
3
|
+
*
|
|
4
|
+
* `next build` prerenders the static pages without the deployment's values, so init has the app
|
|
5
|
+
* serve them when a page loads instead. The route, `@supatype/ssr/next`'s `GET`, answers with
|
|
6
|
+
* `SUPATYPE_URL` and `SUPATYPE_ANON_KEY` as the running server has them; the root layout loads it
|
|
7
|
+
* with `next/script`'s `beforeInteractive`, which Next runs before it requires any of the app's
|
|
8
|
+
* modules, so the client has the values by its first request.
|
|
9
|
+
*
|
|
10
|
+
* The App Router only: route handlers live in `app/`. A Pages Router app is told what to add, since
|
|
11
|
+
* init would have to create an `app/` directory beside it and edit `pages/_document`, which it does
|
|
12
|
+
* not own. A layout init cannot edit safely is left as it is, and the two lines are printed instead.
|
|
13
|
+
*/
|
|
14
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
15
|
+
import { join } from "node:path";
|
|
16
|
+
import { detectFramework } from "./app/framework.js";
|
|
17
|
+
import { file, info, plain } from "./ui/messages.js";
|
|
18
|
+
import { isJsonObject, parseJsonObject } from "@supatype/shared";
|
|
19
|
+
const SSR_PACKAGE = "@supatype/ssr";
|
|
20
|
+
const SCRIPT_SRC = "/supatype-env.js";
|
|
21
|
+
const SCRIPT_IMPORT = 'import Script from "next/script"';
|
|
22
|
+
const LAYOUT_NAMES = ["layout.tsx", "layout.jsx", "layout.js", "layout.ts"];
|
|
23
|
+
/** The route file. The segment config is written in it: Next's build does not recognize a re-exported one. */
|
|
24
|
+
export const NEXT_RUNTIME_ENV_ROUTE = [
|
|
25
|
+
"// The deployment's API address and anon key for the browser client, read from SUPATYPE_URL and",
|
|
26
|
+
"// SUPATYPE_ANON_KEY on the server at each page load. The root layout loads it before the app.",
|
|
27
|
+
`export { GET } from "${SSR_PACKAGE}/next"`,
|
|
28
|
+
"// Written here rather than re-exported: Next reads a route's segment config from this file only.",
|
|
29
|
+
'export const dynamic = "force-dynamic"',
|
|
30
|
+
"",
|
|
31
|
+
].join("\n");
|
|
32
|
+
const NEXT_CONFIG_NAMES = ["next.config.ts", "next.config.mts", "next.config.mjs", "next.config.js", "next.config.cjs"];
|
|
33
|
+
/** `output: "export"` in any quotes, the one setting that makes `next build` a static export. */
|
|
34
|
+
const STATIC_EXPORT_OUTPUT = /\boutput\s*:\s*(["'`])export\1/;
|
|
35
|
+
/**
|
|
36
|
+
* Whether the app's `next.config` makes it a static export, read as text: init never runs the
|
|
37
|
+
* app's config. A static export cannot serve a route, and `next build` refuses a dynamic one.
|
|
38
|
+
*/
|
|
39
|
+
function isStaticExport(dir) {
|
|
40
|
+
return NEXT_CONFIG_NAMES.some((name) => {
|
|
41
|
+
const path = join(dir, name);
|
|
42
|
+
return existsSync(path) && STATIC_EXPORT_OUTPUT.test(readFileSync(path, "utf8"));
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/** A static export takes its values at build time, or from the server that hosts its files. */
|
|
46
|
+
function printStaticExportSteps() {
|
|
47
|
+
info(`This Next.js app is a static export (output: "export"), which cannot serve a route, so init added no ${SCRIPT_SRC} route or layout script.`);
|
|
48
|
+
plain(" A static export takes its values at build time: build it with `supatype build -- next build`.");
|
|
49
|
+
plain(` Or let Supatype hosting serve it, which answers ${SCRIPT_SRC} itself; ${scriptTag("Script")} in the root layout then loads it.`);
|
|
50
|
+
}
|
|
51
|
+
/** The script element, under whatever name the layout imports `next/script` as. */
|
|
52
|
+
function scriptTag(name) {
|
|
53
|
+
return `<${name} src="${SCRIPT_SRC}" strategy="beforeInteractive" />`;
|
|
54
|
+
}
|
|
55
|
+
/** The first of `candidates` (relative to `dir`) that exists. */
|
|
56
|
+
function firstExisting(dir, candidates) {
|
|
57
|
+
return candidates.find((rel) => existsSync(join(dir, rel)));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Serve `/supatype-env.js` from a Next.js app in `dir`, and load it in its root layout. Does
|
|
61
|
+
* nothing for an app that is not Next.js. `ssrRange` is the version range `@supatype/ssr` is added
|
|
62
|
+
* at, when the app does not list it.
|
|
63
|
+
*/
|
|
64
|
+
export function scaffoldNextRuntimeEnv(dir, write, ssrRange) {
|
|
65
|
+
if (detectFramework(dir) !== "nextjs")
|
|
66
|
+
return;
|
|
67
|
+
if (isStaticExport(dir)) {
|
|
68
|
+
printStaticExportSteps();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const appDir = firstExisting(dir, ["app", "src/app"]);
|
|
72
|
+
if (appDir === undefined) {
|
|
73
|
+
printPagesRouterSteps(firstExisting(dir, ["pages", "src/pages"]) ?? "pages");
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const routeExt = existsSync(join(dir, "tsconfig.json")) ? "ts" : "js";
|
|
77
|
+
const routeRel = `${appDir}/supatype-env.js/route.${routeExt}`;
|
|
78
|
+
if (existsSync(join(dir, routeRel)))
|
|
79
|
+
file("skipped", `${routeRel} (already exists)`);
|
|
80
|
+
else
|
|
81
|
+
write(routeRel, NEXT_RUNTIME_ENV_ROUTE);
|
|
82
|
+
addSsrDependency(dir, ssrRange);
|
|
83
|
+
loadInRootLayout(dir, appDir);
|
|
84
|
+
}
|
|
85
|
+
/** Add the script to the root layout, or say what to add when it cannot be done safely. */
|
|
86
|
+
function loadInRootLayout(dir, appDir) {
|
|
87
|
+
const layoutRel = firstExisting(dir, LAYOUT_NAMES.map((name) => `${appDir}/${name}`));
|
|
88
|
+
if (layoutRel === undefined) {
|
|
89
|
+
printLayoutLines(`${appDir}/layout.tsx`, "there is no root layout");
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const source = readFileSync(join(dir, layoutRel), "utf8");
|
|
93
|
+
if (source.includes(SCRIPT_SRC)) {
|
|
94
|
+
file("skipped", `${layoutRel} (already loads ${SCRIPT_SRC})`);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const edited = withRuntimeEnvScript(source);
|
|
98
|
+
if (edited === undefined) {
|
|
99
|
+
printLayoutLines(layoutRel, "init could not edit it safely");
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
writeFileSync(join(dir, layoutRel), edited, "utf8");
|
|
103
|
+
file("updated", `${layoutRel} (loads ${SCRIPT_SRC} before the app)`);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* `source` with the script as the first thing in its one `<body>`, importing `next/script` when it
|
|
107
|
+
* does not already. Undefined when that cannot be done without guessing: no `<body>` or more than
|
|
108
|
+
* one, a `<body>` whose attributes hold a `>`, or a `Script` that is something else.
|
|
109
|
+
*/
|
|
110
|
+
export function withRuntimeEnvScript(source) {
|
|
111
|
+
const eol = source.includes("\r\n") ? "\r\n" : "\n";
|
|
112
|
+
const text = source.replace(/\r\n/g, "\n");
|
|
113
|
+
const bodies = [...text.matchAll(/<body\b[^>]*>/g)];
|
|
114
|
+
const body = bodies[0];
|
|
115
|
+
if (bodies.length !== 1 || body === undefined || body[0].endsWith("/>") || !balancedBraces(body[0]))
|
|
116
|
+
return undefined;
|
|
117
|
+
const imported = /^import\s+([A-Za-z_$][\w$]*)\s+from\s+["']next\/script["']/m.exec(text)?.[1];
|
|
118
|
+
if (imported === undefined && /\bScript\b/.test(text))
|
|
119
|
+
return undefined;
|
|
120
|
+
const name = imported ?? "Script";
|
|
121
|
+
const end = body.index + body[0].length;
|
|
122
|
+
const tag = `\n${childIndent(text, body.index, end)}${scriptTag(name)}`;
|
|
123
|
+
const withTag = text.slice(0, end) + tag + text.slice(end);
|
|
124
|
+
const result = imported === undefined ? withImport(withTag) : withTag;
|
|
125
|
+
return result.replace(/\n/g, eol);
|
|
126
|
+
}
|
|
127
|
+
/** Whether every `{` in a tag's attributes is closed in it, so its `>` really ends the tag. */
|
|
128
|
+
function balancedBraces(tag) {
|
|
129
|
+
let depth = 0;
|
|
130
|
+
for (const ch of tag)
|
|
131
|
+
depth += ch === "{" ? 1 : ch === "}" ? -1 : 0;
|
|
132
|
+
return depth === 0;
|
|
133
|
+
}
|
|
134
|
+
/** The indentation of the line after `<body>` when deeper than its own, else its own plus two. */
|
|
135
|
+
function childIndent(text, tagStart, tagEnd) {
|
|
136
|
+
const lineStart = text.lastIndexOf("\n", tagStart) + 1;
|
|
137
|
+
const own = /^[ \t]*/.exec(text.slice(lineStart))?.[0] ?? "";
|
|
138
|
+
const next = /^\n([ \t]*)\S/.exec(text.slice(tagEnd))?.[1];
|
|
139
|
+
return next !== undefined && next.length > own.length ? next : `${own} `;
|
|
140
|
+
}
|
|
141
|
+
/** `text` importing `next/script` first, below a leading `"use client"` style directive. */
|
|
142
|
+
function withImport(text) {
|
|
143
|
+
const directive = /^(["'])use [a-z]+\1;?[ \t]*\n(\n)?/.exec(text);
|
|
144
|
+
if (directive === null)
|
|
145
|
+
return `${SCRIPT_IMPORT}\n${text}`;
|
|
146
|
+
const at = directive[0].length;
|
|
147
|
+
return `${text.slice(0, at)}${SCRIPT_IMPORT}\n${text.slice(at)}`;
|
|
148
|
+
}
|
|
149
|
+
/** The two lines to add by hand, and why init did not add them. */
|
|
150
|
+
function printLayoutLines(layoutRel, why) {
|
|
151
|
+
info(`${layoutRel} does not load ${SCRIPT_SRC} yet: ${why}. Add these two lines:`);
|
|
152
|
+
plain(` ${SCRIPT_IMPORT}`);
|
|
153
|
+
plain(` ${scriptTag("Script")} (inside <body>, before anything else)`);
|
|
154
|
+
}
|
|
155
|
+
/** A Pages Router app: what to add, since init writes nothing into it. */
|
|
156
|
+
function printPagesRouterSteps(pagesDir) {
|
|
157
|
+
info(`This Next.js app uses the Pages Router (${pagesDir}/), so init added nothing to it. To load the deployment's values when a page loads:`);
|
|
158
|
+
plain(` 1. Create app/supatype-env.js/route.ts (route handlers live in app/, beside ${pagesDir}/):`);
|
|
159
|
+
for (const line of NEXT_RUNTIME_ENV_ROUTE.trimEnd().split("\n"))
|
|
160
|
+
plain(` ${line}`);
|
|
161
|
+
plain(` 2. In ${pagesDir}/_document.tsx, import Script from "next/script" and add, inside <Head>:`);
|
|
162
|
+
plain(` ${scriptTag("Script")}`);
|
|
163
|
+
plain(` 3. Add ${SSR_PACKAGE} to the app's dependencies, and set SUPATYPE_URL and SUPATYPE_ANON_KEY where it runs.`);
|
|
164
|
+
}
|
|
165
|
+
/** List `@supatype/ssr` in the app's dependencies, which the route imports, when it is not there. */
|
|
166
|
+
function addSsrDependency(dir, range) {
|
|
167
|
+
const pkgPath = join(dir, "package.json");
|
|
168
|
+
const parsed = parseJsonObject(readFileSync(pkgPath, "utf8"));
|
|
169
|
+
if (!parsed.ok)
|
|
170
|
+
return;
|
|
171
|
+
const pkg = parsed.value;
|
|
172
|
+
const deps = isJsonObject(pkg["dependencies"]) ? pkg["dependencies"] : {};
|
|
173
|
+
const devDeps = isJsonObject(pkg["devDependencies"]) ? pkg["devDependencies"] : {};
|
|
174
|
+
if (SSR_PACKAGE in deps || SSR_PACKAGE in devDeps)
|
|
175
|
+
return;
|
|
176
|
+
pkg["dependencies"] = { ...deps, [SSR_PACKAGE]: range };
|
|
177
|
+
writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`, "utf8");
|
|
178
|
+
file("updated", `package.json (added ${SSR_PACKAGE}, which serves ${SCRIPT_SRC})`);
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=init-next-runtime-env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-next-runtime-env.js","sourceRoot":"","sources":["../src/init-next-runtime-env.ts"],"names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,OAAM;IACtB,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAA;IACxB,MAAM,IAAI,GAAG,YAAY,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IACzE,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAClF,IAAI,WAAW,IAAI,IAAI,IAAI,WAAW,IAAI,OAAO;QAAE,OAAM;IACzD,GAAG,CAAC,cAAc,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,CAAA;IACvD,aAAa,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACnE,IAAI,CAAC,SAAS,EAAE,uBAAuB,WAAW,kBAAkB,UAAU,GAAG,CAAC,CAAA;AACpF,CAAC"}
|
|
@@ -9,13 +9,50 @@ export interface MergePackageJsonOptions {
|
|
|
9
9
|
}
|
|
10
10
|
type PackageJson = {
|
|
11
11
|
name?: string;
|
|
12
|
+
version?: string;
|
|
12
13
|
private?: boolean;
|
|
13
14
|
type?: string;
|
|
14
15
|
scripts?: Record<string, string>;
|
|
15
16
|
dependencies?: Record<string, string>;
|
|
16
17
|
devDependencies?: Record<string, string>;
|
|
17
18
|
};
|
|
18
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* `supatype generate` when the CLI is installed, and nothing when it is not: a bin of
|
|
21
|
+
* `@supatype/client` (bin/supatype-prepare.js there says how it finds the CLI). The client is a
|
|
22
|
+
* production dependency, so the bin is there on a production install, where the CLI is not.
|
|
23
|
+
*
|
|
24
|
+
* It was once a script written into the project's package.json in full, which no upgrade could
|
|
25
|
+
* fix: each project kept the copy it was made with.
|
|
26
|
+
*/
|
|
27
|
+
export declare const PREPARE_COMMAND = "supatype-prepare";
|
|
28
|
+
/**
|
|
29
|
+
* The scripts every Supatype project gets, written by `init` into a new package.json and merged
|
|
30
|
+
* into an existing one, so the two cannot drift: the merge once ran `tsx seed.ts`, which loads the
|
|
31
|
+
* seed module without calling it, while new projects ran `supatype seed`.
|
|
32
|
+
*/
|
|
33
|
+
export declare const CORE_SCRIPTS: {
|
|
34
|
+
readonly dev: "supatype dev";
|
|
35
|
+
readonly push: "supatype push";
|
|
36
|
+
readonly seed: "supatype seed";
|
|
37
|
+
readonly prepare: "supatype-prepare";
|
|
38
|
+
};
|
|
39
|
+
/** The Vite major that current `@vitejs/plugin-react` requires as a peer. */
|
|
40
|
+
export declare const VITE_RANGE = "^8";
|
|
41
|
+
/** The package.json `init` writes for a new project. */
|
|
42
|
+
export declare function scaffoldPackageJson(opts: MergePackageJsonOptions, deps: InitDependencyVersions): string;
|
|
43
|
+
/**
|
|
44
|
+
* `prepare` as a Supatype project needs it: {@link PREPARE_COMMAND} in place of the one earlier
|
|
45
|
+
* releases of `init` wrote, after a `prepare` of the project's own (husky, say) that does not run
|
|
46
|
+
* either already, and on its own when there is none. A project's own `prepare` used to be kept as
|
|
47
|
+
* it was, so a fresh clone never generated the gitignored seed builder.
|
|
48
|
+
*/
|
|
49
|
+
export declare function supatypePrepare(existing: string | undefined): string;
|
|
50
|
+
/**
|
|
51
|
+
* The script among `scripts` that runs `supatype dev`: `supatype:dev` when the merge put it beside
|
|
52
|
+
* a dev script of the project's own, else `dev`.
|
|
53
|
+
*/
|
|
54
|
+
export declare function supatypeDevScript(scripts: unknown): string;
|
|
55
|
+
/** Merge Supatype deps/scripts into an existing package.json object, keeping what it already has. */
|
|
19
56
|
export declare function mergeSupatypePackageJson(pkg: PackageJson, opts: MergePackageJsonOptions, deps: InitDependencyVersions): PackageJson;
|
|
20
57
|
export {};
|
|
21
58
|
//# sourceMappingURL=init-package-json.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-package-json.d.ts","sourceRoot":"","sources":["../src/init-package-json.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init-package-json.d.ts","sourceRoot":"","sources":["../src/init-package-json.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AAE3E,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IAC1C,aAAa,EAAE,OAAO,CAAA;CACvB;AAED,KAAK,WAAW,GAAG;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACrC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACzC,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,qBAAqB,CAAA;AAEjD;;;;GAIG;AACH,eAAO,MAAM,YAAY;;;;;CAKf,CAAA;AAUV,6EAA6E;AAC7E,eAAO,MAAM,UAAU,OAAO,CAAA;AAgC9B,wDAAwD;AACxD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,sBAAsB,GAAG,MAAM,CAWvG;AAiBD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAIpE;AAMD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAG1D;AAiCD,qGAAqG;AACrG,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,uBAAuB,EAC7B,IAAI,EAAE,sBAAsB,GAC3B,WAAW,CAoBb"}
|
|
@@ -1,48 +1,159 @@
|
|
|
1
|
-
|
|
1
|
+
import semver from "semver";
|
|
2
|
+
import { isJsonObject } from "@supatype/shared";
|
|
3
|
+
/**
|
|
4
|
+
* `supatype generate` when the CLI is installed, and nothing when it is not: a bin of
|
|
5
|
+
* `@supatype/client` (bin/supatype-prepare.js there says how it finds the CLI). The client is a
|
|
6
|
+
* production dependency, so the bin is there on a production install, where the CLI is not.
|
|
7
|
+
*
|
|
8
|
+
* It was once a script written into the project's package.json in full, which no upgrade could
|
|
9
|
+
* fix: each project kept the copy it was made with.
|
|
10
|
+
*/
|
|
11
|
+
export const PREPARE_COMMAND = "supatype-prepare";
|
|
12
|
+
/**
|
|
13
|
+
* The scripts every Supatype project gets, written by `init` into a new package.json and merged
|
|
14
|
+
* into an existing one, so the two cannot drift: the merge once ran `tsx seed.ts`, which loads the
|
|
15
|
+
* seed module without calling it, while new projects ran `supatype seed`.
|
|
16
|
+
*/
|
|
17
|
+
export const CORE_SCRIPTS = {
|
|
2
18
|
dev: "supatype dev",
|
|
3
19
|
push: "supatype push",
|
|
4
|
-
seed: "
|
|
20
|
+
seed: "supatype seed",
|
|
21
|
+
prepare: PREPARE_COMMAND,
|
|
5
22
|
};
|
|
6
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Vite serves the app in development, and `build` writes the `./dist` that `app.static_dir` serves
|
|
25
|
+
* in production. Without `build` nothing ever produced `./dist`.
|
|
26
|
+
*/
|
|
27
|
+
const VITE_SCRIPTS = { vite: "vite", build: "vite build" };
|
|
28
|
+
const FUNCTIONS_SCRIPTS = { functions: "supatype functions serve" };
|
|
29
|
+
/** The Vite major that current `@vitejs/plugin-react` requires as a peer. */
|
|
30
|
+
export const VITE_RANGE = "^8";
|
|
31
|
+
/**
|
|
32
|
+
* Development-time only, so devDependencies. schema/index.ts imports @supatype/types with
|
|
33
|
+
* `import type`, which is erased at build; supatype.config.ts imports defineConfig, which only the
|
|
34
|
+
* CLI evaluates; seed.ts is run by `supatype seed`. Nothing `supatype push` or `supatype generate`
|
|
35
|
+
* writes refers to either package. The generated client imports @supatype/client at runtime, so
|
|
36
|
+
* that one is a real dependency.
|
|
37
|
+
*
|
|
38
|
+
* In dependencies they were installed by `npm install --omit=dev`, so every production install of
|
|
39
|
+
* a Supatype app pulled the CLI to support three files that never run in production.
|
|
40
|
+
*
|
|
41
|
+
* No tsx: the CLI's program runs the project's TypeScript itself. TypeScript stays for the editor
|
|
42
|
+
* and for `tsc`, and `defineConfig`'s module imports it.
|
|
43
|
+
*/
|
|
44
|
+
function toolDependencies(deps, opts) {
|
|
45
|
+
return {
|
|
46
|
+
"@supatype/cli": `^${deps.cli}`,
|
|
47
|
+
"@supatype/types": `^${deps.types}`,
|
|
48
|
+
typescript: "^5",
|
|
49
|
+
...(opts.app.viteDevUrl ? { vite: VITE_RANGE } : {}),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function projectScripts(opts) {
|
|
53
|
+
return {
|
|
54
|
+
...CORE_SCRIPTS,
|
|
55
|
+
...(opts.app.viteDevUrl ? VITE_SCRIPTS : {}),
|
|
56
|
+
...(opts.helloFunction ? FUNCTIONS_SCRIPTS : {}),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** The package.json `init` writes for a new project. */
|
|
60
|
+
export function scaffoldPackageJson(opts, deps) {
|
|
61
|
+
const pkg = {
|
|
62
|
+
name: opts.projectName,
|
|
63
|
+
version: NEW_PROJECT_VERSION,
|
|
64
|
+
private: true,
|
|
65
|
+
type: "module",
|
|
66
|
+
scripts: projectScripts(opts),
|
|
67
|
+
dependencies: { [CLIENT]: clientRange(undefined, deps.client) },
|
|
68
|
+
devDependencies: toolDependencies(deps, opts),
|
|
69
|
+
};
|
|
70
|
+
return `${JSON.stringify(pkg, null, 2)}\n`;
|
|
71
|
+
}
|
|
72
|
+
/** Each of `wanted` that none of `present` already names. */
|
|
73
|
+
function absentFrom(wanted, ...present) {
|
|
74
|
+
return Object.fromEntries(Object.entries(wanted).filter(([key]) => present.every((p) => p?.[key] === undefined)));
|
|
75
|
+
}
|
|
76
|
+
const CLIENT = "@supatype/client";
|
|
77
|
+
/** The `prepare` earlier releases of `init` wrote, which fails every production install. */
|
|
78
|
+
const EARLIER_PREPARE = "supatype generate";
|
|
79
|
+
/** The version `init` writes for a new project, or adds to an existing one that has none. */
|
|
80
|
+
const NEW_PROJECT_VERSION = "0.1.0";
|
|
81
|
+
/**
|
|
82
|
+
* `prepare` as a Supatype project needs it: {@link PREPARE_COMMAND} in place of the one earlier
|
|
83
|
+
* releases of `init` wrote, after a `prepare` of the project's own (husky, say) that does not run
|
|
84
|
+
* either already, and on its own when there is none. A project's own `prepare` used to be kept as
|
|
85
|
+
* it was, so a fresh clone never generated the gitignored seed builder.
|
|
86
|
+
*/
|
|
87
|
+
export function supatypePrepare(existing) {
|
|
88
|
+
if (existing === undefined || existing.trim() === "" || existing.trim() === EARLIER_PREPARE)
|
|
89
|
+
return PREPARE_COMMAND;
|
|
90
|
+
if (existing.includes(PREPARE_COMMAND) || existing.includes(EARLIER_PREPARE))
|
|
91
|
+
return existing;
|
|
92
|
+
return `${existing} && ${PREPARE_COMMAND}`;
|
|
93
|
+
}
|
|
94
|
+
function withPrepare(scripts) {
|
|
95
|
+
return { ...scripts, prepare: supatypePrepare(scripts?.["prepare"]) };
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The script among `scripts` that runs `supatype dev`: `supatype:dev` when the merge put it beside
|
|
99
|
+
* a dev script of the project's own, else `dev`.
|
|
100
|
+
*/
|
|
101
|
+
export function supatypeDevScript(scripts) {
|
|
102
|
+
const named = (key) => isJsonObject(scripts) && scripts[key] === CORE_SCRIPTS.dev;
|
|
103
|
+
return !named("dev") && named("supatype:dev") ? "supatype:dev" : "dev";
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The project's @supatype/client range, as `prepare` needs it: at least `floor`, the client `init`
|
|
107
|
+
* would pick, since an older one may predate `supatype-prepare`. A range whose lowest version, as
|
|
108
|
+
* npm's own `semver` reads it, is at or above the floor is kept. So is a spec that is not a range,
|
|
109
|
+
* such as `workspace:*`, a path, a git URL or a tag. Any other range has its lower end raised and
|
|
110
|
+
* keeps its upper end, so a project on a newer client than the floor is not moved down to it:
|
|
111
|
+
* `>=0.5.0` becomes `>=0.5.0 >=0.9.0`. A range with nothing left at or above the floor becomes
|
|
112
|
+
* `^floor`.
|
|
113
|
+
*/
|
|
114
|
+
function clientRange(listed, floor) {
|
|
115
|
+
if (listed === undefined)
|
|
116
|
+
return `^${floor}`;
|
|
117
|
+
if (semver.validRange(listed) === null || semver.valid(floor) === null)
|
|
118
|
+
return listed;
|
|
119
|
+
const lowest = semver.minVersion(listed);
|
|
120
|
+
if (lowest !== null && semver.gte(lowest, floor))
|
|
121
|
+
return listed;
|
|
122
|
+
const raised = listed
|
|
123
|
+
.split("||")
|
|
124
|
+
.map((alternative) => `${alternative.trim()} >=${floor}`)
|
|
125
|
+
.filter((alternative) => semver.minVersion(alternative) !== null);
|
|
126
|
+
return raised.length > 0 ? raised.join(" || ") : `^${floor}`;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* The client in `dependencies` at a range `prepare` can run with, and out of `devDependencies`: a
|
|
130
|
+
* production install leaves those out, and `supatype-prepare` with them.
|
|
131
|
+
*/
|
|
132
|
+
function withClient(pkg, floor) {
|
|
133
|
+
const { [CLIENT]: listedDev, ...devDependencies } = pkg.devDependencies ?? {};
|
|
134
|
+
const range = clientRange(pkg.dependencies?.[CLIENT] ?? listedDev, floor);
|
|
135
|
+
return { dependencies: { ...pkg.dependencies, [CLIENT]: range }, devDependencies };
|
|
136
|
+
}
|
|
137
|
+
/** Merge Supatype deps/scripts into an existing package.json object, keeping what it already has. */
|
|
7
138
|
export function mergeSupatypePackageJson(pkg, opts, deps) {
|
|
8
|
-
const
|
|
9
|
-
if (!next.name)
|
|
10
|
-
next.name = opts.projectName;
|
|
11
|
-
if (next.private === undefined)
|
|
12
|
-
next.private = true;
|
|
13
|
-
if (!next.type)
|
|
14
|
-
next.type = "module";
|
|
15
|
-
const scripts = { ...(next.scripts ?? {}) };
|
|
16
|
-
for (const [key, value] of Object.entries(CORE_SCRIPTS)) {
|
|
17
|
-
if (scripts[key] === undefined)
|
|
18
|
-
scripts[key] = value;
|
|
19
|
-
}
|
|
139
|
+
const scripts = { ...withPrepare(pkg.scripts), ...absentFrom(projectScripts(opts), pkg.scripts) };
|
|
20
140
|
if (scripts.dev !== CORE_SCRIPTS.dev && scripts["supatype:dev"] === undefined) {
|
|
21
141
|
scripts["supatype:dev"] = CORE_SCRIPTS.dev;
|
|
22
142
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const devDependencies = { ...(next.devDependencies ?? {}) };
|
|
39
|
-
if (devDependencies.tsx === undefined)
|
|
40
|
-
devDependencies.tsx = "^4.19.2";
|
|
41
|
-
if (devDependencies.typescript === undefined)
|
|
42
|
-
devDependencies.typescript = "^5";
|
|
43
|
-
if (opts.app.viteDevUrl && devDependencies.vite === undefined)
|
|
44
|
-
devDependencies.vite = "^6";
|
|
45
|
-
next.devDependencies = devDependencies;
|
|
46
|
-
return next;
|
|
143
|
+
const { dependencies, devDependencies } = withClient(pkg, deps.client);
|
|
144
|
+
return {
|
|
145
|
+
...pkg,
|
|
146
|
+
name: pkg.name || opts.projectName,
|
|
147
|
+
version: pkg.version || NEW_PROJECT_VERSION,
|
|
148
|
+
private: pkg.private ?? true,
|
|
149
|
+
type: pkg.type || "module",
|
|
150
|
+
scripts,
|
|
151
|
+
dependencies,
|
|
152
|
+
// A tool the project already lists in either section stays where it is.
|
|
153
|
+
devDependencies: {
|
|
154
|
+
...devDependencies,
|
|
155
|
+
...absentFrom(toolDependencies(deps, opts), pkg.dependencies, pkg.devDependencies),
|
|
156
|
+
},
|
|
157
|
+
};
|
|
47
158
|
}
|
|
48
159
|
//# sourceMappingURL=init-package-json.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-package-json.js","sourceRoot":"","sources":["../src/init-package-json.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init-package-json.js","sourceRoot":"","sources":["../src/init-package-json.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAmB/C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAA;AAEjD;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,GAAG,EAAE,cAAc;IACnB,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,eAAe;CAChB,CAAA;AAEV;;;GAGG;AACH,MAAM,YAAY,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAW,CAAA;AAEnE,MAAM,iBAAiB,GAAG,EAAE,SAAS,EAAE,0BAA0B,EAAW,CAAA;AAE5E,6EAA6E;AAC7E,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAA;AAE9B;;;;;;;;;;;;GAYG;AACH,SAAS,gBAAgB,CAAC,IAA4B,EAAE,IAA6B;IACnF,OAAO;QACL,eAAe,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE;QAC/B,iBAAiB,EAAE,IAAI,IAAI,CAAC,KAAK,EAAE;QACnC,UAAU,EAAE,IAAI;Q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W,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,GAAG,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,EAAE,CAAA;IACjG,IAAI,OAAO,CAAC,GAAG,KAAK,YAAY,CAAC,GAAG,IAAI,OAAO,CAAC,cAAc,CAAC,KAAK,SAAS,EAAE,CAAC;QAC9E,OAAO,CAAC,cAAc,CAAC,GAAG,YAAY,CAAC,GAAG,CAAA;IAC5C,CAAC;IACD,MAAM,EAAE,YAAY,EAAE,eAAe,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IACtE,OAAO;QACL,GAAG,GAAG;QACN,IAAI,EAAE,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC,WAAW;QAClC,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,mBAAmB;QAC3C,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,IAAI;QAC5B,IAAI,EAAE,GAAG,CAAC,IAAI,IAAI,QAAQ;QAC1B,OAAO;QACP,YAAY;QACZ,wEAAwE;QACxE,eAAe,EAAE;YACf,GAAG,eAAe;YAClB,GAAG,UAAU,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,YAAY,EAAE,GAAG,CAAC,eAAe,CAAC;SACnF;KACF,CAAA;AACH,CAAC"}
|
package/dist/jwt.d.ts
CHANGED
|
@@ -5,4 +5,9 @@ export declare function signJwt(payload: Record<string, unknown>, secret: string
|
|
|
5
5
|
*/
|
|
6
6
|
export declare function verifyJwt(token: string, secret: string): Record<string, unknown> | null;
|
|
7
7
|
export declare function base64url(str: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* The `role` claim of a token, read without checking its signature, or undefined when it is not a
|
|
10
|
+
* JWT with one. For telling a service role key from an anon key, never for trusting either.
|
|
11
|
+
*/
|
|
12
|
+
export declare function unverifiedJwtRole(token: string): string | undefined;
|
|
8
13
|
//# sourceMappingURL=jwt.d.ts.map
|
package/dist/jwt.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../src/jwt.ts"],"names":[],"mappings":"AAGA,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAOhF;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAcvF;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C"}
|
|
1
|
+
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../src/jwt.ts"],"names":[],"mappings":"AAGA,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAOhF;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAcvF;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CASnE"}
|