@juniorsir/vessel 1.0.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/bin/index.js +14 -0
- package/package.json +19 -0
- package/scripts/install.js +52 -0
package/bin/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { spawn } = require('child_process');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
const binaryPath = path.join(__dirname, 'vessel-native');
|
|
6
|
+
|
|
7
|
+
// Spawn the native binary and forward standard I/O streams directly
|
|
8
|
+
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
9
|
+
stdio: 'inherit'
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
child.on('close', (code) => {
|
|
13
|
+
process.exit(code);
|
|
14
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@juniorsir/vessel",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "NEXUS: High-performance local containerization engine",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/juniorsir/vessel.git"
|
|
8
|
+
},
|
|
9
|
+
"bin": {
|
|
10
|
+
"vessel": "./bin/index.js"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"postinstall": "node ./scripts/install.js"
|
|
14
|
+
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=14"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT"
|
|
19
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const https = require('https');
|
|
4
|
+
|
|
5
|
+
const VERSION = 'v1.0.0';
|
|
6
|
+
const REPO = 'juniorsir/vessel';
|
|
7
|
+
const BIN_DIR = path.join(__dirname, '../bin');
|
|
8
|
+
const BIN_PATH = path.join(BIN_DIR, 'vessel-native');
|
|
9
|
+
|
|
10
|
+
// Map Node platform/arch to your pre-compiled GitHub release assets
|
|
11
|
+
const platforms = {
|
|
12
|
+
'linux-x64': 'vessel-linux-amd64',
|
|
13
|
+
'linux-arm64': 'vessel-linux-arm64'
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const key = `${process.platform}-${process.arch}`;
|
|
17
|
+
const assetName = platforms[key];
|
|
18
|
+
|
|
19
|
+
if (!assetName) {
|
|
20
|
+
console.error(`[vessel-npm] Unsupported platform/architecture: ${key}`);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!fs.existsSync(BIN_DIR)) {
|
|
25
|
+
fs.mkdirSync(BIN_DIR);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const url = `https://github.com/${REPO}/releases/download/${VERSION}/${assetName}`;
|
|
29
|
+
|
|
30
|
+
console.log(`[vessel-npm] Fetching native stripped binary from: ${url}`);
|
|
31
|
+
|
|
32
|
+
const file = fs.createWriteStream(BIN_PATH);
|
|
33
|
+
https.get(url, (response) => {
|
|
34
|
+
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
35
|
+
// Handle GitHub Release redirects
|
|
36
|
+
https.get(response.headers.location, (redirectResponse) => {
|
|
37
|
+
redirectResponse.pipe(file);
|
|
38
|
+
});
|
|
39
|
+
} else {
|
|
40
|
+
response.pipe(file);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
file.on('finish', () => {
|
|
44
|
+
file.close();
|
|
45
|
+
fs.chmodSync(BIN_PATH, 0o755); // Make the binary executable
|
|
46
|
+
console.log('[vessel-npm] Native binary installed successfully.');
|
|
47
|
+
});
|
|
48
|
+
}).on('error', (err) => {
|
|
49
|
+
fs.unlink(BIN_PATH, () => {});
|
|
50
|
+
console.error(`[vessel-npm] Failed to download binary: ${err.message}`);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
});
|