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

Migrate to pnpm #1833

Merged
merged 1 commit into from
Oct 9, 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
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ jobs:
with:
ruby-version: '3.3.5'
bundler-cache: true
- uses: pnpm/action-setup@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
- name: Yarn
run: yarn
cache: 'pnpm'
- name: Install node dependencies
run: pnpm install
- name: Set up Database
run: bundle exec rails db:prepare
- name: Check GEOS support
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ jobs:
with:
ruby-version: '3.3.5'
bundler-cache: true
- uses: pnpm/action-setup@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
- name: Yarn
run: yarn
cache: 'pnpm'
- name: Install node dependencies
run: pnpm install
- name: Run lints
run: bundle exec rake lint
2 changes: 1 addition & 1 deletion bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ FileUtils.chdir APP_ROOT do
system("bundle check") || system!("bundle install")

# Install JavaScript dependencies
system!("yarn install")
system!("pnpm install")

# puts "\n== Copying sample files =="
# unless File.exist?("config/database.yml")
Expand Down
11 changes: 5 additions & 6 deletions docker/icare/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax = docker/dockerfile:1

# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
ARG RUBY_VERSION=3.3.3
ARG RUBY_VERSION=3.3.5
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base

# Rails app lives here
Expand All @@ -23,11 +23,11 @@ RUN apt-get update -qq && \

# Install JavaScript dependencies
ARG NODE_VERSION=20.10.0
ARG YARN_VERSION=1.22.21
ARG PNPM_VERSION=9.12.1
ENV PATH=/usr/local/node/bin:$PATH
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
/tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
npm install -g yarn@$YARN_VERSION && \
npm install -g pnpm@$PNPM_VERSION && \
rm -rf /tmp/node-build-master

# Install application gems
Expand All @@ -36,10 +36,9 @@ RUN bundle install && \
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
bundle exec bootsnap precompile --gemfile


# Install node modules
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
COPY package.json pnpm-lock.yaml ./
RUN pnpm install

# Copy application code
COPY . .
Expand Down
18 changes: 9 additions & 9 deletions lib/tasks/yarn_linters.rake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

namespace :yarn do
namespace :pnpm do
# rubocop:disable Rails/RakeEnvironment
task :run, %i[command] do |_, args|
# Install only production deps when for not usual envs.
Expand All @@ -11,25 +11,25 @@ namespace :yarn do

system(
{ 'NODE_ENV' => node_env },
"yarn #{args[:command]}",
"pnpm #{args[:command]}",
exception: true
)
rescue Errno::ENOENT
warn 'bin/yarn was not found.'
warn 'pnpm was not found.'
exit 1
end

desc 'Run `bin/yarn stylelint app/**/*.{scss,css}`'
desc 'Run `bin/pnpm stylelint app/**/*.{scss,css}`'
task :stylelint do
Rake::Task['yarn:run'].execute(command: "stylelint #{Dir.glob('app/**/*.{scss,css}').join(' ')}")
Rake::Task['pnpm:run'].execute(command: "stylelint #{Dir.glob('app/**/*.{scss,css}').join(' ')}")
end

desc 'Run `bin/yarn eslint`'
desc 'Run `bin/pnpm eslint`'
task :eslint do
Rake::Task['yarn:run'].execute(command: 'eslint app/**/*.js')
Rake::Task['pnpm:run'].execute(command: 'eslint app/**/*.js')
end
# rubocop:enable Rails/RakeEnvironment
end

task(:lint).sources.push 'yarn:stylelint'
task(:lint).sources.push 'yarn:eslint'
task(:lint).sources.push 'pnpm:stylelint'
task(:lint).sources.push 'pnpm:eslint'
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"version": "1.0.0",
"engines": {
"node": ">= 20.0",
"yarn": "^1.22.22"
"pnpm": "^9.12.1"
},
"packageManager": "[email protected]",
"packageManager": "pnpm@^9.12.1",
"dependencies": {
"@babel/core": "^7.25.7",
"@babel/plugin-transform-runtime": "^7.25.7",
Expand Down
Loading
Loading