@pnpm/installing.deps-installer 1012.0.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/LICENSE +22 -0
- package/README.md +259 -0
- package/lib/api.d.ts +3 -0
- package/lib/api.js +4 -0
- package/lib/getPeerDependencyIssues.d.ts +5 -0
- package/lib/getPeerDependencyIssues.js +70 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +5 -0
- package/lib/install/checkCompatibility/BreakingChangeError.d.ts +12 -0
- package/lib/install/checkCompatibility/BreakingChangeError.js +13 -0
- package/lib/install/checkCompatibility/CatalogVersionMismatchError.d.ts +9 -0
- package/lib/install/checkCompatibility/CatalogVersionMismatchError.js +11 -0
- package/lib/install/checkCompatibility/ErrorRelatedSources.d.ts +5 -0
- package/lib/install/checkCompatibility/ErrorRelatedSources.js +2 -0
- package/lib/install/checkCompatibility/ModulesBreakingChangeError.d.ts +9 -0
- package/lib/install/checkCompatibility/ModulesBreakingChangeError.js +15 -0
- package/lib/install/checkCompatibility/UnexpectedStoreError.d.ts +11 -0
- package/lib/install/checkCompatibility/UnexpectedStoreError.js +13 -0
- package/lib/install/checkCompatibility/UnexpectedVirtualStoreDirError.d.ts +11 -0
- package/lib/install/checkCompatibility/UnexpectedVirtualStoreDirError.js +13 -0
- package/lib/install/checkCompatibility/index.d.ts +6 -0
- package/lib/install/checkCompatibility/index.js +32 -0
- package/lib/install/checkCustomResolverForceResolve.d.ts +10 -0
- package/lib/install/checkCustomResolverForceResolve.js +47 -0
- package/lib/install/extendInstallOptions.d.ts +163 -0
- package/lib/install/extendInstallOptions.js +156 -0
- package/lib/install/index.d.ts +110 -0
- package/lib/install/index.js +1346 -0
- package/lib/install/link.d.ts +51 -0
- package/lib/install/link.js +382 -0
- package/lib/install/reportPeerDependencyIssues.d.ts +12 -0
- package/lib/install/reportPeerDependencyIssues.js +116 -0
- package/lib/install/validateModules.d.ts +26 -0
- package/lib/install/validateModules.js +135 -0
- package/lib/parseWantedDependencies.d.ts +17 -0
- package/lib/parseWantedDependencies.js +51 -0
- package/lib/pnpmPkgJson.d.ts +3 -0
- package/lib/pnpmPkgJson.js +14 -0
- package/lib/types.d.ts +2 -0
- package/lib/types.js +2 -0
- package/lib/uninstall/removeDeps.d.ts +5 -0
- package/lib/uninstall/removeDeps.js +36 -0
- package/package.json +168 -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-2026 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,259 @@
|
|
|
1
|
+
# @pnpm/core
|
|
2
|
+
|
|
3
|
+
> Fast, disk space efficient installation engine. Used by [pnpm](https://github.com/pnpm/pnpm)
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
Install it via npm.
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
pnpm add @pnpm/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
It also depends on `@pnpm/logger` version `1`, so install it as well via:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
pnpm add @pnpm/logger@1
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## API
|
|
20
|
+
|
|
21
|
+
### `mutateModules(importers, options)`
|
|
22
|
+
|
|
23
|
+
TODO
|
|
24
|
+
|
|
25
|
+
### `link(linkFromPkgs, linkToModules, [options])`
|
|
26
|
+
|
|
27
|
+
Create symbolic links from the linked packages to the target package's `node_modules` (and its `node_modules/.bin`).
|
|
28
|
+
|
|
29
|
+
**Arguments:**
|
|
30
|
+
|
|
31
|
+
* `linkFromPkgs` - *String[]* - paths to the packages that should be linked.
|
|
32
|
+
* `linkToModules` - *String* - path to the dependent package's `node_modules` directory.
|
|
33
|
+
* `options.reporter` - *Function* - A function that listens for logs.
|
|
34
|
+
|
|
35
|
+
### `linkToGlobal(linkFrom, options)`
|
|
36
|
+
|
|
37
|
+
Create a symbolic link from the specified package to the global `node_modules`.
|
|
38
|
+
|
|
39
|
+
**Arguments:**
|
|
40
|
+
|
|
41
|
+
* `linkFrom` - *String* - path to the package that should be linked.
|
|
42
|
+
* `globalDir` - *String* - path to the global directory.
|
|
43
|
+
* `options.reporter` - *Function* - A function that listens for logs.
|
|
44
|
+
|
|
45
|
+
### `linkFromGlobal(pkgNames, linkTo, options)`
|
|
46
|
+
|
|
47
|
+
Create symbolic links from the global `pkgName`s to the `linkTo/node_modules` folder.
|
|
48
|
+
|
|
49
|
+
**Arguments:**
|
|
50
|
+
|
|
51
|
+
* `pkgNames` - *String[]* - packages to link.
|
|
52
|
+
* `linkTo` - *String* - package to link to.
|
|
53
|
+
* `globalDir` - *String* - path to the global directory.
|
|
54
|
+
* `options.reporter` - *Function* - A function that listens for logs.
|
|
55
|
+
|
|
56
|
+
### `storeStatus([options])`
|
|
57
|
+
|
|
58
|
+
Return the list of modified dependencies.
|
|
59
|
+
|
|
60
|
+
**Arguments:**
|
|
61
|
+
|
|
62
|
+
* `options.reporter` - *Function* - A function that listens for logs.
|
|
63
|
+
|
|
64
|
+
**Returns:** `Promise<string[]>` - the paths to the modified packages of the current project. The paths contain the location of packages in the store,
|
|
65
|
+
not in the projects `node_modules` folder.
|
|
66
|
+
|
|
67
|
+
### `storePrune([options])`
|
|
68
|
+
|
|
69
|
+
Remove unreferenced packages from the store.
|
|
70
|
+
|
|
71
|
+
## Hooks
|
|
72
|
+
|
|
73
|
+
Hooks are functions that can step into the installation process. All hooks can be provided as arrays to register multiple hook functions.
|
|
74
|
+
|
|
75
|
+
### `readPackage(pkg: Manifest, context): Manifest | Promise<Manifest>`
|
|
76
|
+
|
|
77
|
+
This hook is called with every dependency's manifest information.
|
|
78
|
+
The modified manifest returned by this hook is then used by `@pnpm/core` during installation.
|
|
79
|
+
An async function is supported.
|
|
80
|
+
|
|
81
|
+
**Arguments:**
|
|
82
|
+
|
|
83
|
+
* `pkg` - The dependency's package manifest.
|
|
84
|
+
* `context.log(message)` - A function to log debug messages.
|
|
85
|
+
|
|
86
|
+
**Example:**
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
const { installPkgs } = require('@pnpm/core')
|
|
90
|
+
|
|
91
|
+
installPkgs({
|
|
92
|
+
hooks: {
|
|
93
|
+
readPackage: [readPackageHook]
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
function readPackageHook (pkg, context) {
|
|
98
|
+
if (pkg.name === 'foo') {
|
|
99
|
+
context.log('Modifying foo dependencies')
|
|
100
|
+
pkg.dependencies = {
|
|
101
|
+
bar: '^2.0.0',
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return pkg
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### `preResolution(context, logger): Promise<void>`
|
|
109
|
+
|
|
110
|
+
This hook is called after reading lockfiles but before resolving dependencies. It can modify lockfile objects.
|
|
111
|
+
|
|
112
|
+
**Arguments:**
|
|
113
|
+
|
|
114
|
+
* `context.wantedLockfile` - The lockfile from `pnpm-lock.yaml`.
|
|
115
|
+
* `context.currentLockfile` - The lockfile from `node_modules/.pnpm/lock.yaml`.
|
|
116
|
+
* `context.existsCurrentLockfile` - Boolean indicating if current lockfile exists.
|
|
117
|
+
* `context.existsNonEmptyWantedLockfile` - Boolean indicating if wanted lockfile exists and is not empty.
|
|
118
|
+
* `context.lockfileDir` - Directory containing the lockfile.
|
|
119
|
+
* `context.storeDir` - Location of the store directory.
|
|
120
|
+
* `context.registries` - Map of registry URLs.
|
|
121
|
+
* `logger.info(message)` - Log an informational message.
|
|
122
|
+
* `logger.warn(message)` - Log a warning message.
|
|
123
|
+
|
|
124
|
+
### `afterAllResolved(lockfile: Lockfile): Lockfile | Promise<Lockfile>`
|
|
125
|
+
|
|
126
|
+
This hook is called after all dependencies are resolved. It receives and returns the resolved lockfile object.
|
|
127
|
+
An async function is supported.
|
|
128
|
+
|
|
129
|
+
**Arguments:**
|
|
130
|
+
|
|
131
|
+
* `lockfile` - The resolved lockfile object that will be written to `pnpm-lock.yaml`.
|
|
132
|
+
|
|
133
|
+
### Custom Resolvers and Fetchers
|
|
134
|
+
|
|
135
|
+
Custom resolvers and fetchers allow you to implement custom package resolution and fetching logic for new package identifier schemes (like `my-protocol:package-name`). These are defined as top-level exports in your `.pnpmfile.cjs`:
|
|
136
|
+
|
|
137
|
+
* **Custom Resolvers**: Convert package descriptors (e.g., `foo@^1.0.0`) into resolutions
|
|
138
|
+
* **Custom Fetchers**: Completely handle fetching for custom package types
|
|
139
|
+
|
|
140
|
+
**Custom Resolver Interface:**
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
interface CustomResolver {
|
|
144
|
+
// Resolution phase
|
|
145
|
+
canResolve?: (wantedDependency: WantedDependency) => boolean | Promise<boolean>
|
|
146
|
+
resolve?: (wantedDependency: WantedDependency, opts: ResolveOptions) => ResolveResult | Promise<ResolveResult>
|
|
147
|
+
|
|
148
|
+
// Force resolution check
|
|
149
|
+
shouldRefreshResolution?: (depPath: string, pkgSnapshot: PackageSnapshot) => boolean | Promise<boolean>
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Custom Fetcher Interface:**
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
interface CustomFetcher {
|
|
157
|
+
// Fetch phase - complete fetcher replacement
|
|
158
|
+
canFetch?: (pkgId: string, resolution: Resolution) => boolean | Promise<boolean>
|
|
159
|
+
fetch?: (cafs: Cafs, resolution: Resolution, opts: FetchOptions, fetchers: Fetchers) => FetchResult | Promise<FetchResult>
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**Custom Resolver Methods:**
|
|
164
|
+
|
|
165
|
+
* `canResolve(wantedDependency)` - Returns `true` if this resolver can resolve the given package descriptor
|
|
166
|
+
* `resolve(wantedDependency, opts)` - Resolves a package descriptor to a resolution. Should return an object with `id` and `resolution`
|
|
167
|
+
* `shouldRefreshResolution(depPath, pkgSnapshot)` - Return `true` to trigger full resolution of all packages (skipping the "Lockfile is up to date" optimization). The `depPath` is the package identifier (e.g., `lodash@4.17.21`) and `pkgSnapshot` provides direct access to the lockfile entry (resolution, dependencies, etc.).
|
|
168
|
+
|
|
169
|
+
**Custom Fetcher Methods:**
|
|
170
|
+
|
|
171
|
+
* `canFetch(pkgId, resolution)` - Returns `true` if this fetcher can handle fetching for the given resolution
|
|
172
|
+
* `fetch(cafs, resolution, opts, fetchers)` - Completely handles fetching the package contents. Receives the content-addressable file system (cafs), the resolution, fetch options, and pnpm's standard fetchers for delegation. Must return a FetchResult with the package files.
|
|
173
|
+
|
|
174
|
+
**Example - Reusing pnpm's fetcher utilities:**
|
|
175
|
+
|
|
176
|
+
```js
|
|
177
|
+
// .pnpmfile.cjs
|
|
178
|
+
const customResolver = {
|
|
179
|
+
canResolve: (wantedDependency) => {
|
|
180
|
+
return wantedDependency.alias.startsWith('company-cdn:')
|
|
181
|
+
},
|
|
182
|
+
|
|
183
|
+
resolve: async (wantedDependency, opts) => {
|
|
184
|
+
const actualName = wantedDependency.alias.replace('company-cdn:', '')
|
|
185
|
+
const version = await fetchVersionFromCompanyCDN(actualName, wantedDependency.bareSpecifier)
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
id: `company-cdn:${actualName}@${version}`,
|
|
189
|
+
resolution: {
|
|
190
|
+
type: 'custom:cdn',
|
|
191
|
+
cdnUrl: `https://cdn.company.com/packages/${actualName}/${version}.tgz`,
|
|
192
|
+
cachedAt: Date.now(), // Custom metadata for shouldRefreshResolution
|
|
193
|
+
},
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
shouldRefreshResolution: (depPath, pkgSnapshot) => {
|
|
198
|
+
// Check custom metadata stored in the resolution
|
|
199
|
+
const cachedAt = pkgSnapshot.resolution?.cachedAt
|
|
200
|
+
if (cachedAt && Date.now() - cachedAt > 24 * 60 * 60 * 1000) {
|
|
201
|
+
return true // Re-resolve if cached more than 24 hours ago
|
|
202
|
+
}
|
|
203
|
+
return false
|
|
204
|
+
},
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const customFetcher = {
|
|
208
|
+
canFetch: (pkgId, resolution) => {
|
|
209
|
+
return resolution.type === 'custom:cdn'
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
fetch: async (cafs, resolution, opts, fetchers) => {
|
|
213
|
+
// Delegate to pnpm's standard tarball fetcher
|
|
214
|
+
// Transform the custom resolution to a standard tarball resolution
|
|
215
|
+
const tarballResolution = {
|
|
216
|
+
tarball: resolution.cdnUrl,
|
|
217
|
+
integrity: resolution.integrity,
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return fetchers.remoteTarball(cafs, tarballResolution, opts)
|
|
221
|
+
},
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Export as top-level arrays
|
|
225
|
+
module.exports = {
|
|
226
|
+
resolvers: [customResolver],
|
|
227
|
+
fetchers: [customFetcher],
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
**Delegating to Standard Fetchers:**
|
|
232
|
+
|
|
233
|
+
The `fetchers` parameter passed to the custom fetcher's `fetch` method provides access to pnpm's standard fetchers for delegation:
|
|
234
|
+
|
|
235
|
+
* `fetchers.remoteTarball` - Fetch from remote tarball URLs
|
|
236
|
+
* `fetchers.localTarball` - Fetch from local tarball files
|
|
237
|
+
* `fetchers.gitHostedTarball` - Fetch from GitHub/GitLab/Bitbucket tarballs
|
|
238
|
+
* `fetchers.directory` - Fetch from local directories
|
|
239
|
+
* `fetchers.git` - Fetch from git repositories
|
|
240
|
+
|
|
241
|
+
See the test cases in `resolving/default-resolver/test/customResolver.ts` and `fetching/pick-fetcher/test/pickFetcher.ts` for complete working examples.
|
|
242
|
+
|
|
243
|
+
**Notes:**
|
|
244
|
+
|
|
245
|
+
* Multiple custom resolvers and fetchers can be registered; they are tried in order until one matches
|
|
246
|
+
* All methods support both synchronous and asynchronous implementations
|
|
247
|
+
* Custom resolvers are tried before pnpm's built-in resolvers (npm, git, tarball, etc.)
|
|
248
|
+
* Custom fetchers can delegate to pnpm's standard fetchers via the `fetchers` parameter to avoid reimplementing common fetch logic
|
|
249
|
+
* The `shouldRefreshResolution` hook allows fine-grained control over when packages should be re-resolved
|
|
250
|
+
|
|
251
|
+
**Performance Considerations:**
|
|
252
|
+
|
|
253
|
+
* `canResolve()` should be a cheap check (ideally synchronous) as it's called for every dependency during resolution
|
|
254
|
+
* `resolve()` can be an expensive async operation (e.g., network requests) as it's only called for matching dependencies
|
|
255
|
+
* If your `canResolve()` implementation is expensive, performance may be impacted during large installations
|
|
256
|
+
|
|
257
|
+
## License
|
|
258
|
+
|
|
259
|
+
[MIT](LICENSE)
|
package/lib/api.d.ts
ADDED
package/lib/api.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type GetContextOptions, type ProjectOptions } from '@pnpm/installing.context';
|
|
2
|
+
import type { PeerDependencyIssuesByProjects } from '@pnpm/types';
|
|
3
|
+
import type { InstallOptions } from './install/extendInstallOptions.js';
|
|
4
|
+
export type ListMissingPeersOptions = Partial<GetContextOptions> & Pick<InstallOptions, 'hooks' | 'catalogs' | 'dedupePeerDependents' | 'ignoreCompatibilityDb' | 'linkWorkspacePackagesDepth' | 'nodeVersion' | 'nodeLinker' | 'overrides' | 'packageExtensions' | 'ignoredOptionalDependencies' | 'preferWorkspacePackages' | 'saveWorkspaceProtocol' | 'storeController' | 'useGitBranchLockfile' | 'peersSuffixMaxLength'> & Partial<Pick<InstallOptions, 'supportedArchitectures'>> & Pick<GetContextOptions, 'autoInstallPeers' | 'excludeLinksFromLockfile' | 'storeDir'> & Required<Pick<InstallOptions, 'globalVirtualStoreDir' | 'virtualStoreDirMaxLength' | 'peersSuffixMaxLength'>>;
|
|
5
|
+
export declare function getPeerDependencyIssues(projects: ProjectOptions[], opts: ListMissingPeersOptions): Promise<PeerDependencyIssuesByProjects>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { DEFAULT_REGISTRIES } from '@pnpm/config.normalize-registries';
|
|
2
|
+
import { parseOverrides } from '@pnpm/config.parse-overrides';
|
|
3
|
+
import { createReadPackageHook } from '@pnpm/hooks.read-package-hook';
|
|
4
|
+
import { getContext } from '@pnpm/installing.context';
|
|
5
|
+
import { getWantedDependencies, resolveDependencies } from '@pnpm/installing.deps-resolver';
|
|
6
|
+
import { getPreferredVersionsFromLockfileAndManifests } from '@pnpm/lockfile.preferred-versions';
|
|
7
|
+
export async function getPeerDependencyIssues(projects, opts) {
|
|
8
|
+
const lockfileDir = opts.lockfileDir ?? process.cwd();
|
|
9
|
+
const ctx = await getContext({
|
|
10
|
+
force: false,
|
|
11
|
+
extraBinPaths: [],
|
|
12
|
+
lockfileDir,
|
|
13
|
+
nodeLinker: opts.nodeLinker ?? 'isolated',
|
|
14
|
+
registries: DEFAULT_REGISTRIES,
|
|
15
|
+
useLockfile: true,
|
|
16
|
+
allProjects: projects,
|
|
17
|
+
...opts,
|
|
18
|
+
});
|
|
19
|
+
const projectsToResolve = Object.values(ctx.projects).map((project) => ({
|
|
20
|
+
...project,
|
|
21
|
+
updatePackageManifest: false,
|
|
22
|
+
wantedDependencies: getWantedDependencies(project.manifest, opts),
|
|
23
|
+
}));
|
|
24
|
+
const preferredVersions = getPreferredVersionsFromLockfileAndManifests(ctx.wantedLockfile.packages, Object.values(ctx.projects).map(({ manifest }) => manifest));
|
|
25
|
+
const overrides = parseOverrides(opts.overrides ?? {}, opts.catalogs ?? {});
|
|
26
|
+
const { peerDependencyIssuesByProjects, waitTillAllFetchingsFinish, } = await resolveDependencies(projectsToResolve, {
|
|
27
|
+
currentLockfile: ctx.currentLockfile,
|
|
28
|
+
allowedDeprecatedVersions: {},
|
|
29
|
+
allowUnusedPatches: false,
|
|
30
|
+
catalogs: opts.catalogs,
|
|
31
|
+
defaultUpdateDepth: -1,
|
|
32
|
+
dedupePeerDependents: opts.dedupePeerDependents,
|
|
33
|
+
dryRun: true,
|
|
34
|
+
engineStrict: false,
|
|
35
|
+
force: false,
|
|
36
|
+
forceFullResolution: true,
|
|
37
|
+
hooks: {
|
|
38
|
+
readPackage: createReadPackageHook({
|
|
39
|
+
ignoreCompatibilityDb: opts.ignoreCompatibilityDb,
|
|
40
|
+
lockfileDir,
|
|
41
|
+
overrides,
|
|
42
|
+
packageExtensions: opts.packageExtensions,
|
|
43
|
+
readPackageHook: opts.hooks?.readPackage,
|
|
44
|
+
ignoredOptionalDependencies: opts.ignoredOptionalDependencies,
|
|
45
|
+
}),
|
|
46
|
+
},
|
|
47
|
+
linkWorkspacePackagesDepth: opts.linkWorkspacePackagesDepth ?? (opts.saveWorkspaceProtocol ? 0 : -1),
|
|
48
|
+
lockfileDir,
|
|
49
|
+
nodeVersion: opts.nodeVersion ?? process.version,
|
|
50
|
+
pnpmVersion: '',
|
|
51
|
+
preferWorkspacePackages: opts.preferWorkspacePackages,
|
|
52
|
+
preferredVersions,
|
|
53
|
+
preserveWorkspaceProtocol: false,
|
|
54
|
+
registries: ctx.registries,
|
|
55
|
+
saveWorkspaceProtocol: false, // this doesn't matter in our case. We won't write changes to package.json files
|
|
56
|
+
storeController: opts.storeController,
|
|
57
|
+
tag: 'latest',
|
|
58
|
+
globalVirtualStoreDir: opts.globalVirtualStoreDir,
|
|
59
|
+
virtualStoreDir: ctx.virtualStoreDir,
|
|
60
|
+
virtualStoreDirMaxLength: ctx.virtualStoreDirMaxLength,
|
|
61
|
+
wantedLockfile: ctx.wantedLockfile,
|
|
62
|
+
workspacePackages: ctx.workspacePackages ?? new Map(),
|
|
63
|
+
supportedArchitectures: opts.supportedArchitectures,
|
|
64
|
+
peersSuffixMaxLength: opts.peersSuffixMaxLength,
|
|
65
|
+
allProjectIds: Object.values(ctx.projects).map((p) => p.id),
|
|
66
|
+
});
|
|
67
|
+
await waitTillAllFetchingsFinish();
|
|
68
|
+
return peerDependencyIssuesByProjects;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=getPeerDependencyIssues.js.map
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './api.js';
|
|
2
|
+
export { UnexpectedStoreError } from './install/checkCompatibility/UnexpectedStoreError.js';
|
|
3
|
+
export { UnexpectedVirtualStoreDirError } from './install/checkCompatibility/UnexpectedVirtualStoreDirError.js';
|
|
4
|
+
export type { InstallOptions } from './install/extendInstallOptions.js';
|
|
5
|
+
export { type ProjectOptions } from '@pnpm/installing.context';
|
|
6
|
+
export type { UpdateMatchingFunction } from '@pnpm/installing.deps-resolver';
|
|
7
|
+
export type { HoistingLimits } from '@pnpm/installing.deps-restorer';
|
|
8
|
+
export type { WorkspacePackages } from '@pnpm/resolving.resolver-base';
|
|
9
|
+
export type { BadPeerDependencyIssue, MissingPeerDependencyIssue, MissingPeerIssuesByPeerName, PackageManifest, PeerDependencyIssues, PeerDependencyIssuesByProjects, } from '@pnpm/types';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from './api.js';
|
|
2
|
+
export { UnexpectedStoreError } from './install/checkCompatibility/UnexpectedStoreError.js';
|
|
3
|
+
export { UnexpectedVirtualStoreDirError } from './install/checkCompatibility/UnexpectedVirtualStoreDirError.js';
|
|
4
|
+
export {} from '@pnpm/installing.context';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PnpmError } from '@pnpm/error';
|
|
2
|
+
import type { ErrorRelatedSources } from './ErrorRelatedSources.js';
|
|
3
|
+
export interface BreakingChangeErrorOptions extends ErrorRelatedSources {
|
|
4
|
+
code: string;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class BreakingChangeError extends PnpmError {
|
|
8
|
+
relatedIssue?: number;
|
|
9
|
+
relatedPR?: number;
|
|
10
|
+
additionalInformation?: string;
|
|
11
|
+
constructor(opts: BreakingChangeErrorOptions);
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PnpmError } from '@pnpm/error';
|
|
2
|
+
export class BreakingChangeError extends PnpmError {
|
|
3
|
+
relatedIssue;
|
|
4
|
+
relatedPR;
|
|
5
|
+
additionalInformation;
|
|
6
|
+
constructor(opts) {
|
|
7
|
+
super(opts.code, opts.message);
|
|
8
|
+
this.relatedIssue = opts.relatedIssue;
|
|
9
|
+
this.relatedPR = opts.relatedPR;
|
|
10
|
+
this.additionalInformation = opts.additionalInformation;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=BreakingChangeError.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PnpmError } from '@pnpm/error';
|
|
2
|
+
export class CatalogVersionMismatchError extends PnpmError {
|
|
3
|
+
catalogDep;
|
|
4
|
+
wantedDep;
|
|
5
|
+
constructor(opts) {
|
|
6
|
+
super('CATALOG_VERSION_MISMATCH', 'Wanted dependency outside the version range defined in catalog');
|
|
7
|
+
this.catalogDep = opts.catalogDep;
|
|
8
|
+
this.wantedDep = opts.wantedDep;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=CatalogVersionMismatchError.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BreakingChangeError } from './BreakingChangeError.js';
|
|
2
|
+
import type { ErrorRelatedSources } from './ErrorRelatedSources.js';
|
|
3
|
+
export interface ModulesBreakingChangeErrorOptions extends ErrorRelatedSources {
|
|
4
|
+
modulesPath: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class ModulesBreakingChangeError extends BreakingChangeError {
|
|
7
|
+
modulesPath: string;
|
|
8
|
+
constructor(opts: ModulesBreakingChangeErrorOptions);
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BreakingChangeError } from './BreakingChangeError.js';
|
|
2
|
+
export class ModulesBreakingChangeError extends BreakingChangeError {
|
|
3
|
+
modulesPath;
|
|
4
|
+
constructor(opts) {
|
|
5
|
+
super({
|
|
6
|
+
additionalInformation: opts.additionalInformation,
|
|
7
|
+
code: 'MODULES_BREAKING_CHANGE',
|
|
8
|
+
message: `The node_modules structure at "${opts.modulesPath}" is not compatible with the current pnpm version. Run "pnpm install --force" to recreate node_modules.`,
|
|
9
|
+
relatedIssue: opts.relatedIssue,
|
|
10
|
+
relatedPR: opts.relatedPR,
|
|
11
|
+
});
|
|
12
|
+
this.modulesPath = opts.modulesPath;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ModulesBreakingChangeError.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PnpmError } from '@pnpm/error';
|
|
2
|
+
export declare class UnexpectedStoreError extends PnpmError {
|
|
3
|
+
expectedStorePath: string;
|
|
4
|
+
actualStorePath: string;
|
|
5
|
+
modulesDir: string;
|
|
6
|
+
constructor(opts: {
|
|
7
|
+
expectedStorePath: string;
|
|
8
|
+
actualStorePath: string;
|
|
9
|
+
modulesDir: string;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PnpmError } from '@pnpm/error';
|
|
2
|
+
export class UnexpectedStoreError extends PnpmError {
|
|
3
|
+
expectedStorePath;
|
|
4
|
+
actualStorePath;
|
|
5
|
+
modulesDir;
|
|
6
|
+
constructor(opts) {
|
|
7
|
+
super('UNEXPECTED_STORE', 'Unexpected store location');
|
|
8
|
+
this.expectedStorePath = opts.expectedStorePath;
|
|
9
|
+
this.actualStorePath = opts.actualStorePath;
|
|
10
|
+
this.modulesDir = opts.modulesDir;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=UnexpectedStoreError.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PnpmError } from '@pnpm/error';
|
|
2
|
+
export declare class UnexpectedVirtualStoreDirError extends PnpmError {
|
|
3
|
+
expected: string;
|
|
4
|
+
actual: string;
|
|
5
|
+
modulesDir: string;
|
|
6
|
+
constructor(opts: {
|
|
7
|
+
expected: string;
|
|
8
|
+
actual: string;
|
|
9
|
+
modulesDir: string;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PnpmError } from '@pnpm/error';
|
|
2
|
+
export class UnexpectedVirtualStoreDirError extends PnpmError {
|
|
3
|
+
expected;
|
|
4
|
+
actual;
|
|
5
|
+
modulesDir;
|
|
6
|
+
constructor(opts) {
|
|
7
|
+
super('UNEXPECTED_VIRTUAL_STORE', 'Unexpected virtual store location');
|
|
8
|
+
this.expected = opts.expected;
|
|
9
|
+
this.actual = opts.actual;
|
|
10
|
+
this.modulesDir = opts.modulesDir;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=UnexpectedVirtualStoreDirError.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { LAYOUT_VERSION } from '@pnpm/constants';
|
|
3
|
+
import { ModulesBreakingChangeError } from './ModulesBreakingChangeError.js';
|
|
4
|
+
import { UnexpectedStoreError } from './UnexpectedStoreError.js';
|
|
5
|
+
import { UnexpectedVirtualStoreDirError } from './UnexpectedVirtualStoreDirError.js';
|
|
6
|
+
export function checkCompatibility(modules, opts) {
|
|
7
|
+
if (!modules.layoutVersion || modules.layoutVersion !== LAYOUT_VERSION) {
|
|
8
|
+
throw new ModulesBreakingChangeError({
|
|
9
|
+
modulesPath: opts.modulesDir,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
// Important: comparing paths with path.relative()
|
|
13
|
+
// is the only way to compare paths correctly on Windows
|
|
14
|
+
// as of Node.js 4-9
|
|
15
|
+
// See related issue: https://github.com/pnpm/pnpm/issues/996
|
|
16
|
+
if (!modules.storeDir ||
|
|
17
|
+
path.relative(modules.storeDir, opts.storeDir) !== '' && path.relative(modules.storeDir, path.join(opts.storeDir, '../v3')) !== '') {
|
|
18
|
+
throw new UnexpectedStoreError({
|
|
19
|
+
actualStorePath: opts.storeDir,
|
|
20
|
+
expectedStorePath: modules.storeDir,
|
|
21
|
+
modulesDir: opts.modulesDir,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (modules.virtualStoreDir && path.relative(modules.virtualStoreDir, opts.virtualStoreDir) !== '') {
|
|
25
|
+
throw new UnexpectedVirtualStoreDirError({
|
|
26
|
+
actual: opts.virtualStoreDir,
|
|
27
|
+
expected: modules.virtualStoreDir,
|
|
28
|
+
modulesDir: opts.modulesDir,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CustomResolver } from '@pnpm/hooks.types';
|
|
2
|
+
import type { LockfileObject } from '@pnpm/lockfile.types';
|
|
3
|
+
/**
|
|
4
|
+
* Check if any custom resolver's shouldRefreshResolution returns true for any
|
|
5
|
+
* package in the lockfile. shouldRefreshResolution is called independently of
|
|
6
|
+
* canResolve — it runs before resolution, so the original specifier is not
|
|
7
|
+
* available. Each resolver's shouldRefreshResolution is responsible for its own
|
|
8
|
+
* filtering logic.
|
|
9
|
+
*/
|
|
10
|
+
export declare function checkCustomResolverForceResolve(customResolvers: CustomResolver[], wantedLockfile: LockfileObject): Promise<boolean>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if any custom resolver's shouldRefreshResolution returns true for any
|
|
3
|
+
* package in the lockfile. shouldRefreshResolution is called independently of
|
|
4
|
+
* canResolve — it runs before resolution, so the original specifier is not
|
|
5
|
+
* available. Each resolver's shouldRefreshResolution is responsible for its own
|
|
6
|
+
* filtering logic.
|
|
7
|
+
*/
|
|
8
|
+
export async function checkCustomResolverForceResolve(customResolvers, wantedLockfile) {
|
|
9
|
+
if (!wantedLockfile.packages)
|
|
10
|
+
return false;
|
|
11
|
+
const hooks = [];
|
|
12
|
+
for (const resolver of customResolvers) {
|
|
13
|
+
if (resolver.shouldRefreshResolution)
|
|
14
|
+
hooks.push(resolver.shouldRefreshResolution);
|
|
15
|
+
}
|
|
16
|
+
if (hooks.length === 0)
|
|
17
|
+
return false;
|
|
18
|
+
const asyncChecks = [];
|
|
19
|
+
for (const [depPath, pkgSnapshot] of Object.entries(wantedLockfile.packages)) {
|
|
20
|
+
for (const hook of hooks) {
|
|
21
|
+
const result = hook(depPath, pkgSnapshot);
|
|
22
|
+
if (result === true)
|
|
23
|
+
return true;
|
|
24
|
+
if (result !== false)
|
|
25
|
+
asyncChecks.push(result);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (asyncChecks.length === 0)
|
|
29
|
+
return false;
|
|
30
|
+
return anyTrue(asyncChecks);
|
|
31
|
+
}
|
|
32
|
+
async function anyTrue(promises) {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
let remaining = promises.length;
|
|
35
|
+
if (remaining === 0)
|
|
36
|
+
return resolve(false);
|
|
37
|
+
for (const p of promises) {
|
|
38
|
+
p.then(value => {
|
|
39
|
+
if (value)
|
|
40
|
+
resolve(true);
|
|
41
|
+
else if (--remaining === 0)
|
|
42
|
+
resolve(false);
|
|
43
|
+
}, reject);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=checkCustomResolverForceResolve.js.map
|