cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-8226) 'cordova platform add' should look into config.xml for correct engine element when no version is provided
Date Tue, 06 Jan 2015 03:26:34 GMT

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

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

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

    https://github.com/apache/cordova-lib/pull/140#discussion_r22506476
  
    --- Diff: cordova-lib/src/cordova/platform.js ---
    @@ -78,62 +76,119 @@ function add(hooksRunner, projectRoot, targets, opts) {
         }
     
         return hooksRunner.fire('before_platform_add', opts)
    -    .then(function() {
    -        return promiseutil.Q_chainmap(targets, function(t) {
    -            // For each platform, download it and call its "create" script.
    -
    -            var p;  // The promise to be returned by this function.
    -            var platform = t.split('@')[0];
    -            // If t is not a platform or platform@version, it must be a dir.
    -            // In this case get platform name from package.json in that dir and
    -            // skip lazy-load.
    -            if( !(platform in platforms) ) {
    -                var pPath = path.resolve(t);
    -                var pkg;
    -                // Prep the message in advance, we might need it in several places.
    -                msg = 'The provided path does not seem to contain a ' +
    -                      'Cordova platform: ' + t;
    -                try {
    -                    pkg = require(path.join(pPath, 'package'));
    -                } catch(e) {
    -                    throw new CordovaError(msg + '\n' + e.message);
    -                }
    -                if ( !pkg || !pkg.name ) {
    -                    throw new CordovaError(msg);
    -                }
    -                // Package names for Cordova platforms look like "cordova-ios".
    -                var nameParts = pkg.name.split('-');
    -                var name = nameParts[1];
    -                if (name == 'amazon') {
    -                    name = 'amazon-fireos';
    -                }
    -                if( !platforms[name] ) {
    -                    throw new CordovaError(msg);
    -                }
    -                platform = name;
    +	.then(function () {
    +	    return promiseutil.Q_chainmap(targets, function (target) {
    +
    +	        // For each platform, download it and call its "create" script.
    +	        var parts = target.split('@');
    +	        var platform = parts[0];
    +	        var version = parts[1];
    +
    +	        return Q.when().then(function () {
    +	            if (!(platform in platforms)) {
    +	                return getPlatformDetailsFromDir(target);
    +	            }
    +	            else {
    +	                if (!version) {
    +	                    events.emit('verbose', 'No version supplied. Retrieving version
from config.xml...');
    +	                }
    +	                version = version || getVersionFromConfigFile(platform, cfg);
    +	                if (version) {
    +	                    version = version.replace(/^file:\/\//, ''); // If version is a
folder, remove the 'file://' prefix from it.
    --- End diff --
    
    Couldn't figure out how to reply to old comment, so creating a new one again :S.
    
    If it starts with "file:", then it's a URL (with file: being the scheme). If it has any
`:`s, or spaces, then it's a malformed URL that most parses allow. However, we really should
support properly formatted URLs by using the url.parse method.


> 'cordova platform add' should look into config.xml for correct engine element when no
version is provided
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: CB-8226
>                 URL: https://issues.apache.org/jira/browse/CB-8226
>             Project: Apache Cordova
>          Issue Type: Improvement
>          Components: CordovaLib
>    Affects Versions: Master
>            Reporter: Omar Mefire
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> When the 'cordova platform add' command is executed with no version specified (e.g: user
runs ‘cordova platform add android’ instead of ‘cordova platform add android@3.6.4’),
cordova-lib should look at the config.xml file for the correct <engine> element and
use its version. It should default to using the pinned version if there is no corresponding
<engine> element in the config.xml file. 
> For example, if the user enters : 'cordova platform add android' and the config.xml file
contains this entry: <cdv:engine id="android" version="file://C:/folder/to/android/platform"
/>, We should use the specified folder's bin/create scripts to add the android platform,
not the default version.
> The engine element in config.xml could be one of the following form :
> 1- <cdv:engine id="android" version="3.6.0" />
> 2- <cdv:engine id="android" version="file://C:/folder/to/android/platform" />



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

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


Mime
View raw message