@lunarisdigitalsolutions/lunapack 0.0.1 → 0.2.0
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/package.json +20 -10
- package/run-luna.mjs +62 -0
package/package.json
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@lunarisdigitalsolutions/lunapack",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@lunarisdigitalsolutions/lunapack",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Luna CLI.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"luna": "run-luna.mjs"
|
|
7
|
+
},
|
|
8
|
+
"optionalDependencies": {
|
|
9
|
+
"@lunarisdigitalsolutions/lunapack-win64": "0.2.0",
|
|
10
|
+
"@lunarisdigitalsolutions/lunapack-linux-x64": "0.2.0",
|
|
11
|
+
"@lunarisdigitalsolutions/lunapack-linux-arm64": "0.2.0",
|
|
12
|
+
"@lunarisdigitalsolutions/lunapack-macos-x64": "0.2.0",
|
|
13
|
+
"@lunarisdigitalsolutions/lunapack-macos-arm64": "0.2.0"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"run-luna.mjs"
|
|
17
|
+
],
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"repository": "github:lunarisdigitalsolutions/lunapack"
|
|
20
|
+
}
|
package/run-luna.mjs
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync } from 'node:child_process'
|
|
3
|
+
import { existsSync } from 'node:fs'
|
|
4
|
+
import { createRequire } from 'node:module'
|
|
5
|
+
import { dirname, join } from 'node:path'
|
|
6
|
+
|
|
7
|
+
const require = createRequire(import.meta.url)
|
|
8
|
+
const targets = {
|
|
9
|
+
'win32-x64': ['@lunarisdigitalsolutions/lunapack-win64', 'luna.exe'],
|
|
10
|
+
'linux-x64': ['@lunarisdigitalsolutions/lunapack-linux-x64', 'luna'],
|
|
11
|
+
'linux-arm64': ['@lunarisdigitalsolutions/lunapack-linux-arm64', 'luna'],
|
|
12
|
+
'darwin-x64': ['@lunarisdigitalsolutions/lunapack-macos-x64', 'luna'],
|
|
13
|
+
'darwin-arm64': ['@lunarisdigitalsolutions/lunapack-macos-arm64', 'luna']
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function resolveBinary(
|
|
17
|
+
platform,
|
|
18
|
+
architecture,
|
|
19
|
+
resolvePackage = require.resolve
|
|
20
|
+
) {
|
|
21
|
+
const target = targets[`${platform}-${architecture}`]
|
|
22
|
+
if (!target) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
`Unsupported Luna platform ${platform}-${architecture}. Supported targets: ${Object.keys(targets).join(', ')}.`
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const [packageName, binaryName] = target
|
|
29
|
+
let packageJson
|
|
30
|
+
try {
|
|
31
|
+
packageJson = resolvePackage(`${packageName}/package.json`)
|
|
32
|
+
} catch {
|
|
33
|
+
throw new Error(
|
|
34
|
+
`Missing ${packageName}. Reinstall @lunarisdigitalsolutions/lunapack with optional dependencies enabled.`
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const binary = join(dirname(packageJson), binaryName)
|
|
39
|
+
if (!existsSync(binary)) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
`Missing Luna binary in ${packageName}. Reinstall @lunarisdigitalsolutions/lunapack.`
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return binary
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (process.argv[1] === import.meta.filename) {
|
|
49
|
+
try {
|
|
50
|
+
const binary = resolveBinary(process.platform, process.arch)
|
|
51
|
+
const result = spawnSync(binary, process.argv.slice(2), {
|
|
52
|
+
stdio: 'inherit'
|
|
53
|
+
})
|
|
54
|
+
if (result.error) {
|
|
55
|
+
throw result.error
|
|
56
|
+
}
|
|
57
|
+
process.exitCode = result.status ?? 1
|
|
58
|
+
} catch (error) {
|
|
59
|
+
process.stderr.write(`luna: ${error.message}\n`)
|
|
60
|
+
process.exitCode = 1
|
|
61
|
+
}
|
|
62
|
+
}
|