Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function updateProjectAccordingTo(platformConfig, locations) {
// Update app name by editing res/values/strings.xml
var name = platformConfig.name();
var strings = xmlHelpers.parseElementtreeSync(locations.strings);
strings.find('string[@name="app_name"]').text = name.replace(/\'/g, '\\\'');
fs.writeFileSync(locations.strings, strings.write({indent: 4}), 'utf-8');
events.emit('verbose', 'Wrote out android application name "' + name + '" to ' + locations.strings);
// Java packages cannot support dashes
var pkg = (platformConfig.android_packageName() || platformConfig.packageName()).replace(/-/g, '_');
var manifest = new AndroidManifest(locations.manifest);
var orig_pkg = manifest.getPackageId();
manifest.getActivity()
.setOrientation(platformConfig.getPreference('orientation'))
.setLaunchMode(findAndroidLaunchModePreference(platformConfig));
manifest.setVersionName(platformConfig.version())
.setVersionCode(platformConfig.android_versionCode() || default_versionCode(platformConfig.version()))
function updateProjectAccordingTo (platformConfig, locations) {
// Update app name by editing res/values/strings.xml
var strings = xmlHelpers.parseElementtreeSync(locations.strings);
var name = platformConfig.name();
strings.find('string[@name="app_name"]').text = name.replace(/'/g, '\\\'');
var shortName = platformConfig.shortName && platformConfig.shortName();
if (shortName && shortName !== name) {
strings.find('string[@name="launcher_name"]').text = shortName.replace(/'/g, '\\\'');
}
fs.writeFileSync(locations.strings, strings.write({ indent: 4 }), 'utf-8');
events.emit('verbose', 'Wrote out android application name "' + name + '" to ' + locations.strings);
// Java packages cannot support dashes
var androidPkgName = (platformConfig.android_packageName() || platformConfig.packageName()).replace(/-/g, '_');
var manifest = new AndroidManifest(locations.manifest);
function updateProjectAccordingTo(platformConfig, locations) {
// Update app name by editing res/values/strings.xml
var name = platformConfig.name();
var strings = xmlHelpers.parseElementtreeSync(locations.strings);
strings.find('string[@name="app_name"]').text = name;
fs.writeFileSync(locations.strings, strings.write({indent: 4}), 'utf-8');
events.emit('verbose', 'Wrote out Android application name to "' + name + '"');
// Java packages cannot support dashes
var pkg = (platformConfig.android_packageName() || platformConfig.packageName()).replace(/-/g, '_');
var manifest = new AndroidManifest(locations.manifest);
var orig_pkg = manifest.getPackageId();
manifest.getActivity()
.setOrientation(findOrientationValue(platformConfig))
.setLaunchMode(findAndroidLaunchModePreference(platformConfig));
manifest.setVersionName(platformConfig.version())
.setVersionCode(platformConfig.android_versionCode() || default_versionCode(platformConfig.version()))
var preferred_path = path.join(project_dir, 'config.xml');
var config_path;
if (!fs.existsSync(preferred_path)) {
// older location
var old_config_path = path.join(module.exports.www_dir(project_dir), 'config.xml');
if (!fs.existsSync(old_config_path)) {
// output newer location and fail reading
config_path = preferred_path;
events.emit('verbose', 'unable to find ' + config_path);
} else {
config_path = old_config_path;
}
} else {
config_path = preferred_path;
}
var widget_doc = xml_helpers.parseElementtreeSync(config_path);
return widget_doc._root.attrib['id'];
},
'source-file': {
removeProjectReference: function (relative_path, targetConditions) {
events.emit('verbose', 'jsprojManager.removeProjectReference(incText: ' + relative_path + ', targetConditions: ' + JSON.stringify(targetConditions) + ')');
// relative_path is the actual path to the file in the current OS, where-as inserted_path is what we write in
// the project file, and is always in Windows format.
relative_path = path.normalize(relative_path);
var inserted_path = relative_path.split('/').join('\\');
// find the guid + name of the referenced project
var pluginProjectXML = xml_helpers.parseElementtreeSync(path.resolve(this.projectFolder, relative_path));
var projectGuid = pluginProjectXML.find("PropertyGroup/ProjectGuid").text;
var projName = getProjectName(pluginProjectXML, relative_path);
// get the project type
var projectTypeGuid = getProjectTypeGuid(relative_path);
if (!projectTypeGuid) {
throw new Error("Unrecognized project type at " + relative_path + " (not .csproj or .vcxproj)");
}
var preInsertTextRegExp = getProjectReferencePreInsertRegExp(projectGuid);
var postInsertTextRegExp = getProjectReferencePostInsertRegExp(projName, projectGuid, inserted_path, projectTypeGuid);
// There may be multiple solutions (for different VS versions) - process them all
getSolutionPaths(this.projectFolder).forEach(function (solutionPath) {
var solText = fs.readFileSync(solutionPath, {encoding: "utf8"});
removeProjectReference: function (relative_path, targetConditions) {
events.emit('verbose', 'jsprojManager.removeProjectReference(incText: ' + relative_path + ', targetConditions: ' + JSON.stringify(targetConditions) + ')');
// relative_path is the actual path to the file in the current OS, where-as inserted_path is what we write in
// the project file, and is always in Windows format.
relative_path = path.normalize(relative_path);
var inserted_path = relative_path.split('/').join('\\');
// find the guid + name of the referenced project
var pluginProjectXML = xml_helpers.parseElementtreeSync(relative_path);
var projectGuid = pluginProjectXML.find('PropertyGroup/ProjectGuid').text;
var projName = getProjectName(pluginProjectXML, relative_path);
// get the project type
var projectTypeGuid = getProjectTypeGuid(relative_path);
if (!projectTypeGuid) {
throw new Error('unrecognized project type');
}
var preInsertTextRegExp = getProjectReferencePreInsertRegExp(projectGuid);
var postInsertTextRegExp = getProjectReferencePostInsertRegExp(projName, projectGuid, inserted_path, projectTypeGuid);
// There may be multiple solutions (for different VS versions) - process them all
getSolutionPaths(this.projectFolder).forEach(function (solutionPath) {
var solText = fs.readFileSync(solutionPath, {encoding: 'utf8'});
function updateProjectAccordingTo(platformConfig, locations) {
// Update app name by editing res/values/strings.xml
var name = platformConfig.name();
var strings = xmlHelpers.parseElementtreeSync(locations.strings);
strings.find('string[@name="app_name"]').text = name.replace(/\'/g, '\\\'');
fs.writeFileSync(locations.strings, strings.write({indent: 4}), 'utf-8');
events.emit('verbose', 'Wrote out android application name "' + name + '" to ' + locations.strings);
// Java packages cannot support dashes
var pkg = (platformConfig.android_packageName() || platformConfig.packageName()).replace(/-/g, '_');
var manifest = new AndroidManifest(locations.manifest);
var orig_pkg = manifest.getPackageId();
manifest.getActivity()
.setOrientation(platformConfig.getPreference('orientation'))
.setLaunchMode(findAndroidLaunchModePreference(platformConfig));
manifest.setVersionName(platformConfig.version())
.setVersionCode(platformConfig.android_versionCode() || default_versionCode(platformConfig.version()))
function updateProjectAccordingTo (platformConfig, locations) {
// Update app name by editing res/values/strings.xml
var strings = xmlHelpers.parseElementtreeSync(locations.strings);
var name = platformConfig.name();
strings.find('string[@name="app_name"]').text = name.replace(/\'/g, '\\\'');
var shortName = platformConfig.shortName && platformConfig.shortName();
if (shortName && shortName !== name) {
strings.find('string[@name="launcher_name"]').text = shortName.replace(/\'/g, '\\\'');
}
fs.writeFileSync(locations.strings, strings.write({indent: 4}), 'utf-8');
events.emit('verbose', 'Wrote out android application name "' + name + '" to ' + locations.strings);
// Java packages cannot support dashes
var androidPkgName = (platformConfig.android_packageName() || platformConfig.packageName()).replace(/-/g, '_');
var manifest = new AndroidManifest(locations.manifest);
function updateProjectAccordingTo(platformConfig, locations) {
// Update app name by editing res/values/strings.xml
var name = platformConfig.name();
var strings = xmlHelpers.parseElementtreeSync(locations.strings);
strings.find('string[@name="app_name"]').text = name.replace(/\'/g, '\\\'');
fs.writeFileSync(locations.strings, strings.write({indent: 4}), 'utf-8');
events.emit('verbose', 'Wrote out android application name "' + name + '" to ' + locations.strings);
// Java packages cannot support dashes
var pkg = (platformConfig.android_packageName() || platformConfig.packageName()).replace(/-/g, '_');
var manifest = new AndroidManifest(locations.manifest);
var orig_pkg = manifest.getPackageId();
manifest.getActivity()
.setOrientation(platformConfig.getPreference('orientation'))
.setLaunchMode(findAndroidLaunchModePreference(platformConfig));
manifest.setVersionName(platformConfig.version())
.setVersionCode(platformConfig.android_versionCode() || default_versionCode(platformConfig.version()))
function AppxManifest (path, prefix) {
this.path = path;
// Append ':' to prefix if needed
prefix = prefix || '';
this.prefix = (prefix.indexOf(':') === prefix.length - 1) ? prefix : prefix + ':';
this.doc = xml.parseElementtreeSync(path);
if (this.doc.getroot().tag !== 'Package') {
// Some basic validation
throw new Error(path + ' has incorrect root node name (expected "Package")');
}
// Indicates that this manifest is for phone application (either WinPhone 8.1 or Universal Windows 10)
this.hasPhoneIdentity = this.prefix === 'uap:' || this.prefix === 'm3:';
}