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
98 99 100 101 102 103 |
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_app_vars.rb', line 98 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
82 83 84 85 |
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_app_vars.rb', line 82 def self. # So no one will ever forget your contribution to fastlane :) You are awesome btw! ["cball", "isaiahgrey93", "cmejet"] end |
.available_options ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_app_vars.rb', line 54 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) ] end |
.default_env_path ⇒ Object
105 106 107 |
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_app_vars.rb', line 105 def self.default_env_path Helper::ReactNativeReleaseHelper::APP_ENV_PATH end |
.description ⇒ Object
45 46 47 |
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_app_vars.rb', line 45 def self.description "Encrypts app env vars and stores them in the context repo." end |
.details ⇒ Object
49 50 51 52 |
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_app_vars.rb', line 49 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
92 93 94 95 |
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_app_vars.rb', line 92 def self.env_path_for(namespace) return default_env_path if namespace.strip.empty? "#{default_env_path}.#{namespace}" end |
.is_supported?(platform) ⇒ Boolean
87 88 89 |
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_app_vars.rb', line 87 def self.is_supported?(platform) [:ios, :android].include?(platform) end |
.return_value ⇒ Object
74 75 76 |
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_app_vars.rb', line 74 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 |
# 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) if !File.exists?(env_path) UI.user_error!("#{env_path} not found!") end 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 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 |