Skip to content

Commit 93501fe

Browse files
committed
readme replacement for ios pods
1 parent 991cdba commit 93501fe

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

scripts/update_ios_android_dependencies.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -290,19 +290,19 @@ def modify_pod_file(pod_file, pod_version_map, dryrun=True):
290290

291291

292292
RE_README_POD_VERSION = re.compile(
293-
r"<br>(?P<pod_name>.+) Cocoapod \((?P<version>.+)\)")
293+
r"Firebase/(?P<product_pod_name>\w+) Cocoapod \((?P<version>([0-9.]+))\)")
294294

295295
def modify_readme_file_pods(readme_filepath, version_map, dryrun=True):
296296
"""Modify a readme Markdown file to reference correct cocoapods versions.
297297
298298
Looks for lines like:
299-
<br>Firebase/AdMob Cocoapod (7.11.0)
299+
<br>Firebase/AdMob Cocoapod (7.11.0)<br>Firebase/Auth Cocoapod (8.1.0)
300300
for pods matching the ones in the version map, and modifies them in-place.
301301
302302
Args:
303303
readme_filepath: Path to readme file to edit.
304304
version_map: Dictionary of packages to version numbers, e.g. {
305-
'FirebaseAuth': '15.0.0' }
305+
'FirebaseAuth': '15.0.0', 'FirebaseDatabase': '14.0.0' }
306306
dryrun (bool, optional): Just print the substitutions.
307307
Do not write to file. Defaults to True.
308308
"""
@@ -317,18 +317,20 @@ def modify_readme_file_pods(readme_filepath, version_map, dryrun=True):
317317
output_lines = []
318318

319319
# Replacement function, look up the version number of the given pkg.
320-
def replace_module_line(m):
321-
if not m.group('pod_name'):
320+
def replace_pod_line(m):
321+
if not m.group('product_pod_name'):
322322
return m.group(0)
323-
pod_key = m.group('pod_name').replace('/', '')
323+
pod_key = 'Firebase' + m.group('product_pod_name')
324324
if pod_key not in version_map:
325325
return m.group(0)
326-
repl = '%s Cocoapod (%s)' % (m.group('pod_name'), version_map[pod_key])
327-
return '<br>{0}'.format(repl)
326+
repl = 'Firebase/%s Cocoapod (%s)' % (m.group('product_pod_name'),
327+
version_map[pod_key])
328+
return repl
328329

329330
substituted_pairs = []
331+
to_update = False
330332
for line in lines:
331-
substituted_line = re.sub(RE_README_ANDROID_VERSION, replace_module_line,
333+
substituted_line = re.sub(RE_README_POD_VERSION, replace_pod_line,
332334
line)
333335
output_lines.append(substituted_line)
334336
if substituted_line != line:
@@ -415,6 +417,7 @@ def replace_dependency(m):
415417
quote_type)
416418

417419
substituted_pairs = []
420+
to_update = False
418421
for line in lines:
419422
substituted_line = re.sub(RE_GENERIC_DEPENDENCY_MODULE, replace_dependency,
420423
line)
@@ -438,7 +441,7 @@ def replace_dependency(m):
438441
r"<br>(?P<pkg>[a-zA-Z0-9._-]+:[a-zA-Z0-9._-]+):([0-9.]+)<br>")
439442

440443

441-
def modify_readme_file(readme_filepath, version_map, dryrun=True):
444+
def modify_readme_file_android(readme_filepath, version_map, dryrun=True):
442445
"""Modify a readme Markdown file to reference correct module versions.
443446
444447
Looks for lines like:
@@ -458,7 +461,8 @@ def modify_readme_file(readme_filepath, version_map, dryrun=True):
458461
with open(readme_filepath, "r") as readme_file:
459462
lines = readme_file.readlines()
460463
if not lines:
461-
logging.fatal('Could not read contents of file %s', readme_filepath)
464+
logging.fatal('Update failed. ' +
465+
'Could not read contents from file {0}.'.format(readme_filepath))
462466

463467
output_lines = []
464468

@@ -469,10 +473,11 @@ def replace_module_line(m):
469473
pkg = m.group('pkg').replace('-', '_').replace(':', '.')
470474
if pkg not in version_map:
471475
return m.group(0)
472-
repl = '%s:%s' % (m.group('pkg'), version_map[pkg])
473-
return '<br>{0}<br>'.format(repl)
476+
repl = '<br>%s:%s<br>' % (m.group('pkg'), version_map[pkg])
477+
return repl
474478

475479
substituted_pairs = []
480+
to_update = False
476481
for line in lines:
477482
substituted_line = re.sub(RE_README_ANDROID_VERSION, replace_module_line,
478483
line)
@@ -545,7 +550,9 @@ def main():
545550
file_name='readme')
546551
if not args.skip_ios:
547552
#latest_pod_versions_map = get_latest_pod_versions(args.specs_repo, PODS)
548-
latest_pod_versions_map = {'FirebaseAuth': '8.0.0', 'FirebaseRemoteConfig':'9.9.9'}
553+
latest_pod_versions_map = {'FirebaseAuth': '8.0.0',
554+
'FirebaseRemoteConfig':'9.9.9',
555+
'FirebaseDatabase': '11.11.11'}
549556
pod_files = get_files(args.podfiles, file_extension='', file_name='Podfile')
550557
for pod_file in pod_files:
551558
modify_pod_file(pod_file, latest_pod_versions_map, args.dryrun)
@@ -556,6 +563,7 @@ def main():
556563
#latest_android_versions_map = get_latest_maven_versions()
557564
latest_android_versions_map = {
558565
'com.google.firebase.firebase_auth': '6.6.6',
566+
'com.google.firebase.firebase_analytics': '8.8.8',
559567
'com.google.firebase.firebase_database': '9.9.9',
560568
}
561569

0 commit comments

Comments
 (0)