From 3ceda99dca82b5641e8ef4a6d6c9e72bcb6be9f5 Mon Sep 17 00:00:00 2001 From: Nicolas Joyard Date: Thu, 17 Dec 2015 13:23:54 +0100 Subject: [PATCH] Use shell script to install client JS libs --- .bowerrc | 3 --- .gitignore | 1 - .openshift/action_hooks/deploy | 12 +--------- .travis.yml | 7 +++--- README.md | 10 ++------ bin/install_client_deps.sh | 44 ++++++++++++++++++++++++++++++++++ bower.json | 11 --------- docs/development.rst | 38 +++++++---------------------- 8 files changed, 58 insertions(+), 68 deletions(-) delete mode 100644 .bowerrc create mode 100755 bin/install_client_deps.sh delete mode 100644 bower.json diff --git a/.bowerrc b/.bowerrc deleted file mode 100644 index 16ec5d0..0000000 --- a/.bowerrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "directory": "static/libs" -} diff --git a/.gitignore b/.gitignore index e66f78f..f90c6b2 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ core/static/libs/* # libs static/libs -node_modules # settings memopol/config.json diff --git a/.openshift/action_hooks/deploy b/.openshift/action_hooks/deploy index 1529789..d1f7b24 100755 --- a/.openshift/action_hooks/deploy +++ b/.openshift/action_hooks/deploy @@ -19,14 +19,6 @@ pip install -Ue ${OPENSHIFT_REPO_DIR} python ${OPENSHIFT_REPO_DIR}manage.py migrate --noinput -pushd ${OPENSHIFT_DATA_DIR} -if ! [ -d node ]; then - wget https://nodejs.org/dist/v4.2.2/node-v4.2.2-linux-x64.tar.gz - tar xvzf node-v4.2.2-linux-x64.tar.gz - ln -sfn node-v4.2.2-linux-x64 node -fi -popd - pushd ${OPENSHIFT_REPO_DIR} if [ -f ${OPENSHIFT_DATA_DIR}sentry ]; then pip install raven @@ -38,9 +30,7 @@ fi PATH="${OPENSHIFT_DATA_DIR}node/bin:$PATH" HOME=$OPENSHIFT_DATA_DIR CI=true -npm install bower -npm install -node_modules/.bin/bower install +bin/install_client_deps.sh mkdir -p wsgi ./manage.py collectstatic --noinput ./manage.py compress diff --git a/.travis.yml b/.travis.yml index 9f2de1c..c660f9c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,11 +8,10 @@ install: - pip install -e . - pip install flake8 pep8 before_script: -- npm install -g bower -- bower install +- bin/install_client_deps.sh script: -- pep8 . --exclude '*/migrations,docs' --ignore E128 -- flake8 . --exclude '*/migrations,docs' --ignore E128 +- pep8 . --exclude '*/migrations,docs,static' --ignore E128 +- flake8 . --exclude '*/migrations,docs,static' --ignore E128 - django-admin migrate - django-admin update_score deploy: diff --git a/README.md b/README.md index b301fdb..7612d65 100644 --- a/README.md +++ b/README.md @@ -16,14 +16,8 @@ # Create the local db python manage.py migrate - # Some static files - bower install - - # Install node modules - npm install - - # Build static files - node_modules/gulp/bin/gulp.js less + # Install browser libs + bin/install_client_deps.sh # In another terminal (don't forget to activate the venv) ./manage.py runserver diff --git a/bin/install_client_deps.sh b/bin/install_client_deps.sh new file mode 100755 index 0000000..7e420dc --- /dev/null +++ b/bin/install_client_deps.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# +# This script downloads browser client libraries. +# Currently all scripts are downloaded from GitHub. +# +# Versions used may be changed by altering the lines +# starting with 'downloadFromGithub' at the bottom. +# The last argument is expected to be a git ref (ie +# a branch name, tag or commit-ish). +# + +set -e + +DEST=$(dirname $(dirname $0))/static/libs + +# Github download helper +# $1 destination directory name under static/libs +# $2 github repo name (user-or-org/repo) +# $3 ref to use (branch or tag or commit) +function downloadFromGithub() +{ + local dest=$DEST/$1 + local repo=$2 + local ref=$3 + + echo "* Downloading $repo ($ref) from Github..." + wget -O temp.zip -q https://github.com/${repo}/archive/${ref}.zip + unzip -q temp.zip + mv $(basename ${repo})* ${dest} + rm temp.zip +} + +set -e + +[ -d ${DEST} ] && rm -r ${DEST} +mkdir -p ${DEST} + +downloadFromGithub jquery jquery/jquery 2.1.4 +downloadFromGithub fontawesome FortAwesome/Font-Awesome v4.3.0 +downloadFromGithub flag-icon-css lipis/flag-icon-css 0.7.1 +downloadFromGithub bootstrap twbs/bootstrap v3.3.5 + +echo "* Done." diff --git a/bower.json b/bower.json deleted file mode 100644 index 95711fc..0000000 --- a/bower.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "Memopol", - "version": "3.0.0", - "dependencies": { - "bootstrap": "~3.3.5", - "flag-icon-css": "~0.7.1" - }, - "devDependencies": { - "fontawesome": "~4.3.0" - } -} diff --git a/docs/development.rst b/docs/development.rst index 4b5a7db..52ae563 100644 --- a/docs/development.rst +++ b/docs/development.rst @@ -67,39 +67,17 @@ Then, install the package for development:: Running setup.py develop for political-memory Successfully installed django-1.9 django-coffeescript-0.7.2 django-debug-toolbar-1.4 django-extensions-1.5.9 django-pdb-0.4.2 hamlpy-0.82.2 ijson-2.2 markdown-2.6.5 political-memory pygments-2.0.2 python-dateutil-2.4.2 pytz-2015.7 six-1.10.0 south-1.0.2 sqlparse-0.1.18 werkzeug-0.11.2 -Install NodeJS dependencies +Install client dependencies =========================== -We'll also need to install bower for the staticfiles:: +We'll also need to download client libraries:: - $ npm install bower - memopol@3.0.0 /tmp/political_memory - └── bower@1.7.0 extraneous - -As well as all the requirements from :file:`package.json`:: - - $ npm install - memopol@3.0.0 /tmp/political_memory - ├── bower@1.7.0 extraneous - ├─┬ gulp@3.9.0 - - [output snipped for readability] - - npm WARN In bower@1.7.0 replacing bundled version of configstore with configstore@0.3.2 - npm WARN In bower@1.7.0 replacing bundled version of latest-version with latest-version@1.0.1 - npm WARN In bower@1.7.0 replacing bundled version of update-notifier with update-notifier@0.3.2 - -Don't worry about the warnings, for they are non-critical (as all warnings). -Then, install the bower packages:: - - $ node_modules/.bin/bower install - bower bootstrap#~3.3.5 cached git://github.com/twbs/bootstrap.git#3.3.6 - bootstrap#3.3.6 static/libs/bootstrap - └── jquery#2.1.4 - - [output snipped for readability] - - jquery#2.1.4 static/libs/jquery + $ bin/install_client_deps.sh + * Downloading jquery/jquery (2.1.4) from Github... + * Downloading FortAwesome/Font-Awesome (v4.3.0) from Github... + * Downloading lipis/flag-icon-css (0.7.1) from Github... + * Downloading twbs/bootstrap (v3.3.5) from Github... + * Done Activate ``DJANGO_DEBUG`` ========================= -- GitLab