@bom0792/herdgate 0.9.16 → 0.9.17
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/bin/herdgate.mjs +18 -6
- package/package.json +1 -1
package/bin/herdgate.mjs
CHANGED
|
@@ -154,27 +154,39 @@ function integrate(home) {
|
|
|
154
154
|
}
|
|
155
155
|
let src = readFileSync(tabs, "utf8");
|
|
156
156
|
const anchor = `.when(enabled.includes("changes"), el => el.child(panelButton("changes", "Changes", "mods/changes/changes.svg")))`;
|
|
157
|
-
|
|
157
|
+
// The exact line we insert — the idempotency marker. (An earlier build checked
|
|
158
|
+
// for a different .when(…) string and never matched, so every re-install added
|
|
159
|
+
// one more button — this marker is the inserted text itself.)
|
|
160
|
+
const inserted = `.child(panelButton("herdgate", "herdgate", "mods/herdgate/herdgate.svg"))`;
|
|
161
|
+
const marker = 'panelButton("herdgate"';
|
|
162
|
+
// Repair old duplicates first: drop every inserted line, re-add exactly one.
|
|
163
|
+
const dupes = src.split("\n").filter((l) => l.trim().startsWith(inserted)).length;
|
|
164
|
+
let dropped = false;
|
|
165
|
+
if (dupes > 1 || (dupes === 1 && src.includes(anchor))) {
|
|
166
|
+
if (dupes > 1) console.log(`herdgate: removing ${dupes - 1} duplicate button(s) from earlier installs`);
|
|
167
|
+
src = src.split("\n").filter((l) => !l.trim().startsWith(inserted)).join("\n");
|
|
168
|
+
dropped = true;
|
|
169
|
+
}
|
|
158
170
|
let changed = false;
|
|
159
|
-
if (src.includes(anchor) && !src.includes(
|
|
171
|
+
if (src.includes(anchor) && !src.includes(marker)) {
|
|
160
172
|
// Unconditional .child — no shared("workspace.panels") gate, no new imports:
|
|
161
173
|
// the button exists on every Herdr version (older apps may lack setShared).
|
|
162
|
-
src = src.replace(anchor, `${anchor}\n
|
|
174
|
+
src = src.replace(anchor, `${anchor}\n ${inserted}`);
|
|
163
175
|
src = src.replace(
|
|
164
176
|
`const enabled = shared("workspace.panels") ?? ["files", "changes"];`,
|
|
165
177
|
`const enabled = shared("workspace.panels") ?? ["files", "changes", "herdgate"];`,
|
|
166
178
|
);
|
|
167
179
|
changed = true;
|
|
168
|
-
} else if (!src.includes(
|
|
180
|
+
} else if (!src.includes(marker)) {
|
|
169
181
|
console.log("herdgate: tabs mod anchors not found (Herdr version drift?) — button not added, pane.split still works");
|
|
170
182
|
}
|
|
171
|
-
if (changed) writeFileSync(tabs, src);
|
|
183
|
+
if (dropped || changed) writeFileSync(tabs, src);
|
|
172
184
|
if (changed && !verifyTabs(home, live)) {
|
|
173
185
|
console.log("herdgate: the patched tabs clone does not load — retrying from a fresh copy");
|
|
174
186
|
cpSync(join(home, "mods", "tabs"), join(home, "mods", "tabs-herdgate"), { recursive: true });
|
|
175
187
|
const fresh = readFileSync(tabs, "utf8");
|
|
176
188
|
if (fresh.includes(anchor)) {
|
|
177
|
-
writeFileSync(tabs, fresh.replace(anchor, `${anchor}\n
|
|
189
|
+
writeFileSync(tabs, fresh.replace(anchor, `${anchor}\n ${inserted}`));
|
|
178
190
|
}
|
|
179
191
|
if (!verifyTabs(home, live)) {
|
|
180
192
|
console.log("herdgate: still no — restoring the shipped tabs mod untouched (button not added; pane.split still works)");
|
package/package.json
CHANGED