Class: Fastlane::Actions::SpmAction

Inherits:
Fastlane::Action show all
Defined in:
fastlane/lib/fastlane/actions/spm.rb

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, deprecated_notes, details, lane_context, method_missing, other_action, output, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorsObject



72
73
74
# File 'fastlane/lib/fastlane/actions/spm.rb', line 72

def self.authors
  ["Flávio Caetano (@fjcaetano)"]
end

.available_commandsObject



95
96
97
# File 'fastlane/lib/fastlane/actions/spm.rb', line 95

def self.available_commands
  %w(build test) + self.package_commands
end

.available_optionsObject



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
# File 'fastlane/lib/fastlane/actions/spm.rb', line 31

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: :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: :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: :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: :verbose,
                                 short_option: "-v",
                                 env_name: "FL_SPM_VERBOSE",
                                 description: "Increase verbosity of informational output",
                                 is_string: false,
                                 default_value: false)
  ]
end

.categoryObject



91
92
93
# File 'fastlane/lib/fastlane/actions/spm.rb', line 91

def self.category
  :building
end

.descriptionObject



27
28
29
# File 'fastlane/lib/fastlane/actions/spm.rb', line 27

def self.description
  "Runs Swift Package Manager on your project"
end

.example_codeObject



80
81
82
83
84
85
86
87
88
89
# File 'fastlane/lib/fastlane/actions/spm.rb', line 80

def self.example_code
  [
    'spm',
    'spm(
      command: "build",
      build_path: "./build",
      configuration: "release"
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



76
77
78
# File 'fastlane/lib/fastlane/actions/spm.rb', line 76

def self.is_supported?(platform)
  true
end

.package_commandsObject



99
100
101
# File 'fastlane/lib/fastlane/actions/spm.rb', line 99

def self.package_commands
  %w(clean reset update)
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 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 << "--verbose" if params[:verbose]
  if params[:xcpretty_output]
    cmd += ["2>&1", "|", "xcpretty", "--#{params[:xcpretty_output]}"]
    cmd = %w(set -o pipefail &&) + cmd
  end
  cmd << params[:command] if package_commands.include?(params[:command])

  FastlaneCore::CommandExecutor.execute(command: cmd.join(" "),
                                        print_all: true,
                                        print_command: true)
end

.valid_configurationsObject



103
104
105
# File 'fastlane/lib/fastlane/actions/spm.rb', line 103

def self.valid_configurations
  %w(debug release)
end

.xcpretty_output_typesObject



107
108
109
# File 'fastlane/lib/fastlane/actions/spm.rb', line 107

def self.xcpretty_output_types
  %w(simple test knock tap)
end