fastlane-plugin-wexlane 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9df3d484d0642c2cc92eaa8fbc9caf86bae83359844ec91061594df3fae19703
4
+ data.tar.gz: 0d7dee24de5f2fd8568d60f277e0be201738a83cb77b2edc2ba93d1bc100817d
5
+ SHA512:
6
+ metadata.gz: afd0467e58221b6005340d5989368f4c89b8e6c384aeea60898735fd7c9e01a338763b312ee8c536cc0451b8dbc16daa35369c5e3c4a0b23d4f2d9d9a471a125
7
+ data.tar.gz: ff6767c2bd3c3f3e617c4a525ecf5ada580142cb1e84f824999d01279057097c8afcb0dc33621e9709971fc756d3fcee4db9cf2c8c8cdf73bf30de0906ec8d34
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Chris River <chris.river@wexinc.com>
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 @@
1
+ # wexlane
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/wexlane/version'
2
+
3
+ module Fastlane
4
+ module Wexlane
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::Wexlane.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,69 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/wexlane_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class AndroidGetVersionAction < Action
7
+ def self.run(params)
8
+ path = params[:gradle_path]#{}"app/build.gradle"
9
+ version_name = "0"
10
+ if !File.file?(path)
11
+ UI.message(" -> No file exist at path: (#{path})!")
12
+ return version_name
13
+ end
14
+ begin
15
+ file = File.new(path, "r")
16
+ while (line = file.gets)
17
+ if line.include? "versionName"
18
+ versionComponents = line.strip.split(' ')
19
+ version_name = versionComponents[versionComponents.length - 1].tr("\"","")
20
+ break
21
+ end
22
+ end
23
+ file.close
24
+ rescue => err
25
+ UI.error("An exception occured while readinf gradle file: #{err}")
26
+ err
27
+ end
28
+ return version_name
29
+ UI.message("The wexlane plugin is working!")
30
+ end
31
+
32
+ def self.description
33
+ "Common tools for CI"
34
+ end
35
+
36
+ def self.authors
37
+ ["Chris River"]
38
+ end
39
+
40
+ def self.return_value
41
+ # If your method provides a return value, you can describe here what it does
42
+ end
43
+
44
+ def self.details
45
+ # Optional:
46
+ "Dependencies shared between all WEX mobile projects"
47
+ end
48
+
49
+ def self.available_options
50
+ [
51
+ FastlaneCore::ConfigItem.new(key: :gradle_path,
52
+ env_name: "WEXLANE_GRADLE_PATH",
53
+ description: "Path to the gradle file",
54
+ optional: false,
55
+ type: String)
56
+ ]
57
+ end
58
+
59
+ def self.is_supported?(platform)
60
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
61
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
62
+ #
63
+ # [:ios, :mac, :android].include?(platform)
64
+ true
65
+ end
66
+
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,163 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/wexlane_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class IOSGetVersionAction < Action
7
+ def self.run(params)
8
+ folder = params[:xcodeproj] ? File.join(params[:xcodeproj], '..') : '.'
9
+ target_name = params[:target]
10
+ configuration = params[:configuration]
11
+
12
+ # Get version_number
13
+ project = get_project!(folder)
14
+ target = get_target!(project, target_name)
15
+ plist_file = get_plist!(folder, target, configuration)
16
+ version_number = get_version_number_from_plist!(plist_file)
17
+
18
+ # Get from build settings (or project settings) if needed (ex: $(MARKETING_VERSION) is default in Xcode 11)
19
+ if version_number =~ /\$\(([\w\-]+)\)/
20
+ version_number = get_version_number_from_build_settings!(target, $1, configuration) || get_version_number_from_build_settings!(project, $1, configuration)
21
+
22
+ # ${MARKETING_VERSION} also works
23
+ elsif version_number =~ /\$\{([\w\-]+)\}/
24
+ version_number = get_version_number_from_build_settings!(target, $1, configuration) || get_version_number_from_build_settings!(project, $1, configuration)
25
+ end
26
+
27
+ # Error out if version_number is not set
28
+ if version_number.nil?
29
+ UI.user_error!("Unable to find Xcode build setting: #{$1}")
30
+ end
31
+
32
+ # Store the number in the shared hash
33
+ Actions.lane_context[SharedValues::VERSION_NUMBER] = version_number
34
+
35
+ # Return the version number because Swift might need this return value
36
+ return version_number
37
+ end
38
+
39
+ def self.get_project!(folder)
40
+ require 'xcodeproj'
41
+ project_path = Dir.glob("#{folder}/*.xcodeproj").first
42
+ if project_path
43
+ return Xcodeproj::Project.open(project_path)
44
+ else
45
+ UI.user_error!("Unable to find Xcode project in folder: #{folder}")
46
+ end
47
+ end
48
+
49
+ def self.get_target!(project, target_name)
50
+ targets = project.targets
51
+
52
+ # Prompt targets if no name
53
+ unless target_name
54
+
55
+ # Gets non-test targets
56
+ non_test_targets = targets.reject do |t|
57
+ # Not all targets respond to `test_target_type?`
58
+ t.respond_to?(:test_target_type?) && t.test_target_type?
59
+ end
60
+
61
+ # Returns if only one non-test target
62
+ if non_test_targets.count == 1
63
+ return targets.first
64
+ end
65
+
66
+ options = targets.map(&:name)
67
+ target_name = UI.select("What target would you like to use?", options)
68
+ end
69
+
70
+ # Find target
71
+ target = targets.find do |t|
72
+ t.name == target_name
73
+ end
74
+ UI.user_error!("Cannot find target named '#{target_name}'") unless target
75
+
76
+ target
77
+ end
78
+
79
+ def self.get_version_number_from_build_settings!(target, variable, configuration = nil)
80
+ target.build_configurations.each do |config|
81
+ if configuration.nil? || config.name == configuration
82
+ value = config.build_settings[variable]
83
+ return value if value
84
+ end
85
+ end
86
+
87
+ return nil
88
+ end
89
+
90
+ def self.get_plist!(folder, target, configuration = nil)
91
+ plist_files = target.resolved_build_setting("INFOPLIST_FILE")
92
+ plist_files_count = plist_files.values.compact.uniq.count
93
+
94
+ # Get plist file for specified configuration
95
+ # Or: Prompt for configuration if plist has different files in each configurations
96
+ # Else: Get first(only) plist value
97
+ if configuration
98
+ plist_file = plist_files[configuration]
99
+ elsif plist_files_count > 1
100
+ options = plist_files.keys
101
+ selected = UI.select("What build configuration would you like to use?", options)
102
+ plist_file = plist_files[selected]
103
+ else
104
+ plist_file = plist_files.values.first
105
+ end
106
+
107
+ # $(SRCROOT) is the path of where the XcodeProject is
108
+ # We can just set this as empty string since we join with `folder` below
109
+ if plist_file.include?("$(SRCROOT)/")
110
+ plist_file.gsub!("$(SRCROOT)/", "")
111
+ end
112
+
113
+ plist_file = File.absolute_path(File.join(folder, plist_file))
114
+ UI.user_error!("Cannot find plist file: #{plist_file}") unless File.exist?(plist_file)
115
+
116
+ plist_file
117
+ end
118
+
119
+ def self.get_version_number_from_plist!(plist_file)
120
+ plist = Xcodeproj::Plist.read_from_path(plist_file)
121
+ UI.user_error!("Unable to read plist: #{plist_file}") unless plist
122
+
123
+ plist["CFBundleShortVersionString"]
124
+ end
125
+
126
+ def self.description
127
+ "Common tools for CI"
128
+ end
129
+
130
+ def self.authors
131
+ ["Chris River"]
132
+ end
133
+
134
+ def self.return_value
135
+ # If your method provides a return value, you can describe here what it does
136
+ end
137
+
138
+ def self.details
139
+ # Optional:
140
+ "Dependencies shared between all WEX mobile projects"
141
+ end
142
+
143
+ def self.available_options
144
+ [
145
+ # FastlaneCore::ConfigItem.new(key: :your_option,
146
+ # env_name: "WEXLANE_YOUR_OPTION",
147
+ # description: "A description of your option",
148
+ # optional: false,
149
+ # type: String)
150
+ ]
151
+ end
152
+
153
+ def self.is_supported?(platform)
154
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
155
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
156
+ #
157
+ # [:ios, :mac, :android].include?(platform)
158
+ true
159
+ end
160
+
161
+ end
162
+ end
163
+ 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 WexlaneHelper
8
+ # class methods that you define here become available in your action
9
+ # as `Helper::WexlaneHelper.your_method`
10
+ #
11
+ def self.show_message
12
+ UI.message("Hello from the wexlane plugin helper!")
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module Wexlane
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-wexlane
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris River
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-10-17 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.128.1
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: 2.128.1
139
+ description:
140
+ email: chris.river@wexinc.com
141
+ executables: []
142
+ extensions: []
143
+ extra_rdoc_files: []
144
+ files:
145
+ - LICENSE
146
+ - README.md
147
+ - lib/fastlane/plugin/wexlane.rb
148
+ - lib/fastlane/plugin/wexlane/actions/android_get_version.rb
149
+ - lib/fastlane/plugin/wexlane/actions/ios_get_version.rb
150
+ - lib/fastlane/plugin/wexlane/helper/wexlane_helper.rb
151
+ - lib/fastlane/plugin/wexlane/version.rb
152
+ homepage: https://github.com/precambrianet/fastlane-plugin-wexlane
153
+ licenses:
154
+ - MIT
155
+ metadata: {}
156
+ post_install_message:
157
+ rdoc_options: []
158
+ require_paths:
159
+ - lib
160
+ required_ruby_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ required_rubygems_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ requirements: []
171
+ rubygems_version: 3.0.6
172
+ signing_key:
173
+ specification_version: 4
174
+ summary: Common tools for CI
175
+ test_files: []