@ankhorage/infra 4.1.12 → 5.1.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/CHANGELOG.md +16 -0
- package/README.md +21 -32
- package/dist/cli/bin.d.ts +1 -8
- package/dist/cli/bin.d.ts.map +1 -1
- package/dist/cli/bin.js +2 -34
- package/dist/cli/bin.js.map +1 -1
- package/dist/cli/commands/destroy.d.ts +11 -0
- package/dist/cli/commands/destroy.d.ts.map +1 -0
- package/dist/cli/commands/destroy.js +51 -0
- package/dist/cli/commands/destroy.js.map +1 -0
- package/dist/cli/commands/down.d.ts +11 -0
- package/dist/cli/commands/down.d.ts.map +1 -0
- package/dist/cli/commands/down.js +27 -0
- package/dist/cli/commands/down.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +11 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +29 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/commands/outputs.d.ts +11 -0
- package/dist/cli/commands/outputs.d.ts.map +1 -0
- package/dist/cli/commands/outputs.js +25 -0
- package/dist/cli/commands/outputs.js.map +1 -0
- package/dist/cli/commands/plan.d.ts +11 -0
- package/dist/cli/commands/plan.d.ts.map +1 -0
- package/dist/cli/commands/plan.js +19 -0
- package/dist/cli/commands/plan.js.map +1 -0
- package/dist/cli/commands/status.d.ts +11 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +19 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/up.d.ts +11 -0
- package/dist/cli/commands/up.d.ts.map +1 -0
- package/dist/cli/commands/up.js +28 -0
- package/dist/cli/commands/up.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +11 -0
- package/dist/cli/commands/validate.d.ts.map +1 -0
- package/dist/cli/commands/validate.js +19 -0
- package/dist/cli/commands/validate.js.map +1 -0
- package/dist/cli/constants.d.ts +66 -0
- package/dist/cli/constants.d.ts.map +1 -0
- package/dist/cli/constants.js +19 -0
- package/dist/cli/constants.js.map +1 -0
- package/dist/cli/createDefaultInfraCommandContext.d.ts +4 -0
- package/dist/cli/createDefaultInfraCommandContext.d.ts.map +1 -0
- package/dist/{commandContext.js → cli/createDefaultInfraCommandContext.js} +4 -3
- package/dist/cli/createDefaultInfraCommandContext.js.map +1 -0
- package/dist/cli/createInfraRuntimeProvider.d.ts +5 -0
- package/dist/cli/createInfraRuntimeProvider.d.ts.map +1 -0
- package/dist/cli/createInfraRuntimeProvider.js +22 -0
- package/dist/cli/createInfraRuntimeProvider.js.map +1 -0
- package/dist/cli/createProviderCommandDescriptors.d.ts +4 -0
- package/dist/cli/createProviderCommandDescriptors.d.ts.map +1 -0
- package/dist/cli/createProviderCommandDescriptors.js +6 -0
- package/dist/cli/createProviderCommandDescriptors.js.map +1 -0
- package/dist/cli/findInfraCommand.d.ts +4 -0
- package/dist/cli/findInfraCommand.d.ts.map +1 -0
- package/dist/cli/findInfraCommand.js +6 -0
- package/dist/cli/findInfraCommand.js.map +1 -0
- package/dist/cli/index.d.ts +3 -8
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2 -24
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/renderInfraRootHelp.d.ts +3 -0
- package/dist/cli/renderInfraRootHelp.d.ts.map +1 -0
- package/dist/cli/renderInfraRootHelp.js +21 -0
- package/dist/cli/renderInfraRootHelp.js.map +1 -0
- package/dist/cli/renderUnknownInfraCommand.d.ts +3 -0
- package/dist/cli/renderUnknownInfraCommand.d.ts.map +1 -0
- package/dist/cli/renderUnknownInfraCommand.js +5 -0
- package/dist/cli/renderUnknownInfraCommand.js.map +1 -0
- package/dist/cli/runInfraCliAsync.d.ts +10 -0
- package/dist/cli/runInfraCliAsync.d.ts.map +1 -0
- package/dist/cli/runInfraCliAsync.js +34 -0
- package/dist/cli/runInfraCliAsync.js.map +1 -0
- package/dist/cli/runInfraCommandAsync.d.ts +4 -0
- package/dist/cli/runInfraCommandAsync.d.ts.map +1 -0
- package/dist/cli/runInfraCommandAsync.js +100 -0
- package/dist/cli/runInfraCommandAsync.js.map +1 -0
- package/dist/cli/utils/prepareInfraCommandOperationAsync.d.ts +4 -0
- package/dist/cli/utils/prepareInfraCommandOperationAsync.d.ts.map +1 -0
- package/dist/cli/utils/prepareInfraCommandOperationAsync.js +45 -0
- package/dist/cli/utils/prepareInfraCommandOperationAsync.js.map +1 -0
- package/dist/cli/utils/requireInfraSuccess.d.ts +7 -0
- package/dist/cli/utils/requireInfraSuccess.d.ts.map +1 -0
- package/dist/cli/utils/requireInfraSuccess.js +17 -0
- package/dist/cli/utils/requireInfraSuccess.js.map +1 -0
- package/dist/cli/utils/resolveInfraPersistence.d.ts +4 -0
- package/dist/cli/utils/resolveInfraPersistence.d.ts.map +1 -0
- package/dist/cli/utils/resolveInfraPersistence.js +17 -0
- package/dist/cli/utils/resolveInfraPersistence.js.map +1 -0
- package/dist/cli/utils/writeInfraEnvironmentOutputs.d.ts +5 -0
- package/dist/cli/utils/writeInfraEnvironmentOutputs.d.ts.map +1 -0
- package/dist/cli/utils/writeInfraEnvironmentOutputs.js +16 -0
- package/dist/cli/utils/writeInfraEnvironmentOutputs.js.map +1 -0
- package/dist/cli/utils/writeInfraStructured.d.ts +4 -0
- package/dist/cli/utils/writeInfraStructured.d.ts.map +1 -0
- package/dist/cli/utils/writeInfraStructured.js +8 -0
- package/dist/cli/utils/writeInfraStructured.js.map +1 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/{packageMetadata.js → constants.js} +6 -3
- package/dist/constants.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraCredentialPort.d.ts +4 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraCredentialPort.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraCredentialPort.js +35 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraCredentialPort.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraSecretPort.d.ts +4 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraSecretPort.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraSecretPort.js +23 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraSecretPort.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createNodeInfraAdapterPackageResolver.d.ts +4 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createNodeInfraAdapterPackageResolver.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createNodeInfraAdapterPackageResolver.js +9 -0
- package/dist/features/environment-lifecycle/adapters/outbound/createNodeInfraAdapterPackageResolver.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/readStoredInfraStateAsync.d.ts +5 -0
- package/dist/features/environment-lifecycle/adapters/outbound/readStoredInfraStateAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/readStoredInfraStateAsync.js +28 -0
- package/dist/features/environment-lifecycle/adapters/outbound/readStoredInfraStateAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/removeStoredInfraStateAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/adapters/outbound/removeStoredInfraStateAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/removeStoredInfraStateAsync.js +7 -0
- package/dist/features/environment-lifecycle/adapters/outbound/removeStoredInfraStateAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/resolveInfraProjectAsync.d.ts +7 -0
- package/dist/features/environment-lifecycle/adapters/outbound/resolveInfraProjectAsync.d.ts.map +1 -0
- package/dist/{project.js → features/environment-lifecycle/adapters/outbound/resolveInfraProjectAsync.js} +10 -34
- package/dist/features/environment-lifecycle/adapters/outbound/resolveInfraProjectAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeInfraGeneratedArtifactsAsync.d.ts +5 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeInfraGeneratedArtifactsAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeInfraGeneratedArtifactsAsync.js +28 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeInfraGeneratedArtifactsAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeStoredInfraStateAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeStoredInfraStateAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeStoredInfraStateAsync.js +16 -0
- package/dist/features/environment-lifecycle/adapters/outbound/writeStoredInfraStateAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/ports/outbound/infraAdapterPackage.d.ts +9 -0
- package/dist/features/environment-lifecycle/application/ports/outbound/infraAdapterPackage.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/ports/outbound/infraAdapterPackage.js +2 -0
- package/dist/features/environment-lifecycle/application/ports/outbound/infraAdapterPackage.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/collectInfraWorkloadsAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/collectInfraWorkloadsAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/collectInfraWorkloadsAsync.js +15 -0
- package/dist/features/environment-lifecycle/application/use-cases/collectInfraWorkloadsAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/destroyInfraEnvironmentAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/destroyInfraEnvironmentAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/destroyInfraEnvironmentAsync.js +84 -0
- package/dist/features/environment-lifecycle/application/use-cases/destroyInfraEnvironmentAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/downInfraEnvironmentAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/downInfraEnvironmentAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/downInfraEnvironmentAsync.js +55 -0
- package/dist/features/environment-lifecycle/application/use-cases/downInfraEnvironmentAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/generateInfraEnvironmentAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/generateInfraEnvironmentAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/generateInfraEnvironmentAsync.js +38 -0
- package/dist/features/environment-lifecycle/application/use-cases/generateInfraEnvironmentAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/getInfraEnvironmentOutputs.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/getInfraEnvironmentOutputs.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/getInfraEnvironmentOutputs.js +34 -0
- package/dist/features/environment-lifecycle/application/use-cases/getInfraEnvironmentOutputs.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/planInfraEnvironmentAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/planInfraEnvironmentAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/planInfraEnvironmentAsync.js +57 -0
- package/dist/features/environment-lifecycle/application/use-cases/planInfraEnvironmentAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/prepareInfraOperationAsync.d.ts +5 -0
- package/dist/features/environment-lifecycle/application/use-cases/prepareInfraOperationAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/prepareInfraOperationAsync.js +109 -0
- package/dist/features/environment-lifecycle/application/use-cases/prepareInfraOperationAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/resolveInfraAdaptersAsync.d.ts +6 -0
- package/dist/features/environment-lifecycle/application/use-cases/resolveInfraAdaptersAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/resolveInfraAdaptersAsync.js +181 -0
- package/dist/features/environment-lifecycle/application/use-cases/resolveInfraAdaptersAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/statusInfraEnvironmentAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/statusInfraEnvironmentAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/statusInfraEnvironmentAsync.js +68 -0
- package/dist/features/environment-lifecycle/application/use-cases/statusInfraEnvironmentAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/upInfraEnvironmentAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/upInfraEnvironmentAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/upInfraEnvironmentAsync.js +98 -0
- package/dist/features/environment-lifecycle/application/use-cases/upInfraEnvironmentAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraAdaptersAsync.d.ts +5 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraAdaptersAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraAdaptersAsync.js +17 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraAdaptersAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraEnvironmentAsync.d.ts +4 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraEnvironmentAsync.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraEnvironmentAsync.js +13 -0
- package/dist/features/environment-lifecycle/application/use-cases/validateInfraEnvironmentAsync.js.map +1 -0
- package/dist/features/environment-lifecycle/composition/createInfraCommandServices.d.ts +4 -0
- package/dist/features/environment-lifecycle/composition/createInfraCommandServices.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/composition/createInfraCommandServices.js +43 -0
- package/dist/features/environment-lifecycle/composition/createInfraCommandServices.js.map +1 -0
- package/dist/features/environment-lifecycle/composition/createProjectInfraLifecycle.d.ts +4 -0
- package/dist/features/environment-lifecycle/composition/createProjectInfraLifecycle.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/composition/createProjectInfraLifecycle.js +123 -0
- package/dist/features/environment-lifecycle/composition/createProjectInfraLifecycle.js.map +1 -0
- package/dist/features/environment-lifecycle/domain/orderInfraPlanActions.d.ts +4 -0
- package/dist/features/environment-lifecycle/domain/orderInfraPlanActions.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/domain/orderInfraPlanActions.js +54 -0
- package/dist/features/environment-lifecycle/domain/orderInfraPlanActions.js.map +1 -0
- package/dist/features/environment-lifecycle/domain/resolveInfraEnvironment.d.ts +5 -0
- package/dist/features/environment-lifecycle/domain/resolveInfraEnvironment.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/domain/resolveInfraEnvironment.js +39 -0
- package/dist/features/environment-lifecycle/domain/resolveInfraEnvironment.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/appendInfraFailure.d.ts +7 -0
- package/dist/features/environment-lifecycle/utils/appendInfraFailure.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/appendInfraFailure.js +5 -0
- package/dist/features/environment-lifecycle/utils/appendInfraFailure.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/createInfraExecutionContext.d.ts +5 -0
- package/dist/features/environment-lifecycle/utils/createInfraExecutionContext.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/createInfraExecutionContext.js +13 -0
- package/dist/features/environment-lifecycle/utils/createInfraExecutionContext.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/createInfraFailure.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/createInfraFailure.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/createInfraFailure.js +5 -0
- package/dist/features/environment-lifecycle/utils/createInfraFailure.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/createInfraLedger.d.ts +12 -0
- package/dist/features/environment-lifecycle/utils/createInfraLedger.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/createInfraLedger.js +14 -0
- package/dist/features/environment-lifecycle/utils/createInfraLedger.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/infraIdentityKey.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/infraIdentityKey.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/infraIdentityKey.js +5 -0
- package/dist/features/environment-lifecycle/utils/infraIdentityKey.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/isInfraStoredState.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/isInfraStoredState.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/isInfraStoredState.js +103 -0
- package/dist/features/environment-lifecycle/utils/isInfraStoredState.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraOutputs.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraOutputs.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraOutputs.js +10 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraOutputs.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraResources.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraResources.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraResources.js +10 -0
- package/dist/features/environment-lifecycle/utils/mergeInfraResources.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/normalizeInfraEnvironmentKey.d.ts +3 -0
- package/dist/features/environment-lifecycle/utils/normalizeInfraEnvironmentKey.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/normalizeInfraEnvironmentKey.js +8 -0
- package/dist/features/environment-lifecycle/utils/normalizeInfraEnvironmentKey.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/resolveInfraStatePath.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/resolveInfraStatePath.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/resolveInfraStatePath.js +11 -0
- package/dist/features/environment-lifecycle/utils/resolveInfraStatePath.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/resolveProjectFile.d.ts +3 -0
- package/dist/features/environment-lifecycle/utils/resolveProjectFile.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/resolveProjectFile.js +19 -0
- package/dist/features/environment-lifecycle/utils/resolveProjectFile.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterOutputs.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterOutputs.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterOutputs.js +6 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterOutputs.js.map +1 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterResources.d.ts +4 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterResources.d.ts.map +1 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterResources.js +6 -0
- package/dist/features/environment-lifecycle/utils/retainUnchangedAdapterResources.js.map +1 -0
- package/dist/index.d.ts +16 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -15
- package/dist/index.js.map +1 -1
- package/dist/metadata/index.d.ts +1 -1
- package/dist/metadata/index.d.ts.map +1 -1
- package/dist/metadata/index.js +1 -1
- package/dist/metadata/index.js.map +1 -1
- package/dist/project/index.d.ts +8 -5
- package/dist/project/index.d.ts.map +1 -1
- package/dist/project/index.js +7 -5
- package/dist/project/index.js.map +1 -1
- package/dist/readme-usage.js +17 -26
- package/dist/readme-usage.js.map +1 -1
- package/dist/testSupport.d.ts +1 -1
- package/dist/testSupport.d.ts.map +1 -1
- package/dist/testSupport.js +11 -1
- package/dist/testSupport.js.map +1 -1
- package/dist/types/infraCli.d.ts +91 -0
- package/dist/types/infraCli.d.ts.map +1 -0
- package/dist/types/infraCli.js +2 -0
- package/dist/types/infraCli.js.map +1 -0
- package/dist/types/infraOrchestration.d.ts +84 -0
- package/dist/types/infraOrchestration.d.ts.map +1 -0
- package/dist/types/infraOrchestration.js +2 -0
- package/dist/types/infraOrchestration.js.map +1 -0
- package/dist/types/infraProject.d.ts +43 -0
- package/dist/types/infraProject.d.ts.map +1 -0
- package/dist/types/infraProject.js +2 -0
- package/dist/types/infraProject.js.map +1 -0
- package/package.json +20 -10
- package/src/adapterPackages.integration.test.ts +79 -0
- package/src/cli/bin.ts +2 -61
- package/src/cli/cli.test.ts +35 -126
- package/src/cli/commands/destroy.ts +57 -0
- package/src/cli/commands/down.ts +28 -0
- package/src/cli/commands/generate.ts +34 -0
- package/src/cli/commands/outputs.ts +25 -0
- package/src/cli/commands/plan.ts +20 -0
- package/src/cli/commands/status.ts +20 -0
- package/src/cli/commands/up.ts +29 -0
- package/src/cli/commands/validate.ts +20 -0
- package/src/cli/constants.ts +19 -0
- package/src/cli/createDefaultInfraCommandContext.ts +17 -0
- package/src/cli/createInfraRuntimeProvider.ts +35 -0
- package/src/cli/createProviderCommandDescriptors.ts +8 -0
- package/src/cli/findInfraCommand.ts +7 -0
- package/src/cli/index.test.ts +12 -20
- package/src/cli/index.ts +7 -49
- package/src/cli/renderInfraRootHelp.ts +23 -0
- package/src/cli/renderUnknownInfraCommand.ts +4 -0
- package/src/cli/runInfraCliAsync.ts +51 -0
- package/src/cli/runInfraCommandAsync.ts +114 -0
- package/src/cli/utils/prepareInfraCommandOperationAsync.ts +64 -0
- package/src/cli/utils/requireInfraSuccess.ts +24 -0
- package/src/cli/utils/resolveInfraPersistence.ts +22 -0
- package/src/cli/utils/writeInfraEnvironmentOutputs.ts +24 -0
- package/src/cli/utils/writeInfraStructured.ts +11 -0
- package/src/commands.test.ts +198 -196
- package/src/{packageMetadata.ts → constants.ts} +5 -2
- package/src/environmentLifecycle.test.ts +193 -0
- package/src/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraCredentialPort.ts +52 -0
- package/src/features/environment-lifecycle/adapters/outbound/createEnvironmentInfraSecretPort.ts +32 -0
- package/src/features/environment-lifecycle/adapters/outbound/createNodeInfraAdapterPackageResolver.ts +10 -0
- package/src/features/environment-lifecycle/adapters/outbound/readStoredInfraStateAsync.ts +34 -0
- package/src/features/environment-lifecycle/adapters/outbound/removeStoredInfraStateAsync.ts +12 -0
- package/src/{project.ts → features/environment-lifecycle/adapters/outbound/resolveInfraProjectAsync.ts} +10 -45
- package/src/features/environment-lifecycle/adapters/outbound/writeInfraGeneratedArtifactsAsync.ts +34 -0
- package/src/features/environment-lifecycle/adapters/outbound/writeStoredInfraStateAsync.ts +21 -0
- package/src/features/environment-lifecycle/application/ports/outbound/infraAdapterPackage.ts +10 -0
- package/src/features/environment-lifecycle/application/use-cases/collectInfraWorkloadsAsync.ts +25 -0
- package/src/features/environment-lifecycle/application/use-cases/destroyInfraEnvironmentAsync.ts +119 -0
- package/src/features/environment-lifecycle/application/use-cases/downInfraEnvironmentAsync.ts +65 -0
- package/src/features/environment-lifecycle/application/use-cases/generateInfraEnvironmentAsync.ts +51 -0
- package/src/features/environment-lifecycle/application/use-cases/getInfraEnvironmentOutputs.ts +41 -0
- package/src/features/environment-lifecycle/application/use-cases/planInfraEnvironmentAsync.ts +67 -0
- package/src/features/environment-lifecycle/application/use-cases/prepareInfraOperationAsync.ts +137 -0
- package/src/features/environment-lifecycle/application/use-cases/resolveInfraAdaptersAsync.ts +257 -0
- package/src/features/environment-lifecycle/application/use-cases/statusInfraEnvironmentAsync.ts +80 -0
- package/src/features/environment-lifecycle/application/use-cases/upInfraEnvironmentAsync.ts +126 -0
- package/src/features/environment-lifecycle/application/use-cases/validateInfraAdaptersAsync.ts +25 -0
- package/src/features/environment-lifecycle/application/use-cases/validateInfraEnvironmentAsync.ts +21 -0
- package/src/features/environment-lifecycle/composition/createInfraCommandServices.ts +47 -0
- package/src/features/environment-lifecycle/composition/createProjectInfraLifecycle.ts +157 -0
- package/src/features/environment-lifecycle/domain/orderInfraPlanActions.ts +64 -0
- package/src/features/environment-lifecycle/domain/resolveInfraEnvironment.ts +62 -0
- package/src/features/environment-lifecycle/utils/appendInfraFailure.ts +9 -0
- package/src/features/environment-lifecycle/utils/createInfraExecutionContext.ts +24 -0
- package/src/features/environment-lifecycle/utils/createInfraFailure.ts +6 -0
- package/src/features/environment-lifecycle/utils/createInfraLedger.ts +30 -0
- package/src/features/environment-lifecycle/utils/infraIdentityKey.ts +6 -0
- package/src/features/environment-lifecycle/utils/isInfraStoredState.ts +141 -0
- package/src/features/environment-lifecycle/utils/mergeInfraOutputs.ts +14 -0
- package/src/features/environment-lifecycle/utils/mergeInfraResources.ts +14 -0
- package/src/features/environment-lifecycle/utils/normalizeInfraEnvironmentKey.ts +7 -0
- package/src/features/environment-lifecycle/utils/resolveInfraStatePath.ts +12 -0
- package/src/features/environment-lifecycle/utils/resolveProjectFile.ts +22 -0
- package/src/features/environment-lifecycle/utils/retainUnchangedAdapterOutputs.ts +15 -0
- package/src/features/environment-lifecycle/utils/retainUnchangedAdapterResources.ts +15 -0
- package/src/index.test.ts +22 -315
- package/src/index.ts +41 -53
- package/src/infraComposition.integration.test.ts +128 -0
- package/src/infraOperations.test.ts +386 -0
- package/src/infraUp.test.ts +260 -0
- package/src/metadata/index.ts +1 -1
- package/src/package.test.ts +4 -2
- package/src/project/index.test.ts +10 -188
- package/src/project/index.ts +15 -22
- package/src/project.test.ts +39 -189
- package/src/projectContractsParser.test.ts +2 -2
- package/src/projectInfrastructure.test.ts +121 -167
- package/src/projectLifecycle.test.ts +136 -0
- package/src/readme-usage.ts +17 -26
- package/src/testSupport.ts +12 -2
- package/src/types/infraCli.ts +115 -0
- package/src/types/infraOrchestration.ts +126 -0
- package/src/types/infraProject.ts +58 -0
- package/dist/adapters/minikube/auth/index.d.ts +0 -8
- package/dist/adapters/minikube/auth/index.d.ts.map +0 -1
- package/dist/adapters/minikube/auth/index.js +0 -29
- package/dist/adapters/minikube/auth/index.js.map +0 -1
- package/dist/adapters/minikube/auth/oauthRuntime.d.ts +0 -4
- package/dist/adapters/minikube/auth/oauthRuntime.d.ts.map +0 -1
- package/dist/adapters/minikube/auth/oauthRuntime.js +0 -138
- package/dist/adapters/minikube/auth/oauthRuntime.js.map +0 -1
- package/dist/adapters/minikube/auth/supabase/index.d.ts +0 -7
- package/dist/adapters/minikube/auth/supabase/index.d.ts.map +0 -1
- package/dist/adapters/minikube/auth/supabase/index.js +0 -232
- package/dist/adapters/minikube/auth/supabase/index.js.map +0 -1
- package/dist/adapters/minikube/auth/supabase/profile.d.ts +0 -20
- package/dist/adapters/minikube/auth/supabase/profile.d.ts.map +0 -1
- package/dist/adapters/minikube/auth/supabase/profile.js +0 -452
- package/dist/adapters/minikube/auth/supabase/profile.js.map +0 -1
- package/dist/adapters/minikube/auth/targetAwareOAuthRuntime.d.ts +0 -7
- package/dist/adapters/minikube/auth/targetAwareOAuthRuntime.d.ts.map +0 -1
- package/dist/adapters/minikube/auth/targetAwareOAuthRuntime.js +0 -104
- package/dist/adapters/minikube/auth/targetAwareOAuthRuntime.js.map +0 -1
- package/dist/adapters/minikube/authz/cerbos/index.d.ts +0 -13
- package/dist/adapters/minikube/authz/cerbos/index.d.ts.map +0 -1
- package/dist/adapters/minikube/authz/cerbos/index.js +0 -382
- package/dist/adapters/minikube/authz/cerbos/index.js.map +0 -1
- package/dist/adapters/minikube/authz/index.d.ts +0 -9
- package/dist/adapters/minikube/authz/index.d.ts.map +0 -1
- package/dist/adapters/minikube/authz/index.js +0 -23
- package/dist/adapters/minikube/authz/index.js.map +0 -1
- package/dist/adapters/minikube/base/index.d.ts +0 -14
- package/dist/adapters/minikube/base/index.d.ts.map +0 -1
- package/dist/adapters/minikube/base/index.js +0 -3433
- package/dist/adapters/minikube/base/index.js.map +0 -1
- package/dist/adapters/minikube/base/supabaseMigrations.d.ts +0 -2
- package/dist/adapters/minikube/base/supabaseMigrations.d.ts.map +0 -1
- package/dist/adapters/minikube/base/supabaseMigrations.js +0 -6
- package/dist/adapters/minikube/base/supabaseMigrations.js.map +0 -1
- package/dist/adapters/minikube/contracts.d.ts +0 -34
- package/dist/adapters/minikube/contracts.d.ts.map +0 -1
- package/dist/adapters/minikube/contracts.js +0 -10
- package/dist/adapters/minikube/contracts.js.map +0 -1
- package/dist/adapters/minikube/index.d.ts +0 -3
- package/dist/adapters/minikube/index.d.ts.map +0 -1
- package/dist/adapters/minikube/index.js +0 -136
- package/dist/adapters/minikube/index.js.map +0 -1
- package/dist/adapters/minikube/secrets/index.d.ts +0 -7
- package/dist/adapters/minikube/secrets/index.d.ts.map +0 -1
- package/dist/adapters/minikube/secrets/index.js +0 -13
- package/dist/adapters/minikube/secrets/index.js.map +0 -1
- package/dist/adapters/minikube/secrets/supabase-vault/index.d.ts +0 -8
- package/dist/adapters/minikube/secrets/supabase-vault/index.d.ts.map +0 -1
- package/dist/adapters/minikube/secrets/supabase-vault/index.js +0 -118
- package/dist/adapters/minikube/secrets/supabase-vault/index.js.map +0 -1
- package/dist/adapters/minikube/storage/index.d.ts +0 -7
- package/dist/adapters/minikube/storage/index.d.ts.map +0 -1
- package/dist/adapters/minikube/storage/index.js +0 -77
- package/dist/adapters/minikube/storage/index.js.map +0 -1
- package/dist/adapters/minikube/storage/supabase/index.d.ts +0 -7
- package/dist/adapters/minikube/storage/supabase/index.d.ts.map +0 -1
- package/dist/adapters/minikube/storage/supabase/index.js +0 -82
- package/dist/adapters/minikube/storage/supabase/index.js.map +0 -1
- package/dist/authRedirects.d.ts +0 -19
- package/dist/authRedirects.d.ts.map +0 -1
- package/dist/authRedirects.js +0 -80
- package/dist/authRedirects.js.map +0 -1
- package/dist/authTargetRedirects.d.ts +0 -12
- package/dist/authTargetRedirects.d.ts.map +0 -1
- package/dist/authTargetRedirects.js +0 -32
- package/dist/authTargetRedirects.js.map +0 -1
- package/dist/commandContext.d.ts +0 -12
- package/dist/commandContext.d.ts.map +0 -1
- package/dist/commandContext.js.map +0 -1
- package/dist/commands.d.ts +0 -95
- package/dist/commands.d.ts.map +0 -1
- package/dist/commands.js +0 -256
- package/dist/commands.js.map +0 -1
- package/dist/infraValidation.d.ts +0 -4
- package/dist/infraValidation.d.ts.map +0 -1
- package/dist/infraValidation.js +0 -63
- package/dist/infraValidation.js.map +0 -1
- package/dist/packageMetadata.d.ts +0 -10
- package/dist/packageMetadata.d.ts.map +0 -1
- package/dist/packageMetadata.js.map +0 -1
- package/dist/project.d.ts +0 -14
- package/dist/project.d.ts.map +0 -1
- package/dist/project.js.map +0 -1
- package/dist/projectDatabase.d.ts +0 -5
- package/dist/projectDatabase.d.ts.map +0 -1
- package/dist/projectDatabase.js +0 -22
- package/dist/projectDatabase.js.map +0 -1
- package/dist/projectEnvironment.d.ts +0 -6
- package/dist/projectEnvironment.d.ts.map +0 -1
- package/dist/projectEnvironment.js +0 -45
- package/dist/projectEnvironment.js.map +0 -1
- package/dist/projectInfrastructure.d.ts +0 -38
- package/dist/projectInfrastructure.d.ts.map +0 -1
- package/dist/projectInfrastructure.js +0 -145
- package/dist/projectInfrastructure.js.map +0 -1
- package/dist/runtime.d.ts +0 -54
- package/dist/runtime.d.ts.map +0 -1
- package/dist/runtime.js +0 -151
- package/dist/runtime.js.map +0 -1
- package/dist/secretStore.d.ts +0 -19
- package/dist/secretStore.d.ts.map +0 -1
- package/dist/secretStore.js +0 -22
- package/dist/secretStore.js.map +0 -1
- package/dist/types.d.ts +0 -70
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/src/adapters/minikube/README.md +0 -115
- package/src/adapters/minikube/appRuntimeServing.test.ts +0 -28
- package/src/adapters/minikube/auth/index.ts +0 -40
- package/src/adapters/minikube/auth/oauthRuntime.ts +0 -163
- package/src/adapters/minikube/auth/supabase/index.test.ts +0 -227
- package/src/adapters/minikube/auth/supabase/index.ts +0 -293
- package/src/adapters/minikube/auth/supabase/oauthRuntime.test.ts +0 -154
- package/src/adapters/minikube/auth/supabase/profile.integration.test.ts +0 -1028
- package/src/adapters/minikube/auth/supabase/profile.ts +0 -526
- package/src/adapters/minikube/auth/supabase/providerAssignments.test.ts +0 -36
- package/src/adapters/minikube/auth/targetAwareOAuthRuntime.test.ts +0 -83
- package/src/adapters/minikube/auth/targetAwareOAuthRuntime.ts +0 -136
- package/src/adapters/minikube/authz/cerbos/index.ts +0 -486
- package/src/adapters/minikube/authz/index.ts +0 -32
- package/src/adapters/minikube/base/appImageBuild.test.ts +0 -352
- package/src/adapters/minikube/base/index.test.ts +0 -693
- package/src/adapters/minikube/base/index.ts +0 -3763
- package/src/adapters/minikube/base/portForwardRuntime.test.ts +0 -624
- package/src/adapters/minikube/base/supabaseMigrations.test.ts +0 -168
- package/src/adapters/minikube/base/supabaseMigrations.ts +0 -5
- package/src/adapters/minikube/base/twoAppIsolation.integration.test.ts +0 -898
- package/src/adapters/minikube/base/upgradeReconciliation.test.ts +0 -135
- package/src/adapters/minikube/contracts.ts +0 -46
- package/src/adapters/minikube/index.ts +0 -172
- package/src/adapters/minikube/secrets/index.test.ts +0 -147
- package/src/adapters/minikube/secrets/index.ts +0 -19
- package/src/adapters/minikube/secrets/supabase-vault/index.ts +0 -139
- package/src/adapters/minikube/storage/index.ts +0 -91
- package/src/adapters/minikube/storage/supabase/index.ts +0 -108
- package/src/apiInfrastructure.test.ts +0 -69
- package/src/authRedirects.test.ts +0 -63
- package/src/authRedirects.ts +0 -113
- package/src/authTargetRedirects.test.ts +0 -62
- package/src/authTargetRedirects.ts +0 -46
- package/src/commandContext.ts +0 -27
- package/src/commands.ts +0 -404
- package/src/generatedApiLedgerCleanup.test.ts +0 -72
- package/src/infraApiValidation.test.ts +0 -42
- package/src/infraValidation.ts +0 -99
- package/src/minikubeImageLifecycle.test.ts +0 -35
- package/src/projectDatabase.ts +0 -27
- package/src/projectEnvironment.ts +0 -51
- package/src/projectInfrastructure.ts +0 -221
- package/src/runtime.test.ts +0 -124
- package/src/runtime.ts +0 -234
- package/src/secretStore.test.ts +0 -76
- package/src/secretStore.ts +0 -44
- package/src/types.ts +0 -82
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { INFRA_CAPABILITIES } from '../../constants.js';
|
|
2
|
+
import type { InfraCommandDefinition } from '../../types/infraCli.js';
|
|
3
|
+
import { prepareInfraCommandOperationAsync } from '../utils/prepareInfraCommandOperationAsync.js';
|
|
4
|
+
import { requireInfraSuccess } from '../utils/requireInfraSuccess.js';
|
|
5
|
+
import { writeInfraStructured } from '../utils/writeInfraStructured.js';
|
|
6
|
+
|
|
7
|
+
/*** Define reversible runtime suspension while retaining persistent resources. */
|
|
8
|
+
export const down = {
|
|
9
|
+
standaloneName: 'down',
|
|
10
|
+
path: ['down'],
|
|
11
|
+
capability: INFRA_CAPABILITIES[6],
|
|
12
|
+
summary: 'Reversibly suspend runtime workloads while retaining persistent data.',
|
|
13
|
+
async run(request, services) {
|
|
14
|
+
const operation = await prepareInfraCommandOperationAsync(request, services);
|
|
15
|
+
const result = await services.operations.down(operation.operation, operation.dependencies);
|
|
16
|
+
requireInfraSuccess(result, request.context);
|
|
17
|
+
await services.writeState(operation.project.projectPath, {
|
|
18
|
+
schemaVersion: 1,
|
|
19
|
+
desired: operation.desired,
|
|
20
|
+
ledger: result.value.ledger,
|
|
21
|
+
});
|
|
22
|
+
writeInfraStructured(request.context, request.arguments.format, {
|
|
23
|
+
environment: result.value.environment,
|
|
24
|
+
state: 'stopped',
|
|
25
|
+
});
|
|
26
|
+
return { exitCode: 0 };
|
|
27
|
+
},
|
|
28
|
+
} as const satisfies InfraCommandDefinition;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { INFRA_CAPABILITIES } from '../../constants.js';
|
|
2
|
+
import type { InfraCommandDefinition } from '../../types/infraCli.js';
|
|
3
|
+
import { prepareInfraCommandOperationAsync } from '../utils/prepareInfraCommandOperationAsync.js';
|
|
4
|
+
import { requireInfraSuccess } from '../utils/requireInfraSuccess.js';
|
|
5
|
+
import { writeInfraStructured } from '../utils/writeInfraStructured.js';
|
|
6
|
+
|
|
7
|
+
/*** Define deterministic review-artifact generation without remote side effects. */
|
|
8
|
+
export const generate = {
|
|
9
|
+
standaloneName: 'generate',
|
|
10
|
+
path: ['generate'],
|
|
11
|
+
capability: INFRA_CAPABILITIES[2],
|
|
12
|
+
summary: 'Generate deterministic review artifacts without remote side effects.',
|
|
13
|
+
async run(request, services) {
|
|
14
|
+
const operation = await prepareInfraCommandOperationAsync(request, services);
|
|
15
|
+
const result = await services.operations.generate(operation.operation, operation.dependencies);
|
|
16
|
+
requireInfraSuccess(result, request.context);
|
|
17
|
+
const written = await services.writeArtifacts(
|
|
18
|
+
operation.project.projectPath,
|
|
19
|
+
result.value.artifacts,
|
|
20
|
+
operation.state?.ledger,
|
|
21
|
+
);
|
|
22
|
+
await services.writeState(operation.project.projectPath, {
|
|
23
|
+
schemaVersion: 1,
|
|
24
|
+
desired: operation.desired,
|
|
25
|
+
ledger: result.value.ledger,
|
|
26
|
+
});
|
|
27
|
+
writeInfraStructured(request.context, request.arguments.format, {
|
|
28
|
+
environment: result.value.environment,
|
|
29
|
+
...written,
|
|
30
|
+
artifacts: result.value.artifacts.map(({ path }) => path),
|
|
31
|
+
});
|
|
32
|
+
return { exitCode: 0 };
|
|
33
|
+
},
|
|
34
|
+
} as const satisfies InfraCommandDefinition;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { INFRA_CAPABILITIES } from '../../constants.js';
|
|
2
|
+
import type { InfraCommandDefinition } from '../../types/infraCli.js';
|
|
3
|
+
import { prepareInfraCommandOperationAsync } from '../utils/prepareInfraCommandOperationAsync.js';
|
|
4
|
+
import { requireInfraSuccess } from '../utils/requireInfraSuccess.js';
|
|
5
|
+
import { writeInfraEnvironmentOutputs } from '../utils/writeInfraEnvironmentOutputs.js';
|
|
6
|
+
import { writeInfraStructured } from '../utils/writeInfraStructured.js';
|
|
7
|
+
|
|
8
|
+
/*** Define safe public-output and secret-reference presentation. */
|
|
9
|
+
export const outputs = {
|
|
10
|
+
standaloneName: 'outputs',
|
|
11
|
+
path: ['outputs'],
|
|
12
|
+
capability: INFRA_CAPABILITIES[5],
|
|
13
|
+
summary: 'Print safe public outputs and secret references.',
|
|
14
|
+
async run(request, services) {
|
|
15
|
+
const operation = await prepareInfraCommandOperationAsync(request, services);
|
|
16
|
+
const result = services.operations.outputs(operation.operation);
|
|
17
|
+
requireInfraSuccess(result, request.context);
|
|
18
|
+
if (request.arguments.format === 'env') {
|
|
19
|
+
writeInfraEnvironmentOutputs(request.context, result.value.outputs);
|
|
20
|
+
} else {
|
|
21
|
+
writeInfraStructured(request.context, request.arguments.format, result.value);
|
|
22
|
+
}
|
|
23
|
+
return { exitCode: 0 };
|
|
24
|
+
},
|
|
25
|
+
} as const satisfies InfraCommandDefinition;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { INFRA_CAPABILITIES } from '../../constants.js';
|
|
2
|
+
import type { InfraCommandDefinition } from '../../types/infraCli.js';
|
|
3
|
+
import { prepareInfraCommandOperationAsync } from '../utils/prepareInfraCommandOperationAsync.js';
|
|
4
|
+
import { requireInfraSuccess } from '../utils/requireInfraSuccess.js';
|
|
5
|
+
import { writeInfraStructured } from '../utils/writeInfraStructured.js';
|
|
6
|
+
|
|
7
|
+
/*** Define the ordered side-effect-free infrastructure planning command. */
|
|
8
|
+
export const plan = {
|
|
9
|
+
standaloneName: 'plan',
|
|
10
|
+
path: ['plan'],
|
|
11
|
+
capability: INFRA_CAPABILITIES[1],
|
|
12
|
+
summary: 'Print an ordered side-effect-free infrastructure plan.',
|
|
13
|
+
async run(request, services) {
|
|
14
|
+
const operation = await prepareInfraCommandOperationAsync(request, services);
|
|
15
|
+
const result = await services.operations.plan(operation.operation, operation.dependencies);
|
|
16
|
+
requireInfraSuccess(result, request.context);
|
|
17
|
+
writeInfraStructured(request.context, request.arguments.format, result.value);
|
|
18
|
+
return { exitCode: 0 };
|
|
19
|
+
},
|
|
20
|
+
} as const satisfies InfraCommandDefinition;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { INFRA_CAPABILITIES } from '../../constants.js';
|
|
2
|
+
import type { InfraCommandDefinition } from '../../types/infraCli.js';
|
|
3
|
+
import { prepareInfraCommandOperationAsync } from '../utils/prepareInfraCommandOperationAsync.js';
|
|
4
|
+
import { requireInfraSuccess } from '../utils/requireInfraSuccess.js';
|
|
5
|
+
import { writeInfraStructured } from '../utils/writeInfraStructured.js';
|
|
6
|
+
|
|
7
|
+
/*** Define provider-neutral environment status aggregation. */
|
|
8
|
+
export const status = {
|
|
9
|
+
standaloneName: 'status',
|
|
10
|
+
path: ['status'],
|
|
11
|
+
capability: INFRA_CAPABILITIES[4],
|
|
12
|
+
summary: 'Aggregate provider-neutral environment status.',
|
|
13
|
+
async run(request, services) {
|
|
14
|
+
const operation = await prepareInfraCommandOperationAsync(request, services);
|
|
15
|
+
const result = await services.operations.status(operation.operation, operation.dependencies);
|
|
16
|
+
requireInfraSuccess(result, request.context);
|
|
17
|
+
writeInfraStructured(request.context, request.arguments.format, result.value);
|
|
18
|
+
return { exitCode: 0 };
|
|
19
|
+
},
|
|
20
|
+
} as const satisfies InfraCommandDefinition;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { INFRA_CAPABILITIES } from '../../constants.js';
|
|
2
|
+
import type { InfraCommandDefinition } from '../../types/infraCli.js';
|
|
3
|
+
import { prepareInfraCommandOperationAsync } from '../utils/prepareInfraCommandOperationAsync.js';
|
|
4
|
+
import { requireInfraSuccess } from '../utils/requireInfraSuccess.js';
|
|
5
|
+
import { writeInfraStructured } from '../utils/writeInfraStructured.js';
|
|
6
|
+
|
|
7
|
+
/*** Define idempotent environment creation and reconciliation. */
|
|
8
|
+
export const up = {
|
|
9
|
+
standaloneName: 'up',
|
|
10
|
+
path: ['up'],
|
|
11
|
+
capability: INFRA_CAPABILITIES[3],
|
|
12
|
+
summary: 'Idempotently ensure and reconcile the selected environment.',
|
|
13
|
+
async run(request, services) {
|
|
14
|
+
const operation = await prepareInfraCommandOperationAsync(request, services);
|
|
15
|
+
const result = await services.operations.up(operation.operation, operation.dependencies);
|
|
16
|
+
requireInfraSuccess(result, request.context);
|
|
17
|
+
await services.writeState(operation.project.projectPath, {
|
|
18
|
+
schemaVersion: 1,
|
|
19
|
+
desired: operation.desired,
|
|
20
|
+
ledger: result.value.ledger,
|
|
21
|
+
});
|
|
22
|
+
writeInfraStructured(request.context, request.arguments.format, {
|
|
23
|
+
environment: result.value.environment,
|
|
24
|
+
resources: result.value.resources.length,
|
|
25
|
+
outputs: result.value.outputs,
|
|
26
|
+
});
|
|
27
|
+
return { exitCode: 0 };
|
|
28
|
+
},
|
|
29
|
+
} as const satisfies InfraCommandDefinition;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { INFRA_CAPABILITIES } from '../../constants.js';
|
|
2
|
+
import type { InfraCommandDefinition } from '../../types/infraCli.js';
|
|
3
|
+
import { prepareInfraCommandOperationAsync } from '../utils/prepareInfraCommandOperationAsync.js';
|
|
4
|
+
import { requireInfraSuccess } from '../utils/requireInfraSuccess.js';
|
|
5
|
+
import { writeInfraStructured } from '../utils/writeInfraStructured.js';
|
|
6
|
+
|
|
7
|
+
/*** Define the manifest, compatibility, credential and selected-adapter validation command. */
|
|
8
|
+
export const validate = {
|
|
9
|
+
standaloneName: 'validate',
|
|
10
|
+
path: ['validate'],
|
|
11
|
+
capability: INFRA_CAPABILITIES[0],
|
|
12
|
+
summary: 'Validate manifest, compatibility, credentials and selected adapters.',
|
|
13
|
+
async run(request, services) {
|
|
14
|
+
const operation = await prepareInfraCommandOperationAsync(request, services);
|
|
15
|
+
const result = await services.operations.validate(operation.operation, operation.dependencies);
|
|
16
|
+
requireInfraSuccess(result, request.context);
|
|
17
|
+
writeInfraStructured(request.context, request.arguments.format, result.value);
|
|
18
|
+
return { exitCode: 0 };
|
|
19
|
+
},
|
|
20
|
+
} as const satisfies InfraCommandDefinition;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { destroy } from './commands/destroy.js';
|
|
2
|
+
import { down } from './commands/down.js';
|
|
3
|
+
import { generate } from './commands/generate.js';
|
|
4
|
+
import { outputs } from './commands/outputs.js';
|
|
5
|
+
import { plan } from './commands/plan.js';
|
|
6
|
+
import { status } from './commands/status.js';
|
|
7
|
+
import { up } from './commands/up.js';
|
|
8
|
+
import { validate } from './commands/validate.js';
|
|
9
|
+
|
|
10
|
+
export const INFRA_COMMANDS = [
|
|
11
|
+
validate,
|
|
12
|
+
plan,
|
|
13
|
+
generate,
|
|
14
|
+
up,
|
|
15
|
+
status,
|
|
16
|
+
outputs,
|
|
17
|
+
down,
|
|
18
|
+
destroy,
|
|
19
|
+
] as const;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { INFRA_PACKAGE_VERSION } from '../constants.js';
|
|
2
|
+
import type { InfraCommandContext } from '../types/infraCli.js';
|
|
3
|
+
|
|
4
|
+
/*** Create the process-backed command context used by the standalone executable. */
|
|
5
|
+
export function createDefaultInfraCommandContext(): InfraCommandContext {
|
|
6
|
+
return {
|
|
7
|
+
cwd: process.cwd(),
|
|
8
|
+
env: process.env,
|
|
9
|
+
version: INFRA_PACKAGE_VERSION,
|
|
10
|
+
writeStdout(text: string) {
|
|
11
|
+
process.stdout.write(text);
|
|
12
|
+
},
|
|
13
|
+
writeStderr(text: string) {
|
|
14
|
+
process.stderr.write(text);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { AnkhRuntimeCommandProvider } from '@ankhorage/ankh';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
INFRA_CAPABILITIES,
|
|
5
|
+
INFRA_COMMAND_CATEGORY,
|
|
6
|
+
INFRA_PACKAGE_NAME,
|
|
7
|
+
INFRA_PACKAGE_VERSION,
|
|
8
|
+
} from '../constants.js';
|
|
9
|
+
import type { CreateInfraRuntimeProviderOptions } from '../types/infraCli.js';
|
|
10
|
+
import { INFRA_COMMANDS } from './constants.js';
|
|
11
|
+
import { createProviderCommandDescriptors } from './createProviderCommandDescriptors.js';
|
|
12
|
+
import { runInfraCommandAsync } from './runInfraCommandAsync.js';
|
|
13
|
+
|
|
14
|
+
/*** Compose the canonical Infra command surface as an Ankh runtime provider. */
|
|
15
|
+
export function createInfraRuntimeProvider(
|
|
16
|
+
options: CreateInfraRuntimeProviderOptions = {},
|
|
17
|
+
): AnkhRuntimeCommandProvider {
|
|
18
|
+
const runCommandImpl = options.runCommandImpl ?? runInfraCommandAsync;
|
|
19
|
+
return {
|
|
20
|
+
id: INFRA_PACKAGE_NAME,
|
|
21
|
+
category: INFRA_COMMAND_CATEGORY,
|
|
22
|
+
version: INFRA_PACKAGE_VERSION,
|
|
23
|
+
capabilities: [...INFRA_CAPABILITIES],
|
|
24
|
+
commands: createProviderCommandDescriptors(),
|
|
25
|
+
handlers: INFRA_COMMANDS.map((command) => ({
|
|
26
|
+
path: command.path,
|
|
27
|
+
handler(request) {
|
|
28
|
+
return runCommandImpl(
|
|
29
|
+
{ argv: request.argv, command, context: request.context },
|
|
30
|
+
{ services: options.services },
|
|
31
|
+
);
|
|
32
|
+
},
|
|
33
|
+
})),
|
|
34
|
+
} satisfies AnkhRuntimeCommandProvider;
|
|
35
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AnkhCommandDescriptor } from '@ankhorage/contracts/cli';
|
|
2
|
+
|
|
3
|
+
import { INFRA_COMMANDS } from './constants.js';
|
|
4
|
+
|
|
5
|
+
/*** Expose the same eight commands through Ankh provider discovery. */
|
|
6
|
+
export function createProviderCommandDescriptors(): readonly AnkhCommandDescriptor[] {
|
|
7
|
+
return INFRA_COMMANDS.map(({ capability, path, summary }) => ({ capability, path, summary }));
|
|
8
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { InfraCommandDefinition } from '../types/infraCli.js';
|
|
2
|
+
import { INFRA_COMMANDS } from './constants.js';
|
|
3
|
+
|
|
4
|
+
/*** Resolve one exact standalone Infra command name without guessing intent. */
|
|
5
|
+
export function findInfraCommand(value: string): InfraCommandDefinition | null {
|
|
6
|
+
return INFRA_COMMANDS.find((candidate) => candidate.standaloneName === value) ?? null;
|
|
7
|
+
}
|
package/src/cli/index.test.ts
CHANGED
|
@@ -1,32 +1,24 @@
|
|
|
1
1
|
import type { AnkhRuntimeCommandProvider } from '@ankhorage/ankh';
|
|
2
2
|
import { describe, expect, test } from 'bun:test';
|
|
3
3
|
|
|
4
|
-
import { createProviderCommandDescriptors
|
|
4
|
+
import { createProviderCommandDescriptors } from './createProviderCommandDescriptors.js';
|
|
5
5
|
import provider, { createInfraRuntimeProvider } from './index.js';
|
|
6
6
|
|
|
7
|
-
describe('
|
|
8
|
-
test('publishes
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
expect(expectedProvider.id).toBe('@ankhorage/infra');
|
|
12
|
-
expect(expectedProvider.category).toBe('infra');
|
|
13
|
-
expect(expectedProvider.capabilities).toEqual([
|
|
7
|
+
describe('Infra Ankh provider', () => {
|
|
8
|
+
test('publishes all eight canonical capabilities and handlers', () => {
|
|
9
|
+
const expected = createInfraRuntimeProvider() satisfies AnkhRuntimeCommandProvider;
|
|
10
|
+
expect(expected.capabilities).toEqual([
|
|
14
11
|
'infra.validate',
|
|
12
|
+
'infra.plan',
|
|
15
13
|
'infra.generate',
|
|
16
|
-
'infra.status',
|
|
17
14
|
'infra.up',
|
|
15
|
+
'infra.status',
|
|
16
|
+
'infra.outputs',
|
|
18
17
|
'infra.down',
|
|
18
|
+
'infra.destroy',
|
|
19
19
|
]);
|
|
20
|
-
expect(
|
|
21
|
-
expect(
|
|
22
|
-
|
|
23
|
-
);
|
|
24
|
-
expect(JSON.stringify(expectedProvider)).not.toContain('port-forward');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test('default export is the runtime provider', () => {
|
|
28
|
-
expect(provider.category).toBe('infra');
|
|
29
|
-
expect(provider.commands).toHaveLength(5);
|
|
30
|
-
expect(provider.handlers).toHaveLength(5);
|
|
20
|
+
expect(expected.commands).toEqual(createProviderCommandDescriptors());
|
|
21
|
+
expect(expected.handlers).toHaveLength(8);
|
|
22
|
+
expect(provider.handlers).toHaveLength(8);
|
|
31
23
|
});
|
|
32
24
|
});
|
package/src/cli/index.ts
CHANGED
|
@@ -1,53 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
createProviderCommandDescriptors,
|
|
5
|
-
INFRA_COMMANDS,
|
|
6
|
-
type InfraCommandServices,
|
|
7
|
-
runInfraCommand,
|
|
8
|
-
type RunInfraCommandImpl,
|
|
9
|
-
} from '../commands.js';
|
|
10
|
-
import {
|
|
11
|
-
INFRA_CAPABILITIES,
|
|
12
|
-
INFRA_COMMAND_CATEGORY,
|
|
13
|
-
INFRA_PACKAGE_NAME,
|
|
14
|
-
INFRA_PACKAGE_VERSION,
|
|
15
|
-
} from '../packageMetadata.js';
|
|
16
|
-
|
|
17
|
-
export interface CreateInfraRuntimeProviderOptions {
|
|
18
|
-
readonly runCommandImpl?: RunInfraCommandImpl;
|
|
19
|
-
readonly services?: Partial<InfraCommandServices>;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function createInfraRuntimeProvider(
|
|
23
|
-
options: CreateInfraRuntimeProviderOptions = {},
|
|
24
|
-
): AnkhRuntimeCommandProvider {
|
|
25
|
-
const runCommandImpl = options.runCommandImpl ?? runInfraCommand;
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
id: INFRA_PACKAGE_NAME,
|
|
29
|
-
category: INFRA_COMMAND_CATEGORY,
|
|
30
|
-
version: INFRA_PACKAGE_VERSION,
|
|
31
|
-
capabilities: [...INFRA_CAPABILITIES],
|
|
32
|
-
commands: createProviderCommandDescriptors(),
|
|
33
|
-
handlers: INFRA_COMMANDS.map((command) => ({
|
|
34
|
-
path: command.path,
|
|
35
|
-
handler(request) {
|
|
36
|
-
return runCommandImpl(
|
|
37
|
-
{
|
|
38
|
-
argv: request.argv,
|
|
39
|
-
command,
|
|
40
|
-
context: request.context,
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
services: options.services,
|
|
44
|
-
},
|
|
45
|
-
);
|
|
46
|
-
},
|
|
47
|
-
})),
|
|
48
|
-
} satisfies AnkhRuntimeCommandProvider;
|
|
49
|
-
}
|
|
1
|
+
import { createInfraRuntimeProvider } from './createInfraRuntimeProvider.js';
|
|
50
2
|
|
|
51
3
|
const provider = createInfraRuntimeProvider();
|
|
52
4
|
|
|
5
|
+
export type {
|
|
6
|
+
CreateInfraRuntimeProviderOptions,
|
|
7
|
+
InfraCommandServices,
|
|
8
|
+
RunInfraCommandImpl,
|
|
9
|
+
} from '../types/infraCli.js';
|
|
10
|
+
export { createInfraRuntimeProvider } from './createInfraRuntimeProvider.js';
|
|
53
11
|
export default provider;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { INFRA_COMMAND_CATEGORY } from '../constants.js';
|
|
2
|
+
import { INFRA_COMMANDS } from './constants.js';
|
|
3
|
+
|
|
4
|
+
/*** Render the standalone Infra command surface and environment safety rules. */
|
|
5
|
+
export function renderInfraRootHelp(version: string): string {
|
|
6
|
+
const commands = INFRA_COMMANDS.map(
|
|
7
|
+
({ standaloneName, summary }) => ` ${standaloneName.padEnd(8, ' ')} ${summary}`,
|
|
8
|
+
).join('\n');
|
|
9
|
+
return [
|
|
10
|
+
`@ankhorage/infra v${version}`,
|
|
11
|
+
'',
|
|
12
|
+
'Usage:',
|
|
13
|
+
' ankhorage-infra <command> [project] [--environment <environment>]',
|
|
14
|
+
` ankh ${INFRA_COMMAND_CATEGORY} <command> [project] [--environment <environment>]`,
|
|
15
|
+
'',
|
|
16
|
+
'Commands:',
|
|
17
|
+
commands,
|
|
18
|
+
'',
|
|
19
|
+
'Safety:',
|
|
20
|
+
' local is the only implicit environment; destroy always requires --environment and --confirm.',
|
|
21
|
+
'',
|
|
22
|
+
].join('\n');
|
|
23
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
InfraCommandContext,
|
|
3
|
+
InfraCommandRunResult,
|
|
4
|
+
InfraCommandServices,
|
|
5
|
+
RunInfraCommandImpl,
|
|
6
|
+
} from '../types/infraCli.js';
|
|
7
|
+
import { createDefaultInfraCommandContext } from './createDefaultInfraCommandContext.js';
|
|
8
|
+
import { findInfraCommand } from './findInfraCommand.js';
|
|
9
|
+
import { renderInfraRootHelp } from './renderInfraRootHelp.js';
|
|
10
|
+
import { renderUnknownInfraCommand } from './renderUnknownInfraCommand.js';
|
|
11
|
+
import { runInfraCommandAsync } from './runInfraCommandAsync.js';
|
|
12
|
+
|
|
13
|
+
/*** Dispatch the standalone executable arguments through the canonical Infra command surface. */
|
|
14
|
+
export async function runInfraCliAsync(
|
|
15
|
+
argv: readonly string[],
|
|
16
|
+
options: InfraCliOptions = {},
|
|
17
|
+
): Promise<InfraCommandRunResult> {
|
|
18
|
+
const context = options.context ?? createDefaultInfraCommandContext();
|
|
19
|
+
const runCommand = options.runCommandImpl ?? runInfraCommandAsync;
|
|
20
|
+
const [firstToken, ...restTokens] = argv;
|
|
21
|
+
if (firstToken === undefined || isHelpToken(firstToken)) {
|
|
22
|
+
context.writeStdout(renderInfraRootHelp(context.version));
|
|
23
|
+
return { exitCode: 0 };
|
|
24
|
+
}
|
|
25
|
+
if (isVersionToken(firstToken)) {
|
|
26
|
+
context.writeStdout(`${context.version}\n`);
|
|
27
|
+
return { exitCode: 0 };
|
|
28
|
+
}
|
|
29
|
+
const command = findInfraCommand(firstToken);
|
|
30
|
+
if (command === null) {
|
|
31
|
+
context.writeStderr(renderUnknownInfraCommand(firstToken));
|
|
32
|
+
return { exitCode: 1 };
|
|
33
|
+
}
|
|
34
|
+
return runCommand({ argv: restTokens, command, context }, { services: options.services });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface InfraCliOptions {
|
|
38
|
+
readonly context?: InfraCommandContext;
|
|
39
|
+
readonly runCommandImpl?: RunInfraCommandImpl;
|
|
40
|
+
readonly services?: Partial<InfraCommandServices>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/*** Recognize standalone help tokens. */
|
|
44
|
+
function isHelpToken(value: string): boolean {
|
|
45
|
+
return value === '--help' || value === '-h' || value === 'help';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/*** Recognize standalone version tokens. */
|
|
49
|
+
function isVersionToken(value: string): boolean {
|
|
50
|
+
return value === '--version' || value === '-v' || value === 'version';
|
|
51
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { APP_ENVIRONMENT_IDS } from '@ankhorage/contracts/environments';
|
|
2
|
+
|
|
3
|
+
import { INFRA_COMMAND_CATEGORY } from '../constants.js';
|
|
4
|
+
import { createInfraCommandServices } from '../features/environment-lifecycle/composition/createInfraCommandServices.js';
|
|
5
|
+
import type {
|
|
6
|
+
InfraCommandDefinition,
|
|
7
|
+
InfraCommandInvocation,
|
|
8
|
+
InfraCommandRunResult,
|
|
9
|
+
ParsedInfraArguments,
|
|
10
|
+
RunInfraCommandOptions,
|
|
11
|
+
} from '../types/infraCli.js';
|
|
12
|
+
|
|
13
|
+
/*** Run one standalone or provider-backed Infra command through the shared typed lifecycle. */
|
|
14
|
+
export async function runInfraCommandAsync(
|
|
15
|
+
request: InfraCommandInvocation,
|
|
16
|
+
options: RunInfraCommandOptions = {},
|
|
17
|
+
): Promise<InfraCommandRunResult> {
|
|
18
|
+
const services = createInfraCommandServices(options.services);
|
|
19
|
+
try {
|
|
20
|
+
const parsed = parseCommandArguments(request.command, request.argv);
|
|
21
|
+
if (parsed === null) {
|
|
22
|
+
request.context.writeStdout(renderCommandHelp(request.command));
|
|
23
|
+
return { exitCode: 0 };
|
|
24
|
+
}
|
|
25
|
+
return await request.command.run({ context: request.context, arguments: parsed }, services);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
request.context.writeStderr(
|
|
28
|
+
`Infra ${request.command.standaloneName} failed: ${getErrorMessage(error)}\n`,
|
|
29
|
+
);
|
|
30
|
+
return { exitCode: 1 };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/*** Parse the common project, environment, output and destruction options. */
|
|
35
|
+
function parseCommandArguments(
|
|
36
|
+
commandDefinition: InfraCommandDefinition,
|
|
37
|
+
argv: readonly string[],
|
|
38
|
+
): ParsedInfraArguments | null {
|
|
39
|
+
if (argv.length === 1 && isHelpToken(argv.at(0))) return null;
|
|
40
|
+
let projectId: string | undefined;
|
|
41
|
+
let environment: ParsedInfraArguments['environment'];
|
|
42
|
+
let format: ParsedInfraArguments['format'] = 'human';
|
|
43
|
+
let confirmation: string | undefined;
|
|
44
|
+
const deleteResources: string[] = [];
|
|
45
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
46
|
+
const token = argv.at(index);
|
|
47
|
+
if (token === '--environment') {
|
|
48
|
+
environment = parseEnvironment(readOptionValue(argv, ++index, token));
|
|
49
|
+
} else if (token === '--format') {
|
|
50
|
+
format = parseFormat(readOptionValue(argv, ++index, token));
|
|
51
|
+
} else if (token === '--confirm') {
|
|
52
|
+
confirmation = readOptionValue(argv, ++index, token);
|
|
53
|
+
} else if (token === '--delete-resource') {
|
|
54
|
+
deleteResources.push(readOptionValue(argv, ++index, token));
|
|
55
|
+
} else if (token?.startsWith('-') === true) {
|
|
56
|
+
throw new Error(`Unknown Infra ${commandDefinition.standaloneName} option: ${token}`);
|
|
57
|
+
} else if (projectId === undefined && token !== undefined) {
|
|
58
|
+
projectId = token;
|
|
59
|
+
} else {
|
|
60
|
+
throw new Error(
|
|
61
|
+
`Infra ${commandDefinition.standaloneName} accepts at most one project argument.`,
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (format === 'env' && commandDefinition.standaloneName !== 'outputs') {
|
|
66
|
+
throw new Error('--format env is supported only by Infra outputs.');
|
|
67
|
+
}
|
|
68
|
+
if (commandDefinition.standaloneName === 'destroy' && environment === undefined) {
|
|
69
|
+
throw new Error('Infra destroy requires --environment <local|preview|production>.');
|
|
70
|
+
}
|
|
71
|
+
return { projectId, environment, format, confirmation, deleteResources };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/*** Parse one environment identifier against the canonical closed set. */
|
|
75
|
+
function parseEnvironment(value: string): ParsedInfraArguments['environment'] {
|
|
76
|
+
const environment = APP_ENVIRONMENT_IDS.find((candidate) => candidate === value);
|
|
77
|
+
if (environment === undefined) throw new Error(`Unknown Infra environment: ${value}.`);
|
|
78
|
+
return environment;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/*** Parse the supported command output formats. */
|
|
82
|
+
function parseFormat(value: string): ParsedInfraArguments['format'] {
|
|
83
|
+
if (value === 'human' || value === 'json' || value === 'env') return value;
|
|
84
|
+
throw new Error(`Unknown Infra output format: ${value}.`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/*** Read one required CLI option value. */
|
|
88
|
+
function readOptionValue(argv: readonly string[], index: number, option: string): string {
|
|
89
|
+
const value = argv.at(index);
|
|
90
|
+
if (value === undefined || value.startsWith('-')) throw new Error(`${option} requires a value.`);
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/*** Render command-specific standalone and provider usage. */
|
|
95
|
+
function renderCommandHelp(commandDefinition: InfraCommandDefinition): string {
|
|
96
|
+
return [
|
|
97
|
+
commandDefinition.summary,
|
|
98
|
+
'',
|
|
99
|
+
'Usage:',
|
|
100
|
+
` ankhorage-infra ${commandDefinition.standaloneName} [project] [--environment <environment>]`,
|
|
101
|
+
` ankh ${INFRA_COMMAND_CATEGORY} ${commandDefinition.path.join(' ')} [project] [--environment <environment>]`,
|
|
102
|
+
'',
|
|
103
|
+
].join('\n');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/*** Normalize arbitrary command failures for the CLI boundary. */
|
|
107
|
+
function getErrorMessage(error: unknown): string {
|
|
108
|
+
return error instanceof Error ? error.message : String(error);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/*** Recognize the command-local help tokens. */
|
|
112
|
+
function isHelpToken(value: string | undefined): boolean {
|
|
113
|
+
return value === '--help' || value === '-h' || value === 'help';
|
|
114
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { AppEnvironmentId } from '@ankhorage/contracts/environments';
|
|
2
|
+
import type { InfraEnvironmentSpec, InfraManifest } from '@ankhorage/contracts/infra';
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
InfraCommandRunRequest,
|
|
6
|
+
InfraCommandServices,
|
|
7
|
+
PreparedInfraCommandOperation,
|
|
8
|
+
} from '../../types/infraCli.js';
|
|
9
|
+
|
|
10
|
+
/*** Resolve one command's project, desired environment, stored ownership and adapter dependencies. */
|
|
11
|
+
export async function prepareInfraCommandOperationAsync(
|
|
12
|
+
request: InfraCommandRunRequest,
|
|
13
|
+
services: InfraCommandServices,
|
|
14
|
+
useStoredDesired = false,
|
|
15
|
+
): Promise<PreparedInfraCommandOperation> {
|
|
16
|
+
const project = await services.resolveProject({
|
|
17
|
+
cwd: request.context.cwd,
|
|
18
|
+
...(request.arguments.projectId === undefined
|
|
19
|
+
? {}
|
|
20
|
+
: { projectId: request.arguments.projectId }),
|
|
21
|
+
});
|
|
22
|
+
const environment = request.arguments.environment ?? 'local';
|
|
23
|
+
const state = await services.readState(project.projectPath, environment);
|
|
24
|
+
const currentDesired = environmentDesired(project.manifest.infra, environment);
|
|
25
|
+
const desired = useStoredDesired && state !== null ? state.desired : currentDesired;
|
|
26
|
+
if (desired === undefined) {
|
|
27
|
+
throw new Error(`Infra environment "${environment}" is not configured.`);
|
|
28
|
+
}
|
|
29
|
+
const manifest = replaceEnvironment(project.manifest.infra, environment, desired);
|
|
30
|
+
return {
|
|
31
|
+
project,
|
|
32
|
+
state,
|
|
33
|
+
desired,
|
|
34
|
+
operation: {
|
|
35
|
+
projectId: project.projectId,
|
|
36
|
+
manifest,
|
|
37
|
+
...(request.arguments.environment === undefined ? {} : { environment }),
|
|
38
|
+
...(state === null ? {} : { previous: state.ledger, previousDesired: state.desired }),
|
|
39
|
+
},
|
|
40
|
+
dependencies: services.createDependencies(request.context),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/*** Select one exact environment specification from the canonical manifest. */
|
|
45
|
+
function environmentDesired(
|
|
46
|
+
manifest: InfraManifest,
|
|
47
|
+
environment: AppEnvironmentId,
|
|
48
|
+
): InfraEnvironmentSpec | undefined {
|
|
49
|
+
if (environment === 'local') return manifest.environments.local;
|
|
50
|
+
if (environment === 'preview') return manifest.environments.preview;
|
|
51
|
+
return manifest.environments.production;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/*** Replace one environment while preserving the rest of the canonical manifest. */
|
|
55
|
+
function replaceEnvironment(
|
|
56
|
+
manifest: InfraManifest,
|
|
57
|
+
environment: AppEnvironmentId,
|
|
58
|
+
desired: InfraEnvironmentSpec,
|
|
59
|
+
): InfraManifest {
|
|
60
|
+
return {
|
|
61
|
+
...manifest,
|
|
62
|
+
environments: { ...manifest.environments, [environment]: desired },
|
|
63
|
+
};
|
|
64
|
+
}
|