You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ti...@apache.org on 2013/10/19 02:24:41 UTC

[1/3] android commit: CB-4872 - moved version script to promise model

Updated Branches:
  refs/heads/master 5ab11edad -> 28c41294b


CB-4872 - moved version script to promise model


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

Branch: refs/heads/master
Commit: 28c41294bba746c75beae0ab26a42c8412cc665a
Parents: 82898da
Author: Tim Kim <ti...@adobe.com>
Authored: Fri Oct 18 15:56:42 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Fri Oct 18 17:13:57 2013 -0700

----------------------------------------------------------------------
 bin/android_sdk_version        |  6 +++++-
 bin/lib/android_sdk_version.js | 30 +++++++++++++++++++++---------
 2 files changed, 26 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/28c41294/bin/android_sdk_version
----------------------------------------------------------------------
diff --git a/bin/android_sdk_version b/bin/android_sdk_version
index e4c8bb5..547f41b 100755
--- a/bin/android_sdk_version
+++ b/bin/android_sdk_version
@@ -21,5 +21,9 @@
 
 var android_sdk_version = require('./lib/android_sdk_version');
 
-android_sdk_version.run();
+android_sdk_version.run().done(null, function(err) {
+    console.log(err);
+    process.exit(2);
+});
+
 

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/28c41294/bin/lib/android_sdk_version.js
----------------------------------------------------------------------
diff --git a/bin/lib/android_sdk_version.js b/bin/lib/android_sdk_version.js
index e8a1b1b..d03e1e7 100755
--- a/bin/lib/android_sdk_version.js
+++ b/bin/lib/android_sdk_version.js
@@ -19,7 +19,9 @@
        under the License.
 */
 
-var shell = require('shelljs');
+var shell = require('shelljs'),
+    child_process = require('child_process'),
+    Q     = require('q');
 
 get_highest_sdk = function(results){
     var reg = /\d+/;
@@ -32,22 +34,32 @@ get_highest_sdk = function(results){
 }
 
 get_sdks = function() {
-    var targets = shell.exec('android list targets', {silent:true, async:false});
+    var d = Q.defer();
+    child_process.exec('android list targets', function(err, stdout, stderr) {
+        if (err) d.reject(stderr);
+        else d.resolve(stdout);
+    });
 
-    if(targets.code > 0 && targets.output.match(/command\snot\sfound/)) {
-        return new Error('The command \"android\" failed. Make sure you have the latest Android SDK installed, and the \"android\" command (inside the tools/ folder) is added to your path.');
-    } else {
+    return d.promise.then(function(output) {
         var reg = /android-\d+/gi;
-        var results = targets.output.match(reg);
+        var results = output.match(reg);
         if(results.length===0){
-            return new Error('No android sdks installed.');
+            return Q.reject(new Error('No android sdks installed.'));
         }else{
             get_highest_sdk(results);
         }
-    }
+
+        return Q();
+    }, function(stderr) {
+        if (stderr.match(/command\snot\sfound/)) {
+            return Q.reject(new Error('The command \"android\" failed. Make sure you have the latest Android SDK installed, and the \"android\" command (inside the tools/ folder) is added to your path.'));
+        } else {
+            return Q.reject(new Error('An error occurred while listing Android targets'));
+        }
+    });
 }
 
 module.exports.run = function() {
-    get_sdks();
+    return Q.all([get_sdks()]);
 }
 


[3/3] android commit: [CB-4872] - added android version scripts

Posted by ti...@apache.org.
[CB-4872] - added android version scripts


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

Branch: refs/heads/master
Commit: eabcdbf129c711cc76ee3e8052fbb49f565988f3
Parents: 5ab11ed
Author: Tim Kim <ti...@adobe.com>
Authored: Mon Sep 23 14:01:03 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Fri Oct 18 17:13:57 2013 -0700

----------------------------------------------------------------------
 bin/android_sdk_version        | 25 +++++++++++++++++
 bin/android_sdk_version.bat    | 26 ++++++++++++++++++
 bin/lib/android_sdk_version.js | 53 +++++++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/eabcdbf1/bin/android_sdk_version
----------------------------------------------------------------------
diff --git a/bin/android_sdk_version b/bin/android_sdk_version
new file mode 100755
index 0000000..e4c8bb5
--- /dev/null
+++ b/bin/android_sdk_version
@@ -0,0 +1,25 @@
+#!/usr/bin/env node
+
+/*
+       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 android_sdk_version = require('./lib/android_sdk_version');
+
+android_sdk_version.run();
+

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/eabcdbf1/bin/android_sdk_version.bat
----------------------------------------------------------------------
diff --git a/bin/android_sdk_version.bat b/bin/android_sdk_version.bat
new file mode 100644
index 0000000..33a1fa2
--- /dev/null
+++ b/bin/android_sdk_version.bat
@@ -0,0 +1,26 @@
+:: 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 script_path="%~dp0android_sdk_version"
+IF EXIST %script_path% (
+        node "%script_path%" %*
+) ELSE (
+    ECHO.
+    ECHO ERROR: Could not find 'android_sdk_version' script in 'bin' folder, aborting...>&2
+    EXIT /B 1
+)

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/eabcdbf1/bin/lib/android_sdk_version.js
----------------------------------------------------------------------
diff --git a/bin/lib/android_sdk_version.js b/bin/lib/android_sdk_version.js
new file mode 100755
index 0000000..e8a1b1b
--- /dev/null
+++ b/bin/lib/android_sdk_version.js
@@ -0,0 +1,53 @@
+#!/usr/bin/env node
+
+/*
+       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 shell = require('shelljs');
+
+get_highest_sdk = function(results){
+    var reg = /\d+/;
+    var apiLevels = [];
+    for(var i=0;i<results.length;i++){
+        apiLevels[i] = parseInt(results[i].match(reg)[0]);
+    }
+    apiLevels.sort(function(a,b){return b-a});
+    console.log(apiLevels[0]);
+}
+
+get_sdks = function() {
+    var targets = shell.exec('android list targets', {silent:true, async:false});
+
+    if(targets.code > 0 && targets.output.match(/command\snot\sfound/)) {
+        return new Error('The command \"android\" failed. Make sure you have the latest Android SDK installed, and the \"android\" command (inside the tools/ folder) is added to your path.');
+    } else {
+        var reg = /android-\d+/gi;
+        var results = targets.output.match(reg);
+        if(results.length===0){
+            return new Error('No android sdks installed.');
+        }else{
+            get_highest_sdk(results);
+        }
+    }
+}
+
+module.exports.run = function() {
+    get_sdks();
+}
+


[2/3] android commit: CB-4872 - make sure to copy over version scripts to project

Posted by ti...@apache.org.
CB-4872 - make sure to copy over version scripts to project


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

Branch: refs/heads/master
Commit: 82898da507f2522f4b647372b95e5490cebb8490
Parents: eabcdbf
Author: Tim Kim <ti...@adobe.com>
Authored: Thu Oct 17 13:36:44 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Fri Oct 18 17:13:57 2013 -0700

----------------------------------------------------------------------
 bin/lib/create.js | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/82898da5/bin/lib/create.js
----------------------------------------------------------------------
diff --git a/bin/lib/create.js b/bin/lib/create.js
index 9ba460d..7b015ac 100755
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -85,7 +85,8 @@ function copyScripts(projectPath) {
     shell.cp('-r', path.join(ROOT, 'bin', 'node_modules'), destScriptsDir);
     shell.cp(path.join(ROOT, 'bin', 'check_reqs'), path.join(destScriptsDir, 'check_reqs'));
     shell.cp(path.join(ROOT, 'bin', 'lib', 'check_reqs.js'), path.join(projectPath, 'cordova', 'lib', 'check_reqs.js'));
-
+    shell.cp(path.join(ROOT, 'bin', 'android_sdk_version'), path.join(destScriptsDir, 'android_sdk_version'));
+    shell.cp(path.join(ROOT, 'bin', 'lib', 'android_sdk_version.js'), path.join(projectPath, 'cordova', 'lib', 'android_sdk_version.js'));
 }
 
 /**