Last active 1771353053

Dumpling app template

Revision 95665d1fbe8a4b55ac608cc357c08f186ecb1674

dumpling.rb Raw
1# Rails Application Template
2# Apply all uncommitted changes
3
4# Download custom .rubocop.yml from URL
5get 'https://gist.gyozaguy.dev/GyozaGuy/cdd6fa0cc913430d8951de685f840e6a/raw/HEAD/.rubocop.yml', '.rubocop.yml'
6
7# Remove omakase rubocop gem and add standard rubocop
8gsub_file 'Gemfile', /^\s+# Omakase Ruby styling.*\n\s+gem ['"]rubocop-rails-omakase['"], require: false\n/m, ''
9insert_into_file 'Gemfile', " gem 'rubocop'\n", after: "group :development do\n"
10
11# Define custom git source shorthand :gg
12# This allows gems to be specified with `gem 'name', gg: 'repo'` syntax
13insert_into_file 'Gemfile',
14 "\n\nsource 'https://git.gyozaguy.com/api/packages/GyozaGuy/rubygems' do\n\tgem 'dumpling', '~> 1.0'\nend"
15
16# Add dumpling gem using the custom :gg git source shorthand
17# This will fetch the gem from https://git.gyozaguy.com/GyozaGuy/dumpling.git
18gem 'dumpling', gg: 'GyozaGuy/dumpling'
19
20# Create application_layout.rb
21file 'app/views/layouts/application_layout.rb', <<~RUBY
22 class Layouts::ApplicationLayout < Components::Layout
23 def view_template(&)
24 doctype
25
26 html(**locale_props, **theme_props) {
27 head {
28 title { "\#{content_for(:page_title) || 'Loading...'} :: Replace Me" }
29 default_meta
30 link(href: '/icon.png', rel: 'icon', type: 'image/png')
31 link(href: '/icon.svg', rel: 'icon', type: 'image/svg+xml')
32 link(href: '/icon.png', rel: 'apple-touch-icon')
33 default_stylesheets
34 default_javascript
35 }
36
37 body(id: page_id) {
38 main(&)
39 }
40 }
41 end
42 end
43RUBY
44
45# Modify application_controller.rb
46gsub_file 'app/controllers/application_controller.rb',
47 'class ApplicationController < ActionController::Base',
48 'class ApplicationController < Dumpling::ApplicationController'
49
50# Run RuboCop auto-correct to standardize quotes and other style issues
51after_bundle do
52 say 'Running RuboCop auto-correct to standardize quotes and other style issues...'
53 run 'bundle exec rubocop -a'
54 say 'RuboCop auto-correction completed!'
55end
56
57# Remove default application.html.erb layout as we're using application_layout.rb instead
58remove_file 'app/views/layouts/application.html.erb'
59
60puts 'Template applied successfully!'
61puts 'Remember to run bundle install to update your gems'