[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-30 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/cordova-windows/pull/96


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-21 Thread muratsu
Github user muratsu commented on the pull request:

https://github.com/apache/cordova-windows/pull/96#issuecomment-123413943
  
lgtm


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-13 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34525670
  
--- Diff: template/cordova/lib/package.js ---
@@ -130,58 +145,47 @@ module.exports.findDevice = function (target) {
 };
 
 // returns array of available devices names
-module.exports.listDevices = function () {
-return utils.getAppDeployUtils().then(function(appDeployUtils) {
-return exec('"' + appDeployUtils + '" 
/enumeratedevices').then(function(output) {
-return Q.resolve(output.split('\n').map(function(line) {
-var match = /\s*(\d)+\s+(.*)/.exec(line);
-return match && match[2];
-}).filter(function (line) {
-return line;
-}));
+module.exports.listDevices = function (deploymentTool) {
+
+return deploymentTool.enumerateDevices().then(function(deviceList) {
+return deviceList.map(function(device) {
+return device.toString();
 });
-});
-};
-
 
-function installAppToPhone(appDeployUtils, package, target, update) {
-// /installlaunch option sometimes fails with 'Error: The parameter is 
incorrect.'
-// so we use separate steps to /install or /update and then /launch
-var cmd = update ? '/update' : '/install';
-console.log('Installing application...');
-return spawn(appDeployUtils, [cmd, package.appx, '/targetdevice:' + 
target]);
-}
+}, function(e) {
+console.warn('Failed to enumerate devices');
+console.warn(e);
 
-function runAppOnPhone(appDeployUtils, target) {
-return Q().then(function() {
-return module.exports.getAppId(path.join(__dirname, '..', '..'));
-}).then(function(appId) {
-console.log('Running application... ');
-return spawn(appDeployUtils, ['/launch', appId, '/targetdevice:' + 
target]);
+throw e;
 });
-}
+};
+
 
 function uninstallAppFromPhone(appDeployUtils, package, target) {
 console.log('Attempting to remove previously installed 
application...');
-return spawn(appDeployUtils, ['/uninstall', package.phoneId, 
'/targetdevice:' + target]);
+return appDeployUtils.uninstallAppPackage(package.phoneId, target);
 }
 
 // deploys specified phone package to device/emulator and launches it
-module.exports.deployToPhone = function (package, deployTarget, 
targetWindows10) {
-var getTarget = deployTarget == 'device' ? Q('de') :
-deployTarget == 'emulator' ? Q('xd') : 
module.exports.findDevice(deployTarget);
-
-return getTarget.then(function(target) {
-return 
utils.getAppDeployUtils(targetWindows10).then(function(appDeployUtils) {
+module.exports.deployToPhone = function (package, deployTarget, 
targetWindows10, deploymentTool) {
+var deployment;
+if (deploymentTool) {
+deployment = Q(deploymentTool);
+}
+else {
+deployment = utils.getAppDeployUtils(targetWindows10);
+}
 
-return uninstallAppFromPhone(appDeployUtils, package, 
target).then(
+return deployment.then(function(deploymentTool) {
+return module.exports.findDevice(deploymentTool, 
deployTarget).then(function(target) {
+return uninstallAppFromPhone(deploymentTool, package, 
target).then(
 function() {}, function() {}).then(function() {
-return installAppToPhone(appDeployUtils, package, 
target, false);
-}).then(function() {
-return runAppOnPhone(appDeployUtils, target);
-}, function(error) {
+// shouldUpdate = false because we've already 
uninstalled
+return deploymentTool.installAppPackage(package.appx, 
target, true, false);
--- End diff --

Thanks! :clap: 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-13 Thread robpaveza
Github user robpaveza commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34480922
  
--- Diff: template/cordova/lib/package.js ---
@@ -130,58 +145,47 @@ module.exports.findDevice = function (target) {
 };
 
 // returns array of available devices names
-module.exports.listDevices = function () {
-return utils.getAppDeployUtils().then(function(appDeployUtils) {
-return exec('"' + appDeployUtils + '" 
/enumeratedevices').then(function(output) {
-return Q.resolve(output.split('\n').map(function(line) {
-var match = /\s*(\d)+\s+(.*)/.exec(line);
-return match && match[2];
-}).filter(function (line) {
-return line;
-}));
+module.exports.listDevices = function (deploymentTool) {
+
+return deploymentTool.enumerateDevices().then(function(deviceList) {
+return deviceList.map(function(device) {
+return device.toString();
 });
-});
-};
-
 
-function installAppToPhone(appDeployUtils, package, target, update) {
-// /installlaunch option sometimes fails with 'Error: The parameter is 
incorrect.'
-// so we use separate steps to /install or /update and then /launch
-var cmd = update ? '/update' : '/install';
-console.log('Installing application...');
-return spawn(appDeployUtils, [cmd, package.appx, '/targetdevice:' + 
target]);
-}
+}, function(e) {
+console.warn('Failed to enumerate devices');
+console.warn(e);
 
-function runAppOnPhone(appDeployUtils, target) {
-return Q().then(function() {
-return module.exports.getAppId(path.join(__dirname, '..', '..'));
-}).then(function(appId) {
-console.log('Running application... ');
-return spawn(appDeployUtils, ['/launch', appId, '/targetdevice:' + 
target]);
+throw e;
 });
-}
+};
+
 
 function uninstallAppFromPhone(appDeployUtils, package, target) {
 console.log('Attempting to remove previously installed 
application...');
-return spawn(appDeployUtils, ['/uninstall', package.phoneId, 
'/targetdevice:' + target]);
+return appDeployUtils.uninstallAppPackage(package.phoneId, target);
 }
 
 // deploys specified phone package to device/emulator and launches it
-module.exports.deployToPhone = function (package, deployTarget, 
targetWindows10) {
-var getTarget = deployTarget == 'device' ? Q('de') :
-deployTarget == 'emulator' ? Q('xd') : 
module.exports.findDevice(deployTarget);
-
-return getTarget.then(function(target) {
-return 
utils.getAppDeployUtils(targetWindows10).then(function(appDeployUtils) {
+module.exports.deployToPhone = function (package, deployTarget, 
targetWindows10, deploymentTool) {
+var deployment;
+if (deploymentTool) {
+deployment = Q(deploymentTool);
+}
+else {
+deployment = utils.getAppDeployUtils(targetWindows10);
+}
 
-return uninstallAppFromPhone(appDeployUtils, package, 
target).then(
+return deployment.then(function(deploymentTool) {
+return module.exports.findDevice(deploymentTool, 
deployTarget).then(function(target) {
+return uninstallAppFromPhone(deploymentTool, package, 
target).then(
 function() {}, function() {}).then(function() {
-return installAppToPhone(appDeployUtils, package, 
target, false);
-}).then(function() {
-return runAppOnPhone(appDeployUtils, target);
-}, function(error) {
+// shouldUpdate = false because we've already 
uninstalled
+return deploymentTool.installAppPackage(package.appx, 
target, true, false);
--- End diff --

Ah, now I understand.  I have pushed a new change that will address this 
feedback.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-08 Thread TimBarham
Github user TimBarham commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34224410
  
--- Diff: template/cordova/lib/package.js ---
@@ -130,58 +145,47 @@ module.exports.findDevice = function (target) {
 };
 
 // returns array of available devices names
-module.exports.listDevices = function () {
-return utils.getAppDeployUtils().then(function(appDeployUtils) {
-return exec('"' + appDeployUtils + '" 
/enumeratedevices').then(function(output) {
-return Q.resolve(output.split('\n').map(function(line) {
-var match = /\s*(\d)+\s+(.*)/.exec(line);
-return match && match[2];
-}).filter(function (line) {
-return line;
-}));
+module.exports.listDevices = function (deploymentTool) {
+
+return deploymentTool.enumerateDevices().then(function(deviceList) {
+return deviceList.map(function(device) {
+return device.toString();
 });
-});
-};
-
 
-function installAppToPhone(appDeployUtils, package, target, update) {
-// /installlaunch option sometimes fails with 'Error: The parameter is 
incorrect.'
-// so we use separate steps to /install or /update and then /launch
-var cmd = update ? '/update' : '/install';
-console.log('Installing application...');
-return spawn(appDeployUtils, [cmd, package.appx, '/targetdevice:' + 
target]);
-}
+}, function(e) {
+console.warn('Failed to enumerate devices');
+console.warn(e);
 
-function runAppOnPhone(appDeployUtils, target) {
-return Q().then(function() {
-return module.exports.getAppId(path.join(__dirname, '..', '..'));
-}).then(function(appId) {
-console.log('Running application... ');
-return spawn(appDeployUtils, ['/launch', appId, '/targetdevice:' + 
target]);
+throw e;
 });
-}
+};
+
 
 function uninstallAppFromPhone(appDeployUtils, package, target) {
 console.log('Attempting to remove previously installed 
application...');
-return spawn(appDeployUtils, ['/uninstall', package.phoneId, 
'/targetdevice:' + target]);
+return appDeployUtils.uninstallAppPackage(package.phoneId, target);
 }
 
 // deploys specified phone package to device/emulator and launches it
-module.exports.deployToPhone = function (package, deployTarget, 
targetWindows10) {
-var getTarget = deployTarget == 'device' ? Q('de') :
-deployTarget == 'emulator' ? Q('xd') : 
module.exports.findDevice(deployTarget);
-
-return getTarget.then(function(target) {
-return 
utils.getAppDeployUtils(targetWindows10).then(function(appDeployUtils) {
+module.exports.deployToPhone = function (package, deployTarget, 
targetWindows10, deploymentTool) {
+var deployment;
+if (deploymentTool) {
+deployment = Q(deploymentTool);
+}
+else {
+deployment = utils.getAppDeployUtils(targetWindows10);
+}
 
-return uninstallAppFromPhone(appDeployUtils, package, 
target).then(
+return deployment.then(function(deploymentTool) {
+return module.exports.findDevice(deploymentTool, 
deployTarget).then(function(target) {
+return uninstallAppFromPhone(deploymentTool, package, 
target).then(
 function() {}, function() {}).then(function() {
-return installAppToPhone(appDeployUtils, package, 
target, false);
-}).then(function() {
-return runAppOnPhone(appDeployUtils, target);
-}, function(error) {
+// shouldUpdate = false because we've already 
uninstalled
+return deploymentTool.installAppPackage(package.appx, 
target, true, false);
--- End diff --

:+1: 

It's a common recommendation for literal Boolean arguments in particular to 
name them at the call point to aid readability. Since JavaScript doesn't 
support named arguments, the usual approach is to include an inline comment, so:
```js
return deploymentTool.installAppPackage(package.appx, target,  
/*shouldLaunch*/ true, /*somethingElse*/ false);
```



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-08 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34168225
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,275 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
+var d = Q.defer();
+try {
+var child = proc.spawn(cmd, args, {cwd: opt_cwd, maxBuffer: 
1024000});
+var stdout = '', stderr = '';
+child.stdout.on('data', function(s) { stdout += s; });
+child.stderr.on('data', function(s) { stderr += s; });
+child.on('exit', function(code) {
+if (code) {
+d.reject(stderr);
+} else {
+d.resolve(stdout);
+}
+});
+} catch(e) {
+console.error('error caught: ' + e);
+d.reject(e);
+}
+return d.promise;
+}
+
+function DeploymentTool() {
+
+}
+
+/**
+ * Determines whether the requested version of the deployment tool is 
available.
+ * @returns True if the deployment tool can function; false if not.
+ */
+DeploymentTool.prototype.isAvailable = function() {
+return fs.existsSync(this.path);
+};
+
+/**
+ * Enumerates devices attached to the development machine.
+ * @returns A Promise for an array of objects, which should be passed into 
other functions to represent the device.
+ * @remarks The returned objects contain 'index', 'name', and 'type' 
properties indicating basic information about them, 
+ *which is limited to the information provided by the system.  Other 
properties may also be included, but they are 
+ *specific to the deployment tool which created them and are likely 
used internally.
+ */
+DeploymentTool.prototype.enumerateDevices = function() {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Installs an app package to the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param pathToAppxPackage The path to the .appx package to install.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ * @shouldLaunch Indicates whether to launch the app after installing it.
+ * @shouldUpdate Indicates whether to explicitly update the app, or 
install clean.
+ * @pin Optionally provided if the device requires pairing for deployment.
+ */
+DeploymentTool.prototype.installAppPackage = function(pathToAppxPackage, 
targetDevice, shouldLaunch, shouldUpdate, pin) {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Uninstalls an app package from the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param packageInfo The app package name or Phone GUID representing the 
app.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ */
+DeploymentTool.prototype.uninstallAppPackage = function(packageInfo, 
targetDevice) {
+return Q.reject('Unable to uninstall any app packages because that 
feature is not supported.');
+};
+
+/**
+ * Gets a list of installed apps on the target device.  This function is 
not supported for
+ * Windows Phone 8.1.
+ * @param targetDevice {Object} An object returned from a successful 

[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-08 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34168004
  
--- Diff: template/cordova/lib/target-list.js ---
@@ -17,20 +17,21 @@
under the License.
 */
 
-var devices = require('./package'),
+var deploy  = require('./deployment'),
 args = process.argv.slice(2);
 
 // help/usage function
 function help() {
 console.log('');
-console.log('Usage: node target-list.js  [ --emulators | --devices | 
--started_emulators | --all ]');
+console.log('Usage: node target-list.js [--win10] [ --emulators | 
--devices | --started_emulators | --all ]');
+console.log('--win10 : Chooses to list Windows 10 
devices (Windows 8.1 is default).');
 console.log('--emulators : List the possible target 
emulators availible.');
-console.log('--devices   : List the possible target 
devices availible. *NOT IMPLEMENTED YET*');
+console.log('--devices   : List the possible target 
devices availible.');
 console.log('--started_emulators : List any started emulators 
availible. *NOT IMPLEMENTED YET*');
 console.log('--all   : List all available devices');
 console.log('examples:');
 console.log('node target-list.js --emulators');
-console.log('node target-list.js --devices');
+console.log('node target-list.js --win10 --devices');
--- End diff --

Fair enough - this is more complicated than it should be. :8ball: 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-08 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34167789
  
--- Diff: template/cordova/lib/run.js ---
@@ -155,7 +155,8 @@ module.exports.help = function () {
 console.log('--appx=<8.1-win|8.1-phone|uap>');
 console.log('  : Overrides windows-target-version to 
build Windows 8.1, ');
 console.log('  Windows Phone 8.1, or 
Windows 10.');
-console.log('');
+console.log('--win10tools  : Uses Windows 10 deployment tools 
(used for a Windows 8.1 app when');
--- End diff --

Fair enough - I remember we faced the same thing with xapDeploy and 
appDeploy. :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-08 Thread robpaveza
Github user robpaveza commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34167364
  
--- Diff: template/cordova/lib/package.js ---
@@ -113,16 +112,32 @@ function getPackageName(platformPath) {
 
 // returns one of available devices which name match with provided string
 // return rejected promise if device with name specified not found
-module.exports.findDevice = function (target) {
+module.exports.findDevice = function (deploymentTool, target) {
 target = target.toLowerCase();
-return module.exports.listDevices().then(function(deviceList) {
+return deploymentTool.enumerateDevices().then(function(deviceList) {
 // CB-7617 since we use partial match shorter names should go 
first,
 // example case is ['Emulator 8.1 WVGA 4 inch 512MB', 'Emulator 
8.1 WVGA 4 inch']
-var sortedList = deviceList.concat().sort(function (l, r) { return 
l.length > r.length; });
-for (var idx in sortedList){
-if (sortedList[idx].toLowerCase().indexOf(target) > -1) {
-// we should return index based on original list
-return Q.resolve(deviceList.indexOf(sortedList[idx]));
+// In CB-9283, we need to differentiate between emulator, device, 
and target.
+// So, for emulators to honor the above CB-7617, we preserve the 
original behavior.
+// Else, we choose either the target by ID (DeviceInfo.index) or 
if it's just device,
+// we choose the default (aka first) device.
+if (target === 'emulator') {
+var sortedList = deviceList.concat().sort(function (l, r) { 
return l.toString().length > r.toString().length; });
--- End diff --

Heh, that's ActionScript, but since it all comes from ES3 it's still true.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-08 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34167579
  
--- Diff: template/cordova/lib/package.js ---
@@ -130,58 +145,47 @@ module.exports.findDevice = function (target) {
 };
 
 // returns array of available devices names
-module.exports.listDevices = function () {
-return utils.getAppDeployUtils().then(function(appDeployUtils) {
-return exec('"' + appDeployUtils + '" 
/enumeratedevices').then(function(output) {
-return Q.resolve(output.split('\n').map(function(line) {
-var match = /\s*(\d)+\s+(.*)/.exec(line);
-return match && match[2];
-}).filter(function (line) {
-return line;
-}));
+module.exports.listDevices = function (deploymentTool) {
+
+return deploymentTool.enumerateDevices().then(function(deviceList) {
+return deviceList.map(function(device) {
+return device.toString();
 });
-});
-};
-
 
-function installAppToPhone(appDeployUtils, package, target, update) {
-// /installlaunch option sometimes fails with 'Error: The parameter is 
incorrect.'
-// so we use separate steps to /install or /update and then /launch
-var cmd = update ? '/update' : '/install';
-console.log('Installing application...');
-return spawn(appDeployUtils, [cmd, package.appx, '/targetdevice:' + 
target]);
-}
+}, function(e) {
+console.warn('Failed to enumerate devices');
+console.warn(e);
 
-function runAppOnPhone(appDeployUtils, target) {
-return Q().then(function() {
-return module.exports.getAppId(path.join(__dirname, '..', '..'));
-}).then(function(appId) {
-console.log('Running application... ');
-return spawn(appDeployUtils, ['/launch', appId, '/targetdevice:' + 
target]);
+throw e;
 });
-}
+};
+
 
 function uninstallAppFromPhone(appDeployUtils, package, target) {
 console.log('Attempting to remove previously installed 
application...');
-return spawn(appDeployUtils, ['/uninstall', package.phoneId, 
'/targetdevice:' + target]);
+return appDeployUtils.uninstallAppPackage(package.phoneId, target);
 }
 
 // deploys specified phone package to device/emulator and launches it
-module.exports.deployToPhone = function (package, deployTarget, 
targetWindows10) {
-var getTarget = deployTarget == 'device' ? Q('de') :
-deployTarget == 'emulator' ? Q('xd') : 
module.exports.findDevice(deployTarget);
-
-return getTarget.then(function(target) {
-return 
utils.getAppDeployUtils(targetWindows10).then(function(appDeployUtils) {
+module.exports.deployToPhone = function (package, deployTarget, 
targetWindows10, deploymentTool) {
+var deployment;
+if (deploymentTool) {
+deployment = Q(deploymentTool);
+}
+else {
+deployment = utils.getAppDeployUtils(targetWindows10);
+}
 
-return uninstallAppFromPhone(appDeployUtils, package, 
target).then(
+return deployment.then(function(deploymentTool) {
+return module.exports.findDevice(deploymentTool, 
deployTarget).then(function(target) {
+return uninstallAppFromPhone(deploymentTool, package, 
target).then(
 function() {}, function() {}).then(function() {
-return installAppToPhone(appDeployUtils, package, 
target, false);
-}).then(function() {
-return runAppOnPhone(appDeployUtils, target);
-}, function(error) {
+// shouldUpdate = false because we've already 
uninstalled
+return deploymentTool.installAppPackage(package.appx, 
target, true, false);
--- End diff --

It's not clear from looking at the code what the literal `true` stands for 
unless I got to definition of the function `installAppPackage`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-08 Thread robpaveza
Github user robpaveza commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34166300
  
--- Diff: template/cordova/lib/package.js ---
@@ -113,16 +112,32 @@ function getPackageName(platformPath) {
 
 // returns one of available devices which name match with provided string
 // return rejected promise if device with name specified not found
-module.exports.findDevice = function (target) {
+module.exports.findDevice = function (deploymentTool, target) {
 target = target.toLowerCase();
-return module.exports.listDevices().then(function(deviceList) {
+return deploymentTool.enumerateDevices().then(function(deviceList) {
 // CB-7617 since we use partial match shorter names should go 
first,
 // example case is ['Emulator 8.1 WVGA 4 inch 512MB', 'Emulator 
8.1 WVGA 4 inch']
-var sortedList = deviceList.concat().sort(function (l, r) { return 
l.length > r.length; });
-for (var idx in sortedList){
-if (sortedList[idx].toLowerCase().indexOf(target) > -1) {
-// we should return index based on original list
-return Q.resolve(deviceList.indexOf(sortedList[idx]));
+// In CB-9283, we need to differentiate between emulator, device, 
and target.
+// So, for emulators to honor the above CB-7617, we preserve the 
original behavior.
+// Else, we choose either the target by ID (DeviceInfo.index) or 
if it's just device,
+// we choose the default (aka first) device.
+if (target === 'emulator') {
+var sortedList = deviceList.concat().sort(function (l, r) { 
return l.toString().length > r.toString().length; });
+for (var idx in sortedList){
--- End diff --

Yeah  I didn't want to mess with this code and end up breaking 
something downstream.  It seems to have been working for us up until now.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-08 Thread robpaveza
Github user robpaveza commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34166637
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,275 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
+var d = Q.defer();
+try {
+var child = proc.spawn(cmd, args, {cwd: opt_cwd, maxBuffer: 
1024000});
+var stdout = '', stderr = '';
+child.stdout.on('data', function(s) { stdout += s; });
+child.stderr.on('data', function(s) { stderr += s; });
+child.on('exit', function(code) {
+if (code) {
+d.reject(stderr);
+} else {
+d.resolve(stdout);
+}
+});
+} catch(e) {
+console.error('error caught: ' + e);
--- End diff --

This function is based on spawn.js, modified only to capture stdout/stderr. 
 The comment is a fair question, but I thought I'd preserve consistency in this 
case.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-08 Thread robpaveza
Github user robpaveza commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34166452
  
--- Diff: template/cordova/lib/package.js ---
@@ -113,16 +112,32 @@ function getPackageName(platformPath) {
 
 // returns one of available devices which name match with provided string
 // return rejected promise if device with name specified not found
-module.exports.findDevice = function (target) {
+module.exports.findDevice = function (deploymentTool, target) {
 target = target.toLowerCase();
-return module.exports.listDevices().then(function(deviceList) {
+return deploymentTool.enumerateDevices().then(function(deviceList) {
 // CB-7617 since we use partial match shorter names should go 
first,
 // example case is ['Emulator 8.1 WVGA 4 inch 512MB', 'Emulator 
8.1 WVGA 4 inch']
-var sortedList = deviceList.concat().sort(function (l, r) { return 
l.length > r.length; });
-for (var idx in sortedList){
-if (sortedList[idx].toLowerCase().indexOf(target) > -1) {
-// we should return index based on original list
-return Q.resolve(deviceList.indexOf(sortedList[idx]));
+// In CB-9283, we need to differentiate between emulator, device, 
and target.
+// So, for emulators to honor the above CB-7617, we preserve the 
original behavior.
+// Else, we choose either the target by ID (DeviceInfo.index) or 
if it's just device,
+// we choose the default (aka first) device.
+if (target === 'emulator') {
+var sortedList = deviceList.concat().sort(function (l, r) { 
return l.toString().length > r.toString().length; });
--- End diff --

concat() returns a copy of the original array.  
http://swingpants.com/2009/03/12/fastest-way-to-copy-an-array-concat-or-slice0/


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-08 Thread robpaveza
Github user robpaveza commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34165767
  
--- Diff: template/cordova/lib/target-list.js ---
@@ -17,20 +17,21 @@
under the License.
 */
 
-var devices = require('./package'),
+var deploy  = require('./deployment'),
 args = process.argv.slice(2);
 
 // help/usage function
 function help() {
 console.log('');
-console.log('Usage: node target-list.js  [ --emulators | --devices | 
--started_emulators | --all ]');
+console.log('Usage: node target-list.js [--win10] [ --emulators | 
--devices | --started_emulators | --all ]');
+console.log('--win10 : Chooses to list Windows 10 
devices (Windows 8.1 is default).');
 console.log('--emulators : List the possible target 
emulators availible.');
-console.log('--devices   : List the possible target 
devices availible. *NOT IMPLEMENTED YET*');
+console.log('--devices   : List the possible target 
devices availible.');
 console.log('--started_emulators : List any started emulators 
availible. *NOT IMPLEMENTED YET*');
 console.log('--all   : List all available devices');
 console.log('examples:');
 console.log('node target-list.js --emulators');
-console.log('node target-list.js --devices');
+console.log('node target-list.js --win10 --devices');
--- End diff --

Yeah, this is a complicated question, and I'm not sure what the right 
answer is right now.

The Windows 8.1 tool actually enumerates Windows 10 emulators, but it can't 
deploy to them.  Conversely, the Windows 10 tool does not presently enumerate 
Windows 10 emulators (because it also can't deploy to them).  The Windows 8.1 
tool is fast, the Windows 10 tool is slow (it does network probing).  We could 
possibly display both, but most likely we would end up simply having the 
following list, for example:

0. Device (device) [Windows 8.1 tools]
1. Mobile 4 inch 512MB 10.0.10176.0 (emulator) [Windows 8.1 tools]
2. Mobile 4 inch 1GB 10.0.10176.0 (emulator) [Windows 8.1 tools]
3. Mobile 5 inch 1GB 10.0.10176.0 (emulator) [Windows 8.1 tools]
4. Mobile 6 inch 2GB 10.0.10176.0 (emulator) [Windows 8.1 tools]
5. Windows Phone 8.1 4 inch 512MB (emulator) [Windows 8.1 tools]
6. Windows Phone 8.1 4 inch 1GB (emulator) [Windows 8.1 tools]
7. Windows Phone 8.1 5 inch 1GB (emulator) [Windows 8.1 tools]
8. Windows Phone 8.1 6 inch 2GB (emulator) [Windows 8.1 tools]
9. Lumia 1520 (RM-940) (device) [Windows 10 tools]

0 and 9 end up being the same thing, which is problematic.  I just don't 
know which is better: to repeat devices, or to have an option that picks "is my 
target device Windows 8.1 or Windows 10?"  I landed on the option choice, for 
compatibility reasons (opt into the new behavior).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-08 Thread robpaveza
Github user robpaveza commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34164434
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,275 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
+var d = Q.defer();
+try {
+var child = proc.spawn(cmd, args, {cwd: opt_cwd, maxBuffer: 
1024000});
+var stdout = '', stderr = '';
+child.stdout.on('data', function(s) { stdout += s; });
+child.stderr.on('data', function(s) { stderr += s; });
+child.on('exit', function(code) {
+if (code) {
+d.reject(stderr);
+} else {
+d.resolve(stdout);
+}
+});
+} catch(e) {
+console.error('error caught: ' + e);
+d.reject(e);
+}
+return d.promise;
+}
+
+function DeploymentTool() {
+
+}
+
+/**
+ * Determines whether the requested version of the deployment tool is 
available.
+ * @returns True if the deployment tool can function; false if not.
+ */
+DeploymentTool.prototype.isAvailable = function() {
+return fs.existsSync(this.path);
+};
+
+/**
+ * Enumerates devices attached to the development machine.
+ * @returns A Promise for an array of objects, which should be passed into 
other functions to represent the device.
+ * @remarks The returned objects contain 'index', 'name', and 'type' 
properties indicating basic information about them, 
+ *which is limited to the information provided by the system.  Other 
properties may also be included, but they are 
+ *specific to the deployment tool which created them and are likely 
used internally.
+ */
+DeploymentTool.prototype.enumerateDevices = function() {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Installs an app package to the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param pathToAppxPackage The path to the .appx package to install.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ * @shouldLaunch Indicates whether to launch the app after installing it.
+ * @shouldUpdate Indicates whether to explicitly update the app, or 
install clean.
+ * @pin Optionally provided if the device requires pairing for deployment.
+ */
+DeploymentTool.prototype.installAppPackage = function(pathToAppxPackage, 
targetDevice, shouldLaunch, shouldUpdate, pin) {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Uninstalls an app package from the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param packageInfo The app package name or Phone GUID representing the 
app.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ */
+DeploymentTool.prototype.uninstallAppPackage = function(packageInfo, 
targetDevice) {
+return Q.reject('Unable to uninstall any app packages because that 
feature is not supported.');
+};
+
+/**
+ * Gets a list of installed apps on the target device.  This function is 
not supported for
+ * Windows Phone 8.1.
+ * @param targetDevice {Object} An object returned from a successful

[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-08 Thread robpaveza
Github user robpaveza commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34164191
  
--- Diff: template/cordova/lib/run.js ---
@@ -155,7 +155,8 @@ module.exports.help = function () {
 console.log('--appx=<8.1-win|8.1-phone|uap>');
 console.log('  : Overrides windows-target-version to 
build Windows 8.1, ');
 console.log('  Windows Phone 8.1, or 
Windows 10.');
-console.log('');
+console.log('--win10tools  : Uses Windows 10 deployment tools 
(used for a Windows 8.1 app when');
--- End diff --

Because Windows 8.1 tools currently can't deploy to an 8.1 app to a Windows 
10 device.  Hence the parenthetical and the following line.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-08 Thread robpaveza
Github user robpaveza commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34164096
  
--- Diff: template/cordova/lib/package.js ---
@@ -130,58 +145,47 @@ module.exports.findDevice = function (target) {
 };
 
 // returns array of available devices names
-module.exports.listDevices = function () {
-return utils.getAppDeployUtils().then(function(appDeployUtils) {
-return exec('"' + appDeployUtils + '" 
/enumeratedevices').then(function(output) {
-return Q.resolve(output.split('\n').map(function(line) {
-var match = /\s*(\d)+\s+(.*)/.exec(line);
-return match && match[2];
-}).filter(function (line) {
-return line;
-}));
+module.exports.listDevices = function (deploymentTool) {
+
+return deploymentTool.enumerateDevices().then(function(deviceList) {
+return deviceList.map(function(device) {
+return device.toString();
 });
-});
-};
-
 
-function installAppToPhone(appDeployUtils, package, target, update) {
-// /installlaunch option sometimes fails with 'Error: The parameter is 
incorrect.'
-// so we use separate steps to /install or /update and then /launch
-var cmd = update ? '/update' : '/install';
-console.log('Installing application...');
-return spawn(appDeployUtils, [cmd, package.appx, '/targetdevice:' + 
target]);
-}
+}, function(e) {
+console.warn('Failed to enumerate devices');
+console.warn(e);
 
-function runAppOnPhone(appDeployUtils, target) {
-return Q().then(function() {
-return module.exports.getAppId(path.join(__dirname, '..', '..'));
-}).then(function(appId) {
-console.log('Running application... ');
-return spawn(appDeployUtils, ['/launch', appId, '/targetdevice:' + 
target]);
+throw e;
 });
-}
+};
+
 
 function uninstallAppFromPhone(appDeployUtils, package, target) {
 console.log('Attempting to remove previously installed 
application...');
-return spawn(appDeployUtils, ['/uninstall', package.phoneId, 
'/targetdevice:' + target]);
+return appDeployUtils.uninstallAppPackage(package.phoneId, target);
 }
 
 // deploys specified phone package to device/emulator and launches it
-module.exports.deployToPhone = function (package, deployTarget, 
targetWindows10) {
-var getTarget = deployTarget == 'device' ? Q('de') :
-deployTarget == 'emulator' ? Q('xd') : 
module.exports.findDevice(deployTarget);
-
-return getTarget.then(function(target) {
-return 
utils.getAppDeployUtils(targetWindows10).then(function(appDeployUtils) {
+module.exports.deployToPhone = function (package, deployTarget, 
targetWindows10, deploymentTool) {
+var deployment;
+if (deploymentTool) {
+deployment = Q(deploymentTool);
+}
+else {
+deployment = utils.getAppDeployUtils(targetWindows10);
+}
 
-return uninstallAppFromPhone(appDeployUtils, package, 
target).then(
+return deployment.then(function(deploymentTool) {
+return module.exports.findDevice(deploymentTool, 
deployTarget).then(function(target) {
+return uninstallAppFromPhone(deploymentTool, package, 
target).then(
 function() {}, function() {}).then(function() {
-return installAppToPhone(appDeployUtils, package, 
target, false);
-}).then(function() {
-return runAppOnPhone(appDeployUtils, target);
-}, function(error) {
+// shouldUpdate = false because we've already 
uninstalled
+return deploymentTool.installAppPackage(package.appx, 
target, true, false);
--- End diff --

I don't understand this comment.  Code comments should specify why you do 
something when it isn't immediately clear, not just repeat the code in comment 
form.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-08 Thread robpaveza
Github user robpaveza commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34163912
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,275 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
+var d = Q.defer();
+try {
+var child = proc.spawn(cmd, args, {cwd: opt_cwd, maxBuffer: 
1024000});
+var stdout = '', stderr = '';
+child.stdout.on('data', function(s) { stdout += s; });
+child.stderr.on('data', function(s) { stderr += s; });
+child.on('exit', function(code) {
+if (code) {
+d.reject(stderr);
+} else {
+d.resolve(stdout);
+}
+});
+} catch(e) {
+console.error('error caught: ' + e);
+d.reject(e);
+}
+return d.promise;
+}
+
+function DeploymentTool() {
+
+}
+
+/**
+ * Determines whether the requested version of the deployment tool is 
available.
+ * @returns True if the deployment tool can function; false if not.
+ */
+DeploymentTool.prototype.isAvailable = function() {
+return fs.existsSync(this.path);
+};
+
+/**
+ * Enumerates devices attached to the development machine.
+ * @returns A Promise for an array of objects, which should be passed into 
other functions to represent the device.
+ * @remarks The returned objects contain 'index', 'name', and 'type' 
properties indicating basic information about them, 
+ *which is limited to the information provided by the system.  Other 
properties may also be included, but they are 
+ *specific to the deployment tool which created them and are likely 
used internally.
+ */
+DeploymentTool.prototype.enumerateDevices = function() {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Installs an app package to the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param pathToAppxPackage The path to the .appx package to install.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ * @shouldLaunch Indicates whether to launch the app after installing it.
+ * @shouldUpdate Indicates whether to explicitly update the app, or 
install clean.
+ * @pin Optionally provided if the device requires pairing for deployment.
+ */
+DeploymentTool.prototype.installAppPackage = function(pathToAppxPackage, 
targetDevice, shouldLaunch, shouldUpdate, pin) {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Uninstalls an app package from the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param packageInfo The app package name or Phone GUID representing the 
app.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ */
+DeploymentTool.prototype.uninstallAppPackage = function(packageInfo, 
targetDevice) {
+return Q.reject('Unable to uninstall any app packages because that 
feature is not supported.');
+};
+
+/**
+ * Gets a list of installed apps on the target device.  This function is 
not supported for
+ * Windows Phone 8.1.
+ * @param targetDevice {Object} An object returned from a successful

[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-08 Thread robpaveza
Github user robpaveza commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34163428
  
--- Diff: spec/unit/deployment.spec.js ---
@@ -0,0 +1,282 @@
+/**
+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 rewire = require('rewire'),
+deployment = rewire('../../template/cordova/lib/deployment'),
+run= deployment.__get__('run'),
+Q  = require('q'),
+
+AppDeployCmdTool = deployment.__get__('AppDeployCmdTool'),
+WinAppDeployCmdTool = deployment.__get__('WinAppDeployCmdTool');
+
+var TEST_APP_PACKAGE_NAME = '"c:\\testapppackage.appx"',
+TEST_APP_PACKAGE_ID   = '12121212-3434-3434-3434-567856785678';
+
+describe('The correct version of the app deployment tool is obtained.', 
function() {
+
+it('Provides an AppDeployCmdTool when 8.1 is requested.', function() {
+
+var tool = deployment.getDeploymentTool('8.1');
+expect(tool instanceof AppDeployCmdTool).toBe(true);
+
+});
+
+it('Provides a WinAppDeployCmdTool when 10.0 is requested.', 
function() {
+
+var tool = deployment.getDeploymentTool('10.0');
+expect(tool instanceof WinAppDeployCmdTool).toBe(true);
+
+});
+
+});
+
+describe('Windows 10 deployment interacts with the file system as 
expected.', function() {
+
+function runMock(cmd, args, cwd) {
+expect(cmd).toBe('c:\\Program Files (x86)\\Windows 
Kits\\10\\bin\\x86\\WinAppDeployCmd.exe');
+switch (args[0]) {
+case 'devices':
+var output = 'Windows App Deployment Tool\r\nVersion 
10.0.0.0\r\nCopyright (c) Microsoft Corporation. All rights 
reserved.\r\n\r\nDiscovering devices...\r\nIP Address  GUID 
   Model/Name\r\n127.0.0.1   
0015-b21e-0da9--Lumia 1520 (RM-940)\r\n10.120.70.172   
----00155d61953200155D619532\r\n10.120.68.150   
----00155d01176500155D011765\r\nDone.';
+return Q(output);
+
+case 'update':
+case 'install':
+expect(args[2]).toBe(TEST_APP_PACKAGE_NAME);
+expect(args[4]).toBe('127.0.0.1');
+return Q('');
+
+case 'uninstall':
+expect(args[2]).toBe(TEST_APP_PACKAGE_ID);
+expect(args[4]).toBe('10.120.68.150');
+return Q('');
+
+}
+}
+
+var mockedProgramFiles = process.env['ProgramFiles(x86)'];
+beforeEach(function() {
+deployment.__set__('run', runMock);
+process.env['ProgramFiles(x86)'] = 'c:\\Program Files (x86)';
+});
+afterEach(function() {
+deployment.__set__('run', run);
+if (mockedProgramFiles) {
+process.env['ProgramFiles(x86)'] = mockedProgramFiles;
+} else {
+delete process.env['ProgramFiles(x86)'];
+}
+});
+
+it('enumerateDevices returns a valid set of objects', function() {
+var deploymentTool = deployment.getDeploymentTool('10.0');
+var done = false;
+deploymentTool.enumerateDevices().then(function(deviceList) {
+
+expect(deviceList.length).toBe(3);
+expect(deviceList[0].name).toBe('Lumia 1520 (RM-940)');
+expect(deviceList[0].index).toBe(0);
+expect(deviceList[0].type).toBe('device');
+
+done = true;
+
+});
+
+waitsFor(function() { return done; });
+});
+
+it('installAppPackage passes the correct set of parameters', 
function() {
+var deploymentTool = deployment.getDeploymentTool('10.0');
+var done = false;
+deploymentTool.enumerateDevices().then(function(deviceList) {
+deploymentToo

[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34110493
  
--- Diff: template/cordova/lib/target-list.js ---
@@ -17,20 +17,21 @@
under the License.
 */
 
-var devices = require('./package'),
+var deploy  = require('./deployment'),
 args = process.argv.slice(2);
 
 // help/usage function
 function help() {
 console.log('');
-console.log('Usage: node target-list.js  [ --emulators | --devices | 
--started_emulators | --all ]');
+console.log('Usage: node target-list.js [--win10] [ --emulators | 
--devices | --started_emulators | --all ]');
+console.log('--win10 : Chooses to list Windows 10 
devices (Windows 8.1 is default).');
 console.log('--emulators : List the possible target 
emulators availible.');
-console.log('--devices   : List the possible target 
devices availible. *NOT IMPLEMENTED YET*');
+console.log('--devices   : List the possible target 
devices availible.');
 console.log('--started_emulators : List any started emulators 
availible. *NOT IMPLEMENTED YET*');
 console.log('--all   : List all available devices');
 console.log('examples:');
 console.log('node target-list.js --emulators');
-console.log('node target-list.js --devices');
+console.log('node target-list.js --win10 --devices');
--- End diff --

does the cordova run --list command need an update? It will be nice to list 
both set of devices/emulators for Win10 & Win8.1 rather than have to specify an 
argument to pick and chose for listing purposes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34110425
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,275 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
+var d = Q.defer();
+try {
+var child = proc.spawn(cmd, args, {cwd: opt_cwd, maxBuffer: 
1024000});
+var stdout = '', stderr = '';
+child.stdout.on('data', function(s) { stdout += s; });
+child.stderr.on('data', function(s) { stderr += s; });
+child.on('exit', function(code) {
+if (code) {
+d.reject(stderr);
+} else {
+d.resolve(stdout);
+}
+});
+} catch(e) {
+console.error('error caught: ' + e);
+d.reject(e);
+}
+return d.promise;
+}
+
+function DeploymentTool() {
+
+}
+
+/**
+ * Determines whether the requested version of the deployment tool is 
available.
+ * @returns True if the deployment tool can function; false if not.
+ */
+DeploymentTool.prototype.isAvailable = function() {
+return fs.existsSync(this.path);
+};
+
+/**
+ * Enumerates devices attached to the development machine.
+ * @returns A Promise for an array of objects, which should be passed into 
other functions to represent the device.
+ * @remarks The returned objects contain 'index', 'name', and 'type' 
properties indicating basic information about them, 
+ *which is limited to the information provided by the system.  Other 
properties may also be included, but they are 
+ *specific to the deployment tool which created them and are likely 
used internally.
+ */
+DeploymentTool.prototype.enumerateDevices = function() {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Installs an app package to the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param pathToAppxPackage The path to the .appx package to install.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ * @shouldLaunch Indicates whether to launch the app after installing it.
+ * @shouldUpdate Indicates whether to explicitly update the app, or 
install clean.
+ * @pin Optionally provided if the device requires pairing for deployment.
+ */
+DeploymentTool.prototype.installAppPackage = function(pathToAppxPackage, 
targetDevice, shouldLaunch, shouldUpdate, pin) {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Uninstalls an app package from the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param packageInfo The app package name or Phone GUID representing the 
app.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ */
+DeploymentTool.prototype.uninstallAppPackage = function(packageInfo, 
targetDevice) {
+return Q.reject('Unable to uninstall any app packages because that 
feature is not supported.');
+};
+
+/**
+ * Gets a list of installed apps on the target device.  This function is 
not supported for
+ * Windows Phone 8.1.
+ * @param targetDevice {Object} An object returned from a successful 

[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34110226
  
--- Diff: template/cordova/lib/package.js ---
@@ -113,16 +112,32 @@ function getPackageName(platformPath) {
 
 // returns one of available devices which name match with provided string
 // return rejected promise if device with name specified not found
-module.exports.findDevice = function (target) {
+module.exports.findDevice = function (deploymentTool, target) {
 target = target.toLowerCase();
-return module.exports.listDevices().then(function(deviceList) {
+return deploymentTool.enumerateDevices().then(function(deviceList) {
 // CB-7617 since we use partial match shorter names should go 
first,
 // example case is ['Emulator 8.1 WVGA 4 inch 512MB', 'Emulator 
8.1 WVGA 4 inch']
-var sortedList = deviceList.concat().sort(function (l, r) { return 
l.length > r.length; });
-for (var idx in sortedList){
-if (sortedList[idx].toLowerCase().indexOf(target) > -1) {
-// we should return index based on original list
-return Q.resolve(deviceList.indexOf(sortedList[idx]));
+// In CB-9283, we need to differentiate between emulator, device, 
and target.
+// So, for emulators to honor the above CB-7617, we preserve the 
original behavior.
+// Else, we choose either the target by ID (DeviceInfo.index) or 
if it's just device,
+// we choose the default (aka first) device.
+if (target === 'emulator') {
+var sortedList = deviceList.concat().sort(function (l, r) { 
return l.toString().length > r.toString().length; });
+for (var idx in sortedList){
--- End diff --

If I understand correctly, `sortedList` is an array and foreach is quite a 
bad practice for arrays - unless we really have a case of a sparse array.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34110160
  
--- Diff: template/cordova/lib/package.js ---
@@ -113,16 +112,32 @@ function getPackageName(platformPath) {
 
 // returns one of available devices which name match with provided string
 // return rejected promise if device with name specified not found
-module.exports.findDevice = function (target) {
+module.exports.findDevice = function (deploymentTool, target) {
 target = target.toLowerCase();
-return module.exports.listDevices().then(function(deviceList) {
+return deploymentTool.enumerateDevices().then(function(deviceList) {
 // CB-7617 since we use partial match shorter names should go 
first,
 // example case is ['Emulator 8.1 WVGA 4 inch 512MB', 'Emulator 
8.1 WVGA 4 inch']
-var sortedList = deviceList.concat().sort(function (l, r) { return 
l.length > r.length; });
-for (var idx in sortedList){
-if (sortedList[idx].toLowerCase().indexOf(target) > -1) {
-// we should return index based on original list
-return Q.resolve(deviceList.indexOf(sortedList[idx]));
+// In CB-9283, we need to differentiate between emulator, device, 
and target.
+// So, for emulators to honor the above CB-7617, we preserve the 
original behavior.
+// Else, we choose either the target by ID (DeviceInfo.index) or 
if it's just device,
+// we choose the default (aka first) device.
+if (target === 'emulator') {
+var sortedList = deviceList.concat().sort(function (l, r) { 
return l.toString().length > r.toString().length; });
--- End diff --

I know this is existing code - but why would you `concat` here to nothing.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34109990
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,275 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
+var d = Q.defer();
+try {
+var child = proc.spawn(cmd, args, {cwd: opt_cwd, maxBuffer: 
1024000});
+var stdout = '', stderr = '';
+child.stdout.on('data', function(s) { stdout += s; });
+child.stderr.on('data', function(s) { stderr += s; });
+child.on('exit', function(code) {
+if (code) {
+d.reject(stderr);
+} else {
+d.resolve(stdout);
+}
+});
+} catch(e) {
+console.error('error caught: ' + e);
+d.reject(e);
+}
+return d.promise;
+}
+
+function DeploymentTool() {
+
+}
+
+/**
+ * Determines whether the requested version of the deployment tool is 
available.
+ * @returns True if the deployment tool can function; false if not.
+ */
+DeploymentTool.prototype.isAvailable = function() {
+return fs.existsSync(this.path);
+};
+
+/**
+ * Enumerates devices attached to the development machine.
+ * @returns A Promise for an array of objects, which should be passed into 
other functions to represent the device.
+ * @remarks The returned objects contain 'index', 'name', and 'type' 
properties indicating basic information about them, 
+ *which is limited to the information provided by the system.  Other 
properties may also be included, but they are 
+ *specific to the deployment tool which created them and are likely 
used internally.
+ */
+DeploymentTool.prototype.enumerateDevices = function() {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Installs an app package to the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param pathToAppxPackage The path to the .appx package to install.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ * @shouldLaunch Indicates whether to launch the app after installing it.
+ * @shouldUpdate Indicates whether to explicitly update the app, or 
install clean.
+ * @pin Optionally provided if the device requires pairing for deployment.
+ */
+DeploymentTool.prototype.installAppPackage = function(pathToAppxPackage, 
targetDevice, shouldLaunch, shouldUpdate, pin) {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Uninstalls an app package from the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param packageInfo The app package name or Phone GUID representing the 
app.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ */
+DeploymentTool.prototype.uninstallAppPackage = function(packageInfo, 
targetDevice) {
+return Q.reject('Unable to uninstall any app packages because that 
feature is not supported.');
+};
+
+/**
+ * Gets a list of installed apps on the target device.  This function is 
not supported for
+ * Windows Phone 8.1.
+ * @param targetDevice {Object} An object returned from a successful 

[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34109871
  
--- Diff: template/cordova/lib/run.js ---
@@ -155,7 +155,8 @@ module.exports.help = function () {
 console.log('--appx=<8.1-win|8.1-phone|uap>');
 console.log('  : Overrides windows-target-version to 
build Windows 8.1, ');
 console.log('  Windows Phone 8.1, or 
Windows 10.');
-console.log('');
+console.log('--win10tools  : Uses Windows 10 deployment tools 
(used for a Windows 8.1 app when');
--- End diff --

Why do we need to expose this as an option to the user?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34109798
  
--- Diff: template/cordova/lib/package.js ---
@@ -130,58 +145,47 @@ module.exports.findDevice = function (target) {
 };
 
 // returns array of available devices names
-module.exports.listDevices = function () {
-return utils.getAppDeployUtils().then(function(appDeployUtils) {
-return exec('"' + appDeployUtils + '" 
/enumeratedevices').then(function(output) {
-return Q.resolve(output.split('\n').map(function(line) {
-var match = /\s*(\d)+\s+(.*)/.exec(line);
-return match && match[2];
-}).filter(function (line) {
-return line;
-}));
+module.exports.listDevices = function (deploymentTool) {
+
+return deploymentTool.enumerateDevices().then(function(deviceList) {
+return deviceList.map(function(device) {
+return device.toString();
 });
-});
-};
-
 
-function installAppToPhone(appDeployUtils, package, target, update) {
-// /installlaunch option sometimes fails with 'Error: The parameter is 
incorrect.'
-// so we use separate steps to /install or /update and then /launch
-var cmd = update ? '/update' : '/install';
-console.log('Installing application...');
-return spawn(appDeployUtils, [cmd, package.appx, '/targetdevice:' + 
target]);
-}
+}, function(e) {
+console.warn('Failed to enumerate devices');
+console.warn(e);
 
-function runAppOnPhone(appDeployUtils, target) {
-return Q().then(function() {
-return module.exports.getAppId(path.join(__dirname, '..', '..'));
-}).then(function(appId) {
-console.log('Running application... ');
-return spawn(appDeployUtils, ['/launch', appId, '/targetdevice:' + 
target]);
+throw e;
 });
-}
+};
+
 
 function uninstallAppFromPhone(appDeployUtils, package, target) {
 console.log('Attempting to remove previously installed 
application...');
-return spawn(appDeployUtils, ['/uninstall', package.phoneId, 
'/targetdevice:' + target]);
+return appDeployUtils.uninstallAppPackage(package.phoneId, target);
 }
 
 // deploys specified phone package to device/emulator and launches it
-module.exports.deployToPhone = function (package, deployTarget, 
targetWindows10) {
-var getTarget = deployTarget == 'device' ? Q('de') :
-deployTarget == 'emulator' ? Q('xd') : 
module.exports.findDevice(deployTarget);
-
-return getTarget.then(function(target) {
-return 
utils.getAppDeployUtils(targetWindows10).then(function(appDeployUtils) {
+module.exports.deployToPhone = function (package, deployTarget, 
targetWindows10, deploymentTool) {
+var deployment;
+if (deploymentTool) {
+deployment = Q(deploymentTool);
+}
+else {
+deployment = utils.getAppDeployUtils(targetWindows10);
+}
 
-return uninstallAppFromPhone(appDeployUtils, package, 
target).then(
+return deployment.then(function(deploymentTool) {
+return module.exports.findDevice(deploymentTool, 
deployTarget).then(function(target) {
+return uninstallAppFromPhone(deploymentTool, package, 
target).then(
 function() {}, function() {}).then(function() {
-return installAppToPhone(appDeployUtils, package, 
target, false);
-}).then(function() {
-return runAppOnPhone(appDeployUtils, target);
-}, function(error) {
+// shouldUpdate = false because we've already 
uninstalled
+return deploymentTool.installAppPackage(package.appx, 
target, true, false);
+}).then(function() { }, function(error) {
+console.dir(error);
--- End diff --

should the console.dir be removed?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34109755
  
--- Diff: template/cordova/lib/package.js ---
@@ -130,58 +145,47 @@ module.exports.findDevice = function (target) {
 };
 
 // returns array of available devices names
-module.exports.listDevices = function () {
-return utils.getAppDeployUtils().then(function(appDeployUtils) {
-return exec('"' + appDeployUtils + '" 
/enumeratedevices').then(function(output) {
-return Q.resolve(output.split('\n').map(function(line) {
-var match = /\s*(\d)+\s+(.*)/.exec(line);
-return match && match[2];
-}).filter(function (line) {
-return line;
-}));
+module.exports.listDevices = function (deploymentTool) {
+
+return deploymentTool.enumerateDevices().then(function(deviceList) {
+return deviceList.map(function(device) {
+return device.toString();
 });
-});
-};
-
 
-function installAppToPhone(appDeployUtils, package, target, update) {
-// /installlaunch option sometimes fails with 'Error: The parameter is 
incorrect.'
-// so we use separate steps to /install or /update and then /launch
-var cmd = update ? '/update' : '/install';
-console.log('Installing application...');
-return spawn(appDeployUtils, [cmd, package.appx, '/targetdevice:' + 
target]);
-}
+}, function(e) {
+console.warn('Failed to enumerate devices');
+console.warn(e);
 
-function runAppOnPhone(appDeployUtils, target) {
-return Q().then(function() {
-return module.exports.getAppId(path.join(__dirname, '..', '..'));
-}).then(function(appId) {
-console.log('Running application... ');
-return spawn(appDeployUtils, ['/launch', appId, '/targetdevice:' + 
target]);
+throw e;
 });
-}
+};
+
 
 function uninstallAppFromPhone(appDeployUtils, package, target) {
 console.log('Attempting to remove previously installed 
application...');
-return spawn(appDeployUtils, ['/uninstall', package.phoneId, 
'/targetdevice:' + target]);
+return appDeployUtils.uninstallAppPackage(package.phoneId, target);
 }
 
 // deploys specified phone package to device/emulator and launches it
-module.exports.deployToPhone = function (package, deployTarget, 
targetWindows10) {
-var getTarget = deployTarget == 'device' ? Q('de') :
-deployTarget == 'emulator' ? Q('xd') : 
module.exports.findDevice(deployTarget);
-
-return getTarget.then(function(target) {
-return 
utils.getAppDeployUtils(targetWindows10).then(function(appDeployUtils) {
+module.exports.deployToPhone = function (package, deployTarget, 
targetWindows10, deploymentTool) {
+var deployment;
+if (deploymentTool) {
+deployment = Q(deploymentTool);
+}
+else {
+deployment = utils.getAppDeployUtils(targetWindows10);
+}
 
-return uninstallAppFromPhone(appDeployUtils, package, 
target).then(
+return deployment.then(function(deploymentTool) {
+return module.exports.findDevice(deploymentTool, 
deployTarget).then(function(target) {
+return uninstallAppFromPhone(deploymentTool, package, 
target).then(
 function() {}, function() {}).then(function() {
-return installAppToPhone(appDeployUtils, package, 
target, false);
-}).then(function() {
-return runAppOnPhone(appDeployUtils, target);
-}, function(error) {
+// shouldUpdate = false because we've already 
uninstalled
+return deploymentTool.installAppPackage(package.appx, 
target, true, false);
--- End diff --

It helps readability to have simple comments /*shouldLaunch=*/ true. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34109679
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,275 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
+var d = Q.defer();
+try {
+var child = proc.spawn(cmd, args, {cwd: opt_cwd, maxBuffer: 
1024000});
+var stdout = '', stderr = '';
+child.stdout.on('data', function(s) { stdout += s; });
+child.stderr.on('data', function(s) { stderr += s; });
+child.on('exit', function(code) {
+if (code) {
+d.reject(stderr);
+} else {
+d.resolve(stdout);
+}
+});
+} catch(e) {
+console.error('error caught: ' + e);
+d.reject(e);
+}
+return d.promise;
+}
+
+function DeploymentTool() {
+
+}
+
+/**
+ * Determines whether the requested version of the deployment tool is 
available.
+ * @returns True if the deployment tool can function; false if not.
+ */
+DeploymentTool.prototype.isAvailable = function() {
+return fs.existsSync(this.path);
+};
+
+/**
+ * Enumerates devices attached to the development machine.
+ * @returns A Promise for an array of objects, which should be passed into 
other functions to represent the device.
+ * @remarks The returned objects contain 'index', 'name', and 'type' 
properties indicating basic information about them, 
+ *which is limited to the information provided by the system.  Other 
properties may also be included, but they are 
+ *specific to the deployment tool which created them and are likely 
used internally.
+ */
+DeploymentTool.prototype.enumerateDevices = function() {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Installs an app package to the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param pathToAppxPackage The path to the .appx package to install.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ * @shouldLaunch Indicates whether to launch the app after installing it.
+ * @shouldUpdate Indicates whether to explicitly update the app, or 
install clean.
+ * @pin Optionally provided if the device requires pairing for deployment.
+ */
+DeploymentTool.prototype.installAppPackage = function(pathToAppxPackage, 
targetDevice, shouldLaunch, shouldUpdate, pin) {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Uninstalls an app package from the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param packageInfo The app package name or Phone GUID representing the 
app.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ */
+DeploymentTool.prototype.uninstallAppPackage = function(packageInfo, 
targetDevice) {
+return Q.reject('Unable to uninstall any app packages because that 
feature is not supported.');
+};
+
+/**
+ * Gets a list of installed apps on the target device.  This function is 
not supported for
+ * Windows Phone 8.1.
+ * @param targetDevice {Object} An object returned from a successful 

[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34109357
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,275 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
+var d = Q.defer();
+try {
+var child = proc.spawn(cmd, args, {cwd: opt_cwd, maxBuffer: 
1024000});
+var stdout = '', stderr = '';
+child.stdout.on('data', function(s) { stdout += s; });
+child.stderr.on('data', function(s) { stderr += s; });
+child.on('exit', function(code) {
+if (code) {
+d.reject(stderr);
+} else {
+d.resolve(stdout);
+}
+});
+} catch(e) {
+console.error('error caught: ' + e);
--- End diff --

Should this method be responsible for logging error or the caller?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34109092
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,272 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks 
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
--- End diff --

@vladimir-kotikov is working on cordova-common module that all platforms 
and cordova-lib could take a dependency on. At that point supersawn could be 
one of those things we could share.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34107527
  
--- Diff: spec/unit/deployment.spec.js ---
@@ -0,0 +1,282 @@
+/**
+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 rewire = require('rewire'),
+deployment = rewire('../../template/cordova/lib/deployment'),
+run= deployment.__get__('run'),
+Q  = require('q'),
+
+AppDeployCmdTool = deployment.__get__('AppDeployCmdTool'),
+WinAppDeployCmdTool = deployment.__get__('WinAppDeployCmdTool');
+
+var TEST_APP_PACKAGE_NAME = '"c:\\testapppackage.appx"',
+TEST_APP_PACKAGE_ID   = '12121212-3434-3434-3434-567856785678';
+
+describe('The correct version of the app deployment tool is obtained.', 
function() {
+
+it('Provides an AppDeployCmdTool when 8.1 is requested.', function() {
+
+var tool = deployment.getDeploymentTool('8.1');
+expect(tool instanceof AppDeployCmdTool).toBe(true);
+
+});
+
+it('Provides a WinAppDeployCmdTool when 10.0 is requested.', 
function() {
+
+var tool = deployment.getDeploymentTool('10.0');
+expect(tool instanceof WinAppDeployCmdTool).toBe(true);
+
+});
+
+});
+
+describe('Windows 10 deployment interacts with the file system as 
expected.', function() {
+
+function runMock(cmd, args, cwd) {
+expect(cmd).toBe('c:\\Program Files (x86)\\Windows 
Kits\\10\\bin\\x86\\WinAppDeployCmd.exe');
+switch (args[0]) {
+case 'devices':
+var output = 'Windows App Deployment Tool\r\nVersion 
10.0.0.0\r\nCopyright (c) Microsoft Corporation. All rights 
reserved.\r\n\r\nDiscovering devices...\r\nIP Address  GUID 
   Model/Name\r\n127.0.0.1   
0015-b21e-0da9--Lumia 1520 (RM-940)\r\n10.120.70.172   
----00155d61953200155D619532\r\n10.120.68.150   
----00155d01176500155D011765\r\nDone.';
+return Q(output);
+
+case 'update':
+case 'install':
+expect(args[2]).toBe(TEST_APP_PACKAGE_NAME);
+expect(args[4]).toBe('127.0.0.1');
+return Q('');
+
+case 'uninstall':
+expect(args[2]).toBe(TEST_APP_PACKAGE_ID);
+expect(args[4]).toBe('10.120.68.150');
+return Q('');
+
+}
+}
+
+var mockedProgramFiles = process.env['ProgramFiles(x86)'];
+beforeEach(function() {
+deployment.__set__('run', runMock);
+process.env['ProgramFiles(x86)'] = 'c:\\Program Files (x86)';
+});
+afterEach(function() {
+deployment.__set__('run', run);
+if (mockedProgramFiles) {
+process.env['ProgramFiles(x86)'] = mockedProgramFiles;
+} else {
+delete process.env['ProgramFiles(x86)'];
+}
+});
+
+it('enumerateDevices returns a valid set of objects', function() {
+var deploymentTool = deployment.getDeploymentTool('10.0');
+var done = false;
+deploymentTool.enumerateDevices().then(function(deviceList) {
+
+expect(deviceList.length).toBe(3);
+expect(deviceList[0].name).toBe('Lumia 1520 (RM-940)');
+expect(deviceList[0].index).toBe(0);
+expect(deviceList[0].type).toBe('device');
+
+done = true;
+
+});
+
+waitsFor(function() { return done; });
+});
+
+it('installAppPackage passes the correct set of parameters', 
function() {
+var deploymentTool = deployment.getDeploymentTool('10.0');
+var done = false;
+deploymentTool.enumerateDevices().then(function(deviceList) {
+deploymentTool

[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread robpaveza
Github user robpaveza commented on the pull request:

https://github.com/apache/cordova-windows/pull/96#issuecomment-119379779
  
The siblings work as expected, although they only support Windows 8.1.  
We'll have to make a decision about how to invoke the Windows 10 equivalent.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread robpaveza
Github user robpaveza commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34105951
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,272 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks 
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
+var d = Q.defer();
+try {
+var child = proc.spawn(cmd, args, {cwd: opt_cwd, maxBuffer: 
1024000});
+var stdout = '', stderr = '';
+child.stdout.on('data', function(s) { stdout += s; });
+child.stderr.on('data', function(s) { stderr += s; });
+child.on('exit', function(code) {
+if (code) {
+d.reject(stderr);
+} else {
+d.resolve(stdout);
+}
+});
+} catch(e) {
+console.error('error caught: ' + e);
+d.reject(e);
+}
+return d.promise;
+}
+
+function DeploymentTool() {
+
+}
+
+/**
+ * Determines whether the requested version of the deployment tool is 
available.
+ * @returns True if the deployment tool can function; false if not.
+ */
+DeploymentTool.prototype.isAvailable = function() {
+return fs.existsSync(this.path);
+};
+
+/** 
+ * Enumerates devices attached to the development machine.
+ * @returns A Promise for an array of objects, which should be passed into 
other functions to represent the device.
+ * @remarks The returned objects contain 'index', 'name', and 'type' 
properties indicating basic information about them, 
+ *which is limited to the information provided by the system.  Other 
properties may also be included, but they are 
+ *specific to the deployment tool which created them and are likely 
used internally.
+ */
+DeploymentTool.prototype.enumerateDevices = function() {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Installs an app package to the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param pathToAppxPackage The path to the .appx package to install.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ * @shouldLaunch Indicates whether to launch the app after installing it.
+ * @shouldUpdate Indicates whether to explicitly update the app, or 
install clean.
+ * @pin Optionally provided if the device requires pairing for deployment.
+ */
+DeploymentTool.prototype.installAppPackage = function(pathToAppxPackage, 
targetDevice, shouldLaunch, shouldUpdate, pin) {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Uninstalls an app package from the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param packageInfo The app package name or Phone GUID representing the 
app.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ */
+DeploymentTool.prototype.uninstallAppPackage = function(packageInfo, 
targetDevice) {
+return Q.reject('Unable to uninstall any app packages because that 
feature is not supported.');
+};
+
+/**
+ * Gets a list of installed apps on the target device.  This function is 
not supported for 
+ * Windows Phone 8.1.
+ * @param targetDevice {Object} An object returned from a success

[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread robpaveza
Github user robpaveza commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34105978
  
--- Diff: template/cordova/lib/target-list.js ---
@@ -17,20 +17,21 @@
under the License.
 */
 
-var devices = require('./package'),
+var deploy  = require('./deployment'),
 args = process.argv.slice(2);
 
 // help/usage function
 function help() {
 console.log('');
-console.log('Usage: node target-list.js  [ --emulators | --devices | 
--started_emulators | --all ]');
+console.log('Usage: node target-list.js [--win10] [ --emulators | 
--devices | --started_emulators | --all ]');
+console.log('--win10 : Chooses to list Windows 10 
devices (Windows 8.1 is default).');
 console.log('--emulators : List the possible target 
emulators availible.');
-console.log('--devices   : List the possible target 
devices availible. *NOT IMPLEMENTED YET*');
+console.log('--devices   : List the possible target 
devices availible.');
 console.log('--started_emulators : List any started emulators 
availible. *NOT IMPLEMENTED YET*');
 console.log('--all   : List all available devices');
 console.log('examples:');
-console.log('node target-list.js --emulators');
-console.log('node target-list.js --devices');
+console.log('node target-list.js --win8.1 --emulators');
--- End diff --

Good catch, it had been dropped.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread robpaveza
Github user robpaveza commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34105916
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,272 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks 
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
--- End diff --

True.  We could create a separate jira (I don't want to dot out of 
cordova-windows to access superspawn here) to do this refactor.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread robpaveza
Github user robpaveza commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34104776
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,272 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks 
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
+var d = Q.defer();
+try {
+var child = proc.spawn(cmd, args, {cwd: opt_cwd, maxBuffer: 
1024000});
+var stdout = '', stderr = '';
+child.stdout.on('data', function(s) { stdout += s; });
+child.stderr.on('data', function(s) { stderr += s; });
+child.on('exit', function(code) {
+if (code) {
+d.reject(stderr);
+} else {
+d.resolve(stdout);
+}
+});
+} catch(e) {
+console.error('error caught: ' + e);
+d.reject(e);
+}
+return d.promise;
+}
+
+function DeploymentTool() {
+
+}
+
+/**
+ * Determines whether the requested version of the deployment tool is 
available.
+ * @returns True if the deployment tool can function; false if not.
+ */
+DeploymentTool.prototype.isAvailable = function() {
+return fs.existsSync(this.path);
+};
+
+/** 
+ * Enumerates devices attached to the development machine.
+ * @returns A Promise for an array of objects, which should be passed into 
other functions to represent the device.
+ * @remarks The returned objects contain 'index', 'name', and 'type' 
properties indicating basic information about them, 
+ *which is limited to the information provided by the system.  Other 
properties may also be included, but they are 
+ *specific to the deployment tool which created them and are likely 
used internally.
+ */
+DeploymentTool.prototype.enumerateDevices = function() {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Installs an app package to the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param pathToAppxPackage The path to the .appx package to install.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ * @shouldLaunch Indicates whether to launch the app after installing it.
+ * @shouldUpdate Indicates whether to explicitly update the app, or 
install clean.
+ * @pin Optionally provided if the device requires pairing for deployment.
+ */
+DeploymentTool.prototype.installAppPackage = function(pathToAppxPackage, 
targetDevice, shouldLaunch, shouldUpdate, pin) {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Uninstalls an app package from the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param packageInfo The app package name or Phone GUID representing the 
app.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ */
+DeploymentTool.prototype.uninstallAppPackage = function(packageInfo, 
targetDevice) {
+return Q.reject('Unable to uninstall any app packages because that 
feature is not supported.');
+};
+
+/**
+ * Gets a list of installed apps on the target device.  This function is 
not supported for 
+ * Windows Phone 8.1.
+ * @param targetDevice {Object} An object returned from a success

[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread robpaveza
Github user robpaveza commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34104478
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,272 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks 
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
+var d = Q.defer();
+try {
+var child = proc.spawn(cmd, args, {cwd: opt_cwd, maxBuffer: 
1024000});
+var stdout = '', stderr = '';
+child.stdout.on('data', function(s) { stdout += s; });
+child.stderr.on('data', function(s) { stderr += s; });
+child.on('exit', function(code) {
+if (code) {
+d.reject(stderr);
+} else {
+d.resolve(stdout);
+}
+});
+} catch(e) {
+console.error('error caught: ' + e);
+d.reject(e);
+}
+return d.promise;
+}
+
+function DeploymentTool() {
+
+}
+
+/**
+ * Determines whether the requested version of the deployment tool is 
available.
+ * @returns True if the deployment tool can function; false if not.
+ */
+DeploymentTool.prototype.isAvailable = function() {
+return fs.existsSync(this.path);
+};
+
+/** 
+ * Enumerates devices attached to the development machine.
+ * @returns A Promise for an array of objects, which should be passed into 
other functions to represent the device.
+ * @remarks The returned objects contain 'index', 'name', and 'type' 
properties indicating basic information about them, 
+ *which is limited to the information provided by the system.  Other 
properties may also be included, but they are 
+ *specific to the deployment tool which created them and are likely 
used internally.
+ */
+DeploymentTool.prototype.enumerateDevices = function() {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Installs an app package to the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param pathToAppxPackage The path to the .appx package to install.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ * @shouldLaunch Indicates whether to launch the app after installing it.
+ * @shouldUpdate Indicates whether to explicitly update the app, or 
install clean.
+ * @pin Optionally provided if the device requires pairing for deployment.
+ */
+DeploymentTool.prototype.installAppPackage = function(pathToAppxPackage, 
targetDevice, shouldLaunch, shouldUpdate, pin) {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Uninstalls an app package from the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param packageInfo The app package name or Phone GUID representing the 
app.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ */
+DeploymentTool.prototype.uninstallAppPackage = function(packageInfo, 
targetDevice) {
+return Q.reject('Unable to uninstall any app packages because that 
feature is not supported.');
+};
+
+/**
+ * Gets a list of installed apps on the target device.  This function is 
not supported for 
+ * Windows Phone 8.1.
+ * @param targetDevice {Object} An object returned from a success

[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread muratsu
Github user muratsu commented on the pull request:

https://github.com/apache/cordova-windows/pull/96#issuecomment-119376109
  
Can you check template/cordova/lib/list-devices.bat and it's siblings to 
see if they still work as expected? This is a big refactor.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread muratsu
Github user muratsu commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34104129
  
--- Diff: template/cordova/lib/target-list.js ---
@@ -40,10 +41,42 @@ function help() {
 if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(args[0]) > 
-1) {
 help();
 } else {
-devices.listDevices()
-.then(function (deviceList) {
+
+var version = '8.1';
+if (args.indexOf('--win10') >= 0) {
+version = '10.0';
+}
+
+var onlyDevices = false;
+if (args.indexOf('--devices') >= 0) {
+onlyDevices = true;
+}
+
+var onlyEmulators = false;
+if (args.indexOf('--emulators') >= 0) {
+onlyEmulators = true;
+}
+
+if (onlyDevices && onlyEmulators) {
+console.warn('Error: Cannot specify both --emulators and 
--devices');
+help();
+return;
+}
+
--- End diff --

nit: trailing whitespace


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread muratsu
Github user muratsu commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34104122
  
--- Diff: template/cordova/lib/target-list.js ---
@@ -17,20 +17,21 @@
under the License.
 */
 
-var devices = require('./package'),
+var deploy  = require('./deployment'),
 args = process.argv.slice(2);
 
 // help/usage function
 function help() {
 console.log('');
-console.log('Usage: node target-list.js  [ --emulators | --devices | 
--started_emulators | --all ]');
+console.log('Usage: node target-list.js [--win10] [ --emulators | 
--devices | --started_emulators | --all ]');
+console.log('--win10 : Chooses to list Windows 10 
devices (Windows 8.1 is default).');
 console.log('--emulators : List the possible target 
emulators availible.');
-console.log('--devices   : List the possible target 
devices availible. *NOT IMPLEMENTED YET*');
+console.log('--devices   : List the possible target 
devices availible.');
 console.log('--started_emulators : List any started emulators 
availible. *NOT IMPLEMENTED YET*');
 console.log('--all   : List all available devices');
 console.log('examples:');
-console.log('node target-list.js --emulators');
-console.log('node target-list.js --devices');
+console.log('node target-list.js --win8.1 --emulators');
--- End diff --

--win8.1 flag is unhandled


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread muratsu
Github user muratsu commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34103731
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,272 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks 
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
+var d = Q.defer();
+try {
+var child = proc.spawn(cmd, args, {cwd: opt_cwd, maxBuffer: 
1024000});
+var stdout = '', stderr = '';
+child.stdout.on('data', function(s) { stdout += s; });
+child.stderr.on('data', function(s) { stderr += s; });
+child.on('exit', function(code) {
+if (code) {
+d.reject(stderr);
+} else {
+d.resolve(stdout);
+}
+});
+} catch(e) {
+console.error('error caught: ' + e);
+d.reject(e);
+}
+return d.promise;
+}
+
+function DeploymentTool() {
+
+}
+
+/**
+ * Determines whether the requested version of the deployment tool is 
available.
+ * @returns True if the deployment tool can function; false if not.
+ */
+DeploymentTool.prototype.isAvailable = function() {
+return fs.existsSync(this.path);
+};
+
+/** 
+ * Enumerates devices attached to the development machine.
+ * @returns A Promise for an array of objects, which should be passed into 
other functions to represent the device.
+ * @remarks The returned objects contain 'index', 'name', and 'type' 
properties indicating basic information about them, 
+ *which is limited to the information provided by the system.  Other 
properties may also be included, but they are 
+ *specific to the deployment tool which created them and are likely 
used internally.
+ */
+DeploymentTool.prototype.enumerateDevices = function() {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Installs an app package to the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param pathToAppxPackage The path to the .appx package to install.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ * @shouldLaunch Indicates whether to launch the app after installing it.
+ * @shouldUpdate Indicates whether to explicitly update the app, or 
install clean.
+ * @pin Optionally provided if the device requires pairing for deployment.
+ */
+DeploymentTool.prototype.installAppPackage = function(pathToAppxPackage, 
targetDevice, shouldLaunch, shouldUpdate, pin) {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Uninstalls an app package from the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param packageInfo The app package name or Phone GUID representing the 
app.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ */
+DeploymentTool.prototype.uninstallAppPackage = function(packageInfo, 
targetDevice) {
+return Q.reject('Unable to uninstall any app packages because that 
feature is not supported.');
+};
+
+/**
+ * Gets a list of installed apps on the target device.  This function is 
not supported for 
+ * Windows Phone 8.1.
+ * @param targetDevice {Object} An object returned from a successfu

[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread muratsu
Github user muratsu commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34103587
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,272 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks 
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
+var d = Q.defer();
+try {
+var child = proc.spawn(cmd, args, {cwd: opt_cwd, maxBuffer: 
1024000});
+var stdout = '', stderr = '';
+child.stdout.on('data', function(s) { stdout += s; });
+child.stderr.on('data', function(s) { stderr += s; });
+child.on('exit', function(code) {
+if (code) {
+d.reject(stderr);
+} else {
+d.resolve(stdout);
+}
+});
+} catch(e) {
+console.error('error caught: ' + e);
+d.reject(e);
+}
+return d.promise;
+}
+
+function DeploymentTool() {
+
+}
+
+/**
+ * Determines whether the requested version of the deployment tool is 
available.
+ * @returns True if the deployment tool can function; false if not.
+ */
+DeploymentTool.prototype.isAvailable = function() {
+return fs.existsSync(this.path);
+};
+
+/** 
+ * Enumerates devices attached to the development machine.
+ * @returns A Promise for an array of objects, which should be passed into 
other functions to represent the device.
+ * @remarks The returned objects contain 'index', 'name', and 'type' 
properties indicating basic information about them, 
+ *which is limited to the information provided by the system.  Other 
properties may also be included, but they are 
+ *specific to the deployment tool which created them and are likely 
used internally.
+ */
+DeploymentTool.prototype.enumerateDevices = function() {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Installs an app package to the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param pathToAppxPackage The path to the .appx package to install.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ * @shouldLaunch Indicates whether to launch the app after installing it.
+ * @shouldUpdate Indicates whether to explicitly update the app, or 
install clean.
+ * @pin Optionally provided if the device requires pairing for deployment.
+ */
+DeploymentTool.prototype.installAppPackage = function(pathToAppxPackage, 
targetDevice, shouldLaunch, shouldUpdate, pin) {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Uninstalls an app package from the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param packageInfo The app package name or Phone GUID representing the 
app.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ */
+DeploymentTool.prototype.uninstallAppPackage = function(packageInfo, 
targetDevice) {
+return Q.reject('Unable to uninstall any app packages because that 
feature is not supported.');
+};
+
+/**
+ * Gets a list of installed apps on the target device.  This function is 
not supported for 
+ * Windows Phone 8.1.
+ * @param targetDevice {Object} An object returned from a successfu

[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread muratsu
Github user muratsu commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34103420
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,272 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks 
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
+var d = Q.defer();
+try {
+var child = proc.spawn(cmd, args, {cwd: opt_cwd, maxBuffer: 
1024000});
+var stdout = '', stderr = '';
+child.stdout.on('data', function(s) { stdout += s; });
+child.stderr.on('data', function(s) { stderr += s; });
+child.on('exit', function(code) {
+if (code) {
+d.reject(stderr);
+} else {
+d.resolve(stdout);
+}
+});
+} catch(e) {
+console.error('error caught: ' + e);
+d.reject(e);
+}
+return d.promise;
+}
+
+function DeploymentTool() {
+
+}
+
+/**
+ * Determines whether the requested version of the deployment tool is 
available.
+ * @returns True if the deployment tool can function; false if not.
+ */
+DeploymentTool.prototype.isAvailable = function() {
+return fs.existsSync(this.path);
+};
+
+/** 
+ * Enumerates devices attached to the development machine.
+ * @returns A Promise for an array of objects, which should be passed into 
other functions to represent the device.
+ * @remarks The returned objects contain 'index', 'name', and 'type' 
properties indicating basic information about them, 
+ *which is limited to the information provided by the system.  Other 
properties may also be included, but they are 
+ *specific to the deployment tool which created them and are likely 
used internally.
+ */
+DeploymentTool.prototype.enumerateDevices = function() {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Installs an app package to the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param pathToAppxPackage The path to the .appx package to install.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ * @shouldLaunch Indicates whether to launch the app after installing it.
+ * @shouldUpdate Indicates whether to explicitly update the app, or 
install clean.
+ * @pin Optionally provided if the device requires pairing for deployment.
+ */
+DeploymentTool.prototype.installAppPackage = function(pathToAppxPackage, 
targetDevice, shouldLaunch, shouldUpdate, pin) {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Uninstalls an app package from the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param packageInfo The app package name or Phone GUID representing the 
app.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ */
+DeploymentTool.prototype.uninstallAppPackage = function(packageInfo, 
targetDevice) {
+return Q.reject('Unable to uninstall any app packages because that 
feature is not supported.');
+};
+
+/**
+ * Gets a list of installed apps on the target device.  This function is 
not supported for 
+ * Windows Phone 8.1.
+ * @param targetDevice {Object} An object returned from a successfu

[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread muratsu
Github user muratsu commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34102430
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,272 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks 
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
+var d = Q.defer();
+try {
+var child = proc.spawn(cmd, args, {cwd: opt_cwd, maxBuffer: 
1024000});
+var stdout = '', stderr = '';
+child.stdout.on('data', function(s) { stdout += s; });
+child.stderr.on('data', function(s) { stderr += s; });
+child.on('exit', function(code) {
+if (code) {
+d.reject(stderr);
+} else {
+d.resolve(stdout);
+}
+});
+} catch(e) {
+console.error('error caught: ' + e);
+d.reject(e);
+}
+return d.promise;
+}
+
+function DeploymentTool() {
+
+}
+
+/**
+ * Determines whether the requested version of the deployment tool is 
available.
+ * @returns True if the deployment tool can function; false if not.
+ */
+DeploymentTool.prototype.isAvailable = function() {
+return fs.existsSync(this.path);
+};
+
+/** 
+ * Enumerates devices attached to the development machine.
+ * @returns A Promise for an array of objects, which should be passed into 
other functions to represent the device.
+ * @remarks The returned objects contain 'index', 'name', and 'type' 
properties indicating basic information about them, 
+ *which is limited to the information provided by the system.  Other 
properties may also be included, but they are 
+ *specific to the deployment tool which created them and are likely 
used internally.
+ */
+DeploymentTool.prototype.enumerateDevices = function() {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Installs an app package to the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param pathToAppxPackage The path to the .appx package to install.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ * @shouldLaunch Indicates whether to launch the app after installing it.
+ * @shouldUpdate Indicates whether to explicitly update the app, or 
install clean.
+ * @pin Optionally provided if the device requires pairing for deployment.
+ */
+DeploymentTool.prototype.installAppPackage = function(pathToAppxPackage, 
targetDevice, shouldLaunch, shouldUpdate, pin) {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Uninstalls an app package from the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param packageInfo The app package name or Phone GUID representing the 
app.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ */
+DeploymentTool.prototype.uninstallAppPackage = function(packageInfo, 
targetDevice) {
+return Q.reject('Unable to uninstall any app packages because that 
feature is not supported.');
+};
+
+/**
+ * Gets a list of installed apps on the target device.  This function is 
not supported for 
+ * Windows Phone 8.1.
+ * @param targetDevice {Object} An object returned from a successfu

[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread muratsu
Github user muratsu commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34101895
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,272 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks 
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
+var d = Q.defer();
+try {
+var child = proc.spawn(cmd, args, {cwd: opt_cwd, maxBuffer: 
1024000});
+var stdout = '', stderr = '';
+child.stdout.on('data', function(s) { stdout += s; });
+child.stderr.on('data', function(s) { stderr += s; });
+child.on('exit', function(code) {
+if (code) {
+d.reject(stderr);
+} else {
+d.resolve(stdout);
+}
+});
+} catch(e) {
+console.error('error caught: ' + e);
+d.reject(e);
+}
+return d.promise;
+}
+
+function DeploymentTool() {
+
+}
+
+/**
+ * Determines whether the requested version of the deployment tool is 
available.
+ * @returns True if the deployment tool can function; false if not.
+ */
+DeploymentTool.prototype.isAvailable = function() {
+return fs.existsSync(this.path);
+};
+
+/** 
+ * Enumerates devices attached to the development machine.
+ * @returns A Promise for an array of objects, which should be passed into 
other functions to represent the device.
+ * @remarks The returned objects contain 'index', 'name', and 'type' 
properties indicating basic information about them, 
+ *which is limited to the information provided by the system.  Other 
properties may also be included, but they are 
+ *specific to the deployment tool which created them and are likely 
used internally.
+ */
+DeploymentTool.prototype.enumerateDevices = function() {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Installs an app package to the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param pathToAppxPackage The path to the .appx package to install.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ * @shouldLaunch Indicates whether to launch the app after installing it.
+ * @shouldUpdate Indicates whether to explicitly update the app, or 
install clean.
+ * @pin Optionally provided if the device requires pairing for deployment.
+ */
+DeploymentTool.prototype.installAppPackage = function(pathToAppxPackage, 
targetDevice, shouldLaunch, shouldUpdate, pin) {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Uninstalls an app package from the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param packageInfo The app package name or Phone GUID representing the 
app.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ */
+DeploymentTool.prototype.uninstallAppPackage = function(packageInfo, 
targetDevice) {
+return Q.reject('Unable to uninstall any app packages because that 
feature is not supported.');
+};
+
+/**
+ * Gets a list of installed apps on the target device.  This function is 
not supported for 
+ * Windows Phone 8.1.
+ * @param targetDevice {Object} An object returned from a successfu

[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread muratsu
Github user muratsu commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34101903
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,272 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks 
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
+var d = Q.defer();
+try {
+var child = proc.spawn(cmd, args, {cwd: opt_cwd, maxBuffer: 
1024000});
+var stdout = '', stderr = '';
+child.stdout.on('data', function(s) { stdout += s; });
+child.stderr.on('data', function(s) { stderr += s; });
+child.on('exit', function(code) {
+if (code) {
+d.reject(stderr);
+} else {
+d.resolve(stdout);
+}
+});
+} catch(e) {
+console.error('error caught: ' + e);
+d.reject(e);
+}
+return d.promise;
+}
+
+function DeploymentTool() {
+
+}
+
+/**
+ * Determines whether the requested version of the deployment tool is 
available.
+ * @returns True if the deployment tool can function; false if not.
+ */
+DeploymentTool.prototype.isAvailable = function() {
+return fs.existsSync(this.path);
+};
+
+/** 
+ * Enumerates devices attached to the development machine.
+ * @returns A Promise for an array of objects, which should be passed into 
other functions to represent the device.
+ * @remarks The returned objects contain 'index', 'name', and 'type' 
properties indicating basic information about them, 
+ *which is limited to the information provided by the system.  Other 
properties may also be included, but they are 
+ *specific to the deployment tool which created them and are likely 
used internally.
+ */
+DeploymentTool.prototype.enumerateDevices = function() {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Installs an app package to the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param pathToAppxPackage The path to the .appx package to install.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ * @shouldLaunch Indicates whether to launch the app after installing it.
+ * @shouldUpdate Indicates whether to explicitly update the app, or 
install clean.
+ * @pin Optionally provided if the device requires pairing for deployment.
+ */
+DeploymentTool.prototype.installAppPackage = function(pathToAppxPackage, 
targetDevice, shouldLaunch, shouldUpdate, pin) {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Uninstalls an app package from the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param packageInfo The app package name or Phone GUID representing the 
app.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ */
+DeploymentTool.prototype.uninstallAppPackage = function(packageInfo, 
targetDevice) {
+return Q.reject('Unable to uninstall any app packages because that 
feature is not supported.');
+};
+
+/**
+ * Gets a list of installed apps on the target device.  This function is 
not supported for 
+ * Windows Phone 8.1.
+ * @param targetDevice {Object} An object returned from a successfu

[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread muratsu
Github user muratsu commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34101879
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,272 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks 
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
+var d = Q.defer();
+try {
+var child = proc.spawn(cmd, args, {cwd: opt_cwd, maxBuffer: 
1024000});
+var stdout = '', stderr = '';
+child.stdout.on('data', function(s) { stdout += s; });
+child.stderr.on('data', function(s) { stderr += s; });
+child.on('exit', function(code) {
+if (code) {
+d.reject(stderr);
+} else {
+d.resolve(stdout);
+}
+});
+} catch(e) {
+console.error('error caught: ' + e);
+d.reject(e);
+}
+return d.promise;
+}
+
+function DeploymentTool() {
+
+}
+
+/**
+ * Determines whether the requested version of the deployment tool is 
available.
+ * @returns True if the deployment tool can function; false if not.
+ */
+DeploymentTool.prototype.isAvailable = function() {
+return fs.existsSync(this.path);
+};
+
+/** 
+ * Enumerates devices attached to the development machine.
+ * @returns A Promise for an array of objects, which should be passed into 
other functions to represent the device.
+ * @remarks The returned objects contain 'index', 'name', and 'type' 
properties indicating basic information about them, 
+ *which is limited to the information provided by the system.  Other 
properties may also be included, but they are 
+ *specific to the deployment tool which created them and are likely 
used internally.
+ */
+DeploymentTool.prototype.enumerateDevices = function() {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Installs an app package to the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param pathToAppxPackage The path to the .appx package to install.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ * @shouldLaunch Indicates whether to launch the app after installing it.
+ * @shouldUpdate Indicates whether to explicitly update the app, or 
install clean.
+ * @pin Optionally provided if the device requires pairing for deployment.
+ */
+DeploymentTool.prototype.installAppPackage = function(pathToAppxPackage, 
targetDevice, shouldLaunch, shouldUpdate, pin) {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Uninstalls an app package from the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param packageInfo The app package name or Phone GUID representing the 
app.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ */
+DeploymentTool.prototype.uninstallAppPackage = function(packageInfo, 
targetDevice) {
+return Q.reject('Unable to uninstall any app packages because that 
feature is not supported.');
+};
+
+/**
+ * Gets a list of installed apps on the target device.  This function is 
not supported for 
--- End diff --

nit: trailing whitespace


---
If your project is set up for it, you c

[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread muratsu
Github user muratsu commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34101887
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,272 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks 
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
+var d = Q.defer();
+try {
+var child = proc.spawn(cmd, args, {cwd: opt_cwd, maxBuffer: 
1024000});
+var stdout = '', stderr = '';
+child.stdout.on('data', function(s) { stdout += s; });
+child.stderr.on('data', function(s) { stderr += s; });
+child.on('exit', function(code) {
+if (code) {
+d.reject(stderr);
+} else {
+d.resolve(stdout);
+}
+});
+} catch(e) {
+console.error('error caught: ' + e);
+d.reject(e);
+}
+return d.promise;
+}
+
+function DeploymentTool() {
+
+}
+
+/**
+ * Determines whether the requested version of the deployment tool is 
available.
+ * @returns True if the deployment tool can function; false if not.
+ */
+DeploymentTool.prototype.isAvailable = function() {
+return fs.existsSync(this.path);
+};
+
+/** 
+ * Enumerates devices attached to the development machine.
+ * @returns A Promise for an array of objects, which should be passed into 
other functions to represent the device.
+ * @remarks The returned objects contain 'index', 'name', and 'type' 
properties indicating basic information about them, 
+ *which is limited to the information provided by the system.  Other 
properties may also be included, but they are 
+ *specific to the deployment tool which created them and are likely 
used internally.
+ */
+DeploymentTool.prototype.enumerateDevices = function() {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Installs an app package to the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param pathToAppxPackage The path to the .appx package to install.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ * @shouldLaunch Indicates whether to launch the app after installing it.
+ * @shouldUpdate Indicates whether to explicitly update the app, or 
install clean.
+ * @pin Optionally provided if the device requires pairing for deployment.
+ */
+DeploymentTool.prototype.installAppPackage = function(pathToAppxPackage, 
targetDevice, shouldLaunch, shouldUpdate, pin) {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Uninstalls an app package from the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param packageInfo The app package name or Phone GUID representing the 
app.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ */
+DeploymentTool.prototype.uninstallAppPackage = function(packageInfo, 
targetDevice) {
+return Q.reject('Unable to uninstall any app packages because that 
feature is not supported.');
+};
+
+/**
+ * Gets a list of installed apps on the target device.  This function is 
not supported for 
+ * Windows Phone 8.1.
+ * @param targetDevice {Object} An object returned from a successfu

[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread muratsu
Github user muratsu commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34101845
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,272 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks 
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
+var d = Q.defer();
+try {
+var child = proc.spawn(cmd, args, {cwd: opt_cwd, maxBuffer: 
1024000});
+var stdout = '', stderr = '';
+child.stdout.on('data', function(s) { stdout += s; });
+child.stderr.on('data', function(s) { stderr += s; });
+child.on('exit', function(code) {
+if (code) {
+d.reject(stderr);
+} else {
+d.resolve(stdout);
+}
+});
+} catch(e) {
+console.error('error caught: ' + e);
+d.reject(e);
+}
+return d.promise;
+}
+
+function DeploymentTool() {
+
+}
+
+/**
+ * Determines whether the requested version of the deployment tool is 
available.
+ * @returns True if the deployment tool can function; false if not.
+ */
+DeploymentTool.prototype.isAvailable = function() {
+return fs.existsSync(this.path);
+};
+
+/** 
--- End diff --

nit: trailing whitespace


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread muratsu
Github user muratsu commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34101792
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,272 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks 
--- End diff --

nit: trailing whitespace


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread muratsu
Github user muratsu commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34101423
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,272 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks 
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
--- End diff --

I see this function everywhere in cordova codebase. We should really make a 
npm module out of it and publish it.
Better(?) version of this function is available at 
cordova-lib\cordova-lib\src\cordova\superspawn.js


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org



[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-07 Thread robpaveza
Github user robpaveza commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r34089196
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,272 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks 
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
+var d = Q.defer();
+try {
+var child = proc.spawn(cmd, args, {cwd: opt_cwd, maxBuffer: 
1024000});
+var stdout = '', stderr = '';
+child.stdout.on('data', function(s) { stdout += s; });
+child.stderr.on('data', function(s) { stderr += s; });
+child.on('exit', function(code) {
+if (code) {
+d.reject(stderr);
+} else {
+d.resolve(stdout);
+}
+});
+} catch(e) {
+console.error('error caught: ' + e);
+d.reject(e);
+}
+return d.promise;
+}
+
+function DeploymentTool() {
+
+}
+
+/**
+ * Determines whether the requested version of the deployment tool is 
available.
+ * @returns True if the deployment tool can function; false if not.
+ */
+DeploymentTool.prototype.isAvailable = function() {
+return fs.existsSync(this.path);
+};
+
+/** 
+ * Enumerates devices attached to the development machine.
+ * @returns A Promise for an array of objects, which should be passed into 
other functions to represent the device.
+ * @remarks The returned objects contain 'index', 'name', and 'type' 
properties indicating basic information about them, 
+ *which is limited to the information provided by the system.  Other 
properties may also be included, but they are 
+ *specific to the deployment tool which created them and are likely 
used internally.
+ */
+DeploymentTool.prototype.enumerateDevices = function() {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Installs an app package to the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param pathToAppxPackage The path to the .appx package to install.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ * @shouldLaunch Indicates whether to launch the app after installing it.
+ * @shouldUpdate Indicates whether to explicitly update the app, or 
install clean.
+ * @pin Optionally provided if the device requires pairing for deployment.
+ */
+DeploymentTool.prototype.installAppPackage = function(pathToAppxPackage, 
targetDevice, shouldLaunch, shouldUpdate, pin) {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Uninstalls an app package from the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param packageInfo The app package name or Phone GUID representing the 
app.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ */
+DeploymentTool.prototype.uninstallAppPackage = function(packageInfo, 
targetDevice) {
+return Q.reject('Unable to uninstall any app packages because that 
feature is not supported.');
+};
+
+/**
+ * Gets a list of installed apps on the target device.  This function is 
not supported for 
+ * Windows Phone 8.1.
+ * @param targetDevice {Object} An object returned from a success

[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-06 Thread nikhilkh
Github user nikhilkh commented on a diff in the pull request:

https://github.com/apache/cordova-windows/pull/96#discussion_r33999448
  
--- Diff: template/cordova/lib/deployment.js ---
@@ -0,0 +1,272 @@
+/*
+   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 Q = require('q'),
+fs= require('fs'),
+/* jshint ignore:start */ // 'path' only used in ignored blocks 
+path  = require('path'),
+/* jshint ignore:end */
+proc  = require('child_process');
+
+// neither 'exec' nor 'spawn' was sufficient because we need to pass 
arguments via spawn
+// but also need to be able to capture stdout / stderr
+function run(cmd, args, opt_cwd) {
+var d = Q.defer();
+try {
+var child = proc.spawn(cmd, args, {cwd: opt_cwd, maxBuffer: 
1024000});
+var stdout = '', stderr = '';
+child.stdout.on('data', function(s) { stdout += s; });
+child.stderr.on('data', function(s) { stderr += s; });
+child.on('exit', function(code) {
+if (code) {
+d.reject(stderr);
+} else {
+d.resolve(stdout);
+}
+});
+} catch(e) {
+console.error('error caught: ' + e);
+d.reject(e);
+}
+return d.promise;
+}
+
+function DeploymentTool() {
+
+}
+
+/**
+ * Determines whether the requested version of the deployment tool is 
available.
+ * @returns True if the deployment tool can function; false if not.
+ */
+DeploymentTool.prototype.isAvailable = function() {
+return fs.existsSync(this.path);
+};
+
+/** 
+ * Enumerates devices attached to the development machine.
+ * @returns A Promise for an array of objects, which should be passed into 
other functions to represent the device.
+ * @remarks The returned objects contain 'index', 'name', and 'type' 
properties indicating basic information about them, 
+ *which is limited to the information provided by the system.  Other 
properties may also be included, but they are 
+ *specific to the deployment tool which created them and are likely 
used internally.
+ */
+DeploymentTool.prototype.enumerateDevices = function() {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Installs an app package to the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param pathToAppxPackage The path to the .appx package to install.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ * @shouldLaunch Indicates whether to launch the app after installing it.
+ * @shouldUpdate Indicates whether to explicitly update the app, or 
install clean.
+ * @pin Optionally provided if the device requires pairing for deployment.
+ */
+DeploymentTool.prototype.installAppPackage = function(pathToAppxPackage, 
targetDevice, shouldLaunch, shouldUpdate, pin) {
+return Q.reject('May not use DeploymentTool directly, instead get an 
instance from DeploymentTool.getDeploymentTool()');
+};
+
+/**
+ * Uninstalls an app package from the target device.
+ * @returns A Promise which will be fulfilled on success or rejected on 
failure.
+ * @param packageInfo The app package name or Phone GUID representing the 
app.
+ * @param targetDevice An object returned from a successful call to 
enumerateDevices.
+ */
+DeploymentTool.prototype.uninstallAppPackage = function(packageInfo, 
targetDevice) {
+return Q.reject('Unable to uninstall any app packages because that 
feature is not supported.');
+};
+
+/**
+ * Gets a list of installed apps on the target device.  This function is 
not supported for 
+ * Windows Phone 8.1.
+ * @param targetDevice {Object} An object returned from a successf

[GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...

2015-07-06 Thread robpaveza
GitHub user robpaveza opened a pull request:

https://github.com/apache/cordova-windows/pull/96

CB-9283: Add support for Windows 10 WinAppDeployCmd

The Windows 10 SDK uses a new "WinAppDeployCmd" utility for deployment to 
phones.  This change abstracts out the differences between Windows 8.1 and 
Windows 10 and the substantially different utility interfaces and factors that 
out into a separate deployment module.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/MSOpenTech/cordova-windows CB-9283

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/cordova-windows/pull/96.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #96


commit 53a6b629ae3f7b646136527ef1e8ca3a83e76954
Author: Rob Paveza 
Date:   2015-07-06T20:20:48Z

CB-9283: Add support for Windows 10 WinAppDeployCmd for deployment to
remote devices.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org