class Highway::Main
This class is a main entry point to Highway
.
Public Class Methods
new(entrypoint:, path:, preset:, fastlane_runner:, fastlane_lane_context:)
click to toggle source
Initialize an instance.
@param entrypoint [Symbol] The entry point. @param path [String] Path to the configuration file. @param preset [String] Preset to run. @param fastlane_runner [Fastlane::Runner] The fastlane runner. @param fastlane_lane_context [Hash] The fastlane lane context.
# File lib/highway/main.rb, line 29 def initialize(entrypoint:, path:, preset:, fastlane_runner:, fastlane_lane_context:) @entrypoint = entrypoint @path = path @preset = preset @fastlane_runner = fastlane_runner @fastlane_lane_context = fastlane_lane_context end
Public Instance Methods
run()
click to toggle source
Run Highway
.
@return [Void]
# File lib/highway/main.rb, line 40 def run() # Always run Highway in the root directory of the project. This should # standardize the legacy directory behavior described here: # https://docs.fastlane.tools/advanced/fastlane/#directory-behavior. Dir.chdir(running_dir) do # Print the header, similar to Fastlane's "driving the lane". interface.success("Driving the Highway preset '#{@preset}' 🏎") # Construct a steps registry and load steps from the default library # by requiring files in `highway/steps/library` and registering all # classes that inherit from `Highway::Steps::Step`. registry = Steps::Registry.new_and_load_default_library() # Set up the compiler and compile Highway configuration file into the # build manifest. See `highway/compiler/parse`, `highway/compiler/analyze` # and `highway/compiler/build` for more information. compiler = Compiler::Suite.new( registry: registry, interface: interface, ) manifest = compiler.compile( path: File.expand_path(@path, running_dir), preset: @preset, ) # At this point the compilation is done. Now, construct the runtime # context, set up the runner and run the compiled build manifest. context = Runtime::Context.new( fastlane_runner: @fastlane_runner, fastlane_lane_context: @fastlane_lane_context, env: env, interface: interface, ) runner = Runtime::Runner.new( manifest: manifest, context: context, interface: interface, ) runner.run() # We can safely print the success summary message because fatal errors # will be catched by the rescue block below. @interface.whitespace() @interface.success("Wubba lubba dub dub, Highway preset '#{@preset}' has succeeded!") end rescue StandardError => error # Unless the error contains any message we should print it right now but # as an error so that we can still control the output. interface.error(error) unless error.message.empty? # We should take care of the unnecessary printing of Fastlane lane # context but only if we're running from lane entry point (otherwise we # could affect other actions and fallback lanes user has set up). # # So, if we're running from lane entry point, we should clear the lane # context before raising a fatal error. If we're in verbose mode, we # should additionally print it before cleaning. if @entrypoint == :lane report_fastlane_lane_context() if env.verbose? clear_fastlane_lane_context() end # Now we throw a fatal error that tells Fastlane to abort. interface.whitespace() interface.fatal!("Highway preset '#{@preset}' has failed with one or more errors. Please examine the above log.") end
Private Instance Methods
clear_fastlane_lane_context()
click to toggle source
Clear all values in Fastlane
lane context.
@return [Void]
# File lib/highway/main.rb, line 167 def clear_fastlane_lane_context() @fastlane_lane_context.clear() end
env()
click to toggle source
The environment instance.
@return [Highway::Environment]
# File lib/highway/main.rb, line 130 def env @env ||= Environment.new() end
interface()
click to toggle source
The interface instance.
@return [Highway::Interface]
# File lib/highway/main.rb, line 137 def interface @interface ||= Interface.new() end
report_fastlane_lane_context()
click to toggle source
Report Fastlane
lane context as a table.
@return [Void]
# File lib/highway/main.rb, line 151 def report_fastlane_lane_context() lane_context_rows = @fastlane_lane_context.collect do |key, content| [key, content.to_s] end interface.table( title: "Fastlane Context".yellow, rows: lane_context_rows ) end
running_dir()
click to toggle source
The running directory to be used.
@return [Path]
# File lib/highway/main.rb, line 144 def running_dir File.expand_path(File.join(FastlaneCore::FastlaneFolder.path, "..")) end