最后活跃于 1752035659

Dumpling app template - Web Awesome alpha

dumpling.rb 原始文件
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 "\ngit_source(:gg) { |repo| \"https://git.gyozaguy.com/\#{repo}.git\" }\n",
15 after: 'source "https://rubygems.org"'
16
17# Add dumpling gem using the custom :gg git source shorthand
18# This will fetch the gem from https://git.gyozaguy.com/GyozaGuy/dumpling.git
19gem 'dumpling', gg: 'GyozaGuy/dumpling'
20
21# Create application_layout.rb
22file 'app/views/layouts/application_layout.rb', <<~RUBY
23 class Layouts::ApplicationLayout < Components::Layout
24 def view_template(&)
25 doctype
26
27 html(**locale_props, **theme_props(theme: 'dark')) {
28 head {
29 title { "\#{content_for(:page_title) || 'Loading...'} :: Replace Me" }
30 default_meta
31 link(href: '/icon.png', rel: 'icon', type: 'image/png')
32 link(href: '/icon.svg', rel: 'icon', type: 'image/svg+xml')
33 link(href: '/icon.png', rel: 'apple-touch-icon')
34 default_stylesheets
35 default_javascript
36 }
37
38 body(id: page_id) {
39 main(&)
40 }
41 }
42 end
43 end
44RUBY
45
46# Modify application_controller.rb
47gsub_file 'app/controllers/application_controller.rb',
48 'class ApplicationController < ActionController::Base',
49 'class ApplicationController < Dumpling::ApplicationController'
50
51# Run RuboCop auto-correct to standardize quotes and other style issues
52after_bundle do
53 say 'Running RuboCop auto-correct to standardize quotes and other style issues...'
54 run 'bundle exec rubocop -a'
55 say 'RuboCop auto-correction completed!'
56end
57
58# Remove default application.html.erb layout as we're using application_layout.rb instead
59remove_file 'app/views/layouts/application.html.erb'
60
61puts 'Template applied successfully!'
62puts 'Remember to run bundle install to update your gems'