glasspane-install 1.12.2 → 1.12.3
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/cli.js +24 -4
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { spawn, spawnSync } from 'node:child_process'
|
|
21
21
|
import { createInterface } from 'node:readline/promises'
|
|
22
|
-
import { pathToFileURL } from 'node:url'
|
|
22
|
+
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
23
23
|
import fs from 'node:fs'
|
|
24
24
|
import os from 'node:os'
|
|
25
25
|
import path from 'node:path'
|
|
@@ -69,7 +69,7 @@ export const INSTALL_SH_URL =
|
|
|
69
69
|
/** 发布线锚点(版本真源 = 根 package.json,由 scripts/set-version.mjs 统一改写,
|
|
70
70
|
* 勿手改):npx 形态下本地没有仓库时,引导 clone 的就是这个 tag,与 install.sh
|
|
71
71
|
* 的 `GLASSPANE_RELEASE` 同值——两条一键入口必须拿到同一份源码。 */
|
|
72
|
-
export const RELEASE_VERSION = '1.12.
|
|
72
|
+
export const RELEASE_VERSION = '1.12.3'
|
|
73
73
|
/** 发布 ref(tag 名)。GLASSPANE_REF 环境变量可覆盖(追主干用 `main`)。 */
|
|
74
74
|
export const REPO_REF = `v${RELEASE_VERSION}`
|
|
75
75
|
|
|
@@ -2512,8 +2512,28 @@ export async function install({
|
|
|
2512
2512
|
return outcome
|
|
2513
2513
|
}
|
|
2514
2514
|
|
|
2515
|
-
/** 入口守卫:直接用 node 运行本文件时才走安装流程(测试导入仅取函数)。
|
|
2516
|
-
|
|
2515
|
+
/** 入口守卫:直接用 node 运行本文件时才走安装流程(测试导入仅取函数)。
|
|
2516
|
+
*
|
|
2517
|
+
* 两侧都必须 realpath。`npm install -g` 和 `npx` 交付的是**符号链接**形式的 bin
|
|
2518
|
+
* (`<prefix>/bin/glasspane-install` → `../lib/node_modules/glasspane-install/cli.js`),
|
|
2519
|
+
* 而 node 把 ESM 入口按 realpath 载入,于是 `import.meta.url` 是被链接的那份、
|
|
2520
|
+
* `process.argv[1]` 是链接本身。只比 `pathToFileURL(process.argv[1]).href` 时两者恒不相等,
|
|
2521
|
+
* 下面整块 `if (isMain)` 一步都不走——退出码 0、stdout 与 stderr 全空:一条 README 里写着
|
|
2522
|
+
* "一键安装"的命令,在 npm/npx 这两条文档路径上安静地什么都不做。
|
|
2523
|
+
* realpathSync 对不存在的路径会抛,而这段在 import 期就执行,所以包起来:比不成=
|
|
2524
|
+
* "不是被直接运行",不是"崩掉整个模块"。
|
|
2525
|
+
*/
|
|
2526
|
+
function invokedAsEntrypoint() {
|
|
2527
|
+
const entry = process.argv[1]
|
|
2528
|
+
if (!entry) return false
|
|
2529
|
+
try {
|
|
2530
|
+
return fs.realpathSync(entry) === fs.realpathSync(fileURLToPath(import.meta.url))
|
|
2531
|
+
} catch {
|
|
2532
|
+
return false
|
|
2533
|
+
}
|
|
2534
|
+
}
|
|
2535
|
+
|
|
2536
|
+
const isMain = invokedAsEntrypoint()
|
|
2517
2537
|
|
|
2518
2538
|
if (isMain) {
|
|
2519
2539
|
// 入口的**每一条**退出都交给事件循环,没有例外。`curl | sh` 是文档里的调用形态,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glasspane-install",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.3",
|
|
4
4
|
"description": "GlassPane one-command installer: terminal onboarding → install deps → build TS + Swift engine → start daemon → open settings GUI for permission guide",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|