@eide/foir-cli 0.20.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/dist/cli.js +26 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4945,13 +4945,37 @@ var PushConflictError = class extends Error {
|
|
|
4945
4945
|
this.conflicts = conflicts;
|
|
4946
4946
|
}
|
|
4947
4947
|
};
|
|
4948
|
+
function normalizeForDiff(v) {
|
|
4949
|
+
if (v === null || v === void 0) return void 0;
|
|
4950
|
+
if (Array.isArray(v)) {
|
|
4951
|
+
const items = v.map(normalizeForDiff).filter((x) => x !== void 0);
|
|
4952
|
+
return items.length ? items : void 0;
|
|
4953
|
+
}
|
|
4954
|
+
if (typeof v !== "object") {
|
|
4955
|
+
if (v === false || v === "" || v === 0) return void 0;
|
|
4956
|
+
return v;
|
|
4957
|
+
}
|
|
4958
|
+
const obj = v;
|
|
4959
|
+
const out = {};
|
|
4960
|
+
for (const [k, val] of Object.entries(obj)) {
|
|
4961
|
+
if (k === "$typeName") continue;
|
|
4962
|
+
if (k === "id") continue;
|
|
4963
|
+
const norm = normalizeForDiff(val);
|
|
4964
|
+
if (norm === void 0) continue;
|
|
4965
|
+
out[k] = norm;
|
|
4966
|
+
}
|
|
4967
|
+
return Object.keys(out).length ? out : void 0;
|
|
4968
|
+
}
|
|
4948
4969
|
function canonicalize(v) {
|
|
4970
|
+
return canonicalJson(normalizeForDiff(v));
|
|
4971
|
+
}
|
|
4972
|
+
function canonicalJson(v) {
|
|
4949
4973
|
if (v === void 0) return "undefined";
|
|
4950
4974
|
if (v === null || typeof v !== "object") return JSON.stringify(v);
|
|
4951
|
-
if (Array.isArray(v)) return "[" + v.map(
|
|
4975
|
+
if (Array.isArray(v)) return "[" + v.map(canonicalJson).join(",") + "]";
|
|
4952
4976
|
const obj = v;
|
|
4953
4977
|
const keys = Object.keys(obj).sort();
|
|
4954
|
-
return "{" + keys.map((k) => JSON.stringify(k) + ":" +
|
|
4978
|
+
return "{" + keys.map((k) => JSON.stringify(k) + ":" + canonicalJson(obj[k])).join(",") + "}";
|
|
4955
4979
|
}
|
|
4956
4980
|
function deepEqual(a, b) {
|
|
4957
4981
|
return canonicalize(a) === canonicalize(b);
|