cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muratsu <...@git.apache.org>
Subject [GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...
Date Tue, 07 Jul 2015 23:18:08 GMT
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 successful call to enumerateDevices.
    + * @returns A Promise for an array of app names.
    + */
    +DeploymentTool.prototype.getInstalledApps = function(targetDevice) {
    +    return Q.reject('Unable to get installed apps because that feature is not supported.');
    +};
    +
    +/**
    + * Launches an app on the target device.  This function is not supported for Windows
10.
    + * @param packageInfo {String} The app package name or Phone GUID representing the app.
    + * @param targetDevice {Object} An object returned from a successful call to enumerateDevices.
    + * @returns A Promise for when the app is launched.
    + */
    +DeploymentTool.prototype.launchApp = function(packageInfo, targetDevice) {
    +    return Q.reject('Unable to launch an app because that feature is not supported.');
    +};
    +
    +/**
    + * Gets a DeploymentTool for use in 
    + */
    +DeploymentTool.getDeploymentTool = function(targetOsVersion) {
    +    if (targetOsVersion === '8.0' || targetOsVersion === '8.1') {
    +        return new AppDeployCmdTool(targetOsVersion);
    +    }
    +    else {
    +        return new WinAppDeployCmdTool(targetOsVersion);
    +    }
    +};
    +
    +// DeviceInfo is an opaque object passed to install/uninstall.
    +// Implementations of DeploymentTool can populate it with any additional
    +//  information required for accessing them.
    +function DeviceInfo(deviceIndex, deviceName, deviceType) {
    +    this.index = deviceIndex;
    +    this.name = deviceName;
    +    this.type = deviceType;
    +}
    +
    +DeviceInfo.prototype.toString = function() {
    +    return this.index + '. ' + this.name + ' (' + this.type + ')';
    +};
    +
    +function AppDeployCmdTool(targetOsVersion) {
    +    if (!(this instanceof AppDeployCmdTool))
    +        throw new ReferenceError('Only create an AppDeployCmdTool as an instance object.');
    +
    +    DeploymentTool.call(this);
    --- End diff --
    
    Is this call required?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message