diff --git a/.gitignore b/.gitignore
index df8deec..af57ee9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@ Gemfile.lock
/rdoc/
fastlane/README.md
fastlane/report.xml
+coverage/
diff --git a/.rubocop.yml b/.rubocop.yml
index f65b55b..2e1286c 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -15,7 +15,9 @@ Style/VariableNumber:
Enabled: false
# This is used a lot across the fastlane code base for config files
-Style/MethodMissing:
+Style/MethodMissingSuper:
+ Enabled: false
+Style/MissingRespondToMissing:
Enabled: false
#
diff --git a/README.md b/README.md
index 789d214..3ae824e 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,11 @@
# _fastlane_ Plugin for Ionic CLI
-[](https://rubygems.org/gems/fastlane-plugin-ionic) [](https://github.com/ionic-zone/fastlane-plugin-ionic/blob/master/LICENSE)
+[](https://rubygems.org/gems/fastlane-plugin-ionic)
+[](https://github.com/ionic-zone/fastlane-plugin-ionic/blob/master/LICENSE)
[](http://rubygems.org/gems/fastlane-plugin-ionic)
+[](https://travis-ci.org/ionic-zone/fastlane-plugin-ionic)
+[](https://codecov.io/gh/ionic-zone/fastlane-plugin-ionic)
+
This _fastlane_ plugin helps you build your **Ionic Cordova** project via the [`ionic` CLI](https://ionicframework.com/docs/cli/).
@@ -97,18 +101,21 @@ Which will produce:
| Key | Description | Env Var | Default |
|-----|-------------|---------|---------|
+| _general_ |
| **platform** | Platform to build on.
Should be either android or ios | CORDOVA_PLATFORM | |
| **release** | Build for release if true,
or for debug if false | CORDOVA_RELEASE | *true* |
| **device** | Build for device | CORDOVA_DEVICE | *true* |
| **prod** | Build for production | IONIC_PROD | *false* |
+| _iOS signing_ |
| **type** | This will determine what type of build is generated by Xcode.
Valid options are development, enterprise, adhoc, and appstore| CORDOVA_IOS_PACKAGE_TYPE | appstore |
| **team_id** | The development team (Team ID) to use for code signing | CORDOVA_IOS_TEAM_ID | *28323HT* |
| **provisioning_profile** | GUID of the provisioning profile to be used for signing | CORDOVA_IOS_PROVISIONING_PROFILE | |
+| _Android signing_ |
| **keystore_path** | Path to the Keystore for Android | CORDOVA_ANDROID_KEYSTORE_PATH | |
| **keystore_password** | Android Keystore password | CORDOVA_ANDROID_KEYSTORE_PASSWORD | |
| **key_password** | Android Key password (default is keystore password) | CORDOVA_ANDROID_KEY_PASSWORD | |
| **keystore_alias** | Android Keystore alias | CORDOVA_ANDROID_KEYSTORE_ALIAS | |
-| **min_sdk_version** | Overrides the value of minSdkVersion | CORDOVA_ANDROID_MIN_SDK_VERSION | |
+| _other config_ |
| **build_number** | Sets the build number for iOS and version code for Android | CORDOVA_BUILD_NUMBER | |
| **browserify** | Specifies whether to browserify build or not | CORDOVA_BROWSERIFY | *false* |
| **cordova_prepare** | Specifies whether to run `ionic cordova prepare` before building | CORDOVA_PREPARE | *true* |
diff --git a/circle.yml b/circle.yml
deleted file mode 100644
index 3c3bb8d..0000000
--- a/circle.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-test:
- override:
- - bundle exec rake
-machine:
- ruby:
- version: 2.2.4
-# Enable xcode below if you need macOS
-# xcode:
-# version: "7.3"
diff --git a/fastlane-plugin-ionic.gemspec b/fastlane-plugin-ionic.gemspec
index 3412534..0a86f54 100644
--- a/fastlane-plugin-ionic.gemspec
+++ b/fastlane-plugin-ionic.gemspec
@@ -25,4 +25,6 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'fastlane', '>= 1.111.0'
+ spec.add_development_dependency 'simplecov'
+ spec.add_development_dependency 'codecov'
end
diff --git a/fastlane/Fastfile b/fastlane/Fastfile
index 51418fa..3d6f067 100644
--- a/fastlane/Fastfile
+++ b/fastlane/Fastfile
@@ -16,7 +16,7 @@ platform :android do
platform: 'android',
keystore_path: './prod.keystore',
keystore_alias: 'prod',
- keystore_password: 'password'
+ keystore_password: 'password',
build_flag: ['-UseModernBuildSystem=0']
)
supply(apk: ENV('CORDOVA_ANDROID_RELEASE_BUILD_PATH'))
diff --git a/lib/fastlane/plugin/ionic/actions/ionic_action.rb b/lib/fastlane/plugin/ionic/actions/ionic_action.rb
index 1adfe23..060d57a 100644
--- a/lib/fastlane/plugin/ionic/actions/ionic_action.rb
+++ b/lib/fastlane/plugin/ionic/actions/ionic_action.rb
@@ -36,18 +36,18 @@ def self.get_platform_args(params, platform_args_map)
if action_key.to_s == 'build_flag' && param_value.kind_of?(Array)
unless param_value.empty?
param_value.each do |flag|
- platform_args << "--#{cli_param}=#{flag.shellescape}"
+ platform_args << "--#{cli_param}=#{flag.to_s.shellescape}"
end
end
# handle all other cases
else
unless param_value.to_s.empty?
- platform_args << "--#{cli_param}=#{param_value.shellescape}"
+ platform_args << "--#{cli_param}=#{param_value.to_s.shellescape}"
end
end
end
- return platform_args.join(' ')
+ return platform_args
end
def self.get_android_args(params)
@@ -94,25 +94,27 @@ def self.get_app_name
return config.elements['widget'].elements['name'].first.value # TODO: Simplify!? (Check logic in cordova)
end
- # actual building! (run step #2)
- def self.build(params)
+ def self.get_args(params)
args = [params[:release] ? '--release' : '--debug']
args << '--device' if params[:device]
args << '--prod' if params[:prod]
args << '--browserify' if params[:browserify]
if !params[:cordova_build_config_file].to_s.empty?
- args << "--buildConfig=#{Shellwords.escape(params[:cordova_build_config_file])}"
+ args << "--buildConfig=#{params[:cordova_build_config_file].shellescape}"
end
- android_args = self.get_android_args(params) if params[:platform].to_s == 'android'
- ios_args = self.get_ios_args(params) if params[:platform].to_s == 'ios'
+ return args
+ end
+ def self.prepare(params, args)
if params[:cordova_prepare]
# TODO: Remove params not allowed/used for `prepare`
sh "ionic cordova prepare #{params[:platform]} --no-interactive #{args.join(' ')}"
end
+ end
+ def self.update_build_number(params)
# special handling for `build_number` param
if params[:platform].to_s == 'ios' && !params[:build_number].to_s.empty?
cf_bundle_version = params[:build_number].to_s
@@ -124,14 +126,26 @@ def self.build(params)
}
)
end
+ end
+ def self.compile(params, args)
if params[:platform].to_s == 'ios'
- sh "ionic cordova compile #{params[:platform]} --no-interactive #{args.join(' ')} -- #{ios_args}"
+ android_args = self.get_android_args(params)
+ sh "ionic cordova compile #{params[:platform]} --no-interactive #{args.join(' ')} -- #{ios_args.join(' ')}"
elsif params[:platform].to_s == 'android'
- sh "ionic cordova compile #{params[:platform]} --no-interactive #{args.join(' ')} -- -- #{android_args}"
+ ios_args = self.get_ios_args(params)
+ sh "ionic cordova compile #{params[:platform]} --no-interactive #{args.join(' ')} -- -- #{android_args.join(' ')}"
end
end
+ # actual building! (run step #2)
+ def self.build(params)
+ args = self.get_args(params)
+ self.prepare(params, args)
+ self.update_build_number(params)
+ self.compile(params, args)
+ end
+
# export build paths (run step #3)
def self.set_build_paths(is_release)
app_name = self.get_app_name
@@ -140,6 +154,7 @@ def self.set_build_paths(is_release)
ENV['CORDOVA_ANDROID_RELEASE_BUILD_PATH'] = "./platforms/android/app/build/outputs/apk/#{build_type}/app-#{build_type}.apk"
ENV['CORDOVA_IOS_RELEASE_BUILD_PATH'] = "./platforms/ios/build/device/#{app_name}.ipa"
+ return true
# TODO: https://github.com/bamlab/fastlane-plugin-cordova/issues/7
# TODO: Set env vars that gym and Co automatically use
end
diff --git a/spec/ionic_action_spec.rb b/spec/ionic_action_spec.rb
index 9ef6c55..d0e3be6 100644
--- a/spec/ionic_action_spec.rb
+++ b/spec/ionic_action_spec.rb
@@ -1,4 +1,74 @@
describe Fastlane::Actions::IonicAction do
describe '#run' do
end
+
+ describe '#check_platform' do
+ before do
+ allow(File).to receive(:directory?).and_return(false)
+ end
+
+ let (:params) { {} }
+
+ describe 'platform missing' do
+ it 'platform = android' do
+ params[:platform] = 'android'
+ result = Fastlane::Actions::IonicAction.check_platform(params);
+ expect(result).to eq("ionic cordova platform add android --no-interactive")
+ end
+
+ it 'platform = ios' do
+ params[:platform] = 'ios'
+ result = Fastlane::Actions::IonicAction.check_platform(params);
+ expect(result).to eq("ionic cordova platform add ios --no-interactive")
+ end
+
+ it 'platform = android + nofetch' do
+ params[:platform] = 'android'
+ params[:cordova_no_fetch] = true
+ result = Fastlane::Actions::IonicAction.check_platform(params);
+ expect(result).to eq("ionic cordova platform add android --no-interactive --nofetch")
+ end
+ end
+
+ describe 'platform exists' do
+ before do
+ allow(File).to receive(:directory?).and_return(true)
+ end
+
+ it 'platform = android' do
+ params[:platform] = 'android'
+ result = Fastlane::Actions::IonicAction.check_platform(params);
+ expect(result).to eq(nil)
+ end
+ end
+ end
+
+ describe '#get_args' do
+ let (:params) { {} }
+
+ #params[:release] ? '--release' : '--debug']
+ #args << '--device' if params[:device]
+ #args << '--prod' if params[:prod]
+ #args << '--browserify' if params[:browserify]
+ #if !params[:cordova_build_config_file].to_s.empty?
+ # args << "--buildConfig=#{
+
+ it 'none' do
+ result = Fastlane::Actions::IonicAction.get_args(params);
+ expect(result).to eq(['--debug'])
+ end
+
+ it 'release, device, prod, browserify, cordova_build_config_file' do
+ params = { :release => true, :device => true, :prod => true, :browserify => true, :cordova_build_config_file => 'foo'}
+ result = Fastlane::Actions::IonicAction.get_args(params);
+ expect(result).to eql(['--release', '--device', '--prod', '--browserify', '--buildConfig=foo'])
+ end
+
+ it 'cordova_build_config_file = path with space' do
+ path = "path with space"
+ params = { :cordova_build_config_file => path}
+ result = Fastlane::Actions::IonicAction.get_args(params);
+ expect(result).to eql(['--debug', "--buildConfig=#{path.shellescape}"])
+ end
+ end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 235cb89..7fabb19 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,3 +1,13 @@
+require 'simplecov'
+SimpleCov.start do
+ add_filter 'spec/'
+end
+
+if(ENV['CI'])
+ require 'codecov'
+ SimpleCov.formatter = SimpleCov::Formatter::Codecov
+end
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
# This module is only used to check the environment is currently a testing env