@geekmidas/cli 10.0.0-alpha.164 → 10.0.0-alpha.166
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-DSzYpSc3.cjs → GoDaddyProvider-DClFHezd.cjs} +2 -2
- package/dist/{GoDaddyProvider-DSzYpSc3.cjs.map → GoDaddyProvider-DClFHezd.cjs.map} +1 -1
- package/dist/{GoDaddyProvider-BrZ7WtmP.mjs → GoDaddyProvider-mnY-cdD2.mjs} +2 -2
- package/dist/{GoDaddyProvider-BrZ7WtmP.mjs.map → GoDaddyProvider-mnY-cdD2.mjs.map} +1 -1
- package/dist/{HostingerProvider-D7N8GbQm.mjs → HostingerProvider-39eSGyBa.mjs} +2 -2
- package/dist/{HostingerProvider-D7N8GbQm.mjs.map → HostingerProvider-39eSGyBa.mjs.map} +1 -1
- package/dist/{HostingerProvider-DQusFkZJ.cjs → HostingerProvider-BMyz2LnZ.cjs} +2 -2
- package/dist/{HostingerProvider-DQusFkZJ.cjs.map → HostingerProvider-BMyz2LnZ.cjs.map} +1 -1
- package/dist/{LegacyStateStore-B2vZVXVe.mjs → LegacyStateStore-B2TBaSMq.mjs} +3 -3
- package/dist/{LegacyStateStore-B2vZVXVe.mjs.map → LegacyStateStore-B2TBaSMq.mjs.map} +1 -1
- package/dist/{LegacyStateStore-CxQkI3fQ.cjs → LegacyStateStore-BJY7ntQk.cjs} +3 -3
- package/dist/{LegacyStateStore-CxQkI3fQ.cjs.map → LegacyStateStore-BJY7ntQk.cjs.map} +1 -1
- package/dist/{LocalStateStore-ff4XiebR.mjs → LocalStateStore-8LFd-aMA.mjs} +2 -2
- package/dist/{LocalStateStore-ff4XiebR.mjs.map → LocalStateStore-8LFd-aMA.mjs.map} +1 -1
- package/dist/{LocalStateStore-CrrjFgMc.cjs → LocalStateStore-BvoEjPi5.cjs} +2 -2
- package/dist/{LocalStateStore-CrrjFgMc.cjs.map → LocalStateStore-BvoEjPi5.cjs.map} +1 -1
- package/dist/{S3StateStore-62sFppnE.mjs → S3StateStore-DMzsqfSa.mjs} +4 -4
- package/dist/{S3StateStore-62sFppnE.mjs.map → S3StateStore-DMzsqfSa.mjs.map} +1 -1
- package/dist/{S3StateStore-EnatbBd3.cjs → S3StateStore-eeA5NXRa.cjs} +4 -4
- package/dist/{S3StateStore-EnatbBd3.cjs.map → S3StateStore-eeA5NXRa.cjs.map} +1 -1
- package/dist/{SSMStateStore-CYPYh1c7.cjs → SSMStateStore-BUv-du0T.cjs} +2 -2
- package/dist/{SSMStateStore-CYPYh1c7.cjs.map → SSMStateStore-BUv-du0T.cjs.map} +1 -1
- package/dist/{SSMStateStore-BON4jyRR.mjs → SSMStateStore-CE2DTAtT.mjs} +2 -2
- package/dist/{SSMStateStore-BON4jyRR.mjs.map → SSMStateStore-CE2DTAtT.mjs.map} +1 -1
- package/dist/{add-CzoX8swL.mjs → add-BgCYGJpE.mjs} +6 -6
- package/dist/{add-CzoX8swL.mjs.map → add-BgCYGJpE.mjs.map} +1 -1
- package/dist/{add-D65M2URP.cjs → add-Dp0KQNkQ.cjs} +7 -7
- package/dist/{add-D65M2URP.cjs.map → add-Dp0KQNkQ.cjs.map} +1 -1
- package/dist/{apps-Dquc1K9N.mjs → apps-CJTOIaz3.mjs} +4 -5
- package/dist/{apps-Dquc1K9N.mjs.map → apps-CJTOIaz3.mjs.map} +1 -1
- package/dist/{apps-DY82zCeA.cjs → apps-DkMR-qvD.cjs} +22 -23
- package/dist/{apps-DY82zCeA.cjs.map → apps-DkMR-qvD.cjs.map} +1 -1
- package/dist/{bundler-wtMYRk9K.cjs → bundler-CA7KimJ0.cjs} +6 -6
- package/dist/{bundler-wtMYRk9K.cjs.map → bundler-CA7KimJ0.cjs.map} +1 -1
- package/dist/{bundler-9RpLU2H3.mjs → bundler-Dt1ffXl6.mjs} +6 -6
- package/dist/{bundler-9RpLU2H3.mjs.map → bundler-Dt1ffXl6.mjs.map} +1 -1
- package/dist/{cli-D0Tu6u1G.mjs → cli-C-fdEb8N.mjs} +5 -5
- package/dist/{cli-D0Tu6u1G.mjs.map → cli-C-fdEb8N.mjs.map} +1 -1
- package/dist/{cli-CgZuiNWv.cjs → cli-CY1Cp8yN.cjs} +5 -5
- package/dist/{cli-CgZuiNWv.cjs.map → cli-CY1Cp8yN.cjs.map} +1 -1
- package/dist/{compose-DgBUpgXh.cjs → compose-BIm9yNH7.cjs} +6 -6
- package/dist/{compose-DgBUpgXh.cjs.map → compose-BIm9yNH7.cjs.map} +1 -1
- package/dist/{compose-pbLaJlts.mjs → compose-CZGeE6QJ.mjs} +6 -6
- package/dist/{compose-pbLaJlts.mjs.map → compose-CZGeE6QJ.mjs.map} +1 -1
- package/dist/{compose-kEjxTamg.cjs → compose-SmuCWWUh.cjs} +22 -10
- package/dist/compose-SmuCWWUh.cjs.map +1 -0
- package/dist/{compose-BfTrMiAk.mjs → compose-tX6YTa1U.mjs} +22 -10
- package/dist/compose-tX6YTa1U.mjs.map +1 -0
- package/dist/{config-DNoWqavN.d.cts → config-B8gSu59v.d.mts} +3 -3
- package/dist/{config-BxSSAzVi.d.mts.map → config-B8gSu59v.d.mts.map} +1 -1
- package/dist/{config-BxSSAzVi.d.mts → config-u5XdE1Cq.d.cts} +3 -3
- package/dist/{config-DNoWqavN.d.cts.map → config-u5XdE1Cq.d.cts.map} +1 -1
- package/dist/config.cjs +457 -19
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +3 -3
- package/dist/config.d.mts +3 -3
- package/dist/config.mjs +440 -2
- package/dist/config.mjs.map +1 -0
- package/dist/{credentials-Bel6afW2.cjs → credentials-CS3Dr-pv.cjs} +6 -6
- package/dist/{credentials-Bel6afW2.cjs.map → credentials-CS3Dr-pv.cjs.map} +1 -1
- package/dist/{credentials-BgtOz5ec.mjs → credentials-V3WgiKmZ.mjs} +6 -6
- package/dist/{credentials-BgtOz5ec.mjs.map → credentials-V3WgiKmZ.mjs.map} +1 -1
- package/dist/deploy/public.cjs +13 -13
- package/dist/deploy/public.d.cts +4 -4
- package/dist/deploy/public.d.mts +4 -4
- package/dist/deploy/public.mjs +13 -13
- package/dist/{deploy-C4V-nsOF.cjs → deploy--ia-CGMv.cjs} +174 -68
- package/dist/deploy--ia-CGMv.cjs.map +1 -0
- package/dist/{deploy-D-5ib-ah.mjs → deploy-BWFFSN5p.mjs} +166 -60
- package/dist/deploy-BWFFSN5p.mjs.map +1 -0
- package/dist/{destroy-DuQqz53a.cjs → destroy-CrxF8Dlk.cjs} +12 -12
- package/dist/{destroy-DuQqz53a.cjs.map → destroy-CrxF8Dlk.cjs.map} +1 -1
- package/dist/{destroy-CYQCEn4A.mjs → destroy-ZNiKL3--.mjs} +12 -12
- package/dist/{destroy-CYQCEn4A.mjs.map → destroy-ZNiKL3--.mjs.map} +1 -1
- package/dist/{docker-BMReDeMB.cjs → docker-BtUjo-J_.cjs} +9 -8
- package/dist/{docker-BMReDeMB.cjs.map → docker-BtUjo-J_.cjs.map} +1 -1
- package/dist/{docker-BEsTfsFc.mjs → docker-DhmU416x.mjs} +6 -5
- package/dist/{docker-BEsTfsFc.mjs.map → docker-DhmU416x.mjs.map} +1 -1
- package/dist/{dokploy-BuYCnz9U.mjs → dokploy-BszAUbbA.mjs} +2 -2
- package/dist/{dokploy-BuYCnz9U.mjs.map → dokploy-BszAUbbA.mjs.map} +1 -1
- package/dist/{dokploy-BpPAgZ0u.cjs → dokploy-ComPiFLl.cjs} +2 -2
- package/dist/{dokploy-BpPAgZ0u.cjs.map → dokploy-ComPiFLl.cjs.map} +1 -1
- package/dist/{eas-DjVtUdb4.mjs → eas-DQudP2g2.mjs} +3 -3
- package/dist/{eas-DjVtUdb4.mjs.map → eas-DQudP2g2.mjs.map} +1 -1
- package/dist/{eas-H-6ixmsY.cjs → eas-zxVAWY6c.cjs} +6 -6
- package/dist/{eas-H-6ixmsY.cjs.map → eas-zxVAWY6c.cjs.map} +1 -1
- package/dist/{encryption-CR4aMkSK.mjs → encryption-BCaweYBJ.mjs} +4 -4
- package/dist/{encryption-CR4aMkSK.mjs.map → encryption-BCaweYBJ.mjs.map} +1 -1
- package/dist/{encryption-BvCsBp2p.cjs → encryption-CU5O0Y61.cjs} +4 -4
- package/dist/{encryption-BvCsBp2p.cjs.map → encryption-CU5O0Y61.cjs.map} +1 -1
- package/dist/{engine-upEpdhEF.mjs → engine-BzeCK6e8.mjs} +10 -11
- package/dist/{engine-upEpdhEF.mjs.map → engine-BzeCK6e8.mjs.map} +1 -1
- package/dist/{engine-CV2wqRFl.cjs → engine-xrlcbr1g.cjs} +11 -12
- package/dist/{engine-CV2wqRFl.cjs.map → engine-xrlcbr1g.cjs.map} +1 -1
- package/dist/{github-D2l7aqFx.mjs → github-CHClpJZS.mjs} +116 -72
- package/dist/github-CHClpJZS.mjs.map +1 -0
- package/dist/{github-BDOLgdMp.cjs → github-Jcrqfzg0.cjs} +116 -72
- package/dist/github-Jcrqfzg0.cjs.map +1 -0
- package/dist/{googlePlay-DJ2Kv0UX.mjs → googlePlay-Dk_pnif9.mjs} +5 -5
- package/dist/{googlePlay-DJ2Kv0UX.mjs.map → googlePlay-Dk_pnif9.mjs.map} +1 -1
- package/dist/{googlePlay-B3FR1VGL.cjs → googlePlay-e_tIBr4n.cjs} +5 -5
- package/dist/{googlePlay-B3FR1VGL.cjs.map → googlePlay-e_tIBr4n.cjs.map} +1 -1
- package/dist/{iam-BVPpX76R.cjs → iam-B6WLUf_x.cjs} +2 -2
- package/dist/{iam-BVPpX76R.cjs.map → iam-B6WLUf_x.cjs.map} +1 -1
- package/dist/{iam-q9ALh-Y5.mjs → iam-BKfO7u14.mjs} +2 -2
- package/dist/{iam-q9ALh-Y5.mjs.map → iam-BKfO7u14.mjs.map} +1 -1
- package/dist/{index-Dy4ojz5P.d.cts → index-1H93w_H6.d.cts} +2 -2
- package/dist/{index-BC1BLv9Q.d.mts.map → index-1H93w_H6.d.cts.map} +1 -1
- package/dist/{index-BC1BLv9Q.d.mts → index-DFZ0SMwN.d.mts} +2 -2
- package/dist/{index-Dy4ojz5P.d.cts.map → index-DFZ0SMwN.d.mts.map} +1 -1
- package/dist/index.cjs +71 -71
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +65 -65
- package/dist/index.mjs.map +1 -1
- package/dist/{local-COaqGFDc.mjs → local-DUi3f-WB.mjs} +2 -2
- package/dist/{local-COaqGFDc.mjs.map → local-DUi3f-WB.mjs.map} +1 -1
- package/dist/{local-DhAnAhXn.cjs → local-Dc2h2Ex3.cjs} +2 -2
- package/dist/{local-DhAnAhXn.cjs.map → local-Dc2h2Ex3.cjs.map} +1 -1
- package/dist/{migrate-CusdrYsn.cjs → migrate-BU4eyd7z.cjs} +6 -6
- package/dist/{migrate-CusdrYsn.cjs.map → migrate-BU4eyd7z.cjs.map} +1 -1
- package/dist/{migrate-Nt9NOr1s.mjs → migrate-BxFCXc7M.mjs} +6 -6
- package/dist/{migrate-Nt9NOr1s.mjs.map → migrate-BxFCXc7M.mjs.map} +1 -1
- package/dist/{migrate-Hjvo9j_J.cjs → migrate-CIjcBr96.cjs} +4 -4
- package/dist/{migrate-Hjvo9j_J.cjs.map → migrate-CIjcBr96.cjs.map} +1 -1
- package/dist/{migrate-CpT7qBZE.mjs → migrate-CbpeVxEW.mjs} +4 -4
- package/dist/{migrate-CpT7qBZE.mjs.map → migrate-CbpeVxEW.mjs.map} +1 -1
- package/dist/{notes-CZvLIjfg.cjs → notes-DJyFkK13.cjs} +7 -8
- package/dist/{notes-CZvLIjfg.cjs.map → notes-DJyFkK13.cjs.map} +1 -1
- package/dist/{notes-B-tgKkvp.mjs → notes-TDHMzdVt.mjs} +3 -4
- package/dist/{notes-B-tgKkvp.mjs.map → notes-TDHMzdVt.mjs.map} +1 -1
- package/dist/openapi.cjs +3 -3
- package/dist/openapi.cjs.map +1 -1
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.mjs +2 -2
- package/dist/{projectBucket-DNAOBIYZ.mjs → projectBucket-BPzx0b0t.mjs} +2 -2
- package/dist/{projectBucket-DNAOBIYZ.mjs.map → projectBucket-BPzx0b0t.mjs.map} +1 -1
- package/dist/{projectBucket-XyxlpATc.cjs → projectBucket-CoskwJC5.cjs} +2 -2
- package/dist/{projectBucket-XyxlpATc.cjs.map → projectBucket-CoskwJC5.cjs.map} +1 -1
- package/dist/{publish-DmBXVNlk.cjs → publish-DB3-zkpm.cjs} +2 -2
- package/dist/{publish-DmBXVNlk.cjs.map → publish-DB3-zkpm.cjs.map} +1 -1
- package/dist/{publish-CwjRq8Ye.mjs → publish-LZ1eb-MI.mjs} +2 -2
- package/dist/{publish-CwjRq8Ye.mjs.map → publish-LZ1eb-MI.mjs.map} +1 -1
- package/dist/reconcile/public.d.cts +1 -1
- package/dist/reconcile/public.d.mts +1 -1
- package/dist/{resolve-BuqA14hD.cjs → resolve-B5_tOTJG.cjs} +4 -4
- package/dist/{resolve-BuqA14hD.cjs.map → resolve-B5_tOTJG.cjs.map} +1 -1
- package/dist/{resolve-vOUrXSHP.mjs → resolve-jez3Y1S0.mjs} +4 -4
- package/dist/{resolve-vOUrXSHP.mjs.map → resolve-jez3Y1S0.mjs.map} +1 -1
- package/dist/{rollback-CiyKH1HK.cjs → rollback-BNo1bCLO.cjs} +8 -8
- package/dist/{rollback-CiyKH1HK.cjs.map → rollback-BNo1bCLO.cjs.map} +1 -1
- package/dist/{rollback-glkFgz6-.mjs → rollback-BtOfxwo-.mjs} +8 -8
- package/dist/{rollback-glkFgz6-.mjs.map → rollback-BtOfxwo-.mjs.map} +1 -1
- package/dist/{runtime-MZ5Pqgan.d.mts → runtime-CKOkIrw0.d.cts} +2 -2
- package/dist/{runtime-BySbkdBz.d.cts.map → runtime-CKOkIrw0.d.cts.map} +1 -1
- package/dist/{runtime-BySbkdBz.d.cts → runtime-Cdvv8SfU.d.mts} +2 -2
- package/dist/{runtime-MZ5Pqgan.d.mts.map → runtime-Cdvv8SfU.d.mts.map} +1 -1
- package/dist/{s3-BZbRcH8T.mjs → s3-Bf_75vVl.mjs} +3 -3
- package/dist/{s3-BZbRcH8T.mjs.map → s3-Bf_75vVl.mjs.map} +1 -1
- package/dist/{s3-C0EBuF8n.cjs → s3-BlPwyu1L.cjs} +3 -3
- package/dist/{s3-C0EBuF8n.cjs.map → s3-BlPwyu1L.cjs.map} +1 -1
- package/dist/{seeds-D7q1zKCJ.cjs → seeds-Bc3niNVb.cjs} +95 -82
- package/dist/seeds-Bc3niNVb.cjs.map +1 -0
- package/dist/{seeds-y1rzXlAc.mjs → seeds-Ccn0Ru2T.mjs} +84 -83
- package/dist/seeds-Ccn0Ru2T.mjs.map +1 -0
- package/dist/{serverSetup-Dlj7JQW-.mjs → serverSetup-D0Zor2i4.mjs} +8 -8
- package/dist/{serverSetup-Dlj7JQW-.mjs.map → serverSetup-D0Zor2i4.mjs.map} +1 -1
- package/dist/{serverSetup-n1Znminh.cjs → serverSetup-D30vVD6t.cjs} +8 -8
- package/dist/{serverSetup-n1Znminh.cjs.map → serverSetup-D30vVD6t.cjs.map} +1 -1
- package/dist/{sniffer-DDAxYDqU.cjs → sniffer-Bw00z3I8.cjs} +8 -8
- package/dist/{sniffer-DDAxYDqU.cjs.map → sniffer-Bw00z3I8.cjs.map} +1 -1
- package/dist/{sniffer-BgzTs_Zt.mjs → sniffer-DdPDiNmc.mjs} +8 -8
- package/dist/{sniffer-BgzTs_Zt.mjs.map → sniffer-DdPDiNmc.mjs.map} +1 -1
- package/dist/{snsSubscriptions-CCyxCMoc.mjs → snsSubscriptions-DBxVTR6Y.mjs} +3 -3
- package/dist/{snsSubscriptions-CCyxCMoc.mjs.map → snsSubscriptions-DBxVTR6Y.mjs.map} +1 -1
- package/dist/{snsSubscriptions-Dr5ghfa5.cjs → snsSubscriptions-g7apv_fy.cjs} +3 -3
- package/dist/{snsSubscriptions-Dr5ghfa5.cjs.map → snsSubscriptions-g7apv_fy.cjs.map} +1 -1
- package/dist/{sst-DBkHn3mA.cjs → sst-CEs0bMxj.cjs} +6 -6
- package/dist/{sst-DBkHn3mA.cjs.map → sst-CEs0bMxj.cjs.map} +1 -1
- package/dist/{sst-CV5TemXa.mjs → sst-DJ22YDEq.mjs} +5 -5
- package/dist/{sst-CV5TemXa.mjs.map → sst-DJ22YDEq.mjs.map} +1 -1
- package/dist/{stack-Dku1pOA2.cjs → stack-BmG-lKgD.cjs} +12 -13
- package/dist/{stack-Dku1pOA2.cjs.map → stack-BmG-lKgD.cjs.map} +1 -1
- package/dist/{stack-r97Ao-uG.mjs → stack-Ds9jjpE1.mjs} +7 -8
- package/dist/{stack-r97Ao-uG.mjs.map → stack-Ds9jjpE1.mjs.map} +1 -1
- package/dist/{stage-Deb-7Ohk.mjs → stage-D9dfV1Ey.mjs} +7 -7
- package/dist/{stage-Deb-7Ohk.mjs.map → stage-D9dfV1Ey.mjs.map} +1 -1
- package/dist/{stage-Du8I-UIa.cjs → stage-kGc9L3yB.cjs} +7 -7
- package/dist/{stage-Du8I-UIa.cjs.map → stage-kGc9L3yB.cjs.map} +1 -1
- package/dist/{stages-CW7qtiJ2.mjs → stages-BL22BLJS.mjs} +3 -3
- package/dist/{stages-CW7qtiJ2.mjs.map → stages-BL22BLJS.mjs.map} +1 -1
- package/dist/{stages-CtqmEJJW.cjs → stages-CN53nNOK.cjs} +3 -3
- package/dist/{stages-CtqmEJJW.cjs.map → stages-CN53nNOK.cjs.map} +1 -1
- 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-BEa0E3pz.mjs → terminal-C0A7S7fB.mjs} +2 -2
- package/dist/{terminal-BEa0E3pz.mjs.map → terminal-C0A7S7fB.mjs.map} +1 -1
- package/dist/{terminal-BXpp9kBr.cjs → terminal-DVlIWcUb.cjs} +2 -2
- package/dist/{terminal-BXpp9kBr.cjs.map → terminal-DVlIWcUb.cjs.map} +1 -1
- package/dist/{types-BsfPHUFZ.d.cts → types-DEmuMHsS.d.cts} +9 -1
- package/dist/types-DEmuMHsS.d.cts.map +1 -0
- package/dist/{types-BXboFkn9.d.mts → types-g_S0_RAi.d.mts} +9 -1
- package/dist/types-g_S0_RAi.d.mts.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-D5Vm2qcy.mjs → workspace-D4hzz6Xb.mjs} +331 -3
- package/dist/workspace-D4hzz6Xb.mjs.map +1 -0
- package/dist/{workspace-VhzmoxOv.cjs → workspace-DPSdiv-b.cjs} +371 -1
- package/dist/workspace-DPSdiv-b.cjs.map +1 -0
- package/package.json +15 -15
- package/dist/compose-BfTrMiAk.mjs.map +0 -1
- package/dist/compose-kEjxTamg.cjs.map +0 -1
- package/dist/config-CXj-9eRo.cjs +0 -890
- package/dist/config-CXj-9eRo.cjs.map +0 -1
- package/dist/config-Di0oJwM9.mjs +0 -759
- package/dist/config-Di0oJwM9.mjs.map +0 -1
- package/dist/deploy-C4V-nsOF.cjs.map +0 -1
- package/dist/deploy-D-5ib-ah.mjs.map +0 -1
- package/dist/github-BDOLgdMp.cjs.map +0 -1
- package/dist/github-D2l7aqFx.mjs.map +0 -1
- package/dist/seeds-D7q1zKCJ.cjs.map +0 -1
- package/dist/seeds-y1rzXlAc.mjs.map +0 -1
- package/dist/types-BXboFkn9.d.mts.map +0 -1
- package/dist/types-BsfPHUFZ.d.cts.map +0 -1
- package/dist/workspace-D5Vm2qcy.mjs.map +0 -1
- package/dist/workspace-VhzmoxOv.cjs.map +0 -1
|
@@ -1,4 +1,86 @@
|
|
|
1
1
|
let node_os = require("node:os");
|
|
2
|
+
//#region src/deploy/dnsResources.ts
|
|
3
|
+
/** The resource type of a DNS record gkm wrote. */
|
|
4
|
+
const DNS_RECORD_RESOURCE = "dns-record";
|
|
5
|
+
/** A record's full name: `api.example.com`, or the domain for `@`. */
|
|
6
|
+
function dnsRecordFqdn(domain, name) {
|
|
7
|
+
return name === "@" || name === "" ? domain : `${name}.${domain}`;
|
|
8
|
+
}
|
|
9
|
+
/** `dns-record:<fqdn>:<type>` */
|
|
10
|
+
function dnsResourceKey(fqdn, type) {
|
|
11
|
+
return `${DNS_RECORD_RESOURCE}:${fqdn.toLowerCase()}:${type.toUpperCase()}`;
|
|
12
|
+
}
|
|
13
|
+
/** The resource record a written DNS record is kept as. */
|
|
14
|
+
function dnsRecordResource(record) {
|
|
15
|
+
const fqdn = dnsRecordFqdn(record.domain, record.name).toLowerCase();
|
|
16
|
+
const type = record.type.toUpperCase();
|
|
17
|
+
const data = {
|
|
18
|
+
domain: record.domain,
|
|
19
|
+
name: record.name,
|
|
20
|
+
value: record.value,
|
|
21
|
+
ttl: record.ttl,
|
|
22
|
+
...record.provider ? { provider: record.provider } : {},
|
|
23
|
+
...record.source ? { source: record.source } : {}
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
key: dnsResourceKey(fqdn, type),
|
|
27
|
+
type: DNS_RECORD_RESOURCE,
|
|
28
|
+
id: `${fqdn} ${type}`,
|
|
29
|
+
status: "ready",
|
|
30
|
+
data
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Records that gkm wrote `record` — or updates the value it holds. */
|
|
34
|
+
async function recordDnsResource(journal, record) {
|
|
35
|
+
const { key, type, id, data } = dnsRecordResource(record);
|
|
36
|
+
await journal.ready({
|
|
37
|
+
key,
|
|
38
|
+
type,
|
|
39
|
+
...data ? { data } : {}
|
|
40
|
+
}, id);
|
|
41
|
+
}
|
|
42
|
+
/** Forgets a DNS record gkm deleted. */
|
|
43
|
+
async function forgetDnsResource(journal, record) {
|
|
44
|
+
await journal.forget(dnsResourceKey(dnsRecordFqdn(record.domain, record.name), record.type));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The changes a DNS step made, kept: what it created, updated or wrote is
|
|
48
|
+
* recorded, what it deleted is forgotten. A record it found already right is
|
|
49
|
+
* recorded only if gkm wrote it before; one it left to a person is not.
|
|
50
|
+
*/
|
|
51
|
+
async function recordDnsChanges(journal, changes, providerOf) {
|
|
52
|
+
for (const change of changes) {
|
|
53
|
+
if (change.action === "delete") {
|
|
54
|
+
await forgetDnsResource(journal, change);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const written = change.action === "create" || change.action === "update" || change.action === "write";
|
|
58
|
+
const known = change.action === "unchanged" && journal.record(dnsResourceKey(dnsRecordFqdn(change.domain, change.name), change.type)) !== void 0;
|
|
59
|
+
if (!written && !known || change.value === void 0) continue;
|
|
60
|
+
const provider = providerOf(change.domain);
|
|
61
|
+
await recordDnsResource(journal, {
|
|
62
|
+
domain: change.domain,
|
|
63
|
+
name: change.name,
|
|
64
|
+
type: change.type,
|
|
65
|
+
value: change.value,
|
|
66
|
+
ttl: change.ttl ?? 0,
|
|
67
|
+
...provider ? { provider } : {}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** Every DNS record gkm wrote for the stage, from its resource records. */
|
|
72
|
+
function dnsResources(resources) {
|
|
73
|
+
return Object.values(resources).filter((record) => record.type === DNS_RECORD_RESOURCE).map((record) => {
|
|
74
|
+
const data = record.data ?? {};
|
|
75
|
+
const [fqdn = "", type = ""] = (record.id ?? "").split(" ");
|
|
76
|
+
return {
|
|
77
|
+
...data,
|
|
78
|
+
type,
|
|
79
|
+
fqdn
|
|
80
|
+
};
|
|
81
|
+
}).sort((a, b) => a.fqdn.localeCompare(b.fqdn) || a.type.localeCompare(b.type));
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
2
84
|
//#region src/deploy/journal.ts
|
|
3
85
|
var DeployJournal = class DeployJournal {
|
|
4
86
|
store;
|
|
@@ -154,87 +236,6 @@ function describeActor(actor) {
|
|
|
154
236
|
return `${actor.actor} (${actor.workflow ? `${actor.workflow}, ` : ""}${actor.run})`;
|
|
155
237
|
}
|
|
156
238
|
//#endregion
|
|
157
|
-
//#region src/deploy/dnsResources.ts
|
|
158
|
-
/** The resource type of a DNS record gkm wrote. */
|
|
159
|
-
const DNS_RECORD_RESOURCE = "dns-record";
|
|
160
|
-
/** A record's full name: `api.example.com`, or the domain for `@`. */
|
|
161
|
-
function dnsRecordFqdn(domain, name) {
|
|
162
|
-
return name === "@" || name === "" ? domain : `${name}.${domain}`;
|
|
163
|
-
}
|
|
164
|
-
/** `dns-record:<fqdn>:<type>` */
|
|
165
|
-
function dnsResourceKey(fqdn, type) {
|
|
166
|
-
return `${DNS_RECORD_RESOURCE}:${fqdn.toLowerCase()}:${type.toUpperCase()}`;
|
|
167
|
-
}
|
|
168
|
-
/** The resource record a written DNS record is kept as. */
|
|
169
|
-
function dnsRecordResource(record) {
|
|
170
|
-
const fqdn = dnsRecordFqdn(record.domain, record.name).toLowerCase();
|
|
171
|
-
const type = record.type.toUpperCase();
|
|
172
|
-
const data = {
|
|
173
|
-
domain: record.domain,
|
|
174
|
-
name: record.name,
|
|
175
|
-
value: record.value,
|
|
176
|
-
ttl: record.ttl,
|
|
177
|
-
...record.provider ? { provider: record.provider } : {}
|
|
178
|
-
};
|
|
179
|
-
return {
|
|
180
|
-
key: dnsResourceKey(fqdn, type),
|
|
181
|
-
type: DNS_RECORD_RESOURCE,
|
|
182
|
-
id: `${fqdn} ${type}`,
|
|
183
|
-
status: "ready",
|
|
184
|
-
data
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
/** Records that gkm wrote `record` — or updates the value it holds. */
|
|
188
|
-
async function recordDnsResource(journal, record) {
|
|
189
|
-
const { key, type, id, data } = dnsRecordResource(record);
|
|
190
|
-
await journal.ready({
|
|
191
|
-
key,
|
|
192
|
-
type,
|
|
193
|
-
...data ? { data } : {}
|
|
194
|
-
}, id);
|
|
195
|
-
}
|
|
196
|
-
/** Forgets a DNS record gkm deleted. */
|
|
197
|
-
async function forgetDnsResource(journal, record) {
|
|
198
|
-
await journal.forget(dnsResourceKey(dnsRecordFqdn(record.domain, record.name), record.type));
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* The changes a DNS step made, kept: what it created, updated or wrote is
|
|
202
|
-
* recorded, what it deleted is forgotten. A record it found already right is
|
|
203
|
-
* recorded only if gkm wrote it before; one it left to a person is not.
|
|
204
|
-
*/
|
|
205
|
-
async function recordDnsChanges(journal, changes, providerOf) {
|
|
206
|
-
for (const change of changes) {
|
|
207
|
-
if (change.action === "delete") {
|
|
208
|
-
await forgetDnsResource(journal, change);
|
|
209
|
-
continue;
|
|
210
|
-
}
|
|
211
|
-
const written = change.action === "create" || change.action === "update" || change.action === "write";
|
|
212
|
-
const known = change.action === "unchanged" && journal.record(dnsResourceKey(dnsRecordFqdn(change.domain, change.name), change.type)) !== void 0;
|
|
213
|
-
if (!written && !known || change.value === void 0) continue;
|
|
214
|
-
const provider = providerOf(change.domain);
|
|
215
|
-
await recordDnsResource(journal, {
|
|
216
|
-
domain: change.domain,
|
|
217
|
-
name: change.name,
|
|
218
|
-
type: change.type,
|
|
219
|
-
value: change.value,
|
|
220
|
-
ttl: change.ttl ?? 0,
|
|
221
|
-
...provider ? { provider } : {}
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
/** Every DNS record gkm wrote for the stage, from its resource records. */
|
|
226
|
-
function dnsResources(resources) {
|
|
227
|
-
return Object.values(resources).filter((record) => record.type === DNS_RECORD_RESOURCE).map((record) => {
|
|
228
|
-
const data = record.data ?? {};
|
|
229
|
-
const [fqdn = "", type = ""] = (record.id ?? "").split(" ");
|
|
230
|
-
return {
|
|
231
|
-
...data,
|
|
232
|
-
type,
|
|
233
|
-
fqdn
|
|
234
|
-
};
|
|
235
|
-
}).sort((a, b) => a.fqdn.localeCompare(b.fqdn) || a.type.localeCompare(b.type));
|
|
236
|
-
}
|
|
237
|
-
//#endregion
|
|
238
239
|
//#region src/target/seeds.ts
|
|
239
240
|
/** A seed of a deployed stage failed; the release stopped before any app. */
|
|
240
241
|
var DeploySeedsFailed = class extends Error {
|
|
@@ -329,6 +330,12 @@ Object.defineProperty(exports, "dnsRecordResource", {
|
|
|
329
330
|
return dnsRecordResource;
|
|
330
331
|
}
|
|
331
332
|
});
|
|
333
|
+
Object.defineProperty(exports, "dnsResourceKey", {
|
|
334
|
+
enumerable: true,
|
|
335
|
+
get: function() {
|
|
336
|
+
return dnsResourceKey;
|
|
337
|
+
}
|
|
338
|
+
});
|
|
332
339
|
Object.defineProperty(exports, "dnsResources", {
|
|
333
340
|
enumerable: true,
|
|
334
341
|
get: function() {
|
|
@@ -353,6 +360,12 @@ Object.defineProperty(exports, "recordDnsChanges", {
|
|
|
353
360
|
return recordDnsChanges;
|
|
354
361
|
}
|
|
355
362
|
});
|
|
363
|
+
Object.defineProperty(exports, "recordDnsResource", {
|
|
364
|
+
enumerable: true,
|
|
365
|
+
get: function() {
|
|
366
|
+
return recordDnsResource;
|
|
367
|
+
}
|
|
368
|
+
});
|
|
356
369
|
Object.defineProperty(exports, "reportDatabaseRuns", {
|
|
357
370
|
enumerable: true,
|
|
358
371
|
get: function() {
|
|
@@ -366,4 +379,4 @@ Object.defineProperty(exports, "reportPlannedSeeds", {
|
|
|
366
379
|
}
|
|
367
380
|
});
|
|
368
381
|
|
|
369
|
-
//# sourceMappingURL=seeds-
|
|
382
|
+
//# sourceMappingURL=seeds-Bc3niNVb.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seeds-Bc3niNVb.cjs","names":["userInfo","hostname"],"sources":["../src/deploy/dnsResources.ts","../src/deploy/journal.ts","../src/deploy/actor.ts","../src/target/seeds.ts"],"sourcesContent":["/**\n * DNS records gkm wrote for a stage, as resource records in its deploy state.\n *\n * Each is `dns-record:<fqdn>:<type>` — `dns-record:api.example.com:A` — with\n * `id` `<fqdn> <type>` and the record's value in `data`. Every deploy's DNS\n * step writes through here — `gkm deploy` and `gkm compose` alike — so each\n * record has one key, whoever wrote it.\n */\n\nimport type { DeployJournal } from './journal';\nimport type { ResourceInput, ResourceRecord } from './StateStore';\n\n/** The resource type of a DNS record gkm wrote. */\nexport const DNS_RECORD_RESOURCE = 'dns-record';\n\n/** A DNS record as gkm writes it. */\nexport interface DnsResourceRecord {\n\t/** The `dns` domain it is under: `example.com`. */\n\tdomain: string;\n\t/** Relative to the domain, as providers take it: `api`, `@`. */\n\tname: string;\n\ttype: string;\n\tvalue: string;\n\tttl: number;\n\t/**\n\t * The domain's provider — `godaddy`, `route53`, … Absent on a record\n\t * migrated from a v2 state, which did not say.\n\t */\n\tprovider?: string;\n\t/**\n\t * `provider`: a resource provider asked for it — a DKIM, MX, validation\n\t * or CDN record — rather than the stack's hosts. Pruned when no provider\n\t * asks for it on a deploy, not when the stack stops serving it.\n\t */\n\tsource?: 'provider';\n}\n\n/** `data` of a `dns-record` resource. */\nexport type DnsResourceData = Omit<DnsResourceRecord, 'type'>;\n\n/** A record's full name: `api.example.com`, or the domain for `@`. */\nexport function dnsRecordFqdn(domain: string, name: string): string {\n\treturn name === '@' || name === '' ? domain : `${name}.${domain}`;\n}\n\n/** `dns-record:<fqdn>:<type>` */\nexport function dnsResourceKey(fqdn: string, type: string): string {\n\treturn `${DNS_RECORD_RESOURCE}:${fqdn.toLowerCase()}:${type.toUpperCase()}`;\n}\n\n/** The resource record a written DNS record is kept as. */\nexport function dnsRecordResource(record: DnsResourceRecord): ResourceInput {\n\tconst fqdn = dnsRecordFqdn(record.domain, record.name).toLowerCase();\n\tconst type = record.type.toUpperCase();\n\tconst data: DnsResourceData = {\n\t\tdomain: record.domain,\n\t\tname: record.name,\n\t\tvalue: record.value,\n\t\tttl: record.ttl,\n\t\t...(record.provider ? { provider: record.provider } : {}),\n\t\t...(record.source ? { source: record.source } : {}),\n\t};\n\treturn {\n\t\tkey: dnsResourceKey(fqdn, type),\n\t\ttype: DNS_RECORD_RESOURCE,\n\t\tid: `${fqdn} ${type}`,\n\t\tstatus: 'ready',\n\t\tdata,\n\t};\n}\n\n/** Records that gkm wrote `record` — or updates the value it holds. */\nexport async function recordDnsResource(\n\tjournal: DeployJournal,\n\trecord: DnsResourceRecord,\n): Promise<void> {\n\tconst { key, type, id, data } = dnsRecordResource(record);\n\tawait journal.ready({ key, type, ...(data ? { data } : {}) }, id!);\n}\n\n/** Forgets a DNS record gkm deleted. */\nexport async function forgetDnsResource(\n\tjournal: DeployJournal,\n\trecord: Pick<DnsResourceRecord, 'domain' | 'name' | 'type'>,\n): Promise<void> {\n\tawait journal.forget(\n\t\tdnsResourceKey(dnsRecordFqdn(record.domain, record.name), record.type),\n\t);\n}\n\n/** One change a DNS step made, as `applyStackDns` reports it. */\nexport interface AppliedDnsChange {\n\tdomain: string;\n\tname: string;\n\ttype: string;\n\taction: string;\n\tvalue?: string;\n\tttl?: number;\n}\n\n/**\n * The changes a DNS step made, kept: what it created, updated or wrote is\n * recorded, what it deleted is forgotten. A record it found already right is\n * recorded only if gkm wrote it before; one it left to a person is not.\n */\nexport async function recordDnsChanges(\n\tjournal: DeployJournal,\n\tchanges: readonly AppliedDnsChange[],\n\tproviderOf: (domain: string) => string | undefined,\n): Promise<void> {\n\tfor (const change of changes) {\n\t\tif (change.action === 'delete') {\n\t\t\tawait forgetDnsResource(journal, change);\n\t\t\tcontinue;\n\t\t}\n\t\tconst written =\n\t\t\tchange.action === 'create' ||\n\t\t\tchange.action === 'update' ||\n\t\t\tchange.action === 'write';\n\t\tconst known =\n\t\t\tchange.action === 'unchanged' &&\n\t\t\tjournal.record(\n\t\t\t\tdnsResourceKey(dnsRecordFqdn(change.domain, change.name), change.type),\n\t\t\t) !== undefined;\n\t\tif ((!written && !known) || change.value === undefined) continue;\n\t\tconst provider = providerOf(change.domain);\n\t\tawait recordDnsResource(journal, {\n\t\t\tdomain: change.domain,\n\t\t\tname: change.name,\n\t\t\ttype: change.type,\n\t\t\tvalue: change.value,\n\t\t\tttl: change.ttl ?? 0,\n\t\t\t...(provider ? { provider } : {}),\n\t\t});\n\t}\n}\n\n/** Every DNS record gkm wrote for the stage, from its resource records. */\nexport function dnsResources(\n\tresources: Record<string, ResourceRecord>,\n): (DnsResourceRecord & { fqdn: string })[] {\n\treturn Object.values(resources)\n\t\t.filter((record) => record.type === DNS_RECORD_RESOURCE)\n\t\t.map((record) => {\n\t\t\tconst data = (record.data ?? {}) as DnsResourceData;\n\t\t\tconst [fqdn = '', type = ''] = (record.id ?? '').split(' ');\n\t\t\treturn { ...data, type, fqdn };\n\t\t})\n\t\t.sort(\n\t\t\t(a, b) => a.fqdn.localeCompare(b.fqdn) || a.type.localeCompare(b.type),\n\t\t);\n}\n","/**\n * A deploy's record of what it is creating, written as it goes.\n *\n * Deploy used to write state once, after every app had deployed, so a run that\n * failed half way lost the ids of everything it had created and the next run\n * fell back to finding them by name — or made them again. The journal writes\n * through the stage's `StateStore` after every resource instead:\n *\n * 1. `pending`, before the call that creates it — \"this may now exist\";\n * 2. `ready` with the target's id, once the call has returned.\n *\n * A run that meets a `pending` record looks the resource up before it creates\n * anything, so a run killed between the create and the record adopts what the\n * dead run made instead of making a second one. Every write is conditional on\n * the version the journal last wrote, so a writer that skipped the stage's\n * lock raises `StateVersionConflict` here rather than being overwritten.\n */\n\nimport type { ResourceRecord, StateStore, StateVersion } from './StateStore';\nimport type { StageState } from './state';\n\n/** One resource, as the journal keys and describes it. */\nexport interface JournalEntry {\n\t/** `<type>:<name>`, unique within the stage — `application:api`. */\n\tkey: string;\n\ttype: string;\n\t/** What a later run needs to find it again — its name, usually. */\n\tdata?: Record<string, unknown>;\n}\n\n/** How to get at one kind of resource on the target. */\nexport interface ResourceSteps<T> {\n\t/** By the id a `ready` record holds; `null` when the target lost it. */\n\tget?: (id: string) => Promise<T | null | undefined>;\n\t/** By what identifies it otherwise — its name, in its environment. */\n\tfind: () => Promise<T | null | undefined>;\n\tcreate: () => Promise<T>;\n\tid: (resource: T) => string;\n}\n\nexport interface Ensured<T> {\n\tresource: T;\n\t/**\n\t * - `recorded`: the id in a `ready` record still resolves\n\t * - `resumed`: a `pending` record's resource was found — a run died\n\t * between creating it and recording it\n\t * - `found`: it existed, unrecorded\n\t * - `created`: it did not exist\n\t */\n\tvia: 'recorded' | 'resumed' | 'found' | 'created';\n\t/** The recorded id that no longer resolved, if there was one. */\n\tstaleId?: string;\n}\n\nexport class DeployJournal<S extends StageState = StageState> {\n\tprivate constructor(\n\t\tprivate readonly store: StateStore,\n\t\treadonly stage: string,\n\t\t/** The stage's state, mutated by the deploy and written by `save`. */\n\t\treadonly state: S,\n\t\tprivate resources: Record<string, ResourceRecord>,\n\t\tprivate version: StateVersion,\n\t\t/** Whether the stage had state before this run. */\n\t\treadonly existed: boolean,\n\t) {}\n\n\t/**\n\t * The stage's journal — its stored state, or `initial` written as the\n\t * stage's first state, so there is somewhere to record the very first\n\t * resource before it is created.\n\t *\n\t * `adopt` turns a stored state into the shape the caller works on — a\n\t * Dokploy deploy of a stage compose deployed keeps its releases and starts\n\t * its Dokploy ids afresh. Without it, the stored state is used as it is.\n\t */\n\tstatic async open(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => StageState,\n\t): Promise<DeployJournal<StageState>>;\n\tstatic async open<S extends StageState>(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => S,\n\t\tadopt: (stored: StageState) => S,\n\t): Promise<DeployJournal<S>>;\n\tstatic async open(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => StageState,\n\t\tadopt: (stored: StageState) => StageState = (stored) => stored,\n\t): Promise<DeployJournal<StageState>> {\n\t\tconst stored = await store.read(stage);\n\t\tif (stored) {\n\t\t\treturn new DeployJournal(\n\t\t\t\tstore,\n\t\t\t\tstage,\n\t\t\t\tadopt(stored.state),\n\t\t\t\tstored.resources,\n\t\t\t\tstored.version,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t}\n\n\t\tconst state = initial();\n\t\tconst version = await store.write(stage, state, { expectedVersion: null });\n\t\treturn new DeployJournal(store, stage, state, {}, version, false);\n\t}\n\n\trecord(key: string): ResourceRecord | undefined {\n\t\treturn this.resources[key];\n\t}\n\n\t/** The keys a previous run marked `pending` and never saw created. */\n\tunfinished(): string[] {\n\t\treturn Object.values(this.resources)\n\t\t\t.filter((record) => record.status === 'pending')\n\t\t\t.map((record) => record.key);\n\t}\n\n\t/** Records that `entry` is about to be created. */\n\tasync pending(entry: JournalEntry): Promise<void> {\n\t\tawait this.put({ ...entry, status: 'pending' });\n\t}\n\n\t/**\n\t * Records `entry` as existing with `id`; a no-op if it already is, with\n\t * the same data.\n\t */\n\tasync ready(entry: JournalEntry, id: string): Promise<void> {\n\t\tconst current = this.resources[entry.key];\n\t\tif (\n\t\t\tcurrent?.status === 'ready' &&\n\t\t\tcurrent.id === id &&\n\t\t\tJSON.stringify(current.data) === JSON.stringify(entry.data)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tawait this.put({ ...entry, status: 'ready', id });\n\t}\n\n\t/**\n\t * The resource `entry` names: by its recorded id, else by looking it up,\n\t * else created — with `pending` written before the create and `ready`\n\t * after, so a run that dies in between leaves a record the next run\n\t * resolves by looking the resource up rather than creating another.\n\t */\n\tasync ensure<T>(\n\t\tentry: JournalEntry,\n\t\tsteps: ResourceSteps<T>,\n\t): Promise<Ensured<T>> {\n\t\tconst record = this.resources[entry.key];\n\t\tlet staleId: string | undefined;\n\n\t\tif (record?.status === 'ready' && record.id && steps.get) {\n\t\t\tconst known = await steps.get(record.id);\n\t\t\tif (known) {\n\t\t\t\tawait this.ready(entry, steps.id(known));\n\t\t\t\treturn { resource: known, via: 'recorded' };\n\t\t\t}\n\t\t\tstaleId = record.id;\n\t\t}\n\n\t\tconst existing = await steps.find();\n\t\tif (existing) {\n\t\t\tawait this.ready(entry, steps.id(existing));\n\t\t\treturn {\n\t\t\t\tresource: existing,\n\t\t\t\tvia: record?.status === 'pending' ? 'resumed' : 'found',\n\t\t\t\t...(staleId ? { staleId } : {}),\n\t\t\t};\n\t\t}\n\n\t\tawait this.pending(entry);\n\t\tconst created = await steps.create();\n\t\tawait this.ready(entry, steps.id(created));\n\t\treturn {\n\t\t\tresource: created,\n\t\t\tvia: 'created',\n\t\t\t...(staleId ? { staleId } : {}),\n\t\t};\n\t}\n\n\t/** Removes `key`'s record — a resource that no longer exists. */\n\tasync forget(key: string): Promise<void> {\n\t\tif (!(key in this.resources)) return;\n\t\tthis.version = await this.store.deleteResource(this.stage, key, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t\tconst { [key]: _removed, ...resources } = this.resources;\n\t\tthis.resources = resources;\n\t}\n\n\t/** Every record, as the journal last wrote or read it. */\n\trecords(): Record<string, ResourceRecord> {\n\t\treturn this.resources;\n\t}\n\n\t/** Writes the stage's state, keeping its resource records. */\n\tasync save(): Promise<void> {\n\t\tthis.state.lastDeployedAt = new Date().toISOString();\n\t\tthis.version = await this.store.write(this.stage, this.state, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t}\n\n\tprivate async put(record: Omit<ResourceRecord, 'updatedAt'>): Promise<void> {\n\t\tthis.version = await this.store.putResource(this.stage, record, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t\tthis.resources = {\n\t\t\t...this.resources,\n\t\t\t[record.key]: { ...record, updatedAt: new Date().toISOString() },\n\t\t};\n\t}\n}\n","/**\n * Who wrote a stage's deploy state: a GitHub Actions run, or a person at a\n * machine. Recorded on every state write (`updatedBy`), on every resource\n * record and on every release (`releasedBy`), so \"who put this here\" has an\n * answer that does not depend on anyone's memory.\n */\n\nimport { hostname, userInfo } from 'node:os';\n\n/** A GitHub Actions run: the account that triggered it and the run's page. */\nexport interface GithubActor {\n\tkind: 'github';\n\t/** `GITHUB_ACTOR` — the account that triggered the run. */\n\tactor: string;\n\t/** `<server>/<repository>/actions/runs/<run id>` */\n\trun: string;\n\t/** `GITHUB_WORKFLOW` — the workflow's name. */\n\tworkflow?: string;\n}\n\n/** A person at a machine. */\nexport interface LocalActor {\n\tkind: 'local';\n\tuser: string;\n\thost: string;\n}\n\nexport type Actor = GithubActor | LocalActor;\n\n/** Whether `env` is a CI job — GitHub Actions or any runner that sets `CI`. */\nexport function isCi(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn env.GITHUB_ACTIONS === 'true' || env.CI === 'true';\n}\n\n/** Who this process is writing as. */\nexport function currentActor(env: NodeJS.ProcessEnv = process.env): Actor {\n\tif (env.GITHUB_ACTIONS === 'true') {\n\t\tconst server = env.GITHUB_SERVER_URL ?? 'https://github.com';\n\t\treturn {\n\t\t\tkind: 'github',\n\t\t\tactor: env.GITHUB_ACTOR ?? 'unknown',\n\t\t\trun: `${server}/${env.GITHUB_REPOSITORY ?? 'unknown'}/actions/runs/${env.GITHUB_RUN_ID ?? 'unknown'}`,\n\t\t\t...(env.GITHUB_WORKFLOW ? { workflow: env.GITHUB_WORKFLOW } : {}),\n\t\t};\n\t}\n\n\tlet user = 'unknown';\n\ttry {\n\t\tuser = userInfo().username;\n\t} catch {\n\t\t// No passwd entry (a container running as an arbitrary uid).\n\t}\n\treturn { kind: 'local', user, host: hostname() };\n}\n\n/** `octocat (deploy, https://github.com/…/runs/1)` or `ada@laptop`. */\nexport function describeActor(actor: Actor | undefined): string {\n\tif (!actor) return 'unknown';\n\tif (actor.kind === 'local') return `${actor.user}@${actor.host}`;\n\treturn `${actor.actor} (${actor.workflow ? `${actor.workflow}, ` : ''}${actor.run})`;\n}\n","/**\n * A deployed stage's seeds: what every server target runs after its\n * migrations and before any app starts.\n *\n * Seeds are reference data — roles, permissions, plans — kept current by\n * being run again, so a deploy runs every one of them, every time, on every\n * stage, production included. That is only safe because a seed is an\n * idempotent upsert; the docs say so, and nothing here can check it.\n */\n\nimport type { TargetEvent } from './types';\n\n/** A seed of a deployed stage failed; the release stopped before any app. */\nexport class DeploySeedsFailed extends Error {\n\tconstructor(\n\t\treadonly stage: string,\n\t\t/** The construct whose seed failed: `Database`. */\n\t\treadonly construct: string,\n\t\t/** The seed file, by name: `001_roles`. */\n\t\treadonly seed: string,\n\t\toverride readonly cause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`Seeding \"${stage}\" failed, so no app was released: ${construct}'s seed ` +\n\t\t\t\t`'${seed}' failed — ${causeMessage(cause)}. Its writes were rolled ` +\n\t\t\t\t'back; the migrations and the seeds before it stay applied. Seeds run ' +\n\t\t\t\t'on every deploy, so each must be an idempotent upsert: fix it and ' +\n\t\t\t\t'deploy again.',\n\t\t);\n\t\tthis.name = 'DeploySeedsFailed';\n\t}\n}\n\n/**\n * What went wrong underneath: a `SeedFailed`'s own cause (the database's\n * error), or — from a sandbox, where errors arrive as data — the same.\n */\nfunction causeMessage(cause: unknown): string {\n\tconst message = (value: unknown): string | undefined =>\n\t\tvalue && typeof value === 'object' && 'message' in value\n\t\t\t? String(value.message)\n\t\t\t: undefined;\n\tconst inner =\n\t\tcause && typeof cause === 'object' && 'cause' in cause\n\t\t\t? message(cause.cause)\n\t\t\t: undefined;\n\treturn inner ?? message(cause) ?? String(cause);\n}\n\n/** One construct's migrations, as a target reports them. */\nexport interface MigrationsReport {\n\tconstruct: string;\n\tfolder: string;\n\tapplied: readonly string[];\n}\n\n/** One construct's seeds, as a target reports them. */\nexport interface SeedsReport {\n\tconstruct: string;\n\tfolder: string;\n\tseeded: readonly string[];\n}\n\n/**\n * Say what a deploy's migrations and seeds did: a line per construct with\n * something applied or run — `🌱 db/database/seeds: ran 2`, then each seed —\n * and a `migration.applied` or `seed.ran` event beside it.\n */\nexport function reportDatabaseRuns(\n\tmigrations: readonly MigrationsReport[],\n\tseeds: readonly SeedsReport[],\n\tlog: (line: string) => void,\n\temit: (event: TargetEvent) => void,\n): void {\n\tfor (const { construct, folder, applied } of migrations) {\n\t\tif (applied.length === 0) continue;\n\t\tlog(`🗄️ ${folder}: applied ${applied.length}`);\n\t\tfor (const name of applied) log(` ✓ ${name}`);\n\t\temit({\n\t\t\ttype: 'migration.applied',\n\t\t\tconstruct,\n\t\t\tfolder,\n\t\t\tapplied: [...applied],\n\t\t});\n\t}\n\tfor (const { construct, folder, seeded } of seeds) {\n\t\tif (seeded.length === 0) continue;\n\t\tlog(`🌱 ${folder}: ran ${seeded.length}`);\n\t\tfor (const name of seeded) log(` ✓ ${name}`);\n\t\temit({ type: 'seed.ran', construct, folder, seeded: [...seeded] });\n\t}\n}\n\n/** What a dry run lists: the seeds a deploy would run, construct by construct. */\nexport function reportPlannedSeeds(\n\tplanned: readonly { folder: string; seeds: readonly string[] }[],\n\tlog: (line: string) => void,\n): void {\n\tfor (const { folder, seeds } of planned) {\n\t\tlog(`🌱 ${folder}: would run ${seeds.length} (${seeds.join(', ')})`);\n\t}\n}\n"],"mappings":";;;AAaA,MAAa,sBAAsB;;AA4BnC,SAAgB,cAAc,QAAgB,MAAsB;CACnE,OAAO,SAAS,OAAO,SAAS,KAAK,SAAS,GAAG,KAAK,GAAG;AAC1D;;AAGA,SAAgB,eAAe,MAAc,MAAsB;CAClE,OAAO,GAAG,oBAAoB,GAAG,KAAK,YAAY,EAAE,GAAG,KAAK,YAAY;AACzE;;AAGA,SAAgB,kBAAkB,QAA0C;CAC3E,MAAM,OAAO,cAAc,OAAO,QAAQ,OAAO,IAAI,CAAC,CAAC,YAAY;CACnE,MAAM,OAAO,OAAO,KAAK,YAAY;CACrC,MAAM,OAAwB;EAC7B,QAAQ,OAAO;EACf,MAAM,OAAO;EACb,OAAO,OAAO;EACd,KAAK,OAAO;EACZ,GAAI,OAAO,WAAW,EAAE,UAAU,OAAO,SAAS,IAAI,CAAC;EACvD,GAAI,OAAO,SAAS,EAAE,QAAQ,OAAO,OAAO,IAAI,CAAC;CAClD;CACA,OAAO;EACN,KAAK,eAAe,MAAM,IAAI;EAC9B,MAAM;EACN,IAAI,GAAG,KAAK,GAAG;EACf,QAAQ;EACR;CACD;AACD;;AAGA,eAAsB,kBACrB,SACA,QACgB;CAChB,MAAM,EAAE,KAAK,MAAM,IAAI,SAAS,kBAAkB,MAAM;CACxD,MAAM,QAAQ,MAAM;EAAE;EAAK;EAAM,GAAI,OAAO,EAAE,KAAK,IAAI,CAAC;CAAG,GAAG,EAAG;AAClE;;AAGA,e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CAKJ,QAHC,SAAS,OAAO,UAAU,YAAY,WAAW,QAC9C,QAAQ,MAAM,KAAK,IACnB,KAAA,MACY,QAAQ,KAAK,KAAK,OAAO,KAAK;AAC/C;;;;;;AAqBA,SAAgB,mBACf,YACA,OACA,KACA,MACO;CACP,KAAK,MAAM,EAAE,WAAW,QAAQ,aAAa,YAAY;EACxD,IAAI,QAAQ,WAAW,GAAG;EAC1B,IAAI,QAAQ,OAAO,YAAY,QAAQ,QAAQ;EAC/C,KAAK,MAAM,QAAQ,SAAS,IAAI,QAAQ,MAAM;EAC9C,KAAK;GACJ,MAAM;GACN;GACA;GACA,SAAS,CAAC,GAAG,OAAO;EACrB,CAAC;CACF;CACA,KAAK,MAAM,EAAE,WAAW,QAAQ,YAAY,OAAO;EAClD,IAAI,OAAO,WAAW,GAAG;EACzB,IAAI,MAAM,OAAO,QAAQ,OAAO,QAAQ;EACxC,KAAK,MAAM,QAAQ,QAAQ,IAAI,QAAQ,MAAM;EAC7C,KAAK;GAAE,MAAM;GAAY;GAAW;GAAQ,QAAQ,CAAC,GAAG,MAAM;EAAE,CAAC;CAClE;AACD;;AAGA,SAAgB,mBACf,SACA,KACO;CACP,KAAK,MAAM,EAAE,QAAQ,WAAW,SAC/B,IAAI,MAAM,OAAO,cAAc,MAAM,OAAO,IAAI,MAAM,KAAK,IAAI,EAAE,EAAE;AAErE"}
|
|
@@ -1,4 +1,86 @@
|
|
|
1
1
|
import { hostname, userInfo } from "node:os";
|
|
2
|
+
//#region src/deploy/dnsResources.ts
|
|
3
|
+
/** The resource type of a DNS record gkm wrote. */
|
|
4
|
+
const DNS_RECORD_RESOURCE = "dns-record";
|
|
5
|
+
/** A record's full name: `api.example.com`, or the domain for `@`. */
|
|
6
|
+
function dnsRecordFqdn(domain, name) {
|
|
7
|
+
return name === "@" || name === "" ? domain : `${name}.${domain}`;
|
|
8
|
+
}
|
|
9
|
+
/** `dns-record:<fqdn>:<type>` */
|
|
10
|
+
function dnsResourceKey(fqdn, type) {
|
|
11
|
+
return `${DNS_RECORD_RESOURCE}:${fqdn.toLowerCase()}:${type.toUpperCase()}`;
|
|
12
|
+
}
|
|
13
|
+
/** The resource record a written DNS record is kept as. */
|
|
14
|
+
function dnsRecordResource(record) {
|
|
15
|
+
const fqdn = dnsRecordFqdn(record.domain, record.name).toLowerCase();
|
|
16
|
+
const type = record.type.toUpperCase();
|
|
17
|
+
const data = {
|
|
18
|
+
domain: record.domain,
|
|
19
|
+
name: record.name,
|
|
20
|
+
value: record.value,
|
|
21
|
+
ttl: record.ttl,
|
|
22
|
+
...record.provider ? { provider: record.provider } : {},
|
|
23
|
+
...record.source ? { source: record.source } : {}
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
key: dnsResourceKey(fqdn, type),
|
|
27
|
+
type: DNS_RECORD_RESOURCE,
|
|
28
|
+
id: `${fqdn} ${type}`,
|
|
29
|
+
status: "ready",
|
|
30
|
+
data
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Records that gkm wrote `record` — or updates the value it holds. */
|
|
34
|
+
async function recordDnsResource(journal, record) {
|
|
35
|
+
const { key, type, id, data } = dnsRecordResource(record);
|
|
36
|
+
await journal.ready({
|
|
37
|
+
key,
|
|
38
|
+
type,
|
|
39
|
+
...data ? { data } : {}
|
|
40
|
+
}, id);
|
|
41
|
+
}
|
|
42
|
+
/** Forgets a DNS record gkm deleted. */
|
|
43
|
+
async function forgetDnsResource(journal, record) {
|
|
44
|
+
await journal.forget(dnsResourceKey(dnsRecordFqdn(record.domain, record.name), record.type));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The changes a DNS step made, kept: what it created, updated or wrote is
|
|
48
|
+
* recorded, what it deleted is forgotten. A record it found already right is
|
|
49
|
+
* recorded only if gkm wrote it before; one it left to a person is not.
|
|
50
|
+
*/
|
|
51
|
+
async function recordDnsChanges(journal, changes, providerOf) {
|
|
52
|
+
for (const change of changes) {
|
|
53
|
+
if (change.action === "delete") {
|
|
54
|
+
await forgetDnsResource(journal, change);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const written = change.action === "create" || change.action === "update" || change.action === "write";
|
|
58
|
+
const known = change.action === "unchanged" && journal.record(dnsResourceKey(dnsRecordFqdn(change.domain, change.name), change.type)) !== void 0;
|
|
59
|
+
if (!written && !known || change.value === void 0) continue;
|
|
60
|
+
const provider = providerOf(change.domain);
|
|
61
|
+
await recordDnsResource(journal, {
|
|
62
|
+
domain: change.domain,
|
|
63
|
+
name: change.name,
|
|
64
|
+
type: change.type,
|
|
65
|
+
value: change.value,
|
|
66
|
+
ttl: change.ttl ?? 0,
|
|
67
|
+
...provider ? { provider } : {}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** Every DNS record gkm wrote for the stage, from its resource records. */
|
|
72
|
+
function dnsResources(resources) {
|
|
73
|
+
return Object.values(resources).filter((record) => record.type === DNS_RECORD_RESOURCE).map((record) => {
|
|
74
|
+
const data = record.data ?? {};
|
|
75
|
+
const [fqdn = "", type = ""] = (record.id ?? "").split(" ");
|
|
76
|
+
return {
|
|
77
|
+
...data,
|
|
78
|
+
type,
|
|
79
|
+
fqdn
|
|
80
|
+
};
|
|
81
|
+
}).sort((a, b) => a.fqdn.localeCompare(b.fqdn) || a.type.localeCompare(b.type));
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
2
84
|
//#region src/deploy/journal.ts
|
|
3
85
|
var DeployJournal = class DeployJournal {
|
|
4
86
|
store;
|
|
@@ -154,87 +236,6 @@ function describeActor(actor) {
|
|
|
154
236
|
return `${actor.actor} (${actor.workflow ? `${actor.workflow}, ` : ""}${actor.run})`;
|
|
155
237
|
}
|
|
156
238
|
//#endregion
|
|
157
|
-
//#region src/deploy/dnsResources.ts
|
|
158
|
-
/** The resource type of a DNS record gkm wrote. */
|
|
159
|
-
const DNS_RECORD_RESOURCE = "dns-record";
|
|
160
|
-
/** A record's full name: `api.example.com`, or the domain for `@`. */
|
|
161
|
-
function dnsRecordFqdn(domain, name) {
|
|
162
|
-
return name === "@" || name === "" ? domain : `${name}.${domain}`;
|
|
163
|
-
}
|
|
164
|
-
/** `dns-record:<fqdn>:<type>` */
|
|
165
|
-
function dnsResourceKey(fqdn, type) {
|
|
166
|
-
return `${DNS_RECORD_RESOURCE}:${fqdn.toLowerCase()}:${type.toUpperCase()}`;
|
|
167
|
-
}
|
|
168
|
-
/** The resource record a written DNS record is kept as. */
|
|
169
|
-
function dnsRecordResource(record) {
|
|
170
|
-
const fqdn = dnsRecordFqdn(record.domain, record.name).toLowerCase();
|
|
171
|
-
const type = record.type.toUpperCase();
|
|
172
|
-
const data = {
|
|
173
|
-
domain: record.domain,
|
|
174
|
-
name: record.name,
|
|
175
|
-
value: record.value,
|
|
176
|
-
ttl: record.ttl,
|
|
177
|
-
...record.provider ? { provider: record.provider } : {}
|
|
178
|
-
};
|
|
179
|
-
return {
|
|
180
|
-
key: dnsResourceKey(fqdn, type),
|
|
181
|
-
type: DNS_RECORD_RESOURCE,
|
|
182
|
-
id: `${fqdn} ${type}`,
|
|
183
|
-
status: "ready",
|
|
184
|
-
data
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
/** Records that gkm wrote `record` — or updates the value it holds. */
|
|
188
|
-
async function recordDnsResource(journal, record) {
|
|
189
|
-
const { key, type, id, data } = dnsRecordResource(record);
|
|
190
|
-
await journal.ready({
|
|
191
|
-
key,
|
|
192
|
-
type,
|
|
193
|
-
...data ? { data } : {}
|
|
194
|
-
}, id);
|
|
195
|
-
}
|
|
196
|
-
/** Forgets a DNS record gkm deleted. */
|
|
197
|
-
async function forgetDnsResource(journal, record) {
|
|
198
|
-
await journal.forget(dnsResourceKey(dnsRecordFqdn(record.domain, record.name), record.type));
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* The changes a DNS step made, kept: what it created, updated or wrote is
|
|
202
|
-
* recorded, what it deleted is forgotten. A record it found already right is
|
|
203
|
-
* recorded only if gkm wrote it before; one it left to a person is not.
|
|
204
|
-
*/
|
|
205
|
-
async function recordDnsChanges(journal, changes, providerOf) {
|
|
206
|
-
for (const change of changes) {
|
|
207
|
-
if (change.action === "delete") {
|
|
208
|
-
await forgetDnsResource(journal, change);
|
|
209
|
-
continue;
|
|
210
|
-
}
|
|
211
|
-
const written = change.action === "create" || change.action === "update" || change.action === "write";
|
|
212
|
-
const known = change.action === "unchanged" && journal.record(dnsResourceKey(dnsRecordFqdn(change.domain, change.name), change.type)) !== void 0;
|
|
213
|
-
if (!written && !known || change.value === void 0) continue;
|
|
214
|
-
const provider = providerOf(change.domain);
|
|
215
|
-
await recordDnsResource(journal, {
|
|
216
|
-
domain: change.domain,
|
|
217
|
-
name: change.name,
|
|
218
|
-
type: change.type,
|
|
219
|
-
value: change.value,
|
|
220
|
-
ttl: change.ttl ?? 0,
|
|
221
|
-
...provider ? { provider } : {}
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
/** Every DNS record gkm wrote for the stage, from its resource records. */
|
|
226
|
-
function dnsResources(resources) {
|
|
227
|
-
return Object.values(resources).filter((record) => record.type === DNS_RECORD_RESOURCE).map((record) => {
|
|
228
|
-
const data = record.data ?? {};
|
|
229
|
-
const [fqdn = "", type = ""] = (record.id ?? "").split(" ");
|
|
230
|
-
return {
|
|
231
|
-
...data,
|
|
232
|
-
type,
|
|
233
|
-
fqdn
|
|
234
|
-
};
|
|
235
|
-
}).sort((a, b) => a.fqdn.localeCompare(b.fqdn) || a.type.localeCompare(b.type));
|
|
236
|
-
}
|
|
237
|
-
//#endregion
|
|
238
239
|
//#region src/target/seeds.ts
|
|
239
240
|
/** A seed of a deployed stage failed; the release stopped before any app. */
|
|
240
241
|
var DeploySeedsFailed = class extends Error {
|
|
@@ -293,6 +294,6 @@ function reportPlannedSeeds(planned, log) {
|
|
|
293
294
|
for (const { folder, seeds } of planned) log(`🌱 ${folder}: would run ${seeds.length} (${seeds.join(", ")})`);
|
|
294
295
|
}
|
|
295
296
|
//#endregion
|
|
296
|
-
export {
|
|
297
|
+
export { describeActor as a, dnsRecordFqdn as c, dnsResources as d, forgetDnsResource as f, currentActor as i, dnsRecordResource as l, recordDnsResource as m, reportDatabaseRuns as n, isCi as o, recordDnsChanges as p, reportPlannedSeeds as r, DeployJournal as s, DeploySeedsFailed as t, dnsResourceKey as u };
|
|
297
298
|
|
|
298
|
-
//# sourceMappingURL=seeds-
|
|
299
|
+
//# sourceMappingURL=seeds-Ccn0Ru2T.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seeds-Ccn0Ru2T.mjs","names":[],"sources":["../src/deploy/dnsResources.ts","../src/deploy/journal.ts","../src/deploy/actor.ts","../src/target/seeds.ts"],"sourcesContent":["/**\n * DNS records gkm wrote for a stage, as resource records in its deploy state.\n *\n * Each is `dns-record:<fqdn>:<type>` — `dns-record:api.example.com:A` — with\n * `id` `<fqdn> <type>` and the record's value in `data`. Every deploy's DNS\n * step writes through here — `gkm deploy` and `gkm compose` alike — so each\n * record has one key, whoever wrote it.\n */\n\nimport type { DeployJournal } from './journal';\nimport type { ResourceInput, ResourceRecord } from './StateStore';\n\n/** The resource type of a DNS record gkm wrote. */\nexport const DNS_RECORD_RESOURCE = 'dns-record';\n\n/** A DNS record as gkm writes it. */\nexport interface DnsResourceRecord {\n\t/** The `dns` domain it is under: `example.com`. */\n\tdomain: string;\n\t/** Relative to the domain, as providers take it: `api`, `@`. */\n\tname: string;\n\ttype: string;\n\tvalue: string;\n\tttl: number;\n\t/**\n\t * The domain's provider — `godaddy`, `route53`, … Absent on a record\n\t * migrated from a v2 state, which did not say.\n\t */\n\tprovider?: string;\n\t/**\n\t * `provider`: a resource provider asked for it — a DKIM, MX, validation\n\t * or CDN record — rather than the stack's hosts. Pruned when no provider\n\t * asks for it on a deploy, not when the stack stops serving it.\n\t */\n\tsource?: 'provider';\n}\n\n/** `data` of a `dns-record` resource. */\nexport type DnsResourceData = Omit<DnsResourceRecord, 'type'>;\n\n/** A record's full name: `api.example.com`, or the domain for `@`. */\nexport function dnsRecordFqdn(domain: string, name: string): string {\n\treturn name === '@' || name === '' ? domain : `${name}.${domain}`;\n}\n\n/** `dns-record:<fqdn>:<type>` */\nexport function dnsResourceKey(fqdn: string, type: string): string {\n\treturn `${DNS_RECORD_RESOURCE}:${fqdn.toLowerCase()}:${type.toUpperCase()}`;\n}\n\n/** The resource record a written DNS record is kept as. */\nexport function dnsRecordResource(record: DnsResourceRecord): ResourceInput {\n\tconst fqdn = dnsRecordFqdn(record.domain, record.name).toLowerCase();\n\tconst type = record.type.toUpperCase();\n\tconst data: DnsResourceData = {\n\t\tdomain: record.domain,\n\t\tname: record.name,\n\t\tvalue: record.value,\n\t\tttl: record.ttl,\n\t\t...(record.provider ? { provider: record.provider } : {}),\n\t\t...(record.source ? { source: record.source } : {}),\n\t};\n\treturn {\n\t\tkey: dnsResourceKey(fqdn, type),\n\t\ttype: DNS_RECORD_RESOURCE,\n\t\tid: `${fqdn} ${type}`,\n\t\tstatus: 'ready',\n\t\tdata,\n\t};\n}\n\n/** Records that gkm wrote `record` — or updates the value it holds. */\nexport async function recordDnsResource(\n\tjournal: DeployJournal,\n\trecord: DnsResourceRecord,\n): Promise<void> {\n\tconst { key, type, id, data } = dnsRecordResource(record);\n\tawait journal.ready({ key, type, ...(data ? { data } : {}) }, id!);\n}\n\n/** Forgets a DNS record gkm deleted. */\nexport async function forgetDnsResource(\n\tjournal: DeployJournal,\n\trecord: Pick<DnsResourceRecord, 'domain' | 'name' | 'type'>,\n): Promise<void> {\n\tawait journal.forget(\n\t\tdnsResourceKey(dnsRecordFqdn(record.domain, record.name), record.type),\n\t);\n}\n\n/** One change a DNS step made, as `applyStackDns` reports it. */\nexport interface AppliedDnsChange {\n\tdomain: string;\n\tname: string;\n\ttype: string;\n\taction: string;\n\tvalue?: string;\n\tttl?: number;\n}\n\n/**\n * The changes a DNS step made, kept: what it created, updated or wrote is\n * recorded, what it deleted is forgotten. A record it found already right is\n * recorded only if gkm wrote it before; one it left to a person is not.\n */\nexport async function recordDnsChanges(\n\tjournal: DeployJournal,\n\tchanges: readonly AppliedDnsChange[],\n\tproviderOf: (domain: string) => string | undefined,\n): Promise<void> {\n\tfor (const change of changes) {\n\t\tif (change.action === 'delete') {\n\t\t\tawait forgetDnsResource(journal, change);\n\t\t\tcontinue;\n\t\t}\n\t\tconst written =\n\t\t\tchange.action === 'create' ||\n\t\t\tchange.action === 'update' ||\n\t\t\tchange.action === 'write';\n\t\tconst known =\n\t\t\tchange.action === 'unchanged' &&\n\t\t\tjournal.record(\n\t\t\t\tdnsResourceKey(dnsRecordFqdn(change.domain, change.name), change.type),\n\t\t\t) !== undefined;\n\t\tif ((!written && !known) || change.value === undefined) continue;\n\t\tconst provider = providerOf(change.domain);\n\t\tawait recordDnsResource(journal, {\n\t\t\tdomain: change.domain,\n\t\t\tname: change.name,\n\t\t\ttype: change.type,\n\t\t\tvalue: change.value,\n\t\t\tttl: change.ttl ?? 0,\n\t\t\t...(provider ? { provider } : {}),\n\t\t});\n\t}\n}\n\n/** Every DNS record gkm wrote for the stage, from its resource records. */\nexport function dnsResources(\n\tresources: Record<string, ResourceRecord>,\n): (DnsResourceRecord & { fqdn: string })[] {\n\treturn Object.values(resources)\n\t\t.filter((record) => record.type === DNS_RECORD_RESOURCE)\n\t\t.map((record) => {\n\t\t\tconst data = (record.data ?? {}) as DnsResourceData;\n\t\t\tconst [fqdn = '', type = ''] = (record.id ?? '').split(' ');\n\t\t\treturn { ...data, type, fqdn };\n\t\t})\n\t\t.sort(\n\t\t\t(a, b) => a.fqdn.localeCompare(b.fqdn) || a.type.localeCompare(b.type),\n\t\t);\n}\n","/**\n * A deploy's record of what it is creating, written as it goes.\n *\n * Deploy used to write state once, after every app had deployed, so a run that\n * failed half way lost the ids of everything it had created and the next run\n * fell back to finding them by name — or made them again. The journal writes\n * through the stage's `StateStore` after every resource instead:\n *\n * 1. `pending`, before the call that creates it — \"this may now exist\";\n * 2. `ready` with the target's id, once the call has returned.\n *\n * A run that meets a `pending` record looks the resource up before it creates\n * anything, so a run killed between the create and the record adopts what the\n * dead run made instead of making a second one. Every write is conditional on\n * the version the journal last wrote, so a writer that skipped the stage's\n * lock raises `StateVersionConflict` here rather than being overwritten.\n */\n\nimport type { ResourceRecord, StateStore, StateVersion } from './StateStore';\nimport type { StageState } from './state';\n\n/** One resource, as the journal keys and describes it. */\nexport interface JournalEntry {\n\t/** `<type>:<name>`, unique within the stage — `application:api`. */\n\tkey: string;\n\ttype: string;\n\t/** What a later run needs to find it again — its name, usually. */\n\tdata?: Record<string, unknown>;\n}\n\n/** How to get at one kind of resource on the target. */\nexport interface ResourceSteps<T> {\n\t/** By the id a `ready` record holds; `null` when the target lost it. */\n\tget?: (id: string) => Promise<T | null | undefined>;\n\t/** By what identifies it otherwise — its name, in its environment. */\n\tfind: () => Promise<T | null | undefined>;\n\tcreate: () => Promise<T>;\n\tid: (resource: T) => string;\n}\n\nexport interface Ensured<T> {\n\tresource: T;\n\t/**\n\t * - `recorded`: the id in a `ready` record still resolves\n\t * - `resumed`: a `pending` record's resource was found — a run died\n\t * between creating it and recording it\n\t * - `found`: it existed, unrecorded\n\t * - `created`: it did not exist\n\t */\n\tvia: 'recorded' | 'resumed' | 'found' | 'created';\n\t/** The recorded id that no longer resolved, if there was one. */\n\tstaleId?: string;\n}\n\nexport class DeployJournal<S extends StageState = StageState> {\n\tprivate constructor(\n\t\tprivate readonly store: StateStore,\n\t\treadonly stage: string,\n\t\t/** The stage's state, mutated by the deploy and written by `save`. */\n\t\treadonly state: S,\n\t\tprivate resources: Record<string, ResourceRecord>,\n\t\tprivate version: StateVersion,\n\t\t/** Whether the stage had state before this run. */\n\t\treadonly existed: boolean,\n\t) {}\n\n\t/**\n\t * The stage's journal — its stored state, or `initial` written as the\n\t * stage's first state, so there is somewhere to record the very first\n\t * resource before it is created.\n\t *\n\t * `adopt` turns a stored state into the shape the caller works on — a\n\t * Dokploy deploy of a stage compose deployed keeps its releases and starts\n\t * its Dokploy ids afresh. Without it, the stored state is used as it is.\n\t */\n\tstatic async open(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => StageState,\n\t): Promise<DeployJournal<StageState>>;\n\tstatic async open<S extends StageState>(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => S,\n\t\tadopt: (stored: StageState) => S,\n\t): Promise<DeployJournal<S>>;\n\tstatic async open(\n\t\tstore: StateStore,\n\t\tstage: string,\n\t\tinitial: () => StageState,\n\t\tadopt: (stored: StageState) => StageState = (stored) => stored,\n\t): Promise<DeployJournal<StageState>> {\n\t\tconst stored = await store.read(stage);\n\t\tif (stored) {\n\t\t\treturn new DeployJournal(\n\t\t\t\tstore,\n\t\t\t\tstage,\n\t\t\t\tadopt(stored.state),\n\t\t\t\tstored.resources,\n\t\t\t\tstored.version,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t}\n\n\t\tconst state = initial();\n\t\tconst version = await store.write(stage, state, { expectedVersion: null });\n\t\treturn new DeployJournal(store, stage, state, {}, version, false);\n\t}\n\n\trecord(key: string): ResourceRecord | undefined {\n\t\treturn this.resources[key];\n\t}\n\n\t/** The keys a previous run marked `pending` and never saw created. */\n\tunfinished(): string[] {\n\t\treturn Object.values(this.resources)\n\t\t\t.filter((record) => record.status === 'pending')\n\t\t\t.map((record) => record.key);\n\t}\n\n\t/** Records that `entry` is about to be created. */\n\tasync pending(entry: JournalEntry): Promise<void> {\n\t\tawait this.put({ ...entry, status: 'pending' });\n\t}\n\n\t/**\n\t * Records `entry` as existing with `id`; a no-op if it already is, with\n\t * the same data.\n\t */\n\tasync ready(entry: JournalEntry, id: string): Promise<void> {\n\t\tconst current = this.resources[entry.key];\n\t\tif (\n\t\t\tcurrent?.status === 'ready' &&\n\t\t\tcurrent.id === id &&\n\t\t\tJSON.stringify(current.data) === JSON.stringify(entry.data)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tawait this.put({ ...entry, status: 'ready', id });\n\t}\n\n\t/**\n\t * The resource `entry` names: by its recorded id, else by looking it up,\n\t * else created — with `pending` written before the create and `ready`\n\t * after, so a run that dies in between leaves a record the next run\n\t * resolves by looking the resource up rather than creating another.\n\t */\n\tasync ensure<T>(\n\t\tentry: JournalEntry,\n\t\tsteps: ResourceSteps<T>,\n\t): Promise<Ensured<T>> {\n\t\tconst record = this.resources[entry.key];\n\t\tlet staleId: string | undefined;\n\n\t\tif (record?.status === 'ready' && record.id && steps.get) {\n\t\t\tconst known = await steps.get(record.id);\n\t\t\tif (known) {\n\t\t\t\tawait this.ready(entry, steps.id(known));\n\t\t\t\treturn { resource: known, via: 'recorded' };\n\t\t\t}\n\t\t\tstaleId = record.id;\n\t\t}\n\n\t\tconst existing = await steps.find();\n\t\tif (existing) {\n\t\t\tawait this.ready(entry, steps.id(existing));\n\t\t\treturn {\n\t\t\t\tresource: existing,\n\t\t\t\tvia: record?.status === 'pending' ? 'resumed' : 'found',\n\t\t\t\t...(staleId ? { staleId } : {}),\n\t\t\t};\n\t\t}\n\n\t\tawait this.pending(entry);\n\t\tconst created = await steps.create();\n\t\tawait this.ready(entry, steps.id(created));\n\t\treturn {\n\t\t\tresource: created,\n\t\t\tvia: 'created',\n\t\t\t...(staleId ? { staleId } : {}),\n\t\t};\n\t}\n\n\t/** Removes `key`'s record — a resource that no longer exists. */\n\tasync forget(key: string): Promise<void> {\n\t\tif (!(key in this.resources)) return;\n\t\tthis.version = await this.store.deleteResource(this.stage, key, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t\tconst { [key]: _removed, ...resources } = this.resources;\n\t\tthis.resources = resources;\n\t}\n\n\t/** Every record, as the journal last wrote or read it. */\n\trecords(): Record<string, ResourceRecord> {\n\t\treturn this.resources;\n\t}\n\n\t/** Writes the stage's state, keeping its resource records. */\n\tasync save(): Promise<void> {\n\t\tthis.state.lastDeployedAt = new Date().toISOString();\n\t\tthis.version = await this.store.write(this.stage, this.state, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t}\n\n\tprivate async put(record: Omit<ResourceRecord, 'updatedAt'>): Promise<void> {\n\t\tthis.version = await this.store.putResource(this.stage, record, {\n\t\t\texpectedVersion: this.version,\n\t\t});\n\t\tthis.resources = {\n\t\t\t...this.resources,\n\t\t\t[record.key]: { ...record, updatedAt: new Date().toISOString() },\n\t\t};\n\t}\n}\n","/**\n * Who wrote a stage's deploy state: a GitHub Actions run, or a person at a\n * machine. Recorded on every state write (`updatedBy`), on every resource\n * record and on every release (`releasedBy`), so \"who put this here\" has an\n * answer that does not depend on anyone's memory.\n */\n\nimport { hostname, userInfo } from 'node:os';\n\n/** A GitHub Actions run: the account that triggered it and the run's page. */\nexport interface GithubActor {\n\tkind: 'github';\n\t/** `GITHUB_ACTOR` — the account that triggered the run. */\n\tactor: string;\n\t/** `<server>/<repository>/actions/runs/<run id>` */\n\trun: string;\n\t/** `GITHUB_WORKFLOW` — the workflow's name. */\n\tworkflow?: string;\n}\n\n/** A person at a machine. */\nexport interface LocalActor {\n\tkind: 'local';\n\tuser: string;\n\thost: string;\n}\n\nexport type Actor = GithubActor | LocalActor;\n\n/** Whether `env` is a CI job — GitHub Actions or any runner that sets `CI`. */\nexport function isCi(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn env.GITHUB_ACTIONS === 'true' || env.CI === 'true';\n}\n\n/** Who this process is writing as. */\nexport function currentActor(env: NodeJS.ProcessEnv = process.env): Actor {\n\tif (env.GITHUB_ACTIONS === 'true') {\n\t\tconst server = env.GITHUB_SERVER_URL ?? 'https://github.com';\n\t\treturn {\n\t\t\tkind: 'github',\n\t\t\tactor: env.GITHUB_ACTOR ?? 'unknown',\n\t\t\trun: `${server}/${env.GITHUB_REPOSITORY ?? 'unknown'}/actions/runs/${env.GITHUB_RUN_ID ?? 'unknown'}`,\n\t\t\t...(env.GITHUB_WORKFLOW ? { workflow: env.GITHUB_WORKFLOW } : {}),\n\t\t};\n\t}\n\n\tlet user = 'unknown';\n\ttry {\n\t\tuser = userInfo().username;\n\t} catch {\n\t\t// No passwd entry (a container running as an arbitrary uid).\n\t}\n\treturn { kind: 'local', user, host: hostname() };\n}\n\n/** `octocat (deploy, https://github.com/…/runs/1)` or `ada@laptop`. */\nexport function describeActor(actor: Actor | undefined): string {\n\tif (!actor) return 'unknown';\n\tif (actor.kind === 'local') return `${actor.user}@${actor.host}`;\n\treturn `${actor.actor} (${actor.workflow ? `${actor.workflow}, ` : ''}${actor.run})`;\n}\n","/**\n * A deployed stage's seeds: what every server target runs after its\n * migrations and before any app starts.\n *\n * Seeds are reference data — roles, permissions, plans — kept current by\n * being run again, so a deploy runs every one of them, every time, on every\n * stage, production included. That is only safe because a seed is an\n * idempotent upsert; the docs say so, and nothing here can check it.\n */\n\nimport type { TargetEvent } from './types';\n\n/** A seed of a deployed stage failed; the release stopped before any app. */\nexport class DeploySeedsFailed extends Error {\n\tconstructor(\n\t\treadonly stage: string,\n\t\t/** The construct whose seed failed: `Database`. */\n\t\treadonly construct: string,\n\t\t/** The seed file, by name: `001_roles`. */\n\t\treadonly seed: string,\n\t\toverride readonly cause: unknown,\n\t) {\n\t\tsuper(\n\t\t\t`Seeding \"${stage}\" failed, so no app was released: ${construct}'s seed ` +\n\t\t\t\t`'${seed}' failed — ${causeMessage(cause)}. Its writes were rolled ` +\n\t\t\t\t'back; the migrations and the seeds before it stay applied. Seeds run ' +\n\t\t\t\t'on every deploy, so each must be an idempotent upsert: fix it and ' +\n\t\t\t\t'deploy again.',\n\t\t);\n\t\tthis.name = 'DeploySeedsFailed';\n\t}\n}\n\n/**\n * What went wrong underneath: a `SeedFailed`'s own cause (the database's\n * error), or — from a sandbox, where errors arrive as data — the same.\n */\nfunction causeMessage(cause: unknown): string {\n\tconst message = (value: unknown): string | undefined =>\n\t\tvalue && typeof value === 'object' && 'message' in value\n\t\t\t? String(value.message)\n\t\t\t: undefined;\n\tconst inner =\n\t\tcause && typeof cause === 'object' && 'cause' in cause\n\t\t\t? message(cause.cause)\n\t\t\t: undefined;\n\treturn inner ?? message(cause) ?? String(cause);\n}\n\n/** One construct's migrations, as a target reports them. */\nexport interface MigrationsReport {\n\tconstruct: string;\n\tfolder: string;\n\tapplied: readonly string[];\n}\n\n/** One construct's seeds, as a target reports them. */\nexport interface SeedsReport {\n\tconstruct: string;\n\tfolder: string;\n\tseeded: readonly string[];\n}\n\n/**\n * Say what a deploy's migrations and seeds did: a line per construct with\n * something applied or run — `🌱 db/database/seeds: ran 2`, then each seed —\n * and a `migration.applied` or `seed.ran` event beside it.\n */\nexport function reportDatabaseRuns(\n\tmigrations: readonly MigrationsReport[],\n\tseeds: readonly SeedsReport[],\n\tlog: (line: string) => void,\n\temit: (event: TargetEvent) => void,\n): void {\n\tfor (const { construct, folder, applied } of migrations) {\n\t\tif (applied.length === 0) continue;\n\t\tlog(`🗄️ ${folder}: applied ${applied.length}`);\n\t\tfor (const name of applied) log(` ✓ ${name}`);\n\t\temit({\n\t\t\ttype: 'migration.applied',\n\t\t\tconstruct,\n\t\t\tfolder,\n\t\t\tapplied: [...applied],\n\t\t});\n\t}\n\tfor (const { construct, folder, seeded } of seeds) {\n\t\tif (seeded.length === 0) continue;\n\t\tlog(`🌱 ${folder}: ran ${seeded.length}`);\n\t\tfor (const name of seeded) log(` ✓ ${name}`);\n\t\temit({ type: 'seed.ran', construct, folder, seeded: [...seeded] });\n\t}\n}\n\n/** What a dry run lists: the seeds a deploy would run, construct by construct. */\nexport function reportPlannedSeeds(\n\tplanned: readonly { folder: string; seeds: readonly string[] }[],\n\tlog: (line: string) => void,\n): void {\n\tfor (const { folder, seeds } of planned) {\n\t\tlog(`🌱 ${folder}: would run ${seeds.length} (${seeds.join(', ')})`);\n\t}\n}\n"],"mappings":";;;AAaA,MAAa,sBAAsB;;AA4BnC,SAAgB,cAAc,QAAgB,MAAsB;CACnE,OAAO,SAAS,OAAO,SAAS,KAAK,SAAS,GAAG,KAAK,GAAG;AAC1D;;AAGA,SAAgB,eAAe,MAAc,MAAsB;CAClE,OAAO,GAAG,oBA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AK,MAAM,QAAQ,QAAQ,IAAI,QAAQ,MAAM;EAC7C,KAAK;GAAE,MAAM;GAAY;GAAW;GAAQ,QAAQ,CAAC,GAAG,MAAM;EAAE,CAAC;CAClE;AACD;;AAGA,SAAgB,mBACf,SACA,KACO;CACP,KAAK,MAAM,EAAE,QAAQ,WAAW,SAC/B,IAAI,MAAM,OAAO,cAAc,MAAM,OAAO,IAAI,MAAM,KAAK,IAAI,EAAE,EAAE;AAErE"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
|
|
2
|
-
import { k as secretsStoreFor, m as createComposeState } from "./credentials-
|
|
3
|
-
import { u as composeServer } from "./compose-
|
|
4
|
-
import { N as assertDeployedStage } from "./workspace-
|
|
5
|
-
import {
|
|
6
|
-
import { S as createStateStore } from "./sniffer-
|
|
7
|
-
import {
|
|
2
|
+
import { k as secretsStoreFor, m as createComposeState } from "./credentials-V3WgiKmZ.mjs";
|
|
3
|
+
import { u as composeServer } from "./compose-tX6YTa1U.mjs";
|
|
4
|
+
import { N as assertDeployedStage } from "./workspace-D4hzz6Xb.mjs";
|
|
5
|
+
import { loadWorkspaceConfig } from "./config.mjs";
|
|
6
|
+
import { S as createStateStore } from "./sniffer-DdPDiNmc.mjs";
|
|
7
|
+
import { a as describeActor, s as DeployJournal } from "./seeds-Ccn0Ru2T.mjs";
|
|
8
8
|
import { u as prompt } from "./index.mjs";
|
|
9
|
-
import { ghCli } from "./github-
|
|
9
|
+
import { ghCli } from "./github-CHClpJZS.mjs";
|
|
10
10
|
import { dirname, join, resolve } from "node:path";
|
|
11
11
|
import { existsSync } from "node:fs";
|
|
12
12
|
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
@@ -682,4 +682,4 @@ async function composeServerCommand(options, deps = {}) {
|
|
|
682
682
|
//#endregion
|
|
683
683
|
export { composeServerCommand };
|
|
684
684
|
|
|
685
|
-
//# sourceMappingURL=serverSetup-
|
|
685
|
+
//# sourceMappingURL=serverSetup-D0Zor2i4.mjs.map
|