@yarnpkg/plugin-essentials 4.0.1 → 4.1.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.
@@ -240,7 +240,7 @@ AddCommand.usage = clipanion_1.Command.Usage({
240
240
 
241
241
  - \`update-lockfile\` will skip the link step altogether, and only fetch packages that are missing from the lockfile (or that have no associated checksums). This mode is typically used by tools like Renovate or Dependabot to keep a lockfile up-to-date without incurring the full install cost.
242
242
 
243
- For a compilation of all the supported protocols, please consult the dedicated page from our website: https://yarnpkg.com/features/protocols.
243
+ For a compilation of all the supported protocols, please consult the dedicated page from our website: https://yarnpkg.com/protocols.
244
244
  `,
245
245
  examples: [[
246
246
  `Add a regular package to the current workspace`,
@@ -241,6 +241,18 @@ class YarnCommand extends cli_1.BaseCommand {
241
241
  restoreResolutions: false,
242
242
  });
243
243
  const enableHardenedMode = configuration.get(`enableHardenedMode`);
244
+ if (enableHardenedMode && typeof configuration.sources.get(`enableHardenedMode`) === `undefined`) {
245
+ await core_1.StreamReport.start({
246
+ configuration,
247
+ json: this.json,
248
+ stdout: this.context.stdout,
249
+ includeFooter: false,
250
+ }, async (report) => {
251
+ report.reportWarning(core_1.MessageName.UNNAMED, `Yarn detected that the current workflow is executed from a public pull request. For safety the hardened mode has been enabled.`);
252
+ report.reportWarning(core_1.MessageName.UNNAMED, `It will prevent malicious lockfile manipulations, in exchange for a slower install time. You can opt-out if necessary; check our ${core_1.formatUtils.applyHyperlink(configuration, `documentation`, `https://yarnpkg.com/features/security#hardened-mode`)} for more details.`);
253
+ report.reportSeparator();
254
+ });
255
+ }
244
256
  if (this.refreshLockfile ?? enableHardenedMode)
245
257
  project.lockfileNeedsRefresh = true;
246
258
  const checkResolutions = this.checkResolutions ?? enableHardenedMode;
@@ -251,15 +263,17 @@ class YarnCommand extends cli_1.BaseCommand {
251
263
  // install logic should be implemented elsewhere (probably in either of
252
264
  // the Configuration and Install classes). Feel free to open an issue
253
265
  // in order to ask for design feedback before writing features.
254
- return await project.installWithNewReport({
266
+ const report = await core_1.StreamReport.start({
267
+ configuration,
255
268
  json: this.json,
256
269
  stdout: this.context.stdout,
257
- }, {
258
- cache,
259
- immutable,
260
- checkResolutions,
261
- mode: this.mode,
270
+ forceSectionAlignment: true,
271
+ includeLogs: true,
272
+ includeVersion: true,
273
+ }, async (report) => {
274
+ await project.install({ cache, report, immutable, checkResolutions, mode: this.mode });
262
275
  });
276
+ return report.exitCode();
263
277
  }
264
278
  }
265
279
  YarnCommand.paths = [
@@ -8,7 +8,6 @@ const core_2 = require("@yarnpkg/core");
8
8
  const fslib_1 = require("@yarnpkg/fslib");
9
9
  const clipanion_1 = require("clipanion");
10
10
  const semver_1 = tslib_1.__importDefault(require("semver"));
11
- const url_1 = require("url");
12
11
  const vm_1 = require("vm");
13
12
  const list_1 = require("./list");
14
13
  // eslint-disable-next-line arca/no-default-export
@@ -39,7 +38,7 @@ class PluginImportCommand extends cli_1.BaseCommand {
39
38
  let pluginUrl;
40
39
  if (this.name.match(/^https?:/)) {
41
40
  try {
42
- new url_1.URL(this.name);
41
+ new URL(this.name);
43
42
  }
44
43
  catch {
45
44
  throw new core_1.ReportError(core_1.MessageName.INVALID_PLUGIN_REFERENCE, `Plugin specifier "${this.name}" is neither a plugin name nor a valid url`);
@@ -1,5 +1,6 @@
1
1
  import { BaseCommand } from '@yarnpkg/cli';
2
2
  export default class RunIndexCommand extends BaseCommand {
3
3
  static paths: string[][];
4
+ json: boolean;
4
5
  execute(): Promise<0 | 1>;
5
6
  }
@@ -3,9 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const cli_1 = require("@yarnpkg/cli");
4
4
  const core_1 = require("@yarnpkg/core");
5
5
  const core_2 = require("@yarnpkg/core");
6
+ const clipanion_1 = require("clipanion");
6
7
  const util_1 = require("util");
7
8
  // eslint-disable-next-line arca/no-default-export
8
9
  class RunIndexCommand extends cli_1.BaseCommand {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.json = clipanion_1.Option.Boolean(`--json`, false, {
13
+ description: `Format the output as an NDJSON stream`,
14
+ });
15
+ }
9
16
  async execute() {
10
17
  const configuration = await core_1.Configuration.find(this.context.cwd, this.context.plugins);
11
18
  const { project, workspace } = await core_1.Project.find(configuration, this.context.cwd);
@@ -14,6 +21,7 @@ class RunIndexCommand extends cli_1.BaseCommand {
14
21
  const report = await core_1.StreamReport.start({
15
22
  configuration,
16
23
  stdout: this.context.stdout,
24
+ json: this.json,
17
25
  }, async (report) => {
18
26
  const scripts = workspace.manifest.scripts;
19
27
  const keys = core_2.miscUtils.sortMap(scripts.keys(), key => key);
@@ -25,8 +33,9 @@ class RunIndexCommand extends cli_1.BaseCommand {
25
33
  const maxKeyLength = keys.reduce((max, key) => {
26
34
  return Math.max(max, key.length);
27
35
  }, 0);
28
- for (const [key, value] of scripts.entries()) {
29
- report.reportInfo(null, `${key.padEnd(maxKeyLength, ` `)} ${(0, util_1.inspect)(value, inspectConfig)}`);
36
+ for (const [key, script] of scripts.entries()) {
37
+ report.reportInfo(null, `${key.padEnd(maxKeyLength, ` `)} ${(0, util_1.inspect)(script, inspectConfig)}`);
38
+ report.reportJson({ name: key, script });
30
39
  }
31
40
  });
32
41
  return report.exitCode();
@@ -3,7 +3,6 @@ import { Usage } from 'clipanion';
3
3
  export default class SetResolutionCommand extends BaseCommand {
4
4
  static paths: string[][];
5
5
  static usage: Usage;
6
- save: boolean;
7
6
  descriptor: string;
8
7
  resolution: string;
9
8
  execute(): Promise<0 | 1>;
@@ -8,9 +8,6 @@ const clipanion_1 = require("clipanion");
8
8
  class SetResolutionCommand extends cli_1.BaseCommand {
9
9
  constructor() {
10
10
  super(...arguments);
11
- this.save = clipanion_1.Option.Boolean(`-s,--save`, false, {
12
- description: `Persist the resolution inside the top-level manifest`,
13
- });
14
11
  this.descriptor = clipanion_1.Option.String();
15
12
  this.resolution = clipanion_1.Option.String();
16
13
  }
@@ -43,7 +40,7 @@ SetResolutionCommand.usage = clipanion_1.Command.Usage({
43
40
  details: `
44
41
  This command updates the resolution table so that \`descriptor\` is resolved by \`resolution\`.
45
42
 
46
- Note that by default this command only affect the current resolution table - meaning that this "manual override" will disappear if you remove the lockfile, or if the package disappear from the table. If you wish to make the enforced resolution persist whatever happens, add the \`-s,--save\` flag which will also edit the \`resolutions\` field from your top-level manifest.
43
+ Note that by default this command only affect the current resolution table - meaning that this "manual override" will disappear if you remove the lockfile, or if the package disappear from the table. If you wish to make the enforced resolution persist whatever happens, edit the \`resolutions\` field in your top-level manifest.
47
44
 
48
45
  Note that no attempt is made at validating that \`resolution\` is a valid resolution entry for \`descriptor\`.
49
46
  `,
@@ -10,6 +10,7 @@ const sources_1 = require("../../plugin/import/sources");
10
10
  const list_1 = require("../../plugin/list");
11
11
  const version_1 = require("../version");
12
12
  const PR_REGEXP = /^[0-9]+$/;
13
+ const IS_WIN32 = process.platform === `win32`;
13
14
  function getBranchRef(branch) {
14
15
  if (PR_REGEXP.test(branch)) {
15
16
  return `pull/${branch}/head`;
@@ -31,7 +32,7 @@ const updateWorkflow = ({ branch }) => [
31
32
  ];
32
33
  const buildWorkflow = ({ plugins, noMinify }, output, target) => [
33
34
  [`yarn`, `build:cli`, ...new Array().concat(...plugins.map(plugin => [`--plugin`, fslib_1.ppath.resolve(target, plugin)])), ...noMinify ? [`--no-minify`] : [], `|`],
34
- [`mv`, `packages/yarnpkg-cli/bundles/yarn.js`, fslib_1.npath.fromPortablePath(output), `|`],
35
+ [IS_WIN32 ? `move` : `mv`, `packages/yarnpkg-cli/bundles/yarn.js`, fslib_1.npath.fromPortablePath(output), `|`],
35
36
  ];
36
37
  // eslint-disable-next-line arca/no-default-export
37
38
  class SetVersionSourcesCommand extends cli_1.BaseCommand {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yarnpkg/plugin-essentials",
3
- "version": "4.0.1",
3
+ "version": "4.1.0",
4
4
  "license": "BSD-2-Clause",
5
5
  "main": "./lib/index.js",
6
6
  "exports": {
@@ -8,7 +8,7 @@
8
8
  "./package.json": "./package.json"
9
9
  },
10
10
  "dependencies": {
11
- "@yarnpkg/fslib": "^3.0.1",
11
+ "@yarnpkg/fslib": "^3.0.2",
12
12
  "@yarnpkg/parsers": "^3.0.0",
13
13
  "ci-info": "^3.2.0",
14
14
  "clipanion": "^4.0.0-rc.2",
@@ -20,16 +20,16 @@
20
20
  "typanion": "^3.14.0"
21
21
  },
22
22
  "peerDependencies": {
23
- "@yarnpkg/cli": "^4.0.1",
24
- "@yarnpkg/core": "^4.0.1",
23
+ "@yarnpkg/cli": "^4.1.0",
24
+ "@yarnpkg/core": "^4.0.3",
25
25
  "@yarnpkg/plugin-git": "^3.0.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/lodash": "^4.14.136",
29
29
  "@types/micromatch": "^4.0.1",
30
30
  "@types/semver": "^7.1.0",
31
- "@yarnpkg/cli": "^4.0.1",
32
- "@yarnpkg/core": "^4.0.1",
31
+ "@yarnpkg/cli": "^4.1.0",
32
+ "@yarnpkg/core": "^4.0.3",
33
33
  "@yarnpkg/plugin-git": "^3.0.0"
34
34
  },
35
35
  "repository": {