Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Object.keys(config_munge[file]).forEach(function(key) {
if (global_munge[file][key] && plistObj) {
// TODO: REMOVE in 3.4 (https://issues.apache.org/jira/browse/CB-4456)
require('../../plugman').emit('warn', 'DEPRECATION WARNING: Plugin "' + plugin_id + '" uses element(s), which are now deprecated. Support will be removed in Cordova 3.4.');
delete plistObj.Plugins[key];
// TODO: don't write out on every change, do it once.
fs.writeFileSync(plistfile, plist.build(plistObj));
delete global_munge[file][key];
}
});
}
// 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));
};
function injectIntoXml(alfredProjects) {
const plist = require('plist');
const fs = require('fs-extra');
const path = require('path');
fs.copySync(path.resolve(`${__dirname}/../info.plist`), `${__dirname}/../info.plist.generatebackup`);
const file = fs.readFileSync(`${__dirname}/../info.plist.generatebackup`, 'utf-8');
const plistJson = plist.parse(file);
plistJson.objects[1].config.items = JSON.stringify(alfredProjects);
fixedPlistJson = fixPlistLibraryNullKey(plistJson);
const updatedPlist = plist.build(fixedPlistJson)
fs.writeFileSync(`${__dirname}/../info.plist`, updatedPlist);
}
function performFirstPassReplacements() {
//Create base plist
var out = plist.build(plistBase);
//1st pass ensures values are 'real' as is required in Plist
out = replaceAll(replaceWithReal,realReplacement,out);
//Ensure real floating values are in 'LocationDeliveryBehavior'
var oldLocDel = "<" + realReplacement + ">" + LocDelBehaviorPlaceholder + "";
var newLocDel = "<" + realReplacement + ">" + LocationDeliveryBehavior + "";
out = out.replace(oldLocDel,newLocDel);
//Ensure real floating values are in 'LocationRepeatBehavior'
var oldLocRep = "<" + realReplacement + ">" + LocRepBehaviorPlaceholder + "";
var newLocRep = "<" + realReplacement + ">" + LocationRepeatBehavior + "";
out = out.replace(oldLocRep,newLocRep);
return out;
}
updateIosPlist: function (targetFile, configItems) {
var infoPlist = plist.parse(fs.readFileSync(targetFile, 'utf-8')),
tempInfoPlist;
_.each(configItems, function (item) {
var key = item.parent;
var plistXml = '' + key + '';
plistXml += platformConfig.eltreeToXmlString(item.data) + '';
var configPlistObj = plist.parse(plistXml);
infoPlist[key] = configPlistObj[key];
});
tempInfoPlist = plist.build(infoPlist);
tempInfoPlist = tempInfoPlist.replace(/[\s\r\n]*<\/string>/g,'');
fs.writeFileSync(targetFile, tempInfoPlist, 'utf-8');
}
};
items: [{
assets: [{
kind: "software-package",
url: content.OTAUrl || '',
}],
metadata: {
"bundle-identifier": content.CFBundleIdentifier || 'example',
"bundle-version": content.CFBundleShortVersionString || '1.0.0',
kind: "software",
title: content.CFBundleDisplayName || '未知'
}
}]
};
try {
plistContent = PList.build(plistJson);
FileUtil.touch(filePath, plistContent);
} catch (err) {
LogUtil.e(`${TAG} buildPList ${JSON.stringify(err)}`);
cb(err);
return;
}
cb(null);
};
function serverInfo(req, res) {
res.set('Content-Type', 'text/x-apple-plist+xml');
res.send(plist.build({
deviceid: "B8:E8:56:30:B9:84",
features: 268446207,
model: SERVER_MODEL,
protovers: "1.0",
srcvers: "150.33"
}));
}
parsedPlistFiles.forEach((json, index) => {
fs.writeFileSync(
path.join(programOpts.ios, plistFilenames[index]),
plist.build(
Object.assign(
{},
json,
!programOpts.incrementBuild
? {
CFBundleShortVersionString: appPkg.version
}
: {},
!programOpts.neverIncrementBuild
? {
CFBundleVersion: getNewVersionCode(
programOpts,
parseInt(json.CFBundleVersion, 10),
appPkg.version,
programOpts.resetBuild
).toString()
fs.readFile( plistPath, 'utf8', ( error, data ) => {
if ( error != null )
return callback( error, null );
const metadata = plist.parse( data );
metadata.CFBundleName = name;
metadata.CFBundleExecutable = name;
metadata.CFBundleIdentifier = identifier != null ? identifier : 'org.mimec.launchui.' + name;
metadata.CFBundleVersion = version;
metadata.CFBundleShortVersionString = version;
if ( copyright != null )
metadata.NSHumanReadableCopyright = copyright;
if ( category != null )
metadata.LSApplicationCategoryType = category;
const newData = plist.build( metadata );
fs.writeFile( plistPath, newData, 'utf8', error => {
if ( error != null )
return callback( error, null );
renameExecutable();
} );
} );
}