Class: Fastlane::Helper::FilesystemHelper
- Inherits:
-
Object
- Object
- Fastlane::Helper::FilesystemHelper
- Defined in:
- lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb
Class Method Summary collapse
-
.absolute_project_path(relative_path) ⇒ Object
Transforms a relative path within the project to an absolute path on disk.
-
.absolute_secret_store_path(relative_path) ⇒ Object
Transforms a relative path within the secret store to an absolute path on disk.
-
.configure_file ⇒ Object
Returns the path to the project’s ‘.configure` file.
-
.configure_files_dir ⇒ Object
Returns the path to the project’s ‘.configure-files` directory.
- .encrypted_file_path(file) ⇒ Object
-
.file_hash(absolute_path) ⇒ Object
Returns the ‘sha1` hash of a file, given the absolute path.
- .plugin_root ⇒ Object
-
.project_path ⇒ Object
Traverse the file system to find the root project directory.
-
.secret_store_dir ⇒ Object
Returns the path to the ‘~/.mobile-secrets` directory.
-
.secret_store_keys_path ⇒ Object
Path to keys.json in the secrets repository.
Class Method Details
.absolute_project_path(relative_path) ⇒ Object
Transforms a relative path within the project to an absolute path on disk.
83 84 85 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb', line 83 def self.absolute_project_path(relative_path) File.join(project_path, relative_path) end |
.absolute_secret_store_path(relative_path) ⇒ Object
Transforms a relative path within the secret store to an absolute path on disk.
73 74 75 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb', line 73 def self.absolute_secret_store_path(relative_path) File.join(secret_store_dir, relative_path) end |
.configure_file ⇒ Object
Returns the path to the project’s ‘.configure` file.
54 55 56 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb', line 54 def self.configure_file Pathname.new(project_path) + '.configure' end |
.configure_files_dir ⇒ Object
Returns the path to the project’s ‘.configure-files` directory.
59 60 61 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb', line 59 def self.configure_files_dir Pathname.new(project_path) + '.configure-files' end |
.encrypted_file_path(file) ⇒ Object
63 64 65 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb', line 63 def self.encrypted_file_path(file) File.join(configure_files_dir, "#{File.basename(file)}.enc") end |
.file_hash(absolute_path) ⇒ Object
Returns the ‘sha1` hash of a file, given the absolute path.
88 89 90 91 92 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb', line 88 def self.file_hash(absolute_path) UI.user_error!("Unable to hash #{absolute_path} – the file does not exist") unless File.file?(absolute_path) Digest::SHA1.file absolute_path end |
.plugin_root ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb', line 32 def self.plugin_root continue = true dir = Pathname.new(__FILE__).dirname while continue child_filenames = dir.children.map! { |x| File.basename(x) } # The first case is for development – where the `.gemspec` is present in the project root # The second case is for production – where there's no `.gemspec`, but the root dir of the plugin is named `fastlane-plugin-wpmreleasetoolkit-{version}`. if child_filenames.include?('fastlane-plugin-wpmreleasetoolkit.gemspec') || File.basename(dir).start_with?('fastlane-plugin-wpmreleasetoolkit-') continue = false else dir = dir.parent end UI.user_error!('Unable to determine the plugin root directory.') if dir.root? end dir end |
.project_path ⇒ Object
Traverse the file system to find the root project directory. For the purposes of this function, we’re assuming the root project directory is the one with the ‘.git` file in it.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb', line 13 def self.project_path continue = true dir = Pathname.new(Dir.pwd) while continue child_filenames = dir.children.map! { |x| File.basename(x) } if child_filenames.include? '.git' continue = false else dir = dir.parent end UI.user_error!("Unable to determine the project root directory – #{Dir.pwd} doesn't appear to reside within a git repository.") if dir.root? end dir end |
.secret_store_dir ⇒ Object
Returns the path to the ‘~/.mobile-secrets` directory.
68 69 70 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb', line 68 def self.secret_store_dir return "#{Dir.home}/.mobile-secrets" end |
.secret_store_keys_path ⇒ Object
Path to keys.json in the secrets repository
78 79 80 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb', line 78 def self.secret_store_keys_path File.join(secret_store_dir, 'keys.json') end |