@yarnpkg/plugin-essentials 4.0.0-rc.47 → 4.0.0-rc.48

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.
@@ -441,24 +441,25 @@ async function autofixLegacyPlugins(configuration, immutable) {
441
441
  return false;
442
442
  const legacyPlugins = [];
443
443
  const yarnPluginDir = fslib_1.ppath.join(configuration.projectCwd, `.yarn/plugins/@yarnpkg`);
444
- const changed = await core_1.Configuration.updateConfiguration(configuration.projectCwd, current => {
445
- if (!Array.isArray(current.plugins))
446
- return current;
447
- const plugins = current.plugins.filter((plugin) => {
448
- if (!plugin.path)
449
- return true;
450
- const resolvedPath = fslib_1.ppath.resolve(configuration.projectCwd, plugin.path);
451
- const isLegacy = core_1.LEGACY_PLUGINS.has(plugin.spec) && fslib_1.ppath.contains(yarnPluginDir, resolvedPath);
452
- if (isLegacy)
453
- legacyPlugins.push(resolvedPath);
454
- return !isLegacy;
455
- });
456
- if (current.plugins.length === plugins.length)
457
- return current;
458
- return {
459
- ...current,
460
- plugins,
461
- };
444
+ const changed = await core_1.Configuration.updateConfiguration(configuration.projectCwd, {
445
+ plugins: plugins => {
446
+ if (!Array.isArray(plugins))
447
+ return plugins;
448
+ const filteredPlugins = plugins.filter((plugin) => {
449
+ if (!plugin.path)
450
+ return true;
451
+ const resolvedPath = fslib_1.ppath.resolve(configuration.projectCwd, plugin.path);
452
+ const isLegacy = core_1.LEGACY_PLUGINS.has(plugin.spec) && fslib_1.ppath.contains(yarnPluginDir, resolvedPath);
453
+ if (isLegacy)
454
+ legacyPlugins.push(resolvedPath);
455
+ return !isLegacy;
456
+ });
457
+ if (filteredPlugins.length === 0)
458
+ return core_1.Configuration.deleteProperty;
459
+ if (filteredPlugins.length === plugins.length)
460
+ return plugins;
461
+ return filteredPlugins;
462
+ },
462
463
  }, {
463
464
  immutable,
464
465
  });
@@ -28,18 +28,19 @@ class PluginRemoveCommand extends cli_1.BaseCommand {
28
28
  await fslib_1.xfs.removePromise(absolutePath);
29
29
  }
30
30
  report.reportInfo(core_1.MessageName.UNNAMED, `Updating the configuration...`);
31
- await core_1.Configuration.updateConfiguration(project.cwd, (current) => {
32
- if (!Array.isArray(current.plugins))
33
- return current;
34
- const plugins = current.plugins.filter((plugin) => {
35
- return plugin.path !== relativePath;
36
- });
37
- if (current.plugins.length === plugins.length)
38
- return current;
39
- return {
40
- ...current,
41
- plugins,
42
- };
31
+ await core_1.Configuration.updateConfiguration(project.cwd, {
32
+ plugins: plugins => {
33
+ if (!Array.isArray(plugins))
34
+ return plugins;
35
+ const filteredPlugins = plugins.filter((plugin) => {
36
+ return plugin.path !== relativePath;
37
+ });
38
+ if (filteredPlugins.length === 0)
39
+ return core_1.Configuration.deleteProperty;
40
+ if (filteredPlugins.length === plugins.length)
41
+ return plugins;
42
+ return filteredPlugins;
43
+ },
43
44
  });
44
45
  });
45
46
  return report.exitCode();
@@ -9,6 +9,7 @@ export default class SetVersionSourcesCommand extends BaseCommand {
9
9
  repository: string;
10
10
  branch: string;
11
11
  plugins: string[];
12
+ dryRun: boolean;
12
13
  noMinify: boolean;
13
14
  force: boolean;
14
15
  skipPlugins: boolean;
@@ -27,10 +27,11 @@ const cloneWorkflow = ({ repository, branch }, target) => [
27
27
  const updateWorkflow = ({ branch }) => [
28
28
  [`git`, `fetch`, `origin`, `--depth=1`, getBranchRef(branch), `--force`],
29
29
  [`git`, `reset`, `--hard`, `FETCH_HEAD`],
30
- [`git`, `clean`, `-dfx`],
30
+ [`git`, `clean`, `-dfx`, `-e`, `packages/yarnpkg-cli/bundles`],
31
31
  ];
32
- const buildWorkflow = ({ plugins, noMinify }, target) => [
32
+ const buildWorkflow = ({ plugins, noMinify }, output, target) => [
33
33
  [`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), `|`],
34
35
  ];
35
36
  // eslint-disable-next-line arca/no-default-export
36
37
  class SetVersionSourcesCommand extends cli_1.BaseCommand {
@@ -48,6 +49,9 @@ class SetVersionSourcesCommand extends cli_1.BaseCommand {
48
49
  this.plugins = clipanion_1.Option.Array(`--plugin`, [], {
49
50
  description: `An array of additional plugins that should be included in the bundle`,
50
51
  });
52
+ this.dryRun = clipanion_1.Option.Boolean(`-n,--dry-run`, false, {
53
+ description: `If set, the bundle will be built but not added to the project`,
54
+ });
51
55
  this.noMinify = clipanion_1.Option.Boolean(`--no-minify`, false, {
52
56
  description: `Build a bundle for development (debugging) - non-minified and non-mangled`,
53
57
  });
@@ -72,15 +76,20 @@ class SetVersionSourcesCommand extends cli_1.BaseCommand {
72
76
  report.reportSeparator();
73
77
  report.reportInfo(core_1.MessageName.UNNAMED, `Building a fresh bundle`);
74
78
  report.reportSeparator();
75
- await runWorkflow(buildWorkflow(this, target), { configuration, context: this.context, target });
76
- report.reportSeparator();
77
- const bundlePath = fslib_1.ppath.resolve(target, `packages/yarnpkg-cli/bundles/yarn.js`);
79
+ const commitHash = await core_1.execUtils.execvp(`git`, [`rev-parse`, `--short`, `HEAD`], { cwd: target, strict: true });
80
+ const bundlePath = fslib_1.ppath.join(target, `packages/yarnpkg-cli/bundles/yarn-${commitHash.stdout.trim()}.js`);
81
+ if (!fslib_1.xfs.existsSync(bundlePath)) {
82
+ await runWorkflow(buildWorkflow(this, bundlePath, target), { configuration, context: this.context, target });
83
+ report.reportSeparator();
84
+ }
78
85
  const bundleBuffer = await fslib_1.xfs.readFilePromise(bundlePath);
79
- const { bundleVersion } = await (0, version_1.setVersion)(configuration, null, async () => bundleBuffer, {
80
- report,
81
- });
82
- if (!this.skipPlugins) {
83
- await updatePlugins(this, bundleVersion, { project, report, target });
86
+ if (!this.dryRun) {
87
+ const { bundleVersion } = await (0, version_1.setVersion)(configuration, null, async () => bundleBuffer, {
88
+ report,
89
+ });
90
+ if (!this.skipPlugins) {
91
+ await updatePlugins(this, bundleVersion, { project, report, target });
92
+ }
84
93
  }
85
94
  });
86
95
  return report.exitCode();
@@ -141,7 +150,7 @@ async function prepareRepo(spec, { configuration, report, target }) {
141
150
  await runWorkflow(updateWorkflow(spec), { configuration, context: spec.context, target });
142
151
  ready = true;
143
152
  }
144
- catch (error) {
153
+ catch {
145
154
  report.reportSeparator();
146
155
  report.reportWarning(core_1.MessageName.UNNAMED, `Repository update failed; we'll try to regenerate it`);
147
156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yarnpkg/plugin-essentials",
3
- "version": "4.0.0-rc.47",
3
+ "version": "4.0.0-rc.48",
4
4
  "stableVersion": "3.3.0",
5
5
  "license": "BSD-2-Clause",
6
6
  "main": "./lib/index.js",
@@ -9,8 +9,8 @@
9
9
  "./package.json": "./package.json"
10
10
  },
11
11
  "dependencies": {
12
- "@yarnpkg/fslib": "^3.0.0-rc.47",
13
- "@yarnpkg/parsers": "^3.0.0-rc.47",
12
+ "@yarnpkg/fslib": "^3.0.0-rc.48",
13
+ "@yarnpkg/parsers": "^3.0.0-rc.48",
14
14
  "ci-info": "^3.2.0",
15
15
  "clipanion": "^3.2.1",
16
16
  "enquirer": "^2.3.6",
@@ -21,17 +21,17 @@
21
21
  "typanion": "^3.12.1"
22
22
  },
23
23
  "peerDependencies": {
24
- "@yarnpkg/cli": "^4.0.0-rc.47",
25
- "@yarnpkg/core": "^4.0.0-rc.47",
26
- "@yarnpkg/plugin-git": "^3.0.0-rc.47"
24
+ "@yarnpkg/cli": "^4.0.0-rc.48",
25
+ "@yarnpkg/core": "^4.0.0-rc.48",
26
+ "@yarnpkg/plugin-git": "^3.0.0-rc.48"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/lodash": "^4.14.136",
30
30
  "@types/micromatch": "^4.0.1",
31
31
  "@types/semver": "^7.1.0",
32
- "@yarnpkg/cli": "^4.0.0-rc.47",
33
- "@yarnpkg/core": "^4.0.0-rc.47",
34
- "@yarnpkg/plugin-git": "^3.0.0-rc.47"
32
+ "@yarnpkg/cli": "^4.0.0-rc.48",
33
+ "@yarnpkg/core": "^4.0.0-rc.48",
34
+ "@yarnpkg/plugin-git": "^3.0.0-rc.48"
35
35
  },
36
36
  "repository": {
37
37
  "type": "git",