@yarnpkg/plugin-pnpm 1.1.0-rc.1 → 1.1.0-rc.13

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.
@@ -9,10 +9,11 @@ export declare class PnpmLinker implements Linker {
9
9
  findPackageLocation(locator: Locator, opts: LinkOptions): Promise<PortablePath>;
10
10
  findPackageLocator(location: PortablePath, opts: LinkOptions): Promise<Locator | null>;
11
11
  makeInstaller(opts: LinkOptions): PnpmInstaller;
12
+ private isEnabled;
12
13
  }
13
14
  declare class PnpmInstaller implements Installer {
14
15
  private opts;
15
- private asyncActions;
16
+ private readonly asyncActions;
16
17
  constructor(opts: LinkOptions);
17
18
  getCustomDataKey(): string;
18
19
  private customData;
package/lib/PnpmLinker.js CHANGED
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PnpmLinker = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const core_1 = require("@yarnpkg/core");
6
5
  const fslib_1 = require("@yarnpkg/fslib");
7
6
  const plugin_pnp_1 = require("@yarnpkg/plugin-pnp");
8
7
  const clipanion_1 = require("clipanion");
9
- const p_limit_1 = (0, tslib_1.__importDefault)(require("p-limit"));
10
8
  class PnpmLinker {
11
9
  supportsPackage(pkg, opts) {
12
- return opts.project.configuration.get(`nodeLinker`) === `pnpm`;
10
+ return this.isEnabled(opts);
13
11
  }
14
12
  async findPackageLocation(locator, opts) {
13
+ if (!this.isEnabled(opts))
14
+ throw new Error(`Assertion failed: Expected the pnpm linker to be enabled`);
15
15
  const customDataKey = getCustomDataKey();
16
16
  const customData = opts.project.installersCustomData.get(customDataKey);
17
17
  if (!customData)
@@ -22,6 +22,8 @@ class PnpmLinker {
22
22
  return packageLocation;
23
23
  }
24
24
  async findPackageLocator(location, opts) {
25
+ if (!this.isEnabled(opts))
26
+ return null;
25
27
  const customDataKey = getCustomDataKey();
26
28
  const customData = opts.project.installersCustomData.get(customDataKey);
27
29
  if (!customData)
@@ -48,12 +50,15 @@ class PnpmLinker {
48
50
  makeInstaller(opts) {
49
51
  return new PnpmInstaller(opts);
50
52
  }
53
+ isEnabled(opts) {
54
+ return opts.project.configuration.get(`nodeLinker`) === `pnpm`;
55
+ }
51
56
  }
52
57
  exports.PnpmLinker = PnpmLinker;
53
58
  class PnpmInstaller {
54
59
  constructor(opts) {
55
60
  this.opts = opts;
56
- this.asyncActions = new AsyncActions();
61
+ this.asyncActions = new core_1.miscUtils.AsyncActions(10);
57
62
  this.customData = {
58
63
  pathByLocator: new Map(),
59
64
  locatorByPath: new Map(),
@@ -216,11 +221,11 @@ class PnpmInstaller {
216
221
  if (!expectedEntries.has(record))
217
222
  removals.push(fslib_1.xfs.removePromise(fslib_1.ppath.join(storeLocation, record)));
218
223
  await Promise.all(removals);
219
- await removeIfEmpty(storeLocation);
220
224
  }
221
225
  // Wait for the package installs to catch up
222
226
  await this.asyncActions.wait(),
223
- await removeIfEmpty(getNodeModulesLocation(this.opts.project));
227
+ await removeIfEmpty(storeLocation);
228
+ await removeIfEmpty(getNodeModulesLocation(this.opts.project));
224
229
  return {
225
230
  customData: this.customData,
226
231
  };
@@ -319,44 +324,3 @@ async function removeIfEmpty(dir) {
319
324
  }
320
325
  }
321
326
  }
322
- function makeDeferred() {
323
- let resolve;
324
- let reject;
325
- const promise = new Promise((resolveFn, rejectFn) => {
326
- resolve = resolveFn;
327
- reject = rejectFn;
328
- });
329
- return { promise, resolve: resolve, reject: reject };
330
- }
331
- class AsyncActions {
332
- constructor() {
333
- this.deferred = new Map();
334
- this.promises = new Map();
335
- this.limit = (0, p_limit_1.default)(10);
336
- }
337
- set(key, factory) {
338
- let deferred = this.deferred.get(key);
339
- if (typeof deferred === `undefined`)
340
- this.deferred.set(key, deferred = makeDeferred());
341
- const promise = this.limit(() => factory());
342
- this.promises.set(key, promise);
343
- promise.then(() => {
344
- if (this.promises.get(key) === promise) {
345
- deferred.resolve();
346
- }
347
- }, err => {
348
- if (this.promises.get(key) === promise) {
349
- deferred.reject(err);
350
- }
351
- });
352
- return deferred.promise;
353
- }
354
- reduce(key, factory) {
355
- var _a;
356
- const promise = (_a = this.promises.get(key)) !== null && _a !== void 0 ? _a : Promise.resolve();
357
- this.set(key, () => factory(promise));
358
- }
359
- async wait() {
360
- await Promise.all(this.promises.values());
361
- }
362
- }
package/package.json CHANGED
@@ -1,23 +1,23 @@
1
1
  {
2
2
  "name": "@yarnpkg/plugin-pnpm",
3
- "version": "1.1.0-rc.1",
3
+ "version": "1.1.0-rc.13",
4
4
  "license": "BSD-2-Clause",
5
5
  "main": "./lib/index.js",
6
6
  "dependencies": {
7
- "@yarnpkg/fslib": "^2.6.0",
8
- "@yarnpkg/plugin-pnp": "^3.1.2-rc.3",
7
+ "@yarnpkg/fslib": "^2.6.1-rc.10",
8
+ "@yarnpkg/plugin-pnp": "^3.2.0-rc.5",
9
9
  "@yarnpkg/plugin-stage": "^3.1.1",
10
- "clipanion": "^3.0.1",
10
+ "clipanion": "^3.2.0-rc.4",
11
11
  "p-limit": "^2.2.0",
12
12
  "tslib": "^1.13.0"
13
13
  },
14
14
  "peerDependencies": {
15
- "@yarnpkg/cli": "^3.2.0-rc.3",
16
- "@yarnpkg/core": "^3.2.0-rc.3"
15
+ "@yarnpkg/cli": "^3.2.0-rc.15",
16
+ "@yarnpkg/core": "^3.2.0-rc.15"
17
17
  },
18
18
  "devDependencies": {
19
- "@yarnpkg/cli": "^3.2.0-rc.3",
20
- "@yarnpkg/core": "^3.2.0-rc.3"
19
+ "@yarnpkg/cli": "^3.2.0-rc.15",
20
+ "@yarnpkg/core": "^3.2.0-rc.15"
21
21
  },
22
22
  "repository": {
23
23
  "type": "git",