New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cordova-android

Package Overview
Dependencies
Maintainers
9
Versions
2381
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-android - npm Package Compare versions

Comparing version 5.1.1 to 5.2.0-nightly.2016.5.24.9738079c

appveyor.yml

38

bin/lib/check_reqs.js

@@ -145,18 +145,16 @@ #!/usr/bin/env node

}).then(function() {
var msg =
'Failed to run "java -version", make sure that you have a JDK installed.\n' +
'You can get it from: http://www.oracle.com/technetwork/java/javase/downloads.\n';
if (process.env['JAVA_HOME']) {
msg += 'Your JAVA_HOME is invalid: ' + process.env['JAVA_HOME'] + '\n';
}
return tryCommand('java -version', msg)
.then(function() {
var msg =
'Failed to run "javac -version", make sure that you have a JDK installed.\n' +
'You can get it from: http://www.oracle.com/technetwork/java/javase/downloads.\n';
if (process.env['JAVA_HOME']) {
msg += 'Your JAVA_HOME is invalid: ' + process.env['JAVA_HOME'] + '\n';
}
// We use tryCommand with catchStderr = true, because
// javac writes version info to stderr instead of stdout
return tryCommand('javac -version', msg, true);
}).then(function (output) {
var match = /javac ((?:\d+\.)+(?:\d+))/i.exec(output)[1];
return match && match[1];
return tryCommand('javac -version', msg, true)
.then(function (output) {
var match = /javac ((?:\d+\.)+(?:\d+))/i.exec(output);
return match && match[1];
});
});
});
};

@@ -242,3 +240,3 @@

module.exports.check_android_target = function(valid_target) {
module.exports.check_android_target = function(originalError) {
// valid_target can look like:

@@ -249,3 +247,3 @@ // android-19

// Google Inc.:Glass Development Kit Preview:20
if (!valid_target) valid_target = module.exports.get_target();
var valid_target = module.exports.get_target();
var msg = 'Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.';

@@ -260,3 +258,3 @@ return tryCommand('android list targets --compact', msg)

var androidCmd = module.exports.getAbsoluteAndroidCmd();
throw new CordovaError('Please install Android target: "' + valid_target + '".\n\n' +
var msg = 'Please install Android target: "' + valid_target + '".\n\n' +
'Hint: Open the SDK manager by running: ' + androidCmd + '\n' +

@@ -266,3 +264,7 @@ 'You will require:\n' +

'2. "Android SDK Platform-tools (latest)\n' +
'3. "Android SDK Build-tools" (latest)');
'3. "Android SDK Build-tools" (latest)';
if (originalError) {
msg = originalError + '\n' + msg;
}
throw new CordovaError(msg);
});

@@ -273,3 +275,3 @@ };

module.exports.run = function() {
return Q.all([this.check_java(), this.check_android().then(this.check_android_target)])
return Q.all([this.check_java(), this.check_android()])
.then(function() {

@@ -276,0 +278,0 @@ console.log('ANDROID_HOME=' + process.env['ANDROID_HOME']);

@@ -249,3 +249,3 @@ #!/usr/bin/env node

events.emit('verbose', 'Copying template files...');
events.emit('verbose', 'Copying android template project to ' + project_path);

@@ -252,0 +252,0 @@ setShellFatal(true, function() {

@@ -20,19 +20,25 @@ /**

var Q = require('q');
var fs = require('fs');
var path = require('path');
var shell = require('shelljs');
var CordovaError = require('cordova-common').CordovaError;
var PlatformJson = require('cordova-common').PlatformJson;
var ActionStack = require('cordova-common').ActionStack;
var AndroidProject = require('./lib/AndroidProject');
var PlatformMunger = require('cordova-common').ConfigChanges.PlatformMunger;
var PluginInfoProvider = require('cordova-common').PluginInfoProvider;
var PluginManager = require('cordova-common').PluginManager;
var ConsoleLogger = require('./lib/ConsoleLogger');
var pluginHandlers = require('./lib/pluginHandlers');
var CordovaLogger = require('cordova-common').CordovaLogger;
var selfEvents = require('cordova-common').events;
var PLATFORM = 'android';
function setupEvents(externalEventEmitter) {
if (externalEventEmitter) {
// This will make the platform internal events visible outside
selfEvents.forwardEventsTo(externalEventEmitter);
return externalEventEmitter;
}
// There is no logger if external emitter is not present,
// so attach a console logger
CordovaLogger.get().subscribe(selfEvents);
return selfEvents;
}
/**

@@ -52,9 +58,4 @@ * Class, that acts as abstraction over particular platform. Encapsulates the

this.root = path.resolve(__dirname, '..');
this.events = events || ConsoleLogger.get();
// NOTE: trick to share one EventEmitter instance across all js code
require('cordova-common').events = this.events;
this._platformJson = PlatformJson.load(this.root, platform);
this._pluginInfoProvider = new PluginInfoProvider();
this._munger = new PlatformMunger(this.platform, this.root, this._platformJson, this._pluginInfoProvider);
setupEvents(events);

@@ -96,4 +97,6 @@ var self = this;

Api.createPlatform = function (destination, config, options, events) {
events = setupEvents(events);
return require('../../lib/create')
.create(destination, config, options, events || ConsoleLogger.get())
.create(destination, config, options, events)
.then(function (destination) {

@@ -122,4 +125,6 @@ var PlatformApi = require(path.resolve(destination, 'cordova/Api'));

Api.updatePlatform = function (destination, options, events) {
events = setupEvents(events);
return require('../../lib/create')
.update(destination, options, events || ConsoleLogger.get())
.update(destination, options, events)
.then(function (destination) {

@@ -187,52 +192,21 @@ var PlatformApi = require(path.resolve(destination, 'cordova/Api'));

Api.prototype.addPlugin = function (plugin, installOptions) {
var project = AndroidProject.getProjectFile(this.root);
if (!plugin || plugin.constructor.name !== 'PluginInfo')
return Q.reject(new CordovaError('The parameter is incorrect. The first parameter to addPlugin should be a PluginInfo instance'));
installOptions = installOptions || {};
installOptions.variables = installOptions.variables || {};
// Add PACKAGE_NAME variable into vars
if (!installOptions.variables.PACKAGE_NAME) {
installOptions.variables.PACKAGE_NAME = project.getPackageName();
}
var self = this;
var actions = new ActionStack();
var project = AndroidProject.getProjectFile(this.root);
return PluginManager.get(this.platform, this.locations, project)
.addPlugin(plugin, installOptions)
.then(function () {
if (plugin.getFrameworks(this.platform).length === 0) return;
// gather all files needs to be handled during install
plugin.getFilesAndFrameworks(this.platform)
.concat(plugin.getAssets(this.platform))
.concat(plugin.getJsModules(this.platform))
.forEach(function(item) {
actions.push(actions.createAction(
pluginHandlers.getInstaller(item.itemType), [item, plugin, project, installOptions],
pluginHandlers.getUninstaller(item.itemType), [item, plugin, project, installOptions]));
});
// run through the action stack
return actions.process(this.platform)
.then(function () {
if (project) {
project.write();
}
// Add PACKAGE_NAME variable into vars
if (!installOptions.variables.PACKAGE_NAME) {
installOptions.variables.PACKAGE_NAME = project.getPackageName();
}
self._munger
// Ignore passed `is_top_level` option since platform itself doesn't know
// anything about managing dependencies - it's responsibility of caller.
.add_plugin_changes(plugin, installOptions.variables, /*is_top_level=*/true, /*should_increment=*/true)
.save_all();
if (plugin.getFrameworks(self.platform).length > 0) {
self.events.emit('verbose', 'Updating build files since android plugin contained <framework>');
selfEvents.emit('verbose', 'Updating build files since android plugin contained <framework>');
require('./lib/builders/builders').getBuilder('gradle').prepBuildFiles();
}
var targetDir = installOptions.usePlatformWww ?
self.locations.platformWww :
self.locations.www;
self._addModulesInfo(plugin, targetDir);
});
}.bind(this))
// CB-11022 Return truthy value to prevent running prepare after
.thenResolve(true);
};

@@ -254,44 +228,13 @@

Api.prototype.removePlugin = function (plugin, uninstallOptions) {
if (!plugin || plugin.constructor.name !== 'PluginInfo')
return Q.reject(new CordovaError('The parameter is incorrect. The first parameter to addPlugin should be a PluginInfo instance'));
var self = this;
var actions = new ActionStack();
var project = AndroidProject.getProjectFile(this.root);
return PluginManager.get(this.platform, this.locations, project)
.removePlugin(plugin, uninstallOptions)
.then(function () {
if (plugin.getFrameworks(this.platform).length === 0) return;
// queue up plugin files
plugin.getFilesAndFrameworks(this.platform)
.concat(plugin.getAssets(this.platform))
.concat(plugin.getJsModules(this.platform))
.forEach(function(item) {
actions.push(actions.createAction(
pluginHandlers.getUninstaller(item.itemType), [item, plugin, project, uninstallOptions],
pluginHandlers.getInstaller(item.itemType), [item, plugin, project, uninstallOptions]));
});
// run through the action stack
return actions.process(this.platform)
.then(function() {
if (project) {
project.write();
}
self._munger
// Ignore passed `is_top_level` option since platform itself doesn't know
// anything about managing dependencies - it's responsibility of caller.
.remove_plugin_changes(plugin, /*is_top_level=*/true)
.save_all();
if (plugin.getFrameworks(self.platform).length > 0) {
self.events.emit('verbose', 'Updating build files since android plugin contained <framework>');
this.events.emit('verbose', 'Updating build files since android plugin contained <framework>');
require('./lib/builders/builders').getBuilder('gradle').prepBuildFiles();
}
var targetDir = uninstallOptions.usePlatformWww ?
self.locations.platformWww :
self.locations.www;
self._removeModulesInfo(plugin, targetDir);
});
}.bind(this))
// CB-11022 Return truthy value to prevent running prepare after
.thenResolve(true);
};

@@ -410,102 +353,1 @@

module.exports = Api;
/**
* Removes the specified modules from list of installed modules and updates
* platform_json and cordova_plugins.js on disk.
*
* @param {PluginInfo} plugin PluginInfo instance for plugin, which modules
* needs to be added.
* @param {String} targetDir The directory, where updated cordova_plugins.js
* should be written to.
*/
Api.prototype._addModulesInfo = function(plugin, targetDir) {
var installedModules = this._platformJson.root.modules || [];
var installedPaths = installedModules.map(function (installedModule) {
return installedModule.file;
});
var modulesToInstall = plugin.getJsModules(this.platform)
.filter(function (moduleToInstall) {
return installedPaths.indexOf(moduleToInstall.file) === -1;
}).map(function (moduleToInstall) {
var moduleName = plugin.id + '.' + ( moduleToInstall.name || moduleToInstall.src.match(/([^\/]+)\.js/)[1] );
var obj = {
file: ['plugins', plugin.id, moduleToInstall.src].join('/'),
id: moduleName
};
if (moduleToInstall.clobbers.length > 0) {
obj.clobbers = moduleToInstall.clobbers.map(function(o) { return o.target; });
}
if (moduleToInstall.merges.length > 0) {
obj.merges = moduleToInstall.merges.map(function(o) { return o.target; });
}
if (moduleToInstall.runs) {
obj.runs = true;
}
return obj;
});
this._platformJson.root.modules = installedModules.concat(modulesToInstall);
if (!this._platformJson.root.plugin_metadata) {
this._platformJson.root.plugin_metadata = {};
}
this._platformJson.root.plugin_metadata[plugin.id] = plugin.version;
this._writePluginModules(targetDir);
this._platformJson.save();
};
/**
* Removes the specified modules from list of installed modules and updates
* platform_json and cordova_plugins.js on disk.
*
* @param {PluginInfo} plugin PluginInfo instance for plugin, which modules
* needs to be removed.
* @param {String} targetDir The directory, where updated cordova_plugins.js
* should be written to.
*/
Api.prototype._removeModulesInfo = function(plugin, targetDir) {
var installedModules = this._platformJson.root.modules || [];
var modulesToRemove = plugin.getJsModules(this.platform)
.map(function (jsModule) {
return ['plugins', plugin.id, jsModule.src].join('/');
});
var updatedModules = installedModules
.filter(function (installedModule) {
return (modulesToRemove.indexOf(installedModule.file) === -1);
});
this._platformJson.root.modules = updatedModules;
if (this._platformJson.root.plugin_metadata) {
delete this._platformJson.root.plugin_metadata[plugin.id];
}
this._writePluginModules(targetDir);
this._platformJson.save();
};
/**
* Fetches all installed modules, generates cordova_plugins contents and writes
* it to file.
*
* @param {String} targetDir Directory, where write cordova_plugins.js to.
* Ususally it is either <platform>/www or <platform>/platform_www
* directories.
*/
Api.prototype._writePluginModules = function (targetDir) {
// Write out moduleObjects as JSON wrapped in a cordova module to cordova_plugins.js
var final_contents = 'cordova.define(\'cordova/plugin_list\', function(require, exports, module) {\n';
final_contents += 'module.exports = ' + JSON.stringify(this._platformJson.root.modules, null, ' ') + ';\n';
final_contents += 'module.exports.metadata = \n';
final_contents += '// TOP OF METADATA\n';
final_contents += JSON.stringify(this._platformJson.root.plugin_metadata, null, 4) + ';\n';
final_contents += '// BOTTOM OF METADATA\n';
final_contents += '});'; // Close cordova.define.
shell.mkdir('-p', targetDir);
fs.writeFileSync(path.join(targetDir, 'cordova_plugins.js'), final_contents, 'utf-8');
};

@@ -59,3 +59,3 @@ /**

Adb.install = function (target, packagePath, opts) {
events.emit('verbose', 'Installing apk ' + packagePath + ' on ' + target + '...');
events.emit('verbose', 'Installing apk ' + packagePath + ' on target ' + target + '...');
var args = ['-s', target, 'install'];

@@ -67,4 +67,13 @@ if (opts && opts.replace) args.push('-r');

// so we catching output to detect installation failure
if (output.match(/Failure/))
if (output.match(/Failure/)) {
if (output.match(/INSTALL_PARSE_FAILED_NO_CERTIFICATES/)) {
output += '\n\n' + 'Sign the build using \'-- --keystore\' or \'--buildConfig\'' +
' or sign and deploy the unsigned apk manually using Android tools.';
} else if (output.match(/INSTALL_FAILED_VERSION_DOWNGRADE/)) {
output += '\n\n' + 'You\'re trying to install apk with a lower versionCode that is already installed.' +
'\nEither uninstall an app or increment the versionCode.';
}
return Q.reject(new CordovaError('Failed to install apk to device: ' + output));
}
});

@@ -74,3 +83,3 @@ };

Adb.uninstall = function (target, packageId) {
events.emit('verbose', 'Uninstalling ' + packageId + ' from ' + target + '...');
events.emit('verbose', 'Uninstalling package ' + packageId + ' from target ' + target + '...');
return spawn('adb', ['-s', target, 'uninstall', packageId], {cwd: os.tmpdir()});

@@ -80,3 +89,3 @@ };

Adb.shell = function (target, shellCommand) {
events.emit('verbose', 'Running command "' + shellCommand + '" on ' + target + '...');
events.emit('verbose', 'Running adb shell command "' + shellCommand + '" on target ' + target + '...');
var args = ['-s', target, 'shell'];

@@ -92,3 +101,3 @@ shellCommand = shellCommand.split(/\s+/);

Adb.start = function (target, activityName) {
events.emit('verbose', 'Starting application "' + activityName + '" on ' + target + '...');
events.emit('verbose', 'Starting application "' + activityName + '" on target ' + target + '...');
return Adb.shell(target, 'am start -W -a android.intent.action.MAIN -n' + activityName)

@@ -95,0 +104,0 @@ .catch(function (output) {

@@ -31,3 +31,3 @@ /**

if (this.doc.getroot().tag !== 'manifest') {
throw new Error(path + ' has incorrect root node name (expected "manifest")');
throw new Error('AndroidManifest at ' + path + ' has incorrect root node name (expected "manifest")');
}

@@ -34,0 +34,0 @@ }

@@ -24,2 +24,3 @@ /**

var AndroidManifest = require('./AndroidManifest');
var pluginHandlers = require('./pluginHandlers');

@@ -184,3 +185,11 @@ var projectFileCache = {};

AndroidProject.prototype.getInstaller = function (type) {
return pluginHandlers.getInstaller(type);
};
AndroidProject.prototype.getUninstaller = function (type) {
return pluginHandlers.getUninstaller(type);
};
module.exports = AndroidProject;

@@ -42,3 +42,3 @@ #!/usr/bin/env node

minSdkVersion: String,
gradleArg: String,
gradleArg: [String, Array],
keystore: path,

@@ -70,4 +70,5 @@ alias: String,

if (options.argv.gradleArg)
ret.extraArgs.push(options.argv.gradleArg);
if (options.argv.gradleArg) {
ret.extraArgs = ret.extraArgs.concat(options.argv.gradleArg);
}

@@ -94,4 +95,3 @@ var packageArgs = {};

var buildjson = fs.readFileSync(buildConfig, 'utf8');
//var config = JSON.parse(fs.readFileSync(buildConfig, 'utf8'));
var config = JSON.parse(buildjson);
var config = JSON.parse(buildjson.replace(/^\ufeff/, '')); // Remove BOM
if (config.android && config.android[ret.buildType]) {

@@ -155,7 +155,6 @@ var androidInfo = config.android[ret.buildType];

var builder = builders.getBuilder(opts.buildMethod);
var self = this;
return builder.prepEnv(opts)
.then(function() {
if (opts.prepEnv) {
self.events.emit('verbose', 'Build file successfully prepared.');
events.emit('verbose', 'Build file successfully prepared.');
return;

@@ -166,3 +165,3 @@ }

var apkPaths = builder.findOutputApks(opts.buildType, opts.arch);
self.events.emit('log', 'Built the following apk(s): \n\t' + apkPaths.join('\n\t'));
events.emit('log', 'Built the following apk(s): \n\t' + apkPaths.join('\n\t'));
return {

@@ -197,9 +196,9 @@ apkPaths: apkPaths,

// sure that this scenario even happens on non-OSX machines.
events.emit('verbose', 'adb timed out while detecting device/emulator architecture. Killing adb and trying again.');
return spawn('killall', ['adb'])
.then(function() {
events.emit('verbose', 'adb seems hung. retrying.');
return helper()
.then(null, function() {
// The double kill is sadly often necessary, at least on mac.
events.emit('warn', 'Now device not found... restarting adb again.');
events.emit('warn', 'adb timed out a second time while detecting device/emulator architecture. Killing adb and trying again.');
return spawn('killall', ['adb'])

@@ -209,3 +208,3 @@ .then(function() {

.then(null, function() {
return Q.reject(new CordovaError('USB is flakey. Try unplugging & replugging the device.'));
return Q.reject(new CordovaError('adb timed out a third time while detecting device/emulator architecture. Try unplugging & replugging the device.'));
});

@@ -212,0 +211,0 @@ });

@@ -82,3 +82,3 @@ /*

if (propertiesObj.systemLibs.length > 0) {
throw new CordovaError('Project contains at least one plugin that requires a system library. This is not supported with ANT. Please build using gradle.');
throw new CordovaError('Project contains at least one plugin that requires a system library. This is not supported with ANT. Use gradle instead.');
}

@@ -111,3 +111,18 @@

.then(function() {
return spawn('ant', args, {stdio: 'inherit'});
return spawn('ant', args, {stdio: 'pipe'});
}).progress(function (stdio){
if (stdio.stderr) {
process.stderr.write(stdio.stderr);
} else {
process.stdout.write(stdio.stdout);
}
}).catch(function (error) {
if (error.toString().indexOf('Unable to resolve project target') >= 0) {
return check_reqs.check_android_target(error).then(function() {
// If due to some odd reason - check_android_target succeeds
// we should still fail here.
return Q.reject(error);
});
}
return Q.reject(error);
});

@@ -114,0 +129,0 @@ };

@@ -96,2 +96,10 @@ /*

function apkSorter(fileA, fileB) {
// De-prioritize unsigned builds
var unsignedRE = /-unsigned/;
if (unsignedRE.exec(fileA)) {
return 1;
} else if (unsignedRE.exec(fileB)) {
return -1;
}
var timeDiff = fs.statSync(fileA).mtime - fs.statSync(fileB).mtime;

@@ -132,3 +140,4 @@ return timeDiff === 0 ? fileA.length - fileB.length : timeDiff;

});
if (archSpecific && ret.length > 1) {
if (archSpecific && ret.length > 1 && arch) {
ret = ret.filter(function(p) {

@@ -135,0 +144,0 @@ return path.basename(p).indexOf('-' + arch) != -1;

@@ -25,3 +25,2 @@ /*

var shell = require('shelljs');
var child_process = require('child_process');
var spawn = require('cordova-common').superspawn.spawn;

@@ -166,3 +165,3 @@ var CordovaError = require('cordova-common').CordovaError;

/*jshint -W069 */
var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'http\\://services.gradle.org/distributions/gradle-2.2.1-all.zip';
var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'http\\://services.gradle.org/distributions/gradle-2.13-all.zip';
/*jshint +W069 */

@@ -190,3 +189,31 @@ var gradleWrapperPropertiesPath = path.join(self.root, 'gradle', 'wrapper', 'gradle-wrapper.properties');

var args = this.getArgs(opts.buildType == 'debug' ? 'debug' : 'release', opts);
return spawnAndSuppressJavaOptions(wrapper, args);
return spawn(wrapper, args, {stdio: 'pipe'})
.progress(function (stdio){
if (stdio.stderr) {
/*
* Workaround for the issue with Java printing some unwanted information to
* stderr instead of stdout.
* This function suppresses 'Picked up _JAVA_OPTIONS' message from being
* printed to stderr. See https://issues.apache.org/jira/browse/CB-9971 for
* explanation.
*/
var suppressThisLine = /^Picked up _JAVA_OPTIONS: /i.test(stdio.stderr.toString());
if (suppressThisLine) {
return;
}
process.stderr.write(stdio.stderr);
} else {
process.stdout.write(stdio.stdout);
}
}).catch(function (error) {
if (error.toString().indexOf('failed to find target with hash string') >= 0) {
return check_reqs.check_android_target(error).then(function() {
// If due to some odd reason - check_android_target succeeds
// we should still fail here.
return Q.reject(error);
});
}
return Q.reject(error);
});
};

@@ -218,62 +245,1 @@

}
/**
* A special superspawn-like implementation, required to workaround the issue
* with Java printing some unwanted information to stderr instead of stdout.
* This function suppresses 'Picked up _JAVA_OPTIONS' message from being
* printed to stderr. See https://issues.apache.org/jira/browse/CB-9971 for
* explanation.
*
* This function needed because superspawn does not provide a way to get and
* manage spawned process output streams. There is a CB-10052 which describes
* an improvements for superspawn, needed to get rid of this.
* TODO: Once this improvement added to cordova-common, we could remove this functionality.
*
* @param {String} cmd A command to spawn
* @param {String[]} args Command arguments. Note that on Windows arguments
* will be concatenated into string and passed to 'cmd.exe' along with '/s'
* and '/c' switches for proper space-in-path handling
*
* @return {Promise} A promise, rejected with error message if
* underlying command exits with nonzero exit code, fulfilled otherwise
*/
function spawnAndSuppressJavaOptions(cmd, args) {
var opts = { stdio: 'pipe' };
if (process.platform === 'win32') {
// Work around spawn not being able to find .bat files.
var joinedArgs = [cmd]
.concat(args)
.map(function(a){
// Add quotes to arguments which contains whitespaces
if (/^[^"].* .*[^"]/.test(a)) return '"' + a + '"';
return a;
}).join(' ');
args = ['/s', '/c'].concat('"' + joinedArgs + '"');
cmd = 'cmd';
opts.windowsVerbatimArguments = true;
}
return Q.Promise(function (resolve, reject) {
var proc = child_process.spawn(cmd, args, opts);
proc.stdout.on('data', process.stdout.write.bind(process.stdout));
proc.stderr.on('data', function (data) {
var suppressThisLine = /^Picked up _JAVA_OPTIONS: /i.test(data.toString());
if (suppressThisLine) {
return;
}
process.stderr.write(data);
});
proc.on('exit', function(code) {
if (code) {
reject('Error code ' + code + ' for command: ' + cmd + ' with args: ' + args);
} else {
resolve();
}
});
});
}

@@ -92,2 +92,3 @@ #!/usr/bin/env node

events.emit('log', 'Using apk: ' + apk_path);
events.emit('log', 'Package name: ' + pkgName);

@@ -94,0 +95,0 @@ return Adb.install(resolvedTarget.target, apk_path, {replace: true})

@@ -65,2 +65,6 @@ #!/usr/bin/env node

img_obj['name'] = response[i].split('Name: ')[1].replace('\r', '');
if (response[i + 1].match(/Device:\s/)) {
i++;
img_obj['device'] = response[i].split('Device: ')[1].replace('\r', '');
}
if (response[i + 1].match(/Path:\s/)) {

@@ -70,5 +74,6 @@ i++;

}
if (response[i + 1].match(/\(API\slevel\s/)) {
if (response[i + 1].match(/\(API\slevel\s/) || (response[i + 2] && response[i + 2].match(/\(API\slevel\s/))) {
i++;
img_obj['target'] = response[i].replace('\r', '');
var secondLine = response[i + 1].match(/\(API\slevel\s/) ? response[i + 1] : '';
img_obj['target'] = (response[i] + secondLine).split('Target: ')[1].replace('\r', '');
}

@@ -187,3 +192,3 @@ if (response[i + 1].match(/ABI:\s/)) {

// wait for emulator to start
events.emit('log', 'Waiting for emulator...');
events.emit('log', 'Waiting for emulator to start...');
return self.wait_for_emulator(uuid);

@@ -195,3 +200,3 @@ }).then(function(emulatorId) {

//wait for emulator to boot up
process.stdout.write('Booting up emulator (this may take a while)...');
process.stdout.write('Waiting for emulator to boot (this may take a while)...');
return self.wait_for_boot(emulatorId, boot_timeout)

@@ -274,3 +279,3 @@ .then(function(success) {

module.exports.create_image = function(name, target) {
console.log('Creating avd named ' + name);
console.log('Creating new avd named ' + name);
if (target) {

@@ -289,3 +294,3 @@ return spawn('android', ['create', 'avd', '--name', name, '--target', target])

console.error('ERROR : Unable to create an avd emulator, no targets found.');
console.error('Please insure you have targets available by running the "android" command');
console.error('Ensure you have targets available by running the "android" command');
return Q.reject();

@@ -303,3 +308,3 @@ }, function(error) {

if (emulator_list.length < 1) {
return Q.reject('No started emulators found, please start an emultor before deploying your project.');
return Q.reject('No running Android emulators found, please start an emulator before deploying your project.');
}

@@ -359,2 +364,3 @@

events.emit('log', 'Using apk: ' + apk_path);
events.emit('log', 'Package name: ' + pkgName);
events.emit('verbose', 'Installing app on emulator...');

@@ -374,4 +380,13 @@

// message to stdout, so we have to use RegExp matching to detect installation failure.
else if (/Failure/.test(stdout)) reject(new CordovaError('Failed to install apk to emulator: ' + stdout));
else resolve(stdout);
else if (/Failure/.test(stdout)) {
if (stdout.match(/INSTALL_PARSE_FAILED_NO_CERTIFICATES/)) {
stdout += 'Sign the build using \'-- --keystore\' or \'--buildConfig\'' +
' or sign and deploy the unsigned apk manually using Android tools.';
} else if (stdout.match(/INSTALL_FAILED_VERSION_DOWNGRADE/)) {
stdout += 'You\'re trying to install apk with a lower versionCode that is already installed.' +
'\nEither uninstall an app or increment the versionCode.';
}
reject(new CordovaError('Failed to install apk to emulator: ' + stdout));
} else resolve(stdout);
});

@@ -389,4 +404,4 @@ });

events.emit('warn', 'Uninstalling app from device and reinstalling it again because the ' +
'installed app already signed with different key');
events.emit('warn', 'Uninstalling app from device and reinstalling it because the ' +
'currently installed app was signed with different key');

@@ -393,0 +408,0 @@ // This promise is always resolved, even if 'adb uninstall' fails to uninstall app

@@ -31,6 +31,10 @@ /*

install:function(obj, plugin, project, options) {
if (!obj.src) throw new CordovaError('<source-file> element is missing "src" attribute for plugin: ' + plugin.id);
if (!obj.targetDir) throw new CordovaError('<source-file> element is missing "target-dir" attribute for plugin: ' + plugin.id);
if (!obj.src) throw new CordovaError(generateAttributeError('src', 'source-file', plugin.id));
if (!obj.targetDir) throw new CordovaError(generateAttributeError('target-dir', 'source-file', plugin.id));
var dest = path.join(obj.targetDir, path.basename(obj.src));
copyNewFile(plugin.dir, obj.src, project.projectDir, dest, options && options.link);
if (options && options.force) {
copyFile(plugin.dir, obj.src, project.projectDir, dest, !!(options && options.link));
} else {
copyNewFile(plugin.dir, obj.src, project.projectDir, dest, !!(options && options.link));
}
},

@@ -45,3 +49,3 @@ uninstall:function(obj, plugin, project, options) {

var dest = path.join('libs', path.basename(obj.src));
copyFile(plugin.dir, obj.src, project.projectDir, dest, options && options.link);
copyFile(plugin.dir, obj.src, project.projectDir, dest, !!(options && options.link));
},

@@ -55,3 +59,3 @@ uninstall:function(obj, plugin, project, options) {

install:function(obj, plugin, project, options) {
copyFile(plugin.dir, obj.src, project.projectDir, path.normalize(obj.target), options && options.link);
copyFile(plugin.dir, obj.src, project.projectDir, path.normalize(obj.target), !!(options && options.link));
},

@@ -65,3 +69,3 @@ uninstall:function(obj, plugin, project, options) {

var src = obj.src;
if (!src) throw new CordovaError('src not specified in <framework> for plugin: ' + plugin.id);
if (!src) throw new CordovaError(generateAttributeError('src', 'framework', plugin.id));

@@ -74,3 +78,3 @@ events.emit('verbose', 'Installing Android library: ' + src);

var subRelativeDir = project.getCustomSubprojectRelativeDir(plugin.id, src);
copyNewFile(plugin.dir, src, project.projectDir, subRelativeDir, options && options.link);
copyNewFile(plugin.dir, src, project.projectDir, subRelativeDir, !!(options && options.link));
subDir = path.resolve(project.projectDir, subRelativeDir);

@@ -92,3 +96,3 @@ } else {

var src = obj.src;
if (!src) throw new CordovaError('src not specified in <framework> for plugin: ' + plugin.id);
if (!src) throw new CordovaError(generateAttributeError('src', 'framework', plugin.id));

@@ -105,3 +109,3 @@ events.emit('verbose', 'Uninstalling Android library: ' + src);

var parDir = path.dirname(subDir);
if (fs.readdirSync(parDir).length === 0) {
if (fs.existsSync(parDir) && fs.readdirSync(parDir).length === 0) {
fs.rmdirSync(parDir);

@@ -126,10 +130,13 @@ }

if (!obj.src) {
throw new CordovaError('<asset> tag without required "src" attribute. plugin=' + plugin.dir);
throw new CordovaError(generateAttributeError('src', 'asset', plugin.id));
}
if (!obj.target) {
throw new CordovaError('<asset> tag without required "target" attribute');
throw new CordovaError(generateAttributeError('target', 'asset', plugin.id));
}
var www = options.usePlatformWww ? project.platformWww : project.www;
copyFile(plugin.dir, obj.src, www, obj.target);
copyFile(plugin.dir, obj.src, project.www, obj.target);
if (options && options.usePlatformWww) {
// CB-11022 copy file to both directories if usePlatformWww is specified
copyFile(plugin.dir, obj.src, project.platformWww, obj.target);
}
},

@@ -139,7 +146,11 @@ uninstall:function(obj, plugin, project, options) {

if (!target) throw new CordovaError('<asset> tag without required "target" attribute');
if (!target) throw new CordovaError(generateAttributeError('target', 'asset', plugin.id));
var www = options.usePlatformWww ? project.platformWww : project.www;
removeFile(www, target);
removeFileF(path.resolve(www, 'plugins', plugin.id));
removeFileF(path.resolve(project.www, target));
removeFileF(path.resolve(project.www, 'plugins', plugin.id));
if (options && options.usePlatformWww) {
// CB-11022 remove file from both directories if usePlatformWww is specified
removeFileF(path.resolve(project.platformWww, target));
removeFileF(path.resolve(project.platformWww, 'plugins', plugin.id));
}
}

@@ -151,3 +162,3 @@ },

var moduleSource = path.resolve(plugin.dir, obj.src);
var moduleName = plugin.id + '.' + (obj.name || path.parse(obj.src).name);
var moduleName = plugin.id + '.' + (obj.name || path.basename(obj.src, path.extname (obj.src)));

@@ -161,11 +172,20 @@ // Read in the file, prepend the cordova.define, and write it back out.

var www = options.usePlatformWww ? project.platformWww : project.www;
var moduleDestination = path.resolve(www, 'plugins', plugin.id, obj.src);
shell.mkdir('-p', path.dirname(moduleDestination));
fs.writeFileSync(moduleDestination, scriptContent, 'utf-8');
var wwwDest = path.resolve(project.www, 'plugins', plugin.id, obj.src);
shell.mkdir('-p', path.dirname(wwwDest));
fs.writeFileSync(wwwDest, scriptContent, 'utf-8');
if (options && options.usePlatformWww) {
// CB-11022 copy file to both directories if usePlatformWww is specified
var platformWwwDest = path.resolve(project.platformWww, 'plugins', plugin.id, obj.src);
shell.mkdir('-p', path.dirname(platformWwwDest));
fs.writeFileSync(platformWwwDest, scriptContent, 'utf-8');
}
},
uninstall: function (obj, plugin, project, options) {
var pluginRelativePath = path.join('plugins', plugin.id, obj.src);
var www = options.usePlatformWww ? project.platformWww : project.www;
removeFileAndParents(www, pluginRelativePath);
removeFileAndParents(project.www, pluginRelativePath);
if (options && options.usePlatformWww) {
// CB-11022 remove file from both directories if usePlatformWww is specified
removeFileAndParents(project.platformWww, pluginRelativePath);
}
}

@@ -199,3 +219,3 @@ }

if (real_path.indexOf(real_plugin_path) !== 0)
throw new CordovaError('"' + src + '" not located within plugin!');
throw new CordovaError('File "' + src + '" is located outside the plugin directory "' + plugin_dir + '"');

@@ -206,3 +226,3 @@ dest = path.resolve(project_dir, dest);

if (dest.indexOf(project_dir) !== 0)
throw new CordovaError('"' + dest + '" not located within project!');
throw new CordovaError('Destination "' + dest + '" for source file "' + src + '" is located outside the project');

@@ -266,1 +286,5 @@ shell.mkdir('-p', path.dirname(dest));

}
function generateAttributeError(attribute, element, id) {
return 'Required attribute "' + attribute + '" not specified in <' + element + '> element from plugin: ' + id;
}

@@ -29,2 +29,5 @@ /**

var ConfigParser = require('cordova-common').ConfigParser;
var PlatformJson = require('cordova-common').PlatformJson;
var PlatformMunger = require('cordova-common').ConfigChanges.PlatformMunger;
var PluginInfoProvider = require('cordova-common').PluginInfoProvider;

@@ -35,5 +38,7 @@ module.exports.prepare = function (cordovaProject) {

this._config = updateConfigFilesFrom(cordovaProject.projectConfig,
this._munger, this.locations);
var platformJson = PlatformJson.load(this.locations.root, this.platform);
var munger = new PlatformMunger(this.platform, this.locations.root, platformJson, new PluginInfoProvider());
this._config = updateConfigFilesFrom(cordovaProject.projectConfig, munger, this.locations);
// Update own www dir with project's www assets and plugins' assets and js-files

@@ -50,3 +55,3 @@ return Q.when(updateWwwFrom(cordovaProject, this.locations))

.then(function () {
self.events.emit('verbose', 'updated project successfully');
events.emit('verbose', 'Prepared android project successfully');
});

@@ -70,3 +75,3 @@ };

function updateConfigFilesFrom(sourceConfig, configMunger, locations) {
events.emit('verbose', 'Generating config.xml from defaults for platform "android"');
events.emit('verbose', 'Generating platform-specific config.xml from defaults for android at ' + locations.configXml);

@@ -81,2 +86,3 @@ // First cleanup current config and merge project's one into own

events.emit('verbose', 'Merging project\'s config.xml into platform-specific android config.xml');
// Merge changes from app's config.xml into platform's one

@@ -111,3 +117,3 @@ var config = new ConfigParser(locations.configXml);

if (fs.existsSync(merges_path)) {
events.emit('verbose', 'Found "merges" for android platform. Copying over existing "www" files.');
events.emit('verbose', 'Found "merges/android" folder. Copying its contents into the android project.');
var overrides = path.join(merges_path, '*');

@@ -131,3 +137,3 @@ shell.cp('-rf', overrides, destinations.www);

fs.writeFileSync(locations.strings, strings.write({indent: 4}), 'utf-8');
events.emit('verbose', 'Wrote out Android application name to "' + name + '"');
events.emit('verbose', 'Wrote out android application name "' + name + '" to ' + locations.strings);

@@ -141,3 +147,3 @@ // Java packages cannot support dashes

manifest.getActivity()
.setOrientation(findOrientationValue(platformConfig))
.setOrientation(platformConfig.getPreference('orientation'))
.setLaunchMode(findAndroidLaunchModePreference(platformConfig));

@@ -159,5 +165,5 @@

if (java_files.length === 0) {
throw new CordovaError('No Java files found which extend CordovaActivity.');
throw new CordovaError('No Java files found that extend CordovaActivity.');
} else if(java_files.length > 1) {
events.emit('log', 'Multiple candidate Java files (.java files which extend CordovaActivity) found. Guessing at the first one, ' + java_files[0]);
events.emit('log', 'Multiple candidate Java files that extend CordovaActivity found. Guessing at the first one, ' + java_files[0]);
}

@@ -168,3 +174,3 @@

shell.sed(/package [\w\.]*;/, 'package ' + pkg + ';', java_files[0]).to(destFile);
events.emit('verbose', 'Wrote out Android package name to "' + pkg + '"');
events.emit('verbose', 'Wrote out Android package name "' + pkg + '" to ' + destFile);

@@ -203,2 +209,4 @@ if (orig_pkg !== pkg) {

}
events.emit('verbose', 'android-versionCode not found in config.xml. Generating a code based on version in config.xml (' + version + '): ' + versionCode);
return versionCode;

@@ -218,3 +226,3 @@ }

var destFilePath = path.join(destFolder, isNinePatch ? ninePatchName : name);
events.emit('verbose', 'copying image from ' + src + ' to ' + destFilePath);
events.emit('verbose', 'Copying image from ' + src + ' to ' + destFilePath);
shell.cp('-f', src, destFilePath);

@@ -299,3 +307,3 @@ }

if (default_icon) {
events.emit('verbose', 'more than one default icon: ' + JSON.stringify(icon));
events.emit('verbose', 'Found extra default icon: ' + icon.src + ' (ignoring in favor of ' + default_icon.src + ')');
} else {

@@ -360,34 +368,1 @@ default_icon = icon;

}
/**
* Queries ConfigParser object for the orientation <preference> value. Warns if
* global preference value is not supported by platform.
*
* @param {Object} platformConfig ConfigParser object
*
* @return {String} Global/platform-specific orientation in lower-case
* (or empty string if both are undefined).
*/
function findOrientationValue(platformConfig) {
var ORIENTATION_DEFAULT = 'default';
var orientation = platformConfig.getPreference('orientation');
if (!orientation) {
return ORIENTATION_DEFAULT;
}
var GLOBAL_ORIENTATIONS = ['default', 'portrait','landscape'];
function isSupported(orientation) {
return GLOBAL_ORIENTATIONS.indexOf(orientation.toLowerCase()) >= 0;
}
// Check if the given global orientation is supported
if (orientation && isSupported(orientation)) {
return orientation;
}
events.emit('warn', 'Unsupported global orientation: ' + orientation +
'. Defaulting to value: ' + ORIENTATION_DEFAULT);
return ORIENTATION_DEFAULT;
}

@@ -28,3 +28,4 @@ #!/usr/bin/env node

device = require('./device'),
Q = require('q');
Q = require('q'),
events = require('cordova-common').events;

@@ -66,6 +67,6 @@ function getInstallTarget(runOptions) {

if (device_list.length > 0) {
self.events.emit('warn', 'No target specified, deploying to device \'' + device_list[0] + '\'.');
events.emit('warn', 'No target specified, deploying to device \'' + device_list[0] + '\'.');
install_target = device_list[0];
} else {
self.events.emit('warn', 'No target specified, deploying to emulator');
events.emit('warn', 'No target specified and no devices found, deploying to emulator');
install_target = '--emulator';

@@ -72,0 +73,0 @@ }

@@ -20,5 +20,2 @@ /**

/* jshint node:true */
// For now expose plugman and cordova just as they were in the old repos
exports = module.exports = {

@@ -37,2 +34,4 @@ events: require('./src/events'),

PluginInfoProvider: require('./src/PluginInfo/PluginInfoProvider.js'),
PluginManager: require('./src/PluginManager'),

@@ -39,0 +38,0 @@ ConfigChanges: require('./src/ConfigChanges/ConfigChanges.js'),

{
"_args": [
[
"cordova-common@^1.1.0",
"/Users/steveng/repo/cordova/cordova-android"
"cordova-common@1.2.0",
"d:\\cordova\\cordova-android"
]
],
"_from": "cordova-common@>=1.1.0 <2.0.0",
"_id": "cordova-common@1.1.0",
"_from": "cordova-common@1.2.0",
"_id": "cordova-common@1.2.0",
"_inCache": true,
"_installable": true,
"_location": "/cordova-common",
"_nodeVersion": "4.2.3",
"_nodeVersion": "5.9.1",
"_npmOperationalInternal": {
"host": "packages-5-east.internal.npmjs.com",
"tmp": "tmp/cordova-common-1.1.0.tgz_1455781889491_0.6937742941081524"
"host": "packages-12-west.internal.npmjs.com",
"tmp": "tmp/cordova-common-1.2.0.tgz_1461227352417_0.14771279646083713"
},

@@ -22,11 +22,11 @@ "_npmUser": {

},
"_npmVersion": "2.14.7",
"_npmVersion": "3.8.5",
"_phantomChildren": {},
"_requested": {
"name": "cordova-common",
"raw": "cordova-common@^1.1.0",
"rawSpec": "^1.1.0",
"raw": "cordova-common@1.2.0",
"rawSpec": "1.2.0",
"scope": null,
"spec": ">=1.1.0 <2.0.0",
"type": "range"
"spec": "1.2.0",
"type": "version"
},

@@ -36,7 +36,7 @@ "_requiredBy": [

],
"_resolved": "http://registry.npmjs.org/cordova-common/-/cordova-common-1.1.0.tgz",
"_shasum": "8682721466ee354747ec6241f34f412b7e0ef636",
"_resolved": "file:cordova-dist\\tools\\cordova-common-1.2.0.tgz",
"_shasum": "474b7f77c6c89d3f995c947d96046edf2e8c404d",
"_shrinkwrap": null,
"_spec": "cordova-common@^1.1.0",
"_where": "/Users/steveng/repo/cordova/cordova-android",
"_spec": "cordova-common@1.2.0",
"_where": "d:\\cordova\\cordova-android",
"author": {

@@ -60,3 +60,3 @@ "name": "Apache Software Foundation"

"semver": "^5.0.1",
"shelljs": "^0.5.1",
"shelljs": "^0.5.3",
"underscore": "^1.8.3",

@@ -69,8 +69,10 @@ "unorm": "^1.3.3"

"jasmine-node": "^1.14.5",
"jshint": "^2.8.0"
"jshint": "^2.8.0",
"promise-matchers": "^0.9.6",
"rewire": "^2.5.1"
},
"directories": {},
"dist": {
"shasum": "8682721466ee354747ec6241f34f412b7e0ef636",
"tarball": "http://registry.npmjs.org/cordova-common/-/cordova-common-1.1.0.tgz"
"shasum": "474b7f77c6c89d3f995c947d96046edf2e8c404d",
"tarball": "https://registry.npmjs.org/cordova-common/-/cordova-common-1.2.0.tgz"
},

@@ -85,24 +87,24 @@ "engineStrict": true,

{
"name": "bowserj",
"email": "bowserj@apache.org"
"email": "bowserj@apache.org",
"name": "bowserj"
},
{
"name": "kotikov.vladimir",
"email": "kotikov.vladimir@gmail.com"
"email": "kotikov.vladimir@gmail.com",
"name": "kotikov.vladimir"
},
{
"name": "purplecabbage",
"email": "purplecabbage@gmail.com"
"email": "purplecabbage@gmail.com",
"name": "purplecabbage"
},
{
"name": "shazron",
"email": "shazron@gmail.com"
"email": "shazron@gmail.com",
"name": "shazron"
},
{
"name": "stevegill",
"email": "stevengill97@gmail.com"
"email": "stevengill97@gmail.com",
"name": "stevegill"
},
{
"name": "timbarham",
"email": "npmjs@barhams.info"
"email": "npmjs@barhams.info",
"name": "timbarham"
}

@@ -123,3 +125,3 @@ ],

},
"version": "1.1.0"
"version": "1.2.0"
}

@@ -23,2 +23,18 @@ <!--

### 1.2.0 (Apr 18, 2016)
* CB-11022 Save modulesMetadata to both www and platform_www when necessary
* CB-10833 Deduplicate common logic for plugin installation/uninstallation
* CB-10822 Manage plugins/modules metadata using PlatformJson
* CB-10940 Can't add Android platform from path
* CB-10965 xml helper allows multiple instances to be merge in config.xml
### 1.1.1 (Mar 18, 2016)
* CB-10694 Update test to reflect merging of CB-9264 fix
* CB-10694 Platform-specific configuration preferences don't override global settings
* CB-9264 Duplicate entries in `config.xml`
* CB-10791 Add `adjustLoggerLevel` to `cordova-common.CordovaLogger`
* CB-10662 Add tests for `ConfigParser.getStaticResources`
* CB-10622 fix target attribute being ignored for images in `config.xml`.
* CB-10583 Protect plugin preferences from adding extra Array properties.
### 1.1.0 (Feb 16, 2016)

@@ -25,0 +41,0 @@ * CB-10482 Remove references to windows8 from cordova-lib/cli

@@ -189,2 +189,3 @@ /**

res.src = elt.attrib.src;
res.target = elt.attrib.target || undefined;
res.density = elt.attrib['density'] || elt.attrib[that.cdvNamespacePrefix+':density'] || elt.attrib['gap:density'];

@@ -191,0 +192,0 @@ res.platform = elt.platform || null; // null means icon represents default icon (shared between platforms)

@@ -156,2 +156,19 @@ /*

/**
* Adjusts the current logger level according to the passed options.
*
* @param {Object|Array} opts An object or args array with options
*
* @return {CordovaLogger} Current instance, to allow calls chaining.
*/
CordovaLogger.prototype.adjustLevel = function (opts) {
if (opts.verbose || (Array.isArray(opts) && opts.indexOf('--verbose') !== -1)) {
this.setLevel('verbose');
} else if (opts.silent || (Array.isArray(opts) && opts.indexOf('--silent') !== -1)) {
this.setLevel('error');
}
return this;
};
/**
* Attaches logger to EventEmitter instance provided.

@@ -158,0 +175,0 @@ *

@@ -45,3 +45,10 @@ /**

EVENTS_RECEIVER = eventEmitter;
// CB-10940 Skipping forwarding to self to avoid infinite recursion.
// This is the case when the modules are npm-linked.
if (this !== eventEmitter) {
EVENTS_RECEIVER = eventEmitter;
} else {
// Reset forwarding if we are subscribing to self
EVENTS_RECEIVER = undefined;
}
};

@@ -48,0 +55,0 @@

@@ -94,2 +94,34 @@ /*

/**
* @chaining
* Generates and adds metadata for provided plugin into associated <platform>.json file
*
* @param {PluginInfo} pluginInfo A pluginInfo instance to add metadata from
* @returns {this} Current PlatformJson instance to allow calls chaining
*/
PlatformJson.prototype.addPluginMetadata = function (pluginInfo) {
var installedModules = this.root.modules || [];
var installedPaths = installedModules.map(function (installedModule) {
return installedModule.file;
});
var modulesToInstall = pluginInfo.getJsModules(this.platform)
.map(function (module) {
return new ModuleMetadata(pluginInfo.id, module);
})
.filter(function (metadata) {
// Filter out modules which are already added to metadata
return installedPaths.indexOf(metadata.file) === -1;
});
this.root.modules = installedModules.concat(modulesToInstall);
this.root.plugin_metadata = this.root.plugin_metadata || {};
this.root.plugin_metadata[pluginInfo.id] = pluginInfo.version;
return this;
};
PlatformJson.prototype.removePlugin = function(pluginId, isTopLevel) {

@@ -105,2 +137,31 @@ var pluginsList = isTopLevel ?

/**
* @chaining
* Removes metadata for provided plugin from associated file
*
* @param {PluginInfo} pluginInfo A PluginInfo instance to which modules' metadata
* we need to remove
*
* @returns {this} Current PlatformJson instance to allow calls chaining
*/
PlatformJson.prototype.removePluginMetadata = function (pluginInfo) {
var modulesToRemove = pluginInfo.getJsModules(this.platform)
.map(function (jsModule) {
return ['plugins', pluginInfo.id, jsModule.src].join('/');
});
var installedModules = this.root.modules || [];
this.root.modules = installedModules
.filter(function (installedModule) {
// Leave only those metadatas which 'file' is not in removed modules
return (modulesToRemove.indexOf(installedModule.file) === -1);
});
if (this.root.plugin_metadata) {
delete this.root.plugin_metadata[pluginInfo.id];
}
return this;
};
PlatformJson.prototype.addInstalledPluginToPrepareQueue = function(pluginDirName, vars, is_top_level) {

@@ -130,2 +191,35 @@ this.root.prepare_queue.installed.push({'plugin':pluginDirName, 'vars':vars, 'topLevel':is_top_level});

/**
* Generates a metadata for all installed plugins and js modules. The resultant
* string is ready to be written to 'cordova_plugins.js'
*
* @returns {String} cordova_plugins.js contents
*/
PlatformJson.prototype.generateMetadata = function () {
return [
'cordova.define(\'cordova/plugin_list\', function(require, exports, module) {',
'module.exports = ' + JSON.stringify(this.root.modules, null, 4) + ';',
'module.exports.metadata = ',
'// TOP OF METADATA',
JSON.stringify(this.root.plugin_metadata, null, 4) + ';',
'// BOTTOM OF METADATA',
'});' // Close cordova.define.
].join('\n');
};
/**
* @chaining
* Generates and then saves metadata to specified file. Doesn't check if file exists.
*
* @param {String} destination File metadata will be written to
* @return {PlatformJson} PlatformJson instance
*/
PlatformJson.prototype.generateAndSaveMetadata = function (destination) {
var meta = this.generateMetadata();
shelljs.mkdir('-p', path.dirname(destination));
fs.writeFileSync(destination, meta, 'utf-8');
return this;
};
// convert a munge from the old format ([file][parent][xml] = count) to the current one

@@ -157,3 +251,33 @@ function fix_munge(root) {

/**
* @constructor
* @class ModuleMetadata
*
* Creates a ModuleMetadata object that represents module entry in 'cordova_plugins.js'
* file at run time
*
* @param {String} pluginId Plugin id where this module installed from
* @param (JsModule|Object) jsModule A js-module entry from PluginInfo class to generate metadata for
*/
function ModuleMetadata (pluginId, jsModule) {
if (!pluginId) throw new TypeError('pluginId argument must be a valid plugin id');
if (!jsModule.src && !jsModule.name) throw new TypeError('jsModule argument must contain src or/and name properties');
this.id = pluginId + '.' + ( jsModule.name || jsModule.src.match(/([^\/]+)\.js/)[1] );
this.file = ['plugins', pluginId, jsModule.src].join('/');
this.pluginId = pluginId;
if (jsModule.clobbers && jsModule.clobbers.length > 0) {
this.clobbers = jsModule.clobbers.map(function(o) { return o.target; });
}
if (jsModule.merges && jsModule.merges.length > 0) {
this.merges = jsModule.merges.map(function(o) { return o.target; });
}
if (jsModule.runs) {
this.runs = true;
}
}
module.exports = PlatformJson;

@@ -46,14 +46,10 @@ /**

// Used to require a variable to be specified via --variable when installing the plugin.
// returns { key : default | null}
self.getPreferences = getPreferences;
function getPreferences(platform) {
var arprefs = _getTags(self._et, 'preference', platform, _parsePreference);
var prefs= {};
for(var i in arprefs)
{
var pref=arprefs[i];
prefs[pref.preference]=pref.default;
}
// returns { key : default | null}
return prefs;
return _getTags(self._et, 'preference', platform, _parsePreference)
.reduce(function (preferences, pref) {
preferences[pref.preference] = pref.default;
return preferences;
}, {});
}

@@ -60,0 +56,0 @@

@@ -197,3 +197,3 @@ /*

var BLACKLIST = ['platform', 'feature','plugin','engine'];
var SINGLETONS = ['content', 'author'];
var SINGLETONS = ['content', 'author', 'name'];
function mergeXml(src, dest, platform, clobber) {

@@ -213,2 +213,5 @@ // Do nothing for blacklisted tags.

}
//Handle children
src.getchildren().forEach(mergeChild);
//Handle platform

@@ -221,4 +224,4 @@ if (platform) {

//Handle children
src.getchildren().forEach(mergeChild);
//Handle duplicate preference tags (by name attribute)
removeDuplicatePreferences(dest);

@@ -260,2 +263,22 @@ function mergeChild (srcChild) {

}
function removeDuplicatePreferences(xml) {
// reduce preference tags to a hashtable to remove dupes
var prefHash = xml.findall('preference[@name][@value]').reduce(function(previousValue, currentValue) {
previousValue[ currentValue.attrib.name ] = currentValue.attrib.value;
return previousValue;
}, {});
// remove all preferences
xml.findall('preference[@name][@value]').forEach(function(pref) {
xml.remove(pref);
});
// write new preferences
Object.keys(prefHash).forEach(function(key, index) {
var element = et.SubElement(xml, 'preference');
element.set('name', key);
element.set('value', this[key]);
}, prefHash);
}
}

@@ -262,0 +285,0 @@

{
"name": "cordova-android",
"version": "5.1.1",
"description": "cordova-android release",
"bin": {
"create": "bin/create"
},
"main": "bin/templates/cordova/Api.js",
"repository": {
"type": "git",
"url": "https://git-wip-us.apache.org/repos/asf/cordova-android.git"
},
"keywords": [
"android",
"cordova",
"apache"
],
"scripts": {
"test": "npm run jshint && jasmine-node --color spec/unit",
"test-build": "jasmine-node --captureExceptions --color spec/e2e",
"jshint": "node node_modules/jshint/bin/jshint bin && node node_modules/jshint/bin/jshint spec"
},
"author": "Apache Software Foundation",
"license": "Apache-2.0",
"dependencies": {
"cordova-common": "^1.1.0",
"elementtree": "^0.1.6",
"nopt": "^3.0.1",
"properties-parser": "^0.2.3",
"q": "^1.4.1",
"shelljs": "^0.5.3"
},
"bundledDependencies": [
"cordova-common",
"elementtree",
"nopt",
"properties-parser",
"q",
"shelljs"
],
"devDependencies": {
"jasmine-node": "^1.14.5",
"jshint": "^2.6.0",
"promise-matchers": "~0",
"rewire": "^2.1.3"
}
}
"name": "cordova-android",
"version": "5.2.0-nightly.2016.5.24.9738079c",
"description": "cordova-android release",
"bin": {
"create": "bin/create"
},
"main": "bin/templates/cordova/Api.js",
"repository": {
"type": "git",
"url": "https://git-wip-us.apache.org/repos/asf/cordova-android.git"
},
"keywords": [
"android",
"cordova",
"apache"
],
"scripts": {
"test": "npm run jshint && jasmine-node --color spec/unit",
"cover": "istanbul cover --root bin/templates/cordova --print detail node_modules/jasmine-node/bin/jasmine-node -- spec/unit",
"test-build": "jasmine-node --captureExceptions --color spec/e2e",
"jshint": "node node_modules/jshint/bin/jshint bin && node node_modules/jshint/bin/jshint spec"
},
"author": "Apache Software Foundation",
"license": "Apache-2.0",
"dependencies": {
"cordova-common": "^1.2.0",
"elementtree": "^0.1.6",
"nopt": "^3.0.1",
"properties-parser": "^0.2.3",
"q": "^1.4.1",
"shelljs": "^0.5.3"
},
"bundledDependencies": [
"cordova-common",
"elementtree",
"nopt",
"properties-parser",
"q",
"shelljs"
],
"devDependencies": {
"istanbul": "^0.4.2",
"jasmine-node": "^1.14.5",
"jshint": "^2.6.0",
"promise-matchers": "~0",
"rewire": "^2.1.3"
}
}

@@ -21,2 +21,7 @@ <!--

-->
[![Build status](https://ci.appveyor.com/api/projects/status/github/apache/cordova-android?branch=master)](https://ci.appveyor.com/project/Humbedooh/cordova-android)
[![Build Status](https://travis-ci.org/apache/cordova-android.svg?branch=master)](https://travis-ci.org/apache/cordova-android)
[![codecov.io](https://codecov.io/github/apache/cordova-android/coverage.svg?branch=master)](https://codecov.io/github/apache/cordova-android?branch=master)
# Cordova Android

@@ -30,3 +35,5 @@

:warning: Report issues on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Android%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC)
## Requires

@@ -60,2 +67,1 @@

2. Import it via "Non-Android Studio Project"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc