ann-flavor-flutter 0.1.12 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 815a329fc3fb31c9cec3e8482b5023c68c2951eb73ba10331ac910e3dc1ba0f2
4
- data.tar.gz: 32d4865b2b969ba4296609a480608c1bbb68b1e1959c1c2d38084c6d3027136b
3
+ metadata.gz: 86afd16e35ee819fdc999f688a838a3aac99e1488df8b701926ee696c3a27d94
4
+ data.tar.gz: 509143d39a25e2923f04f303895ff90e57d6f1967a988ac356e19efcf4453955
5
5
  SHA512:
6
- metadata.gz: 228523643e49ee2bace67ce3dd706c6411de3d4558d04326dfa9447964c56a5780a0657910345d9392ef999c034dd4ae22264bc4cf90151801d38394e5f830ea
7
- data.tar.gz: 168799e6071ec946faf8c77a40cf40e4c04dee8d8b917f2bf0eb6b546af6c74e1cae5bc17a4812107ee852b6af31181cc85f1709c635960faa03d779a9481681
6
+ metadata.gz: 8480fc1f4ca939e98dcdda2e7a97115be71155fe858addcdcf1df62e85e1ba23fe372356361ad8e7ed47f62bde19ab65096dae78927fefde6952ca17a5f1e27b
7
+ data.tar.gz: cb8f39ac36485def3ce474e44bbc86e35588f938ee302679aa461a1eb5b3648c201608f2f5f9ce0837a9899d358a7799287afc843d5381bb9032eb0d1d794932
@@ -1,3 +1,3 @@
1
1
  module AnnFlavorFlutter
2
- VERSION = "0.1.12"
2
+ VERSION = "0.1.14"
3
3
  end
@@ -94,7 +94,6 @@ module Fastlane
94
94
  skip_compile: params[:skip_compile],
95
95
  skip_sound_null_safety: params[:skip_sound_null_safety],
96
96
  firebase_project: params[:firebase_project],
97
- firebase_token: params[:firebase_token] || ENV["FIREBASE_TOKEN"],
98
97
  )
99
98
 
100
99
  if success
@@ -151,11 +150,6 @@ module Fastlane
151
150
  default_value: false),
152
151
 
153
152
  # --- Web / Firebase Specific Parameters ---
154
- FastlaneCore::ConfigItem.new(key: :firebase_token,
155
- description: "Firebase CLI CI token for authentication (generated via 'firebase login:ci')",
156
- optional: true,
157
- env_name: "FIREBASE_TOKEN",
158
- type: String),
159
153
  FastlaneCore::ConfigItem.new(key: :firebase_project,
160
154
  description: "The Firebase Project ID to deploy to. This value overrides the 'project_id' in the annai spec file",
161
155
  optional: true,
@@ -162,7 +162,7 @@ module FastlaneFlutterFlavor
162
162
  # New method to compile web build and deploy to Firebase Hosting
163
163
  def upload_to_firebase(flavor: "", main_file: "lib/main.dart", build_config: "release",
164
164
  skip_compile: false, skip_sound_null_safety: false,
165
- firebase_project:, firebase_token:) # firebase_project is the user override
165
+ firebase_project:)
166
166
 
167
167
  begin
168
168
  unless @isWeb
@@ -216,12 +216,14 @@ module FastlaneFlutterFlavor
216
216
  # 5. Write the updated firebase.json back to disk
217
217
  File.write(firebase_config_path, JSON.pretty_generate(config))
218
218
 
219
- token = firebase_token.to_s.strip
220
- if token.empty?
221
- token = @specLoader.get_firebase_token_from_properties.to_s.strip
222
- unless token.empty?
223
- Fastlane::UI.message("Successfully retrieved Firebase token from external properties file.")
224
- end
219
+ # Resolve service account for ADC auth — set GOOGLE_APPLICATION_CREDENTIALS if found
220
+ sa_path = @specLoader.get_service_account(@platform, flavor, build_config)
221
+ env_overrides = {}
222
+ if sa_path && File.exist?(sa_path)
223
+ env_overrides['GOOGLE_APPLICATION_CREDENTIALS'] = sa_path
224
+ Fastlane::UI.message("Using service account for Firebase auth: #{sa_path}")
225
+ elsif sa_path
226
+ Fastlane::UI.error("service_account file not found at: #{sa_path}")
225
227
  end
226
228
 
227
229
  # 6. Deploy to Firebase Hosting using the determined ID
@@ -230,17 +232,15 @@ module FastlaneFlutterFlavor
230
232
  "--only", "hosting",
231
233
  "--project", final_project_id,
232
234
  ]
233
- # Only add the token flags if token is present
234
- if !token.empty?
235
- command_parts.push("--token", token)
236
- end
237
235
 
238
236
  firebase_root = @root_folder
239
237
 
240
238
  Fastlane::UI.message("Executing Firebase deploy command: #{command_parts.join(' ')}")
241
239
 
242
240
  Dir.chdir firebase_root do
241
+ env_overrides.each { |k, v| ENV[k] = v }
243
242
  Fastlane::Actions::sh(*command_parts)
243
+ env_overrides.keys.each { |k| ENV.delete(k) }
244
244
  end
245
245
 
246
246
  @statusManager.logSuccess flavor, "upload_to_firebase", @platform
@@ -71,6 +71,11 @@ module FastlaneFlutterFlavor
71
71
  return current_data
72
72
  end
73
73
 
74
+ def enabled?
75
+ return false unless @spec_data
76
+ @spec_data.fetch('enabled', true) != false
77
+ end
78
+
74
79
  # Retrieves the configuration for a specific flavor, merged with the platform defaults.
75
80
  # This function uses the spec data loaded into the instance variable @spec_data.
76
81
  #
@@ -78,7 +83,7 @@ module FastlaneFlutterFlavor
78
83
  # @param flavor_name [String] The name of the flavor (e.g., 'dev', 'staging').
79
84
  # @return [Hash, nil] The fully merged configuration for the flavor, or nil if missing.
80
85
  def get_merged_flavor_config(platform, flavor_name)
81
- return nil unless @spec_data # Check if file was loaded successfully
86
+ return nil unless @spec_data && enabled?
82
87
 
83
88
  platform_key = platform.to_s
84
89
  flavor_key = flavor_name.to_s
@@ -120,7 +125,7 @@ module FastlaneFlutterFlavor
120
125
  # @param platform [Symbol] The target platform (:ios or :android).
121
126
  # @return [Hash] A hash where keys are flavor names (String) and values are their raw configs (Hash).
122
127
  def get_platform_flavors(platform)
123
- return {} unless @spec_data
128
+ return {} unless @spec_data && enabled?
124
129
  platform_key = platform.to_s
125
130
 
126
131
  # Use dig to safely retrieve the flavors hash from @spec_data
@@ -274,49 +279,25 @@ module FastlaneFlutterFlavor
274
279
  config.dig('build_types', build_config, 'firebase', 'project_id') if config
275
280
  end
276
281
 
277
- # Retrieves the firebase token from a external .properties file
278
- # as defined in app -> general -> firebase_token_file
279
- # @return [String, nil] The token value, or nil if not found/error.
280
- def get_firebase_token_from_properties
282
+ # Returns the resolved service_account path for the given platform/flavor/build_config,
283
+ # cascading from flavor build_type default build_type.
284
+ # @return [String, nil]
285
+ def get_service_account(platform, flavor_name, build_config)
281
286
  return nil unless @spec_data
282
287
 
283
- # 1. Get the properties file path from the YAML spec
284
- # Path: app -> general -> firebase_token_file
285
- rel_props_path = @spec_data.dig('app', 'general', 'firebase_token_file')
286
-
287
- if rel_props_path.nil? || rel_props_path.empty?
288
- Fastlane::UI.verbose("No 'firebase_token_file' defined in app -> general.")
289
- return nil
290
- end
288
+ platform_data = @spec_data.dig('app', platform)
289
+ return nil unless platform_data
291
290
 
292
- # 2. Resolve the full path relative to project root
293
- full_props_path = File.expand_path(rel_props_path, @root_folder)
291
+ flavor_data = platform_data.dig('flavor', flavor_name) || {}
292
+ default_data = platform_data['default'] || {}
294
293
 
295
- unless File.exist?(full_props_path)
296
- Fastlane::UI.error("Firebase token file not found at: #{full_props_path}")
297
- return nil
298
- end
294
+ flavor_bt_sa = flavor_data.dig('build_types', build_config, 'firebase', 'service_account')
295
+ default_bt_sa = default_data.dig('build_types', build_config, 'firebase', 'service_account')
299
296
 
300
- # 3. Parse the .properties file for FIREBASE_TOKEN
301
- begin
302
- File.foreach(full_props_path) do |line|
303
- # Remove whitespace and skip comments/empty lines
304
- line = line.strip
305
- next if line.empty? || line.start_with?('#', '!')
306
-
307
- # Match KEY=VALUE (handles both = and : as separators)
308
- if line =~ /^\s*FIREBASE_TOKEN\s*[=:]\s*(.*)$/
309
- token = $1.strip
310
- # Remove optional surrounding quotes if present
311
- return token.gsub(/^['"]|['"]$/, '')
312
- end
313
- end
314
- rescue => e
315
- Fastlane::UI.error("Error reading properties file at #{rel_props_path}: #{e.message}")
316
- end
297
+ path = flavor_bt_sa || default_bt_sa
298
+ return nil if path.nil? || path.empty?
317
299
 
318
- Fastlane::UI.verbose("FIREBASE_TOKEN key not found in #{rel_props_path}")
319
- return nil
300
+ File.expand_path(path, @root_folder)
320
301
  end
321
302
 
322
303
  # For AdMob (annai_ads)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ann-flavor-flutter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - ANN Solutions
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-06-27 00:00:00.000000000 Z
11
+ date: 2026-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fastlane