@yarnpkg/plugin-essentials 3.4.0 → 3.5.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.
@@ -82,9 +82,9 @@ class AddCommand extends cli_1.BaseCommand {
82
82
  : core_3.structUtils.tryParseDescriptor(pseudoDescriptor);
83
83
  const unsupportedPrefix = pseudoDescriptor.match(/^(https?:|git@github)/);
84
84
  if (unsupportedPrefix)
85
- throw new clipanion_1.UsageError(`It seems you are trying to add a package using a ${core_1.formatUtils.pretty(configuration, `${unsupportedPrefix[0]}...`, core_1.FormatType.RANGE)} url; we now require package names to be explicitly specified.\nTry running the command again with the package name prefixed: ${core_1.formatUtils.pretty(configuration, `yarn add`, core_1.FormatType.CODE)} ${core_1.formatUtils.pretty(configuration, core_3.structUtils.makeDescriptor(core_3.structUtils.makeIdent(null, `my-package`), `${unsupportedPrefix[0]}...`), core_1.FormatType.DESCRIPTOR)}`);
85
+ throw new clipanion_1.UsageError(`It seems you are trying to add a package using a ${core_1.formatUtils.pretty(configuration, `${unsupportedPrefix[0]}...`, core_1.formatUtils.Type.RANGE)} url; we now require package names to be explicitly specified.\nTry running the command again with the package name prefixed: ${core_1.formatUtils.pretty(configuration, `yarn add`, core_1.formatUtils.Type.CODE)} ${core_1.formatUtils.pretty(configuration, core_3.structUtils.makeDescriptor(core_3.structUtils.makeIdent(null, `my-package`), `${unsupportedPrefix[0]}...`), core_1.formatUtils.Type.DESCRIPTOR)}`);
86
86
  if (!request)
87
- throw new clipanion_1.UsageError(`The ${core_1.formatUtils.pretty(configuration, pseudoDescriptor, core_1.FormatType.CODE)} string didn't match the required format (package-name@range). Did you perhaps forget to explicitly reference the package name?`);
87
+ throw new clipanion_1.UsageError(`The ${core_1.formatUtils.pretty(configuration, pseudoDescriptor, core_1.formatUtils.Type.CODE)} string didn't match the required format (package-name@range). Did you perhaps forget to explicitly reference the package name?`);
88
88
  const targetList = suggestTargetList(workspace, request, {
89
89
  dev: this.dev,
90
90
  peer: this.peer,
@@ -6,6 +6,6 @@ export default class LinkCommand extends BaseCommand {
6
6
  all: boolean;
7
7
  private: boolean;
8
8
  relative: boolean;
9
- destination: string;
9
+ destinations: string[];
10
10
  execute(): Promise<1 | 0>;
11
11
  }
@@ -9,15 +9,15 @@ class LinkCommand extends cli_1.BaseCommand {
9
9
  constructor() {
10
10
  super(...arguments);
11
11
  this.all = clipanion_1.Option.Boolean(`-A,--all`, false, {
12
- description: `Link all workspaces belonging to the target project to the current one`,
12
+ description: `Link all workspaces belonging to the target projects to the current one`,
13
13
  });
14
14
  this.private = clipanion_1.Option.Boolean(`-p,--private`, false, {
15
- description: `Also link private workspaces belonging to the target project to the current one`,
15
+ description: `Also link private workspaces belonging to the target projects to the current one`,
16
16
  });
17
17
  this.relative = clipanion_1.Option.Boolean(`-r,--relative`, false, {
18
18
  description: `Link workspaces using relative paths instead of absolute paths`,
19
19
  });
20
- this.destination = clipanion_1.Option.String();
20
+ this.destinations = clipanion_1.Option.Rest();
21
21
  }
22
22
  async execute() {
23
23
  const configuration = await core_1.Configuration.find(this.context.cwd, this.context.plugins);
@@ -28,29 +28,35 @@ class LinkCommand extends cli_1.BaseCommand {
28
28
  await project.restoreInstallState({
29
29
  restoreResolutions: false,
30
30
  });
31
- const absoluteDestination = fslib_1.ppath.resolve(this.context.cwd, fslib_1.npath.toPortablePath(this.destination));
32
- const configuration2 = await core_1.Configuration.find(absoluteDestination, this.context.plugins, { useRc: false, strict: false });
33
- const { project: project2, workspace: workspace2 } = await core_1.Project.find(configuration2, absoluteDestination);
34
- if (project.cwd === project2.cwd)
35
- throw new clipanion_1.UsageError(`Invalid destination; Can't link the project to itself`);
36
- if (!workspace2)
37
- throw new cli_1.WorkspaceRequiredError(project2.cwd, absoluteDestination);
38
31
  const topLevelWorkspace = project.topLevelWorkspace;
39
32
  const linkedWorkspaces = [];
40
- if (this.all) {
41
- for (const workspace of project2.workspaces)
42
- if (workspace.manifest.name && (!workspace.manifest.private || this.private))
43
- linkedWorkspaces.push(workspace);
44
- if (linkedWorkspaces.length === 0) {
45
- throw new clipanion_1.UsageError(`No workspace found to be linked in the target project`);
33
+ for (const destination of this.destinations) {
34
+ const absoluteDestination = fslib_1.ppath.resolve(this.context.cwd, fslib_1.npath.toPortablePath(destination));
35
+ const configuration2 = await core_1.Configuration.find(absoluteDestination, this.context.plugins, { useRc: false, strict: false });
36
+ const { project: project2, workspace: workspace2 } = await core_1.Project.find(configuration2, absoluteDestination);
37
+ if (project.cwd === project2.cwd)
38
+ throw new clipanion_1.UsageError(`Invalid destination '${destination}'; Can't link the project to itself`);
39
+ if (!workspace2)
40
+ throw new cli_1.WorkspaceRequiredError(project2.cwd, absoluteDestination);
41
+ if (this.all) {
42
+ let found = false;
43
+ for (const workspace of project2.workspaces) {
44
+ if (workspace.manifest.name && (!workspace.manifest.private || this.private)) {
45
+ linkedWorkspaces.push(workspace);
46
+ found = true;
47
+ }
48
+ }
49
+ if (!found) {
50
+ throw new clipanion_1.UsageError(`No workspace found to be linked in the target project: ${destination}`);
51
+ }
52
+ }
53
+ else {
54
+ if (!workspace2.manifest.name)
55
+ throw new clipanion_1.UsageError(`The target workspace at '${destination}' doesn't have a name and thus cannot be linked`);
56
+ if (workspace2.manifest.private && !this.private)
57
+ throw new clipanion_1.UsageError(`The target workspace at '${destination}' is marked private - use the --private flag to link it anyway`);
58
+ linkedWorkspaces.push(workspace2);
46
59
  }
47
- }
48
- else {
49
- if (!workspace2.manifest.name)
50
- throw new clipanion_1.UsageError(`The target workspace doesn't have a name and thus cannot be linked`);
51
- if (workspace2.manifest.private && !this.private)
52
- throw new clipanion_1.UsageError(`The target workspace is marked private - use the --private flag to link it anyway`);
53
- linkedWorkspaces.push(workspace2);
54
60
  }
55
61
  for (const workspace of linkedWorkspaces) {
56
62
  const fullName = core_1.structUtils.stringifyIdent(workspace.locator);
@@ -80,8 +86,8 @@ LinkCommand.usage = clipanion_1.Command.Usage({
80
86
  This command will set a new \`resolutions\` field in the project-level manifest and point it to the workspace at the specified location (even if part of another project).
81
87
  `,
82
88
  examples: [[
83
- `Register a remote workspace for use in the current project`,
84
- `$0 link ~/ts-loader`,
89
+ `Register one or more remote workspaces for use in the current project`,
90
+ `$0 link ~/ts-loader ~/jest`,
85
91
  ], [
86
92
  `Register all workspaces from a remote project for use in the current project`,
87
93
  `$0 link ~/jest --all`,
@@ -1,5 +1,4 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
2
  import { BaseCommand } from '@yarnpkg/cli';
4
3
  import { Project, Report } from '@yarnpkg/core';
5
4
  import { Usage } from 'clipanion';
@@ -89,7 +89,7 @@ class RemoveCommand extends cli_1.BaseCommand {
89
89
  ? `any`
90
90
  : `this`;
91
91
  if (unreferencedPatterns.length > 0)
92
- throw new clipanion_1.UsageError(`${patterns} ${core_1.formatUtils.prettyList(configuration, unreferencedPatterns, core_1.FormatType.CODE)} ${dont} match any packages referenced by ${which} workspace`);
92
+ throw new clipanion_1.UsageError(`${patterns} ${core_1.formatUtils.prettyList(configuration, unreferencedPatterns, core_1.formatUtils.Type.CODE)} ${dont} match any packages referenced by ${which} workspace`);
93
93
  if (hasChanged) {
94
94
  await configuration.triggerMultipleHooks((hooks) => hooks.afterWorkspaceDependencyRemoval, afterWorkspaceDependencyRemovalList);
95
95
  const report = await core_2.StreamReport.start({
@@ -1,5 +1,4 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
2
  import { BaseCommand } from '@yarnpkg/cli';
4
3
  import { Configuration, Report } from '@yarnpkg/core';
5
4
  import { Usage } from 'clipanion';
@@ -63,11 +63,11 @@ class SetVersionCommand extends cli_1.BaseCommand {
63
63
  const filePrefix = `file://`;
64
64
  let bundleBuffer;
65
65
  if (bundleUrl.startsWith(filePrefix)) {
66
- report.reportInfo(core_1.MessageName.UNNAMED, `Downloading ${core_2.formatUtils.pretty(configuration, bundleUrl, core_1.FormatType.URL)}`);
66
+ report.reportInfo(core_1.MessageName.UNNAMED, `Downloading ${core_2.formatUtils.pretty(configuration, bundleUrl, core_2.formatUtils.Type.URL)}`);
67
67
  bundleBuffer = await fslib_1.xfs.readFilePromise(fslib_1.npath.toPortablePath(bundleUrl.slice(filePrefix.length)));
68
68
  }
69
69
  else {
70
- report.reportInfo(core_1.MessageName.UNNAMED, `Retrieving ${core_2.formatUtils.pretty(configuration, bundleUrl, core_1.FormatType.PATH)}`);
70
+ report.reportInfo(core_1.MessageName.UNNAMED, `Retrieving ${core_2.formatUtils.pretty(configuration, bundleUrl, core_2.formatUtils.Type.PATH)}`);
71
71
  bundleBuffer = await core_2.httpUtils.get(bundleUrl, { configuration });
72
72
  }
73
73
  await setVersion(configuration, null, bundleBuffer, { report });
@@ -136,9 +136,9 @@ class UpCommand extends cli_1.BaseCommand {
136
136
  }
137
137
  }
138
138
  if (unreferencedPatterns.length > 1)
139
- throw new clipanion_1.UsageError(`Patterns ${core_3.formatUtils.prettyList(configuration, unreferencedPatterns, core_3.FormatType.CODE)} don't match any packages referenced by any workspace`);
139
+ throw new clipanion_1.UsageError(`Patterns ${core_3.formatUtils.prettyList(configuration, unreferencedPatterns, core_3.formatUtils.Type.CODE)} don't match any packages referenced by any workspace`);
140
140
  if (unreferencedPatterns.length > 0)
141
- throw new clipanion_1.UsageError(`Pattern ${core_3.formatUtils.prettyList(configuration, unreferencedPatterns, core_3.FormatType.CODE)} doesn't match any packages referenced by any workspace`);
141
+ throw new clipanion_1.UsageError(`Pattern ${core_3.formatUtils.prettyList(configuration, unreferencedPatterns, core_3.formatUtils.Type.CODE)} doesn't match any packages referenced by any workspace`);
142
142
  const allSuggestions = await Promise.all(allSuggestionsPromises);
143
143
  const checkReport = await core_3.LightReport.start({
144
144
  configuration,
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@yarnpkg/plugin-essentials",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "license": "BSD-2-Clause",
5
5
  "main": "./lib/index.js",
6
6
  "dependencies": {
7
- "@yarnpkg/fslib": "^2.10.3",
7
+ "@yarnpkg/fslib": "^2.10.4",
8
8
  "@yarnpkg/parsers": "^2.6.0",
9
9
  "ci-info": "^3.2.0",
10
10
  "clipanion": "3.2.0-rc.4",
@@ -16,17 +16,17 @@
16
16
  "typanion": "^3.3.0"
17
17
  },
18
18
  "peerDependencies": {
19
- "@yarnpkg/cli": "^3.7.0",
20
- "@yarnpkg/core": "^3.6.0",
21
- "@yarnpkg/plugin-git": "^2.6.7"
19
+ "@yarnpkg/cli": "^3.8.0",
20
+ "@yarnpkg/core": "^3.7.0",
21
+ "@yarnpkg/plugin-git": "^2.6.8"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/lodash": "^4.14.136",
25
25
  "@types/micromatch": "^4.0.1",
26
26
  "@types/semver": "^7.1.0",
27
- "@yarnpkg/cli": "^3.7.0",
28
- "@yarnpkg/core": "^3.6.0",
29
- "@yarnpkg/plugin-git": "^2.6.7"
27
+ "@yarnpkg/cli": "^3.8.0",
28
+ "@yarnpkg/core": "^3.7.0",
29
+ "@yarnpkg/plugin-git": "^2.6.8"
30
30
  },
31
31
  "repository": {
32
32
  "type": "git",