potassium 6.7.0 → 7.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +9 -1
  3. data/.node-version +1 -1
  4. data/.rubocop.yml +4 -0
  5. data/CHANGELOG.md +40 -0
  6. data/README.md +8 -1
  7. data/docs/CONTRIBUTING.md +6 -6
  8. data/lib/potassium/assets/.circleci/config.yml.erb +19 -13
  9. data/lib/potassium/assets/.env.development.erb +1 -0
  10. data/lib/potassium/assets/.env.test.erb +1 -0
  11. data/lib/potassium/assets/.eslintrc.json +14 -9
  12. data/lib/potassium/assets/.rubocop.yml +66 -1
  13. data/lib/potassium/assets/README.yml +3 -9
  14. data/lib/potassium/assets/app/frontend/active_admin/jquery.js +2 -0
  15. data/lib/potassium/assets/app/frontend/api/__mocks__/index.mock.ts +3 -0
  16. data/lib/potassium/assets/app/frontend/api/index.ts +63 -0
  17. data/lib/potassium/assets/app/frontend/css/application.css +3 -0
  18. data/lib/potassium/assets/app/frontend/entrypoints/active_admin.js +7 -0
  19. data/lib/potassium/assets/app/frontend/entrypoints/active_admin.scss +38 -0
  20. data/lib/potassium/assets/app/frontend/entrypoints/application.js +12 -0
  21. data/lib/potassium/assets/app/{javascript → frontend}/types/vue.d.ts +1 -0
  22. data/lib/potassium/assets/app/{javascript → frontend}/utils/case-converter.ts +2 -2
  23. data/lib/potassium/assets/app/frontend/utils/csrf-token.ts +9 -0
  24. data/lib/potassium/assets/bin/setup.erb +1 -1
  25. data/lib/potassium/assets/bin/update.erb +1 -1
  26. data/lib/potassium/assets/config/initializers/session_store.rb +20 -0
  27. data/lib/potassium/assets/config/sentry.rb.erb +2 -10
  28. data/lib/potassium/assets/lib/dotenv_monkeypatch.rb +19 -0
  29. data/lib/potassium/assets/lib/environment_variables.rb +9 -0
  30. data/lib/potassium/assets/package.json +7 -0
  31. data/lib/potassium/assets/tailwind.config.js +14 -0
  32. data/lib/potassium/assets/testing/simplecov_config.rb +10 -1
  33. data/lib/potassium/assets/tsconfig.config.json +18 -0
  34. data/lib/potassium/assets/tsconfig.json +17 -27
  35. data/lib/potassium/assets/vite.config.ts +46 -0
  36. data/lib/potassium/cli_options.rb +6 -4
  37. data/lib/potassium/helpers/rubocop-helpers.rb +6 -12
  38. data/lib/potassium/platanus_config.rb +1 -1
  39. data/lib/potassium/recipes/admin.rb +43 -72
  40. data/lib/potassium/recipes/background_processor.rb +0 -30
  41. data/lib/potassium/recipes/bullet.rb +41 -0
  42. data/lib/potassium/recipes/ci.rb +5 -0
  43. data/lib/potassium/recipes/cleanup.rb +0 -1
  44. data/lib/potassium/recipes/coverage.rb +4 -27
  45. data/lib/potassium/recipes/database_container.rb +1 -1
  46. data/lib/potassium/recipes/environment_variables.rb +18 -0
  47. data/lib/potassium/recipes/error_reporting.rb +2 -2
  48. data/lib/potassium/recipes/front_end_vite.rb +155 -0
  49. data/lib/potassium/recipes/google_tag_manager.rb +19 -23
  50. data/lib/potassium/recipes/mailer.rb +1 -1
  51. data/lib/potassium/recipes/mjml.rb +1 -1
  52. data/lib/potassium/recipes/node.rb +1 -1
  53. data/lib/potassium/recipes/rails.rb +2 -0
  54. data/lib/potassium/recipes/redis.rb +57 -0
  55. data/lib/potassium/recipes/style.rb +4 -6
  56. data/lib/potassium/recipes/vue_admin.rb +18 -14
  57. data/lib/potassium/recipes/yarn.rb +1 -1
  58. data/lib/potassium/templates/application.rb +11 -13
  59. data/lib/potassium/version.rb +8 -7
  60. data/spec/features/api_spec.rb +2 -2
  61. data/spec/features/background_processor_spec.rb +2 -2
  62. data/spec/features/bullet_spec.rb +29 -0
  63. data/spec/features/ci_spec.rb +17 -4
  64. data/spec/features/coverage_spec.rb +7 -10
  65. data/spec/features/database_container_spec.rb +1 -1
  66. data/spec/features/database_spec.rb +1 -1
  67. data/spec/features/draper_spec.rb +1 -1
  68. data/spec/features/environment_variables_spec.rb +28 -0
  69. data/spec/features/error_reporting_spec.rb +2 -2
  70. data/spec/features/file_storage_spec.rb +4 -4
  71. data/spec/features/google_tag_manager_spec.rb +1 -1
  72. data/spec/features/i18n_spec.rb +1 -1
  73. data/spec/features/mailer_spec.rb +1 -2
  74. data/spec/features/new_project_spec.rb +2 -8
  75. data/spec/features/node_spec.rb +1 -1
  76. data/spec/features/power_types_spec.rb +1 -1
  77. data/spec/features/pundit_spec.rb +1 -1
  78. data/spec/features/redis_spec.rb +43 -0
  79. data/spec/features/schedule_spec.rb +1 -1
  80. data/spec/features/testing_spec.rb +0 -1
  81. data/spec/features/vue_admin_spec.rb +1 -1
  82. data/spec/front_end_vite_spec.rb +79 -0
  83. data/spec/support/potassium_test_helpers.rb +0 -6
  84. metadata +36 -19
  85. data/lib/potassium/assets/app/javascript/api/index.ts +0 -55
  86. data/lib/potassium/assets/config/webpack/rules/css.js +0 -5
  87. data/lib/potassium/assets/config/webpack/rules/index.js +0 -11
  88. data/lib/potassium/assets/config/webpack/rules/jquery.js +0 -11
  89. data/lib/potassium/assets/config/webpack/rules/typescript.js +0 -32
  90. data/lib/potassium/assets/config/webpack/rules/vue.js +0 -19
  91. data/lib/potassium/assets/config/webpack/webpack.config.js +0 -4
  92. data/lib/potassium/recipes/front_end.rb +0 -270
  93. data/spec/features/front_end_spec.rb +0 -76
  94. /data/lib/potassium/assets/app/{javascript → frontend}/components/app.spec.ts +0 -0
  95. /data/lib/potassium/assets/app/{javascript → frontend}/components/app.vue +0 -0
@@ -0,0 +1,19 @@
1
+ module Dotenv
2
+ module Substitutions
3
+ module Command
4
+ class << self
5
+ INTERPOLATED_SHELL_COMMAND = /
6
+ (?<backslash>\\)? # is it escaped with a backslash?
7
+ COMMAND_EXPAND # literal $
8
+ (?<cmd> # collect command content for eval
9
+ \( # require opening paren
10
+ (?:[^()]|\g<cmd>)+ # allow any number of non-parens, or balanced
11
+ # parens (by nesting the <cmd> expression
12
+ # recursively)
13
+ \) # require closing paren
14
+ )
15
+ /x
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ module EnvironmentVariables
2
+ extend self
3
+
4
+ APPLICATION_HOST = ENV.fetch('APPLICATION_HOST')
5
+
6
+ def application_host
7
+ APPLICATION_HOST
8
+ end
9
+ end
@@ -1,5 +1,12 @@
1
1
  {
2
2
  "name": "<%= @app_name.camelcase %>",
3
+ "private": true,
4
+ "version": "0.0.1",
5
+ "scripts": {
6
+ "test": "vitest run",
7
+ "test:watch": "vitest",
8
+ "test:changes": "vitest --changed master"
9
+ },
3
10
  "engines": {
4
11
  "node": "<%= get(:node_version) %>"
5
12
  }
@@ -0,0 +1,14 @@
1
+ /* eslint-disable no-undef */
2
+ module.exports = {
3
+ theme: {
4
+ extend: {},
5
+ },
6
+ variants: {},
7
+ plugins: [],
8
+ content: [
9
+ './app/**/*.html',
10
+ './app/**/*.vue',
11
+ './app/**/*.js',
12
+ './app/**/*.erb',
13
+ ],
14
+ };
@@ -1,6 +1,7 @@
1
1
  require 'simplecov'
2
2
  require 'simplecov_text_formatter'
3
3
  require 'simplecov_linter_formatter'
4
+ require 'simplecov_json_formatter'
4
5
 
5
6
  SimpleCovLinterFormatter.setup do |config|
6
7
  config.scope = ENV.fetch(
@@ -48,9 +49,17 @@ SimpleCov.start 'rails' do
48
49
  add_filter 'app/responders'
49
50
  add_filter 'lib/fake_data_loader.rb'
50
51
  add_filter 'lib/vue_component.rb'
52
+ add_filter 'lib/environment_variables.rb'
51
53
 
52
54
  if ENV["CIRCLECI"]
53
- formatter(SimpleCov::Formatter::TextFormatter)
55
+ formatter(
56
+ SimpleCov::Formatter::MultiFormatter.new(
57
+ [
58
+ SimpleCov::Formatter::TextFormatter,
59
+ SimpleCov::Formatter::JSONFormatter
60
+ ]
61
+ )
62
+ )
54
63
  else
55
64
  formatter(
56
65
  SimpleCov::Formatter::MultiFormatter.new(
@@ -0,0 +1,18 @@
1
+ {
2
+ "extends": [
3
+ "@tsconfig/node14/tsconfig.json",
4
+ "@vue/tsconfig/tsconfig.json"
5
+ ],
6
+ "include": [
7
+ "vite.config.*",
8
+ "vitest.config.*",
9
+ "cypress.config.*",
10
+ "playwright.config.*"
11
+ ],
12
+ "compilerOptions": {
13
+ "composite": true,
14
+ "types": [
15
+ "node"
16
+ ]
17
+ }
18
+ }
@@ -1,32 +1,22 @@
1
1
  {
2
- "compilerOptions": {
3
- "module": "ESNext",
4
- "moduleResolution": "Node",
5
- "resolveJsonModule": true,
6
- "useDefineForClassFields": true,
7
- "jsx": "preserve",
8
- "noImplicitThis": true,
9
- "strict": true,
10
- "isolatedModules": true,
11
- "preserveValueImports": true,
12
- "importsNotUsedAsValues": "error",
13
- "target": "esnext",
14
- "allowJs": true,
15
-
16
- // Recommended
17
- "esModuleInterop": true,
18
- "forceConsistentCasingInFileNames": true,
19
- // See <https://github.com/vuejs/vue-cli/pull/5688>
20
- "skipLibCheck": true,
21
- "baseUrl": "app/javascript/",
22
- "types": ["@types/jest", "@types/node"],
23
- },
2
+ "extends": "@vue/tsconfig/tsconfig.dom.json",
24
3
  "include": [
25
- "app/javascript/**/*.ts",
26
- "app/javascript/**/*.vue"
4
+ "env.d.ts",
5
+ "app/**/*",
6
+ "app/**/*.vue"
27
7
  ],
28
- "exclude": [
29
- "node_modules",
30
- "**/*.spec.ts"
8
+ "compilerOptions": {
9
+ "baseUrl": ".",
10
+ "paths": {
11
+ "@/*": [
12
+ "./app/frontend/*"
13
+ ]
14
+ },
15
+ "types": ["vitest/globals", "vite/client"]
16
+ },
17
+ "references": [
18
+ {
19
+ "path": "./tsconfig.config.json"
20
+ }
31
21
  ]
32
22
  }
@@ -0,0 +1,46 @@
1
+ import { fileURLToPath, URL } from 'node:url';
2
+ import { defineConfig } from 'vitest/config'
3
+ import RubyPlugin from 'vite-plugin-ruby';
4
+ import vue from '@vitejs/plugin-vue';
5
+
6
+ export default defineConfig({
7
+ plugins: [
8
+ RubyPlugin(),
9
+ vue()
10
+ ],
11
+ resolve: {
12
+ alias: {
13
+ vue: 'vue/dist/vue.esm-bundler.js',
14
+ '@': fileURLToPath(new URL('./app/frontend', import.meta.url)),
15
+ },
16
+ },
17
+ test: {
18
+ globals: true,
19
+ environment: 'jsdom',
20
+ coverage: {
21
+ provider: 'c8',
22
+ all: true,
23
+ include: ['app/frontend/**/*.{js,ts,vue}'],
24
+ exclude: [
25
+ /* default excludes */
26
+ 'coverage/**',
27
+ 'dist/**',
28
+ 'packages/*/test{,s}/**',
29
+ '**/*.d.ts',
30
+ 'cypress/**',
31
+ 'test{,s}/**',
32
+ 'test{,-*}.{js,cjs,mjs,ts,tsx,jsx}',
33
+ '**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}',
34
+ '**/*{.,-}spec.{js,cjs,mjs,ts,tsx,jsx}',
35
+ '**/__tests__/**',
36
+ '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*',
37
+ '**/.{eslint,mocha,prettier}rc.{js,cjs,yml}',
38
+ /* custom excludes */
39
+ 'app/frontend/**/*.spec.{js,ts,vue}',
40
+ 'app/frontend/**/*.mock.{js,ts,vue}',
41
+ 'app/frontend/active_admin/jquery.js',
42
+ 'app/frontend/entrypoints',
43
+ ]
44
+ }
45
+ },
46
+ })
@@ -172,10 +172,12 @@ module Potassium::CliOptions # rubocop:disable Metrics/ModuleLength
172
172
  default_test_value: false
173
173
  },
174
174
  {
175
- type: :flag,
176
- name: :front_end,
177
- desc: "Decides which front-end framework to use. Available: Vue, Angular 2, None",
178
- default_test_value: "None"
175
+ type: :switch,
176
+ name: :front_end_vite,
177
+ desc: "Whether to use Vite as frontend bundler",
178
+ negatable: true,
179
+ default_value: true,
180
+ default_test_value: true
179
181
  },
180
182
  {
181
183
  type: :switch,
@@ -1,15 +1,9 @@
1
- module RubocopHelpers
2
- def rubocop_revision
3
- fix_environments
4
- end
1
+ require "rubocop"
5
2
 
6
- private
7
-
8
- def fix_environments
9
- # Style problem in Rails 5 production environments
10
- file_name = "config/environments/production.rb"
11
- production = File.read(file_name)
12
- production.gsub!("config.log_tags = [ :request_id ]", "config.log_tags = [:request_id]")
13
- File.open(file_name, "w") { |file| file.write(production) }
3
+ module RubocopHelpers
4
+ def run_rubocop
5
+ options, paths = RuboCop::Options.new.parse(["-A"])
6
+ runner = RuboCop::Runner.new(options, RuboCop::ConfigStore.new)
7
+ runner.run(paths)
14
8
  end
15
9
  end
@@ -10,7 +10,7 @@ module Potassium
10
10
  'db': 'postgresql', 'locale': 'es-CL', 'email_service': 'sendgrid', 'devise': true,
11
11
  'devise-user-model': true, 'admin': true, 'vue_admin': true, 'pundit': true,
12
12
  'api': true, 'storage': 'shrine', 'heroku': true, 'background_processor': true,
13
- 'draper': true, 'schedule': true, 'sentry': true, 'front_end': 'vue',
13
+ 'draper': true, 'schedule': true, 'sentry': true, 'front_end_vite': true,
14
14
  'google_tag_manager': true, 'test': true, 'spring': true
15
15
  }
16
16
  default_options = default_options.filter { |key, _| @option_key_names.include?(key) }
@@ -29,15 +29,14 @@ class Recipes::Admin < Rails::AppBuilder
29
29
  gem_exists?(/activeadmin/)
30
30
  end
31
31
 
32
- private
33
-
34
32
  def add_active_admin
33
+ recipe = self
35
34
  gather_gem 'activeadmin', '~> 2.9'
36
- gather_gem 'activeadmin_addons'
35
+ gather_gem 'activeadmin_addons', '~> 2.0.0.beta.0'
37
36
  add_readme_section :internal_dependencies, :active_admin
38
37
  after(:gem_install, wrap_in_action: :admin_install) do
39
38
  generate "active_admin:install --use_webpacker"
40
- run 'bin/yarn add @activeadmin/activeadmin'
39
+ run 'yarn add @activeadmin/activeadmin'
41
40
  line = "ActiveAdmin.setup do |config|"
42
41
  initializer = "config/initializers/active_admin.rb"
43
42
  gsub_file initializer, /(#{Regexp.escape(line)})/mi do |_match|
@@ -53,82 +52,54 @@ class Recipes::Admin < Rails::AppBuilder
53
52
  meta_tags_options = { viewport: 'width=device-width, initial-scale=1' }
54
53
  config.meta_tags = meta_tags_options
55
54
  config.meta_tags_for_logged_out_pages = meta_tags_options
55
+ config.comments = false
56
56
  HERE
57
57
  end
58
58
 
59
59
  generate "activeadmin_addons:install"
60
60
 
61
- run "bin/yarn add arctic_admin @fortawesome/fontawesome-free"
62
-
63
- aa_style = "app/javascript/stylesheets/active_admin.scss"
64
-
65
- gsub_file(
66
- aa_style,
67
- "@import \"~@activeadmin/activeadmin/src/scss/mixins\";\n" +
68
- "@import \"~@activeadmin/activeadmin/src/scss/base\";",
69
- <<~HERE
70
- @import '~arctic_admin/src/scss/main';
71
-
72
- // Fix for sidebar when there are too many filters
73
- #sidebar {
74
- height: 100vh;
75
- top: 0;
76
- z-index: 10;
77
- }
78
-
79
- #sidebar::before {
80
- top: 200px !important;
81
- }
82
-
83
- #filters_sidebar_section {
84
- height: 100vh;
85
- overflow: auto;
86
- }
87
-
88
- // Fix for invisible datepicker calendar
89
- #ui-datepicker-div {
90
- z-index: 11 !important;
91
- }
92
-
93
- // Fix for backwards date range input
94
- #sidebar .sidebar_section .filter_date_range input:nth-child(2) {
95
- float: none;
96
- }
97
-
98
- #sidebar .sidebar_section .filter_date_range {
99
- display: flex;
100
- flex-flow: row wrap;
101
- justify-content: space-between
102
- }
103
-
104
- #sidebar .sidebar_section .filter_date_range label {
105
- width: 100%;
106
- }
107
- HERE
108
- )
109
-
110
- aa_js = "app/javascript/packs/active_admin.js"
111
- js_line = "import \"@activeadmin/activeadmin\";\n"
112
-
113
- gsub_file(
114
- aa_js,
115
- js_line,
116
- <<~HERE
117
- #{js_line}
118
- import '@fortawesome/fontawesome-free/css/all.css';
119
- import 'arctic_admin';
120
- HERE
121
- )
122
-
123
- run "mv app/javascript/packs/active_admin.js app/javascript/active_admin.js"
124
- gsub_file(
125
- "app/javascript/active_admin.js",
126
- 'import "../stylesheets/active_admin";',
127
- 'import "./stylesheets/active_admin.scss";'
128
- )
61
+ run "yarn add arctic_admin @fortawesome/fontawesome-free"
129
62
 
130
63
  run 'rm -rf config/webpack/plugins'
64
+ run 'rm app/javascript/packs/active_admin.js'
131
65
  run 'rm -rf app/javascript/packs/active_admin'
66
+ run 'rm app/javascript/stylesheets/active_admin.scss'
67
+ run 'rmdir app/javascript/packs'
68
+ run 'rmdir app/javascript/stylesheets'
69
+ run 'rmdir app/javascript'
70
+
71
+ recipe.copy_frontend_files
72
+ recipe.insert_vite_monkeypatch
132
73
  end
133
74
  end
75
+
76
+ def copy_frontend_files
77
+ copy_file '../assets/app/frontend/entrypoints/active_admin.js',
78
+ 'app/frontend/entrypoints/active_admin.js'
79
+ copy_file '../assets/app/frontend/entrypoints/active_admin.scss',
80
+ 'app/frontend/entrypoints/active_admin.scss'
81
+ copy_file '../assets/app/frontend/active_admin/jquery.js', 'app/frontend/active_admin/jquery.js'
82
+ end
83
+
84
+ def insert_vite_monkeypatch
85
+ monkeypatch =
86
+ <<~HERE
87
+ module ActiveAdminViteJS
88
+ def stylesheet_pack_tag(style, **options)
89
+ style = 'active_admin.scss' if style == 'active_admin.css'
90
+ vite_stylesheet_tag(style, **options)
91
+ end
92
+
93
+ def javascript_pack_tag(script, **options)
94
+ vite_javascript_tag(script, **options)
95
+ end
96
+ end
97
+
98
+ ActiveAdmin::Views::Pages::Base.include ActiveAdminViteJS
99
+ ActiveSupport.on_load(:action_view) { include ActiveAdminViteJS }
100
+
101
+ HERE
102
+ insert_into_file "config/initializers/active_admin.rb", monkeypatch,
103
+ before: "ActiveAdmin.setup do |config|"
104
+ end
134
105
  end
@@ -14,8 +14,6 @@ class Recipes::BackgroundProcessor < Rails::AppBuilder
14
14
  def create
15
15
  if get(:background_processor)
16
16
  add_sidekiq
17
- add_docker_compose_redis_config
18
- set_redis_dot_env
19
17
  end
20
18
  end
21
19
 
@@ -40,7 +38,6 @@ class Recipes::BackgroundProcessor < Rails::AppBuilder
40
38
  append_to_file(".env.development", "DB_POOL=25\n")
41
39
  template("../assets/sidekiq.rb.erb", "config/initializers/sidekiq.rb", force: true)
42
40
  copy_file("../assets/sidekiq.yml", "config/sidekiq.yml", force: true)
43
- copy_file("../assets/redis.yml", "config/redis.yml", force: true)
44
41
  recipe.mount_sidekiq_routes
45
42
  end
46
43
  end
@@ -68,33 +65,6 @@ class Recipes::BackgroundProcessor < Rails::AppBuilder
68
65
 
69
66
  private
70
67
 
71
- def add_docker_compose_redis_config
72
- compose = DockerHelpers.new('docker-compose.yml')
73
-
74
- service_definition =
75
- <<~YAML
76
- image: redis
77
- ports:
78
- - 6379
79
- volumes:
80
- - redis_data:/data
81
- YAML
82
-
83
- compose.add_service('redis', service_definition)
84
- compose.add_volume('redis_data')
85
- end
86
-
87
- def set_redis_dot_env
88
- append_to_file(
89
- '.env.development',
90
- <<~TEXT
91
- REDIS_HOST=127.0.0.1
92
- REDIS_PORT=$(make services-port SERVICE=redis PORT=6379)
93
- REDIS_URL=redis://${REDIS_HOST}:${REDIS_PORT}/1
94
- TEXT
95
- )
96
- end
97
-
98
68
  def enabled_mailer?
99
69
  mailer_answer = get(:email_service)
100
70
  mailer_answer && ![:none, :None].include?(mailer_answer.to_sym)
@@ -0,0 +1,41 @@
1
+ class Recipes::Bullet < Rails::AppBuilder
2
+ def create
3
+ gather_gem 'bullet'
4
+ recipe = self
5
+ after(:gem_install) do
6
+ recipe.bullet_config
7
+ end
8
+ end
9
+
10
+ def installed?
11
+ gem_exists?(/bullet/)
12
+ end
13
+
14
+ def install
15
+ create
16
+ end
17
+
18
+ def bullet_config
19
+ application bullet_after_initialize, env: "development"
20
+ insert_into_file "app/jobs/application_job.rb", bullet_application_job_config, before: "end"
21
+ end
22
+
23
+ private
24
+
25
+ def bullet_after_initialize
26
+ <<~RUBY
27
+ config.after_initialize do
28
+ Bullet.enable = true
29
+ Bullet.alert = true
30
+ Bullet.bullet_logger = true
31
+ Bullet.console = true
32
+ Bullet.rails_logger = true
33
+ Bullet.add_footer = true
34
+ end
35
+ RUBY
36
+ end
37
+
38
+ def bullet_application_job_config
39
+ " include Bullet::ActiveJob if Rails.env.development?\n"
40
+ end
41
+ end
@@ -1,11 +1,16 @@
1
1
  class Recipes::Ci < Rails::AppBuilder
2
2
  def create
3
3
  template '../assets/.circleci/config.yml.erb', '.circleci/config.yml'
4
+ gather_gem 'repo_analyzer'
4
5
 
5
6
  gather_gems(:test) do
6
7
  gather_gem 'rspec_junit_formatter', '~> 0.4'
7
8
  end
8
9
 
10
+ gather_gems(:development, :test) do
11
+ gather_gem('brakeman')
12
+ end
13
+
9
14
  add_readme_header :ci
10
15
  application 'config.assets.js_compressor = :uglifier', env: 'test'
11
16
  end
@@ -4,6 +4,5 @@ class Recipes::Cleanup < Rails::AppBuilder
4
4
  erase_comments "config/environments/production.rb"
5
5
  erase_comments "config/environments/test.rb"
6
6
  erase_comments "config/environments/development.rb"
7
- cut_comments "config/initializers/backtrace_silencers.rb", limit: 100
8
7
  end
9
8
  end
@@ -4,9 +4,8 @@ class Recipes::Coverage < Rails::AppBuilder
4
4
  configure_rails_helper
5
5
  append_to_file('.gitignore', "/coverage/*\n")
6
6
  recipe = self
7
- after(:setup_jest) do
8
- recipe.configure_jest_coverage
9
- recipe.setup_jest_text_formatter
7
+ after(:vite_install) do
8
+ recipe.setup_coverage_dependencies
10
9
  end
11
10
  end
12
11
 
@@ -18,16 +17,8 @@ class Recipes::Coverage < Rails::AppBuilder
18
17
  create
19
18
  end
20
19
 
21
- def configure_jest_coverage
22
- json_file = File.read(Pathname.new("package.json"))
23
- js_package = JSON.parse(json_file)
24
- js_package = add_coverage_config(js_package)
25
- json_string = JSON.pretty_generate(js_package)
26
- create_file 'package.json', json_string, force: true
27
- end
28
-
29
- def setup_jest_text_formatter
30
- run "bin/yarn add jest-text-formatter@1.0.2 --dev"
20
+ def setup_coverage_dependencies
21
+ run "yarn add c8 --dev"
31
22
  end
32
23
 
33
24
  private
@@ -49,18 +40,4 @@ class Recipes::Coverage < Rails::AppBuilder
49
40
  end
50
41
  end
51
42
  end
52
-
53
- def add_coverage_config(js_package)
54
- js_package['scripts']['test:changes'] = 'jest --changedSince=master'
55
- js_package['jest'] = js_package['jest'].merge(coverage_defaults)
56
- js_package
57
- end
58
-
59
- def coverage_defaults
60
- {
61
- collectCoverage: true,
62
- collectCoverageFrom: ['**/*.{js,ts,vue}', '!**/node_modules/**'],
63
- coverageReporters: ['text']
64
- }
65
- end
66
43
  end
@@ -81,7 +81,7 @@ class Recipes::DatabaseContainer < Rails::AppBuilder
81
81
 
82
82
  # Database
83
83
  DB_HOST=127.0.0.1
84
- DB_PORT=$(make services-port SERVICE=#{_service_name} PORT=#{_port})
84
+ DB_PORT=COMMAND_EXPAND(make services-port SERVICE=#{_service_name} PORT=#{_port})
85
85
  DB_USER=#{_user}
86
86
 
87
87
  TEXT
@@ -0,0 +1,18 @@
1
+ class Recipes::EnvironmentVariables < Rails::AppBuilder
2
+ def create
3
+ template '../assets/.env.test.erb', '.env.test'
4
+ copy_file '../assets/lib/environment_variables.rb', 'lib/environment_variables.rb'
5
+
6
+ application(before_configuration_require)
7
+ end
8
+
9
+ private
10
+
11
+ def before_configuration_require
12
+ <<~RUBY
13
+ config.before_configuration do
14
+ require Rails.root.join('lib/environment_variables.rb')
15
+ end
16
+ RUBY
17
+ end
18
+ end
@@ -8,7 +8,7 @@ class Recipes::ErrorReporting < Rails::AppBuilder
8
8
 
9
9
  def create
10
10
  if selected?(:report_error)
11
- gather_gem 'sentry-raven'
11
+ gather_gem 'sentry-rails'
12
12
  template '../assets/config/sentry.rb.erb', 'config/initializers/sentry.rb'
13
13
  append_to_file '.env.development', "SENTRY_DSN=\n"
14
14
  add_readme_section :internal_dependencies, :sentry
@@ -21,6 +21,6 @@ class Recipes::ErrorReporting < Rails::AppBuilder
21
21
  end
22
22
 
23
23
  def installed?
24
- gem_exists?(/sentry-raven/) && file_exist?('config/initializers/sentry.rb')
24
+ gem_exists?(/sentry-rails/) && file_exist?('config/initializers/sentry.rb')
25
25
  end
26
26
  end