primitive-admin 1.1.0-alpha.8 → 1.1.0-alpha.80
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/README.md +444 -106
- package/assets/skill/skills/primitive-platform/SKILL.md +811 -0
- package/dist/bin/primitive.d.ts +2 -0
- package/dist/bin/primitive.js +373 -21
- package/dist/bin/primitive.js.map +1 -1
- package/dist/src/commands/admins.d.ts +2 -0
- package/dist/src/commands/admins.js +128 -19
- package/dist/src/commands/admins.js.map +1 -1
- package/dist/src/commands/analytics.d.ts +2 -0
- package/dist/src/commands/analytics.js +700 -55
- package/dist/src/commands/analytics.js.map +1 -1
- package/dist/src/commands/apps.d.ts +2 -0
- package/dist/src/commands/apps.js +54 -96
- package/dist/src/commands/apps.js.map +1 -1
- package/dist/src/commands/auth.d.ts +2 -0
- package/dist/src/commands/auth.js +196 -105
- package/dist/src/commands/auth.js.map +1 -1
- package/dist/src/commands/blob-buckets.d.ts +2 -0
- package/dist/src/commands/blob-buckets.js +330 -0
- package/dist/src/commands/blob-buckets.js.map +1 -0
- package/dist/src/commands/catalog.d.ts +2 -0
- package/dist/src/commands/catalog.js +37 -38
- package/dist/src/commands/catalog.js.map +1 -1
- package/dist/src/commands/collection-type-configs.d.ts +2 -0
- package/dist/src/commands/collection-type-configs.js +84 -0
- package/dist/src/commands/collection-type-configs.js.map +1 -0
- package/dist/src/commands/collections.d.ts +2 -0
- package/dist/src/commands/collections.js +565 -0
- package/dist/src/commands/collections.js.map +1 -0
- package/dist/src/commands/comparisons.d.ts +2 -0
- package/dist/src/commands/comparisons.js +6 -6
- package/dist/src/commands/comparisons.js.map +1 -1
- package/dist/src/commands/config.d.ts +46 -0
- package/dist/src/commands/config.js +465 -0
- package/dist/src/commands/config.js.map +1 -0
- package/dist/src/commands/connections.d.ts +2 -0
- package/dist/src/commands/connections.js +100 -0
- package/dist/src/commands/connections.js.map +1 -0
- package/dist/src/commands/cron-triggers.d.ts +2 -0
- package/dist/src/commands/cron-triggers.js +265 -0
- package/dist/src/commands/cron-triggers.js.map +1 -0
- package/dist/src/commands/database-type-configs.d.ts +2 -0
- package/dist/src/commands/database-type-configs.js +163 -0
- package/dist/src/commands/database-type-configs.js.map +1 -0
- package/dist/src/commands/database-types.d.ts +2 -0
- package/dist/src/commands/database-types.js +171 -0
- package/dist/src/commands/database-types.js.map +1 -0
- package/dist/src/commands/databases.d.ts +65 -0
- package/dist/src/commands/databases.js +1859 -238
- package/dist/src/commands/databases.js.map +1 -1
- package/dist/src/commands/documents.d.ts +2 -0
- package/dist/src/commands/documents.js +2062 -19
- package/dist/src/commands/documents.js.map +1 -1
- package/dist/src/commands/email-templates.d.ts +2 -0
- package/dist/src/commands/email-templates.js +174 -0
- package/dist/src/commands/email-templates.js.map +1 -0
- package/dist/src/commands/env.d.ts +23 -0
- package/dist/src/commands/env.js +385 -0
- package/dist/src/commands/env.js.map +1 -0
- package/dist/src/commands/feature-flags.d.ts +14 -0
- package/dist/src/commands/feature-flags.js +116 -0
- package/dist/src/commands/feature-flags.js.map +1 -0
- package/dist/src/commands/functions.d.ts +20 -0
- package/dist/src/commands/functions.js +672 -0
- package/dist/src/commands/functions.js.map +1 -0
- package/dist/src/commands/group-type-configs.d.ts +2 -0
- package/dist/src/commands/group-type-configs.js +86 -0
- package/dist/src/commands/group-type-configs.js.map +1 -0
- package/dist/src/commands/groups.d.ts +2 -0
- package/dist/src/commands/groups.js +39 -108
- package/dist/src/commands/groups.js.map +1 -1
- package/dist/src/commands/guides.d.ts +223 -0
- package/dist/src/commands/guides.js +617 -65
- package/dist/src/commands/guides.js.map +1 -1
- package/dist/src/commands/init.d.ts +37 -0
- package/dist/src/commands/init.js +1693 -208
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/integrations.d.ts +2 -0
- package/dist/src/commands/integrations.js +402 -182
- package/dist/src/commands/integrations.js.map +1 -1
- package/dist/src/commands/llm.d.ts +2 -0
- package/dist/src/commands/llm.js +13 -8
- package/dist/src/commands/llm.js.map +1 -1
- package/dist/src/commands/locks.d.ts +8 -0
- package/dist/src/commands/locks.js +160 -0
- package/dist/src/commands/locks.js.map +1 -0
- package/dist/src/commands/metadata-category-configs.d.ts +12 -0
- package/dist/src/commands/metadata-category-configs.js +112 -0
- package/dist/src/commands/metadata-category-configs.js.map +1 -0
- package/dist/src/commands/metadata.d.ts +2 -0
- package/dist/src/commands/metadata.js +281 -0
- package/dist/src/commands/metadata.js.map +1 -0
- package/dist/src/commands/prompts.d.ts +2 -0
- package/dist/src/commands/prompts.js +275 -621
- package/dist/src/commands/prompts.js.map +1 -1
- package/dist/src/commands/rule-sets.d.ts +3 -0
- package/dist/src/commands/rule-sets.js +137 -147
- package/dist/src/commands/rule-sets.js.map +1 -1
- package/dist/src/commands/scripts.d.ts +30 -0
- package/dist/src/commands/scripts.js +679 -0
- package/dist/src/commands/scripts.js.map +1 -0
- package/dist/src/commands/secrets.d.ts +2 -0
- package/dist/src/commands/secrets.js +108 -0
- package/dist/src/commands/secrets.js.map +1 -0
- package/dist/src/commands/sessions.d.ts +2 -0
- package/dist/src/commands/sessions.js +75 -0
- package/dist/src/commands/sessions.js.map +1 -0
- package/dist/src/commands/settings.d.ts +18 -0
- package/dist/src/commands/settings.js +54 -0
- package/dist/src/commands/settings.js.map +1 -0
- package/dist/src/commands/skill.d.ts +2 -0
- package/dist/src/commands/skill.js +29 -0
- package/dist/src/commands/skill.js.map +1 -0
- package/dist/src/commands/sync-app-settings.d.ts +158 -0
- package/dist/src/commands/sync-app-settings.js +328 -0
- package/dist/src/commands/sync-app-settings.js.map +1 -0
- package/dist/src/commands/sync.d.ts +2514 -0
- package/dist/src/commands/sync.js +16106 -848
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/commands/tokens.d.ts +2 -0
- package/dist/src/commands/tokens.js +130 -21
- package/dist/src/commands/tokens.js.map +1 -1
- package/dist/src/commands/users.d.ts +2 -0
- package/dist/src/commands/users.js +532 -23
- package/dist/src/commands/users.js.map +1 -1
- package/dist/src/commands/vars.d.ts +8 -0
- package/dist/src/commands/vars.js +96 -0
- package/dist/src/commands/vars.js.map +1 -0
- package/dist/src/commands/waitlist.d.ts +2 -0
- package/dist/src/commands/waitlist.js +10 -10
- package/dist/src/commands/waitlist.js.map +1 -1
- package/dist/src/commands/webhooks.d.ts +2 -0
- package/dist/src/commands/webhooks.js +562 -0
- package/dist/src/commands/webhooks.js.map +1 -0
- package/dist/src/commands/workflows.d.ts +116 -0
- package/dist/src/commands/workflows.js +1638 -729
- package/dist/src/commands/workflows.js.map +1 -1
- package/dist/src/lib/access-rule-display.d.ts +21 -0
- package/dist/src/lib/access-rule-display.js +34 -0
- package/dist/src/lib/access-rule-display.js.map +1 -0
- package/dist/src/lib/api-client.d.ts +2147 -0
- package/dist/src/lib/api-client.js +2042 -160
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/app-match-guard.d.ts +44 -0
- package/dist/src/lib/app-match-guard.js +72 -0
- package/dist/src/lib/app-match-guard.js.map +1 -0
- package/dist/src/lib/app-settings-descriptor.d.ts +263 -0
- package/dist/src/lib/app-settings-descriptor.js +584 -0
- package/dist/src/lib/app-settings-descriptor.js.map +1 -0
- package/dist/src/lib/auth-flow.d.ts +8 -0
- package/dist/src/lib/batch.d.ts +26 -0
- package/dist/src/lib/batch.js +32 -0
- package/dist/src/lib/batch.js.map +1 -0
- package/dist/src/lib/block-layout.d.ts +160 -0
- package/dist/src/lib/block-layout.js +451 -0
- package/dist/src/lib/block-layout.js.map +1 -0
- package/dist/src/lib/block-selector.d.ts +58 -0
- package/dist/src/lib/block-selector.js +92 -0
- package/dist/src/lib/block-selector.js.map +1 -0
- package/dist/src/lib/canonical-json.d.ts +12 -0
- package/dist/src/lib/canonical-json.js +35 -0
- package/dist/src/lib/canonical-json.js.map +1 -0
- package/dist/src/lib/channel.d.ts +30 -0
- package/dist/src/lib/channel.js +68 -0
- package/dist/src/lib/channel.js.map +1 -0
- package/dist/src/lib/cli-manifest.d.ts +68 -0
- package/dist/src/lib/cli-manifest.js +71 -0
- package/dist/src/lib/cli-manifest.js.map +1 -0
- package/dist/src/lib/codegen-shared/generatedFiles.d.ts +101 -0
- package/dist/src/lib/codegen-shared/generatedFiles.js +191 -0
- package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -0
- package/dist/src/lib/codegen-shared/prettierStable.d.ts +262 -0
- package/dist/src/lib/codegen-shared/prettierStable.js +610 -0
- package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -0
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.d.ts +38 -0
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js +46 -0
- package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js.map +1 -0
- package/dist/src/lib/config-json-field.d.ts +28 -0
- package/dist/src/lib/config-json-field.js +56 -0
- package/dist/src/lib/config-json-field.js.map +1 -0
- package/dist/src/lib/config-object-descriptor.d.ts +127 -0
- package/dist/src/lib/config-object-descriptor.js +696 -0
- package/dist/src/lib/config-object-descriptor.js.map +1 -0
- package/dist/src/lib/config-payload.d.ts +85 -0
- package/dist/src/lib/config-payload.js +116 -0
- package/dist/src/lib/config-payload.js.map +1 -0
- package/dist/src/lib/config-surface.d.ts +140 -0
- package/dist/src/lib/config-surface.js +317 -0
- package/dist/src/lib/config-surface.js.map +1 -0
- package/dist/src/lib/config-toml.d.ts +10 -0
- package/dist/src/lib/config-toml.js +42 -0
- package/dist/src/lib/config-toml.js.map +1 -0
- package/dist/src/lib/config.d.ts +71 -0
- package/dist/src/lib/config.js +71 -68
- package/dist/src/lib/config.js.map +1 -1
- package/dist/src/lib/confirm-prompt.d.ts +83 -0
- package/dist/src/lib/confirm-prompt.js +110 -0
- package/dist/src/lib/confirm-prompt.js.map +1 -0
- package/dist/src/lib/constants.d.ts +11 -0
- package/dist/src/lib/constants.js +12 -0
- package/dist/src/lib/constants.js.map +1 -0
- package/dist/src/lib/crash-handlers.d.ts +20 -0
- package/dist/src/lib/crash-handlers.js +49 -0
- package/dist/src/lib/crash-handlers.js.map +1 -0
- package/dist/src/lib/credentials-store.d.ts +104 -0
- package/dist/src/lib/credentials-store.js +336 -0
- package/dist/src/lib/credentials-store.js.map +1 -0
- package/dist/src/lib/csv.d.ts +47 -0
- package/dist/src/lib/csv.js +172 -0
- package/dist/src/lib/csv.js.map +1 -0
- package/dist/src/lib/data-input.d.ts +23 -0
- package/dist/src/lib/data-input.js +50 -0
- package/dist/src/lib/data-input.js.map +1 -0
- package/dist/src/lib/db-codegen/dbFingerprint.d.ts +10 -0
- package/dist/src/lib/db-codegen/dbFingerprint.js +17 -0
- package/dist/src/lib/db-codegen/dbFingerprint.js.map +1 -0
- package/dist/src/lib/db-codegen/dbGenerator.d.ts +67 -0
- package/dist/src/lib/db-codegen/dbGenerator.js +170 -0
- package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -0
- package/dist/src/lib/db-codegen/dbNaming.d.ts +87 -0
- package/dist/src/lib/db-codegen/dbNaming.js +180 -0
- package/dist/src/lib/db-codegen/dbNaming.js.map +1 -0
- package/dist/src/lib/db-codegen/dbTemplates.d.ts +272 -0
- package/dist/src/lib/db-codegen/dbTemplates.js +480 -0
- package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -0
- package/dist/src/lib/db-codegen/dbTsTypes.d.ts +73 -0
- package/dist/src/lib/db-codegen/dbTsTypes.js +139 -0
- package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -0
- package/dist/src/lib/db-codegen/dbTypeIR.d.ts +146 -0
- package/dist/src/lib/db-codegen/dbTypeIR.js +517 -0
- package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -0
- package/dist/src/lib/db-codegen/generated-operation-def-descriptor.d.ts +112 -0
- package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js +211 -0
- package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js.map +1 -0
- package/dist/src/lib/document-export-permissions.d.ts +30 -0
- package/dist/src/lib/document-export-permissions.js +54 -0
- package/dist/src/lib/document-export-permissions.js.map +1 -0
- package/dist/src/lib/env-resolver-core.d.ts +253 -0
- package/dist/src/lib/env-resolver-core.js +459 -0
- package/dist/src/lib/env-resolver-core.js.map +1 -0
- package/dist/src/lib/env-resolver.d.ts +99 -0
- package/dist/src/lib/env-resolver.js +153 -0
- package/dist/src/lib/env-resolver.js.map +1 -0
- package/dist/src/lib/fetch.d.ts +5 -0
- package/dist/src/lib/function-bundle.d.ts +141 -0
- package/dist/src/lib/function-bundle.js +333 -0
- package/dist/src/lib/function-bundle.js.map +1 -0
- package/dist/src/lib/function-collect.d.ts +123 -0
- package/dist/src/lib/function-collect.js +594 -0
- package/dist/src/lib/function-collect.js.map +1 -0
- package/dist/src/lib/function-db-types.d.ts +187 -0
- package/dist/src/lib/function-db-types.js +782 -0
- package/dist/src/lib/function-db-types.js.map +1 -0
- package/dist/src/lib/function-document-types.d.ts +50 -0
- package/dist/src/lib/function-document-types.js +163 -0
- package/dist/src/lib/function-document-types.js.map +1 -0
- package/dist/src/lib/function-grants-preflight.d.ts +64 -0
- package/dist/src/lib/function-grants-preflight.js +100 -0
- package/dist/src/lib/function-grants-preflight.js.map +1 -0
- package/dist/src/lib/function-log-tail.d.ts +83 -0
- package/dist/src/lib/function-log-tail.js +115 -0
- package/dist/src/lib/function-log-tail.js.map +1 -0
- package/dist/src/lib/function-schema-codegen.d.ts +118 -0
- package/dist/src/lib/function-schema-codegen.js +402 -0
- package/dist/src/lib/function-schema-codegen.js.map +1 -0
- package/dist/src/lib/function-sync.d.ts +263 -0
- package/dist/src/lib/function-sync.js +604 -0
- package/dist/src/lib/function-sync.js.map +1 -0
- package/dist/src/lib/function-triggers.d.ts +66 -0
- package/dist/src/lib/function-triggers.js +285 -0
- package/dist/src/lib/function-triggers.js.map +1 -0
- package/dist/src/lib/function-typecheck.d.ts +86 -0
- package/dist/src/lib/function-typecheck.js +370 -0
- package/dist/src/lib/function-typecheck.js.map +1 -0
- package/dist/src/lib/generated-allowlist.d.ts +28 -0
- package/dist/src/lib/generated-allowlist.js +281 -0
- package/dist/src/lib/generated-allowlist.js.map +1 -0
- package/dist/src/lib/generated-config-surfaces.d.ts +1445 -0
- package/dist/src/lib/generated-config-surfaces.js +5836 -0
- package/dist/src/lib/generated-config-surfaces.js.map +1 -0
- package/dist/src/lib/generated-sdk-types.d.ts +12 -0
- package/dist/src/lib/generated-sdk-types.js +13 -0
- package/dist/src/lib/generated-sdk-types.js.map +1 -0
- package/dist/src/lib/generated-template-lint.d.ts +212 -0
- package/dist/src/lib/generated-template-lint.js +624 -0
- package/dist/src/lib/generated-template-lint.js.map +1 -0
- package/dist/src/lib/generated-workflow-model-fields.d.ts +20 -0
- package/dist/src/lib/generated-workflow-model-fields.js +53 -0
- package/dist/src/lib/generated-workflow-model-fields.js.map +1 -0
- package/dist/src/lib/google-client-secret-status.d.ts +35 -0
- package/dist/src/lib/google-client-secret-status.js +56 -0
- package/dist/src/lib/google-client-secret-status.js.map +1 -0
- package/dist/src/lib/init-adopt.d.ts +16 -0
- package/dist/src/lib/init-adopt.js +34 -0
- package/dist/src/lib/init-adopt.js.map +1 -0
- package/dist/src/lib/init-assets.d.ts +39 -0
- package/dist/src/lib/init-assets.js +97 -0
- package/dist/src/lib/init-assets.js.map +1 -0
- package/dist/src/lib/init-client-platforms.d.ts +14 -0
- package/dist/src/lib/init-client-platforms.js +71 -0
- package/dist/src/lib/init-client-platforms.js.map +1 -0
- package/dist/src/lib/init-config.d.ts +98 -0
- package/dist/src/lib/init-config.js +186 -0
- package/dist/src/lib/init-config.js.map +1 -0
- package/dist/src/lib/init-email-redirect-uris.d.ts +37 -0
- package/dist/src/lib/init-email-redirect-uris.js +46 -0
- package/dist/src/lib/init-email-redirect-uris.js.map +1 -0
- package/dist/src/lib/init-ios-links.d.ts +91 -0
- package/dist/src/lib/init-ios-links.js +219 -0
- package/dist/src/lib/init-ios-links.js.map +1 -0
- package/dist/src/lib/init-plan.d.ts +80 -0
- package/dist/src/lib/init-plan.js +95 -0
- package/dist/src/lib/init-plan.js.map +1 -0
- package/dist/src/lib/init-production-env.d.ts +48 -0
- package/dist/src/lib/init-production-env.js +59 -0
- package/dist/src/lib/init-production-env.js.map +1 -0
- package/dist/src/lib/init-schema.d.ts +74 -0
- package/dist/src/lib/init-schema.js +358 -0
- package/dist/src/lib/init-schema.js.map +1 -0
- package/dist/src/lib/init-xcode.d.ts +34 -0
- package/dist/src/lib/init-xcode.js +138 -0
- package/dist/src/lib/init-xcode.js.map +1 -0
- package/dist/src/lib/integration-request-config.d.ts +30 -0
- package/dist/src/lib/integration-request-config.js +145 -0
- package/dist/src/lib/integration-request-config.js.map +1 -0
- package/dist/src/lib/integration-selector.d.ts +42 -0
- package/dist/src/lib/integration-selector.js +46 -0
- package/dist/src/lib/integration-selector.js.map +1 -0
- package/dist/src/lib/ios-app-id.d.ts +34 -0
- package/dist/src/lib/ios-app-id.js +69 -0
- package/dist/src/lib/ios-app-id.js.map +1 -0
- package/dist/src/lib/local-state.d.ts +55 -0
- package/dist/src/lib/local-state.js +167 -0
- package/dist/src/lib/local-state.js.map +1 -0
- package/dist/src/lib/local-test-cases.d.ts +63 -0
- package/dist/src/lib/local-test-cases.js +136 -0
- package/dist/src/lib/local-test-cases.js.map +1 -0
- package/dist/src/lib/log-inspection.d.ts +680 -0
- package/dist/src/lib/log-inspection.js +784 -0
- package/dist/src/lib/log-inspection.js.map +1 -0
- package/dist/src/lib/migration-nag.d.ts +49 -0
- package/dist/src/lib/migration-nag.js +164 -0
- package/dist/src/lib/migration-nag.js.map +1 -0
- package/dist/src/lib/object-status-filter.d.ts +22 -0
- package/dist/src/lib/object-status-filter.js +45 -0
- package/dist/src/lib/object-status-filter.js.map +1 -0
- package/dist/src/lib/output.d.ts +109 -0
- package/dist/src/lib/output.js +191 -8
- package/dist/src/lib/output.js.map +1 -1
- package/dist/src/lib/package-manager.d.ts +140 -0
- package/dist/src/lib/package-manager.js +305 -0
- package/dist/src/lib/package-manager.js.map +1 -0
- package/dist/src/lib/paginate.d.ts +83 -0
- package/dist/src/lib/paginate.js +95 -0
- package/dist/src/lib/paginate.js.map +1 -0
- package/dist/src/lib/platform-owned.d.ts +63 -0
- package/dist/src/lib/platform-owned.js +85 -0
- package/dist/src/lib/platform-owned.js.map +1 -0
- package/dist/src/lib/project-config.d.ts +122 -0
- package/dist/src/lib/project-config.js +244 -0
- package/dist/src/lib/project-config.js.map +1 -0
- package/dist/src/lib/query-operators.d.ts +43 -0
- package/dist/src/lib/query-operators.js +80 -0
- package/dist/src/lib/query-operators.js.map +1 -0
- package/dist/src/lib/record-filter.d.ts +18 -0
- package/dist/src/lib/record-filter.js +55 -0
- package/dist/src/lib/record-filter.js.map +1 -0
- package/dist/src/lib/refresh-admin-credentials.d.ts +65 -0
- package/dist/src/lib/refresh-admin-credentials.js +103 -0
- package/dist/src/lib/refresh-admin-credentials.js.map +1 -0
- package/dist/src/lib/resolve-init-dev-port.d.ts +56 -0
- package/dist/src/lib/resolve-init-dev-port.js +55 -0
- package/dist/src/lib/resolve-init-dev-port.js.map +1 -0
- package/dist/src/lib/resolve-init-server.d.ts +64 -0
- package/dist/src/lib/resolve-init-server.js +77 -0
- package/dist/src/lib/resolve-init-server.js.map +1 -0
- package/dist/src/lib/resolve-platform.d.ts +74 -0
- package/dist/src/lib/resolve-platform.js +105 -0
- package/dist/src/lib/resolve-platform.js.map +1 -0
- package/dist/src/lib/run-status.d.ts +19 -0
- package/dist/src/lib/run-status.generated.d.ts +39 -0
- package/dist/src/lib/run-status.generated.js +66 -0
- package/dist/src/lib/run-status.generated.js.map +1 -0
- package/dist/src/lib/run-status.js +19 -0
- package/dist/src/lib/run-status.js.map +1 -0
- package/dist/src/lib/server-text-normalization.d.ts +51 -0
- package/dist/src/lib/server-text-normalization.js +90 -0
- package/dist/src/lib/server-text-normalization.js.map +1 -0
- package/dist/src/lib/server-url.d.ts +22 -0
- package/dist/src/lib/server-url.js +33 -0
- package/dist/src/lib/server-url.js.map +1 -0
- package/dist/src/lib/signing-secret-status.d.ts +81 -0
- package/dist/src/lib/signing-secret-status.js +116 -0
- package/dist/src/lib/signing-secret-status.js.map +1 -0
- package/dist/src/lib/skill-installer.d.ts +25 -0
- package/dist/src/lib/skill-installer.js +266 -0
- package/dist/src/lib/skill-installer.js.map +1 -0
- package/dist/src/lib/snapshots.d.ts +98 -0
- package/dist/src/lib/snapshots.js +294 -0
- package/dist/src/lib/snapshots.js.map +1 -0
- package/dist/src/lib/swift-codegen/dbGenerator.d.ts +113 -0
- package/dist/src/lib/swift-codegen/dbGenerator.js +914 -0
- package/dist/src/lib/swift-codegen/dbGenerator.js.map +1 -0
- package/dist/src/lib/swift-codegen/dbSwiftTypes.d.ts +42 -0
- package/dist/src/lib/swift-codegen/dbSwiftTypes.js +100 -0
- package/dist/src/lib/swift-codegen/dbSwiftTypes.js.map +1 -0
- package/dist/src/lib/swift-codegen/generator.d.ts +94 -0
- package/dist/src/lib/swift-codegen/generator.js +440 -0
- package/dist/src/lib/swift-codegen/generator.js.map +1 -0
- package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +72 -0
- package/dist/src/lib/swift-codegen/schemaToSwift.js +644 -0
- package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -0
- package/dist/src/lib/swift-codegen/siblingSymbols.d.ts +94 -0
- package/dist/src/lib/swift-codegen/siblingSymbols.js +155 -0
- package/dist/src/lib/swift-codegen/siblingSymbols.js.map +1 -0
- package/dist/src/lib/swift-codegen/swiftNaming.d.ts +85 -0
- package/dist/src/lib/swift-codegen/swiftNaming.js +198 -0
- package/dist/src/lib/swift-codegen/swiftNaming.js.map +1 -0
- package/dist/src/lib/sync-dir-selector.d.ts +21 -0
- package/dist/src/lib/sync-dir-selector.js +30 -0
- package/dist/src/lib/sync-dir-selector.js.map +1 -0
- package/dist/src/lib/sync-paths.d.ts +123 -0
- package/dist/src/lib/sync-paths.js +193 -0
- package/dist/src/lib/sync-paths.js.map +1 -0
- package/dist/src/lib/sync-resource-types.d.ts +563 -0
- package/dist/src/lib/sync-resource-types.js +1073 -0
- package/dist/src/lib/sync-resource-types.js.map +1 -0
- package/dist/src/lib/sync-selectors.d.ts +95 -0
- package/dist/src/lib/sync-selectors.js +228 -0
- package/dist/src/lib/sync-selectors.js.map +1 -0
- package/dist/src/lib/template.d.ts +170 -0
- package/dist/src/lib/template.js +484 -68
- package/dist/src/lib/template.js.map +1 -1
- package/dist/src/lib/test-case-file-names.d.ts +40 -0
- package/dist/src/lib/test-case-file-names.js +91 -0
- package/dist/src/lib/test-case-file-names.js.map +1 -0
- package/dist/src/lib/test-case-keys.d.ts +29 -0
- package/dist/src/lib/test-case-keys.js +55 -0
- package/dist/src/lib/test-case-keys.js.map +1 -0
- package/dist/src/lib/test-case-variables.d.ts +29 -0
- package/dist/src/lib/test-case-variables.js +71 -0
- package/dist/src/lib/test-case-variables.js.map +1 -0
- package/dist/src/lib/token-inject.d.ts +56 -0
- package/dist/src/lib/token-inject.js +204 -0
- package/dist/src/lib/token-inject.js.map +1 -0
- package/dist/src/lib/toml-database-config.d.ts +123 -0
- package/dist/src/lib/toml-database-config.js +544 -0
- package/dist/src/lib/toml-database-config.js.map +1 -0
- package/dist/src/lib/toml-metadata-config.d.ts +151 -0
- package/dist/src/lib/toml-metadata-config.js +476 -0
- package/dist/src/lib/toml-metadata-config.js.map +1 -0
- package/dist/src/lib/toml-native-form.d.ts +46 -0
- package/dist/src/lib/toml-native-form.js +78 -0
- package/dist/src/lib/toml-native-form.js.map +1 -0
- package/dist/src/lib/toml-params-validator.d.ts +129 -0
- package/dist/src/lib/toml-params-validator.js +298 -0
- package/dist/src/lib/toml-params-validator.js.map +1 -0
- package/dist/src/lib/toml-scalar-edit.d.ts +43 -0
- package/dist/src/lib/toml-scalar-edit.js +283 -0
- package/dist/src/lib/toml-scalar-edit.js.map +1 -0
- package/dist/src/lib/user-selector.d.ts +24 -0
- package/dist/src/lib/user-selector.js +33 -0
- package/dist/src/lib/user-selector.js.map +1 -0
- package/dist/src/lib/version-check.d.ts +35 -0
- package/dist/src/lib/version-check.js +241 -0
- package/dist/src/lib/version-check.js.map +1 -0
- package/dist/src/lib/watch.d.ts +121 -0
- package/dist/src/lib/watch.js +169 -0
- package/dist/src/lib/watch.js.map +1 -0
- package/dist/src/lib/web-url.d.ts +40 -0
- package/dist/src/lib/web-url.js +76 -0
- package/dist/src/lib/web-url.js.map +1 -0
- package/dist/src/lib/workflow-apply.d.ts +110 -0
- package/dist/src/lib/workflow-apply.js +164 -0
- package/dist/src/lib/workflow-apply.js.map +1 -0
- package/dist/src/lib/workflow-codegen/generated-schema-descriptor.d.ts +129 -0
- package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js +269 -0
- package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js.map +1 -0
- package/dist/src/lib/workflow-codegen/generator.d.ts +96 -0
- package/dist/src/lib/workflow-codegen/generator.js +361 -0
- package/dist/src/lib/workflow-codegen/generator.js.map +1 -0
- package/dist/src/lib/workflow-codegen/invokerIR.d.ts +94 -0
- package/dist/src/lib/workflow-codegen/invokerIR.js +76 -0
- package/dist/src/lib/workflow-codegen/invokerIR.js.map +1 -0
- package/dist/src/lib/workflow-codegen/naming.d.ts +33 -0
- package/dist/src/lib/workflow-codegen/naming.js +81 -0
- package/dist/src/lib/workflow-codegen/naming.js.map +1 -0
- package/dist/src/lib/workflow-codegen/schemaToTs.d.ts +80 -0
- package/dist/src/lib/workflow-codegen/schemaToTs.js +303 -0
- package/dist/src/lib/workflow-codegen/schemaToTs.js.map +1 -0
- package/dist/src/lib/workflow-config-apply.d.ts +70 -0
- package/dist/src/lib/workflow-config-apply.js +137 -0
- package/dist/src/lib/workflow-config-apply.js.map +1 -0
- package/dist/src/lib/workflow-config-sidecar.d.ts +63 -0
- package/dist/src/lib/workflow-config-sidecar.js +96 -0
- package/dist/src/lib/workflow-config-sidecar.js.map +1 -0
- package/dist/src/lib/workflow-defaults.d.ts +29 -0
- package/dist/src/lib/workflow-defaults.js +41 -0
- package/dist/src/lib/workflow-defaults.js.map +1 -0
- package/dist/src/lib/workflow-field-descriptor.d.ts +91 -0
- package/dist/src/lib/workflow-field-descriptor.js +153 -0
- package/dist/src/lib/workflow-field-descriptor.js.map +1 -0
- package/dist/src/lib/workflow-fragments.d.ts +64 -0
- package/dist/src/lib/workflow-fragments.js +342 -0
- package/dist/src/lib/workflow-fragments.js.map +1 -0
- package/dist/src/lib/workflow-include-preserve.d.ts +76 -0
- package/dist/src/lib/workflow-include-preserve.js +286 -0
- package/dist/src/lib/workflow-include-preserve.js.map +1 -0
- package/dist/src/lib/workflow-payload.d.ts +98 -0
- package/dist/src/lib/workflow-payload.js +178 -0
- package/dist/src/lib/workflow-payload.js.map +1 -0
- package/dist/src/lib/workflow-toml-validator.d.ts +207 -0
- package/dist/src/lib/workflow-toml-validator.js +762 -0
- package/dist/src/lib/workflow-toml-validator.js.map +1 -0
- package/dist/src/lib/workflow-usage.d.ts +198 -0
- package/dist/src/lib/workflow-usage.js +312 -0
- package/dist/src/lib/workflow-usage.js.map +1 -0
- package/dist/src/types/index.d.ts +591 -0
- package/dist/src/validators.d.ts +65 -0
- package/dist/src/validators.js +64 -0
- package/dist/src/validators.js.map +1 -0
- package/package.json +34 -9
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared Primitive environment resolver (#2873).
|
|
3
|
+
*
|
|
4
|
+
* Three surfaces have to agree on which backend/app a project is pointed at:
|
|
5
|
+
* the CLI, the Vue build (`primitive-app`'s `primitiveEnv()` plugin), and the
|
|
6
|
+
* Swift template's pre-build script. This module is the single algorithm they
|
|
7
|
+
* share. The CLI owns it; `packages/primitive-app` carries a byte-identical
|
|
8
|
+
* GENERATED copy (`cli/scripts/gen-primitive-env-resolver.mjs`, checked for
|
|
9
|
+
* freshness by `cli/tests/unit/env-resolver-copy-drift-guard.test.ts`); the
|
|
10
|
+
* Swift script is an independent bash+python3 port pinned by a parity test.
|
|
11
|
+
*
|
|
12
|
+
* ── COPYABILITY (load-bearing) ────────────────────────────────────────────
|
|
13
|
+
* This file MUST stay self-contained: node builtins only, ZERO relative
|
|
14
|
+
* imports. The generator copies it verbatim into a package that cannot depend
|
|
15
|
+
* on the CLI, so any `./x.js` import here would break that copy at runtime.
|
|
16
|
+
* The drift guard asserts this.
|
|
17
|
+
*
|
|
18
|
+
* Scope: config discovery, the schema `version` check, structural validation,
|
|
19
|
+
* the local selection, the precedence, and the http→ws scheme swap. It
|
|
20
|
+
* deliberately does NOT duplicate the CLI's full field-level validation
|
|
21
|
+
* (`validateProjectConfig` in `project-config.ts`) — the CLI wrapper runs that
|
|
22
|
+
* first, and the other readers only need "version understood, shape sane, fail
|
|
23
|
+
* loudly otherwise".
|
|
24
|
+
*
|
|
25
|
+
* Precedence (one order, everywhere):
|
|
26
|
+
* 1. an explicit name (`--env` / `--primitive-env`)
|
|
27
|
+
* 2. PRIMITIVE_ENV (per-invocation intent, keeps CI working)
|
|
28
|
+
* 3. .primitive/local.json (this machine's `primitive env use`)
|
|
29
|
+
* 4. defaultEnvironment (the committed team default)
|
|
30
|
+
* 5. the sole environment, if there is exactly one
|
|
31
|
+
*/
|
|
32
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
33
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
34
|
+
/** Schema version of `primitive/config.json` this core understands. */
|
|
35
|
+
export const PRIMITIVE_CONFIG_VERSION = 1;
|
|
36
|
+
/** Schema version of `.primitive/local.json` this core writes and reads. */
|
|
37
|
+
export const PRIMITIVE_LOCAL_STATE_VERSION = 1;
|
|
38
|
+
/**
|
|
39
|
+
* The two directories, split apart by #3153 so one name never means two
|
|
40
|
+
* things: `primitive/` is the COMMITTED tree (the config and every
|
|
41
|
+
* environment's TOML), `.primitive/` is MACHINE-LOCAL state (credentials, this
|
|
42
|
+
* machine's selection, snapshot backups) and is gitignored whole.
|
|
43
|
+
*/
|
|
44
|
+
export const PROJECT_TREE_DIR = "primitive";
|
|
45
|
+
export const PROJECT_LOCAL_STATE_DIR = ".primitive";
|
|
46
|
+
export const PROJECT_CONFIG_FILENAME = "config.json";
|
|
47
|
+
export const LOCAL_STATE_FILENAME = "local.json";
|
|
48
|
+
export const PROJECT_CONFIG_DISPLAY_NAME = "primitive/config.json";
|
|
49
|
+
export const LOCAL_STATE_DISPLAY_NAME = ".primitive/local.json";
|
|
50
|
+
/** The docs-site slug of the migration procedure (#3155 publishes the page). */
|
|
51
|
+
export const MIGRATION_GUIDE_SLUG = "getting-started/cli-project-migration";
|
|
52
|
+
/**
|
|
53
|
+
* The one refusal for a project still holding the pre-#3153 layout.
|
|
54
|
+
*
|
|
55
|
+
* There is no fallback read: a tool that quietly read `.primitive/sync/` after
|
|
56
|
+
* the move would let a half-migrated project look healthy while push and pull
|
|
57
|
+
* disagreed about which tree is the truth. So every reader — this core, the
|
|
58
|
+
* generated Vite-plugin copy, the Swift pre-build script — stops here and names
|
|
59
|
+
* the document that says what to move where.
|
|
60
|
+
*/
|
|
61
|
+
export function staleLayoutMessage(detail) {
|
|
62
|
+
return (`${detail} The Primitive configuration tree moved out of the hidden ` +
|
|
63
|
+
`directory: the config is now ${PROJECT_CONFIG_DISPLAY_NAME} and each ` +
|
|
64
|
+
`environment's TOML is at primitive/<env>/, while .primitive/ keeps only ` +
|
|
65
|
+
`machine-local state. Nothing is read from either tree until the project ` +
|
|
66
|
+
`is migrated — follow ${MIGRATION_GUIDE_SLUG}.`);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The one refusal for a command run outside a Primitive project (#3154,
|
|
70
|
+
* intent criterion 5).
|
|
71
|
+
*
|
|
72
|
+
* There is exactly one way to resolve the configuration tree, the credentials
|
|
73
|
+
* and the app: the environment named by `primitive/config.json`. Outside a
|
|
74
|
+
* project there is no such thing, and the CLI says so once, in these words,
|
|
75
|
+
* wherever the question is asked — the resolver core, the CLI's
|
|
76
|
+
* `requireCurrentEnvironment()`, and the credentials store.
|
|
77
|
+
*
|
|
78
|
+
* Two constraints on the wording, both test-asserted:
|
|
79
|
+
*
|
|
80
|
+
* - it names `primitive init`, the one command that creates what is missing;
|
|
81
|
+
* - it never names `primitive env add`, which after this change also fails
|
|
82
|
+
* outside a project — an error may only offer an invocation it does not
|
|
83
|
+
* itself block.
|
|
84
|
+
*/
|
|
85
|
+
export function missingConfigMessage(where) {
|
|
86
|
+
return (`No ${PROJECT_CONFIG_DISPLAY_NAME} found in ${where} or any parent directory. ` +
|
|
87
|
+
`Primitive commands run inside a Primitive project: it is where the CLI reads ` +
|
|
88
|
+
`the environment, the app that environment names, and the configuration tree ` +
|
|
89
|
+
`from. Run 'primitive init' to create one.`);
|
|
90
|
+
}
|
|
91
|
+
export class PrimitiveEnvError extends Error {
|
|
92
|
+
kind;
|
|
93
|
+
path;
|
|
94
|
+
constructor(kind, message, path) {
|
|
95
|
+
super(message);
|
|
96
|
+
this.name = "PrimitiveEnvError";
|
|
97
|
+
this.kind = kind;
|
|
98
|
+
this.path = path;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The app's web counterpart as a normalized ORIGIN, or undefined when the
|
|
103
|
+
* value cannot be one (#2982).
|
|
104
|
+
*
|
|
105
|
+
* Unlike `appId`/`appName`, a typed read is not enough. This value is not
|
|
106
|
+
* merely carried: the Swift app points its emailed sign-in link at
|
|
107
|
+
* `<webUrl>/oauth/callback` and trusts incoming universal links from the same
|
|
108
|
+
* origin, and BOTH jobs need an origin —
|
|
109
|
+
*
|
|
110
|
+
* - https except loopback, the rule the server applies to every redirect URI
|
|
111
|
+
* (`src/auth/redirect-uri.ts`): an origin that cannot be allow-listed turns
|
|
112
|
+
* every sign-in request into a 400, and a plain-http link would carry the
|
|
113
|
+
* magic token in clear;
|
|
114
|
+
* - no path, query or fragment: the web client serves its callback on its own
|
|
115
|
+
* origin plus `/oauth/callback`, which is also the exact path the
|
|
116
|
+
* `apple-app-site-association` component claims;
|
|
117
|
+
* - no credentials, which have no business in a link that goes out by email.
|
|
118
|
+
*
|
|
119
|
+
* `primitive env add --web-url` and the project-config validation reject those
|
|
120
|
+
* shapes with a field-named error, but neither is on the path from a
|
|
121
|
+
* hand-edited `.primitive/config.json` to an Xcode build: the Swift template's
|
|
122
|
+
* pre-build script reads the file directly. So every reader that feeds
|
|
123
|
+
* `primitive.json` applies the contract, and a value that misses it is read as
|
|
124
|
+
* "this environment has no web counterpart" — code-only email, no trusted
|
|
125
|
+
* origin, nothing silently pointed at the wrong URL.
|
|
126
|
+
*
|
|
127
|
+
* The message-producing twin of this rule lives in `cli/src/lib/web-url.ts`;
|
|
128
|
+
* this file cannot import it (see COPYABILITY above), and a test pins that the
|
|
129
|
+
* two agree.
|
|
130
|
+
*/
|
|
131
|
+
export function normalizeWebOrigin(value) {
|
|
132
|
+
if (typeof value !== "string")
|
|
133
|
+
return undefined;
|
|
134
|
+
const trimmed = value.trim();
|
|
135
|
+
if (!trimmed)
|
|
136
|
+
return undefined;
|
|
137
|
+
let url;
|
|
138
|
+
try {
|
|
139
|
+
url = new URL(trimmed);
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
if (url.protocol !== "https:" && url.protocol !== "http:")
|
|
145
|
+
return undefined;
|
|
146
|
+
if (url.protocol === "http:" &&
|
|
147
|
+
url.hostname !== "localhost" &&
|
|
148
|
+
url.hostname !== "127.0.0.1") {
|
|
149
|
+
return undefined;
|
|
150
|
+
}
|
|
151
|
+
if (url.username || url.password)
|
|
152
|
+
return undefined;
|
|
153
|
+
if (url.pathname !== "/" && url.pathname !== "")
|
|
154
|
+
return undefined;
|
|
155
|
+
if (url.search || url.hash)
|
|
156
|
+
return undefined;
|
|
157
|
+
return url.origin;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* The one remedy for an environment that names no app (#3152), shared by every
|
|
161
|
+
* reader that can hit it: this core, the CLI's `validateProjectConfig`, the
|
|
162
|
+
* Swift template's pre-build script, and the Vue template's cf-deploy.
|
|
163
|
+
*
|
|
164
|
+
* Two constraints on the wording, both test-asserted:
|
|
165
|
+
*
|
|
166
|
+
* - it never says `primitive env add <name>`, which REFUSES an environment
|
|
167
|
+
* name that already exists — the shape this error is always about;
|
|
168
|
+
* - it names no command the failure itself blocks. The CLI validates the
|
|
169
|
+
* project config before any command parses, so every `primitive` command
|
|
170
|
+
* run inside the broken project fails with this same error. The only
|
|
171
|
+
* invocation it may offer is one it says out loud to run elsewhere.
|
|
172
|
+
*/
|
|
173
|
+
export function missingAppIdMessage(name, configPath) {
|
|
174
|
+
const where = configPath
|
|
175
|
+
? `${PROJECT_CONFIG_DISPLAY_NAME} (${configPath})`
|
|
176
|
+
: PROJECT_CONFIG_DISPLAY_NAME;
|
|
177
|
+
return (`Environment "${name}" in ${where} has no "appId". ` +
|
|
178
|
+
`Every environment names exactly one app — add "appId": "<app-id>" to that environment in ${PROJECT_CONFIG_DISPLAY_NAME}. ` +
|
|
179
|
+
`Find the app id in the Primitive admin UI, with 'primitive apps list' run from another Primitive project, ` +
|
|
180
|
+
`or as the residual "currentAppId" in .primitive/credentials.json if this environment was ever pointed at an app by the retired per-machine app selection.`);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* An environment's `appId` as a usable string, or undefined when the value
|
|
184
|
+
* cannot be one. Non-string and blank-after-trim are both "no app named": a
|
|
185
|
+
* numeric or whitespace appId reaches a consumer as an app id it cannot use,
|
|
186
|
+
* which is the silent version of the failure this field exists to prevent.
|
|
187
|
+
*/
|
|
188
|
+
function readAppId(value) {
|
|
189
|
+
if (typeof value !== "string")
|
|
190
|
+
return undefined;
|
|
191
|
+
const trimmed = value.trim();
|
|
192
|
+
return trimmed || undefined;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Derives the WebSocket URL from the API URL. Every apiUrl/wsUrl pair in
|
|
196
|
+
* practice is the same host with the scheme swapped, so it is derived rather
|
|
197
|
+
* than authored — one less thing to get out of sync.
|
|
198
|
+
*/
|
|
199
|
+
export function deriveWsUrl(apiUrl) {
|
|
200
|
+
if (apiUrl.startsWith("https://"))
|
|
201
|
+
return "wss://" + apiUrl.slice("https://".length);
|
|
202
|
+
if (apiUrl.startsWith("http://"))
|
|
203
|
+
return "ws://" + apiUrl.slice("http://".length);
|
|
204
|
+
return apiUrl;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Refuses a project still holding the pre-#3153 layout, wherever it is found.
|
|
208
|
+
*
|
|
209
|
+
* Two shapes, one error. During the walk: a directory that has
|
|
210
|
+
* `.primitive/config.json` and no `primitive/config.json` never migrated. After
|
|
211
|
+
* a root is known: `<root>/.primitive/sync/` or a leftover
|
|
212
|
+
* `<root>/.primitive/config.json` means the migration stopped halfway, which is
|
|
213
|
+
* the state a fallback read would hide.
|
|
214
|
+
*/
|
|
215
|
+
function assertNoStaleLayout(root) {
|
|
216
|
+
const oldConfig = join(root, PROJECT_LOCAL_STATE_DIR, PROJECT_CONFIG_FILENAME);
|
|
217
|
+
if (existsSync(oldConfig)) {
|
|
218
|
+
throw new PrimitiveEnvError("stale-layout", staleLayoutMessage(`${oldConfig} still exists.`), oldConfig);
|
|
219
|
+
}
|
|
220
|
+
const oldTree = join(root, PROJECT_LOCAL_STATE_DIR, "sync");
|
|
221
|
+
if (existsSync(oldTree)) {
|
|
222
|
+
throw new PrimitiveEnvError("stale-layout", staleLayoutMessage(`${oldTree} still exists.`), oldTree);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Finds `primitive/config.json` by walking up from `cwd`, or returns the
|
|
227
|
+
* PRIMITIVE_PROJECT_CONFIG override when it is set (and exists).
|
|
228
|
+
*
|
|
229
|
+
* The override is checked for provenance BEFORE the file is read (#3153, F2):
|
|
230
|
+
* it bypasses the walk, so without this an old-layout config could be handed
|
|
231
|
+
* straight to a reader and defeat the cutover.
|
|
232
|
+
*
|
|
233
|
+
* Every return is checked against the root it implies, not just the levels the
|
|
234
|
+
* walk passed through: this is the one function every reader goes through —
|
|
235
|
+
* `resolvePrimitiveEnv` and the CLI's own `loadProjectConfig`/`findProjectRoot`
|
|
236
|
+
* alike — so a half-migrated project must be refused HERE, or the commands that
|
|
237
|
+
* never call `resolvePrimitiveEnv` would read the new tree with the old one
|
|
238
|
+
* still beside it.
|
|
239
|
+
*/
|
|
240
|
+
export function findPrimitiveConfigPath(options = {}) {
|
|
241
|
+
const env = options.env ?? process.env;
|
|
242
|
+
const override = env.PRIMITIVE_PROJECT_CONFIG;
|
|
243
|
+
if (override) {
|
|
244
|
+
const forced = resolve(override);
|
|
245
|
+
if (basename(dirname(forced)) === PROJECT_LOCAL_STATE_DIR) {
|
|
246
|
+
throw new PrimitiveEnvError("stale-layout", staleLayoutMessage(`PRIMITIVE_PROJECT_CONFIG points at ${forced}, inside a ${PROJECT_LOCAL_STATE_DIR}/ directory.`), forced);
|
|
247
|
+
}
|
|
248
|
+
if (!existsSync(forced))
|
|
249
|
+
return null;
|
|
250
|
+
assertNoStaleLayout(projectRootForConfigPath(forced));
|
|
251
|
+
return forced;
|
|
252
|
+
}
|
|
253
|
+
let current = resolve(options.cwd ?? process.cwd());
|
|
254
|
+
while (true) {
|
|
255
|
+
const candidate = join(current, PROJECT_TREE_DIR, PROJECT_CONFIG_FILENAME);
|
|
256
|
+
// Runs whether or not the new anchor is here: without it, a directory that
|
|
257
|
+
// has both anchors resolves (half-migrated), and one that has only the old
|
|
258
|
+
// one is not a project at all.
|
|
259
|
+
assertNoStaleLayout(current);
|
|
260
|
+
if (existsSync(candidate))
|
|
261
|
+
return candidate;
|
|
262
|
+
const parent = dirname(current);
|
|
263
|
+
if (parent === current)
|
|
264
|
+
return null;
|
|
265
|
+
current = parent;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* The project root for a config path: the parent of `primitive/`, or the
|
|
270
|
+
* containing directory when the config was pointed at directly (a fixture via
|
|
271
|
+
* PRIMITIVE_PROJECT_CONFIG, which is not inside a `primitive/` directory).
|
|
272
|
+
*/
|
|
273
|
+
export function projectRootForConfigPath(configPath) {
|
|
274
|
+
const dir = dirname(configPath);
|
|
275
|
+
return basename(dir) === PROJECT_TREE_DIR ? dirname(dir) : dir;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Machine-local state lives under the project root's `.primitive/`, not beside
|
|
279
|
+
* the config — the config is committed now, and the two must not share a
|
|
280
|
+
* directory. A fixture-pointed bare config still gets its own `.primitive/`
|
|
281
|
+
* in its own directory, so it never picks up a real project's selection.
|
|
282
|
+
*/
|
|
283
|
+
export function localStatePathForConfigPath(configPath) {
|
|
284
|
+
return join(projectRootForConfigPath(configPath), PROJECT_LOCAL_STATE_DIR, LOCAL_STATE_FILENAME);
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Reads and structurally validates `.primitive/config.json`. Throws rather
|
|
288
|
+
* than guessing: a config that cannot be understood is always louder than a
|
|
289
|
+
* silent fallback to the wrong backend.
|
|
290
|
+
*/
|
|
291
|
+
export function readCoreProjectConfig(configPath) {
|
|
292
|
+
if (!existsSync(configPath)) {
|
|
293
|
+
throw new PrimitiveEnvError("missing-config", missingConfigMessage(dirname(configPath)), configPath);
|
|
294
|
+
}
|
|
295
|
+
let raw;
|
|
296
|
+
try {
|
|
297
|
+
raw = readFileSync(configPath, "utf-8");
|
|
298
|
+
}
|
|
299
|
+
catch (err) {
|
|
300
|
+
throw new PrimitiveEnvError("malformed-config", `Failed to read ${PROJECT_CONFIG_DISPLAY_NAME} (${configPath}): ${err.message}`, configPath);
|
|
301
|
+
}
|
|
302
|
+
let parsed;
|
|
303
|
+
try {
|
|
304
|
+
parsed = JSON.parse(raw);
|
|
305
|
+
}
|
|
306
|
+
catch (err) {
|
|
307
|
+
throw new PrimitiveEnvError("malformed-config", `Failed to parse ${PROJECT_CONFIG_DISPLAY_NAME} (${configPath}): ${err.message}`, configPath);
|
|
308
|
+
}
|
|
309
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
310
|
+
throw new PrimitiveEnvError("malformed-config", `${PROJECT_CONFIG_DISPLAY_NAME} (${configPath}) must contain a JSON object at the top level.`, configPath);
|
|
311
|
+
}
|
|
312
|
+
const obj = parsed;
|
|
313
|
+
if (typeof obj.version !== "number" || !Number.isInteger(obj.version)) {
|
|
314
|
+
throw new PrimitiveEnvError("malformed-config", `${PROJECT_CONFIG_DISPLAY_NAME} (${configPath}) is missing required integer field "version".`, configPath);
|
|
315
|
+
}
|
|
316
|
+
if (obj.version !== PRIMITIVE_CONFIG_VERSION) {
|
|
317
|
+
throw new PrimitiveEnvError("unsupported-version", `${PROJECT_CONFIG_DISPLAY_NAME} (${configPath}) has version ${obj.version}, but this tool understands version ${PRIMITIVE_CONFIG_VERSION}.`, configPath);
|
|
318
|
+
}
|
|
319
|
+
if (!obj.environments || typeof obj.environments !== "object" || Array.isArray(obj.environments)) {
|
|
320
|
+
throw new PrimitiveEnvError("malformed-config", `${PROJECT_CONFIG_DISPLAY_NAME} (${configPath}) is missing required "environments" object.`, configPath);
|
|
321
|
+
}
|
|
322
|
+
const environments = {};
|
|
323
|
+
for (const [name, entry] of Object.entries(obj.environments)) {
|
|
324
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
|
|
325
|
+
throw new PrimitiveEnvError("malformed-config", `Environment "${name}" must be an object in ${PROJECT_CONFIG_DISPLAY_NAME} (${configPath}).`, configPath);
|
|
326
|
+
}
|
|
327
|
+
const e = entry;
|
|
328
|
+
if (typeof e.apiUrl !== "string" || !e.apiUrl) {
|
|
329
|
+
throw new PrimitiveEnvError("malformed-config", `Environment "${name}" must have a non-empty "apiUrl" string in ${PROJECT_CONFIG_DISPLAY_NAME} (${configPath}).`, configPath);
|
|
330
|
+
}
|
|
331
|
+
// Every environment names one app, checked here rather than after the
|
|
332
|
+
// selection: the criterion is about the FILE, and a second reader (the
|
|
333
|
+
// Vite plugin, cf-deploy, the Swift pre-build script) may land on a
|
|
334
|
+
// different environment than the CLI did.
|
|
335
|
+
const appId = readAppId(e.appId);
|
|
336
|
+
if (!appId) {
|
|
337
|
+
throw new PrimitiveEnvError("missing-app-id", missingAppIdMessage(name, configPath), configPath);
|
|
338
|
+
}
|
|
339
|
+
environments[name] = {
|
|
340
|
+
apiUrl: e.apiUrl.replace(/\/$/, ""),
|
|
341
|
+
appId,
|
|
342
|
+
appName: typeof e.appName === "string" ? e.appName : undefined,
|
|
343
|
+
webUrl: normalizeWebOrigin(e.webUrl),
|
|
344
|
+
description: typeof e.description === "string" ? e.description : undefined,
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
return {
|
|
348
|
+
version: obj.version,
|
|
349
|
+
defaultEnvironment: typeof obj.defaultEnvironment === "string" && obj.defaultEnvironment
|
|
350
|
+
? obj.defaultEnvironment
|
|
351
|
+
: undefined,
|
|
352
|
+
environments,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Reads this machine's selection from `.primitive/local.json`. Returns null
|
|
357
|
+
* when there is no file or no selection in it; throws when the file exists but
|
|
358
|
+
* cannot be read as the shape `primitive env use` writes.
|
|
359
|
+
*/
|
|
360
|
+
export function readLocalSelection(configPath) {
|
|
361
|
+
const path = localStatePathForConfigPath(configPath);
|
|
362
|
+
if (!existsSync(path))
|
|
363
|
+
return null;
|
|
364
|
+
const corrupt = (detail) => {
|
|
365
|
+
throw new PrimitiveEnvError("corrupt-local-state", `${LOCAL_STATE_DISPLAY_NAME} (${path}) is unreadable: ${detail}. Delete the file or re-run 'primitive env use <name>'.`, path);
|
|
366
|
+
};
|
|
367
|
+
let parsed;
|
|
368
|
+
try {
|
|
369
|
+
parsed = JSON.parse(readFileSync(path, "utf-8"));
|
|
370
|
+
}
|
|
371
|
+
catch (err) {
|
|
372
|
+
return corrupt(err.message);
|
|
373
|
+
}
|
|
374
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
375
|
+
return corrupt("expected a JSON object");
|
|
376
|
+
}
|
|
377
|
+
const obj = parsed;
|
|
378
|
+
const selected = obj.selectedEnvironment;
|
|
379
|
+
if (selected === undefined || selected === null || selected === "")
|
|
380
|
+
return null;
|
|
381
|
+
if (typeof selected !== "string") {
|
|
382
|
+
return corrupt(`"selectedEnvironment" must be a string`);
|
|
383
|
+
}
|
|
384
|
+
return selected;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Applies the precedence to an already-loaded config. Exposed separately so
|
|
388
|
+
* the CLI wrapper can run its own field-level validation first and still share
|
|
389
|
+
* one ordering with every other reader.
|
|
390
|
+
*/
|
|
391
|
+
export function selectEnvironmentName(config, options) {
|
|
392
|
+
const available = Object.keys(config.environments);
|
|
393
|
+
const list = available.join(", ") || "(none)";
|
|
394
|
+
const where = options.configPath
|
|
395
|
+
? `${PROJECT_CONFIG_DISPLAY_NAME} (${options.configPath})`
|
|
396
|
+
: PROJECT_CONFIG_DISPLAY_NAME;
|
|
397
|
+
const requireKnown = (name, source, origin) => {
|
|
398
|
+
if (!config.environments[name]) {
|
|
399
|
+
throw new PrimitiveEnvError("unknown-environment", `Environment "${name}" is not defined in ${where} (selected ${origin}). Available: ${list}`, options.configPath);
|
|
400
|
+
}
|
|
401
|
+
return { name, source };
|
|
402
|
+
};
|
|
403
|
+
if (options.explicitEnvName) {
|
|
404
|
+
return requireKnown(options.explicitEnvName, "explicit", "explicitly");
|
|
405
|
+
}
|
|
406
|
+
if (options.envVarName) {
|
|
407
|
+
return requireKnown(options.envVarName, "env-var", "via PRIMITIVE_ENV");
|
|
408
|
+
}
|
|
409
|
+
if (options.localSelection) {
|
|
410
|
+
return requireKnown(options.localSelection, "local", `in ${LOCAL_STATE_DISPLAY_NAME}`);
|
|
411
|
+
}
|
|
412
|
+
if (config.defaultEnvironment) {
|
|
413
|
+
return requireKnown(config.defaultEnvironment, "default", `as "defaultEnvironment"`);
|
|
414
|
+
}
|
|
415
|
+
if (available.length === 1) {
|
|
416
|
+
return { name: available[0], source: "sole" };
|
|
417
|
+
}
|
|
418
|
+
if (available.length === 0) {
|
|
419
|
+
throw new PrimitiveEnvError("no-selection", `${where} has no environments defined. Run 'primitive env add <name>' or 'primitive init'.`, options.configPath);
|
|
420
|
+
}
|
|
421
|
+
throw new PrimitiveEnvError("no-selection", `No environment selected. Run 'primitive env use <name>', set "defaultEnvironment" in ${where}, or export PRIMITIVE_ENV. Available: ${list}`, options.configPath);
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* The whole algorithm end to end: discover the config, read the selection,
|
|
425
|
+
* apply the precedence, derive the WebSocket URL.
|
|
426
|
+
*/
|
|
427
|
+
export function resolvePrimitiveEnv(options = {}) {
|
|
428
|
+
const env = options.env ?? process.env;
|
|
429
|
+
const configPath = options.configPath ?? findPrimitiveConfigPath({ cwd: options.cwd, env });
|
|
430
|
+
if (!configPath) {
|
|
431
|
+
throw new PrimitiveEnvError("missing-config", missingConfigMessage(options.cwd ?? process.cwd()));
|
|
432
|
+
}
|
|
433
|
+
// The root is known now (by the walk OR by an override), so the
|
|
434
|
+
// half-migrated shapes can be ruled out before anything is read.
|
|
435
|
+
const projectRoot = projectRootForConfigPath(configPath);
|
|
436
|
+
assertNoStaleLayout(projectRoot);
|
|
437
|
+
const config = readCoreProjectConfig(configPath);
|
|
438
|
+
const { name, source } = selectEnvironmentName(config, {
|
|
439
|
+
explicitEnvName: options.explicitEnvName || null,
|
|
440
|
+
envVarName: env.PRIMITIVE_ENV || null,
|
|
441
|
+
localSelection: readLocalSelection(configPath),
|
|
442
|
+
configPath,
|
|
443
|
+
});
|
|
444
|
+
const entry = config.environments[name];
|
|
445
|
+
return {
|
|
446
|
+
name,
|
|
447
|
+
apiUrl: entry.apiUrl,
|
|
448
|
+
wsUrl: deriveWsUrl(entry.apiUrl),
|
|
449
|
+
appId: entry.appId,
|
|
450
|
+
appName: entry.appName,
|
|
451
|
+
webUrl: entry.webUrl,
|
|
452
|
+
description: entry.description,
|
|
453
|
+
source,
|
|
454
|
+
configPath,
|
|
455
|
+
localStatePath: localStatePathForConfigPath(configPath),
|
|
456
|
+
projectRoot,
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
//# sourceMappingURL=env-resolver-core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-resolver-core.js","sourceRoot":"","sources":["../../../src/lib/env-resolver-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7D,uEAAuE;AACvE,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAC1C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAC5C,MAAM,CAAC,MAAM,uBAAuB,GAAG,YAAY,CAAC;AACpD,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAAC;AACrD,MAAM,CAAC,MAAM,oBAAoB,GAAG,YAAY,CAAC;AACjD,MAAM,CAAC,MAAM,2BAA2B,GAAG,uBAAuB,CAAC;AACnE,MAAM,CAAC,MAAM,wBAAwB,GAAG,uBAAuB,CAAC;AAEhE,gFAAgF;AAChF,MAAM,CAAC,MAAM,oBAAoB,GAAG,uCAAuC,CAAC;AAE5E;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAC/C,OAAO,CACL,GAAG,MAAM,4DAA4D;QACrE,gCAAgC,2BAA2B,YAAY;QACvE,0EAA0E;QAC1E,0EAA0E;QAC1E,wBAAwB,oBAAoB,GAAG,CAChD,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,OAAO,CACL,MAAM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IAED,gEAAgE;IAChE,iEAAiE;IACjE,MAAM,WAAW,GAAG,wBAAwB,CAAC,UAAU,CAAC,CAAC;IACzD,mBAAmB,CAAC,WAAW,CAAC,CAAC;IAEjC,MAAM,MAAM,GAAG,qBAAqB,CAAC,UAAU,CAAC,CAAC;IACjD,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,qBAAqB,CAAC,MAAM,EAAE;QACrD,eAAe,EAAE,OAAO,CAAC,eAAe,IAAI,IAAI;QAChD,UAAU,EAAE,GAAG,CAAC,aAAa,IAAI,IAAI;QACrC,cAAc,EAAE,kBAAkB,CAAC,UAAU,CAAC;QAC9C,UAAU;KACX,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAExC,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC;QAChC,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,MAAM;QACN,UAAU;QACV,cAAc,EAAE,2BAA2B,CAAC,UAAU,CAAC;QACvD,WAAW;KACZ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment resolution (CLI side).
|
|
3
|
+
*
|
|
4
|
+
* The algorithm itself lives in `env-resolver-core.ts` — the one copy the Vite
|
|
5
|
+
* plugin and the Swift pre-build script also run (#2873). This module is the
|
|
6
|
+
* CLI's thin wrapper around it: process-lifetime caching, the `--env` override
|
|
7
|
+
* commander sets, and — load-bearing — the CLI's own FULL field-level
|
|
8
|
+
* validation via `validateProjectConfig()`. The core carries only the version
|
|
9
|
+
* and structural checks the other readers need; running the CLI's validation
|
|
10
|
+
* first is what keeps `getProjectConfig()` and `getCurrentEnvironment()` from
|
|
11
|
+
* ever disagreeing about the same file.
|
|
12
|
+
*
|
|
13
|
+
* The resolution order is:
|
|
14
|
+
*
|
|
15
|
+
* 1. Explicit --env <name> flag (set via setCurrentEnvName from bin/primitive.ts)
|
|
16
|
+
* 2. PRIMITIVE_ENV environment variable
|
|
17
|
+
* 3. The per-machine selection in .primitive/local.json (`primitive env use`)
|
|
18
|
+
* 4. The project config's committed defaultEnvironment
|
|
19
|
+
* 5. If the project has exactly one environment, that one
|
|
20
|
+
* 6. null (legacy mode — fall back to ~/.primitive/credentials.json)
|
|
21
|
+
*
|
|
22
|
+
* Commands read the resolved environment once via getCurrentEnvironment().
|
|
23
|
+
* The resolution is cached for the lifetime of the process.
|
|
24
|
+
*/
|
|
25
|
+
import { type ProjectConfig, type ProjectEnvironment } from "./project-config.js";
|
|
26
|
+
import { PrimitiveEnvError, type PrimitiveEnvSource } from "./env-resolver-core.js";
|
|
27
|
+
export interface ResolvedEnvironment {
|
|
28
|
+
/** The environment name (e.g. "dev", "prod"). */
|
|
29
|
+
name: string;
|
|
30
|
+
/** The config entry for this environment. */
|
|
31
|
+
config: ProjectEnvironment;
|
|
32
|
+
/** Absolute path to primitive/config.json. */
|
|
33
|
+
projectConfigPath: string;
|
|
34
|
+
/** Absolute path to the project root (the parent of .primitive/). */
|
|
35
|
+
projectRoot: string;
|
|
36
|
+
/** Which precedence step chose this environment. */
|
|
37
|
+
source: PrimitiveEnvSource;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Called by bin/primitive.ts when the user passes --env <name> on the command
|
|
41
|
+
* line. Must be called before any command code runs so subsequent calls to
|
|
42
|
+
* getCurrentEnvironment() see the override.
|
|
43
|
+
*/
|
|
44
|
+
export declare function setCurrentEnvName(name: string | null): void;
|
|
45
|
+
/**
|
|
46
|
+
* Forces the resolver to re-read the project config on the next call.
|
|
47
|
+
* Used by tests and by commands that mutate the project config.
|
|
48
|
+
*/
|
|
49
|
+
export declare function resetEnvResolver(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Loads and caches the project config. Returns null if no
|
|
52
|
+
* primitive/config.json is present. Throws ProjectConfigError on a broken config.
|
|
53
|
+
*/
|
|
54
|
+
export declare function getProjectConfig(): ProjectConfig | null;
|
|
55
|
+
/**
|
|
56
|
+
* Reads this machine's environment selection (`primitive env use`), or null
|
|
57
|
+
* when nothing is selected. Throws PrimitiveEnvError on corrupt local state —
|
|
58
|
+
* `env list` / `env show` surface that distinctly instead of quietly falling
|
|
59
|
+
* back to the committed default.
|
|
60
|
+
*/
|
|
61
|
+
export declare function getLocalSelection(): string | null;
|
|
62
|
+
/** Absolute path of the local-state file for the current project, if any. */
|
|
63
|
+
export declare function getLocalStatePath(): string | null;
|
|
64
|
+
/**
|
|
65
|
+
* Resolves the current environment, or returns null if we're running in
|
|
66
|
+
* legacy mode (no primitive/config.json present).
|
|
67
|
+
*
|
|
68
|
+
* This never throws for a missing project config — that's legitimate
|
|
69
|
+
* "legacy mode" usage. It DOES throw if the project config exists but the
|
|
70
|
+
* requested environment doesn't.
|
|
71
|
+
*/
|
|
72
|
+
export declare function getCurrentEnvironment(): ResolvedEnvironment | null;
|
|
73
|
+
/**
|
|
74
|
+
* The resolved environment, or the one refusal (#3154, intent criterion 5).
|
|
75
|
+
*
|
|
76
|
+
* `getCurrentEnvironment()` answers `null` outside a project, which used to
|
|
77
|
+
* mean "legacy mode — fall back to `./config` and `~/.primitive/`". There is
|
|
78
|
+
* no such mode any more: the environment is the ONLY thing that names the
|
|
79
|
+
* configuration tree, the app and the server, so a caller that needs one asks
|
|
80
|
+
* here and gets an error naming what is missing instead of a second answer.
|
|
81
|
+
*
|
|
82
|
+
* Everything else propagates untouched. `no-selection`, `unknown-environment`,
|
|
83
|
+
* `corrupt-local-state` and `stale-layout` are real answers about a real
|
|
84
|
+
* project, and the old `safeEnv()` swallowing them is exactly how a typo in
|
|
85
|
+
* `--env` used to end up writing into `./config`.
|
|
86
|
+
*/
|
|
87
|
+
export declare function requireCurrentEnvironment(): ResolvedEnvironment;
|
|
88
|
+
/**
|
|
89
|
+
* Returns the current environment name for display purposes (e.g. in status
|
|
90
|
+
* headers). Returns null in legacy mode. Swallows resolution errors so the
|
|
91
|
+
* header never crashes the CLI.
|
|
92
|
+
*/
|
|
93
|
+
export declare function getCurrentEnvNameSafe(): string | null;
|
|
94
|
+
/**
|
|
95
|
+
* Returns the explicit name set via setCurrentEnvName(), for commands that
|
|
96
|
+
* need to know whether the user passed --env vs. relying on defaults.
|
|
97
|
+
*/
|
|
98
|
+
export declare function getExplicitEnvName(): string | null;
|
|
99
|
+
export { PrimitiveEnvError };
|