diff --git a/.gitignore b/.gitignore index e4e9ea615ea8..17009f00783b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -# https://yarnpkg.com/getting-started/qa/#which-files-should-be-gitignored +# https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored .yarn/* !.yarn/cache !.yarn/patches diff --git a/.pnp.cjs b/.pnp.cjs index 5e033b6038eb..bda164210db3 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -8837,6 +8837,7 @@ const RAW_RUNTIME_STATE = ["@monaco-editor/react", "virtual:efae73f2e9aa11493dde5182b5b7f0894b5c101cb3c916b74523dc0bde92d8579259d43c7f83a5363dbd8939dc3d1e6c45c5965b9191878533d9a2c19b046d70#npm:4.4.6"],\ ["@primer/octicons-react", "virtual:efae73f2e9aa11493dde5182b5b7f0894b5c101cb3c916b74523dc0bde92d8579259d43c7f83a5363dbd8939dc3d1e6c45c5965b9191878533d9a2c19b046d70#npm:17.7.0"],\ ["@tsconfig/docusaurus", "npm:2.0.0"],\ + ["@types/cross-spawn", "npm:6.0.0"],\ ["@types/dompurify", "npm:3.0.2"],\ ["@types/git-url-parse", "npm:9.0.0"],\ ["@types/lodash", "npm:4.14.172"],\ @@ -8852,6 +8853,7 @@ const RAW_RUNTIME_STATE = ["@types/semver", "npm:7.5.0"],\ ["@types/three", "npm:0.144.0"],\ ["@yarnpkg/cli", "virtual:8bb72793b532d34e63bbc26264dcbcfc4dc4faa0a42627635e997081722bf229d67b7a677d86a568dad949d756630e45b9d4da97ee14b1b4c506494f8a58ea91#workspace:packages/yarnpkg-cli"],\ + ["@yarnpkg/core", "workspace:packages/yarnpkg-core"],\ ["@yarnpkg/fslib", "workspace:packages/yarnpkg-fslib"],\ ["@yarnpkg/libzip", "virtual:b73ceab179a3b4f89c4a5be81bd0c20a80eda623489cb284f304cc8104dbb771916bbc246d0ba809faebd8459cb6554cf114954badb021279ea7aee216456122#workspace:packages/yarnpkg-libzip"],\ ["@yarnpkg/monorepo", "workspace:."],\ @@ -8861,6 +8863,7 @@ const RAW_RUNTIME_STATE = ["ansi-to-html", "npm:0.7.2"],\ ["clipanion", "virtual:576bf3e379b293160348e4cadfbd6541796e6f78477b0875c4437065090cec6f78b6ec2281b8e15d1c870d61578dc7dee16a5ae49a65701fec83e592ce2ebdeb#npm:4.0.0-rc.2"],\ ["clsx", "npm:1.2.1"],\ + ["cross-spawn", "npm:7.0.3"],\ ["dompurify", "npm:3.0.5"],\ ["esbuild-loader", "virtual:efae73f2e9aa11493dde5182b5b7f0894b5c101cb3c916b74523dc0bde92d8579259d43c7f83a5363dbd8939dc3d1e6c45c5965b9191878533d9a2c19b046d70#npm:2.20.0"],\ ["git-url-parse", "npm:13.1.0"],\ diff --git a/.yarn/patches/typedoc-npm-0.17.0-3-0ce05847cf.patch b/.yarn/patches/typedoc-npm-0.17.0-3-0ce05847cf.patch deleted file mode 100644 index 698f32663f8b..000000000000 --- a/.yarn/patches/typedoc-npm-0.17.0-3-0ce05847cf.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/dist/lib/converter/factories/reference.js b/dist/lib/converter/factories/reference.js -index 08cf5781b27bd5e0018a8b74e295dec209d37e57..178d46b932f3ce5764db3a766008b4d075d10edf 100644 ---- a/dist/lib/converter/factories/reference.js -+++ b/dist/lib/converter/factories/reference.js -@@ -19,7 +19,8 @@ function createReferenceReflection(context, source, target) { - if (!(context.scope instanceof models_1.ContainerReflection)) { - throw new Error('Cannot add reference to a non-container'); - } -- if (target.declarations.some(d => context.isOutsideDocumentation(d.getSourceFile().fileName))) { -+ const declarations = target.getDeclarations(); -+ if (!declarations || declarations.some(d => context.isOutsideDocumentation(d.getSourceFile().fileName))) { - return; - } - const reflection = new models_1.ReferenceReflection(source.name, [reference_1.ReferenceState.Unresolved, context.checker.getFullyQualifiedName(target)], context.scope); diff --git a/.yarn/versions/aa1cf688.yml b/.yarn/versions/aa1cf688.yml new file mode 100644 index 000000000000..7b1be90befc3 --- /dev/null +++ b/.yarn/versions/aa1cf688.yml @@ -0,0 +1,23 @@ +releases: + "@yarnpkg/cli": patch + "@yarnpkg/doctor": patch + "@yarnpkg/plugin-essentials": patch + "@yarnpkg/plugin-init": patch + "@yarnpkg/plugin-patch": patch + +declined: + - "@yarnpkg/plugin-compat" + - "@yarnpkg/plugin-constraints" + - "@yarnpkg/plugin-dlx" + - "@yarnpkg/plugin-interactive-tools" + - "@yarnpkg/plugin-nm" + - "@yarnpkg/plugin-npm-cli" + - "@yarnpkg/plugin-pack" + - "@yarnpkg/plugin-pnp" + - "@yarnpkg/plugin-pnpm" + - "@yarnpkg/plugin-stage" + - "@yarnpkg/plugin-typescript" + - "@yarnpkg/plugin-version" + - "@yarnpkg/plugin-workspace-tools" + - "@yarnpkg/builder" + - "@yarnpkg/core" diff --git a/README.md b/README.md index ebbad8d9557e..7130966bb449 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Yarn is a modern package manager split into various packages. Its novel architecture allows to do things currently impossible with existing solutions: -- Yarn supports [plugins](https://yarnpkg.com/features/plugins); adding a plugin is as simple as adding it to your repository +- Yarn supports [plugins](https://yarnpkg.com/features/extensibility); 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 make package scripts portable across Windows, Linux, and macOS diff --git a/package.json b/package.json index 4492a5899720..8980687d29c8 100644 --- a/package.json +++ b/package.json @@ -32,9 +32,7 @@ }, "resolutions": { "ink": "patch:ink@npm%3A3.0.8#~/.yarn/patches/ink-npm-3.0.8-3a8005f59f.patch", - "yoga-layout-prebuilt": "patch:yoga-layout-prebuilt@1.10.0#./.yarn/patches/yoga-layout-prebuilt.patch", - "typedoc@npm:0.16.0": "patch:typedoc@npm%3A0.17.0-3#~/.yarn/patches/typedoc-npm-0.17.0-3-0ce05847cf.patch", - "typedoc@npm:0.17.0-3": "patch:typedoc@npm%3A0.17.0-3#~/.yarn/patches/typedoc-npm-0.17.0-3-0ce05847cf.patch" + "yoga-layout-prebuilt": "patch:yoga-layout-prebuilt@1.10.0#./.yarn/patches/yoga-layout-prebuilt.patch" }, "dependenciesMeta": { "core-js": { @@ -48,27 +46,6 @@ }, "fsevents": { "built": false - }, - "gatsby": { - "built": false - }, - "gatsby-cli": { - "built": false - }, - "gatsby-plugin-mdx@2.14.0": { - "unplugged": true - }, - "gatsby-telemetry": { - "built": false - }, - "react-json-doc@2.1.0": { - "unplugged": true - }, - "react-json-doc@2.3.2": { - "unplugged": true - }, - "svg2png": { - "unplugged": true } }, "scripts": { diff --git a/packages/docusaurus/README.md b/packages/docusaurus/README.md index aaba2fa1e16e..461c04efdc9c 100644 --- a/packages/docusaurus/README.md +++ b/packages/docusaurus/README.md @@ -2,13 +2,7 @@ This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator. -### Installation - -``` -$ yarn -``` - -### Local Development +### Development ``` $ yarn start @@ -26,16 +20,4 @@ This command generates static content into the `build` directory and can be serv ### Deployment -Using SSH: - -``` -$ USE_SSH=true yarn deploy -``` - -Not using SSH: - -``` -$ GIT_USER= yarn deploy -``` - -If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. +The `master` branch is automatically deployed to https://yarnpkg.com/ via [Netlify](https://www.netlify.com/). Pull Requests are also deployed as Deploy Previews. diff --git a/packages/docusaurus/docs/advanced/01-general-reference/lexicon.md b/packages/docusaurus/docs/advanced/01-general-reference/lexicon.md index b409c4d1e7c4..4265506ce76f 100644 --- a/packages/docusaurus/docs/advanced/01-general-reference/lexicon.md +++ b/packages/docusaurus/docs/advanced/01-general-reference/lexicon.md @@ -132,13 +132,13 @@ See also: [Workspaces](/features/workspaces) A range is a string that, when combined with a package name, can be used to select multiple versions of a single package. Ranges typically follow semver, but can use any of the supported Yarn protocols. -See also: [Protocols](/features/protocols) +See also: [Protocols](/protocols) ### Reference A reference is a string that, when combined with a package name, can be used to select one single version of a single package. References typically follow semver, but can use any of the supported Yarn protocols. -See also: [Protocols](/features/protocols) +See also: [Protocols](/protocols) ### Resolver @@ -192,7 +192,7 @@ Generally speaking workspaces are a Yarn features used to work on multiple proje In the context of Yarn's vocabulary, workspaces are local packages that directly belong to a project. -See also: [Packages](/features/packages), [Workspaces](/features/workspaces) +See also: [Workspaces](/features/workspaces) ### Worktree diff --git a/packages/docusaurus/docs/advanced/02-package-management/lifecycle-scripts.md b/packages/docusaurus/docs/advanced/02-package-management/lifecycle-scripts.md index de3dc17e77ae..aa319b4a1a81 100644 --- a/packages/docusaurus/docs/advanced/02-package-management/lifecycle-scripts.md +++ b/packages/docusaurus/docs/advanced/02-package-management/lifecycle-scripts.md @@ -26,7 +26,7 @@ Although rarely called directly, `yarn pack` is a crucial part of Yarn. Each tim This script is called before `yarn npm publish` before the package has even been packed. This is the place where you'll want to check that the project is in an ok state. :::caution -Because it's only called on prepublish, **the prepublish hook shouldn't have side effects.** In particular don't transpile the package sources in `prepublish`, as people consuming directly your repository (such as through the [`git:` protocol](/features/protocols#git)) wouldn't be able to use your project. Instead, use `prepack`. +Because it's only called on prepublish, **the prepublish hook shouldn't have side effects.** In particular don't transpile the package sources in `prepublish`, as people consuming directly your repository (such as through the [`git:` protocol](/protocol/git)) wouldn't be able to use your project. Instead, use `prepack`. ::: ## `postinstall` diff --git a/packages/docusaurus/docs/advanced/02-package-management/rulebook.md b/packages/docusaurus/docs/advanced/02-package-management/rulebook.md index 2922bcaf0660..8224c419afec 100644 --- a/packages/docusaurus/docs/advanced/02-package-management/rulebook.md +++ b/packages/docusaurus/docs/advanced/02-package-management/rulebook.md @@ -9,10 +9,6 @@ Writing portable packages is incredibly important, as it ensures that your users To help with that, this page details the up-to-date collection of good practices you should follow in order to make your package work seamlessly on all three main package managers (Yarn, pnpm, and npm), and explanations if you want to learn more. -```toc -# This code block gets replaced with the Table of Contents -``` - ## Packages should only ever require what they formally list in their dependencies **Why?** Because otherwise your package will be susceptible to unpredictable [hoisting](/advanced/lexicon#hoisting) that will lead some of your consumers to experience pseudo-random crashes, depending on the other packages they will happen to use. diff --git a/packages/docusaurus/docs/advanced/03-pnp/pnp-api.md b/packages/docusaurus/docs/advanced/03-pnp/pnp-api.md index 6a03dab42c1a..1aa3708f0a98 100644 --- a/packages/docusaurus/docs/advanced/03-pnp/pnp-api.md +++ b/packages/docusaurus/docs/advanced/03-pnp/pnp-api.md @@ -265,7 +265,7 @@ This function will return `null` if the request is a builtin module, unless `con export function resolveVirtual(path: string): string | null; ``` -**Important:** This function is not part of the Plug'n'Play specification and only available as a Yarn extension. In order to use it, you first must check that the [`VERSIONS`](/advanced/pnp-api#versions) dictionary contains a valid `resolveVirtual` property. +**Important:** This function is not part of the Plug'n'Play specification and only available as a Yarn extension. In order to use it, you first must check that the [`VERSIONS`](/advanced/pnpapi#versions) dictionary contains a valid `resolveVirtual` property. The `resolveVirtual` function will accept any path as parameter and return the same path minus any [virtual component](/advanced/lexicon#virtual-package). This makes it easier to store the location to the files in a portable way as long as you don't care about losing the dependency tree information in the process (requiring files through those paths will prevent them from accessing their peer dependencies). diff --git a/packages/docusaurus/docs/advanced/03-pnp/pnp-spec.md b/packages/docusaurus/docs/advanced/03-pnp/pnp-spec.md index 827f5a20ea8c..90b6990801d5 100644 --- a/packages/docusaurus/docs/advanced/03-pnp/pnp-spec.md +++ b/packages/docusaurus/docs/advanced/03-pnp/pnp-spec.md @@ -295,7 +295,7 @@ FIND_PNP_MANIFEST(url) Finding the right PnP manifest to use for a resolution isn't always trivial. There are two main options: -- Assume that there is a single PnP manifest covering the whole project. This is the most common case, as even when referencing third-party projects (for example via the [`portal:` protocol](/features/protocols#whats-the-difference-between-link-and-portal)) their dependency trees are stored in the same manifest as the main project. +- Assume that there is a single PnP manifest covering the whole project. This is the most common case, as even when referencing third-party projects (for example via the [`portal:` protocol](/protocol/portal#portals-vs-links)) their dependency trees are stored in the same manifest as the main project. To do that, call [`FIND_CLOSEST_PNP_MANIFEST`](#find_closest_pnp_manifest)`(require.main.filename)` once at the start of the process, cache its result, and return it for each call to [`FIND_PNP_MANIFEST`](#find_pnp_manifest) (if you're running in Node.js, you can even use `require.resolve('pnpapi')` which will do this work for you). diff --git a/packages/docusaurus/docs/advanced/04-technical/architecture.md b/packages/docusaurus/docs/advanced/04-technical/architecture.md index 1d1e51ce8c5b..cace8fcb5fd7 100644 --- a/packages/docusaurus/docs/advanced/04-technical/architecture.md +++ b/packages/docusaurus/docs/advanced/04-technical/architecture.md @@ -31,7 +31,7 @@ What happens when running `yarn install` can be summarized in a few different st - Now that we have the exact set of packages that make up our dependency tree, we iterate over it and for each of them we start a new request to the cache to know whether the package is anywhere to be found. If it isn't we do just like we did in the previous step and we ask our plugins (through the [`Fetcher`](https://github.com/yarnpkg/berry/blob/master/packages/yarnpkg-core/sources/Fetcher.ts) interface) whether they know about the package ([`supports`](https://github.com/yarnpkg/berry/blob/master/packages/yarnpkg-core/sources/Fetcher.ts#L43)) and if so to retrieve it from whatever its remote location is ([`fetch`](https://github.com/yarnpkg/berry/blob/master/packages/yarnpkg-core/sources/Fetcher.ts#L67)). - - Interesting tidbit regarding the fetchers: they communicate with the core through an abstraction layer over `fs`. We do this so that our packages can come from many different sources - it can be from a zip archive for packages downloaded from a registry, or from an actual directory on the disk for [`portal:`](/features/protocols#portal) dependencies. + - Interesting tidbit regarding the fetchers: they communicate with the core through an abstraction layer over `fs`. We do this so that our packages can come from many different sources - it can be from a zip archive for packages downloaded from a registry, or from an actual directory on the disk for [`portal:`](/protocol/portal) dependencies. 3. And finally, once all the packages are ready for consumption, comes the "link step": diff --git a/packages/docusaurus/docs/advanced/04-technical/plugin-tutorial.md b/packages/docusaurus/docs/advanced/04-technical/plugin-tutorial.md index cf0ff326b57b..093052bd4ae8 100644 --- a/packages/docusaurus/docs/advanced/04-technical/plugin-tutorial.md +++ b/packages/docusaurus/docs/advanced/04-technical/plugin-tutorial.md @@ -5,7 +5,7 @@ title: "Plugin Tutorial" description: A basic plugin tutorial which shows how to work with Yarn's plugin API. --- -Starting from the Yarn 2, Yarn now supports plugins. For more information about what they are and in which case you'd want to use them, consult the [dedicated page](/features/plugins). We'll talk here about the exact steps needed to write one. It's quite simple, really! +Starting from the Yarn 2, Yarn now supports plugins. For more information about what they are and in which case you'd want to use them, consult the [dedicated page](/features/extensibility). We'll talk here about the exact steps needed to write one. It's quite simple, really! ## What does a plugin look like? diff --git a/packages/docusaurus/docs/features/constraints.md b/packages/docusaurus/docs/features/constraints.md index 22f8eba04e06..887d8fea92a9 100644 --- a/packages/docusaurus/docs/features/constraints.md +++ b/packages/docusaurus/docs/features/constraints.md @@ -6,7 +6,7 @@ description: An in-depth guide to Yarn's constraints, a feature that provides an --- :::info -This page documents the new JavaScript-based constraints. The older constraints, based on Prolog, are still supported but should be considered deprecated. Their documentation can be found [here](/features/constraints-prolog). +This page documents the new JavaScript-based constraints. The older constraints, based on Prolog, are still supported but should be considered deprecated. Their documentation can be found [here](https://v3.yarnpkg.com/features/constraints). ::: ## Overview @@ -156,4 +156,3 @@ module.exports = defineConfig({ }, }); ``` - diff --git a/packages/docusaurus/docs/features/patching.md b/packages/docusaurus/docs/features/patching.md index bf7685760119..4464a513fa96 100644 --- a/packages/docusaurus/docs/features/patching.md +++ b/packages/docusaurus/docs/features/patching.md @@ -27,6 +27,6 @@ By default, `yarn patch` will always reset the patch. If you wish to add new cha ## Limitations -- Because they're currently computed at fetch time rather than resolution time, the package dependencies have already been resolved and patches won't be able to alter them. +- Because they're currently computed at fetch time rather than resolution time, the package dependencies have already been resolved and patches won't be able to alter them. Instead, use the `packageExtensions` mechanism which is specifically made to add new runtime dependencies to packages. - Patches are ill-suited for modifying binary files. Minified files are problematic as well, although we could improve the feature to automatically process such files through a Prettier-like tool. diff --git a/packages/docusaurus/docs/features/publishing.md b/packages/docusaurus/docs/features/publishing.md deleted file mode 100644 index 623731e386c8..000000000000 --- a/packages/docusaurus/docs/features/publishing.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -category: features -slug: /features/publishing -title: "Publishing" -description: Yarn features that simplify the process of releasing new versions on the npm registry. ---- - -## Overview diff --git a/packages/docusaurus/docs/features/release-workflow.md b/packages/docusaurus/docs/features/release-workflow.md new file mode 100644 index 000000000000..d2b7815cb563 --- /dev/null +++ b/packages/docusaurus/docs/features/release-workflow.md @@ -0,0 +1,88 @@ +--- +category: features +path: /features/release-workflow +title: "Release Workflow" +description: An in-depth guide to Yarn's release workflow which helps with managing versions across a monorepo. +--- + + +:::info Experimental +This feature is still incubating, and we'll likely be improving it based on your feedback. +::: + +When working with monorepos, a hard task often is to figure out which packages should receive a new version when starting a new release. Yarn offers a few tools that aim to make this workflow easier without the need for third-party tools (although it's possible you may prefer the workflow offered by different implementations, of course!). + +## Auto-updated dependencies + +When running the `yarn version` command to upgrade the version of a workspace, every other workspace that depend on the first one through a basic semver ranges (`^x.y.z`, `~x.y.z`, ...) will get auto-updated to reference the new version. For example, let's say we have the following workspaces: + +``` +/packages/common (1.0.0) +/packages/server (depends on common@^1.0.0) +/packages/client (depends on common@^1.0.0) +``` + +In pre-2.0, upgrading `common` would have required you to run the command there, then go into each of `server` and `client` to manually upgrade their dependencies to reference the new version. But not anymore! If we run `yarn version 1.1.1` into `common`, the following changes will be applied: + +``` +/packages/common (1.1.1) +/packages/server (depends on common@^1.1.1) +/packages/client (depends on common@^1.1.1) +``` + +Of course it's not that important when the packages from the monorepo are always meant to be used as part of the monorepo, but it becomes much more interesting when you work with multiple packages meant to be published. Had you forgotten to update the range of either of your dependent packages, your users would have potentially downloaded an old version of `common` which wouldn't have been compatible with the newer one. + +## Deferred versioning + +Starting from the 2.0, the `yarn version` command now accepts a new flag: `--deferred`. When set, this flag will cause the command to not immediately change the `version` field of the local manifest, but to instead internally record an entry stating that the current package will need to receive an upgrade during the next release cycle. For example, the following: + +``` +yarn version minor --deferred +``` + +Will not cause the `package.json` file to change! Instead, Yarn will create (or reuse, if you're inside a branch) a file within the `.yarn/versions` directory. This file will record the requested upgrade: + +```yaml +releases: + my-package@1.0.0: minor +``` + +Then later on, once you're ready, just run `yarn version apply`. Yarn will then locate all the upgrade records it previously saved, and apply them all at once (including by taking care of upgrading inter-dependencies as we saw). + +## Checked-in deferred records + +We've seen in the previous section that `yarn version patch` could store the future versions in an internal folder, `.yarn/versions`. But why is that? What good is it? To answer this question, consider a popular open-source project developed through a monorepo. This project receives many external pull requests, but they aren't released right away - they're often released as part of a batch. Every once in a while, the lead maintainer will take all the changes, convert them into new versions, and start the deployment. + +Let's focus on the part where changes have to be converted into versions. How does that work? This isn't easy. Taking Lerna, for example (the most popular version management tool for monorepos), you have two solutions: + +- With the fixed mode, all your packages have a single version. As such, they get upgraded all at once. + +- With the independent mode, you get to chose a version for each package whose sources changed. + +One critical problem remains, though: even if you use the independent mode, how will you know which packages are meant to be upgraded? And, just as critical, should they be patch releases? Minor releases? Hard to know - large projects can receive dozens of PRs a week, and keeping track of which units need to be released and to which version is a pretty difficult task. + +With Yarn's workflow, however, this all becomes very easy! Since the upgrades are kept in a file, and since this file is magically bound to a Git branch, it simply becomes a matter of committing the release folder - all expected releases will then become part of the project history until comes the time of `yarn version apply` - then Yarn will consume all the individual records, merge them (so that a PR requiring a minor will have higher precedence than the PR requiring a patch), and apply them simultaneously. + +As an added bonus, you'll even be able to review the package upgrades as part of the typical PR review! This will have the effect of delegating more power to your community while being able to ensure that everyone follows rules. + +## Ensuring that versions are bumped (CI) + +One problem with committing the deferred releases, however, is that it becomes important to make sure that the PRs you receive include the correct package release definitions. For example, you should be able to trust that the definition contains release strategies (patch, minor, major, ...) for each modified workspace. + +To solve this problem in an automated way, the `yarn version check` command appeared. When run, this command will figure out which packages changed and whether they are listed in the release definition file. If they aren't, an error will be thrown and - assuming you integrate this into a CI system such as the GitHub Actions - the PR author will be asked to fill out the release definition file. + +Writing this file can be tedious; fortunately `yarn version check` implements a very handy flag named `--interactive`. When set (`yarn version check --interactive`), Yarn will print a terminal interface that will summarize all the changed files, all the changed workspaces, all relevant dependent workspaces, and checkboxes for each entry allowing you to pick the release strategies you want to set for each workspace. + +The [`changesetIgnorePatterns`](/configuration/yarnrc#changesetIgnorePatterns) configuration option can be used to ignore files when checking which files have changed. It is useful for excluding files that don't affect the release process (e.g. test files). + +### Caveat + +#### Commit history + +The [version plugin](https://github.com/yarnpkg/berry/tree/master/packages/plugin-version) requires access to the commit history in order to be able to correctly infer which packages require release specifications. In particular, when using GitHub Actions with `actions/checkout@v2` or greater the default behavior is for Git to fetch just the version being checked, which would cause problems. To correct this, you will need to override the `fetch-depth` configuration value to fetch the whole commit history: + +```yaml +- uses: actions/checkout@v2 + with: + fetch-depth: 0 +``` diff --git a/packages/docusaurus/docs/getting-started/extra/questions-and-answers.md b/packages/docusaurus/docs/getting-started/extra/questions-and-answers.md index 36a7315fd99d..af4a3640868c 100644 --- a/packages/docusaurus/docs/getting-started/extra/questions-and-answers.md +++ b/packages/docusaurus/docs/getting-started/extra/questions-and-answers.md @@ -43,7 +43,7 @@ Generally, a few main things will need to be taken care of: 4. Some tools (mostly React Native and Flow) will require downgrading to the `node_modules` install strategy by setting the [`nodeLinker`](https://yarnpkg.com/configuration/yarnrc#nodeLinker) setting to `node-modules`. TypeScript doesn't have this problem. -Most projects will only face those four problems, which can all be fixed in a good afternoon of work. For more detailed instructions, please see the detailed [migration guide](/getting-started/migration). +Most projects will only face those four problems, which can all be fixed in a good afternoon of work. For more detailed instructions, please see the detailed [migration guide](/migration/guide). ## Which files should be gitignored? @@ -211,7 +211,7 @@ Speed is relative and a temporary state. Processes, roadmaps and core values are ## Why is TypeScript patched even if I don't use Plug'n'Play? -Given that PnP is a resolver standard different from Node, tools that reimplement the `require.resolve` API need to add some logic to account for the PnP resolution. While various projects did so (for example Webpack 5 now supports PnP out of the box), a few are still on the fence about it. In the case of TypeScript we started and keep maintaining a [pull request](https://github.com/microsoft/TypeScript/pull/35206), but the TypeScript team still has to accept it. In order to unblock our users, we made the decision to automatically apply this exact pull request to the downloaded TypeScript versions, using our new [`patch:` protocol](/features/protocols#patch). +Given that PnP is a resolver standard different from Node, tools that reimplement the `require.resolve` API need to add some logic to account for the PnP resolution. While various projects did so (for example Webpack 5 now supports PnP out of the box), a few are still on the fence about it. In the case of TypeScript we started and keep maintaining a [pull request](https://github.com/microsoft/TypeScript/pull/35206), but the TypeScript team still has to accept it. In order to unblock our users, we made the decision to automatically apply this exact pull request to the downloaded TypeScript versions, using our new [`patch:` protocol](/protocol/patch). Which now begs the question: why do we still apply this patch even when Plug'n'Play is disabled? The main reason is that Yarn intends to provide consistent behaviour. Some setups involve using the `node_modules` linker during development (to avoid having to setup editor [SDKS](/getting-started/editor-sdks)) and PnP in production (for install speed). If we were to only apply the patches when PnP is enabled, then the package cache would turn different, which would for example break immutable installs. diff --git a/packages/docusaurus/docs/getting-started/migrating/pnp.md b/packages/docusaurus/docs/getting-started/migrating/pnp.md index 70f8925dcedb..b807ace9085e 100644 --- a/packages/docusaurus/docs/getting-started/migrating/pnp.md +++ b/packages/docusaurus/docs/getting-started/migrating/pnp.md @@ -15,7 +15,7 @@ While we recommend to use [Yarn Plug'n'Play](/features/pnp) for new projects, en ## Calling the Doctor -Plug'n'Play enforces strict [dependency rules]((/advanced/rulebook)). You'll get errors should something in your application rely on unlisted dependencies which could cause your application to become unstable. +Plug'n'Play enforces strict [dependency rules](/advanced/rulebook). You'll get errors should something in your application rely on unlisted dependencies which could cause your application to become unstable. To quickly detect which places may rely on unsafe patterns, Yarn provides a tool called the Doctor. Just run `yarn dlx @yarnpkg/doctor` in your project and the Doctor will start looking at your source files to detect any potentially problematic pattern. diff --git a/packages/docusaurus/docs/protocols/_category_.json b/packages/docusaurus/docs/protocols/_category_.json deleted file mode 100644 index 9585d84268b2..000000000000 --- a/packages/docusaurus/docs/protocols/_category_.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "label": "Protocols", - "collapsed": true, - "collapsible": false -} diff --git a/packages/docusaurus/docusaurus.config.js b/packages/docusaurus/docusaurus.config.js index 7a8cbbc93dec..adf134cad166 100644 --- a/packages/docusaurus/docusaurus.config.js +++ b/packages/docusaurus/docusaurus.config.js @@ -6,6 +6,8 @@ require(`@yarnpkg/monorepo/scripts/setup-local-plugins`); const fs = require(`fs`); +const {YarnVersion} = require(`@yarnpkg/core`); + const lightCodeTheme = require(`prism-react-renderer/themes/github`); const darkCodeTheme = require(`prism-react-renderer/themes/dracula`); @@ -73,6 +75,11 @@ const config = { }, docs: { routeBasePath: `/`, + versions: { + current: { + label: `master (${YarnVersion})`, + }, + }, sidebarPath: require.resolve(`./sidebars.js`), editUrl: `https://github.com/yarnpkg/berry/edit/master/packages/docusaurus/`, remarkPlugins, @@ -145,6 +152,21 @@ const config = { label: `Blog`, position: `left`, }, + { + type: `docsVersionDropdown`, + position: `right`, + dropdownActiveClassDisabled: true, + dropdownItemsAfter: [ + { + label: `3.6.4`, + href: `https://v3.yarnpkg.com`, + }, + { + label: `1.22.19`, + href: `https://classic.yarnpkg.com/en/docs`, + }, + ], + }, { href: `https://discord.gg/yarnpkg`, label: `Discord`, diff --git a/packages/docusaurus/empty.js b/packages/docusaurus/empty.js deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/packages/docusaurus/package.json b/packages/docusaurus/package.json index 49a4732bc24b..fa27e0547e68 100644 --- a/packages/docusaurus/package.json +++ b/packages/docusaurus/package.json @@ -6,11 +6,8 @@ "start": "NODE_OPTIONS=\"${NODE_OPTIONS:-} --require ./vfs.js\" docusaurus start", "build": "NODE_OPTIONS=\"${NODE_OPTIONS:-} --require ./vfs.js\" docusaurus build", "swizzle": "docusaurus swizzle", - "deploy": "docusaurus deploy", "clear": "docusaurus clear", - "serve": "docusaurus serve", - "write-translations": "docusaurus write-translations", - "write-heading-ids": "docusaurus write-heading-ids" + "serve": "docusaurus serve" }, "dependencies": { "@codesandbox/sandpack-react": "^1.15.0", @@ -22,10 +19,12 @@ "@primer/octicons-react": "^17.7.0", "@types/three": "^0.144.0", "@yarnpkg/cli": "workspace:^", + "@yarnpkg/core": "workspace:^", "@yarnpkg/parsers": "workspace:^", "algoliasearch": "^4.14.2", "clipanion": "^4.0.0-rc.2", "clsx": "^1.2.1", + "cross-spawn": "7.0.3", "dompurify": "^3.0.5", "git-url-parse": "^13.1.0", "github-markdown-css": "^5.1.0", @@ -72,6 +71,7 @@ "@docusaurus/theme-classic": "^2.4.3", "@docusaurus/theme-common": "^2.4.3", "@tsconfig/docusaurus": "^2.0.0", + "@types/cross-spawn": "6.0.0", "@types/dompurify": "^3", "@types/git-url-parse": "^9.0.0", "@types/lodash": "^4.14.136", diff --git a/packages/docusaurus/plugin.js b/packages/docusaurus/plugin.js index 04ec35303c2f..83cc9e1d49b5 100644 --- a/packages/docusaurus/plugin.js +++ b/packages/docusaurus/plugin.js @@ -17,6 +17,7 @@ module.exports = function(context, options) { fallback: { fs: false, module: false, + buffer: false, os: require.resolve(`os-browserify`), path: require.resolve(`path-browserify`), }, diff --git a/packages/docusaurus/sidebars.js b/packages/docusaurus/sidebars.js index 6a9d0482cab7..4e3fd0647f76 100644 --- a/packages/docusaurus/sidebars.js +++ b/packages/docusaurus/sidebars.js @@ -19,7 +19,6 @@ const sidebars = { advanced: [{type: `autogenerated`, dirName: `advanced`}], features: [{type: `autogenerated`, dirName: `features`}], configuration: [{type: `autogenerated`, dirName: `configuration`}], - protocols: [{type: `autogenerated`, dirName: `protocols`}], // But you can create a sidebar manually /* diff --git a/packages/docusaurus/src/css/custom.css b/packages/docusaurus/src/css/custom.css index 980fa1da95bd..dea3955ad191 100644 --- a/packages/docusaurus/src/css/custom.css +++ b/packages/docusaurus/src/css/custom.css @@ -204,7 +204,7 @@ html.search-page-wrapper .row { .rjd-annotation a { color: rgb(156, 220, 254); text-decoration: underline; - text-decoration-skip: ink; + text-decoration-skip-ink: auto; text-decoration-color: #518dae; text-underline-offset: 0.2em; } diff --git a/packages/docusaurus/src/remark/commandLineHighlight.ts b/packages/docusaurus/src/remark/commandLineHighlight.ts index 7df62735595d..412d644c6695 100644 --- a/packages/docusaurus/src/remark/commandLineHighlight.ts +++ b/packages/docusaurus/src/remark/commandLineHighlight.ts @@ -130,7 +130,7 @@ const makeCommandOrRawLine = (line: string, cli: YarnCli) => { try { return makeCommandLine(line, cli); } catch (err: any) { - console.log(`Failed to parse "${line}": ${err.message}`); + console.log(`Failed to parse "${line}"`); return makeRawLine(line); } }; diff --git a/packages/docusaurus/static/img/docusaurus.png b/packages/docusaurus/static/img/docusaurus.png deleted file mode 100644 index f458149e3c8f..000000000000 Binary files a/packages/docusaurus/static/img/docusaurus.png and /dev/null differ diff --git a/packages/docusaurus/static/img/favicon.ico b/packages/docusaurus/static/img/favicon.ico deleted file mode 100644 index c01d54bcd39a..000000000000 Binary files a/packages/docusaurus/static/img/favicon.ico and /dev/null differ diff --git a/packages/docusaurus/static/img/logo.svg b/packages/docusaurus/static/img/logo.svg deleted file mode 100644 index 9db6d0d066e3..000000000000 --- a/packages/docusaurus/static/img/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/docusaurus/static/img/undraw_docusaurus_mountain.svg b/packages/docusaurus/static/img/undraw_docusaurus_mountain.svg deleted file mode 100644 index af961c49a888..000000000000 --- a/packages/docusaurus/static/img/undraw_docusaurus_mountain.svg +++ /dev/null @@ -1,171 +0,0 @@ - - Easy to Use - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/docusaurus/static/img/undraw_docusaurus_react.svg b/packages/docusaurus/static/img/undraw_docusaurus_react.svg deleted file mode 100644 index 94b5cf08f88f..000000000000 --- a/packages/docusaurus/static/img/undraw_docusaurus_react.svg +++ /dev/null @@ -1,170 +0,0 @@ - - Powered by React - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/docusaurus/static/img/undraw_docusaurus_tree.svg b/packages/docusaurus/static/img/undraw_docusaurus_tree.svg deleted file mode 100644 index d9161d33920c..000000000000 --- a/packages/docusaurus/static/img/undraw_docusaurus_tree.svg +++ /dev/null @@ -1,40 +0,0 @@ - - Focus on What Matters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/docusaurus/static/img/yarn-bg-lossless.webp b/packages/docusaurus/static/img/yarn-bg-lossless.webp deleted file mode 100644 index 41bf6e457609..000000000000 Binary files a/packages/docusaurus/static/img/yarn-bg-lossless.webp and /dev/null differ diff --git a/packages/docusaurus/static/img/yarn-bg-white.webp b/packages/docusaurus/static/img/yarn-bg-white.webp deleted file mode 100644 index 4ce32093090f..000000000000 Binary files a/packages/docusaurus/static/img/yarn-bg-white.webp and /dev/null differ diff --git a/packages/docusaurus/static/img/yarn-hero-compressed.png b/packages/docusaurus/static/img/yarn-hero-compressed.png deleted file mode 100644 index 12774344acae..000000000000 Binary files a/packages/docusaurus/static/img/yarn-hero-compressed.png and /dev/null differ diff --git a/packages/docusaurus/static/img/yarn-hero-opaque.png b/packages/docusaurus/static/img/yarn-hero-opaque.png deleted file mode 100644 index 8337c56d276a..000000000000 Binary files a/packages/docusaurus/static/img/yarn-hero-opaque.png and /dev/null differ diff --git a/packages/docusaurus/static/img/yarn-hero-stars.png b/packages/docusaurus/static/img/yarn-hero-stars.png deleted file mode 100644 index 54b9eb93899f..000000000000 Binary files a/packages/docusaurus/static/img/yarn-hero-stars.png and /dev/null differ diff --git a/packages/docusaurus/static/img/yarn-hero-transparent.png b/packages/docusaurus/static/img/yarn-hero-transparent.png deleted file mode 100644 index 0a5e66595078..000000000000 Binary files a/packages/docusaurus/static/img/yarn-hero-transparent.png and /dev/null differ diff --git a/packages/docusaurus/vfs.js b/packages/docusaurus/vfs.js index e9000e410677..f8baac119e26 100644 --- a/packages/docusaurus/vfs.js +++ b/packages/docusaurus/vfs.js @@ -2,7 +2,7 @@ require(`@yarnpkg/monorepo/scripts/setup-ts-execution`); const {ppath, npath} = require(`@yarnpkg/fslib`); const {mountMemoryDrive} = require(`@yarnpkg/libzip`); -const {execFileSync} = require(`child_process`); +const crossSpawn = require(`cross-spawn`); const {constants} = require(`fs`); const memoryDrive = mountMemoryDrive( @@ -41,9 +41,10 @@ for (const [position, {binary, package}] of binaries.entries()) { ? `/cli` : `/${name}/cli`; - const output = execFileSync(`yarn`, [`node`, binary, `--clipanion=definitions`], { + const output = crossSpawn.sync(`yarn`, [`node`, binary, `--clipanion=definitions`], { env: {...process.env, NODE_OPTIONS: undefined}, - }); + windowsHide: true, + }).stdout; let commands; try { diff --git a/packages/plugin-essentials/sources/commands/add.ts b/packages/plugin-essentials/sources/commands/add.ts index 9aaf74678e09..5a2f99cb513e 100644 --- a/packages/plugin-essentials/sources/commands/add.ts +++ b/packages/plugin-essentials/sources/commands/add.ts @@ -43,7 +43,7 @@ export default class AddCommand extends BaseCommand { - \`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. - For a compilation of all the supported protocols, please consult the dedicated page from our website: https://yarnpkg.com/features/protocols. + For a compilation of all the supported protocols, please consult the dedicated page from our website: https://yarnpkg.com/protocols. `, examples: [[ `Add a regular package to the current workspace`, diff --git a/packages/plugin-init/sources/commands/init.ts b/packages/plugin-init/sources/commands/init.ts index 365c5d5287d4..a8fe7e7b8308 100644 --- a/packages/plugin-init/sources/commands/init.ts +++ b/packages/plugin-init/sources/commands/init.ts @@ -182,7 +182,7 @@ export default class InitCommand extends BaseCommand { ``, `# Swap the comments on the following lines if you wish to use zero-installs`, `# In that case, don't forget to run \`yarn config set enableGlobalCache false\`!`, - `# Documentation here: https://yarnpkg.com/features/zero-installs`, + `# Documentation here: https://yarnpkg.com/features/caching#zero-installs`, ``, `#!.yarn/cache`, `.pnp.*`, diff --git a/packages/plugin-patch/README.md b/packages/plugin-patch/README.md index e3e27e39cb33..635311826796 100644 --- a/packages/plugin-patch/README.md +++ b/packages/plugin-patch/README.md @@ -24,4 +24,4 @@ This plugin is included by default in Yarn. ## Caveat -You cannot add dependencies through the `patch:` protocol. Check this [FAQ entry](https://yarnpkg.com/features/protocols#why-cant-i-add-dependencies-through-the-patch-protocol) for more details. +You cannot add dependencies through the `patch:` protocol. Check this [FAQ entry](https://yarnpkg.com/features/patching#limitations) for more details. diff --git a/packages/yarnpkg-doctor/README.md b/packages/yarnpkg-doctor/README.md index 55725b4952d0..6ee7b577cd13 100644 --- a/packages/yarnpkg-doctor/README.md +++ b/packages/yarnpkg-doctor/README.md @@ -97,7 +97,7 @@ This rule is a temporary measure to address this [issue](https://github.com/webp This rule warns when the `bundleDependencies` (or `bundledDependencies`) field is used. -Visit [the dedicated section](https://yarnpkg.com/getting-started/migration#dont-use-bundledependencies) on the website to learn more. +Visit [the dedicated section](https://yarnpkg.com/migration/guide#dont-use-bundledependencies) on the website to learn more. ## Further reading diff --git a/yarn.lock b/yarn.lock index 84d38f8a579f..de8d7d4e2429 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5121,6 +5121,7 @@ __metadata: "@monaco-editor/react": "npm:^4.4.6" "@primer/octicons-react": "npm:^17.7.0" "@tsconfig/docusaurus": "npm:^2.0.0" + "@types/cross-spawn": "npm:6.0.0" "@types/dompurify": "npm:^3" "@types/git-url-parse": "npm:^9.0.0" "@types/lodash": "npm:^4.14.136" @@ -5136,6 +5137,7 @@ __metadata: "@types/semver": "npm:^7.1.0" "@types/three": "npm:^0.144.0" "@yarnpkg/cli": "workspace:^" + "@yarnpkg/core": "workspace:^" "@yarnpkg/fslib": "workspace:^" "@yarnpkg/libzip": "workspace:^" "@yarnpkg/monorepo": "workspace:^" @@ -5145,6 +5147,7 @@ __metadata: ansi-to-html: "npm:^0.7.2" clipanion: "npm:^4.0.0-rc.2" clsx: "npm:^1.2.1" + cross-spawn: "npm:7.0.3" dompurify: "npm:^3.0.5" esbuild-loader: "npm:^2.20.0" git-url-parse: "npm:^13.1.0" @@ -5298,20 +5301,6 @@ __metadata: built: false fsevents: built: false - gatsby: - built: false - gatsby-cli: - built: false - gatsby-plugin-mdx@2.14.0: - unplugged: true - gatsby-telemetry: - built: false - react-json-doc@2.1.0: - unplugged: true - react-json-doc@2.3.2: - unplugged: true - svg2png: - unplugged: true languageName: unknown linkType: soft