Skip to content

Commit

Permalink
fix SCSS/JS assets, add compile assets task
Browse files Browse the repository at this point in the history
* fix scss: use scss imports, not css ones that cannot be resolved by the browser
* add missing jQuery import
* drop yarn - not needed
* add rake task to compile assets, corresponding post install message
  • Loading branch information
langalex committed Jan 23, 2025
1 parent 5c0ee88 commit 33b49e4
Show file tree
Hide file tree
Showing 10 changed files with 430 additions and 404 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/coveralls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,23 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: yarn
- run: yarn install --frozen-lockfile
cache: npm
- run: npm ci

- name: Install Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true

- name: Update surfer gem
run: bundle update comfortable_media_surfer

- name: Compile assets
run: bin/bundle exec rails comfy:compile_assets

- name: Run tests, report coverage
run: |
bin/bundle install --retry 3 --quiet
bin/bundle exec rails db:drop
bin/bundle exec rails db:create
bin/bundle exec rails db:migrate
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/rubyonrails.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,23 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: yarn
- run: yarn install --frozen-lockfile
cache: npm
- run: npm ci

- name: Install Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true

- name: Update surfer gem
run: bundle update comfortable_media_surfer

- name: Compile assets
run: bin/bundle exec rails comfy:compile_assets

- name: Run tests
run: |
bin/bundle install --retry 3 --quiet
bin/bundle exec rails db:drop
bin/bundle exec rails db:create
bin/bundle exec rails db:migrate
Expand Down
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ Please follow the recommendations outlined at [keepachangelog.com](https://keepa
For all changes prior to the inception of this project, see the [Release History](https://github.com/comfy/comfortable-mexican-sofa/releases) of ComfortableMexicanSofa.

## Versions

## [Unreleased]

## [v3.1.0] - 2024-12-31

### Added

- Added compatibility and support for Rails 8
- Added compatibility and support for propshaft (sprockets is still supported) - installing the gem now requires NodeJS to be installed. In addition, the `comfy:compile_assets` task needs to be run after installing the gem.

### Removed

Expand All @@ -28,7 +30,7 @@ For all changes prior to the inception of this project, see the [Release History

## [v3.0.0] - 2024-11-30

First release of `comfortable_media_surfer`. This new gem is a revival of [ComfortableMexicanSofa](https://github.com/comfy/comfortable-mexican-sofa) which had been dormant for nearly 5 years.
First release of `comfortable_media_surfer`. This new gem is a revival of [ComfortableMexicanSofa](https://github.com/comfy/comfortable-mexican-sofa) which had been dormant for nearly 5 years.

### Fixed

Expand All @@ -37,7 +39,7 @@ First release of `comfortable_media_surfer`. This new gem is a revival of [Comf

### Added

- Rails 7 compatibility, including many config and code changes. See the [PR](https://github.com/shakacode/comfortable-media-surfer/pull/1/files) for full details
- Rails 7 compatibility, including many config and code changes. See the [PR](https://github.com/shakacode/comfortable-media-surfer/pull/1/files) for full details
- Added github actions workflows for CI build and test coverage
- Added CMS tags for navigation: children, siblings, breadcrumbs, with tests
- Added CMS tag for embedded audio, with tests
Expand All @@ -55,5 +57,3 @@ First release of `comfortable_media_surfer`. This new gem is a revival of [Comf
[Unreleased]: https://github.com/shakacode/comfortable-media-surfer/compare/v3.1.0...master
[v3.1.0]: https://github.com/shakacode/comfortable-media-surfer/compare/v3.0.0...v3.1.0
[v3.0.0]: https://github.com/shakacode/comfortable-media-surfer/compare/v2.0.19...v3.0.0


2 changes: 2 additions & 0 deletions app/assets/javascripts/comfy/vendor/redactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
fixes and tweaks annotated with "COMFY FIX"
*/

import jQuery from 'jquery';

(function($)
{

Expand Down
4 changes: 2 additions & 2 deletions app/assets/stylesheets/comfy/admin/cms/application.sass
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@import "comfy/vendor/bootstrap/bootstrap"

@import "node_modules/codemirror/lib/codemirror.css"
@import "codemirror/lib/codemirror"
@import "comfy/vendor/fontawesome"
@import "comfy/vendor/redactor"
@import "node_modules/flatpickr/dist/flatpickr.min.css"
@import "flatpickr/dist/flatpickr.min"

@import "comfy/admin/cms/codemirror_overrides"
@import "comfy/admin/cms/redactor_overrides"
Expand Down
16 changes: 3 additions & 13 deletions comfortable_media_surfer.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,6 @@
$LOAD_PATH.unshift File.expand_path('lib', __dir__)
require 'comfortable_media_surfer/version'

module Assets
def self.compiled_assets
puts 'Compiling assets...'
if system('yarn build && yarn build:css')
Dir.glob(['app/assets/builds/**/*.js', 'app/assets/builds/**/*.css'])
else
puts 'Error: Failed to compile assets'
exit(-1)
end
end
end

Gem::Specification.new do |spec|
spec.name = 'comfortable_media_surfer'
spec.version = ComfortableMediaSurfer::VERSION
Expand All @@ -25,9 +13,11 @@ Gem::Specification.new do |spec|
spec.description = 'ComfortableMediaSurfer is a powerful Rails 7.0+ CMS Engine'
spec.license = 'MIT'

spec.post_install_message = 'Please run rake comfy:compile_assets to compile assets.'

spec.files = `git ls-files -z`.split("\x0").reject do |f|
f.match(%r{^(test|doc)/})
end + Assets.compiled_assets
end

spec.required_ruby_version = '>= 3.2.0'
spec.metadata['rubygems_mfa_required'] = 'true'
Expand Down
19 changes: 19 additions & 0 deletions lib/tasks/cms_assets.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

namespace :comfy do
desc 'Compile SCSS and JS assets for propshaft.'
task :compile_assets do
puts 'Compiling assets...'
dir = File.expand_path("#{__dir__}/..")
Dir.chdir(dir) do
unless system('npm install')
puts 'Error: Failed to install npm packages.'
exit(-1)
end
unless system('npm run build && npm run build:css')
puts 'Error: Failed to compile assets'
exit(-1)
end
end
end
end
Loading

0 comments on commit 33b49e4

Please sign in to comment.