electrobun 0.0.19-beta.1 → 0.0.19-beta.12
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/electrobun.cjs +145 -0
- package/package.json +21 -11
- package/src/cli/bun.lockb +0 -0
- package/src/cli/index.ts +1527 -0
- package/src/cli/package-lock.json +93 -0
- package/src/cli/package.json +14 -0
- package/scripts/postinstall.js +0 -165
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "electrobun-cli",
|
|
3
|
+
"lockfileVersion": 3,
|
|
4
|
+
"requires": true,
|
|
5
|
+
"packages": {
|
|
6
|
+
"": {
|
|
7
|
+
"name": "electrobun-cli",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@oneidentity/zstd-js": "^1.0.3",
|
|
10
|
+
"bsdiff-wasm": "^0.1.4",
|
|
11
|
+
"node-tar": "^1.0.0"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@types/bun": "latest"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"typescript": "^5.0.0"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"node_modules/@oneidentity/zstd-js": {
|
|
21
|
+
"version": "1.0.3",
|
|
22
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@types/emscripten": "^1.39.4"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"node_modules/@types/bun": {
|
|
28
|
+
"version": "1.0.10",
|
|
29
|
+
"resolved": "https://registry.npmjs.org/@types/bun/-/bun-1.0.10.tgz",
|
|
30
|
+
"integrity": "sha512-Jaz6YYAdm1u3NVlgSyEK+qGmrlLQ20sbWeEoXD64b9w6z/YKYNWlfaphu+xF2Kiy5Tpykm5Q9jIquLegwXx4ng==",
|
|
31
|
+
"dev": true,
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"bun-types": "1.0.33"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"node_modules/@types/emscripten": {
|
|
37
|
+
"version": "1.39.10",
|
|
38
|
+
"license": "MIT"
|
|
39
|
+
},
|
|
40
|
+
"node_modules/@types/node": {
|
|
41
|
+
"version": "20.11.30",
|
|
42
|
+
"dev": true,
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"undici-types": "~5.26.4"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"node_modules/@types/ws": {
|
|
49
|
+
"version": "8.5.10",
|
|
50
|
+
"dev": true,
|
|
51
|
+
"license": "MIT",
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@types/node": "*"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"node_modules/bsdiff-wasm": {
|
|
57
|
+
"version": "0.1.4",
|
|
58
|
+
"license": "MIT"
|
|
59
|
+
},
|
|
60
|
+
"node_modules/bun-types": {
|
|
61
|
+
"version": "1.0.33",
|
|
62
|
+
"dev": true,
|
|
63
|
+
"license": "MIT",
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"@types/node": "~20.11.3",
|
|
66
|
+
"@types/ws": "~8.5.10"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"node_modules/node-tar": {
|
|
70
|
+
"version": "1.0.0",
|
|
71
|
+
"resolved": "https://registry.npmjs.org/node-tar/-/node-tar-1.0.0.tgz",
|
|
72
|
+
"integrity": "sha512-cowng5lugLQ3Bb5wWYfWM3067/S9xHDwCw3RWbqn0swqmgApDwklyg31XRci97cT7gNbVHmxoXQSkr2zDi5n+g==",
|
|
73
|
+
"deprecated": "please use 'tar'"
|
|
74
|
+
},
|
|
75
|
+
"node_modules/typescript": {
|
|
76
|
+
"version": "5.4.3",
|
|
77
|
+
"license": "Apache-2.0",
|
|
78
|
+
"peer": true,
|
|
79
|
+
"bin": {
|
|
80
|
+
"tsc": "bin/tsc",
|
|
81
|
+
"tsserver": "bin/tsserver"
|
|
82
|
+
},
|
|
83
|
+
"engines": {
|
|
84
|
+
"node": ">=14.17"
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"node_modules/undici-types": {
|
|
88
|
+
"version": "5.26.5",
|
|
89
|
+
"dev": true,
|
|
90
|
+
"license": "MIT"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
package/scripts/postinstall.js
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import https from 'https';
|
|
6
|
-
import { createWriteStream } from 'fs';
|
|
7
|
-
import { pipeline } from 'stream';
|
|
8
|
-
import { promisify } from 'util';
|
|
9
|
-
import tar from 'tar';
|
|
10
|
-
import { execSync } from 'child_process';
|
|
11
|
-
import { fileURLToPath } from 'url';
|
|
12
|
-
|
|
13
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
-
const __dirname = path.dirname(__filename);
|
|
15
|
-
|
|
16
|
-
const pipelineAsync = promisify(pipeline);
|
|
17
|
-
|
|
18
|
-
const REPO = 'blackboardsh/electrobun';
|
|
19
|
-
const DIST_DIR = path.join(__dirname, '..', 'dist');
|
|
20
|
-
|
|
21
|
-
function getPlatform() {
|
|
22
|
-
const platform = process.platform;
|
|
23
|
-
const arch = process.arch;
|
|
24
|
-
|
|
25
|
-
// Map Node.js platform/arch to our naming
|
|
26
|
-
const platformMap = {
|
|
27
|
-
'darwin': 'darwin',
|
|
28
|
-
'linux': 'linux',
|
|
29
|
-
'win32': 'win32'
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const archMap = {
|
|
33
|
-
'x64': 'x64',
|
|
34
|
-
'arm64': 'arm64'
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
platform: platformMap[platform] || platform,
|
|
39
|
-
arch: archMap[arch] || arch
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async function downloadFile(url, dest) {
|
|
44
|
-
return new Promise((resolve, reject) => {
|
|
45
|
-
https.get(url, { headers: { 'User-Agent': 'electrobun-installer' } }, (response) => {
|
|
46
|
-
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
47
|
-
// Follow redirect
|
|
48
|
-
downloadFile(response.headers.location, dest).then(resolve).catch(reject);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (response.statusCode !== 200) {
|
|
53
|
-
reject(new Error(`Failed to download: ${response.statusCode}`));
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const file = createWriteStream(dest);
|
|
58
|
-
response.pipe(file);
|
|
59
|
-
|
|
60
|
-
file.on('finish', () => {
|
|
61
|
-
file.close();
|
|
62
|
-
resolve();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
file.on('error', (err) => {
|
|
66
|
-
fs.unlinkSync(dest);
|
|
67
|
-
reject(err);
|
|
68
|
-
});
|
|
69
|
-
}).on('error', reject);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
async function getLatestRelease() {
|
|
74
|
-
return new Promise((resolve, reject) => {
|
|
75
|
-
const options = {
|
|
76
|
-
hostname: 'api.github.com',
|
|
77
|
-
path: `/repos/${REPO}/releases/latest`,
|
|
78
|
-
headers: {
|
|
79
|
-
'User-Agent': 'electrobun-installer',
|
|
80
|
-
'Accept': 'application/vnd.github.v3+json'
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
https.get(options, (res) => {
|
|
85
|
-
let data = '';
|
|
86
|
-
res.on('data', chunk => data += chunk);
|
|
87
|
-
res.on('end', () => {
|
|
88
|
-
try {
|
|
89
|
-
const release = JSON.parse(data);
|
|
90
|
-
resolve(release.tag_name);
|
|
91
|
-
} catch (err) {
|
|
92
|
-
reject(err);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}).on('error', reject);
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async function main() {
|
|
100
|
-
try {
|
|
101
|
-
// Skip if running in CI or if binaries already exist
|
|
102
|
-
if (process.env.CI || process.env.ELECTROBUN_SKIP_DOWNLOAD) {
|
|
103
|
-
console.log('Skipping binary download');
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Check if dist already exists with binaries
|
|
108
|
-
if (fs.existsSync(path.join(DIST_DIR, 'electrobun'))) {
|
|
109
|
-
console.log('Binaries already exist, skipping download');
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const { platform, arch } = getPlatform();
|
|
114
|
-
const binaryName = `electrobun-${platform}-${arch}`;
|
|
115
|
-
|
|
116
|
-
console.log(`Downloading Electrobun binaries for ${platform}-${arch}...`);
|
|
117
|
-
|
|
118
|
-
// Get the latest release tag
|
|
119
|
-
const version = process.env.ELECTROBUN_VERSION || await getLatestRelease();
|
|
120
|
-
|
|
121
|
-
const downloadUrl = `https://github.com/${REPO}/releases/download/${version}/${binaryName}.tar.gz`;
|
|
122
|
-
const tempFile = path.join(__dirname, `${binaryName}.tar.gz`);
|
|
123
|
-
|
|
124
|
-
// Download the tarball
|
|
125
|
-
console.log(`Downloading from ${downloadUrl}...`);
|
|
126
|
-
await downloadFile(downloadUrl, tempFile);
|
|
127
|
-
|
|
128
|
-
// Create dist directory if it doesn't exist
|
|
129
|
-
if (!fs.existsSync(DIST_DIR)) {
|
|
130
|
-
fs.mkdirSync(DIST_DIR, { recursive: true });
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// Extract the tarball
|
|
134
|
-
console.log('Extracting binaries...');
|
|
135
|
-
await tar.x({
|
|
136
|
-
file: tempFile,
|
|
137
|
-
cwd: DIST_DIR
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
// Clean up
|
|
141
|
-
fs.unlinkSync(tempFile);
|
|
142
|
-
|
|
143
|
-
// Make binaries executable on Unix-like systems
|
|
144
|
-
if (platform !== 'win32') {
|
|
145
|
-
const binaries = ['bun', 'electrobun', 'launcher', 'extractor', 'bsdiff', 'bspatch', 'process_helper'];
|
|
146
|
-
binaries.forEach(bin => {
|
|
147
|
-
const binPath = path.join(DIST_DIR, bin);
|
|
148
|
-
if (fs.existsSync(binPath)) {
|
|
149
|
-
fs.chmodSync(binPath, 0o755);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
console.log('Electrobun installed successfully!');
|
|
155
|
-
|
|
156
|
-
} catch (error) {
|
|
157
|
-
console.error('Failed to download Electrobun binaries:', error.message);
|
|
158
|
-
console.error('You can manually download from: https://github.com/blackboardsh/electrobun/releases');
|
|
159
|
-
// Don't fail the installation
|
|
160
|
-
process.exit(0);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// Run main function
|
|
165
|
-
main();
|