Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support for yarn berry #99

Merged
merged 4 commits into from
Jul 5, 2024
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
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
Loading