@runa-ai/runa-cli 0.5.72 → 0.7.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-V66FAQXB.js +1719 -0
- package/dist/cache-N7WNPEYF.js +111 -0
- package/dist/check-LOMVIRHX.js +12 -0
- package/dist/chunk-2APB25TT.js +442 -0
- package/dist/chunk-3FDQW524.js +544 -0
- package/dist/chunk-3WDV32GA.js +33 -0
- package/dist/chunk-5FT3F36G.js +59 -0
- package/dist/chunk-5NKWR4FF.js +254 -0
- package/dist/chunk-644FVGIQ.js +194 -0
- package/dist/chunk-6AALH2ED.js +121 -0
- package/dist/chunk-6FAU4IGR.js +63 -0
- package/dist/chunk-6Y3LAUGL.js +35 -0
- package/dist/chunk-7B5C6U2K.js +274 -0
- package/dist/chunk-AAIE4F2U.js +140 -0
- package/dist/chunk-AIP6MR42.js +12 -0
- package/dist/chunk-CCKG5R4Y.js +59 -0
- package/dist/chunk-DRSUEMAK.js +123 -0
- package/dist/chunk-FHG3ILE4.js +2011 -0
- package/dist/chunk-H2AHNI75.js +31 -0
- package/dist/chunk-HD74F6W2.js +460 -0
- package/dist/chunk-HKUWEGUX.js +36 -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-KE6QJBZG.js +41 -0
- package/dist/chunk-KWX3JHCY.js +85 -0
- package/dist/chunk-MXRWBNIY.js +74 -0
- package/dist/chunk-NPSRD26F.js +149 -0
- package/dist/chunk-QDF7QXBL.js +67 -0
- package/dist/chunk-QM53IQHM.js +209 -0
- package/dist/chunk-RZLYEO4U.js +219 -0
- package/dist/chunk-SGJG3BKD.js +351 -0
- package/dist/chunk-TYIAD6SB.js +74 -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-WJXC4MVY.js +75 -0
- package/dist/chunk-XDCHRVE3.js +215 -0
- package/dist/chunk-Z4Z5DNW4.js +1196 -0
- package/dist/chunk-ZZOXM6Q4.js +8 -0
- package/dist/ci-ZWRVWNFX.js +9298 -0
- package/dist/cli/contract-output.d.ts +1 -0
- package/dist/cli/index.d.ts +7 -1
- package/dist/cli/requested-command.d.ts +8 -0
- package/dist/cli-2JNBJUBB.js +704 -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/actors/validate.d.ts +2 -0
- 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/check/commands/check.d.ts +8 -3
- package/dist/commands/ci/machine/actors/db/collect-schema-stats.d.ts +9 -6
- package/dist/commands/ci/machine/actors/db/schema-canonical-diff.d.ts +55 -0
- package/dist/commands/ci/machine/actors/db/schema-stats.d.ts +11 -0
- package/dist/commands/ci/machine/actors/db/sync-schema.d.ts +9 -1
- 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/formatters/sections/schema-matrix.d.ts +3 -3
- 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 +2 -5
- package/dist/commands/ci/utils/ci-summary.d.ts +15 -15
- package/dist/commands/ci/utils/execa-helpers.d.ts +2 -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/error-classifier.d.ts +9 -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 +12 -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/actors/tables-manifest.d.ts +16 -0
- package/dist/commands/dev/contract.d.ts +3 -3
- package/dist/commands/dev/guards.d.ts +24 -0
- package/dist/commands/dev/machine.d.ts +27 -32
- package/dist/commands/dev/types.d.ts +2 -0
- package/dist/commands/doctor.d.ts +9 -0
- 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/inject-test-attrs/defaults.d.ts +9 -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/commands/utils/machine-state-logging.d.ts +20 -0
- package/dist/commands/utils/repo-root.d.ts +2 -0
- package/dist/config/env.d.ts +4 -4
- package/dist/config-loader-GT3HAQ7U.js +7 -0
- package/dist/db-XULCILOU.js +14137 -0
- package/dist/dev-5YXNPTCJ.js +992 -0
- package/dist/doctor-MZLOA53G.js +44 -0
- package/dist/env-HMMRSYCI.js +7 -0
- package/dist/env-SS66PZ4B.js +2623 -0
- package/dist/env-files-2UIUYLLR.js +8 -0
- package/dist/error-handler-HEXBRNVV.js +460 -0
- package/dist/hotfix-YA3DGLOM.js +1477 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +48 -42995
- package/dist/init-ZIL6LRFO.js +631 -0
- package/dist/inject-test-attrs-P44BVTQS.js +23 -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-VSNDVZZD.js +59 -0
- package/dist/manifest-TMFLESHW.js +19 -0
- package/dist/prepare-32DOVHTE.js +250 -0
- package/dist/risk-detector-4U6ZJ2G5.js +6 -0
- package/dist/risk-detector-core-TK4OAI3N.js +166 -0
- package/dist/risk-detector-plpgsql-HWKS4OLR.js +1886 -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-UTKS63AB.js +94 -0
- package/dist/telemetry-P56UBLZ2.js +93 -0
- package/dist/template-check-3P4HZXVY.js +1944 -0
- package/dist/test-V4KQL574.js +650 -0
- package/dist/test-gen-FS4CEY3P.js +88 -0
- package/dist/ui-RJAMCWUI.js +331 -0
- package/dist/upgrade-NUK3ZBCL.js +637 -0
- package/dist/utils/config-loader.d.ts +0 -3
- package/dist/validate-CAAW4Y44.js +54 -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-2W7N5TA2.js +121 -0
- package/dist/vuln-checker-IQJ56RUV.js +3223 -0
- package/dist/watch-PNTKZYFB.js +911 -0
- package/dist/workflow-H75N4BXX.js +897 -0
- package/package.json +5 -2
- 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,219 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
import { init_esm_shims } from './chunk-VRXHCR5K.js';
|
|
4
|
+
import { lstatSync, realpathSync, statSync, accessSync, constants } from 'fs';
|
|
5
|
+
import { dirname, isAbsolute, normalize, join } from 'path';
|
|
6
|
+
import { execa } from 'execa';
|
|
7
|
+
|
|
8
|
+
createRequire(import.meta.url);
|
|
9
|
+
|
|
10
|
+
// src/utils/secure-exec.ts
|
|
11
|
+
init_esm_shims();
|
|
12
|
+
var TRUSTED_BINARIES = [
|
|
13
|
+
"node",
|
|
14
|
+
"pnpm",
|
|
15
|
+
"npm",
|
|
16
|
+
"npx",
|
|
17
|
+
"git",
|
|
18
|
+
"gh",
|
|
19
|
+
"vercel",
|
|
20
|
+
"supabase",
|
|
21
|
+
"docker",
|
|
22
|
+
"psql",
|
|
23
|
+
"turbo",
|
|
24
|
+
"biome",
|
|
25
|
+
"lsof",
|
|
26
|
+
"runa"
|
|
27
|
+
];
|
|
28
|
+
var TRUSTED_DIRECTORIES_UNIX = [
|
|
29
|
+
"/usr/bin",
|
|
30
|
+
"/usr/local/bin",
|
|
31
|
+
"/bin",
|
|
32
|
+
"/usr/sbin",
|
|
33
|
+
"/sbin",
|
|
34
|
+
// Homebrew on macOS
|
|
35
|
+
"/opt/homebrew/bin",
|
|
36
|
+
"/opt/homebrew/sbin",
|
|
37
|
+
// Node.js version managers and corepack symlink targets
|
|
38
|
+
"/usr/local/lib/node_modules/.bin",
|
|
39
|
+
"/usr/local/lib/node_modules",
|
|
40
|
+
// Common package manager locations
|
|
41
|
+
"/usr/local/share/npm/bin"
|
|
42
|
+
];
|
|
43
|
+
var TRUSTED_DIRECTORY_PATTERNS_WINDOWS = [
|
|
44
|
+
/^[A-Z]:\\Windows\\System32\\?$/i,
|
|
45
|
+
/^[A-Z]:\\Windows\\?$/i,
|
|
46
|
+
/^[A-Z]:\\Program Files\\.*\\bin\\?$/i,
|
|
47
|
+
/^[A-Z]:\\Program Files \(x86\)\\.*\\bin\\?$/i,
|
|
48
|
+
// Node.js and npm
|
|
49
|
+
/^[A-Z]:\\Program Files\\nodejs\\?$/i,
|
|
50
|
+
/^[A-Z]:\\Users\\[^\\]+\\AppData\\Roaming\\npm\\?$/i
|
|
51
|
+
];
|
|
52
|
+
var CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
53
|
+
var binaryPathCache = /* @__PURE__ */ new Map();
|
|
54
|
+
function getPathFingerprint() {
|
|
55
|
+
const pathEnv = process.env.PATH || "";
|
|
56
|
+
return `${pathEnv.length}:${pathEnv.slice(0, 100)}:${pathEnv.slice(-100)}`;
|
|
57
|
+
}
|
|
58
|
+
function isExecutable(filePath) {
|
|
59
|
+
try {
|
|
60
|
+
accessSync(filePath, constants.X_OK);
|
|
61
|
+
const stats = statSync(filePath);
|
|
62
|
+
return stats.isFile();
|
|
63
|
+
} catch {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function resolveAndValidateSymlink(filePath) {
|
|
68
|
+
try {
|
|
69
|
+
const lstats = lstatSync(filePath);
|
|
70
|
+
if (lstats.isSymbolicLink()) {
|
|
71
|
+
const realPath = realpathSync(filePath);
|
|
72
|
+
const realDir = dirname(realPath);
|
|
73
|
+
if (!isTrustedDirectory(realDir)) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
const realStats = statSync(realPath);
|
|
77
|
+
if (!realStats.isFile()) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
return realPath;
|
|
81
|
+
}
|
|
82
|
+
return filePath;
|
|
83
|
+
} catch {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
var TRUSTED_VERSION_MANAGER_PATTERNS_UNIX = [
|
|
88
|
+
// Homebrew Cellar (macOS)
|
|
89
|
+
/^\/opt\/homebrew\/Cellar\/[^/]+\/[^/]+\/bin$/,
|
|
90
|
+
// nvm
|
|
91
|
+
/^\/Users\/[^/]+\/\.nvm\/versions\/node\/[^/]+\/bin$/,
|
|
92
|
+
/^\/home\/[^/]+\/\.nvm\/versions\/node\/[^/]+\/bin$/,
|
|
93
|
+
// fnm
|
|
94
|
+
/^\/Users\/[^/]+\/\.fnm\/node-versions\/[^/]+\/installation\/bin$/,
|
|
95
|
+
/^\/home\/[^/]+\/\.fnm\/node-versions\/[^/]+\/installation\/bin$/,
|
|
96
|
+
// pnpm global
|
|
97
|
+
/^\/Users\/[^/]+\/Library\/pnpm$/,
|
|
98
|
+
/^\/home\/[^/]+\/\.local\/share\/pnpm$/,
|
|
99
|
+
// mise
|
|
100
|
+
/^\/Users\/[^/]+\/\.local\/share\/mise\/installs\/[^/]+\/[^/]+\/bin$/,
|
|
101
|
+
/^\/Users\/[^/]+\/\.local\/share\/mise\/shims$/,
|
|
102
|
+
/^\/home\/[^/]+\/\.local\/share\/mise\/installs\/[^/]+\/[^/]+\/bin$/,
|
|
103
|
+
/^\/home\/[^/]+\/\.local\/share\/mise\/shims$/,
|
|
104
|
+
// volta
|
|
105
|
+
/^\/Users\/[^/]+\/\.volta\/bin$/,
|
|
106
|
+
/^\/home\/[^/]+\/\.volta\/bin$/,
|
|
107
|
+
// asdf
|
|
108
|
+
/^\/Users\/[^/]+\/\.asdf\/shims$/,
|
|
109
|
+
/^\/Users\/[^/]+\/\.asdf\/installs\/[^/]+\/[^/]+\/bin$/,
|
|
110
|
+
/^\/home\/[^/]+\/\.asdf\/shims$/,
|
|
111
|
+
/^\/home\/[^/]+\/\.asdf\/installs\/[^/]+\/[^/]+\/bin$/,
|
|
112
|
+
// proto
|
|
113
|
+
/^\/Users\/[^/]+\/\.proto\/shims$/,
|
|
114
|
+
/^\/Users\/[^/]+\/\.proto\/tools\/[^/]+\/[^/]+\/bin$/,
|
|
115
|
+
/^\/home\/[^/]+\/\.proto\/shims$/,
|
|
116
|
+
/^\/home\/[^/]+\/\.proto\/tools\/[^/]+\/[^/]+\/bin$/
|
|
117
|
+
];
|
|
118
|
+
function isTrustedDirectory(dir) {
|
|
119
|
+
const normalizedDir = normalize(dir).replace(/[/\\]$/, "");
|
|
120
|
+
if (process.platform === "win32") {
|
|
121
|
+
return TRUSTED_DIRECTORY_PATTERNS_WINDOWS.some((pattern) => pattern.test(normalizedDir));
|
|
122
|
+
}
|
|
123
|
+
for (const trusted of TRUSTED_DIRECTORIES_UNIX) {
|
|
124
|
+
const normalizedTrusted = normalize(trusted).replace(/[/\\]$/, "");
|
|
125
|
+
if (normalizedDir === normalizedTrusted || normalizedDir.startsWith(`${normalizedTrusted}/`)) {
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return TRUSTED_VERSION_MANAGER_PATTERNS_UNIX.some((pattern) => pattern.test(normalizedDir));
|
|
130
|
+
}
|
|
131
|
+
function searchPathForBinary(binaryName) {
|
|
132
|
+
const pathEnv = process.env.PATH ?? "";
|
|
133
|
+
const pathDirs = pathEnv.split(process.platform === "win32" ? ";" : ":");
|
|
134
|
+
const extensions = process.platform === "win32" ? ["", ".exe", ".cmd", ".bat"] : [""];
|
|
135
|
+
for (const dir of pathDirs) {
|
|
136
|
+
if (!dir || !isAbsolute(dir) || !isTrustedDirectory(dir)) continue;
|
|
137
|
+
const matchedBinary = findValidatedBinaryInDirectory(dir, binaryName, extensions);
|
|
138
|
+
if (matchedBinary) {
|
|
139
|
+
return matchedBinary;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
function findValidatedBinaryInDirectory(dir, binaryName, extensions) {
|
|
145
|
+
for (const ext of extensions) {
|
|
146
|
+
const fullPath = join(dir, binaryName + ext);
|
|
147
|
+
if (!isExecutable(fullPath)) {
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
const validatedPath = resolveAndValidateSymlink(fullPath);
|
|
151
|
+
if (validatedPath) {
|
|
152
|
+
return { originalPath: fullPath, validatedPath };
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
function resolveBinaryPath(binaryName) {
|
|
158
|
+
if (!TRUSTED_BINARIES.includes(binaryName)) {
|
|
159
|
+
throw new Error(
|
|
160
|
+
`Security: Binary '${binaryName}' is not in the trusted binaries list. Allowed: ${TRUSTED_BINARIES.join(", ")}`
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
const now = Date.now();
|
|
164
|
+
const currentPathFingerprint = getPathFingerprint();
|
|
165
|
+
const cached = binaryPathCache.get(binaryName);
|
|
166
|
+
if (cached) {
|
|
167
|
+
const isExpired = now - cached.resolvedAt >= CACHE_TTL_MS;
|
|
168
|
+
const pathChanged = cached.pathFingerprint !== currentPathFingerprint;
|
|
169
|
+
if (!isExpired && !pathChanged) {
|
|
170
|
+
const validatedPath2 = resolveAndValidateSymlink(cached.path);
|
|
171
|
+
if (validatedPath2 && isExecutable(validatedPath2)) {
|
|
172
|
+
return validatedPath2;
|
|
173
|
+
}
|
|
174
|
+
binaryPathCache.delete(binaryName);
|
|
175
|
+
} else {
|
|
176
|
+
binaryPathCache.delete(binaryName);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const result = searchPathForBinary(binaryName);
|
|
180
|
+
if (!result) {
|
|
181
|
+
throw new Error(
|
|
182
|
+
`Binary '${binaryName}' not found in trusted PATH directories. Ensure ${binaryName} is installed in a system directory.`
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
const { validatedPath } = result;
|
|
186
|
+
if (!isExecutable(validatedPath)) {
|
|
187
|
+
throw new Error(`Binary '${binaryName}' at '${validatedPath}' is not executable.`);
|
|
188
|
+
}
|
|
189
|
+
binaryPathCache.set(binaryName, {
|
|
190
|
+
path: validatedPath,
|
|
191
|
+
resolvedAt: now,
|
|
192
|
+
pathFingerprint: currentPathFingerprint
|
|
193
|
+
});
|
|
194
|
+
return validatedPath;
|
|
195
|
+
}
|
|
196
|
+
function secureExeca(binaryName, args = [], options) {
|
|
197
|
+
const resolvedPath = resolveBinaryPath(binaryName);
|
|
198
|
+
const finalPath = resolveAndValidateSymlink(resolvedPath);
|
|
199
|
+
if (!finalPath || !isExecutable(finalPath)) {
|
|
200
|
+
throw new Error(
|
|
201
|
+
`Security: Binary '${binaryName}' validation failed just before execution. The file may have been modified.`
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
return execa(finalPath, args, { ...options, shell: false });
|
|
205
|
+
}
|
|
206
|
+
function securePnpm(args = [], options) {
|
|
207
|
+
return secureExeca("pnpm", args, options);
|
|
208
|
+
}
|
|
209
|
+
function secureGh(args = [], options) {
|
|
210
|
+
return secureExeca("gh", args, options);
|
|
211
|
+
}
|
|
212
|
+
function secureSupabase(args = [], options) {
|
|
213
|
+
return secureExeca("supabase", args, options);
|
|
214
|
+
}
|
|
215
|
+
function secureDocker(args = [], options) {
|
|
216
|
+
return secureExeca("docker", args, options);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export { secureDocker, secureExeca, secureGh, securePnpm, secureSupabase };
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
import { isPathContained } from './chunk-DRSUEMAK.js';
|
|
4
|
+
import { secureGh, securePnpm } from './chunk-RZLYEO4U.js';
|
|
5
|
+
import { init_esm_shims } from './chunk-VRXHCR5K.js';
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
import { rm, mkdir, writeFile, cp, readdir, lstat } from 'fs/promises';
|
|
8
|
+
import os from 'os';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
import { CLIError } from '@runa-ai/runa';
|
|
11
|
+
|
|
12
|
+
createRequire(import.meta.url);
|
|
13
|
+
|
|
14
|
+
// src/utils/template-fetcher.ts
|
|
15
|
+
init_esm_shims();
|
|
16
|
+
|
|
17
|
+
// src/constants/versions.ts
|
|
18
|
+
init_esm_shims();
|
|
19
|
+
var COMPATIBLE_TEMPLATES_VERSION = "0.5.71";
|
|
20
|
+
var TEMPLATES_PACKAGE_NAME = "@r06-dev/runa-templates";
|
|
21
|
+
var GITHUB_PACKAGES_REGISTRY = "https://npm.pkg.github.com";
|
|
22
|
+
|
|
23
|
+
// src/utils/template-fetcher.ts
|
|
24
|
+
var SAFE_VERSION_PATTERN = /^[a-zA-Z0-9._-]+$/;
|
|
25
|
+
function validateVersion(version) {
|
|
26
|
+
if (!version || version.trim() === "") {
|
|
27
|
+
throw new CLIError("Invalid version: version cannot be empty.", "INVALID_VERSION", [
|
|
28
|
+
"Provide a valid semantic version (e.g., 0.1.0)"
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
31
|
+
if (version.includes("..") || version.includes("/") || version.includes("\\")) {
|
|
32
|
+
throw new CLIError(
|
|
33
|
+
"Invalid version: path traversal sequences detected.",
|
|
34
|
+
"INVALID_VERSION_PATH_TRAVERSAL",
|
|
35
|
+
[
|
|
36
|
+
'Version cannot contain "..", "/", or "\\"',
|
|
37
|
+
"Provide a valid semantic version (e.g., 0.1.0)"
|
|
38
|
+
]
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
if (!SAFE_VERSION_PATTERN.test(version)) {
|
|
42
|
+
throw new CLIError(
|
|
43
|
+
"Invalid version: contains prohibited characters.",
|
|
44
|
+
"INVALID_VERSION_CHARS",
|
|
45
|
+
[
|
|
46
|
+
'Version can only contain: a-z, A-Z, 0-9, ".", "-", "_"',
|
|
47
|
+
"Provide a valid semantic version (e.g., 0.1.0)"
|
|
48
|
+
]
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function getCacheBase() {
|
|
53
|
+
return path.join(os.homedir(), ".cache", "runa", "templates");
|
|
54
|
+
}
|
|
55
|
+
function getCacheDir(version) {
|
|
56
|
+
validateVersion(version);
|
|
57
|
+
const cacheBase = getCacheBase();
|
|
58
|
+
const cacheDir = path.join(cacheBase, version);
|
|
59
|
+
const resolvedCacheDir = path.resolve(cacheDir);
|
|
60
|
+
if (!isPathContained(cacheBase, resolvedCacheDir)) {
|
|
61
|
+
throw new CLIError(
|
|
62
|
+
"Security: cache directory would escape allowed location.",
|
|
63
|
+
"CACHE_PATH_ESCAPE",
|
|
64
|
+
["This is likely a bug. Please report this issue."]
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
return resolvedCacheDir;
|
|
68
|
+
}
|
|
69
|
+
function isCached(version) {
|
|
70
|
+
const cacheDir = getCacheDir(version);
|
|
71
|
+
const templatesDir = path.join(cacheDir, "templates");
|
|
72
|
+
return fs.existsSync(templatesDir);
|
|
73
|
+
}
|
|
74
|
+
var scopedAuthToken = null;
|
|
75
|
+
var tokenWasAutoDetected = false;
|
|
76
|
+
async function getAuthToken() {
|
|
77
|
+
if (process.env.NODE_AUTH_TOKEN) {
|
|
78
|
+
return process.env.NODE_AUTH_TOKEN;
|
|
79
|
+
}
|
|
80
|
+
if (scopedAuthToken) {
|
|
81
|
+
return scopedAuthToken;
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const result = await secureGh(["auth", "token"], {
|
|
85
|
+
reject: false,
|
|
86
|
+
timeout: 5e3
|
|
87
|
+
});
|
|
88
|
+
const stdout = typeof result.stdout === "string" ? result.stdout : "";
|
|
89
|
+
if (result.exitCode === 0 && stdout.trim()) {
|
|
90
|
+
scopedAuthToken = stdout.trim();
|
|
91
|
+
tokenWasAutoDetected = true;
|
|
92
|
+
return scopedAuthToken;
|
|
93
|
+
}
|
|
94
|
+
} catch {
|
|
95
|
+
}
|
|
96
|
+
throw new CLIError("GitHub authentication required for template fetch.", "GITHUB_AUTH_REQUIRED", [
|
|
97
|
+
"Option 1: Use GitHub CLI (recommended)",
|
|
98
|
+
" gh auth login",
|
|
99
|
+
" # Token will be auto-detected on next run",
|
|
100
|
+
"",
|
|
101
|
+
"Option 2: Set NODE_AUTH_TOKEN manually",
|
|
102
|
+
" export NODE_AUTH_TOKEN=$(gh auth token)",
|
|
103
|
+
"",
|
|
104
|
+
"Option 3: Create Personal Access Token",
|
|
105
|
+
" https://github.com/settings/tokens (packages:read scope)"
|
|
106
|
+
]);
|
|
107
|
+
}
|
|
108
|
+
function cleanupAuthToken() {
|
|
109
|
+
if (tokenWasAutoDetected) {
|
|
110
|
+
scopedAuthToken = null;
|
|
111
|
+
tokenWasAutoDetected = false;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async function createTempPackageJson(tempDir, version) {
|
|
115
|
+
const packageJson = {
|
|
116
|
+
name: "runa-templates-installer",
|
|
117
|
+
private: true,
|
|
118
|
+
dependencies: {
|
|
119
|
+
[TEMPLATES_PACKAGE_NAME]: version
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
await writeFile(path.join(tempDir, "package.json"), JSON.stringify(packageJson, null, 2));
|
|
123
|
+
}
|
|
124
|
+
async function createTempNpmrc(tempDir) {
|
|
125
|
+
const npmrc = `@r06-dev:registry=${GITHUB_PACKAGES_REGISTRY}
|
|
126
|
+
//npm.pkg.github.com/:_authToken=\${NODE_AUTH_TOKEN}
|
|
127
|
+
`;
|
|
128
|
+
await writeFile(path.join(tempDir, ".npmrc"), npmrc);
|
|
129
|
+
}
|
|
130
|
+
async function installTemplates(tempDir, authToken, verbose) {
|
|
131
|
+
try {
|
|
132
|
+
const childEnv = {
|
|
133
|
+
...process.env,
|
|
134
|
+
// SECURITY: Pass token only to this specific child process
|
|
135
|
+
NODE_AUTH_TOKEN: authToken
|
|
136
|
+
};
|
|
137
|
+
await securePnpm(["install", "--no-frozen-lockfile"], {
|
|
138
|
+
cwd: tempDir,
|
|
139
|
+
stdio: verbose ? "inherit" : "pipe",
|
|
140
|
+
env: childEnv
|
|
141
|
+
});
|
|
142
|
+
} catch (error) {
|
|
143
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
144
|
+
if (message.includes("401") || message.includes("403")) {
|
|
145
|
+
throw new CLIError("GitHub Packages authentication failed.", "GITHUB_AUTH_FAILED", [
|
|
146
|
+
"Ensure your GitHub authentication is valid:",
|
|
147
|
+
" gh auth status",
|
|
148
|
+
"",
|
|
149
|
+
"Re-authenticate if needed:",
|
|
150
|
+
" gh auth login",
|
|
151
|
+
"",
|
|
152
|
+
"Or generate a new token with `packages:read` scope:",
|
|
153
|
+
" https://github.com/settings/tokens"
|
|
154
|
+
]);
|
|
155
|
+
}
|
|
156
|
+
if (message.includes("404")) {
|
|
157
|
+
throw new CLIError("Templates package not found.", "TEMPLATES_NOT_FOUND", [
|
|
158
|
+
`Package: ${TEMPLATES_PACKAGE_NAME}@${COMPATIBLE_TEMPLATES_VERSION}`,
|
|
159
|
+
"",
|
|
160
|
+
"Possible causes:",
|
|
161
|
+
" 1. This version is not published yet",
|
|
162
|
+
" 2. The package registry is unavailable",
|
|
163
|
+
"",
|
|
164
|
+
"Workarounds:",
|
|
165
|
+
" - Try a specific version: runa init --templates-version 0.5.30",
|
|
166
|
+
" - Check available versions: npm view @r06-dev/runa-templates versions"
|
|
167
|
+
]);
|
|
168
|
+
}
|
|
169
|
+
const errorDetail = message.length > 200 ? `${message.slice(0, 200)}...` : message;
|
|
170
|
+
throw new CLIError("Failed to install templates.", "TEMPLATES_INSTALL_FAILED", [
|
|
171
|
+
`Error: ${errorDetail}`,
|
|
172
|
+
"",
|
|
173
|
+
"Troubleshooting:",
|
|
174
|
+
" 1. Check your network connection",
|
|
175
|
+
" 2. Verify GitHub authentication: gh auth status",
|
|
176
|
+
" 3. Run with DEBUG=true for verbose output",
|
|
177
|
+
" 4. Clear cache and retry: runa init --fresh",
|
|
178
|
+
"",
|
|
179
|
+
`Requested version: ${COMPATIBLE_TEMPLATES_VERSION}`
|
|
180
|
+
]);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async function verifyNoSymlinks(dir, baseDir) {
|
|
184
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
185
|
+
for (const entry of entries) {
|
|
186
|
+
const fullPath = path.join(dir, entry.name);
|
|
187
|
+
const stats = await lstat(fullPath);
|
|
188
|
+
if (stats.isSymbolicLink()) {
|
|
189
|
+
const relativePath = path.relative(baseDir, fullPath);
|
|
190
|
+
throw new CLIError(
|
|
191
|
+
"Security: Symlink detected in template package.",
|
|
192
|
+
"SYMLINK_ATTACK_DETECTED",
|
|
193
|
+
[
|
|
194
|
+
`Symlink found: ${relativePath}`,
|
|
195
|
+
"This could be an attempt to access files outside the template directory.",
|
|
196
|
+
"The template package may be malicious or corrupted.",
|
|
197
|
+
"Please report this issue if you believe this is a false positive."
|
|
198
|
+
]
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
if (stats.isDirectory()) {
|
|
202
|
+
await verifyNoSymlinks(fullPath, baseDir);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
async function copyToCache(tempDir, cacheDir) {
|
|
207
|
+
const sourceTemplates = path.join(tempDir, "node_modules", TEMPLATES_PACKAGE_NAME, "templates");
|
|
208
|
+
if (!fs.existsSync(sourceTemplates)) {
|
|
209
|
+
throw new CLIError("Templates directory not found in package.", "TEMPLATES_DIR_NOT_FOUND", [
|
|
210
|
+
`Expected: ${sourceTemplates}`,
|
|
211
|
+
"The templates package may be corrupted.",
|
|
212
|
+
"Try running with --fresh to re-download."
|
|
213
|
+
]);
|
|
214
|
+
}
|
|
215
|
+
await verifyNoSymlinks(sourceTemplates, sourceTemplates);
|
|
216
|
+
await mkdir(cacheDir, { recursive: true });
|
|
217
|
+
const targetTemplates = path.join(cacheDir, "templates");
|
|
218
|
+
await cp(sourceTemplates, targetTemplates, {
|
|
219
|
+
recursive: true,
|
|
220
|
+
dereference: false
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
function logVerboseMessage(verbose, message) {
|
|
224
|
+
if (verbose) {
|
|
225
|
+
console.log(message);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function getWorkspaceTemplatesResult(workspaceTemplatesDir, verbose) {
|
|
229
|
+
if (!workspaceTemplatesDir) return null;
|
|
230
|
+
logVerboseMessage(verbose, `Using workspace templates: ${workspaceTemplatesDir}`);
|
|
231
|
+
return {
|
|
232
|
+
templatesDir: workspaceTemplatesDir,
|
|
233
|
+
version: "workspace",
|
|
234
|
+
cached: true
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
function getCachedTemplatesResult(version, fresh, templatesDir, verbose) {
|
|
238
|
+
if (fresh || !isCached(version)) {
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
logVerboseMessage(verbose, `Using cached templates v${version}: ${templatesDir}`);
|
|
242
|
+
return {
|
|
243
|
+
templatesDir,
|
|
244
|
+
version,
|
|
245
|
+
cached: true
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
async function fetchAndCacheTemplates(options) {
|
|
249
|
+
const { authToken, cacheDir, fresh, templatesDir, version, verbose } = options;
|
|
250
|
+
if (fresh && fs.existsSync(cacheDir)) {
|
|
251
|
+
await rm(cacheDir, { recursive: true, force: true });
|
|
252
|
+
}
|
|
253
|
+
const tempDir = path.join(os.tmpdir(), `runa-templates-${Date.now()}`);
|
|
254
|
+
await mkdir(tempDir, { recursive: true });
|
|
255
|
+
try {
|
|
256
|
+
logVerboseMessage(verbose, `Fetching templates v${version}...`);
|
|
257
|
+
await createTempPackageJson(tempDir, version);
|
|
258
|
+
await createTempNpmrc(tempDir);
|
|
259
|
+
await installTemplates(tempDir, authToken, verbose);
|
|
260
|
+
await copyToCache(tempDir, cacheDir);
|
|
261
|
+
logVerboseMessage(verbose, `Templates cached at: ${templatesDir}`);
|
|
262
|
+
return {
|
|
263
|
+
templatesDir,
|
|
264
|
+
version,
|
|
265
|
+
cached: false
|
|
266
|
+
};
|
|
267
|
+
} finally {
|
|
268
|
+
await rm(tempDir, { recursive: true, force: true }).catch(() => {
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
async function fetchTemplates(options = {}) {
|
|
273
|
+
const version = options.version ?? COMPATIBLE_TEMPLATES_VERSION;
|
|
274
|
+
const fresh = options.fresh ?? false;
|
|
275
|
+
const verbose = options.verbose ?? false;
|
|
276
|
+
const workspaceResult = getWorkspaceTemplatesResult(resolveWorkspaceTemplates(), verbose);
|
|
277
|
+
if (workspaceResult) {
|
|
278
|
+
return workspaceResult;
|
|
279
|
+
}
|
|
280
|
+
const cacheDir = getCacheDir(version);
|
|
281
|
+
const templatesDir = path.join(cacheDir, "templates");
|
|
282
|
+
const cachedResult = getCachedTemplatesResult(version, fresh, templatesDir, verbose);
|
|
283
|
+
if (cachedResult) {
|
|
284
|
+
return cachedResult;
|
|
285
|
+
}
|
|
286
|
+
const authToken = await getAuthToken();
|
|
287
|
+
try {
|
|
288
|
+
return fetchAndCacheTemplates({ authToken, cacheDir, fresh, templatesDir, version, verbose });
|
|
289
|
+
} finally {
|
|
290
|
+
cleanupAuthToken();
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
var MAX_WORKSPACE_TRAVERSAL_DEPTH = 10;
|
|
294
|
+
function isLegitimateWorkspaceRoot(workspaceRoot) {
|
|
295
|
+
const pnpmWorkspaceFile = path.join(workspaceRoot, "pnpm-workspace.yaml");
|
|
296
|
+
if (!fs.existsSync(pnpmWorkspaceFile)) {
|
|
297
|
+
return false;
|
|
298
|
+
}
|
|
299
|
+
const rootPackageFile = path.join(workspaceRoot, "package.json");
|
|
300
|
+
if (!fs.existsSync(rootPackageFile)) {
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
try {
|
|
304
|
+
const rootPkg = JSON.parse(fs.readFileSync(rootPackageFile, "utf-8"));
|
|
305
|
+
const hasWorkspaces = Array.isArray(rootPkg.workspaces) && rootPkg.workspaces.length > 0;
|
|
306
|
+
const hasExpectedName = rootPkg.name === "runa" || rootPkg.name === "@r06-dev/runa";
|
|
307
|
+
return hasWorkspaces || hasExpectedName;
|
|
308
|
+
} catch {
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
function hasValidTemplatesPackageMarker(workspaceRoot) {
|
|
313
|
+
const markerFile = path.join(workspaceRoot, "packages", "runa-templates", "package.json");
|
|
314
|
+
if (!fs.existsSync(markerFile)) {
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
try {
|
|
318
|
+
const pkg = JSON.parse(fs.readFileSync(markerFile, "utf-8"));
|
|
319
|
+
return pkg.name === "@r06-dev/runa-templates";
|
|
320
|
+
} catch {
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
function resolveWorkspaceTemplatesFromRoot(workspaceRoot) {
|
|
325
|
+
if (!isLegitimateWorkspaceRoot(workspaceRoot)) {
|
|
326
|
+
return void 0;
|
|
327
|
+
}
|
|
328
|
+
const templatesPath = path.join(workspaceRoot, "packages", "runa-templates", "templates");
|
|
329
|
+
const normalizedTemplatesPath = path.resolve(templatesPath);
|
|
330
|
+
if (!isPathContained(workspaceRoot, normalizedTemplatesPath)) {
|
|
331
|
+
return void 0;
|
|
332
|
+
}
|
|
333
|
+
if (!fs.existsSync(normalizedTemplatesPath)) {
|
|
334
|
+
return void 0;
|
|
335
|
+
}
|
|
336
|
+
return hasValidTemplatesPackageMarker(workspaceRoot) ? normalizedTemplatesPath : void 0;
|
|
337
|
+
}
|
|
338
|
+
function resolveWorkspaceTemplates() {
|
|
339
|
+
let current = path.resolve(process.cwd());
|
|
340
|
+
const root = path.parse(current).root;
|
|
341
|
+
for (let depth = 0; current !== root && depth < MAX_WORKSPACE_TRAVERSAL_DEPTH; depth += 1) {
|
|
342
|
+
const resolved = resolveWorkspaceTemplatesFromRoot(current);
|
|
343
|
+
if (resolved) {
|
|
344
|
+
return resolved;
|
|
345
|
+
}
|
|
346
|
+
current = path.dirname(current);
|
|
347
|
+
}
|
|
348
|
+
return void 0;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export { fetchTemplates };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
import { init_esm_shims } from './chunk-VRXHCR5K.js';
|
|
4
|
+
|
|
5
|
+
createRequire(import.meta.url);
|
|
6
|
+
|
|
7
|
+
// src/cli/signal-handler.ts
|
|
8
|
+
init_esm_shims();
|
|
9
|
+
var state = {
|
|
10
|
+
cleanupFns: [],
|
|
11
|
+
sigintCount: 0,
|
|
12
|
+
isShuttingDown: false
|
|
13
|
+
};
|
|
14
|
+
function registerCleanup(fn) {
|
|
15
|
+
state.cleanupFns.push(fn);
|
|
16
|
+
}
|
|
17
|
+
function unregisterCleanup(fn) {
|
|
18
|
+
const index = state.cleanupFns.indexOf(fn);
|
|
19
|
+
if (index !== -1) {
|
|
20
|
+
state.cleanupFns.splice(index, 1);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
async function runCleanup() {
|
|
24
|
+
for (const fn of state.cleanupFns) {
|
|
25
|
+
try {
|
|
26
|
+
await fn();
|
|
27
|
+
} catch (error) {
|
|
28
|
+
logSignal(
|
|
29
|
+
"debug",
|
|
30
|
+
`Cleanup error: ${error instanceof Error ? error.message : String(error)}`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
state.cleanupFns = [];
|
|
35
|
+
}
|
|
36
|
+
function shouldLogDebug() {
|
|
37
|
+
return process.env.DEBUG === "true" || process.env.LOG_LEVEL === "debug";
|
|
38
|
+
}
|
|
39
|
+
function logSignal(level, message) {
|
|
40
|
+
if (process.env.RUNA_OUTPUT_FORMAT === "json") return;
|
|
41
|
+
if (level === "debug" && !shouldLogDebug()) return;
|
|
42
|
+
const stream = level === "warn" ? process.stderr : process.stdout;
|
|
43
|
+
const label = level.toUpperCase();
|
|
44
|
+
stream.write(`[${label}] [signal] ${message}
|
|
45
|
+
`);
|
|
46
|
+
}
|
|
47
|
+
async function handleShutdown(signal, exitCode) {
|
|
48
|
+
if (state.isShuttingDown) {
|
|
49
|
+
logSignal("warn", "Force exit");
|
|
50
|
+
process.exit(exitCode);
|
|
51
|
+
}
|
|
52
|
+
state.isShuttingDown = true;
|
|
53
|
+
logSignal("info", `Received ${signal}, shutting down...`);
|
|
54
|
+
await runCleanup();
|
|
55
|
+
process.exit(exitCode);
|
|
56
|
+
}
|
|
57
|
+
function setupSignalHandlers() {
|
|
58
|
+
process.on("SIGINT", async () => {
|
|
59
|
+
state.sigintCount++;
|
|
60
|
+
if (state.sigintCount >= 2) {
|
|
61
|
+
logSignal("warn", "Force exit (double Ctrl+C)");
|
|
62
|
+
process.exit(130);
|
|
63
|
+
}
|
|
64
|
+
await handleShutdown("SIGINT", 130);
|
|
65
|
+
});
|
|
66
|
+
process.on("SIGTERM", async () => {
|
|
67
|
+
await handleShutdown("SIGTERM", 143);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function isShuttingDown() {
|
|
71
|
+
return state.isShuttingDown;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { isShuttingDown, registerCleanup, setupSignalHandlers, unregisterCleanup };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
import { init_esm_shims } from './chunk-VRXHCR5K.js';
|
|
4
|
+
|
|
5
|
+
createRequire(import.meta.url);
|
|
6
|
+
|
|
7
|
+
// src/cli/requested-command.ts
|
|
8
|
+
init_esm_shims();
|
|
9
|
+
function getRequestedCommandNameFromArgv(argv) {
|
|
10
|
+
let skipNextToken = false;
|
|
11
|
+
for (const token of argv) {
|
|
12
|
+
if (skipNextToken) {
|
|
13
|
+
skipNextToken = false;
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (token === "--") break;
|
|
17
|
+
if (token === "--format") {
|
|
18
|
+
skipNextToken = true;
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (token.startsWith("--format=")) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (!token.startsWith("-")) {
|
|
25
|
+
return token;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { getRequestedCommandNameFromArgv };
|