You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Xandor Schiefer (JIRA)" <ji...@apache.org> on 2015/09/22 22:26:04 UTC

[jira] [Comment Edited] (CB-9686) Adding Android platform puts folders in wrong place

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

Xandor Schiefer edited comment on CB-9686 at 9/22/15 8:25 PM:
--------------------------------------------------------------

This bug is not as serious as I first thought.

The pertinent structure of my project is as follows (files & folders irrelevant to this issue removed):

{quote}
.
├── app
....├── config.xml
├── cordova
....├── config.xml
....├── www -> ../www
├── Gruntfile.js
├── package.json
└── www
....├── config.xml
{quote}

The files in the app folder are the 'source' files, which the grunt build script deposits in the www folder. I inherited this project from other developers, and they seem to have mixed Cordova/PhoneGap files with the actual HTML, CSS, & JavaScript inside the app folder.
When I come along and think to keep them separated (as I think one should), this legacy stuff throws off the isCordova and isRootDir functions inside cordova-lib's util.js module.

My issue is a result of legacy muddled file structure and an unfortunate naming convention of what is normally called the dist folder (in this case www).

Removing config.xml from the app (and thus, after running the grunt build script again, also from the www folder) restores the expected behaviour.

The reason it was working for me on OS X is because I created the project on that machine, which means the platform folder existed in the cordova folder, and isRootDir returned 2, which means that isCordova correctly determined the cordova folder to be the Cordova project root folder. I then added platforms and plugins to .gitignore, pushed my changes and checked it out on my Debian machine.

Here the platforms folder doesn't exist yet, so isRootDir returns 1, and isCordova tries the parent dir, for whom isRootDir also returns 1, and then it iterates up to the root of the filesystem. The result is that the most recent value of bestReturnValueSoFar is the incorrect directory.

As you can determine from the comments in that code, the first folder (i.e. the cordova folder, in my case), is supposed to override the other 'hit'. At least, that's what I would assume from "For sure is" inside the same block as the recognition of the cordova folder.

However, a later piece of code says "Might be (or may be under plaforms/)", and that receives the same numerical value as the previous hit, but because of the way isCordova treats such values, the second hit is now considered a better match for the root folder than the first (even though the command was run in a folder that contained a config.xml file...).

Whether that's something that needs to be fixed is up to you.


was (Author: zeorin):
This bug is not as serious as I first thought.

The pertinent structure of my project is as follows (files & folders irrelevant to this issue removed):

{quote}
.
├── app
    ├── config.xml
├── cordova
    ├── config.xml
    ├── www -> ../www
├── Gruntfile.js
├── package.json
└── www
    ├── config.xml
{quote}

The files in the app folder are the 'source' files, which the grunt build script deposits in the www folder. I inherited this project from other developers, and they seem to have mixed Cordova/PhoneGap files with the actual HTML, CSS, & JavaScript inside the app folder.
When I come along and think to keep them separated (as I think one should), this legacy stuff throws off the isCordova and isRootDir functions inside cordova-lib's util.js module.

My issue is a result of legacy muddled file structure and an unfortunate naming convention of what is normally called the dist folder (in this case www).

Removing config.xml from the app (and thus, after running the grunt build script again, also from the www folder) restores the expected behaviour.

The reason it was working for me on OS X is because I created the project on that machine, which means the platform folder existed in the cordova folder, and isRootDir returned 2, which means that isCordova correctly determined the cordova folder to be the Cordova project root folder. I then added platforms and plugins to .gitignore, pushed my changes and checked it out on my Debian machine.

Here the platforms folder doesn't exist yet, so isRootDir returns 1, and isCordova tries the parent dir, for whom isRootDir also returns 1, and then it iterates up to the root of the filesystem. The result is that the most recent value of bestReturnValueSoFar is the incorrect directory.

As you can determine from the comments in that code, the first folder (i.e. the cordova folder, in my case), is supposed to override the other 'hit'. At least, that's what I would assume from "For sure is" inside the same block as the recognition of the cordova folder.

However, a later piece of code says "Might be (or may be under plaforms/)", and that receives the same numerical value as the previous hit, but because of the way isCordova treats such values, the second hit is now considered a better match for the root folder than the first (even though the command was run in a folder that contained a config.xml file...).

Whether that's something that needs to be fixed is up to you.

> Adding Android platform puts folders in wrong place
> ---------------------------------------------------
>
>                 Key: CB-9686
>                 URL: https://issues.apache.org/jira/browse/CB-9686
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android
>         Environment: Debian 8 "Jessie" Stable
> Node v4.1.0
> Npm v3.3.3
> Cordova 5.1.1, 5.3.1 & 5.3.2-dev (I tried different versions)
>            Reporter: Xandor Schiefer
>
> When I run `cordova platform add android`, it adds the platform and plugins folders to the current directory's parent, i.e. it creates `../platforms` and `../plugins` instead of `./platforms` and `./plugins`.
> It also doesn't seem to edit the config.xml file whether I run it with the `--save` flag or without.
> The cordova project folder is in a subdirectory of the git repo's root folder:
> {quote}
> .
> ├── app
> ├── bower_components
> ├── bower.json
> ├── cordova
> ├── Gruntfile.js
> ├── node_modules
> ├── package.json
> └── www
> {quote}
> When I run `cordova platform add android` whilst my working directory is the `cordova` folder, the repo root looks like this:
> {quote}
> .
> ├── app
> ├── bower_components
> ├── bower.json
> ├── cordova
> ├── Gruntfile.js
> ├── node_modules
> ├── package.json
> ├── platforms
> ├── plugins
> └── www
> {quote}
> When I did this on OS X (in that case `cordova platform add ios`), the folders were created as expected (i.e. in the `cordova` folder, not the repo root). Cordova version 5.3.1, Node version 4.1.0 and Npm version 3.3.3 on OS X 10.10.5.



--
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