Module: FastlaneFlutterFlavor::ProjectUtil
- Defined in:
- lib/fastlane/plugin/ann_flutter_flavor/helper/utils_project_config.rb
Overview
ProjectUtil (Helper Module) Contains logic to locate the Flutter project root directory and key config files.
Class Method Summary collapse
-
.find_annai_spec_path(user_defined_path = nil) ⇒ Object
Find Annai Spec File Path (annspec.yaml) Uses ANN_SPEC_FILE environment variable.
-
.find_annai_test_spec_path(user_defined_path = nil) ⇒ Object
Find Annai Test Spec File Path (annaitestspec.yaml) Uses ANNAI_TEST_SPEC_FILE environment variable.
-
.find_flutter_root ⇒ Object
Find Flutter Project Root Searches upwards from the current directory for a pubspec.yaml file.
-
.resolve_config_path(filename, user_defined_path, env_var_name) ⇒ Object
Internal method to resolve config path with precedence Precedence: User Parameter > Environment Variable > Default Path.
Class Method Details
.find_annai_spec_path(user_defined_path = nil) ⇒ Object
Find Annai Spec File Path (annspec.yaml) Uses ANN_SPEC_FILE environment variable.
84 85 86 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/helper/utils_project_config.rb', line 84 def self.find_annai_spec_path(user_defined_path = nil) return resolve_config_path('annspec.yaml', user_defined_path, 'ANN_SPEC_FILE') end |
.find_annai_test_spec_path(user_defined_path = nil) ⇒ Object
Find Annai Test Spec File Path (annaitestspec.yaml) Uses ANNAI_TEST_SPEC_FILE environment variable.
92 93 94 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/helper/utils_project_config.rb', line 92 def self.find_annai_test_spec_path(user_defined_path = nil) return resolve_config_path('annaitestspec.yaml', user_defined_path, 'ANNAI_TEST_SPEC_FILE') end |
.find_flutter_root ⇒ Object
Find Flutter Project Root Searches upwards from the current directory for a pubspec.yaml file.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/helper/utils_project_config.rb', line 15 def self.find_flutter_root current_dir = Dir.pwd while current_dir != '/' do pubspec_path = File.join(current_dir, 'pubspec.yaml') if File.exist?(pubspec_path) Fastlane::UI.verbose("Found pubspec.yaml at: #{current_dir}") return current_dir end parent_dir = File.dirname(current_dir) # Prevent infinite loop if we hit the root and haven't found it break if parent_dir == current_dir current_dir = parent_dir end # Fallback to the original logic if pubspec.yaml isn't found Fastlane::UI.important("pubspec.yaml not found by searching up. Falling back to current directory.") return Dir.pwd end |
.resolve_config_path(filename, user_defined_path, env_var_name) ⇒ Object
Internal method to resolve config path with precedence Precedence: User Parameter > Environment Variable > Default Path
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/helper/utils_project_config.rb', line 39 def self.resolve_config_path(filename, user_defined_path, env_var_name) chosen_path_value = nil source = "default in project root" # Precedence 1: User-passed parameter (from action/lane) # Check if user passed an explicit path (i.e., not the action's default filename string) if user_defined_path && user_defined_path != filename chosen_path_value = user_defined_path source = "user parameter" end # Precedence 2: Environment Variable if chosen_path_value.nil? env_path = ENV[env_var_name] if env_path && !env_path.empty? chosen_path_value = env_path source = "environment variable (#{env_var_name})" end end # Precedence 3: Default in Project Root if chosen_path_value.nil? root = find_flutter_root chosen_path_value = File.join(root, filename) # source remains "default in project root" end # Resolve the path and check for existence resolved_path = File.(chosen_path_value) if File.exist?(resolved_path) Fastlane::UI.verbose("Found #{filename} path from #{source}: #{resolved_path}") else Fastlane::UI.warning("#{filename} file not found at resolved path: #{resolved_path} (Source: #{source}).") # Note: We still return the path, as it might be created later or is only referenced for metadata. end return resolved_path end |