@nuphus/nuphus-desktop 0.1.3 → 0.1.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.
Files changed (2) hide show
  1. package/bin/nuphus.js +83 -77
  2. package/package.json +4 -4
package/bin/nuphus.js CHANGED
@@ -1,77 +1,83 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Nuphus 桌面应用启动器(npm 一键安装入口)
4
- *
5
- * 通过 optionalDependencies 自动选择对应平台的二进制子包:
6
- * win32-x64 -> @nuphus/nuphus-desktop-win32-x64 (nuphus.exe)
7
- * darwin-arm64-> @nuphus/nuphus-desktop-osx-arm64 (Nuphus.app)
8
- * linux-x64 -> @nuphus/nuphus-desktop-linux-x64 (nuphus)
9
- */
10
- 'use strict';
11
-
12
- const { spawn } = require('child_process');
13
- const path = require('path');
14
- const fs = require('fs');
15
-
16
- const PLATFORM_MAP = {
17
- 'win32-x64': {
18
- pkg: 'nuphus-desktop-win32-x64',
19
- binary: 'nuphus.exe',
20
- },
21
- 'darwin-arm64': {
22
- pkg: 'nuphus-desktop-osx-arm64',
23
- app: 'Nuphus.app',
24
- },
25
- 'linux-x64': {
26
- pkg: 'nuphus-desktop-linux-x64',
27
- binary: 'nuphus',
28
- },
29
- };
30
-
31
- function resolveVendorDir() {
32
- const key = `${process.platform}-${process.arch}`;
33
- const spec = PLATFORM_MAP[key];
34
- if (!spec) {
35
- console.error(`[nuphus] 暂不支持该平台/架构: ${key}`);
36
- console.error(' 当前支持: win32-x64 / darwin-arm64 / linux-x64');
37
- process.exit(1);
38
- }
39
- // 主包位于 node_modules/@nuphus/nuphus-desktop/,平台子包与其同级
40
- // __dirname = <node_modules>/@nuphus/nuphus-desktop/bin
41
- const vendor = path.join(__dirname, '..', '..', '@nuphus', spec.pkg);
42
- if (!fs.existsSync(vendor)) {
43
- console.error(`[nuphus] 未找到平台包: ${spec.pkg}`);
44
- console.error(' 请确认安装完整(npm install -g @nuphus/nuphus-desktop)或重装。');
45
- process.exit(1);
46
- }
47
- return { vendor, spec };
48
- }
49
-
50
- function main() {
51
- const { vendor, spec } = resolveVendorDir();
52
-
53
- let cmd;
54
- let args = [];
55
- if (process.platform === 'darwin') {
56
- // macOS: open -a Nuphus.app(正确的应用启动方式)
57
- cmd = 'open';
58
- args = ['-a', path.join(vendor, spec.app)];
59
- } else {
60
- cmd = path.join(vendor, spec.binary);
61
- }
62
-
63
- const child = spawn(cmd, args, {
64
- stdio: 'ignore',
65
- detached: process.platform !== 'win32',
66
- });
67
-
68
- child.on('error', (err) => {
69
- console.error(`[nuphus] 启动失败: ${err.message}`);
70
- process.exit(1);
71
- });
72
-
73
- child.unref();
74
- console.log(`[nuphus] 正在启动 Nuphus 桌面应用…`);
75
- }
76
-
77
- main();
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Nuphus 桌面应用启动器(npm 一键安装入口)
4
+ *
5
+ * 通过 optionalDependencies 自动选择对应平台的二进制子包:
6
+ * win32-x64 -> @nuphus/nuphus-desktop-win32-x64 (nuphus.exe)
7
+ * darwin-arm64-> @nuphus/nuphus-desktop-osx-arm64 (Nuphus.app)
8
+ * linux-x64 -> @nuphus/nuphus-desktop-linux-x64 (nuphus)
9
+ */
10
+ 'use strict';
11
+
12
+ const { spawn } = require('child_process');
13
+ const path = require('path');
14
+ const fs = require('fs');
15
+
16
+ const PLATFORM_MAP = {
17
+ 'win32-x64': {
18
+ pkg: 'nuphus-desktop-win32-x64',
19
+ binary: 'nuphus.exe',
20
+ },
21
+ 'darwin-arm64': {
22
+ pkg: 'nuphus-desktop-osx-arm64',
23
+ app: 'Nuphus.app',
24
+ },
25
+ 'linux-x64': {
26
+ pkg: 'nuphus-desktop-linux-x64',
27
+ binary: 'nuphus',
28
+ },
29
+ };
30
+
31
+ function resolveVendorDir() {
32
+ const key = `${process.platform}-${process.arch}`;
33
+ const spec = PLATFORM_MAP[key];
34
+ if (!spec) {
35
+ console.error(`[nuphus] 暂不支持该平台/架构: ${key}`);
36
+ console.error(' 当前支持: win32-x64 / darwin-arm64 / linux-x64');
37
+ process.exit(1);
38
+ }
39
+ // 平台子包可能被 npm 提升到 <node_modules>/@nuphus/ 下(与主包同级),也可能被
40
+ // 嵌套在主包的 node_modules/@nuphus/ 下;用 Node 模块解析定位,两种布局都能命中。
41
+ const pkgName = `@nuphus/${spec.pkg}`;
42
+ let vendor;
43
+ try {
44
+ vendor = path.dirname(require.resolve(`${pkgName}/package.json`));
45
+ } catch (_) {
46
+ vendor = path.join(__dirname, '..', '..', pkgName);
47
+ }
48
+ if (!fs.existsSync(vendor)) {
49
+ console.error(`[nuphus] 未找到平台包: ${spec.pkg}`);
50
+ console.error(' 请确认安装完整(npm install -g @nuphus/nuphus-desktop)或重装。');
51
+ process.exit(1);
52
+ }
53
+ return { vendor, spec };
54
+ }
55
+
56
+ function main() {
57
+ const { vendor, spec } = resolveVendorDir();
58
+
59
+ let cmd;
60
+ let args = [];
61
+ if (process.platform === 'darwin') {
62
+ // macOS: open -a Nuphus.app(正确的应用启动方式)
63
+ cmd = 'open';
64
+ args = ['-a', path.join(vendor, spec.app)];
65
+ } else {
66
+ cmd = path.join(vendor, spec.binary);
67
+ }
68
+
69
+ const child = spawn(cmd, args, {
70
+ stdio: 'ignore',
71
+ detached: process.platform !== 'win32',
72
+ });
73
+
74
+ child.on('error', (err) => {
75
+ console.error(`[nuphus] 启动失败: ${err.message}`);
76
+ process.exit(1);
77
+ });
78
+
79
+ child.unref();
80
+ console.log(`[nuphus] 正在启动 Nuphus 桌面应用…`);
81
+ }
82
+
83
+ main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuphus/nuphus-desktop",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Nuphus - 协同共生桌面助手。npm 一键安装:自动选择对应平台二进制(win32-x64 / macOS arm64 / linux-x64)。",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -11,9 +11,9 @@
11
11
  "url": "git+https://github.com/mrpulor-gh/nuphus.git"
12
12
  },
13
13
  "optionalDependencies": {
14
- "@nuphus/nuphus-desktop-osx-arm64": "0.1.3",
15
- "@nuphus/nuphus-desktop-win32-x64": "0.1.3",
16
- "@nuphus/nuphus-desktop-linux-x64": "0.1.3"
14
+ "@nuphus/nuphus-desktop-win32-x64": "0.1.5",
15
+ "@nuphus/nuphus-desktop-osx-arm64": "0.1.5",
16
+ "@nuphus/nuphus-desktop-linux-x64": "0.1.5"
17
17
  },
18
18
  "engines": {
19
19
  "node": "\u003e=16"