@geekmidas/cli 10.0.0-alpha.82 → 10.0.0-alpha.83
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/{LegacyStateStore-Ceq7A_75.mjs → LegacyStateStore-DFO3aJgs.mjs} +2 -2
- package/dist/{LegacyStateStore-Ceq7A_75.mjs.map → LegacyStateStore-DFO3aJgs.mjs.map} +1 -1
- package/dist/{LegacyStateStore-Z-EKUGSX.cjs → LegacyStateStore-iUWVxrXU.cjs} +2 -2
- package/dist/{LegacyStateStore-Z-EKUGSX.cjs.map → LegacyStateStore-iUWVxrXU.cjs.map} +1 -1
- package/dist/{LocalStateStore-Bocb8dmZ.cjs → LocalStateStore-BsFHdSeA.cjs} +2 -2
- package/dist/{LocalStateStore-Bocb8dmZ.cjs.map → LocalStateStore-BsFHdSeA.cjs.map} +1 -1
- package/dist/{LocalStateStore-C72bwpG2.mjs → LocalStateStore-DIfuh0Z1.mjs} +2 -2
- package/dist/{LocalStateStore-C72bwpG2.mjs.map → LocalStateStore-DIfuh0Z1.mjs.map} +1 -1
- package/dist/{S3StateStore-C9upSW5o.mjs → S3StateStore-DR2f78Dj.mjs} +2 -2
- package/dist/{S3StateStore-C9upSW5o.mjs.map → S3StateStore-DR2f78Dj.mjs.map} +1 -1
- package/dist/{S3StateStore-35YfcdL_.cjs → S3StateStore-ytvpIiv8.cjs} +2 -2
- package/dist/{S3StateStore-35YfcdL_.cjs.map → S3StateStore-ytvpIiv8.cjs.map} +1 -1
- package/dist/{SSMStateStore-dOmFO6g1.mjs → SSMStateStore-BZ3XL0Mr.mjs} +2 -2
- package/dist/{SSMStateStore-dOmFO6g1.mjs.map → SSMStateStore-BZ3XL0Mr.mjs.map} +1 -1
- package/dist/{SSMStateStore-W-Ps22AQ.cjs → SSMStateStore-C1JruCD9.cjs} +2 -2
- package/dist/{SSMStateStore-W-Ps22AQ.cjs.map → SSMStateStore-C1JruCD9.cjs.map} +1 -1
- package/dist/{add-1T3y6E4M.cjs → add-Bwddb4KD.cjs} +3 -3
- package/dist/{add-1T3y6E4M.cjs.map → add-Bwddb4KD.cjs.map} +1 -1
- package/dist/{add-DnYHJOap.mjs → add-DkBEZ5_s.mjs} +3 -3
- package/dist/{add-DnYHJOap.mjs.map → add-DkBEZ5_s.mjs.map} +1 -1
- package/dist/{bundler-DlKdxCGh.mjs → bundler-B8TGsunu.mjs} +5 -5
- package/dist/{bundler-DlKdxCGh.mjs.map → bundler-B8TGsunu.mjs.map} +1 -1
- package/dist/{bundler-YNvLdvlh.cjs → bundler-BkH1kPEX.cjs} +5 -5
- package/dist/{bundler-YNvLdvlh.cjs.map → bundler-BkH1kPEX.cjs.map} +1 -1
- package/dist/{cli-qMszGvDu.mjs → cli-BgDd4cZB.mjs} +3 -3
- package/dist/{cli-qMszGvDu.mjs.map → cli-BgDd4cZB.mjs.map} +1 -1
- package/dist/{cli-CWee1-wU.cjs → cli-DO7DQqCq.cjs} +3 -3
- package/dist/{cli-CWee1-wU.cjs.map → cli-DO7DQqCq.cjs.map} +1 -1
- package/dist/{compose-D4sD4Lgr.mjs → compose-BPJ9bUKp.mjs} +3 -3
- package/dist/{compose-D4sD4Lgr.mjs.map → compose-BPJ9bUKp.mjs.map} +1 -1
- package/dist/{compose-qnDyPJNp.cjs → compose-CGyxYe-h.cjs} +3 -3
- package/dist/{compose-qnDyPJNp.cjs.map → compose-CGyxYe-h.cjs.map} +1 -1
- package/dist/{config-L_6NivCp.d.mts → config-BBFiH4qk.d.mts} +2 -2
- package/dist/{config-L_6NivCp.d.mts.map → config-BBFiH4qk.d.mts.map} +1 -1
- package/dist/{config-Mr4rcXFC.d.cts → config-DMdzdO5u.d.cts} +2 -2
- package/dist/{config-Mr4rcXFC.d.cts.map → config-DMdzdO5u.d.cts.map} +1 -1
- package/dist/config.cjs +1 -1
- package/dist/config.d.cts +2 -2
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +1 -1
- package/dist/deploy/public.cjs +6 -6
- package/dist/deploy/public.d.cts +1 -1
- package/dist/deploy/public.d.mts +1 -1
- package/dist/deploy/public.mjs +6 -6
- package/dist/{deploy-C00DAKOt.mjs → deploy-0XpZDYAr.mjs} +5 -5
- package/dist/{deploy-C00DAKOt.mjs.map → deploy-0XpZDYAr.mjs.map} +1 -1
- package/dist/{deploy-CXP2fXvK.cjs → deploy-BlZx6J5x.cjs} +5 -5
- package/dist/{deploy-CXP2fXvK.cjs.map → deploy-BlZx6J5x.cjs.map} +1 -1
- package/dist/{dokploy-B3zoCmJb.mjs → dokploy-Crh4uDmP.mjs} +2 -2
- package/dist/{dokploy-B3zoCmJb.mjs.map → dokploy-Crh4uDmP.mjs.map} +1 -1
- package/dist/{dokploy-BHcSmghb.cjs → dokploy-rjXmkuwH.cjs} +2 -2
- package/dist/{dokploy-BHcSmghb.cjs.map → dokploy-rjXmkuwH.cjs.map} +1 -1
- package/dist/{encryption-DPFljXtM.mjs → encryption-0eo9aY_H.mjs} +3 -3
- package/dist/{encryption-DPFljXtM.mjs.map → encryption-0eo9aY_H.mjs.map} +1 -1
- package/dist/{encryption-DLin89I_.cjs → encryption-CxTfRx4h.cjs} +3 -3
- package/dist/{encryption-DLin89I_.cjs.map → encryption-CxTfRx4h.cjs.map} +1 -1
- package/dist/{engine-BS3iX9Mu.cjs → engine-CMzSebbs.cjs} +4 -4
- package/dist/{engine-BS3iX9Mu.cjs.map → engine-CMzSebbs.cjs.map} +1 -1
- package/dist/{engine-CgzgIg-_.mjs → engine-DxWswfXe.mjs} +4 -4
- package/dist/{engine-CgzgIg-_.mjs.map → engine-DxWswfXe.mjs.map} +1 -1
- package/dist/{github-D8KVmNRg.cjs → github-Dukt5cJe.cjs} +3 -3
- package/dist/{github-D8KVmNRg.cjs.map → github-Dukt5cJe.cjs.map} +1 -1
- package/dist/{github-DL4zwJsR.mjs → github-HOfOpFI_.mjs} +3 -3
- package/dist/{github-DL4zwJsR.mjs.map → github-HOfOpFI_.mjs.map} +1 -1
- package/dist/{index-DTEPwLml.d.cts → index-DFrbhRwg.d.cts} +6 -2
- package/dist/{index-C0UmP_lg.d.mts.map → index-DFrbhRwg.d.cts.map} +1 -1
- package/dist/{index-C0UmP_lg.d.mts → index-Wuqpf316.d.mts} +6 -2
- package/dist/{index-DTEPwLml.d.cts.map → index-Wuqpf316.d.mts.map} +1 -1
- package/dist/index.cjs +427 -111
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +427 -111
- package/dist/index.mjs.map +1 -1
- package/dist/{migrate-CCejlgU0.mjs → migrate-1dGEzuJ-.mjs} +3 -3
- package/dist/{migrate-CCejlgU0.mjs.map → migrate-1dGEzuJ-.mjs.map} +1 -1
- package/dist/{migrate-BdKhIJgT.cjs → migrate-Bemd4tkz.cjs} +3 -3
- package/dist/{migrate-BdKhIJgT.cjs.map → migrate-Bemd4tkz.cjs.map} +1 -1
- package/dist/{migrate-DIjG8-QR.cjs → migrate-BgPWVnAZ.cjs} +3 -3
- package/dist/{migrate-DIjG8-QR.cjs.map → migrate-BgPWVnAZ.cjs.map} +1 -1
- package/dist/{migrate-Cd3kcI7o.mjs → migrate-C14NNbFx.mjs} +3 -3
- package/dist/{migrate-Cd3kcI7o.mjs.map → migrate-C14NNbFx.mjs.map} +1 -1
- package/dist/openapi.cjs +1 -1
- package/dist/openapi.mjs +1 -1
- package/dist/{resolve-ApSUK_HB.cjs → resolve-DCTcD823.cjs} +3 -3
- package/dist/{resolve-ApSUK_HB.cjs.map → resolve-DCTcD823.cjs.map} +1 -1
- package/dist/{resolve-DY9TaVeV.mjs → resolve-y1PkSZrF.mjs} +3 -3
- package/dist/{resolve-DY9TaVeV.mjs.map → resolve-y1PkSZrF.mjs.map} +1 -1
- package/dist/{rollback-CdGhCk1d.cjs → rollback-BVQFDjxr.cjs} +5 -5
- package/dist/{rollback-CdGhCk1d.cjs.map → rollback-BVQFDjxr.cjs.map} +1 -1
- package/dist/{rollback-DXU6cr7q.mjs → rollback-CwVhG_xa.mjs} +5 -5
- package/dist/{rollback-DXU6cr7q.mjs.map → rollback-CwVhG_xa.mjs.map} +1 -1
- package/dist/{seeds-DbyqaXW4.mjs → seeds-BoKQ74Od.mjs} +3 -3
- package/dist/{seeds-DbyqaXW4.mjs.map → seeds-BoKQ74Od.mjs.map} +1 -1
- package/dist/{seeds-BLzrSwEr.cjs → seeds-Ccju3zGl.cjs} +3 -3
- package/dist/{seeds-BLzrSwEr.cjs.map → seeds-Ccju3zGl.cjs.map} +1 -1
- package/dist/{sniffer-ByWtH28i.mjs → sniffer-6oYI-MpT.mjs} +6 -6
- package/dist/{sniffer-ByWtH28i.mjs.map → sniffer-6oYI-MpT.mjs.map} +1 -1
- package/dist/{sniffer-BjG-1mlD.cjs → sniffer-DeyYI9Iv.cjs} +6 -6
- package/dist/{sniffer-BjG-1mlD.cjs.map → sniffer-DeyYI9Iv.cjs.map} +1 -1
- package/dist/stages-CHF9RFog.mjs +174 -0
- package/dist/stages-CHF9RFog.mjs.map +1 -0
- package/dist/stages-CwrYVX9u.cjs +174 -0
- package/dist/stages-CwrYVX9u.cjs.map +1 -0
- package/dist/target/public.cjs +1 -1
- package/dist/target/public.mjs +1 -1
- package/dist/workspace/index.cjs +2 -1
- package/dist/workspace/index.d.cts +2 -2
- package/dist/workspace/index.d.mts +2 -2
- package/dist/workspace/index.mjs +2 -2
- package/dist/{workspace-Bp8FEkF-.cjs → workspace-4i6Jwsoa.cjs} +22 -2
- package/dist/{workspace-Bp8FEkF-.cjs.map → workspace-4i6Jwsoa.cjs.map} +1 -1
- package/dist/{workspace-BBdqmkch.mjs → workspace-DD9mtPy8.mjs} +11 -3
- package/dist/{workspace-BBdqmkch.mjs.map → workspace-DD9mtPy8.mjs.map} +1 -1
- package/package.json +15 -15
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { A as UndeclaredStage } from "./workspace-DD9mtPy8.mjs";
|
|
2
|
+
import { loadWorkspaceSettings } from "./config.mjs";
|
|
3
|
+
import { appendFile } from "node:fs/promises";
|
|
4
|
+
//#region src/stages/plan.ts
|
|
5
|
+
/**
|
|
6
|
+
* Which stages a workflow run builds and deploys, from the event that started
|
|
7
|
+
* it and the project's `stages`.
|
|
8
|
+
*
|
|
9
|
+
* The rules live here, in tested code, rather than in a workflow's YAML or in
|
|
10
|
+
* the action that runs `gkm stages --github-output`: a project's deploy
|
|
11
|
+
* workflow names no stage, and what it does for each event is decided by the
|
|
12
|
+
* CLI the project installed.
|
|
13
|
+
*
|
|
14
|
+
* | event | build | deploy |
|
|
15
|
+
* | ------------------- | ------------------ | ------------------------------- |
|
|
16
|
+
* | `push` | every deployed | deployed, less the protected |
|
|
17
|
+
* | `release` | none | the protected |
|
|
18
|
+
* | `workflow_dispatch` | none | the one stage named |
|
|
19
|
+
* | anything else | none | none |
|
|
20
|
+
*
|
|
21
|
+
* A push builds every deployed stage, protected ones included, so a release
|
|
22
|
+
* deploys images built from the very commit its tag names; a release and a
|
|
23
|
+
* manual run deploy what a push already built.
|
|
24
|
+
*/
|
|
25
|
+
function planStages(stages, input) {
|
|
26
|
+
const kept = stages.protected ?? [];
|
|
27
|
+
switch (input.event) {
|
|
28
|
+
case "push": return {
|
|
29
|
+
build: [...stages.deployed],
|
|
30
|
+
deploy: stages.deployed.filter((stage) => !kept.includes(stage))
|
|
31
|
+
};
|
|
32
|
+
case "release": return {
|
|
33
|
+
build: [],
|
|
34
|
+
deploy: [...kept]
|
|
35
|
+
};
|
|
36
|
+
case "workflow_dispatch": {
|
|
37
|
+
const stage = input.stage?.trim();
|
|
38
|
+
if (!stage) throw new DispatchNamesNoStage(stages.deployed);
|
|
39
|
+
if (!stages.deployed.includes(stage)) throw new UndeclaredStage(stage, stages.deployed);
|
|
40
|
+
return {
|
|
41
|
+
build: [],
|
|
42
|
+
deploy: [stage]
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
default: return {
|
|
46
|
+
build: [],
|
|
47
|
+
deploy: []
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A manual run with no stage. Refused rather than read as "nothing to do", so
|
|
53
|
+
* a run started with the field left empty fails where it can be seen.
|
|
54
|
+
*/
|
|
55
|
+
var DispatchNamesNoStage = class extends Error {
|
|
56
|
+
deployed;
|
|
57
|
+
constructor(deployed) {
|
|
58
|
+
super(`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"}.`);
|
|
59
|
+
this.deployed = deployed;
|
|
60
|
+
this.name = "DispatchNamesNoStage";
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/stages/index.ts
|
|
65
|
+
/**
|
|
66
|
+
* `gkm stages` — the workspace's stages, as gkm.config.ts declares them.
|
|
67
|
+
*
|
|
68
|
+
* ```bash
|
|
69
|
+
* gkm stages # a table
|
|
70
|
+
* gkm stages --json # {"local":"dev","deployed":["prod"],"protected":["prod"]}
|
|
71
|
+
* gkm stages --github-output # a workflow run's build and deploy matrices
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* The config is read by the normal loader (and sandbox), so a workflow never
|
|
75
|
+
* parses TypeScript to learn which stages exist. `--github-output` is what the
|
|
76
|
+
* `geekmidas/toolbox/actions/stages` action runs: it writes the stages, and
|
|
77
|
+
* which of them this run builds and deploys, to `$GITHUB_OUTPUT`.
|
|
78
|
+
*/
|
|
79
|
+
function stagesJson(stages) {
|
|
80
|
+
return {
|
|
81
|
+
local: stages.local,
|
|
82
|
+
deployed: [...stages.deployed],
|
|
83
|
+
protected: [...stages.protected ?? []]
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The region of the workspace's AWS secrets store — `ssm` or
|
|
88
|
+
* `secrets-manager` — or `''` when its deployed stages keep their secrets
|
|
89
|
+
* anywhere else. A job assumes the stage's AWS role only when this is set.
|
|
90
|
+
*/
|
|
91
|
+
function awsSecretsRegion(workspace) {
|
|
92
|
+
const store = workspace.secrets?.store;
|
|
93
|
+
if (typeof store !== "object" || store === null) return "";
|
|
94
|
+
if (store.provider === "ssm" || store.provider === "secrets-manager") return store.region;
|
|
95
|
+
return "";
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Every output the stages action sets, each a string `fromJSON()` reads, for
|
|
99
|
+
* one workflow run.
|
|
100
|
+
*/
|
|
101
|
+
function githubOutputs(workspace, input) {
|
|
102
|
+
const stages = stagesJson(workspace.stages);
|
|
103
|
+
const plan = planStages(workspace.stages, input);
|
|
104
|
+
return {
|
|
105
|
+
local: JSON.stringify(stages.local),
|
|
106
|
+
deployed: JSON.stringify(stages.deployed),
|
|
107
|
+
protected: JSON.stringify(stages.protected),
|
|
108
|
+
build: JSON.stringify(plan.build),
|
|
109
|
+
deploy: JSON.stringify(plan.deploy),
|
|
110
|
+
"has-build": String(plan.build.length > 0),
|
|
111
|
+
"has-deploy": String(plan.deploy.length > 0),
|
|
112
|
+
"aws-region": awsSecretsRegion(workspace)
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/** `name=value` lines, as `$GITHUB_OUTPUT` takes single-line values. */
|
|
116
|
+
function formatGithubOutputs(outputs) {
|
|
117
|
+
return Object.entries(outputs).map(([name, value]) => `${name}=${value}\n`).join("");
|
|
118
|
+
}
|
|
119
|
+
/** A message as a workflow command's data: GitHub reads `%`, CR and LF escaped. */
|
|
120
|
+
function workflowCommandData(message) {
|
|
121
|
+
return message.replaceAll("%", "%25").replaceAll("\r", "%0D").replaceAll("\n", "%0A");
|
|
122
|
+
}
|
|
123
|
+
function table(stages) {
|
|
124
|
+
const rows = [
|
|
125
|
+
["STAGE", "KIND"],
|
|
126
|
+
[stages.local, "local"],
|
|
127
|
+
...stages.deployed.map((name) => [name, stages.protected.includes(name) ? "deployed, protected" : "deployed"])
|
|
128
|
+
];
|
|
129
|
+
const width = Math.max(...rows.map(([name]) => name.length));
|
|
130
|
+
return rows.map(([name, kind]) => `${name.padEnd(width)} ${kind}`).join("\n");
|
|
131
|
+
}
|
|
132
|
+
async function stagesCommand(options, deps = {}) {
|
|
133
|
+
const env = deps.env ?? process.env;
|
|
134
|
+
const log = deps.log ?? ((line) => console.log(line));
|
|
135
|
+
if (!options.githubOutput) {
|
|
136
|
+
const stages = stagesJson((await loadWorkspaceSettings(deps.cwd)).stages);
|
|
137
|
+
log(options.json ? JSON.stringify(stages) : table(stages));
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
try {
|
|
141
|
+
const file = env.GITHUB_OUTPUT;
|
|
142
|
+
if (!file) throw new GithubOutputNotSet();
|
|
143
|
+
const workspace = await loadWorkspaceSettings(deps.cwd);
|
|
144
|
+
const event = options.event || env.GITHUB_EVENT_NAME;
|
|
145
|
+
if (!event) throw new GithubEventNotSet();
|
|
146
|
+
const outputs = githubOutputs(workspace, {
|
|
147
|
+
event,
|
|
148
|
+
...options.stage ? { stage: options.stage } : {}
|
|
149
|
+
});
|
|
150
|
+
await appendFile(file, formatGithubOutputs(outputs));
|
|
151
|
+
log(`${event}: build ${outputs.build}, deploy ${outputs.deploy}`);
|
|
152
|
+
} catch (error) {
|
|
153
|
+
log(`::error title=gkm stages::${workflowCommandData(error instanceof Error ? error.message : String(error))}`);
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/** `--github-output` outside a GitHub Actions step, which sets the file. */
|
|
158
|
+
var GithubOutputNotSet = class extends Error {
|
|
159
|
+
constructor() {
|
|
160
|
+
super("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.");
|
|
161
|
+
this.name = "GithubOutputNotSet";
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
/** No `--event`, and no `GITHUB_EVENT_NAME` to take it from. */
|
|
165
|
+
var GithubEventNotSet = class extends Error {
|
|
166
|
+
constructor() {
|
|
167
|
+
super("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.");
|
|
168
|
+
this.name = "GithubEventNotSet";
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
//#endregion
|
|
172
|
+
export { stagesCommand };
|
|
173
|
+
|
|
174
|
+
//# sourceMappingURL=stages-CHF9RFog.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stages-CHF9RFog.mjs","names":[],"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 { 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 Error {\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 { loadWorkspaceSettings } from '../config.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 * 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};\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 Error {\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 Error {\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":";;;;;;;;;;;;;;;;;;;;;;;;AAsCA,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,IAAI,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,cAA0C,MAAM;CAC1B;CAArB,YAAY,UAAsC;EACjD,MACC,wGAAwG,SAAS,KAAK,IAAI,KAAK,kDA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,oKACD;EACA,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,oBAAb,cAAuC,MAAM;CAC5C,cAAc;EACb,MACC,uLACD;EACA,KAAK,OAAO;CACb;AACD"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
const require_workspace = require("./workspace-4i6Jwsoa.cjs");
|
|
2
|
+
const require_config = require("./config.cjs");
|
|
3
|
+
let node_fs_promises = require("node:fs/promises");
|
|
4
|
+
//#region src/stages/plan.ts
|
|
5
|
+
/**
|
|
6
|
+
* Which stages a workflow run builds and deploys, from the event that started
|
|
7
|
+
* it and the project's `stages`.
|
|
8
|
+
*
|
|
9
|
+
* The rules live here, in tested code, rather than in a workflow's YAML or in
|
|
10
|
+
* the action that runs `gkm stages --github-output`: a project's deploy
|
|
11
|
+
* workflow names no stage, and what it does for each event is decided by the
|
|
12
|
+
* CLI the project installed.
|
|
13
|
+
*
|
|
14
|
+
* | event | build | deploy |
|
|
15
|
+
* | ------------------- | ------------------ | ------------------------------- |
|
|
16
|
+
* | `push` | every deployed | deployed, less the protected |
|
|
17
|
+
* | `release` | none | the protected |
|
|
18
|
+
* | `workflow_dispatch` | none | the one stage named |
|
|
19
|
+
* | anything else | none | none |
|
|
20
|
+
*
|
|
21
|
+
* A push builds every deployed stage, protected ones included, so a release
|
|
22
|
+
* deploys images built from the very commit its tag names; a release and a
|
|
23
|
+
* manual run deploy what a push already built.
|
|
24
|
+
*/
|
|
25
|
+
function planStages(stages, input) {
|
|
26
|
+
const kept = stages.protected ?? [];
|
|
27
|
+
switch (input.event) {
|
|
28
|
+
case "push": return {
|
|
29
|
+
build: [...stages.deployed],
|
|
30
|
+
deploy: stages.deployed.filter((stage) => !kept.includes(stage))
|
|
31
|
+
};
|
|
32
|
+
case "release": return {
|
|
33
|
+
build: [],
|
|
34
|
+
deploy: [...kept]
|
|
35
|
+
};
|
|
36
|
+
case "workflow_dispatch": {
|
|
37
|
+
const stage = input.stage?.trim();
|
|
38
|
+
if (!stage) throw new DispatchNamesNoStage(stages.deployed);
|
|
39
|
+
if (!stages.deployed.includes(stage)) throw new require_workspace.UndeclaredStage(stage, stages.deployed);
|
|
40
|
+
return {
|
|
41
|
+
build: [],
|
|
42
|
+
deploy: [stage]
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
default: return {
|
|
46
|
+
build: [],
|
|
47
|
+
deploy: []
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A manual run with no stage. Refused rather than read as "nothing to do", so
|
|
53
|
+
* a run started with the field left empty fails where it can be seen.
|
|
54
|
+
*/
|
|
55
|
+
var DispatchNamesNoStage = class extends Error {
|
|
56
|
+
deployed;
|
|
57
|
+
constructor(deployed) {
|
|
58
|
+
super(`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"}.`);
|
|
59
|
+
this.deployed = deployed;
|
|
60
|
+
this.name = "DispatchNamesNoStage";
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/stages/index.ts
|
|
65
|
+
/**
|
|
66
|
+
* `gkm stages` — the workspace's stages, as gkm.config.ts declares them.
|
|
67
|
+
*
|
|
68
|
+
* ```bash
|
|
69
|
+
* gkm stages # a table
|
|
70
|
+
* gkm stages --json # {"local":"dev","deployed":["prod"],"protected":["prod"]}
|
|
71
|
+
* gkm stages --github-output # a workflow run's build and deploy matrices
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* The config is read by the normal loader (and sandbox), so a workflow never
|
|
75
|
+
* parses TypeScript to learn which stages exist. `--github-output` is what the
|
|
76
|
+
* `geekmidas/toolbox/actions/stages` action runs: it writes the stages, and
|
|
77
|
+
* which of them this run builds and deploys, to `$GITHUB_OUTPUT`.
|
|
78
|
+
*/
|
|
79
|
+
function stagesJson(stages) {
|
|
80
|
+
return {
|
|
81
|
+
local: stages.local,
|
|
82
|
+
deployed: [...stages.deployed],
|
|
83
|
+
protected: [...stages.protected ?? []]
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The region of the workspace's AWS secrets store — `ssm` or
|
|
88
|
+
* `secrets-manager` — or `''` when its deployed stages keep their secrets
|
|
89
|
+
* anywhere else. A job assumes the stage's AWS role only when this is set.
|
|
90
|
+
*/
|
|
91
|
+
function awsSecretsRegion(workspace) {
|
|
92
|
+
const store = workspace.secrets?.store;
|
|
93
|
+
if (typeof store !== "object" || store === null) return "";
|
|
94
|
+
if (store.provider === "ssm" || store.provider === "secrets-manager") return store.region;
|
|
95
|
+
return "";
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Every output the stages action sets, each a string `fromJSON()` reads, for
|
|
99
|
+
* one workflow run.
|
|
100
|
+
*/
|
|
101
|
+
function githubOutputs(workspace, input) {
|
|
102
|
+
const stages = stagesJson(workspace.stages);
|
|
103
|
+
const plan = planStages(workspace.stages, input);
|
|
104
|
+
return {
|
|
105
|
+
local: JSON.stringify(stages.local),
|
|
106
|
+
deployed: JSON.stringify(stages.deployed),
|
|
107
|
+
protected: JSON.stringify(stages.protected),
|
|
108
|
+
build: JSON.stringify(plan.build),
|
|
109
|
+
deploy: JSON.stringify(plan.deploy),
|
|
110
|
+
"has-build": String(plan.build.length > 0),
|
|
111
|
+
"has-deploy": String(plan.deploy.length > 0),
|
|
112
|
+
"aws-region": awsSecretsRegion(workspace)
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/** `name=value` lines, as `$GITHUB_OUTPUT` takes single-line values. */
|
|
116
|
+
function formatGithubOutputs(outputs) {
|
|
117
|
+
return Object.entries(outputs).map(([name, value]) => `${name}=${value}\n`).join("");
|
|
118
|
+
}
|
|
119
|
+
/** A message as a workflow command's data: GitHub reads `%`, CR and LF escaped. */
|
|
120
|
+
function workflowCommandData(message) {
|
|
121
|
+
return message.replaceAll("%", "%25").replaceAll("\r", "%0D").replaceAll("\n", "%0A");
|
|
122
|
+
}
|
|
123
|
+
function table(stages) {
|
|
124
|
+
const rows = [
|
|
125
|
+
["STAGE", "KIND"],
|
|
126
|
+
[stages.local, "local"],
|
|
127
|
+
...stages.deployed.map((name) => [name, stages.protected.includes(name) ? "deployed, protected" : "deployed"])
|
|
128
|
+
];
|
|
129
|
+
const width = Math.max(...rows.map(([name]) => name.length));
|
|
130
|
+
return rows.map(([name, kind]) => `${name.padEnd(width)} ${kind}`).join("\n");
|
|
131
|
+
}
|
|
132
|
+
async function stagesCommand(options, deps = {}) {
|
|
133
|
+
const env = deps.env ?? process.env;
|
|
134
|
+
const log = deps.log ?? ((line) => console.log(line));
|
|
135
|
+
if (!options.githubOutput) {
|
|
136
|
+
const stages = stagesJson((await require_config.loadWorkspaceSettings(deps.cwd)).stages);
|
|
137
|
+
log(options.json ? JSON.stringify(stages) : table(stages));
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
try {
|
|
141
|
+
const file = env.GITHUB_OUTPUT;
|
|
142
|
+
if (!file) throw new GithubOutputNotSet();
|
|
143
|
+
const workspace = await require_config.loadWorkspaceSettings(deps.cwd);
|
|
144
|
+
const event = options.event || env.GITHUB_EVENT_NAME;
|
|
145
|
+
if (!event) throw new GithubEventNotSet();
|
|
146
|
+
const outputs = githubOutputs(workspace, {
|
|
147
|
+
event,
|
|
148
|
+
...options.stage ? { stage: options.stage } : {}
|
|
149
|
+
});
|
|
150
|
+
await (0, node_fs_promises.appendFile)(file, formatGithubOutputs(outputs));
|
|
151
|
+
log(`${event}: build ${outputs.build}, deploy ${outputs.deploy}`);
|
|
152
|
+
} catch (error) {
|
|
153
|
+
log(`::error title=gkm stages::${workflowCommandData(error instanceof Error ? error.message : String(error))}`);
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/** `--github-output` outside a GitHub Actions step, which sets the file. */
|
|
158
|
+
var GithubOutputNotSet = class extends Error {
|
|
159
|
+
constructor() {
|
|
160
|
+
super("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.");
|
|
161
|
+
this.name = "GithubOutputNotSet";
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
/** No `--event`, and no `GITHUB_EVENT_NAME` to take it from. */
|
|
165
|
+
var GithubEventNotSet = class extends Error {
|
|
166
|
+
constructor() {
|
|
167
|
+
super("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.");
|
|
168
|
+
this.name = "GithubEventNotSet";
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
//#endregion
|
|
172
|
+
exports.stagesCommand = stagesCommand;
|
|
173
|
+
|
|
174
|
+
//# sourceMappingURL=stages-CwrYVX9u.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stages-CwrYVX9u.cjs","names":["UndeclaredStage","loadWorkspaceSettings","appendFile"],"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 { 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 Error {\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 { loadWorkspaceSettings } from '../config.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 * 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};\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 Error {\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 Error {\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":";;;;;;;;;;;;;;;;;;;;;;;;AAsCA,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,OAA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AAc,WAAW;GACxC;GACA,GAAI,QAAQ,QAAQ,EAAE,OAAO,QAAQ,MAAM,IAAI,CAAC;EACjD,CAAC;EACD,OAAA,GAAMC,iBAAAA,WAAAA,CAAW,MAAM,oBAAoB,OAAO,CAAC;EAEnD,IAAI,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,cAAwC,MAAM;CAC7C,cAAc;EACb,MACC,oKACD;EACA,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,oBAAb,cAAuC,MAAM;CAC5C,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-DzRz8FgH.cjs");
|
|
3
|
-
const require_resolve = require("../resolve-
|
|
3
|
+
const require_resolve = require("../resolve-DCTcD823.cjs");
|
|
4
4
|
const require_provider = require("../provider-C9_-45d5.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-DR8xGYfL.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-y1PkSZrF.mjs";
|
|
3
3
|
import { t as ProviderRemoved } from "../provider-q4lsYzYG.mjs";
|
|
4
4
|
export { DeployTargetNotYetSupported, InvalidTargetOptions, ProviderRemoved, TargetEntryInvalid, TargetPackageInvalid, TargetPackageNotFound, TargetRuntimeMismatch, TargetRuntimeUndeclared, UnknownDeployTarget, defineTarget, isDeployTarget };
|
package/dist/workspace/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_workspace = require("../workspace-
|
|
2
|
+
const require_workspace = require("../workspace-4i6Jwsoa.cjs");
|
|
3
3
|
exports.DokployRegistryMoved = require_workspace.DokployRegistryMoved;
|
|
4
|
+
exports.InvalidWorkspaceConfig = require_workspace.InvalidWorkspaceConfig;
|
|
4
5
|
exports.PHASE_2_DEPLOY_TARGETS = require_workspace.PHASE_2_DEPLOY_TARGETS;
|
|
5
6
|
exports.PUBLIC_ENV_PREFIXES = require_workspace.PUBLIC_ENV_PREFIXES;
|
|
6
7
|
exports.SUPPORTED_DEPLOY_TARGETS = require_workspace.SUPPORTED_DEPLOY_TARGETS;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { A as FrontendFramework, B as validateWorkspaceConfig, C as SecretsConfig, D as isWorkspaceConfig, E as WorkspaceInput, F as formatValidationErrors, I as getDeployTargetError, L as isDeployTargetSupported, M as PHASE_2_DEPLOY_TARGETS, N as SUPPORTED_DEPLOY_TARGETS, O as BackendFramework, P as WorkspaceConfigSchema, R as isPhase2DeployTarget, S as NormalizedWorkspace, T as WorkspaceConfig, _ as InferAppNames, b as ModelsConfig, c as AppInput, d as ComposeWorkspaceConfig, f as ConstrainedApps, g as DokployWorkspaceConfig, j as MobileFramework, l as AppsRecord, m as DeployTargetName, o as AppConfig, p as DeployConfig, s as AppConfigInput, u as ComposeLogsConfig, v as InferredWorkspaceConfig, w as SharedConfig, x as NormalizedAppConfig, y as LoadedConfig, z as safeValidateWorkspaceConfig } from "../types-DZtj9jeI.cjs";
|
|
2
|
-
import { a as
|
|
3
|
-
export { type AppConfig, type AppConfigInput, type AppInput, type AppsRecord, type BackendFramework, type ComposeLogsConfig, type ComposeWorkspaceConfig, type ConstrainedApps, type DeployConfig, type DeployTargetName, DokployRegistryMoved, type DokployWorkspaceConfig, type FrontendFramework, type InferAppNames, type InferredWorkspaceConfig, type LoadedConfig, type MobileFramework, type ModelsConfig, type NormalizedAppConfig, type NormalizedWorkspace, PHASE_2_DEPLOY_TARGETS, PUBLIC_ENV_PREFIXES, SUPPORTED_DEPLOY_TARGETS, type SecretsConfig, type SharedConfig, type WorkspaceConfig, WorkspaceConfigSchema, type WorkspaceInput, allConstructGlobs, appConstructGlobs, assertNoMovedDeployKeys, constructPatterns, defineWorkspace, formatValidationErrors, getAppBuildOrder, getAppGkmConfig, getDeployTargetError, getEndpointForStage, getPublicEnvPrefix, isDeployTargetSupported, isPhase2DeployTarget, isWorkspaceConfig, normalizeWorkspace, processConfig, safeValidateWorkspaceConfig, stripPublicPrefix, validateWorkspaceConfig, workspaceConstructGlobs, wrapSingleAppAsWorkspace };
|
|
2
|
+
import { _ as stripPublicPrefix, a as assertNoMovedDeployKeys, c as getAppBuildOrder, d as normalizeWorkspace, f as processConfig, g as getPublicEnvPrefix, h as PUBLIC_ENV_PREFIXES, i as appConstructGlobs, l as getAppGkmConfig, m as wrapSingleAppAsWorkspace, n as InvalidWorkspaceConfig, o as constructPatterns, p as workspaceConstructGlobs, r as allConstructGlobs, s as defineWorkspace, t as DokployRegistryMoved, u as getEndpointForStage } from "../index-DFrbhRwg.cjs";
|
|
3
|
+
export { type AppConfig, type AppConfigInput, type AppInput, type AppsRecord, type BackendFramework, type ComposeLogsConfig, type ComposeWorkspaceConfig, type ConstrainedApps, type DeployConfig, type DeployTargetName, DokployRegistryMoved, type DokployWorkspaceConfig, type FrontendFramework, type InferAppNames, type InferredWorkspaceConfig, InvalidWorkspaceConfig, type LoadedConfig, type MobileFramework, type ModelsConfig, type NormalizedAppConfig, type NormalizedWorkspace, PHASE_2_DEPLOY_TARGETS, PUBLIC_ENV_PREFIXES, SUPPORTED_DEPLOY_TARGETS, type SecretsConfig, type SharedConfig, type WorkspaceConfig, WorkspaceConfigSchema, type WorkspaceInput, allConstructGlobs, appConstructGlobs, assertNoMovedDeployKeys, constructPatterns, defineWorkspace, formatValidationErrors, getAppBuildOrder, getAppGkmConfig, getDeployTargetError, getEndpointForStage, getPublicEnvPrefix, isDeployTargetSupported, isPhase2DeployTarget, isWorkspaceConfig, normalizeWorkspace, processConfig, safeValidateWorkspaceConfig, stripPublicPrefix, validateWorkspaceConfig, workspaceConstructGlobs, wrapSingleAppAsWorkspace };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { A as FrontendFramework, B as validateWorkspaceConfig, C as SecretsConfig, D as isWorkspaceConfig, E as WorkspaceInput, F as formatValidationErrors, I as getDeployTargetError, L as isDeployTargetSupported, M as PHASE_2_DEPLOY_TARGETS, N as SUPPORTED_DEPLOY_TARGETS, O as BackendFramework, P as WorkspaceConfigSchema, R as isPhase2DeployTarget, S as NormalizedWorkspace, T as WorkspaceConfig, _ as InferAppNames, b as ModelsConfig, c as AppInput, d as ComposeWorkspaceConfig, f as ConstrainedApps, g as DokployWorkspaceConfig, j as MobileFramework, l as AppsRecord, m as DeployTargetName, o as AppConfig, p as DeployConfig, s as AppConfigInput, u as ComposeLogsConfig, v as InferredWorkspaceConfig, w as SharedConfig, x as NormalizedAppConfig, y as LoadedConfig, z as safeValidateWorkspaceConfig } from "../types-BzCavjGt.mjs";
|
|
2
|
-
import { a as
|
|
3
|
-
export { type AppConfig, type AppConfigInput, type AppInput, type AppsRecord, type BackendFramework, type ComposeLogsConfig, type ComposeWorkspaceConfig, type ConstrainedApps, type DeployConfig, type DeployTargetName, DokployRegistryMoved, type DokployWorkspaceConfig, type FrontendFramework, type InferAppNames, type InferredWorkspaceConfig, type LoadedConfig, type MobileFramework, type ModelsConfig, type NormalizedAppConfig, type NormalizedWorkspace, PHASE_2_DEPLOY_TARGETS, PUBLIC_ENV_PREFIXES, SUPPORTED_DEPLOY_TARGETS, type SecretsConfig, type SharedConfig, type WorkspaceConfig, WorkspaceConfigSchema, type WorkspaceInput, allConstructGlobs, appConstructGlobs, assertNoMovedDeployKeys, constructPatterns, defineWorkspace, formatValidationErrors, getAppBuildOrder, getAppGkmConfig, getDeployTargetError, getEndpointForStage, getPublicEnvPrefix, isDeployTargetSupported, isPhase2DeployTarget, isWorkspaceConfig, normalizeWorkspace, processConfig, safeValidateWorkspaceConfig, stripPublicPrefix, validateWorkspaceConfig, workspaceConstructGlobs, wrapSingleAppAsWorkspace };
|
|
2
|
+
import { _ as stripPublicPrefix, a as assertNoMovedDeployKeys, c as getAppBuildOrder, d as normalizeWorkspace, f as processConfig, g as getPublicEnvPrefix, h as PUBLIC_ENV_PREFIXES, i as appConstructGlobs, l as getAppGkmConfig, m as wrapSingleAppAsWorkspace, n as InvalidWorkspaceConfig, o as constructPatterns, p as workspaceConstructGlobs, r as allConstructGlobs, s as defineWorkspace, t as DokployRegistryMoved, u as getEndpointForStage } from "../index-Wuqpf316.mjs";
|
|
3
|
+
export { type AppConfig, type AppConfigInput, type AppInput, type AppsRecord, type BackendFramework, type ComposeLogsConfig, type ComposeWorkspaceConfig, type ConstrainedApps, type DeployConfig, type DeployTargetName, DokployRegistryMoved, type DokployWorkspaceConfig, type FrontendFramework, type InferAppNames, type InferredWorkspaceConfig, InvalidWorkspaceConfig, type LoadedConfig, type MobileFramework, type ModelsConfig, type NormalizedAppConfig, type NormalizedWorkspace, PHASE_2_DEPLOY_TARGETS, PUBLIC_ENV_PREFIXES, SUPPORTED_DEPLOY_TARGETS, type SecretsConfig, type SharedConfig, type WorkspaceConfig, WorkspaceConfigSchema, type WorkspaceInput, allConstructGlobs, appConstructGlobs, assertNoMovedDeployKeys, constructPatterns, defineWorkspace, formatValidationErrors, getAppBuildOrder, getAppGkmConfig, getDeployTargetError, getEndpointForStage, getPublicEnvPrefix, isDeployTargetSupported, isPhase2DeployTarget, isWorkspaceConfig, normalizeWorkspace, processConfig, safeValidateWorkspaceConfig, stripPublicPrefix, validateWorkspaceConfig, workspaceConstructGlobs, wrapSingleAppAsWorkspace };
|
package/dist/workspace/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
export { DokployRegistryMoved, 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 };
|
|
1
|
+
import { C as getDeployTargetError, D as validateWorkspaceConfig, E as safeValidateWorkspaceConfig, S as formatValidationErrors, T as isPhase2DeployTarget, _ as stripPublicPrefix, a as assertNoMovedDeployKeys, b as SUPPORTED_DEPLOY_TARGETS, c as getAppBuildOrder, d as normalizeWorkspace, f as processConfig, g as getPublicEnvPrefix, h as PUBLIC_ENV_PREFIXES, i as appConstructGlobs, l as getAppGkmConfig, m as wrapSingleAppAsWorkspace, n as InvalidWorkspaceConfig, o as constructPatterns, p as workspaceConstructGlobs, r as allConstructGlobs, s as defineWorkspace, t as DokployRegistryMoved, u as getEndpointForStage, v as isWorkspaceConfig, w as isDeployTargetSupported, x as WorkspaceConfigSchema, y as PHASE_2_DEPLOY_TARGETS } from "../workspace-DD9mtPy8.mjs";
|
|
2
|
+
export { DokployRegistryMoved, 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 };
|
|
@@ -1162,8 +1162,9 @@ function processConfig(config, cwd) {
|
|
|
1162
1162
|
assertNoMovedDeployKeys(config.deploy);
|
|
1163
1163
|
if (isWorkspaceConfig(config)) {
|
|
1164
1164
|
assertKnownSecretsStore(config.secrets?.store);
|
|
1165
|
+
if (config.stages === void 0) throw new InvalidStages(stageProblems(void 0));
|
|
1165
1166
|
const result = safeValidateWorkspaceConfig(config);
|
|
1166
|
-
if (!result.success && result.error) throw new
|
|
1167
|
+
if (!result.success && result.error) throw new InvalidWorkspaceConfig(formatValidationErrors(result.error));
|
|
1167
1168
|
return {
|
|
1168
1169
|
type: "workspace",
|
|
1169
1170
|
raw: config,
|
|
@@ -1176,6 +1177,13 @@ function processConfig(config, cwd) {
|
|
|
1176
1177
|
workspace: wrapSingleAppAsWorkspace(config, cwd)
|
|
1177
1178
|
};
|
|
1178
1179
|
}
|
|
1180
|
+
/** A workspace config the schema refuses; the message lists every issue. */
|
|
1181
|
+
var InvalidWorkspaceConfig = class extends Error {
|
|
1182
|
+
constructor(message) {
|
|
1183
|
+
super(message);
|
|
1184
|
+
this.name = "InvalidWorkspaceConfig";
|
|
1185
|
+
}
|
|
1186
|
+
};
|
|
1179
1187
|
/**
|
|
1180
1188
|
* The workspace's own constructs globs, absolute.
|
|
1181
1189
|
*
|
|
@@ -1306,6 +1314,12 @@ Object.defineProperty(exports, "InvalidStages", {
|
|
|
1306
1314
|
return InvalidStages;
|
|
1307
1315
|
}
|
|
1308
1316
|
});
|
|
1317
|
+
Object.defineProperty(exports, "InvalidWorkspaceConfig", {
|
|
1318
|
+
enumerable: true,
|
|
1319
|
+
get: function() {
|
|
1320
|
+
return InvalidWorkspaceConfig;
|
|
1321
|
+
}
|
|
1322
|
+
});
|
|
1309
1323
|
Object.defineProperty(exports, "LOGS_PORT", {
|
|
1310
1324
|
enumerable: true,
|
|
1311
1325
|
get: function() {
|
|
@@ -1342,6 +1356,12 @@ Object.defineProperty(exports, "TEST_STAGE", {
|
|
|
1342
1356
|
return TEST_STAGE;
|
|
1343
1357
|
}
|
|
1344
1358
|
});
|
|
1359
|
+
Object.defineProperty(exports, "UndeclaredStage", {
|
|
1360
|
+
enumerable: true,
|
|
1361
|
+
get: function() {
|
|
1362
|
+
return UndeclaredStage;
|
|
1363
|
+
}
|
|
1364
|
+
});
|
|
1345
1365
|
Object.defineProperty(exports, "UnknownSecretsStoreProvider", {
|
|
1346
1366
|
enumerable: true,
|
|
1347
1367
|
get: function() {
|
|
@@ -1517,4 +1537,4 @@ Object.defineProperty(exports, "wrapSingleAppAsWorkspace", {
|
|
|
1517
1537
|
}
|
|
1518
1538
|
});
|
|
1519
1539
|
|
|
1520
|
-
//# sourceMappingURL=workspace-
|
|
1540
|
+
//# sourceMappingURL=workspace-4i6Jwsoa.cjs.map
|