diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5f4cc244..1cd692ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -92,3 +92,11 @@ jobs: PGPASSWORD: postgres PGHOST: localhost run: ./ci/bin/build-and-test + spellr: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.1 + - run: gem install spellr; spellr diff --git a/template.rb b/template.rb index 96e389a4..180c36f1 100644 --- a/template.rb +++ b/template.rb @@ -131,10 +131,6 @@ def apply_template! template "rubocop.yml.tt", ".rubocop.yml" run_rubocop_autocorrections - copy_file ".spellr.yml" - copy_file ".spellr_wordlists/english.txt" - # TODO: add the @app_name to the wordlist then clean it - apply "variants/frontend-audit-app/template.rb" apply "variants/frontend-base/js-lint/fixes.rb" @@ -156,6 +152,13 @@ def apply_template! # we deliberately place this after the initial git commit because it # contains a lot of changes and adds its own git commit apply "variants/devise/template.rb" if $config.apply_variant_devise? + + copy_file ".spellr.yml" + FileUtils.mkdir_p ".spellr_wordlists" + wordlist = run_with_clean_bundler_env "bundle exec spellr --wordlist", capture: true + File.write('.spellr_wordlists/english.txt', wordlist) + git add: '.spellr_wordlists' + git commit: "-m 'Add Spellr wordlist'" end end @@ -250,16 +253,18 @@ def preexisting_git_repo? @preexisting_git_repo == true end -def run_with_clean_bundler_env(cmd) - success = if defined?(Bundler) - Bundler.with_unbundled_env { run(cmd) } +def run_with_clean_bundler_env(cmd, **options) + result = if defined?(Bundler) + Bundler.with_unbundled_env { run(cmd, **options) } else - run(cmd) + run(cmd, **options) end - unless success + unless result puts "Command failed, exiting: #{cmd}" exit(1) end + + result end def run_rubocop_autocorrections