From a41e4250e3a39550f37052e04df21341d2c06ae3 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Wed, 31 Jan 2024 00:48:36 +0100 Subject: [PATCH] `COREPACK_ENABLE_UNSAFE_CUSTOM_URLS` --- README.md | 2 +- sources/Engine.ts | 4 ++-- sources/specUtils.ts | 4 ++-- tests/main.test.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b9acce29a..72d45b5d6 100644 --- a/README.md +++ b/README.md @@ -243,7 +243,7 @@ same major line. Should you need to upgrade to a new major, use an explicit When standard input is a TTY and no CI environment is detected, Corepack will ask for user input before starting the download. -- `COREPACK_ENABLE_URL_VERSION_FOR_KNOWN_PM` can be set to `1` to allow use of +- `COREPACK_ENABLE_UNSAFE_CUSTOM_URLS` can be set to `1` to allow use of custom URLs to load a package manager known by Corepack (`yarn`, `npm`, and `pnpm`). diff --git a/sources/Engine.ts b/sources/Engine.ts index b36db8fa1..41b05e980 100644 --- a/sources/Engine.ts +++ b/sources/Engine.ts @@ -207,8 +207,8 @@ export class Engine { async resolveDescriptor(descriptor: Descriptor, {allowTags = false, useCache = true}: {allowTags?: boolean, useCache?: boolean} = {}) { if (!corepackUtils.isNotURLDescriptor(descriptor)) { - if (process.env.COREPACK_ENABLE_URL_VERSION_FOR_KNOWN_PM !== `1` && isSupportedPackageManager(descriptor.name)) - throw new UsageError(`Illegal use of URL for known package manager. Instead, select a specific version, or set COREPACK_ENABLE_URL_VERSION_FOR_KNOWN_PM=1 in your environment (${descriptor.name}@${descriptor.range})`); + if (process.env.COREPACK_ENABLE_UNSAFE_CUSTOM_URLS !== `1` && isSupportedPackageManager(descriptor.name)) + throw new UsageError(`Illegal use of URL for known package manager. Instead, select a specific version, or set COREPACK_ENABLE_UNSAFE_CUSTOM_URLS=1 in your environment (${descriptor.name}@${descriptor.range})`); return { name: descriptor.name, diff --git a/sources/specUtils.ts b/sources/specUtils.ts index a1ee17756..9d366675a 100644 --- a/sources/specUtils.ts +++ b/sources/specUtils.ts @@ -38,8 +38,8 @@ export function parseSpec(raw: unknown, source: string, {enforceExactVersion = t if (!isSupportedPackageManager(name)) { throw new UsageError(`Unsupported package manager specification (${raw})`); } - } else if (isSupportedPackageManager(name) && process.env.COREPACK_ENABLE_URL_VERSION_FOR_KNOWN_PM !== `1`) { - throw new UsageError(`Illegal use of URL for known package manager. Instead, select a specific version, or set COREPACK_ENABLE_URL_VERSION_FOR_KNOWN_PM=1 in your environment (${raw})`); + } else if (isSupportedPackageManager(name) && process.env.COREPACK_ENABLE_UNSAFE_CUSTOM_URLS !== `1`) { + throw new UsageError(`Illegal use of URL for known package manager. Instead, select a specific version, or set COREPACK_ENABLE_UNSAFE_CUSTOM_URLS=1 in your environment (${raw})`); } diff --git a/tests/main.test.ts b/tests/main.test.ts index ceff8b923..aa76636c8 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -140,7 +140,7 @@ const testedPackageManagers: Array<[string, string] | [string, string, string]> for (const [name, version, expectedVersion = version.split(`+`, 1)[0]] of testedPackageManagers) { it(`should use the right package manager version for a given project (${name}@${version})`, async () => { await xfs.mktempPromise(async cwd => { - const env = {...process.env, COREPACK_ENABLE_URL_VERSION_FOR_KNOWN_PM: `1`}; + const env = {...process.env, COREPACK_ENABLE_UNSAFE_CUSTOM_URLS: `1`}; await expect(runCli(cwd, [`${name}@${version}`, `--version`], {env})).resolves.toMatchObject({ exitCode: 0, stderr: ``,