[ 
https://issues.apache.org/jira/browse/CB-9235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14615975#comment-14615975
 ] 

ASF GitHub Bot commented on CB-9235:
------------------------------------

Github user robpaveza commented on a diff in the pull request:

    https://github.com/apache/cordova-windows/pull/92#discussion_r33998489
  
    --- Diff: bin/lib/check_reqs.js ---
    @@ -19,15 +19,226 @@
     
     /*jshint node:true*/
     
    -var Q     = require('Q');
    +var Q     = require('q');
    +var os    = require('os');
    +var path  = require('path');
    +var shell = require('shelljs');
     
    -var MSBuildTools;
    +var ConfigParser, MSBuildTools, Version, exec;
     try {
    +    ConfigParser = require('../../template/cordova/lib/ConfigParser');
         MSBuildTools = require('../../template/cordova/lib/MSBuildTools');
    +    exec = require('../../template/cordova/lib/exec');
    +    Version = require('../../template/cordova/lib/Version');
     } catch (ex) {
         // If previous import fails, we're probably running this script
         // from installed platform and the module location is different.
    +    ConfigParser = require('./ConfigParser');
         MSBuildTools = require('./MSBuildTools');
    +    exec = require('./exec');
    +    Version = require('./Version');
    +}
    +
    +// The constant for VS2013 Upd2 PackageVersion. See MSDN for
    +// reference: 
https://msdn.microsoft.com/en-us/library/bb164659(v=vs.120).aspx
    +var VS2013_UPDATE2_RC = new Version(12, 0, 30324);
    +var REQUIRED_VERSIONS = {
    +    '8.0': {
    +        os: '6.1',
    +        msbuild: '11.0',
    +        visualstudio: '11.0',
    +        windowssdk: '8.0'
    +    },
    +    '8.1': {
    +        os: '6.2',
    +        msbuild: '12.0',
    +        visualstudio: '12.0',
    +        windowssdk: '8.1',
    +        phonesdk: '8.1'
    +    },
    +    '10.0': {
    +        os: '6.2',
    +        msbuild: '14.0',
    +        visualstudio: '14.0',
    +        windowssdk: '10.0',
    +        phonesdk: '10.0'
    +    }
    +};
    +
    +function getMinimalRequiredVersionFor (requirement) {
    +    var config = new ConfigParser(path.join(__dirname, '..', '..', 
'config.xml'));
    +
    +    var windowsTargetVersion = config.getWindowsTargetVersion();
    +    var windowsPhoneTargetVersion = config.getWindowsPhoneTargetVersion();
    +    var windowsReqVersion = 
Version.tryParse(REQUIRED_VERSIONS[windowsTargetVersion][requirement]);
    +    var phoneReqVersion = 
Version.tryParse(REQUIRED_VERSIONS[windowsPhoneTargetVersion][requirement]);
    +
    +    // If we're searching for Windows SDK, we're not
    +    // interested in Phone's version and and vice versa.
    +    if (requirement === 'windowssdk') return windowsReqVersion;
    +    if (requirement === 'phonesdk') return phoneReqVersion;
    +
    +    // If both windowsReqVersion and phoneReqVersion is valid Versions, 
choose the max one
    +    if (windowsReqVersion && phoneReqVersion) {
    +        return windowsReqVersion.gt(phoneReqVersion) ?
    +            windowsReqVersion :
    +            phoneReqVersion;
    +    }
    +
    +    // Otherwise return that one which is defined and valid
    +    return windowsReqVersion || phoneReqVersion;
    +}
    +
    +function getHighestAppropriateVersion (versions, requiredVersion) {
    +    return versions.map(function (version) {
    +        return Version.tryParse(version);
    +    })
    +    .sort(Version.comparer)
    +    .filter(function (toolVersion) {
    +        return toolVersion.gte(requiredVersion);
    +    })[0];
    +}
    +
    +/**
    + * Return Version object for current Windows version. User 'ver' binary or
    + *   os.release() in case of errors.
    + *
    + * @return  {Version}  Version information for current OS.
    + */
    +function getWindowsVersion() {
    +    return exec('ver').then(function (output) {
    +        var match = /\[Version (.*)\]\s*$/.exec(output);
    +        return Version.fromString(match[1]);
    +    }).fail(function () {
    +        return Version.fromString(os.release());
    +    });
    +}
    +
    +/**
    + * Lists all Visual Studio versions insalled. For VS 2013 if it present, 
alao
    + *   checks if Update 2 is installed.
    + *
    + * @return  {String[]}  List of installed Visual Studio versions.
    + */
    +function getInstalledVSVersions() {
    +    // Query all keys with Install value equal to 1, then filter out
    +    // those, which are not related to VS itself
    +    return exec('reg query 
HKLM\\SOFTWARE\\Microsoft\\DevDiv\\vs\\Servicing /s /v Install /f 1 /d /e 
/reg:32')
    +    .fail(function () { return ''; })
    +    .then(function (output) {
    +        return output.split('\n')
    +        .reduce(function (installedVersions, line) {
    +            var match = 
/(\d+\.\d+)\\(ultimate|professional|premium|community)/.exec(line);
    +            if (match && match[1] && installedVersions.indexOf(match[1]) 
=== -1)
    +                installedVersions.push(match[1]);
    +            return installedVersions;
    +        }, []);
    +    })
    +    .then(function (installedVersions) {
    +        // If there is no VS2013 installed, the we have nothing to do
    +        if (installedVersions.indexOf('12.0') === -1) return 
installedVersions;
    +
    +        // special case for VS 2013. We need to check if VS2013 update 2 
is installed
    +        return exec('reg query 
"HKLM\\SOFTWARE\\Microsoft\\Updates\\Microsoft Visual Studio' +
    +            ' 2013\\vsupdate_KB2829760" /v PackageVersion /reg:32')
    +        .then(function (output) {
    +            var updateVer = 
Version.fromString(/PackageVersion\s+REG_SZ\s+(.*)/i.exec(output)[1]);
    +            // if update version is lover than Update2, reject the promise
    +            if (VS2013_UPDATE2_RC.gte(updateVer)) return Q.reject();
    +            return installedVersions;
    +        })
    +        .fail(function () {
    +            // if we got any errors on previous steps, we're assuming that
    +            // required VS update is not installed.
    +            installedVersions.splice(installedVersions.indexOf('12.0'));
    +            return installedVersions;
    +        });
    +    });
    +}
    +
    +/**
    + * Gets list of installed Windows SDKs
    + *
    + * @return  {Version[]}  List of installed SDKs' versions
    + */
    +function getInstalledWindowsSdks () {
    +    var installedSdks = [];
    +    return exec('reg query "HKLM\\SOFTWARE\\Microsoft\\Microsoft 
SDKs\\Windows" /s /v InstallationFolder /reg:32')
    +    .fail(function () { return ''; })
    +    .then(function (output) {
    +        var re = /\\Microsoft 
SDKs\\Windows\\v(\d+\.\d+)\s*InstallationFolder\s+REG_SZ\s+(.*)/gim;
    +        var match;
    +        while ((match = re.exec(output))){
    +            var sdkPath = match[2];
    +            // Verify that SDKs is really installed by checking 
SDKManifest file at SDK root
    +            if (shell.test('-e', path.join(sdkPath, 'SDKManifest.xml'))) {
    +                installedSdks.push(Version.tryParse(match[1]));
    +            }
    +        }
    +    })
    +    .thenResolve(installedSdks);
    +}
    +
    +/**
    + * Gets list of installed Windows Phone SDKs. Separately searches for 8.1 
Phone
    + *   SDK and Windows 10 SDK, because the latter is needed for both Windows 
and
    + *   Windows Phone applications.
    + *
    + * @return  {Version[]}  List of installed Phone SDKs' versions.
    + */
    +function getInstalledPhoneSdks () {
    +    var installedSdks = [];
    +    return exec('reg query "HKLM\\SOFTWARE\\Microsoft\\Microsoft 
SDKs\\Windows Phone\\v8.1" /v InstallationFolder /reg:32')
    +    .fail(function () { return ''; })
    +    .then(function (output) {
    +        var match = /\\Microsoft SDKs\\Windows 
Phone\\v(\d+\.\d+)\s*InstallationFolder\s+REG_SZ\s+(.*)/gim.exec(output);
    +        if (match && shell.test('-e', path.join(match[2], 
'SDKManifest.xml'))) {
    +            installedSdks.push(Version.tryParse(match[1]));
    +        }
    +    })
    +    .then(function () {
    +        return exec('reg query "HKLM\\SOFTWARE\\Microsoft\\Microsoft 
SDKs\\Windows\\v10.0" /v InstallationFolder /reg:32');
    +    })
    +    .fail(function () { return ''; })
    +    .then(function (output) {
    +        var match = /\\Microsoft 
SDKs\\Windows\\v(\d+\.\d+)\s*InstallationFolder\s+REG_SZ\s+(.*)/gim.exec(output);
    +        if (match && shell.test('-e', path.join(match[2], 
'SDKManifest.xml'))) {
    +            installedSdks.push(Version.tryParse(match[1]));
    +        }
    +    })
    +    .thenResolve(installedSdks);
    +}
    +
    +/**
    + * Shortens version string or Version object by leaving only first two 
segments
    + *   (major and minor).
    + * @param   {String|Version}  version  The version identifier. Either 
Version
    + *   object or string that looks like "12.5.6"
    + * @return  {String}          Shortened version, or undefined if provided
    + *   parameter is not a valid version
    + */
    +function shortenVersion (version) {
    +    return /^(\d+(?:\.\d+)?)/.exec(version.toString())[1];
    +}
    +
    +function mapWindowsVersionToName(version) {
    +    var map = {
    +        '6.2': 'Windows 8',
    +        '6.3': 'Windows 8.1',
    +        '10.0': 'Windows 10'
    +    };
    +    var majorMinor = shortenVersion(version);
    +    return map[majorMinor];
    +}
    +
    +function mapVSVersionToName(version) {
    +    var map = {
    --- End diff --
    
    You might suggest "2012 Express for Windows", "2013 Express for Windows", 
"2015 Community" to be specific.  Our documentation is incorrectly specific 
because it says "Professional."


> Enhance check_reqs for Windows to include more checks
> -----------------------------------------------------
>
>                 Key: CB-9235
>                 URL: https://issues.apache.org/jira/browse/CB-9235
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Windows
>    Affects Versions: 4.0.0
>            Reporter: Vladimir Kotikov
>            Assignee: Vladimir Kotikov
>
> For Windows the requirements will vary depending on the version of Windows 
> you are targeting:
> _8.1:_
> * MSBuild
> * VS 2013
> _Phone:_
> * 8.1 Phone support – at least VS 2013 Update 2.
> * Phone SDK
> _Win 10:_
> * UAP Windows SDK
> * VS 2015 RC+
> We'll need to enhance check_reqs for Windows with more checks based on the 
> windows-target-version and windows-phone-target-version. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to