Merge pull request #9 from bennmapes/CB-2833
[CB-2833] Changed git repo urls in scripts
diff --git a/bin/create.js b/bin/create.js
index bc2f5d9..727eefd 100644
--- a/bin/create.js
+++ b/bin/create.js
@@ -28,7 +28,10 @@
// sub folder for full project
FULL_PATH = TEMPLATES_PATH + '\\full',
// default template to use when creating the project
- CREATE_TEMPLATE = STANDALONE_PATH;
+ CREATE_TEMPLATE = STANDALONE_PATH,
+ PROJECT_PATH,
+ PACKAGE,
+ NAME;
// working dir
var ROOT = WScript.ScriptFullName.split('\\bin\\create.js').join('');
@@ -36,12 +39,13 @@
function Usage()
{
- WScript.StdOut.WriteLine("Usage: create [ PathTONewProject ProjectName ]");
+ WScript.StdOut.WriteLine("Usage: create PathTONewProject [ PackageName AppName ]");
WScript.StdOut.WriteLine(" PathTONewProject : The path to where you wish to create the project");
- WScript.StdOut.WriteLine(" ProjectName : The name of the project (default is CordovaAppProj)");
+ WScript.StdOut.WriteLine(" PackageName : The namespace for the project (default is CordovaAppProj)")
+ WScript.StdOut.WriteLine(" AppName : The name of the application (default is CordovaAppProj)");
WScript.StdOut.WriteLine("examples:");
WScript.StdOut.WriteLine(" create C:\\Users\\anonymous\\Desktop\\MyProject");
- WScript.StdOut.WriteLine(" create C:\\Users\\anonymous\\Desktop\\MyProject AnApplication");
+ WScript.StdOut.WriteLine(" create C:\\Users\\anonymous\\Desktop\\MyProject io.Cordova.Example AnApp");
}
var ForReading = 1, ForWriting = 2, ForAppending = 8;
@@ -98,11 +102,12 @@
}
// creates a project from the standalone template
-function create(path, name)
+function create(path, namespace, name)
{
WScript.StdOut.WriteLine("Creating Cordova-WP7 Project:");
- WScript.StdOut.WriteLine("\tName : " + name);
- WScript.StdOut.WriteLine("\tDirectory : " + path);
+ WScript.StdOut.WriteLine("\tApp Name : " + name);
+ WScript.StdOut.WriteLine("\tNamespace : " + namespace);
+ WScript.StdOut.WriteLine("\tPath : " + path);
fso.CreateFolder(path);
@@ -111,7 +116,7 @@
var sourceItems = shell.NameSpace(ROOT + CREATE_TEMPLATE).items();
if (dest != null)
{
- dest.CopyHere(sourceItems);
+ dest.CopyHere(sourceItems, 4|20);
WScript.Sleep(1000);
}
else
@@ -136,49 +141,61 @@
replaceInFile(path + "\\Properties\\WMAppManifest.xml", /\$guid1\$/, newProjGuid);
// replace safe-project-name in all files
replaceInFile(path + "\\Properties\\WMAppManifest.xml",/\$safeprojectname\$/g, name);
- replaceInFile(path + "\\App.xaml",/\$safeprojectname\$/g, name);
- replaceInFile(path + "\\App.xaml.cs",/\$safeprojectname\$/g, name);
- replaceInFile(path + "\\CordovaAppProj.csproj",/\$safeprojectname\$/g, name);
- replaceInFile(path + "\\MainPage.xaml",/\$safeprojectname\$/g, name);
- replaceInFile(path + "\\MainPage.xaml.cs",/\$safeprojectname\$/g, name);
+ replaceInFile(path + "\\App.xaml",/\$safeprojectname\$/g, namespace);
+ replaceInFile(path + "\\App.xaml.cs",/\$safeprojectname\$/g, namespace);
+ replaceInFile(path + "\\CordovaAppProj.csproj",/\$safeprojectname\$/g, namespace);
+ replaceInFile(path + "\\MainPage.xaml",/\$safeprojectname\$/g, namespace);
+ replaceInFile(path + "\\MainPage.xaml.cs",/\$safeprojectname\$/g, namespace);
+
+ //set up debug + emulate paths
+ 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);
WScript.StdOut.WriteLine("CREATE SUCCESS.");
}
-
if(args.Count() > 0)
{
// support help flags
if(args(0) == "--help" || args(0) == "/?" ||
- args(0) == "help" || args(0) == "-help" || args(0) == "/help")
+ args(0) == "help" || args(0) == "-help" || args(0) == "/help" || args(0) == "-h")
{
Usage();
WScript.Quit(1);
}
+
+ PROJECT_PATH = args(0);
+ if(fso.FolderExists(PROJECT_PATH))
+ {
+ WScript.StdOut.WriteLine("Project directory already exists:");
+ WScript.StdOut.WriteLine("\t" + PROJECT_PATH);
+ WScript.StdOut.WriteLine("CREATE FAILED.");
+ WScript.Quit(1);
+ }
+
+ if(args.Count() > 1)
+ {
+ PACKAGE = args(1);
+ }
else
{
- PROJECT_PATH = args(0);
- if(fso.FolderExists(PROJECT_PATH))
- {
- WScript.StdOut.WriteLine("Project directory already exists:");
- WScript.StdOut.WriteLine("\t" + PROJECT_PATH);
- Wscript.StdOut.WriteLine("BUILD FAILED.");
- Wscript.Quit(1);
- }
- else
- {
- if(args.Count() > 1)
- {
- create(PROJECT_PATH, args(1));
- }
- else
- {
- create(PROJECT_PATH, "CordovaAppProj");
- }
- }
+ PACKAGE = "CordovaAppProj";
}
+
+ if(args.Count() > 2)
+ {
+ NAME = args(2);
+ }
+ else
+ {
+ NAME = "CordovaAppProj";
+ }
+
+ create(PROJECT_PATH, PACKAGE, NAME);
}
else
{
diff --git a/framework/WPCordovaClassLib.csproj b/framework/WPCordovaClassLib.csproj
index 85ec759..846bfdf 100644
--- a/framework/WPCordovaClassLib.csproj
+++ b/framework/WPCordovaClassLib.csproj
@@ -287,8 +287,8 @@
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
<AssemblyInfo
- AssemblyVersion=" "
- AssemblyFileVersion="$(VersionNumber)"
+ AssemblyVersion="$(BaseVersion)"
+ AssemblyFileVersion="$(BaseVersion)"
AssemblyDescription="$(VersionNumber)"
>
</AssemblyInfo>
diff --git a/templates/full/cordova/debug.bat b/templates/full/cordova/debug.bat
index 4efc80c..649e515 100644
--- a/templates/full/cordova/debug.bat
+++ b/templates/full/cordova/debug.bat
@@ -1,68 +1,18 @@
-
-@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
-
-
-if /i "%1"=="help" goto usage
-if /i "%1"=="-help" goto usage
-if /i "%1"=="--help" goto usage
-if /i "%1"=="/help" goto usage
-if /i "%1"=="/?" goto usage
-
-
-if defined VCINSTALLDIR goto start-msbuild
-if not defined VS100COMNTOOLS goto msbuild-missing
-if not exist "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" goto msbuild-missing
-call "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat"
-if not defined VCINSTALLDIR goto msbuild-missing
-goto start-msbuild
-
-
-:builderror
-echo Error level 1
-goto exit
-
-:msbuild-missing
-echo Error! Cannot run msbuild from this command prompt. Try running a VS Command prompt.
-goto exit
-
-
-:start-msbuild
-cd ..
-msbuild /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo /p:Configuration=Debug
-cd cordova
-if errorlevel 1 goto builderror
-goto deploy
-
-:usage
-echo "Usage: %0"
-echo "solution file is expected to be in the parent folder."
-goto exit
-
-:deploy
-CordovaDeploy ../Bin/Debug -d:1
-
-
-:exit
-
-
+:: 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/full/cordova/emulate.bat b/templates/full/cordova/emulate.bat
index b3375fe..fbf9da2 100644
--- a/templates/full/cordova/emulate.bat
+++ b/templates/full/cordova/emulate.bat
@@ -1,24 +1,18 @@
-
-@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
-CordovaDeploy ../Bin/Debug -d:1
\ No newline at end of file
+:: 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/templates/standalone/cordova/debug.bat b/templates/standalone/cordova/debug.bat
index 4efc80c..649e515 100644
--- a/templates/standalone/cordova/debug.bat
+++ b/templates/standalone/cordova/debug.bat
@@ -1,68 +1,18 @@
-
-@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
-
-
-if /i "%1"=="help" goto usage
-if /i "%1"=="-help" goto usage
-if /i "%1"=="--help" goto usage
-if /i "%1"=="/help" goto usage
-if /i "%1"=="/?" goto usage
-
-
-if defined VCINSTALLDIR goto start-msbuild
-if not defined VS100COMNTOOLS goto msbuild-missing
-if not exist "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat" goto msbuild-missing
-call "%VS100COMNTOOLS%\..\..\vc\vcvarsall.bat"
-if not defined VCINSTALLDIR goto msbuild-missing
-goto start-msbuild
-
-
-:builderror
-echo Error level 1
-goto exit
-
-:msbuild-missing
-echo Error! Cannot run msbuild from this command prompt. Try running a VS Command prompt.
-goto exit
-
-
-:start-msbuild
-cd ..
-msbuild /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo /p:Configuration=Debug
-cd cordova
-if errorlevel 1 goto builderror
-goto deploy
-
-:usage
-echo "Usage: %0"
-echo "solution file is expected to be in the parent folder."
-goto exit
-
-:deploy
-CordovaDeploy ../Bin/Debug -d:1
-
-
-:exit
-
-
+:: 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
index b3375fe..fbf9da2 100644
--- a/templates/standalone/cordova/emulate.bat
+++ b/templates/standalone/cordova/emulate.bat
@@ -1,24 +1,18 @@
-
-@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
-CordovaDeploy ../Bin/Debug -d:1
\ No newline at end of file
+:: 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/templates/standalone/cordovalib/Commands/AudioPlayer.cs b/templates/standalone/cordovalib/Commands/AudioPlayer.cs
index ffc6a94..a83be5b 100644
--- a/templates/standalone/cordovalib/Commands/AudioPlayer.cs
+++ b/templates/standalone/cordovalib/Commands/AudioPlayer.cs
@@ -23,6 +23,7 @@
using Microsoft.Xna.Framework.Media;
using Microsoft.Phone.Controls;
using System.Diagnostics;
+using System.Windows.Resources;
namespace WPCordovaClassLib.Cordova.Commands
{
@@ -57,7 +58,7 @@
private const int MediaErrorStopState = 8;
//TODO: get rid of this callback, it should be universal
- private const string CallbackFunction = "CordovaMediaonStatus";
+ //private const string CallbackFunction = "CordovaMediaonStatus";
#endregion
@@ -132,7 +133,6 @@
/// </summary>
public void Dispose()
{
- Debug.WriteLine("Dispose :: " + this.audioFile);
if (this.player != null)
{
this.stopPlaying();
@@ -147,6 +147,33 @@
this.FinalizeXnaGameLoop();
}
+ private void InvokeCallback(int message, string value, bool removeHandler)
+ {
+ string args = string.Format("('{0}',{1},{2});", this.id, message, value);
+ string callback = @"(function(id,msg,value){
+ try {
+ if (msg == Media.MEDIA_ERROR) {
+ value = {'code':value};
+ }
+ Media.onStatus(id,msg,value);
+ }
+ catch(e) {
+ console.log('Error calling Media.onStatus :: ' + e);
+ }
+ })" + args;
+ this.handler.InvokeCustomScript(new ScriptCallback("eval", new string[] { callback }), false);
+ }
+
+ private void InvokeCallback(int message, int value, bool removeHandler)
+ {
+ InvokeCallback(message, value.ToString(), removeHandler);
+ }
+
+ private void InvokeCallback(int message, double value, bool removeHandler)
+ {
+ InvokeCallback(message, value.ToString(), removeHandler);
+ }
+
/// <summary>
/// Starts recording, data is stored in memory
/// </summary>
@@ -155,7 +182,7 @@
{
if (this.player != null)
{
- this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorPlayModeSet),false);
+ InvokeCallback(MediaError, MediaErrorPlayModeSet, false);
}
else if (this.recorder == null)
{
@@ -175,13 +202,14 @@
}
catch (Exception)
{
- this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorStartingRecording),false);
+ InvokeCallback(MediaError, MediaErrorStartingRecording, false);
+ //this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorStartingRecording),false);
}
}
else
{
-
- this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorAlreadyRecording),false);
+ InvokeCallback(MediaError, MediaErrorAlreadyRecording, false);
+ //this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorAlreadyRecording),false);
}
}
@@ -223,12 +251,13 @@
{
if (this.recorder != null)
{
- this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorRecordModeSet),false);
+ InvokeCallback(MediaError, MediaErrorRecordModeSet, false);
+ //this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorRecordModeSet),false);
return;
}
- if (this.player == null || this.player.Source == null || this.player.Source.AbsolutePath.LastIndexOf(filePath) < 0)
+ if (this.player == null || this.player.Source.AbsolutePath.LastIndexOf(filePath) < 0)
{
try
{
@@ -243,7 +272,6 @@
if (grid != null)
{
- //Microsoft.Xna.Framework.Media.MediaPlayer.Play(
this.player = grid.FindName("playerMediaElement") as MediaElement;
if (this.player == null) // still null ?
{
@@ -276,6 +304,37 @@
{
using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication())
{
+ if (!isoFile.FileExists(filePath))
+ {
+ // try to unpack it from the dll into isolated storage
+ StreamResourceInfo fileResourceStreamInfo = Application.GetResourceStream(new Uri(filePath, UriKind.Relative));
+ if (fileResourceStreamInfo != null)
+ {
+ using (BinaryReader br = new BinaryReader(fileResourceStreamInfo.Stream))
+ {
+ byte[] data = br.ReadBytes((int)fileResourceStreamInfo.Stream.Length);
+
+ string[] dirParts = filePath.Split('/');
+ string dirName = "";
+ for (int n = 0; n < dirParts.Length - 1; n++)
+ {
+ dirName += dirParts[n] + "/";
+ }
+ if (!isoFile.DirectoryExists(dirName))
+ {
+ isoFile.CreateDirectory(dirName);
+ }
+
+ using (IsolatedStorageFileStream outFile = isoFile.OpenFile(filePath, FileMode.Create))
+ {
+ using (BinaryWriter writer = new BinaryWriter(outFile))
+ {
+ writer.Write(data);
+ }
+ }
+ }
+ }
+ }
if (isoFile.FileExists(filePath))
{
using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(filePath, FileMode.Open, isoFile))
@@ -285,10 +344,9 @@
}
else
{
- Debug.WriteLine("Error: source doesn't exist :: " + filePath);
- this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, 1),false);
+ InvokeCallback(MediaError, MediaErrorPlayModeSet, false);
+ //this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, 1), false);
return;
- //throw new ArgumentException("Source doesn't exist");
}
}
}
@@ -296,8 +354,9 @@
}
catch (Exception e)
{
- Debug.WriteLine("Error: " + e.Message);
- this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorStartingPlayback),false);
+ Debug.WriteLine("Error in AudioPlayer::startPlaying : " + e.Message);
+ InvokeCallback(MediaError, MediaErrorStartingPlayback, false);
+ //this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorStartingPlayback),false);
}
}
else
@@ -309,7 +368,8 @@
}
else
{
- this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorResumeState),false);
+ InvokeCallback(MediaError, MediaErrorResumeState, false);
+ //this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorResumeState),false);
}
}
}
@@ -322,7 +382,8 @@
if (this.player != null)
{
this.duration = this.player.NaturalDuration.TimeSpan.TotalSeconds;
- this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaDuration, this.duration),false);
+ InvokeCallback(MediaDuration, this.duration, false);
+ //this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaDuration, this.duration),false);
if (!this.prepareOnly)
{
this.player.Play();
@@ -350,7 +411,8 @@
private void MediaFailed(object sender, RoutedEventArgs arg)
{
player.Stop();
- this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError.ToString(), "Media failed"),false);
+ InvokeCallback(MediaError, MediaErrorStartingPlayback, false);
+ //this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError.ToString(), "Media failed"),false);
}
/// <summary>
@@ -363,7 +425,8 @@
{
TimeSpan tsPos = new TimeSpan(0, 0, 0, 0, milliseconds);
this.player.Position = tsPos;
- this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaPosition, milliseconds / 1000.0f),false);
+ InvokeCallback(MediaPosition, milliseconds / 1000.0f, false);
+ //this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaPosition, milliseconds / 1000.0f),false);
}
}
@@ -391,7 +454,8 @@
}
else
{
- this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorPauseState),false);
+ InvokeCallback(MediaError, MediaErrorPauseState, false);
+ //this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorPauseState),false);
}
}
@@ -465,7 +529,8 @@
{
if (this.state != state)
{
- this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaState, state),false);
+ InvokeCallback(MediaState, state, false);
+ //this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaState, state),false);
}
this.state = state;
@@ -523,7 +588,6 @@
}
}
-
#region Xna loop
/// <summary>
/// Special initialization required for the microphone: XNA game loop
diff --git a/templates/standalone/cordovalib/Commands/BaseCommand.cs b/templates/standalone/cordovalib/Commands/BaseCommand.cs
index f6e45da..237b72a 100644
--- a/templates/standalone/cordovalib/Commands/BaseCommand.cs
+++ b/templates/standalone/cordovalib/Commands/BaseCommand.cs
@@ -71,7 +71,7 @@
}
-
+ [Obsolete]
public void InvokeCustomScript(ScriptCallback script, bool removeHandler)
{
if (this.OnCustomScript != null)
@@ -111,6 +111,14 @@
{
}
+ /// <summary>
+ /// Occurs when the application is being loaded, and the config.xml has an autoload entry
+ /// </summary>
+ public virtual void OnInit()
+ {
+
+ }
+
/// <summary>
/// Occurs when the application is being deactivated.
diff --git a/templates/standalone/cordovalib/CordovaCommandCall.cs b/templates/standalone/cordovalib/CordovaCommandCall.cs
index 084fd2c..a864fe6 100644
--- a/templates/standalone/cordovalib/CordovaCommandCall.cs
+++ b/templates/standalone/cordovalib/CordovaCommandCall.cs
@@ -64,7 +64,7 @@
// sanity check for illegal names
// was failing with ::
- // CordovaCommandResult :: 1, Device1, {"status":1,"message":"{\"name\":\"XD.....
+ // 1, Device1, {"status":1,"message":"{\"name\":\"XD.....
if (commandCallParameters.Service.IndexOfAny(new char[] { '@', ':', ',', '!', ' ' }) > -1)
{
return null;
diff --git a/templates/standalone/cordovalib/CordovaView.xaml.cs b/templates/standalone/cordovalib/CordovaView.xaml.cs
index a6c4bce..f6584a8 100644
--- a/templates/standalone/cordovalib/CordovaView.xaml.cs
+++ b/templates/standalone/cordovalib/CordovaView.xaml.cs
@@ -161,7 +161,7 @@
void AppClosing(object sender, ClosingEventArgs e)
{
- Debug.WriteLine("AppClosing");
+ //Debug.WriteLine("AppClosing");
}
void AppDeactivated(object sender, DeactivatedEventArgs e)
@@ -170,7 +170,7 @@
try
{
- CordovaBrowser.InvokeScript("CordovaCommandResult", new string[] { "pause" });
+ CordovaBrowser.InvokeScript("eval", new string[] { "cordova.fireDocumentEvent('pause');" });
}
catch (Exception)
{
@@ -180,7 +180,7 @@
void AppLaunching(object sender, LaunchingEventArgs e)
{
- Debug.WriteLine("INFO: AppLaunching");
+ //Debug.WriteLine("INFO: AppLaunching");
}
void AppActivated(object sender, Microsoft.Phone.Shell.ActivatedEventArgs e)
@@ -188,7 +188,7 @@
Debug.WriteLine("INFO: AppActivated");
try
{
- CordovaBrowser.InvokeScript("CordovaCommandResult", new string[] { "resume" });
+ CordovaBrowser.InvokeScript("eval", new string[] { "cordova.fireDocumentEvent('resume');" });
}
catch (Exception)
{
@@ -332,7 +332,7 @@
{
try
{
- CordovaBrowser.InvokeScript("CordovaCommandResult", new string[] { "backbutton" });
+ CordovaBrowser.InvokeScript("eval", new string[] { "cordova.fireDocumentEvent('backbutton');" });
e.Cancel = true;
}
catch (Exception ex)
@@ -367,9 +367,9 @@
try
{
- CordovaBrowser.InvokeScript("execScript", new string[] { nativeReady });
+ CordovaBrowser.InvokeScript("eval", new string[] { nativeReady });
}
- catch (Exception /*ex*/)
+ catch (Exception ex)
{
Debug.WriteLine("Error calling js to fire nativeReady event. Did you include cordova-x.x.x.js in your html script tag?");
}
diff --git a/templates/standalone/cordovalib/NativeExecution.cs b/templates/standalone/cordovalib/NativeExecution.cs
index 9459ffc..25efd01 100644
--- a/templates/standalone/cordovalib/NativeExecution.cs
+++ b/templates/standalone/cordovalib/NativeExecution.cs
@@ -61,15 +61,23 @@
CommandFactory.ResetAllCommands();
}
+ public void AutoLoadCommand(string commandService)
+ {
+ BaseCommand bc = CommandFactory.CreateByServiceName(commandService);
+ if (bc != null)
+ {
+ bc.OnInit();
+ }
+
+ }
+
/// <summary>
/// Executes command and returns result back.
/// </summary>
/// <param name="commandCallParams">Command to execute</param>
-
public void ProcessCommand(CordovaCommandCall commandCallParams)
{
-
if (commandCallParams == null)
{
throw new ArgumentNullException("commandCallParams");
@@ -90,7 +98,6 @@
this.OnCommandResult(commandCallParams.CallbackId, res);
};
- bc.OnCommandResult -= OnCommandResultHandler;
bc.OnCommandResult += OnCommandResultHandler;
EventHandler<ScriptCallback> OnCustomScriptHandler = delegate(object o, ScriptCallback script)
@@ -98,14 +105,12 @@
this.InvokeScriptCallback(script);
};
- bc.OnCustomScript -= OnCustomScriptHandler;
+
bc.OnCustomScript += OnCustomScriptHandler;
- // TODO: alternative way is using thread pool (ThreadPool.QueueUserWorkItem) instead of
- // new thread for every command call; but num threads are not sufficient - 2 threads per CPU core
-
- Thread thread = new Thread(func =>
+ ThreadStart methodInvocation = () =>
{
+
try
{
bc.InvokeMethodNamed(commandCallParams.Action, commandCallParams.Args);
@@ -122,9 +127,20 @@
return;
}
- });
+ };
- thread.Start();
+ if ((bc is File) || (bc is Accelerometer))
+ {
+ // Due to some issues with the IsolatedStorage in current version of WP8 SDK we have to run all File Api commands synchronously.
+ // TODO: test this in WP8 RTM
+ methodInvocation.Invoke();
+ }
+ else
+ {
+ new Thread(methodInvocation).Start();
+ }
+
+
}
catch (Exception ex)
{
@@ -160,21 +176,27 @@
#endregion
- string status = ((int)result.Result).ToString();
string jsonResult = result.ToJSONString();
- ScriptCallback scriptCallback = null;
+ string callback;
+ string args = string.Format("('{0}',{1});", callbackId, jsonResult);
- if (String.IsNullOrEmpty(result.Cast))
+ if (result.Result == PluginResult.Status.NO_RESULT ||
+ result.Result == PluginResult.Status.OK)
{
- scriptCallback = new ScriptCallback("CordovaCommandResult", new string[] { status, callbackId, jsonResult });
+ callback = @"(function(callbackId,args) {
+ try { args.message = JSON.parse(args.message); } catch (ex) { }
+ cordova.callbackSuccess(callbackId,args);
+ })" + args;
}
else
{
- scriptCallback = new ScriptCallback("CordovaCommandResult", new string[] { status, callbackId, jsonResult, result.Cast });
+ callback = @"(function(callbackId,args) {
+ try { args.message = JSON.parse(args.message); } catch (ex) { }
+ cordova.callbackError(callbackId,args);
+ })" + args;
}
-
- this.InvokeScriptCallback(scriptCallback);
+ this.InvokeScriptCallback(new ScriptCallback("eval", new string[] { callback }));
}
@@ -197,7 +219,6 @@
//Debug.WriteLine("INFO:: About to invoke ::" + script.ScriptName + " with args ::" + script.Args[0]);
this.webBrowser.Dispatcher.BeginInvoke((ThreadStart)delegate()
{
-
try
{
//Debug.WriteLine("INFO:: InvokingScript::" + script.ScriptName + " with args ::" + script.Args[0]);
diff --git a/templates/standalone/cordovalib/PluginResult.cs b/templates/standalone/cordovalib/PluginResult.cs
index b887bb8..e6d0c56 100644
--- a/templates/standalone/cordovalib/PluginResult.cs
+++ b/templates/standalone/cordovalib/PluginResult.cs
@@ -68,8 +68,6 @@
public Status Result { get; private set; }
public string Message { get; set; }
- public String Cast { get; private set; }
-
public bool KeepCallback { get; set; }
/// <summary>
@@ -103,21 +101,6 @@
this.Message = JSON.JsonHelper.Serialize(message);
}
- /// <summary>
- /// Creates new instance of the PluginResult class.
- /// </summary>
- /// <param name="status">Execution result</param>
- /// <param name="message">The message</param>
- /// <param name="cast">The cast parameter</param>
- ///
- [Obsolete("Don't use Cast!!", false)]
- public PluginResult(Status status, object message, string cast)
- {
- this.Result = status;
- this.Message = JSON.JsonHelper.Serialize(message);
- this.Cast = cast;
- }
-
public string ToJSONString()
{
string res = String.Format("\"status\":{0},\"message\":{1},\"keepCallback\":{2}",
@@ -132,21 +115,10 @@
public string ToCallbackString(string callbackId, string successCallback, string errorCallback)
{
- //return String.Format("{0}('{1}',{2});", successCallback, callbackId, this.ToJSONString());
-
if (this.IsSuccess)
{
StringBuilder buf = new StringBuilder("");
- if (this.Cast != null)
- {
- Debug.WriteLine(callbackId + "this.Cast = " + this.Cast);
- buf.Append("var temp = " + this.Cast + "(" + this.ToJSONString() + ");\n");
- buf.Append(String.Format("{0}('{1}',temp);", successCallback, callbackId));
- }
- else
- {
- buf.Append(String.Format("{0}('{1}',{2});", successCallback, callbackId, this.ToJSONString()));
- }
+ buf.Append(String.Format("{0}('{1}',{2});", successCallback, callbackId, this.ToJSONString()));
return buf.ToString();
}
else
diff --git a/tooling/scripts/buildjs.js b/tooling/scripts/buildjs.js
index dd53a2f..78a68f1 100644
--- a/tooling/scripts/buildjs.js
+++ b/tooling/scripts/buildjs.js
@@ -37,7 +37,8 @@
//Git Repositories
CORDOVA_JS = 'https://git-wip-us.apache.org/repos/asf/cordova-js.git',
// get version
- VERSION = read(ROOT+'\\VERSION').replace(/\r\n/,'').replace(/\n/,'');
+ VERSION = read(ROOT+'\\VERSION').replace(/\r\n/,'').replace(/\n/,''),
+ BUILD_DESTINATION;
// help function
@@ -52,6 +53,7 @@
WScript.StdOut.WriteLine("examples:");
WScript.StdOut.WriteLine(" buildjs 2.5.0rc1 //Puts cordova-2.5.0rc1 as the cordova.js in the current working directory");
WScript.StdOut.WriteLine(" buildjs 2.4.0 C:\\Users\\anonymous\\Desktop\\cordova-wp7 //Puts cordova-2.4.0.js in the given directory");
+ WScript.StdOut.WriteLine(" buildjs //Builds the version of cordova.js from the root folder and adds it to the working directory repo");
WScript.StdOut.WriteLine("");
}
@@ -77,18 +79,34 @@
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) {
+ //WScript.StdOut.WriteLine("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();
- // XXX: Change to verbose mode
- // WScript.StdOut.WriteLine(line);
+ WScript.StdOut.WriteLine(line);
}
- WScript.sleep(100);
+ }
+ //Check to make sure our scripts did not encounter an error
+ if(!oShell.StdErr.AtEndOfStream)
+ {
+ var line = oShell.StdErr.ReadAll();
+ WScript.StdErr.WriteLine(line);
+ WScript.Quit(1);
}
}
function build_js(path)
{
- WScript.StdOut.WriteLine("Creating cordova.js...");
if(fso.FolderExists(path + '\\temp'))
{
fso.DeleteFolder(path + '\\temp', true);
@@ -97,12 +115,23 @@
wscript_shell.CurrentDirectory = path + '\\temp';
WScript.StdOut.WriteLine('\tCloning js tagged with ' + VERSION + '...');
- exec('%comspec% /c git clone ' + CORDOVA_JS + ' && cd cordova-js && git fetch --tags && git checkout ' + VERSION );
-
- // build and copy over cordova.js
- WScript.StdOut.WriteLine("\tBuilding Cordova.js...");
+ exec('%comspec% /c git clone ' + CORDOVA_JS + ' && cd cordova-js && git fetch && git checkout ' + VERSION );
+ if(!fso.FolderExists(path + '\\temp\\cordova-js'))
+ {
+ WScript.StdErr.WriteLine("ERROR: Failed to clone cordova-js. Aborting...");
+ WScript.Quit(1);
+ }
wscript_shell.CurrentDirectory = path + '\\temp\\cordova-js';
- exec('%comspec% /c jake build');
+ WScript.StdOut.WriteLine("Building Cordova.js...");
+
+ exec_verbose('%comspec% /c jake build');
+ if(!fso.FolderExists(path + '\\temp\\cordova-js\\pkg'))
+ {
+ WScript.StdErr.WriteLine("ERROR: Failed to build cordova-js. Aborting...");
+ WScript.Quit(1);
+ }
+
+ //copy the javascript wherever it needs to go.
wscript_shell.CurrentDirectory = path + '\\temp\\cordova-js\\pkg';
exec('%comspec% /c copy cordova.windowsphone.js ' + path + STANDALONE_PATH + '\\www\\cordova-' + VERSION + '.js');
exec('%comspec% /c copy cordova.windowsphone.js ' + path + FULL_PATH + '\\www\\cordova-' + VERSION + '.js');
@@ -110,7 +139,7 @@
//TODO: Delete old cordova.js
- WScript.StdOut.WriteLine("DONE.");
+ WScript.StdOut.WriteLine("SUCESS");
}
function set_path(some_arg)
@@ -156,6 +185,10 @@
if(args(0).match(/(\d+)[.](\d+)[.](\d+)(rc\d)?/))
{
VERSION = args(0);
+ if(args.Count() == 1)
+ {
+ BUILD_DESTINATION = ROOT;
+ }
}
else if(set_path(arg(0))) {} //do nothing
else
@@ -172,4 +205,5 @@
}
//If we haven't quit by here, build the damn javascript!
+WScript.StdOut.WriteLine("Creating js for " + BUILD_DESTINATION);
build_js(BUILD_DESTINATION);
\ No newline at end of file
diff --git a/tooling/scripts/deploy.js b/tooling/scripts/deploy.js
index 6318ada..dd5492e 100644
--- a/tooling/scripts/deploy.js
+++ b/tooling/scripts/deploy.js
@@ -48,16 +48,32 @@
// executes a commmand in the shell
-function exec(command, output) {
+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) {
+ //WScript.StdOut.WriteLine("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();
- // XXX: Change to verbose mode
- if(output)
- WScript.StdOut.WriteLine(line);
+ WScript.StdOut.WriteLine(line);
}
- WScript.sleep(100);
+ }
+ //Check to make sure our scripts did not encounter an error
+ if(!oShell.StdErr.AtEndOfStream)
+ {
+ var line = oShell.StdErr.ReadAll();
+ WScript.StdErr.WriteLine(line);
+ WScript.Quit(1);
}
}
@@ -78,7 +94,7 @@
}
wscript_shell.CurrentDirectory = path;
- exec('msbuild CordovaAppProj.csproj');
+ exec_verbose('msbuild CordovaAppProj.csproj');
WScript.StdOut.WriteLine("BUILD SUCCESS.");
}
@@ -116,7 +132,7 @@
{
build(path);
WScript.StdOut.WriteLine('Deploying to device ...');
- exec('%comspec% /c ' + ROOT + CORDOVA_DEPLOY_EXE + ' ' + path + ' -d:0', true);
+ exec_verbose('%comspec% /c ' + ROOT + CORDOVA_DEPLOY_EXE + ' ' + path + ' -d:0');
}
else
{
@@ -133,7 +149,7 @@
{
build(path);
WScript.StdOut.WriteLine('Deploying to emulator ...');
- exec('%comspec% /c ' + ROOT + CORDOVA_DEPLOY_EXE + ' ' + path + ' -d:1', true);
+ exec_verbose('%comspec% /c ' + ROOT + CORDOVA_DEPLOY_EXE + ' ' + path + ' -d:1');
}
else
{
diff --git a/tooling/scripts/dist.js b/tooling/scripts/dist.js
index 6560bed..8278c77 100644
--- a/tooling/scripts/dist.js
+++ b/tooling/scripts/dist.js
@@ -52,6 +52,8 @@
//Destination to build to
var BUILD_DESTINATION;
+//current script that is running
+var current_script = "dist";
/*************************************************/
@@ -93,14 +95,30 @@
function exec(command) {
//WScript.StdOut.WriteLine("Command: " + command);
var oShell=wscript_shell.Exec(command);
- while (oShell.Status != 1) {
- while(!oShell.StdOut.AtEndOfStream) {
+ 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();
- // XXX: Change to verbose mode
WScript.StdOut.WriteLine(line);
}
- WScript.sleep(100);
}
+ //Check to make sure our scripts did not encounter an error
+ if(!oShell.StdErr.AtEndOfStream)
+ {
+ var line = oShell.StdErr.ReadAll();
+ WScript.StdErr.WriteLine(line);
+ WScript.StdErr.WriteLine("ERROR: Could not complete distribution, failed while running: " + current_script);
+ WScript.Quit(1);
+ }
+}
+
+function space()
+{
+ WScript.StdOut.WriteLine("");
+ WScript.StdOut.WriteLine("*****************************************************");
+ WScript.StdOut.WriteLine("");
}
@@ -122,7 +140,6 @@
Usage();
WScript.Quit(1);
}
-
}
else
{
@@ -136,9 +153,9 @@
/*************************************************/
/** - Copy source code to new directory **/
/*************************************************/
-
+current_script = "new.js";
exec('cscript ' + ROOT + SCRIPTS + '\\new.js ' + BUILD_DESTINATION + ' //nologo');
-
+space();
/*************************************************/
/****************** Step 2 *********************/
@@ -147,9 +164,9 @@
/** - Delete any generated files and cordova.js **/
/** - Rebuild dll **/
/*************************************************/
-
+current_script = "reversion.js";
exec('cscript ' + BUILD_DESTINATION + SCRIPTS + '\\reversion.js ' + VERSION + ' //nologo');
-
+space();
/*************************************************/
/****************** Step 3 *********************/
@@ -158,9 +175,9 @@
/** - build cordova.js **/
/** - windows.cordova.js -> templates + example **/
/*************************************************/
-
+current_script = "buildjs.js";
exec('cscript ' + BUILD_DESTINATION + SCRIPTS + '\\buildjs.js //nologo');
-
+space();
/*************************************************/
/****************** Step 5 *********************/
@@ -169,5 +186,7 @@
/** - Zip templates **/
/** - inject into Visual Studio **/
/*************************************************/
-
-exec('cscript ' + BUILD_DESTINATION + SCRIPTS + '\\package.js //nologo');
\ No newline at end of file
+current_script = "package.js";
+exec('cscript ' + BUILD_DESTINATION + SCRIPTS + '\\package.js //nologo');
+space();
+WScript.StdOut.WriteLine("Distribution Complete.");
\ No newline at end of file
diff --git a/tooling/scripts/new.js b/tooling/scripts/new.js
index be10a55..1e6597b 100644
--- a/tooling/scripts/new.js
+++ b/tooling/scripts/new.js
@@ -75,11 +75,6 @@
function exec(command) {
var oShell=wscript_shell.Exec(command);
while (oShell.Status == 0) {
- if(!oShell.StdOut.AtEndOfStream) {
- var line = oShell.StdOut.ReadLine();
- // XXX: Change to verbose mode
- // WScript.StdOut.WriteLine(line);
- }
WScript.sleep(100);
}
}
@@ -91,17 +86,17 @@
WScript.StdOut.WriteLine("Copying files to build directory...");
/** copy by file instead? (just what we need)**/
- dest.CopyHere(ROOT + "\\bin");
- dest.CopyHere(ROOT + EXAMPLE_PATH); //Should mostly be copied from standalone
- dest.CopyHere(ROOT + FRAMEWORK_PATH);
- dest.CopyHere(ROOT + TEMPLATES_PATH);
- dest.CopyHere(ROOT + "\\tests");
- dest.CopyHere(ROOT + "\\tooling");
- dest.CopyHere(ROOT + "\\.gitignore");
- dest.CopyHere(ROOT + "\\LICENSE");
- dest.CopyHere(ROOT + "\\NOTICE");
- dest.CopyHere(ROOT + "\\README.md");
- dest.CopyHere(ROOT + "\\VERSION");
+ dest.CopyHere(ROOT + "\\bin", 4|20);
+ dest.CopyHere(ROOT + EXAMPLE_PATH, 4|20); //Should mostly be copied from standalone
+ dest.CopyHere(ROOT + FRAMEWORK_PATH, 4|20);
+ dest.CopyHere(ROOT + TEMPLATES_PATH, 4|20);
+ dest.CopyHere(ROOT + "\\tests", 4|20);
+ dest.CopyHere(ROOT + "\\tooling", 4|20);
+ dest.CopyHere(ROOT + "\\.gitignore", 4|20);
+ dest.CopyHere(ROOT + "\\LICENSE", 4|20);
+ dest.CopyHere(ROOT + "\\NOTICE", 4|20);
+ dest.CopyHere(ROOT + "\\README.md", 4|20);
+ dest.CopyHere(ROOT + "\\VERSION", 4|20);
}
WScript.StdOut.WriteLine("");
diff --git a/tooling/scripts/package.js b/tooling/scripts/package.js
index fe418d0..812c78d 100644
--- a/tooling/scripts/package.js
+++ b/tooling/scripts/package.js
@@ -77,11 +77,6 @@
function exec(command) {
var oShell=wscript_shell.Exec(command);
while (oShell.Status == 0) {
- if(!oShell.StdOut.AtEndOfStream) {
- var line = oShell.StdOut.ReadLine();
- // XXX: Change to verbose mode
- // WScript.StdOut.WriteLine(line);
- }
WScript.sleep(100);
}
}
@@ -132,8 +127,8 @@
if(fso.FolderExists(template_dir ))
{
dest = shell.NameSpace(template_dir);
- dest.CopyHere(standalone_zip, 20);
- dest.CopyHere(full_zip, 20);
+ dest.CopyHere(standalone_zip, 4|20);
+ dest.CopyHere(full_zip, 4|20);
}
else
{
@@ -142,19 +137,28 @@
}
}
-// builds the cordova dll and copys it to the full template
+// builds the new cordova dll and copys it to the full template (only done because of the version referance in Device.cs)
function build_dll()
{
WScript.StdOut.WriteLine("Packaging .dll ...");
// move to framework directory
wscript_shell.CurrentDirectory = BUILD_DESTINATION + FRAMEWORK_PATH;
// build .dll in Release
- exec('msbuild /p:Configuration=Release;VersionNumber=' + VERSION + ';BaseVersionNumber=' + BASE_VERSION);
+ exec_verbose('msbuild /p:Configuration=Release;VersionNumber=' + VERSION + ';BaseVersionNumber=' + BASE_VERSION);
+ //Check if file dll was created
+ if(!fso.FileExists(BUILD_DESTINATION + FRAMEWORK_PATH + '\\Bin\\Release\\WPCordovaClassLib.dll'))
+ {
+ WScript.StdErr.WriteLine('ERROR: MSBuild failed to create .dll when reversioning cordova-wp7.');
+ WScript.Quit(1);
+ }
+
if(!fso.FolderExists(BUILD_DESTINATION + FULL_PATH + '\\CordovaLib'))
{
fso.CreateFolder(BUILD_DESTINATION + FULL_PATH + '\\CordovaLib');
}
exec('%comspec% /c copy Bin\\Release\\WPCordovaClassLib.dll ' + BUILD_DESTINATION + FULL_PATH + '\\CordovaLib');
+
+ WScript.StdOut.WriteLine("SUCESS");
}
// delete any unnessisary files when finished
@@ -216,4 +220,6 @@
// build/package the templates
package_templates(BUILD_DESTINATION);
-cleanUp();
\ No newline at end of file
+cleanUp();
+
+WScript.StdOut.WriteLine("SUCESS");
\ No newline at end of file
diff --git a/tooling/scripts/reversion.js b/tooling/scripts/reversion.js
index 696f9e2..cbed71b 100644
--- a/tooling/scripts/reversion.js
+++ b/tooling/scripts/reversion.js
@@ -79,7 +79,7 @@
}
else
{
- WScript.StdOut.WriteLine('Cannot read non-existant file : ' + filename);
+ WScript.StdErr.WriteLine('Cannot read non-existant file : ' + filename);
WScript.Quit(1);
}
return null;
@@ -104,12 +104,29 @@
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) {
+ //WScript.StdOut.WriteLine("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();
- // XXX: Change to verbose mode
- // WScript.StdOut.WriteLine(line);
+ WScript.StdOut.WriteLine(line);
}
- WScript.sleep(100);
+ }
+ //Check to make sure our scripts did not encounter an error
+ if(!oShell.StdErr.AtEndOfStream)
+ {
+ var line = oShell.StdErr.ReadAll();
+ WScript.StdErr.WriteLine(line);
+ WScript.Quit(1);
}
}
@@ -117,13 +134,20 @@
WScript.StdOut.WriteLine("Updating version numbers....");
var version_regex = /(\d+)[.](\d+)[.](\d+)(rc\d)?/
replaceInFile(BUILD_DESTINATION + '\\VERSION', version_regex, VERSION);
- // replace assembaly versions in framework
- var framework_regex = /\(\"(\d+)[.](\d+)[.](\d+)(rc\d)?\"\)\]/g; //Will match ("x.x.x[rcx]")]
- replaceInFile(BUILD_DESTINATION + FRAMEWORK_PATH + "\\Properties\\AssemblyInfo.cs", framework_regex, "(\"" + VERSION + "\")]");
- framework_regex = /\(\"(\d+)[.](\d+)[.](\d+)[.](\d+)"\)\]/;
- replaceInFile(BUILD_DESTINATION + FRAMEWORK_PATH + "\\Properties\\AssemblyInfo.cs", framework_regex, "(\"" + BASE_VERSION + "\")]");
+ // update version number in the framwork
+ // AssemblyDescription
+ var framework_regex = /Description\(\"(\d+)[.](\d+)[.](\d+)(rc\d)?\"\)\]/; //Will match ("x.x.x[rcx]")]
+ replaceInFile(BUILD_DESTINATION + FRAMEWORK_PATH + "\\Properties\\AssemblyInfo.cs", framework_regex, "Description(\"" + VERSION + "\")]");
+ // AssemblyFileVersion
+ framework_regex = /Version\(\"(\d+)[.](\d+)[.](\d+)\"\)\]/g;
+ replaceInFile(BUILD_DESTINATION + FRAMEWORK_PATH + "\\Properties\\AssemblyInfo.cs", framework_regex, "Version(\"" + VERSION + "\")]");
+ // AssemblyVersion
+ framework_regex = /Version\(\"(\d+)[.](\d+)[.](\d+)[.](\d+)\"\)\]/g;
+ replaceInFile(BUILD_DESTINATION + FRAMEWORK_PATH + "\\Properties\\AssemblyInfo.cs", framework_regex, "Version(\"" + BASE_VERSION + "\")]");
// update standalone project
+ var dest = shell.NameSpace(BUILD_DESTINATION + STANDALONE_PATH);
+ dest.CopyHere(BUILD_DESTINATION + "\\VERSION", 4|20);
var cordova_regex = /cordova-(\d+)[.](\d+)[.](\d+)(rc\d)?/g; //Matches *first* cordova-x.x.x[rcx] (just ad g at end to make global)
replaceInFile(BUILD_DESTINATION + STANDALONE_PATH + '\\CordovaAppProj.csproj', cordova_regex, "cordova-" + VERSION);
replaceInFile(BUILD_DESTINATION + STANDALONE_PATH + '\\CordovaSourceDictionary.xml', cordova_regex, "cordova-" + VERSION);
@@ -133,7 +157,7 @@
// update full project
dest = shell.NameSpace(BUILD_DESTINATION + FULL_PATH);
- dest.CopyHere(BUILD_DESTINATION + "\\VERSION", 20);
+ dest.CopyHere(BUILD_DESTINATION + "\\VERSION", 4|20);
replaceInFile(BUILD_DESTINATION + FULL_PATH + '\\CordovaAppProj.csproj', cordova_regex, "cordova-" + VERSION);
replaceInFile(BUILD_DESTINATION + FULL_PATH + '\\CordovaSourceDictionary.xml', cordova_regex, "cordova-" + VERSION);
replaceInFile(BUILD_DESTINATION + FULL_PATH + '\\www\\index.html', cordova_regex, "cordova-" + VERSION);
@@ -194,6 +218,16 @@
{
fso.DeleteFolder(BUILD_DESTINATION + 'tooling\\CordovaDeploy\\CordovaDeploy\\obj');
}
+ //remove old template .zip files
+ WScript.Echo(BUILD_DESTINATION);
+ var root_folder = shell.NameSpace(BUILD_DESTINATION + '\\').Items();
+ for(var i = 0; i < root_folder.Count; i++)
+ {
+ if(root_folder.Item(i).Name.match(/CordovaWP7[_](\d+)[_](\d+)[_](\d+)(rc\d)?[_]/))
+ {
+ fso.DeleteFile(BUILD_DESTINATION + '\\' + root_folder.Item(i).Name);
+ }
+ }
// remove old cordova.js
var example_www = shell.NameSpace(BUILD_DESTINATION + EXAMPLE_PATH + '\\www').Items();
for(var i = 0; i < example_www.Count; i++)
@@ -228,12 +262,21 @@
// move to framework directory
wscript_shell.CurrentDirectory = BUILD_DESTINATION + FRAMEWORK_PATH;
// build .dll in Release
- exec('msbuild /p:Configuration=Release;VersionNumber=' + VERSION + ';BaseVersionNumber=' + BASE_VERSION);
+ exec_verbose('msbuild /p:Configuration=Release;VersionNumber=' + VERSION + ';BaseVersionNumber=' + BASE_VERSION);
+ //Check if file dll was created
+ if(!fso.FileExists(BUILD_DESTINATION + FRAMEWORK_PATH + '\\Bin\\Release\\WPCordovaClassLib.dll'))
+ {
+ WScript.StdErr.WriteLine('ERROR: MSBuild failed to create .dll when reversioning cordova-wp7.');
+ WScript.Quit(1);
+ }
+
if(!fso.FolderExists(BUILD_DESTINATION + FULL_PATH + '\\CordovaLib'))
{
fso.CreateFolder(BUILD_DESTINATION + FULL_PATH + '\\CordovaLib');
}
exec('%comspec% /c copy Bin\\Release\\WPCordovaClassLib.dll ' + BUILD_DESTINATION + FULL_PATH + '\\CordovaLib');
+
+ WScript.StdOut.WriteLine("SUCESS");
}
@@ -247,9 +290,9 @@
}
else
{
- WScript.StdOut.WriteLine("The given path is not a cordova-wp7 repo, if");
- WScript.StdOut.WriteLine(" your trying to reversion a cordova-wp7 repo");
- WScript.StdOut.WriteLine(" other then this one, please provide its path.");
+ WScript.StdErr.WriteLine("The given path is not a cordova-wp7 repo, if");
+ WScript.StdErr.WriteLine(" your trying to reversion a cordova-wp7 repo");
+ WScript.StdErr.WriteLine(" other then this one, please provide its path.");
Usage();
WScript.Quit(1);
}
@@ -283,8 +326,8 @@
}
else
{
- WScript.StdOut.WriteLine("The version number is invalid, please provide");
- WScript.StdOut.WriteLine(" a version number in the format Major.Minor.Fix[rc#]")
+ WScript.StdErr.WriteLine("ERROR: The version number provided is invalid, please provide");
+ WScript.StdErr.WriteLine(" a version number in the format Major.Minor.Fix[rc#]")
Usage();
WScript.Quit(1);
}
diff --git a/tooling/scripts/win-zip.js b/tooling/scripts/win-zip.js
index 22190ec..8455a54 100644
--- a/tooling/scripts/win-zip.js
+++ b/tooling/scripts/win-zip.js
@@ -25,7 +25,7 @@
var sourceItems = objShell.NameSpace(sourcePath).items();
if (zipFolder != null)
{
- zipFolder.CopyHere(sourceItems);
+ zipFolder.CopyHere(sourceItems, 4|20);
WScript.Sleep(1000);
}
else {