Class: Fastlane::Actions::EncryptAppVarsAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::EncryptAppVarsAction
- Defined in:
- lib/fastlane/plugin/react_native_release/actions/encrypt_app_vars.rb
Documentation collapse
-
.app_key_for(namespace) ⇒ Object
Returns the app key for cryptex.
- .authors ⇒ Object
- .available_options ⇒ Object
- .default_env_path ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
-
.env_path_for(namespace) ⇒ Object
Returns a path for an env var.
- .is_supported?(platform) ⇒ Boolean
- .return_value ⇒ Object
Class Method Summary collapse
Class Method Details
.app_key_for(namespace) ⇒ Object
Returns the app key for cryptex. optionally namespaced
109 110 111 112 113 114 |
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_app_vars.rb', line 109 def self.app_key_for(namespace) default_app_key = Helper::ReactNativeReleaseHelper::APP_CRYPTEX_KEY return default_app_key if namespace.strip.empty? "#{namespace}_#{default_app_key}" end |
.authors ⇒ Object
93 94 95 96 |
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_app_vars.rb', line 93 def self. # So no one will ever forget your contribution to fastlane :) You are awesome btw! ["cball", "isaiahgrey93", "cmejet"] end |
.available_options ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_app_vars.rb', line 58 def self. [ FastlaneCore::ConfigItem.new(key: :namespace, env_name: "FL_ENCRYPT_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: :env_path, env_name: "FL_ENCRYPT_APP_VARS_ENV_PATH", # The name of the environment variable description: "A path to an ENV file that contains app related ENV vars", # a short description of this parameter type: String, optional: 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 |
.default_env_path ⇒ Object
116 117 118 |
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_app_vars.rb', line 116 def self.default_env_path Helper::ReactNativeReleaseHelper::APP_ENV_PATH end |
.description ⇒ Object
49 50 51 |
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_app_vars.rb', line 49 def self.description "Encrypts app env vars and stores them in the context repo." end |
.details ⇒ Object
53 54 55 56 |
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_app_vars.rb', line 53 def self.details # Optional: # this is your chance to provide a more detailed description of this action end |
.env_path_for(namespace) ⇒ Object
Returns a path for an env var. optionally namespaced
103 104 105 106 |
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_app_vars.rb', line 103 def self.env_path_for(namespace) return default_env_path if namespace.strip.empty? "#{default_env_path}.#{namespace}" end |
.is_supported?(platform) ⇒ Boolean
98 99 100 |
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_app_vars.rb', line 98 def self.is_supported?(platform) [:ios, :android].include?(platform) end |
.return_value ⇒ Object
85 86 87 |
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_app_vars.rb', line 85 def self.return_value # If your method provides a return value, you can describe here what it does end |
.run(params) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_app_vars.rb', line 7 def self.run(params) namespace = params[:namespace] cryptex_app_key = app_key_for(namespace) env_path = params[:env_path] || env_path_for(namespace) skip_confirmation= params[:skip_confirmation] if !File.exists?(env_path) UI.user_error!("#{env_path} not found!") end if(!skip_confirmation) if !UI.confirm("This will save values from #{env_path} to the #{cryptex_app_key} namespace in the encrypted context repo. Proceed?") UI.("Stepping away...") end end app_vars = Dotenv.parse(env_path) existing_app_vars = {} begin existing_app_vars = other_action.cryptex( type: 'export_env', key: cryptex_app_key, ) rescue => ex # If key doesn't exist cryptex will error end other_action.cryptex( type: "import_env", key: cryptex_app_key, hash: existing_app_vars.merge(app_vars) ) UI.success('Encrypted app ENV vars') end |