rails_app_generator 0.1.10 → 0.1.13
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/CHANGELOG.md +21 -0
- data/after_templates/addons/honeybadger/_.rb +46 -0
- data/after_templates/addons/honeybadger/app/controllers/application_controller.rb +9 -0
- data/after_templates/addons/honeybadger/app/controllers/errors_controller.rb +17 -0
- data/after_templates/addons/honeybadger/app/controllers/products_controller.rb +72 -0
- data/after_templates/addons/honeybadger/app/views/home/index.html.erb +49 -0
- data/after_templates/addons/honeybadger/public/404.html +69 -0
- data/after_templates/addons/honeybadger/public/500.html +68 -0
- data/after_templates/addons/rails_html_sanitizer/_.rb +15 -0
- data/after_templates/addons/rails_html_sanitizer/home/index.html.erb +31 -0
- data/after_templates/addons/{rails_html_sanitizer → rails_html_sanitizer_xxx/home}/index.html.erb +0 -0
- data/lib/rails_app_generator/add_on.rb +36 -0
- data/lib/rails_app_generator/addons/honeybadger.rb +19 -0
- data/lib/rails_app_generator/app_generator.rb +58 -32
- data/lib/rails_app_generator/options/rails_options.rb +1 -0
- data/lib/rails_app_generator/version.rb +1 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- data/profiles/addons/honeybadger.json +12 -0
- data/profiles/addons/rails-html-sanitizer.json +2 -2
- data/tasks/addon.thor +48 -24
- data/tasks/profile.thor +88 -9
- data/templates/addons/honeybadger/en.yml +10 -0
- data/templates/addons/honeybadger/honeybadger.sample.yml +37 -0
- data/templates/thor_task/addon/addon.tt +13 -6
- data/templates/thor_task/profile/after_template.rb.tt +44 -0
- data/templates/thor_task/profile/home/index.html.erb.tt +7 -0
- data/templates/thor_task/profile/profile.json.tt +12 -0
- metadata +33 -19
- data/after_templates/addons/rails_html_sanitizer.rb +0 -15
- data/templates/app_x/controllers/authorized_controller.rb.erb +0 -10
- data/templates/app_x/controllers/errors_controller.rb.erb +0 -24
- data/templates/app_x/javascript/images/checkmark.svg +0 -1
- data/templates/app_x/javascript/images/logo.svg +0 -1
- data/templates/app_x/javascript/stylesheets/components.scss +0 -206
- data/templates/app_x/views/errors/internal_error.html.erb +0 -14
- data/templates/app_x/views/errors/not_found.html.erb +0 -14
- data/templates/app_x/views/errors/unacceptable.html.erb +0 -14
- data/templates/app_x/views/layouts/application.html.erb.tt +0 -30
- data/templates/app_x/views/pages/home.html.erb.tt +0 -20
- data/templates/app_x/views/shared/_flashes.html.erb.tt +0 -12
- data/templates/app_x/views/shared/_footer.html.erb.tt +0 -21
- data/templates/app_x/views/shared/_navbar.html.erb.tt +0 -55
- data/templates/app_x/workers/application_worker.rb +0 -5
- data/templates/thor_task/profile/after_template.tt +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1505eaa23b41f69afe5f4060221b479ae01209f1a76df69577ef715b17c9455f
|
4
|
+
data.tar.gz: f33d5a7001365a84503d2640053604e3e6fe52632f54f0c03c17fe36ff83c869
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00b2d94306f636e25800d4d6ed09d8536535f47c630662ee6beda2939dbf871e01721d2978e19dc6bb5c0e281f47913d73535bfb2ef8ecaee427726e9308be7f
|
7
|
+
data.tar.gz: 3dde1c772e2d56ad34d9b190742c25725e744145e4754630425613ced8525e026d935a671f8335b3fb60a56122547b0bc589845bb9f1de61689c94a74b5e0070
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
## [0.1.12](https://github.com/klueless-io/rails_app_generator/compare/v0.1.11...v0.1.12) (2022-08-02)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* update rails-html-sanitizer example ([7f3a2d8](https://github.com/klueless-io/rails_app_generator/commit/7f3a2d810a968748baf4f8a4a147b086a26781c0))
|
7
|
+
|
8
|
+
## [0.1.11](https://github.com/klueless-io/rails_app_generator/compare/v0.1.10...v0.1.11) (2022-08-02)
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* add thor task to create profiles ([0ec4ae0](https://github.com/klueless-io/rails_app_generator/commit/0ec4ae01a2879fc627422cb79e4cbc685e78dcb8))
|
14
|
+
|
15
|
+
## [0.1.10](https://github.com/klueless-io/rails_app_generator/compare/v0.1.9...v0.1.10) (2022-08-02)
|
16
|
+
|
17
|
+
|
18
|
+
### Bug Fixes
|
19
|
+
|
20
|
+
* refactor GemInfo ([9294d5f](https://github.com/klueless-io/rails_app_generator/commit/9294d5faff71e69f6812868c976a26171a12d4c5))
|
21
|
+
|
1
22
|
## [0.1.9](https://github.com/klueless-io/rails_app_generator/compare/v0.1.8...v0.1.9) (2022-08-02)
|
2
23
|
|
3
24
|
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# require 'pry'
|
4
|
+
|
5
|
+
# Make managing application errors a more pleasant experience.
|
6
|
+
#
|
7
|
+
# exe/rag addons/honeybadger
|
8
|
+
# see: https://honeybadger.wistia.com/medias/l3cmyucx8f
|
9
|
+
|
10
|
+
self.local_template_path = File.dirname(__FILE__)
|
11
|
+
|
12
|
+
gac 'base rails 7 image created'
|
13
|
+
|
14
|
+
add_controller('home', 'index')
|
15
|
+
route("root 'home#index'")
|
16
|
+
|
17
|
+
force_copy
|
18
|
+
|
19
|
+
copy_file 'app/views/home/index.html.erb', 'app/views/home/index.html.erb'
|
20
|
+
copy_file 'app/controllers/application_controller.rb', 'app/controllers/application_controller.rb'
|
21
|
+
copy_file 'app/controllers/errors_controller.rb', 'app/controllers/errors_controller.rb'
|
22
|
+
|
23
|
+
# Test if this is really needed
|
24
|
+
insert_into_file 'config/application.rb', after: 'class Application < Rails::Application' do
|
25
|
+
<<-RUBY
|
26
|
+
config.generators.system_tests = nil
|
27
|
+
RUBY
|
28
|
+
end
|
29
|
+
|
30
|
+
copy_file 'public/404.html', 'public/404.html'
|
31
|
+
copy_file 'public/500.html', 'public/500.html'
|
32
|
+
|
33
|
+
copy_file 'config/locales/en.yml', 'config/locales/en.yml'
|
34
|
+
|
35
|
+
move_file('config/honeybadger.sample.yml', 'config/honeybadger.yml')
|
36
|
+
|
37
|
+
after_bundle do
|
38
|
+
setup_db
|
39
|
+
end
|
40
|
+
|
41
|
+
def setup_db
|
42
|
+
add_scaffold('product', 'name', 'price:integer')
|
43
|
+
copy_file 'app/controllers/products_controller.rb', 'app/controllers/products_controller.rb'
|
44
|
+
|
45
|
+
db_migrate
|
46
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class ErrorsController < ApplicationController
|
2
|
+
def not_found
|
3
|
+
render status: 404
|
4
|
+
end
|
5
|
+
|
6
|
+
def internal_server
|
7
|
+
render status: 500
|
8
|
+
end
|
9
|
+
|
10
|
+
def unprocessable
|
11
|
+
render status: 422
|
12
|
+
end
|
13
|
+
|
14
|
+
def unacceptable
|
15
|
+
render status: 406
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
class ProductsController < ApplicationController
|
2
|
+
before_action :set_product, only: %i[ show edit update destroy ]
|
3
|
+
|
4
|
+
# GET /products or /products.json
|
5
|
+
def index
|
6
|
+
@products = Product.all
|
7
|
+
end
|
8
|
+
|
9
|
+
# GET /products/1 or /products/1.json
|
10
|
+
def show
|
11
|
+
end
|
12
|
+
|
13
|
+
# GET /products/new
|
14
|
+
def new
|
15
|
+
# remove this comment to see error in Honeybadger
|
16
|
+
raise 'Oh No!'
|
17
|
+
@product = Product.new
|
18
|
+
end
|
19
|
+
|
20
|
+
# GET /products/1/edit
|
21
|
+
def edit
|
22
|
+
end
|
23
|
+
|
24
|
+
# POST /products or /products.json
|
25
|
+
def create
|
26
|
+
@product = Product.new(product_params)
|
27
|
+
|
28
|
+
respond_to do |format|
|
29
|
+
if @product.save
|
30
|
+
format.html { redirect_to product_url(@product), notice: "Product was successfully created." }
|
31
|
+
format.json { render :show, status: :created, location: @product }
|
32
|
+
else
|
33
|
+
format.html { render :new, status: :unprocessable_entity }
|
34
|
+
format.json { render json: @product.errors, status: :unprocessable_entity }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# PATCH/PUT /products/1 or /products/1.json
|
40
|
+
def update
|
41
|
+
respond_to do |format|
|
42
|
+
if @product.update(product_params)
|
43
|
+
format.html { redirect_to product_url(@product), notice: "Product was successfully updated." }
|
44
|
+
format.json { render :show, status: :ok, location: @product }
|
45
|
+
else
|
46
|
+
format.html { render :edit, status: :unprocessable_entity }
|
47
|
+
format.json { render json: @product.errors, status: :unprocessable_entity }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# DELETE /products/1 or /products/1.json
|
53
|
+
def destroy
|
54
|
+
@product.destroy
|
55
|
+
|
56
|
+
respond_to do |format|
|
57
|
+
format.html { redirect_to products_url, notice: "Product was successfully destroyed." }
|
58
|
+
format.json { head :no_content }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
# Use callbacks to share common setup or constraints between actions.
|
64
|
+
def set_product
|
65
|
+
@product = Product.find(params[:id])
|
66
|
+
end
|
67
|
+
|
68
|
+
# Only allow a list of trusted parameters through.
|
69
|
+
def product_params
|
70
|
+
params.require(:product).permit(:name, :price)
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
<h1>Honeybadger</h1>
|
2
|
+
|
3
|
+
<h2>Make managing application errors a more pleasant experience.</h2>
|
4
|
+
|
5
|
+
<p>Follow the instructions below and then click on products -> new</p>
|
6
|
+
|
7
|
+
<%= link_to 'Products', products_path %>
|
8
|
+
|
9
|
+
<h2>Instructions</h2>
|
10
|
+
|
11
|
+
<p>If you want to see 404/500 HTML inplace of the debug routing error when in development then alter the following file</p>
|
12
|
+
|
13
|
+
<b>config/environments/development.rb</b>
|
14
|
+
<pre>
|
15
|
+
|
16
|
+
# config.consider_all_requests_local = true
|
17
|
+
config.consider_all_requests_local = false
|
18
|
+
|
19
|
+
</pre>
|
20
|
+
|
21
|
+
<p>If you want to see the exception message in Honeybadger then make sure then remove the comment<p>
|
22
|
+
|
23
|
+
<b>config/honeybadger.yml</b>
|
24
|
+
|
25
|
+
<pre>
|
26
|
+
# report_data: true
|
27
|
+
report_data: true
|
28
|
+
</pre>
|
29
|
+
|
30
|
+
<p>If you want to send the exception message to Honeybadger then make sure your remove development from the list<p>
|
31
|
+
|
32
|
+
<pre>
|
33
|
+
# development_environments:
|
34
|
+
- test
|
35
|
+
- development
|
36
|
+
- cucumber
|
37
|
+
</pre>
|
38
|
+
|
39
|
+
<p>Test frrom the command line using</p>
|
40
|
+
|
41
|
+
<pre>
|
42
|
+
bundle exec honeybadger test
|
43
|
+
</pre>
|
44
|
+
|
45
|
+
<p>More information can be found at
|
46
|
+
<a href="http://honeybadger.io/">http://honeybadger.io/</a> and
|
47
|
+
<a hreg="https://honeybadger.wistia.com/medias/l3cmyucx8f">https://honeybadger.wistia.com/medias/l3cmyucx8f</a>
|
48
|
+
|
49
|
+
</p>
|
@@ -0,0 +1,69 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
.rails-default-error-page {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
.rails-default-error-page div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
.rails-default-error-page div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
.rails-default-error-page h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
.rails-default-error-page div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body class="rails-default-error-page">
|
58
|
+
<!-- This file lives in public/404.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
<!-- HONEYBADGER FEEDBACK -->
|
67
|
+
<!-- HONEYBADGER ERROR -->
|
68
|
+
</body>
|
69
|
+
</html>
|
@@ -0,0 +1,68 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
.rails-default-error-page {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
.rails-default-error-page div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
.rails-default-error-page div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
.rails-default-error-page h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
.rails-default-error-page div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body class="rails-default-error-page">
|
58
|
+
<!-- This file lives in public/500.html -->
|
59
|
+
<!-- HONEYBADGER FEEDBACK -->
|
60
|
+
<!-- HONEYBADGER ERROR -->
|
61
|
+
<div class="dialog">
|
62
|
+
<div>
|
63
|
+
<h1>We're sorry, but something went wrong.</h1>
|
64
|
+
</div>
|
65
|
+
<p>If you are the application owner check the logs for more information.</p>
|
66
|
+
</div>
|
67
|
+
</body>
|
68
|
+
</html>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# HTML sanitization for Rails applications
|
4
|
+
require 'pry'
|
5
|
+
|
6
|
+
self.local_template_path = File.dirname(__FILE__)
|
7
|
+
|
8
|
+
gac 'base rails 7 image created'
|
9
|
+
|
10
|
+
add_controller('home', 'index')
|
11
|
+
route("root 'home#index'")
|
12
|
+
|
13
|
+
force_copy
|
14
|
+
|
15
|
+
copy_file 'home/index.html.erb', 'app/views/home/index.html.erb'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<h1>Rails HTML Sanitizer</h1>
|
2
|
+
|
3
|
+
<p>Read more here <a href="https://github.com/rails/rails-html-sanitizer">rails-html-sanitizer</a></p>
|
4
|
+
|
5
|
+
<textarea rows="4" cols="200">
|
6
|
+
full_sanitizer = Rails::Html::FullSanitizer.new
|
7
|
+
full_sanitizer.sanitize("<b>Bold</b> no more! <a href='more.html'>See more here</a>...")
|
8
|
+
</textarea>
|
9
|
+
|
10
|
+
<hr>
|
11
|
+
<%=
|
12
|
+
Rails::Html::FullSanitizer
|
13
|
+
.new
|
14
|
+
.sanitize("<b>Bold</b> no more! <a href='more.html'>See more here</a>...")
|
15
|
+
%>
|
16
|
+
|
17
|
+
<br/><br/><br/>
|
18
|
+
|
19
|
+
<hr>
|
20
|
+
|
21
|
+
<textarea rows="4" cols="200">
|
22
|
+
link_sanitizer = Rails::Html::LinkSanitizer.new
|
23
|
+
link_sanitizer.sanitize('<a href="example.com">Only the link text will be kept.</a>')
|
24
|
+
# => Only the link text will be kept.
|
25
|
+
</textarea>
|
26
|
+
|
27
|
+
<%=
|
28
|
+
Rails::Html::LinkSanitizer
|
29
|
+
.new
|
30
|
+
.sanitize('<a href="example.com">Only the link text will be kept.</a>')
|
31
|
+
%>
|
data/after_templates/addons/{rails_html_sanitizer → rails_html_sanitizer_xxx/home}/index.html.erb
RENAMED
File without changes
|
@@ -21,6 +21,7 @@ module RailsAppGenerator
|
|
21
21
|
def apply; end
|
22
22
|
|
23
23
|
# list any methods that you want access to, but not to be exposed as a thor command
|
24
|
+
# rubocop:disable Metrics/BlockLength
|
24
25
|
no_commands do
|
25
26
|
def source_paths
|
26
27
|
[
|
@@ -43,7 +44,42 @@ module RailsAppGenerator
|
|
43
44
|
klass = addon_name.nil? ? self.class : self.class.get(addon_name)
|
44
45
|
Dependencies.new(klass, context).satisfied?
|
45
46
|
end
|
47
|
+
|
48
|
+
def read_template(template_file)
|
49
|
+
path = find_in_source_paths(template_file)
|
50
|
+
|
51
|
+
File.read(path)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Moves a file at given location, to another location. Both files are relative to the destination_root
|
55
|
+
#
|
56
|
+
# ==== Parameters
|
57
|
+
# path<String>:: source_path of the file to be moved (relative to destination_root)
|
58
|
+
# path<String>:: target_path of the file moving to (relative to destination_root)
|
59
|
+
# config<Hash>:: give :verbose => false to not log the status.
|
60
|
+
#
|
61
|
+
# ==== Example
|
62
|
+
#
|
63
|
+
# move_file 'README', 'readme.md'
|
64
|
+
# move_file 'config/xmen.sample.yml', 'config/xmen.yml
|
65
|
+
#
|
66
|
+
# rubocop:disable Metrics/AbcSize
|
67
|
+
def move_file(source_path, target_path, config = {})
|
68
|
+
source = File.expand_path(source_path, destination_root)
|
69
|
+
target = File.expand_path(target_path, destination_root)
|
70
|
+
config.merge!({ verbose: true })
|
71
|
+
|
72
|
+
say_status :move_file_source, relative_to_original_destination_root(source), config.fetch(:verbose, true)
|
73
|
+
say_status :move_file_source, relative_to_original_destination_root(target), config.fetch(:verbose, true)
|
74
|
+
|
75
|
+
return unless !options[:pretend] && File.exist?(source)
|
76
|
+
|
77
|
+
require 'fileutils'
|
78
|
+
::FileUtils.mv(source, target)
|
79
|
+
end
|
80
|
+
# rubocop:enable Metrics/AbcSize
|
46
81
|
end
|
82
|
+
# rubocop:enable Metrics/BlockLength
|
47
83
|
|
48
84
|
class << self
|
49
85
|
def apply(context = Context.new({}))
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RailsAppGenerator
|
4
|
+
# Custom add-ons for RailsAppGenerator
|
5
|
+
module AddOns
|
6
|
+
# Add Honeybadger to rails application
|
7
|
+
class Honeybadger < AddOn
|
8
|
+
required_gem gem.version('honeybadger', '4.12.1', 'Make managing application errors a more pleasant experience.')
|
9
|
+
|
10
|
+
def apply
|
11
|
+
run('bundle exec honeybadger install 1111')
|
12
|
+
say 'Update the honeybadger.yml file with your API key.'
|
13
|
+
|
14
|
+
copy_file('honeybadger.sample.yml', 'config/honeybadger.sample.yml')
|
15
|
+
append_to_file('config/locales/en.yml', read_template('en.yml'))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -149,6 +149,7 @@ module RailsAppGenerator
|
|
149
149
|
# gem "net-sftp", "3.0.0"
|
150
150
|
# gem "prawn", "2.4.0"
|
151
151
|
# gem "prawn-table", "0.2.2"
|
152
|
+
# gem "appraisal"
|
152
153
|
|
153
154
|
class_option :add_irbrc , type: :boolean, default: false
|
154
155
|
class_option :add_foreman , type: :boolean, default: false
|
@@ -173,6 +174,7 @@ module RailsAppGenerator
|
|
173
174
|
|
174
175
|
# NEW GEM ADDONS
|
175
176
|
class_option :add_rails_html_sanitizer , type: :boolean, default: false
|
177
|
+
class_option :add_honeybadger , type: :boolean, default: false
|
176
178
|
|
177
179
|
class << self
|
178
180
|
# points to the original rails templates
|
@@ -300,6 +302,7 @@ module RailsAppGenerator
|
|
300
302
|
# # add(:rspec) if options[:testing_framework] == 'rspec'
|
301
303
|
# end
|
302
304
|
|
305
|
+
# rubocop:disable Metrics/AbcSize
|
303
306
|
def finish_template
|
304
307
|
puts 'finish template'
|
305
308
|
|
@@ -315,34 +318,18 @@ module RailsAppGenerator
|
|
315
318
|
add(:views, :errors, :scaffold) if options[:add_views]
|
316
319
|
add_if(:factory_bot)
|
317
320
|
add_if(:shoulda)
|
321
|
+
add_if(:rails_app_generator)
|
322
|
+
add_if(:honeybadger)
|
318
323
|
|
319
324
|
# invoke :rails_customization
|
320
325
|
super
|
321
326
|
end
|
327
|
+
# rubocop:enable Metrics/AbcSize
|
322
328
|
|
323
329
|
no_commands do
|
324
|
-
#
|
325
|
-
# gac 'base rails 7 image created'
|
326
|
-
# force_copy
|
327
|
-
# add_controller('home', 'index')
|
328
|
-
# add_scaffold('people', 'first_name', 'last_name', 'age:integer', 'address:text')
|
329
|
-
# route("root 'home#index'")
|
330
|
-
# css_install('tailwind')
|
331
|
-
# rails_command('db:migrate')
|
332
|
-
# db_migrate
|
333
|
-
# bundle_add('hotwire-rails')
|
334
|
-
# rails_command('hotwire:install')
|
335
|
-
# run('bin/importmap pin sortablejs')
|
336
|
-
# run('npm install daisyui')
|
337
|
-
# create_file 'app/assets/stylesheets/custom-bootstrap-import.scss' , read_template('custom-bootstrap-import.scss')
|
338
|
-
# append_to_file 'app/assets/config/manifest.js' , read_template('manifest.js')
|
339
|
-
# insert_into_file 'app/views/layouts/application.html.erb', read_template('application.html.erb')
|
340
|
-
# insert_into_file 'app/views/layouts/application.html.erb', read_template('application.html.erb'),
|
341
|
-
# before: %( <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>)
|
342
|
-
|
343
|
-
# gsub_file 'app/views/layouts/application.html.erb', %(container mx-auto mt-28 px-5 flex), 'container mx-auto px-5'
|
344
|
-
# template 'home.css', 'app/assets/stylesheets/home.css'
|
330
|
+
# https://codingpackets.com/blog/rails-generators-cheat-sheet/
|
345
331
|
|
332
|
+
# OLD style will be removed soon
|
346
333
|
def local_template_base(xxx)
|
347
334
|
File.join(File.dirname(xxx), File.basename(xxx, '.*'))
|
348
335
|
end
|
@@ -395,6 +382,10 @@ module RailsAppGenerator
|
|
395
382
|
run("bundle add #{name}")
|
396
383
|
end
|
397
384
|
|
385
|
+
def bundle_exec(name, *args)
|
386
|
+
run("bundle exec #{name} #{args.join(' ')}")
|
387
|
+
end
|
388
|
+
|
398
389
|
# If you need to manually install tailwind (instead of using the --template option)
|
399
390
|
# you can use css_install('tailwind')
|
400
391
|
def css_install(name)
|
@@ -434,6 +425,34 @@ module RailsAppGenerator
|
|
434
425
|
template_files.map { |template_file| read_template(template_file) }.join(join)
|
435
426
|
end
|
436
427
|
|
428
|
+
# Moves a file at given location, to another location. Both files are relative to the destination_root
|
429
|
+
#
|
430
|
+
# ==== Parameters
|
431
|
+
# path<String>:: source_path of the file to be moved (relative to destination_root)
|
432
|
+
# path<String>:: target_path of the file moving to (relative to destination_root)
|
433
|
+
# config<Hash>:: give :verbose => false to not log the status.
|
434
|
+
#
|
435
|
+
# ==== Example
|
436
|
+
#
|
437
|
+
# move_file 'README', 'readme.md'
|
438
|
+
# move_file 'config/xmen.sample.yml', 'config/xmen.yml
|
439
|
+
#
|
440
|
+
# rubocop:disable Metrics/AbcSize
|
441
|
+
def move_file(source_path, target_path, config = {})
|
442
|
+
source = File.expand_path(source_path, destination_root)
|
443
|
+
target = File.expand_path(target_path, destination_root)
|
444
|
+
config.merge!({ verbose: true })
|
445
|
+
|
446
|
+
say_status :move_file_source, relative_to_original_destination_root(source), config.fetch(:verbose, true)
|
447
|
+
say_status :move_file_source, relative_to_original_destination_root(target), config.fetch(:verbose, true)
|
448
|
+
|
449
|
+
return unless !options[:pretend] && File.exist?(source)
|
450
|
+
|
451
|
+
require 'fileutils'
|
452
|
+
::FileUtils.mv(source, target)
|
453
|
+
end
|
454
|
+
# rubocop:enable Metrics/AbcSize
|
455
|
+
|
437
456
|
# Local template path is handy when you want template files used when working with the --template flag
|
438
457
|
attr_accessor :local_template_path
|
439
458
|
|
@@ -465,17 +484,16 @@ module RailsAppGenerator
|
|
465
484
|
end
|
466
485
|
|
467
486
|
def add_if(addon)
|
468
|
-
|
469
|
-
add(addon) if options[option_name]
|
487
|
+
add(addon) if active?(addon)
|
470
488
|
end
|
471
489
|
|
472
|
-
def skip_flag?(option_name)
|
473
|
-
|
490
|
+
# def skip_flag?(option_name)
|
491
|
+
# value = options["skip_#{option_name}".to_sym]
|
474
492
|
|
475
|
-
|
493
|
+
# return true if value.nil?
|
476
494
|
|
477
|
-
|
478
|
-
end
|
495
|
+
# value == true
|
496
|
+
# end
|
479
497
|
|
480
498
|
def add_flag?(option_name)
|
481
499
|
value = options["add_#{option_name}".to_sym]
|
@@ -486,7 +504,7 @@ module RailsAppGenerator
|
|
486
504
|
end
|
487
505
|
|
488
506
|
def active?(option_name)
|
489
|
-
add_flag?(option_name) || !skip_flag?(option_name)
|
507
|
+
add_flag?(option_name) # || !skip_flag?(option_name)
|
490
508
|
end
|
491
509
|
|
492
510
|
def uses?(addon)
|
@@ -504,10 +522,18 @@ module RailsAppGenerator
|
|
504
522
|
end
|
505
523
|
end
|
506
524
|
|
507
|
-
def
|
525
|
+
def addon_classes
|
508
526
|
AddOns.constants
|
509
|
-
.
|
510
|
-
.
|
527
|
+
.map { |addon_klass_name| AddOns.const_get(addon_klass_name) }
|
528
|
+
.select { |klass| klass.is_a?(Class) && klass.respond_to?(:addon_name) }
|
529
|
+
end
|
530
|
+
|
531
|
+
def active_addon_classes
|
532
|
+
addon_classes.select { |klass| active?(klass.addon_name) }
|
533
|
+
end
|
534
|
+
|
535
|
+
def addon_gemfile_entries
|
536
|
+
active_addon_classes.flat_map(&:gem_entries)
|
511
537
|
end
|
512
538
|
end
|
513
539
|
|