diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..76f9d43 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,52 @@ +name: CI +on: [push, pull_request] +jobs: + tests: + strategy: + fail-fast: false + matrix: + ruby-version: + - "3.0" + - "3.1" + - "3.2" + gemfile: + - Gemfile + - gemfiles/rails_7_0_propshaft.gemfile + - gemfiles/rails_7_1_propshaft.gemfile + - gemfiles/rails_main_propshaft.gemfile + - gemfiles/rails_7_0_sprockets.gemfile + - gemfiles/rails_7_1_sprockets.gemfile + - gemfiles/rails_main_sprockets.gemfile + continue-on-error: [ false ] + + name: ${{ format('Tests (Ruby {0}, {1})', matrix.ruby-version, matrix.gemfile) }} + runs-on: ubuntu-latest + continue-on-error: ${{ matrix.continue-on-error }} + + env: + BUNDLE_GEMFILE: ${{ matrix.gemfile }} + + steps: + - uses: actions/checkout@v4 + + - name: Remove Gemfile lock + run: | + rm -f $BUNDLE_GEMFILE.lock + + - name: Install Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true + + # This prevents a "Failed to build gem native extension" error when + # running `bundle install` inside a Rails app that is generated for + # testing. The error occurs only in CI, and only when using Ruby 3.0 and + # Rails >= 7.1. + - name: Install sass-embedded gem + if: ${{ matrix.ruby-version == '3.0' }} + run: gem install sass-embedded + + - name: Run tests + run: | + bundle exec rake diff --git a/.gitignore b/.gitignore index b2a1445..f689000 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,6 @@ .idea/ **/tmp/ /exe/*/tailwindcss + +# Ignore Gemfile.lock files for Rails main branch. +/gemfiles/rails_main*.gemfile.lock diff --git a/Appraisals b/Appraisals new file mode 100644 index 0000000..dd6b0c7 --- /dev/null +++ b/Appraisals @@ -0,0 +1,29 @@ +appraise "rails_7_0_sprockets" do + gem "rails", "~> 7.0.0" + gem "sprockets-rails" +end + +appraise "rails_7_0_propshaft" do + gem "rails", "~> 7.0.0" + gem "propshaft" +end + +appraise "rails_7_1_sprockets" do + gem "rails", "~> 7.1.0" + gem "sprockets-rails" +end + +appraise "rails_7_1_propshaft" do + gem "rails", "~> 7.1.0" + gem "propshaft" +end + +appraise "rails_main_sprockets" do + gem "rails", github: "rails/rails", branch: "main" + gem "sprockets-rails" +end + +appraise "rails_main_propshaft" do + gem "rails", github: "rails/rails", branch: "main" + gem "propshaft" +end diff --git a/Gemfile b/Gemfile index 5db3afe..41619eb 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,9 @@ source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } + gemspec +gem "appraisal" +gem "rails", "~> 6.1.0" gem "sqlite3" gem "debug", ">= 1.0.0" - -group :test do - gem "actionmailer", ">= 6.0.0" -end diff --git a/Gemfile.lock b/Gemfile.lock index 18566c8..b1942c6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,96 +8,174 @@ PATH GEM remote: https://rubygems.org/ specs: - actionmailer (6.1.4.1) - actionpack (= 6.1.4.1) - actionview (= 6.1.4.1) - activejob (= 6.1.4.1) - activesupport (= 6.1.4.1) + actioncable (6.1.7.6) + actionpack (= 6.1.7.6) + activesupport (= 6.1.7.6) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (6.1.7.6) + actionpack (= 6.1.7.6) + activejob (= 6.1.7.6) + activerecord (= 6.1.7.6) + activestorage (= 6.1.7.6) + activesupport (= 6.1.7.6) + mail (>= 2.7.1) + actionmailer (6.1.7.6) + actionpack (= 6.1.7.6) + actionview (= 6.1.7.6) + activejob (= 6.1.7.6) + activesupport (= 6.1.7.6) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.4.1) - actionview (= 6.1.4.1) - activesupport (= 6.1.4.1) + actionpack (6.1.7.6) + actionview (= 6.1.7.6) + activesupport (= 6.1.7.6) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actionview (6.1.4.1) - activesupport (= 6.1.4.1) + actiontext (6.1.7.6) + actionpack (= 6.1.7.6) + activerecord (= 6.1.7.6) + activestorage (= 6.1.7.6) + activesupport (= 6.1.7.6) + nokogiri (>= 1.8.5) + actionview (6.1.7.6) + activesupport (= 6.1.7.6) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.4.1) - activesupport (= 6.1.4.1) + activejob (6.1.7.6) + activesupport (= 6.1.7.6) globalid (>= 0.3.6) - activesupport (6.1.4.1) + activemodel (6.1.7.6) + activesupport (= 6.1.7.6) + activerecord (6.1.7.6) + activemodel (= 6.1.7.6) + activesupport (= 6.1.7.6) + activestorage (6.1.7.6) + actionpack (= 6.1.7.6) + activejob (= 6.1.7.6) + activerecord (= 6.1.7.6) + activesupport (= 6.1.7.6) + marcel (~> 1.0) + mini_mime (>= 1.1.0) + activesupport (6.1.7.6) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) builder (3.2.4) - concurrent-ruby (1.1.9) + concurrent-ruby (1.2.2) crass (1.0.6) + date (3.3.4) debug (1.1.0) irb reline (>= 0.2.7) - erubi (1.10.0) - globalid (1.0.0) - activesupport (>= 5.0) + erubi (1.12.0) + globalid (1.2.1) + activesupport (>= 6.1) google-protobuf (3.23.3) - i18n (1.8.11) + i18n (1.14.1) concurrent-ruby (~> 1.0) io-console (0.5.9) irb (1.3.7) reline (>= 0.2.7) - loofah (2.12.0) + loofah (2.22.0) crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.7.1) + nokogiri (>= 1.12.0) + mail (2.8.1) mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.2) method_source (1.0.0) - mini_mime (1.1.2) - mini_portile2 (2.6.1) - minitest (5.14.4) - nokogiri (1.12.5) - mini_portile2 (~> 2.6.1) + mini_mime (1.1.5) + mini_portile2 (2.8.5) + minitest (5.20.0) + net-imap (0.4.7) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.4.0) + net-protocol + nio4r (2.7.0) + nokogiri (1.15.5) + mini_portile2 (~> 2.8.2) racc (~> 1.4) - racc (1.6.0) - rack (2.2.3) - rack-test (1.1.0) - rack (>= 1.0, < 3) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + racc (1.7.3) + rack (2.2.8) + rack-test (2.1.0) + rack (>= 1.3) + rails (6.1.7.6) + actioncable (= 6.1.7.6) + actionmailbox (= 6.1.7.6) + actionmailer (= 6.1.7.6) + actionpack (= 6.1.7.6) + actiontext (= 6.1.7.6) + actionview (= 6.1.7.6) + activejob (= 6.1.7.6) + activemodel (= 6.1.7.6) + activerecord (= 6.1.7.6) + activestorage (= 6.1.7.6) + activesupport (= 6.1.7.6) + bundler (>= 1.15.0) + railties (= 6.1.7.6) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.4.2) - loofah (~> 2.3) - railties (6.1.4.1) - actionpack (= 6.1.4.1) - activesupport (= 6.1.4.1) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (6.1.7.6) + actionpack (= 6.1.7.6) + activesupport (= 6.1.7.6) method_source - rake (>= 0.13) + rake (>= 12.2) thor (~> 1.0) - rake (13.0.6) + rake (13.1.0) reline (0.2.7) io-console (~> 0.5) sass-embedded (1.63.4) google-protobuf (~> 3.23) rake (>= 13.0.0) + sprockets (4.2.1) + concurrent-ruby (~> 1.0) + rack (>= 2.2.4, < 4) + sprockets-rails (3.4.2) + actionpack (>= 5.2) + activesupport (>= 5.2) + sprockets (>= 3.0.0) sqlite3 (1.4.2) - thor (1.2.2) - tzinfo (2.0.4) + thor (1.3.0) + timeout (0.4.1) + tzinfo (2.0.6) concurrent-ruby (~> 1.0) - zeitwerk (2.5.1) + websocket-driver (0.7.6) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.6.12) PLATFORMS ruby DEPENDENCIES - actionmailer (>= 6.0.0) + appraisal dartsass-rails! debug (>= 1.0.0) + rails (~> 6.1.0) sqlite3 BUNDLED WITH diff --git a/README.md b/README.md index 6bd4a7f..0ac9db9 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ the Dart Sass process is most likely not running. ##### Solution -Make sure the Dart Sass process is running by starting the Rails sever by +Make sure the Dart Sass process is running by starting the Rails server by running: `./bin/dev`. #### Running continuous integration pipelines diff --git a/gemfiles/rails_7_0_propshaft.gemfile b/gemfiles/rails_7_0_propshaft.gemfile new file mode 100644 index 0000000..1d545f8 --- /dev/null +++ b/gemfiles/rails_7_0_propshaft.gemfile @@ -0,0 +1,11 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "appraisal" +gem "rails", "~> 7.0.0" +gem "sqlite3" +gem "debug", ">= 1.0.0" +gem "propshaft" + +gemspec path: "../" diff --git a/gemfiles/rails_7_0_propshaft.gemfile.lock b/gemfiles/rails_7_0_propshaft.gemfile.lock new file mode 100644 index 0000000..60da9e6 --- /dev/null +++ b/gemfiles/rails_7_0_propshaft.gemfile.lock @@ -0,0 +1,190 @@ +PATH + remote: .. + specs: + dartsass-rails (0.5.0) + railties (>= 6.0.0) + sass-embedded (~> 1.63) + +GEM + remote: https://rubygems.org/ + specs: + actioncable (7.0.8) + actionpack (= 7.0.8) + activesupport (= 7.0.8) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (7.0.8) + actionpack (= 7.0.8) + activejob (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) + mail (>= 2.7.1) + net-imap + net-pop + net-smtp + actionmailer (7.0.8) + actionpack (= 7.0.8) + actionview (= 7.0.8) + activejob (= 7.0.8) + activesupport (= 7.0.8) + mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp + rails-dom-testing (~> 2.0) + actionpack (7.0.8) + actionview (= 7.0.8) + activesupport (= 7.0.8) + rack (~> 2.0, >= 2.2.4) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (7.0.8) + actionpack (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (7.0.8) + activesupport (= 7.0.8) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (7.0.8) + activesupport (= 7.0.8) + globalid (>= 0.3.6) + activemodel (7.0.8) + activesupport (= 7.0.8) + activerecord (7.0.8) + activemodel (= 7.0.8) + activesupport (= 7.0.8) + activestorage (7.0.8) + actionpack (= 7.0.8) + activejob (= 7.0.8) + activerecord (= 7.0.8) + activesupport (= 7.0.8) + marcel (~> 1.0) + mini_mime (>= 1.1.0) + activesupport (7.0.8) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + builder (3.2.4) + concurrent-ruby (1.2.2) + crass (1.0.6) + date (3.3.4) + debug (1.8.0) + irb (>= 1.5.0) + reline (>= 0.3.1) + erubi (1.12.0) + globalid (1.2.1) + activesupport (>= 6.1) + google-protobuf (3.25.1-x86_64-linux) + i18n (1.14.1) + concurrent-ruby (~> 1.0) + io-console (0.6.0) + irb (1.9.1) + rdoc + reline (>= 0.3.8) + loofah (2.22.0) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.2) + method_source (1.0.0) + mini_mime (1.1.5) + minitest (5.20.0) + net-imap (0.4.7) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.4.0) + net-protocol + nio4r (2.7.0) + nokogiri (1.15.5-x86_64-linux) + racc (~> 1.4) + propshaft (0.8.0) + actionpack (>= 7.0.0) + activesupport (>= 7.0.0) + rack + railties (>= 7.0.0) + psych (5.1.1.1) + stringio + racc (1.7.3) + rack (2.2.8) + rack-test (2.1.0) + rack (>= 1.3) + rails (7.0.8) + actioncable (= 7.0.8) + actionmailbox (= 7.0.8) + actionmailer (= 7.0.8) + actionpack (= 7.0.8) + actiontext (= 7.0.8) + actionview (= 7.0.8) + activejob (= 7.0.8) + activemodel (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) + bundler (>= 1.15.0) + railties (= 7.0.8) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (7.0.8) + actionpack (= 7.0.8) + activesupport (= 7.0.8) + method_source + rake (>= 12.2) + thor (~> 1.0) + zeitwerk (~> 2.5) + rake (13.1.0) + rdoc (6.6.0) + psych (>= 4.0.0) + reline (0.4.1) + io-console (~> 0.5) + sass-embedded (1.69.5-x86_64-linux-gnu) + google-protobuf (~> 3.23) + sqlite3 (1.6.9-x86_64-linux) + stringio (3.1.0) + thor (1.3.0) + timeout (0.4.1) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + websocket-driver (0.7.6) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.6.12) + +PLATFORMS + x86_64-linux + +DEPENDENCIES + appraisal + dartsass-rails! + debug (>= 1.0.0) + propshaft + rails (~> 7.0.0) + sqlite3 + +BUNDLED WITH + 2.2.32 diff --git a/gemfiles/rails_7_0_sprockets.gemfile b/gemfiles/rails_7_0_sprockets.gemfile new file mode 100644 index 0000000..c55d639 --- /dev/null +++ b/gemfiles/rails_7_0_sprockets.gemfile @@ -0,0 +1,11 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "appraisal" +gem "rails", "~> 7.0.0" +gem "sqlite3" +gem "debug", ">= 1.0.0" +gem "sprockets-rails" + +gemspec path: "../" diff --git a/gemfiles/rails_7_0_sprockets.gemfile.lock b/gemfiles/rails_7_0_sprockets.gemfile.lock new file mode 100644 index 0000000..28be6c4 --- /dev/null +++ b/gemfiles/rails_7_0_sprockets.gemfile.lock @@ -0,0 +1,192 @@ +PATH + remote: .. + specs: + dartsass-rails (0.5.0) + railties (>= 6.0.0) + sass-embedded (~> 1.63) + +GEM + remote: https://rubygems.org/ + specs: + actioncable (7.0.8) + actionpack (= 7.0.8) + activesupport (= 7.0.8) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (7.0.8) + actionpack (= 7.0.8) + activejob (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) + mail (>= 2.7.1) + net-imap + net-pop + net-smtp + actionmailer (7.0.8) + actionpack (= 7.0.8) + actionview (= 7.0.8) + activejob (= 7.0.8) + activesupport (= 7.0.8) + mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp + rails-dom-testing (~> 2.0) + actionpack (7.0.8) + actionview (= 7.0.8) + activesupport (= 7.0.8) + rack (~> 2.0, >= 2.2.4) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (7.0.8) + actionpack (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (7.0.8) + activesupport (= 7.0.8) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (7.0.8) + activesupport (= 7.0.8) + globalid (>= 0.3.6) + activemodel (7.0.8) + activesupport (= 7.0.8) + activerecord (7.0.8) + activemodel (= 7.0.8) + activesupport (= 7.0.8) + activestorage (7.0.8) + actionpack (= 7.0.8) + activejob (= 7.0.8) + activerecord (= 7.0.8) + activesupport (= 7.0.8) + marcel (~> 1.0) + mini_mime (>= 1.1.0) + activesupport (7.0.8) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + builder (3.2.4) + concurrent-ruby (1.2.2) + crass (1.0.6) + date (3.3.4) + debug (1.8.0) + irb (>= 1.5.0) + reline (>= 0.3.1) + erubi (1.12.0) + globalid (1.2.1) + activesupport (>= 6.1) + google-protobuf (3.25.1-x86_64-linux) + i18n (1.14.1) + concurrent-ruby (~> 1.0) + io-console (0.6.0) + irb (1.9.1) + rdoc + reline (>= 0.3.8) + loofah (2.22.0) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.2) + method_source (1.0.0) + mini_mime (1.1.5) + minitest (5.20.0) + net-imap (0.4.7) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.4.0) + net-protocol + nio4r (2.7.0) + nokogiri (1.15.5-x86_64-linux) + racc (~> 1.4) + psych (5.1.1.1) + stringio + racc (1.7.3) + rack (2.2.8) + rack-test (2.1.0) + rack (>= 1.3) + rails (7.0.8) + actioncable (= 7.0.8) + actionmailbox (= 7.0.8) + actionmailer (= 7.0.8) + actionpack (= 7.0.8) + actiontext (= 7.0.8) + actionview (= 7.0.8) + activejob (= 7.0.8) + activemodel (= 7.0.8) + activerecord (= 7.0.8) + activestorage (= 7.0.8) + activesupport (= 7.0.8) + bundler (>= 1.15.0) + railties (= 7.0.8) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (7.0.8) + actionpack (= 7.0.8) + activesupport (= 7.0.8) + method_source + rake (>= 12.2) + thor (~> 1.0) + zeitwerk (~> 2.5) + rake (13.1.0) + rdoc (6.6.0) + psych (>= 4.0.0) + reline (0.4.1) + io-console (~> 0.5) + sass-embedded (1.69.5-x86_64-linux-gnu) + google-protobuf (~> 3.23) + sprockets (4.2.1) + concurrent-ruby (~> 1.0) + rack (>= 2.2.4, < 4) + sprockets-rails (3.4.2) + actionpack (>= 5.2) + activesupport (>= 5.2) + sprockets (>= 3.0.0) + sqlite3 (1.6.9-x86_64-linux) + stringio (3.1.0) + thor (1.3.0) + timeout (0.4.1) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + websocket-driver (0.7.6) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.6.12) + +PLATFORMS + x86_64-linux + +DEPENDENCIES + appraisal + dartsass-rails! + debug (>= 1.0.0) + rails (~> 7.0.0) + sprockets-rails + sqlite3 + +BUNDLED WITH + 2.2.32 diff --git a/gemfiles/rails_7_1_propshaft.gemfile b/gemfiles/rails_7_1_propshaft.gemfile new file mode 100644 index 0000000..1c990c0 --- /dev/null +++ b/gemfiles/rails_7_1_propshaft.gemfile @@ -0,0 +1,11 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "appraisal" +gem "rails", "~> 7.1.0" +gem "sqlite3" +gem "debug", ">= 1.0.0" +gem "propshaft" + +gemspec path: "../" diff --git a/gemfiles/rails_7_1_propshaft.gemfile.lock b/gemfiles/rails_7_1_propshaft.gemfile.lock new file mode 100644 index 0000000..a65e679 --- /dev/null +++ b/gemfiles/rails_7_1_propshaft.gemfile.lock @@ -0,0 +1,212 @@ +PATH + remote: .. + specs: + dartsass-rails (0.5.0) + railties (>= 6.0.0) + sass-embedded (~> 1.63) + +GEM + remote: https://rubygems.org/ + specs: + actioncable (7.1.2) + actionpack (= 7.1.2) + activesupport (= 7.1.2) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + zeitwerk (~> 2.6) + actionmailbox (7.1.2) + actionpack (= 7.1.2) + activejob (= 7.1.2) + activerecord (= 7.1.2) + activestorage (= 7.1.2) + activesupport (= 7.1.2) + mail (>= 2.7.1) + net-imap + net-pop + net-smtp + actionmailer (7.1.2) + actionpack (= 7.1.2) + actionview (= 7.1.2) + activejob (= 7.1.2) + activesupport (= 7.1.2) + mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp + rails-dom-testing (~> 2.2) + actionpack (7.1.2) + actionview (= 7.1.2) + activesupport (= 7.1.2) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.2) + actionpack (= 7.1.2) + activerecord (= 7.1.2) + activestorage (= 7.1.2) + activesupport (= 7.1.2) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (7.1.2) + activesupport (= 7.1.2) + builder (~> 3.1) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.1.2) + activesupport (= 7.1.2) + globalid (>= 0.3.6) + activemodel (7.1.2) + activesupport (= 7.1.2) + activerecord (7.1.2) + activemodel (= 7.1.2) + activesupport (= 7.1.2) + timeout (>= 0.4.0) + activestorage (7.1.2) + actionpack (= 7.1.2) + activejob (= 7.1.2) + activerecord (= 7.1.2) + activesupport (= 7.1.2) + marcel (~> 1.0) + activesupport (7.1.2) + base64 + bigdecimal + concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + minitest (>= 5.1) + mutex_m + tzinfo (~> 2.0) + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + base64 (0.2.0) + bigdecimal (3.1.4) + builder (3.2.4) + concurrent-ruby (1.2.2) + connection_pool (2.4.1) + crass (1.0.6) + date (3.3.4) + debug (1.8.0) + irb (>= 1.5.0) + reline (>= 0.3.1) + drb (2.2.0) + ruby2_keywords + erubi (1.12.0) + globalid (1.2.1) + activesupport (>= 6.1) + google-protobuf (3.25.1-x86_64-linux) + i18n (1.14.1) + concurrent-ruby (~> 1.0) + io-console (0.6.0) + irb (1.9.1) + rdoc + reline (>= 0.3.8) + loofah (2.22.0) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.2) + mini_mime (1.1.5) + minitest (5.20.0) + mutex_m (0.2.0) + net-imap (0.4.7) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.4.0) + net-protocol + nio4r (2.7.0) + nokogiri (1.15.5-x86_64-linux) + racc (~> 1.4) + propshaft (0.8.0) + actionpack (>= 7.0.0) + activesupport (>= 7.0.0) + rack + railties (>= 7.0.0) + psych (5.1.1.1) + stringio + racc (1.7.3) + rack (3.0.8) + rack-session (2.0.0) + rack (>= 3.0.0) + rack-test (2.1.0) + rack (>= 1.3) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + rails (7.1.2) + actioncable (= 7.1.2) + actionmailbox (= 7.1.2) + actionmailer (= 7.1.2) + actionpack (= 7.1.2) + actiontext (= 7.1.2) + actionview (= 7.1.2) + activejob (= 7.1.2) + activemodel (= 7.1.2) + activerecord (= 7.1.2) + activestorage (= 7.1.2) + activesupport (= 7.1.2) + bundler (>= 1.15.0) + railties (= 7.1.2) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (7.1.2) + actionpack (= 7.1.2) + activesupport (= 7.1.2) + irb + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) + rake (13.1.0) + rdoc (6.6.0) + psych (>= 4.0.0) + reline (0.4.1) + io-console (~> 0.5) + ruby2_keywords (0.0.5) + sass-embedded (1.69.5-x86_64-linux-gnu) + google-protobuf (~> 3.23) + sqlite3 (1.6.9-x86_64-linux) + stringio (3.1.0) + thor (1.3.0) + timeout (0.4.1) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + webrick (1.8.1) + websocket-driver (0.7.6) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.6.12) + +PLATFORMS + x86_64-linux + +DEPENDENCIES + appraisal + dartsass-rails! + debug (>= 1.0.0) + propshaft + rails (~> 7.1.0) + sqlite3 + +BUNDLED WITH + 2.2.32 diff --git a/gemfiles/rails_7_1_sprockets.gemfile b/gemfiles/rails_7_1_sprockets.gemfile new file mode 100644 index 0000000..074b901 --- /dev/null +++ b/gemfiles/rails_7_1_sprockets.gemfile @@ -0,0 +1,11 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "appraisal" +gem "rails", "~> 7.1.0" +gem "sqlite3" +gem "debug", ">= 1.0.0" +gem "sprockets-rails" + +gemspec path: "../" diff --git a/gemfiles/rails_7_1_sprockets.gemfile.lock b/gemfiles/rails_7_1_sprockets.gemfile.lock new file mode 100644 index 0000000..fb1cb6a --- /dev/null +++ b/gemfiles/rails_7_1_sprockets.gemfile.lock @@ -0,0 +1,214 @@ +PATH + remote: .. + specs: + dartsass-rails (0.5.0) + railties (>= 6.0.0) + sass-embedded (~> 1.63) + +GEM + remote: https://rubygems.org/ + specs: + actioncable (7.1.2) + actionpack (= 7.1.2) + activesupport (= 7.1.2) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + zeitwerk (~> 2.6) + actionmailbox (7.1.2) + actionpack (= 7.1.2) + activejob (= 7.1.2) + activerecord (= 7.1.2) + activestorage (= 7.1.2) + activesupport (= 7.1.2) + mail (>= 2.7.1) + net-imap + net-pop + net-smtp + actionmailer (7.1.2) + actionpack (= 7.1.2) + actionview (= 7.1.2) + activejob (= 7.1.2) + activesupport (= 7.1.2) + mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp + rails-dom-testing (~> 2.2) + actionpack (7.1.2) + actionview (= 7.1.2) + activesupport (= 7.1.2) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.2) + actionpack (= 7.1.2) + activerecord (= 7.1.2) + activestorage (= 7.1.2) + activesupport (= 7.1.2) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (7.1.2) + activesupport (= 7.1.2) + builder (~> 3.1) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.1.2) + activesupport (= 7.1.2) + globalid (>= 0.3.6) + activemodel (7.1.2) + activesupport (= 7.1.2) + activerecord (7.1.2) + activemodel (= 7.1.2) + activesupport (= 7.1.2) + timeout (>= 0.4.0) + activestorage (7.1.2) + actionpack (= 7.1.2) + activejob (= 7.1.2) + activerecord (= 7.1.2) + activesupport (= 7.1.2) + marcel (~> 1.0) + activesupport (7.1.2) + base64 + bigdecimal + concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + minitest (>= 5.1) + mutex_m + tzinfo (~> 2.0) + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + base64 (0.2.0) + bigdecimal (3.1.4) + builder (3.2.4) + concurrent-ruby (1.2.2) + connection_pool (2.4.1) + crass (1.0.6) + date (3.3.4) + debug (1.8.0) + irb (>= 1.5.0) + reline (>= 0.3.1) + drb (2.2.0) + ruby2_keywords + erubi (1.12.0) + globalid (1.2.1) + activesupport (>= 6.1) + google-protobuf (3.25.1-x86_64-linux) + i18n (1.14.1) + concurrent-ruby (~> 1.0) + io-console (0.6.0) + irb (1.9.1) + rdoc + reline (>= 0.3.8) + loofah (2.22.0) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.2) + mini_mime (1.1.5) + minitest (5.20.0) + mutex_m (0.2.0) + net-imap (0.4.7) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.4.0) + net-protocol + nio4r (2.7.0) + nokogiri (1.15.5-x86_64-linux) + racc (~> 1.4) + psych (5.1.1.1) + stringio + racc (1.7.3) + rack (3.0.8) + rack-session (2.0.0) + rack (>= 3.0.0) + rack-test (2.1.0) + rack (>= 1.3) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + rails (7.1.2) + actioncable (= 7.1.2) + actionmailbox (= 7.1.2) + actionmailer (= 7.1.2) + actionpack (= 7.1.2) + actiontext (= 7.1.2) + actionview (= 7.1.2) + activejob (= 7.1.2) + activemodel (= 7.1.2) + activerecord (= 7.1.2) + activestorage (= 7.1.2) + activesupport (= 7.1.2) + bundler (>= 1.15.0) + railties (= 7.1.2) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (7.1.2) + actionpack (= 7.1.2) + activesupport (= 7.1.2) + irb + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) + rake (13.1.0) + rdoc (6.6.0) + psych (>= 4.0.0) + reline (0.4.1) + io-console (~> 0.5) + ruby2_keywords (0.0.5) + sass-embedded (1.69.5-x86_64-linux-gnu) + google-protobuf (~> 3.23) + sprockets (4.2.1) + concurrent-ruby (~> 1.0) + rack (>= 2.2.4, < 4) + sprockets-rails (3.4.2) + actionpack (>= 5.2) + activesupport (>= 5.2) + sprockets (>= 3.0.0) + sqlite3 (1.6.9-x86_64-linux) + stringio (3.1.0) + thor (1.3.0) + timeout (0.4.1) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + webrick (1.8.1) + websocket-driver (0.7.6) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.6.12) + +PLATFORMS + x86_64-linux + +DEPENDENCIES + appraisal + dartsass-rails! + debug (>= 1.0.0) + rails (~> 7.1.0) + sprockets-rails + sqlite3 + +BUNDLED WITH + 2.2.32 diff --git a/gemfiles/rails_main_propshaft.gemfile b/gemfiles/rails_main_propshaft.gemfile new file mode 100644 index 0000000..b72b45b --- /dev/null +++ b/gemfiles/rails_main_propshaft.gemfile @@ -0,0 +1,11 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "appraisal" +gem "rails", branch: "main", git: "https://github.com/rails/rails.git" +gem "sqlite3" +gem "debug", ">= 1.0.0" +gem "propshaft" + +gemspec path: "../" diff --git a/gemfiles/rails_main_sprockets.gemfile b/gemfiles/rails_main_sprockets.gemfile new file mode 100644 index 0000000..1b35512 --- /dev/null +++ b/gemfiles/rails_main_sprockets.gemfile @@ -0,0 +1,11 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "appraisal" +gem "rails", branch: "main", git: "https://github.com/rails/rails.git" +gem "sqlite3" +gem "debug", ">= 1.0.0" +gem "sprockets-rails" + +gemspec path: "../" diff --git a/test/installer_test.rb b/test/installer_test.rb new file mode 100644 index 0000000..4921f95 --- /dev/null +++ b/test/installer_test.rb @@ -0,0 +1,71 @@ +require "test_helper" + +class InstallerTest < ActiveSupport::TestCase + include RailsAppHelpers + + test "installer" do + with_new_rails_app do + out, _err = run_command("bin/rails", "dartsass:install") + + assert_match "", out + assert_equal 0, File.size("app/assets/builds/.keep") + assert_match "/app/assets/builds/*\n!/app/assets/builds/.keep", File.read(".gitignore") + assert_equal File.read("#{__dir__}/../lib/install/application.scss"), File.read("app/assets/stylesheets/application.scss") + assert_equal File.read("#{__dir__}/../lib/install/Procfile.dev"), File.read("Procfile.dev") + assert_equal File.read("#{__dir__}/../lib/install/dev"), File.read("bin/dev") + assert_equal 0700, File.stat("bin/dev").mode & 0700 + + if sprockets? + assert_match "//= link_tree ../builds", File.read("app/assets/config/manifest.js") + assert_no_match "//= link_directory ../stylesheets .css", File.read("app/assets/config/manifest.js") + end + end + end + + test "installer with missing .gitignore" do + with_new_rails_app do + FileUtils.rm(".gitignore") + out, _err = run_command("bin/rails", "dartsass:install") + + assert_match "", out + assert_not File.exist?(".gitignore") + end + end + + test "installer with pre-existing application.scss" do + with_new_rails_app do + File.write("app/assets/stylesheets/application.scss", "// pre-existing") + out, _err = run_command("bin/rails", "dartsass:install") + + assert_match "", out + assert_equal "// pre-existing", File.read("app/assets/stylesheets/application.scss") + end + end + + test "installer with pre-existing Procfile" do + with_new_rails_app do + File.write("Procfile.dev", "pre: existing\n") + out, _err = run_command("bin/rails", "dartsass:install") + + assert_match "", out + assert_equal "pre: existing\ncss: bin/rails dartsass:watch\n", File.read("Procfile.dev") + end + end + + private + def with_new_rails_app(&block) + super do + # Override `dartsass:build` to check that installation completed and to reduce test run time. + File.write("Rakefile", <<~RAKEFILE, mode: "a+") + Rake::Task["dartsass:build"].clear + namespace :dartsass do + task build: :environment do + puts "" + end + end + RAKEFILE + + block.call + end + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..a8c6aaa --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,78 @@ +# Configure Rails Environment +ENV["RAILS_ENV"] = "test" + +require "fileutils" +require "rails" +require "rails/test_help" + +module RailsAppHelpers + def self.included(base) + base.include ActiveSupport::Testing::Isolation + end + + private + def sprockets? + Gem.loaded_specs.key?("sprockets-rails") + end + + def propshaft? + Gem.loaded_specs.key?("propshaft") + end + + def asset_pipeline_option + if Rails::VERSION::MAJOR >= 7 + if propshaft? + "--asset-pipeline=propshaft" + elsif sprockets? + "--asset-pipeline=sprockets" + end + end + end + + def create_new_rails_app(app_dir) + require "rails/generators/rails/app/app_generator" + Rails::Generators::AppGenerator.start([app_dir, *asset_pipeline_option, "--skip-bundle", "--skip-bootsnap", "--quiet"]) + + Dir.chdir(app_dir) do + gemfile = File.read("Gemfile") + + gemfile.gsub!(/^gem ["']sassc?-rails["'].*/, "") # for Rails 6.1 and 7.0 + gemfile.gsub!(/^gem ["']dartsass-rails["'].*/, "") + gemfile << %(gem "dartsass-rails", path: #{File.expand_path("..", __dir__).inspect}\n) + + if Rails::VERSION::PRE == "alpha" + gemfile.gsub!(/^gem ["']rails["'].*/, "") + gemfile << %(gem "rails", path: #{Gem.loaded_specs["rails"].full_gem_path.inspect}\n) + end + + File.write("Gemfile", gemfile) + + run_command("bundle", "install") + end + end + + def with_new_rails_app(&block) + require "digest/sha1" + variant = [RUBY_VERSION, Gem.loaded_specs["rails"].full_gem_path, asset_pipeline_option] + app_name = "app_#{Digest::SHA1.hexdigest(variant.to_s)}" + cache_dir = "#{__dir__}/../tmp" + FileUtils.mkdir_p(cache_dir) + + Dir.mktmpdir do |tmpdir| + if Dir.exist?("#{cache_dir}/#{app_name}") + FileUtils.cp_r("#{cache_dir}/#{app_name}", tmpdir) + else + create_new_rails_app("#{tmpdir}/#{app_name}") + FileUtils.cp_r("#{tmpdir}/#{app_name}", cache_dir) # Cache app for future runs. + end + + Dir.chdir("#{tmpdir}/#{app_name}", &block) + end + end + + def run_command(*command) + Bundler.with_unbundled_env do + capture_subprocess_io { system(*command, exception: true) } + end + end +end