Class: Frozen::Generators::SsgGenerator

Inherits:
FrozenRails::Generator show all
Defined in:
lib/generators/frozen/ssg_generator.rb

Constant Summary

Constants included from Nodeable

Nodeable::REQUIRED_EXECUTABLES

Instance Method Summary collapse

Instance Method Details

#add_gemsObject



10
11
12
13
14
15
# File 'lib/generators/frozen/ssg_generator.rb', line 10

def add_gems
  add_frozen_gems <<~RUBY
    # frozen:ssg
    gem "parklife-rails"
  RUBY
end

#bundle_gemsObject



17
18
19
# File 'lib/generators/frozen/ssg_generator.rb', line 17

def bundle_gems
  bundle!
end

#configure_parklife_active_storage_integrationObject



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/generators/frozen/ssg_generator.rb', line 37

def configure_parklife_active_storage_integration
  copy_file "storage.yml", "config/storage.yml", force: true

  uncomment_lines "config/environments/production.rb", /config\.assume_ssl = true/
  gsub_file "config/environments/production.rb", /config\.active_storage\.service = :\w+/, "config.active_storage.service = :parklife"

  insert_into_file "config/application.rb", "\n" + <<~RUBY, before: /(\n#.*)?\n#.*\nBundler\.require/
    # frozen:ssg
    if ARGV.first == "build"
      require "parklife-rails/activestorage"
    end
  RUBY
end

#run_parklife_initObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/generators/frozen/ssg_generator.rb', line 21

def run_parklife_init
  run "bundle exec parklife init --rails --github-pages"
  append_to_file ".gitignore", "# frozen:ssg\n/build\n"

  insert_into_file ".github/workflows/parklife.yml", <<YAML, before: "\n    - uses: actions/checkout@v4"

    - name: Install packages
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y libvips
YAML
end

#setup_gitlab_pagesObject



32
33
34
35
# File 'lib/generators/frozen/ssg_generator.rb', line 32

def setup_gitlab_pages
  copy_file ".gitlab-ci.yml"
  comment_lines "Parkfile", /config\.nested_index = false/
end