Class: Bridgetown::Commands::Build

Inherits:
Thor::Group
  • Object
show all
Extended by:
BuildOptions, Summarizable
Includes:
ConfigurationOverridable
Defined in:
bridgetown-core/lib/bridgetown-core/commands/build.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BuildOptions

extended

Methods included from Summarizable

summary

Methods included from ConfigurationOverridable

#configuration_with_overrides, included

Class Method Details



14
15
16
# File 'bridgetown-core/lib/bridgetown-core/commands/build.rb', line 14

def self.banner
  "bridgetown build [options]"
end


24
25
26
27
# File 'bridgetown-core/lib/bridgetown-core/commands/build.rb', line 24

def self.print_startup_message
  Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta} " \
                                      "(codename \"#{Bridgetown::CODE_NAME.yellow}\")"
end

Instance Method Details

#buildObject

Build your bridgetown site Continuously watch if watch is set to true in the config.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'bridgetown-core/lib/bridgetown-core/commands/build.rb', line 31

def build
  Bridgetown.logger.adjust_verbosity(options)

  # @type [Bridgetown::Configuration]
  config_options = configuration_with_overrides(
    options, Bridgetown::Current.preloaded_configuration
  )

  self.class.print_startup_message unless config_options["start_command"]

  Process.setproctitle(
    "bridgetown #{Bridgetown::VERSION} " \
    "(#{config_options["start_command"] ? "start" : "build"}) [#{File.basename(Dir.pwd)}]"
  )

  config_options.run_initializers! context: :static

  if !Bridgetown.env.production? &&
      !config_options[:skip_frontend] && config_options["start_command"]
    if Bridgetown::Utils.frontend_bundler_type(config_options[:root_dir]) == :esbuild
      Bridgetown::Utils.update_esbuild_autogenerated_config config_options
    end
    require "rake"
    Rake.with_application do |rake|
      rake.load_rakefile
      rake["frontend:watcher"].invoke(true)
    end
  end

  @site = Bridgetown::Site.new(config_options)

  if config_options.fetch("skip_initial_build", false)
    Bridgetown.logger.warn "Build Warning:", "Skipping the initial build. " \
                                             "This may result in an out-of-date site."
  else
    build_site(config_options)
  end

  # TODO: remove this logic…I can't find "detach" anywhere
  if config_options.fetch("detach", false)
    Bridgetown.logger.info "Auto-regeneration:",
                           "disabled when running server detached."
  elsif config_options.fetch("watch", false)
    watch_site(config_options)
  else
    Bridgetown.logger.info "Auto-regeneration:", "disabled. Use --watch to enable."
  end
end