@pnpm/resolving.npm-resolver 1102.1.3 → 1102.1.4
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/CHANGELOG.md +7 -0
- package/package.json +6 -6
- package/lib/clearMeta.d.ts +0 -16
- package/lib/clearMeta.js +0 -55
- package/lib/createNpmResolutionVerifier.d.ts +0 -89
- package/lib/createNpmResolutionVerifier.js +0 -724
- package/lib/fetch.d.ts +0 -37
- package/lib/fetch.js +0 -224
- package/lib/fetchAttestationPublishedAt.d.ts +0 -31
- package/lib/fetchAttestationPublishedAt.js +0 -99
- package/lib/fetchFullMetadataCached.d.ts +0 -33
- package/lib/fetchFullMetadataCached.js +0 -63
- package/lib/index.d.ts +0 -133
- package/lib/memoizeFetchMetadata.d.ts +0 -24
- package/lib/memoizeFetchMetadata.js +0 -37
- package/lib/normalizeRegistryUrl.d.ts +0 -4
- package/lib/normalizeRegistryUrl.js +0 -12
- package/lib/parseBareSpecifier.d.ts +0 -16
- package/lib/parseBareSpecifier.js +0 -143
- package/lib/pickPackage.d.ts +0 -109
- package/lib/pickPackage.js +0 -631
- package/lib/pickPackageFromMeta.d.ts +0 -20
- package/lib/pickPackageFromMeta.js +0 -227
- package/lib/toRaw.d.ts +0 -2
- package/lib/toRaw.js +0 -4
- package/lib/trustChecks.d.ts +0 -9
- package/lib/trustChecks.js +0 -96
- package/lib/violationCodes.d.ts +0 -14
- package/lib/violationCodes.js +0 -15
- package/lib/whichVersionIsPinned.d.ts +0 -2
- package/lib/whichVersionIsPinned.js +0 -36
- package/lib/workspacePrefToNpm.d.ts +0 -1
- package/lib/workspacePrefToNpm.js +0 -13
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import util from 'node:util';
|
|
2
|
-
import { PnpmError } from '@pnpm/error';
|
|
3
|
-
import { filterPkgMetadataByPublishDate } from '@pnpm/resolving.registry.pkg-metadata-filter';
|
|
4
|
-
import semver from 'semver';
|
|
5
|
-
export function pickPackageFromMeta(pickVersionByVersionRangeFn, { preferredVersionSelectors, publishedBy, publishedByExclude, }, meta, spec) {
|
|
6
|
-
if (publishedBy) {
|
|
7
|
-
const excludeResult = publishedByExclude?.(meta.name) ?? false;
|
|
8
|
-
if (excludeResult !== true) {
|
|
9
|
-
if (meta.time != null) {
|
|
10
|
-
// Full metadata with per-version timestamps: filter normally
|
|
11
|
-
assertMetaHasTime(meta);
|
|
12
|
-
const trustedVersions = Array.isArray(excludeResult) ? excludeResult : undefined;
|
|
13
|
-
meta = filterPkgMetadataByPublishDate(meta, publishedBy, trustedVersions);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
const modifiedDate = parseModifiedDate(meta.modified);
|
|
17
|
-
if (modifiedDate == null || modifiedDate > publishedBy) {
|
|
18
|
-
// Abbreviated metadata without per-version timestamps, and the package
|
|
19
|
-
// was recently modified (or has no/invalid modified field). We cannot determine
|
|
20
|
-
// which individual versions are mature enough — need full metadata.
|
|
21
|
-
assertMetaHasTime(meta);
|
|
22
|
-
}
|
|
23
|
-
// else: meta.modified <= publishedBy — every version was published at or
|
|
24
|
-
// before the cutoff (modified is an upper bound on per-version time), so
|
|
25
|
-
// they all pass the per-version `<=` maturity filter and no filtering is
|
|
26
|
-
// needed. Inclusive at the boundary on purpose so this branch matches the
|
|
27
|
-
// per-version filter in `filterPkgMetadataByPublishDate`.
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
if ((!meta.versions || Object.keys(meta.versions).length === 0) && !publishedBy) {
|
|
32
|
-
// Unfortunately, the npm registry doesn't return the time field in the abbreviated metadata.
|
|
33
|
-
// So we won't always know if the package was unpublished.
|
|
34
|
-
if (meta.time?.unpublished?.versions?.length) {
|
|
35
|
-
throw new PnpmError('UNPUBLISHED_PKG', `No versions available for ${spec.name} because it was unpublished`);
|
|
36
|
-
}
|
|
37
|
-
throw new PnpmError('NO_VERSIONS', `No versions available for ${spec.name}. The package may be unpublished.`);
|
|
38
|
-
}
|
|
39
|
-
try {
|
|
40
|
-
let version;
|
|
41
|
-
switch (spec.type) {
|
|
42
|
-
case 'version':
|
|
43
|
-
version = spec.fetchSpec;
|
|
44
|
-
break;
|
|
45
|
-
case 'tag':
|
|
46
|
-
version = meta['dist-tags'][spec.fetchSpec];
|
|
47
|
-
break;
|
|
48
|
-
case 'range':
|
|
49
|
-
version = pickVersionByVersionRangeFn({
|
|
50
|
-
meta,
|
|
51
|
-
versionRange: spec.fetchSpec,
|
|
52
|
-
preferredVersionSelectors,
|
|
53
|
-
publishedBy,
|
|
54
|
-
});
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
if (!version)
|
|
58
|
-
return null;
|
|
59
|
-
const manifest = meta.versions[version];
|
|
60
|
-
if (manifest && meta['name']) {
|
|
61
|
-
// Packages that are published to the GitHub registry are always published with a scope.
|
|
62
|
-
// However, the name in the package.json for some reason may omit the scope.
|
|
63
|
-
// So the package published to the GitHub registry will be published under @foo/bar
|
|
64
|
-
// but the name in package.json will be just bar.
|
|
65
|
-
// In order to avoid issues, we consider that the real name of the package is the one with the scope.
|
|
66
|
-
manifest.name = meta['name'];
|
|
67
|
-
}
|
|
68
|
-
return manifest;
|
|
69
|
-
}
|
|
70
|
-
catch (err) {
|
|
71
|
-
if (util.types.isNativeError(err) &&
|
|
72
|
-
'code' in err &&
|
|
73
|
-
typeof err.code === 'string' &&
|
|
74
|
-
err.code.startsWith('ERR_PNPM_')) {
|
|
75
|
-
throw err;
|
|
76
|
-
}
|
|
77
|
-
throw new PnpmError('MALFORMED_METADATA', `Received malformed metadata for "${spec.name}"`, { hint: 'This might mean that the package was unpublished from the registry', cause: err });
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
export function assertMetaHasTime(meta) {
|
|
81
|
-
if (meta.time == null) {
|
|
82
|
-
throw new PnpmError('MISSING_TIME', `The metadata of ${meta.name} is missing the "time" field`);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
function parseModifiedDate(modified) {
|
|
86
|
-
if (!modified)
|
|
87
|
-
return null;
|
|
88
|
-
const date = new Date(modified);
|
|
89
|
-
if (Number.isNaN(date.getTime()))
|
|
90
|
-
return null;
|
|
91
|
-
return date;
|
|
92
|
-
}
|
|
93
|
-
const semverRangeCache = new Map();
|
|
94
|
-
// This is a performance optimization; working with string-ish semver
|
|
95
|
-
// causes lots of allocations and repeated work, but caching the Range
|
|
96
|
-
// and ensuring we give it a SemVer instance greatly speeds things up.
|
|
97
|
-
function semverSatisfiesLoose(version, range) {
|
|
98
|
-
let semverRange = semverRangeCache.get(range);
|
|
99
|
-
if (semverRange === undefined) {
|
|
100
|
-
try {
|
|
101
|
-
semverRange = new semver.Range(range, true);
|
|
102
|
-
}
|
|
103
|
-
catch {
|
|
104
|
-
semverRange = null;
|
|
105
|
-
}
|
|
106
|
-
semverRangeCache.set(range, semverRange);
|
|
107
|
-
}
|
|
108
|
-
if (semverRange) {
|
|
109
|
-
try {
|
|
110
|
-
return semverRange.test(new semver.SemVer(version, true));
|
|
111
|
-
}
|
|
112
|
-
catch {
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
export function pickLowestVersionByVersionRange({ meta, versionRange, preferredVersionSelectors }) {
|
|
119
|
-
if (preferredVersionSelectors != null && Object.keys(preferredVersionSelectors).length > 0) {
|
|
120
|
-
const prioritizedPreferredVersions = prioritizePreferredVersions(meta, versionRange, preferredVersionSelectors);
|
|
121
|
-
for (const preferredVersions of prioritizedPreferredVersions) {
|
|
122
|
-
const preferredVersion = semver.minSatisfying(preferredVersions, versionRange, true);
|
|
123
|
-
if (preferredVersion) {
|
|
124
|
-
return preferredVersion;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
if (versionRange === '*') {
|
|
129
|
-
return Object.keys(meta.versions).sort(semver.compare)[0];
|
|
130
|
-
}
|
|
131
|
-
return semver.minSatisfying(Object.keys(meta.versions), versionRange, true);
|
|
132
|
-
}
|
|
133
|
-
export function pickVersionByVersionRange({ meta, versionRange, preferredVersionSelectors }) {
|
|
134
|
-
const latest = meta['dist-tags'].latest;
|
|
135
|
-
if (preferredVersionSelectors != null && Object.keys(preferredVersionSelectors).length > 0) {
|
|
136
|
-
const prioritizedPreferredVersions = prioritizePreferredVersions(meta, versionRange, preferredVersionSelectors);
|
|
137
|
-
for (const preferredVersions of prioritizedPreferredVersions) {
|
|
138
|
-
if (preferredVersions.includes(latest) && semverSatisfiesLoose(latest, versionRange)) {
|
|
139
|
-
return latest;
|
|
140
|
-
}
|
|
141
|
-
const preferredVersion = semver.maxSatisfying(preferredVersions, versionRange, true);
|
|
142
|
-
if (preferredVersion) {
|
|
143
|
-
return preferredVersion;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
const versions = Object.keys(meta.versions);
|
|
148
|
-
if (latest && (versionRange === '*' || semverSatisfiesLoose(latest, versionRange))) {
|
|
149
|
-
// Not using semver.satisfies in case of * because it does not select beta versions.
|
|
150
|
-
// E.g.: 1.0.0-beta.1. See issue: https://github.com/pnpm/pnpm/issues/865
|
|
151
|
-
return latest;
|
|
152
|
-
}
|
|
153
|
-
const maxVersion = semver.maxSatisfying(versions, versionRange, true);
|
|
154
|
-
// if the selected version is deprecated, try to find a non-deprecated one that satisfies the range
|
|
155
|
-
if (maxVersion && meta.versions[maxVersion].deprecated && versions.length > 1) {
|
|
156
|
-
const nonDeprecatedVersions = versions.map((version) => meta.versions[version])
|
|
157
|
-
.filter((versionMeta) => !versionMeta.deprecated)
|
|
158
|
-
.map((versionMeta) => versionMeta.version);
|
|
159
|
-
const maxNonDeprecatedVersion = semver.maxSatisfying(nonDeprecatedVersions, versionRange, true);
|
|
160
|
-
if (maxNonDeprecatedVersion)
|
|
161
|
-
return maxNonDeprecatedVersion;
|
|
162
|
-
}
|
|
163
|
-
return maxVersion;
|
|
164
|
-
}
|
|
165
|
-
function prioritizePreferredVersions(meta, versionRange, preferredVerSelectors) {
|
|
166
|
-
const preferredVerSelectorsArr = Object.entries(preferredVerSelectors ?? {});
|
|
167
|
-
const versionsPrioritizer = new PreferredVersionsPrioritizer();
|
|
168
|
-
// First, add all versions that satisfy versionRange with default weight 0
|
|
169
|
-
for (const version of Object.keys(meta.versions)) {
|
|
170
|
-
if (semverSatisfiesLoose(version, versionRange)) {
|
|
171
|
-
versionsPrioritizer.add(version, 0);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
// Then apply weights from preferred selectors
|
|
175
|
-
for (const [preferredSelector, preferredSelectorType] of preferredVerSelectorsArr) {
|
|
176
|
-
const { selectorType, weight } = typeof preferredSelectorType === 'string'
|
|
177
|
-
? { selectorType: preferredSelectorType, weight: 1 }
|
|
178
|
-
: preferredSelectorType;
|
|
179
|
-
if (preferredSelector === versionRange)
|
|
180
|
-
continue;
|
|
181
|
-
switch (selectorType) {
|
|
182
|
-
case 'tag': {
|
|
183
|
-
versionsPrioritizer.add(meta['dist-tags'][preferredSelector], weight);
|
|
184
|
-
break;
|
|
185
|
-
}
|
|
186
|
-
case 'range': {
|
|
187
|
-
const versions = Object.keys(meta.versions);
|
|
188
|
-
for (const version of versions) {
|
|
189
|
-
if (semverSatisfiesLoose(version, preferredSelector)) {
|
|
190
|
-
versionsPrioritizer.add(version, weight);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
break;
|
|
194
|
-
}
|
|
195
|
-
case 'version': {
|
|
196
|
-
if (meta.versions[preferredSelector]) {
|
|
197
|
-
versionsPrioritizer.add(preferredSelector, weight);
|
|
198
|
-
}
|
|
199
|
-
break;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
return versionsPrioritizer.versionsByPriority();
|
|
204
|
-
}
|
|
205
|
-
class PreferredVersionsPrioritizer {
|
|
206
|
-
preferredVersions = {};
|
|
207
|
-
add(version, weight) {
|
|
208
|
-
if (!this.preferredVersions[version]) {
|
|
209
|
-
this.preferredVersions[version] = weight;
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
this.preferredVersions[version] += weight;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
versionsByPriority() {
|
|
216
|
-
const versionsByWeight = Object.entries(this.preferredVersions)
|
|
217
|
-
.reduce((acc, [version, weight]) => {
|
|
218
|
-
acc[weight] = acc[weight] ?? [];
|
|
219
|
-
acc[weight].push(version);
|
|
220
|
-
return acc;
|
|
221
|
-
}, {});
|
|
222
|
-
return Object.keys(versionsByWeight)
|
|
223
|
-
.sort((a, b) => parseInt(b, 10) - parseInt(a, 10))
|
|
224
|
-
.map((weight) => versionsByWeight[parseInt(weight, 10)]);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
//# sourceMappingURL=pickPackageFromMeta.js.map
|
package/lib/toRaw.d.ts
DELETED
package/lib/toRaw.js
DELETED
package/lib/trustChecks.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { PackageInRegistry, PackageMeta } from '@pnpm/resolving.registry.types';
|
|
2
|
-
import type { PackageVersionPolicy } from '@pnpm/types';
|
|
3
|
-
type TrustEvidence = 'provenance' | 'trustedPublisher' | 'stagedPublish';
|
|
4
|
-
export declare function failIfTrustDowngraded(meta: PackageMeta, version: string, opts?: {
|
|
5
|
-
trustPolicyExclude?: PackageVersionPolicy;
|
|
6
|
-
trustPolicyIgnoreAfter?: number;
|
|
7
|
-
}): void;
|
|
8
|
-
export declare function getTrustEvidence(manifest: PackageInRegistry): TrustEvidence | undefined;
|
|
9
|
-
export {};
|
package/lib/trustChecks.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { PnpmError } from '@pnpm/error';
|
|
2
|
-
import semver from 'semver';
|
|
3
|
-
import { assertMetaHasTime } from './pickPackageFromMeta.js';
|
|
4
|
-
const TRUST_RANK = {
|
|
5
|
-
stagedPublish: 3,
|
|
6
|
-
trustedPublisher: 2,
|
|
7
|
-
provenance: 1,
|
|
8
|
-
};
|
|
9
|
-
export function failIfTrustDowngraded(meta, version, opts) {
|
|
10
|
-
if (opts?.trustPolicyExclude) {
|
|
11
|
-
const excludeResult = opts.trustPolicyExclude(meta.name);
|
|
12
|
-
if (excludeResult === true) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
if (Array.isArray(excludeResult) && excludeResult.includes(version)) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
assertMetaHasTime(meta);
|
|
20
|
-
const versionPublishedAt = meta.time[version];
|
|
21
|
-
if (!versionPublishedAt) {
|
|
22
|
-
throw new PnpmError('TRUST_CHECK_FAIL', `Missing time for version ${version} of ${meta.name} in metadata`);
|
|
23
|
-
}
|
|
24
|
-
const versionDate = new Date(versionPublishedAt);
|
|
25
|
-
if (opts?.trustPolicyIgnoreAfter) {
|
|
26
|
-
const now = new Date();
|
|
27
|
-
const minutesSincePublish = (now.getTime() - versionDate.getTime()) / (1000 * 60);
|
|
28
|
-
if (minutesSincePublish > opts.trustPolicyIgnoreAfter) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
const manifest = meta.versions[version];
|
|
33
|
-
if (!manifest) {
|
|
34
|
-
throw new PnpmError('TRUST_CHECK_FAIL', `Missing version object for version ${version} of ${meta.name} in metadata`);
|
|
35
|
-
}
|
|
36
|
-
const strongestEvidencePriorToRequestedVersion = detectStrongestTrustEvidenceBeforeDate(meta, versionDate, {
|
|
37
|
-
excludePrerelease: !semver.prerelease(version, true),
|
|
38
|
-
});
|
|
39
|
-
if (strongestEvidencePriorToRequestedVersion == null) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const currentTrustEvidence = getTrustEvidence(manifest);
|
|
43
|
-
if (currentTrustEvidence == null || TRUST_RANK[strongestEvidencePriorToRequestedVersion] > TRUST_RANK[currentTrustEvidence]) {
|
|
44
|
-
throw new PnpmError('TRUST_DOWNGRADE', `High-risk trust downgrade for "${meta.name}@${version}" (possible package takeover)`, {
|
|
45
|
-
hint: 'Trust checks are based solely on publish date, not semver. ' +
|
|
46
|
-
'A package cannot be installed if any earlier-published version had stronger trust evidence. ' +
|
|
47
|
-
`Earlier versions had ${prettyPrintTrustEvidence(strongestEvidencePriorToRequestedVersion)}, ` +
|
|
48
|
-
`but this version has ${prettyPrintTrustEvidence(currentTrustEvidence)}. ` +
|
|
49
|
-
'A trust downgrade may indicate a supply chain incident.',
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function prettyPrintTrustEvidence(trustEvidence) {
|
|
54
|
-
switch (trustEvidence) {
|
|
55
|
-
case 'stagedPublish': return 'staged publish';
|
|
56
|
-
case 'trustedPublisher': return 'trusted publisher';
|
|
57
|
-
case 'provenance': return 'provenance attestation';
|
|
58
|
-
default: return 'no trust evidence';
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
function detectStrongestTrustEvidenceBeforeDate(meta, beforeDate, options) {
|
|
62
|
-
let best;
|
|
63
|
-
for (const [version, manifest] of Object.entries(meta.versions)) {
|
|
64
|
-
if (options.excludePrerelease && semver.prerelease(version, true))
|
|
65
|
-
continue;
|
|
66
|
-
const ts = meta.time[version];
|
|
67
|
-
if (!ts)
|
|
68
|
-
continue;
|
|
69
|
-
const publishedAt = new Date(ts);
|
|
70
|
-
if (!(publishedAt < beforeDate))
|
|
71
|
-
continue;
|
|
72
|
-
const trustEvidence = getTrustEvidence(manifest);
|
|
73
|
-
if (!trustEvidence)
|
|
74
|
-
continue;
|
|
75
|
-
if (best === undefined || TRUST_RANK[trustEvidence] > TRUST_RANK[best]) {
|
|
76
|
-
best = trustEvidence;
|
|
77
|
-
if (best === 'stagedPublish') {
|
|
78
|
-
return best;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return best;
|
|
83
|
-
}
|
|
84
|
-
export function getTrustEvidence(manifest) {
|
|
85
|
-
if (manifest._npmUser?.approver) {
|
|
86
|
-
return 'stagedPublish';
|
|
87
|
-
}
|
|
88
|
-
if (manifest._npmUser?.trustedPublisher && manifest.dist?.attestations?.provenance) {
|
|
89
|
-
return 'trustedPublisher';
|
|
90
|
-
}
|
|
91
|
-
if (manifest.dist?.attestations?.provenance) {
|
|
92
|
-
return 'provenance';
|
|
93
|
-
}
|
|
94
|
-
return undefined;
|
|
95
|
-
}
|
|
96
|
-
//# sourceMappingURL=trustChecks.js.map
|
package/lib/violationCodes.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Violation codes the npm resolver attaches to
|
|
3
|
-
* `ResolutionPolicyViolation.code` when an inline policy check rejects
|
|
4
|
-
* a pick. Exported so downstream code (the install command, the strict
|
|
5
|
-
* resolver wrapper, tests) references one source of truth instead of
|
|
6
|
-
* re-typing the string.
|
|
7
|
-
*
|
|
8
|
-
* Lives in its own module — both `index.ts` and `createNpmResolutionVerifier.ts`
|
|
9
|
-
* import it, so keeping the constants here avoids a cycle.
|
|
10
|
-
*/
|
|
11
|
-
export declare const MINIMUM_RELEASE_AGE_VIOLATION_CODE = "MINIMUM_RELEASE_AGE_VIOLATION";
|
|
12
|
-
export declare const TRUST_DOWNGRADE_VIOLATION_CODE = "TRUST_DOWNGRADE";
|
|
13
|
-
export declare const TARBALL_URL_MISMATCH_VIOLATION_CODE = "TARBALL_URL_MISMATCH";
|
|
14
|
-
export declare const MISSING_TARBALL_INTEGRITY_VIOLATION_CODE = "MISSING_TARBALL_INTEGRITY";
|
package/lib/violationCodes.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Violation codes the npm resolver attaches to
|
|
3
|
-
* `ResolutionPolicyViolation.code` when an inline policy check rejects
|
|
4
|
-
* a pick. Exported so downstream code (the install command, the strict
|
|
5
|
-
* resolver wrapper, tests) references one source of truth instead of
|
|
6
|
-
* re-typing the string.
|
|
7
|
-
*
|
|
8
|
-
* Lives in its own module — both `index.ts` and `createNpmResolutionVerifier.ts`
|
|
9
|
-
* import it, so keeping the constants here avoids a cycle.
|
|
10
|
-
*/
|
|
11
|
-
export const MINIMUM_RELEASE_AGE_VIOLATION_CODE = 'MINIMUM_RELEASE_AGE_VIOLATION';
|
|
12
|
-
export const TRUST_DOWNGRADE_VIOLATION_CODE = 'TRUST_DOWNGRADE';
|
|
13
|
-
export const TARBALL_URL_MISMATCH_VIOLATION_CODE = 'TARBALL_URL_MISMATCH';
|
|
14
|
-
export const MISSING_TARBALL_INTEGRITY_VIOLATION_CODE = 'MISSING_TARBALL_INTEGRITY';
|
|
15
|
-
//# sourceMappingURL=violationCodes.js.map
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { parseRange } from 'semver-utils';
|
|
2
|
-
export function whichVersionIsPinned(spec) {
|
|
3
|
-
// A catalog reference carries no version pinning of its own; the pinning is
|
|
4
|
-
// defined by the catalog entry it points to. Bail out so a catalog name that
|
|
5
|
-
// happens to look like a version (e.g. "catalog:express4-21") isn't misread
|
|
6
|
-
// as a pinned version.
|
|
7
|
-
if (spec.startsWith('catalog:'))
|
|
8
|
-
return undefined;
|
|
9
|
-
const colonIndex = spec.indexOf(':');
|
|
10
|
-
if (colonIndex !== -1) {
|
|
11
|
-
spec = spec.substring(colonIndex + 1);
|
|
12
|
-
}
|
|
13
|
-
const index = spec.lastIndexOf('@');
|
|
14
|
-
if (index !== -1) {
|
|
15
|
-
spec = spec.slice(index + 1);
|
|
16
|
-
}
|
|
17
|
-
if (spec === '*')
|
|
18
|
-
return 'none';
|
|
19
|
-
const parsedRange = parseRange(spec);
|
|
20
|
-
if (parsedRange.length !== 1)
|
|
21
|
-
return undefined;
|
|
22
|
-
const versionObject = parsedRange[0];
|
|
23
|
-
switch (versionObject.operator) {
|
|
24
|
-
case '~': return 'minor';
|
|
25
|
-
case '^': return 'major';
|
|
26
|
-
case undefined:
|
|
27
|
-
if (versionObject.patch)
|
|
28
|
-
return 'patch';
|
|
29
|
-
if (versionObject.minor)
|
|
30
|
-
return 'minor';
|
|
31
|
-
if (versionObject.major)
|
|
32
|
-
return 'major';
|
|
33
|
-
}
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=whichVersionIsPinned.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function workspacePrefToNpm(workspaceBareSpecifier: string): string;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { WorkspaceSpec } from '@pnpm/workspace.spec-parser';
|
|
2
|
-
export function workspacePrefToNpm(workspaceBareSpecifier) {
|
|
3
|
-
const parseResult = WorkspaceSpec.parse(workspaceBareSpecifier);
|
|
4
|
-
if (parseResult == null) {
|
|
5
|
-
throw new Error(`Invalid workspace spec: ${workspaceBareSpecifier}`);
|
|
6
|
-
}
|
|
7
|
-
const { alias, version } = parseResult;
|
|
8
|
-
const versionPart = version === '^' || version === '~' || version === '' ? '*' : version;
|
|
9
|
-
return alias
|
|
10
|
-
? `npm:${alias}@${versionPart}`
|
|
11
|
-
: versionPart;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=workspacePrefToNpm.js.map
|