Class RuntimeBuilderUtilities

java.lang.Object
com.iizix.run.RuntimeBuilderUtilities

public class RuntimeBuilderUtilities extends Object
  • Field Details

    • PLATFORM_ANDROID

      public static final String PLATFORM_ANDROID
      The Cordova platform ID of Android, the key of its project in izRun.FCM_PROJECT.
      See Also:
    • PLATFORM_IOS

      public static final String PLATFORM_IOS
      The Cordova platform ID of iOS, the key of its project in izRun.FCM_PROJECT.
      See Also:
    • FIREBASE_ANDROID_CONFIG_FILE_NAME

      public static final String FIREBASE_ANDROID_CONFIG_FILE_NAME
      The file name of the Android Firebase configuration.
      See Also:
    • FIREBASE_IOS_CONFIG_FILE_NAME

      public static final String 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 calling JSON.stringify on the result -- that is, the engine performed the JavaScript to JSON conversion and JSONObject only parsed the outcome. That coupled the runtime builder to Nashorn through GUnit.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 a object that CodeModifier.createSource_JS_Msg writes 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 evaluating window.izRun.M=... in an engine with no browser globals failed on window before 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 the file is not found.
      IOException - For file errors, or if the file is not the single window.izRun.M assignment the format requires.
    • getFirebaseProjects

      public static LinkedHashMap<String,String> getFirebaseProjects(File dir) throws IOException
      Gets the Firebase project of each platform the app in a directory is built with: the project_info.project_id of google-services.json for "android" and the PROJECT_ID of GoogleService-Info.plist for "ios". The runtime builder writes the result into setup.js as izRun.FCM_PROJECT, which common/push/pushdev.js reports 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

      public static List<String> getFirebaseAndroidPackageNames(File file) throws IOException
      Reads the package names of a google-services.json file: every client[].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

      public static String getFirebaseIOSBundleID(File file) throws IOException
      Reads the BUNDLE_ID of a GoogleService-Info.plist file, as getFirebaseProjects(File) reads its PROJECT_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.