cicy-desktop 2.1.92 → 2.1.93

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.
Files changed (2) hide show
  1. package/bin/cicy-desktop +48 -18
  2. package/package.json +1 -1
package/bin/cicy-desktop CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const { spawn, execSync } = require("child_process");
2
+ const { spawn, execSync, execFileSync } = require("child_process");
3
3
  const path = require("path");
4
4
  const fs = require("fs");
5
5
  const os = require("os");
@@ -76,13 +76,50 @@ function globalElectronDir() {
76
76
  } catch { return null; }
77
77
  }
78
78
 
79
+ // The per-platform Electron artifact (mirror zip name + the in-dist executable
80
+ // that path.txt must point at).
81
+ function electronArtifact() {
82
+ const plat = process.platform === "win32" ? "win32" : process.platform === "darwin" ? "darwin" : "linux";
83
+ const arch = process.arch === "arm64" ? "arm64" : "x64";
84
+ return {
85
+ zip: `electron-v${ELECTRON_VERSION}-${plat}-${arch}.zip`,
86
+ exe: process.platform === "win32" ? "electron.exe"
87
+ : process.platform === "darwin" ? "Electron.app/Contents/MacOS/Electron"
88
+ : "electron",
89
+ };
90
+ }
91
+
92
+ // Provision the Electron binary INTO the bundled npx copy ourselves: download the
93
+ // platform zip from the mirror (R2) with curl, extract with the OS's own unzip,
94
+ // then write path.txt. We deliberately do NOT use electron's install.js /
95
+ // @electron/get: on Windows its bundled extract-zip only PARTIALLY unpacks
96
+ // electron 41 (leaves no path.txt → "Electron failed to install correctly") even
97
+ // though the downloaded zip is valid. curl + Expand-Archive/unzip is reliable,
98
+ // mirror-only (no GitHub), and writes a complete dist/.
99
+ function provisionElectronFromMirror(bundledDir) {
100
+ const { zip, exe } = electronArtifact();
101
+ const url = `${ELECTRON_MIRROR}v${ELECTRON_VERSION}/${zip}`;
102
+ const tmpZip = path.join(os.tmpdir(), `cicy-${zip}`);
103
+ const curl = isWindows ? "curl.exe" : "curl";
104
+ execFileSync(curl, ["-fL", "--retry", "5", "--retry-delay", "2", "--connect-timeout", "20", "-o", tmpZip, url], { stdio: "inherit" });
105
+ const distDir = path.join(bundledDir, "dist");
106
+ fs.rmSync(distDir, { recursive: true, force: true });
107
+ fs.mkdirSync(distDir, { recursive: true });
108
+ if (isWindows) {
109
+ execFileSync("powershell", ["-NoProfile", "-Command", `Expand-Archive -LiteralPath "${tmpZip}" -DestinationPath "${distDir}" -Force`], { stdio: "inherit" });
110
+ } else {
111
+ execFileSync("unzip", ["-o", "-q", tmpZip, "-d", distDir], { stdio: "inherit" });
112
+ try { fs.chmodSync(path.join(distDir, exe), 0o755); } catch {}
113
+ }
114
+ fs.writeFileSync(path.join(bundledDir, "path.txt"), exe);
115
+ try { fs.rmSync(tmpZip, { force: true }); } catch {}
116
+ }
117
+
79
118
  // Make sure a USABLE electron exists before spawning the worker. A pre-existing
80
- // GLOBAL electron is reused if present (downloaded once, shared). Otherwise we
81
- // provision the electron binary LOCALLY into the bundled npx copy by re-running
82
- // electron's own install.js against our R2 mirror NO `npm i -g`, NO GitHub.
83
- // This is what lets a single `npx cicy-desktop` self-provision electron and
84
- // start first-try even when the install-time postinstall couldn't fetch the
85
- // binary (GitHub blocked/slow). Runs once per process.
119
+ // GLOBAL electron is reused if present. Otherwise we provision the binary LOCALLY
120
+ // into the bundled npx copy straight from the R2 mirror NO `npm i -g`, NO
121
+ // GitHub, NO @electron/get. This is what lets a single `npx cicy-desktop`
122
+ // self-provision electron and start first-try. Runs once per process.
86
123
  let _electronEnsured = false;
87
124
  function ensureElectron() {
88
125
  if (_electronEnsured) return;
@@ -96,20 +133,13 @@ function ensureElectron() {
96
133
  console.warn(`⚠️ electron package not resolvable under ${PACKAGE_ROOT}; cannot self-provision.`);
97
134
  return;
98
135
  }
99
- // The electron package is installed but its binary wasn't downloaded. Fetch it
100
- // INTO node_modules/electron from the mirror (R2) by invoking electron's own
101
- // installer — @electron/get reads ELECTRON_MIRROR and pulls
102
- // <mirror>v<version>/electron-v<version>-<platform>.zip. Local, no global.
103
136
  console.log(`⚙️ Fetching Electron ${ELECTRON_VERSION} from mirror (one-time)…`);
104
137
  try {
105
- execSync(`node "${path.join(bundledDir, "install.js")}"`, {
106
- stdio: "inherit",
107
- cwd: bundledDir,
108
- env: { ...process.env, ELECTRON_MIRROR, npm_config_registry: NPM_REGISTRY },
109
- });
138
+ provisionElectronFromMirror(bundledDir);
139
+ if (electronBinaryHealthy(bundledDir)) return;
140
+ console.warn(`⚠️ Electron provisioned but health check still failing.`);
110
141
  } catch (e) {
111
- console.warn(`⚠️ Electron download from mirror failed: ${e.message}`);
112
- console.warn(` Retry: ELECTRON_MIRROR=${ELECTRON_MIRROR} node "${path.join(bundledDir, "install.js")}"`);
142
+ console.warn(`⚠️ Electron provision from mirror failed: ${e.message}`);
113
143
  }
114
144
  }
115
145
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cicy-desktop",
3
- "version": "2.1.92",
3
+ "version": "2.1.93",
4
4
  "description": "CiCy - AI-powered operating system browser",
5
5
  "main": "src/main.js",
6
6
  "bin": {