You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2013/06/07 03:31:08 UTC

[01/22] updating cordova-android and cordova-ios libs to 2.8.0rc1

Updated Branches:
  refs/heads/2.8.x 9f3431a36 -> a2f158653
Updated Tags:  refs/tags/2.8.0 [created] a2f158653


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-ios/CordovaLibTests/ExifTests.m
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLibTests/ExifTests.m b/lib/cordova-ios/CordovaLibTests/ExifTests.m
index 960ac95..dfd6da4 100644
--- a/lib/cordova-ios/CordovaLibTests/ExifTests.m
+++ b/lib/cordova-ios/CordovaLibTests/ExifTests.m
@@ -1,154 +1,171 @@
-//
-//  ExifTestTests.m
-//  ExifTestTests
-//
-//  Created by Lorin Beer on 2013-03-18.
-//
-//
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
 
 #import <SenTestingKit/SenTestingKit.h>
 
 #import "ExifTestTests.h"
 #import "../ExifTest/CDVJpegHeaderWriter.m"
 
-
 @implementation ExifTestTests
 
 - (void)setUp
 {
     [super setUp];
     testHeaderWriter = [[CDVJpegHeaderWriter alloc] init];
-    testErrorThreshhold = [NSNumber numberWithDouble: 0.000001];
-    NSLog(@"%x", ~10+1);
-    
-    
+    testErrorThreshhold = [NSNumber numberWithDouble:0.000001];
+    NSLog(@"%x", ~10 + 1);
 }
 
 - (void)tearDown
 {
     // Tear-down code here.
-    
+
     [super tearDown];
 }
 
-//==================================================================================================
+// ==================================================================================================
 // rational approximation of decimal by continued fraction tests
-//==================================================================================================
+// ==================================================================================================
 
 // tests continued fraction with random int
-- (void)testContinuedFractionWithUInt {
+- (void)testContinuedFractionWithUInt
+{
     NSLog(@"Continued Fraction Test with random int value, numerator should be generated value, denominator should be 1");
-    NSNumber * numerator = @0;
-    NSNumber * denominator = @0;
-    NSNumber * testValue = [NSNumber numberWithInt: abs(arc4random())];
-    [testHeaderWriter decimalToUnsignedRational: testValue
-                  withResultNumerator: &numerator
-                withResultDenominator: &denominator];
+    NSNumber* numerator = @0;
+    NSNumber* denominator = @0;
+    NSNumber* testValue = [NSNumber numberWithInt:abs(arc4random())];
+    [testHeaderWriter decimalToUnsignedRational:testValue
+                            withResultNumerator:&numerator
+                          withResultDenominator:&denominator];
     STAssertEquals([numerator intValue],
-                   [testValue intValue],
-                   @"Numerator did not match");
+        [testValue intValue],
+        @"Numerator did not match");
     STAssertEquals([denominator intValue],
-                   1,
-                   @"denominator was not one");
+        1,
+        @"denominator was not one");
 }
 
 // tests continued fraction with random float
-- (void)testContinuedFractionWithUFloat {
+- (void)testContinuedFractionWithUFloat
+{
     NSLog(@"Continued Fraction Test with random double value, resulting fraction should be within acceptable error threshhold");
-    NSNumber * threshhold = @0.1;
-    NSNumber * numerator = @0;
-    NSNumber * denominator = @0;
-    NSLog(@"%f",((double)arc4random() / ARC4RANDOM_MAX) * 100.0f);
-    NSNumber * testValue = [NSNumber numberWithDouble:
-                                ((double)arc4random() / ARC4RANDOM_MAX) * 100.0f];
-
-    [testHeaderWriter decimalToUnsignedRational: testValue
-                            withResultNumerator: &numerator
-                          withResultDenominator: &denominator];
-    NSLog(@"%lf, %lf",[testValue doubleValue], [numerator doubleValue]/[denominator doubleValue]);
+    NSNumber* threshhold = @0.1;
+    NSNumber* numerator = @0;
+    NSNumber* denominator = @0;
+    NSLog(@"%f", ((double)arc4random() / ARC4RANDOM_MAX) * 100.0f);
+    NSNumber* testValue = [NSNumber numberWithDouble:
+        ((double)arc4random() / ARC4RANDOM_MAX) * 100.0f];
+
+    [testHeaderWriter decimalToUnsignedRational:testValue
+                            withResultNumerator:&numerator
+                          withResultDenominator:&denominator];
+    NSLog(@"%lf, %lf", [testValue doubleValue], [numerator doubleValue] / [denominator doubleValue]);
 
     STAssertEqualsWithAccuracy([testValue doubleValue],
-                               [numerator doubleValue]/[denominator doubleValue],
-                               [threshhold doubleValue],
-                               @"rational approximation did not meet acceptable error threshhold");
-    
+        [numerator doubleValue] / [denominator doubleValue],
+        [threshhold doubleValue],
+        @"rational approximation did not meet acceptable error threshhold");
 }
 
 // tests continued fraction in sqrt(2) worst case
-- (void)testContinuedFractionsWorstCase {
+- (void)testContinuedFractionsWorstCase
+{
     NSLog(@"Continued Fraction Test with provable worst case ~sqrt(2), resulting fraction should be within acceptable error threshhold");
-    NSNumber * threshhold = @0.1;
-    NSNumber * numerator = @0;
-    NSNumber * denominator = @0;
-    NSNumber * testValue = [NSNumber numberWithDouble: sqrt(2)];
-    [testHeaderWriter decimalToUnsignedRational: testValue
-                            withResultNumerator: &numerator
-                          withResultDenominator: &denominator];
+    NSNumber* threshhold = @0.1;
+    NSNumber* numerator = @0;
+    NSNumber* denominator = @0;
+    NSNumber* testValue = [NSNumber numberWithDouble:sqrt(2)];
+    [testHeaderWriter decimalToUnsignedRational:testValue
+                            withResultNumerator:&numerator
+                          withResultDenominator:&denominator];
     STAssertEqualsWithAccuracy([testValue doubleValue],
-                               [numerator doubleValue]/[denominator doubleValue],
-                               [threshhold doubleValue],
-                               @"rational approximation did not meet acceptable error threshhold");
+        [numerator doubleValue] / [denominator doubleValue],
+        [threshhold doubleValue],
+        @"rational approximation did not meet acceptable error threshhold");
 }
 
 // tests format hex from a decimal
-- (void) testFormatHexFromDecimal {
-    NSNumber * testValue = @1;
-    NSNumber * testPlaces = @8;
-    NSString * result = nil;
-    result = [testHeaderWriter formattedHexStringFromDecimalNumber: testValue
-                                                        withPlaces: testPlaces];
+- (void)testFormatHexFromDecimal
+{
+    NSNumber* testValue = @1;
+    NSNumber* testPlaces = @8;
+    NSString* result = nil;
+
+    result = [testHeaderWriter formattedHexStringFromDecimalNumber:testValue
+                                                        withPlaces:testPlaces];
     // assert not nil
     STAssertNotNil(result, @"nil renturned from formattedHexStringFromDecimalNumber");
     // assert correct number of places
     STAssertEquals([result length], [testPlaces unsignedIntegerValue],
-                   @"returned string to wrong number of places. Should be = %i Was = %i",
-                   [testPlaces intValue],
-                   [result length]);
+        @"returned string to wrong number of places. Should be = %i Was = %i",
+        [testPlaces intValue],
+        [result length]);
     // assert correct hex representation
     STAssertTrueNoThrow([result isEqualToString:@"00000001"], @"result should be equal to @00000001");
-
 }
 
 // tests format number string with leading zeroes
-- (void) testFormatNumberWithLeadingZeroes {
-    NSString * result = nil;
-    NSNumber * testValue = @8769; // Exif SubIFD Offset Tag
-    NSNumber * testPlaces = @6;
-    result = [testHeaderWriter formatNumberWithLeadingZeroes: testValue
-                                                  withPlaces: testPlaces];
+- (void)testFormatNumberWithLeadingZeroes
+{
+    NSString* result = nil;
+    NSNumber* testValue = @8769;  // Exif SubIFD Offset Tag
+    NSNumber* testPlaces = @6;
+
+    result = [testHeaderWriter formatNumberWithLeadingZeroes:testValue
+                                                  withPlaces:testPlaces];
     STAssertNotNil(result, @"nil renturned from formattedHexStringFromDecimalNumber");
     STAssertEquals([result length],
-                   [testPlaces unsignedIntegerValue],
-                   @"returned string to wrong number of places. Should be = %i Was = %i",
-                   [testPlaces intValue],
-                   [result length]);
+        [testPlaces unsignedIntegerValue],
+        @"returned string to wrong number of places. Should be = %i Was = %i",
+        [testPlaces intValue],
+        [result length]);
     // assert correct hex representation
     STAssertTrueNoThrow([result isEqualToString:@"008769"], @"result was = %@ should be = @008769", result);
 }
 
-- (void) testUnsignedRationalToString {
-    NSString * result = nil;
-    NSNumber * numerator = @1;
-    NSNumber * denominator = @10;
-    result = [testHeaderWriter formatRationalWithNumerator: numerator
-                                           withDenominator: denominator
-                                                  asSigned: FALSE];
+- (void)testUnsignedRationalToString
+{
+    NSString* result = nil;
+    NSNumber* numerator = @1;
+    NSNumber* denominator = @10;
+
+    result = [testHeaderWriter formatRationalWithNumerator:numerator
+                                           withDenominator:denominator
+                                                  asSigned:FALSE];
     NSLog(result);
     STAssertNotNil(result, @"nil returned from testUnsignedRationalToString");
-    STAssertTrueNoThrow([result length]==16, @"returned string with wrong length. Exif rationals are 8 bytes, string has %ld bytes",[result length]/2);
+    STAssertTrueNoThrow([result length] == 16, @"returned string with wrong length. Exif rationals are 8 bytes, string has %ld bytes", [result length] / 2);
     STAssertTrueNoThrow([result isEqualToString:@"000000010000000a"], @"result was = %@ should be = @0000000100000010", result);
 }
 
-- (void) testSignedRationalToString {
-    NSString * result = nil;
-    NSNumber * numerator = @-1;
-    NSNumber * denominator = @-10;
-    result = [testHeaderWriter formatRationalWithNumerator: numerator
-                                           withDenominator: denominator
-                                                  asSigned: TRUE];
+- (void)testSignedRationalToString
+{
+    NSString* result = nil;
+    NSNumber* numerator = @ - 1;
+    NSNumber* denominator = @ - 10;
+
+    result = [testHeaderWriter formatRationalWithNumerator:numerator
+                                           withDenominator:denominator
+                                                  asSigned:TRUE];
     NSLog(result);
     STAssertNotNil(result, @"nil returned from testSignedRationalToString");
-    STAssertTrueNoThrow([result length]==16, @"returned string with wrong length. Exif rationals are 8 bytes, string has %ld bytes",[result length]/2);
+    STAssertTrueNoThrow([result length] == 16, @"returned string with wrong length. Exif rationals are 8 bytes, string has %ld bytes", [result length] / 2);
     STAssertTrueNoThrow([result isEqualToString:@"fffffffffffffff6"], @"result was = %@ should be = @000000FF000000F6", result);
 }
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-ios/RELEASENOTES.md
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/RELEASENOTES.md b/lib/cordova-ios/RELEASENOTES.md
index 3c2031a..9c50659 100644
--- a/lib/cordova-ios/RELEASENOTES.md
+++ b/lib/cordova-ios/RELEASENOTES.md
@@ -19,8 +19,44 @@
 #
 -->
 ## Release Notes for Cordova (iOS) ##
- 
- Cordova is a static library that enables developers to include the Cordova API in their iOS application projects easily, and also create new Cordova-based iOS application projects through the command-line.
+
+Update these notes using: git log --pretty=format:'* %s' --topo-order --no-merges origin/2.7.x...HEAD
+
+Cordova is a static library that enables developers to include the Cordova API in their iOS application projects easily, and also create new Cordova-based iOS application projects through the command-line.
+
+### 2.8.0 (201305XX) ###
+
+* [CB-2840] Nil checks to avoid crash when network disconnected
+* [CB-3416] adding empty <plugins> element during deprecation window.
+* [CB-3006] Customize InAppBrowser location bar
+* [CB-3405] InAppBrowser option to hide bottom bar with Done/History buttons
+* [CB-3394] Cordova iOS crashes when multiple access elements in config.xml
+* [CB-3166] Add deprecation notice for use of <plugin> in config.xml in iOS
+* [CB-2905] Exif geolocation meta data tag writing
+* [CB-3307] Rename cordova-ios.js -> cordova.js
+* [CB-1108] Convert <plugin> -> <feature> with <param>
+* [CB-3321] Fix bogus "failed whitelist" log messages
+* [CB-3311] add default textbox for notification prompt
+* [CB-2846] SplashScreen crashes app when image not available
+* [CB-2789] Remove CaptureOptions.mode support.
+* [CB-3295] Send InAppBrowser loadstart events when redirects occur
+* [CB-2896] added ImageIO and OpenAL system frameworks to support new exif functionality in CDVCamera
+* [CB-2896] writing data to object through CGImageDestinationRef, enables multipart exif tag writing
+* [CB-2958] simple fix, moved write to photealbum code and sourced from modified data. Photo data returned by cordova will match photo on cameraroll
+* [CB-3339] add version to command line scripts
+* [CB-3377] Remove cordova/release script
+* [CB-2974] Add a ./cordova/lib/list-devices project-level helper script to iOS
+* [CB-2951] Add a ./cordova/lib/list-emulator-images project-level helper script to iOS
+* [CB-2974] Add a ./cordova/lib/list-devices project-level helper script to iOS
+* [CB-2966] Add a ./cordova/lib/list-started-emulators as project-level helper script to iOS
+* [CB-2990] Add a ./cordova/lib/install-device project-level helper script to iOS
+* [CB-2982] Add a ./cordova/lib/install-emulator project-level helper script to iOS
+* [CB-2998] Add a ./cordova/lib/start-emulator project-level helper script to iOS
+* [CB-2916] Add a ./cordova/clean project-level script for iOS
+* [CB-2053] Update UIImagePickerController label to reflect video media type in CDVCamera
+* [CB-3530] PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1"
+
+<br />
 
 ### 2.7.0 (201304XX) ###
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-ios/bin/templates/project/__TESTING__/config.xml
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/bin/templates/project/__TESTING__/config.xml b/lib/cordova-ios/bin/templates/project/__TESTING__/config.xml
index ca292c8..db64661 100644
--- a/lib/cordova-ios/bin/templates/project/__TESTING__/config.xml
+++ b/lib/cordova-ios/bin/templates/project/__TESTING__/config.xml
@@ -1,4 +1,22 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
 <widget xmlns     = "http://www.w3.org/ns/widgets"
         id        = "io.cordova.helloCordova"
         version   = "2.0.0">

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-ios/bin/uncrustify.cfg
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/bin/uncrustify.cfg b/lib/cordova-ios/bin/uncrustify.cfg
index d52ce33..1e3099b 100644
--- a/lib/cordova-ios/bin/uncrustify.cfg
+++ b/lib/cordova-ios/bin/uncrustify.cfg
@@ -1,4 +1,20 @@
-# Uncrustify 0.59
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
 # Based off of https://gist.github.com/261662/
 
 #

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-ios/guides/Cordova Plugin Upgrade Guide.md
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/guides/Cordova Plugin Upgrade Guide.md b/lib/cordova-ios/guides/Cordova Plugin Upgrade Guide.md
index 7a03bc4..8fc3776 100644
--- a/lib/cordova-ios/guides/Cordova Plugin Upgrade Guide.md	
+++ b/lib/cordova-ios/guides/Cordova Plugin Upgrade Guide.md	
@@ -22,6 +22,71 @@
 
 This document is for developers who need to upgrade their Cordova  plugins to a newer Cordova version. Starting with Cordova 1.5.0, some classes have been renamed, which will require the plugin to be upgraded. Make sure your project itself has been upgraded using the [Cordova iOS Upgrading Guide](http://cordova.apache.org/docs/en/edge/guide_upgrading_ios_index.md.html#Upgrading%20Cordova%20iOS) document.
 
+## Upgrading older Cordova plugins to 2.8.0 ##
+
+1. **Install** Cordova 2.8.0
+2. Follow the **"Upgrading older Cordova plugins to 2.7.0"** section, if necessary
+3. The &lt;plugin&gt; tag in **config.xml** has been deprecated and support will be removed in 3.0.0. To upgrade to the &lt;feature&gt; tag, see this example:
+
+        <plugins>
+            <plugin name="LocalStorage" value="CDVLocalStorage" />
+            <!-- other plugins -->
+        </plugins>
+        
+        <!-- change to: (note that a <feature> tag is on the same level as <plugins> -->
+        <feature name="LocalStorage">
+        <param name="ios-package" value="CDVLocalStorage" />
+        </feature>
+        
+
+## Upgrading older Cordova plugins to 2.7.0 ##
+
+1. **Install** Cordova 2.7.0
+2. Follow the **"Upgrading older Cordova plugins to 2.6.0"** section, if necessary
+3. The old cordova.exec signature has been deprecated since 2.1, and removed in 2.7.0. See upgrade steps below.
+
+When you use a method signature in JavaScript like this:
+
+        cordova.exec('MyService.myMethod', myArg1, myArg2, myArg3);
+
+
+The console log will ask you to upgrade it like this:
+
+        The old format of this exec call has been removed (deprecated since 2.1). 
+        Change to: cordova.exec(null, null, "MyService", "myMethod", [ myArg1, myArg2, myArg3 ]);
+
+
+But, if your corresponding Objective-C method uses the old signature like so:
+
+        - (void) myMethod:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
+
+
+Update it to this new signature:
+
+        - (void) myMethod:(CDVInvokedUrlCommand*)command;
+
+Also update any references to "arguments" in the method body with "command.arguments".
+
+So if your method looked like this:
+
+		- (void) myMethod:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
+		{
+			NSString* myArgs1 = [arguments objectAtIndex:0];
+			NSString* myArgs2 = [arguments objectAtIndex:1];
+			NSString* myArgs3 = [arguments objectAtIndex:2];
+		}
+
+Change it to this:
+
+		- (void) myMethod:(CDVInvokedUrlCommand*)command
+		{
+			NSString* myArgs1 = [command.arguments objectAtIndex:0];
+			NSString* myArgs2 = [command.arguments objectAtIndex:1];
+			NSString* myArgs3 = [command.arguments objectAtIndex:2];
+		}
+
+This is the easiest upgrade path. If you want to further use the more powerful callback mechanisms provided, see the [Plugin Development Guide](http://docs.phonegap.com/en/2.7.0/guide_plugin-development_ios_index.md.html#Developing%20a%20Plugin%20on%20iOS) to upgrade your plugin.
+
 ## Upgrading older Cordova plugins to 2.6.0 ##
 
 1. **Install** Cordova 2.6.0


[17/22] git commit: updated SDK locations and minimum setup in README

Posted by fi...@apache.org.
updated SDK locations and minimum setup in README


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/4621cb7f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/4621cb7f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/4621cb7f

Branch: refs/heads/2.8.x
Commit: 4621cb7fd229303244539f60def5516336022f66
Parents: f5baa6e
Author: Fil Maj <ma...@gmail.com>
Authored: Thu Jun 6 10:36:08 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 6 18:30:13 2013 -0700

----------------------------------------------------------------------
 README.md |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/4621cb7f/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 2ea3da4..763f61b 100644
--- a/README.md
+++ b/README.md
@@ -8,13 +8,13 @@
 
 * [nodejs](http://nodejs.org/)
 * SDKs for every platform you wish to support
-  - [BlackBerry WebWorks SDK](http://developer.blackberry.com)
-  - [iOS SDK](http://developer.apple.com) with the latest Xcode and Xcode Command Line Tools
+  - BlackBerry 10: [BlackBerry 10 WebWorks SDK](http://developer.blackberry.com/html5/download/) as well as the [BlackBerry 10 NDK](http://developer.blackberry.com/native/download/). You will also need to have the NDK environment variables on your path by running `bb10ndk/bbndk-env.sh`.
+  - iOS: [iOS SDK](http://developer.apple.com) with the latest Xcode and Xcode Command Line Tools
   - [Android SDK](http://developer.android.com) - **NOTE** This tool
     will not work unless you have the absolute latest updates for all
     Android SDK components. Also you will need the SDK's `tools` and `platform-tools` directories on your __system path__ otherwise Android support will fail.
 
-cordova-cli has been tested on Mas OS X and Linux.
+cordova-cli has been tested on Mas OS X, Linux, Windows 7 and Windows 8.
 
 # Install
 


[18/22] git commit: npm version 2.8.10. [CB-3624] Re-added support for BB10.

Posted by fi...@apache.org.
npm version 2.8.10. [CB-3624] Re-added support for BB10.


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/dc340238
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/dc340238
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/dc340238

Branch: refs/heads/2.8.x
Commit: dc3402383d954b98b6ff12c6951b16b5e5f5e961
Parents: 4621cb7
Author: Fil Maj <ma...@gmail.com>
Authored: Thu Jun 6 12:26:26 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 6 18:30:17 2013 -0700

----------------------------------------------------------------------
 bin/cordova                                        |    1 +
 package.json                                       |    2 +-
 platforms.js                                       |    2 +-
 spec/cordova-cli/platform.spec.js                  |   38 +++---
 spec/platform-script/blackberry/blackberry.spec.js |   16 ++-
 .../blackberry/blackberry_parser.spec.js           |    5 +-
 src/emulate.js                                     |   23 +++-
 src/metadata/blackberry_parser.js                  |  113 +++++++++++----
 src/prepare.js                                     |    9 +-
 src/run.js                                         |   20 +++-
 10 files changed, 156 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/dc340238/bin/cordova
----------------------------------------------------------------------
diff --git a/bin/cordova b/bin/cordova
index 17b3569..fc47ad1 100755
--- a/bin/cordova
+++ b/bin/cordova
@@ -22,6 +22,7 @@ process.on('uncaughtException', function(err){
 if (verbose) {
     cordova.on('log', console.log);
     cordova.on('warn', console.warn);
+    process.on('uncaughtException', function(err) { console.error(err.stack) });
 }
 
 if (version) {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/dc340238/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index db47513..103ba49 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "cordova",
-  "version": "2.8.9",
+  "version": "2.8.10",
   "preferGlobal": "true",
   "description": "Cordova command line interface tool",
   "main": "cordova",

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/dc340238/platforms.js
----------------------------------------------------------------------
diff --git a/platforms.js b/platforms.js
index 1854695..d41abd3 100644
--- a/platforms.js
+++ b/platforms.js
@@ -35,7 +35,7 @@ module.exports = {
         url    : 'https://git-wip-us.apache.org/repos/asf/cordova-wp8.git'
     },
     blackberry : {
-        parser : require('./metadata/blackberry_parser'),
+        parser : require('./src/metadata/blackberry_parser'),
         url    : 'https://git-wip-us.apache.org/repos/asf/cordova-blackberry.git'
     }
 };

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/dc340238/spec/cordova-cli/platform.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova-cli/platform.spec.js b/spec/cordova-cli/platform.spec.js
index 61a6e7e..301ec4b 100644
--- a/spec/cordova-cli/platform.spec.js
+++ b/spec/cordova-cli/platform.spec.js
@@ -69,7 +69,8 @@ describe('platform command', function() {
 
     describe('`ls`', function() { 
         beforeEach(function() {
-            process.chdir(cordova_project);
+            cordova.create(tempDir);
+            process.chdir(tempDir);
         });
 
         afterEach(function() {
@@ -77,19 +78,14 @@ describe('platform command', function() {
         });
 
         it('should list out no platforms for a fresh project', function() {
-            shell.mv('-f', path.join(cordova_project, 'platforms', '*'), tempDir);
-            this.after(function() {
-                shell.mv('-f', path.join(tempDir, '*'), path.join(cordova_project, 'platforms'));
-            });
+            shell.rm('-rf', path.join(tempDir, 'platforms', '*'));
             expect(cordova.platform('list').length).toEqual(0);
         });
 
-        // TODO: false test as environment where these tests are running may or may not have the specific platform's project built for it. if user does not have the appropriate sdk installed, this will fail.
-        xit('should list out added platforms in a project', function() {
-            process.chdir(tempDir);
-            cordova.create(tempDir);
-            shell.cp('-Rf', path.join(cordova_project, 'platforms', 'android'), path.join(tempDir, 'platforms'));
-            shell.cp('-Rf', path.join(cordova_project, 'platforms', 'blackberry'), path.join(tempDir, 'platforms'));
+        it('should list out added platforms in a project', function() {
+            var platforms = path.join(tempDir, 'platforms');
+            shell.mkdir(path.join(platforms, 'android'));
+            shell.mkdir(path.join(platforms, 'ios'));
             expect(cordova.platform('list').length).toEqual(2);
         });
     });
@@ -118,26 +114,28 @@ describe('platform command', function() {
     });
 
     describe('`remove`',function() {
-        var num_platforms = fs.readdirSync(path.join(cordova_project, 'platforms')).length; 
         beforeEach(function() {
-            process.chdir(cordova_project);
-            shell.cp('-rf', path.join(cordova_project, 'platforms' ,'*'), tempDir);
+            cordova.create(tempDir);
+            process.chdir(tempDir);
         });
 
         afterEach(function() {
             process.chdir(cwd);
-            shell.cp('-rf', path.join(tempDir, '*'), path.join(cordova_project, 'platforms')); 
         });
 
         it('should remove a supported and added platform', function() {
+            shell.mkdir(path.join(tempDir, 'platforms', 'android'));
+            shell.mkdir(path.join(tempDir, 'platforms', 'ios'));
             cordova.platform('remove', 'android');
-            expect(cordova.platform('ls').length).toEqual(num_platforms - 1);
+            expect(cordova.platform('ls').length).toEqual(1);
         });
-        // TODO: fails if environemtn not configured for the specified paltforms.
-        // need to rethink this.
-        xit('should be able to remove multiple platforms', function() {
+
+        it('should be able to remove multiple platforms', function() {
+            shell.mkdir(path.join(tempDir, 'platforms', 'android'));
+            shell.mkdir(path.join(tempDir, 'platforms', 'blackberry'));
+            shell.mkdir(path.join(tempDir, 'platforms', 'ios'));
             cordova.platform('remove', ['android','blackberry']);
-            expect(cordova.platform('ls').length).toEqual(num_platforms - 2);
+            expect(cordova.platform('ls').length).toEqual(1);
         });
     });
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/dc340238/spec/platform-script/blackberry/blackberry.spec.js
----------------------------------------------------------------------
diff --git a/spec/platform-script/blackberry/blackberry.spec.js b/spec/platform-script/blackberry/blackberry.spec.js
index ff997c1..bb59973 100644
--- a/spec/platform-script/blackberry/blackberry.spec.js
+++ b/spec/platform-script/blackberry/blackberry.spec.js
@@ -23,8 +23,7 @@ describe('Test:', function() {
         };
         var fake_create = function(a_path) {
             shell.mkdir('-p', path.join(a_path, 'www'));
-            fs.writeFileSync(path.join(a_path, 'project.properties'), 'hi', 'utf-8');
-            fs.writeFileSync(path.join(a_path, 'build.xml'), 'hi', 'utf-8');
+            fs.writeFileSync(path.join(a_path, 'project.json'), 'hi', 'utf-8');
             shell.cp('-rf', path.join(cordova_project, 'platforms', 'blackberry', 'www', 'config.xml'), path.join(a_path, 'www'));
             sh.mostRecentCall.args[2](0, '');
         };
@@ -61,6 +60,9 @@ describe('Test:', function() {
     describe('\'emulate blackberry\'', function() {
         beforeEach(function() {
             process.chdir(tempDir);
+            spyOn(blackberry_parser.prototype, 'get_cordova_config').andReturn({
+                signing_password:'pwd'
+            });
         });
         afterEach(function() {
             process.chdir(cwd);
@@ -68,13 +70,14 @@ describe('Test:', function() {
         shell.rm('-rf', tempDir);
         cordova.create(tempDir);
         shell.cp('-rf', path.join(cordova_project, 'platforms', 'blackberry'), path.join(tempDir, 'platforms'));
-        it('should shell out to ant command on blackberry', function() {
+        it('should shell out to run command with a specific target', function() {
             var proj_spy = spyOn(blackberry_parser.prototype, 'update_project');
+            spyOn(blackberry_parser.prototype, 'get_all_targets').andReturn([{name:'fakesim',type:'simulator'}]);
             var s = spyOn(require('shelljs'), 'exec');
             cordova.emulate('blackberry');
             proj_spy.mostRecentCall.args[1](); // update_project fake
             expect(s).toHaveBeenCalled();
-            var emulate_cmd = 'ant -f .*build\.xml" qnx load-simulator';
+            var emulate_cmd = 'cordova.run" --target=fakesim -k pwd$';
             expect(s.mostRecentCall.args[0]).toMatch(emulate_cmd);
         });
         it('should call blackberry_parser\'s update_project', function() {
@@ -96,10 +99,9 @@ describe('Test:', function() {
         cordova.create(tempDir);
         shell.cp('-rf', path.join(cordova_project, 'platforms', 'blackberry'), path.join(tempDir, 'platforms'));
         it('should shell out to build command', function() {
-            var build_cmd = 'build.xml" qnx load-device';
             var s = spyOn(require('shelljs'), 'exec').andReturn({code:0});
             cordova.compile('blackberry');
-            expect(s.mostRecentCall.args[0]).toContain(build_cmd);
+            expect(s.mostRecentCall.args[0]).toMatch(/blackberry.cordova.build"$/gi);
         });
     });
-});
\ No newline at end of file
+});

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/dc340238/spec/platform-script/blackberry/blackberry_parser.spec.js
----------------------------------------------------------------------
diff --git a/spec/platform-script/blackberry/blackberry_parser.spec.js b/spec/platform-script/blackberry/blackberry_parser.spec.js
index 0ed2f2c..ec836e4 100644
--- a/spec/platform-script/blackberry/blackberry_parser.spec.js
+++ b/spec/platform-script/blackberry/blackberry_parser.spec.js
@@ -1,4 +1,3 @@
-
 /**
     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file
@@ -204,7 +203,7 @@ describe('blackberry project parser', function() {
                     expect(spyEnv).not.toHaveBeenCalled();
                 });
                 it('should write out project properties', function(done) {
-                    var spyProps = spyOn(parser, 'write_project_properties');
+                    var spyProps = spyOn(parser, 'write_blackberry_environment');
                     parser.update_project(config, function() { 
                         expect(spyProps).toHaveBeenCalled();
                         done();
@@ -229,7 +228,7 @@ describe('blackberry project parser', function() {
                     expect(spyEnv).toHaveBeenCalled();
                 });
                 it('should write out project properties', function(done) {
-                    var spyProps = spyOn(parser, 'write_project_properties');
+                    var spyProps = spyOn(parser, 'write_blackberry_environment');
                     var promptSpy = spyOn(require('prompt'), 'get');
                     parser.update_project(config, function() {
                         expect(spyProps).toHaveBeenCalled();

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/dc340238/src/emulate.js
----------------------------------------------------------------------
diff --git a/src/emulate.js b/src/emulate.js
index a6460c9..2d902b2 100644
--- a/src/emulate.js
+++ b/src/emulate.js
@@ -30,8 +30,20 @@ var cordova_util      = require('./util'),
     hooker            = require('../src/hooker'),
     util              = require('util');
 
-function shell_out_to_emulate(root, platform, callback) {
+function shell_out_to_emulate(root, platform, done) {
     var cmd = '"' + path.join(root, 'platforms', platform, 'cordova', 'run') + '" --debug --emulator';
+    // TODO: inconsistent API for BB10 run command
+    if (platform == 'blackberry') {
+        var bb_project = path.join(root, 'platforms', 'blackberry')
+        var project = new platforms.blackberry.parser(bb_project);
+        if (project.has_simulator_target()) {
+            var bb_config = project.get_cordova_config();
+            var sim = project.get_simulator_targets()[0].name;
+            cmd = '"' + path.join(bb_project, 'cordova', 'run') + '" --target=' + sim + ' -k ' + bb_config.signing_password;
+        } else {
+            throw new Error('No BlackBerry simulator targets defined. If you want to run emulate with BB10, please add a simulator target. For more information run "' + path.join(bb_project, 'cordova', 'target') + '" -h');
+        }
+    }
     events.emit('log', 'Running on emulator for platform "' + platform + '" via command "' + cmd + '" (output to follow)...');
     shell.exec(cmd, {silent:true, async:true}, function(code, output) {
         events.emit('log', output);
@@ -39,7 +51,7 @@ function shell_out_to_emulate(root, platform, callback) {
             throw new Error('An error occurred while emulating/deploying the ' + platform + ' project.' + output);
         } else {
             events.emit('log', 'Platform "' + platform + '" deployed to emulator.');
-            callback();
+            done();
         }
     });
 }
@@ -97,7 +109,12 @@ module.exports = function emulate (platformList, callback) {
             else throw err;
         } else {
             platformList.forEach(function(platform) {
-                shell_out_to_emulate(projectRoot, platform, end);
+                try {
+                    shell_out_to_emulate(projectRoot, platform, end);
+                } catch(e) {
+                    if (callback) callback(e);
+                    else throw e;
+                }
             });
         }
     });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/dc340238/src/metadata/blackberry_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/blackberry_parser.js b/src/metadata/blackberry_parser.js
index e3c6f87..9144d13 100644
--- a/src/metadata/blackberry_parser.js
+++ b/src/metadata/blackberry_parser.js
@@ -26,8 +26,8 @@ var fs            = require('fs'),
     config_parser = require('../config_parser');
 
 module.exports = function blackberry_parser(project) {
-    if (!fs.existsSync(path.join(project, 'project.properties')) || !fs.existsSync(path.join(project, 'build.xml'))) {
-        throw new Error('The provided path "' + project + '" is not a Cordova BlackBerry WebWorks project.');
+    if (!fs.existsSync(path.join(project, 'project.json')) || !fs.existsSync(path.join(project, 'www'))) {
+        throw new Error('The provided path "' + project + '" is not a Cordova BlackBerry10 WebWorks project.');
     }
     this.path = project;
     this.config_path = path.join(this.path, 'www', 'config.xml');
@@ -35,8 +35,11 @@ module.exports = function blackberry_parser(project) {
 };
 
 module.exports.check_requirements = function(callback) {
-    // TODO: below, we ask for users to fill out SDK paths, etc. into config.json. Android requires the sdk path be on the PATH. Which to choose? 
-    callback(false);
+    if (process.env && process.env.QNX_HOST) {
+        callback(false);
+    } else {
+        callback('The BB10NDK environment variable QNX_HOST is missing. Make sure you run `source <path to bb10ndk>/bbndk-env.sh`. Even better, add `source`ing that script to your .bash_profile or equivalent so you don\'t have to do it manually every time.');
+    }
 };
 
 module.exports.prototype = {
@@ -81,16 +84,13 @@ module.exports.prototype = {
         var dotFile = path.join(projectRoot, '.cordova', 'config.json');
         var dot = JSON.parse(fs.readFileSync(dotFile, 'utf-8'));
         if (dot.blackberry === undefined || dot.blackberry.qnx === undefined) {
-            events.emit('warn', 'WARNING! Missing BlackBerry configuration file.');
+            events.emit('warn', 'WARNING! Missing BlackBerry 10 configuration file, prompting for information...');
             this.get_blackberry_environment(function() {
-                // Update project.properties
-                self.write_project_properties();
-
+                self.write_blackberry_environment();
                 if (callback) callback();
             });
         } else {
-            // Write out config stuff to project.properties file
-            this.write_project_properties();
+            self.write_blackberry_environment();
             if (callback) callback();
         }
     },
@@ -120,7 +120,7 @@ module.exports.prototype = {
         shell.cp('-rf', www, this.path);
 
         // add cordova.js
-        shell.cp('-f', path.join(util.libDirectory, 'cordova-blackberry', 'javascript', 'cordova.blackberry.js'), path.join(this.www_dir(), 'cordova.js'));
+        shell.cp('-f', path.join(util.libDirectory, 'cordova-blackberry', 'javascript', 'cordova.blackberry10.js'), path.join(this.www_dir(), 'cordova.js'));
 
         // add webworks ext directories
         shell.cp('-rf', path.join(util.libDirectory, 'cordova-blackberry', 'framework', 'ext*'), this.www_dir());
@@ -152,24 +152,11 @@ module.exports.prototype = {
             shell.cp('-rf', staging, this.www_dir());
         }
     },
-
-    write_project_properties:function() {
+    get_cordova_config:function() {
         var projectRoot = util.isCordova(this.path);
-
-        var projFile = path.join(this.path, 'project.properties');
-        var props = fs.readFileSync(projFile, 'utf-8');
-
         var dotFile = path.join(projectRoot, '.cordova', 'config.json');
         var dot = JSON.parse(fs.readFileSync(dotFile, 'utf-8'));
-
-        props = props.replace(/qnx\.bbwp\.dir=.*\n/, 'qnx.bbwp.dir=' + dot.blackberry.qnx.bbwp + '\n');
-        props = props.replace(/qnx\.sigtool\.password=.*\n/, 'qnx.sigtool.password=' + dot.blackberry.qnx.signing_password + '\n');
-        props = props.replace(/qnx\.device\.ip=.*\n/, 'qnx.device.ip=' + dot.blackberry.qnx.device_ip + '\n');
-        props = props.replace(/qnx\.device\.password=.*\n/, 'qnx.device.password=' + dot.blackberry.qnx.device_password + '\n');
-        props = props.replace(/qnx\.sim\.ip=.*\n/, 'qnx.sim.ip=' + dot.blackberry.qnx.sim_ip + '\n');
-        props = props.replace(/qnx\.sim\.password=.*\n/, 'qnx.sim.password=' + dot.blackberry.qnx.sim_password + '\n');
-        fs.writeFileSync(projFile, props, 'utf-8');
-        events.emit('log', 'Wrote out BlackBerry 10 configuration file to "' + projFile + '"');
+        return dot.blackberry.qnx;
     },
     get_blackberry_environment:function(callback) {
         var projectRoot = util.isCordova(this.path);
@@ -179,21 +166,26 @@ module.exports.prototype = {
         events.emit('log', 'Prompting for BlackBerry 10 configuration information...');
         prompt.start();
         prompt.get([{
-            name:'bbwp',
-            required:true,
-            description:'Enter the full path to your BB10 bbwp executable'
-        },{
             name:'signing_password',
             required:true,
-            description:'Enter your BlackBerry signing password',
+            description:'Enter your BlackBerry 10 signing/keystore password',
             hidden:true
         },{
+            name:'device_name',
+            description:'Enter a name for your BB10 device'
+        },{
             name:'device_ip',
             description:'Enter the IP to your BB10 device'
         },{
             name:'device_password',
             description:'Enter the password for your BB10 device'
         },{
+            name:'device_pin',
+            description:'Enter the PIN for your BB10 device (under Settings->About->Hardware)'
+        },{
+            name:'sim_name',
+            description:'Enter a name for your BB10 simulator'
+        },{
             name:'sim_ip',
             description:'Enter the IP to your BB10 simulator'
         },{
@@ -208,16 +200,73 @@ module.exports.prototype = {
                 // Write out .cordova/config.json file
                 if (dot.blackberry === undefined) dot.blackberry = {};
                 if (dot.blackberry.qnx === undefined) dot.blackberry.qnx = {};
-                dot.blackberry.qnx.bbwp = results.bbwp;
                 dot.blackberry.qnx.signing_password = results.signing_password;
                 dot.blackberry.qnx.device_ip = results.device_ip;
+                dot.blackberry.qnx.device_name = results.device_name;
                 dot.blackberry.qnx.device_password = results.device_password;
+                dot.blackberry.qnx.device_pin = results.device_pin;
                 dot.blackberry.qnx.sim_ip = results.sim_ip;
+                dot.blackberry.qnx.sim_name = results.sim_name;
                 dot.blackberry.qnx.sim_password = results.sim_password;
                 fs.writeFileSync(dotFile, JSON.stringify(dot), 'utf-8');
                 events.emit('log', 'Wrote out BlackBerry 10 configuration file to "' + dotFile + '"');
                 if (callback) callback();
             }
         });
+    },
+    write_blackberry_environment:function() {
+        var projectRoot = util.isCordova(this.path);
+        // Write it out to project.json as well
+        var project_json_file = path.join(projectRoot, 'platforms', 'blackberry', 'project.json');
+        var proj_json = JSON.parse(fs.readFileSync(project_json_file,'utf-8'));
+
+        // write out stuff to the project.json if user specified it
+        var bb_config = this.get_cordova_config();
+        if (bb_config.device_name && bb_config.device_ip && bb_config.device_password && bb_config.device_pin) {
+            proj_json.targets[bb_config.device_name] = {
+                ip:bb_config.device_ip,
+                type:"device",
+                password:bb_config.device_password,
+                pin:bb_config.device_pin
+            };
+            proj_json.defaultTarget = bb_config.device_name;
+            events.emit('log', 'Wrote out BlackBerry 10 device information to ' + project_json_file);
+        }
+        if (bb_config.sim_name && bb_config.sim_ip && bb_config.sim_password) {
+            proj_json.targets[bb_config.sim_name] = {
+                ip:bb_config.sim_ip,
+                type:"simulator",
+                password:bb_config.sim_password
+            };
+            events.emit('log', 'Wrote out BlackBerry 10 simulator information to ' + project_json_file);
+        }
+        fs.writeFileSync(project_json_file, JSON.stringify(proj_json), 'utf-8');
+    },
+    get_all_targets:function() {
+        var json_file = path.join(this.path, 'project.json');
+        var json = JSON.parse(fs.readFileSync(json_file, 'utf-8'));
+        var targets = [];
+        Object.keys(json.targets).forEach(function(target) {
+            var t = json.targets[target];
+            t.name = target;
+            targets.push(t);
+        });
+        return targets;
+    },
+    get_device_targets:function() {
+        return this.get_all_targets().filter(function(t) {
+            return t.type == 'device';
+        });
+    },
+    get_simulator_targets:function() {
+        return this.get_all_targets().filter(function(t) {
+            return t.type == 'simulator';
+        });
+    },
+    has_device_target:function() {
+        return this.get_device_targets().length > 0;
+    },
+    has_simulator_target:function() {
+        return this.get_simulator_targets().length > 0;
     }
 };

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/dc340238/src/prepare.js
----------------------------------------------------------------------
diff --git a/src/prepare.js b/src/prepare.js
index 9911000..d1fbce7 100644
--- a/src/prepare.js
+++ b/src/prepare.js
@@ -85,18 +85,17 @@ module.exports = function prepare(platformList, callback) {
             // Call plugman --prepare for this platform. sets up js-modules appropriately.
             var plugins_dir = path.join(projectRoot, 'plugins');
             events.emit('log', 'Calling plugman.prepare for platform "' + platform + '"');
-            plugman.prepare(platformPath, platform, plugins_dir);
-
+            plugman.prepare(platformPath, (platform=='blackberry'?'blackberry10':platform), plugins_dir);
             // Make sure that config changes for each existing plugin is in place
             var plugins = cordova_util.findPlugins(plugins_dir);
-            var platform_json = plugman.config_changes.get_platform_json(plugins_dir, platform);
+            var platform_json = plugman.config_changes.get_platform_json(plugins_dir, (platform=='blackberry'?'blackberry10':platform));
             plugins && plugins.forEach(function(plugin_id) {
                 if (platform_json.installed_plugins[plugin_id]) {
                     events.emit('log', 'Ensuring plugin "' + plugin_id + '" is installed correctly...');
-                    plugman.config_changes.add_plugin_changes(platform, platformPath, plugins_dir, plugin_id, /* variables for plugin */ platform_json.installed_plugins[plugin_id], /* top level plugin? */ true, /* should increment config munge? cordova-cli never should, only plugman */ false);
+                    plugman.config_changes.add_plugin_changes((platform=='blackberry'?'blackberry10':platform), platformPath, plugins_dir, plugin_id, /* variables for plugin */ platform_json.installed_plugins[plugin_id], /* top level plugin? */ true, /* should increment config munge? cordova-cli never should, only plugman */ false);
                 } else if (platform_json.dependent_plugins[plugin_id]) {
                     events.emit('log', 'Ensuring plugin "' + plugin_id + '" is installed correctly...');
-                    plugman.config_changes.add_plugin_changes(platform, platformPath, plugins_dir, plugin_id, /* variables for plugin */ platform_json.dependent_plugins[plugin_id], /* top level plugin? */ false, /* should increment config munge? cordova-cli never should, only plugman */ false);
+                    plugman.config_changes.add_plugin_changes((platform=='blackberry'?'blackberry10':platform), platformPath, plugins_dir, plugin_id, /* variables for plugin */ platform_json.dependent_plugins[plugin_id], /* top level plugin? */ false, /* should increment config munge? cordova-cli never should, only plugman */ false);
                 }
                 events.emit('log', 'Plugin "' + plugin_id + '" is good to go.');
             });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/dc340238/src/run.js
----------------------------------------------------------------------
diff --git a/src/run.js b/src/run.js
index 63af0a3..ff7ea17 100644
--- a/src/run.js
+++ b/src/run.js
@@ -23,11 +23,24 @@ var cordova_util      = require('./util'),
     shell             = require('shelljs'),
     et                = require('elementtree'),
     hooker            = require('./hooker'),
+    platforms         = require('./../platforms'),
     events            = require('./events'),
     n                 = require('ncallbacks');
 
 function shell_out_to_run(projectRoot, platform, callback) {
     var cmd = '"' + path.join(projectRoot, 'platforms', platform, 'cordova', 'run') + '" --debug --device';
+    // TODO: inconsistent API for BB10 run command
+    if (platform == 'blackberry') {
+        var bb_project = path.join(projectRoot, 'platforms', 'blackberry')
+        var project = new platforms.blackberry.parser(bb_project);
+        if (project.has_device_target()) {
+            var bb_config = project.get_cordova_config();
+            var device = project.get_device_targets()[0].name;
+            cmd = '"' + path.join(bb_project, 'cordova', 'run') + '" --target=' + device + ' -k ' + bb_config.signing_password;
+        } else {
+            throw new Error('No BlackBerry device targets defined. If you want to run `run` with BB10, please add a device target. For more information run "' + path.join(bb_project, 'cordova', 'target') + '" -h');
+        }
+    }
 
     events.emit('log', 'Running app on platform "' + platform + '" with command "' + cmd + '" (output to follow)...');
     shell.exec(cmd, {silent:true, async:true}, function(code, output) {
@@ -94,7 +107,12 @@ module.exports = function run(platformList, callback) {
             else throw err;
         } else {
             platformList.forEach(function(platform) {
-                shell_out_to_run(projectRoot, platform, end);
+                try {
+                    shell_out_to_run(projectRoot, platform, end);
+                } catch(e) {
+                    if (callback) callback(e);
+                    else throw e;
+                }
             });
         }
     });


[04/22] git commit: added another spec for listing multiple plugins

Posted by fi...@apache.org.
added another spec for listing multiple plugins


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/5ccaec09
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/5ccaec09
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/5ccaec09

Branch: refs/heads/2.8.x
Commit: 5ccaec099e302a8fbefad7d4646b28b6615e3422
Parents: 3ee9664
Author: Fil Maj <ma...@gmail.com>
Authored: Tue Jun 4 14:21:19 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 6 18:26:02 2013 -0700

----------------------------------------------------------------------
 spec/cordova-cli/plugin.spec.js |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5ccaec09/spec/cordova-cli/plugin.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova-cli/plugin.spec.js b/spec/cordova-cli/plugin.spec.js
index b24580c..43d4a9a 100644
--- a/spec/cordova-cli/plugin.spec.js
+++ b/spec/cordova-cli/plugin.spec.js
@@ -101,6 +101,12 @@ describe('plugin command', function() {
 
             expect(cordova.plugin('list')).toEqual('No plugins added. Use `cordova plugin add <plugin>`.');
         });
+        it('should list out any added plugins in a project', function() {
+            process.chdir(tempDir);
+            var random_plug = 'randomplug';
+            shell.mkdir('-p', path.join(tempDir, 'plugins', random_plug));
+            expect(cordova.plugin('list')).toEqual([random_plug]);
+        });
     });
 
     describe('`add`', function() {


[03/22] git commit: merged in bootstrap conflict after platform parser reorg.

Posted by fi...@apache.org.
merged in bootstrap conflict after platform parser reorg.


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/3ee9664b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/3ee9664b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/3ee9664b

Branch: refs/heads/2.8.x
Commit: 3ee9664bcb9041a6324b9f076755d538e8656544
Parents: 61e23c1
Author: Benn Mapes <be...@gmail.com>
Authored: Mon Jun 3 16:58:58 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 6 18:25:43 2013 -0700

----------------------------------------------------------------------
 bootstrap.js                      |   18 +--------------
 package.json                      |    2 +-
 platforms.js                      |   23 +++++++++++++++++++-
 spec/cordova-cli/platform.spec.js |   18 ++++++++--------
 src/compile.js                    |   20 ++++++++--------
 src/emulate.js                    |   36 ++++++++++---------------------
 src/platform.js                   |   27 +++++++++--------------
 src/plugin.js                     |   21 ++++++------------
 src/plugin_parser.js              |    1 -
 src/prepare.js                    |   36 ++++++++++---------------------
 src/serve.js                      |   17 ++++----------
 src/util.js                       |    4 +-
 test_runner.js                    |    7 ++++-
 13 files changed, 98 insertions(+), 132 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/3ee9664b/bootstrap.js
----------------------------------------------------------------------
diff --git a/bootstrap.js b/bootstrap.js
index c70188f..aeefa2b 100644
--- a/bootstrap.js
+++ b/bootstrap.js
@@ -22,26 +22,12 @@
 
 var util      = require('./src/util'),
     create    = require('./src/create'),
-    a_parser  = require('./src/metadata/android_parser'),
-    b_parser  = require('./src/metadata/blackberry_parser'),
-    i_parser  = require('./src/metadata/ios_parser'),
-    wp7_parser= require('./src/metadata/wp7_parser'),
-    wp8_parser= require('./src/metadata/wp8_parser'),
     n         = require('ncallbacks'),
     path      = require('path'),
     fs        = require('fs'),
     shell     = require('shelljs'),
     platforms = require('./platforms');
 
-// Library requirements checkers
-var min_reqs = {
-    "android":a_parser.check_requirements,
-    "ios":i_parser.check_requirements,
-    "blackberry":b_parser.check_requirements,
-    "wp7":wp7_parser.check_requirements,
-    "wp8":wp8_parser.check_requirements
-}
-
 // Create native projects using bin/create
 var projectFixtures = path.join(__dirname, 'spec', 'fixtures', 'projects');
 var tempDir = path.join(projectFixtures, 'native');
@@ -69,8 +55,8 @@ var end = n(platforms.length, function() {
     }
 });
 
-platforms.forEach(function(platform) {
-    min_reqs[platform](function(err) {
+Object.keys(platforms).forEach(function(platform) {
+    platforms[platform].parser.check_requirements(function(err) {
         if (err) {
             console.error('WARNING: Your system does not meet requirements to create ' + platform + ' projects. See error output below.');
             console.error(err);

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/3ee9664b/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index d34c03f..0642eb2 100644
--- a/package.json
+++ b/package.json
@@ -39,7 +39,7 @@
     "open": "0.0.3"
   },
   "devDependencies": {
-    "jasmine-node":"1.3.x"
+    "jasmine-node":"1.8.x"
   },
   "author": "Anis Kadri",
   "contributors": [

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/3ee9664b/platforms.js
----------------------------------------------------------------------
diff --git a/platforms.js b/platforms.js
index c49c797..b2f7b0b 100644
--- a/platforms.js
+++ b/platforms.js
@@ -17,4 +17,25 @@
     under the License.
 */
 
-module.exports = ['ios', 'android', /*'blackberry',*/ 'wp7', 'wp8'];
+module.exports = {
+    'ios' : {
+        parser : require('./src/metadata/ios_parser'),
+        url    : 'https://git-wip-us.apache.org/repos/asf/cordova-ios.git'
+    }, 
+    'android' : {
+        parser : require('./src/metadata/android_parser'),
+        url    : 'https://git-wip-us.apache.org/repos/asf/cordova-ios.git'
+    }, 
+    'wp7' : {
+        parser : require('./src/metadata/wp7_parser'),
+        url    : 'https://git-wip-us.apache.org/repos/asf/cordova-wp7.git'
+    },
+    'wp8' : {
+        parser : require('./src/metadata/wp8_parser'),
+        url    : 'https://git-wip-us.apache.org/repos/asf/cordova-wp8.git'
+    }/*,
+    blackberry : {
+        parser : require('./metadata/blackberry_parser'),
+        url    : 'https://git-wip-us.apache.org/repos/asf/cordova-blackberry.git'
+    }*/
+};

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/3ee9664b/spec/cordova-cli/platform.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova-cli/platform.spec.js b/spec/cordova-cli/platform.spec.js
index 5aab03d..2aa0177 100644
--- a/spec/cordova-cli/platform.spec.js
+++ b/spec/cordova-cli/platform.spec.js
@@ -27,6 +27,7 @@ var cordova = require('../../cordova'),
     util = require('../../src/util'),
     hooker = require('../../src/hooker'),
     platforms = require('../../platforms'),
+    platform  = require('../../src/platform'),
     tempDir = path.join(__dirname, '..', '..', 'temp');
     android_parser = require('../../src/metadata/android_parser'),
     ios_parser = require('../../src/metadata/ios_parser'),
@@ -104,16 +105,15 @@ describe('platform command', function() {
         });
 
         it('should handle multiple platforms', function() {
-            var arc = spyOn(android_parser, 'check_requirements');
-            var brc = spyOn(blackberry_parser, 'check_requirements');
+            spyOn(platform, 'supports').andCallFake(function(target, callback) {
+                    callback(null);
+            });
             var sh = spyOn(shell, 'exec');
-            cordova.platform('add', ['android', 'blackberry']);
-            arc.mostRecentCall.args[0](false);
-            brc.mostRecentCall.args[0](false);
-            var android_create = path.join('android', 'bin', 'create');
-            var bb_create      = path.join('blackberry', 'bin', 'create');
-            expect(sh.argsForCall[0][0]).toContain(android_create);
-            expect(sh.argsForCall[1][0]).toContain(bb_create);
+            cordova.platform('add', ['foo', 'bar']);
+            var foo_create = path.join('foo', 'bin', 'create');
+            var bar_create      = path.join('bar', 'bin', 'create');
+            expect(sh.argsForCall[0][0]).toContain(foo_create);
+            expect(sh.argsForCall[1][0]).toContain(bar_create);
         });
     });
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/3ee9664b/src/compile.js
----------------------------------------------------------------------
diff --git a/src/compile.js b/src/compile.js
index 2521811..4cf3b85 100644
--- a/src/compile.js
+++ b/src/compile.js
@@ -45,7 +45,7 @@ function shell_out_to_debug(projectRoot, platform, callback) {
 }
 
 
-module.exports = function compile(platforms, callback) {
+module.exports = function compile(platformList, callback) {
     var projectRoot = cordova_util.isCordova(process.cwd());
 
     if (!projectRoot) {
@@ -55,22 +55,22 @@ module.exports = function compile(platforms, callback) {
     var xml = cordova_util.projectConfig(projectRoot);
     var cfg = new config_parser(xml);
 
-    if (arguments.length === 0 || (platforms instanceof Array && platforms.length === 0)) {
-        platforms = cordova_util.listPlatforms(projectRoot);
-    } else if (typeof platforms == 'string') platforms = [platforms];
-    else if (platforms instanceof Function && callback === undefined) {
-        callback = platforms;
-        platforms = cordova_util.listPlatforms(projectRoot);
+    if (arguments.length === 0 || (platformList instanceof Array && platformList.length === 0)) {
+        platformList = cordova_util.listPlatforms(projectRoot);
+    } else if (typeof platformList == 'string') platformList = [platformList];
+    else if (platformList instanceof Function && callback === undefined) {
+        callback = platformList;
+        platformList = cordova_util.listPlatforms(projectRoot);
     }
 
-    if (platforms.length === 0) throw new Error('No platforms added to this project. Please use `cordova platform add <platform>`.');
+    if (platformList.length === 0) throw new Error('No platforms added to this project. Please use `cordova platform add <platform>`.');
 
     var hooks = new hooker(projectRoot);
     if (!(hooks.fire('before_compile'))) {
         throw new Error('before_compile hooks exited with non-zero code. Aborting.');
     }
 
-    var end = n(platforms.length, function() {
+    var end = n(platformList.length, function() {
         if (!(hooks.fire('after_compile'))) {
             throw new Error('after_compile hooks exited with non-zero code. Aborting.');
         }
@@ -78,7 +78,7 @@ module.exports = function compile(platforms, callback) {
     });
 
     // Iterate over each added platform
-    platforms.forEach(function(platform) {
+    platformList.forEach(function(platform) {
         shell_out_to_debug(projectRoot, platform, end);
     });
 };

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/3ee9664b/src/emulate.js
----------------------------------------------------------------------
diff --git a/src/emulate.js b/src/emulate.js
index ffa1319..4e5451a 100644
--- a/src/emulate.js
+++ b/src/emulate.js
@@ -20,11 +20,7 @@ var cordova_util      = require('./util'),
     path              = require('path'),
     shell             = require('shelljs'),
     config_parser     = require('./config_parser'),
-    android_parser    = require('./metadata/android_parser'),
-    ios_parser        = require('./metadata/ios_parser'),
-    blackberry_parser = require('./metadata/blackberry_parser'),
-    wp7_parser        = require('./metadata/wp7_parser'),
-    wp8_parser        = require('./metadata/wp8_parser'),
+    platforms         = require('../platforms'),
     platform          = require('./platform'),
     fs                = require('fs'),
     ls                = fs.readdirSync,
@@ -32,14 +28,6 @@ var cordova_util      = require('./util'),
     hooker            = require('../src/hooker'),
     util              = require('util');
 
-var parsers = {
-    "android":android_parser,
-    "ios":ios_parser,
-    "blackberry":blackberry_parser,
-    "wp7":wp7_parser,
-    "wp8":wp8_parser
-};
-
 function shell_out_to_emulate(root, platform, callback) {
     var cmd = '"' + path.join(root, 'platforms', platform, 'cordova', 'run') + '"';
     // TODO: PLATFORM LIBRARY INCONSISTENCY 
@@ -55,7 +43,7 @@ function shell_out_to_emulate(root, platform, callback) {
     });
 }
 
-module.exports = function emulate (platforms, callback) {
+module.exports = function emulate (platformList, callback) {
     var projectRoot = cordova_util.isCordova(process.cwd());
 
     if (!projectRoot) {
@@ -65,22 +53,22 @@ module.exports = function emulate (platforms, callback) {
     var xml = cordova_util.projectConfig(projectRoot);
     var cfg = new config_parser(xml);
 
-    if (arguments.length === 0 || (platforms instanceof Array && platforms.length === 0)) {
-        platforms = cordova_util.listPlatforms(projectRoot);
-    } else if (typeof platforms == 'string') platforms = [platforms];
-    else if (platforms instanceof Function && callback === undefined) {
-        callback = platforms;
-        platforms = cordova_util.listPlatforms(projectRoot);
+    if (arguments.length === 0 || (platformList instanceof Array && platformList.length === 0)) {
+        platformList = cordova_util.listPlatforms(projectRoot);
+    } else if (typeof platformList == 'string') platformList = [platformList];
+    else if (platformList instanceof Function && callback === undefined) {
+        callback = platformList;
+        platformList = cordova_util.listPlatforms(projectRoot);
     }
 
-    if (platforms.length === 0) throw new Error('No platforms added to this project. Please use `cordova platform add <platform>`.');
+    if (platformList.length === 0) throw new Error('No platforms added to this project. Please use `cordova platform add <platform>`.');
 
     var hooks = new hooker(projectRoot);
     if (!(hooks.fire('before_emulate'))) {
         throw new Error('before_emulate hooks exited with non-zero code. Aborting build.');
     }
 
-    var end = n(platforms.length, function() {
+    var end = n(platformList.length, function() {
         if (!(hooks.fire('after_emulate'))) {
             throw new Error('after_emulate hooks exited with non-zero code. Aborting.');
         }
@@ -88,9 +76,9 @@ module.exports = function emulate (platforms, callback) {
     });
 
     // Iterate over each added platform and shell out to debug command
-    platforms.forEach(function(platform) {
+    platformList.forEach(function(platform) {
         var platformPath = path.join(projectRoot, 'platforms', platform);
-        var parser = new parsers[platform](platformPath);
+        var parser = new platforms[platform].parser(platformPath);
         parser.update_project(cfg, function() {
             shell_out_to_emulate(projectRoot, platform, end);
         });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/3ee9664b/src/platform.js
----------------------------------------------------------------------
diff --git a/src/platform.js b/src/platform.js
index 5670f1b..38032bc 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -23,22 +23,10 @@ var config_parser     = require('./config_parser'),
     path              = require('path'),
     hooker            = require('./hooker'),
     n                 = require('ncallbacks'),
-    android_parser    = require('./metadata/android_parser'),
-    ios_parser        = require('./metadata/ios_parser'),
-    blackberry_parser = require('./metadata/blackberry_parser'),
-    wp7_parser        = require('./metadata/wp7_parser'),
-    wp8_parser        = require('./metadata/wp8_parser'),
+    platforms         = require('../platforms'),
     plugman           = require('plugman'),
     shell             = require('shelljs');
 
-var parsers = {
-    "android":android_parser,
-    "ios":ios_parser,
-    "blackberry":blackberry_parser,
-    "wp7":wp7_parser,
-    "wp8":wp8_parser
-};
-
 module.exports = function platform(command, targets, callback) {
     var projectRoot = cordova_util.isCordova(process.cwd());
 
@@ -103,7 +91,7 @@ module.exports = function platform(command, targets, callback) {
                                 throw new Error('An error occured during creation of ' + target + ' sub-project. ' + create_output);
                             }
 
-                            var parser = new parsers[target](output);
+                            var parser = new platforms[target].parser(output);
                             parser.update_project(cfg, function() {
                                 createOverrides(target);
                                 hooks.fire('after_platform_add');
@@ -154,10 +142,17 @@ module.exports.supports = function(name, callback) {
     if (!name) throw new Error('requires a platform name parameter');
     if (!callback) throw new Error('requires a callback parameter');
 
+    // check if platform exists
+    var platform = platforms[name];
+    if (!platform) {
+        callback(new Error(util.format('"%s" platform does not exist', name)));
+        return;
+    }
+
     // look up platform meta-data parser
-    var platformParser = parsers[name];
+    var platformParser = platforms[name].parser;
     if (!platformParser) {
-        callback(new Error(util.format('"%s" platform does not exist', name)));
+        callback(new Error(util.format('"%s" platform parser does not exist', name)));
         return;
     }
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/3ee9664b/src/plugin.js
----------------------------------------------------------------------
diff --git a/src/plugin.js b/src/plugin.js
index d5371cf..6045840 100644
--- a/src/plugin.js
+++ b/src/plugin.js
@@ -22,20 +22,13 @@ var cordova_util  = require('./util'),
     shell         = require('shelljs'),
     path          = require('path'),
     shell         = require('shelljs'),
+    platforms     = require('../platforms'),
     config_parser = require('./config_parser'),
     hooker        = require('./hooker'),
     plugin_parser = require('./plugin_parser'),
     ls            = fs.readdirSync,
     plugman       = require('plugman');
 
-var parsers = {
-    "android": require('./metadata/android_parser'),
-    "ios": require('./metadata/ios_parser'),
-    "wp7": require('./metadata/wp7_parser'),
-    "wp8": require('./metadata/wp8_parser'),
-    "blackberry": require('./metadata/blackberry_parser')
-};
-
 module.exports = function plugin(command, targets, callback) {
     var projectRoot = cordova_util.isCordova(process.cwd());
 
@@ -49,7 +42,7 @@ module.exports = function plugin(command, targets, callback) {
     // Grab config info for the project
     var xml = cordova_util.projectConfig(projectRoot);
     var cfg = new config_parser(xml);
-    var platforms = cordova_util.listPlatforms(projectRoot);
+    var platformList = cordova_util.listPlatforms(projectRoot);
 
     // Massage plugin name(s) / path(s)
     var pluginPath, plugins;
@@ -85,9 +78,9 @@ module.exports = function plugin(command, targets, callback) {
                     }
 
                     // Iterate over all platforms in the project and install the plugin.
-                    platforms.forEach(function(platform) {
+                    platformList.forEach(function(platform) {
                         var platformRoot = path.join(projectRoot, 'platforms', platform);
-                        var parser = new parsers[platform](platformRoot);
+                        var parser = new platforms[platform].parser(platformRoot);
                         // TODO: unify use of blackberry in cli vs blackberry10 in plugman
                         plugman.install((platform=='blackberry'?'blackberry10':platform), platformRoot,
                                         path.basename(dir), pluginsDir, { www_dir: parser.staging_dir() });
@@ -100,7 +93,7 @@ module.exports = function plugin(command, targets, callback) {
             break;
         case 'rm':
         case 'remove':
-            if (platforms.length === 0) {
+            if (platformList.length === 0) {
                 throw new Error('You need at least one platform added to your app. Use `cordova platform add <platform>`.');
             }
             targets.forEach(function(target, index) {
@@ -112,7 +105,7 @@ module.exports = function plugin(command, targets, callback) {
                     // supported platforms and app platforms
                     var pluginXml = new plugin_parser(path.join(targetPath, 'plugin.xml'));
                     var intersection = pluginXml.platforms.filter(function(e) {
-                        if (platforms.indexOf(e) == -1) return false;
+                        if (platformList.indexOf(e) == -1) return false;
                         else return true;
                     });
 
@@ -122,7 +115,7 @@ module.exports = function plugin(command, targets, callback) {
                     // is not needed and we just --remove the plugin below.
                     intersection.forEach(function(platform) {
                         var platformRoot = path.join(projectRoot, 'platforms', platform);
-                        var parser = new parsers[platform](platformRoot);
+                        var parser = new platforms[platform].parser(platformRoot);
                         plugman.uninstall(platform, platformRoot, target, path.join(projectRoot, 'plugins'), { www_dir: parser.staging_dir() });
                     });
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/3ee9664b/src/plugin_parser.js
----------------------------------------------------------------------
diff --git a/src/plugin_parser.js b/src/plugin_parser.js
index d104c9e..3b1c24b 100644
--- a/src/plugin_parser.js
+++ b/src/plugin_parser.js
@@ -18,7 +18,6 @@
     under the License.
 */
 var et = require('elementtree'),
-    platforms = require('./../platforms'),
     fs = require('fs');
 
 function plugin_parser(xmlPath) {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/3ee9664b/src/prepare.js
----------------------------------------------------------------------
diff --git a/src/prepare.js b/src/prepare.js
index b5c66ee..b08827e 100644
--- a/src/prepare.js
+++ b/src/prepare.js
@@ -19,30 +19,18 @@
 var cordova_util      = require('./util'),
     path              = require('path'),
     config_parser     = require('./config_parser'),
+    platforms         = require('../platforms'),
     platform          = require('./platform'),
     fs                = require('fs'),
     shell             = require('shelljs'),
     et                = require('elementtree'),
-    android_parser    = require('./metadata/android_parser'),
-    blackberry_parser = require('./metadata/blackberry_parser'),
-    ios_parser        = require('./metadata/ios_parser'),
-    wp7_parser        = require('./metadata/wp7_parser'),
-    wp8_parser        = require('./metadata/wp8_parser'),
     hooker            = require('./hooker'),
     n                 = require('ncallbacks'),
     prompt            = require('prompt'),
     plugman           = require('plugman'),
     util              = require('util');
 
-var parsers = {
-    "android":android_parser,
-    "ios":ios_parser,
-    "blackberry":blackberry_parser,
-    "wp7":wp7_parser,
-    "wp8":wp8_parser
-};
-
-module.exports = function prepare(platforms, callback) {
+module.exports = function prepare(platformList, callback) {
     var projectRoot = cordova_util.isCordova(process.cwd());
 
     if (!projectRoot) {
@@ -52,22 +40,22 @@ module.exports = function prepare(platforms, callback) {
     var xml = cordova_util.projectConfig(projectRoot);
     var cfg = new config_parser(xml);
 
-    if (arguments.length === 0 || (platforms instanceof Array && platforms.length === 0)) {
-        platforms = cordova_util.listPlatforms(projectRoot);
-    } else if (typeof platforms == 'string') platforms = [platforms];
-    else if (platforms instanceof Function && callback === undefined) {
-        callback = platforms;
-        platforms = cordova_util.listPlatforms(projectRoot);
+    if (arguments.length === 0 || (platformList instanceof Array && platformList.length === 0)) {
+        platformList = cordova_util.listPlatforms(projectRoot);
+    } else if (typeof platformList == 'string') platformList = [platformList];
+    else if (platformList instanceof Function && callback === undefined) {
+        callback = platformList;
+        platformList = cordova_util.listPlatforms(projectRoot);
     }
 
-    if (platforms.length === 0) throw new Error('No platforms added to this project. Please use `cordova platform add <platform>`.');
+    if (platformList.length === 0) throw new Error('No platforms added to this project. Please use `cordova platform add <platform>`.');
 
     var hooks = new hooker(projectRoot);
     if (!(hooks.fire('before_prepare'))) {
         throw new Error('before_prepare hooks exited with non-zero code. Aborting.');
     }
 
-    var end = n(platforms.length, function() {
+    var end = n(platformList.length, function() {
         if (!(hooks.fire('after_prepare'))) {
             throw new Error('after_prepare hooks exited with non-zero code. Aborting.');
         }
@@ -75,9 +63,9 @@ module.exports = function prepare(platforms, callback) {
     });
 
     // Iterate over each added platform
-    platforms.forEach(function(platform) {
+    platformList.forEach(function(platform) {
         var platformPath = path.join(projectRoot, 'platforms', platform);
-        var parser = new parsers[platform](platformPath);
+        var parser = new platforms[platform].parser(platformPath);
 
         parser.update_project(cfg, function() {
             // Call plugman --prepare for this platform. sets up js-modules appropriately.

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/3ee9664b/src/serve.js
----------------------------------------------------------------------
diff --git a/src/serve.js b/src/serve.js
index e7eb42b..b5036de 100644
--- a/src/serve.js
+++ b/src/serve.js
@@ -20,20 +20,13 @@
 var cordova_util = require('./util'),
     path = require('path'),
     shell = require('shelljs'),
+    platforms     = require('../platforms'),
     config_parser = require('./config_parser'),
     fs = require('fs'),
     util = require('util'),
     http = require("http"),
     url = require("url");
 
-var parsers = {
-    'android': require('./metadata/android_parser'),
-    'ios': require('./metadata/ios_parser'),
-    'blackberry': require('./metadata/blackberry_parser'),
-    'wp7': require('./metadata/wp7_parser'),
-    'wp8': require('./metadata/wp8_parser')
-};
-
 function launch_server(www, platform_www, config_xml_path, port) {
     port = port || 8000;
 
@@ -107,12 +100,12 @@ module.exports.config = function (platform, port, callback) {
     var cfg = new config_parser(xml);
 
     // Retrieve the platforms.
-    var platforms = cordova_util.listPlatforms(projectRoot);
+    var platformList = cordova_util.listPlatforms(projectRoot);
     if (!platform) {
         throw new Error('You need to specify a platform.');
-    } else if (platforms.length == 0) {
+    } else if (platformList.length == 0) {
         throw new Error('No platforms to serve.');
-    } else if (platforms.filter(function(x) { return x == platform }).length == 0) {
+    } else if (platformList.filter(function(x) { return x == platform }).length == 0) {
         throw new Error(platform + ' is not an installed platform.');
     }
 
@@ -129,7 +122,7 @@ module.exports.config = function (platform, port, callback) {
     // Top-level www directory.
     result.paths.push(cordova_util.projectWww(projectRoot));
 
-    var parser = parsers[platform](path.join(projectRoot, 'platforms', platform));
+    var parser = platforms[platform].parser(path.join(projectRoot, 'platforms', platform));
 
     // Update the related platform project from the config
     parser.update_project(cfg, function() {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/3ee9664b/src/util.js
----------------------------------------------------------------------
diff --git a/src/util.js b/src/util.js
index 9b725a4..1ec7813 100644
--- a/src/util.js
+++ b/src/util.js
@@ -19,7 +19,6 @@
 */
 var fs         = require('fs'),
     path       = require('path'),
-    core_platforms = require('../platforms'),
     shell      = require('shelljs');
 
 var lib_path = path.join(__dirname, '..', 'lib')
@@ -59,8 +58,9 @@ module.exports = {
         });
     },
     listPlatforms:function(project_dir) {
+        var core_platforms = require('../platforms');
         return fs.readdirSync(path.join(project_dir, 'platforms')).filter(function(p) {
-            return core_platforms.indexOf(p) > -1;
+            return Object.keys(core_platforms).indexOf(p) > -1;
         });
     },
     // list the directories in the path, ignoring any files

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/3ee9664b/test_runner.js
----------------------------------------------------------------------
diff --git a/test_runner.js b/test_runner.js
index 1174b37..0250aa3 100644
--- a/test_runner.js
+++ b/test_runner.js
@@ -14,7 +14,7 @@ shell.rm('-rf', tmp);
 shell.mkdir('-p', path.join(tmp, 'platform-script'));
 shell.cp('-r', path.join(__dirname, 'spec', 'fixtures'), tmp);
 
-var end = n(platforms.length, function() {
+var end = n(Object.keys(platforms).length, function() {
     console.log('Testing core cli and the following platforms: ' + supported.join(', '));
     var cmd = 'node ' + path.join('node_modules', 'jasmine-node', 'bin', 'jasmine-node') + ' --color ' + tmp;
     specs.forEach(function(s) { 
@@ -23,10 +23,13 @@ var end = n(platforms.length, function() {
     });
     shell.cp('-r', path.join(__dirname, 'spec', 'cordova-cli'), tmp);
     shell.exec(cmd, {async:true, silent:false}, function(code, output) {
+        if(code > 0) {
+            console.log(output);
+        }
     });
 });
 console.log('Determining which platforms to run tests for...');
-platforms.forEach(function(p) {
+Object.keys(platforms).forEach(function(p) {
     platform.supports(p, function(e) {
         if (e) {
         } else {


[02/22] git commit: updating cordova-android and cordova-ios libs to 2.8.0rc1

Posted by fi...@apache.org.
updating cordova-android and cordova-ios libs to 2.8.0rc1


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/61e23c1e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/61e23c1e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/61e23c1e

Branch: refs/heads/2.8.x
Commit: 61e23c1e39c0a05623e9a383631ed1cd2327d343
Parents: 9f3431a
Author: Fil Maj <ma...@gmail.com>
Authored: Tue Jun 4 11:57:07 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 6 18:25:16 2013 -0700

----------------------------------------------------------------------
 lib/cordova-android/README.md                      |   20 ++
 lib/cordova-android/bin/check_reqs.bat             |   19 ++-
 lib/cordova-android/bin/create                     |    1 +
 .../bin/templates/cordova/build.bat                |   18 ++-
 .../bin/templates/cordova/clean.bat                |   16 ++
 .../bin/templates/cordova/cordova.bat              |    4 +-
 .../bin/templates/cordova/lib/install-device.bat   |   18 ++-
 .../bin/templates/cordova/lib/install-emulator.bat |   18 ++-
 .../bin/templates/cordova/lib/list-devices.bat     |   18 ++-
 .../templates/cordova/lib/list-emulator-images.bat |   18 ++-
 .../cordova/lib/list-started-emulators.bat         |   18 ++-
 .../bin/templates/cordova/lib/start-emulator.bat   |   18 ++-
 lib/cordova-android/bin/templates/cordova/log.bat  |   16 ++
 lib/cordova-android/bin/templates/cordova/run.bat  |   18 ++-
 lib/cordova-android/framework/project.properties   |    2 +-
 lib/cordova-android/framework/res/xml/config.xml   |   29 ++-
 .../src/org/apache/cordova/AudioHandler.java       |   13 +-
 .../src/org/apache/cordova/CameraLauncher.java     |   61 ++---
 .../framework/src/org/apache/cordova/Capture.java  |   13 +-
 .../src/org/apache/cordova/FileHelper.java         |   56 +----
 .../src/org/apache/cordova/FileUtils.java          |  121 ++++++----
 .../cordova/IceCreamCordovaWebViewClient.java      |   48 +++--
 .../src/org/apache/cordova/JSONUtils.java          |   18 ++
 .../org/apache/cordova/api/CallbackContext.java    |   18 ++
 .../src/org/apache/cordova/api/CordovaPlugin.java  |   14 -
 .../src/org/apache/cordova/api/PluginManager.java  |   29 ---
 lib/cordova-android/test/README.md                 |   20 ++
 lib/cordova-android/test/res/xml/config.xml        |   18 ++
 .../CordovaLib/Classes/CDVAvailability.h           |    3 +-
 lib/cordova-ios/CordovaLib/Classes/CDVDevice.m     |    1 -
 .../CordovaLib/Classes/CDVWebViewDelegate.m        |   15 +-
 .../CordovaLibTests/CordovaLibApp/config.xml       |   18 ++
 lib/cordova-ios/CordovaLibTests/ExifTests.h        |   45 ++--
 lib/cordova-ios/CordovaLibTests/ExifTests.m        |  195 ++++++++-------
 lib/cordova-ios/RELEASENOTES.md                    |   40 +++-
 .../bin/templates/project/__TESTING__/config.xml   |   18 ++
 lib/cordova-ios/bin/uncrustify.cfg                 |   18 ++-
 .../guides/Cordova Plugin Upgrade Guide.md         |   65 +++++
 38 files changed, 743 insertions(+), 355 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/README.md
----------------------------------------------------------------------
diff --git a/lib/cordova-android/README.md b/lib/cordova-android/README.md
index a785943..aca3242 100755
--- a/lib/cordova-android/README.md
+++ b/lib/cordova-android/README.md
@@ -1,3 +1,23 @@
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+# http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+-->
 Cordova Android
 ===
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/bin/check_reqs.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-android/bin/check_reqs.bat b/lib/cordova-android/bin/check_reqs.bat
index 65514c8..12da1e7 100644
--- a/lib/cordova-android/bin/check_reqs.bat
+++ b/lib/cordova-android/bin/check_reqs.bat
@@ -1,3 +1,20 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements.  See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership.  The ASF licenses this file
+:: to you under the Apache License, Version 2.0 (the
+:: "License"); you may not use this file except in compliance
+:: with the License.  You may obtain a copy of the License at
+:: 
+:: http://www.apache.org/licenses/LICENSE-2.0
+:: 
+:: Unless required by applicable law or agreed to in writing,
+:: software distributed under the License is distributed on an
+:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+:: KIND, either express or implied.  See the License for the
+:: specific language governing permissions and limitations
+:: under the License.
+
 @ECHO OFF
 SET full_path=%~dp0
 IF EXIST %full_path%check_reqs.js (
@@ -6,4 +23,4 @@ IF EXIST %full_path%check_reqs.js (
     ECHO.
     ECHO ERROR: Could not find 'check_reqs.js' in 'bin' folder, aborting...>&2
     EXIT /B 1
-)
\ No newline at end of file
+)

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/bin/create
----------------------------------------------------------------------
diff --git a/lib/cordova-android/bin/create b/lib/cordova-android/bin/create
index 39aff6b..b38ed51 100755
--- a/lib/cordova-android/bin/create
+++ b/lib/cordova-android/bin/create
@@ -153,6 +153,7 @@ cp "$BUILD_PATH"/bin/templates/cordova/build "$PROJECT_PATH"/cordova/build
 cp "$BUILD_PATH"/bin/templates/cordova/clean "$PROJECT_PATH"/cordova/clean
 cp "$BUILD_PATH"/bin/templates/cordova/log "$PROJECT_PATH"/cordova/log
 cp "$BUILD_PATH"/bin/templates/cordova/run "$PROJECT_PATH"/cordova/run
+cp "$BUILD_PATH"/bin/templates/cordova/version "$PROJECT_PATH"/cordova/version
 cp "$BUILD_PATH"/bin/templates/cordova/lib/cordova "$PROJECT_PATH"/cordova/lib/cordova
 cp "$BUILD_PATH"/bin/templates/cordova/lib/install-device "$PROJECT_PATH"/cordova/lib/install-device
 cp "$BUILD_PATH"/bin/templates/cordova/lib/install-emulator "$PROJECT_PATH"/cordova/lib/install-emulator

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/bin/templates/cordova/build.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-android/bin/templates/cordova/build.bat b/lib/cordova-android/bin/templates/cordova/build.bat
index 7aa7c75..392f374 100644
--- a/lib/cordova-android/bin/templates/cordova/build.bat
+++ b/lib/cordova-android/bin/templates/cordova/build.bat
@@ -1,2 +1,18 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements.  See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership.  The ASF licenses this file
+:: to you under the Apache License, Version 2.0 (the
+:: "License"); you may not use this file except in compliance
+:: with the License.  You may obtain a copy of the License at
+:: 
+:: http://www.apache.org/licenses/LICENSE-2.0
+:: 
+:: Unless required by applicable law or agreed to in writing,
+:: software distributed under the License is distributed on an
+:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+:: KIND, either express or implied.  See the License for the
+:: specific language governing permissions and limitations
+:: under the License.
 @ECHO OFF
-%~dp0\cordova.bat build %*
\ No newline at end of file
+%~dp0\cordova.bat build %*

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/bin/templates/cordova/clean.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-android/bin/templates/cordova/clean.bat b/lib/cordova-android/bin/templates/cordova/clean.bat
index b41bdc9..643c8d5 100644
--- a/lib/cordova-android/bin/templates/cordova/clean.bat
+++ b/lib/cordova-android/bin/templates/cordova/clean.bat
@@ -1,2 +1,18 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements.  See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership.  The ASF licenses this file
+:: to you under the Apache License, Version 2.0 (the
+:: "License"); you may not use this file except in compliance
+:: with the License.  You may obtain a copy of the License at
+:: 
+:: http://www.apache.org/licenses/LICENSE-2.0
+:: 
+:: Unless required by applicable law or agreed to in writing,
+:: software distributed under the License is distributed on an
+:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+:: KIND, either express or implied.  See the License for the
+:: specific language governing permissions and limitations
+:: under the License.
 @ECHO OFF
 %~dp0\cordova.bat clean %*

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/bin/templates/cordova/cordova.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-android/bin/templates/cordova/cordova.bat b/lib/cordova-android/bin/templates/cordova/cordova.bat
index 9b56199..6235fdb 100644
--- a/lib/cordova-android/bin/templates/cordova/cordova.bat
+++ b/lib/cordova-android/bin/templates/cordova/cordova.bat
@@ -1,5 +1,3 @@
-@ECHO OFF
-GOTO BEGIN
 :: Licensed to the Apache Software Foundation (ASF) under one
 :: or more contributor license agreements.  See the NOTICE file
 :: distributed with this work for additional information
@@ -16,7 +14,7 @@ GOTO BEGIN
 :: KIND, either express or implied.  See the License for the
 :: specific language governing permissions and limitations
 :: under the License.
-:BEGIN
+@ECHO OFF
 IF NOT DEFINED JAVA_HOME GOTO MISSING
 FOR %%X in (java.exe ant.bat android.bat) do (
     SET FOUND=%%~$PATH:X

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/bin/templates/cordova/lib/install-device.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-android/bin/templates/cordova/lib/install-device.bat b/lib/cordova-android/bin/templates/cordova/lib/install-device.bat
index 52d9775..b00e757 100644
--- a/lib/cordova-android/bin/templates/cordova/lib/install-device.bat
+++ b/lib/cordova-android/bin/templates/cordova/lib/install-device.bat
@@ -1,3 +1,19 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements.  See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership.  The ASF licenses this file
+:: to you under the Apache License, Version 2.0 (the
+:: "License"); you may not use this file except in compliance
+:: with the License.  You may obtain a copy of the License at
+:: 
+:: http://www.apache.org/licenses/LICENSE-2.0
+:: 
+:: Unless required by applicable law or agreed to in writing,
+:: software distributed under the License is distributed on an
+:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+:: KIND, either express or implied.  See the License for the
+:: specific language governing permissions and limitations
+:: under the License.
 @ECHO OFF
 SET full_path=%~dp0
 IF EXIST %full_path%cordova.js (
@@ -6,4 +22,4 @@ IF EXIST %full_path%cordova.js (
     ECHO. 
     ECHO ERROR: Could not find 'cordova.js' in cordova/lib, aborting...>&2
     EXIT /B 1
-)
\ No newline at end of file
+)

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/bin/templates/cordova/lib/install-emulator.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-android/bin/templates/cordova/lib/install-emulator.bat b/lib/cordova-android/bin/templates/cordova/lib/install-emulator.bat
index d11a7be..2b88630 100644
--- a/lib/cordova-android/bin/templates/cordova/lib/install-emulator.bat
+++ b/lib/cordova-android/bin/templates/cordova/lib/install-emulator.bat
@@ -1,3 +1,19 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements.  See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership.  The ASF licenses this file
+:: to you under the Apache License, Version 2.0 (the
+:: "License"); you may not use this file except in compliance
+:: with the License.  You may obtain a copy of the License at
+:: 
+:: http://www.apache.org/licenses/LICENSE-2.0
+:: 
+:: Unless required by applicable law or agreed to in writing,
+:: software distributed under the License is distributed on an
+:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+:: KIND, either express or implied.  See the License for the
+:: specific language governing permissions and limitations
+:: under the License.
 @ECHO OFF
 SET full_path=%~dp0
 IF EXIST %full_path%cordova.js (
@@ -6,4 +22,4 @@ IF EXIST %full_path%cordova.js (
     ECHO. 
     ECHO ERROR: Could not find 'cordova.js' in cordova/lib, aborting...>&2
     EXIT /B 1
-)
\ No newline at end of file
+)

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/bin/templates/cordova/lib/list-devices.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-android/bin/templates/cordova/lib/list-devices.bat b/lib/cordova-android/bin/templates/cordova/lib/list-devices.bat
index c146f10..3840d12 100644
--- a/lib/cordova-android/bin/templates/cordova/lib/list-devices.bat
+++ b/lib/cordova-android/bin/templates/cordova/lib/list-devices.bat
@@ -1,3 +1,19 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements.  See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership.  The ASF licenses this file
+:: to you under the Apache License, Version 2.0 (the
+:: "License"); you may not use this file except in compliance
+:: with the License.  You may obtain a copy of the License at
+:: 
+:: http://www.apache.org/licenses/LICENSE-2.0
+:: 
+:: Unless required by applicable law or agreed to in writing,
+:: software distributed under the License is distributed on an
+:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+:: KIND, either express or implied.  See the License for the
+:: specific language governing permissions and limitations
+:: under the License.
 @ECHO OFF
 SET full_path=%~dp0
 IF EXIST %full_path%cordova.js (
@@ -6,4 +22,4 @@ IF EXIST %full_path%cordova.js (
     ECHO. 
     ECHO ERROR: Could not find 'cordova.js' in cordova/lib, aborting...>&2
     EXIT /B 1
-)
\ No newline at end of file
+)

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/bin/templates/cordova/lib/list-emulator-images.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-android/bin/templates/cordova/lib/list-emulator-images.bat b/lib/cordova-android/bin/templates/cordova/lib/list-emulator-images.bat
index 172520b..e21aafe 100644
--- a/lib/cordova-android/bin/templates/cordova/lib/list-emulator-images.bat
+++ b/lib/cordova-android/bin/templates/cordova/lib/list-emulator-images.bat
@@ -1,3 +1,19 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements.  See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership.  The ASF licenses this file
+:: to you under the Apache License, Version 2.0 (the
+:: "License"); you may not use this file except in compliance
+:: with the License.  You may obtain a copy of the License at
+:: 
+:: http://www.apache.org/licenses/LICENSE-2.0
+:: 
+:: Unless required by applicable law or agreed to in writing,
+:: software distributed under the License is distributed on an
+:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+:: KIND, either express or implied.  See the License for the
+:: specific language governing permissions and limitations
+:: under the License.
 @ECHO OFF
 SET full_path=%~dp0
 IF EXIST %full_path%cordova.js (
@@ -6,4 +22,4 @@ IF EXIST %full_path%cordova.js (
     ECHO. 
     ECHO ERROR: Could not find 'cordova.js' in cordova/lib, aborting...>&2
     EXIT /B 1
-)
\ No newline at end of file
+)

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/bin/templates/cordova/lib/list-started-emulators.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-android/bin/templates/cordova/lib/list-started-emulators.bat b/lib/cordova-android/bin/templates/cordova/lib/list-started-emulators.bat
index f1b3c5d..eb9f3b6 100644
--- a/lib/cordova-android/bin/templates/cordova/lib/list-started-emulators.bat
+++ b/lib/cordova-android/bin/templates/cordova/lib/list-started-emulators.bat
@@ -1,3 +1,19 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements.  See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership.  The ASF licenses this file
+:: to you under the Apache License, Version 2.0 (the
+:: "License"); you may not use this file except in compliance
+:: with the License.  You may obtain a copy of the License at
+:: 
+:: http://www.apache.org/licenses/LICENSE-2.0
+:: 
+:: Unless required by applicable law or agreed to in writing,
+:: software distributed under the License is distributed on an
+:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+:: KIND, either express or implied.  See the License for the
+:: specific language governing permissions and limitations
+:: under the License.
 @ECHO OFF
 SET full_path=%~dp0
 IF EXIST %full_path%cordova.js (
@@ -6,4 +22,4 @@ IF EXIST %full_path%cordova.js (
     ECHO. 
     ECHO ERROR: Could not find 'cordova.js' in cordova/lib, aborting...>&2
     EXIT /B 1
-)
\ No newline at end of file
+)

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/bin/templates/cordova/lib/start-emulator.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-android/bin/templates/cordova/lib/start-emulator.bat b/lib/cordova-android/bin/templates/cordova/lib/start-emulator.bat
index 4f3fb5d..758c854 100644
--- a/lib/cordova-android/bin/templates/cordova/lib/start-emulator.bat
+++ b/lib/cordova-android/bin/templates/cordova/lib/start-emulator.bat
@@ -1,3 +1,19 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements.  See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership.  The ASF licenses this file
+:: to you under the Apache License, Version 2.0 (the
+:: "License"); you may not use this file except in compliance
+:: with the License.  You may obtain a copy of the License at
+:: 
+:: http://www.apache.org/licenses/LICENSE-2.0
+:: 
+:: Unless required by applicable law or agreed to in writing,
+:: software distributed under the License is distributed on an
+:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+:: KIND, either express or implied.  See the License for the
+:: specific language governing permissions and limitations
+:: under the License.
 @ECHO OFF
 SET full_path=%~dp0
 IF EXIST %full_path%cordova.js (
@@ -6,4 +22,4 @@ IF EXIST %full_path%cordova.js (
     ECHO. 
     ECHO ERROR: Could not find 'cordova.js' in cordova/lib, aborting...>&2
     EXIT /B 1
-)
\ No newline at end of file
+)

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/bin/templates/cordova/log.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-android/bin/templates/cordova/log.bat b/lib/cordova-android/bin/templates/cordova/log.bat
index 2c492e7..c259802 100644
--- a/lib/cordova-android/bin/templates/cordova/log.bat
+++ b/lib/cordova-android/bin/templates/cordova/log.bat
@@ -1,2 +1,18 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements.  See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership.  The ASF licenses this file
+:: to you under the Apache License, Version 2.0 (the
+:: "License"); you may not use this file except in compliance
+:: with the License.  You may obtain a copy of the License at
+:: 
+:: http://www.apache.org/licenses/LICENSE-2.0
+:: 
+:: Unless required by applicable law or agreed to in writing,
+:: software distributed under the License is distributed on an
+:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+:: KIND, either express or implied.  See the License for the
+:: specific language governing permissions and limitations
+:: under the License.
 @ECHO OFF
 %~dp0\cordova.bat log %*

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/bin/templates/cordova/run.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-android/bin/templates/cordova/run.bat b/lib/cordova-android/bin/templates/cordova/run.bat
index b1cab64..f191f67 100644
--- a/lib/cordova-android/bin/templates/cordova/run.bat
+++ b/lib/cordova-android/bin/templates/cordova/run.bat
@@ -1,2 +1,18 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements.  See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership.  The ASF licenses this file
+:: to you under the Apache License, Version 2.0 (the
+:: "License"); you may not use this file except in compliance
+:: with the License.  You may obtain a copy of the License at
+:: 
+:: http://www.apache.org/licenses/LICENSE-2.0
+:: 
+:: Unless required by applicable law or agreed to in writing,
+:: software distributed under the License is distributed on an
+:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+:: KIND, either express or implied.  See the License for the
+:: specific language governing permissions and limitations
+:: under the License.
 @ECHO OFF
-%~dp0\cordova.bat run %*
\ No newline at end of file
+%~dp0\cordova.bat run %*

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/framework/project.properties
----------------------------------------------------------------------
diff --git a/lib/cordova-android/framework/project.properties b/lib/cordova-android/framework/project.properties
index 2f39d91..d556741 100644
--- a/lib/cordova-android/framework/project.properties
+++ b/lib/cordova-android/framework/project.properties
@@ -10,7 +10,7 @@
 # Indicates whether an apk should be generated for each density.
 split.density=false
 # Project target.
-target=android-17
+target=Google Inc.:Google APIs:17
 apk-configurations=
 renderscript.opt.level=O0
 android.library=true

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/framework/res/xml/config.xml
----------------------------------------------------------------------
diff --git a/lib/cordova-android/framework/res/xml/config.xml b/lib/cordova-android/framework/res/xml/config.xml
index 935eda4..5b5a270 100644
--- a/lib/cordova-android/framework/res/xml/config.xml
+++ b/lib/cordova-android/framework/res/xml/config.xml
@@ -1,18 +1,21 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
-   Licensed to the Apache Software Foundation (ASF) under one
-   or more contributor license agreements.  See the NOTICE file
-   distributed with this work for additional information
-   regarding copyright ownership.  The ASF licenses this file
-   to you under the Apache License, Version 2.0 (the
-   "License"); you may not use this file except in compliance
-   with the License.  You may obtain a copy of the License at
-   Unless required by applicable law or agreed to in writing,
-   software distributed under the License is distributed on an
-   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-   KIND, either express or implied.  See the License for the
-   specific language governing permissions and limitations
-   under the License.
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
 -->
 <widget xmlns     = "http://www.w3.org/ns/widgets"
         id        = "io.cordova.helloCordova"

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/framework/src/org/apache/cordova/AudioHandler.java
----------------------------------------------------------------------
diff --git a/lib/cordova-android/framework/src/org/apache/cordova/AudioHandler.java b/lib/cordova-android/framework/src/org/apache/cordova/AudioHandler.java
index 20c3c4e..fd8c9df 100644
--- a/lib/cordova-android/framework/src/org/apache/cordova/AudioHandler.java
+++ b/lib/cordova-android/framework/src/org/apache/cordova/AudioHandler.java
@@ -20,7 +20,7 @@ package org.apache.cordova;
 
 import org.apache.cordova.api.CallbackContext;
 import org.apache.cordova.api.CordovaPlugin;
-import org.apache.cordova.api.DataResource;
+
 import android.content.Context;
 import android.media.AudioManager;
 
@@ -56,11 +56,6 @@ public class AudioHandler extends CordovaPlugin {
         this.pausedForPhone = new ArrayList<AudioPlayer>();
     }
 
-    public String getFilePath(String url, String source){
-        DataResource dataResource = DataResource.initiateNewDataRequestForUri(url, this.webView.pluginManager, cordova, source);
-        return dataResource.getRealFile().getPath();
-    }
-
     /**
      * Executes the request and returns PluginResult.
      * @param action 		The action to execute.
@@ -73,13 +68,13 @@ public class AudioHandler extends CordovaPlugin {
         String result = "";
 
         if (action.equals("startRecordingAudio")) {
-            this.startRecordingAudio(args.getString(0), getFilePath(args.getString(1), "AudioHandler.startRecordingAudio"));
+            this.startRecordingAudio(args.getString(0), FileHelper.stripFileProtocol(args.getString(1)));
         }
         else if (action.equals("stopRecordingAudio")) {
             this.stopRecordingAudio(args.getString(0));
         }
         else if (action.equals("startPlayingAudio")) {
-            this.startPlayingAudio(args.getString(0), getFilePath(args.getString(1), "AudioHandler.startPlayingAudio"));
+            this.startPlayingAudio(args.getString(0), FileHelper.stripFileProtocol(args.getString(1)));
         }
         else if (action.equals("seekToAudio")) {
             this.seekToAudio(args.getString(0), args.getInt(1));
@@ -107,7 +102,7 @@ public class AudioHandler extends CordovaPlugin {
         }
         else if (action.equals("create")) {
             String id = args.getString(0);
-            String src = getFilePath(args.getString(1), "AudioHandler.create");
+            String src = FileHelper.stripFileProtocol(args.getString(1));
             AudioPlayer audio = new AudioPlayer(this, id, src);
             this.players.put(id, audio);
         }

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/framework/src/org/apache/cordova/CameraLauncher.java
----------------------------------------------------------------------
diff --git a/lib/cordova-android/framework/src/org/apache/cordova/CameraLauncher.java b/lib/cordova-android/framework/src/org/apache/cordova/CameraLauncher.java
index 1974dd7..426d250 100755
--- a/lib/cordova-android/framework/src/org/apache/cordova/CameraLauncher.java
+++ b/lib/cordova-android/framework/src/org/apache/cordova/CameraLauncher.java
@@ -20,16 +20,15 @@ package org.apache.cordova;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.OutputStream;
 
 import org.apache.commons.codec.binary.Base64;
 import org.apache.cordova.api.CallbackContext;
 import org.apache.cordova.api.CordovaPlugin;
-import org.apache.cordova.api.DataResource;
 import org.apache.cordova.api.LOG;
 import org.apache.cordova.api.PluginResult;
 import org.json.JSONArray;
@@ -43,6 +42,7 @@ import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.graphics.Matrix;
 import android.graphics.Bitmap.CompressFormat;
+import android.graphics.Rect;
 import android.media.MediaScannerConnection;
 import android.media.MediaScannerConnection.MediaScannerConnectionClient;
 import android.net.Uri;
@@ -290,7 +290,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
 
                     // If sending base64 image back
                     if (destType == DATA_URL) {
-                        bitmap = getScaledBitmap(imageUri.toString());
+                        bitmap = getScaledBitmap(FileHelper.stripFileProtocol(imageUri.toString()));
                         if (bitmap == null) {
                             // Try to get the bitmap from intent.
                             bitmap = (Bitmap)intent.getExtras().get("data");
@@ -316,9 +316,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
                         if (this.saveToPhotoAlbum) {
                             Uri inputUri = getUriFromMediaStore();
                             //Just because we have a media URI doesn't mean we have a real file, we need to make it
-                            DataResource dataResource = DataResource.initiateNewDataRequestForUri(inputUri, webView.pluginManager, cordova, "CameraLauncher.CameraExitIntent");
-                            File file = dataResource.getRealFile();
-                            uri = Uri.fromFile(file);
+                            uri = Uri.fromFile(new File(FileHelper.getRealPath(inputUri, this.cordova)));
                         } else {
                             uri = Uri.fromFile(new File(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()), System.currentTimeMillis() + ".jpg"));
                         }
@@ -334,15 +332,14 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
 
                             this.callbackContext.success(uri.toString());
                         } else {
-                            bitmap = getScaledBitmap(imageUri.toString());
+                            bitmap = getScaledBitmap(FileHelper.stripFileProtocol(imageUri.toString()));
 
                             if (rotate != 0 && this.correctOrientation) {
                                 bitmap = getRotatedBitmap(rotate, bitmap, exif);
                             }
 
                             // Add compressed version of captured image to returned media store Uri
-                            DataResource dataResource = DataResource.initiateNewDataRequestForUri(uri, webView.pluginManager, cordova, "CameraLauncher.CameraExitIntent");
-                            OutputStream os = dataResource.getOutputStream();
+                            OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri);
                             bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os);
                             os.close();
 
@@ -350,7 +347,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
                             if (this.encodingType == JPEG) {
                                 String exifPath;
                                 if (this.saveToPhotoAlbum) {
-                                    exifPath = dataResource.getRealFile().getPath();
+                                    exifPath = FileHelper.getRealPath(uri, this.cordova);
                                 } else {
                                     exifPath = uri.getPath();
                                 }
@@ -401,9 +398,8 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
                         this.callbackContext.success(uri.toString());
                     } else {
                         String uriString = uri.toString();
-                        DataResource dataResource = DataResource.initiateNewDataRequestForUri(uri, webView.pluginManager, cordova, "CameraLauncher.CameraExitIntent");
                         // Get the path to the image. Makes loading so much easier.
-                        String mimeType = dataResource.getMimeType();
+                        String mimeType = FileHelper.getMimeType(uriString, this.cordova);
                         // If we don't have a valid image so quit.
                         if (!("image/jpeg".equalsIgnoreCase(mimeType) || "image/png".equalsIgnoreCase(mimeType))) {
                         	Log.d(LOG_TAG, "I either have a null image path or bitmap");
@@ -444,8 +440,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
                                     // Create an ExifHelper to save the exif data that is lost during compression
                                     String resizePath = DirectoryManager.getTempDirectoryPath(this.cordova.getActivity()) + "/resize.jpg";
                                     // Some content: URIs do not map to file paths (e.g. picasa).
-                                    File realFile = DataResource.initiateNewDataRequestForUri(uri, webView.pluginManager, cordova, "CameraLauncher.CameraExitIntent").getRealFile();
-                                    String realPath = realFile != null? realFile.getPath() : null;
+                                    String realPath = FileHelper.getRealPath(uri, this.cordova);
                                     ExifHelper exif = new ExifHelper();
                                     if (realPath != null && this.encodingType == JPEG) {
                                         try {
@@ -539,15 +534,8 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
      */
     private void writeUncompressedImage(Uri uri) throws FileNotFoundException,
             IOException {
-        DataResource inputDataResource = DataResource.initiateNewDataRequestForUri(imageUri, webView.pluginManager, cordova, "CameraLauncher.writeUncompressedImage");
-        InputStream fis = inputDataResource.getInputStream();
-        DataResource outDataResource = DataResource.initiateNewDataRequestForUri(uri, webView.pluginManager, cordova, "CameraLauncher.writeUncompressedImage");
-        OutputStream os = outDataResource.getOutputStream();
-        if(fis == null) {
-            throw new FileNotFoundException("Could not get the input file");
-        } else if(os == null) {
-            throw new FileNotFoundException("Could not get the output file");
-        }
+        FileInputStream fis = new FileInputStream(FileHelper.stripFileProtocol(imageUri.toString()));
+        OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri);
         byte[] buffer = new byte[4096];
         int len;
         while ((len = fis.read(buffer)) != -1) {
@@ -590,15 +578,14 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
      */
     private Bitmap getScaledBitmap(String imageUrl) throws IOException {
         // If no new width or height were specified return the original bitmap
-        DataResource dataResource = DataResource.initiateNewDataRequestForUri(imageUrl, webView.pluginManager, cordova, "CameraLauncher.getScaledBitmap");
         if (this.targetWidth <= 0 && this.targetHeight <= 0) {
-            return BitmapFactory.decodeStream(dataResource.getInputStream());
+            return BitmapFactory.decodeStream(FileHelper.getInputStreamFromUriString(imageUrl, cordova));
         }
 
         // figure out the original width and height of the image
         BitmapFactory.Options options = new BitmapFactory.Options();
         options.inJustDecodeBounds = true;
-        BitmapFactory.decodeStream(dataResource.getInputStream(), null, options);
+        BitmapFactory.decodeStream(FileHelper.getInputStreamFromUriString(imageUrl, cordova), null, options);
         
         //CB-2292: WTF? Why is the width null?
         if(options.outWidth == 0 || options.outHeight == 0)
@@ -612,7 +599,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
         // Load in the smallest bitmap possible that is closest to the size we want
         options.inJustDecodeBounds = false;
         options.inSampleSize = calculateSampleSize(options.outWidth, options.outHeight, this.targetWidth, this.targetHeight);
-        Bitmap unscaledBitmap = BitmapFactory.decodeStream(dataResource.getInputStream(), null, options);
+        Bitmap unscaledBitmap = BitmapFactory.decodeStream(FileHelper.getInputStreamFromUriString(imageUrl, cordova), null, options);
         if (unscaledBitmap == null) {
             return null;
         }
@@ -711,20 +698,16 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
             bitmap.recycle();
         }
 
-        DataResource dataResource = DataResource.initiateNewDataRequestForUri(oldImage, webView.pluginManager, cordova, "CameraLauncher.cleanup");
-        File file = dataResource.getRealFile();
-        if(file != null) {
-            // Clean up initial camera-written image file.
-            file.delete();
-
-            checkForDuplicateImage(imageType);
-            // Scan for the gallery to update pic refs in gallery
-            if (this.saveToPhotoAlbum && newImage != null) {
-                this.scanForGallery(newImage);
-            }
+        // Clean up initial camera-written image file.
+        (new File(FileHelper.stripFileProtocol(oldImage.toString()))).delete();
 
-            System.gc();
+        checkForDuplicateImage(imageType);
+        // Scan for the gallery to update pic refs in gallery
+        if (this.saveToPhotoAlbum && newImage != null) {
+            this.scanForGallery(newImage);
         }
+
+        System.gc();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/framework/src/org/apache/cordova/Capture.java
----------------------------------------------------------------------
diff --git a/lib/cordova-android/framework/src/org/apache/cordova/Capture.java b/lib/cordova-android/framework/src/org/apache/cordova/Capture.java
index d7ad419..5f737ca 100644
--- a/lib/cordova-android/framework/src/org/apache/cordova/Capture.java
+++ b/lib/cordova-android/framework/src/org/apache/cordova/Capture.java
@@ -26,7 +26,6 @@ import java.io.OutputStream;
 import android.os.Build;
 import org.apache.cordova.api.CallbackContext;
 import org.apache.cordova.api.CordovaPlugin;
-import org.apache.cordova.api.DataResource;
 import org.apache.cordova.api.LOG;
 import org.apache.cordova.api.PluginResult;
 import org.json.JSONArray;
@@ -130,8 +129,7 @@ public class Capture extends CordovaPlugin {
         // If the mimeType isn't set the rest will fail
         // so let's see if we can determine it.
         if (mimeType == null || mimeType.equals("") || "null".equals(mimeType)) {
-            DataResource dataResource = DataResource.initiateNewDataRequestForUri(filePath, webView.pluginManager, cordova, "Capture.dataResource");
-            mimeType = dataResource.getMimeType();
+            mimeType = FileHelper.getMimeType(filePath, cordova);
         }
         Log.d(LOG_TAG, "Mime type = " + mimeType);
 
@@ -158,8 +156,7 @@ public class Capture extends CordovaPlugin {
     private JSONObject getImageData(String filePath, JSONObject obj) throws JSONException {
         BitmapFactory.Options options = new BitmapFactory.Options();
         options.inJustDecodeBounds = true;
-        DataResource dataResource = DataResource.initiateNewDataRequestForUri(filePath, webView.pluginManager, cordova, "Capture.getImageData");
-        BitmapFactory.decodeFile(dataResource.getRealFile().getPath(), options);
+        BitmapFactory.decodeFile(FileHelper.stripFileProtocol(filePath), options);
         obj.put("height", options.outHeight);
         obj.put("width", options.outWidth);
         return obj;
@@ -351,8 +348,7 @@ public class Capture extends CordovaPlugin {
      * @throws IOException
      */
     private JSONObject createMediaFile(Uri data) {
-        DataResource dataResource = DataResource.initiateNewDataRequestForUri(data, webView.pluginManager, cordova, "Capture.createMediaFile");
-        File fp = dataResource.getRealFile();
+        File fp = new File(FileHelper.getRealPath(data, this.cordova));
         JSONObject obj = new JSONObject();
 
         try {
@@ -362,7 +358,6 @@ public class Capture extends CordovaPlugin {
             // Because of an issue with MimeTypeMap.getMimeTypeFromExtension() all .3gpp files
             // are reported as video/3gpp. I'm doing this hacky check of the URI to see if it
             // is stored in the audio or video content store.
-
             if (fp.getAbsoluteFile().toString().endsWith(".3gp") || fp.getAbsoluteFile().toString().endsWith(".3gpp")) {
                 if (data.toString().contains("/audio/")) {
                     obj.put("type", AUDIO_3GPP);
@@ -370,7 +365,7 @@ public class Capture extends CordovaPlugin {
                     obj.put("type", VIDEO_3GPP);
                 }
             } else {
-                obj.put("type", dataResource.getMimeType());
+                obj.put("type", FileHelper.getMimeType(fp.getAbsolutePath(), cordova));
             }
 
             obj.put("lastModifiedDate", fp.lastModified());

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/framework/src/org/apache/cordova/FileHelper.java
----------------------------------------------------------------------
diff --git a/lib/cordova-android/framework/src/org/apache/cordova/FileHelper.java b/lib/cordova-android/framework/src/org/apache/cordova/FileHelper.java
index 8bc24aa..8b446b0 100644
--- a/lib/cordova-android/framework/src/org/apache/cordova/FileHelper.java
+++ b/lib/cordova-android/framework/src/org/apache/cordova/FileHelper.java
@@ -26,11 +26,10 @@ import org.apache.cordova.api.CordovaInterface;
 import org.apache.cordova.api.LOG;
 
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
+import java.net.URLConnection;
+import java.util.Locale;
 
 public class FileHelper {
     private static final String LOG_TAG = "FileUtils";
@@ -91,63 +90,16 @@ public class FileHelper {
      * @throws IOException
      */
     public static InputStream getInputStreamFromUriString(String uriString, CordovaInterface cordova) throws IOException {
-        if (uriString.startsWith("content:")) {
+        if (uriString.startsWith("content")) {
             Uri uri = Uri.parse(uriString);
             return cordova.getActivity().getContentResolver().openInputStream(uri);
         } else if (uriString.startsWith("file:///android_asset/")) {
             Uri uri = Uri.parse(uriString);
             String relativePath = uri.getPath().substring(15);
             return cordova.getActivity().getAssets().open(relativePath);
-        } else if (uriString.startsWith("file://")) {
-            return new FileInputStream(getRealPath(uriString, cordova));
         } else {
-            return null;
-        }
-    }
-
-    public static OutputStream getOutputStreamFromUriString(String uriString, CordovaInterface cordova) throws FileNotFoundException{
-        if (uriString.startsWith("content:")) {
-            Uri uri = Uri.parse(uriString);
-            return cordova.getActivity().getContentResolver().openOutputStream(uri);
-        } else if (uriString.startsWith("file:") && !uriString.startsWith("file:///android_asset/")) {
-            String realPath = uriString.substring(7);
-            return new FileOutputStream(realPath);
-        } else {
-            return null;
-        }
-    }
-    /**
-     * Returns whether the uri can be written to by openeing a File to that uri
-     *
-     * @param the URI to test
-     * @return boolean indicating whether the uri is writable
-     */
-    public static boolean isUriWritable(String uriString) {
-        String scheme = uriString.split(":")[0];
-
-        if(scheme.equals("file")){
-            // special case file
-            return !uriString.startsWith("file:///android_asset/");
-        }
-        return "content".equals(scheme);
-    }
-
-    /**
-     * Ensures the "file://" prefix exists for the given string
-     * If the given URI string already has a scheme, it is returned unchanged
-     *
-     * @param path - the path string to operate on
-     * @return a String with the "file://" scheme set
-     */
-    public static String insertFileProtocol(String path) {
-        if(!path.matches("^[a-z0-9+.-]+:.*")){
-            //Ensure it is not a relative path
-            if(!path.startsWith("/")){
-                throw new IllegalArgumentException("Relative paths" + path + "are not allowed.");
-            }
-            path = "file://" + path;
+            return new FileInputStream(getRealPath(uriString, cordova));
         }
-        return path;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/framework/src/org/apache/cordova/FileUtils.java
----------------------------------------------------------------------
diff --git a/lib/cordova-android/framework/src/org/apache/cordova/FileUtils.java b/lib/cordova-android/framework/src/org/apache/cordova/FileUtils.java
index e62fc4a..2135be9 100755
--- a/lib/cordova-android/framework/src/org/apache/cordova/FileUtils.java
+++ b/lib/cordova-android/framework/src/org/apache/cordova/FileUtils.java
@@ -18,6 +18,8 @@
  */
 package org.apache.cordova;
 
+import android.database.Cursor;
+import android.net.Uri;
 import android.os.Environment;
 import android.provider.MediaStore;
 import android.util.Log;
@@ -25,7 +27,6 @@ import android.util.Log;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.cordova.api.CallbackContext;
 import org.apache.cordova.api.CordovaPlugin;
-import org.apache.cordova.api.DataResource;
 import org.apache.cordova.api.PluginResult;
 import org.apache.cordova.file.EncodingException;
 import org.apache.cordova.file.FileExistsException;
@@ -45,6 +46,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.RandomAccessFile;
 import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLDecoder;
 import java.nio.channels.FileChannel;
 
 /**
@@ -231,7 +234,7 @@ public class FileUtils extends CordovaPlugin {
      * @param filePath the path to check
      */
     private void notifyDelete(String filePath) {
-        String newFilePath = DataResource.initiateNewDataRequestForUri(filePath, webView.pluginManager, cordova, "FileUtils.notifyDelete").getRealFile().getPath();
+        String newFilePath = FileHelper.getRealPath(filePath, cordova);
         try {
             this.cordova.getActivity().getContentResolver().delete(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                     MediaStore.Images.Media.DATA + " = ?",
@@ -253,10 +256,37 @@ public class FileUtils extends CordovaPlugin {
      * @throws IOException if the user can't read the file
      * @throws JSONException
      */
+    @SuppressWarnings("deprecation")
     private JSONObject resolveLocalFileSystemURI(String url) throws IOException, JSONException {
-        File fp = DataResource.initiateNewDataRequestForUri(url, webView.pluginManager, cordova, "FileUtils.resolveLocalFileSystemURI").getRealFile();
+        String decoded = URLDecoder.decode(url, "UTF-8");
 
-        if (fp == null || !fp.exists()) {
+        File fp = null;
+
+        // Handle the special case where you get an Android content:// uri.
+        if (decoded.startsWith("content:")) {
+            Cursor cursor = this.cordova.getActivity().managedQuery(Uri.parse(decoded), new String[] { MediaStore.Images.Media.DATA }, null, null, null);
+            // Note: MediaStore.Images/Audio/Video.Media.DATA is always "_data"
+            int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
+            cursor.moveToFirst();
+            fp = new File(cursor.getString(column_index));
+        } else {
+            // Test to see if this is a valid URL first
+            @SuppressWarnings("unused")
+            URL testUrl = new URL(decoded);
+
+            if (decoded.startsWith("file://")) {
+                int questionMark = decoded.indexOf("?");
+                if (questionMark < 0) {
+                    fp = new File(decoded.substring(7, decoded.length()));
+                } else {
+                    fp = new File(decoded.substring(7, questionMark));
+                }
+            } else {
+                fp = new File(decoded);
+            }
+        }
+
+        if (!fp.exists()) {
             throw new FileNotFoundException();
         }
         if (!fp.canRead()) {
@@ -274,9 +304,9 @@ public class FileUtils extends CordovaPlugin {
      * @throws JSONException
      */
     private JSONArray readEntries(String fileName) throws FileNotFoundException, JSONException {
-        File fp = DataResource.initiateNewDataRequestForUri(fileName, webView.pluginManager, cordova, "FileUtils.readEntries").getRealFile();
+        File fp = createFileObject(fileName);
 
-        if (fp == null || !fp.exists()) {
+        if (!fp.exists()) {
             // The directory we are listing doesn't exist so we should fail.
             throw new FileNotFoundException();
         }
@@ -311,10 +341,8 @@ public class FileUtils extends CordovaPlugin {
      * @throws FileExistsException
      */
     private JSONObject transferTo(String fileName, String newParent, String newName, boolean move) throws JSONException, NoModificationAllowedException, IOException, InvalidModificationException, EncodingException, FileExistsException {
-        DataResource dataResourceFrom = DataResource.initiateNewDataRequestForUri(fileName, webView.pluginManager, cordova, "FileUtils.transferTo");
-        String newFileName = dataResourceFrom.getRealFile().getPath();
-        DataResource dataResourceTo = DataResource.initiateNewDataRequestForUri(newParent, webView.pluginManager, cordova, "FileUtils.transferTo");
-        newParent = dataResourceTo.getRealFile().getPath();
+        String newFileName = FileHelper.getRealPath(fileName, cordova);
+        newParent = FileHelper.getRealPath(newParent, cordova);
 
         // Check for invalid file name
         if (newName != null && newName.contains(":")) {
@@ -585,7 +613,7 @@ public class FileUtils extends CordovaPlugin {
      * @throws FileExistsException
      */
     private boolean removeRecursively(String filePath) throws FileExistsException {
-        File fp = DataResource.initiateNewDataRequestForUri(filePath, webView.pluginManager, cordova, "FileUtils.readEntries").getRealFile();
+        File fp = createFileObject(filePath);
 
         // You can't delete the root directory.
         if (atRootDirectory(filePath)) {
@@ -626,7 +654,7 @@ public class FileUtils extends CordovaPlugin {
      * @throws InvalidModificationException
      */
     private boolean remove(String filePath) throws NoModificationAllowedException, InvalidModificationException {
-        File fp = DataResource.initiateNewDataRequestForUri(filePath, webView.pluginManager, cordova, "FileUtils.readEntries").getRealFile();
+        File fp = createFileObject(filePath);
 
         // You can't delete the root directory.
         if (atRootDirectory(filePath)) {
@@ -670,8 +698,7 @@ public class FileUtils extends CordovaPlugin {
             throw new EncodingException("This file has a : in it's name");
         }
 
-        String filePath = getFullFilePath(dirPath, fileName);
-        File fp = DataResource.initiateNewDataRequestForUri(filePath, webView.pluginManager, cordova, "FileUtils.getFile").getRealFile();
+        File fp = createFileObject(dirPath, fileName);
 
         if (create) {
             if (exclusive && fp.exists()) {
@@ -713,14 +740,15 @@ public class FileUtils extends CordovaPlugin {
      * @param fileName new file name
      * @return
      */
-    private String getFullFilePath(String dirPath, String fileName) {
+    private File createFileObject(String dirPath, String fileName) {
+        File fp = null;
         if (fileName.startsWith("/")) {
-            return fileName;
+            fp = new File(fileName);
         } else {
-            DataResource dataResource = DataResource.initiateNewDataRequestForUri(dirPath, webView.pluginManager, cordova, "FileUtils.getFullFilePath");
-            dirPath = dataResource.getRealFile().getPath();
-            return dirPath + File.separator + fileName;
+            dirPath = FileHelper.getRealPath(dirPath, cordova);
+            fp = new File(dirPath + File.separator + fileName);
         }
+        return fp;
     }
 
     /**
@@ -732,13 +760,12 @@ public class FileUtils extends CordovaPlugin {
      * @throws JSONException
      */
     private JSONObject getParent(String filePath) throws JSONException {
-        DataResource dataResource = DataResource.initiateNewDataRequestForUri(filePath, webView.pluginManager, cordova, "FileUtils.getParent");
-        filePath = dataResource.getRealFile().getPath();
+        filePath = FileHelper.getRealPath(filePath, cordova);
 
         if (atRootDirectory(filePath)) {
             return getEntry(filePath);
         }
-        return getEntry(dataResource.getRealFile().getParent());
+        return getEntry(new File(filePath).getParent());
     }
 
     /**
@@ -749,7 +776,7 @@ public class FileUtils extends CordovaPlugin {
      * @return true if we are at the root, false otherwise.
      */
     private boolean atRootDirectory(String filePath) {
-        filePath = DataResource.initiateNewDataRequestForUri(filePath, webView.pluginManager, cordova, "FileUtils.atRootDirectory").getRealFile().getPath();
+        filePath = FileHelper.getRealPath(filePath, cordova);
 
         if (filePath.equals(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data/" + cordova.getActivity().getPackageName() + "/cache") ||
                 filePath.equals(Environment.getExternalStorageDirectory().getAbsolutePath()) ||
@@ -760,6 +787,19 @@ public class FileUtils extends CordovaPlugin {
     }
 
     /**
+     * Create a File object from the passed in path
+     *
+     * @param filePath
+     * @return
+     */
+    private File createFileObject(String filePath) {
+        filePath = FileHelper.getRealPath(filePath, cordova);
+
+        File file = new File(filePath);
+        return file;
+    }
+
+    /**
      * Look up metadata about this entry.
      *
      * @param filePath to entry
@@ -767,9 +807,9 @@ public class FileUtils extends CordovaPlugin {
      * @throws FileNotFoundException
      */
     private long getMetadata(String filePath) throws FileNotFoundException {
-        File file = DataResource.initiateNewDataRequestForUri(filePath, webView.pluginManager, cordova, "FileUtils.getMetadata").getRealFile();
+        File file = createFileObject(filePath);
 
-        if (file == null || !file.exists()) {
+        if (!file.exists()) {
             throw new FileNotFoundException("Failed to find file in getMetadata");
         }
 
@@ -785,16 +825,15 @@ public class FileUtils extends CordovaPlugin {
      * @throws JSONException
      */
     private JSONObject getFileMetadata(String filePath) throws FileNotFoundException, JSONException {
-        DataResource dataResource = DataResource.initiateNewDataRequestForUri(filePath, webView.pluginManager, cordova, "FileUtils.getMetadata");
-        File file = dataResource.getRealFile();
+        File file = createFileObject(filePath);
 
-        if (file == null || !file.exists()) {
+        if (!file.exists()) {
             throw new FileNotFoundException("File: " + filePath + " does not exist.");
         }
 
         JSONObject metadata = new JSONObject();
         metadata.put("size", file.length());
-        metadata.put("type", dataResource.getMimeType());
+        metadata.put("type", FileHelper.getMimeType(filePath, cordova));
         metadata.put("name", file.getName());
         metadata.put("fullPath", filePath);
         metadata.put("lastModifiedDate", file.lastModified());
@@ -896,8 +935,7 @@ public class FileUtils extends CordovaPlugin {
         this.cordova.getThreadPool().execute(new Runnable() {
             public void run() {
                 try {
-                    DataResource dataResource = DataResource.initiateNewDataRequestForUri(filename, webView.pluginManager, cordova, "FileUtils.readFileAs");
-                    byte[] bytes = readAsBinaryHelper(dataResource.getInputStream(), start, end);
+                    byte[] bytes = readAsBinaryHelper(filename, start, end);
                     
                     PluginResult result;
                     switch (resultType) {
@@ -911,7 +949,7 @@ public class FileUtils extends CordovaPlugin {
                             result = new PluginResult(PluginResult.Status.OK, bytes, true);
                             break;
                         default: // Base64.
-                            String contentType = dataResource.getMimeType();
+                            String contentType = FileHelper.getMimeType(filename, cordova);
                             byte[] base64 = Base64.encodeBase64(bytes);
                             String s = "data:" + contentType + ";base64," + new String(base64, "US-ASCII");
                             result = new PluginResult(PluginResult.Status.OK, s);
@@ -938,9 +976,10 @@ public class FileUtils extends CordovaPlugin {
      * @return                  Contents of the file as a byte[].
      * @throws IOException
      */
-    private byte[] readAsBinaryHelper(InputStream inputStream, int start, int end) throws IOException {
+    private byte[] readAsBinaryHelper(String filename, int start, int end) throws IOException {
         int numBytesToRead = end - start;
         byte[] bytes = new byte[numBytesToRead];
+        InputStream inputStream = FileHelper.getInputStreamFromUriString(filename, cordova);
         int numBytesRead = 0;
 
         if (start > 0) {
@@ -969,8 +1008,7 @@ public class FileUtils extends CordovaPlugin {
             throw new NoModificationAllowedException("Couldn't write to file given its content URI");
         }
 
-        DataResource dataResource = DataResource.initiateNewDataRequestForUri(filename, webView.pluginManager, cordova, "FileUtils.write");
-        filename = dataResource.getRealFile().getPath();
+        filename = FileHelper.getRealPath(filename, cordova);
 
         boolean append = false;
         if (offset > 0) {
@@ -999,16 +1037,13 @@ public class FileUtils extends CordovaPlugin {
      * @throws NoModificationAllowedException
      */
     private long truncateFile(String filename, long size) throws FileNotFoundException, IOException, NoModificationAllowedException {
-        DataResource dataResource = DataResource.initiateNewDataRequestForUri(filename, webView.pluginManager, cordova, "FileUtils.truncateFile");
-        if(!dataResource.isWritable()) {
-            throw new NoModificationAllowedException("Couldn't truncate file as it is not writable");
-        }
-        File file = dataResource.getRealFile();
-        if(file == null) {
-            throw new FileNotFoundException("Couldn't get the file");
+        if (filename.startsWith("content://")) {
+            throw new NoModificationAllowedException("Couldn't truncate file given its content URI");
         }
 
-        RandomAccessFile raf = new RandomAccessFile(file, "rw");
+        filename = FileHelper.getRealPath(filename, cordova);
+
+        RandomAccessFile raf = new RandomAccessFile(filename, "rw");
         try {
             if (raf.length() >= size) {
                 FileChannel channel = raf.getChannel();

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
----------------------------------------------------------------------
diff --git a/lib/cordova-android/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java b/lib/cordova-android/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
index 14c7603..847972e 100644
--- a/lib/cordova-android/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
+++ b/lib/cordova-android/framework/src/org/apache/cordova/IceCreamCordovaWebViewClient.java
@@ -22,8 +22,6 @@ import java.io.IOException;
 import java.io.InputStream;
 
 import org.apache.cordova.api.CordovaInterface;
-import org.apache.cordova.api.DataResource;
-import org.apache.cordova.api.DataResourceContext;
 import org.apache.cordova.api.LOG;
 
 import android.annotation.TargetApi;
@@ -45,27 +43,41 @@ public class IceCreamCordovaWebViewClient extends CordovaWebViewClient {
 
     @Override
     public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
-        // We need to support the new DataResource intercepts without breaking the shouldInterceptRequest mechanism.
-        DataResource dataResource = DataResource.initiateNewDataRequestForUri(url, this.appView.pluginManager, cordova,
-                "WebViewClient.shouldInterceptRequest");
-        url = dataResource.getUri().toString();
-
-        // This mechanism is no longer needed due to the dataResource mechanism. It would be awesome to just get rid of it.
         //Check if plugins intercept the request
         WebResourceResponse ret = super.shouldInterceptRequest(view, url);
+        if(ret == null && (url.contains("?") || url.contains("#") || needsIceCreamSpaceInAssetUrlFix(url))){
+            ret = generateWebResourceResponse(url);
+        }
+        return ret;
+    }
+
+    private WebResourceResponse generateWebResourceResponse(String url) {
+        if (url.startsWith("file:///android_asset/")) {
+            String mimetype = FileHelper.getMimeType(url, cordova);
 
-        if(ret == null) {
             try {
-                InputStream is;
-                String mimeType;
-                if((is = dataResource.getInputStream()) != null && (mimeType = dataResource.getMimeType()) != null) {
-                    // If we don't know how to open this file, let the browser continue loading
-                    ret = new WebResourceResponse(mimeType, "UTF-8", is);
-                }
-            } catch(IOException e) {
-                LOG.e("IceCreamCordovaWebViewClient", "Error occurred while loading a file.", e);
+                InputStream stream = FileHelper.getInputStreamFromUriString(url, cordova);
+                WebResourceResponse response = new WebResourceResponse(mimetype, "UTF-8", stream);
+                return response;
+            } catch (IOException e) {
+                LOG.e("generateWebResourceResponse", e.getMessage(), e);
             }
         }
-        return ret;
+        return null;
     }
+    
+    private static boolean needsIceCreamSpaceInAssetUrlFix(String url) {
+        if (!url.contains("%20")){
+            return false;
+        }
+
+        switch(android.os.Build.VERSION.SDK_INT){
+            case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH:
+            case android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1:
+                return true;
+            default:
+                return false;
+        }
+    }
+    
 }

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/framework/src/org/apache/cordova/JSONUtils.java
----------------------------------------------------------------------
diff --git a/lib/cordova-android/framework/src/org/apache/cordova/JSONUtils.java b/lib/cordova-android/framework/src/org/apache/cordova/JSONUtils.java
index 77df876..da777c1 100644
--- a/lib/cordova-android/framework/src/org/apache/cordova/JSONUtils.java
+++ b/lib/cordova-android/framework/src/org/apache/cordova/JSONUtils.java
@@ -1,3 +1,21 @@
+/*
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+*/
 package org.apache.cordova;
 
 import java.util.ArrayList;

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/framework/src/org/apache/cordova/api/CallbackContext.java
----------------------------------------------------------------------
diff --git a/lib/cordova-android/framework/src/org/apache/cordova/api/CallbackContext.java b/lib/cordova-android/framework/src/org/apache/cordova/api/CallbackContext.java
index a5d1255..237d0f4 100644
--- a/lib/cordova-android/framework/src/org/apache/cordova/api/CallbackContext.java
+++ b/lib/cordova-android/framework/src/org/apache/cordova/api/CallbackContext.java
@@ -1,3 +1,21 @@
+/*
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+*/
 package org.apache.cordova.api;
 
 import org.json.JSONArray;

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/framework/src/org/apache/cordova/api/CordovaPlugin.java
----------------------------------------------------------------------
diff --git a/lib/cordova-android/framework/src/org/apache/cordova/api/CordovaPlugin.java b/lib/cordova-android/framework/src/org/apache/cordova/api/CordovaPlugin.java
index 866677c..2b225e6 100644
--- a/lib/cordova-android/framework/src/org/apache/cordova/api/CordovaPlugin.java
+++ b/lib/cordova-android/framework/src/org/apache/cordova/api/CordovaPlugin.java
@@ -176,20 +176,6 @@ public class CordovaPlugin {
     }
 
     /**
-     * All plugins can now choose if they want to modify any uri requests. This includes all webview requests, opening of files, content uri's etc.
-     * This mechanism allows several plugins to modify the same request
-     * @param requestSource The source of the incoming request
-     *
-     * @param dataResource          The resource to be loaded.
-     * @param dataResourceContext   Context associated with the resource load
-     * @return                      Return a new DataResource if the plugin wants to assist in loading the request or null if it doesn't.
-     */
-    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
-    public DataResource handleDataResourceRequest(DataResource dataResource, DataResourceContext dataResourceContext) {
-        return null;
-    }
-
-    /**
      * Called when the WebView does a top-level navigation or refreshes.
      *
      * Plugins should stop any long-running processes and clean up internal state.

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/framework/src/org/apache/cordova/api/PluginManager.java
----------------------------------------------------------------------
diff --git a/lib/cordova-android/framework/src/org/apache/cordova/api/PluginManager.java b/lib/cordova-android/framework/src/org/apache/cordova/api/PluginManager.java
index e0ceabf..71fc258 100755
--- a/lib/cordova-android/framework/src/org/apache/cordova/api/PluginManager.java
+++ b/lib/cordova-android/framework/src/org/apache/cordova/api/PluginManager.java
@@ -54,7 +54,6 @@ public class PluginManager {
     // Map URL schemes like foo: to plugins that want to handle those schemes
     // This would allow how all URLs are handled to be offloaded to a plugin
     protected HashMap<String, String> urlMap = new HashMap<String, String>();
-    private int MAX_REPITIONS = 1000;
 
     /**
      * Constructor.
@@ -401,32 +400,4 @@ public class PluginManager {
         LOG.e(TAG, "https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-android.git;a=blob;f=framework/res/xml/plugins.xml");
         LOG.e(TAG, "=====================================================================================");
     }
-
-    /**
-     * Called when the any resource is going to be loaded - either from the webview, files or any other resource
-     *
-     *
-     * @param dataResource          The resource request to be loaded.
-     * @param dataResourceContext   The context of the dataResource request
-     * @return                      Return the resource request that will be loaded. The returned request may be modified or unchanged.
-     */
-    public DataResource handleDataResourceRequestWithPlugins(DataResource dataResource, DataResourceContext dataResourceContext){
-        int repetitions = 0;
-        boolean requestModified = true;
-        while(requestModified && repetitions < MAX_REPITIONS) {
-            requestModified = false;
-            repetitions ++;
-            for (PluginEntry entry : this.entries.values()) {
-                if (entry.plugin != null) {
-                    DataResource ret = entry.plugin.handleDataResourceRequest(dataResource, dataResourceContext);
-                    if(ret != null) {
-                        dataResource = ret;
-                        requestModified = true;
-                        break;
-                    }
-                }
-            }
-        }
-        return dataResource;
-    }
 }

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/test/README.md
----------------------------------------------------------------------
diff --git a/lib/cordova-android/test/README.md b/lib/cordova-android/test/README.md
index 79cf85f..5d86720 100755
--- a/lib/cordova-android/test/README.md
+++ b/lib/cordova-android/test/README.md
@@ -1,3 +1,23 @@
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+# http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+-->
 # Android Native Tests #
 
 These tests are designed to verify Android native features and other Android specific features.

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-android/test/res/xml/config.xml
----------------------------------------------------------------------
diff --git a/lib/cordova-android/test/res/xml/config.xml b/lib/cordova-android/test/res/xml/config.xml
index d3ea4d8..5ad2b25 100644
--- a/lib/cordova-android/test/res/xml/config.xml
+++ b/lib/cordova-android/test/res/xml/config.xml
@@ -1,4 +1,22 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
 <widget xmlns     = "http://www.w3.org/ns/widgets"
         id        = "io.cordova.helloCordova"
         version   = "2.0.0">

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-ios/CordovaLib/Classes/CDVAvailability.h
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVAvailability.h b/lib/cordova-ios/CordovaLib/Classes/CDVAvailability.h
index b288522..324237d 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVAvailability.h
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVAvailability.h
@@ -41,6 +41,7 @@
 #define __CORDOVA_2_5_0 20500
 #define __CORDOVA_2_6_0 20600
 #define __CORDOVA_2_7_0 20700
+#define __CORDOVA_2_8_0 20800
 #define __CORDOVA_NA 99999      /* not available */
 
 /*
@@ -51,7 +52,7 @@
  #endif
  */
 #ifndef CORDOVA_VERSION_MIN_REQUIRED
-    #define CORDOVA_VERSION_MIN_REQUIRED __CORDOVA_2_7_0
+    #define CORDOVA_VERSION_MIN_REQUIRED __CORDOVA_2_8_0
 #endif
 
 /*

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-ios/CordovaLib/Classes/CDVDevice.m
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVDevice.m b/lib/cordova-ios/CordovaLib/Classes/CDVDevice.m
index cc7ad89..a331b81 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVDevice.m
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVDevice.m
@@ -75,7 +75,6 @@
     [devProps setObject:@"iOS" forKey:@"platform"];
     [devProps setObject:[device systemVersion] forKey:@"version"];
     [devProps setObject:[device uniqueAppInstanceIdentifier] forKey:@"uuid"];
-    [devProps setObject:[device model] forKey:@"name"];
     [devProps setObject:[[self class] cordovaVersion] forKey:@"cordova"];
 
     NSDictionary* devReturn = [NSDictionary dictionaryWithDictionary:devProps];

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-ios/CordovaLib/Classes/CDVWebViewDelegate.m
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/Classes/CDVWebViewDelegate.m b/lib/cordova-ios/CordovaLib/Classes/CDVWebViewDelegate.m
index fd9c032..1ee7aea 100644
--- a/lib/cordova-ios/CordovaLib/Classes/CDVWebViewDelegate.m
+++ b/lib/cordova-ios/CordovaLib/Classes/CDVWebViewDelegate.m
@@ -193,11 +193,16 @@ typedef enum {
                     break;
 
                 default:
-                    NSLog(@"CDVWebViewDelegate: Navigation started when state=%d", _state);
-                    _loadCount = 0;
-                    _state = STATE_WAITING_FOR_LOAD_START;
-                    if ([_delegate respondsToSelector:@selector(webView:didFailLoadWithError:)]) {
-                        [_delegate webView:webView didFailLoadWithError:nil];
+                    {
+                        NSString* description = [NSString stringWithFormat:@"CDVWebViewDelegate: Navigation started when state=%d", _state];
+                        NSLog(@"%@", description);
+                        _loadCount = 0;
+                        _state = STATE_WAITING_FOR_LOAD_START;
+                        if ([_delegate respondsToSelector:@selector(webView:didFailLoadWithError:)]) {
+                            NSDictionary* errorDictionary = @{NSLocalizedDescriptionKey : description};
+                            NSError* error = [[NSError alloc] initWithDomain:@"CDVWebViewDelegate" code:1 userInfo:errorDictionary];
+                            [_delegate webView:webView didFailLoadWithError:error];
+                        }
                     }
             }
         } else {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-ios/CordovaLibTests/CordovaLibApp/config.xml
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLibTests/CordovaLibApp/config.xml b/lib/cordova-ios/CordovaLibTests/CordovaLibApp/config.xml
index 3e84967..136804e 100644
--- a/lib/cordova-ios/CordovaLibTests/CordovaLibApp/config.xml
+++ b/lib/cordova-ios/CordovaLibTests/CordovaLibApp/config.xml
@@ -1,4 +1,22 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
 <widget xmlns     = "http://www.w3.org/ns/widgets"
         id        = "io.cordova.helloCordova"
         version   = "2.0.0">

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/61e23c1e/lib/cordova-ios/CordovaLibTests/ExifTests.h
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLibTests/ExifTests.h b/lib/cordova-ios/CordovaLibTests/ExifTests.h
index b46241b..45e17c4 100644
--- a/lib/cordova-ios/CordovaLibTests/ExifTests.h
+++ b/lib/cordova-ios/CordovaLibTests/ExifTests.h
@@ -1,10 +1,21 @@
-//
-//  ExifTestTests.h
-//  ExifTestTests
-//
-//  Created by Lorin Beer on 2013-03-18.
-//
-//
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
 
 #import <SenTestingKit/SenTestingKit.h>
 
@@ -13,15 +24,15 @@
 #define ARC4RANDOM_MAX 0x100000000
 
 @interface ExifTestTests : SenTestCase {
-    CDVJpegHeaderWriter * testHeaderWriter;
-    NSNumber * testErrorThreshhold;
+    CDVJpegHeaderWriter* testHeaderWriter;
+    NSNumber* testErrorThreshhold;
 }
 
-- (void) testContinuedFractionWithUInt;
-- (void) testContinuedFractionWithUFloat;
-- (void) testContinuedFractionsWorstCase;
-- (void) testFormatHexFromDecimal;
-- (void) testFormatNumberWithLeadingZeroes;
-- (void) testUnsignedRationalToString;
-- (void) testSignedRationalToString;
-@end
\ No newline at end of file
+- (void)testContinuedFractionWithUInt;
+- (void)testContinuedFractionWithUFloat;
+- (void)testContinuedFractionsWorstCase;
+- (void)testFormatHexFromDecimal;
+- (void)testFormatNumberWithLeadingZeroes;
+- (void)testUnsignedRationalToString;
+- (void)testSignedRationalToString;
+@end


[06/22] git commit: updated instrucitons on how to use verbose mode from CL, bumped to npm version 2.8.3

Posted by fi...@apache.org.
updated instrucitons on how to use verbose mode from CL, bumped to npm version 2.8.3


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/3124223e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/3124223e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/3124223e

Branch: refs/heads/2.8.x
Commit: 3124223e931e58dd80eda500890de8044dea3026
Parents: 00d8853
Author: Fil Maj <ma...@gmail.com>
Authored: Tue Jun 4 17:25:16 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 6 18:26:11 2013 -0700

----------------------------------------------------------------------
 README.md    |    3 +++
 package.json |    2 +-
 2 files changed, 4 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/3124223e/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index db232ce..2ea3da4 100644
--- a/README.md
+++ b/README.md
@@ -47,6 +47,9 @@ cordova-cli has a single global `create` command that creates new cordova projec
 - `emulate [<platform> [<platform> [...]]]` launch emulators and deploy app to them. With no parameters emulates for all platforms added to the project, otherwise emulates for the specified platforms
 - `serve <platform> [port]` launch a local web server for that platform's www directory on the given port (default 8000).
 
+### Optional Flags
+
+- `-d` or `--verbose` will pipe out more verbose output to your shell. You can also subscribe to `log` and `warn` events if you are consuming cordova-cli as a node module by calling `cordova.on('log', function() {})` or `cordova.on('warn', function() {})`.
 
 # Project Directory Structure
 A Cordova application built with cordova-cli will have the following directory structure:

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/3124223e/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 0642eb2..71f9453 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "cordova",
-  "version": "2.8.2",
+  "version": "2.8.3",
   "preferGlobal": "true",
   "description": "Cordova command line interface tool",
   "main": "cordova",


[14/22] git commit: npm version 2.8.8. Should resolve [CB-3614]. Updated bundled android lib to 2.8.0 tag.

Posted by fi...@apache.org.
npm version 2.8.8. Should resolve [CB-3614]. Updated bundled android lib to 2.8.0 tag.


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/2c4112ec
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/2c4112ec
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/2c4112ec

Branch: refs/heads/2.8.x
Commit: 2c4112ec114f8f61ef1a53f6eb32d9f8a8bdcc2f
Parents: ca42474
Author: Fil Maj <ma...@gmail.com>
Authored: Wed Jun 5 14:10:09 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 6 18:29:25 2013 -0700

----------------------------------------------------------------------
 lib/cordova-android/VERSION                        |    2 +-
 .../framework/assets/www/cordova.js                |   26 ++-
 .../src/org/apache/cordova/api/DataResource.java   |  141 ---------------
 .../apache/cordova/api/DataResourceContext.java    |   31 ----
 package.json                                       |    2 +-
 5 files changed, 19 insertions(+), 183 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2c4112ec/lib/cordova-android/VERSION
----------------------------------------------------------------------
diff --git a/lib/cordova-android/VERSION b/lib/cordova-android/VERSION
index 1277c83..834f262 100644
--- a/lib/cordova-android/VERSION
+++ b/lib/cordova-android/VERSION
@@ -1 +1 @@
-2.8.0rc1
+2.8.0

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2c4112ec/lib/cordova-android/framework/assets/www/cordova.js
----------------------------------------------------------------------
diff --git a/lib/cordova-android/framework/assets/www/cordova.js b/lib/cordova-android/framework/assets/www/cordova.js
index 3730047..5e460e4 100644
--- a/lib/cordova-android/framework/assets/www/cordova.js
+++ b/lib/cordova-android/framework/assets/www/cordova.js
@@ -1,5 +1,5 @@
 // Platform: android
-// 2.8.0rc1-0-g22bc4d8
+// 2.8.0-0-g6208c95
 /*
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
@@ -19,7 +19,7 @@
  under the License.
 */
 ;(function() {
-var CORDOVA_JS_BUILD_LABEL = '2.8.0rc1-0-g22bc4d8';
+var CORDOVA_JS_BUILD_LABEL = '2.8.0-0-g6208c95';
 // file: lib/scripts/require.js
 
 var require,
@@ -2396,11 +2396,7 @@ function initRead(reader, file) {
     reader._error = null;
     reader._readyState = FileReader.LOADING;
 
-    if (typeof file == 'string') {
-        // Deprecated in Cordova 2.4.
-        console.warn('Using a string argument with FileReader.readAs functions is deprecated.');
-        reader._fileName = file;
-    } else if (typeof file.fullPath == 'string') {
+    if (typeof file.fullPath == 'string') {
         reader._fileName = file.fullPath;
     } else {
         reader._fileName = '';
@@ -4071,6 +4067,10 @@ module.exports = {
 // file: lib/android/plugin/android/nativeapiprovider.js
 define("cordova/plugin/android/nativeapiprovider", function(require, exports, module) {
 
+/**
+ * Exports the ExposedJsApi.java object if available, otherwise exports the PromptBasedNativeApi.
+ */
+
 var nativeApi = this._cordovaNative || require('cordova/plugin/android/promptbasednativeapi');
 var currentApi = nativeApi;
 
@@ -4149,6 +4149,11 @@ module.exports = {
 // file: lib/android/plugin/android/promptbasednativeapi.js
 define("cordova/plugin/android/promptbasednativeapi", function(require, exports, module) {
 
+/**
+ * Implements the API of ExposedJsApi.java, but uses prompt() to communicate.
+ * This is used only on the 2.3 simulator, where addJavascriptInterface() is broken.
+ */
+
 module.exports = {
     exec: function(service, action, callbackId, argsJson) {
         return prompt(argsJson, 'gap:'+JSON.stringify([service, action, callbackId]));
@@ -5072,7 +5077,6 @@ function Device() {
     this.available = false;
     this.platform = null;
     this.version = null;
-    this.name = null;
     this.uuid = null;
     this.cordova = null;
     this.model = null;
@@ -5088,7 +5092,6 @@ function Device() {
             me.available = true;
             me.platform = info.platform;
             me.version = info.version;
-            me.name = info.name;
             me.uuid = info.uuid;
             me.cordova = buildLabel;
             me.model = info.model;
@@ -6676,6 +6679,11 @@ window.cordova = require('cordova');
 // file: lib/scripts/bootstrap.js
 
 (function (context) {
+    if (context._cordovaJsLoaded) {
+        throw new Error('cordova.js included multiple times.');
+    }
+    context._cordovaJsLoaded = true;
+
     var channel = require('cordova/channel');
     var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady];
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2c4112ec/lib/cordova-android/framework/src/org/apache/cordova/api/DataResource.java
----------------------------------------------------------------------
diff --git a/lib/cordova-android/framework/src/org/apache/cordova/api/DataResource.java b/lib/cordova-android/framework/src/org/apache/cordova/api/DataResource.java
deleted file mode 100644
index 3e6ead8..0000000
--- a/lib/cordova-android/framework/src/org/apache/cordova/api/DataResource.java
+++ /dev/null
@@ -1,141 +0,0 @@
-package org.apache.cordova.api;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.cordova.FileHelper;
-
-import android.net.Uri;
-
-/*
- * All requests to access files, browser network requests etc have to go through this class.
- */
-public class DataResource {
-    private CordovaInterface cordova;
-
-    // Uri of the request. Always required.
-    private Uri uri;
-    // Remaining fields may or may not be null
-    private InputStream is;
-    private OutputStream os;
-    private String mimeType;
-    private Boolean writable;
-    private File realFile;
-    private boolean retryIsLoad = true;
-    private boolean retryOsLoad = true;
-    private boolean retryMimeTypeLoad = true;
-    private boolean retryWritableLoad = true;
-    private boolean retryRealFileLoad = true;
-
-    public DataResource(CordovaInterface cordova, Uri uri) {
-        this.cordova = cordova;
-        this.uri = uri;
-    }
-    public DataResource(CordovaInterface cordova, Uri uri, InputStream is,
-            OutputStream os, String mimeType, boolean writable, File realFile) {
-        this(cordova, uri);
-        this.is = is;
-        this.mimeType = mimeType;
-        this.writable = Boolean.valueOf(writable);
-        this.realFile = realFile;
-    }
-    public Uri getUri() {
-        // Uri is always provided
-        return uri;
-    }
-    public InputStream getInputStream() throws IOException {
-        if(is == null && retryIsLoad) {
-            try {
-                is = FileHelper.getInputStreamFromUriString(uri.toString(), cordova);
-            } finally {
-                // We failed loading once, don't try loading anymore
-                if(is == null) {
-                    retryIsLoad = false;
-                }
-            }
-        }
-        return is;
-    }
-    public OutputStream getOutputStream() throws FileNotFoundException {
-        if(os == null && retryOsLoad) {
-            try {
-                os = FileHelper.getOutputStreamFromUriString(uri.toString(), cordova);
-            } finally {
-                // We failed loading once, don't try loading anymore
-                if(os == null) {
-                    retryOsLoad = false;
-                }
-            }
-        }
-        return os;
-    }
-    public String getMimeType() {
-        if(mimeType == null && retryMimeTypeLoad) {
-            try {
-                mimeType = FileHelper.getMimeType(uri.toString(), cordova);
-            } finally {
-                // We failed loading once, don't try loading anymore
-                if(mimeType == null) {
-                    retryMimeTypeLoad = false;
-                }
-            }
-        }
-        return mimeType;
-    }
-    public boolean isWritable() {
-        if(writable == null && retryWritableLoad) {
-            try {
-                writable = FileHelper.isUriWritable(uri.toString());
-            } finally {
-                // We failed loading once, don't try loading anymore
-                if(writable == null) {
-                    retryWritableLoad = false;
-                }
-            }
-        }
-        // default to false
-        return writable != null && writable.booleanValue();
-    }
-    public File getRealFile() {
-        if(realFile == null && retryRealFileLoad) {
-            try {
-                String realPath = FileHelper.getRealPath(uri, cordova);
-                if(realPath != null) {
-                    realFile = new File(realPath);
-                }
-            } finally {
-                // We failed loading once, don't try loading anymore
-                if(realFile == null) {
-                    retryRealFileLoad = false;
-                }
-            }
-        }
-        return realFile;
-    }
-
-    // static instantiation methods
-    public static DataResource initiateNewDataRequestForUri(String uriString, PluginManager pluginManager, CordovaInterface cordova, String requestSourceTag){
-        // if no protocol is specified, assume its file:
-        uriString = FileHelper.insertFileProtocol(uriString);
-        return initiateNewDataRequestForUri(Uri.parse(uriString), pluginManager, cordova, requestSourceTag);
-    }
-    public static DataResource initiateNewDataRequestForUri(Uri uri, PluginManager pluginManager, CordovaInterface cordova, String requestSourceTag){
-        return initiateNewDataRequestForUri(uri, pluginManager, cordova, new DataResourceContext(requestSourceTag));
-    }
-    public static DataResource initiateNewDataRequestForUri(String uriString, PluginManager pluginManager, CordovaInterface cordova, DataResourceContext dataResourceContext){
-     // if no protocol is specified, assume its file:
-        uriString = FileHelper.insertFileProtocol(uriString);
-        return initiateNewDataRequestForUri(Uri.parse(uriString), pluginManager, cordova, dataResourceContext);
-    }
-    public static DataResource initiateNewDataRequestForUri(Uri uri, PluginManager pluginManager, CordovaInterface cordova, DataResourceContext dataResourceContext){
-        DataResource dataResource = new DataResource(cordova, uri);
-        if (pluginManager != null) {
-            // get the resource as returned by plugins
-            dataResource = pluginManager.handleDataResourceRequestWithPlugins(dataResource, dataResourceContext);
-        }
-        return dataResource;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2c4112ec/lib/cordova-android/framework/src/org/apache/cordova/api/DataResourceContext.java
----------------------------------------------------------------------
diff --git a/lib/cordova-android/framework/src/org/apache/cordova/api/DataResourceContext.java b/lib/cordova-android/framework/src/org/apache/cordova/api/DataResourceContext.java
deleted file mode 100644
index 310586b..0000000
--- a/lib/cordova-android/framework/src/org/apache/cordova/api/DataResourceContext.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.apache.cordova.api;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Random;
-/*
- * Some context information associated with a DataRequest.
- */
-public class DataResourceContext {
-    // A random id that is unique for a particular request.
-    private int requestId;
-    // A tag associated with the source of this dataResourceContext
-    private String source;
-    // If needed, any data associated with core plugins can be a part of the context object
-    // If needed, any data associated with non core plugins  should store data in a Map so as to not clutter the context object
-    private Map<String, Object> dataMap;
-    public DataResourceContext(String source) {
-        this.requestId = new Random().nextInt();
-        this.source = source;
-        this.dataMap = new HashMap<String, Object>();
-    }
-    public int getRequestId() {
-        return requestId;
-    }
-    public String getSource() {
-        return source;
-    }
-    public Map<String, Object> getDataMap() {
-        return dataMap;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2c4112ec/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 2ab9de2..315374f 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "cordova",
-  "version": "2.8.7",
+  "version": "2.8.8",
   "preferGlobal": "true",
   "description": "Cordova command line interface tool",
   "main": "cordova",


[15/22] git commit: npm version 2.8.9. [CB-3461] Exposing parser modules to the platform command

Posted by fi...@apache.org.
npm version 2.8.9. [CB-3461] Exposing parser modules to the platform command


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/6bdf8363
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/6bdf8363
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/6bdf8363

Branch: refs/heads/2.8.x
Commit: 6bdf8363b4269b9a7a5e3cb7e0d401a47879a44a
Parents: 2c4112e
Author: Fil Maj <ma...@gmail.com>
Authored: Wed Jun 5 15:12:02 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 6 18:29:29 2013 -0700

----------------------------------------------------------------------
 package.json                      |    2 +-
 spec/cordova-cli/platform.spec.js |   11 +++++++++++
 src/platform.js                   |    5 +++++
 3 files changed, 17 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6bdf8363/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 315374f..db47513 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "cordova",
-  "version": "2.8.8",
+  "version": "2.8.9",
   "preferGlobal": "true",
   "description": "Cordova command line interface tool",
   "main": "cordova",

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6bdf8363/spec/cordova-cli/platform.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova-cli/platform.spec.js b/spec/cordova-cli/platform.spec.js
index 2aa0177..61a6e7e 100644
--- a/spec/cordova-cli/platform.spec.js
+++ b/spec/cordova-cli/platform.spec.js
@@ -258,3 +258,14 @@ describe('platform.supports(name, callback)', function() {
         });
     });
 });
+
+describe('platform parsers', function() {
+    it('should be exposed on the platform module', function() {
+        for (var platform in platforms) {
+            expect(cordova.platform[platform]).toBeDefined();
+            for (var prop in platforms[platform]) {
+                expect(cordova.platform[platform][prop]).toBeDefined();
+            }
+        }
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6bdf8363/src/platform.js
----------------------------------------------------------------------
diff --git a/src/platform.js b/src/platform.js
index e60aa1f..c36b582 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -183,3 +183,8 @@ module.exports.supports = function(name, callback) {
         callback(e);
     });
 };
+
+// Expose the platform parsers on top of this command
+for (var p in platforms) {
+    module.exports[p] = platforms[p];
+}


[16/22] git commit: Re-enabled BB10 platform support and updated bb10 lib to cordova 2.8.0 tag.

Posted by fi...@apache.org.
Re-enabled BB10 platform support and updated bb10 lib to cordova 2.8.0 tag.


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/f5baa6e5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/f5baa6e5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/f5baa6e5

Branch: refs/heads/2.8.x
Commit: f5baa6e5f995821c41b32d797dd675b166b0c6a9
Parents: 6bdf836
Author: Fil Maj <ma...@gmail.com>
Authored: Thu Jun 6 10:11:40 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 6 18:30:08 2013 -0700

----------------------------------------------------------------------
 lib/cordova-blackberry/README.md                   |   12 +-
 lib/cordova-blackberry/VERSION                     |    2 +-
 lib/cordova-blackberry/bin/check_reqs              |   57 ++--
 lib/cordova-blackberry/bin/check_reqs.bat          |   27 ++-
 lib/cordova-blackberry/bin/check_reqs.js           |   38 +++
 lib/cordova-blackberry/bin/create                  |   16 +-
 lib/cordova-blackberry/bin/create.bat              |    8 +-
 lib/cordova-blackberry/bin/create.js               |   38 ++-
 .../bin/templates/project/cordova/build            |    2 +-
 .../bin/templates/project/cordova/build.bat        |    2 +-
 .../bin/templates/project/cordova/clean            |    2 +-
 .../bin/templates/project/cordova/clean.bat        |    2 +-
 .../bin/templates/project/cordova/lib/build        |  140 ++++------
 .../project/cordova/lib/debugtoken-helper.js       |   70 +++++
 .../templates/project/cordova/lib/install-device   |   24 ++
 .../project/cordova/lib/install-device.bat         |   21 ++
 .../bin/templates/project/cordova/lib/list-devices |   24 ++
 .../templates/project/cordova/lib/list-devices.bat |   21 ++
 .../project/cordova/lib/list-emulator-images       |   24 ++
 .../project/cordova/lib/list-emulator-images.bat   |   21 ++
 .../bin/templates/project/cordova/lib/localize.js  |    7 +-
 .../bin/templates/project/cordova/lib/log          |   24 ++
 .../bin/templates/project/cordova/lib/log.bat      |   21 ++
 .../project/cordova/lib/packager-utils.js          |   25 ++-
 .../project/cordova/lib/packager-validator.js      |    3 -
 .../bin/templates/project/cordova/lib/plugin.js    |   15 +-
 .../bin/templates/project/cordova/lib/run          |  213 ++++++++++----
 .../templates/project/cordova/lib/start-emulator   |   54 ++++
 .../project/cordova/lib/start-emulator.bat         |   21 ++
 .../bin/templates/project/cordova/lib/target       |   40 ++-
 .../bin/templates/project/cordova/plugin.bat       |    2 +-
 .../bin/templates/project/cordova/run              |    2 +-
 .../bin/templates/project/cordova/run.bat          |    2 +-
 .../bin/templates/project/cordova/target           |    2 +-
 .../bin/templates/project/cordova/target.bat       |    2 +-
 .../bin/templates/project/project.json             |    1 -
 .../bin/templates/project/www/VERSION              |    2 +-
 .../bin/templates/project/www/config.xml           |    2 +-
 .../bin/templates/project/www/index.html           |    2 +-
 .../www/res/screen/blackberry/screen-225.png       |  Bin 0 -> 16776 bytes
 .../javascript/cordova.blackberry10.js             |   11 +-
 lib/cordova-blackberry/package.json                |   10 +-
 platforms.js                                       |    4 +-
 43 files changed, 768 insertions(+), 248 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/README.md
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/README.md b/lib/cordova-blackberry/README.md
index a19b87a..7430e96 100644
--- a/lib/cordova-blackberry/README.md
+++ b/lib/cordova-blackberry/README.md
@@ -22,6 +22,10 @@ Install node.js:
 
 [http://nodejs.org/](http://nodejs.org/)
 
+Ensure npm is installed:
+
+More recent versions of Nodejs will come with npm included.
+
 ## Getting Started
 
 Create a new project:
@@ -32,7 +36,7 @@ Create a new project:
 
 A target is a device or simulator which will run the app.
 
-This command will add a new target: 
+This command will add a new target:
 
 `<path to project>/cordova/target add <name> <ip> <device | simulator> [-p | --password <password>] [--pin <devicepin>]`
 
@@ -60,10 +64,10 @@ Here is the build script syntax:
 
 Commands:
 
-    release [options] 
+    release [options]
         Build in release mode. This will sign the resulting bar.
-    
-    debug [options] 
+
+    debug [options]
         Build in debug mode.
 
   Options:

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/VERSION
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/VERSION b/lib/cordova-blackberry/VERSION
index 38f8e88..834f262 100644
--- a/lib/cordova-blackberry/VERSION
+++ b/lib/cordova-blackberry/VERSION
@@ -1 +1 @@
-dev
+2.8.0

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/check_reqs
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/check_reqs b/lib/cordova-blackberry/bin/check_reqs
index 9a8e9ee..9c2545c 100755
--- a/lib/cordova-blackberry/bin/check_reqs
+++ b/lib/cordova-blackberry/bin/check_reqs
@@ -1,28 +1,31 @@
-#!/usr/bin/env node
+#! /bin/sh
+#       Licensed to the Apache Software Foundation (ASF) under one
+#       or more contributor license agreements.  See the NOTICE file
+#       distributed with this work for additional information
+#       regarding copyright ownership.  The ASF licenses this file
+#       to you under the Apache License, Version 2.0 (the
+#       "License"); you may not use this file except in compliance
+#       with the License.  You may obtain a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#       Unless required by applicable law or agreed to in writing,
+#       software distributed under the License is distributed on an
+#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#       KIND, either express or implied.  See the License for the
+#       specific language governing permissions and limitations
+#       under the License.
+#
+#!/bin/sh
+if command -v node >/dev/null 2>&1; then
+    if command -v npm >/dev/null 2>&1; then
+        node "$( dirname "$0" )/check_reqs.js" "$@"
+    else
+        echo "npm cannot be found on the path. Aborting."
+        exit 1
+    fi
+else
+    echo "Node cannot be found on the path. Aborting."
+    exit 1
+fi
 
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-var qnxHost = process.env.QNX_HOST;
-
-if (typeof qnxHost !== "undefined" && typeof process.env.QNX_TARGET !== "undefined" && process.env.PATH.indexOf(qnxHost) !== -1) {
-    process.exit(0);
-} else {
-    process.exit(-1);
-}

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/check_reqs.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/check_reqs.bat b/lib/cordova-blackberry/bin/check_reqs.bat
index ed05fac..faef279 100755
--- a/lib/cordova-blackberry/bin/check_reqs.bat
+++ b/lib/cordova-blackberry/bin/check_reqs.bat
@@ -18,4 +18,29 @@ goto comment
        under the License.
 :comment
 
-@node.exe %~dp0\check_reqs %*
+set FOUNDNODE=
+for %%e in (%PATHEXT%) do (
+  for %%X in (node%%e) do (
+    if not defined FOUNDNODE (
+      set FOUNDNODE=%%~$PATH:X
+    )
+  )
+)
+
+set FOUNDNPM=
+for %%X in (npm) do (
+  if not defined FOUNDNPM (
+    set FOUNDNPM=%%~$PATH:X
+  )
+)
+
+if not defined FOUNDNODE (
+  echo "npm cannot be found on the path. Aborting."
+  exit /b 1
+)
+if not defined FOUNDNPM (
+  echo "Node cannot be found on the path. Aborting."
+  exit /b 1
+)
+
+@node.exe "%~dp0\check_reqs.js" %*

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/check_reqs.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/check_reqs.js b/lib/cordova-blackberry/bin/check_reqs.js
new file mode 100644
index 0000000..081a0e0
--- /dev/null
+++ b/lib/cordova-blackberry/bin/check_reqs.js
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+var MIN_NODE_VER = "0.9.9",
+    qnxHost = process.env.QNX_HOST;
+
+function isNodeNewerThanMin () {
+    //Current version is stored as a String in format "X.X.X"
+    //Must be newer than "0.9.9"
+    var currentVer = process.versions.node.split(".").map(function (verNumStr) { return parseInt(verNumStr, 10);});
+    return (currentVer[0] > 0 || currentVer[1] > 9 || currentVer[1] === 9 && currentVer[2] >= 9);
+}
+
+if (typeof qnxHost === "undefined" || typeof process.env.QNX_TARGET === "undefined" || process.env.PATH.indexOf(qnxHost) === -1) {
+    console.log("BBNDK has not been setup. Please run the appropriate shell script. Aborting.");
+    process.exit(1);
+} else if (!isNodeNewerThanMin()) {
+    console.log("Node version '" + process.versions.node + "' is not new enough. Please upgrade to " + MIN_NODE_VER + " or newer. Aborting.");
+    process.exit(1);
+}
+
+process.exit(0);

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/create
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/create b/lib/cordova-blackberry/bin/create
index 87ce4c3..b8b2b89 100755
--- a/lib/cordova-blackberry/bin/create
+++ b/lib/cordova-blackberry/bin/create
@@ -22,4 +22,18 @@
 #   ./create [path package appname]
 #
 #!/bin/sh
-node $( dirname "$0" )"/create.js" "$@"
+
+CURRENT_DIR=$(pwd)
+BIN_DIR=$(dirname "$0")
+
+#Run npm install every time (even if node_modules folder is present) to cover platform upgrade
+cd "$BIN_DIR"/..
+#Removed sudo usage so that node modules are not ownder by root
+npm install
+cd "$CURRENT_DIR"
+
+if ! [ $? -eq 0 ]; then
+  echo "NPM install failed. Aborting."
+else
+  node "$BIN_DIR"/create.js "$@"
+fi

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/create.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/create.bat b/lib/cordova-blackberry/bin/create.bat
index 7b15594..a8f7bab 100644
--- a/lib/cordova-blackberry/bin/create.bat
+++ b/lib/cordova-blackberry/bin/create.bat
@@ -18,4 +18,10 @@ goto comment
        under the License.
 :comment
 
-node.exe %~dp0\create.js %*
+set BIN_DIR=%~dp0
+
+pushd %BIN_DIR%..
+call npm install
+popd
+
+node.exe "%BIN_DIR%create.js" %*

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/create.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/create.js b/lib/cordova-blackberry/bin/create.js
index 253c093..b454d37 100644
--- a/lib/cordova-blackberry/bin/create.js
+++ b/lib/cordova-blackberry/bin/create.js
@@ -30,7 +30,7 @@ var build,
     wrench = require("wrench"),
     utils = require(path.join(__dirname, 'lib/utils')),
     version = getVersion(),
-    project_path = path.resolve(process.argv[2]),
+    project_path = validateProjectPath(),
     app_id = process.argv[3],
     bar_name = process.argv[4],
     TARGETS = ["device", "simulator"],
@@ -43,7 +43,7 @@ var build,
     update_dir = path.join(project_path, "lib", "cordova." + version),
     native_dir = path.join(project_path, "native"),
     js_path = "javascript",
-    js_basename = "cordova-" + version + ".js";
+    js_basename = "cordova.js";
 
 function getVersion() {
     var version = fs.readFileSync(path.join(__dirname,  "..", "VERSION"));
@@ -67,18 +67,32 @@ function validBarName(barName) {
     return (typeof barName === "undefined") || barNameRegex.test(barName);
 }
 
-function validate() {
-    if (!project_path) {
-        throw "You must give a project PATH";
+function validateProjectPath() {
+    if (!process.argv[2]) {
+        console.log("You must give a project PATH");
+        help();
+        process.exit(2); 
+        return "";
+    } else {
+        return path.resolve(process.argv[2]);
     }
+}
+
+function validate() {
     if (fs.existsSync(project_path)) {
-        throw "The project path must be an empty directory";
+        console.log("The project path must be an empty directory");
+        help();
+        process.exit(2);
     }
     if (!validPackageName(app_id)) {
-        throw "App ID must be sequence of alpha-numeric (optionally seperated by '.') characters, no longer than 50 characters";
+        console.log("App ID must be sequence of alpha-numeric (optionally seperated by '.') characters, no longer than 50 characters");
+        help();
+        process.exit(2);
     }
     if (!validBarName(bar_name)) {
-        throw "BAR filename can only contain alpha-numeric, '.', '-' and '_' characters";
+        console.log("BAR filename can only contain alpha-numeric, '.', '-' and '_' characters");
+        help();
+        process.exit(2);
     }
 }
 
@@ -150,14 +164,18 @@ function updateProject() {
 }
 
 function installPlugins() {
-    var pluginScript = path.resolve(__dirname, "..", path.join(project_path, "cordova", "lib", "plugin.js"));
+    var pluginScript = path.join(project_path, "cordova", "lib", "plugin.js");
     require(pluginScript).add(path.join(__dirname, "..", "plugins"));
 }
 
-if ( process.argv[2] === "-h" || process.argv[2] === "--help" ) {
+function help() {
     console.log("\nUsage: create <project path> [package name [BAR filename]] \n");
     console.log("Options: \n");
     console.log("   -h, --help      output usage information \n");
+}
+
+if ( process.argv[2] === "-h" || process.argv[2] === "--help" ) {
+    help();
 } else {
     try {
         validate();

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/build
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/build b/lib/cordova-blackberry/bin/templates/project/cordova/build
index c1e6f63..ade60b0 100755
--- a/lib/cordova-blackberry/bin/templates/project/cordova/build
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/build
@@ -1,5 +1,5 @@
 #!/bin/sh
 
 #package app
-node $(dirname "$0")"/lib/build" "$@"
+node "$(dirname "$0")/lib/build" "$@"
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/build.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/build.bat b/lib/cordova-blackberry/bin/templates/project/cordova/build.bat
index 186bbba..191e448 100755
--- a/lib/cordova-blackberry/bin/templates/project/cordova/build.bat
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/build.bat
@@ -18,4 +18,4 @@ goto comment
        under the License.
 :comment
 
-@node.exe %~dp0\lib\build %*
+@node.exe %~dps0\lib\build %*

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/clean
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/clean b/lib/cordova-blackberry/bin/templates/project/cordova/clean
index 54d888c..abe96ea 100755
--- a/lib/cordova-blackberry/bin/templates/project/cordova/clean
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/clean
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-node $(dirname "$0")"/lib/clean"
+node "$(dirname "$0")/lib/clean"

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/clean.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/clean.bat b/lib/cordova-blackberry/bin/templates/project/cordova/clean.bat
index 636862f..d613d87 100755
--- a/lib/cordova-blackberry/bin/templates/project/cordova/clean.bat
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/clean.bat
@@ -18,4 +18,4 @@ goto comment
        under the License.
 :comment
 
-@node.exe %~dp0\lib\clean %*
+@node.exe %~dps0\lib\clean %*

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/lib/build
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/build b/lib/cordova-blackberry/bin/templates/project/cordova/lib/build
index 3fb3432..5e15425 100644
--- a/lib/cordova-blackberry/bin/templates/project/cordova/lib/build
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/build
@@ -18,11 +18,7 @@
 
 var path = require("path"),
     command = require("commander"),
-    jWorkflow = require("jWorkflow"),
-    localize = require("./localize"),
-    logger = require("./logger"),
     projectProperties = require("../../project.json"),
-    debugTokenHelper = require("./debugtoken-helper"),
     bbwpArgv = [
         process.argv[0],
         path.resolve(path.join(__dirname, process.argv[1])),
@@ -30,12 +26,10 @@ var path = require("path"),
         "-o",
         path.resolve(path.join(__dirname, "..", "..", "build"))
     ],
-    built = false,
-    debugtoken = false;
-
-function getTarget() {
-    return typeof command.args[0] === "string" ? command.args[0] : undefined;
-}
+    jWorkflow = require("jWorkflow"),
+    childProcess = require("child_process"),
+    pkgrUtils = require("./packager-utils"),
+    commandStr;
 
 function copyArgIfExists(arg) {
     if (command[arg]) {
@@ -44,49 +38,14 @@ function copyArgIfExists(arg) {
     }
 }
 
-function createDebugtoken(previous, baton) {
-    var keystorepass = command["keystorepass"] ? command["keystorepass"] : projectProperties.keystorepass;
-    baton.take();
-    logger.info(localize.translate("PROGRESS_WILL_CREATE_DEBUG_TOKEN"));
-    debugTokenHelper.createToken(projectProperties, getTarget(), keystorepass, function (code) {
-        if (code === 0) {
-            debugtoken = true;
-        }
-
-        baton.pass();
-    });
-}
-
-function deployDebugToken(previous, baton) {
-    baton.take();
-
-    // If in debug build and debug token was created, deploy the debug token and wait until the deployment is finished
-    if (debugtoken) {
-        logger.info(localize.translate("PROGRESS_WILL_DEPLOY_DEBUG_TOKEN"));
-        debugTokenHelper.deployToken(projectProperties, getTarget(), function () {
-            baton.pass();
-        });
-    } else {
-        baton.pass();
-    }
-}
-
 function doDebugBuild() {
-    built = true;
-
     //build in debug mode by default
     bbwpArgv.push("-d");
 
-    // In debug build, it needs to create debug token first
-    jWorkflow.order(createDebugtoken)
-             .andThen(deployDebugToken)
-             .andThen(build)
-             .start();
+    build();
 }
 
 function doReleaseBuild() {
-    built = true;
-
     //Note: Packager refers to signing password as "password" not "keystorepass"
     if (command["keystorepass"]) {
         bbwpArgv.push("--password");
@@ -95,7 +54,9 @@ function doReleaseBuild() {
         bbwpArgv.push("--password");
         bbwpArgv.push( projectProperties.keystorepass);
     } else {
-        throw "No signing password provided. Please use --keystorepass via command-line or enter a value for keystorepass in project.json";
+        console.log("No signing password provided. Please use --keystorepass via command-line or enter a value for keystorepass in project.json");
+        console.log(command.helpInformation()); 
+        process.exit(2);
     }
 
     copyArgIfExists("buildId");
@@ -107,68 +68,71 @@ function build() {
     copyArgIfExists("params");
     copyArgIfExists("loglevel");
 
-    //Overrite process.argv, before calling packager
+    //Overwrite process.argv, before calling packager
     process.argv = bbwpArgv;
 
     //Delete cached commander object. It will conflict with the packagers commander
     delete require.cache[require.resolve("commander")];
     delete require.cache[require.resolve("commander/lib/commander")];
 
-    //Package app. If successfull call run
-    require("./packager").start(run);
+    require("./packager").start(function() {});
 }
 
-function run() {
-    var target = getTarget();
+function postClean() {
+    if (command.release) {
+        doReleaseBuild();
+    } else {
+        doDebugBuild();
+    }
+}
 
-    //Overrite process.argv, before calling run
-    process.argv = [
-        process.argv[0],
-        process.argv[1],
-    ];
+function clean(previous, baton) {
+    var cleanScript,
+        execName = "./clean";
 
-    if (target) {
-        process.argv.push(target);
-    }
+    if (pkgrUtils.isWindows()) {
+        execName = "clean";
+    } 
 
-    //deploy app
-    require("./run");
-}
+    baton.take();
 
-command
-    .usage('command [<target>] [-k | --keystorepass] [-b | --buildId <number>] [-p | --params <json>] [-ll | --loglevel <level>]')
-    .option('-k, --keystorepass <password>', 'Signing key password')
-    .option('-b, --buildId <num>', 'Specifies the build number for signing (typically incremented from previous signing).')
-    .option('-p, --params <params JSON file>', 'Specifies additional parameters to pass to downstream tools.')
-    .option('-ll, --loglevel <loglevel>', 'set the logging level (error, warn, verbose)');
+    cleanScript = childProcess.exec(execName, {
+        "cwd": path.normalize(__dirname + "/.."),
+        "env": process.env
+    });
 
-command
-    .command('release')
-    .usage('[<target>] [-k | --keystorepass] [-b | --buildId <number>] [-p | --params <json>] [-ll | --loglevel <level>]')
-    .description('    Build in release mode. This will sign the resulting bar.')
-    .option('-k, --keystorepass <password>', 'Signing key password')
-    .option('-b, --buildId <num>', 'Specifies the build number for signing (typically incremented from previous signing).')
-    .option('-p, --params <params JSON file>', 'Specifies additional parameters to pass to downstream tools.')
-    .option('-ll, --loglevel <loglevel>', 'set the logging level (error, warn, verbose)')
-    .action(doReleaseBuild);
+    cleanScript.stdout.on("data", pkgrUtils.handleProcessOutput);
+    cleanScript.stderr.on("data", pkgrUtils.handleProcessOutput);
+
+    cleanScript.on("exit", function (code) {
+        baton.pass();
+    });
+}
 
 command
-    .command('debug')
-    .usage('[<target>] [-p | --params <json>] [-ll | --loglevel <level>]')
-    .description('    Build in debug mode.')
-    .option('-p, --params <params JSON file>', 'Specifies additional parameters to pass to downstream tools.')
-    .option('-ll, --loglevel <loglevel>', 'set the logging level (error, warn, verbose)')
-    .action(doDebugBuild);
+    .usage('[--debug] [--release] [-k | --keystorepass] [-b | --buildId <number>] [-p | --params <json>] [-ll | --loglevel <level>]')
+    .option('--debug', 'build in debug mode.')
+    .option('--release', 'build in release mode. This will sign the resulting bar.')
+    .option('-k, --keystorepass <password>', 'signing key password')
+    .option('-b, --buildId <num>', 'specifies the build number for signing (typically incremented from previous signing).')
+    .option('-p, --params <params JSON file>', 'specifies additional parameters to pass to downstream tools.')
+    .option('-ll, --loglevel <loglevel>', 'set the logging level (error, warn, verbose)');
 
 try {
     command.parse(process.argv);
 
-    //if we get here and haven't built yet then no mode was provided [debug, release], default to debug mode
-    if (!built) {
-        doDebugBuild();
+    if (command.debug && command.release) {
+        console.log("Invalid build command: cannot specify both debug and release parameters.");
+        console.log(command.helpInformation());
+        process.exit(2);
     }
+
+    // Implicitly call clean first
+    jWorkflow.order(clean)
+             .andThen(postClean)
+             .start();
 } catch (e) {
     console.log(e);
-    process.exit();
+    process.exit(2);
 }
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/lib/debugtoken-helper.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/debugtoken-helper.js b/lib/cordova-blackberry/bin/templates/project/cordova/lib/debugtoken-helper.js
index 791973c..f1a4220 100755
--- a/lib/cordova-blackberry/bin/templates/project/cordova/lib/debugtoken-helper.js
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/debugtoken-helper.js
@@ -28,6 +28,44 @@ var childProcess = require("child_process"),
     deployCallback,
     self = {};
 
+function isDebugTokenValid(pin, data) {
+    var manifests,
+        i,
+        l,
+        expiry = null,
+        pin,
+        devices = [],
+        line,
+        now = new Date();
+
+    if (!data) {
+        return false;
+    }
+
+    manifests = data.toString().replace(/[\r]/g, '').split('\n');
+
+    for (i=0, l=manifests.length; i<l; i++) {
+        if (manifests[i].indexOf("Debug-Token-Expiry-Date: ") >= 0) {
+            // Parse the expiry date
+            line = manifests[i].substring("Debug-Token-Expiry-Date: ".length);
+            expiry = new Date(line.substring(0, line.indexOf("T")) + " " + line.substring(line.indexOf("T") + 1, line.length -1) + " UTC");
+        } else if (manifests[i].indexOf("Debug-Token-Device-Id: ") >= 0) {
+            line = manifests[i].substring("Debug-Token-Device-Id: ".length);
+            devices = line.split(",");
+        }
+    }
+
+    if (expiry && expiry > now) {
+        for (i=0, l=devices.length; i<l; i++) {
+            if (parseInt(devices[i]) === parseInt(pin, 16)) {
+                return true; // The debug token is valid if not expired and device pin is included
+            }
+        }
+    }
+
+    return false;
+}
+
 function generateCreateTokenOptions(pins, password) {
     var options = [],
         i;
@@ -208,4 +246,36 @@ self.deployToken = function (projectProperties, target, callback) {
     deployTokenToTargetsRecursively();
 };
 
+self.checkDebugToken = function (pin, callback) {
+    var process,
+        script = "/bin/blackberry-nativepackager",
+        nativePackager;
+
+    if (!callback || typeof callback !== "function") {
+        return;
+    }
+
+    if (!fs.existsSync(debugTokenDir)) {
+        callback(false);
+        return;
+    }
+
+    if (pkgrUtils.isWindows()) {
+        script += ".bat";
+    }
+
+    if (fs.existsSync(conf.DEPENDENCIES_TOOLS)) {
+        nativePackager = childProcess.exec(path.normalize(conf.DEPENDENCIES_TOOLS + script +" -listManifest " + debugTokenDir), {
+            "cwd": workingDir,
+            "env": process ? process.env : undefined
+        }, function (error, stdout, stderr) {
+            callback(isDebugTokenValid(pin, stdout));
+        });
+    } else {
+        throw localize.translate("EXCEPTION_MISSING_TOOLS");
+    }
+
+    return;
+};
+
 module.exports = self;

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/lib/install-device
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/install-device b/lib/cordova-blackberry/bin/templates/project/cordova/lib/install-device
new file mode 100755
index 0000000..b9f38d3
--- /dev/null
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/install-device
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+set -e
+
+echo 'BlackBerry10: Not able to install to connected devices through command-line at this time.'
+exit 1

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/lib/install-device.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/install-device.bat b/lib/cordova-blackberry/bin/templates/project/cordova/lib/install-device.bat
new file mode 100644
index 0000000..965417e
--- /dev/null
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/install-device.bat
@@ -0,0 +1,21 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements.  See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership.  The ASF licenses this file
+:: to you under the Apache License, Version 2.0 (the
+:: "License"); you may not use this file except in compliance
+:: with the License.  You may obtain a copy of the License at
+::
+:: http://www.apache.org/licenses/LICENSE-2.0
+::
+:: Unless required by applicable law or agreed to in writing,
+:: software distributed under the License is distributed on an
+:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+:: KIND, either express or implied.  See the License for the
+:: specific language governing permissions and limitations
+:: under the License.
+
+@ECHO OFF
+
+ECHO echo 'BlackBerry10: Not able to install to connected devices through command-line at this time.'
+EXIT /B 1

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-devices
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-devices b/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-devices
new file mode 100755
index 0000000..09d3cec
--- /dev/null
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-devices
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+set -e
+
+echo 'BlackBerry10: Not able to list connected devices through command-line at this time.'
+exit 1

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-devices.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-devices.bat b/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-devices.bat
new file mode 100644
index 0000000..d0da1c6
--- /dev/null
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-devices.bat
@@ -0,0 +1,21 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements.  See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership.  The ASF licenses this file
+:: to you under the Apache License, Version 2.0 (the
+:: "License"); you may not use this file except in compliance
+:: with the License.  You may obtain a copy of the License at
+::
+:: http://www.apache.org/licenses/LICENSE-2.0
+::
+:: Unless required by applicable law or agreed to in writing,
+:: software distributed under the License is distributed on an
+:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+:: KIND, either express or implied.  See the License for the
+:: specific language governing permissions and limitations
+:: under the License.
+
+@ECHO OFF
+
+ECHO echo 'BlackBerry10: Not able to list connected devices through command-line at this time.'
+EXIT /B 1

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-emulator-images
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-emulator-images b/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-emulator-images
new file mode 100755
index 0000000..f065a7a
--- /dev/null
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-emulator-images
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+set -e
+
+echo 'BlackBerry10: Not able to list valid emulator images through command-line at this time.'
+exit 1

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-emulator-images.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-emulator-images.bat b/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-emulator-images.bat
new file mode 100644
index 0000000..60baaaf
--- /dev/null
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/list-emulator-images.bat
@@ -0,0 +1,21 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements.  See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership.  The ASF licenses this file
+:: to you under the Apache License, Version 2.0 (the
+:: "License"); you may not use this file except in compliance
+:: with the License.  You may obtain a copy of the License at
+::
+:: http://www.apache.org/licenses/LICENSE-2.0
+::
+:: Unless required by applicable law or agreed to in writing,
+:: software distributed under the License is distributed on an
+:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+:: KIND, either express or implied.  See the License for the
+:: specific language governing permissions and limitations
+:: under the License.
+
+@ECHO OFF
+
+ECHO echo 'BlackBerry10: Not able to list valid emulator images through command-line at this time.'
+EXIT /B 1

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/lib/localize.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/localize.js b/lib/cordova-blackberry/bin/templates/project/cordova/lib/localize.js
index 04e89ac..4990a93 100644
--- a/lib/cordova-blackberry/bin/templates/project/cordova/lib/localize.js
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/localize.js
@@ -172,11 +172,8 @@ var Localize = require("localize"),
         "WARNING_WEBSECURITY_DISABLED": {
             "en": "You have disabled all web security in this WebWorks application"
         },
-        "PROGRESS_WILL_CREATE_DEBUG_TOKEN": {
-            "en": "Will create debug token"
-        },
-        "PROGRESS_WILL_DEPLOY_DEBUG_TOKEN": {
-            "en": "Will deploy debug token"
+        "PROGRESS_DEBUG_TOKEN_IS_VALID": {
+            "en": "The existing debug token is valid"
         },
         "WARN_TARGET_NOT_EXIST": {
             "en": "The target \"$[1]\" does not exist"

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/lib/log
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/log b/lib/cordova-blackberry/bin/templates/project/cordova/lib/log
new file mode 100755
index 0000000..1b34649
--- /dev/null
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/log
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+set -e
+
+echo 'BlackBerry10: logging not supported at this time.'
+exit 1

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/lib/log.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/log.bat b/lib/cordova-blackberry/bin/templates/project/cordova/lib/log.bat
new file mode 100644
index 0000000..ef5f6d9
--- /dev/null
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/log.bat
@@ -0,0 +1,21 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements.  See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership.  The ASF licenses this file
+:: to you under the Apache License, Version 2.0 (the
+:: "License"); you may not use this file except in compliance
+:: with the License.  You may obtain a copy of the License at
+::
+:: http://www.apache.org/licenses/LICENSE-2.0
+::
+:: Unless required by applicable law or agreed to in writing,
+:: software distributed under the License is distributed on an
+:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+:: KIND, either express or implied.  See the License for the
+:: specific language governing permissions and limitations
+:: under the License.
+
+@ECHO OFF
+
+ECHO echo 'BlackBerry10: logging not supported at this time.'
+EXIT /B 1

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/lib/packager-utils.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/packager-utils.js b/lib/cordova-blackberry/bin/templates/project/cordova/lib/packager-utils.js
index 09465e8..8bc3acf 100644
--- a/lib/cordova-blackberry/bin/templates/project/cordova/lib/packager-utils.js
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/packager-utils.js
@@ -49,12 +49,12 @@ _self = {
 
         fs.writeFileSync(path.join(fileLocation, fileName), fileData);
     },
-    
+
     copyFile: function (srcFile, destDir, baseDir) {
         var filename = path.basename(srcFile),
             fileBuffer = fs.readFileSync(srcFile),
             fileLocation;
-        
+
         //if a base directory was provided, determine
         //folder structure from the relative path of the base folder
         if (baseDir && srcFile.indexOf(baseDir) === 0) {
@@ -65,27 +65,27 @@ _self = {
             fs.writeFileSync(path.join(destDir, filename), fileBuffer);
         }
     },
-    
+
     listFiles: function (directory, filter) {
         var files = wrench.readdirSyncRecursive(directory),
             filteredFiles = [];
-        
+
         files.forEach(function (file) {
             //On mac wrench.readdirSyncRecursive does not return absolute paths, so resolve one.
             file = path.resolve(directory, file);
-        
+
             if (filter(file)) {
                 filteredFiles.push(file);
             }
         });
-        
+
         return filteredFiles;
     },
 
     isWindows: function () {
         return os.type().toLowerCase().indexOf("windows") >= 0;
     },
-    
+
     isArray: function (obj) {
         return obj.constructor.toString().indexOf("Array") !== -1;
     },
@@ -97,7 +97,7 @@ _self = {
         }
         return true;
     },
-    
+
     toBoolean: function (myString, defaultVal) {
         // if defaultVal is not passed, default value is undefined
         return myString === "true" ? true : myString === "false" ? false : defaultVal;
@@ -170,7 +170,16 @@ _self = {
                 logger.info(msg);
             }
         }
+    },
+
+    escapeStringForShell: function (str) {
+        if (require('os').type().toLowerCase().indexOf("windows") >= 0) {
+            return "\"" + str + "\"";
+        } else {
+            return str.replace(/(["\s'$`\\])/g,'\\$1');
+        }
     }
+
 };
 
 module.exports = _self;

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/lib/packager-validator.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/packager-validator.js b/lib/cordova-blackberry/bin/templates/project/cordova/lib/packager-validator.js
index 507b9f2..d85c0db 100644
--- a/lib/cordova-blackberry/bin/templates/project/cordova/lib/packager-validator.js
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/packager-validator.js
@@ -81,9 +81,6 @@ _self = {
         if (commandLinebuildId && !keysPassword) {
             //if --buildId was provided with NO password, throw error
             throw localize.translate("EXCEPTION_MISSING_SIGNING_PASSWORD");
-        } else if (buildId && !keysPassword) {
-            //if a buildId was provided in config.xml with NO password, throw warning
-            logger.warn(localize.translate("WARNING_SIGNING_PASSWORD_EXPECTED"));
         }
 
         //if --appdesc was provided, but the file is not existing, throw an error

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/lib/plugin.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/plugin.js b/lib/cordova-blackberry/bin/templates/project/cordova/lib/plugin.js
index 1f11481..7e1412c 100644
--- a/lib/cordova-blackberry/bin/templates/project/cordova/lib/plugin.js
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/plugin.js
@@ -22,8 +22,9 @@ var path = require("path"),
     wrench = require("wrench"),
     fs = require('fs'),
     et   = require('elementtree'),
+    escapeStringForShell = require("./packager-utils").escapeStringForShell,
     PROJECT_ROOT = path.join(__dirname, "..", ".."),
-    PLUGMAN = path.join(PROJECT_ROOT, "cordova", "node_modules", "plugman", "main.js"),
+    PLUGMAN = escapeStringForShell(path.join(PROJECT_ROOT, "cordova", "node_modules", "plugman", "main.js")),
     GLOBAL_PLUGIN_PATH = require(path.join(PROJECT_ROOT, "project.json")).globalFetchDir,
     LOCAL_PLUGIN_PATH = path.join(PROJECT_ROOT, "plugins"),
     argumentor = {
@@ -45,26 +46,26 @@ var path = require("path"),
         },
         setProject: function () {
             this.args.push("--project");
-            this.args.push(PROJECT_ROOT);
+            this.args.push(escapeStringForShell(PROJECT_ROOT));
             return argumentor;
         },
         setPlugin: function () {
             var pluginWithoutTrailingSlash = this.plugin.charAt(this.plugin.length - 1) === "/" ? this.plugin.slice(0, -1) : this.plugin;
             this.args.push("--plugin");
-            this.args.push(pluginWithoutTrailingSlash);
+            this.args.push(escapeStringForShell(pluginWithoutTrailingSlash));
             return argumentor;
         },
         setPluginsDir: function (isGlobal) {
             this.args.push("--plugins_dir");
             if (isGlobal) {
-                this.args.push(GLOBAL_PLUGIN_PATH);
+                this.args.push(escapeStringForShell(GLOBAL_PLUGIN_PATH));
             } else {
-                this.args.push(LOCAL_PLUGIN_PATH);
+                this.args.push(escapeStringForShell(LOCAL_PLUGIN_PATH));
             }
             return argumentor;
         },
         run: function () {
-            var cmd = "";           
+            var cmd = "";
             if (require('os').type().toLowerCase().indexOf("windows") >= 0) {
                 cmd += "@node.exe ";
             }
@@ -104,6 +105,7 @@ function addPlugin (pluginPath) {
         plugin = path.resolve(GLOBAL_PLUGIN_PATH, plugin);
         if (!fs.existsSync(plugin)) {
             console.log("Input ", pluginPath || argumentor.plugin, " cannot be resolved as a plugin");
+            listHelp();
             process.exit(1);
         }
     }
@@ -119,6 +121,7 @@ function addPlugin (pluginPath) {
 
     if (!pluginDirs.length) {
         console.log("No plugins could be found given the input " + pluginPath || argumentor.plugin);
+        listHelp();
         process.exit(1);
     } else {
         pluginDirs.forEach(function (pluginDir) {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/lib/run
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/run b/lib/cordova-blackberry/bin/templates/project/cordova/lib/run
index d6b4b9c..d4430f9 100755
--- a/lib/cordova-blackberry/bin/templates/project/cordova/lib/run
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/run
@@ -24,20 +24,24 @@ var childProcess = require("child_process"),
     conf = require("./conf"),
     localize = require("./localize"),
     pkgrUtils = require("./packager-utils"),
+    debugTokenHelper = require("./debugtoken-helper"),
     properties = require('../../project.json'),
     program = require('commander'),
     xml2js = require('xml2js'),
+    jWorkflow = require("jWorkflow"),
+    logger = require("./logger"),
+    pin,
+    needCreateDebugToken = false,
+    needDeployDebugToken = false,
+    commandStr,
     target,
     ip,
     password,
-    workingdir,
-    barPath;
+    workingdir = path.normalize(__dirname + "/..");
 
 function generateOptions(uninstall) {
     var options = [];
-
-    workingdir = path.normalize(__dirname + "/.."),
-    barPath = path.normalize(__dirname + "/../../build/" + properties.targets[target].type + "/" + properties.barName + ".bar");
+        barPath = pkgrUtils.escapeStringForShell(path.normalize(__dirname + "/../../build/" + properties.targets[target].type + "/" + properties.barName + ".bar"));
 
     options.push("-device");
     options.push(ip);
@@ -96,49 +100,29 @@ function execNativeDeploy(optionsArray, callback) {
 
 function checkTarget() {
     if (!target) {
-        console.log("No target exists, to add that target please run target add <name> <ip> [-t | --type <device | simulator>] [-p <password>] [--pin <devicepin>]\n");
+        console.log("No target exists, to add that target please run target add <name> <ip> [-t | --type <device | simulator>] [-p <password>] [--pin <devicepin>]");
+        console.log(program.helpInformation());
         return false;
     }
     if (!properties.targets[target]) {
-        console.log("The target \""+target+"\" does not exist, to add that target please run target add "+target+" <ip> [-t | --type <device | simulator>] [-p <password>] [--pin <devicepin>]\n");
+        console.log("The target \""+target+"\" does not exist, to add that target please run target add "+target+" <ip> [-t | --type <device | simulator>] [-p <password>] [--pin <devicepin>]");
+        console.log(program.helpInformation());
         return false;
     }
     if (properties.targets[target].ip) {
-       ip = properties.targets[target].ip; 
+       ip = properties.targets[target].ip;
     } else {
-        console.log("IP is not defined in target \""+target+"\"\n");
+        console.log("IP is not defined in target \""+target+"\"");
+        console.log(program.helpInformation());
         return false;
     }
     if (properties.targets[target].password) {
        password = properties.targets[target].password;
-    } 
-    return true;
-
-}
-
-function deployAll(keys) {
-    target = keys[0];
-
-    if (target) {
-        if (checkTarget()) {
-            var options = generateOptions();
-            if (program.uninstall) {
-                uninstall(
-                    function() {
-                        keys.shift();
-                        deployAll(keys);
-                });
-            } else {
-                execNativeDeploy(options,
-                    function() {
-                        deployAll(keys);
-                });
-            }
-        }
     }
+    return true;
 }
 
-function uninstall(callback) {
+function uninstall() {
     var script = "/bin/blackberry-deploy",
         nativeDeploy;
 
@@ -158,12 +142,10 @@ function uninstall(callback) {
                         var options = generateOptions(true);
                         execNativeDeploy(options,
                             function(){
-                                options = generateOptions(false);
-                                execNativeDeploy(options, callback);
+                                deploy();
                         });
                     } else {
-                        options = generateOptions(false);
-                        execNativeDeploy(options, callback);
+                        deploy();
                     }
                 });
             });
@@ -171,34 +153,143 @@ function uninstall(callback) {
     }
 }
 
-function exec(callback) {
-    program
-        .usage('command [<target>] [--no-launch] [--no-uninstall]')
-        .option('--no-uninstall', 'does not uninstall app from device')
-        .option('--no-launch', 'do not launch the app on device')
+function deploy() {
+    options = generateOptions(false);
+    execNativeDeploy(options, function (code) {
+        if (code) {
+            process.exit(2);
+        } else {
+            process.exit(0);
+        }
+    });
+}
 
-    program
-        .command('all')
-        .usage('all [--no-launch] [--no-uninstall]')
-        .description('    Deploy the app on all targets')
-        .option('--no-uninstall', 'does not uninstall app from device')
-        .option('--no-launch', 'do not launch the app on device')
-    
-    program.parse(process.argv);
-    target = program.args[0] ? program.args[0] : properties.defaultTarget
+function checkDebugtoken(previous, baton) {
+    baton.take();
 
-    if (target === "all") {
-        deployAll(Object.keys(properties.targets));
-    } else {
-        if (checkTarget()) {
-            if (program.uninstall) {
-                uninstall(callback);
+    // if target has no pin, skip the debug token feature
+    if (properties.targets[target].pin) {
+        debugTokenHelper.checkDebugToken(properties.targets[target].pin, function (valid) {
+            // If the debug token is not valid, we need create new debug token
+            if (valid) {
+                // No need to create the debug token
+                logger.info(localize.translate("PROGRESS_DEBUG_TOKEN_IS_VALID"));
+                needDeployDebugToken = true;
             } else {
-                options = generateOptions(false);
-                execNativeDeploy(options, callback)
+                needCreateDebugToken = true;
             }
+            baton.pass();
+        });
+    } else {
+        baton.pass();
+    }
+}
+
+function createDebugToken(previous, baton) {
+    var keystorepass = program["keystorepass"] ? program["keystorepass"] : properties.keystorepass;
+
+    baton.take();
+
+    if (needCreateDebugToken) {
+        debugTokenHelper.createToken(properties, "all", keystorepass, function (code) {
+            if (code === 0) {
+                // Deploy the debug token if created
+                needDeployDebugToken = true;
+            }
+
+            baton.pass();
+        });
+    } else {
+            baton.pass();
+    }
+}
+
+function deployDebugToken(previous, baton) {
+    baton.take();
+
+    // If in debug build and debug token was created, deploy the debug token and wait until the deployment is finished
+    if (needDeployDebugToken) {
+        debugTokenHelper.deployToken(properties, target, function () {
+            baton.pass();
+        });
+    } else {
+        baton.pass();
+    }
+}
+
+function handleBuildOutput(data) {
+    var msg = data.toString().replace(/[\n\r]/g, '');
+    console.log(msg);
+}
+
+function build(previous, baton) {
+    var nativeDeploy,
+        execName = "./build";
+
+    baton.take();
+
+    if (pkgrUtils.isWindows()) {
+        execName = "build";
+    } 
+
+    nativeDeploy = childProcess.exec(execName, {
+        "cwd": path.normalize(__dirname + "/.."),
+        "env": process.env
+    });
+
+    nativeDeploy.stdout.on("data", handleBuildOutput);
+
+    nativeDeploy.stderr.on("data", handleBuildOutput);
+
+    nativeDeploy.on("exit", function (code) {
+        // If error happened during building the bar, exit
+        if (code === 2) {
+            process.exit(2);
+        }
+
+        baton.pass();
+    });
+}
+
+function postBuild() {
+    if (program.uninstall) {
+        uninstall();
+    } else {
+        deploy();
+    }
+}
+
+function exec() {
+    program
+        .usage('[--target=<id>] [-k | --keystorepass] [--no-launch] [--no-uninstall] [--no-build]')
+        .option('-k, --keystorepass <password>', 'the password of signing key; needed for creating debug token')
+        .option('--target', 'specifies the target to run the application')
+        .option('--no-uninstall', 'does not uninstall application from device')
+        .option('--no-launch', 'do not launch the application on device')
+        .option('--no-build', 'deploy the pre-built bar file and skip building');
+
+    commandStr = typeof process.argv[2] === "string" ? process.argv[2] : undefined;
+    if (commandStr && commandStr.indexOf("--target=") === 0) {
+        // Convert "--target=<id>" into "--target id"
+        process.argv[2] = "--target";
+        process.argv.splice(3, 0, commandStr.substring("--target=".length));
+    }
+
+    program.parse(process.argv);
+    target = program.args[0] ? program.args[0] : properties.defaultTarget;
+
+    if (checkTarget()) {
+        if (program.build) {
+            jWorkflow.order(checkDebugtoken)
+                     .andThen(createDebugToken)
+                     .andThen(deployDebugToken)
+                     .andThen(build)
+                     .andThen(postBuild)
+                     .start();
+        } else {
+            postBuild();
         }
     }
 }
 
-exec(null);
\ No newline at end of file
+exec();

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/lib/start-emulator
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/start-emulator b/lib/cordova-blackberry/bin/templates/project/cordova/lib/start-emulator
new file mode 100755
index 0000000..cfb96a8
--- /dev/null
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/start-emulator
@@ -0,0 +1,54 @@
+#!/usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# support for this script on BB10 is dependent on vmware tools being on the path, or in the default install directory
+# Valid values for "--target": path to 'vmwarevm' file
+
+VMWARE_DEFAULT_PATH=/Applications/VMware\ Fusion.app/Contents/Library
+VMWARE_TOOL=vmrun
+OS_NAME=`uname`
+
+if [ "$1" = "" -o ! -e "$1" ]
+then
+    echo "BlackBerry10: must provide path to valid vmwarevm image"
+    exit 2
+fi
+
+if [ "$OS_NAME" = "Darwin" ]; then
+    if [ "`which vmrun`" = "" ]; then
+        echo "BlackBerry10: VMware Fusion 'vmrun' tool not found on path, trying default install path"
+        runpath=$VMWARE_DEFAULT_PATH/$VMWARE_TOOL
+    else
+        runpath=`which vmrun`
+    fi
+    
+    if [ -x "$runpath" ]; then
+        echo $runpath start $1
+        `$"$runpath" start "$1" > /dev/null`
+
+        exit 0 
+    else
+        echo "BlackBerry10: could not find VMware Fusion 'vmrun' tool"
+        exit 1 
+    fi
+else
+    echo "BlackBerry10: currently only supports installing to emulator on OS X"
+    exit 1
+fi

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/lib/start-emulator.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/start-emulator.bat b/lib/cordova-blackberry/bin/templates/project/cordova/lib/start-emulator.bat
new file mode 100644
index 0000000..6671abb
--- /dev/null
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/start-emulator.bat
@@ -0,0 +1,21 @@
+:: Licensed to the Apache Software Foundation (ASF) under one
+:: or more contributor license agreements.  See the NOTICE file
+:: distributed with this work for additional information
+:: regarding copyright ownership.  The ASF licenses this file
+:: to you under the Apache License, Version 2.0 (the
+:: "License"); you may not use this file except in compliance
+:: with the License.  You may obtain a copy of the License at
+::
+:: http://www.apache.org/licenses/LICENSE-2.0
+::
+:: Unless required by applicable law or agreed to in writing,
+:: software distributed under the License is distributed on an
+:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+:: KIND, either express or implied.  See the License for the
+:: specific language governing permissions and limitations
+:: under the License.
+
+@ECHO OFF
+
+ECHO echo 'BlackBerry10: Not able to start emulator images on windows command-line at this time.'
+EXIT /B 1

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/lib/target
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/lib/target b/lib/cordova-blackberry/bin/templates/project/cordova/lib/target
index c21e6c7..0a5746b 100644
--- a/lib/cordova-blackberry/bin/templates/project/cordova/lib/target
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/lib/target
@@ -41,7 +41,9 @@ function isValidIp(ip) {
         ipArray;
 
     if (typeof ip !== 'string') {
-        throw "IP is required";
+        console.log("IP is required");
+        console.log(commander.helpInformation());
+        process.exit(2); 
     } else {
         ipArray = ip.split('.');
         if (ipArray.length !== 4) {
@@ -61,7 +63,9 @@ function isValidType(type) {
     var result = true;
 
     if (typeof type !== 'string') {
-        throw "target type is required";
+        console.log("target type is required");
+        console.log(commander.helpInformation());
+        process.exit(2); 
     }
     else if (!(type === 'device' || type === 'simulator')) {
         result = false;
@@ -98,7 +102,9 @@ commander
     .description("Add specified target")
     .action(function () {
         if (commander.args.length === 1) {
-            throw "Target details not specified";
+            console.log("Target details not specified");
+            console.log(commander.helpInformation());
+            process.exit(2); 
         }
         name = commander.args[0];
         ip = commander.args[1];
@@ -110,13 +116,19 @@ commander
             pin = commander.pin;
         }
         if (!isValidIp(ip)) {
-            throw "Invalid IP: " + ip;
+            console.log("Invalid IP: " + ip);
+            console.log(commander.helpInformation());
+            process.exit(2); 
         }
         if (!isValidType(type)) {
-            throw "Invalid target type: " + type;
+            console.log("Invalid target type: " + type);
+            console.log(commander.helpInformation());
+            process.exit(2); 
         }
         if (!isValidPin(pin)) {
-            throw "Invalid PIN: " + pin;
+            console.log("Invalid PIN: " + pin);
+            console.log(commander.helpInformation());
+            process.exit(2); 
         }
         if (properties.targets.hasOwnProperty(name)) {
             console.log("Overwriting target: " + name);
@@ -129,11 +141,15 @@ commander
     .description("Remove specified target")
     .action(function () {
         if (commander.args.length === 1) {
-            throw 'No target specified';
+            console.log('No target specified');
+            console.log(commander.helpInformation());
+            process.exit(2); 
         }
         name = commander.args[0];
         if (!properties.targets.hasOwnProperty(name)) {
-            throw "Target: '" + name + "' not found";
+            console.log("Target: '" + name + "' not found");
+            console.log(commander.helpInformation());
+            process.exit(2); 
         }
         if (name === properties.defaultTarget) {
             console.log("Deleting default target, please set a new default target");
@@ -154,14 +170,18 @@ commander
         if (properties.targets.hasOwnProperty(name)) {
             properties.defaultTarget = name;
         } else {
-            throw "Target '" + name + "' not found";
+            console.log("Target '" + name + "' not found");
+            console.log(commander.helpInformation());
+            process.exit(2); 
         }
     });
 
 commander
     .command('*')
     .action(function () {
-        throw 'Unrecognized command';
+        console.log('Unrecognized command');
+        console.log(commander.helpInformation());
+        process.exit(2);
     });
 
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/plugin.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/plugin.bat b/lib/cordova-blackberry/bin/templates/project/cordova/plugin.bat
index 54245e0..8a53da1 100755
--- a/lib/cordova-blackberry/bin/templates/project/cordova/plugin.bat
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/plugin.bat
@@ -18,4 +18,4 @@ goto comment
        under the License.
 :comment
 
-@node.exe %~dp0\plugin %*
+@node.exe %~dps0\plugin %*

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/run
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/run b/lib/cordova-blackberry/bin/templates/project/cordova/run
index 44d3334..c6ccacf 100755
--- a/lib/cordova-blackberry/bin/templates/project/cordova/run
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/run
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-node $( dirname "$0")"/lib/run" "$@"
+node "$( dirname "$0")/lib/run" "$@"

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/run.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/run.bat b/lib/cordova-blackberry/bin/templates/project/cordova/run.bat
index 0f5da0a..32b6cc3 100755
--- a/lib/cordova-blackberry/bin/templates/project/cordova/run.bat
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/run.bat
@@ -18,4 +18,4 @@ goto comment
        under the License.
 :comment
 
-@node.exe %~dp0\lib\run %*
+@node.exe %~dps0\lib\run %*

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/target
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/target b/lib/cordova-blackberry/bin/templates/project/cordova/target
index 6a28219..4e676d2 100755
--- a/lib/cordova-blackberry/bin/templates/project/cordova/target
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/target
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-node $( dirname "$0")"/lib/target" "$@"
+node "$( dirname "$0")/lib/target" "$@"

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/cordova/target.bat
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/cordova/target.bat b/lib/cordova-blackberry/bin/templates/project/cordova/target.bat
index 545b79e..3c05c97 100755
--- a/lib/cordova-blackberry/bin/templates/project/cordova/target.bat
+++ b/lib/cordova-blackberry/bin/templates/project/cordova/target.bat
@@ -18,4 +18,4 @@ goto comment
        under the License.
 :comment
 
-@node.exe %~dp0\lib\target %*
+@node.exe %~dps0\lib\target %*

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/project.json
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/project.json b/lib/cordova-blackberry/bin/templates/project/project.json
index 97bbb24..97390ae 100644
--- a/lib/cordova-blackberry/bin/templates/project/project.json
+++ b/lib/cordova-blackberry/bin/templates/project/project.json
@@ -1,6 +1,5 @@
 {
     "barName": "cordova-BB10-app",
-    "keystorepass": "password",
     "defaultTarget": "",
     "targets": {}
 }

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/www/VERSION
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/www/VERSION b/lib/cordova-blackberry/bin/templates/project/www/VERSION
index 38f8e88..834f262 100644
--- a/lib/cordova-blackberry/bin/templates/project/www/VERSION
+++ b/lib/cordova-blackberry/bin/templates/project/www/VERSION
@@ -1 +1 @@
-dev
+2.8.0

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/www/config.xml
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/www/config.xml b/lib/cordova-blackberry/bin/templates/project/www/config.xml
index 3edc941..a645139 100644
--- a/lib/cordova-blackberry/bin/templates/project/www/config.xml
+++ b/lib/cordova-blackberry/bin/templates/project/www/config.xml
@@ -24,7 +24,7 @@
 
 <widget xmlns="http://www.w3.org/ns/widgets"
         xmlns:rim="http://www.blackberry.com/ns/widgets"
-	version="1.0.0" id="default.app.id">
+	version="1.0.0.1" id="default.app.id">
 
   <name>Webworks Application</name>
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/www/index.html
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/www/index.html b/lib/cordova-blackberry/bin/templates/project/www/index.html
index ce767eb..e84fbd7 100644
--- a/lib/cordova-blackberry/bin/templates/project/www/index.html
+++ b/lib/cordova-blackberry/bin/templates/project/www/index.html
@@ -33,7 +33,7 @@
                 <p class="event received">Device is Ready</p>
             </div>
         </div>
-        <script type="text/javascript" src="cordova-dev.js"></script>
+        <script type="text/javascript" src="cordova.js"></script>
         <script type="text/javascript" src="js/index.js"></script>
         <script type="text/javascript">
             app.initialize();

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/bin/templates/project/www/res/screen/blackberry/screen-225.png
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/bin/templates/project/www/res/screen/blackberry/screen-225.png b/lib/cordova-blackberry/bin/templates/project/www/res/screen/blackberry/screen-225.png
new file mode 100644
index 0000000..29873e9
Binary files /dev/null and b/lib/cordova-blackberry/bin/templates/project/www/res/screen/blackberry/screen-225.png differ

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/javascript/cordova.blackberry10.js
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/javascript/cordova.blackberry10.js b/lib/cordova-blackberry/javascript/cordova.blackberry10.js
index ebe8a46..e97f404 100644
--- a/lib/cordova-blackberry/javascript/cordova.blackberry10.js
+++ b/lib/cordova-blackberry/javascript/cordova.blackberry10.js
@@ -1,5 +1,5 @@
 // Platform: blackberry10
-// 2.7.0rc1-73-g0bca505
+// 2.8.0-0-g6208c95
 /*
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
@@ -19,7 +19,7 @@
  under the License.
 */
 ;(function() {
-var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-73-g0bca505';
+var CORDOVA_JS_BUILD_LABEL = '2.8.0-0-g6208c95';
 // file: lib/scripts/require.js
 
 var require,
@@ -5023,7 +5023,6 @@ function Device() {
     this.available = false;
     this.platform = null;
     this.version = null;
-    this.name = null;
     this.uuid = null;
     this.cordova = null;
     this.model = null;
@@ -5039,7 +5038,6 @@ function Device() {
             me.available = true;
             me.platform = info.platform;
             me.version = info.version;
-            me.name = info.name;
             me.uuid = info.uuid;
             me.cordova = buildLabel;
             me.model = info.model;
@@ -6583,6 +6581,11 @@ window.cordova = require('cordova');
 // file: lib/scripts/bootstrap.js
 
 (function (context) {
+    if (context._cordovaJsLoaded) {
+        throw new Error('cordova.js included multiple times.');
+    }
+    context._cordovaJsLoaded = true;
+
     var channel = require('cordova/channel');
     var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady];
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/lib/cordova-blackberry/package.json
----------------------------------------------------------------------
diff --git a/lib/cordova-blackberry/package.json b/lib/cordova-blackberry/package.json
index a879ba3..d1f25f7 100644
--- a/lib/cordova-blackberry/package.json
+++ b/lib/cordova-blackberry/package.json
@@ -11,11 +11,13 @@
     "type": "Apache 2.0",
     "url": "http://www.apache.org/licenses/LICENSE-2.0"
   }],
+  "engines": {
+    "node": ">=0.9.9"
+  },
   "scripts": {
     "test": "./node_modules/jake/bin/cli.js"
   },
   "dependencies": {
-    "jasmine-node": "1.0.7",
     "jWorkflow": "0.8.0",
     "commander": "0.5.2",
     "localize": "*0.4.2",
@@ -28,6 +30,8 @@
     "plugman": "0.7.7"
   },
   "devDependencies": {
-    "jake":"*"
-  }
+    "jake":"*",
+    "jasmine-node": "1.0.7"
+  },
+  "readmeFilename": "README.md"
 }

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/f5baa6e5/platforms.js
----------------------------------------------------------------------
diff --git a/platforms.js b/platforms.js
index b2f7b0b..1854695 100644
--- a/platforms.js
+++ b/platforms.js
@@ -33,9 +33,9 @@ module.exports = {
     'wp8' : {
         parser : require('./src/metadata/wp8_parser'),
         url    : 'https://git-wip-us.apache.org/repos/asf/cordova-wp8.git'
-    }/*,
+    },
     blackberry : {
         parser : require('./metadata/blackberry_parser'),
         url    : 'https://git-wip-us.apache.org/repos/asf/cordova-blackberry.git'
-    }*/
+    }
 };


[19/22] git commit: fixed wp deploy tooling to work with new run/emulate command

Posted by fi...@apache.org.
fixed wp deploy tooling to work with new run/emulate command


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/b7fc9df1
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/b7fc9df1
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/b7fc9df1

Branch: refs/heads/2.8.x
Commit: b7fc9df19ef638d9e5942948f0ca9b7b6a028cdf
Parents: dc34023
Author: Benn Mapes <be...@gmail.com>
Authored: Thu Jun 6 14:47:17 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 6 18:30:21 2013 -0700

----------------------------------------------------------------------
 .../templates/standalone/cordova/lib/deploy.js     |  117 ++++++++-------
 .../templates/standalone/cordova/lib/deploy.js     |  117 ++++++++-------
 2 files changed, 128 insertions(+), 106 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b7fc9df1/lib/cordova-wp7/templates/standalone/cordova/lib/deploy.js
----------------------------------------------------------------------
diff --git a/lib/cordova-wp7/templates/standalone/cordova/lib/deploy.js b/lib/cordova-wp7/templates/standalone/cordova/lib/deploy.js
index 29a3f7d..448fa78 100644
--- a/lib/cordova-wp7/templates/standalone/cordova/lib/deploy.js
+++ b/lib/cordova-wp7/templates/standalone/cordova/lib/deploy.js
@@ -28,6 +28,8 @@ var ROOT = WScript.ScriptFullName.split('\\cordova\\lib\\deploy.js').join('');
 var CORDOVA_DEPLOY_EXE = '\\cordova\\lib\\CordovaDeploy\\CordovaDeploy\\bin\\Debug\\CordovaDeploy.exe';
     // path to CordovaDeploy
 var CORDOVA_DEPLOY = '\\cordova\\lib\\CordovaDeploy';
+//device_id for targeting specific device
+var device_id;
 
 //build types
 var NONE = 0,
@@ -36,18 +38,27 @@ var NONE = 0,
     NO_BUILD = 3;
 var build_type = NONE;
 
+//deploy tpyes
+var NONE = 0,
+    EMULATOR = 1,
+    DEVICE = 2,
+    TARGET = 3;
+var deploy_type = NONE;
+
 
 // help function
 function Usage() {
     Log("");
-    Log("Usage: run [ --device | --emulator | --target=<id> ] [ --debug | --release | --nobuild ]");
+    Log("Usage:");
+    Log("  run [ --device || --emulator || --target=<id> ] ");
+    Log("      [ --debug || --release || --nobuild ]");
     Log("    --device      : Deploys and runs the project on the connected device.");
-    Log("    --emulator    : Deploys and runs the project on an emulator.");
+    Log("    --emulator    : [DEFAULT] Deploys and runs the project on an emulator.");
     Log("    --target=<id> : Deploys and runs the project on the specified target.");
-    Log("    --debug       : Builds project in debug mode.");
+    Log("    --debug       : [DEFAULT] Builds project in debug mode.");
     Log("    --release     : Builds project in release mode.");
     Log("    --nobuild     : Ueses pre-built xap, or errors if project is not built.");
-    Log("examples:");
+    Log("Examples:");
     Log("    run");
     Log("    run --emulator");
     Log("    run --device");
@@ -184,7 +195,7 @@ function emulator(path)
 }
 
 // builds and launches the project on the specified target
-function target(path, device_id) {
+function target(path) {
     if (!fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
         cordovaDeploy(path);
     }
@@ -246,65 +257,67 @@ function build(path) {
     }
 }
 
+function run(path) {
+    switch(deploy_type) {
+        case EMULATOR :
+            build(path);
+            emulator(path);
+            break;
+        case DEVICE :
+            build(path);
+            device(path);
+            break;
+        case TARGET :
+            build(path);
+            target(path);
+            break;
+        case NONE :
+            Log("WARNING: [ --target=<ID> | --emulator | --device ] not specified, defaulting to --emulator");
+            build(path);
+            emulator(path);
+            break;
+        default :
+            Log("Deploy option not recognized: " + deploy_type, true);
+            WScript.Quit(2);
+            break;
+    }
+}
+
 
 if (args.Count() > 0) {
-    // support help flags
-    if (args(0) == "--help" || args(0) == "/?" ||
-            args(0) == "help" || args(0) == "-help" || args(0) == "/help") {
-        Usage();
-        WScript.Quit(2);
-    }
-    else if (args.Count() > 2) {
+    // limit args
+    if (args.Count() > 2) {
         Log('Error: Too many arguments.', true);
         Usage();
         WScript.Quit(2);
     }
     else if (fso.FolderExists(ROOT)) {
-        if (args.Count() > 1) {
-            if (args(1) == "--release") {
+        // parse arguments
+        for(var i = 0; i < args.Count(); i++) {
+            if (args(i) == "--release") {
                 build_type = RELEASE;
             }
-            else if (args(1) == "--debug") {
+            else if (args(i) == "--debug") {
                 build_type = DEBUG;
             }
-            else if (args(1) == "--nobuild") {
+            else if (args(i) == "--nobuild") {
                 build_type = NO_BUILD;
             }
-            else {
-                Log('Error: \"' + args(1) + '\" is not recognized as a deploy option', true);
-                Usage();
-                WScript.Quit(2);
+            else if (args(i) == "--emulator" || args(i) == "-e") {
+                deploy_type = EMULATOR;
             }
-        }
-
-        if (args(0) == "--emulator" || args(0) == "-e") {
-            build(ROOT);
-            emulator(ROOT);
-        }
-        else if (args(0) == "--device" || args(0) == "-d") {
-            build(ROOT);
-            device(ROOT);
-        }
-        else if (args(0).substr(0,9) == "--target=") {
-            build(ROOT);
-            var device_id = args(0).split("--target=").join("");
-            target(ROOT, device_id);
-        }
-        else {
-            Log("WARNING: [ --target=<ID> | --emulator | --device ] not specified, defaulting to --emulator");
-            if (args(0) == "--release") {
-                build_type = RELEASE;
-                build(ROOT);
-                emulator(ROOT);
+            else if (args(i) == "--device" || args(i) == "-d") {
+                deploy_type = DEVICE;
             }
-            else if (args(0) == "--debug") {
-                build_type = DEBUG;
-                build(ROOT);
-                emulator(ROOT);
+            else if (args(i).substr(0,9) == "--target=") {
+                device_id = args(i).split("--target=").join("");
+                deploy_type = TARGET;
             }
-            else if (args(0) == "--nobuild") {
-                build_type = NO_BUILD;
-                emulator(ROOT);
+             // support help flags
+            else if (args(0) == "--help" || args(0) == "/?" ||
+                    args(0) == "help" || args(0) == "-help" || args(0) == "/help") {
+                Usage();
+                WScript.Quit(2);
             }
             else {
                 Log('Error: \"' + args(0) + '\" is not recognized as a deploy option', true);
@@ -319,8 +332,6 @@ if (args.Count() > 0) {
         WScript.Quit(2);
     }
 }
-else {
-    Log("WARNING: [ --target=<ID> | --emulator | --device ] not specified, defaulting to --emulator");
-    build(ROOT);
-    emulator(ROOT);
-}
\ No newline at end of file
+
+// Finally run the project!
+run(ROOT);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b7fc9df1/lib/cordova-wp8/templates/standalone/cordova/lib/deploy.js
----------------------------------------------------------------------
diff --git a/lib/cordova-wp8/templates/standalone/cordova/lib/deploy.js b/lib/cordova-wp8/templates/standalone/cordova/lib/deploy.js
index 29a3f7d..448fa78 100644
--- a/lib/cordova-wp8/templates/standalone/cordova/lib/deploy.js
+++ b/lib/cordova-wp8/templates/standalone/cordova/lib/deploy.js
@@ -28,6 +28,8 @@ var ROOT = WScript.ScriptFullName.split('\\cordova\\lib\\deploy.js').join('');
 var CORDOVA_DEPLOY_EXE = '\\cordova\\lib\\CordovaDeploy\\CordovaDeploy\\bin\\Debug\\CordovaDeploy.exe';
     // path to CordovaDeploy
 var CORDOVA_DEPLOY = '\\cordova\\lib\\CordovaDeploy';
+//device_id for targeting specific device
+var device_id;
 
 //build types
 var NONE = 0,
@@ -36,18 +38,27 @@ var NONE = 0,
     NO_BUILD = 3;
 var build_type = NONE;
 
+//deploy tpyes
+var NONE = 0,
+    EMULATOR = 1,
+    DEVICE = 2,
+    TARGET = 3;
+var deploy_type = NONE;
+
 
 // help function
 function Usage() {
     Log("");
-    Log("Usage: run [ --device | --emulator | --target=<id> ] [ --debug | --release | --nobuild ]");
+    Log("Usage:");
+    Log("  run [ --device || --emulator || --target=<id> ] ");
+    Log("      [ --debug || --release || --nobuild ]");
     Log("    --device      : Deploys and runs the project on the connected device.");
-    Log("    --emulator    : Deploys and runs the project on an emulator.");
+    Log("    --emulator    : [DEFAULT] Deploys and runs the project on an emulator.");
     Log("    --target=<id> : Deploys and runs the project on the specified target.");
-    Log("    --debug       : Builds project in debug mode.");
+    Log("    --debug       : [DEFAULT] Builds project in debug mode.");
     Log("    --release     : Builds project in release mode.");
     Log("    --nobuild     : Ueses pre-built xap, or errors if project is not built.");
-    Log("examples:");
+    Log("Examples:");
     Log("    run");
     Log("    run --emulator");
     Log("    run --device");
@@ -184,7 +195,7 @@ function emulator(path)
 }
 
 // builds and launches the project on the specified target
-function target(path, device_id) {
+function target(path) {
     if (!fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
         cordovaDeploy(path);
     }
@@ -246,65 +257,67 @@ function build(path) {
     }
 }
 
+function run(path) {
+    switch(deploy_type) {
+        case EMULATOR :
+            build(path);
+            emulator(path);
+            break;
+        case DEVICE :
+            build(path);
+            device(path);
+            break;
+        case TARGET :
+            build(path);
+            target(path);
+            break;
+        case NONE :
+            Log("WARNING: [ --target=<ID> | --emulator | --device ] not specified, defaulting to --emulator");
+            build(path);
+            emulator(path);
+            break;
+        default :
+            Log("Deploy option not recognized: " + deploy_type, true);
+            WScript.Quit(2);
+            break;
+    }
+}
+
 
 if (args.Count() > 0) {
-    // support help flags
-    if (args(0) == "--help" || args(0) == "/?" ||
-            args(0) == "help" || args(0) == "-help" || args(0) == "/help") {
-        Usage();
-        WScript.Quit(2);
-    }
-    else if (args.Count() > 2) {
+    // limit args
+    if (args.Count() > 2) {
         Log('Error: Too many arguments.', true);
         Usage();
         WScript.Quit(2);
     }
     else if (fso.FolderExists(ROOT)) {
-        if (args.Count() > 1) {
-            if (args(1) == "--release") {
+        // parse arguments
+        for(var i = 0; i < args.Count(); i++) {
+            if (args(i) == "--release") {
                 build_type = RELEASE;
             }
-            else if (args(1) == "--debug") {
+            else if (args(i) == "--debug") {
                 build_type = DEBUG;
             }
-            else if (args(1) == "--nobuild") {
+            else if (args(i) == "--nobuild") {
                 build_type = NO_BUILD;
             }
-            else {
-                Log('Error: \"' + args(1) + '\" is not recognized as a deploy option', true);
-                Usage();
-                WScript.Quit(2);
+            else if (args(i) == "--emulator" || args(i) == "-e") {
+                deploy_type = EMULATOR;
             }
-        }
-
-        if (args(0) == "--emulator" || args(0) == "-e") {
-            build(ROOT);
-            emulator(ROOT);
-        }
-        else if (args(0) == "--device" || args(0) == "-d") {
-            build(ROOT);
-            device(ROOT);
-        }
-        else if (args(0).substr(0,9) == "--target=") {
-            build(ROOT);
-            var device_id = args(0).split("--target=").join("");
-            target(ROOT, device_id);
-        }
-        else {
-            Log("WARNING: [ --target=<ID> | --emulator | --device ] not specified, defaulting to --emulator");
-            if (args(0) == "--release") {
-                build_type = RELEASE;
-                build(ROOT);
-                emulator(ROOT);
+            else if (args(i) == "--device" || args(i) == "-d") {
+                deploy_type = DEVICE;
             }
-            else if (args(0) == "--debug") {
-                build_type = DEBUG;
-                build(ROOT);
-                emulator(ROOT);
+            else if (args(i).substr(0,9) == "--target=") {
+                device_id = args(i).split("--target=").join("");
+                deploy_type = TARGET;
             }
-            else if (args(0) == "--nobuild") {
-                build_type = NO_BUILD;
-                emulator(ROOT);
+             // support help flags
+            else if (args(0) == "--help" || args(0) == "/?" ||
+                    args(0) == "help" || args(0) == "-help" || args(0) == "/help") {
+                Usage();
+                WScript.Quit(2);
             }
             else {
                 Log('Error: \"' + args(0) + '\" is not recognized as a deploy option', true);
@@ -319,8 +332,6 @@ if (args.Count() > 0) {
         WScript.Quit(2);
     }
 }
-else {
-    Log("WARNING: [ --target=<ID> | --emulator | --device ] not specified, defaulting to --emulator");
-    build(ROOT);
-    emulator(ROOT);
-}
\ No newline at end of file
+
+// Finally run the project!
+run(ROOT);
\ No newline at end of file


[08/22] git commit: npm version 2.8.4

Posted by fi...@apache.org.
npm version 2.8.4


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/bb9e8232
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/bb9e8232
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/bb9e8232

Branch: refs/heads/2.8.x
Commit: bb9e8232e57748ae07392634730bc9a3093241ae
Parents: cf9eb15
Author: Fil Maj <ma...@gmail.com>
Authored: Wed Jun 5 08:18:32 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 6 18:28:55 2013 -0700

----------------------------------------------------------------------
 package.json |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bb9e8232/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 71f9453..82db18f 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "cordova",
-  "version": "2.8.3",
+  "version": "2.8.4",
   "preferGlobal": "true",
   "description": "Cordova command line interface tool",
   "main": "cordova",


[20/22] git commit: start of serializing events/hooks

Posted by fi...@apache.org.
start of serializing events/hooks


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/6d81b4d9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/6d81b4d9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/6d81b4d9

Branch: refs/heads/2.8.x
Commit: 6d81b4d92f4dba4a453f3f513a5eca15eeb4a0f3
Parents: b7fc9df
Author: Fil Maj <ma...@gmail.com>
Authored: Thu Jun 6 10:09:57 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 6 18:30:24 2013 -0700

----------------------------------------------------------------------
 src/compile.js |   38 ++++++++++++++--------------
 src/hooker.js  |   70 +++++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 73 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6d81b4d9/src/compile.js
----------------------------------------------------------------------
diff --git a/src/compile.js b/src/compile.js
index 8d9d217..f969624 100644
--- a/src/compile.js
+++ b/src/compile.js
@@ -26,7 +26,6 @@ var cordova_util      = require('./util'),
     events            = require('./events'),
     n                 = require('ncallbacks');
 
-
 function shell_out_to_build(projectRoot, platform, callback) {
     var cmd = '"' + path.join(projectRoot, 'platforms', platform, 'cordova', 'build') + '"';
     events.emit('log', 'Compiling platform "' + platform + '" with command "' + cmd + '" (output to follow)...');
@@ -70,25 +69,26 @@ module.exports = function compile(platformList, callback) {
     }
 
     var hooks = new hooker(projectRoot);
-    if (!(hooks.fire('before_compile'))) {
-        var err = new Error('before_compile hooks exited with non-zero code. Aborting.');
-        if (callback) callback(err);
-        else throw err;
-        return;
-    }
+    hooks.fire('before_compile', function(err) {
+        if (err) {
+            var error = new Error('before_compile hooks exited with non-zero code or caused an error: ' + err.message);
+            if (callback) callback(error);
+            else throw error;
+        } else {
+            var end = n(platformList.length, function() {
+                hooks.fire('after_compile', function(error) {
+                    if (error) {
+                        var arr = new Error('after_compile hooks exited with non-zero code. Aborting.');
+                        if (callback) callback(arr);
+                        else throw arr;
+                    } else if (callback) callback();
+                });
+            });
 
-    var end = n(platformList.length, function() {
-        if (!(hooks.fire('after_compile'))) {
-            var err = new Error('after_compile hooks exited with non-zero code. Aborting.');
-            if (callback) callback(err);
-            else throw err;
-            return;
+            // Iterate over each added platform
+            platformList.forEach(function(platform) {
+                shell_out_to_build(projectRoot, platform, end);
+            });
         }
-        if (callback) callback();
-    });
-
-    // Iterate over each added platform
-    platformList.forEach(function(platform) {
-        shell_out_to_build(projectRoot, platform, end);
     });
 };

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6d81b4d9/src/hooker.js
----------------------------------------------------------------------
diff --git a/src/hooker.js b/src/hooker.js
index 0d51304..15c9a6c 100644
--- a/src/hooker.js
+++ b/src/hooker.js
@@ -29,25 +29,63 @@ module.exports = function hooker(root) {
 }
 
 module.exports.prototype = {
-    fire:function fire(hook) {
+    fire:function fire(hook, callback) {
+        var self = this;
         var dir = path.join(this.root, '.cordova', 'hooks', hook);
         if (!(fs.existsSync(dir))) return true; // hooks directory got axed post-create; ignore.
 
-        // Fire JS hook/event
-        events.emit(hook, this.root);
-
-        // Fire script-based hooks
-        var contents = fs.readdirSync(dir);
-        var self = this;
-        contents.forEach(function(script) {
-            var fullpath = path.join(dir, script);
-            if (fs.statSync(fullpath).isDirectory()) return; // skip directories if they're in there.
-            var command = fullpath + ' "' + self.root + '"';
-            events.emit('log', 'Executing hook "' + hook + '" (output to follow)...');
-            var status = shell.exec(command);
-            events.emit('log', status.output);
-            if (status.code !== 0) throw new Error('Script "' + path.basename(script) + '"' + 'in the ' + hook + ' hook exited with non-zero status code. Aborting.');
+        // Fire JS hook for the event
+        // These ones need to "serialize" events, that is, each handler attached to the event needs to finish processing (if it "opted in" to the callback) before the next one will fire.
+        var handlers = events.listeners(hook);
+        execute_handlers_serially(handlers, this.root, function() {
+            // Fire script-based hooks
+            var scripts = fs.readdirSync(dir);
+            execute_scripts_serially(scripts, self.root, dir, function(err) {
+                if (err) {
+                    callback(err);
+                } else {
+                    callback();
+                }
+            });
         });
-        return true;
+    }
+}
+
+function execute_scripts_serially(scripts, root, dir, callback) {
+    if (scripts.length) {
+        var s = scripts.shift();
+        var fullpath = path.join(dir, s);
+        if (fs.statSync(fullpath).isDirectory()) {
+            execute_scripts_serially(scripts, root, dir, callback); // skip directories if they're in there.
+        } else {
+            var command = fullpath + ' "' + root + '"';
+            events.emit('log', 'Executing hook "' + command + '" (output to follow)...');
+            shell.exec(command, {silent:true, async:true}, function(code, output) {
+                events.emit('log', output);
+                if (code !== 0) {
+                    callback(new Error('Script "' + fullpath + '" exited with non-zero status code. Aborting. Output: ' + output));
+                } else {
+                    execute_scripts_serially(scripts, root, dir, callback);
+                }
+            });
+        }
+    } else {
+        callback();
+    }
+}
+
+function execute_handlers_serially(handlers, root, callback) {
+    if (handlers.length) {
+        var h = handlers.shift();
+        if (h.length > 1) {
+            h(root, function() {
+                execute_handlers_serially(handlers, root, callback);
+            });
+        } else {
+            h(root);
+            execute_handlers_serially(handlers, root, callback);
+        }
+    } else {
+        callback();
     }
 }


[11/22] git commit: npm version 2.8.6. [CB-3614] Fix in bootstrap / post-install script for detecting when bootstrap is complete. Giant sudo notification warning should now show up.

Posted by fi...@apache.org.
npm version 2.8.6. [CB-3614] Fix in bootstrap / post-install script for detecting when bootstrap is complete. Giant sudo notification warning should now show up.


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/5fcbb518
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/5fcbb518
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/5fcbb518

Branch: refs/heads/2.8.x
Commit: 5fcbb51809ad70ca65191f32c12e675c87106647
Parents: 05196b3
Author: Fil Maj <ma...@gmail.com>
Authored: Wed Jun 5 12:17:56 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 6 18:29:08 2013 -0700

----------------------------------------------------------------------
 bootstrap.js |    5 +++--
 package.json |    2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5fcbb518/bootstrap.js
----------------------------------------------------------------------
diff --git a/bootstrap.js b/bootstrap.js
index aeefa2b..41dc854 100644
--- a/bootstrap.js
+++ b/bootstrap.js
@@ -42,7 +42,7 @@ var platformsDir = path.join(cordovaDir, 'platforms');
 // kill the stupid spec shit!
 shell.rm('-rf', path.join(cordovaDir, 'www', 'spec'));
 
-var end = n(platforms.length, function() {
+var end = n(Object.keys(platforms).length, function() {
     // Check that we are installing globally into a root-only directory.
     if (process.env.USER == 'root') {
         console.log("**************************************************************************");
@@ -61,6 +61,7 @@ Object.keys(platforms).forEach(function(platform) {
             console.error('WARNING: Your system does not meet requirements to create ' + platform + ' projects. See error output below.');
             console.error(err);
             console.error('SKIPPING ' + platform + ' bootstrap.');
+            end();
         } else {
             console.log('SUCCESS: Minimum requirements for ' + platform + ' met.');
             var fix_path = path.join(tempDir, platform + '_fixture');
@@ -93,8 +94,8 @@ Object.keys(platforms).forEach(function(platform) {
                         shell.chmod('+x', other_script_path);
                     });
                     console.log('SUCCESS: ' + platform + ' ready to rock!');
-                    end();
                 }
+                end();
             });
         }
     });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5fcbb518/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index f3d386c..38ac8a3 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "cordova",
-  "version": "2.8.5",
+  "version": "2.8.6",
   "preferGlobal": "true",
   "description": "Cordova command line interface tool",
   "main": "cordova",


[07/22] git commit: small merge conflict in WP parsers with logging events.

Posted by fi...@apache.org.
small merge conflict in WP parsers with logging events.


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/cf9eb156
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/cf9eb156
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/cf9eb156

Branch: refs/heads/2.8.x
Commit: cf9eb15696760f26204233e4366c6181627d5a76
Parents: 3124223
Author: Fil Maj <ma...@gmail.com>
Authored: Wed Jun 5 08:18:00 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 6 18:28:47 2013 -0700

----------------------------------------------------------------------
 src/compile.js                 |    3 ++-
 src/emulate.js                 |    3 ++-
 src/hooker.js                  |    5 ++++-
 src/metadata/android_parser.js |    8 +++++++-
 src/metadata/ios_parser.js     |    8 ++++++--
 src/metadata/wp7_parser.js     |    7 ++++---
 src/metadata/wp8_parser.js     |    6 +++---
 src/platform.js                |    3 ++-
 8 files changed, 30 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/cf9eb156/src/compile.js
----------------------------------------------------------------------
diff --git a/src/compile.js b/src/compile.js
index 58d944e..1f550f8 100644
--- a/src/compile.js
+++ b/src/compile.js
@@ -36,8 +36,9 @@ function shell_out_to_debug(projectRoot, platform, callback) {
     } else {
         cmd = '"' + path.join(cmd, 'cordova', 'build') + '"';
     }
-    events.emit('log', 'Compiling platform "' + platform + '" with command "' + cmd + '"');
+    events.emit('log', 'Compiling platform "' + platform + '" with command "' + cmd + '" (output to follow)...');
     shell.exec(cmd, {silent:true, async:true}, function(code, output) {
+        events.emit('log', output);
         if (code > 0) {
             throw new Error('An error occurred while building the ' + platform + ' project. ' + output);
         } else {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/cf9eb156/src/emulate.js
----------------------------------------------------------------------
diff --git a/src/emulate.js b/src/emulate.js
index 0787f60..9ccfc0b 100644
--- a/src/emulate.js
+++ b/src/emulate.js
@@ -36,8 +36,9 @@ function shell_out_to_emulate(root, platform, callback) {
     if (platform == 'blackberry') {
         cmd = 'ant -f "' + path.join(root, 'platforms', platform, 'build.xml') + '" qnx load-simulator';
     }
-    events.emit('log', 'Running on emulator for platform "' + platform + '" via command "' + cmd + '"');
+    events.emit('log', 'Running on emulator for platform "' + platform + '" via command "' + cmd + '" (output to follow)...');
     shell.exec(cmd, {silent:true, async:true}, function(code, output) {
+        events.emit('log', output);
         if (code > 0) {
             throw new Error('An error occurred while emulating/deploying the ' + platform + ' project.' + output);
         } else {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/cf9eb156/src/hooker.js
----------------------------------------------------------------------
diff --git a/src/hooker.js b/src/hooker.js
index d40b686..0d51304 100644
--- a/src/hooker.js
+++ b/src/hooker.js
@@ -42,7 +42,10 @@ module.exports.prototype = {
         contents.forEach(function(script) {
             var fullpath = path.join(dir, script);
             if (fs.statSync(fullpath).isDirectory()) return; // skip directories if they're in there.
-            var status = shell.exec(fullpath + ' "' + self.root + '"');
+            var command = fullpath + ' "' + self.root + '"';
+            events.emit('log', 'Executing hook "' + hook + '" (output to follow)...');
+            var status = shell.exec(command);
+            events.emit('log', status.output);
             if (status.code !== 0) throw new Error('Script "' + path.basename(script) + '"' + 'in the ' + hook + ' hook exited with non-zero status code. Aborting.');
         });
         return true;

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/cf9eb156/src/metadata/android_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/android_parser.js b/src/metadata/android_parser.js
index 63582a4..b66e58b 100644
--- a/src/metadata/android_parser.js
+++ b/src/metadata/android_parser.js
@@ -40,7 +40,11 @@ module.exports = function android_parser(project) {
 };
 
 module.exports.check_requirements = function(callback) {
-    shell.exec('android list target', {silent:true, async:true}, function(code, output) {
+    events.emit('log', 'Checking Android requirements...');
+    var command = 'android list target';
+    events.emit('log', 'Running "' + command + '" (output to follow)');
+    shell.exec(command, {silent:true, async:true}, function(code, output) {
+        events.emit('log', output);
         if (code != 0) {
             callback('The command `android` failed. Make sure you have the latest Android SDK installed, and the `android` command (inside the tools/ folder) added to your path. Output: ' + output);
         } else {
@@ -48,7 +52,9 @@ module.exports.check_requirements = function(callback) {
                 callback('Please install Android target 17 (the Android 4.2 SDK). Make sure you have the latest Android tools installed as well. Run `android` from your command-line to install/update any missing SDKs or tools.');
             } else {
                 var cmd = 'android update project -p ' + path.join(__dirname, '..', '..', 'lib', 'cordova-android', 'framework') + ' -t android-17';
+                events.emit('log', 'Running "' + cmd + '" (output to follow)...');
                 shell.exec(cmd, {silent:true, async:true}, function(code, output) {
+                    events.emit('log', output);
                     if (code != 0) {
                         callback('Error updating the Cordova library to work with your Android environment. Command run: "' + cmd + '", output: ' + output);
                     } else {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/cf9eb156/src/metadata/ios_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/ios_parser.js b/src/metadata/ios_parser.js
index b7e2d69..a8c6229 100644
--- a/src/metadata/ios_parser.js
+++ b/src/metadata/ios_parser.js
@@ -61,10 +61,14 @@ module.exports = function ios_parser(project) {
 };
 
 module.exports.check_requirements = function(callback) {
+    events.emit('log', 'Checking iOS requirements...');
     // Check xcode + version.
-    shell.exec('xcodebuild -version', {silent:true, async:true}, function(code, output) {
+    var command = 'xcodebuild -version';
+    events.emit('log', 'Running "' + command + '" (output to follow)');
+    shell.exec(command, {silent:true, async:true}, function(code, output) {
+        events.emit('log', output);
         if (code != 0) {
-            callback('Xcode is (probably) not installed, specifically the command `xcodebuild` is unavailable or erroring out. Output of `xcodebuild -version` is: ' + output);
+            callback('Xcode is (probably) not installed, specifically the command `xcodebuild` is unavailable or erroring out. Output of `'+command+'` is: ' + output);
         } else {
             var xc_version = output.split('\n')[0].split(' ')[1];
             if (semver.lt(xc_version, MIN_XCODE_VERSION)) {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/cf9eb156/src/metadata/wp7_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/wp7_parser.js b/src/metadata/wp7_parser.js
index 657d266..f0127e9 100644
--- a/src/metadata/wp7_parser.js
+++ b/src/metadata/wp7_parser.js
@@ -1,4 +1,3 @@
-
 /**
     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file
@@ -21,6 +20,7 @@ var fs            = require('fs'),
     path          = require('path'),
     et            = require('elementtree'),
     util          = require('../util'),
+    events        = require('../events'),
     shell         = require('shelljs'),
     events        = require('../events'),
     config_parser = require('../config_parser');
@@ -40,14 +40,15 @@ module.exports = function wp7_parser(project) {
 };
 
 module.exports.check_requirements = function(callback) {
-    events.emit('log', 'Checking wp7 requirements...');
+    events.emit('log', 'Checking WP7 requirements...');
     var command = '"' + path.join(util.libDirectory, 'cordova-wp7', 'bin', 'check_reqs') + '"';
     events.emit('log', 'Running "' + command + '" (output to follow)');
     shell.exec(command, {silent:true, async:true}, function(code, output) {
+        events.emit('log', output);
         if (code != 0) {
             callback(output);
         } else {
-                callback(false);
+            callback(false);
         }
     });
 };

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/cf9eb156/src/metadata/wp8_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/wp8_parser.js b/src/metadata/wp8_parser.js
index 27e3a5c..ac5613c 100644
--- a/src/metadata/wp8_parser.js
+++ b/src/metadata/wp8_parser.js
@@ -1,4 +1,3 @@
-
 /**
     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file
@@ -21,6 +20,7 @@ var fs            = require('fs'),
     path          = require('path'),
     et            = require('elementtree'),
     util          = require('../util'),
+    events        = require('../events'),
     shell         = require('shelljs'),
     events        = require('../events'),
     config_parser = require('../config_parser');
@@ -40,7 +40,7 @@ module.exports = function wp8_parser(project) {
 };
 
 module.exports.check_requirements = function(callback) {
-    events.emit('log', 'Checking wp8 requirements...');
+    events.emit('log', 'Checking WP8 requirements...');
     var command = '"' + path.join(util.libDirectory, 'cordova-wp8', 'bin', 'check_reqs') + '"';
     events.emit('log', 'Running "' + command + '" (output to follow)');
     shell.exec(command, {silent:true, async:true}, function(code, output) {
@@ -48,7 +48,7 @@ module.exports.check_requirements = function(callback) {
         if (code != 0) {
             callback(output);
         } else {
-                callback(false);
+            callback(false);
         }
     });
 };

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/cf9eb156/src/platform.js
----------------------------------------------------------------------
diff --git a/src/platform.js b/src/platform.js
index 7f9af14..e60aa1f 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -95,9 +95,10 @@ module.exports = function platform(command, targets, callback) {
                         // TODO: PLATFORM LIBRARY INCONSISTENCY: order/number of arguments to create
                         // TODO: keep tabs on CB-2300
                         var command = util.format('"%s" %s "%s" "%s" "%s"', bin, args, output, (target=='blackberry'?name:pkg), name);
-                        events.emit('log', 'Running bin/create for platform "' + target + '" with command: "' + command + '"');
+                        events.emit('log', 'Running bin/create for platform "' + target + '" with command: "' + command + '" (output to follow)');
 
                         shell.exec(command, {silent:true,async:true}, function(code, create_output) {
+                            events.emit('log', create_output);
                             if (code > 0) {
                                 var err = new Error('An error occured during creation of ' + target + ' sub-project. ' + create_output);
                                 if (callback) callback(err);


[05/22] git commit: [CB-2452] added a verbosity flag (-d or --verbose) using event emitters.

Posted by fi...@apache.org.
[CB-2452] added a verbosity flag (-d or --verbose) using event emitters.


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/00d88531
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/00d88531
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/00d88531

Branch: refs/heads/2.8.x
Commit: 00d885319c1fedff594b387aa29fc273fc9ea127
Parents: 5ccaec0
Author: Fil Maj <ma...@gmail.com>
Authored: Tue Jun 4 17:22:10 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 6 18:26:07 2013 -0700

----------------------------------------------------------------------
 bin/cordova                                  |   18 ++++---
 spec/platform-script/android/android.spec.js |    3 +-
 spec/platform-script/ios/ios.spec.js         |    3 +-
 src/compile.js                               |   26 ++++++++--
 src/create.js                                |    5 ++-
 src/emulate.js                               |   43 ++++++++++++----
 src/hooker.js                                |    1 -
 src/metadata/android_parser.js               |   11 ++++-
 src/metadata/blackberry_parser.js            |   55 +++++++++++++--------
 src/metadata/ios_parser.js                   |   34 +++++++++---
 src/platform.js                              |   26 ++++++++--
 src/plugin.js                                |   28 +++++++++--
 src/prepare.js                               |   31 +++++++++---
 13 files changed, 209 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/00d88531/bin/cordova
----------------------------------------------------------------------
diff --git a/bin/cordova b/bin/cordova
index e6ec3e1..941f461 100755
--- a/bin/cordova
+++ b/bin/cordova
@@ -2,12 +2,6 @@
 var tokens = process.argv.slice(2, process.argv.length),
     cordova= require('../cordova');
 
-// provide clean output on exceptions rather than dumping a stack trace
-process.on('uncaughtException', function(err){
-	console.error(err);
-    process.exit(1);
-});
-
 var cmd, version = false, verbose = false, current;
 
 while (current = tokens.shift()) {
@@ -20,6 +14,16 @@ while (current = tokens.shift()) {
     }
 }
 
+// provide clean output on exceptions rather than dumping a stack trace
+process.on('uncaughtException', function(err){
+	console.error(err);
+    process.exit(1);
+});
+if (verbose) {
+    cordova.on('log', console.log);
+    cordova.on('warn', console.warn);
+}
+
 if (version) {
     console.log(require('../package').version);
 } else if (cmd === undefined) {
@@ -41,5 +45,5 @@ if (version) {
     }
     if (r) console.log(r);
 } else {
-    console.error('Cordova does not know ' + cmd + '; try help for a list of all the available commands.')
+    throw new Error('Cordova does not know ' + cmd + '; try help for a list of all the available commands.');
 }

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/00d88531/spec/platform-script/android/android.spec.js
----------------------------------------------------------------------
diff --git a/spec/platform-script/android/android.spec.js b/spec/platform-script/android/android.spec.js
index 8c39af0..2433c0a 100644
--- a/spec/platform-script/android/android.spec.js
+++ b/spec/platform-script/android/android.spec.js
@@ -64,6 +64,7 @@ describe('Test:', function() {
         it('should shell out to run command on Android', function() {
             var proj_spy = spyOn(android_parser.prototype, 'update_project');
             var s = spyOn(require('shelljs'), 'exec');
+            spyOn(require('plugman'), 'prepare');
             cordova.emulate('android');
             proj_spy.mostRecentCall.args[1](); // update_project fake
             expect(s).toHaveBeenCalled();
@@ -95,4 +96,4 @@ describe('Test:', function() {
             expect(s.mostRecentCall.args[0]).toContain(build_cmd);
         });
     });
-});
\ No newline at end of file
+});

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/00d88531/spec/platform-script/ios/ios.spec.js
----------------------------------------------------------------------
diff --git a/spec/platform-script/ios/ios.spec.js b/spec/platform-script/ios/ios.spec.js
index 0fecd75..04ae4bf 100644
--- a/spec/platform-script/ios/ios.spec.js
+++ b/spec/platform-script/ios/ios.spec.js
@@ -65,6 +65,7 @@ describe('Test:', function() {
         it('should shell out to run command on ios', function() {
             var proj_spy = spyOn(ios_parser.prototype, 'update_project');
             var s = spyOn(require('shelljs'), 'exec');
+            spyOn(require('plugman'), 'prepare');
             cordova.emulate('ios');
             proj_spy.mostRecentCall.args[1](); // update_project fake
             expect(s).toHaveBeenCalled();
@@ -96,4 +97,4 @@ describe('Test:', function() {
             expect(s.mostRecentCall.args[0]).toContain(build_cmd);
         });
     });
-});
\ No newline at end of file
+});

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/00d88531/src/compile.js
----------------------------------------------------------------------
diff --git a/src/compile.js b/src/compile.js
index 4cf3b85..58d944e 100644
--- a/src/compile.js
+++ b/src/compile.js
@@ -23,6 +23,7 @@ var cordova_util      = require('./util'),
     shell             = require('shelljs'),
     et                = require('elementtree'),
     hooker            = require('./hooker'),
+    events            = require('./events'),
     n                 = require('ncallbacks');
 
 
@@ -35,21 +36,25 @@ function shell_out_to_debug(projectRoot, platform, callback) {
     } else {
         cmd = '"' + path.join(cmd, 'cordova', 'build') + '"';
     }
+    events.emit('log', 'Compiling platform "' + platform + '" with command "' + cmd + '"');
     shell.exec(cmd, {silent:true, async:true}, function(code, output) {
         if (code > 0) {
             throw new Error('An error occurred while building the ' + platform + ' project. ' + output);
         } else {
+            events.emit('log', 'Platform "' + platform + '" compiled successfully.');
             if (callback) callback();
         }
     });
 }
 
-
 module.exports = function compile(platformList, callback) {
     var projectRoot = cordova_util.isCordova(process.cwd());
 
     if (!projectRoot) {
-        throw new Error('Current working directory is not a Cordova-based project.');
+        var err = new Error('Current working directory is not a Cordova-based project.');
+        if (callback) callback(err);
+        else throw err;
+        return;
     }
 
     var xml = cordova_util.projectConfig(projectRoot);
@@ -63,16 +68,27 @@ module.exports = function compile(platformList, callback) {
         platformList = cordova_util.listPlatforms(projectRoot);
     }
 
-    if (platformList.length === 0) throw new Error('No platforms added to this project. Please use `cordova platform add <platform>`.');
+    if (platformList.length === 0) {
+        var err = new Error('No platforms added to this project. Please use `cordova platform add <platform>`.');
+        if (callback) callback(err);
+        else throw err;
+        return;
+    }
 
     var hooks = new hooker(projectRoot);
     if (!(hooks.fire('before_compile'))) {
-        throw new Error('before_compile hooks exited with non-zero code. Aborting.');
+        var err = new Error('before_compile hooks exited with non-zero code. Aborting.');
+        if (callback) callback(err);
+        else throw err;
+        return;
     }
 
     var end = n(platformList.length, function() {
         if (!(hooks.fire('after_compile'))) {
-            throw new Error('after_compile hooks exited with non-zero code. Aborting.');
+            var err = new Error('after_compile hooks exited with non-zero code. Aborting.');
+            if (callback) callback(err);
+            else throw err;
+            return;
         }
         if (callback) callback();
     });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/00d88531/src/create.js
----------------------------------------------------------------------
diff --git a/src/create.js b/src/create.js
index 84e8b13..5cced50 100644
--- a/src/create.js
+++ b/src/create.js
@@ -1,4 +1,3 @@
-
 /**
     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file
@@ -22,6 +21,7 @@ var path          = require('path'),
     shell         = require('shelljs'),
     help          = require('./help'),
     config_parser = require('./config_parser'),
+    events        = require('./events'),
     util          = require('./util');
 
 var DEFAULT_NAME = "HelloCordova",
@@ -49,6 +49,8 @@ module.exports = function create (dir, id, name) {
     // Make absolute.
     dir = path.resolve(dir);
 
+    events.emit('log', 'Creating a new cordova project with name "' + name + '" and id "' + id + '" at location "' + dir + '"');
+
     var dotCordova = path.join(dir, '.cordova');
 
     // Check for existing cordova project
@@ -95,6 +97,7 @@ module.exports = function create (dir, id, name) {
     }));
 
     // Copy in base template
+    events.emit('log', 'Copying stock application assets into "' + path.join(dir, 'www') + '"');
     shell.cp('-r', path.join(__dirname, '..', 'templates', 'www'), dir);
 
     // Write out id and name to config.xml

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/00d88531/src/emulate.js
----------------------------------------------------------------------
diff --git a/src/emulate.js b/src/emulate.js
index 4e5451a..0787f60 100644
--- a/src/emulate.js
+++ b/src/emulate.js
@@ -22,6 +22,8 @@ var cordova_util      = require('./util'),
     config_parser     = require('./config_parser'),
     platforms         = require('../platforms'),
     platform          = require('./platform'),
+    events            = require('./events'),
+    prepare           = require('./prepare'),
     fs                = require('fs'),
     ls                = fs.readdirSync,
     n                 = require('ncallbacks'),
@@ -34,10 +36,12 @@ function shell_out_to_emulate(root, platform, callback) {
     if (platform == 'blackberry') {
         cmd = 'ant -f "' + path.join(root, 'platforms', platform, 'build.xml') + '" qnx load-simulator';
     }
+    events.emit('log', 'Running on emulator for platform "' + platform + '" via command "' + cmd + '"');
     shell.exec(cmd, {silent:true, async:true}, function(code, output) {
         if (code > 0) {
             throw new Error('An error occurred while emulating/deploying the ' + platform + ' project.' + output);
         } else {
+            events.emit('log', 'Platform "' + platform + '" deployed to emulator.');
             callback();
         }
     });
@@ -47,7 +51,10 @@ module.exports = function emulate (platformList, callback) {
     var projectRoot = cordova_util.isCordova(process.cwd());
 
     if (!projectRoot) {
-        throw new Error('Current working directory is not a Cordova-based project.');
+        var err = new Error('Current working directory is not a Cordova-based project.');
+        if (callback) callback(err);
+        else throw err;
+        return;
     }
 
     var xml = cordova_util.projectConfig(projectRoot);
@@ -61,27 +68,41 @@ module.exports = function emulate (platformList, callback) {
         platformList = cordova_util.listPlatforms(projectRoot);
     }
 
-    if (platformList.length === 0) throw new Error('No platforms added to this project. Please use `cordova platform add <platform>`.');
+    if (platformList.length === 0) {
+        var err = new Error('No platforms added to this project. Please use `cordova platform add <platform>`.');
+        if (callback) callback(err);
+        else throw err;
+        return;
+    }
 
     var hooks = new hooker(projectRoot);
     if (!(hooks.fire('before_emulate'))) {
-        throw new Error('before_emulate hooks exited with non-zero code. Aborting build.');
+        var err = new Error('before_emulate hooks exited with non-zero code. Aborting build.');
+        if (callback) callback(err);
+        else throw err;
+        return;
     }
 
     var end = n(platformList.length, function() {
         if (!(hooks.fire('after_emulate'))) {
-            throw new Error('after_emulate hooks exited with non-zero code. Aborting.');
+            var err = new Error('after_emulate hooks exited with non-zero code. Aborting.');
+            if (callback) callback(err);
+            else throw err;
+            return;
         }
         if (callback) callback();
     });
 
-    // Iterate over each added platform and shell out to debug command
-    platformList.forEach(function(platform) {
-        var platformPath = path.join(projectRoot, 'platforms', platform);
-        var parser = new platforms[platform].parser(platformPath);
-        parser.update_project(cfg, function() {
-            shell_out_to_emulate(projectRoot, platform, end);
-        });
+    // Run a prepare first!
+    prepare(platformList, function(err) {
+        if (err) {
+            if (callback) callback(err);
+            else throw err;
+        } else {
+            platformList.forEach(function(platform) {
+                shell_out_to_emulate(projectRoot, platform, end);
+            });
+        }
     });
 };
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/00d88531/src/hooker.js
----------------------------------------------------------------------
diff --git a/src/hooker.js b/src/hooker.js
index 5a0eb3c..d40b686 100644
--- a/src/hooker.js
+++ b/src/hooker.js
@@ -1,4 +1,3 @@
-
 /**
     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/00d88531/src/metadata/android_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/android_parser.js b/src/metadata/android_parser.js
index a81de9d..63582a4 100644
--- a/src/metadata/android_parser.js
+++ b/src/metadata/android_parser.js
@@ -20,6 +20,7 @@ var fs            = require('fs'),
     path          = require('path'),
     et            = require('elementtree'),
     util          = require('../util'),
+    events        = require('../events'),
     shell         = require('shelljs'),
     config_parser = require('../config_parser');
 
@@ -69,6 +70,7 @@ module.exports.prototype = {
         var strings = new et.ElementTree(et.XML(fs.readFileSync(this.strings, 'utf-8')));
         strings.find('string[@name="app_name"]').text = name;
         fs.writeFileSync(this.strings, strings.write({indent: 4}), 'utf-8');
+        events.emit('log', 'Wrote out Android application name to "' + name + '"');
 
         // Update package name by changing the AndroidManifest id and moving the entry class around to the proper package directory
         var manifest = new et.ElementTree(et.XML(fs.readFileSync(this.manifest, 'utf-8')));
@@ -85,6 +87,7 @@ module.exports.prototype = {
         var new_javs = path.join(pkgDir, orig_java_class);
         var javs_contents = fs.readFileSync(orig_javs, 'utf-8');
         javs_contents = javs_contents.replace(/package [\w\.]*;/, 'package ' + pkg + ';');
+        events.emit('log', 'Wrote out Android package name to "' + pkg + '"');
         fs.writeFileSync(new_javs, javs_contents, 'utf-8');
 
         // Update whitelist by changing res/xml/config.xml
@@ -171,7 +174,13 @@ module.exports.prototype = {
 
     update_project:function(cfg, callback) {
         var platformWww = path.join(this.path, 'assets');
-        this.update_from_config(cfg);
+        try {
+            this.update_from_config(cfg);
+        } catch(e) {
+            if (callback) callback(e);
+            else throw e;
+            return;
+        }
         this.update_www();
         this.update_overrides();
         this.update_staging();

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/00d88531/src/metadata/blackberry_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/blackberry_parser.js b/src/metadata/blackberry_parser.js
index 7ad69ba..e3c6f87 100644
--- a/src/metadata/blackberry_parser.js
+++ b/src/metadata/blackberry_parser.js
@@ -22,6 +22,7 @@ var fs            = require('fs'),
     prompt        = require('prompt'),
     shell         = require('shelljs'),
     util          = require('../util'),
+    events        = require('../events'),
     config_parser = require('../config_parser');
 
 module.exports = function blackberry_parser(project) {
@@ -44,7 +45,9 @@ module.exports.prototype = {
         } else throw new Error('update_from_config requires a config_parser object');
 
         this.xml.name(config.name());
+        events.emit('log', 'Wrote out BlackBerry application name to "' + config.name() + '"');
         this.xml.packageName(config.packageName());
+        events.emit('log', 'Wrote out BlackBerry package name to "' + config.packageName() + '"');
         this.xml.access.remove();
         var self = this;
         this.xml.doc.findall('access').forEach(function(a) {
@@ -61,7 +64,13 @@ module.exports.prototype = {
     update_project:function(cfg, callback) {
         var self = this;
 
-        self.update_from_config(cfg);
+        try {
+            self.update_from_config(cfg);
+        } catch(e) {
+            if (callback) callback(e);
+            else throw e;
+            return;
+        }
         self.update_www();
         self.update_overrides();
         self.update_staging();
@@ -72,17 +81,18 @@ module.exports.prototype = {
         var dotFile = path.join(projectRoot, '.cordova', 'config.json');
         var dot = JSON.parse(fs.readFileSync(dotFile, 'utf-8'));
         if (dot.blackberry === undefined || dot.blackberry.qnx === undefined) {
+            events.emit('warn', 'WARNING! Missing BlackBerry configuration file.');
             this.get_blackberry_environment(function() {
                 // Update project.properties
                 self.write_project_properties();
 
                 if (callback) callback();
             });
-            return;
+        } else {
+            // Write out config stuff to project.properties file
+            this.write_project_properties();
+            if (callback) callback();
         }
-        // Write out config stuff to project.properties file
-        this.write_project_properties();
-        if (callback) callback();
     },
 
     // Returns the platform-specific www directory.
@@ -144,7 +154,6 @@ module.exports.prototype = {
     },
 
     write_project_properties:function() {
-        // TODO: eventually support all blackberry sub-platforms
         var projectRoot = util.isCordova(this.path);
 
         var projFile = path.join(this.path, 'project.properties');
@@ -160,14 +169,14 @@ module.exports.prototype = {
         props = props.replace(/qnx\.sim\.ip=.*\n/, 'qnx.sim.ip=' + dot.blackberry.qnx.sim_ip + '\n');
         props = props.replace(/qnx\.sim\.password=.*\n/, 'qnx.sim.password=' + dot.blackberry.qnx.sim_password + '\n');
         fs.writeFileSync(projFile, props, 'utf-8');
+        events.emit('log', 'Wrote out BlackBerry 10 configuration file to "' + projFile + '"');
     },
     get_blackberry_environment:function(callback) {
-        // TODO: add other blackberry sub-platforms
         var projectRoot = util.isCordova(this.path);
         var dotFile = path.join(projectRoot, '.cordova', 'config.json');
         var dot = JSON.parse(fs.readFileSync(dotFile, 'utf-8'));
         // Let's save relevant BB SDK + signing info to .cordova/config.json
-        console.log('Looks like we need some of your BlackBerry development environment information. We\'ll just ask you a few questions and we\'ll be on our way to building.');
+        events.emit('log', 'Prompting for BlackBerry 10 configuration information...');
         prompt.start();
         prompt.get([{
             name:'bbwp',
@@ -192,19 +201,23 @@ module.exports.prototype = {
             description:'Enter the password for your BB10 simulator'
         }
         ], function(err, results) {
-            if (err) throw new Error('Error during BlackBerry environment config retrieval');
-            // Write out .cordova/config.json file
-            if (dot.blackberry === undefined) dot.blackberry = {};
-            if (dot.blackberry.qnx === undefined) dot.blackberry.qnx = {};
-            dot.blackberry.qnx.bbwp = results.bbwp;
-            dot.blackberry.qnx.signing_password = results.signing_password;
-            dot.blackberry.qnx.device_ip = results.device_ip;
-            dot.blackberry.qnx.device_password = results.device_password;
-            dot.blackberry.qnx.sim_ip = results.sim_ip;
-            dot.blackberry.qnx.sim_password = results.sim_password;
-            fs.writeFileSync(dotFile, JSON.stringify(dot), 'utf-8');
-            console.log('Perfect! If you need to change any of these properties, just edit the .cordova/config.json file in the root of your cordova project.');
-            if (callback) callback();
+            if (err) {
+                if (callback) callback(err);
+                else throw err;
+            } else {
+                // Write out .cordova/config.json file
+                if (dot.blackberry === undefined) dot.blackberry = {};
+                if (dot.blackberry.qnx === undefined) dot.blackberry.qnx = {};
+                dot.blackberry.qnx.bbwp = results.bbwp;
+                dot.blackberry.qnx.signing_password = results.signing_password;
+                dot.blackberry.qnx.device_ip = results.device_ip;
+                dot.blackberry.qnx.device_password = results.device_password;
+                dot.blackberry.qnx.sim_ip = results.sim_ip;
+                dot.blackberry.qnx.sim_password = results.sim_password;
+                fs.writeFileSync(dotFile, JSON.stringify(dot), 'utf-8');
+                events.emit('log', 'Wrote out BlackBerry 10 configuration file to "' + dotFile + '"');
+                if (callback) callback();
+            }
         });
     }
 };

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/00d88531/src/metadata/ios_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/ios_parser.js b/src/metadata/ios_parser.js
index 4f15a59..b7e2d69 100644
--- a/src/metadata/ios_parser.js
+++ b/src/metadata/ios_parser.js
@@ -20,6 +20,7 @@ var fs            = require('fs'),
     path          = require('path'),
     xcode         = require('xcode'),
     util          = require('../util'),
+    events        = require('../events'),
     shell         = require('shelljs'),
     plist         = require('plist'),
     semver        = require('semver'),
@@ -76,7 +77,12 @@ module.exports.check_requirements = function(callback) {
 module.exports.prototype = {
     update_from_config:function(config, callback) {
         if (config instanceof config_parser) {
-        } else throw new Error('update_from_config requires a config_parser object');
+        } else {
+            var err = new Error('update_from_config requires a config_parser object');
+            if (callback) callback(err);
+            else throw err;
+            return;
+        }
         var name = config.name();
         var pkg = config.packageName();
 
@@ -87,6 +93,7 @@ module.exports.prototype = {
         var info_contents = plist.build(infoPlist);
         info_contents = info_contents.replace(/<string>[\s\r\n]*<\/string>/g,'<string></string>');
         fs.writeFileSync(plistFile, info_contents, 'utf-8');
+        events.emit('log', 'Wrote out iOS Bundle Identifier to "' + pkg + '"');
 
         // Update whitelist
         var self = this;
@@ -124,10 +131,14 @@ module.exports.prototype = {
         var proj = new xcode.project(this.pbxproj);
         var parser = this;
         proj.parse(function(err,hash) {
-            if (err) throw new Error('An error occured during parsing of project.pbxproj. Start weeping.');
-            else {
+            if (err) {
+                var err = new Error('An error occured during parsing of project.pbxproj. Start weeping. Output: ' + err);
+                if (callback) callback(err);
+                else throw err;
+            } else {
                 proj.updateProductName(name);
                 fs.writeFileSync(parser.pbxproj, proj.writeSync(), 'utf-8');
+                events.emit('log', 'Wrote out iOS Product Name to "' + name + '"');
                 if (callback) callback();
             }
         });
@@ -183,12 +194,17 @@ module.exports.prototype = {
 
     update_project:function(cfg, callback) {
         var self = this;
-        this.update_from_config(cfg, function() {
-            self.update_www();
-            self.update_overrides();
-            self.update_staging();
-            util.deleteSvnFolders(self.www_dir());
-            if (callback) callback();
+        this.update_from_config(cfg, function(err) {
+            if (err) {
+                if (callback) callback(err);
+                else throw err;
+            } else {
+                self.update_www();
+                self.update_overrides();
+                self.update_staging();
+                util.deleteSvnFolders(self.www_dir());
+                if (callback) callback();
+            }
         });
     }
 };

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/00d88531/src/platform.js
----------------------------------------------------------------------
diff --git a/src/platform.js b/src/platform.js
index 38032bc..7f9af14 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -22,6 +22,7 @@ var config_parser     = require('./config_parser'),
     fs                = require('fs'),
     path              = require('path'),
     hooker            = require('./hooker'),
+    events            = require('./events'),
     n                 = require('ncallbacks'),
     platforms         = require('../platforms'),
     plugman           = require('plugman'),
@@ -31,7 +32,10 @@ module.exports = function platform(command, targets, callback) {
     var projectRoot = cordova_util.isCordova(process.cwd());
 
     if (!projectRoot) {
-        throw new Error('Current working directory is not a Cordova-based project.');
+        var err = new Error('Current working directory is not a Cordova-based project.');
+        if (callback) callback(err);
+        else throw err;
+        return;
     }
 
     var hooks = new hooker(projectRoot),
@@ -67,16 +71,22 @@ module.exports = function platform(command, targets, callback) {
 
                 // Check if output directory already exists.
                 if (fs.existsSync(output)) {
-                    throw new Error('Platform "' + target + '" already exists' );
+                    var err = new Error('Platform "' + target + '" already exists' );
+                    if (callback) callback(err);
+                    else throw err;
+                    return;
                 }
 
                 // Make sure we have minimum requirements to work with specified platform
+                events.emit('log', 'Checking if platform "' + target + '" passes minimum requirements.');
                 module.exports.supports(target, function(err) {
                     if (err) {
-                        throw new Error('Your system does not meet the requirements to create ' + target + ' projects: ' + err.message);
+                        var err = new Error('Your system does not meet the requirements to create ' + target + ' projects: ' + err.message);
+                        if (callback) callback(err);
+                        else throw err;
+                        return;
                     } else {
                         // Create a platform app using the ./bin/create scripts that exist in each repo.
-                        // TODO: eventually refactor to allow multiple versions to be created.
                         // Run platform's create script
                         var bin = path.join(cordova_util.libDirectory, 'cordova-' + target, 'bin', 'create');
                         var args = (target=='ios') ? '--arc' : '';
@@ -85,13 +95,18 @@ module.exports = function platform(command, targets, callback) {
                         // TODO: PLATFORM LIBRARY INCONSISTENCY: order/number of arguments to create
                         // TODO: keep tabs on CB-2300
                         var command = util.format('"%s" %s "%s" "%s" "%s"', bin, args, output, (target=='blackberry'?name:pkg), name);
+                        events.emit('log', 'Running bin/create for platform "' + target + '" with command: "' + command + '"');
 
                         shell.exec(command, {silent:true,async:true}, function(code, create_output) {
                             if (code > 0) {
-                                throw new Error('An error occured during creation of ' + target + ' sub-project. ' + create_output);
+                                var err = new Error('An error occured during creation of ' + target + ' sub-project. ' + create_output);
+                                if (callback) callback(err);
+                                else throw err;
+                                return;
                             }
 
                             var parser = new platforms[target].parser(output);
+                            events.emit('log', 'Updating ' + target + ' project from config.xml...');
                             parser.update_project(cfg, function() {
                                 createOverrides(target);
                                 hooks.fire('after_platform_add');
@@ -104,6 +119,7 @@ module.exports = function platform(command, targets, callback) {
                                         return;
                                     }
 
+                                    events.emit('log', 'Installing plugin "' + plugin + '" following success platform add of ' + target);
                                     plugman.install(target, output, path.basename(plugin), pluginsDir, { www_dir: parser.staging_dir() });
                                 });
                                 end();

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/00d88531/src/plugin.js
----------------------------------------------------------------------
diff --git a/src/plugin.js b/src/plugin.js
index 6045840..0851305 100644
--- a/src/plugin.js
+++ b/src/plugin.js
@@ -25,6 +25,7 @@ var cordova_util  = require('./util'),
     platforms     = require('../platforms'),
     config_parser = require('./config_parser'),
     hooker        = require('./hooker'),
+    events        = require('./events'),
     plugin_parser = require('./plugin_parser'),
     ls            = fs.readdirSync,
     plugman       = require('plugman');
@@ -33,7 +34,10 @@ module.exports = function plugin(command, targets, callback) {
     var projectRoot = cordova_util.isCordova(process.cwd());
 
     if (!projectRoot) {
-        throw new Error('Current working directory is not a Cordova-based project.');
+        var err = new Error('Current working directory is not a Cordova-based project.');
+        if (callback) callback(err);
+        else throw err;
+        return;
     }
     if (arguments.length === 0) command = 'ls';
 
@@ -72,9 +76,13 @@ module.exports = function plugin(command, targets, callback) {
                 }
 
                 // Fetch the plugin first.
+                events.emit('log', 'Calling plugman.fetch on plugin "' + target + '"');
                 plugman.fetch(target, pluginsDir, {}, function(err, dir) {
                     if (err) {
-                        throw new Error('Error fetching plugin: ' + err);
+                        var err = new Error('Error fetching plugin: ' + err);
+                        if (callback) callback(err);
+                        else throw err;
+                        return;
                     }
 
                     // Iterate over all platforms in the project and install the plugin.
@@ -82,6 +90,7 @@ module.exports = function plugin(command, targets, callback) {
                         var platformRoot = path.join(projectRoot, 'platforms', platform);
                         var parser = new platforms[platform].parser(platformRoot);
                         // TODO: unify use of blackberry in cli vs blackberry10 in plugman
+                        events.emit('log', 'Calling plugman.install on plugin "' + dir + '" for platform "' + platform + '"');
                         plugman.install((platform=='blackberry'?'blackberry10':platform), platformRoot,
                                         path.basename(dir), pluginsDir, { www_dir: parser.staging_dir() });
                     });
@@ -94,7 +103,10 @@ module.exports = function plugin(command, targets, callback) {
         case 'rm':
         case 'remove':
             if (platformList.length === 0) {
-                throw new Error('You need at least one platform added to your app. Use `cordova platform add <platform>`.');
+                var err = new Error('You need at least one platform added to your app. Use `cordova platform add <platform>`.');
+                if (callback) callback(err);
+                else throw err;
+                return;
             }
             targets.forEach(function(target, index) {
                 // Check if we have the plugin.
@@ -116,17 +128,23 @@ module.exports = function plugin(command, targets, callback) {
                     intersection.forEach(function(platform) {
                         var platformRoot = path.join(projectRoot, 'platforms', platform);
                         var parser = new platforms[platform].parser(platformRoot);
+                        events.emit('log', 'Calling plugman.uninstall on plugin "' + target + '" for platform "' + platform + '"');
                         plugman.uninstall(platform, platformRoot, target, path.join(projectRoot, 'plugins'), { www_dir: parser.staging_dir() });
                     });
 
                     hooks.fire('after_plugin_rm');
                 } else {
-                    throw new Error('Plugin "' + target + '" not added to project.');
+                    var err = new Error('Plugin "' + target + '" not added to project.');
+                    if (callback) callback(err);
+                    else throw err;
+                    return;
                 }
             });
             if (callback) callback();
             break;
         default:
-            throw new Error('Unrecognized command "' + command + '". Use either `add`, `remove`, or `list`.');
+            var err = new Error('Unrecognized command "' + command + '". Use either `add`, `remove`, or `list`.');
+            if (callback) callback(err);
+            else throw err;
     }
 };

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/00d88531/src/prepare.js
----------------------------------------------------------------------
diff --git a/src/prepare.js b/src/prepare.js
index b08827e..9911000 100644
--- a/src/prepare.js
+++ b/src/prepare.js
@@ -25,6 +25,7 @@ var cordova_util      = require('./util'),
     shell             = require('shelljs'),
     et                = require('elementtree'),
     hooker            = require('./hooker'),
+    events            = require('./events'),
     n                 = require('ncallbacks'),
     prompt            = require('prompt'),
     plugman           = require('plugman'),
@@ -34,7 +35,10 @@ module.exports = function prepare(platformList, callback) {
     var projectRoot = cordova_util.isCordova(process.cwd());
 
     if (!projectRoot) {
-        throw new Error('Current working directory is not a Cordova-based project.');
+        var err = new Error('Current working directory is not a Cordova-based project.');
+        if (callback) callback(err);
+        else throw err;
+        return;
     }
 
     var xml = cordova_util.projectConfig(projectRoot);
@@ -48,16 +52,27 @@ module.exports = function prepare(platformList, callback) {
         platformList = cordova_util.listPlatforms(projectRoot);
     }
 
-    if (platformList.length === 0) throw new Error('No platforms added to this project. Please use `cordova platform add <platform>`.');
+    if (platformList.length === 0) {
+        var err = new Error('No platforms added to this project. Please use `cordova platform add <platform>`.');
+        if (callback) callback(err);
+        else throw err;
+        return;
+    }
 
     var hooks = new hooker(projectRoot);
     if (!(hooks.fire('before_prepare'))) {
-        throw new Error('before_prepare hooks exited with non-zero code. Aborting.');
+        var err = new Error('before_prepare hooks exited with non-zero code. Aborting.');
+        if (callback) callback(err);
+        else throw err;
+        return;
     }
 
     var end = n(platformList.length, function() {
         if (!(hooks.fire('after_prepare'))) {
-            throw new Error('after_prepare hooks exited with non-zero code. Aborting.');
+            var err = new Error('after_prepare hooks exited with non-zero code. Aborting.');
+            if (callback) callback(err);
+            else throw err;
+            return;
         }
         if (callback) callback();
     });
@@ -66,22 +81,24 @@ module.exports = function prepare(platformList, callback) {
     platformList.forEach(function(platform) {
         var platformPath = path.join(projectRoot, 'platforms', platform);
         var parser = new platforms[platform].parser(platformPath);
-
         parser.update_project(cfg, function() {
             // Call plugman --prepare for this platform. sets up js-modules appropriately.
             var plugins_dir = path.join(projectRoot, 'plugins');
+            events.emit('log', 'Calling plugman.prepare for platform "' + platform + '"');
             plugman.prepare(platformPath, platform, plugins_dir);
 
             // Make sure that config changes for each existing plugin is in place
             var plugins = cordova_util.findPlugins(plugins_dir);
             var platform_json = plugman.config_changes.get_platform_json(plugins_dir, platform);
-            plugins.forEach(function(plugin_id) {
+            plugins && plugins.forEach(function(plugin_id) {
                 if (platform_json.installed_plugins[plugin_id]) {
-                    console.log('readding ' + plugin_id);
+                    events.emit('log', 'Ensuring plugin "' + plugin_id + '" is installed correctly...');
                     plugman.config_changes.add_plugin_changes(platform, platformPath, plugins_dir, plugin_id, /* variables for plugin */ platform_json.installed_plugins[plugin_id], /* top level plugin? */ true, /* should increment config munge? cordova-cli never should, only plugman */ false);
                 } else if (platform_json.dependent_plugins[plugin_id]) {
+                    events.emit('log', 'Ensuring plugin "' + plugin_id + '" is installed correctly...');
                     plugman.config_changes.add_plugin_changes(platform, platformPath, plugins_dir, plugin_id, /* variables for plugin */ platform_json.dependent_plugins[plugin_id], /* top level plugin? */ false, /* should increment config munge? cordova-cli never should, only plugman */ false);
                 }
+                events.emit('log', 'Plugin "' + plugin_id + '" is good to go.');
             });
             end();
         });


[12/22] git commit: 2.8.7. updated emulate + run commands to use proper flags and whatnot.

Posted by fi...@apache.org.
2.8.7. updated emulate + run commands to use proper flags and whatnot.


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/2300651e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/2300651e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/2300651e

Branch: refs/heads/2.8.x
Commit: 2300651eb1ec9a1ad50096e966e6a224e8e6ae9c
Parents: 5fcbb51
Author: Fil Maj <ma...@gmail.com>
Authored: Wed Jun 5 12:36:02 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 6 18:29:16 2013 -0700

----------------------------------------------------------------------
 package.json                     |    2 +-
 spec/cordova-cli/emulate.spec.js |    2 +-
 spec/cordova-cli/run.spec.js     |    2 +-
 src/emulate.js                   |    2 +-
 src/run.js                       |    2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2300651e/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 38ac8a3..2ab9de2 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "cordova",
-  "version": "2.8.6",
+  "version": "2.8.7",
   "preferGlobal": "true",
   "description": "Cordova command line interface tool",
   "main": "cordova",

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2300651e/spec/cordova-cli/emulate.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova-cli/emulate.spec.js b/spec/cordova-cli/emulate.spec.js
index 64464cb..8df6ce3 100644
--- a/spec/cordova-cli/emulate.spec.js
+++ b/spec/cordova-cli/emulate.spec.js
@@ -72,7 +72,7 @@ describe('emulate command', function() {
                 cordova.emulate();
                 a_spy.mostRecentCall.args[1](); // fake out android parser
                 expect(s).toHaveBeenCalled();
-                expect(s.mostRecentCall.args[0]).toMatch(/cordova.emulate"$/gi);
+                expect(s.mostRecentCall.args[0]).toMatch(/cordova.run" --emulator$/gi);
             }).not.toThrow();
         });
     });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2300651e/spec/cordova-cli/run.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova-cli/run.spec.js b/spec/cordova-cli/run.spec.js
index fb4da30..6904c73 100644
--- a/spec/cordova-cli/run.spec.js
+++ b/spec/cordova-cli/run.spec.js
@@ -79,7 +79,7 @@ describe('run command', function() {
                 cb(0, 'yep');
             });
             cordova.run('android', function() {
-                 expect(spy.mostRecentCall.args[0]).toMatch(/cordova.run"$/gi);
+                 expect(spy.mostRecentCall.args[0]).toMatch(/cordova.run" --device$/gi);
                  done();
             });
         });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2300651e/src/emulate.js
----------------------------------------------------------------------
diff --git a/src/emulate.js b/src/emulate.js
index 9dd8857..ba2883b 100644
--- a/src/emulate.js
+++ b/src/emulate.js
@@ -31,7 +31,7 @@ var cordova_util      = require('./util'),
     util              = require('util');
 
 function shell_out_to_emulate(root, platform, callback) {
-    var cmd = '"' + path.join(root, 'platforms', platform, 'cordova', 'emulate') + '"';
+    var cmd = '"' + path.join(root, 'platforms', platform, 'cordova', 'run') + '" --emulator';
     events.emit('log', 'Running on emulator for platform "' + platform + '" via command "' + cmd + '" (output to follow)...');
     shell.exec(cmd, {silent:true, async:true}, function(code, output) {
         events.emit('log', output);

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/2300651e/src/run.js
----------------------------------------------------------------------
diff --git a/src/run.js b/src/run.js
index c13e4ab..5777599 100644
--- a/src/run.js
+++ b/src/run.js
@@ -27,7 +27,7 @@ var cordova_util      = require('./util'),
     n                 = require('ncallbacks');
 
 function shell_out_to_run(projectRoot, platform, callback) {
-    var cmd = '"' + path.join(projectRoot, 'platforms', platform, 'cordova', 'run') + '"';
+    var cmd = '"' + path.join(projectRoot, 'platforms', platform, 'cordova', 'run') + '" --device';
 
     events.emit('log', 'Running app on platform "' + platform + '" with command "' + cmd + '" (output to follow)...');
     shell.exec(cmd, {silent:true, async:true}, function(code, output) {


[09/22] git commit: Added a few prepare specs regarding plugman integration.

Posted by fi...@apache.org.
Added a few prepare specs regarding plugman integration.


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/1a40e10f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/1a40e10f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/1a40e10f

Branch: refs/heads/2.8.x
Commit: 1a40e10ff31ab7c3b5366c3d63a061299a0475b4
Parents: bb9e823
Author: Fil Maj <ma...@gmail.com>
Authored: Wed Jun 5 10:39:56 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 6 18:28:59 2013 -0700

----------------------------------------------------------------------
 spec/cordova-cli/prepare.spec.js |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/1a40e10f/spec/cordova-cli/prepare.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova-cli/prepare.spec.js b/spec/cordova-cli/prepare.spec.js
index da77935..b420024 100644
--- a/spec/cordova-cli/prepare.spec.js
+++ b/spec/cordova-cli/prepare.spec.js
@@ -19,11 +19,13 @@
 var cordova = require('../../cordova'),
     et = require('elementtree'),
     shell = require('shelljs'),
+    plugman = require('plugman'),
     path = require('path'),
     fs = require('fs'),
     config_parser = require('../../src/config_parser'),
     hooker = require('../../src/hooker'),
     fixtures = path.join(__dirname, '..', 'fixtures'),
+    test_plugin = path.join(fixtures, 'plugins', 'android'),
     hooks = path.join(fixtures, 'hooks'),
     tempDir = path.join(__dirname, '..', '..', 'temp'),
     cordova_project = path.join(fixtures, 'projects', 'cordova');
@@ -76,6 +78,37 @@ describe('prepare command', function() {
         }).toThrow();
     });
 
+    describe('plugman integration', function() {
+        beforeEach(function() {
+            shell.cp('-Rf', path.join(cordova_project, 'platforms', 'android'), path.join(tempDir, 'platforms'));
+            process.chdir(tempDir);
+        });
+        afterEach(function() {
+            process.chdir(cwd);
+        });
+
+        it('should invoke plugman.prepare after update_project', function() {
+            var a_parser_spy = spyOn(android_parser.prototype, 'update_project');
+            var prep_spy = spyOn(plugman, 'prepare');
+            cordova.prepare();
+            a_parser_spy.mostRecentCall.args[1](); // fake out android_parser
+            var android_path = path.join(tempDir, 'platforms', 'android');
+            var plugins_dir = path.join(tempDir, 'plugins');
+            expect(prep_spy).toHaveBeenCalledWith(android_path, 'android', plugins_dir);
+        });
+        it('should invoke add_plugin_changes for any added plugins to verify configuration changes for plugins are in place', function() {
+            var platform_path  = path.join(tempDir, 'platforms', 'android');
+            var plugins_dir = path.join(tempDir, 'plugins');
+            plugman.install('android', platform_path, test_plugin, plugins_dir, {});
+            var a_parser_spy = spyOn(android_parser.prototype, 'update_project');
+            var prep_spy = spyOn(plugman, 'prepare');
+            var plugin_changes_spy = spyOn(plugman.config_changes, 'add_plugin_changes');
+            cordova.prepare();
+            a_parser_spy.mostRecentCall.args[1](); // fake out android_parser
+            expect(plugin_changes_spy).toHaveBeenCalledWith('android', platform_path, plugins_dir, 'ca.filmaj.AndroidPlugin', {PACKAGE_NAME:"org.apache.cordova.cordovaExample"}, true, false); 
+        });
+    });
+
     describe('hooks', function() {
         var s;
         beforeEach(function() {


[22/22] git commit: npm version 2.8.12. Updated cordova-ios library to 2.8.0 tag.

Posted by fi...@apache.org.
npm version 2.8.12. Updated cordova-ios library to 2.8.0 tag.


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/a2f15865
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/a2f15865
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/a2f15865

Branch: refs/heads/2.8.x
Commit: a2f158653f533ebbb5dfbfe136bfdf9e1a57f01c
Parents: bb7c377
Author: Fil Maj <ma...@gmail.com>
Authored: Thu Jun 6 18:09:44 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 6 18:30:33 2013 -0700

----------------------------------------------------------------------
 lib/cordova-ios/CordovaLib/VERSION    |    2 +-
 lib/cordova-ios/CordovaLib/cordova.js |   17 ++++++++---------
 package.json                          |    2 +-
 3 files changed, 10 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/a2f15865/lib/cordova-ios/CordovaLib/VERSION
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/VERSION b/lib/cordova-ios/CordovaLib/VERSION
index 1277c83..834f262 100644
--- a/lib/cordova-ios/CordovaLib/VERSION
+++ b/lib/cordova-ios/CordovaLib/VERSION
@@ -1 +1 @@
-2.8.0rc1
+2.8.0

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/a2f15865/lib/cordova-ios/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/lib/cordova-ios/CordovaLib/cordova.js b/lib/cordova-ios/CordovaLib/cordova.js
index f48d6f9..0dc412a 100644
--- a/lib/cordova-ios/CordovaLib/cordova.js
+++ b/lib/cordova-ios/CordovaLib/cordova.js
@@ -1,5 +1,5 @@
 // Platform: ios
-// 2.8.0rc1-0-g22bc4d8
+// 2.8.0-0-g6208c95
 /*
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
@@ -19,7 +19,7 @@
  under the License.
 */
 ;(function() {
-var CORDOVA_JS_BUILD_LABEL = '2.8.0rc1-0-g22bc4d8';
+var CORDOVA_JS_BUILD_LABEL = '2.8.0-0-g6208c95';
 // file: lib/scripts/require.js
 
 var require,
@@ -2383,11 +2383,7 @@ function initRead(reader, file) {
     reader._error = null;
     reader._readyState = FileReader.LOADING;
 
-    if (typeof file == 'string') {
-        // Deprecated in Cordova 2.4.
-        console.warn('Using a string argument with FileReader.readAs functions is deprecated.');
-        reader._fileName = file;
-    } else if (typeof file.fullPath == 'string') {
+    if (typeof file.fullPath == 'string') {
         reader._fileName = file.fullPath;
     } else {
         reader._fileName = '';
@@ -4502,7 +4498,6 @@ function Device() {
     this.available = false;
     this.platform = null;
     this.version = null;
-    this.name = null;
     this.uuid = null;
     this.cordova = null;
     this.model = null;
@@ -4518,7 +4513,6 @@ function Device() {
             me.available = true;
             me.platform = info.platform;
             me.version = info.version;
-            me.name = info.name;
             me.uuid = info.uuid;
             me.cordova = buildLabel;
             me.model = info.model;
@@ -6259,6 +6253,11 @@ window.cordova = require('cordova');
 // file: lib/scripts/bootstrap.js
 
 (function (context) {
+    if (context._cordovaJsLoaded) {
+        throw new Error('cordova.js included multiple times.');
+    }
+    context._cordovaJsLoaded = true;
+
     var channel = require('cordova/channel');
     var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady];
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/a2f15865/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index fde2ff7..f7f781e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "cordova",
-  "version": "2.8.11",
+  "version": "2.8.12",
   "preferGlobal": "true",
   "description": "Cordova command line interface tool",
   "main": "cordova",


[13/22] git commit: run and emulate commands now call into the ./cordova/run command with --debug flag always, and either --device or --emulator flags depending on cli command invoked.

Posted by fi...@apache.org.
run and emulate commands now call into the ./cordova/run command with --debug flag always, and either --device or --emulator flags depending on cli command invoked.


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/ca42474a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/ca42474a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/ca42474a

Branch: refs/heads/2.8.x
Commit: ca42474a7ff3a320bf576a330927dddaaeb28050
Parents: 2300651
Author: Fil Maj <ma...@gmail.com>
Authored: Wed Jun 5 13:50:37 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 6 18:29:20 2013 -0700

----------------------------------------------------------------------
 spec/cordova-cli/emulate.spec.js |    2 +-
 spec/cordova-cli/run.spec.js     |    2 +-
 src/emulate.js                   |    2 +-
 src/run.js                       |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/ca42474a/spec/cordova-cli/emulate.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova-cli/emulate.spec.js b/spec/cordova-cli/emulate.spec.js
index 8df6ce3..93eaa90 100644
--- a/spec/cordova-cli/emulate.spec.js
+++ b/spec/cordova-cli/emulate.spec.js
@@ -72,7 +72,7 @@ describe('emulate command', function() {
                 cordova.emulate();
                 a_spy.mostRecentCall.args[1](); // fake out android parser
                 expect(s).toHaveBeenCalled();
-                expect(s.mostRecentCall.args[0]).toMatch(/cordova.run" --emulator$/gi);
+                expect(s.mostRecentCall.args[0]).toMatch(/cordova.run" --debug --emulator$/gi);
             }).not.toThrow();
         });
     });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/ca42474a/spec/cordova-cli/run.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova-cli/run.spec.js b/spec/cordova-cli/run.spec.js
index 6904c73..359a723 100644
--- a/spec/cordova-cli/run.spec.js
+++ b/spec/cordova-cli/run.spec.js
@@ -79,7 +79,7 @@ describe('run command', function() {
                 cb(0, 'yep');
             });
             cordova.run('android', function() {
-                 expect(spy.mostRecentCall.args[0]).toMatch(/cordova.run" --device$/gi);
+                 expect(spy.mostRecentCall.args[0]).toMatch(/cordova.run" --debug --device$/gi);
                  done();
             });
         });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/ca42474a/src/emulate.js
----------------------------------------------------------------------
diff --git a/src/emulate.js b/src/emulate.js
index ba2883b..a6460c9 100644
--- a/src/emulate.js
+++ b/src/emulate.js
@@ -31,7 +31,7 @@ var cordova_util      = require('./util'),
     util              = require('util');
 
 function shell_out_to_emulate(root, platform, callback) {
-    var cmd = '"' + path.join(root, 'platforms', platform, 'cordova', 'run') + '" --emulator';
+    var cmd = '"' + path.join(root, 'platforms', platform, 'cordova', 'run') + '" --debug --emulator';
     events.emit('log', 'Running on emulator for platform "' + platform + '" via command "' + cmd + '" (output to follow)...');
     shell.exec(cmd, {silent:true, async:true}, function(code, output) {
         events.emit('log', output);

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/ca42474a/src/run.js
----------------------------------------------------------------------
diff --git a/src/run.js b/src/run.js
index 5777599..63af0a3 100644
--- a/src/run.js
+++ b/src/run.js
@@ -27,7 +27,7 @@ var cordova_util      = require('./util'),
     n                 = require('ncallbacks');
 
 function shell_out_to_run(projectRoot, platform, callback) {
-    var cmd = '"' + path.join(projectRoot, 'platforms', platform, 'cordova', 'run') + '" --device';
+    var cmd = '"' + path.join(projectRoot, 'platforms', platform, 'cordova', 'run') + '" --debug --device';
 
     events.emit('log', 'Running app on platform "' + platform + '" with command "' + cmd + '" (output to follow)...');
     shell.exec(cmd, {silent:true, async:true}, function(code, output) {


[21/22] git commit: npm version 2.8.11. [CB-3460] Serializing event hooks now fixed.

Posted by fi...@apache.org.
npm version 2.8.11. [CB-3460] Serializing event hooks now fixed.


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/bb7c377b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/bb7c377b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/bb7c377b

Branch: refs/heads/2.8.x
Commit: bb7c377be3244463c42480217d38a334c8b87b13
Parents: 6d81b4d
Author: Fil Maj <ma...@gmail.com>
Authored: Thu Jun 6 18:02:59 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 6 18:30:28 2013 -0700

----------------------------------------------------------------------
 bin/cordova                       |    9 +-
 cordova.js                        |    3 +
 package.json                      |    2 +-
 spec/cordova-cli/compile.spec.js  |   44 ++++----
 spec/cordova-cli/emulate.spec.js  |   50 +++++-----
 spec/cordova-cli/hooker.spec.js   |  125 +++++++++++++++--------
 spec/cordova-cli/platform.spec.js |   58 ++++++++---
 spec/cordova-cli/plugin.spec.js   |   30 ++++--
 spec/cordova-cli/prepare.spec.js  |    3 +-
 spec/cordova-cli/run.spec.js      |   11 ++-
 src/compile.js                    |   30 ++++--
 src/emulate.js                    |   57 ++++++-----
 src/hooker.js                     |   38 ++++---
 src/platform.js                   |  172 +++++++++++++++++++-------------
 src/plugin.js                     |  165 ++++++++++++++++++------------
 src/prepare.js                    |   75 +++++++-------
 src/run.js                        |   54 ++++++-----
 17 files changed, 546 insertions(+), 380 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bb7c377b/bin/cordova
----------------------------------------------------------------------
diff --git a/bin/cordova b/bin/cordova
index fc47ad1..60b2e09 100755
--- a/bin/cordova
+++ b/bin/cordova
@@ -19,6 +19,7 @@ process.on('uncaughtException', function(err){
 	console.error(err);
     process.exit(1);
 });
+cordova.on('result', console.log);
 if (verbose) {
     cordova.on('log', console.log);
     cordova.on('warn', console.warn);
@@ -31,20 +32,18 @@ if (version) {
     console.log(cordova.help());
 } else if (cordova.hasOwnProperty(cmd)) {
     var opts = Array.prototype.slice.call(tokens, 0);
-    var r;
     if (cmd == 'create' || cmd == 'docs' || cmd == 'serve') {
-        r = cordova[cmd].apply(this, opts);
+        cordova[cmd].apply(this, opts);
     } else if (cmd == 'emulate' || cmd == 'build' || cmd == 'prepare' || cmd == 'compile' || cmd == 'run') {
-        r = cordova[cmd].call(this, opts);
+        cordova[cmd].call(this, opts);
     } else {
         // platform or plugin cmds
         if (tokens.length > 2) {
             opts = [tokens.shift()];
             opts.push(tokens);
         }
-        r = cordova[cmd].apply(this, opts);
+        cordova[cmd].apply(this, opts);
     }
-    if (r) console.log(r);
 } else {
     throw new Error('Cordova does not know ' + cmd + '; try help for a list of all the available commands.');
 }

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bb7c377b/cordova.js
----------------------------------------------------------------------
diff --git a/cordova.js b/cordova.js
index efdc4b2..694089c 100644
--- a/cordova.js
+++ b/cordova.js
@@ -52,6 +52,9 @@ module.exports = {
     },
     off:       off,
     removeListener:off,
+    removeAllListeners:function() {
+        cordova_events.removeAllListeners.apply(cordova_events, arguments);
+    },
     emit:      emit,
     trigger:   emit,
     build:     function() {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bb7c377b/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 103ba49..fde2ff7 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "cordova",
-  "version": "2.8.10",
+  "version": "2.8.11",
   "preferGlobal": "true",
   "description": "Cordova command line interface tool",
   "main": "cordova",

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bb7c377b/spec/cordova-cli/compile.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova-cli/compile.spec.js b/spec/cordova-cli/compile.spec.js
index bd7dc42..0ebfc1a 100644
--- a/spec/cordova-cli/compile.spec.js
+++ b/spec/cordova-cli/compile.spec.js
@@ -96,51 +96,49 @@ describe('compile command', function() {
     });
 
     describe('hooks', function() {
-        var s;
+        var hook_spy;
+        var shell_spy;
         beforeEach(function() {
-            s = spyOn(hooker.prototype, 'fire').andReturn(true);
+            hook_spy = spyOn(hooker.prototype, 'fire').andCallFake(function(hook, opts, cb) {
+                cb();
+            });
+            shell_spy = spyOn(shell, 'exec').andCallFake(function(cmd, opts, cb) {
+                cb(0, 'yup'); // fake out shell so system thinks every shell-out is successful
+            });
+            cordova.create(tempDir);
+            process.chdir(tempDir);
+        });
+        afterEach(function() {
+            hook_spy.reset();
+            shell_spy.reset();
+            process.chdir(cwd);
         });
 
         describe('when platforms are added', function() {
             beforeEach(function() {
-                shell.mv('-f', path.join(cordova_project, 'platforms', 'android'), path.join(tempDir));
-                process.chdir(cordova_project);
-            });
-            afterEach(function() {
-                shell.mv('-f', path.join(tempDir, 'android'), path.join(cordova_project, 'platforms', 'android'));
-                process.chdir(cwd);
+                shell.mkdir(path.join(tempDir, 'platforms', 'android'));
+                shell.mkdir(path.join(tempDir, 'platforms', 'blackberry'));
             });
 
             it('should fire before hooks through the hooker module', function() {
-                spyOn(shell, 'exec');
                 cordova.compile();
-                expect(s).toHaveBeenCalledWith('before_compile');
+                expect(hook_spy).toHaveBeenCalledWith('before_compile', {platforms:['android', 'blackberry']}, jasmine.any(Function));
             });
             it('should fire after hooks through the hooker module', function(done) {
-                spyOn(shell, 'exec').andCallFake(function(cmd, options, callback) {
-                    callback(0, 'fucking eh');
-                });
                 cordova.compile('android', function() {
-                     expect(hooker.prototype.fire).toHaveBeenCalledWith('after_compile');
+                     expect(hook_spy).toHaveBeenCalledWith('after_compile', {platforms:['android']}, jasmine.any(Function));
                      done();
                 });
             });
         });
 
         describe('with no platforms added', function() {
-            beforeEach(function() {
-                cordova.create(tempDir);
-                process.chdir(tempDir);
-            });
-            afterEach(function() {
-                process.chdir(cwd);
-            });
             it('should not fire the hooker', function() {
                 expect(function() {
                     cordova.compile();
                 }).toThrow();
-                expect(s).not.toHaveBeenCalledWith('before_compile');
-                expect(s).not.toHaveBeenCalledWith('after_compile');
+                expect(hook_spy).not.toHaveBeenCalled();
+                expect(hook_spy).not.toHaveBeenCalled();
             });
         });
     });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bb7c377b/spec/cordova-cli/emulate.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova-cli/emulate.spec.js b/spec/cordova-cli/emulate.spec.js
index 93eaa90..7e4850b 100644
--- a/spec/cordova-cli/emulate.spec.js
+++ b/spec/cordova-cli/emulate.spec.js
@@ -72,56 +72,56 @@ describe('emulate command', function() {
                 cordova.emulate();
                 a_spy.mostRecentCall.args[1](); // fake out android parser
                 expect(s).toHaveBeenCalled();
-                expect(s.mostRecentCall.args[0]).toMatch(/cordova.run" --debug --emulator$/gi);
+                expect(s.mostRecentCall.args[0]).toMatch(/cordova.run" --emulator$/gi);
             }).not.toThrow();
         });
     });
 
     describe('hooks', function() {
-        var s;
+        var hook_spy;
+        var shell_spy;
         beforeEach(function() {
-            s = spyOn(hooker.prototype, 'fire').andReturn(true);
+            hook_spy = spyOn(hooker.prototype, 'fire').andCallFake(function(hook, opts, cb) {
+                if (cb) cb();
+                else opts();
+            });
+            shell_spy = spyOn(shell, 'exec').andCallFake(function(cmd, opts, cb) {
+                cb(0, 'yup'); // fake out shell so system thinks every shell-out is successful
+            });
+            process.chdir(tempDir);
+        });
+        afterEach(function() {
+            hook_spy.reset();
+            shell_spy.reset();
+            process.chdir(cwd);
         });
 
         describe('when platforms are added', function() {
+            var android_platform = path.join(tempDir, 'platforms', 'android');
             beforeEach(function() {
-                shell.cp('-Rf', path.join(cordova_project, 'platforms', 'android'), path.join(tempDir, 'platforms'));
-                process.chdir(tempDir);
+                shell.mkdir('-p', path.join(android_platform, 'assets', 'www'));
+                fs.writeFileSync(path.join(android_platform, 'AndroidManifest.xml'), '<xml></xml>', 'utf-8');
             });
-            afterEach(function() {
-                process.chdir(cwd);
-            });
-
             it('should fire before hooks through the hooker module', function() {
 
-                spyOn(shell, 'exec');
                 cordova.emulate();
-                expect(hooker.prototype.fire).toHaveBeenCalledWith('before_emulate');
+                expect(hook_spy).toHaveBeenCalledWith('before_emulate', {platforms:['android']}, jasmine.any(Function));
             });
-            it('should fire after hooks through the hooker module', function() {
-                spyOn(shell, 'exec').andCallFake(function(cmd, options, callback) {
-                    callback(0, 'fucking eh');
-                });
+            it('should fire after hooks through the hooker module', function(done) {
                 cordova.emulate('android', function() {
-                     expect(hooker.prototype.fire).toHaveBeenCalledWith('after_emulate');
+                     expect(hook_spy).toHaveBeenCalledWith('after_emulate', {platforms:['android']}, jasmine.any(Function));
+                     done();
                 });
             });
         });
 
         describe('with no platforms added', function() {
-            beforeEach(function() {
-                process.chdir(tempDir);
-            });
-            afterEach(function() {
-                process.chdir(cwd);
-            });
             it('should not fire the hooker', function() {
-                spyOn(shell, 'exec');
                 expect(function() {
                     cordova.emulate();
                 }).toThrow();
-                expect(s).not.toHaveBeenCalledWith('before_emulate');
-                expect(s).not.toHaveBeenCalledWith('after_emulate');
+                expect(hook_spy).not.toHaveBeenCalled();
+                expect(hook_spy).not.toHaveBeenCalled();
             });
         });
     });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bb7c377b/spec/cordova-cli/hooker.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova-cli/hooker.spec.js b/spec/cordova-cli/hooker.spec.js
index ff92f43..6b0129a 100644
--- a/spec/cordova-cli/hooker.spec.js
+++ b/spec/cordova-cli/hooker.spec.js
@@ -63,12 +63,13 @@ describe('hooker', function() {
         });
 
         describe('failure', function() {
-            it('should not throw if the hook is unrecognized', function() {
-                expect(function() {
-                    h.fire('CLEAN YOUR SHORTS GODDAMNIT LIKE A BIG BOY!');
-                }).not.toThrow();
+            it('should not error if the hook is unrecognized', function(done) {
+                h.fire('CLEAN YOUR SHORTS GODDAMNIT LIKE A BIG BOY!', function(err){
+                    expect(err).not.toBeDefined();
+                    done();
+                });
             });
-            it('should throw if any script exits with non-zero code', function() {
+            it('should error if any script exits with non-zero code', function(done) {
                 var script;
                 if (platform.match(/(win32|win64)/)) {
                     script = path.join(tempDir, '.cordova', 'hooks', 'before_build', 'fail.bat');
@@ -78,14 +79,15 @@ describe('hooker', function() {
                     shell.cp(path.join(hooks, 'fail', 'fail.sh'), script);
                 }
                 fs.chmodSync(script, '754');
-                expect(function() {
-                    h.fire('before_build');
-                }).toThrow();
+                h.fire('before_build', function(err){
+                    expect(err).toBeDefined();
+                    done();
+                });
             });
         });
 
         describe('success', function() {
-            it('should execute all scripts in order and return true', function() {
+            it('should execute all scripts in order and fire callback', function(done) {
                 var hook = path.join(tempDir, '.cordova', 'hooks', 'before_build');
                 if (platform.match(/(win32|win64)/)) {
                     shell.cp(path.join(hooks, 'test', '0.bat'), hook);
@@ -98,20 +100,22 @@ describe('hooker', function() {
                     fs.chmodSync(path.join(hook, script), '754');
                 });
                 var returnValue;
-                var s = spyOn(shell, 'exec').andReturn({code:0});
-                expect(function() {
-                    returnValue = h.fire('before_build');
-                }).not.toThrow();
-                expect(returnValue).toBe(true);
-                if (platform.match(/(win32|win64)/)) {
-                    expect(s.calls[0].args[0]).toMatch(/0.bat/);
-                    expect(s.calls[1].args[0]).toMatch(/1.bat/);
-                } else {
-                    expect(s.calls[0].args[0]).toMatch(/0.sh/);
-                    expect(s.calls[1].args[0]).toMatch(/1.sh/);
-                }
+                var s = spyOn(shell, 'exec').andCallFake(function(cmd, opts, cb) {
+                    cb(0, '');
+                });
+                h.fire('before_build', function(err) {
+                    expect(err).not.toBeDefined();
+                    if (platform.match(/(win32|win64)/)) {
+                        expect(s.calls[0].args[0]).toMatch(/0.bat/);
+                        expect(s.calls[1].args[0]).toMatch(/1.bat/);
+                    } else {
+                        expect(s.calls[0].args[0]).toMatch(/0.sh/);
+                        expect(s.calls[1].args[0]).toMatch(/1.sh/);
+                    }
+                    done();
+                });
             });
-            it('should pass the project root folder as parameter into the project-level hooks', function() {
+            it('should pass the project root folder as parameter into the project-level hooks', function(done) {
                 var hook = path.join(tempDir, '.cordova', 'hooks', 'before_build');
                 if (platform.match(/(win32|win64)/)) {
                     shell.cp(path.join(hooks, 'test', '0.bat'), hook);
@@ -121,19 +125,20 @@ describe('hooker', function() {
                 fs.readdirSync(hook).forEach(function(script) {
                     fs.chmodSync(path.join(hook, script), '754');
                 });
-                var returnValue;
-                var s = spyOn(shell, 'exec').andReturn({code:0});
-                expect(function() {
-                    returnValue = h.fire('before_build');
-                }).not.toThrow();
-                expect(returnValue).toBe(true);
-                var param_str;
-                if (platform.match(/(win32|win64)/)) {
-                    param_str = '0.bat "'+tempDir+'"';
-                } else { 
-                    param_str = '0.sh "'+tempDir+'"'; 
-                }
-                expect(s.calls[0].args[0].indexOf(param_str)).not.toEqual(-1);
+                var s = spyOn(shell, 'exec').andCallFake(function(cmd, opts, cb) {
+                    cb(0, '');
+                });
+                h.fire('before_build', function(err) {
+                    expect(err).not.toBeDefined();
+                    var param_str;
+                    if (platform.match(/(win32|win64)/)) {
+                        param_str = '0.bat "'+tempDir+'"';
+                    } else { 
+                        param_str = '0.sh "'+tempDir+'"'; 
+                    }
+                    expect(s.calls[0].args[0].indexOf(param_str)).not.toEqual(-1);
+                    done();
+                });
             });
             describe('module-level hooks', function() {
                 var handler = jasmine.createSpy();
@@ -143,21 +148,53 @@ describe('hooker', function() {
                     handler.reset();
                 });
 
-                it('should fire handlers using cordova.on', function() {
+                it('should fire handlers using cordova.on', function(done) {
                     cordova.on(test_event, handler);
-                    h.fire(test_event);
-                    expect(handler).toHaveBeenCalled();
+                    h.fire(test_event, function(err) {
+                        expect(handler).toHaveBeenCalled();
+                        expect(err).not.toBeDefined();
+                        done();
+                    });
                 });
-                it('should pass the project root folder as parameter into the module-level handlers', function() {
+                it('should pass the project root folder as parameter into the module-level handlers', function(done) {
                     cordova.on(test_event, handler);
-                    h.fire('before_build');
-                    expect(handler).toHaveBeenCalledWith(tempDir);
+                    h.fire(test_event, function(err) {
+                        expect(handler).toHaveBeenCalledWith({root:tempDir});
+                        expect(err).not.toBeDefined();
+                        done();
+                    });
                 });
-                it('should be able to stop listening to events using cordova.off', function() {
+                it('should be able to stop listening to events using cordova.off', function(done) {
                     cordova.on(test_event, handler);
                     cordova.off(test_event, handler);
-                    h.fire('before_build');
-                    expect(handler).not.toHaveBeenCalled();
+                    h.fire(test_event, function(err) {
+                        expect(handler).not.toHaveBeenCalled();
+                        done();
+                    });
+                });
+                it('should allow for hook to opt into asynchronous execution and block further hooks from firing using the done callback', function(done) {
+                    var h1_fired = false;
+                    var h1 = function(root, cb) {
+                        h1_fired = true;
+                        setTimeout(cb, 100);
+                    };
+                    var h2_fired = false;
+                    var h2 = function() {
+                        h2_fired = true;
+                    };
+                    runs(function() {
+                        cordova.on(test_event, h1);
+                        cordova.on(test_event, h2);
+                        h.fire(test_event, function(err) {
+                            done();
+                        });
+                        expect(h1_fired).toBe(true);
+                        expect(h2_fired).toBe(false);
+                    });
+                    waits(100);
+                    runs(function() {
+                        expect(h2_fired).toBe(true);
+                    });
                 });
             });
         });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bb7c377b/spec/cordova-cli/platform.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova-cli/platform.spec.js b/spec/cordova-cli/platform.spec.js
index 301ec4b..4e21aad 100644
--- a/spec/cordova-cli/platform.spec.js
+++ b/spec/cordova-cli/platform.spec.js
@@ -75,18 +75,28 @@ describe('platform command', function() {
 
         afterEach(function() {
             process.chdir(cwd);
+            cordova.removeAllListeners('results'); // clean up event listener
         });
 
-        it('should list out no platforms for a fresh project', function() {
+        it('should list out no platforms for a fresh project', function(done) {
             shell.rm('-rf', path.join(tempDir, 'platforms', '*'));
-            expect(cordova.platform('list').length).toEqual(0);
+            cordova.on('results', function(res) {
+                expect(res).toEqual('No platforms added. Use `cordova platform add <platform>`.');
+                done();
+            });
+            cordova.platform('list');
         });
 
-        it('should list out added platforms in a project', function() {
+        it('should list out added platforms in a project', function(done) {
             var platforms = path.join(tempDir, 'platforms');
             shell.mkdir(path.join(platforms, 'android'));
             shell.mkdir(path.join(platforms, 'ios'));
-            expect(cordova.platform('list').length).toEqual(2);
+            
+            cordova.on('results', function(res) {
+                expect(res.length).toEqual(2);
+                done();
+            });
+            cordova.platform('list');
         });
     });
 
@@ -121,21 +131,32 @@ describe('platform command', function() {
 
         afterEach(function() {
             process.chdir(cwd);
+            cordova.removeAllListeners('results');
         });
 
-        it('should remove a supported and added platform', function() {
+        it('should remove a supported and added platform', function(done) {
             shell.mkdir(path.join(tempDir, 'platforms', 'android'));
             shell.mkdir(path.join(tempDir, 'platforms', 'ios'));
-            cordova.platform('remove', 'android');
-            expect(cordova.platform('ls').length).toEqual(1);
+            cordova.platform('remove', 'android', function() {
+                cordova.on('results', function(res) {
+                    expect(res.length).toEqual(1);
+                    done();
+                });
+                cordova.platform('list');
+            });
         });
 
-        it('should be able to remove multiple platforms', function() {
+        it('should be able to remove multiple platforms', function(done) {
             shell.mkdir(path.join(tempDir, 'platforms', 'android'));
             shell.mkdir(path.join(tempDir, 'platforms', 'blackberry'));
             shell.mkdir(path.join(tempDir, 'platforms', 'ios'));
-            cordova.platform('remove', ['android','blackberry']);
-            expect(cordova.platform('ls').length).toEqual(1);
+            cordova.platform('remove', ['android','blackberry'], function() {
+                cordova.on('results', function(res) {
+                    expect(res.length).toEqual(1);
+                    done();
+                });
+                cordova.platform('list');
+            });
         });
     });
 
@@ -144,7 +165,10 @@ describe('platform command', function() {
         beforeEach(function() {
             cordova.create(tempDir);
             process.chdir(tempDir);
-            s = spyOn(hooker.prototype, 'fire').andReturn(true);
+            s = spyOn(hooker.prototype, 'fire').andCallFake(function(hook, opts, cb) {
+                if (cb) cb();
+                else opts();
+            });
         });
         afterEach(function() {
             process.chdir(cwd);
@@ -154,21 +178,21 @@ describe('platform command', function() {
         describe('list (ls) hooks', function() {
             it('should fire before hooks through the hooker module', function() {
                 cordova.platform();
-                expect(s).toHaveBeenCalledWith('before_platform_ls');
+                expect(s).toHaveBeenCalledWith('before_platform_ls', jasmine.any(Function));
             });
             it('should fire after hooks through the hooker module', function() {
                 cordova.platform();
-                expect(s).toHaveBeenCalledWith('after_platform_ls');
+                expect(s).toHaveBeenCalledWith('after_platform_ls', jasmine.any(Function));
             });
         });
         describe('remove (rm) hooks', function() {
             it('should fire before hooks through the hooker module', function() {
                 cordova.platform('rm', 'android');
-                expect(s).toHaveBeenCalledWith('before_platform_rm');
+                expect(s).toHaveBeenCalledWith('before_platform_rm', {platforms:['android']}, jasmine.any(Function));
             });
             it('should fire after hooks through the hooker module', function() {
                 cordova.platform('rm', 'android');
-                expect(s).toHaveBeenCalledWith('after_platform_rm');
+                expect(s).toHaveBeenCalledWith('after_platform_rm', {platforms:['android']}, jasmine.any(Function));
             });
         });
         describe('add hooks', function() {
@@ -191,8 +215,8 @@ describe('platform command', function() {
                 fake_reqs_check();
                 fake_create(path.join(tempDir, 'platforms', 'android'));
                 ap.mostRecentCall.args[1](); // fake out update_project
-                expect(s).toHaveBeenCalledWith('before_platform_add');
-                expect(s).toHaveBeenCalledWith('after_platform_add');
+                expect(s).toHaveBeenCalledWith('before_platform_add', {platforms:['android']}, jasmine.any(Function));
+                expect(s).toHaveBeenCalledWith('after_platform_add', {platforms:['android']}, jasmine.any(Function));
             });
         });
     });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bb7c377b/spec/cordova-cli/plugin.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova-cli/plugin.spec.js b/spec/cordova-cli/plugin.spec.js
index 43d4a9a..d042841 100644
--- a/spec/cordova-cli/plugin.spec.js
+++ b/spec/cordova-cli/plugin.spec.js
@@ -69,6 +69,7 @@ describe('plugin command', function() {
 
        afterEach(function() {
            process.chdir(cwd);
+           cordova.removeAllListeners('results');
        });
 
        it('should not fail when the plugins directory is missing', function() {
@@ -79,33 +80,44 @@ describe('plugin command', function() {
            }).not.toThrow();
        });
 
-       it('should ignore files, like .gitignore, in the plugins directory', function() {
+       it('should ignore files, like .gitignore, in the plugins directory', function(done) {
            var someFile = path.join(tempDir, 'plugins', '.gitignore');
            fs.writeFileSync(someFile, 'not a plugin');
+           cordova.on('results', function(res) {
+               expect(res).toEqual('No plugins added. Use `cordova plugin add <plugin>`.');
+               done();
+           });
 
-           expect(cordova.plugin('list')).toEqual('No plugins added. Use `cordova plugin add <plugin>`.');
+           cordova.plugin('list');
        });
     });
 
     describe('`ls`', function() {
         beforeEach(function() {
             cordova.create(tempDir);
+            process.chdir(tempDir);
         });
 
         afterEach(function() {
             process.chdir(cwd);
+            cordova.removeAllListeners('results');
         });
 
-        it('should list out no plugins for a fresh project', function() {
-            process.chdir(tempDir);
-
-            expect(cordova.plugin('list')).toEqual('No plugins added. Use `cordova plugin add <plugin>`.');
+        it('should list out no plugins for a fresh project', function(done) {
+            cordova.on('results', function(res) {
+                expect(res).toEqual('No plugins added. Use `cordova plugin add <plugin>`.');
+                done();
+            });
+            cordova.plugin('list');
         });
-        it('should list out any added plugins in a project', function() {
-            process.chdir(tempDir);
+        it('should list out any added plugins in a project', function(done) {
             var random_plug = 'randomplug';
             shell.mkdir('-p', path.join(tempDir, 'plugins', random_plug));
-            expect(cordova.plugin('list')).toEqual([random_plug]);
+            cordova.on('results', function(res) {
+                expect(res).toEqual([random_plug]);
+                done();
+            });
+            cordova.plugin('list');
         });
     });
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bb7c377b/spec/cordova-cli/prepare.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova-cli/prepare.spec.js b/spec/cordova-cli/prepare.spec.js
index b420024..94ca13b 100644
--- a/spec/cordova-cli/prepare.spec.js
+++ b/spec/cordova-cli/prepare.spec.js
@@ -23,6 +23,7 @@ var cordova = require('../../cordova'),
     path = require('path'),
     fs = require('fs'),
     config_parser = require('../../src/config_parser'),
+    android_parser = require('../../src/metadata/android_parser'),
     hooker = require('../../src/hooker'),
     fixtures = path.join(__dirname, '..', 'fixtures'),
     test_plugin = path.join(fixtures, 'plugins', 'android'),
@@ -127,7 +128,7 @@ describe('prepare command', function() {
 
             it('should fire before hooks through the hooker module', function() {
                 cordova.prepare();
-                expect(s).toHaveBeenCalledWith('before_prepare');
+                expect(s).toHaveBeenCalledWith('before_prepare', jasmine.any(Function));
             });
             it('should fire after hooks through the hooker module', function() {
                 spyOn(shell, 'exec');

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bb7c377b/spec/cordova-cli/run.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova-cli/run.spec.js b/spec/cordova-cli/run.spec.js
index 359a723..7e505ef 100644
--- a/spec/cordova-cli/run.spec.js
+++ b/spec/cordova-cli/run.spec.js
@@ -79,7 +79,7 @@ describe('run command', function() {
                 cb(0, 'yep');
             });
             cordova.run('android', function() {
-                 expect(spy.mostRecentCall.args[0]).toMatch(/cordova.run" --debug --device$/gi);
+                 expect(spy.mostRecentCall.args[0]).toMatch(/cordova.run" --device$/gi);
                  done();
             });
         });
@@ -89,7 +89,10 @@ describe('run command', function() {
     describe('hooks', function() {
         var s;
         beforeEach(function() {
-            s = spyOn(hooker.prototype, 'fire').andReturn(true);
+            s = spyOn(hooker.prototype, 'fire').andCallFake(function(hook, opts, cb) {
+                if (cb) cb();
+                else opts();
+            });
         });
 
         describe('when platforms are added', function() {
@@ -105,14 +108,14 @@ describe('run command', function() {
 
                 spyOn(shell, 'exec');
                 cordova.run();
-                expect(hooker.prototype.fire).toHaveBeenCalledWith('before_run');
+                expect(hooker.prototype.fire).toHaveBeenCalledWith('before_run', {platforms:['android']}, jasmine.any(Function));
             });
             it('should fire after hooks through the hooker module', function(done) {
                 spyOn(shell, 'exec').andCallFake(function(cmd, options, callback) {
                     callback(0, 'fucking eh');
                 });
                 cordova.run('android', function() {
-                     expect(hooker.prototype.fire).toHaveBeenCalledWith('after_run');
+                     expect(hooker.prototype.fire).toHaveBeenCalledWith('after_run', {platforms:['android']}, jasmine.any(Function));
                      done();
                 });
             });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bb7c377b/src/compile.js
----------------------------------------------------------------------
diff --git a/src/compile.js b/src/compile.js
index f969624..39c78bc 100644
--- a/src/compile.js
+++ b/src/compile.js
@@ -67,27 +67,35 @@ module.exports = function compile(platformList, callback) {
         else throw err;
         return;
     }
+    var opts = {
+        platforms:platformList
+    };
 
     var hooks = new hooker(projectRoot);
-    hooks.fire('before_compile', function(err) {
+    hooks.fire('before_compile', opts, function(err) {
         if (err) {
-            var error = new Error('before_compile hooks exited with non-zero code or caused an error: ' + err.message);
-            if (callback) callback(error);
-            else throw error;
+            if (callback) callback(err);
+            else throw err;
         } else {
             var end = n(platformList.length, function() {
-                hooks.fire('after_compile', function(error) {
-                    if (error) {
-                        var arr = new Error('after_compile hooks exited with non-zero code. Aborting.');
-                        if (callback) callback(arr);
-                        else throw arr;
-                    } else if (callback) callback();
+                hooks.fire('after_compile', opts, function(err) {
+                    if (err) {
+                        if (callback) callback(err);
+                        else throw err;
+                    } else {
+                        if (callback) callback();
+                    }
                 });
             });
 
             // Iterate over each added platform
             platformList.forEach(function(platform) {
-                shell_out_to_build(projectRoot, platform, end);
+                try {
+                    shell_out_to_build(projectRoot, platform, end);
+                } catch(e) {
+                    if (callback) callback(e);
+                    else throw e;
+                }
             });
         }
     });

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bb7c377b/src/emulate.js
----------------------------------------------------------------------
diff --git a/src/emulate.js b/src/emulate.js
index 2d902b2..b8bc4ad 100644
--- a/src/emulate.js
+++ b/src/emulate.js
@@ -31,7 +31,7 @@ var cordova_util      = require('./util'),
     util              = require('util');
 
 function shell_out_to_emulate(root, platform, done) {
-    var cmd = '"' + path.join(root, 'platforms', platform, 'cordova', 'run') + '" --debug --emulator';
+    var cmd = '"' + path.join(root, 'platforms', platform, 'cordova', 'run') + '" --emulator';
     // TODO: inconsistent API for BB10 run command
     if (platform == 'blackberry') {
         var bb_project = path.join(root, 'platforms', 'blackberry')
@@ -83,40 +83,43 @@ module.exports = function emulate (platformList, callback) {
         else throw err;
         return;
     }
+    var opts = {
+        platforms:platformList
+    };
 
     var hooks = new hooker(projectRoot);
-    if (!(hooks.fire('before_emulate'))) {
-        var err = new Error('before_emulate hooks exited with non-zero code. Aborting build.');
-        if (callback) callback(err);
-        else throw err;
-        return;
-    }
-
-    var end = n(platformList.length, function() {
-        if (!(hooks.fire('after_emulate'))) {
-            var err = new Error('after_emulate hooks exited with non-zero code. Aborting.');
-            if (callback) callback(err);
-            else throw err;
-            return;
-        }
-        if (callback) callback();
-    });
-
-    // Run a prepare first!
-    prepare(platformList, function(err) {
+    hooks.fire('before_emulate', opts, function(err) {
         if (err) {
             if (callback) callback(err);
             else throw err;
         } else {
-            platformList.forEach(function(platform) {
-                try {
-                    shell_out_to_emulate(projectRoot, platform, end);
-                } catch(e) {
-                    if (callback) callback(e);
-                    else throw e;
+            var end = n(platformList.length, function() {
+                hooks.fire('after_emulate', opts, function(err) {
+                    if (err) {
+                        if (callback) callback(err);
+                        else throw err;
+                    } else {
+                        if (callback) callback();
+                    }
+                });
+            });
+
+            // Run a prepare first!
+            prepare(platformList, function(err) {
+                if (err) {
+                    if (callback) callback(err);
+                    else throw err;
+                } else {
+                    platformList.forEach(function(platform) {
+                        try {
+                            shell_out_to_emulate(projectRoot, platform, end);
+                        } catch(e) {
+                            if (callback) callback(e);
+                            else throw e;
+                        }
+                    });
                 }
             });
         }
     });
 };
-

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bb7c377b/src/hooker.js
----------------------------------------------------------------------
diff --git a/src/hooker.js b/src/hooker.js
index 15c9a6c..a483b8f 100644
--- a/src/hooker.js
+++ b/src/hooker.js
@@ -29,24 +29,32 @@ module.exports = function hooker(root) {
 }
 
 module.exports.prototype = {
-    fire:function fire(hook, callback) {
+    fire:function fire(hook, opts, callback) {
+        if (arguments.length == 2) {
+            callback = opts;
+            opts = {};
+        }
         var self = this;
         var dir = path.join(this.root, '.cordova', 'hooks', hook);
-        if (!(fs.existsSync(dir))) return true; // hooks directory got axed post-create; ignore.
+        opts.root = this.root;
 
         // Fire JS hook for the event
         // These ones need to "serialize" events, that is, each handler attached to the event needs to finish processing (if it "opted in" to the callback) before the next one will fire.
         var handlers = events.listeners(hook);
-        execute_handlers_serially(handlers, this.root, function() {
+        execute_handlers_serially(handlers, opts, function() {
             // Fire script-based hooks
-            var scripts = fs.readdirSync(dir);
-            execute_scripts_serially(scripts, self.root, dir, function(err) {
-                if (err) {
-                    callback(err);
-                } else {
-                    callback();
-                }
-            });
+            if (!(fs.existsSync(dir))) {
+                callback(); // hooks directory got axed post-create; ignore.
+            } else {
+                var scripts = fs.readdirSync(dir);
+                execute_scripts_serially(scripts, self.root, dir, function(err) {
+                    if (err) {
+                        callback(err);
+                    } else {
+                        callback();
+                    }
+                });
+            }
         });
     }
 }
@@ -74,16 +82,16 @@ function execute_scripts_serially(scripts, root, dir, callback) {
     }
 }
 
-function execute_handlers_serially(handlers, root, callback) {
+function execute_handlers_serially(handlers, opts, callback) {
     if (handlers.length) {
         var h = handlers.shift();
         if (h.length > 1) {
             h(root, function() {
-                execute_handlers_serially(handlers, root, callback);
+                execute_handlers_serially(handlers, opts, callback);
             });
         } else {
-            h(root);
-            execute_handlers_serially(handlers, root, callback);
+            h(opts);
+            execute_handlers_serially(handlers, opts, callback);
         }
     } else {
         callback();

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bb7c377b/src/platform.js
----------------------------------------------------------------------
diff --git a/src/platform.js b/src/platform.js
index c36b582..82cc532 100644
--- a/src/platform.js
+++ b/src/platform.js
@@ -38,8 +38,7 @@ module.exports = function platform(command, targets, callback) {
         return;
     }
 
-    var hooks = new hooker(projectRoot),
-        end;
+    var hooks = new hooker(projectRoot);
 
     var createOverrides = function(target) {
         shell.mkdir('-p', path.join(cordova_util.appDir(projectRoot), 'merges', target));
@@ -48,95 +47,128 @@ module.exports = function platform(command, targets, callback) {
     if (arguments.length === 0) command = 'ls';
     if (targets) {
         if (!(targets instanceof Array)) targets = [targets];
-        end = n(targets.length, function() {
-            if (callback) callback();
-        });
     }
 
     var xml = cordova_util.projectConfig(projectRoot);
     var cfg = new config_parser(xml);
+    var opts = {
+        platforms:targets
+    };
 
     switch(command) {
         case 'ls':
         case 'list':
-            // TODO before+after hooks here are awkward
-            hooks.fire('before_platform_ls');
-            hooks.fire('after_platform_ls');
-            return fs.readdirSync(path.join(projectRoot, 'platforms'));
-            break;
-        case 'add':
-            targets.forEach(function(target) {
-                hooks.fire('before_platform_add');
-                var output = path.join(projectRoot, 'platforms', target);
-
-                // Check if output directory already exists.
-                if (fs.existsSync(output)) {
-                    var err = new Error('Platform "' + target + '" already exists' );
+            var platforms_on_fs = fs.readdirSync(path.join(projectRoot, 'platforms'));
+            hooks.fire('before_platform_ls', function(err) {
+                if (err) {
                     if (callback) callback(err);
                     else throw err;
-                    return;
+                } else {
+                    events.emit('results', (platforms_on_fs.length ? platforms_on_fs : 'No platforms added. Use `cordova platform add <platform>`.'));
+                    hooks.fire('after_platform_ls', function(err) {
+                        if (err) {
+                            if (callback) callback(err);
+                            else throw err;
+                        }
+                    });
                 }
-
-                // Make sure we have minimum requirements to work with specified platform
-                events.emit('log', 'Checking if platform "' + target + '" passes minimum requirements.');
-                module.exports.supports(target, function(err) {
+            });
+            break;
+        case 'add':
+            var end = n(targets.length, function() {
+                hooks.fire('after_platform_add', opts, function(err) {
                     if (err) {
-                        var err = new Error('Your system does not meet the requirements to create ' + target + ' projects: ' + err.message);
                         if (callback) callback(err);
                         else throw err;
-                        return;
                     } else {
-                        // Create a platform app using the ./bin/create scripts that exist in each repo.
-                        // Run platform's create script
-                        var bin = path.join(cordova_util.libDirectory, 'cordova-' + target, 'bin', 'create');
-                        var args = (target=='ios') ? '--arc' : '';
-                        var pkg = cfg.packageName().replace(/[^\w.]/g,'_');
-                        var name = cfg.name().replace(/\W/g,'_');
-                        // TODO: PLATFORM LIBRARY INCONSISTENCY: order/number of arguments to create
-                        // TODO: keep tabs on CB-2300
-                        var command = util.format('"%s" %s "%s" "%s" "%s"', bin, args, output, (target=='blackberry'?name:pkg), name);
-                        events.emit('log', 'Running bin/create for platform "' + target + '" with command: "' + command + '" (output to follow)');
-
-                        shell.exec(command, {silent:true,async:true}, function(code, create_output) {
-                            events.emit('log', create_output);
-                            if (code > 0) {
-                                var err = new Error('An error occured during creation of ' + target + ' sub-project. ' + create_output);
-                                if (callback) callback(err);
-                                else throw err;
-                                return;
-                            }
-
-                            var parser = new platforms[target].parser(output);
-                            events.emit('log', 'Updating ' + target + ' project from config.xml...');
-                            parser.update_project(cfg, function() {
-                                createOverrides(target);
-                                hooks.fire('after_platform_add');
-
-                                // Install all currently installed plugins into this new platform.
-                                var pluginsDir = path.join(projectRoot, 'plugins');
-                                var plugins = fs.readdirSync(pluginsDir);
-                                plugins && plugins.forEach(function(plugin) {
-                                    if (!fs.statSync(path.join(projectRoot, 'plugins', plugin)).isDirectory()) {
-                                        return;
-                                    }
-
-                                    events.emit('log', 'Installing plugin "' + plugin + '" following success platform add of ' + target);
-                                    plugman.install(target, output, path.basename(plugin), pluginsDir, { www_dir: parser.staging_dir() });
-                                });
-                                end();
-                            });
-                        });
+                        if (callback) callback();
                     }
                 });
             });
+            hooks.fire('before_platform_add', opts, function(err) {
+                if (err) {
+                    if (callback) callback(err);
+                    else throw err;
+                } else {
+                    targets.forEach(function(target) {
+                        var output = path.join(projectRoot, 'platforms', target);
+
+                        // Check if output directory already exists.
+                        if (fs.existsSync(output)) {
+                            var err = new Error('Platform "' + target + '" already exists at "' + output + '"');
+                            if (callback) callback(err);
+                            else throw err;
+                        } else {
+                            // Make sure we have minimum requirements to work with specified platform
+                            events.emit('log', 'Checking if platform "' + target + '" passes minimum requirements...');
+                            module.exports.supports(target, function(err) {
+                                if (err) {
+                                    if (callback) callback(err);
+                                    else throw err;
+                                } else {
+                                    // Create a platform app using the ./bin/create scripts that exist in each repo.
+                                    // Run platform's create script
+                                    var bin = path.join(cordova_util.libDirectory, 'cordova-' + target, 'bin', 'create');
+                                    var args = (target=='ios') ? '--arc' : '';
+                                    var pkg = cfg.packageName().replace(/[^\w.]/g,'_');
+                                    var name = cfg.name().replace(/\W/g,'_');
+                                    var command = util.format('"%s" %s "%s" "%s" "%s"', bin, args, output, pkg, name);
+                                    events.emit('log', 'Running bin/create for platform "' + target + '" with command: "' + command + '" (output to follow)');
+
+                                    shell.exec(command, {silent:true,async:true}, function(code, create_output) {
+                                        events.emit('log', create_output);
+                                        if (code > 0) {
+                                            var err = new Error('An error occured during creation of ' + target + ' sub-project. ' + create_output);
+                                            if (callback) callback(err);
+                                            else throw err;
+                                        } else {
+                                            var parser = new platforms[target].parser(output);
+                                            events.emit('log', 'Updating ' + target + ' project from config.xml...');
+                                            parser.update_project(cfg, function() {
+                                                createOverrides(target);
+                                                end(); //platform add is done by now.
+                                                // Install all currently installed plugins into this new platform.
+                                                var pluginsDir = path.join(projectRoot, 'plugins');
+                                                var plugins = fs.readdirSync(pluginsDir);
+                                                plugins && plugins.forEach(function(plugin) {
+                                                    if (fs.statSync(path.join(projectRoot, 'plugins', plugin)).isDirectory()) {
+                                                        events.emit('log', 'Installing plugin "' + plugin + '" following successful platform add of ' + target);
+                                                        plugman.install(target, output, path.basename(plugin), pluginsDir, { www_dir: parser.staging_dir() });
+                                                    }
+                                                });
+                                            });
+                                        }
+                                    });
+                                }
+                            });
+                        }
+                    });
+                }
+            });
             break;
         case 'rm':
         case 'remove':
-            targets.forEach(function(target) {
-                hooks.fire('before_platform_rm');
-                shell.rm('-rf', path.join(projectRoot, 'platforms', target));
-                shell.rm('-rf', path.join(cordova_util.appDir(projectRoot), 'merges', target));
-                hooks.fire('after_platform_rm');
+            var end = n(targets.length, function() {
+                hooks.fire('after_platform_rm', opts, function(err) {
+                    if (err) {
+                        if (callback) callback(err);
+                        else throw err;
+                    } else {
+                        if (callback) callback();
+                    }
+                });
+            });
+            hooks.fire('before_platform_rm', opts, function(err) {
+                if (err) {
+                    if (callback) callback(err);
+                    else throw err;
+                } else {
+                    targets.forEach(function(target) {
+                        shell.rm('-rf', path.join(projectRoot, 'platforms', target));
+                        shell.rm('-rf', path.join(cordova_util.appDir(projectRoot), 'merges', target));
+                        end();
+                    });
+                }
             });
             break;
         default:

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bb7c377b/src/plugin.js
----------------------------------------------------------------------
diff --git a/src/plugin.js b/src/plugin.js
index 0851305..8fbe355 100644
--- a/src/plugin.js
+++ b/src/plugin.js
@@ -24,6 +24,7 @@ var cordova_util  = require('./util'),
     shell         = require('shelljs'),
     platforms     = require('../platforms'),
     config_parser = require('./config_parser'),
+    n             = require('ncallbacks'),
     hooker        = require('./hooker'),
     events        = require('./events'),
     plugin_parser = require('./plugin_parser'),
@@ -55,92 +56,124 @@ module.exports = function plugin(command, targets, callback) {
     if (targets && !(targets instanceof Array)) {
         targets = [targets];
     }
+    var opts = {
+        plugins:targets
+    };
 
     switch(command) {
         case 'ls':
         case 'list':
-            // TODO awkward before+after hooks here
-            hooks.fire('before_plugin_ls');
-            hooks.fire('after_plugin_ls');
-            if (plugins.length) {
-                return plugins;
-            } else return 'No plugins added. Use `cordova plugin add <plugin>`.';
+            hooks.fire('before_plugin_ls', function(err) {
+                if (err) {
+                    if (callback) callback(err);
+                    else throw err;
+                } else {
+                    events.emit('results', (plugins.length ? plugins : 'No plugins added. Use `cordova plugin add <plugin>`.'));
+                    hooks.fire('after_plugin_ls', function(err) {
+                        if (err) {
+                            if (callback) callback(err);
+                            else throw err;
+                        }
+                    });
+                }
+            });
             break;
         case 'add':
-            targets.forEach(function(target, index) {
-                hooks.fire('before_plugin_add');
-                var pluginsDir = path.join(projectRoot, 'plugins');
-
-                if (target[target.length - 1] == path.sep) {
-                    target = target.substring(0, target.length - 1);
-                }
-
-                // Fetch the plugin first.
-                events.emit('log', 'Calling plugman.fetch on plugin "' + target + '"');
-                plugman.fetch(target, pluginsDir, {}, function(err, dir) {
+            var end = n(targets.length, function() {
+                hooks.fire('after_plugin_add', opts, function(err) {
                     if (err) {
-                        var err = new Error('Error fetching plugin: ' + err);
                         if (callback) callback(err);
                         else throw err;
-                        return;
+                    } else {
+                        if (callback) callback();
                     }
+                });
+            });
+            hooks.fire('before_plugin_add', opts, function(err) {
+                if (err) {
+                    if (callback) callback(err);
+                    else throw err;
+                } else {
+                    targets.forEach(function(target, index) {
+                        var pluginsDir = path.join(projectRoot, 'plugins');
 
-                    // Iterate over all platforms in the project and install the plugin.
-                    platformList.forEach(function(platform) {
-                        var platformRoot = path.join(projectRoot, 'platforms', platform);
-                        var parser = new platforms[platform].parser(platformRoot);
-                        // TODO: unify use of blackberry in cli vs blackberry10 in plugman
-                        events.emit('log', 'Calling plugman.install on plugin "' + dir + '" for platform "' + platform + '"');
-                        plugman.install((platform=='blackberry'?'blackberry10':platform), platformRoot,
-                                        path.basename(dir), pluginsDir, { www_dir: parser.staging_dir() });
-                    });
+                        if (target[target.length - 1] == path.sep) {
+                            target = target.substring(0, target.length - 1);
+                        }
 
-                    hooks.fire('after_plugin_add');
-                });
+                        // Fetch the plugin first.
+                        events.emit('log', 'Calling plugman.fetch on plugin "' + target + '"');
+                        plugman.fetch(target, pluginsDir, {}, function(err, dir) {
+                            if (err) {
+                                var err = new Error('Error fetching plugin: ' + err);
+                                if (callback) callback(err);
+                                else throw err;
+                            } else {
+                                // Iterate over all platforms in the project and install the plugin.
+                                platformList.forEach(function(platform) {
+                                    var platformRoot = path.join(projectRoot, 'platforms', platform);
+                                    var parser = new platforms[platform].parser(platformRoot);
+                                    // TODO: unify use of blackberry in cli vs blackberry10 in plugman
+                                    events.emit('log', 'Calling plugman.install on plugin "' + dir + '" for platform "' + platform + '"');
+                                    plugman.install((platform=='blackberry'?'blackberry10':platform), platformRoot,
+                                                    path.basename(dir), pluginsDir, { www_dir: parser.staging_dir() });
+                                });
+                                end();
+                            }
+                        });
+                    });
+                }
             });
-            if (callback) callback();
             break;
         case 'rm':
         case 'remove':
-            if (platformList.length === 0) {
-                var err = new Error('You need at least one platform added to your app. Use `cordova platform add <platform>`.');
-                if (callback) callback(err);
-                else throw err;
-                return;
-            }
-            targets.forEach(function(target, index) {
-                // Check if we have the plugin.
-                if (plugins.indexOf(target) > -1) {
-                    var targetPath = path.join(pluginPath, target);
-                    hooks.fire('before_plugin_rm');
-                    // Check if there is at least one match between plugin
-                    // supported platforms and app platforms
-                    var pluginXml = new plugin_parser(path.join(targetPath, 'plugin.xml'));
-                    var intersection = pluginXml.platforms.filter(function(e) {
-                        if (platformList.indexOf(e) == -1) return false;
-                        else return true;
-                    });
-
-                    // Iterate over all the common platforms between the plugin
-                    // and the app, and uninstall.
-                    // If this is a web-only plugin with no platform tags, this step
-                    // is not needed and we just --remove the plugin below.
-                    intersection.forEach(function(platform) {
-                        var platformRoot = path.join(projectRoot, 'platforms', platform);
-                        var parser = new platforms[platform].parser(platformRoot);
-                        events.emit('log', 'Calling plugman.uninstall on plugin "' + target + '" for platform "' + platform + '"');
-                        plugman.uninstall(platform, platformRoot, target, path.join(projectRoot, 'plugins'), { www_dir: parser.staging_dir() });
-                    });
-
-                    hooks.fire('after_plugin_rm');
-                } else {
-                    var err = new Error('Plugin "' + target + '" not added to project.');
+            var end = n(targets.length, function() {
+                hooks.fire('after_plugin_rm', opts, function(err) {
+                    if (err) {
+                        if (callback) callback(err);
+                        else throw err;
+                    } else {
+                        if (callback) callback();
+                    }
+                });
+            });
+            hooks.fire('before_plugin_rm', opts, function(err) {
+                if (err) {
                     if (callback) callback(err);
                     else throw err;
-                    return;
+                } else {
+                    targets.forEach(function(target, index) {
+                        // Check if we have the plugin.
+                        if (plugins.indexOf(target) > -1) {
+                            var targetPath = path.join(pluginPath, target);
+                            // Check if there is at least one match between plugin
+                            // supported platforms and app platforms
+                            var pluginXml = new plugin_parser(path.join(targetPath, 'plugin.xml'));
+                            var intersection = pluginXml.platforms.filter(function(e) {
+                                if (platformList.indexOf(e) == -1) return false;
+                                else return true;
+                            });
+
+                            // Iterate over all the common platforms between the plugin
+                            // and the app, and uninstall.
+                            // If this is a web-only plugin with no platform tags, this step
+                            // is not needed and we just --remove the plugin below.
+                            intersection.forEach(function(platform) {
+                                var platformRoot = path.join(projectRoot, 'platforms', platform);
+                                var parser = new platforms[platform].parser(platformRoot);
+                                events.emit('log', 'Calling plugman.uninstall on plugin "' + target + '" for platform "' + platform + '"');
+                                plugman.uninstall(platform, platformRoot, target, path.join(projectRoot, 'plugins'), { www_dir: parser.staging_dir() });
+                            });
+                            end();
+                        } else {
+                            var err = new Error('Plugin "' + target + '" not added to project.');
+                            if (callback) callback(err);
+                            else throw err;
+                            return;
+                        }
+                    });
                 }
             });
-            if (callback) callback();
             break;
         default:
             var err = new Error('Unrecognized command "' + command + '". Use either `add`, `remove`, or `list`.');

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bb7c377b/src/prepare.js
----------------------------------------------------------------------
diff --git a/src/prepare.js b/src/prepare.js
index d1fbce7..2205186 100644
--- a/src/prepare.js
+++ b/src/prepare.js
@@ -60,46 +60,47 @@ module.exports = function prepare(platformList, callback) {
     }
 
     var hooks = new hooker(projectRoot);
-    if (!(hooks.fire('before_prepare'))) {
-        var err = new Error('before_prepare hooks exited with non-zero code. Aborting.');
-        if (callback) callback(err);
-        else throw err;
-        return;
-    }
-
-    var end = n(platformList.length, function() {
-        if (!(hooks.fire('after_prepare'))) {
-            var err = new Error('after_prepare hooks exited with non-zero code. Aborting.');
+    hooks.fire('before_prepare', function(err) {
+        if (err) {
             if (callback) callback(err);
             else throw err;
-            return;
-        }
-        if (callback) callback();
-    });
+        } else {
+            var end = n(platformList.length, function() {
+                hooks.fire('after_prepare', function(err) {
+                    if (err) {
+                        if (callback) callback(err);
+                        else throw err;
+                    } else {
+                        if (callback) callback();
+                    }
+                });
+            });
 
-    // Iterate over each added platform
-    platformList.forEach(function(platform) {
-        var platformPath = path.join(projectRoot, 'platforms', platform);
-        var parser = new platforms[platform].parser(platformPath);
-        parser.update_project(cfg, function() {
-            // Call plugman --prepare for this platform. sets up js-modules appropriately.
-            var plugins_dir = path.join(projectRoot, 'plugins');
-            events.emit('log', 'Calling plugman.prepare for platform "' + platform + '"');
-            plugman.prepare(platformPath, (platform=='blackberry'?'blackberry10':platform), plugins_dir);
-            // Make sure that config changes for each existing plugin is in place
-            var plugins = cordova_util.findPlugins(plugins_dir);
-            var platform_json = plugman.config_changes.get_platform_json(plugins_dir, (platform=='blackberry'?'blackberry10':platform));
-            plugins && plugins.forEach(function(plugin_id) {
-                if (platform_json.installed_plugins[plugin_id]) {
-                    events.emit('log', 'Ensuring plugin "' + plugin_id + '" is installed correctly...');
-                    plugman.config_changes.add_plugin_changes((platform=='blackberry'?'blackberry10':platform), platformPath, plugins_dir, plugin_id, /* variables for plugin */ platform_json.installed_plugins[plugin_id], /* top level plugin? */ true, /* should increment config munge? cordova-cli never should, only plugman */ false);
-                } else if (platform_json.dependent_plugins[plugin_id]) {
-                    events.emit('log', 'Ensuring plugin "' + plugin_id + '" is installed correctly...');
-                    plugman.config_changes.add_plugin_changes((platform=='blackberry'?'blackberry10':platform), platformPath, plugins_dir, plugin_id, /* variables for plugin */ platform_json.dependent_plugins[plugin_id], /* top level plugin? */ false, /* should increment config munge? cordova-cli never should, only plugman */ false);
-                }
-                events.emit('log', 'Plugin "' + plugin_id + '" is good to go.');
+            // Iterate over each added platform
+            platformList.forEach(function(platform) {
+                var platformPath = path.join(projectRoot, 'platforms', platform);
+                var parser = new platforms[platform].parser(platformPath);
+                parser.update_project(cfg, function() {
+                    // Call plugman --prepare for this platform. sets up js-modules appropriately.
+                    var plugins_dir = path.join(projectRoot, 'plugins');
+                    events.emit('log', 'Calling plugman.prepare for platform "' + platform + '"');
+                    plugman.prepare(platformPath, (platform=='blackberry'?'blackberry10':platform), plugins_dir);
+                    // Make sure that config changes for each existing plugin is in place
+                    var plugins = cordova_util.findPlugins(plugins_dir);
+                    var platform_json = plugman.config_changes.get_platform_json(plugins_dir, (platform=='blackberry'?'blackberry10':platform));
+                    plugins && plugins.forEach(function(plugin_id) {
+                        if (platform_json.installed_plugins[plugin_id]) {
+                            events.emit('log', 'Ensuring plugin "' + plugin_id + '" is installed correctly...');
+                            plugman.config_changes.add_plugin_changes((platform=='blackberry'?'blackberry10':platform), platformPath, plugins_dir, plugin_id, /* variables for plugin */ platform_json.installed_plugins[plugin_id], /* top level plugin? */ true, /* should increment config munge? cordova-cli never should, only plugman */ false);
+                        } else if (platform_json.dependent_plugins[plugin_id]) {
+                            events.emit('log', 'Ensuring plugin "' + plugin_id + '" is installed correctly...');
+                            plugman.config_changes.add_plugin_changes((platform=='blackberry'?'blackberry10':platform), platformPath, plugins_dir, plugin_id, /* variables for plugin */ platform_json.dependent_plugins[plugin_id], /* top level plugin? */ false, /* should increment config munge? cordova-cli never should, only plugman */ false);
+                        }
+                        events.emit('log', 'Plugin "' + plugin_id + '" is good to go.');
+                    });
+                    end();
+                });
             });
-            end();
-        });
+        }
     });
 };

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/bb7c377b/src/run.js
----------------------------------------------------------------------
diff --git a/src/run.js b/src/run.js
index ff7ea17..6913a21 100644
--- a/src/run.js
+++ b/src/run.js
@@ -28,7 +28,7 @@ var cordova_util      = require('./util'),
     n                 = require('ncallbacks');
 
 function shell_out_to_run(projectRoot, platform, callback) {
-    var cmd = '"' + path.join(projectRoot, 'platforms', platform, 'cordova', 'run') + '" --debug --device';
+    var cmd = '"' + path.join(projectRoot, 'platforms', platform, 'cordova', 'run') + '" --device';
     // TODO: inconsistent API for BB10 run command
     if (platform == 'blackberry') {
         var bb_project = path.join(projectRoot, 'platforms', 'blackberry')
@@ -83,35 +83,39 @@ module.exports = function run(platformList, callback) {
     }
 
     var hooks = new hooker(projectRoot);
-    if (!(hooks.fire('before_run'))) {
-        var err = new Error('before_run hooks exited with non-zero code. Aborting.');
-        if (callback) callback(err);
-        else throw err;
-        return;
+    var opts = {
+        platforms:platformList
     }
-
-    var end = n(platformList.length, function() {
-        if (!(hooks.fire('after_run'))) {
-            var err = new Error('after_run hooks exited with non-zero code. Aborting.');
-            if (callback) callback(err);
-            else throw err;
-            return;
-        }
-        if (callback) callback();
-    });
-
-    // Run a prepare first, then shell out to run
-    require('../cordova').prepare(platformList, function(err) {
+    hooks.fire('before_run', opts, function(err) {
         if (err) {
             if (callback) callback(err);
             else throw err;
         } else {
-            platformList.forEach(function(platform) {
-                try {
-                    shell_out_to_run(projectRoot, platform, end);
-                } catch(e) {
-                    if (callback) callback(e);
-                    else throw e;
+            var end = n(platformList.length, function() {
+                hooks.fire('after_run', opts, function(err) {
+                    if (err) {
+                        if (callback) callback(err);
+                        else throw err;
+                    } else {
+                        if (callback) callback();
+                    }
+                });
+            });
+
+            // Run a prepare first, then shell out to run
+            require('../cordova').prepare(platformList, function(err) {
+                if (err) {
+                    if (callback) callback(err);
+                    else throw err;
+                } else {
+                    platformList.forEach(function(platform) {
+                        try {
+                            shell_out_to_run(projectRoot, platform, end);
+                        } catch(e) {
+                            if (callback) callback(e);
+                            else throw e;
+                        }
+                    });
                 }
             });
         }


[10/22] git commit: npm version 2.8.5. [CB-3612] added run command. Cleaned up some tests , removed some duplicate specs, added run specs. Updated help documentation. Updated commands invoked by cordova-cli (compile->./cordova/build, emulate->./cordova/em

Posted by fi...@apache.org.
npm version 2.8.5. [CB-3612] added run command. Cleaned up some tests ,removed some duplicate specs, added run specs. Updated help documentation. Updated commands invoked by cordova-cli (compile->./cordova/build, emulate->./cordova/emulate)


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/05196b36
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/05196b36
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/05196b36

Branch: refs/heads/2.8.x
Commit: 05196b3671422b6d917fcc0ea68d6ae209250bd1
Parents: 1a40e10
Author: Fil Maj <ma...@gmail.com>
Authored: Wed Jun 5 11:54:31 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Jun 6 18:29:03 2013 -0700

----------------------------------------------------------------------
 bin/cordova                                  |    2 +-
 cordova.js                                   |    2 +
 doc/help.txt                                 |   27 +++--
 package.json                                 |    2 +-
 spec/cordova-cli/compile.spec.js             |   74 +++++------
 spec/cordova-cli/create.spec.js              |    2 +
 spec/cordova-cli/emulate.spec.js             |   57 +++++----
 spec/cordova-cli/run.spec.js                 |  138 +++++++++++++++++++++
 spec/platform-script/android/android.spec.js |   10 --
 spec/platform-script/ios/ios.spec.js         |   10 --
 src/compile.js                               |   13 +--
 src/create.js                                |    2 +
 src/emulate.js                               |    6 +-
 src/run.js                                   |  101 +++++++++++++++
 14 files changed, 332 insertions(+), 114 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/05196b36/bin/cordova
----------------------------------------------------------------------
diff --git a/bin/cordova b/bin/cordova
index 941f461..17b3569 100755
--- a/bin/cordova
+++ b/bin/cordova
@@ -33,7 +33,7 @@ if (version) {
     var r;
     if (cmd == 'create' || cmd == 'docs' || cmd == 'serve') {
         r = cordova[cmd].apply(this, opts);
-    } else if (cmd == 'emulate' || cmd == 'build' || cmd == 'prepare' || cmd == 'compile') {
+    } else if (cmd == 'emulate' || cmd == 'build' || cmd == 'prepare' || cmd == 'compile' || cmd == 'run') {
         r = cordova[cmd].call(this, opts);
     } else {
         // platform or plugin cmds

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/05196b36/cordova.js
----------------------------------------------------------------------
diff --git a/cordova.js b/cordova.js
index 73d3a64..efdc4b2 100644
--- a/cordova.js
+++ b/cordova.js
@@ -19,6 +19,7 @@
 var cordova_events = require('./src/events'),
     prepare        = require('./src/prepare'),
     platform       = require('./src/platform'),
+    run            = require('./src/run'),
     hooker         = require('./src/hooker'),
     util           = require('./src/util'),
     path           = require('path'),
@@ -40,6 +41,7 @@ module.exports = {
     platforms: platform,
     prepare:   prepare,
     compile:   compile,
+    run:       run,
     emulate:   require('./src/emulate'),
     plugin:    require('./src/plugin'),
     plugins:   require('./src/plugin'),

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/05196b36/doc/help.txt
----------------------------------------------------------------------
diff --git a/doc/help.txt b/doc/help.txt
index fea484c..73510d0 100644
--- a/doc/help.txt
+++ b/doc/help.txt
@@ -5,23 +5,30 @@ Synopsis
 Global Commands
 
     create [path] [id] [name] ......... creates a cordova project in the specified directory optional name and id (package name, reverse-domain style)
-    -v ................................ prints out this utility's version
 
 Project-Level Commands
 
     platform(s) [add|remove|ls [name]] ... adds or removes a platform, or lists all currently-added platforms
     plugin(s) [add|remove|ls [path]] ..... adds or removes a plugin (from the specified path), or lists all currently-added plugins
-    prepare [platform...] ............. copies files into the specified platforms, or all platforms.
-                                        it is then ready for building by Eclipse/Xcode/etc.
-    compile [platform...] ............. builds the app for the specified (or all) platforms
-    build ............................. alias for prepare and then compile
-    emulate ........................... starts emulator for cordova project
-    serve <platform> [port] ........... runs a local web server for the www/ directory of the given platform
+    prepare [platform...] ................ copies files into the specified platforms, or all platforms
+                                        it is then ready for building by Eclipse/Xcode/etc
+    compile [platform...] ................ builds the app for the specified (or all) platforms
+    build [platform...]................... alias for prepare and then compile
+    emulate [platform...] ................ starts emulator for the specified (or all) platforms, then deploys application to emulator 
+    run [platform...] .................... deployes the application to the specified (or all) platform devices, which must be
+                                        connected and configured for running via your machine
+    serve <platform> [port] .............. runs a local web server for the www/ directory of the given platform
                                         the default port is 8000
                                         note that you must edit the native code to point at the server!
-    ripple <platform> [port] .......... uses the serve command as a base and then wraps the server
-                                        with ripple to test your app in your desktop browser.
-    help .............................. shows this!
+    ripple <platform> [port] ............. uses the serve command as a base and then wraps the server
+                                        with ripple to test your app in your desktop browser
+    help ................................. shows this!
+
+Command-line Flags/Options
+
+    -v, --version ......................... prints out this utility's version
+    -d, --verbose ......................... debug, or verbose, mode. Makes this utility very chatty, logging everything it does, including
+                                        redirecting output of commands it shells out to back to stdout
 
 Example usage
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/05196b36/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 82db18f..f3d386c 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "cordova",
-  "version": "2.8.4",
+  "version": "2.8.5",
   "preferGlobal": "true",
   "description": "Cordova command line interface tool",
   "main": "cordova",

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/05196b36/spec/cordova-cli/compile.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova-cli/compile.spec.js b/spec/cordova-cli/compile.spec.js
index 814d2ab..bd7dc42 100644
--- a/spec/cordova-cli/compile.spec.js
+++ b/spec/cordova-cli/compile.spec.js
@@ -35,53 +35,49 @@ describe('compile command', function() {
         shell.mkdir('-p', tempDir);
     });
 
-    it('should not run inside a Cordova-based project with no added platforms', function() {
-        this.after(function() {
+    describe('failure', function() {
+        afterEach(function() {
             process.chdir(cwd);
+            spyOn(shell, 'exec');
         });
-
-        cordova.create(tempDir);
-        process.chdir(tempDir);
-        expect(function() {
-            cordova.compile();
-        }).toThrow();
-    });
-    
-    it('should run inside a Cordova-based project with at least one added platform', function() {
-        // move platform project fixtures over to fake cordova into thinking platforms were added
-        // TODO: possibly add this to helper?
-        // Just make a folder instead of moving the whole platform? 
-        shell.mkdir('-p', tempDir);
-        shell.mv('-f', path.join(cordova_project, 'platforms', 'android'), path.join(tempDir));
-        this.after(function() {
-            process.chdir(cwd);
-            shell.mv('-f', path.join(tempDir, 'android'), path.join(cordova_project, 'platforms', 'android'));
+        it('should not run inside a Cordova-based project with no added platforms', function() {
+            cordova.create(tempDir);
+            process.chdir(tempDir);
+            expect(function() {
+                cordova.compile();
+            }).toThrow();
+        });
+        it('should not run outside of a Cordova-based project', function() {
+            shell.mkdir('-p', tempDir);
+            process.chdir(tempDir);
+            expect(function() {
+                cordova.compile();
+            }).toThrow();
         });
-
-        process.chdir(cordova_project);
-
-        var sh_spy = spyOn(shell, 'exec');
-
-        expect(function() {
-            cordova.compile();
-            expect(sh_spy).toHaveBeenCalled();
-        }).not.toThrow();
     });
-    it('should not run outside of a Cordova-based project', function() {
-        this.after(function() {
+
+    describe('success', function() {
+        beforeEach(function() {
+            cordova.create(tempDir);
+            shell.cp('-Rf', path.join(cordova_project, 'platforms', 'android'), path.join(tempDir, 'platforms'));
+            process.chdir(tempDir);
+        });
+        afterEach(function() {
             process.chdir(cwd);
         });
+        it('should run inside a Cordova-based project with at least one added platform', function() {
+            // move platform project fixtures over to fake cordova into thinking platforms were added
+            // TODO: possibly add this to helper?
+            var sh_spy = spyOn(shell, 'exec');
 
-        shell.mkdir('-p', tempDir);
-        process.chdir(tempDir);
-
-        // we don't actually want it building the project (if it does somehow exist)
-        var sh_spy = spyOn(shell, 'exec');
-
-        expect(function() {
-            cordova.compile();
-        }).toThrow();
+            expect(function() {
+                cordova.compile();
+                expect(sh_spy).toHaveBeenCalled();
+                expect(sh_spy.mostRecentCall.args[0]).toMatch(/cordova.build"$/gi);
+            }).not.toThrow();
+        });
     });
+
     /* Is this a repeat of the util.spec.js test? */
     it('should not treat a .gitignore file as a platform', function() {
         var gitignore = path.join(cordova_project, 'platforms', '.gitignore');

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/05196b36/spec/cordova-cli/create.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova-cli/create.spec.js b/spec/cordova-cli/create.spec.js
index 8a31ed6..4dad502 100644
--- a/spec/cordova-cli/create.spec.js
+++ b/spec/cordova-cli/create.spec.js
@@ -42,6 +42,8 @@ describe('create command', function () {
         expect(fs.existsSync(path.join(hooks, 'after_emulate'))).toBe(true);
         expect(fs.existsSync(path.join(hooks, 'before_docs'))).toBe(true);
         expect(fs.existsSync(path.join(hooks, 'after_docs'))).toBe(true);
+        expect(fs.existsSync(path.join(hooks, 'before_run'))).toBe(true);
+        expect(fs.existsSync(path.join(hooks, 'after_run'))).toBe(true);
     });
     it('should throw if the directory is already a cordova project', function() {
         shell.mkdir('-p', path.join(tempDir, '.cordova'));

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/05196b36/spec/cordova-cli/emulate.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova-cli/emulate.spec.js b/spec/cordova-cli/emulate.spec.js
index a3e5136..64464cb 100644
--- a/spec/cordova-cli/emulate.spec.js
+++ b/spec/cordova-cli/emulate.spec.js
@@ -37,43 +37,44 @@ describe('emulate command', function() {
         cordova.create(tempDir);
     });
 
-    it('should not run inside a Cordova-based project with no added platforms', function() {
-        this.after(function() {
+    describe('failure', function() {
+        afterEach(function() {
             process.chdir(cwd);
         });
+        it('should not run inside a Cordova-based project with no added platforms', function() {
+            process.chdir(tempDir);
+            expect(function() {
+                cordova.emulate();
+            }).toThrow();
+        });
+        it('should not run outside of a Cordova-based project', function() {
+            shell.mkdir('-p', tempDir);
+            process.chdir(tempDir);
 
-        process.chdir(tempDir);
-        expect(function() {
-            cordova.emulate();
-        }).toThrow();
-    });
-    
-    it('should run inside a Cordova-based project with at least one added platform', function() {
-        this.after(function() {
-            process.chdir(cwd);
+            expect(function() {
+                cordova.emulate();
+            }).toThrow();
         });
+    });
 
-        var s = spyOn(shell, 'exec');
-        var a_spy = spyOn(android_parser.prototype, 'update_project');
-        expect(function() {
+    describe('success', function() {
+        beforeEach(function() {
             shell.cp('-Rf', path.join(cordova_project, 'platforms', 'android'), path.join(tempDir, 'platforms'));
             process.chdir(tempDir);
-            cordova.emulate();
-            a_spy.mostRecentCall.args[1](); // fake out android parser
-            expect(s).toHaveBeenCalled();
-        }).not.toThrow();
-    });
-    it('should not run outside of a Cordova-based project', function() {
-        this.after(function() {
+        });
+        afterEach(function() {
             process.chdir(cwd);
         });
-
-        shell.mkdir('-p', tempDir);
-        process.chdir(tempDir);
-
-        expect(function() {
-            cordova.emulate();
-        }).toThrow();
+        it('should run inside a Cordova-based project with at least one added platform', function() {
+            var s = spyOn(shell, 'exec');
+            var a_spy = spyOn(android_parser.prototype, 'update_project');
+            expect(function() {
+                cordova.emulate();
+                a_spy.mostRecentCall.args[1](); // fake out android parser
+                expect(s).toHaveBeenCalled();
+                expect(s.mostRecentCall.args[0]).toMatch(/cordova.emulate"$/gi);
+            }).not.toThrow();
+        });
     });
 
     describe('hooks', function() {

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/05196b36/spec/cordova-cli/run.spec.js
----------------------------------------------------------------------
diff --git a/spec/cordova-cli/run.spec.js b/spec/cordova-cli/run.spec.js
new file mode 100644
index 0000000..fb4da30
--- /dev/null
+++ b/spec/cordova-cli/run.spec.js
@@ -0,0 +1,138 @@
+/**
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+*/
+var cordova = require('../../cordova'),
+    et = require('elementtree'),
+    shell = require('shelljs'),
+    path = require('path'),
+    fs = require('fs'),
+    config_parser = require('../../src/config_parser'),
+    android_parser = require('../../src/metadata/android_parser'),
+    hooker = require('../../src/hooker'),
+    fixtures = path.join(__dirname, '..', 'fixtures'),
+    hooks = path.join(fixtures, 'hooks'),
+    tempDir = path.join(__dirname, '..', '..', 'temp'),
+    cordova_project = path.join(fixtures, 'projects', 'cordova');
+
+var cwd = process.cwd();
+
+describe('run command', function() {
+    beforeEach(function() {
+        shell.rm('-rf', tempDir);
+        cordova.create(tempDir);
+    });
+
+    describe('failure', function() {
+        afterEach(function() {
+            process.chdir(cwd);
+        });
+        it('should not run inside a Cordova-based project with no added platforms', function() {
+            process.chdir(tempDir);
+            expect(function() {
+                cordova.run();
+            }).toThrow();
+        });
+        it('should not run outside of a Cordova-based project', function() {
+            shell.mkdir('-p', tempDir);
+            process.chdir(tempDir);
+
+            expect(function() {
+                cordova.run();
+            }).toThrow();
+        });
+    });
+    
+    describe('success', function() {
+        beforeEach(function() {
+            shell.cp('-Rf', path.join(cordova_project, 'platforms', 'android'), path.join(tempDir, 'platforms'));
+            process.chdir(tempDir);
+        });
+        afterEach(function() {
+            process.chdir(cwd);
+        });
+        it('should invoke prepare', function() {
+            var spy = spyOn(cordova, 'prepare');
+            spyOn(shell, 'exec');
+            cordova.run();
+            expect(spy).toHaveBeenCalled();
+        });
+        it('should shell out to underlying `run` platform-level scripts', function(done) {
+            spyOn(cordova, 'prepare').andCallFake(function(platforms, callback) {
+                callback(false);
+            });
+            var spy = spyOn(shell, 'exec').andCallFake(function(cmd, options, cb) {
+                cb(0, 'yep');
+            });
+            cordova.run('android', function() {
+                 expect(spy.mostRecentCall.args[0]).toMatch(/cordova.run"$/gi);
+                 done();
+            });
+        });
+    });
+
+
+    describe('hooks', function() {
+        var s;
+        beforeEach(function() {
+            s = spyOn(hooker.prototype, 'fire').andReturn(true);
+        });
+
+        describe('when platforms are added', function() {
+            beforeEach(function() {
+                shell.cp('-Rf', path.join(cordova_project, 'platforms', 'android'), path.join(tempDir, 'platforms'));
+                process.chdir(tempDir);
+            });
+            afterEach(function() {
+                process.chdir(cwd);
+            });
+
+            it('should fire before hooks through the hooker module', function() {
+
+                spyOn(shell, 'exec');
+                cordova.run();
+                expect(hooker.prototype.fire).toHaveBeenCalledWith('before_run');
+            });
+            it('should fire after hooks through the hooker module', function(done) {
+                spyOn(shell, 'exec').andCallFake(function(cmd, options, callback) {
+                    callback(0, 'fucking eh');
+                });
+                cordova.run('android', function() {
+                     expect(hooker.prototype.fire).toHaveBeenCalledWith('after_run');
+                     done();
+                });
+            });
+        });
+
+        describe('with no platforms added', function() {
+            beforeEach(function() {
+                process.chdir(tempDir);
+            });
+            afterEach(function() {
+                process.chdir(cwd);
+            });
+            it('should not fire the hooker', function() {
+                spyOn(shell, 'exec');
+                expect(function() {
+                    cordova.run();
+                }).toThrow();
+                expect(s).not.toHaveBeenCalledWith('before_run');
+                expect(s).not.toHaveBeenCalledWith('after_run');
+            });
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/05196b36/spec/platform-script/android/android.spec.js
----------------------------------------------------------------------
diff --git a/spec/platform-script/android/android.spec.js b/spec/platform-script/android/android.spec.js
index 2433c0a..8890276 100644
--- a/spec/platform-script/android/android.spec.js
+++ b/spec/platform-script/android/android.spec.js
@@ -61,16 +61,6 @@ describe('Test:', function() {
         shell.rm('-rf', tempDir);
         cordova.create(tempDir);
         shell.cp('-rf', path.join(cordova_project, 'platforms', 'android'), path.join(tempDir, 'platforms'));
-        it('should shell out to run command on Android', function() {
-            var proj_spy = spyOn(android_parser.prototype, 'update_project');
-            var s = spyOn(require('shelljs'), 'exec');
-            spyOn(require('plugman'), 'prepare');
-            cordova.emulate('android');
-            proj_spy.mostRecentCall.args[1](); // update_project fake
-            expect(s).toHaveBeenCalled();
-            var emulate_cmd = path.join('android', 'cordova', 'run');
-            expect(s.mostRecentCall.args[0]).toContain(emulate_cmd);
-        });
         it('should call android_parser\'s update_project', function() {
             spyOn(require('shelljs'), 'exec');
             spyOn(android_parser.prototype, 'update_project');

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/05196b36/spec/platform-script/ios/ios.spec.js
----------------------------------------------------------------------
diff --git a/spec/platform-script/ios/ios.spec.js b/spec/platform-script/ios/ios.spec.js
index 04ae4bf..2723b83 100644
--- a/spec/platform-script/ios/ios.spec.js
+++ b/spec/platform-script/ios/ios.spec.js
@@ -62,16 +62,6 @@ describe('Test:', function() {
         shell.rm('-rf', tempDir);
         cordova.create(tempDir);
         shell.cp('-rf', path.join(cordova_project, 'platforms', 'ios'), path.join(tempDir, 'platforms'));
-        it('should shell out to run command on ios', function() {
-            var proj_spy = spyOn(ios_parser.prototype, 'update_project');
-            var s = spyOn(require('shelljs'), 'exec');
-            spyOn(require('plugman'), 'prepare');
-            cordova.emulate('ios');
-            proj_spy.mostRecentCall.args[1](); // update_project fake
-            expect(s).toHaveBeenCalled();
-            var emulate_cmd = path.join('ios', 'cordova', 'run');
-            expect(s.mostRecentCall.args[0]).toContain(emulate_cmd);
-        });
         it('should call ios_parser\'s update_project', function() {
             spyOn(require('shelljs'), 'exec');
             spyOn(ios_parser.prototype, 'update_project');

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/05196b36/src/compile.js
----------------------------------------------------------------------
diff --git a/src/compile.js b/src/compile.js
index 1f550f8..8d9d217 100644
--- a/src/compile.js
+++ b/src/compile.js
@@ -27,15 +27,8 @@ var cordova_util      = require('./util'),
     n                 = require('ncallbacks');
 
 
-function shell_out_to_debug(projectRoot, platform, callback) {
-    var cmd = path.join(projectRoot, 'platforms', platform);
-    // TODO: this is bb10 only for now
-    // TODO: PLATFORM LIBRARY INCONSISTENCY
-    if (platform == 'blackberry') {
-        cmd = 'ant -f "' + path.join(cmd, 'build.xml') + '" qnx load-device';
-    } else {
-        cmd = '"' + path.join(cmd, 'cordova', 'build') + '"';
-    }
+function shell_out_to_build(projectRoot, platform, callback) {
+    var cmd = '"' + path.join(projectRoot, 'platforms', platform, 'cordova', 'build') + '"';
     events.emit('log', 'Compiling platform "' + platform + '" with command "' + cmd + '" (output to follow)...');
     shell.exec(cmd, {silent:true, async:true}, function(code, output) {
         events.emit('log', output);
@@ -96,6 +89,6 @@ module.exports = function compile(platformList, callback) {
 
     // Iterate over each added platform
     platformList.forEach(function(platform) {
-        shell_out_to_debug(projectRoot, platform, end);
+        shell_out_to_build(projectRoot, platform, end);
     });
 };

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/05196b36/src/create.js
----------------------------------------------------------------------
diff --git a/src/create.js b/src/create.js
index 5cced50..be9966c 100644
--- a/src/create.js
+++ b/src/create.js
@@ -78,6 +78,7 @@ module.exports = function create (dir, id, name) {
     shell.mkdir(path.join(hooks, 'after_plugin_ls'));
     shell.mkdir(path.join(hooks, 'after_plugin_rm'));
     shell.mkdir(path.join(hooks, 'after_prepare'));
+    shell.mkdir(path.join(hooks, 'after_run'));
     shell.mkdir(path.join(hooks, 'before_build'));
     shell.mkdir(path.join(hooks, 'before_compile'));
     shell.mkdir(path.join(hooks, 'before_docs'));
@@ -89,6 +90,7 @@ module.exports = function create (dir, id, name) {
     shell.mkdir(path.join(hooks, 'before_plugin_ls'));
     shell.mkdir(path.join(hooks, 'before_plugin_rm'));
     shell.mkdir(path.join(hooks, 'before_prepare'));
+    shell.mkdir(path.join(hooks, 'before_run'));
 
     // Write out .cordova/config.json file with a simple json manifest
     fs.writeFileSync(path.join(dotCordova, 'config.json'), JSON.stringify({

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/05196b36/src/emulate.js
----------------------------------------------------------------------
diff --git a/src/emulate.js b/src/emulate.js
index 9ccfc0b..9dd8857 100644
--- a/src/emulate.js
+++ b/src/emulate.js
@@ -31,11 +31,7 @@ var cordova_util      = require('./util'),
     util              = require('util');
 
 function shell_out_to_emulate(root, platform, callback) {
-    var cmd = '"' + path.join(root, 'platforms', platform, 'cordova', 'run') + '"';
-    // TODO: PLATFORM LIBRARY INCONSISTENCY 
-    if (platform == 'blackberry') {
-        cmd = 'ant -f "' + path.join(root, 'platforms', platform, 'build.xml') + '" qnx load-simulator';
-    }
+    var cmd = '"' + path.join(root, 'platforms', platform, 'cordova', 'emulate') + '"';
     events.emit('log', 'Running on emulator for platform "' + platform + '" via command "' + cmd + '" (output to follow)...');
     shell.exec(cmd, {silent:true, async:true}, function(code, output) {
         events.emit('log', output);

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/05196b36/src/run.js
----------------------------------------------------------------------
diff --git a/src/run.js b/src/run.js
new file mode 100644
index 0000000..c13e4ab
--- /dev/null
+++ b/src/run.js
@@ -0,0 +1,101 @@
+/**
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+*/
+var cordova_util      = require('./util'),
+    path              = require('path'),
+    config_parser     = require('./config_parser'),
+    fs                = require('fs'),
+    shell             = require('shelljs'),
+    et                = require('elementtree'),
+    hooker            = require('./hooker'),
+    events            = require('./events'),
+    n                 = require('ncallbacks');
+
+function shell_out_to_run(projectRoot, platform, callback) {
+    var cmd = '"' + path.join(projectRoot, 'platforms', platform, 'cordova', 'run') + '"';
+
+    events.emit('log', 'Running app on platform "' + platform + '" with command "' + cmd + '" (output to follow)...');
+    shell.exec(cmd, {silent:true, async:true}, function(code, output) {
+        events.emit('log', output);
+        if (code > 0) {
+            throw new Error('An error occurred while running the ' + platform + ' project. ' + output);
+        } else {
+            events.emit('log', 'Platform "' + platform + '" ran successfully.');
+            if (callback) callback();
+        }
+    });
+}
+
+module.exports = function run(platformList, callback) {
+    var projectRoot = cordova_util.isCordova(process.cwd());
+
+    if (!projectRoot) {
+        var err = new Error('Current working directory is not a Cordova-based project.');
+        if (callback) callback(err);
+        else throw err;
+        return;
+    }
+
+    var xml = cordova_util.projectConfig(projectRoot);
+    var cfg = new config_parser(xml);
+
+    if (arguments.length === 0 || (platformList instanceof Array && platformList.length === 0)) {
+        platformList = cordova_util.listPlatforms(projectRoot);
+    } else if (typeof platformList == 'string') platformList = [platformList];
+    else if (platformList instanceof Function && callback === undefined) {
+        callback = platformList;
+        platformList = cordova_util.listPlatforms(projectRoot);
+    }
+
+    if (platformList.length === 0) {
+        var err = new Error('No platforms added to this project. Please use `cordova platform add <platform>`.');
+        if (callback) callback(err);
+        else throw err;
+        return;
+    }
+
+    var hooks = new hooker(projectRoot);
+    if (!(hooks.fire('before_run'))) {
+        var err = new Error('before_run hooks exited with non-zero code. Aborting.');
+        if (callback) callback(err);
+        else throw err;
+        return;
+    }
+
+    var end = n(platformList.length, function() {
+        if (!(hooks.fire('after_run'))) {
+            var err = new Error('after_run hooks exited with non-zero code. Aborting.');
+            if (callback) callback(err);
+            else throw err;
+            return;
+        }
+        if (callback) callback();
+    });
+
+    // Run a prepare first, then shell out to run
+    require('../cordova').prepare(platformList, function(err) {
+        if (err) {
+            if (callback) callback(err);
+            else throw err;
+        } else {
+            platformList.forEach(function(platform) {
+                shell_out_to_run(projectRoot, platform, end);
+            });
+        }
+    });
+};