You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2014/06/20 19:48:25 UTC
[5/7] CB-6976 Add support for Windows Universal apps (Windows 8.1 and
WP 8.1)
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/cordova/lib/ApplyPlatformConfig.ps1
----------------------------------------------------------------------
diff --git a/windows/template/cordova/lib/ApplyPlatformConfig.ps1 b/windows/template/cordova/lib/ApplyPlatformConfig.ps1
new file mode 100644
index 0000000..33d18de
--- /dev/null
+++ b/windows/template/cordova/lib/ApplyPlatformConfig.ps1
@@ -0,0 +1,216 @@
+<#
+ 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.
+#>
+
+param(
+ [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
+ [string] $platformRoot
+)
+
+Write-Host "Applying Platform Config..."
+
+Function UpdateManifest ($manifestFile)
+{
+ $configFile = "$platformRoot\config.xml"
+ [xml]$config = Get-Content $configFile
+ [xml]$manifest = Get-Content $manifestFile
+
+ # Replace app start page with config.xml setting.
+
+ $startPage = $config.widget.content.src
+ if (-not $startPage) {
+ # If not specified, set default value
+ # http://cordova.apache.org/docs/en/edge/config_ref_index.md.html#The%20config.xml%20File
+ $startPage = "index.html"
+ }
+ $manifest.Package.Applications.Application.StartPage = "www/$startpage"
+
+ # Update app name & version
+
+ # update identity name
+ $identityname = $config.widget.id
+ if ($identityname) {
+ $manifest.Package.Identity.Name = $identityname
+ $manifest.Package.Applications.Application.Id = $identityname
+ }
+
+ # update app display name
+ $displayname = $config.widget.name
+
+ $manifestDisplayName = $manifest.Package.Properties.DisplayName
+ if ($displayname -and $manifestDisplayName) {
+ $manifestDisplayName = $displayname
+ }
+
+ $visualelems = $manifest.Package.Applications.Application.VisualElements
+ if ($displayname -and $visualelems) {
+ $visualelems.DisplayName = $displayname
+ }
+
+ # update publisher display name
+ $publisher = $config.widget.author.InnerText
+ $manifestPublisher = $manifest.Package.Properties.PublisherDisplayName
+ if ($publisher -and $manifestPublisher) {
+ $manifestPublisher = $publisher.InnerText
+ }
+
+ # Adjust version number as per CB-5337 Windows8 build fails due to invalid app version
+ $version = $config.widget.version
+ if ($version -and $version -match "\." ) {
+ while ($version.Split(".").Length -lt 4) {
+ $version = $version + ".0"
+ }
+ }
+ $manifest.Package.Identity.Version = $version
+
+ # Sort capabilities elements
+ $capabilities = $manifest.Package.Capabilities
+ if ($capabilities) {
+ # Get sorted list of elements
+ $sorted = $capabilities.ChildNodes | sort
+ # Remove parent node
+ $manifest.Package.RemoveChild($capabilities) | Out-Null
+ # Create new node
+ $capabilities = $manifest.CreateElement("Capabilities", $manifest.DocumentElement.NamespaceURI)
+ # Then add sorted children
+ $sorted | foreach {
+ $Capabilities.AppendChild($_) | Out-Null
+ }
+ $manifest.Package.AppendChild($capabilities) | Out-Null
+ }
+
+ # Add domain whitelist rules
+ $acls = [string[]]$config.widget.access.origin
+ $rules = $manifest.Package.Applications.Application.ApplicationContentUriRules
+
+ # Remove existing rules from manifest
+ if ($rules) {
+ $manifest.Package.Applications.Application.RemoveChild($rules)
+ }
+
+ if ($acls -and ($acls -notcontains "*")) {
+ $rules = $manifest.CreateElement("ApplicationContentUriRules", $manifest.DocumentElement.NamespaceURI)
+ $manifest.Package.Applications.Application.AppendChild($rules)
+ $acls | foreach {
+ $elem = $manifest.CreateElement("Rule", $manifest.DocumentElement.NamespaceURI)
+ $elem.SetAttribute("Match", $_)
+ $elem.SetAttribute("Type", "include")
+ $rules.AppendChild($elem)
+ }
+ }
+
+ # Splash screen support
+ $configSplashScreen = $config.SelectNodes('//*[local-name()="preference"][@name="SplashScreen"]').value
+ if($configSplashScreen)
+ {
+ "Setting SplashScreen = $configSplashScreen"
+ $imgPath = $null;
+
+ # do search relative to platform and app folders
+ foreach ($testPath in @($configSplashScreen, "..\..\$configSplashScreen"))
+ {
+ $testPath = join-path $platformRoot $testPath
+
+ if (Test-Path -PathType Leaf $testPath)
+ {
+ $imgPath = $testPath;
+ break
+ }
+ }
+
+ if ($imgPath -eq $null)
+ {
+ "Unable to locate splash image: $configSplashScreen"
+ } else {
+ # Default splash screen is stored as 'images\splashscreen.png'
+ # http://msdn.microsoft.com/en-us/library/windows/apps/hh465346.aspx
+ Copy-Item $imgPath -Destination (join-path $platformRoot "images\splashscreen.png")
+ }
+
+ }
+
+ # Format splash screen background color to windows8 format
+ $configSplashScreenBGColor = $config.SelectNodes('//*[local-name()="preference"][@name="SplashScreenBackgroundColor"]').value
+ if($configSplashScreenBGColor)
+ {
+ "Setting SplashScreenBackgroundColor = $configSplashScreenBGColor"
+
+ $bgColor = ($configSplashScreenBGColor -replace "0x", "") -replace "#", ""
+
+ # Double all bytes if color specified as "fff"
+ if ($bgColor.Length -eq 3) {
+ $bgColor = $bgColor[0] + $bgColor[0] + $bgColor[1] + $bgColor[1] + $bgColor[2] + $bgColor[2]
+ }
+
+ # Parse hex representation to array of color bytes [b, g, r, a]
+ $colorBytes = [System.BitConverter]::GetBytes(
+ [int]::Parse($bgColor,
+ [System.Globalization.NumberStyles]::HexNumber))
+
+ Add-Type -AssemblyName PresentationCore
+
+ # Create new Color object ignoring alpha, because windows 8 doesn't support it
+ # see http://msdn.microsoft.com/en-us/library/windows/apps/br211471.aspx
+ $color = ([System.Windows.Media.Color]::FromRgb(
+ $colorBytes[2], $colorBytes[1], $colorBytes[0]
+ # FromRGB method add 100% alpha, so we remove it from resulting string
+ ).ToString()) -replace "#FF", "#"
+
+ $manifest.Package.Applications.Application.VisualElements.SplashScreen.BackgroundColor = [string]$color
+ }
+
+ # Format background color to windows format
+
+ $configBgColor = $config.SelectNodes('//*[local-name()="preference"][@name="BackgroundColor"]').value
+ if ($configBgColor) {
+ $bgColor = ($configBgColor -replace "0x", "") -replace "#", ""
+
+ # Double all bytes if color specified as "fff"
+ if ($bgColor.Length -eq 3) {
+ $bgColor = $bgColor[0] + $bgColor[0] + $bgColor[1] + $bgColor[1] + $bgColor[2] + $bgColor[2]
+ }
+
+ # Parse hex representation to array of color bytes [b, g, r, a]
+ $colorBytes = [System.BitConverter]::GetBytes(
+ [int]::Parse($bgColor, [System.Globalization.NumberStyles]::HexNumber)
+ )
+
+ Add-Type -AssemblyName PresentationCore
+
+ # Create new Color object ignoring alpha, because windows doesn't support it
+ # see http://msdn.microsoft.com/en-us/library/windows/apps/dn423310.aspx
+ $color = ([System.Windows.Media.Color]::FromRgb(
+ $colorBytes[2], $colorBytes[1], $colorBytes[0]
+ # FromRGB method add 100% alpha, so we remove it from resulting string
+ ).ToString()) -replace "#FF", "#"
+
+ $manifest.Package.Applications.Application.VisualElements.BackgroundColor = [string]$color
+ }
+
+ # Write out manifest file
+
+ $xmlWriter = New-Object System.Xml.XmlTextWriter($manifestFile, $null)
+ $xmlWriter.Formatting = "Indented"
+ $xmlWriter.Indentation = 4
+ $manifest.WriteContentTo($xmlWriter)
+ $xmlWriter.Close()
+}
+
+UpdateManifest "$platformRoot\package.store.appxmanifest"
+UpdateManifest "$platformRoot\package.store80.appxmanifest"
+UpdateManifest "$platformRoot\package.phone.appxmanifest"
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/cordova/lib/WindowsStoreAppUtils.ps1
----------------------------------------------------------------------
diff --git a/windows/template/cordova/lib/WindowsStoreAppUtils.ps1 b/windows/template/cordova/lib/WindowsStoreAppUtils.ps1
new file mode 100644
index 0000000..603b5a4
--- /dev/null
+++ b/windows/template/cordova/lib/WindowsStoreAppUtils.ps1
@@ -0,0 +1,116 @@
+<#
+ 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.
+#>
+$code = @"
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+namespace StoreAppRunner
+{
+ public enum ActivateOptions
+ {
+ None = 0,
+ DesignMode = 0x1,
+ NoErrorUI = 0x2,
+ NoSplashScreen = 0x4
+ }
+
+ [ComImport]
+ [Guid("2e941141-7f97-4756-ba1d-9decde894a3d")]
+ [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ public interface IApplicationActivationManager
+ {
+ IntPtr ActivateApplication([In] String appUserModelId, [In] String arguments, [In] ActivateOptions options, [Out] out UInt32 processId);
+ IntPtr ActivateForFile([In] String appUserModelId, [In] IntPtr itemArray, [In] String verb, [Out] out UInt32 processId);
+ IntPtr ActivateForProtocol([In] String appUserModelId, [In] IntPtr itemArray, [Out] out UInt32 processId);
+ }
+ [ComImport]
+ [Guid("45BA127D-10A8-46EA-8AB7-56EA9078943C")]
+ public class ApplicationActivationManager : IApplicationActivationManager
+ {
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ public extern IntPtr ActivateApplication([In] String appUserModelId, [In] String arguments, [In] ActivateOptions options, [Out] out UInt32 processId);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ public extern IntPtr ActivateForFile([In] String appUserModelId, [In] IntPtr itemArray, [In] String verb, [Out] out UInt32 processId);
+ [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ public extern IntPtr ActivateForProtocol([In] String appUserModelId, [In] IntPtr itemArray, [Out] out UInt32 processId);
+ }
+}
+"@
+
+function Uninstall-App {
+ param(
+ [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
+ [string] $ID <# package.appxmanifest//Identity@name #>
+ )
+
+ $package = Get-AppxPackage $ID
+
+ if($package) {
+ Remove-AppxPackage $package.PackageFullName
+ }
+}
+
+#
+# Checks whether the machine is missing a valid developer license.
+#
+function CheckIfNeedDeveloperLicense
+{
+ $Result = $true
+ try
+ {
+ $Result = (Get-WindowsDeveloperLicense | Where-Object { $_.IsValid }).Count -eq 0
+ }
+ catch {}
+
+ return $Result
+}
+
+function Install-App {
+ param(
+ [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
+ [string] $Path <# Full path to Add-AppDevPackage.ps1 #>
+ )
+
+ if (CheckIfNeedDeveloperLicense)
+ {
+ # we can't run the script with -force param if license installation step is required
+ Invoke-Expression ("& `"$Path`"")
+ }
+ else
+ {
+ Invoke-Expression ("& `"$Path`" -force")
+ }
+}
+
+function Start-Locally {
+ param(
+ [Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
+ [string] $ID <# package.appxmanifest//Identity@name #>
+ )
+
+ $package = Get-AppxPackage $ID
+ $manifest = Get-appxpackagemanifest $package
+ $applicationUserModelId = $package.PackageFamilyName + "!" + $manifest.package.applications.application.id
+
+ Write-Host "ActivateApplication: " $applicationUserModelId
+
+ add-type -TypeDefinition $code
+ $appActivator = new-object StoreAppRunner.ApplicationActivationManager
+ $appActivator.ActivateApplication($applicationUserModelId,$null,[StoreAppRunner.ActivateOptions]::None,[ref]0) | Out-Null
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/windows/template/cordova/lib/build.js b/windows/template/cordova/lib/build.js
new file mode 100644
index 0000000..ecd535b
--- /dev/null
+++ b/windows/template/cordova/lib/build.js
@@ -0,0 +1,265 @@
+/*
+ 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;
+
+// build type. Possible values: "debug", "release"
+var buildType = null,
+// list of build architectures. list of strings
+buildArchs = null;
+
+// working dir
+var ROOT = WScript.ScriptFullName.split('\\cordova\\lib\\build.js').join('');
+
+// help/usage function
+function Usage() {
+ Log("");
+ Log("Usage: build [ --debug | --release ] [--archs=\"<list of architectures...>\"]");
+ Log(" --help : Displays this dialog.");
+ Log(" --debug : builds project in debug mode. (Default)");
+ Log(" --release : builds project in release mode.");
+ Log(" -r : shortcut :: builds project in release mode.");
+ Log(" --archs : Builds project binaries for specific chip architectures. `arm` + `x86` + `x64` are supported.");
+ Log("examples:");
+ Log(" build ");
+ Log(" build --debug");
+ Log(" build --release");
+ Log(" build --release --archs=\"arm x86\"");
+ Log("");
+}
+
+// logs messaged to stdout and stderr
+function Log(msg, error) {
+ if (error) {
+ WScript.StdErr.WriteLine(msg);
+ }
+ else {
+ WScript.StdOut.WriteLine(msg);
+ }
+}
+
+// executes a commmand in the shell
+function exec_verbose(command) {
+ //Log("Command: " + command);
+ var oShell=wscript_shell.Exec(command);
+ while (oShell.Status === 0) {
+ //Wait a little bit so we're not super looping
+ WScript.sleep(100);
+ //Print any stdout output from the script
+ if (!oShell.StdOut.AtEndOfStream) {
+ var line = oShell.StdOut.ReadLine();
+ Log(line);
+ }
+ }
+ //Check to make sure our scripts did not encounter an error
+ if (!oShell.StdErr.AtEndOfStream) {
+ var line = oShell.StdErr.ReadAll();
+ Log(line, true);
+ WScript.Quit(2);
+ }
+ return oShell.ExitCode;
+}
+
+// checks to see if a .jsproj file exists in the project root
+function is_cordova_project(path) {
+ if (fso.FolderExists(path)) {
+ var proj_folder = fso.GetFolder(path);
+ var proj_files = new Enumerator(proj_folder.Files);
+ for (;!proj_files.atEnd(); proj_files.moveNext()) {
+ if (fso.GetExtensionName(proj_files.item()) == 'shproj') {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+// escapes a path so that it can be passed to shell command.
+function escapePath(path) {
+ return '"' + path + '"';
+}
+
+// returns full path to msbuild tools required to build the project and tools version
+function getMSBuildTools() {
+ // use the latest version of the msbuild tools available on this machine
+ var toolsVersions = ['12.0', '4.0'];
+ for (var idx in toolsVersions) {
+ try {
+ return {
+ version: toolsVersions[idx],
+ path: wscript_shell.RegRead('HKLM\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\' + toolsVersions[idx] + '\\MSBuildToolsPath')
+ };
+ } catch(err) {}
+ }
+ Log('MSBuild tools have not been found. Please install Microsoft Visual Studio 2013 or later', true);
+ WScript.Quit(2);
+}
+
+// builds the project and .xap in debug mode
+function build_appx(path, buildtype, buildarchs) {
+
+ if (!buildtype) {
+ Log("WARNING: [ --debug | --release ] not specified, defaulting to debug...");
+ buildtype = "debug";
+ }
+
+ if (!buildarchs) {
+ Log("WARNING: target architecture not specified, defaulting to AnyCPU...");
+ buildarchs = ["Any CPU"];
+ }
+
+ for (var i = 0; i < buildarchs.length; i++) {
+
+ var buildarch = buildarchs[i];
+
+ Log("Building Cordova Windows Project:");
+ Log("\tConfiguration : " + buildtype);
+ Log("\tPlatform : " + buildarch);
+ Log("\tDirectory : " + path);
+
+ try {
+ wscript_shell.CurrentDirectory = path;
+
+ // Get the latest build tools available on this machine
+ var msbuild = getMSBuildTools();
+ Log("\tMSBuildToolsPath: " + msbuild.path);
+
+ var solutionFilePath = path+'\\CordovaApp.sln'; // default sln file
+
+ if (msbuild.version == '4.0') {
+ Log("\r\nWarning. Windows 8.1 and Windows Phone 8.1 target platforms are not supported on this development machine and will be skipped.");
+ Log("Please install OS Windows 8.1 and Visual Studio 2013 Update2 in order to build for Windows 8.1 and Windows Phone 8.1.\r\n");
+ solutionFilePath = path+'\\CordovaApp.vs2012.sln';
+ }
+
+ var buildCommand = escapePath(msbuild.path + 'msbuild') +
+ ' ' + escapePath(solutionFilePath) +
+ ' /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo' +
+ ' /p:Configuration=' + buildtype +
+ ' /p:Platform="' + buildarch + '"';
+
+ // hack to get rid of 'Access is denied.' error when running the shell w/ access to C:\path..
+ buildCommand = 'cmd /c "' + buildCommand + '"';
+ Log(buildCommand);
+ if (exec_verbose(buildCommand) !== 0) {
+ // msbuild failed
+ WScript.Quit(2);
+ }
+ return "Success";
+ } catch (err) {
+ Log("Build failed: " + err.message, true);
+ }
+ }
+
+ // TODO: there could be multiple AppPackages
+ // check if AppPackages created
+ if (fso.FolderExists(path + '\\AppPackages')) {
+ var out_folder = fso.GetFolder(path + '\\AppPackages');
+ var subFolders = new Enumerator(out_folder.SubFolders);
+ for(;!subFolders.atEnd();subFolders.moveNext())
+ {
+ var subFolder = subFolders.item();
+ var files = new Enumerator(subFolder.Files);
+ for(;!files.atEnd();files.moveNext())
+ {
+ if(fso.GetExtensionName(files.item()) == "ps1")
+ {
+ // app was built, installation script exists
+ return "\nSUCCESS";
+ }
+ }
+
+ }
+
+ }
+ Log("Error : AppPackages were not built");
+ WScript.Quit(2);
+
+}
+
+// parses script args and set global variables for build
+// throws error if unknown argument specified.
+function parseArgs () {
+
+ // return build type, specified by input string, or null, if not build type parameter
+ function getBuildType (arg) {
+ arg = arg.toLowerCase();
+ if (arg == "--debug" || arg == "-d") {
+ return "debug";
+ }
+ else if (arg == "--release" || arg == "-r") {
+ return "release";
+ }
+ return null;
+ }
+
+ // returns build architectures list, specified by input string
+ // or null if nothing specified, or not --archs parameter
+ function getBuildArchs (arg) {
+ arg = arg.toLowerCase();
+ var archs = /--archs=(.+)/.exec(arg);
+ if (archs) {
+ // if architectures list contains commas, suppose that is comma delimited
+ if (archs[1].indexOf(',') != -1){
+ return archs[1].split(',');
+ }
+ // else space delimited
+ return archs[1].split(/\s/);
+ }
+ return null;
+ }
+
+ for (var i = 0; i < args.Length; i++) {
+ if (getBuildType(args(i))) {
+ buildType = getBuildType(args(i));
+ } else if (getBuildArchs(args(i))) {
+ buildArchs = getBuildArchs(args(i));
+ } else {
+ // Skip unknown args. Build could be called from run/emulate commands,
+ // so there could be additional args (specific for run/emulate)
+
+ // Log("Error: \"" + args(i) + "\" is not recognized as a build option", true);
+ // Usage();
+ // WScript.Quit(2);
+ }
+ }
+}
+
+Log("");
+
+if (args.Count() > 0) {
+ // support help flags
+ if (args(0) == "--help" || args(0) == "/?" ||
+ args(0) == "help" || args(0) == "-help" || args(0) == "/help") {
+ Usage();
+ WScript.Quit(2);
+ }
+ else if (!fso.FolderExists(ROOT) || !is_cordova_project(ROOT)) {
+ Log("Error: could not find project at " + ROOT, true);
+ WScript.Quit(2);
+ }
+
+ parseArgs();
+}
+
+Log(build_appx(ROOT, buildType, buildArchs));
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/cordova/lib/clean.js
----------------------------------------------------------------------
diff --git a/windows/template/cordova/lib/clean.js b/windows/template/cordova/lib/clean.js
new file mode 100644
index 0000000..9b77ccc
--- /dev/null
+++ b/windows/template/cordova/lib/clean.js
@@ -0,0 +1,91 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
+
+var fso = WScript.CreateObject('Scripting.FileSystemObject');
+var wscript_shell = WScript.CreateObject("WScript.Shell");
+var args = WScript.Arguments;
+// working dir
+var ROOT = WScript.ScriptFullName.split('\\cordova\\lib\\clean.js').join('');
+
+
+// help function
+function Usage() {
+ Log("");
+ Log("Usage: clean");
+ Log(" - deletes all generated files in project");
+ Log("");
+}
+
+// logs to stdout or stderr
+function Log(msg, error) {
+ if (error) {
+ WScript.StdErr.WriteLine(msg);
+ }
+ else {
+ WScript.StdOut.WriteLine(msg);
+ }
+}
+
+// cleans any generated files in the cordova project
+function clean_project(path) {
+ delete_if_exists(path + "\\Windows\\bld");
+ delete_if_exists(path + "\\WindowsPhone\\bld");
+ delete_if_exists(path + "\\Windows\\bin");
+ delete_if_exists(path + "\\WindowsPhone\\bin");
+}
+
+
+// deletes the path element if it exists
+function delete_if_exists(path) {
+ if (fso.FolderExists(path)) {
+ Log('Deleting folder: ' + path);
+ fso.DeleteFolder(path);
+ }
+ else if (fso.FileExists(path)) {
+ Log('Deleting file: ' + path);
+ fso.DeleteFile(path);
+ }
+}
+
+
+if (args.Count() > 0) {
+ // support help flags
+ if (args(0) == "--help" || args(0) == "/?" ||
+ args(0) == "help" || args(0) == "-help" || args(0) == "/help") {
+ Usage();
+ WScript.Quit(2);
+ }
+ else if (args.Count() > 1) {
+ Log("Error: Too many arguments.", true);
+ Usage();
+ WScript.Quit(2);
+ }
+}
+else {
+ if (fso.FolderExists(ROOT)) {
+ Log("Cleaning cordova project...");
+ clean_project(ROOT);
+ }
+ else {
+ Log("Error: Project directory not found,", true);
+ Usage();
+ WScript.Quit(2);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/cordova/lib/deploy.js
----------------------------------------------------------------------
diff --git a/windows/template/cordova/lib/deploy.js b/windows/template/cordova/lib/deploy.js
new file mode 100644
index 0000000..4850a76
--- /dev/null
+++ b/windows/template/cordova/lib/deploy.js
@@ -0,0 +1,465 @@
+/*
+ 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 WindowsStoreAppUtils.ps1; provides helper functions to install/unistall/start Windows Store app
+var WINDOWS_STORE_UTILS = fso.GetAbsolutePathName(ROOT+'\\cordova\\lib\\WindowsStoreAppUtils.ps1');
+// path to AppDeploy util from Windows Phone 8.1 SDK
+var APP_DEPLOY_UTILS = (wscript_shell.Environment("Process")("ProgramFiles(x86)") ||
+ wscript_shell.Environment("Process")("ProgramFiles")) +
+ '\\Microsoft SDKs\\Windows Phone\\v8.1\\Tools\\AppDeploy\\AppDeployCmd.exe';
+// Check if AppDeployCmd is exists
+if (!fso.FileExists(APP_DEPLOY_UTILS)) {
+ Log("WARNING: AppDeploy tool (AppDeployCmd.exe) didn't found. Assume that it's in %PATH%");
+ APP_DEPLOY_UTILS = "AppDeployCmd";
+}
+
+//device_id for targeting specific device
+var device_id;
+
+//build types
+var NONE = 0,
+ DEBUG = 1,
+ RELEASE = 2,
+ NO_BUILD = 3;
+var build_type = NONE;
+
+//deploy types
+var NONE = 0,
+ EMULATOR = 1,
+ DEVICE = 2,
+ TARGET = 3;
+var deploy_type = NONE;
+
+// project types
+var NONE = 0;
+ STORE80 = 1;
+ STORE81 = 2;
+ PHONE = 3;
+var project_type = NONE;
+
+
+var PACKAGE_NAME = '$namespace$';
+
+// help function
+function Usage() {
+ Log("");
+ Log("Usage: run [ --device | --emulator | --target=<id> ] [ --debug | --release | --nobuild ]");
+ Log("");
+ Log(" [ --x86 | --x64 | --arm ] [--phone | --store | --store81 | --store80]");
+ 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 : Uses pre-built xap, or errors if project is not built.");
+ Log(" --x86, --x64, --arm");
+ Log(" : Specifies chip architecture.");
+ Log(" --phone, --store, --store81, --store80");
+ Log(" : Specifies, what type of project to deploy");
+ Log("");
+ 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);
+ }
+}
+
+// return chip architecture specified in script arguments
+// used to select/find appropriate appx package to deploy.
+function getChipArchitecture() {
+ if (joinArgs().indexOf('--arm') > -1) {
+ return 'arm';
+ } else if (joinArgs().indexOf('--x86') > -1) {
+ return 'x86';
+ } else if (joinArgs().indexOf('--x64') > -1) {
+ return 'x64';
+ }
+ return 'anycpu';
+}
+
+// returns build type (debug/release) specified in script arguments
+// used to select/find appropriate appx package to deploy.
+function getBuildType() {
+ if (joinArgs().indexOf("--release") > -1) {
+ return "release";
+ }
+ return "debug";
+}
+
+// returns project type (phone/store/store80) specified in script arguments
+// used to select/find appropriate appx package to deploy.
+function getProjectType() {
+ var argString = joinArgs();
+ if (argString.indexOf("--phone") > -1) {
+ return "phone";
+ }
+ else if (argString.indexOf("--store80") > -1) {
+ return "store80";
+ }
+ // default is 'store' - Windows 8.1 store app
+ return "store";
+}
+
+// returns folder that contains package with chip architecture,
+// build and project types specified by script parameters
+function getPackage (path) {
+ wscript_shell.CurrentDirectory = path;
+
+ // check if AppPackages created
+ if (fso.FolderExists(path + '\\AppPackages')) {
+ var out_folder = fso.GetFolder(path + '\\AppPackages');
+
+ // Get preferred chip architecture, build and project types
+ var chipArch = getChipArchitecture();
+ var buildType = getBuildType();
+ var projectType = getProjectType();
+
+ // Iterating over AppPackages subfolders with built packages
+ var subFolders = new Enumerator(out_folder.SubFolders);
+ for(;!subFolders.atEnd();subFolders.moveNext())
+ {
+ var subFolder = subFolders.item();
+ var appx_props,
+ appxProjectType,
+ appxChipArch,
+ appxBuildType;
+
+ // This RE matches with package folder name like:
+ // CordovaApp.Phone_0.0.1.0_AnyCPU_Debug_Test
+ // Group: ( 1 ) ( 2 ) ( 3 ) ( 4 )
+ appx_props = /^.*\.(Phone|Store|Store80)_((?:\d\.)*\d)_(AnyCPU|x64|x86|ARM)(?:_(Debug))?_Test$/.exec(subFolder.Name);
+ if (appx_props){
+ appxProjectType = appx_props[1].toLowerCase();
+ appxChipArch = appx_props[3].toLowerCase();
+ appxBuildType = appx_props[4] ? appx_props[4].toLowerCase() : "release";
+ }
+
+ // compare chip architecture and build type of package found with
+ // chip architecture and build type specified in script arguments
+ if (appxChipArch == chipArch && appxBuildType == buildType && appxProjectType == projectType) {
+ // Appropriate package found
+ Log('Appropriate package found at ' + subFolder.Path);
+ return subFolder.Path;
+ }
+ }
+ }
+ Log('Error : AppPackages were not built or appropriate package was not found', true);
+ WScript.Quit(2);
+}
+
+// launches project on local machine
+function localMachine(path) {
+ Log('Deploying to local machine ...');
+ makeAppStoreUtils(path);
+ uninstallApp(path);
+ installApp(path);
+
+ var command = "powershell -ExecutionPolicy RemoteSigned \". " + WINDOWS_STORE_UTILS + "; Start-Locally '" + PACKAGE_NAME + "'\"";
+ Log(command);
+ exec_verbose(command);
+}
+
+// launches project on device
+function device(path) {
+ if (project_type != PHONE) {
+ // on windows8 platform we treat this command as running application on local machine
+ localMachine(path);
+ } else {
+ Log('Deploying to device ...');
+ var appxFolder = getPackage(path);
+ var appxPath = appxFolder + '\\' + fso.GetFolder(appxFolder).Name.split('_Test').join('') + '.appx';
+ var cmd = '"' + APP_DEPLOY_UTILS + '" /installlaunch "' + appxPath + '" /targetdevice:de';
+ Log(cmd);
+ exec_verbose(cmd);
+ }
+}
+
+// launches project on emulator
+function emulator(path) {
+ if (project_type != PHONE) {
+ // TODO: currently we can run application on local machine only
+ localMachine(path);
+ } else {
+ Log('Deploying to emulator ...');
+ var appxFolder = getPackage(path);
+ var appxPath = appxFolder + '\\' + fso.GetFolder(appxFolder).Name.split('_Test').join('') + '.appx';
+ var cmd = '"' + APP_DEPLOY_UTILS + '" /installlaunch "' + appxPath + '" /targetdevice:xd';
+ Log(cmd);
+ exec_verbose(cmd);
+ }
+}
+
+// builds and launches the project on the specified target
+function target(path) {
+ if (project_type != PHONE){
+ Log('ERROR: not supported yet', true);
+ Log('DEPLOY FAILED.', true);
+ WScript.Quit(2);
+ } else {
+ // We're deploying package on phone device/emulator
+ // Let's find target specified by script arguments
+ var cmd = APP_DEPLOY_UTILS + ' /enumeratedevices';
+ var out = wscript_shell.Exec(cmd);
+ while(out.Status === 0) {
+ WScript.Sleep(100);
+ }
+ if (!out.StdErr.AtEndOfStream) {
+ var error = out.StdErr.ReadAll();
+ Log("ERROR: Error calling AppDeploy : ", true);
+ Log(error, true);
+ WScript.Quit(2);
+ }
+ else {
+ if (!out.StdOut.AtEndOfStream) {
+ // get output from AppDeployCmd
+ var lines = out.StdOut.ReadAll().split('\r\n');
+ // regular expression, that matches with AppDeploy /enumeratedevices output
+ // e.g. ' 1 Emulator 8.1 WVGA 4 inch 512MB'
+ var deviceRe = /^\s?(\d)+\s+(.*)$/;
+ // iterate over lines
+ for (var line in lines){
+ var deviceMatch = lines[line].match(deviceRe);
+ // check that line contains device id and name
+ // and match with 'target' parameter of script
+ if (deviceMatch && deviceMatch[1] == device_id) {
+ // start deploy to target specified
+ var appxFolder = getPackage(path);
+ var appxPath = appxFolder + '\\' + fso.GetFolder(appxFolder).Name.split('_Test').join('') + '.appx';
+ Log('Deploying to target with id: ' + device_id);
+ cmd = '"' + APP_DEPLOY_UTILS + '" /installlaunch "' + appxPath + '" /targetdevice:' + deviceMatch[1];
+ Log(cmd);
+ exec_verbose(cmd);
+ 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 makeAppStoreUtils(path) {
+ if (fso.FileExists(WINDOWS_STORE_UTILS)) {
+ Log("Removing execution restrictions from AppStoreUtils...");
+ var command = "powershell \"Unblock-File \'" + WINDOWS_STORE_UTILS + "\'\"";
+ exec_verbose(command);
+ return;
+ }
+}
+
+// uninstalls previous application instance (if exists)
+function uninstallApp(path) {
+ Log("Attempt to uninstall previous application version...");
+ Log("\tDirectory : " + path);
+
+ wscript_shell.CurrentDirectory = path;
+ var command = "powershell -ExecutionPolicy RemoteSigned \". " + WINDOWS_STORE_UTILS + "; Uninstall-App " + PACKAGE_NAME;
+ Log(command);
+ exec_verbose(command);
+}
+
+// executes store application installation script (Add-AppDevPackage.ps1)
+function installApp(path) {
+
+ Log("Attempt to install application...");
+ Log("\tDirectory : " + path);
+
+ var command = "powershell -ExecutionPolicy RemoteSigned \". " + WINDOWS_STORE_UTILS + "; Install-App " + "'" + getPackage(path) + "\\Add-AppDevPackage.ps1" + "'\"";
+ Log(command);
+ exec_verbose(command);
+ return;
+}
+
+// builds project with arguments specified
+// all arguments passes directly into build script without changes
+function build(path) {
+
+ switch (build_type) {
+ // debug & release configurations are specified
+ case DEBUG :
+ case RELEASE :
+ exec_verbose('%comspec% /c "' + ROOT + '\\cordova\\build" ' + joinArgs());
+ break;
+ case NO_BUILD :
+ break;
+ case NONE :
+ Log("WARNING: [ --debug | --release | --nobuild ] not specified, defaulting to --debug.");
+ exec_verbose('%comspec% /c "' + ROOT + '\\cordova\\build" ' + joinArgs());
+ break;
+ default :
+ Log("Build option not recognized: " + build_type, true);
+ WScript.Quit(2);
+ break;
+ }
+}
+
+function run(path) {
+ switch(deploy_type) {
+ case EMULATOR :
+ build(path);
+ emulator(path);
+ break;
+ case DEVICE :
+ build(path);
+ device(path);
+ break;
+ case TARGET :
+ build(path);
+ target(path);
+ break;
+ case NONE :
+ Log("WARNING: [ --target=<ID> | --emulator | --device ] not specified, defaulting to --emulator");
+ build(path);
+ emulator(path);
+ break;
+ default :
+ Log("Deploy option not recognized: " + deploy_type, true);
+ WScript.Quit(2);
+ break;
+ }
+}
+
+// returns script arguments, joined into string
+function joinArgs () {
+ var argArray = [];
+ for (var i = 0; i < args.Length; i++) {
+ argArray[i] = args.Item(i);
+ }
+ return argArray.join(" ");
+}
+
+// parses script arguments and sets script's build_type/deploy_type variables
+function parseArgs () {
+
+ // support help flags
+ if (args(0) == "--help" || args(0) == "/?" ||
+ args(0) == "help" || args(0) == "-help" || args(0) == "/help") {
+ Usage();
+ WScript.Quit(2);
+ }
+
+ var argString = joinArgs();
+
+ // Check for build type
+ if (argString.indexOf('--release') > -1){
+ build_type = RELEASE;
+ } else if (argString.indexOf('--debug') > -1) {
+ build_type = DEBUG;
+ } else if (argString.indexOf('--nobuild') > -1) {
+ build_type = NO_BUILD;
+ }
+
+ // Check for deploy destination
+ if (argString.indexOf("--emulator") > -1 || argString.indexOf("-e") > -1) {
+ deploy_type = EMULATOR;
+ }
+ else if (argString.indexOf("--device") > -1 || argString.indexOf("-d") > -1) {
+ deploy_type = DEVICE;
+ }
+ else if (argString.indexOf("--target=") > -1) {
+ device_id = argString.split("--target=")[1].split(' ')[0];
+ deploy_type = TARGET;
+ }
+
+ // Check for project type
+ if (argString.indexOf("--phone") > -1) {
+ project_type = PHONE;
+ }
+ else if (argString.indexOf("--store80") > -1) {
+ project_type = STORE80;
+ }
+ else if (argString.indexOf("--store") > -1 || argString.indexOf("--store81") > -1) {
+ project_type = STORE81;
+ }
+}
+
+// check root folder exists
+if (!fso.FolderExists(ROOT)) {
+ Log('Error: Project directory not found,', true);
+ Usage();
+ WScript.Quit(2);
+}
+
+if (args.Count() > 0) {
+
+ // parse arguments
+ parseArgs();
+}
+
+run(ROOT);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/cordova/lib/list-devices.bat
----------------------------------------------------------------------
diff --git a/windows/template/cordova/lib/list-devices.bat b/windows/template/cordova/lib/list-devices.bat
new file mode 100644
index 0000000..3c0aac7
--- /dev/null
+++ b/windows/template/cordova/lib/list-devices.bat
@@ -0,0 +1,3 @@
+@ECHO OFF
+ECHO Error! Windows 8 Cordova CLI tools do not support multiple devices currently.
+EXIT /B 1
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/cordova/lib/list-emulator-images.bat
----------------------------------------------------------------------
diff --git a/windows/template/cordova/lib/list-emulator-images.bat b/windows/template/cordova/lib/list-emulator-images.bat
new file mode 100644
index 0000000..149e2d0
--- /dev/null
+++ b/windows/template/cordova/lib/list-emulator-images.bat
@@ -0,0 +1,3 @@
+@ECHO OFF
+ECHO Error! Windows 8 Cordova CLI tools do not support list-emulator-images currently.
+EXIT /B 1
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/cordova/lib/list-started-emulators.bat
----------------------------------------------------------------------
diff --git a/windows/template/cordova/lib/list-started-emulators.bat b/windows/template/cordova/lib/list-started-emulators.bat
new file mode 100644
index 0000000..1a6ffa4
--- /dev/null
+++ b/windows/template/cordova/lib/list-started-emulators.bat
@@ -0,0 +1,3 @@
+@ECHO OFF
+ECHO Error! Windows 8 Cordova CLI tools do not support list-started-emulators currently.
+EXIT /B 1
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/cordova/lib/log.js
----------------------------------------------------------------------
diff --git a/windows/template/cordova/lib/log.js b/windows/template/cordova/lib/log.js
new file mode 100644
index 0000000..0b4ea7d
--- /dev/null
+++ b/windows/template/cordova/lib/log.js
@@ -0,0 +1,77 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
+
+var fso = WScript.CreateObject('Scripting.FileSystemObject');
+var wscript_shell = WScript.CreateObject("WScript.Shell");
+var args = WScript.Arguments;
+// working dir
+var ROOT = WScript.ScriptFullName.split('\\cordova\\lib\\log.js').join('');
+
+
+// help function
+function Usage() {
+ Log("");
+ Log("Usage: log");
+ Log("examples:");
+ Log(" log");
+ Log(" - logs output from running application *NOT IMPLIMENTED*");
+ Log("");
+}
+
+// logs to stdout or stderr
+function Log(msg, error) {
+ if (error) {
+ WScript.StdErr.WriteLine(msg);
+ }
+ else {
+ WScript.StdOut.WriteLine(msg);
+ }
+}
+
+// log output from running projects *NOT IMPLEMENTED*
+function log_output(path) {
+ Log("ERROR: Logging is not supported on Windows Phone", true);
+ WScript.Quit(1);
+}
+
+
+if (args.Count() > 0) {
+ // support help flags
+ if (args(0) == "--help" || args(0) == "/?" ||
+ args(0) == "help" || args(0) == "-help" || args(0) == "/help") {
+ Usage();
+ WScript.Quit(2);
+ }
+ else {
+ Log("Error: \"" + args(0) + "\" is not recognized as a log option.", true);
+ Usage();
+ WScript.Quit(2);
+ }
+}
+else {
+ if (fso.FolderExists(ROOT)) {
+ log_output(ROOT);
+ }
+ else {
+ Log("Error: Project directory not found,", true);
+ Usage();
+ WScript.Quit(2);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/cordova/lib/target-list.js
----------------------------------------------------------------------
diff --git a/windows/template/cordova/lib/target-list.js b/windows/template/cordova/lib/target-list.js
new file mode 100644
index 0000000..805eea5
--- /dev/null
+++ b/windows/template/cordova/lib/target-list.js
@@ -0,0 +1,233 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
+
+var fso = WScript.CreateObject('Scripting.FileSystemObject');
+var wscript_shell = WScript.CreateObject("WScript.Shell");
+
+var args = WScript.Arguments;
+// working dir
+var ROOT = WScript.ScriptFullName.split('\\cordova\\lib\\target-list.js').join('');
+ // path to CordovaDeploy.exe
+var CORDOVA_DEPLOY_EXE = '\\cordova\\lib\\CordovaDeploy\\CordovaDeploy\\bin\\Debug\\CordovaDeploy.exe';
+ // path to CordovaDeploy
+var CORDOVA_DEPLOY = '\\cordova\\lib\\CordovaDeploy';
+
+// help/usage function
+function Usage() {
+ Log("");
+ Log("Usage: cscript target-list.js [ --emulators | --devices | --started_emulators | --all ]");
+ Log(" --emulators : List the possible target emulators availible.");
+ Log(" --devices : List the possible target devices availible. *NOT IMPLEMENTED YET*");
+ Log(" --started_emulators : List any started emulators availible. *NOT IMPLEMENTED YET*");
+ Log(" --all : List all devices returned by CordovaDeploy.exe -devices ");
+ Log("examples:");
+ Log(" cscript target-list.js --emulators");
+ Log(" cscript target-list.js --devices");
+ Log(" cscript target-list.js --started_emulators");
+ Log(" cscript target-list.js --all");
+ Log("");
+}
+
+// logs messaged to stdout and stderr
+function Log(msg, error) {
+ if (error) {
+ WScript.StdErr.WriteLine(msg);
+ }
+ else {
+ WScript.StdOut.WriteLine(msg);
+ }
+}
+
+// executes a commmand in the shell
+function exec(command) {
+ var oShell=wscript_shell.Exec(command);
+ while (oShell.Status == 0) {
+ //Wait a little bit so we're not super looping
+ WScript.sleep(100);
+ //Print output? Naa.....
+ if (!oShell.StdOut.AtEndOfStream) {
+ var line = oShell.StdOut.ReadAll();
+ //Log(line);
+ }
+ }
+ //Check to make sure our scripts did not encounter an error
+ if (!oShell.StdErr.AtEndOfStream) {
+ var line = oShell.StdErr.ReadAll();
+ Log(line, true);
+ WScript.Quit(2);
+ }
+}
+
+// returns all possible targets generated by the CordovaDeploy tool
+function get_targets(path) {
+ if (!fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
+ cordovaDeploy(path);
+ }
+ wscript_shell.CurrentDirectory = path + CORDOVA_DEPLOY + '\\CordovaDeploy\\bin\\Debug';
+ var cmd = 'CordovaDeploy -devices';
+ var out = wscript_shell.Exec(cmd);
+ while(out.Status == 0) {
+ WScript.Sleep(100);
+ }
+ //Check to make sure our script did not encounter an error
+ if (!out.StdErr.AtEndOfStream) {
+ var line = out.StdErr.ReadAll();
+ Log("Error calling CordovaDeploy : ", true);
+ Log(line, true);
+ WScript.Quit(2);
+ }
+ else {
+ if (!out.StdOut.AtEndOfStream) {
+ var line = out.StdOut.ReadAll();
+ var targets = line.split('\r\n');
+ //format (ID DESCRIPTION)
+ for (i in targets) {
+ // remove device index and separator colen
+ targets[i] = targets[i].replace(/\d*\s\:\s/, '').replace(/\:\s/, '');
+ }
+ return targets;
+ }
+ else {
+ Log('Error : CordovaDeploy Failed to find any devices', true);
+ WScript.Quit(2);
+ }
+ }
+}
+
+function list_targets(path) {
+ var targets = get_targets(path);
+ for (i in targets) {
+ Log(targets[i]);
+ }
+}
+
+// lists the Device returned by CordovaDeploy (NOTE: this does not indicate that a device is connected)
+function list_devices(path) {
+ var targets = get_targets(path);
+ var device_found = false;
+ for (i in targets) {
+ if (targets[i].match(/Device/)) {
+ Log(targets[i]);
+ device_found = true;
+ }
+ }
+ if (device_found) {
+ Log('');
+ Log('WARNING : This does not mean that a device is connected, make');
+ Log(' sure your device is connected before deploying to it.');
+ }
+}
+
+// lists the emulators availible to CordovaDeploy
+function list_emulator_images(path) {
+ var targets = get_targets(path);
+ for (i in targets) {
+ if (targets[i].match(/Emulator/)) {
+ Log(targets[i]);
+ }
+ }
+}
+
+// lists any started emulators *NOT IMPLEMENTED*
+function list_started_emulators(path) {
+ Log('ERROR : list-started-emulators is not supported on Windows Phone.', true);
+ WScript.Quit(1);
+}
+
+// builds the CordovaDeploy.exe if it does not already exist
+function cordovaDeploy(path) {
+ if (fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
+ return;
+ }
+
+ // build CordovaDeploy.exe
+ if (fso.FolderExists(path + '\\cordova') && fso.FolderExists(path + CORDOVA_DEPLOY) &&
+ fso.FileExists(path + CORDOVA_DEPLOY + '\\CordovaDeploy.sln')) {
+ // delete any previously generated files
+ if (fso.FolderExists(path + CORDOVA_DEPLOY + "\\CordovaDeploy\\obj")) {
+ fso.DeleteFolder(path + CORDOVA_DEPLOY + "\\CordovaDeploy\\obj");
+ }
+ if (fso.FolderExists(path + CORDOVA_DEPLOY + "\\CordovaDeploy\\Bin")) {
+ fso.DeleteFolder(path + CORDOVA_DEPLOY + "\\CordovaDeploy\\Bin");
+ }
+ exec('msbuild ' + path + CORDOVA_DEPLOY + '\\CordovaDeploy.sln');
+
+ if (fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
+ return;
+ }
+ else {
+ Log("ERROR: MSBUILD FAILED TO COMPILE CordovaDeploy.exe", true);
+ WScript.Quit(2);
+ }
+ }
+ else {
+ Log("ERROR: CordovaDeploy.sln not found, unable to compile CordovaDeploy tool.", true);
+ WScript.Quit(2);
+ }
+}
+
+
+if (args.Count() > 0) {
+ // support help flags
+ if (args(0) == "--help" || args(0) == "/?" ||
+ args(0) == "help" || args(0) == "-help" || args(0) == "/help") {
+ Usage();
+ WScript.Quit(2);
+ }
+ else if (args.Count() > 1) {
+ Log("Error: Too many arguments.", true);
+ Usage();
+ WScript.Quit(2);
+ }
+ else if (fso.FolderExists(ROOT)) {
+ if (!fso.FolderExists(ROOT + '\\cordova')) {
+ Log("Error: cordova tooling folder not found in project directory,", true);
+ Log("could not lsit targets.", true);
+ WScript.Quit(2);
+ }
+
+ if (args(0) == "--emulators" || args(0) == "-e") {
+ list_emulator_images(ROOT);
+ }
+ else if (args(0) == "--devices" || args(0) == "-d") {
+ list_devices(ROOT);
+ }
+ else if (args(0) == "--started_emulators" || args(0) == "-s") {
+ list_started_emulators(ROOT);
+ }
+ else if (args(0) == "--all" || args(0) == "-a") {
+ list_targets(ROOT);
+ }
+ else {
+ Log("Error: \"" + args(0) + "\" is not recognized as a target-list option", true);
+ Usage();
+ WScript.Quit(2);
+ }
+ }
+ else {
+ Log("Error: Project directory not found,", true);
+ Usage();
+ WScript.Quit(2);
+ }
+}
+else {
+ Log("WARNING: target list not specified, showing all targets...");
+ list_targets(ROOT);
+}
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/cordova/log.bat
----------------------------------------------------------------------
diff --git a/windows/template/cordova/log.bat b/windows/template/cordova/log.bat
new file mode 100644
index 0000000..d34a8ab
--- /dev/null
+++ b/windows/template/cordova/log.bat
@@ -0,0 +1,3 @@
+@ECHO OFF
+ECHO Sorry, logging is not supported for Windows Phone. 1>&2
+EXIT /B 1
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/cordova/run.bat
----------------------------------------------------------------------
diff --git a/windows/template/cordova/run.bat b/windows/template/cordova/run.bat
new file mode 100644
index 0000000..850104f
--- /dev/null
+++ b/windows/template/cordova/run.bat
@@ -0,0 +1,9 @@
+@ECHO OFF
+SET full_path=%~dp0
+IF EXIST "%full_path%lib\deploy.js" (
+ cscript "%full_path%lib\deploy.js" %* //nologo
+) ELSE (
+ ECHO.
+ ECHO ERROR: Could not find 'deploy.js' in cordova/lib, aborting...>&2
+ EXIT /B 1
+)
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/cordova/version.bat
----------------------------------------------------------------------
diff --git a/windows/template/cordova/version.bat b/windows/template/cordova/version.bat
new file mode 100644
index 0000000..714e876
--- /dev/null
+++ b/windows/template/cordova/version.bat
@@ -0,0 +1,9 @@
+@ECHO OFF
+SET full_path=%~dp0
+IF EXIST "%full_path%..\VERSION" (
+ type "%full_path%..\VERSION"
+) ELSE (
+ ECHO.
+ ECHO ERROR: Could not find file VERSION in project folder
+ EXIT /B 1
+)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/images/SplashScreen.scale-240.png
----------------------------------------------------------------------
diff --git a/windows/template/images/SplashScreen.scale-240.png b/windows/template/images/SplashScreen.scale-240.png
new file mode 100644
index 0000000..33f26b3
Binary files /dev/null and b/windows/template/images/SplashScreen.scale-240.png differ
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/images/Square150x150Logo.scale-240.png
----------------------------------------------------------------------
diff --git a/windows/template/images/Square150x150Logo.scale-240.png b/windows/template/images/Square150x150Logo.scale-240.png
new file mode 100644
index 0000000..76921ca
Binary files /dev/null and b/windows/template/images/Square150x150Logo.scale-240.png differ
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/images/Square44x44Logo.scale-240.png
----------------------------------------------------------------------
diff --git a/windows/template/images/Square44x44Logo.scale-240.png b/windows/template/images/Square44x44Logo.scale-240.png
new file mode 100644
index 0000000..3166301
Binary files /dev/null and b/windows/template/images/Square44x44Logo.scale-240.png differ
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/images/Square71x71Logo.scale-240.png
----------------------------------------------------------------------
diff --git a/windows/template/images/Square71x71Logo.scale-240.png b/windows/template/images/Square71x71Logo.scale-240.png
new file mode 100644
index 0000000..cfa54be
Binary files /dev/null and b/windows/template/images/Square71x71Logo.scale-240.png differ
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/images/StoreLogo.scale-240.png
----------------------------------------------------------------------
diff --git a/windows/template/images/StoreLogo.scale-240.png b/windows/template/images/StoreLogo.scale-240.png
new file mode 100644
index 0000000..903528e
Binary files /dev/null and b/windows/template/images/StoreLogo.scale-240.png differ
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/images/Wide310x150Logo.scale-240.png
----------------------------------------------------------------------
diff --git a/windows/template/images/Wide310x150Logo.scale-240.png b/windows/template/images/Wide310x150Logo.scale-240.png
new file mode 100644
index 0000000..6249d29
Binary files /dev/null and b/windows/template/images/Wide310x150Logo.scale-240.png differ
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/images/logo.png
----------------------------------------------------------------------
diff --git a/windows/template/images/logo.png b/windows/template/images/logo.png
new file mode 100644
index 0000000..86a48a8
Binary files /dev/null and b/windows/template/images/logo.png differ
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/images/smalllogo.png
----------------------------------------------------------------------
diff --git a/windows/template/images/smalllogo.png b/windows/template/images/smalllogo.png
new file mode 100644
index 0000000..0e648ef
Binary files /dev/null and b/windows/template/images/smalllogo.png differ
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/images/splashscreen.png
----------------------------------------------------------------------
diff --git a/windows/template/images/splashscreen.png b/windows/template/images/splashscreen.png
new file mode 100644
index 0000000..d1e6c98
Binary files /dev/null and b/windows/template/images/splashscreen.png differ
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/images/storelogo.png
----------------------------------------------------------------------
diff --git a/windows/template/images/storelogo.png b/windows/template/images/storelogo.png
new file mode 100644
index 0000000..dd00478
Binary files /dev/null and b/windows/template/images/storelogo.png differ
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/package.phone.appxmanifest
----------------------------------------------------------------------
diff --git a/windows/template/package.phone.appxmanifest b/windows/template/package.phone.appxmanifest
new file mode 100644
index 0000000..581a409
--- /dev/null
+++ b/windows/template/package.phone.appxmanifest
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns:m3="http://schemas.microsoft.com/appx/2014/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest">
+ <Identity Name="$guid1$" Version="1.0.0.0" Publisher="CN=$username$" />
+ <mp:PhoneIdentity PhoneProductId="$guid1$" PhonePublisherId="db093ed5-53b1-45f7-af72-751e8f36ab80" />
+ <Properties>
+ <DisplayName>$projectname$</DisplayName>
+ <PublisherDisplayName>$username$</PublisherDisplayName>
+ <Logo>images\StoreLogo.png</Logo>
+ </Properties>
+ <Prerequisites>
+ <OSMinVersion>6.3.1</OSMinVersion>
+ <OSMaxVersionTested>6.3.1</OSMaxVersionTested>
+ </Prerequisites>
+ <Resources>
+ <Resource Language="x-generate" />
+ </Resources>
+ <Applications>
+ <Application Id="$safeprojectname$" StartPage="www/index.html">
+ <m3:VisualElements DisplayName="$projectname$"
+ Square150x150Logo="images\Square150x150Logo.png"
+ Square44x44Logo="images\Square44x44Logo.png"
+ Description="CordovaApp"
+ ForegroundText="light"
+ BackgroundColor="transparent">
+ <m3:DefaultTile Wide310x150Logo="images\Wide310x150Logo.png" Square71x71Logo="images\Square71x71Logo.png">
+ </m3:DefaultTile>
+ <m3:SplashScreen Image="images\SplashScreen.png" />
+ </m3:VisualElements>
+ </Application>
+ </Applications>
+ <Capabilities>
+ <Capability Name="internetClientServer" />
+ </Capabilities>
+</Package>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/package.store.appxmanifest
----------------------------------------------------------------------
diff --git a/windows/template/package.store.appxmanifest b/windows/template/package.store.appxmanifest
new file mode 100644
index 0000000..dc9a22c
--- /dev/null
+++ b/windows/template/package.store.appxmanifest
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest">
+ <Identity Name="$guid1$" Version="1.0.0.0" Publisher="CN=$username$" />
+ <Properties>
+ <DisplayName>$projectname$</DisplayName>
+ <PublisherDisplayName>$username$</PublisherDisplayName>
+ <Logo>images\storelogo.png</Logo>
+ </Properties>
+ <Prerequisites>
+ <OSMinVersion>6.3.0</OSMinVersion>
+ <OSMaxVersionTested>6.3.0</OSMaxVersionTested>
+ </Prerequisites>
+ <Resources>
+ <Resource Language="x-generate" />
+ </Resources>
+ <Applications>
+ <Application Id="$safeprojectname$" StartPage="www/index.html">
+ <m2:VisualElements DisplayName="$projectname$"
+ Description="CordovaApp"
+ ForegroundText="light"
+ BackgroundColor="#464646"
+ Square150x150Logo="images\Logo.png"
+ Square30x30Logo="images\SmallLogo.png">
+ <m2:SplashScreen Image="images\splashscreen.png" />
+ </m2:VisualElements>
+ </Application>
+ </Applications>
+ <Capabilities>
+ <Capability Name="internetClient" />
+ </Capabilities>
+</Package>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/29d15d6e/windows/template/package.store80.appxmanifest
----------------------------------------------------------------------
diff --git a/windows/template/package.store80.appxmanifest b/windows/template/package.store80.appxmanifest
new file mode 100644
index 0000000..4f64cc2
--- /dev/null
+++ b/windows/template/package.store80.appxmanifest
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest">
+ <Identity Name="$guid1$" Version="1.0.0.0" Publisher="CN=$username$" />
+ <Properties>
+ <DisplayName>$projectname$</DisplayName>
+ <PublisherDisplayName>$username$</PublisherDisplayName>
+ <Logo>images\storelogo.png</Logo>
+ </Properties>
+ <Prerequisites>
+ <OSMinVersion>6.2.1</OSMinVersion>
+ <OSMaxVersionTested>6.2.1</OSMaxVersionTested>
+ </Prerequisites>
+ <Resources>
+ <Resource Language="x-generate" />
+ </Resources>
+ <Applications>
+ <Application Id="$safeprojectname$" StartPage="www/index.html">
+ <VisualElements DisplayName="$projectname$"
+ Logo="images\logo.png"
+ SmallLogo="images\smalllogo.png"
+ Description="CordovaApp"
+ ForegroundText="light"
+ BackgroundColor="#464646">
+ <DefaultTile ShowName="allLogos" />
+ <SplashScreen Image="images\splashscreen.png" />
+ </VisualElements>
+ </Application>
+ </Applications>
+ <Capabilities>
+ <Capability Name="internetClient" />
+ </Capabilities>
+</Package>
\ No newline at end of file