Class: Fastlane::Actions::DepmanAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/depman/actions/depman_action.rb

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



90
91
92
# File 'lib/fastlane/plugin/depman/actions/depman_action.rb', line 90

def self.authors
  ["[email protected]"]
end

.available_optionsObject



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
79
80
81
82
83
84
# File 'lib/fastlane/plugin/depman/actions/depman_action.rb', line 49

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :project_root,
                                  env_name: "FL_DEPMAN_PROJECT_ROOT",
                                  description: "The path to your project",
                                  optional: false,
                                  verify_block: proc do |value|
                                    UI.user_error!("Couldn't find file at path '#{value}'") unless value.nil? || File.exist?(value)
                                  end),
    FastlaneCore::ConfigItem.new(key: :server_host,
                                 env_name: "FL_DEPMAN_SERVER_HOST",
                                 description: "Depman server address",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :auth_token,
                                 env_name: "FL_DEPMAN_AUTH_TOKEN",
                                 description: "Project access token",
                                 optional: true,
                                 is_string: true,
                                 sensitive: true),
    FastlaneCore::ConfigItem.new(key: :project_name,
                                 env_name: "FL_DEPMAN_PROJECT_NAME",
                                 description: "Project key",
                                 optional: true,
                                 is_string: true),
    FastlaneCore::ConfigItem.new(key: :project_version,
                                 env_name: "FL_DEPMAN_PROJECT_VERSION",
                                 description: "Project version",
                                 optional: true,
                                 is_string: true),
    FastlaneCore::ConfigItem.new(key: :project_platform,
                                 env_name: "FL_DEPMAN_PROJECT_PLATFORM",
                                 description: "One of: gradle, maven, cocoapods, npm",
                                 optional: true,
                                 is_string: true),
  ]
end

.categoryObject



111
112
113
# File 'lib/fastlane/plugin/depman/actions/depman_action.rb', line 111

def self.category
  :testing
end

.descriptionObject



41
42
43
# File 'lib/fastlane/plugin/depman/actions/depman_action.rb', line 41

def self.description
  "Arcsinus Dependency manager"
end

.detailsObject



45
46
47
# File 'lib/fastlane/plugin/depman/actions/depman_action.rb', line 45

def self.details
  "Invokes depman-scanner to programmatically run Depman analysis"
end

.example_codeObject



98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/fastlane/plugin/depman/actions/depman_action.rb', line 98

def self.example_code
  [
    'depman(
      project_root: File.expand_path("../MyProject"),
      server_host: "depman.company.org",
      auth_token: "1234567890abcdef",
      project_name: "my-project",
      project_version: "1.0",
      project_platform: "gradle"
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean



94
95
96
# File 'lib/fastlane/plugin/depman/actions/depman_action.rb', line 94

def self.is_supported?(platform)
  true
end

.return_valueObject



86
87
88
# File 'lib/fastlane/plugin/depman/actions/depman_action.rb', line 86

def self.return_value
  "The exit code of the depman-scanner binary"
end

.run(params) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fastlane/plugin/depman/actions/depman_action.rb', line 7

def self.run(params)
  verify_depman_scanner_binary

  command_prefix = [
    'cd',
    File.expand_path('.').shellescape,
    '&&'
  ].join(' ')

  depman_scanner_args = []
  depman_scanner_args << "--src=\"#{params[:project_root]}\"" if params[:project_root]
  depman_scanner_args << "--host=\"#{params[:server_host]}\"" if params[:server_host]
  depman_scanner_args << "--token=\"#{params[:auth_token]}\"" if params[:auth_token]
  depman_scanner_args << "--name=\"#{params[:project_name]}\"" if params[:project_name]
  depman_scanner_args << "--version=\"#{params[:project_version]}\"" if params[:project_version]
  depman_scanner_args << "--platform=\"#{params[:project_platform]}\"" if params[:project_platform]
       
  command = [
    command_prefix,
    'depman-scanner',
    depman_scanner_args
  ].join(' ')
  # hide command, as it may contain credentials

  Fastlane::Actions.sh_control_output(command, print_command: false, print_command_output: true)
end

.verify_depman_scanner_binaryObject



33
34
35
# File 'lib/fastlane/plugin/depman/actions/depman_action.rb', line 33

def self.verify_depman_scanner_binary
  UI.user_error!("You have to install depman-scanner") unless `which depman-scanner`.to_s.length > 0
end