Skip to content

Commit

Permalink
fix(core): use the current CLI to prepare external Yarn classic projects
Browse files Browse the repository at this point in the history
  • Loading branch information
merceyz committed Jul 27, 2022
1 parent 4a097fa commit e19690a
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 1 deletion.
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,29 @@ 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`),
});
},
),
);
});
});
2 changes: 1 addition & 1 deletion packages/yarnpkg-core/sources/scriptUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export async function prepareExternalProject(cwd: PortablePath, outputPath: Port
: [];

// 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`], {cwd, env, stdin, stdout, stderr, end: execUtils.EndStrategy.ErrorCode});
if (version.code !== 0)
return version.code;

Expand Down

0 comments on commit e19690a

Please sign in to comment.