From 9a14efb1a2590bed65c84a7b9c737480399cefb1 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Mon, 3 Jul 2023 12:46:36 +0700 Subject: [PATCH 01/33] [#383] Upgrade Rails version --- .github/workflows/test_generated_app.yml | 2 +- .github/workflows/test_production_build.yml | 2 +- Gemfile.tt | 2 +- README.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test_generated_app.yml b/.github/workflows/test_generated_app.yml index 7092b8a34..bbee7add9 100644 --- a/.github/workflows/test_generated_app.yml +++ b/.github/workflows/test_generated_app.yml @@ -11,7 +11,7 @@ env: DOCKER_REGISTRY_TOKEN: ${{ secrets.DOCKER_REGISTRY_TOKEN }} RUBY_VERSION: 3.0.1 NODE_VERSION: 16 - RAILS_VERSION: 7.0.1 + RAILS_VERSION: 7.0.6 concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/test_production_build.yml b/.github/workflows/test_production_build.yml index 92628552f..48790aac8 100644 --- a/.github/workflows/test_production_build.yml +++ b/.github/workflows/test_production_build.yml @@ -8,7 +8,7 @@ env: DOCKER_REGISTRY_HOST: ${{ secrets.DOCKER_REGISTRY_HOST }} RUBY_VERSION: 3.0.1 NODE_VERSION: 16 - RAILS_VERSION: 7.0.1 + RAILS_VERSION: 7.0.6 concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/Gemfile.tt b/Gemfile.tt index 8d603fe61..8e8ec02e9 100644 --- a/Gemfile.tt +++ b/Gemfile.tt @@ -2,7 +2,7 @@ source 'https://rubygems.org' ruby '<%= RUBY_VERSION %>' # Backend -gem 'rails', '7.0.1' # Latest stable +gem 'rails', '7.0.6' # Latest stable gem 'pg' # Use Postgresql as database gem 'puma' # Use Puma as the app server gem 'mini_magick' # A ruby wrapper for ImageMagick or GraphicsMagick command line diff --git a/README.md b/README.md index 26252bb23..4bb5e9fa4 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ with building complex applications over the years. ### Requirements - Install ruby and set your local ruby version to `3.0.1` -- Install rails `7.0.1` +- Install rails `7.0.6` - Install node `16.13.2` (For creating web application) > 📝 If running on Apple M1, to build docker image, please make sure to set platform to AMD64 by `export DOCKER_DEFAULT_PLATFORM=linux/amd64` From 46a091c7154f85dbbd4fd1e2ec2667e356314094 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Mon, 3 Jul 2023 13:13:41 +0700 Subject: [PATCH 02/33] [#383] Upgrade Ruby version --- .github/workflows/test_generated_app.yml | 2 +- .github/workflows/test_production_build.yml | 2 +- .github/workflows/test_template.yml | 2 +- .tool-versions | 2 +- README.md | 2 +- template.rb | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test_generated_app.yml b/.github/workflows/test_generated_app.yml index bbee7add9..12fd16010 100644 --- a/.github/workflows/test_generated_app.yml +++ b/.github/workflows/test_generated_app.yml @@ -9,7 +9,7 @@ env: DOCKER_REGISTRY_HOST: ${{ secrets.DOCKER_REGISTRY_HOST }} DOCKER_REGISTRY_USERNAME: ${{ github.repository_owner }} DOCKER_REGISTRY_TOKEN: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - RUBY_VERSION: 3.0.1 + RUBY_VERSION: 3.2.2 NODE_VERSION: 16 RAILS_VERSION: 7.0.6 diff --git a/.github/workflows/test_production_build.yml b/.github/workflows/test_production_build.yml index 48790aac8..01d4570b7 100644 --- a/.github/workflows/test_production_build.yml +++ b/.github/workflows/test_production_build.yml @@ -6,7 +6,7 @@ env: APP_NAME: rails_templates DOCKER_IMAGE: ${{ github.repository }} DOCKER_REGISTRY_HOST: ${{ secrets.DOCKER_REGISTRY_HOST }} - RUBY_VERSION: 3.0.1 + RUBY_VERSION: 3.2.2 NODE_VERSION: 16 RAILS_VERSION: 7.0.6 diff --git a/.github/workflows/test_template.yml b/.github/workflows/test_template.yml index e54f01bcb..37ceb327f 100644 --- a/.github/workflows/test_template.yml +++ b/.github/workflows/test_template.yml @@ -3,7 +3,7 @@ name: Test the codebase of the template on: push env: - RUBY_VERSION: 3.0.1 + RUBY_VERSION: 3.2.2 concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.tool-versions b/.tool-versions index 7fcd1b3fa..97b2cd183 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ nodejs 16.13.2 -ruby 3.0.1 +ruby 3.2.2 diff --git a/README.md b/README.md index 4bb5e9fa4..54a95428c 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ with building complex applications over the years. ### Requirements -- Install ruby and set your local ruby version to `3.0.1` +- Install ruby and set your local ruby version to `3.2.2` - Install rails `7.0.6` - Install node `16.13.2` (For creating web application) diff --git a/template.rb b/template.rb index 73550b180..7c0a67e45 100644 --- a/template.rb +++ b/template.rb @@ -8,7 +8,7 @@ APP_NAME_HUMANIZED = app_name.split(/[-_]/).map(&:capitalize).join(' ').gsub(/ Web$/, '') DOCKER_REGISTRY_HOST = 'docker.io' DOCKER_IMAGE = "nimblehq/#{APP_NAME}".freeze -RUBY_VERSION = '3.0.1' +RUBY_VERSION = '3.2.2' POSTGRES_VERSION = '15.2' REDIS_VERSION = '6.2.7' # Variants From 3e26faa708f5612db62d5f669c88cdb55381df64 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Mon, 3 Jul 2023 13:17:56 +0700 Subject: [PATCH 03/33] [#383] Use figjam --- Gemfile.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.tt b/Gemfile.tt index 8e8ec02e9..bc65a6e03 100644 --- a/Gemfile.tt +++ b/Gemfile.tt @@ -41,7 +41,7 @@ group :development, :test do # gem 'debug', platforms: %i[ mri mingw x64_mingw ] # Official debug # Utilities - gem 'figaro' # Simple Rails app configuration + gem 'figjam' # ENV configuration for ruby using yaml files gem 'listen' # Listens to file modifications gem 'letter_opener' # Preview mail in the browser instead of sending gem 'ffaker' # A library for generating fake data such as names, addresses, and phone numbers From d6a2ba39861c77a011c5f05035bef2ba1aaf1c64 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Mon, 3 Jul 2023 13:24:44 +0700 Subject: [PATCH 04/33] [#383] Update the excon and other package to fix the Docker::Container `unix://` connections --- .template/Gemfile.lock | 66 +++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/.template/Gemfile.lock b/.template/Gemfile.lock index 0b4602541..6b2e96cbe 100644 --- a/.template/Gemfile.lock +++ b/.template/Gemfile.lock @@ -2,64 +2,70 @@ GEM remote: https://rubygems.org/ specs: ast (2.4.2) - diff-lcs (1.4.4) + diff-lcs (1.5.0) docker-api (2.2.0) excon (>= 0.47.0) multi_json - excon (0.90.0) + excon (0.100.0) + json (2.6.3) + language_server-protocol (3.17.0.3) multi_json (1.15.0) - net-scp (3.0.0) - net-ssh (>= 2.6.5, < 7.0.0) - net-ssh (6.1.0) + net-scp (4.0.0) + net-ssh (>= 2.6.5, < 8.0.0) + net-ssh (7.1.0) net-telnet (0.1.1) - parallel (1.21.0) - parser (3.1.0.0) + parallel (1.23.0) + parser (3.2.2.3) ast (~> 2.4.1) + racc + racc (1.7.1) rainbow (3.1.1) - regexp_parser (2.2.0) + regexp_parser (2.8.1) rexml (3.2.5) - rspec (3.9.0) - rspec-core (~> 3.9.0) - rspec-expectations (~> 3.9.0) - rspec-mocks (~> 3.9.0) - rspec-core (3.9.2) - rspec-support (~> 3.9.3) - rspec-expectations (3.9.2) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-core (3.12.2) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.3) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) + rspec-support (~> 3.12.0) rspec-its (1.3.0) rspec-core (>= 3.0.0) rspec-expectations (>= 3.0.0) - rspec-mocks (3.9.1) + rspec-mocks (3.12.5) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-support (3.9.3) + rspec-support (~> 3.12.0) + rspec-support (3.12.1) rspec-wait (0.0.9) rspec (>= 3, < 4) - rubocop (1.25.0) + rubocop (1.54.0) + json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.1.0.0) + parser (>= 3.2.2.3) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.15.1, < 2.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.15.1) - parser (>= 3.0.1.1) - ruby-progressbar (1.11.0) - serverspec (2.41.5) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.29.0) + parser (>= 3.2.1.0) + ruby-progressbar (1.13.0) + serverspec (2.42.2) multi_json rspec (~> 3.0) rspec-its specinfra (~> 2.72) sfl (2.3) - specinfra (2.82.18) + specinfra (2.86.0) net-scp net-ssh (>= 2.7) net-telnet (= 0.1.1) sfl - unicode-display_width (2.1.0) + unicode-display_width (2.4.2) PLATFORMS ruby From 3b2c3d6de51cd2d5185ff2e6b7832e2d17d85547 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Mon, 3 Jul 2023 13:28:06 +0700 Subject: [PATCH 05/33] [#383] Fix rubocop --- .template/variants/web/package.json.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.template/variants/web/package.json.rb b/.template/variants/web/package.json.rb index 0b1a4a7ce..34b2e414a 100644 --- a/.template/variants/web/package.json.rb +++ b/.template/variants/web/package.json.rb @@ -52,7 +52,7 @@ run %(npm set-script build "node app/javascript/build.js") run %( npm set-script build:css-production \ - "sass #{source_stylesheet} #{bundled_stylesheet} #{(production_bundled_stylesheet_options).join(' ')}" + "sass #{source_stylesheet} #{bundled_stylesheet} #{production_bundled_stylesheet_options.join(' ')}" ) run %( npm set-script build:css \ From c7e95b6c6996c5996e813e377aa255ea9c7c4946 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Mon, 3 Jul 2023 13:51:20 +0700 Subject: [PATCH 06/33] [#383] Pin the deb.nodesource.com instead of deb.debian.org for the nodejs --- .template/addons/docker/Dockerfile.tt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.template/addons/docker/Dockerfile.tt b/.template/addons/docker/Dockerfile.tt index 22bb1f9e4..cee943e99 100644 --- a/.template/addons/docker/Dockerfile.tt +++ b/.template/addons/docker/Dockerfile.tt @@ -38,7 +38,8 @@ RUN apt-get update -qq && \ ADD https://dl.yarnpkg.com/debian/pubkey.gpg /tmp/yarn-pubkey.gpg RUN apt-key add /tmp/yarn-pubkey.gpg && rm /tmp/yarn-pubkey.gpg && \ echo "deb http://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list && \ - curl -sL https://deb.nodesource.com/setup_"$NODE_SOURCE_VERSION".x | bash - && \ + echo 'Package: nodejs\nPin: origin deb.nodesource.com\nPin-Priority: 600' > /etc/apt/preferences.d/nodesource && \ + curl -fsSL https://deb.nodesource.com/setup_"$NODE_SOURCE_VERSION".x | bash - && \ apt-get update -qq && \ apt-get install -y --no-install-recommends nodejs yarn && \ apt-get clean && \ From ce00e6ea8c41413df546be1c2dc1c2673b5ea7c5 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Mon, 3 Jul 2023 13:59:44 +0700 Subject: [PATCH 07/33] [#383] YAML load with aliases: true --- .template/addons/phrase/spec/codebase/codebase_spec.rb | 2 +- bin/docker-assets-precompile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.template/addons/phrase/spec/codebase/codebase_spec.rb b/.template/addons/phrase/spec/codebase/codebase_spec.rb index 64378d71b..251349a85 100644 --- a/.template/addons/phrase/spec/codebase/codebase_spec.rb +++ b/.template/addons/phrase/spec/codebase/codebase_spec.rb @@ -16,7 +16,7 @@ # replace en with root as `en` is not a tag locale_tags[locale_tags.index('en')] = 'root' - phrase_pull_tags = YAML.load_file(Rails.root.join('.phrase.yml')) + phrase_pull_tags = YAML.load_file(Rails.root.join('.phrase.yml'), aliases: true) .dig('phrase', 'pull', 'targets') .map { |target| target.dig('params', 'tags') } .sort diff --git a/bin/docker-assets-precompile b/bin/docker-assets-precompile index a5b95c279..30e844dad 100755 --- a/bin/docker-assets-precompile +++ b/bin/docker-assets-precompile @@ -15,7 +15,7 @@ require 'yaml' rails_env = ENV.fetch('RAILS_ENV', 'production') if rails_env == 'production' - docker_build_envs = YAML.load_file('config/application.yml')['docker_build'] + docker_build_envs = YAML.load_file('config/application.yml', aliases: true)['docker_build'] docker_build_envs.each { |name, value| ENV[name] = value } ENV['DATABASE_URL'] = 'postgres://postgres:postgres@postgres:5432/postgres' From 6592c3be15a22dd36993dd7f9ef155c12e05a9d4 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Mon, 3 Jul 2023 14:17:38 +0700 Subject: [PATCH 08/33] [#383] Upgrade Nodejs to 16.20.1 --- .tool-versions | 2 +- README.md | 2 +- template.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.tool-versions b/.tool-versions index 97b2cd183..429e999cc 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -nodejs 16.13.2 +nodejs 16.20.1 ruby 3.2.2 diff --git a/README.md b/README.md index 54a95428c..add4e1f1b 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ with building complex applications over the years. - Install ruby and set your local ruby version to `3.2.2` - Install rails `7.0.6` -- Install node `16.13.2` (For creating web application) +- Install node `16.20.1` (For creating web application) > 📝 If running on Apple M1, to build docker image, please make sure to set platform to AMD64 by `export DOCKER_DEFAULT_PLATFORM=linux/amd64` diff --git a/template.rb b/template.rb index 7c0a67e45..658521cdd 100644 --- a/template.rb +++ b/template.rb @@ -21,7 +21,7 @@ }.freeze if WEB_VARIANT - NODE_VERSION = '16.13.2' + NODE_VERSION = '16.20.1' NODE_SOURCE_VERSION = '16' # Used in Dockerfile https://github.com/nodesource/distributions end From 5f7703362c5fe759a96fc1b74a3c4e9220b3a007 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Mon, 3 Jul 2023 14:22:24 +0700 Subject: [PATCH 09/33] [#383] Upgrade Node and Ruby dependencies --- .template/addons/bootstrap/package.json.rb | 4 +-- .../variants/web/app/javascript/global.js | 2 +- .template/variants/web/package.json.rb | 36 ++++++++++--------- Gemfile.tt | 6 ++-- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/.template/addons/bootstrap/package.json.rb b/.template/addons/bootstrap/package.json.rb index d2a0e8d6b..585bc94df 100644 --- a/.template/addons/bootstrap/package.json.rb +++ b/.template/addons/bootstrap/package.json.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true -run 'yarn add bootstrap@5.2.3' -run 'yarn add @popperjs/core@2.11.2' +run 'yarn add bootstrap@5.3.0' +run 'yarn add @popperjs/core@2.11.8' diff --git a/.template/variants/web/app/javascript/global.js b/.template/variants/web/app/javascript/global.js index 994e2cdcf..b7cf488aa 100644 --- a/.template/variants/web/app/javascript/global.js +++ b/.template/variants/web/app/javascript/global.js @@ -1,3 +1,3 @@ -import I18n from 'i18n-js'; +import { I18n } from 'i18n-js'; export { I18n }; diff --git a/.template/variants/web/package.json.rb b/.template/variants/web/package.json.rb index 34b2e414a..121f9d372 100644 --- a/.template/variants/web/package.json.rb +++ b/.template/variants/web/package.json.rb @@ -23,21 +23,22 @@ end # Install dependencies -run 'yarn add i18n-js@3.8.0' +run 'yarn add i18n-js@4.2.3' run 'yarn add sass' run 'yarn add esbuild' run 'yarn add postcss postcss-cli autoprefixer' -run 'yarn add --dev @nimblehq/eslint-config-nimble@2.2.1' +run 'yarn add --dev @nimblehq/eslint-config-nimble@2.6.0' run 'yarn add --dev stylelint' -run 'yarn add --dev @nimblehq/stylelint-config-nimble' +run 'yarn add --dev @nimblehq/stylelint-config-nimble@1.0.2' + # Setup scripts -run 'npm set-script eslint "eslint . --color"' -run 'npm set-script eslint:fix "eslint . --color --fix"' -run 'npm set-script stylelint "stylelint **/*.scss --color"' -run 'npm set-script stylelint:fix "stylelint **/*.scss --color --fix"' -run 'npm set-script codebase "yarn eslint && yarn stylelint"' -run 'npm set-script codebase:fix "yarn eslint:fix && yarn stylelint:fix"' +run 'npm pkg set scripts.eslint="eslint . --color"' +run 'npm pkg set scripts.eslint:fix="eslint . --color --fix"' +run 'npm pkg set scripts.stylelint="stylelint **/*.scss --color"' +run 'npm pkg set scripts.stylelint:fix="stylelint **/*.scss --color --fix"' +run 'npm pkg set scripts.codebase="yarn eslint && yarn stylelint"' +run 'npm pkg set scripts.codebase:fix="yarn eslint:fix && yarn stylelint:fix"' source_stylesheet = 'app/assets/stylesheets/application.scss' bundled_stylesheet = 'app/assets/builds/application.css' @@ -49,17 +50,18 @@ '--style=compressed' ] -run %(npm set-script build "node app/javascript/build.js") +run %(npm pkg set scripts.build="node app/javascript/build.js") run %( - npm set-script build:css-production \ - "sass #{source_stylesheet} #{bundled_stylesheet} #{production_bundled_stylesheet_options.join(' ')}" + npm pkg set scripts.build:css-production="sass\ + #{source_stylesheet} #{bundled_stylesheet} #{production_bundled_stylesheet_options.join(' ')}" ) run %( - npm set-script build:css \ - "sass #{source_stylesheet} #{bundled_stylesheet} #{bundled_stylesheet_base_options.join(' ')}" + npm pkg set scripts.build:css="sass\ + #{source_stylesheet} #{bundled_stylesheet} #{bundled_stylesheet_base_options.join(' ')}" ) -run %(npm set-script postcss "postcss public/assets/*.css --dir public/assets --config ./") +run %(npm pkg set scripts.postcss="postcss\ + public/assets/*.css --dir public/assets --config ./") run %( - npm set-script build:postcss \ - "postcss app/assets/builds/*.css --dir app/assets/builds --config ./", + npm pkg set scripts.build:postcss="postcss\ + app/assets/builds/*.css --dir app/assets/builds --config ./", ) diff --git a/Gemfile.tt b/Gemfile.tt index bc65a6e03..4208722cb 100644 --- a/Gemfile.tt +++ b/Gemfile.tt @@ -21,7 +21,7 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] # Windows doe gem 'pundit' # Minimal authorization through OO design and pure Ruby classes # Translations -# gem 'rails-i18n', '~> 6.0.0' # Translations for Rails +# gem 'rails-i18n', '~> 7.0' # Translations for Rails group :development do gem 'foreman' # Manage Procfile-based applications @@ -31,7 +31,7 @@ group :development do gem 'roadie-rails' # Mailers gem 'spring' # Spring speeds up development by keeping your application running in the background. gem 'spring-commands-rspec' # This gem implements the rspec command for Spring. - gem 'spring-watcher-listen', '2.0.1' # Makes Spring watch the filesystem for changes using Listen + gem 'spring-watcher-listen', '2.1.0' # Makes Spring watch the filesystem for changes using Listen end group :development, :test do @@ -53,7 +53,7 @@ group :development, :test do # Code Analysis gem 'bullet' # help to kill N+1 queries and unused eager loading gem 'brakeman', require: false # A static analysis security vulnerability scanner for Ruby on Rails applications - gem 'parser', '3.0.1.1' # Use correct parser version to avoid parser warnings + gem 'parser', '3.2.2.3' # Use correct parser version to avoid parser warnings gem 'rubocop', require: false # A Ruby static code analyzer and formatter, based on the community Ruby style guide. gem 'rubocop-rails', require: false # A RuboCop extension focused on enforcing Rails best practices and coding conventions. gem 'rubocop-rspec', require: false # Code style checking for RSpec files From 442021a0b52755ea2d85a23da3e662411dfed5d5 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Mon, 3 Jul 2023 14:27:06 +0700 Subject: [PATCH 10/33] [#383] Correct the version --- .template/variants/web/package.json.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.template/variants/web/package.json.rb b/.template/variants/web/package.json.rb index 121f9d372..706d5232e 100644 --- a/.template/variants/web/package.json.rb +++ b/.template/variants/web/package.json.rb @@ -28,7 +28,7 @@ run 'yarn add esbuild' run 'yarn add postcss postcss-cli autoprefixer' -run 'yarn add --dev @nimblehq/eslint-config-nimble@2.6.0' +run 'yarn add --dev @nimblehq/eslint-config-nimble@2.4.0' run 'yarn add --dev stylelint' run 'yarn add --dev @nimblehq/stylelint-config-nimble@1.0.2' From 9574f8010120dc35ad50206c286664ac6344a2aa Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Mon, 3 Jul 2023 14:34:13 +0700 Subject: [PATCH 11/33] [#383] Revert to the working version --- .template/variants/web/package.json.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.template/variants/web/package.json.rb b/.template/variants/web/package.json.rb index 706d5232e..1fd0d92ee 100644 --- a/.template/variants/web/package.json.rb +++ b/.template/variants/web/package.json.rb @@ -28,7 +28,7 @@ run 'yarn add esbuild' run 'yarn add postcss postcss-cli autoprefixer' -run 'yarn add --dev @nimblehq/eslint-config-nimble@2.4.0' +run 'yarn add --dev @nimblehq/eslint-config-nimble@2.2.1' run 'yarn add --dev stylelint' run 'yarn add --dev @nimblehq/stylelint-config-nimble@1.0.2' From 6b2e6d7f94b12cbd348a91d43b397a0b2b75138d Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Mon, 3 Jul 2023 14:46:47 +0700 Subject: [PATCH 12/33] [#383] Fix rubocop --- .template/addons/phrase/spec/codebase/codebase_spec.rb | 2 +- spec/codebase/codebase_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.template/addons/phrase/spec/codebase/codebase_spec.rb b/.template/addons/phrase/spec/codebase/codebase_spec.rb index 251349a85..e80270255 100644 --- a/.template/addons/phrase/spec/codebase/codebase_spec.rb +++ b/.template/addons/phrase/spec/codebase/codebase_spec.rb @@ -5,7 +5,7 @@ # rubocop:disable RSpec/ExampleLength it 'does not offend Phrase Pull configuration' do - locale_tags = Dir[File.expand_path(Rails.root.join('config', 'locales', '*.yml'))] + locale_tags = Dir[Rails.root.join('config', 'locales', '*.yml').expand_path] .map { |path| path.split('/').last } # ['campaign.en.yml', 'article.en.yml', 'campaign.th.yml', 'en.yml'] .map { |path| path.split('.').first } diff --git a/spec/codebase/codebase_spec.rb b/spec/codebase/codebase_spec.rb index fc4578184..62b745b73 100644 --- a/spec/codebase/codebase_spec.rb +++ b/spec/codebase/codebase_spec.rb @@ -16,7 +16,7 @@ end it 'does not offend engine prefix name' do - engine_paths = Dir[File.expand_path(Rails.root.join('engines', '*'))] + engine_paths = Dir[Rails.root.join('engines', '*').expand_path] .select { |f| File.directory? f } .map { |path| path.split('/').last } invalid_engine_paths = engine_paths.reject { |path| path.start_with?('APP_NAME_HERE_') } From d7ea4752793e7f87e1c9c288f4206428af1c8c72 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Mon, 3 Jul 2023 14:59:16 +0700 Subject: [PATCH 13/33] [#383] Add eslint and revert bootstrap --- .template/addons/bootstrap/package.json.rb | 2 +- .template/variants/web/package.json.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.template/addons/bootstrap/package.json.rb b/.template/addons/bootstrap/package.json.rb index 585bc94df..3e3978375 100644 --- a/.template/addons/bootstrap/package.json.rb +++ b/.template/addons/bootstrap/package.json.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true -run 'yarn add bootstrap@5.3.0' +run 'yarn add bootstrap@5.2.3' run 'yarn add @popperjs/core@2.11.8' diff --git a/.template/variants/web/package.json.rb b/.template/variants/web/package.json.rb index 1fd0d92ee..b1d54112e 100644 --- a/.template/variants/web/package.json.rb +++ b/.template/variants/web/package.json.rb @@ -28,8 +28,9 @@ run 'yarn add esbuild' run 'yarn add postcss postcss-cli autoprefixer' -run 'yarn add --dev @nimblehq/eslint-config-nimble@2.2.1' +run 'yarn add --dev eslint' run 'yarn add --dev stylelint' +run 'yarn add --dev @nimblehq/eslint-config-nimble@2.2.1' run 'yarn add --dev @nimblehq/stylelint-config-nimble@1.0.2' # Setup scripts From a085a9fa2b7d4eb977dda1979a7592f79d59dce1 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Mon, 3 Jul 2023 14:48:07 +0700 Subject: [PATCH 14/33] [#416] Remove sassc --- Gemfile.tt | 1 - 1 file changed, 1 deletion(-) diff --git a/Gemfile.tt b/Gemfile.tt index 4208722cb..23bfeb00b 100644 --- a/Gemfile.tt +++ b/Gemfile.tt @@ -9,7 +9,6 @@ gem 'mini_magick' # A ruby wrapper for ImageMagick or GraphicsMagick command lin gem 'pagy' # A pagination gem that is very light and fast gem 'discard' # Soft deletes for ActiveRecord gem 'sidekiq' # background processing for Ruby -gem 'sassc' # bootsnap dependency gem 'bootsnap', require: false # Reduces boot times through caching; required in config/boot.rb gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] # Windows does not include zoneinfo files, so bundle the tzinfo-data gem # gem 'jbuilder' # Build JSON APIs with ease From b3635dbe5aafed5ce076831bbd0361fa5ec7b7e4 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Mon, 3 Jul 2023 15:08:03 +0700 Subject: [PATCH 15/33] [#383] Add bootstrap 5.3.0 --- .template/addons/bootstrap/package.json.rb | 2 +- .template/addons/bootstrap/stylesheets/vendor/_bootstrap.scss | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.template/addons/bootstrap/package.json.rb b/.template/addons/bootstrap/package.json.rb index 3e3978375..585bc94df 100644 --- a/.template/addons/bootstrap/package.json.rb +++ b/.template/addons/bootstrap/package.json.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true -run 'yarn add bootstrap@5.2.3' +run 'yarn add bootstrap@5.3.0' run 'yarn add @popperjs/core@2.11.8' diff --git a/.template/addons/bootstrap/stylesheets/vendor/_bootstrap.scss b/.template/addons/bootstrap/stylesheets/vendor/_bootstrap.scss index dababadc4..89072d36c 100644 --- a/.template/addons/bootstrap/stylesheets/vendor/_bootstrap.scss +++ b/.template/addons/bootstrap/stylesheets/vendor/_bootstrap.scss @@ -6,6 +6,7 @@ // Configuration @import 'bootstrap/scss/functions'; @import 'bootstrap/scss/variables'; +@import 'bootstrap/scss/variables-dark'; @import 'bootstrap/scss/maps'; // @import 'sass_maps'; // Optional Sass map overrides here (See: https://getbootstrap.com/docs/5.2/migration/#new-_mapsscss) // e.g., $theme-colors: map-merge($theme-colors, $custom-theme-colors); From c1b608626f5146e7b5b3457f72f127f3474413e6 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Tue, 4 Jul 2023 16:05:26 +0700 Subject: [PATCH 16/33] [#383] Revert the i18n-js to 3.8.0 --- .template/variants/web/app/javascript/global.js | 2 +- .template/variants/web/package.json.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.template/variants/web/app/javascript/global.js b/.template/variants/web/app/javascript/global.js index b7cf488aa..994e2cdcf 100644 --- a/.template/variants/web/app/javascript/global.js +++ b/.template/variants/web/app/javascript/global.js @@ -1,3 +1,3 @@ -import { I18n } from 'i18n-js'; +import I18n from 'i18n-js'; export { I18n }; diff --git a/.template/variants/web/package.json.rb b/.template/variants/web/package.json.rb index b1d54112e..3e03631ea 100644 --- a/.template/variants/web/package.json.rb +++ b/.template/variants/web/package.json.rb @@ -23,7 +23,7 @@ end # Install dependencies -run 'yarn add i18n-js@4.2.3' +run 'yarn add i18n-js@3.8.0' run 'yarn add sass' run 'yarn add esbuild' run 'yarn add postcss postcss-cli autoprefixer' From 22171269e84607f38db556cca84fdc006eff8668 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Thu, 6 Jul 2023 09:07:46 +0700 Subject: [PATCH 17/33] [#433] Add the `.keep` file --- .template/spec/variants/web/app/template_spec.rb | 6 ++++++ .template/variants/web/app/assets/builds/.keep | 0 .template/variants/web/app/template.rb | 1 + 3 files changed, 7 insertions(+) create mode 100644 .template/variants/web/app/assets/builds/.keep diff --git a/.template/spec/variants/web/app/template_spec.rb b/.template/spec/variants/web/app/template_spec.rb index 6e2e756a1..d296d6dbc 100644 --- a/.template/spec/variants/web/app/template_spec.rb +++ b/.template/spec/variants/web/app/template_spec.rb @@ -85,6 +85,12 @@ end end + context 'Assets Builds' do + it 'creates the app/assets/builds/.keep file' do + expect(file('app/assets/builds/.keep')).to exist + end + end + context 'I18n' do it 'creates the translation.js file' do expect(file('app/javascript/translations/translations.js')).to exist diff --git a/.template/variants/web/app/assets/builds/.keep b/.template/variants/web/app/assets/builds/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/.template/variants/web/app/template.rb b/.template/variants/web/app/template.rb index d498d2808..eaba8e367 100644 --- a/.template/variants/web/app/template.rb +++ b/.template/variants/web/app/template.rb @@ -19,6 +19,7 @@ # Stylesheets remove_file 'app/assets/stylesheets/application.css' directory 'app/assets/stylesheets' +directory 'app/assets/builds' run 'yarn build:css' gsub_file 'app/assets/config/manifest.js', "//= link_directory ../stylesheets .css\n", '' From b92f0514487ddc98403008b86b16b5f9b36c741a Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Thu, 6 Jul 2023 09:14:25 +0700 Subject: [PATCH 18/33] [#430] Update the .stylelintignore - Add public/* --- .template/variants/web/.stylelintignore | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.template/variants/web/.stylelintignore b/.template/variants/web/.stylelintignore index 3a8c45427..eca84617d 100644 --- a/.template/variants/web/.stylelintignore +++ b/.template/variants/web/.stylelintignore @@ -1,4 +1,6 @@ /node_modules/** -/app/assets/builds/** -/vendor/** /coverage/** +/public/** +/vendor/** + +/app/assets/builds/** From 8069b8f140c4384ee9896f82ad225ec2f29227c1 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Tue, 4 Jul 2023 13:34:04 +0700 Subject: [PATCH 19/33] Correct the build:css task --- .template/spec/variants/web/package_json_spec.rb | 4 ++-- .template/variants/web/.gitignore.rb | 4 ++++ .template/variants/web/Procfile.dev.rb | 2 +- .template/variants/web/app/template.rb | 2 +- .template/variants/web/package.json.rb | 6 +++--- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.template/spec/variants/web/package_json_spec.rb b/.template/spec/variants/web/package_json_spec.rb index 60cdb296a..fb4d2d45a 100644 --- a/.template/spec/variants/web/package_json_spec.rb +++ b/.template/spec/variants/web/package_json_spec.rb @@ -26,11 +26,11 @@ end it 'adds the script for bundling css' do - expect(subject['scripts']).to include('build:css') + expect(subject['scripts']).to include('build:css-dev') end it 'adds the script for bundling css in production' do - expect(subject['scripts']).to include('build:css-production') + expect(subject['scripts']).to include('build:css') end it 'adds the script for bundling postcss' do diff --git a/.template/variants/web/.gitignore.rb b/.template/variants/web/.gitignore.rb index b235fdae7..d066a679f 100644 --- a/.template/variants/web/.gitignore.rb +++ b/.template/variants/web/.gitignore.rb @@ -26,5 +26,9 @@ # Ignore Gemfile.lock file in engines. /engines/*/Gemfile.lock + + # Ignore asset builds + /app/assets/builds/* + !/app/assets/builds/.keep IGNORE end diff --git a/.template/variants/web/Procfile.dev.rb b/.template/variants/web/Procfile.dev.rb index b72ad4ac3..c617cbd0f 100644 --- a/.template/variants/web/Procfile.dev.rb +++ b/.template/variants/web/Procfile.dev.rb @@ -3,7 +3,7 @@ append_to_file 'Procfile.dev' do <<~PROCFILE js: yarn build --watch - css: yarn build:css --watch + css: yarn build:css-dev --watch postcss: yarn build:postcss --watch PROCFILE end diff --git a/.template/variants/web/app/template.rb b/.template/variants/web/app/template.rb index eaba8e367..ab983770f 100644 --- a/.template/variants/web/app/template.rb +++ b/.template/variants/web/app/template.rb @@ -21,7 +21,7 @@ directory 'app/assets/stylesheets' directory 'app/assets/builds' -run 'yarn build:css' +run 'yarn build:css-dev' gsub_file 'app/assets/config/manifest.js', "//= link_directory ../stylesheets .css\n", '' append_to_file 'app/assets/config/manifest.js', '//= link_tree ../builds' diff --git a/.template/variants/web/package.json.rb b/.template/variants/web/package.json.rb index 3e03631ea..ab848f0ae 100644 --- a/.template/variants/web/package.json.rb +++ b/.template/variants/web/package.json.rb @@ -53,12 +53,12 @@ run %(npm pkg set scripts.build="node app/javascript/build.js") run %( - npm pkg set scripts.build:css-production="sass\ - #{source_stylesheet} #{bundled_stylesheet} #{production_bundled_stylesheet_options.join(' ')}" + npm pkg set scripts.build:css-dev="sass\ + #{source_stylesheet} #{bundled_stylesheet} #{bundled_stylesheet_base_options.join(' ')}" ) run %( npm pkg set scripts.build:css="sass\ - #{source_stylesheet} #{bundled_stylesheet} #{bundled_stylesheet_base_options.join(' ')}" + yarn build:css-dev #{production_bundled_stylesheet_options.join(' ')}" ) run %(npm pkg set scripts.postcss="postcss\ public/assets/*.css --dir public/assets --config ./") From 63dd5fe457d0d0cdeed3296bc76cc1395e9fb777 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Tue, 4 Jul 2023 13:43:29 +0700 Subject: [PATCH 20/33] Fix the typo --- .template/variants/web/package.json.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.template/variants/web/package.json.rb b/.template/variants/web/package.json.rb index ab848f0ae..684ede1d9 100644 --- a/.template/variants/web/package.json.rb +++ b/.template/variants/web/package.json.rb @@ -57,8 +57,7 @@ #{source_stylesheet} #{bundled_stylesheet} #{bundled_stylesheet_base_options.join(' ')}" ) run %( - npm pkg set scripts.build:css="sass\ - yarn build:css-dev #{production_bundled_stylesheet_options.join(' ')}" + npm pkg set scripts.build:css="yarn build:css-dev #{production_bundled_stylesheet_options.join(' ')}" ) run %(npm pkg set scripts.postcss="postcss\ public/assets/*.css --dir public/assets --config ./") From 0f39c3971d6d9c243f69783c6ef4a85f8a018861 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Tue, 4 Jul 2023 14:42:30 +0700 Subject: [PATCH 21/33] Add the option to build multiple JS files with engines --- .template/variants/web/app/javascript/build.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.template/variants/web/app/javascript/build.js b/.template/variants/web/app/javascript/build.js index 9d9c585e1..c403aa99a 100644 --- a/.template/variants/web/app/javascript/build.js +++ b/.template/variants/web/app/javascript/build.js @@ -2,7 +2,10 @@ const watch = process.argv.slice(2).includes('--watch'); require('esbuild') .context({ - entryPoints: ['app/javascript/application.js'], + entryPoints: [ + { in: 'app/javascript/application.js', out: 'application.js' }, + // { in: 'engines/[engine_name]/app/javascript/[engine_name]/application.js', out: '[engine_name]/application.js' }, + ], inject: ['app/javascript/global.js'], bundle: true, sourcemap: true, From 9d3ced550d99769f66394b81a7beee8821133135 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Tue, 4 Jul 2023 14:52:48 +0700 Subject: [PATCH 22/33] Add the Alias --- .template/variants/web/app/javascript/build.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.template/variants/web/app/javascript/build.js b/.template/variants/web/app/javascript/build.js index c403aa99a..f8b1a8cce 100644 --- a/.template/variants/web/app/javascript/build.js +++ b/.template/variants/web/app/javascript/build.js @@ -11,6 +11,9 @@ require('esbuild') sourcemap: true, minify: !watch, outdir: 'app/assets/builds', + alias: { + 'Core': './app/javascript/', + }, }) .then((ctx) => { watch ? ctx.watch() : ctx.rebuild().then(() => process.exit(0)); From 8c6b58540aed84ed66cfc337f29fbf0e4aad092a Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Tue, 4 Jul 2023 14:54:36 +0700 Subject: [PATCH 23/33] Remove the duplicate gitignore --- .template/variants/web/.gitignore.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.template/variants/web/.gitignore.rb b/.template/variants/web/.gitignore.rb index d066a679f..b235fdae7 100644 --- a/.template/variants/web/.gitignore.rb +++ b/.template/variants/web/.gitignore.rb @@ -26,9 +26,5 @@ # Ignore Gemfile.lock file in engines. /engines/*/Gemfile.lock - - # Ignore asset builds - /app/assets/builds/* - !/app/assets/builds/.keep IGNORE end From d58fe531977c3ba9d50fed712e607a17399b317f Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Tue, 4 Jul 2023 15:00:06 +0700 Subject: [PATCH 24/33] Correct the out filename --- .template/variants/web/app/javascript/build.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.template/variants/web/app/javascript/build.js b/.template/variants/web/app/javascript/build.js index f8b1a8cce..9b2fe7932 100644 --- a/.template/variants/web/app/javascript/build.js +++ b/.template/variants/web/app/javascript/build.js @@ -3,8 +3,8 @@ const watch = process.argv.slice(2).includes('--watch'); require('esbuild') .context({ entryPoints: [ - { in: 'app/javascript/application.js', out: 'application.js' }, - // { in: 'engines/[engine_name]/app/javascript/[engine_name]/application.js', out: '[engine_name]/application.js' }, + { in: 'app/javascript/application.js', out: 'application' }, + // { in: 'engines/[engine_name]/app/javascript/[engine_name]/application.js', out: '[engine_name]/application' }, ], inject: ['app/javascript/global.js'], bundle: true, From bec259c6835c8f0f09a53a547e1919724a32698c Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Thu, 6 Jul 2023 09:29:08 +0700 Subject: [PATCH 25/33] Remove the alias config --- .template/variants/web/app/javascript/build.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/.template/variants/web/app/javascript/build.js b/.template/variants/web/app/javascript/build.js index 9b2fe7932..4415b7473 100644 --- a/.template/variants/web/app/javascript/build.js +++ b/.template/variants/web/app/javascript/build.js @@ -11,9 +11,6 @@ require('esbuild') sourcemap: true, minify: !watch, outdir: 'app/assets/builds', - alias: { - 'Core': './app/javascript/', - }, }) .then((ctx) => { watch ? ctx.watch() : ctx.rebuild().then(() => process.exit(0)); From e57226f2354dea77b43776c8fb4362c3fdff149e Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Fri, 7 Jul 2023 11:52:30 +0700 Subject: [PATCH 26/33] [#393] Update the Bootstrap vendor fiel --- .../stylesheets/vendor/_bootstrap.scss | 74 ++++++++++--------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/.template/addons/bootstrap/stylesheets/vendor/_bootstrap.scss b/.template/addons/bootstrap/stylesheets/vendor/_bootstrap.scss index 89072d36c..3591b455c 100644 --- a/.template/addons/bootstrap/stylesheets/vendor/_bootstrap.scss +++ b/.template/addons/bootstrap/stylesheets/vendor/_bootstrap.scss @@ -1,53 +1,55 @@ -// By default every component is imported -// But DO NOT import the whole framework but instead -// pick what the project requires -// and comment out the rest. - -// Configuration +// 1. Include functions first (so you can manipulate colors, SVGs, calc, etc) @import 'bootstrap/scss/functions'; + +// 2. Include remainder of required Bootstrap stylesheets (including any separate color mode stylesheets) @import 'bootstrap/scss/variables'; @import 'bootstrap/scss/variables-dark'; -@import 'bootstrap/scss/maps'; -// @import 'sass_maps'; // Optional Sass map overrides here (See: https://getbootstrap.com/docs/5.2/migration/#new-_mapsscss) -// e.g., $theme-colors: map-merge($theme-colors, $custom-theme-colors); +// 3. Include remainder of required parts +@import 'bootstrap/scss/maps'; @import 'bootstrap/scss/mixins'; +@import 'bootstrap/scss/root'; @import 'bootstrap/scss/utilities'; -// Layout & components -@import 'bootstrap/scss/root'; -@import 'bootstrap/scss/reboot'; -@import 'bootstrap/scss/type'; -@import 'bootstrap/scss/images'; -@import 'bootstrap/scss/containers'; -@import 'bootstrap/scss/grid'; -@import 'bootstrap/scss/tables'; -@import 'bootstrap/scss/forms'; +// 4. Optionally include any other parts as needed +// By default every component is imported +// But DO NOT import the whole framework but instead +// pick what the project requires +// and comment out the rest. +@import 'bootstrap/scss/alert'; +@import 'bootstrap/scss/badge'; +@import 'bootstrap/scss/breadcrumb'; +@import 'bootstrap/scss/button-group'; @import 'bootstrap/scss/buttons'; -@import 'bootstrap/scss/transitions'; +@import 'bootstrap/scss/card'; +@import 'bootstrap/scss/carousel'; +@import 'bootstrap/scss/close'; +@import 'bootstrap/scss/code'; +@import 'bootstrap/scss/custom-forms'; +@import 'bootstrap/scss/containers'; @import 'bootstrap/scss/dropdown'; -@import 'bootstrap/scss/button-group'; +@import 'bootstrap/scss/forms'; +@import 'bootstrap/scss/grid'; +@import 'bootstrap/scss/helpers'; +@import 'bootstrap/scss/images'; +@import 'bootstrap/scss/input-group'; +@import 'bootstrap/scss/jumbotron'; +@import 'bootstrap/scss/list-group'; +@import 'bootstrap/scss/media'; +@import 'bootstrap/scss/modal'; @import 'bootstrap/scss/nav'; @import 'bootstrap/scss/navbar'; -@import 'bootstrap/scss/card'; -@import 'bootstrap/scss/accordion'; -@import 'bootstrap/scss/breadcrumb'; @import 'bootstrap/scss/pagination'; -@import 'bootstrap/scss/badge'; -@import 'bootstrap/scss/alert'; +@import 'bootstrap/scss/popover'; @import 'bootstrap/scss/progress'; -@import 'bootstrap/scss/list-group'; -@import 'bootstrap/scss/close'; +@import 'bootstrap/scss/reboot'; +@import 'bootstrap/scss/root'; +@import 'bootstrap/scss/spinners'; +@import 'bootstrap/scss/tables'; @import 'bootstrap/scss/toasts'; -@import 'bootstrap/scss/modal'; @import 'bootstrap/scss/tooltip'; -@import 'bootstrap/scss/popover'; -@import 'bootstrap/scss/carousel'; -@import 'bootstrap/scss/spinners'; -@import 'bootstrap/scss/offcanvas'; - -// Helpers -@import 'bootstrap/scss/helpers'; +@import 'bootstrap/scss/transitions'; +@import 'bootstrap/scss/type'; -// Utilities +// 5. Optionally include utilities API last to generate classes based on the Sass map in `_utilities.scss` @import 'bootstrap/scss/utilities/api'; From d89b31765de3c261298a37318b012f7344e46677 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Fri, 7 Jul 2023 13:08:03 +0700 Subject: [PATCH 27/33] [#393] Correct the Bootstrap package --- .../addons/bootstrap/stylesheets/vendor/_bootstrap.scss | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.template/addons/bootstrap/stylesheets/vendor/_bootstrap.scss b/.template/addons/bootstrap/stylesheets/vendor/_bootstrap.scss index 3591b455c..2ab59fbf8 100644 --- a/.template/addons/bootstrap/stylesheets/vendor/_bootstrap.scss +++ b/.template/addons/bootstrap/stylesheets/vendor/_bootstrap.scss @@ -16,6 +16,7 @@ // But DO NOT import the whole framework but instead // pick what the project requires // and comment out the rest. +@import 'bootstrap/scss/accordion'; @import 'bootstrap/scss/alert'; @import 'bootstrap/scss/badge'; @import 'bootstrap/scss/breadcrumb'; @@ -24,22 +25,19 @@ @import 'bootstrap/scss/card'; @import 'bootstrap/scss/carousel'; @import 'bootstrap/scss/close'; -@import 'bootstrap/scss/code'; -@import 'bootstrap/scss/custom-forms'; @import 'bootstrap/scss/containers'; @import 'bootstrap/scss/dropdown'; @import 'bootstrap/scss/forms'; @import 'bootstrap/scss/grid'; @import 'bootstrap/scss/helpers'; @import 'bootstrap/scss/images'; -@import 'bootstrap/scss/input-group'; -@import 'bootstrap/scss/jumbotron'; @import 'bootstrap/scss/list-group'; -@import 'bootstrap/scss/media'; @import 'bootstrap/scss/modal'; @import 'bootstrap/scss/nav'; @import 'bootstrap/scss/navbar'; +@import 'bootstrap/scss/offcanvas'; @import 'bootstrap/scss/pagination'; +@import 'bootstrap/scss/placeholders'; @import 'bootstrap/scss/popover'; @import 'bootstrap/scss/progress'; @import 'bootstrap/scss/reboot'; From 522b2164d2d4bcc2ab3e4df1ebf1c5c858fe5ac2 Mon Sep 17 00:00:00 2001 From: Htoo Date: Tue, 11 Jul 2023 11:43:15 +0700 Subject: [PATCH 28/33] update .eslintrc --- .template/variants/web/.eslintrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.template/variants/web/.eslintrc b/.template/variants/web/.eslintrc index 7ca79dc21..f635c3607 100644 --- a/.template/variants/web/.eslintrc +++ b/.template/variants/web/.eslintrc @@ -4,5 +4,8 @@ ], "globals": { "I18n": true + }, + "parserOptions":{ + "ecmaVersion": "latest" } } From 7f0c393898cf72f51bda48159325694574c83243 Mon Sep 17 00:00:00 2001 From: Md Mosharaf Hossan Date: Thu, 13 Jul 2023 16:24:25 +0700 Subject: [PATCH 29/33] Remove the ./bin/dev.sh script in favor of the makefile (#443) * [#410] Remove bin/dev.sh and start foreman from makefile * [#410] Remove test related to bin/dev file existence * [#410] Remove instructions about copying bin/dev * [#410] Rename phrase add-on spec's template file --- .../addons/base/phrase/{template.rb => template_spec.rb} | 0 .template/spec/base/bin/template_spec.rb | 5 ----- Makefile.tt | 2 +- bin/dev | 3 --- bin/template.rb | 1 - 5 files changed, 1 insertion(+), 10 deletions(-) rename .template/spec/addons/base/phrase/{template.rb => template_spec.rb} (100%) delete mode 100755 bin/dev diff --git a/.template/spec/addons/base/phrase/template.rb b/.template/spec/addons/base/phrase/template_spec.rb similarity index 100% rename from .template/spec/addons/base/phrase/template.rb rename to .template/spec/addons/base/phrase/template_spec.rb diff --git a/.template/spec/base/bin/template_spec.rb b/.template/spec/base/bin/template_spec.rb index d5e7e6293..5ec00c821 100644 --- a/.template/spec/base/bin/template_spec.rb +++ b/.template/spec/base/bin/template_spec.rb @@ -21,11 +21,6 @@ expect(file('bin/worker.sh')).to be_executable end - it 'creates the start dev server script' do - expect(file('bin/dev')).to exist - expect(file('bin/dev')).to be_executable - end - it 'creates the docker prepare script' do expect(file('bin/docker-prepare')).to exist expect(file('bin/docker-prepare')).to be_executable diff --git a/Makefile.tt b/Makefile.tt index 0000e804c..ee8ac2014 100644 --- a/Makefile.tt +++ b/Makefile.tt @@ -5,7 +5,7 @@ include .env dev: make install-dependencies make env/setup - ./bin/dev + foreman start -f Procfile.dev env/setup: ./bin/envsetup.sh diff --git a/bin/dev b/bin/dev deleted file mode 100755 index f709c1f6c..000000000 --- a/bin/dev +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -foreman start -f Procfile.dev diff --git a/bin/template.rb b/bin/template.rb index eabab904a..7298e4ae3 100644 --- a/bin/template.rb +++ b/bin/template.rb @@ -5,6 +5,5 @@ copy_file 'bin/start.sh', mode: :preserve copy_file 'bin/test.sh', mode: :preserve copy_file 'bin/worker.sh', mode: :preserve -copy_file 'bin/dev', mode: :preserve copy_file 'bin/docker-prepare', mode: :preserve copy_file 'bin/docker-assets-precompile', mode: :preserve From c21e356db65b53d8f6bd834c61e9327a4bdd1111 Mon Sep 17 00:00:00 2001 From: Md Mosharaf Hossan Date: Thu, 13 Jul 2023 18:12:18 +0700 Subject: [PATCH 30/33] [#414] Enable source map in css build (#444) --- .template/variants/web/package.json.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.template/variants/web/package.json.rb b/.template/variants/web/package.json.rb index 684ede1d9..a6b89f8b1 100644 --- a/.template/variants/web/package.json.rb +++ b/.template/variants/web/package.json.rb @@ -44,7 +44,7 @@ source_stylesheet = 'app/assets/stylesheets/application.scss' bundled_stylesheet = 'app/assets/builds/application.css' bundled_stylesheet_base_options = [ - '--no-source-map', + '--source-map-urls=absolute', '--load-path=node_modules' ] production_bundled_stylesheet_options = bundled_stylesheet_base_options + [ From 7f0418c8fbb02e6772fa5979d8b7e472d745fd76 Mon Sep 17 00:00:00 2001 From: Md Mosharaf Hossan Date: Mon, 17 Jul 2023 09:16:36 +0700 Subject: [PATCH 31/33] [#436] Fix invalid workflow bug for publish wiki workflow (#437) * [#436] Fix invalid workflow bug for publish wiki workflow * [#436] Change implementation of github wiki publish workflow * [#436] Add concurrency, remove env section from publish wiki template file * [#436] Use action checkout v3 for publish wiki workflow --- .../.github/workflows/publish_wiki.yml.tt | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/.template/addons/github/.github/workflows/publish_wiki.yml.tt b/.template/addons/github/.github/workflows/publish_wiki.yml.tt index 15764365b..894e61ea3 100644 --- a/.template/addons/github/.github/workflows/publish_wiki.yml.tt +++ b/.template/addons/github/.github/workflows/publish_wiki.yml.tt @@ -2,17 +2,30 @@ name: Publish Wiki on: push: - paths: - - .github/wiki/** branches: - develop + paths: + - .github/wiki/** + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: publish: - name: Publish Wiki - uses: nimblehq/github-actions-workflows/.github/workflows/publish_wiki.yml@0.1.0 - with: - USER_NAME: github-wiki-workflow - USER_EMAIL: ${{ secrets.GH_EMAIL }} - secrets: - USER_TOKEN: ${{ secrets.GH_TOKEN }} + name: Publish Github Wiki + runs-on: ubuntu-latest + timeout-minutes: 1 + + steps: + - name: Checkout the repository + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + + - name: Publish Github Wiki + uses: nimblehq/publish-github-wiki-action@v1.0 + with: + user_name: github-wiki-workflow + user_email: bot@nimblehq.co + user_access_token: ${{ secrets.USER_ACCESS_TOKEN }} From 613e39ba9f7c89878405eedddcfaa6ce6bbeb183 Mon Sep 17 00:00:00 2001 From: Md Mosharaf Hossan Date: Mon, 17 Jul 2023 09:36:26 +0700 Subject: [PATCH 32/33] [#223] Ignore Danger run on WIP pull request (#432) * [#223] Ignore Danger run on WIP pull request * [#223] Change implementation of Ignoring Danger run on WIP pull request * [#223] Have danger run skip on PR with case insensitive conditions on title and label * [#223] Fix lint in Dangerfile * [#223] Shift danger skip condition from Dangerfile to github test workflow * [#223] Trigger test workflow for pr state or attribute changes * [#223] Remove immediate test workflow trigger for pr state or attribute changes --- .template/addons/github/.github/workflows/test.yml.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.template/addons/github/.github/workflows/test.yml.tt b/.template/addons/github/.github/workflows/test.yml.tt index 99ed67b53..84e462d49 100644 --- a/.template/addons/github/.github/workflows/test.yml.tt +++ b/.template/addons/github/.github/workflows/test.yml.tt @@ -144,7 +144,7 @@ jobs: needs: unit_tests runs-on: ubuntu-latest timeout-minutes: 5 - if: github.event_name == 'pull_request' + if: github.event_name == 'pull_request' && !contains(join(github.event.pull_request.labels.*.name, ','), 'wip') && !contains(github.event.pull_request.title, '[wip]') && !github.event.pull_request.draft steps: - uses: actions/checkout@v3 with: From 6c8da127b48b6331174dff495c19603080207aef Mon Sep 17 00:00:00 2001 From: Md Mosharaf Hossan Date: Wed, 26 Jul 2023 15:13:33 +0700 Subject: [PATCH 33/33] Add svgeez addon (#445) * [#425] Add svg sprite addon * [#425] Add svgeez add on in place of svg sprite add on * [#425] add inline_svg gem for svgeez addon, move it to web variant * [#425] Add binary file and change wiki for svgeez addon * [#425] Fix lint * [#425] Update gemfile spec for svgeez addon * [#425] Change svgeez installation location in gemfile * [#425] Change svgeez gem location in gemfile * [#425] Add svgeez github wiki addon if .github directory exists * [#425] Remove unnecessary line from svgeez template * [#425] Add svg helper for svgeez addon * [#425] Fix lint * [#425] Modify svgeez addon test * [#425] Remove gemfile spec for svgeez * [#425] Fix lint * [#425] Change svgeez github wiki sidebar title * [#425] Add svgeez addon's gems inside development group * [#425] Change svgeez addon binary file * [#425] Change svgeez wiki file name * [#425] Remove empty line * [#425] Add inline_svg gem under production group --- .../svgeez/.github/wiki/Managing-SVG-Icons.md | 35 +++++++++++++++++++ .../addons/svgeez/.github/wiki/template.rb | 14 ++++++++ .template/addons/svgeez/Gemfile.rb | 15 ++++++++ .template/addons/svgeez/bin/svg-sprite | 12 +++++++ .template/addons/svgeez/bin/template.rb | 5 +++ .template/addons/svgeez/helpers/svg_helper.rb | 14 ++++++++ .template/addons/svgeez/helpers/template.rb | 5 +++ .template/addons/svgeez/template.rb | 6 ++++ .template/variants/web/template.rb | 1 + 9 files changed, 107 insertions(+) create mode 100644 .template/addons/svgeez/.github/wiki/Managing-SVG-Icons.md create mode 100644 .template/addons/svgeez/.github/wiki/template.rb create mode 100644 .template/addons/svgeez/Gemfile.rb create mode 100755 .template/addons/svgeez/bin/svg-sprite create mode 100644 .template/addons/svgeez/bin/template.rb create mode 100644 .template/addons/svgeez/helpers/svg_helper.rb create mode 100644 .template/addons/svgeez/helpers/template.rb create mode 100644 .template/addons/svgeez/template.rb diff --git a/.template/addons/svgeez/.github/wiki/Managing-SVG-Icons.md b/.template/addons/svgeez/.github/wiki/Managing-SVG-Icons.md new file mode 100644 index 000000000..2d0be8525 --- /dev/null +++ b/.template/addons/svgeez/.github/wiki/Managing-SVG-Icons.md @@ -0,0 +1,35 @@ +From time to time, we need to add new SVG icons to the app. This document describes the steps to do that. + +## Gems +The following 2 gems are used to handle SVG: +- [svgeez](https://github.com/jgarber623/svgeez): for generating an SVG sprite from a folder of SVG icons. Requires Node.js and SVGO 1.3.2. +- [inline_svg](https://github.com/jamesmartin/inline_svg): to use inline SVG for styling SVG with CSS + +## Node dependencies +- [svgo](https://www.npmjs.com/package/svgo): Optimizes SVG sprite file size + ```sh + npm -g install svgo@1.3.2 + ``` + +## Add a new icon: +- Export the SVG icon from Figma +- Add the icon to `app/assets/images/icons` directory. +- Run the following command to generate the new `app/assets/images/icon-sprite.svg` file which contains all of the icons in the `icons` directory + ```sh + bin/svg-sprite + ``` + +## Use the new icon +- Add the `icon-sprite.svg` file to the layout of the page + ```erb + + <%= inline_svg_tag 'icon-sprite.svg' %> + + ``` +- Use the `svg_tag` provided by the `SvgHelper` (app/helpers/svg_helper.rb) and provided `icon_id` matched with icon file name with prefix `icon-`: + ```erb + <%= svg_tag icon_id: 'icon-[icon-file-name]', html: {} %> + + + <%= svg_tag icon_id: 'icon-contacts', html: { class: 'icon' } %> + ``` diff --git a/.template/addons/svgeez/.github/wiki/template.rb b/.template/addons/svgeez/.github/wiki/template.rb new file mode 100644 index 000000000..8472ac0e8 --- /dev/null +++ b/.template/addons/svgeez/.github/wiki/template.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +if Dir.exist?('.github/wiki') + use_source_path __dir__ + + copy_file 'Managing-SVG-Icons.md', '.github/wiki/Managing-SVG-Icons.md' + + # SVG Sprite + insert_into_file '.github/wiki/_Sidebar.md', after: /## Operations.*\n/ do + <<~RUBY + - [[Managing SVG icons]] + RUBY + end +end diff --git a/.template/addons/svgeez/Gemfile.rb b/.template/addons/svgeez/Gemfile.rb new file mode 100644 index 000000000..5a443a30d --- /dev/null +++ b/.template/addons/svgeez/Gemfile.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +# SVG Sprite +insert_into_file 'Gemfile', after: /gem 'danger'.*\n/ do + <<~RUBY + gem 'svgeez' # Gem for generating an SVG sprite from a folder of SVG icons. + RUBY +end + +# SVG Sprite +insert_into_file 'Gemfile', after: /gem 'bcrypt'.*\n/ do + <<~RUBY + gem 'inline_svg' # Use Inline SVG for styling SVG with CSS + RUBY +end diff --git a/.template/addons/svgeez/bin/svg-sprite b/.template/addons/svgeez/bin/svg-sprite new file mode 100755 index 000000000..e9937d8b3 --- /dev/null +++ b/.template/addons/svgeez/bin/svg-sprite @@ -0,0 +1,12 @@ +# Generates an SVG sprite from a folder of SVG icons. +# +# Uses `svgeez` gem. +# https://github.com/jgarber623/svgeez +# +# Usage +# -s --source: Path to the folder of source SVGs (defaults to ./_svgeez). +# -d --destination: Path to the destination file or folder (defaults to ./svgeez.svg) +# --with-svgo: Optimize SVG sprite file with SVGO + +# Generate the sprite file which includes the `icon-` prefix +bin/bundle exec svgeez build --prefix icon --source app/assets/images/icons/ --destination app/assets/images/icon-sprite.svg --with-svgo diff --git a/.template/addons/svgeez/bin/template.rb b/.template/addons/svgeez/bin/template.rb new file mode 100644 index 000000000..1455f7144 --- /dev/null +++ b/.template/addons/svgeez/bin/template.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +use_source_path __dir__ + +copy_file 'svg-sprite', 'bin/svg-sprite', mode: :preserve diff --git a/.template/addons/svgeez/helpers/svg_helper.rb b/.template/addons/svgeez/helpers/svg_helper.rb new file mode 100644 index 000000000..3b2a658cc --- /dev/null +++ b/.template/addons/svgeez/helpers/svg_helper.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module SvgHelper + DEFAULT_SVG_ATTRIBUTES = { + width: '16', + height: '16' + }.freeze + + def svg_tag(html: {}, icon_id: '') + svg_attributes = DEFAULT_SVG_ATTRIBUTES.merge(html) + + tag.svg(tag.use(nil, 'xlink:href' => "##{icon_id}"), **svg_attributes) + end +end diff --git a/.template/addons/svgeez/helpers/template.rb b/.template/addons/svgeez/helpers/template.rb new file mode 100644 index 000000000..536e91d06 --- /dev/null +++ b/.template/addons/svgeez/helpers/template.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +use_source_path __dir__ + +copy_file 'svg_helper.rb', 'app/helpers/svg_helper.rb' diff --git a/.template/addons/svgeez/template.rb b/.template/addons/svgeez/template.rb new file mode 100644 index 000000000..1f1f3e1c4 --- /dev/null +++ b/.template/addons/svgeez/template.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +apply '.template/addons/svgeez/Gemfile.rb' +apply '.template/addons/svgeez/bin/template.rb' +apply '.template/addons/svgeez/.github/wiki/template.rb' +apply '.template/addons/svgeez/helpers/template.rb' diff --git a/.template/variants/web/template.rb b/.template/variants/web/template.rb index 83660a384..4b4c2c6e2 100644 --- a/.template/variants/web/template.rb +++ b/.template/variants/web/template.rb @@ -25,6 +25,7 @@ def apply_web_variant! apply '.template/addons/bootstrap/template.rb' if yes? install_addon_prompt 'Bootstrap' apply '.template/addons/slim/template.rb' if yes? install_addon_prompt 'Slim Template Engine' apply '.template/addons/hotwire/template.rb' if yes? install_addon_prompt 'Hotwire' + apply '.template/addons/svgeez/template.rb' if yes? install_addon_prompt 'Svgeez' after_bundle do use_source_path __dir__