@ytchuan/flowlink 1.0.4 → 1.0.5

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/README.md CHANGED
@@ -19,6 +19,7 @@ app/
19
19
  ├── scripts/ # 发布辅助脚本
20
20
  │ ├── copy-ui.js # 发布前复制渲染层产物到包内
21
21
  │ ├── manifest-electron.js # 切换 electron 依赖位置(保留兼容)
22
+ │ ├── postinstall.js # 安装后校验/补装 Electron 二进制(国内镜像)
22
23
  │ └── release.js # 发布脚本(处理 electron 依赖 + 调用 npm publish)
23
24
  ├── docs/ # 设计文档与 Agent 说明
24
25
  └── package.json # 依赖与 electron-builder 打包配置
@@ -37,8 +38,11 @@ npm install -g @ytchuan/flowlink
37
38
  flowlink
38
39
  ```
39
40
 
40
- > 首次安装会下载 Electron(~150MB),包内已配置国内镜像加速下载。
41
- > `flowlink` 默认后台运行,不占用终端。如需调试,使用 `flowlink --foreground` 前台运行。
41
+ ## 首次安装会下载 Electron(~150MB)。已内置国内镜像(npmmirror),无需额外配置;
42
+ ### 如仍下载失败,可手动设置镜像后重装:
43
+ ```bash
44
+ npm config set electron_mirror https://npmmirror.com/mirrors/electron/
45
+ ```
42
46
 
43
47
  ## 版本更新
44
48
 
package/bin/flowlink.js CHANGED
@@ -11,6 +11,12 @@
11
11
  const { spawn } = require('child_process')
12
12
  const path = require('path')
13
13
 
14
+ // 兜底:Electron 二进制缺失时会触发运行时按需下载(@electron/get),
15
+ // 默认源是 GitHub Releases,国内容易失败。未显式配置镜像时默认走国内镜像。
16
+ if (!process.env.ELECTRON_MIRROR && !process.env.npm_config_electron_mirror) {
17
+ process.env.ELECTRON_MIRROR = 'https://npmmirror.com/mirrors/electron/'
18
+ }
19
+
14
20
  // 定位 electron 可执行文件
15
21
  const electronPath = require('electron')
16
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ytchuan/flowlink",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "FlowLink 桌面客户端 - AI 服务调度与管理",
5
5
  "main": "main.js",
6
6
  "bin": {
@@ -14,6 +14,7 @@
14
14
  "app-ui/dist/",
15
15
  "assets/",
16
16
  "resources/",
17
+ "scripts/postinstall.js",
17
18
  ".npmrc"
18
19
  ],
19
20
  "engines": {
@@ -31,6 +32,7 @@
31
32
  "build:mac": "npm run build:ui && electron-builder --mac",
32
33
  "build:mac:zip": "npm run build:ui && electron-builder --mac zip",
33
34
  "prepack": "npm run build:ui && node scripts/copy-ui.js",
35
+ "postinstall": "node scripts/postinstall.js",
34
36
  "release": "node scripts/release.js",
35
37
  "test": "echo \"Error: no test specified\" && exit 1"
36
38
  },
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * 安装兜底脚本(postinstall)
5
+ *
6
+ * electron 包自带的 postinstall 负责下载二进制,但在网络异常/跳过脚本等情况下
7
+ * 可能下载失败,导致用户首次运行 `flowlink` 时触发运行时按需下载(默认走 GitHub,
8
+ * 国内大概率失败)。此脚本在包安装完成后校验二进制是否完整,缺失则用国内镜像补装。
9
+ */
10
+ const fs = require('fs')
11
+ const path = require('path')
12
+ const { execFileSync } = require('child_process')
13
+
14
+ const MIRROR = 'https://npmmirror.com/mirrors/electron/'
15
+
16
+ try {
17
+ // 定位全局/本地安装的 electron 包目录
18
+ const electronDir = path.dirname(require.resolve('electron/package.json'))
19
+ const pathTxt = path.join(electronDir, 'path.txt')
20
+
21
+ // 二进制已完整则跳过(path.txt 内容为 dist 内的相对路径)
22
+ if (fs.existsSync(pathTxt)) {
23
+ const relPath = fs.readFileSync(pathTxt, 'utf8').trim()
24
+ if (fs.existsSync(path.join(electronDir, 'dist', relPath))) {
25
+ process.exit(0)
26
+ }
27
+ }
28
+
29
+ // 未显式配置镜像时默认走国内镜像
30
+ const env = { ...process.env }
31
+ if (!env.ELECTRON_MIRROR && !env.npm_config_electron_mirror) {
32
+ env.ELECTRON_MIRROR = MIRROR
33
+ }
34
+
35
+ console.log('[flowlink] Electron 二进制缺失,正在通过镜像补装...')
36
+ execFileSync(process.execPath, [path.join(electronDir, 'install.js')], {
37
+ stdio: 'inherit',
38
+ env,
39
+ cwd: electronDir,
40
+ })
41
+ } catch (err) {
42
+ // 补装失败不阻塞安装流程;首次运行 `flowlink` 时会再次尝试(同样走镜像)
43
+ console.warn('[flowlink] Electron 二进制补装失败,首次运行时将自动重试:', err.message)
44
+ }