fastlane-plugin-ionic 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05eda74ea8206f68043e2b98ac5b13ba71729c08
4
- data.tar.gz: e1a8d6cd895a9aa0affcb4e4789aec3c469f5058
3
+ metadata.gz: b8f4609dd838294349cf26fdb60735e9a86bc856
4
+ data.tar.gz: d519bc0267d2430b05849464797d75570d6304c5
5
5
  SHA512:
6
- metadata.gz: 849af397d9278b12f3ab0f9e49071eecb227def87666043179d75fbd7c7ce3810f969de49564f9b3c67f69c627d8d7ebb59338d03af71de705fa4cce5e96b2ed
7
- data.tar.gz: 8da34756a643d071a31b0f5441924a24d556b44e1a7caabf261a8bc435cf5cfef7cc7fb4159e19a6e72044f21cc5ef639bd3738017d1dfc722fed35dba3c18eb
6
+ metadata.gz: a5e5f539141e43ce3154291163885bd6bf89c7bb6352f0edab0597b7b5ab2e4c6d5ae75a2ea86f1d16c1a172a396907eb6385d7549e5d9d4320664f3a75550c8
7
+ data.tar.gz: adbaede51e3ee70c67644b2cec9ecffbab751e6dfd9c762ea9ad10f38f285cd86aed547a485dc100ee6a79da617602bf964f7b05802c6de38d18016746dec7cc
data/LICENSE CHANGED
@@ -1,22 +1,22 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2017 Jan Piotrowski <piotrowski@gmail.com>
4
- Copyright (c) 2016 Almouro <contact@almouro.com>
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to deal
8
- in the Software without restriction, including without limitation the rights
9
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in all
14
- copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Jan Piotrowski <piotrowski@gmail.com>
4
+ Copyright (c) 2016 Almouro <contact@almouro.com>
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
data/README.md CHANGED
@@ -1,138 +1,146 @@
1
- # _fastlane_ Plugin for Ionic CLI
2
-
3
- [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-ionic) [![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/ionic-zone/fastlane-plugin-ionic/blob/master/LICENSE)
4
- [![Gem](https://img.shields.io/gem/v/fastlane-plugin-ionic.svg?style=flat)](http://rubygems.org/gems/fastlane-plugin-ionic)
5
-
6
- This _fastlane_ plugin helps you build your **Ionic Cordova** project via the [`ionic` CLI](https://ionicframework.com/docs/cli/) and its `ionic cordova build` command.
7
-
8
- It is based on [fastlane-plugin-cordova](https://github.com/bamlab/fastlane-plugin-cordova) (where it borrows a lot of its code. Thanks!).
9
-
10
- ## Getting Started
11
-
12
- This project is a [fastlane](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-ionic`, add it to your project by running:
13
-
14
- ```bash
15
- fastlane add_plugin ionic
16
- ```
17
-
18
- ## Actions
19
-
20
- ### `ionic`
21
-
22
- Runs `ionic cordova build` to build your Ionic project.
23
-
24
- ```ruby
25
- ionic(
26
- platform: 'ios', # Build your iOS Ionic project
27
- )
28
- ionic(
29
- platform: 'android', # Build your Android Ionic project
30
- release: false # Build a "Debug" app
31
- )
32
- ```
33
-
34
-
35
- ## Examples
36
-
37
- Lanes using these actions could look like this:
38
-
39
- ```ruby
40
- platform :ios do
41
- desc "Deploy ios app on the appstore"
42
-
43
- lane :deploy do
44
- match(type: "appstore")
45
- ionic(platform: 'ios')
46
- deliver(ipa: ENV['CORDOVA_IOS_RELEASE_BUILD_PATH'])
47
- end
48
- end
49
-
50
- platform :android do
51
- desc "Deploy android app on play store"
52
-
53
- lane :deploy do
54
- ionic(
55
- platform: 'android',
56
- keystore_path: './prod.keystore',
57
- keystore_alias: 'prod',
58
- keystore_password: 'password'
59
- )
60
- supply(apk: ENV['CORDOVA_ANDROID_RELEASE_BUILD_PATH'])
61
- end
62
- end
63
- ```
64
-
65
- with an `Appfile` such as
66
-
67
- ```ruby
68
- app_identifier "com.awesome.app"
69
- apple_id "apple@id.com"
70
- team_id "28323HT"
71
- ```
72
-
73
- If you're using **Crosswalk**, replace `supply(apk: ENV['CORDOVA_ANDROID_RELEASE_BUILD_PATH'])` (and equivalents) by:
74
-
75
- ```ruby
76
- supply(
77
- apk_paths: [
78
- 'platforms/android/build/outputs/apk/android-armv7-release.apk',
79
- 'platforms/android/build/outputs/apk/android-x86-release.apk'
80
- ],
81
- )
82
- ```
83
-
84
- ## Plugin API
85
-
86
- To check what's available in the plugin, install it in a project and run at the root of the project:
87
-
88
- ```
89
- fastlane actions ionic
90
- ```
91
-
92
- Which will produce:
93
-
94
- | Key | Description | Env Var | Default |
95
- |-----|-------------|---------|---------|
96
- | **platform** | Platform to build on. <br>Should be either android or ios | CORDOVA_PLATFORM | |
97
- | **release** | Build for release if true,<br>or for debug if false | CORDOVA_RELEASE | *true* |
98
- | **device** | Build for device | CORDOVA_DEVICE | *true* |
99
- | **prod** | Build for production | IONIC_PROD | *true* |
100
- | **type** | This will determine what type of build is generated by Xcode. <br>Valid options are development, enterprise, adhoc, and appstore| CORDOVA_IOS_PACKAGE_TYPE | appstore |
101
- | **team_id** | The development team (Team ID) to use for code signing | CORDOVA_IOS_TEAM_ID | *28323HT* |
102
- | **provisioning_profile** | GUID of the provisioning profile to be used for signing | CORDOVA_IOS_PROVISIONING_PROFILE | |
103
- | **keystore_path** | Path to the Keystore for Android | CORDOVA_ANDROID_KEYSTORE_PATH | |
104
- | **keystore_password** | Android Keystore password | CORDOVA_ANDROID_KEYSTORE_PASSWORD | |
105
- | **key_password** | Android Key password (default is keystore password) | CORDOVA_ANDROID_KEY_PASSWORD | |
106
- | **keystore_alias** | Android Keystore alias | CORDOVA_ANDROID_KEYSTORE_ALIAS | |
107
- | **build_number** | Build Number for iOS and Android | CORDOVA_BUILD_NUMBER | |
108
- | **browserify** | Specifies whether to browserify build or not | CORDOVA_BROWSERIFY | *false* |
109
- | **cordova_prepare** | Specifies whether to run `ionic cordova prepare` before building | CORDOVA_PREPARE | *true* |
110
-
111
- ## Run tests for this plugin
112
-
113
- To run both the tests, and code style validation, run
114
-
115
- ```
116
- rake
117
- ```
118
-
119
- To automatically fix many of the styling issues, use
120
- ```
121
- rubocop -a
122
- ```
123
-
124
- ## Issues and Feedback
125
-
126
- For any other issues and feedback about this plugin, please submit it to this repository.
127
-
128
- ## Troubleshooting
129
-
130
- If you have trouble using plugins, check out the [Plugins Troubleshooting](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/PluginsTroubleshooting.md) doc in the main `fastlane` repo.
131
-
132
- ## Using `fastlane` Plugins
133
-
134
- For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Plugins.md).
135
-
136
- ## About `fastlane`
137
-
138
- `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).
1
+ # _fastlane_ Plugin for Ionic CLI
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-ionic) [![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/ionic-zone/fastlane-plugin-ionic/blob/master/LICENSE)
4
+ [![Gem](https://img.shields.io/gem/v/fastlane-plugin-ionic.svg?style=flat)](http://rubygems.org/gems/fastlane-plugin-ionic)
5
+
6
+ This _fastlane_ plugin helps you build your **Ionic Cordova** project via the [`ionic` CLI](https://ionicframework.com/docs/cli/).
7
+
8
+ It is based on [fastlane-plugin-cordova](https://github.com/bamlab/fastlane-plugin-cordova) (where it borrows a lot of its code. Thanks!).
9
+
10
+ ## Getting Started
11
+
12
+ This project is a [fastlane](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-ionic`, add it to your project by running:
13
+
14
+ ```bash
15
+ fastlane add_plugin ionic
16
+ ```
17
+
18
+ ## Actions
19
+
20
+ ### `ionic`
21
+
22
+ Runs `ionic cordova build` (technically: `ionic cordova prepare` first, then `ionic cordova compile` [which is the same as what `build` does internally]) to build your Ionic project.
23
+
24
+ ```ruby
25
+ ionic(
26
+ platform: 'ios', # Build your iOS Ionic project
27
+ )
28
+ ionic(
29
+ platform: 'android', # Build your Android Ionic project
30
+ release: false # Build a "Debug" app
31
+ )
32
+ ```
33
+
34
+
35
+ ## Examples
36
+
37
+ Lanes using these actions could look like this:
38
+
39
+ ```ruby
40
+ platform :ios do
41
+ desc "Deploy ios app on the appstore"
42
+
43
+ lane :deploy do
44
+ match(type: "appstore")
45
+ ionic(platform: 'ios')
46
+ deliver(ipa: ENV['CORDOVA_IOS_RELEASE_BUILD_PATH'])
47
+ end
48
+ end
49
+
50
+ platform :android do
51
+ desc "Deploy android app on play store"
52
+
53
+ lane :deploy do
54
+ ionic(
55
+ platform: 'android',
56
+ keystore_path: './prod.keystore',
57
+ keystore_alias: 'prod',
58
+ keystore_password: 'password'
59
+ )
60
+ supply(apk: ENV['CORDOVA_ANDROID_RELEASE_BUILD_PATH'])
61
+ end
62
+ end
63
+ ```
64
+
65
+ with an `Appfile` such as
66
+
67
+ ```ruby
68
+ app_identifier "com.awesome.app"
69
+ apple_id "apple@id.com"
70
+ team_id "28323HT"
71
+ ```
72
+
73
+ ---
74
+
75
+ The `ENV['CORDOVA_ANDROID_RELEASE_BUILD_PATH']` is only valid for `cordova-android` 7.x and newer (which you should be using anyway!).
76
+
77
+ If you're using **Crosswalk** (which oyu should not really be doing anymore), replace `supply(apk: ENV['CORDOVA_ANDROID_RELEASE_BUILD_PATH'])` (and equivalents) by:
78
+
79
+ ```ruby
80
+ supply(
81
+ apk_paths: [
82
+ 'platforms/android/build/outputs/apk/android-armv7-release.apk',
83
+ 'platforms/android/build/outputs/apk/android-x86-release.apk'
84
+ ],
85
+ )
86
+ ```
87
+
88
+ ## Plugin API
89
+
90
+ To check what's available in the plugin, install it in a project and run at the root of the project:
91
+
92
+ ```
93
+ fastlane actions ionic
94
+ ```
95
+
96
+ Which will produce:
97
+
98
+ | Key | Description | Env Var | Default |
99
+ |-----|-------------|---------|---------|
100
+ | **platform** | Platform to build on. <br>Should be either android or ios | CORDOVA_PLATFORM | |
101
+ | **release** | Build for release if true,<br>or for debug if false | CORDOVA_RELEASE | *true* |
102
+ | **device** | Build for device | CORDOVA_DEVICE | *true* |
103
+ | **prod** | Build for production | IONIC_PROD | *false* |
104
+ | **type** | This will determine what type of build is generated by Xcode. <br>Valid options are development, enterprise, adhoc, and appstore| CORDOVA_IOS_PACKAGE_TYPE | appstore |
105
+ | **team_id** | The development team (Team ID) to use for code signing | CORDOVA_IOS_TEAM_ID | *28323HT* |
106
+ | **build_flag** | An array of Xcode buildFlag. Will be appended on compile command. | CORDOVA_IOS_BUILD_FLAG | [] |
107
+ | **provisioning_profile** | GUID of the provisioning profile to be used for signing | CORDOVA_IOS_PROVISIONING_PROFILE | |
108
+ | **keystore_path** | Path to the Keystore for Android | CORDOVA_ANDROID_KEYSTORE_PATH | |
109
+ | **keystore_password** | Android Keystore password | CORDOVA_ANDROID_KEYSTORE_PASSWORD | |
110
+ | **key_password** | Android Key password (default is keystore password) | CORDOVA_ANDROID_KEY_PASSWORD | |
111
+ | **keystore_alias** | Android Keystore alias | CORDOVA_ANDROID_KEYSTORE_ALIAS | |
112
+ | **min_sdk_version** | Overrides the value of minSdkVersion | CORDOVA_ANDROID_MIN_SDK_VERSION | |
113
+ | **build_number** | Build Number for iOS and Android | CORDOVA_BUILD_NUMBER | |
114
+ | **browserify** | Specifies whether to browserify build or not | CORDOVA_BROWSERIFY | *false* |
115
+ | **cordova_prepare** | Specifies whether to run `ionic cordova prepare` before building | CORDOVA_PREPARE | *true* |
116
+ | **cordova_no_fetch** | Specifies whether to run `ionic cordova platform add` with `--nofetch` parameter | CORDOVA_NO_FETCH | *false* |
117
+ | **cordova_build_config_file** | Call `ionic cordova compile` with `--buildConfig=<ConfigFile>` to specify build config file path | CORDOVA_BUILD_CONFIG_FILE | |
118
+
119
+ ## Run tests for this plugin
120
+
121
+ To run both the tests, and code style validation, run
122
+
123
+ ```
124
+ rake
125
+ ```
126
+
127
+ To automatically fix many of the styling issues, use
128
+ ```
129
+ rubocop -a
130
+ ```
131
+
132
+ ## Issues and Feedback
133
+
134
+ For any other issues and feedback about this plugin, please submit it to this repository.
135
+
136
+ ## Troubleshooting
137
+
138
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/PluginsTroubleshooting.md) doc in the main `fastlane` repo.
139
+
140
+ ## Using `fastlane` Plugins
141
+
142
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Plugins.md).
143
+
144
+ ## About `fastlane`
145
+
146
+ `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).
@@ -1,16 +1,16 @@
1
- require 'fastlane/plugin/ionic/version'
2
-
3
- module Fastlane
4
- module Ionic
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::Ionic.all_classes.each do |current|
15
- require current
16
- end
1
+ require 'fastlane/plugin/ionic/version'
2
+
3
+ module Fastlane
4
+ module Ionic
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::Ionic.all_classes.each do |current|
15
+ require current
16
+ end
@@ -1,294 +1,345 @@
1
- module Fastlane
2
- module Actions
3
- module SharedValues
4
- CORDOVA_IOS_RELEASE_BUILD_PATH = :CORDOVA_IOS_RELEASE_BUILD_PATH
5
- CORDOVA_ANDROID_RELEASE_BUILD_PATH = :CORDOVA_ANDROID_RELEASE_BUILD_PATH
6
- end
7
-
8
- class IonicAction < Action
9
- # valid action params
10
-
11
- ANDROID_ARGS_MAP = {
12
- keystore_path: 'keystore',
13
- keystore_password: 'storePassword',
14
- key_password: 'password',
15
- keystore_alias: 'alias',
16
- build_number: 'versionCode'
17
- }
18
-
19
- IOS_ARGS_MAP = {
20
- type: 'packageType',
21
- team_id: 'developmentTeam',
22
- provisioning_profile: 'provisioningProfile'
23
- }
24
-
25
- # do rewriting and copying of action params
26
- def self.get_platform_args(params, args_map)
27
- platform_args = []
28
- args_map.each do |action_key, cli_param|
29
- param_value = params[action_key]
30
- unless param_value.to_s.empty?
31
- platform_args << "--#{cli_param}=#{Shellwords.escape(param_value)}"
32
- end
33
- end
34
-
35
- return platform_args.join(' ')
36
- end
37
-
38
- # map action params to the cli param they will be used for
39
-
40
- def self.get_android_args(params)
41
- # TODO document magic in README
42
- if params[:key_password].empty?
43
- params[:key_password] = params[:keystore_password]
44
- end
45
-
46
- return self.get_platform_args(params, ANDROID_ARGS_MAP)
47
- end
48
-
49
- def self.get_ios_args(params)
50
- app_identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)
51
-
52
- if params[:provisioning_profile].empty?
53
- # If `match` or `sigh` were used before this, use the certificates returned from there
54
- params[:provisioning_profile] = ENV['SIGH_UUID'] || ENV["sigh_#{app_identifier}_#{params[:type].sub('-', '')}"]
55
- end
56
-
57
- if params[:type] == 'adhoc'
58
- params[:type] = 'ad-hoc'
59
- end
60
- if params[:type] == 'appstore'
61
- params[:type] = 'app-store'
62
- end
63
-
64
- return self.get_platform_args(params, IOS_ARGS_MAP)
65
- end
66
-
67
- # add cordova platform if missing (run #1)
68
- def self.check_and_add_platform(platform)
69
- if platform && !File.directory?("./platforms/#{platform}")
70
- sh "ionic cordova platform add #{platform}"
71
- end
72
- end
73
-
74
- # app_name
75
- def self.get_app_name
76
- config = REXML::Document.new(File.open('config.xml'))
77
- return config.elements['widget'].elements['name'].first.value # TODO: Simplify!? (Check logic in cordova)
78
- end
79
-
80
- # actual building! (run #2)
81
- def self.build(params)
82
- args = [params[:release] ? '--release' : '--debug']
83
- args << '--device' if params[:device]
84
- args << '--prod' if params[:prod]
85
- args << '--browserify' if params[:browserify]
86
- android_args = self.get_android_args(params) if params[:platform].to_s == 'android'
87
- ios_args = self.get_ios_args(params) if params[:platform].to_s == 'ios'
88
-
89
- if params[:cordova_prepare]
90
- # TODO: Remove params not allowed/used for `prepare`
91
- sh "ionic cordova prepare #{params[:platform]} #{args.join(' ')}"
92
- end
93
-
94
- # special handling for `build_number` param
95
- if params[:platform].to_s == 'ios' && !params[:build_number].to_s.empty?
96
- cf_bundle_version = params[:build_number].to_s
97
- Actions::UpdateInfoPlistAction.run(
98
- xcodeproj: "./platforms/ios/#{self.get_app_name}.xcodeproj",
99
- plist_path: "#{self.get_app_name}/#{self.get_app_name}-Info.plist",
100
- block: lambda { |plist|
101
- plist['CFBundleVersion'] = cf_bundle_version
102
- }
103
- )
104
- end
105
-
106
- if params[:platform].to_s == 'ios'
107
- sh "ionic cordova compile #{params[:platform]} #{args.join(' ')} -- #{ios_args}"
108
- elsif params[:platform].to_s == 'android'
109
- sh "ionic cordova compile #{params[:platform]} #{args.join(' ')} -- -- #{android_args}"
110
- end
111
- end
112
-
113
- # export build paths (run #3)
114
- def self.set_build_paths(is_release)
115
- app_name = self.get_app_name
116
- build_type = is_release ? 'release' : 'debug'
117
-
118
- ENV['CORDOVA_ANDROID_RELEASE_BUILD_PATH'] = "./platforms/android/build/outputs/apk/android-#{build_type}.apk"
119
- ENV['CORDOVA_IOS_RELEASE_BUILD_PATH'] = "./platforms/ios/build/device/#{app_name}.ipa"
120
-
121
- # TODO: https://github.com/bamlab/fastlane-plugin-cordova/issues/7
122
- end
123
-
124
- def self.run(params)
125
- self.check_and_add_platform(params[:platform])
126
- self.build(params)
127
- self.set_build_paths(params[:release])
128
- end
129
-
130
- #####################################################
131
- # @!group Documentation
132
- #####################################################
133
-
134
- def self.description
135
- "Build your Ionic app"
136
- end
137
-
138
- def self.details
139
- "Easily integrate your Ionic build into a Fastlane setup"
140
- end
141
-
142
- def self.available_options
143
- [
144
- FastlaneCore::ConfigItem.new(
145
- key: :platform,
146
- env_name: "CORDOVA_PLATFORM",
147
- description: "Platform to build on. Should be either android or ios",
148
- is_string: true,
149
- default_value: '',
150
- verify_block: proc do |value|
151
- UI.user_error!("Platform should be either android or ios") unless ['', 'android', 'ios'].include? value
152
- end
153
- ),
154
- FastlaneCore::ConfigItem.new(
155
- key: :release,
156
- env_name: "CORDOVA_RELEASE",
157
- description: "Build for release if true, or for debug if false",
158
- is_string: false,
159
- default_value: true,
160
- verify_block: proc do |value|
161
- UI.user_error!("Release should be boolean") unless [false, true].include? value
162
- end
163
- ),
164
- FastlaneCore::ConfigItem.new(
165
- key: :device,
166
- env_name: "CORDOVA_DEVICE",
167
- description: "Build for device",
168
- is_string: false,
169
- default_value: true,
170
- verify_block: proc do |value|
171
- UI.user_error!("Device should be boolean") unless [false, true].include? value
172
- end
173
- ),
174
- FastlaneCore::ConfigItem.new(
175
- key: :prod,
176
- env_name: "IONIC_PROD",
177
- description: "Build for production",
178
- is_string: false,
179
- default_value: false,
180
- verify_block: proc do |value|
181
- UI.user_error!("Prod should be boolean") unless [false, true].include? value
182
- end
183
- ),
184
- FastlaneCore::ConfigItem.new(
185
- key: :type,
186
- env_name: "CORDOVA_IOS_PACKAGE_TYPE",
187
- description: "This will determine what type of build is generated by Xcode. Valid options are development, enterprise, adhoc, and appstore",
188
- is_string: true,
189
- default_value: 'appstore',
190
- verify_block: proc do |value|
191
- UI.user_error!("Valid options are development, enterprise, adhoc, and appstore.") unless ['development', 'enterprise', 'adhoc', 'appstore', 'ad-hoc', 'app-store'].include? value
192
- end
193
- ),
194
- FastlaneCore::ConfigItem.new(
195
- key: :team_id,
196
- env_name: "CORDOVA_IOS_TEAM_ID",
197
- description: "The development team (Team ID) to use for code signing",
198
- is_string: true,
199
- default_value: CredentialsManager::AppfileConfig.try_fetch_value(:team_id)
200
- ),
201
- FastlaneCore::ConfigItem.new(
202
- key: :provisioning_profile,
203
- env_name: "CORDOVA_IOS_PROVISIONING_PROFILE",
204
- description: "GUID of the provisioning profile to be used for signing",
205
- is_string: true,
206
- default_value: ''
207
- ),
208
- FastlaneCore::ConfigItem.new(
209
- key: :keystore_path,
210
- env_name: "CORDOVA_ANDROID_KEYSTORE_PATH",
211
- description: "Path to the Keystore for Android",
212
- is_string: true,
213
- default_value: ''
214
- ),
215
- FastlaneCore::ConfigItem.new(
216
- key: :keystore_password,
217
- env_name: "CORDOVA_ANDROID_KEYSTORE_PASSWORD",
218
- description: "Android Keystore password",
219
- is_string: true,
220
- default_value: ''
221
- ),
222
- FastlaneCore::ConfigItem.new(
223
- key: :key_password,
224
- env_name: "CORDOVA_ANDROID_KEY_PASSWORD",
225
- description: "Android Key password (default is keystore password)",
226
- is_string: true,
227
- default_value: ''
228
- ),
229
- FastlaneCore::ConfigItem.new(
230
- key: :keystore_alias,
231
- env_name: "CORDOVA_ANDROID_KEYSTORE_ALIAS",
232
- description: "Android Keystore alias",
233
- is_string: true,
234
- default_value: ''
235
- ),
236
- FastlaneCore::ConfigItem.new(
237
- key: :build_number,
238
- env_name: "CORDOVA_BUILD_NUMBER",
239
- description: "Build Number for iOS",
240
- optional: true,
241
- is_string: false
242
- ),
243
- FastlaneCore::ConfigItem.new(
244
- key: :browserify,
245
- env_name: "CORDOVA_BROWSERIFY",
246
- description: "Specifies whether to browserify build or not",
247
- default_value: false,
248
- is_string: false
249
- ),
250
- FastlaneCore::ConfigItem.new(
251
- key: :cordova_prepare,
252
- env_name: "CORDOVA_PREPARE",
253
- description: "Specifies whether to run `ionic cordova prepare` before building",
254
- default_value: true,
255
- is_string: false
256
- )
257
- ]
258
- end
259
-
260
- def self.output
261
- [
262
- ['CORDOVA_ANDROID_RELEASE_BUILD_PATH', 'Path to the signed release APK if it was generated'],
263
- ['CORDOVA_IOS_RELEASE_BUILD_PATH', 'Path to the signed release IPA if it was generated']
264
- ]
265
- end
266
-
267
- def self.authors
268
- ['Jan Piotrowski']
269
- end
270
-
271
- def self.is_supported?(platform)
272
- true
273
- end
274
-
275
- def self.example_code
276
- [
277
- "ionic(
278
- platform: 'ios'
279
- )",
280
- "ionic(
281
- platform: 'android',
282
- keystore_path: './staging.keystore',
283
- keystore_alias: 'alias_name',
284
- keystore_password: 'store_password'
285
- )"
286
- ]
287
- end
288
-
289
- def self.category
290
- :building
291
- end
292
- end
293
- end
294
- end
1
+ module Fastlane
2
+ module Actions
3
+ module SharedValues
4
+ CORDOVA_IOS_RELEASE_BUILD_PATH = :CORDOVA_IOS_RELEASE_BUILD_PATH
5
+ CORDOVA_ANDROID_RELEASE_BUILD_PATH = :CORDOVA_ANDROID_RELEASE_BUILD_PATH
6
+ end
7
+
8
+ class IonicAction < Action
9
+ # valid action params
10
+
11
+ ANDROID_ARGS_MAP = {
12
+ keystore_path: 'keystore',
13
+ keystore_password: 'storePassword',
14
+ key_password: 'password',
15
+ keystore_alias: 'alias',
16
+ build_number: 'versionCode',
17
+ min_sdk_version: 'gradleArg=-PcdvMinSdkVersion',
18
+ cordova_no_fetch: 'cordovaNoFetch'
19
+ }
20
+
21
+ IOS_ARGS_MAP = {
22
+ type: 'packageType',
23
+ team_id: 'developmentTeam',
24
+ provisioning_profile: 'provisioningProfile',
25
+ build_flag: 'buildFlag'
26
+ }
27
+
28
+ # do rewriting and copying of action params
29
+ def self.get_platform_args(params, args_map)
30
+ platform_args = []
31
+ args_map.each do |action_key, cli_param|
32
+ param_value = params[action_key]
33
+
34
+ if action_key.to_s == 'build_flag' && param_value.kind_of?(Array)
35
+ unless param_value.empty?
36
+ param_value.each do |flag|
37
+ platform_args << "--#{cli_param}=#{flag.shellescape}"
38
+ end
39
+ end
40
+ else
41
+ unless param_value.to_s.empty?
42
+ platform_args << "--#{cli_param}=#{Shellwords.escape(param_value)}"
43
+ end
44
+ end
45
+ end
46
+
47
+ return platform_args.join(' ')
48
+ end
49
+
50
+ # map action params to the cli param they will be used for
51
+
52
+ def self.get_android_args(params)
53
+ # TODO document magic in README
54
+ if params[:key_password].empty?
55
+ params[:key_password] = params[:keystore_password]
56
+ end
57
+
58
+ return self.get_platform_args(params, ANDROID_ARGS_MAP)
59
+ end
60
+
61
+ def self.get_ios_args(params)
62
+ app_identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)
63
+
64
+ if params[:provisioning_profile].empty?
65
+ # If `match` or `sigh` were used before this, use the certificates returned from there
66
+ params[:provisioning_profile] = ENV['SIGH_UUID'] || ENV["sigh_#{app_identifier}_#{params[:type].sub('-', '')}"]
67
+ end
68
+
69
+ if params[:type] == 'adhoc'
70
+ params[:type] = 'ad-hoc'
71
+ end
72
+ if params[:type] == 'appstore'
73
+ params[:type] = 'app-store'
74
+ end
75
+
76
+ return self.get_platform_args(params, IOS_ARGS_MAP)
77
+ end
78
+
79
+ def self.check_platform(params)
80
+ platform = params[:platform]
81
+ if platform && !File.directory?("./platforms/#{platform}")
82
+ if params[:cordova_no_fetch]
83
+ sh "ionic cordova platform add #{platform} --no-interactive --nofetch"
84
+ else
85
+ sh "ionic cordova platform add #{platform} --no-interactive"
86
+ end
87
+ end
88
+ end
89
+
90
+ # app_name
91
+ def self.get_app_name
92
+ config = REXML::Document.new(File.open('config.xml'))
93
+ return config.elements['widget'].elements['name'].first.value # TODO: Simplify!? (Check logic in cordova)
94
+ end
95
+
96
+ # actual building! (run #2)
97
+ def self.build(params)
98
+ args = [params[:release] ? '--release' : '--debug']
99
+ args << '--device' if params[:device]
100
+ args << '--prod' if params[:prod]
101
+ args << '--browserify' if params[:browserify]
102
+
103
+ if !params[:cordova_build_config_file].to_s.empty?
104
+ args << "--buildConfig=#{Shellwords.escape(params[:cordova_build_config_file])}"
105
+ end
106
+
107
+ android_args = self.get_android_args(params) if params[:platform].to_s == 'android'
108
+ ios_args = self.get_ios_args(params) if params[:platform].to_s == 'ios'
109
+
110
+ if params[:cordova_prepare]
111
+ # TODO: Remove params not allowed/used for `prepare`
112
+ sh "ionic cordova prepare #{params[:platform]} --no-interactive #{args.join(' ')}"
113
+ end
114
+
115
+ # special handling for `build_number` param
116
+ if params[:platform].to_s == 'ios' && !params[:build_number].to_s.empty?
117
+ cf_bundle_version = params[:build_number].to_s
118
+ Actions::UpdateInfoPlistAction.run(
119
+ xcodeproj: "./platforms/ios/#{self.get_app_name}.xcodeproj",
120
+ plist_path: "#{self.get_app_name}/#{self.get_app_name}-Info.plist",
121
+ block: lambda { |plist|
122
+ plist['CFBundleVersion'] = cf_bundle_version
123
+ }
124
+ )
125
+ end
126
+
127
+ if params[:platform].to_s == 'ios'
128
+ sh "ionic cordova compile #{params[:platform]} --no-interactive #{args.join(' ')} -- #{ios_args}"
129
+ elsif params[:platform].to_s == 'android'
130
+ sh "ionic cordova compile #{params[:platform]} --no-interactive #{args.join(' ')} -- -- #{android_args}"
131
+ end
132
+ end
133
+
134
+ # export build paths (run #3)
135
+ def self.set_build_paths(is_release)
136
+ app_name = self.get_app_name
137
+ build_type = is_release ? 'release' : 'debug'
138
+
139
+ ENV['CORDOVA_ANDROID_RELEASE_BUILD_PATH'] = "./platforms/android/app/build/outputs/apk/#{build_type}/app-#{build_type}.apk"
140
+ ENV['CORDOVA_IOS_RELEASE_BUILD_PATH'] = "./platforms/ios/build/device/#{app_name}.ipa"
141
+
142
+ # TODO: https://github.com/bamlab/fastlane-plugin-cordova/issues/7
143
+ end
144
+
145
+ def self.run(params)
146
+ self.check_platform(params)
147
+ self.build(params)
148
+ self.set_build_paths(params[:release])
149
+ end
150
+
151
+ #####################################################
152
+ # @!group Documentation
153
+ #####################################################
154
+
155
+ def self.description
156
+ "Build your Ionic app"
157
+ end
158
+
159
+ def self.details
160
+ "Easily integrate your Ionic build into a Fastlane setup"
161
+ end
162
+
163
+ def self.available_options
164
+ [
165
+ FastlaneCore::ConfigItem.new(
166
+ key: :platform,
167
+ env_name: "CORDOVA_PLATFORM",
168
+ description: "Platform to build on. Should be either android or ios",
169
+ is_string: true,
170
+ default_value: '',
171
+ verify_block: proc do |value|
172
+ UI.user_error!("Platform should be either android or ios") unless ['', 'android', 'ios'].include? value
173
+ end
174
+ ),
175
+ FastlaneCore::ConfigItem.new(
176
+ key: :release,
177
+ env_name: "CORDOVA_RELEASE",
178
+ description: "Build for release if true, or for debug if false",
179
+ is_string: false,
180
+ default_value: true,
181
+ verify_block: proc do |value|
182
+ UI.user_error!("Release should be boolean") unless [false, true].include? value
183
+ end
184
+ ),
185
+ FastlaneCore::ConfigItem.new(
186
+ key: :device,
187
+ env_name: "CORDOVA_DEVICE",
188
+ description: "Build for device",
189
+ is_string: false,
190
+ default_value: true,
191
+ verify_block: proc do |value|
192
+ UI.user_error!("Device should be boolean") unless [false, true].include? value
193
+ end
194
+ ),
195
+ FastlaneCore::ConfigItem.new(
196
+ key: :prod,
197
+ env_name: "IONIC_PROD",
198
+ description: "Build for production",
199
+ is_string: false,
200
+ default_value: false,
201
+ verify_block: proc do |value|
202
+ UI.user_error!("Prod should be boolean") unless [false, true].include? value
203
+ end
204
+ ),
205
+ FastlaneCore::ConfigItem.new(
206
+ key: :type,
207
+ env_name: "CORDOVA_IOS_PACKAGE_TYPE",
208
+ description: "This will determine what type of build is generated by Xcode. Valid options are development, enterprise, adhoc, and appstore",
209
+ is_string: true,
210
+ default_value: 'appstore',
211
+ verify_block: proc do |value|
212
+ UI.user_error!("Valid options are development, enterprise, adhoc, and appstore.") unless ['development', 'enterprise', 'adhoc', 'appstore', 'ad-hoc', 'app-store'].include? value
213
+ end
214
+ ),
215
+ FastlaneCore::ConfigItem.new(
216
+ key: :team_id,
217
+ env_name: "CORDOVA_IOS_TEAM_ID",
218
+ description: "The development team (Team ID) to use for code signing",
219
+ is_string: true,
220
+ default_value: CredentialsManager::AppfileConfig.try_fetch_value(:team_id)
221
+ ),
222
+ FastlaneCore::ConfigItem.new(
223
+ key: :provisioning_profile,
224
+ env_name: "CORDOVA_IOS_PROVISIONING_PROFILE",
225
+ description: "GUID of the provisioning profile to be used for signing",
226
+ is_string: true,
227
+ default_value: ''
228
+ ),
229
+ FastlaneCore::ConfigItem.new(
230
+ key: :keystore_path,
231
+ env_name: "CORDOVA_ANDROID_KEYSTORE_PATH",
232
+ description: "Path to the Keystore for Android",
233
+ is_string: true,
234
+ default_value: ''
235
+ ),
236
+ FastlaneCore::ConfigItem.new(
237
+ key: :keystore_password,
238
+ env_name: "CORDOVA_ANDROID_KEYSTORE_PASSWORD",
239
+ description: "Android Keystore password",
240
+ is_string: true,
241
+ default_value: ''
242
+ ),
243
+ FastlaneCore::ConfigItem.new(
244
+ key: :key_password,
245
+ env_name: "CORDOVA_ANDROID_KEY_PASSWORD",
246
+ description: "Android Key password (default is keystore password)",
247
+ is_string: true,
248
+ default_value: ''
249
+ ),
250
+ FastlaneCore::ConfigItem.new(
251
+ key: :keystore_alias,
252
+ env_name: "CORDOVA_ANDROID_KEYSTORE_ALIAS",
253
+ description: "Android Keystore alias",
254
+ is_string: true,
255
+ default_value: ''
256
+ ),
257
+ FastlaneCore::ConfigItem.new(
258
+ key: :build_number,
259
+ env_name: "CORDOVA_BUILD_NUMBER",
260
+ description: "Sets the build number for iOS and version code for Android",
261
+ optional: true,
262
+ is_string: false
263
+ ),
264
+ FastlaneCore::ConfigItem.new(
265
+ key: :browserify,
266
+ env_name: "CORDOVA_BROWSERIFY",
267
+ description: "Specifies whether to browserify build or not",
268
+ default_value: false,
269
+ is_string: false
270
+ ),
271
+ FastlaneCore::ConfigItem.new(
272
+ key: :cordova_prepare,
273
+ env_name: "CORDOVA_PREPARE",
274
+ description: "Specifies whether to run `ionic cordova prepare` before building",
275
+ default_value: true,
276
+ is_string: false
277
+ ),
278
+ FastlaneCore::ConfigItem.new(
279
+ key: :min_sdk_version,
280
+ env_name: "CORDOVA_ANDROID_MIN_SDK_VERSION",
281
+ description: "Overrides the value of minSdkVersion set in AndroidManifest.xml",
282
+ default_value: '',
283
+ is_string: false
284
+ ),
285
+ FastlaneCore::ConfigItem.new(
286
+ key: :cordova_no_fetch,
287
+ env_name: "CORDOVA_NO_FETCH",
288
+ description: "Call `cordova platform add` with `--nofetch` parameter",
289
+ default_value: false,
290
+ is_string: false
291
+ ),
292
+ FastlaneCore::ConfigItem.new(
293
+ key: :build_flag,
294
+ env_name: "CORDOVA_IOS_BUILD_FLAG",
295
+ description: "An array of Xcode buildFlag. Will be appended on compile command",
296
+ is_string: false,
297
+ optional: true,
298
+ default_value: []
299
+ ),
300
+ FastlaneCore::ConfigItem.new(
301
+ key: :cordova_build_config_file,
302
+ env_name: "CORDOVA_BUILD_CONFIG_FILE",
303
+ description: "Call `ionic cordova compile` with `--buildConfig=<ConfigFile>` to specify build config file path",
304
+ is_string: true,
305
+ optional: true,
306
+ default_value: ''
307
+ )
308
+ ]
309
+ end
310
+
311
+ def self.output
312
+ [
313
+ ['CORDOVA_ANDROID_RELEASE_BUILD_PATH', 'Path to the signed release APK if it was generated'],
314
+ ['CORDOVA_IOS_RELEASE_BUILD_PATH', 'Path to the signed release IPA if it was generated']
315
+ ]
316
+ end
317
+
318
+ def self.authors
319
+ ['Jan Piotrowski']
320
+ end
321
+
322
+ def self.is_supported?(platform)
323
+ true
324
+ end
325
+
326
+ def self.example_code
327
+ [
328
+ "ionic(
329
+ platform: 'ios'
330
+ )",
331
+ "ionic(
332
+ platform: 'android',
333
+ keystore_path: './staging.keystore',
334
+ keystore_alias: 'alias_name',
335
+ keystore_password: 'store_password'
336
+ )"
337
+ ]
338
+ end
339
+
340
+ def self.category
341
+ :building
342
+ end
343
+ end
344
+ end
345
+ end
@@ -1,12 +1,12 @@
1
- module Fastlane
2
- module Helper
3
- class IonicHelper
4
- # class methods that you define here become available in your action
5
- # as `Helper::IonicHelper.your_method`
6
- #
7
- def self.show_message
8
- UI.message("Hello from the ionic plugin helper!")
9
- end
10
- end
11
- end
12
- end
1
+ module Fastlane
2
+ module Helper
3
+ class IonicHelper
4
+ # class methods that you define here become available in your action
5
+ # as `Helper::IonicHelper.your_method`
6
+ #
7
+ def self.show_message
8
+ UI.message("Hello from the ionic plugin helper!")
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,5 +1,5 @@
1
- module Fastlane
2
- module Ionic
3
- VERSION = "0.0.4"
4
- end
5
- end
1
+ module Fastlane
2
+ module Ionic
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-ionic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Piotrowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-16 00:00:00.000000000 Z
11
+ date: 2018-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  requirements: []
128
128
  rubyforge_project:
129
- rubygems_version: 2.6.13
129
+ rubygems_version: 2.6.14.1
130
130
  signing_key:
131
131
  specification_version: 4
132
132
  summary: Build your Ionic app