@juniorsir/vessel 1.0.0 → 1.0.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/index.js CHANGED
@@ -1,14 +1,40 @@
1
1
  #!/usr/bin/env node
2
2
  const { spawn } = require('child_process');
3
+ const fs = require('fs');
3
4
  const path = require('path');
4
5
 
5
6
  const binaryPath = path.join(__dirname, 'vessel-native');
6
7
 
7
- // Spawn the native binary and forward standard I/O streams directly
8
+ // 1. Sanity check: Ensure the postinstall script actually succeeded
9
+ if (!fs.existsSync(binaryPath)) {
10
+ console.error(`\x1b[1m\x1b[31m[vessel-npm] Fatal Error: Native core missing.\x1b[0m`);
11
+ console.error(`Could not find the executable at: ${binaryPath}`);
12
+ console.error(`It looks like the install script failed or was skipped by your package manager.`);
13
+ console.error(`Try running: \x1b[1mnpm rebuild @juniorsir/vessel\x1b[0m\n`);
14
+ process.exit(1);
15
+ }
16
+
17
+ // 2. Spawn the Rust binary
18
+ // We pass process.env explicitly to ensure variables like $PREFIX reach the Rust Termux detector
8
19
  const child = spawn(binaryPath, process.argv.slice(2), {
9
- stdio: 'inherit'
20
+ stdio: 'inherit',
21
+ env: process.env
22
+ });
23
+
24
+ // 3. Transparent Signal Forwarding
25
+ // If the user presses Ctrl+C (SIGINT), we must forward it to Rust so it can cleanly detach mounted filesystems
26
+ const SIGNALS = ['SIGINT', 'SIGTERM', 'SIGQUIT'];
27
+ SIGNALS.forEach(signal => {
28
+ process.on(signal, () => {
29
+ child.kill(signal);
30
+ });
31
+ });
32
+
33
+ child.on('error', (err) => {
34
+ console.error(`\x1b[1m\x1b[31m[vessel-npm] Execution failed:\x1b[0m ${err.message}`);
35
+ process.exit(1);
10
36
  });
11
37
 
12
38
  child.on('close', (code) => {
13
- process.exit(code);
39
+ process.exit(code ?? 0);
14
40
  });
package/package.json CHANGED
@@ -1,19 +1,40 @@
1
1
  {
2
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
- },
3
+ "version": "1.0.2",
4
+ "description": "NEXUS: High-performance local containerization engine & zero-latency sandbox",
5
+ "main": "bin/index.js",
9
6
  "bin": {
10
7
  "vessel": "./bin/index.js"
11
8
  },
12
9
  "scripts": {
13
10
  "postinstall": "node ./scripts/install.js"
14
11
  },
15
- "engines": {
16
- "node": ">=14"
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/juniorsir/vessel.git"
17
15
  },
18
- "license": "MIT"
16
+ "keywords": [
17
+ "container",
18
+ "sandbox",
19
+ "docker",
20
+ "termux",
21
+ "linux",
22
+ "namespaces",
23
+ "cgroups",
24
+ "virtualization",
25
+ "rust"
26
+ ],
27
+ "author": "JuniorSir <https://github.com/juniorsir>",
28
+ "license": "MIT",
29
+ "bugs": {
30
+ "url": "https://github.com/juniorsir/vessel/issues"
31
+ },
32
+ "homepage": "https://github.com/juniorsir/vessel#readme",
33
+ "os": [
34
+ "linux",
35
+ "android"
36
+ ],
37
+ "engines": {
38
+ "node": ">=14.0.0"
39
+ }
19
40
  }
@@ -1,16 +1,19 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
  const https = require('https');
4
+ const { execSync } = require('child_process');
4
5
 
5
- const VERSION = 'v1.0.0';
6
+ const VERSION = 'v1.0.2'; // Change this to match your GitHub Release tag!
6
7
  const REPO = 'juniorsir/vessel';
7
8
  const BIN_DIR = path.join(__dirname, '../bin');
8
9
  const BIN_PATH = path.join(BIN_DIR, 'vessel-native');
9
10
 
10
- // Map Node platform/arch to your pre-compiled GitHub release assets
11
+ // Expanded map to catch Termux (android) and Standard Linux (linux)
11
12
  const platforms = {
12
13
  'linux-x64': 'vessel-linux-amd64',
13
- 'linux-arm64': 'vessel-linux-arm64'
14
+ 'linux-arm64': 'vessel-linux-arm64',
15
+ 'android-arm64': 'vessel-linux-arm64', // Termux identifier!
16
+ 'android-x64': 'vessel-linux-amd64' // Android x86 emulators
14
17
  };
15
18
 
16
19
  const key = `${process.platform}-${process.arch}`;
@@ -27,12 +30,12 @@ if (!fs.existsSync(BIN_DIR)) {
27
30
 
28
31
  const url = `https://github.com/${REPO}/releases/download/${VERSION}/${assetName}`;
29
32
 
30
- console.log(`[vessel-npm] Fetching native stripped binary from: ${url}`);
33
+ console.log(`[vessel-npm] Fetching native core for ${key}...`);
31
34
 
32
35
  const file = fs.createWriteStream(BIN_PATH);
33
36
  https.get(url, (response) => {
34
37
  if (response.statusCode === 302 || response.statusCode === 301) {
35
- // Handle GitHub Release redirects
38
+ // Follow GitHub redirect
36
39
  https.get(response.headers.location, (redirectResponse) => {
37
40
  redirectResponse.pipe(file);
38
41
  });
@@ -42,8 +45,14 @@ https.get(url, (response) => {
42
45
 
43
46
  file.on('finish', () => {
44
47
  file.close();
45
- fs.chmodSync(BIN_PATH, 0o755); // Make the binary executable
46
- console.log('[vessel-npm] Native binary installed successfully.');
48
+
49
+ // Explicitly make the binary executable using native shell commands
50
+ try {
51
+ execSync(`chmod +x "${BIN_PATH}"`);
52
+ console.log('[vessel-npm] Native binary installed successfully.');
53
+ } catch (e) {
54
+ console.error('[vessel-npm] Warning: Could not chmod binary natively.');
55
+ }
47
56
  });
48
57
  }).on('error', (err) => {
49
58
  fs.unlink(BIN_PATH, () => {});