You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2014/09/10 18:44:22 UTC
[1/2] android commit: Use add --compact flag in check_reqs when
listing targets. No functional change.
Repository: cordova-android
Updated Branches:
refs/heads/master 0e78dc35d -> bf13fd48c
Use add --compact flag in check_reqs when listing targets. No functional change.
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/bf13fd48
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/bf13fd48
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/bf13fd48
Branch: refs/heads/master
Commit: bf13fd48ceb23a671a03ddfe4400003b70b72a9d
Parents: 3b99760
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed Sep 10 12:43:40 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Sep 10 12:44:17 2014 -0400
----------------------------------------------------------------------
bin/lib/check_reqs.js | 39 ++++++++++++++++++++++-----------------
1 file changed, 22 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/bf13fd48/bin/lib/check_reqs.js
----------------------------------------------------------------------
diff --git a/bin/lib/check_reqs.js b/bin/lib/check_reqs.js
index d2b3dcf..00137ff 100644
--- a/bin/lib/check_reqs.js
+++ b/bin/lib/check_reqs.js
@@ -48,20 +48,21 @@ function tryCommand(cmd, errMsg) {
// Get valid target from framework/project.properties
module.exports.get_target = function() {
- if(fs.existsSync(path.join(ROOT, 'framework', 'project.properties'))) {
- var target = shelljs.grep(/target=android-[\d+]/, path.join(ROOT, 'framework', 'project.properties'));
- return target.split('=')[1].replace('\n', '').replace('\r', '').replace(' ', '');
- } else if (fs.existsSync(path.join(ROOT, 'project.properties'))) {
- // if no target found, we're probably in a project and project.properties is in ROOT.
- // this is called on the project itself, and can support Google APIs AND Vanilla Android
- var target = shelljs.grep(/target=android-[\d+]/, path.join(ROOT, 'project.properties')) ||
- shelljs.grep(/target=Google Inc.:Google APIs:[\d+]/, path.join(ROOT, 'project.properties'));
- if(target == "" || !target) {
- // Try Google Glass APIs
- target = shelljs.grep(/target=Google Inc.:Glass Development Kit Preview:[\d+]/, path.join(ROOT, 'project.properties'));
+ function extractFromFile(filePath) {
+ var target = shelljs.grep(/\btarget=/, filePath);
+ if (!target) {
+ throw new Error('Could not find android target within: ' + filePath);
}
- return target.split('=')[1].replace('\n', '').replace('\r', '');
+ return target.split('=')[1].trim();
+ }
+ if (fs.existsSync(path.join(ROOT, 'framework', 'project.properties'))) {
+ return extractFromFile(path.join(ROOT, 'framework', 'project.properties'));
+ }
+ if (fs.existsSync(path.join(ROOT, 'project.properties'))) {
+ // if no target found, we're probably in a project and project.properties is in ROOT.
+ return extractFromFile(path.join(ROOT, 'project.properties'));
}
+ throw new Error('Could not find android target. File missing: ' + path.join(ROOT, 'project.properties'));
}
// Returns a promise. Called only by build and clean commands.
@@ -180,13 +181,17 @@ module.exports.check_android = function() {
};
module.exports.check_android_target = function(valid_target) {
+ // valid_target can look like:
+ // android-19
+ // android-L
+ // Google Inc.:Google APIs:20
+ // Google Inc.:Glass Development Kit Preview:20
var msg = 'Failed to run "android". Make sure you have the latest Android SDK installed, and that the "android" command (inside the tools/ folder) is added to your PATH.';
- return tryCommand('android list targets', msg)
+ return tryCommand('android list targets --compact', msg)
.then(function(output) {
- if (!output.match(valid_target)) {
- throw new Error('Please install Android target "' + valid_target + '".\n' +
- output + '\n\n' +
- 'Hint: Install it using the SDK manager by running: ' + forgivingWhichSync('android'));
+ if (output.split('\n').indexOf(valid_target) == -1) {
+ throw new Error('Please install Android target: "' + valid_target + '".\n' +
+ 'Hint: Open the SDK manager by running: ' + forgivingWhichSync('android'));
}
});
};
[2/2] android commit: CB-7330 Don't run check_reqs for bin/create.
Posted by ag...@apache.org.
CB-7330 Don't run check_reqs for bin/create.
The create / update script doesn't require any dependencies, so we
shouldn't fail without them.
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/3b99760a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/3b99760a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/3b99760a
Branch: refs/heads/master
Commit: 3b99760a4250bfd8b357584d2657f6b25a1ce152
Parents: 0e78dc3
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed Sep 10 12:42:37 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Sep 10 12:44:17 2014 -0400
----------------------------------------------------------------------
bin/lib/create.js | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/3b99760a/bin/lib/create.js
----------------------------------------------------------------------
diff --git a/bin/lib/create.js b/bin/lib/create.js
index c4c6f1b..0b79533 100755
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -226,10 +226,6 @@ exports.createProject = function(project_path, package_name, project_name, proje
return validatePackageName(package_name)
.then(function() {
validateProjectName(project_name);
- })
- // Check that requirements are met and proper targets are installed
- .then(function() {
- return check_reqs.run();
}).then(function() {
// Log the given values for the project
console.log('Creating Cordova project for the Android platform:');
@@ -305,8 +301,7 @@ function extractProjectNameFromManifest(projectPath) {
// Returns a promise.
exports.updateProject = function(projectPath, shared) {
var newVersion = fs.readFileSync(path.join(ROOT, 'VERSION'), 'utf-8').trim();
- // Check that requirements are met and proper targets are installed
- return check_reqs.run()
+ return Q()
.then(function() {
var projectName = extractProjectNameFromManifest(projectPath);
var target_api = check_reqs.get_target();