function prunePLIST(doc, xml, selector) {
    var obj = plist.parse('<plist>'+xml+'</plist>');

    pruneOBJECT(doc, selector, obj);

    return true;
}
Example #2
0
        return new Promise(function(resolve, reject) {
            if(!options.appName || !options.appVersion) {
                return reject('You have to set the appName and appVersion in the Plist options');
            }

            // Handle the INfo.plist file
            var info = plist.parse(fs.readFileSync(plistInput, 'utf8'));
            info.CFBundleDisplayName = options.appName;
            info.CFBundleName = options.appName;
            info.CFBundleVersion = options.appVersion;
            info.CFBundleShortVersionString = 'Version ' + options.appVersion;
            if(options.copyright) {
              info.NSHumanReadableCopyright = options.copyright;
            }
            if(options.mac_bundle_id) {
                info.CFBundleIdentifier = options.mac_bundle_id;
            }
            if(options.mac_document_types) {
                info.CFBundleDocumentTypes = options.mac_document_types.map(function(type) {
                    return {
                        CFBundleTypeName: type.name,
                        CFBundleTypeExtensions: type.extensions,
                        CFBundleTypeRole: type.role,
                        LSIsAppleDefaultForType: type.isDefault
                    };
                });
            } else {
                info.CFBundleDocumentTypes = [];
            }

            info.UTExportedTypeDeclarations = [];
            fs.writeFileSync(plistOutput, plist.build(info));
            resolve();
        });
    function updatePlist(settings) {
        var defer = q.defer(),
            plistPath = path.resolve(
                settings.basePath,
                'platforms',
                'ios',
                settings.appName,
                settings.appName + '-Info.plist'
            ),
            plistObj;
        if (!grunt.file.exists(plistPath)) {
            grunt.log.error(['Failed to find plist file for phonegap project.'],
                            ['Skipping plist update.'].join(' '));
            defer.resolve();
            return;
        }

        plistObj = plist.parse(grunt.file.read(plistPath, {encoding: 'utf8'}));

        //if the appUrlScheme is defined, update the plist file to include changes
        if (settings.appUrlScheme) {
            plistObj =
                updatePlistURLTypes(settings.appId, settings.appUrlScheme, plistObj);

            grunt.file.write(plistPath, plist.build(plistObj), {encoding: 'utf8'});
        }

        defer.resolve();
        return defer.promise;
    }
Example #4
0
 this.client_.get('/playback-info', function(res) {
   if (res) {
     plist.parse(res.body, function(err, obj) {
       var el = obj[0];
       var result = {
         duration: el.duration,
         position: el.position,
         rate: el.rate,
         playbackBufferEmpty: el.playbackBufferEmpty,
         playbackBufferFull: el.playbackBufferFull,
         playbackLikelyToKeepUp: el.playbackLikelyToKeepUp,
         readyToPlay: el.readyToPlay,
         loadedTimeRanges: el.loadedTimeRanges,
         seekableTimeRanges: el.seekableTimeRanges
       };
       if (callback) {
         callback(result);
       }
     });
   } else {
     if (callback) {
       callback(null);
     }
   }
 });
Example #5
0
function ConfigFile_load() {
    var self = this;

    // config file may be in a place not exactly specified in the target
    var filepath = self.filepath = resolveConfigFilePath(self.project_dir, self.platform, self.file_tag);

    if ( !filepath || !fs.existsSync(filepath) ) {
        self.exists = false;
        return;
    }
    self.exists = true;
    var ext = path.extname(filepath);
    // Windows8 uses an appxmanifest, and wp8 will likely use
    // the same in a future release
    if (ext == '.xml' || ext == '.appxmanifest') {
        self.type = 'xml';
        self.data = xml_helpers.parseElementtreeSync(filepath);
    } else if (ext == '.pbxproj') {
        self.type = 'pbxproj';
        self.data = xcode.project(filepath).parseSync();
        self.cordovaVersion = fs.readFileSync(path.join(self.project_dir, 'CordovaLib', 'VERSION'), 'utf8').trim();
    } else {
        // plist file
        self.type = 'plist';
        // TODO: isBinaryPlist() reads the file and then parse re-reads it again.
        //       We always write out text plist, not binary.
        //       Do we still need to support binary plist?
        //       If yes, use plist.parseStringSync() and read the file once.
        self.data = isBinaryPlist(filepath) ?
                bplist.parseBuffer(fs.readFileSync(filepath)) :
                plist.parse(fs.readFileSync(filepath, 'utf8'));
    }
}
Example #6
0
exports.readFileSync = function(aFile) {
	var results,
		contents = fs.readFileSync(aFile),
		firstByte = contents[0];

	if (contents.length === 0) {
		console.error("Unable to read file '%s'", aFile);
		return {};
	}

	try {
		if (firstByte === 60) {
			results = plist.parse(contents.toString());
		}
		else if (firstByte === 98) {
			results = bplistParser.parseBuffer(contents)[0];
		}
		else {
			console.error("Unable to determine format for '%s'", aFile);
			results = {};
		}
	}
	catch(e) {
		throw Error("'%s' has errors", aFile);
	}
	return results;
};
Example #7
0
  unzipper.on('extract', function() {
    var path = glob.sync(output.path + '/Payload/*/')[0];

    data.metadata = plist.parse(fs.readFileSync(path + 'Info.plist', 'utf8'));

    if(!fs.existsSync(path + 'embedded.mobileprovision') || !which.sync('security')){
      return cleanUp();
    }
    exec('security cms -D -i embedded.mobileprovision > ' + provisionFilename, { cwd: path }, function(error) {
      if(error){
        cleanUp(error);
      }

      data.provisioning = plist.parse(fs.readFileSync(path + provisionFilename, 'utf8'));
      delete data.provisioning.DeveloperCertificates;

      if(!which.sync('codesign')){
        return cleanUp();
      }

      exec('codesign -d --entitlements :- ' + path, function(error, output) {
        data.entitlements = plist.parse(output);

        return cleanUp();
      });
    });
  });
Example #8
0
function postDarwinism () {
  var plist = require('plist')
  var contentsPath = path.join.apply(null, [
    __dirname,
    '..',
    'dist',
    `${config.APP_NAME}-darwin-x64`,
    `${config.APP_NAME}.app`,
    'Contents'
  ])
  var resourcesPath = path.join(contentsPath, 'Resources')
  var infoPlistPath = path.join(contentsPath, 'Info.plist')
  var webTorrentFileIconPath = path.join.apply(null, [
    __dirname,
    '..',
    'static',
    'WebTorrentFile.icns'
  ])
  var infoPlist = plist.parse(fs.readFileSync(infoPlistPath).toString())

  infoPlist['CFBundleDocumentTypes'] = [{
    CFBundleTypeExtensions: [ 'torrent' ],
    CFBundleTypeName: 'BitTorrent Document',
    CFBundleTypeRole: 'Editor',
    CFBundleTypeIconFile: 'WebTorrentFile.icns'
  }]

  fs.writeFileSync(infoPlistPath, plist.build(infoPlist))
  cp.execSync(`cp ${webTorrentFileIconPath} ${resourcesPath}`)
}
Example #9
0
	return download.toString(contentPath).then(function (content) {
		var ext = path.extname(repoPath);
		var grammar;
		if (ext === '.tmLanguage' || ext === '.plist') {
			grammar = plist.parse(content);
		} else if (ext === '.cson') {
			grammar = cson.parse(content);
		} else if (ext === '.json') {
			grammar = JSON.parse(content);
		} else {
			console.error('Unknown file extension: ' + ext);
			return;
		}
		if (modifyGrammar) {
			modifyGrammar(grammar);
		}
		return getCommitSha(repoId, repoPath).then(function (info) {
			if (info) {
				grammar.version = 'https://github.com/' + repoId + '/commit/' + info.commitSha;
			}
			try {
				fs.writeFileSync(dest, JSON.stringify(grammar, null, '\t'));
				if (info) {
					console.log('Updated ' + path.basename(dest) + ' to ' + repoId + '@' + info.commitSha.substr(0, 7) + ' (' + info.commitDate.substr(0, 10) + ')');
				} else {
					console.log('Updated ' + path.basename(dest));
				}
			} catch (e) {
				console.error(e);
			}
		});

	}, console.error);
Example #10
0
		f.contents.on('end', function () {
			var infoPlist = plist.parse(contents.toString('utf8'));
			var match = /\.helper\.([^.]+)$/.exec(infoPlist['CFBundleIdentifier'] || '');
			var suffix = match ? match[1] : '';

			if (opts.darwinBundleIdentifier) {
				infoPlist['CFBundleIdentifier'] = opts.darwinBundleIdentifier + '.helper';

				if (suffix) {
					infoPlist['CFBundleIdentifier'] += '.' + suffix;
				}
			}

			infoPlist['CFBundleName'] = opts.productName + ' Helper';
			if (suffix) {
				infoPlist['CFBundleName'] += ' ' + suffix;
			}

			if (infoPlist['CFBundleDisplayName']) {
				infoPlist['CFBundleDisplayName'] = infoPlist['CFBundleName'];
			}

			if (infoPlist['CFBundleExecutable']) {
				infoPlist['CFBundleExecutable'] = infoPlist['CFBundleName'];
			}

			f.contents = new Buffer(plist.build(infoPlist), 'utf8');
			that.emit('data', f);
		});
Example #11
0
async function getConnectedDevices () {

  const cmd = '/usr/sbin/system_profiler';
  const args = ['-xml', 'SPUSBDataType'];
  let {stdout} = await exec(cmd, args, {timeout: XCODE_SELECT_TIMEOUT});
  let plistContent = parsePlistData(stdout);

  let devicesFound = [];
  let entriesToSearch = [plistContent[0]];
  while (entriesToSearch.length > 0) {
    let currentEntry = entriesToSearch.pop();
    if (currentEntry instanceof Array) {
      entriesToSearch = entriesToSearch.concat(currentEntry);
    } else if ((currentEntry._name &&
                currentEntry._name.substring(0, 4) === "iPad") ||
               (currentEntry._name &&
                currentEntry._name.substring(0, 6) === "iPhone")) {
      let deviceInfo = {
        name: currentEntry._name,
        udid: currentEntry.serial_num,
        productId: currentEntry.product_id,
        deviceVersion: currentEntry.bcd_device
      };
      devicesFound.push(deviceInfo);
    } else if (currentEntry._items) {
      entriesToSearch = entriesToSearch.concat(currentEntry._items);
    }
  }
  return devicesFound;
}
Example #12
0
 .then(function(pContents) {
   pContents = plist.parse(pContents);
   pContents.CFBundleDisplayName = displayName.trim();
   pContents.CFBundleName = displayName.trim();
   pContents.CFBundleIdentifier = opts.appId.trim();
   return fs.writeFileAsync(pFile, plist.build(pContents));
 });
Example #13
0
  this._extractProfileData = function(profile) {
    this.provisions = this.provisions || {};
    profile = plist.parse(profile);

    var teamId = profile.Entitlements['com.apple.developer.team-identifier'],
        appId = profile.Entitlements['application-identifier'];

    appId = appId.replace(/^\w+\./, "");

    this.provisions[appId] = {
      name: profile.Name,
      date: profile.CreationDate,
      uuid: profile.UUID,
      publicKeys: [],
      teamId: teamId
    };

    return Promise.resolve(profile.DeveloperCertificates).bind(this)
      .each(function(cert) {
        return Security.pemToPub('echo ' + this._certToPem(cert)).bind(this)
        .then(function(pub) {
          this.provisions[appId].publicKeys.push(pub);
        });
      })
      .then(function() {
        return this.provisions[appId];
      });
  };
Example #14
0
/**
 * Updates project structure and AndroidManifest according to project's configuration.
 *
 * @param   {ConfigParser}  platformConfig  A project's configuration that will
 *   be used to update project
 * @param   {Object}  locations       A map of locations for this platform (In/Out)
 */
function updateProject(platformConfig, locations) {

    // CB-6992 it is necessary to normalize characters
    // because node and shell scripts handles unicode symbols differently
    // We need to normalize the name to NFD form since iOS uses NFD unicode form
    var name = unorm.nfd(platformConfig.name());
    var pkg = platformConfig.getAttribute('ios-CFBundleIdentifier') || platformConfig.packageName();
    var version = platformConfig.version();

    var originalName = path.basename(locations.xcodeCordovaProj);

    // Update package id (bundle id)
    var plistFile = path.join(locations.xcodeCordovaProj, originalName + '-Info.plist');
    var infoPlist = plist.parse(fs.readFileSync(plistFile, 'utf8'));
    infoPlist['CFBundleIdentifier'] = pkg;

    // Update version (bundle version)
    infoPlist['CFBundleShortVersionString'] = version;
    var CFBundleVersion = platformConfig.getAttribute('ios-CFBundleVersion') || default_CFBundleVersion(version);
    infoPlist['CFBundleVersion'] = CFBundleVersion;

    if (platformConfig.getAttribute('defaultlocale')) {
        infoPlist['CFBundleDevelopmentRegion'] = platformConfig.getAttribute('defaultlocale');
    }

    // replace Info.plist ATS entries according to <access> and <allow-navigation> config.xml entries
    var ats = writeATSEntries(platformConfig);
    if (Object.keys(ats).length > 0) {
        infoPlist['NSAppTransportSecurity'] = ats;
    } else {
        delete infoPlist['NSAppTransportSecurity'];
    }

    handleOrientationSettings(platformConfig, infoPlist);
    updateProjectPlistForLaunchStoryboard(platformConfig, infoPlist);

    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');
    events.emit('verbose', 'Wrote out iOS Bundle Identifier "' + pkg + '" and iOS Bundle Version "' + version + '" to ' + plistFile);

    return handleBuildSettings(platformConfig, locations).then(function() {
        if (name == originalName) {
            events.emit('verbose', 'iOS Product Name has not changed (still "' + originalName + '")');
            return Q();
        } else { // CB-11712 <name> was changed, we don't support it'
            var errorString = 
            'The product name change (<name> tag) in config.xml is not supported dynamically.\n' +
            'To change your product name, you have to remove, then add your ios platform again.\n' +
            'Make sure you save your plugins beforehand using `cordova plugin save`.\n' +
            '\tcordova plugin save\n' +
            '\tcordova platform rm ios\n' +
            '\tcordova platform add ios\n'
            ;

            return Q.reject(new CordovaError(errorString));
        }
    });
}
 }, function (file, cb) {
   var obj = plist.parse(file)
   t.equal(obj.CFBundleVersion, '' + opts['build-version'], 'CFBundleVersion should reflect build-version')
   t.equal(obj.CFBundleShortVersionString, '' + opts['app-version'], 'CFBundleShortVersionString should reflect app-version')
   t.equal(typeof obj.CFBundleVersion, 'string', 'CFBundleVersion should be a string')
   t.equal(typeof obj.CFBundleShortVersionString, 'string', 'CFBundleShortVersionString should be a string')
   cb()
 }
Example #16
0
exports.parseVersionByPlist = function(plPath, key, cb) {
  if (!fs.existsSync(plPath)) {
    cb(null)
  } else {
    var data = plist.parse(fs.readFileSync(plPath, 'utf8'))
    cb(data[key])
  }
}
Example #17
0
    it('decodes base64 certificate', function() {
      var data = readFile('test/fixtures/profile.mobileprovision', {encoding: 'utf8'}),
          profile = plist.parse(data);

      return expect(MobileProvision._certToPem(profile.DeveloperCertificates[0]))
        .to.match(/BEGIN CERTIFICATE/)
        .and.to.match(/END CERTIFICATE/);
    });
Example #18
0
 it('sets the correct CFBundleIdentifier', function() {
   if (target.platform !== 'darwin') {
     return this.skip();
   }
   const info = target.dest(`${target.productName}-darwin-x64`, `${target.productName}.app`, 'Contents', 'Info.plist');
   const config = plist.parse(fs.readFileSync(info, 'utf8'));
   assert.equal(config.CFBundleIdentifier, 'com.mongodb.hadron-testing.beta');
 });
            _.each(configItems, function (item) {
                var key = item.parent;
                var plistXml = '<plist><dict><key>' + key + '</key>';
                plistXml += platformConfig.eltreeToXmlString(item.data) + '</dict></plist>';

                var configPlistObj = plist.parse(plistXml);
                infoPlist[key] = configPlistObj[key];
            });
Example #20
0
 }).forEach(function(filename) {
     var infoPListFile = path.join(configFolder, filename);
     var data = plist.parse(fs.readFileSync(infoPListFile, 'utf-8'));
     data.NSAppTransportSecurity = {
         NSAllowsArbitraryLoads: true
     };
     fs.writeFileSync(infoPListFile, plist.build(data));
 });
Example #21
0
gulp.task('modify-plist', ['electron-pack'], (callback) => {
  const info = plist.parse(fs.readFileSync(paths.plist, 'utf8'))
  info.NSAppTransportSecurity = {
    NSAllowsArbitraryLoads: true
  }
  info.LSMinimumSystemVersion = "10.9.0"
  fs.writeFileSync(paths.plist, plist.build(info))
  return callback()
})
Example #22
0
/**
 * Returns Info.plist located in the iOS project
 *
 * Returns `null` if INFOPLIST_FILE is not specified.
 */
export default function getPlist(project, sourceDir) {
  const plistPath = getPlistPath(project, sourceDir);

  if (!plistPath || !fs.existsSync(plistPath)) {
    return null;
  }

  return plistParser.parse(fs.readFileSync(plistPath, 'utf-8'));
}
Example #23
0
    it('is a valid certificate', function() {
      var data = readFile('test/fixtures/profile.mobileprovision', {encoding: 'utf8'}),
          profile = plist.parse(data),
          cert = MobileProvision._certToPem(profile.DeveloperCertificates[0]);

      return expect(Security.pemToPub('echo ' + cert))
        .to.eventually.match(/BEGIN PUBLIC KEY/)
        .and.eventually.to.match(/END PUBLIC KEY/);
    });
Example #24
0
            }, (err, data) => {

                if(err) {
                    return cb.expect(2)(err);
                }

                cb.expect(2)(null, plist.parse(data.toString()));

            });
Example #25
0
	plist: function(data, callback) {
		try {
			data = plist(data);
			callback(null, data);
		}
		catch(e) {
			ok = false;
			callback(e.stack || e);
		}
	}
 .then(function (result) {
   var provisioningProfile = new ProvisioningProfile(filePath, plist.parse(result))
   debuglog('Provisioning profile:', '\n',
     '> Name:', provisioningProfile.name, '\n',
     '> Platforms:', provisioningProfile.platforms, '\n',
     '> Type:', provisioningProfile.type, '\n',
     '> Path:', provisioningProfile.filePath, '\n',
     '> Message:', provisioningProfile.message)
   return provisioningProfile
 })
Example #27
0
 }, function (file, cb) {
   t.deepEqual(plist.parse(file).CFBundleURLTypes, [{
     CFBundleURLName: 'Foo',
     CFBundleURLSchemes: ['foo']
   }, {
     CFBundleURLName: 'Bar',
     CFBundleURLSchemes: ['bar', 'baz']
   }], 'CFBundleURLTypes did not contain specified protocol schemes and names')
   cb()
 }
Example #28
0
 }, (file, cb) => {
   let obj = plist.parse(file)
   t.equal(typeof obj.CFBundleDisplayName, 'string', 'CFBundleDisplayName should be a string')
   t.equal(obj.CFBundleDisplayName, opts.name, 'CFBundleDisplayName should reflect opts.name')
   t.equal(typeof obj.CFBundleName, 'string', 'CFBundleName should be a string')
   t.equal(obj.CFBundleName, expectedSanitizedName, 'CFBundleName should reflect a sanitized opts.name')
   t.equal(typeof obj.CFBundleIdentifier, 'string', 'CFBundleIdentifier should be a string')
   t.equal(/^[a-zA-Z0-9-.]*$/.test(obj.CFBundleIdentifier), true, 'CFBundleIdentifier should allow only alphanumeric (A-Z,a-z,0-9), hyphen (-), and period (.)')
   t.equal(obj.CFBundleIdentifier, appBundleIdentifier, 'CFBundleIdentifier should reflect the sanitized opts.name')
   cb()
 }
 }, function (file, cb) {
   var obj = plist.parse(file)
   t.equal(obj.CFBundleDisplayName, opts.name, 'CFBundleDisplayName should reflect opts.name')
   t.equal(obj.CFBundleName, opts.name, 'CFBundleName should reflect opts.name')
   t.equal(obj.CFBundleIdentifier, appBundleIdentifier, 'CFBundleName should reflect opts["app-bundle-id"] or fallback to default')
   t.equal(typeof obj.CFBundleDisplayName, 'string', 'CFBundleDisplayName should be a string')
   t.equal(typeof obj.CFBundleName, 'string', 'CFBundleName should be a string')
   t.equal(typeof obj.CFBundleIdentifier, 'string', 'CFBundleIdentifier should be a string')
   t.equal(/^[a-zA-Z0-9-.]*$/.test(obj.CFBundleIdentifier), true, 'CFBundleIdentifier should allow only alphanumeric (A-Z,a-z,0-9), hyphen (-), and period (.)')
   cb()
 }
 }, function (file, cb) {
   var obj = plist.parse(file)
   t.equal(obj.CFBundleName, opts.name, 'CFBundleName should reflect opts.name in helper app')
   t.equal(obj.CFBundleIdentifier, helperBundleIdentifier, 'CFBundleName should reflect opts["helper-bundle-id"], opts["app-bundle-id"] or fallback to default in helper app')
   t.equal(typeof obj.CFBundleName, 'string', 'CFBundleName should be a string in helper app')
   t.equal(typeof obj.CFBundleIdentifier, 'string', 'CFBundleIdentifier should be a string in helper app')
   t.equal(/^[a-zA-Z0-9-.]*$/.test(obj.CFBundleIdentifier), true, 'CFBundleIdentifier should allow only alphanumeric (A-Z,a-z,0-9), hyphen (-), and period (.)')
   // check helper EH
   plistPath = path.join(tempPath, opts.name + '.app', 'Contents', 'Frameworks', opts.name + ' Helper EH.app', 'Contents', 'Info.plist')
   fs.stat(plistPath, cb)
 }, function (stats, cb) {