diff --git a/.yarn/versions/3a69f2b3.yml b/.yarn/versions/3a69f2b3.yml new file mode 100644 index 000000000000..20a0069f4eaf --- /dev/null +++ b/.yarn/versions/3a69f2b3.yml @@ -0,0 +1,34 @@ +releases: + "@yarnpkg/cli": major + "@yarnpkg/core": major + +declined: + - "@yarnpkg/plugin-compat" + - "@yarnpkg/plugin-constraints" + - "@yarnpkg/plugin-dlx" + - "@yarnpkg/plugin-essentials" + - "@yarnpkg/plugin-exec" + - "@yarnpkg/plugin-file" + - "@yarnpkg/plugin-git" + - "@yarnpkg/plugin-github" + - "@yarnpkg/plugin-http" + - "@yarnpkg/plugin-init" + - "@yarnpkg/plugin-interactive-tools" + - "@yarnpkg/plugin-link" + - "@yarnpkg/plugin-nm" + - "@yarnpkg/plugin-npm" + - "@yarnpkg/plugin-npm-cli" + - "@yarnpkg/plugin-pack" + - "@yarnpkg/plugin-patch" + - "@yarnpkg/plugin-pnp" + - "@yarnpkg/plugin-pnpm" + - "@yarnpkg/plugin-stage" + - "@yarnpkg/plugin-typescript" + - "@yarnpkg/plugin-version" + - "@yarnpkg/plugin-workspace-tools" + - "@yarnpkg/builder" + - "@yarnpkg/doctor" + - "@yarnpkg/extensions" + - "@yarnpkg/nm" + - "@yarnpkg/pnpify" + - "@yarnpkg/sdks" diff --git a/constraints.pro b/constraints.pro index 8c1be64d0927..5c52d2c777b5 100644 --- a/constraints.pro +++ b/constraints.pro @@ -2,4 +2,4 @@ % % Check this other file in this same repository to see the new way to write constraints, using JS/TS: % -% yarn.config.js +% yarn.config.cjs diff --git a/packages/acceptance-tests/pkg-tests-specs/sources/commands/__snapshots__/constraints.test.ts.snap b/packages/acceptance-tests/pkg-tests-specs/sources/commands/__snapshots__/constraints.test.ts.snap index 6660dc376e81..12a8fa724420 100644 --- a/packages/acceptance-tests/pkg-tests-specs/sources/commands/__snapshots__/constraints.test.ts.snap +++ b/packages/acceptance-tests/pkg-tests-specs/sources/commands/__snapshots__/constraints.test.ts.snap @@ -22,8 +22,8 @@ exports[`Commands constraints test (empty project / gen_enforced_dependency (amb "stderr": "", "stdout": "└─ root-workspace-0b6124@workspace:. └─ Conflict detected in constraint targeting dependencies["no-deps"]; conflicting values are: - ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:3:46) - └─ '2.0.0' at exports.constraints (/path/to/yarn.config.js:4:46) + ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:3:46) + └─ '2.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:46) ", } `; @@ -126,8 +126,8 @@ exports[`Commands constraints test (empty project / gen_enforced_field (ambiguou "stderr": "", "stdout": "└─ root-workspace-0b6124@workspace:. └─ Conflict detected in constraint targeting dependencies["a-new-dep"]; conflicting values are: - ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:3:46) - └─ '2.0.0' at exports.constraints (/path/to/yarn.config.js:4:46) + ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:3:46) + └─ '2.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:46) ", } `; @@ -278,18 +278,18 @@ exports[`Commands constraints test (multiple workspaces / gen_enforced_dependenc "stderr": "", "stdout": "├─ root-workspace-0b6124@workspace:. │ └─ Conflict detected in constraint targeting dependencies["no-deps"]; conflicting values are: -│ ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:3:46) -│ └─ '2.0.0' at exports.constraints (/path/to/yarn.config.js:4:46) +│ ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:3:46) +│ └─ '2.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:46) │ ├─ workspace-a@workspace:packages/workspace-a │ └─ Conflict detected in constraint targeting dependencies["no-deps"]; conflicting values are: -│ ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:3:46) -│ └─ '2.0.0' at exports.constraints (/path/to/yarn.config.js:4:46) +│ ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:3:46) +│ └─ '2.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:46) │ └─ workspace-b@workspace:packages/workspace-b └─ Conflict detected in constraint targeting dependencies["no-deps"]; conflicting values are: - ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:3:46) - └─ '2.0.0' at exports.constraints (/path/to/yarn.config.js:4:46) + ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:3:46) + └─ '2.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:46) ", } `; @@ -354,19 +354,19 @@ exports[`Commands constraints test (multiple workspaces / gen_enforced_dependenc "stderr": "", "stdout": "├─ workspace-a@workspace:packages/workspace-a │ ├─ Conflict detected in constraint targeting dependencies["no-deps"]; conflicting values are: -│ │ ├─ undefined at exports.constraints (/path/to/yarn.config.js:3:72) -│ │ └─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:4:82) +│ │ ├─ undefined at exports.constraints (/path/to/yarn.config.cjs:3:72) +│ │ └─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:82) │ └─ Conflict detected in constraint targeting devDependencies["no-deps"]; conflicting values are: -│ ├─ undefined at exports.constraints (/path/to/yarn.config.js:3:72) -│ └─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:4:82) +│ ├─ undefined at exports.constraints (/path/to/yarn.config.cjs:3:72) +│ └─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:82) │ └─ workspace-b@workspace:packages/workspace-b ├─ Conflict detected in constraint targeting dependencies["no-deps"]; conflicting values are: - │ ├─ undefined at exports.constraints (/path/to/yarn.config.js:3:72) - │ └─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:4:82) + │ ├─ undefined at exports.constraints (/path/to/yarn.config.cjs:3:72) + │ └─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:82) └─ Conflict detected in constraint targeting devDependencies["no-deps"]; conflicting values are: - ├─ undefined at exports.constraints (/path/to/yarn.config.js:3:72) - └─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:4:82) + ├─ undefined at exports.constraints (/path/to/yarn.config.cjs:3:72) + └─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:82) ", } `; @@ -472,18 +472,18 @@ exports[`Commands constraints test (multiple workspaces / gen_enforced_field (am "stderr": "", "stdout": "├─ root-workspace-0b6124@workspace:. │ └─ Conflict detected in constraint targeting dependencies["a-new-dep"]; conflicting values are: -│ ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:3:46) -│ └─ '2.0.0' at exports.constraints (/path/to/yarn.config.js:4:46) +│ ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:3:46) +│ └─ '2.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:46) │ ├─ workspace-a@workspace:packages/workspace-a │ └─ Conflict detected in constraint targeting dependencies["a-new-dep"]; conflicting values are: -│ ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:3:46) -│ └─ '2.0.0' at exports.constraints (/path/to/yarn.config.js:4:46) +│ ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:3:46) +│ └─ '2.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:46) │ └─ workspace-b@workspace:packages/workspace-b └─ Conflict detected in constraint targeting dependencies["a-new-dep"]; conflicting values are: - ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:3:46) - └─ '2.0.0' at exports.constraints (/path/to/yarn.config.js:4:46) + ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:3:46) + └─ '2.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:46) ", } `; @@ -696,8 +696,8 @@ exports[`Commands constraints test (one regular dependency / gen_enforced_depend "stderr": "", "stdout": "└─ root-workspace-0b6124@workspace:. └─ Conflict detected in constraint targeting dependencies["no-deps"]; conflicting values are: - ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:3:46) - └─ '2.0.0' at exports.constraints (/path/to/yarn.config.js:4:46) + ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:3:46) + └─ '2.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:46) ", } `; @@ -744,8 +744,8 @@ exports[`Commands constraints test (one regular dependency / gen_enforced_depend "stderr": "", "stdout": "└─ root-workspace-0b6124@workspace:. └─ Conflict detected in constraint targeting dependencies["no-deps"]; conflicting values are: - ├─ undefined at exports.constraints (/path/to/yarn.config.js:3:72) - └─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:4:82) + ├─ undefined at exports.constraints (/path/to/yarn.config.cjs:3:72) + └─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:82) ", } `; @@ -812,8 +812,8 @@ exports[`Commands constraints test (one regular dependency / gen_enforced_field "stderr": "", "stdout": "└─ root-workspace-0b6124@workspace:. └─ Conflict detected in constraint targeting dependencies["a-new-dep"]; conflicting values are: - ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:3:46) - └─ '2.0.0' at exports.constraints (/path/to/yarn.config.js:4:46) + ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:3:46) + └─ '2.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:46) ", } `; @@ -972,8 +972,8 @@ exports[`Commands constraints test (two development dependencies / gen_enforced_ "stderr": "", "stdout": "└─ root-workspace-0b6124@workspace:. └─ Conflict detected in constraint targeting dependencies["no-deps"]; conflicting values are: - ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:3:46) - └─ '2.0.0' at exports.constraints (/path/to/yarn.config.js:4:46) + ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:3:46) + └─ '2.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:46) ", } `; @@ -1016,8 +1016,8 @@ exports[`Commands constraints test (two development dependencies / gen_enforced_ "stderr": "", "stdout": "└─ root-workspace-0b6124@workspace:. └─ Conflict detected in constraint targeting devDependencies["no-deps"]; conflicting values are: - ├─ undefined at exports.constraints (/path/to/yarn.config.js:3:72) - └─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:4:82) + ├─ undefined at exports.constraints (/path/to/yarn.config.cjs:3:72) + └─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:82) ", } `; @@ -1084,8 +1084,8 @@ exports[`Commands constraints test (two development dependencies / gen_enforced_ "stderr": "", "stdout": "└─ root-workspace-0b6124@workspace:. └─ Conflict detected in constraint targeting dependencies["a-new-dep"]; conflicting values are: - ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:3:46) - └─ '2.0.0' at exports.constraints (/path/to/yarn.config.js:4:46) + ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:3:46) + └─ '2.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:46) ", } `; @@ -1236,8 +1236,8 @@ exports[`Commands constraints test (two regular dependencies / gen_enforced_depe "stderr": "", "stdout": "└─ root-workspace-0b6124@workspace:. └─ Conflict detected in constraint targeting dependencies["no-deps"]; conflicting values are: - ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:3:46) - └─ '2.0.0' at exports.constraints (/path/to/yarn.config.js:4:46) + ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:3:46) + └─ '2.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:46) ", } `; @@ -1284,8 +1284,8 @@ exports[`Commands constraints test (two regular dependencies / gen_enforced_depe "stderr": "", "stdout": "└─ root-workspace-0b6124@workspace:. └─ Conflict detected in constraint targeting dependencies["no-deps"]; conflicting values are: - ├─ undefined at exports.constraints (/path/to/yarn.config.js:3:72) - └─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:4:82) + ├─ undefined at exports.constraints (/path/to/yarn.config.cjs:3:72) + └─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:82) ", } `; @@ -1352,8 +1352,8 @@ exports[`Commands constraints test (two regular dependencies / gen_enforced_fiel "stderr": "", "stdout": "└─ root-workspace-0b6124@workspace:. └─ Conflict detected in constraint targeting dependencies["a-new-dep"]; conflicting values are: - ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:3:46) - └─ '2.0.0' at exports.constraints (/path/to/yarn.config.js:4:46) + ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:3:46) + └─ '2.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:46) ", } `; @@ -1512,8 +1512,8 @@ exports[`Commands constraints test (two regular dependencies, two development de "stderr": "", "stdout": "└─ root-workspace-0b6124@workspace:. └─ Conflict detected in constraint targeting dependencies["no-deps"]; conflicting values are: - ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:3:46) - └─ '2.0.0' at exports.constraints (/path/to/yarn.config.js:4:46) + ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:3:46) + └─ '2.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:46) ", } `; @@ -1561,11 +1561,11 @@ exports[`Commands constraints test (two regular dependencies, two development de "stderr": "", "stdout": "└─ root-workspace-0b6124@workspace:. ├─ Conflict detected in constraint targeting dependencies["no-deps"]; conflicting values are: - │ ├─ undefined at exports.constraints (/path/to/yarn.config.js:3:72) - │ └─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:4:82) + │ ├─ undefined at exports.constraints (/path/to/yarn.config.cjs:3:72) + │ └─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:82) └─ Conflict detected in constraint targeting devDependencies["no-deps"]; conflicting values are: - ├─ undefined at exports.constraints (/path/to/yarn.config.js:3:72) - └─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:4:82) + ├─ undefined at exports.constraints (/path/to/yarn.config.cjs:3:72) + └─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:82) ", } `; @@ -1632,8 +1632,8 @@ exports[`Commands constraints test (two regular dependencies, two development de "stderr": "", "stdout": "└─ root-workspace-0b6124@workspace:. └─ Conflict detected in constraint targeting dependencies["a-new-dep"]; conflicting values are: - ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:3:46) - └─ '2.0.0' at exports.constraints (/path/to/yarn.config.js:4:46) + ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:3:46) + └─ '2.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:46) ", } `; @@ -1792,8 +1792,8 @@ exports[`Commands constraints test (various field types / gen_enforced_dependenc "stderr": "", "stdout": "└─ foo@workspace:. └─ Conflict detected in constraint targeting dependencies["no-deps"]; conflicting values are: - ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:3:46) - └─ '2.0.0' at exports.constraints (/path/to/yarn.config.js:4:46) + ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:3:46) + └─ '2.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:46) ", } `; @@ -1896,8 +1896,8 @@ exports[`Commands constraints test (various field types / gen_enforced_field (am "stderr": "", "stdout": "└─ foo@workspace:. └─ Conflict detected in constraint targeting dependencies["a-new-dep"]; conflicting values are: - ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.js:3:46) - └─ '2.0.0' at exports.constraints (/path/to/yarn.config.js:4:46) + ├─ '1.0.0' at exports.constraints (/path/to/yarn.config.cjs:3:46) + └─ '2.0.0' at exports.constraints (/path/to/yarn.config.cjs:4:46) ", } `; diff --git a/packages/acceptance-tests/pkg-tests-specs/sources/commands/constraints.test.ts b/packages/acceptance-tests/pkg-tests-specs/sources/commands/constraints.test.ts index ec78114570b0..2d395fac0c4a 100644 --- a/packages/acceptance-tests/pkg-tests-specs/sources/commands/constraints.test.ts +++ b/packages/acceptance-tests/pkg-tests-specs/sources/commands/constraints.test.ts @@ -9,7 +9,7 @@ const { const scriptNames = { prolog: `constraints.pro`, - js: `yarn.config.js`, + js: `yarn.config.cjs`, }; const constraints = { @@ -98,7 +98,7 @@ describe(`Commands`, () => { it(`should report custom errors`, makeTemporaryEnv({}, async ({path, run, source}) => { await run(`install`); - await writeFile(ppath.join(path, `yarn.config.js`), ` + await writeFile(ppath.join(path, `yarn.config.cjs`), ` exports.constraints = ({Yarn}) => { Yarn.workspace().error('This should fail'); }; @@ -128,7 +128,7 @@ describe(`Commands`, () => { } // TODO: Use .replaceAll when we drop support for Node.js v14 - stdout = stdout.split(npath.join(npath.fromPortablePath(path), `yarn.config.js`)).join(`/path/to/yarn.config.js`); + stdout = stdout.split(npath.join(npath.fromPortablePath(path), `yarn.config.cjs`)).join(`/path/to/yarn.config.cjs`); stdout = stdout.replace(/(Module|Object)\.(exports\.)/g, `$2`); expect({code, stdout, stderr}).toMatchSnapshot(); diff --git a/packages/acceptance-tests/pkg-tests-specs/sources/features/constraintsChecks.test.ts b/packages/acceptance-tests/pkg-tests-specs/sources/features/constraintsChecks.test.ts index 033907791ade..92c7a55af204 100644 --- a/packages/acceptance-tests/pkg-tests-specs/sources/features/constraintsChecks.test.ts +++ b/packages/acceptance-tests/pkg-tests-specs/sources/features/constraintsChecks.test.ts @@ -7,7 +7,7 @@ describe(`Features`, () => { makeTemporaryEnv({}, { enableConstraintsChecks: true, }, async ({path, run}) => { - await xfs.writeFilePromise(ppath.join(path, `yarn.config.js`), [ + await xfs.writeFilePromise(ppath.join(path, `yarn.config.cjs`), [ `exports.constraints = ({ Yarn }) => {\n`, ` for (const workspace of Yarn.workspaces()) {\n`, ` workspace.set('foo', 'bar')\n`, diff --git a/packages/docusaurus/docs/features/constraints.md b/packages/docusaurus/docs/features/constraints.md index 414687f1b937..dbbcd0da4459 100644 --- a/packages/docusaurus/docs/features/constraints.md +++ b/packages/docusaurus/docs/features/constraints.md @@ -27,9 +27,9 @@ It currently doesn't support the following, but might in the future (PRs welcome ## Creating a constraint -Constraints are created by adding a `yarn.config.js` file at the root of your project (repository). This file should export an object with a `constraints` method. This method will be called by the constraints engine, and must define the rules to enforce on the project, using the provided API. +Constraints are created by adding a `yarn.config.cjs` file at the root of your project (repository). This file should export an object with a `constraints` method. This method will be called by the constraints engine, and must define the rules to enforce on the project, using the provided API. -For example, the following `yarn.config.js` will enforce that all `react` dependencies are set to `18.0.0`. +For example, the following `yarn.config.cjs` will enforce that all `react` dependencies are set to `18.0.0`. ```ts module.exports = { @@ -80,7 +80,7 @@ Yarn ships types that make it easier to write constraints. To use them, add the $ yarn add @yarnpkg/types ``` -Then, in your `yarn.config.js` file, import the types, in particular the `defineConfig` function which automatically type the configuration methods: +Then, in your `yarn.config.cjs` file, import the types, in particular the `defineConfig` function which automatically type the configuration methods: ```ts /** @type {import('@yarnpkg/types')} */ diff --git a/packages/docusaurus/static/configuration/yarnrc.json b/packages/docusaurus/static/configuration/yarnrc.json index 6a6e4e8934a5..1725745b1e5e 100644 --- a/packages/docusaurus/static/configuration/yarnrc.json +++ b/packages/docusaurus/static/configuration/yarnrc.json @@ -89,7 +89,7 @@ "constraintsPath": { "_package": "@yarnpkg/plugin-constraints", "title": "Path of the constraints file.", - "description": "This only matters for Prolog constraints, which are being deprecated. JavaScript constraints will always be read from the `yarn.config.js` file.", + "description": "This only matters for Prolog constraints, which are being deprecated. JavaScript constraints will always be read from the `yarn.config.cjs` file.", "type": "string", "format": "uri-reference", "default": "./constraints.pro" diff --git a/packages/yarnpkg-core/sources/Project.ts b/packages/yarnpkg-core/sources/Project.ts index 956d778e3a26..0cdcdf1869f2 100644 --- a/packages/yarnpkg-core/sources/Project.ts +++ b/packages/yarnpkg-core/sources/Project.ts @@ -711,7 +711,7 @@ export class Project { } async loadUserConfig() { - const configPath = ppath.join(this.cwd, `yarn.config.js`); + const configPath = ppath.join(this.cwd, `yarn.config.cjs`); if (!await xfs.existsPromise(configPath)) return null; diff --git a/yarn.config.js b/yarn.config.cjs similarity index 100% rename from yarn.config.js rename to yarn.config.cjs