@pnpm/resolving.bun-resolver 1000.0.0
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/LICENSE +22 -0
- package/README.md +17 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.js +75 -0
- package/lib/index.js.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-2016 Rico Sta. Cruz and other contributors
|
|
4
|
+
Copyright (c) 2016-2025 Zoltan Kochan and other contributors
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @pnpm/resolving.bun-resolver
|
|
2
|
+
|
|
3
|
+
> Resolves the Bun runtime
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@pnpm/resolving.bun-resolver)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm add @pnpm/resolving.bun-resolver
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## License
|
|
14
|
+
|
|
15
|
+
MIT
|
|
16
|
+
|
|
17
|
+
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type FetchFromRegistry } from '@pnpm/fetching-types';
|
|
2
|
+
import { type ResolveResult, type VariationsResolution, type WantedDependency } from '@pnpm/resolver-base';
|
|
3
|
+
import { type NpmResolver } from '@pnpm/npm-resolver';
|
|
4
|
+
export interface BunRuntimeResolveResult extends ResolveResult {
|
|
5
|
+
resolution: VariationsResolution;
|
|
6
|
+
resolvedVia: 'github.com/oven-sh/bun';
|
|
7
|
+
}
|
|
8
|
+
export declare function resolveBunRuntime(ctx: {
|
|
9
|
+
fetchFromRegistry: FetchFromRegistry;
|
|
10
|
+
rawConfig: Record<string, string>;
|
|
11
|
+
offline?: boolean;
|
|
12
|
+
resolveFromNpm: NpmResolver;
|
|
13
|
+
}, wantedDependency: WantedDependency): Promise<BunRuntimeResolveResult | null>;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveBunRuntime = resolveBunRuntime;
|
|
4
|
+
const constants_1 = require("@pnpm/constants");
|
|
5
|
+
const crypto_shasums_file_1 = require("@pnpm/crypto.shasums-file");
|
|
6
|
+
const error_1 = require("@pnpm/error");
|
|
7
|
+
const util_lex_comparator_1 = require("@pnpm/util.lex-comparator");
|
|
8
|
+
async function resolveBunRuntime(ctx, wantedDependency) {
|
|
9
|
+
if (wantedDependency.alias !== 'bun' || !wantedDependency.bareSpecifier?.startsWith('runtime:'))
|
|
10
|
+
return null;
|
|
11
|
+
const versionSpec = wantedDependency.bareSpecifier.substring('runtime:'.length);
|
|
12
|
+
// We use the npm registry for version resolution as it is easier than using the GitHub API for releases,
|
|
13
|
+
// which uses pagination (e.g. https://api.github.com/repos/oven-sh/bun/releases?per_page=100).
|
|
14
|
+
const npmResolution = await ctx.resolveFromNpm({ ...wantedDependency, bareSpecifier: versionSpec }, {});
|
|
15
|
+
if (npmResolution == null) {
|
|
16
|
+
throw new error_1.PnpmError('BUN_RESOLUTION_FAILURE', `Could not resolve Bun version specified as ${versionSpec}`);
|
|
17
|
+
}
|
|
18
|
+
const version = npmResolution.manifest.version;
|
|
19
|
+
const assets = await readBunAssets(ctx.fetchFromRegistry, version);
|
|
20
|
+
assets.sort((asset1, asset2) => (0, util_lex_comparator_1.lexCompare)(asset1.resolution.url, asset2.resolution.url));
|
|
21
|
+
return {
|
|
22
|
+
id: `bun@runtime:${version}`,
|
|
23
|
+
normalizedBareSpecifier: `runtime:${versionSpec}`,
|
|
24
|
+
resolvedVia: 'github.com/oven-sh/bun',
|
|
25
|
+
manifest: {
|
|
26
|
+
name: 'bun',
|
|
27
|
+
version,
|
|
28
|
+
bin: (0, constants_1.getBunBinLocationForCurrentOS)(),
|
|
29
|
+
},
|
|
30
|
+
resolution: {
|
|
31
|
+
type: 'variations',
|
|
32
|
+
variants: assets,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
async function readBunAssets(fetch, version) {
|
|
37
|
+
const integritiesFileUrl = `https://github.com/oven-sh/bun/releases/download/bun-v${version}/SHASUMS256.txt`;
|
|
38
|
+
const shasumsFileItems = await (0, crypto_shasums_file_1.fetchShasumsFile)(fetch, integritiesFileUrl);
|
|
39
|
+
const pattern = /^bun-([^-.]+)-([^-.]+)(-musl)?\.zip$/;
|
|
40
|
+
const assets = [];
|
|
41
|
+
for (const { integrity, fileName } of shasumsFileItems) {
|
|
42
|
+
const match = pattern.exec(fileName);
|
|
43
|
+
if (!match)
|
|
44
|
+
continue;
|
|
45
|
+
let [, platform, arch, musl] = match;
|
|
46
|
+
if (platform === 'windows') {
|
|
47
|
+
platform = 'win32';
|
|
48
|
+
}
|
|
49
|
+
if (arch === 'aarch64') {
|
|
50
|
+
arch = 'arm64';
|
|
51
|
+
}
|
|
52
|
+
const url = `https://github.com/oven-sh/bun/releases/download/bun-v${version}/${fileName}`;
|
|
53
|
+
const resolution = {
|
|
54
|
+
type: 'binary',
|
|
55
|
+
archive: 'zip',
|
|
56
|
+
bin: (0, constants_1.getBunBinLocationForCurrentOS)(platform),
|
|
57
|
+
integrity,
|
|
58
|
+
url,
|
|
59
|
+
prefix: fileName.replace(/\.zip$/, ''),
|
|
60
|
+
};
|
|
61
|
+
const target = {
|
|
62
|
+
os: platform,
|
|
63
|
+
cpu: arch,
|
|
64
|
+
};
|
|
65
|
+
if (musl != null) {
|
|
66
|
+
target.libc = 'musl';
|
|
67
|
+
}
|
|
68
|
+
assets.push({
|
|
69
|
+
targets: [target],
|
|
70
|
+
resolution,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return assets;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAqBA,8CAmCC;AAxDD,+CAA+D;AAC/D,mEAA4D;AAC5D,uCAAuC;AAYvC,mEAAsD;AAO/C,KAAK,UAAU,iBAAiB,CACrC,GAKC,EACD,gBAAkC;IAElC,IAAI,gBAAgB,CAAC,KAAK,KAAK,KAAK,IAAI,CAAC,gBAAgB,CAAC,aAAa,EAAE,UAAU,CAAC,UAAU,CAAC;QAAE,OAAO,IAAI,CAAA;IAC5G,MAAM,WAAW,GAAG,gBAAgB,CAAC,aAAa,CAAC,SAAS,CAA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
7
|
+
"pnpm10",
|
|
8
|
+
"bun",
|
|
9
|
+
"runtime"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"funding": "https://opencollective.com/pnpm",
|
|
13
|
+
"repository": "https://github.com/pnpm/pnpm/blob/main/resolving/bun-resolver",
|
|
14
|
+
"homepage": "https://github.com/pnpm/pnpm/blob/main/resolving/bun-resolver#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/pnpm/pnpm/issues"
|
|
17
|
+
},
|
|
18
|
+
"type": "commonjs",
|
|
19
|
+
"main": "lib/index.js",
|
|
20
|
+
"types": "lib/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": "./lib/index.js"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"lib",
|
|
26
|
+
"!*.map"
|
|
27
|
+
],
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@pnpm/util.lex-comparator": "^3.0.2",
|
|
30
|
+
"semver": "^7.7.1",
|
|
31
|
+
"@pnpm/constants": "1001.3.0",
|
|
32
|
+
"@pnpm/error": "1000.0.4",
|
|
33
|
+
"@pnpm/crypto.shasums-file": "1001.0.0",
|
|
34
|
+
"@pnpm/fetching-types": "1000.2.0",
|
|
35
|
+
"@pnpm/fetcher-base": "1001.0.0",
|
|
36
|
+
"@pnpm/node.fetcher": "1001.0.0",
|
|
37
|
+
"@pnpm/fetching.binary-fetcher": "1000.0.0",
|
|
38
|
+
"@pnpm/npm-resolver": "1004.1.3",
|
|
39
|
+
"@pnpm/resolver-base": "1005.0.0",
|
|
40
|
+
"@pnpm/worker": "1000.1.11",
|
|
41
|
+
"@pnpm/types": "1000.7.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/semver": "7.5.3",
|
|
45
|
+
"@pnpm/resolving.bun-resolver": "1000.0.0",
|
|
46
|
+
"@pnpm/resolving.deno-resolver": "1000.0.0"
|
|
47
|
+
},
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=18.12"
|
|
50
|
+
},
|
|
51
|
+
"jest": {
|
|
52
|
+
"preset": "@pnpm/jest-config"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"lint": "eslint \"src/**/*.ts\"",
|
|
56
|
+
"test": "pnpm run compile",
|
|
57
|
+
"compile": "tsc --build && pnpm run lint --fix"
|
|
58
|
+
}
|
|
59
|
+
}
|