You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2014/09/23 00:16:34 UTC
[42/50] [abbrv] Revert "Revert "Merge branch 'browserPlatform' of
https://github.com/surajpindoria/cordova-lib""
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/62bdd246/cordova-lib/src/cordova/restore.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/restore.js b/cordova-lib/src/cordova/restore.js
index ffd1edc..6e4d262 100644
--- a/cordova-lib/src/cordova/restore.js
+++ b/cordova-lib/src/cordova/restore.js
@@ -60,39 +60,41 @@ function installPlatformsFromConfigXML(cfg){
//returns a Promise
function installPluginsFromConfigXML(cfg) {
//Install plugins that are listed on config.xml
- var pluginsFromConfig = [];
var projectRoot = cordova_util.cdProjectRoot();
var plugins_dir = path.join(projectRoot, 'plugins');
- var features = cfg.doc.findall('feature');
- features.forEach(function(feature){
- var params = feature.findall('param');
- var pluginId = '';
- var pluginVersion = '';
- for (var i = 0; i < params.length; i++) {
- if (params[i].attrib.name === 'id') {
- pluginId = params[i].attrib.value;
- }
- if (params[i].attrib.name === 'version') {
- pluginVersion = params[i].attrib.value;
- }
+ // Get all configured plugins
+ var features = cfg.getFeatureIdList();
+ if (0 === features.length) {
+ return Q.all('No config.xml plugins to install');
+ }
+
+ return features.reduce(function(soFar, featureId) {
+
+ var pluginPath = path.join(plugins_dir, featureId);
+ if (fs.existsSync(pluginPath)) {
+ // Plugin already exists
+ return soFar;
}
- var pluginPath = path.join(plugins_dir,pluginId);
- // contents of the plugins folder takes precedence hence
- // we ignore if the correct version is installed or not.
- if (pluginId !== '' && !fs.existsSync(pluginPath)) {
- if ( pluginVersion !== '') {
- pluginId = pluginId + '@' + pluginVersion;
+
+ return soFar.then(function() {
+ events.emit('log', 'Discovered ' + featureId + ' in config.xml. Installing to the project');
+
+ var feature = cfg.getFeature(featureId);
+
+ // Install from given URL if defined or using a plugin id
+ var installFrom = feature.url;
+ if (!installFrom) {
+ installFrom = feature.id;
+ if (!!feature.version) {
+ installFrom += ('@' + feature.version);
+ }
}
- events.emit('log', 'Discovered ' + pluginId + ' in config.xml. Installing to the project');
- pluginsFromConfig.push(pluginId);
- }
- });
- //Use cli instead of plugman directly ensuring all the hooks
- // to get fired.
- if (pluginsFromConfig.length >0) {
- return plugin('add', pluginsFromConfig);
- }
- return Q.all('No config.xml plugins to install');
+ // Add feature preferences as CLI variables if have any
+ var options = 'undefined' !== typeof feature.variables ? {cli_variables: feature.variables} : null;
+
+ return plugin('add', installFrom, options);
+ });
+ }, Q());
}
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/62bdd246/cordova-lib/src/cordova/superspawn.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/superspawn.js b/cordova-lib/src/cordova/superspawn.js
index b35e311..51a4d6b 100644
--- a/cordova-lib/src/cordova/superspawn.js
+++ b/cordova-lib/src/cordova/superspawn.js
@@ -141,3 +141,10 @@ exports.spawn = function(cmd, args, opts) {
return d.promise;
};
+exports.maybeSpawn = function(cmd, args, opts) {
+ if (fs.existsSync(cmd)) {
+ return exports.spawn(cmd, args, opts);
+ }
+ return Q(null);
+};
+
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/62bdd246/cordova-lib/src/plugman/create.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/create.js b/cordova-lib/src/plugman/create.js
index 684b126..a63ffea 100644
--- a/cordova-lib/src/plugman/create.js
+++ b/cordova-lib/src/plugman/create.js
@@ -37,38 +37,38 @@ module.exports = function create( name, id, version, pluginPath, options ) {
clobber,
jsMod;
- //check we are not already in a plugin
+ // Check we are not already in a plugin
if( fs.existsSync( cwd + 'plugin.xml' ) ) {
return Q.reject( new CordovaError( 'plugin.xml already exists. Are you already in a plugin?' ) );
}
- //Create a plugin.xml file
+ // Create a plugin.xml file
root = et.Element( 'plugin' );
root.set( 'xmlns', 'http://apache.org/cordova/ns/plugins/1.0' );
root.set( 'xmlns:android', 'http://schemas.android.com/apk/res/android' );
root.set( 'id', id );
root.set( 'version', version );
- //Add the name tag
+ // Add the name tag
pluginName = et.XML( '<name>' );
pluginName.text = name;
root.append( pluginName );
- //loop through the options( variables ) for other tags
+ // Loop through the options( variables ) for other tags
for( var key in options ) {
var temp = et.XML( '<' + key + '>');
temp.text = options[ key ];
root.append( temp );
}
- //setup the directory structure
+ // Setup the directory structure
shell.mkdir( '-p', cwd + 'www' );
shell.mkdir( '-p', cwd + 'src' );
- //create a base plugin.js file
+ // Create a base plugin.js file
baseJS = fs.readFileSync( templatesDir + 'base.js', 'utf-8').replace( /%pluginName%/g, name );
fs.writeFileSync( cwd + 'www/' + name + '.js', baseJS, 'utf-8' );
- //Add it to the xml as a js module
+ // Add it to the xml as a js module
jsMod = et.Element( 'js-module' );
jsMod.set( 'src', 'www/' + name + '.js' );
jsMod.set( 'name', name );
@@ -79,7 +79,7 @@ module.exports = function create( name, id, version, pluginPath, options ) {
root.append( jsMod );
- //Write out the plugin.xml file
+ // Write out the plugin.xml file
fs.writeFileSync( cwd + 'plugin.xml', new et.ElementTree( root ).write( {indent: 4} ), 'utf-8' );
return Q();
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/62bdd246/cordova-lib/src/plugman/install.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/install.js b/cordova-lib/src/plugman/install.js
index 83834b4..045afb7 100644
--- a/cordova-lib/src/plugman/install.js
+++ b/cordova-lib/src/plugman/install.js
@@ -512,19 +512,19 @@ function handleInstall(actions, pluginInfo, platform, project_dir, plugins_dir,
var handler = platform_modules[platform];
var platformTag = pluginInfo._et.find('./platform[@name="'+platform+'"]');
+
// CB-6976 Windows Universal Apps. For smooth transition and to prevent mass api failures
// we allow using windows8 tag for new windows platform
if (platform == 'windows' && !platformTag) {
platformTag = pluginInfo._et.find('platform[@name="' + 'windows8' + '"]');
}
- if ( pluginInfo.hasPlatformSection(platform) ) {
+ if (platformTag) {
var sourceFiles = platformTag.findall('./source-file'),
headerFiles = platformTag.findall('./header-file'),
resourceFiles = platformTag.findall('./resource-file'),
frameworkFiles = platformTag.findall('./framework'),
libFiles = platformTag.findall('./lib-file');
-
// queue up native stuff
sourceFiles && sourceFiles.forEach(function(item) {
actions.push(actions.createAction(handler['source-file'].install,
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/62bdd246/cordova-lib/src/plugman/platform.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/platform.js b/cordova-lib/src/plugman/platform.js
index 414e975..8761986 100644
--- a/cordova-lib/src/plugman/platform.js
+++ b/cordova-lib/src/plugman/platform.js
@@ -33,23 +33,23 @@ module.exports = {
var pluginxml,
platform;
- //check to make sure we are in the plugin first
+ // Check to make sure we are in the plugin first
if( !fs.existsSync( 'plugin.xml' ) ) {
return Q.reject( new Error( "can't find a plugin.xml. Are you in the plugin?" ) );
}
- //Get the current plugin.xml file
+ // Get the current plugin.xml file
pluginxml = et.parse( fs.readFileSync('plugin.xml', 'utf-8') );
- //Check if this platform exists
+ // Check if this platform exists
if( pluginxml.find("./platform/[@name='"+ platformName +"']") ) {
return Q.reject( new Error( "platform: " + platformName + " already added" ) );
}
- //Get the platform specific elements
+ // Get the platform specific elements
platform = doPlatform( platformName, pluginxml.find("./name").text, pluginxml.getroot().get( "id" ) );
- //Make sure we support it
+ // Make sure we support it
if( !platform ) {
return Q.reject( new Error( "platform: " + platformName + " not yet supported" ) );
}
@@ -60,26 +60,26 @@ module.exports = {
return Q();
},
remove: function( platformName ) {
- //check to make sure we are in the plugin first
+ // Check to make sure we are in the plugin first
if( !fs.existsSync( 'plugin.xml' ) ) {
return Q.reject( new Error( "can't find a plugin.xml. Are you in the plugin?" ) );
}
- //Get the current plugin.xml file
+ // Get the current plugin.xml file
var pluginxml = et.parse( fs.readFileSync('plugin.xml', 'utf-8') );
- //Check if this platform exists
+ // Check if this platform exists
if( !pluginxml.find("./platform/[@name='"+ platformName +"']") ) {
return Q.reject( new Error( "platform: " + platformName + " hasn't been added" ) );
}
- //Remove the Platform in question
+ // Remove the Platform in question
pluginxml.getroot().remove( 0, pluginxml.find("./platform/[@name='"+ platformName +"']") );
- //Rewrite the plugin.xml file back out
+ // Rewrite the plugin.xml file back out
fs.writeFileSync( "plugin.xml", pluginxml.write( "plugin.xml", {indent: 4} ), 'utf-8' );
- //Remove the src/"platform"
+ // Remove the src/"platform"
shell.rm( '-rf', 'src/' + platformName );
return Q();
@@ -107,7 +107,7 @@ function doPlatform( platformName, pluginName, pluginID, pluginVersion ) {
}
function doPlatformBase( templatesDir, platformName, pluginName, pluginID, pluginVersion ) {
- //Create the default plugin file
+ // Create the default plugin file
var baseFiles = [],
i = 0;
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/62bdd246/cordova-lib/src/plugman/platforms/ios.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/platforms/ios.js b/cordova-lib/src/plugman/platforms/ios.js
index 6e2f3fd..49336fc 100644
--- a/cordova-lib/src/plugman/platforms/ios.js
+++ b/cordova-lib/src/plugman/platforms/ios.js
@@ -26,7 +26,7 @@ var path = require('path')
, fs = require('fs')
, glob = require('glob')
, xcode = require('xcode')
- , plist = require('plist-with-patches')
+ , plist = require('plist')
, shell = require('shelljs')
, events = require('../../events')
, cachedProjectFiles = {}
@@ -38,7 +38,7 @@ module.exports = {
},
package_name:function(project_dir) {
var plist_file = glob.sync(path.join(project_dir, '**', '*-Info.plist'))[0];
- return plist.parseFileSync(plist_file).CFBundleIdentifier;
+ return plist.parse(fs.readFileSync(plist_file, 'utf8')).CFBundleIdentifier;
},
'source-file':{
install:function(source_el, plugin_dir, project_dir, plugin_id, project) {
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/62bdd246/cordova-lib/src/plugman/platforms/ubuntu.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/platforms/ubuntu.js b/cordova-lib/src/plugman/platforms/ubuntu.js
index c422d7c..bf2665b 100644
--- a/cordova-lib/src/plugman/platforms/ubuntu.js
+++ b/cordova-lib/src/plugman/platforms/ubuntu.js
@@ -32,8 +32,10 @@ function toCamelCase(str) {
}).join('');
}
-var fs = require('fs')
+var shell = require('shelljs')
+ , fs = require('fs')
, path = require('path')
+ , common = require('./common')
, events = require('../../events')
, xml_helpers = require(path.join(__dirname, '..', '..', 'util', 'xml-helpers'));
@@ -49,26 +51,24 @@ module.exports = {
},
'source-file':{
install:function(source_el, plugin_dir, project_dir, plugin_id) {
- var shell = require('shelljs');
- var dest = path.join(project_dir, 'build', 'src', 'plugins', plugin_id);
- shell.mkdir(dest);
- shell.cp(path.join(plugin_dir, source_el.attrib.src), dest);
+ var dest = path.join('build', 'src', 'plugins', plugin_id, path.basename(source_el.attrib.src));
+ common.copyFile(plugin_dir, source_el.attrib.src, project_dir, dest);
- shell.exec('touch ' + path.join(project_dir, 'CMakeLists.txt'));
+ var cmake = path.join(project_dir, 'build', 'CMakeLists.txt');
+ shell.exec('touch ' + cmake);
},
uninstall:function(source_el, project_dir, plugin_id) {
- var shell = require('shelljs');
-
var dest = path.join(project_dir, 'build', 'src', 'plugins', plugin_id);
shell.rm(path.join(dest, path.basename(source_el.attrib.src)));
+
+ var cmake = path.join(project_dir, 'build', 'CMakeLists.txt');
+ shell.exec('touch ' + cmake);
}
},
'header-file':{
install:function(source_el, plugin_dir, project_dir, plugin_id) {
- var shell = require('shelljs');
- var dest = path.join(project_dir, 'build', 'src', 'plugins', plugin_id);
- shell.mkdir(dest);
- shell.cp(path.join(plugin_dir, source_el.attrib.src), dest);
+ var dest = path.join('build', 'src', 'plugins', plugin_id, path.basename(source_el.attrib.src));
+ common.copyFile(plugin_dir, source_el.attrib.src, project_dir, dest);
var plugins = path.join(project_dir, 'build', 'src', 'coreplugins.cpp');
var src = String(fs.readFileSync(plugins));
@@ -81,7 +81,6 @@ module.exports = {
fs.writeFileSync(plugins, src);
},
uninstall:function(source_el, project_dir, plugin_id) {
- var shell = require('shelljs');
var dest = path.join(project_dir, 'build', 'src', 'plugins', plugin_id);
shell.rm(path.join(dest, path.basename(source_el.attrib.src)));
@@ -98,15 +97,15 @@ module.exports = {
},
'resource-file':{
install:function(source_el, plugin_dir, project_dir, plugin_id) {
- var shell = require('shelljs');
- var dest = path.join(project_dir, 'qml');
- shell.mkdir(dest);
- shell.cp(path.join(plugin_dir, source_el.attrib.src), dest);
+ var dest = path.join('qml', path.basename(source_el.attrib.src));
+ if (source_el.attrib['target-dir'])
+ dest = path.join(source_el.attrib['target-dir'], path.basename(source_el.attrib.src));
+ common.copyFile(plugin_dir, source_el.attrib.src, project_dir, dest);
},
uninstall:function(source_el, project_dir, plugin_id) {
- var shell = require('shelljs');
-
var dest = path.join(project_dir, 'qml');
+ if (source_el.attrib['target-dir'])
+ dest = path.join(project_dir, source_el.attrib['target-dir']);
shell.rm(path.join(dest, path.basename(source_el.attrib.src)));
}
},
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/62bdd246/cordova-lib/src/plugman/platforms/windows.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/platforms/windows.js b/cordova-lib/src/plugman/platforms/windows.js
index 803a3c8..347e6a3 100644
--- a/cordova-lib/src/plugman/platforms/windows.js
+++ b/cordova-lib/src/plugman/platforms/windows.js
@@ -39,8 +39,8 @@ module.exports = {
package_name:function(project_dir) {
// CB-6976 Windows Universal Apps. To make platform backward compatible
// with old template we look for package.appxmanifest file as well.
- var manifestPath = fs.existsSync(path.join(project_dir, 'package.store.appxmanifest')) ?
- path.join(project_dir, 'package.store.appxmanifest') :
+ var manifestPath = fs.existsSync(path.join(project_dir, 'package.windows.appxmanifest')) ?
+ path.join(project_dir, 'package.windows.appxmanifest') :
path.join(project_dir, 'package.appxmanifest');
var manifest = xml_helpers.parseElementtreeSync(manifestPath);
@@ -61,15 +61,15 @@ module.exports = {
'source-file': {
install:function(source_el, plugin_dir, project_dir, plugin_id, project_file) {
var targetDir = source_el.attrib['target-dir'] || '';
- var dest = path.join('www', 'plugins', plugin_id, targetDir, path.basename(source_el.attrib['src']));
+ var dest = path.join('plugins', plugin_id, targetDir, path.basename(source_el.attrib['src']));
common.copyNewFile(plugin_dir, source_el.attrib['src'], project_dir, dest);
// add reference to this file to jsproj.
project_file.addSourceFile(dest);
},
uninstall:function(source_el, project_dir, plugin_id, project_file) {
- var dest = path.join('www', 'plugins', plugin_id,
- source_el.attrib['target-dir'] ? source_el.attrib['target-dir'] : '',
+ var dest = path.join('plugins', plugin_id,
+ source_el.attrib['target-dir'] || '',
path.basename(source_el.attrib['src']));
common.removeFile(project_dir, dest);
// remove reference to this file from csproj.
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/62bdd246/cordova-lib/src/plugman/prepare.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/prepare.js b/cordova-lib/src/plugman/prepare.js
index 961141e..284d164 100644
--- a/cordova-lib/src/plugman/prepare.js
+++ b/cordova-lib/src/plugman/prepare.js
@@ -26,8 +26,6 @@ var platform_modules = require('./platforms'),
path = require('path'),
config_changes = require('./util/config-changes'),
xml_helpers = require('../util/xml-helpers'),
- wp8 = require('./platforms/wp8'),
- windows = require('./platforms/windows'),
common = require('./platforms/common'),
fs = require('fs'),
shell = require('shelljs'),
@@ -73,16 +71,6 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
events.emit('verbose', 'Processing configuration changes for plugins.');
config_changes.process(plugins_dir, project_dir, platform);
- // for windows phone and windows8 platforms we need to add all www resources to the .csproj(.jsproj) file
- // first we need to remove them all to prevent duplicates
- var projFile;
- if (platform == 'wp8' || platform == 'windows8' || platform == 'windows') {
- projFile = (platform == 'wp8') ? wp8.parseProjectFile(project_dir) :
- windows.parseProjectFile(project_dir);
- // remove reference to cordova_plugins.js and all files inside plugins folder
- projFile.removeSourceFile(/^(\$\(MSBuildThisFileDirectory\))?www\\(cordova_plugins.js|plugins\\)/i);
- }
-
platform_json = config_changes.get_platform_json(plugins_dir, platform);
// This array holds all the metadata for each module and ends up in cordova_plugins.json
var plugins = Object.keys(platform_json.installed_plugins).concat(Object.keys(platform_json.dependent_plugins));
@@ -150,11 +138,11 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
var fsPath = path.join.apply(path, pathParts);
var scriptContent = fs.readFileSync(path.join(pluginDir, fsPath), 'utf-8').replace(/^\ufeff/, ''); // Window BOM
+ if (fsPath.match(/.*\.json$/)) {
+ scriptContent = 'module.exports = ' + scriptContent;
+ }
scriptContent = 'cordova.define("' + moduleName + '", function(require, exports, module) { ' + scriptContent + '\n});\n';
fs.writeFileSync(path.join(platformPluginsDir, plugin_id, fsPath), scriptContent, 'utf-8');
- if(platform == 'wp8' || platform == 'windows8') {
- projFile.addSourceFile(path.join('www', 'plugins', plugin_id, fsPath));
- }
// Prepare the object for cordova_plugins.json.
var obj = {
@@ -195,9 +183,4 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
events.emit('verbose', 'Writing out cordova_plugins.js...');
fs.writeFileSync(path.join(wwwDir, 'cordova_plugins.js'), final_contents, 'utf-8');
-
- if(platform == 'wp8' || platform == 'windows8' || platform == 'windows') {
- projFile.addSourceFile(path.join('www', 'cordova_plugins.js'));
- projFile.write();
- }
};
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/62bdd246/cordova-lib/src/plugman/registry/manifest.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/registry/manifest.js b/cordova-lib/src/plugman/registry/manifest.js
index 5306b0e..4496f34 100644
--- a/cordova-lib/src/plugman/registry/manifest.js
+++ b/cordova-lib/src/plugman/registry/manifest.js
@@ -88,7 +88,7 @@ function generatePackageJsonFromPluginXml(plugin_path) {
if(keywords) package_json.keywords = keywords.split(',');
if(platforms) package_json.platforms = platforms;
- // adding engines
+ // Adding engines
if(engines) {
package_json.engines = [];
for(var i = 0, j = engines.length ; i < j ; i++) {
@@ -96,10 +96,10 @@ function generatePackageJsonFromPluginXml(plugin_path) {
}
}
- //set docs_path to doc/index.md exists
+ // Set docs_path to doc/index.md exists
var docs_path = path.resolve(plugin_path, 'doc/index.md');
if(!(fs.existsSync(docs_path))){
- //set docs_path to doc/en/index.md
+ // Set docs_path to doc/en/index.md
docs_path = path.resolve(plugin_path, 'doc/en/index.md');
}
if(fs.existsSync(docs_path)){
@@ -107,9 +107,8 @@ function generatePackageJsonFromPluginXml(plugin_path) {
package_json.englishdoc = englishdoc;
}
- // write package.json
+ // Write package.json
var package_json_path = path.resolve(plugin_path, 'package.json');
- //console.log('about to write package.json');
fs.writeFileSync(package_json_path, JSON.stringify(package_json, null, 4), 'utf8');
return package_json;
});
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/62bdd246/cordova-lib/src/plugman/util/action-stack.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/util/action-stack.js b/cordova-lib/src/plugman/util/action-stack.js
index 376b397..d2508de 100644
--- a/cordova-lib/src/plugman/util/action-stack.js
+++ b/cordova-lib/src/plugman/util/action-stack.js
@@ -25,6 +25,8 @@
var platforms = require("../platforms"),
events = require('../../events'),
Q = require('q');
+var superspawn = require('../../cordova/superspawn');
+var path = require('path');
function ActionStack() {
this.stack = [];
@@ -96,12 +98,13 @@ ActionStack.prototype = {
}
events.emit('verbose', 'Action stack processing complete.');
- if (project_files) {
- events.emit('verbose', 'Writing out ' + platform + ' project files...');
- project_files.write();
- }
-
- return Q();
+ return superspawn.maybeSpawn(path.join(project_dir, 'cordova', 'version'))
+ .then(function(platformVersion) {
+ if (project_files) {
+ events.emit('verbose', 'Writing out ' + platform + ' project files...');
+ project_files.write(platformVersion);
+ }
+ });
}
};
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/62bdd246/cordova-lib/src/plugman/util/android-project.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/util/android-project.js b/cordova-lib/src/plugman/util/android-project.js
index d13bfe9..bedec6b 100644
--- a/cordova-lib/src/plugman/util/android-project.js
+++ b/cordova-lib/src/plugman/util/android-project.js
@@ -29,6 +29,7 @@ var fs = require('fs'),
path = require('path'),
properties_parser = require('properties-parser'),
shell = require('shelljs');
+var semver = require('semver');
function addLibraryReference(projectProperties, libraryPath) {
@@ -85,16 +86,22 @@ AndroidProject.prototype = {
delete this._subProjectDirs[subDir];
this._dirty = true;
},
- write: function () {
+ write: function(platformVersion) {
if (!this._dirty) return;
for (var filename in this._propertiesEditors) {
fs.writeFileSync(filename, this._propertiesEditors[filename].toString());
}
- for (var sub_dir in this._subProjectDirs)
- {
- shell.exec('android update lib-project --path "' + sub_dir + '"');
+ // Starting with 3.6.0, the build scripts set ANDROID_HOME, so there is
+ // no reason to keep run this command. Plus - we really want to avoid
+ // relying on the presense of native SDKs within plugman.
+ var needsUpdateProject = !platformVersion || semver.lt(platformVersion, '3.6.0');
+ if (needsUpdateProject) {
+ for (var sub_dir in this._subProjectDirs)
+ {
+ shell.exec('android update lib-project --path "' + sub_dir + '"');
+ }
}
this._dirty = false;
},
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/62bdd246/cordova-lib/src/plugman/util/config-changes.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/util/config-changes.js b/cordova-lib/src/plugman/util/config-changes.js
index f93a9b5..8a580cc 100644
--- a/cordova-lib/src/plugman/util/config-changes.js
+++ b/cordova-lib/src/plugman/util/config-changes.js
@@ -38,7 +38,7 @@
var fs = require('fs'),
path = require('path'),
glob = require('glob'),
- plist = require('plist-with-patches'),
+ plist = require('plist'),
bplist = require('bplist-parser'),
et = require('elementtree'),
semver = require('semver'),
@@ -201,7 +201,7 @@ function remove_plugin_changes(plugin_name, plugin_id, is_top_level) {
if (self.platform == 'windows' && file == 'package.appxmanifest' &&
!fs.existsSync(path.join(self.project_dir, 'package.appxmanifest'))) {
// New windows template separate manifest files for Windows8, Windows8.1 and WP8.1
- var substs = ['package.phone.appxmanifest', 'package.store.appxmanifest', 'package.store80.appxmanifest'];
+ var substs = ['package.phone.appxmanifest', 'package.windows.appxmanifest', 'package.windows80.appxmanifest'];
for (var subst in substs) {
events.emit('verbose', 'Applying munge to ' + substs[subst]);
self.apply_file_munge(substs[subst], munge.files[file], true);
@@ -260,7 +260,7 @@ function add_plugin_changes(plugin_id, plugin_vars, is_top_level, should_increme
// CB-6976 Windows Universal Apps. Compatibility fix for existing plugins.
if (self.platform == 'windows' && file == 'package.appxmanifest' &&
!fs.existsSync(path.join(self.project_dir, 'package.appxmanifest'))) {
- var substs = ['package.phone.appxmanifest', 'package.store.appxmanifest', 'package.store80.appxmanifest'];
+ var substs = ['package.phone.appxmanifest', 'package.windows.appxmanifest', 'package.windows80.appxmanifest'];
for (var subst in substs) {
events.emit('verbose', 'Applying munge to ' + substs[subst]);
self.apply_file_munge(substs[subst], munge.files[file]);
@@ -421,8 +421,8 @@ ConfigKeeper.prototype.get = ConfigKeeper_get;
function ConfigKeeper_get(project_dir, platform, file) {
var self = this;
- //This fixes a bug with older plugins - when specifying config xml instead of res/xml/config.xml
- //https://issues.apache.org/jira/browse/CB-6414
+ // This fixes a bug with older plugins - when specifying config xml instead of res/xml/config.xml
+ // https://issues.apache.org/jira/browse/CB-6414
if(file == 'config.xml' && platform == 'android'){
file = 'res/xml/config.xml';
}
@@ -554,8 +554,9 @@ function ConfigFile_load() {
// 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.plist_module = (isBinaryPlist(filepath) ? bplist : plist);
- self.data = self.plist_module.parseFileSync(filepath);
+ self.data = isBinaryPlist(filepath) ?
+ bplist.parseBuffer(fs.readFileSync(filepath)) :
+ plist.parse(fs.readFileSync(filepath, 'utf8'));
}
}
@@ -796,7 +797,7 @@ function process_munge(obj, createParents, func, keys /* or key1, key2 .... */ )
}
// All values from munge are added to base as
-// base[file][selector][child] += base[file][selector][child]
+// base[file][selector][child] += munge[file][selector][child]
// Returns a munge object containing values that exist in munge
// but not in base.
function increment_munge(base, munge) {
@@ -819,7 +820,7 @@ function increment_munge(base, munge) {
}
// Update the base munge object as
-// base[file][selector][child] -= base[file][selector][child]
+// base[file][selector][child] -= munge[file][selector][child]
// nodes that reached zero value are removed from base and added to the returned munge
// object.
function decrement_munge(base, munge) {
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/62bdd246/cordova-lib/src/plugman/util/plist-helpers.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/util/plist-helpers.js b/cordova-lib/src/plugman/util/plist-helpers.js
index b8d93f2..605a6c2 100644
--- a/cordova-lib/src/plugman/util/plist-helpers.js
+++ b/cordova-lib/src/plugman/util/plist-helpers.js
@@ -23,12 +23,12 @@
// contains PLIST utility functions
-var plist = require('plist-with-patches');
+var plist = require('plist');
// adds node to doc at selector
module.exports.graftPLIST = graftPLIST;
function graftPLIST(doc, xml, selector) {
- var obj = plist.parseStringSync('<plist>'+xml+'</plist>');
+ var obj = plist.parse('<plist>'+xml+'</plist>');
var node = doc[selector];
if (node && Array.isArray(node) && Array.isArray(obj))
@@ -42,7 +42,7 @@ function graftPLIST(doc, xml, selector) {
// removes node from doc at selector
module.exports.prunePLIST = prunePLIST;
function prunePLIST(doc, xml, selector) {
- var obj = plist.parseStringSync('<plist>'+xml+'</plist>');
+ var obj = plist.parse('<plist>'+xml+'</plist>');
pruneOBJECT(doc, selector, obj);
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/62bdd246/cordova-lib/src/util/windows/jsproj.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/util/windows/jsproj.js b/cordova-lib/src/util/windows/jsproj.js
index d847603..ef1cb38 100644
--- a/cordova-lib/src/util/windows/jsproj.js
+++ b/cordova-lib/src/util/windows/jsproj.js
@@ -82,8 +82,6 @@ jsproj.prototype = {
events.emit('verbose','addReference::' + relPath);
- relPath = this.isUniversalWindowsApp ? '$(MSBuildThisFileDirectory)' + relPath : relPath;
-
var item = new et.Element('ItemGroup');
var extName = path.extname(relPath);
@@ -110,8 +108,6 @@ jsproj.prototype = {
removeReference:function(relPath) {
events.emit('verbose','removeReference::' + relPath);
- relPath = this.isUniversalWindowsApp ? '$(MSBuildThisFileDirectory)' + relPath : relPath;
-
var extName = path.extname(relPath);
var includeText = path.basename(relPath,extName);
// <ItemGroup>
@@ -134,7 +130,6 @@ jsproj.prototype = {
relative_path.forEach(function(filePath) {
filePath = filePath.split('/').join('\\');
- filePath = this.isUniversalWindowsApp ? '$(MSBuildThisFileDirectory)' + filePath : filePath;
var content = new et.Element('Content');
content.attrib.Include = filePath;
@@ -148,7 +143,6 @@ jsproj.prototype = {
if (!isRegexp) {
// path.normalize(relative_path);// ??
relative_path = relative_path.split('/').join('\\');
- relative_path = this.isUniversalWindowsApp ? '$(MSBuildThisFileDirectory)' + relative_path : relative_path;
}
var root = this.xml.getroot();