class Fastlane::Actions::SpmAction

Public Class Methods

authors() click to toggle source
# File fastlane/lib/fastlane/actions/spm.rb, line 100
def self.authors
  ["fjcaetano", "nxtstep"]
end
available_commands() click to toggle source
# File fastlane/lib/fastlane/actions/spm.rb, line 127
def self.available_commands
  %w(build test) + self.package_commands
end
available_options() click to toggle source
# File fastlane/lib/fastlane/actions/spm.rb, line 39
def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :command,
                                 env_name: "FL_SPM_COMMAND",
                                 description: "The swift command (one of: #{available_commands.join(', ')})",
                                 default_value: "build",
                                 verify_block: proc do |value|
                                   UI.user_error!("Please pass a valid command. Use one of the following: #{available_commands.join(', ')}") unless available_commands.include?(value)
                                 end),
    FastlaneCore::ConfigItem.new(key: :enable_code_coverage,
                                 env_name: "FL_SPM_ENABLE_CODE_COVERAGE",
                                 description: "Enables code coverage for the generated Xcode project when using the 'generate-xcodeproj' and the 'test' command",
                                 type: Boolean,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :build_path,
                                 env_name: "FL_SPM_BUILD_PATH",
                                 description: "Specify build/cache directory [default: ./.build]",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :package_path,
                                 env_name: "FL_SPM_PACKAGE_PATH",
                                 description: "Change working directory before any other operation",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :xcconfig,
                                 env_name: "FL_SPM_XCCONFIG",
                                 description: "Use xcconfig file to override swift package generate-xcodeproj defaults",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :configuration,
                                 short_option: "-c",
                                 env_name: "FL_SPM_CONFIGURATION",
                                 description: "Build with configuration (debug|release) [default: debug]",
                                 optional: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("Please pass a valid configuration: (debug|release)") unless valid_configurations.include?(value)
                                 end),
    FastlaneCore::ConfigItem.new(key: :disable_sandbox,
                                 env_name: "FL_SPM_DISABLE_SANDBOX",
                                 description: "Disable using the sandbox when executing subprocesses",
                                 optional: true,
                                 type: Boolean,
                                 default_value: false),
    FastlaneCore::ConfigItem.new(key: :xcpretty_output,
                                 env_name: "FL_SPM_XCPRETTY_OUTPUT",
                                 description: "Specifies the output type for xcpretty. eg. 'test', or 'simple'",
                                 optional: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("Please pass a valid xcpretty output type: (#{xcpretty_output_types.join('|')})") unless xcpretty_output_types.include?(value)
                                 end),
    FastlaneCore::ConfigItem.new(key: :xcpretty_args,
                                 env_name: "FL_SPM_XCPRETTY_ARGS",
                                 description: "Pass in xcpretty additional command line arguments (e.g. '--test --no-color' or '--tap --no-utf'), requires xcpretty_output to be specified also",
                                 type: String,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :verbose,
                                 short_option: "-v",
                                 env_name: "FL_SPM_VERBOSE",
                                 description: "Increase verbosity of informational output",
                                 type: Boolean,
                                 default_value: false)
  ]
end
category() click to toggle source
# File fastlane/lib/fastlane/actions/spm.rb, line 123
def self.category
  :building
end
description() click to toggle source

@!group Documentation

# File fastlane/lib/fastlane/actions/spm.rb, line 35
def self.description
  "Runs Swift Package Manager on your project"
end
example_code() click to toggle source
# File fastlane/lib/fastlane/actions/spm.rb, line 108
def self.example_code
  [
    'spm',
    'spm(
      command: "build",
      build_path: "./build",
      configuration: "release"
    )',
    'spm(
      command: "generate-xcodeproj",
      xcconfig: "Package.xcconfig"
    )'
  ]
end
is_supported?(platform) click to toggle source
# File fastlane/lib/fastlane/actions/spm.rb, line 104
def self.is_supported?(platform)
  true
end
package_commands() click to toggle source
# File fastlane/lib/fastlane/actions/spm.rb, line 131
def self.package_commands
  %w(clean reset update resolve generate-xcodeproj init)
end
run(params) click to toggle source
# File fastlane/lib/fastlane/actions/spm.rb, line 4
def self.run(params)
  cmd = ["swift"]

  cmd << (package_commands.include?(params[:command]) ? "package" : params[:command])
  cmd << "--build-path #{params[:build_path]}" if params[:build_path]
  cmd << "--package-path #{params[:package_path]}" if params[:package_path]
  cmd << "--configuration #{params[:configuration]}" if params[:configuration]
  cmd << "--disable-sandbox" if params[:disable_sandbox]
  cmd << "--verbose" if params[:verbose]
  cmd << params[:command] if package_commands.include?(params[:command])
  cmd << "--enable-code-coverage" if params[:enable_code_coverage] && (params[:command] == 'generate-xcodeproj' || params[:command] == 'test')
  if params[:xcconfig]
    cmd << "--xcconfig-overrides #{params[:xcconfig]}"
  end
  if params[:xcpretty_output]
    cmd += ["2>&1", "|", "xcpretty", "--#{params[:xcpretty_output]}"]
    if params[:xcpretty_args]
      cmd << (params[:xcpretty_args]).to_s
    end
    cmd = %w(set -o pipefail &&) + cmd
  end

  FastlaneCore::CommandExecutor.execute(command: cmd.join(" "),
                                        print_all: true,
                                        print_command: true)
end
valid_configurations() click to toggle source
# File fastlane/lib/fastlane/actions/spm.rb, line 135
def self.valid_configurations
  %w(debug release)
end
xcpretty_output_types() click to toggle source
# File fastlane/lib/fastlane/actions/spm.rb, line 139
def self.xcpretty_output_types
  %w(simple test knock tap)
end