@ankhorage/infra 4.0.0 → 4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/minikube/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,kBAAkB,EAClB,+BAA+B,EAC/B,8BAA8B,EAC/B,MAAM,aAAa,CAAC;AAUrB,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,GAAE,+BAAoC,GAC5C,8BAA8B,CAmFhC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/minikube/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,kBAAkB,EAClB,+BAA+B,EAC/B,8BAA8B,EAC/B,MAAM,aAAa,CAAC;AAUrB,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,GAAE,+BAAoC,GAC5C,8BAA8B,CAuFhC"}
@@ -14,6 +14,8 @@ export function generateMinikubeInfra(manifest, options = {}) {
14
14
  throw new Error(`Unsupported database provider for minikube adapter: "${manifest.database.provider}". Only "supabase" is implemented.`);
15
15
  }
16
16
  const appSlug = validateCanonicalAppSlug(options.appManifest?.metadata.slug);
17
+ const appRuntimeEnabled = options.appManifest?.deploy === undefined ||
18
+ options.appManifest.deploy.targets.web?.enabled === true;
17
19
  const namespace = APP_NAMESPACE;
18
20
  const authArtifacts = generateAuthProviderArtifacts({
19
21
  appManifest: options.appManifest,
@@ -55,6 +57,7 @@ export function generateMinikubeInfra(manifest, options = {}) {
55
57
  providerNamespaces,
56
58
  providerLifecycle,
57
59
  extraEnvEntries,
60
+ appRuntimeEnabled,
58
61
  });
59
62
  const warnings = unique([
60
63
  ...collectWarnings(manifest),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/minikube/index.ts"],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,CAAC,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import { validateInfraApiSupport } from '../../infraValidation';\nimport type {\n GeneratedPackageDependency,\n InfraManifestInput,\n InfrastructureGenerationOptions,\n InfrastructureGenerationResult,\n} from '../../types';\nimport { generateAuthProviderArtifacts } from './auth';\nimport { generateAuthorizationArtifacts } from './authz';\nimport { APP_NAMESPACE, generateMinikubeBaseArtifacts } from './base';\nimport { generateSecretStoreArtifacts } from './secrets';\nimport { generateStorageArtifacts } from './storage';\n\nconst CANONICAL_PROJECT_SLUG_RE = /^[a-z0-9](?:[a-z0-9-]{0,38}[a-z0-9])?$/;\nconst BUILT_IN_NAMESPACES = new Set([APP_NAMESPACE, 'supabase']);\n\nexport function generateMinikubeInfra(\n manifest: InfraManifestInput,\n options: InfrastructureGenerationOptions = {},\n): InfrastructureGenerationResult {\n if (manifest.deployment?.target !== 'minikube') {\n throw new Error(\n `Minikube adapter only supports deployment target \"minikube\" (received \"${manifest.deployment?.target ?? 'undefined'}\").`,\n );\n }\n\n if (manifest.database?.provider && manifest.database.provider !== 'supabase') {\n throw new Error(\n `Unsupported database provider for minikube adapter: \"${manifest.database.provider}\". Only \"supabase\" is implemented.`,\n );\n }\n\n const appSlug = validateCanonicalAppSlug(options.appManifest?.metadata.slug);\n const namespace = APP_NAMESPACE;\n\n const authArtifacts = generateAuthProviderArtifacts({\n appManifest: options.appManifest,\n manifest,\n namespace,\n });\n const authzArtifacts = generateAuthorizationArtifacts({\n manifest,\n namespace,\n appManifest: options.appManifest,\n });\n const storageArtifacts = generateStorageArtifacts({ manifest, namespace });\n const secretStoreArtifacts = generateSecretStoreArtifacts({ manifest, namespace });\n\n const extraResources = unique([\n ...authArtifacts.resources,\n ...authzArtifacts.resources,\n ...storageArtifacts.resources,\n ...secretStoreArtifacts.resources,\n ]);\n const providerLifecycle = [\n ...authArtifacts.providerLifecycle,\n ...authzArtifacts.providerLifecycle,\n ...storageArtifacts.providerLifecycle,\n ...secretStoreArtifacts.providerLifecycle,\n ];\n const providerNamespaces = unique([\n ...providerLifecycle.map((contribution) => contribution.namespace),\n ]).filter((providerNamespace) => !BUILT_IN_NAMESPACES.has(providerNamespace));\n const extraEnvEntries = unique([\n ...authArtifacts.envEntries,\n ...authzArtifacts.envEntries,\n ...storageArtifacts.envEntries,\n ...secretStoreArtifacts.envEntries,\n ]);\n\n const baseFiles = generateMinikubeBaseArtifacts({\n manifest,\n appSlug,\n extraResources,\n providerNamespaces,\n providerLifecycle,\n extraEnvEntries,\n });\n\n const warnings = unique([\n ...collectWarnings(manifest),\n ...authArtifacts.warnings,\n ...authzArtifacts.warnings,\n ...storageArtifacts.warnings,\n ...secretStoreArtifacts.warnings,\n ]);\n\n return {\n files: [\n ...baseFiles,\n ...authArtifacts.files,\n ...authzArtifacts.files,\n ...storageArtifacts.files,\n ...secretStoreArtifacts.files,\n ],\n warnings,\n meta: {\n target: 'minikube',\n providers: collectProviders(manifest),\n },\n dependencies: collectDependencies(manifest),\n };\n}\n\nfunction collectProviders(manifest: InfraManifestInput): string[] {\n const providers = new Set<string>();\n\n if (manifest.auth?.provider) providers.add(manifest.auth.provider);\n if (manifest.auth?.authorization?.engine) {\n providers.add(manifest.auth.authorization.engine);\n }\n if (manifest.database?.provider) providers.add(manifest.database.provider);\n if (manifest.storage?.provider) providers.add(manifest.storage.provider);\n if (manifest.secretStore?.provider) providers.add(manifest.secretStore.provider);\n if (manifest.state?.provider) providers.add(manifest.state.provider);\n\n return [...providers].sort();\n}\n\nfunction collectDependencies(manifest: InfraManifestInput): readonly GeneratedPackageDependency[] {\n if (manifest.state?.provider !== 'legend') {\n return [];\n }\n\n return [\n {\n name: '@ankhorage/state-legend',\n version: '^0.1.0',\n reason: 'Selected by infra.state.provider=legend.',\n },\n ];\n}\n\nfunction collectWarnings(manifest: InfraManifestInput): string[] {\n const warnings = [...validateInfraApiSupport(manifest)];\n\n if (manifest.deployment?.monitoring) {\n warnings.push(\n 'Monitoring is enabled in manifest, but monitoring stack resources are not generated yet.',\n );\n }\n\n if (manifest.networking?.cdn) {\n warnings.push('CDN is enabled in manifest, but CDN resources are not generated for minikube.');\n }\n\n return warnings;\n}\n\nfunction validateCanonicalAppSlug(slug: string | undefined): string {\n if (!slug) {\n throw new Error(\n 'Cannot generate Minikube infrastructure: appManifest.metadata.slug is required.',\n );\n }\n\n if (slug.trim() !== slug || !CANONICAL_PROJECT_SLUG_RE.test(slug)) {\n throw new Error(\n 'Cannot generate Minikube infrastructure: appManifest.metadata.slug must be a canonical lowercase slug up to 40 characters using only a-z, 0-9, and hyphens, without leading or trailing hyphens.',\n );\n }\n\n return slug;\n}\n\nfunction unique(values: string[]): string[] {\n return [...new Set(values)];\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/minikube/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAOhE,OAAO,EAAE,6BAA6B,EAAE,MAAM,QAAQ,CAAC;AACvD,OAAO,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,6BAA6B,EAAE,MAAM,QAAQ,CAAC;AACtE,OAAO,EAAE,4BAA4B,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAErD,MAAM,yBAAyB,GAAG,wCAAwC,CAAC;AAC3E,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC,CAAC;AAEjE,MAAM,UAAU,qBAAqB,CACnC,QAA4B,EAC5B,UAA2C,EAAE;IAE7C,IAAI,QAAQ,CAAC,UAAU,EAAE,MAAM,KAAK,UAAU,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CACb,0EAA0E,QAAQ,CAAC,UAAU,EAAE,MAAM,IAAI,WAAW,KAAK,CAC1H,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,CAAC,QAAQ,E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CAAC,UAAU,EAAE,UAAU,EAAE,CAAC;QACpC,QAAQ,CAAC,IAAI,CACX,0FAA0F,CAC3F,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC;QAC7B,QAAQ,CAAC,IAAI,CAAC,+EAA+E,CAAC,CAAC;IACjG,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,wBAAwB,CAAC,IAAwB;IACxD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CACb,iFAAiF,CAClF,CAAC;IACJ,CAAC;IAED,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,IAAI,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAClE,MAAM,IAAI,KAAK,CACb,kMAAkM,CACnM,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,MAAM,CAAC,MAAgB;IAC9B,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import { validateInfraApiSupport } from '../../infraValidation';\nimport type {\n GeneratedPackageDependency,\n InfraManifestInput,\n InfrastructureGenerationOptions,\n InfrastructureGenerationResult,\n} from '../../types';\nimport { generateAuthProviderArtifacts } from './auth';\nimport { generateAuthorizationArtifacts } from './authz';\nimport { APP_NAMESPACE, generateMinikubeBaseArtifacts } from './base';\nimport { generateSecretStoreArtifacts } from './secrets';\nimport { generateStorageArtifacts } from './storage';\n\nconst CANONICAL_PROJECT_SLUG_RE = /^[a-z0-9](?:[a-z0-9-]{0,38}[a-z0-9])?$/;\nconst BUILT_IN_NAMESPACES = new Set([APP_NAMESPACE, 'supabase']);\n\nexport function generateMinikubeInfra(\n manifest: InfraManifestInput,\n options: InfrastructureGenerationOptions = {},\n): InfrastructureGenerationResult {\n if (manifest.deployment?.target !== 'minikube') {\n throw new Error(\n `Minikube adapter only supports deployment target \"minikube\" (received \"${manifest.deployment?.target ?? 'undefined'}\").`,\n );\n }\n\n if (manifest.database?.provider && manifest.database.provider !== 'supabase') {\n throw new Error(\n `Unsupported database provider for minikube adapter: \"${manifest.database.provider}\". Only \"supabase\" is implemented.`,\n );\n }\n\n const appSlug = validateCanonicalAppSlug(options.appManifest?.metadata.slug);\n const appRuntimeEnabled =\n options.appManifest?.deploy === undefined ||\n options.appManifest.deploy.targets.web?.enabled === true;\n const namespace = APP_NAMESPACE;\n\n const authArtifacts = generateAuthProviderArtifacts({\n appManifest: options.appManifest,\n manifest,\n namespace,\n });\n const authzArtifacts = generateAuthorizationArtifacts({\n manifest,\n namespace,\n appManifest: options.appManifest,\n });\n const storageArtifacts = generateStorageArtifacts({ manifest, namespace });\n const secretStoreArtifacts = generateSecretStoreArtifacts({ manifest, namespace });\n\n const extraResources = unique([\n ...authArtifacts.resources,\n ...authzArtifacts.resources,\n ...storageArtifacts.resources,\n ...secretStoreArtifacts.resources,\n ]);\n const providerLifecycle = [\n ...authArtifacts.providerLifecycle,\n ...authzArtifacts.providerLifecycle,\n ...storageArtifacts.providerLifecycle,\n ...secretStoreArtifacts.providerLifecycle,\n ];\n const providerNamespaces = unique([\n ...providerLifecycle.map((contribution) => contribution.namespace),\n ]).filter((providerNamespace) => !BUILT_IN_NAMESPACES.has(providerNamespace));\n const extraEnvEntries = unique([\n ...authArtifacts.envEntries,\n ...authzArtifacts.envEntries,\n ...storageArtifacts.envEntries,\n ...secretStoreArtifacts.envEntries,\n ]);\n\n const baseFiles = generateMinikubeBaseArtifacts({\n manifest,\n appSlug,\n extraResources,\n providerNamespaces,\n providerLifecycle,\n extraEnvEntries,\n appRuntimeEnabled,\n });\n\n const warnings = unique([\n ...collectWarnings(manifest),\n ...authArtifacts.warnings,\n ...authzArtifacts.warnings,\n ...storageArtifacts.warnings,\n ...secretStoreArtifacts.warnings,\n ]);\n\n return {\n files: [\n ...baseFiles,\n ...authArtifacts.files,\n ...authzArtifacts.files,\n ...storageArtifacts.files,\n ...secretStoreArtifacts.files,\n ],\n warnings,\n meta: {\n target: 'minikube',\n providers: collectProviders(manifest),\n },\n dependencies: collectDependencies(manifest),\n };\n}\n\nfunction collectProviders(manifest: InfraManifestInput): string[] {\n const providers = new Set<string>();\n\n if (manifest.auth?.provider) providers.add(manifest.auth.provider);\n if (manifest.auth?.authorization?.engine) {\n providers.add(manifest.auth.authorization.engine);\n }\n if (manifest.database?.provider) providers.add(manifest.database.provider);\n if (manifest.storage?.provider) providers.add(manifest.storage.provider);\n if (manifest.secretStore?.provider) providers.add(manifest.secretStore.provider);\n if (manifest.state?.provider) providers.add(manifest.state.provider);\n\n return [...providers].sort();\n}\n\nfunction collectDependencies(manifest: InfraManifestInput): readonly GeneratedPackageDependency[] {\n if (manifest.state?.provider !== 'legend') {\n return [];\n }\n\n return [\n {\n name: '@ankhorage/state-legend',\n version: '^0.1.0',\n reason: 'Selected by infra.state.provider=legend.',\n },\n ];\n}\n\nfunction collectWarnings(manifest: InfraManifestInput): string[] {\n const warnings = [...validateInfraApiSupport(manifest)];\n\n if (manifest.deployment?.monitoring) {\n warnings.push(\n 'Monitoring is enabled in manifest, but monitoring stack resources are not generated yet.',\n );\n }\n\n if (manifest.networking?.cdn) {\n warnings.push('CDN is enabled in manifest, but CDN resources are not generated for minikube.');\n }\n\n return warnings;\n}\n\nfunction validateCanonicalAppSlug(slug: string | undefined): string {\n if (!slug) {\n throw new Error(\n 'Cannot generate Minikube infrastructure: appManifest.metadata.slug is required.',\n );\n }\n\n if (slug.trim() !== slug || !CANONICAL_PROJECT_SLUG_RE.test(slug)) {\n throw new Error(\n 'Cannot generate Minikube infrastructure: appManifest.metadata.slug must be a canonical lowercase slug up to 40 characters using only a-z, 0-9, and hyphens, without leading or trailing hyphens.',\n );\n }\n\n return slug;\n}\n\nfunction unique(values: string[]): string[] {\n return [...new Set(values)];\n}\n"]}
@@ -2,5 +2,5 @@ export { type ResolvedInfraProject, resolveInfraProject as resolveInfraWorkspace
2
2
  export { resolveProjectInfrastructureDatabaseUrl } from '../projectDatabase.js';
3
3
  export { readProjectInfrastructureEnvironment } from '../projectEnvironment.js';
4
4
  export { type InfraProjectInspection, type InfraSyncResult, inspectProjectInfrastructure, resolveProjectInfrastructureTarget, syncProjectInfrastructure, } from '../projectInfrastructure.js';
5
- export { type InfraLifecycleScript, type InfraPortForwardInfo, InfraScriptExecutionError, type InfraScriptOutput, resolveProjectInfrastructurePortForward, runProjectInfrastructureLifecycle, } from '../runtime.js';
5
+ export { ensureProjectInfrastructureRuntime, type InfraLifecycleScript, type InfraPortForwardInfo, InfraScriptExecutionError, type InfraScriptOutput, resolveProjectInfrastructurePortForward, runProjectInfrastructureLifecycle, } from '../runtime.js';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/project/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,oBAAoB,EACzB,mBAAmB,IAAI,4BAA4B,GACpD,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,uCAAuC,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,oCAAoC,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,4BAA4B,EAC5B,kCAAkC,EAClC,yBAAyB,GAC1B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,yBAAyB,EACzB,KAAK,iBAAiB,EACtB,uCAAuC,EACvC,iCAAiC,GAClC,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/project/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,oBAAoB,EACzB,mBAAmB,IAAI,4BAA4B,GACpD,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,uCAAuC,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,oCAAoC,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,4BAA4B,EAC5B,kCAAkC,EAClC,yBAAyB,GAC1B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,kCAAkC,EAClC,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,yBAAyB,EACzB,KAAK,iBAAiB,EACtB,uCAAuC,EACvC,iCAAiC,GAClC,MAAM,eAAe,CAAC"}
@@ -2,5 +2,5 @@ export { resolveInfraProject as resolveInfraWorkspaceProject, } from '../project
2
2
  export { resolveProjectInfrastructureDatabaseUrl } from '../projectDatabase.js';
3
3
  export { readProjectInfrastructureEnvironment } from '../projectEnvironment.js';
4
4
  export { inspectProjectInfrastructure, resolveProjectInfrastructureTarget, syncProjectInfrastructure, } from '../projectInfrastructure.js';
5
- export { InfraScriptExecutionError, resolveProjectInfrastructurePortForward, runProjectInfrastructureLifecycle, } from '../runtime.js';
5
+ export { ensureProjectInfrastructureRuntime, InfraScriptExecutionError, resolveProjectInfrastructurePortForward, runProjectInfrastructureLifecycle, } from '../runtime.js';
6
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/project/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,IAAI,4BAA4B,GACpD,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,uCAAuC,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,oCAAoC,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAGL,4BAA4B,EAC5B,kCAAkC,EAClC,yBAAyB,GAC1B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAGL,yBAAyB,EAEzB,uCAAuC,EACvC,iCAAiC,GAClC,MAAM,eAAe,CAAC","sourcesContent":["export {\n type ResolvedInfraProject,\n resolveInfraProject as resolveInfraWorkspaceProject,\n} from '../project.js';\nexport { resolveProjectInfrastructureDatabaseUrl } from '../projectDatabase.js';\nexport { readProjectInfrastructureEnvironment } from '../projectEnvironment.js';\nexport {\n type InfraProjectInspection,\n type InfraSyncResult,\n inspectProjectInfrastructure,\n resolveProjectInfrastructureTarget,\n syncProjectInfrastructure,\n} from '../projectInfrastructure.js';\nexport {\n type InfraLifecycleScript,\n type InfraPortForwardInfo,\n InfraScriptExecutionError,\n type InfraScriptOutput,\n resolveProjectInfrastructurePortForward,\n runProjectInfrastructureLifecycle,\n} from '../runtime.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/project/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,IAAI,4BAA4B,GACpD,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,uCAAuC,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,oCAAoC,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAGL,4BAA4B,EAC5B,kCAAkC,EAClC,yBAAyB,GAC1B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,kCAAkC,EAGlC,yBAAyB,EAEzB,uCAAuC,EACvC,iCAAiC,GAClC,MAAM,eAAe,CAAC","sourcesContent":["export {\n type ResolvedInfraProject,\n resolveInfraProject as resolveInfraWorkspaceProject,\n} from '../project.js';\nexport { resolveProjectInfrastructureDatabaseUrl } from '../projectDatabase.js';\nexport { readProjectInfrastructureEnvironment } from '../projectEnvironment.js';\nexport {\n type InfraProjectInspection,\n type InfraSyncResult,\n inspectProjectInfrastructure,\n resolveProjectInfrastructureTarget,\n syncProjectInfrastructure,\n} from '../projectInfrastructure.js';\nexport {\n ensureProjectInfrastructureRuntime,\n type InfraLifecycleScript,\n type InfraPortForwardInfo,\n InfraScriptExecutionError,\n type InfraScriptOutput,\n resolveProjectInfrastructurePortForward,\n runProjectInfrastructureLifecycle,\n} from '../runtime.js';\n"]}
@@ -28,6 +28,11 @@ import { runCli } from './cli/bin.js';
28
28
  * operations accept an explicit project path and do not require Studio or a
29
29
  * particular workspace layout.
30
30
  *
31
+ * Running applications can repair their provider-aware host endpoints through
32
+ * `ensureProjectInfrastructureRuntime()` from `@ankhorage/infra/project`. This
33
+ * operation only ensures the generated runtime port-forward group; it does not
34
+ * deploy, bootstrap, or reconcile infrastructure.
35
+ *
31
36
  * @usage
32
37
  */
33
38
  await runCli(['--help']);
@@ -1 +1 @@
1
- {"version":3,"file":"readme-usage.js","sourceRoot":"","sources":["../src/readme-usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC","sourcesContent":["import { runCli } from './cli/bin.js';\n\n/***\n * Provider, CLI, and project API surface\n *\n * `@ankhorage/infra` owns infrastructure generation, project reconciliation,\n * and generated lifecycle execution.\n *\n * The same owner implementation backs CLI consumers and the public\n * `@ankhorage/infra/project` application-service boundary. Trusted hosts such\n * as Studio should call that subpath instead of reproducing ledger, generated\n * file, lifecycle-script, or port-forward configuration semantics.\n *\n * CLI entrypoints:\n *\n * - `ankh infra ...`\n * - `bunx @ankhorage/infra ...`\n *\n * Current command surface:\n *\n * - `validate`\n * - `generate`\n * - `status`\n * - `up`\n * - `down`\n *\n * Project resolution for the CLI is workspace-aware: pass `[project]`, or\n * omit it when cwd is already inside `apps/<project>`. Programmatic project\n * operations accept an explicit project path and do not require Studio or a\n * particular workspace layout.\n *\n * @usage\n */\nawait runCli(['--help']);\n"]}
1
+ {"version":3,"file":"readme-usage.js","sourceRoot":"","sources":["../src/readme-usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC","sourcesContent":["import { runCli } from './cli/bin.js';\n\n/***\n * Provider, CLI, and project API surface\n *\n * `@ankhorage/infra` owns infrastructure generation, project reconciliation,\n * and generated lifecycle execution.\n *\n * The same owner implementation backs CLI consumers and the public\n * `@ankhorage/infra/project` application-service boundary. Trusted hosts such\n * as Studio should call that subpath instead of reproducing ledger, generated\n * file, lifecycle-script, or port-forward configuration semantics.\n *\n * CLI entrypoints:\n *\n * - `ankh infra ...`\n * - `bunx @ankhorage/infra ...`\n *\n * Current command surface:\n *\n * - `validate`\n * - `generate`\n * - `status`\n * - `up`\n * - `down`\n *\n * Project resolution for the CLI is workspace-aware: pass `[project]`, or\n * omit it when cwd is already inside `apps/<project>`. Programmatic project\n * operations accept an explicit project path and do not require Studio or a\n * particular workspace layout.\n *\n * Running applications can repair their provider-aware host endpoints through\n * `ensureProjectInfrastructureRuntime()` from `@ankhorage/infra/project`. This\n * operation only ensures the generated runtime port-forward group; it does not\n * deploy, bootstrap, or reconcile infrastructure.\n *\n * @usage\n */\nawait runCli(['--help']);\n"]}
package/dist/runtime.d.ts CHANGED
@@ -33,6 +33,12 @@ export declare function resolveProjectInfrastructurePortForward(args: {
33
33
  readonly projectPath: string;
34
34
  readonly target: string;
35
35
  }): Promise<InfraPortForwardInfo>;
36
+ /** Ensures the generated host forwards required by a running application are active. */
37
+ export declare function ensureProjectInfrastructureRuntime(args: {
38
+ readonly projectId: string;
39
+ readonly projectPath: string;
40
+ readonly target: string;
41
+ }): Promise<InfraScriptOutput>;
36
42
  export declare function runProjectInfraScript(args: {
37
43
  readonly context: InfraCommandContext;
38
44
  readonly projectId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG/D,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,MAAM,GAAG,cAAc,GAAG,OAAO,GAAG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QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAwB7B;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE;IAChD,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;IACtC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,GAAG,OAAO,CAAC,IAAI,CAAC,CAUhB;AAED,wBAAgB,6BAA6B,CAAC,IAAI,EAAE;IAClD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,GAAG,MAAM,CAET"}
package/dist/runtime.js CHANGED
@@ -42,6 +42,30 @@ export async function resolveProjectInfrastructurePortForward(args) {
42
42
  url: `http://127.0.0.1:${localPort}`,
43
43
  };
44
44
  }
45
+ /** Ensures the generated host forwards required by a running application are active. */
46
+ export async function ensureProjectInfrastructureRuntime(args) {
47
+ try {
48
+ return await runProjectInfrastructureLifecycle({
49
+ args: ['start', 'runtime'],
50
+ projectId: args.projectId,
51
+ projectPath: args.projectPath,
52
+ script: 'port-forward',
53
+ target: args.target,
54
+ });
55
+ }
56
+ catch (error) {
57
+ if (!(error instanceof InfraScriptExecutionError)) {
58
+ throw error;
59
+ }
60
+ const detail = error.stderr.trim() || error.stdout.trim();
61
+ throw new InfraScriptExecutionError({
62
+ exitCode: error.exitCode,
63
+ message: `Failed to ensure infrastructure runtime for project '${args.projectId}'${detail.length > 0 ? `: ${detail}` : '.'}`,
64
+ stderr: error.stderr,
65
+ stdout: error.stdout,
66
+ });
67
+ }
68
+ }
45
69
  export async function runProjectInfraScript(args) {
46
70
  await runProjectInfrastructureLifecycle({
47
71
  env: args.context.env,
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,oCAAoC,EAAE,MAAM,yBAAyB,CAAC;AAc/E,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IACzC,QAAQ,CAAgB;IACxB,MAAM,CAAS;IACf,MAAM,CAAS;IAExB,YAAY,IAKX;QACC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;QACxC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC5B,CAAC;CACF;AAED,MAAM,CAAC,KAAK,UAAU,iCAAiC,CAAC,IASvD;IACC,MAAM,UAAU,GAAG,6BAA6B,CAAC,IAAI,CAAC,CAAC;IACvD,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CACb,2BAA2B,UAAU,qCAAqC,IAAI,CAAC,SAAS,UAAU,CACnG,CAAC;IACJ,CAAC;IAED,OAAO,cAAc,CAAC;QACpB,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE;QACrB,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG;QAC5B,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,U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AC,CAAC,IAAI,CAAC;AACrF,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,QAAgB;IACxC,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import { spawn } from 'child_process';\nimport { promises as fs } from 'fs';\nimport path from 'path';\n\nimport type { InfraCommandContext } from './commandContext.js';\nimport { readProjectInfrastructureEnvironment } from './projectEnvironment.js';\n\nexport type InfraLifecycleScript = 'destroy' | 'down' | 'port-forward' | 'reset' | 'status' | 'up';\n\nexport interface InfraScriptOutput {\n readonly stderr: string;\n readonly stdout: string;\n}\n\nexport interface InfraPortForwardInfo {\n readonly localPort: number;\n readonly url: string;\n}\n\nexport class InfraScriptExecutionError extends Error {\n readonly exitCode: number | null;\n readonly stderr: string;\n readonly stdout: string;\n\n constructor(args: {\n readonly exitCode: number | null;\n readonly message: string;\n readonly stderr: string;\n readonly stdout: string;\n }) {\n super(args.message);\n this.name = 'InfraScriptExecutionError';\n this.exitCode = args.exitCode;\n this.stderr = args.stderr;\n this.stdout = args.stdout;\n }\n}\n\nexport async function runProjectInfrastructureLifecycle(args: {\n readonly args?: readonly string[];\n readonly env?: Readonly<Record<string, string | undefined>>;\n readonly onStderr?: (chunk: string) => void;\n readonly onStdout?: (chunk: string) => void;\n readonly projectId: string;\n readonly projectPath: string;\n readonly script: InfraLifecycleScript;\n readonly target: string;\n}): Promise<InfraScriptOutput> {\n const scriptPath = resolveProjectInfraScriptPath(args);\n if (!(await pathExists(scriptPath))) {\n throw new Error(\n `Infra script not found: ${scriptPath}. Run infra generate for project '${args.projectId}' first.`,\n );\n }\n\n return runShellScript({\n args: args.args ?? [],\n env: args.env ?? process.env,\n onStderr: args.onStderr,\n onStdout: args.onStdout,\n scriptPath,\n });\n}\n\nexport async function resolveProjectInfrastructurePortForward(args: {\n readonly projectPath: string;\n readonly target: string;\n}): Promise<InfraPortForwardInfo> {\n const environment = await readProjectInfrastructureEnvironment({\n keys: ['APP_PORT_FORWARD_LOCAL_PORT'],\n projectPath: args.projectPath,\n target: args.target,\n });\n const localPort = parsePositivePort(environment.APP_PORT_FORWARD_LOCAL_PORT);\n\n if (localPort === null) {\n throw new Error(\n 'Generated Infra did not provide a valid APP_PORT_FORWARD_LOCAL_PORT. Regenerate infrastructure first.',\n );\n }\n\n return {\n localPort,\n url: `http://127.0.0.1:${localPort}`,\n };\n}\n\nexport async function runProjectInfraScript(args: {\n readonly context: InfraCommandContext;\n readonly projectId: string;\n readonly projectPath: string;\n readonly script: InfraLifecycleScript;\n readonly target: string;\n}): Promise<void> {\n await runProjectInfrastructureLifecycle({\n env: args.context.env,\n onStderr: (chunk) => args.context.writeStderr(chunk),\n onStdout: (chunk) => args.context.writeStdout(chunk),\n projectId: args.projectId,\n projectPath: args.projectPath,\n script: args.script,\n target: args.target,\n });\n}\n\nexport function resolveProjectInfraScriptPath(args: {\n readonly projectPath: string;\n readonly script: InfraLifecycleScript;\n readonly target: string;\n}): string {\n return path.join(args.projectPath, getInfraScriptsDirectory(args.target), `${args.script}.sh`);\n}\n\nfunction getInfraScriptsDirectory(target: string): string {\n switch (target) {\n case 'minikube':\n return 'infra/minikube/scripts';\n default:\n throw new Error(`Unsupported deployment target for infra scripts: ${target}`);\n }\n}\n\nasync function runShellScript(args: {\n readonly args: readonly string[];\n readonly env: Readonly<Record<string, string | undefined>>;\n readonly onStderr?: (chunk: string) => void;\n readonly onStdout?: (chunk: string) => void;\n readonly scriptPath: string;\n}): Promise<InfraScriptOutput> {\n return new Promise<InfraScriptOutput>((resolve, reject) => {\n const child = spawn('bash', [args.scriptPath, ...args.args], {\n cwd: path.dirname(args.scriptPath),\n env: { ...args.env },\n stdio: ['ignore', 'pipe', 'pipe'],\n });\n\n let stdout = '';\n let stderr = '';\n child.stdout.setEncoding('utf8');\n child.stderr.setEncoding('utf8');\n child.stdout.on('data', (chunk: string) => {\n stdout += chunk;\n args.onStdout?.(chunk);\n });\n child.stderr.on('data', (chunk: string) => {\n stderr += chunk;\n args.onStderr?.(chunk);\n });\n child.once('error', (error) =>\n reject(createStartError(args.scriptPath, error, stdout, stderr)),\n );\n child.once('close', (exitCode) => {\n if (exitCode === 0) {\n resolve({ stderr, stdout });\n return;\n }\n reject(createExitError(args.scriptPath, exitCode, stdout, stderr));\n });\n });\n}\n\nfunction createStartError(\n scriptPath: string,\n error: Error,\n stdout: string,\n stderr: string,\n): InfraScriptExecutionError {\n return new InfraScriptExecutionError({\n exitCode: null,\n message: `Failed to start infra script '${scriptPath}': ${error.message}`,\n stderr,\n stdout,\n });\n}\n\nfunction createExitError(\n scriptPath: string,\n exitCode: number | null,\n stdout: string,\n stderr: string,\n): InfraScriptExecutionError {\n return new InfraScriptExecutionError({\n exitCode,\n message: `Infra script '${scriptPath}' exited with code ${exitCode ?? 'unknown'}.`,\n stderr,\n stdout,\n });\n}\n\nfunction parsePositivePort(value: string | undefined): number | null {\n if (value === undefined) return null;\n const parsed = Number.parseInt(value.trim(), 10);\n return Number.isInteger(parsed) && parsed >= 1 && parsed <= 65_535 ? parsed : null;\n}\n\nasync function pathExists(filePath: string): Promise<boolean> {\n try {\n await fs.access(filePath);\n return true;\n } catch {\n return false;\n }\n}\n"]}
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,oCAAoC,EAAE,MAAM,yBAAyB,CAAC;AAc/E,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IACzC,QAAQ,CAAgB;IACxB,MAAM,CAAS;IACf,MAAM,CAAS;IAExB,YAAY,IAKX;QACC,KAAK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,EAAE,iBAAiB,UAAU,sBAAsB,QAAQ,IAAI,SAAS,GAAG;QAClF,MAAM;QACN,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAyB;IAClD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACrC,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IACjD,OAAO,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,CAAC,IAAI,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACrF,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,QAAgB;IACxC,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import { spawn } from 'child_process';\nimport { promises as fs } from 'fs';\nimport path from 'path';\n\nimport type { InfraCommandContext } from './commandContext.js';\nimport { readProjectInfrastructureEnvironment } from './projectEnvironment.js';\n\nexport type InfraLifecycleScript = 'destroy' | 'down' | 'port-forward' | 'reset' | 'status' | 'up';\n\nexport interface InfraScriptOutput {\n readonly stderr: string;\n readonly stdout: string;\n}\n\nexport interface InfraPortForwardInfo {\n readonly localPort: number;\n readonly url: string;\n}\n\nexport class InfraScriptExecutionError extends Error {\n readonly exitCode: number | null;\n readonly stderr: string;\n readonly stdout: string;\n\n constructor(args: {\n readonly exitCode: number | null;\n readonly message: string;\n readonly stderr: string;\n readonly stdout: string;\n }) {\n super(args.message);\n this.name = 'InfraScriptExecutionError';\n this.exitCode = args.exitCode;\n this.stderr = args.stderr;\n this.stdout = args.stdout;\n }\n}\n\nexport async function runProjectInfrastructureLifecycle(args: {\n readonly args?: readonly string[];\n readonly env?: Readonly<Record<string, string | undefined>>;\n readonly onStderr?: (chunk: string) => void;\n readonly onStdout?: (chunk: string) => void;\n readonly projectId: string;\n readonly projectPath: string;\n readonly script: InfraLifecycleScript;\n readonly target: string;\n}): Promise<InfraScriptOutput> {\n const scriptPath = resolveProjectInfraScriptPath(args);\n if (!(await pathExists(scriptPath))) {\n throw new Error(\n `Infra script not found: ${scriptPath}. Run infra generate for project '${args.projectId}' first.`,\n );\n }\n\n return runShellScript({\n args: args.args ?? [],\n env: args.env ?? process.env,\n onStderr: args.onStderr,\n onStdout: args.onStdout,\n scriptPath,\n });\n}\n\nexport async function resolveProjectInfrastructurePortForward(args: {\n readonly projectPath: string;\n readonly target: string;\n}): Promise<InfraPortForwardInfo> {\n const environment = await readProjectInfrastructureEnvironment({\n keys: ['APP_PORT_FORWARD_LOCAL_PORT'],\n projectPath: args.projectPath,\n target: args.target,\n });\n const localPort = parsePositivePort(environment.APP_PORT_FORWARD_LOCAL_PORT);\n\n if (localPort === null) {\n throw new Error(\n 'Generated Infra did not provide a valid APP_PORT_FORWARD_LOCAL_PORT. Regenerate infrastructure first.',\n );\n }\n\n return {\n localPort,\n url: `http://127.0.0.1:${localPort}`,\n };\n}\n\n/** Ensures the generated host forwards required by a running application are active. */\nexport async function ensureProjectInfrastructureRuntime(args: {\n readonly projectId: string;\n readonly projectPath: string;\n readonly target: string;\n}): Promise<InfraScriptOutput> {\n try {\n return await runProjectInfrastructureLifecycle({\n args: ['start', 'runtime'],\n projectId: args.projectId,\n projectPath: args.projectPath,\n script: 'port-forward',\n target: args.target,\n });\n } catch (error) {\n if (!(error instanceof InfraScriptExecutionError)) {\n throw error;\n }\n\n const detail = error.stderr.trim() || error.stdout.trim();\n throw new InfraScriptExecutionError({\n exitCode: error.exitCode,\n message: `Failed to ensure infrastructure runtime for project '${args.projectId}'${\n detail.length > 0 ? `: ${detail}` : '.'\n }`,\n stderr: error.stderr,\n stdout: error.stdout,\n });\n }\n}\n\nexport async function runProjectInfraScript(args: {\n readonly context: InfraCommandContext;\n readonly projectId: string;\n readonly projectPath: string;\n readonly script: InfraLifecycleScript;\n readonly target: string;\n}): Promise<void> {\n await runProjectInfrastructureLifecycle({\n env: args.context.env,\n onStderr: (chunk) => args.context.writeStderr(chunk),\n onStdout: (chunk) => args.context.writeStdout(chunk),\n projectId: args.projectId,\n projectPath: args.projectPath,\n script: args.script,\n target: args.target,\n });\n}\n\nexport function resolveProjectInfraScriptPath(args: {\n readonly projectPath: string;\n readonly script: InfraLifecycleScript;\n readonly target: string;\n}): string {\n return path.join(args.projectPath, getInfraScriptsDirectory(args.target), `${args.script}.sh`);\n}\n\nfunction getInfraScriptsDirectory(target: string): string {\n switch (target) {\n case 'minikube':\n return 'infra/minikube/scripts';\n default:\n throw new Error(`Unsupported deployment target for infra scripts: ${target}`);\n }\n}\n\nasync function runShellScript(args: {\n readonly args: readonly string[];\n readonly env: Readonly<Record<string, string | undefined>>;\n readonly onStderr?: (chunk: string) => void;\n readonly onStdout?: (chunk: string) => void;\n readonly scriptPath: string;\n}): Promise<InfraScriptOutput> {\n return new Promise<InfraScriptOutput>((resolve, reject) => {\n const child = spawn('bash', [args.scriptPath, ...args.args], {\n cwd: path.dirname(args.scriptPath),\n env: { ...args.env },\n stdio: ['ignore', 'pipe', 'pipe'],\n });\n\n let stdout = '';\n let stderr = '';\n child.stdout.setEncoding('utf8');\n child.stderr.setEncoding('utf8');\n child.stdout.on('data', (chunk: string) => {\n stdout += chunk;\n args.onStdout?.(chunk);\n });\n child.stderr.on('data', (chunk: string) => {\n stderr += chunk;\n args.onStderr?.(chunk);\n });\n child.once('error', (error) =>\n reject(createStartError(args.scriptPath, error, stdout, stderr)),\n );\n child.once('close', (exitCode) => {\n if (exitCode === 0) {\n resolve({ stderr, stdout });\n return;\n }\n reject(createExitError(args.scriptPath, exitCode, stdout, stderr));\n });\n });\n}\n\nfunction createStartError(\n scriptPath: string,\n error: Error,\n stdout: string,\n stderr: string,\n): InfraScriptExecutionError {\n return new InfraScriptExecutionError({\n exitCode: null,\n message: `Failed to start infra script '${scriptPath}': ${error.message}`,\n stderr,\n stdout,\n });\n}\n\nfunction createExitError(\n scriptPath: string,\n exitCode: number | null,\n stdout: string,\n stderr: string,\n): InfraScriptExecutionError {\n return new InfraScriptExecutionError({\n exitCode,\n message: `Infra script '${scriptPath}' exited with code ${exitCode ?? 'unknown'}.`,\n stderr,\n stdout,\n });\n}\n\nfunction parsePositivePort(value: string | undefined): number | null {\n if (value === undefined) return null;\n const parsed = Number.parseInt(value.trim(), 10);\n return Number.isInteger(parsed) && parsed >= 1 && parsed <= 65_535 ? parsed : null;\n}\n\nasync function pathExists(filePath: string): Promise<boolean> {\n try {\n await fs.access(filePath);\n return true;\n } catch {\n return false;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ankhorage/infra",
3
3
  "type": "module",
4
- "version": "4.0.0",
4
+ "version": "4.1.1",
5
5
  "description": "Project-aware infrastructure generation library and executable Ankh provider for Ankhorage.",
6
6
  "homepage": "https://github.com/ankhorage/infra#readme",
7
7
  "bugs": {
@@ -25,14 +25,32 @@ when provided by caller.
25
25
 
26
26
  ## Runtime Scripts
27
27
 
28
- - `scripts/up.sh`: starts `minikube -p <slug>`, applies manifests, waits for Supabase, runs migrations with CLI telemetry disabled for that command, builds/loads the app image, and starts slug-owned port-forwards.
28
+ - `scripts/up.sh`: starts `minikube -p <slug>`, applies manifests, waits for Supabase, runs migrations with CLI telemetry disabled for that command, and starts slug-owned port-forwards. It builds and deploys the Kubernetes Web app runtime only when the canonical app manifest enables `deploy.targets.web` (legacy manifests without `deploy` retain the Web runtime).
29
29
  - `scripts/down.sh`: stops slug-owned port-forwards, then runs `minikube stop -p <slug>`. Persistent profile data remains.
30
30
  - `scripts/reset.sh`: requires `ANKH_RESET_CONFIRM=<slug>` and deletes/recreates namespaces `app` and `supabase`, including Supabase DB and Storage PVC data. It does not delete the Minikube profile.
31
31
  - `scripts/destroy.sh`: stops slug-owned port-forwards and runs `minikube delete -p <slug>`.
32
32
  - `scripts/status.sh`: reports profile, namespace, workload, and port-forward health.
33
- - `scripts/port-forward.sh`: owns named forwards for `app`, `supabase-gateway`, `studio`, and `db-migration`.
33
+ - `scripts/port-forward.sh`: owns topology-derived named forwards plus provider-aware `runtime` and `all` groups.
34
34
  - `scripts/build-app-image.sh`: exports Expo web build from app source and builds the Docker image.
35
35
 
36
+ The `runtime` group is the canonical repair lifecycle for host endpoints required by the
37
+ running app. It contains `app` only when the generated topology includes the Kubernetes Web
38
+ app Service, and adds `supabase-gateway` when the generated Supabase Kubernetes runtime is
39
+ enabled. Native-only apps therefore restore provider endpoints without requiring a fictional
40
+ app Service. The group deliberately excludes `studio` and `db-migration`; `all` retains
41
+ those operational/bootstrap forwards. Start, stop, or inspect the group with
42
+ `scripts/port-forward.sh {start|stop|status} runtime`. Package consumers should call
43
+ `ensureProjectInfrastructureRuntime()` from `@ankhorage/infra/project` instead of depending
44
+ on concrete provider forward names. Forward startup retries bounded transient Kubernetes
45
+ pod-selection and readiness failures that can occur immediately after a profile restart.
46
+ Active runtime/all groups contain only targets in the generated topology. Cleanup retains
47
+ the exact identities of all Infra-managed forwards so a Web-to-native regeneration safely
48
+ stops an obsolete owned `app` forward without making it an active start target.
49
+
50
+ When the Web app runtime is disabled, `up.sh` also reconciles the former generated
51
+ `Deployment/app-runtime`, `Service/app-runtime`, and `ConfigMap/app-infra-config` with exact,
52
+ idempotent deletes. It does not prune unrelated resources or delete the `app` namespace.
53
+
36
54
  ## Supabase Runtime
37
55
 
38
56
  Runtime ownership is Kubernetes. Migration authoring/history remains Supabase migration
@@ -387,7 +387,9 @@ describe('generateMinikubeBaseArtifacts app-owned cluster model', () => {
387
387
  );
388
388
  expect(upScript).toContain('ensure_supabase_runtime_env\nsync_app_public_supabase_env');
389
389
  expect(upScript.lastIndexOf('sync_app_public_supabase_env')).toBeLessThan(
390
- upScript.indexOf('if [[ "${APP_BUILD_ENABLED}" == "true" ]]'),
390
+ upScript.indexOf(
391
+ 'if [[ "${APP_RUNTIME_ENABLED}" == "true" && "${APP_BUILD_ENABLED}" == "true" ]]',
392
+ ),
391
393
  );
392
394
  expect(upScript).not.toContain('SUPABASE_SERVICE_ROLE_KEY" "${SUPABASE_SERVICE_ROLE_KEY}"');
393
395
  expect(buildScript).toContain(
@@ -452,6 +454,17 @@ describe('generateMinikubeBaseArtifacts app-owned cluster model', () => {
452
454
  expect(portForwardScript).toContain('service/gateway');
453
455
  expect(portForwardScript).toContain('service/studio');
454
456
  expect(portForwardScript).toContain('service/postgres');
457
+ expect(portForwardScript).toContain('RUNTIME_FORWARD_NAMES=(app supabase-gateway)');
458
+ expect(portForwardScript).toContain(
459
+ 'ALL_FORWARD_NAMES=(app supabase-gateway studio db-migration)',
460
+ );
461
+ expect(portForwardScript).toContain(
462
+ 'start:runtime) for_each_forward start app supabase-gateway',
463
+ );
464
+ expect(portForwardScript).toContain('for_each_forward stop app supabase-gateway');
465
+ expect(portForwardScript).toContain(
466
+ 'status:runtime) for_each_forward status app supabase-gateway',
467
+ );
455
468
  expect(portForwardScript).toContain('${PROFILE}-${1}.pid');
456
469
  expect(portForwardScript).toContain('crashed stale_pid');
457
470
  expect(portForwardScript).toContain('is_port_accepting()');
@@ -488,6 +501,157 @@ describe('generateMinikubeBaseArtifacts app-owned cluster model', () => {
488
501
  expect(upScript).toContain('trap - ERR');
489
502
  expect(downScript).toContain('port-forward.sh" stop all');
490
503
  });
504
+
505
+ test('generates an app-only runtime forward group without Supabase', () => {
506
+ const result = generateInfrastructure(
507
+ {
508
+ deployment: {
509
+ target: 'minikube',
510
+ monitoring: false,
511
+ },
512
+ modules: [],
513
+ },
514
+ {
515
+ appManifest: createAppManifest('frontend-only'),
516
+ },
517
+ );
518
+ const portForwardScript = getFile(result.files, 'infra/minikube/scripts/port-forward.sh');
519
+
520
+ expect(portForwardScript).toContain('RUNTIME_FORWARD_NAMES=(app)');
521
+ expect(portForwardScript).toContain('ALL_FORWARD_NAMES=(app)');
522
+ expect(portForwardScript).toContain(
523
+ 'OBSOLETE_FORWARD_NAMES=(supabase-gateway studio db-migration)',
524
+ );
525
+ expect(portForwardScript).not.toContain('RUNTIME_FORWARD_NAMES=(app supabase-gateway)');
526
+ });
527
+
528
+ test('reconciles a generated Web topology to the exact native-only desired topology', () => {
529
+ const baseManifest = createAppManifest('topology-upgrade');
530
+ const webResult = generateInfrastructure(createSupabaseManifest(), {
531
+ appManifest: {
532
+ ...baseManifest,
533
+ deploy: { targets: { web: { enabled: true } } },
534
+ },
535
+ });
536
+ const nativeResult = generateInfrastructure(createSupabaseManifest(), {
537
+ appManifest: {
538
+ ...baseManifest,
539
+ deploy: {
540
+ targets: {
541
+ android: { enabled: true, package: 'com.ankh.topologyupgrade' },
542
+ },
543
+ },
544
+ },
545
+ });
546
+ const webPaths = webResult.files.map((file) => file.path);
547
+ const nativePaths = nativeResult.files.map((file) => file.path);
548
+ const webAppConfig = getFile(webResult.files, 'infra/minikube/k8s/app.configmap.yaml');
549
+ const webUpScript = getFile(webResult.files, 'infra/minikube/scripts/up.sh');
550
+ const nativeUpScript = getFile(nativeResult.files, 'infra/minikube/scripts/up.sh');
551
+ const nativePortForwardScript = getFile(
552
+ nativeResult.files,
553
+ 'infra/minikube/scripts/port-forward.sh',
554
+ );
555
+ const exactDelete =
556
+ 'delete deployment/app-runtime service/app-runtime configmap/app-infra-config --ignore-not-found';
557
+
558
+ expect(webPaths).toContain('infra/minikube/k8s/app/deployment.yaml');
559
+ expect(webPaths).toContain('infra/minikube/k8s/app/service.yaml');
560
+ expect(webPaths).toContain('infra/minikube/k8s/app.configmap.yaml');
561
+ expect(webAppConfig).toContain('name: app-infra-config');
562
+ expect(getFile(webResult.files, 'infra/minikube/scripts/port-forward.sh')).toContain(
563
+ 'RUNTIME_FORWARD_NAMES=(app supabase-gateway)',
564
+ );
565
+
566
+ expect(nativePaths).not.toContain('infra/minikube/k8s/app/deployment.yaml');
567
+ expect(nativePaths).not.toContain('infra/minikube/k8s/app/service.yaml');
568
+ expect(nativePaths).not.toContain('infra/minikube/k8s/app.configmap.yaml');
569
+ expect(nativeUpScript).toContain(exactDelete);
570
+ expect(nativeUpScript).toContain('"${PORT_FORWARD_SCRIPT}" stop obsolete');
571
+ expect(nativeUpScript.indexOf(exactDelete)).toBeLessThan(
572
+ nativeUpScript.indexOf('"${PORT_FORWARD_SCRIPT}" stop obsolete'),
573
+ );
574
+ expect(nativePortForwardScript).toContain(
575
+ 'MANAGED_FORWARD_NAMES=(app supabase-gateway studio db-migration)',
576
+ );
577
+ expect(nativePortForwardScript).toContain('OBSOLETE_FORWARD_NAMES=(app)');
578
+ expect(webUpScript).not.toContain(exactDelete);
579
+ expect(webUpScript).not.toContain('stop obsolete');
580
+ });
581
+
582
+ test('derives native-only runtime topology without a fictional Kubernetes app service', () => {
583
+ const appManifest = {
584
+ ...createAppManifest('native-only'),
585
+ deploy: {
586
+ targets: {
587
+ android: { enabled: true, package: 'com.ankh.nativeonly' },
588
+ ios: { enabled: true, bundleIdentifier: 'com.ankh.nativeonly' },
589
+ },
590
+ },
591
+ };
592
+ const result = generateInfrastructure(createSupabaseManifest(), { appManifest });
593
+ const paths = result.files.map((file) => file.path);
594
+ const kustomization = getFile(result.files, 'infra/minikube/k8s/kustomization.yaml');
595
+ const portForwardScript = getFile(result.files, 'infra/minikube/scripts/port-forward.sh');
596
+ const upScript = getFile(result.files, 'infra/minikube/scripts/up.sh');
597
+ const readme = getFile(result.files, 'infra/minikube/README.md');
598
+
599
+ expect(paths).not.toContain('infra/minikube/k8s/app/deployment.yaml');
600
+ expect(paths).not.toContain('infra/minikube/k8s/app/service.yaml');
601
+ expect(paths).not.toContain('infra/minikube/k8s/app.configmap.yaml');
602
+ expect(kustomization).not.toContain('app/deployment.yaml');
603
+ expect(kustomization).not.toContain('app/service.yaml');
604
+ expect(portForwardScript).toContain('RUNTIME_FORWARD_NAMES=(supabase-gateway)');
605
+ expect(portForwardScript).toContain('ALL_FORWARD_NAMES=(supabase-gateway studio db-migration)');
606
+ expect(portForwardScript).toContain(
607
+ 'MANAGED_FORWARD_NAMES=(app supabase-gateway studio db-migration)',
608
+ );
609
+ expect(portForwardScript).toContain('OBSOLETE_FORWARD_NAMES=(app)');
610
+ expect(portForwardScript).toContain('${name}: skipped (Web app runtime disabled)');
611
+ expect(upScript).toContain('APP_RUNTIME_ENABLED="false"');
612
+ expect(upScript).toContain(
613
+ 'delete deployment/app-runtime service/app-runtime configmap/app-infra-config --ignore-not-found',
614
+ );
615
+ expect(readme).toContain('disabled (no enabled Web deploy target)');
616
+ expect(JSON.stringify(result.files)).not.toContain('adb');
617
+ expect(JSON.stringify(result.files)).not.toContain('10.0.2.2');
618
+ });
619
+
620
+ test('keeps legacy manifests without deploy targets on the Web app runtime topology', () => {
621
+ const result = generateInfrastructure(createSupabaseManifest(), {
622
+ appManifest: createAppManifest('legacy-web'),
623
+ });
624
+ const paths = result.files.map((file) => file.path);
625
+ const portForwardScript = getFile(result.files, 'infra/minikube/scripts/port-forward.sh');
626
+ const upScript = getFile(result.files, 'infra/minikube/scripts/up.sh');
627
+
628
+ expect(paths).toContain('infra/minikube/k8s/app/service.yaml');
629
+ expect(portForwardScript).toContain('RUNTIME_FORWARD_NAMES=(app supabase-gateway)');
630
+ expect(portForwardScript).toContain('OBSOLETE_FORWARD_NAMES=()');
631
+ expect(upScript).not.toContain('delete deployment/app-runtime');
632
+ });
633
+
634
+ test('generates an empty provider-agnostic runtime group when no host target exists', () => {
635
+ const appManifest = {
636
+ ...createAppManifest('native-no-provider'),
637
+ deploy: {
638
+ targets: {
639
+ android: { enabled: true, package: 'com.ankh.nativeproviderless' },
640
+ },
641
+ },
642
+ };
643
+ const result = generateInfrastructure(
644
+ { deployment: { target: 'minikube', monitoring: false }, modules: [] },
645
+ { appManifest },
646
+ );
647
+ const portForwardScript = getFile(result.files, 'infra/minikube/scripts/port-forward.sh');
648
+
649
+ expect(portForwardScript).toContain('RUNTIME_FORWARD_NAMES=()');
650
+ expect(portForwardScript).toContain('ALL_FORWARD_NAMES=()');
651
+ expect(portForwardScript).toContain(
652
+ 'OBSOLETE_FORWARD_NAMES=(app supabase-gateway studio db-migration)',
653
+ );
654
+ });
491
655
  });
492
656
 
493
657
  function createSupabaseManifest(): InfraManifestInput {