Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cordova

Package Overview
Dependencies
Maintainers
2
Versions
2531
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

spec/fixtures/plugins/android/src/android/SomethingWithR.java

16

package.json
{
"name": "cordova",
"version": "0.0.3",
"version": "0.0.4",
"preferGlobal": "true",

@@ -11,3 +11,3 @@ "description": "Cordova client tool",

"scripts": {
"test": "./node_modules/jasmine-node/bin/jasmine-node --color spec"
"test": "node test_bootstrap.js && ./node_modules/jasmine-node/bin/jasmine-node --color spec"
},

@@ -26,6 +26,8 @@ "repository": {

"wrench":"1.3.9",
"elementtree":"0.1.1",
"pluginstall":"0.5.0",
"elementtree":"0.1.3",
"pluginstall":"git://github.com/imhotep/pluginstall.git",
"node-xcode":"git://github.com/imhotep/node-xcode.git",
"express":"3.0",
"asyncblock":"2.1.4"
"shelljs":"0.0.4",
"ncallbacks":"1.0.0"
},

@@ -38,5 +40,7 @@ "devDependencies": {

{"name": "Brian LeRoux","email": "b@brian.io"},
{"name": "Fil Maj", "email": "filmaj@apache.org"}
{"name": "Fil Maj", "email": "filmaj@apache.org"},
{"name": "Mike Reinstein", "email":""},
{"name": "Darry Pogue", "email":"darryl@dpogue.ca"}
],
"license": "Apache version 2.0"
}

@@ -24,7 +24,7 @@ # cordova-client

Eventually this will be available via npm. For now you must install manually:
```
git clone https://github.com/filmaj/cordova-client.git
cd cordova-client
sudo npm install -g
npm install -g
```

@@ -34,3 +34,5 @@

**NOTE**: on Mac OS X, you may want to change the owner of the cordova directory that npm installs to. This will allow you to run cordova as local user without requiring root permissions. Assuming your node_modules directory is in `/usr/local/lib/`, you can do this by running: `sudo chown -R <username> /usr/local/lib/node_modules/cordova`
## Subcommands

@@ -85,3 +87,8 @@

#### Your Blanket: www/config.xml
This file is what you should be editing to modify your application's metadata. Any time you run any cordova-client commands, the tool will look at the contents of `config.xml` and use all relevant info from this file to define native application information. cordova-client supports changing your application's data via the following elements inside the `config.xml` file:
- The user-facing name can be modified via the contents of the `<name>` element.
# Examples

@@ -138,11 +145,5 @@

## TO-DO
## TO-DO + Issues
- bootstrapping the tests
- properly extracting info from config.xml
- checking SDK compatibility
- blackberry support
- windows phone support
- testing on machines other than Mac OS X
- figure out versioning. for now: 2.1.0 minimum
Please check [cordova-client on GitHub](http://github.com/filmaj/cordova-client).

@@ -156,11 +157,1 @@ ### Bash Completions

### Random Notes
posted to the mailing list by BrianL
yah. there is tonnes of prior art for this stuff. I will update the wiki but quickly, this was stable: [https://github.com/brianleroux/Cordova/tree/b816aacfb7583174be9f44f71dc32c8465d1319]()
then other things happened. Those scripts ended up in the mainline projects. The idea was a standard package format for a project and upgrading would consist only of swapping out the bin directory. The scripts would live local the project avoiding version hell between releases.
This new thinking is different. We now think the native project as it were should host its own scripts. Upgrading not a consideration. Maybe it should be. You're thinking of a master global script, which is cool and something I've always wanted, but the version thing needs to be considered. perhaps not an issue between releases if the native project (the target of www) deals with the version itself...
cordova-client internally depends on pluginstall, a tool written by Andrew Lunny to support installing plugins for the iOS and Android platforms [https://github.com/alunny/pluginstall]()

@@ -7,2 +7,3 @@ var cordova = require('../cordova'),

fs = require('fs'),
config_parser = require('../src/config_parser'),
tempDir = path.join(__dirname, '..', 'temp');

@@ -47,5 +48,7 @@

runs(function() {
var s = spyOn(require('shelljs'), 'exec').andReturn({code:0});
expect(function() {
cordova.build(buildcb);
}).not.toThrow();
expect(s).toHaveBeenCalled();
});

@@ -66,3 +69,3 @@ waitsFor(function() { return buildcb.wasCalled; }, 'build call', 20000);

});
describe('should shell out to the debug command and create a binary', function() {
describe('binary creation', function() {
beforeEach(function() {

@@ -76,3 +79,3 @@ cordova.create(tempDir);

});
it('on Android', function() {
it('should shell out to debug command on Android', function() {
var buildcb = jasmine.createSpy();

@@ -87,18 +90,11 @@ var cb = jasmine.createSpy();

runs(function() {
var s = spyOn(require('shelljs'), 'exec').andReturn({code:0});
cordova.build(buildcb);
expect(s.mostRecentCall.args[0].match(/android\/cordova\/debug > \/dev\/null$/)).not.toBeNull();
});
waitsFor(function() { return buildcb.wasCalled; }, 'build call', 20000);
runs(function() {
var binaryPath = path.join(tempDir, 'platforms','android','bin');
// Check that "bin" dir of android native proj has at
// least one file ennding in ".apk"
expect(fs.readdirSync(binaryPath)
.filter(function(e) {
return e.indexOf('.apk', e.length - 4) !== -1;
}).length > 0).toBe(true);
});
});
it('on iOS', function() {
it('should shelll out to debug command on iOS', function() {
var buildcb = jasmine.createSpy();
var cb = jasmine.createSpy();
var s;

@@ -110,2 +106,3 @@ runs(function() {

runs(function() {
s = spyOn(require('shelljs'), 'exec').andReturn({code:0});
cordova.build(buildcb);

@@ -115,7 +112,4 @@ });

runs(function() {
var binaryPath = path.join(tempDir, 'platforms','ios','build');
expect(fs.existsSync(binaryPath)).toBe(true);
var appPath = path.join(binaryPath,"Hello_Cordova.app");
expect(fs.existsSync(appPath)).toBe(true);
expect(s).toHaveBeenCalled();
expect(s.mostRecentCall.args[0].match(/ios\/cordova\/debug > \/dev\/null$/)).not.toBeNull();
});

@@ -125,10 +119,43 @@ });

describe('should interpolate config.xml app metadata', function() {
describe('before each run it should interpolate config.xml app metadata', function() {
var cfg;
beforeEach(function() {
cordova.create(tempDir);
process.chdir(tempDir);
cfg = config_parser(path.join(tempDir, 'www', 'config.xml'));
});
afterEach(function() {
process.chdir(cwd);
});
describe('into Android builds', function() {
it('should interpolate app name');
it('should interpolate app name', function () {
/*
var buildcb = jasmine.createSpy();
var cb = jasmine.createSpy();
var newName = "devil ether";
runs(function() {
cordova.platform('add', 'android', cb);
});
waitsFor(function() { return cb.wasCalled; }, 'platform add android callback');
runs(function() {
cfg.name(newName); // set a new name in the config.xml
cordova.build(buildcb);
});
waitsFor(function() { return buildcb.wasCalled; }, 'build call', 20000);
runs(function() {
// TODO
});
*/
});
it('should interpolate package name');
});
describe('into iOS builds', function() {
it('should interpolate app name');
it('should interpolate package name');
});
});
});

@@ -26,3 +26,5 @@ var cordova = require('../cordova'),

cordova.create(tempDir);
expect(fs.lstatSync(path.join(tempDir, '.cordova')).isFile()).toBe(true);
var dotc = path.join(tempDir, '.cordova');
expect(fs.lstatSync(dotc).isFile()).toBe(true);
expect(JSON.parse(fs.readFileSync(dotc, 'utf8')).name).toBe("Hello Cordova");
});

@@ -29,0 +31,0 @@ it('should throw if the directory is already a cordova project', function() {

jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
var shell = require('shelljs'),
path = require('path'),
fs = require('fs'),
android_project = path.join(__dirname, 'fixtures', 'projects', 'native', 'android'),
wrench = require('wrench'),
cpr = wrench.copyDirSyncRecursive;
var orig_exec = shell.exec;
shell.exec = function(cmd, opts) {
// Match various commands to exec
if (cmd.match(/android.bin.create/)) {
var r = new RegExp(/android.bin.create"\s"([\/\\\w-_\.]*)"/);
var dir = r.exec(cmd)[1];
cpr(android_project, dir);
fs.chmodSync(path.join(dir, 'cordova', 'debug'), '754');
return {code:0};
}
// Fire off to original exec
return orig_exec.apply(null, arguments);
}

@@ -7,2 +7,4 @@ var cordova = require('../cordova'),

fs = require('fs'),
et = require('elementtree'),
config_parser = require('../src/config_parser'),
tempDir = path.join(__dirname, '..', 'temp');

@@ -18,3 +20,2 @@

});
it('should run inside a Cordova-based project', function() {

@@ -48,2 +49,3 @@ this.after(function() {

cordova.create(tempDir);
process.chdir(tempDir);
});

@@ -56,4 +58,2 @@

it('should list out no platforms for a fresh project', function() {
process.chdir(tempDir);
expect(cordova.platform('ls')).toEqual('No platforms added. Use `cordova platform add <platform>`.');

@@ -66,3 +66,2 @@ });

process.chdir(tempDir);
runs(function() {

@@ -86,2 +85,3 @@ cordova.platform('add', 'android', cb);

cordova.create(tempDir);
process.chdir(tempDir);
});

@@ -94,2 +94,3 @@

describe('without any libraries cloned', function() {
// TODO!
it('should clone down and checkout the correct android library');

@@ -105,3 +106,2 @@ it('should clone down and checkout the correct ios library');

process.chdir(tempDir);
runs(function() {

@@ -115,4 +115,23 @@ cordova.platform('add', 'android', cb);

});
it('should use the correct application name based on what is in config.xml', function() {
var cfg_path = path.join(tempDir, 'www', 'config.xml');
var orig_cfg_contents = fs.readFileSync(cfg_path, 'utf-8');
this.after(function() {
fs.writeFileSync(cfg_path, orig_cfg_contents, 'utf-8');
});
var cfg = new config_parser(cfg_path);
var cb = jasmine.createSpy();
runs(function() {
cfg.name('chim chim');
cordova.platform('add', 'android', cb);
});
waitsFor(function() { return cb.wasCalled; }, "platform add android callback");
runs(function() {
var strings = new et.ElementTree(et.XML(fs.readFileSync(path.join(tempDir, 'platforms', 'android', 'res', 'values', 'strings.xml'), 'utf-8')));
var app_name = strings.find('string[@name="app_name"]').text;
expect(app_name).toBe('chim chim');
});
});
});
describe('ios', function() {

@@ -122,3 +141,2 @@ it('should add a basic ios project', function() {

process.chdir(tempDir);
runs(function() {

@@ -132,8 +150,27 @@ cordova.platform('add', 'ios', cb);

});
it('should use the correct application name based on what is in config.xml', function() {
var cfg_path = path.join(tempDir, 'www', 'config.xml');
var orig_cfg_contents = fs.readFileSync(cfg_path, 'utf-8');
this.after(function() {
fs.writeFileSync(cfg_path, orig_cfg_contents, 'utf-8');
});
var cfg = new config_parser(cfg_path);
var cb = jasmine.createSpy();
runs(function() {
cfg.name('upon closer inspection they appear to be loafers');
cordova.platform('add', 'ios', cb);
});
waitsFor(function() { return cb.wasCalled; }, "platform add ios callback");
runs(function() {
var pbxproj = fs.readFileSync(path.join(tempDir, 'platforms', 'ios', 'upon_closer_inspection_they_appear_to_be_loafers.xcodeproj', 'project.pbxproj'), 'utf-8');
expect(pbxproj.match(/PRODUCT_NAME\s*=\s*"upon closer inspection they appear to be loafers"/)[0]).toBe('PRODUCT_NAME = "upon closer inspection they appear to be loafers"');
});
});
});
});
describe('remove', function() {
beforeEach(function() {
cordova.create(tempDir);
process.chdir(tempDir);
});

@@ -149,3 +186,2 @@

process.chdir(tempDir);
runs(function() {

@@ -152,0 +188,0 @@ cordova.platform('add', 'ios', cbone);

@@ -150,2 +150,7 @@ var cordova = require('../cordova'),

});
describe('on Android', function() {
it('should properly change any imports of ".R" to match the app\'s package name', function() {
});
});
});

@@ -152,0 +157,0 @@ });

var cordova_util = require('./util'),
path = require('path'),
exec = require('child_process').exec,
config_parser = require('./config_parser'),
fs = require('fs'),
shell = require('shelljs'),
wrench = require('wrench'),
rmrf = wrench.rmdirSyncRecursive,
cpr = wrench.copyDirSyncRecursive,
config_parser = require('./config_parser'),
fs = require('fs'),
asyncblock = require('asyncblock'),
et = require('elementtree'),
android_parser= require('./metadata/android_parser'),
ios_parser = require('./metadata/ios_parser'),
n = require('ncallbacks'),
util = require('util');
function shell_out_to_debug(projectRoot, platform, www_target, js) {
// Clean out the existing www.
shell.rm('-rf', www_target);
// Copy app assets into native package
cpr(path.join(projectRoot, 'www'), www_target);
// Copy in the appropriate JS
var jsPath = path.join(www_target, 'cordova.js');
fs.writeFileSync(jsPath, fs.readFileSync(js));
// shell out to debug command
var cmd = path.join(projectRoot, 'platforms', platform, 'cordova', 'debug > /dev/null');
var response = shell.exec(cmd, {silent:true});
if (response.code > 0) throw 'An error occurred while building the ' + platform + ' project. ' + response.output;
}
module.exports = function build (callback) {

@@ -23,4 +41,2 @@ var projectRoot = cordova_util.isCordova(process.cwd());

var cfg = new config_parser(xml);
var name = cfg.name();
var id = cfg.packageName();
var platforms = cfg.ls_platforms();

@@ -30,49 +46,33 @@

asyncblock(function(flow) {
var end = n(platforms.length, function() {
if (callback) callback();
});
// Iterate over each added platform
platforms.map(function(platform) {
// Figure out paths based on platform
var assetsPath, js;
switch (platform) {
case 'android':
assetsPath = path.join(projectRoot, 'platforms', 'android', 'assets', 'www');
js = path.join(__dirname, '..', 'lib', 'android', 'framework', 'assets', 'js', 'cordova.android.js');
// Iterate over each added platform
platforms.forEach(function(platform) {
// Figure out paths based on platform
var assetsPath, js, parser;
switch (platform) {
case 'android':
assetsPath = path.join(projectRoot, 'platforms', 'android', 'assets', 'www');
js = path.join(__dirname, '..', 'lib', 'android', 'framework', 'assets', 'js', 'cordova.android.js');
parser = new android_parser(path.join(projectRoot, 'platforms', 'android'));
// Update the related platform project from the config
parser.update_from_config(cfg);
shell_out_to_debug(projectRoot, 'android', assetsPath, js);
end();
break;
case 'ios':
assetsPath = path.join(projectRoot, 'platforms', 'ios', 'www');
js = path.join(__dirname, '..', 'lib', 'ios', 'CordovaLib', 'javascript', 'cordova.ios.js');
parser = new ios_parser(path.join(projectRoot, 'platforms', 'ios'));
// Update the related platform project from the config
parser.update_from_config(cfg, function() {
shell_out_to_debug(projectRoot, 'ios', assetsPath, js);
end();
});
break;
}
// update activity name
var stringsXml = path.join(projectRoot, 'platforms', 'android', 'res', 'values', 'strings.xml');
var strings = new et.ElementTree(et.XML(fs.readFileSync(stringsXml, 'utf-8')));
strings.find('string[@name="app_name"]').text = name;
fs.writeFileSync(stringsXml, strings.write(), 'utf-8');
break;
case 'ios':
assetsPath = path.join(projectRoot, 'platforms', 'ios', 'www');
js = path.join(__dirname, '..', 'lib', 'ios', 'CordovaLib', 'javascript', 'cordova.ios.js');
// TODO: update activity name
break;
}
// Clean out the existing www.
rmrf(assetsPath);
// Copy app assets into native package
cpr(assets, assetsPath);
// Copy in the appropriate JS
var jsPath = path.join(assetsPath, 'cordova.js');
fs.writeFileSync(jsPath, fs.readFileSync(js));
// shell out to debug command
var cmd = path.join(projectRoot, 'platforms', platform, 'cordova', 'debug > /dev/null');
exec(cmd, flow.set({
key:'debug',
firstArgIsError:false,
responseFormat:['err', 'stdout', 'stderr']
}));
var buffers = flow.get('debug');
if (buffers.err) throw 'An error occurred while building the ' + platform + ' project. ' + buffers.err;
if (callback) callback();
});
});
};

@@ -5,5 +5,5 @@ var et = require('elementtree'),

function config_parser(xmlPath) {
this.path = xmlPath;
this.doc = new et.ElementTree(et.XML(fs.readFileSync(xmlPath, 'utf-8')));
function config_parser(path) {
this.path = path;
this.doc = new et.ElementTree(et.XML(fs.readFileSync(path, 'utf-8')));
}

@@ -48,3 +48,3 @@

update:function() {
fs.writeFileSync(this.path, this.doc.write(), 'utf-8');
fs.writeFileSync(this.path, this.doc.write({indent: 4}), 'utf-8');
}

@@ -51,0 +51,0 @@ };

@@ -47,3 +47,7 @@ var wrench = require('wrench'),

fs.writeFileSync(dotCordova, 'do or do not. there is no try.');
// Write out .cordova file with a simple json manifest
fs.writeFileSync(dotCordova, JSON.stringify({
id:id,
name:name
}));

@@ -50,0 +54,0 @@ // Copy in base template

var cordova_util = require('./util'),
path = require('path'),
exec = require('child_process').exec,
shell = require('shelljs'),
config_parser = require('./config_parser'),

@@ -22,7 +22,6 @@ fs = require('fs'),

var cmd = path.join(projectRoot, 'platforms', platform, 'cordova', 'emulate');
exec(cmd, function(err, stderr, stdout) {
if (err) throw 'An error occurred while emulating/deploying the ' + platform + ' project.' + err;
});
var em = shell.exec(cmd, {silent:true});
if (em.code > 0) throw 'An error occurred while emulating/deploying the ' + platform + ' project.' + em.output;
});
};

@@ -7,11 +7,7 @@ var config_parser = require('./config_parser'),

rmrf = wrench.rmdirSyncRecursive,
exec = require('child_process').exec,
path = require('path'),
asyncblock = require('asyncblock');
android_parser= require('./metadata/android_parser'),
ios_parser = require('./metadata/ios_parser'),
shell = require('shelljs');
var repos = {
ios:'https://git-wip-us.apache.org/repos/asf/incubator-cordova-ios.git',
android:'https://git-wip-us.apache.org/repos/asf/incubator-cordova-android.git'
};
module.exports = function platform(command, target, callback) {

@@ -36,65 +32,38 @@ var projectRoot = cordova_util.isCordova(process.cwd());

case 'add':
asyncblock(function(flow) {
// Add the platform to the config.xml
cfg.add_platform(target);
var output = path.join(projectRoot, 'platforms', target);
var output = path.join(projectRoot, 'platforms', target);
// Do we have the cordova library for this platform?
if (!cordova_util.havePlatformLib(target)) {
// Shell out to git.
var outPath = path.join(__dirname, '..', 'lib', target);
var cmd = util.format('git clone %s %s', repos[target], outPath);
// If the Cordova library for this platform is missing, get it.
if (!cordova_util.havePlatformLib(target)) {
cordova_util.getPlatformLib(target);
}
console.log('Cloning ' + repos[target] + ', this may take a while...');
exec(cmd, flow.set({
key:'cloning',
firstArgIsError:false,
responseFormat:['err', 'stdout', 'stderr']
}));
var buffers = flow.get('cloning');
if (buffers.err) {
cfg.remove_platform(target);
throw ('An error occured during git-clone of ' + repos[target] + '. ' + buffers.err);
// Create a platform app using the ./bin/create scripts that exist in each repo.
// TODO: eventually refactor to allow multiple versions to be created.
// Check if output directory already exists.
if (fs.existsSync(output)) {
throw 'Platform "' + target + '" already exists'
} else {
// directory doesn't exist, run platform's create script
var bin = path.join(__dirname, '..', 'lib', target, 'bin', 'create');
var pkg = cfg.packageName().replace(/[^\w.]/g,'_');
var name = cfg.name().replace(/\W/g,'_');
var command = util.format('"%s" "%s" "%s" "%s"', bin, output, pkg, name);
var create = shell.exec(command, {silent:true});
if (create.code > 0) {
throw ('An error occured during creation of ' + target + ' sub-project. ' + create.output);
} else {
cfg.add_platform(target);
switch(target) {
case 'android':
var android = new android_parser(output);
android.update_from_config(cfg);
if (callback) callback();
break;
case 'ios':
var ios = new ios_parser(output);
ios.update_from_config(cfg, callback);
break;
}
// Check out the right version. Currently: 2.1.0rc1.
cmd = util.format('cd "%s" && git checkout 2.1.0rc1', outPath);
exec(cmd, flow.set({
key:'tagcheckout',
firstArgIsError:false,
responseFormat:['err', 'stdout', 'stderr']
}));
buffers = flow.get('tagcheckout');
if (buffers.err) {
cfg.remove_platform(target);
throw ('An error occured during git-checkout of ' + outPath + ' to tag 2.1.0rc1. ' + buffers.err);
}
}
// Create a platform app using the ./bin/create scripts that exist in each repo.
// TODO: eventually refactor to allow multiple versions to be created.
// Check if output dir already exists.
try {
fs.lstatSync(output);
// TODO: this platform dir already exists. what do we do?
} catch(e) {
// Doesn't exist, continue.
var bin = path.join(__dirname, '..', 'lib', target, 'bin', 'create');
var pkg = cfg.packageName().replace(/[^\w.]/g,'_');
var name = cfg.name().replace(/\W/g,'_');
var command = util.format('"%s" "%s" "%s" "%s"', bin, output, pkg, name);
child = exec(command, flow.set({
key:'create',
firstArgIsError:false,
responseFormat:['err', 'stdout', 'stderr']
}));
var bfrs = flow.get('create');
if (bfrs.err) {
cfg.remove_platform(target);
throw ('An error occured during creation of ' + target + ' sub-project. ' + bfrs.err);
} else {
if (callback) callback();
}
}
});
}
break;

@@ -101,0 +70,0 @@ case 'remove':

@@ -7,6 +7,5 @@ var cordova_util = require('./util'),

path = require('path'),
shell = require('shelljs'),
config_parser = require('./config_parser'),
plugin_parser = require('./plugin_parser'),
exec = require('child_process').exec,
asyncblock = require('asyncblock'),
ls = fs.readdirSync;

@@ -77,38 +76,29 @@

asyncblock(function(flow) {
// Iterate over all matchin app-plugin platforms in the project and install the
// plugin.
intersection.forEach(function(platform) {
var cmd = util.format('%s %s "%s" "%s"', cli, platform, path.join(projectRoot, 'platforms', platform), target);
var key = 'pluginstall-' + platform;
exec(cmd, flow.set({
key:key,
firstArgIsError:false,
responseFormat:['err', 'stdout', 'stderr']
}));
var buffers = flow.get(key);
if (buffers.err) throw 'An error occured during plugin installation for ' + platform + '. ' + buffers.err;
});
// Add the plugin web assets to the www folder as well
// TODO: assumption that web assets go under www folder
// inside plugin dir; instead should read plugin.xml
wwwContents.forEach(function(asset) {
asset = path.resolve(path.join(pluginWww, asset));
var info = fs.lstatSync(asset);
var name = asset.substr(asset.lastIndexOf('/')+1);
var wwwPath = path.join(projectWww, name);
if (info.isDirectory()) {
cpr(asset, wwwPath);
} else {
fs.writeFileSync(wwwPath, fs.readFileSync(asset));
}
});
// Iterate over all matchin app-plugin platforms in the project and install the
// plugin.
intersection.forEach(function(platform) {
var cmd = util.format('%s %s "%s" "%s"', cli, platform, path.join(projectRoot, 'platforms', platform), target);
var plugin_cli = shell.exec(cmd, {silent:true});
if (plugin_cli.code > 0) throw 'An error occured during plugin installation for ' + platform + '. ' + cli.output;
});
// Add the plugin web assets to the www folder as well
// TODO: assumption that web assets go under www folder
// inside plugin dir; instead should read plugin.xml
wwwContents.forEach(function(asset) {
asset = path.resolve(path.join(pluginWww, asset));
var info = fs.lstatSync(asset);
var name = asset.substr(asset.lastIndexOf('/')+1);
var wwwPath = path.join(projectWww, name);
if (info.isDirectory()) {
cpr(asset, wwwPath);
} else {
fs.writeFileSync(wwwPath, fs.readFileSync(asset));
}
});
// Finally copy the plugin into the project
cpr(target, path.join(pluginPath, targetName));
// Finally copy the plugin into the project
cpr(target, path.join(pluginPath, targetName));
if (callback) callback();
});
if (callback) callback();
break;

@@ -115,0 +105,0 @@ case 'remove':

var fs = require('fs'),
path = require('path');
path = require('path'),
util = require('util'),
shell = require('shelljs');
var repos = {
ios:'https://git-wip-us.apache.org/repos/asf/incubator-cordova-ios.git',
android:'https://git-wip-us.apache.org/repos/asf/incubator-cordova-android.git'
};
module.exports = {

@@ -25,11 +32,38 @@ // Runs up the directory chain looking for a .cordova directory.

var dir = path.join(__dirname, '..', 'lib', platform);
try {
fs.lstatSync(dir);
// Have it!
return true;
} catch(e) {
// Don't have it.
return false;
return fs.existsSync(dir);
},
/**
* checkout a platform from the git repo
* @param target string platform to get (enum of 'ios' or 'android' for now)
* @param flow I/O object to handle synchronous sys calls
* @throws Javascript Error on failure
*/
getPlatformLib: function getPlatformLib(target) {
if (!repos[target]) {
// TODO: this is really a pretty terrible pattern because it kills
// excecution immediately and prevents cleanup routines. However,
// I don't want to just spew a stack trace to the user either.
console.error('platform "' + target + '" not found.');
process.exit(1);
}
// specify which project tag to check out. minimum tag is 2.1.0rc1
var cordova_lib_tag = '2.1.0';
// Shell out to git.
var outPath = path.join(__dirname, '..', 'lib', target);
var cmd = util.format('git clone %s "%s"', repos[target], outPath);
console.log('Cloning ' + repos[target] + ', this may take a while...');
var clone = shell.exec(cmd, {silent:true});
if (clone.code > 0) {
throw ('An error occured during git-clone of ' + repos[target] + '. ' + clone.output);
}
// Check out the right version.
cmd = util.format('cd "%s" && git checkout %s', outPath, cordova_lib_tag);
var checkout = shell.exec(cmd, {silent:true});
if (checkout.code > 0) {
throw ('An error occured during git-checkout of ' + outPath + ' to tag ' + cordova_lib_tag + '. ' + checkout.output);
}
}
};
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