Skip to content

Commit 978bc1d

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 978bc1d

15 files changed

Lines changed: 9026 additions & 7919 deletions

File tree

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 pnpm@10.18.3 --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'

bin/yarn

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
#!/usr/bin/env ruby
22
APP_ROOT = File.expand_path('..', __dir__)
33
Dir.chdir(APP_ROOT) do
4-
yarn = ENV["PATH"].split(File::PATH_SEPARATOR).
5-
select { |dir| File.expand_path(dir) != __dir__ }.
6-
product(["yarn", "yarn.cmd", "yarn.ps1"]).
4+
pnpm = ENV.fetch("PATH", "").split(File::PATH_SEPARATOR).
5+
reject { |dir| File.expand_path(dir) == __dir__ }.
6+
product(["pnpm", "pnpm.cmd", "pnpm.ps1"]).
77
map { |dir, file| File.expand_path(file, dir) }.
88
find { |file| File.executable?(file) }
99

10-
if yarn
11-
exec yarn, *ARGV
10+
if pnpm
11+
warn "Deprecated: bin/yarn now proxies to pnpm. Update scripts to use bin/pnpm." unless ENV["PNPM_PROXY_SILENT"]
12+
exec pnpm, *ARGV
1213
else
13-
$stderr.puts "Yarn executable was not detected in the system."
14-
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
14+
$stderr.puts "pnpm executable was not detected in the system."
15+
$stderr.puts "Install pnpm via https://pnpm.io/installation"
1516
exit 1
1617
end
1718
end

config/webpacker.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ development:
5252
<<: *default
5353
compile: true
5454

55-
# Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules
56-
check_yarn_integrity: true
55+
# Legacy option retained for compatibility; pnpm's lockfile is validated via install flags instead.
56+
check_yarn_integrity: false
5757

5858
# Reference: https://webpack.js.org/configuration/dev-server/
5959
dev_server:

0 commit comments

Comments
 (0)