fastlane-plugin-swiftformat 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e72acfd10fcf8470ad31b0201f0dd372f605b4e2
4
+ data.tar.gz: 517c364dc1d4cb78c13ac15be61eff9bd5a8780d
5
+ SHA512:
6
+ metadata.gz: 71995b5bda7b711ca58d8c2dd0ace837ae1b9f39ceef2e4b10c18c7b8772b51317d2a2034e9b5e311baf1726c5e4b2f623412b2ae619bf66e53c16a690277d15
7
+ data.tar.gz: 874f0c92fd85c735a46604201c2d0ab00c3d5268e7b61eb38d60695b7bd1466b3e297c7e2f126b7b3555089314041f9d0051be6a0e5641fe26265ccd7c977d08
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Felix Mau <me@felix.hamburg>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,50 @@
1
+ # fastlane-plugin-swiftformat
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-swiftformat)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-swiftformat`, add it to your project by running:
8
+
9
+ ```bash
10
+ gem "fastlane-plugin-swiftformat", git: "https://github.com/fxm90/fastlane-plugin-swiftformat"
11
+ ```
12
+
13
+ ## About fastlane-plugin-swiftformat
14
+
15
+ Run swift code formatting using [SwiftFormat](https://github.com/nicklockwood/SwiftFormat) with fastlane. 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.
16
+
17
+ ##### Example Code
18
+ ```ruby
19
+ swiftformat(
20
+ executable: "Pods/SwiftFormat/CommandLineTool/swiftformat", # Path to the `swiftformat` executable on your machine (optional)
21
+ path: "path/to/format", # Path to format (optional)
22
+ rules: "indent,linebreaks", # Specify a whitelist of rules (optional)
23
+ disable: "redundantSelf,trailingClosures", # Specify rules to disable (optional)
24
+ enable: "isEmpty", # Specify rules to enable (optional)
25
+ swiftversion: "5.1" # Specify swift version (optional)
26
+ config: "path/to/configuration/.swiftformat" # Path to configuration file (optional)
27
+ dryrun: false, # Run in dry mode (without actually changing any files) (optional)
28
+ lint: true # Like `--dryrun`, but returns an error if formatting is needed (optional)
29
+ )
30
+ ```
31
+
32
+ ## Run tests for this plugin
33
+
34
+ To run both the tests, and code style validation, run
35
+
36
+ ```
37
+ rake
38
+ ```
39
+
40
+ ## Issues and Feedback
41
+
42
+ For any other issues and feedback about this plugin, please submit it to this repository.
43
+
44
+ ## Using _fastlane_ Plugins
45
+
46
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
47
+
48
+ ## About _fastlane_
49
+
50
+ _fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/swiftformat/version'
2
+
3
+ module Fastlane
4
+ module Swiftformat
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
8
+ end
9
+ end
10
+ end
11
+
12
+ # By default we want to import all available actions and helpers
13
+ # A plugin can contain any number of actions and plugins
14
+ Fastlane::Swiftformat.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,135 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/swiftformat_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class SwiftformatAction < Action
7
+ def self.run(params)
8
+ if `which swiftformat`.to_s.length == 0 && params[:executable].nil? && !Helper.test?
9
+ UI.user_error!("You have to install swiftformat using `brew install swiftformat` or specify the executable path with the `:executable` option.")
10
+ end
11
+
12
+ command = ""
13
+ if params[:executable]
14
+ command << params[:executable]
15
+ else
16
+ command << "swiftformat"
17
+ end
18
+
19
+ if params[:path]
20
+ command << " #{params[:path].shellescape}"
21
+ else
22
+ command << " ."
23
+ end
24
+
25
+ command << " --rules #{params[:rules].shellescape}" if params[:rules]
26
+ command << " --disable #{params[:disable].shellescape}" if params[:disable]
27
+ command << " --enable #{params[:enable].shellescape}" if params[:enable]
28
+
29
+ command << " --swiftversion #{params[:swiftversion].shellescape}" if params[:swiftversion]
30
+ command << " --config #{params[:config].shellescape}" if params[:config]
31
+
32
+ command << " --dryrun" if params[:dryrun]
33
+ command << " --lint" if params[:lint]
34
+
35
+ Actions.sh(command)
36
+ end
37
+
38
+ #####################################################
39
+ # @!group Documentation
40
+ #####################################################
41
+
42
+ def self.description
43
+ "Run swift code formatting using SwiftFormat"
44
+ end
45
+
46
+ def self.details
47
+ "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."
48
+ end
49
+
50
+ def self.available_options
51
+ [
52
+ FastlaneCore::ConfigItem.new(key: :executable,
53
+ description: "Path to the `swiftformat` executable on your machine",
54
+ is_string: true,
55
+ optional: true,
56
+ verify_block: proc do |value|
57
+ UI.user_error!("Couldn't find path '#{File.expand_path(value)}'") unless File.exist?(value) || Helper.test?
58
+ end),
59
+ FastlaneCore::ConfigItem.new(key: :path,
60
+ description: "Path to format",
61
+ is_string: true,
62
+ optional: true,
63
+ verify_block: proc do |value|
64
+ UI.user_error!("Couldn't find path '#{File.expand_path(value)}'") unless File.exist?(value) || Helper.test?
65
+ end),
66
+ FastlaneCore::ConfigItem.new(key: :rules,
67
+ description: "Specify a whitelist of rules",
68
+ is_string: false,
69
+ optional: true),
70
+ FastlaneCore::ConfigItem.new(key: :disable,
71
+ description: "Specify rules to disable",
72
+ is_string: false,
73
+ optional: true),
74
+ FastlaneCore::ConfigItem.new(key: :enable,
75
+ description: "Specify rules to enable",
76
+ is_string: false,
77
+ optional: true),
78
+ FastlaneCore::ConfigItem.new(key: :swiftversion,
79
+ description: "Specify swift version",
80
+ is_string: false,
81
+ optional: true),
82
+ FastlaneCore::ConfigItem.new(key: :config,
83
+ description: "Path to configuration file",
84
+ is_string: true,
85
+ optional: true,
86
+ verify_block: proc do |value|
87
+ UI.user_error!("Couldn't find path '#{File.expand_path(value)}'") unless File.exist?(value) || Helper.test?
88
+ end),
89
+ FastlaneCore::ConfigItem.new(key: :dryrun,
90
+ description: "Run in dry mode (without actually changing any files)",
91
+ is_string: false,
92
+ optional: true),
93
+ FastlaneCore::ConfigItem.new(key: :lint,
94
+ description: "Like `--dryrun`, but returns an error if formatting is needed",
95
+ is_string: false,
96
+ optional: true)
97
+ ]
98
+ end
99
+
100
+ def self.output
101
+ end
102
+
103
+ def self.return_value
104
+ end
105
+
106
+ def self.authors
107
+ ["fxm90"]
108
+ end
109
+
110
+ def self.is_supported?(platform)
111
+ [:ios, :mac].include?(platform)
112
+ end
113
+
114
+ def self.example_code
115
+ [
116
+ 'swiftformat(
117
+ executable: "Pods/SwiftFormat/CommandLineTool/swiftformat", # Path to the `swiftformat` executable on your machine (optional)
118
+ path: "path/to/format", # Path to format (optional)
119
+ rules: "indent,linebreaks", # Specify a whitelist of rules (optional)
120
+ disable: "redundantSelf,trailingClosures", # Specify rules to disable (optional)
121
+ enable: "isEmpty", # Specify rules to enable (optional)
122
+ swiftversion: "5.1" # Specify swift version (optional)
123
+ config: "path/to/configuration/.swiftformat" # Path to configuration file (optional)
124
+ dryrun: false, # Run in dry mode (without actually changing any files) (optional)
125
+ lint: true # Like `--dryrun`, but returns an error if formatting is needed (optional)
126
+ )'
127
+ ]
128
+ end
129
+
130
+ def self.category
131
+ :testing
132
+ end
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,16 @@
1
+ require 'fastlane_core/ui/ui'
2
+
3
+ module Fastlane
4
+ UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
5
+
6
+ module Helper
7
+ class SwiftformatHelper
8
+ # class methods that you define here become available in your action
9
+ # as `Helper::SwiftformatHelper.your_method`
10
+ #
11
+ def self.show_message
12
+ UI.message("Hello from the swiftformat plugin helper!")
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module Swiftformat
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-swiftformat
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Felix Mau
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-02-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec_junit_formatter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.49.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.49.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-require_tools
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: fastlane
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: 2.141.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: 2.141.0
139
+ description:
140
+ email: me@felix.hamburg
141
+ executables: []
142
+ extensions: []
143
+ extra_rdoc_files: []
144
+ files:
145
+ - LICENSE
146
+ - README.md
147
+ - lib/fastlane/plugin/swiftformat.rb
148
+ - lib/fastlane/plugin/swiftformat/actions/swiftformat_action.rb
149
+ - lib/fastlane/plugin/swiftformat/helper/swiftformat_helper.rb
150
+ - lib/fastlane/plugin/swiftformat/version.rb
151
+ homepage: https://github.com/fxm90/fastlane-plugin-swiftformat
152
+ licenses:
153
+ - MIT
154
+ metadata: {}
155
+ post_install_message:
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubyforge_project:
171
+ rubygems_version: 2.5.2.3
172
+ signing_key:
173
+ specification_version: 4
174
+ summary: Run swift code formatting using SwiftFormat
175
+ test_files: []