rails-interactive 2.1.2 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d5f8f264844d295476f2a3a1b5321d4a24efd197385a3e46476b9e6912fdd35d
4
- data.tar.gz: 0a305f3ddd4307d3380034b784d5a2e8f2e708c65be9039b5603e479a0e29fbd
3
+ metadata.gz: a8f73ef75d5e0f8f36b2206dc2b36f11e9d3a64103496d03b893bbf431cce3c9
4
+ data.tar.gz: 48036a06a2a349f958e34249c833b9462ff4a1452feadd9e611a2880ec34ffad
5
5
  SHA512:
6
- metadata.gz: 11ba30482ac8c3892b7c103fd2e11e4e92fe6cf9fad851f264e526d2af50c2e2203240aabe18b4fcdccf0846a6f5d9fbe5773990d11fef9100d2d40875346f64
7
- data.tar.gz: e3b1de0b4b081528d4a0260531e0ec30814d55da0b5e543e0b4dcece30954a3376593be483f14ddb191c52cb4f0a7ea8da940acb008c3a21ccbee68b8e5454f6
6
+ metadata.gz: bd644861a5cc67eaab30f629965a36ce3bb9fea78d071055e6ede9ddea5296f44f9be1f05cf2ca21c128f3b7352f73bad60474ec6e6f4c596e1ad5592c656352
7
+ data.tar.gz: 0baa8477280f02d4d564cb54e9a3e478160b1c0c3e13610b8ec2ef806f6b4d033303a1bf26b0218e6bd1894050111cd447bd5b2f47927b71665316512e1a9629
data/.rubocop.yml CHANGED
@@ -19,4 +19,10 @@ Metrics/MethodLength:
19
19
  Max: 12
20
20
 
21
21
  Metrics/CyclomaticComplexity:
22
- Max: 25
22
+ Max: 25
23
+
24
+ Metrics/PerceivedComplexity:
25
+ Max: 10
26
+
27
+ Metrics/AbcSize:
28
+ Enabled: false
data/Gemfile.lock CHANGED
@@ -1,73 +1,73 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails-interactive (2.1.2)
4
+ rails-interactive (2.1.3)
5
5
  tty-prompt
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (7.0.3)
11
- actionpack (= 7.0.3)
12
- activesupport (= 7.0.3)
10
+ actioncable (7.0.3.1)
11
+ actionpack (= 7.0.3.1)
12
+ activesupport (= 7.0.3.1)
13
13
  nio4r (~> 2.0)
14
14
  websocket-driver (>= 0.6.1)
15
- actionmailbox (7.0.3)
16
- actionpack (= 7.0.3)
17
- activejob (= 7.0.3)
18
- activerecord (= 7.0.3)
19
- activestorage (= 7.0.3)
20
- activesupport (= 7.0.3)
15
+ actionmailbox (7.0.3.1)
16
+ actionpack (= 7.0.3.1)
17
+ activejob (= 7.0.3.1)
18
+ activerecord (= 7.0.3.1)
19
+ activestorage (= 7.0.3.1)
20
+ activesupport (= 7.0.3.1)
21
21
  mail (>= 2.7.1)
22
22
  net-imap
23
23
  net-pop
24
24
  net-smtp
25
- actionmailer (7.0.3)
26
- actionpack (= 7.0.3)
27
- actionview (= 7.0.3)
28
- activejob (= 7.0.3)
29
- activesupport (= 7.0.3)
25
+ actionmailer (7.0.3.1)
26
+ actionpack (= 7.0.3.1)
27
+ actionview (= 7.0.3.1)
28
+ activejob (= 7.0.3.1)
29
+ activesupport (= 7.0.3.1)
30
30
  mail (~> 2.5, >= 2.5.4)
31
31
  net-imap
32
32
  net-pop
33
33
  net-smtp
34
34
  rails-dom-testing (~> 2.0)
35
- actionpack (7.0.3)
36
- actionview (= 7.0.3)
37
- activesupport (= 7.0.3)
35
+ actionpack (7.0.3.1)
36
+ actionview (= 7.0.3.1)
37
+ activesupport (= 7.0.3.1)
38
38
  rack (~> 2.0, >= 2.2.0)
39
39
  rack-test (>= 0.6.3)
40
40
  rails-dom-testing (~> 2.0)
41
41
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
42
- actiontext (7.0.3)
43
- actionpack (= 7.0.3)
44
- activerecord (= 7.0.3)
45
- activestorage (= 7.0.3)
46
- activesupport (= 7.0.3)
42
+ actiontext (7.0.3.1)
43
+ actionpack (= 7.0.3.1)
44
+ activerecord (= 7.0.3.1)
45
+ activestorage (= 7.0.3.1)
46
+ activesupport (= 7.0.3.1)
47
47
  globalid (>= 0.6.0)
48
48
  nokogiri (>= 1.8.5)
49
- actionview (7.0.3)
50
- activesupport (= 7.0.3)
49
+ actionview (7.0.3.1)
50
+ activesupport (= 7.0.3.1)
51
51
  builder (~> 3.1)
52
52
  erubi (~> 1.4)
53
53
  rails-dom-testing (~> 2.0)
54
54
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
55
- activejob (7.0.3)
56
- activesupport (= 7.0.3)
55
+ activejob (7.0.3.1)
56
+ activesupport (= 7.0.3.1)
57
57
  globalid (>= 0.3.6)
58
- activemodel (7.0.3)
59
- activesupport (= 7.0.3)
60
- activerecord (7.0.3)
61
- activemodel (= 7.0.3)
62
- activesupport (= 7.0.3)
63
- activestorage (7.0.3)
64
- actionpack (= 7.0.3)
65
- activejob (= 7.0.3)
66
- activerecord (= 7.0.3)
67
- activesupport (= 7.0.3)
58
+ activemodel (7.0.3.1)
59
+ activesupport (= 7.0.3.1)
60
+ activerecord (7.0.3.1)
61
+ activemodel (= 7.0.3.1)
62
+ activesupport (= 7.0.3.1)
63
+ activestorage (7.0.3.1)
64
+ actionpack (= 7.0.3.1)
65
+ activejob (= 7.0.3.1)
66
+ activerecord (= 7.0.3.1)
67
+ activesupport (= 7.0.3.1)
68
68
  marcel (~> 1.0)
69
69
  mini_mime (>= 1.1.0)
70
- activesupport (7.0.3)
70
+ activesupport (7.0.3.1)
71
71
  concurrent-ruby (~> 1.0, >= 1.0.2)
72
72
  i18n (>= 1.6, < 2)
73
73
  minitest (>= 5.1)
@@ -84,8 +84,9 @@ GEM
84
84
  erubi (1.10.0)
85
85
  globalid (1.0.0)
86
86
  activesupport (>= 5.0)
87
- i18n (1.10.0)
87
+ i18n (1.12.0)
88
88
  concurrent-ruby (~> 1.0)
89
+ json (2.6.2)
89
90
  loofah (2.18.0)
90
91
  crass (~> 1.0.2)
91
92
  nokogiri (>= 1.5.9)
@@ -94,7 +95,7 @@ GEM
94
95
  marcel (1.0.2)
95
96
  method_source (1.0.0)
96
97
  mini_mime (1.1.2)
97
- minitest (5.15.0)
98
+ minitest (5.16.2)
98
99
  net-imap (0.2.3)
99
100
  digest
100
101
  net-protocol
@@ -110,9 +111,9 @@ GEM
110
111
  net-protocol
111
112
  timeout
112
113
  nio4r (2.5.8)
113
- nokogiri (1.13.6-x86_64-darwin)
114
+ nokogiri (1.13.7-x86_64-darwin)
114
115
  racc (~> 1.4)
115
- nokogiri (1.13.6-x86_64-linux)
116
+ nokogiri (1.13.7-x86_64-linux)
116
117
  racc (~> 1.4)
117
118
  parallel (1.22.1)
118
119
  parser (3.1.2.0)
@@ -123,31 +124,31 @@ GEM
123
124
  coderay (~> 1.1)
124
125
  method_source (~> 1.0)
125
126
  racc (1.6.0)
126
- rack (2.2.3.1)
127
- rack-test (1.1.0)
128
- rack (>= 1.0, < 3)
129
- rails (7.0.3)
130
- actioncable (= 7.0.3)
131
- actionmailbox (= 7.0.3)
132
- actionmailer (= 7.0.3)
133
- actionpack (= 7.0.3)
134
- actiontext (= 7.0.3)
135
- actionview (= 7.0.3)
136
- activejob (= 7.0.3)
137
- activemodel (= 7.0.3)
138
- activerecord (= 7.0.3)
139
- activestorage (= 7.0.3)
140
- activesupport (= 7.0.3)
127
+ rack (2.2.4)
128
+ rack-test (2.0.2)
129
+ rack (>= 1.3)
130
+ rails (7.0.3.1)
131
+ actioncable (= 7.0.3.1)
132
+ actionmailbox (= 7.0.3.1)
133
+ actionmailer (= 7.0.3.1)
134
+ actionpack (= 7.0.3.1)
135
+ actiontext (= 7.0.3.1)
136
+ actionview (= 7.0.3.1)
137
+ activejob (= 7.0.3.1)
138
+ activemodel (= 7.0.3.1)
139
+ activerecord (= 7.0.3.1)
140
+ activestorage (= 7.0.3.1)
141
+ activesupport (= 7.0.3.1)
141
142
  bundler (>= 1.15.0)
142
- railties (= 7.0.3)
143
+ railties (= 7.0.3.1)
143
144
  rails-dom-testing (2.0.3)
144
145
  activesupport (>= 4.2.0)
145
146
  nokogiri (>= 1.6)
146
- rails-html-sanitizer (1.4.2)
147
+ rails-html-sanitizer (1.4.3)
147
148
  loofah (~> 2.3)
148
- railties (7.0.3)
149
- actionpack (= 7.0.3)
150
- activesupport (= 7.0.3)
149
+ railties (7.0.3.1)
150
+ actionpack (= 7.0.3.1)
151
+ activesupport (= 7.0.3.1)
151
152
  method_source
152
153
  rake (>= 12.2)
153
154
  thor (~> 1.0)
@@ -169,7 +170,8 @@ GEM
169
170
  diff-lcs (>= 1.2.0, < 2.0)
170
171
  rspec-support (~> 3.11.0)
171
172
  rspec-support (3.11.0)
172
- rubocop (1.30.0)
173
+ rubocop (1.31.2)
174
+ json (~> 2.3)
173
175
  parallel (~> 1.10)
174
176
  parser (>= 3.1.0.0)
175
177
  rainbow (>= 2.2.2, < 4.0)
@@ -178,7 +180,7 @@ GEM
178
180
  rubocop-ast (>= 1.18.0, < 2.0)
179
181
  ruby-progressbar (~> 1.7)
180
182
  unicode-display_width (>= 1.4.0, < 3.0)
181
- rubocop-ast (1.18.0)
183
+ rubocop-ast (1.19.1)
182
184
  parser (>= 3.1.1.0)
183
185
  ruby-progressbar (1.11.0)
184
186
  strscan (3.0.3)
@@ -196,13 +198,13 @@ GEM
196
198
  tty-screen (0.8.1)
197
199
  tzinfo (2.0.4)
198
200
  concurrent-ruby (~> 1.0)
199
- unicode-display_width (2.1.0)
201
+ unicode-display_width (2.2.0)
200
202
  websocket-driver (0.7.5)
201
203
  websocket-extensions (>= 0.1.0)
202
204
  websocket-extensions (0.1.5)
203
205
  wisper (2.0.1)
204
206
  yaml (0.2.0)
205
- zeitwerk (2.5.4)
207
+ zeitwerk (2.6.0)
206
208
 
207
209
  PLATFORMS
208
210
  x86_64-darwin-20
@@ -25,32 +25,42 @@
25
25
  type: "select"
26
26
  required: false
27
27
  -
28
- name: code_quality
28
+ name: frontend
29
29
  weight: 6
30
30
  type: "select"
31
31
  required: false
32
32
  -
33
- name: background_job
33
+ name: css_framework
34
34
  weight: 7
35
35
  type: "select"
36
36
  required: false
37
37
  -
38
- name: security
38
+ name: background_job
39
39
  weight: 8
40
40
  type: "select"
41
41
  required: false
42
42
  -
43
- name: admin_panel
43
+ name: code_quality
44
44
  weight: 9
45
45
  type: "select"
46
46
  required: false
47
47
  -
48
- name: features
48
+ name: security
49
49
  weight: 10
50
+ type: "select"
51
+ required: false
52
+ -
53
+ name: admin_panel
54
+ weight: 11
55
+ type: "select"
56
+ required: false
57
+ -
58
+ name: features
59
+ weight: 12
50
60
  type: "multi_select"
51
61
  required: false
52
62
  -
53
63
  name: development
54
- weight: 11
64
+ weight: 13
55
65
  type: "multi_select"
56
66
  required: false
@@ -151,4 +151,22 @@
151
151
  name: Capybara
152
152
  category: end_to_end_testing
153
153
  description: "Acceptance test framework for web applications. For details: https://github.com/teamcapybara/capybara"
154
+ dependencies: null
155
+ -
156
+ identifier: stimulus
157
+ name: StimulusJS
158
+ category: frontend
159
+ description: "A modest JavaScript framework for the HTML you already have. For details: https://github.com/hotwired/stimulus"
160
+ dependencies: null
161
+ -
162
+ identifier: react
163
+ name: ReactJS
164
+ category: frontend
165
+ description: "A declarative, efficient, and flexible JavaScript library for building user interfaces. For details: https://github.com/facebook/react/"
166
+ dependencies: null
167
+ -
168
+ identifier: tailwind
169
+ name: Tailwind
170
+ category: css_framework
171
+ description: "A utility-first CSS framework for rapid UI development. For details: https://github.com/tailwindlabs/tailwindcss"
154
172
  dependencies: null
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ # NPM
4
+ run "yarn init -y"
5
+ run "yarn add esbuild react react-dom"
6
+
7
+ # rubocop:disable Layout/LineLength
8
+ run "npm set-script build 'esbuild app/javascript/*.* --bundle --sourcemap --loader:.js=jsx --outdir=app/assets/javascripts'"
9
+ # rubocop:enable Layout/LineLength
10
+ #
11
+ # Foreman
12
+ run "gem install foreman"
13
+ run 'echo "#!/usr/bin/env bash\nforeman start -f Procfile.dev "$@"" > bin/dev'
14
+ run "echo 'web: bin/rails server -p 3000\njs: yarn build --watch' > Procfile.dev"
15
+ run "chmod u+x bin/dev"
16
+
17
+ # Component Helper from Ruby on Rails
18
+ inject_into_file "app/helpers/application_helper.rb", after: "module ApplicationHelper" do
19
+ <<~RB
20
+
21
+ def react_component(component_name, **props)
22
+ tag.div(data: {
23
+ react_component: component_name,
24
+ props: props.to_json
25
+ }) { '' }
26
+ end
27
+ RB
28
+ end
29
+
30
+ # Include JS to application.html.erb
31
+ inject_into_file "app/views/layouts/application.html.erb", after: "<%= javascript_importmap_tags %>" do
32
+ <<~ERB
33
+
34
+ <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>
35
+ ERB
36
+ end
37
+
38
+ # Component Mounter for JS
39
+ create_file "app/javascript/mount.js" do
40
+ <<~JAVASCRIPT
41
+ import React from 'react';
42
+ import ReactDOM from 'react-dom';
43
+
44
+ export default function mount(components = {}) {
45
+ const mountPoints = document.querySelectorAll('[data-react-component]');
46
+ mountPoints.forEach((mountPoint) => {
47
+ const { dataset } = mountPoint;
48
+ const componentName = dataset.reactComponent;
49
+ const Component = components[componentName];
50
+
51
+ if (Component) {
52
+ const props = JSON.parse(dataset.props);
53
+ ReactDOM.render(<Component {...props} />, mountPoint);
54
+ }
55
+ });
56
+ }
57
+ JAVASCRIPT
58
+ end
59
+
60
+ # Example React Component
61
+ create_file "app/javascript/components/hello.jsx" do
62
+ <<~JAVASCRIPT
63
+ import React from "react";
64
+
65
+ const Hello = () => <div>HELLO WORLD!</div>
66
+
67
+ export default Hello;
68
+ JAVASCRIPT
69
+ end
70
+
71
+ # rubocop:disable Layout/LineLength
72
+ # Application JS file update
73
+ inject_into_file "app/javascript/application.js",
74
+ after: "// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails" do
75
+ <<~JAVASCRIPT
76
+
77
+ // Components
78
+ import Hello from "./components/hello"
79
+
80
+ // Component Mounter
81
+ import mount from './mount'
82
+
83
+ // Mount Components
84
+ mount({ Hello });
85
+ JAVASCRIPT
86
+ end
87
+ # rubocop:enable Layout/LineLength
88
+
89
+ run "yarn build"
90
+
91
+ # Example Page for Component Test
92
+ rails_command "g controller Home index"
93
+ inject_into_file "app/views/home/index.html.erb", after: "<p>Find me in app/views/home/index.html.erb</p>" do
94
+ <<~ERB
95
+
96
+ <%= react_component "Hello" %>
97
+ ERB
98
+ end
99
+
100
+ puts "React is installed! You can run bin/dev then go to home/index and see the Hello World component."
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ run "bundle add turbo-rails"
4
+ run "bundle add stimulus-rails"
5
+
6
+ Bundler.with_unbundled_env { run "bundle install" }
7
+
8
+ rails_command "turbo:install stimulus:install"
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ def package?(package)
4
+ require "json"
5
+
6
+ file = File.open("package.json") if File.file?("package.json")
7
+
8
+ packages = JSON.parse(file.read) if file
9
+
10
+ packages["dependencies"].include?(package) if packages
11
+ end
12
+
13
+ run "bundle add tailwindcss-rails"
14
+
15
+ if package?("react")
16
+ run "rm Procfile.dev"
17
+ run "rm bin/dev"
18
+ end
19
+
20
+ rails_command "tailwindcss:install"
21
+
22
+ if package?("react")
23
+ run "rm Procfile.dev"
24
+ run "echo 'web: bin/rails server -p 3000\njs: yarn build --watch\ncss: bin/rails tailwindcss:watch' > Procfile.dev"
25
+ end
data/lib/cli/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RailsInteractive
4
4
  class CLI
5
- VERSION = "2.1.2"
5
+ VERSION = "2.1.3"
6
6
  end
7
7
  end
@@ -63,7 +63,7 @@ module RailsInteractive
63
63
 
64
64
  @inputs.first(3).each { |_key, value| cmd += "#{value} " unless value.empty? }
65
65
 
66
- "#{base} #{cmd} -q"
66
+ "#{base} #{cmd} -q --skip-hotwire"
67
67
  end
68
68
 
69
69
  def create_project
@@ -72,7 +72,7 @@ module RailsInteractive
72
72
  # Create project
73
73
  system(setup)
74
74
  # Install gems
75
- intall_gems
75
+ install_gems
76
76
  # Prepare project requirements and give instructions
77
77
  Utils.sign_project
78
78
  Message.prepare
@@ -95,19 +95,21 @@ module RailsInteractive
95
95
  list
96
96
  end
97
97
 
98
- def intall_gems
98
+ def install_gems
99
99
  # Copy template files to project folder
100
100
  Utils.copy_templates_to_project(@inputs[:name])
101
101
 
102
102
  @inputs.each do |key, value|
103
103
  next if %i[name type database].include?(key) || value.is_a?(Array) && value.empty? || value.nil?
104
104
 
105
- dependencies = @commands.dependencies(value)
106
-
105
+ dependencies ||= @commands.dependencies(value)
107
106
  @handler.handle_multi_options(value, dependencies) if value.is_a?(Array)
108
107
  @handler.handle_option(value, dependencies) if value.is_a?(String)
109
108
  end
110
109
 
110
+ # Prepare database for project everytime
111
+ system("bin/rails db:prepare")
112
+
111
113
  # Remove templates folder from project folder
112
114
  Utils.remove_templates(@inputs[:name])
113
115
  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: 2.1.2
4
+ version: 2.1.3
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-06-05 00:00:00.000000000 Z
11
+ date: 2022-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -189,12 +189,15 @@ files:
189
189
  - lib/cli/templates/setup_omniauth.rb
190
190
  - lib/cli/templates/setup_pundit.rb
191
191
  - lib/cli/templates/setup_rails_admin.rb
192
+ - lib/cli/templates/setup_react.rb
192
193
  - lib/cli/templates/setup_rspec.rb
193
194
  - lib/cli/templates/setup_rubocop.rb
194
195
  - lib/cli/templates/setup_sassc_rails.rb
195
196
  - lib/cli/templates/setup_sidekiq.rb
196
197
  - lib/cli/templates/setup_slim.rb
197
198
  - lib/cli/templates/setup_standardrb.rb
199
+ - lib/cli/templates/setup_stimulus.rb
200
+ - lib/cli/templates/setup_tailwind.rb
198
201
  - lib/cli/utils.rb
199
202
  - lib/cli/version.rb
200
203
  - lib/rails_interactive.rb