@pnpm/resolving.deno-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 +16 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.js +89 -0
- package/lib/index.js.map +1 -0
- package/package.json +58 -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,16 @@
|
|
|
1
|
+
# @pnpm/resolving.deno-resolver
|
|
2
|
+
|
|
3
|
+
> Resolves the Deno runtime
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@pnpm/resolving.deno-resolver)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm add @pnpm/resolving.deno-resolver
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## License
|
|
14
|
+
|
|
15
|
+
MIT
|
|
16
|
+
|
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 DenoRuntimeResolveResult extends ResolveResult {
|
|
5
|
+
resolution: VariationsResolution;
|
|
6
|
+
resolvedVia: 'github.com/denoland/deno';
|
|
7
|
+
}
|
|
8
|
+
export declare function resolveDenoRuntime(ctx: {
|
|
9
|
+
fetchFromRegistry: FetchFromRegistry;
|
|
10
|
+
rawConfig: Record<string, string>;
|
|
11
|
+
offline?: boolean;
|
|
12
|
+
resolveFromNpm: NpmResolver;
|
|
13
|
+
}, wantedDependency: WantedDependency): Promise<DenoRuntimeResolveResult | null>;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveDenoRuntime = resolveDenoRuntime;
|
|
4
|
+
const constants_1 = require("@pnpm/constants");
|
|
5
|
+
const error_1 = require("@pnpm/error");
|
|
6
|
+
const util_lex_comparator_1 = require("@pnpm/util.lex-comparator");
|
|
7
|
+
const ASSET_REGEX = /^deno-(?<cpu>aarch64|x86_64)-(?<os>apple-darwin|unknown-linux-gnu|pc-windows-msvc)\.zip\.sha256sum$/;
|
|
8
|
+
const OS_MAP = {
|
|
9
|
+
'apple-darwin': 'darwin',
|
|
10
|
+
'unknown-linux-gnu': 'linux',
|
|
11
|
+
'pc-windows-msvc': 'win32',
|
|
12
|
+
};
|
|
13
|
+
const CPU_MAP = {
|
|
14
|
+
aarch64: 'arm64',
|
|
15
|
+
x86_64: 'x64',
|
|
16
|
+
};
|
|
17
|
+
async function resolveDenoRuntime(ctx, wantedDependency) {
|
|
18
|
+
if (wantedDependency.alias !== 'deno' || !wantedDependency.bareSpecifier?.startsWith('runtime:'))
|
|
19
|
+
return null;
|
|
20
|
+
const versionSpec = wantedDependency.bareSpecifier.substring('runtime:'.length);
|
|
21
|
+
// We use the npm registry for version resolution as it is easier than using the GitHub API for releases,
|
|
22
|
+
// which uses pagination (e.g. https://api.github.com/repos/denoland/deno/releases?per_page=100).
|
|
23
|
+
const npmResolution = await ctx.resolveFromNpm({ ...wantedDependency, bareSpecifier: versionSpec }, {});
|
|
24
|
+
if (npmResolution == null) {
|
|
25
|
+
throw new error_1.PnpmError('DENO_RESOLUTION_FAILURE', `Could not resolve Deno version specified as ${versionSpec}`);
|
|
26
|
+
}
|
|
27
|
+
const version = npmResolution.manifest.version;
|
|
28
|
+
const res = await ctx.fetchFromRegistry(`https://api.github.com/repos/denoland/deno/releases/tags/v${version}`);
|
|
29
|
+
const data = (await res.json());
|
|
30
|
+
const assets = [];
|
|
31
|
+
await Promise.all(data.assets.map(async (asset) => {
|
|
32
|
+
const targets = parseAssetName(asset.name);
|
|
33
|
+
if (!targets)
|
|
34
|
+
return;
|
|
35
|
+
const sha256 = await fetchSha256(ctx.fetchFromRegistry, asset.browser_download_url);
|
|
36
|
+
const base64 = Buffer.from(sha256, 'hex').toString('base64');
|
|
37
|
+
assets.push({
|
|
38
|
+
targets,
|
|
39
|
+
resolution: {
|
|
40
|
+
type: 'binary',
|
|
41
|
+
url: asset.browser_download_url.replace(/\.sha256sum$/, ''),
|
|
42
|
+
integrity: `sha256-${base64}`,
|
|
43
|
+
bin: (0, constants_1.getDenoBinLocationForCurrentOS)(targets[0].os),
|
|
44
|
+
archive: 'zip',
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}));
|
|
48
|
+
assets.sort((asset1, asset2) => (0, util_lex_comparator_1.lexCompare)(asset1.resolution.url, asset2.resolution.url));
|
|
49
|
+
return {
|
|
50
|
+
id: `deno@runtime:${version}`,
|
|
51
|
+
normalizedBareSpecifier: `runtime:${versionSpec}`,
|
|
52
|
+
resolvedVia: 'github.com/denoland/deno',
|
|
53
|
+
manifest: {
|
|
54
|
+
name: 'deno',
|
|
55
|
+
version,
|
|
56
|
+
bin: (0, constants_1.getDenoBinLocationForCurrentOS)(),
|
|
57
|
+
},
|
|
58
|
+
resolution: {
|
|
59
|
+
type: 'variations',
|
|
60
|
+
variants: assets,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function parseAssetName(name) {
|
|
65
|
+
const m = ASSET_REGEX.exec(name);
|
|
66
|
+
if (!m?.groups)
|
|
67
|
+
return null;
|
|
68
|
+
const os = OS_MAP[m.groups.os];
|
|
69
|
+
const cpu = CPU_MAP[m.groups.cpu];
|
|
70
|
+
const targets = [{ os, cpu }];
|
|
71
|
+
if (os === 'win32' && cpu === 'x64') {
|
|
72
|
+
// The Windows x64 binaries of Deno are compatible with arm64 architecture.
|
|
73
|
+
targets.push({ os: 'win32', cpu: 'arm64' });
|
|
74
|
+
}
|
|
75
|
+
return targets;
|
|
76
|
+
}
|
|
77
|
+
async function fetchSha256(fetch, url) {
|
|
78
|
+
const response = await fetch(url);
|
|
79
|
+
if (!response.ok) {
|
|
80
|
+
throw new error_1.PnpmError('DENO_GITHUB_FAILURE', `Failed to GET sha256 at ${url}`);
|
|
81
|
+
}
|
|
82
|
+
const txt = await response.text();
|
|
83
|
+
const m = txt.match(/([a-f0-9]{64})/i);
|
|
84
|
+
if (!m) {
|
|
85
|
+
throw new error_1.PnpmError('DENO_PARSE_HASH', `No SHA256 in ${url}`);
|
|
86
|
+
}
|
|
87
|
+
return m[1].toLowerCase();
|
|
88
|
+
}
|
|
89
|
+
//# 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":";;AA+BA,gDAqDC;AApFD,+CAAgE;AAChE,uCAAuC;AAYvC,mEAAsD;AAEtD,MAAM,WAAW,GAAG,qGAAqG,CAAA;AACzH,MAAM,MAAM,GAAG;IACb,cAAc,EAAE,QAAQ;IACxB,mBAAmB,EAAE,OAAO;IAC5B,iBAAiB,EAAE,OAAO;CAClB,CAAA;AACV,MAAM,OAAO,GAAG;IACd,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,KAAK;CACL,CAAA;AAOH,KAAK,UAAU,kBAAkB,CACtC,GAKC,EACD,gBAAkC;IAElC,IAAI,gBAAgB,CAAC,KAAK,KAAK,MAAM,IAAI,CAAC,gBAAgB,CAAC,aAAa,EAAE,UAAU,CAAC,UAAU,CAAC;QAAE,OAAO,IAAI,CAAA;IAC7G,MAAM,WAAW,GAAG,gBAAgB,CAAC,aAAa,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;IAC/E,yGAAyG;IACzG,iGAAiG;IACjG,MAAM,aAAa,GAAG,MAAM,GAAG,CAAC,cAAc,CAAC,EAAE,GAAG,gBAAgB,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAA;IACvG,IAAI,aAAa,IAAI,IAAI,EAAE,CAAC;QAC1B,MAAM,IAAI,iBAAS,CAAC,yBAAyB,EAAE,+CAA+C,WAAW,EAAE,CAAC,CAAA;IAC9G,CAAC;IACD,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAA;IAC9C,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,iBAAiB,CAAC,6DAA6D,OAAO,EAAE,CAAC,CAAA;IAC/G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E,CAAC,CAAA;IAC/D,CAAC;IACD,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;AAC3B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pnpm/resolving.deno-resolver",
|
|
3
|
+
"version": "1000.0.0",
|
|
4
|
+
"description": "Resolves the Deno runtime",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pnpm",
|
|
7
|
+
"pnpm10",
|
|
8
|
+
"deno",
|
|
9
|
+
"runtime"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"funding": "https://opencollective.com/pnpm",
|
|
13
|
+
"repository": "https://github.com/pnpm/pnpm/blob/main/resolving/deno-resolver",
|
|
14
|
+
"homepage": "https://github.com/pnpm/pnpm/blob/main/resolving/deno-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/crypto.shasums-file": "1001.0.0",
|
|
33
|
+
"@pnpm/fetcher-base": "1001.0.0",
|
|
34
|
+
"@pnpm/error": "1000.0.4",
|
|
35
|
+
"@pnpm/fetching-types": "1000.2.0",
|
|
36
|
+
"@pnpm/node.fetcher": "1001.0.0",
|
|
37
|
+
"@pnpm/npm-resolver": "1004.1.3",
|
|
38
|
+
"@pnpm/resolver-base": "1005.0.0",
|
|
39
|
+
"@pnpm/fetching.binary-fetcher": "1000.0.0",
|
|
40
|
+
"@pnpm/types": "1000.7.0",
|
|
41
|
+
"@pnpm/worker": "1000.1.11"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/semver": "7.5.3",
|
|
45
|
+
"@pnpm/resolving.deno-resolver": "1000.0.0"
|
|
46
|
+
},
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=18.12"
|
|
49
|
+
},
|
|
50
|
+
"jest": {
|
|
51
|
+
"preset": "@pnpm/jest-config"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"lint": "eslint \"src/**/*.ts\"",
|
|
55
|
+
"test": "pnpm run compile",
|
|
56
|
+
"compile": "tsc --build && pnpm run lint --fix"
|
|
57
|
+
}
|
|
58
|
+
}
|