diff --git a/.github/workflows/deployment-checks.yml b/.github/workflows/deployment-checks.yml index 9ba80825f..e360af9f4 100644 --- a/.github/workflows/deployment-checks.yml +++ b/.github/workflows/deployment-checks.yml @@ -48,7 +48,14 @@ jobs: cp config/secrets.github.yml config/secrets.yml cp config/ingestion.example.yml config/ingestion.yml bundle exec rake db:setup - - run: bundle exec rake assets:precompile - name: Run asset compilation - - run: bundle exec whenever --update-crontab --set environment="$ENV" - name: Run whenever update + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: '20.x' + cache: 'yarn' + - name: Install JS dependencies + run: yarn install --frozen-lockfile --non-interactive + - name: Run asset compilation + run: bundle exec rake assets:precompile + - name: Run whenever update + run: bundle exec whenever --update-crontab --set environment="$ENV" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cee5cf256..a26626838 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -53,5 +53,12 @@ jobs: cp config/secrets.github.yml config/secrets.yml cp config/ingestion.example.yml config/ingestion.yml bundle exec rake db:test:prepare - - run: bundle exec rails test - name: Run tests + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: '20.x' + cache: 'yarn' + - name: Install JS dependencies + run: yarn install --frozen-lockfile --non-interactive + - name: Run tests + run: bundle exec rails test diff --git a/.gitignore b/.gitignore index 81f49743d..67cb83951 100644 --- a/.gitignore +++ b/.gitignore @@ -40,4 +40,5 @@ config/ontologies/*.cache tess.crontab -app-secrets* \ No newline at end of file +app-secrets* +node_modules/ diff --git a/Dockerfile b/Dockerfile index fbd087827..cff719442 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,9 +8,11 @@ WORKDIR /code # install dependencies RUN apt-get update \ - && apt-get install build-essential curl file git gnupg2 imagemagick libpq-dev libyaml-dev nodejs -y \ + && apt-get install build-essential curl file git gnupg2 imagemagick libpq-dev libyaml-dev nodejs npm -y \ && apt-get clean +# install yarn to manage JS dependencies +RUN npm install --global yarn@1.22.22 # install supercronic - a cron alternative ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.12/supercronic-linux-amd64 \ @@ -41,6 +43,12 @@ COPY Gemfile Gemfile.lock ./ # install gems RUN bundle check || bundle install +# copy package file +COPY package.json yarn.lock ./ + +# install js dependencies +RUN yarn install --frozen-lockfile --non-interactive + # copy code COPY . . diff --git a/Gemfile b/Gemfile index 70c29cd45..fd62d50fe 100644 --- a/Gemfile +++ b/Gemfile @@ -74,15 +74,6 @@ gem 'validate_url' gem 'whenever', require: false # Work around https://github.com/javan/whenever/issues/831 gem 'will_paginate' -source 'https://rails-assets.org' do - gem 'rails-assets-clipboard', '~> 1.5.12' - gem 'rails-assets-devbridge-autocomplete', '~> 1.4.9' - gem 'rails-assets-eonasdan-bootstrap-datetimepicker', '~> 4.17.42' - gem 'rails-assets-markdown-it', '~> 7.0.1' - gem 'rails-assets-moment', '~> 2.30.1' - gem 'rails-assets-select2', '~> 4.0.8' -end - group :development, :test do gem 'byebug' gem 'pry-byebug' diff --git a/Gemfile.lock b/Gemfile.lock index 793c350d3..768ed9d62 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,20 +6,6 @@ GIT tess_rdf_extractors (1.1.0) linkeddata (~> 3.2.0) -GEM - remote: https://rails-assets.org/ - specs: - rails-assets-clipboard (1.5.16) - rails-assets-devbridge-autocomplete (1.4.9) - rails-assets-jquery (>= 1.7) - rails-assets-eonasdan-bootstrap-datetimepicker (4.17.49) - rails-assets-jquery (>= 1.8.3) - rails-assets-moment (>= 2.10.5) - rails-assets-jquery (3.7.0) - rails-assets-markdown-it (7.0.1) - rails-assets-moment (2.30.1) - rails-assets-select2 (4.0.8) - GEM remote: https://rubygems.org/ specs: @@ -872,12 +858,6 @@ DEPENDENCIES pundit rack-cors rails (= 7.2.2.2) - rails-assets-clipboard (~> 1.5.12)! - rails-assets-devbridge-autocomplete (~> 1.4.9)! - rails-assets-eonasdan-bootstrap-datetimepicker (~> 4.17.42)! - rails-assets-markdown-it (~> 7.0.1)! - rails-assets-moment (~> 2.30.1)! - rails-assets-select2 (~> 4.0.8)! rails-controller-testing rails-i18n rails_admin diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 3cf22c352..90b513d49 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -26,8 +26,8 @@ //= require markdown-it //= require URI //= require moment -//= require eonasdan-bootstrap-datetimepicker -//= require devbridge-autocomplete +//= require bootstrap-datetimepicker +//= require jquery.autocomplete //= require clipboard //= require ardc_vocab_widget_v2 //= require select2 diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 083317b65..51dca1c07 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -47,7 +47,7 @@ // Vendor @import "cytoscape-panzoom"; @import "jquery.simplecolorpicker"; -@import "eonasdan-bootstrap-datetimepicker"; +@import "bootstrap-datetimepicker"; @import "ardc_vocab_widget_v2"; @import "jquery.qtip.min"; @import "select2"; diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index bd5bcd2b6..80180b6f2 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -3,8 +3,20 @@ # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = "1.0" -# Add additional assets to the asset load path. -# Rails.application.config.assets.paths << Emoji.images_path +# Add node_modules subdirectories to the Sprockets asset load path so that +# JS/CSS packages installed via yarn can be referenced with //= require and @import. +%w[ + clipboard/dist + devbridge-autocomplete/dist + eonasdan-bootstrap-datetimepicker/src/js + eonasdan-bootstrap-datetimepicker/build/css + markdown-it/dist + moment + select2/dist/js + select2/dist/css +].each do |path| + Rails.application.config.assets.paths << Rails.root.join("node_modules/#{path}") +end # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in the app/assets diff --git a/docs/install.md b/docs/install.md index ed448cf23..22d4cfcb0 100644 --- a/docs/install.md +++ b/docs/install.md @@ -16,11 +16,12 @@ TeSS requires the following system packages to be installed: - ImageMagick - A Java runtime - A JavaScript runtime +- npm (and yarn) - Redis To install these under an Ubuntu-like OS using apt: - sudo apt-get install git postgresql libpq-dev imagemagick nodejs redis-server openjdk-11-jdk + sudo apt-get install git postgresql libpq-dev imagemagick nodejs npm redis-server openjdk-11-jdk For Mac OS X: @@ -67,6 +68,18 @@ Once you have Ruby, RVM and bundler installed, from the root folder of the app d 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). +## JS + +TeSS uses yarn to manage JS dependencies. + +Install it using npm: + + npm install --global yarn@1.22.22 + +and install JS dependencies using (from the app's root directory): + + yarn install --frozen-lockfile + ## PostgreSQL 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). diff --git a/docs/production.md b/docs/production.md index f68b7855f..e95b1fc58 100644 --- a/docs/production.md +++ b/docs/production.md @@ -4,7 +4,7 @@ This page contains some extra notes about setting up TeSS for production on an U ## System Dependencies - sudo apt-get install git postgresql libpq-dev imagemagick nodejs openjdk-11-jdk apache2 gnupg2 + sudo apt-get install git postgresql libpq-dev imagemagick nodejs npm openjdk-11-jdk apache2 gnupg2 To install a recent version of Redis (6.2+), use the official Redis APT repo: @@ -184,6 +184,16 @@ _Note: Ensure you have started Solr before running this command!_ RAILS_ENV=production bundle exec rake db:setup +## Install yarn & install JS dependencies + +Install yarn globally via npm: + + npm install --global yarn@1.22.22 + +Install JS dependencies: + + yarn install --frozen-lockfile --non-interactive + ## Compile assets Assets - such as images, javascript and stylesheets, need to be precompiled - diff --git a/package.json b/package.json new file mode 100644 index 000000000..621ddf060 --- /dev/null +++ b/package.json @@ -0,0 +1,12 @@ +{ + "name": "tess", + "private": true, + "dependencies": { + "clipboard": "^1.5.16", + "devbridge-autocomplete": "^1.4.9", + "eonasdan-bootstrap-datetimepicker": "^4.17.49", + "markdown-it": "^7.0.1", + "moment": "^2.30.1", + "select2": "^4.0.8" + } +} diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 000000000..9324f9e79 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,121 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +argparse@^1.0.7: + version "1.0.10" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" + integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== + dependencies: + sprintf-js "~1.0.2" + +bootstrap@^3.3: + version "3.4.1" + resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-3.4.1.tgz#c3a347d419e289ad11f4033e3c4132b87c081d72" + integrity sha512-yN5oZVmRCwe5aKwzRj6736nSmKDX7pLYwsXiCj/EYmo16hODaBiT4En5btW/jhBF/seV+XMx3aYwukYC3A49DA== + +clipboard@^1.5.16: + version "1.7.1" + resolved "https://registry.yarnpkg.com/clipboard/-/clipboard-1.7.1.tgz#360d6d6946e99a7a1fef395e42ba92b5e9b5a16b" + integrity sha512-smkaRaIQsrnKN1F3wd1/vY9Q+DeR4L8ZCXKeHCFC2j8RZuSBbuImcLdnIO4GTxmzJxQuDGNKkyfpGoPW7Ua5bQ== + dependencies: + good-listener "^1.2.2" + select "^1.1.2" + tiny-emitter "^2.0.0" + +delegate@^3.1.2: + version "3.2.0" + resolved "https://registry.yarnpkg.com/delegate/-/delegate-3.2.0.tgz#b66b71c3158522e8ab5744f720d8ca0c2af59166" + integrity sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw== + +devbridge-autocomplete@^1.4.9: + version "1.5.0" + resolved "https://registry.yarnpkg.com/devbridge-autocomplete/-/devbridge-autocomplete-1.5.0.tgz#b630ef596f00ab511e2d41ae91788368e968ee01" + integrity sha512-yz6W76PyXS9DtuyYbQtVcpxtkI8pQ02EQwZeNWnqUJXmM5jSmsPFKmpFEBneImcHwYJrMf3+6m86Hj2MRPELGQ== + +entities@~1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.2.tgz#bdfa735299664dfafd34529ed4f8522a275fea56" + integrity sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w== + +eonasdan-bootstrap-datetimepicker@^4.17.49: + version "4.17.49" + resolved "https://registry.yarnpkg.com/eonasdan-bootstrap-datetimepicker/-/eonasdan-bootstrap-datetimepicker-4.17.49.tgz#5534ba581c1e7eb988dbf773e2fed8a7f48cc76a" + integrity sha512-7KZeDpkj+A6AtPR3XjX8gAnRPUkPSfW0OmMANG1dkUOPMtLSzbyoCjDIdEcfRtQPU5X0D9Gob7wWKn0h4QWy7A== + dependencies: + bootstrap "^3.3" + jquery "^3.5.1" + moment "^2.10" + moment-timezone "^0.4.0" + +good-listener@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/good-listener/-/good-listener-1.2.2.tgz#d53b30cdf9313dffb7dc9a0d477096aa6d145c50" + integrity sha512-goW1b+d9q/HIwbVYZzZ6SsTr4IgE+WA44A0GmPIQstuOrgsFcT7VEJ48nmr9GaRtNu0XTKacFLGnBPAM6Afouw== + dependencies: + delegate "^3.1.2" + +jquery@^3.5.1: + version "3.7.1" + resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.7.1.tgz#083ef98927c9a6a74d05a6af02806566d16274de" + integrity sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg== + +linkify-it@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-2.2.0.tgz#e3b54697e78bf915c70a38acd78fd09e0058b1cf" + integrity sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw== + dependencies: + uc.micro "^1.0.1" + +markdown-it@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-7.0.1.tgz#f12d8b88a93e64254348dfd183bd70bf60567a42" + integrity sha512-etdzRx/pMUtILytasHAo4+9xCPjdsNFvwBr+ye3edqNc128whm/dJ47pVc5ng584v7Ko35X8mMM9Rc5TicKXKg== + dependencies: + argparse "^1.0.7" + entities "~1.1.1" + linkify-it "^2.0.0" + mdurl "^1.0.1" + uc.micro "^1.0.1" + +mdurl@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e" + integrity sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g== + +moment-timezone@^0.4.0: + version "0.4.1" + resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.4.1.tgz#81f598c3ad5e22cdad796b67ecd8d88d0f5baa06" + integrity sha512-5cNPVUwaVJDCe9JM8m/qz17f9SkaI8rpnRUyDJi2K5HAd6EwhuQ3n5nLclZkNC/qJnomKgQH2TIu70Gy2dxFKA== + dependencies: + moment ">= 2.6.0" + +"moment@>= 2.6.0", moment@^2.10, moment@^2.30.1: + version "2.30.1" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.30.1.tgz#f8c91c07b7a786e30c59926df530b4eac96974ae" + integrity sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how== + +select2@^4.0.8: + version "4.0.13" + resolved "https://registry.yarnpkg.com/select2/-/select2-4.0.13.tgz#0dbe377df3f96167c4c1626033e924372d8ef44d" + integrity sha512-1JeB87s6oN/TDxQQYCvS5EFoQyvV6eYMZZ0AeA4tdFDYWN3BAGZ8npr17UBFddU0lgAt3H0yjX3X6/ekOj1yjw== + +select@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/select/-/select-1.1.2.tgz#0e7350acdec80b1108528786ec1d4418d11b396d" + integrity sha512-OwpTSOfy6xSs1+pwcNrv0RBMOzI39Lp3qQKUTPVVPRjCdNa5JH/oPRiqsesIskK8TVgmRiHwO4KXlV2Li9dANA== + +sprintf-js@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== + +tiny-emitter@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/tiny-emitter/-/tiny-emitter-2.1.0.tgz#1d1a56edfc51c43e863cbb5382a72330e3555423" + integrity sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q== + +uc.micro@^1.0.1: + version "1.0.6" + resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac" + integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==