@bom0792/herdgate 0.9.12 → 0.9.13
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/app-mod/herdgate/main.js +1 -11
- package/bin/herdgate.mjs +38 -20
- package/package.json +1 -1
- package/src/web/herdgate-host.zip +0 -0
package/app-mod/herdgate/main.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
import { View, div } from "gpui-kit";
|
|
23
23
|
import { v_flex, h_flex, InputState, Input } from "gpui-base";
|
|
24
|
-
import { exec, appHome, readTextFile, notify, theme, props
|
|
24
|
+
import { exec, appHome, readTextFile, notify, theme, props } from "herdr";
|
|
25
25
|
|
|
26
26
|
const BASE = `${appHome()}/herdgate`;
|
|
27
27
|
const SETTINGS = `${BASE}/settings.json`;
|
|
@@ -90,16 +90,6 @@ export default class Herdgate extends View {
|
|
|
90
90
|
this.tokenInput = InputState.new({ placeholder: "account token — only for approving other machines" });
|
|
91
91
|
this.codeInput = InputState.new({ placeholder: "the code its panel shows" });
|
|
92
92
|
|
|
93
|
-
// The shipped tabs mod renders its panel buttons from shared("workspace.panels")
|
|
94
|
-
// (the welcome may have fixed it to ["files","changes"] — the layout clone's new
|
|
95
|
-
// default never applies then). Self-heal: join the list once, keeping whatever
|
|
96
|
-
// the person chose.
|
|
97
|
-
{
|
|
98
|
-
const panels = shared("workspace.panels");
|
|
99
|
-
const list = Array.isArray(panels) ? panels : ["files", "changes"];
|
|
100
|
-
if (!list.includes("herdgate")) setShared("workspace.panels", [...list, "herdgate"]);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
93
|
cx.spawn(async (cx) => {
|
|
104
94
|
await this.load();
|
|
105
95
|
cx.notify();
|
package/bin/herdgate.mjs
CHANGED
|
@@ -101,6 +101,20 @@ function do_(args) {
|
|
|
101
101
|
return { ok: r.status === 0, out: `${r.stdout ?? ""}${r.stderr ?? ""}`.trim() };
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
/** A clone the app rejects (version drift, a broken older patch) must never stay:
|
|
105
|
+
* verify, and on failure rebuild from the shipped mod and re-patch once. */
|
|
106
|
+
function verifyTabs(home, live) {
|
|
107
|
+
const dir = join(home, "mods", "tabs-herdgate");
|
|
108
|
+
const main = join(dir, "main.js");
|
|
109
|
+
if (!existsSync(main)) return false;
|
|
110
|
+
if (live) {
|
|
111
|
+
const r = spawnSync("herdr-app", ["check", dir], { encoding: "utf8" });
|
|
112
|
+
return r.status === 0 && !/failed|error/i.test(`${r.stdout}${r.stderr}`);
|
|
113
|
+
}
|
|
114
|
+
const r = spawnSync(process.execPath, ["--check", main], { encoding: "utf8" });
|
|
115
|
+
return r.status === 0;
|
|
116
|
+
}
|
|
117
|
+
|
|
104
118
|
function integrate(home) {
|
|
105
119
|
const probe = spawnSync("herdr-app", ["status"], { encoding: "utf8" });
|
|
106
120
|
const live = probe.status === 0;
|
|
@@ -108,6 +122,10 @@ function integrate(home) {
|
|
|
108
122
|
// registers the clone). Offline: shipped mods are plain files — copy them; a
|
|
109
123
|
// closed app reads the folder at start.
|
|
110
124
|
let tabs = join(home, "mods", "tabs-herdgate", "main.js");
|
|
125
|
+
if (existsSync(tabs) && !verifyTabs(home, live)) {
|
|
126
|
+
console.log("herdgate: the existing tabs-herdgate does not load — rebuilding it from the shipped tabs mod");
|
|
127
|
+
cpSync(join(home, "mods", "tabs"), join(home, "mods", "tabs-herdgate"), { recursive: true });
|
|
128
|
+
}
|
|
111
129
|
if (!existsSync(tabs)) {
|
|
112
130
|
let ok = false;
|
|
113
131
|
if (live) ok = do_(["mod.clone", JSON.stringify({ name: "tabs", as: "tabs-herdgate" })]).ok;
|
|
@@ -119,30 +137,30 @@ function integrate(home) {
|
|
|
119
137
|
const btn = `.when(enabled.includes("herdgate"), el => el.child(panelButton("herdgate", "herdgate", "mods/herdgate/herdgate.svg")))`;
|
|
120
138
|
let changed = false;
|
|
121
139
|
if (src.includes(anchor) && !src.includes(btn)) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
console.log("herdgate: tabs mod anchors not found (Herdr version drift?) — button not added, pane.split still works");
|
|
126
|
-
}
|
|
127
|
-
// Independent of the button: the tab bar always loads, so IT self-heals the panel
|
|
128
|
-
// list — if the welcome fixed workspace.panels without us, join it (converges in
|
|
129
|
-
// one re-render). Machines patched by older installers lack this; re-running adds it.
|
|
130
|
-
if (!src.includes("setShared(\"workspace.panels\")")) {
|
|
131
|
-
const heal = `const __panels = shared("workspace.panels");
|
|
132
|
-
if (!Array.isArray(__panels) || !__panels.includes("herdgate"))
|
|
133
|
-
setShared("workspace.panels", [...(Array.isArray(__panels) ? __panels : ["files", "changes"]), "herdgate"]);
|
|
134
|
-
const enabled = shared("workspace.panels") ?? ["files", "changes"];`;
|
|
135
|
-
// 0.9.7-patched clones carry the herdgate variant of the enabled default.
|
|
136
|
-
const before = src;
|
|
137
|
-
src = src.replace(`const enabled = shared("workspace.panels") ?? ["files", "changes"];`, heal);
|
|
138
|
-
if (src === before) src = src.replace(`const enabled = shared("workspace.panels") ?? ["files", "changes", "herdgate"];`, heal);
|
|
140
|
+
// Unconditional .child — no shared("workspace.panels") gate, no new imports:
|
|
141
|
+
// the button exists on every Herdr version (older apps may lack setShared).
|
|
142
|
+
src = src.replace(anchor, `${anchor}\n .child(panelButton("herdgate", "herdgate", "mods/herdgate/herdgate.svg"))`);
|
|
139
143
|
src = src.replace(
|
|
140
|
-
`
|
|
141
|
-
`
|
|
144
|
+
`const enabled = shared("workspace.panels") ?? ["files", "changes"];`,
|
|
145
|
+
`const enabled = shared("workspace.panels") ?? ["files", "changes", "herdgate"];`,
|
|
142
146
|
);
|
|
143
147
|
changed = true;
|
|
148
|
+
} else if (!src.includes(btn) && !src.includes('panelButton("herdgate"')) {
|
|
149
|
+
console.log("herdgate: tabs mod anchors not found (Herdr version drift?) — button not added, pane.split still works");
|
|
150
|
+
}
|
|
151
|
+
if (changed) writeFileSync(tabs, src);
|
|
152
|
+
if (changed && !verifyTabs(home, live)) {
|
|
153
|
+
console.log("herdgate: the patched tabs clone does not load — retrying from a fresh copy");
|
|
154
|
+
cpSync(join(home, "mods", "tabs"), join(home, "mods", "tabs-herdgate"), { recursive: true });
|
|
155
|
+
const fresh = readFileSync(tabs, "utf8");
|
|
156
|
+
if (fresh.includes(anchor)) {
|
|
157
|
+
writeFileSync(tabs, fresh.replace(anchor, `${anchor}\n .child(panelButton("herdgate", "herdgate", "mods/herdgate/herdgate.svg"))`));
|
|
158
|
+
}
|
|
159
|
+
if (!verifyTabs(home, live)) {
|
|
160
|
+
console.log("herdgate: still no — restoring the shipped tabs mod untouched (button not added; pane.split still works)");
|
|
161
|
+
cpSync(join(home, "mods", "tabs"), join(home, "mods", "tabs-herdgate"), { recursive: true });
|
|
162
|
+
}
|
|
144
163
|
}
|
|
145
|
-
if (changed) writeFileSync(tabs, src);
|
|
146
164
|
|
|
147
165
|
// 2. clone the main layout, seat herdgate in panel-body, point the tab bar at the clone.
|
|
148
166
|
const layoutPath = join(home, "layouts", "herdgate-main.json");
|
package/package.json
CHANGED
|
Binary file
|