ann-flavor-flutter 0.1.13 → 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: 16d7f58e4027292d95f6a258d4ff3c3ac7b26b76c6cfc60c9406af289fa97fdc
4
- data.tar.gz: 4027de193deef4a6293fef30bf505fe57412f82255dcc7d036b62c6de28d55d3
3
+ metadata.gz: 86afd16e35ee819fdc999f688a838a3aac99e1488df8b701926ee696c3a27d94
4
+ data.tar.gz: 509143d39a25e2923f04f303895ff90e57d6f1967a988ac356e19efcf4453955
5
5
  SHA512:
6
- metadata.gz: 19f6a97ecde33b1d933bf4ae0e4a0e7016214a04c0f52c9d5940cc0625a04637ad65b0fd87fdf1be848843e20b23bbb110135c41a33b99fb59a04ac07199c26e
7
- data.tar.gz: 1972bfc4ba0b631a6551214620d5f94afff4e2d2871ee4229cc9024e60216ec57ce2475e316bc312f733cef12853a54fc4d1fa4b26d71cc39b0f5bf6586fd368
6
+ metadata.gz: 8480fc1f4ca939e98dcdda2e7a97115be71155fe858addcdcf1df62e85e1ba23fe372356361ad8e7ed47f62bde19ab65096dae78927fefde6952ca17a5f1e27b
7
+ data.tar.gz: cb8f39ac36485def3ce474e44bbc86e35588f938ee302679aa461a1eb5b3648c201608f2f5f9ce0837a9899d358a7799287afc843d5381bb9032eb0d1d794932
@@ -1,3 +1,3 @@
1
1
  module AnnFlavorFlutter
2
- VERSION = "0.1.13"
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
@@ -279,49 +279,25 @@ module FastlaneFlutterFlavor
279
279
  config.dig('build_types', build_config, 'firebase', 'project_id') if config
280
280
  end
281
281
 
282
- # Retrieves the firebase token from a external .properties file
283
- # as defined in app -> general -> firebase_token_file
284
- # @return [String, nil] The token value, or nil if not found/error.
285
- 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)
286
286
  return nil unless @spec_data
287
287
 
288
- # 1. Get the properties file path from the YAML spec
289
- # Path: app -> general -> firebase_token_file
290
- rel_props_path = @spec_data.dig('app', 'general', 'firebase_token_file')
288
+ platform_data = @spec_data.dig('app', platform)
289
+ return nil unless platform_data
291
290
 
292
- if rel_props_path.nil? || rel_props_path.empty?
293
- Fastlane::UI.verbose("No 'firebase_token_file' defined in app -> general.")
294
- return nil
295
- end
296
-
297
- # 2. Resolve the full path relative to project root
298
- 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'] || {}
299
293
 
300
- unless File.exist?(full_props_path)
301
- Fastlane::UI.error("Firebase token file not found at: #{full_props_path}")
302
- return nil
303
- 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')
304
296
 
305
- # 3. Parse the .properties file for FIREBASE_TOKEN
306
- begin
307
- File.foreach(full_props_path) do |line|
308
- # Remove whitespace and skip comments/empty lines
309
- line = line.strip
310
- next if line.empty? || line.start_with?('#', '!')
311
-
312
- # Match KEY=VALUE (handles both = and : as separators)
313
- if line =~ /^\s*FIREBASE_TOKEN\s*[=:]\s*(.*)$/
314
- token = $1.strip
315
- # Remove optional surrounding quotes if present
316
- return token.gsub(/^['"]|['"]$/, '')
317
- end
318
- end
319
- rescue => e
320
- Fastlane::UI.error("Error reading properties file at #{rel_props_path}: #{e.message}")
321
- end
297
+ path = flavor_bt_sa || default_bt_sa
298
+ return nil if path.nil? || path.empty?
322
299
 
323
- Fastlane::UI.verbose("FIREBASE_TOKEN key not found in #{rel_props_path}")
324
- return nil
300
+ File.expand_path(path, @root_folder)
325
301
  end
326
302
 
327
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.13
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