@pnpm/resolving.local-resolver 1101.1.13 → 1101.1.15
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 +22 -0
- package/lib/index.d.ts +34 -0
- package/lib/parseBareSpecifier.d.ts +18 -0
- package/lib/parseBareSpecifier.js +111 -0
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @pnpm/local-resolver
|
|
2
2
|
|
|
3
|
+
## 1101.1.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies:
|
|
8
|
+
- @pnpm/resolving.resolver-base@1100.5.5
|
|
9
|
+
- @pnpm/types@1101.7.0
|
|
10
|
+
- @pnpm/workspace.project-manifest-reader@1100.0.21
|
|
11
|
+
|
|
12
|
+
## 1101.1.14
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Republished every package: the tarballs published by the v11.13.1 through v11.16.0 releases were missing most of their compiled files due to a packing bug [#13164](https://github.com/pnpm/pnpm/issues/13164).
|
|
17
|
+
|
|
18
|
+
- Updated dependencies:
|
|
19
|
+
- @pnpm/crypto.hash@1100.0.2
|
|
20
|
+
- @pnpm/error@1100.1.0
|
|
21
|
+
- @pnpm/resolving.resolver-base@1100.5.4
|
|
22
|
+
- @pnpm/types@1101.6.0
|
|
23
|
+
- @pnpm/workspace.project-manifest-reader@1100.0.20
|
|
24
|
+
|
|
3
25
|
## 1101.1.13
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { DirectoryResolution, LatestInfo, LatestQuery, Resolution, ResolveResult, TarballResolution } from '@pnpm/resolving.resolver-base';
|
|
2
|
+
import type { DependencyManifest, PkgResolutionId } from '@pnpm/types';
|
|
3
|
+
import { type WantedLocalDependency } from './parseBareSpecifier.js';
|
|
4
|
+
export { type WantedLocalDependency };
|
|
5
|
+
export interface LocalResolveResult extends ResolveResult {
|
|
6
|
+
manifest?: DependencyManifest;
|
|
7
|
+
normalizedBareSpecifier?: string;
|
|
8
|
+
resolution: DirectoryResolution | TarballResolution;
|
|
9
|
+
resolvedVia: 'local-filesystem';
|
|
10
|
+
}
|
|
11
|
+
export interface LocalResolverContext {
|
|
12
|
+
preserveAbsolutePaths?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface LocalResolverOptions {
|
|
15
|
+
lockfileDir?: string;
|
|
16
|
+
projectDir: string;
|
|
17
|
+
currentPkg?: {
|
|
18
|
+
id: PkgResolutionId;
|
|
19
|
+
resolution: DirectoryResolution | TarballResolution | Resolution;
|
|
20
|
+
};
|
|
21
|
+
update?: false | 'compatible' | 'latest';
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Resolves a dependency declared with an explicit local scheme:
|
|
25
|
+
* `link:`, `workspace:`, `file:`, or (rejected) `path:`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveFromLocalScheme(ctx: LocalResolverContext, wantedDependency: WantedLocalDependency, opts: LocalResolverOptions): Promise<LocalResolveResult | null>;
|
|
28
|
+
/**
|
|
29
|
+
* Resolves a dependency by path shape — a relative/absolute path or a tarball
|
|
30
|
+
* filename. Does not look at scheme prefixes; callers that want scheme support
|
|
31
|
+
* should call {@link resolveFromLocalScheme} first.
|
|
32
|
+
*/
|
|
33
|
+
export declare function resolveFromLocalPath(ctx: LocalResolverContext, wantedDependency: WantedLocalDependency, opts: LocalResolverOptions): Promise<LocalResolveResult | null>;
|
|
34
|
+
export declare function resolveLatestFromLocal(query: LatestQuery): Promise<LatestInfo | undefined>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PkgResolutionId } from '@pnpm/resolving.resolver-base';
|
|
2
|
+
export interface LocalPackageSpec {
|
|
3
|
+
dependencyPath: string;
|
|
4
|
+
fetchSpec: string;
|
|
5
|
+
id: PkgResolutionId;
|
|
6
|
+
type: 'directory' | 'file';
|
|
7
|
+
normalizedBareSpecifier: string;
|
|
8
|
+
}
|
|
9
|
+
export interface WantedLocalDependency {
|
|
10
|
+
bareSpecifier: string;
|
|
11
|
+
injected?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function parseLocalScheme(wd: WantedLocalDependency, projectDir: string, lockfileDir: string, opts: {
|
|
14
|
+
preserveAbsolutePaths: boolean;
|
|
15
|
+
}): LocalPackageSpec | null;
|
|
16
|
+
export declare function parseLocalPath(wd: WantedLocalDependency, projectDir: string, lockfileDir: string, opts: {
|
|
17
|
+
preserveAbsolutePaths: boolean;
|
|
18
|
+
}): LocalPackageSpec | null;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import os from 'node:os';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { PnpmError } from '@pnpm/error';
|
|
4
|
+
import normalize from 'normalize-path';
|
|
5
|
+
// @ts-expect-error
|
|
6
|
+
const isWindows = process.platform === 'win32' || global['FAKE_WINDOWS'];
|
|
7
|
+
const isFilespec = isWindows ? /^(?:[./\\]|~\/|[a-z]:)/i : /^(?:[./]|~\/|[a-z]:)/i;
|
|
8
|
+
const isFilename = /\.(?:tgz|tar.gz|tar)$/i;
|
|
9
|
+
const isAbsolutePath = /^\/|^[A-Z]:/i;
|
|
10
|
+
class PathIsUnsupportedProtocolError extends PnpmError {
|
|
11
|
+
bareSpecifier;
|
|
12
|
+
protocol;
|
|
13
|
+
constructor(bareSpecifier, protocol) {
|
|
14
|
+
super('PATH_IS_UNSUPPORTED_PROTOCOL', 'Local dependencies via `path:` protocol are not supported. ' +
|
|
15
|
+
'Use the `link:` protocol for folder dependencies and `file:` for local tarballs');
|
|
16
|
+
this.bareSpecifier = bareSpecifier;
|
|
17
|
+
this.protocol = protocol;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function parseLocalScheme(wd, projectDir, lockfileDir, opts) {
|
|
21
|
+
if (wd.bareSpecifier.startsWith('link:') || wd.bareSpecifier.startsWith('workspace:')) {
|
|
22
|
+
return fromLocal(wd, projectDir, lockfileDir, 'directory', opts);
|
|
23
|
+
}
|
|
24
|
+
if (wd.bareSpecifier.startsWith('file:')) {
|
|
25
|
+
const type = isFilename.test(wd.bareSpecifier) ? 'file' : 'directory';
|
|
26
|
+
return fromLocal(wd, projectDir, lockfileDir, type, opts);
|
|
27
|
+
}
|
|
28
|
+
if (wd.bareSpecifier.startsWith('path:')) {
|
|
29
|
+
throw new PathIsUnsupportedProtocolError(wd.bareSpecifier, 'path:');
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
export function parseLocalPath(wd, projectDir, lockfileDir, opts) {
|
|
34
|
+
if (wd.bareSpecifier.endsWith('.tgz') ||
|
|
35
|
+
wd.bareSpecifier.endsWith('.tar.gz') ||
|
|
36
|
+
wd.bareSpecifier.endsWith('.tar') ||
|
|
37
|
+
wd.bareSpecifier.includes(path.sep) ||
|
|
38
|
+
isFilespec.test(wd.bareSpecifier)) {
|
|
39
|
+
const type = isFilename.test(wd.bareSpecifier) ? 'file' : 'directory';
|
|
40
|
+
return fromLocal(wd, projectDir, lockfileDir, type, opts);
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
function fromLocal({ bareSpecifier, injected }, projectDir, lockfileDir, type, opts) {
|
|
45
|
+
const spec = bareSpecifier.replace(/\\/g, '/')
|
|
46
|
+
.replace(/^(?:file|link|workspace):\/*([A-Z]:)/i, '$1') // drive name paths on windows
|
|
47
|
+
.replace(/^(?:file|link|workspace):(?:\/*([~./]))?/, '$1');
|
|
48
|
+
let protocol;
|
|
49
|
+
if (bareSpecifier.startsWith('file:')) {
|
|
50
|
+
protocol = 'file:';
|
|
51
|
+
}
|
|
52
|
+
else if (bareSpecifier.startsWith('link:')) {
|
|
53
|
+
protocol = 'link:';
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
protocol = type === 'directory' && !injected ? 'link:' : 'file:';
|
|
57
|
+
}
|
|
58
|
+
let fetchSpec;
|
|
59
|
+
let normalizedBareSpecifier;
|
|
60
|
+
if (/^~\//.test(spec)) {
|
|
61
|
+
// this is needed for windows and for file:~/foo/bar
|
|
62
|
+
fetchSpec = resolvePath(os.homedir(), spec.slice(2));
|
|
63
|
+
normalizedBareSpecifier = `${protocol}${spec}`;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
fetchSpec = resolvePath(projectDir, spec);
|
|
67
|
+
if (isAbsolute(spec)) {
|
|
68
|
+
normalizedBareSpecifier = `${protocol}${spec}`;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
normalizedBareSpecifier = `${protocol}${path.relative(projectDir, fetchSpec)}`;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function normalizeRelativeOrAbsolute(relativeTo, fromPath) {
|
|
75
|
+
let specPath;
|
|
76
|
+
if (opts.preserveAbsolutePaths && isAbsolute(spec)) {
|
|
77
|
+
specPath = path.resolve(fromPath);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
specPath = path.relative(relativeTo, fromPath);
|
|
81
|
+
}
|
|
82
|
+
return normalize(specPath);
|
|
83
|
+
}
|
|
84
|
+
injected = protocol === 'file:';
|
|
85
|
+
const dependencyPath = injected
|
|
86
|
+
? normalizeRelativeOrAbsolute(lockfileDir, fetchSpec)
|
|
87
|
+
: normalize(path.resolve(fetchSpec));
|
|
88
|
+
const id = (!injected && (type === 'directory' || projectDir === lockfileDir)
|
|
89
|
+
? `${protocol}${normalizeRelativeOrAbsolute(projectDir, fetchSpec)}`
|
|
90
|
+
: `${protocol}${normalizeRelativeOrAbsolute(lockfileDir, fetchSpec)}`);
|
|
91
|
+
return {
|
|
92
|
+
dependencyPath,
|
|
93
|
+
fetchSpec,
|
|
94
|
+
id,
|
|
95
|
+
normalizedBareSpecifier,
|
|
96
|
+
type,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function resolvePath(where, spec) {
|
|
100
|
+
if (isAbsolutePath.test(spec))
|
|
101
|
+
return spec;
|
|
102
|
+
return path.resolve(where, spec);
|
|
103
|
+
}
|
|
104
|
+
function isAbsolute(dir) {
|
|
105
|
+
if (dir[0] === '/')
|
|
106
|
+
return true;
|
|
107
|
+
if (/^[A-Z]:/i.test(dir))
|
|
108
|
+
return true;
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=parseBareSpecifier.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/resolving.local-resolver",
|
|
3
|
-
"version": "1101.1.
|
|
3
|
+
"version": "1101.1.15",
|
|
4
4
|
"description": "Resolver for local packages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"!*.map"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@pnpm/crypto.hash": "1100.0.
|
|
33
|
-
"@pnpm/error": "1100.0
|
|
34
|
-
"@pnpm/resolving.resolver-base": "1100.5.
|
|
35
|
-
"@pnpm/types": "1101.
|
|
36
|
-
"@pnpm/workspace.project-manifest-reader": "1100.0.
|
|
32
|
+
"@pnpm/crypto.hash": "1100.0.2",
|
|
33
|
+
"@pnpm/error": "1100.1.0",
|
|
34
|
+
"@pnpm/resolving.resolver-base": "1100.5.5",
|
|
35
|
+
"@pnpm/types": "1101.7.0",
|
|
36
|
+
"@pnpm/workspace.project-manifest-reader": "1100.0.21",
|
|
37
37
|
"normalize-path": "^3.0.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@jest/globals": "30.4.1",
|
|
44
44
|
"@pnpm/logger": "1100.0.0",
|
|
45
|
-
"@pnpm/resolving.local-resolver": "1101.1.
|
|
45
|
+
"@pnpm/resolving.local-resolver": "1101.1.15",
|
|
46
46
|
"@types/normalize-path": "^3.0.2"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|