@geekmidas/cli 10.0.0-alpha.15 → 10.0.0-alpha.150
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +313 -380
- package/bin/adjacent-tsconfig.mjs +46 -8
- package/bin/gkm.mjs +11 -3
- package/bin/owning-tsconfig-jsx-register.mjs +18 -0
- package/bin/owning-tsconfig-jsx.mjs +108 -0
- package/dist/EndpointGenerator-CusLH-9S.mjs +1037 -0
- package/dist/EndpointGenerator-CusLH-9S.mjs.map +1 -0
- package/dist/EndpointGenerator-DyLMYClE.cjs +1096 -0
- package/dist/EndpointGenerator-DyLMYClE.cjs.map +1 -0
- package/dist/GoDaddyProvider-CytuBrRm.cjs +412 -0
- package/dist/GoDaddyProvider-CytuBrRm.cjs.map +1 -0
- package/dist/GoDaddyProvider-W0Dxd5v9.mjs +412 -0
- package/dist/GoDaddyProvider-W0Dxd5v9.mjs.map +1 -0
- package/dist/{HostingerProvider-BZFGYYVA.cjs → HostingerProvider-CCc9xoBN.cjs} +23 -9
- package/dist/HostingerProvider-CCc9xoBN.cjs.map +1 -0
- package/dist/{HostingerProvider-BY26bWwB.mjs → HostingerProvider-DaQr2ueR.mjs} +23 -9
- package/dist/HostingerProvider-DaQr2ueR.mjs.map +1 -0
- package/dist/LegacyStateStore-BDA0rx3b.cjs +124 -0
- package/dist/LegacyStateStore-BDA0rx3b.cjs.map +1 -0
- package/dist/LegacyStateStore-BTcTbCGk.mjs +124 -0
- package/dist/LegacyStateStore-BTcTbCGk.mjs.map +1 -0
- package/dist/LocalStateStore-BNuQoZYe.cjs +178 -0
- package/dist/LocalStateStore-BNuQoZYe.cjs.map +1 -0
- package/dist/LocalStateStore-CqpCKVvi.mjs +167 -0
- package/dist/LocalStateStore-CqpCKVvi.mjs.map +1 -0
- package/dist/OpenApiTsGenerator-BTMuu1WS.mjs +534 -0
- package/dist/OpenApiTsGenerator-BTMuu1WS.mjs.map +1 -0
- package/dist/OpenApiTsGenerator-CI-tceXV.cjs +539 -0
- package/dist/OpenApiTsGenerator-CI-tceXV.cjs.map +1 -0
- package/dist/{Route53Provider-Cvj40A8I.mjs → Route53Provider-Di_SD9CF.mjs} +3 -3
- package/dist/Route53Provider-Di_SD9CF.mjs.map +1 -0
- package/dist/{Route53Provider-DVILBsvV.cjs → Route53Provider-emLuQHVw.cjs} +3 -3
- package/dist/Route53Provider-emLuQHVw.cjs.map +1 -0
- package/dist/S3StateStore-BpsGWDMK.mjs +223 -0
- package/dist/S3StateStore-BpsGWDMK.mjs.map +1 -0
- package/dist/S3StateStore-nrmSClXN.cjs +222 -0
- package/dist/S3StateStore-nrmSClXN.cjs.map +1 -0
- package/dist/SSMStateStore-DrPCC_VN.mjs +205 -0
- package/dist/SSMStateStore-DrPCC_VN.mjs.map +1 -0
- package/dist/SSMStateStore-hexM8C7n.cjs +204 -0
- package/dist/SSMStateStore-hexM8C7n.cjs.map +1 -0
- package/dist/SubscriberGenerator-BNJyPmXJ.cjs +848 -0
- package/dist/SubscriberGenerator-BNJyPmXJ.cjs.map +1 -0
- package/dist/SubscriberGenerator-CzPrixYu.mjs +783 -0
- package/dist/SubscriberGenerator-CzPrixYu.mjs.map +1 -0
- package/dist/add-DXMYV5ak.mjs +711 -0
- package/dist/add-DXMYV5ak.mjs.map +1 -0
- package/dist/add-DgAeo6ht.cjs +713 -0
- package/dist/add-DgAeo6ht.cjs.map +1 -0
- package/dist/appPorts-BoXMwolc.mjs +249 -0
- package/dist/appPorts-BoXMwolc.mjs.map +1 -0
- package/dist/appPorts-IW-OZmRi.cjs +296 -0
- package/dist/appPorts-IW-OZmRi.cjs.map +1 -0
- package/dist/apps-Bb05wCBm.mjs +5534 -0
- package/dist/apps-Bb05wCBm.mjs.map +1 -0
- package/dist/apps-CMLyyVGQ.cjs +6148 -0
- package/dist/apps-CMLyyVGQ.cjs.map +1 -0
- package/dist/aws-8QQ8n-t6.mjs +89 -0
- package/dist/aws-8QQ8n-t6.mjs.map +1 -0
- package/dist/aws-DY9NqQIT.cjs +100 -0
- package/dist/aws-DY9NqQIT.cjs.map +1 -0
- package/dist/awsStore-Bx5nCFnS.mjs +121 -0
- package/dist/awsStore-Bx5nCFnS.mjs.map +1 -0
- package/dist/awsStore-u3ehhMoY.cjs +138 -0
- package/dist/awsStore-u3ehhMoY.cjs.map +1 -0
- package/dist/{backup-provisioner-DIVCbfee.mjs → backup-provisioner-C8DnCmxK.mjs} +2 -2
- package/dist/backup-provisioner-C8DnCmxK.mjs.map +1 -0
- package/dist/{backup-provisioner-BmhIO_Yr.cjs → backup-provisioner-oDEsPj02.cjs} +2 -2
- package/dist/backup-provisioner-oDEsPj02.cjs.map +1 -0
- package/dist/backups/runner.cjs +519 -0
- package/dist/backups/runner.cjs.map +1 -0
- package/dist/backups/runner.d.cts +102 -0
- package/dist/backups/runner.d.cts.map +1 -0
- package/dist/backups/runner.d.mts +102 -0
- package/dist/backups/runner.d.mts.map +1 -0
- package/dist/backups/runner.mjs +506 -0
- package/dist/backups/runner.mjs.map +1 -0
- package/dist/{bundler-BodTL4kf.mjs → bundler-C1kDZyQ-.mjs} +59 -14
- package/dist/bundler-C1kDZyQ-.mjs.map +1 -0
- package/dist/{bundler-BeNDZdHQ.cjs → bundler-CD9Ug2uu.cjs} +59 -14
- package/dist/bundler-CD9Ug2uu.cjs.map +1 -0
- package/dist/cli-35yoGg9o.cjs +71 -0
- package/dist/cli-35yoGg9o.cjs.map +1 -0
- package/dist/cli-BAcJaRG7.mjs +71 -0
- package/dist/cli-BAcJaRG7.mjs.map +1 -0
- package/dist/compose-BZTh5HR3.mjs +1560 -0
- package/dist/compose-BZTh5HR3.mjs.map +1 -0
- package/dist/compose-CAhGIfG8.mjs +2877 -0
- package/dist/compose-CAhGIfG8.mjs.map +1 -0
- package/dist/compose-DF08HNJE.cjs +2966 -0
- package/dist/compose-DF08HNJE.cjs.map +1 -0
- package/dist/compose-KV6q3cEz.cjs +1919 -0
- package/dist/compose-KV6q3cEz.cjs.map +1 -0
- package/dist/config-BLrAd7Of.mjs +659 -0
- package/dist/config-BLrAd7Of.mjs.map +1 -0
- package/dist/config-CRk2vdSp.d.mts +268 -0
- package/dist/config-CRk2vdSp.d.mts.map +1 -0
- package/dist/config-juUyBlb1.cjs +772 -0
- package/dist/config-juUyBlb1.cjs.map +1 -0
- package/dist/config-oBgsbLip.d.cts +268 -0
- package/dist/config-oBgsbLip.d.cts.map +1 -0
- package/dist/config.cjs +11 -3
- package/dist/config.d.cts +4 -117
- package/dist/config.d.mts +4 -117
- package/dist/config.mjs +3 -3
- package/dist/credentialSchemas-BAklWDna.cjs +271 -0
- package/dist/credentialSchemas-BAklWDna.cjs.map +1 -0
- package/dist/credentialSchemas-mz9QZTYh.mjs +236 -0
- package/dist/credentialSchemas-mz9QZTYh.mjs.map +1 -0
- package/dist/credentials-B72Jrk66.mjs +1817 -0
- package/dist/credentials-B72Jrk66.mjs.map +1 -0
- package/dist/credentials-Dmhuj3FX.cjs +2272 -0
- package/dist/credentials-Dmhuj3FX.cjs.map +1 -0
- package/dist/databases-DawSdqBI.cjs +703 -0
- package/dist/databases-DawSdqBI.cjs.map +1 -0
- package/dist/databases-mzSUFBTw.mjs +588 -0
- package/dist/databases-mzSUFBTw.mjs.map +1 -0
- package/dist/define-6poNqm5O.mjs +106 -0
- package/dist/define-6poNqm5O.mjs.map +1 -0
- package/dist/define-crmMcXFS.cjs +153 -0
- package/dist/define-crmMcXFS.cjs.map +1 -0
- package/dist/deploy/public.cjs +211 -0
- package/dist/deploy/public.cjs.map +1 -0
- package/dist/deploy/public.d.cts +647 -0
- package/dist/deploy/public.d.cts.map +1 -0
- package/dist/deploy/public.d.mts +647 -0
- package/dist/deploy/public.d.mts.map +1 -0
- package/dist/deploy/public.mjs +144 -0
- package/dist/deploy/public.mjs.map +1 -0
- package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
- package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
- package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
- package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
- package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
- package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
- package/dist/deploy/sniffer-hooks.cjs +1 -1
- package/dist/deploy/sniffer-hooks.mjs +1 -1
- package/dist/deploy/sniffer-loader.cjs +2 -2
- package/dist/deploy/sniffer-loader.mjs +1 -1
- package/dist/deploy/sniffer-routes-worker.cjs +2 -2
- package/dist/deploy/sniffer-routes-worker.mjs +1 -1
- package/dist/deploy-BV6Tw73K.cjs +3892 -0
- package/dist/deploy-BV6Tw73K.cjs.map +1 -0
- package/dist/deploy-C4XjPy-a.mjs +3836 -0
- package/dist/deploy-C4XjPy-a.mjs.map +1 -0
- package/dist/discover-CRywE7yc.cjs +1085 -0
- package/dist/discover-CRywE7yc.cjs.map +1 -0
- package/dist/discover-DbDrCQ8h.mjs +940 -0
- package/dist/discover-DbDrCQ8h.mjs.map +1 -0
- package/dist/docker-B0di7_Ub.cjs +1514 -0
- package/dist/docker-B0di7_Ub.cjs.map +1 -0
- package/dist/docker-D_NN2Z6W.mjs +1407 -0
- package/dist/docker-D_NN2Z6W.mjs.map +1 -0
- package/dist/dokploy-DDyZ0o4M.mjs +38 -0
- package/dist/dokploy-DDyZ0o4M.mjs.map +1 -0
- package/dist/dokploy-FFNHKz37.cjs +38 -0
- package/dist/dokploy-FFNHKz37.cjs.map +1 -0
- package/dist/drivers-aM87NQJi.cjs +224 -0
- package/dist/drivers-aM87NQJi.cjs.map +1 -0
- package/dist/drivers-uxLBq3e3.mjs +195 -0
- package/dist/drivers-uxLBq3e3.mjs.map +1 -0
- package/dist/eas-6_Z1ImVg.mjs +334 -0
- package/dist/eas-6_Z1ImVg.mjs.map +1 -0
- package/dist/eas-BetrZzjq.cjs +337 -0
- package/dist/eas-BetrZzjq.cjs.map +1 -0
- package/dist/emit-Bj6XSivk.mjs +136 -0
- package/dist/emit-Bj6XSivk.mjs.map +1 -0
- package/dist/emit-CDC__ubE.cjs +147 -0
- package/dist/emit-CDC__ubE.cjs.map +1 -0
- package/dist/encryption-BrRVjItb.cjs +90 -0
- package/dist/encryption-BrRVjItb.cjs.map +1 -0
- package/dist/encryption-DGnfdO68.mjs +89 -0
- package/dist/encryption-DGnfdO68.mjs.map +1 -0
- package/dist/engine-8TjM26dd.mjs +3217 -0
- package/dist/engine-8TjM26dd.mjs.map +1 -0
- package/dist/engine-C36N8por.cjs +3330 -0
- package/dist/engine-C36N8por.cjs.map +1 -0
- package/dist/errors-D8Gwp5kU.mjs +23 -0
- package/dist/errors-D8Gwp5kU.mjs.map +1 -0
- package/dist/errors-DMC4Umsb.cjs +34 -0
- package/dist/errors-DMC4Umsb.cjs.map +1 -0
- package/dist/github-BOu0bETi.cjs +901 -0
- package/dist/github-BOu0bETi.cjs.map +1 -0
- package/dist/github-Ct6XDkzE.mjs +900 -0
- package/dist/github-Ct6XDkzE.mjs.map +1 -0
- package/dist/googlePlay-BaRsxlJo.mjs +931 -0
- package/dist/googlePlay-BaRsxlJo.mjs.map +1 -0
- package/dist/googlePlay-JAxXMaGu.cjs +931 -0
- package/dist/googlePlay-JAxXMaGu.cjs.map +1 -0
- package/dist/{index-D-iAVHx-.d.cts → index-B35vTdAW.d.cts} +39 -15
- package/dist/index-B35vTdAW.d.cts.map +1 -0
- package/dist/{index-Cd-qeOam.d.mts → index-Dv1Zj86i.d.mts} +39 -15
- package/dist/index-Dv1Zj86i.d.mts.map +1 -0
- package/dist/index.cjs +13594 -12347
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +13541 -12292
- package/dist/index.mjs.map +1 -1
- package/dist/local-D7WVQcJJ.mjs +224 -0
- package/dist/local-D7WVQcJJ.mjs.map +1 -0
- package/dist/local-DFPeCIJi.cjs +241 -0
- package/dist/local-DFPeCIJi.cjs.map +1 -0
- package/dist/migrate-BMIUYmpM.mjs +267 -0
- package/dist/migrate-BMIUYmpM.mjs.map +1 -0
- package/dist/migrate-CnE-X40v.mjs +181 -0
- package/dist/migrate-CnE-X40v.mjs.map +1 -0
- package/dist/migrate-CvuWFjos.cjs +181 -0
- package/dist/migrate-CvuWFjos.cjs.map +1 -0
- package/dist/migrate-DdE8kF0j.cjs +272 -0
- package/dist/migrate-DdE8kF0j.cjs.map +1 -0
- package/dist/notes-C_4SO0x4.mjs +399 -0
- package/dist/notes-C_4SO0x4.mjs.map +1 -0
- package/dist/notes-ORze6zXA.cjs +500 -0
- package/dist/notes-ORze6zXA.cjs.map +1 -0
- package/dist/openapi.cjs +213 -7
- package/dist/openapi.cjs.map +1 -0
- package/dist/openapi.d.cts +32 -8
- package/dist/openapi.d.cts.map +1 -1
- package/dist/openapi.d.mts +32 -8
- package/dist/openapi.d.mts.map +1 -1
- package/dist/openapi.mjs +208 -2
- package/dist/openapi.mjs.map +1 -0
- package/dist/projectBucket-C9x0gzEO.cjs +263 -0
- package/dist/projectBucket-C9x0gzEO.cjs.map +1 -0
- package/dist/projectBucket-CdRj4IyR.mjs +222 -0
- package/dist/projectBucket-CdRj4IyR.mjs.map +1 -0
- package/dist/provider-BqpjG9QM.cjs +57 -0
- package/dist/provider-BqpjG9QM.cjs.map +1 -0
- package/dist/provider-CEOKk8NS.mjs +46 -0
- package/dist/provider-CEOKk8NS.mjs.map +1 -0
- package/dist/publish-CL376jrq.cjs +124 -0
- package/dist/publish-CL376jrq.cjs.map +1 -0
- package/dist/publish-DkkWS3Pj.mjs +123 -0
- package/dist/publish-DkkWS3Pj.mjs.map +1 -0
- package/dist/ready-BNh3zsSn.cjs +404 -0
- package/dist/ready-BNh3zsSn.cjs.map +1 -0
- package/dist/ready-g25dcGzK.mjs +375 -0
- package/dist/ready-g25dcGzK.mjs.map +1 -0
- package/dist/reconcile/public.cjs +3 -5
- package/dist/reconcile/public.d.cts +31 -89
- package/dist/reconcile/public.d.cts.map +1 -1
- package/dist/reconcile/public.d.mts +31 -89
- package/dist/reconcile/public.d.mts.map +1 -1
- package/dist/reconcile/public.mjs +3 -3
- package/dist/{reconcile-DhQ00DpU.mjs → reconcile--I7V4Klj.mjs} +2 -2
- package/dist/{reconcile-DhQ00DpU.mjs.map → reconcile--I7V4Klj.mjs.map} +1 -1
- package/dist/{reconcile-Dd2iyILf.cjs → reconcile-CuCQBa5-.cjs} +3 -3
- package/dist/{reconcile-Dd2iyILf.cjs.map → reconcile-CuCQBa5-.cjs.map} +1 -1
- package/dist/resolve-BXzDwYUS.cjs +316 -0
- package/dist/resolve-BXzDwYUS.cjs.map +1 -0
- package/dist/resolve-CZ_Wel7j.mjs +263 -0
- package/dist/resolve-CZ_Wel7j.mjs.map +1 -0
- package/dist/rollback-D_FXI_K5.mjs +136 -0
- package/dist/rollback-D_FXI_K5.mjs.map +1 -0
- package/dist/rollback-p1y0KlED.cjs +165 -0
- package/dist/rollback-p1y0KlED.cjs.map +1 -0
- package/dist/runtime-CFvcLEJW.d.cts +82 -0
- package/dist/runtime-CFvcLEJW.d.cts.map +1 -0
- package/dist/runtime-dwsH6ddo.d.mts +82 -0
- package/dist/runtime-dwsH6ddo.d.mts.map +1 -0
- package/dist/s3-CV5baYeq.mjs +215 -0
- package/dist/s3-CV5baYeq.mjs.map +1 -0
- package/dist/s3-DTX4Kkmn.cjs +215 -0
- package/dist/s3-DTX4Kkmn.cjs.map +1 -0
- package/dist/sandbox/config-worker.cjs +43 -0
- package/dist/sandbox/config-worker.cjs.map +1 -0
- package/dist/sandbox/config-worker.d.cts +1 -0
- package/dist/sandbox/config-worker.d.mts +1 -0
- package/dist/sandbox/config-worker.mjs +44 -0
- package/dist/sandbox/config-worker.mjs.map +1 -0
- package/dist/sandbox/credentials-worker.cjs +53 -0
- package/dist/sandbox/credentials-worker.cjs.map +1 -0
- package/dist/sandbox/credentials-worker.d.cts +1 -0
- package/dist/sandbox/credentials-worker.d.mts +1 -0
- package/dist/sandbox/credentials-worker.mjs +54 -0
- package/dist/sandbox/credentials-worker.mjs.map +1 -0
- package/dist/sandbox/discover-worker.cjs +47 -0
- package/dist/sandbox/discover-worker.cjs.map +1 -0
- package/dist/sandbox/discover-worker.d.cts +1 -0
- package/dist/sandbox/discover-worker.d.mts +1 -0
- package/dist/sandbox/discover-worker.mjs +48 -0
- package/dist/sandbox/discover-worker.mjs.map +1 -0
- package/dist/sandbox/migrate-worker.cjs +75 -0
- package/dist/sandbox/migrate-worker.cjs.map +1 -0
- package/dist/sandbox/migrate-worker.d.cts +1 -0
- package/dist/sandbox/migrate-worker.d.mts +1 -0
- package/dist/sandbox/migrate-worker.mjs +76 -0
- package/dist/sandbox/migrate-worker.mjs.map +1 -0
- package/dist/{workspace-mFpI_ky_.cjs → schemas-BCwKKA42.mjs} +399 -1162
- package/dist/schemas-BCwKKA42.mjs.map +1 -0
- package/dist/{workspace-CgwmXEtc.mjs → schemas-BQ_v0lEX.cjs} +487 -971
- package/dist/schemas-BQ_v0lEX.cjs.map +1 -0
- package/dist/secretsManager-CQORubp9.mjs +97 -0
- package/dist/secretsManager-CQORubp9.mjs.map +1 -0
- package/dist/secretsManager-RAGcEDX1.cjs +108 -0
- package/dist/secretsManager-RAGcEDX1.cjs.map +1 -0
- package/dist/seeds-B3xvUAQf.cjs +363 -0
- package/dist/seeds-B3xvUAQf.cjs.map +1 -0
- package/dist/seeds-BCC8vAXR.mjs +298 -0
- package/dist/seeds-BCC8vAXR.mjs.map +1 -0
- package/dist/serverSetup-BykJrnYe.cjs +652 -0
- package/dist/serverSetup-BykJrnYe.cjs.map +1 -0
- package/dist/serverSetup-CkuvIoej.mjs +652 -0
- package/dist/serverSetup-CkuvIoej.mjs.map +1 -0
- package/dist/sniffer-BIpoMNGz.mjs +1824 -0
- package/dist/sniffer-BIpoMNGz.mjs.map +1 -0
- package/dist/sniffer-DiBMi93N.cjs +1997 -0
- package/dist/sniffer-DiBMi93N.cjs.map +1 -0
- package/dist/snsSubscriptions-CkO_zk0j.cjs +1173 -0
- package/dist/snsSubscriptions-CkO_zk0j.cjs.map +1 -0
- package/dist/snsSubscriptions-CrmfcJfv.mjs +1048 -0
- package/dist/snsSubscriptions-CrmfcJfv.mjs.map +1 -0
- package/dist/sst-BZ9sTG8H.mjs +462 -0
- package/dist/sst-BZ9sTG8H.mjs.map +1 -0
- package/dist/sst-D233GoQY.cjs +485 -0
- package/dist/sst-D233GoQY.cjs.map +1 -0
- package/dist/stack-1yXKqI83.cjs +2287 -0
- package/dist/stack-1yXKqI83.cjs.map +1 -0
- package/dist/stack-pUz70Rmw.mjs +2124 -0
- package/dist/stack-pUz70Rmw.mjs.map +1 -0
- package/dist/stage-D6E_TlvR.mjs +302 -0
- package/dist/stage-D6E_TlvR.mjs.map +1 -0
- package/dist/stage-DAhomyUk.cjs +313 -0
- package/dist/stage-DAhomyUk.cjs.map +1 -0
- package/dist/stages-Bs1THSy7.cjs +190 -0
- package/dist/stages-Bs1THSy7.cjs.map +1 -0
- package/dist/stages-_xCG4Ymu.mjs +190 -0
- package/dist/stages-_xCG4Ymu.mjs.map +1 -0
- package/dist/target/public.cjs +15 -0
- package/dist/target/public.d.cts +28 -0
- package/dist/target/public.d.cts.map +1 -0
- package/dist/target/public.d.mts +28 -0
- package/dist/target/public.d.mts.map +1 -0
- package/dist/target/public.mjs +4 -0
- package/dist/terminal-CKBLsg6b.cjs +85 -0
- package/dist/terminal-CKBLsg6b.cjs.map +1 -0
- package/dist/terminal-CRinpE1t.mjs +85 -0
- package/dist/terminal-CRinpE1t.mjs.map +1 -0
- package/dist/types-Bl_CwZC9.cjs +90 -0
- package/dist/types-Bl_CwZC9.cjs.map +1 -0
- package/dist/{types-BGo5TaNE.d.mts → types-Dk--xVOT.d.cts} +2234 -439
- package/dist/types-Dk--xVOT.d.cts.map +1 -0
- package/dist/{types-C5ZNpUad.d.cts → types-DwQYpd_0.d.mts} +2232 -439
- package/dist/types-DwQYpd_0.d.mts.map +1 -0
- package/dist/types-Y1NfWlyG.mjs +61 -0
- package/dist/types-Y1NfWlyG.mjs.map +1 -0
- package/dist/utils-D2Nk1Nv2.cjs +205 -0
- package/dist/utils-D2Nk1Nv2.cjs.map +1 -0
- package/dist/utils-D_fxUqvU.mjs +156 -0
- package/dist/utils-D_fxUqvU.mjs.map +1 -0
- package/dist/vitest.cjs +65 -0
- package/dist/vitest.cjs.map +1 -0
- package/dist/vitest.d.cts +29 -0
- package/dist/vitest.d.cts.map +1 -0
- package/dist/vitest.d.mts +29 -0
- package/dist/vitest.d.mts.map +1 -0
- package/dist/vitest.mjs +65 -0
- package/dist/vitest.mjs.map +1 -0
- package/dist/workerRuntime-BXfhbe13.cjs +108 -0
- package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
- package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
- package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
- package/dist/workspace/index.cjs +6 -2
- package/dist/workspace/index.d.cts +3 -3
- package/dist/workspace/index.d.mts +3 -3
- package/dist/workspace/index.mjs +2 -2
- package/dist/workspace-1szcahj9.cjs +2916 -0
- package/dist/workspace-1szcahj9.cjs.map +1 -0
- package/dist/workspace-DFGsrjGD.mjs +2480 -0
- package/dist/workspace-DFGsrjGD.mjs.map +1 -0
- package/package.json +66 -14
- package/dist/HostingerProvider-BY26bWwB.mjs.map +0 -1
- package/dist/HostingerProvider-BZFGYYVA.cjs.map +0 -1
- package/dist/LocalStateProvider-7HR6SS2t.cjs +0 -48
- package/dist/LocalStateProvider-7HR6SS2t.cjs.map +0 -1
- package/dist/LocalStateProvider-D7QyJoLM.mjs +0 -48
- package/dist/LocalStateProvider-D7QyJoLM.mjs.map +0 -1
- package/dist/Route53Provider-Cvj40A8I.mjs.map +0 -1
- package/dist/Route53Provider-DVILBsvV.cjs.map +0 -1
- package/dist/SSMStateProvider-B0Hu1MKZ.mjs +0 -75
- package/dist/SSMStateProvider-B0Hu1MKZ.mjs.map +0 -1
- package/dist/SSMStateProvider-VrQ-yeqd.cjs +0 -74
- package/dist/SSMStateProvider-VrQ-yeqd.cjs.map +0 -1
- package/dist/backup-provisioner-BmhIO_Yr.cjs.map +0 -1
- package/dist/backup-provisioner-DIVCbfee.mjs.map +0 -1
- package/dist/bundler-BeNDZdHQ.cjs.map +0 -1
- package/dist/bundler-BodTL4kf.mjs.map +0 -1
- package/dist/config-Q1rvKHvw.cjs +0 -467
- package/dist/config-Q1rvKHvw.cjs.map +0 -1
- package/dist/config-pqGD3hF9.mjs +0 -414
- package/dist/config-pqGD3hF9.mjs.map +0 -1
- package/dist/config.d.cts.map +0 -1
- package/dist/config.d.mts.map +0 -1
- package/dist/credentials-BekkKtY_.mjs +0 -2780
- package/dist/credentials-BekkKtY_.mjs.map +0 -1
- package/dist/credentials-Q6F0uqJq.cjs +0 -2917
- package/dist/credentials-Q6F0uqJq.cjs.map +0 -1
- package/dist/discover-BERGFg8v.cjs +0 -288
- package/dist/discover-BERGFg8v.cjs.map +0 -1
- package/dist/discover-CK-n3w6b.mjs +0 -244
- package/dist/discover-CK-n3w6b.mjs.map +0 -1
- package/dist/emit-BdoPFjZf.cjs +0 -253
- package/dist/emit-BdoPFjZf.cjs.map +0 -1
- package/dist/emit-Bzq7JsMP.mjs +0 -224
- package/dist/emit-Bzq7JsMP.mjs.map +0 -1
- package/dist/fullstack-secrets-BET8gqwK.mjs +0 -81
- package/dist/fullstack-secrets-BET8gqwK.mjs.map +0 -1
- package/dist/fullstack-secrets-DXsWO-5m.cjs +0 -92
- package/dist/fullstack-secrets-DXsWO-5m.cjs.map +0 -1
- package/dist/generator-LfZU7NlU.mjs +0 -247
- package/dist/generator-LfZU7NlU.mjs.map +0 -1
- package/dist/generator-Wdfp0jCS.cjs +0 -282
- package/dist/generator-Wdfp0jCS.cjs.map +0 -1
- package/dist/github-BfflNPVe.cjs +0 -203
- package/dist/github-BfflNPVe.cjs.map +0 -1
- package/dist/github-CRwnxKmD.mjs +0 -203
- package/dist/github-CRwnxKmD.mjs.map +0 -1
- package/dist/index-Cd-qeOam.d.mts.map +0 -1
- package/dist/index-D-iAVHx-.d.cts.map +0 -1
- package/dist/keystore-B4PRlbgE.mjs +0 -81
- package/dist/keystore-B4PRlbgE.mjs.map +0 -1
- package/dist/keystore-DgGRj2Yy.cjs +0 -98
- package/dist/keystore-DgGRj2Yy.cjs.map +0 -1
- package/dist/openapi-Dcbme-Us.cjs +0 -2038
- package/dist/openapi-Dcbme-Us.cjs.map +0 -1
- package/dist/openapi-vy4JzhUv.mjs +0 -1991
- package/dist/openapi-vy4JzhUv.mjs.map +0 -1
- package/dist/storage-C-30BD1e.cjs +0 -272
- package/dist/storage-C-30BD1e.cjs.map +0 -1
- package/dist/storage-P_b3w7uj.mjs +0 -231
- package/dist/storage-P_b3w7uj.mjs.map +0 -1
- package/dist/sync-B3xxXtJT.mjs +0 -88
- package/dist/sync-B3xxXtJT.mjs.map +0 -1
- package/dist/sync-D7uTIIEi.cjs +0 -111
- package/dist/sync-D7uTIIEi.cjs.map +0 -1
- package/dist/types-BGo5TaNE.d.mts.map +0 -1
- package/dist/types-C5ZNpUad.d.cts.map +0 -1
- package/dist/workspace-CgwmXEtc.mjs.map +0 -1
- package/dist/workspace-mFpI_ky_.cjs.map +0 -1
|
@@ -0,0 +1,1048 @@
|
|
|
1
|
+
import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
|
|
2
|
+
import { a as findRootDomain, i as extractSubdomain, l as DnsRecordsUnreadable, o as normalizeDnsConfig, r as storedCredentials, u as createDnsProvider } from "./credentials-B72Jrk66.mjs";
|
|
3
|
+
import { _t as SERVER_IPV6_KEY, gt as SERVER_IPV4_KEY, vt as cnameTarget } from "./workspace-DFGsrjGD.mjs";
|
|
4
|
+
import { isIPv4, isIPv6 } from "node:net";
|
|
5
|
+
import { lookup } from "node:dns/promises";
|
|
6
|
+
//#region src/providers/aws.ts
|
|
7
|
+
/**
|
|
8
|
+
* The AWS account a provider provisions in — the stage's, found the way the
|
|
9
|
+
* SSM and Secrets Manager stores find it.
|
|
10
|
+
*
|
|
11
|
+
* 1. `--profile`, resolved on its own: exported keys left over from another
|
|
12
|
+
* account never win over a profile someone named.
|
|
13
|
+
* 2. `AWS_PROFILE`, else `AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY` — the
|
|
14
|
+
* deploy's own `aws` credential kind (`storedCredentials`).
|
|
15
|
+
* 3. The SDK's default chain: `~/.aws` default profile, SSO, a role. In CI,
|
|
16
|
+
* whatever `aws-actions/configure-aws-credentials` exported.
|
|
17
|
+
*
|
|
18
|
+
* None of them: the provider has no provisioning credentials, and the stage
|
|
19
|
+
* is treated as `external`.
|
|
20
|
+
*/
|
|
21
|
+
async function awsProvisioningCredentials(lookup) {
|
|
22
|
+
const region = lookup.env.AWS_REGION ?? lookup.env.AWS_DEFAULT_REGION;
|
|
23
|
+
const where = region ? { region } : {};
|
|
24
|
+
if (lookup.profile) return {
|
|
25
|
+
profile: lookup.profile,
|
|
26
|
+
...where
|
|
27
|
+
};
|
|
28
|
+
const stored = await storedCredentials({
|
|
29
|
+
env: lookup.env,
|
|
30
|
+
...lookup.home ? { home: lookup.home } : {}
|
|
31
|
+
}).get({
|
|
32
|
+
kind: "aws",
|
|
33
|
+
stage: lookup.stage
|
|
34
|
+
});
|
|
35
|
+
if (stored) return stored;
|
|
36
|
+
try {
|
|
37
|
+
const { fromNodeProviderChain } = await import("@aws-sdk/credential-providers");
|
|
38
|
+
await fromNodeProviderChain({
|
|
39
|
+
timeout: 1e3,
|
|
40
|
+
maxRetries: 0
|
|
41
|
+
})();
|
|
42
|
+
return {
|
|
43
|
+
chain: true,
|
|
44
|
+
...where
|
|
45
|
+
};
|
|
46
|
+
} catch {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* An S3-compatible endpoint the environment points the SDK at — the AWS
|
|
52
|
+
* emulator in tests. The SDK reads it itself; it is read here too, because
|
|
53
|
+
* an emulator takes path-style requests, and a key written for one has to
|
|
54
|
+
* say where it is.
|
|
55
|
+
*/
|
|
56
|
+
function awsEndpoint(env, service) {
|
|
57
|
+
return env[`AWS_ENDPOINT_URL_${service}`] ?? env.AWS_ENDPOINT_URL;
|
|
58
|
+
}
|
|
59
|
+
/** An SDK client's config for a provisioning credential. */
|
|
60
|
+
async function awsClientConfig(credential, region) {
|
|
61
|
+
if ("profile" in credential) {
|
|
62
|
+
const { fromIni } = await import("@aws-sdk/credential-providers");
|
|
63
|
+
return {
|
|
64
|
+
region,
|
|
65
|
+
credentials: fromIni({ profile: credential.profile })
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if ("accessKeyId" in credential) return {
|
|
69
|
+
region,
|
|
70
|
+
credentials: {
|
|
71
|
+
accessKeyId: credential.accessKeyId,
|
|
72
|
+
secretAccessKey: credential.secretAccessKey,
|
|
73
|
+
...credential.sessionToken ? { sessionToken: credential.sessionToken } : {}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
return { region };
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/compose/dns.ts
|
|
80
|
+
/**
|
|
81
|
+
* A compose stage's DNS: the records its public hosts need, and the check that
|
|
82
|
+
* they resolve to its server before a certificate is asked for.
|
|
83
|
+
*
|
|
84
|
+
* - **The server** (`serverAddress`): the stage's own secrets hold its public
|
|
85
|
+
* addresses — `GKM_SERVER_IPV4`, and `GKM_SERVER_IPV6` where it has one.
|
|
86
|
+
* Reserved for gkm: never handed to an app.
|
|
87
|
+
* - **The plan** (`planStackDns`, pure): every public host the stack serves —
|
|
88
|
+
* its apex, each app, each file server, the public log UI — pointed at the
|
|
89
|
+
* server. An A record per host (and an AAAA with an IPv6 address), or, where
|
|
90
|
+
* the domain's `dns` entry says `records: { mode: 'cname', target }`, one A
|
|
91
|
+
* record for the target and a CNAME to it for every other host but the
|
|
92
|
+
* apex, which DNS forbids a CNAME at.
|
|
93
|
+
* - **Applying it** (`applyStackDns`): through the domain's provider in `dns`,
|
|
94
|
+
* a record set at a time. A record with the right value is left alone; one
|
|
95
|
+
* with another value is replaced and the change printed. A `manual` domain
|
|
96
|
+
* is printed and nothing else. A dry run reads, prints and writes nothing.
|
|
97
|
+
* - **The check** (`checkStackDns`): each host resolved with the system
|
|
98
|
+
* resolver. One that is not the server stops the deploy with
|
|
99
|
+
* {@link HostNotPointingAtServer}, before Caddy or Traefik ask Let's Encrypt
|
|
100
|
+
* for a certificate it cannot get — and use up the rate limit trying.
|
|
101
|
+
* - **What gkm wrote before** (`diffRecordedDns`, pure): the plan against the
|
|
102
|
+
* records the stage's state says gkm wrote — added, kept, and stale: a
|
|
103
|
+
* host the stage no longer serves, after a domain or an app changed.
|
|
104
|
+
* - **The prune** (`pruneStackDns`): each stale record deleted through its
|
|
105
|
+
* domain's provider, if it still holds the value gkm wrote. One someone
|
|
106
|
+
* pointed elsewhere is left alone; one no provider can delete is printed.
|
|
107
|
+
* - **The step** (`stageDns`): all of it, as every deploy runs it — the plan applied through each provider,
|
|
108
|
+
* what was written read back from the provider, the stale records pruned,
|
|
109
|
+
* and only the hosts no provider wrote resolved publicly. A brand-new name
|
|
110
|
+
* is never looked up before its record exists, so no resolver caches it as
|
|
111
|
+
* missing.
|
|
112
|
+
*/
|
|
113
|
+
/** The line that says how to set the server's address. */
|
|
114
|
+
function serverAddressHint(stage) {
|
|
115
|
+
return `gkm secrets:set ${SERVER_IPV4_KEY} '<ip>' --stage ${stage}`;
|
|
116
|
+
}
|
|
117
|
+
/** A server address in the stage's secrets that is not an address. */
|
|
118
|
+
var ServerAddressInvalid = class extends GkmError {
|
|
119
|
+
stage;
|
|
120
|
+
key;
|
|
121
|
+
value;
|
|
122
|
+
constructor(stage, key, value) {
|
|
123
|
+
const ipv4 = key === SERVER_IPV4_KEY;
|
|
124
|
+
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}.`);
|
|
125
|
+
this.stage = stage;
|
|
126
|
+
this.key = key;
|
|
127
|
+
this.value = value;
|
|
128
|
+
this.name = "ServerAddressInvalid";
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* A compose stage that serves real domains with no server address: its hosts
|
|
133
|
+
* cannot be pointed or checked, and a certificate would be asked for blind.
|
|
134
|
+
*/
|
|
135
|
+
var ServerAddressMissing = class extends GkmError {
|
|
136
|
+
stage;
|
|
137
|
+
domain;
|
|
138
|
+
constructor(stage, domain) {
|
|
139
|
+
super(`The '${stage}' stage serves ${domain} and its secrets hold no ${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 ${SERVER_IPV6_KEY} for an IPv6 address).`);
|
|
140
|
+
this.stage = stage;
|
|
141
|
+
this.domain = domain;
|
|
142
|
+
this.name = "ServerAddressMissing";
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* The server's address from the stage's secrets, checked — `undefined` when
|
|
147
|
+
* `GKM_SERVER_IPV4` is not set.
|
|
148
|
+
*
|
|
149
|
+
* @throws {ServerAddressInvalid} for a value that is not an address
|
|
150
|
+
*/
|
|
151
|
+
function serverAddress(stage, custom) {
|
|
152
|
+
const ipv4 = custom?.[SERVER_IPV4_KEY]?.trim();
|
|
153
|
+
const ipv6 = custom?.[SERVER_IPV6_KEY]?.trim();
|
|
154
|
+
if (ipv6 && !isIPv6(ipv6)) throw new ServerAddressInvalid(stage, SERVER_IPV6_KEY, ipv6);
|
|
155
|
+
if (!ipv4) return void 0;
|
|
156
|
+
if (!isIPv4(ipv4)) throw new ServerAddressInvalid(stage, SERVER_IPV4_KEY, ipv4);
|
|
157
|
+
return {
|
|
158
|
+
ipv4,
|
|
159
|
+
...ipv6 ? { ipv6 } : {}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* A name that resolves to this machine by definition — `localhost` and every
|
|
164
|
+
* `*.localhost` — and is in nobody's DNS.
|
|
165
|
+
*/
|
|
166
|
+
function isLocalHost(host) {
|
|
167
|
+
const name = host.toLowerCase().replace(/\.$/, "");
|
|
168
|
+
return name === "localhost" || name.endsWith(".localhost");
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* The server's address, required where the stage serves real domains — not
|
|
172
|
+
* `*.localhost` ones, which point at this machine already.
|
|
173
|
+
*
|
|
174
|
+
* @throws {ServerAddressMissing} when the stage has a domain and no address
|
|
175
|
+
* @throws {ServerAddressInvalid} for a value that is not an address
|
|
176
|
+
*/
|
|
177
|
+
function requiredServerAddress(stage, domain, custom) {
|
|
178
|
+
const server = serverAddress(stage, custom);
|
|
179
|
+
if (!server && domain && !isLocalHost(domain)) throw new ServerAddressMissing(stage, domain);
|
|
180
|
+
return server;
|
|
181
|
+
}
|
|
182
|
+
/** The types that point a name somewhere — a name holds a CNAME or the others. */
|
|
183
|
+
const ADDRESS_TYPES = [
|
|
184
|
+
"A",
|
|
185
|
+
"AAAA",
|
|
186
|
+
"CNAME"
|
|
187
|
+
];
|
|
188
|
+
/** Every public host the stack serves, once each, sorted. */
|
|
189
|
+
function stackHosts(stack) {
|
|
190
|
+
return [...new Set(stack.routes.map((route) => route.host))].sort();
|
|
191
|
+
}
|
|
192
|
+
/** The TTL a domain's records are written with. */
|
|
193
|
+
function recordTtl(config) {
|
|
194
|
+
const ttl = "ttl" in config ? config.ttl : void 0;
|
|
195
|
+
if (ttl) return ttl;
|
|
196
|
+
return config.provider === "godaddy" ? 600 : 300;
|
|
197
|
+
}
|
|
198
|
+
function providerName(config) {
|
|
199
|
+
return typeof config.provider === "string" ? config.provider : "custom";
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* A wildcard host that is not the stage's wildcard site's: gkm writes one
|
|
203
|
+
* record per public host, so a stage on another server — or a name someone
|
|
204
|
+
* else points elsewhere — is never caught by a record it did not ask for.
|
|
205
|
+
* Only `*.<domain>` for a site declared `subdomain: '*'` is written, and it
|
|
206
|
+
* covers no name that has a record of its own.
|
|
207
|
+
*/
|
|
208
|
+
var DnsWildcardRefused = class extends GkmError {
|
|
209
|
+
stage;
|
|
210
|
+
host;
|
|
211
|
+
constructor(stage, host) {
|
|
212
|
+
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.`);
|
|
213
|
+
this.stage = stage;
|
|
214
|
+
this.host = host;
|
|
215
|
+
this.name = "DnsWildcardRefused";
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
/** The records a stage's hosts need — pure. */
|
|
219
|
+
function planStackDns(input) {
|
|
220
|
+
const { stage, server } = input;
|
|
221
|
+
const dns = input.dns ? normalizeDnsConfig(input.dns) : {};
|
|
222
|
+
const records = /* @__PURE__ */ new Map();
|
|
223
|
+
const uncovered = [];
|
|
224
|
+
const add = (host, domain, type, value) => {
|
|
225
|
+
const name = extractSubdomain(host, domain);
|
|
226
|
+
records.set(`${domain} ${name} ${type}`, {
|
|
227
|
+
host,
|
|
228
|
+
domain,
|
|
229
|
+
name,
|
|
230
|
+
type,
|
|
231
|
+
value,
|
|
232
|
+
ttl: recordTtl(dns[domain])
|
|
233
|
+
});
|
|
234
|
+
};
|
|
235
|
+
const pointAt = (host, domain) => {
|
|
236
|
+
add(host, domain, "A", server.ipv4);
|
|
237
|
+
if (server.ipv6) add(host, domain, "AAAA", server.ipv6);
|
|
238
|
+
};
|
|
239
|
+
for (const raw of input.hosts) {
|
|
240
|
+
const host = raw.toLowerCase();
|
|
241
|
+
if (host.includes("*") && host !== input.wildcard?.toLowerCase()) throw new DnsWildcardRefused(stage, host);
|
|
242
|
+
const domain = findRootDomain(host, dns);
|
|
243
|
+
if (!domain) {
|
|
244
|
+
uncovered.push(host);
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
const target = cnameTarget(dns[domain].records, stage);
|
|
248
|
+
if (target) pointAt(target, domain);
|
|
249
|
+
if (target && host !== domain && host !== target) add(host, domain, "CNAME", target);
|
|
250
|
+
else pointAt(host, domain);
|
|
251
|
+
}
|
|
252
|
+
const domains = /* @__PURE__ */ new Map();
|
|
253
|
+
for (const record of [...records.values()].sort((a, b) => a.domain.localeCompare(b.domain) || a.name.localeCompare(b.name) || a.type.localeCompare(b.type))) {
|
|
254
|
+
const config = dns[record.domain];
|
|
255
|
+
const plan = domains.get(record.domain) ?? {
|
|
256
|
+
domain: record.domain,
|
|
257
|
+
provider: providerName(config),
|
|
258
|
+
config,
|
|
259
|
+
records: []
|
|
260
|
+
};
|
|
261
|
+
plan.records.push(record);
|
|
262
|
+
domains.set(record.domain, plan);
|
|
263
|
+
}
|
|
264
|
+
return {
|
|
265
|
+
stage,
|
|
266
|
+
server,
|
|
267
|
+
domains: [...domains.values()],
|
|
268
|
+
uncovered: uncovered.sort()
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
/** Records a provider accepted and then did not read back with their value. */
|
|
272
|
+
var DnsRecordsNotConfirmed = class extends GkmError {
|
|
273
|
+
stage;
|
|
274
|
+
domain;
|
|
275
|
+
provider;
|
|
276
|
+
records;
|
|
277
|
+
constructor(stage, domain, provider, records) {
|
|
278
|
+
const lines = records.map((r) => ` - ${r.host} ${r.type}: ${r.found.length > 0 ? r.found.join(", ") : "nothing"}, expected ${r.expected}`);
|
|
279
|
+
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.`);
|
|
280
|
+
this.stage = stage;
|
|
281
|
+
this.domain = domain;
|
|
282
|
+
this.provider = provider;
|
|
283
|
+
this.records = records;
|
|
284
|
+
this.name = "DnsRecordsNotConfirmed";
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
/** `api.example.com A 203.0.113.10 (TTL 600)` */
|
|
288
|
+
function describe(record) {
|
|
289
|
+
return `${record.host.padEnd(32)} ${record.type.padEnd(5)} ${record.value} (TTL ${record.ttl})`;
|
|
290
|
+
}
|
|
291
|
+
function printManual(plan, log, why) {
|
|
292
|
+
log(` ${plan.domain}: ${why} — create these records at its DNS host:`);
|
|
293
|
+
for (const record of plan.records) log(` ${describe(record)}`);
|
|
294
|
+
return plan.records.map((r) => ({
|
|
295
|
+
domain: r.domain,
|
|
296
|
+
name: r.name,
|
|
297
|
+
type: r.type,
|
|
298
|
+
action: "manual",
|
|
299
|
+
value: r.value,
|
|
300
|
+
ttl: r.ttl
|
|
301
|
+
}));
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* The existing records of every planned name: A, AAAA and CNAME where one of
|
|
305
|
+
* them is planned — what the name points at, and what a change of mode
|
|
306
|
+
* deletes — and MX where an MX is. No other type is read.
|
|
307
|
+
*/
|
|
308
|
+
async function existingRecords(provider, plan) {
|
|
309
|
+
const wanted = /* @__PURE__ */ new Map();
|
|
310
|
+
for (const record of plan.records) {
|
|
311
|
+
const types = ADDRESS_TYPES.includes(record.type) ? ADDRESS_TYPES : [record.type];
|
|
312
|
+
for (const type of types) wanted.set(`${record.name} ${type}`, {
|
|
313
|
+
name: record.name,
|
|
314
|
+
type
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
return readRecords(provider, plan.domain, [...wanted.values()]);
|
|
318
|
+
}
|
|
319
|
+
/** Exactly these names and types, as the provider holds them. */
|
|
320
|
+
async function readRecords(provider, domain, wanted) {
|
|
321
|
+
if (provider.readRecords) return provider.readRecords(domain, wanted);
|
|
322
|
+
return (await provider.getRecords(domain)).filter((r) => wanted.some((w) => w.name === r.name && w.type === r.type));
|
|
323
|
+
}
|
|
324
|
+
/** The provider for a domain's config: `providerFor`, or the real one. */
|
|
325
|
+
function providerResolver(options) {
|
|
326
|
+
return options.providerFor ?? ((config) => createDnsProvider({
|
|
327
|
+
config,
|
|
328
|
+
...options.credentials ? { godaddy: options.credentials } : {},
|
|
329
|
+
...options.hostinger ? { hostinger: options.hostinger } : {}
|
|
330
|
+
}));
|
|
331
|
+
}
|
|
332
|
+
/** Two values compared as DNS does: case, a trailing dot and spacing aside. */
|
|
333
|
+
const same = (a, b) => {
|
|
334
|
+
const normalize = (value) => value.trim().replace(/\.$/, "").replace(/\s+/g, " ").toLowerCase();
|
|
335
|
+
return normalize(a) === normalize(b);
|
|
336
|
+
};
|
|
337
|
+
/**
|
|
338
|
+
* What each domain's records need, compared with what is there: creates,
|
|
339
|
+
* updates, and the deletes a change of mode needs — a name moving from an A
|
|
340
|
+
* record to a CNAME, or back, cannot hold both. Nothing else is deleted: an
|
|
341
|
+
* MX planned at a name deletes nothing, and a CNAME or A planned at a name
|
|
342
|
+
* never deletes its MX.
|
|
343
|
+
*/
|
|
344
|
+
function diffDomainDns(plan, existing) {
|
|
345
|
+
const changes = [];
|
|
346
|
+
const find = (name, type) => existing.find((r) => r.name === name && r.type === type);
|
|
347
|
+
const planned = /* @__PURE__ */ new Map();
|
|
348
|
+
for (const record of plan.records) {
|
|
349
|
+
const types = planned.get(record.name) ?? /* @__PURE__ */ new Set();
|
|
350
|
+
types.add(record.type);
|
|
351
|
+
planned.set(record.name, types);
|
|
352
|
+
}
|
|
353
|
+
for (const [name, types] of planned) {
|
|
354
|
+
const conflicting = types.has("CNAME") ? ["A", "AAAA"] : types.has("A") || types.has("AAAA") ? ["CNAME"] : [];
|
|
355
|
+
for (const type of conflicting) {
|
|
356
|
+
const found = find(name, type);
|
|
357
|
+
if (!found || found.values.length === 0) continue;
|
|
358
|
+
changes.push({
|
|
359
|
+
domain: plan.domain,
|
|
360
|
+
name,
|
|
361
|
+
type,
|
|
362
|
+
action: "delete",
|
|
363
|
+
previous: found.values.join(", ")
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
for (const record of plan.records) {
|
|
368
|
+
const found = find(record.name, record.type);
|
|
369
|
+
const base = {
|
|
370
|
+
domain: plan.domain,
|
|
371
|
+
name: record.name,
|
|
372
|
+
type: record.type,
|
|
373
|
+
value: record.value,
|
|
374
|
+
ttl: record.ttl
|
|
375
|
+
};
|
|
376
|
+
if (!found || found.values.length === 0) changes.push({
|
|
377
|
+
...base,
|
|
378
|
+
action: "create"
|
|
379
|
+
});
|
|
380
|
+
else if (found.values.length === 1 && same(found.values[0], record.value)) changes.push({
|
|
381
|
+
...base,
|
|
382
|
+
action: "unchanged"
|
|
383
|
+
});
|
|
384
|
+
else changes.push({
|
|
385
|
+
...base,
|
|
386
|
+
action: "update",
|
|
387
|
+
previous: found.values.join(", ")
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
return changes;
|
|
391
|
+
}
|
|
392
|
+
/** A host's full name from a domain and a relative name. */
|
|
393
|
+
function fullName(domain, name) {
|
|
394
|
+
return name === "@" ? domain : `${name}.${domain}`;
|
|
395
|
+
}
|
|
396
|
+
function printChange(change, dryRun, log) {
|
|
397
|
+
const host = fullName(change.domain, change.name).padEnd(32);
|
|
398
|
+
const type = change.type.padEnd(5);
|
|
399
|
+
const would = dryRun ? "would " : "";
|
|
400
|
+
switch (change.action) {
|
|
401
|
+
case "unchanged":
|
|
402
|
+
log(` ✓ ${host} ${type} ${change.value} (TTL ${change.ttl}) — up to date`);
|
|
403
|
+
break;
|
|
404
|
+
case "create":
|
|
405
|
+
log(` + ${host} ${type} ${change.value} (TTL ${change.ttl}) — ${would}create`);
|
|
406
|
+
break;
|
|
407
|
+
case "update":
|
|
408
|
+
log(` ~ ${host} ${type} ${change.previous} → ${change.value} (TTL ${change.ttl}) — ${would}update`);
|
|
409
|
+
break;
|
|
410
|
+
case "write":
|
|
411
|
+
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)`);
|
|
412
|
+
break;
|
|
413
|
+
case "delete": log(` - ${host} ${type} ${change.previous} — ${would}delete (a name cannot hold a CNAME and an A record)`);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Each domain's records, through its provider — and, with `confirm`, what was
|
|
418
|
+
* written read back from it. A record already holding its value is neither
|
|
419
|
+
* written nor read again.
|
|
420
|
+
*
|
|
421
|
+
* @throws {DnsRecordsNotConfirmed} when a written record does not read back
|
|
422
|
+
*/
|
|
423
|
+
async function settleStackDns(plan, options = {}) {
|
|
424
|
+
const dryRun = options.dryRun === true;
|
|
425
|
+
const log = options.log ?? ((line) => console.log(line));
|
|
426
|
+
const providerFor = providerResolver(options);
|
|
427
|
+
const changes = [];
|
|
428
|
+
const confirmed = /* @__PURE__ */ new Set();
|
|
429
|
+
const unconfirmed = /* @__PURE__ */ new Set();
|
|
430
|
+
const hostsOf = (domain) => new Set(domain.records.map((r) => r.host));
|
|
431
|
+
for (const host of plan.uncovered) log(` ⚠ ${host} is under no domain in dns — point it at ${plan.server.ipv4} yourself`);
|
|
432
|
+
for (const domain of plan.domains) {
|
|
433
|
+
if (domain.provider === "manual") {
|
|
434
|
+
changes.push(...printManual(domain, log, "manual"));
|
|
435
|
+
for (const host of hostsOf(domain)) unconfirmed.add(host);
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
const provider = await providerFor(domain.config);
|
|
439
|
+
if (!provider) {
|
|
440
|
+
changes.push(...printManual(domain, log, "manual"));
|
|
441
|
+
for (const host of hostsOf(domain)) unconfirmed.add(host);
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
log(` ${domain.domain} (${provider.name})${dryRun ? " — dry run" : ""}`);
|
|
445
|
+
let existing;
|
|
446
|
+
let diff;
|
|
447
|
+
let unreadable = false;
|
|
448
|
+
try {
|
|
449
|
+
existing = await existingRecords(provider, domain);
|
|
450
|
+
diff = diffDomainDns(domain, existing);
|
|
451
|
+
} catch (error) {
|
|
452
|
+
if (!(error instanceof DnsRecordsUnreadable)) throw error;
|
|
453
|
+
log(` ℹ The ${provider.name} key cannot read ${domain.domain}'s DNS records, so changes cannot be diffed: every record is written (idempotent).`);
|
|
454
|
+
unreadable = true;
|
|
455
|
+
existing = [];
|
|
456
|
+
diff = domain.records.map((r) => ({
|
|
457
|
+
domain: r.domain,
|
|
458
|
+
name: r.name,
|
|
459
|
+
type: r.type,
|
|
460
|
+
action: "write",
|
|
461
|
+
value: r.value,
|
|
462
|
+
ttl: r.ttl
|
|
463
|
+
}));
|
|
464
|
+
}
|
|
465
|
+
for (const change of diff) printChange(change, dryRun, log);
|
|
466
|
+
if (!plan.server.ipv6) for (const name of new Set(domain.records.map((r) => r.name))) {
|
|
467
|
+
const aaaa = existing.find((r) => r.name === name && r.type === "AAAA");
|
|
468
|
+
const planned = domain.records.find((r) => r.name === name && r.type === "A");
|
|
469
|
+
if (aaaa && planned && aaaa.values.length > 0) log(` ⚠ ${fullName(domain.domain, name)} also has AAAA ${aaaa.values.join(", ")}: set ${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`);
|
|
470
|
+
}
|
|
471
|
+
changes.push(...diff);
|
|
472
|
+
const written = new Set(diff.filter((c) => c.action !== "unchanged").map((c) => fullName(c.domain, c.name)));
|
|
473
|
+
for (const host of hostsOf(domain)) if (unreadable) {
|
|
474
|
+
if (!dryRun) unconfirmed.add(host);
|
|
475
|
+
} else if (!written.has(host)) confirmed.add(host);
|
|
476
|
+
if (dryRun) continue;
|
|
477
|
+
const deletes = diff.filter((c) => c.action === "delete");
|
|
478
|
+
if (deletes.length > 0) await provider.deleteRecords(domain.domain, deletes.map((c) => ({
|
|
479
|
+
name: c.name,
|
|
480
|
+
type: c.type
|
|
481
|
+
})));
|
|
482
|
+
const writes = diff.filter((c) => c.action === "create" || c.action === "update" || c.action === "write");
|
|
483
|
+
if (writes.length > 0) await provider.upsertRecords(domain.domain, writes.map((c) => ({
|
|
484
|
+
name: c.name,
|
|
485
|
+
type: c.type,
|
|
486
|
+
value: c.value,
|
|
487
|
+
ttl: c.ttl
|
|
488
|
+
})));
|
|
489
|
+
if (!options.confirm || unreadable || written.size === 0) continue;
|
|
490
|
+
const rewritten = {
|
|
491
|
+
...domain,
|
|
492
|
+
records: domain.records.filter((r) => written.has(r.host))
|
|
493
|
+
};
|
|
494
|
+
const after = await existingRecords(provider, rewritten);
|
|
495
|
+
const missing = [];
|
|
496
|
+
for (const record of rewritten.records) {
|
|
497
|
+
const values = after.find((r) => r.name === record.name && r.type === record.type)?.values ?? [];
|
|
498
|
+
if (values.length !== 1 || !same(values[0], record.value)) missing.push({
|
|
499
|
+
host: record.host,
|
|
500
|
+
type: record.type,
|
|
501
|
+
expected: record.value,
|
|
502
|
+
found: values
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
if (missing.length > 0) throw new DnsRecordsNotConfirmed(plan.stage, domain.domain, provider.name, missing);
|
|
506
|
+
for (const host of written) confirmed.add(host);
|
|
507
|
+
log(` ✓ ${written.size} host${written.size === 1 ? "" : "s"} read back from ${provider.name}`);
|
|
508
|
+
}
|
|
509
|
+
for (const host of plan.uncovered) unconfirmed.add(host);
|
|
510
|
+
return {
|
|
511
|
+
changes,
|
|
512
|
+
confirmed: [...confirmed].sort(),
|
|
513
|
+
unconfirmed: [...unconfirmed].filter((h) => !confirmed.has(h)).sort()
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
/** `api.example.com A` — a record's identity, whatever its value. */
|
|
517
|
+
const recordKey = (fqdn, type) => `${fqdn.trim().replace(/\.$/, "").toLowerCase()} ${type.toUpperCase()}`;
|
|
518
|
+
/**
|
|
519
|
+
* The plan against the records gkm wrote for the stage — pure. A record is
|
|
520
|
+
* its full name and its type: one the plan has at another value is kept (the
|
|
521
|
+
* apply updates it), and one whose name or type the plan no longer has is
|
|
522
|
+
* stale — a host the stage stopped serving when its domain or an app changed,
|
|
523
|
+
* or an AAAA once its server has no IPv6 address.
|
|
524
|
+
*/
|
|
525
|
+
function diffRecordedDns(plan, recorded) {
|
|
526
|
+
const planned = plan.domains.flatMap((domain) => domain.records);
|
|
527
|
+
const wanted = new Set(planned.map((r) => recordKey(r.host, r.type)));
|
|
528
|
+
const written = new Set(recorded.map((r) => recordKey(r.fqdn, r.type)));
|
|
529
|
+
return {
|
|
530
|
+
added: planned.filter((r) => !written.has(recordKey(r.host, r.type))),
|
|
531
|
+
kept: planned.filter((r) => written.has(recordKey(r.host, r.type))),
|
|
532
|
+
stale: recorded.filter((r) => !wanted.has(recordKey(r.fqdn, r.type)))
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Each stale record deleted through its domain's provider — only where the
|
|
537
|
+
* provider still holds exactly the value gkm wrote, so a name someone has
|
|
538
|
+
* since pointed elsewhere is never taken from them. Where no provider can
|
|
539
|
+
* read and delete it — a `manual` domain, one gone from `dns`, a key that
|
|
540
|
+
* can only write — it is printed for a person to remove. A dry run reads
|
|
541
|
+
* and prints, and deletes nothing.
|
|
542
|
+
*/
|
|
543
|
+
async function pruneStackDns(stale, options) {
|
|
544
|
+
if (stale.length === 0) return [];
|
|
545
|
+
const dryRun = options.dryRun === true;
|
|
546
|
+
const log = options.log ?? ((line) => console.log(line));
|
|
547
|
+
const providerFor = providerResolver(options);
|
|
548
|
+
const dns = options.dns ? normalizeDnsConfig(options.dns) : {};
|
|
549
|
+
const byDomain = /* @__PURE__ */ new Map();
|
|
550
|
+
for (const record of stale) byDomain.set(record.domain, [...byDomain.get(record.domain) ?? [], record]);
|
|
551
|
+
log(` No longer served by '${options.stage}':`);
|
|
552
|
+
const pruned = [];
|
|
553
|
+
const byHand = (domain, records, why) => {
|
|
554
|
+
log(` ${domain}: ${why} — remove these records at its DNS host:`);
|
|
555
|
+
for (const record of records) {
|
|
556
|
+
log(` ${record.fqdn.padEnd(32)} ${record.type.padEnd(5)} ${record.value}`);
|
|
557
|
+
pruned.push({
|
|
558
|
+
record,
|
|
559
|
+
action: "manual"
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
};
|
|
563
|
+
for (const [domain, records] of byDomain) {
|
|
564
|
+
const config = dns[domain];
|
|
565
|
+
if (!config) {
|
|
566
|
+
byHand(domain, records, "no longer in dns");
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
569
|
+
const provider = providerName(config) === "manual" ? null : await providerFor(config);
|
|
570
|
+
if (!provider) {
|
|
571
|
+
byHand(domain, records, "manual");
|
|
572
|
+
continue;
|
|
573
|
+
}
|
|
574
|
+
let existing;
|
|
575
|
+
try {
|
|
576
|
+
existing = await readRecords(provider, domain, records.map((r) => ({
|
|
577
|
+
name: r.name,
|
|
578
|
+
type: r.type
|
|
579
|
+
})));
|
|
580
|
+
} catch (error) {
|
|
581
|
+
if (!(error instanceof DnsRecordsUnreadable)) throw error;
|
|
582
|
+
byHand(domain, records, `the ${provider.name} key cannot read its records, so none is deleted unchecked`);
|
|
583
|
+
continue;
|
|
584
|
+
}
|
|
585
|
+
const would = dryRun ? "would " : "";
|
|
586
|
+
const deletes = [];
|
|
587
|
+
for (const record of records) {
|
|
588
|
+
const host = record.fqdn.padEnd(32);
|
|
589
|
+
const type = record.type.padEnd(5);
|
|
590
|
+
const found = existing.find((r) => r.name === record.name && r.type === record.type)?.values ?? [];
|
|
591
|
+
if (found.length === 0) {
|
|
592
|
+
log(` · ${host} ${type} already gone`);
|
|
593
|
+
pruned.push({
|
|
594
|
+
record,
|
|
595
|
+
action: "gone"
|
|
596
|
+
});
|
|
597
|
+
} else if (found.length === 1 && same(found[0], record.value)) {
|
|
598
|
+
log(` - ${host} ${type} ${record.value} — ${would}delete`);
|
|
599
|
+
deletes.push({
|
|
600
|
+
record,
|
|
601
|
+
action: "delete"
|
|
602
|
+
});
|
|
603
|
+
} else {
|
|
604
|
+
log(` ⚠ ${host} ${type} ${found.join(", ")} — pointed elsewhere since gkm wrote ${record.value}; left as it is`);
|
|
605
|
+
pruned.push({
|
|
606
|
+
record,
|
|
607
|
+
action: "changed",
|
|
608
|
+
found
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
if (!dryRun && deletes.length > 0) await provider.deleteRecords(domain, deletes.map(({ record }) => ({
|
|
613
|
+
name: record.name,
|
|
614
|
+
type: record.type
|
|
615
|
+
})));
|
|
616
|
+
pruned.push(...deletes);
|
|
617
|
+
}
|
|
618
|
+
return pruned;
|
|
619
|
+
}
|
|
620
|
+
/** The system resolver: what the server's own clients would be told. */
|
|
621
|
+
const systemLookup = async (host) => {
|
|
622
|
+
return (await lookup(host, { all: true })).map((a) => a.address);
|
|
623
|
+
};
|
|
624
|
+
/** Hosts that do not resolve to the stage's server. */
|
|
625
|
+
var HostNotPointingAtServer = class extends GkmError {
|
|
626
|
+
stage;
|
|
627
|
+
hosts;
|
|
628
|
+
expected;
|
|
629
|
+
fix;
|
|
630
|
+
constructor(stage, hosts, expected, fix) {
|
|
631
|
+
const want = expected.ipv6 ? `${expected.ipv4} (and ${expected.ipv6})` : expected.ipv4;
|
|
632
|
+
const lines = hosts.map((h) => ` - ${h.host} → ${h.resolved.length > 0 ? h.resolved.join(", ") : `nothing${h.error ? ` (${h.error})` : ""}`}, expected ${want}`);
|
|
633
|
+
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.`);
|
|
634
|
+
this.stage = stage;
|
|
635
|
+
this.hosts = hosts;
|
|
636
|
+
this.expected = expected;
|
|
637
|
+
this.fix = fix;
|
|
638
|
+
this.name = "HostNotPointingAtServer";
|
|
639
|
+
}
|
|
640
|
+
};
|
|
641
|
+
/**
|
|
642
|
+
* The name a wildcard record is resolved through: one label no app takes,
|
|
643
|
+
* which only the `*` record answers.
|
|
644
|
+
*/
|
|
645
|
+
const WILDCARD_PROBE = "gkm-wildcard-check";
|
|
646
|
+
/**
|
|
647
|
+
* Every host resolved: each must resolve to the server's IPv4 address and to
|
|
648
|
+
* nothing but the server's addresses.
|
|
649
|
+
*
|
|
650
|
+
* @throws {HostNotPointingAtServer} naming every host that does not
|
|
651
|
+
*/
|
|
652
|
+
async function checkStackDns(input) {
|
|
653
|
+
const lookup = input.lookup ?? systemLookup;
|
|
654
|
+
const { server } = input;
|
|
655
|
+
const ours = new Set([server.ipv4, server.ipv6].filter(Boolean).map((a) => a.toLowerCase()));
|
|
656
|
+
const bad = [];
|
|
657
|
+
const ok = [];
|
|
658
|
+
for (const host of input.hosts) {
|
|
659
|
+
let resolved;
|
|
660
|
+
const asked = host.startsWith("*.") ? `${WILDCARD_PROBE}.${host.slice(2)}` : host;
|
|
661
|
+
try {
|
|
662
|
+
resolved = [...new Set(await lookup(asked))];
|
|
663
|
+
} catch (error) {
|
|
664
|
+
const code = error && typeof error === "object" && "code" in error ? String(error.code) : error instanceof Error ? error.message : String(error);
|
|
665
|
+
bad.push({
|
|
666
|
+
host,
|
|
667
|
+
resolved: [],
|
|
668
|
+
error: code
|
|
669
|
+
});
|
|
670
|
+
continue;
|
|
671
|
+
}
|
|
672
|
+
if (resolved.some((a) => a.toLowerCase() === server.ipv4.toLowerCase()) && resolved.every((a) => ours.has(a.toLowerCase()))) ok.push(host);
|
|
673
|
+
else bad.push({
|
|
674
|
+
host,
|
|
675
|
+
resolved
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
if (bad.length > 0) throw new HostNotPointingAtServer(input.stage, bad, {
|
|
679
|
+
ipv4: server.ipv4,
|
|
680
|
+
...server.ipv6 ? { ipv6: server.ipv6 } : {}
|
|
681
|
+
}, dnsFix(input, bad));
|
|
682
|
+
return ok;
|
|
683
|
+
}
|
|
684
|
+
/** How to fix it: the deploy, or the records to create by hand. */
|
|
685
|
+
function dnsFix(input, bad) {
|
|
686
|
+
const hosts = bad.map((h) => h.host);
|
|
687
|
+
let plan;
|
|
688
|
+
try {
|
|
689
|
+
plan = planStackDns({
|
|
690
|
+
stage: input.stage,
|
|
691
|
+
hosts,
|
|
692
|
+
server: input.server,
|
|
693
|
+
dns: input.dns
|
|
694
|
+
});
|
|
695
|
+
} catch {
|
|
696
|
+
plan = {
|
|
697
|
+
stage: input.stage,
|
|
698
|
+
server: input.server,
|
|
699
|
+
domains: [],
|
|
700
|
+
uncovered: hosts
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
const automatic = plan.domains.filter((d) => d.provider !== "manual");
|
|
704
|
+
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}`] : []])];
|
|
705
|
+
const lines = [];
|
|
706
|
+
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).`);
|
|
707
|
+
if (byHand.length > 0) lines.push(`${automatic.length > 0 ? "And create" : "Fix: create"} these records at the DNS host:`, ...byHand.map((line) => ` ${line}`));
|
|
708
|
+
return lines.join("\n");
|
|
709
|
+
}
|
|
710
|
+
/** The environment variable each token-authenticated provider reads. */
|
|
711
|
+
const DNS_TOKEN_KEYS = {
|
|
712
|
+
godaddy: "GODADDY_API_TOKEN",
|
|
713
|
+
hostinger: "HOSTINGER_API_TOKEN"
|
|
714
|
+
};
|
|
715
|
+
/**
|
|
716
|
+
* A domain whose records the deploy writes, and no token to write them with.
|
|
717
|
+
* Raised before anything is built, started or written.
|
|
718
|
+
*/
|
|
719
|
+
var DnsCredentialMissing = class extends GkmError {
|
|
720
|
+
stage;
|
|
721
|
+
domain;
|
|
722
|
+
provider;
|
|
723
|
+
key;
|
|
724
|
+
constructor(stage, domain, provider, key) {
|
|
725
|
+
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.`);
|
|
726
|
+
this.stage = stage;
|
|
727
|
+
this.domain = domain;
|
|
728
|
+
this.provider = provider;
|
|
729
|
+
this.key = key;
|
|
730
|
+
this.name = "DnsCredentialMissing";
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
/**
|
|
734
|
+
* The `dns` domain a stage's own domain (`domains.<stage>`) is under — where
|
|
735
|
+
* its hosts' records go — or none.
|
|
736
|
+
*/
|
|
737
|
+
function stageDnsDomains(stage, domains, dns) {
|
|
738
|
+
const own = domains?.[stage];
|
|
739
|
+
if (!own || !dns || isLocalHost(own)) return [];
|
|
740
|
+
const normalized = normalizeDnsConfig(dns);
|
|
741
|
+
const root = findRootDomain(own.toLowerCase(), normalized);
|
|
742
|
+
return root ? [{
|
|
743
|
+
domain: root,
|
|
744
|
+
config: normalized[root]
|
|
745
|
+
}] : [];
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Each token the domains' providers need, from `credentials` — `manual`,
|
|
749
|
+
* Route53 (the AWS SDK's own chain) and a provider object need none.
|
|
750
|
+
*
|
|
751
|
+
* @throws {DnsCredentialMissing} naming the first domain with no token
|
|
752
|
+
*/
|
|
753
|
+
async function dnsCredentials(stage, domains, credentials) {
|
|
754
|
+
const found = {};
|
|
755
|
+
for (const { domain, config } of domains) {
|
|
756
|
+
const provider = config.provider;
|
|
757
|
+
if (provider !== "godaddy" && provider !== "hostinger") continue;
|
|
758
|
+
if (found[provider]) continue;
|
|
759
|
+
const token = await credentials.get({ kind: provider });
|
|
760
|
+
if (!token?.token) throw new DnsCredentialMissing(stage, domain, provider, DNS_TOKEN_KEYS[provider]);
|
|
761
|
+
found[provider] = token;
|
|
762
|
+
}
|
|
763
|
+
return found;
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* A stage's DNS, as every deploy runs it: the
|
|
767
|
+
* stage's own hosts planned, written through each domain's provider where
|
|
768
|
+
* they differ, and read back from it — and each record gkm wrote for a host
|
|
769
|
+
* the stage no longer serves found, for `prune` to delete. Only A, AAAA and CNAME records of those
|
|
770
|
+
* names are touched; nothing is a wildcard but a wildcard site's
|
|
771
|
+
* `*.<domain>`, and no other name is read,
|
|
772
|
+
* written or deleted. What no provider confirms — a `manual` domain, a host
|
|
773
|
+
* under no domain in `dns`, a key that cannot read — is resolved publicly.
|
|
774
|
+
* A dry run prints the plan and writes nothing.
|
|
775
|
+
*
|
|
776
|
+
* @throws {DnsCredentialMissing} before anything is read or written
|
|
777
|
+
* @throws {DnsRecordsNotConfirmed} when a written record does not read back
|
|
778
|
+
* @throws {HostNotPointingAtServer} when a resolved host is not the server
|
|
779
|
+
*/
|
|
780
|
+
async function stageDns(input) {
|
|
781
|
+
const { stage, server } = input;
|
|
782
|
+
const log = input.log ?? ((line) => console.log(line));
|
|
783
|
+
const plan = planStackDns({
|
|
784
|
+
stage,
|
|
785
|
+
hosts: input.hosts,
|
|
786
|
+
server,
|
|
787
|
+
dns: input.dns,
|
|
788
|
+
...input.wildcard ? { wildcard: input.wildcard } : {}
|
|
789
|
+
});
|
|
790
|
+
const recorded = diffRecordedDns(plan, input.recorded ?? []);
|
|
791
|
+
const dns = input.dns ? normalizeDnsConfig(input.dns) : {};
|
|
792
|
+
const staleDomains = [...new Set(recorded.stale.map((r) => r.domain))].filter((domain) => dns[domain] && !plan.domains.some((d) => d.domain === domain)).map((domain) => ({
|
|
793
|
+
domain,
|
|
794
|
+
config: dns[domain]
|
|
795
|
+
}));
|
|
796
|
+
const tokens = await dnsCredentials(stage, [...plan.domains.map(({ domain, config }) => ({
|
|
797
|
+
domain,
|
|
798
|
+
config
|
|
799
|
+
})), ...staleDomains], input.credentials);
|
|
800
|
+
const providers = {
|
|
801
|
+
log,
|
|
802
|
+
credentials: {
|
|
803
|
+
...input.godaddy ?? {},
|
|
804
|
+
...tokens.godaddy ? { credential: tokens.godaddy } : {},
|
|
805
|
+
log
|
|
806
|
+
},
|
|
807
|
+
...tokens.hostinger ? { hostinger: tokens.hostinger } : {},
|
|
808
|
+
...input.providerFor ? { providerFor: input.providerFor } : {}
|
|
809
|
+
};
|
|
810
|
+
const applied = !input.dns ? {
|
|
811
|
+
changes: [],
|
|
812
|
+
confirmed: [],
|
|
813
|
+
unconfirmed: [...plan.uncovered]
|
|
814
|
+
} : await settleStackDns(plan, {
|
|
815
|
+
...input.dryRun ? { dryRun: true } : { confirm: true },
|
|
816
|
+
...providers
|
|
817
|
+
});
|
|
818
|
+
const deleted = new Set(applied.changes.filter((c) => c.action === "delete").map((c) => recordKey(fullName(c.domain, c.name), c.type)));
|
|
819
|
+
const stale = recorded.stale.filter((r) => !deleted.has(recordKey(r.fqdn, r.type)));
|
|
820
|
+
const prune = () => pruneStackDns(stale, {
|
|
821
|
+
stage,
|
|
822
|
+
dns: input.dns,
|
|
823
|
+
...input.dryRun ? { dryRun: true } : {},
|
|
824
|
+
...providers
|
|
825
|
+
});
|
|
826
|
+
let resolved = [];
|
|
827
|
+
if (applied.unconfirmed.length > 0) resolved = await checkStackDns({
|
|
828
|
+
stage,
|
|
829
|
+
hosts: applied.unconfirmed,
|
|
830
|
+
server,
|
|
831
|
+
dns: input.dns,
|
|
832
|
+
...input.lookup ? { lookup: input.lookup } : {}
|
|
833
|
+
});
|
|
834
|
+
return {
|
|
835
|
+
plan,
|
|
836
|
+
changes: applied.changes,
|
|
837
|
+
confirmed: applied.confirmed,
|
|
838
|
+
resolved,
|
|
839
|
+
recorded,
|
|
840
|
+
prune
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
//#endregion
|
|
844
|
+
//#region src/deploy/snsSubscriptions.ts
|
|
845
|
+
/** The type every recorded subscription has in the stage's state. */
|
|
846
|
+
const SUBSCRIPTION_TYPE = "sns-subscription";
|
|
847
|
+
/** The state key a subscriber's SNS subscription is recorded under. */
|
|
848
|
+
const subscriptionKey = (worker, name) => `${SUBSCRIPTION_TYPE}:${worker}/${name}`;
|
|
849
|
+
/** What a recorded subscription is written to the stage's state as. */
|
|
850
|
+
function subscriptionResource(subscription, arn) {
|
|
851
|
+
const { name, ...data } = subscription;
|
|
852
|
+
return {
|
|
853
|
+
key: subscriptionKey(subscription.worker, name),
|
|
854
|
+
type: SUBSCRIPTION_TYPE,
|
|
855
|
+
id: arn,
|
|
856
|
+
status: "ready",
|
|
857
|
+
data: {
|
|
858
|
+
...data,
|
|
859
|
+
...data.events ? { events: [...data.events] } : {}
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
/** The subscription a record holds, as an endpoint to reconcile. */
|
|
864
|
+
function specOf(record) {
|
|
865
|
+
const events = record.data?.events;
|
|
866
|
+
return {
|
|
867
|
+
name: record.key.split("/").pop(),
|
|
868
|
+
endpoint: String(record.data?.endpoint),
|
|
869
|
+
...record.data?.deadLetterQueueArn ? { deadLetterQueueArn: String(record.data.deadLetterQueueArn) } : {},
|
|
870
|
+
...Array.isArray(events) ? { events: events.map(String) } : {}
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* The subscriptions the deploy recorded, by worker and export — what each
|
|
875
|
+
* worker is handed as `GKM_SNS_SUBSCRIPTIONS`.
|
|
876
|
+
*/
|
|
877
|
+
function recordedPushSubscriptions(resources) {
|
|
878
|
+
const byWorker = {};
|
|
879
|
+
for (const record of Object.values(resources ?? {})) {
|
|
880
|
+
if (record.type !== "sns-subscription" || !record.id) continue;
|
|
881
|
+
const [worker, name] = record.key.slice(`${SUBSCRIPTION_TYPE}:`.length).split("/");
|
|
882
|
+
if (!worker || !name) continue;
|
|
883
|
+
byWorker[worker] = {
|
|
884
|
+
...byWorker[worker],
|
|
885
|
+
[name]: record.id
|
|
886
|
+
};
|
|
887
|
+
}
|
|
888
|
+
return byWorker;
|
|
889
|
+
}
|
|
890
|
+
/** A topic connection string the deploy cannot sign with. */
|
|
891
|
+
var TopicSubscriptionUnsigned = class extends GkmError {
|
|
892
|
+
connectionKey;
|
|
893
|
+
constructor(connectionKey) {
|
|
894
|
+
super(`'${connectionKey}' carries no keys, and the deploy found no AWS credentials of its own to subscribe the worker's routes with. Put accessKeyId and secretAccessKey in it — keys allowed sns:Subscribe, sns:ListSubscriptionsByTopic, sns:GetSubscriptionAttributes, sns:SetSubscriptionAttributes and sns:Unsubscribe on the topic — or sign in with \`gkm login\`.`);
|
|
895
|
+
this.connectionKey = connectionKey;
|
|
896
|
+
this.name = "TopicSubscriptionUnsigned";
|
|
897
|
+
}
|
|
898
|
+
};
|
|
899
|
+
/**
|
|
900
|
+
* A connection to the topic a stage's connection string names, signed with
|
|
901
|
+
* its own keys — or, carrying none, the deploy's.
|
|
902
|
+
*
|
|
903
|
+
* The emulator the environment points the SDK at stands in for SNS, as it
|
|
904
|
+
* does for every provider: a string with no `endpoint` is SNS itself.
|
|
905
|
+
*
|
|
906
|
+
* @throws {TopicSubscriptionUnsigned} with no keys from either
|
|
907
|
+
*/
|
|
908
|
+
async function topicConnection(input) {
|
|
909
|
+
const { SNSConnection, snsUrl } = await import("@geekmidas/events/sns");
|
|
910
|
+
const { topicArn, region, endpoint } = snsUrl.parse(input.connectionString);
|
|
911
|
+
const params = new URL(input.connectionString).searchParams;
|
|
912
|
+
const accessKeyId = params.get("accessKeyId");
|
|
913
|
+
const secretAccessKey = params.get("secretAccessKey");
|
|
914
|
+
const where = region ?? topicArn.split(":")[3];
|
|
915
|
+
let credentials;
|
|
916
|
+
if (accessKeyId && secretAccessKey) {
|
|
917
|
+
const sessionToken = params.get("sessionToken");
|
|
918
|
+
credentials = {
|
|
919
|
+
accessKeyId,
|
|
920
|
+
secretAccessKey,
|
|
921
|
+
...sessionToken ? { sessionToken } : {}
|
|
922
|
+
};
|
|
923
|
+
} else {
|
|
924
|
+
const provisioning = await awsProvisioningCredentials({
|
|
925
|
+
stage: input.stage,
|
|
926
|
+
env: input.env,
|
|
927
|
+
...input.home ? { home: input.home } : {}
|
|
928
|
+
});
|
|
929
|
+
if (!provisioning) throw new TopicSubscriptionUnsigned(input.connectionKey);
|
|
930
|
+
credentials = (await awsClientConfig(provisioning, where ?? "us-east-1")).credentials;
|
|
931
|
+
}
|
|
932
|
+
const override = endpoint ?? awsEndpoint(input.env, "SNS");
|
|
933
|
+
return new SNSConnection({
|
|
934
|
+
topicArn,
|
|
935
|
+
...where ? { region: where } : {},
|
|
936
|
+
...override ? { endpoint: override } : {},
|
|
937
|
+
...credentials ? { credentials } : {}
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
/** A subscription still waiting to be confirmed once its worker is up. */
|
|
941
|
+
var PushSubscriptionsUnconfirmed = class extends GkmError {
|
|
942
|
+
endpoints;
|
|
943
|
+
constructor(endpoints) {
|
|
944
|
+
super(`SNS still waits for ${endpoints.join(", ")} to confirm ${endpoints.length === 1 ? "its subscription" : "their subscriptions"}, so nothing is pushed there yet. Check the worker's logs for the confirmation it refused, and that its host answers from the internet; the next deploy sends the confirmation again.`);
|
|
945
|
+
this.endpoints = endpoints;
|
|
946
|
+
this.name = "PushSubscriptionsUnconfirmed";
|
|
947
|
+
}
|
|
948
|
+
};
|
|
949
|
+
/**
|
|
950
|
+
* Once the workers are up: every subscription recorded as pending is
|
|
951
|
+
* subscribed again — SNS resends its confirmation to a worker now there to
|
|
952
|
+
* answer it — and waited on until confirmed.
|
|
953
|
+
*
|
|
954
|
+
* The first deploy needs it: the subscription is made before the worker
|
|
955
|
+
* starts, so SNS's first confirmation finds nobody.
|
|
956
|
+
*
|
|
957
|
+
* A bucket's subscriptions are reached with the deploy's provisioning
|
|
958
|
+
* credentials; a hand-set topic's with the connection string they were made
|
|
959
|
+
* with, read from the stage's secrets.
|
|
960
|
+
*
|
|
961
|
+
* @returns what is still pending when the wait ran out — none, normally.
|
|
962
|
+
*/
|
|
963
|
+
async function confirmPendingSubscriptions(input) {
|
|
964
|
+
const env = input.env ?? process.env;
|
|
965
|
+
const records = Object.values(input.resources ?? {}).filter((r) => r.type === "sns-subscription" && r.id);
|
|
966
|
+
if (!records.some((r) => r.data?.pending === true)) return [];
|
|
967
|
+
const { SNSConnection, reconcileHttpSubscriptions } = await import("@geekmidas/events/sns");
|
|
968
|
+
const { GetSubscriptionAttributesCommand } = await import("@aws-sdk/client-sns");
|
|
969
|
+
const endpoint = awsEndpoint(env, "SNS");
|
|
970
|
+
let provisioning = null;
|
|
971
|
+
const groups = /* @__PURE__ */ new Map();
|
|
972
|
+
for (const record of records) {
|
|
973
|
+
const host = new URL(String(record.data?.endpoint)).host;
|
|
974
|
+
const group = `${record.data?.topicArn}|${host}`;
|
|
975
|
+
groups.set(group, [...groups.get(group) ?? [], record]);
|
|
976
|
+
}
|
|
977
|
+
const left = [];
|
|
978
|
+
for (const [group, members] of groups) {
|
|
979
|
+
const pending = members.filter((r) => r.data?.pending === true);
|
|
980
|
+
if (pending.length === 0) continue;
|
|
981
|
+
const [topicArn, host] = group.split("|");
|
|
982
|
+
const unreachable = () => left.push(...pending.map((r) => String(r.data?.endpoint)));
|
|
983
|
+
let connection;
|
|
984
|
+
const connectionKey = members[0].data?.connectionKey;
|
|
985
|
+
if (typeof connectionKey === "string") {
|
|
986
|
+
const connectionString = input.secrets?.[connectionKey];
|
|
987
|
+
if (!connectionString?.startsWith("sns:")) {
|
|
988
|
+
unreachable();
|
|
989
|
+
continue;
|
|
990
|
+
}
|
|
991
|
+
connection = await topicConnection({
|
|
992
|
+
connectionKey,
|
|
993
|
+
connectionString,
|
|
994
|
+
stage: input.stage,
|
|
995
|
+
env,
|
|
996
|
+
...input.home ? { home: input.home } : {}
|
|
997
|
+
});
|
|
998
|
+
} else {
|
|
999
|
+
if (provisioning === null) provisioning = await awsProvisioningCredentials({
|
|
1000
|
+
stage: input.stage,
|
|
1001
|
+
env,
|
|
1002
|
+
...input.home ? { home: input.home } : {}
|
|
1003
|
+
});
|
|
1004
|
+
if (!provisioning) {
|
|
1005
|
+
unreachable();
|
|
1006
|
+
continue;
|
|
1007
|
+
}
|
|
1008
|
+
const region = topicArn.split(":")[3];
|
|
1009
|
+
const { credentials } = await awsClientConfig(provisioning, region);
|
|
1010
|
+
connection = new SNSConnection({
|
|
1011
|
+
topicArn,
|
|
1012
|
+
region,
|
|
1013
|
+
...endpoint ? { endpoint } : {},
|
|
1014
|
+
...credentials ? { credentials } : {}
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
await reconcileHttpSubscriptions(connection, {
|
|
1018
|
+
endpoints: members.map(specOf),
|
|
1019
|
+
ownedHost: host
|
|
1020
|
+
});
|
|
1021
|
+
const deadline = Date.now() + (input.timeoutMs ?? 6e4);
|
|
1022
|
+
for (const record of pending) {
|
|
1023
|
+
let confirmed = false;
|
|
1024
|
+
while (!confirmed) {
|
|
1025
|
+
const { Attributes = {} } = await connection.snsClient.send(new GetSubscriptionAttributesCommand({ SubscriptionArn: record.id }));
|
|
1026
|
+
confirmed = Attributes.PendingConfirmation !== "true";
|
|
1027
|
+
if (confirmed || Date.now() > deadline) break;
|
|
1028
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
1029
|
+
}
|
|
1030
|
+
if (confirmed) {
|
|
1031
|
+
input.log?.(` ✓ ${record.data?.endpoint} confirmed its subscription`);
|
|
1032
|
+
await input.record?.({
|
|
1033
|
+
...record,
|
|
1034
|
+
data: {
|
|
1035
|
+
...record.data,
|
|
1036
|
+
pending: false
|
|
1037
|
+
}
|
|
1038
|
+
});
|
|
1039
|
+
} else left.push(String(record.data?.endpoint));
|
|
1040
|
+
}
|
|
1041
|
+
await connection.close();
|
|
1042
|
+
}
|
|
1043
|
+
return left;
|
|
1044
|
+
}
|
|
1045
|
+
//#endregion
|
|
1046
|
+
export { stageDnsDomains as _, subscriptionKey as a, awsEndpoint as b, HostNotPointingAtServer as c, recordTtl as d, requiredServerAddress as f, stageDns as g, stackHosts as h, recordedPushSubscriptions as i, dnsCredentials as l, settleStackDns as m, SUBSCRIPTION_TYPE as n, subscriptionResource as o, serverAddressHint as p, confirmPendingSubscriptions as r, topicConnection as s, PushSubscriptionsUnconfirmed as t, isLocalHost as u, systemLookup as v, awsProvisioningCredentials as x, awsClientConfig as y };
|
|
1047
|
+
|
|
1048
|
+
//# sourceMappingURL=snsSubscriptions-CrmfcJfv.mjs.map
|