Class: Fastlane::Actions::ConfigureAddFilesToCopyAction

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

Class Method Summary collapse

Class Method Details

.absolute_secret_store_path(relative_path) ⇒ Object



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

def self.absolute_secret_store_path(relative_path)
  Fastlane::Helper::FilesystemHelper.absolute_secret_store_path(relative_path)
end

.add_fileObject

Walks the user through adding a file to the project’s ‘/.configure `file.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_add_files_to_copy_action.rb', line 33

def self.add_file
  invalid_file = true

  while invalid_file
    UI.header 'Please provide the location of the source file relative to the secrets repository'
    UI.message 'Example: google-services.json'

    source = UI.input('Source File Path:')
    source_path = absolute_secret_store_path(source) # Transform the relative path into an absolute path.

    # Don't allow the developer to accidentally specify an invalid file, otherwise validation will never succeed.
    if File.file?(source_path)
      invalid_file = false
    else
      UI.error "There is no file at #{source_path}."
    end
  end

  UI.header 'Please provide the destination of the file relative to the project root'
  UI.message 'Example: WordPress/google-services.json'

  destination = UI.input('Destination File Path:') # Leave the destination as a relative path, as no validation is required.

  encrypt = UI.confirm('Encrypt file?:')

  Fastlane::Helper::ConfigureHelper.add_file(source: source, destination: destination, encrypt: encrypt)
end

.authorsObject



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

def self.authors
  ['Automattic']
end

.available_optionsObject



85
86
87
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_add_files_to_copy_action.rb', line 85

def self.available_options
  []
end

.descriptionObject



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

def self.description
  'Interactively add files to the `files_to_copy` list in .configure.'
end

.detailsObject



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

def self.details
  'Interactively add files to the `files_to_copy` list in .configure.'
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_add_files_to_copy_action.rb', line 89

def self.is_supported?(platform)
  true
end

.return_valueObject



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

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
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_add_files_to_copy_action.rb', line 12

def self.run(params = {})
  continue = true

  while continue

    confirmation = 'Do you want to specify a file that should be copied from the secrets repository into your project?'

    confirmation = 'Do you want to specify additional files that should be copied from the secrets repository into your project?' if Fastlane::Helper::ConfigureHelper.has_files

    if UI.confirm(confirmation)
      add_file
    else
      continue = false
    end

    Fastlane::Helper::ConfigureHelper.files_to_copy.each(&:update)
  end
end

.secret_store_dirObject



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

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