@pnpm/resolving.local-resolver 1100.0.6 → 1101.0.0
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.d.ts +15 -6
- package/lib/index.js +21 -5
- package/lib/parseBareSpecifier.d.ts +4 -1
- package/lib/parseBareSpecifier.js +11 -5
- package/package.json +5 -5
package/lib/index.d.ts
CHANGED
|
@@ -8,12 +8,10 @@ export interface LocalResolveResult extends ResolveResult {
|
|
|
8
8
|
resolution: DirectoryResolution | TarballResolution;
|
|
9
9
|
resolvedVia: 'local-filesystem';
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
* Resolves a package hosted on the local filesystem
|
|
13
|
-
*/
|
|
14
|
-
export declare function resolveFromLocal(ctx: {
|
|
11
|
+
export interface LocalResolverContext {
|
|
15
12
|
preserveAbsolutePaths?: boolean;
|
|
16
|
-
}
|
|
13
|
+
}
|
|
14
|
+
export interface LocalResolverOptions {
|
|
17
15
|
lockfileDir?: string;
|
|
18
16
|
projectDir: string;
|
|
19
17
|
currentPkg?: {
|
|
@@ -21,4 +19,15 @@ export declare function resolveFromLocal(ctx: {
|
|
|
21
19
|
resolution: DirectoryResolution | TarballResolution | Resolution;
|
|
22
20
|
};
|
|
23
21
|
update?: false | 'compatible' | 'latest';
|
|
24
|
-
}
|
|
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>;
|
package/lib/index.js
CHANGED
|
@@ -4,14 +4,30 @@ import { getTarballIntegrity } from '@pnpm/crypto.hash';
|
|
|
4
4
|
import { PnpmError } from '@pnpm/error';
|
|
5
5
|
import { logger } from '@pnpm/logger';
|
|
6
6
|
import { readProjectManifestOnly } from '@pnpm/workspace.project-manifest-reader';
|
|
7
|
-
import {
|
|
7
|
+
import { parseLocalPath, parseLocalScheme } from './parseBareSpecifier.js';
|
|
8
8
|
export {};
|
|
9
9
|
/**
|
|
10
|
-
* Resolves a
|
|
10
|
+
* Resolves a dependency declared with an explicit local scheme:
|
|
11
|
+
* `link:`, `workspace:`, `file:`, or (rejected) `path:`.
|
|
11
12
|
*/
|
|
12
|
-
export async function
|
|
13
|
-
const
|
|
14
|
-
|
|
13
|
+
export async function resolveFromLocalScheme(ctx, wantedDependency, opts) {
|
|
14
|
+
const spec = parseLocalScheme(wantedDependency, opts.projectDir, opts.lockfileDir ?? opts.projectDir, {
|
|
15
|
+
preserveAbsolutePaths: ctx.preserveAbsolutePaths ?? false,
|
|
16
|
+
});
|
|
17
|
+
return resolveSpec(spec, opts);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Resolves a dependency by path shape — a relative/absolute path or a tarball
|
|
21
|
+
* filename. Does not look at scheme prefixes; callers that want scheme support
|
|
22
|
+
* should call {@link resolveFromLocalScheme} first.
|
|
23
|
+
*/
|
|
24
|
+
export async function resolveFromLocalPath(ctx, wantedDependency, opts) {
|
|
25
|
+
const spec = parseLocalPath(wantedDependency, opts.projectDir, opts.lockfileDir ?? opts.projectDir, {
|
|
26
|
+
preserveAbsolutePaths: ctx.preserveAbsolutePaths ?? false,
|
|
27
|
+
});
|
|
28
|
+
return resolveSpec(spec, opts);
|
|
29
|
+
}
|
|
30
|
+
async function resolveSpec(spec, opts) {
|
|
15
31
|
if (spec == null)
|
|
16
32
|
return null;
|
|
17
33
|
if (spec.type === 'file') {
|
|
@@ -10,6 +10,9 @@ export interface WantedLocalDependency {
|
|
|
10
10
|
bareSpecifier: string;
|
|
11
11
|
injected?: boolean;
|
|
12
12
|
}
|
|
13
|
-
export declare function
|
|
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: {
|
|
14
17
|
preserveAbsolutePaths: boolean;
|
|
15
18
|
}): LocalPackageSpec | null;
|
|
@@ -17,22 +17,28 @@ class PathIsUnsupportedProtocolError extends PnpmError {
|
|
|
17
17
|
this.protocol = protocol;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
export function
|
|
20
|
+
export function parseLocalScheme(wd, projectDir, lockfileDir, opts) {
|
|
21
21
|
if (wd.bareSpecifier.startsWith('link:') || wd.bareSpecifier.startsWith('workspace:')) {
|
|
22
22
|
return fromLocal(wd, projectDir, lockfileDir, 'directory', opts);
|
|
23
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) {
|
|
24
34
|
if (wd.bareSpecifier.endsWith('.tgz') ||
|
|
25
35
|
wd.bareSpecifier.endsWith('.tar.gz') ||
|
|
26
36
|
wd.bareSpecifier.endsWith('.tar') ||
|
|
27
37
|
wd.bareSpecifier.includes(path.sep) ||
|
|
28
|
-
wd.bareSpecifier.startsWith('file:') ||
|
|
29
38
|
isFilespec.test(wd.bareSpecifier)) {
|
|
30
39
|
const type = isFilename.test(wd.bareSpecifier) ? 'file' : 'directory';
|
|
31
40
|
return fromLocal(wd, projectDir, lockfileDir, type, opts);
|
|
32
41
|
}
|
|
33
|
-
if (wd.bareSpecifier.startsWith('path:')) {
|
|
34
|
-
throw new PathIsUnsupportedProtocolError(wd.bareSpecifier, 'path:');
|
|
35
|
-
}
|
|
36
42
|
return null;
|
|
37
43
|
}
|
|
38
44
|
function fromLocal({ bareSpecifier, injected }, projectDir, lockfileDir, type, opts) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/resolving.local-resolver",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1101.0.0",
|
|
4
4
|
"description": "Resolver for local packages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"normalize-path": "^3.0.0",
|
|
30
30
|
"@pnpm/crypto.hash": "1100.0.1",
|
|
31
31
|
"@pnpm/resolving.resolver-base": "1100.1.3",
|
|
32
|
-
"@pnpm/
|
|
32
|
+
"@pnpm/types": "1101.1.0",
|
|
33
33
|
"@pnpm/error": "1100.0.0",
|
|
34
|
-
"@pnpm/
|
|
34
|
+
"@pnpm/workspace.project-manifest-reader": "1100.0.4"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@pnpm/logger": ">=1001.0.0 <1002.0.0"
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@jest/globals": "30.3.0",
|
|
41
41
|
"@types/normalize-path": "^3.0.2",
|
|
42
|
-
"@pnpm/
|
|
43
|
-
"@pnpm/
|
|
42
|
+
"@pnpm/resolving.local-resolver": "1101.0.0",
|
|
43
|
+
"@pnpm/logger": "1100.0.0"
|
|
44
44
|
},
|
|
45
45
|
"engines": {
|
|
46
46
|
"node": ">=22.13"
|