bun 1.0.36 → 1.1.1
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/README.txt +12 -0
- package/bin/bun.exe +0 -0
- package/install.js +31 -14
- package/package.json +28 -25
- package/bin/bun +0 -409
package/bin/README.txt
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
The 'bun.exe' file is a placeholder for the binary file, which
|
|
2
|
+
is replaced by Bun's 'postinstall' script. For this to work, make
|
|
3
|
+
sure that you do not use --ignore-scripts while installing.
|
|
4
|
+
|
|
5
|
+
The postinstall script is responsible for linking the binary file
|
|
6
|
+
directly into 'node_modules/.bin' and avoiding a Node.js wrapper
|
|
7
|
+
script being called on every invocation of 'bun'. If this wasn't
|
|
8
|
+
done, Bun would seem to be slower than Node.js, because it would
|
|
9
|
+
be executing a copy of Node.js every time!
|
|
10
|
+
|
|
11
|
+
Unfortunately, it is not possible to fix all cases on all platforms
|
|
12
|
+
without *requiring* a postinstall script.
|
package/bin/bun.exe
ADDED
|
File without changes
|
package/install.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// Source code: https://github.com/oven-sh/bun/blob/main/packages/bun-release/scripts/npm-postinstall.ts
|
|
1
2
|
"use strict";
|
|
2
3
|
var __create = Object.create;
|
|
3
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;
|
|
@@ -230,7 +231,7 @@ __name(chmod, "chmod");
|
|
|
230
231
|
var import_zlib = require("zlib");
|
|
231
232
|
|
|
232
233
|
// src/platform.ts
|
|
233
|
-
var os2 = process.platform, arch = os2 === "darwin" && process.arch === "x64" && isRosetta2() ? "arm64" : process.arch, avx2 = arch === "x64" && os2 === "linux" && isLinuxAVX2() || os2 === "darwin" && isDarwinAVX2(), platforms = [
|
|
234
|
+
var os2 = process.platform, arch = os2 === "darwin" && process.arch === "x64" && isRosetta2() ? "arm64" : process.arch, avx2 = arch === "x64" && (os2 === "linux" && isLinuxAVX2() || os2 === "darwin" && isDarwinAVX2() || os2 === "win32" && isWindowsAVX2()), platforms = [
|
|
234
235
|
{
|
|
235
236
|
os: "darwin",
|
|
236
237
|
arch: "arm64",
|
|
@@ -268,6 +269,19 @@ var os2 = process.platform, arch = os2 === "darwin" && process.arch === "x64" &&
|
|
|
268
269
|
arch: "x64",
|
|
269
270
|
bin: "bun-linux-x64-baseline",
|
|
270
271
|
exe: "bin/bun"
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
os: "win32",
|
|
275
|
+
arch: "x64",
|
|
276
|
+
avx2: !0,
|
|
277
|
+
bin: "bun-windows-x64",
|
|
278
|
+
exe: "bin/bun.exe"
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
os: "win32",
|
|
282
|
+
arch: "x64",
|
|
283
|
+
bin: "bun-windows-x64-baseline",
|
|
284
|
+
exe: "bin/bun.exe"
|
|
271
285
|
}
|
|
272
286
|
], supportedPlatforms = platforms.filter((platform) => platform.os === os2 && platform.arch === arch && (!platform.avx2 || avx2)).sort((a, b) => a.avx2 === b.avx2 ? 0 : a.avx2 ? -1 : 1);
|
|
273
287
|
function isLinuxAVX2() {
|
|
@@ -296,6 +310,17 @@ function isRosetta2() {
|
|
|
296
310
|
}
|
|
297
311
|
}
|
|
298
312
|
__name(isRosetta2, "isRosetta2");
|
|
313
|
+
function isWindowsAVX2() {
|
|
314
|
+
try {
|
|
315
|
+
return spawn("powershell", [
|
|
316
|
+
"-c",
|
|
317
|
+
`(Add-Type -MemberDefinition '[DllImport("kernel32.dll")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);' -Name 'Kernel32' -Namespace 'Win32' -PassThru)::IsProcessorFeaturePresent(40);`
|
|
318
|
+
]).stdout == "True";
|
|
319
|
+
} catch (error2) {
|
|
320
|
+
return debug("isWindowsAVX2 failed", error2), !1;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
__name(isWindowsAVX2, "isWindowsAVX2");
|
|
299
324
|
|
|
300
325
|
// src/npm/install.ts
|
|
301
326
|
function importBun() {
|
|
@@ -351,7 +376,7 @@ function installBun(platform, dst) {
|
|
|
351
376
|
write(join(cwd, "package.json"), "{}");
|
|
352
377
|
let { exitCode } = spawn(
|
|
353
378
|
"npm",
|
|
354
|
-
["install", "--loglevel=error", "--prefer-offline", "--no-audit", "--progress=false", `${module2}@1.
|
|
379
|
+
["install", "--loglevel=error", "--prefer-offline", "--no-audit", "--progress=false", `${module2}@1.1.1`],
|
|
355
380
|
{
|
|
356
381
|
cwd,
|
|
357
382
|
stdio: "pipe",
|
|
@@ -372,7 +397,7 @@ function installBun(platform, dst) {
|
|
|
372
397
|
__name(installBun, "installBun");
|
|
373
398
|
function downloadBun(platform, dst) {
|
|
374
399
|
return __async(this, null, function* () {
|
|
375
|
-
let tgz = yield (yield fetch(`https://registry.npmjs.org/@oven/${platform.bin}/-/${platform.bin}-1.
|
|
400
|
+
let tgz = yield (yield fetch(`https://registry.npmjs.org/@oven/${platform.bin}/-/${platform.bin}-1.1.1.tgz`)).arrayBuffer(), buffer;
|
|
376
401
|
try {
|
|
377
402
|
buffer = (0, import_zlib.unzipSync)(tgz);
|
|
378
403
|
} catch (cause) {
|
|
@@ -399,23 +424,15 @@ function downloadBun(platform, dst) {
|
|
|
399
424
|
}
|
|
400
425
|
__name(downloadBun, "downloadBun");
|
|
401
426
|
function optimizeBun(path2) {
|
|
402
|
-
|
|
403
|
-
throw new Error(
|
|
404
|
-
"You must use Windows Subsystem for Linux, aka. WSL, to run bun. Learn more: https://learn.microsoft.com/en-us/windows/wsl/install"
|
|
405
|
-
);
|
|
406
|
-
let { npm_config_user_agent } = process.env;
|
|
407
|
-
if (npm_config_user_agent && /\byarn\//.test(npm_config_user_agent))
|
|
408
|
-
throw new Error(
|
|
409
|
-
"Yarn does not support bun, because it does not allow linking to binaries. To use bun, install using the following command: curl -fsSL https://bun.sh/install | bash"
|
|
410
|
-
);
|
|
427
|
+
let installScript = os2 === "win32" ? 'powershell -c "irm bun.sh/install.ps1 | iex"' : "curl -fsSL https://bun.sh/install | bash";
|
|
411
428
|
try {
|
|
412
|
-
rename(path2, join(__dirname, "bin", "bun"));
|
|
429
|
+
rename(path2, join(__dirname, "bin", "bun.exe"));
|
|
413
430
|
return;
|
|
414
431
|
} catch (error2) {
|
|
415
432
|
debug("optimizeBun failed", error2);
|
|
416
433
|
}
|
|
417
434
|
throw new Error(
|
|
418
|
-
|
|
435
|
+
`Your package manager doesn't seem to support bun. To use bun, install using the following command: ${installScript}`
|
|
419
436
|
);
|
|
420
437
|
}
|
|
421
438
|
__name(optimizeBun, "optimizeBun");
|
package/package.json
CHANGED
|
@@ -1,7 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bun",
|
|
3
|
-
"version": "1.0.36",
|
|
4
3
|
"description": "Bun is a fast all-in-one JavaScript runtime.",
|
|
4
|
+
"version": "1.1.1",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"postinstall": "node install.js"
|
|
7
|
+
},
|
|
8
|
+
"optionalDependencies": {
|
|
9
|
+
"@oven/bun-darwin-aarch64": "1.1.1",
|
|
10
|
+
"@oven/bun-darwin-x64": "1.1.1",
|
|
11
|
+
"@oven/bun-darwin-x64-baseline": "1.1.1",
|
|
12
|
+
"@oven/bun-linux-aarch64": "1.1.1",
|
|
13
|
+
"@oven/bun-linux-x64": "1.1.1",
|
|
14
|
+
"@oven/bun-linux-x64-baseline": "1.1.1",
|
|
15
|
+
"@oven/bun-windows-x64": "1.1.1",
|
|
16
|
+
"@oven/bun-windows-x64-baseline": "1.1.1"
|
|
17
|
+
},
|
|
18
|
+
"bin": {
|
|
19
|
+
"bun": "bin/bun.exe",
|
|
20
|
+
"bunx": "bin/bun.exe"
|
|
21
|
+
},
|
|
22
|
+
"os": [
|
|
23
|
+
"darwin",
|
|
24
|
+
"linux",
|
|
25
|
+
"win32"
|
|
26
|
+
],
|
|
27
|
+
"cpu": [
|
|
28
|
+
"arm64",
|
|
29
|
+
"x64"
|
|
30
|
+
],
|
|
5
31
|
"keywords": [
|
|
6
32
|
"bun",
|
|
7
33
|
"bun.js",
|
|
@@ -15,28 +41,5 @@
|
|
|
15
41
|
"homepage": "https://bun.sh",
|
|
16
42
|
"bugs": "https://github.com/oven-sh/issues",
|
|
17
43
|
"license": "MIT",
|
|
18
|
-
"
|
|
19
|
-
"bun": "bin/bun",
|
|
20
|
-
"bunx": "bin/bun"
|
|
21
|
-
},
|
|
22
|
-
"repository": "https://github.com/oven-sh/bun",
|
|
23
|
-
"scripts": {
|
|
24
|
-
"postinstall": "node install.js"
|
|
25
|
-
},
|
|
26
|
-
"optionalDependencies": {
|
|
27
|
-
"@oven/bun-darwin-aarch64": "1.0.36",
|
|
28
|
-
"@oven/bun-darwin-x64": "1.0.36",
|
|
29
|
-
"@oven/bun-darwin-x64-baseline": "1.0.36",
|
|
30
|
-
"@oven/bun-linux-aarch64": "1.0.36",
|
|
31
|
-
"@oven/bun-linux-x64": "1.0.36",
|
|
32
|
-
"@oven/bun-linux-x64-baseline": "1.0.36"
|
|
33
|
-
},
|
|
34
|
-
"os": [
|
|
35
|
-
"darwin",
|
|
36
|
-
"linux"
|
|
37
|
-
],
|
|
38
|
-
"cpu": [
|
|
39
|
-
"arm64",
|
|
40
|
-
"x64"
|
|
41
|
-
]
|
|
44
|
+
"repository": "https://github.com/oven-sh/bun"
|
|
42
45
|
}
|
package/bin/bun
DELETED
|
@@ -1,409 +0,0 @@
|
|
|
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/console.ts
|
|
45
|
-
var isAction = !!process.env.GITHUB_ACTION, isDebug = process.env.DEBUG === "1" || process.env.LOG_LEVEL === "debug" || process.env.RUNNER_DEBUG === "1";
|
|
46
|
-
function debug(...message) {
|
|
47
|
-
isAction ? [...message] : isDebug && [...message];
|
|
48
|
-
}
|
|
49
|
-
__name(debug, "debug");
|
|
50
|
-
function error(...message) {
|
|
51
|
-
isAction ? console.error("::error::", ...message) : console.error(...message);
|
|
52
|
-
}
|
|
53
|
-
__name(error, "error");
|
|
54
|
-
|
|
55
|
-
// src/fetch.ts
|
|
56
|
-
var fetch = "fetch" in globalThis ? webFetch : nodeFetch;
|
|
57
|
-
function webFetch(_0) {
|
|
58
|
-
return __async(this, arguments, function* (url, options = {}) {
|
|
59
|
-
debug("fetch request", url, options);
|
|
60
|
-
let response = yield globalThis.fetch(url, options, { verbose: isDebug });
|
|
61
|
-
if (debug("fetch response", response), (options == null ? void 0 : options.assert) !== !1 && !isOk(response.status)) {
|
|
62
|
-
try {
|
|
63
|
-
debug(yield response.text());
|
|
64
|
-
} catch (e) {
|
|
65
|
-
}
|
|
66
|
-
throw new Error(`${response.status}: ${url}`);
|
|
67
|
-
}
|
|
68
|
-
return response;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
__name(webFetch, "webFetch");
|
|
72
|
-
function nodeFetch(_0) {
|
|
73
|
-
return __async(this, arguments, function* (url, options = {}) {
|
|
74
|
-
let { get } = yield import("http");
|
|
75
|
-
return new Promise((resolve, reject) => {
|
|
76
|
-
get(url, (response) => {
|
|
77
|
-
var _a;
|
|
78
|
-
debug("http.get", url, response.statusCode);
|
|
79
|
-
let status = (_a = response.statusCode) != null ? _a : 501;
|
|
80
|
-
if (response.headers.location && isRedirect(status))
|
|
81
|
-
return nodeFetch(url).then(resolve, reject);
|
|
82
|
-
if ((options == null ? void 0 : options.assert) !== !1 && !isOk(status))
|
|
83
|
-
return reject(new Error(`${status}: ${url}`));
|
|
84
|
-
let body = [];
|
|
85
|
-
response.on("data", (chunk) => {
|
|
86
|
-
body.push(chunk);
|
|
87
|
-
}), response.on("end", () => {
|
|
88
|
-
resolve({
|
|
89
|
-
ok: isOk(status),
|
|
90
|
-
status,
|
|
91
|
-
arrayBuffer() {
|
|
92
|
-
return __async(this, null, function* () {
|
|
93
|
-
return Buffer.concat(body).buffer;
|
|
94
|
-
});
|
|
95
|
-
},
|
|
96
|
-
text() {
|
|
97
|
-
return __async(this, null, function* () {
|
|
98
|
-
return Buffer.concat(body).toString("utf-8");
|
|
99
|
-
});
|
|
100
|
-
},
|
|
101
|
-
json() {
|
|
102
|
-
return __async(this, null, function* () {
|
|
103
|
-
let text = Buffer.concat(body).toString("utf-8");
|
|
104
|
-
return JSON.parse(text);
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
}).on("error", reject);
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
__name(nodeFetch, "nodeFetch");
|
|
114
|
-
function isOk(status) {
|
|
115
|
-
return status >= 200 && status <= 204;
|
|
116
|
-
}
|
|
117
|
-
__name(isOk, "isOk");
|
|
118
|
-
function isRedirect(status) {
|
|
119
|
-
switch (status) {
|
|
120
|
-
case 301:
|
|
121
|
-
case 308:
|
|
122
|
-
case 302:
|
|
123
|
-
case 307:
|
|
124
|
-
case 303:
|
|
125
|
-
return !0;
|
|
126
|
-
}
|
|
127
|
-
return !1;
|
|
128
|
-
}
|
|
129
|
-
__name(isRedirect, "isRedirect");
|
|
130
|
-
|
|
131
|
-
// src/spawn.ts
|
|
132
|
-
var import_child_process = __toESM(require("child_process"));
|
|
133
|
-
function spawn(cmd, args, options = {}) {
|
|
134
|
-
debug("spawn", [cmd, ...args].join(" "));
|
|
135
|
-
let { status, stdout, stderr } = import_child_process.default.spawnSync(cmd, args, __spreadValues({
|
|
136
|
-
stdio: "pipe",
|
|
137
|
-
encoding: "utf-8"
|
|
138
|
-
}, options));
|
|
139
|
-
return {
|
|
140
|
-
exitCode: status != null ? status : 1,
|
|
141
|
-
stdout,
|
|
142
|
-
stderr
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
__name(spawn, "spawn");
|
|
146
|
-
|
|
147
|
-
// src/fs.ts
|
|
148
|
-
var import_path = __toESM(require("path")), import_fs = __toESM(require("fs")), import_os = __toESM(require("os"));
|
|
149
|
-
function join(...paths) {
|
|
150
|
-
return import_path.default.join(...paths.flat(2));
|
|
151
|
-
}
|
|
152
|
-
__name(join, "join");
|
|
153
|
-
function tmp() {
|
|
154
|
-
var _a;
|
|
155
|
-
let tmpdir = (_a = process.env.RUNNER_TEMP) != null ? _a : import_os.default.tmpdir(), dir = import_fs.default.mkdtempSync(join(tmpdir, "bun-"));
|
|
156
|
-
return debug("tmp", dir), dir;
|
|
157
|
-
}
|
|
158
|
-
__name(tmp, "tmp");
|
|
159
|
-
function rm(path2) {
|
|
160
|
-
debug("rm", path2);
|
|
161
|
-
try {
|
|
162
|
-
import_fs.default.rmSync(path2, { recursive: !0 });
|
|
163
|
-
return;
|
|
164
|
-
} catch (error2) {
|
|
165
|
-
debug("fs.rmSync failed", error2);
|
|
166
|
-
}
|
|
167
|
-
let stats;
|
|
168
|
-
try {
|
|
169
|
-
stats = import_fs.default.lstatSync(path2);
|
|
170
|
-
} catch (error2) {
|
|
171
|
-
debug("fs.lstatSync failed", error2);
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
if (!stats.isDirectory()) {
|
|
175
|
-
import_fs.default.unlinkSync(path2);
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
try {
|
|
179
|
-
import_fs.default.rmdirSync(path2, { recursive: !0 });
|
|
180
|
-
return;
|
|
181
|
-
} catch (error2) {
|
|
182
|
-
debug("fs.rmdirSync failed", error2);
|
|
183
|
-
}
|
|
184
|
-
for (let filename of import_fs.default.readdirSync(path2))
|
|
185
|
-
rm(join(path2, filename));
|
|
186
|
-
import_fs.default.rmdirSync(path2);
|
|
187
|
-
}
|
|
188
|
-
__name(rm, "rm");
|
|
189
|
-
function rename(path2, newPath) {
|
|
190
|
-
debug("rename", path2, newPath);
|
|
191
|
-
try {
|
|
192
|
-
import_fs.default.renameSync(path2, newPath);
|
|
193
|
-
return;
|
|
194
|
-
} catch (error2) {
|
|
195
|
-
debug("fs.renameSync failed", error2);
|
|
196
|
-
}
|
|
197
|
-
try {
|
|
198
|
-
rm(newPath);
|
|
199
|
-
} catch (error2) {
|
|
200
|
-
debug("rm failed", error2);
|
|
201
|
-
}
|
|
202
|
-
import_fs.default.renameSync(path2, newPath);
|
|
203
|
-
}
|
|
204
|
-
__name(rename, "rename");
|
|
205
|
-
function write(dst, content) {
|
|
206
|
-
debug("write", dst);
|
|
207
|
-
try {
|
|
208
|
-
import_fs.default.writeFileSync(dst, content);
|
|
209
|
-
return;
|
|
210
|
-
} catch (error2) {
|
|
211
|
-
debug("fs.writeFileSync failed", error2);
|
|
212
|
-
try {
|
|
213
|
-
import_fs.default.mkdirSync(import_path.default.dirname(dst), { recursive: !0 });
|
|
214
|
-
} catch (error3) {
|
|
215
|
-
debug("fs.mkdirSync failed", error3);
|
|
216
|
-
}
|
|
217
|
-
import_fs.default.writeFileSync(dst, content);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
__name(write, "write");
|
|
221
|
-
function read(path2) {
|
|
222
|
-
return debug("read", path2), import_fs.default.readFileSync(path2, "utf-8");
|
|
223
|
-
}
|
|
224
|
-
__name(read, "read");
|
|
225
|
-
function chmod(path2, mode) {
|
|
226
|
-
debug("chmod", path2, mode), import_fs.default.chmodSync(path2, mode);
|
|
227
|
-
}
|
|
228
|
-
__name(chmod, "chmod");
|
|
229
|
-
|
|
230
|
-
// src/npm/install.ts
|
|
231
|
-
var import_zlib = require("zlib");
|
|
232
|
-
|
|
233
|
-
// src/platform.ts
|
|
234
|
-
var os2 = process.platform, arch = os2 === "darwin" && process.arch === "x64" && isRosetta2() ? "arm64" : process.arch, avx2 = arch === "x64" && os2 === "linux" && isLinuxAVX2() || os2 === "darwin" && isDarwinAVX2(), platforms = [
|
|
235
|
-
{
|
|
236
|
-
os: "darwin",
|
|
237
|
-
arch: "arm64",
|
|
238
|
-
bin: "bun-darwin-aarch64",
|
|
239
|
-
exe: "bin/bun"
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
os: "darwin",
|
|
243
|
-
arch: "x64",
|
|
244
|
-
avx2: !0,
|
|
245
|
-
bin: "bun-darwin-x64",
|
|
246
|
-
exe: "bin/bun"
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
os: "darwin",
|
|
250
|
-
arch: "x64",
|
|
251
|
-
bin: "bun-darwin-x64-baseline",
|
|
252
|
-
exe: "bin/bun"
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
os: "linux",
|
|
256
|
-
arch: "arm64",
|
|
257
|
-
bin: "bun-linux-aarch64",
|
|
258
|
-
exe: "bin/bun"
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
os: "linux",
|
|
262
|
-
arch: "x64",
|
|
263
|
-
avx2: !0,
|
|
264
|
-
bin: "bun-linux-x64",
|
|
265
|
-
exe: "bin/bun"
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
os: "linux",
|
|
269
|
-
arch: "x64",
|
|
270
|
-
bin: "bun-linux-x64-baseline",
|
|
271
|
-
exe: "bin/bun"
|
|
272
|
-
}
|
|
273
|
-
], supportedPlatforms = platforms.filter((platform) => platform.os === os2 && platform.arch === arch && (!platform.avx2 || avx2)).sort((a, b) => a.avx2 === b.avx2 ? 0 : a.avx2 ? -1 : 1);
|
|
274
|
-
function isLinuxAVX2() {
|
|
275
|
-
try {
|
|
276
|
-
return read("/proc/cpuinfo").includes("avx2");
|
|
277
|
-
} catch (error2) {
|
|
278
|
-
return debug("isLinuxAVX2 failed", error2), !1;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
__name(isLinuxAVX2, "isLinuxAVX2");
|
|
282
|
-
function isDarwinAVX2() {
|
|
283
|
-
try {
|
|
284
|
-
let { exitCode, stdout } = spawn("sysctl", ["-n", "machdep.cpu"]);
|
|
285
|
-
return exitCode === 0 && stdout.includes("AVX2");
|
|
286
|
-
} catch (error2) {
|
|
287
|
-
return debug("isDarwinAVX2 failed", error2), !1;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
__name(isDarwinAVX2, "isDarwinAVX2");
|
|
291
|
-
function isRosetta2() {
|
|
292
|
-
try {
|
|
293
|
-
let { exitCode, stdout } = spawn("sysctl", ["-n", "sysctl.proc_translated"]);
|
|
294
|
-
return exitCode === 0 && stdout.includes("1");
|
|
295
|
-
} catch (error2) {
|
|
296
|
-
return debug("isRosetta2 failed", error2), !1;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
__name(isRosetta2, "isRosetta2");
|
|
300
|
-
|
|
301
|
-
// src/npm/install.ts
|
|
302
|
-
function importBun() {
|
|
303
|
-
return __async(this, null, function* () {
|
|
304
|
-
if (!supportedPlatforms.length)
|
|
305
|
-
throw new Error(`Unsupported platform: ${os2} ${arch}`);
|
|
306
|
-
for (let platform of supportedPlatforms)
|
|
307
|
-
try {
|
|
308
|
-
return yield requireBun(platform);
|
|
309
|
-
} catch (error2) {
|
|
310
|
-
debug("requireBun failed", error2);
|
|
311
|
-
}
|
|
312
|
-
throw new Error('Failed to install package "bun"');
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
__name(importBun, "importBun");
|
|
316
|
-
function requireBun(platform) {
|
|
317
|
-
return __async(this, null, function* () {
|
|
318
|
-
let module2 = `@oven/${platform.bin}`;
|
|
319
|
-
function resolveBun() {
|
|
320
|
-
let exe = require.resolve(join(module2, platform.exe)), { exitCode, stderr, stdout } = spawn(exe, ["--version"]);
|
|
321
|
-
if (exitCode === 0)
|
|
322
|
-
return exe;
|
|
323
|
-
throw new Error(stderr || stdout);
|
|
324
|
-
}
|
|
325
|
-
__name(resolveBun, "resolveBun");
|
|
326
|
-
try {
|
|
327
|
-
return resolveBun();
|
|
328
|
-
} catch (cause) {
|
|
329
|
-
debug("resolveBun failed", cause), error(
|
|
330
|
-
`Failed to find package "${module2}".`,
|
|
331
|
-
'You may have used the "--no-optional" flag when running "npm install".'
|
|
332
|
-
);
|
|
333
|
-
}
|
|
334
|
-
let cwd = join("node_modules", module2);
|
|
335
|
-
try {
|
|
336
|
-
installBun(platform, cwd);
|
|
337
|
-
} catch (cause) {
|
|
338
|
-
debug("installBun failed", cause), error(`Failed to install package "${module2}" using "npm install".`, cause);
|
|
339
|
-
try {
|
|
340
|
-
yield downloadBun(platform, cwd);
|
|
341
|
-
} catch (cause2) {
|
|
342
|
-
debug("downloadBun failed", cause2), error(`Failed to download package "${module2}" from "registry.npmjs.org".`, cause2);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
return resolveBun();
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
__name(requireBun, "requireBun");
|
|
349
|
-
function installBun(platform, dst) {
|
|
350
|
-
let module2 = `@oven/${platform.bin}`, cwd = tmp();
|
|
351
|
-
try {
|
|
352
|
-
write(join(cwd, "package.json"), "{}");
|
|
353
|
-
let { exitCode } = spawn(
|
|
354
|
-
"npm",
|
|
355
|
-
["install", "--loglevel=error", "--prefer-offline", "--no-audit", "--progress=false", `${module2}@1.0.36`],
|
|
356
|
-
{
|
|
357
|
-
cwd,
|
|
358
|
-
stdio: "pipe",
|
|
359
|
-
env: __spreadProps(__spreadValues({}, process.env), {
|
|
360
|
-
npm_config_global: void 0
|
|
361
|
-
})
|
|
362
|
-
}
|
|
363
|
-
);
|
|
364
|
-
exitCode === 0 && rename(join(cwd, "node_modules", module2), dst);
|
|
365
|
-
} finally {
|
|
366
|
-
try {
|
|
367
|
-
rm(cwd);
|
|
368
|
-
} catch (error2) {
|
|
369
|
-
debug("rm failed", error2);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
__name(installBun, "installBun");
|
|
374
|
-
function downloadBun(platform, dst) {
|
|
375
|
-
return __async(this, null, function* () {
|
|
376
|
-
let tgz = yield (yield fetch(`https://registry.npmjs.org/@oven/${platform.bin}/-/${platform.bin}-1.0.36.tgz`)).arrayBuffer(), buffer;
|
|
377
|
-
try {
|
|
378
|
-
buffer = (0, import_zlib.unzipSync)(tgz);
|
|
379
|
-
} catch (cause) {
|
|
380
|
-
throw new Error("Invalid gzip data", { cause });
|
|
381
|
-
}
|
|
382
|
-
function str(i, n) {
|
|
383
|
-
return String.fromCharCode(...buffer.subarray(i, i + n)).replace(/\0.*$/, "");
|
|
384
|
-
}
|
|
385
|
-
__name(str, "str");
|
|
386
|
-
let offset = 0;
|
|
387
|
-
for (; offset < buffer.length; ) {
|
|
388
|
-
let name = str(offset, 100).replace("package/", ""), size = parseInt(str(offset + 124, 12), 8);
|
|
389
|
-
if (offset += 512, !isNaN(size)) {
|
|
390
|
-
if (write(join(dst, name), buffer.subarray(offset, offset + size)), name === platform.exe)
|
|
391
|
-
try {
|
|
392
|
-
chmod(join(dst, name), 493);
|
|
393
|
-
} catch (error2) {
|
|
394
|
-
debug("chmod failed", error2);
|
|
395
|
-
}
|
|
396
|
-
offset += size + 511 & -512;
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
__name(downloadBun, "downloadBun");
|
|
402
|
-
|
|
403
|
-
// scripts/npm-exec.ts
|
|
404
|
-
var import_child_process2 = require("child_process");
|
|
405
|
-
importBun().then((bun) => (0, import_child_process2.execFileSync)(bun, process.argv.slice(2), {
|
|
406
|
-
stdio: "inherit"
|
|
407
|
-
})).catch((error2) => {
|
|
408
|
-
console.error(error2), process.exit(1);
|
|
409
|
-
});
|