Class: Sitepress::CLI
- Inherits:
-
Thor
- Object
- Thor
- Sitepress::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/sitepress/cli.rb
Overview
Command line interface for compiling Sitepress sites.
Constant Summary collapse
- SERVER_PORT =
Default port address for server port.
8080
- SERVER_BIND_ADDRESS =
Default address is public to all IPs.
"127.0.0.1".freeze
- COMPILE_TARGET_PATH =
Default build path for compiler.
"./build".freeze
- SERVER_SITE_ERROR_REPORTING =
Display detailed error messages to the developer. Useful for development environments where the error should be displayed to the developer so they can debug errors.
true
- SERVER_SITE_RELOADING =
Reload the site between requests, useful for development environments when the site has to be rebuilt between requests. Disable in production environments to run the site faster.
true
Instance Method Summary collapse
Instance Method Details
#compile ⇒ Object
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 79 80 81 82 |
# File 'lib/sitepress/cli.rb', line 53 def compile initialize! logger.info "Sitepress compiling assets" sprockets_manifest(target_path: .fetch("output_path")).compile precompile_assets logger.info "Sitepress compiling pages" compiler = Compiler::Files.new \ site: configuration.site, root_path: .fetch("output_path"), fail_on_error: .fetch("fail_on_error") begin compiler.compile ensure logger.info "" logger.info "Compilation Summary" logger.info " Build path: #{compiler.root_path.}" logger.info " Succeeded: #{compiler.succeeded.count}" logger.info " Failed: #{compiler.failed.count}" if compiler.failed.any? logger.info "" logger.info "Failed Resources" compiler.failed.each do |resource| logger.info " #{resource.request_path} #{resource.asset.path}" end abort # We want a non-zero exit code so we can fail CI pipelines, etc. end end end |
#console ⇒ Object
85 86 87 88 89 |
# File 'lib/sitepress/cli.rb', line 85 def console initialize! # Start's an interactive console. REPL.new(context: configuration).start end |
#new(target) ⇒ Object
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/sitepress/cli.rb', line 92 def new(target) # Peg the generated site to roughly the released version. *segments, _ = Gem::Version.new(Sitepress::VERSION).segments @target_sitepress_version = segments.join(".") inside target do directory self.class.source_root, "." run "bundle install" end end |
#server ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/sitepress/cli.rb', line 33 def server # Now boot everything for the Rack server to pickup. initialize! do |app| # Enable Sitepress web error reporting so users have more friendly # error messages instead of seeing a Rails exception. app.config.enable_site_error_reporting = .fetch("site_error_reporting") # Enable reloading the site between requests so we can see changes. app.config.enable_site_reloading = .fetch("site_reloading") end # This will use whatever server is found in the user's Gemfile. Rack::Server.start app: app, Port: .fetch("port"), Host: .fetch("bind_address") end |
#version ⇒ Object
104 105 106 |
# File 'lib/sitepress/cli.rb', line 104 def version say Sitepress::VERSION end |