Skip to content

Commit 14b27a6

Browse files
authored
Merge pull request #1254 from ElixirTeSS/copilot/change-js-css-dependency-installation
Replace rails-assets.org gems with yarn/npm packages
2 parents 651afe9 + b28ba81 commit 14b27a6

13 files changed

Lines changed: 206 additions & 44 deletions

File tree

.github/workflows/deployment-checks.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,14 @@ jobs:
4848
cp config/secrets.github.yml config/secrets.yml
4949
cp config/ingestion.example.yml config/ingestion.yml
5050
bundle exec rake db:setup
51-
- run: bundle exec rake assets:precompile
52-
name: Run asset compilation
53-
- run: bundle exec whenever --update-crontab --set environment="$ENV"
54-
name: Run whenever update
51+
- name: Set up Node
52+
uses: actions/setup-node@v4
53+
with:
54+
node-version: '20.x'
55+
cache: 'yarn'
56+
- name: Install JS dependencies
57+
run: yarn install --frozen-lockfile --non-interactive
58+
- name: Run asset compilation
59+
run: bundle exec rake assets:precompile
60+
- name: Run whenever update
61+
run: bundle exec whenever --update-crontab --set environment="$ENV"

.github/workflows/test.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,12 @@ jobs:
5353
cp config/secrets.github.yml config/secrets.yml
5454
cp config/ingestion.example.yml config/ingestion.yml
5555
bundle exec rake db:test:prepare
56-
- run: bundle exec rails test
57-
name: Run tests
56+
- name: Set up Node
57+
uses: actions/setup-node@v4
58+
with:
59+
node-version: '20.x'
60+
cache: 'yarn'
61+
- name: Install JS dependencies
62+
run: yarn install --frozen-lockfile --non-interactive
63+
- name: Run tests
64+
run: bundle exec rails test

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ config/ontologies/*.cache
4040

4141
tess.crontab
4242

43-
app-secrets*
43+
app-secrets*
44+
node_modules/

Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ WORKDIR /code
88

99
# install dependencies
1010
RUN apt-get update \
11-
&& apt-get install build-essential curl file git gnupg2 imagemagick libpq-dev libyaml-dev nodejs -y \
11+
&& apt-get install build-essential curl file git gnupg2 imagemagick libpq-dev libyaml-dev nodejs npm -y \
1212
&& apt-get clean
1313

14+
# install yarn to manage JS dependencies
15+
RUN npm install --global yarn@1.22.22
1416

1517
# install supercronic - a cron alternative
1618
ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.12/supercronic-linux-amd64 \
@@ -41,6 +43,12 @@ COPY Gemfile Gemfile.lock ./
4143
# install gems
4244
RUN bundle check || bundle install
4345

46+
# copy package file
47+
COPY package.json yarn.lock ./
48+
49+
# install js dependencies
50+
RUN yarn install --frozen-lockfile --non-interactive
51+
4452
# copy code
4553
COPY . .
4654

Gemfile

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,6 @@ gem 'validate_url'
7474
gem 'whenever', require: false # Work around https://github.com/javan/whenever/issues/831
7575
gem 'will_paginate'
7676

77-
source 'https://rails-assets.org' do
78-
gem 'rails-assets-clipboard', '~> 1.5.12'
79-
gem 'rails-assets-devbridge-autocomplete', '~> 1.4.9'
80-
gem 'rails-assets-eonasdan-bootstrap-datetimepicker', '~> 4.17.42'
81-
gem 'rails-assets-markdown-it', '~> 7.0.1'
82-
gem 'rails-assets-moment', '~> 2.30.1'
83-
gem 'rails-assets-select2', '~> 4.0.8'
84-
end
85-
8677
group :development, :test do
8778
gem 'byebug'
8879
gem 'pry-byebug'

Gemfile.lock

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,6 @@ GIT
66
tess_rdf_extractors (1.1.0)
77
linkeddata (~> 3.2.0)
88

9-
GEM
10-
remote: https://rails-assets.org/
11-
specs:
12-
rails-assets-clipboard (1.5.16)
13-
rails-assets-devbridge-autocomplete (1.4.9)
14-
rails-assets-jquery (>= 1.7)
15-
rails-assets-eonasdan-bootstrap-datetimepicker (4.17.49)
16-
rails-assets-jquery (>= 1.8.3)
17-
rails-assets-moment (>= 2.10.5)
18-
rails-assets-jquery (3.7.0)
19-
rails-assets-markdown-it (7.0.1)
20-
rails-assets-moment (2.30.1)
21-
rails-assets-select2 (4.0.8)
22-
239
GEM
2410
remote: https://rubygems.org/
2511
specs:
@@ -872,12 +858,6 @@ DEPENDENCIES
872858
pundit
873859
rack-cors
874860
rails (= 7.2.2.2)
875-
rails-assets-clipboard (~> 1.5.12)!
876-
rails-assets-devbridge-autocomplete (~> 1.4.9)!
877-
rails-assets-eonasdan-bootstrap-datetimepicker (~> 4.17.42)!
878-
rails-assets-markdown-it (~> 7.0.1)!
879-
rails-assets-moment (~> 2.30.1)!
880-
rails-assets-select2 (~> 4.0.8)!
881861
rails-controller-testing
882862
rails-i18n
883863
rails_admin

app/assets/javascripts/application.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
//= require markdown-it
2727
//= require URI
2828
//= require moment
29-
//= require eonasdan-bootstrap-datetimepicker
30-
//= require devbridge-autocomplete
29+
//= require bootstrap-datetimepicker
30+
//= require jquery.autocomplete
3131
//= require clipboard
3232
//= require ardc_vocab_widget_v2
3333
//= require select2

app/assets/stylesheets/application.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
// Vendor
4848
@import "cytoscape-panzoom";
4949
@import "jquery.simplecolorpicker";
50-
@import "eonasdan-bootstrap-datetimepicker";
50+
@import "bootstrap-datetimepicker";
5151
@import "ardc_vocab_widget_v2";
5252
@import "jquery.qtip.min";
5353
@import "select2";

config/initializers/assets.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,20 @@
33
# Version of your assets, change this if you want to expire all your assets.
44
Rails.application.config.assets.version = "1.0"
55

6-
# Add additional assets to the asset load path.
7-
# Rails.application.config.assets.paths << Emoji.images_path
6+
# Add node_modules subdirectories to the Sprockets asset load path so that
7+
# JS/CSS packages installed via yarn can be referenced with //= require and @import.
8+
%w[
9+
clipboard/dist
10+
devbridge-autocomplete/dist
11+
eonasdan-bootstrap-datetimepicker/src/js
12+
eonasdan-bootstrap-datetimepicker/build/css
13+
markdown-it/dist
14+
moment
15+
select2/dist/js
16+
select2/dist/css
17+
].each do |path|
18+
Rails.application.config.assets.paths << Rails.root.join("node_modules/#{path}")
19+
end
820

921
# Precompile additional assets.
1022
# application.js, application.css, and all non-JS/CSS in the app/assets

docs/install.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ TeSS requires the following system packages to be installed:
1616
- ImageMagick
1717
- A Java runtime
1818
- A JavaScript runtime
19+
- npm (and yarn)
1920
- Redis
2021

2122
To install these under an Ubuntu-like OS using apt:
2223

23-
sudo apt-get install git postgresql libpq-dev imagemagick nodejs redis-server openjdk-11-jdk
24+
sudo apt-get install git postgresql libpq-dev imagemagick nodejs npm redis-server openjdk-11-jdk
2425

2526
For Mac OS X:
2627

@@ -67,6 +68,18 @@ Once you have Ruby, RVM and bundler installed, from the root folder of the app d
6768

6869
This will install Rails, as well as any other gem that the TeSS app needs as specified in Gemfile (located in the root folder of the TeSS app).
6970

71+
## JS
72+
73+
TeSS uses yarn to manage JS dependencies.
74+
75+
Install it using npm:
76+
77+
npm install --global yarn@1.22.22
78+
79+
and install JS dependencies using (from the app's root directory):
80+
81+
yarn install --frozen-lockfile
82+
7083
## PostgreSQL
7184

7285
Install postgres and add a postgres user called 'tess_user' for the use by the TeSS app (you can name the user any way you like).

0 commit comments

Comments
 (0)