Yeoman install generates two copies of components directory #622

Closed
jonjaques opened this Issue Oct 12, 2012 · 30 comments

Comments

Projects
None yet

Hello there. I'm new to the Yeoman/Bower ecosystem, so please excuse my ignorance if I'm off base here.

Are there supposed to be two copies of the components directory (one in app/ and one in the root)?

Test case:

yeoman init

[?] Would you like to include Twitter Bootstrap for Compass? (Y/n) y
[?] Would you like to include the Twitter Bootstrap plugins? (Y/n) y
[?] Would you like to include RequireJS (for AMD support)? (Y/n) y
[?] Would you like to support writing ECMAScript 6 modules? (Y/n) n

...

After app is scaffolded yeoman install backbone (or any other package) yields two components directories. Isn't this sort of redundant?

dnlek commented Oct 15, 2012

+1 agree. Also "yeoman init" + "yeoman install jquery" ends up with three jquery versions ./components, app/components, and app/scripts/libs/vendor... is that ok?

Contributor

btford commented Oct 16, 2012

The jQuery files created by yeoman init will probably be removed in favor of hooking into yeoman install when you run yeoman init. I think it's just the case that no one has gotten around to refactoring this yet.

I'm also seeing the two component directories, which I think is weird.

Owner

addyosmani commented Oct 16, 2012

Bower installs components to root, however because Yeoman serves up the different versions of your application via sub-directories inside root, we're unable to reliably access ../../ etc. at a localhost level. To work around this issue, we clone/sync the Bower components directory. To the best of my knowledge, if we were to delete the original Bower components directory its commands wouldn't take note of our custom location. We can try handling this better in the future.

Contributor

btford commented Oct 16, 2012

Is there any reason we can't temporarily change the working directory to app/scripts/ when running Bower tasks?

coolxeo commented Oct 27, 2012

+1

When trying to uninstall a component yeoman uninstall jquery, the root version (/components/jquery) is deleted, however, the cloned copy in /app/components/jquery is still present.

yderidde commented Nov 5, 2012

What is the purpose of the "main" property in component.json ? I was expecting that yeoman would only copy the files enumerated in the main property would ino /app/scripts/vendor.
The problem i see now, is that the entire repo is copied into app/scripts/vendor and when doing yeoman build, everything is copied over in dist/ .. while I'm expecting my distribution package to only contains the necessary files ... and not everything.

Whats the workaround ? what is the expected behaviour ?

Owner

sindresorhus commented Nov 5, 2012

What is the purpose of the "main" property in component.json ? I was expecting that yeoman would only copy the files enumerated in the main property would ino /app/scripts/vendor.

The problem with the main property is that it its usage isn't really defined yet. Lot of components are missing it, some use a string, some use array.

twitter/bower#46

Owner

addyosmani commented Nov 14, 2012

Let's investigate this to see if we can avoid the duplicate directories. If Bower properly handles just setting a custom directory now we should be able to get around the issue of it just installing to a path our server can't access.

Owner

addyosmani commented Nov 14, 2012

Nice to have for 1.0, moving to 1.1 unless someone gets bandwidth to work on this.

sindresorhus was assigned Nov 14, 2012

Contributor

sleeper commented Nov 14, 2012

Just looking at bower page, on the Configuration related part, it seems that the components dir is configurable, at least using a .bowercrc file (it can be at project level or user level).

What about having yeoman create a .bowerrc in the project directory with something like:

{
  "directory" : "components"
}

I'll try to give it a run tonight ;)

Contributor

sleeper commented Nov 15, 2012

OK, I give it a small run ... Let me first re-state what I understand of the "process" and then what I do propose.

If I do understand clearly, currently when we're performing a yeoman install jquery, yeoman delegates the retrieval and installation of jquery.
The default configuration for bower is to install stuff in a components subdirectory of the directory when it is launched (in our case in ./components).

As when we're launching for example the server, the application has only a view on app and subdirectories, yeoman copies ./components into app/components (by default but changeable through bower.dir config). This is not what we want as it complicates the processing, doubles the installed packages and leads to confusion.

What would be great:

  1. Have yeoman install jquery install jquery in, for example, app/scripts/vendor/components, and have bower manage this directory (i.e in case of update for example)
  2. Have this in a manner that would work even if yeoman is no more used (i.e. if only plain bower is used) in order to be inline with the new specifications

So, the small experiment I did is quite simple:

  1. Create a .bowerrc file in the project directory, with a content like:
{
  "directory" : "app/scripts/vendor/components"
}
  1. Run yeoman install jquery .. jquery is installed in the app/scripts/vendor/components directory
  2. If you use plain bower, it will update packages in this directory

So what is needed, and what I do propose:

  1. As part of the init action, have yeoman create a .bowerrc file and populate it according to the location we want to put our bower managed files (can perhaps even be configurable)
  2. Remove all the stuff used to synchronize the bower's components and the yeoman components cache
  3. Update all generators to remove the bower.dir configuration describing the location of the yeoman's cache

@sindresorhus @addyosmani Does it seems correct ? If yes, I'll prepare a PR (well a set of PR considering the generators need to be touched ;))

Owner

sindresorhus commented Nov 15, 2012

Since components can be more than just scripts (like styles, templates, etc) I feel like we should have a generic app/components folder where we can put everything component related.

@addyosmani ?

Contributor

sleeper commented Nov 15, 2012

Yep, right, I forgot this.
Except for the location, does the process/idea seem fine ?

Owner

sindresorhus commented Nov 15, 2012

Yes, I agree with the idea.

sleeper referenced this issue in yeoman/generator Nov 18, 2012

Merged

Fixing yeoman/yeoman#622 #126

@sindresorhus sindresorhus added a commit to yeoman/generator that referenced this issue Nov 19, 2012

@sindresorhus sindresorhus Merge pull request #126 from sleeper/generate_bowerrc e47bf1d

sleeper closed this in 497a6b6 Nov 20, 2012

@sindresorhus sindresorhus added a commit that referenced this issue Nov 20, 2012

@sindresorhus sindresorhus Merge pull request #726 from sleeper/fixing_622
Removes the process of copying components/*. Fixes #622
9274aa6

@sindresorhus sindresorhus pushed a commit to yeoman/generator-chromeapp that referenced this issue Nov 21, 2012

@sleeper sleeper Fixing yeoman/yeoman#622 d3a3414

@sindresorhus sindresorhus pushed a commit to yeoman/generator-angular that referenced this issue Nov 21, 2012

@sleeper sleeper Fixing yeoman/yeoman#622 fed5b68

@sindresorhus sindresorhus pushed a commit to deprecate/generator-bbb that referenced this issue Nov 21, 2012

@sleeper sleeper Fixing yeoman/yeoman#622 99eba21

@sindresorhus sindresorhus pushed a commit to yeoman/generator-webapp_DEPRECATED that referenced this issue Nov 21, 2012

@sleeper sleeper Fixing yeoman/yeoman#622 45b4f1c
yeoman init quickstart 

doesn't generate the .bowerrc file.

but

yeoman init

does

Also this might be a windows problem,

but if I run

yeoman install backbone

from a location other than my project home directory where .bowerrc lives then the component will get installed in the root project directory. /components/..

otherwise if I run the command from the project home directory where .bowerrc lives then the component will get installed under /app/components/..

installing the .bowerrc in my

USER_HOME

directory seemed to fix the problem. But now that is a global setting for all my bower components. Not a big deal but it would be nice if

yeoman install backbone

would install to

/app/components/backbone

no matter where I was under the project. Wish list.

Contributor

sleeper commented Nov 27, 2012

OK, so basically there are 2 issues here:

  1. .bowerrc is not always generated: my bad, I forget to add it to the other generators . I cannot fix it right now, as @sindresorhus is reworking and splitting the generators
  2. .bowerrc created in project "root" directory is not always taken into account when you're in subdirectory. Could you please open a dedicated issue on this one ?

sleeper reopened this Nov 27, 2012

cobbweb commented Nov 28, 2012

FYI, I just did yeoman init and it didn't generate .bowerrc for me.

Contributor

sleeper commented Nov 29, 2012

Which version of yeoman are you using ?

cobbweb commented Nov 29, 2012

All sorted, had some trouble updating generators but I deleted node_modules and re-ran npm install and it seem to fix it. :/

@sleeper sleeper added a commit to deprecate/generator-ember that referenced this issue Dec 10, 2012

@sleeper sleeper Fixing yeoman/yeoman#622 24f19ef

0.9.6 and I didn't get a .bowerrc on yeoman init

I manually added a .bowerrc with:

{ "directory" : "app/components", "json" : "component.json" }

...but yeoman install still fails with cp: no such file or directory: components/*
bower install works fine.

Contributor

sleeper commented Dec 13, 2012

Yes ... part of the implementation is in yeoman, the other part in generators ... Not sure it is included in 0.9.6, as we've exploded the generators in many different repository/npm modules for the next version ...

Owner

sindresorhus commented Dec 13, 2012

0.9.6 only disables automatic update from 0.9.5.

As @timkelty said, the latest version of Yeoman (0.9.6) still isn't creating a .bowerrc file on yeoman init.

Manually creating one end saving the following:

{
    "directory" : "app/components",
    "json" : "component.json"
}

Runs fine with bower install, but yields the following error when using yeoman install:

cp: no such file or directory: components/*

Contributor

sleeper commented Jan 18, 2013

Yes, 0.9.6 is basically 1 commit away from 0.9.5, and thus not including this development.
It will be in 1.0

Would love to see this issue fixed!

Contributor

sleeper commented Jan 24, 2013

It is .. but you do not see it ;) Will be part of 1.0 ;)

Thanks for fixing this issue!

@TimvdEijnden TimvdEijnden pushed a commit to TimvdEijnden/generator-webapp_requirejs that referenced this issue Jan 29, 2014

@sleeper sleeper Fixing yeoman/yeoman#622 8c272cc

@sleeper sleeper added a commit that referenced this issue Apr 24, 2015

@sleeper sleeper Should fix #622 632327d

@sindresorhus sindresorhus added a commit that referenced this issue Apr 24, 2015

@sindresorhus sindresorhus Merge pull request #726 from sleeper/fixing_622
Removes the process of copying components/*. Fixes #622
4203d59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment