@sylphx/cli 0.20.0 → 0.20.1
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/CHANGELOG.md +5 -0
- package/README.md +1 -1
- package/binaries/linux-x64/sylphx +0 -0
- package/lib/get-binary.js +20 -8
- package/package.json +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
## 0.20.1
|
|
2
|
+
|
|
3
|
+
- Vendor native `sylphx` binary inside `@sylphx/cli` under `binaries/<os>-<arch>/` so `npm install -g @sylphx/cli` works without depending on separate platform package registry propagation.
|
|
4
|
+
- Platform optional packages remain secondary install path when available.
|
|
5
|
+
|
|
1
6
|
# Changelog
|
|
2
7
|
|
|
3
8
|
## 0.20.0
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ npm install -g @sylphx/cli
|
|
|
19
19
|
cargo install sylphx-cli
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
Ships a vendored native binary under `binaries/<os>-<arch>/` for supported hosts (linux-x64 first). Optional platform packages (`@sylphx/cli-linux-x64`,
|
|
23
23
|
`@sylphx/cli-darwin-arm64`, …). If the optional native package is missing for
|
|
24
24
|
your OS/arch, install falls back messaging to `cargo install sylphx-cli`.
|
|
25
25
|
|
|
Binary file
|
package/lib/get-binary.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require('node:fs')
|
|
4
4
|
const path = require('node:path')
|
|
5
|
-
const { platformPackageName, knownPlatforms, platformKey } = require('./platform')
|
|
5
|
+
const { platformPackageName, knownPlatforms, platformKey, normalizeArch } = require('./platform')
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Resolve the absolute path to the native `sylphx` binary.
|
|
@@ -10,17 +10,21 @@ const { platformPackageName, knownPlatforms, platformKey } = require('./platform
|
|
|
10
10
|
*
|
|
11
11
|
* Resolution order:
|
|
12
12
|
* 1. SYLPHX_CLI_BINARY env override (absolute path)
|
|
13
|
-
* 2.
|
|
14
|
-
* 3.
|
|
13
|
+
* 2. Vendored binaries shipped inside this package (binaries/<os>-<arch>/sylphx)
|
|
14
|
+
* 3. optionalDependency platform package bin/sylphx(.exe)
|
|
15
|
+
* 4. sibling packages/cli-<platform>/bin (workspace / local pack layout)
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
18
|
function binaryFileName() {
|
|
18
19
|
return process.platform === 'win32' ? 'sylphx.exe' : 'sylphx'
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
function vendorDirName(platform = process.platform, arch = process.arch) {
|
|
23
|
+
return `${platform}-${normalizeArch(arch)}`
|
|
24
|
+
}
|
|
25
|
+
|
|
21
26
|
function tryRequireResolve(pkgName) {
|
|
22
27
|
try {
|
|
23
|
-
// package.json is always resolvable even if exports hide other files
|
|
24
28
|
return require.resolve(`${pkgName}/package.json`)
|
|
25
29
|
} catch {
|
|
26
30
|
return null
|
|
@@ -33,6 +37,12 @@ function pathFromPackageRoot(pkgRoot) {
|
|
|
33
37
|
return null
|
|
34
38
|
}
|
|
35
39
|
|
|
40
|
+
function pathFromVendor() {
|
|
41
|
+
const vendor = path.join(__dirname, '..', 'binaries', vendorDirName(), binaryFileName())
|
|
42
|
+
if (fs.existsSync(vendor)) return vendor
|
|
43
|
+
return null
|
|
44
|
+
}
|
|
45
|
+
|
|
36
46
|
function getBinaryPath() {
|
|
37
47
|
if (process.env.SYLPHX_CLI_BINARY) {
|
|
38
48
|
const override = path.resolve(process.env.SYLPHX_CLI_BINARY)
|
|
@@ -44,6 +54,9 @@ function getBinaryPath() {
|
|
|
44
54
|
return override
|
|
45
55
|
}
|
|
46
56
|
|
|
57
|
+
const vendored = pathFromVendor()
|
|
58
|
+
if (vendored) return vendored
|
|
59
|
+
|
|
47
60
|
const pkgName = platformPackageName()
|
|
48
61
|
if (!pkgName) {
|
|
49
62
|
throw missingBinaryError(
|
|
@@ -57,20 +70,18 @@ function getBinaryPath() {
|
|
|
57
70
|
if (fromOptional) return fromOptional
|
|
58
71
|
}
|
|
59
72
|
|
|
60
|
-
// Workspace / monorepo layout: packages/cli-linux-x64 next to packages/cli
|
|
61
73
|
const localSibling = pathFromPackageRoot(
|
|
62
74
|
path.resolve(__dirname, '..', '..', pkgName.replace('@sylphx/', '')),
|
|
63
75
|
)
|
|
64
76
|
if (localSibling) return localSibling
|
|
65
77
|
|
|
66
|
-
// Nested node_modules of this package (some installers place optionals here)
|
|
67
78
|
const nested = pathFromPackageRoot(
|
|
68
79
|
path.resolve(__dirname, '..', 'node_modules', ...pkgName.split('/')),
|
|
69
80
|
)
|
|
70
81
|
if (nested) return nested
|
|
71
82
|
|
|
72
83
|
throw missingBinaryError(
|
|
73
|
-
`
|
|
84
|
+
`No vendored binary for ${platformKey()} and optional package ${pkgName} is missing.`,
|
|
74
85
|
)
|
|
75
86
|
}
|
|
76
87
|
|
|
@@ -80,7 +91,7 @@ function missingBinaryError(detail) {
|
|
|
80
91
|
detail,
|
|
81
92
|
'',
|
|
82
93
|
'Fix options:',
|
|
83
|
-
' 1) npm install -g @sylphx/cli@
|
|
94
|
+
' 1) npm install -g @sylphx/cli@latest # reinstall npm channel',
|
|
84
95
|
' 2) cargo install sylphx-cli # crates.io SSOT (same binary product)',
|
|
85
96
|
' 3) export SYLPHX_CLI_BINARY=/path/to/sylphx',
|
|
86
97
|
'',
|
|
@@ -94,5 +105,6 @@ function missingBinaryError(detail) {
|
|
|
94
105
|
module.exports = {
|
|
95
106
|
getBinaryPath,
|
|
96
107
|
binaryFileName,
|
|
108
|
+
vendorDirName,
|
|
97
109
|
missingBinaryError,
|
|
98
110
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sylphx/cli",
|
|
3
|
-
"version": "0.20.
|
|
4
|
-
"description": "Sylphx Platform CLI
|
|
3
|
+
"version": "0.20.1",
|
|
4
|
+
"description": "Sylphx Platform CLI \u2014 npm install channel for the Rust `sylphx` binary (same SSOT as crates.io sylphx-cli).",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"homepage": "https://sylphx.com",
|
|
7
7
|
"repository": {
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"main": "lib/index.js",
|
|
21
21
|
"files": [
|
|
22
22
|
"bin",
|
|
23
|
+
"binaries",
|
|
23
24
|
"lib",
|
|
24
25
|
"install.js",
|
|
25
26
|
"README.md",
|
|
@@ -34,11 +35,11 @@
|
|
|
34
35
|
"postinstall": "node ./install.js"
|
|
35
36
|
},
|
|
36
37
|
"optionalDependencies": {
|
|
37
|
-
"@sylphx/cli-linux-x64": "0.20.
|
|
38
|
-
"@sylphx/cli-linux-arm64": "0.20.
|
|
39
|
-
"@sylphx/cli-darwin-x64": "0.20.
|
|
40
|
-
"@sylphx/cli-darwin-arm64": "0.20.
|
|
41
|
-
"@sylphx/cli-win32-x64": "0.20.
|
|
38
|
+
"@sylphx/cli-linux-x64": "0.20.1",
|
|
39
|
+
"@sylphx/cli-linux-arm64": "0.20.1",
|
|
40
|
+
"@sylphx/cli-darwin-x64": "0.20.1",
|
|
41
|
+
"@sylphx/cli-darwin-arm64": "0.20.1",
|
|
42
|
+
"@sylphx/cli-win32-x64": "0.20.1"
|
|
42
43
|
},
|
|
43
44
|
"engines": {
|
|
44
45
|
"node": ">=18"
|