rails_app_generator 0.1.2 → 0.1.3

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.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/after_templates/rag_tailwind.rb +2 -4
  4. data/after_templates/rag_tailwind_daisyui/index.html.erb +181 -0
  5. data/after_templates/rag_tailwind_daisyui.rb +25 -0
  6. data/after_templates/rag_tailwind_hotwire_form/_contact.html.erb +8 -0
  7. data/after_templates/rag_tailwind_hotwire_form/_count.html.erb +1 -0
  8. data/after_templates/rag_tailwind_hotwire_form/_flash.html.erb +6 -0
  9. data/after_templates/rag_tailwind_hotwire_form/_form.html.erb +16 -0
  10. data/after_templates/rag_tailwind_hotwire_form/_list.html.erb +19 -0
  11. data/after_templates/rag_tailwind_hotwire_form/application.html.erb +24 -0
  12. data/after_templates/rag_tailwind_hotwire_form/application.js +30 -0
  13. data/after_templates/rag_tailwind_hotwire_form/application.tailwind.css +111 -0
  14. data/after_templates/rag_tailwind_hotwire_form/application_helper.rb +15 -0
  15. data/after_templates/rag_tailwind_hotwire_form/contact.rb +5 -0
  16. data/after_templates/rag_tailwind_hotwire_form/contacts_controller.rb +98 -0
  17. data/after_templates/rag_tailwind_hotwire_form/create.turbo_stream.erb +4 -0
  18. data/after_templates/rag_tailwind_hotwire_form/edit.html.erb +12 -0
  19. data/after_templates/rag_tailwind_hotwire_form/index.html.erb +5 -0
  20. data/after_templates/rag_tailwind_hotwire_form/new.html.erb +12 -0
  21. data/after_templates/rag_tailwind_hotwire_form/show.html.erb +16 -0
  22. data/after_templates/rag_tailwind_hotwire_form/update.turbo_stream.erb +2 -0
  23. data/after_templates/rag_tailwind_hotwire_form.rb +54 -0
  24. data/lib/rails_app_generator/app_generator.rb +21 -0
  25. data/lib/rails_app_generator/diff/open_in_editor.rb +1 -1
  26. data/lib/rails_app_generator/diff/processor.rb +7 -1
  27. data/lib/rails_app_generator/version.rb +1 -1
  28. data/package-lock.json +1019 -85
  29. data/package.json +4 -1
  30. data/profiles/rag-tailwind-daisyui.json +10 -0
  31. data/profiles/rag-tailwind-hotwire-form.json +13 -0
  32. metadata +24 -2
@@ -0,0 +1,16 @@
1
+ <div class="prose lg:prose-xl">
2
+ <h1>Contact details</h2>
3
+ </div>
4
+
5
+ <div class="w-1/2 mx-auto p-8 border-2 m-8 grid grid-cols-2 gap-4">
6
+ <div>
7
+ <div class="my-4">Name: <%= @contact.name %></div>
8
+ <hr />
9
+ <div class="my-4">Age: <%= @contact.age %></div>
10
+ <hr />
11
+ <div class="my-4">Email: <%= @contact.email %></div>
12
+ </div>
13
+ <div>
14
+ <img src="https://i.pravatar.cc/300" />
15
+ </div>
16
+ </div>
@@ -0,0 +1,2 @@
1
+ <%= turbo_stream.update("flash", partial: "shared/flash") %>
2
+ <%= turbo_stream.replace(dom_id(@contact), partial: "contacts/contact", locals: { contact: @contact }) %>
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ # How to Start a Ruby on Rails 7 App With Hotwire and Tailwind CSS
4
+ # https://www.youtube.com/watch?v=7G0oWn2Gn5c
5
+
6
+ require 'pry'
7
+
8
+ self.local_template_path = File.join(File.dirname(__FILE__), 'rag_tailwind_hotwire_form')
9
+
10
+ gac 'base rails 7 image created'
11
+
12
+ route("resources :contacts")
13
+ route("root 'contacts#index'")
14
+
15
+ after_bundle do
16
+ gsub_file 'app/views/layouts/application.html.erb', %(container mx-auto mt-28 px-5 flex), 'container mt-8 mx-auto'
17
+
18
+ # add_scaffold('contact', 'name', 'email')
19
+ add_migration('create_contacts', 'name', 'email', 'age:integer')
20
+ # rails generate migration CreateUsers name:string salary:decimal
21
+
22
+ copy_file 'contact.rb' , 'app/models/contact.rb'
23
+ copy_file 'contacts_controller.rb' , 'app/controllers/contacts_controller.rb'
24
+
25
+ copy_file '_contact.html.erb' , 'app/views/contacts/_contact.html.erb'
26
+ copy_file '_count.html.erb' , 'app/views/contacts/_count.html.erb'
27
+ copy_file '_form.html.erb' , 'app/views/contacts/_form.html.erb'
28
+ copy_file '_list.html.erb' , 'app/views/contacts/_list.html.erb'
29
+ copy_file 'edit.html.erb' , 'app/views/contacts/edit.html.erb'
30
+ copy_file 'index.html.erb' , 'app/views/contacts/index.html.erb'
31
+ copy_file 'new.html.erb' , 'app/views/contacts/new.html.erb'
32
+ copy_file 'show.html.erb' , 'app/views/contacts/show.html.erb'
33
+
34
+ copy_file 'application_helper.rb' , 'app/helpers/application_helper.rb' , force: true
35
+ copy_file 'application.html.erb' , 'app/views/layouts/application.html.erb' , force: true
36
+ copy_file 'create.turbo_stream.erb' , 'app/views/contacts/create.turbo_stream.erb'
37
+ copy_file 'update.turbo_stream.erb' , 'app/views/contacts/update.turbo_stream.erb'
38
+ copy_file 'application.js' , 'app/javascript/application.js' , force: true
39
+
40
+ copy_file '_flash.html.erb' , 'app/views/shared/_flash.html.erb'
41
+
42
+ # Install tailwind directly, instead of via the --css=tailwind option so that we can configure 3rd party plugins
43
+ # gem "jsbundling-rails"
44
+ gem "cssbundling-rails"
45
+
46
+ rails_command('css:install:tailwind')
47
+ run('npm install daisyui')
48
+ # run('@tailwindcss/typography') , require(\"@tailwindcss/typography\")
49
+
50
+ gsub_file 'tailwind.config.js', %(]\n}), "],\n plugins: [require(\"daisyui\")],\n}"
51
+ copy_file 'application.tailwind.css' , 'app/assets/stylesheets/application.tailwind.css' , force: true
52
+
53
+ rails_command('db:migrate')
54
+ end
@@ -171,6 +171,23 @@ module RailsAppGenerator
171
171
  end
172
172
 
173
173
  no_commands do
174
+ # Template command examples
175
+ # gac 'base rails 7 image created'
176
+ # add_controller('home', 'index')
177
+ # add_scaffold('people', 'first_name', 'last_name', 'age:integer', 'address:text')
178
+ # route("root 'home#index'")
179
+ # gem "cssbundling-rails"
180
+ # rails_command('db:migrate')
181
+ # bundle_add('hotwire-rails')
182
+ # rails_command('hotwire:install')
183
+ # run('bin/importmap pin sortablejs')
184
+ # run('npm install daisyui')
185
+ # create_file 'app/assets/stylesheets/custom-bootstrap-import.scss' , read_template('custom-bootstrap-import.scss')
186
+ # append_to_file 'app/assets/config/manifest.js' , read_template('manifest.js')
187
+ # insert_into_file 'app/views/layouts/application.html.erb', read_template('application.html.erb'),
188
+ # gsub_file 'app/views/layouts/application.html.erb', %(container mx-auto mt-28 px-5 flex), 'container mx-auto px-5'
189
+ # template 'home.css', 'app/assets/stylesheets/home.css'
190
+
174
191
  # USED BY AFTER_TEMPLATE
175
192
  def gac(message)
176
193
  return unless active?(:git)
@@ -187,6 +204,10 @@ module RailsAppGenerator
187
204
  generate(:scaffold, name, *args)
188
205
  end
189
206
 
207
+ def add_migration(name, *args)
208
+ generate(:migration, name, *args)
209
+ end
210
+
190
211
  def bundle_add(name)
191
212
  run("bundle add #{name}")
192
213
  end
@@ -15,7 +15,7 @@ module RailsAppGenerator
15
15
  @info = compare_info
16
16
 
17
17
  @open_left_only = opts[:open_left_only].nil? ? false : opts[:open_left_only]
18
- @open_right_only = opts[:open_right_only].nil? ? true : opts[:open_right_only]
18
+ @open_right_only = opts[:open_right_only].nil? ? false : opts[:open_right_only]
19
19
  @open_same = opts[:open_same].nil? ? false : opts[:open_same]
20
20
  @open_different = opts[:open_different].nil? ? true : opts[:open_different]
21
21
  end
@@ -11,7 +11,13 @@ module RailsAppGenerator
11
11
  relative_file.start_with?('tmp') ||
12
12
  relative_file.start_with?('node_modules') ||
13
13
  relative_file.start_with?('log') ||
14
- relative_file == 'Gemfile.lock'
14
+ relative_file.start_with?('db') ||
15
+ relative_file.start_with?('app/assets/builds') ||
16
+ relative_file == 'Gemfile.lock' ||
17
+ relative_file == 'Package.lock' ||
18
+ relative_file == 'Yarn.lock' ||
19
+ relative_file == 'config/master.key' ||
20
+ relative_file == 'config/credentials.yml.enc'
15
21
  end
16
22
 
17
23
  def initialize(lhs_path, rhs_path)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsAppGenerator
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.3'
5
5
  end