boring_generators 0.1.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +12 -0
  3. data/.github/PULL_REQUEST_TEMPLATE.md +11 -0
  4. data/.github/workflows/ci.yml +17 -0
  5. data/CHANGELOG.md +36 -0
  6. data/Gemfile +6 -0
  7. data/Gemfile.lock +148 -0
  8. data/README.md +52 -6
  9. data/boring_generators.gemspec +3 -1
  10. data/exe/boring +5 -0
  11. data/lib/boring_generators.rb +1 -0
  12. data/lib/boring_generators/cli.rb +26 -0
  13. data/lib/boring_generators/version.rb +1 -1
  14. data/lib/generators/boring/active_storage/aws/install/install_generator.rb +48 -0
  15. data/lib/generators/boring/active_storage/azure/install/install_generator.rb +48 -0
  16. data/lib/generators/boring/active_storage/google/install/install_generator.rb +48 -0
  17. data/lib/generators/boring/audit/install/install_generator.rb +22 -0
  18. data/lib/generators/boring/bootstrap/install/install_generator.rb +67 -0
  19. data/lib/generators/boring/bootstrap/install/templates/application.scss +1 -0
  20. data/lib/generators/boring/bullet/install/install_generator.rb +31 -0
  21. data/lib/generators/boring/bullet/install/templates/bullet.rb +8 -0
  22. data/lib/generators/boring/ci/circleci/install/install_generator.rb +31 -0
  23. data/lib/generators/boring/ci/circleci/install/templates/config.psql.yml.tt +48 -0
  24. data/lib/generators/boring/ci/circleci/install/templates/config.sql.yml.tt +48 -0
  25. data/lib/generators/boring/ci/circleci/install/templates/database.yml.ci.tt +14 -0
  26. data/lib/generators/boring/ci/github_action/install/install_generator.rb +45 -0
  27. data/lib/generators/boring/ci/github_action/install/templates/ci.yml.tt +49 -0
  28. data/lib/generators/boring/ci/travisci/install/install_generator.rb +23 -0
  29. data/lib/generators/boring/ci/travisci/install/templates/.travis.yml.tt +35 -0
  30. data/lib/generators/boring/devise/install/install_generator.rb +75 -0
  31. data/lib/generators/boring/favicon/build/build_generator.rb +120 -0
  32. data/lib/generators/boring/favicon/build/templates/favicon.html.erb.tt +19 -0
  33. data/lib/generators/boring/font_awesome/ruby_gem/install/install_generator.rb +42 -0
  34. data/lib/generators/boring/font_awesome/yarn/install/install_generator.rb +53 -0
  35. data/lib/generators/boring/font_awesome/yarn/install/templates/application.scss +1 -0
  36. data/lib/generators/boring/graphql/install/install_generator.rb +51 -0
  37. data/lib/generators/boring/graphql/install/templates/base_resolver.rb +2 -0
  38. data/lib/generators/boring/graphql/install/templates/hello_world_resolver.rb +11 -0
  39. data/lib/generators/boring/jquery/install/install_generator.rb +32 -0
  40. data/lib/generators/boring/oauth/facebook/install/install_generator.rb +91 -0
  41. data/lib/generators/boring/oauth/facebook/install/templates/README +24 -0
  42. data/lib/generators/boring/oauth/facebook/install/templates/omniauth.rb +3 -0
  43. data/lib/generators/boring/oauth/facebook/install/templates/omniauth_callbacks_controller.rb +21 -0
  44. data/lib/generators/boring/pry/install/install_generator.rb +29 -0
  45. data/lib/generators/boring/pry/install/templates/pryrc +24 -0
  46. data/lib/generators/boring/pundit/install/install_generator.rb +85 -0
  47. data/lib/generators/boring/rubocop/install/install_generator.rb +37 -0
  48. data/lib/generators/boring/rubocop/install/templates/.rubocop.yml.tt +262 -0
  49. data/lib/generators/boring/simple_form/install/install_generator.rb +44 -0
  50. data/lib/generators/boring/tailwind/install/install_generator.rb +28 -20
  51. metadata +2527 -6
  52. data/.travis.yml +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fdb73c106d2605bd3f2a97cc509f2204dc7d74670f4b67685abebf01ea93e42a
4
- data.tar.gz: dccbd9b93fd021b3fc4e8a567166d0d0134ddd4ec6a51251f3b4d18204ce6daf
3
+ metadata.gz: 66c4c0c7499756d66e0d992e4ec79ad105f310b40384a49d99b1a3f96ebfaeab
4
+ data.tar.gz: '074778686e124d14e6010e6a886b209484abf2774e0836e48631c900738f3ae8'
5
5
  SHA512:
6
- metadata.gz: 2158a1c67c89389e4c17cd53df289bc623c47191253d2a4e9c1cb665e0c47ad0cf65ae92f290fbaf8a927028c150be8194ad8dc6e1a3f3744a56bc9d6168c290
7
- data.tar.gz: c5b4082ae50708c0846aee643cd88fa9b7f40ed88766124f9eee86135f90b6e0a9e63760edce26d5dbe3748cf27b5794089b2c39ff3d6df5d891cf3eb82e19c6
6
+ metadata.gz: 44e5a7cfde50201a16ce39cd6c1e28618efe002229e81f15613278bdfdb5f448a4d02532d974b7fe232742cd5d6b5c55ac9aa851b84cad8bc90c1cb7c9efdb77
7
+ data.tar.gz: 7ec572ba9730632511e08d4aa6a943a8c97db89ae93c0b5d2db4813b9ece7ac53b586b1690d2f636d1bd7fcff6c46572501ec69752af1008b43c949e1789e456
@@ -0,0 +1,12 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4
+ patreon: # Replace with a single Patreon username
5
+ open_collective: boring_generators
6
+ ko_fi: # Replace with a single Ko-fi username
7
+ tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ liberapay: # Replace with a single Liberapay username
10
+ issuehunt: # Replace with a single IssueHunt username
11
+ otechie: # Replace with a single Otechie username
12
+ custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
@@ -0,0 +1,11 @@
1
+ <!--
2
+ Thanks for submitting a pull request!
3
+ We appreciate you spending the time to work on these changes. Please provide enough information so that others can review your pull request. The three fields below are mandatory.
4
+
5
+ Before submitting a pull request, please make sure the following is done:
6
+
7
+ 1. Fork [the repository](https://github.com/abhaynikam/boring_generators) and create your branch from `master`.
8
+ 2. Run `bundle install` in the repository root.
9
+ 3. If you've fixed a bug or added code that should be tested, add tests!
10
+ 4. Ensure the test suite passes (`rake test`).
11
+ -->
@@ -0,0 +1,17 @@
1
+ name: CI
2
+ on: [push]
3
+ jobs:
4
+ test:
5
+ name: Tests
6
+ runs-on: ubuntu-latest
7
+ steps:
8
+ - name: Checkout code
9
+ uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 2.7.0
14
+ - name: Install gems
15
+ run: bundle install --jobs 4 --retry 3
16
+ - name: Run tests
17
+ run: bundle exec rake test
@@ -2,9 +2,45 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.6.0 (January 10th, 2021)
6
+ * Updates default ruby version of GitHub Actions install generator. ([@jamesglover][])
7
+ * Simplify generated GitHub Actions install ([@jamesglover][])
8
+ * Adds boring generator CLI ([@luathn][])
9
+ * Adds Devise Facebook Omniauth generator. ([@abhaynikam][])
10
+
11
+ ## 0.5.0 (December 20th, 2020)
12
+ * Adds favicon build generator. ([@abhaynikam][])
13
+ * Adds Pundit install generator. ([@CiTroNaK][])
14
+ * Adds GraphQL generator. ([@abhaynikam][])
15
+ * Adds SimpleForm generator. ([@abhaynikam][])
16
+ * Adds Devise generator. ([@abhaynikam][])
17
+
18
+ ## 0.4.0 (October 23rd, 2020)
19
+ * Adds CircleCI install generator. ([@abhaynikam][])
20
+ * Adds GitHub Actions install generator. ([@abhaynikam][])
21
+ * Adds Travis CI install generator. ([@abhaynikam][])
22
+ * Adds Rubocop install generator. ([@abhaynikam][])
23
+
24
+ ## 0.3.0 (September 19th, 2020)
25
+ * Adds Bullet install generator. ([@abhaynikam][])
26
+ * Adds Audit gems(bundler-audit, ruby_audit) install generator. ([@abhaynikam][])
27
+ * Adds Pry install generator. ([@abhaynikam][])
28
+ * Adds Active Storage Google install generator. ([@abhaynikam][])
29
+ * Adds Active Storage AWS install generator. ([@abhaynikam][])
30
+ * Adds Active Storage Microsoft Azure install generator. ([@abhaynikam][])
31
+
32
+ ## 0.2.0 (September 16th, 2020)
33
+ * Adds JQuery install generator. ([@abhaynikam][])
34
+ * Adds Bootstrap install generator. ([@abhaynikam][])
35
+ * Adds FontAwesome install generator via Yarn. ([@abhaynikam][])
36
+ * Adds FontAwesome install generator via RubyGems. ([@abhaynikam][])
37
+
5
38
  ## 0.1.0 (September 5th, 2020)
6
39
 
7
40
  * Adds Tailwind CSS install generator. ([@abhaynikam][])
8
41
  * Initial release. ([@abhaynikam][])
9
42
 
10
43
  [@abhaynikam]: https://github.com/abhaynikam
44
+ [@CiTroNaK]: https://github.com/CiTroNaK
45
+ [@jamesglover]: https://github.com/JamesGlover
46
+ [@luathn]: https://github.com/luathn
data/Gemfile CHANGED
@@ -3,5 +3,11 @@ source "https://rubygems.org"
3
3
  # Specify your gem's dependencies in boring_generators.gemspec
4
4
  gemspec
5
5
 
6
+ gem "rails", "~> 6.0.3.4"
6
7
  gem "rake", "~> 12.0"
7
8
  gem "minitest", "~> 5.0"
9
+ gem "byebug"
10
+
11
+ platforms :ruby do
12
+ gem "sqlite3", "~> 1.4"
13
+ end
@@ -0,0 +1,148 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ boring_generators (0.5.0)
5
+ railties
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (6.0.3.4)
11
+ actionpack (= 6.0.3.4)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
14
+ actionmailbox (6.0.3.4)
15
+ actionpack (= 6.0.3.4)
16
+ activejob (= 6.0.3.4)
17
+ activerecord (= 6.0.3.4)
18
+ activestorage (= 6.0.3.4)
19
+ activesupport (= 6.0.3.4)
20
+ mail (>= 2.7.1)
21
+ actionmailer (6.0.3.4)
22
+ actionpack (= 6.0.3.4)
23
+ actionview (= 6.0.3.4)
24
+ activejob (= 6.0.3.4)
25
+ mail (~> 2.5, >= 2.5.4)
26
+ rails-dom-testing (~> 2.0)
27
+ actionpack (6.0.3.4)
28
+ actionview (= 6.0.3.4)
29
+ activesupport (= 6.0.3.4)
30
+ rack (~> 2.0, >= 2.0.8)
31
+ rack-test (>= 0.6.3)
32
+ rails-dom-testing (~> 2.0)
33
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
34
+ actiontext (6.0.3.4)
35
+ actionpack (= 6.0.3.4)
36
+ activerecord (= 6.0.3.4)
37
+ activestorage (= 6.0.3.4)
38
+ activesupport (= 6.0.3.4)
39
+ nokogiri (>= 1.8.5)
40
+ actionview (6.0.3.4)
41
+ activesupport (= 6.0.3.4)
42
+ builder (~> 3.1)
43
+ erubi (~> 1.4)
44
+ rails-dom-testing (~> 2.0)
45
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
46
+ activejob (6.0.3.4)
47
+ activesupport (= 6.0.3.4)
48
+ globalid (>= 0.3.6)
49
+ activemodel (6.0.3.4)
50
+ activesupport (= 6.0.3.4)
51
+ activerecord (6.0.3.4)
52
+ activemodel (= 6.0.3.4)
53
+ activesupport (= 6.0.3.4)
54
+ activestorage (6.0.3.4)
55
+ actionpack (= 6.0.3.4)
56
+ activejob (= 6.0.3.4)
57
+ activerecord (= 6.0.3.4)
58
+ marcel (~> 0.3.1)
59
+ activesupport (6.0.3.4)
60
+ concurrent-ruby (~> 1.0, >= 1.0.2)
61
+ i18n (>= 0.7, < 2)
62
+ minitest (~> 5.1)
63
+ tzinfo (~> 1.1)
64
+ zeitwerk (~> 2.2, >= 2.2.2)
65
+ builder (3.2.4)
66
+ byebug (11.1.3)
67
+ concurrent-ruby (1.1.7)
68
+ crass (1.0.6)
69
+ erubi (1.10.0)
70
+ globalid (0.4.2)
71
+ activesupport (>= 4.2.0)
72
+ i18n (1.8.5)
73
+ concurrent-ruby (~> 1.0)
74
+ loofah (2.8.0)
75
+ crass (~> 1.0.2)
76
+ nokogiri (>= 1.5.9)
77
+ mail (2.7.1)
78
+ mini_mime (>= 0.1.1)
79
+ marcel (0.3.3)
80
+ mimemagic (~> 0.3.2)
81
+ method_source (1.0.0)
82
+ mimemagic (0.3.5)
83
+ mini_mime (1.0.2)
84
+ mini_portile2 (2.4.0)
85
+ minitest (5.14.2)
86
+ nio4r (2.5.4)
87
+ nokogiri (1.10.10)
88
+ mini_portile2 (~> 2.4.0)
89
+ rack (2.2.3)
90
+ rack-test (1.1.0)
91
+ rack (>= 1.0, < 3)
92
+ rails (6.0.3.4)
93
+ actioncable (= 6.0.3.4)
94
+ actionmailbox (= 6.0.3.4)
95
+ actionmailer (= 6.0.3.4)
96
+ actionpack (= 6.0.3.4)
97
+ actiontext (= 6.0.3.4)
98
+ actionview (= 6.0.3.4)
99
+ activejob (= 6.0.3.4)
100
+ activemodel (= 6.0.3.4)
101
+ activerecord (= 6.0.3.4)
102
+ activestorage (= 6.0.3.4)
103
+ activesupport (= 6.0.3.4)
104
+ bundler (>= 1.3.0)
105
+ railties (= 6.0.3.4)
106
+ sprockets-rails (>= 2.0.0)
107
+ rails-dom-testing (2.0.3)
108
+ activesupport (>= 4.2.0)
109
+ nokogiri (>= 1.6)
110
+ rails-html-sanitizer (1.3.0)
111
+ loofah (~> 2.3)
112
+ railties (6.0.3.4)
113
+ actionpack (= 6.0.3.4)
114
+ activesupport (= 6.0.3.4)
115
+ method_source
116
+ rake (>= 0.8.7)
117
+ thor (>= 0.20.3, < 2.0)
118
+ rake (12.3.3)
119
+ sprockets (4.0.2)
120
+ concurrent-ruby (~> 1.0)
121
+ rack (> 1, < 3)
122
+ sprockets-rails (3.2.2)
123
+ actionpack (>= 4.0)
124
+ activesupport (>= 4.0)
125
+ sprockets (>= 3.0.0)
126
+ sqlite3 (1.4.2)
127
+ thor (1.0.1)
128
+ thread_safe (0.3.6)
129
+ tzinfo (1.2.9)
130
+ thread_safe (~> 0.1)
131
+ websocket-driver (0.7.3)
132
+ websocket-extensions (>= 0.1.0)
133
+ websocket-extensions (0.1.5)
134
+ zeitwerk (2.4.2)
135
+
136
+ PLATFORMS
137
+ ruby
138
+
139
+ DEPENDENCIES
140
+ boring_generators!
141
+ byebug
142
+ minitest (~> 5.0)
143
+ rails (~> 6.0.3.4)
144
+ rake (~> 12.0)
145
+ sqlite3 (~> 1.4)
146
+
147
+ BUNDLED WITH
148
+ 2.1.4
data/README.md CHANGED
@@ -1,8 +1,20 @@
1
- # BoringGenerators
1
+ <h3 align="center">
2
+ Boring Generators
3
+ </h3>
2
4
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/boring_generators`. To experiment with that code, run `bin/console` for an interactive prompt.
5
+ <p align="center">
6
+ <a href="https://rubygems.org/gems/boring_generators"><img alt="Gem" src="https://img.shields.io/gem/dt/boring_generators?style=flat-square"></a>
7
+ <img alt="GitHub Workflow Status" src="https://img.shields.io/github/workflow/status/abhaynikam/boring_generators/CI?style=flat-square">
8
+ </p>
9
+
10
+ <p>
11
+ Have you ever started a new adventure/hobby project of your and instead of spending time in solving the actual problem statement with the website ended up configuring the application and put a lot of effort into it. Yeah, We felt that too. Boring generator tries to resolve the painful same redundant configuration you do in every application by adding generators to easily configure it.
12
+ </p>
13
+
14
+ <p>
15
+ Check out the generator we support right now. We are planning to add support to most of the mostly used and required gems. We are open to any idea of yours, feel free to raise a discussion by opening up an issue or try contributing.
16
+ </p>
4
17
 
5
- TODO: Delete this and the text above, and describe your gem
6
18
 
7
19
  ## Installation
8
20
 
@@ -20,20 +32,54 @@ Or install it yourself as:
20
32
 
21
33
  $ gem install boring_generators
22
34
 
35
+ And then you can use it this way:
36
+
37
+ $ boring generate boring:simple_form:install --css_framework=<css_framework>
38
+ $ boring g boring:pry:install
39
+
23
40
  ## Usage
24
41
 
25
- TODO: Write usage instructions here
42
+ The boring generator introduces following generators:
43
+ - Install Tailwind CSS: `rails generate boring:tailwind:install`
44
+ - Install Bootstrap: `rails generate boring:bootstrap:install`
45
+ - Install JQuery: `rails generate boring:jquery:install`
46
+ - Install FontAwesome via Yarn: `rails generate boring:font_awesome:yarn:install`
47
+ - Install FontAwesome via RubyGems: `rails generate boring:font_awesome:ruby_gem:install`
48
+ - Install Bullet: `rails generate boring:bullet:install`
49
+ - Install Audit gems(bundler-audit, ruby_audit): `rails generate boring:audit:install`
50
+ - Install Pry gems for easy debugging: `rails generate boring:pry:install`
51
+ - Install Active Storage for Google Cloud Service: `rails generate boring:active_storage:google:install`
52
+ - Install Active Storage for AWS: `rails generate boring:active_storage:aws:install`
53
+ - Install Active Storage for Azure: `rails generate boring:active_storage:azure:install`
54
+ - Install CircleCI: `rails generate boring:ci:circleci:install --repository_name=<name> --ruby_version=<version>`
55
+ - Install GitHub Actions: `rails generate boring:ci:github_action:install --repository_name=<name> --ruby_version=<version>`
56
+ - Install Travis CI: `rails generate boring:ci:travisci:install --ruby_version=<version>`
57
+ - Install Rubocop: `rails generate boring:rubocop:install --ruby_version=<version>`
58
+ - Build Favicon: `rails generate boring:favicon:build --application_name=<application_name> --favico_letter=<favico_letter> --primary_color=<color>`
59
+ - Install Pundit: `rails generate boring:pundit:install`
60
+ - Install GraphQL: `rails generate boring:graphql:install`
61
+ - Install SimpleForm: `rails generate boring:simple_form:install --css_framework=<css_framework>`
62
+ - Install Devise: `rails generate boring:devise:install`
63
+ - Install Devise Facebook Omniauth: `rails generate boring:oauth:facebook:install`
26
64
 
27
65
  ## Development
28
66
 
29
67
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
68
 
69
+ You can also run specific test cases using following commands:
70
+ ```
71
+ bundle exec ruby -w -Itest test/generators/tailwind_install_generator_test.rb
72
+ ```
73
+
31
74
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
75
 
33
76
  ## Contributing
34
77
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/boring_generators. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/boring_generators/blob/master/CODE_OF_CONDUCT.md).
78
+ Bug reports and pull requests are welcome on GitHub at https://github.com/abhaynikam/boring_generators. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/abhaynikam/boring_generators/blob/master/CODE_OF_CONDUCT.md).
79
+
80
+ ## Changelog
36
81
 
82
+ Boring Generators changelog is available [here](https://github.com/abhaynikam/boring_generators/blob/master/CHANGELOG.md).
37
83
 
38
84
  ## License
39
85
 
@@ -41,4 +87,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
41
87
 
42
88
  ## Code of Conduct
43
89
 
44
- Everyone interacting in the BoringGenerators project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/boring_generators/blob/master/CODE_OF_CONDUCT.md).
90
+ Everyone interacting in the BoringGenerators project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/abhaynikam/boring_generators/blob/master/CODE_OF_CONDUCT.md).
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = "https://github.com/abhaynikam/boring-generators"
19
- spec.metadata["changelog_uri"] = "https://github.com/abhaynikam/boring-generators."
19
+ spec.metadata["changelog_uri"] = "https://github.com/abhaynikam/boring_generators/blob/master/CHANGELOG.md"
20
20
 
21
21
  # Specify which files should be added to the gem when it is released.
22
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -26,4 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.bindir = "exe"
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency "railties"
29
31
  end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/boring_generators/cli"
4
+
5
+ BoringGenerators::CLI.start(ARGV)
@@ -1,4 +1,5 @@
1
1
  require "boring_generators/version"
2
+ require 'bundler'
2
3
 
3
4
  module BoringGenerators
4
5
  class Error < StandardError; end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+ require "rails/generators"
3
+ require_relative "../boring_generators"
4
+
5
+ module BoringGenerators
6
+ class CLI < Thor
7
+ map "g" => :generate
8
+ map %w(--version -v) => :__print_version
9
+
10
+ desc "generate GENERATOR [options]", "Add gem to the application"
11
+ def generate(generator, *options)
12
+ Rails::Generators.invoke(generator, options)
13
+ end
14
+
15
+ desc "--version, -v", "Print gem version"
16
+ def __print_version
17
+ puts "Boring generators #{BoringGenerators::VERSION}"
18
+ end
19
+
20
+ class << self
21
+ def exit_on_failure?
22
+ true
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module BoringGenerators
2
- VERSION = "0.1.0"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -0,0 +1,48 @@
1
+ module Boring
2
+ module ActiveStorage
3
+ module Aws
4
+ class InstallGenerator < Rails::Generators::Base
5
+ desc "Adds ActiveStorage AWS service the application"
6
+
7
+ class_option :skip_active_storage, type: :boolean, aliases: "-s",
8
+ desc: "Skips running ActiveStorage installer"
9
+
10
+ def add_active_storage
11
+ unless options[:skip_active_storage]
12
+ say "Adding ActiveStorage", :green
13
+ run "bin/rails active_storage:install"
14
+ end
15
+ end
16
+
17
+ def add_aws_to_the_application
18
+ say "Adding AWS gem", :green
19
+ aws_gem_content = <<~RUBY
20
+ \n
21
+ # for AWS Service
22
+ gem "aws-sdk-s3", require: false
23
+ RUBY
24
+ append_to_file "Gemfile", aws_gem_content
25
+ run "bundle install"
26
+ end
27
+
28
+ def add_configuration_to_production
29
+ gsub_file "config/environments/production.rb",
30
+ "config.active_storage.service = :local",
31
+ "config.active_storage.service = :amazon"
32
+ end
33
+
34
+ def add_aws_storage_configuration
35
+ aws_storage_config_content = <<~RUBY
36
+ amazon:
37
+ service: S3
38
+ access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
39
+ secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
40
+ region: us-east-1
41
+ bucket: your_own_bucket
42
+ RUBY
43
+ append_to_file "config/storage.yml", aws_storage_config_content
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end