Skip to content

Commit ec8ead8

Browse files
committed
✨ Current rails project using yarn as package manager, please change to pnpm, also keep yarn.lock version as same as possible. You may need to search web first to see any relative standard migration process or guide.
1 parent bfe09b0 commit ec8ead8

File tree

21 files changed

+9076
-7930
lines changed

21 files changed

+9076
-7930
lines changed

.circleci/config.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ jobs:
1616
steps:
1717
- checkout # pull down our git code.
1818
- ruby/install-deps # use the ruby orb to install dependencies
19-
# use the node orb to install our packages
20-
# specifying that we use `yarn` and to cache dependencies with `yarn.lock`
21-
# learn more: https://circleci.com/docs/2.0/caching/
19+
# use the node orb to install our packages with pnpm and cache using pnpm-lock.yaml
2220
- node/install-packages:
23-
pkg-manager: yarn
24-
cache-key: "yarn.lock"
21+
pkg-manager: pnpm
22+
cache-key: "pnpm-lock.yaml"
2523

2624
test: # our next job, called "test"
2725
docker:
@@ -51,8 +49,8 @@ jobs:
5149
- browser-tools/install-chrome
5250
- ruby/install-deps
5351
- node/install-packages:
54-
pkg-manager: yarn
55-
cache-key: "yarn.lock"
52+
pkg-manager: pnpm
53+
cache-key: "pnpm-lock.yaml"
5654
- run:
5755
name: Check browser install
5856
command: |

.gitlab-ci.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ before_script:
88
- gem install bundler
99
- bundle config set path 'vendor' # Install dependencies into ./vendor/ruby
1010
- sed -i 's/mutex_m (0.2.0)/mutex_m (0.1.1)/g' Gemfile.lock
11+
- |
12+
if command -v corepack >/dev/null; then
13+
corepack enable pnpm
14+
corepack prepare pnpm@latest --activate
15+
else
16+
npm install -g pnpm@8
17+
fi
1118
1219
stages:
1320
- test
@@ -23,12 +30,12 @@ test:
2330
- vendor/ruby
2431
- key:
2532
files:
26-
- yarn.lock
33+
- pnpm-lock.yaml
2734
paths:
28-
- ".yarn-cache/"
35+
- ".pnpm-store/"
2936
script:
3037
- bundle install -j $(nproc)
31-
- yarn install --cache-folder .yarn-cache
38+
- pnpm install --frozen-lockfile --store-dir .pnpm-store
3239
- cp config/database.yml.sample config/database.yml
3340
- echo $RAILS_MASTER_KEY > config/master.key
3441
- bundle exec rails db:migrate RAILS_ENV=test

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Keep Rails domain logic inside `app/`, following conventional directories for controllers, models, policies, datatables, and views. Stimulus controllers and Webpacker packs live in `app/javascript`, while shared helpers and extensions belong in `lib/`. Configuration, environment credentials, and deployment hooks sit under `config/`, and migrations plus seeds live in `db/`. Test fixtures, unit specs, and system flows mirror the app layout within `test/`, with Capybara scenarios in `test/system/`.
55

66
## Build, Test, and Development Commands
7-
Run `bin/setup` after cloning or pulling to install Ruby gems, Yarn packages, and migrate the database. Start the Rails server via `bin/rails s`, and pair it with `bin/webpack-dev-server` or `foreman start -f Procfile.dev` for hot asset reloading. Sync front-end dependencies with `yarn install --check-files`. Execute the targeted test suite using `bin/rails test path/to/file_test.rb`, or run the full matrix through `bin/rails test:all`.
7+
Run `bin/setup` after cloning or pulling to install Ruby gems, PNPM packages, and migrate the database. Start the Rails server via `bin/rails s`, and pair it with `bin/webpack-dev-server` or `foreman start -f Procfile.dev` for hot asset reloading. Sync front-end dependencies with `pnpm install --frozen-lockfile`. Execute the targeted test suite using `bin/rails test path/to/file_test.rb`, or run the full matrix through `bin/rails test:all`.
88

99
## Coding Style & Naming Conventions
1010
Use Ruby two-space indentation and idiomatic Rails naming: `CamelCase` classes, snake_case files, and kebab-case Stimulus controllers in `app/javascript/controllers/`. Follow the cops configured in `.rubocop.yml`; run `bundle exec rubocop` before opening a pull request. JavaScript modules target ES2015 and are linted with the “recommended” ESLint profile defined in `.eslintrc.js`.

Capfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ install_plugin Capistrano::SCM::Git
3030
require 'capistrano/rbenv'
3131
# require 'capistrano/chruby'
3232
require 'capistrano/bundler'
33-
require 'capistrano/yarn'
3433
require 'capistrano/rails/assets'
3534
require 'capistrano/rails/migrations'
3635
# require "capistrano/passenger"

Dockerfile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@ RUN apt-get update -qq && \
2424
# Install curl and gpg
2525
RUN apt-get update && apt-get install -y curl gnupg
2626

27-
# Install Node.js and Yarn
27+
# Install Node.js and pnpm
2828
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - && \
2929
apt-get install -y nodejs gcc g++ make && \
30-
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /usr/share/keyrings/yarnkey.gpg >/dev/null && \
31-
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | tee /etc/apt/sources.list.d/yarn.list && \
32-
apt-get update && apt-get install -y yarn
30+
corepack enable && \
31+
corepack prepare [email protected] --activate
3332

3433
# Install application gems
3534
COPY Gemfile Gemfile.lock ./
@@ -38,8 +37,8 @@ RUN bundle install && \
3837
bundle exec bootsnap precompile --gemfile
3938

4039
# Install node modules
41-
COPY package.json yarn.lock ./
42-
RUN yarn install --frozen-lockfile
40+
COPY package.json pnpm-lock.yaml ./
41+
RUN pnpm install --frozen-lockfile
4342

4443
# Copy application code
4544
COPY . .

Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ group :development do
9696

9797
gem 'capistrano3-puma', '~> 6.0'
9898
gem 'capistrano-rails'
99-
gem 'capistrano-yarn'
10099
gem 'capistrano-rbenv'
101100
gem 'ed25519'
102101
gem 'bcrypt_pbkdf'

Gemfile.lock

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ GEM
155155
capistrano-rbenv (2.2.0)
156156
capistrano (~> 3.1)
157157
sshkit (~> 1.3)
158-
capistrano-yarn (2.0.2)
159-
capistrano (~> 3.0)
160158
capistrano3-puma (6.2.0)
161159
capistrano (~> 3.7)
162160
capistrano-bundler
@@ -480,7 +478,6 @@ DEPENDENCIES
480478
bootsnap (>= 1.18.4)
481479
capistrano-rails
482480
capistrano-rbenv
483-
capistrano-yarn
484481
capistrano3-puma (~> 6.0)
485482
capybara (>= 3.40)
486483
csv

bin/pnpm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env ruby
2+
APP_ROOT = File.expand_path('..', __dir__)
3+
Dir.chdir(APP_ROOT) do
4+
pnpm = ENV.fetch('PATH', '').split(File::PATH_SEPARATOR).
5+
reject { |dir| File.expand_path(dir) == __dir__ }.
6+
product(%w[pnpm pnpm.cmd pnpm.ps1]).
7+
map { |dir, file| File.expand_path(file, dir) }.
8+
find { |file| File.executable?(file) }
9+
10+
if pnpm
11+
exec pnpm, *ARGV
12+
else
13+
$stderr.puts 'pnpm executable was not detected in the system.'
14+
$stderr.puts 'Install pnpm via https://pnpm.io/installation'
15+
exit 1
16+
end
17+
end

bin/setup

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ FileUtils.chdir APP_ROOT do
1818
system("bundle check") || system!("bundle install")
1919

2020
# Install JavaScript dependencies
21-
system! 'bin/yarn'
21+
system! 'bin/pnpm', 'install', '--frozen-lockfile'
2222

2323
# puts "\n== Copying sample files =="
2424
# unless File.exist?("config/database.yml")

bin/update

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ chdir APP_ROOT do
1717
system! 'gem install bundler --conservative'
1818
system('bundle check') || system!('bundle install')
1919

20-
# Install JavaScript dependencies if using Yarn
21-
# system('bin/yarn')
20+
# Install JavaScript dependencies if needed
21+
# system('bin/pnpm', 'install', '--frozen-lockfile')
2222

2323
puts "\n== Updating database =="
2424
system! 'bin/rails db:migrate'

0 commit comments

Comments
 (0)