@geekmidas/cli 10.0.0-alpha.65 → 10.0.0-alpha.66
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 +14 -0
- package/dist/{HostingerProvider-Dlmbfass.cjs → HostingerProvider-BznqRC2S.cjs} +3 -3
- package/dist/HostingerProvider-BznqRC2S.cjs.map +1 -0
- package/dist/{HostingerProvider-x9gQTAGZ.mjs → HostingerProvider-CY_VpVud.mjs} +3 -3
- package/dist/HostingerProvider-CY_VpVud.mjs.map +1 -0
- package/dist/{LegacyStateStore-BGoo__sO.cjs → LegacyStateStore-BFcTT2QL.cjs} +2 -2
- package/dist/{LegacyStateStore-BGoo__sO.cjs.map → LegacyStateStore-BFcTT2QL.cjs.map} +1 -1
- package/dist/{LegacyStateStore-BUu1nQ5u.mjs → LegacyStateStore-CFheFo62.mjs} +2 -2
- package/dist/{LegacyStateStore-BUu1nQ5u.mjs.map → LegacyStateStore-CFheFo62.mjs.map} +1 -1
- package/dist/{LocalStateStore-93urXyQe.cjs → LocalStateStore-BVUexSvu.cjs} +2 -2
- package/dist/{LocalStateStore-93urXyQe.cjs.map → LocalStateStore-BVUexSvu.cjs.map} +1 -1
- package/dist/{LocalStateStore-BRhMQRuy.mjs → LocalStateStore-Bm3x9oOg.mjs} +2 -2
- package/dist/{LocalStateStore-BRhMQRuy.mjs.map → LocalStateStore-Bm3x9oOg.mjs.map} +1 -1
- package/dist/{OpenApiTsGenerator-BWuDRHe9.cjs → OpenApiTsGenerator-B2zrdyP4.cjs} +2 -2
- package/dist/{OpenApiTsGenerator-BWuDRHe9.cjs.map → OpenApiTsGenerator-B2zrdyP4.cjs.map} +1 -1
- package/dist/{OpenApiTsGenerator-C6v-IeHt.mjs → OpenApiTsGenerator-BmUAcR7d.mjs} +2 -2
- package/dist/{OpenApiTsGenerator-C6v-IeHt.mjs.map → OpenApiTsGenerator-BmUAcR7d.mjs.map} +1 -1
- package/dist/{Route53Provider-DVILBsvV.cjs → Route53Provider-Bllus2NR.cjs} +2 -2
- package/dist/Route53Provider-Bllus2NR.cjs.map +1 -0
- package/dist/{Route53Provider-Cvj40A8I.mjs → Route53Provider-QXxjkZO1.mjs} +2 -2
- package/dist/Route53Provider-QXxjkZO1.mjs.map +1 -0
- package/dist/{S3StateStore-pw1GhWwt.mjs → S3StateStore-BFHuctWM.mjs} +2 -2
- package/dist/{S3StateStore-pw1GhWwt.mjs.map → S3StateStore-BFHuctWM.mjs.map} +1 -1
- package/dist/{S3StateStore-F4dxw6kS.cjs → S3StateStore-CoXBhILd.cjs} +2 -2
- package/dist/{S3StateStore-F4dxw6kS.cjs.map → S3StateStore-CoXBhILd.cjs.map} +1 -1
- package/dist/{SSMStateStore-Bt9acuAF.cjs → SSMStateStore-BqCA9TP2.cjs} +2 -2
- package/dist/{SSMStateStore-Bt9acuAF.cjs.map → SSMStateStore-BqCA9TP2.cjs.map} +1 -1
- package/dist/{SSMStateStore-Dmj7zzFO.mjs → SSMStateStore-C1kvHScY.mjs} +2 -2
- package/dist/{SSMStateStore-Dmj7zzFO.mjs.map → SSMStateStore-C1kvHScY.mjs.map} +1 -1
- 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/{bundler-D_14JLZF.mjs → bundler-Dvaiud0h.mjs} +4 -4
- package/dist/{bundler-D_14JLZF.mjs.map → bundler-Dvaiud0h.mjs.map} +1 -1
- package/dist/{bundler-D6MlIfBT.cjs → bundler-orRqUJNZ.cjs} +4 -4
- package/dist/{bundler-D6MlIfBT.cjs.map → bundler-orRqUJNZ.cjs.map} +1 -1
- package/dist/{cli-P56vvrDQ.mjs → cli-CfHm0AO7.mjs} +5 -4
- package/dist/cli-CfHm0AO7.mjs.map +1 -0
- package/dist/{cli-BfH1deAT.cjs → cli-D1JkkOwg.cjs} +5 -4
- package/dist/cli-D1JkkOwg.cjs.map +1 -0
- package/dist/{compose-DprE3ASm.mjs → compose-CNQL8BnO.mjs} +18 -482
- package/dist/compose-CNQL8BnO.mjs.map +1 -0
- package/dist/{compose-391oEKj1.cjs → compose-jrLy7KGO.cjs} +16 -571
- package/dist/compose-jrLy7KGO.cjs.map +1 -0
- package/dist/{config-V_X_BMpm.d.cts → config-4XFxX1al.d.cts} +3 -3
- package/dist/{config-BonvTW8p.d.mts.map → config-4XFxX1al.d.cts.map} +1 -1
- package/dist/{config-BonvTW8p.d.mts → config-UtKzhpFb.d.mts} +3 -3
- package/dist/{config-V_X_BMpm.d.cts.map → config-UtKzhpFb.d.mts.map} +1 -1
- package/dist/config.cjs +3 -3
- package/dist/config.d.cts +3 -3
- package/dist/config.d.mts +3 -3
- package/dist/config.mjs +3 -3
- package/dist/databases-C2p5LGAp.cjs +419 -0
- package/dist/databases-C2p5LGAp.cjs.map +1 -0
- package/dist/databases-hUHTuwhx.mjs +346 -0
- package/dist/databases-hUHTuwhx.mjs.map +1 -0
- package/dist/deploy/public.cjs +26 -17
- package/dist/deploy/public.d.cts +136 -19
- package/dist/deploy/public.d.cts.map +1 -1
- package/dist/deploy/public.d.mts +136 -19
- package/dist/deploy/public.d.mts.map +1 -1
- package/dist/deploy/public.mjs +8 -8
- package/dist/deploy-B7aJi_Ah.cjs +511 -0
- package/dist/deploy-B7aJi_Ah.cjs.map +1 -0
- package/dist/deploy-DWn7YfIc.mjs +488 -0
- package/dist/deploy-DWn7YfIc.mjs.map +1 -0
- package/dist/{discover-LMrqsWSU.mjs → discover-BFoJWKGD.mjs} +4 -2
- package/dist/discover-BFoJWKGD.mjs.map +1 -0
- package/dist/{discover-DHdECueV.cjs → discover-OEfZ9OkA.cjs} +4 -2
- package/dist/discover-OEfZ9OkA.cjs.map +1 -0
- package/dist/dokploy-B4LcYG1E.cjs +38 -0
- package/dist/dokploy-B4LcYG1E.cjs.map +1 -0
- package/dist/dokploy-DalwLML5.mjs +38 -0
- package/dist/dokploy-DalwLML5.mjs.map +1 -0
- package/dist/{encryption-B1wJwgae.cjs → encryption-3KlGS1sl.cjs} +5 -7
- package/dist/{encryption-B1wJwgae.cjs.map → encryption-3KlGS1sl.cjs.map} +1 -1
- package/dist/{encryption-DF_hgIpl.mjs → encryption-CPfENwWO.mjs} +3 -5
- package/dist/{encryption-DF_hgIpl.mjs.map → encryption-CPfENwWO.mjs.map} +1 -1
- package/dist/{deploy-CZ5nlpsu.mjs → engine-CunvOG3s.mjs} +2100 -1733
- package/dist/engine-CunvOG3s.mjs.map +1 -0
- package/dist/{deploy-Cy8igpQF.cjs → engine-DR6KurWX.cjs} +2136 -1727
- package/dist/engine-DR6KurWX.cjs.map +1 -0
- package/dist/{github-CYcmTdFs.cjs → github-BJ5gh9bw.cjs} +7 -7
- package/dist/{github-CYcmTdFs.cjs.map → github-BJ5gh9bw.cjs.map} +1 -1
- package/dist/{github-B0YYE98x.mjs → github-MXA9v7Ge.mjs} +3 -3
- package/dist/{github-B0YYE98x.mjs.map → github-MXA9v7Ge.mjs.map} +1 -1
- package/dist/{index-DwKD_8lt.d.mts → index-CyApaHVe.d.cts} +2 -2
- package/dist/{index-DPUAGJaK.d.cts.map → index-CyApaHVe.d.cts.map} +1 -1
- package/dist/{index-DPUAGJaK.d.cts → index-DD1FfUHh.d.mts} +2 -2
- package/dist/{index-DwKD_8lt.d.mts.map → index-DD1FfUHh.d.mts.map} +1 -1
- package/dist/index.cjs +276 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +254 -50
- package/dist/index.mjs.map +1 -1
- package/dist/{migrate-B2qL5wj4.mjs → migrate-BJBcm4sG.mjs} +6 -6
- package/dist/{migrate-B2qL5wj4.mjs.map → migrate-BJBcm4sG.mjs.map} +1 -1
- package/dist/{migrate-q4pPAXtO.cjs → migrate-CF4J4GQS.cjs} +16 -16
- package/dist/{migrate-q4pPAXtO.cjs.map → migrate-CF4J4GQS.cjs.map} +1 -1
- package/dist/openapi.cjs +1 -1
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.mjs +1 -1
- package/dist/provider-B3Sv_a74.cjs +173 -0
- package/dist/provider-B3Sv_a74.cjs.map +1 -0
- package/dist/provider-D7rQzzzf.mjs +138 -0
- package/dist/provider-D7rQzzzf.mjs.map +1 -0
- package/dist/{ready-bQfu9GES.mjs → ready-2s3-CndS.mjs} +3 -3
- package/dist/{ready-bQfu9GES.mjs.map → ready-2s3-CndS.mjs.map} +1 -1
- package/dist/{ready-brEhh68f.cjs → ready-B6uHr4sm.cjs} +3 -3
- package/dist/{ready-brEhh68f.cjs.map → ready-B6uHr4sm.cjs.map} +1 -1
- package/dist/reconcile/public.cjs +1 -1
- package/dist/reconcile/public.d.cts +1 -1
- package/dist/reconcile/public.d.mts +1 -1
- package/dist/reconcile/public.mjs +1 -1
- package/dist/{resolve-N_i4XNd-.cjs → resolve-CVmch0wI.cjs} +3 -3
- package/dist/{resolve-N_i4XNd-.cjs.map → resolve-CVmch0wI.cjs.map} +1 -1
- package/dist/{resolve-DLkIXTct.mjs → resolve-Db0tNlrW.mjs} +3 -3
- package/dist/{resolve-DLkIXTct.mjs.map → resolve-Db0tNlrW.mjs.map} +1 -1
- package/dist/rollback-DvAo4OKS.mjs +133 -0
- package/dist/rollback-DvAo4OKS.mjs.map +1 -0
- package/dist/rollback-DxJK84hy.cjs +162 -0
- package/dist/rollback-DxJK84hy.cjs.map +1 -0
- package/dist/{runtime-BnD7Nn96.d.cts → runtime-BRqFOvPM.d.cts} +2 -2
- package/dist/{runtime-BnD7Nn96.d.cts.map → runtime-BRqFOvPM.d.cts.map} +1 -1
- package/dist/{runtime-j-tmFL65.d.mts → runtime-CEk5n4VH.d.mts} +2 -2
- package/dist/{runtime-j-tmFL65.d.mts.map → runtime-CEk5n4VH.d.mts.map} +1 -1
- package/dist/sandbox/discover-worker.cjs +1 -1
- package/dist/sandbox/discover-worker.mjs +1 -1
- package/dist/sandbox/migrate-worker.cjs +61 -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 +62 -0
- package/dist/sandbox/migrate-worker.mjs.map +1 -0
- package/dist/{schemas-D2LCF689.mjs → schemas-Cfhtpdo0.mjs} +10 -2
- package/dist/{schemas-Ckm_aBnF.cjs.map → schemas-Cfhtpdo0.mjs.map} +1 -1
- package/dist/{schemas-Ckm_aBnF.cjs → schemas-RUlKHu27.cjs} +15 -1
- package/dist/{schemas-D2LCF689.mjs.map → schemas-RUlKHu27.cjs.map} +1 -1
- package/dist/{sniffer-BSwaL-dX.cjs → sniffer-5xmrkh2a.cjs} +112 -606
- package/dist/sniffer-5xmrkh2a.cjs.map +1 -0
- package/dist/{sniffer-BZ-OJO4Y.mjs → sniffer-BAQhLEsI.mjs} +95 -546
- package/dist/sniffer-BAQhLEsI.mjs.map +1 -0
- package/dist/{state-DF26e_lo.cjs → state-Y6ATakMX.cjs} +744 -20
- package/dist/state-Y6ATakMX.cjs.map +1 -0
- package/dist/{state-B8YwmUZU.mjs → state-uuYqnRVO.mjs} +605 -19
- package/dist/state-uuYqnRVO.mjs.map +1 -0
- package/dist/target/public.cjs +1 -1
- package/dist/target/public.d.cts +2 -2
- package/dist/target/public.d.mts +2 -2
- package/dist/target/public.mjs +1 -1
- package/dist/{terminal-Bs5E1oxm.cjs → terminal-CHy_MdjG.cjs} +11 -15
- package/dist/{terminal-Bs5E1oxm.cjs.map → terminal-CHy_MdjG.cjs.map} +1 -1
- package/dist/{terminal-CfbiYUbZ.mjs → terminal-DUhcZ1ND.mjs} +4 -4
- package/dist/{terminal-CfbiYUbZ.mjs.map → terminal-DUhcZ1ND.mjs.map} +1 -1
- package/dist/{types-ByMWkXKP.d.cts → types-CSw2w69a.d.mts} +68 -10
- package/dist/types-CSw2w69a.d.mts.map +1 -0
- package/dist/{types-BCzMWBb6.d.mts → types-D5WIxRDP.d.cts} +69 -9
- package/dist/types-D5WIxRDP.d.cts.map +1 -0
- package/dist/vitest.cjs +1 -1
- package/dist/vitest.mjs +1 -1
- 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-C06_pW4g.mjs → workspace-Be6uBhlF.mjs} +10 -3
- package/dist/workspace-Be6uBhlF.mjs.map +1 -0
- package/dist/{workspace-BewAHZIo.cjs → workspace-ON-bqiJz.cjs} +10 -3
- package/dist/workspace-ON-bqiJz.cjs.map +1 -0
- package/package.json +13 -13
- package/dist/HostingerProvider-Dlmbfass.cjs.map +0 -1
- package/dist/HostingerProvider-x9gQTAGZ.mjs.map +0 -1
- package/dist/Route53Provider-Cvj40A8I.mjs.map +0 -1
- package/dist/Route53Provider-DVILBsvV.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/cli-BfH1deAT.cjs.map +0 -1
- package/dist/cli-P56vvrDQ.mjs.map +0 -1
- package/dist/compose-391oEKj1.cjs.map +0 -1
- package/dist/compose-DprE3ASm.mjs.map +0 -1
- package/dist/deploy-9MBG_QLd.mjs +0 -137
- package/dist/deploy-9MBG_QLd.mjs.map +0 -1
- package/dist/deploy-B80idPUZ.cjs +0 -142
- package/dist/deploy-B80idPUZ.cjs.map +0 -1
- package/dist/deploy-CZ5nlpsu.mjs.map +0 -1
- package/dist/deploy-Cy8igpQF.cjs.map +0 -1
- package/dist/discover-DHdECueV.cjs.map +0 -1
- package/dist/discover-LMrqsWSU.mjs.map +0 -1
- package/dist/dokploy-BdtBePjp.mjs +0 -32
- package/dist/dokploy-BdtBePjp.mjs.map +0 -1
- package/dist/dokploy-iFY8MY-L.cjs +0 -32
- package/dist/dokploy-iFY8MY-L.cjs.map +0 -1
- package/dist/sniffer-BSwaL-dX.cjs.map +0 -1
- package/dist/sniffer-BZ-OJO4Y.mjs.map +0 -1
- package/dist/state-B8YwmUZU.mjs.map +0 -1
- package/dist/state-DF26e_lo.cjs.map +0 -1
- package/dist/storage-BzaUxmqe.mjs +0 -124
- package/dist/storage-BzaUxmqe.mjs.map +0 -1
- package/dist/storage-CSGoC3bK.cjs +0 -152
- package/dist/storage-CSGoC3bK.cjs.map +0 -1
- package/dist/store-CJF1Tqkq.cjs +0 -510
- package/dist/store-CJF1Tqkq.cjs.map +0 -1
- package/dist/store-CLiHnqOY.mjs +0 -415
- package/dist/store-CLiHnqOY.mjs.map +0 -1
- package/dist/types-BCzMWBb6.d.mts.map +0 -1
- package/dist/types-ByMWkXKP.d.cts.map +0 -1
- package/dist/workspace-BewAHZIo.cjs.map +0 -1
- package/dist/workspace-C06_pW4g.mjs.map +0 -1
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
|
|
2
2
|
const require_local = require("./local-BdH4XN0E.cjs");
|
|
3
|
-
const require_discover = require("./discover-
|
|
3
|
+
const require_discover = require("./discover-OEfZ9OkA.cjs");
|
|
4
4
|
const require_sandbox = require("./sandbox-CL--ZDui.cjs");
|
|
5
5
|
const require_derive = require("./derive-DAbo49sm.cjs");
|
|
6
6
|
const require_define = require("./define-DzRz8FgH.cjs");
|
|
7
|
-
const
|
|
8
|
-
const require_store = require("./store-CJF1Tqkq.cjs");
|
|
9
|
-
const require_state = require("./state-DF26e_lo.cjs");
|
|
7
|
+
const require_state = require("./state-Y6ATakMX.cjs");
|
|
10
8
|
const require_fakes = require("./fakes-zW-jNAbQ.cjs");
|
|
9
|
+
const require_databases = require("./databases-C2p5LGAp.cjs");
|
|
11
10
|
let node_path = require("node:path");
|
|
12
11
|
let node_fs = require("node:fs");
|
|
13
12
|
let node_fs_promises = require("node:fs/promises");
|
|
14
13
|
let _geekmidas_manifest = require("@geekmidas/manifest");
|
|
15
|
-
let node_module = require("node:module");
|
|
16
14
|
let node_url = require("node:url");
|
|
17
15
|
let node_child_process = require("node:child_process");
|
|
18
|
-
let pg = require("pg");
|
|
19
|
-
pg = require_rolldown_runtime.__toESM(pg, 1);
|
|
20
16
|
let yaml = require("yaml");
|
|
21
17
|
let node_https = require("node:https");
|
|
22
18
|
//#region src/compose/docker.ts
|
|
@@ -605,7 +601,7 @@ function stackApps(workspace, manifest, plan, options) {
|
|
|
605
601
|
if (!app || !resource || !app.port) continue;
|
|
606
602
|
const host = hostOf(name, app, workspace, resource, options);
|
|
607
603
|
const tag = declaration.kind === "site" ? siteTag(options.images.tag, options.stage) : options.images.tag;
|
|
608
|
-
const ref = require_state.validateImageRef(
|
|
604
|
+
const ref = require_state.validateImageRef(require_state.imageRef(options.identity, name, options.images.registry, tag));
|
|
609
605
|
apps.push({
|
|
610
606
|
app: name,
|
|
611
607
|
name,
|
|
@@ -711,474 +707,6 @@ function envFile(env) {
|
|
|
711
707
|
return `${Object.entries(env).sort(([a], [b]) => a.localeCompare(b)).map(([key, value]) => `${key}=${value}`).join("\n")}\n`;
|
|
712
708
|
}
|
|
713
709
|
//#endregion
|
|
714
|
-
//#region src/migrate/provider.ts
|
|
715
|
-
/**
|
|
716
|
-
* One construct's migrations and seeds, read from its folders.
|
|
717
|
-
*
|
|
718
|
-
* Two kinds of file, told apart by extension rather than by configuration: a
|
|
719
|
-
* script exports `up` (and may export `down`) — or `seed(db, { stage })`, in
|
|
720
|
-
* `seeds/` — and a
|
|
721
|
-
* `.sql` file is run whole. The second is what makes a folder independent of
|
|
722
|
-
* the client the app uses — Better Auth's schema is SQL whatever the
|
|
723
|
-
* application queries with.
|
|
724
|
-
*/
|
|
725
|
-
const SCRIPTS = /* @__PURE__ */ new Set([
|
|
726
|
-
".ts",
|
|
727
|
-
".mts",
|
|
728
|
-
".js",
|
|
729
|
-
".mjs"
|
|
730
|
-
]);
|
|
731
|
-
/** Two files in one folder that would be one migration. */
|
|
732
|
-
var DuplicateMigration = class extends Error {
|
|
733
|
-
folder;
|
|
734
|
-
migration;
|
|
735
|
-
constructor(folder, migration) {
|
|
736
|
-
super(`${folder} has two migrations named '${migration}' — a script and a .sql file with the same name. A migration is recorded by name, so only one of them could ever run; rename or remove the other.`);
|
|
737
|
-
this.folder = folder;
|
|
738
|
-
this.migration = migration;
|
|
739
|
-
this.name = "DuplicateMigration";
|
|
740
|
-
}
|
|
741
|
-
};
|
|
742
|
-
/** A script in a migrations folder that exports no `up`. */
|
|
743
|
-
var MigrationHasNoUp = class extends Error {
|
|
744
|
-
file;
|
|
745
|
-
constructor(file) {
|
|
746
|
-
super(`${file} is in a migrations folder but exports no \`up\` function. Export \`async function up(db: Kysely<unknown>)\`, or move the file out of the folder if it is not a migration.`);
|
|
747
|
-
this.file = file;
|
|
748
|
-
this.name = "MigrationHasNoUp";
|
|
749
|
-
}
|
|
750
|
-
};
|
|
751
|
-
/** A script in a seeds folder that exports no `seed`. */
|
|
752
|
-
var SeedHasNoSeed = class extends Error {
|
|
753
|
-
file;
|
|
754
|
-
constructor(file) {
|
|
755
|
-
super(`${file} is in a seeds folder but exports no \`seed\` function. Export \`async function seed(db, { stage })\`, or move the file out of the folder if it is not a seed.`);
|
|
756
|
-
this.file = file;
|
|
757
|
-
this.name = "SeedHasNoSeed";
|
|
758
|
-
}
|
|
759
|
-
};
|
|
760
|
-
/**
|
|
761
|
-
* The migration files in a folder, by name, without reading them.
|
|
762
|
-
*
|
|
763
|
-
* Also what `gkm dev` compares against a construct's history to report what
|
|
764
|
-
* is pending, which is why it is separate from loading them.
|
|
765
|
-
*/
|
|
766
|
-
async function migrationFiles(folder) {
|
|
767
|
-
const entries = await (0, node_fs_promises.readdir)(folder, { withFileTypes: true }).catch((error) => {
|
|
768
|
-
if (error.code === "ENOENT") return [];
|
|
769
|
-
throw error;
|
|
770
|
-
});
|
|
771
|
-
const files = /* @__PURE__ */ new Map();
|
|
772
|
-
for (const entry of entries) {
|
|
773
|
-
if (!entry.isFile() || !isMigration(entry.name)) continue;
|
|
774
|
-
const name = entry.name.slice(0, -(0, node_path.extname)(entry.name).length);
|
|
775
|
-
if (files.has(name)) throw new DuplicateMigration(folder, name);
|
|
776
|
-
files.set(name, (0, node_path.join)(folder, entry.name));
|
|
777
|
-
}
|
|
778
|
-
return files;
|
|
779
|
-
}
|
|
780
|
-
/** A Kysely provider over one construct's folder. */
|
|
781
|
-
function folderProvider(folder, raw) {
|
|
782
|
-
return { async getMigrations() {
|
|
783
|
-
const migrations = {};
|
|
784
|
-
for (const [name, file] of await migrationFiles(folder)) migrations[name] = (0, node_path.extname)(file) === ".sql" ? await sqlMigration(file, raw) : await scriptMigration(file);
|
|
785
|
-
return migrations;
|
|
786
|
-
} };
|
|
787
|
-
}
|
|
788
|
-
/**
|
|
789
|
-
* The seeds in a folder, loaded, in name order.
|
|
790
|
-
*
|
|
791
|
-
* Every one runs on every pass — there is no history to consult — so the order
|
|
792
|
-
* is the only thing between two seeds where one reads what another writes.
|
|
793
|
-
* Name them to sort that way.
|
|
794
|
-
*/
|
|
795
|
-
async function loadSeeds(folder, raw) {
|
|
796
|
-
const files = [...await migrationFiles(folder)].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
797
|
-
const seeds = [];
|
|
798
|
-
for (const [name, file] of files) seeds.push({
|
|
799
|
-
name,
|
|
800
|
-
run: (0, node_path.extname)(file) === ".sql" ? (await sqlMigration(file, raw)).up : await scriptSeed(file)
|
|
801
|
-
});
|
|
802
|
-
return seeds;
|
|
803
|
-
}
|
|
804
|
-
/**
|
|
805
|
-
* A seed script, imported as it is on disk now.
|
|
806
|
-
*
|
|
807
|
-
* Keyed by its modification time: a seed is run again after it is edited, and
|
|
808
|
-
* a process that has imported it once would otherwise run the old one.
|
|
809
|
-
*/
|
|
810
|
-
async function scriptSeed(file) {
|
|
811
|
-
const url = (0, node_url.pathToFileURL)(file);
|
|
812
|
-
url.searchParams.set("mtime", String((await (0, node_fs_promises.stat)(file)).mtimeMs));
|
|
813
|
-
const module = await import(url.href);
|
|
814
|
-
if (typeof module.seed !== "function") throw new SeedHasNoSeed(file);
|
|
815
|
-
return module.seed;
|
|
816
|
-
}
|
|
817
|
-
function isMigration(file) {
|
|
818
|
-
if (file.endsWith(".d.ts")) return false;
|
|
819
|
-
if (/\.(spec|test)\.[cm]?[jt]s$/.test(file)) return false;
|
|
820
|
-
const extension = (0, node_path.extname)(file);
|
|
821
|
-
return extension === ".sql" || SCRIPTS.has(extension);
|
|
822
|
-
}
|
|
823
|
-
async function scriptMigration(file) {
|
|
824
|
-
const module = await import((0, node_url.pathToFileURL)(file).href);
|
|
825
|
-
if (typeof module.up !== "function") throw new MigrationHasNoUp(file);
|
|
826
|
-
return {
|
|
827
|
-
up: module.up,
|
|
828
|
-
...typeof module.down === "function" ? { down: module.down } : {}
|
|
829
|
-
};
|
|
830
|
-
}
|
|
831
|
-
/**
|
|
832
|
-
* A `.sql` file, run whole.
|
|
833
|
-
*
|
|
834
|
-
* One query rather than split on `;`: with no parameters, Postgres takes
|
|
835
|
-
* several statements in one message, and splitting by hand breaks on the first
|
|
836
|
-
* `;` inside a string or a function body. There is no `down` — a generated
|
|
837
|
-
* schema is rolled back by a migration that says how, not by guessing.
|
|
838
|
-
*/
|
|
839
|
-
async function sqlMigration(file, raw) {
|
|
840
|
-
const statements = await (0, node_fs_promises.readFile)(file, "utf-8");
|
|
841
|
-
return { up: async (db) => {
|
|
842
|
-
await raw.raw(statements).execute(db);
|
|
843
|
-
} };
|
|
844
|
-
}
|
|
845
|
-
//#endregion
|
|
846
|
-
//#region src/migrate/databases.ts
|
|
847
|
-
/**
|
|
848
|
-
* Bring each construct's schema up to its migrations folder.
|
|
849
|
-
*
|
|
850
|
-
* Which constructs, in what order, from which folder, is `migrationTargets`'
|
|
851
|
-
* answer and nobody else's. What is decided here is only how one target is
|
|
852
|
-
* run: as its owner, in its own schema, with a history of its own.
|
|
853
|
-
*/
|
|
854
|
-
/** A folder under `db/` that names no construct. */
|
|
855
|
-
var UnknownMigrationFolder = class extends Error {
|
|
856
|
-
folder;
|
|
857
|
-
known;
|
|
858
|
-
constructor(folder, known) {
|
|
859
|
-
super(`${folder} names no database construct, so its migrations would never run. ${known.length > 0 ? `The folders that do: ${known.join(", ")}.` : "This project declares no database."} Rename the folder after the construct it belongs to.`);
|
|
860
|
-
this.folder = folder;
|
|
861
|
-
this.known = known;
|
|
862
|
-
this.name = "UnknownMigrationFolder";
|
|
863
|
-
}
|
|
864
|
-
};
|
|
865
|
-
/** A construct was asked for by a name that takes no migrations. */
|
|
866
|
-
var NoSuchMigrationTarget = class extends Error {
|
|
867
|
-
construct;
|
|
868
|
-
known;
|
|
869
|
-
constructor(construct, known) {
|
|
870
|
-
super(`'${construct}' is not a database construct. ` + (known.length > 0 ? `The ones with migrations: ${known.join(", ")}.` : "This project declares no database."));
|
|
871
|
-
this.construct = construct;
|
|
872
|
-
this.known = known;
|
|
873
|
-
this.name = "NoSuchMigrationTarget";
|
|
874
|
-
}
|
|
875
|
-
};
|
|
876
|
-
/**
|
|
877
|
-
* A migration left directly in a construct's folder, where nothing reads it.
|
|
878
|
-
*
|
|
879
|
-
* Migrations moved into `migrations/` so seeds could sit beside them. A file
|
|
880
|
-
* still at the old level would otherwise never run, and nothing would say so.
|
|
881
|
-
*/
|
|
882
|
-
var MigrationsOutsideFolder = class extends Error {
|
|
883
|
-
folder;
|
|
884
|
-
files;
|
|
885
|
-
constructor(folder, files) {
|
|
886
|
-
super(`${folder} has ${files.join(", ")} directly inside it, where nothing runs them. Migrations live in ${folder}/migrations/ and seeds in ${folder}/seeds/ — move ${files.length === 1 ? "it" : "them"} there.`);
|
|
887
|
-
this.folder = folder;
|
|
888
|
-
this.files = files;
|
|
889
|
-
this.name = "MigrationsOutsideFolder";
|
|
890
|
-
}
|
|
891
|
-
};
|
|
892
|
-
/** A folder inside a construct's folder that is neither `migrations` nor `seeds`. */
|
|
893
|
-
var UnknownDatabaseFolder = class extends Error {
|
|
894
|
-
folder;
|
|
895
|
-
constructor(folder) {
|
|
896
|
-
super(`${folder} is neither migrations/ nor seeds/, so nothing in it would ever run. A construct's folder holds those two; rename or remove it.`);
|
|
897
|
-
this.folder = folder;
|
|
898
|
-
this.name = "UnknownDatabaseFolder";
|
|
899
|
-
}
|
|
900
|
-
};
|
|
901
|
-
/** A seed failed; its own writes are rolled back, the ones before it stay. */
|
|
902
|
-
var SeedFailed = class extends Error {
|
|
903
|
-
construct;
|
|
904
|
-
seed;
|
|
905
|
-
cause;
|
|
906
|
-
constructor(construct, seed, cause) {
|
|
907
|
-
super(`${construct}: seed '${seed}' failed — ${cause instanceof Error ? cause.message : String(cause)}. Its writes were rolled back; fix it and run it again.`);
|
|
908
|
-
this.construct = construct;
|
|
909
|
-
this.seed = seed;
|
|
910
|
-
this.cause = cause;
|
|
911
|
-
this.name = "SeedFailed";
|
|
912
|
-
}
|
|
913
|
-
};
|
|
914
|
-
/** A construct with roles has no owner URL to migrate with. */
|
|
915
|
-
var NoOwnerCredential = class extends Error {
|
|
916
|
-
construct;
|
|
917
|
-
key;
|
|
918
|
-
constructor(construct, key) {
|
|
919
|
-
super(`${construct} has no ${key} to migrate with. Migrations run as the owner role — the runtime one cannot create a table — and nothing resolved its URL. Is the stage reconciled?`);
|
|
920
|
-
this.construct = construct;
|
|
921
|
-
this.key = key;
|
|
922
|
-
this.name = "NoOwnerCredential";
|
|
923
|
-
}
|
|
924
|
-
};
|
|
925
|
-
/** A migration failed; the ones before it in the run stay applied. */
|
|
926
|
-
var MigrationFailed = class extends Error {
|
|
927
|
-
construct;
|
|
928
|
-
migration;
|
|
929
|
-
cause;
|
|
930
|
-
constructor(construct, migration, cause) {
|
|
931
|
-
super(`${construct}: migration ${migration ? `'${migration}' ` : ""}failed — ${cause instanceof Error ? cause.message : String(cause)}`);
|
|
932
|
-
this.construct = construct;
|
|
933
|
-
this.migration = migration;
|
|
934
|
-
this.cause = cause;
|
|
935
|
-
this.name = "MigrationFailed";
|
|
936
|
-
}
|
|
937
|
-
};
|
|
938
|
-
/** The project's Kysely could not be found from where a database is declared. */
|
|
939
|
-
var KyselyNotFound = class extends Error {
|
|
940
|
-
from;
|
|
941
|
-
constructor(from) {
|
|
942
|
-
super(`Could not resolve 'kysely' from ${from}. Migrations run with the project's own Kysely — install it where the database is declared.`);
|
|
943
|
-
this.from = from;
|
|
944
|
-
this.name = "KyselyNotFound";
|
|
945
|
-
}
|
|
946
|
-
};
|
|
947
|
-
/** Apply every pending migration, construct by construct, parents first. */
|
|
948
|
-
async function migrateDatabases(options) {
|
|
949
|
-
const runs = [];
|
|
950
|
-
for (const target of await targetsFor(options)) {
|
|
951
|
-
if ((await migrationFiles((0, node_path.join)(options.root, target.migrations))).size === 0) {
|
|
952
|
-
runs.push({
|
|
953
|
-
target,
|
|
954
|
-
applied: []
|
|
955
|
-
});
|
|
956
|
-
continue;
|
|
957
|
-
}
|
|
958
|
-
const applied = await withMigrator(options, target, async (migrator) => {
|
|
959
|
-
const { error, results = [] } = await migrator.migrateToLatest();
|
|
960
|
-
if (error) {
|
|
961
|
-
const failed = results.find((result) => result.status === "Error");
|
|
962
|
-
throw new MigrationFailed(target.id, failed?.migrationName, error);
|
|
963
|
-
}
|
|
964
|
-
return results.filter((result) => result.status === "Success").map((result) => result.migrationName);
|
|
965
|
-
});
|
|
966
|
-
runs.push({
|
|
967
|
-
target,
|
|
968
|
-
applied
|
|
969
|
-
});
|
|
970
|
-
}
|
|
971
|
-
return runs;
|
|
972
|
-
}
|
|
973
|
-
/**
|
|
974
|
-
* Run every construct's seeds, parents first — each one, every time, on every
|
|
975
|
-
* stage, production included. Each is handed the stage, so a seed decides
|
|
976
|
-
* what belongs where.
|
|
977
|
-
*
|
|
978
|
-
* Seeds are reference data kept up to date by being run again, so there is no
|
|
979
|
-
* history: a seed is an upsert, and a changed one is applied by the next run.
|
|
980
|
-
* Each runs in its own transaction, as the construct's owner, so a failure
|
|
981
|
-
* leaves nothing half-written. Assumes the schema is migrated —
|
|
982
|
-
* {@link migrateAndSeed} is what makes that true.
|
|
983
|
-
*/
|
|
984
|
-
async function seedDatabases(options) {
|
|
985
|
-
const runs = [];
|
|
986
|
-
for (const target of await targetsFor(options)) {
|
|
987
|
-
const folder = (0, node_path.join)(options.root, target.seeds);
|
|
988
|
-
if ((await migrationFiles(folder)).size === 0) {
|
|
989
|
-
runs.push({
|
|
990
|
-
target,
|
|
991
|
-
seeded: []
|
|
992
|
-
});
|
|
993
|
-
continue;
|
|
994
|
-
}
|
|
995
|
-
const seeded = await withOwner(options, target, async (db, kysely) => {
|
|
996
|
-
const names = [];
|
|
997
|
-
for (const seed of await loadSeeds(folder, kysely.sql)) {
|
|
998
|
-
try {
|
|
999
|
-
await db.transaction().execute((trx) => seed.run(trx, { stage: options.stage }));
|
|
1000
|
-
} catch (error) {
|
|
1001
|
-
throw new SeedFailed(target.id, seed.name, error);
|
|
1002
|
-
}
|
|
1003
|
-
names.push(seed.name);
|
|
1004
|
-
}
|
|
1005
|
-
return names;
|
|
1006
|
-
});
|
|
1007
|
-
runs.push({
|
|
1008
|
-
target,
|
|
1009
|
-
seeded
|
|
1010
|
-
});
|
|
1011
|
-
}
|
|
1012
|
-
return runs;
|
|
1013
|
-
}
|
|
1014
|
-
/**
|
|
1015
|
-
* Migrate, then seed: a seed only ever runs against the schema it was written
|
|
1016
|
-
* for.
|
|
1017
|
-
*
|
|
1018
|
-
* With `only`, the constructs it lives in are migrated too — a tenant's seed
|
|
1019
|
-
* cannot run before the database that owns its schema exists — and only it is
|
|
1020
|
-
* seeded.
|
|
1021
|
-
*/
|
|
1022
|
-
async function migrateAndSeed(options) {
|
|
1023
|
-
const migrations = [];
|
|
1024
|
-
for (const target of await withParents(options)) migrations.push(...await migrateDatabases({
|
|
1025
|
-
...options,
|
|
1026
|
-
only: target.id
|
|
1027
|
-
}));
|
|
1028
|
-
return {
|
|
1029
|
-
migrations,
|
|
1030
|
-
seeds: await seedDatabases(options)
|
|
1031
|
-
};
|
|
1032
|
-
}
|
|
1033
|
-
/** The targets `only` names, after the ones it lives in; all without it. */
|
|
1034
|
-
async function withParents(options) {
|
|
1035
|
-
const chosen = await targetsFor(options);
|
|
1036
|
-
if (!options.only) return chosen;
|
|
1037
|
-
const all = (0, _geekmidas_manifest.migrationTargets)(options.manifest);
|
|
1038
|
-
const ids = /* @__PURE__ */ new Set();
|
|
1039
|
-
for (const target of chosen) {
|
|
1040
|
-
let current = target;
|
|
1041
|
-
while (current) {
|
|
1042
|
-
ids.add(current.id);
|
|
1043
|
-
const parent = current.of;
|
|
1044
|
-
current = parent ? all.find((t) => t.id === parent) : void 0;
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
return all.filter((target) => ids.has(target.id));
|
|
1048
|
-
}
|
|
1049
|
-
/**
|
|
1050
|
-
* What each construct's folder has that its history does not — without
|
|
1051
|
-
* applying any of it. What `gkm dev` reports.
|
|
1052
|
-
*/
|
|
1053
|
-
async function pendingMigrations(options) {
|
|
1054
|
-
const found = [];
|
|
1055
|
-
for (const target of await targetsFor(options)) {
|
|
1056
|
-
if ((await migrationFiles((0, node_path.join)(options.root, target.migrations))).size === 0) continue;
|
|
1057
|
-
const pending = await withMigrator(options, target, async (migrator) => (await migrator.getMigrations()).filter((migration) => migration.executedAt === void 0).map((migration) => migration.name));
|
|
1058
|
-
if (pending.length > 0) found.push({
|
|
1059
|
-
target,
|
|
1060
|
-
pending
|
|
1061
|
-
});
|
|
1062
|
-
}
|
|
1063
|
-
return found;
|
|
1064
|
-
}
|
|
1065
|
-
/**
|
|
1066
|
-
* The targets this run covers, with every folder under `db/` accounted for.
|
|
1067
|
-
*
|
|
1068
|
-
* A folder that names no construct is an error rather than something to skip:
|
|
1069
|
-
* a typo in its name is otherwise a migration that silently never runs.
|
|
1070
|
-
*/
|
|
1071
|
-
async function targetsFor(options) {
|
|
1072
|
-
const targets = (0, _geekmidas_manifest.migrationTargets)(options.manifest);
|
|
1073
|
-
const folders = targets.map((target) => target.folder);
|
|
1074
|
-
for (const folder of await foldersIn((0, node_path.join)(options.root, _geekmidas_manifest.MIGRATIONS_ROOT))) {
|
|
1075
|
-
const relative = `${_geekmidas_manifest.MIGRATIONS_ROOT}/${folder}`;
|
|
1076
|
-
if (!folders.includes(relative)) throw new UnknownMigrationFolder(relative, folders);
|
|
1077
|
-
await checkLayout(options.root, relative);
|
|
1078
|
-
}
|
|
1079
|
-
if (!options.only) return targets;
|
|
1080
|
-
const id = (0, _geekmidas_manifest.canonicalId)(options.only);
|
|
1081
|
-
const chosen = targets.filter((target) => target.id === id);
|
|
1082
|
-
if (chosen.length === 0) throw new NoSuchMigrationTarget(options.only, targets.map((target) => target.id));
|
|
1083
|
-
return chosen;
|
|
1084
|
-
}
|
|
1085
|
-
/**
|
|
1086
|
-
* A construct's folder holds `migrations/` and `seeds/`, and nothing else —
|
|
1087
|
-
* anything beside them is a file or folder nothing would ever run.
|
|
1088
|
-
*/
|
|
1089
|
-
async function checkLayout(root, folder) {
|
|
1090
|
-
const entries = await (0, node_fs_promises.readdir)((0, node_path.join)(root, folder), { withFileTypes: true });
|
|
1091
|
-
const loose = entries.filter((entry) => entry.isFile() && !entry.name.startsWith(".")).map((entry) => entry.name);
|
|
1092
|
-
if (loose.length > 0) throw new MigrationsOutsideFolder(folder, loose);
|
|
1093
|
-
for (const entry of entries) if (entry.isDirectory() && !_geekmidas_manifest.DATABASE_FOLDERS.includes(entry.name)) throw new UnknownDatabaseFolder(`${folder}/${entry.name}`);
|
|
1094
|
-
}
|
|
1095
|
-
async function foldersIn(dir) {
|
|
1096
|
-
return (await (0, node_fs_promises.readdir)(dir, { withFileTypes: true }).catch((error) => {
|
|
1097
|
-
if (error.code === "ENOENT") return [];
|
|
1098
|
-
throw error;
|
|
1099
|
-
})).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
1100
|
-
}
|
|
1101
|
-
/**
|
|
1102
|
-
* A migrator for one target, connected as its owner.
|
|
1103
|
-
*
|
|
1104
|
-
* No `migrationTableSchema`: the owner role's `search_path` is pinned to the
|
|
1105
|
-
* construct's schema, so the history lands there — `app.kysely_migration` for
|
|
1106
|
-
* the database, `auth_database.kysely_migration` for its tenant — and two
|
|
1107
|
-
* constructs in one Postgres never share one.
|
|
1108
|
-
*
|
|
1109
|
-
* Unordered migrations are allowed. Files are timestamped, so a branch merged
|
|
1110
|
-
* after another's migration ran carries an older one; refusing it would make
|
|
1111
|
-
* every such merge a manual repair.
|
|
1112
|
-
*/
|
|
1113
|
-
async function withMigrator(options, target, run) {
|
|
1114
|
-
return withOwner(options, target, (db, { Migrator, sql }) => run(new Migrator({
|
|
1115
|
-
db,
|
|
1116
|
-
provider: folderProvider((0, node_path.join)(options.root, target.migrations), sql),
|
|
1117
|
-
allowUnorderedMigrations: true
|
|
1118
|
-
})));
|
|
1119
|
-
}
|
|
1120
|
-
/**
|
|
1121
|
-
* One target's database, connected as its owner and closed afterwards — what
|
|
1122
|
-
* migrations and seeds both run as.
|
|
1123
|
-
*/
|
|
1124
|
-
async function withOwner(options, target, run) {
|
|
1125
|
-
const kysely = await kyselyFrom(options.sources?.[target.id]?.file ?? (target.of ? options.sources?.[target.of]?.file : void 0) ?? (0, node_path.join)(options.root, "package.json"));
|
|
1126
|
-
const db = new kysely.Kysely({ dialect: new kysely.PostgresDialect({ pool: new pg.default.Pool(poolConfig(ownerUrl(options, target))) }) });
|
|
1127
|
-
try {
|
|
1128
|
-
return await run(db, kysely);
|
|
1129
|
-
} finally {
|
|
1130
|
-
await db.destroy();
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
/**
|
|
1134
|
-
* The owner's URL, with no fallback to the runtime one.
|
|
1135
|
-
*
|
|
1136
|
-
* The runtime role can create nothing, so falling back would only move the
|
|
1137
|
-
* failure to the first `CREATE TABLE` and make it read like a permissions
|
|
1138
|
-
* bug. The one exception is a database declared `roles: false`, where there is
|
|
1139
|
-
* no owner — both URLs are the master credential by design.
|
|
1140
|
-
*/
|
|
1141
|
-
function ownerUrl(options, target) {
|
|
1142
|
-
const key = (0, _geekmidas_manifest.provideKey)(target.id, "ownerUrl");
|
|
1143
|
-
const owner = options.env[key];
|
|
1144
|
-
if (owner) return owner;
|
|
1145
|
-
const database = options.manifest[target.of ?? target.id];
|
|
1146
|
-
if (database?.kind === "database" && database.roles === false) {
|
|
1147
|
-
const url = options.env[(0, _geekmidas_manifest.provideKey)(target.id, "url")];
|
|
1148
|
-
if (url) return url;
|
|
1149
|
-
}
|
|
1150
|
-
throw new NoOwnerCredential(target.id, key);
|
|
1151
|
-
}
|
|
1152
|
-
/**
|
|
1153
|
-
* Pool settings for a URL, with `?search_path=` as the startup option Postgres
|
|
1154
|
-
* reads. Only a `roles: false` URL carries it — a role pins its own.
|
|
1155
|
-
*/
|
|
1156
|
-
function poolConfig(url) {
|
|
1157
|
-
const parsed = new URL(url);
|
|
1158
|
-
const searchPath = parsed.searchParams.get("search_path");
|
|
1159
|
-
if (!searchPath) return { connectionString: url };
|
|
1160
|
-
parsed.searchParams.delete("search_path");
|
|
1161
|
-
return {
|
|
1162
|
-
connectionString: parsed.toString(),
|
|
1163
|
-
options: `-c search_path=${searchPath}`
|
|
1164
|
-
};
|
|
1165
|
-
}
|
|
1166
|
-
/** Kysely as the project resolves it from `from`. */
|
|
1167
|
-
async function kyselyFrom(from) {
|
|
1168
|
-
const require$1 = (0, node_module.createRequire)(from);
|
|
1169
|
-
try {
|
|
1170
|
-
const [main, migration] = await Promise.all([import((0, node_url.pathToFileURL)(require$1.resolve("kysely")).href), import((0, node_url.pathToFileURL)(require$1.resolve("kysely/migration")).href)]);
|
|
1171
|
-
return {
|
|
1172
|
-
Kysely: main.Kysely,
|
|
1173
|
-
PostgresDialect: main.PostgresDialect,
|
|
1174
|
-
sql: main.sql,
|
|
1175
|
-
Migrator: migration.Migrator
|
|
1176
|
-
};
|
|
1177
|
-
} catch {
|
|
1178
|
-
throw new KyselyNotFound(from);
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
//#endregion
|
|
1182
710
|
//#region src/target/compose/health.ts
|
|
1183
711
|
/**
|
|
1184
712
|
* Asking each app of a stack whether it answers — through Caddy, over HTTPS,
|
|
@@ -1378,7 +906,7 @@ const defaultDeps = {
|
|
|
1378
906
|
bundle: bundleInSandbox,
|
|
1379
907
|
revision: gitRevision,
|
|
1380
908
|
sql: require_state.pgClient,
|
|
1381
|
-
migrate: migrateDatabases,
|
|
909
|
+
migrate: require_databases.migrateDatabases,
|
|
1382
910
|
probe: httpsProbe,
|
|
1383
911
|
healthAttempts: 90,
|
|
1384
912
|
healthIntervalMs: 2e3,
|
|
@@ -1418,7 +946,14 @@ async function validateCompose(ctx, deps, forced) {
|
|
|
1418
946
|
});
|
|
1419
947
|
if (mode === "pull" && !ctx.dryRun) await assertImagesExist(deps.docker, tag, stack.apps);
|
|
1420
948
|
const dir = (0, node_path.join)(root, stackDir(stage));
|
|
1421
|
-
const previous = (await ctx.state.read(stage))?.state.
|
|
949
|
+
const previous = Object.fromEntries(Object.entries((await ctx.state.read(stage))?.state.releases ?? {}).map(([name, releases]) => {
|
|
950
|
+
const { ref, tag, digest } = releases.current;
|
|
951
|
+
return [name, {
|
|
952
|
+
ref,
|
|
953
|
+
...tag ? { tag } : {},
|
|
954
|
+
...digest ? { digest } : {}
|
|
955
|
+
}];
|
|
956
|
+
}));
|
|
1422
957
|
return {
|
|
1423
958
|
mode,
|
|
1424
959
|
stack,
|
|
@@ -1450,7 +985,7 @@ async function stageSecrets(ctx, manifest) {
|
|
|
1450
985
|
secrets: stored,
|
|
1451
986
|
generated: []
|
|
1452
987
|
};
|
|
1453
|
-
const { secrets, generated } = require_state.withGeneratedSecrets(stored ??
|
|
988
|
+
const { secrets, generated } = require_state.withGeneratedSecrets(stored ?? require_state.initStageSecrets(ctx.stage), manifest);
|
|
1454
989
|
if (secrets.seed) ctx.secrets.mask(secrets.seed);
|
|
1455
990
|
for (const value of Object.values(secrets.custom ?? {})) ctx.secrets.mask(value);
|
|
1456
991
|
return {
|
|
@@ -1637,7 +1172,7 @@ async function recordImages(ctx, run) {
|
|
|
1637
1172
|
ref: app.ref,
|
|
1638
1173
|
tag: app.tag
|
|
1639
1174
|
};
|
|
1640
|
-
require_state.
|
|
1175
|
+
require_state.recordRelease(journal.state, app.name, image);
|
|
1641
1176
|
}
|
|
1642
1177
|
journal.state.identity = ctx.identity.key;
|
|
1643
1178
|
await journal.save();
|
|
@@ -1858,72 +1393,6 @@ function composeTarget(options = {}) {
|
|
|
1858
1393
|
});
|
|
1859
1394
|
}
|
|
1860
1395
|
//#endregion
|
|
1861
|
-
Object.defineProperty(exports, "DuplicateMigration", {
|
|
1862
|
-
enumerable: true,
|
|
1863
|
-
get: function() {
|
|
1864
|
-
return DuplicateMigration;
|
|
1865
|
-
}
|
|
1866
|
-
});
|
|
1867
|
-
Object.defineProperty(exports, "KyselyNotFound", {
|
|
1868
|
-
enumerable: true,
|
|
1869
|
-
get: function() {
|
|
1870
|
-
return KyselyNotFound;
|
|
1871
|
-
}
|
|
1872
|
-
});
|
|
1873
|
-
Object.defineProperty(exports, "MigrationFailed", {
|
|
1874
|
-
enumerable: true,
|
|
1875
|
-
get: function() {
|
|
1876
|
-
return MigrationFailed;
|
|
1877
|
-
}
|
|
1878
|
-
});
|
|
1879
|
-
Object.defineProperty(exports, "MigrationHasNoUp", {
|
|
1880
|
-
enumerable: true,
|
|
1881
|
-
get: function() {
|
|
1882
|
-
return MigrationHasNoUp;
|
|
1883
|
-
}
|
|
1884
|
-
});
|
|
1885
|
-
Object.defineProperty(exports, "MigrationsOutsideFolder", {
|
|
1886
|
-
enumerable: true,
|
|
1887
|
-
get: function() {
|
|
1888
|
-
return MigrationsOutsideFolder;
|
|
1889
|
-
}
|
|
1890
|
-
});
|
|
1891
|
-
Object.defineProperty(exports, "NoOwnerCredential", {
|
|
1892
|
-
enumerable: true,
|
|
1893
|
-
get: function() {
|
|
1894
|
-
return NoOwnerCredential;
|
|
1895
|
-
}
|
|
1896
|
-
});
|
|
1897
|
-
Object.defineProperty(exports, "NoSuchMigrationTarget", {
|
|
1898
|
-
enumerable: true,
|
|
1899
|
-
get: function() {
|
|
1900
|
-
return NoSuchMigrationTarget;
|
|
1901
|
-
}
|
|
1902
|
-
});
|
|
1903
|
-
Object.defineProperty(exports, "SeedFailed", {
|
|
1904
|
-
enumerable: true,
|
|
1905
|
-
get: function() {
|
|
1906
|
-
return SeedFailed;
|
|
1907
|
-
}
|
|
1908
|
-
});
|
|
1909
|
-
Object.defineProperty(exports, "SeedHasNoSeed", {
|
|
1910
|
-
enumerable: true,
|
|
1911
|
-
get: function() {
|
|
1912
|
-
return SeedHasNoSeed;
|
|
1913
|
-
}
|
|
1914
|
-
});
|
|
1915
|
-
Object.defineProperty(exports, "UnknownDatabaseFolder", {
|
|
1916
|
-
enumerable: true,
|
|
1917
|
-
get: function() {
|
|
1918
|
-
return UnknownDatabaseFolder;
|
|
1919
|
-
}
|
|
1920
|
-
});
|
|
1921
|
-
Object.defineProperty(exports, "UnknownMigrationFolder", {
|
|
1922
|
-
enumerable: true,
|
|
1923
|
-
get: function() {
|
|
1924
|
-
return UnknownMigrationFolder;
|
|
1925
|
-
}
|
|
1926
|
-
});
|
|
1927
1396
|
Object.defineProperty(exports, "composeProject", {
|
|
1928
1397
|
enumerable: true,
|
|
1929
1398
|
get: function() {
|
|
@@ -1948,30 +1417,6 @@ Object.defineProperty(exports, "dockerCompose", {
|
|
|
1948
1417
|
return dockerCompose;
|
|
1949
1418
|
}
|
|
1950
1419
|
});
|
|
1951
|
-
Object.defineProperty(exports, "migrateAndSeed", {
|
|
1952
|
-
enumerable: true,
|
|
1953
|
-
get: function() {
|
|
1954
|
-
return migrateAndSeed;
|
|
1955
|
-
}
|
|
1956
|
-
});
|
|
1957
|
-
Object.defineProperty(exports, "migrateDatabases", {
|
|
1958
|
-
enumerable: true,
|
|
1959
|
-
get: function() {
|
|
1960
|
-
return migrateDatabases;
|
|
1961
|
-
}
|
|
1962
|
-
});
|
|
1963
|
-
Object.defineProperty(exports, "pendingMigrations", {
|
|
1964
|
-
enumerable: true,
|
|
1965
|
-
get: function() {
|
|
1966
|
-
return pendingMigrations;
|
|
1967
|
-
}
|
|
1968
|
-
});
|
|
1969
|
-
Object.defineProperty(exports, "seedDatabases", {
|
|
1970
|
-
enumerable: true,
|
|
1971
|
-
get: function() {
|
|
1972
|
-
return seedDatabases;
|
|
1973
|
-
}
|
|
1974
|
-
});
|
|
1975
1420
|
Object.defineProperty(exports, "stackDir", {
|
|
1976
1421
|
enumerable: true,
|
|
1977
1422
|
get: function() {
|
|
@@ -1979,4 +1424,4 @@ Object.defineProperty(exports, "stackDir", {
|
|
|
1979
1424
|
}
|
|
1980
1425
|
});
|
|
1981
1426
|
|
|
1982
|
-
//# sourceMappingURL=compose-
|
|
1427
|
+
//# sourceMappingURL=compose-jrLy7KGO.cjs.map
|