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,145 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execSync, spawn } = require('child_process');
|
|
4
|
+
const { existsSync, mkdirSync, createWriteStream, unlinkSync, chmodSync } = require('fs');
|
|
5
|
+
const { join, dirname } = require('path');
|
|
6
|
+
const https = require('https');
|
|
7
|
+
const tar = require('tar');
|
|
8
|
+
|
|
9
|
+
// Detect platform and architecture
|
|
10
|
+
function getPlatform() {
|
|
11
|
+
switch (process.platform) {
|
|
12
|
+
case 'win32': return 'win';
|
|
13
|
+
case 'darwin': return 'darwin';
|
|
14
|
+
case 'linux': return 'linux';
|
|
15
|
+
default: throw new Error(`Unsupported platform: ${process.platform}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getArch() {
|
|
20
|
+
switch (process.arch) {
|
|
21
|
+
case 'arm64': return 'arm64';
|
|
22
|
+
case 'x64': return 'x64';
|
|
23
|
+
default: throw new Error(`Unsupported architecture: ${process.arch}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const platform = getPlatform();
|
|
28
|
+
const arch = getArch();
|
|
29
|
+
const binExt = platform === 'win' ? '.exe' : '';
|
|
30
|
+
|
|
31
|
+
// Paths
|
|
32
|
+
const electrobunDir = join(__dirname, '..');
|
|
33
|
+
const cacheDir = join(electrobunDir, '.cache');
|
|
34
|
+
const cliBinary = join(cacheDir, `electrobun${binExt}`);
|
|
35
|
+
|
|
36
|
+
async function downloadFile(url, filePath) {
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
mkdirSync(dirname(filePath), { recursive: true });
|
|
39
|
+
const file = createWriteStream(filePath);
|
|
40
|
+
|
|
41
|
+
https.get(url, (response) => {
|
|
42
|
+
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
43
|
+
// Follow redirect
|
|
44
|
+
return downloadFile(response.headers.location, filePath).then(resolve).catch(reject);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (response.statusCode !== 200) {
|
|
48
|
+
reject(new Error(`Download failed: ${response.statusCode}`));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
response.pipe(file);
|
|
53
|
+
|
|
54
|
+
file.on('finish', () => {
|
|
55
|
+
file.close();
|
|
56
|
+
resolve();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
file.on('error', reject);
|
|
60
|
+
}).on('error', reject);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function ensureCliBinary() {
|
|
65
|
+
if (existsSync(cliBinary)) {
|
|
66
|
+
return cliBinary;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
console.log('Downloading electrobun CLI for your platform...');
|
|
70
|
+
|
|
71
|
+
// Get the package version to download the matching release
|
|
72
|
+
const packageJson = require(join(electrobunDir, 'package.json'));
|
|
73
|
+
const version = packageJson.version;
|
|
74
|
+
const tag = `v${version}`;
|
|
75
|
+
|
|
76
|
+
const tarballUrl = `https://github.com/blackboardsh/electrobun/releases/download/${tag}/electrobun-cli-${platform}-${arch}.tar.gz`;
|
|
77
|
+
const tarballPath = join(cacheDir, `electrobun-${platform}-${arch}.tar.gz`);
|
|
78
|
+
|
|
79
|
+
try {
|
|
80
|
+
// Download tarball
|
|
81
|
+
await downloadFile(tarballUrl, tarballPath);
|
|
82
|
+
|
|
83
|
+
// Extract CLI binary
|
|
84
|
+
await tar.x({
|
|
85
|
+
file: tarballPath,
|
|
86
|
+
cwd: cacheDir
|
|
87
|
+
// No strip needed - CLI tarball contains just the binary
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// Clean up tarball
|
|
91
|
+
unlinkSync(tarballPath);
|
|
92
|
+
|
|
93
|
+
// Check if CLI binary was extracted
|
|
94
|
+
if (!existsSync(cliBinary)) {
|
|
95
|
+
throw new Error(`CLI binary not found at ${cliBinary} after extraction`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Make executable on Unix systems
|
|
99
|
+
if (platform !== 'win') {
|
|
100
|
+
chmodSync(cliBinary, '755');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
console.log('electrobun CLI downloaded successfully!');
|
|
104
|
+
return cliBinary;
|
|
105
|
+
|
|
106
|
+
} catch (error) {
|
|
107
|
+
throw new Error(`Failed to download electrobun CLI: ${error.message}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function main() {
|
|
112
|
+
try {
|
|
113
|
+
const args = process.argv.slice(2);
|
|
114
|
+
|
|
115
|
+
// Handle postinstall flag - just download CLI and exit
|
|
116
|
+
if (args.includes('--install-only')) {
|
|
117
|
+
await ensureCliBinary();
|
|
118
|
+
console.log('electrobun CLI installed successfully!');
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const cliPath = await ensureCliBinary();
|
|
123
|
+
|
|
124
|
+
// Replace this process with the actual CLI
|
|
125
|
+
const child = spawn(cliPath, args, {
|
|
126
|
+
stdio: 'inherit',
|
|
127
|
+
cwd: process.cwd()
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
child.on('exit', (code) => {
|
|
131
|
+
process.exit(code || 0);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
child.on('error', (error) => {
|
|
135
|
+
console.error('Failed to start electrobun CLI:', error.message);
|
|
136
|
+
process.exit(1);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
} catch (error) {
|
|
140
|
+
console.error('Error:', error.message);
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
main();
|
package/package.json
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "electrobun",
|
|
3
|
-
"version": "0.0.19-beta.
|
|
3
|
+
"version": "0.0.19-beta.12",
|
|
4
4
|
"description": "Build ultra fast, tiny, and cross-platform desktop apps with Typescript.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Blackboard Technologies Inc.",
|
|
7
|
-
"keywords": [
|
|
7
|
+
"keywords": [
|
|
8
|
+
"bun",
|
|
9
|
+
"desktop",
|
|
10
|
+
"app",
|
|
11
|
+
"cross-platform",
|
|
12
|
+
"typescript"
|
|
13
|
+
],
|
|
8
14
|
"exports": {
|
|
9
15
|
".": "./dist/api/bun/index.ts",
|
|
10
16
|
"./bun": "./dist/api/bun/index.ts",
|
|
@@ -12,7 +18,7 @@
|
|
|
12
18
|
},
|
|
13
19
|
"type": "module",
|
|
14
20
|
"bin": {
|
|
15
|
-
"electrobun": "
|
|
21
|
+
"electrobun": "./bin/electrobun"
|
|
16
22
|
},
|
|
17
23
|
"homepage": "https://electrobun.dev",
|
|
18
24
|
"repository": {
|
|
@@ -20,12 +26,13 @@
|
|
|
20
26
|
"url": "git+https://github.com/blackboardsh/electrobun.git"
|
|
21
27
|
},
|
|
22
28
|
"scripts": {
|
|
23
|
-
"postinstall": "node
|
|
29
|
+
"postinstall": "node bin/electrobun.cjs --install-only",
|
|
30
|
+
"build:cli": "mkdir -p bin && bun build src/cli/index.ts --compile --outfile bin/electrobun",
|
|
24
31
|
"start": "bun src/bun/index.ts",
|
|
25
32
|
"check-zig-version": "vendors/zig/zig version",
|
|
26
33
|
"build:dev": "bun build.ts",
|
|
27
34
|
"build:release": "bun build.ts --release",
|
|
28
|
-
"dev:playground": "bun build:dev && cd playground && npm install && bun build:dev && bun start",
|
|
35
|
+
"dev:playground": "bun build:dev && bun build:cli && cd playground && npm install && bun build:dev && bun start",
|
|
29
36
|
"dev:playground:linux": "bun build:dev && npm link && cd playground && npm link electrobun && bun build:dev && bun start",
|
|
30
37
|
"dev:playground:clean": "cd playground && rm -rf node_modules && npm install && cd .. && bun dev:playground",
|
|
31
38
|
"dev:playground:rerun": "cd playground && bun start",
|
|
@@ -34,14 +41,17 @@
|
|
|
34
41
|
"build:docs:release": "cd documentation && bun run build",
|
|
35
42
|
"npm:publish": "bun build:release && npm publish",
|
|
36
43
|
"npm:publish:beta": "bun build:release && npm publish --tag beta",
|
|
37
|
-
"npm:version:beta": "npm version prerelease --preid=beta"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
44
|
+
"npm:version:beta": "npm version prerelease --preid=beta",
|
|
45
|
+
"push:beta": "bun npm:version:beta && git push origin main --tags",
|
|
46
|
+
"push:patch": "npm version patch && git push origin main --tags",
|
|
47
|
+
"push:minor": "npm version minor && git push origin main --tags",
|
|
48
|
+
"push:major": "npm version major && git push origin main --tags"
|
|
41
49
|
},
|
|
42
50
|
"dependencies": {
|
|
43
51
|
"@oneidentity/zstd-js": "^1.0.3",
|
|
44
|
-
"
|
|
52
|
+
"@types/bun": "1.1.9",
|
|
53
|
+
"bun": "1.1.9",
|
|
54
|
+
"rpc-anywhere": "1.5.0",
|
|
45
55
|
"tar": "^6.2.1"
|
|
46
56
|
}
|
|
47
|
-
}
|
|
57
|
+
}
|
|
Binary file
|