@geekmidas/cli 10.0.0-alpha.62 → 10.0.0-alpha.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/{HostingerProvider-B92qH4dC.mjs → HostingerProvider-DBBwpDjn.mjs} +2 -2
- package/dist/{HostingerProvider-B92qH4dC.mjs.map → HostingerProvider-DBBwpDjn.mjs.map} +1 -1
- package/dist/{HostingerProvider-DyD1Hin8.cjs → HostingerProvider-mJ7YruxH.cjs} +2 -2
- package/dist/{HostingerProvider-DyD1Hin8.cjs.map → HostingerProvider-mJ7YruxH.cjs.map} +1 -1
- package/dist/{LegacyStateStore-UHJEBLdn.cjs → LegacyStateStore-CP7SZwTP.cjs} +2 -2
- package/dist/{LegacyStateStore-UHJEBLdn.cjs.map → LegacyStateStore-CP7SZwTP.cjs.map} +1 -1
- package/dist/{LegacyStateStore-A8d2GdT7.mjs → LegacyStateStore-Q3GmKOdw.mjs} +2 -2
- package/dist/{LegacyStateStore-A8d2GdT7.mjs.map → LegacyStateStore-Q3GmKOdw.mjs.map} +1 -1
- package/dist/{LocalStateStore-B51rnfgn.mjs → LocalStateStore-BGIXcrvX.mjs} +2 -2
- package/dist/{LocalStateStore-B51rnfgn.mjs.map → LocalStateStore-BGIXcrvX.mjs.map} +1 -1
- package/dist/{LocalStateStore-COW3Ldwa.cjs → LocalStateStore-sS8mvLeq.cjs} +2 -2
- package/dist/{LocalStateStore-COW3Ldwa.cjs.map → LocalStateStore-sS8mvLeq.cjs.map} +1 -1
- package/dist/{OpenApiTsGenerator-BSrgw7B0.cjs → OpenApiTsGenerator-CjHWFRDd.cjs} +2 -2
- package/dist/{OpenApiTsGenerator-BSrgw7B0.cjs.map → OpenApiTsGenerator-CjHWFRDd.cjs.map} +1 -1
- package/dist/{OpenApiTsGenerator-q5B0z8Xg.mjs → OpenApiTsGenerator-CnAwhGxi.mjs} +2 -2
- package/dist/{OpenApiTsGenerator-q5B0z8Xg.mjs.map → OpenApiTsGenerator-CnAwhGxi.mjs.map} +1 -1
- package/dist/{S3StateStore-WUJGdRNL.cjs → S3StateStore-6jqITH2F.cjs} +2 -2
- package/dist/{S3StateStore-WUJGdRNL.cjs.map → S3StateStore-6jqITH2F.cjs.map} +1 -1
- package/dist/{S3StateStore-CJewPhgz.mjs → S3StateStore-D7l_lWJ3.mjs} +2 -2
- package/dist/{S3StateStore-CJewPhgz.mjs.map → S3StateStore-D7l_lWJ3.mjs.map} +1 -1
- package/dist/{SSMStateStore-Zejt42V8.cjs → SSMStateStore-B__F7IJa.cjs} +2 -2
- package/dist/{SSMStateStore-Zejt42V8.cjs.map → SSMStateStore-B__F7IJa.cjs.map} +1 -1
- package/dist/{SSMStateStore-iK5UKp9d.mjs → SSMStateStore-CAQDVpoc.mjs} +2 -2
- package/dist/{SSMStateStore-iK5UKp9d.mjs.map → SSMStateStore-CAQDVpoc.mjs.map} +1 -1
- package/dist/{bundler-CfH9frOS.cjs → bundler-DLfOn0ls.cjs} +3 -3
- package/dist/{bundler-CfH9frOS.cjs.map → bundler-DLfOn0ls.cjs.map} +1 -1
- package/dist/{bundler-DN5r4x5b.mjs → bundler-DyWI41Iy.mjs} +2 -2
- package/dist/{bundler-DN5r4x5b.mjs.map → bundler-DyWI41Iy.mjs.map} +1 -1
- package/dist/{cli-DOAUp80L.cjs → cli-D-ZM-X2s.cjs} +4 -4
- package/dist/{cli-DOAUp80L.cjs.map → cli-D-ZM-X2s.cjs.map} +1 -1
- package/dist/{cli-DYwxmfsW.mjs → cli-PkVF28LM.mjs} +4 -4
- package/dist/{cli-DYwxmfsW.mjs.map → cli-PkVF28LM.mjs.map} +1 -1
- package/dist/{config-BYh9S0cZ.cjs → config-BEJYKd4s.cjs} +132 -18
- package/dist/config-BEJYKd4s.cjs.map +1 -0
- package/dist/config-C2BUosLm.d.mts +256 -0
- package/dist/config-C2BUosLm.d.mts.map +1 -0
- package/dist/config-CemHVcIr.d.cts +256 -0
- package/dist/config-CemHVcIr.d.cts.map +1 -0
- package/dist/{config-Bf4-bROQ.mjs → config-LKKCVCnC.mjs} +109 -19
- package/dist/config-LKKCVCnC.mjs.map +1 -0
- package/dist/config.cjs +6 -2
- package/dist/config.d.cts +3 -210
- package/dist/config.d.mts +3 -210
- package/dist/config.mjs +3 -3
- package/dist/deploy/public.cjs +151 -5
- package/dist/deploy/public.cjs.map +1 -0
- package/dist/deploy/public.d.cts +186 -1
- package/dist/deploy/public.d.cts.map +1 -1
- package/dist/deploy/public.d.mts +186 -1
- package/dist/deploy/public.d.mts.map +1 -1
- package/dist/deploy/public.mjs +134 -6
- package/dist/deploy/public.mjs.map +1 -0
- package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
- package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
- package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
- package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
- package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
- package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
- package/dist/{deploy-DSaCYvcO.cjs → deploy-ABBI0lf1.cjs} +7 -7
- package/dist/{deploy-DSaCYvcO.cjs.map → deploy-ABBI0lf1.cjs.map} +1 -1
- package/dist/{deploy-D8Qr-Xto.cjs → deploy-BiMrP9i7.cjs} +11 -9
- package/dist/deploy-BiMrP9i7.cjs.map +1 -0
- package/dist/{deploy-B7jvUORo.mjs → deploy-CG8bfFij.mjs} +7 -7
- package/dist/{deploy-B7jvUORo.mjs.map → deploy-CG8bfFij.mjs.map} +1 -1
- package/dist/{deploy-Cg9fae7a.mjs → deploy-CGW-QY9D.mjs} +11 -9
- package/dist/deploy-CGW-QY9D.mjs.map +1 -0
- package/dist/discover-B6yPpvRV.d.mts +99 -0
- package/dist/discover-B6yPpvRV.d.mts.map +1 -0
- package/dist/discover-B_IkPukx.d.cts +99 -0
- package/dist/discover-B_IkPukx.d.cts.map +1 -0
- package/dist/discover-BaT6bpnA.mjs +614 -0
- package/dist/discover-BaT6bpnA.mjs.map +1 -0
- package/dist/discover-C_6COHEv.cjs +729 -0
- package/dist/discover-C_6COHEv.cjs.map +1 -0
- package/dist/{dokploy-CD9PY-3D.mjs → dokploy-CwdmlyQL.mjs} +2 -2
- package/dist/{dokploy-CD9PY-3D.mjs.map → dokploy-CwdmlyQL.mjs.map} +1 -1
- package/dist/{dokploy-Ey2foJLv.cjs → dokploy-QJxMhxdf.cjs} +2 -2
- package/dist/{dokploy-Ey2foJLv.cjs.map → dokploy-QJxMhxdf.cjs.map} +1 -1
- package/dist/{encryption-CVwvGbsL.mjs → encryption-CbQG_ayW.mjs} +4 -4
- package/dist/{encryption-CVwvGbsL.mjs.map → encryption-CbQG_ayW.mjs.map} +1 -1
- package/dist/{encryption-ChBk3hTj.cjs → encryption-DXw3jj0c.cjs} +4 -4
- package/dist/{encryption-ChBk3hTj.cjs.map → encryption-DXw3jj0c.cjs.map} +1 -1
- package/dist/fakes-C9RiT6XG.mjs.map +1 -1
- package/dist/fakes-zW-jNAbQ.cjs.map +1 -1
- package/dist/{github-OUgPDlqg.cjs → github-BH_mETav.cjs} +3 -3
- package/dist/{github-OUgPDlqg.cjs.map → github-BH_mETav.cjs.map} +1 -1
- package/dist/{github-BCB3_LBX.mjs → github-ciwbIwVa.mjs} +3 -3
- package/dist/{github-BCB3_LBX.mjs.map → github-ciwbIwVa.mjs.map} +1 -1
- package/dist/index.cjs +55 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +52 -45
- package/dist/index.mjs.map +1 -1
- package/dist/{migrate-dnaFMvOm.cjs → migrate-6oa9y_f2.cjs} +5 -5
- package/dist/{migrate-dnaFMvOm.cjs.map → migrate-6oa9y_f2.cjs.map} +1 -1
- package/dist/{migrate-BoHMqdCu.mjs → migrate-ImBKTBcW.mjs} +5 -5
- package/dist/{migrate-BoHMqdCu.mjs.map → migrate-ImBKTBcW.mjs.map} +1 -1
- package/dist/openapi.cjs +3 -3
- package/dist/openapi.mjs +3 -3
- package/dist/{ready-XlNx-Gbo.cjs → ready-BiG0rt4h.cjs} +3 -3
- package/dist/{ready-XlNx-Gbo.cjs.map → ready-BiG0rt4h.cjs.map} +1 -1
- package/dist/{ready-DQIy21W5.mjs → ready-Bpdnn2ON.mjs} +3 -3
- package/dist/{ready-DQIy21W5.mjs.map → ready-Bpdnn2ON.mjs.map} +1 -1
- package/dist/reconcile/public.cjs +1 -1
- package/dist/reconcile/public.d.cts +3 -76
- package/dist/reconcile/public.d.cts.map +1 -1
- package/dist/reconcile/public.d.mts +3 -76
- package/dist/reconcile/public.d.mts.map +1 -1
- package/dist/reconcile/public.mjs +1 -1
- package/dist/{resolve-CFCIkm7m.mjs → resolve-B1T0hUaR.mjs} +2 -2
- package/dist/{resolve-CFCIkm7m.mjs.map → resolve-B1T0hUaR.mjs.map} +1 -1
- package/dist/{resolve-wbv66HjD.cjs → resolve-xytBTtG4.cjs} +2 -2
- package/dist/{resolve-wbv66HjD.cjs.map → resolve-xytBTtG4.cjs.map} +1 -1
- package/dist/sandbox/config-worker.cjs +43 -0
- package/dist/sandbox/config-worker.cjs.map +1 -0
- package/dist/sandbox/config-worker.d.cts +1 -0
- package/dist/sandbox/config-worker.d.mts +1 -0
- package/dist/sandbox/config-worker.mjs +44 -0
- package/dist/sandbox/config-worker.mjs.map +1 -0
- package/dist/sandbox/discover-worker.cjs +44 -0
- package/dist/sandbox/discover-worker.cjs.map +1 -0
- package/dist/sandbox/discover-worker.d.cts +1 -0
- package/dist/sandbox/discover-worker.d.mts +1 -0
- package/dist/sandbox/discover-worker.mjs +45 -0
- package/dist/sandbox/discover-worker.mjs.map +1 -0
- package/dist/sandbox-M8UnLhXE.d.cts +126 -0
- package/dist/sandbox-M8UnLhXE.d.cts.map +1 -0
- package/dist/sandbox-M8UnLhXE.d.mts +126 -0
- package/dist/sandbox-M8UnLhXE.d.mts.map +1 -0
- package/dist/{workspace-BFe57es7.mjs → schemas-Ckm_aBnF.cjs} +71 -982
- package/dist/schemas-Ckm_aBnF.cjs.map +1 -0
- package/dist/{workspace-B6zQO6RY.cjs → schemas-D2LCF689.mjs} +2 -1168
- package/dist/schemas-D2LCF689.mjs.map +1 -0
- package/dist/{sniffer-BsfPa-GA.cjs → sniffer-D_SYc_pO.cjs} +369 -207
- package/dist/sniffer-D_SYc_pO.cjs.map +1 -0
- package/dist/{sniffer-DHE2Nafd.mjs → sniffer-aO_-s5vq.mjs} +336 -204
- package/dist/sniffer-aO_-s5vq.mjs.map +1 -0
- package/dist/target/public.cjs +1 -1
- package/dist/target/public.mjs +1 -1
- package/dist/{terminal-6oL0vANs.cjs → terminal-D0f1u0LG.cjs} +6 -6
- package/dist/{terminal-6oL0vANs.cjs.map → terminal-D0f1u0LG.cjs.map} +1 -1
- package/dist/{terminal-ByZNjuig.mjs → terminal-gMxAo9Dj.mjs} +6 -6
- package/dist/{terminal-ByZNjuig.mjs.map → terminal-gMxAo9Dj.mjs.map} +1 -1
- package/dist/vitest.cjs +2 -2
- package/dist/vitest.mjs +2 -2
- package/dist/workerRuntime-BXfhbe13.cjs +108 -0
- package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
- package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
- package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.mjs +1 -1
- package/dist/workspace-Dh7rr7l4.mjs +1024 -0
- package/dist/workspace-Dh7rr7l4.mjs.map +1 -0
- package/dist/workspace-Kl4NG9IH.cjs +1196 -0
- package/dist/workspace-Kl4NG9IH.cjs.map +1 -0
- package/package.json +13 -13
- package/dist/config-BYh9S0cZ.cjs.map +0 -1
- package/dist/config-Bf4-bROQ.mjs.map +0 -1
- package/dist/config.d.cts.map +0 -1
- package/dist/config.d.mts.map +0 -1
- package/dist/deploy-Cg9fae7a.mjs.map +0 -1
- package/dist/deploy-D8Qr-Xto.cjs.map +0 -1
- package/dist/discover-Bc-4eA_p.cjs +0 -299
- package/dist/discover-Bc-4eA_p.cjs.map +0 -1
- package/dist/discover-FrYvzkeC.mjs +0 -262
- package/dist/discover-FrYvzkeC.mjs.map +0 -1
- package/dist/sniffer-BsfPa-GA.cjs.map +0 -1
- package/dist/sniffer-DHE2Nafd.mjs.map +0 -1
- package/dist/workspace-B6zQO6RY.cjs.map +0 -1
- package/dist/workspace-BFe57es7.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-wbv66HjD.cjs","names":["DeployTargetNotYetSupported","builtinTarget","DeployTargetNotYetSupported","configuredTarget","UnknownDeployTarget","configurableBuiltins","declaredRuntime","importPackage","isDeployTarget"],"sources":["../src/target/provider.ts","../src/target/resolve.ts"],"sourcesContent":["/**\n * `gkm deploy --provider`, from before there were targets.\n *\n * It named three things, and only one of them ever deployed a workspace:\n * `dokploy` is now the target of that name; `docker` and `aws-lambda` were\n * accepted and always failed, so they are gone with a pointer to what does\n * the job.\n */\n\nimport { DeployTargetNotYetSupported } from './builtins';\n\n/** What each removed provider's job is done with now. */\nconst REMOVED: Record<string, string> = {\n\tdocker:\n\t\t'Build images with `gkm docker`, or run the stage as one Docker Compose stack with `gkm compose`',\n\t'aws-lambda':\n\t\t\"Deploy to AWS with SST: set deploy: { default: 'sst' } and run `gkm build && sst deploy --stage <stage>`\",\n};\n\n/** A `--provider` that no longer exists. */\nexport class ProviderRemoved extends Error {\n\tconstructor(\n\t\treadonly provider: string,\n\t\t/** What to use instead. */\n\t\treadonly instead: string,\n\t) {\n\t\tsuper(`--provider ${provider} has been removed. ${instead}.`);\n\t\tthis.name = 'ProviderRemoved';\n\t}\n}\n\n/** The deprecation `--provider` prints when it still means something. */\nexport function providerDeprecation(provider: string): string {\n\treturn `--provider is deprecated; use --target ${provider}.`;\n}\n\n/**\n * The target a `--provider` value means. `warn` hears the deprecation; a\n * provider that is gone, or a target not deployable yet, throws.\n */\nexport function targetForProvider(\n\tprovider: string,\n\twarn: (message: string) => void,\n): string {\n\tconst removed = REMOVED[provider];\n\tif (removed) throw new ProviderRemoved(provider, removed);\n\tif (provider === 'vercel' || provider === 'cloudflare') {\n\t\tthrow new DeployTargetNotYetSupported(provider);\n\t}\n\twarn(providerDeprecation(provider));\n\treturn provider;\n}\n","/**\n * From a target's name to the target.\n *\n * In this order, the first that has the name wins:\n *\n * 1. the host's own targets — what a program calling `deploy()` passes\n * 2. the built-ins — `dokploy`\n * 3. `deploy.targets` in gkm.config.ts — a package, an object, or either\n * with options\n *\n * Built-ins come before the config so that a dependency cannot take over\n * `dokploy` by being listed under its name. A name nothing has is\n * `UnknownDeployTarget`. There is deliberately no fourth step that guesses a\n * package from the name (`acme` → `@acme/gkm-target`): an npm scope nobody\n * has claimed can be claimed by anyone, and a deploy would then run their\n * code with the stage's credentials. A target is installed and named.\n */\n\nimport {\n\tbuiltinTarget,\n\tconfigurableBuiltins,\n\tconfiguredTarget,\n\tDeployTargetNotYetSupported,\n\tUnknownDeployTarget,\n} from './builtins';\nimport { isDeployTarget } from './define';\nimport { importPackage } from './package';\nimport { declaredRuntime } from './runtime';\nimport type {\n\tAnyDeployTarget,\n\tDeployRuntime,\n\tDeployTargetEntry,\n\tTargetOptionsIssue,\n} from './types';\n\n/** Where a target came from. */\nexport type TargetSourceKind = 'host' | 'builtin' | 'config';\n\nexport interface ResolvedTarget {\n\t/** The name it was asked for by. */\n\tname: string;\n\ttarget: AnyDeployTarget;\n\tsource: TargetSourceKind;\n\t/** Its options as written in the config, before its schema parsed them. */\n\toptions: unknown;\n}\n\nexport interface ResolveTargetOptions {\n\t/** The workspace whose `deploy.targets` is consulted. */\n\tworkspace: {\n\t\troot: string;\n\t\tdeploy?: { targets?: Record<string, DeployTargetEntry> } | undefined;\n\t};\n\t/** The host's targets, consulted first. */\n\thost?: Record<string, AnyDeployTarget>;\n\t/** The stage being deployed, for what to do instead of a refused target. */\n\tstage: string;\n}\n\n/** A target package whose default export is not a target. */\nexport class TargetPackageInvalid extends Error {\n\tconstructor(\n\t\treadonly target: string,\n\t\treadonly packageName: string,\n\t) {\n\t\tsuper(\n\t\t\t`deploy.targets.${target} names \"${packageName}\", whose default export is not a deploy target. A target package exports one as default: export default defineTarget({ … }) from '@geekmidas/cli/target'.`,\n\t\t);\n\t\tthis.name = 'TargetPackageInvalid';\n\t}\n}\n\n/** A `deploy.targets` entry that is not a target, a package name or a pair. */\nexport class TargetEntryInvalid extends Error {\n\tconstructor(readonly target: string) {\n\t\tsuper(\n\t\t\t`deploy.targets.${target} must be a package name, a target object (defineTarget), or [package or target, options].`,\n\t\t);\n\t\tthis.name = 'TargetEntryInvalid';\n\t}\n}\n\n/** A target whose `runtime` is not the one its package declares. */\nexport class TargetRuntimeMismatch extends Error {\n\tconstructor(\n\t\treadonly target: string,\n\t\treadonly packageName: string,\n\t\treadonly declared: DeployRuntime,\n\t\treadonly actual: DeployRuntime,\n\t) {\n\t\tsuper(\n\t\t\t`The deploy target \"${target}\" runs on \"${actual}\", but ${packageName}'s package.json declares gkm.runtime \"${declared}\". gkm dev and gkm build chose backends for \"${declared}\", so the two must agree — fix the package.`,\n\t\t);\n\t\tthis.name = 'TargetRuntimeMismatch';\n\t}\n}\n\n/** Options a target's schema rejected. */\nexport class InvalidTargetOptions extends Error {\n\tconstructor(\n\t\treadonly target: string,\n\t\treadonly issues: readonly TargetOptionsIssue[],\n\t) {\n\t\tconst lines = issues.map((issue) => {\n\t\t\tconst path = (issue.path ?? [])\n\t\t\t\t.map((segment) =>\n\t\t\t\t\ttypeof segment === 'object' ? String(segment.key) : String(segment),\n\t\t\t\t)\n\t\t\t\t.join('.');\n\t\t\treturn ` - ${path ? `${path}: ` : ''}${issue.message}`;\n\t\t});\n\t\tsuper(\n\t\t\t`The options for deploy target \"${target}\" are invalid — fix them in deploy.targets.${target} in gkm.config.ts:\\n${lines.join('\\n')}`,\n\t\t);\n\t\tthis.name = 'InvalidTargetOptions';\n\t}\n}\n\n/** The built-ins `gkm deploy` deploys through, loaded only when used. */\nconst BUILTIN_LOADERS: Record<string, () => Promise<AnyDeployTarget>> = {\n\tdokploy: async () => (await import('./dokploy')).dokployTarget,\n};\n\n/** The target `name` means, in this workspace, for this host. */\nexport async function resolveTarget(\n\tname: string,\n\t{ workspace, host, stage }: ResolveTargetOptions,\n): Promise<ResolvedTarget> {\n\tif (host && Object.hasOwn(host, name)) {\n\t\treturn { name, target: host[name]!, source: 'host', options: undefined };\n\t}\n\n\tconst builtin = builtinTarget(name);\n\tif (builtin) {\n\t\tconst load = BUILTIN_LOADERS[name];\n\t\tif (builtin.status !== 'available' || !load) {\n\t\t\tthrow new DeployTargetNotYetSupported(name, builtin.instead?.(stage));\n\t\t}\n\t\treturn {\n\t\t\tname,\n\t\t\ttarget: await load(),\n\t\t\tsource: 'builtin',\n\t\t\toptions: undefined,\n\t\t};\n\t}\n\n\tconst entry = configuredTarget(workspace.deploy, name);\n\tif (entry === undefined) {\n\t\tthrow new UnknownDeployTarget(name, [\n\t\t\t...configurableBuiltins(),\n\t\t\t...Object.keys(workspace.deploy?.targets ?? {}),\n\t\t]);\n\t}\n\n\tconst [implementation, options] = Array.isArray(entry)\n\t\t? (entry as readonly [unknown, unknown])\n\t\t: [entry, undefined];\n\n\tif (typeof implementation === 'string') {\n\t\t// Before the import: a package that does not say where it runs is\n\t\t// refused without running any of its code.\n\t\tconst declared = declaredRuntime(name, implementation, workspace.root);\n\t\tconst loaded = await importPackage(name, implementation, workspace.root);\n\t\tconst target = loaded.default;\n\t\tif (!isDeployTarget(target)) {\n\t\t\tthrow new TargetPackageInvalid(name, implementation);\n\t\t}\n\t\tif (target.runtime !== declared) {\n\t\t\tthrow new TargetRuntimeMismatch(\n\t\t\t\tname,\n\t\t\t\timplementation,\n\t\t\t\tdeclared,\n\t\t\t\ttarget.runtime,\n\t\t\t);\n\t\t}\n\t\treturn { name, target, source: 'config', options };\n\t}\n\n\tif (!isDeployTarget(implementation)) throw new TargetEntryInvalid(name);\n\treturn { name, target: implementation, source: 'config', options };\n}\n\n/** The target's options, parsed by its schema. */\nexport async function parseTargetOptions(\n\tresolved: ResolvedTarget,\n): Promise<unknown> {\n\tconst { name, target, options } = resolved;\n\tif (!target.options) {\n\t\tif (options !== undefined) {\n\t\t\tthrow new InvalidTargetOptions(name, [\n\t\t\t\t{ message: 'this target takes no options' },\n\t\t\t]);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tconst result = await target.options['~standard'].validate(options);\n\tif (result.issues) throw new InvalidTargetOptions(name, result.issues);\n\treturn result.value;\n}\n"],"mappings":";;;;;;;;;;;;AAYA,MAAM,UAAkC;CACvC,QACC;CACD,cACC;AACF;;AAGA,IAAa,kBAAb,cAAqC,MAAM;CAEhC;CAEA;CAHV,YACC,UAEA,SACC;EACD,MAAM,cAAc,SAAS,qBAAqB,QAAQ,EAAE;EAJnD,KAAA,WAAA;EAEA,KAAA,UAAA;EAGT,KAAK,OAAO;CACb;AACD;;AAGA,SAAgB,oBAAoB,UAA0B;CAC7D,OAAO,0CAA0C,SAAS;AAC3D;;;;;AAMA,SAAgB,kBACf,UACA,MACS;CACT,MAAM,UAAU,QAAQ;CACxB,IAAI,SAAS,MAAM,IAAI,gBAAgB,UAAU,OAAO;CACxD,IAAI,aAAa,YAAY,aAAa,cACzC,MAAM,IAAIA,eAAAA,4BAA4B,QAAQ;CAE/C,KAAK,oBAAoB,QAAQ,CAAC;CAClC,OAAO;AACR;;;;;;;;;;;;;;;;;;;;;ACSA,IAAa,uBAAb,cAA0C,MAAM;CAErC;CACA;CAFV,YACC,QACA,aACC;EACD,MACC,kBAAkB,OAAO,UAAU,YAAY,0JAChD;EALS,KAAA,SAAA;EACA,KAAA,cAAA;EAKT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,qBAAb,cAAwC,MAAM;CACxB;CAArB,YAAY,QAAyB;EACpC,MACC,kBAAkB,OAAO,0FAC1B;EAHoB,KAAA,SAAA;EAIpB,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,wBAAb,cAA2C,MAAM;CAEtC;CACA;CACA;CACA;CAJV,YACC,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Target","UnknownDeployTarget","configurableBuiltins","declaredRuntime","importPackage","isDeployTarget"],"sources":["../src/target/provider.ts","../src/target/resolve.ts"],"sourcesContent":["/**\n * `gkm deploy --provider`, from before there were targets.\n *\n * It named three things, and only one of them ever deployed a workspace:\n * `dokploy` is now the target of that name; `docker` and `aws-lambda` were\n * accepted and always failed, so they are gone with a pointer to what does\n * the job.\n */\n\nimport { DeployTargetNotYetSupported } from './builtins';\n\n/** What each removed provider's job is done with now. */\nconst REMOVED: Record<string, string> = {\n\tdocker:\n\t\t'Build images with `gkm docker`, or run the stage as one Docker Compose stack with `gkm compose`',\n\t'aws-lambda':\n\t\t\"Deploy to AWS with SST: set deploy: { default: 'sst' } and run `gkm build && sst deploy --stage <stage>`\",\n};\n\n/** A `--provider` that no longer exists. */\nexport class ProviderRemoved extends Error {\n\tconstructor(\n\t\treadonly provider: string,\n\t\t/** What to use instead. */\n\t\treadonly instead: string,\n\t) {\n\t\tsuper(`--provider ${provider} has been removed. ${instead}.`);\n\t\tthis.name = 'ProviderRemoved';\n\t}\n}\n\n/** The deprecation `--provider` prints when it still means something. */\nexport function providerDeprecation(provider: string): string {\n\treturn `--provider is deprecated; use --target ${provider}.`;\n}\n\n/**\n * The target a `--provider` value means. `warn` hears the deprecation; a\n * provider that is gone, or a target not deployable yet, throws.\n */\nexport function targetForProvider(\n\tprovider: string,\n\twarn: (message: string) => void,\n): string {\n\tconst removed = REMOVED[provider];\n\tif (removed) throw new ProviderRemoved(provider, removed);\n\tif (provider === 'vercel' || provider === 'cloudflare') {\n\t\tthrow new DeployTargetNotYetSupported(provider);\n\t}\n\twarn(providerDeprecation(provider));\n\treturn provider;\n}\n","/**\n * From a target's name to the target.\n *\n * In this order, the first that has the name wins:\n *\n * 1. the host's own targets — what a program calling `deploy()` passes\n * 2. the built-ins — `dokploy`\n * 3. `deploy.targets` in gkm.config.ts — a package, an object, or either\n * with options\n *\n * Built-ins come before the config so that a dependency cannot take over\n * `dokploy` by being listed under its name. A name nothing has is\n * `UnknownDeployTarget`. There is deliberately no fourth step that guesses a\n * package from the name (`acme` → `@acme/gkm-target`): an npm scope nobody\n * has claimed can be claimed by anyone, and a deploy would then run their\n * code with the stage's credentials. A target is installed and named.\n */\n\nimport {\n\tbuiltinTarget,\n\tconfigurableBuiltins,\n\tconfiguredTarget,\n\tDeployTargetNotYetSupported,\n\tUnknownDeployTarget,\n} from './builtins';\nimport { isDeployTarget } from './define';\nimport { importPackage } from './package';\nimport { declaredRuntime } from './runtime';\nimport type {\n\tAnyDeployTarget,\n\tDeployRuntime,\n\tDeployTargetEntry,\n\tTargetOptionsIssue,\n} from './types';\n\n/** Where a target came from. */\nexport type TargetSourceKind = 'host' | 'builtin' | 'config';\n\nexport interface ResolvedTarget {\n\t/** The name it was asked for by. */\n\tname: string;\n\ttarget: AnyDeployTarget;\n\tsource: TargetSourceKind;\n\t/** Its options as written in the config, before its schema parsed them. */\n\toptions: unknown;\n}\n\nexport interface ResolveTargetOptions {\n\t/** The workspace whose `deploy.targets` is consulted. */\n\tworkspace: {\n\t\troot: string;\n\t\tdeploy?: { targets?: Record<string, DeployTargetEntry> } | undefined;\n\t};\n\t/** The host's targets, consulted first. */\n\thost?: Record<string, AnyDeployTarget>;\n\t/** The stage being deployed, for what to do instead of a refused target. */\n\tstage: string;\n}\n\n/** A target package whose default export is not a target. */\nexport class TargetPackageInvalid extends Error {\n\tconstructor(\n\t\treadonly target: string,\n\t\treadonly packageName: string,\n\t) {\n\t\tsuper(\n\t\t\t`deploy.targets.${target} names \"${packageName}\", whose default export is not a deploy target. A target package exports one as default: export default defineTarget({ … }) from '@geekmidas/cli/target'.`,\n\t\t);\n\t\tthis.name = 'TargetPackageInvalid';\n\t}\n}\n\n/** A `deploy.targets` entry that is not a target, a package name or a pair. */\nexport class TargetEntryInvalid extends Error {\n\tconstructor(readonly target: string) {\n\t\tsuper(\n\t\t\t`deploy.targets.${target} must be a package name, a target object (defineTarget), or [package or target, options].`,\n\t\t);\n\t\tthis.name = 'TargetEntryInvalid';\n\t}\n}\n\n/** A target whose `runtime` is not the one its package declares. */\nexport class TargetRuntimeMismatch extends Error {\n\tconstructor(\n\t\treadonly target: string,\n\t\treadonly packageName: string,\n\t\treadonly declared: DeployRuntime,\n\t\treadonly actual: DeployRuntime,\n\t) {\n\t\tsuper(\n\t\t\t`The deploy target \"${target}\" runs on \"${actual}\", but ${packageName}'s package.json declares gkm.runtime \"${declared}\". gkm dev and gkm build chose backends for \"${declared}\", so the two must agree — fix the package.`,\n\t\t);\n\t\tthis.name = 'TargetRuntimeMismatch';\n\t}\n}\n\n/** Options a target's schema rejected. */\nexport class InvalidTargetOptions extends Error {\n\tconstructor(\n\t\treadonly target: string,\n\t\treadonly issues: readonly TargetOptionsIssue[],\n\t) {\n\t\tconst lines = issues.map((issue) => {\n\t\t\tconst path = (issue.path ?? [])\n\t\t\t\t.map((segment) =>\n\t\t\t\t\ttypeof segment === 'object' ? String(segment.key) : String(segment),\n\t\t\t\t)\n\t\t\t\t.join('.');\n\t\t\treturn ` - ${path ? `${path}: ` : ''}${issue.message}`;\n\t\t});\n\t\tsuper(\n\t\t\t`The options for deploy target \"${target}\" are invalid — fix them in deploy.targets.${target} in gkm.config.ts:\\n${lines.join('\\n')}`,\n\t\t);\n\t\tthis.name = 'InvalidTargetOptions';\n\t}\n}\n\n/** The built-ins `gkm deploy` deploys through, loaded only when used. */\nconst BUILTIN_LOADERS: Record<string, () => Promise<AnyDeployTarget>> = {\n\tdokploy: async () => (await import('./dokploy')).dokployTarget,\n};\n\n/** The target `name` means, in this workspace, for this host. */\nexport async function resolveTarget(\n\tname: string,\n\t{ workspace, host, stage }: ResolveTargetOptions,\n): Promise<ResolvedTarget> {\n\tif (host && Object.hasOwn(host, name)) {\n\t\treturn { name, target: host[name]!, source: 'host', options: undefined };\n\t}\n\n\tconst builtin = builtinTarget(name);\n\tif (builtin) {\n\t\tconst load = BUILTIN_LOADERS[name];\n\t\tif (builtin.status !== 'available' || !load) {\n\t\t\tthrow new DeployTargetNotYetSupported(name, builtin.instead?.(stage));\n\t\t}\n\t\treturn {\n\t\t\tname,\n\t\t\ttarget: await load(),\n\t\t\tsource: 'builtin',\n\t\t\toptions: undefined,\n\t\t};\n\t}\n\n\tconst entry = configuredTarget(workspace.deploy, name);\n\tif (entry === undefined) {\n\t\tthrow new UnknownDeployTarget(name, [\n\t\t\t...configurableBuiltins(),\n\t\t\t...Object.keys(workspace.deploy?.targets ?? {}),\n\t\t]);\n\t}\n\n\tconst [implementation, options] = Array.isArray(entry)\n\t\t? (entry as readonly [unknown, unknown])\n\t\t: [entry, undefined];\n\n\tif (typeof implementation === 'string') {\n\t\t// Before the import: a package that does not say where it runs is\n\t\t// refused without running any of its code.\n\t\tconst declared = declaredRuntime(name, implementation, workspace.root);\n\t\tconst loaded = await importPackage(name, implementation, workspace.root);\n\t\tconst target = loaded.default;\n\t\tif (!isDeployTarget(target)) {\n\t\t\tthrow new TargetPackageInvalid(name, implementation);\n\t\t}\n\t\tif (target.runtime !== declared) {\n\t\t\tthrow new TargetRuntimeMismatch(\n\t\t\t\tname,\n\t\t\t\timplementation,\n\t\t\t\tdeclared,\n\t\t\t\ttarget.runtime,\n\t\t\t);\n\t\t}\n\t\treturn { name, target, source: 'config', options };\n\t}\n\n\tif (!isDeployTarget(implementation)) throw new TargetEntryInvalid(name);\n\treturn { name, target: implementation, source: 'config', options };\n}\n\n/** The target's options, parsed by its schema. */\nexport async function parseTargetOptions(\n\tresolved: ResolvedTarget,\n): Promise<unknown> {\n\tconst { name, target, options } = resolved;\n\tif (!target.options) {\n\t\tif (options !== undefined) {\n\t\t\tthrow new InvalidTargetOptions(name, [\n\t\t\t\t{ message: 'this target takes no options' },\n\t\t\t]);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tconst result = await target.options['~standard'].validate(options);\n\tif (result.issues) throw new InvalidTargetOptions(name, result.issues);\n\treturn result.value;\n}\n"],"mappings":";;;;;;;;;;;;AAYA,MAAM,UAAkC;CACvC,QACC;CACD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,gBAAgB,UAAU,IAAI;EAErE,MAAM,UAAS,MADMC,gBAAAA,cAAc,MAAM,gBAAgB,UAAU,IAAI,EAAA,CACjD;EACtB,IAAI,CAACC,eAAAA,eAAe,MAAM,GACzB,MAAM,IAAI,qBAAqB,MAAM,cAAc;EAEpD,IAAI,OAAO,YAAY,UACtB,MAAM,IAAI,sBACT,MACA,gBACA,UACA,OAAO,OACR;EAED,OAAO;GAAE;GAAM;GAAQ,QAAQ;GAAU;EAAQ;CAClD;CAEA,IAAI,CAACA,eAAAA,eAAe,cAAc,GAAG,MAAM,IAAI,mBAAmB,IAAI;CACtE,OAAO;EAAE;EAAM,QAAQ;EAAgB,QAAQ;EAAU;CAAQ;AAClE;;AAGA,eAAsB,mBACrB,UACmB;CACnB,MAAM,EAAE,MAAM,QAAQ,YAAY;CAClC,IAAI,CAAC,OAAO,SAAS;EACpB,IAAI,YAAY,KAAA,GACf,MAAM,IAAI,qBAAqB,MAAM,CACpC,EAAE,SAAS,+BAA+B,CAC3C,CAAC;EAEF;CACD;CAEA,MAAM,SAAS,MAAM,OAAO,QAAQ,YAAY,CAAC,SAAS,OAAO;CACjE,IAAI,OAAO,QAAQ,MAAM,IAAI,qBAAqB,MAAM,OAAO,MAAM;CACrE,OAAO,OAAO;AACf"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const require_workerRuntime = require("../workerRuntime-BXfhbe13.cjs");
|
|
2
|
+
let node_fs_promises = require("node:fs/promises");
|
|
3
|
+
let node_url = require("node:url");
|
|
4
|
+
//#region src/sandbox/config-worker.ts
|
|
5
|
+
/**
|
|
6
|
+
* Loads `gkm.config.ts` in a sandbox and answers with it as data.
|
|
7
|
+
*
|
|
8
|
+
* Usage (by `loadWorkspaceConfig` with a sandbox, never by hand):
|
|
9
|
+
* node --import=<tsx> config-worker.ts /path/to/gkm.config.ts
|
|
10
|
+
*
|
|
11
|
+
* Answers `{ reason: 'loaded', config }`, `{ reason: 'live', paths }` when the
|
|
12
|
+
* config holds something JSON cannot carry, or `{ reason: 'failed', error }`
|
|
13
|
+
* when it could not be loaded at all.
|
|
14
|
+
*/
|
|
15
|
+
async function load(configPath) {
|
|
16
|
+
if (configPath.endsWith(".json")) return JSON.parse(await (0, node_fs_promises.readFile)(configPath, "utf8"));
|
|
17
|
+
return (await import((0, node_url.pathToFileURL)(configPath).href)).default;
|
|
18
|
+
}
|
|
19
|
+
async function main() {
|
|
20
|
+
const configPath = process.argv[2];
|
|
21
|
+
try {
|
|
22
|
+
if (!configPath) throw new TypeError("No config path was given.");
|
|
23
|
+
await require_workerRuntime.registerAdjacentTsconfig();
|
|
24
|
+
const config = await load(configPath);
|
|
25
|
+
const paths = require_workerRuntime.liveValuePaths(config);
|
|
26
|
+
require_workerRuntime.answer(paths.length > 0 ? {
|
|
27
|
+
reason: "live",
|
|
28
|
+
paths
|
|
29
|
+
} : {
|
|
30
|
+
reason: "loaded",
|
|
31
|
+
config
|
|
32
|
+
});
|
|
33
|
+
} catch (error) {
|
|
34
|
+
require_workerRuntime.answer({
|
|
35
|
+
reason: "failed",
|
|
36
|
+
error: require_workerRuntime.errorData(error)
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
main();
|
|
41
|
+
//#endregion
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=config-worker.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-worker.cjs","names":["readFile","pathToFileURL","registerAdjacentTsconfig","liveValuePaths","errorData"],"sources":["../../src/sandbox/config-worker.ts"],"sourcesContent":["/**\n * Loads `gkm.config.ts` in a sandbox and answers with it as data.\n *\n * Usage (by `loadWorkspaceConfig` with a sandbox, never by hand):\n * node --import=<tsx> config-worker.ts /path/to/gkm.config.ts\n *\n * Answers `{ reason: 'loaded', config }`, `{ reason: 'live', paths }` when the\n * config holds something JSON cannot carry, or `{ reason: 'failed', error }`\n * when it could not be loaded at all.\n */\n\nimport { readFile } from 'node:fs/promises';\nimport { pathToFileURL } from 'node:url';\nimport {\n\tanswer,\n\terrorData,\n\tliveValuePaths,\n\tregisterAdjacentTsconfig,\n} from './workerRuntime';\n\nasync function load(configPath: string): Promise<unknown> {\n\tif (configPath.endsWith('.json')) {\n\t\treturn JSON.parse(await readFile(configPath, 'utf8'));\n\t}\n\tconst module = await import(pathToFileURL(configPath).href);\n\treturn module.default;\n}\n\nasync function main(): Promise<void> {\n\tconst configPath = process.argv[2];\n\ttry {\n\t\tif (!configPath) throw new TypeError('No config path was given.');\n\t\tawait registerAdjacentTsconfig();\n\t\tconst config = await load(configPath);\n\t\tconst paths = liveValuePaths(config);\n\t\tanswer(\n\t\t\tpaths.length > 0\n\t\t\t\t? { reason: 'live', paths }\n\t\t\t\t: { reason: 'loaded', config },\n\t\t);\n\t} catch (error) {\n\t\tanswer({ reason: 'failed', error: errorData(error) });\n\t}\n}\n\nvoid main();\n"],"mappings":";;;;;;;;;;;;;;AAoBA,eAAe,KAAK,YAAsC;CACzD,IAAI,WAAW,SAAS,OAAO,GAC9B,OAAO,KAAK,MAAM,OAAA,GAAMA,iBAAAA,SAAAA,CAAS,YAAY,MAAM,CAAC;CAGrD,QAAO,MADc,QAAA,GAAOC,SAAAA,cAAAA,CAAc,UAAU,CAAC,CAAC,MAAA,CACxC;AACf;AAEA,eAAe,OAAsB;CACpC,MAAM,aAAa,QAAQ,KAAK;CAChC,IAAI;EACH,IAAI,CAAC,YAAY,MAAM,IAAI,UAAU,2BAA2B;EAChE,MAAMC,sBAAAA,yBAAyB;EAC/B,MAAM,SAAS,MAAM,KAAK,UAAU;EACpC,MAAM,QAAQC,sBAAAA,eAAe,MAAM;EACnC,sBAAA,OACC,MAAM,SAAS,IACZ;GAAE,QAAQ;GAAQ;EAAM,IACxB;GAAE,QAAQ;GAAU;EAAO,CAC/B;CACD,SAAS,OAAO;EACf,sBAAA,OAAO;GAAE,QAAQ;GAAU,OAAOC,sBAAAA,UAAU,KAAK;EAAE,CAAC;CACrD;AACD;AAEK,KAAK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { a as registerAdjacentTsconfig, i as liveValuePaths, n as answer, r as errorData } from "../workerRuntime-CsOyBRx2.mjs";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
//#region src/sandbox/config-worker.ts
|
|
5
|
+
/**
|
|
6
|
+
* Loads `gkm.config.ts` in a sandbox and answers with it as data.
|
|
7
|
+
*
|
|
8
|
+
* Usage (by `loadWorkspaceConfig` with a sandbox, never by hand):
|
|
9
|
+
* node --import=<tsx> config-worker.ts /path/to/gkm.config.ts
|
|
10
|
+
*
|
|
11
|
+
* Answers `{ reason: 'loaded', config }`, `{ reason: 'live', paths }` when the
|
|
12
|
+
* config holds something JSON cannot carry, or `{ reason: 'failed', error }`
|
|
13
|
+
* when it could not be loaded at all.
|
|
14
|
+
*/
|
|
15
|
+
async function load(configPath) {
|
|
16
|
+
if (configPath.endsWith(".json")) return JSON.parse(await readFile(configPath, "utf8"));
|
|
17
|
+
return (await import(pathToFileURL(configPath).href)).default;
|
|
18
|
+
}
|
|
19
|
+
async function main() {
|
|
20
|
+
const configPath = process.argv[2];
|
|
21
|
+
try {
|
|
22
|
+
if (!configPath) throw new TypeError("No config path was given.");
|
|
23
|
+
await registerAdjacentTsconfig();
|
|
24
|
+
const config = await load(configPath);
|
|
25
|
+
const paths = liveValuePaths(config);
|
|
26
|
+
answer(paths.length > 0 ? {
|
|
27
|
+
reason: "live",
|
|
28
|
+
paths
|
|
29
|
+
} : {
|
|
30
|
+
reason: "loaded",
|
|
31
|
+
config
|
|
32
|
+
});
|
|
33
|
+
} catch (error) {
|
|
34
|
+
answer({
|
|
35
|
+
reason: "failed",
|
|
36
|
+
error: errorData(error)
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
main();
|
|
41
|
+
//#endregion
|
|
42
|
+
export {};
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=config-worker.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-worker.mjs","names":[],"sources":["../../src/sandbox/config-worker.ts"],"sourcesContent":["/**\n * Loads `gkm.config.ts` in a sandbox and answers with it as data.\n *\n * Usage (by `loadWorkspaceConfig` with a sandbox, never by hand):\n * node --import=<tsx> config-worker.ts /path/to/gkm.config.ts\n *\n * Answers `{ reason: 'loaded', config }`, `{ reason: 'live', paths }` when the\n * config holds something JSON cannot carry, or `{ reason: 'failed', error }`\n * when it could not be loaded at all.\n */\n\nimport { readFile } from 'node:fs/promises';\nimport { pathToFileURL } from 'node:url';\nimport {\n\tanswer,\n\terrorData,\n\tliveValuePaths,\n\tregisterAdjacentTsconfig,\n} from './workerRuntime';\n\nasync function load(configPath: string): Promise<unknown> {\n\tif (configPath.endsWith('.json')) {\n\t\treturn JSON.parse(await readFile(configPath, 'utf8'));\n\t}\n\tconst module = await import(pathToFileURL(configPath).href);\n\treturn module.default;\n}\n\nasync function main(): Promise<void> {\n\tconst configPath = process.argv[2];\n\ttry {\n\t\tif (!configPath) throw new TypeError('No config path was given.');\n\t\tawait registerAdjacentTsconfig();\n\t\tconst config = await load(configPath);\n\t\tconst paths = liveValuePaths(config);\n\t\tanswer(\n\t\t\tpaths.length > 0\n\t\t\t\t? { reason: 'live', paths }\n\t\t\t\t: { reason: 'loaded', config },\n\t\t);\n\t} catch (error) {\n\t\tanswer({ reason: 'failed', error: errorData(error) });\n\t}\n}\n\nvoid main();\n"],"mappings":";;;;;;;;;;;;;;AAoBA,eAAe,KAAK,YAAsC;CACzD,IAAI,WAAW,SAAS,OAAO,GAC9B,OAAO,KAAK,MAAM,MAAM,SAAS,YAAY,MAAM,CAAC;CAGrD,QAAO,MADc,OAAO,cAAc,UAAU,CAAC,CAAC,MAAA,CACxC;AACf;AAEA,eAAe,OAAsB;CACpC,MAAM,aAAa,QAAQ,KAAK;CAChC,IAAI;EACH,IAAI,CAAC,YAAY,MAAM,IAAI,UAAU,2BAA2B;EAChE,MAAM,yBAAyB;EAC/B,MAAM,SAAS,MAAM,KAAK,UAAU;EACpC,MAAM,QAAQ,eAAe,MAAM;EACnC,OACC,MAAM,SAAS,IACZ;GAAE,QAAQ;GAAQ;EAAM,IACxB;GAAE,QAAQ;GAAU;EAAO,CAC/B;CACD,SAAS,OAAO;EACf,OAAO;GAAE,QAAQ;GAAU,OAAO,UAAU,KAAK;EAAE,CAAC;CACrD;AACD;AAEK,KAAK"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const require_discover = require("../discover-C_6COHEv.cjs");
|
|
2
|
+
const require_workerRuntime = require("../workerRuntime-BXfhbe13.cjs");
|
|
3
|
+
//#region src/sandbox/discover-worker.ts
|
|
4
|
+
/**
|
|
5
|
+
* Discovers a project's constructs in a sandbox and answers with the
|
|
6
|
+
* manifest as data.
|
|
7
|
+
*
|
|
8
|
+
* Usage (by `discover` under a sandbox, never by hand):
|
|
9
|
+
* node --import=<tsx> discover-worker.ts '{"patterns":[…],"cwd":"…"}'
|
|
10
|
+
*
|
|
11
|
+
* Discovery imports every construct module — the project's code — which is
|
|
12
|
+
* why it runs here rather than in the deploy. Its warnings go to stderr, where
|
|
13
|
+
* the host passes them on.
|
|
14
|
+
*/
|
|
15
|
+
async function main() {
|
|
16
|
+
try {
|
|
17
|
+
const request = JSON.parse(process.argv[2] ?? "{}");
|
|
18
|
+
await require_workerRuntime.registerAdjacentTsconfig();
|
|
19
|
+
const runnables = {};
|
|
20
|
+
const manifest = await require_discover.discover({
|
|
21
|
+
patterns: request.patterns,
|
|
22
|
+
cwd: request.cwd,
|
|
23
|
+
runnables
|
|
24
|
+
});
|
|
25
|
+
const paths = require_workerRuntime.liveValuePaths(manifest);
|
|
26
|
+
require_workerRuntime.answer(paths.length > 0 ? {
|
|
27
|
+
reason: "live",
|
|
28
|
+
paths
|
|
29
|
+
} : {
|
|
30
|
+
reason: "discovered",
|
|
31
|
+
manifest,
|
|
32
|
+
runnables
|
|
33
|
+
});
|
|
34
|
+
} catch (error) {
|
|
35
|
+
require_workerRuntime.answer({
|
|
36
|
+
reason: "failed",
|
|
37
|
+
error: require_workerRuntime.errorData(error)
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
main();
|
|
42
|
+
//#endregion
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=discover-worker.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover-worker.cjs","names":["registerAdjacentTsconfig","discover","liveValuePaths","errorData"],"sources":["../../src/sandbox/discover-worker.ts"],"sourcesContent":["/**\n * Discovers a project's constructs in a sandbox and answers with the\n * manifest as data.\n *\n * Usage (by `discover` under a sandbox, never by hand):\n * node --import=<tsx> discover-worker.ts '{\"patterns\":[…],\"cwd\":\"…\"}'\n *\n * Discovery imports every construct module — the project's code — which is\n * why it runs here rather than in the deploy. Its warnings go to stderr, where\n * the host passes them on.\n */\n\nimport { discover } from '../reconcile/discover';\nimport {\n\tanswer,\n\terrorData,\n\tliveValuePaths,\n\tregisterAdjacentTsconfig,\n} from './workerRuntime';\n\nasync function main(): Promise<void> {\n\ttry {\n\t\tconst request = JSON.parse(process.argv[2] ?? '{}') as {\n\t\t\tpatterns: string[];\n\t\t\tcwd: string;\n\t\t};\n\t\tawait registerAdjacentTsconfig();\n\n\t\tconst runnables: Record<string, string[]> = {};\n\t\tconst manifest = await discover({\n\t\t\tpatterns: request.patterns,\n\t\t\tcwd: request.cwd,\n\t\t\trunnables,\n\t\t});\n\n\t\tconst paths = liveValuePaths(manifest);\n\t\tanswer(\n\t\t\tpaths.length > 0\n\t\t\t\t? { reason: 'live', paths }\n\t\t\t\t: { reason: 'discovered', manifest, runnables },\n\t\t);\n\t} catch (error) {\n\t\tanswer({ reason: 'failed', error: errorData(error) });\n\t}\n}\n\nvoid main();\n"],"mappings":";;;;;;;;;;;;;;AAoBA,eAAe,OAAsB;CACpC,IAAI;EACH,MAAM,UAAU,KAAK,MAAM,QAAQ,KAAK,MAAM,IAAI;EAIlD,MAAMA,sBAAAA,yBAAyB;EAE/B,MAAM,YAAsC,CAAC;EAC7C,MAAM,WAAW,MAAMC,iBAAAA,SAAS;GAC/B,UAAU,QAAQ;GAClB,KAAK,QAAQ;GACb;EACD,CAAC;EAED,MAAM,QAAQC,sBAAAA,eAAe,QAAQ;EACrC,sBAAA,OACC,MAAM,SAAS,IACZ;GAAE,QAAQ;GAAQ;EAAM,IACxB;GAAE,QAAQ;GAAc;GAAU;EAAU,CAChD;CACD,SAAS,OAAO;EACf,sBAAA,OAAO;GAAE,QAAQ;GAAU,OAAOC,sBAAAA,UAAU,KAAK;EAAE,CAAC;CACrD;AACD;AAEK,KAAK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { r as discover } from "../discover-BaT6bpnA.mjs";
|
|
2
|
+
import { a as registerAdjacentTsconfig, i as liveValuePaths, n as answer, r as errorData } from "../workerRuntime-CsOyBRx2.mjs";
|
|
3
|
+
//#region src/sandbox/discover-worker.ts
|
|
4
|
+
/**
|
|
5
|
+
* Discovers a project's constructs in a sandbox and answers with the
|
|
6
|
+
* manifest as data.
|
|
7
|
+
*
|
|
8
|
+
* Usage (by `discover` under a sandbox, never by hand):
|
|
9
|
+
* node --import=<tsx> discover-worker.ts '{"patterns":[…],"cwd":"…"}'
|
|
10
|
+
*
|
|
11
|
+
* Discovery imports every construct module — the project's code — which is
|
|
12
|
+
* why it runs here rather than in the deploy. Its warnings go to stderr, where
|
|
13
|
+
* the host passes them on.
|
|
14
|
+
*/
|
|
15
|
+
async function main() {
|
|
16
|
+
try {
|
|
17
|
+
const request = JSON.parse(process.argv[2] ?? "{}");
|
|
18
|
+
await registerAdjacentTsconfig();
|
|
19
|
+
const runnables = {};
|
|
20
|
+
const manifest = await discover({
|
|
21
|
+
patterns: request.patterns,
|
|
22
|
+
cwd: request.cwd,
|
|
23
|
+
runnables
|
|
24
|
+
});
|
|
25
|
+
const paths = liveValuePaths(manifest);
|
|
26
|
+
answer(paths.length > 0 ? {
|
|
27
|
+
reason: "live",
|
|
28
|
+
paths
|
|
29
|
+
} : {
|
|
30
|
+
reason: "discovered",
|
|
31
|
+
manifest,
|
|
32
|
+
runnables
|
|
33
|
+
});
|
|
34
|
+
} catch (error) {
|
|
35
|
+
answer({
|
|
36
|
+
reason: "failed",
|
|
37
|
+
error: errorData(error)
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
main();
|
|
42
|
+
//#endregion
|
|
43
|
+
export {};
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=discover-worker.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover-worker.mjs","names":[],"sources":["../../src/sandbox/discover-worker.ts"],"sourcesContent":["/**\n * Discovers a project's constructs in a sandbox and answers with the\n * manifest as data.\n *\n * Usage (by `discover` under a sandbox, never by hand):\n * node --import=<tsx> discover-worker.ts '{\"patterns\":[…],\"cwd\":\"…\"}'\n *\n * Discovery imports every construct module — the project's code — which is\n * why it runs here rather than in the deploy. Its warnings go to stderr, where\n * the host passes them on.\n */\n\nimport { discover } from '../reconcile/discover';\nimport {\n\tanswer,\n\terrorData,\n\tliveValuePaths,\n\tregisterAdjacentTsconfig,\n} from './workerRuntime';\n\nasync function main(): Promise<void> {\n\ttry {\n\t\tconst request = JSON.parse(process.argv[2] ?? '{}') as {\n\t\t\tpatterns: string[];\n\t\t\tcwd: string;\n\t\t};\n\t\tawait registerAdjacentTsconfig();\n\n\t\tconst runnables: Record<string, string[]> = {};\n\t\tconst manifest = await discover({\n\t\t\tpatterns: request.patterns,\n\t\t\tcwd: request.cwd,\n\t\t\trunnables,\n\t\t});\n\n\t\tconst paths = liveValuePaths(manifest);\n\t\tanswer(\n\t\t\tpaths.length > 0\n\t\t\t\t? { reason: 'live', paths }\n\t\t\t\t: { reason: 'discovered', manifest, runnables },\n\t\t);\n\t} catch (error) {\n\t\tanswer({ reason: 'failed', error: errorData(error) });\n\t}\n}\n\nvoid main();\n"],"mappings":";;;;;;;;;;;;;;AAoBA,eAAe,OAAsB;CACpC,IAAI;EACH,MAAM,UAAU,KAAK,MAAM,QAAQ,KAAK,MAAM,IAAI;EAIlD,MAAM,yBAAyB;EAE/B,MAAM,YAAsC,CAAC;EAC7C,MAAM,WAAW,MAAM,SAAS;GAC/B,UAAU,QAAQ;GAClB,KAAK,QAAQ;GACb;EACD,CAAC;EAED,MAAM,QAAQ,eAAe,QAAQ;EACrC,OACC,MAAM,SAAS,IACZ;GAAE,QAAQ;GAAQ;EAAM,IACxB;GAAE,QAAQ;GAAc;GAAU;EAAU,CAChD;CACD,SAAS,OAAO;EACf,OAAO;GAAE,QAAQ;GAAU,OAAO,UAAU,KAAK;EAAE,CAAC;CACrD;AACD;AAEK,KAAK"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
//#region src/sandbox/sandbox.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Where a deploy runs the project's own code.
|
|
4
|
+
*
|
|
5
|
+
* A deploy holds credentials — Dokploy's token, a registry login, an AWS key —
|
|
6
|
+
* and loading `gkm.config.ts`, sniffing an app's environment and building it
|
|
7
|
+
* all execute code from the repository being deployed. On a developer's own
|
|
8
|
+
* laptop that is the developer's code. On a CI job for a fork, or a shared
|
|
9
|
+
* build runner, it is not, and that code should not be able to read the
|
|
10
|
+
* credentials used to deploy it, hang the deploy, or reach outside the
|
|
11
|
+
* checkout.
|
|
12
|
+
*
|
|
13
|
+
* So every step that runs project code goes through a `Sandbox`: one call,
|
|
14
|
+
* with an argument array rather than a shell line, the complete environment
|
|
15
|
+
* the step needs rather than the host's, a timeout it cannot outlive, secrets
|
|
16
|
+
* as files rather than variables, and a working directory inside the project.
|
|
17
|
+
* The steps that need credentials — provisioning, pushing, releasing — are
|
|
18
|
+
* the deploy's own code and never run in one.
|
|
19
|
+
*
|
|
20
|
+
* `LocalSandbox` is the default: a child process on this machine with an
|
|
21
|
+
* allowlisted environment. A host that builds repositories it does not trust
|
|
22
|
+
* passes its own — a container per build, a VM — through `deploy()`'s
|
|
23
|
+
* `sandbox`.
|
|
24
|
+
*/
|
|
25
|
+
/** Where a command's output goes. */
|
|
26
|
+
type SandboxOutput = 'capture' | 'inherit' | 'stderr' | 'ignore';
|
|
27
|
+
interface SandboxExecOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Where the command runs: the project root or a directory below it, as an
|
|
30
|
+
* absolute path or relative to the root. Anywhere else is refused with
|
|
31
|
+
* {@link SandboxCwdEscape}.
|
|
32
|
+
*/
|
|
33
|
+
cwd: string;
|
|
34
|
+
/**
|
|
35
|
+
* The command's whole environment. Nothing of the host's is added to it:
|
|
36
|
+
* start from {@link Sandbox.env} and add what the step needs.
|
|
37
|
+
*/
|
|
38
|
+
env: Readonly<Record<string, string>>;
|
|
39
|
+
/**
|
|
40
|
+
* How long the command may run before it is killed. Required: a step that
|
|
41
|
+
* waits forever — a sniffed entry that opens a server, a build stuck on a
|
|
42
|
+
* prompt — would otherwise hold the deploy, and its lock, forever.
|
|
43
|
+
*/
|
|
44
|
+
timeoutMs: number;
|
|
45
|
+
/**
|
|
46
|
+
* Files the command can read, by name. Mounted in a directory of their own
|
|
47
|
+
* — named by `GKM_SECRETS_DIR` in the command's environment — and removed
|
|
48
|
+
* when it exits. Never set as variables, which every child inherits, a
|
|
49
|
+
* crash report prints and `/proc/<pid>/environ` shows.
|
|
50
|
+
*/
|
|
51
|
+
secrets?: Readonly<Record<string, string>>;
|
|
52
|
+
/**
|
|
53
|
+
* `capture` (the default) returns stdout and stderr in the result;
|
|
54
|
+
* `inherit` gives the command the host's terminal; `stderr` sends both
|
|
55
|
+
* streams to the host's stderr; `ignore` discards them.
|
|
56
|
+
*/
|
|
57
|
+
output?: SandboxOutput;
|
|
58
|
+
/** Kills the command when aborted; `exec` rejects with the signal's reason. */
|
|
59
|
+
signal?: AbortSignal;
|
|
60
|
+
}
|
|
61
|
+
/** How a command ended. A non-zero exit is a result, not an error. */
|
|
62
|
+
interface SandboxResult {
|
|
63
|
+
exitCode: number | null;
|
|
64
|
+
signal: string | null;
|
|
65
|
+
/** What it wrote to stdout, when its output was captured. */
|
|
66
|
+
stdout: string;
|
|
67
|
+
/** What it wrote to stderr, when its output was captured. */
|
|
68
|
+
stderr: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Runs a command against the project, and nothing else of the host's.
|
|
72
|
+
*
|
|
73
|
+
* `exec` resolves with the result however the command exited. It rejects
|
|
74
|
+
* with {@link CommandTimedOut} once the timeout passes — after the command is
|
|
75
|
+
* gone — with {@link SandboxCwdEscape} for a directory outside the project,
|
|
76
|
+
* with the signal's reason when aborted, and with the spawn error when the
|
|
77
|
+
* program cannot be started.
|
|
78
|
+
*/
|
|
79
|
+
interface Sandbox {
|
|
80
|
+
/** The project: the directory every command runs at or below. */
|
|
81
|
+
readonly root: string;
|
|
82
|
+
/**
|
|
83
|
+
* Whether the code it runs is kept from the host: its files, its
|
|
84
|
+
* processes, its memory.
|
|
85
|
+
*
|
|
86
|
+
* An isolating sandbox shares nothing but what crosses `exec`, so a config
|
|
87
|
+
* reaches the deploy as data — a live object in it (a custom state store,
|
|
88
|
+
* an inline target) cannot cross, and is refused with
|
|
89
|
+
* `ConfigObjectNotSerializable`. A non-isolating one, like
|
|
90
|
+
* {@link LocalSandbox}, runs on the host as the host's user; a project
|
|
91
|
+
* whose config holds live objects is then loaded in-process as before,
|
|
92
|
+
* because a project trusted to run there is trusted to do that.
|
|
93
|
+
*/
|
|
94
|
+
readonly isolating: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* The environment a command starts from: what any program needs to run
|
|
97
|
+
* here — `PATH`, `HOME`, the locale — and no credential.
|
|
98
|
+
*/
|
|
99
|
+
readonly env: Readonly<Record<string, string>>;
|
|
100
|
+
exec(command: string, args: readonly string[], options: SandboxExecOptions): Promise<SandboxResult>;
|
|
101
|
+
}
|
|
102
|
+
/** The variable naming the directory a command's secrets are mounted in. */
|
|
103
|
+
declare const SECRETS_DIR_ENV = "GKM_SECRETS_DIR";
|
|
104
|
+
/** A command was asked to run outside the project. */
|
|
105
|
+
declare class SandboxCwdEscape extends Error {
|
|
106
|
+
readonly cwd: string;
|
|
107
|
+
readonly root: string;
|
|
108
|
+
constructor(cwd: string, root: string);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* `cwd` as an absolute directory inside `root`, or {@link SandboxCwdEscape}.
|
|
112
|
+
*
|
|
113
|
+
* Symlinks are resolved on both sides first, so a link inside the project
|
|
114
|
+
* that points out of it is an escape, and a project reached through a link
|
|
115
|
+
* (`/tmp` on macOS) is still itself. For a sandbox of a host's own to call
|
|
116
|
+
* before it runs anything.
|
|
117
|
+
*/
|
|
118
|
+
declare function confineCwd(root: string, cwd: string): string;
|
|
119
|
+
/** A secret's file name: one path segment, so it cannot be written elsewhere. */
|
|
120
|
+
declare class SecretNameInvalid extends Error {
|
|
121
|
+
readonly secretName: string;
|
|
122
|
+
constructor(secretName: string);
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { SandboxOutput as a, confineCwd as c, SandboxExecOptions as i, Sandbox as n, SandboxResult as o, SandboxCwdEscape as r, SecretNameInvalid as s, SECRETS_DIR_ENV as t };
|
|
126
|
+
//# sourceMappingURL=sandbox-M8UnLhXE.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-M8UnLhXE.d.cts","names":[],"sources":["../src/sandbox/sandbox.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;KA6BY;UAEK;;;;;;EAMhB;;;;;EAKA,KAAK,SAAS;;;;;;EAMd;;;;;;;EAOA,UAAU,SAAS;;;;;;EAMnB,SAAS;;EAET,SAAS;;;UAIO;EAChB;EACA;;EAEA;;EAEA;;;;;;;;;;;UAYgB;;WAEP;;;;;;;;;;;;;WAaA;;;;;WAKA,KAAK,SAAS;EACvB,KACC,iBACA,yBACA,SAAS,qBACP,QAAQ;;;cAIC;;cAGA,yBAAyB;WAE3B;WACA;EAFV,YACU,aACA;;;;;;;;;;iBAwBK,WAAW,cAAc;;cAU5B,0BAA0B;WACjB;EAArB,YAAqB"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
//#region src/sandbox/sandbox.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Where a deploy runs the project's own code.
|
|
4
|
+
*
|
|
5
|
+
* A deploy holds credentials — Dokploy's token, a registry login, an AWS key —
|
|
6
|
+
* and loading `gkm.config.ts`, sniffing an app's environment and building it
|
|
7
|
+
* all execute code from the repository being deployed. On a developer's own
|
|
8
|
+
* laptop that is the developer's code. On a CI job for a fork, or a shared
|
|
9
|
+
* build runner, it is not, and that code should not be able to read the
|
|
10
|
+
* credentials used to deploy it, hang the deploy, or reach outside the
|
|
11
|
+
* checkout.
|
|
12
|
+
*
|
|
13
|
+
* So every step that runs project code goes through a `Sandbox`: one call,
|
|
14
|
+
* with an argument array rather than a shell line, the complete environment
|
|
15
|
+
* the step needs rather than the host's, a timeout it cannot outlive, secrets
|
|
16
|
+
* as files rather than variables, and a working directory inside the project.
|
|
17
|
+
* The steps that need credentials — provisioning, pushing, releasing — are
|
|
18
|
+
* the deploy's own code and never run in one.
|
|
19
|
+
*
|
|
20
|
+
* `LocalSandbox` is the default: a child process on this machine with an
|
|
21
|
+
* allowlisted environment. A host that builds repositories it does not trust
|
|
22
|
+
* passes its own — a container per build, a VM — through `deploy()`'s
|
|
23
|
+
* `sandbox`.
|
|
24
|
+
*/
|
|
25
|
+
/** Where a command's output goes. */
|
|
26
|
+
type SandboxOutput = 'capture' | 'inherit' | 'stderr' | 'ignore';
|
|
27
|
+
interface SandboxExecOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Where the command runs: the project root or a directory below it, as an
|
|
30
|
+
* absolute path or relative to the root. Anywhere else is refused with
|
|
31
|
+
* {@link SandboxCwdEscape}.
|
|
32
|
+
*/
|
|
33
|
+
cwd: string;
|
|
34
|
+
/**
|
|
35
|
+
* The command's whole environment. Nothing of the host's is added to it:
|
|
36
|
+
* start from {@link Sandbox.env} and add what the step needs.
|
|
37
|
+
*/
|
|
38
|
+
env: Readonly<Record<string, string>>;
|
|
39
|
+
/**
|
|
40
|
+
* How long the command may run before it is killed. Required: a step that
|
|
41
|
+
* waits forever — a sniffed entry that opens a server, a build stuck on a
|
|
42
|
+
* prompt — would otherwise hold the deploy, and its lock, forever.
|
|
43
|
+
*/
|
|
44
|
+
timeoutMs: number;
|
|
45
|
+
/**
|
|
46
|
+
* Files the command can read, by name. Mounted in a directory of their own
|
|
47
|
+
* — named by `GKM_SECRETS_DIR` in the command's environment — and removed
|
|
48
|
+
* when it exits. Never set as variables, which every child inherits, a
|
|
49
|
+
* crash report prints and `/proc/<pid>/environ` shows.
|
|
50
|
+
*/
|
|
51
|
+
secrets?: Readonly<Record<string, string>>;
|
|
52
|
+
/**
|
|
53
|
+
* `capture` (the default) returns stdout and stderr in the result;
|
|
54
|
+
* `inherit` gives the command the host's terminal; `stderr` sends both
|
|
55
|
+
* streams to the host's stderr; `ignore` discards them.
|
|
56
|
+
*/
|
|
57
|
+
output?: SandboxOutput;
|
|
58
|
+
/** Kills the command when aborted; `exec` rejects with the signal's reason. */
|
|
59
|
+
signal?: AbortSignal;
|
|
60
|
+
}
|
|
61
|
+
/** How a command ended. A non-zero exit is a result, not an error. */
|
|
62
|
+
interface SandboxResult {
|
|
63
|
+
exitCode: number | null;
|
|
64
|
+
signal: string | null;
|
|
65
|
+
/** What it wrote to stdout, when its output was captured. */
|
|
66
|
+
stdout: string;
|
|
67
|
+
/** What it wrote to stderr, when its output was captured. */
|
|
68
|
+
stderr: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Runs a command against the project, and nothing else of the host's.
|
|
72
|
+
*
|
|
73
|
+
* `exec` resolves with the result however the command exited. It rejects
|
|
74
|
+
* with {@link CommandTimedOut} once the timeout passes — after the command is
|
|
75
|
+
* gone — with {@link SandboxCwdEscape} for a directory outside the project,
|
|
76
|
+
* with the signal's reason when aborted, and with the spawn error when the
|
|
77
|
+
* program cannot be started.
|
|
78
|
+
*/
|
|
79
|
+
interface Sandbox {
|
|
80
|
+
/** The project: the directory every command runs at or below. */
|
|
81
|
+
readonly root: string;
|
|
82
|
+
/**
|
|
83
|
+
* Whether the code it runs is kept from the host: its files, its
|
|
84
|
+
* processes, its memory.
|
|
85
|
+
*
|
|
86
|
+
* An isolating sandbox shares nothing but what crosses `exec`, so a config
|
|
87
|
+
* reaches the deploy as data — a live object in it (a custom state store,
|
|
88
|
+
* an inline target) cannot cross, and is refused with
|
|
89
|
+
* `ConfigObjectNotSerializable`. A non-isolating one, like
|
|
90
|
+
* {@link LocalSandbox}, runs on the host as the host's user; a project
|
|
91
|
+
* whose config holds live objects is then loaded in-process as before,
|
|
92
|
+
* because a project trusted to run there is trusted to do that.
|
|
93
|
+
*/
|
|
94
|
+
readonly isolating: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* The environment a command starts from: what any program needs to run
|
|
97
|
+
* here — `PATH`, `HOME`, the locale — and no credential.
|
|
98
|
+
*/
|
|
99
|
+
readonly env: Readonly<Record<string, string>>;
|
|
100
|
+
exec(command: string, args: readonly string[], options: SandboxExecOptions): Promise<SandboxResult>;
|
|
101
|
+
}
|
|
102
|
+
/** The variable naming the directory a command's secrets are mounted in. */
|
|
103
|
+
declare const SECRETS_DIR_ENV = "GKM_SECRETS_DIR";
|
|
104
|
+
/** A command was asked to run outside the project. */
|
|
105
|
+
declare class SandboxCwdEscape extends Error {
|
|
106
|
+
readonly cwd: string;
|
|
107
|
+
readonly root: string;
|
|
108
|
+
constructor(cwd: string, root: string);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* `cwd` as an absolute directory inside `root`, or {@link SandboxCwdEscape}.
|
|
112
|
+
*
|
|
113
|
+
* Symlinks are resolved on both sides first, so a link inside the project
|
|
114
|
+
* that points out of it is an escape, and a project reached through a link
|
|
115
|
+
* (`/tmp` on macOS) is still itself. For a sandbox of a host's own to call
|
|
116
|
+
* before it runs anything.
|
|
117
|
+
*/
|
|
118
|
+
declare function confineCwd(root: string, cwd: string): string;
|
|
119
|
+
/** A secret's file name: one path segment, so it cannot be written elsewhere. */
|
|
120
|
+
declare class SecretNameInvalid extends Error {
|
|
121
|
+
readonly secretName: string;
|
|
122
|
+
constructor(secretName: string);
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { SandboxOutput as a, confineCwd as c, SandboxExecOptions as i, Sandbox as n, SandboxResult as o, SandboxCwdEscape as r, SecretNameInvalid as s, SECRETS_DIR_ENV as t };
|
|
126
|
+
//# sourceMappingURL=sandbox-M8UnLhXE.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-M8UnLhXE.d.mts","names":[],"sources":["../src/sandbox/sandbox.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;KA6BY;UAEK;;;;;;EAMhB;;;;;EAKA,KAAK,SAAS;;;;;;EAMd;;;;;;;EAOA,UAAU,SAAS;;;;;;EAMnB,SAAS;;EAET,SAAS;;;UAIO;EAChB;EACA;;EAEA;;EAEA;;;;;;;;;;;UAYgB;;WAEP;;;;;;;;;;;;;WAaA;;;;;WAKA,KAAK,SAAS;EACvB,KACC,iBACA,yBACA,SAAS,qBACP,QAAQ;;;cAIC;;cAGA,yBAAyB;WAE3B;WACA;EAFV,YACU,aACA;;;;;;;;;;iBAwBK,WAAW,cAAc;;cAU5B,0BAA0B;WACjB;EAArB,YAAqB"}
|