cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an-s...@apache.org
Subject cordova-cli git commit: CB-8898 Introduces `cordova requirements` command
Date Wed, 06 May 2015 08:17:30 GMT
Repository: cordova-cli
Updated Branches:
  refs/heads/master 2ce84c7e0 -> 27db65b74


CB-8898 Introduces `cordova requirements` 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/27db65b7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/27db65b7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/27db65b7

Branch: refs/heads/master
Commit: 27db65b748c29a2a1e4e03fc5ff05ff638f14b92
Parents: 2ce84c7
Author: Vladimir Kotikov <v-vlkoti@microsoft.com>
Authored: Thu Apr 23 10:55:30 2015 +0300
Committer: Vladimir Kotikov <v-vlkoti@microsoft.com>
Committed: Tue May 5 12:19:56 2015 +0300

----------------------------------------------------------------------
 doc/requirements.txt |  7 ++++++
 src/cli.js           | 54 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/27db65b7/doc/requirements.txt
----------------------------------------------------------------------
diff --git a/doc/requirements.txt b/doc/requirements.txt
new file mode 100644
index 0000000..4c18726
--- /dev/null
+++ b/doc/requirements.txt
@@ -0,0 +1,7 @@
+Synopsis
+
+    cordova-cli requirements [PLATFORM ...]
+
+Checks and print out all the requirements for platforms specified (or all platforms added
+to project if none specified). If all requirements for each platform are met exits with code
0
+otherwise exits with non-zero code.

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/27db65b7/src/cli.js
----------------------------------------------------------------------
diff --git a/src/cli.js b/src/cli.js
index 8f6f87a..c96c4e3 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -241,6 +241,60 @@ function cli(inputArgs) {
         }
 
         cordova.raw[cmd].call(null, opts).done();
+    } else if (cmd === 'requirements') {
+        // All options without dashes are assumed to be platform names
+        opts.platforms = undashed.slice(1);
+        var badPlatforms = _.difference(opts.platforms, known_platforms);
+        if( !_.isEmpty(badPlatforms) ) {
+            msg = 'Unknown platforms: ' + badPlatforms.join(', ');
+            throw new CordovaError(msg);
+        }
+
+        // CB-6976 Windows Universal Apps. Allow mixing windows and windows8 aliases
+        opts.platforms = opts.platforms.map(function(platform) {
+            // allow using old windows8 alias for new unified windows platform
+            if (platform == 'windows8' && fs.existsSync('platforms/windows')) {
+                return 'windows';
+            }
+            // allow using new windows alias for old windows8 platform
+            if (platform == 'windows' &&
+                !fs.existsSync('platforms/windows') &&
+                fs.existsSync('platforms/windows8')) {
+                return 'windows8';
+            }
+            return platform;
+        });
+
+        cordova.raw[cmd].call(null, opts.platforms)
+        .then(function (platformChecks) {
+
+            var someChecksFailed = Object.keys(platformChecks).map(function (platformName)
{
+                events.emit('log', '\nRequirements check results for ' + platformName + ':');
+                var platformCheck = platformChecks[platformName];
+                if (platformCheck instanceof CordovaError) {
+                    events.emit('warn', 'Check failed for ' + platformName + ' due to ' +
platformCheck);
+                    return true;
+                }
+
+                var someChecksFailed = false;
+                platformCheck.forEach(function (checkItem) {
+                    var checkSummary = checkItem.name + ': ' +
+                                    (checkItem.installed ? 'installed ' : 'not installed
') +
+                                    (checkItem.metadata.version || '');
+                    events.emit('log', checkSummary);
+                    if (!checkItem.installed) {
+                        someChecksFailed = true;
+                        events.emit('warn', checkItem.metadata.reason);
+                    }
+                });
+
+                return someChecksFailed;
+            }).some(function (isCheckFailedForPlatform) {
+                return isCheckFailedForPlatform;
+            });
+
+            if (someChecksFailed) throw new CordovaError('Some of requirements check failed');
+        }).done();
     } else if (cmd == 'serve') {
         var port = undashed[1];
         cordova.raw.serve(port).done();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message