@drzl/cli 4.39.0 → 4.40.0
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/cli.cjs +36 -0
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +36 -0
- package/dist/cli.js.map +1 -1
- package/dist/config.d.cts +2 -2
- package/dist/config.d.ts +2 -2
- package/package.json +8 -8
package/dist/cli.js
CHANGED
|
@@ -3046,6 +3046,34 @@ function nextManifestFiles(writtenNow, stale, root) {
|
|
|
3046
3046
|
return manifestEntries([...writtenNow, ...kept], root);
|
|
3047
3047
|
}
|
|
3048
3048
|
|
|
3049
|
+
// src/rebuild-fingerprint.ts
|
|
3050
|
+
import { createHash } from "crypto";
|
|
3051
|
+
function analysisFingerprint(analysis) {
|
|
3052
|
+
const material = {
|
|
3053
|
+
dialect: analysis.dialect,
|
|
3054
|
+
tables: analysis.tables,
|
|
3055
|
+
enums: analysis.enums,
|
|
3056
|
+
relations: analysis.relations
|
|
3057
|
+
};
|
|
3058
|
+
return createHash("sha256").update(stableStringify(material)).digest("hex");
|
|
3059
|
+
}
|
|
3060
|
+
function configFingerprint(generators) {
|
|
3061
|
+
return createHash("sha256").update(stableStringify(generators)).digest("hex");
|
|
3062
|
+
}
|
|
3063
|
+
function stableStringify(value) {
|
|
3064
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value) ?? "null";
|
|
3065
|
+
if (Array.isArray(value)) return `[${value.map(stableStringify).join(",")}]`;
|
|
3066
|
+
const entries = Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
3067
|
+
return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${stableStringify(v)}`).join(",")}}`;
|
|
3068
|
+
}
|
|
3069
|
+
function rebuildSignature(analysis, generators) {
|
|
3070
|
+
return { analysis: analysisFingerprint(analysis), config: configFingerprint(generators) };
|
|
3071
|
+
}
|
|
3072
|
+
function sameAsLast(previous, next) {
|
|
3073
|
+
if (!previous) return false;
|
|
3074
|
+
return previous.analysis === next.analysis && previous.config === next.config;
|
|
3075
|
+
}
|
|
3076
|
+
|
|
3049
3077
|
// src/unified-diff.ts
|
|
3050
3078
|
var DEFAULT_DIFF_LIMITS = {
|
|
3051
3079
|
maxLines: 4e3,
|
|
@@ -4538,6 +4566,7 @@ program.command("watch").description("Watch schema and regenerate on changes").o
|
|
|
4538
4566
|
trigger(p);
|
|
4539
4567
|
});
|
|
4540
4568
|
let lastFiles = [];
|
|
4569
|
+
let lastSignature;
|
|
4541
4570
|
const watchGenerated = (kind, files) => {
|
|
4542
4571
|
if (opts.json) {
|
|
4543
4572
|
out.jsonData({ event: "generate_complete", kind, files });
|
|
@@ -4624,6 +4653,13 @@ program.command("watch").description("Watch schema and regenerate on changes").o
|
|
|
4624
4653
|
}
|
|
4625
4654
|
return;
|
|
4626
4655
|
}
|
|
4656
|
+
const signature = rebuildSignature(analysis, cfg.generators);
|
|
4657
|
+
if (sameAsLast(lastSignature, signature)) {
|
|
4658
|
+
if (opts.json) out.jsonData({ event: "generate_skipped", reason: "no change" });
|
|
4659
|
+
else out.note(out.errStyle.gray("No change to anything a generator reads. Skipped."));
|
|
4660
|
+
return;
|
|
4661
|
+
}
|
|
4662
|
+
lastSignature = signature;
|
|
4627
4663
|
for (const g of selectGenerators(cfg.generators, selection.kinds)) {
|
|
4628
4664
|
const entry = GENERATOR_BY_KIND.get(g.kind);
|
|
4629
4665
|
if (!entry) continue;
|