Repository: cordova-cli
Updated Branches:
  refs/heads/master 34f61cdf0 -> 05eb4a3fa


CB-9964 Added --template support to Cordova Create


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

Branch: refs/heads/master
Commit: 05eb4a3fab2a8560aad93d26a0d0f70c286acf8d
Parents: 34f61cd
Author: dubeejw <[email protected]>
Authored: Thu Nov 5 15:55:14 2015 -0500
Committer: Carlos Santana <[email protected]>
Committed: Thu Dec 3 16:54:29 2015 -0500

----------------------------------------------------------------------
 doc/create.txt |  5 ++--
 src/cli.js     | 79 +++++++++++++++++++++++++++++++++--------------------
 src/create.js  |  2 +-
 3 files changed, 53 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/05eb4a3f/doc/create.txt
----------------------------------------------------------------------
diff --git a/doc/create.txt b/doc/create.txt
index 50aa354..d3cab64 100644
--- a/doc/create.txt
+++ b/doc/create.txt
@@ -11,5 +11,6 @@ Create a Cordova project
                                     [PATH]/.cordova-cli/config.json
 
     Options:
-        --copy-from|src=<PATH> ... use custom www assets instead of the stock 
Cordova hello-world.
-        --link-to=<PATH> ......... symlink to custom www assets without 
creating a copy.
+        --template=<PATH|NPM PACKAGE|GIT URL> ... use a custom template 
located locally, in NPM, or GitHub.
+        --copy-from|src=<PATH> .................. deprecated, use --template 
instead.
+        --link-to=<PATH> ........................ symlink to custom www assets 
without creating a copy.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/05eb4a3f/src/cli.js
----------------------------------------------------------------------
diff --git a/src/cli.js b/src/cli.js
index 05d17db..b5b7103 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -96,6 +96,7 @@ function cli(inputArgs) {
         , 'nobuild': Boolean
         , 'list': Boolean
         , 'buildConfig' : String
+        , 'template' : String
         };
 
     var shortHands =
@@ -103,6 +104,7 @@ function cli(inputArgs) {
         , 'v' : '--version'
         , 'h' : '--help'
         , 'src' : '--copy-from'
+        , 't' : '--template'
         };
 
     // If no inputArgs given, use process.argv.
@@ -114,7 +116,6 @@ function cli(inputArgs) {
 
     var args = nopt(knownOpts, shortHands, inputArgs);
 
-
     if (args.version) {
         var cliVersion = require('../package').version;
         var libVersion = require('cordova-lib/package').version;
@@ -288,35 +289,7 @@ function cli(inputArgs) {
         var port = undashed[1];
         cordova.raw.serve(port).done();
     } else if (cmd == 'create') {
-        var cfg = {};
-        // If we got a fourth parameter, consider it to be JSON to init the 
config.
-        if ( undashed[4] ) {
-            cfg = JSON.parse(undashed[4]);
-        }
-        var customWww = args['copy-from'] || args['link-to'];
-        if (customWww) {
-            if (customWww.indexOf('http') === 0) {
-                throw new CordovaError(
-                    'Only local paths for custom www assets are supported.'
-                );
-            }
-            if ( customWww.substr(0,1) === '~' ) {  // resolve tilde in a 
naive way.
-                customWww = path.join(process.env.HOME,  customWww.substr(1));
-            }
-            customWww = path.resolve(customWww);
-            var wwwCfg = { url: customWww };
-            if (args['link-to']) {
-                wwwCfg.link = true;
-            }
-            cfg.lib = cfg.lib || {};
-            cfg.lib.www = wwwCfg;
-        }
-        // create(dir, id, name, cfg)
-        cordova.raw.create( undashed[1]  // dir to create the project in
-                          , undashed[2]  // App id
-                          , undashed[3]  // App name
-                          , cfg
-        ).done();
+        create();
     } else {
         // platform/plugins add/rm [target(s)]
         subcommand = undashed[1]; // sub-command like "add", "ls", "rm" etc.
@@ -343,4 +316,50 @@ function cli(inputArgs) {
                             };
         cordova.raw[cmd](subcommand, targets, download_opts).done();
     }
+
+    function create() {
+        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 = {};
+
+        customWww = args['copy-from'] || args['link-to'] || args.template;
+
+        if (customWww) {
+            if (!args.template && customWww.indexOf('http') === 0) {
+                throw new CordovaError(
+                    'Only local paths for custom www assets are supported.'
+                );
+            }
+
+            // Resolve tilda
+            if (customWww.substr(0,1) === '~')
+                customWww = path.join(process.env.HOME,  customWww.substr(1));
+
+            wwwCfg = {
+                url: customWww,
+                template: false
+            };
+
+            if (args['link-to'])
+                wwwCfg.link = true;
+            else if (args.template)
+                wwwCfg.template = true;
+
+            cfg.lib = cfg.lib || {};
+            cfg.lib.www = wwwCfg;
+        }
+
+        // create(dir, id, name, cfg)
+        cordova.raw.create( undashed[1]  // dir to create the project in
+            , undashed[2]  // App id
+            , undashed[3]  // App name
+            , cfg
+        ).done();
+    }
 }

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/05eb4a3f/src/create.js
----------------------------------------------------------------------
diff --git a/src/create.js b/src/create.js
index 6a509ce..8ec2956 100644
--- a/src/create.js
+++ b/src/create.js
@@ -62,8 +62,8 @@ CordovaCliCreate.prototype.parseConfig = function (jsondata) {
         process.exit(2); 
     }
 };
-
 CordovaCliCreate.prototype.customWww = function (args) {
+
     // handle custom www
     if (customWww = args['copy-from'] || args['link-to']) {
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to