Skip to content

Commit

Permalink
Enables all official plugins by default (#4253)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
arcanis authored Mar 29, 2022
1 parent 80a1c28 commit 952e88e
Show file tree
Hide file tree
Showing 56 changed files with 7,194 additions and 3,430 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/debug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on:
pull_request:
types:
- labeled

concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: true

name: Debuggable Container
jobs:
debug:
if: "${{github.event.label.name == 'infra: debug container'}}"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup upterm session
uses: lhotari/action-upterm@d23c2722bdab893785c9fbeae314cbf080645bd7
7 changes: 0 additions & 7 deletions .github/workflows/integration-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,6 @@ jobs:
node ./scripts/run-yarn.js build:cli
mv ./packages/yarnpkg-cli/bundles/yarn.js ./packages/yarnpkg-cli/bundles/yarn-min.js
node ./scripts/run-yarn.js build:cli --no-minify
node ./scripts/run-yarn.js build:plugin-constraints
node ./scripts/run-yarn.js build:plugin-exec
node ./scripts/run-yarn.js build:plugin-interactive-tools
node ./scripts/run-yarn.js build:plugin-stage
node ./scripts/run-yarn.js build:plugin-typescript
node ./scripts/run-yarn.js build:plugin-version
node ./scripts/run-yarn.js build:plugin-workspace-tools
shell: bash

- uses: actions/upload-artifact@v2
Expand Down
9 changes: 1 addition & 8 deletions .github/workflows/release-candidate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,7 @@ jobs:

- name: 'Build a binary for convenience'
run: |
yarn build:cli $(
yarn constraints query "
workspace(Cwd),
workspace_field(Cwd, 'scripts["update-local"]', _),
workspace_ident(Cwd, Ident),
sub_atom(Ident, 0, _, _, '@yarnpkg/plugin-')
" --json | jq -r '"--plugin='$(pwd)'/" + .Cwd' | xargs
)
yarn build:cli
TMPBIN=$(mktemp -d)
cp ./packages/yarnpkg-cli/bundles/yarn.js $TMPBIN/yarn.js
Expand Down
8,701 changes: 6,896 additions & 1,805 deletions .pnp.cjs

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions .yarn/versions/bbd4868b.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
releases:
"@yarnpkg/cli": major
"@yarnpkg/libui": major
"@yarnpkg/plugin-constraints": major
"@yarnpkg/plugin-interactive-tools": major
"@yarnpkg/plugin-version": major

declined:
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-exec"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-nm"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-pnpm"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-workspace-tools"
- "@yarnpkg/builder"
- "@yarnpkg/core"
- "@yarnpkg/doctor"
51 changes: 23 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Yarn is a modern package manager split into various packages. Its novel architec
- Yarn supports [plugins](https://yarnpkg.com/features/plugins); adding a plugin is as simple as adding it into your repository
- Yarn supports Node by default but isn't limited to it - plugins can add support for other languages
- Yarn supports [workspaces](https://yarnpkg.com/features/workspaces) natively, and its CLI takes advantage of that
- 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
- 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
- Yarn is first and foremost a [Node API](https://yarnpkg.com/api/) that can be used programmatically (via [@yarnpkg/core](packages/yarnpkg-core))
- Yarn is written in [TypeScript](https://www.typescriptlang.org/) and is fully type-checked

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

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

- [★ 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.
- [★ plugin-dlx](packages/plugin-dlx) adds support for the [`yarn dlx`](https://yarnpkg.com/cli/dlx) command.
- [★ plugin-essentials](packages/plugin-essentials) adds various commands deemed necessary for a package manager (add, remove, ...).
- [★ plugin-file](packages/plugin-file) adds support for using the `file:` protocol within your dependencies.
- [★ plugin-git](packages/plugin-git) adds support for cloning packages from Git repositories.
- [★ 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)
- [★ plugin-http](packages/plugin-http) adds support for using straight URL references as dependencies (tgz archives only).
- [★ plugin-init](packages/plugin-init) adds support for the [`yarn init`](https://yarnpkg.com/cli/init) command.
- [★ 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.
- [★ plugin-nm](packages/plugin-nm) adds support for installing packages through a `node_modules` folder.
- [★ plugin-npm](packages/plugin-npm) adds support for using [semver ranges](https://semver.org) as dependencies, resolving them to an NPM-like registry.
- [★ 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), ...).
- [★ plugin-pack](packages/plugin-pack) adds support for the [`yarn pack`](https://yarnpkg.com/cli/pack) command.
- [★ plugin-patch](packages/plugin-patch) adds support for the `patch:` protocol.
- [★ plugin-pnp](packages/plugin-pnp) adds support for installing JavaScript dependencies through the [Plug'n'Play](https://yarnpkg.com/features/pnp) specification.

### Contrib plugins

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>`.

- [☆ plugin-constraints](packages/plugin-constraints) adds support for [constraints](https://yarnpkg.com/features/constraints) to Yarn.
- [☆ 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.
- [☆ plugin-interactive-tools](packages/plugin-interactive-tools) adds support for various interactive commands ([`yarn upgrade-interactive`](https://yarnpkg.com/cli/upgrade-interactive)).
- [☆ plugin-stage](packages/plugin-stage) adds support for the [`yarn stage`](https://yarnpkg.com/cli/stage) command.
- [☆ plugin-typescript](packages/plugin-typescript) improves the user experience when working with TypeScript.
- [☆ plugin-version](packages/plugin-version) adds support for the new [release workflow](https://yarnpkg.com/features/release-workflow).
- [☆ plugin-workspace-tools](packages/plugin-workspace-tools) adds support for the [`yarn workspaces foreach`](https://yarnpkg.com/cli/workspaces/foreach) command.
- [plugin-compat](packages/plugin-compat) contains a few built-in patches applied to improve PnP support.
- [plugin-constraints](packages/plugin-constraints) adds support for [constraints](https://yarnpkg.com/features/constraints) to Yarn.
- [plugin-dlx](packages/plugin-dlx) adds support for the [`yarn dlx`](https://yarnpkg.com/cli/dlx) command.
- [plugin-essentials](packages/plugin-essentials) adds various commands deemed necessary for a package manager (add, remove, ...).
- [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.
- [plugin-file](packages/plugin-file) adds support for using the `file:` protocol within your dependencies.
- [plugin-git](packages/plugin-git) adds support for cloning packages from Git repositories.
- [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)
- [plugin-http](packages/plugin-http) adds support for using straight URL references as dependencies (tgz archives only).
- [plugin-init](packages/plugin-init) adds support for the [`yarn init`](https://yarnpkg.com/cli/init) command.
- [plugin-interactive-tools](packages/plugin-interactive-tools) adds support for various interactive commands ([`yarn upgrade-interactive`](https://yarnpkg.com/cli/upgrade-interactive)).
- [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.
- [plugin-nm](packages/plugin-nm) adds support for installing packages through a `node_modules` folder.
- [plugin-npm](packages/plugin-npm) adds support for using [semver ranges](https://semver.org) dependencies, resolving them from an npm-like registry.
- [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), ...).
- [plugin-pack](packages/plugin-pack) adds support for the [`yarn pack`](https://yarnpkg.com/cli/pack) command.
- [plugin-patch](packages/plugin-patch) adds support for the `patch:` protocol.
- [plugin-pnp](packages/plugin-pnp) adds support for installing JavaScript dependencies through the [Plug'n'Play](https://yarnpkg.com/features/pnp) specification.
- [plugin-stage](packages/plugin-stage) adds support for the [`yarn stage`](https://yarnpkg.com/cli/stage) command.
- [plugin-typescript](packages/plugin-typescript) improves the user experience when working with TypeScript.
- [plugin-version](packages/plugin-version) adds support for the new [release workflow](https://yarnpkg.com/features/release-workflow).
- [plugin-workspace-tools](packages/plugin-workspace-tools) adds support for the [`yarn workspaces foreach`](https://yarnpkg.com/cli/workspaces/foreach) command.

### Third-party plugins

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ describe(`Commands`, () => {
for (const [environmentDescription, environment] of Object.entries(environments)) {
for (const [scriptDescription, script] of Object.entries(constraints)) {
test(`test (${environmentDescription} / ${scriptDescription})`,
makeTemporaryEnv({}, {
plugins: [
require.resolve(`@yarnpkg/monorepo/scripts/plugin-constraints.js`),
],
}, async ({path, run, source}) => {
makeTemporaryEnv({}, async ({path, run, source}) => {
await environment(path);
await writeFile(`${path}/constraints.pro`, script);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ import {xfs} from '@yarnpkg/fslib';
import {environments} from './environments';

describe(`Commands`, () => {
const config = {
plugins: [
require.resolve(`@yarnpkg/monorepo/scripts/plugin-constraints.js`),
],
};

const manifest = {
workspaces: [
`packages/*`,
Expand All @@ -24,7 +18,7 @@ describe(`Commands`, () => {
};

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

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

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

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

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

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

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

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

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

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

await xfs.writeFilePromise(`${path}/constraints.pro`, `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ describe(`Commands`, () => {
describe(`constraints query`, () => {
test(
`test without trailing .`,
makeTemporaryEnv({}, {
plugins: [
require.resolve(`@yarnpkg/monorepo/scripts/plugin-constraints.js`),
],
}, async({path, run, source}) => {
makeTemporaryEnv({}, async({path, run, source}) => {
await environments[`one regular dependency`](path);

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

test(
`test with a syntax error`,
makeTemporaryEnv({}, {
plugins: [
require.resolve(`@yarnpkg/monorepo/scripts/plugin-constraints.js`),
],
}, async({path, run, source}) => {
makeTemporaryEnv({}, async({path, run, source}) => {
await environments[`one regular dependency`](path);

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

test(
`test with an unknown predicate`,
makeTemporaryEnv({}, {
plugins: [
require.resolve(`@yarnpkg/monorepo/scripts/plugin-constraints.js`),
],
}, async({path, run, source}) => {
makeTemporaryEnv({}, async({path, run, source}) => {
await environments[`one regular dependency`](path);

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

test(
`test with an empty predicate`,
makeTemporaryEnv({}, {
plugins: [
require.resolve(`@yarnpkg/monorepo/scripts/plugin-constraints.js`),
],
}, async({path, run, source}) => {
makeTemporaryEnv({}, async({path, run, source}) => {
await environments[`one regular dependency`](path);

let code;
Expand All @@ -120,11 +104,7 @@ describe(`Commands`, () => {
for (const [queryDescription, query] of Object.entries(queries)) {
test(
`test (${environmentDescription} / ${queryDescription})`,
makeTemporaryEnv({}, {
plugins: [
require.resolve(`@yarnpkg/monorepo/scripts/plugin-constraints.js`),
],
}, async ({path, run, source}) => {
makeTemporaryEnv({}, async ({path, run, source}) => {
await environment(path);
await writeFile(`${path}/constraints.pro`, constraintsFile);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ describe(`Commands`, () => {
for (const [scriptDescription, script] of Object.entries(constraints)) {
test(
`test (${environmentDescription} / ${scriptDescription})`,
makeTemporaryEnv({}, {
plugins: [
require.resolve(`@yarnpkg/monorepo/scripts/plugin-constraints.js`),
],
}, async ({path, run, source}) => {
makeTemporaryEnv({}, async ({path, run, source}) => {
await environment(path);
await writeFile(`${path}/constraints.pro`, script);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe(`Commands`, () => {

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

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

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

await writeFile(`${path}/.yarnrc.yml`, [
`plugins:`,
` - path: ${JSON.stringify(require.resolve(`@yarnpkg/monorepo/scripts/plugin-version.js`))}`,
` spec: "@yarnpkg/plugin-version"`,
` - path: ${JSON.stringify(require.resolve(`@yarnpkg/monorepo/scripts/plugin-hello-world.js`))}`,
` spec: "@yarnpkg/plugin-hello-world"`,
`npmScopes:`,
` private:`,
` npmRegistryServer: "${url}"`,
Expand Down
Loading

0 comments on commit 952e88e

Please sign in to comment.