@voltro/cli 0.19.0 → 0.20.1
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/CHANGELOG.md +224 -0
- package/dist/apiBuild-C9aHz4Yh.js +2 -0
- package/dist/{apiBuild-CY5pEwwq.js → apiBuild-qZBEu59d.js} +2 -2
- package/dist/bin.js +41 -9
- package/dist/{commands-BvvoQL0v.js → commands-CA7jwejs.js} +1930 -1770
- package/dist/dbCommand-DA_RFj5K.js +2 -0
- package/dist/{dbCommand-DJSxnjPt.js → dbCommand-DFw2UoC-.js} +24 -24
- package/dist/{dev-C_E1XxNF.js → dev-2AvdzDg2.js} +1 -1
- package/dist/{dev-B6rfgKfo.js → dev-OHLsAq4K.js} +1488 -1462
- package/dist/index.js +1 -1
- package/dist/{inspectMetrics-D1DmLeJs.js → inspectMetrics-DvPNXmGA.js} +208 -179
- package/dist/{serveCommand-vPF5ucXC.js → serveCommand-BKqTKWTX.js} +341 -341
- package/dist/serveEntry.js +2 -2
- package/dist/{start-Clvz4IJb.js → start-CXQ7WL1W.js} +376 -368
- package/dist/startEntry.js +2 -2
- package/package.json +17 -17
- package/templates/AGENTS.md +1 -1
- package/templates/agent-docs/_index.md +1 -1
- package/templates/agent-docs/cli.md +33 -0
- package/templates/agent-docs/database/migrations.md +35 -2
- package/templates/agent-docs/database/misc.md +16 -0
- package/templates/agent-docs/database/seedsdialects.md +25 -0
- package/templates/agent-docs/database/transactions.md +15 -0
- package/templates/agent-docs/routing.md +13 -0
- package/templates/agent-docs/whats-new.md +78 -94
- package/templates/apps/api-ai/package.json +7 -7
- package/templates/apps/api-auth/package.json +8 -8
- package/templates/apps/api-backend/package.json +7 -7
- package/templates/apps/api-backend-deactivation/package.json +7 -7
- package/templates/apps/api-backend-mail/package.json +8 -8
- package/templates/apps/api-backend-mariadb/package.json +9 -9
- package/templates/apps/api-backend-storage/package.json +8 -8
- package/templates/apps/api-data-advanced/package.json +8 -8
- package/templates/apps/api-durable/package.json +8 -8
- package/templates/apps/api-feature-flags/package.json +9 -9
- package/templates/apps/api-governance/package.json +8 -8
- package/templates/apps/api-kv/package.json +8 -8
- package/templates/apps/api-moderation/package.json +8 -8
- package/templates/apps/api-observability/package.json +8 -8
- package/templates/apps/api-ratelimit/package.json +8 -8
- package/templates/apps/api-rbac/package.json +8 -8
- package/templates/apps/api-rest/package.json +7 -7
- package/templates/apps/api-saas/package.json +11 -11
- package/templates/apps/api-search/package.json +8 -8
- package/templates/apps/api-versioning/package.json +8 -8
- package/templates/apps/api-webhooks/package.json +9 -9
- package/templates/apps/changelog/package.json +6 -6
- package/templates/apps/edge-functions/package.json +2 -2
- package/templates/apps/frontend-admin/package.json +8 -8
- package/templates/apps/frontend-app/package.json +8 -8
- package/templates/apps/frontend-blank/package.json +7 -7
- package/templates/apps/frontend-contact/package.json +7 -7
- package/templates/apps/frontend-dashboard/package.json +7 -7
- package/templates/apps/frontend-docs/package.json +7 -7
- package/templates/apps/frontend-i18n/package.json +6 -6
- package/templates/apps/frontend-landing/package.json +7 -7
- package/templates/apps/frontend-spa/package.json +7 -7
- package/templates/apps/frontend-ssr/package.json +7 -7
- package/templates/apps/frontend-ssr-api/package.json +8 -8
- package/templates/apps/frontend-static-blog/package.json +6 -6
- package/dist/apiBuild-9NXH53Sd.js +0 -2
- package/dist/dbCommand-C3R5LrBZ.js +0 -2
|
@@ -659,9 +659,9 @@ var O = class extends Error {
|
|
|
659
659
|
}), 0;
|
|
660
660
|
}, Ee = async (e) => {
|
|
661
661
|
let t = Math.max(1, Number(c(e, "--limit") ?? "20")), n = await J(await U(), y.SqlClient.pipe(h.flatMap((e) => e`
|
|
662
|
-
SELECT ${e("id")}, ${e("fingerprint")}, ${e("operations")}
|
|
662
|
+
SELECT ${e("id")}, ${e("fingerprint")}, ${e("operations")},
|
|
663
663
|
${e("appliedBy")}, ${e("environment")}, ${e("source")},
|
|
664
|
-
${e("durationMs")}, ${e("notes")}, ${e("appliedAt")}
|
|
664
|
+
${e("durationMs")}, ${e("notes")}, ${e("appliedAt")}
|
|
665
665
|
FROM ${e("_voltro_migration_plans")}
|
|
666
666
|
ORDER BY ${e("appliedAt")} DESC
|
|
667
667
|
LIMIT ${t}
|
|
@@ -671,20 +671,20 @@ var O = class extends Error {
|
|
|
671
671
|
for (let e of n) {
|
|
672
672
|
let t = 0;
|
|
673
673
|
try {
|
|
674
|
-
t = JSON.parse(e.operations).length;
|
|
674
|
+
t = JSON.parse(Q(e.operations)).length;
|
|
675
675
|
} catch {}
|
|
676
|
-
console.log(` ${e.id} fp=${D(e.fingerprint)} env=${e.environment} src=${e.source} ${t} op(s) ${e.durationMs}ms ${e.appliedAt} by=${e.appliedBy}`), e.notes && console.log(` [2mnote: ${e.notes}[0m`);
|
|
676
|
+
console.log(` ${e.id} fp=${D(e.fingerprint)} env=${e.environment} src=${e.source} ${t} op(s) ${e.durationMs}ms ${Ae(e.appliedAt)} by=${e.appliedBy}`), e.notes && console.log(` [2mnote: ${e.notes}[0m`);
|
|
677
677
|
}
|
|
678
678
|
return console.log(), 0;
|
|
679
679
|
}, De = async (e) => {
|
|
680
680
|
let t = e[0];
|
|
681
681
|
if (!t) return console.error("voltro db restore-snapshot <plan-id>"), console.error(" Renames soft-dropped columns/tables from a plan back to their original names."), console.error(" Requires the plan to have been applied with VOLTRO_SOFT_DROP=1."), 2;
|
|
682
|
-
let n = await U(), r = await J(n, y.SqlClient.pipe(h.flatMap((e) => e`SELECT ${e("id")}, ${e("operations")}
|
|
682
|
+
let n = await U(), r = await J(n, y.SqlClient.pipe(h.flatMap((e) => e`SELECT ${e("id")}, ${e("operations")}
|
|
683
683
|
FROM ${e("_voltro_migration_plans")} WHERE ${e("id")} = ${t}`)));
|
|
684
684
|
if (r.length === 0) return console.error(`restore-snapshot: plan '${t}' not found`), 1;
|
|
685
685
|
let i;
|
|
686
686
|
try {
|
|
687
|
-
i = JSON.parse(r[0].operations);
|
|
687
|
+
i = JSON.parse(Q(r[0].operations));
|
|
688
688
|
} catch {
|
|
689
689
|
return console.error(`restore-snapshot: plan '${t}' has corrupted operations JSON`), 1;
|
|
690
690
|
}
|
|
@@ -728,7 +728,7 @@ var O = class extends Error {
|
|
|
728
728
|
await J(n, y.SqlClient.pipe(h.flatMap((t) => t.unsafe(`ALTER TABLE "${r}" RENAME TO "${e.table}"`)))), c++, console.log(` ↩ restored table ${e.table} (from ${r})`);
|
|
729
729
|
}
|
|
730
730
|
return console.log(`\n✓ restored ${s} column(s) + ${c} table(s) from plan '${t}'\n`), 0;
|
|
731
|
-
},
|
|
731
|
+
}, Oe = async (e) => {
|
|
732
732
|
let t = c(e, "--before");
|
|
733
733
|
if (!t) return console.error("voltro db gc-snapshots --before <date> [--dry-run]"), console.error(" Permanently drops soft-dropped columns/tables (<name>__dropped_<ts>) older than <date>."), console.error(" <date> is ISO — e.g. 2026-01-01 or 2026-01-01T00:00:00Z. NOT reversible."), 2;
|
|
734
734
|
let n = t.replace(/[^0-9]/g, "");
|
|
@@ -752,7 +752,7 @@ var O = class extends Error {
|
|
|
752
752
|
t === null || t >= r || (console.log(` ${i ? "[dry-run] would drop table" : "dropping table"} ${e.table_name}`), i || await J(a, y.SqlClient.pipe(h.flatMap((t) => t.unsafe(`DROP TABLE "${e.table_name}"`)))), u++);
|
|
753
753
|
}
|
|
754
754
|
return console.log(`\n${i ? `[dry-run] ${u} snapshot(s) would be dropped` : `✓ dropped ${u} snapshot(s)`} (older than ${r}).\n`), 0;
|
|
755
|
-
},
|
|
755
|
+
}, ke = async (e) => {
|
|
756
756
|
let t = c(e, "--before");
|
|
757
757
|
if (!t) return console.error("voltro db squash --before <iso-date> [--note \"<text>\"]"), 2;
|
|
758
758
|
let n = t;
|
|
@@ -776,17 +776,17 @@ var O = class extends Error {
|
|
|
776
776
|
} catch (e) {
|
|
777
777
|
return console.error(`squash refused: ${e.message}`), 1;
|
|
778
778
|
}
|
|
779
|
-
},
|
|
779
|
+
}, Q = (e) => typeof e == "string" ? e : e == null ? "" : JSON.stringify(e), Ae = (e) => e instanceof Date ? e.toISOString() : String(e ?? ""), je = async (e) => {
|
|
780
780
|
let t = await U(), n = await J(t, y.SqlClient.pipe(h.flatMap((e) => e`
|
|
781
|
-
SELECT ${e("id")}, ${e("fingerprint")}, ${e("appliedAt")}
|
|
781
|
+
SELECT ${e("id")}, ${e("fingerprint")}, ${e("appliedAt")}
|
|
782
782
|
FROM ${e("_voltro_migration_plans")}
|
|
783
783
|
ORDER BY ${e("appliedAt")} DESC
|
|
784
784
|
LIMIT 1
|
|
785
785
|
`))), r = w({ tables: (await Y(t)).tables.filter((e) => !e.name.startsWith("_voltro_")) });
|
|
786
786
|
if (n.length === 0) return I.info("db drift: no _voltro_migration_plans rows yet"), console.log(`live user-schema fingerprint: ${D(r)}`), console.log("No baseline to compare against. Run `voltro db apply` to lock in the current state."), 0;
|
|
787
787
|
let i = n[0];
|
|
788
|
-
return i.fingerprint === r ? (I.info(`db drift: live matches last applied (${D(r)})`), 0) : (I.error("db drift: live schema DIVERGED from last applied state"), console.log(), console.log(` last applied: ${D(i.fingerprint)} at ${i.appliedAt} (${i.id})`), console.log(` live now: ${D(r)}`), console.log(), console.log("Probable causes:"), console.log(" - manual DDL ran out-of-band (psql session, another tool)"), console.log(" - someone applied a plan but the row never made it into _voltro_migration_plans"), console.log(), console.log("To reconcile, run `voltro db plan` to see what your code expects vs the live DB."), 4);
|
|
789
|
-
},
|
|
788
|
+
return i.fingerprint === r ? (I.info(`db drift: live matches last applied (${D(r)})`), 0) : (I.error("db drift: live schema DIVERGED from last applied state"), console.log(), console.log(` last applied: ${D(i.fingerprint)} at ${Ae(i.appliedAt)} (${i.id})`), console.log(` live now: ${D(r)}`), console.log(), console.log("Probable causes:"), console.log(" - manual DDL ran out-of-band (psql session, another tool)"), console.log(" - someone applied a plan but the row never made it into _voltro_migration_plans"), console.log(), console.log("To reconcile, run `voltro db plan` to see what your code expects vs the live DB."), 4);
|
|
789
|
+
}, Me = async (e) => {
|
|
790
790
|
let t = R(e), n = await U(), r = (process.env.NODE_ENV ?? "").toLowerCase() === "production" ? "prod" : (process.env.NODE_ENV ?? "").toLowerCase() === "staging" ? "staging" : "dev";
|
|
791
791
|
await J(n, C(b, H()));
|
|
792
792
|
let i = await J(n, y.SqlClient.pipe(h.flatMap((e) => ce(e, {
|
|
@@ -798,7 +798,7 @@ var O = class extends Error {
|
|
|
798
798
|
applied: i.applied.map((e) => `${e.id} (${e.durationMs}ms)`),
|
|
799
799
|
skipped: i.skipped.length
|
|
800
800
|
}), 0);
|
|
801
|
-
},
|
|
801
|
+
}, Ne = async (e) => {
|
|
802
802
|
let t = R(e), n = e.find((e) => !e.startsWith("--"));
|
|
803
803
|
if (!n) return I.error("voltro db rollback-file <migration-id>"), 2;
|
|
804
804
|
if ((process.env.NODE_ENV ?? "").toLowerCase() === "production") return I.error("voltro db rollback-file: refusing on prod — schema rollback runs as an explicit deploy step."), 3;
|
|
@@ -807,7 +807,7 @@ var O = class extends Error {
|
|
|
807
807
|
id: n
|
|
808
808
|
}))));
|
|
809
809
|
return I.info(`db rollback-file: rolled back ${r.id} in ${r.durationMs}ms`), 0;
|
|
810
|
-
},
|
|
810
|
+
}, Pe = () => {
|
|
811
811
|
let e = /* @__PURE__ */ new Date();
|
|
812
812
|
return [
|
|
813
813
|
e.getUTCFullYear(),
|
|
@@ -817,7 +817,7 @@ var O = class extends Error {
|
|
|
817
817
|
String(e.getUTCMinutes()).padStart(2, "0"),
|
|
818
818
|
String(e.getUTCSeconds()).padStart(2, "0")
|
|
819
819
|
].join("");
|
|
820
|
-
},
|
|
820
|
+
}, Fe = (e) => e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "") || "migration", Ie = (e, t) => `import { defineMigration, SqlClient } from '@voltro/database'
|
|
821
821
|
import { Effect } from 'effect'
|
|
822
822
|
|
|
823
823
|
// A hand-written migration. Reach for this when the DECLARATIVE differ can't
|
|
@@ -853,21 +853,21 @@ export default defineMigration({
|
|
|
853
853
|
plan: Ce,
|
|
854
854
|
apply: Te,
|
|
855
855
|
plans: Ee,
|
|
856
|
-
drift:
|
|
857
|
-
files:
|
|
858
|
-
"rollback-file":
|
|
856
|
+
drift: je,
|
|
857
|
+
files: Me,
|
|
858
|
+
"rollback-file": Ne,
|
|
859
859
|
migrate: he,
|
|
860
860
|
rollback: ge,
|
|
861
861
|
status: _e,
|
|
862
862
|
seed: ye,
|
|
863
863
|
generate: async (e) => {
|
|
864
|
-
let { value: t, rest: n } = s(e, "--root"), { value: r, rest: i } = s(n, "--name"), a = t ? p(t) : process.cwd(), o =
|
|
865
|
-
return await _.mkdir(u, { recursive: !0 }), await _.writeFile(m,
|
|
864
|
+
let { value: t, rest: n } = s(e, "--root"), { value: r, rest: i } = s(n, "--name"), a = t ? p(t) : process.cwd(), o = Fe(r ?? l(i) ?? "migration"), c = `${Pe()}_${o}`, u = d(a, "migrations"), m = d(u, `${c}.migration.ts`);
|
|
865
|
+
return await _.mkdir(u, { recursive: !0 }), await _.writeFile(m, Ie(c, o), "utf8"), I.info(`created ${f(a, m)}`), console.error("Fill in the apply/undo steps, then run `voltro db migrate` (rollback with `voltro db rollback`)."), console.error("For a plain schema shape change you may not need this — `voltro db apply` diffs declared vs live."), 0;
|
|
866
866
|
},
|
|
867
|
-
squash:
|
|
867
|
+
squash: ke,
|
|
868
868
|
"restore-snapshot": De,
|
|
869
|
-
"gc-snapshots":
|
|
870
|
-
},
|
|
869
|
+
"gc-snapshots": Oe
|
|
870
|
+
}, Le = async (e) => {
|
|
871
871
|
let [t, ...n] = e;
|
|
872
872
|
if (!t) {
|
|
873
873
|
console.error("voltro db <subcommand> [args]"), console.error("subcommands:");
|
|
@@ -888,4 +888,4 @@ export default defineMigration({
|
|
|
888
888
|
}
|
|
889
889
|
};
|
|
890
890
|
//#endregion
|
|
891
|
-
export { B as a, de as c, G as i, z as n,
|
|
891
|
+
export { B as a, de as c, G as i, z as n, Le as o, W as r, O as s, V as t };
|