@jixoai/gh-runner 0.2.0 → 0.2.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/main.mjs +17 -26
- package/dist/ui/index.html +12 -1
- package/package.json +2 -1
package/dist/main.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { arch, homedir, platform } from "node:os";
|
|
3
3
|
import { mkdir, open, readFile, readdir, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
4
|
-
import { execFile, spawn } from "node:child_process";
|
|
5
4
|
import { createTray } from "opentray";
|
|
6
5
|
import { attachDialog } from "@opentray/ext-dialog";
|
|
6
|
+
import { attachOpener } from "@opentray/ext-opener";
|
|
7
7
|
import { dirname, isAbsolute, join } from "node:path";
|
|
8
8
|
import { createWriteStream, existsSync } from "node:fs";
|
|
9
|
+
import { execFile, spawn } from "node:child_process";
|
|
9
10
|
import { promisify } from "node:util";
|
|
10
11
|
import { Readable } from "node:stream";
|
|
11
12
|
import { pipeline } from "node:stream/promises";
|
|
@@ -223,21 +224,6 @@ function defaultSearchDirs() {
|
|
|
223
224
|
if (IS_WIN) return ["C:\\actions-runner", homedir()];
|
|
224
225
|
return [homedir()];
|
|
225
226
|
}
|
|
226
|
-
/** 在系统文件管理器中揭示目录/文件。 */
|
|
227
|
-
function revealInFileManager(path) {
|
|
228
|
-
if (PLATFORM === "darwin") return {
|
|
229
|
-
file: "open",
|
|
230
|
-
args: ["-R", path]
|
|
231
|
-
};
|
|
232
|
-
if (IS_WIN) return {
|
|
233
|
-
file: "explorer",
|
|
234
|
-
args: [`/select,${path}`]
|
|
235
|
-
};
|
|
236
|
-
return {
|
|
237
|
-
file: "xdg-open",
|
|
238
|
-
args: [path]
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
227
|
/** 平台路径分段(win32 反斜杠)。 */
|
|
242
228
|
function basenameOf(dir) {
|
|
243
229
|
const parts = dir.split(/[\\/]+/).filter(Boolean);
|
|
@@ -1226,6 +1212,7 @@ var UiHost = class {
|
|
|
1226
1212
|
webviewTray;
|
|
1227
1213
|
onOpenDiag;
|
|
1228
1214
|
pickPackageFile;
|
|
1215
|
+
openExternal;
|
|
1229
1216
|
#window = null;
|
|
1230
1217
|
#lastSnapshot = null;
|
|
1231
1218
|
#ackedSeq = 0;
|
|
@@ -1237,11 +1224,12 @@ var UiHost = class {
|
|
|
1237
1224
|
/** 单飞守卫:hello 全量重推与去抖推送并发交错会让同一批日志行重复送达页面。 */
|
|
1238
1225
|
#pushInFlight = false;
|
|
1239
1226
|
#pushPending = false;
|
|
1240
|
-
constructor(fleet, webviewTray, onOpenDiag, pickPackageFile) {
|
|
1227
|
+
constructor(fleet, webviewTray, onOpenDiag, pickPackageFile, openExternal) {
|
|
1241
1228
|
this.fleet = fleet;
|
|
1242
1229
|
this.webviewTray = webviewTray;
|
|
1243
1230
|
this.onOpenDiag = onOpenDiag;
|
|
1244
1231
|
this.pickPackageFile = pickPackageFile;
|
|
1232
|
+
this.openExternal = openExternal;
|
|
1245
1233
|
}
|
|
1246
1234
|
async open() {
|
|
1247
1235
|
if (this.#window) {
|
|
@@ -1431,6 +1419,13 @@ var UiHost = class {
|
|
|
1431
1419
|
case "open-diag":
|
|
1432
1420
|
this.onOpenDiag(cmd.id);
|
|
1433
1421
|
break;
|
|
1422
|
+
case "open-url":
|
|
1423
|
+
try {
|
|
1424
|
+
await this.openExternal(cmd.url);
|
|
1425
|
+
} catch (err) {
|
|
1426
|
+
console.error("[gh-runner] 打开链接失败:", err);
|
|
1427
|
+
}
|
|
1428
|
+
break;
|
|
1434
1429
|
case "register":
|
|
1435
1430
|
await this.fleet.register({
|
|
1436
1431
|
dir: cmd.dir,
|
|
@@ -1459,12 +1454,6 @@ function extendWebview(tray) {
|
|
|
1459
1454
|
}
|
|
1460
1455
|
// src/main.ts
|
|
1461
1456
|
const APP_ID = "com.jixoai.gh-runner";
|
|
1462
|
-
async function revealPath(path) {
|
|
1463
|
-
const { file, args } = revealInFileManager(path);
|
|
1464
|
-
await new Promise((resolve) => {
|
|
1465
|
-
execFile(file, args, () => resolve());
|
|
1466
|
-
});
|
|
1467
|
-
}
|
|
1468
1457
|
/** 导入本地分发包:系统文件选择框(ext-dialog;darwin NSOpenPanel / win32 对话框)。 */
|
|
1469
1458
|
async function pickPackageFile(tray) {
|
|
1470
1459
|
try {
|
|
@@ -1624,10 +1613,12 @@ async function main() {
|
|
|
1624
1613
|
},
|
|
1625
1614
|
quit: () => void shutdown()
|
|
1626
1615
|
});
|
|
1627
|
-
const
|
|
1616
|
+
const webviewTray = extendWebview(tray);
|
|
1617
|
+
const opener = attachOpener(tray);
|
|
1618
|
+
const uiHost = new UiHost(fleet, webviewTray, (id) => {
|
|
1628
1619
|
const view = fleet.view(id);
|
|
1629
|
-
if (view)
|
|
1630
|
-
}, () => pickPackageFile(tray));
|
|
1620
|
+
if (view) opener.revealInFolder(`${view.dir}/_diag`).catch((err) => console.error("[gh-runner] 揭示目录失败:", err));
|
|
1621
|
+
}, () => pickPackageFile(tray), (url) => opener.open(url));
|
|
1631
1622
|
fleet.onSnapshot((snap) => {
|
|
1632
1623
|
projection.update(snap);
|
|
1633
1624
|
uiHost.push(snap);
|
package/dist/ui/index.html
CHANGED
|
@@ -126,6 +126,7 @@
|
|
|
126
126
|
.field input:focus { outline: 2px solid color-mix(in srgb, var(--run) 55%, transparent); border-color: transparent; }
|
|
127
127
|
.field .hint { font-size: 10.5px; color: var(--ink-2); }
|
|
128
128
|
.field .hint a { color: var(--run); text-decoration: none; }
|
|
129
|
+
a.ext-link { cursor: pointer; }
|
|
129
130
|
.pkg-row { display: flex; gap: 6px; }
|
|
130
131
|
.pkg-row select {
|
|
131
132
|
flex: 1; min-width: 0; font: inherit; padding: 5px 7px; border: 1px solid var(--line);
|
|
@@ -196,7 +197,7 @@
|
|
|
196
197
|
<div class="field">
|
|
197
198
|
<label>注册 Token(org 设置页生成,一次性)</label>
|
|
198
199
|
<input name="token" type="password" placeholder="粘贴一次性注册 Token" required>
|
|
199
|
-
<span class="hint">获取:<a href="https://github.com/organizations/jixoai/settings/actions/runners/new"
|
|
200
|
+
<span class="hint">获取:<a href="#" id="link-runner-new" data-url="https://github.com/organizations/jixoai/settings/actions/runners/new">org runners 新建页</a>(系统浏览器打开;自动解包本机已有分发包)</span>
|
|
200
201
|
</div>
|
|
201
202
|
<div class="field">
|
|
202
203
|
<label>Labels</label>
|
|
@@ -329,6 +330,16 @@ function renderPackages(packages, download) {
|
|
|
329
330
|
}
|
|
330
331
|
}
|
|
331
332
|
|
|
333
|
+
document.querySelectorAll("a.ext-link").forEach((a) => {
|
|
334
|
+
a.addEventListener("click", (e) => {
|
|
335
|
+
e.preventDefault();
|
|
336
|
+
const url = a.dataset.url;
|
|
337
|
+
if (!url) return;
|
|
338
|
+
const ipc = navigator.opentray && navigator.opentray.ipc;
|
|
339
|
+
if (ipc) void ipc.postMessage({ type: "open-url", url });
|
|
340
|
+
else window.open(url, "_blank");
|
|
341
|
+
});
|
|
342
|
+
});
|
|
332
343
|
$("#pkg-download").addEventListener("click", () => send({ type: "download-latest" }));
|
|
333
344
|
$("#pkg-import").addEventListener("click", () => send({ type: "import-package" }));
|
|
334
345
|
document.querySelector('#register-form input[name="labels"]').addEventListener("input", () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jixoai/gh-runner",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Menu-bar (tray) manager for multiple GitHub Actions self-hosted runners: discover, register from downloaded/imported packages, start/stop, and live job-result analysis. macOS & Windows.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@opentray/ext-dialog": "^0.36.0",
|
|
48
|
+
"@opentray/ext-opener": "^0.36.0",
|
|
48
49
|
"@opentray/ext-webview": "^0.36.0",
|
|
49
50
|
"opentray": "^0.36.0"
|
|
50
51
|
},
|