cicy-desktop 2.1.182 → 2.1.184
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.
|
@@ -23,36 +23,10 @@ jobs:
|
|
|
23
23
|
node-version: "20"
|
|
24
24
|
cache: "npm"
|
|
25
25
|
|
|
26
|
-
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
- name: Read cicy-code ref pin
|
|
32
|
-
id: cicy_code_ref
|
|
33
|
-
shell: bash
|
|
34
|
-
run: |
|
|
35
|
-
ref="$(cat .cicy-code-ref | tr -d '[:space:]')"
|
|
36
|
-
echo "ref=${ref}" >> "$GITHUB_OUTPUT"
|
|
37
|
-
if ! [[ "$ref" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
|
|
38
|
-
echo "::error::.cicy-code-ref must be a release tag (vX.Y.Z), got: $ref"
|
|
39
|
-
exit 1
|
|
40
|
-
fi
|
|
41
|
-
|
|
42
|
-
- name: Checkout cicy-code as sibling
|
|
43
|
-
uses: actions/checkout@v4
|
|
44
|
-
with:
|
|
45
|
-
repository: cicy-ai/cicy-code
|
|
46
|
-
ref: ${{ steps.cicy_code_ref.outputs.ref }}
|
|
47
|
-
path: cicy-code
|
|
48
|
-
|
|
49
|
-
- name: Build cicy-code sidecar binaries (linux amd64 + arm64)
|
|
50
|
-
shell: bash
|
|
51
|
-
working-directory: cicy-code
|
|
52
|
-
run: |
|
|
53
|
-
SKIP_TTYD_ASSET=1 SKIP_SKILLS_EMBED=1 bash build.sh all
|
|
54
|
-
ls -lh dist/
|
|
55
|
-
|
|
26
|
+
# cicy-code is NOT built-from-source here anymore (主人 2026-06): bundled
|
|
27
|
+
# sidecar = the per-platform optionalDependency, seeded by localbin at runtime.
|
|
28
|
+
# The .cicy-code-ref source-build → vendor/cicy-code path was stale + never
|
|
29
|
+
# packaged, so it's removed. Sync just pins optionalDeps to latest.
|
|
56
30
|
- name: Sync runtime deps to latest (cicy-code + cicy-mihomo; drop msys2)
|
|
57
31
|
run: node scripts/sync-runtime-deps.cjs
|
|
58
32
|
|
|
@@ -62,6 +36,17 @@ jobs:
|
|
|
62
36
|
- name: Install Electron build dependencies
|
|
63
37
|
run: npm install --save-dev --no-audit electron@41.0.2 electron-builder@26.7.0
|
|
64
38
|
|
|
39
|
+
# 主人(2026-06 关键修复): runner 是 x64,npm 只装 linux-x64 的 cicy-code/mihomo →
|
|
40
|
+
# linux-arm64 用户的包里塞的是 x64 二进制。强制把两个 linux 架构都装进 node_modules,
|
|
41
|
+
# electron-builder 两架构都打包,localbin 按用户机器选。必须在所有 npm install 之后。
|
|
42
|
+
- name: Bundle BOTH linux arches of cicy-code/mihomo (runner is single-arch)
|
|
43
|
+
run: |
|
|
44
|
+
pkgs=$(node -e "const o=require('./package.json').optionalDependencies||{}; const w=['cicy-code-linux-x64','cicy-code-linux-arm64','cicy-mihomo-linux-x64','cicy-mihomo-linux-arm64']; console.log(w.filter(p=>o[p]).map(p=>p+'@'+o[p]).join(' '))")
|
|
45
|
+
echo "force-installing both arches: $pkgs"
|
|
46
|
+
npm install --no-save --no-audit --force $pkgs
|
|
47
|
+
ls node_modules | grep -E 'cicy-(code|mihomo)-linux' || true
|
|
48
|
+
for a in x64 arm64; do test -f "node_modules/cicy-code-linux-$a/cicy-code" || { echo "::error::cicy-code-linux-$a binary missing"; exit 1; }; done
|
|
49
|
+
|
|
65
50
|
# NOTE: the homepage SPA is rebuilt automatically by the prebuild:linux npm
|
|
66
51
|
# hook (scripts/build-homepage.cjs) right before `npm run build:linux` below,
|
|
67
52
|
# so the AppImage can never ship a stale homepage. No explicit step needed.
|
|
@@ -69,7 +54,6 @@ jobs:
|
|
|
69
54
|
- name: Build Linux app (deb + AppImage)
|
|
70
55
|
shell: bash
|
|
71
56
|
env:
|
|
72
|
-
CICY_CODE_DIST_DIR: ${{ github.workspace }}/cicy-code/dist
|
|
73
57
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
74
58
|
run: |
|
|
75
59
|
set -euo pipefail
|
|
@@ -23,44 +23,12 @@ jobs:
|
|
|
23
23
|
node-version: "20"
|
|
24
24
|
cache: "npm"
|
|
25
25
|
|
|
26
|
-
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
id: cicy_code_ref
|
|
33
|
-
shell: bash
|
|
34
|
-
run: |
|
|
35
|
-
ref="$(cat .cicy-code-ref | tr -d '[:space:]')"
|
|
36
|
-
echo "ref=${ref}" >> "$GITHUB_OUTPUT"
|
|
37
|
-
# Enforce: ref must be a tagged release (vX.Y.Z), not a branch.
|
|
38
|
-
# This guarantees a deterministic build and lets the homepage
|
|
39
|
-
# display the same version it shipped with.
|
|
40
|
-
if ! [[ "$ref" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
|
|
41
|
-
echo "::error::.cicy-code-ref must be a release tag (vX.Y.Z), got: $ref"
|
|
42
|
-
exit 1
|
|
43
|
-
fi
|
|
44
|
-
|
|
45
|
-
- name: Checkout cicy-code as sibling
|
|
46
|
-
uses: actions/checkout@v4
|
|
47
|
-
with:
|
|
48
|
-
repository: cicy-ai/cicy-code
|
|
49
|
-
ref: ${{ steps.cicy_code_ref.outputs.ref }}
|
|
50
|
-
path: cicy-code
|
|
51
|
-
|
|
52
|
-
- name: Build cicy-code sidecar binaries (darwin amd64 + arm64)
|
|
53
|
-
# `bash build.sh all` runs prepare_embed (cicy-skills tarball, frontend,
|
|
54
|
-
# ttyd assets) and cross-compiles all four darwin/linux targets.
|
|
55
|
-
# We only need the two darwin slots for the Mac .app, but building
|
|
56
|
-
# the linux ones here is cheap (~20s) and keeps the prepare:sidecar
|
|
57
|
-
# script's "all targets at once" mode happy.
|
|
58
|
-
shell: bash
|
|
59
|
-
working-directory: cicy-code
|
|
60
|
-
run: |
|
|
61
|
-
bash build.sh all
|
|
62
|
-
ls -lh dist/
|
|
63
|
-
|
|
26
|
+
# cicy-code is NOT built-from-source here anymore. 主人(2026-06): the bundled
|
|
27
|
+
# sidecar = the per-platform optionalDependency (cicy-code-<plat>, prebuilt +
|
|
28
|
+
# arm64 linker-adhoc-signed), seeded at runtime by localbin.fromBundle. The old
|
|
29
|
+
# .cicy-code-ref source-build → vendor/cicy-code path was stale + never packaged
|
|
30
|
+
# (vendor/ not in package.json files), so it's removed. Sync just pins the
|
|
31
|
+
# optionalDeps to the latest published cicy-code/cicy-mihomo.
|
|
64
32
|
- name: Sync runtime deps to latest (cicy-code + cicy-mihomo; drop msys2)
|
|
65
33
|
run: node scripts/sync-runtime-deps.cjs
|
|
66
34
|
|
|
@@ -70,6 +38,20 @@ jobs:
|
|
|
70
38
|
- name: Install Electron build dependencies in project directory
|
|
71
39
|
run: npm install --save-dev --no-audit electron@41.0.2 electron-builder@26.7.0
|
|
72
40
|
|
|
41
|
+
# 主人(2026-06 关键修复): macos-latest runner 是 arm64,`npm install` 的 os/cpu
|
|
42
|
+
# 过滤只装 arm64 的 cicy-code/mihomo 子包 → x64(Intel)的 .pkg 里塞的也是 arm64
|
|
43
|
+
# 二进制 → Intel fresh 装没 :8008(实测 josephs)。这里强制把 BOTH darwin 架构都
|
|
44
|
+
# 装进 node_modules(--force 绕过 EBADPLATFORM),让 electron-builder 两架构都打包,
|
|
45
|
+
# localbin 按用户机器选对应那份。必须在所有 npm install 之后(否则被剪枝)。
|
|
46
|
+
- name: Bundle BOTH macOS arches of cicy-code/mihomo (runner is single-arch)
|
|
47
|
+
run: |
|
|
48
|
+
pkgs=$(node -e "const o=require('./package.json').optionalDependencies||{}; const w=['cicy-code-darwin-x64','cicy-code-darwin-arm64','cicy-mihomo-darwin-x64','cicy-mihomo-darwin-arm64']; console.log(w.filter(p=>o[p]).map(p=>p+'@'+o[p]).join(' '))")
|
|
49
|
+
echo "force-installing both arches: $pkgs"
|
|
50
|
+
npm install --no-save --no-audit --force $pkgs
|
|
51
|
+
echo "--- bundled darwin subpackages ---"
|
|
52
|
+
ls node_modules | grep -E 'cicy-(code|mihomo)-darwin' || true
|
|
53
|
+
for a in x64 arm64; do test -f "node_modules/cicy-code-darwin-$a/cicy-code" || { echo "::error::cicy-code-darwin-$a binary missing after force-install"; exit 1; }; done
|
|
54
|
+
|
|
73
55
|
# NOTE: the homepage SPA is rebuilt automatically by the prebuild:mac npm
|
|
74
56
|
# hook (scripts/build-homepage.cjs) right before `npm run build:mac` below,
|
|
75
57
|
# so the dmg can never ship a stale homepage. No explicit step needed.
|
|
@@ -100,16 +82,13 @@ jobs:
|
|
|
100
82
|
iconutil -c icns build/icon.iconset -o build/logo.icns || { echo "::warning::iconutil failed"; exit 0; }
|
|
101
83
|
|
|
102
84
|
- name: Build macOS app (dmg + zip, unsigned)
|
|
103
|
-
#
|
|
104
|
-
#
|
|
105
|
-
#
|
|
106
|
-
#
|
|
107
|
-
#
|
|
108
|
-
# unsigned build (with the cicy-code sidecar ad-hoc signed by
|
|
109
|
-
# prepare-cicy-code-sidecar.js so Apple Silicon will exec it).
|
|
85
|
+
# CSC_IDENTITY_AUTO_DISCOVERY=false stops electron-builder from probing the
|
|
86
|
+
# runner keychain for a cert it does not have; combined with
|
|
87
|
+
# build.mac.identity=null in package.json this produces a clean unsigned
|
|
88
|
+
# build. The cicy-code sidecar arrives via the optionalDependency
|
|
89
|
+
# (arm64 is linker-adhoc-signed already), seeded by localbin at runtime.
|
|
110
90
|
shell: bash
|
|
111
91
|
env:
|
|
112
|
-
CICY_CODE_DIST_DIR: ${{ github.workspace }}/cicy-code/dist
|
|
113
92
|
CSC_IDENTITY_AUTO_DISCOVERY: "false"
|
|
114
93
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
115
94
|
run: |
|
|
@@ -161,7 +140,6 @@ jobs:
|
|
|
161
140
|
shell: bash
|
|
162
141
|
env:
|
|
163
142
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
164
|
-
CICY_CODE_DIST_DIR: ${{ github.workspace }}/cicy-code/dist
|
|
165
143
|
CSC_IDENTITY_AUTO_DISCOVERY: "false"
|
|
166
144
|
run: |
|
|
167
145
|
gh release upload "${{ steps.meta.outputs.tag }}" dist/*.dmg dist/*.zip \
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cicy-desktop",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.184",
|
|
4
4
|
"description": "CiCy - AI-powered operating system browser",
|
|
5
5
|
"main": "src/main.js",
|
|
6
6
|
"bin": {
|
|
@@ -140,11 +140,11 @@
|
|
|
140
140
|
"//optionalDependencies": "主人(2026-06 回调): mac/linux 改回 native cicy-code(:8008,colima 在 16G mac 上压垮内存)→ 重新内置 cicy-code-<plat> / cicy-mihomo-<plat>,localbin.fromBundle 零网络 seed(npm 仅作更新通道,带 npmmirror→npmjs 回退)。这些由 scripts/sync-runtime-deps.cjs 在 tag-push 时同步到最新版。npm 的 os/cpu 字段保证每个平台只装自己那份。Windows 仍走 docker(WSL :8009),它那份 cicy-code-windows 用不到但 bundle 着无害。",
|
|
141
141
|
"optionalDependencies": {
|
|
142
142
|
"electron": "41.0.3",
|
|
143
|
-
"cicy-code-darwin-x64": "2.3.
|
|
144
|
-
"cicy-code-darwin-arm64": "2.3.
|
|
145
|
-
"cicy-code-linux-x64": "2.3.
|
|
146
|
-
"cicy-code-linux-arm64": "2.3.
|
|
147
|
-
"cicy-code-windows-x64": "2.3.
|
|
143
|
+
"cicy-code-darwin-x64": "2.3.23",
|
|
144
|
+
"cicy-code-darwin-arm64": "2.3.23",
|
|
145
|
+
"cicy-code-linux-x64": "2.3.23",
|
|
146
|
+
"cicy-code-linux-arm64": "2.3.23",
|
|
147
|
+
"cicy-code-windows-x64": "2.3.23",
|
|
148
148
|
"cicy-mihomo-darwin-x64": "1.10.4",
|
|
149
149
|
"cicy-mihomo-darwin-arm64": "1.10.4",
|
|
150
150
|
"cicy-mihomo-linux-x64": "1.10.4",
|
package/src/backends/ipc.js
CHANGED
|
@@ -174,18 +174,20 @@ function register(opts = {}) {
|
|
|
174
174
|
ipcMain.handle("app:check-update", async () => { await appUpdater.check(); return appUpdater.getState(); });
|
|
175
175
|
ipcMain.handle("app:install-update", () => { appUpdater.installNow(); return true; });
|
|
176
176
|
|
|
177
|
-
// Static version info: cicy-desktop's own version + the cicy-code
|
|
178
|
-
//
|
|
179
|
-
//
|
|
177
|
+
// Static version info: cicy-desktop's own version + the cicy-code version we
|
|
178
|
+
// actually ship. 主人(2026-06): the real bundled cicy-code = the per-platform
|
|
179
|
+
// optionalDependency (localbin.bundledVersion), not the retired `.cicy-code-ref`
|
|
180
|
+
// source-build pin (which was stale + never packaged). Used by the homepage
|
|
181
|
+
// footer to show "CiCy Desktop vX.Y · cicy-code vA.B".
|
|
180
182
|
ipcMain.handle("app:get-version", () => {
|
|
181
183
|
let cicyCodeRef = "";
|
|
182
184
|
try {
|
|
183
|
-
const
|
|
184
|
-
cicyCodeRef =
|
|
185
|
+
const bv = require("../sidecar/localbin").bundledVersion("cicy-code");
|
|
186
|
+
if (bv) cicyCodeRef = `v${bv}`;
|
|
185
187
|
} catch {}
|
|
186
188
|
return {
|
|
187
189
|
desktop: app.getVersion(),
|
|
188
|
-
cicyCodeRef, // e.g. "v2.
|
|
190
|
+
cicyCodeRef, // e.g. "v2.3.22" — the bundled cicy-code
|
|
189
191
|
electron: process.versions.electron,
|
|
190
192
|
node: process.versions.node,
|
|
191
193
|
chrome: process.versions.chrome,
|
package/src/sidecar/localbin.js
CHANGED
|
@@ -35,11 +35,36 @@ const path = require("path");
|
|
|
35
35
|
const { execFile, execFileSync } = require("child_process");
|
|
36
36
|
|
|
37
37
|
const IS_WIN = process.platform === "win32";
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
//
|
|
42
|
-
|
|
38
|
+
const NPMMIRROR = "https://registry.npmmirror.com"; // CN-fast
|
|
39
|
+
const NPMJS = "https://registry.npmjs.org"; // 官方,新版本/新子包先到这
|
|
40
|
+
|
|
41
|
+
// 主人(2026-06): 按网络环境选 registry 顺序,两边都用各自最快的源(对方做回退)。
|
|
42
|
+
// CN(GFW 内):npmmirror 优先 → npmjs 兜底
|
|
43
|
+
// 非CN: npmjs 优先 → npmmirror 兜底(npmmirror 海外慢,别让它当首选)
|
|
44
|
+
// 判断:探 generate_204 —— 能 204(够到 Google/有代理)= 非CN;超时/失败 = CN。探一次缓存。
|
|
45
|
+
// CICY_NPM_REGISTRY 覆盖时强制该源优先(测试/私有源用)。
|
|
46
|
+
let _cnProbe = null;
|
|
47
|
+
function probeIsCN() {
|
|
48
|
+
if (_cnProbe) return _cnProbe;
|
|
49
|
+
_cnProbe = new Promise((resolve) => {
|
|
50
|
+
let done = false;
|
|
51
|
+
const fin = (cn) => { if (!done) { done = true; resolve(cn); } };
|
|
52
|
+
try {
|
|
53
|
+
const req = require("https").get("https://www.gstatic.com/generate_204", { timeout: 2000 }, (res) => {
|
|
54
|
+
const ok = res.statusCode === 204; res.destroy(); fin(!ok); // 204 够到 = 非CN
|
|
55
|
+
});
|
|
56
|
+
req.on("timeout", () => { req.destroy(); fin(true); }); // 超时 = GFW = CN
|
|
57
|
+
req.on("error", () => fin(true)); // 连不上 = CN
|
|
58
|
+
} catch { fin(true); }
|
|
59
|
+
});
|
|
60
|
+
return _cnProbe;
|
|
61
|
+
}
|
|
62
|
+
async function registries() {
|
|
63
|
+
const override = process.env.CICY_NPM_REGISTRY;
|
|
64
|
+
if (override) return [override, NPMJS, NPMMIRROR].filter((r, i, a) => a.indexOf(r) === i);
|
|
65
|
+
const cn = await probeIsCN();
|
|
66
|
+
return cn ? [NPMMIRROR, NPMJS] : [NPMJS, NPMMIRROR];
|
|
67
|
+
}
|
|
43
68
|
const LOCAL_BIN = path.join(os.homedir(), ".local", "bin");
|
|
44
69
|
const MANIFEST = path.join(LOCAL_BIN, ".cicy-localbin.json");
|
|
45
70
|
|
|
@@ -126,11 +151,12 @@ function npmExec(args, timeout = 600000) {
|
|
|
126
151
|
});
|
|
127
152
|
}
|
|
128
153
|
|
|
129
|
-
// Latest published version of the per-platform subpackage. Tries
|
|
130
|
-
// npmjs
|
|
154
|
+
// Latest published version of the per-platform subpackage. Tries the env-ordered
|
|
155
|
+
// registries (CN→npmmirror first, 非CN→npmjs first) so a not-yet-mirrored
|
|
156
|
+
// package/version still resolves and 非CN 不被慢镜像拖住。
|
|
131
157
|
async function latestVersion(name = DEFAULT) {
|
|
132
158
|
let lastErr;
|
|
133
|
-
for (const reg of
|
|
159
|
+
for (const reg of await registries()) {
|
|
134
160
|
try { return (await npmExec(["view", pkgFor(name), "version", `--registry=${reg}`], 30000)).trim(); }
|
|
135
161
|
catch (e) { lastErr = e; }
|
|
136
162
|
}
|
|
@@ -221,7 +247,7 @@ async function fetchToLocalBin(ver, { emit, name = DEFAULT } = {}) {
|
|
|
221
247
|
try {
|
|
222
248
|
e({ phase: "download", status: "running", message: `下载 ${label} ${ver}…` });
|
|
223
249
|
let out, lastErr;
|
|
224
|
-
for (const reg of
|
|
250
|
+
for (const reg of await registries()) {
|
|
225
251
|
try { out = await npmExec(["pack", `${pkgFor(name)}@${ver}`, `--registry=${reg}`, "--pack-destination", tmp]); break; }
|
|
226
252
|
catch (e2) { lastErr = e2; }
|
|
227
253
|
}
|
package/.cicy-code-ref
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
v2.2.5
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Populates vendor/cicy-code/<platform>-<arch>/cicy-code so electron-builder
|
|
3
|
-
// can include the cicy-code daemon as an extraResources sidecar.
|
|
4
|
-
//
|
|
5
|
-
// Source resolution (first hit wins):
|
|
6
|
-
// 1. CICY_CODE_BIN_PATH — single binary file, copied to the current host's
|
|
7
|
-
// platform/arch slot only. Dev shortcut on the maintainer's own box.
|
|
8
|
-
// 2. CICY_CODE_DIST_DIR — directory containing all four
|
|
9
|
-
// cicy-code-{darwin,linux}-{amd64,arm64} files as produced by
|
|
10
|
-
// `bash build.sh all` in the cicy-code repo. Used by CI.
|
|
11
|
-
// 3. ../cicy-code/dist — sibling checkout fallback.
|
|
12
|
-
//
|
|
13
|
-
// Output layout (the ${arch} macro in electron-builder uses x64/arm64 naming,
|
|
14
|
-
// not Go's amd64/arm64, so we rename at copy time):
|
|
15
|
-
// vendor/cicy-code/darwin-x64/cicy-code
|
|
16
|
-
// vendor/cicy-code/darwin-arm64/cicy-code
|
|
17
|
-
// vendor/cicy-code/linux-x64/cicy-code
|
|
18
|
-
// vendor/cicy-code/linux-arm64/cicy-code
|
|
19
|
-
//
|
|
20
|
-
// On macOS hosts the copied binary is ad-hoc signed (`codesign --sign -`) so
|
|
21
|
-
// it loads on Apple Silicon (which refuses to exec any unsigned mach-o).
|
|
22
|
-
// When a real Apple Developer ID is configured, electron-builder's signing
|
|
23
|
-
// pass during build:mac will overwrite this ad-hoc sig.
|
|
24
|
-
|
|
25
|
-
const fs = require("fs");
|
|
26
|
-
const path = require("path");
|
|
27
|
-
const { spawnSync } = require("child_process");
|
|
28
|
-
|
|
29
|
-
const REPO_ROOT = path.resolve(__dirname, "..");
|
|
30
|
-
const VENDOR_ROOT = path.join(REPO_ROOT, "vendor", "cicy-code");
|
|
31
|
-
|
|
32
|
-
const TARGETS = [
|
|
33
|
-
{ platform: "darwin", goArch: "amd64", electronArch: "x64" },
|
|
34
|
-
{ platform: "darwin", goArch: "arm64", electronArch: "arm64" },
|
|
35
|
-
{ platform: "linux", goArch: "amd64", electronArch: "x64" },
|
|
36
|
-
{ platform: "linux", goArch: "arm64", electronArch: "arm64" },
|
|
37
|
-
];
|
|
38
|
-
|
|
39
|
-
function nodePlatformToGo(p) {
|
|
40
|
-
if (p === "darwin") return "darwin";
|
|
41
|
-
if (p === "linux") return "linux";
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
function nodeArchToGo(a) {
|
|
45
|
-
if (a === "x64") return "amd64";
|
|
46
|
-
if (a === "arm64") return "arm64";
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function adhocSignIfDarwin(destPath, target) {
|
|
51
|
-
if (process.platform !== "darwin" || target.platform !== "darwin") return;
|
|
52
|
-
const r = spawnSync("codesign", ["--force", "--sign", "-", destPath], { stdio: "pipe", encoding: "utf8" });
|
|
53
|
-
if (r.status === 0) {
|
|
54
|
-
console.log(`[cicy-code-sidecar] ad-hoc signed ${path.basename(destPath)}`);
|
|
55
|
-
} else {
|
|
56
|
-
console.warn(`[cicy-code-sidecar] codesign failed (rc=${r.status}); arm64 may refuse to launch this binary: ${r.stderr.trim()}`);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function copyOne(srcPath, target) {
|
|
61
|
-
if (!fs.existsSync(srcPath)) return false;
|
|
62
|
-
const destDir = path.join(VENDOR_ROOT, `${target.platform}-${target.electronArch}`);
|
|
63
|
-
fs.mkdirSync(destDir, { recursive: true });
|
|
64
|
-
const destPath = path.join(destDir, "cicy-code");
|
|
65
|
-
fs.copyFileSync(srcPath, destPath);
|
|
66
|
-
fs.chmodSync(destPath, 0o755);
|
|
67
|
-
const sizeMB = (fs.statSync(destPath).size / (1024 * 1024)).toFixed(1);
|
|
68
|
-
console.log(`[cicy-code-sidecar] ${target.platform}/${target.electronArch} ${sizeMB} MB <- ${srcPath}`);
|
|
69
|
-
adhocSignIfDarwin(destPath, target);
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function main() {
|
|
74
|
-
fs.mkdirSync(VENDOR_ROOT, { recursive: true });
|
|
75
|
-
|
|
76
|
-
const binPath = process.env.CICY_CODE_BIN_PATH;
|
|
77
|
-
if (binPath) {
|
|
78
|
-
const goPlat = nodePlatformToGo(process.platform);
|
|
79
|
-
const goArch = nodeArchToGo(process.arch);
|
|
80
|
-
if (!goPlat || !goArch) {
|
|
81
|
-
console.error(`[cicy-code-sidecar] CICY_CODE_BIN_PATH set but current host ${process.platform}/${process.arch} is not a supported sidecar target`);
|
|
82
|
-
process.exit(1);
|
|
83
|
-
}
|
|
84
|
-
const t = TARGETS.find(x => x.platform === goPlat && x.goArch === goArch);
|
|
85
|
-
if (!copyOne(binPath, t)) {
|
|
86
|
-
console.error(`[cicy-code-sidecar] CICY_CODE_BIN_PATH=${binPath} does not exist`);
|
|
87
|
-
process.exit(1);
|
|
88
|
-
}
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const sibling = path.resolve(REPO_ROOT, "..", "cicy-code", "dist");
|
|
93
|
-
const distDir = process.env.CICY_CODE_DIST_DIR
|
|
94
|
-
|| (fs.existsSync(sibling) ? sibling : null);
|
|
95
|
-
if (!distDir) {
|
|
96
|
-
console.error("[cicy-code-sidecar] no source found.");
|
|
97
|
-
console.error(" Set one of:");
|
|
98
|
-
console.error(" CICY_CODE_BIN_PATH=/path/to/cicy-code");
|
|
99
|
-
console.error(" CICY_CODE_DIST_DIR=/path/to/cicy-code/dist");
|
|
100
|
-
console.error(" …or check out cicy-code as a sibling at ../cicy-code and run `bash build.sh all` there.");
|
|
101
|
-
process.exit(1);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
let copied = 0;
|
|
105
|
-
for (const t of TARGETS) {
|
|
106
|
-
const srcPath = path.join(distDir, `cicy-code-${t.platform}-${t.goArch}`);
|
|
107
|
-
if (copyOne(srcPath, t)) copied++;
|
|
108
|
-
}
|
|
109
|
-
if (copied === 0) {
|
|
110
|
-
console.error(`[cicy-code-sidecar] no expected binaries found under ${distDir}`);
|
|
111
|
-
console.error(" Expected: cicy-code-{darwin,linux}-{amd64,arm64}");
|
|
112
|
-
process.exit(1);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
main();
|