@pnpm/resolving.default-resolver 1002.2.12
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 +23 -0
- package/lib/index.js +71 -0
- package/package.json +63 -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,17 @@
|
|
|
1
|
+
# @pnpm/default-resolver
|
|
2
|
+
|
|
3
|
+
> pnpm's default package resolver
|
|
4
|
+
|
|
5
|
+
<!--@shields('npm')-->
|
|
6
|
+
[](https://www.npmjs.com/package/@pnpm/default-resolver)
|
|
7
|
+
<!--/@-->
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pnpm add @pnpm/default-resolver
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## License
|
|
16
|
+
|
|
17
|
+
MIT
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type BunRuntimeResolveResult } from '@pnpm/engine.runtime.bun-resolver';
|
|
2
|
+
import { type DenoRuntimeResolveResult } from '@pnpm/engine.runtime.deno-resolver';
|
|
3
|
+
import { type NodeRuntimeResolveResult } from '@pnpm/engine.runtime.node-resolver';
|
|
4
|
+
import type { FetchFromRegistry, GetAuthHeader } from '@pnpm/fetching.types';
|
|
5
|
+
import { type CustomResolver } from '@pnpm/hooks.types';
|
|
6
|
+
import { type GitResolveResult } from '@pnpm/resolving.git-resolver';
|
|
7
|
+
import { type LocalResolveResult } from '@pnpm/resolving.local-resolver';
|
|
8
|
+
import { type JsrResolveResult, type NpmResolveResult, type PackageMeta, type PackageMetaCache, type ResolverFactoryOptions, type WorkspaceResolveResult } from '@pnpm/resolving.npm-resolver';
|
|
9
|
+
import type { ResolveFunction, ResolveOptions, ResolveResult, WantedDependency } from '@pnpm/resolving.resolver-base';
|
|
10
|
+
import { type TarballResolveResult } from '@pnpm/resolving.tarball-resolver';
|
|
11
|
+
export type { PackageMeta, PackageMetaCache, ResolveFunction, ResolverFactoryOptions, };
|
|
12
|
+
export interface CustomResolverResolveResult extends ResolveResult {
|
|
13
|
+
resolvedVia: 'custom-resolver';
|
|
14
|
+
}
|
|
15
|
+
export type DefaultResolveResult = NpmResolveResult | JsrResolveResult | GitResolveResult | LocalResolveResult | TarballResolveResult | WorkspaceResolveResult | NodeRuntimeResolveResult | DenoRuntimeResolveResult | BunRuntimeResolveResult | CustomResolverResolveResult;
|
|
16
|
+
export type DefaultResolver = (wantedDependency: WantedDependency, opts: ResolveOptions) => Promise<DefaultResolveResult>;
|
|
17
|
+
export declare function createResolver(fetchFromRegistry: FetchFromRegistry, getAuthHeader: GetAuthHeader, pnpmOpts: ResolverFactoryOptions & {
|
|
18
|
+
rawConfig: Record<string, string>;
|
|
19
|
+
customResolvers?: CustomResolver[];
|
|
20
|
+
}): {
|
|
21
|
+
resolve: DefaultResolver;
|
|
22
|
+
clearCache: () => void;
|
|
23
|
+
};
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { resolveBunRuntime } from '@pnpm/engine.runtime.bun-resolver';
|
|
2
|
+
import { resolveDenoRuntime } from '@pnpm/engine.runtime.deno-resolver';
|
|
3
|
+
import { resolveNodeRuntime } from '@pnpm/engine.runtime.node-resolver';
|
|
4
|
+
import { PnpmError } from '@pnpm/error';
|
|
5
|
+
import { checkCustomResolverCanResolve } from '@pnpm/hooks.types';
|
|
6
|
+
import { createGitResolver } from '@pnpm/resolving.git-resolver';
|
|
7
|
+
import { resolveFromLocal } from '@pnpm/resolving.local-resolver';
|
|
8
|
+
import { createNpmResolver, } from '@pnpm/resolving.npm-resolver';
|
|
9
|
+
import { resolveFromTarball } from '@pnpm/resolving.tarball-resolver';
|
|
10
|
+
async function resolveFromCustomResolvers(customResolvers, wantedDependency, opts) {
|
|
11
|
+
if (!customResolvers || customResolvers.length === 0) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
for (const customResolver of customResolvers) {
|
|
15
|
+
// Skip custom resolvers that don't support both canResolve and resolve
|
|
16
|
+
if (!customResolver.canResolve || !customResolver.resolve)
|
|
17
|
+
continue;
|
|
18
|
+
// eslint-disable-next-line no-await-in-loop
|
|
19
|
+
const canResolve = await checkCustomResolverCanResolve(customResolver, wantedDependency);
|
|
20
|
+
if (canResolve) {
|
|
21
|
+
// eslint-disable-next-line no-await-in-loop
|
|
22
|
+
const result = await customResolver.resolve(wantedDependency, {
|
|
23
|
+
lockfileDir: opts.lockfileDir,
|
|
24
|
+
projectDir: opts.projectDir,
|
|
25
|
+
preferredVersions: (opts.preferredVersions ?? {}),
|
|
26
|
+
currentPkg: opts.currentPkg,
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
...result,
|
|
30
|
+
resolvedVia: 'custom-resolver',
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
export function createResolver(fetchFromRegistry, getAuthHeader, pnpmOpts) {
|
|
37
|
+
const { resolveFromNpm, resolveFromJsr, clearCache } = createNpmResolver(fetchFromRegistry, getAuthHeader, pnpmOpts);
|
|
38
|
+
const resolveFromGit = createGitResolver(pnpmOpts);
|
|
39
|
+
const _resolveFromLocal = resolveFromLocal.bind(null, {
|
|
40
|
+
preserveAbsolutePaths: pnpmOpts.preserveAbsolutePaths,
|
|
41
|
+
});
|
|
42
|
+
const _resolveNodeRuntime = resolveNodeRuntime.bind(null, { fetchFromRegistry, offline: pnpmOpts.offline, rawConfig: pnpmOpts.rawConfig });
|
|
43
|
+
const _resolveDenoRuntime = resolveDenoRuntime.bind(null, { fetchFromRegistry, offline: pnpmOpts.offline, rawConfig: pnpmOpts.rawConfig, resolveFromNpm });
|
|
44
|
+
const _resolveBunRuntime = resolveBunRuntime.bind(null, { fetchFromRegistry, offline: pnpmOpts.offline, rawConfig: pnpmOpts.rawConfig, resolveFromNpm });
|
|
45
|
+
const _resolveFromCustomResolvers = pnpmOpts.customResolvers
|
|
46
|
+
? resolveFromCustomResolvers.bind(null, pnpmOpts.customResolvers)
|
|
47
|
+
: null;
|
|
48
|
+
return {
|
|
49
|
+
resolve: async (wantedDependency, opts) => {
|
|
50
|
+
const resolution = await _resolveFromCustomResolvers?.(wantedDependency, opts) ??
|
|
51
|
+
await resolveFromNpm(wantedDependency, opts) ??
|
|
52
|
+
await resolveFromJsr(wantedDependency, opts) ??
|
|
53
|
+
(wantedDependency.bareSpecifier && (await resolveFromGit(wantedDependency, opts) ??
|
|
54
|
+
await resolveFromTarball(fetchFromRegistry, wantedDependency) ??
|
|
55
|
+
await _resolveFromLocal(wantedDependency, opts))) ??
|
|
56
|
+
await _resolveNodeRuntime(wantedDependency, opts) ??
|
|
57
|
+
await _resolveDenoRuntime(wantedDependency, opts) ??
|
|
58
|
+
await _resolveBunRuntime(wantedDependency, opts);
|
|
59
|
+
if (!resolution) {
|
|
60
|
+
let specifier = `${wantedDependency.alias ? wantedDependency.alias + '@' : ''}${wantedDependency.bareSpecifier ?? ''}`;
|
|
61
|
+
if (specifier !== '') {
|
|
62
|
+
specifier = `"${specifier}"`;
|
|
63
|
+
}
|
|
64
|
+
throw new PnpmError('SPEC_NOT_SUPPORTED_BY_ANY_RESOLVER', `${specifier} isn't supported by any available resolver.`);
|
|
65
|
+
}
|
|
66
|
+
return resolution;
|
|
67
|
+
},
|
|
68
|
+
clearCache,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pnpm/resolving.default-resolver",
|
|
3
|
+
"version": "1002.2.12",
|
|
4
|
+
"description": "pnpm's default package resolver",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pnpm",
|
|
7
|
+
"pnpm11",
|
|
8
|
+
"npm",
|
|
9
|
+
"resolver"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"funding": "https://opencollective.com/pnpm",
|
|
13
|
+
"repository": "https://github.com/pnpm/pnpm/tree/main/resolving/default-resolver",
|
|
14
|
+
"homepage": "https://github.com/pnpm/pnpm/tree/main/resolving/default-resolver#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/pnpm/pnpm/issues"
|
|
17
|
+
},
|
|
18
|
+
"type": "module",
|
|
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/engine.runtime.deno-resolver": "1002.0.1",
|
|
30
|
+
"@pnpm/engine.runtime.bun-resolver": "1002.0.1",
|
|
31
|
+
"@pnpm/error": "1000.0.5",
|
|
32
|
+
"@pnpm/engine.runtime.node-resolver": "1001.0.5",
|
|
33
|
+
"@pnpm/fetching.types": "1000.2.0",
|
|
34
|
+
"@pnpm/hooks.types": "1001.0.12",
|
|
35
|
+
"@pnpm/resolving.local-resolver": "1002.1.4",
|
|
36
|
+
"@pnpm/resolving.npm-resolver": "1004.4.1",
|
|
37
|
+
"@pnpm/resolving.git-resolver": "1001.1.5",
|
|
38
|
+
"@pnpm/resolving.resolver-base": "1005.1.0",
|
|
39
|
+
"@pnpm/resolving.tarball-resolver": "1002.1.4",
|
|
40
|
+
"@pnpm/types": "1000.9.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@jest/globals": "30.0.5",
|
|
44
|
+
"node-fetch": "^3.3.2",
|
|
45
|
+
"@pnpm/fetching.fetcher-base": "1001.0.2",
|
|
46
|
+
"@pnpm/fetching.tarball-fetcher": "1003.0.0",
|
|
47
|
+
"@pnpm/network.fetch": "1000.2.6",
|
|
48
|
+
"@pnpm/resolving.default-resolver": "1002.2.12",
|
|
49
|
+
"@pnpm/store.cafs-types": "1000.0.0"
|
|
50
|
+
},
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">=22.13"
|
|
53
|
+
},
|
|
54
|
+
"jest": {
|
|
55
|
+
"preset": "@pnpm/jest-config"
|
|
56
|
+
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
59
|
+
"_test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest",
|
|
60
|
+
"test": "pnpm run compile && pnpm run _test",
|
|
61
|
+
"compile": "tsgo --build && pnpm run lint --fix"
|
|
62
|
+
}
|
|
63
|
+
}
|