nvbn / django-bower

Easy way to use bower with your django project
https://django-bower.readthedocs.io/
518 stars 74 forks source link

Allow changing of versions without human interaction #6

Closed graingert closed 8 years ago

graingert commented 10 years ago

In some situations I've needed to downgrade/upgrade versions of bower components but django_bower fails with some dependency issues:

Unable to find a suitable version for jquery, please choose one:
    1) jquery#1.7.1 which resolved to 1.7.1
    2) jquery#2.0.3 which resolved to 2.0.3 and has components as dependants
    3) jquery#>=0.6.0 which resolved to 2.0.3 and has selectize#0.7.7 as dependants

Prefix the choice with ! to persist it to bower.json

[?] Answer: 1

Unable to find a suitable version for mustache, please choose one:
    1) mustache#0.3.1 which resolved to 0.3.1
    2) mustache#0.7.2 which resolved to 0.7.2 and has components as dependants

Prefix the choice with ! to persist it to bower.json

[?] Answer: 1

Unable to find a suitable version for requirejs, please choose one:
    1) requirejs#1.0.2 which resolved to 1.0.2
    2) requirejs#2.1.8 which resolved to 2.1.8 and has components as dependants

Prefix the choice with ! to persist it to bower.json

[?] Answer: 1

It would be nice to always respect the values in BOWER_INSTALLED_APPS.

As a work-around I've been deleting the bower components directory.

googol7 commented 9 years ago

bower resolutions is missing for that purpose:

http://jaketrent.com/post/bower-resolutions/

kupuguy commented 9 years ago

I think it is worth noting on this issue that while django-bower doesn't have explicit support for bower resolutions, the copy of bower that it spawns will respect an existing bower.json if there is one. While not ideal this can provide a usable workaround.

You can use 'manage.py bower init' to interactively create a bower.json file in the BOWER_COMPONENTS_ROOT folder. Answer 'No' to the question 'set currently installed components as dependencies' as these will be listed in Django settings.

Once you have created the bower.json file the '! to persist to bower.json' will update the requirements section of that file.

olivierdalang commented 8 years ago

Hi,

Here I dynamically add the requirements in my module's app.py, so that each module defines it's own js dependencies :

class MyAppConfig(AppConfig):
    name = 'ToolMap'
    def ready(self):
        settings.BOWER_INSTALLED_APPS.extend([
            'ol3=https://github.com/openlayers/ol3/releases/download/v3.16.0/v3.16.0-dist.zip',
            'js-cookie#2.1.0',
            "fontawesome#~4.5.0",
        ])

I think it's much cleaner than defining everything in a central file. But this also means I can't use the bower.json file in BOWER_COMPONENTS_ROOT.

I'd love a BOWER_RESOLUTIONS setting or something like that allowing for non-interactive update of bower dependencies in my case.

Thanks for the great work !