Class: Fastlane::Actions::SwiftformatAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::SwiftformatAction
- Defined in:
- lib/fastlane/plugin/swiftformat/actions/swiftformat_action.rb
Documentation collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .output ⇒ Object
- .return_value ⇒ Object
Class Method Summary collapse
Class Method Details
.authors ⇒ Object
121 122 123 |
# File 'lib/fastlane/plugin/swiftformat/actions/swiftformat_action.rb', line 121 def self. ["fxm90"] end |
.available_options ⇒ Object
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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/fastlane/plugin/swiftformat/actions/swiftformat_action.rb', line 51 def self. [ FastlaneCore::ConfigItem.new(key: :executable, env_name: "SWIFTFORMAT_EXECUTABLE", description: "Path to the `swiftformat` executable on your machine", is_string: true, optional: true, verify_block: proc do |value| UI.user_error!("Couldn't find path '#{File.expand_path(value)}'") unless File.exist?(value) || Helper.test? end), FastlaneCore::ConfigItem.new(key: :path, env_name: "SWIFTFORMAT_PATH", description: "Path to format", is_string: true, optional: true, verify_block: proc do |value| UI.user_error!("Couldn't find path '#{File.expand_path(value)}'") unless File.exist?(value) || Helper.test? end), FastlaneCore::ConfigItem.new(key: :rules, env_name: "SWIFTFORMAT_RULES", description: "Specify a whitelist of rules", is_string: false, optional: true), FastlaneCore::ConfigItem.new(key: :disable, env_name: "SWIFTFORMAT_DISABLE", description: "Specify rules to disable", is_string: false, optional: true), FastlaneCore::ConfigItem.new(key: :enable, env_name: "SWIFTFORMAT_ENABLE", description: "Specify rules to enable", is_string: false, optional: true), FastlaneCore::ConfigItem.new(key: :swiftversion, env_name: "SWIFTFORMAT_SWIFTVERSION", description: "Specify swift version", is_string: false, optional: true), FastlaneCore::ConfigItem.new(key: :config, env_name: "SWIFTFORMAT_CONFIG", description: "Path to configuration file", is_string: true, optional: true, verify_block: proc do |value| UI.user_error!("Couldn't find path '#{File.expand_path(value)}'") unless File.exist?(value) || Helper.test? end), FastlaneCore::ConfigItem.new(key: :header, env_name: "SWIFTFORMAT_HEADER", description: "Strip or replace the header comments in every file with the given template", is_string: true, optional: true), FastlaneCore::ConfigItem.new(key: :dryrun, env_name: "SWIFTFORMAT_DRYRUN", description: "Run in dry mode (without actually changing any files)", is_string: false, optional: true), FastlaneCore::ConfigItem.new(key: :lint, env_name: "SWIFTFORMAT_LINT", description: "Like `--dryrun`, but returns an error if formatting is needed", is_string: false, optional: true) ] end |
.category ⇒ Object
146 147 148 |
# File 'lib/fastlane/plugin/swiftformat/actions/swiftformat_action.rb', line 146 def self.category :testing end |
.description ⇒ Object
43 44 45 |
# File 'lib/fastlane/plugin/swiftformat/actions/swiftformat_action.rb', line 43 def self.description "Run swift code formatting using SwiftFormat" end |
.details ⇒ Object
47 48 49 |
# File 'lib/fastlane/plugin/swiftformat/actions/swiftformat_action.rb', line 47 def self.details "Run swift code formatting using [SwiftFormat](https://github.com/nicklockwood/SwiftFormat). Please specify your options using a `.swiftformat` file. An up-to-date list with all available rules can be found in [Rules.md](https://github.com/nicklockwood/SwiftFormat/blob/master/Rules.md) along with documentation for how they are used." end |
.example_code ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/fastlane/plugin/swiftformat/actions/swiftformat_action.rb', line 129 def self.example_code [ 'swiftformat( executable: "Pods/SwiftFormat/CommandLineTool/swiftformat", # Path to the `swiftformat` executable on your machine (optional) path: "path/to/format", # Path to format (optional) rules: "indent,linebreaks", # Specify a whitelist of rules (optional) disable: "redundantSelf,trailingClosures", # Specify rules to disable (optional) enable: "isEmpty", # Specify rules to enable (optional) swiftversion: "5.1" # Specify swift version (optional) config: "path/to/configuration/.swiftformat" # Path to configuration file (optional) header: "{file}\nCopyright (c) 2022 Foobar Industries" # Strip or replace the header comments in every file with the given template (optional) dryrun: false, # Run in dry mode (without actually changing any files) (optional) lint: true # Like `--dryrun`, but returns an error if formatting is needed (optional) )' ] end |
.is_supported?(platform) ⇒ Boolean
125 126 127 |
# File 'lib/fastlane/plugin/swiftformat/actions/swiftformat_action.rb', line 125 def self.is_supported?(platform) [:ios, :mac].include?(platform) end |
.output ⇒ Object
115 116 |
# File 'lib/fastlane/plugin/swiftformat/actions/swiftformat_action.rb', line 115 def self.output end |
.return_value ⇒ Object
118 119 |
# File 'lib/fastlane/plugin/swiftformat/actions/swiftformat_action.rb', line 118 def self.return_value 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 32 33 34 35 36 37 |
# File 'lib/fastlane/plugin/swiftformat/actions/swiftformat_action.rb', line 7 def self.run(params) if `which swiftformat`.to_s.length == 0 && params[:executable].nil? && !Helper.test? UI.user_error!("You have to install swiftformat using `brew install swiftformat` or specify the executable path with the `:executable` option.") end command = "" if params[:executable] command << params[:executable] else command << "swiftformat" end if params[:path] command << " #{params[:path].shellescape}" else command << " ." end command << " --rules #{params[:rules].shellescape}" if params[:rules] command << " --disable #{params[:disable].shellescape}" if params[:disable] command << " --enable #{params[:enable].shellescape}" if params[:enable] command << " --swiftversion #{params[:swiftversion].shellescape}" if params[:swiftversion] command << " --config #{params[:config].shellescape}" if params[:config] command << ' --header "' + params[:header] + '"' if params[:header] command << " --dryrun" if params[:dryrun] command << " --lint" if params[:lint] Actions.sh(command) end |