cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [2/5] cordova-create git commit: CB-12765: default app cordova-app-hello-world is now treated like a template
Date Mon, 08 May 2017 14:30:09 GMT
CB-12765: default app cordova-app-hello-world is now treated like a template


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

Branch: refs/heads/1.1.x
Commit: a60bfa309115dd6f7079dd6af3165e8214d96a08
Parents: 37d329d
Author: Steve Gill <stevengill97@gmail.com>
Authored: Thu May 4 17:31:25 2017 +0200
Committer: Steve Gill <stevengill97@gmail.com>
Committed: Thu May 4 17:34:57 2017 +0200

----------------------------------------------------------------------
 index.js            |  6 +++---
 spec/create.spec.js | 27 +++++++++++++++++++++------
 2 files changed, 24 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-create/blob/a60bfa30/index.js
----------------------------------------------------------------------
diff --git a/index.js b/index.js
index d29b8a4..827f158 100644
--- a/index.js
+++ b/index.js
@@ -133,7 +133,8 @@ module.exports = function(dir, optionalId, optionalName, cfg, extEvents)
{
 
         if (!cfg.lib.www.url) {
             try {
-                cfg.lib.www.url = require('cordova-app-hello-world').dirname;
+                cfg.lib.www.url = require.resolve('cordova-app-hello-world');
+                cfg.lib.www.template = true;
             } catch (e) {
                 // Falling back on npm@2 path hierarchy
                 // TODO: Remove fallback after cordova-app-hello-world release
@@ -229,7 +230,7 @@ module.exports = function(dir, optionalId, optionalName, cfg, extEvents)
{
             // Delete cached require incase one exists
             delete require.cache[require.resolve(input_directory)];
             var templatePkg = require(input_directory);
-            if (templatePkg && templatePkg.dirname){
+            if (templatePkg && templatePkg.dirname) {
                 import_from_path = templatePkg.dirname;
                 isSubDir = true;
             }
@@ -255,7 +256,6 @@ module.exports = function(dir, optionalId, optionalName, cfg, extEvents)
{
         paths.hooks = path.join(require('cordova-app-hello-world').dirname, 'hooks');
         
         // ToDo: get stock package.json if template does not contain package.json;
-
         var dirAlreadyExisted = fs.existsSync(dir);
         if (!dirAlreadyExisted) {
             fs.mkdirSync(dir);

http://git-wip-us.apache.org/repos/asf/cordova-create/blob/a60bfa30/spec/create.spec.js
----------------------------------------------------------------------
diff --git a/spec/create.spec.js b/spec/create.spec.js
index 407ee46..f8db27e 100644
--- a/spec/create.spec.js
+++ b/spec/create.spec.js
@@ -109,7 +109,6 @@ describe('cordova create checks for valid-identifier', function() {
 
 
 describe('create end-to-end', function() {
-    //this.timeout(240000);
 
     beforeEach(function() {
         shell.rm('-rf', project);
@@ -203,9 +202,25 @@ describe('create end-to-end', function() {
     var results;
     events.on('results', function(res) { results = res; });
 
+    it('should successfully run without template and use default hello-world app', function(done)
{
+        // Create a real project with no template
+        // use default cordova-app-hello-world app
+        return create(project, appId, appName, {}, events)
+        .then(checkProject)
+        .then(function() {
+            delete require.cache[require.resolve(path.join(project, 'package.json'))];
+            var pkgJson = require(path.join(project, 'package.json'));
+            //confirm default hello world app copies over package.json and it matched appId
+            expect(pkgJson.name).toEqual(appId);
+        }).fail(function(err) {
+            console.log(err && err.stack);
+            expect(err).toBeUndefined();
+        })
+        .fin(done);
+    }, 60000);
+
     it('should successfully run with Git URL', function(done) {
-        // Call cordova create with no args, should return help.)
-        // Create a real project
+        // Create a real project with gitURL as template
         return create(project, appId, appName, configGit, events)
         .then(checkProject)
         .fail(function(err) {
@@ -217,9 +232,9 @@ describe('create end-to-end', function() {
 
     it('should successfully run with NPM package and not use old cache of template on second
create', function(done) {
         var templatePkgJsonPath = path.join(global_config_path, 'node_modules', 'phonegap-template-vue-f7-tabs',
'package.json');
-        // Call cordova create with no args, should return help.
-        // Create a real project
-        //uses phonegap-template-vue-f7-tabs
+        // Create a real project with npm module as template
+        // tests cache clearing of npm template
+        // uses phonegap-template-vue-f7-tabs
         return create(project, appId, appName, configNPMold)
         .then(checkProject)
         .then(function() {


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


Mime
View raw message