Class: Fastlane::Actions::EncryptFastlaneVarsAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/react_native_release/actions/encrypt_fastlane_vars.rb

Constant Summary collapse

ANDROID_ENV_PATH =
"./android/fastlane/.env"
IOS_ENV_PATH =
'./ios/fastlane/.env'
FASTLANE_CRYPTEX_KEY =
'fastlane_vars'

Class Method Summary collapse

Class Method Details

.authorsObject



56
57
58
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_fastlane_vars.rb', line 56

def self.authors
  ["cball", "isaiahgrey93", "cmejet"]
end

.available_optionsObject



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_fastlane_vars.rb', line 44

def self.available_options
  [
    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

.descriptionObject



40
41
42
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_fastlane_vars.rb', line 40

def self.description
  "Encrypt fastlane vars for CI"
end

.detailsObject



64
65
66
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_fastlane_vars.rb', line 64

def self.details
  "Saves the current vars in android/fastlane/.env and ios/fastlane/.env"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


68
69
70
71
72
73
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_fastlane_vars.rb', line 68

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
  #
  [:ios, :android].include?(platform)
end

.return_valueObject



60
61
62
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_fastlane_vars.rb', line 60

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



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
# File 'lib/fastlane/plugin/react_native_release/actions/encrypt_fastlane_vars.rb', line 11

def self.run(params)
  skip_confirmation= params[:skip_confirmation]

  if !File.exists?(IOS_ENV_PATH)
    UI.user_error!("No .env found in ios directory!")
  end

  if !File.exists?(ANDROID_ENV_PATH)
    UI.user_error!("No .env found in Android directory")
  end


  if !skip_confirmation && !UI.confirm("This will save values from your #{IOS_ENV_PATH} and #{ANDROID_ENV_PATH} to the encrypted context repo. Proceed?")
    UI.abort_with_message!("Stepping away...")
  end

  android_env_vars = Dotenv.parse(ANDROID_ENV_PATH)
  ios_env_vars = Dotenv.parse(IOS_ENV_PATH)
  vars = android_env_vars.merge(ios_env_vars)
    
  other_action.cryptex(
    type: "import_env",
    key: FASTLANE_CRYPTEX_KEY,
    hash: vars,
  )

  UI.success "ENV vars set in context repo."
end