@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.cjs
CHANGED
|
@@ -4304,6 +4304,34 @@ function nextManifestFiles(writtenNow, stale, root) {
|
|
|
4304
4304
|
return manifestEntries([...writtenNow, ...kept], root);
|
|
4305
4305
|
}
|
|
4306
4306
|
|
|
4307
|
+
// src/rebuild-fingerprint.ts
|
|
4308
|
+
var import_node_crypto = require("crypto");
|
|
4309
|
+
function analysisFingerprint(analysis) {
|
|
4310
|
+
const material = {
|
|
4311
|
+
dialect: analysis.dialect,
|
|
4312
|
+
tables: analysis.tables,
|
|
4313
|
+
enums: analysis.enums,
|
|
4314
|
+
relations: analysis.relations
|
|
4315
|
+
};
|
|
4316
|
+
return (0, import_node_crypto.createHash)("sha256").update(stableStringify(material)).digest("hex");
|
|
4317
|
+
}
|
|
4318
|
+
function configFingerprint(generators) {
|
|
4319
|
+
return (0, import_node_crypto.createHash)("sha256").update(stableStringify(generators)).digest("hex");
|
|
4320
|
+
}
|
|
4321
|
+
function stableStringify(value) {
|
|
4322
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value) ?? "null";
|
|
4323
|
+
if (Array.isArray(value)) return `[${value.map(stableStringify).join(",")}]`;
|
|
4324
|
+
const entries = Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
4325
|
+
return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${stableStringify(v)}`).join(",")}}`;
|
|
4326
|
+
}
|
|
4327
|
+
function rebuildSignature(analysis, generators) {
|
|
4328
|
+
return { analysis: analysisFingerprint(analysis), config: configFingerprint(generators) };
|
|
4329
|
+
}
|
|
4330
|
+
function sameAsLast(previous, next) {
|
|
4331
|
+
if (!previous) return false;
|
|
4332
|
+
return previous.analysis === next.analysis && previous.config === next.config;
|
|
4333
|
+
}
|
|
4334
|
+
|
|
4307
4335
|
// src/unified-diff.ts
|
|
4308
4336
|
var DEFAULT_DIFF_LIMITS = {
|
|
4309
4337
|
maxLines: 4e3,
|
|
@@ -5796,6 +5824,7 @@ program.command("watch").description("Watch schema and regenerate on changes").o
|
|
|
5796
5824
|
trigger(p);
|
|
5797
5825
|
});
|
|
5798
5826
|
let lastFiles = [];
|
|
5827
|
+
let lastSignature;
|
|
5799
5828
|
const watchGenerated = (kind, files) => {
|
|
5800
5829
|
if (opts.json) {
|
|
5801
5830
|
out.jsonData({ event: "generate_complete", kind, files });
|
|
@@ -5882,6 +5911,13 @@ program.command("watch").description("Watch schema and regenerate on changes").o
|
|
|
5882
5911
|
}
|
|
5883
5912
|
return;
|
|
5884
5913
|
}
|
|
5914
|
+
const signature = rebuildSignature(analysis, cfg.generators);
|
|
5915
|
+
if (sameAsLast(lastSignature, signature)) {
|
|
5916
|
+
if (opts.json) out.jsonData({ event: "generate_skipped", reason: "no change" });
|
|
5917
|
+
else out.note(out.errStyle.gray("No change to anything a generator reads. Skipped."));
|
|
5918
|
+
return;
|
|
5919
|
+
}
|
|
5920
|
+
lastSignature = signature;
|
|
5885
5921
|
for (const g of selectGenerators(cfg.generators, selection.kinds)) {
|
|
5886
5922
|
const entry = GENERATOR_BY_KIND.get(g.kind);
|
|
5887
5923
|
if (!entry) continue;
|