@geekmidas/cli 10.0.0-alpha.95 → 10.0.0-alpha.96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{GoDaddyProvider-BwW51hPm.mjs → GoDaddyProvider-BsUKjGcg.mjs} +2 -2
- package/dist/{GoDaddyProvider-BwW51hPm.mjs.map → GoDaddyProvider-BsUKjGcg.mjs.map} +1 -1
- package/dist/{GoDaddyProvider-C_DgIkMv.cjs → GoDaddyProvider-DyHXHDHe.cjs} +2 -2
- package/dist/{GoDaddyProvider-C_DgIkMv.cjs.map → GoDaddyProvider-DyHXHDHe.cjs.map} +1 -1
- package/dist/{LegacyStateStore-D5DarNA2.mjs → LegacyStateStore-B6SOqRFi.mjs} +3 -3
- package/dist/{LegacyStateStore-D5DarNA2.mjs.map → LegacyStateStore-B6SOqRFi.mjs.map} +1 -1
- package/dist/{LegacyStateStore-BawjE_5n.cjs → LegacyStateStore-BnMcONE0.cjs} +3 -3
- package/dist/{LegacyStateStore-BawjE_5n.cjs.map → LegacyStateStore-BnMcONE0.cjs.map} +1 -1
- package/dist/{LocalStateStore-YjIqlgAz.mjs → LocalStateStore-6CrsZzqI.mjs} +2 -2
- package/dist/{LocalStateStore-YjIqlgAz.mjs.map → LocalStateStore-6CrsZzqI.mjs.map} +1 -1
- package/dist/{LocalStateStore-D8fu5WiF.cjs → LocalStateStore-pd4bbdJJ.cjs} +2 -2
- package/dist/{LocalStateStore-D8fu5WiF.cjs.map → LocalStateStore-pd4bbdJJ.cjs.map} +1 -1
- package/dist/{S3StateStore-Cm-v2IPI.cjs → S3StateStore-CoGk6ZKU.cjs} +2 -2
- package/dist/{S3StateStore-Cm-v2IPI.cjs.map → S3StateStore-CoGk6ZKU.cjs.map} +1 -1
- package/dist/{S3StateStore-CjTAVsWh.mjs → S3StateStore-DP_7Q4yb.mjs} +2 -2
- package/dist/{S3StateStore-CjTAVsWh.mjs.map → S3StateStore-DP_7Q4yb.mjs.map} +1 -1
- package/dist/{SSMStateStore-BhtM6jOh.mjs → SSMStateStore-Bo6_KDYY.mjs} +2 -2
- package/dist/{SSMStateStore-BhtM6jOh.mjs.map → SSMStateStore-Bo6_KDYY.mjs.map} +1 -1
- package/dist/{SSMStateStore-BS4BiZCN.cjs → SSMStateStore-D9s4_Do3.cjs} +2 -2
- package/dist/{SSMStateStore-BS4BiZCN.cjs.map → SSMStateStore-D9s4_Do3.cjs.map} +1 -1
- package/dist/{add-ylx8dejw.mjs → add-BQS2QZHp.mjs} +4 -4
- package/dist/{add-ylx8dejw.mjs.map → add-BQS2QZHp.mjs.map} +1 -1
- package/dist/{add-D-3IKT7W.cjs → add-CjURJ-vI.cjs} +4 -4
- package/dist/{add-D-3IKT7W.cjs.map → add-CjURJ-vI.cjs.map} +1 -1
- package/dist/{bundler-ywR3C1B_.mjs → bundler-BMM3UsGm.mjs} +5 -5
- package/dist/{bundler-ywR3C1B_.mjs.map → bundler-BMM3UsGm.mjs.map} +1 -1
- package/dist/{bundler-CI3elfZS.cjs → bundler-DmLJQ7AY.cjs} +5 -5
- package/dist/{bundler-CI3elfZS.cjs.map → bundler-DmLJQ7AY.cjs.map} +1 -1
- package/dist/{cli-Dewt2T21.cjs → cli-C2c-jOVK.cjs} +2 -2
- package/dist/{cli-Dewt2T21.cjs.map → cli-C2c-jOVK.cjs.map} +1 -1
- package/dist/{cli-BCSuCfQk.mjs → cli-Ce6NgaQF.mjs} +2 -2
- package/dist/{cli-BCSuCfQk.mjs.map → cli-Ce6NgaQF.mjs.map} +1 -1
- package/dist/{compose-C4js1JDv.mjs → compose-BJDPFBAN.mjs} +7 -7
- package/dist/{compose-C4js1JDv.mjs.map → compose-BJDPFBAN.mjs.map} +1 -1
- package/dist/{compose-Dd0XphvF.cjs → compose-ETFKqkTu.cjs} +7 -7
- package/dist/{compose-Dd0XphvF.cjs.map → compose-ETFKqkTu.cjs.map} +1 -1
- package/dist/config.cjs +1 -1
- package/dist/config.mjs +1 -1
- package/dist/deploy/public.cjs +7 -7
- package/dist/deploy/public.mjs +7 -7
- package/dist/{deploy-Bw1FjX_x.cjs → deploy-BdN0ym2i.cjs} +200 -46
- package/dist/deploy-BdN0ym2i.cjs.map +1 -0
- package/dist/{deploy-B0drCD6s.mjs → deploy-DktQl7ti.mjs} +200 -46
- package/dist/deploy-DktQl7ti.mjs.map +1 -0
- package/dist/{dns-X3oqEV4C.mjs → dns-BjHECDO7.mjs} +5 -5
- package/dist/{dns-X3oqEV4C.mjs.map → dns-BjHECDO7.mjs.map} +1 -1
- package/dist/{dns-Bmk7P9c2.cjs → dns-C-X6PLkV.cjs} +3 -3
- package/dist/{dns-Bmk7P9c2.cjs.map → dns-C-X6PLkV.cjs.map} +1 -1
- package/dist/{dns-idXfyCay.mjs → dns-C2EeR6n2.mjs} +3 -3
- package/dist/{dns-idXfyCay.mjs.map → dns-C2EeR6n2.mjs.map} +1 -1
- package/dist/{dns-CyMIq6to.cjs → dns-ClI7-d5g.cjs} +5 -5
- package/dist/{dns-CyMIq6to.cjs.map → dns-ClI7-d5g.cjs.map} +1 -1
- package/dist/{dokploy-DaT0mgLU.cjs → dokploy-CD_Bc4EV.cjs} +2 -2
- package/dist/{dokploy-DaT0mgLU.cjs.map → dokploy-CD_Bc4EV.cjs.map} +1 -1
- package/dist/{dokploy-CZYxXeMa.mjs → dokploy-CxtkS5hl.mjs} +2 -2
- package/dist/{dokploy-CZYxXeMa.mjs.map → dokploy-CxtkS5hl.mjs.map} +1 -1
- package/dist/{encryption-D0ucY4O7.mjs → encryption-BgQd4f2S.mjs} +3 -3
- package/dist/{encryption-D0ucY4O7.mjs.map → encryption-BgQd4f2S.mjs.map} +1 -1
- package/dist/{encryption-Dp0IvLVX.cjs → encryption-CqVfz-m7.cjs} +3 -3
- package/dist/{encryption-Dp0IvLVX.cjs.map → encryption-CqVfz-m7.cjs.map} +1 -1
- package/dist/{engine-WY6j_kvA.cjs → engine-OVVKtPmW.cjs} +4 -4
- package/dist/{engine-WY6j_kvA.cjs.map → engine-OVVKtPmW.cjs.map} +1 -1
- package/dist/{engine-BcuhnyQO.mjs → engine-YlXzlTUl.mjs} +4 -4
- package/dist/{engine-BcuhnyQO.mjs.map → engine-YlXzlTUl.mjs.map} +1 -1
- package/dist/{github-DgmW83OP.cjs → github-CsMloeSL.cjs} +5 -5
- package/dist/{github-DgmW83OP.cjs.map → github-CsMloeSL.cjs.map} +1 -1
- package/dist/{github-DUGA57du.mjs → github-DuuvqI3Z.mjs} +5 -5
- package/dist/{github-DUGA57du.mjs.map → github-DuuvqI3Z.mjs.map} +1 -1
- package/dist/index.cjs +48 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +48 -48
- package/dist/index.mjs.map +1 -1
- package/dist/{migrate-afgRL3Hg.cjs → migrate-BAmJeVq1.cjs} +3 -3
- package/dist/{migrate-afgRL3Hg.cjs.map → migrate-BAmJeVq1.cjs.map} +1 -1
- package/dist/{migrate-BBcG1dhS.cjs → migrate-BdkoNdIu.cjs} +3 -3
- package/dist/{migrate-BBcG1dhS.cjs.map → migrate-BdkoNdIu.cjs.map} +1 -1
- package/dist/{migrate-CZ-v5WV0.mjs → migrate-CB8B6W9y.mjs} +3 -3
- package/dist/{migrate-CZ-v5WV0.mjs.map → migrate-CB8B6W9y.mjs.map} +1 -1
- package/dist/{migrate-D6PlNv2o.mjs → migrate-CsPFHgTs.mjs} +3 -3
- package/dist/{migrate-D6PlNv2o.mjs.map → migrate-CsPFHgTs.mjs.map} +1 -1
- package/dist/openapi.cjs +1 -1
- package/dist/openapi.mjs +1 -1
- package/dist/{resolve-CFb4Navi.cjs → resolve-BDatNOoG.cjs} +3 -3
- package/dist/{resolve-CFb4Navi.cjs.map → resolve-BDatNOoG.cjs.map} +1 -1
- package/dist/{resolve-DakDhr6Z.mjs → resolve-CUne0qOm.mjs} +3 -3
- package/dist/{resolve-DakDhr6Z.mjs.map → resolve-CUne0qOm.mjs.map} +1 -1
- package/dist/{rollback-B1TIpjdE.mjs → rollback-CCdEEEcF.mjs} +5 -5
- package/dist/{rollback-B1TIpjdE.mjs.map → rollback-CCdEEEcF.mjs.map} +1 -1
- package/dist/{rollback-B-1dPP0m.cjs → rollback-CuG3DkTY.cjs} +5 -5
- package/dist/{rollback-B-1dPP0m.cjs.map → rollback-CuG3DkTY.cjs.map} +1 -1
- package/dist/{secrets-CPM0Qffe.cjs → secrets-C5qROlbp.cjs} +3 -3
- package/dist/{secrets-CPM0Qffe.cjs.map → secrets-C5qROlbp.cjs.map} +1 -1
- package/dist/{secrets-oI9ClAPR.mjs → secrets-ZikTIxEm.mjs} +3 -3
- package/dist/{secrets-oI9ClAPR.mjs.map → secrets-ZikTIxEm.mjs.map} +1 -1
- package/dist/{seeds-CnXkgKUv.cjs → seeds-BjXW-Krf.cjs} +4 -4
- package/dist/{seeds-CnXkgKUv.cjs.map → seeds-BjXW-Krf.cjs.map} +1 -1
- package/dist/{seeds-CoKkrSny.mjs → seeds-CbJSne1A.mjs} +4 -4
- package/dist/{seeds-CoKkrSny.mjs.map → seeds-CbJSne1A.mjs.map} +1 -1
- package/dist/{sniffer-CFRzIrby.mjs → sniffer-DQGBYY8i.mjs} +7 -7
- package/dist/{sniffer-CFRzIrby.mjs.map → sniffer-DQGBYY8i.mjs.map} +1 -1
- package/dist/{sniffer-vbiQ2Isn.cjs → sniffer-NPD1dyab.cjs} +7 -7
- package/dist/{sniffer-vbiQ2Isn.cjs.map → sniffer-NPD1dyab.cjs.map} +1 -1
- package/dist/{stack-B7O975TR.mjs → stack-BFq3K-_z.mjs} +3 -3
- package/dist/{stack-B7O975TR.mjs.map → stack-BFq3K-_z.mjs.map} +1 -1
- package/dist/{stack-1g57OfOw.cjs → stack-DOVvEd1T.cjs} +3 -3
- package/dist/{stack-1g57OfOw.cjs.map → stack-DOVvEd1T.cjs.map} +1 -1
- package/dist/{stages-Bt4OggMm.mjs → stages-BEn2ArJZ.mjs} +4 -4
- package/dist/{stages-Bt4OggMm.mjs.map → stages-BEn2ArJZ.mjs.map} +1 -1
- package/dist/{stages-BujUB4we.cjs → stages-Cw6urZyJ.cjs} +4 -4
- package/dist/{stages-BujUB4we.cjs.map → stages-Cw6urZyJ.cjs.map} +1 -1
- package/dist/target/public.cjs +1 -1
- package/dist/target/public.mjs +1 -1
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.mjs +1 -1
- package/dist/{workspace-DWK1PTXP.mjs → workspace-CqFUjObk.mjs} +54 -2
- package/dist/workspace-CqFUjObk.mjs.map +1 -0
- package/dist/{workspace-cSyi5nb1.cjs → workspace-DDkm4y6D.cjs} +71 -1
- package/dist/workspace-DDkm4y6D.cjs.map +1 -0
- package/package.json +15 -15
- package/dist/deploy-B0drCD6s.mjs.map +0 -1
- package/dist/deploy-Bw1FjX_x.cjs.map +0 -1
- package/dist/workspace-DWK1PTXP.mjs.map +0 -1
- package/dist/workspace-cSyi5nb1.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stages-BujUB4we.cjs","names":["UndeclaredStage","GkmError","PROVIDER_KINDS","stageProvider","stageDnsDomains","loadWorkspaceSettings","appendFile","GkmError"],"sources":["../src/stages/plan.ts","../src/stages/index.ts"],"sourcesContent":["/**\n * Which stages a workflow run builds and deploys, from the event that started\n * it and the project's `stages`.\n *\n * The rules live here, in tested code, rather than in a workflow's YAML or in\n * the action that runs `gkm stages --github-output`: a project's deploy\n * workflow names no stage, and what it does for each event is decided by the\n * CLI the project installed.\n *\n * | event | build | deploy |\n * | ------------------- | ------------------ | ------------------------------- |\n * | `push` | every deployed | deployed, less the protected |\n * | `release` | none | the protected |\n * | `workflow_dispatch` | none | the one stage named |\n * | anything else | none | none |\n *\n * A push builds every deployed stage, protected ones included, so a release\n * deploys images built from the very commit its tag names; a release and a\n * manual run deploy what a push already built.\n */\n\nimport { GkmError } from '../errors';\nimport { UndeclaredStage } from '../workspace/stages.js';\nimport type { StagesConfig } from '../workspace/types.js';\n\nexport interface StagePlan {\n\t/** The stages whose images this run builds and pushes. */\n\tbuild: string[];\n\t/** The stages this run deploys. */\n\tdeploy: string[];\n}\n\nexport interface PlanInput {\n\t/** The GitHub event name: `push`, `release`, `workflow_dispatch`, … */\n\tevent: string;\n\t/** The stage a `workflow_dispatch` names. */\n\tstage?: string;\n}\n\nexport function planStages(stages: StagesConfig, input: PlanInput): StagePlan {\n\tconst kept = stages.protected ?? [];\n\n\tswitch (input.event) {\n\t\tcase 'push':\n\t\t\treturn {\n\t\t\t\tbuild: [...stages.deployed],\n\t\t\t\tdeploy: stages.deployed.filter((stage) => !kept.includes(stage)),\n\t\t\t};\n\t\tcase 'release':\n\t\t\treturn { build: [], deploy: [...kept] };\n\t\tcase 'workflow_dispatch': {\n\t\t\tconst stage = input.stage?.trim();\n\t\t\tif (!stage) throw new DispatchNamesNoStage(stages.deployed);\n\t\t\tif (!stages.deployed.includes(stage)) {\n\t\t\t\tthrow new UndeclaredStage(stage, stages.deployed);\n\t\t\t}\n\t\t\treturn { build: [], deploy: [stage] };\n\t\t}\n\t\tdefault:\n\t\t\treturn { build: [], deploy: [] };\n\t}\n}\n\n/**\n * A manual run with no stage. Refused rather than read as \"nothing to do\", so\n * a run started with the field left empty fails where it can be seen.\n */\nexport class DispatchNamesNoStage extends GkmError {\n\tconstructor(readonly deployed: readonly string[]) {\n\t\tsuper(\n\t\t\t`A manual run deploys one stage, and none was given. Run the workflow again with stage set to one of: ${deployed.join(', ') || 'nothing yet — gkm.config.ts deploys to no stage'}.`,\n\t\t);\n\t\tthis.name = 'DispatchNamesNoStage';\n\t}\n}\n","/**\n * `gkm stages` — the workspace's stages, as gkm.config.ts declares them.\n *\n * ```bash\n * gkm stages # a table\n * gkm stages --json # {\"local\":\"dev\",\"deployed\":[\"prod\"],\"protected\":[\"prod\"]}\n * gkm stages --github-output # a workflow run's build and deploy matrices\n * ```\n *\n * The config is read by the normal loader (and sandbox), so a workflow never\n * parses TypeScript to learn which stages exist. `--github-output` is what the\n * `geekmidas/toolbox/actions/stages` action runs: it writes the stages, and\n * which of them this run builds and deploys, to `$GITHUB_OUTPUT`.\n */\n\nimport { appendFile } from 'node:fs/promises';\nimport { stageDnsDomains } from '../compose/dns.js';\nimport { loadWorkspaceSettings } from '../config.js';\nimport { GkmError } from '../errors';\nimport { stageProvider } from '../providers/config.js';\nimport { PROVIDER_KINDS } from '../providers/types.js';\nimport type { NormalizedWorkspace, StagesConfig } from '../workspace/types.js';\nimport { planStages } from './plan.js';\n\nexport { DispatchNamesNoStage, type PlanInput, planStages } from './plan.js';\n\nexport interface StagesOptions {\n\t/** Print the stages as JSON. */\n\tjson?: boolean;\n\t/** Write the outputs a deploy workflow reads to `$GITHUB_OUTPUT`. */\n\tgithubOutput?: boolean;\n\t/** The event to plan for; defaults to `GITHUB_EVENT_NAME`. */\n\tevent?: string;\n\t/** The stage a `workflow_dispatch` names. */\n\tstage?: string;\n}\n\nexport interface StagesDeps {\n\tcwd?: string;\n\tenv?: NodeJS.ProcessEnv;\n\t/** Where lines go; stdout by default. */\n\tlog?: (line: string) => void;\n}\n\n/** The stages, as `gkm stages --json` prints them. */\nexport interface StagesJson {\n\tlocal: string;\n\tdeployed: string[];\n\tprotected: string[];\n}\n\nexport function stagesJson(stages: StagesConfig): StagesJson {\n\treturn {\n\t\tlocal: stages.local,\n\t\tdeployed: [...stages.deployed],\n\t\tprotected: [...(stages.protected ?? [])],\n\t};\n}\n\n/**\n * The region of the workspace's AWS secrets store — `ssm` or\n * `secrets-manager` — or `''` when its deployed stages keep their secrets\n * anywhere else. A job assumes the stage's AWS role only when this is set.\n */\nexport function awsSecretsRegion(workspace: NormalizedWorkspace): string {\n\tconst store = workspace.secrets?.store;\n\tif (typeof store !== 'object' || store === null) return '';\n\tif (store.provider === 'ssm' || store.provider === 'secrets-manager') {\n\t\treturn store.region;\n\t}\n\treturn '';\n}\n\n/**\n * The deployed stages with resources the deploy creates — a provider under\n * `deploy.<kind>.<stage>`, or a domain under a `dns` entry whose provider\n * writes records — and secrets a CI runner can reach (an AWS store): a\n * compose deploy workflow creates their resources on the runner, with the\n * stage's role and DNS token, rather than on the server.\n */\nexport function resourceStages(workspace: NormalizedWorkspace): string[] {\n\tif (!awsSecretsRegion(workspace)) return [];\n\treturn workspace.stages.deployed.filter(\n\t\t(stage) =>\n\t\t\tPROVIDER_KINDS.some(\n\t\t\t\t(kind) => stageProvider(workspace, kind, stage).mode === 'provider',\n\t\t\t) ||\n\t\t\tstageDnsDomains(stage, workspace.domains, workspace.dns).some(\n\t\t\t\t({ config }) => config.provider !== 'manual',\n\t\t\t),\n\t);\n}\n\n/**\n * Every output the stages action sets, each a string `fromJSON()` reads, for\n * one workflow run.\n */\nexport function githubOutputs(\n\tworkspace: NormalizedWorkspace,\n\tinput: { event: string; stage?: string },\n): Record<string, string> {\n\tconst stages = stagesJson(workspace.stages);\n\tconst plan = planStages(workspace.stages, input);\n\n\treturn {\n\t\tlocal: JSON.stringify(stages.local),\n\t\tdeployed: JSON.stringify(stages.deployed),\n\t\tprotected: JSON.stringify(stages.protected),\n\t\tbuild: JSON.stringify(plan.build),\n\t\tdeploy: JSON.stringify(plan.deploy),\n\t\t// A matrix over an empty list is an error on GitHub, so a job over one\n\t\t// is skipped on these instead.\n\t\t'has-build': String(plan.build.length > 0),\n\t\t'has-deploy': String(plan.deploy.length > 0),\n\t\t'aws-region': awsSecretsRegion(workspace),\n\t\tresources: JSON.stringify(resourceStages(workspace)),\n\t};\n}\n\n/** `name=value` lines, as `$GITHUB_OUTPUT` takes single-line values. */\nexport function formatGithubOutputs(outputs: Record<string, string>): string {\n\treturn Object.entries(outputs)\n\t\t.map(([name, value]) => `${name}=${value}\\n`)\n\t\t.join('');\n}\n\n/** A message as a workflow command's data: GitHub reads `%`, CR and LF escaped. */\nfunction workflowCommandData(message: string): string {\n\treturn message\n\t\t.replaceAll('%', '%25')\n\t\t.replaceAll('\\r', '%0D')\n\t\t.replaceAll('\\n', '%0A');\n}\n\nfunction table(stages: StagesJson): string {\n\tconst rows: [string, string][] = [\n\t\t['STAGE', 'KIND'],\n\t\t[stages.local, 'local'],\n\t\t...stages.deployed.map((name): [string, string] => [\n\t\t\tname,\n\t\t\tstages.protected.includes(name) ? 'deployed, protected' : 'deployed',\n\t\t]),\n\t];\n\tconst width = Math.max(...rows.map(([name]) => name.length));\n\treturn rows\n\t\t.map(([name, kind]) => `${name.padEnd(width)} ${kind}`)\n\t\t.join('\\n');\n}\n\nexport async function stagesCommand(\n\toptions: StagesOptions,\n\tdeps: StagesDeps = {},\n): Promise<void> {\n\tconst env = deps.env ?? process.env;\n\tconst log = deps.log ?? ((line: string) => console.log(line));\n\n\tif (!options.githubOutput) {\n\t\tconst workspace = await loadWorkspaceSettings(deps.cwd);\n\t\tconst stages = stagesJson(workspace.stages);\n\t\tlog(options.json ? JSON.stringify(stages) : table(stages));\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst file = env.GITHUB_OUTPUT;\n\t\tif (!file) throw new GithubOutputNotSet();\n\n\t\tconst workspace = await loadWorkspaceSettings(deps.cwd);\n\t\tconst event = options.event || env.GITHUB_EVENT_NAME;\n\t\tif (!event) throw new GithubEventNotSet();\n\n\t\tconst outputs = githubOutputs(workspace, {\n\t\t\tevent,\n\t\t\t...(options.stage ? { stage: options.stage } : {}),\n\t\t});\n\t\tawait appendFile(file, formatGithubOutputs(outputs));\n\n\t\tlog(`${event}: build ${outputs.build}, deploy ${outputs.deploy}`);\n\t} catch (error) {\n\t\t// Annotated on the run, where whoever started it looks first.\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tlog(`::error title=gkm stages::${workflowCommandData(message)}`);\n\t\tthrow error;\n\t}\n}\n\n/** `--github-output` outside a GitHub Actions step, which sets the file. */\nexport class GithubOutputNotSet extends GkmError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'gkm stages --github-output writes to the file GITHUB_OUTPUT names, and it is not set. Run it in a GitHub Actions step, or set GITHUB_OUTPUT to a file to write to.',\n\t\t);\n\t\tthis.name = 'GithubOutputNotSet';\n\t}\n}\n\n/** No `--event`, and no `GITHUB_EVENT_NAME` to take it from. */\nexport class GithubEventNotSet extends GkmError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'gkm stages --github-output plans for an event, and none was given. Pass --event (push, release, workflow_dispatch), or run it in a GitHub Actions step, which sets GITHUB_EVENT_NAME.',\n\t\t);\n\t\tthis.name = 'GithubEventNotSet';\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,WAAW,QAAsB,OAA6B;CAC7E,MAAM,OAAO,OAAO,aAAa,CAAC;CAElC,QAAQ,MAAM,OAAd;EACC,KAAK,QACJ,OAAO;GACN,OAAO,CAAC,GAAG,OAAO,QAAQ;GAC1B,QAAQ,OAAO,SAAS,QAAQ,UAAU,CAAC,KAAK,SAAS,KAAK,CAAC;EAChE;EACD,KAAK,WACJ,OAAO;GAAE,OAAO,CAAC;GAAG,QAAQ,CAAC,GAAG,IAAI;EAAE;EACvC,KAAK,qBAAqB;GACzB,MAAM,QAAQ,MAAM,OAAO,KAAK;GAChC,IAAI,CAAC,OAAO,MAAM,IAAI,qBAAqB,OAAO,QAAQ;GAC1D,IAAI,CAAC,OAAO,SAAS,SAAS,KAAK,GAClC,MAAM,IAAIA,kBAAAA,gBAAgB,OAAO,OAAO,QAAQ;GAEjD,OAAO;IAAE,OAAO,CAAC;IAAG,QAAQ,CAAC,KAAK;GAAE;EACrC;EACA,SACC,OAAO;GAAE,OAAO,CAAC;GAAG,QAAQ,CAAC;EAAE;CACjC;AACD;;;;;AAMA,IAAa,uBAAb,cAA0CC,eAAAA,SAAS;CAC7B;CAArB,YAAY,UAAsC;EACjD,MACC,wGAAwG,SAAS,KAAK,IAAI,KAAK,kDAAkD,EAClL;EAHoB,KAAA,WAAA;EAIpB,KAAK,OAAO;CACb;AACD;;;;;;;;;;;;;;;;;ACvBA,SAAgB,WAAW,QAAkC;CAC5D,OAAO;EACN,OAAO,OAAO;EACd,UAAU,CAAC,GAAG,OAAO,QAAQ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AAI,GAAG,MAAM,UAAU,QAAQ,MAAM,WAAW,QAAQ,QAAQ;CACjE,SAAS,OAAO;EAGf,IAAI,6BAA6B,oBADjB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CACT,GAAG;EAC/D,MAAM;CACP;AACD;;AAGA,IAAa,qBAAb,cAAwCC,eAAAA,SAAS;CAChD,cAAc;EACb,MACC,oKACD;EACA,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,oBAAb,cAAuCA,eAAAA,SAAS;CAC/C,cAAc;EACb,MACC,uLACD;EACA,KAAK,OAAO;CACb;AACD"}
|
|
1
|
+
{"version":3,"file":"stages-Cw6urZyJ.cjs","names":["UndeclaredStage","GkmError","PROVIDER_KINDS","stageProvider","stageDnsDomains","loadWorkspaceSettings","appendFile","GkmError"],"sources":["../src/stages/plan.ts","../src/stages/index.ts"],"sourcesContent":["/**\n * Which stages a workflow run builds and deploys, from the event that started\n * it and the project's `stages`.\n *\n * The rules live here, in tested code, rather than in a workflow's YAML or in\n * the action that runs `gkm stages --github-output`: a project's deploy\n * workflow names no stage, and what it does for each event is decided by the\n * CLI the project installed.\n *\n * | event | build | deploy |\n * | ------------------- | ------------------ | ------------------------------- |\n * | `push` | every deployed | deployed, less the protected |\n * | `release` | none | the protected |\n * | `workflow_dispatch` | none | the one stage named |\n * | anything else | none | none |\n *\n * A push builds every deployed stage, protected ones included, so a release\n * deploys images built from the very commit its tag names; a release and a\n * manual run deploy what a push already built.\n */\n\nimport { GkmError } from '../errors';\nimport { UndeclaredStage } from '../workspace/stages.js';\nimport type { StagesConfig } from '../workspace/types.js';\n\nexport interface StagePlan {\n\t/** The stages whose images this run builds and pushes. */\n\tbuild: string[];\n\t/** The stages this run deploys. */\n\tdeploy: string[];\n}\n\nexport interface PlanInput {\n\t/** The GitHub event name: `push`, `release`, `workflow_dispatch`, … */\n\tevent: string;\n\t/** The stage a `workflow_dispatch` names. */\n\tstage?: string;\n}\n\nexport function planStages(stages: StagesConfig, input: PlanInput): StagePlan {\n\tconst kept = stages.protected ?? [];\n\n\tswitch (input.event) {\n\t\tcase 'push':\n\t\t\treturn {\n\t\t\t\tbuild: [...stages.deployed],\n\t\t\t\tdeploy: stages.deployed.filter((stage) => !kept.includes(stage)),\n\t\t\t};\n\t\tcase 'release':\n\t\t\treturn { build: [], deploy: [...kept] };\n\t\tcase 'workflow_dispatch': {\n\t\t\tconst stage = input.stage?.trim();\n\t\t\tif (!stage) throw new DispatchNamesNoStage(stages.deployed);\n\t\t\tif (!stages.deployed.includes(stage)) {\n\t\t\t\tthrow new UndeclaredStage(stage, stages.deployed);\n\t\t\t}\n\t\t\treturn { build: [], deploy: [stage] };\n\t\t}\n\t\tdefault:\n\t\t\treturn { build: [], deploy: [] };\n\t}\n}\n\n/**\n * A manual run with no stage. Refused rather than read as \"nothing to do\", so\n * a run started with the field left empty fails where it can be seen.\n */\nexport class DispatchNamesNoStage extends GkmError {\n\tconstructor(readonly deployed: readonly string[]) {\n\t\tsuper(\n\t\t\t`A manual run deploys one stage, and none was given. Run the workflow again with stage set to one of: ${deployed.join(', ') || 'nothing yet — gkm.config.ts deploys to no stage'}.`,\n\t\t);\n\t\tthis.name = 'DispatchNamesNoStage';\n\t}\n}\n","/**\n * `gkm stages` — the workspace's stages, as gkm.config.ts declares them.\n *\n * ```bash\n * gkm stages # a table\n * gkm stages --json # {\"local\":\"dev\",\"deployed\":[\"prod\"],\"protected\":[\"prod\"]}\n * gkm stages --github-output # a workflow run's build and deploy matrices\n * ```\n *\n * The config is read by the normal loader (and sandbox), so a workflow never\n * parses TypeScript to learn which stages exist. `--github-output` is what the\n * `geekmidas/toolbox/actions/stages` action runs: it writes the stages, and\n * which of them this run builds and deploys, to `$GITHUB_OUTPUT`.\n */\n\nimport { appendFile } from 'node:fs/promises';\nimport { stageDnsDomains } from '../compose/dns.js';\nimport { loadWorkspaceSettings } from '../config.js';\nimport { GkmError } from '../errors';\nimport { stageProvider } from '../providers/config.js';\nimport { PROVIDER_KINDS } from '../providers/types.js';\nimport type { NormalizedWorkspace, StagesConfig } from '../workspace/types.js';\nimport { planStages } from './plan.js';\n\nexport { DispatchNamesNoStage, type PlanInput, planStages } from './plan.js';\n\nexport interface StagesOptions {\n\t/** Print the stages as JSON. */\n\tjson?: boolean;\n\t/** Write the outputs a deploy workflow reads to `$GITHUB_OUTPUT`. */\n\tgithubOutput?: boolean;\n\t/** The event to plan for; defaults to `GITHUB_EVENT_NAME`. */\n\tevent?: string;\n\t/** The stage a `workflow_dispatch` names. */\n\tstage?: string;\n}\n\nexport interface StagesDeps {\n\tcwd?: string;\n\tenv?: NodeJS.ProcessEnv;\n\t/** Where lines go; stdout by default. */\n\tlog?: (line: string) => void;\n}\n\n/** The stages, as `gkm stages --json` prints them. */\nexport interface StagesJson {\n\tlocal: string;\n\tdeployed: string[];\n\tprotected: string[];\n}\n\nexport function stagesJson(stages: StagesConfig): StagesJson {\n\treturn {\n\t\tlocal: stages.local,\n\t\tdeployed: [...stages.deployed],\n\t\tprotected: [...(stages.protected ?? [])],\n\t};\n}\n\n/**\n * The region of the workspace's AWS secrets store — `ssm` or\n * `secrets-manager` — or `''` when its deployed stages keep their secrets\n * anywhere else. A job assumes the stage's AWS role only when this is set.\n */\nexport function awsSecretsRegion(workspace: NormalizedWorkspace): string {\n\tconst store = workspace.secrets?.store;\n\tif (typeof store !== 'object' || store === null) return '';\n\tif (store.provider === 'ssm' || store.provider === 'secrets-manager') {\n\t\treturn store.region;\n\t}\n\treturn '';\n}\n\n/**\n * The deployed stages with resources the deploy creates — a provider under\n * `deploy.<kind>.<stage>`, or a domain under a `dns` entry whose provider\n * writes records — and secrets a CI runner can reach (an AWS store): a\n * compose deploy workflow creates their resources on the runner, with the\n * stage's role and DNS token, rather than on the server.\n */\nexport function resourceStages(workspace: NormalizedWorkspace): string[] {\n\tif (!awsSecretsRegion(workspace)) return [];\n\treturn workspace.stages.deployed.filter(\n\t\t(stage) =>\n\t\t\tPROVIDER_KINDS.some(\n\t\t\t\t(kind) => stageProvider(workspace, kind, stage).mode === 'provider',\n\t\t\t) ||\n\t\t\tstageDnsDomains(stage, workspace.domains, workspace.dns).some(\n\t\t\t\t({ config }) => config.provider !== 'manual',\n\t\t\t),\n\t);\n}\n\n/**\n * Every output the stages action sets, each a string `fromJSON()` reads, for\n * one workflow run.\n */\nexport function githubOutputs(\n\tworkspace: NormalizedWorkspace,\n\tinput: { event: string; stage?: string },\n): Record<string, string> {\n\tconst stages = stagesJson(workspace.stages);\n\tconst plan = planStages(workspace.stages, input);\n\n\treturn {\n\t\tlocal: JSON.stringify(stages.local),\n\t\tdeployed: JSON.stringify(stages.deployed),\n\t\tprotected: JSON.stringify(stages.protected),\n\t\tbuild: JSON.stringify(plan.build),\n\t\tdeploy: JSON.stringify(plan.deploy),\n\t\t// A matrix over an empty list is an error on GitHub, so a job over one\n\t\t// is skipped on these instead.\n\t\t'has-build': String(plan.build.length > 0),\n\t\t'has-deploy': String(plan.deploy.length > 0),\n\t\t'aws-region': awsSecretsRegion(workspace),\n\t\tresources: JSON.stringify(resourceStages(workspace)),\n\t};\n}\n\n/** `name=value` lines, as `$GITHUB_OUTPUT` takes single-line values. */\nexport function formatGithubOutputs(outputs: Record<string, string>): string {\n\treturn Object.entries(outputs)\n\t\t.map(([name, value]) => `${name}=${value}\\n`)\n\t\t.join('');\n}\n\n/** A message as a workflow command's data: GitHub reads `%`, CR and LF escaped. */\nfunction workflowCommandData(message: string): string {\n\treturn message\n\t\t.replaceAll('%', '%25')\n\t\t.replaceAll('\\r', '%0D')\n\t\t.replaceAll('\\n', '%0A');\n}\n\nfunction table(stages: StagesJson): string {\n\tconst rows: [string, string][] = [\n\t\t['STAGE', 'KIND'],\n\t\t[stages.local, 'local'],\n\t\t...stages.deployed.map((name): [string, string] => [\n\t\t\tname,\n\t\t\tstages.protected.includes(name) ? 'deployed, protected' : 'deployed',\n\t\t]),\n\t];\n\tconst width = Math.max(...rows.map(([name]) => name.length));\n\treturn rows\n\t\t.map(([name, kind]) => `${name.padEnd(width)} ${kind}`)\n\t\t.join('\\n');\n}\n\nexport async function stagesCommand(\n\toptions: StagesOptions,\n\tdeps: StagesDeps = {},\n): Promise<void> {\n\tconst env = deps.env ?? process.env;\n\tconst log = deps.log ?? ((line: string) => console.log(line));\n\n\tif (!options.githubOutput) {\n\t\tconst workspace = await loadWorkspaceSettings(deps.cwd);\n\t\tconst stages = stagesJson(workspace.stages);\n\t\tlog(options.json ? JSON.stringify(stages) : table(stages));\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst file = env.GITHUB_OUTPUT;\n\t\tif (!file) throw new GithubOutputNotSet();\n\n\t\tconst workspace = await loadWorkspaceSettings(deps.cwd);\n\t\tconst event = options.event || env.GITHUB_EVENT_NAME;\n\t\tif (!event) throw new GithubEventNotSet();\n\n\t\tconst outputs = githubOutputs(workspace, {\n\t\t\tevent,\n\t\t\t...(options.stage ? { stage: options.stage } : {}),\n\t\t});\n\t\tawait appendFile(file, formatGithubOutputs(outputs));\n\n\t\tlog(`${event}: build ${outputs.build}, deploy ${outputs.deploy}`);\n\t} catch (error) {\n\t\t// Annotated on the run, where whoever started it looks first.\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tlog(`::error title=gkm stages::${workflowCommandData(message)}`);\n\t\tthrow error;\n\t}\n}\n\n/** `--github-output` outside a GitHub Actions step, which sets the file. */\nexport class GithubOutputNotSet extends GkmError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'gkm stages --github-output writes to the file GITHUB_OUTPUT names, and it is not set. Run it in a GitHub Actions step, or set GITHUB_OUTPUT to a file to write to.',\n\t\t);\n\t\tthis.name = 'GithubOutputNotSet';\n\t}\n}\n\n/** No `--event`, and no `GITHUB_EVENT_NAME` to take it from. */\nexport class GithubEventNotSet extends GkmError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'gkm stages --github-output plans for an event, and none was given. Pass --event (push, release, workflow_dispatch), or run it in a GitHub Actions step, which sets GITHUB_EVENT_NAME.',\n\t\t);\n\t\t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AAAA,SAAS;CAChD,cAAc;EACb,MACC,oKACD;EACA,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,oBAAb,cAAuCA,eAAAA,SAAS;CAC/C,cAAc;EACb,MACC,uLACD;EACA,KAAK,OAAO;CACb;AACD"}
|
package/dist/target/public.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_define = require("../define-crmMcXFS.cjs");
|
|
3
|
-
const require_resolve = require("../resolve-
|
|
3
|
+
const require_resolve = require("../resolve-BDatNOoG.cjs");
|
|
4
4
|
const require_provider = require("../provider-BqpjG9QM.cjs");
|
|
5
5
|
exports.DeployTargetNotYetSupported = require_define.DeployTargetNotYetSupported;
|
|
6
6
|
exports.InvalidTargetOptions = require_resolve.InvalidTargetOptions;
|
package/dist/target/public.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { a as UnknownDeployTarget, i as DeployTargetNotYetSupported, n as isDeployTarget, t as defineTarget } from "../define-6poNqm5O.mjs";
|
|
2
|
-
import { i as TargetRuntimeMismatch, l as TargetPackageNotFound, n as TargetEntryInvalid, r as TargetPackageInvalid, s as TargetRuntimeUndeclared, t as InvalidTargetOptions } from "../resolve-
|
|
2
|
+
import { i as TargetRuntimeMismatch, l as TargetPackageNotFound, n as TargetEntryInvalid, r as TargetPackageInvalid, s as TargetRuntimeUndeclared, t as InvalidTargetOptions } from "../resolve-CUne0qOm.mjs";
|
|
3
3
|
import { t as ProviderRemoved } from "../provider-CEOKk8NS.mjs";
|
|
4
4
|
export { DeployTargetNotYetSupported, InvalidTargetOptions, ProviderRemoved, TargetEntryInvalid, TargetPackageInvalid, TargetPackageNotFound, TargetRuntimeMismatch, TargetRuntimeUndeclared, UnknownDeployTarget, defineTarget, isDeployTarget };
|
package/dist/workspace/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_workspace = require("../workspace-
|
|
2
|
+
const require_workspace = require("../workspace-DDkm4y6D.cjs");
|
|
3
3
|
exports.DnsMoved = require_workspace.DnsMoved;
|
|
4
4
|
exports.DokployRegistryMoved = require_workspace.DokployRegistryMoved;
|
|
5
5
|
exports.DomainsMoved = require_workspace.DomainsMoved;
|
package/dist/workspace/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as WorkspaceConfigSchema, D as isPhase2DeployTarget, E as isDeployTargetSupported, O as safeValidateWorkspaceConfig, S as SUPPORTED_DEPLOY_TARGETS, T as getDeployTargetError, _ as PUBLIC_ENV_PREFIXES, a as allConstructGlobs, b as isWorkspaceConfig, c as constructPatterns, d as getAppGkmConfig, f as getEndpointForStage, g as wrapSingleAppAsWorkspace, h as workspaceConstructGlobs, i as InvalidWorkspaceConfig, k as validateWorkspaceConfig, l as defineWorkspace, m as processConfig, n as DokployRegistryMoved, o as appConstructGlobs, p as normalizeWorkspace, r as DomainsMoved, s as assertNoMovedDeployKeys, t as DnsMoved, u as getAppBuildOrder, v as getPublicEnvPrefix, w as formatValidationErrors, x as PHASE_2_DEPLOY_TARGETS, y as stripPublicPrefix } from "../workspace-
|
|
1
|
+
import { C as WorkspaceConfigSchema, D as isPhase2DeployTarget, E as isDeployTargetSupported, O as safeValidateWorkspaceConfig, S as SUPPORTED_DEPLOY_TARGETS, T as getDeployTargetError, _ as PUBLIC_ENV_PREFIXES, a as allConstructGlobs, b as isWorkspaceConfig, c as constructPatterns, d as getAppGkmConfig, f as getEndpointForStage, g as wrapSingleAppAsWorkspace, h as workspaceConstructGlobs, i as InvalidWorkspaceConfig, k as validateWorkspaceConfig, l as defineWorkspace, m as processConfig, n as DokployRegistryMoved, o as appConstructGlobs, p as normalizeWorkspace, r as DomainsMoved, s as assertNoMovedDeployKeys, t as DnsMoved, u as getAppBuildOrder, v as getPublicEnvPrefix, w as formatValidationErrors, x as PHASE_2_DEPLOY_TARGETS, y as stripPublicPrefix } from "../workspace-CqFUjObk.mjs";
|
|
2
2
|
export { DnsMoved, DokployRegistryMoved, DomainsMoved, InvalidWorkspaceConfig, PHASE_2_DEPLOY_TARGETS, PUBLIC_ENV_PREFIXES, SUPPORTED_DEPLOY_TARGETS, WorkspaceConfigSchema, allConstructGlobs, appConstructGlobs, assertNoMovedDeployKeys, constructPatterns, defineWorkspace, formatValidationErrors, getAppBuildOrder, getAppGkmConfig, getDeployTargetError, getEndpointForStage, getPublicEnvPrefix, isDeployTargetSupported, isPhase2DeployTarget, isWorkspaceConfig, normalizeWorkspace, processConfig, safeValidateWorkspaceConfig, stripPublicPrefix, validateWorkspaceConfig, workspaceConstructGlobs, wrapSingleAppAsWorkspace };
|
|
@@ -313,6 +313,58 @@ var ProvisionedBucketUnreachable = class extends GkmError {
|
|
|
313
313
|
this.name = "ProvisionedBucketUnreachable";
|
|
314
314
|
}
|
|
315
315
|
};
|
|
316
|
+
/**
|
|
317
|
+
* `verify()`: the bucket answers from another region than the one its URL
|
|
318
|
+
* names — S3 redirects (301) or refuses the signature (400) and says where
|
|
319
|
+
* the bucket is.
|
|
320
|
+
*/
|
|
321
|
+
var BucketRegionMismatch = class extends GkmError {
|
|
322
|
+
id;
|
|
323
|
+
bucket;
|
|
324
|
+
stage;
|
|
325
|
+
key;
|
|
326
|
+
bucketRegion;
|
|
327
|
+
urlRegion;
|
|
328
|
+
askedRegion;
|
|
329
|
+
answer;
|
|
330
|
+
constructor(id, bucket, stage, key, bucketRegion, urlRegion, askedRegion, answer) {
|
|
331
|
+
const says = urlRegion ? `says ${urlRegion}` : `names no region, so ${askedRegion} was asked`;
|
|
332
|
+
super(`The bucket '${bucket}' (${id}) is in ${bucketRegion}, but ${key} in the stage '${stage}''s secrets ${says} (${answer}). Deploy '${stage}' with the stage account's credentials (gkm deploy --stage ${stage}): the s3 provider reads the bucket's region and rewrites ${key} with it. Set deploy.objects.${stage}.region to '${bucketRegion}' in gkm.config.ts so the stage's config says where its buckets are.`);
|
|
333
|
+
this.id = id;
|
|
334
|
+
this.bucket = bucket;
|
|
335
|
+
this.stage = stage;
|
|
336
|
+
this.key = key;
|
|
337
|
+
this.bucketRegion = bucketRegion;
|
|
338
|
+
this.urlRegion = urlRegion;
|
|
339
|
+
this.askedRegion = askedRegion;
|
|
340
|
+
this.answer = answer;
|
|
341
|
+
this.name = "BucketRegionMismatch";
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
/** Neither `HeadBucket` nor `GetBucketLocation` says where a bucket is. */
|
|
345
|
+
var BucketRegionUnknown = class extends GkmError {
|
|
346
|
+
bucket;
|
|
347
|
+
head;
|
|
348
|
+
location;
|
|
349
|
+
constructor(bucket, head, location) {
|
|
350
|
+
super(`gkm cannot tell which region the bucket '${bucket}' is in: HeadBucket answered ${head}, and GetBucketLocation ${location}. Check that the provisioning credentials are the stage account's and may call s3:GetBucketLocation on it, then run the deploy again.`);
|
|
351
|
+
this.bucket = bucket;
|
|
352
|
+
this.head = head;
|
|
353
|
+
this.location = location;
|
|
354
|
+
this.name = "BucketRegionUnknown";
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
/** `HeadBucket` answered neither yes, no, nor "another account's". */
|
|
358
|
+
var BucketProbeFailed = class extends GkmError {
|
|
359
|
+
bucket;
|
|
360
|
+
answer;
|
|
361
|
+
constructor(bucket, answer) {
|
|
362
|
+
super(`gkm asked S3 whether the bucket '${bucket}' exists and got ${answer}. Check the provisioning credentials and the stage's region, then run the deploy again.`);
|
|
363
|
+
this.bucket = bucket;
|
|
364
|
+
this.answer = answer;
|
|
365
|
+
this.name = "BucketProbeFailed";
|
|
366
|
+
}
|
|
367
|
+
};
|
|
316
368
|
//#endregion
|
|
317
369
|
//#region src/providers/s3/config.ts
|
|
318
370
|
const FIELDS = [
|
|
@@ -1975,6 +2027,6 @@ function getEndpointForStage(dokployConfig, stage) {
|
|
|
1975
2027
|
return dokployConfig.endpoint;
|
|
1976
2028
|
}
|
|
1977
2029
|
//#endregion
|
|
1978
|
-
export {
|
|
2030
|
+
export { IamUserNotOwned as $, InvalidStages as A, LOGS_PORT as B, WorkspaceConfigSchema as C, isPhase2DeployTarget as D, isDeployTargetSupported as E, stageProblems as F, checkS3Config as G, provisioningOf as H, otlpTelemetryEnv as I, BucketNameUnavailable as J, AccessKeyLimit as K, resolveStageTelemetry as L, UndeclaredStage as M, assertDeployedStage as N, safeValidateWorkspaceConfig as O, deployedProblems as P, BucketRegionUnknown as Q, stageSampleRate as R, SUPPORTED_DEPLOY_TARGETS as S, getDeployTargetError as T, stageProvider as U, UnknownStageProvider as V, S3_PROVISIONING as W, BucketProbeFailed as X, BucketOwnedByAnotherProject as Y, BucketRegionMismatch as Z, PUBLIC_ENV_PREFIXES as _, allConstructGlobs as a, certificateFor as at, isWorkspaceConfig as b, constructPatterns as c, SERVER_IPV6_KEY as ct, getAppGkmConfig as d, SECRETS_STORE_PROVIDERS as dt, ProvisionedBucketUnreachable as et, getEndpointForStage as f, UnknownSecretsStoreProvider as ft, wrapSingleAppAsWorkspace as g, workspaceConstructGlobs as h, InvalidWorkspaceConfig as i, ComposeTlsFileMissing as it, TEST_STAGE as j, validateWorkspaceConfig as k, defineWorkspace as l, cnameTarget as lt, processConfig as m, DokployRegistryMoved as n, RotationInProgress as nt, appConstructGlobs as o, proxyFor as ot, normalizeWorkspace as p, BucketKeySetElsewhere as q, DomainsMoved as r, S3RegionRequired as rt, assertNoMovedDeployKeys as s, SERVER_IPV4_KEY as st, DnsMoved as t, RecordedBucketUnreachable as tt, getAppBuildOrder as u, isReservedStageKey as ut, getPublicEnvPrefix as v, formatValidationErrors as w, PHASE_2_DEPLOY_TARGETS as x, stripPublicPrefix as y, telemetryEnv as z };
|
|
1979
2031
|
|
|
1980
|
-
//# sourceMappingURL=workspace-
|
|
2032
|
+
//# sourceMappingURL=workspace-CqFUjObk.mjs.map
|