Skip to content

Commit

Permalink
feat: Support for yarn berry (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
LekoArts authored Jul 5, 2024
1 parent 0b858c5 commit 1593131
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/cool-actors-visit.md
Original file line number Diff line number Diff line change
@@ -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
11 changes: 9 additions & 2 deletions .github/workflows/integration-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions src/verdaccio/install-packages.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1593131

Please sign in to comment.