How to use the plist.parseFileSync function in plist

To help you get started, we’ve selected a few plist examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apache / cordova-lib / test / ios-plist-install.js View on Github external
exports['should edit PhoneGap.plist'] = function (test) {
    // run the platform-specific function
    ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });

    var plistPath = test_project_dir + '/SampleApp/PhoneGap.plist';
    var obj = plist.parseFileSync(plistPath);

    test.equal(obj.Plugins['com.phonegap.plugins.childbrowser'],
        'ChildBrowserCommand');
        
    test.equal(obj.ExternalHosts.length, 2)    
    test.equal(obj.ExternalHosts[0], "build.phonegap.com")
    test.equal(obj.ExternalHosts[1], "12345.s3.amazonaws.com")

    test.done();
}
github rev087 / ng-inspector / gulpfile.js View on Github external
run('git', ['diff', '--staged'], function(res) {
		if (res.length > 0) {
			return console.error('\n ' + ' BUMP ERROR '.redBG.bold.black +
				' Cannot update manifests with a dirty Git stage. \n'.red);
		}

		// Bump the version in package.json
		var pkg = require('./package.json');
		var old = pkg.version;
		pkg.version = 'v' + semver.inc(pkg.version, release);
		var pkgStr = JSON.stringify(pkg, null, 2);
		fs.writeFileSync('package.json', pkgStr);

		// Bump the version in Info.plist
		var info = plist.parseFileSync('ng-inspector.safariextension/Info.plist');
		info.CFBundleShortVersionString = pkg.version;
		info.CFBundleVersion = pkg.version;
		var plistStr = plist.build(info).toString();
		fs.writeFileSync('ng-inspector.safariextension/Info.plist', plistStr);

		// Bump the version in manifest.json
		var manifest = require('./ng-inspector.chrome/manifest.json');
		manifest.version = semver.inc(manifest.version, release);
		var manifestStr = JSON.stringify(manifest, null, 2);
		fs.writeFileSync('./ng-inspector.chrome/manifest.json', manifestStr);

		// Bump the version in manifest.json
		var ffpkg = require('./ng-inspector.firefox/package.json');
		ffpkg.version = semver.inc(fxpackage.version, release);
		var ffpkgString = JSON.stringify(fxpackage, null, 2);
		fs.writeFileSync('./ng-inspector.firefox/package.json', ffpkgString);
github apache / cordova-cli / src / metadata / ios_parser.js View on Github external
update_from_config:function(config, callback) {
        if (config instanceof config_parser) {
        } else {
            var err = new Error('update_from_config requires a config_parser object');
            if (callback) callback(err);
            else throw err;
            return;
        }
        var name = config.name();
        var pkg = config.packageName();

        // Update package id (bundle id)
        var plistFile = path.join(this.cordovaproj, this.originalName + '-Info.plist');
        var infoPlist = plist.parseFileSync(plistFile);
        infoPlist['CFBundleIdentifier'] = pkg;
        var info_contents = plist.build(infoPlist);
        info_contents = info_contents.replace(/[\s\r\n]*<\/string>/g,'');
        fs.writeFileSync(plistFile, info_contents, 'utf-8');
        events.emit('log', 'Wrote out iOS Bundle Identifier to "' + pkg + '"');

        // Update whitelist
        var self = this;
        this.config.access.remove();
        config.access.get().forEach(function(uri) {
            self.config.access.add(uri);
        });
        
        // Update preferences
        this.config.preference.remove();
        var prefs = config.preference.get();
github rev087 / ng-inspector / gulp / tasks / bump.js View on Github external
run('git', ['diff', '--staged'], function(res) {
		if (res.length > 0) {
			return console.error('\n ' + ' BUMP ERROR '.redBG.bold.black +
				' Cannot update manifests with a dirty Git stage. \n'.red);
		}

		// Bump the version in package.json
		var pkg = require('./package.json');
		var old = pkg.version;
		pkg.version = 'v' + semver.inc(pkg.version, release);
		var pkgStr = JSON.stringify(pkg, null, 2);
		fs.writeFileSync('package.json', pkgStr);

		// Bump the version in Info.plist
		var info = plist.parseFileSync(format('%s/Info.plist', config.safariDir));
		info.CFBundleShortVersionString = pkg.version;
		info.CFBundleVersion = pkg.version;
		var plistStr = plist.build(info).toString();
		fs.writeFileSync(format('%s/Info.plist', config.safariDir), plistStr);

		// Bump the version in manifest.json
		var manifest = require(format('./%s/manifest.json', config.chromeDir));
		manifest.version = semver.inc(manifest.version, release);
		var manifestStr = JSON.stringify(manifest, null, 2);
		fs.writeFileSync(format('./%s/manifest.json', config.chromeDir), manifestStr);

		// Bump the version in manifest.json
		var ffpkg = require(format('./%s/package.json', config.firefox));
		ffpkg.version = semver.inc(fxpackage.version, release);
		var ffpkgString = JSON.stringify(fxpackage, null, 2);
		fs.writeFileSync(format('./%s/package.json', config.firefoxDir), ffpkgString);
github MobileChromeApps / mobile-chrome-apps / node_modules / cordova / src / metadata / ios_parser.js View on Github external
update_from_config:function(config) {
        if (config instanceof config_parser) {
        } else {
            return Q.reject(new Error('update_from_config requires a config_parser object'));
        }
        var name = config.name();
        var pkg = config.packageName();
        var version = config.version();

        // Update package id (bundle id)
        var plistFile = path.join(this.cordovaproj, this.originalName + '-Info.plist');
        var infoPlist = plist.parseFileSync(plistFile);
        infoPlist['CFBundleIdentifier'] = pkg;

        // Update version (bundle version)
        infoPlist['CFBundleVersion'] = version;
        var info_contents = plist.build(infoPlist);
        info_contents = info_contents.replace(/[\s\r\n]*<\/string>/g,'');
        fs.writeFileSync(plistFile, info_contents, 'utf-8');
        events.emit('verbose', 'Wrote out iOS Bundle Identifier to "' + pkg + '"');
        events.emit('verbose', 'Wrote out iOS Bundle Version to "' + version + '"');

        if (name != this.originalName) {
            // Update product name inside pbxproj file
            var proj = new xcode.project(this.pbxproj);
            var parser = this;
            var d = Q.defer();
            proj.parse(function(err,hash) {
github nwjs / grunt-nw-builder / tasks / lib / utils.js View on Github external
exports.generatePlist = function(abspath, target_filename, options, appOptions) {

        // Handle the INfo.plist file
        var info = plist.parseFileSync(abspath);
        info.CFBundleDisplayName = options.app_name;
        info.CFBundleName = options.app_name;

        info.CFBundleDocumentTypes = []; // zero out any document binding
        info.UTExportedTypeDeclarations = [];

        info.CFBundleVersion = options.app_version; // TODO: if git, get commit hash!
        info.CFBundleShortVersionString = 'Version ' + options.app_version;

        if(appOptions.copyright) {
          info.NSHumanReadableCopyright = appOptions.copyright;
        }

        grunt.file.write(target_filename, plist.build(info));
    };
github mozilla / i18n-abide / lib / i18n.js View on Github external
function parse_messages_file(locale) {
    var filepath = messages_file_path(locale);

    if (options.translation_type === 'plist') {
      return plist.parseFileSync(filepath);
    }
    else if (options.translation_type === 'key-value-json') {
      return require(filepath);
    }
    // PO->json file
    else {
      var rawMessages = fs.readFileSync(filepath).toString();
      return JSON.parse(rawMessages).messages;
    }
  }
github SpiderOak / SpiderOakMobileClient / .cordova / hooks / after_prepare / version.js View on Github external
),
    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(/[\s\r\n]*<\/string>/g,'');
    fs.writeFileSync(plistFile, info_contents, 'utf-8');
    var configXML = new et.ElementTree(
github appium / appium / lib / devices / ios / ios.js View on Github external
var xmlPlistFile = function (filename, callback) {
  try {
    var result = xmlplist.parseFileSync(filename);
    return callback(null, result);
  } catch (ex) {
    return callback(ex);
  }
};

plist

Apple's property list parser/builder for Node.js and browsers

MIT
Latest version published 10 months ago

Package Health Score

77 / 100
Full package analysis