@linebridge/engine-neo 1.0.0 → 1.0.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/install.mjs +73 -0
- package/package.json +4 -1
- package/uws-wrapper.node +0 -0
package/install.mjs
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import fs from "fs"
|
|
2
|
+
import path from "path"
|
|
3
|
+
import os from "os"
|
|
4
|
+
import https from "https"
|
|
5
|
+
import { fileURLToPath } from "url"
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
8
|
+
const __dirname = path.dirname(__filename)
|
|
9
|
+
|
|
10
|
+
const platform = os.platform()
|
|
11
|
+
const arch = os.arch()
|
|
12
|
+
const pkgJson = JSON.parse(
|
|
13
|
+
fs.readFileSync(path.join(__dirname, "package.json"), "utf8"),
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
const REPO = "ragestudio/linebridge"
|
|
17
|
+
const VERSION = process.env.npm_package_version || pkgJson.version
|
|
18
|
+
|
|
19
|
+
const BIN_NAME = `uws-wrapper-${platform}-${arch}.node`
|
|
20
|
+
const DOWNLOAD_URL = `https://github.com/${REPO}/releases/download/engine-neo-v${VERSION}/${BIN_NAME}`
|
|
21
|
+
const DEST_FILE = path.join(__dirname, "uws-wrapper.node")
|
|
22
|
+
|
|
23
|
+
function downloadBinary(url, dest) {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
console.log(`Downloading binary [${url}]`)
|
|
26
|
+
https
|
|
27
|
+
.get(url, (res) => {
|
|
28
|
+
if (res.statusCode === 302 || res.statusCode === 301) {
|
|
29
|
+
return downloadBinary(res.headers.location, dest)
|
|
30
|
+
.then(resolve)
|
|
31
|
+
.catch(reject)
|
|
32
|
+
}
|
|
33
|
+
if (res.statusCode !== 200) {
|
|
34
|
+
return reject(new Error(`status code: ${res.statusCode}`))
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true })
|
|
38
|
+
const file = fs.createWriteStream(dest)
|
|
39
|
+
res.pipe(file)
|
|
40
|
+
|
|
41
|
+
file.on("finish", () => {
|
|
42
|
+
file.close()
|
|
43
|
+
resolve()
|
|
44
|
+
})
|
|
45
|
+
file.on("error", (err) => {
|
|
46
|
+
fs.unlink(dest, () => reject(err))
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
.on("error", reject)
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function main() {
|
|
54
|
+
if (
|
|
55
|
+
fs.existsSync(path.join(__dirname), ".experimental") &&
|
|
56
|
+
!process.argv.includes("--force")
|
|
57
|
+
)
|
|
58
|
+
return
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
console.log("Downloading engine binary...", {
|
|
62
|
+
url: DOWNLOAD_URL,
|
|
63
|
+
dest: DEST_FILE,
|
|
64
|
+
})
|
|
65
|
+
await downloadBinary(DOWNLOAD_URL, DEST_FILE)
|
|
66
|
+
console.log("Successfully downloaded pre-built binary.")
|
|
67
|
+
process.exit(0)
|
|
68
|
+
} catch (err) {
|
|
69
|
+
console.error("❌ Failed to download engine binary:", err.message)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
main()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linebridge/engine-neo",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -28,5 +28,8 @@
|
|
|
28
28
|
"fast-querystring": "^1.1.2",
|
|
29
29
|
"mime-types": "^3.0.2",
|
|
30
30
|
"tseep": "^1.3.1"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"install": "node install.mjs"
|
|
31
34
|
}
|
|
32
35
|
}
|
package/uws-wrapper.node
DELETED
|
Binary file
|