Skip to content

Commit 952e88e

Browse files
authored
Enables all official plugins by default (#4253)
* wip * Enables all plugins by default * Lazy-loads packages * Only adds @types/ packages if the project has a tsconfig * Removes debug * Fixes lint * Adds a configuration option for @types auto-adds * Fixes tests * Removes plugin configuration from the tests * Fixes linting * Removes plugins from the scripts directory * Removes checked-in plugins * Removes plugins from the yaml database * Removes the update-local scripts * Removes the plugin build from the CI * Disables auto types removal if tsEnableAutoTypes is set * Updates readme * Simplifies rc build * Fixes plugins.yml * Fixes tests * Fixes tests * Adds debug workflow * Removes yup * Cancels the debug job on repeated triggers
1 parent 80a1c28 commit 952e88e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+7194
-3430
lines changed

.github/workflows/debug.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
on:
2+
pull_request:
3+
types:
4+
- labeled
5+
6+
concurrency:
7+
group: ${{github.workflow}}-${{github.ref}}
8+
cancel-in-progress: true
9+
10+
name: Debuggable Container
11+
jobs:
12+
debug:
13+
if: "${{github.event.label.name == 'infra: debug container'}}"
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Setup upterm session
19+
uses: lhotari/action-upterm@d23c2722bdab893785c9fbeae314cbf080645bd7

.github/workflows/integration-workflow.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,6 @@ jobs:
158158
node ./scripts/run-yarn.js build:cli
159159
mv ./packages/yarnpkg-cli/bundles/yarn.js ./packages/yarnpkg-cli/bundles/yarn-min.js
160160
node ./scripts/run-yarn.js build:cli --no-minify
161-
node ./scripts/run-yarn.js build:plugin-constraints
162-
node ./scripts/run-yarn.js build:plugin-exec
163-
node ./scripts/run-yarn.js build:plugin-interactive-tools
164-
node ./scripts/run-yarn.js build:plugin-stage
165-
node ./scripts/run-yarn.js build:plugin-typescript
166-
node ./scripts/run-yarn.js build:plugin-version
167-
node ./scripts/run-yarn.js build:plugin-workspace-tools
168161
shell: bash
169162

170163
- uses: actions/upload-artifact@v2

.github/workflows/release-candidate.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,7 @@ jobs:
3131

3232
- name: 'Build a binary for convenience'
3333
run: |
34-
yarn build:cli $(
35-
yarn constraints query "
36-
workspace(Cwd),
37-
workspace_field(Cwd, 'scripts["update-local"]', _),
38-
workspace_ident(Cwd, Ident),
39-
sub_atom(Ident, 0, _, _, '@yarnpkg/plugin-')
40-
" --json | jq -r '"--plugin='$(pwd)'/" + .Cwd' | xargs
41-
)
34+
yarn build:cli
4235
4336
TMPBIN=$(mktemp -d)
4437
cp ./packages/yarnpkg-cli/bundles/yarn.js $TMPBIN/yarn.js

.pnp.cjs

Lines changed: 6896 additions & 1805 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.yarn/versions/bbd4868b.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
releases:
2+
"@yarnpkg/cli": major
3+
"@yarnpkg/libui": major
4+
"@yarnpkg/plugin-constraints": major
5+
"@yarnpkg/plugin-interactive-tools": major
6+
"@yarnpkg/plugin-version": major
7+
8+
declined:
9+
- "@yarnpkg/plugin-compat"
10+
- "@yarnpkg/plugin-dlx"
11+
- "@yarnpkg/plugin-essentials"
12+
- "@yarnpkg/plugin-exec"
13+
- "@yarnpkg/plugin-init"
14+
- "@yarnpkg/plugin-nm"
15+
- "@yarnpkg/plugin-npm-cli"
16+
- "@yarnpkg/plugin-pack"
17+
- "@yarnpkg/plugin-patch"
18+
- "@yarnpkg/plugin-pnp"
19+
- "@yarnpkg/plugin-pnpm"
20+
- "@yarnpkg/plugin-stage"
21+
- "@yarnpkg/plugin-typescript"
22+
- "@yarnpkg/plugin-workspace-tools"
23+
- "@yarnpkg/builder"
24+
- "@yarnpkg/core"
25+
- "@yarnpkg/doctor"

README.md

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Yarn is a modern package manager split into various packages. Its novel architec
2121
- Yarn supports [plugins](https://yarnpkg.com/features/plugins); adding a plugin is as simple as adding it into your repository
2222
- Yarn supports Node by default but isn't limited to it - plugins can add support for other languages
2323
- Yarn supports [workspaces](https://yarnpkg.com/features/workspaces) natively, and its CLI takes advantage of that
24-
- Yarn uses a bash-like [portable shell](https://github.com/yarnpkg/berry/tree/master/packages/yarnpkg-shell#yarnpkgshell) to execute package scripts, guaranteeing they work the same way on Windows, Linux, and macOS
24+
- Yarn uses a bash-like [portable shell](https://github.com/yarnpkg/berry/tree/master/packages/yarnpkg-shell#yarnpkgshell) to make package scripts portable across of Windows, Linux, and macOS
2525
- Yarn is first and foremost a [Node API](https://yarnpkg.com/api/) that can be used programmatically (via [@yarnpkg/core](packages/yarnpkg-core))
2626
- Yarn is written in [TypeScript](https://www.typescriptlang.org/) and is fully type-checked
2727

@@ -194,33 +194,28 @@ Note that no other command is needed! Given that our dependencies are checked-in
194194

195195
Those plugins typically come bundled with Yarn. You don't need to do anything special to use them.
196196

197-
- [★ plugin-compat](packages/plugin-compat) contains various built-in patches that will be applied to packages that aren't compatible with the Plug'n'Play resolution out-of-the-box.
198-
- [★ plugin-dlx](packages/plugin-dlx) adds support for the [`yarn dlx`](https://yarnpkg.com/cli/dlx) command.
199-
- [★ plugin-essentials](packages/plugin-essentials) adds various commands deemed necessary for a package manager (add, remove, ...).
200-
- [★ plugin-file](packages/plugin-file) adds support for using the `file:` protocol within your dependencies.
201-
- [★ plugin-git](packages/plugin-git) adds support for cloning packages from Git repositories.
202-
- [★ plugin-github](packages/plugin-github) adds support for using GitHub references as dependencies. [This plugin doesn't use git.](https://stackoverflow.com/a/13636954/880703)
203-
- [★ plugin-http](packages/plugin-http) adds support for using straight URL references as dependencies (tgz archives only).
204-
- [★ plugin-init](packages/plugin-init) adds support for the [`yarn init`](https://yarnpkg.com/cli/init) command.
205-
- [★ plugin-link](packages/plugin-link) adds support for using [`link:` and `portal:`](https://yarnpkg.com/features/protocols#whats-the-difference-between-link-and-portal) references as dependencies.
206-
- [★ plugin-nm](packages/plugin-nm) adds support for installing packages through a `node_modules` folder.
207-
- [★ plugin-npm](packages/plugin-npm) adds support for using [semver ranges](https://semver.org) as dependencies, resolving them to an NPM-like registry.
208-
- [★ plugin-npm-cli](packages/plugin-npm-cli) adds support for the NPM-specific commands ([`yarn npm info`](https://yarnpkg.com/cli/npm/info), [`yarn npm login`](https://yarnpkg.com/cli/npm/login), [`yarn npm publish`](https://yarnpkg.com/cli/npm/publish), ...).
209-
- [★ plugin-pack](packages/plugin-pack) adds support for the [`yarn pack`](https://yarnpkg.com/cli/pack) command.
210-
- [★ plugin-patch](packages/plugin-patch) adds support for the `patch:` protocol.
211-
- [★ plugin-pnp](packages/plugin-pnp) adds support for installing JavaScript dependencies through the [Plug'n'Play](https://yarnpkg.com/features/pnp) specification.
212-
213-
### Contrib plugins
214-
215-
Although developed on the same repository as Yarn itself, those plugins are optional and need to be explicitly installed through `yarn plugin import @yarnpkg/<plugin-name>`.
216-
217-
- [☆ plugin-constraints](packages/plugin-constraints) adds support for [constraints](https://yarnpkg.com/features/constraints) to Yarn.
218-
- [☆ plugin-exec](packages/plugin-exec) adds support for using the [`exec:`](https://github.com/yarnpkg/berry/tree/master/packages/plugin-exec#documentation) protocol within your dependencies.
219-
- [☆ plugin-interactive-tools](packages/plugin-interactive-tools) adds support for various interactive commands ([`yarn upgrade-interactive`](https://yarnpkg.com/cli/upgrade-interactive)).
220-
- [☆ plugin-stage](packages/plugin-stage) adds support for the [`yarn stage`](https://yarnpkg.com/cli/stage) command.
221-
- [☆ plugin-typescript](packages/plugin-typescript) improves the user experience when working with TypeScript.
222-
- [☆ plugin-version](packages/plugin-version) adds support for the new [release workflow](https://yarnpkg.com/features/release-workflow).
223-
- [☆ plugin-workspace-tools](packages/plugin-workspace-tools) adds support for the [`yarn workspaces foreach`](https://yarnpkg.com/cli/workspaces/foreach) command.
197+
- [plugin-compat](packages/plugin-compat) contains a few built-in patches applied to improve PnP support.
198+
- [plugin-constraints](packages/plugin-constraints) adds support for [constraints](https://yarnpkg.com/features/constraints) to Yarn.
199+
- [plugin-dlx](packages/plugin-dlx) adds support for the [`yarn dlx`](https://yarnpkg.com/cli/dlx) command.
200+
- [plugin-essentials](packages/plugin-essentials) adds various commands deemed necessary for a package manager (add, remove, ...).
201+
- [plugin-exec](packages/plugin-exec) adds support for using the [`exec:`](https://github.com/yarnpkg/berry/tree/master/packages/plugin-exec#documentation) protocol within your dependencies.
202+
- [plugin-file](packages/plugin-file) adds support for using the `file:` protocol within your dependencies.
203+
- [plugin-git](packages/plugin-git) adds support for cloning packages from Git repositories.
204+
- [plugin-github](packages/plugin-github) adds support for using GitHub references as dependencies. [This plugin doesn't use git.](https://stackoverflow.com/a/13636954/880703)
205+
- [plugin-http](packages/plugin-http) adds support for using straight URL references as dependencies (tgz archives only).
206+
- [plugin-init](packages/plugin-init) adds support for the [`yarn init`](https://yarnpkg.com/cli/init) command.
207+
- [plugin-interactive-tools](packages/plugin-interactive-tools) adds support for various interactive commands ([`yarn upgrade-interactive`](https://yarnpkg.com/cli/upgrade-interactive)).
208+
- [plugin-link](packages/plugin-link) adds support for using [`link:` and `portal:`](https://yarnpkg.com/features/protocols#whats-the-difference-between-link-and-portal) references as dependencies.
209+
- [plugin-nm](packages/plugin-nm) adds support for installing packages through a `node_modules` folder.
210+
- [plugin-npm](packages/plugin-npm) adds support for using [semver ranges](https://semver.org) dependencies, resolving them from an npm-like registry.
211+
- [plugin-npm-cli](packages/plugin-npm-cli) adds support for npm-specific commands ([`yarn npm login`](https://yarnpkg.com/cli/npm/login), [`yarn npm publish`](https://yarnpkg.com/cli/npm/publish), ...).
212+
- [plugin-pack](packages/plugin-pack) adds support for the [`yarn pack`](https://yarnpkg.com/cli/pack) command.
213+
- [plugin-patch](packages/plugin-patch) adds support for the `patch:` protocol.
214+
- [plugin-pnp](packages/plugin-pnp) adds support for installing JavaScript dependencies through the [Plug'n'Play](https://yarnpkg.com/features/pnp) specification.
215+
- [plugin-stage](packages/plugin-stage) adds support for the [`yarn stage`](https://yarnpkg.com/cli/stage) command.
216+
- [plugin-typescript](packages/plugin-typescript) improves the user experience when working with TypeScript.
217+
- [plugin-version](packages/plugin-version) adds support for the new [release workflow](https://yarnpkg.com/features/release-workflow).
218+
- [plugin-workspace-tools](packages/plugin-workspace-tools) adds support for the [`yarn workspaces foreach`](https://yarnpkg.com/cli/workspaces/foreach) command.
224219

225220
### Third-party plugins
226221

packages/acceptance-tests/pkg-tests-specs/sources/commands/constraints.test.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@ describe(`Commands`, () => {
3131
for (const [environmentDescription, environment] of Object.entries(environments)) {
3232
for (const [scriptDescription, script] of Object.entries(constraints)) {
3333
test(`test (${environmentDescription} / ${scriptDescription})`,
34-
makeTemporaryEnv({}, {
35-
plugins: [
36-
require.resolve(`@yarnpkg/monorepo/scripts/plugin-constraints.js`),
37-
],
38-
}, async ({path, run, source}) => {
34+
makeTemporaryEnv({}, async ({path, run, source}) => {
3935
await environment(path);
4036
await writeFile(`${path}/constraints.pro`, script);
4137

packages/acceptance-tests/pkg-tests-specs/sources/commands/constraints/fix.test.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ import {xfs} from '@yarnpkg/fslib';
33
import {environments} from './environments';
44

55
describe(`Commands`, () => {
6-
const config = {
7-
plugins: [
8-
require.resolve(`@yarnpkg/monorepo/scripts/plugin-constraints.js`),
9-
],
10-
};
11-
126
const manifest = {
137
workspaces: [
148
`packages/*`,
@@ -24,7 +18,7 @@ describe(`Commands`, () => {
2418
};
2519

2620
describe(`constraints --fix`, () => {
27-
test(`test apply fix to dependencies`, makeTemporaryEnv(manifest, config, async ({path, run, source}) => {
21+
test(`test apply fix to dependencies`, makeTemporaryEnv(manifest, async ({path, run, source}) => {
2822
await xfs.writeFilePromise(`${path}/constraints.pro`, `
2923
gen_enforced_dependency('.', 'is-number', '2.0.0', dependencies).
3024
`);
@@ -37,7 +31,7 @@ describe(`Commands`, () => {
3731
expect(fixedManifest.license).toBe(`MIT`);
3832
}));
3933

40-
test(`test apply fix to fields`, makeTemporaryEnv(manifest, config, async ({path, run, source}) => {
34+
test(`test apply fix to fields`, makeTemporaryEnv(manifest, async ({path, run, source}) => {
4135
await xfs.writeFilePromise(`${path}/constraints.pro`, `
4236
gen_enforced_field('.', 'license', 'BSD-2-Clause').
4337
`);
@@ -50,7 +44,7 @@ describe(`Commands`, () => {
5044
expect(fixedManifest.license).toBe(`BSD-2-Clause`);
5145
}));
5246

53-
test(`test apply fix to fields and manifests`, makeTemporaryEnv(manifest, config, async ({path, run, source}) => {
47+
test(`test apply fix to fields and manifests`, makeTemporaryEnv(manifest, async ({path, run, source}) => {
5448
await xfs.writeFilePromise(`${path}/constraints.pro`, `
5549
gen_enforced_dependency('.', 'is-number', '2.0.0', dependencies).
5650
gen_enforced_field('.', 'license', 'BSD-2-Clause').
@@ -64,7 +58,7 @@ describe(`Commands`, () => {
6458
expect(fixedManifest.license).toBe(`BSD-2-Clause`);
6559
}));
6660

67-
test(`test applying fix shouldn't duplicate workspaces`, makeTemporaryEnv(manifest, config, async ({path, run, source}) => {
61+
test(`test applying fix shouldn't duplicate workspaces`, makeTemporaryEnv(manifest, async ({path, run, source}) => {
6862
await xfs.writeFilePromise(`${path}/constraints.pro`, `
6963
gen_enforced_dependency('.', 'is-number', '2.0.0', dependencies).
7064
gen_enforced_field('.', 'license', 'BSD-2-Clause').
@@ -77,7 +71,7 @@ describe(`Commands`, () => {
7771
expect(fixedManifest.workspaces.length).toBe(1);
7872
}));
7973

80-
it(`should preserve the raw manifest data when applying a fix`, makeTemporaryEnv(manifest, config, async ({path, run, source}) => {
74+
it(`should preserve the raw manifest data when applying a fix`, makeTemporaryEnv(manifest, async ({path, run, source}) => {
8175
await xfs.writeFilePromise(`${path}/constraints.pro`, `
8276
gen_enforced_dependency('.', 'is-number', null, dependencies).
8377
`);
@@ -90,7 +84,7 @@ describe(`Commands`, () => {
9084
expect(fixedManifest.unparsedKey).toBe(`foo`);
9185
}));
9286

93-
test(`test apply fix to string fields`, makeTemporaryEnv(manifest, config, async ({path, run, source}) => {
87+
test(`test apply fix to string fields`, makeTemporaryEnv(manifest, async ({path, run, source}) => {
9488
environments[`various field types`](path);
9589

9690
await xfs.writeFilePromise(`${path}/constraints.pro`, `
@@ -104,7 +98,7 @@ describe(`Commands`, () => {
10498
expect(fixedManifest._name).toStrictEqual(`foo`);
10599
}));
106100

107-
test(`test apply fix to object fields`, makeTemporaryEnv(manifest, config, async ({path, run, source}) => {
101+
test(`test apply fix to object fields`, makeTemporaryEnv(manifest, async ({path, run, source}) => {
108102
environments[`various field types`](path);
109103

110104
await xfs.writeFilePromise(`${path}/constraints.pro`, `
@@ -122,7 +116,7 @@ describe(`Commands`, () => {
122116
});
123117
}));
124118

125-
test(`test apply fix to array fields`, makeTemporaryEnv(manifest, config, async ({path, run, source}) => {
119+
test(`test apply fix to array fields`, makeTemporaryEnv(manifest, async ({path, run, source}) => {
126120
environments[`various field types`](path);
127121

128122
await xfs.writeFilePromise(`${path}/constraints.pro`, `

packages/acceptance-tests/pkg-tests-specs/sources/commands/constraints/query.test.js

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ describe(`Commands`, () => {
2626
describe(`constraints query`, () => {
2727
test(
2828
`test without trailing .`,
29-
makeTemporaryEnv({}, {
30-
plugins: [
31-
require.resolve(`@yarnpkg/monorepo/scripts/plugin-constraints.js`),
32-
],
33-
}, async({path, run, source}) => {
29+
makeTemporaryEnv({}, async({path, run, source}) => {
3430
await environments[`one regular dependency`](path);
3531

3632
let code;
@@ -49,11 +45,7 @@ describe(`Commands`, () => {
4945

5046
test(
5147
`test with a syntax error`,
52-
makeTemporaryEnv({}, {
53-
plugins: [
54-
require.resolve(`@yarnpkg/monorepo/scripts/plugin-constraints.js`),
55-
],
56-
}, async({path, run, source}) => {
48+
makeTemporaryEnv({}, async({path, run, source}) => {
5749
await environments[`one regular dependency`](path);
5850

5951
let code;
@@ -72,11 +64,7 @@ describe(`Commands`, () => {
7264

7365
test(
7466
`test with an unknown predicate`,
75-
makeTemporaryEnv({}, {
76-
plugins: [
77-
require.resolve(`@yarnpkg/monorepo/scripts/plugin-constraints.js`),
78-
],
79-
}, async({path, run, source}) => {
67+
makeTemporaryEnv({}, async({path, run, source}) => {
8068
await environments[`one regular dependency`](path);
8169

8270
let code;
@@ -95,11 +83,7 @@ describe(`Commands`, () => {
9583

9684
test(
9785
`test with an empty predicate`,
98-
makeTemporaryEnv({}, {
99-
plugins: [
100-
require.resolve(`@yarnpkg/monorepo/scripts/plugin-constraints.js`),
101-
],
102-
}, async({path, run, source}) => {
86+
makeTemporaryEnv({}, async({path, run, source}) => {
10387
await environments[`one regular dependency`](path);
10488

10589
let code;
@@ -120,11 +104,7 @@ describe(`Commands`, () => {
120104
for (const [queryDescription, query] of Object.entries(queries)) {
121105
test(
122106
`test (${environmentDescription} / ${queryDescription})`,
123-
makeTemporaryEnv({}, {
124-
plugins: [
125-
require.resolve(`@yarnpkg/monorepo/scripts/plugin-constraints.js`),
126-
],
127-
}, async ({path, run, source}) => {
107+
makeTemporaryEnv({}, async ({path, run, source}) => {
128108
await environment(path);
129109
await writeFile(`${path}/constraints.pro`, constraintsFile);
130110

packages/acceptance-tests/pkg-tests-specs/sources/commands/constraints/source.test.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ describe(`Commands`, () => {
1717
for (const [scriptDescription, script] of Object.entries(constraints)) {
1818
test(
1919
`test (${environmentDescription} / ${scriptDescription})`,
20-
makeTemporaryEnv({}, {
21-
plugins: [
22-
require.resolve(`@yarnpkg/monorepo/scripts/plugin-constraints.js`),
23-
],
24-
}, async ({path, run, source}) => {
20+
makeTemporaryEnv({}, async ({path, run, source}) => {
2521
await environment(path);
2622
await writeFile(`${path}/constraints.pro`, script);
2723

packages/acceptance-tests/pkg-tests-specs/sources/commands/dlx.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ describe(`Commands`, () => {
9292

9393
await writeFile(`${path}/.yarnrc.yml`, [
9494
`plugins:`,
95-
` - ${JSON.stringify(require.resolve(`@yarnpkg/monorepo/scripts/plugin-version.js`))}`,
95+
` - ${JSON.stringify(require.resolve(`@yarnpkg/monorepo/scripts/plugin-hello-world.js`))}`,
9696
`npmScopes:`,
9797
` private:`,
9898
` npmRegistryServer: "${url}"`,
@@ -111,7 +111,7 @@ describe(`Commands`, () => {
111111
makeTemporaryEnv({}, async ({path, run, source}) => {
112112
const url = await startPackageServer();
113113

114-
const relativePluginPath = require.resolve(`@yarnpkg/monorepo/scripts/plugin-version.js`);
114+
const relativePluginPath = require.resolve(`@yarnpkg/monorepo/scripts/plugin-hello-world.js`);
115115

116116
await writeFile(`${path}/.yarnrc.yml`, [
117117
`plugins:`,
@@ -136,8 +136,8 @@ describe(`Commands`, () => {
136136

137137
await writeFile(`${path}/.yarnrc.yml`, [
138138
`plugins:`,
139-
` - path: ${JSON.stringify(require.resolve(`@yarnpkg/monorepo/scripts/plugin-version.js`))}`,
140-
` spec: "@yarnpkg/plugin-version"`,
139+
` - path: ${JSON.stringify(require.resolve(`@yarnpkg/monorepo/scripts/plugin-hello-world.js`))}`,
140+
` spec: "@yarnpkg/plugin-hello-world"`,
141141
`npmScopes:`,
142142
` private:`,
143143
` npmRegistryServer: "${url}"`,

0 commit comments

Comments
 (0)