rails-interactive 0.1.7 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6afcb39a24c3349eeb1612c9718ec6eac30719daf817adba40db94cdb75b09f9
4
- data.tar.gz: '0981f8d0e62091899e86bc90cefe2bb8bd6ad54830bc46f8ba87e6b85cfd201b'
3
+ metadata.gz: 0ed0537b6d53cb2eb3f395bbde2c35b9b798c9b74361a28fd26420ff450f5088
4
+ data.tar.gz: 1d41ee1c12f1979dcb372a36d340bf670ef03b2146c3b8bec781456a9284a9c4
5
5
  SHA512:
6
- metadata.gz: c000dc682e8459d7909ade1944799cf9106dba51eda6158d1106ff5f065f381ee3633b4521dbc51af949442e334fa289e9199f3d43e72be477cc112259ac0506
7
- data.tar.gz: a909ff4109ea75853bfbfb7e4a1343c1812d8c2c4c9accfb92da62fb2dd5fee71d15406879e612a2e433d59bf0b591d726ddeb0a513aa5f9c057d9f95642b477
6
+ metadata.gz: 483c4f42d0c78380e98722b8c5f84dc4e6bdc66e041eca02b6a82ed036e138eca618cd97d43a79089c785ed969e3ec4f7b8094a910cb38c8a4a66e724a034f9b
7
+ data.tar.gz: 4f847ee3dcfcaba3091121a1672c922e74e2bae30b8f5231811a24ca8b6151229b29950c287e5f7e7a91005fe84e6cbe8a2eca728bc678e3c76d7f6a632b513c
@@ -0,0 +1,9 @@
1
+ ## What's up?
2
+
3
+ In this PR, Rails interactive have `gem` integration. In this way, when users select `gem` to install their rails project, CLI will install `gem` to the related project with the use of rails templates
4
+
5
+ ## Issue
6
+ Related Issue: `issue_link`
7
+
8
+ ## Closed Issue
9
+ Closes `issue_link`
@@ -1,57 +1,57 @@
1
- name: Release and Publish
2
- on:
3
- push:
4
- branches:
5
- - main
6
- jobs:
7
- build:
8
- runs-on: ubuntu-latest
9
- steps:
10
- - name: Wait for tests to succeed
11
- uses: lewagon/wait-on-check-action@v1.0.0
12
- with:
13
- ref: ${{ github.ref }}
14
- check-name: 'Run tests'
15
- repo-token: ${{ secrets.GITHUB_TOKEN }}
16
- wait-interval: 10
17
- - uses: GoogleCloudPlatform/release-please-action@v2
18
- id: release
19
- with:
20
- release-type: ruby
21
- package-name: rails-interactive
22
- version-file: 'lib/rails_interactive/version.rb'
23
- - uses: actions/checkout@v2
24
- if: ${{ steps.release.outputs.release_created }}
25
- - name: Set up Ruby
26
- uses: ruby/setup-ruby@v1
27
- if: ${{ steps.release.outputs.release_created }}
28
- with:
29
- ruby-version: 3.0.2
30
- bundler-cache: true
31
- - name: Bundle Install
32
- run: bundle install
33
- if: ${{ steps.release.outputs.release_created }}
34
- - name: Set Credentials
35
- run: |
36
- mkdir -p $HOME/.gem
37
- touch $HOME/.gem/credentials
38
- chmod 0600 $HOME/.gem/credentials
39
- printf -- "---\n:github: Bearer ${GITHUB_TOKEN}\n" > $HOME/.gem/credentials
40
- printf -- "---\n:rubygems_api_key: ${RUBYGEMS_TOKEN}\n" > $HOME/.gem/credentials
41
- if: ${{ steps.release.outputs.release_created }}
42
- env:
43
- GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
44
- RUBYGEMS_TOKEN: '${{secrets.RUBYGEMS_TOKEN}}'
45
- - name: Publish to GitHub Packages
46
- run: |
47
- export OWNER=$( echo ${{ github.repository }} | cut -d "/" -f 1 )
48
- gem build *.gemspec
49
- gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
50
- gem push *.gem
51
- if: ${{ steps.release.outputs.release_created }}
52
- - name: Publish to RubyGems
53
- run: |
54
- gem build *.gemspec
55
- gem push --host https://rubygems.pkg.github.com/${OWNER} *.gem
56
- gem push *.gem
57
- if: ${{ steps.release.outputs.release_created }}
1
+ # name: Release and Publish
2
+ # on:
3
+ # push:
4
+ # branches:
5
+ # - main
6
+ # jobs:
7
+ # build:
8
+ # runs-on: ubuntu-latest
9
+ # steps:
10
+ # - name: Wait for tests to succeed
11
+ # uses: lewagon/wait-on-check-action@v1.0.0
12
+ # with:
13
+ # ref: ${{ github.ref }}
14
+ # check-name: 'Run tests'
15
+ # repo-token: ${{ secrets.GITHUB_TOKEN }}
16
+ # wait-interval: 10
17
+ # - uses: GoogleCloudPlatform/release-please-action@v2
18
+ # id: release
19
+ # with:
20
+ # release-type: ruby
21
+ # package-name: rails-interactive
22
+ # version-file: 'lib/rails_interactive/version.rb'
23
+ # - uses: actions/checkout@v2
24
+ # if: ${{ steps.release.outputs.release_created }}
25
+ # - name: Set up Ruby
26
+ # uses: ruby/setup-ruby@v1
27
+ # if: ${{ steps.release.outputs.release_created }}
28
+ # with:
29
+ # ruby-version: 3.0.2
30
+ # bundler-cache: true
31
+ # - name: Bundle Install
32
+ # run: bundle install
33
+ # if: ${{ steps.release.outputs.release_created }}
34
+ # - name: Set Credentials
35
+ # run: |
36
+ # mkdir -p $HOME/.gem
37
+ # touch $HOME/.gem/credentials
38
+ # chmod 0600 $HOME/.gem/credentials
39
+ # printf -- "---\n:github: Bearer ${GITHUB_TOKEN}\n" > $HOME/.gem/credentials
40
+ # printf -- "---\n:rubygems_api_key: ${RUBYGEMS_TOKEN}\n" > $HOME/.gem/credentials
41
+ # if: ${{ steps.release.outputs.release_created }}
42
+ # env:
43
+ # GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
44
+ # RUBYGEMS_TOKEN: '${{secrets.RUBYGEMS_TOKEN}}'
45
+ # - name: Publish to GitHub Packages
46
+ # run: |
47
+ # export OWNER=$( echo ${{ github.repository }} | cut -d "/" -f 1 )
48
+ # gem build *.gemspec
49
+ # gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
50
+ # gem push *.gem
51
+ # if: ${{ steps.release.outputs.release_created }}
52
+ # - name: Publish to RubyGems
53
+ # run: |
54
+ # gem build *.gemspec
55
+ # gem push --host https://rubygems.pkg.github.com/${OWNER} *.gem
56
+ # gem push *.gem
57
+ # if: ${{ steps.release.outputs.release_created }}
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ### [0.1.9](https://www.github.com/oguzsh/rails-interactive/compare/v0.1.8...v0.1.9) (2022-04-24)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * file name typo ([#60](https://www.github.com/oguzsh/rails-interactive/issues/60)) ([542c76f](https://www.github.com/oguzsh/rails-interactive/commit/542c76fa57fd37cf583a7238b2a9b527aeba1778))
9
+
3
10
  ## [0.1.0] - 2022-03-11
4
11
 
5
12
  - Initial release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails-interactive (0.1.6)
4
+ rails-interactive (0.1.9)
5
5
  tty-prompt
6
6
 
7
7
  GEM
@@ -19,11 +19,13 @@ module RailsInteractive
19
19
  def self.render_ascii
20
20
  # rubocop:disable Naming/HeredocDelimiterNaming
21
21
  puts <<-'EOF'
22
- ___ _ _ _ ____ _ _
23
- |_ _|_ __ | |_ ___ _ __ __ _ ___| |_(_)_ _____| _ \ __ _(_) |___
24
- | || '_ \| __/ _ \ '__/ _` |/ __| __| \ \ / / _ \ |_) / _` | | / __|
25
- | || | | | || __/ | | (_| | (__| |_| |\ V / __/ _ < (_| | | \__ \
26
- |___|_| |_|\__\___|_| \__,_|\___|\__|_| \_/ \___|_| \_\__,_|_|_|___/
22
+ _____ _ _ _____ _ _ _
23
+ | __ \ (_) | |_ _| | | | | (_)
24
+ | |__) |__ _ _| |___ | | _ __ | |_ ___ _ __ __ _ ___| |_ ___ _____
25
+ | _ // _` | | / __| | | | '_ \| __/ _ \ '__/ _` |/ __| __| \ \ / / _ \
26
+ | | \ \ (_| | | \__ \_| |_| | | | || __/ | | (_| | (__| |_| |\ V / __/
27
+ |_| \_\__,_|_|_|___/_____|_| |_|\__\___|_| \__,_|\___|\__|_| \_/ \___|
28
+
27
29
 
28
30
  EOF
29
31
  # rubocop:enable Naming/HeredocDelimiterNaming
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsInteractive
4
- VERSION = "0.1.7"
4
+ VERSION = "1.0.0"
5
5
  end
@@ -27,10 +27,7 @@ module RailsInteractive
27
27
  name
28
28
  type
29
29
  database
30
- features
31
- code_quality_tool
32
- admin_panel
33
- testing_tools
30
+ css_frameworks
34
31
 
35
32
  create
36
33
  end
@@ -38,27 +35,15 @@ module RailsInteractive
38
35
  def create
39
36
  # Install gems
40
37
  system("bin/setup")
38
+
41
39
  # Create project
42
40
  system(setup)
43
41
 
44
- copy_templates_to_project
45
-
46
- # Move to project folder and install gems
42
+ # Prepare project requirements and give instructions
47
43
  Dir.chdir "./#{@inputs[:name]}"
44
+ system("rails db:create")
48
45
 
49
- # Features Templates
50
- handle_multi_options(key: :features)
51
-
52
- # Code Quality Template
53
- system("bin/rails app:template LOCATION=templates/setup_#{@inputs[:code_quality_tool]}.rb")
54
-
55
- # Admin Panel Template
56
- system("bin/rails app:template LOCATION=templates/setup_#{@inputs[:admin_panel]}.rb")
57
-
58
- # Testing tools Template
59
- handle_multi_options(key: :testing_tools)
60
-
61
- # Prepare project requirements and give instructions
46
+ sign_project
62
47
  Message.prepare
63
48
  end
64
49
 
@@ -66,23 +51,13 @@ module RailsInteractive
66
51
  base = "rails new"
67
52
  cmd = ""
68
53
 
69
- @inputs.first(3).each { |_key, value| cmd += "#{value} " }
54
+ @inputs.each { |_key, value| cmd += "#{value} " }
70
55
 
71
56
  "#{base} #{cmd}".strip!
72
57
  end
73
58
 
74
- def copy_templates_to_project
75
- FileUtils.cp_r "#{__dir__}/rails_interactive/templates", "./#{@inputs[:name]}"
76
- end
77
-
78
59
  private
79
60
 
80
- def handle_multi_options(key:)
81
- @inputs[key].each do |value|
82
- system("bin/rails app:template LOCATION=templates/setup_#{value}.rb")
83
- end
84
- end
85
-
86
61
  def name
87
62
  @inputs[:name] = Prompt.new("Enter the name of the project: ", "ask", required: true).perform
88
63
  end
@@ -98,31 +73,17 @@ module RailsInteractive
98
73
  @inputs[:database] = Prompt.new("Choose project's database: ", "select", database_types, required: true).perform
99
74
  end
100
75
 
101
- def features
102
- features = %w[devise cancancan omniauth pundit brakeman sidekiq]
103
-
104
- @inputs[:features] = Prompt.new("Choose project features: ", "multi_select", features).perform
105
- end
106
-
107
- def code_quality_tool
108
- code_quality_tool = { "Rubocop" => "rubocop", "StandardRB" => "standardrb" }
76
+ def css_frameworks
77
+ css_frameworks = { "None" => "", "Bootstrap" => "--css=bootstrap", "Tailwind" => "--css=tailwind" }
109
78
 
110
- @inputs[:code_quality_tool] =
111
- Prompt.new("Choose project code quality tool: ", "select", code_quality_tool).perform
79
+ @inputs[:css_framework] =
80
+ Prompt.new("Choose project's CSS framework: ", "select", css_frameworks, required: true).perform
112
81
  end
113
82
 
114
- def admin_panel
115
- admin_panel = { "RailsAdmin" => "rails_admin", "Avo" => "avo" }
116
-
117
- @inputs[:admin_panel] =
118
- Prompt.new("Choose project's admin panel: ", "select", admin_panel).perform
119
- end
120
-
121
- def testing_tools
122
- testing_tools = %w[rspec]
123
-
124
- @inputs[:testing_tools] =
125
- Prompt.new("Choose project's testing tools: ", "multi_select", testing_tools).perform
83
+ def sign_project
84
+ file = "README.md"
85
+ msg = "\n> This project was generated by [Rails Interactive CLI](https://github.com/oguzsh/rails-interactive)"
86
+ File.write(file, msg, mode: "a+")
126
87
  end
127
88
  end
128
89
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-interactive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oguzhan Ince
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-24 00:00:00.000000000 Z
11
+ date: 2022-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -119,6 +119,7 @@ extensions: []
119
119
  extra_rdoc_files: []
120
120
  files:
121
121
  - ".github/FUNDING.yml"
122
+ - ".github/PULL_REQUEST_TEMPLATE/pull_request_template.md"
122
123
  - ".github/workflows/main.yml"
123
124
  - ".github/workflows/rspec_rubocop.yml"
124
125
  - ".gitignore"
@@ -137,17 +138,6 @@ files:
137
138
  - lib/rails_interactive.rb
138
139
  - lib/rails_interactive/message.rb
139
140
  - lib/rails_interactive/prompt.rb
140
- - lib/rails_interactive/templates/setup_avo.rb
141
- - lib/rails_interactive/templates/setup_brakeman.rb
142
- - lib/rails_interactive/templates/setup_cancancan.rb
143
- - lib/rails_interactive/templates/setup_devise.rb
144
- - lib/rails_interactive/templates/setup_omniauth.rb
145
- - lib/rails_interactive/templates/setup_pundit.rb
146
- - lib/rails_interactive/templates/setup_rails_admin.rb
147
- - lib/rails_interactive/templates/setup_rspec.rb
148
- - lib/rails_interactive/templates/setup_rubocop.rb
149
- - lib/rails_interactive/templates/setup_sidekiq.rb
150
- - lib/rails_interactive/templates/setup_standardrb.rb
151
141
  - lib/rails_interactive/version.rb
152
142
  - rails-interactive.gemspec
153
143
  homepage: https://github.com/oguzsh/rails-interactive
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- run "rails db:prepare"
4
- run "bundle add avo"
5
-
6
- Bundler.with_unbundled_env { run "bundle install" }
7
-
8
- rails_command("generate avo:install")
9
-
10
- puts "Avo is installed! You can go to http://localhost:3000/avo for next steps"
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- run 'bundle add brakeman --group "development"'
4
- Bundler.with_unbundled_env { run "bundle install" }
5
- run "bundle binstubs brakeman"
6
- run "bin/brakeman"
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- run "bundle add cancancan"
4
-
5
- Bundler.with_unbundled_env { run "bundle install" }
6
-
7
- rails_command "generate cancan:ability"
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- run "bundle add devise"
4
- Bundler.with_unbundled_env { run "bundle install" }
5
-
6
- rails_command "generate devise:install"
7
-
8
- run "rails generate devise User"
9
- run "rails db:create"
10
- run "rails db:migrate"
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- run "bundle add omniauth"
4
-
5
- run "bundle install"
6
-
7
- # rubocop:disable Layout/LineLength
8
- rails_command "generate model identity user:references provider:string:index uid:string:index token:string:index refresh_token:string:index"
9
- # rubocop:enable Layout/LineLength
10
-
11
- rails_command "generate migration AddIdentityToUsers identities_count:integer"
12
-
13
- rails_command "db:migrate"
14
-
15
- inject_into_file "config/routes.rb", after: "devise_for :users\n" do
16
- " # devise_for :users, controllers: { omniauth_callbacks: 'omniauth' }"
17
- end
18
-
19
- inject_into_file "app/models/user.rb", after: ":database_authenticatable, " do
20
- ":omniauthable, "
21
- end
22
-
23
- inject_into_file "app/models/identity.rb", after: "belongs_to :user" do
24
- ", counter_cache: true"
25
- end
26
-
27
- inject_into_file "app/models/user.rb", after: "class User < ApplicationRecord\n" do
28
- # rubocop:disable Naming/HeredocDelimiterNaming
29
- <<-EOF
30
- has_many :identities, dependent: :destroy
31
-
32
- def self.from_omniauth(auth)
33
- if auth.present? && auth.provider.present? && auth.uid.present?
34
- identity = Identity.where(provider: auth.provider, uid: auth.uid).first_or_initialize
35
- if auth.credentials.present?
36
- identity.token = auth.credentials.token
37
- identity.refresh_token = auth.credentials.refresh_token
38
- end
39
- if identity.user.nil? && auth.info.email.present?
40
- user = User.where(email: auth.info.email).first_or_initialize
41
- user.name = auth.info.name
42
- user.password = Devise.friendly_token if user.new_record?
43
- user.save!
44
- identity.user = user
45
- end
46
- identity.save!
47
- identity.user
48
- end
49
- end
50
-
51
- EOF
52
- # rubocop:enable Naming/HeredocDelimiterNaming
53
- end
54
-
55
- file "app/controllers/omniauth_controller.rb", <<~CODE
56
- class OmniauthController < Devise::OmniauthCallbacksController
57
-
58
- end
59
- CODE
60
-
61
- puts "IMPORTANT: Add devise_for :users, controllers: { omniauth_callbacks: 'omniauth' } to your routes.rb"
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- run "bundle add pundit"
4
-
5
- puts "Add - Pundit module to Application Controller"
6
- puts ""
7
-
8
- inject_into_file "app/controllers/application_controller.rb",
9
- after: "class ApplicationController < ActionController::Base\n" do
10
- " include Pundit\n"
11
- end
12
-
13
- puts "Run - Pundit Generator"
14
-
15
- rails_command("generate pundit:install")
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- run "rails db:prepare"
4
- run "bundle add rails_admin"
5
-
6
- Bundler.with_unbundled_env { run "bundle install" }
7
-
8
- rails_command("generate rails_admin:install")
9
-
10
- puts "RailsAdmin is installed! You can go to your admin panel at /admin"
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- run "spring stop"
4
-
5
- gem_group :development, :test do
6
- gem "rspec-rails"
7
- end
8
-
9
- Bundler.with_unbundled_env { run "bundle install" }
10
-
11
- rails_command "generate rspec:install"
12
-
13
- puts "RSpec is installed!"
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- gem_group :development do
4
- gem "rubocop", require: false
5
- end
6
-
7
- Bundler.with_unbundled_env { run "bundle install" }
8
-
9
- run "rubocop --auto-gen-config"
10
- run "bundle binstubs rubocop"
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- def file_contains?(filename, string)
4
- File.foreach(filename).detect { |line| line.include?(string) }
5
- end
6
-
7
- run "bundle add sidekiq"
8
- run "bundle add redis" unless file_contains? "Gemfile", "Gem 'redis'"
9
-
10
- Bundler.with_unbundled_env { run "bundle install" }
11
-
12
- # rubocop:disable Naming/HeredocDelimiterNaming
13
- application do
14
- <<~EOF
15
- config.active_job.queue_adapter = :sidekiq
16
- EOF
17
- end
18
-
19
- inject_into_file "config/routes.rb" do
20
- <<~EOF
21
- require "sidekiq/web"
22
- if Rails.env.production?
23
- Sidekiq::Web.use Rack::Auth::Basic do |username, password|
24
- ActiveSupport::SecurityUtils.secure_compare(::Digest::SHA256.hexdigest(username), ::Digest::SHA256.hexdigest(ENV["SIDEKIQ_USERNAME"])) &
25
- ActiveSupport::SecurityUtils.secure_compare(::Digest::SHA256.hexdigest(password), ::Digest::SHA256.hexdigest(ENV["SIDEKIQ_PASSWORD"]))
26
- end
27
- end
28
- EOF
29
- end
30
- # rubocop:enable Naming/HeredocDelimiterNaming
31
-
32
- route 'mount Sidekiq::Web => "/sidekiq"'
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- gem_group :development, :test do
4
- gem "standard"
5
- end
6
-
7
- Bundler.with_unbundled_env { run "bundle install" }
8
-
9
- puts "You can then run Standard from the command line with:"
10
- puts "bundle exec standardrb"