From 466a101c6ef44298c547cb3ecd2e1455311d70f7 Mon Sep 17 00:00:00 2001 From: Chris Dixon <37882933+Audiosutras@users.noreply.github.com> Date: Tue, 15 Oct 2019 15:23:27 -0400 Subject: [PATCH] Update Node & PIP Dependencies (#295) Update to project's pip and node dependencies. --- .npmrc | 2 +- .travis.yml | 24 ++++----- Makefile | 11 ++--- README.rst | 53 ++++++-------------- circle.yml | 2 +- docs/dev/provisioning.rst | 5 +- gulpfile.js | 30 +++++------- package.json | 92 +++++++++++++++++------------------ project.travis.yml | 20 +++----- project_name/settings/base.py | 1 - project_name/urls.py | 8 ++- requirements/base.txt | 17 +++---- requirements/deploy.txt | 10 ---- requirements/dev.txt | 26 ++++++---- requirements/production.txt | 5 +- runtime.txt | 2 +- 16 files changed, 136 insertions(+), 172 deletions(-) delete mode 100644 requirements/deploy.txt diff --git a/.npmrc b/.npmrc index 9eda0d4..9a241d2 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1 @@ -python=python2.7 +python=python3.7 diff --git a/.travis.yml b/.travis.yml index 3035a56..fbe27d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,29 +11,29 @@ language: python sudo: false python: - - "3.5" + - "3.7" # Match postgresql version to that in conf/pillar/project.sls -addons: - postgresql: "9.3" +services: + - postgresql # In general, cache things where they are. - directories: - - $HOME/.cache/pip - - $HOME/.npm - - $HOME/.nvm - - $HOME/.cache/node_modules - - $HOME/.cache/venvs +directories: + - $HOME/.cache/pip + - $HOME/.npm + - $HOME/.nvm + - $HOME/.cache/node_modules + - $HOME/.cache/venvs env: - WORKON_HOME=$HOME/.cache/venvs install: - pip install -U pip wheel - - pip install -U 'Django<2.0' + - pip install -U 'Django>2.0' - mkdir -p $WORKON_HOME - - nvm install 6.11 - - nvm use 6.11 + - nvm install 10.16.0 + - nvm use 10.16.0 script: - django-admin.py startproject --template=https://github.com/caktus/django-project-template/zipball/${TRAVIS_BRANCH} --extension=py,yml --name=Makefile,gulpfile.js,package.json test_template diff --git a/Makefile b/Makefile index 7bdffaf..91c1c39 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ PROJECT_NAME = {{ project_name }} -STATIC_LIBS_DIR = ./$(PROJECT_NAME)/static/libs +STATIC_DIR = ./$(PROJECT_NAME)/static default: lint test @@ -20,15 +20,10 @@ lint-py: lint-js: # Check JS for any problems # Requires jshint - ./node_modules/.bin/eslint -c .eslintrc "${STATIC_LIBS_DIR}*" --ext js,jsx + ./node_modules/.bin/eslint -c .eslintrc '${STATIC_DIR}' --ext js,jsx lint: lint-py lint-js -$(STATIC_LIBS_DIR): - mkdir -p $@ - -update-static-libs: $(LIBS) - # Generate a random string of desired length generate-secret: length = 32 generate-secret: @@ -62,7 +57,7 @@ pullmessages: tx pull -af setup: - virtualenv -p `which python3.5` $(WORKON_HOME)/{{ project_name }} + virtualenv -p `which python3.7` $(WORKON_HOME)/{{ project_name }} $(WORKON_HOME)/{{ project_name }}/bin/pip install -U pip wheel $(WORKON_HOME)/{{ project_name }}/bin/pip install -Ur requirements/dev.txt $(WORKON_HOME)/{{ project_name }}/bin/pip freeze diff --git a/README.rst b/README.rst index df21c41..ff11a2e 100644 --- a/README.rst +++ b/README.rst @@ -11,7 +11,7 @@ To start a new project with this template:: django-admin.py startproject \ --template=https://github.com/caktus/django-project-template/zipball/master \ - --extension=py,rst,yml,sh \ + --extension=py,rst,yml,sh,js \ --name=Makefile,gulpfile.js,package.json,Procfile \ @@ -56,24 +56,16 @@ Below you will find basic setup and deployment instructions for the {{ project_n project. To begin you should have the following applications installed on your local development system: -- Python >= 3.5 -- NodeJS >= 6.11 -- npm >= 3.10.10 -- `pip `_ >= 1.5 +- Python >= 3.7 +- NodeJS >= 10.16 +- `pip `_ >= 19 - `virtualenv `_ >= 1.10 - `virtualenvwrapper `_ >= 3.0 - Postgres >= 9.3 - git >= 1.7 -A note on NodeJS 6.x for Ubuntu users: this LTS release may not be available through the -Ubuntu repository, but you can configure a PPA from which it may be installed:: - - curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - - sudo apt-get install -y nodejs - -You may also follow the manual instructions if you wish to configure the PPA yourself: - - https://github.com/nodesource/distributions#manual-installation +Installing the proper NodeJS versions for each of your projects can be difficult. It's probably best +to `use nvm `_. Django version ------------------------ @@ -103,9 +95,9 @@ adjustments as necessary to your needs. To setup your local environment you should create a virtualenv and install the necessary requirements:: - # Check that you have python3.5 installed - $ which python3.5 - $ mkvirtualenv {{ project_name }} -p `which python3.5` + # Check that you have python3.7 installed + $ which python3.7 + $ mkvirtualenv {{ project_name }} -p `which python3.7` ({{ project_name }})$ pip install -r requirements/dev.txt ({{ project_name }})$ npm install @@ -145,33 +137,20 @@ long as the development server is running. Deployment ---------- -There are `different ways to deploy `_. -Here are a couple of them that could be used for {{ project_name }}. +There are different ways to deploy, and `this document `_ outlines a few of them that could be used for {{ project_name }}. Deployment with fabric ...................... -Fabric does not yet support Python 3. You -must either create a new virtualenv for the deployment:: - - # Create a new virtualenv for the deployment - $ mkvirtualenv {{ project_name }}-deploy -p `which python2.7` - ({{ project_name }}-deploy)$ pip install -r requirements/deploy.txt - -or install the deploy requirements -globally:: - - $ sudo pip install -r requirements/deploy.txt - - -You can deploy changes to a particular environment with -the ``deploy`` command:: +We use a library called `fabric `_ as a wrapper around a lot of our deployment +functionality. However, deployment is no longer fully set up in this template, and instead you'll need +to do something like set up `Tequila `_ for your project. Currently, +best way to do that is to copy the configuration from an existing project. Once that is done, and the +servers have been provisioned, you can deploy changes to a particular environment with the ``deploy`` +command:: $ fab staging deploy -New requirements or migrations are detected by parsing the VCS changes and -will be installed/run automatically. - Deployment with Dokku ..................... diff --git a/circle.yml b/circle.yml index 3de02d1..7bb6dc1 100644 --- a/circle.yml +++ b/circle.yml @@ -1,6 +1,6 @@ machine: python: - version: 3.5.0 + version: 3.7 environment: DJANGO_SETTINGS_MODULE: {{ project_name }}.settings.dev dependencies: diff --git a/docs/dev/provisioning.rst b/docs/dev/provisioning.rst index 8dffd54..077b1ac 100644 --- a/docs/dev/provisioning.rst +++ b/docs/dev/provisioning.rst @@ -7,8 +7,8 @@ Overview {{ project_name|title }} is deployed on the following stack. -- OS: Ubuntu 14.04 LTS -- Python: 3.5 +- OS: Ubuntu 18.04 LTS +- Python: 3.7+ - Database: Postgres 9.3 - Application Server: Gunicorn - Frontend Server: Nginx @@ -65,4 +65,3 @@ You can read about how to setup Tequila for a new project from `Tequila Project Setup ` documentation, which will walk you through adding Tequila to any Django project, including one created from this project template. - diff --git a/gulpfile.js b/gulpfile.js index bd0aadc..780214d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -8,8 +8,8 @@ var uglify = require('gulp-uglify'); var streamify = require('gulp-streamify'); var notify = require('gulp-notify'); var concat = require('gulp-concat'); -var cssmin = require('gulp-cssmin'); -var gutil = require('gulp-util'); +var cleancss = require('gulp-clean-css'); +var log = require('fancy-log'); var rename = require("gulp-rename"); var less = require('gulp-less'); var glob = require('glob'); @@ -58,10 +58,6 @@ if (argv._ && argv._[0] === 'deploy') { if (options.development) { console.log("Building for development") delete process.env['NODE_ENV']; - // Be more verbose for developers - gulp.onAll(function (e) { - console.log(e); - }) } else { console.log("Building for production") process.env['NODE_ENV'] = 'production'; @@ -94,7 +90,7 @@ var browserifyTask = function () { var start = Date.now(); console.log('Building APP bundle'); return appBundler.bundle() - .on('error', gutil.log) + .on('error', log) .pipe(source('index.js')) .pipe(gulpif(!options.development, streamify(uglify()))) .pipe(rename('bundle.js')) @@ -126,7 +122,7 @@ var browserifyTask = function () { var start = new Date(); console.log('Building VENDORS bundle'); vendorsBundler.bundle() - .on('error', gutil.log) + .on('error', log) .pipe(source('vendors.js')) .pipe(gulpif(!options.development, streamify(uglify()))) .pipe(gulp.dest(options.dest)) @@ -137,7 +133,7 @@ var browserifyTask = function () { return rebundle(); }; -gulp.task('browserify', ['modernizr'], browserifyTask); +gulp.task('browserify', gulp.series('modernizr', browserifyTask)); var cssTask = function () { var lessOpts = { @@ -164,13 +160,13 @@ var cssTask = function () { .pipe(concat('index.less')) .pipe(less(lessOpts)) .pipe(rename('bundle.css')) - .pipe(cssmin()) + .pipe(cleancss()) .pipe(gulp.dest(options.css.dest)); } }; gulp.task('css', cssTask); -gulp.task('rebuild', ['css', 'browserify']) +gulp.task('rebuild', gulp.parallel('css', 'browserify')) function start_dev_server(done) { console.log("Starting Django runserver http://"+argv.address+":"+argv.port+"/"); @@ -190,17 +186,17 @@ function start_dev_server(done) { }); done(); } -gulp.task('start_dev_server', ['rebuild'], start_dev_server) +gulp.task('start_dev_server', gulp.series('rebuild', start_dev_server)) // Starts our development workflow -gulp.task('default', ['start_dev_server'], function (done) { +gulp.task('default', gulp.series('start_dev_server', function (done) { livereload.listen(); done(); -}); +})); -gulp.task('deploy', ['rebuild']); +gulp.task('deploy', gulp.series('rebuild')) -gulp.task('test', function () { +gulp.task('test', gulp.series(function () { require('babel-core/register'); return gulp .src('./{{ project_name }}/static/js/app/**/*.js') @@ -242,4 +238,4 @@ gulp.task('test', function () { ; }) ; -}); +})); diff --git a/package.json b/package.json index 37fd438..90ca072 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "The {{ project_name|title }} Project", "main": "", "engines": { - "node": ">=6.11 <7" + "node": ">=10.15 <11" }, "directories": { "doc": "docs" @@ -25,52 +25,52 @@ }, "homepage": "https://github.com/[ORGANIZATION]/{{ project_name }}#readme", "dependencies": { - "babel-core": "^6.6.0", - "babel-eslint": "^6.0.4", - "babel-plugin-rewire": "^1.0.0-rc-2", - "babel-plugin-transform-react-jsx": "^6.6.0", - "babel-preset-es2015": "^6.1.18", - "babelify": "^7.2.0", - "bootstrap": "^3.3.6", - "browserify": "^12.0.1", - "chai": "^3.5.0", - "eslint": "^2.10.2", - "file-exists": "^1.0.0", - "flux": "^2.1.1", - "glob": "^6.0.1", - "gulp": "^3.8.9", - "gulp-concat": "^2.3.4", - "gulp-connect": "^2.2.0", - "gulp-cssmin": "^0.1.6", - "gulp-if": "^1.2.4", - "gulp-istanbul": "^0.10.3", + "babel-core": "^6.26.3", + "babel-eslint": "^10.0.3", + "babel-plugin-rewire": "^1.2.0", + "babel-plugin-transform-react-jsx": "^6.24.1", + "babel-preset-es2015": "^6.24.1", + "babelify": "^8.0.0", + "bootstrap": "^4.3.1", + "browserify": "^16.5.0", + "chai": "^4.2.0", + "eslint": "^6.5.0", + "fancy-log": "^1.3.3", + "file-exists": "^5.0.1", + "flux": "^3.1.3", + "glob": "^7.1.4", + "gulp": "^4.0.2", + "gulp-clean-css": "^4.2.0", + "gulp-concat": "^2.6.1", + "gulp-connect": "^5.7.0", + "gulp-if": "^3.0.0", + "gulp-istanbul": "^1.1.3", "gulp-istanbul-enforcer": "^1.0.3", - "gulp-jasmine2-phantomjs": "^0.1.1", - "gulp-less": "^3.0.5", - "gulp-livereload": "^2.1.1", - "gulp-mocha": "^2.2.0", - "gulp-modernizr": "0.0.0", - "gulp-notify": "^1.4.2", - "gulp-rename": "^1.2.2", - "gulp-streamify": "0.0.5", - "gulp-uglify": "^0.3.1", - "gulp-util": "^3.0.0", - "immutable": "^3.7.6", - "isparta": "^4.0.0", - "jquery": "^3.0.0", - "jsdom": "^8.3.0", - "jsdom-global": "^1.7.0", - "less": "^2.5.3", - "mocha": "^2.4.5", - "mocha-jsdom": "^1.1.0", - "react": "^0.14.7", - "react-addons-test-utils": "^0.14.7", - "react-dom": "^0.14.7", - "react-functional": "^1.2.0", - "sinon": "^1.17.3", - "vinyl-source-stream": "^0.1.1", - "watchify": "^2.1.1", - "yargs": "^3.31.0" + "gulp-jasmine2-phantomjs": "^1.0.1", + "gulp-less": "^4.0.1", + "gulp-livereload": "^4.0.2", + "gulp-mocha": "^7.0.1", + "gulp-modernizr": "3.3.0", + "gulp-notify": "^3.2.0", + "gulp-rename": "^1.4.0", + "gulp-streamify": "1.0.2", + "gulp-uglify": "^3.0.2", + "immutable": "^3.8.2", + "isparta": "^4.1.1", + "jquery": "^3.4.1", + "jsdom": "^15.1.1", + "jsdom-global": "^3.0.2", + "less": "^3.10.3", + "mocha": "^6.2.1", + "mocha-jsdom": "^2.0.0", + "react": "^16.10.1", + "react-addons-test-utils": "^15.6.2", + "react-dom": "^16.10.1", + "react-functional": "^3.0.2", + "sinon": "^7.5.0", + "vinyl-source-stream": "^2.0.0", + "watchify": "^3.11.1", + "yargs": "^14.0.0" }, "browserify": { "transform": [ diff --git a/project.travis.yml b/project.travis.yml index 80d0952..84510b0 100644 --- a/project.travis.yml +++ b/project.travis.yml @@ -3,11 +3,11 @@ language: python sudo: false python: - - "3.5" + - "3.7" # Match postgresql version to that in conf/pillar/project.sls -addons: - postgresql: "9.3" +services: + - postgresql cache: directories: @@ -21,10 +21,10 @@ env: - DJANGO_SETTINGS_MODULE="{{ project_name }}.settings.dev" install: - - pip install -U pip + - pip install -U pip wheel - pip install -U -r requirements/dev.txt - - nvm install 6.11 - - nvm use 6.11 + - nvm install 10.16.0 + - nvm use 10.16 - npm install before_script: @@ -43,11 +43,3 @@ script: - flake8 . - make docs - npm test - -notifications: - hipchat: - rooms: - secure: 'FIXME: replace with "travis encrypt --add notifications.hipchat.rooms"' - template: - - '%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message} (Details/Change view)' - format: html diff --git a/project_name/settings/base.py b/project_name/settings/base.py index 78108d1..663f238 100644 --- a/project_name/settings/base.py +++ b/project_name/settings/base.py @@ -41,7 +41,6 @@ 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] diff --git a/project_name/urls.py b/project_name/urls.py index 7023dad..3bf6f77 100644 --- a/project_name/urls.py +++ b/project_name/urls.py @@ -14,7 +14,7 @@ 2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) """ from django.conf import settings -from django.conf.urls import url +from django.conf.urls import url, include from django.conf.urls.static import static from django.contrib import admin from django.views.generic import TemplateView @@ -23,3 +23,9 @@ url(r'^$', TemplateView.as_view(template_name='base.html')), url(r'^admin/', admin.site.urls), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + +if settings.DEBUG: + import debug_toolbar + urlpatterns += [ + url(r'^__debug__/', include(debug_toolbar.urls)), + ] diff --git a/requirements/base.txt b/requirements/base.txt index e353aa8..14aefef 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,16 +1,15 @@ -psycopg2==2.7.4 -Pillow==5.0.0 # The comment on the next line tells requests.io to warn us if there's a newer # version of Django within the given range, but not for versions outside that # range. So if 1.11.12 gets released, we get warned. If 2.0.1 gets released, # we don't. -Django==1.11.11 # rq.filter: >=1.11.11,<2.0 -six==1.11.0 +Django==2.2.6 # rq.filter: >=2.2.7,<2.3 +# Required by Django +sqlparse==0.3.0 +pytz -BeautifulSoup4==4.6.0 - -django-dotenv==1.4.2 dealer==2.0.5 - +django-dotenv==1.4.2 dj-database-url==0.5.0 -whitenoise==3.3.1 +Pillow==6.1.0 +psycopg2-binary==2.8.3 +whitenoise==4.1.4 diff --git a/requirements/deploy.txt b/requirements/deploy.txt deleted file mode 100644 index 959b964..0000000 --- a/requirements/deploy.txt +++ /dev/null @@ -1,10 +0,0 @@ -# These are the requirements for a virtualenv that can be used to run 'fabric' to do a deploy, -# *NOT* the requirements for a server running this Django site. -PyYAML==3.12 -Fabric==1.14.0 -# Required by Fabric -paramiko==2.4.1 -pycrypto==2.6.1 -ecdsa==0.13 - -newrelic diff --git a/requirements/dev.txt b/requirements/dev.txt index 0f0d3d1..62f37e1 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,17 +1,15 @@ -r base.txt -django-debug-toolbar==1.9.1 -# Required by django-debug-toolbar -sqlparse==0.2.4 +django-debug-toolbar==2.0 -coverage==4.5.1 -flake8==3.5.0 +coverage==4.5.4 +flake8==3.7.8 # Required by flake8 -pyflakes==1.6.0 -pep8==1.7.1 -mccabe==0.6.1 +entrypoints==0.3 +pycodestyle==2.5.0 +pyflakes==2.1.1 # For translation -transifex-client==0.13.1 +transifex-client==0.13.6 requires.io @@ -23,3 +21,13 @@ Babel==2.5.3 docutils==0.14 Pygments==2.2.0 snowballstemmer==1.2.1 + +# For deployment +Fabric3==1.14.post1 +asn1crypto==0.24.0 +bcrypt==3.1.7 +cffi==1.12.3 +cryptography==2.7 +paramiko==2.6.0 +pycparser==2.19 +pynacl==1.3.0 diff --git a/requirements/production.txt b/requirements/production.txt index 07a596a..932ddfd 100644 --- a/requirements/production.txt +++ b/requirements/production.txt @@ -1,3 +1,4 @@ -r base.txt -python3-memcached==1.51 -gunicorn==19.7.1 +python-memcached==1.59 +gunicorn==19.9.0 +newrelic diff --git a/runtime.txt b/runtime.txt index 5c45380..881a2db 100644 --- a/runtime.txt +++ b/runtime.txt @@ -1 +1 @@ -python-3.6.4 +python-3.7.0