From 3dc8632f94800fe7083f0a6e774b00fe10d6088e Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Thu, 14 Dec 2023 10:13:01 +0700 Subject: [PATCH] Update Rails 7.1, Node 18, stylelint-config 1.1 and fix deprecated usage --- .github/workflows/test_generated_app.yml | 4 +- .github/workflows/test_production_build.yml | 4 +- .../github/.github/workflows/test.yml.tt | 2 +- .template/variants/web/.stylelintrc | 1 - .../assets/stylesheets/functions/_sizing.scss | 10 +++-- .template/variants/web/package.json.rb | 2 +- .tool-versions | 2 +- Gemfile.tt | 2 +- README.md | 4 +- template.rb | 40 +++++++++++-------- 10 files changed, 40 insertions(+), 31 deletions(-) diff --git a/.github/workflows/test_generated_app.yml b/.github/workflows/test_generated_app.yml index 12fd16010..567d045ad 100644 --- a/.github/workflows/test_generated_app.yml +++ b/.github/workflows/test_generated_app.yml @@ -10,8 +10,8 @@ env: DOCKER_REGISTRY_USERNAME: ${{ github.repository_owner }} DOCKER_REGISTRY_TOKEN: ${{ secrets.DOCKER_REGISTRY_TOKEN }} RUBY_VERSION: 3.2.2 - NODE_VERSION: 16 - RAILS_VERSION: 7.0.6 + NODE_VERSION: 18 + RAILS_VERSION: 7.1.2 concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/test_production_build.yml b/.github/workflows/test_production_build.yml index 01d4570b7..b24ae93a7 100644 --- a/.github/workflows/test_production_build.yml +++ b/.github/workflows/test_production_build.yml @@ -7,8 +7,8 @@ env: DOCKER_IMAGE: ${{ github.repository }} DOCKER_REGISTRY_HOST: ${{ secrets.DOCKER_REGISTRY_HOST }} RUBY_VERSION: 3.2.2 - NODE_VERSION: 16 - RAILS_VERSION: 7.0.6 + NODE_VERSION: 18 + RAILS_VERSION: 7.1.2 concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.template/addons/github/.github/workflows/test.yml.tt b/.template/addons/github/.github/workflows/test.yml.tt index 2ee0e6cd3..05c5f4818 100644 --- a/.template/addons/github/.github/workflows/test.yml.tt +++ b/.template/addons/github/.github/workflows/test.yml.tt @@ -14,7 +14,7 @@ env: DOCKER_REGISTRY_TOKEN: ${{ secrets.DOCKER_REGISTRY_TOKEN }} DOCKER_IMAGE: ${{ github.repository }} <%- if WEB_VARIANT -%> - NODE_VERSION: 16 + NODE_VERSION: 18 <%- end -%> # Set the default docker-compose file diff --git a/.template/variants/web/.stylelintrc b/.template/variants/web/.stylelintrc index d5cc86ef9..488b0cb79 100644 --- a/.template/variants/web/.stylelintrc +++ b/.template/variants/web/.stylelintrc @@ -3,7 +3,6 @@ "@nimblehq/stylelint-config-nimble" ], "rules": { - "no-eol-whitespace": true, "max-nesting-depth": 3, "scss/at-extend-no-missing-placeholder": null, "order/properties-alphabetical-order": null diff --git a/.template/variants/web/app/assets/stylesheets/functions/_sizing.scss b/.template/variants/web/app/assets/stylesheets/functions/_sizing.scss index 56ecb8c68..e3e200fac 100644 --- a/.template/variants/web/app/assets/stylesheets/functions/_sizing.scss +++ b/.template/variants/web/app/assets/stylesheets/functions/_sizing.scss @@ -1,12 +1,14 @@ +@use 'sass:list'; + @function em($values, $base-font-size: 16px) { $list: (); @each $value in $values { @if ($value == 0 or $value == auto) { - $list: append($list, $value); + $list: list.append($list, $value); } @else { $em-value: calc($value / $base-font-size) + em; - $list: append($list, $em-value); + $list: list.append($list, $em-value); } } @@ -18,10 +20,10 @@ @each $value in $values { @if ($value == 0 or $value == auto) { - $list: append($list, $value); + $list: list.append($list, $value); } @else { $rem-value: calc($value / $base-font-size) + rem; - $list: append($list, $rem-value); + $list: list.append($list, $rem-value); } } diff --git a/.template/variants/web/package.json.rb b/.template/variants/web/package.json.rb index a6b89f8b1..d38b5c259 100644 --- a/.template/variants/web/package.json.rb +++ b/.template/variants/web/package.json.rb @@ -31,7 +31,7 @@ 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' +run 'yarn add --dev @nimblehq/stylelint-config-nimble@1.1.0' # Setup scripts run 'npm pkg set scripts.eslint="eslint . --color"' diff --git a/.tool-versions b/.tool-versions index 429e999cc..df6fb92db 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -nodejs 16.20.1 +nodejs >= 18 ruby 3.2.2 diff --git a/Gemfile.tt b/Gemfile.tt index 4d5fbf168..07c0a5c94 100644 --- a/Gemfile.tt +++ b/Gemfile.tt @@ -2,7 +2,7 @@ source 'https://rubygems.org' ruby '<%= RUBY_VERSION %>' # Backend -gem 'rails', '7.0.6' # Latest stable +gem 'rails', '7.1.2' # 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 be635f675..ef8ec3848 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ with building complex applications over the years. ### Requirements - Install ruby and set your local ruby version to `3.2.2` -- Install rails `7.0.6` -- Install node `16.20.1` (For creating web application) +- Install rails `7.1.2` +- Install node `18.19.0` (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 e0831b9ff..41e81b41c 100644 --- a/template.rb +++ b/template.rb @@ -21,8 +21,8 @@ }.freeze if WEB_VARIANT - NODE_VERSION = '16.20.1' - NODE_SOURCE_VERSION = '16' # Used in Dockerfile https://github.com/nodesource/distributions + NODE_VERSION = '18.19.0' + NODE_SOURCE_VERSION = '18' # Used in Dockerfile https://github.com/nodesource/distributions end def apply_template!(template_root) @@ -80,20 +80,27 @@ def apply_template!(template_root) end def ask_for_optional_addons - @install_github_action = true if yes?(install_addon_prompt('Github Action and Wiki')) - @install_openapi = true if API_VARIANT || yes?(install_addon_prompt('OpenAPI')) - @install_mock_server = true if @install_openapi && yes?(install_addon_prompt('Mock Server')) - @install_semaphore = true if yes?(install_addon_prompt('SemaphoreCI')) - @install_nginx = true if yes?(install_addon_prompt('Nginx')) - @install_phrase = true if yes?(install_addon_prompt('Phrase')) - @install_devise = true if yes?(install_addon_prompt('Devise')) - - return unless WEB_VARIANT - - @install_bootstrap = true if yes?(install_addon_prompt('Bootstrap')) - @install_slim = true if yes?(install_addon_prompt('Slim Template Engine')) - @install_hotwire = true if yes?(install_addon_prompt('Hotwire')) - @install_svgeez = true if yes?(install_addon_prompt('Svgeez')) + ask_for_all_variant_addons + + ask_for_web_variant_addons if WEB_VARIANT +end + +def ask_for_all_variant_addons + @install_github_action = yes?(install_addon_prompt('Github Action and Wiki')) + @install_openapi = API_VARIANT || yes?(install_addon_prompt('OpenAPI')) + @install_mock_server = @install_openapi && yes?(install_addon_prompt('Mock Server')) + @install_semaphore = yes?(install_addon_prompt('SemaphoreCI')) + @install_nginx = yes?(install_addon_prompt('Nginx')) + @install_phrase = yes?(install_addon_prompt('Phrase')) + @install_crud = WEB_VARIANT && yes?(install_addon_prompt('Crud (includes Devise, Bootstrap and Slim)')) + @install_devise = @install_crud || yes?(install_addon_prompt('Devise')) +end + +def ask_for_web_variant_addons + @install_bootstrap = @install_crud || yes?(install_addon_prompt('Bootstrap')) + @install_slim = @install_crud || yes?(install_addon_prompt('Slim Template Engine')) + @install_hotwire = yes?(install_addon_prompt('Hotwire')) + @install_svgeez = yes?(install_addon_prompt('Svgeez')) end def apply_optional_addons @@ -103,6 +110,7 @@ def apply_optional_addons apply '.template/addons/nginx/template.rb' if @install_nginx apply '.template/addons/phrase/template.rb' if @install_phrase apply '.template/addons/devise/template.rb' if @install_devise + apply '.template/addons/crud/template.rb' if @install_crud end # Set Thor::Actions source path for looking up the files