cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [7/7] git commit: CB-6976 Add support for Windows Universal apps (Windows 8.1 and WP 8.1)
Date Fri, 20 Jun 2014 17:48:27 GMT
CB-6976 Add support for Windows Universal apps (Windows 8.1 and WP 8.1)


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

Branch: refs/heads/master
Commit: 29d15d6ef847d430747a7abdd9ed7c95d0289f85
Parents: 2dd7c37
Author: sgrebnov <v-segreb@microsoft.com>
Authored: Fri Jun 20 15:38:19 2014 +0400
Committer: sgrebnov <v-segreb@microsoft.com>
Committed: Fri Jun 20 15:38:19 2014 +0400

----------------------------------------------------------------------
 .gitignore                                      |    1 -
 windows/CONTRIBUTING.md                         |   37 +
 windows/LICENSE                                 |   12 +
 windows/NOTICE                                  |    5 +
 windows/README.md                               |  109 ++
 windows/VERSION                                 |    1 +
 windows/bin/check_reqs                          |   24 +
 windows/bin/check_reqs.bat                      |    9 +
 windows/bin/check_reqs.js                       |   96 ++
 windows/bin/create.bat                          |    9 +
 windows/bin/create.js                           |  230 +++
 windows/bin/update.bat                          |    9 +
 windows/bin/update.js                           |  210 +++
 windows/cordova.js                              | 1598 ++++++++++++++++++
 windows/package.json                            |   17 +
 windows/template/CordovaApp.Phone.jsproj        |   86 +
 windows/template/CordovaApp.Store.jsproj        |   84 +
 windows/template/CordovaApp.Store80.jsproj      |   76 +
 windows/template/CordovaApp.projitems           |   21 +
 windows/template/CordovaApp.shproj              |   12 +
 windows/template/CordovaApp.sln                 |  116 ++
 windows/template/CordovaApp.vs2012.sln          |   46 +
 windows/template/CordovaApp_TemporaryKey.pfx    |  Bin 0 -> 2536 bytes
 windows/template/MyTemplate.vstemplate          |   44 +
 windows/template/VERSION                        |    1 +
 windows/template/config.xml                     |   23 +
 windows/template/cordova/build.bat              |    9 +
 windows/template/cordova/clean.bat              |    9 +
 .../cordova/lib/ApplyPlatformConfig.ps1         |  216 +++
 .../cordova/lib/WindowsStoreAppUtils.ps1        |  116 ++
 windows/template/cordova/lib/build.js           |  265 +++
 windows/template/cordova/lib/clean.js           |   91 +
 windows/template/cordova/lib/deploy.js          |  465 +++++
 windows/template/cordova/lib/list-devices.bat   |    3 +
 .../cordova/lib/list-emulator-images.bat        |    3 +
 .../cordova/lib/list-started-emulators.bat      |    3 +
 windows/template/cordova/lib/log.js             |   77 +
 windows/template/cordova/lib/target-list.js     |  233 +++
 windows/template/cordova/log.bat                |    3 +
 windows/template/cordova/run.bat                |    9 +
 windows/template/cordova/version.bat            |    9 +
 .../template/images/SplashScreen.scale-240.png  |  Bin 0 -> 14715 bytes
 .../images/Square150x150Logo.scale-240.png      |  Bin 0 -> 2516 bytes
 .../images/Square44x44Logo.scale-240.png        |  Bin 0 -> 753 bytes
 .../images/Square71x71Logo.scale-240.png        |  Bin 0 -> 1122 bytes
 windows/template/images/StoreLogo.scale-240.png |  Bin 0 -> 902 bytes
 .../images/Wide310x150Logo.scale-240.png        |  Bin 0 -> 4530 bytes
 windows/template/images/logo.png                |  Bin 0 -> 11600 bytes
 windows/template/images/smalllogo.png           |  Bin 0 -> 2831 bytes
 windows/template/images/splashscreen.png        |  Bin 0 -> 24855 bytes
 windows/template/images/storelogo.png           |  Bin 0 -> 4052 bytes
 windows/template/package.phone.appxmanifest     |   34 +
 windows/template/package.store.appxmanifest     |   31 +
 windows/template/package.store80.appxmanifest   |   32 +
 windows/template/www/cordova.js                 | 1598 ++++++++++++++++++
 windows/template/www/css/index.css              |  115 ++
 windows/template/www/img/logo.png               |  Bin 0 -> 11600 bytes
 windows/template/www/img/smalllogo.png          |  Bin 0 -> 2831 bytes
 windows/template/www/img/splashscreen.png       |  Bin 0 -> 24855 bytes
 windows/template/www/img/storelogo.png          |  Bin 0 -> 4052 bytes
 windows/template/www/index.html                 |   42 +
 windows/template/www/js/index.js                |   49 +
 windows/utils/testCreateProject.bat             |    5 +
 windows8/CONTRIBUTING.md                        |   37 -
 windows8/LICENSE                                |   12 -
 windows8/NOTICE                                 |    5 -
 windows8/README.md                              |  109 --
 windows8/VERSION                                |    1 -
 windows8/bin/check_reqs                         |   24 -
 windows8/bin/check_reqs.bat                     |    9 -
 windows8/bin/check_reqs.js                      |   96 --
 windows8/bin/create.bat                         |    9 -
 windows8/bin/create.js                          |  223 ---
 windows8/bin/update.bat                         |    9 -
 windows8/bin/update.js                          |  353 ----
 windows8/cordova.js                             | 1465 ----------------
 windows8/package.json                           |   17 -
 windows8/template/CordovaApp.jsproj             |   90 -
 windows8/template/CordovaApp.sln                |   46 -
 windows8/template/CordovaApp_TemporaryKey.pfx   |  Bin 2536 -> 0 bytes
 windows8/template/MyTemplate.vstemplate         |   44 -
 windows8/template/VERSION                       |    1 -
 windows8/template/config.xml                    |   24 -
 windows8/template/cordova/build.bat             |    9 -
 windows8/template/cordova/clean.bat             |    9 -
 .../cordova/lib/ApplyPlatformConfig.ps1         |  157 --
 .../cordova/lib/WindowsStoreAppUtils.ps1        |  116 --
 windows8/template/cordova/lib/build.js          |  264 ---
 windows8/template/cordova/lib/clean.js          |   87 -
 windows8/template/cordova/lib/deploy.js         |  286 ----
 windows8/template/cordova/lib/list-devices.bat  |    3 -
 .../cordova/lib/list-emulator-images.bat        |    3 -
 .../cordova/lib/list-started-emulators.bat      |    3 -
 windows8/template/cordova/lib/log.js            |   77 -
 windows8/template/cordova/lib/target-list.js    |  233 ---
 windows8/template/cordova/log.bat               |    3 -
 windows8/template/cordova/run.bat               |    9 -
 windows8/template/cordova/version.bat           |    9 -
 windows8/template/images/logo.png               |  Bin 11600 -> 0 bytes
 windows8/template/images/smalllogo.png          |  Bin 2831 -> 0 bytes
 windows8/template/images/splashscreen.png       |  Bin 24855 -> 0 bytes
 windows8/template/images/storelogo.png          |  Bin 4052 -> 0 bytes
 windows8/template/package.appxmanifest          |   32 -
 windows8/template/www/cordova.js                | 1465 ----------------
 windows8/template/www/css/index.css             |  115 --
 windows8/template/www/img/logo.png              |  Bin 11600 -> 0 bytes
 windows8/template/www/img/smalllogo.png         |  Bin 2831 -> 0 bytes
 windows8/template/www/img/splashscreen.png      |  Bin 24855 -> 0 bytes
 windows8/template/www/img/storelogo.png         |  Bin 4052 -> 0 bytes
 windows8/template/www/index.html                |   42 -
 windows8/template/www/js/index.js               |   49 -
 windows8/tests/testCreateProject.bat            |    5 -
 .../CordovaWindows8Deploy.cpp                   |   61 -
 .../CordovaWindows8Deploy.vcxproj               |   85 -
 114 files changed, 6292 insertions(+), 5697 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 7e3a752..8909f7a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,4 +8,3 @@ Debug
 obj
 Thumbs.db
 
-windows8/test/bin/
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/CONTRIBUTING.md
----------------------------------------------------------------------
diff --git a/windows/CONTRIBUTING.md b/windows/CONTRIBUTING.md
new file mode 100644
index 0000000..f7dbcab
--- /dev/null
+++ b/windows/CONTRIBUTING.md
@@ -0,0 +1,37 @@
+<!--
+#
+# 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.
+#
+-->
+
+# Contributing to Apache Cordova
+
+Anyone can contribute to Cordova. And we need your contributions.
+
+There are multiple ways to contribute: report bugs, improve the docs, and
+contribute code.
+
+For instructions on this, start with the 
+[contribution overview](http://cordova.apache.org/#contribute).
+
+The details are explained there, but the important items are:
+ - Sign and submit an Apache ICLA (Contributor License Agreement).
+ - Have a Jira issue open that corresponds to your contribution.
+ - Run the tests so your patch doesn't break existing functionality.
+
+We look forward to your contributions!

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/LICENSE
----------------------------------------------------------------------
diff --git a/windows/LICENSE b/windows/LICENSE
new file mode 100644
index 0000000..6b6bd20
--- /dev/null
+++ b/windows/LICENSE
@@ -0,0 +1,12 @@
+
+Licensed 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.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/NOTICE
----------------------------------------------------------------------
diff --git a/windows/NOTICE b/windows/NOTICE
new file mode 100644
index 0000000..c38e7d7
--- /dev/null
+++ b/windows/NOTICE
@@ -0,0 +1,5 @@
+Apache Cordova
+Copyright 2012 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/README.md
----------------------------------------------------------------------
diff --git a/windows/README.md b/windows/README.md
new file mode 100644
index 0000000..417eeec
--- /dev/null
+++ b/windows/README.md
@@ -0,0 +1,109 @@
+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.
+
+
+Getting Started with Windows 8
+==================================
+
+This guide describes how to set up your development environment for Cordova and run a sample
application.  Note that Cordova used to be called PhoneGap, so some of the sites still use
the old PhoneGap name.
+
+During development of Windows 8 and Windows RT, Microsoft deprecated the name "Metro-style
apps". On MSDN, this type of app is now called a "Windows Store" app. That's the name that
we'll use in this guide. Also in this guide whenever we refer to Windows 8, you should take
that to mean both Windows 8 and Windows RT.
+
+1. Requirements
+---------------
+
+- Windows 8
+
+- Visual Studio 2012 Professional or better, or Visual Studio 2012 Express for Windows 8
+
+Follow the instructions [here](http://www.windowsstore.com/) to submit your apps Windows
Store.
+
+2. Install SDK + Cordova
+----------------------------
+
+- Setup your preferred variant of Visual Studio 2012. All of the paid versions of the product
(Professional, etc) let you build Windows Store apps. To build Windows Store apps using the
[Express editions](http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products),
you will need **Express for Windows 8**.
+- Download the latest copy of [Cordova](http://phonegap.com/download) and extract its contents.
We will be working with the subfolder **lib\windows-8**.
+
+3. Setup New Project
+--------------------
+
+You can already build Windows 8 apps using the "HTML/JavaScript track" available in Windows
Store apps. The purpose of Cordova in Windows Store apps is to expose the same APIs used on
all the other Cordova platforms.
+
+- Open Visual Studio 2012 and choose **New Project**.
+- Select **Installed - Template - Other Languages - JavaScript - Windows Store** from the
tree, and then **Blank App** from the projects list. Enter whatever project name you like.
We're using **CordovaWin8Foo** in this guide.
+
+    ![](img/guide/getting-started/windows-8/wsnewproject.PNG)
+
+- Microsoft continues to use **default.html** as the default page for use in websites, whereas
most "open web" developers use **index.html**. (Plus it's likely that in the other platform
variants of your project you are using **index.html** as the name of your default page.) To
fix this, in Solution Explorer rename the **default.html** file to **index.html**. Then double-click
the **package.appxmanifest** file and change the **Start page** value to **index.html**. 
+
+	![](img/guide/getting-started/windows-8/wschangemanifest.PNG)
+
+- To include **cordova.js** in your project, right-click on the **js** folder in Solution
Explorer and select **Add - New Item**. Locate the **corvoda.js** file in the **lib\windows-8**
folder that we called out previously. 
+
+- Edit the code for **index.html**. Add a reference to **cordova.js**. You can do this manually,
or by dragging the file from Solution Explorer.
+
+### Adding the reference...
+	    <!-- WinJS references -->
+	    <link href="//Microsoft.WinJS.1.0/css/ui-dark.css" rel="stylesheet" />
+	    <script src="//Microsoft.WinJS.1.0/js/base.js"></script>
+	    <script src="//Microsoft.WinJS.1.0/js/ui.js"></script>
+
+	    <!-- Cordova -->
+	    <script src="/js/cordova-x.x.x.js"></script>
+
+	    <!-- CordovaWin8Foo references -->
+	    <link href="/css/default.css" rel="stylesheet" />
+	    <script src="/js/default.js"></script>
+
+- Next we want to add some code that will demonstrate that Cordova is working. 
+
+### Adding a 'deviceready' handler...
+	<body>
+	    <p>Content goes here</p>
+
+	    <script type="text/javascript">
+
+	        console.log("Subscribing...");
+	        document.addEventListener("deviceready", function () {
+
+	            navigator.notification.alert("The device is ready!");
+
+	        });
+
+	    </script>
+
+	</body>
+
+
+5. Test the Project
+-------------------------------
+
+- Run the project from Visual Studio. You'll see the message box appear.
+
+	![](img/guide/getting-started/windows-8/wsalert.PNG)
+
+Done!
+-----
+
+That's it! You're now ready to build Windows Store apps with Cordova.
+
+## Issues &&|| Defects
+- [https://issues.apache.org/jira/browse/CB](https://issues.apache.org/jira/browse/CB)
+
+## Further Reading
+- [http://docs.phonegap.com](http://docs.phonegap.com)
+- [http://wiki.phonegap.com](http://wiki.phonegap.com)

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/VERSION
----------------------------------------------------------------------
diff --git a/windows/VERSION b/windows/VERSION
new file mode 100644
index 0000000..216add7
--- /dev/null
+++ b/windows/VERSION
@@ -0,0 +1 @@
+3.5.0-dev
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/bin/check_reqs
----------------------------------------------------------------------
diff --git a/windows/bin/check_reqs b/windows/bin/check_reqs
new file mode 100644
index 0000000..9b73d88
--- /dev/null
+++ b/windows/bin/check_reqs
@@ -0,0 +1,24 @@
+#! /bin/sh
+
+#
+# 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.
+#
+
+echo "ERROR: Cordova tooling for Windows 8 requires Windows 8 Professional with the 'msbuild'
command "
+echo " in the PATH environment variable as well as having .NET Framework 4.0 (from WP SDK's)"
+exit 1
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/bin/check_reqs.bat
----------------------------------------------------------------------
diff --git a/windows/bin/check_reqs.bat b/windows/bin/check_reqs.bat
new file mode 100644
index 0000000..26e7393
--- /dev/null
+++ b/windows/bin/check_reqs.bat
@@ -0,0 +1,9 @@
+@ECHO OFF
+SET full_path=%~dp0
+IF EXIST %full_path%check_reqs.js (
+        cscript "%full_path%check_reqs.js" %* //nologo
+) ELSE (
+    ECHO.
+    ECHO ERROR: Could not find 'check_reqs.js' in 'bin' folder, aborting...>&2
+    EXIT /B 1
+)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/bin/check_reqs.js
----------------------------------------------------------------------
diff --git a/windows/bin/check_reqs.js b/windows/bin/check_reqs.js
new file mode 100644
index 0000000..fd0fd8c
--- /dev/null
+++ b/windows/bin/check_reqs.js
@@ -0,0 +1,96 @@
+/*
+       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.
+*/
+
+
+var args = WScript.Arguments;
+var wscript_shell = WScript.CreateObject("WScript.Shell");
+
+function Usage() {
+    Log("Usage: [ check_reqs | cscript check_reqs.js ]");
+    Log("examples:");
+    Log("    cscript C:\\Users\\anonymous\\cordova-windows\\windows8\\bin\\check_reqs.js");
+    Log("    CordovaWindowsPhone\\bin\\check_reqs");
+
+}
+
+// log to stdout or stderr
+function Log(msg, error) {
+    if (error) {
+        WScript.StdErr.WriteLine(msg);
+    }
+    else {
+        WScript.StdOut.WriteLine(msg);
+    }
+}
+
+// gets the output from a command, failing with the given error message
+function check_command(cmd, fail_msg) {
+    Log("CMD:"+cmd);
+    var out = wscript_shell.Exec(cmd);
+    while (out.Status == 0) {
+        WScript.Sleep(100);
+    }
+
+    //Check that command executed
+    if (!out.StdErr.AtEndOfStream) {
+        var line = out.StdErr.ReadLine();
+        Log(fail_msg, true);
+        Log('Output : ' + line, true);
+        WScript.Quit(1);
+    }
+
+    if (!out.StdOut.AtEndOfStream) {
+        var line = out.StdOut.ReadAll();
+        return line;
+    }
+    else {
+         Log('Unable to get output from command "' + cmd + '"', true);
+         WScript.Quit(1);
+    }
+}
+
+
+if (args.Count() > 0) {
+    Usage();
+    WScript.Quit(1);
+}
+else
+{
+/* The tooling for cordova windows phone requires these commands
+ *  in the environment PATH variable.
+ * - msbuild (ex. C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319)
+ */
+    var version;
+
+    try {
+        version = wscript_shell.RegRead("HKLM\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\4.0\\MSBuildRuntimeVersion");
+        if(version != null && version.indexOf("4.0") == 0) {
+            // All good!
+            Log(version);
+        }
+        else {
+            throw(new Error("version not 4.0"));
+        }
+    }
+    catch(err) {
+        Log('Please install the .NET Framework v4.0 (part of the latest windows phone SDK\'s).',
true);
+        WScript.Quit(2);
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/bin/create.bat
----------------------------------------------------------------------
diff --git a/windows/bin/create.bat b/windows/bin/create.bat
new file mode 100644
index 0000000..329048e
--- /dev/null
+++ b/windows/bin/create.bat
@@ -0,0 +1,9 @@
+@ECHO OFF
+SET full_path=%~dp0
+IF EXIST %full_path%create.js (
+        cscript "%full_path%create.js" %* //nologo
+) ELSE (
+    ECHO.
+    ECHO ERROR: Could not find 'create.js' in 'bin' folder, aborting...>&2
+    EXIT /B 1
+)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/bin/create.js
----------------------------------------------------------------------
diff --git a/windows/bin/create.js b/windows/bin/create.js
new file mode 100644
index 0000000..2fb092b
--- /dev/null
+++ b/windows/bin/create.js
@@ -0,0 +1,230 @@
+/*
+       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.
+*/
+
+/*
+ * create a cordova/windows8 project
+ *
+ * USAGE
+ *  ./create [path package activity]
+
+    ./bin/create.bat C:\Users\Me\MyTestProj "test.proj" "TestProject"
+ */
+
+
+var fso=WScript.CreateObject("Scripting.FileSystemObject");
+var wscript_shell = WScript.CreateObject("WScript.Shell");
+// working dir
+var ROOT = WScript.ScriptFullName.split('\\bin\\create.js').join('');
+
+var args = WScript.Arguments,
+    TEMPLATES_PATH = '\\template',
+    // default template to use when creating the project
+    CREATE_TEMPLATE = TEMPLATES_PATH,
+    PROJECT_PATH,
+    PACKAGE,
+    NAME,
+    GUID;
+
+// File System Object constants
+var ForReading = 1, ForWriting = 2, ForAppending = 8;
+var TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0;
+
+function Usage() {
+    Log("Usage: create PathTONewProject [ PackageName AppName ]");
+    Log("    PathTONewProject : The path to where you wish to create the project");
+    Log("    PackageName      : The namespace for the project (default is Cordova.Example)")
+    Log("    AppName          : The name of the application (default is CordovaAppProj)");
+    Log("examples:");
+    Log("    create C:\\Users\\anonymous\\Desktop\\MyProject");
+    Log("    create C:\\Users\\anonymous\\Desktop\\MyProject io.Cordova.Example AnApp");
+}
+
+// logs messaged to stdout and stderr
+function Log(msg, isError) {
+    if (isError) {
+        WScript.StdErr.WriteLine(msg);
+    }
+    else {
+        WScript.StdOut.WriteLine(msg);
+    }
+}
+
+function read(filename) {
+    var f=fso.OpenTextFile(filename, 1,2);
+    var s=f.ReadAll();
+    f.Close();
+    return s;
+}
+
+function write(filename, contents) {
+    var f=fso.OpenTextFile(filename, ForWriting, TristateTrue);
+    f.Write(contents);
+    f.Close();
+}
+
+function replaceInFile(filename, regexp, replacement) {
+    write(filename,read(filename).replace(regexp,replacement));
+}
+
+
+// executes a commmand in the shell
+function exec(command) {
+    var oShell=wscript_shell.Exec(command);
+    while (oShell.Status == 0) {
+        WScript.sleep(100);
+    }
+}
+
+// executes a commmand in the shell
+function exec_verbose(command) {
+    //Log("Command: " + command);
+    var oShell=wscript_shell.Exec(command);
+    while (oShell.Status == 0) {
+        //Wait a little bit so we're not super looping
+        WScript.sleep(100);
+        //Print any stdout output from the script
+        if (!oShell.StdOut.AtEndOfStream) {
+            var line = oShell.StdOut.ReadLine();
+            Log(line);
+        }
+    }
+    //Check to make sure our scripts did not encounter an error
+    if (!oShell.StdErr.AtEndOfStream) {
+        var line = oShell.StdErr.ReadAll();
+        Log(line, true);
+        WScript.Quit(1);
+    }
+}
+
+//generate guid for the project
+function genGuid() {
+    var TypeLib = WScript.CreateObject("Scriptlet.TypeLib");
+    strGuid = TypeLib.Guid.split("}")[0]; // there is extra crap after the } that is causing
file streams to break, probably an EOF ...
+    strGuid = strGuid.replace(/[\{\}]/g,"");
+    return strGuid;
+}
+
+// deletes the path element if it exists
+function delete_if_exists(path) {
+    if (fso.FolderExists(path)) {
+        fso.DeleteFolder(path);
+    }
+    else if (fso.FileExists(path)) {
+        fso.DeleteFile(path);
+    }
+}
+
+
+// creates new project in path, with the given package and app name
+function create(destPath, namespace, name, guid) {
+    Log("Creating Cordova Windows Project:");
+    Log("\tApp Name : " + name);
+    Log("\tNamespace : " + namespace);
+    Log("\tPath : " + destPath);
+
+    var safeProjectName = name.replace(/(\.\s|\s\.|\s+|\.+)/g, '_');
+
+    var srcPath = ROOT + CREATE_TEMPLATE;
+
+    // Copy the template source files to the new destination
+    fso.CopyFolder(srcPath,destPath);
+    var newProjGuid = guid || genGuid();
+
+    // replace the guid in the AppManifest and deploy script
+    replaceInFile(destPath + "\\package.store.appxmanifest",/\$guid1\$/g,newProjGuid);
+    replaceInFile(destPath + "\\package.store80.appxmanifest",/\$guid1\$/g,newProjGuid);
+    replaceInFile(destPath + "\\package.phone.appxmanifest",/\$guid1\$/g,newProjGuid);
+
+    replaceInFile(destPath + "\\cordova\\lib\\deploy.js",/\$guid1\$/g,newProjGuid);
+    replaceInFile(destPath + "\\cordova\\lib\\deploy.js",/\$namespace\$/g,namespace);
+
+    // replace $safeprojectname$ and $projectname$ in AppManifest
+    replaceInFile(destPath + "\\package.store.appxmanifest",/\$safeprojectname\$/g,safeProjectName);
+    replaceInFile(destPath + "\\package.store80.appxmanifest",/\$safeprojectname\$/g,safeProjectName);
+    replaceInFile(destPath + "\\package.phone.appxmanifest",/\$safeprojectname\$/g,safeProjectName);
+    replaceInFile(destPath + "\\package.store.appxmanifest",/\$projectname\$/g,name);
+    replaceInFile(destPath + "\\package.store80.appxmanifest",/\$projectname\$/g,name);
+    replaceInFile(destPath + "\\package.phone.appxmanifest",/\$projectname\$/g,name);
+
+
+    // cleanup
+
+    // Delete bld forder and bin folder
+
+    delete_if_exists(destPath + "\\bld");
+    delete_if_exists(destPath + "\\bin");
+    delete_if_exists(destPath + "\\*.user");
+    delete_if_exists(destPath + "\\*.suo");
+    delete_if_exists(destPath + "\\MyTemplate.vstemplate");
+
+    // TODO: Name the project according to the arguments
+    // update the solution to include the new project by name
+    // version BS
+    // index.html title set to project name ?
+
+    Log("Project created");
+}
+
+if (args.Count() > 0) {
+    // support help flags
+    if (args(0) == "--help" || args(0) == "/?" ||
+            args(0) == "help" || args(0) == "-help" || args(0) == "/help" || args(0) == "-h")
{
+        Usage();
+        WScript.Quit(1);
+    }
+
+    PROJECT_PATH = args(0);
+    if (fso.FolderExists(PROJECT_PATH)) {
+        Log("Project directory already exists:", true);
+        Log("\t" + PROJECT_PATH, true);
+        Log("CREATE FAILED.", true);
+        WScript.Quit(1);
+    }
+
+    if (args.Count() > 1) {
+        PACKAGE = args(1);
+    }
+    else {
+        PACKAGE = "Cordova.Example";
+    }
+
+    if (args.Count() > 2) {
+        NAME = args(2);
+    }
+    else {
+        NAME = "CordovaAppProj";
+    }
+
+    if (args.Count() > 3) {
+        var guid_regex = /\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}/;
+        if (args(3).substr(0,7) == "--guid=" && args(3).match(guid_regex)) {
+            GUID = args(3).split
+        } else {
+            Log("Did not recognize argument '" + args(3) + "'. If your trying to add a GUID
make sure it's in the proper format.");
+            WScript.Quit(2);
+        }
+    }
+
+    create(PROJECT_PATH, PACKAGE, NAME, GUID);
+}
+else {
+    Usage();
+    WScript.Quit(1);
+}
+

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/bin/update.bat
----------------------------------------------------------------------
diff --git a/windows/bin/update.bat b/windows/bin/update.bat
new file mode 100644
index 0000000..9da7e3c
--- /dev/null
+++ b/windows/bin/update.bat
@@ -0,0 +1,9 @@
+@ECHO OFF
+SET full_path=%~dp0
+IF EXIST %full_path%update.js (
+        cscript "%full_path%update.js" %* //nologo
+) ELSE (
+    ECHO.
+    ECHO ERROR: Could not find 'update.js' in 'bin' folder, aborting...>&2
+    EXIT /B 1
+)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/bin/update.js
----------------------------------------------------------------------
diff --git a/windows/bin/update.js b/windows/bin/update.js
new file mode 100644
index 0000000..b34dec9
--- /dev/null
+++ b/windows/bin/update.js
@@ -0,0 +1,210 @@
+/*
+       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.
+*/
+
+var fso           = WScript.CreateObject("Scripting.FileSystemObject");
+var wscript_shell = WScript.CreateObject("WScript.Shell");
+var shell         = WScript.CreateObject("shell.application");
+var args          = WScript.Arguments;
+// working dir
+var ROOT = WScript.ScriptFullName.split('\\bin\\update.js').join('');
+//Get version number
+var VERSION = read(ROOT+'\\VERSION').replace(/\r\n/,'').replace(/\n/,'');
+var plugins_folder = "\\Plugins";
+var template_folder = "\\templates\\standalone";
+// anything thats missing to the project
+var overwrite = false;
+var replace = false;
+
+// usage function
+function Usage() {
+    Log("WARNING : Make sure to back up your project before updating!")
+    Log("Usage: update Path-To-Project ");//[ -f | -r ] ");
+    Log("    Path-To-Old-Project : The path the project you would like to update.");
+    //Log("                     -f : Will forcefully overwrite and add all core components
of the application.");
+    //Log("                     -r : Will create an updated project, only keeping the www
assets. *NOTE: no native code will be preserved*");
+    Log("examples:");
+    Log("    update C:\\Users\\anonymous\\Desktop\\MyProject");
+}
+
+// logs messaged to stdout and stderr
+function Log(msg, error) {
+    if (error) {
+        WScript.StdErr.WriteLine(msg);
+    }
+    else {
+        WScript.StdOut.WriteLine(msg);
+    }
+}
+
+// executes a commmand in the shell
+function exec_verbose(command) {
+    Log("Command: " + command);
+    var oShell=wscript_shell.Exec(command);
+    while (oShell.Status == 0) {
+        //Wait a little bit so we're not super looping
+        WScript.sleep(100);
+        //Print any stdout output from the script
+        if (!oShell.StdOut.AtEndOfStream) {
+            var line = oShell.StdOut.ReadAll();
+            Log(line);
+        }
+    }
+    //Check to make sure our scripts did not encounter an error
+    if (!oShell.StdErr.AtEndOfStream) {
+        var line = oShell.StdErr.ReadAll();
+        Log(line, true);
+        WScript.Quit(2);
+    }
+}
+
+var ForReading = 1, ForWriting = 2, ForAppending = 8;
+var TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0;
+
+// returns the contents of a file
+function read(filename) {
+    if (fso.FileExists(filename)) {
+        var f=fso.OpenTextFile(filename, 1, 2);
+        var s=f.ReadAll();
+        f.Close();
+        return s;
+    }
+    else {
+        Log('Cannot read non-existant file : ' + filename, true);
+        WScript.Quit(2);
+    }
+    return null;
+}
+
+
+// // returns the name of the application
+// function get_app_name(path) {
+//     var WMAppManifest = read(path + '\\Properties\\WMAppManifest.xml').split('\n');
+//     for (line in WMAppManifest) {
+//         if (WMAppManifest[line].match(/Title\=\"/)) {
+//             return WMAppManifest[line].split('Title="')[1].split('"')[0];
+//         }
+//     }
+//     Log("Error : unable to find applicaiton name in the project.", true);
+//     Log(" Path : " + path, true);
+//     WScript.Quit(2);
+// }
+
+// // returns the name of the application package
+// function get_package_name(path) {
+//     var WMAppManifest = read(path + '\\Properties\\WMAppManifest.xml').split('\n');
+//     for (line in WMAppManifest) {
+//         if (WMAppManifest[line].match(/Title\=\"/)) {
+//             return WMAppManifest[line].split('Title="')[1].split('"')[0];
+//         }
+//     }
+//     Log("Error : unable to find applicaiton name in the project.", true);
+//     Log(" Path : " + path, true);
+//     WScript.Quit(2);
+// }
+
+// // returns the GUID ame of the application
+// function get_app_GUID(path) {
+//     var AppXAML = read(path + '\\App.xaml').split('\n');
+//     for (line in AppXAML) {
+//         if (AppXAML[line].match(/x\:Class\=\"/)) {
+//             return AppXAML[line].split('Class="')[1].split('"')[0];
+//         }
+//     }
+//     Log("Error : unable to find package name in the project.", true);
+//     Log(" Path : " + path, true);
+//     WScript.Quit(2);
+// }
+
+// deletes the path element if it exists
+function delete_if_exists(path) {
+    if (fso.FolderExists(path)) {
+        fso.DeleteFolder(path);
+    }
+    else if (fso.FileExists(path)) {
+        fso.DeleteFile(path);
+    }
+}
+
+function extractMetadata(path) {
+    if (!fso.FileExists(path+'/config.xml')) {
+        Log('config.xml does not exist');
+        WScript.Quit(2);
+    }
+
+    var meta =  { // default values
+        namespace: 'io.cordova.hellocordova',
+        name: 'HelloCordova'
+    }
+
+    var config = read(path + '/config.xml').split('\n');
+    for (line in config) {
+        // TODO read real values from config.xml
+        // in case of cli all values will be updated by cli for you
+        // but the script could be used w/o cli so we should correctly populate meta
+    }
+
+    return meta;
+}
+
+function quote(value) {
+    return "\"" + value + "\"";
+}
+
+// updates the cordova.js in project along with the cordova tooling.
+function update_project(path) {
+    var meta = extractMetadata(path);
+
+    delete_if_exists(path);
+
+    // this could be used to automatically produce correct folder name under cli
+    // var targetPath = path.replace(/platforms\\windows8$/, 'platforms\\windows')
+
+    exec_verbose(quote(ROOT + '\\bin\\create.bat')
+        + ' ' + quote(path) 
+        + ' ' + quote(meta.namespace)
+        + ' ' + quote(meta.name));
+}
+
+// no args
+if (args.Count() == 0) {
+    Usage();
+    WScript.Quit(1);
+}
+
+// to many args
+if(args.Count() > 2) {
+    Log("Error : too many arguments provided.", true);
+    WScript.Quit(1);
+}
+
+// help
+if (args(0).indexOf("--help") > -1 || args(0).indexOf("/?") > -1 ) {
+    Usage();
+    WScript.Quit(1);
+}
+
+// folder does not exist
+if (!fso.FolderExists(args(0))) {
+    Log("The given path to the project does not exist.", true);
+    Log(" Please provide a path to the project you would like to update.", true);
+    Usage();
+    WScript.Quit(2);
+}
+
+update_project(args(0));
\ No newline at end of file


Mime
View raw message