@pnpm/engine.runtime.node-resolver 1101.1.7 → 1101.1.9
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/lib/index.js +24 -4
- package/package.json +10 -10
package/lib/index.js
CHANGED
|
@@ -25,7 +25,7 @@ export async function resolveNodeRuntime(ctx, wantedDependency, opts) {
|
|
|
25
25
|
}
|
|
26
26
|
if (ctx.offline)
|
|
27
27
|
throw new PnpmError('NO_OFFLINE_NODEJS_RESOLUTION', 'Offline Node.js resolution is not supported');
|
|
28
|
-
const versionSpec = wantedDependency.bareSpecifier.substring('runtime:'.length);
|
|
28
|
+
const versionSpec = normalizeRuntimeSpec(wantedDependency.bareSpecifier.substring('runtime:'.length));
|
|
29
29
|
const { releaseChannel, versionSpecifier } = parseNodeSpecifier(versionSpec);
|
|
30
30
|
const nodeMirrorBaseUrl = getNodeMirror(ctx.nodeDownloadMirrors, releaseChannel);
|
|
31
31
|
const version = await resolveNodeVersion(ctx.fetchFromRegistry, versionSpecifier, nodeMirrorBaseUrl);
|
|
@@ -33,7 +33,7 @@ export async function resolveNodeRuntime(ctx, wantedDependency, opts) {
|
|
|
33
33
|
throw new PnpmError('NODEJS_VERSION_NOT_FOUND', `Could not find a Node.js version that satisfies ${versionSpec}`);
|
|
34
34
|
}
|
|
35
35
|
const variants = await readNodeAssets(ctx.fetchFromRegistry, nodeMirrorBaseUrl, version, releaseChannel);
|
|
36
|
-
const range =
|
|
36
|
+
const range = createNodeRuntimeVersionSpec(versionSpec, version, wantedDependency);
|
|
37
37
|
return {
|
|
38
38
|
id: `node@runtime:${version}`,
|
|
39
39
|
normalizedBareSpecifier: `runtime:${range}`,
|
|
@@ -53,7 +53,7 @@ export async function resolveLatestNodeRuntime(ctx, query, _opts) {
|
|
|
53
53
|
const manifestSpec = query.wantedDependency.bareSpecifier;
|
|
54
54
|
if (query.wantedDependency.alias !== 'node' || !manifestSpec?.startsWith('runtime:'))
|
|
55
55
|
return undefined;
|
|
56
|
-
const versionSpec = query.compatible ? manifestSpec.substring('runtime:'.length) : 'latest';
|
|
56
|
+
const versionSpec = query.compatible ? normalizeRuntimeSpec(manifestSpec.substring('runtime:'.length)) : 'latest';
|
|
57
57
|
const { releaseChannel, versionSpecifier } = parseNodeSpecifier(versionSpec);
|
|
58
58
|
const nodeMirrorBaseUrl = getNodeMirror(ctx.nodeDownloadMirrors, releaseChannel);
|
|
59
59
|
const version = await resolveNodeVersion(ctx.fetchFromRegistry, versionSpecifier, nodeMirrorBaseUrl);
|
|
@@ -61,6 +61,20 @@ export async function resolveLatestNodeRuntime(ctx, query, _opts) {
|
|
|
61
61
|
return {};
|
|
62
62
|
return { latestManifest: { name: 'node', version } };
|
|
63
63
|
}
|
|
64
|
+
function createNodeRuntimeVersionSpec(versionSpec, resolvedVersion, wantedDependency) {
|
|
65
|
+
if (resolvedVersion === versionSpec || semver.parse(resolvedVersion)?.prerelease.length) {
|
|
66
|
+
return resolvedVersion;
|
|
67
|
+
}
|
|
68
|
+
const source = wantedDependency.prevSpecifier?.startsWith('runtime:')
|
|
69
|
+
? wantedDependency.prevSpecifier.substring('runtime:'.length)
|
|
70
|
+
: versionSpec;
|
|
71
|
+
const spec = source.includes('/') ? source.split('/', 2)[1] : source;
|
|
72
|
+
if (spec.startsWith('^'))
|
|
73
|
+
return `^${resolvedVersion}`;
|
|
74
|
+
if (spec.startsWith('~'))
|
|
75
|
+
return `~${resolvedVersion}`;
|
|
76
|
+
return resolvedVersion;
|
|
77
|
+
}
|
|
64
78
|
async function readNodeAssets(fetch, nodeMirrorBaseUrl, version, releaseChannel) {
|
|
65
79
|
// The mirror is repository-configurable, so the SHASUMS file's hashes are only
|
|
66
80
|
// trustworthy once its OpenPGP signature is verified against the Node.js
|
|
@@ -142,6 +156,7 @@ const SEMVER_OPTS = {
|
|
|
142
156
|
};
|
|
143
157
|
export async function resolveNodeVersion(fetch, versionSpec, nodeMirrorBaseUrl) {
|
|
144
158
|
const allVersions = await fetchAllVersions(fetch, nodeMirrorBaseUrl);
|
|
159
|
+
versionSpec = normalizeRuntimeSpec(versionSpec);
|
|
145
160
|
if (versionSpec === 'latest') {
|
|
146
161
|
return allVersions[0].version;
|
|
147
162
|
}
|
|
@@ -150,15 +165,20 @@ export async function resolveNodeVersion(fetch, versionSpec, nodeMirrorBaseUrl)
|
|
|
150
165
|
}
|
|
151
166
|
export async function resolveNodeVersions(fetch, versionSpec, nodeMirrorBaseUrl) {
|
|
152
167
|
const allVersions = await fetchAllVersions(fetch, nodeMirrorBaseUrl);
|
|
153
|
-
if (
|
|
168
|
+
if (versionSpec == null) {
|
|
154
169
|
return allVersions.map(({ version }) => version);
|
|
155
170
|
}
|
|
171
|
+
versionSpec = normalizeRuntimeSpec(versionSpec);
|
|
156
172
|
if (versionSpec === 'latest') {
|
|
157
173
|
return [allVersions[0].version];
|
|
158
174
|
}
|
|
159
175
|
const { versions, versionRange } = filterVersions(allVersions, versionSpec);
|
|
160
176
|
return versions.filter(version => semver.satisfies(version, versionRange, SEMVER_OPTS));
|
|
161
177
|
}
|
|
178
|
+
function normalizeRuntimeSpec(versionSpec) {
|
|
179
|
+
versionSpec = versionSpec.trim();
|
|
180
|
+
return versionSpec === '' ? 'latest' : versionSpec;
|
|
181
|
+
}
|
|
162
182
|
async function fetchAllVersions(fetch, nodeMirrorBaseUrl) {
|
|
163
183
|
const response = await fetch(`${nodeMirrorBaseUrl ?? 'https://nodejs.org/download/release/'}index.json`);
|
|
164
184
|
return (await response.json()).map(({ version, lts }) => ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/engine.runtime.node-resolver",
|
|
3
|
-
"version": "1101.1.
|
|
3
|
+
"version": "1101.1.9",
|
|
4
4
|
"description": "Resolves a Node.js version specifier to an exact Node.js version",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"funding": "https://opencollective.com/pnpm",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "https://github.com/pnpm/pnpm/tree/main/engine/runtime/node-resolver"
|
|
15
|
+
"url": "https://github.com/pnpm/pnpm/tree/main/pnpm11/engine/runtime/node-resolver"
|
|
16
16
|
},
|
|
17
|
-
"homepage": "https://github.com/pnpm/pnpm/tree/main/engine/runtime/node-resolver#readme",
|
|
17
|
+
"homepage": "https://github.com/pnpm/pnpm/tree/main/pnpm11/engine/runtime/node-resolver#readme",
|
|
18
18
|
"bugs": {
|
|
19
19
|
"url": "https://github.com/pnpm/pnpm/issues"
|
|
20
20
|
},
|
|
@@ -31,18 +31,18 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"semver": "^7.8.4",
|
|
33
33
|
"version-selector-type": "^3.0.0",
|
|
34
|
-
"@pnpm/
|
|
35
|
-
"@pnpm/
|
|
34
|
+
"@pnpm/error": "1100.0.1",
|
|
35
|
+
"@pnpm/config.reader": "1101.10.1",
|
|
36
36
|
"@pnpm/fetching.types": "1100.0.2",
|
|
37
|
-
"@pnpm/
|
|
38
|
-
"@pnpm/
|
|
39
|
-
"@pnpm/
|
|
37
|
+
"@pnpm/resolving.resolver-base": "1100.5.0",
|
|
38
|
+
"@pnpm/types": "1101.3.2",
|
|
39
|
+
"@pnpm/crypto.shasums-file": "1100.1.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@jest/globals": "30.4.1",
|
|
43
43
|
"@types/semver": "7.7.1",
|
|
44
|
-
"@pnpm/network.fetch": "1100.1.
|
|
45
|
-
"@pnpm/engine.runtime.node-resolver": "1101.1.
|
|
44
|
+
"@pnpm/network.fetch": "1100.1.4",
|
|
45
|
+
"@pnpm/engine.runtime.node-resolver": "1101.1.9"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
48
|
"node": ">=22.13"
|