From 8d66a2bdb4c296406dfde54f5ff323176d773226 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Fri, 5 Jul 2024 09:39:53 +0200 Subject: [PATCH 1/4] update test workflow --- .github/workflows/integration-testing.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration-testing.yml b/.github/workflows/integration-testing.yml index bebb5bf..6b348fa 100644 --- a/.github/workflows/integration-testing.yml +++ b/.github/workflows/integration-testing.yml @@ -9,20 +9,27 @@ jobs: matrix: pm: - name: npm + displayName: npm version: 10.8.1 - name: pnpm + displayName: pnpm version: 9.4.0 - name: yarn + displayName: yarn (classic) version: 1.22.22 + - name: yarn + displayName: yarn (berry) + version: 4.3.1 - name: bun + displayName: bun version: 1.1.17 - name: ${{ matrix.pm.name }} + name: ${{ matrix.pm.displayName }} steps: - name: Checkout uses: actions/checkout@v4 - name: Install dependencies uses: ./.github/actions/pnpm-install - - name: Install Bun + - name: Install Bun (optional) uses: oven-sh/setup-bun@v2 if: ${{ matrix.pm.name == 'bun' }} - uses: actions/download-artifact@v4 From cf55dd21fe7c130097c3203032b599eb3b6eff30 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Fri, 5 Jul 2024 09:51:16 +0200 Subject: [PATCH 2/4] add config update --- src/verdaccio/install-packages.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/verdaccio/install-packages.ts b/src/verdaccio/install-packages.ts index d53444b..f12cd3a 100644 --- a/src/verdaccio/install-packages.ts +++ b/src/verdaccio/install-packages.ts @@ -1,4 +1,5 @@ import process from 'node:process' +import { execa } from 'execa' import { detectPackageManager } from 'nypm' import { logger } from '../utils/logger' import type { PromisifiedSpawnArgs } from '../utils/promisified-spawn' @@ -31,13 +32,13 @@ If you have control over the destination, manually add the "packageManager" key let externalRegistry = false let env: NodeJS.ProcessEnv = {} - // The combination of name and majorVersion allows us to detect yarn 3 - if (name === 'yarn' && majorVersion === '3') + // Yarn Berry + if (name === 'yarn' && (majorVersion === '3' || majorVersion === '4')) { externalRegistry = true - // TODO(feature): Handle externalRegistry case by detecting yarn 2/3 and modify yarn config - // We need to set programatically: - // yarn config set npmRegistryServer http://localhost:4873 - // unsafeHttpWhitelist:\n - "localhost" + + await execa`yarn config set npmRegistryServer ${REGISTRY_URL}` + await execa`yarn config set unsafeHttpWhitelist --json '["localhost"]'` + } if (name === 'bun') { externalRegistry = true From d0b45b99f77dc4212247a17a79520977133dceb7 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Fri, 5 Jul 2024 10:15:37 +0200 Subject: [PATCH 3/4] fix command --- src/verdaccio/install-packages.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/verdaccio/install-packages.ts b/src/verdaccio/install-packages.ts index f12cd3a..2b523a0 100644 --- a/src/verdaccio/install-packages.ts +++ b/src/verdaccio/install-packages.ts @@ -37,7 +37,7 @@ If you have control over the destination, manually add the "packageManager" key externalRegistry = true await execa`yarn config set npmRegistryServer ${REGISTRY_URL}` - await execa`yarn config set unsafeHttpWhitelist --json '["localhost"]'` + await execa`yarn config set unsafeHttpWhitelist --json ["localhost"]` } if (name === 'bun') { From b90e23cba85d3fc48bfafdce0007e1bff0794c29 Mon Sep 17 00:00:00 2001 From: LekoArts Date: Fri, 5 Jul 2024 10:19:17 +0200 Subject: [PATCH 4/4] add changeset --- .changeset/cool-actors-visit.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/cool-actors-visit.md diff --git a/.changeset/cool-actors-visit.md b/.changeset/cool-actors-visit.md new file mode 100644 index 0000000..4faea9f --- /dev/null +++ b/.changeset/cool-actors-visit.md @@ -0,0 +1,5 @@ +--- +"secco": minor +--- + +Support Yarn Berry (currently v3 & v4) by modyfing the .yarnrc.yml file inside the destination before trying to install packages from the local Verdaccio registry