cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [3/4] cordova-cli git commit: CB-12570 : updated based on feedback and rebased from master.
Date Thu, 20 Apr 2017 01:14:37 GMT
CB-12570 : updated based on feedback and rebased from master.


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

Branch: refs/heads/master
Commit: 5cd8b35a27f422f109fcbe375e5bee3a3928d224
Parents: 7740bcb
Author: Audrey So <audreyso@apache.org>
Authored: Mon Mar 20 10:13:17 2017 -0700
Committer: Steve Gill <stevengill97@gmail.com>
Committed: Wed Apr 19 18:07:51 2017 -0700

----------------------------------------------------------------------
 doc/platform.txt |   8 ++--
 doc/readme.md    |  12 +++---
 spec/cli.spec.js | 115 ++++++++++++++++++++++----------------------------
 src/cli.js       |  86 ++++++++++++++++++-------------------
 4 files changed, 103 insertions(+), 118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5cd8b35a/doc/platform.txt
----------------------------------------------------------------------
diff --git a/doc/platform.txt b/doc/platform.txt
index 29bad89..199d451 100644
--- a/doc/platform.txt
+++ b/doc/platform.txt
@@ -15,14 +15,16 @@ Manage project platforms
                                         varies by platform; useful for platform development)
         
         --nofetch ..................... Prevent fetching the plugin into the project's node_modules

-                                        directory. Prevent using `npm install` to do the
fetching.
+                                        directory. Uses older fetching method (pre cordova-7)

+                                        instead of using npm install under the hood
 
     remove <platform> [...] ........... Remove specified platforms
 
         --nosave ...................... Prevent deleting specified platforms from 
                                         config.xml & package.json after removing them
         --nofetch ..................... Prevent removing the plugin from the project's node_modules

-                                        directory. Prevent running `npm uninstall` under
the hood.
+                                        directory. Uses older fetching method (pre cordova-7)

+                                        instead of using npm install under the hood
 
     update <plat-spec> ................ Update the version of Cordova used for a specific
platform;
                                         update to the latest <version> if no <plat-spec>
is specified
@@ -31,8 +33,6 @@ Manage project platforms
     check ............................. List platforms which can be updated by `cordova-cli
platform update`
     nosave ............................ Prevents saving version of all platforms added to

                                         config.xml & package.json
-    nofetch ........................... Prevents fetching the plugin into the project's node_modules

-                                        directory.
 Syntax
     <plat-spec> : <platform>[@<version>]|<path>|<url>[#<commit-ish>]
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5cd8b35a/doc/readme.md
----------------------------------------------------------------------
diff --git a/doc/readme.md b/doc/readme.md
index ba1189e..283a545 100644
--- a/doc/readme.md
+++ b/doc/readme.md
@@ -83,12 +83,10 @@ Certain commands have options (`platformOpts`) that are specific to a
particular
         cd myApp
         # Add camera plugin to the project and remember that in config.xml & package.json.
Do not use npm install to fetch.
         cordova plugin add cordova-plugin-camera --nofetch
-        # Add camera plugin to the project and remember that in config.xml. Use npm install
to fetch.
-        cordova plugin add cordova-plugin-camera --save --fetch
-        # Add android platform to the project and remember that in config.xml & package.json.
-        cordova platform add android
-        # Add android platform to the project and remember that in config.xml. Do not use
npm install to fetch.
-        cordova platform add android --save --nofetch
+        # Add camera plugin to the project and remember that in config.xml and package.json.
Uses pre cordova@7 fetching methods instead of cordova-fetch which uses npm install under
the hood.
+        cordova plugin add cordova-plugin-camera --nofetch
+        # Add android platform to the project and remember that in config.xml & package.json.
Uses pre cordova@7 fetching methods instead of cordova-fetch which uses npm install under
the hood
+        cordova platform add android --nofetch
         # Check to see if your system is configured for building android platform.
         cordova requirements android
         # Build the android and emit verbose logs.
@@ -404,7 +402,7 @@ based on the following criteria (listed in order of precedence):
 
         cordova plugin rm camera --nosave
 
-- Do not remove the plugin from the project and `npm uninstall` it. Do not remove it from
the `node_modules` directory:
+- Remove the plugin from the project. Do not remove it from the node_modules directory and
don't run npm uninstall under the hood:
 
         cordova plugin rm camera --nofetch
 

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5cd8b35a/spec/cli.spec.js
----------------------------------------------------------------------
diff --git a/spec/cli.spec.js b/spec/cli.spec.js
index 5bb2fb2..daa6e2e 100644
--- a/spec/cli.spec.js
+++ b/spec/cli.spec.js
@@ -190,7 +190,20 @@ describe("cordova cli", function () {
             });
         });
 
-        it("Test #015 : will pass save:false", function (done) {
+        it("Test #015 : (add) will pass save:true", function (done) {
+            cli(["node", "cordova", "plugin", "add", "device"], function () {
+                expect(cordova.raw.plugin).toHaveBeenCalledWith(
+                    "add",
+                    ["device"],
+                    jasmine.any(Object)
+                );
+                var opts = cordova.raw.plugin.calls.argsFor(0)[2];
+                expect(opts.save).toBe(true);
+                done();
+            });
+        });
+
+        it("Test #016 : (add) will pass save:false", function (done) {
             cli(["node", "cordova", "plugin", "add", "device", "--nosave"], function () {
                 expect(cordova.raw.plugin).toHaveBeenCalledWith(
                     "add",
@@ -203,10 +216,10 @@ describe("cordova cli", function () {
             });
         });
 
-        it("Test #017 : will pass save:false", function (done) {
+        it("Test #017: (remove) will pass save:false", function (done) {
             cli(["node", "cordova", "plugin", "remove", "device", "--nosave"], function ()
{
                 expect(cordova.raw.plugin).toHaveBeenCalledWith(
-                    "add",
+                    "remove",
                     ["device"],
                     jasmine.any(Object)
                 );
@@ -216,7 +229,20 @@ describe("cordova cli", function () {
             });
         });
 
-        it("Test #034 : (add) will pass fetch:false", function (done) {
+        it("Test #018 : (remove) autosave is default and will pass save:true", function (done)
{
+            cli(["node", "cordova", "plugin", "remove", "device"], function () {
+                expect(cordova.raw.plugin).toHaveBeenCalledWith(
+                    "remove",
+                    ["device"],
+                    jasmine.any(Object)
+                );
+                var opts = cordova.raw.plugin.calls.argsFor(0)[2];
+                expect(opts.save).toBe(true);
+                done();
+            });
+        });
+
+        it("Test #019 : (add) will pass fetch:false", function (done) {
             cli(["node", "cordova", "plugin", "add", "device", "--nofetch"], function ()
{
               expect(cordova.raw.plugin).toHaveBeenCalledWith(
                   "add",
@@ -229,33 +255,20 @@ describe("cordova cli", function () {
             });
         });
 
-        it("Test #035 : (add) fetch is true by default and will pass fetch:true", function
(done) {
+        it("Test #020 : (add) fetch is true by default and will pass fetch:true", function
(done) {
             cli(["node", "cordova", "plugin", "add", "device"], function () {
                 expect(cordova.raw.plugin).toHaveBeenCalledWith(
-                    "remove",
-                    ["device"],
-                    jasmine.any(Object)
-                );
-                var opts = cordova.raw.plugin.calls.argsFor(0)[2];
-                expect(opts.save).toBe(false);
-                done();
-            });
-        });
-
-        it("Test #018 : autosave is default and will pass save:true", function (done) {
-            cli(["node", "cordova", "plugin", "remove", "device"], function () {
-                expect(cordova.raw.plugin).toHaveBeenCalledWith(
-                    "remove",
+                    "add",
                     ["device"],
                     jasmine.any(Object)
                 );
                 var opts = cordova.raw.plugin.calls.argsFor(0)[2];
-                expect(opts.save).toBe(true);
+                expect(opts.fetch).toBe(true);
                 done();
             });
         });
 
-        it("Test #036 : (remove) fetch is true by default and will pass fetch:true", function
(done) {
+        it("Test #021 : (remove) fetch is true by default and will pass fetch:true", function
(done) {
             cli(["node", "cordova", "plugin", "remove", "device"], function () {
                 expect(cordova.raw.plugin).toHaveBeenCalledWith(
                     "remove",
@@ -263,12 +276,12 @@ describe("cordova cli", function () {
                     jasmine.any(Object)
                 );
                 var opts = cordova.raw.plugin.calls.argsFor(0)[2];
-                expect(opts.save).toBe(true);
+                expect(opts.fetch).toBe(true);
                 done();
             });
         });
 
-        it("Test #037 : (remove) will pass fetch:false", function (done) {
+        it("Test #022 : (remove) will pass fetch:false", function (done) {
             cli(["node", "cordova", "plugin", "remove", "device", "--nofetch"], function
() {
                 expect(cordova.raw.plugin).toHaveBeenCalledWith(
                     "remove",
@@ -283,7 +296,7 @@ describe("cordova cli", function () {
     });
     
     describe("telemetry", function() {
-       it("Test#019 : skips prompt when user runs 'cordova telemetry X'", function(done)
{
+       it("Test#023 : skips prompt when user runs 'cordova telemetry X'", function(done)
{
            var wasPromptShown = false;
            spyOn(telemetry, "showPrompt").and.callFake(function () {
                wasPromptShown = true;
@@ -297,7 +310,7 @@ describe("cordova cli", function () {
            });         
        });
        
-       it("Test#020 : is NOT collected when user runs 'cordova telemetry on' while NOT opted-in",
function(done) {
+       it("Test#024 : is NOT collected when user runs 'cordova telemetry on' while NOT opted-in",
function(done) {
            spyOn(telemetry, "isOptedIn").and.returnValue(false);
            spyOn(telemetry, "isCI").and.returnValue(false);
            
@@ -309,7 +322,7 @@ describe("cordova cli", function () {
            });
        });
        
-       it("Test#021 : is collected when user runs 'cordova telemetry off' while opted-in",
function(done) {
+       it("Test#025 : is collected when user runs 'cordova telemetry off' while opted-in",
function(done) {
            spyOn(telemetry, "isOptedIn").and.returnValue(true);
            spyOn(telemetry, "isCI").and.returnValue(false);
            
@@ -321,7 +334,7 @@ describe("cordova cli", function () {
            });
        });
        
-       it("Test#022 : tracks platforms/plugins subcommands", function(done) {
+       it("Test#026 : tracks platforms/plugins subcommands", function(done) {
            spyOn(telemetry, "isOptedIn").and.returnValue(true);
            spyOn(telemetry, "isCI").and.returnValue(false);
            spyOn(telemetry, "hasUserOptedInOrOut").and.returnValue(true);
@@ -335,7 +348,7 @@ describe("cordova cli", function () {
            });
        });
        
-       it("Test#023 : shows prompt if user neither opted in or out yet", function(done) {
+       it("Test#027 : shows prompt if user neither opted in or out yet", function(done) {
            spyOn(cordova.raw, "prepare").and.returnValue(Q());
            spyOn(telemetry, "hasUserOptedInOrOut").and.returnValue(false);
            
@@ -351,7 +364,7 @@ describe("cordova cli", function () {
 
        // ToDO: Figure out a way to modify default timeout
        // ... Timeout overriding isn't working anymore due to a bug with jasmine-node
-       xit("Test#024 : opts-out if prompt times out AND it tracks opt-out", function(done)
{
+       xit("Test#028 : opts-out if prompt times out AND it tracks opt-out", function(done)
{
            // Remove any optOut settings that might have been saved
            // ... and force prompt to be shown
            telemetry.clear();
@@ -366,7 +379,7 @@ describe("cordova cli", function () {
            });
        }/*, 45000*/);
        
-       it("Test#025 : is NOT collected in CI environments and doesn't prompt", function(done)
{
+       it("Test#029 : is NOT collected in CI environments and doesn't prompt", function(done)
{
            spyOn(telemetry, "hasUserOptedInOrOut").and.returnValue(true);
            spyOn(telemetry, "isOptedIn").and.returnValue(true);
            spyOn(telemetry, "isCI").and.returnValue(true);
@@ -381,7 +394,7 @@ describe("cordova cli", function () {
            });
        });
        
-       it("Test#026 : is NOT collected when --no-telemetry flag found and doesn't prompt",
function(done) {
+       it("Test#030 : is NOT collected when --no-telemetry flag found and doesn't prompt",
function(done) {
            spyOn(telemetry, "hasUserOptedInOrOut").and.returnValue(false);
            spyOn(telemetry, "isOptedIn").and.returnValue(true);
            spyOn(telemetry, "isCI").and.returnValue(false);
@@ -396,7 +409,7 @@ describe("cordova cli", function () {
            });
        });
        
-       it("Test#027 : is NOT collected if user opted out", function(done) {
+       it("Test#031 : is NOT collected if user opted out", function(done) {
            spyOn(telemetry, "hasUserOptedInOrOut").and.returnValue(true);
            spyOn(telemetry, "isOptedIn").and.returnValue(false);
            spyOn(telemetry, "isCI").and.returnValue(false);
@@ -411,7 +424,7 @@ describe("cordova cli", function () {
            });
        });
        
-       it("Test#028 : is collected if user opted in", function(done) {
+       it("Test#032 : is collected if user opted in", function(done) {
            spyOn(telemetry, "hasUserOptedInOrOut").and.returnValue(true);
            spyOn(telemetry, "isOptedIn").and.returnValue(true);
            spyOn(telemetry, "isCI").and.returnValue(false);
@@ -426,7 +439,7 @@ describe("cordova cli", function () {
            });
        });
        
-       it("Test#029 : track opt-out that happened via 'cordova telemetry off' even if user
is NOT opted-in ", function(done) {
+       it("Test#033 : track opt-out that happened via 'cordova telemetry off' even if user
is NOT opted-in ", function(done) {
            spyOn(telemetry, "isCI").and.returnValue(false);
            spyOn(telemetry, "isOptedIn").and.returnValue(false); // same as calling `telemetry.turnOff();`
            spyOn(telemetry, "hasUserOptedInOrOut").and.returnValue(true);
@@ -448,7 +461,7 @@ describe("platform", function () {
         spyOn(cordova.raw, "platform").and.returnValue(Q());
     });
 
-    it("Test #030 : autosave is the default setting for platform add", function (done) {
+    it("Test #034 : (add) autosave is the default setting for platform add", function (done)
{
         cli(["node", "cordova", "platform", "add", "ios"], function () {
             expect(cordova.raw.platform).toHaveBeenCalledWith(
                 "add",
@@ -461,7 +474,7 @@ describe("platform", function () {
         });
     });
 
-    it("Test #031 : platform is not saved when --nosave is passed in", function (done) {
+    it("Test #035 : (add) platform is not saved when --nosave is passed in", function (done)
{
         cli(["node", "cordova", "platform", "add", "ios", "--nosave"], function () {
             expect(cordova.raw.platform).toHaveBeenCalledWith(
                 "add",
@@ -474,7 +487,7 @@ describe("platform", function () {
         });
     });
 
-    it("Test #032 : autosave is the default setting for platform remove", function (done)
{
+    it("Test #036 : (remove) autosave is the default setting for platform remove", function
(done) {
         cli(["node", "cordova", "platform", "remove", "ios"], function () {
             expect(cordova.raw.platform).toHaveBeenCalledWith(
                 "remove",
@@ -487,7 +500,7 @@ describe("platform", function () {
         });
     });
 
-    it("Test #033 : platform is not removed when --nosave is passed in", function (done)
{
+    it("Test #037 : (remove) platform is not removed when --nosave is passed in", function
(done) {
         cli(["node", "cordova", "platform", "remove", "ios", "--nosave"], function () {
             expect(cordova.raw.platform).toHaveBeenCalledWith(
                 "remove",
@@ -500,32 +513,6 @@ describe("platform", function () {
         });
     });
 
-    it("Test #036 : will pass fetch:false", function (done) {
-        cli(["node", "cordova", "platform", "add", "device", "--nofetch"], function () {
-            expect(cordova.raw.platform).toHaveBeenCalledWith(
-                "add",
-                ["device"],
-                jasmine.any(Object)
-            );
-            var opts = cordova.raw.platform.calls.argsFor(0)[2];
-            expect(opts.fetch).toBe(false);
-            done();
-        });
-    });
-
-    it("Test #037 : fetch is true by default and will pass fetch:true", function (done) {
-        cli(["node", "cordova", "platform", "add", "device"], function () {
-            expect(cordova.raw.platform).toHaveBeenCalledWith(
-                "add",
-                ["device"],
-                jasmine.any(Object)
-            );
-            var opts = cordova.raw.platform.calls.argsFor(0)[2];
-            expect(opts.fetch).toBe(true);
-            done();
-        });
-    });
-
     it("Test #038 : (add) will pass fetch:false", function (done) {
         cli(["node", "cordova", "platform", "add", "device", "--nofetch"], function () {
           expect(cordova.raw.platform).toHaveBeenCalledWith(

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5cd8b35a/src/cli.js
----------------------------------------------------------------------
diff --git a/src/cli.js b/src/cli.js
index bdda821..63b7763 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -453,6 +453,7 @@ function cli(inputArgs) {
             args.save = false;
         } else {
             args.save = true;
+        }
 
         if (args.save === undefined) {
             // User explicitly did not pass in save
@@ -477,59 +478,58 @@ function cli(inputArgs) {
                             , save: args.save
                             , shrinkwrap: args.shrinkwrap || false
                             , force: args.force || false
-
         };
         return cordova.raw[cmd](subcommand, targets, download_opts);
     }
 }
 
- function create(undashed, args) {
-        var cfg;            // Create config
-        var customWww;      // Template path
-        var wwwCfg;         // Template config
-
-        // If we got a fourth parameter, consider it to be JSON to init the config.
-        if (undashed[4])
-            cfg = JSON.parse(undashed[4]);
-        else
-            cfg = {};
+function create(undashed, args) {
+    var cfg;            // Create config
+    var customWww;      // Template path
+    var wwwCfg;         // Template config
 
-        customWww = args['copy-from'] || args['link-to'] || args.template;
+    // If we got a fourth parameter, consider it to be JSON to init the config.
+    if (undashed[4])
+        cfg = JSON.parse(undashed[4]);
+    else
+        cfg = {};
 
-        if (customWww) {
-            if (!args.template && !args['copy-from'] && customWww.indexOf('http')
=== 0) {
-                throw new CordovaError(
-                    'Only local paths for custom www assets are supported for linking' +
customWww
-                );
-            }
+    customWww = args['copy-from'] || args['link-to'] || args.template;
 
-            // Resolve tilda
-            if (customWww.substr(0,1) === '~')
-                customWww = path.join(process.env.HOME,  customWww.substr(1));
+    if (customWww) {
+        if (!args.template && !args['copy-from'] && customWww.indexOf('http')
=== 0) {
+            throw new CordovaError(
+                'Only local paths for custom www assets are supported for linking' + customWww
+            );
+        }
 
-            wwwCfg = {
-                url: customWww,
-                template: false,
-                link: false
-            };
+        // Resolve tilda
+        if (customWww.substr(0,1) === '~')
+            customWww = path.join(process.env.HOME,  customWww.substr(1));
 
-            if (args['link-to']) {
-                wwwCfg.link = true;
-            }
-            if (args.template) {
-                wwwCfg.template = true;
-            } else if (args['copy-from']) {
-                logger.warn('Warning: --copy-from option is being deprecated. Consider using
--template instead.');
-                wwwCfg.template = true;
-            }
+        wwwCfg = {
+            url: customWww,
+            template: false,
+            link: false
+        };
 
-            cfg.lib = cfg.lib || {};
-            cfg.lib.www = wwwCfg;
+        if (args['link-to']) {
+            wwwCfg.link = true;
+        }
+        if (args.template) {
+            wwwCfg.template = true;
+        } else if (args['copy-from']) {
+            logger.warn('Warning: --copy-from option is being deprecated. Consider using
--template instead.');
+            wwwCfg.template = true;
         }
-        return cordova.raw.create( undashed[1]  // dir to create the project in
-            , undashed[2]  // App id
-            , undashed[3]  // App name
-            , cfg
-            , events || undefined
-        );
+
+        cfg.lib = cfg.lib || {};
+        cfg.lib.www = wwwCfg;
     }
+    return cordova.raw.create( undashed[1]  // dir to create the project in
+        , undashed[2]  // App id
+        , undashed[3]  // App name
+        , cfg
+        , events || undefined
+    );
+}


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


Mime
View raw message