class Fastlane::Actions::DecryptAppVarsAction
Public Class Methods
available_options()
click to toggle source
# File lib/fastlane/plugin/react_native_release/actions/decrypt_app_vars.rb, line 72 def self.available_options [ FastlaneCore::ConfigItem.new(key: :namespace, env_name: "FL_DECRYPT_APP_VARS_NAMESPACE", # The name of the environment variable description: "What namespace should we use? (alpha, beta, release, ENTER = root)", # a short description of this parameter type: String, verify_block: lambda do |value| unless Helper::ReactNativeReleaseHelper::VALID_NAMESPACES.include?(value) UI.user_error!("Invalid namespace #{value}. Valid targets are #{Helper::ReactNativeReleaseHelper::VALID_NAMESPACES.join(', ')}") next end end), FastlaneCore::ConfigItem.new(key: :write_env, env_name: "FL_DECRYPT_APP_VARS_WRITE_ENV", # The name of the environment variable description: "If we should write an .env file", # a short description of this parameter type: Boolean, default_value: true), FastlaneCore::ConfigItem.new(key: :skip_confirmation, env_name: "FL_ENCRYPT_APP_VARS_SKIP_CONFIRMATION", # The name of the environment variable description: "Allows commands to be run from within CLI and skip the UI.message confirmation dialog", # a short description of this parameter type: Boolean, short_option:'s', default_value: false, optional: true) ] end
description()
click to toggle source
@!group Documentation
# File lib/fastlane/plugin/react_native_release/actions/decrypt_app_vars.rb, line 63 def self.description "Decrypts app env vars and sets the values in the root .env file" end
details()
click to toggle source
# File lib/fastlane/plugin/react_native_release/actions/decrypt_app_vars.rb, line 67 def self.details # Optional: # this is your chance to provide a more detailed description of this action end
is_supported?(platform)
click to toggle source
# File lib/fastlane/plugin/react_native_release/actions/decrypt_app_vars.rb, line 112 def self.is_supported?(platform) [:ios, :android].include?(platform) end
return_value()
click to toggle source
# File lib/fastlane/plugin/react_native_release/actions/decrypt_app_vars.rb, line 99 def self.return_value # If your method provides a return value, you can describe here what it does end
run(params)
click to toggle source
# File lib/fastlane/plugin/react_native_release/actions/decrypt_app_vars.rb, line 7 def self.run(params) is_ci = ENV['CI'] === 'true' namespace = params[:namespace] write_env = params[:write_env] skip_confirmation= params[:skip_confirmation] default_cryptex_app_key = Helper::ReactNativeReleaseHelper::APP_CRYPTEX_KEY cryptex_app_key = Helper::ReactNativeReleaseHelper.app_key_for(namespace) is_same_key = default_cryptex_app_key == cryptex_app_key message = '' if(!skip_confirmation) if is_same_key message = "This will decrypt values from #{cryptex_app_key}. Proceed?" else message = "This will decrypt and merge values from #{cryptex_app_key} into #{default_cryptex_app_key}. Proceed?" end if !is_ci && !UI.confirm(message) UI.abort_with_message!("Stepping away...") end end app_vars = other_action.cryptex( type: "export_env", key: default_cryptex_app_key ) namespaced_vars = other_action.cryptex( type: "export_env", key: cryptex_app_key ) merged_vars = app_vars.merge(namespaced_vars) has_env_file = File.exists?(Helper::ReactNativeReleaseHelper::APP_ENV_PATH) should_write_env = write_env && (is_ci || skip_confirmation || !has_env_file || UI.confirm("It looks like you already have an .env file. Overwrite it?")) # write an env file with the merged values if (should_write_env) # TODO: handle running action from root and from ios/android folders. This will not work properly in the root as is. open('../.env', 'w') do |f| merged_vars.each {|key, value| f.puts "#{key}=#{value}" } end UI.success('.env written') else UI.success('not writing .env') end merged_vars end