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



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

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.



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

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



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

def self.authors
  ['Automattic']
end

.available_optionsObject



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

def self.available_options
  []
end

.descriptionObject



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

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

.detailsObject



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

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

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


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

def self.is_supported?(platform)
  true
end

.return_valueObject



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

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
# 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 do |file_reference|
      file_reference.update
    end
  end
end

.secret_store_dirObject



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

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