cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tim...@apache.org
Subject [3/3] android commit: [CB-4872] - added android version scripts
Date Sat, 19 Oct 2013 00:24:43 GMT
[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 <timk@adobe.com>
Authored: Mon Sep 23 14:01:03 2013 -0700
Committer: Tim Kim <timk@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();
+}
+


Mime
View raw message