Class: Fastlane::Actions::ConfigureSetupAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_setup_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



65
66
67
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_setup_action.rb', line 65

def self.authors
  ['Automattic']
end

.available_optionsObject



77
78
79
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_setup_action.rb', line 77

def self.available_options
  []
end

.configuration_file_existsObject



53
54
55
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_setup_action.rb', line 53

def self.configuration_file_exists
  Fastlane::Helper::ConfigureHelper.configuration_path_exists
end

.descriptionObject



61
62
63
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_setup_action.rb', line 61

def self.description
  'Set up the .configure file'
end

.detailsObject



73
74
75
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_setup_action.rb', line 73

def self.details
  'Interactively walks the user through setting up the `.configure` file. Assumes the ~/.mobile-secrets directory exists'
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_setup_action.rb', line 81

def self.is_supported?(platform)
  true
end

.prompt_to_update_to_most_recent_versionObject



40
41
42
43
44
45
46
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_setup_action.rb', line 40

def self.prompt_to_update_to_most_recent_version
  if UI.confirm("The current branch is #{Fastlane::Helper::ConfigureHelper.repo_commits_behind_remote} commit(s) behind. It must be updated to complete the setup. Would you like to continue?")
    update_branch
  else
    UI.user_error!('Cannot complete setup when the repo is not up to date.')
  end
end

.repository_pathObject



57
58
59
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_setup_action.rb', line 57

def self.repository_path
  Fastlane::Helper::FilesystemHelper.secret_store_dir
end

.return_valueObject



69
70
71
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_setup_action.rb', line 69

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

.run(params = {}) ⇒ Object



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/wpmreleasetoolkit/actions/configure/configure_setup_action.rb', line 12

def self.run(params = {})
  # Check to see if the local secret storage is set up at ~/.mobile-secrets.
  UI.user_error!('The local secrets store does not exist. Please clone it to ~/.mobile-secrets before continuing.') unless File.directory?(repository_path)

  # Checks to see if .configure exists. If so, exit – there’s no need to continue as everything is set up.
  if configuration_file_exists
    UI.success 'Configure file exists – exiting.'
    return
  end

  # The mobile secrets repo must be up to date in order to generate and save the encryption key
  prompt_to_update_to_most_recent_version if Fastlane::Helper::ConfigureHelper.repo_is_behind_remote

  # Generate an encryption key for the new project, if needed
  Fastlane::Helper::ConfigureHelper.update_project_encryption_key if Fastlane::Helper::ConfigureHelper.project_encryption_key.nil?

  # Write out the `.configure` file.
  Fastlane::Helper::ConfigureHelper.update_configure_file_from_repository

  # Walk the user through adding files to copy to the `.configure` file.
  ConfigureAddFilesToCopyAction.run

  # Copy the files we just walked the user through setting up.
  ConfigureApplyAction.run

  UI.success 'Created .configure file'
end

.update_branchObject

Ensure that the local secrets respository is up to date



49
50
51
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_setup_action.rb', line 49

def self.update_branch
  sh("cd '#{Fastlane::Helper::FilesystemHelper.secret_store_dir}' && git pull")
end