@yarnpkg/plugin-pnp 3.1.2-rc.6 → 3.2.0-rc.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/lib/PnpLinker.d.ts +4 -2
- package/lib/PnpLinker.js +30 -19
- package/package.json +8 -8
package/lib/PnpLinker.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Descriptor, LocatorHash } from '@yarnpkg/core';
|
|
1
|
+
import { Descriptor, LocatorHash, InstallPackageExtraApi } from '@yarnpkg/core';
|
|
2
2
|
import { FetchResult, Locator, Package } from '@yarnpkg/core';
|
|
3
3
|
import { Linker, LinkOptions, MinimalLinkOptions, Installer } from '@yarnpkg/core';
|
|
4
4
|
import { PortablePath } from '@yarnpkg/fslib';
|
|
@@ -10,10 +10,12 @@ export declare class PnpLinker implements Linker {
|
|
|
10
10
|
findPackageLocation(locator: Locator, opts: LinkOptions): Promise<PortablePath>;
|
|
11
11
|
findPackageLocator(location: PortablePath, opts: LinkOptions): Promise<Locator | null>;
|
|
12
12
|
makeInstaller(opts: LinkOptions): PnpInstaller;
|
|
13
|
+
private isEnabled;
|
|
13
14
|
}
|
|
14
15
|
export declare class PnpInstaller implements Installer {
|
|
15
16
|
protected opts: LinkOptions;
|
|
16
17
|
protected mode: string;
|
|
18
|
+
private readonly asyncActions;
|
|
17
19
|
private readonly packageRegistry;
|
|
18
20
|
private readonly virtualTemplates;
|
|
19
21
|
private isESMLoaderRequired;
|
|
@@ -21,7 +23,7 @@ export declare class PnpInstaller implements Installer {
|
|
|
21
23
|
getCustomDataKey(): string;
|
|
22
24
|
private customData;
|
|
23
25
|
attachCustomData(customData: any): void;
|
|
24
|
-
installPackage(pkg: Package, fetchResult: FetchResult): Promise<{
|
|
26
|
+
installPackage(pkg: Package, fetchResult: FetchResult, api: InstallPackageExtraApi): Promise<{
|
|
25
27
|
packageLocation: PortablePath;
|
|
26
28
|
buildDirective: import("@yarnpkg/core").BuildDirective[] | null;
|
|
27
29
|
}>;
|
package/lib/PnpLinker.js
CHANGED
|
@@ -25,13 +25,11 @@ class PnpLinker {
|
|
|
25
25
|
this.pnpCache = new Map();
|
|
26
26
|
}
|
|
27
27
|
supportsPackage(pkg, opts) {
|
|
28
|
-
|
|
29
|
-
return false;
|
|
30
|
-
if (opts.project.configuration.get(`pnpMode`) !== this.mode)
|
|
31
|
-
return false;
|
|
32
|
-
return true;
|
|
28
|
+
return this.isEnabled(opts);
|
|
33
29
|
}
|
|
34
30
|
async findPackageLocation(locator, opts) {
|
|
31
|
+
if (!this.isEnabled(opts))
|
|
32
|
+
throw new Error(`Assertion failed: Expected the PnP linker to be enabled`);
|
|
35
33
|
const pnpPath = (0, index_1.getPnpPath)(opts.project).cjs;
|
|
36
34
|
if (!fslib_1.xfs.existsSync(pnpPath))
|
|
37
35
|
throw new clipanion_1.UsageError(`The project in ${core_1.formatUtils.pretty(opts.project.configuration, `${opts.project.cwd}/package.json`, core_1.formatUtils.Type.PATH)} doesn't seem to have been installed - running an install there might help`);
|
|
@@ -45,6 +43,8 @@ class PnpLinker {
|
|
|
45
43
|
return fslib_1.npath.toPortablePath(packageInformation.packageLocation);
|
|
46
44
|
}
|
|
47
45
|
async findPackageLocator(location, opts) {
|
|
46
|
+
if (!this.isEnabled(opts))
|
|
47
|
+
return null;
|
|
48
48
|
const pnpPath = (0, index_1.getPnpPath)(opts.project).cjs;
|
|
49
49
|
if (!fslib_1.xfs.existsSync(pnpPath))
|
|
50
50
|
return null;
|
|
@@ -59,12 +59,20 @@ class PnpLinker {
|
|
|
59
59
|
makeInstaller(opts) {
|
|
60
60
|
return new PnpInstaller(opts);
|
|
61
61
|
}
|
|
62
|
+
isEnabled(opts) {
|
|
63
|
+
if (opts.project.configuration.get(`nodeLinker`) !== `pnp`)
|
|
64
|
+
return false;
|
|
65
|
+
if (opts.project.configuration.get(`pnpMode`) !== this.mode)
|
|
66
|
+
return false;
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
62
69
|
}
|
|
63
70
|
exports.PnpLinker = PnpLinker;
|
|
64
71
|
class PnpInstaller {
|
|
65
72
|
constructor(opts) {
|
|
66
73
|
this.opts = opts;
|
|
67
74
|
this.mode = `strict`;
|
|
75
|
+
this.asyncActions = new core_1.miscUtils.AsyncActions(10);
|
|
68
76
|
this.packageRegistry = new Map();
|
|
69
77
|
this.virtualTemplates = new Map();
|
|
70
78
|
this.isESMLoaderRequired = false;
|
|
@@ -83,7 +91,7 @@ class PnpInstaller {
|
|
|
83
91
|
attachCustomData(customData) {
|
|
84
92
|
this.customData = customData;
|
|
85
93
|
}
|
|
86
|
-
async installPackage(pkg, fetchResult) {
|
|
94
|
+
async installPackage(pkg, fetchResult, api) {
|
|
87
95
|
const key1 = core_1.structUtils.stringifyIdent(pkg);
|
|
88
96
|
const key2 = pkg.reference;
|
|
89
97
|
const isWorkspace = !!this.opts.project.tryWorkspaceByLocator(pkg);
|
|
@@ -122,7 +130,7 @@ class PnpInstaller {
|
|
|
122
130
|
? jsInstallUtils.extractBuildScripts(pkg, customPackageData, dependencyMeta, { configuration: this.opts.project.configuration, report: this.opts.report })
|
|
123
131
|
: [];
|
|
124
132
|
const packageFs = mayNeedToBeUnplugged
|
|
125
|
-
? await this.unplugPackageIfNeeded(pkg, customPackageData, fetchResult, dependencyMeta)
|
|
133
|
+
? await this.unplugPackageIfNeeded(pkg, customPackageData, fetchResult, dependencyMeta, api)
|
|
126
134
|
: fetchResult.packageFs;
|
|
127
135
|
if (fslib_1.ppath.isAbsolute(fetchResult.prefixPath))
|
|
128
136
|
throw new Error(`Assertion failed: Expected the prefix path (${fetchResult.prefixPath}) to be relative to the parent`);
|
|
@@ -223,6 +231,7 @@ class PnpInstaller {
|
|
|
223
231
|
packageRegistry,
|
|
224
232
|
shebang,
|
|
225
233
|
});
|
|
234
|
+
await this.asyncActions.wait();
|
|
226
235
|
return {
|
|
227
236
|
customData: this.customData,
|
|
228
237
|
};
|
|
@@ -317,9 +326,9 @@ class PnpInstaller {
|
|
|
317
326
|
}
|
|
318
327
|
return nodeModules;
|
|
319
328
|
}
|
|
320
|
-
async unplugPackageIfNeeded(pkg, customPackageData, fetchResult, dependencyMeta) {
|
|
329
|
+
async unplugPackageIfNeeded(pkg, customPackageData, fetchResult, dependencyMeta, api) {
|
|
321
330
|
if (this.shouldBeUnplugged(pkg, customPackageData, dependencyMeta)) {
|
|
322
|
-
return this.unplugPackage(pkg, fetchResult);
|
|
331
|
+
return this.unplugPackage(pkg, fetchResult, api);
|
|
323
332
|
}
|
|
324
333
|
else {
|
|
325
334
|
return fetchResult.packageFs;
|
|
@@ -338,20 +347,22 @@ class PnpInstaller {
|
|
|
338
347
|
return true;
|
|
339
348
|
return false;
|
|
340
349
|
}
|
|
341
|
-
async unplugPackage(locator, fetchResult) {
|
|
350
|
+
async unplugPackage(locator, fetchResult, api) {
|
|
342
351
|
const unplugPath = pnpUtils.getUnpluggedPath(locator, { configuration: this.opts.project.configuration });
|
|
343
352
|
if (this.opts.project.disabledLocators.has(locator.locatorHash))
|
|
344
353
|
return new fslib_1.AliasFS(unplugPath, { baseFs: fetchResult.packageFs, pathUtils: fslib_1.ppath });
|
|
345
354
|
this.unpluggedPaths.add(unplugPath);
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
+
api.holdFetchResult(this.asyncActions.set(locator.locatorHash, async () => {
|
|
356
|
+
const readyFile = fslib_1.ppath.join(unplugPath, fetchResult.prefixPath, `.ready`);
|
|
357
|
+
if (await fslib_1.xfs.existsPromise(readyFile))
|
|
358
|
+
return;
|
|
359
|
+
// Delete any build state for the locator so it can run anew, this allows users
|
|
360
|
+
// to remove `.yarn/unplugged` and have the builds run again
|
|
361
|
+
this.opts.project.storedBuildState.delete(locator.locatorHash);
|
|
362
|
+
await fslib_1.xfs.mkdirPromise(unplugPath, { recursive: true });
|
|
363
|
+
await fslib_1.xfs.copyPromise(unplugPath, fslib_1.PortablePath.dot, { baseFs: fetchResult.packageFs, overwrite: false });
|
|
364
|
+
await fslib_1.xfs.writeFilePromise(readyFile, ``);
|
|
365
|
+
}));
|
|
355
366
|
return new fslib_1.CwdFS(unplugPath);
|
|
356
367
|
}
|
|
357
368
|
getPackageInformation(locator) {
|
package/package.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yarnpkg/plugin-pnp",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0-rc.1",
|
|
4
4
|
"license": "BSD-2-Clause",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@types/semver": "^7.1.0",
|
|
8
|
-
"@yarnpkg/fslib": "^2.6.1-rc.
|
|
8
|
+
"@yarnpkg/fslib": "^2.6.1-rc.6",
|
|
9
9
|
"@yarnpkg/plugin-stage": "^3.1.1",
|
|
10
|
-
"@yarnpkg/pnp": "^3.1.1-rc.
|
|
11
|
-
"clipanion": "^3.0.
|
|
10
|
+
"@yarnpkg/pnp": "^3.1.1-rc.11",
|
|
11
|
+
"clipanion": "^3.2.0-rc.4",
|
|
12
12
|
"micromatch": "^4.0.2",
|
|
13
13
|
"semver": "^7.1.2",
|
|
14
14
|
"tslib": "^1.13.0"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@yarnpkg/cli": "^3.2.0-rc.
|
|
18
|
-
"@yarnpkg/core": "^3.2.0-rc.
|
|
17
|
+
"@yarnpkg/cli": "^3.2.0-rc.11",
|
|
18
|
+
"@yarnpkg/core": "^3.2.0-rc.11"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/micromatch": "^4.0.1",
|
|
22
|
-
"@yarnpkg/cli": "^3.2.0-rc.
|
|
23
|
-
"@yarnpkg/core": "^3.2.0-rc.
|
|
22
|
+
"@yarnpkg/cli": "^3.2.0-rc.11",
|
|
23
|
+
"@yarnpkg/core": "^3.2.0-rc.11"
|
|
24
24
|
},
|
|
25
25
|
"repository": {
|
|
26
26
|
"type": "git",
|