Skip to content

Commit

Permalink
Install NPM asset dependencies locally instead of globally
Browse files Browse the repository at this point in the history
Use NPM's package.json to accomplish this.
Had to change version schemes to be semver-compatible.
  • Loading branch information
malept committed Jul 4, 2014
1 parent 3b58db1 commit 6246b0d
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ gmusicprocurator/static/vendor/*
.webassets-cache
build
dist
node_modules
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ python:
env:
- NO_FRONTEND=1
install:
- if [[ -z "$NO_FRONTEND" ]]; then sudo add-apt-repository --yes ppa:chris-lea/node.js; fi
- if [[ -z "$NO_FRONTEND" ]]; then sudo apt-get update -qq; fi
- if [[ -z "$NO_FRONTEND" ]]; then sudo apt-get install nodejs; fi
- if [[ -z "$NO_FRONTEND" ]]; then sudo npm install -g coffee-script uglify-js browserify coffeeify browserify-shim coffeelint csslint bower; fi
- if [[ -z "$NO_FRONTEND" ]]; then sudo add-apt-repository --yes ppa:chris-lea/node.js; sudo apt-get update -qq; sudo apt-get install nodejs; npm install -g coffeelint csslint; npm install; fi
- if [[ -z "$NO_FRONTEND" ]]; then gem install scss-lint; fi
- if [[ -z "$NO_FRONTEND" ]]; then bower install; fi
- if [[ -z "$NO_PYTHON" ]]; then export REQ_TXT=requirements/dev.txt; else export REQ_TXT=requirements.txt; fi; pip install -r "$REQ_TXT"
Expand Down
11 changes: 4 additions & 7 deletions INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ Frontend
* Either libsass-python_ or the reference implementation of Sass_ (which
requires Ruby)
* Node.js + NPM
* Bower (``npm install -g bower``)
* CoffeeScript (``npm install -g coffee-script``)
* UglifyJS2 (``npm install -g uglify-js``)
* Browserify and related dependencies (``npm install -g browserify coffeeify browserify-shim``)

.. _libsass-python: http://dahlia.kr/libsass-python/
.. _Sass: http://sass-lang.com/
Expand Down Expand Up @@ -113,9 +109,10 @@ with the proper playlist ID.
Frontend-specific
~~~~~~~~~~~~~~~~~

If you want to run the frontend as well, run the following before you start the
server:
If you want to run the frontend as well, run the following before starting
the server:

.. code-block:: shell-session
(venv)user@host:gmusicprocurator$ bower install -p
(venv)user@host:gmusicprocurator$ npm install
(venv)user@host:gmusicprocurator$ node_modules/.bin/bower install -p
6 changes: 3 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "gmusicprocurator",
"version": "1.0dev4",
"version": "0.5.0",
"homepage": "https://gmusicprocurator.readthedocs.org/",
"authors": [
"Mark Lee"
],
"description": "Google Music proxy/frontend for streaming",
"license": "GPL3+",
"license": "GPL-3.0+",
"private": true,
"ignore": [
"**/.*",
Expand All @@ -27,7 +27,7 @@
"lodash": "~2.4.1",
"backbone.localstorage": "~1.1.7",
"html5-desktop-notifications": "malept/HTML5-Desktop-Notifications#firefox-mobile",
"aurora.js": "malept/aurora.js#global-browserify",
"aurora.js": "audiocogs/aurora.js#~0.4.2",
"mp3.js": "audiocogs/mp3.js#~0.1.0"
}
}
3 changes: 3 additions & 0 deletions gmusicprocurator/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
if app.config['GMP_FRONTEND_ENABLED']:
from flask.ext.assets import Environment
assets = Environment(app)
os.environ['PATH'] = \
'{}/.bin:{}'.format(app.config['GMP_NODE_MODULES_DIR'],
os.environ['PATH'])
else:
assets = None

Expand Down
3 changes: 1 addition & 2 deletions gmusicprocurator/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ def setup(self):
'{{output}}',
]
if self.coffeescript:
self.argv.extend(['--transform', 'coffeeify',
'--extension', '.coffee'])
self.argv.extend(['--extension', '.coffee'])
if self.extra_args:
self.argv.extend(self.extra_args)

Expand Down
12 changes: 12 additions & 0 deletions gmusicprocurator/default_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
frontend are not loaded. For example, ``GET / HTTP/1.1`` will return
a ``404``.
.. attribute:: GMP_NODE_MODULES_DIR
Defaults to the ``node_modules`` directory in the top-level directory of
the repository. This is the path where all of the Node-based asset
utilities are installed.
.. attribute:: GMP_SONG_FILTERS
A tuple of callable filters used on streaming MP3 data. By default, it
Expand Down Expand Up @@ -74,6 +80,12 @@ def (str song_id, io.BytesIO data) -> io.BytesIO

GMP_FRONTEND_ENABLED = True

dirname = os.path.dirname
default_node_modules_dir = os.path.join(dirname(dirname(__file__)),
'node_modules')
GMP_NODE_MODULES_DIR = os.environ.get('GMP_NODE_MODULES_DIR',
default_node_modules_dir)

GMP_SONG_FILTERS = (
'add_id3_tags_to_mp3',
)
Expand Down
27 changes: 27 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "gmusicprocurator",
"description": "Google Music proxy/frontend for streaming",
"version": "0.5.0",
"homepage": "https://gmusicprocurator.readthedocs.org/",
"repository": {
"type": "git",
"url": "https://github.com/malept/gmusicprocurator.git"
},
"bugs": {
"url": "https://github.com/malept/gmusicprocurator/issues"
},
"author": {
"name": "Mark Lee",
"url": "https://malept.com/"
},
"license": "GPL-3.0+",
"dependencies": {
"bower": "1.x",
"browserify": "4.x",
"browserify-shim": "3.x",
"coffee-script": "1.x",
"coffeeify": "0.6.x",
"uglify-js": "2.x"
},
"private": true
}
13 changes: 5 additions & 8 deletions salt/roots/assets.sls
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
assets-deps:
npm.installed:
- names:
- bower
- browserify
- browserify-shim
- coffeeify
- coffee-script
- uglify-js
npm.bootstrap:
- name: /vagrant
- user: vagrant
- require:
- pkg: nodejs
gem.installed:
- names:
- sass

0 comments on commit 6246b0d

Please sign in to comment.