bun 0.0.12 → 0.5.1-canary
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/README.md +20 -93
- package/bin/bun +392 -0
- package/install.js +410 -0
- package/package.json +34 -23
- package/.npmignore +0 -1
- package/.travis.yml +0 -6
- package/example.js +0 -27
- package/lib/bun.js +0 -92
- package/test/bun_test.js +0 -447
package/README.md
CHANGED
|
@@ -1,104 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
===
|
|
1
|
+
# Bun
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
in a bun! **bun** wraps a series of streams into a single
|
|
6
|
-
`stream.Duplex`-compliant unit.
|
|
3
|
+
Bun is a fast all-in-one JavaScript runtime. https://bun.sh
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
------------------------------
|
|
5
|
+
### Install
|
|
10
6
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
```js
|
|
14
|
-
// my-transport.js
|
|
15
|
-
encryptor.pipe(compressor).pipe(socket).pipe(decompressor).pipe(decryptor);
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
Totally believable, right? Now each time someone wants to use your module, you
|
|
19
|
-
have to do something like this
|
|
20
|
-
|
|
21
|
-
```js
|
|
22
|
-
// too much work!
|
|
23
|
-
client.pipe(encryptor)
|
|
24
|
-
.pipe(compressor)
|
|
25
|
-
.pipe(socket)
|
|
26
|
-
.pipe(decompressor)
|
|
27
|
-
.pipe(decryptor)
|
|
28
|
-
.pipe(client);
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
Gross! Puke! This is horribly inconvenient and ugly for the end user! Let's look
|
|
32
|
-
at a **better solution**
|
|
33
|
-
|
|
34
|
-
```js
|
|
35
|
-
// defined in my-transport.js
|
|
36
|
-
var bun = require("bun");
|
|
37
|
-
module.service = function(socket) {
|
|
38
|
-
return bun([encryptor, compressor, socket, decompressor, decryptor]);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// used in client
|
|
42
|
-
var transport = require("./my-transport");
|
|
43
|
-
client.pipe(transport.service(socket)).pipe(client);
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Hot cross buns! **bun** is amazing!
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
Example
|
|
50
|
-
-------
|
|
51
|
-
|
|
52
|
-
```js
|
|
53
|
-
var stream = require("stream"),
|
|
54
|
-
bun = require("bun");
|
|
55
|
-
|
|
56
|
-
// stream generator
|
|
57
|
-
var createStream = function createStream(id) {
|
|
58
|
-
var s = new stream.Transform({encoding: "utf8"});
|
|
59
|
-
s._transform = function _transform(str, encoding, done) {
|
|
60
|
-
this.push("(" + id + " " + str + ")");
|
|
61
|
-
done();
|
|
62
|
-
};
|
|
63
|
-
return s;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
// create some streams
|
|
67
|
-
var streams = ["G", "O", "D"].map(function(id) {
|
|
68
|
-
return createStream(id);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
// wrap the streams in a bun!
|
|
72
|
-
var hotdog = bun(streams);
|
|
73
|
-
|
|
74
|
-
// connect hotdog to stdout
|
|
75
|
-
hotdog.pipe(process.stdout);
|
|
76
|
-
|
|
77
|
-
// use the hotdog
|
|
78
|
-
hotdog.write("in a bun"); // (D (O (G in a bun)))
|
|
7
|
+
```sh
|
|
8
|
+
npm install -g bun
|
|
79
9
|
```
|
|
80
10
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
API
|
|
85
|
-
---
|
|
11
|
+
### Upgrade
|
|
86
12
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
```js
|
|
90
|
-
var service = bun(streams, [options]);
|
|
13
|
+
```sh
|
|
14
|
+
bun upgrade
|
|
91
15
|
```
|
|
92
16
|
|
|
93
|
-
|
|
94
|
-
* _options_ - An object specifying options. (options are optional)
|
|
95
|
-
|
|
96
|
-
Options:
|
|
17
|
+
### Supported Platforms
|
|
97
18
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
19
|
+
- [macOS, arm64 (Apple Silicon)](https://www.npmjs.com/package/@oven/bun-darwin-aarch64)
|
|
20
|
+
- [macOS, x64](<(https://www.npmjs.com/package/@oven/bun-darwin-x64)>)
|
|
21
|
+
- [macOS, x64 (without AVX2 instructions)](https://www.npmjs.com/package/@oven/bun-darwin-x64-baseline)
|
|
22
|
+
- [Linux, arm64](https://www.npmjs.com/package/@oven/bun-linux-aarch64)
|
|
23
|
+
- [Linux, x64](https://www.npmjs.com/package/@oven/bun-linux-x64)
|
|
24
|
+
- [Linux, x64 (without AVX2 instructions)](https://www.npmjs.com/package/@oven/bun-linux-x64-baseline)
|
|
25
|
+
- [Windows (using Windows Subsystem for Linux, aka. "WSL")](https://relatablecode.com/how-to-set-up-bun-on-a-windows-machine)
|
|
101
26
|
|
|
102
|
-
|
|
27
|
+
### Future Platforms
|
|
103
28
|
|
|
104
|
-
[
|
|
29
|
+
- [Windows](https://github.com/oven-sh/bun/issues/43)
|
|
30
|
+
- Unix-like variants such as FreeBSD, OpenBSD, etc.
|
|
31
|
+
- Android and iOS
|
package/bin/bun
ADDED
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty, __defProps = Object.defineProperties, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropDescs = Object.getOwnPropertyDescriptors, __getOwnPropNames = Object.getOwnPropertyNames, __getOwnPropSymbols = Object.getOwnPropertySymbols, __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty, __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues = (a, b) => {
|
|
6
|
+
for (var prop in b || (b = {}))
|
|
7
|
+
__hasOwnProp.call(b, prop) && __defNormalProp(a, prop, b[prop]);
|
|
8
|
+
if (__getOwnPropSymbols)
|
|
9
|
+
for (var prop of __getOwnPropSymbols(b))
|
|
10
|
+
__propIsEnum.call(b, prop) && __defNormalProp(a, prop, b[prop]);
|
|
11
|
+
return a;
|
|
12
|
+
}, __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)), __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __async = (__this, __arguments, generator) => new Promise((resolve, reject) => {
|
|
28
|
+
var fulfilled = (value) => {
|
|
29
|
+
try {
|
|
30
|
+
step(generator.next(value));
|
|
31
|
+
} catch (e) {
|
|
32
|
+
reject(e);
|
|
33
|
+
}
|
|
34
|
+
}, rejected = (value) => {
|
|
35
|
+
try {
|
|
36
|
+
step(generator.throw(value));
|
|
37
|
+
} catch (e) {
|
|
38
|
+
reject(e);
|
|
39
|
+
}
|
|
40
|
+
}, step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
41
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// src/util.ts
|
|
45
|
+
var import_fs = __toESM(require("fs")), import_path = __toESM(require("path")), import_os = require("os"), import_child_process = __toESM(require("child_process"));
|
|
46
|
+
process.env.DEBUG !== "1" && (console.debug = () => {
|
|
47
|
+
});
|
|
48
|
+
function join(...paths) {
|
|
49
|
+
return import_path.default.join(...paths.flat(2));
|
|
50
|
+
}
|
|
51
|
+
__name(join, "join");
|
|
52
|
+
function tmp() {
|
|
53
|
+
let path2 = import_fs.default.mkdtempSync(join((0, import_os.tmpdir)(), "bun-"));
|
|
54
|
+
return path2;
|
|
55
|
+
}
|
|
56
|
+
__name(tmp, "tmp");
|
|
57
|
+
function rm(path2) {
|
|
58
|
+
try {
|
|
59
|
+
import_fs.default.rmSync(path2, { recursive: !0 });
|
|
60
|
+
return;
|
|
61
|
+
} catch (error) {
|
|
62
|
+
}
|
|
63
|
+
let stats;
|
|
64
|
+
try {
|
|
65
|
+
stats = import_fs.default.lstatSync(path2);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (!stats.isDirectory()) {
|
|
70
|
+
import_fs.default.unlinkSync(path2);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
import_fs.default.rmdirSync(path2, { recursive: !0 });
|
|
75
|
+
return;
|
|
76
|
+
} catch (error) {
|
|
77
|
+
}
|
|
78
|
+
for (let filename of import_fs.default.readdirSync(path2))
|
|
79
|
+
rm(join(path2, filename));
|
|
80
|
+
import_fs.default.rmdirSync(path2);
|
|
81
|
+
}
|
|
82
|
+
__name(rm, "rm");
|
|
83
|
+
function rename(path2, newPath) {
|
|
84
|
+
try {
|
|
85
|
+
import_fs.default.renameSync(path2, newPath);
|
|
86
|
+
return;
|
|
87
|
+
} catch (error) {
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
rm(newPath);
|
|
91
|
+
} catch (error) {
|
|
92
|
+
}
|
|
93
|
+
import_fs.default.renameSync(path2, newPath);
|
|
94
|
+
}
|
|
95
|
+
__name(rename, "rename");
|
|
96
|
+
function write(path2, content) {
|
|
97
|
+
try {
|
|
98
|
+
import_fs.default.writeFileSync(path2, content);
|
|
99
|
+
return;
|
|
100
|
+
} catch (error) {
|
|
101
|
+
try {
|
|
102
|
+
import_fs.default.mkdirSync((0, import_path.dirname)(path2), { recursive: !0 });
|
|
103
|
+
} catch (error2) {
|
|
104
|
+
}
|
|
105
|
+
import_fs.default.writeFileSync(path2, content);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
__name(write, "write");
|
|
109
|
+
function read(path2) {
|
|
110
|
+
return import_fs.default.readFileSync(path2, "utf-8");
|
|
111
|
+
}
|
|
112
|
+
__name(read, "read");
|
|
113
|
+
function chmod(path2, mode) {
|
|
114
|
+
import_fs.default.chmodSync(path2, mode);
|
|
115
|
+
}
|
|
116
|
+
__name(chmod, "chmod");
|
|
117
|
+
function spawn(cmd, args, options = {}) {
|
|
118
|
+
[cmd, ...args].join(" ");
|
|
119
|
+
let { status, stdout, stderr } = import_child_process.default.spawnSync(cmd, args, __spreadValues({
|
|
120
|
+
stdio: "pipe",
|
|
121
|
+
encoding: "utf-8"
|
|
122
|
+
}, options));
|
|
123
|
+
return {
|
|
124
|
+
exitCode: status != null ? status : 1,
|
|
125
|
+
stdout,
|
|
126
|
+
stderr
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
__name(spawn, "spawn");
|
|
130
|
+
var fetch = "fetch" in globalThis ? webFetch : nodeFetch;
|
|
131
|
+
function webFetch(url, assert) {
|
|
132
|
+
return __async(this, null, function* () {
|
|
133
|
+
let response = yield globalThis.fetch(url);
|
|
134
|
+
if (response.status, assert !== !1 && !isOk(response.status))
|
|
135
|
+
throw new Error(`${response.status}: ${url}`);
|
|
136
|
+
return response;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
__name(webFetch, "webFetch");
|
|
140
|
+
function nodeFetch(url, assert) {
|
|
141
|
+
return __async(this, null, function* () {
|
|
142
|
+
let { get } = yield import("http");
|
|
143
|
+
return new Promise((resolve, reject) => {
|
|
144
|
+
get(url, (response) => {
|
|
145
|
+
var _a;
|
|
146
|
+
response.statusCode;
|
|
147
|
+
let status = (_a = response.statusCode) != null ? _a : 501;
|
|
148
|
+
if (response.headers.location && isRedirect(status))
|
|
149
|
+
return nodeFetch(url).then(resolve, reject);
|
|
150
|
+
if (assert !== !1 && !isOk(status))
|
|
151
|
+
return reject(new Error(`${status}: ${url}`));
|
|
152
|
+
let body = [];
|
|
153
|
+
response.on("data", (chunk) => {
|
|
154
|
+
body.push(chunk);
|
|
155
|
+
}), response.on("end", () => {
|
|
156
|
+
resolve({
|
|
157
|
+
status,
|
|
158
|
+
arrayBuffer() {
|
|
159
|
+
return __async(this, null, function* () {
|
|
160
|
+
return Buffer.concat(body).buffer;
|
|
161
|
+
});
|
|
162
|
+
},
|
|
163
|
+
json() {
|
|
164
|
+
return __async(this, null, function* () {
|
|
165
|
+
let text = Buffer.concat(body).toString("utf-8");
|
|
166
|
+
return JSON.parse(text);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
}).on("error", reject);
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
__name(nodeFetch, "nodeFetch");
|
|
176
|
+
function isOk(status) {
|
|
177
|
+
return status === 200;
|
|
178
|
+
}
|
|
179
|
+
__name(isOk, "isOk");
|
|
180
|
+
function isRedirect(status) {
|
|
181
|
+
switch (status) {
|
|
182
|
+
case 301:
|
|
183
|
+
case 308:
|
|
184
|
+
case 302:
|
|
185
|
+
case 307:
|
|
186
|
+
case 303:
|
|
187
|
+
return !0;
|
|
188
|
+
}
|
|
189
|
+
return !1;
|
|
190
|
+
}
|
|
191
|
+
__name(isRedirect, "isRedirect");
|
|
192
|
+
|
|
193
|
+
// src/install.ts
|
|
194
|
+
var import_zlib = require("zlib");
|
|
195
|
+
|
|
196
|
+
// src/platform.ts
|
|
197
|
+
var os = process.platform, arch = os === "darwin" && process.arch === "x64" && isRosetta2() ? "arm64" : process.arch, avx2 = arch === "x64" && os === "linux" && isLinuxAVX2() || os === "darwin" && isDarwinAVX2(), platforms = [
|
|
198
|
+
{
|
|
199
|
+
os: "darwin",
|
|
200
|
+
arch: "arm64",
|
|
201
|
+
bin: "bun-darwin-aarch64",
|
|
202
|
+
exe: "bin/bun"
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
os: "darwin",
|
|
206
|
+
arch: "x64",
|
|
207
|
+
avx2: !0,
|
|
208
|
+
bin: "bun-darwin-x64",
|
|
209
|
+
exe: "bin/bun"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
os: "darwin",
|
|
213
|
+
arch: "x64",
|
|
214
|
+
bin: "bun-darwin-x64-baseline",
|
|
215
|
+
exe: "bin/bun"
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
os: "linux",
|
|
219
|
+
arch: "arm64",
|
|
220
|
+
bin: "bun-linux-aarch64",
|
|
221
|
+
exe: "bin/bun"
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
os: "linux",
|
|
225
|
+
arch: "x64",
|
|
226
|
+
avx2: !0,
|
|
227
|
+
bin: "bun-linux-x64",
|
|
228
|
+
exe: "bin/bun"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
os: "linux",
|
|
232
|
+
arch: "x64",
|
|
233
|
+
bin: "bun-linux-x64-baseline",
|
|
234
|
+
exe: "bin/bun"
|
|
235
|
+
}
|
|
236
|
+
], supportedPlatforms = platforms.filter(
|
|
237
|
+
(platform) => platform.os === os && platform.arch === arch && (!platform.avx2 || avx2)
|
|
238
|
+
).sort((a, b) => a.avx2 === b.avx2 ? 0 : a.avx2 ? -1 : 1);
|
|
239
|
+
function isLinuxAVX2() {
|
|
240
|
+
try {
|
|
241
|
+
return read("/proc/cpuinfo").includes("avx2");
|
|
242
|
+
} catch (error) {
|
|
243
|
+
return !1;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
__name(isLinuxAVX2, "isLinuxAVX2");
|
|
247
|
+
function isDarwinAVX2() {
|
|
248
|
+
try {
|
|
249
|
+
let { exitCode, stdout } = spawn("sysctl", ["-n", "machdep.cpu"]);
|
|
250
|
+
return exitCode === 0 && stdout.includes("AVX2");
|
|
251
|
+
} catch (error) {
|
|
252
|
+
return !1;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
__name(isDarwinAVX2, "isDarwinAVX2");
|
|
256
|
+
function isRosetta2() {
|
|
257
|
+
try {
|
|
258
|
+
let { exitCode, stdout } = spawn("sysctl", [
|
|
259
|
+
"-n",
|
|
260
|
+
"sysctl.proc_translated"
|
|
261
|
+
]);
|
|
262
|
+
return exitCode === 0 && stdout.includes("1");
|
|
263
|
+
} catch (error) {
|
|
264
|
+
return !1;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
__name(isRosetta2, "isRosetta2");
|
|
268
|
+
|
|
269
|
+
// src/install.ts
|
|
270
|
+
function importBun() {
|
|
271
|
+
return __async(this, null, function* () {
|
|
272
|
+
if (!supportedPlatforms.length)
|
|
273
|
+
throw new Error(`Unsupported platform: ${os} ${arch}`);
|
|
274
|
+
for (let platform of supportedPlatforms)
|
|
275
|
+
try {
|
|
276
|
+
return yield requireBun(platform);
|
|
277
|
+
} catch (error) {
|
|
278
|
+
}
|
|
279
|
+
throw new Error('Failed to install package "bun"');
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
__name(importBun, "importBun");
|
|
283
|
+
function requireBun(platform) {
|
|
284
|
+
return __async(this, null, function* () {
|
|
285
|
+
let npmPackage2 = `@oven/${platform.bin}`;
|
|
286
|
+
function resolveBun() {
|
|
287
|
+
let exe = require.resolve(join(npmPackage2, platform.exe)), { exitCode, stderr, stdout } = spawn(exe, ["--version"]);
|
|
288
|
+
if (exitCode === 0)
|
|
289
|
+
return exe;
|
|
290
|
+
throw new Error(stderr || stdout);
|
|
291
|
+
}
|
|
292
|
+
__name(resolveBun, "resolveBun");
|
|
293
|
+
try {
|
|
294
|
+
return resolveBun();
|
|
295
|
+
} catch (error) {
|
|
296
|
+
console.error(
|
|
297
|
+
`Failed to find package "${npmPackage2}".`,
|
|
298
|
+
'You may have used the "--no-optional" flag when running "npm install".'
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
let cwd = join("node_modules", npmPackage2);
|
|
302
|
+
try {
|
|
303
|
+
installBun(platform, cwd);
|
|
304
|
+
} catch (error) {
|
|
305
|
+
console.error(
|
|
306
|
+
`Failed to install package "${npmPackage2}" using "npm install".`,
|
|
307
|
+
error
|
|
308
|
+
);
|
|
309
|
+
try {
|
|
310
|
+
yield downloadBun(platform, cwd);
|
|
311
|
+
} catch (error2) {
|
|
312
|
+
console.error(
|
|
313
|
+
`Failed to download package "${npmPackage2}" from "registry.npmjs.org".`,
|
|
314
|
+
error2
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return resolveBun();
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
__name(requireBun, "requireBun");
|
|
322
|
+
function installBun(platform, dst) {
|
|
323
|
+
let npmPackage2 = `@oven/${platform.bin}`, cwd = tmp();
|
|
324
|
+
try {
|
|
325
|
+
write(join(cwd, "package.json"), "{}");
|
|
326
|
+
let { exitCode } = spawn(
|
|
327
|
+
"npm",
|
|
328
|
+
[
|
|
329
|
+
"install",
|
|
330
|
+
"--loglevel=error",
|
|
331
|
+
"--prefer-offline",
|
|
332
|
+
"--no-audit",
|
|
333
|
+
"--progress=false",
|
|
334
|
+
`${npmPackage2}@0.5.1-canary+ff6fb58`
|
|
335
|
+
],
|
|
336
|
+
{
|
|
337
|
+
cwd,
|
|
338
|
+
stdio: "pipe",
|
|
339
|
+
env: __spreadProps(__spreadValues({}, process.env), {
|
|
340
|
+
npm_config_global: void 0
|
|
341
|
+
})
|
|
342
|
+
}
|
|
343
|
+
);
|
|
344
|
+
exitCode === 0 && rename(join(cwd, "node_modules", npmPackage2), dst);
|
|
345
|
+
} finally {
|
|
346
|
+
try {
|
|
347
|
+
rm(cwd);
|
|
348
|
+
} catch (error) {
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
__name(installBun, "installBun");
|
|
353
|
+
function downloadBun(platform, dst) {
|
|
354
|
+
return __async(this, null, function* () {
|
|
355
|
+
let tgz = yield (yield fetch(
|
|
356
|
+
`https://registry.npmjs.org/@oven/${platform.bin}/-/${platform.bin}-0.5.1-canary+ff6fb58.tgz`
|
|
357
|
+
)).arrayBuffer(), buffer;
|
|
358
|
+
try {
|
|
359
|
+
buffer = (0, import_zlib.unzipSync)(tgz);
|
|
360
|
+
} catch (cause) {
|
|
361
|
+
throw new Error("Invalid gzip data", { cause });
|
|
362
|
+
}
|
|
363
|
+
function str(i, n) {
|
|
364
|
+
return String.fromCharCode(...buffer.subarray(i, i + n)).replace(
|
|
365
|
+
/\0.*$/,
|
|
366
|
+
""
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
__name(str, "str");
|
|
370
|
+
let offset = 0;
|
|
371
|
+
for (; offset < buffer.length; ) {
|
|
372
|
+
let name = str(offset, 100).replace("package/", ""), size = parseInt(str(offset + 124, 12), 8);
|
|
373
|
+
if (offset += 512, !isNaN(size)) {
|
|
374
|
+
if (write(join(dst, name), buffer.subarray(offset, offset + size)), name === platform.exe)
|
|
375
|
+
try {
|
|
376
|
+
chmod(join(dst, name), 493);
|
|
377
|
+
} catch (error) {
|
|
378
|
+
}
|
|
379
|
+
offset += size + 511 & -512;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
__name(downloadBun, "downloadBun");
|
|
385
|
+
|
|
386
|
+
// scripts/npm-exec.ts
|
|
387
|
+
var import_child_process2 = require("child_process");
|
|
388
|
+
importBun().then((bun) => (0, import_child_process2.execFileSync)(bun, process.argv.slice(2), {
|
|
389
|
+
stdio: "inherit"
|
|
390
|
+
})).catch((error) => {
|
|
391
|
+
console.error(error), process.exit(1);
|
|
392
|
+
});
|