You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2013/05/25 03:04:03 UTC

git commit: wip CLI for Windows8, [CB-3338]

Updated Branches:
  refs/heads/master 63e87cede -> 4ea376dbc


wip CLI for Windows8, [CB-3338]


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

Branch: refs/heads/master
Commit: 4ea376dbc829e384ef1239e5e794b5d783bab39a
Parents: 63e87ce
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Fri May 24 18:03:44 2013 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Fri May 24 18:03:44 2013 -0700

----------------------------------------------------------------------
 windows8/template/VERSION                    |    1 +
 windows8/template/cordova/build.bat          |    9 +
 windows8/template/cordova/clean.bat          |    9 +
 windows8/template/cordova/lib/build.js       |  181 ++++++++++++
 windows8/template/cordova/lib/clean.js       |  129 ++++++++
 windows8/template/cordova/lib/deploy.js      |  326 +++++++++++++++++++++
 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/tools/scripts/create.bat            |   25 --
 12 files changed, 986 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/4ea376db/windows8/template/VERSION
----------------------------------------------------------------------
diff --git a/windows8/template/VERSION b/windows8/template/VERSION
new file mode 100644
index 0000000..38f8e88
--- /dev/null
+++ b/windows8/template/VERSION
@@ -0,0 +1 @@
+dev

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

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

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/4ea376db/windows8/template/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/windows8/template/cordova/lib/build.js b/windows8/template/cordova/lib/build.js
new file mode 100644
index 0000000..9986a7e
--- /dev/null
+++ b/windows8/template/cordova/lib/build.js
@@ -0,0 +1,181 @@
+/*
+       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 args = WScript.Arguments;
+
+// working dir
+var ROOT = WScript.ScriptFullName.split('\\cordova\\lib\\build.js').join('');
+
+// help/usage function
+function Usage() {
+    Log("");
+    Log("Usage: build [ --debug | --release ]");
+    Log("    --help    : Displays this dialog.");
+    Log("    --debug   : Cleans and builds project in debug mode.");
+    Log("    --release : Cleans and builds project in release mode.");
+    Log("examples:");
+    Log("    build ");
+    Log("    build --debug");
+    Log("    build --release");
+    Log("");
+}
+
+// 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.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(2);
+    }
+}
+
+// checks to see if a .csproj file exists in the project root
+function is_cordova_project(path) {
+    if (fso.FolderExists(path)) {
+        var proj_folder = fso.GetFolder(path);
+        var proj_files = new Enumerator(proj_folder.Files);
+        for (;!proj_files.atEnd(); proj_files.moveNext()) {
+            if (fso.GetExtensionName(proj_files.item()) == 'csproj') {
+                return true;  
+            }
+        }
+    }
+    return false;
+}
+
+// builds the project and .xap in release mode
+function build_xap_release(path) {
+    Log("Building Cordova-WP8 Project:");
+    Log("\tConfiguration : Release");
+    Log("\tDirectory : " + path);
+    
+    wscript_shell.CurrentDirectory = path;
+    exec_verbose('msbuild /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo /p:Configuration=Release');
+    
+    // check if file xap was created
+    if (fso.FolderExists(path + '\\Bin\\Release')) {
+        var out_folder = fso.GetFolder(path + '\\Bin\\Release');
+        var out_files = new Enumerator(out_folder.Files);
+        for (;!out_files.atEnd(); out_files.moveNext()) {
+            if (fso.GetExtensionName(out_files.item()) == 'xap') {
+                Log("BUILD SUCCESS.");
+                return;  
+            }
+        }
+    }
+    Log('ERROR: MSBuild failed to create .xap when building cordova-wp8 for release.', true);
+    WScript.Quit(2);
+}
+
+// builds the project and .xap in debug mode
+function build_xap_debug(path) {
+    Log("Building Cordova-WP8 Project:");
+    Log("\tConfiguration : Debug");
+    Log("\tDirectory : " + path);
+    
+    wscript_shell.CurrentDirectory = path;
+    exec_verbose('msbuild /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo /p:Configuration=Debug');
+    
+    // check if file xap was created
+    if (fso.FolderExists(path + '\\Bin\\Debug')) {
+        var out_folder = fso.GetFolder(path + '\\Bin\\Debug');
+        var out_files = new Enumerator(out_folder.Files);
+        for (;!out_files.atEnd(); out_files.moveNext()) {
+            if (fso.GetExtensionName(out_files.item()) == 'xap') {
+                Log("BUILD SUCCESS.");
+                return;  
+            }
+        }
+    }
+    Log('ERROR: MSBuild failed to create .xap when building cordova-wp8 for debugging.', true);
+    WScript.Quit(2);
+}
+
+
+Log("");
+
+if (args.Count() > 0) {
+    // support help flags
+    if (args(0) == "--help" || args(0) == "/?" ||
+            args(0) == "help" || args(0) == "-help" || args(0) == "/help") {
+        Usage();
+        WScript.Quit(2);
+    }
+    else if (args.Count() > 1) {
+        Log("Error: Too many arguments.", true);
+        Usage();
+        WScript.Quit(2);
+    }
+    else if (fso.FolderExists(ROOT)) {
+        if (!is_cordova_project(ROOT)) {
+            Log('Error: .csproj file not found in ' + ROOT, true);
+            Log('could not build project.', true);
+            WScript.Quit(2);
+        }
+
+        if (args(0) == "--debug" || args(0) == "-d") {
+            exec_verbose('%comspec% /c ' + ROOT + '\\cordova\\clean');
+            build_xap_debug(ROOT);
+        }
+        else if (args(0) == "--release" || args(0) == "-r") {
+            exec_verbose('%comspec% /c ' + ROOT + '\\cordova\\clean');
+            build_xap_release(ROOT);
+        }
+        else {
+            Log("Error: \"" + args(0) + "\" is not recognized as a build option", true);
+            Usage();
+            WScript.Quit(2);
+        }
+    }
+    else {
+        Log("Error: Project directory not found,", true);
+        Usage();
+        WScript.Quit(2);
+    }
+}
+else {
+    Log("WARNING: [ --debug | --release ] not specified, defaulting to debug...");
+    build_xap_debug(ROOT);
+}

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/4ea376db/windows8/template/cordova/lib/clean.js
----------------------------------------------------------------------
diff --git a/windows8/template/cordova/lib/clean.js b/windows8/template/cordova/lib/clean.js
new file mode 100644
index 0000000..caa1957
--- /dev/null
+++ b/windows8/template/cordova/lib/clean.js
@@ -0,0 +1,129 @@
+/*
+       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 args = WScript.Arguments;
+// working dir
+var ROOT = WScript.ScriptFullName.split('\\cordova\\lib\\clean.js').join('');
+
+
+// help function
+function Usage() {
+    Log("");
+    Log("Usage: clean [ --debug | --release ]");
+    Log("    --debug   : Cleans generated debug files in project.");
+    Log("    --release : Cleans generated release files in project.");
+    Log("examples:");
+    Log("    clean --debug");
+    Log("    clean");
+    Log("         - deletes all generated files in project");
+    Log("");
+}
+
+//  logs to stdout or stderr
+function Log(msg, error) {
+    if (error) {
+        WScript.StdErr.WriteLine(msg);
+    }
+    else {
+        WScript.StdOut.WriteLine(msg);
+    }
+}
+
+// cleans any generated files in the cordova project
+function clean_project(path) {
+    delete_if_exists(path + "\\obj");
+    delete_if_exists(path + "\\Bin");
+    // delete AppName.csproj.user as well? Service References?
+    var proj_folder = fso.GetFolder(path);
+    var proj_files = new Enumerator(proj_folder.Files);
+    for (;!proj_files.atEnd(); proj_files.moveNext()) {
+        if (fso.GetExtensionName(proj_files.item()).match(/user/)) {
+            fso.DeleteFile(proj_files.item());
+        }
+    }
+}
+
+// cleans any files generated by build --debug
+function clean_debug(path) {
+    delete_if_exists(path + "\\obj\\Debug");
+    delete_if_exists(path + "\\Bin\\Debug");
+}
+
+// cleans any files generated by build --release
+function clean_release(path) {
+    delete_if_exists(path + "\\obj\\Release");
+    delete_if_exists(path + "\\Bin\\Release");
+}
+
+// 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);
+    }
+}
+
+
+if (args.Count() > 0) {
+    // support help flags
+    if (args(0) == "--help" || args(0) == "/?" ||
+            args(0) == "help" || args(0) == "-help" || args(0) == "/help") {
+        Usage();
+        WScript.Quit(2);
+    }
+    else if (args.Count() > 1) {
+        Log("Error: Too many arguments.", true);
+        Usage();
+        WScript.Quit(2);
+    }
+    else if (fso.FolderExists(ROOT)) {
+        if (args(0) == "--debug" || args(0) == "-d") {
+            clean_debug(ROOT);
+        }
+        else if (args(0) == "--release" || args(0) == "-r") {
+            clean_release(ROOT);
+        }
+        else {
+            Log("Error: \"" + args(0) + "\" is not recognized as a build option", true);
+            Usage();
+            WScript.Quit(2);
+        }
+    }
+    else {
+        Log("Error: Project directory not found,", true);
+        Usage();
+        WScript.Quit(2);
+    }
+}
+else {
+   if (fso.FolderExists(ROOT)) {
+        Log("Cleaning cordova project...");
+        clean_project(ROOT);
+    }
+    else {
+        Log("Error: Project directory not found,", true);
+        Usage();
+        WScript.Quit(2);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/4ea376db/windows8/template/cordova/lib/deploy.js
----------------------------------------------------------------------
diff --git a/windows8/template/cordova/lib/deploy.js b/windows8/template/cordova/lib/deploy.js
new file mode 100644
index 0000000..29a3f7d
--- /dev/null
+++ b/windows8/template/cordova/lib/deploy.js
@@ -0,0 +1,326 @@
+/*
+       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 args = WScript.Arguments;
+// working dir
+var ROOT = WScript.ScriptFullName.split('\\cordova\\lib\\deploy.js').join('');
+    // path to CordovaDeploy.exe
+var CORDOVA_DEPLOY_EXE = '\\cordova\\lib\\CordovaDeploy\\CordovaDeploy\\bin\\Debug\\CordovaDeploy.exe';
+    // path to CordovaDeploy
+var CORDOVA_DEPLOY = '\\cordova\\lib\\CordovaDeploy';
+
+//build types
+var NONE = 0,
+    DEBUG = 1,
+    RELEASE = 2,
+    NO_BUILD = 3;
+var build_type = NONE;
+
+
+// help function
+function Usage() {
+    Log("");
+    Log("Usage: run [ --device | --emulator | --target=<id> ] [ --debug | --release | --nobuild ]");
+    Log("    --device      : Deploys and runs the project on the connected device.");
+    Log("    --emulator    : Deploys and runs the project on an emulator.");
+    Log("    --target=<id> : Deploys and runs the project on the specified target.");
+    Log("    --debug       : Builds project in debug mode.");
+    Log("    --release     : Builds project in release mode.");
+    Log("    --nobuild     : Ueses pre-built xap, or errors if project is not built.");
+    Log("examples:");
+    Log("    run");
+    Log("    run --emulator");
+    Log("    run --device");
+    Log("    run --target=7988B8C3-3ADE-488d-BA3E-D052AC9DC710");
+    Log("    run --device --release");
+    Log("    run --emulator --debug");
+    Log("");
+}
+
+// log to stdout or stderr
+function Log(msg, error) {
+    if (error) {
+        WScript.StdErr.WriteLine(msg);
+    }
+    else {
+        WScript.StdOut.WriteLine(msg);
+    }
+} 
+
+var ForReading = 1, ForWriting = 2, ForAppending = 8;
+var TristateUseDefault = 2, TristateTrue = 1, TristateFalse = 0;
+
+
+// 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.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);
+    }
+}
+
+// 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;
+}
+
+// builds the CordovaDeploy.exe if it does not already exist 
+function cordovaDeploy(path) {
+    if (fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
+        return;
+    }
+
+    Log('CordovaDeploy.exe not found, attempting to build CordovaDeploy.exe...');
+
+    // build CordovaDeploy.exe
+    if (fso.FolderExists(path + '\\cordova') && fso.FolderExists(path + CORDOVA_DEPLOY) && 
+        fso.FileExists(path + CORDOVA_DEPLOY + '\\CordovaDeploy.sln')) {
+        // delete any previously generated files
+        if (fso.FolderExists(path + CORDOVA_DEPLOY + '\\CordovaDeploy\\obj')) {
+            fso.DeleteFolder(path + CORDOVA_DEPLOY + '\\CordovaDeploy\\obj');
+        }
+        if (fso.FolderExists(path + CORDOVA_DEPLOY + '\\CordovaDeploy\\Bin')) {
+            fso.DeleteFolder(path + CORDOVA_DEPLOY + '\\CordovaDeploy\\Bin');
+        }
+        exec_verbose('msbuild ' + path + CORDOVA_DEPLOY + '\\CordovaDeploy.sln');
+
+        if (fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
+            Log('CordovaDeploy.exe compiled, SUCCESS.');
+        }
+        else {
+            Log('ERROR: MSBUILD FAILED TO COMPILE CordovaDeploy.exe', true);
+            WScript.Quit(2);
+        }
+    }
+    else {
+        Log('ERROR: CordovaDeploy.sln not found, unable to compile CordovaDeploy tool.', true);
+        WScript.Quit(2);
+    }
+}
+
+// launches project on device
+function device(path)
+{
+    cordovaDeploy(path);
+    if (fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
+        Log('Deploying to device ...');
+        //TODO: get device ID from list-devices and deploy to first one
+        exec_verbose('%comspec% /c ' + path + CORDOVA_DEPLOY_EXE + ' ' + path + ' -d:0');
+    }
+    else
+    {
+        Log('Error: Failed to find CordovaDeploy.exe in ' + path, true);
+        Log('DEPLOY FAILED.', true);
+        WScript.Quit(2);
+    }
+}
+
+// launches project on emulator
+function emulator(path)
+{
+    cordovaDeploy(path);
+    if (fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
+        Log('Deploying to emulator ...');
+        //TODO: get emulator ID from list-emulators and deploy to first one
+        exec_verbose('%comspec% /c ' + path + CORDOVA_DEPLOY_EXE + ' ' + path + ' -d:1');
+    }
+    else
+    {
+        Log('Error: Failed to find CordovaDeploy.exe in ' + path, true);
+        Log('DEPLOY FAILED.', true);
+        WScript.Quit(2);
+    }
+}
+
+// builds and launches the project on the specified target
+function target(path, device_id) {
+    if (!fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
+        cordovaDeploy(path);
+    }
+    wscript_shell.CurrentDirectory = path + CORDOVA_DEPLOY + '\\CordovaDeploy\\bin\\Debug';
+    var cmd = 'CordovaDeploy -devices';
+    var out = wscript_shell.Exec(cmd);
+    while(out.Status == 0) {
+        WScript.Sleep(100);
+    }
+    if (!out.StdErr.AtEndOfStream) {
+        var line = out.StdErr.ReadAll();
+        Log("Error calling CordovaDeploy : ", true);
+        Log(line, true);
+        WScript.Quit(2);
+    }
+    else {
+        if (!out.StdOut.AtEndOfStream) {
+            var line = out.StdOut.ReadAll();
+            var targets = line.split('\r\n');
+            var check_id = new RegExp(device_id);
+            for (target in targets) {
+                if (targets[target].match(check_id)) {
+                    //TODO: this only gets single digit index, account for device index of 10+?
+                    var index = targets[target].substr(0,1);
+                    exec_verbose(path + CORDOVA_DEPLOY_EXE + ' ' + path + ' -d:' + index);
+                    return;
+                }
+            }
+            Log('Error : target ' + device_id + ' was not found.', true);
+            Log('DEPLOY FAILED.', true);
+            WScript.Quit(2);
+        }
+        else {
+            Log('Error : CordovaDeploy Failed to find any devices', true);
+            Log('DEPLOY FAILED.', true);
+            WScript.Quit(2);
+        }
+    }
+}
+
+function build(path) {
+    switch (build_type) {
+        case DEBUG :
+            exec_verbose('%comspec% /c ' + ROOT + '\\cordova\\build --debug');
+            break;
+        case RELEASE :
+            exec_verbose('%comspec% /c ' + ROOT + '\\cordova\\build --release');
+            break;
+        case NO_BUILD :
+            break;
+        case NONE :
+            Log("WARNING: [ --debug | --release | --nobuild ] not specified, defaulting to --debug.");
+            exec_verbose('%comspec% /c ' + ROOT + '\\cordova\\build --debug');
+            break;
+        default :
+            Log("Build option not recognized: " + build_type, true);
+            WScript.Quit(2);
+            break;
+    }
+}
+
+
+if (args.Count() > 0) {
+    // support help flags
+    if (args(0) == "--help" || args(0) == "/?" ||
+            args(0) == "help" || args(0) == "-help" || args(0) == "/help") {
+        Usage();
+        WScript.Quit(2);
+    }
+    else if (args.Count() > 2) {
+        Log('Error: Too many arguments.', true);
+        Usage();
+        WScript.Quit(2);
+    }
+    else if (fso.FolderExists(ROOT)) {
+        if (args.Count() > 1) {
+            if (args(1) == "--release") {
+                build_type = RELEASE;
+            }
+            else if (args(1) == "--debug") {
+                build_type = DEBUG;
+            }
+            else if (args(1) == "--nobuild") {
+                build_type = NO_BUILD;
+            }
+            else {
+                Log('Error: \"' + args(1) + '\" is not recognized as a deploy option', true);
+                Usage();
+                WScript.Quit(2);
+            }
+        }
+
+        if (args(0) == "--emulator" || args(0) == "-e") {
+            build(ROOT);
+            emulator(ROOT);
+        }
+        else if (args(0) == "--device" || args(0) == "-d") {
+            build(ROOT);
+            device(ROOT);
+        }
+        else if (args(0).substr(0,9) == "--target=") {
+            build(ROOT);
+            var device_id = args(0).split("--target=").join("");
+            target(ROOT, device_id);
+        }
+        else {
+            Log("WARNING: [ --target=<ID> | --emulator | --device ] not specified, defaulting to --emulator");
+            if (args(0) == "--release") {
+                build_type = RELEASE;
+                build(ROOT);
+                emulator(ROOT);
+            }
+            else if (args(0) == "--debug") {
+                build_type = DEBUG;
+                build(ROOT);
+                emulator(ROOT);
+            }
+            else if (args(0) == "--nobuild") {
+                build_type = NO_BUILD;
+                emulator(ROOT);
+            }
+            else {
+                Log('Error: \"' + args(0) + '\" is not recognized as a deploy option', true);
+                Usage();
+                WScript.Quit(2);
+            }
+        }
+    }
+    else {
+        Log('Error: Project directory not found,', true);
+        Usage();
+        WScript.Quit(2);
+    }
+}
+else {
+    Log("WARNING: [ --target=<ID> | --emulator | --device ] not specified, defaulting to --emulator");
+    build(ROOT);
+    emulator(ROOT);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/4ea376db/windows8/template/cordova/lib/log.js
----------------------------------------------------------------------
diff --git a/windows8/template/cordova/lib/log.js b/windows8/template/cordova/lib/log.js
new file mode 100644
index 0000000..0b4ea7d
--- /dev/null
+++ b/windows8/template/cordova/lib/log.js
@@ -0,0 +1,77 @@
+/*
+       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 args = WScript.Arguments;
+// working dir
+var ROOT = WScript.ScriptFullName.split('\\cordova\\lib\\log.js').join('');
+
+
+// help function
+function Usage() {
+    Log("");
+    Log("Usage: log");
+    Log("examples:");
+    Log("    log");
+    Log("         - logs output from running application  *NOT IMPLIMENTED*");
+    Log("");
+}
+
+//  logs to stdout or stderr
+function Log(msg, error) {
+    if (error) {
+        WScript.StdErr.WriteLine(msg);
+    }
+    else {
+        WScript.StdOut.WriteLine(msg);
+    }
+}
+
+// log output from running projects *NOT IMPLEMENTED*
+function log_output(path) {
+    Log("ERROR: Logging is not supported on Windows Phone", true);
+    WScript.Quit(1);
+}
+
+
+if (args.Count() > 0) {
+    // support help flags
+    if (args(0) == "--help" || args(0) == "/?" ||
+            args(0) == "help" || args(0) == "-help" || args(0) == "/help") {
+        Usage();
+        WScript.Quit(2);
+    }
+    else {
+        Log("Error: \"" + args(0) + "\" is not recognized as a log option.", true);
+        Usage();
+        WScript.Quit(2);
+    }
+}
+else {
+   if (fso.FolderExists(ROOT)) {
+        log_output(ROOT);
+    }
+    else {
+        Log("Error: Project directory not found,", true);
+        Usage();
+        WScript.Quit(2);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/4ea376db/windows8/template/cordova/lib/target-list.js
----------------------------------------------------------------------
diff --git a/windows8/template/cordova/lib/target-list.js b/windows8/template/cordova/lib/target-list.js
new file mode 100644
index 0000000..805eea5
--- /dev/null
+++ b/windows8/template/cordova/lib/target-list.js
@@ -0,0 +1,233 @@
+/*
+       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 args = WScript.Arguments;
+// working dir
+var ROOT = WScript.ScriptFullName.split('\\cordova\\lib\\target-list.js').join('');
+    // path to CordovaDeploy.exe
+var CORDOVA_DEPLOY_EXE = '\\cordova\\lib\\CordovaDeploy\\CordovaDeploy\\bin\\Debug\\CordovaDeploy.exe';
+    // path to CordovaDeploy
+var CORDOVA_DEPLOY = '\\cordova\\lib\\CordovaDeploy';
+
+// help/usage function
+function Usage() {
+    Log("");
+    Log("Usage: cscript target-list.js  [ --emulators | --devices | --started_emulators | --all ]");
+    Log("    --emulators         : List the possible target emulators availible.");
+    Log("    --devices           : List the possible target devices availible. *NOT IMPLEMENTED YET*");
+    Log("    --started_emulators : List any started emulators availible. *NOT IMPLEMENTED YET*");
+    Log("    --all               : List all devices returned by CordovaDeploy.exe -devices ");
+    Log("examples:");
+    Log("    cscript target-list.js --emulators");
+    Log("    cscript target-list.js --devices");
+    Log("    cscript target-list.js --started_emulators");
+    Log("    cscript target-list.js --all");
+    Log("");
+}
+
+// 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(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 output? Naa.....
+        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);
+    }
+}
+
+// returns all possible targets generated by the CordovaDeploy tool
+function get_targets(path) {
+    if (!fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
+        cordovaDeploy(path);
+    }
+    wscript_shell.CurrentDirectory = path + CORDOVA_DEPLOY + '\\CordovaDeploy\\bin\\Debug';
+    var cmd = 'CordovaDeploy -devices';
+    var out = wscript_shell.Exec(cmd);
+    while(out.Status == 0) {
+        WScript.Sleep(100);
+    }
+    //Check to make sure our script did not encounter an error
+    if (!out.StdErr.AtEndOfStream) {
+        var line = out.StdErr.ReadAll();
+        Log("Error calling CordovaDeploy : ", true);
+        Log(line, true);
+        WScript.Quit(2);
+    }
+    else {
+        if (!out.StdOut.AtEndOfStream) {
+            var line = out.StdOut.ReadAll();
+            var targets = line.split('\r\n');
+            //format (ID DESCRIPTION)
+            for (i in targets) {
+                // remove device index and separator colen
+                targets[i] = targets[i].replace(/\d*\s\:\s/, '').replace(/\:\s/, '');
+            }
+            return targets;
+        }
+        else {
+            Log('Error : CordovaDeploy Failed to find any devices', true);
+            WScript.Quit(2);
+        }
+    }
+}
+
+function list_targets(path) {
+    var targets = get_targets(path);
+    for (i in targets) {
+        Log(targets[i]);
+    }
+}
+
+// lists the Device returned by CordovaDeploy (NOTE: this does not indicate that a device is connected)
+function list_devices(path) {
+    var targets = get_targets(path);
+    var device_found = false;
+    for (i in targets) {
+        if (targets[i].match(/Device/)) {
+            Log(targets[i]);
+            device_found = true;
+        }
+    }
+    if (device_found) {
+        Log('');
+        Log('WARNING : This does not mean that a device is connected, make');
+        Log(' sure your device is connected before deploying to it.');
+    }
+}
+
+// lists the emulators availible to CordovaDeploy
+function list_emulator_images(path) {
+    var targets = get_targets(path);
+    for (i in targets) {
+        if (targets[i].match(/Emulator/)) {
+            Log(targets[i]);
+        }
+    }
+}
+
+// lists any started emulators *NOT IMPLEMENTED*
+function list_started_emulators(path) {
+    Log('ERROR : list-started-emulators is not supported on Windows Phone.', true);
+    WScript.Quit(1);
+}
+
+// builds the CordovaDeploy.exe if it does not already exist 
+function cordovaDeploy(path) {
+    if (fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
+        return;
+    }
+
+    // build CordovaDeploy.exe
+    if (fso.FolderExists(path + '\\cordova') && fso.FolderExists(path + CORDOVA_DEPLOY) && 
+        fso.FileExists(path + CORDOVA_DEPLOY + '\\CordovaDeploy.sln')) {
+        // delete any previously generated files
+        if (fso.FolderExists(path + CORDOVA_DEPLOY + "\\CordovaDeploy\\obj")) {
+            fso.DeleteFolder(path + CORDOVA_DEPLOY + "\\CordovaDeploy\\obj");
+        }
+        if (fso.FolderExists(path + CORDOVA_DEPLOY + "\\CordovaDeploy\\Bin")) {
+            fso.DeleteFolder(path + CORDOVA_DEPLOY + "\\CordovaDeploy\\Bin");
+        }
+        exec('msbuild ' + path + CORDOVA_DEPLOY + '\\CordovaDeploy.sln');
+
+        if (fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
+            return;
+        }
+        else {
+            Log("ERROR: MSBUILD FAILED TO COMPILE CordovaDeploy.exe", true);
+            WScript.Quit(2);
+        }
+    }
+    else {
+        Log("ERROR: CordovaDeploy.sln not found, unable to compile CordovaDeploy tool.", true);
+        WScript.Quit(2);
+    }
+}
+
+
+if (args.Count() > 0) {
+    // support help flags
+    if (args(0) == "--help" || args(0) == "/?" ||
+            args(0) == "help" || args(0) == "-help" || args(0) == "/help") {
+        Usage();
+        WScript.Quit(2);
+    }
+    else if (args.Count() > 1) {
+        Log("Error: Too many arguments.", true);
+        Usage();
+        WScript.Quit(2);
+    }
+    else if (fso.FolderExists(ROOT)) {
+        if (!fso.FolderExists(ROOT + '\\cordova')) {
+            Log("Error: cordova tooling folder not found in project directory,", true);
+            Log("could not lsit targets.", true);
+            WScript.Quit(2);
+        }
+
+        if (args(0) == "--emulators" || args(0) == "-e") {
+            list_emulator_images(ROOT);
+        }
+        else if (args(0) == "--devices" || args(0) == "-d") {
+            list_devices(ROOT);
+        }
+        else if (args(0) == "--started_emulators" || args(0) == "-s") {
+            list_started_emulators(ROOT);
+        }
+        else if (args(0) == "--all" || args(0) == "-a") {
+            list_targets(ROOT);
+        }
+        else {
+            Log("Error: \"" + args(0) + "\" is not recognized as a target-list option", true);
+            Usage();
+            WScript.Quit(2);
+        }
+    }
+    else {
+        Log("Error: Project directory not found,", true);
+        Usage();
+        WScript.Quit(2);
+    }
+}
+else {
+    Log("WARNING: target list not specified, showing all targets...");
+    list_targets(ROOT);
+}

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/4ea376db/windows8/template/cordova/log.bat
----------------------------------------------------------------------
diff --git a/windows8/template/cordova/log.bat b/windows8/template/cordova/log.bat
new file mode 100644
index 0000000..d34a8ab
--- /dev/null
+++ b/windows8/template/cordova/log.bat
@@ -0,0 +1,3 @@
+@ECHO OFF
+ECHO Sorry, logging is not supported for Windows Phone. 1>&2
+EXIT /B 1
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/4ea376db/windows8/template/cordova/run.bat
----------------------------------------------------------------------
diff --git a/windows8/template/cordova/run.bat b/windows8/template/cordova/run.bat
new file mode 100644
index 0000000..b966856
--- /dev/null
+++ b/windows8/template/cordova/run.bat
@@ -0,0 +1,9 @@
+@ECHO OFF
+SET full_path=%~dp0
+IF EXIST %full_path%lib\deploy.js (
+        cscript "%full_path%lib\deploy.js" %* //nologo
+) ELSE (
+    ECHO.
+    ECHO ERROR: Could not find 'deploy.js' in cordova/lib, aborting...>&2
+    EXIT /B 1
+)

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/4ea376db/windows8/template/cordova/version.bat
----------------------------------------------------------------------
diff --git a/windows8/template/cordova/version.bat b/windows8/template/cordova/version.bat
new file mode 100644
index 0000000..714e876
--- /dev/null
+++ b/windows8/template/cordova/version.bat
@@ -0,0 +1,9 @@
+@ECHO OFF
+SET full_path=%~dp0
+IF EXIST "%full_path%..\VERSION" (
+    type "%full_path%..\VERSION"
+) ELSE (
+    ECHO.
+    ECHO ERROR: Could not find file VERSION in project folder
+    EXIT /B 1
+)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/4ea376db/windows8/tools/scripts/create.bat
----------------------------------------------------------------------
diff --git a/windows8/tools/scripts/create.bat b/windows8/tools/scripts/create.bat
deleted file mode 100644
index 25dccbe..0000000
--- a/windows8/tools/scripts/create.bat
+++ /dev/null
@@ -1,25 +0,0 @@
-
-@echo off
-goto start
-
-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.
-
-
-:start
-csc /out:..\CordovaBuilder\CordovaBuilder\bin\Debug\CordovaBuilder.exe ..\CordovaBuilder\CordovaBuilder\CordovaBuilder.cs
-csc /out:..\CordovaBuilder\CordovaBuilder\bin\Release\CordovaBuilder.exe ..\CordovaBuilder\CordovaBuilder\CordovaBuilder.cs
\ No newline at end of file