cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From csantan...@apache.org
Subject cordova-lib git commit: CB-10808 CLI Support templates with subdirectory
Date Tue, 15 Mar 2016 21:02:16 GMT
Repository: cordova-lib
Updated Branches:
  refs/heads/master d779242e8 -> 07354885e


CB-10808 CLI Support templates with subdirectory

 This closes #410


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

Branch: refs/heads/master
Commit: 07354885e62b4c1c48577e9ed878e8c45193443c
Parents: d779242
Author: Carlos Santana <csantana23@gmail.com>
Authored: Mon Mar 14 12:17:58 2016 -0400
Committer: Carlos Santana <csantana23@gmail.com>
Committed: Tue Mar 15 16:58:13 2016 -0400

----------------------------------------------------------------------
 cordova-lib/spec-cordova/create.spec.js         | 105 +++++++++++++++++--
 .../templates/nopackage_json/config.xml         |  45 ++++++++
 .../templates/nopackage_json/www/index.html     |  49 +++++++++
 .../templates/withpackage_json/config.xml       |  45 ++++++++
 .../templates/withpackage_json/pacakge.json     |  14 +++
 .../templates/withpackage_json/www/index.html   |  49 +++++++++
 .../templates/withsubdirectory/index.js         |   4 +
 .../templates/withsubdirectory/package.json     |  11 ++
 .../withsubdirectory/template/config.xml        |  45 ++++++++
 .../withsubdirectory/template/www/index.html    |  49 +++++++++
 .../withsubdirectory_package_json/index.js      |   4 +
 .../withsubdirectory_package_json/package.json  |  11 ++
 .../template/config.xml                         |  45 ++++++++
 .../template/package.json                       |  10 ++
 .../template/www/index.html                     |  49 +++++++++
 cordova-lib/src/cordova/create.js               |  23 +++-
 16 files changed, 550 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/create.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/create.spec.js b/cordova-lib/spec-cordova/create.spec.js
index 1f4be51..99579a2 100644
--- a/cordova-lib/spec-cordova/create.spec.js
+++ b/cordova-lib/spec-cordova/create.spec.js
@@ -35,8 +35,7 @@ var configNormal = {
       lib: {
         www: {
           url: path.join(__dirname, 'fixtures', 'base', 'www'),
-          version: 'testCordovaCreate',
-          id: appName
+          version: 'testCordovaCreate'
         }
       }
     };
@@ -54,8 +53,7 @@ var configGit = {
         www: {
             url: 'https://github.com/apache/cordova-app-hello-world',
             template: true,
-            version: 'not_versioned',
-            id: appName
+            version: 'not_versioned'
         }
     }
 };
@@ -65,8 +63,7 @@ var configNPM = {
         www: {
             template: true,
             url: 'cordova-app-hello-world',
-            version: '',
-            id: appName
+            version: ''
         }
     }
 };
@@ -194,6 +191,102 @@ describe('create end-to-end', function() {
             })
             .fin(done);
     });
+    
+    it('should successfully run with template not having a package.json at toplevel', function(done)
{
+        // Call cordova create with no args, should return help.
+        var config = {
+            lib: {
+                www: {
+                    template: true,
+                    url: path.join(__dirname, 'fixtures', 'templates', 'nopackage_json'),
+                    version: ''
+                }
+            }
+        };
+        Q()
+            .then(function() {
+                // Create a real project
+                return cordova.raw.create(project, appId, appName, config);
+            })
+            .then(checkProject)
+            .fail(function(err) {
+                console.log(err && err.stack);
+                expect(err).toBeUndefined();
+            })
+            .fin(done);
+    });
+    
+    it('should successfully run with template having package.json and no sub directory',
function(done) {
+        // Call cordova create with no args, should return help.
+        var config = {
+            lib: {
+                www: {
+                    template: true,
+                    url: path.join(__dirname, 'fixtures', 'templates', 'withpackage_json'),
+                    version: ''
+                }
+            }
+        };
+        Q()
+            .then(function() {
+                // Create a real project
+                return cordova.raw.create(project, appId, appName, config);
+            })
+            .then(checkProject)
+            .fail(function(err) {
+                console.log(err && err.stack);
+                expect(err).toBeUndefined();
+            })
+            .fin(done);
+    });
+    
+    it('should successfully run with template having package.json, and subdirectory, and
no package.json in subdirectory', function(done) {
+        // Call cordova create with no args, should return help.
+        var config = {
+            lib: {
+                www: {
+                    template: true,
+                    url: path.join(__dirname, 'fixtures', 'templates', 'withsubdirectory'),
+                    version: ''
+                }
+            }
+        };
+        Q()
+            .then(function() {
+                // Create a real project
+                return cordova.raw.create(project, appId, appName, config);
+            })
+            .then(checkProject)
+            .fail(function(err) {
+                console.log(err && err.stack);
+                expect(err).toBeUndefined();
+            })
+            .fin(done);
+    });
+    
+    it('should successfully run with template having package.json, and subdirectory, and
package.json in subdirectory', function(done) {
+        // Call cordova create with no args, should return help.
+        var config = {
+            lib: {
+                www: {
+                    template: true,
+                    url: path.join(__dirname, 'fixtures', 'templates', 'withsubdirectory_package_json'),
+                    version: ''
+                }
+            }
+        };
+        Q()
+            .then(function() {
+                // Create a real project
+                return cordova.raw.create(project, appId, appName, config);
+            })
+            .then(checkProject)
+            .fail(function(err) {
+                console.log(err && err.stack);
+                expect(err).toBeUndefined();
+            })
+            .fin(done);
+    });
 
 
 

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/nopackage_json/config.xml
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/nopackage_json/config.xml b/cordova-lib/spec-cordova/fixtures/templates/nopackage_json/config.xml
new file mode 100644
index 0000000..02e616c
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/nopackage_json/config.xml
@@ -0,0 +1,45 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0">
+    <name>HelloCordova</name>
+    <description>
+        A sample Apache Cordova application that responds to the deviceready event.
+    </description>
+    <author email="dev@cordova.apache.org" href="http://cordova.io">
+        Apache Cordova Team
+    </author>
+    <content src="index.html" />
+    <!-- Whitelist configuration. Refer to https://cordova.apache.org/docs/en/edge/guide_appdev_whitelist_index.md.html
-->
+    <plugin name="cordova-plugin-whitelist" spec="1" />
+    <access origin="*" />
+    <allow-intent href="http://*/*" />
+    <allow-intent href="https://*/*" />
+    <allow-intent href="tel:*" />
+    <allow-intent href="sms:*" />
+    <allow-intent href="mailto:*" />
+    <allow-intent href="geo:*" />
+    <platform name="android">
+        <allow-intent href="market:*" />
+    </platform>
+    <platform name="ios">
+        <allow-intent href="itms:*" />
+        <allow-intent href="itms-apps:*" />
+    </platform>
+</widget>

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/nopackage_json/www/index.html
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/nopackage_json/www/index.html b/cordova-lib/spec-cordova/fixtures/templates/nopackage_json/www/index.html
new file mode 100644
index 0000000..646f9cb
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/nopackage_json/www/index.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+     KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+<html>
+    <head>
+        <!--
+        Customize this policy to fit your own app's needs. For more guidance, see:
+            https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy
+        Some notes:
+            * gap: is required only on iOS (when using UIWebView) and is needed for JS->native
communication
+            * https://ssl.gstatic.com is required only on Android and is needed for TalkBack
to function properly
+            * Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities.
To change this:
+                * Enable inline JS: add 'unsafe-inline' to default-src
+        -->
+        <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap:
https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
+        <meta name="format-detection" content="telephone=no">
+        <meta name="msapplication-tap-highlight" content="no">
+        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1,
minimum-scale=1, width=device-width">
+        <link rel="stylesheet" type="text/css" href="css/index.css">
+        <title>Hello World</title>
+    </head>
+    <body>
+        <div class="app">
+            <h1>Apache Cordova</h1>
+            <div id="deviceready" class="blink">
+                <p class="event listening">Connecting to Device</p>
+                <p class="event received">Device is Ready</p>
+            </div>
+        </div>
+        <script type="text/javascript" src="cordova.js"></script>
+        <script type="text/javascript" src="js/index.js"></script>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/config.xml
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/config.xml b/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/config.xml
new file mode 100644
index 0000000..02e616c
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/config.xml
@@ -0,0 +1,45 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0">
+    <name>HelloCordova</name>
+    <description>
+        A sample Apache Cordova application that responds to the deviceready event.
+    </description>
+    <author email="dev@cordova.apache.org" href="http://cordova.io">
+        Apache Cordova Team
+    </author>
+    <content src="index.html" />
+    <!-- Whitelist configuration. Refer to https://cordova.apache.org/docs/en/edge/guide_appdev_whitelist_index.md.html
-->
+    <plugin name="cordova-plugin-whitelist" spec="1" />
+    <access origin="*" />
+    <allow-intent href="http://*/*" />
+    <allow-intent href="https://*/*" />
+    <allow-intent href="tel:*" />
+    <allow-intent href="sms:*" />
+    <allow-intent href="mailto:*" />
+    <allow-intent href="geo:*" />
+    <platform name="android">
+        <allow-intent href="market:*" />
+    </platform>
+    <platform name="ios">
+        <allow-intent href="itms:*" />
+        <allow-intent href="itms-apps:*" />
+    </platform>
+</widget>

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/pacakge.json
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/pacakge.json b/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/pacakge.json
new file mode 100644
index 0000000..ef6f89e
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/pacakge.json
@@ -0,0 +1,14 @@
+{
+  "name": "template",
+  "version": "1.0.0",
+  "description": "Apache Cordova Application",
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/apache/cordova-app-hello-world.git"
+  },
+  "license": "Apache-2.0",
+  "scripts": {
+    "preinstall": "echo \"Yay npm preinstall script\" ",
+    "postinstall": "echo \"Yay npm postinstall script\" "
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/www/index.html
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/www/index.html b/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/www/index.html
new file mode 100644
index 0000000..646f9cb
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withpackage_json/www/index.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+     KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+<html>
+    <head>
+        <!--
+        Customize this policy to fit your own app's needs. For more guidance, see:
+            https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy
+        Some notes:
+            * gap: is required only on iOS (when using UIWebView) and is needed for JS->native
communication
+            * https://ssl.gstatic.com is required only on Android and is needed for TalkBack
to function properly
+            * Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities.
To change this:
+                * Enable inline JS: add 'unsafe-inline' to default-src
+        -->
+        <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap:
https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
+        <meta name="format-detection" content="telephone=no">
+        <meta name="msapplication-tap-highlight" content="no">
+        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1,
minimum-scale=1, width=device-width">
+        <link rel="stylesheet" type="text/css" href="css/index.css">
+        <title>Hello World</title>
+    </head>
+    <body>
+        <div class="app">
+            <h1>Apache Cordova</h1>
+            <div id="deviceready" class="blink">
+                <p class="event listening">Connecting to Device</p>
+                <p class="event received">Device is Ready</p>
+            </div>
+        </div>
+        <script type="text/javascript" src="cordova.js"></script>
+        <script type="text/javascript" src="js/index.js"></script>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/index.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/index.js b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/index.js
new file mode 100644
index 0000000..4cb425b
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/index.js
@@ -0,0 +1,4 @@
+var path = require('path');
+module.exports = {
+  "dirname": path.join(__dirname, 'template')
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/package.json
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/package.json b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/package.json
new file mode 100644
index 0000000..51cbb55
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/package.json
@@ -0,0 +1,11 @@
+{
+  "name": "template",
+  "version": "1.0.0",
+  "description": "Apache Cordova Application",
+  "main": "index.js",
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/apache/cordova-app-hello-world.git"
+  },
+  "license": "Apache-2.0"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/template/config.xml
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/template/config.xml
b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/template/config.xml
new file mode 100644
index 0000000..02e616c
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/template/config.xml
@@ -0,0 +1,45 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0">
+    <name>HelloCordova</name>
+    <description>
+        A sample Apache Cordova application that responds to the deviceready event.
+    </description>
+    <author email="dev@cordova.apache.org" href="http://cordova.io">
+        Apache Cordova Team
+    </author>
+    <content src="index.html" />
+    <!-- Whitelist configuration. Refer to https://cordova.apache.org/docs/en/edge/guide_appdev_whitelist_index.md.html
-->
+    <plugin name="cordova-plugin-whitelist" spec="1" />
+    <access origin="*" />
+    <allow-intent href="http://*/*" />
+    <allow-intent href="https://*/*" />
+    <allow-intent href="tel:*" />
+    <allow-intent href="sms:*" />
+    <allow-intent href="mailto:*" />
+    <allow-intent href="geo:*" />
+    <platform name="android">
+        <allow-intent href="market:*" />
+    </platform>
+    <platform name="ios">
+        <allow-intent href="itms:*" />
+        <allow-intent href="itms-apps:*" />
+    </platform>
+</widget>

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/template/www/index.html
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/template/www/index.html
b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/template/www/index.html
new file mode 100644
index 0000000..646f9cb
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory/template/www/index.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+     KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+<html>
+    <head>
+        <!--
+        Customize this policy to fit your own app's needs. For more guidance, see:
+            https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy
+        Some notes:
+            * gap: is required only on iOS (when using UIWebView) and is needed for JS->native
communication
+            * https://ssl.gstatic.com is required only on Android and is needed for TalkBack
to function properly
+            * Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities.
To change this:
+                * Enable inline JS: add 'unsafe-inline' to default-src
+        -->
+        <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap:
https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
+        <meta name="format-detection" content="telephone=no">
+        <meta name="msapplication-tap-highlight" content="no">
+        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1,
minimum-scale=1, width=device-width">
+        <link rel="stylesheet" type="text/css" href="css/index.css">
+        <title>Hello World</title>
+    </head>
+    <body>
+        <div class="app">
+            <h1>Apache Cordova</h1>
+            <div id="deviceready" class="blink">
+                <p class="event listening">Connecting to Device</p>
+                <p class="event received">Device is Ready</p>
+            </div>
+        </div>
+        <script type="text/javascript" src="cordova.js"></script>
+        <script type="text/javascript" src="js/index.js"></script>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/index.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/index.js
b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/index.js
new file mode 100644
index 0000000..4cb425b
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/index.js
@@ -0,0 +1,4 @@
+var path = require('path');
+module.exports = {
+  "dirname": path.join(__dirname, 'template')
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/package.json
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/package.json
b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/package.json
new file mode 100644
index 0000000..51cbb55
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/package.json
@@ -0,0 +1,11 @@
+{
+  "name": "template",
+  "version": "1.0.0",
+  "description": "Apache Cordova Application",
+  "main": "index.js",
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/apache/cordova-app-hello-world.git"
+  },
+  "license": "Apache-2.0"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/config.xml
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/config.xml
b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/config.xml
new file mode 100644
index 0000000..02e616c
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/config.xml
@@ -0,0 +1,45 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0">
+    <name>HelloCordova</name>
+    <description>
+        A sample Apache Cordova application that responds to the deviceready event.
+    </description>
+    <author email="dev@cordova.apache.org" href="http://cordova.io">
+        Apache Cordova Team
+    </author>
+    <content src="index.html" />
+    <!-- Whitelist configuration. Refer to https://cordova.apache.org/docs/en/edge/guide_appdev_whitelist_index.md.html
-->
+    <plugin name="cordova-plugin-whitelist" spec="1" />
+    <access origin="*" />
+    <allow-intent href="http://*/*" />
+    <allow-intent href="https://*/*" />
+    <allow-intent href="tel:*" />
+    <allow-intent href="sms:*" />
+    <allow-intent href="mailto:*" />
+    <allow-intent href="geo:*" />
+    <platform name="android">
+        <allow-intent href="market:*" />
+    </platform>
+    <platform name="ios">
+        <allow-intent href="itms:*" />
+        <allow-intent href="itms-apps:*" />
+    </platform>
+</widget>

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/package.json
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/package.json
b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/package.json
new file mode 100644
index 0000000..30a86ba
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/package.json
@@ -0,0 +1,10 @@
+{
+  "name": "template",
+  "version": "1.0.0",
+  "description": "Apache Cordova Application",
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/apache/cordova-app-hello-world.git"
+  },
+  "license": "Apache-2.0"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/www/index.html
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/www/index.html
b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/www/index.html
new file mode 100644
index 0000000..646f9cb
--- /dev/null
+++ b/cordova-lib/spec-cordova/fixtures/templates/withsubdirectory_package_json/template/www/index.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+     KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+<html>
+    <head>
+        <!--
+        Customize this policy to fit your own app's needs. For more guidance, see:
+            https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy
+        Some notes:
+            * gap: is required only on iOS (when using UIWebView) and is needed for JS->native
communication
+            * https://ssl.gstatic.com is required only on Android and is needed for TalkBack
to function properly
+            * Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities.
To change this:
+                * Enable inline JS: add 'unsafe-inline' to default-src
+        -->
+        <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap:
https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
+        <meta name="format-detection" content="telephone=no">
+        <meta name="msapplication-tap-highlight" content="no">
+        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1,
minimum-scale=1, width=device-width">
+        <link rel="stylesheet" type="text/css" href="css/index.css">
+        <title>Hello World</title>
+    </head>
+    <body>
+        <div class="app">
+            <h1>Apache Cordova</h1>
+            <div id="deviceready" class="blink">
+                <p class="event listening">Connecting to Device</p>
+                <p class="event received">Device is Ready</p>
+            </div>
+        </div>
+        <script type="text/javascript" src="cordova.js"></script>
+        <script type="text/javascript" src="js/index.js"></script>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/07354885/cordova-lib/src/cordova/create.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/create.js b/cordova-lib/src/cordova/create.js
index 5d8cef7..9150020 100644
--- a/cordova-lib/src/cordova/create.js
+++ b/cordova-lib/src/cordova/create.js
@@ -220,8 +220,19 @@ function create(dir, optionalId, optionalName, cfg) {
             }
         }
     })
-    .then(function(import_from_path) {
-
+    .then(function(input_directory) {
+        var import_from_path = input_directory;
+        
+        //handle when input wants to specify sub-directory 
+        try {
+            var templatePkg = require(input_directory);
+            if (templatePkg && templatePkg.dirname){
+                import_from_path = templatePkg.dirname;
+            }
+        } catch (e) {
+            events.emit('verbose', 'Can not load template package.json using directory '
+ input_directory); 
+        }
+         
         if (!fs.existsSync(import_from_path)) {
             throw new CordovaError('Could not find directory: ' +
                 import_from_path);
@@ -361,5 +372,13 @@ function create(dir, optionalId, optionalName, cfg) {
         if (cfg.id) conf.setPackageName(cfg.id);
         if (cfg.name) conf.setName(cfg.name);
         conf.write();
+        
+        //run npm install if package.json is at the root of cordova project
+        if (fs.existsSync(path.join(dir,'package.json'))){
+            shell.pushd(dir);
+            events.emit('log', 'Executing npm install...');
+            shell.exec('npm install');
+            shell.popd();
+        }
     });
 }


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


Mime
View raw message