rolemodel-rails 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +10 -2
- data/lib/generators/rolemodel/all_generator.rb +1 -0
- data/lib/generators/rolemodel/core_setup/README.md +27 -0
- data/lib/generators/rolemodel/core_setup/USAGE +12 -0
- data/lib/generators/rolemodel/core_setup/core_setup_generator.rb +19 -0
- data/lib/generators/rolemodel/github/README.md +4 -0
- data/lib/generators/rolemodel/github/templates/workflows/deploy-production.yml +34 -0
- data/lib/generators/rolemodel/github/templates/workflows/deploy-staging.yml +35 -0
- data/lib/generators/rolemodel/good_job/good_job_generator.rb +0 -2
- data/lib/generators/rolemodel/heroku/README.md +20 -1
- data/lib/generators/rolemodel/heroku/heroku_generator.rb +35 -0
- data/lib/generators/rolemodel/heroku/templates/app.json.tt +5 -2
- data/lib/generators/rolemodel/heroku/templates/deploy-app/SKILL.md +202 -0
- data/lib/generators/rolemodel/linters/eslint/eslint_generator.rb +1 -0
- data/lib/generators/rolemodel/linters/rubocop/rubocop_generator.rb +5 -1
- data/lib/generators/rolemodel/lograge/README.md +1 -1
- data/lib/generators/rolemodel/lograge/templates/config/initializers/lograge.rb +1 -1
- data/lib/generators/rolemodel/optics/base/base_generator.rb +1 -0
- data/lib/generators/rolemodel/react/react_generator.rb +1 -0
- data/lib/generators/rolemodel/readme/templates/README.md.erb +2 -4
- data/lib/generators/rolemodel/sentry/README.md +25 -0
- data/lib/generators/rolemodel/sentry/USAGE +13 -0
- data/lib/generators/rolemodel/sentry/sentry_generator.rb +126 -0
- data/lib/generators/rolemodel/sentry/templates/app/javascript/initializers/sentry.js +34 -0
- data/lib/generators/rolemodel/sentry/templates/config/initializers/sentry.rb +68 -0
- data/lib/generators/rolemodel/simple_form/README.md +6 -0
- data/lib/generators/rolemodel/simple_form/USAGE +3 -0
- data/lib/generators/rolemodel/simple_form/simple_form_generator.rb +11 -0
- data/lib/generators/rolemodel/simple_form/templates/app/inputs/switch_checkbox_input.rb +1 -1
- data/lib/generators/rolemodel/tailored_select/USAGE +2 -1
- data/lib/generators/rolemodel/tailored_select/tailored_select_generator.rb +15 -0
- data/lib/generators/rolemodel/testing/factory_bot/templates/support/factory_bot.rb +2 -0
- data/lib/generators/rolemodel/testing/jasmine_playwright/jasmine_playwright_generator.rb +2 -2
- data/lib/generators/rolemodel/testing/rspec/templates/spec/rails_helper.rb.tt +4 -1
- data/lib/generators/rolemodel/testing/rspec/templates/spec/support/capybara_drivers.rb.tt +2 -0
- data/lib/generators/rolemodel/testing/rspec/templates/spec/support/helpers/action_cable_helper.rb +2 -0
- data/lib/generators/rolemodel/testing/rspec/templates/spec/support/helpers/test_element_helper.rb +2 -0
- data/lib/generators/rolemodel/testing/rspec/templates/spec/support/helpers.rb.tt +3 -1
- data/lib/generators/rolemodel/testing/vitest/vitest_generator.rb +1 -0
- data/lib/generators/rolemodel/ui_components/modals/modals_generator.rb +1 -0
- data/lib/generators/rolemodel/ui_components/modals/templates/app/helpers/turbo_frame_link_helper.rb +2 -0
- data/lib/generators/rolemodel/ui_components/navbar/navbar_generator.rb +1 -0
- data/lib/generators/rolemodel/webpack/README.md +2 -1
- data/lib/generators/rolemodel/webpack/templates/webpack.config.js +2 -12
- data/lib/generators/rolemodel/webpack/webpack_generator.rb +19 -11
- data/lib/rolemodel/generator_base.rb +37 -0
- data/lib/rolemodel/version.rb +1 -1
- data/lib/rolemodel-rails.rb +1 -0
- metadata +13 -12
- data/lib/generators/rolemodel/linters/rubocop/templates/lib/cops/form_error_response.rb +0 -54
- data/lib/generators/rolemodel/linters/rubocop/templates/lib/cops/no_chrome_tag.rb +0 -45
- data/lib/generators/rolemodel/semaphore/README.md +0 -15
- data/lib/generators/rolemodel/semaphore/USAGE +0 -11
- data/lib/generators/rolemodel/semaphore/semaphore_generator.rb +0 -25
- data/lib/generators/rolemodel/semaphore/templates/heroku-deployment-commands.sh +0 -3
- data/lib/generators/rolemodel/semaphore/templates/production-deploy.yml.erb +0 -17
- data/lib/generators/rolemodel/semaphore/templates/semaphore.yml.erb +0 -145
- data/lib/generators/rolemodel/semaphore/templates/staging-deploy.yml.erb +0 -17
- data/lib/generators/rolemodel/webpack/templates/app/javascript/initializers/honeybadger.js +0 -26
- /data/lib/generators/rolemodel/{simple_form → tailored_select}/templates/app/inputs/tailored_select_input.rb +0 -0
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Cops
|
|
4
|
-
# Custom Cop to Ensure Form Error Response Statuses
|
|
5
|
-
#
|
|
6
|
-
# There are three levels of matching here:
|
|
7
|
-
# Methods (def on_if)
|
|
8
|
-
# This scans code and only stops on the method specified.
|
|
9
|
-
# E.G. `on_if` will only move into the below checks when it encounters an if statement.
|
|
10
|
-
#
|
|
11
|
-
# Node matcher (def_node_matcher :form_error)
|
|
12
|
-
# This scans the block of code (in this case, the else branch of the if block)
|
|
13
|
-
# using AST (Abstract Tree Syntax) to match certain patterns
|
|
14
|
-
#
|
|
15
|
-
# Regex
|
|
16
|
-
# This checks the specific matching line to ensure it meets our expectations
|
|
17
|
-
class FormErrorResponse < RuboCop::Cop::Base
|
|
18
|
-
extend RuboCop::Cop::AutoCorrector
|
|
19
|
-
|
|
20
|
-
def self.rack_version
|
|
21
|
-
Gem.loaded_specs['rack'].version
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def self.http_status
|
|
25
|
-
if rack_version >= '3.1'
|
|
26
|
-
:unprocessable_content
|
|
27
|
-
else
|
|
28
|
-
:unprocessable_entity
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# Match code in the else branch that either: is the only line and looks like `render :something, ...`
|
|
33
|
-
# or is not the first line and looks like the same.
|
|
34
|
-
def_node_matcher :form_error, <<~PATTERN
|
|
35
|
-
{(... $(send nil? :render (:sym _) ...)) | $(send nil? :render (:sym _) ...)}
|
|
36
|
-
PATTERN
|
|
37
|
-
|
|
38
|
-
MSG = "Use status: :#{self.http_status} for invalid form requests."
|
|
39
|
-
|
|
40
|
-
# Ensure the render is returning the correct status, otherwise add the offense
|
|
41
|
-
STATUS_PAIR = /\(pair\s+\(sym :status\)\s+\(sym :#{self.http_status}\)\)/m
|
|
42
|
-
|
|
43
|
-
# Only check within if blocks
|
|
44
|
-
def on_if(node)
|
|
45
|
-
form_error(node.else_branch) do |name|
|
|
46
|
-
next if name.to_s.match?(STATUS_PAIR)
|
|
47
|
-
|
|
48
|
-
add_offense(name) do |corrector|
|
|
49
|
-
corrector.insert_after(name, ", status: :#{self.class.http_status}")
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'rubocop'
|
|
4
|
-
|
|
5
|
-
module Cops
|
|
6
|
-
# Detect occurences of the chrome tag in specs, and warn and remove them.
|
|
7
|
-
class NoChromeTag < RuboCop::Cop::Base
|
|
8
|
-
include RuboCop::Cop::RangeHelp
|
|
9
|
-
extend RuboCop::Cop::AutoCorrector
|
|
10
|
-
|
|
11
|
-
MSG = 'The :chrome tag is only for testing, and should not be checked into the repository.'
|
|
12
|
-
RESTRICT_ON_SEND = %i[describe context it feature scenario].freeze
|
|
13
|
-
|
|
14
|
-
def on_send(node) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
|
15
|
-
node.arguments.each do |a|
|
|
16
|
-
if a.sym_type? && a.value == :chrome
|
|
17
|
-
range = range_with_surrounding_comma(a.source_range)
|
|
18
|
-
add_offense(range) do |corrector|
|
|
19
|
-
corrector.replace(range, '')
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
next unless a.hash_type?
|
|
24
|
-
|
|
25
|
-
a.pairs.each do |pair|
|
|
26
|
-
next unless pair.key.value == :chrome
|
|
27
|
-
|
|
28
|
-
range = range_with_surrounding_comma(pair.source_range)
|
|
29
|
-
add_offense(range) do |corrector|
|
|
30
|
-
corrector.replace(range, '')
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def range_with_surrounding_comma(source_range)
|
|
37
|
-
buffer = source_range.source_buffer
|
|
38
|
-
src = buffer.source
|
|
39
|
-
end_pos = source_range.end_pos
|
|
40
|
-
comma_index = src[...end_pos].rindex(/\s*,\s*/)
|
|
41
|
-
|
|
42
|
-
Parser::Source::Range.new(buffer, comma_index, end_pos)
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# Semaphore Generator
|
|
2
|
-
|
|
3
|
-
## What you get
|
|
4
|
-
|
|
5
|
-
* semaphore.yml file to run the relevant CI commands
|
|
6
|
-
* heroku-deployment-commands.sh file with commands to deploy to heroku
|
|
7
|
-
* staging-deploy.yml file with commands to deploy to staging
|
|
8
|
-
* production-deploy.yml file with commands to deploy to production
|
|
9
|
-
|
|
10
|
-
This is the basic config needed to use semaphore.
|
|
11
|
-
|
|
12
|
-
## Note
|
|
13
|
-
This config assumes
|
|
14
|
-
- `main` is the base branch
|
|
15
|
-
- `yarn test` is the command to run JS tests
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
module Rolemodel
|
|
2
|
-
class SemaphoreGenerator < GeneratorBase
|
|
3
|
-
source_root File.expand_path('templates', __dir__)
|
|
4
|
-
|
|
5
|
-
def create_base_semaphore_config
|
|
6
|
-
@project_name = Rails.application.class.try(:parent_name) || Rails.application.class.module_parent_name
|
|
7
|
-
template 'semaphore.yml.erb', '.semaphore/semaphore.yml'
|
|
8
|
-
|
|
9
|
-
if yes?('Does your project have JavaScript tests and/or eslint?')
|
|
10
|
-
uncomment_lines('.semaphore/semaphore.yml', '- yarn test')
|
|
11
|
-
uncomment_lines('.semaphore/semaphore.yml', '- yarn run eslint')
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def create_deplyment_commands
|
|
16
|
-
default_heroku_prefix = (Rails.application.class.try(:parent_name) || Rails.application.class.module_parent_name).underscore.dasherize
|
|
17
|
-
|
|
18
|
-
@heroku_prefix = ask('Enter the heroku project prefix', default: default_heroku_prefix)
|
|
19
|
-
|
|
20
|
-
template 'heroku-deployment-commands.sh', '.semaphore/heroku-deployment-commands.sh'
|
|
21
|
-
template 'staging-deploy.yml.erb', '.semaphore/staging-deploy.yml'
|
|
22
|
-
template 'production-deploy.yml.erb', '.semaphore/production-deploy.yml'
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
version: v1.0
|
|
2
|
-
name: Deploy to Production
|
|
3
|
-
agent:
|
|
4
|
-
machine:
|
|
5
|
-
type: e1-standard-2
|
|
6
|
-
os_image: ubuntu1804
|
|
7
|
-
blocks:
|
|
8
|
-
- name: Deploy
|
|
9
|
-
task:
|
|
10
|
-
secrets:
|
|
11
|
-
- name: heroku_http_auth
|
|
12
|
-
env_vars:
|
|
13
|
-
- name: HEROKU_APP_NAME
|
|
14
|
-
value: <%= "#{@heroku_prefix}-production" %>
|
|
15
|
-
jobs:
|
|
16
|
-
- name: 'Push code to Production'
|
|
17
|
-
commands_file: heroku-deployment-commands.sh
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
version: v1.0
|
|
2
|
-
name: <%= @project_name %>
|
|
3
|
-
agent:
|
|
4
|
-
machine:
|
|
5
|
-
type: e1-standard-2
|
|
6
|
-
os_image: ubuntu2004
|
|
7
|
-
auto_cancel:
|
|
8
|
-
running:
|
|
9
|
-
when: branch != 'main'
|
|
10
|
-
global_job_config:
|
|
11
|
-
env_vars:
|
|
12
|
-
- name: RAILS_ENV
|
|
13
|
-
value: test
|
|
14
|
-
- name: HONEYBADGER_SOURCE_MAP_DISABLED
|
|
15
|
-
value: 'true'
|
|
16
|
-
- name: DATABASE_URL
|
|
17
|
-
value: 'postgres://postgres:@0.0.0.0/<%= Rails.application.config.database_configuration['test']['database'] %>'
|
|
18
|
-
- name: GOOGLE_CHROME_BIN
|
|
19
|
-
value: 'google-chrome'
|
|
20
|
-
# https://github.com/renderedtext/test-boosters#rspec-booster
|
|
21
|
-
- name: TB_RSPEC_OPTIONS
|
|
22
|
-
value: '--format RspecJunitFormatter --out tmp/test_results/rspec_junit.xml --format documentation'
|
|
23
|
-
secrets:
|
|
24
|
-
- name: rmsbackup_ssh_private_key
|
|
25
|
-
prologue:
|
|
26
|
-
commands:
|
|
27
|
-
# Add keys
|
|
28
|
-
- ssh-keyscan -H github.com >> ~/.ssh/known_hosts
|
|
29
|
-
- chmod 600 ~/.ssh/id_rsa_rmsbackup_ssh_private_key
|
|
30
|
-
- ssh-add ~/.ssh/id_rsa_rmsbackup_ssh_private_key
|
|
31
|
-
|
|
32
|
-
- checkout
|
|
33
|
-
|
|
34
|
-
# Ruby setup
|
|
35
|
-
- sem-service start postgres 14
|
|
36
|
-
- sem-version ruby $(cat .ruby-version)
|
|
37
|
-
- gem install bundler --no-document
|
|
38
|
-
- bundle config set deployment 'true'
|
|
39
|
-
- bundle config set path 'vendor/bundle'
|
|
40
|
-
|
|
41
|
-
# Node setup
|
|
42
|
-
- sem-version node $(cat .node-version)
|
|
43
|
-
- npm i -g yarn
|
|
44
|
-
|
|
45
|
-
# Cache setup
|
|
46
|
-
- cache restore gems-$(checksum .ruby-version)-$(checksum Gemfile.lock)
|
|
47
|
-
- cache restore yarn-cache-$(checksum .node-version)-$(checksum yarn.lock)
|
|
48
|
-
- cache restore yarn-node-modules-$(checksum .node-version)-$(checksum yarn.lock)
|
|
49
|
-
blocks:
|
|
50
|
-
- name: Build
|
|
51
|
-
dependencies: []
|
|
52
|
-
task:
|
|
53
|
-
jobs:
|
|
54
|
-
- name: Install Dependencies
|
|
55
|
-
commands:
|
|
56
|
-
- bundle check || bundle install
|
|
57
|
-
- yarn check || yarn install
|
|
58
|
-
epilogue:
|
|
59
|
-
commands:
|
|
60
|
-
- cache store gems-$(checksum .ruby-version)-$(checksum Gemfile.lock) vendor/bundle
|
|
61
|
-
- cache store yarn-cache-$(checksum .node-version)-$(checksum yarn.lock) /home/semaphore/.cache/yarn
|
|
62
|
-
- cache store yarn-node-modules-$(checksum .node-version)-$(checksum yarn.lock) node_modules
|
|
63
|
-
- name: Ruby/JS/Linting
|
|
64
|
-
execution_time_limit:
|
|
65
|
-
minutes: 20
|
|
66
|
-
dependencies:
|
|
67
|
-
- Build
|
|
68
|
-
task:
|
|
69
|
-
jobs:
|
|
70
|
-
- name: Ruby Test/JS Tests/Audit/Linting
|
|
71
|
-
commands:
|
|
72
|
-
- bundle exec rails db:setup db:test:prepare
|
|
73
|
-
- bundle exec rspec --exclude-pattern "spec/system/**/*_spec.rb" --format RspecJunitFormatter --out tmp/test_results/rspec_junit.xml --format documentation
|
|
74
|
-
- bundle exec bundle-audit update
|
|
75
|
-
- bundle exec bundle-audit check
|
|
76
|
-
# - bundle exec rubocop --fail-level warning --display-only-fail-level-offenses
|
|
77
|
-
# - yarn test
|
|
78
|
-
# - yarn run eslint
|
|
79
|
-
epilogue:
|
|
80
|
-
always:
|
|
81
|
-
commands:
|
|
82
|
-
- test-results publish tmp/test_results
|
|
83
|
-
on_fail:
|
|
84
|
-
commands:
|
|
85
|
-
- artifact push job log/test.log
|
|
86
|
-
- name: Assets Compile
|
|
87
|
-
dependencies:
|
|
88
|
-
- Build
|
|
89
|
-
execution_time_limit:
|
|
90
|
-
minutes: 20
|
|
91
|
-
task:
|
|
92
|
-
jobs:
|
|
93
|
-
- name: Webpack Compile and Store Assets
|
|
94
|
-
commands:
|
|
95
|
-
- bundle check || bundle install --without legacy_data_migration
|
|
96
|
-
- yarn check || yarn install
|
|
97
|
-
- yarn build
|
|
98
|
-
- cache store assets-public-$SEMAPHORE_WORKFLOW_ID public
|
|
99
|
-
- name: System Tests
|
|
100
|
-
dependencies:
|
|
101
|
-
- Assets Compile
|
|
102
|
-
execution_time_limit:
|
|
103
|
-
minutes: 20
|
|
104
|
-
task:
|
|
105
|
-
agent:
|
|
106
|
-
machine:
|
|
107
|
-
type: e1-standard-2
|
|
108
|
-
os_image: ubuntu2004
|
|
109
|
-
env_vars:
|
|
110
|
-
- name: TEST_BOOSTERS_RSPEC_TEST_FILE_PATTERN
|
|
111
|
-
value: spec/system/**/*_spec.rb
|
|
112
|
-
prologue:
|
|
113
|
-
commands:
|
|
114
|
-
- gem install semaphore_test_boosters
|
|
115
|
-
- bundle exec rails db:setup db:test:prepare
|
|
116
|
-
- cache restore assets-public-$SEMAPHORE_WORKFLOW_ID
|
|
117
|
-
jobs:
|
|
118
|
-
- name: Ruby System Tests
|
|
119
|
-
parallelism: 2
|
|
120
|
-
commands:
|
|
121
|
-
- rspec_booster --job $SEMAPHORE_JOB_INDEX/$SEMAPHORE_JOB_COUNT
|
|
122
|
-
epilogue:
|
|
123
|
-
always:
|
|
124
|
-
commands:
|
|
125
|
-
- test-results publish tmp/test_results
|
|
126
|
-
- cache delete assets-public-$SEMAPHORE_WORKFLOW_ID
|
|
127
|
-
on_fail:
|
|
128
|
-
commands:
|
|
129
|
-
- artifact push job log/test.log
|
|
130
|
-
- artifact push workflow tmp/capybara
|
|
131
|
-
after_pipeline:
|
|
132
|
-
task:
|
|
133
|
-
jobs:
|
|
134
|
-
- name: Publish Results
|
|
135
|
-
commands:
|
|
136
|
-
- test-results gen-pipeline-report
|
|
137
|
-
promotions:
|
|
138
|
-
- name: Deploy Staging
|
|
139
|
-
pipeline_file: staging-deploy.yml
|
|
140
|
-
auto_promote_on:
|
|
141
|
-
- result: passed
|
|
142
|
-
branch:
|
|
143
|
-
- main
|
|
144
|
-
- name: Deploy Production
|
|
145
|
-
pipeline_file: production-deploy.yml
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
version: v1.0
|
|
2
|
-
name: Deploy to Staging
|
|
3
|
-
agent:
|
|
4
|
-
machine:
|
|
5
|
-
type: e1-standard-2
|
|
6
|
-
os_image: ubuntu1804
|
|
7
|
-
blocks:
|
|
8
|
-
- name: Deploy
|
|
9
|
-
task:
|
|
10
|
-
secrets:
|
|
11
|
-
- name: heroku_http_auth
|
|
12
|
-
env_vars:
|
|
13
|
-
- name: HEROKU_APP_NAME
|
|
14
|
-
value: <%= "#{@heroku_prefix}-staging" %>
|
|
15
|
-
jobs:
|
|
16
|
-
- name: 'Push code to staging'
|
|
17
|
-
commands_file: heroku-deployment-commands.sh
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import Honeybadger from '@honeybadger-io/js'
|
|
2
|
-
|
|
3
|
-
if (process.env.RAILS_ENV === 'production') {
|
|
4
|
-
Honeybadger.configure({
|
|
5
|
-
apiKey: process.env.HONEYBADGER_API_KEY,
|
|
6
|
-
environment: process.env.HONEYBADGER_ENV,// ‘production’ or ‘review-app’ from app.json
|
|
7
|
-
revision: process.env.SOURCE_VERSION // provided by heroku
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
const IGNORE_ERRORS = [
|
|
11
|
-
/AbortError/,
|
|
12
|
-
/UnhandledPromiseRejectionWarning: {}/,
|
|
13
|
-
/UnhandledPromiseRejectionWarning.*Load failed/,
|
|
14
|
-
/UnhandledPromiseRejectionWarning: Object Not Found Matching/,
|
|
15
|
-
/UnhandledPromiseRejectionWarning.*Failed to fetch/,
|
|
16
|
-
/ResizeObserver loop completed with undelivered notifications./,
|
|
17
|
-
]
|
|
18
|
-
|
|
19
|
-
Honeybadger.beforeNotify((notice) => {
|
|
20
|
-
for (const ignoreError of IGNORE_ERRORS) {
|
|
21
|
-
if (ignoreError.test(notice.message)) {
|
|
22
|
-
return false
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
}
|
|
File without changes
|