<commit_before>#!/usr/bin/env node
(function(require, console) {
  var
    fs = require('fs'),
    moment = require('moment'),
    path = require('path'),
    et = require('elementtree'),
    plist = require('plist'),
    shell = require('shelljs'),
    projectRootDir = path.resolve(__dirname, '..', '..', '..'),
    projectConfigFilePath = path.join(projectRootDir,
                                      'custom', 'brand', 'project_config.json'),
    projectConfig = require(projectConfigFilePath),
    genericConfigFile = path.join(
      projectRootDir,
      'config.xml'
    ),
    iOSConfigFilePath = path.join(
        projectRootDir,
        'platforms',
        'ios',
        projectConfig.projectName
    ),
    iOSConfigXMLFilePath = path.join(
        projectRootDir,
        'platforms',
        'ios',
        projectConfig.projectName,
        'config.xml'
    ),
    androidConfigFilePath = path.join(
        projectRootDir,
        'platforms',
        'android'
    ),
    androidConfigXMLFilePath = path.join(
        projectRootDir,
        'platforms',
        'android',
        'res',
        'xml',
        'config.xml'
    ),
    version = shell.exec('git describe --tags', {silent:true}).output.trim();
  var etSubElement = et.SubElement;

  var displayName = projectConfig.projectName;
  if (projectConfig.displayName) {
    displayName = projectConfig.displayName;
  }
  var shortDisplayName = projectConfig.projectName;
  if (projectConfig.shortDisplayName) {
    shortDisplayName = projectConfig.shortDisplayName;
  }

  if (fs.existsSync(iOSConfigFilePath)) {
    var plistFile = path.join(iOSConfigFilePath, projectConfig.projectName + '-Info.plist');
    var infoPlist = plist.parseFileSync(plistFile);
    var config = new et.ElementTree(
      et.XML(
        fs.readFileSync(genericConfigFile, 'utf-8')
      )
    );
    var package = config.getroot().attrib.id.split(".");
    package.pop();
    package.push(projectConfig.projectName);
    infoPlist['CFBundleIdentifier'] = package.join(".");
    infoPlist['CFBundleVersion'] = moment().format('YYYYMMDDkkmm');
    infoPlist['CFBundleShortVersionString'] = version;
    infoPlist['CFBundleDisplayName'] = shortDisplayName;
    var info_contents = plist.build(infoPlist);
    info_contents = info_contents.replace(/<string>[\s\r\n]*<\/string>/g,'<string></string>');
    fs.writeFileSync(plistFile, info_contents, 'utf-8');
    var configXML = new et.ElementTree(
      et.XML(
        fs.readFileSync(iOSConfigXMLFilePath, 'utf-8')
      )
    );
    configXML.getroot().attrib.version = version;
    fs.writeFileSync(
      iOSConfigXMLFilePath, configXML.write({indent: 4}), 'utf-8'
    );
  }

  if (fs.existsSync(androidConfigFilePath)) {
    var doc = new et.ElementTree(
      et.XML(
        fs.readFileSync(path.join(androidConfigFilePath, 'AndroidManifest.xml'), 'utf-8')<commit_msg>Grab iOS app ID from config instead of parsing package.json.<commit_after>#!/usr/bin/env node
(function(require, console) {
  var
    fs = require('fs'),
    moment = require('moment'),
    path = require('path'),
    et = require('elementtree'),
    plist = require('plist'),
    shell = require('shelljs'),
    projectRootDir = path.resolve(__dirname, '..', '..', '..'),
    projectConfigFilePath = path.join(projectRootDir,
                                      'custom', 'brand', 'project_config.json'),
    projectConfig = require(projectConfigFilePath),
    genericConfigFile = path.join(
      projectRootDir,
      'config.xml'
    ),
    iOSConfigFilePath = path.join(
        projectRootDir,
        'platforms',
        'ios',
        projectConfig.projectName
    ),
    iOSConfigXMLFilePath = path.join(
        projectRootDir,
        'platforms',
        'ios',
        projectConfig.projectName,
        'config.xml'
    ),
    androidConfigFilePath = path.join(
        projectRootDir,
        'platforms',
        'android'
    ),
    androidConfigXMLFilePath = path.join(
        projectRootDir,
        'platforms',
        'android',
        'res',
        'xml',
        'config.xml'
    ),
    version = shell.exec('git describe --tags', {silent:true}).output.trim();
  var etSubElement = et.SubElement;

  var displayName = projectConfig.projectName;
  if (projectConfig.displayName) {
    displayName = projectConfig.displayName;
  }
  var shortDisplayName = projectConfig.projectName;
  if (projectConfig.shortDisplayName) {
    shortDisplayName = projectConfig.shortDisplayName;
  }

  if (fs.existsSync(iOSConfigFilePath)) {
    var plistFile = path.join(iOSConfigFilePath, projectConfig.projectName + '-Info.plist');
    var infoPlist = plist.parseFileSync(plistFile);
    var config = new et.ElementTree(
      et.XML(
        fs.readFileSync(genericConfigFile, 'utf-8')
      )
    );
    var package = config.getroot().attrib.id.split(".");
    package.pop();
    package.push(projectConfig.projectName);
    infoPlist['CFBundleIdentifier'] = projectConfig.iosIdentifier;
    infoPlist['CFBundleVersion'] = moment().format('YYYYMMDDkkmm');
    infoPlist['CFBundleShortVersionString'] = version;
    infoPlist['CFBundleDisplayName'] = shortDisplayName;
    var info_contents = plist.build(infoPlist);
    info_contents = info_contents.replace(/<string>[\s\r\n]*<\/string>/g,'<string></string>');
    fs.writeFileSync(plistFile, info_contents, 'utf-8');
    var configXML = new et.ElementTree(
      et.XML(
        fs.readFileSync(iOSConfigXMLFilePath, 'utf-8')
      )
    );
    configXML.getroot().attrib.version = version;
    fs.writeFileSync(
      iOSConfigXMLFilePath, configXML.write({indent: 4}), 'utf-8'
    );
  }

  if (fs.existsSync(androidConfigFilePath)) {
    var doc = new et.ElementTree(
      et.XML(
        fs.readFileSync(path.join(androidConfigFilePath, 'AndroidManifest.xml'), 'utf-8')
{'fraction_non_alphanumeric': 0.1375107296137339, 'fraction_numerical': 0.0020600858369098714, 'mean_word_length': 2.9876796714579057, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1353096', 'n_tokens_mistral': 1769, 'n_tokens_neox': 1741, 'n_words': 288}