@runa-ai/runa-cli 0.5.72 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-BXUJKYHC.js +1730 -0
- package/dist/cache-H63JKFYH.js +112 -0
- package/dist/check-6AB5NGWK.js +207 -0
- package/dist/chunk-22CS6EMA.js +31 -0
- package/dist/chunk-3FDQW524.js +544 -0
- package/dist/chunk-5NKWR4FF.js +254 -0
- package/dist/chunk-6AALH2ED.js +121 -0
- package/dist/chunk-6Y3LAUGL.js +35 -0
- package/dist/chunk-7QV7U6NI.js +62 -0
- package/dist/chunk-AAIE4F2U.js +140 -0
- package/dist/chunk-CCKG5R4Y.js +59 -0
- package/dist/chunk-CE3DEYFT.js +480 -0
- package/dist/chunk-DRSUEMAK.js +123 -0
- package/dist/chunk-GOGRLQNP.js +12 -0
- package/dist/chunk-HD74F6W2.js +460 -0
- package/dist/chunk-HKUWEGUX.js +36 -0
- package/dist/chunk-HPYJPB5Y.js +408 -0
- package/dist/chunk-IBVVGH6X.js +33 -0
- package/dist/chunk-II7VYQEM.js +179 -0
- package/dist/chunk-JMJP4A47.js +204 -0
- package/dist/chunk-JQXOVCOP.js +574 -0
- package/dist/chunk-JT5SUTWE.js +9 -0
- package/dist/chunk-KWX3JHCY.js +85 -0
- package/dist/chunk-M47WJJVS.js +71 -0
- package/dist/chunk-MNPMZERI.js +194 -0
- package/dist/chunk-MXRWBNIY.js +74 -0
- package/dist/chunk-NPSRD26F.js +149 -0
- package/dist/chunk-P7U52PBY.js +1149 -0
- package/dist/chunk-QDF7QXBL.js +67 -0
- package/dist/chunk-RRGQCUKT.js +48 -0
- package/dist/chunk-RZLYEO4U.js +219 -0
- package/dist/chunk-TYIAD6SB.js +74 -0
- package/dist/chunk-UU55OH7P.js +42 -0
- package/dist/chunk-UWWSAPDR.js +31 -0
- package/dist/chunk-VM3IWOT5.js +458 -0
- package/dist/chunk-VRXHCR5K.js +42 -0
- package/dist/chunk-XJBQINSA.js +351 -0
- package/dist/chunk-ZZOXM6Q4.js +8 -0
- package/dist/ci-V3PIG2GI.js +8322 -0
- package/dist/cli/index.d.ts +7 -1
- package/dist/cli/requested-command.d.ts +8 -0
- package/dist/cli-GFRZCJQR.js +661 -0
- package/dist/commands/build/actors/db-sync.d.ts +2 -0
- package/dist/commands/build/actors/static-checks.d.ts +7 -6
- package/dist/commands/build/contract.d.ts +30 -30
- package/dist/commands/build/machine-dry-run.d.ts +3 -0
- package/dist/commands/build/machine-e2e-meta.d.ts +120 -0
- package/dist/commands/build/machine.d.ts +22 -22
- package/dist/commands/build/types.d.ts +2 -4
- package/dist/commands/ci/machine/contract.d.ts +26 -26
- package/dist/commands/ci/machine/formatters/sections/final-comment.d.ts +1 -5
- package/dist/commands/ci/machine/formatters/sections/format-helpers.d.ts +5 -0
- package/dist/commands/ci/machine/formatters/sections/index.d.ts +2 -2
- package/dist/commands/ci/machine/machine-execution-helpers.d.ts +40 -0
- package/dist/commands/ci/machine/machine-state-helpers.d.ts +14 -0
- package/dist/commands/ci/machine/machine.d.ts +12 -12
- package/dist/commands/ci/machine/types.d.ts +0 -5
- package/dist/commands/ci/utils/ci-summary.d.ts +15 -15
- package/dist/commands/ci/utils/execa-helpers.d.ts +1 -0
- package/dist/commands/db/apply/actors/idempotent-actors.d.ts +34 -0
- package/dist/commands/db/apply/actors/lock-actors.d.ts +16 -0
- package/dist/commands/db/apply/actors/pg-schema-diff-actors.d.ts +31 -0
- package/dist/commands/db/apply/actors/seed-actors.d.ts +11 -0
- package/dist/commands/db/apply/actors/shared.d.ts +9 -0
- package/dist/commands/db/apply/actors.d.ts +16 -65
- package/dist/commands/db/apply/contract.d.ts +8 -1
- package/dist/commands/db/apply/helpers/data-compatibility-checker.d.ts +3 -4
- package/dist/commands/db/apply/helpers/data-integrity-verifier.d.ts +37 -0
- package/dist/commands/db/apply/helpers/fresh-db-handler.d.ts +34 -0
- package/dist/commands/db/apply/helpers/hazard-handler.d.ts +60 -0
- package/dist/commands/db/apply/helpers/idempotent-object-registry.d.ts +96 -0
- package/dist/commands/db/apply/helpers/idempotent-transaction.d.ts +20 -0
- package/dist/commands/db/apply/helpers/index.d.ts +6 -0
- package/dist/commands/db/apply/helpers/partition-validator.d.ts +2 -15
- package/dist/commands/db/apply/helpers/pg-schema-diff-helpers.d.ts +18 -162
- package/dist/commands/db/apply/helpers/pg-schema-diff-patterns.d.ts +55 -0
- package/dist/commands/db/apply/helpers/pg-schema-diff-version.d.ts +50 -0
- package/dist/commands/db/apply/helpers/plan-validator.d.ts +4 -10
- package/dist/commands/db/apply/helpers/rbac-password-manager.d.ts +34 -0
- package/dist/commands/db/apply/helpers/retry-logic.d.ts +16 -2
- package/dist/commands/db/apply/helpers/shadow-db-manager.d.ts +1 -1
- package/dist/commands/db/apply/helpers/sql-utils.d.ts +26 -0
- package/dist/commands/db/apply/machine.d.ts +52 -1
- package/dist/commands/db/commands/db-apply.d.ts +18 -0
- package/dist/commands/db/commands/db-sync/boundary-classifier.d.ts +21 -0
- package/dist/commands/db/commands/db-sync/plan-hazard-analyzer.d.ts +13 -0
- package/dist/commands/db/commands/db-sync/risk-reporter.d.ts +19 -0
- package/dist/commands/db/commands/db-sync/sql-parser.d.ts +25 -0
- package/dist/commands/db/commands/db-sync/types.d.ts +47 -0
- package/dist/commands/db/commands/db-sync.d.ts +14 -0
- package/dist/commands/db/sync/contract.d.ts +6 -2
- package/dist/commands/db/sync/machine.d.ts +2 -1
- package/dist/commands/db/types.d.ts +2 -0
- package/dist/commands/db/utils/boundary-policy/rule-compiler.d.ts +11 -0
- package/dist/commands/db/utils/boundary-policy/types.d.ts +105 -0
- package/dist/commands/db/utils/boundary-policy/validation.d.ts +20 -0
- package/dist/commands/db/utils/boundary-policy-runtime.d.ts +28 -0
- package/dist/commands/db/utils/boundary-policy.d.ts +5 -0
- package/dist/commands/db/utils/idempotent-risk-context.d.ts +29 -0
- package/dist/commands/db/utils/preflight-check.d.ts +14 -0
- package/dist/commands/db/utils/preflight-checks/domain-naming-checks.d.ts +106 -0
- package/dist/commands/db/utils/preflight-checks/orphan-checks.d.ts +36 -0
- package/dist/commands/db/utils/preflight-checks/schema-risk-checks.d.ts +22 -0
- package/dist/commands/db/utils/preflight-checks/supabase-checks.d.ts +55 -0
- package/dist/commands/db/utils/risk-detector-loader.d.ts +8 -0
- package/dist/commands/db/utils/schema-precheck-budget.d.ts +17 -0
- package/dist/commands/db/utils/sql-boundary-parser.d.ts +12 -0
- package/dist/commands/db/utils/sql-file-collector.d.ts +8 -0
- package/dist/commands/db/utils/sql-filename-parser.d.ts +20 -0
- package/dist/commands/db/utils/sql-table-extractor-ast.d.ts +19 -0
- package/dist/commands/db/utils/sql-table-extractor-regex.d.ts +50 -0
- package/dist/commands/db/utils/sql-table-extractor-rls.d.ts +13 -0
- package/dist/commands/db/utils/sql-table-extractor.d.ts +79 -1
- package/dist/commands/db/utils/table-registry-introspection.d.ts +68 -0
- package/dist/commands/db/utils/table-registry.d.ts +3 -38
- package/dist/commands/dev/actors/app-lifecycle.d.ts +18 -0
- package/dist/commands/dev/actors/index.d.ts +7 -2
- package/dist/commands/dev/actors/process-check.d.ts +12 -0
- package/dist/commands/dev/actors/shared.d.ts +15 -0
- package/dist/commands/dev/contract.d.ts +2 -2
- package/dist/commands/dev/machine.d.ts +7 -31
- package/dist/commands/env/commands/env-pull/auth.d.ts +13 -0
- package/dist/commands/env/commands/env-pull/dotenv-files.d.ts +14 -0
- package/dist/commands/env/commands/env-pull/security.d.ts +12 -0
- package/dist/commands/env/commands/env-pull/service.d.ts +8 -0
- package/dist/commands/env/commands/env-pull/shared.d.ts +79 -0
- package/dist/commands/env/commands/setup/types.d.ts +1 -1
- package/dist/commands/env/constants/local-supabase.d.ts +2 -0
- package/dist/commands/template-check/contract.d.ts +6 -6
- package/dist/commands/template-check/machine.d.ts +2 -2
- package/dist/commands/template-check/types.d.ts +0 -4
- package/dist/commands/template-check/utils/diff-analyzer.d.ts +0 -4
- package/dist/config/env.d.ts +4 -4
- package/dist/config-loader-GT3HAQ7U.js +7 -0
- package/dist/db-HR7CREX2.js +15913 -0
- package/dist/dev-A7RW6XQV.js +873 -0
- package/dist/env-B47Z4747.js +2624 -0
- package/dist/env-HMMRSYCI.js +7 -0
- package/dist/env-files-K2C7O7L5.js +8 -0
- package/dist/error-handler-4EYSDOSE.js +460 -0
- package/dist/hotfix-CULKKMGS.js +1477 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +48 -42995
- package/dist/init-ELK5QCWR.js +632 -0
- package/dist/inject-test-attrs-Y5UD5P7Q.js +36 -0
- package/dist/internal/machines/snapshot-helpers.d.ts +6 -0
- package/dist/lib/sql-comment-utils.d.ts +25 -0
- package/dist/license-OB7GVJQ2.js +468 -0
- package/dist/link-C43JRZWY.js +60 -0
- package/dist/manifest-2NOQ2IMK.js +32 -0
- package/dist/prepare-32DOVHTE.js +250 -0
- package/dist/risk-detector-BXUY2WKS.js +6 -0
- package/dist/risk-detector-core-O7I7SPR7.js +166 -0
- package/dist/risk-detector-plpgsql-SGMVKYJP.js +1856 -0
- package/dist/sdk-XK6HQU7S.js +348 -0
- package/dist/services-7VK5KZTO.js +177 -0
- package/dist/session-SFW5QSXZ.js +142 -0
- package/dist/signal-handler-DO3OANW5.js +6 -0
- package/dist/status-IJ4ZWHMX.js +95 -0
- package/dist/telemetry-FN7V727Y.js +94 -0
- package/dist/template-check-PNG5NQ5H.js +1933 -0
- package/dist/test-QYXE5UVW.js +626 -0
- package/dist/test-gen-QPWOIEHU.js +89 -0
- package/dist/ui-RJAMCWUI.js +331 -0
- package/dist/upgrade-3SLWVNAC.js +625 -0
- package/dist/utils/config-loader.d.ts +0 -3
- package/dist/validate-SM4PXPS7.js +55 -0
- package/dist/validators/risk-detector-content-risks.d.ts +13 -0
- package/dist/validators/risk-detector-core.d.ts +25 -0
- package/dist/validators/risk-detector-patterns.d.ts +15 -0
- package/dist/validators/risk-detector-plpgsql-expression-resolver.d.ts +22 -0
- package/dist/validators/risk-detector-plpgsql-parser.d.ts +5 -0
- package/dist/validators/risk-detector-plpgsql-tokenizer.d.ts +18 -0
- package/dist/validators/risk-detector-plpgsql.d.ts +9 -0
- package/dist/validators/risk-detector-text-utils.d.ts +6 -0
- package/dist/validators/risk-detector-types.d.ts +16 -0
- package/dist/validators/risk-detector.d.ts +7 -26
- package/dist/vuln-check-TYQNEFS7.js +122 -0
- package/dist/vuln-checker-2QXGN5YT.js +2950 -0
- package/dist/watch-UCDVOQAH.js +911 -0
- package/dist/workflow-ZB5Q2PFY.js +898 -0
- package/package.json +4 -1
- package/dist/cli/contract-mode.d.ts.map +0 -1
- package/dist/cli/contract-output.d.ts.map +0 -1
- package/dist/cli/early-flags.d.ts.map +0 -1
- package/dist/cli/error-handler.d.ts.map +0 -1
- package/dist/cli/exec.d.ts.map +0 -1
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/json-output.d.ts.map +0 -1
- package/dist/cli/non-interactive.d.ts.map +0 -1
- package/dist/cli/output-format.d.ts.map +0 -1
- package/dist/cli/signal-handler.d.ts.map +0 -1
- package/dist/commands/build/actors/build.d.ts.map +0 -1
- package/dist/commands/build/actors/clean.d.ts.map +0 -1
- package/dist/commands/build/actors/db-sync.d.ts.map +0 -1
- package/dist/commands/build/actors/index.d.ts.map +0 -1
- package/dist/commands/build/actors/manifest.d.ts.map +0 -1
- package/dist/commands/build/actors/setup.d.ts.map +0 -1
- package/dist/commands/build/actors/static-checks.d.ts.map +0 -1
- package/dist/commands/build/actors/validate.d.ts.map +0 -1
- package/dist/commands/build/commands/build.d.ts.map +0 -1
- package/dist/commands/build/contract.d.ts.map +0 -1
- package/dist/commands/build/guards.d.ts.map +0 -1
- package/dist/commands/build/index.d.ts.map +0 -1
- package/dist/commands/build/machine.d.ts.map +0 -1
- package/dist/commands/build/types.d.ts.map +0 -1
- package/dist/commands/cache.d.ts.map +0 -1
- package/dist/commands/check/commands/check.d.ts.map +0 -1
- package/dist/commands/check/index.d.ts.map +0 -1
- package/dist/commands/ci/commands/ci-checks.d.ts.map +0 -1
- package/dist/commands/ci/commands/ci-layer-content.d.ts.map +0 -1
- package/dist/commands/ci/commands/ci-pr-capabilities.d.ts.map +0 -1
- package/dist/commands/ci/commands/ci-prod-apply.d.ts.map +0 -1
- package/dist/commands/ci/commands/ci-prod-db-operations.d.ts.map +0 -1
- package/dist/commands/ci/commands/ci-prod-github.d.ts.map +0 -1
- package/dist/commands/ci/commands/ci-prod-types.d.ts.map +0 -1
- package/dist/commands/ci/commands/ci-prod-utils.d.ts.map +0 -1
- package/dist/commands/ci/commands/ci-prod-workflow.d.ts.map +0 -1
- package/dist/commands/ci/commands/ci-resolvers.d.ts.map +0 -1
- package/dist/commands/ci/commands/ci-static.d.ts.map +0 -1
- package/dist/commands/ci/commands/ci-supabase-local.d.ts.map +0 -1
- package/dist/commands/ci/index.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/build/app-build.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/build/app-start.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/build/build-and-playwright.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/build/index.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/build/playwright-install.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/build/static-checks.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/db/apply-seeds.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/db/collect-schema-stats.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/db/index.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/db/pgtap-install.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/db/production-preview.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/db/pull-production.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/db/reset.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/db/schema-stats.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/db/setup-roles.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/db/sync-schema.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/finalize/github.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/finalize/index.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/finalize/summary.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/index.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/setup/index.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/setup/local.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/setup/pr-common.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/setup/pr-local.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/test/capabilities.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/test/index.d.ts.map +0 -1
- package/dist/commands/ci/machine/actors/test/run-layers.d.ts.map +0 -1
- package/dist/commands/ci/machine/commands/ci-local.d.ts.map +0 -1
- package/dist/commands/ci/machine/commands/ci-pr.d.ts.map +0 -1
- package/dist/commands/ci/machine/commands/index.d.ts.map +0 -1
- package/dist/commands/ci/machine/commands/machine-runner.d.ts.map +0 -1
- package/dist/commands/ci/machine/commands/runtime-env.d.ts.map +0 -1
- package/dist/commands/ci/machine/contract.d.ts.map +0 -1
- package/dist/commands/ci/machine/formatters/github-comment-types.d.ts.map +0 -1
- package/dist/commands/ci/machine/formatters/github-comment.d.ts.map +0 -1
- package/dist/commands/ci/machine/formatters/index.d.ts.map +0 -1
- package/dist/commands/ci/machine/formatters/sections/final-comment.d.ts.map +0 -1
- package/dist/commands/ci/machine/formatters/sections/format-helpers.d.ts.map +0 -1
- package/dist/commands/ci/machine/formatters/sections/index.d.ts.map +0 -1
- package/dist/commands/ci/machine/formatters/sections/progress-comment.d.ts.map +0 -1
- package/dist/commands/ci/machine/formatters/sections/schema-matrix.d.ts.map +0 -1
- package/dist/commands/ci/machine/formatters/summary.d.ts.map +0 -1
- package/dist/commands/ci/machine/guards.d.ts.map +0 -1
- package/dist/commands/ci/machine/helpers.d.ts.map +0 -1
- package/dist/commands/ci/machine/index.d.ts.map +0 -1
- package/dist/commands/ci/machine/machine.d.ts.map +0 -1
- package/dist/commands/ci/machine/types.d.ts.map +0 -1
- package/dist/commands/ci/utils/ai-report.d.ts.map +0 -1
- package/dist/commands/ci/utils/app-process.d.ts.map +0 -1
- package/dist/commands/ci/utils/app-runtime.d.ts.map +0 -1
- package/dist/commands/ci/utils/ci-config.d.ts.map +0 -1
- package/dist/commands/ci/utils/ci-env-schema.d.ts.map +0 -1
- package/dist/commands/ci/utils/ci-logging.d.ts.map +0 -1
- package/dist/commands/ci/utils/ci-summary.d.ts.map +0 -1
- package/dist/commands/ci/utils/config-readers.d.ts.map +0 -1
- package/dist/commands/ci/utils/db-url-utils.d.ts.map +0 -1
- package/dist/commands/ci/utils/e2e-auth-setup.d.ts.map +0 -1
- package/dist/commands/ci/utils/env-security.d.ts.map +0 -1
- package/dist/commands/ci/utils/execa-helpers.d.ts.map +0 -1
- package/dist/commands/ci/utils/exit-code-computation.d.ts.map +0 -1
- package/dist/commands/ci/utils/github-api.d.ts.map +0 -1
- package/dist/commands/ci/utils/github.d.ts.map +0 -1
- package/dist/commands/ci/utils/index.d.ts.map +0 -1
- package/dist/commands/ci/utils/pgtap-installer.d.ts.map +0 -1
- package/dist/commands/ci/utils/rls-verification.d.ts.map +0 -1
- package/dist/commands/ci/utils/schema-operations.d.ts.map +0 -1
- package/dist/commands/ci/utils/seed-operations.d.ts.map +0 -1
- package/dist/commands/ci/utils/test-parallel.d.ts.map +0 -1
- package/dist/commands/ci/utils/timestamp-invariants.d.ts.map +0 -1
- package/dist/commands/ci/utils/workflow-idempotency.d.ts.map +0 -1
- package/dist/commands/db/apply/actors.d.ts.map +0 -1
- package/dist/commands/db/apply/contract.d.ts.map +0 -1
- package/dist/commands/db/apply/helpers/advisory-lock.d.ts.map +0 -1
- package/dist/commands/db/apply/helpers/data-compatibility-checker.d.ts.map +0 -1
- package/dist/commands/db/apply/helpers/index.d.ts.map +0 -1
- package/dist/commands/db/apply/helpers/partition-acl-cleaner.d.ts.map +0 -1
- package/dist/commands/db/apply/helpers/partition-prefilter.d.ts.map +0 -1
- package/dist/commands/db/apply/helpers/partition-validator.d.ts.map +0 -1
- package/dist/commands/db/apply/helpers/pg-schema-diff-helpers.d.ts.map +0 -1
- package/dist/commands/db/apply/helpers/plan-validator.d.ts.map +0 -1
- package/dist/commands/db/apply/helpers/retry-logic.d.ts.map +0 -1
- package/dist/commands/db/apply/helpers/shadow-db-manager.d.ts.map +0 -1
- package/dist/commands/db/apply/index.d.ts.map +0 -1
- package/dist/commands/db/apply/machine.d.ts.map +0 -1
- package/dist/commands/db/commands/db-apply.d.ts.map +0 -1
- package/dist/commands/db/commands/db-audit.d.ts.map +0 -1
- package/dist/commands/db/commands/db-backup.d.ts.map +0 -1
- package/dist/commands/db/commands/db-cleanup.d.ts.map +0 -1
- package/dist/commands/db/commands/db-derive-role-passwords.d.ts.map +0 -1
- package/dist/commands/db/commands/db-derive-urls.d.ts.map +0 -1
- package/dist/commands/db/commands/db-diagram.d.ts.map +0 -1
- package/dist/commands/db/commands/db-drizzle.d.ts.map +0 -1
- package/dist/commands/db/commands/db-extension.d.ts.map +0 -1
- package/dist/commands/db/commands/db-generate-password.d.ts.map +0 -1
- package/dist/commands/db/commands/db-lifecycle.d.ts.map +0 -1
- package/dist/commands/db/commands/db-rollback.d.ts.map +0 -1
- package/dist/commands/db/commands/db-schema.d.ts.map +0 -1
- package/dist/commands/db/commands/db-seed-metadata.d.ts.map +0 -1
- package/dist/commands/db/commands/db-seed-verify.d.ts.map +0 -1
- package/dist/commands/db/commands/db-seed.d.ts.map +0 -1
- package/dist/commands/db/commands/db-snapshot.d.ts.map +0 -1
- package/dist/commands/db/commands/db-stack.d.ts.map +0 -1
- package/dist/commands/db/commands/db-stats.d.ts.map +0 -1
- package/dist/commands/db/commands/db-sync.d.ts.map +0 -1
- package/dist/commands/db/commands/db-test.d.ts.map +0 -1
- package/dist/commands/db/constants.d.ts.map +0 -1
- package/dist/commands/db/extension-registry.d.ts.map +0 -1
- package/dist/commands/db/index.d.ts.map +0 -1
- package/dist/commands/db/preflight/actors.d.ts.map +0 -1
- package/dist/commands/db/preflight/contract.d.ts.map +0 -1
- package/dist/commands/db/preflight/index.d.ts.map +0 -1
- package/dist/commands/db/sync/actors.d.ts.map +0 -1
- package/dist/commands/db/sync/contract.d.ts.map +0 -1
- package/dist/commands/db/sync/index.d.ts.map +0 -1
- package/dist/commands/db/sync/machine.d.ts.map +0 -1
- package/dist/commands/db/types.d.ts.map +0 -1
- package/dist/commands/db/utils/db-target.d.ts.map +0 -1
- package/dist/commands/db/utils/db-url-builder.d.ts.map +0 -1
- package/dist/commands/db/utils/error-handlers.d.ts.map +0 -1
- package/dist/commands/db/utils/import-impact-analyzer.d.ts.map +0 -1
- package/dist/commands/db/utils/preflight-check.d.ts.map +0 -1
- package/dist/commands/db/utils/psql.d.ts.map +0 -1
- package/dist/commands/db/utils/schema-detector.d.ts.map +0 -1
- package/dist/commands/db/utils/schema-sync.d.ts.map +0 -1
- package/dist/commands/db/utils/script-runner.d.ts.map +0 -1
- package/dist/commands/db/utils/seed-manager.d.ts.map +0 -1
- package/dist/commands/db/utils/semantic-mapper.d.ts.map +0 -1
- package/dist/commands/db/utils/sql-table-extractor.d.ts.map +0 -1
- package/dist/commands/db/utils/stack-detector.d.ts.map +0 -1
- package/dist/commands/db/utils/table-registry.d.ts.map +0 -1
- package/dist/commands/db/utils/table-source-classifier.d.ts.map +0 -1
- package/dist/commands/dev/actors/index.d.ts.map +0 -1
- package/dist/commands/dev/commands/dev.d.ts.map +0 -1
- package/dist/commands/dev/contract.d.ts.map +0 -1
- package/dist/commands/dev/guards.d.ts.map +0 -1
- package/dist/commands/dev/helpers/stale-process-detector.d.ts.map +0 -1
- package/dist/commands/dev/machine.d.ts.map +0 -1
- package/dist/commands/dev/types.d.ts.map +0 -1
- package/dist/commands/env/commands/env-check.d.ts.map +0 -1
- package/dist/commands/env/commands/env-encrypt.d.ts.map +0 -1
- package/dist/commands/env/commands/env-pull.d.ts.map +0 -1
- package/dist/commands/env/commands/env-setup.d.ts.map +0 -1
- package/dist/commands/env/commands/env-sync.d.ts.map +0 -1
- package/dist/commands/env/commands/setup/action.d.ts.map +0 -1
- package/dist/commands/env/commands/setup/auth.d.ts.map +0 -1
- package/dist/commands/env/commands/setup/file-export.d.ts.map +0 -1
- package/dist/commands/env/commands/setup/github-api.d.ts.map +0 -1
- package/dist/commands/env/commands/setup/helpers.d.ts.map +0 -1
- package/dist/commands/env/commands/setup/index.d.ts.map +0 -1
- package/dist/commands/env/commands/setup/parsers.d.ts.map +0 -1
- package/dist/commands/env/commands/setup/prompts.d.ts.map +0 -1
- package/dist/commands/env/commands/setup/supabase-api.d.ts.map +0 -1
- package/dist/commands/env/commands/setup/types.d.ts.map +0 -1
- package/dist/commands/env/commands/setup/vercel-api.d.ts.map +0 -1
- package/dist/commands/env/constants/local-supabase.d.ts.map +0 -1
- package/dist/commands/env/index.d.ts.map +0 -1
- package/dist/commands/hotfix/actors.d.ts.map +0 -1
- package/dist/commands/hotfix/commands/hotfix-complete.d.ts.map +0 -1
- package/dist/commands/hotfix/commands/hotfix-create.d.ts.map +0 -1
- package/dist/commands/hotfix/commands/hotfix-deploy.d.ts.map +0 -1
- package/dist/commands/hotfix/commands/hotfix-status.d.ts.map +0 -1
- package/dist/commands/hotfix/contract.d.ts.map +0 -1
- package/dist/commands/hotfix/index.d.ts.map +0 -1
- package/dist/commands/hotfix/machine.d.ts.map +0 -1
- package/dist/commands/hotfix/metadata.d.ts.map +0 -1
- package/dist/commands/hotfix/utils/hotfix-machine-helper.d.ts.map +0 -1
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/inject-test-attrs/action.d.ts.map +0 -1
- package/dist/commands/inject-test-attrs/commands/inject-test-attrs.d.ts.map +0 -1
- package/dist/commands/inject-test-attrs/contract.d.ts.map +0 -1
- package/dist/commands/inject-test-attrs/detection-diagnostics.d.ts.map +0 -1
- package/dist/commands/inject-test-attrs/formatter.d.ts.map +0 -1
- package/dist/commands/inject-test-attrs/index.d.ts.map +0 -1
- package/dist/commands/inject-test-attrs/manifest-generator.d.ts.map +0 -1
- package/dist/commands/inject-test-attrs/processor-utils.d.ts.map +0 -1
- package/dist/commands/inject-test-attrs/processor.d.ts.map +0 -1
- package/dist/commands/inject-test-attrs/types.d.ts.map +0 -1
- package/dist/commands/link.d.ts.map +0 -1
- package/dist/commands/manifest/index.d.ts.map +0 -1
- package/dist/commands/prepare/commands/prepare.d.ts.map +0 -1
- package/dist/commands/prepare/index.d.ts.map +0 -1
- package/dist/commands/sdk/commands/publish.d.ts.map +0 -1
- package/dist/commands/sdk/index.d.ts.map +0 -1
- package/dist/commands/services/index.d.ts.map +0 -1
- package/dist/commands/session/index.d.ts.map +0 -1
- package/dist/commands/status.d.ts.map +0 -1
- package/dist/commands/telemetry.d.ts.map +0 -1
- package/dist/commands/template-check/actors/compare.d.ts.map +0 -1
- package/dist/commands/template-check/actors/discover.d.ts.map +0 -1
- package/dist/commands/template-check/actors/index.d.ts.map +0 -1
- package/dist/commands/template-check/actors/report.d.ts.map +0 -1
- package/dist/commands/template-check/commands/template-check.d.ts.map +0 -1
- package/dist/commands/template-check/config.d.ts.map +0 -1
- package/dist/commands/template-check/contract.d.ts.map +0 -1
- package/dist/commands/template-check/index.d.ts.map +0 -1
- package/dist/commands/template-check/machine.d.ts.map +0 -1
- package/dist/commands/template-check/types.d.ts.map +0 -1
- package/dist/commands/template-check/utils/diff-analyzer.d.ts.map +0 -1
- package/dist/commands/template-check/utils/normalizer.d.ts.map +0 -1
- package/dist/commands/template-check/utils/path-mapping.d.ts.map +0 -1
- package/dist/commands/test/commands/test-db.d.ts.map +0 -1
- package/dist/commands/test/commands/test-e2e.d.ts.map +0 -1
- package/dist/commands/test/commands/test-fast.d.ts.map +0 -1
- package/dist/commands/test/commands/test-integration.d.ts.map +0 -1
- package/dist/commands/test/commands/test-layer.d.ts.map +0 -1
- package/dist/commands/test/commands/test-owasp-generate.d.ts.map +0 -1
- package/dist/commands/test/commands/test-service.d.ts.map +0 -1
- package/dist/commands/test/commands/test-static.d.ts.map +0 -1
- package/dist/commands/test/commands/test.d.ts.map +0 -1
- package/dist/commands/test/index.d.ts.map +0 -1
- package/dist/commands/test-gen.d.ts.map +0 -1
- package/dist/commands/ui.d.ts.map +0 -1
- package/dist/commands/upgrade.d.ts.map +0 -1
- package/dist/commands/validate.d.ts.map +0 -1
- package/dist/commands/vuln-check.d.ts.map +0 -1
- package/dist/commands/watch.d.ts.map +0 -1
- package/dist/commands/workflow/commands/deploy-production.d.ts.map +0 -1
- package/dist/commands/workflow/commands/final-status.d.ts.map +0 -1
- package/dist/commands/workflow/commands/log.d.ts.map +0 -1
- package/dist/commands/workflow/commands/notify.d.ts.map +0 -1
- package/dist/commands/workflow/commands/paths.d.ts.map +0 -1
- package/dist/commands/workflow/commands/sync.d.ts.map +0 -1
- package/dist/commands/workflow/commands/validate.d.ts.map +0 -1
- package/dist/commands/workflow/commands/verify-credentials.d.ts.map +0 -1
- package/dist/commands/workflow/index.d.ts.map +0 -1
- package/dist/commands/workflow/types.d.ts.map +0 -1
- package/dist/config/env-files.d.ts.map +0 -1
- package/dist/config/env.d.ts.map +0 -1
- package/dist/constants/versions.d.ts.map +0 -1
- package/dist/contracts/envelope.d.ts.map +0 -1
- package/dist/errors/catalog.d.ts.map +0 -1
- package/dist/errors/exit-codes.d.ts.map +0 -1
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/incremental/affected-tests.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/internal/machines/index.d.ts.map +0 -1
- package/dist/internal/machines/machine-runner.d.ts.map +0 -1
- package/dist/internal/machines/snapshot-helpers.d.ts.map +0 -1
- package/dist/internal/machines/types.d.ts.map +0 -1
- package/dist/internal/vuln-checker/analyzers/dependency-analyzer.d.ts.map +0 -1
- package/dist/internal/vuln-checker/analyzers/rls-analyzer.d.ts.map +0 -1
- package/dist/internal/vuln-checker/analyzers/secret-analyzer.d.ts.map +0 -1
- package/dist/internal/vuln-checker/analyzers/typescript-analyzer.d.ts.map +0 -1
- package/dist/internal/vuln-checker/config/loader.d.ts.map +0 -1
- package/dist/internal/vuln-checker/constants.d.ts.map +0 -1
- package/dist/internal/vuln-checker/ignore/matcher.d.ts.map +0 -1
- package/dist/internal/vuln-checker/index.d.ts.map +0 -1
- package/dist/internal/vuln-checker/reporters/console-reporter.d.ts.map +0 -1
- package/dist/internal/vuln-checker/reporters/json-reporter.d.ts.map +0 -1
- package/dist/internal/vuln-checker/reporters/markdown-reporter.d.ts.map +0 -1
- package/dist/internal/vuln-checker/reporters/sarif-reporter.d.ts.map +0 -1
- package/dist/internal/vuln-checker/security/path-validation.d.ts.map +0 -1
- package/dist/internal/vuln-checker/types.d.ts.map +0 -1
- package/dist/notifiers/desktop-notifier.d.ts.map +0 -1
- package/dist/ui/components/db-panel.d.ts.map +0 -1
- package/dist/ui/components/status-bar.d.ts.map +0 -1
- package/dist/ui/components/test-panel.d.ts.map +0 -1
- package/dist/ui/dashboard.d.ts.map +0 -1
- package/dist/ui/index.d.ts.map +0 -1
- package/dist/utils/config-loader.d.ts.map +0 -1
- package/dist/utils/config-updater.d.ts.map +0 -1
- package/dist/utils/diagnostics.d.ts.map +0 -1
- package/dist/utils/dotenvx.d.ts.map +0 -1
- package/dist/utils/env-local-bridge.d.ts.map +0 -1
- package/dist/utils/execution-plan.d.ts.map +0 -1
- package/dist/utils/github-output-security.d.ts.map +0 -1
- package/dist/utils/help-system.d.ts.map +0 -1
- package/dist/utils/license/admin-auth.d.ts.map +0 -1
- package/dist/utils/license/allowlist-checker.d.ts.map +0 -1
- package/dist/utils/license/ci-detector.d.ts.map +0 -1
- package/dist/utils/license/index.d.ts.map +0 -1
- package/dist/utils/license/owner-resolver.d.ts.map +0 -1
- package/dist/utils/license/types.d.ts.map +0 -1
- package/dist/utils/license/validate-owner.d.ts.map +0 -1
- package/dist/utils/path-security.d.ts.map +0 -1
- package/dist/utils/port-allocator.d.ts.map +0 -1
- package/dist/utils/secure-exec.d.ts.map +0 -1
- package/dist/utils/template-fetcher.d.ts.map +0 -1
- package/dist/utils/type-guards.d.ts.map +0 -1
- package/dist/utils/vercel-project.d.ts.map +0 -1
- package/dist/utils/workspace-detector.d.ts.map +0 -1
- package/dist/validators/risk-detector.d.ts.map +0 -1
- package/dist/validators/schema-validator.d.ts.map +0 -1
- package/dist/version.d.ts.map +0 -1
- package/dist/watchers/schema-watcher.d.ts.map +0 -1
- package/dist/watchers/test-watcher.d.ts.map +0 -1
|
@@ -0,0 +1,873 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
import { startAppBackground, waitForAppReady, detectApp } from './chunk-HD74F6W2.js';
|
|
4
|
+
import { writeEnvLocalBridge } from './chunk-M47WJJVS.js';
|
|
5
|
+
import { supabaseStartActor, envCheckActor, depsInstallActor, detectDatabase } from './chunk-HPYJPB5Y.js';
|
|
6
|
+
import { init_local_supabase, detectLocalSupabasePorts } from './chunk-VM3IWOT5.js';
|
|
7
|
+
import { secureExeca } from './chunk-RZLYEO4U.js';
|
|
8
|
+
import { emitJsonSuccess } from './chunk-UU55OH7P.js';
|
|
9
|
+
import './chunk-RRGQCUKT.js';
|
|
10
|
+
import './chunk-JT5SUTWE.js';
|
|
11
|
+
import './chunk-HKUWEGUX.js';
|
|
12
|
+
import { init_esm_shims } from './chunk-VRXHCR5K.js';
|
|
13
|
+
import { createCLILogger, CLIError } from '@runa-ai/runa';
|
|
14
|
+
import { Command } from 'commander';
|
|
15
|
+
import { fromPromise, setup, assign, createActor } from 'xstate';
|
|
16
|
+
import { existsSync, rmSync, readFileSync, unlinkSync } from 'fs';
|
|
17
|
+
import path4 from 'path';
|
|
18
|
+
import { z } from 'zod';
|
|
19
|
+
import net from 'net';
|
|
20
|
+
import { mkdir } from 'fs/promises';
|
|
21
|
+
|
|
22
|
+
createRequire(import.meta.url);
|
|
23
|
+
|
|
24
|
+
// src/commands/dev/commands/dev.ts
|
|
25
|
+
init_esm_shims();
|
|
26
|
+
|
|
27
|
+
// src/commands/dev/contract.ts
|
|
28
|
+
init_esm_shims();
|
|
29
|
+
var DevInputSchema = z.object({
|
|
30
|
+
/** Port for Next.js dev server (default: 3000) */
|
|
31
|
+
port: z.number().int().positive().default(3e3),
|
|
32
|
+
/** Skip Supabase start */
|
|
33
|
+
skipDb: z.boolean().default(false),
|
|
34
|
+
/** Skip app start (Supabase only) */
|
|
35
|
+
skipApp: z.boolean().default(false),
|
|
36
|
+
/** Show detailed output */
|
|
37
|
+
verbose: z.boolean().default(false),
|
|
38
|
+
/** Stream app output to terminal (in addition to log file). Default: true */
|
|
39
|
+
stream: z.boolean().default(true),
|
|
40
|
+
/** Target directory (defaults to cwd) */
|
|
41
|
+
targetDir: z.string().optional(),
|
|
42
|
+
/** Replace existing runa dev process if already running */
|
|
43
|
+
replace: z.boolean().default(false),
|
|
44
|
+
/** Bundler to use for Next.js dev server */
|
|
45
|
+
bundler: z.enum(["turbopack", "webpack"]).optional()
|
|
46
|
+
}).strict();
|
|
47
|
+
z.enum(["pending", "running", "passed", "failed", "skipped"]);
|
|
48
|
+
var DevOutputSchema = z.object({
|
|
49
|
+
/** Overall success status */
|
|
50
|
+
success: z.boolean(),
|
|
51
|
+
/** Exit code: 0 = success, 1 = failure */
|
|
52
|
+
exitCode: z.union([z.literal(0), z.literal(1)]),
|
|
53
|
+
/** App PID if started */
|
|
54
|
+
appPid: z.number().optional(),
|
|
55
|
+
/** Supabase status */
|
|
56
|
+
supabaseStarted: z.boolean().optional(),
|
|
57
|
+
/** Error message if failed */
|
|
58
|
+
error: z.string().optional()
|
|
59
|
+
}).strict();
|
|
60
|
+
|
|
61
|
+
// src/commands/dev/commands/dev.ts
|
|
62
|
+
init_local_supabase();
|
|
63
|
+
|
|
64
|
+
// src/commands/dev/machine.ts
|
|
65
|
+
init_esm_shims();
|
|
66
|
+
|
|
67
|
+
// src/commands/dev/actors/index.ts
|
|
68
|
+
init_esm_shims();
|
|
69
|
+
|
|
70
|
+
// src/commands/dev/actors/process-check.ts
|
|
71
|
+
init_esm_shims();
|
|
72
|
+
|
|
73
|
+
// src/commands/ci/utils/app-process.ts
|
|
74
|
+
init_esm_shims();
|
|
75
|
+
function killProcessGroup(pid) {
|
|
76
|
+
try {
|
|
77
|
+
process.kill(-pid, "SIGTERM");
|
|
78
|
+
} catch {
|
|
79
|
+
process.kill(pid, "SIGTERM");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function forceKillProcessGroup(pid) {
|
|
83
|
+
try {
|
|
84
|
+
process.kill(-pid, "SIGKILL");
|
|
85
|
+
} catch {
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
process.kill(pid, "SIGKILL");
|
|
89
|
+
} catch {
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
async function terminateAppProcessByPid(params) {
|
|
93
|
+
const { pid, logger } = params;
|
|
94
|
+
if (!Number.isFinite(pid) || pid <= 0) {
|
|
95
|
+
logger.warn(`Invalid PID: ${pid}`);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
logger.info(`Terminating app process group (pid=${pid})`);
|
|
99
|
+
killProcessGroup(pid);
|
|
100
|
+
await new Promise((r) => setTimeout(r, 1e3));
|
|
101
|
+
forceKillProcessGroup(pid);
|
|
102
|
+
logger.info("App process terminated");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src/commands/dev/helpers/stale-process-detector.ts
|
|
106
|
+
init_esm_shims();
|
|
107
|
+
var SAFE_TO_KILL_NAMES = ["node", "next-server", "next-router-worker", "tsx", "ts-node"];
|
|
108
|
+
async function findProcessOnPort(port) {
|
|
109
|
+
try {
|
|
110
|
+
const result = await secureExeca("lsof", ["-i", `:${port}`, "-sTCP:LISTEN", "-P", "-n"], {
|
|
111
|
+
reject: false
|
|
112
|
+
});
|
|
113
|
+
const stdout = String(result.stdout ?? "");
|
|
114
|
+
if (result.exitCode !== 0 || !stdout) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
const lines = stdout.trim().split("\n");
|
|
118
|
+
if (lines.length < 2) return null;
|
|
119
|
+
const dataLine = lines[1];
|
|
120
|
+
const parts = dataLine.split(/\s+/);
|
|
121
|
+
if (parts.length < 2) return null;
|
|
122
|
+
const name = parts[0];
|
|
123
|
+
const pid = parseInt(parts[1], 10);
|
|
124
|
+
if (Number.isNaN(pid) || pid <= 0) return null;
|
|
125
|
+
let command = "";
|
|
126
|
+
try {
|
|
127
|
+
const psResult = await secureExeca("lsof", ["-p", `${pid}`, "-Fn"], { reject: false });
|
|
128
|
+
command = String(psResult.stdout ?? "");
|
|
129
|
+
} catch {
|
|
130
|
+
}
|
|
131
|
+
return { pid, name, command };
|
|
132
|
+
} catch {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function isNodeOrNextProcess(name, command) {
|
|
137
|
+
const lowerName = name.toLowerCase();
|
|
138
|
+
if (!SAFE_TO_KILL_NAMES.some((safe) => lowerName === safe)) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
if (lowerName === "node") {
|
|
142
|
+
return command.toLowerCase().includes("next");
|
|
143
|
+
}
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
async function isServerHealthy(port) {
|
|
147
|
+
try {
|
|
148
|
+
const controller = new AbortController();
|
|
149
|
+
const timeout = setTimeout(() => controller.abort(), 2e3);
|
|
150
|
+
const response = await fetch(`http://localhost:${port}/`, {
|
|
151
|
+
signal: controller.signal,
|
|
152
|
+
method: "GET"
|
|
153
|
+
});
|
|
154
|
+
clearTimeout(timeout);
|
|
155
|
+
return response.status > 0;
|
|
156
|
+
} catch {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
async function detectAndRecoverStaleProcess(port, logger) {
|
|
161
|
+
const processInfo = await findProcessOnPort(port);
|
|
162
|
+
if (!processInfo) {
|
|
163
|
+
return { status: "port-free" };
|
|
164
|
+
}
|
|
165
|
+
const { pid, name, command } = processInfo;
|
|
166
|
+
logger.info(`Found process on port ${port}: ${name} (PID: ${pid})`);
|
|
167
|
+
if (!isNodeOrNextProcess(name, command)) {
|
|
168
|
+
return { status: "foreign-process", pid, name };
|
|
169
|
+
}
|
|
170
|
+
const healthy = await isServerHealthy(port);
|
|
171
|
+
if (healthy) {
|
|
172
|
+
return { status: "healthy-running", pid, name };
|
|
173
|
+
}
|
|
174
|
+
logger.info(`Stale process detected (${name}, PID: ${pid}). Recovering...`);
|
|
175
|
+
try {
|
|
176
|
+
await terminateAppProcessByPid({ pid, logger });
|
|
177
|
+
logger.info(`Stale process terminated (PID: ${pid})`);
|
|
178
|
+
return { status: "stale-killed", pid, name };
|
|
179
|
+
} catch (error) {
|
|
180
|
+
return {
|
|
181
|
+
status: "detection-failed",
|
|
182
|
+
reason: `Failed to terminate PID ${pid}: ${error instanceof Error ? error.message : String(error)}`
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// src/commands/dev/actors/shared.ts
|
|
188
|
+
init_esm_shims();
|
|
189
|
+
var consoleLogger = {
|
|
190
|
+
info: console.log,
|
|
191
|
+
warn: console.warn
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
// src/commands/dev/actors/process-check.ts
|
|
195
|
+
function isProcessAlive(pid) {
|
|
196
|
+
try {
|
|
197
|
+
process.kill(pid, 0);
|
|
198
|
+
return true;
|
|
199
|
+
} catch {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
function checkPortAvailable(port) {
|
|
204
|
+
return new Promise((resolve, reject) => {
|
|
205
|
+
const server = net.createServer();
|
|
206
|
+
server.once("error", (err) => {
|
|
207
|
+
if (err.code === "EADDRINUSE") {
|
|
208
|
+
reject(
|
|
209
|
+
new Error(
|
|
210
|
+
`Port ${port} is already in use. Use --port <number> to specify a different port, or --replace to restart.`
|
|
211
|
+
)
|
|
212
|
+
);
|
|
213
|
+
} else {
|
|
214
|
+
reject(err);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
server.once("listening", () => {
|
|
218
|
+
server.close(() => resolve());
|
|
219
|
+
});
|
|
220
|
+
server.listen(port, "127.0.0.1");
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
function readPidFileContent(pidFile) {
|
|
224
|
+
try {
|
|
225
|
+
return readFileSync(pidFile, "utf-8").trim();
|
|
226
|
+
} catch {
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
function parsePid(content) {
|
|
231
|
+
const pid = Number.parseInt(content, 10);
|
|
232
|
+
return Number.isNaN(pid) ? null : pid;
|
|
233
|
+
}
|
|
234
|
+
async function stopExistingProcess(pid, replace) {
|
|
235
|
+
if (!isProcessAlive(pid)) return;
|
|
236
|
+
if (!replace) {
|
|
237
|
+
throw new Error(
|
|
238
|
+
`runa dev is already running (PID: ${pid}). Use --replace to restart, or stop the existing process first.`
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
await terminateAppProcessByPid({
|
|
242
|
+
pid,
|
|
243
|
+
logger: consoleLogger
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
function cleanupPidFile(pidFile) {
|
|
247
|
+
try {
|
|
248
|
+
unlinkSync(pidFile);
|
|
249
|
+
} catch {
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
async function handlePidFile(pidFile, replace) {
|
|
253
|
+
const pidFileContent = readPidFileContent(pidFile);
|
|
254
|
+
if (!pidFileContent) return;
|
|
255
|
+
const pid = parsePid(pidFileContent);
|
|
256
|
+
if (pid !== null) {
|
|
257
|
+
await stopExistingProcess(pid, replace);
|
|
258
|
+
}
|
|
259
|
+
cleanupPidFile(pidFile);
|
|
260
|
+
}
|
|
261
|
+
function isPortInUseError(portError) {
|
|
262
|
+
return portError instanceof Error && portError.message.includes("already in use");
|
|
263
|
+
}
|
|
264
|
+
async function waitForPortRelease(port) {
|
|
265
|
+
for (let attempt = 0; attempt < 5; attempt++) {
|
|
266
|
+
try {
|
|
267
|
+
await checkPortAvailable(port);
|
|
268
|
+
return;
|
|
269
|
+
} catch {
|
|
270
|
+
if (attempt === 4) {
|
|
271
|
+
throw new Error(`Port ${port} still in use after killing stale process`);
|
|
272
|
+
}
|
|
273
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
function createPortRecoveryError(result, port) {
|
|
278
|
+
if (result.status === "healthy-running") {
|
|
279
|
+
return new Error(
|
|
280
|
+
`Port ${port} is in use by a running server (${result.name}, PID: ${result.pid}). Use --port <number> or --replace to restart.`
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
return new Error(
|
|
284
|
+
`Port ${port} is in use by ${result.name} (PID: ${result.pid}). Stop it manually before running runa dev.`
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
async function recoverPortConflict(port, portError) {
|
|
288
|
+
if (!isPortInUseError(portError)) {
|
|
289
|
+
throw portError;
|
|
290
|
+
}
|
|
291
|
+
const result = await detectAndRecoverStaleProcess(port, consoleLogger);
|
|
292
|
+
if (result.status === "port-free") {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
if (result.status === "stale-killed") {
|
|
296
|
+
await waitForPortRelease(port);
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
if (result.status === "detection-failed") {
|
|
300
|
+
throw portError;
|
|
301
|
+
}
|
|
302
|
+
throw createPortRecoveryError(result, port);
|
|
303
|
+
}
|
|
304
|
+
var processCheckActor = fromPromise(
|
|
305
|
+
async ({ input }) => {
|
|
306
|
+
const pidFile = path4.join(input.repoRoot, input.tmpDir, "app.pid");
|
|
307
|
+
let staleProcessRecovered = false;
|
|
308
|
+
await handlePidFile(pidFile, input.replace);
|
|
309
|
+
if (!input.skipApp) {
|
|
310
|
+
try {
|
|
311
|
+
await checkPortAvailable(input.port);
|
|
312
|
+
} catch (portError) {
|
|
313
|
+
staleProcessRecovered = await recoverPortConflict(input.port, portError);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return { staleProcessRecovered };
|
|
317
|
+
}
|
|
318
|
+
);
|
|
319
|
+
|
|
320
|
+
// src/commands/dev/actors/app-lifecycle.ts
|
|
321
|
+
init_esm_shims();
|
|
322
|
+
var appStartActor = fromPromise(
|
|
323
|
+
async ({ input }) => {
|
|
324
|
+
const { repoRoot, appDir, port, tmpDir, stream, bundler } = input;
|
|
325
|
+
const fullTmpDir = path4.join(repoRoot, tmpDir);
|
|
326
|
+
await mkdir(fullTmpDir, { recursive: true });
|
|
327
|
+
const nextDir = path4.join(appDir, ".next");
|
|
328
|
+
if (existsSync(nextDir)) {
|
|
329
|
+
rmSync(nextDir, { recursive: true, force: true });
|
|
330
|
+
console.log("[runa dev] Cleaned .next cache for fresh start");
|
|
331
|
+
}
|
|
332
|
+
const result = await startAppBackground({
|
|
333
|
+
repoRoot,
|
|
334
|
+
appDir,
|
|
335
|
+
port,
|
|
336
|
+
env: process.env,
|
|
337
|
+
tmpDir: fullTmpDir,
|
|
338
|
+
mode: "dev",
|
|
339
|
+
stream,
|
|
340
|
+
bundler
|
|
341
|
+
});
|
|
342
|
+
await waitForAppReady({
|
|
343
|
+
port,
|
|
344
|
+
timeoutSeconds: 120,
|
|
345
|
+
tmpDir: fullTmpDir
|
|
346
|
+
});
|
|
347
|
+
return result;
|
|
348
|
+
}
|
|
349
|
+
);
|
|
350
|
+
var shutdownActor = fromPromise(
|
|
351
|
+
async ({ input }) => {
|
|
352
|
+
const { pid } = input;
|
|
353
|
+
if (pid > 0) {
|
|
354
|
+
await terminateAppProcessByPid({
|
|
355
|
+
pid,
|
|
356
|
+
logger: consoleLogger
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
);
|
|
361
|
+
|
|
362
|
+
// src/commands/dev/guards.ts
|
|
363
|
+
init_esm_shims();
|
|
364
|
+
function shouldSkipDb({ context }) {
|
|
365
|
+
return context.input.skipDb || !context.hasDatabase;
|
|
366
|
+
}
|
|
367
|
+
function shouldSkipApp({ context }) {
|
|
368
|
+
return context.input.skipApp;
|
|
369
|
+
}
|
|
370
|
+
var guards = {
|
|
371
|
+
shouldSkipDb,
|
|
372
|
+
shouldSkipApp
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
// src/commands/dev/types.ts
|
|
376
|
+
init_esm_shims();
|
|
377
|
+
function createOutput(context) {
|
|
378
|
+
return {
|
|
379
|
+
success: context.error === null,
|
|
380
|
+
exitCode: context.error ? 1 : 0,
|
|
381
|
+
appPid: context.appPid ?? void 0,
|
|
382
|
+
supabaseStarted: context.supabaseStarted,
|
|
383
|
+
error: context.error ?? void 0
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// src/commands/dev/machine.ts
|
|
388
|
+
var e2eMeta = {
|
|
389
|
+
idle: {
|
|
390
|
+
description: "Waiting for START event to begin dev workflow",
|
|
391
|
+
severity: "non-critical",
|
|
392
|
+
observables: {
|
|
393
|
+
log: "Starting dev"
|
|
394
|
+
},
|
|
395
|
+
assertions: ["expect(log).toContain('Starting dev')", "expect(state).toBe('idle')"],
|
|
396
|
+
nextStates: ["processCheck"]
|
|
397
|
+
},
|
|
398
|
+
processCheck: {
|
|
399
|
+
description: "Check for existing runa dev process and port availability",
|
|
400
|
+
severity: "blocking",
|
|
401
|
+
observables: {
|
|
402
|
+
log: "Checking for existing processes"
|
|
403
|
+
},
|
|
404
|
+
assertions: ["expect(log).toContain('Checking for existing processes')"],
|
|
405
|
+
nextStates: ["setup", "failed"]
|
|
406
|
+
},
|
|
407
|
+
setup: {
|
|
408
|
+
description: "Setup phase: deps, env, Supabase",
|
|
409
|
+
severity: "blocking",
|
|
410
|
+
observables: {
|
|
411
|
+
log: "Setup"
|
|
412
|
+
},
|
|
413
|
+
assertions: ["expect(log).toContain('Setup')"],
|
|
414
|
+
nextStates: ["appStart", "running", "failed"]
|
|
415
|
+
},
|
|
416
|
+
appStart: {
|
|
417
|
+
description: "Start Next.js dev server",
|
|
418
|
+
severity: "blocking",
|
|
419
|
+
observables: {
|
|
420
|
+
log: "Starting app",
|
|
421
|
+
process: "Next.js dev server process started"
|
|
422
|
+
},
|
|
423
|
+
assertions: ["expect(log).toContain('Starting app')", "expect(ctx.appPid).toBeGreaterThan(0)"],
|
|
424
|
+
nextStates: ["running", "failed"]
|
|
425
|
+
},
|
|
426
|
+
running: {
|
|
427
|
+
description: "Dev server running until STOP signal",
|
|
428
|
+
severity: "non-critical",
|
|
429
|
+
observables: {
|
|
430
|
+
log: "Dev server running",
|
|
431
|
+
http: "http://localhost:3000 responding"
|
|
432
|
+
},
|
|
433
|
+
assertions: ["expect(log).toContain('Dev server running')"],
|
|
434
|
+
nextStates: ["shutdown"]
|
|
435
|
+
},
|
|
436
|
+
shutdown: {
|
|
437
|
+
description: "Gracefully shutdown dev server",
|
|
438
|
+
severity: "blocking",
|
|
439
|
+
observables: {
|
|
440
|
+
log: "Shutting down",
|
|
441
|
+
process: "Dev server process terminated"
|
|
442
|
+
},
|
|
443
|
+
assertions: ["expect(log).toContain('Shutting down')"],
|
|
444
|
+
nextStates: ["done"]
|
|
445
|
+
},
|
|
446
|
+
done: {
|
|
447
|
+
description: "Dev workflow completed successfully",
|
|
448
|
+
severity: "final",
|
|
449
|
+
observables: {
|
|
450
|
+
exit: 0
|
|
451
|
+
},
|
|
452
|
+
assertions: ["expect(exitCode).toBe(0)"],
|
|
453
|
+
nextStates: []
|
|
454
|
+
},
|
|
455
|
+
failed: {
|
|
456
|
+
description: "Dev workflow failed with error",
|
|
457
|
+
severity: "final",
|
|
458
|
+
observables: {
|
|
459
|
+
exit: 1
|
|
460
|
+
},
|
|
461
|
+
assertions: ["expect(exitCode).toBe(1)"],
|
|
462
|
+
nextStates: []
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
function normalizeDevMachineInput(input) {
|
|
466
|
+
const normalizedInput = DevInputSchema.parse(input?.input ?? {});
|
|
467
|
+
const repoRoot = input?.repoRoot ?? normalizedInput.targetDir ?? process.cwd();
|
|
468
|
+
return {
|
|
469
|
+
input: normalizedInput,
|
|
470
|
+
repoRoot
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
var devMachine = setup({
|
|
474
|
+
types: {},
|
|
475
|
+
actors: {
|
|
476
|
+
processCheck: processCheckActor,
|
|
477
|
+
depsInstall: depsInstallActor,
|
|
478
|
+
envCheck: envCheckActor,
|
|
479
|
+
supabaseStart: supabaseStartActor,
|
|
480
|
+
appStart: appStartActor,
|
|
481
|
+
shutdown: shutdownActor
|
|
482
|
+
},
|
|
483
|
+
guards: {
|
|
484
|
+
shouldSkipDb: guards.shouldSkipDb,
|
|
485
|
+
shouldSkipApp: guards.shouldSkipApp
|
|
486
|
+
}
|
|
487
|
+
}).createMachine({
|
|
488
|
+
id: "dev",
|
|
489
|
+
initial: "idle",
|
|
490
|
+
context: ({ input }) => {
|
|
491
|
+
const normalizedInput = normalizeDevMachineInput(input);
|
|
492
|
+
const repoRoot = normalizedInput.repoRoot;
|
|
493
|
+
return {
|
|
494
|
+
input: normalizedInput.input,
|
|
495
|
+
repoRoot,
|
|
496
|
+
tmpDir: ".runa/tmp/dev",
|
|
497
|
+
hasDatabase: detectDatabase(repoRoot),
|
|
498
|
+
appPid: null,
|
|
499
|
+
supabaseStarted: false,
|
|
500
|
+
staleProcessRecovered: false,
|
|
501
|
+
startTime: Date.now(),
|
|
502
|
+
error: null
|
|
503
|
+
};
|
|
504
|
+
},
|
|
505
|
+
states: {
|
|
506
|
+
// ============================================================
|
|
507
|
+
// Idle State
|
|
508
|
+
// ============================================================
|
|
509
|
+
idle: {
|
|
510
|
+
meta: { e2e: e2eMeta.idle },
|
|
511
|
+
on: {
|
|
512
|
+
START: { target: "processCheck" }
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
// ============================================================
|
|
516
|
+
// Process Check Phase
|
|
517
|
+
// ============================================================
|
|
518
|
+
processCheck: {
|
|
519
|
+
meta: { e2e: e2eMeta.processCheck },
|
|
520
|
+
invoke: {
|
|
521
|
+
src: "processCheck",
|
|
522
|
+
input: ({ context }) => ({
|
|
523
|
+
repoRoot: context.repoRoot,
|
|
524
|
+
tmpDir: context.tmpDir,
|
|
525
|
+
port: context.input.port,
|
|
526
|
+
replace: context.input.replace,
|
|
527
|
+
skipApp: context.input.skipApp
|
|
528
|
+
}),
|
|
529
|
+
onDone: {
|
|
530
|
+
target: "setup",
|
|
531
|
+
actions: assign({
|
|
532
|
+
staleProcessRecovered: ({ event }) => {
|
|
533
|
+
const output = event.output;
|
|
534
|
+
return output?.staleProcessRecovered ?? false;
|
|
535
|
+
}
|
|
536
|
+
})
|
|
537
|
+
},
|
|
538
|
+
onError: {
|
|
539
|
+
target: "failed",
|
|
540
|
+
actions: assign({
|
|
541
|
+
error: ({ event }) => event.error instanceof Error ? event.error.message : String(event.error)
|
|
542
|
+
})
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
},
|
|
546
|
+
// ============================================================
|
|
547
|
+
// Setup Phase
|
|
548
|
+
// ============================================================
|
|
549
|
+
setup: {
|
|
550
|
+
meta: { e2e: e2eMeta.setup },
|
|
551
|
+
initial: "depsInstall",
|
|
552
|
+
states: {
|
|
553
|
+
depsInstall: {
|
|
554
|
+
invoke: {
|
|
555
|
+
src: "depsInstall",
|
|
556
|
+
input: ({ context }) => ({
|
|
557
|
+
repoRoot: context.repoRoot,
|
|
558
|
+
verbose: context.input.verbose
|
|
559
|
+
}),
|
|
560
|
+
onDone: { target: "envCheck" },
|
|
561
|
+
onError: {
|
|
562
|
+
target: "#dev.failed",
|
|
563
|
+
actions: assign({
|
|
564
|
+
error: ({ event }) => `Dependencies install failed: ${event.error instanceof Error ? event.error.message : String(event.error)}`
|
|
565
|
+
})
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
},
|
|
569
|
+
envCheck: {
|
|
570
|
+
invoke: {
|
|
571
|
+
src: "envCheck",
|
|
572
|
+
input: ({ context }) => ({
|
|
573
|
+
repoRoot: context.repoRoot,
|
|
574
|
+
verbose: context.input.verbose
|
|
575
|
+
}),
|
|
576
|
+
onDone: { target: "supabaseStart" },
|
|
577
|
+
onError: { target: "supabaseStart" }
|
|
578
|
+
// Non-blocking
|
|
579
|
+
}
|
|
580
|
+
},
|
|
581
|
+
supabaseStart: {
|
|
582
|
+
always: [{ guard: "shouldSkipDb", target: "done" }],
|
|
583
|
+
invoke: {
|
|
584
|
+
src: "supabaseStart",
|
|
585
|
+
input: ({ context }) => ({
|
|
586
|
+
repoRoot: context.repoRoot,
|
|
587
|
+
verbose: context.input.verbose
|
|
588
|
+
}),
|
|
589
|
+
onDone: {
|
|
590
|
+
target: "done",
|
|
591
|
+
actions: assign({
|
|
592
|
+
supabaseStarted: ({ event }) => event.output.started || event.output.alreadyRunning
|
|
593
|
+
})
|
|
594
|
+
},
|
|
595
|
+
onError: { target: "done" }
|
|
596
|
+
// Non-blocking
|
|
597
|
+
}
|
|
598
|
+
},
|
|
599
|
+
done: {
|
|
600
|
+
type: "final"
|
|
601
|
+
}
|
|
602
|
+
},
|
|
603
|
+
onDone: [{ guard: "shouldSkipApp", target: "running" }, { target: "appStart" }]
|
|
604
|
+
},
|
|
605
|
+
// ============================================================
|
|
606
|
+
// App Start Phase
|
|
607
|
+
// ============================================================
|
|
608
|
+
appStart: {
|
|
609
|
+
meta: { e2e: e2eMeta.appStart },
|
|
610
|
+
invoke: {
|
|
611
|
+
src: "appStart",
|
|
612
|
+
input: ({ context }) => {
|
|
613
|
+
const detected = detectApp(context.repoRoot);
|
|
614
|
+
return {
|
|
615
|
+
repoRoot: context.repoRoot,
|
|
616
|
+
appDir: detected?.appDir ?? context.repoRoot,
|
|
617
|
+
port: context.input.port,
|
|
618
|
+
tmpDir: context.tmpDir,
|
|
619
|
+
stream: context.input.stream,
|
|
620
|
+
bundler: context.input.bundler
|
|
621
|
+
};
|
|
622
|
+
},
|
|
623
|
+
onDone: {
|
|
624
|
+
target: "running",
|
|
625
|
+
actions: assign({
|
|
626
|
+
appPid: ({ event }) => event.output.pid
|
|
627
|
+
})
|
|
628
|
+
},
|
|
629
|
+
onError: {
|
|
630
|
+
target: "failed",
|
|
631
|
+
actions: assign({
|
|
632
|
+
error: ({ event }) => `App start failed: ${event.error instanceof Error ? event.error.message : String(event.error)}`
|
|
633
|
+
})
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
},
|
|
637
|
+
// ============================================================
|
|
638
|
+
// Running State (waiting for STOP signal)
|
|
639
|
+
// ============================================================
|
|
640
|
+
running: {
|
|
641
|
+
meta: { e2e: e2eMeta.running },
|
|
642
|
+
on: {
|
|
643
|
+
STOP: { target: "shutdown" }
|
|
644
|
+
}
|
|
645
|
+
},
|
|
646
|
+
// ============================================================
|
|
647
|
+
// Shutdown Phase
|
|
648
|
+
// ============================================================
|
|
649
|
+
shutdown: {
|
|
650
|
+
meta: { e2e: e2eMeta.shutdown },
|
|
651
|
+
invoke: {
|
|
652
|
+
src: "shutdown",
|
|
653
|
+
input: ({ context }) => ({
|
|
654
|
+
pid: context.appPid ?? 0
|
|
655
|
+
}),
|
|
656
|
+
onDone: { target: "done" },
|
|
657
|
+
onError: { target: "done" }
|
|
658
|
+
// Still exit on error
|
|
659
|
+
}
|
|
660
|
+
},
|
|
661
|
+
// ============================================================
|
|
662
|
+
// Final States
|
|
663
|
+
// ============================================================
|
|
664
|
+
done: {
|
|
665
|
+
meta: { e2e: e2eMeta.done },
|
|
666
|
+
type: "final"
|
|
667
|
+
},
|
|
668
|
+
failed: {
|
|
669
|
+
meta: { e2e: e2eMeta.failed },
|
|
670
|
+
type: "final"
|
|
671
|
+
}
|
|
672
|
+
},
|
|
673
|
+
output: ({ context }) => createOutput(context)
|
|
674
|
+
});
|
|
675
|
+
function getStateName(snapshot) {
|
|
676
|
+
if (typeof snapshot.value === "string") {
|
|
677
|
+
return snapshot.value;
|
|
678
|
+
}
|
|
679
|
+
const topLevel = Object.keys(snapshot.value)[0];
|
|
680
|
+
if (topLevel && typeof snapshot.value === "object") {
|
|
681
|
+
const nested = snapshot.value[topLevel];
|
|
682
|
+
if (nested && typeof nested === "string") {
|
|
683
|
+
return `${topLevel}.${nested}`;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
return topLevel ?? "unknown";
|
|
687
|
+
}
|
|
688
|
+
function isComplete(snapshot) {
|
|
689
|
+
return snapshot.status === "done";
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
// src/commands/dev/commands/dev.ts
|
|
693
|
+
var stateLogHandlers = {
|
|
694
|
+
idle: (logger) => {
|
|
695
|
+
logger.section("Dev Server");
|
|
696
|
+
logger.info("Starting development environment...");
|
|
697
|
+
},
|
|
698
|
+
processCheck: (logger) => {
|
|
699
|
+
logger.info("Checking for existing processes...");
|
|
700
|
+
},
|
|
701
|
+
setup: (logger) => {
|
|
702
|
+
logger.section("Phase 0: Setup");
|
|
703
|
+
logger.info("Checking environment prerequisites...");
|
|
704
|
+
},
|
|
705
|
+
"setup.depsInstall": (logger) => {
|
|
706
|
+
logger.info(" Checking dependencies...");
|
|
707
|
+
},
|
|
708
|
+
"setup.envCheck": (logger) => {
|
|
709
|
+
logger.info(" Checking environment variables...");
|
|
710
|
+
},
|
|
711
|
+
"setup.supabaseStart": (logger) => {
|
|
712
|
+
logger.info(" Starting Supabase...");
|
|
713
|
+
},
|
|
714
|
+
appStart: (logger) => {
|
|
715
|
+
logger.section("Phase 1: App Start");
|
|
716
|
+
logger.info("Starting Next.js dev server...");
|
|
717
|
+
},
|
|
718
|
+
running: (logger, context) => {
|
|
719
|
+
logger.section("Development Server Running");
|
|
720
|
+
logger.success(`App running at http://localhost:${context?.port ?? 3e3}`);
|
|
721
|
+
logger.info("");
|
|
722
|
+
logger.info("Press Ctrl+C to stop");
|
|
723
|
+
},
|
|
724
|
+
shutdown: (logger) => {
|
|
725
|
+
logger.info("");
|
|
726
|
+
logger.section("Shutting Down");
|
|
727
|
+
logger.info("Stopping dev server...");
|
|
728
|
+
}
|
|
729
|
+
};
|
|
730
|
+
function handleStateChange(snapshot, prevState, logger, port) {
|
|
731
|
+
const state = getStateName(snapshot);
|
|
732
|
+
if (state === prevState) return;
|
|
733
|
+
const handler = stateLogHandlers[state] ?? stateLogHandlers[state.split(".")[0]];
|
|
734
|
+
if (handler) {
|
|
735
|
+
handler(logger, { port });
|
|
736
|
+
}
|
|
737
|
+
if (prevState === "processCheck" && state.startsWith("setup") && snapshot.context.staleProcessRecovered) {
|
|
738
|
+
logger.success(" Stale process recovered. Port is now available.");
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
function printSummary(logger, output) {
|
|
742
|
+
if (output.success) {
|
|
743
|
+
logger.success("Dev server stopped successfully");
|
|
744
|
+
} else {
|
|
745
|
+
logger.error(`Dev server failed: ${output.error}`);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
function shouldWritePortBridge(snapshot, previousState, currentState) {
|
|
749
|
+
return previousState.startsWith("setup") && (currentState === "appStart" || currentState === "running") && snapshot.context.supabaseStarted;
|
|
750
|
+
}
|
|
751
|
+
function logPortBridgeResult(logger, bridgeResult) {
|
|
752
|
+
if (bridgeResult.written) {
|
|
753
|
+
logger.info(
|
|
754
|
+
` \u2192 .env.local written (port override: api=${bridgeResult.ports.api}, db=${bridgeResult.ports.db})`
|
|
755
|
+
);
|
|
756
|
+
return;
|
|
757
|
+
}
|
|
758
|
+
if (bridgeResult.reason === "user-managed") {
|
|
759
|
+
logger.warn(" \u2192 .env.local exists but is user-managed; port override skipped");
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
function tryWritePortBridge(snapshot, previousState, currentState, logger) {
|
|
763
|
+
if (!shouldWritePortBridge(snapshot, previousState, currentState)) {
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
try {
|
|
767
|
+
const bridgeResult = writeEnvLocalBridge(
|
|
768
|
+
snapshot.context.repoRoot,
|
|
769
|
+
detectLocalSupabasePorts(snapshot.context.repoRoot)
|
|
770
|
+
);
|
|
771
|
+
logPortBridgeResult(logger, bridgeResult);
|
|
772
|
+
} catch {
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
function resolveOutputIfComplete(snapshot, resolve) {
|
|
776
|
+
if (!isComplete(snapshot)) return;
|
|
777
|
+
const output = snapshot.output;
|
|
778
|
+
if (output) {
|
|
779
|
+
resolve(output);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
function findRepoRoot(startDir) {
|
|
783
|
+
let current = startDir;
|
|
784
|
+
while (current !== path4.dirname(current)) {
|
|
785
|
+
if (existsSync(path4.join(current, "turbo.json"))) {
|
|
786
|
+
return current;
|
|
787
|
+
}
|
|
788
|
+
const pkgPath = path4.join(current, "package.json");
|
|
789
|
+
if (existsSync(pkgPath)) {
|
|
790
|
+
try {
|
|
791
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
792
|
+
if (pkg.workspaces) {
|
|
793
|
+
return current;
|
|
794
|
+
}
|
|
795
|
+
} catch {
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
current = path4.dirname(current);
|
|
799
|
+
}
|
|
800
|
+
return startDir;
|
|
801
|
+
}
|
|
802
|
+
async function runDevMachine(input, logger) {
|
|
803
|
+
const repoRoot = input.targetDir ?? findRepoRoot(process.cwd());
|
|
804
|
+
return new Promise((resolve, reject) => {
|
|
805
|
+
const actor = createActor(devMachine, {
|
|
806
|
+
input: { input, repoRoot }
|
|
807
|
+
});
|
|
808
|
+
let previousState = "";
|
|
809
|
+
actor.subscribe((snapshot) => {
|
|
810
|
+
const currentState = getStateName(snapshot);
|
|
811
|
+
if (currentState !== previousState) {
|
|
812
|
+
handleStateChange(snapshot, previousState, logger, input.port);
|
|
813
|
+
tryWritePortBridge(snapshot, previousState, currentState, logger);
|
|
814
|
+
previousState = currentState;
|
|
815
|
+
}
|
|
816
|
+
resolveOutputIfComplete(snapshot, resolve);
|
|
817
|
+
});
|
|
818
|
+
actor.subscribe({
|
|
819
|
+
error: (error) => {
|
|
820
|
+
reject(error);
|
|
821
|
+
actor.stop();
|
|
822
|
+
}
|
|
823
|
+
});
|
|
824
|
+
const handleSignal = () => {
|
|
825
|
+
logger.info("");
|
|
826
|
+
logger.info("Received shutdown signal...");
|
|
827
|
+
actor.send({ type: "STOP" });
|
|
828
|
+
};
|
|
829
|
+
process.on("SIGINT", handleSignal);
|
|
830
|
+
process.on("SIGTERM", handleSignal);
|
|
831
|
+
actor.start();
|
|
832
|
+
actor.send({ type: "START" });
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
async function runDevAction(options, cmd) {
|
|
836
|
+
const logger = createCLILogger("dev");
|
|
837
|
+
try {
|
|
838
|
+
const result = await runDevMachine(options, logger);
|
|
839
|
+
printSummary(logger, result);
|
|
840
|
+
emitJsonSuccess(cmd, DevOutputSchema, result);
|
|
841
|
+
if (!result.success) {
|
|
842
|
+
throw new CLIError(result.error ?? "Dev server failed", "DEV_FAILED", [
|
|
843
|
+
"Check logs in .runa/tmp/dev/ for details",
|
|
844
|
+
"Run with --verbose for more output"
|
|
845
|
+
]);
|
|
846
|
+
}
|
|
847
|
+
} catch (error) {
|
|
848
|
+
if (error instanceof CLIError) {
|
|
849
|
+
throw error;
|
|
850
|
+
}
|
|
851
|
+
throw new CLIError(
|
|
852
|
+
error instanceof Error ? error.message : String(error),
|
|
853
|
+
"DEV_ERROR",
|
|
854
|
+
["Run with --verbose for more details"],
|
|
855
|
+
error instanceof Error ? error : void 0
|
|
856
|
+
);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
var devCommand = new Command("dev").description("Start development server (Supabase + Next.js)").option("--port <number>", "Port for Next.js dev server", (val) => Number.parseInt(val, 10), 3e3).option("--skip-db", "Skip Supabase start").option("--skip-app", "Start Supabase only (no app server)").option("--verbose", "Show detailed output").option("--no-stream", "Disable streaming app output to terminal (log to file only)").option("--target-dir <path>", "Target directory (defaults to repo root)").option("--replace", "Replace existing runa dev process if already running").option("--bundler <type>", "Bundler for Next.js dev server (turbopack or webpack)").action(async (options, cmd) => {
|
|
860
|
+
const input = {
|
|
861
|
+
port: options.port,
|
|
862
|
+
skipDb: options.skipDb ?? false,
|
|
863
|
+
skipApp: options.skipApp ?? false,
|
|
864
|
+
verbose: options.verbose ?? false,
|
|
865
|
+
stream: options.stream ?? true,
|
|
866
|
+
targetDir: options.targetDir,
|
|
867
|
+
replace: options.replace ?? false,
|
|
868
|
+
bundler: options.bundler
|
|
869
|
+
};
|
|
870
|
+
await runDevAction(input, cmd);
|
|
871
|
+
});
|
|
872
|
+
|
|
873
|
+
export { devCommand };
|