Class: Fastlane::Actions::AppstorePrecheckAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::AppstorePrecheckAction
- Defined in:
- lib/fastlane/plugin/appstore_precheck/actions/appstore_precheck_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .return_value ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
66 67 68 |
# File 'lib/fastlane/plugin/appstore_precheck/actions/appstore_precheck_action.rb', line 66 def self. ['berkayturk'] end |
.available_options ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/fastlane/plugin/appstore_precheck/actions/appstore_precheck_action.rb', line 70 def self. [ FastlaneCore::ConfigItem.new( key: :dir, env_name: 'APPSTORE_PRECHECK_DIR', description: 'Directory to scan', type: String, default_value: '.' ), FastlaneCore::ConfigItem.new( key: :fail_on, env_name: 'APPSTORE_PRECHECK_FAIL_ON', description: 'Fail the lane at RED (default) or YELLOW', type: String, default_value: 'RED' ), FastlaneCore::ConfigItem.new( key: :fail_build, env_name: 'APPSTORE_PRECHECK_FAIL_BUILD', description: 'Raise when the gate is hit; set false to only warn and return the verdict', type: Boolean, default_value: true ), FastlaneCore::ConfigItem.new( key: :cli_path, env_name: 'APPSTORE_PRECHECK_CLI_PATH', description: 'Explicit path to the appstore-precheck executable (default: PATH, then npx)', type: String, optional: true ) ] end |
.category ⇒ Object
111 112 113 |
# File 'lib/fastlane/plugin/appstore_precheck/actions/appstore_precheck_action.rb', line 111 def self.category :testing end |
.description ⇒ Object
52 53 54 |
# File 'lib/fastlane/plugin/appstore_precheck/actions/appstore_precheck_action.rb', line 52 def self.description 'Read-only iOS App Store pre-submission scan (42 rejection vectors) as a lane gate' end |
.details ⇒ Object
56 57 58 59 60 |
# File 'lib/fastlane/plugin/appstore_precheck/actions/appstore_precheck_action.rb', line 56 def self.details 'Runs the appstore-precheck static scanner (https://github.com/berkayturk/appstore-precheck) ' \ 'over the project and fails the lane when the GREEN/YELLOW/RED verdict is at or past fail_on. ' \ 'The scan is read-only, needs no credentials, and never edits your files.' end |
.example_code ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/fastlane/plugin/appstore_precheck/actions/appstore_precheck_action.rb', line 103 def self.example_code [ 'appstore_precheck', "appstore_precheck(fail_on: 'YELLOW')", "verdict = appstore_precheck(fail_build: false)\n slack(message: \"Precheck verdict: \#{verdict}\") if verdict != 'GREEN'" ] end |
.is_supported?(platform) ⇒ Boolean
115 116 117 |
# File 'lib/fastlane/plugin/appstore_precheck/actions/appstore_precheck_action.rb', line 115 def self.is_supported?(platform) [:ios, :mac].include?(platform) end |
.return_value ⇒ Object
62 63 64 |
# File 'lib/fastlane/plugin/appstore_precheck/actions/appstore_precheck_action.rb', line 62 def self.return_value "The verdict as a String: 'GREEN', 'YELLOW', or 'RED'." end |
.run(params) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fastlane/plugin/appstore_precheck/actions/appstore_precheck_action.rb', line 8 def self.run(params) runner = Fastlane::AppstorePrecheck::Runner unless runner.valid_fail_on?(params[:fail_on]) UI.user_error!("appstore_precheck: fail_on must be RED or YELLOW (got '#{params[:fail_on]}')") end command = runner.resolve_command(cli_path: params[:cli_path]) if command.nil? UI.user_error!( 'appstore_precheck: scanner not found. Install it with ' \ '`brew install berkayturk/tap/appstore-precheck` or `npm i -g appstore-precheck`, ' \ 'or pass cli_path.' ) end argv = command + ['--dir', params[:dir], '--fail-on', params[:fail_on].to_s.upcase] UI.("appstore_precheck: running #{argv.join(' ')}") output, status = Open3.capture2e(*argv) output.each_line { |line| UI.(line.chomp) } verdict = runner.parse_verdict(output) UI.user_error!('appstore_precheck: scanner produced no verdict (see output above)') if verdict.nil? # Exit codes: 0 ok, 1 gate hit, 64 bad usage, 70 environment error. if !status.exitstatus.nil? && status.exitstatus > 1 UI.user_error!("appstore_precheck: scanner failed (exit #{status.exitstatus}, see output above)") end if runner.gate_hit?(verdict, params[:fail_on]) = "appstore_precheck: verdict is #{verdict} (gate: #{params[:fail_on]}) — submission blocked" if params[:fail_build] UI.user_error!() else UI.important("#{} (fail_build: false, continuing)") end else UI.success("appstore_precheck: verdict is #{verdict} 🟢") end verdict end |