Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Use locally installed Ionic (from node_modules/.bin) #58

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ Which will produce:
| **cordova_no_fetch** | Specifies whether to run `ionic cordova platform add` with `--nofetch` parameter | CORDOVA_NO_FETCH | *false* |
| **build_flag** | An array of Xcode buildFlag. Will be appended on compile command. | CORDOVA_IOS_BUILD_FLAG | [] |
| **cordova_build_config_file** | Call `ionic cordova compile` with `--buildConfig=<ConfigFile>` to specify build config file path | CORDOVA_BUILD_CONFIG_FILE | |
| **use_local_ionic** | Use locally installed Ionic instead of globally installed one. Useful for shared CI environments. | USE_LOCAL_IONIC | *false* |


## Run tests for this plugin
Expand Down
26 changes: 20 additions & 6 deletions lib/fastlane/plugin/ionic/actions/ionic_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,18 @@ def self.get_ios_args(params)
return self.get_platform_args(params, IOS_ARGS_MAP)
end

def self.get_ionic_path(params)
return params[:use_local_ionic] ? File.join("node_modules", ".bin", "") : ""
end

# add platform if missing (run step #1)
def self.check_platform(params)
platform = params[:platform]
if platform && !File.directory?("./platforms/#{platform}")
if params[:cordova_no_fetch]
sh "ionic cordova platform add #{platform} --no-interactive --nofetch"
sh "#{self.get_ionic_path(params)}ionic cordova platform add #{platform} --no-interactive --nofetch"
else
sh "ionic cordova platform add #{platform} --no-interactive"
sh "#{self.get_ionic_path(params)}ionic cordova platform add #{platform} --no-interactive"
end
end
end
Expand All @@ -110,7 +114,7 @@ def self.build(params)

if params[:cordova_prepare]
# TODO: Remove params not allowed/used for `prepare`
sh "ionic cordova prepare #{params[:platform]} --no-interactive #{args.join(' ')}"
sh "#{self.get_ionic_path(params)}ionic cordova prepare #{params[:platform]} --no-interactive #{args.join(' ')}"
end

# special handling for `build_number` param
Expand All @@ -126,9 +130,9 @@ def self.build(params)
end

if params[:platform].to_s == 'ios'
sh "ionic cordova compile #{params[:platform]} --no-interactive #{args.join(' ')} -- #{ios_args}"
sh "#{ionic_path}ionic cordova compile #{params[:platform]} --no-interactive #{args.join(' ')} -- #{ios_args}"
elsif params[:platform].to_s == 'android'
sh "ionic cordova compile #{params[:platform]} --no-interactive #{args.join(' ')} -- -- #{android_args}"
sh "#{ionic_path}ionic cordova compile #{params[:platform]} --no-interactive #{args.join(' ')} -- -- #{android_args}"
end
end

Expand Down Expand Up @@ -306,7 +310,17 @@ def self.available_options
is_string: true,
optional: true,
default_value: ''
)
),
FastlaneCore::ConfigItem.new(
key: :use_local_ionic,
env_name: "USE_LOCAL_IONIC",
description: "Use locally installed Ionic instead of globally installed one. Useful for shared CI environments.",
is_string: false,
default_value: false,
verify_block: proc do |value|
UI.user_error!("Local Ionic should be boolean") unless [false, true].include? value
end
),
]
end

Expand Down