Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .yarn/versions/8fe58483.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
releases:
"@yarnpkg/cli": patch
"@yarnpkg/core": patch

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"
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ The following changes only affect people writing Yarn plugins:
### Bugfixes

- `yarn dlx` will no longer report false-positive `UNUSED_PACKAGE_EXTENSION` warnings
- When Corepack is enabled Yarn will now use the current CLI to prepare external Yarn classic projects, matching the behaviour of when Corepack is disabled.

## 3.2.2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const {
} = require(`pkg-tests-core`);
const {parseSyml} = require(`@yarnpkg/parsers`);
const {execUtils, semverUtils} = require(`@yarnpkg/core`);
const {npath} = require(`@yarnpkg/fslib`);

const TESTED_URLS = {
// We've picked util-deprecate because it doesn't have any dependency, and
Expand Down Expand Up @@ -221,5 +222,45 @@ describe(`Protocols`, () => {
},
),
);

test(
`it should not use Corepack to fetch Yarn Classic`,
makeTemporaryEnv(
{
dependencies: {
[`yarn-1-project`]: startPackageServer().then(url => `${url}/repositories/yarn-1-project.git`),
},
},
async ({path, run, source}) => {
// This checks that the `set version classic` part of `scriptUtils.prepareExternalProject` doesn't use Corepack.
// The rest of the install will fail though.
await expect(run(`install`, {
env: {
COREPACK_ROOT: npath.join(npath.fromPortablePath(path), `404`),
YARN_ENABLE_INLINE_BUILDS: `true`,
},
})).rejects.toMatchObject({
code: 1,
stdout: expect.stringContaining(`Saving the new release`),
});
},
),
);

test(
`it should not add a 'packageManager' field to a Yarn classic project`,
makeTemporaryEnv(
{
dependencies: {
[`yarn-1-project`]: startPackageServer().then(url => `${url}/repositories/yarn-1-project.git`),
},
},
async ({path, run, source}) => {
await expect(run(`install`)).resolves.toBeTruthy();

await expect(source(`require('yarn-1-project/package.json').packageManager`)).resolves.toBeUndefined();
},
),
);
});
});
11 changes: 10 additions & 1 deletion packages/yarnpkg-core/sources/scriptUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,20 @@ export async function prepareExternalProject(cwd: PortablePath, outputPath: Port
? [`workspace`, workspace]
: [];

// `set version` will update the Manifest to contain a `packageManager` field with the latest
// Yarn version which causes the results to change depending on when this command was run,
// therefore we revert any change made to it.
const manifestPath = ppath.join(cwd, Filename.manifest);
const manifestBuffer = await xfs.readFilePromise(manifestPath);

// Makes sure that we'll be using Yarn 1.x
const version = await execUtils.pipevp(`yarn`, [`set`, `version`, `classic`, `--only-if-needed`], {cwd, env, stdin, stdout, stderr, end: execUtils.EndStrategy.ErrorCode});
const version = await execUtils.pipevp(process.execPath, [process.argv[1], `set`, `version`, `classic`, `--only-if-needed`, `--yarn-path`], {cwd, env, stdin, stdout, stderr, end: execUtils.EndStrategy.ErrorCode});
if (version.code !== 0)
return version.code;

// Revert any changes made to the Manifest by `set version`.
await xfs.writeFilePromise(manifestPath, manifestBuffer);

// Otherwise Yarn 1 will pack the .yarn directory :(
await xfs.appendFilePromise(ppath.join(cwd, `.npmignore` as PortablePath), `/.yarn\n`);

Expand Down