Moved cordova scripts to remaining template, added cli support
diff --git a/bin/check_reqs.js b/bin/check_reqs.js
index 9ccad61..3dc1496 100644
--- a/bin/check_reqs.js
+++ b/bin/check_reqs.js
@@ -1,3 +1,23 @@
+/*
+ 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");
diff --git a/bin/create.js b/bin/create.js
index 8755f2c..ec19ed8 100644
--- a/bin/create.js
+++ b/bin/create.js
@@ -42,7 +42,7 @@
FULL_PATH = TEMPLATES_PATH + '\\full',
CUSTOM_PATH = TEMPLATES_PATH + '\\custom',
// default template to use when creating the project
- CREATE_TEMPLATE = FULL_PATH,
+ CREATE_TEMPLATE = STANDALONE_PATH,
PROJECT_PATH,
PACKAGE,
NAME;
@@ -174,13 +174,6 @@
replaceInFile(path + "\\MainPage.xaml.cs",/\$safeprojectname\$/g,namespace);
replaceInFile(path + "\\CordovaAppProj.csproj",/\$safeprojectname\$/g,namespace);
- //set up debug + emulate paths
- // TODO : Remove (replaced by cordova scripts build/run/log/clean etc...)
- replaceInFile(path + "\\cordova\\debug.bat",/__PATH_TO_TOOLING_SCRIPTS__/g, ROOT + '\\tooling\\scripts');
- replaceInFile(path + "\\cordova\\emulate.bat",/__PATH_TO_TOOLING_SCRIPTS__/g, ROOT + '\\tooling\\scripts');
- replaceInFile(path + "\\cordova\\debug.bat",/__PATH_TO_PROJ__/g, path);
- replaceInFile(path + "\\cordova\\emulate.bat",/__PATH_TO_PROJ__/g, path);
-
//copy .dll if necessary
if (CREATE_TEMPLATE == FULL_PATH || CREATE_TEMPLATE == CUSTOM_PATH) {
var dllPath = ROOT + FRAMEWORK_PATH + '\\Bin\\Release\\WPCordovaClassLib.dll';
@@ -206,12 +199,6 @@
}
}
- //TODO: remove cordova folder transfer once reorg of repo is finished and this is put into the template
- if (fso.FolderExists(path + '\\cordova')) {
- fso.DeleteFolder(path + '\\cordova');
- }
- fso.CopyFolder(ROOT + TOOLING_PATH + '\\cordova', path + '\\cordova');
-
Log("CREATE SUCCESS : " + path);
// TODO: Name the project according to the arguments
diff --git a/templates/standalone/CordovaAppProj.csproj b/templates/standalone/CordovaAppProj.csproj
index a251f92..dcd90bc 100644
--- a/templates/standalone/CordovaAppProj.csproj
+++ b/templates/standalone/CordovaAppProj.csproj
@@ -167,6 +167,7 @@
</Page>
</ItemGroup>
<ItemGroup>
+ <Content Include="www\**" />
<Content Include="config.xml" />
<Content Include="Images\appbar.back.rest.png" />
<Content Include="Images\appbar.close.rest.png" />
@@ -175,9 +176,6 @@
<Content Include="Images\appbar.save.rest.png" />
<Content Include="Images\appbar.stop.rest.png" />
<Content Include="resources\notification-beep.wav" />
- <Content Include="www\cordova-2.6.0.js" />
- <Content Include="www\img\logo.png" />
- <Content Include="www\js\index.js" />
<None Include="VERSION" />
<Resource Include="cordovalib\Images\appbar.back.rest.png" />
<Resource Include="cordovalib\Images\appbar.close.rest.png" />
@@ -190,12 +188,6 @@
<SubType>Designer</SubType>
</Content>
<None Include="BuildManifestProcessor.js" />
- <Content Include="www\css\index.css" />
- <Content Include="www\index.html">
- <SubType>Designer</SubType>
- </Content>
- <None Include="cordova\debug.bat" />
- <None Include="cordova\emulate.bat" />
<None Include="Properties\AppManifest.xml">
<SubType>Designer</SubType>
</None>
diff --git a/tooling/cordova/build.bat b/templates/standalone/cordova/build.bat
similarity index 100%
rename from tooling/cordova/build.bat
rename to templates/standalone/cordova/build.bat
diff --git a/tooling/cordova/clean.bat b/templates/standalone/cordova/clean.bat
similarity index 100%
rename from tooling/cordova/clean.bat
rename to templates/standalone/cordova/clean.bat
diff --git a/templates/standalone/cordova/debug.bat b/templates/standalone/cordova/debug.bat
deleted file mode 100644
index 649e515..0000000
--- a/templates/standalone/cordova/debug.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-:: 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 OFF
-cscript "__PATH_TO_TOOLING_SCRIPTS__\deploy.js" __PATH_TO_PROJ__ -debug //nologo
\ No newline at end of file
diff --git a/templates/standalone/cordova/emulate.bat b/templates/standalone/cordova/emulate.bat
deleted file mode 100644
index fbf9da2..0000000
--- a/templates/standalone/cordova/emulate.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-:: 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 OFF
-cscript "__PATH_TO_TOOLING_SCRIPTS__\deploy.js" __PATH_TO_PROJ__ -emulate //nologo
\ No newline at end of file
diff --git a/tooling/cordova/lib/CordovaDeploy/CordovaDeploy.sln b/templates/standalone/cordova/lib/CordovaDeploy/CordovaDeploy.sln
similarity index 100%
rename from tooling/cordova/lib/CordovaDeploy/CordovaDeploy.sln
rename to templates/standalone/cordova/lib/CordovaDeploy/CordovaDeploy.sln
diff --git a/tooling/cordova/lib/CordovaDeploy/CordovaDeploy/CordovaDeploy.csproj b/templates/standalone/cordova/lib/CordovaDeploy/CordovaDeploy/CordovaDeploy.csproj
similarity index 100%
rename from tooling/cordova/lib/CordovaDeploy/CordovaDeploy/CordovaDeploy.csproj
rename to templates/standalone/cordova/lib/CordovaDeploy/CordovaDeploy/CordovaDeploy.csproj
diff --git a/tooling/CordovaDeploy/CordovaDeploy/Program.cs b/templates/standalone/cordova/lib/CordovaDeploy/CordovaDeploy/Program.cs
similarity index 85%
rename from tooling/CordovaDeploy/CordovaDeploy/Program.cs
rename to templates/standalone/cordova/lib/CordovaDeploy/CordovaDeploy/Program.cs
index f8e1bdd..2e70187 100644
--- a/tooling/CordovaDeploy/CordovaDeploy/Program.cs
+++ b/templates/standalone/cordova/lib/CordovaDeploy/CordovaDeploy/Program.cs
@@ -55,10 +55,17 @@
//Console.Read();
}
- static void Log(string msg)
+ static void Log(string msg, bool error = false)
{
Debug.WriteLine(msg);
- Console.Error.WriteLine(msg);
+ if (error)
+ {
+ Console.Error.WriteLine(msg);
+ }
+ else
+ {
+ Console.Out.WriteLine(msg);
+ }
}
static Guid ReadAppId(string root)
@@ -77,12 +84,12 @@
}
else
{
- Log(string.Format("Unable to find appID, expected to find an App.ProductID property defined in the file {0}", manifestFilePath));
+ Log(string.Format("Unable to find appID, expected to find an App.ProductID property defined in the file {0}", manifestFilePath), true);
}
}
else
{
- Log(string.Format("Error: the file {0} does not exist", manifestFilePath));
+ Log(string.Format("Error: the file {0} does not exist", manifestFilePath), true);
}
@@ -151,16 +158,25 @@
}
else
{
- Log(string.Format("Error: could not find application icon at {0}", root + @"\ApplicationIcon.png"));
+ Log(string.Format("Error: could not find application icon at {0}", root + @"\ApplicationIcon.png"), true);
ReadWait();
return;
}
+ try {
+ xapFilePath = Directory.GetFiles(root + @"\Bin\Debug", "*.xap").FirstOrDefault();
+ } catch (DirectoryNotFoundException e) {
+ try {
+ xapFilePath = Directory.GetFiles(root + @"\Bin\Release", "*.xap").FirstOrDefault();
+ } catch (DirectoryNotFoundException ex) {
+ Log(string.Format("Error: could not find project build directoy in {0}", root), true);
+ Log("make sure your app has been successfully built before deploying.", true);
+ }
+ }
- xapFilePath = Directory.GetFiles(root + @"\Bin\Debug", "*.xap").FirstOrDefault();
if (string.IsNullOrEmpty(xapFilePath))
{
- Log(string.Format("Error: could not find application .xap in folder {0}", root));
+ Log(string.Format("Error: could not find application .xap in folder {0}", root), true);
ReadWait();
return;
}
@@ -193,7 +209,7 @@
}
catch (Exception ex)
{
- Console.WriteLine("Error: " + ex.Message);
+ Log("Error: " + ex.Message, true);
ReadWait();
return;
}
diff --git a/tooling/cordova/lib/CordovaDeploy/CordovaDeploy/Properties/AssemblyInfo.cs b/templates/standalone/cordova/lib/CordovaDeploy/CordovaDeploy/Properties/AssemblyInfo.cs
similarity index 100%
rename from tooling/cordova/lib/CordovaDeploy/CordovaDeploy/Properties/AssemblyInfo.cs
rename to templates/standalone/cordova/lib/CordovaDeploy/CordovaDeploy/Properties/AssemblyInfo.cs
diff --git a/tooling/cordova/lib/build.js b/templates/standalone/cordova/lib/build.js
similarity index 85%
rename from tooling/cordova/lib/build.js
rename to templates/standalone/cordova/lib/build.js
index d5e0704..948fca7 100644
--- a/tooling/cordova/lib/build.js
+++ b/templates/standalone/cordova/lib/build.js
@@ -31,8 +31,8 @@
Log("");
Log("Usage: build [ --debug | --release ]");
Log(" --help : Displays this dialog.");
- Log(" --debug : Builds project in debug mode.");
- Log(" --release : Builds project in release mode.");
+ 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");
@@ -67,7 +67,7 @@
if (!oShell.StdErr.AtEndOfStream) {
var line = oShell.StdErr.ReadAll();
Log(line, true);
- WScript.Quit(1);
+ WScript.Quit(2);
}
}
@@ -87,7 +87,7 @@
// builds the project and .xap in release mode
function build_xap_release(path) {
- Log("Building Cordova-WP7 Project:");
+ Log("Building Cordova-WP8 Project:");
Log("\tConfiguration : Release");
Log("\tDirectory : " + path);
@@ -105,13 +105,13 @@
}
}
}
- Log('ERROR: MSBuild failed to create .xap when building cordova-wp7 for release.', true);
- WScript.Quit(1);
+ 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-WP7 Project:");
+ Log("Building Cordova-WP8 Project:");
Log("\tConfiguration : Debug");
Log("\tDirectory : " + path);
@@ -129,8 +129,8 @@
}
}
}
- Log('ERROR: MSBuild failed to create .xap when building cordova-wp7 for debugging.', true);
- WScript.Quit(1);
+ Log('ERROR: MSBuild failed to create .xap when building cordova-wp8 for debugging.', true);
+ WScript.Quit(2);
}
@@ -141,42 +141,38 @@
if (args(0) == "--help" || args(0) == "/?" ||
args(0) == "help" || args(0) == "-help" || args(0) == "/help") {
Usage();
- WScript.Quit(1);
+ WScript.Quit(2);
}
else if (args.Count() > 1) {
Log("Error: Too many arguments.", true);
Usage();
- WScript.Quit(1);
+ 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(1);
+ WScript.Quit(2);
}
if (args(0) == "--debug" || args(0) == "-d") {
- if (fso.FolderExists(ROOT + '\\Bin\\Debug')) {
- exec_verbose('%comspec% /c ' + ROOT + '\\cordova\\clean --debug');
- }
+ exec_verbose('%comspec% /c ' + ROOT + '\\cordova\\clean');
build_xap_debug(ROOT);
}
else if (args(0) == "--release" || args(0) == "-r") {
- if (fso.FolderExists(ROOT + '\\Bin\\Release')) {
- exec_verbose('%comspec% /c ' + ROOT + '\\cordova\\clean --release');
- }
+ exec_verbose('%comspec% /c ' + ROOT + '\\cordova\\clean');
build_xap_release(ROOT);
}
else {
- Log("Error: \"" + arg(0) + "\" is not recognized as a build option", true);
+ Log("Error: \"" + args(0) + "\" is not recognized as a build option", true);
Usage();
- WScript.Quit(1);
+ WScript.Quit(2);
}
}
else {
Log("Error: Project directory not found,", true);
Usage();
- WScript.Quit(1);
+ WScript.Quit(2);
}
}
else {
diff --git a/tooling/cordova/lib/clean.js b/templates/standalone/cordova/lib/clean.js
similarity index 93%
rename from tooling/cordova/lib/clean.js
rename to templates/standalone/cordova/lib/clean.js
index a6ae740..3a8c871 100644
--- a/tooling/cordova/lib/clean.js
+++ b/templates/standalone/cordova/lib/clean.js
@@ -79,19 +79,18 @@
}
}
-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(1);
+ WScript.Quit(2);
}
else if (args.Count() > 1) {
Log("Error: Too many arguments.", true);
Usage();
- WScript.Quit(1);
+ WScript.Quit(2);
}
else if (fso.FolderExists(ROOT)) {
if (args(0) == "--debug" || args(0) == "-d") {
@@ -101,15 +100,15 @@
clean_release(ROOT);
}
else {
- Log("Error: \"" + arg(0) + "\" is not recognized as a build option", true);
+ Log("Error: \"" + args(0) + "\" is not recognized as a build option", true);
Usage();
- WScript.Quit(1);
+ WScript.Quit(2);
}
}
else {
Log("Error: Project directory not found,", true);
Usage();
- WScript.Quit(1);
+ WScript.Quit(2);
}
}
else {
@@ -120,6 +119,6 @@
else {
Log("Error: Project directory not found,", true);
Usage();
- WScript.Quit(1);
+ WScript.Quit(2);
}
}
\ No newline at end of file
diff --git a/templates/standalone/cordova/lib/deploy.js b/templates/standalone/cordova/lib/deploy.js
new file mode 100644
index 0000000..29a3f7d
--- /dev/null
+++ b/templates/standalone/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
diff --git a/tooling/cordova/lib/deploy-device.bat b/templates/standalone/cordova/lib/install-device.bat
similarity index 71%
rename from tooling/cordova/lib/deploy-device.bat
rename to templates/standalone/cordova/lib/install-device.bat
index 90e39bf..9507c36 100644
--- a/tooling/cordova/lib/deploy-device.bat
+++ b/templates/standalone/cordova/lib/install-device.bat
@@ -1,7 +1,7 @@
@ECHO OFF
SET full_path=%~dp0
IF EXIST %full_path%deploy.js (
- cscript "%full_path%deploy.js" %* --device //nologo
+ cscript "%full_path%deploy.js" %* --device --nobuild //nologo
) ELSE (
ECHO.
ECHO ERROR: Could not find 'deploy.js' in cordova/lib, aborting...>&2
diff --git a/tooling/cordova/lib/deploy-emulator.bat b/templates/standalone/cordova/lib/install-emulator.bat
similarity index 71%
rename from tooling/cordova/lib/deploy-emulator.bat
rename to templates/standalone/cordova/lib/install-emulator.bat
index b4a02d5..b3ee451 100644
--- a/tooling/cordova/lib/deploy-emulator.bat
+++ b/templates/standalone/cordova/lib/install-emulator.bat
@@ -1,7 +1,7 @@
@ECHO OFF
SET full_path=%~dp0
IF EXIST %full_path%deploy.js (
- cscript "%full_path%deploy.js" %* --emulator //nologo
+ cscript "%full_path%deploy.js" %* --emulator --nobuild //nologo
) ELSE (
ECHO.
ECHO ERROR: Could not find 'deploy.js' in cordova/lib, aborting...>&2
diff --git a/tooling/cordova/lib/list-devices.bat b/templates/standalone/cordova/lib/list-devices.bat
similarity index 100%
rename from tooling/cordova/lib/list-devices.bat
rename to templates/standalone/cordova/lib/list-devices.bat
diff --git a/tooling/cordova/lib/list-emulator-images.bat b/templates/standalone/cordova/lib/list-emulator-images.bat
similarity index 100%
rename from tooling/cordova/lib/list-emulator-images.bat
rename to templates/standalone/cordova/lib/list-emulator-images.bat
diff --git a/templates/standalone/cordova/lib/list-started-emulators.bat b/templates/standalone/cordova/lib/list-started-emulators.bat
new file mode 100644
index 0000000..d779b5d
--- /dev/null
+++ b/templates/standalone/cordova/lib/list-started-emulators.bat
@@ -0,0 +1,3 @@
+@ECHO OFF
+ECHO Sorry, list-started-emulators is not availible yet for Windows Phone. 1>&2
+EXIT /B 1
\ No newline at end of file
diff --git a/tooling/cordova/lib/log.js b/templates/standalone/cordova/lib/log.js
similarity index 92%
rename from tooling/cordova/lib/log.js
rename to templates/standalone/cordova/lib/log.js
index acd3399..0b4ea7d 100644
--- a/tooling/cordova/lib/log.js
+++ b/templates/standalone/cordova/lib/log.js
@@ -51,19 +51,18 @@
WScript.Quit(1);
}
-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(1);
+ WScript.Quit(2);
}
else {
- Log("Error: \"" + arg(0) + "\" is not recognized as a log option.", true);
+ Log("Error: \"" + args(0) + "\" is not recognized as a log option.", true);
Usage();
- WScript.Quit(1);
+ WScript.Quit(2);
}
}
else {
@@ -73,6 +72,6 @@
else {
Log("Error: Project directory not found,", true);
Usage();
- WScript.Quit(1);
+ WScript.Quit(2);
}
}
\ No newline at end of file
diff --git a/tooling/cordova/lib/start-emulator.bat b/templates/standalone/cordova/lib/start-emulator.bat
similarity index 90%
rename from tooling/cordova/lib/start-emulator.bat
rename to templates/standalone/cordova/lib/start-emulator.bat
index bf38d0c..19983fd 100644
--- a/tooling/cordova/lib/start-emulator.bat
+++ b/templates/standalone/cordova/lib/start-emulator.bat
@@ -1,3 +1,3 @@
@ECHO OFF
-ECHO Sorry, start-emulator is not availible yet for Windows Phone.>&2
+ECHO Sorry, start-emulator is not availible yet for Windows Phone. 1>&2
EXIT /B 1
\ No newline at end of file
diff --git a/tooling/cordova/lib/target-list.js b/templates/standalone/cordova/lib/target-list.js
similarity index 90%
rename from tooling/cordova/lib/target-list.js
rename to templates/standalone/cordova/lib/target-list.js
index b53670d..805eea5 100644
--- a/tooling/cordova/lib/target-list.js
+++ b/templates/standalone/cordova/lib/target-list.js
@@ -71,7 +71,7 @@
if (!oShell.StdErr.AtEndOfStream) {
var line = oShell.StdErr.ReadAll();
Log(line, true);
- WScript.Quit(1);
+ WScript.Quit(2);
}
}
@@ -89,25 +89,24 @@
//Check to make sure our script did not encounter an error
if (!out.StdErr.AtEndOfStream) {
var line = out.StdErr.ReadAll();
- if (line.substring(0, 1) == '0') {
- var targets = line.split('\r\n');
- return targets;
- }
- else {
- Log("Error calling CordovaDeploy : ", true);
- Log(line, true);
- WScript.Quit(1);
- }
+ Log("Error calling CordovaDeploy : ", true);
+ Log(line, true);
+ WScript.Quit(2);
}
else {
if (!out.StdOut.AtEndOfStream) {
- var line = out.StdErr.ReadAll();
+ 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(1);
+ WScript.Quit(2);
}
}
}
@@ -175,34 +174,33 @@
}
else {
Log("ERROR: MSBUILD FAILED TO COMPILE CordovaDeploy.exe", true);
- WScript.Quit(1);
+ WScript.Quit(2);
}
}
else {
Log("ERROR: CordovaDeploy.sln not found, unable to compile CordovaDeploy tool.", true);
- WScript.Quit(1);
+ 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(1);
+ WScript.Quit(2);
}
else if (args.Count() > 1) {
Log("Error: Too many arguments.", true);
Usage();
- WScript.Quit(1);
+ 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(1);
+ WScript.Quit(2);
}
if (args(0) == "--emulators" || args(0) == "-e") {
@@ -218,15 +216,15 @@
list_targets(ROOT);
}
else {
- Log("Error: \"" + arg(0) + "\" is not recognized as a target-list option", true);
+ Log("Error: \"" + args(0) + "\" is not recognized as a target-list option", true);
Usage();
- WScript.Quit(1);
+ WScript.Quit(2);
}
}
else {
Log("Error: Project directory not found,", true);
Usage();
- WScript.Quit(1);
+ WScript.Quit(2);
}
}
else {
diff --git a/templates/standalone/cordova/log.bat b/templates/standalone/cordova/log.bat
new file mode 100644
index 0000000..46dbe5c
--- /dev/null
+++ b/templates/standalone/cordova/log.bat
@@ -0,0 +1,3 @@
+@ECHO OFF
+ECHO Sorry, loging is yet supported for Windows Phone. 1>&2
+EXIT /B 1
\ No newline at end of file
diff --git a/templates/standalone/cordova/run.bat b/templates/standalone/cordova/run.bat
new file mode 100644
index 0000000..b966856
--- /dev/null
+++ b/templates/standalone/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
+)
diff --git a/tooling/CordovaDeploy/CordovaDeploy.sln b/tooling/CordovaDeploy/CordovaDeploy.sln
deleted file mode 100644
index 3305276..0000000
--- a/tooling/CordovaDeploy/CordovaDeploy.sln
+++ /dev/null
@@ -1,20 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CordovaDeploy", "CordovaDeploy\CordovaDeploy.csproj", "{E752165B-AF59-4FF0-8601-A2A69FE09E0E}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|x86 = Debug|x86
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {E752165B-AF59-4FF0-8601-A2A69FE09E0E}.Debug|x86.ActiveCfg = Debug|x86
- {E752165B-AF59-4FF0-8601-A2A69FE09E0E}.Debug|x86.Build.0 = Debug|x86
- {E752165B-AF59-4FF0-8601-A2A69FE09E0E}.Release|x86.ActiveCfg = Release|x86
- {E752165B-AF59-4FF0-8601-A2A69FE09E0E}.Release|x86.Build.0 = Release|x86
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/tooling/CordovaDeploy/CordovaDeploy/CordovaDeploy.csproj b/tooling/CordovaDeploy/CordovaDeploy/CordovaDeploy.csproj
deleted file mode 100644
index fb9949f..0000000
--- a/tooling/CordovaDeploy/CordovaDeploy/CordovaDeploy.csproj
+++ /dev/null
@@ -1,79 +0,0 @@
-<?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.
--->
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
- <ProductVersion>8.0.30703</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{E752165B-AF59-4FF0-8601-A2A69FE09E0E}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>CordovaDeploy</RootNamespace>
- <AssemblyName>CordovaDeploy</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
- <TargetFrameworkProfile>Client</TargetFrameworkProfile>
- <FileAlignment>512</FileAlignment>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
- <PlatformTarget>x86</PlatformTarget>
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
- <PlatformTarget>x86</PlatformTarget>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="Microsoft.Smartdevice.Connectivity, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>C:\Program Files (x86)\Common Files\microsoft shared\Phone Tools\CoreCon\10.0\Bin\Microsoft.Smartdevice.Connectivity.dll</HintPath>
- </Reference>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="Microsoft.CSharp" />
- <Reference Include="System.Data" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Program.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
diff --git a/tooling/CordovaDeploy/CordovaDeploy/Properties/AssemblyInfo.cs b/tooling/CordovaDeploy/CordovaDeploy/Properties/AssemblyInfo.cs
deleted file mode 100644
index 3c26c87..0000000
--- a/tooling/CordovaDeploy/CordovaDeploy/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("CordovaDeploy")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("CordovaDeploy")]
-[assembly: AssemblyCopyright("Copyright © 2012")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("256b11aa-d4bb-48cf-8024-7c040421fa8d")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/tooling/cordova/lib/CordovaDeploy/CordovaDeploy/Program.cs b/tooling/cordova/lib/CordovaDeploy/CordovaDeploy/Program.cs
deleted file mode 100644
index f8e1bdd..0000000
--- a/tooling/cordova/lib/CordovaDeploy/CordovaDeploy/Program.cs
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- 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.
-*/
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.SmartDevice.Connectivity;
-using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.IO;
-using System.Xml.XPath;
-using System.Xml;
-using System.Xml.Linq;
-
-
-namespace CordovaDeploy
-{
-
- class DeployTool
- {
-
- static void Usage()
- {
- Log("Usage: CordovaDeploy [ -devices BuildOutputPath -d:DeviceIndex ]");
- Log(" -devices : lists the devices and exits");
- Log(" BuildOutputPath : path to the built application, typically Bin/Debug/ or Bin/Release/");
- Log(" -d : index of the device to deploy, default is 0 ");
- Log("examples:");
- Log(" CordovaDeploy -devices");
- Log(" CordovaDeploy Bin/Debug");
- Log(" CordovaDeploy Bin/Release -d:1");
-
- }
-
- static void ReadWait()
- {
- //Console.WriteLine("\nPress ENTER to continue...");
- //Console.Read();
- }
-
- static void Log(string msg)
- {
- Debug.WriteLine(msg);
- Console.Error.WriteLine(msg);
- }
-
- static Guid ReadAppId(string root)
- {
- Guid appID = Guid.Empty;
- string manifestFilePath = root + @"\Properties\WMAppManifest.xml";
-
- if (File.Exists(manifestFilePath))
- {
- XDocument xdoc = XDocument.Load(manifestFilePath);
- var appNode = xdoc.Root.Descendants("App").FirstOrDefault();
- if (appNode != null)
- {
- string guidStr = appNode.Attribute("ProductID").Value;
- appID = new Guid(guidStr);
- }
- else
- {
- Log(string.Format("Unable to find appID, expected to find an App.ProductID property defined in the file {0}", manifestFilePath));
- }
- }
- else
- {
- Log(string.Format("Error: the file {0} does not exist", manifestFilePath));
- }
-
-
- return appID;
- }
-
-
-
- static void ListDevices()
- {
- // Get CoreCon WP7 SDK
- DatastoreManager dsmgrObj = new DatastoreManager(1033);
- Platform WP7SDK = dsmgrObj.GetPlatforms().Single(p => p.Name == "Windows Phone 7");
- Collection<Device> devices = WP7SDK.GetDevices();
- for (int index = 0; index < devices.Count; index++)
- {
- Device d = devices[index];
- string info = string.Format("{0} : {1} : {2}", index.ToString(), d.Id, d.Name);
- Log(info);
- }
- }
-
- static void Main(string[] args)
- {
- int deviceIndex = 0;
-
- string iconFilePath = "";
- string xapFilePath = "";
- Guid appID = Guid.Empty;
-
- string root = Directory.GetCurrentDirectory();
-
- if (args.Length < 1)
- {
- Usage();
- ReadWait();
- return;
- }
- else if (args[0] == "-devices")
- {
- ListDevices();
- return;
- }
- else if (args.Length > 1 && args[1].StartsWith("-d:"))
- {
- deviceIndex = int.Parse(args[1].Substring(3));
- }
-
-
- if (Directory.Exists(args[0]))
- {
- DirectoryInfo info = new DirectoryInfo(args[0]);
- root = info.FullName;
- }
-
- appID = ReadAppId(root);
- if (appID == Guid.Empty)
- {
- // Logging of errors is done in ReadAppId
- return;
- }
-
- if (File.Exists(root + @"\ApplicationIcon.png"))
- {
- iconFilePath = root + @"\ApplicationIcon.png";
- }
- else
- {
- Log(string.Format("Error: could not find application icon at {0}", root + @"\ApplicationIcon.png"));
- ReadWait();
- return;
- }
-
-
- xapFilePath = Directory.GetFiles(root + @"\Bin\Debug", "*.xap").FirstOrDefault();
- if (string.IsNullOrEmpty(xapFilePath))
- {
- Log(string.Format("Error: could not find application .xap in folder {0}", root));
- ReadWait();
- return;
- }
-
-
- // Get CoreCon WP7 SDK
- DatastoreManager dsmgrObj = new DatastoreManager(1033);
- Collection<Platform> WP7SDKs = dsmgrObj.GetPlatforms();
- Platform WP7SDK = dsmgrObj.GetPlatforms().Single(p => p.Name == "Windows Phone 7");
-
- Collection<Device> devices = null;
-
- devices = WP7SDK.GetDevices();
-
- //// Get Emulator / Device
- Device WP7Device = devices[deviceIndex];
-
- if (WP7Device != null)
- {
- RemoteApplication app;
- bool isConnected = WP7Device.IsConnected();
-
- Debug.WriteLine(WP7Device.ToString());
-
- if (!isConnected)
- {
- try
- {
- WP7Device.Connect();
- }
- catch (Exception ex)
- {
- Console.WriteLine("Error: " + ex.Message);
- ReadWait();
- return;
- }
- }
-
- if (WP7Device.IsApplicationInstalled(appID))
- {
- Log("Uninstalling XAP from " + WP7Device.Name);
- app = WP7Device.GetApplication(appID);
- app.Uninstall();
- }
-
- Log("Installing app on " + WP7Device.Name);
- app = WP7Device.InstallApplication(appID, appID, "NormalApp", iconFilePath, xapFilePath);
-
- Log("Launching app on " + WP7Device.Name);
- app.Launch();
-
- ReadWait();
- }
- }
- }
-}
diff --git a/tooling/cordova/lib/deploy.js b/tooling/cordova/lib/deploy.js
deleted file mode 100644
index fcb011e..0000000
--- a/tooling/cordova/lib/deploy.js
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- 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';
-var BUILD_RELEASE = false;
-
-
-// help function
-function Usage() {
- Log("");
- Log("Usage: run [ --device | --emulator | --target=<id> ]");
- 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("examples:");
- Log(" run");
- Log(" run --emulator");
- Log(" run --device");
- Log(" run --target=7988B8C3-3ADE-488d-BA3E-D052AC9DC710");
- 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(1);
- }
-}
-
-// 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(1);
- }
- 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(1);
- }
- }
- else {
- Log('ERROR: CordovaDeploy.sln not found, unable to compile CordovaDeploy tool.', true);
- WScript.Quit(1);
- }
-}
-
-// builds and launches project on device
-function device(path)
-{
- cordovaDeploy(path);
- if (fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
- Log('Deploying to device ...');
- 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(1);
- }
-}
-
-// builds and launches project on emulator
-function emulator(path)
-{
- cordovaDeploy(path);
- if (fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
- Log('Deploying to emulator ...');
- 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(1);
- }
-}
-
-// builds and launches the project on the specified target
-function target(path, device_id) {
- cordovaDeploy(path);
- if (fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
- Log('Deploying to ' + device_id + ' ...');
- var out = wscript_shell.Exec('cscript ' + path + '\\cordova\\lib\\target-list.js //nologo');
- 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 getting availible targets : ', true);
- Log(line, true);
- WScript.Quit(1);
- }
- 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(1);
- }
- else {
- Log('Error : target-list.js Failed to find any devices', true);
- Log('DEPLOY FAILED.', true);
- WScript.Quit(1);
- }
-
- }
-
- }
- else {
- Log('Error: Failed to find CordovaDeploy.exe in ' + path, true);
- Log('DEPLOY FAILED.', true);
- WScript.Quit(1);
- }
-}
-
-function build(path) {
- if (!BUILD_RELEASE) {
- exec_verbose('%comspec% /c ' + ROOT + '\\cordova\\build --debug');
- }
- else {
- exec_verbose('%comspec% /c ' + ROOT + '\\cordova\\build --release');
- }
-}
-
-
-
-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(1);
- }
- else if (args.Count() > 1) {
- Log('Error: Too many arguments.', true);
- Usage();
- WScript.Quit(1);
- }
- else if (fso.FolderExists(ROOT)) {
- 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('Error: \"' + arg(0) + '\" is not recognized as a deploy option', true);
- Usage();
- WScript.Quit(1);
- }
- }
- else {
- Log('Error: Project directory not found,', true);
- Usage();
- WScript.Quit(1);
- }
-}
-else {
- Log('WARNING: [ --device | --emulator | --target=<id> ] not specified, defaulting to emulator...');
- emulator(ROOT);
-}
\ No newline at end of file
diff --git a/tooling/cordova/lib/list-started-emulators.bat b/tooling/cordova/lib/list-started-emulators.bat
deleted file mode 100644
index 93e5c5f..0000000
--- a/tooling/cordova/lib/list-started-emulators.bat
+++ /dev/null
@@ -1,9 +0,0 @@
-@ECHO OFF
-SET full_path=%~dp0
-IF EXIST %full_path%target-list.js (
- cscript "%full_path%target-list.js" %* --started_emulators //nologo
-) ELSE (
- ECHO.
- ECHO ERROR: Could not find 'target-list.js' in cordova/lib, aborting...>&2
- EXIT /B 1
-)
\ No newline at end of file
diff --git a/tooling/cordova/lib/run.js b/tooling/cordova/lib/run.js
deleted file mode 100644
index 7ad3ba6..0000000
--- a/tooling/cordova/lib/run.js
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- 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\\run.js').join('');
-
-
-// help function
-function Usage() {
- Log("");
- Log("Usage: run [ --target=<ID> ]");
- Log("examples:");
- Log(" run");
- Log(" run target=7988B8C3-3ADE-488d-BA3E-D052AC9DC710")
- Log("");
- Log("Flow for run command :");
- Log("\t0. Are there any actual devices available? (use list-devices to determine this). If so, target the first one. If no, continue.");
- Log("\t1. Are there any actual emulators available, i.e. started/running? (use list-started-emulators to determine this). If so, target the first one. If no, continue.");
- Log("\t2. Are there any emulator images available to start? (use list-emulator-images to determine this). If so, call start-emulator <id> of the first available image, wait for it to become ready, then target it. If no, continue.");
- Log("\t3. Fail horribly.");
-}
-
-// 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);
- }
-}
-
-// log to stdout or stderr
-function Log(msg, error) {
- if (error) {
- WScript.StdErr.WriteLine(msg);
- }
- else {
- WScript.StdOut.WriteLine(msg);
- }
-}
-
-// deploy to specified target
-function target(path, target) {
- var cmd = 'cscript ' + path + '\\cordova\\lib\\deploy.js --target=' + target + ' //nologo';
- exec_verbose(cmd);
-}
-
-// deploy to availible device, if no device is availible, deploy to emulator.
-// TODO: implement list-devices (currenly not possible) and list-started-emulators and use device first then started emulator
-function deploy(path) {
- var cmd = 'cscript ' + path + '\\cordova\\lib\\deploy.js --emulator //nologo';
- exec_verbose(cmd);
-}
-
-
-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(1);
- }
- else if (args.Count() > 1) {
- Log("Error: Too many arguments.", true);
- Usage();
- WScript.Quit(1);
- }
- else if (fso.FolderExists(ROOT)) {
- if (args(0).substr(0,9) == "--target=") {
- target(ROOT, args(0));
- }
- else {
- Log("Error: \"" + arg(0) + "\" is not recognized as a run option", true);
- Usage();
- WScript.Quit(1);
- }
- }
- else {
- Log("Error: Project directory not found,", true);
- Usage();
- WScript.Quit(1);
- }
-}
-else {
- Log("WARNING: [ --target=<ID> ] not specified, using defaults...");
- deploy(ROOT);
-}
diff --git a/tooling/cordova/log.bat b/tooling/cordova/log.bat
deleted file mode 100644
index a491724..0000000
--- a/tooling/cordova/log.bat
+++ /dev/null
@@ -1,9 +0,0 @@
-@ECHO OFF
-SET full_path=%~dp0
-IF EXIST %full_path%lib\log.js (
- cscript "%full_path%lib\log.js" %* //nologo
-) ELSE (
- ECHO.
- ECHO ERROR: Could not find 'log.js' in cordova/lib, aborting...>&2
- EXIT /B 1
-)
\ No newline at end of file
diff --git a/tooling/cordova/run.bat b/tooling/cordova/run.bat
deleted file mode 100644
index daf077b..0000000
--- a/tooling/cordova/run.bat
+++ /dev/null
@@ -1,9 +0,0 @@
-@ECHO OFF
-SET full_path=%~dp0
-IF EXIST %full_path%lib\deploy.js (
- cscript "%full_path%lib\run.js" %* //nologo
-) ELSE (
- ECHO.
- ECHO ERROR: Could not find 'run.js' in cordova/lib, aborting...>&2
- EXIT /B 1
-)