orez-sync-native 0.0.0-bootstrap.0 → 0.1.2
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/bin/sync-native.cjs +91 -0
- package/package.json +23 -3
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
const { createRequire } = require('node:module')
|
|
5
|
+
const { spawn } = require('node:child_process')
|
|
6
|
+
|
|
7
|
+
const PACKAGES = {
|
|
8
|
+
'darwin-arm64': {
|
|
9
|
+
packageName: 'orez-sync-native-darwin-arm64',
|
|
10
|
+
binary: 'orez-sync-native-darwin-arm64/bin/sync-native',
|
|
11
|
+
},
|
|
12
|
+
'darwin-x64': {
|
|
13
|
+
packageName: 'orez-sync-native-darwin-x64',
|
|
14
|
+
binary: 'orez-sync-native-darwin-x64/bin/sync-native',
|
|
15
|
+
},
|
|
16
|
+
'linux-arm64-glibc': {
|
|
17
|
+
packageName: 'orez-sync-native-linux-arm64-gnu',
|
|
18
|
+
binary: 'orez-sync-native-linux-arm64-gnu/bin/sync-native',
|
|
19
|
+
},
|
|
20
|
+
'linux-arm64-musl': {
|
|
21
|
+
packageName: 'orez-sync-native-linux-arm64-musl',
|
|
22
|
+
binary: 'orez-sync-native-linux-arm64-musl/bin/sync-native',
|
|
23
|
+
},
|
|
24
|
+
'linux-x64-glibc': {
|
|
25
|
+
packageName: 'orez-sync-native-linux-x64-gnu',
|
|
26
|
+
binary: 'orez-sync-native-linux-x64-gnu/bin/sync-native',
|
|
27
|
+
},
|
|
28
|
+
'linux-x64-musl': {
|
|
29
|
+
packageName: 'orez-sync-native-linux-x64-musl',
|
|
30
|
+
binary: 'orez-sync-native-linux-x64-musl/bin/sync-native',
|
|
31
|
+
},
|
|
32
|
+
'win32-arm64': {
|
|
33
|
+
packageName: 'orez-sync-native-win32-arm64',
|
|
34
|
+
binary: 'orez-sync-native-win32-arm64/bin/sync-native.exe',
|
|
35
|
+
},
|
|
36
|
+
'win32-x64': {
|
|
37
|
+
packageName: 'orez-sync-native-win32-x64',
|
|
38
|
+
binary: 'orez-sync-native-win32-x64/bin/sync-native.exe',
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const libc =
|
|
43
|
+
process.platform === 'linux'
|
|
44
|
+
? process.report?.getReport().header.glibcVersionRuntime
|
|
45
|
+
? 'glibc'
|
|
46
|
+
: 'musl'
|
|
47
|
+
: undefined
|
|
48
|
+
const key = [process.platform, process.arch, libc].filter(Boolean).join('-')
|
|
49
|
+
const selected = PACKAGES[key]
|
|
50
|
+
|
|
51
|
+
if (!selected) {
|
|
52
|
+
console.error(`sync-native does not support ${key}`)
|
|
53
|
+
process.exit(1)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const load = createRequire(__filename)
|
|
57
|
+
let binary
|
|
58
|
+
try {
|
|
59
|
+
const launcherVersion = load('../package.json').version
|
|
60
|
+
const platformVersion = load(`${selected.packageName}/package.json`).version
|
|
61
|
+
if (platformVersion !== launcherVersion) {
|
|
62
|
+
console.error(
|
|
63
|
+
`sync-native binary package for ${key} is ${platformVersion}, expected ${launcherVersion}. ` +
|
|
64
|
+
'Reinstall orez-sync-native so its optional dependencies match.'
|
|
65
|
+
)
|
|
66
|
+
process.exit(1)
|
|
67
|
+
}
|
|
68
|
+
binary = load.resolve(selected.binary)
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.error(
|
|
71
|
+
`sync-native binary package for ${key} is missing. ` +
|
|
72
|
+
'Reinstall orez-sync-native without omitting optional dependencies.'
|
|
73
|
+
)
|
|
74
|
+
process.exit(1)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const child = spawn(binary, process.argv.slice(2), { stdio: 'inherit' })
|
|
78
|
+
for (const signal of ['SIGINT', 'SIGTERM']) {
|
|
79
|
+
process.on(signal, () => child.kill(signal))
|
|
80
|
+
}
|
|
81
|
+
child.on('error', (error) => {
|
|
82
|
+
throw error
|
|
83
|
+
})
|
|
84
|
+
child.on('exit', (code, signal) => {
|
|
85
|
+
if (!signal) {
|
|
86
|
+
process.exitCode = code ?? 1
|
|
87
|
+
return
|
|
88
|
+
}
|
|
89
|
+
process.removeAllListeners(signal)
|
|
90
|
+
process.kill(process.pid, signal)
|
|
91
|
+
})
|
package/package.json
CHANGED
|
@@ -1,13 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orez-sync-native",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Prebuilt generic Orez sync host for application-owned callbacks
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Prebuilt generic Orez sync host for application-owned callbacks",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/natew/orez.git"
|
|
9
9
|
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"sync-native": "bin/sync-native.cjs"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
"./launcher": "./bin/sync-native.cjs"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"bin"
|
|
18
|
+
],
|
|
19
|
+
"optionalDependencies": {
|
|
20
|
+
"orez-sync-native-darwin-arm64": "0.1.2",
|
|
21
|
+
"orez-sync-native-darwin-x64": "0.1.2",
|
|
22
|
+
"orez-sync-native-linux-arm64-gnu": "0.1.2",
|
|
23
|
+
"orez-sync-native-linux-arm64-musl": "0.1.2",
|
|
24
|
+
"orez-sync-native-linux-x64-gnu": "0.1.2",
|
|
25
|
+
"orez-sync-native-linux-x64-musl": "0.1.2",
|
|
26
|
+
"orez-sync-native-win32-arm64": "0.1.2",
|
|
27
|
+
"orez-sync-native-win32-x64": "0.1.2"
|
|
28
|
+
},
|
|
10
29
|
"publishConfig": {
|
|
11
30
|
"access": "public"
|
|
12
|
-
}
|
|
31
|
+
},
|
|
32
|
+
"orezSourceCommit": "68d1ba3121d27c1f0408cfa637d5a2fce718d30b"
|
|
13
33
|
}
|