Skip to content

Commit 08a45a4

Browse files
authored
feat(all): migrate to yarn berry (#73)
* chore: migrate from pnpm to yarn berry - Update packageManager to yarn@4.9.1 in all package.json files - Add workspaces field to root package.json (replaces pnpm-workspace.yaml) - Rename root package to @kubit-ui-web/monorepo to avoid workspace name conflict - Set root package as private: true - Replace all pnpm script references with yarn equivalents - Create .yarnrc.yml with nodeLinker: node-modules - Update .gitignore for Yarn Berry artifacts - Migrate all 5 GitHub workflows to use Corepack + Yarn caching - Update README.md and CONTRIBUTING.md documentation - Remove pnpm-lock.yaml and pnpm-workspace.yaml - Add yarn.lock * chore: optimize yarn berry monorepo configuration - Fix vercel.json: still had pnpm commands (build, dev, install) - Replace npx with yarn exec in design-system scripts (bv-build, bernova) - Add enableTelemetry: false to .yarnrc.yml - Add dependenciesMeta to root package.json (migrates pnpm-workspace.yaml ignoredBuiltDependencies for bernova and unrs-resolver) * feat(monorepo): add yarn berry constraints, focus, and foreach support - Create yarn.config.cjs with 5 workspace consistency rules: 1. Shared deps must use same version range across workspaces 2. All sub-workspaces must declare packageManager and engines.node 3. Public packages must have publishConfig 4. Workspace cross-references must use workspace:* protocol 5. No package should depend on itself - Auto-fix 4 version drifts caught by constraints: - @rslib/core: ^0.19.6 → ^0.20.0 (design-system) - @types/node: ^25.3.3 → ^25.5.0 (design-system, storybook) - html-validate: ^10.11.0 → ^10.11.1 (storybook) - Add constraints check to both PR validation workflows + reports - Add convenience scripts: constraints, constraints:fix, focus:*, foreach:clean, info:workspaces - Update README.md Scripts Reference with new commands - Update CONTRIBUTING.md with Constraints and Focused Development docs * fix(design-system): break cyclic dependency with react-components Remove optional peerDependency on @kubit-ui-web/react-components from design-system. Yarn Berry resolves workspace:* peerDeps as hard links in node_modules, creating a bidirectional cycle that Turbo 2.x rejects: components → design-system (devDependency) design-system → components (peerDependency, optional) The peerDep was already optional: true, so design-system functions without it. Consumers install both packages per README instructions. * fix(tsconfig): add root node_modules/@types to typeRoots for Yarn Berry hoisting Yarn Berry hoists all dependencies to the root node_modules/. The typeRoots in sub-package tsconfigs only referenced their own node_modules/@types which is empty after hoisting, causing TS2688: Cannot find type definition file for 'node'. Add ../../node_modules/@types to typeRoots in both components and design-system tsconfigs. * fix: resolve TS2688 and recursive turbo invocations under Yarn Berry - Add ../../node_modules to typeRoots in components and design-system tsconfigs. Scoped type packages like @testing-library/jest-dom are not under @types/ so they need the full root node_modules path, not just ../../node_modules/@types. - Remove //#build root task from turbo.json. With Yarn Berry the root package IS a workspace, so Turbo tried to execute the root build script (which calls turbo run build) as a pipeline task, creating infinite recursion. Without //#build, Turbo only runs build in workspace packages and the root script acts as a convenience wrapper. * chore: switch .yarnrc.yml to public npm registry Open source repo should use the public registry (registry.npmjs.org) in the committed config. Developers with JFrog access can override locally via skip-worktree. * fix(vercel): pin Node range and enable Corepack for Yarn Berry - engines.node: '>=22.0.0' → '>=22.0.0 <25.0.0' to prevent Vercel from auto-upgrading to Node 24.x - installCommand: prepend 'corepack enable' so Vercel activates Yarn Berry (4.9.1) from packageManager field instead of falling back to Yarn Classic 1.22.19 * fix(vercel): pin Node range and enable Corepack for Yarn Berry - engines.node: '>=22.0.0' → '>=22.0.0 <25.0.0' to prevent Vercel from auto-upgrading to Node 24.x - installCommand: prepend 'corepack enable' so Vercel activates Yarn Berry (4.9.1) from packageManager field instead of falling back to Yarn Classic 1.22.19
1 parent e74d6c7 commit 08a45a4

21 files changed

Lines changed: 13424 additions & 13246 deletions

.github/workflows/pr-validation-changesets.yml

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,22 @@ jobs:
3737
with:
3838
node-version: '22'
3939

40-
- name: Setup pnpm
41-
uses: pnpm/action-setup@v4
40+
- name: Enable Corepack
41+
run: corepack enable
4242

43-
- name: Get pnpm store directory
43+
- name: Get Yarn cache directory
44+
id: yarn-cache
4445
shell: bash
4546
run: |
46-
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
47+
echo "CACHE_DIR=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
4748
48-
- name: Setup pnpm cache
49+
- name: Setup Yarn cache
4950
uses: actions/cache@v4
5051
with:
51-
path: ${{ env.STORE_PATH }}
52-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
52+
path: ${{ steps.yarn-cache.outputs.CACHE_DIR }}
53+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
5354
restore-keys: |
54-
${{ runner.os }}-pnpm-store-
55+
${{ runner.os }}-yarn-
5556
5657
- name: Setup Turbo cache
5758
uses: actions/cache@v4
@@ -64,8 +65,22 @@ jobs:
6465
- name: Install dependencies
6566
run: |
6667
echo "Installing monorepo dependencies..."
67-
pnpm --version
68-
pnpm install --frozen-lockfile
68+
yarn --version
69+
yarn install --immutable
70+
71+
- name: Check workspace constraints
72+
id: constraints-check
73+
continue-on-error: true
74+
run: |
75+
echo "🔍 Checking workspace constraints..."
76+
if yarn constraints; then
77+
echo "✅ All workspace constraints pass"
78+
echo "constraints_valid=true" >> $GITHUB_OUTPUT
79+
else
80+
echo "⚠️ Workspace constraint violations detected"
81+
echo "constraints_valid=false" >> $GITHUB_OUTPUT
82+
echo "Run 'yarn constraints --fix' locally to auto-fix"
83+
fi
6984
7085
- name: Validate Branch Naming
7186
id: branch-validation
@@ -228,7 +243,7 @@ jobs:
228243
continue-on-error: true
229244
run: |
230245
echo "🔍 Running TypeScript check for components..."
231-
pnpm typecheck:components
246+
yarn typecheck:components
232247
echo "typecheck_components=true" >> $GITHUB_OUTPUT
233248
234249
- name: TypeScript Check (Design System)
@@ -237,7 +252,7 @@ jobs:
237252
continue-on-error: true
238253
run: |
239254
echo "🔍 Running TypeScript check for design-system..."
240-
pnpm typecheck:design-system
255+
yarn typecheck:design-system
241256
echo "typecheck_design_system=true" >> $GITHUB_OUTPUT
242257
243258
- name: Run Tests (Components)
@@ -246,7 +261,7 @@ jobs:
246261
continue-on-error: true
247262
run: |
248263
echo "🧪 Running tests for components..."
249-
pnpm test
264+
yarn test
250265
echo "test_components=true" >> $GITHUB_OUTPUT
251266
252267
- name: Lint Check (Components)
@@ -255,7 +270,7 @@ jobs:
255270
continue-on-error: true
256271
run: |
257272
echo "🔍 Running lint for components..."
258-
pnpm lint:components
273+
yarn lint:components
259274
echo "lint_components=true" >> $GITHUB_OUTPUT
260275
261276
- name: Lint Check (Design System)
@@ -264,7 +279,7 @@ jobs:
264279
continue-on-error: true
265280
run: |
266281
echo "🔍 Running lint for design-system..."
267-
pnpm lint:design-system
282+
yarn lint:design-system
268283
echo "lint_design_system=true" >> $GITHUB_OUTPUT
269284
270285
- name: Check for console.log
@@ -308,6 +323,7 @@ jobs:
308323
with:
309324
github-token: ${{ secrets.GITHUB_TOKEN }}
310325
script: |
326+
const constraintsValid = '${{ steps.constraints-check.outputs.constraints_valid }}' === 'true';
311327
const branchValid = '${{ steps.branch-validation.outputs.branch_valid }}' === 'true';
312328
const titleValid = '${{ steps.pr-title-validation.outputs.title_valid }}' === 'true';
313329
const scopeValid = '${{ steps.pr-title-validation.outputs.scope_valid }}' === 'true';
@@ -325,7 +341,7 @@ jobs:
325341
const bumpType = '${{ steps.version-detection.outputs.bump_type }}';
326342
const scope = '${{ steps.pr-title-validation.outputs.scope }}';
327343
328-
const allPassed = branchValid && titleValid && scopeValid &&
344+
const allPassed = constraintsValid && branchValid && titleValid && scopeValid &&
329345
(!componentsAffected || (typecheckComponents && testComponents && lintComponents)) &&
330346
(!designSystemAffected || (typecheckDesignSystem && lintDesignSystem)) &&
331347
consoleCheck && todoCheck;
@@ -350,6 +366,7 @@ jobs:
350366
comment += '\n### ✅ Validation Results\n\n';
351367
comment += '| Check | Status | Description |\n';
352368
comment += '|-------|--------|-------------|\n';
369+
comment += `| Constraints | ${constraintsValid ? '✅ Pass' : '❌ Fail'} | Workspace dependency consistency |\n`;
353370
comment += `| Branch Naming | ${branchValid ? '✅ Pass' : '❌ Fail'} | Must follow \`type/description\` |\n`;
354371
comment += `| PR Title | ${titleValid ? '✅ Pass' : '❌ Fail'} | Must follow conventional commits |\n`;
355372
comment += `| Scope | ${scopeValid ? '✅ Pass' : '⚠️ Warning'} | Should specify package scope |\n`;

.github/workflows/pr-validation.yml

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: PR Validation & Quality Checks (Monorepo)
22

33
# This workflow validates PRs against project standards and coding guidelines
44
# It runs on every PR to ensure code quality, documentation, and best practices
5-
# Adapted for pnpm workspace monorepo structure
5+
# Adapted for yarn workspace monorepo structure
66

77
on:
88
pull_request:
@@ -34,21 +34,22 @@ jobs:
3434
node-version: '22'
3535
registry-url: 'https://registry.npmjs.org'
3636

37-
- name: Setup pnpm
38-
uses: pnpm/action-setup@v4
37+
- name: Enable Corepack
38+
run: corepack enable
3939

40-
- name: Get pnpm store directory
40+
- name: Get Yarn cache directory
41+
id: yarn-cache
4142
shell: bash
4243
run: |
43-
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
44+
echo "CACHE_DIR=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
4445
45-
- name: Setup pnpm cache
46+
- name: Setup Yarn cache
4647
uses: actions/cache@v4
4748
with:
48-
path: ${{ env.STORE_PATH }}
49-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
49+
path: ${{ steps.yarn-cache.outputs.CACHE_DIR }}
50+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
5051
restore-keys: |
51-
${{ runner.os }}-pnpm-store-
52+
${{ runner.os }}-yarn-
5253
5354
- name: Setup Turbo cache
5455
uses: actions/cache@v4
@@ -61,8 +62,22 @@ jobs:
6162
- name: Install dependencies (Monorepo)
6263
run: |
6364
echo "Installing monorepo dependencies..."
64-
pnpm --version
65-
pnpm install --frozen-lockfile
65+
yarn --version
66+
yarn install --immutable
67+
68+
- name: Check workspace constraints
69+
id: constraints-check
70+
continue-on-error: true
71+
run: |
72+
echo "🔍 Checking workspace constraints..."
73+
if yarn constraints; then
74+
echo "✅ All workspace constraints pass"
75+
echo "constraints_valid=true" >> $GITHUB_OUTPUT
76+
else
77+
echo "⚠️ Workspace constraint violations detected"
78+
echo "constraints_valid=false" >> $GITHUB_OUTPUT
79+
echo "Run 'yarn constraints --fix' locally to auto-fix"
80+
fi
6681
6782
- name: Validate Branch Naming
6883
id: branch-validation
@@ -104,7 +119,7 @@ jobs:
104119
continue-on-error: true
105120
run: |
106121
echo "Running lint on all packages with Turbo..."
107-
if pnpm lint; then
122+
if yarn lint; then
108123
echo "✅ Lint passed"
109124
echo "lint_valid=true" >> $GITHUB_OUTPUT
110125
else
@@ -117,7 +132,7 @@ jobs:
117132
continue-on-error: true
118133
run: |
119134
echo "Running type check on all packages with Turbo..."
120-
if pnpm typecheck; then
135+
if yarn typecheck; then
121136
echo "✅ Type check passed"
122137
echo "typecheck_valid=true" >> $GITHUB_OUTPUT
123138
else
@@ -130,7 +145,7 @@ jobs:
130145
continue-on-error: true
131146
run: |
132147
echo "Running tests on components package with Turbo..."
133-
if pnpm test; then
148+
if yarn test; then
134149
echo "✅ Tests passed"
135150
echo "tests_valid=true" >> $GITHUB_OUTPUT
136151
else
@@ -143,7 +158,7 @@ jobs:
143158
continue-on-error: true
144159
run: |
145160
echo "Building all packages with Turbo..."
146-
if pnpm build; then
161+
if yarn build; then
147162
echo "✅ Build passed"
148163
echo "build_valid=true" >> $GITHUB_OUTPUT
149164
else
@@ -182,6 +197,7 @@ jobs:
182197
183198
| Check | Status | Description |
184199
|-------|--------|-------------|
200+
| **Constraints** | ${'${{ steps.constraints-check.outputs.constraints_valid }}' === 'true' ? '✅ Pass' : '❌ Fail'} | Workspace dependency consistency |
185201
| **Basic Validation** | ✅ Pass | PR structure validated |
186202
| **Branch Check** | ✅ Pass | Branch name accepted |
187203
| **Lint** | ✅ Pass | All packages linted |

.github/workflows/release-beta.yml

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,22 @@ jobs:
3737
node-version: '22'
3838
registry-url: 'https://registry.npmjs.org'
3939

40-
- name: Setup pnpm
41-
uses: pnpm/action-setup@v4
40+
- name: Enable Corepack
41+
run: corepack enable
4242

43-
- name: Get pnpm store directory
43+
- name: Get Yarn cache directory
44+
id: yarn-cache
4445
shell: bash
4546
run: |
46-
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
47+
echo "CACHE_DIR=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
4748
48-
- name: Setup pnpm cache
49+
- name: Setup Yarn cache
4950
uses: actions/cache@v4
5051
with:
51-
path: ${{ env.STORE_PATH }}
52-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
52+
path: ${{ steps.yarn-cache.outputs.CACHE_DIR }}
53+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
5354
restore-keys: |
54-
${{ runner.os }}-pnpm-store-
55+
${{ runner.os }}-yarn-
5556
5657
- name: Setup Turbo cache
5758
uses: actions/cache@v4
@@ -63,9 +64,9 @@ jobs:
6364
6465
- name: Install dependencies
6566
run: |
66-
echo "Installing dependencies with pnpm..."
67-
pnpm --version
68-
pnpm install --frozen-lockfile
67+
echo "Installing dependencies with yarn..."
68+
yarn --version
69+
yarn install --immutable
6970
env:
7071
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
7172

@@ -170,7 +171,7 @@ jobs:
170171
# Check if already in pre mode
171172
if [ -f ".changeset/pre.json" ]; then
172173
echo "⚠️ Already in prerelease mode, exiting first..."
173-
pnpm changeset pre exit
174+
yarn changeset pre exit
174175
175176
# Commit the exit
176177
git config --global user.name "github-actions[bot]"
@@ -182,12 +183,12 @@ jobs:
182183
fi
183184
184185
echo "📦 Entering beta prerelease mode..."
185-
pnpm changeset pre enter beta
186+
yarn changeset pre enter beta
186187
187188
- name: Version packages
188189
run: |
189190
echo "📦 Versioning packages for beta..."
190-
pnpm changeset:version
191+
yarn changeset:version
191192
192193
# Configure git
193194
git config --global user.name "github-actions[bot]"
@@ -205,22 +206,22 @@ jobs:
205206
- name: Build packages
206207
run: |
207208
echo "🏗️ Building packages..."
208-
pnpm build
209+
yarn build
209210
env:
210211
NODE_ENV: production
211212

212213
- name: Publish beta to NPM
213214
run: |
214215
echo "🚀 Publishing beta to NPM..."
215-
pnpm changeset:publish
216+
yarn changeset:publish
216217
env:
217218
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
218219
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
219220

220221
- name: Exit prerelease mode
221222
run: |
222223
echo "📦 Exiting beta prerelease mode..."
223-
pnpm changeset pre exit
224+
yarn changeset pre exit
224225
225226
git add .
226227
if git diff --staged --quiet; then
@@ -289,7 +290,7 @@ jobs:
289290
: 'packages/design-system';
290291
const packageJson = JSON.parse(require('fs').readFileSync(`${pkgDir}/package.json`, 'utf8'));
291292
const version = packageJson.version;
292-
comment += `pnpm add ${pkg}@${version}\n`;
293+
comment += `yarn add ${pkg}@${version}\n`;
293294
}
294295
comment += '```';
295296

0 commit comments

Comments
 (0)