Class RuntimeBuilderUtilities
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe file name of the Android Firebase configuration.static final StringThe file name of the iOS Firebase configuration.static final StringThe Cordova platform ID of Android, the key of its project inizRun.FCM_PROJECT.static final StringThe Cordova platform ID of iOS, the key of its project inizRun.FCM_PROJECT.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionReads the package names of agoogle-services.jsonfile: everyclient[].client_info.android_client_info.package_name, in file order, trimmed.static StringgetFirebaseIOSBundleID(File file) Reads theBUNDLE_IDof aGoogleService-Info.plistfile, asgetFirebaseProjects(File)reads itsPROJECT_ID.static LinkedHashMap<String, String> getFirebaseProjects(File dir) static LinkedHashMap<String, String> getLanguageStringsMap(File file) Gets the English language strings required in "msg.js".
Field Details
PLATFORM_ANDROID
The Cordova platform ID of Android, the key of its project inizRun.FCM_PROJECT.- See Also:
PLATFORM_IOS
The Cordova platform ID of iOS, the key of its project inizRun.FCM_PROJECT.- See Also:
FIREBASE_ANDROID_CONFIG_FILE_NAME
The file name of the Android Firebase configuration.- See Also:
FIREBASE_IOS_CONFIG_FILE_NAME
The file name of the iOS Firebase configuration.- See Also:
Constructor Details
RuntimeBuilderUtilities
public RuntimeBuilderUtilities()
Method Details
getLanguageStringsMap
public static LinkedHashMap<String,String> getLanguageStringsMap(File file) throws FileNotFoundException, IOException Gets the English language strings required in "msg.js".The file is a JavaScript object literal, NOT JSON: the keys are unquoted identifiers, the values are single-quoted strings, and
//comments separate the groups. It used to be read by handing the whole file to a JavaScript engine, evaluating it and callingJSON.stringifyon the result -- that is, the engine performed the JavaScript to JSON conversion andJSONObjectonly parsed the outcome. That coupled the runtime builder to Nashorn throughGUnit.getScriptEngine(), a units class that has nothing to do with language strings, and it is parsed directly here instead.Non-string values are not represented. The result is a flat map of text ID to text, so a value that is not a string has nowhere to go. The only one that occurs is the nested
aobject thatCodeModifier.createSource_JS_Msgwrites into a GENERATED "msg.js", holding every non-default localisation: legitimate content that this consumer does not want. It is skipped. Any OTHER non-string shape throws rather than being dropped quietly, because a shape nobody has seen before is far more likely to be a mistake than an intended omission.That throw is deliberate. Do not soften it to a skip. Silently dropping an unrecognised value would lose a text ID with no signal anywhere -- no exception, no log line, and a text table that is quietly short of an entry. That is the exact failure class this method was rewritten to stop producing, so failing loudly on an unknown shape is the feature, not an oversight to be tidied away later.
Note that skipping it is a widening: the previous implementation could not read a generated "msg.js" at all. Such a file is a single line, so the
window.izRun.M=substitution the old code relied on never matched, and evaluatingwindow.izRun.M=...in an engine with no browser globals failed onwindowbefore the nested object was ever reached.- Parameters:
file- The "msg.js" file.- Returns:
- A new map of the strings, key is the text ID and the value is the text, in file order -- the order is observable, as it becomes the order of a generated text table.
- Throws:
FileNotFoundException- If thefileis not found.IOException- For file errors, or if the file is not the singlewindow.izRun.Massignment the format requires.
getFirebaseProjects
Gets the Firebase project of each platform the app in a directory is built with: theproject_info.project_idofgoogle-services.jsonfor "android" and thePROJECT_IDofGoogleService-Info.plistfor "ios". The runtime builder writes the result intosetup.jsasizRun.FCM_PROJECT, whichcommon/push/pushdev.jsreports beside the device's FCM token so that the server can refuse a row the token could never serve (CC-PUSH-ROADMAP row 4 A, CC-FIX-PUSHDEV-PROJECT). FirebaseX tells no project at run time, and a copy kept by hand drifts from these files, which are the ones FirebaseX registers the token with.A file that is absent gives no entry: Firebase is optional. A file that is present but unreadable, or that names no project, throws: the app would be built with a configuration nothing can tell the project of, and a build that goes on would ship devices reporting none. The two projects may differ (Firebase allows one app per platform in different projects); that is logged as a warning, since the application's Push configuration names one project and the other platform's devices will be refused.
Only the project ID is read. Nothing else in either file - the API key among them - is returned or logged.
- Parameters:
dir- The directory holding the files: the Cordova app directory of the build.- Returns:
- A new map of Cordova platform ID to project ID, Android first, empty when neither file is present.
- Throws:
IOException- If a file is present but cannot be read or parsed, or names no project.
getFirebaseAndroidPackageNames
Reads the package names of agoogle-services.jsonfile: everyclient[].client_info.android_client_info.package_name, in file order, trimmed. The Builder refuses an Android App ID the file does not name, as Gradle fails late with "No matching client found for package name" otherwise (CC-FIX-BUILDER-PREFLIGHT). Nothing else of the file - the API key among them - is returned or logged.- Parameters:
file- The file.- Returns:
- The package names, at least one.
- Throws:
IOException- If the file cannot be read or parsed, or names no package.
getFirebaseIOSBundleID
Reads theBUNDLE_IDof aGoogleService-Info.plistfile, asgetFirebaseProjects(File)reads itsPROJECT_ID. The Builder refuses an iOS App ID that is not this bundle ID (CC-FIX-BUILDER-PREFLIGHT).- Parameters:
file- The file.- Returns:
- The bundle ID, trimmed.
- Throws:
IOException- If the file cannot be read or parsed, or names no bundle ID.