@sylphx/cli 0.19.3 → 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 +18 -812
- package/README.md +41 -445
- package/bin/run.js +41 -0
- package/binaries/linux-x64/sylphx +0 -0
- package/install.js +37 -0
- package/lib/get-binary.js +110 -0
- package/lib/index.js +12 -0
- package/lib/platform.js +40 -0
- package/package.json +63 -73
- package/dist/main.d.ts +0 -1
- package/dist/main.js +0 -48572
- package/dist/main.js.map +0 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const fs = require('node:fs')
|
|
4
|
+
const path = require('node:path')
|
|
5
|
+
const { platformPackageName, knownPlatforms, platformKey, normalizeArch } = require('./platform')
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Resolve the absolute path to the native `sylphx` binary.
|
|
9
|
+
* Fail closed with actionable install paths when missing.
|
|
10
|
+
*
|
|
11
|
+
* Resolution order:
|
|
12
|
+
* 1. SYLPHX_CLI_BINARY env override (absolute path)
|
|
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)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
function binaryFileName() {
|
|
19
|
+
return process.platform === 'win32' ? 'sylphx.exe' : 'sylphx'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function vendorDirName(platform = process.platform, arch = process.arch) {
|
|
23
|
+
return `${platform}-${normalizeArch(arch)}`
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function tryRequireResolve(pkgName) {
|
|
27
|
+
try {
|
|
28
|
+
return require.resolve(`${pkgName}/package.json`)
|
|
29
|
+
} catch {
|
|
30
|
+
return null
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function pathFromPackageRoot(pkgRoot) {
|
|
35
|
+
const candidate = path.join(pkgRoot, 'bin', binaryFileName())
|
|
36
|
+
if (fs.existsSync(candidate)) return candidate
|
|
37
|
+
return null
|
|
38
|
+
}
|
|
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
|
+
|
|
46
|
+
function getBinaryPath() {
|
|
47
|
+
if (process.env.SYLPHX_CLI_BINARY) {
|
|
48
|
+
const override = path.resolve(process.env.SYLPHX_CLI_BINARY)
|
|
49
|
+
if (!fs.existsSync(override)) {
|
|
50
|
+
throw missingBinaryError(
|
|
51
|
+
`SYLPHX_CLI_BINARY is set to ${override} but that file does not exist.`,
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
return override
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const vendored = pathFromVendor()
|
|
58
|
+
if (vendored) return vendored
|
|
59
|
+
|
|
60
|
+
const pkgName = platformPackageName()
|
|
61
|
+
if (!pkgName) {
|
|
62
|
+
throw missingBinaryError(
|
|
63
|
+
`Unsupported platform: ${platformKey()}. Supported: ${knownPlatforms().join(', ')}.`,
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const pkgJson = tryRequireResolve(pkgName)
|
|
68
|
+
if (pkgJson) {
|
|
69
|
+
const fromOptional = pathFromPackageRoot(path.dirname(pkgJson))
|
|
70
|
+
if (fromOptional) return fromOptional
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const localSibling = pathFromPackageRoot(
|
|
74
|
+
path.resolve(__dirname, '..', '..', pkgName.replace('@sylphx/', '')),
|
|
75
|
+
)
|
|
76
|
+
if (localSibling) return localSibling
|
|
77
|
+
|
|
78
|
+
const nested = pathFromPackageRoot(
|
|
79
|
+
path.resolve(__dirname, '..', 'node_modules', ...pkgName.split('/')),
|
|
80
|
+
)
|
|
81
|
+
if (nested) return nested
|
|
82
|
+
|
|
83
|
+
throw missingBinaryError(
|
|
84
|
+
`No vendored binary for ${platformKey()} and optional package ${pkgName} is missing.`,
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function missingBinaryError(detail) {
|
|
89
|
+
const msg = [
|
|
90
|
+
'Sylphx CLI: native Rust binary not available via npm channel.',
|
|
91
|
+
detail,
|
|
92
|
+
'',
|
|
93
|
+
'Fix options:',
|
|
94
|
+
' 1) npm install -g @sylphx/cli@latest # reinstall npm channel',
|
|
95
|
+
' 2) cargo install sylphx-cli # crates.io SSOT (same binary product)',
|
|
96
|
+
' 3) export SYLPHX_CLI_BINARY=/path/to/sylphx',
|
|
97
|
+
'',
|
|
98
|
+
'This package is an install channel for the Rust `sylphx` binary, not a TypeScript reimplementation.',
|
|
99
|
+
].join('\n')
|
|
100
|
+
const err = new Error(msg)
|
|
101
|
+
err.code = 'SYLPHX_CLI_BINARY_MISSING'
|
|
102
|
+
return err
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
module.exports = {
|
|
106
|
+
getBinaryPath,
|
|
107
|
+
binaryFileName,
|
|
108
|
+
vendorDirName,
|
|
109
|
+
missingBinaryError,
|
|
110
|
+
}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { getBinaryPath, binaryFileName } = require('./get-binary')
|
|
4
|
+
const { platformPackageName, platformKey, knownPlatforms } = require('./platform')
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
getBinaryPath,
|
|
8
|
+
binaryFileName,
|
|
9
|
+
platformPackageName,
|
|
10
|
+
platformKey,
|
|
11
|
+
knownPlatforms,
|
|
12
|
+
}
|
package/lib/platform.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Map host (os, cpu) → optional platform package name.
|
|
5
|
+
* Same pattern as esbuild / @swc / turbo: one meta package + optional native pkgs.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const PLATFORM_PACKAGES = {
|
|
9
|
+
'linux x64': '@sylphx/cli-linux-x64',
|
|
10
|
+
'linux arm64': '@sylphx/cli-linux-arm64',
|
|
11
|
+
'darwin x64': '@sylphx/cli-darwin-x64',
|
|
12
|
+
'darwin arm64': '@sylphx/cli-darwin-arm64',
|
|
13
|
+
'win32 x64': '@sylphx/cli-win32-x64',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function normalizeArch(arch) {
|
|
17
|
+
if (arch === 'x64' || arch === 'amd64') return 'x64'
|
|
18
|
+
if (arch === 'arm64' || arch === 'aarch64') return 'arm64'
|
|
19
|
+
return arch
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function platformKey(platform = process.platform, arch = process.arch) {
|
|
23
|
+
return `${platform} ${normalizeArch(arch)}`
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function platformPackageName(platform = process.platform, arch = process.arch) {
|
|
27
|
+
return PLATFORM_PACKAGES[platformKey(platform, arch)] || null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function knownPlatforms() {
|
|
31
|
+
return Object.keys(PLATFORM_PACKAGES)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = {
|
|
35
|
+
PLATFORM_PACKAGES,
|
|
36
|
+
platformKey,
|
|
37
|
+
platformPackageName,
|
|
38
|
+
knownPlatforms,
|
|
39
|
+
normalizeArch,
|
|
40
|
+
}
|
package/package.json
CHANGED
|
@@ -1,75 +1,65 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
},
|
|
66
|
-
"devDependencies": {
|
|
67
|
-
"@sylphx/contract": "0.23.0",
|
|
68
|
-
"@sylphx/management": "0.15.3",
|
|
69
|
-
"@types/bun": "1.3.14",
|
|
70
|
-
"@types/eventsource": "^1.1.15",
|
|
71
|
-
"@types/node": "^22.0.0",
|
|
72
|
-
"tsup": "^8.3.0",
|
|
73
|
-
"typescript": "^5.9.3"
|
|
74
|
-
}
|
|
2
|
+
"name": "@sylphx/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
|
+
"type": "commonjs",
|
|
6
|
+
"homepage": "https://sylphx.com",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/SylphxAI/platform.git",
|
|
10
|
+
"directory": "packages/cli"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/SylphxAI/platform/issues"
|
|
14
|
+
},
|
|
15
|
+
"author": "Sylphx",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"bin": {
|
|
18
|
+
"sylphx": "bin/run.js"
|
|
19
|
+
},
|
|
20
|
+
"main": "lib/index.js",
|
|
21
|
+
"files": [
|
|
22
|
+
"bin",
|
|
23
|
+
"binaries",
|
|
24
|
+
"lib",
|
|
25
|
+
"install.js",
|
|
26
|
+
"README.md",
|
|
27
|
+
"CHANGELOG.md",
|
|
28
|
+
"LICENSE"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "node ./scripts/verify-package.js",
|
|
32
|
+
"test": "node ./scripts/verify-package.js",
|
|
33
|
+
"typecheck": "node ./scripts/verify-package.js",
|
|
34
|
+
"prepack": "node ./scripts/verify-package.js",
|
|
35
|
+
"postinstall": "node ./install.js"
|
|
36
|
+
},
|
|
37
|
+
"optionalDependencies": {
|
|
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"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=18"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"sylphx",
|
|
49
|
+
"cli",
|
|
50
|
+
"paas",
|
|
51
|
+
"deploy",
|
|
52
|
+
"platform",
|
|
53
|
+
"rust",
|
|
54
|
+
"binary"
|
|
55
|
+
],
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"access": "public"
|
|
58
|
+
},
|
|
59
|
+
"sylphx": {
|
|
60
|
+
"channel": "rust-native",
|
|
61
|
+
"crate": "sylphx-cli",
|
|
62
|
+
"crateVersion": "0.1.1",
|
|
63
|
+
"binaryName": "sylphx"
|
|
64
|
+
}
|
|
75
65
|
}
|
package/dist/main.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|