harvesthq / chosen

Deprecated - Chosen is a library for making long, unwieldy select boxes more friendly.

Home Page:http://harvesthq.github.io/chosen/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Include compiled JS in repo for bower

aq1018 opened this issue · comments

When installing chosen using bower:

bower install chosen

It fetches from this repo directly, and since there is no compiled JS file, it is currently not usable with bower.

Hm, they just got removed recently (#1316). A solution would be to set bower to use the release zip, but as far I can see there is no possibility to link to the actual release zip in the bower package definition.

It looks like we can create a bower.json file and set main to be the most recent release's zip file.

https://github.com/bower/bower#defining-a-package

@kenearley I'd just tried that and it appears that setting main to the most recent release does not work..

bummer 😦

It looks like they are working on ways to handle compiled files in Bower. We may just have to wait until it's implemented. bower/bower#584

This worked for me!

In my bower.json:

"chosen": "https://github.com/harvesthq/chosen/releases/download/v0.12.0/chosen_v0.12.0.zip"

@kenearley @aq1018

I've implemented this plugin to assist with this issue:

https://github.com/walmartlabs/grunt-release-component

As @kyrstenkelly pointed out, you can specify the release zip file in your own project's dependencies in its bower.json file like so:

{
  "name": "my-project",
  "version": "1.0.0",
  "dependencies": {
    "jquery": "1.10.2",
    "chosen": "https://github.com/harvesthq/chosen/releases/download/0.13.0/chosen_v0.13.0.zip"
  }
}

Unfortunately, we cannot specify that zip file in a bower.json file in this project. That means, you can't get it from the command line with bower install chosen.

Although @eastridge's suggestion would work, it feels a bit heavy handed. Especially if the Bower team is working to address this issue.

@kenearley just for context, we might be able to use the github releases "get the zip" feature once there is an API for it as all of our releases our automated. Presently there is no API. Once there is one my helper might be able to go away. I also didn't see any of the issues addressed in the bower re-write, am I missing something? Would love it if you pointed me at any links / docs / discussions for that.

@eastridge There has been some discussion about being able to run a post install script. Also improvements to the registry

Great links! Thanks

On Wed, Jul 17, 2013 at 12:13 PM, Ken Earley notifications@github.comwrote:

@eastridge https://github.com/eastridge There has been some discussion
about being able to run a post install scripthttps://github.com/bower/bower/issues/145#issuecomment-10534589.
Also improvements to the registryhttps://github.com/bower/bower/issues/584


Reply to this email directly or view it on GitHubhttps://github.com//issues/1333#issuecomment-21136968
.

I agree with @eastridge, the best course of action for now is probably simply waiting for either the github to release the new API or bower to improve.

Referring back to @kyrstenkelly 's post. In our case the .js file we wanted in the zip is called "chosen.jquery.js", so we put this in our bower.json before installing:

"chosen.jquery": "https://github.com/harvesthq/chosen/releases/download/1.0.0/chosen_v1.0.0.zip"

Then instead of "bower install chosen", simply run "bower install".

This was the worst workaround to the problem. You guys should provide the compiled js file untill the release api thing is done. Bummer.

And the .zip solution didn't worked either:

λ bower install
bower not-cached    https://github.com/harvesthq/chosen/releases/download/1.0.0/chosen_v1.0.0.zip#*
bower resolve       https://github.com/harvesthq/chosen/releases/download/1.0.0/chosen_v1.0.0.zip#*
bower download      https://github.com/harvesthq/chosen/releases/download/1.0.0/chosen_v1.0.0.zip
bower not-cached    git://github.com/harvesthq/chosen.git#~1.0.0
bower resolve       git://github.com/harvesthq/chosen.git#~1.0.0
bower download      https://github.com/harvesthq/chosen/archive/1.0.0.tar.gz
bower extract       chosen.jquery#* chosen_v1.0.0.zip
bower extract       chosen#~1.0.0 archive.tar.gz
bower resolved      git://github.com/harvesthq/chosen.git#1.0.0
bower EPERM         EPERM, rename 'C:\Users\LUS~1\AppData\Local\Temp\NOTE-Lu¡s\bower\chosen.jquery-8912-HOtqg2'


Stack trace:
Error: EPERM, rename 'C:\Users\LUS~1\AppData\Local\Temp\NOTE-Lu¡s\bower\chosen.jquery-8912-HOtqg2'

Console trace:
Trace
    at StandardRenderer.error (C:\Users\Lu¡s\AppData\Roaming\npm\node_modules\bower\lib\renderers\StandardRende
rer.js:74:17)
    at Logger.updateNotifier.packageName (C:\Users\Lu¡s\AppData\Roaming\npm\node_modules\bower\bin\bower:109:18
)
    at Logger.EventEmitter.emit (events.js:95:17)
    at Logger.emit (C:\Users\Lu¡s\AppData\Roaming\npm\node_modules\bower\node_modules\bower-logger\lib\Logger.j
s:29:39)
    at C:\Users\Lu¡s\AppData\Roaming\npm\node_modules\bower\lib\commands\install.js:27:16
    at _rejected (C:\Users\Lu¡s\AppData\Roaming\npm\node_modules\bower\node_modules\q\q.js:808:24)
    at C:\Users\Lu¡s\AppData\Roaming\npm\node_modules\bower\node_modules\q\q.js:834:30
    at Promise.when (C:\Users\Lu¡s\AppData\Roaming\npm\node_modules\bower\node_modules\q\q.js:1079:31)
    at Promise.promise.promiseDispatch (C:\Users\Lu¡s\AppData\Roaming\npm\node_modules\bower\node_modules\q\q.j
s:752:41)
    at C:\Users\Lu¡s\AppData\Roaming\npm\node_modules\bower\node_modules\q\q.js:574:44

System info:
Bower version: 1.2.8
Node version: 0.10.21
OS: Windows_NT 6.2.9200 x64

@luisrudge we ended up switching to Select2... not for this reason though, for a completely different UI need.

Having 3 different versions of the code in the VCS (coffee source, compiled code, compiled minified code) is insane:

  • nothing ensures that contributors would rebuild it properly each time (meaning that they could be out of sync)
  • approximately 75% of contributions were changing the compiled files rather than the source (even though the contributing documentation was explicitly warning against this)
  • for PRs doing things fully, it would forbid having 2 concurrent mergeable PRs because of conflicts in the minified files
  • PRs were often sending lots of unrelated changes in the compiled code (thus increasing the potential for conflicts in it) because of using a different version of the compiler.

All these are drawbacks of the previous process, which is why we changed it.

On the other hand, e never advocated to support bower, even before removing the compiled code.
And the release API is available since a few months now as well. It is not our fault if bower does not use it while expecting to get files from github.
If you want to have a working bower package, my suggestion is to contact the bower team to see how you can help them to get the support of build assets done.

@andrew-cs i would to, but i think chosen has a cleaner api and it's easier to style too...

@stof well, thanks for pointing me the issues, but i'm sure there is a way to solve that. Maybe you should drop support of coffee script as this is the first barrier someone would face to contribute to this project. This alone would solve this issue too :)

@luisrudge agree with you there, especially about the API! We just had a requirement that at the time only Select2 fulfilled so we switched.

@luisrudge I'm not the lead developer of the project, and CoffeeScript was used before I even started to contribute. So I would not be the one doing such choice.

and it would also require dropping the use of sass for the CSS, which would also increase the maintenance work needed (and remove the CSS customization capabilities for Sass users)

js can't coexist with coffee?

@luisrudge you mean maintaining a JS codebase which would not be the compiled code ? This would be totally insane. Why would we maintain 2 codebases ?

ohhh, sorry.. I miswrote. I want to know why js can't coexist with sass.. Sorry

@luisrudge well, if the goal is to be able to get the files from the repo itself for bower, Sass will cause the same issue for the CSS file than CoffeeScript is causing for the JS file

Oh, right. I agree... Maybe we could investigate how other projects are doing?

so came here wondering why I can't use chosen with bower, and leaving even more confused i.e. I thought the whole point of bower was to solve these sorts of issues

@gaving I also think it should be bower job to fix the issue, which is why we rejected this request, telling to ask the bower team to finally implement the feature

I created a bower package for chosen. Get it with bower install chosen-bower.

The problem is not creating the package, the problem is maintaining.

bower install chosen

As of 1.4.2, Chosen supports bower installs. Read the 1.4.2 release notes for details.