@geekmidas/cli 10.0.0-alpha.93 → 10.0.0-alpha.95
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-Mi3vptSR.mjs → GoDaddyProvider-BwW51hPm.mjs} +3 -3
- package/dist/{GoDaddyProvider-Mi3vptSR.mjs.map → GoDaddyProvider-BwW51hPm.mjs.map} +1 -1
- package/dist/{GoDaddyProvider-BZb-V14e.cjs → GoDaddyProvider-C_DgIkMv.cjs} +3 -3
- package/dist/{GoDaddyProvider-BZb-V14e.cjs.map → GoDaddyProvider-C_DgIkMv.cjs.map} +1 -1
- package/dist/{HostingerProvider-1mqD6aG8.mjs → HostingerProvider-BNpS9aRJ.mjs} +9 -4
- package/dist/{HostingerProvider-1mqD6aG8.mjs.map → HostingerProvider-BNpS9aRJ.mjs.map} +1 -1
- package/dist/{HostingerProvider-C6t-PSNe.cjs → HostingerProvider-DR1iws1P.cjs} +9 -4
- package/dist/HostingerProvider-DR1iws1P.cjs.map +1 -0
- package/dist/{LegacyStateStore-BlYXQQSE.cjs → LegacyStateStore-BawjE_5n.cjs} +10 -9
- package/dist/{LegacyStateStore-BlYXQQSE.cjs.map → LegacyStateStore-BawjE_5n.cjs.map} +1 -1
- package/dist/{LegacyStateStore-CtwO7fwy.mjs → LegacyStateStore-D5DarNA2.mjs} +3 -2
- package/dist/{LegacyStateStore-CtwO7fwy.mjs.map → LegacyStateStore-D5DarNA2.mjs.map} +1 -1
- package/dist/{LocalStateStore-oX_zxj9V.cjs → LocalStateStore-D8fu5WiF.cjs} +8 -8
- package/dist/{LocalStateStore-oX_zxj9V.cjs.map → LocalStateStore-D8fu5WiF.cjs.map} +1 -1
- package/dist/{LocalStateStore-D40_SDmJ.mjs → LocalStateStore-YjIqlgAz.mjs} +2 -2
- package/dist/{LocalStateStore-D40_SDmJ.mjs.map → LocalStateStore-YjIqlgAz.mjs.map} +1 -1
- package/dist/{S3StateStore-BzS0IeSt.mjs → S3StateStore-CjTAVsWh.mjs} +2 -2
- package/dist/{S3StateStore-BzS0IeSt.mjs.map → S3StateStore-CjTAVsWh.mjs.map} +1 -1
- package/dist/{S3StateStore-DeI7jtvi.cjs → S3StateStore-Cm-v2IPI.cjs} +5 -5
- package/dist/{S3StateStore-DeI7jtvi.cjs.map → S3StateStore-Cm-v2IPI.cjs.map} +1 -1
- package/dist/{SSMStateStore-CaCtrzFL.cjs → SSMStateStore-BS4BiZCN.cjs} +9 -9
- package/dist/{SSMStateStore-CaCtrzFL.cjs.map → SSMStateStore-BS4BiZCN.cjs.map} +1 -1
- package/dist/{SSMStateStore-k_Ew7TWx.mjs → SSMStateStore-BhtM6jOh.mjs} +2 -2
- package/dist/{SSMStateStore-k_Ew7TWx.mjs.map → SSMStateStore-BhtM6jOh.mjs.map} +1 -1
- package/dist/{add-VcyJnsPX.cjs → add-D-3IKT7W.cjs} +24 -53
- package/dist/add-D-3IKT7W.cjs.map +1 -0
- package/dist/{add-CP1podDH.mjs → add-ylx8dejw.mjs} +23 -52
- package/dist/add-ylx8dejw.mjs.map +1 -0
- package/dist/{bundler-Dfsr6KXU.cjs → bundler-CI3elfZS.cjs} +5 -5
- package/dist/{bundler-Dfsr6KXU.cjs.map → bundler-CI3elfZS.cjs.map} +1 -1
- package/dist/{bundler-BWrh-AJH.mjs → bundler-ywR3C1B_.mjs} +5 -5
- package/dist/{bundler-BWrh-AJH.mjs.map → bundler-ywR3C1B_.mjs.map} +1 -1
- package/dist/{cli-B8otnZfX.mjs → cli-BCSuCfQk.mjs} +9 -5
- package/dist/cli-BCSuCfQk.mjs.map +1 -0
- package/dist/{cli-DL19w4OE.cjs → cli-Dewt2T21.cjs} +9 -5
- package/dist/cli-Dewt2T21.cjs.map +1 -0
- package/dist/{compose-DrEB_4F-.mjs → compose-C4js1JDv.mjs} +82 -47
- package/dist/compose-C4js1JDv.mjs.map +1 -0
- package/dist/{compose-BHVKLluX.cjs → compose-Dd0XphvF.cjs} +94 -59
- package/dist/compose-Dd0XphvF.cjs.map +1 -0
- package/dist/{config-DCCcrOSo.d.cts → config-4yirvxS8.d.cts} +4 -4
- package/dist/{config-CHX5GOo3.d.mts.map → config-4yirvxS8.d.cts.map} +1 -1
- package/dist/{config-CHX5GOo3.d.mts → config-C8NPCn1l.d.mts} +4 -4
- package/dist/{config-DCCcrOSo.d.cts.map → config-C8NPCn1l.d.mts.map} +1 -1
- package/dist/config.cjs +1 -1
- package/dist/config.d.cts +3 -3
- package/dist/config.d.mts +3 -3
- package/dist/config.mjs +1 -1
- package/dist/{credentials-C4KII3PD.mjs → credentials-B5N5yKk6.mjs} +12 -134
- package/dist/credentials-B5N5yKk6.mjs.map +1 -0
- package/dist/{credentials-QBu7VgaQ.cjs → credentials-Zqr3QQYB.cjs} +11 -175
- package/dist/credentials-Zqr3QQYB.cjs.map +1 -0
- package/dist/deploy/public.cjs +19 -18
- package/dist/deploy/public.cjs.map +1 -1
- package/dist/deploy/public.d.cts +24 -9
- package/dist/deploy/public.d.cts.map +1 -1
- package/dist/deploy/public.d.mts +24 -9
- package/dist/deploy/public.d.mts.map +1 -1
- package/dist/deploy/public.mjs +11 -10
- package/dist/deploy/public.mjs.map +1 -1
- package/dist/deploy-B0drCD6s.mjs +1854 -0
- package/dist/deploy-B0drCD6s.mjs.map +1 -0
- package/dist/deploy-Bw1FjX_x.cjs +1903 -0
- package/dist/deploy-Bw1FjX_x.cjs.map +1 -0
- package/dist/{discover-vk2r5giK.d.cts → discover-BtFofyQB.d.cts} +2 -2
- package/dist/{discover-DqwlBVyY.d.mts.map → discover-BtFofyQB.d.cts.map} +1 -1
- package/dist/{discover-DqwlBVyY.d.mts → discover-D-MdXZgm.d.mts} +2 -2
- package/dist/{discover-vk2r5giK.d.cts.map → discover-D-MdXZgm.d.mts.map} +1 -1
- package/dist/dns-Bmk7P9c2.cjs +663 -0
- package/dist/dns-Bmk7P9c2.cjs.map +1 -0
- package/dist/dns-CyMIq6to.cjs +55 -0
- package/dist/dns-CyMIq6to.cjs.map +1 -0
- package/dist/dns-X3oqEV4C.mjs +44 -0
- package/dist/dns-X3oqEV4C.mjs.map +1 -0
- package/dist/dns-idXfyCay.mjs +610 -0
- package/dist/dns-idXfyCay.mjs.map +1 -0
- package/dist/{dokploy-o4I6vb9W.mjs → dokploy-CZYxXeMa.mjs} +2 -2
- package/dist/{dokploy-o4I6vb9W.mjs.map → dokploy-CZYxXeMa.mjs.map} +1 -1
- package/dist/{dokploy-rivb1RFt.cjs → dokploy-DaT0mgLU.cjs} +2 -2
- package/dist/{dokploy-rivb1RFt.cjs.map → dokploy-DaT0mgLU.cjs.map} +1 -1
- package/dist/{encryption-B6ilrT7p.mjs → encryption-D0ucY4O7.mjs} +3 -3
- package/dist/{encryption-B6ilrT7p.mjs.map → encryption-D0ucY4O7.mjs.map} +1 -1
- package/dist/{encryption-D7zmwzWz.cjs → encryption-Dp0IvLVX.cjs} +3 -3
- package/dist/{encryption-D7zmwzWz.cjs.map → encryption-Dp0IvLVX.cjs.map} +1 -1
- package/dist/{engine-DjEcovm-.mjs → engine-BcuhnyQO.mjs} +14 -31
- package/dist/{engine-DjEcovm-.mjs.map → engine-BcuhnyQO.mjs.map} +1 -1
- package/dist/{engine-Cfx8fEZU.cjs → engine-WY6j_kvA.cjs} +18 -35
- package/dist/engine-WY6j_kvA.cjs.map +1 -0
- package/dist/{github-CzBbs43W.mjs → github-DUGA57du.mjs} +96 -6
- package/dist/github-DUGA57du.mjs.map +1 -0
- package/dist/{github-zneTMvnO.cjs → github-DgmW83OP.cjs} +96 -6
- package/dist/github-DgmW83OP.cjs.map +1 -0
- package/dist/{index-BiYU7cUl.d.mts → index-5eL8rM6H.d.mts} +2 -2
- package/dist/{index-BiYU7cUl.d.mts.map → index-5eL8rM6H.d.mts.map} +1 -1
- package/dist/{index-Dm6V9bwh.d.cts → index-Dz-gyjm_.d.cts} +2 -2
- package/dist/{index-Dm6V9bwh.d.cts.map → index-Dz-gyjm_.d.cts.map} +1 -1
- package/dist/index.cjs +150 -118
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +144 -112
- package/dist/index.mjs.map +1 -1
- package/dist/{local-Otp74ak0.mjs → local-BwC2v2Y8.mjs} +2 -2
- package/dist/{local-Otp74ak0.mjs.map → local-BwC2v2Y8.mjs.map} +1 -1
- package/dist/{local-B61kUh0w.cjs → local-DNhnkugT.cjs} +3 -3
- package/dist/{local-B61kUh0w.cjs.map → local-DNhnkugT.cjs.map} +1 -1
- package/dist/{migrate-DFjbGnSr.cjs → migrate-BBcG1dhS.cjs} +3 -3
- package/dist/{migrate-DFjbGnSr.cjs.map → migrate-BBcG1dhS.cjs.map} +1 -1
- package/dist/{migrate-CsBZKALY.mjs → migrate-CZ-v5WV0.mjs} +3 -3
- package/dist/{migrate-CsBZKALY.mjs.map → migrate-CZ-v5WV0.mjs.map} +1 -1
- package/dist/{migrate-BaC4w0sb.mjs → migrate-D6PlNv2o.mjs} +3 -3
- package/dist/{migrate-BaC4w0sb.mjs.map → migrate-D6PlNv2o.mjs.map} +1 -1
- package/dist/{migrate-C8wTpakT.cjs → migrate-afgRL3Hg.cjs} +3 -3
- package/dist/{migrate-C8wTpakT.cjs.map → migrate-afgRL3Hg.cjs.map} +1 -1
- package/dist/openapi.cjs +1 -1
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.mjs +1 -1
- package/dist/reconcile/public.d.cts +2 -2
- package/dist/reconcile/public.d.mts +2 -2
- package/dist/{resolve-g8htuR80.cjs → resolve-CFb4Navi.cjs} +4 -4
- package/dist/{resolve-g8htuR80.cjs.map → resolve-CFb4Navi.cjs.map} +1 -1
- package/dist/{resolve-Ccjlpnd9.mjs → resolve-DakDhr6Z.mjs} +4 -4
- package/dist/{resolve-Ccjlpnd9.mjs.map → resolve-DakDhr6Z.mjs.map} +1 -1
- package/dist/{rollback--ympG9ss.cjs → rollback-B-1dPP0m.cjs} +9 -8
- package/dist/{rollback--ympG9ss.cjs.map → rollback-B-1dPP0m.cjs.map} +1 -1
- package/dist/{rollback-Drbg0OeR.mjs → rollback-B1TIpjdE.mjs} +7 -6
- package/dist/{rollback-Drbg0OeR.mjs.map → rollback-B1TIpjdE.mjs.map} +1 -1
- package/dist/run-BJLIerMM.mjs +133 -0
- package/dist/run-BJLIerMM.mjs.map +1 -0
- package/dist/run-fVZ-rLnc.cjs +174 -0
- package/dist/run-fVZ-rLnc.cjs.map +1 -0
- package/dist/{runtime-_wEVtshH.d.mts → runtime-DUQdM-mW.d.cts} +2 -2
- package/dist/{runtime-D_J3ExJn.d.cts.map → runtime-DUQdM-mW.d.cts.map} +1 -1
- package/dist/{runtime-D_J3ExJn.d.cts → runtime-Vr6mleo2.d.mts} +2 -2
- package/dist/{runtime-_wEVtshH.d.mts.map → runtime-Vr6mleo2.d.mts.map} +1 -1
- package/dist/{sandbox-CPJq1Kia.d.mts → sandbox-BbJmh2rI.d.cts} +2 -2
- package/dist/{sandbox-CPJq1Kia.d.mts.map → sandbox-BbJmh2rI.d.cts.map} +1 -1
- package/dist/{sandbox-JwuPAl7I.d.cts → sandbox-DGOsMPMf.d.mts} +2 -2
- package/dist/{sandbox-JwuPAl7I.d.cts.map → sandbox-DGOsMPMf.d.mts.map} +1 -1
- package/dist/{secrets-DJteijZo.cjs → secrets-CPM0Qffe.cjs} +3 -3
- package/dist/secrets-CPM0Qffe.cjs.map +1 -0
- package/dist/{secrets-DbPmAS4k.mjs → secrets-oI9ClAPR.mjs} +3 -3
- package/dist/secrets-oI9ClAPR.mjs.map +1 -0
- package/dist/{seeds-c-ByX9je.cjs → seeds-CnXkgKUv.cjs} +1339 -3594
- package/dist/seeds-CnXkgKUv.cjs.map +1 -0
- package/dist/{seeds-BSL55F6q.mjs → seeds-CoKkrSny.mjs} +1126 -3266
- package/dist/seeds-CoKkrSny.mjs.map +1 -0
- package/dist/{sniffer-BTtGAtm3.mjs → sniffer-CFRzIrby.mjs} +496 -5
- package/dist/sniffer-CFRzIrby.mjs.map +1 -0
- package/dist/{sniffer-Dq5BS98f.cjs → sniffer-vbiQ2Isn.cjs} +572 -3
- package/dist/sniffer-vbiQ2Isn.cjs.map +1 -0
- package/dist/{sst-BaRXp2Dd.mjs → sst-CGdjHn2A.mjs} +4 -3
- package/dist/{sst-BaRXp2Dd.mjs.map → sst-CGdjHn2A.mjs.map} +1 -1
- package/dist/{sst-CnKY-CSh.cjs → sst-DGuHDxVU.cjs} +5 -4
- package/dist/{sst-CnKY-CSh.cjs.map → sst-DGuHDxVU.cjs.map} +1 -1
- package/dist/{stack-1PeLJS2j.cjs → stack-1g57OfOw.cjs} +14 -52
- package/dist/stack-1g57OfOw.cjs.map +1 -0
- package/dist/{stack-Co4uZkAo.mjs → stack-B7O975TR.mjs} +14 -52
- package/dist/stack-B7O975TR.mjs.map +1 -0
- package/dist/{stages-DY-fQKmo.mjs → stages-Bt4OggMm.mjs} +17 -3
- package/dist/stages-Bt4OggMm.mjs.map +1 -0
- package/dist/{stages-BI8JvPzI.cjs → stages-BujUB4we.cjs} +17 -3
- package/dist/stages-BujUB4we.cjs.map +1 -0
- package/dist/target/public.cjs +1 -1
- package/dist/target/public.d.cts +2 -2
- package/dist/target/public.d.mts +2 -2
- package/dist/target/public.mjs +1 -1
- package/dist/{terminal-8XngdSTo.cjs → terminal-CPHuH4S1.cjs} +2 -2
- package/dist/{terminal-8XngdSTo.cjs.map → terminal-CPHuH4S1.cjs.map} +1 -1
- package/dist/{terminal-C4XRdwnU.mjs → terminal-iNmAXXjs.mjs} +2 -2
- package/dist/{terminal-C4XRdwnU.mjs.map → terminal-iNmAXXjs.mjs.map} +1 -1
- package/dist/{types-BibpiHKB.d.cts → types-bkqVscdN.d.mts} +43 -11
- package/dist/types-bkqVscdN.d.mts.map +1 -0
- package/dist/{types-B6lmD3en.d.mts → types-dipJRmKV.d.cts} +44 -10
- package/dist/types-dipJRmKV.d.cts.map +1 -0
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.d.cts +2 -2
- package/dist/workspace/index.d.mts +2 -2
- package/dist/workspace/index.mjs +1 -1
- package/dist/{workspace-Bzw7Zs82.mjs → workspace-DWK1PTXP.mjs} +4 -4
- package/dist/workspace-DWK1PTXP.mjs.map +1 -0
- package/dist/{workspace-CHOB2Xg3.cjs → workspace-cSyi5nb1.cjs} +4 -4
- package/dist/workspace-cSyi5nb1.cjs.map +1 -0
- package/package.json +15 -15
- package/dist/HostingerProvider-C6t-PSNe.cjs.map +0 -1
- package/dist/add-CP1podDH.mjs.map +0 -1
- package/dist/add-VcyJnsPX.cjs.map +0 -1
- package/dist/cli-B8otnZfX.mjs.map +0 -1
- package/dist/cli-DL19w4OE.cjs.map +0 -1
- package/dist/compose-BHVKLluX.cjs.map +0 -1
- package/dist/compose-DrEB_4F-.mjs.map +0 -1
- package/dist/credentials-C4KII3PD.mjs.map +0 -1
- package/dist/credentials-QBu7VgaQ.cjs.map +0 -1
- package/dist/deploy-C3Mhnmus.cjs +0 -556
- package/dist/deploy-C3Mhnmus.cjs.map +0 -1
- package/dist/deploy-DYIyIUYd.mjs +0 -527
- package/dist/deploy-DYIyIUYd.mjs.map +0 -1
- package/dist/engine-Cfx8fEZU.cjs.map +0 -1
- package/dist/github-CzBbs43W.mjs.map +0 -1
- package/dist/github-zneTMvnO.cjs.map +0 -1
- package/dist/secrets-DJteijZo.cjs.map +0 -1
- package/dist/secrets-DbPmAS4k.mjs.map +0 -1
- package/dist/seeds-BSL55F6q.mjs.map +0 -1
- package/dist/seeds-c-ByX9je.cjs.map +0 -1
- package/dist/sniffer-BTtGAtm3.mjs.map +0 -1
- package/dist/sniffer-Dq5BS98f.cjs.map +0 -1
- package/dist/stack-1PeLJS2j.cjs.map +0 -1
- package/dist/stack-Co4uZkAo.mjs.map +0 -1
- package/dist/stages-BI8JvPzI.cjs.map +0 -1
- package/dist/stages-DY-fQKmo.mjs.map +0 -1
- package/dist/types-B6lmD3en.d.mts.map +0 -1
- package/dist/types-BibpiHKB.d.cts.map +0 -1
- package/dist/workspace-Bzw7Zs82.mjs.map +0 -1
- package/dist/workspace-CHOB2Xg3.cjs.map +0 -1
|
@@ -0,0 +1,663 @@
|
|
|
1
|
+
const require_errors = require("./errors-DMC4Umsb.cjs");
|
|
2
|
+
const require_workspace = require("./workspace-cSyi5nb1.cjs");
|
|
3
|
+
const require_seeds = require("./seeds-CnXkgKUv.cjs");
|
|
4
|
+
let node_net = require("node:net");
|
|
5
|
+
let node_dns_promises = require("node:dns/promises");
|
|
6
|
+
//#region src/compose/dns.ts
|
|
7
|
+
/**
|
|
8
|
+
* A compose stage's DNS: the records its public hosts need, and the check that
|
|
9
|
+
* they resolve to its server before a certificate is asked for.
|
|
10
|
+
*
|
|
11
|
+
* - **The server** (`serverAddress`): the stage's own secrets hold its public
|
|
12
|
+
* addresses — `GKM_SERVER_IPV4`, and `GKM_SERVER_IPV6` where it has one.
|
|
13
|
+
* Reserved for gkm: never handed to an app.
|
|
14
|
+
* - **The plan** (`planStackDns`, pure): every public host the stack serves —
|
|
15
|
+
* its apex, each app, each file server, the public log UI — pointed at the
|
|
16
|
+
* server. An A record per host (and an AAAA with an IPv6 address), or, where
|
|
17
|
+
* the domain's `dns` entry says `records: { mode: 'cname', target }`, one A
|
|
18
|
+
* record for the target and a CNAME to it for every other host but the
|
|
19
|
+
* apex, which DNS forbids a CNAME at.
|
|
20
|
+
* - **Applying it** (`applyStackDns`): through the domain's provider in `dns`,
|
|
21
|
+
* a record set at a time. A record with the right value is left alone; one
|
|
22
|
+
* with another value is replaced and the change printed. A `manual` domain
|
|
23
|
+
* is printed and nothing else. A dry run reads, prints and writes nothing.
|
|
24
|
+
* - **The check** (`checkStackDns`): each host resolved with the system
|
|
25
|
+
* resolver. One that is not the server stops the deploy with
|
|
26
|
+
* {@link HostNotPointingAtServer}, before Caddy or Traefik ask Let's Encrypt
|
|
27
|
+
* for a certificate it cannot get — and use up the rate limit trying.
|
|
28
|
+
* - **The step** (`stageDns`): all three, as every deploy runs them — the plan applied through each provider,
|
|
29
|
+
* what was written read back from the provider, and only the hosts no
|
|
30
|
+
* provider wrote resolved publicly. A brand-new name is never looked up
|
|
31
|
+
* before its record exists, so no resolver caches it as missing.
|
|
32
|
+
*/
|
|
33
|
+
/** The line that says how to set the server's address. */
|
|
34
|
+
function serverAddressHint(stage) {
|
|
35
|
+
return `gkm secrets:set ${require_workspace.SERVER_IPV4_KEY} '<ip>' --stage ${stage}`;
|
|
36
|
+
}
|
|
37
|
+
/** A server address in the stage's secrets that is not an address. */
|
|
38
|
+
var ServerAddressInvalid = class extends require_errors.GkmError {
|
|
39
|
+
stage;
|
|
40
|
+
key;
|
|
41
|
+
value;
|
|
42
|
+
constructor(stage, key, value) {
|
|
43
|
+
const ipv4 = key === require_workspace.SERVER_IPV4_KEY;
|
|
44
|
+
super(`${key} in the '${stage}' stage's secrets is ${JSON.stringify(value)}, which is not an ${ipv4 ? "IPv4 address (like 203.0.113.10)" : "IPv6 address (like 2001:db8::10)"}. Set the server's public address: gkm secrets:set ${key} '<ip>' --stage ${stage}.`);
|
|
45
|
+
this.stage = stage;
|
|
46
|
+
this.key = key;
|
|
47
|
+
this.value = value;
|
|
48
|
+
this.name = "ServerAddressInvalid";
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* A compose stage that serves real domains with no server address: its hosts
|
|
53
|
+
* cannot be pointed or checked, and a certificate would be asked for blind.
|
|
54
|
+
*/
|
|
55
|
+
var ServerAddressMissing = class extends require_errors.GkmError {
|
|
56
|
+
stage;
|
|
57
|
+
domain;
|
|
58
|
+
constructor(stage, domain) {
|
|
59
|
+
super(`The '${stage}' stage serves ${domain} and its secrets hold no ${require_workspace.SERVER_IPV4_KEY} — the public address of the server its stack runs on, which its hosts' DNS records point at and every deploy checks before asking for certificates. Set it: ${serverAddressHint(stage)} (and ${require_workspace.SERVER_IPV6_KEY} for an IPv6 address).`);
|
|
60
|
+
this.stage = stage;
|
|
61
|
+
this.domain = domain;
|
|
62
|
+
this.name = "ServerAddressMissing";
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* The server's address from the stage's secrets, checked — `undefined` when
|
|
67
|
+
* `GKM_SERVER_IPV4` is not set.
|
|
68
|
+
*
|
|
69
|
+
* @throws {ServerAddressInvalid} for a value that is not an address
|
|
70
|
+
*/
|
|
71
|
+
function serverAddress(stage, custom) {
|
|
72
|
+
const ipv4 = custom?.[require_workspace.SERVER_IPV4_KEY]?.trim();
|
|
73
|
+
const ipv6 = custom?.[require_workspace.SERVER_IPV6_KEY]?.trim();
|
|
74
|
+
if (ipv6 && !(0, node_net.isIPv6)(ipv6)) throw new ServerAddressInvalid(stage, require_workspace.SERVER_IPV6_KEY, ipv6);
|
|
75
|
+
if (!ipv4) return void 0;
|
|
76
|
+
if (!(0, node_net.isIPv4)(ipv4)) throw new ServerAddressInvalid(stage, require_workspace.SERVER_IPV4_KEY, ipv4);
|
|
77
|
+
return {
|
|
78
|
+
ipv4,
|
|
79
|
+
...ipv6 ? { ipv6 } : {}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* A name that resolves to this machine by definition — `localhost` and every
|
|
84
|
+
* `*.localhost` — and is in nobody's DNS.
|
|
85
|
+
*/
|
|
86
|
+
function isLocalHost(host) {
|
|
87
|
+
const name = host.toLowerCase().replace(/\.$/, "");
|
|
88
|
+
return name === "localhost" || name.endsWith(".localhost");
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The server's address, required where the stage serves real domains — not
|
|
92
|
+
* `*.localhost` ones, which point at this machine already.
|
|
93
|
+
*
|
|
94
|
+
* @throws {ServerAddressMissing} when the stage has a domain and no address
|
|
95
|
+
* @throws {ServerAddressInvalid} for a value that is not an address
|
|
96
|
+
*/
|
|
97
|
+
function requiredServerAddress(stage, domain, custom) {
|
|
98
|
+
const server = serverAddress(stage, custom);
|
|
99
|
+
if (!server && domain && !isLocalHost(domain)) throw new ServerAddressMissing(stage, domain);
|
|
100
|
+
return server;
|
|
101
|
+
}
|
|
102
|
+
const MANAGED = [
|
|
103
|
+
"A",
|
|
104
|
+
"AAAA",
|
|
105
|
+
"CNAME"
|
|
106
|
+
];
|
|
107
|
+
/** Every public host the stack serves, once each, sorted. */
|
|
108
|
+
function stackHosts(stack) {
|
|
109
|
+
return [...new Set(stack.routes.map((route) => route.host))].sort();
|
|
110
|
+
}
|
|
111
|
+
/** The TTL a domain's records are written with. */
|
|
112
|
+
function recordTtl(config) {
|
|
113
|
+
const ttl = "ttl" in config ? config.ttl : void 0;
|
|
114
|
+
if (ttl) return ttl;
|
|
115
|
+
return config.provider === "godaddy" ? 600 : 300;
|
|
116
|
+
}
|
|
117
|
+
function providerName(config) {
|
|
118
|
+
return typeof config.provider === "string" ? config.provider : "custom";
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* A wildcard host: gkm writes one record per public host, so a stage on
|
|
122
|
+
* another server — or a name someone else points elsewhere — is never caught
|
|
123
|
+
* by a record it did not ask for.
|
|
124
|
+
*/
|
|
125
|
+
var DnsWildcardRefused = class extends require_errors.GkmError {
|
|
126
|
+
stage;
|
|
127
|
+
host;
|
|
128
|
+
constructor(stage, host) {
|
|
129
|
+
super(`'${stage}' would point ${host} at its server, and gkm never writes a wildcard record: each public host gets its own. Give the app a subdomain of its own instead.`);
|
|
130
|
+
this.stage = stage;
|
|
131
|
+
this.host = host;
|
|
132
|
+
this.name = "DnsWildcardRefused";
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
/** The records a stage's hosts need — pure. */
|
|
136
|
+
function planStackDns(input) {
|
|
137
|
+
const { stage, server } = input;
|
|
138
|
+
const dns = input.dns ? require_seeds.normalizeDnsConfig(input.dns) : {};
|
|
139
|
+
const records = /* @__PURE__ */ new Map();
|
|
140
|
+
const uncovered = [];
|
|
141
|
+
const add = (host, domain, type, value) => {
|
|
142
|
+
const name = require_seeds.extractSubdomain(host, domain);
|
|
143
|
+
records.set(`${domain} ${name} ${type}`, {
|
|
144
|
+
host,
|
|
145
|
+
domain,
|
|
146
|
+
name,
|
|
147
|
+
type,
|
|
148
|
+
value,
|
|
149
|
+
ttl: recordTtl(dns[domain])
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
const pointAt = (host, domain) => {
|
|
153
|
+
add(host, domain, "A", server.ipv4);
|
|
154
|
+
if (server.ipv6) add(host, domain, "AAAA", server.ipv6);
|
|
155
|
+
};
|
|
156
|
+
for (const raw of input.hosts) {
|
|
157
|
+
const host = raw.toLowerCase();
|
|
158
|
+
if (host.includes("*")) throw new DnsWildcardRefused(stage, host);
|
|
159
|
+
const domain = require_seeds.findRootDomain(host, dns);
|
|
160
|
+
if (!domain) {
|
|
161
|
+
uncovered.push(host);
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
const target = require_workspace.cnameTarget(dns[domain].records, stage);
|
|
165
|
+
if (target) pointAt(target, domain);
|
|
166
|
+
if (target && host !== domain && host !== target) add(host, domain, "CNAME", target);
|
|
167
|
+
else pointAt(host, domain);
|
|
168
|
+
}
|
|
169
|
+
const domains = /* @__PURE__ */ new Map();
|
|
170
|
+
for (const record of [...records.values()].sort((a, b) => a.domain.localeCompare(b.domain) || a.name.localeCompare(b.name) || a.type.localeCompare(b.type))) {
|
|
171
|
+
const config = dns[record.domain];
|
|
172
|
+
const plan = domains.get(record.domain) ?? {
|
|
173
|
+
domain: record.domain,
|
|
174
|
+
provider: providerName(config),
|
|
175
|
+
config,
|
|
176
|
+
records: []
|
|
177
|
+
};
|
|
178
|
+
plan.records.push(record);
|
|
179
|
+
domains.set(record.domain, plan);
|
|
180
|
+
}
|
|
181
|
+
return {
|
|
182
|
+
stage,
|
|
183
|
+
server,
|
|
184
|
+
domains: [...domains.values()],
|
|
185
|
+
uncovered: uncovered.sort()
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/** Records a provider accepted and then did not read back with their value. */
|
|
189
|
+
var DnsRecordsNotConfirmed = class extends require_errors.GkmError {
|
|
190
|
+
stage;
|
|
191
|
+
domain;
|
|
192
|
+
provider;
|
|
193
|
+
records;
|
|
194
|
+
constructor(stage, domain, provider, records) {
|
|
195
|
+
const lines = records.map((r) => ` - ${r.host} ${r.type}: ${r.found.length > 0 ? r.found.join(", ") : "nothing"}, expected ${r.expected}`);
|
|
196
|
+
super(`${provider} accepted '${stage}''s records for ${domain}, and reading them back does not show them:\n${lines.join("\n")}\nDeploy again; if it persists, check the records in the provider's console — another tool may be writing the same names.`);
|
|
197
|
+
this.stage = stage;
|
|
198
|
+
this.domain = domain;
|
|
199
|
+
this.provider = provider;
|
|
200
|
+
this.records = records;
|
|
201
|
+
this.name = "DnsRecordsNotConfirmed";
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
/** `api.example.com A 203.0.113.10 (TTL 600)` */
|
|
205
|
+
function describe(record) {
|
|
206
|
+
return `${record.host.padEnd(32)} ${record.type.padEnd(5)} ${record.value} (TTL ${record.ttl})`;
|
|
207
|
+
}
|
|
208
|
+
function printManual(plan, log, why) {
|
|
209
|
+
log(` ${plan.domain}: ${why} — create these records at its DNS host:`);
|
|
210
|
+
for (const record of plan.records) log(` ${describe(record)}`);
|
|
211
|
+
return plan.records.map((r) => ({
|
|
212
|
+
domain: r.domain,
|
|
213
|
+
name: r.name,
|
|
214
|
+
type: r.type,
|
|
215
|
+
action: "manual",
|
|
216
|
+
value: r.value,
|
|
217
|
+
ttl: r.ttl
|
|
218
|
+
}));
|
|
219
|
+
}
|
|
220
|
+
/** The existing records of every planned name, for the types gkm manages. */
|
|
221
|
+
async function existingRecords(provider, plan) {
|
|
222
|
+
const names = [...new Set(plan.records.map((r) => r.name))];
|
|
223
|
+
const wanted = names.flatMap((name) => MANAGED.map((type) => ({
|
|
224
|
+
name,
|
|
225
|
+
type
|
|
226
|
+
})));
|
|
227
|
+
if (provider.readRecords) return provider.readRecords(plan.domain, wanted);
|
|
228
|
+
return (await provider.getRecords(plan.domain)).filter((r) => names.includes(r.name) && MANAGED.includes(r.type));
|
|
229
|
+
}
|
|
230
|
+
const same = (a, b) => a.trim().replace(/\.$/, "").toLowerCase() === b.trim().replace(/\.$/, "").toLowerCase();
|
|
231
|
+
/**
|
|
232
|
+
* What each domain's records need, compared with what is there: creates,
|
|
233
|
+
* updates, and the deletes a change of mode needs — a name moving from an A
|
|
234
|
+
* record to a CNAME, or back, cannot hold both. Nothing else is deleted.
|
|
235
|
+
*/
|
|
236
|
+
function diffDomainDns(plan, existing) {
|
|
237
|
+
const changes = [];
|
|
238
|
+
const find = (name, type) => existing.find((r) => r.name === name && r.type === type);
|
|
239
|
+
const planned = /* @__PURE__ */ new Map();
|
|
240
|
+
for (const record of plan.records) {
|
|
241
|
+
const types = planned.get(record.name) ?? /* @__PURE__ */ new Set();
|
|
242
|
+
types.add(record.type);
|
|
243
|
+
planned.set(record.name, types);
|
|
244
|
+
}
|
|
245
|
+
for (const [name, types] of planned) {
|
|
246
|
+
const conflicting = types.has("CNAME") ? ["A", "AAAA"] : ["CNAME"];
|
|
247
|
+
for (const type of conflicting) {
|
|
248
|
+
const found = find(name, type);
|
|
249
|
+
if (!found || found.values.length === 0) continue;
|
|
250
|
+
changes.push({
|
|
251
|
+
domain: plan.domain,
|
|
252
|
+
name,
|
|
253
|
+
type,
|
|
254
|
+
action: "delete",
|
|
255
|
+
previous: found.values.join(", ")
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
for (const record of plan.records) {
|
|
260
|
+
const found = find(record.name, record.type);
|
|
261
|
+
const base = {
|
|
262
|
+
domain: plan.domain,
|
|
263
|
+
name: record.name,
|
|
264
|
+
type: record.type,
|
|
265
|
+
value: record.value,
|
|
266
|
+
ttl: record.ttl
|
|
267
|
+
};
|
|
268
|
+
if (!found || found.values.length === 0) changes.push({
|
|
269
|
+
...base,
|
|
270
|
+
action: "create"
|
|
271
|
+
});
|
|
272
|
+
else if (found.values.length === 1 && same(found.values[0], record.value)) changes.push({
|
|
273
|
+
...base,
|
|
274
|
+
action: "unchanged"
|
|
275
|
+
});
|
|
276
|
+
else changes.push({
|
|
277
|
+
...base,
|
|
278
|
+
action: "update",
|
|
279
|
+
previous: found.values.join(", ")
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
return changes;
|
|
283
|
+
}
|
|
284
|
+
/** A host's full name from a domain and a relative name. */
|
|
285
|
+
function fullName(domain, name) {
|
|
286
|
+
return name === "@" ? domain : `${name}.${domain}`;
|
|
287
|
+
}
|
|
288
|
+
function printChange(change, dryRun, log) {
|
|
289
|
+
const host = fullName(change.domain, change.name).padEnd(32);
|
|
290
|
+
const type = change.type.padEnd(5);
|
|
291
|
+
const would = dryRun ? "would " : "";
|
|
292
|
+
switch (change.action) {
|
|
293
|
+
case "unchanged":
|
|
294
|
+
log(` ✓ ${host} ${type} ${change.value} (TTL ${change.ttl}) — up to date`);
|
|
295
|
+
break;
|
|
296
|
+
case "create":
|
|
297
|
+
log(` + ${host} ${type} ${change.value} (TTL ${change.ttl}) — ${would}create`);
|
|
298
|
+
break;
|
|
299
|
+
case "update":
|
|
300
|
+
log(` ~ ${host} ${type} ${change.previous} → ${change.value} (TTL ${change.ttl}) — ${would}update`);
|
|
301
|
+
break;
|
|
302
|
+
case "write":
|
|
303
|
+
log(dryRun ? ` ? ${host} ${type} ${change.value} (TTL ${change.ttl}) — would write; current value unknown (key cannot read DNS)` : ` ! ${host} ${type} ${change.value} (TTL ${change.ttl}) — written (not diffed)`);
|
|
304
|
+
break;
|
|
305
|
+
case "delete": log(` - ${host} ${type} ${change.previous} — ${would}delete (a name cannot hold a CNAME and an A record)`);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Each domain's records, through its provider — and, with `confirm`, what was
|
|
310
|
+
* written read back from it. A record already holding its value is neither
|
|
311
|
+
* written nor read again.
|
|
312
|
+
*
|
|
313
|
+
* @throws {DnsRecordsNotConfirmed} when a written record does not read back
|
|
314
|
+
*/
|
|
315
|
+
async function settleStackDns(plan, options = {}) {
|
|
316
|
+
const dryRun = options.dryRun === true;
|
|
317
|
+
const log = options.log ?? ((line) => console.log(line));
|
|
318
|
+
const providerFor = options.providerFor ?? ((config) => require_seeds.createDnsProvider({
|
|
319
|
+
config,
|
|
320
|
+
...options.credentials ? { godaddy: options.credentials } : {},
|
|
321
|
+
...options.hostinger ? { hostinger: options.hostinger } : {}
|
|
322
|
+
}));
|
|
323
|
+
const changes = [];
|
|
324
|
+
const confirmed = /* @__PURE__ */ new Set();
|
|
325
|
+
const unconfirmed = /* @__PURE__ */ new Set();
|
|
326
|
+
const hostsOf = (domain) => new Set(domain.records.map((r) => r.host));
|
|
327
|
+
for (const host of plan.uncovered) log(` ⚠ ${host} is under no domain in dns — point it at ${plan.server.ipv4} yourself`);
|
|
328
|
+
for (const domain of plan.domains) {
|
|
329
|
+
if (domain.provider === "manual") {
|
|
330
|
+
changes.push(...printManual(domain, log, "manual"));
|
|
331
|
+
for (const host of hostsOf(domain)) unconfirmed.add(host);
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
334
|
+
const provider = await providerFor(domain.config);
|
|
335
|
+
if (!provider) {
|
|
336
|
+
changes.push(...printManual(domain, log, "manual"));
|
|
337
|
+
for (const host of hostsOf(domain)) unconfirmed.add(host);
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
log(` ${domain.domain} (${provider.name})${dryRun ? " — dry run" : ""}`);
|
|
341
|
+
let existing;
|
|
342
|
+
let diff;
|
|
343
|
+
let unreadable = false;
|
|
344
|
+
try {
|
|
345
|
+
existing = await existingRecords(provider, domain);
|
|
346
|
+
diff = diffDomainDns(domain, existing);
|
|
347
|
+
} catch (error) {
|
|
348
|
+
if (!(error instanceof require_seeds.DnsRecordsUnreadable)) throw error;
|
|
349
|
+
log(` ℹ The ${provider.name} key cannot read ${domain.domain}'s DNS records, so changes cannot be diffed: every record is written (idempotent).`);
|
|
350
|
+
unreadable = true;
|
|
351
|
+
existing = [];
|
|
352
|
+
diff = domain.records.map((r) => ({
|
|
353
|
+
domain: r.domain,
|
|
354
|
+
name: r.name,
|
|
355
|
+
type: r.type,
|
|
356
|
+
action: "write",
|
|
357
|
+
value: r.value,
|
|
358
|
+
ttl: r.ttl
|
|
359
|
+
}));
|
|
360
|
+
}
|
|
361
|
+
for (const change of diff) printChange(change, dryRun, log);
|
|
362
|
+
if (!plan.server.ipv6) for (const name of new Set(domain.records.map((r) => r.name))) {
|
|
363
|
+
const aaaa = existing.find((r) => r.name === name && r.type === "AAAA");
|
|
364
|
+
const planned = domain.records.find((r) => r.name === name && r.type === "A");
|
|
365
|
+
if (aaaa && planned && aaaa.values.length > 0) log(` ⚠ ${fullName(domain.domain, name)} also has AAAA ${aaaa.values.join(", ")}: set ${require_workspace.SERVER_IPV6_KEY} in the '${plan.stage}' stage's secrets to the server's IPv6 address, or remove that record, or IPv6 clients go elsewhere`);
|
|
366
|
+
}
|
|
367
|
+
changes.push(...diff);
|
|
368
|
+
const written = new Set(diff.filter((c) => c.action !== "unchanged").map((c) => fullName(c.domain, c.name)));
|
|
369
|
+
for (const host of hostsOf(domain)) if (unreadable) {
|
|
370
|
+
if (!dryRun) unconfirmed.add(host);
|
|
371
|
+
} else if (!written.has(host)) confirmed.add(host);
|
|
372
|
+
if (dryRun) continue;
|
|
373
|
+
const deletes = diff.filter((c) => c.action === "delete");
|
|
374
|
+
if (deletes.length > 0) await provider.deleteRecords(domain.domain, deletes.map((c) => ({
|
|
375
|
+
name: c.name,
|
|
376
|
+
type: c.type
|
|
377
|
+
})));
|
|
378
|
+
const writes = diff.filter((c) => c.action === "create" || c.action === "update" || c.action === "write");
|
|
379
|
+
if (writes.length > 0) await provider.upsertRecords(domain.domain, writes.map((c) => ({
|
|
380
|
+
name: c.name,
|
|
381
|
+
type: c.type,
|
|
382
|
+
value: c.value,
|
|
383
|
+
ttl: c.ttl
|
|
384
|
+
})));
|
|
385
|
+
if (!options.confirm || unreadable || written.size === 0) continue;
|
|
386
|
+
const rewritten = {
|
|
387
|
+
...domain,
|
|
388
|
+
records: domain.records.filter((r) => written.has(r.host))
|
|
389
|
+
};
|
|
390
|
+
const after = await existingRecords(provider, rewritten);
|
|
391
|
+
const missing = [];
|
|
392
|
+
for (const record of rewritten.records) {
|
|
393
|
+
const values = after.find((r) => r.name === record.name && r.type === record.type)?.values ?? [];
|
|
394
|
+
if (values.length !== 1 || !same(values[0], record.value)) missing.push({
|
|
395
|
+
host: record.host,
|
|
396
|
+
type: record.type,
|
|
397
|
+
expected: record.value,
|
|
398
|
+
found: values
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
if (missing.length > 0) throw new DnsRecordsNotConfirmed(plan.stage, domain.domain, provider.name, missing);
|
|
402
|
+
for (const host of written) confirmed.add(host);
|
|
403
|
+
log(` ✓ ${written.size} host${written.size === 1 ? "" : "s"} read back from ${provider.name}`);
|
|
404
|
+
}
|
|
405
|
+
for (const host of plan.uncovered) unconfirmed.add(host);
|
|
406
|
+
return {
|
|
407
|
+
changes,
|
|
408
|
+
confirmed: [...confirmed].sort(),
|
|
409
|
+
unconfirmed: [...unconfirmed].filter((h) => !confirmed.has(h)).sort()
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
/** The system resolver: what the server's own clients would be told. */
|
|
413
|
+
const systemLookup = async (host) => {
|
|
414
|
+
return (await (0, node_dns_promises.lookup)(host, { all: true })).map((a) => a.address);
|
|
415
|
+
};
|
|
416
|
+
/** Hosts that do not resolve to the stage's server. */
|
|
417
|
+
var HostNotPointingAtServer = class extends require_errors.GkmError {
|
|
418
|
+
stage;
|
|
419
|
+
hosts;
|
|
420
|
+
expected;
|
|
421
|
+
fix;
|
|
422
|
+
constructor(stage, hosts, expected, fix) {
|
|
423
|
+
const want = expected.ipv6 ? `${expected.ipv4} (and ${expected.ipv6})` : expected.ipv4;
|
|
424
|
+
const lines = hosts.map((h) => ` - ${h.host} → ${h.resolved.length > 0 ? h.resolved.join(", ") : `nothing${h.error ? ` (${h.error})` : ""}`}, expected ${want}`);
|
|
425
|
+
super(`${hosts.length === 1 ? "A host" : `${hosts.length} hosts`} of '${stage}' do${hosts.length === 1 ? "es" : ""} not resolve to its server, so a certificate for ${hosts.length === 1 ? "it" : "them"} cannot be issued:\n${lines.join("\n")}\n${fix}\nRecords can take a few minutes to propagate. With a CDN or proxy in front of the server, pass --skip-dns.`);
|
|
426
|
+
this.stage = stage;
|
|
427
|
+
this.hosts = hosts;
|
|
428
|
+
this.expected = expected;
|
|
429
|
+
this.fix = fix;
|
|
430
|
+
this.name = "HostNotPointingAtServer";
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
/**
|
|
434
|
+
* Every host resolved: each must resolve to the server's IPv4 address and to
|
|
435
|
+
* nothing but the server's addresses.
|
|
436
|
+
*
|
|
437
|
+
* @throws {HostNotPointingAtServer} naming every host that does not
|
|
438
|
+
*/
|
|
439
|
+
async function checkStackDns(input) {
|
|
440
|
+
const lookup = input.lookup ?? systemLookup;
|
|
441
|
+
const { server } = input;
|
|
442
|
+
const ours = new Set([server.ipv4, server.ipv6].filter(Boolean).map((a) => a.toLowerCase()));
|
|
443
|
+
const bad = [];
|
|
444
|
+
const ok = [];
|
|
445
|
+
for (const host of input.hosts) {
|
|
446
|
+
let resolved;
|
|
447
|
+
try {
|
|
448
|
+
resolved = [...new Set(await lookup(host))];
|
|
449
|
+
} catch (error) {
|
|
450
|
+
const code = error && typeof error === "object" && "code" in error ? String(error.code) : error instanceof Error ? error.message : String(error);
|
|
451
|
+
bad.push({
|
|
452
|
+
host,
|
|
453
|
+
resolved: [],
|
|
454
|
+
error: code
|
|
455
|
+
});
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
458
|
+
if (resolved.some((a) => a.toLowerCase() === server.ipv4.toLowerCase()) && resolved.every((a) => ours.has(a.toLowerCase()))) ok.push(host);
|
|
459
|
+
else bad.push({
|
|
460
|
+
host,
|
|
461
|
+
resolved
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
if (bad.length > 0) throw new HostNotPointingAtServer(input.stage, bad, {
|
|
465
|
+
ipv4: server.ipv4,
|
|
466
|
+
...server.ipv6 ? { ipv6: server.ipv6 } : {}
|
|
467
|
+
}, dnsFix(input, bad));
|
|
468
|
+
return ok;
|
|
469
|
+
}
|
|
470
|
+
/** How to fix it: the deploy, or the records to create by hand. */
|
|
471
|
+
function dnsFix(input, bad) {
|
|
472
|
+
const hosts = bad.map((h) => h.host);
|
|
473
|
+
let plan;
|
|
474
|
+
try {
|
|
475
|
+
plan = planStackDns({
|
|
476
|
+
stage: input.stage,
|
|
477
|
+
hosts,
|
|
478
|
+
server: input.server,
|
|
479
|
+
dns: input.dns
|
|
480
|
+
});
|
|
481
|
+
} catch {
|
|
482
|
+
plan = {
|
|
483
|
+
stage: input.stage,
|
|
484
|
+
server: input.server,
|
|
485
|
+
domains: [],
|
|
486
|
+
uncovered: hosts
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
const automatic = plan.domains.filter((d) => d.provider !== "manual");
|
|
490
|
+
const byHand = [...plan.domains.filter((d) => d.provider === "manual").flatMap((d) => d.records.map(describe)), ...plan.uncovered.flatMap((host) => [`${host.padEnd(32)} A ${input.server.ipv4}`, ...input.server.ipv6 ? [`${host.padEnd(32)} AAAA ${input.server.ipv6}`] : []])];
|
|
491
|
+
const lines = [];
|
|
492
|
+
if (automatic.length > 0) lines.push(`Fix: gkm deploy --stage ${input.stage} writes the records for ${automatic.map((d) => d.domain).join(", ")} through their provider (--dry-run shows them first).`);
|
|
493
|
+
if (byHand.length > 0) lines.push(`${automatic.length > 0 ? "And create" : "Fix: create"} these records at the DNS host:`, ...byHand.map((line) => ` ${line}`));
|
|
494
|
+
return lines.join("\n");
|
|
495
|
+
}
|
|
496
|
+
/** The environment variable each token-authenticated provider reads. */
|
|
497
|
+
const DNS_TOKEN_KEYS = {
|
|
498
|
+
godaddy: "GODADDY_API_TOKEN",
|
|
499
|
+
hostinger: "HOSTINGER_API_TOKEN"
|
|
500
|
+
};
|
|
501
|
+
/**
|
|
502
|
+
* A domain whose records the deploy writes, and no token to write them with.
|
|
503
|
+
* Raised before anything is built, started or written.
|
|
504
|
+
*/
|
|
505
|
+
var DnsCredentialMissing = class extends require_errors.GkmError {
|
|
506
|
+
stage;
|
|
507
|
+
domain;
|
|
508
|
+
provider;
|
|
509
|
+
key;
|
|
510
|
+
constructor(stage, domain, provider, key) {
|
|
511
|
+
super(`'${stage}''s hosts are under ${domain}, whose DNS is ${provider}'s, and the deploy writes their records — but ${key} is not set. In CI, add ${key} as a secret on the '${stage}' GitHub environment and pass it to the step that writes the records: env: { ${key}: \${{ secrets.${key} }} }. On this machine, export ${key} or run gkm login --provider ${provider}. With a CDN or proxy in front of the server, pass --skip-dns.`);
|
|
512
|
+
this.stage = stage;
|
|
513
|
+
this.domain = domain;
|
|
514
|
+
this.provider = provider;
|
|
515
|
+
this.key = key;
|
|
516
|
+
this.name = "DnsCredentialMissing";
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
/**
|
|
520
|
+
* The `dns` domain a stage's own domain (`domains.<stage>`) is under — where
|
|
521
|
+
* its hosts' records go — or none.
|
|
522
|
+
*/
|
|
523
|
+
function stageDnsDomains(stage, domains, dns) {
|
|
524
|
+
const own = domains?.[stage];
|
|
525
|
+
if (!own || !dns || isLocalHost(own)) return [];
|
|
526
|
+
const normalized = require_seeds.normalizeDnsConfig(dns);
|
|
527
|
+
const root = require_seeds.findRootDomain(own.toLowerCase(), normalized);
|
|
528
|
+
return root ? [{
|
|
529
|
+
domain: root,
|
|
530
|
+
config: normalized[root]
|
|
531
|
+
}] : [];
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Each token the domains' providers need, from `credentials` — `manual`,
|
|
535
|
+
* Route53 (the AWS SDK's own chain) and a provider object need none.
|
|
536
|
+
*
|
|
537
|
+
* @throws {DnsCredentialMissing} naming the first domain with no token
|
|
538
|
+
*/
|
|
539
|
+
async function dnsCredentials(stage, domains, credentials) {
|
|
540
|
+
const found = {};
|
|
541
|
+
for (const { domain, config } of domains) {
|
|
542
|
+
const provider = config.provider;
|
|
543
|
+
if (provider !== "godaddy" && provider !== "hostinger") continue;
|
|
544
|
+
if (found[provider]) continue;
|
|
545
|
+
const token = await credentials.get({ kind: provider });
|
|
546
|
+
if (!token?.token) throw new DnsCredentialMissing(stage, domain, provider, DNS_TOKEN_KEYS[provider]);
|
|
547
|
+
found[provider] = token;
|
|
548
|
+
}
|
|
549
|
+
return found;
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* A stage's DNS, as every deploy runs it: the
|
|
553
|
+
* stage's own hosts planned, written through each domain's provider where
|
|
554
|
+
* they differ, and read back from it. Only A, AAAA and CNAME records of
|
|
555
|
+
* those names are touched; nothing is a wildcard, and no other name is read,
|
|
556
|
+
* written or deleted. What no provider confirms — a `manual` domain, a host
|
|
557
|
+
* under no domain in `dns`, a key that cannot read — is resolved publicly.
|
|
558
|
+
* A dry run prints the plan and writes nothing.
|
|
559
|
+
*
|
|
560
|
+
* @throws {DnsCredentialMissing} before anything is read or written
|
|
561
|
+
* @throws {DnsRecordsNotConfirmed} when a written record does not read back
|
|
562
|
+
* @throws {HostNotPointingAtServer} when a resolved host is not the server
|
|
563
|
+
*/
|
|
564
|
+
async function stageDns(input) {
|
|
565
|
+
const { stage, server } = input;
|
|
566
|
+
const log = input.log ?? ((line) => console.log(line));
|
|
567
|
+
const plan = planStackDns({
|
|
568
|
+
stage,
|
|
569
|
+
hosts: input.hosts,
|
|
570
|
+
server,
|
|
571
|
+
dns: input.dns
|
|
572
|
+
});
|
|
573
|
+
const tokens = await dnsCredentials(stage, plan.domains.map(({ domain, config }) => ({
|
|
574
|
+
domain,
|
|
575
|
+
config
|
|
576
|
+
})), input.credentials);
|
|
577
|
+
const applied = !input.dns ? {
|
|
578
|
+
changes: [],
|
|
579
|
+
confirmed: [],
|
|
580
|
+
unconfirmed: [...plan.uncovered]
|
|
581
|
+
} : await settleStackDns(plan, {
|
|
582
|
+
...input.dryRun ? { dryRun: true } : { confirm: true },
|
|
583
|
+
log,
|
|
584
|
+
credentials: {
|
|
585
|
+
...input.godaddy ?? {},
|
|
586
|
+
...tokens.godaddy ? { credential: tokens.godaddy } : {},
|
|
587
|
+
log
|
|
588
|
+
},
|
|
589
|
+
...tokens.hostinger ? { hostinger: tokens.hostinger } : {},
|
|
590
|
+
...input.providerFor ? { providerFor: input.providerFor } : {}
|
|
591
|
+
});
|
|
592
|
+
let resolved = [];
|
|
593
|
+
if (applied.unconfirmed.length > 0) resolved = await checkStackDns({
|
|
594
|
+
stage,
|
|
595
|
+
hosts: applied.unconfirmed,
|
|
596
|
+
server,
|
|
597
|
+
dns: input.dns,
|
|
598
|
+
...input.lookup ? { lookup: input.lookup } : {}
|
|
599
|
+
});
|
|
600
|
+
return {
|
|
601
|
+
plan,
|
|
602
|
+
changes: applied.changes,
|
|
603
|
+
confirmed: applied.confirmed,
|
|
604
|
+
resolved
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
//#endregion
|
|
608
|
+
Object.defineProperty(exports, "HostNotPointingAtServer", {
|
|
609
|
+
enumerable: true,
|
|
610
|
+
get: function() {
|
|
611
|
+
return HostNotPointingAtServer;
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
Object.defineProperty(exports, "dnsCredentials", {
|
|
615
|
+
enumerable: true,
|
|
616
|
+
get: function() {
|
|
617
|
+
return dnsCredentials;
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
Object.defineProperty(exports, "isLocalHost", {
|
|
621
|
+
enumerable: true,
|
|
622
|
+
get: function() {
|
|
623
|
+
return isLocalHost;
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
Object.defineProperty(exports, "requiredServerAddress", {
|
|
627
|
+
enumerable: true,
|
|
628
|
+
get: function() {
|
|
629
|
+
return requiredServerAddress;
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
Object.defineProperty(exports, "serverAddressHint", {
|
|
633
|
+
enumerable: true,
|
|
634
|
+
get: function() {
|
|
635
|
+
return serverAddressHint;
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
Object.defineProperty(exports, "stackHosts", {
|
|
639
|
+
enumerable: true,
|
|
640
|
+
get: function() {
|
|
641
|
+
return stackHosts;
|
|
642
|
+
}
|
|
643
|
+
});
|
|
644
|
+
Object.defineProperty(exports, "stageDns", {
|
|
645
|
+
enumerable: true,
|
|
646
|
+
get: function() {
|
|
647
|
+
return stageDns;
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
Object.defineProperty(exports, "stageDnsDomains", {
|
|
651
|
+
enumerable: true,
|
|
652
|
+
get: function() {
|
|
653
|
+
return stageDnsDomains;
|
|
654
|
+
}
|
|
655
|
+
});
|
|
656
|
+
Object.defineProperty(exports, "systemLookup", {
|
|
657
|
+
enumerable: true,
|
|
658
|
+
get: function() {
|
|
659
|
+
return systemLookup;
|
|
660
|
+
}
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
//# sourceMappingURL=dns-Bmk7P9c2.cjs.map
|