cicy-desktop 2.1.129 → 2.1.130
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/cicy-desktop +39 -8
- package/package.json +1 -1
- package/cicy-dektop.command +0 -51
package/bin/cicy-desktop
CHANGED
|
@@ -170,19 +170,42 @@ function provisionElectronFromMirror(bundledDir) {
|
|
|
170
170
|
// into the bundled npx copy straight from the R2 mirror — NO `npm i -g`, NO
|
|
171
171
|
// GitHub, NO @electron/get. This is what lets a single `npx cicy-desktop`
|
|
172
172
|
// self-provision electron and start first-try. Runs once per process.
|
|
173
|
+
// The electron dir we provision into: the real electron npm package if it's
|
|
174
|
+
// installed, otherwise a self-managed dir under our own node_modules. `npx
|
|
175
|
+
// cicy-desktop` does NOT pull electron (it's not a runtime dep), so on a fresh
|
|
176
|
+
// machine require.resolve('electron') fails — we must NOT give up there.
|
|
177
|
+
function bundledElectronDir() {
|
|
178
|
+
try { return path.dirname(require.resolve("electron/package.json", { paths: [PACKAGE_ROOT] })); } catch {}
|
|
179
|
+
return path.join(PACKAGE_ROOT, "node_modules", "electron");
|
|
180
|
+
}
|
|
181
|
+
// Make `dir` a resolvable electron package (package.json + index.js that reads
|
|
182
|
+
// path.txt) so provisionElectronFromMirror's layout + a spawned require('electron')
|
|
183
|
+
// both work — WITHOUT ever running electron's own installer. Only fills in missing
|
|
184
|
+
// files, so a real electron package is left untouched.
|
|
185
|
+
function ensureMinimalElectronPkg(dir) {
|
|
186
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
187
|
+
const pj = path.join(dir, "package.json");
|
|
188
|
+
if (!fs.existsSync(pj)) fs.writeFileSync(pj, JSON.stringify({ name: "electron", version: ELECTRON_VERSION, main: "index.js" }));
|
|
189
|
+
const ij = path.join(dir, "index.js");
|
|
190
|
+
if (!fs.existsSync(ij)) fs.writeFileSync(ij,
|
|
191
|
+
"const fs=require('fs'),path=require('path');const p=path.join(__dirname,'path.txt');" +
|
|
192
|
+
"module.exports=fs.existsSync(p)?path.join(__dirname,'dist',fs.readFileSync(p,'utf8').trim()):null;\n");
|
|
193
|
+
}
|
|
194
|
+
|
|
173
195
|
let _electronEnsured = false;
|
|
174
196
|
function ensureElectron() {
|
|
175
197
|
if (_electronEnsured) return;
|
|
176
198
|
_electronEnsured = true;
|
|
177
|
-
// Already usable (a shared global, or
|
|
199
|
+
// Already usable (a shared global, or an already-provisioned bundled copy)? done.
|
|
178
200
|
if (electronBinaryHealthy(globalElectronDir())) return;
|
|
179
|
-
|
|
180
|
-
try { bundledDir = path.dirname(require.resolve("electron/package.json", { paths: [PACKAGE_ROOT] })); } catch {}
|
|
201
|
+
const bundledDir = bundledElectronDir();
|
|
181
202
|
if (electronBinaryHealthy(bundledDir)) return;
|
|
182
|
-
if
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
203
|
+
// Set up the dir (create minimal pkg if electron isn't installed) then download
|
|
204
|
+
// the binary straight from the mirror — bypassing electron's own installer,
|
|
205
|
+
// which is broken on win32 + node 24 (@electron-internal extract-zip native
|
|
206
|
+
// binding "intentionally not published" → "Cannot find native binding").
|
|
207
|
+
try { ensureMinimalElectronPkg(bundledDir); }
|
|
208
|
+
catch (e) { console.warn(`⚠️ could not set up electron dir ${bundledDir}: ${e.message}`); return; }
|
|
186
209
|
console.log(`⚙️ Fetching Electron ${ELECTRON_VERSION} from mirror (one-time)…`);
|
|
187
210
|
try {
|
|
188
211
|
provisionElectronFromMirror(bundledDir);
|
|
@@ -200,9 +223,17 @@ function resolveElectronSpawn() {
|
|
|
200
223
|
ensureElectron();
|
|
201
224
|
const g = globalElectronBin();
|
|
202
225
|
if (g) return { cmd: g, prefixArgs: [] };
|
|
203
|
-
|
|
226
|
+
// Spawn the self-provisioned binary DIRECTLY (mirror download → <dir>/dist/<exe>).
|
|
227
|
+
// Critically: prefer this over `npx electron` — electron's own installer is
|
|
228
|
+
// broken on win32 + node 24, so the npx fallback below just crashes there.
|
|
229
|
+
try {
|
|
230
|
+
const { exe } = electronArtifact();
|
|
231
|
+
const bin = path.join(bundledElectronDir(), "dist", exe);
|
|
232
|
+
if (fs.existsSync(bin)) return { cmd: bin, prefixArgs: [] };
|
|
233
|
+
} catch {}
|
|
204
234
|
const local = path.join(PACKAGE_ROOT, "node_modules", ".bin", "electron");
|
|
205
235
|
if (fs.existsSync(local)) return { cmd: local, prefixArgs: [] };
|
|
236
|
+
if (isWindows) return { cmd: "npx.cmd", prefixArgs: ["electron"] };
|
|
206
237
|
return { cmd: "npx", prefixArgs: ["electron"] };
|
|
207
238
|
}
|
|
208
239
|
const PROJECT_COMMAND_FILE = path.join(PACKAGE_ROOT, "cicy-dektop.command");
|
package/package.json
CHANGED
package/cicy-dektop.command
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
#!/bin/zsh
|
|
2
|
-
set -e
|
|
3
|
-
|
|
4
|
-
PROJECT_DIR="/Users/ton/projects/cicy-desktop"
|
|
5
|
-
|
|
6
|
-
exec 2>&1
|
|
7
|
-
|
|
8
|
-
echo "========================================="
|
|
9
|
-
echo " 🚀 CiCy Desktop Master + Worker"
|
|
10
|
-
echo " 📅 $(date '+%Y-%m-%d %H:%M:%S')"
|
|
11
|
-
echo "========================================="
|
|
12
|
-
|
|
13
|
-
if [ ! -d "$PROJECT_DIR" ]; then
|
|
14
|
-
echo "❌ Project directory not found: $PROJECT_DIR"
|
|
15
|
-
echo "按回车键退出..."
|
|
16
|
-
read
|
|
17
|
-
exit 1
|
|
18
|
-
fi
|
|
19
|
-
|
|
20
|
-
cd "$PROJECT_DIR" || {
|
|
21
|
-
echo "❌ Failed to cd into project directory"
|
|
22
|
-
echo "按回车键退出..."
|
|
23
|
-
read
|
|
24
|
-
exit 1
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
echo "📁 Project: $PROJECT_DIR"
|
|
28
|
-
|
|
29
|
-
# Dev override: if .env.dev exists in the project root, source it before
|
|
30
|
-
# npm start. Useful for CICY_HOMEPAGE_URL=http://localhost:8173 to load
|
|
31
|
-
# the workers/render vite dev server (HMR) into the BrowserWindow instead
|
|
32
|
-
# of the production CF Worker / bundled file://.
|
|
33
|
-
if [ -f "$PROJECT_DIR/.env.dev" ]; then
|
|
34
|
-
echo "🧪 .env.dev detected — loading dev overrides"
|
|
35
|
-
set -a
|
|
36
|
-
. "$PROJECT_DIR/.env.dev"
|
|
37
|
-
set +a
|
|
38
|
-
fi
|
|
39
|
-
|
|
40
|
-
echo "🚀 Running: npm start"
|
|
41
|
-
echo "⚠️ 关闭此窗口将停止 Master 和 Worker"
|
|
42
|
-
echo "========================================="
|
|
43
|
-
echo ""
|
|
44
|
-
|
|
45
|
-
npm start
|
|
46
|
-
|
|
47
|
-
echo ""
|
|
48
|
-
echo "========================================="
|
|
49
|
-
echo "Master + Worker 已停止"
|
|
50
|
-
echo "按回车键关闭窗口..."
|
|
51
|
-
read
|