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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81ec8c6408ed21f78421ecb48565bcd42e6478fc0a08a7ca0881035eb8d0c444
4
- data.tar.gz: 0b925fa5a1344c3f284d91f8fdb092d984d47f8434b4beed51678e4a909e2ada
3
+ metadata.gz: bf8fa48bec3abe9c9a5a0b78b1bce9e5d3a16a7ae2026ca7675a46b4cd65900e
4
+ data.tar.gz: d0eb6c8fbc7d0efec8f2920ad3b94c240ec344ee8e0a5606072016193889f5e3
5
5
  SHA512:
6
- metadata.gz: 8a07cf43e021c0350e84eb0213f5ac513fa2446c16cfd492a0b7947acdd45776b817004d5f4cf42962947137dc988ccaa1e61020f23b89a63040b85d04e61a2e
7
- data.tar.gz: af4598c990bede9a8be8cbf47dd324f9f13b584b5b0982ab277806f71318b4d97da289e9cad725d45398e66cc7454578bd89fc086b550ebc586286d46d217f98
6
+ metadata.gz: 555b3a8191c0eb1cee82b0fab20796827ee7e9a2191e61c9e462ab907ded83279e5e4a3472160db52cb43068dd5d969c07a9712767dedfafa769c436f647416f
7
+ data.tar.gz: 2e7358f4f012301fa59add914bc80692a3e135025bab6fc96c007c50f46808fcc19b33c21cca2876475f3f7ce978b0a9d0b4a01b8ac9f65113620427314c2569
data/.circleci/config.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  version: 2.1
2
2
 
3
- ruby-image: &ruby-image cimg/ruby:2.7.4-node
3
+ ruby-image: &ruby-image cimg/ruby:2.7
4
4
  env-vars: &env-vars
5
5
  BUNDLE_JOBS: 4
6
6
  RAILS_ENV: test
@@ -32,6 +32,14 @@ commands:
32
32
  gem install bundler:2.1.4
33
33
  bundle _2.1.4_ install
34
34
 
35
+ - run:
36
+ name: Install node and yarn
37
+ command: |
38
+ curl -sL https://deb.nodesource.com/setup_$(cat .node-version).x | sudo -E bash -
39
+ sudo apt-get install -y nodejs
40
+ curl -o- -sL https://yarnpkg.com/install.sh | bash
41
+ sudo ln -s $HOME/.yarn/bin/yarn /usr/local/bin/yarn
42
+
35
43
  - save_cache:
36
44
  key: potassium-vendor-bundle-{{ .Branch }}
37
45
  paths:
data/.node-version CHANGED
@@ -1 +1 @@
1
- 14
1
+ 20
data/.rubocop.yml CHANGED
@@ -528,3 +528,7 @@ RSpec/ExpectChange:
528
528
  EnforcedStyle: block
529
529
  RSpec/BeforeAfterAll:
530
530
  Enabled: false
531
+ RSpec/Focus:
532
+ AutoCorrect: false
533
+ RSpec/MultipleMemoizedHelpers:
534
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,45 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ ## 7.1.0
6
+ Features
7
+ - Add environment variables module recipe [#435](https://github.com/platanus/potassium/pull/435)
8
+ - Run [Brakeman](https://brakemanscanner.org/) with reviewdog on CI [#440](https://github.com/platanus/potassium/pull/440)
9
+ - Changes to a couple of rspec rubocop rules [#441](https://github.com/platanus/potassium/pull/441)
10
+ - Update node to 20 [#447](https://github.com/platanus/potassium/pull/447)
11
+
12
+ Fixes
13
+ - Fix CircleCI config [#434](https://github.com/platanus/potassium/pull/434)
14
+ - Fix `cannot load such file -- sassc` error [#436](https://github.com/platanus/potassium/pull/436)
15
+ - Set jsdom version for node compatibility [#436](https://github.com/platanus/potassium/pull/436)
16
+ - Fix `uninitialized constant RubocopHelpers::RuboCop` [#436](https://github.com/platanus/potassium/pull/436)
17
+ - Use Redis for sessions to address security issues [#437](https://github.com/platanus/potassium/pull/437)
18
+ - Comment vue mount in admin js to address security issues [#438](https://github.com/platanus/potassium/pull/438)
19
+ - Remove ActiveAdmin comments to address security issues [#439](https://github.com/platanus/potassium/pull/439)
20
+ - Various fixes related to TS, vite and vitest [#444](https://github.com/platanus/potassium/pull/444)
21
+
22
+ ## 7.0.0
23
+
24
+ Features
25
+ - Updates to ActiveAdmin Addons 2 (beta) [#431](https://github.com/platanus/potassium/pull/431)
26
+ - Replaces Shakapacker with Vite [#431](https://github.com/platanus/potassium/pull/431)
27
+ - Update to Rails 7 [#431](https://github.com/platanus/potassium/pull/431)
28
+ - Install repo analyzer gem to run in CI environment
29
+ - Removes enumerize in favor of built-in enums [#428](https://github.com/platanus/potassium/pull/428)
30
+ - Add linter rule to enforce the use of named exports [#427](https://github.com/platanus/potassium/pull/427)
31
+ - Enable new rubocop rules [#429](https://github.com/platanus/potassium/pull/429)
32
+ <details>
33
+ <summary>See rules</summary>
34
+
35
+ - [Rails/Delegate](https://docs.rubocop.org/rubocop-rails/2.17/cops_rails.html#railsdelegate)
36
+ - [Rails/I18nLocaleAssignment](https://docs.rubocop.org/rubocop-rails/2.17/cops_rails.html#railsi18nlocaleassignment)
37
+ - [Rails/WhereEquals](https://docs.rubocop.org/rubocop-rails/2.17/cops_rails.html#railswhereequals)
38
+ - [Rails/WhereNot](https://docs.rubocop.org/rubocop-rails/2.17/cops_rails.html#railswherenot)
39
+ - [Rails/RedundantPresenceValidationOnBelongsTo](https://docs.rubocop.org/rubocop-rails/cops_rails.html#railsredundantpresencevalidationonbelongsto)
40
+ - [Layout/ClassStructure](https://docs.rubocop.org/rubocop/1.24/cops_layout.html#layoutclassstructure)
41
+ </details>
42
+
3
43
  ## 6.7.0
4
44
 
5
45
  Features
data/README.md CHANGED
@@ -43,12 +43,18 @@ This will create a project with the following configuration:
43
43
  13. `draper`: `true`
44
44
  14. `schedule`: `true`
45
45
  15. `sentry`: `true`
46
- 16. `front_end`: `'vue'`
46
+ 16. `front_end_vite`: `true`
47
47
  17. `google_tag_manager`: `true`
48
48
  18. `test`: `true`
49
49
  19. `spring`: `true`
50
50
 
51
51
  The remaining question will be asked as usual.
52
+
53
+ ### Running from Repository
54
+
55
+ If you cloned this repository and are running the gem using the bin script (`potassium/bin/potassium create`), take careful note of the gem versions that are used. Sometimes the local Rails version is used instead of the one specified in the gemspec. Remove your local Gemfile.lock after pulling from the repository to help prevent these issues.
56
+
57
+
52
58
  ### Adding recipes to an existing project
53
59
 
54
60
  Use the `potassium install` command to add a recipe to a project:
@@ -82,6 +88,7 @@ Potassium Rails apps includes the following gems and technologies:
82
88
  - [Faker](https://github.com/stympy/faker) for creating development data
83
89
  - [Scout](https://github.com/scoutapp/scout_apm_ruby) for monitoring performance
84
90
  - [Mjml](https://github.com/sighmon/mjml-rails) for mails style
91
+ - [Bullet](https://github.com/flyerhzm/bullet) to identify eager loading (N+1 queries)
85
92
 
86
93
  The following optional integrations are also added:
87
94
 
data/docs/CONTRIBUTING.md CHANGED
@@ -14,13 +14,13 @@ Now, to add some behavior, thanks to the [DSL](/docs/DSL.md) we have a kind of s
14
14
  4. Install the gems, filling the `Gemfile` before with all the gathered gems.
15
15
  5. Finally, create the database.
16
16
 
17
- The main step is the 3rd, when we call the `create` methods from the recipes. A recipe can do anything (because is a ruby script) but their responsability should be to gather gems and register callbacks for the process.
17
+ The main step is the 3rd, when we call the `create` methods from the recipes. A recipe can do anything (because is a ruby script) but their responsibility should be to gather gems and register callbacks for the process.
18
18
 
19
19
  ### Recipe
20
20
 
21
21
  The recipes are classes defined in the `Recipes` module that inherit from
22
22
  `Rails::AppBuilder` and by convention can implement some of the following
23
- methods `ask`, `create` and `install`. So they took this form.
23
+ methods `ask`, `create` and `install`. They take this form.
24
24
 
25
25
  ```ruby
26
26
  class Recipes::MyRecipe < Rails::AppBuilder
@@ -73,7 +73,7 @@ This method is used if you need to ask something to the user before doing someth
73
73
 
74
74
  We'll call this method to add specific functionality to the rails project.
75
75
 
76
- 1. In the `create` method register a gem using `gather_gem` and create a callback to be called after the `gem_install` action succeded to run the generator. `gem_install` is one of the main actions that should be easily visible with a sneak peek in [the template][the-template].
76
+ 1. In the `create` method register a gem using `gather_gem` and create a callback to be called after the `gem_install` action succeeds to run the generator. `gem_install` is one of the main actions that should be easily visible with a sneak peek in [the template][the-template].
77
77
 
78
78
  ```ruby
79
79
  def create
@@ -99,8 +99,8 @@ We'll call this method to add specific functionality to the rails project.
99
99
  ##### | `install`
100
100
 
101
101
  The install method will be called when you use the `install` command from potassium.
102
- For example if you run `portassium install devise` this will use
103
- [the recipe template](/lib/potassium/templates/recipe.rb) to load an execute the
102
+ For example, if you run `potassium install devise` this will use
103
+ [the recipe template](/lib/potassium/templates/recipe.rb) to load and execute the
104
104
  `install` method for the **devise** recipe.
105
105
 
106
106
  You can define the main functionallity of a recipe in a private method and call
@@ -127,6 +127,6 @@ end
127
127
 
128
128
  To see further documentation of what we added to the rails template's DSL, check the [DSL documentation](/docs/DSL.md).
129
129
 
130
- > Remember that the DSL we are documenting is an extension over the [Rails Application Template DSL](http://edgeguides.rubyonrails.org/rails_application_templates.html), that itself is a dsl based on [Thor](https://github.com/erikhuda/thor/wiki).
130
+ > Remember that the DSL we are documenting is an extension over the [Rails Application Template DSL](http://edgeguides.rubyonrails.org/rails_application_templates.html), that itself is a DSL based on [Thor](https://github.com/erikhuda/thor/wiki).
131
131
 
132
132
  [the-template]: /lib/potassium/templates/application.rb
@@ -4,9 +4,7 @@ ruby-image: &ruby-image cimg/ruby:<%= ruby_version %>
4
4
  <%- if selected?(:database, :postgresql) -%>
5
5
  postgres-image: &postgres-image postgres:<%= Potassium::POSTGRES_VERSION %>
6
6
  <%- end -%>
7
- <%- if selected?(:background_processor) -%>
8
- redis-image: &redis-image redis
9
- <%- end -%>
7
+ redis-image: &redis-image cimg/redis:6.2.12
10
8
  env-vars: &env-vars
11
9
  BUNDLE_JOBS: 4
12
10
  BUNDLE_PATH: vendor/bundle
@@ -23,9 +21,7 @@ executors:
23
21
  <%- if selected?(:database, :postgresql) -%>
24
22
  - image: *postgres-image
25
23
  <%- end -%>
26
- <%- if selected?(:background_processor) -%>
27
24
  - image: *redis-image
28
- <%- end -%>
29
25
 
30
26
  lint-executor:
31
27
  docker:
@@ -94,11 +90,10 @@ jobs:
94
90
  - browser-tools/install-chrome
95
91
  - browser-tools/install-chromedriver
96
92
 
97
- <%- if selected?(:background_processor) -%>
98
93
  - run:
99
94
  name: Wait for redis service
100
95
  command: dockerize -wait tcp://localhost:6379 -timeout 1m
101
- <%- end -%>
96
+
102
97
  <%- if selected?(:database, :postgresql) -%>
103
98
  - run:
104
99
  name: Wait for postgres service
@@ -116,6 +111,14 @@ jobs:
116
111
  RSPEC_FORMAT_ARGS="-f progress --no-color -p 10"
117
112
  bundle exec rspec spec $RSPEC_FORMAT_ARGS $RSPEC_JUNIT_ARGS
118
113
 
114
+ - run:
115
+ name: Update repo analyzer gem
116
+ command: bundle update --conservative repo_analyzer
117
+
118
+ - run:
119
+ name: POST extracted data to nest
120
+ command: bin/rake "repo_analyzer:analyze[platanus/<%= get(:github_repo_name) || get(:dasherized_app_name) %>]"
121
+
119
122
  - run:
120
123
  name: Run simplecov
121
124
  shell: /bin/bash
@@ -129,14 +132,10 @@ jobs:
129
132
  RSPEC_FORMAT_ARGS="--tag type:system -f progress --no-color -p 10"
130
133
  bundle exec rspec spec $RSPEC_FORMAT_ARGS $RSPEC_JUNIT_ARGS
131
134
 
132
- <%- if selected?(:front_end, :vue) -%>
133
135
  - run:
134
- name: Run jest
136
+ name: Run vitest
135
137
  command: |
136
- yarn run test > coverage/input_jest.txt
137
- ./node_modules/.bin/format-coverage coverage/input_jest.txt coverage/output_jest.txt /home/circleci/project/app/javascript
138
- cat coverage/output_jest.txt | ./bin/reviewdog -reporter=github-pr-review -efm="%f:%l:%c: %m"
139
- <%- end -%>
138
+ yarn run test
140
139
 
141
140
  - store_test_results:
142
141
  path: test_results
@@ -146,6 +145,13 @@ jobs:
146
145
  steps:
147
146
  - setup
148
147
 
148
+ - run:
149
+ name: Run brakeman
150
+ shell: /bin/bash
151
+ command: |
152
+ bundle exec brakeman --quiet --format tabs --no-exit-on-warn --no-exit-on-error --output "tmp/brakeman_report"; \
153
+ ./bin/reviewdog < "tmp/brakeman_report" -reporter=github-pr-review -f=brakeman -name="Brakeman"
154
+
149
155
  - run:
150
156
  name: Get files to lint
151
157
  command: git diff origin/master --name-only --diff-filter=d > tmp/files_to_lint
@@ -5,3 +5,4 @@ DEFAULT_EMAIL_ADDRESS=
5
5
  EXECJS_RUNTIME=Node
6
6
  SECRET_KEY_BASE=development_secret
7
7
  WEB_CONCURRENCY=1
8
+ APPLICATION_HOST=localhost:3000
@@ -0,0 +1 @@
1
+ APPLICATION_HOST=localhost:3000
@@ -3,14 +3,13 @@
3
3
  "browser": true,
4
4
  "es2021": true,
5
5
  "node": true,
6
- "jest/globals": true,
7
6
  "vue/setup-compiler-macros": true
8
7
  },
9
8
  "parserOptions": {
10
9
  "ecmaVersion": 2020,
11
10
  "sourceType": "module"
12
11
  },
13
- "plugins": ["import", "jest", "tailwindcss"],
12
+ "plugins": ["import", "tailwindcss"],
14
13
  "settings": {
15
14
  "import/resolver": {
16
15
  "node": {
@@ -209,7 +208,7 @@
209
208
  "newlines-between": "never"
210
209
  }],
211
210
  "import/newline-after-import": 2,
212
- "import/prefer-default-export": 2,
211
+ "import/no-default-export": 2,
213
212
  "array-bracket-spacing": [2, "never"],
214
213
  "block-spacing": [2, "always"],
215
214
  "brace-style": [2, "1tbs", {
@@ -255,7 +254,7 @@
255
254
  "lines-around-comment": 0,
256
255
  "max-depth": [2, 4],
257
256
  "max-len": [2, 120, {
258
- "ignorePattern": "^\\s.+class=\""
257
+ "ignorePattern": "^\\s.+class=|\\s.d=\""
259
258
  }],
260
259
  "max-nested-callbacks": [2, 4],
261
260
  "max-params": [1, 4],
@@ -287,7 +286,7 @@
287
286
  "no-new-object": 2,
288
287
  "no-plusplus": 0,
289
288
  "no-restricted-syntax": [2, "DebuggerStatement", "ForInStatement", "LabeledStatement", "WithStatement"],
290
- "no-spaced-func": 2,
289
+ "no-spaced-func": 0,
291
290
  "no-ternary": 0,
292
291
  "no-trailing-spaces": 2,
293
292
  "no-underscore-dangle": [1],
@@ -346,14 +345,20 @@
346
345
  "vue/max-len": ["error", {
347
346
  "code": 120,
348
347
  "ignoreHTMLAttributeValues": true
348
+ }],
349
+ "tailwindcss/no-custom-classname": ["warn", {
350
+ "cssFiles": ["**/*.css", "!**/node_modules", "!**/.*", "!**/dist", "!**/build", "!**/vendor"]
349
351
  }]
350
352
  },
351
353
  "overrides": [
352
354
  {
353
- "files": ["*.ts", "*.vue"],
354
- "rules": {
355
- "no-undef": "off"
356
- }
355
+ "files": ["*.ts", "*.vue"],
356
+ "rules": {
357
+ "no-undef": "off",
358
+ "no-unused-vars": "off",
359
+ "no-spaced-func": "off",
360
+ "@typescript-eslint/no-unused-vars": "error"
361
+ }
357
362
  }
358
363
  ]
359
364
  }
@@ -282,6 +282,59 @@ Style/SymbolArray:
282
282
  Layout/ExtraSpacing:
283
283
  Description: Do not use unnecessary spacing.
284
284
  Enabled: false
285
+ Layout/ClassStructure:
286
+ Enabled: true
287
+ Categories:
288
+ validation:
289
+ - validate
290
+ - validates
291
+ association:
292
+ - belongs_to
293
+ - has_one
294
+ - has_many
295
+ - has_and_belongs_to_many
296
+ attribute_macros:
297
+ - attribute
298
+ - attr_accessor
299
+ - attr_reader
300
+ - attr_writer
301
+ callbacks:
302
+ - before_validation
303
+ - after_validation
304
+ - before_save
305
+ - before_create
306
+ - after_create
307
+ - after_save
308
+ - after_commit
309
+ - after_create_commit
310
+ other_macros:
311
+ - devise
312
+ - acts_as_token_authenticatable
313
+ - accepts_nested_attributes_for
314
+ - humanize
315
+ - monetize
316
+ scope:
317
+ - scope
318
+ - pg_search_scope
319
+ ExpectedOrder:
320
+ - module_inclusion
321
+ - constants
322
+ - public_attribute_macros
323
+ - association
324
+ - validation
325
+ - enum
326
+ - aasm
327
+ - scope
328
+ - public_delegate
329
+ - other_macros
330
+ - class_methods
331
+ - initializer
332
+ - public_methods
333
+ - protected_attribute_macros
334
+ - protected_methods
335
+ - private_attribute_macros
336
+ - private_delegate
337
+ - private_methods
285
338
  Naming/AccessorMethodName:
286
339
  Description: Check the naming of accessor methods for get_/set_.
287
340
  Enabled: false
@@ -498,7 +551,15 @@ Lint/StructNewOverride:
498
551
  Enabled: true
499
552
  Rails/Delegate:
500
553
  Description: Prefer delegate method for delegations.
501
- Enabled: false
554
+ Enabled: true
555
+ Rails/I18nLocaleAssignment:
556
+ Enabled: true
557
+ Rails/WhereEquals:
558
+ Enabled: true
559
+ Rails/WhereNot:
560
+ Enabled: true
561
+ Rails/RedundantPresenceValidationOnBelongsTo:
562
+ Enabled: true
502
563
  Performance/RedundantBlockCall:
503
564
  Description: Use `yield` instead of `block.call`.
504
565
  Reference: https://github.com/JuanitoFatas/fast-ruby#proccall-vs-yield-code
@@ -527,3 +588,7 @@ RSpec/LetSetup:
527
588
  RSpec/ExpectChange:
528
589
  Enabled: true
529
590
  EnforcedStyle: block
591
+ RSpec/Focus:
592
+ AutoCorrect: false
593
+ RSpec/MultipleMemoizedHelpers:
594
+ Enabled: false
@@ -22,20 +22,14 @@ readme:
22
22
  $ heroku local
23
23
 
24
24
  [Heroku Local]: https://devcenter.heroku.com/articles/heroku-local
25
- webpack:
25
+ vite:
26
26
  title: "Development"
27
27
  body: |
28
- For hot-reloading and fast webpacker compilation you need to run webpack's dev server along with the rails server:
28
+ For hot-reloading and fast compilation you need to run the vite dev server along with the rails server:
29
29
 
30
- $ ./bin/webpacker-dev-server
30
+ $ ./bin/vite dev
31
31
 
32
32
  Running the dev server will also solve problems with the cache not refreshing between changes and provide better error messages if something fails to compile.
33
-
34
- For even faster in-place component refreshing (with no page reloads), you can enable Hot Module Reloading in `config/webpacker.yml`
35
-
36
- development:
37
- dev_server:
38
- hmr: true
39
33
  ci:
40
34
  title: "Continuous Integrations"
41
35
  body: |
@@ -0,0 +1,2 @@
1
+ import $ from 'jquery'
2
+ window.jQuery = window.$ = $
@@ -0,0 +1,3 @@
1
+ const api = vi.fn();
2
+
3
+ export { api };
@@ -0,0 +1,63 @@
1
+ import axios, { type AxiosRequestTransformer, type AxiosResponseTransformer } from 'axios';
2
+ import { convertKeys, type objectToConvert } from '../utils/case-converter';
3
+ import { csrfToken } from '../utils/csrf-token';
4
+
5
+ const api = axios.create({
6
+ transformRequest: [
7
+ (data: objectToConvert) => convertKeys(data, 'decamelize'),
8
+ ...(axios.defaults.transformRequest as AxiosRequestTransformer[]),
9
+ ],
10
+ transformResponse: [
11
+ ...(axios.defaults.transformResponse as AxiosResponseTransformer[]),
12
+ (data: objectToConvert) => convertKeys(data, 'camelize'),
13
+ ],
14
+ headers: {
15
+ 'Content-Type': 'application/json',
16
+ 'Accept': 'application/json',
17
+ 'X-CSRF-Token': csrfToken(),
18
+ },
19
+ });
20
+
21
+ export { api };
22
+
23
+ /*
24
+ // Example to use the api object in the path ´app/javascript/api/users.ts´
25
+
26
+ import { api } from './index';
27
+
28
+ function index() {
29
+ const path = '/api/internal/users';
30
+
31
+ return api({
32
+ method: 'get',
33
+ url: path,
34
+ });
35
+ }
36
+
37
+ function create(data: Partial<User>) {
38
+ const path = '/api/internal/users';
39
+
40
+ return api({
41
+ method: 'post',
42
+ url: path,
43
+ data: {
44
+ user: data,
45
+ },
46
+ });
47
+ }
48
+
49
+ function update(data: Partial<User>) {
50
+ const path = `/api/internal/users/${data.id}`;
51
+
52
+ return api({
53
+ method: 'put',
54
+ url: path,
55
+ data: {
56
+ user: data,
57
+ },
58
+ });
59
+ }
60
+
61
+ export { index, create, update };
62
+
63
+ */
@@ -0,0 +1,3 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
@@ -0,0 +1,7 @@
1
+ import '../active_admin/jquery'
2
+ import 'jquery-ui'
3
+ import 'jquery-ui/ui/widgets/mouse'
4
+ import '@activeadmin/activeadmin'
5
+ import "activeadmin_addons"
6
+ import "@fortawesome/fontawesome-free/css/all.css";
7
+ import 'arctic_admin'
@@ -0,0 +1,38 @@
1
+ @import 'activeadmin_addons/src/stylesheets/all';
2
+ @import 'arctic_admin/src/scss/main';
3
+
4
+ // Fix for sidebar when there are too many filters
5
+ #sidebar {
6
+ height: 100vh;
7
+ top: 0;
8
+ z-index: 10;
9
+ }
10
+
11
+ #sidebar::before {
12
+ top: 200px !important;
13
+ }
14
+
15
+ #filters_sidebar_section {
16
+ height: 100vh;
17
+ overflow: auto;
18
+ }
19
+
20
+ // Fix for invisible datepicker calendar
21
+ #ui-datepicker-div {
22
+ z-index: 11 !important;
23
+ }
24
+
25
+ // Fix for backwards date range input
26
+ #sidebar .sidebar_section .filter_date_range input:nth-child(2) {
27
+ float: none;
28
+ }
29
+
30
+ #sidebar .sidebar_section .filter_date_range {
31
+ display: flex;
32
+ flex-flow: row wrap;
33
+ justify-content: space-between
34
+ }
35
+
36
+ #sidebar .sidebar_section .filter_date_range label {
37
+ width: 100%;
38
+ }
@@ -0,0 +1,12 @@
1
+ import { createApp } from 'vue';
2
+ import App from '../components/app.vue';
3
+ import '../css/application.css';
4
+
5
+ document.addEventListener('DOMContentLoaded', () => {
6
+ const app = createApp({
7
+ components: { App },
8
+ });
9
+ app.mount('#vue-app');
10
+
11
+ return app;
12
+ });
@@ -1,3 +1,4 @@
1
+ /* eslint-disable import/no-default-export */
1
2
  declare module '*.vue' {
2
3
  import type { DefineComponent } from 'vue'
3
4
  const component: DefineComponent<{}, {}, any>
@@ -3,7 +3,7 @@
3
3
  /* eslint-disable max-statements */
4
4
  import { camelize, decamelize } from 'humps';
5
5
 
6
- type objectToConvert = File | FormData | Blob | Record<string, unknown> | Array<objectToConvert>;
6
+ export type objectToConvert = File | FormData | Blob | Record<string, unknown> | Array<objectToConvert>;
7
7
 
8
8
  function convertKeys(
9
9
  object: objectToConvert,
@@ -36,4 +36,4 @@ function convertKeys(
36
36
  return object;
37
37
  }
38
38
 
39
- export default convertKeys;
39
+ export { convertKeys };
@@ -0,0 +1,9 @@
1
+ // From: https://github.com/rails/rails/blob/main/actionview/app/javascript/rails-ujs/utils/csrf.js
2
+ function csrfToken() {
3
+ const meta = document.querySelector('meta[name=csrf-token]');
4
+ const token = meta && meta.getAttribute('content');
5
+
6
+ return token ?? false;
7
+ }
8
+
9
+ export { csrfToken };
@@ -11,7 +11,7 @@ gem install bundler --conservative
11
11
  bundle check || bundle install
12
12
 
13
13
  # Install javascript dependencies
14
- bin/yarn install
14
+ yarn install
15
15
 
16
16
  # Set up required services
17
17
  docker-compose up -d
@@ -18,7 +18,7 @@ chdir APP_ROOT do
18
18
  system! 'gem install bundler --conservative'
19
19
 
20
20
  puts '== Installing YARN stuff =='
21
- system! 'bin/yarn install'
21
+ system! 'yarn install'
22
22
 
23
23
  system('bundle check') || system!('bundle install')
24
24
  puts "\n== Updating database =="
@@ -0,0 +1,20 @@
1
+ # https://github.com/redis-store/redis-store/issues/358#issuecomment-1537920008
2
+ class RedisClient::Config
3
+ alias original_initialize initialize
4
+
5
+ def initialize(**kwargs)
6
+ # remove not supported kwargs
7
+ original_initialize(
8
+ **kwargs.except(:raw, :serializer, :marshalling, :namespace, :scheme)
9
+ )
10
+ end
11
+ end
12
+
13
+ Rails.application.config.session_store :redis_store, {
14
+ servers: [{
15
+ url: ENV['REDIS_URL']
16
+ }],
17
+ expire_after: 30.days,
18
+ key: '_app_session',
19
+ secure: Rails.env.production?
20
+ }
@@ -1,15 +1,7 @@
1
1
  if Rails.env.production?
2
- Raven.configure do |config|
3
- config.sanitize_fields = Rails.application.config.filter_parameters.map(&:to_s)
2
+ Sentry.init do |config|
4
3
  <% if get(:heroku) %>
5
- config.current_environment = Heroku.stage
4
+ config.environment = Heroku.stage
6
5
  <% end %>
7
6
  end
8
-
9
- # In case you want to group the events with different ids in the
10
- module RackTimeoutExtensions
11
- def raven_context
12
- { fingerprint: ["{{ default }}", env["REQUEST_PATH"].gsub(/\d/, '')] }
13
- end
14
- end
15
7
  end