rsg 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +13 -0
  3. data/.gitignore +11 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +14 -0
  6. data/Gemfile +13 -0
  7. data/Gemfile.lock +190 -0
  8. data/LICENSE +201 -0
  9. data/README.md +192 -0
  10. data/Rakefile +10 -0
  11. data/bin/console +12 -0
  12. data/bin/setup +8 -0
  13. data/exe/rsg +22 -0
  14. data/lib/rsg/generators/actions.rb +108 -0
  15. data/lib/rsg/generators/app/USAGE +14 -0
  16. data/lib/rsg/generators/app/app_builder.rb +42 -0
  17. data/lib/rsg/generators/app/app_generator.rb +80 -0
  18. data/lib/rsg/generators/app/templates/README.md.erb +22 -0
  19. data/lib/rsg/generators/base.rb +27 -0
  20. data/lib/rsg/generators/dotenv/install_generator.rb +24 -0
  21. data/lib/rsg/generators/dotenv/templates/env.development +2 -0
  22. data/lib/rsg/generators/dotenv/templates/env.test +2 -0
  23. data/lib/rsg/generators/gemfile/cleanup_generator.rb +28 -0
  24. data/lib/rsg/generators/install/install_generator.rb +13 -0
  25. data/lib/rsg/generators/logging/common_generator.rb +40 -0
  26. data/lib/rsg/generators/logging/lograge_generator.rb +31 -0
  27. data/lib/rsg/generators/logging/templates/initializer_lograge.rb +9 -0
  28. data/lib/rsg/generators/misc/misc_generator.rb +61 -0
  29. data/lib/rsg/generators/misc/templates/puma.rb +44 -0
  30. data/lib/rsg/generators/options.rb +15 -0
  31. data/lib/rsg/generators/orm/active_record_generator.rb +44 -0
  32. data/lib/rsg/generators/orm/templates/active_record/mysql.yml +59 -0
  33. data/lib/rsg/generators/orm/templates/active_record/postgresql.yml +86 -0
  34. data/lib/rsg/generators/orm/templates/active_record/sqlite3.yml +25 -0
  35. data/lib/rsg/generators/orm/templates/db.rake +7 -0
  36. data/lib/rsg/generators/orm/templates/samples.rb +10 -0
  37. data/lib/rsg/generators/orm/templates/seeds.rb +9 -0
  38. data/lib/rsg/generators/testing/rspec_generator.rb +33 -0
  39. data/lib/rsg/generators/webpacker/install_generator.rb +51 -0
  40. data/lib/rsg/generators/webpacker/templates/application.js +18 -0
  41. data/lib/rsg/generators/webpacker/templates/application.sass +19 -0
  42. data/lib/rsg/generators/webpacker/templates/landing_controller.rb.erb +6 -0
  43. data/lib/rsg/generators/webpacker/templates/landing_show.html.erb +8 -0
  44. data/lib/rsg/version.rb +4 -0
  45. data/lib/rsg.rb +36 -0
  46. data/rsg.gemspec +28 -0
  47. data/templates/README.md +4 -0
  48. data/templates/rsg-default.rb +17 -0
  49. metadata +109 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 49abbdf2e54f937084ca700c8cf3dbb09a2f9f2cb691f4c06d4fd9996c600a65
4
+ data.tar.gz: 3cf5638be1c8d1039c310ecdd4f3cc3687a984dd88cc3c86c494d23839081d70
5
+ SHA512:
6
+ metadata.gz: ed4c80320bf9939dbe762024bea33810e33f971dd469665e9d81803cf1b48c2a7cd67f3e4d0f952b3979cf6a04015dd20de5f399fd5458d3b91f907928eabf30
7
+ data.tar.gz: b34f4042d78ed407d13acc8d92d930201691b9c93f7f1e473161997e24e1ed4cc02aa00e44dbba4cad0bf75b5c2702d847e3e62f355e92c664a6273824210772
@@ -0,0 +1,13 @@
1
+ version: 2.1
2
+ jobs:
3
+ build:
4
+ docker:
5
+ - image: ruby:3.0.0
6
+ steps:
7
+ - checkout
8
+ - run:
9
+ name: Run the default task
10
+ command: |
11
+ gem install bundler -v 2.2.7
12
+ bundle install
13
+ bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,14 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.7
3
+ NewCops: enable
4
+
5
+ Style/StringLiterals:
6
+ Enabled: true
7
+ EnforcedStyle: double_quotes
8
+
9
+ Style/StringLiteralsInInterpolation:
10
+ Enabled: true
11
+ EnforcedStyle: double_quotes
12
+
13
+ Layout/LineLength:
14
+ Max: 120
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in rsg.gemspec
6
+ gemspec
7
+
8
+ gem "pry"
9
+ gem "rake", "~> 13.0"
10
+ gem "rspec", "~> 3.0"
11
+ gem "rubocop", "~> 1.7"
12
+ gem "rubocop-rake"
13
+ gem "rubocop-rspec"
data/Gemfile.lock ADDED
@@ -0,0 +1,190 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rsg (0.0.1)
5
+ rails (~> 6.1.4)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (6.1.4.1)
11
+ actionpack (= 6.1.4.1)
12
+ activesupport (= 6.1.4.1)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailbox (6.1.4.1)
16
+ actionpack (= 6.1.4.1)
17
+ activejob (= 6.1.4.1)
18
+ activerecord (= 6.1.4.1)
19
+ activestorage (= 6.1.4.1)
20
+ activesupport (= 6.1.4.1)
21
+ mail (>= 2.7.1)
22
+ actionmailer (6.1.4.1)
23
+ actionpack (= 6.1.4.1)
24
+ actionview (= 6.1.4.1)
25
+ activejob (= 6.1.4.1)
26
+ activesupport (= 6.1.4.1)
27
+ mail (~> 2.5, >= 2.5.4)
28
+ rails-dom-testing (~> 2.0)
29
+ actionpack (6.1.4.1)
30
+ actionview (= 6.1.4.1)
31
+ activesupport (= 6.1.4.1)
32
+ rack (~> 2.0, >= 2.0.9)
33
+ rack-test (>= 0.6.3)
34
+ rails-dom-testing (~> 2.0)
35
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
36
+ actiontext (6.1.4.1)
37
+ actionpack (= 6.1.4.1)
38
+ activerecord (= 6.1.4.1)
39
+ activestorage (= 6.1.4.1)
40
+ activesupport (= 6.1.4.1)
41
+ nokogiri (>= 1.8.5)
42
+ actionview (6.1.4.1)
43
+ activesupport (= 6.1.4.1)
44
+ builder (~> 3.1)
45
+ erubi (~> 1.4)
46
+ rails-dom-testing (~> 2.0)
47
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
48
+ activejob (6.1.4.1)
49
+ activesupport (= 6.1.4.1)
50
+ globalid (>= 0.3.6)
51
+ activemodel (6.1.4.1)
52
+ activesupport (= 6.1.4.1)
53
+ activerecord (6.1.4.1)
54
+ activemodel (= 6.1.4.1)
55
+ activesupport (= 6.1.4.1)
56
+ activestorage (6.1.4.1)
57
+ actionpack (= 6.1.4.1)
58
+ activejob (= 6.1.4.1)
59
+ activerecord (= 6.1.4.1)
60
+ activesupport (= 6.1.4.1)
61
+ marcel (~> 1.0.0)
62
+ mini_mime (>= 1.1.0)
63
+ activesupport (6.1.4.1)
64
+ concurrent-ruby (~> 1.0, >= 1.0.2)
65
+ i18n (>= 1.6, < 2)
66
+ minitest (>= 5.1)
67
+ tzinfo (~> 2.0)
68
+ zeitwerk (~> 2.3)
69
+ ast (2.4.2)
70
+ builder (3.2.4)
71
+ coderay (1.1.3)
72
+ concurrent-ruby (1.1.9)
73
+ crass (1.0.6)
74
+ diff-lcs (1.4.4)
75
+ erubi (1.10.0)
76
+ globalid (0.5.2)
77
+ activesupport (>= 5.0)
78
+ i18n (1.8.11)
79
+ concurrent-ruby (~> 1.0)
80
+ loofah (2.12.0)
81
+ crass (~> 1.0.2)
82
+ nokogiri (>= 1.5.9)
83
+ mail (2.7.1)
84
+ mini_mime (>= 0.1.1)
85
+ marcel (1.0.2)
86
+ method_source (1.0.0)
87
+ mini_mime (1.1.2)
88
+ minitest (5.14.4)
89
+ nio4r (2.5.8)
90
+ nokogiri (1.12.5-x86_64-linux)
91
+ racc (~> 1.4)
92
+ parallel (1.21.0)
93
+ parser (3.0.2.0)
94
+ ast (~> 2.4.1)
95
+ pry (0.14.1)
96
+ coderay (~> 1.1)
97
+ method_source (~> 1.0)
98
+ racc (1.6.0)
99
+ rack (2.2.3)
100
+ rack-test (1.1.0)
101
+ rack (>= 1.0, < 3)
102
+ rails (6.1.4.1)
103
+ actioncable (= 6.1.4.1)
104
+ actionmailbox (= 6.1.4.1)
105
+ actionmailer (= 6.1.4.1)
106
+ actionpack (= 6.1.4.1)
107
+ actiontext (= 6.1.4.1)
108
+ actionview (= 6.1.4.1)
109
+ activejob (= 6.1.4.1)
110
+ activemodel (= 6.1.4.1)
111
+ activerecord (= 6.1.4.1)
112
+ activestorage (= 6.1.4.1)
113
+ activesupport (= 6.1.4.1)
114
+ bundler (>= 1.15.0)
115
+ railties (= 6.1.4.1)
116
+ sprockets-rails (>= 2.0.0)
117
+ rails-dom-testing (2.0.3)
118
+ activesupport (>= 4.2.0)
119
+ nokogiri (>= 1.6)
120
+ rails-html-sanitizer (1.4.2)
121
+ loofah (~> 2.3)
122
+ railties (6.1.4.1)
123
+ actionpack (= 6.1.4.1)
124
+ activesupport (= 6.1.4.1)
125
+ method_source
126
+ rake (>= 0.13)
127
+ thor (~> 1.0)
128
+ rainbow (3.0.0)
129
+ rake (13.0.6)
130
+ regexp_parser (2.1.1)
131
+ rexml (3.2.5)
132
+ rspec (3.10.0)
133
+ rspec-core (~> 3.10.0)
134
+ rspec-expectations (~> 3.10.0)
135
+ rspec-mocks (~> 3.10.0)
136
+ rspec-core (3.10.1)
137
+ rspec-support (~> 3.10.0)
138
+ rspec-expectations (3.10.1)
139
+ diff-lcs (>= 1.2.0, < 2.0)
140
+ rspec-support (~> 3.10.0)
141
+ rspec-mocks (3.10.2)
142
+ diff-lcs (>= 1.2.0, < 2.0)
143
+ rspec-support (~> 3.10.0)
144
+ rspec-support (3.10.2)
145
+ rubocop (1.22.3)
146
+ parallel (~> 1.10)
147
+ parser (>= 3.0.0.0)
148
+ rainbow (>= 2.2.2, < 4.0)
149
+ regexp_parser (>= 1.8, < 3.0)
150
+ rexml
151
+ rubocop-ast (>= 1.12.0, < 2.0)
152
+ ruby-progressbar (~> 1.7)
153
+ unicode-display_width (>= 1.4.0, < 3.0)
154
+ rubocop-ast (1.12.0)
155
+ parser (>= 3.0.1.1)
156
+ rubocop-rake (0.6.0)
157
+ rubocop (~> 1.0)
158
+ rubocop-rspec (2.5.0)
159
+ rubocop (~> 1.19)
160
+ ruby-progressbar (1.11.0)
161
+ sprockets (4.0.2)
162
+ concurrent-ruby (~> 1.0)
163
+ rack (> 1, < 3)
164
+ sprockets-rails (3.2.2)
165
+ actionpack (>= 4.0)
166
+ activesupport (>= 4.0)
167
+ sprockets (>= 3.0.0)
168
+ thor (1.1.0)
169
+ tzinfo (2.0.4)
170
+ concurrent-ruby (~> 1.0)
171
+ unicode-display_width (2.1.0)
172
+ websocket-driver (0.7.5)
173
+ websocket-extensions (>= 0.1.0)
174
+ websocket-extensions (0.1.5)
175
+ zeitwerk (2.5.1)
176
+
177
+ PLATFORMS
178
+ x86_64-linux
179
+
180
+ DEPENDENCIES
181
+ pry
182
+ rake (~> 13.0)
183
+ rsg!
184
+ rspec (~> 3.0)
185
+ rubocop (~> 1.7)
186
+ rubocop-rake
187
+ rubocop-rspec
188
+
189
+ BUNDLED WITH
190
+ 2.2.7
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,192 @@
1
+ # Ready, Set, Go!
2
+
3
+ `rsg` is an opinionated Rails application generator that scaffolds apps with the bare minimum needed to run
4
+ nicely in development and production.
5
+
6
+ ## Usage
7
+
8
+ ```sh
9
+ # Install the executable
10
+ gem install rsg
11
+
12
+ # Generate an API application called "the-next-twitter" under `~/projects`
13
+ rsg --api ~/projects/the-next-twitter
14
+
15
+ # Generate a "traditional" web application called "the-next-tiktok" under `~/projects`
16
+ rsg ~/projects/the-next-tiktok
17
+
18
+ # Use a custom application template to generate an application
19
+ rsg -m "my-org-template.rb" ~/projects/the-next-github
20
+ ```
21
+
22
+ The main `rsg` executable assumes you have everything necessary for bootstrapping the app, like for example
23
+ having `DATABASE_URL` set for automatic execution of `rails db:migrate` and nodejs / yarn available for
24
+ configuration of webpacker.
25
+
26
+ Alongside the `rsg` executable, the gem also provides a set of Rails generators that can be executed on top
27
+ of existing apps. You can lookup the ones that are available with `rails generate --help | grep rsg`.
28
+
29
+ ## Background
30
+
31
+ Rails comes with lots of things by default these days and while it provides a nice experience for newbies, it
32
+ is terrible for folks that would like to create micro services / apps with just the bare minimum. We also
33
+ believe that some of the provided defaults are not that great for production use (like for example logging).
34
+
35
+ Sure, we can use the `--minimal` flag and ignore most of the framework, or pass in `--api` to cut down even
36
+ more but the meaning of `--minimal` will change over time. Another option would be to run `rails new --help`
37
+ and go through all those 20+ `--skip-*` flags (in Rails 6.1) and pass the appropriate ones to `rails new`,
38
+ which is kinda boring and error prone.
39
+
40
+ Even if we provide all the `--skip-*` flags, there are things that we can't customize from the CLI, like
41
+ for example, the generated `README.md` or disabling Rail's encrypted secrets / credentials. The Rails Way :tm:
42
+ of doing those types of customizations are through [application templates](https://guides.rubyonrails.org/rails_application_templates.html).
43
+ With those one can easily do things like add gems, create routes, etc. Application templates are simply Ruby
44
+ files that can be passed on to the `-m` flag of `rails new`. Those files can live anywhere, like on GitHub
45
+ repositories or Gists, or even inside other gems (like `rsg` itself).
46
+
47
+ With all that in mind we've decided to create our own Rails application generator that's simplifies that
48
+ process. This project draws some inspiration from thoughtbot's [suspenders](https://github.com/thoughtbot/suspenders)
49
+ but it has a subtle difference, `rsg` will do its best to hide the complexities of `rails new`s by opting out
50
+ of all components it can (like `active_record` or the asset pipeline) and hiding the vast majority of `rails new`
51
+ flags from its help just so users are not confused. Once that "barebones application" is created, the [`rsg`
52
+ generators kick in and do their magic](templates/rsg-default.rb).
53
+
54
+ Different from suspenders, we chose to work off from application templates for "orchestration of generators"
55
+ instead of doing things from the [app generator itself](https://github.com/thoughtbot/suspenders/blob/31ff7bc0df1794b82bf95fcefb3e03a08bd6866e/lib/suspenders/generators/app_generator.rb#L38-L58).
56
+ The reason for doing that is just so developers can easily customize how `rsg` behaves by providing a simple ruby
57
+ file to it, instead of having to go through the process of adding extra flags, going through PRs, etc.
58
+
59
+ Finally, we want `rsg` to be the basis of other application generators so we did the best we could to make
60
+ wrapping `rsg` into your own internal / open source gem very simple (more on that below).
61
+
62
+ ## How does it work?
63
+
64
+ ```
65
+ TODO: Write about it, with as many links as possible
66
+ ```
67
+
68
+ ### Base application
69
+
70
+ ```
71
+ TODO: Document how it'll look like
72
+ ```
73
+
74
+ ### Available generators
75
+
76
+ ```
77
+ TODO: Document, explain what they do
78
+ ```
79
+
80
+ ## Development
81
+
82
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
83
+ You can also run `bin/console` for an interactive prompt that will allow you to experiment.
84
+
85
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update
86
+ the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for
87
+ the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
88
+
89
+ **NOTE**: The gem is currently owned by [@fgrehm](https://github.com/fgrehm) on RubyGems so you'll jave to ask
90
+ him to publish a new release, we'll automate releases from GitHub actions or CircleCI later and will transfer
91
+ the gem ownership to doximity.
92
+
93
+ ### Running `rsg` from source
94
+
95
+ ```bash
96
+ git clone https://github.com/doximity/rsg && cd rsg
97
+ ./bin/setup
98
+
99
+ # Scaffold a sample app under ./tmp and configure the app to use RSG from sources
100
+ ./exe/rsg --path="../../" tmp/sample-app
101
+
102
+ # Or if you want an API only project
103
+ ./exe/rsg --path="../../" --api tmp/sample-api
104
+ ```
105
+
106
+ ### Upgrading to newer rails releases
107
+
108
+ ```
109
+ TODO: Document
110
+ ```
111
+
112
+ <!--
113
+
114
+ * Link to rails diff to inspect what changed
115
+ * https://railsdiff.org/6.0.4.1/6.1.4.1
116
+ * Update RAILS_VERSION
117
+
118
+ -->
119
+
120
+ ### Adding a new generator
121
+
122
+ ```
123
+ TODO: Document, provide as many links as possible
124
+ ```
125
+
126
+ <!--
127
+
128
+ * Basics of Rails generators
129
+ * Talk about templates VS file manipulation (AKA file manipulation should be easier to maintain in the long
130
+ run, but will require more manual intervention when bumping rails releases of the generator itself, but
131
+ should make app's rails upgrades easier)
132
+ * Make sure to mention that methods are executed in order
133
+ * Granularity depends on reusability, but general guidance is to start with a single generator and break
134
+ apart if we end up wanting to execute just a portion of a given generator in a different context
135
+ * Do our best to support running on top of existing apps
136
+ * Always run after bundling, make sure to bundle from generators
137
+ * https://guides.rubyonrails.org/rails_application_templates.html
138
+ * https://guides.rubyonrails.org/generators.html
139
+ * https://www.rubydoc.info/github/erikhuda/thor/master/Thor/Base/ClassMethods#class_option-instance_method
140
+ * https://rdoc.info/github/rails/thor/master/Thor/Actions
141
+ -->
142
+
143
+ ### Custom `rsg` actions
144
+
145
+ ```
146
+ TODO: Document, or link to file
147
+ ```
148
+
149
+ ### Wrapping `rsg` into your own generator
150
+
151
+ ```
152
+ TODO: Document
153
+ ```
154
+
155
+ ## Contributing
156
+
157
+ Bug reports and pull requests are welcome on GitHub at https://github.com/doximity/rsg.
158
+
159
+ ## TODO
160
+
161
+ - [x] Generate a barebones app with a clean gemfile, pry and basic README
162
+ - [x] Hide the `rails new` flags that make sense or have a sane default
163
+ - [x] Disable Rails encrypted secrets
164
+ - [x] Healthcheck endpoint
165
+ - [x] `git commit` after each generator
166
+ - [x] Application template that calls generators
167
+ - [x] Accept a template, set a default
168
+ - [ ] Automated releases
169
+ - [x] Basic documentation with placeholders of content to write later
170
+ - [ ] Test coverage, can start with a simple test that runs the command and boots the app
171
+ - [ ] Generators
172
+ - [x] webpacker for all the things, including SASS
173
+ - [x] Productiong grade logging
174
+ - [x] `rspec-rails`
175
+ - [x] `dotenv-rails`
176
+ - [ ] `slim-rails`
177
+ - [ ] `factory_bot`
178
+ - [ ] docker-compose
179
+ - [ ] robots.txt
180
+ - [ ] Code coverage for rspec
181
+ - [ ] CI with GitHub Actions
182
+ - [ ] CI with CircleCI
183
+ - [ ] Sidekiq with opt in support for sidekiq-pro and sidekiq-enterprise
184
+ - [ ] `action_cable`
185
+ - [ ] `action_mailbox`
186
+ - [ ] `action_mailer`
187
+ - [ ] `action_text`
188
+ - [ ] `active_job`
189
+ - [x] `active_record`
190
+ - [ ] `active_storage`
191
+ - [ ] `test_unit`
192
+ - [x] Overview of the project, including some background
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ require "rubocop/rake_task"
7
+
8
+ RuboCop::RakeTask.new
9
+
10
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "rsg"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ require "pry"
12
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here