@bettercms-ai/convert 0.16.0 → 0.16.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 +13 -0
- package/README.md +7 -0
- package/dist/cli.js +32 -18
- package/dist/cli.js.map +1 -1
- package/dist/index.js +20 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6531,32 +6531,33 @@ async function wireForms(briefIn, sources, options_ = {}) {
|
|
|
6531
6531
|
}
|
|
6532
6532
|
const holds = (c, f) => f.fields.filter((field) => c.controls.has(field.key)).length;
|
|
6533
6533
|
const covers2 = (c, f) => f.fields.length > 0 && holds(c, f) === f.fields.length;
|
|
6534
|
-
const posts = (c) => new Set(c.controls.values()).size;
|
|
6535
6534
|
const samePath = (a, b) => a.replace(/\\/g, "/").replace(/^\.\//, "") === b.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
6536
6535
|
const options = new Map(forms.map((f) => [f.id, candidates.filter((c) => covers2(c, f))]));
|
|
6537
6536
|
const pinned = /* @__PURE__ */ new Map();
|
|
6538
6537
|
for (const [ref, file] of Object.entries(options_.pins ?? {})) {
|
|
6539
6538
|
const form = forms.find((f) => f.id === ref || f.name === ref);
|
|
6540
6539
|
if (!form) throw new Error(`--pin ${ref}: the brief lists no form with that id or name.`);
|
|
6540
|
+
if (file.trim() === "") throw new Error(`--pin ${ref}: no file named. Give "<form>=<file>".`);
|
|
6541
6541
|
pinned.set(form.id, file);
|
|
6542
|
-
|
|
6542
|
+
}
|
|
6543
|
+
for (const [id, file] of pinned) {
|
|
6544
|
+
options.set(id, options.get(id).filter((c) => samePath(c.file, file)));
|
|
6543
6545
|
for (const other of forms) {
|
|
6544
|
-
|
|
6546
|
+
const its = pinned.get(other.id);
|
|
6547
|
+
if (other.id === id || its !== void 0 && samePath(its, file)) continue;
|
|
6548
|
+
options.set(other.id, options.get(other.id).filter((c) => !samePath(c.file, file)));
|
|
6545
6549
|
}
|
|
6546
6550
|
}
|
|
6551
|
+
const beat = /* @__PURE__ */ new Map();
|
|
6547
6552
|
for (const c of candidates) {
|
|
6548
6553
|
const claimants = forms.filter((f) => options.get(f.id).includes(c));
|
|
6549
6554
|
if (claimants.length < 2) continue;
|
|
6550
6555
|
const top = Math.max(...claimants.map((f) => holds(c, f)));
|
|
6551
6556
|
const winners = claimants.filter((f) => holds(c, f) === top);
|
|
6552
6557
|
if (winners.length !== 1) continue;
|
|
6553
|
-
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
const list = options.get(f.id);
|
|
6557
|
-
if (list.length < 2) continue;
|
|
6558
|
-
const exact = list.filter((c) => posts(c) === f.fields.length);
|
|
6559
|
-
if (exact.length === 1) options.set(f.id, exact);
|
|
6558
|
+
const rivals = claimants.filter((f) => f !== winners[0]);
|
|
6559
|
+
for (const f of rivals) options.set(f.id, options.get(f.id).filter((x) => x !== c));
|
|
6560
|
+
beat.set(c, { winner: winners[0], rivals });
|
|
6560
6561
|
}
|
|
6561
6562
|
const wanted = /* @__PURE__ */ new Map();
|
|
6562
6563
|
for (const list of options.values()) for (const c of list) wanted.set(c, (wanted.get(c) ?? 0) + 1);
|
|
@@ -6572,7 +6573,7 @@ async function wireForms(briefIn, sources, options_ = {}) {
|
|
|
6572
6573
|
form,
|
|
6573
6574
|
"FORM_AMBIGUOUS",
|
|
6574
6575
|
void 0,
|
|
6575
|
-
`${list.length} forms post every field of "${form.name}": ${list.map((c) => c.file).join(", ")}. Name the right one with --pin "${form.name}=<file>".`
|
|
6576
|
+
`${list.length} forms post every field of "${form.name}": ${list.map((c) => c.file).join(", ")}.${pinned.has(form.id) ? " The pin names that file, and it holds more than one." : ` Name the right one with --pin "${form.name}=<file>".`}`
|
|
6576
6577
|
);
|
|
6577
6578
|
continue;
|
|
6578
6579
|
}
|
|
@@ -6636,6 +6637,14 @@ ${indent}${scriptFor(last.candidate.dialect)}`);
|
|
|
6636
6637
|
files.push({ path, operation: "modify", content: source.toString() });
|
|
6637
6638
|
}
|
|
6638
6639
|
const notes = onSite.filter(({ form }) => form.status === "draft").map(({ form }) => `publish form ${form.name} in the Forms tab \u2014 a draft form rejects every submission with 403.`);
|
|
6640
|
+
for (const { form, candidate } of matched) {
|
|
6641
|
+
const tie = beat.get(candidate);
|
|
6642
|
+
if (tie?.winner === form) {
|
|
6643
|
+
notes.push(
|
|
6644
|
+
`form ${form.name}: ${candidate.file} posts every field of ${tie.rivals.map((f) => f.name).join(", ")} too, and more of ${form.name}'s, so it went to ${form.name} \u2014 name the file yourself with --pin "<form>=<file>" if that is wrong.`
|
|
6645
|
+
);
|
|
6646
|
+
}
|
|
6647
|
+
}
|
|
6639
6648
|
for (const { form, candidate } of matched) {
|
|
6640
6649
|
const keys = form.fields.filter((field) => candidate.foreign.has(candidate.controls.get(field.key))).map((field) => field.key);
|
|
6641
6650
|
if (keys.length > 0) {
|