Skip to content

Commit

Permalink
Use pnpm (#985)
Browse files Browse the repository at this point in the history
  • Loading branch information
tagliala authored Oct 8, 2024
1 parent f374b37 commit 146d893
Show file tree
Hide file tree
Showing 7 changed files with 8,504 additions and 12,740 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,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: 'npm'
- name: Run npm install
run: |
npm install -g [email protected]
npm install
cache: 'pnpm'
- name: Install node dependencies
run: pnpm install
- name: Set up Database
run: bundle exec rails db:prepare
- name: Run specs
Expand Down
24 changes: 10 additions & 14 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,18 @@ jobs:
.eslintrc.cjs
.github/workflows/lint.yml
app/**/*.js
- uses: pnpm/action-setup@v4
- name: Set up Node
if: steps.changed-files.outputs.any_changed == 'true'
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Run npm install
if: steps.changed-files.outputs.any_changed == 'true'
run: |
npm install -g [email protected]
npm install
cache: 'pnpm'
- name: Install node dependencies
run: pnpm install
- name: Run ESLint
if: steps.changed-files.outputs.any_changed == 'true'
run: npx eslint app/**/*.js
run: pnpm eslint app/**/*.js

stylelint:
name: Stylelint
Expand All @@ -101,17 +99,15 @@ jobs:
.github/workflows/lint.yml
.stylelintrc
app/**/*.{scss,css}
- uses: pnpm/action-setup@v4
- name: Set up Node
if: steps.changed-files.outputs.any_changed == 'true'
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Run npm install
if: steps.changed-files.outputs.any_changed == 'true'
run: |
npm install -g [email protected]
npm install
cache: 'pnpm'
- name: Install node dependencies
run: pnpm install
- name: Run Stylelint
if: steps.changed-files.outputs.any_changed == 'true'
run: npx stylelint app/**/*.{scss,css}
run: pnpm stylelint app/**/*.{scss,css}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This is an opinionated starter web application based on the following technology
* [Ruby 3.3.5][:ruby-url]
* [Rails 7.2.1][:ruby-on-rails-url]
* [Webpack 5][:webpack-url] (via [Shakapacker][:shakapacker-url])
* [npm][:npm-url]
* [pnpm][:pnpm-url]
* [Puma][:puma-url]
* [PostgreSQL][:postgresql-url]
* [Redis][:redis-url]
Expand All @@ -27,7 +27,7 @@ This is an opinionated starter web application based on the following technology
[:autoprefixer-url]: https://github.com/postcss/autoprefixer
[:bootstrap-url]: https://getbootstrap.com/
[:fontawesome-url]: https://fontawesome.com/
[:npm-url]: https://www.npmjs.com/
[:pnpm-url]: https://pnpm.io/
[:postgresql-url]: https://www.postgresql.org/
[:puma-url]: https://puma.io/
[:redis-url]: https://redis.io/
Expand Down
18 changes: 9 additions & 9 deletions lib/tasks/npx_linters.rake → lib/tasks/pnpm_linters.rake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

namespace :npx 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 :npx do

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

desc 'Run `npx stylelint app/**/*.{scss,css}`'
desc 'Run `pnpm stylelint app/**/*.{scss,css}`'
task :stylelint do
Rake::Task['npx: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 `npx eslint`'
desc 'Run `pnpm eslint`'
task :eslint do
Rake::Task['npx: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 'npx:stylelint'
task(:lint).sources.push 'npx:eslint'
task(:lint).sources.push 'pnpm:stylelint'
task(:lint).sources.push 'pnpm:eslint'
Loading

0 comments on commit 146d893

Please sign in to comment.