From c7f3b688cd633bbfec2849791d2dedbd1416c678 Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Mon, 1 Apr 2019 09:15:09 +0100 Subject: [PATCH 01/11] Bump version of NodeJS to 10.15.3 Updates the README to reference this. If running this locally, it's recommended to use the 'n' NPM package to manage your version of NodeJS, as described in the README: https://github.com/alphagov/notifications-admin#first-time-setup --- README.md | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 74ce65197..c9eeb68ae 100644 --- a/README.md +++ b/README.md @@ -22,19 +22,19 @@ Brew is a package manager for OSX. The following command installs brew: Languages needed - Python 3.4 -- [Node](https://nodejs.org/) 5.0.0 or greater -- [npm](https://www.npmjs.com/) 3.0.0 or greater +- [Node](https://nodejs.org/) 10.15.3 or greater +- [npm](https://www.npmjs.com/) 6.4.1 or greater ```shell brew install node ``` [NPM](npmjs.org) is Node's package management tool. `n` is a tool for managing -different versions of Node. The following installs `n` and uses the latest +different versions of Node. The following installs `n` and uses the long term support (LTS) version of Node. ```shell npm install -g n - n latest + n lts npm rebuild node-sass ``` diff --git a/package.json b/package.json index 3e81dc120..ee398e34e 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.0.1", "description": "Admin front end for GOV.UK Notify", "engines": { - "node": "5.0.0" + "node": "10.15.3" }, "scripts": { "test": "gulp lint", From c3a1e6ed59e011791439938cfea2858ec751b9ed Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Mon, 1 Apr 2019 09:58:13 +0100 Subject: [PATCH 02/11] Bump Gulp to 4.0.0 Brings in a new API which is a breaking change: https://github.com/gulpjs/gulp/blob/master/CHANGELOG.md#400 Requires gulpfile.babel.js to be a CommonJS module and for all tasks to be exported. Replaces using ES6 modules for the CommonJS to include other packages to match the type of module the gulpfile now is. Updates to 4.0.0 include `series` and `parallel` methods which remove the need for the `run-sequence` package. Also bumps gulp-specific libraries. --- gulpfile.babel.js | 301 +++++++++++++++++++++++----------------------- package.json | 13 +- 2 files changed, 158 insertions(+), 156 deletions(-) diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 1e68636df..69567cbd7 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -5,178 +5,181 @@ // 1. LIBRARIES // - - - - - - - - - - - - - - - -import gulp from 'gulp'; -import loadPlugins from 'gulp-load-plugins'; -import stylish from 'jshint-stylish'; -import runSequence from 'run-sequence'; +const { src, pipe, dest, series, parallel } = require('gulp'); +const loadPlugins = require('gulp-load-plugins'); +const stylish = require('jshint-stylish'); -const plugins = loadPlugins(), +const plugins = loadPlugins(); // 2. CONFIGURATION // - - - - - - - - - - - - - - - - paths = { - src: 'app/assets/', - dist: 'app/static/', - templates: 'app/templates/', - npm: 'node_modules/', - template: 'node_modules/govuk_template_jinja/', - toolkit: 'node_modules/govuk_frontend_toolkit/' - }; +const paths = { + src: 'app/assets/', + dist: 'app/static/', + templates: 'app/templates/', + npm: 'node_modules/', + template: 'node_modules/govuk_template_jinja/', + toolkit: 'node_modules/govuk_frontend_toolkit/' +}; // 3. TASKS // - - - - - - - - - - - - - - - // Move GOV.UK template resources -gulp.task('copy:govuk_template:template', () => gulp.src(paths.template + 'views/layouts/govuk_template.html') - .pipe(gulp.dest(paths.templates)) -); +const copy = { + govuk_template: { + template: () => { + return src(paths.template + 'views/layouts/govuk_template.html') + .pipe(dest(paths.templates)); + }, + css: () => { + return src(paths.template + 'assets/stylesheets/**/*.css') + .pipe(plugins.sass({ + outputStyle: 'compressed' + })) + .on('error', plugins.sass.logError) + .pipe(plugins.cssUrlAdjuster({ + prependRelative: process.env.NOTIFY_ENVIRONMENT == 'development' ? '/static/' : '/', + })) + .pipe(dest(paths.dist + 'stylesheets/')); + }, + js: () => { + return src(paths.template + 'assets/javascripts/**/*.js') + .pipe(plugins.uglify()) + .pipe(dest(paths.dist + 'javascripts/')); + }, + images: () => { + return src(paths.template + 'assets/stylesheets/images/**/*') + .pipe(dest(paths.dist + 'images/')); + }, + fonts: () => { + return src(paths.template + 'assets/stylesheets/fonts/**/*') + .pipe(dest(paths.dist + 'fonts/')); + }, + error_page: () => { + return src(paths.src + 'error_pages/**/*') + .pipe(dest(paths.dist + 'error_pages/')) + } + } +}; -gulp.task('copy:govuk_template:css', () => gulp.src(paths.template + 'assets/stylesheets/**/*.css') - .pipe(plugins.sass({ - outputStyle: 'compressed' - })) - .on('error', plugins.sass.logError) - .pipe(plugins.cssUrlAdjuster({ - prependRelative: process.env.NOTIFY_ENVIRONMENT == 'development' ? '/static/' : '/', - })) - .pipe(gulp.dest(paths.dist + 'stylesheets/')) -); -gulp.task('copy:govuk_template:js', () => gulp.src(paths.template + 'assets/javascripts/**/*.js') - .pipe(plugins.uglify()) - .pipe(gulp.dest(paths.dist + 'javascripts/')) -); +const javascripts = () => { + return src([ + paths.toolkit + 'javascripts/govuk/modules.js', + paths.toolkit + 'javascripts/govuk/show-hide-content.js', + paths.src + 'javascripts/stick-to-window-when-scrolling.js', + paths.src + 'javascripts/detailsPolyfill.js', + paths.src + 'javascripts/apiKey.js', + paths.src + 'javascripts/autofocus.js', + paths.src + 'javascripts/highlightTags.js', + paths.src + 'javascripts/fileUpload.js', + paths.src + 'javascripts/expandCollapse.js', + paths.src + 'javascripts/radioSelect.js', + paths.src + 'javascripts/updateContent.js', + paths.src + 'javascripts/listEntry.js', + paths.src + 'javascripts/liveSearch.js', + paths.src + 'javascripts/errorTracking.js', + paths.src + 'javascripts/preventDuplicateFormSubmissions.js', + paths.src + 'javascripts/fullscreenTable.js', + paths.src + 'javascripts/previewPane.js', + paths.src + 'javascripts/colourPreview.js', + paths.src + 'javascripts/templateFolderForm.js', + paths.src + 'javascripts/main.js' + ]) + .pipe(plugins.prettyerror()) + .pipe(plugins.babel({ + presets: ['es2015'] + })) + .pipe(plugins.addSrc.prepend([ + paths.npm + 'hogan.js/dist/hogan-3.0.2.js', + paths.npm + 'jquery/dist/jquery.min.js', + paths.npm + 'query-command-supported/dist/queryCommandSupported.min.js', + paths.npm + 'diff-dom/diffDOM.js', + paths.npm + 'timeago/jquery.timeago.js', + paths.npm + 'textarea-caret/index.js' + ])) + .pipe(plugins.uglify()) + .pipe(plugins.concat('all.js')) + .pipe(dest(paths.dist + 'javascripts/')) +}; -gulp.task('copy:govuk_template:images', () => gulp.src(paths.template + 'assets/stylesheets/images/**/*') - .pipe(gulp.dest(paths.dist + 'images/')) -); -gulp.task('copy:govuk_template:fonts', () => gulp.src(paths.template + 'assets/stylesheets/fonts/**/*') - .pipe(gulp.dest(paths.dist + 'fonts/')) -); - -gulp.task('javascripts', () => gulp - .src([ - paths.toolkit + 'javascripts/govuk/modules.js', - paths.toolkit + 'javascripts/govuk/show-hide-content.js', - paths.src + 'javascripts/stick-to-window-when-scrolling.js', - paths.src + 'javascripts/detailsPolyfill.js', - paths.src + 'javascripts/apiKey.js', - paths.src + 'javascripts/autofocus.js', - paths.src + 'javascripts/highlightTags.js', - paths.src + 'javascripts/fileUpload.js', - paths.src + 'javascripts/expandCollapse.js', - paths.src + 'javascripts/radioSelect.js', - paths.src + 'javascripts/updateContent.js', - paths.src + 'javascripts/listEntry.js', - paths.src + 'javascripts/liveSearch.js', - paths.src + 'javascripts/errorTracking.js', - paths.src + 'javascripts/preventDuplicateFormSubmissions.js', - paths.src + 'javascripts/fullscreenTable.js', - paths.src + 'javascripts/previewPane.js', - paths.src + 'javascripts/colourPreview.js', - paths.src + 'javascripts/templateFolderForm.js', - paths.src + 'javascripts/main.js' - ]) - .pipe(plugins.prettyerror()) - .pipe(plugins.babel({ - presets: ['es2015'] - })) - .pipe(plugins.addSrc.prepend([ - paths.npm + 'hogan.js/dist/hogan-3.0.2.js', - paths.npm + 'jquery/dist/jquery.min.js', - paths.npm + 'query-command-supported/dist/queryCommandSupported.min.js', - paths.npm + 'diff-dom/diffDOM.js', - paths.npm + 'timeago/jquery.timeago.js', - paths.npm + 'textarea-caret/index.js' - ])) - .pipe(plugins.uglify()) - .pipe(plugins.concat('all.js')) - .pipe(gulp.dest(paths.dist + 'javascripts/')) -); - -gulp.task('sass', () => gulp - .src(paths.src + '/stylesheets/main*.scss') - .pipe(plugins.prettyerror()) - .pipe(plugins.sass({ - outputStyle: 'compressed', - includePaths: [ - paths.npm + 'govuk-elements-sass/public/sass/', - paths.toolkit + 'stylesheets/' - ] - })) - .pipe(plugins.base64({baseDir: 'app'})) - .pipe(gulp.dest(paths.dist + 'stylesheets/')) -); +const sass = () => { + return src(paths.src + '/stylesheets/main*.scss') + .pipe(plugins.prettyerror()) + .pipe(plugins.sass({ + outputStyle: 'compressed', + includePaths: [ + paths.npm + 'govuk-elements-sass/public/sass/', + paths.toolkit + 'stylesheets/' + ] + })) + .pipe(plugins.base64({baseDir: 'app'})) + .pipe(dest(paths.dist + 'stylesheets/')) +}; // Copy images -gulp.task('images', () => gulp - .src([ - paths.src + 'images/**/*', - paths.toolkit + 'images/**/*', - paths.template + 'assets/images/**/*' - ]) - .pipe(gulp.dest(paths.dist + 'images/')) -); - -gulp.task('copy:govuk_template:error_page', () => gulp.src(paths.src + 'error_pages/**/*') - .pipe(gulp.dest(paths.dist + 'error_pages/')) -); +const images = () => { + return src([ + paths.src + 'images/**/*', + paths.toolkit + 'images/**/*', + paths.template + 'assets/images/**/*' + ]) + .pipe(dest(paths.dist + 'images/')) +}; // Watch for changes and re-run tasks -gulp.task('watchForChanges', function() { - gulp.watch(paths.src + 'javascripts/**/*', ['javascripts']); - gulp.watch(paths.src + 'stylesheets/**/*', ['sass']); - gulp.watch(paths.src + 'images/**/*', ['images']); - gulp.watch('gulpfile.babel.js', ['default']); -}); +const watchForChanges = () => { + return watch(paths.src + 'javascripts/**/*', ['javascripts']) + .watch(paths.src + 'stylesheets/**/*', ['sass']) + .watch(paths.src + 'images/**/*', ['images']) + .watch('gulpfile.babel.js', ['default']); +}; -gulp.task('lint:sass', () => gulp - .src([ - paths.src + 'stylesheets/*.scss', - paths.src + 'stylesheets/components/*.scss', - paths.src + 'stylesheets/views/*.scss', - ]) - .pipe(plugins.sassLint()) - .pipe(plugins.sassLint.format(stylish)) - .pipe(plugins.sassLint.failOnError()) -); - -gulp.task('lint:js', () => gulp - .src(paths.src + 'javascripts/**/*.js') - .pipe(plugins.jshint()) - .pipe(plugins.jshint.reporter(stylish)) - .pipe(plugins.jshint.reporter('fail')) -); - -gulp.task('lint', - ['lint:sass', 'lint:js'] -); +const lint = { + 'sass': () => { + return src([ + paths.src + 'stylesheets/*.scss', + paths.src + 'stylesheets/components/*.scss', + paths.src + 'stylesheets/views/*.scss', + ]) + .pipe(plugins.sassLint()) + .pipe(plugins.sassLint.format(stylish)) + .pipe(plugins.sassLint.failOnError()); + }, + 'js': (cb) => { + return src(paths.src + 'javascripts/**/*.js') + .pipe(plugins.jshint()) + .pipe(plugins.jshint.reporter(stylish)) + .pipe(plugins.jshint.reporter('fail')) + } +}; // Default: compile everything -gulp.task('default', function() { - runSequence( - [ - 'copy:govuk_template:template', - 'copy:govuk_template:images', - 'copy:govuk_template:fonts', - 'copy:govuk_template:css', - 'copy:govuk_template:js', - 'images', - ], - [ - 'copy:govuk_template:error_page', - 'javascripts', - 'sass' - ] - ); -}); +const defaultTask = parallel( + series( + copy.govuk_template.template, + copy.govuk_template.images, + copy.govuk_template.fonts, + copy.govuk_template.css, + copy.govuk_template.js, + images + ), + series( + copy.govuk_template.error_page, + javascripts, + sass + ) +); + +exports.default = defaultTask; + +exports.lint = series(lint.sass, lint.js); // Optional: recompile on changes -gulp.task('watch', - ['default', 'watchForChanges'] -); +exports.watch = series(defaultTask, watchForChanges); diff --git a/package.json b/package.json index ee398e34e..7397f0486 100644 --- a/package.json +++ b/package.json @@ -24,28 +24,27 @@ "govuk-elements-sass": "3.1.2", "govuk_frontend_toolkit": "7.2.0", "govuk_template_jinja": "0.24.0", - "gulp": "3.9.1", + "gulp": "4.0.0", "gulp-add-src": "1.0.0", "gulp-babel": "7.0.0", "gulp-base64": "0.1.3", "gulp-concat": "2.6.1", "gulp-include": "2.3.1", "gulp-load-plugins": "1.5.0", - "gulp-sass": "3.1.0", - "gulp-uglify": "3.0.0", + "gulp-sass": "4.0.2", + "gulp-uglify": "3.0.2", "hogan": "1.0.2", "jquery": "1.12.4", "query-command-supported": "1.0.0", - "textarea-caret": "^3.1.0", + "textarea-caret": "3.1.0", "timeago": "1.6.1" }, "devDependencies": { "gulp-css-url-adjuster": "0.2.3", "gulp-jshint": "2.1.0", "gulp-prettyerror": "1.2.1", - "gulp-sass-lint": "1.2.0", + "gulp-sass-lint": "1.4.0", "jshint": "2.9.5", - "jshint-stylish": "2.2.1", - "run-sequence": "2.2.1" + "jshint-stylish": "2.2.1" } } From b83053ddd1ec167a69ed9302588db15f796f8e9d Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Thu, 4 Apr 2019 14:44:46 +0100 Subject: [PATCH 03/11] Fix sass-lint Sass-lint was bumped when gulp-sass-lint was bumped. This brought in a new version which changed the interface of `sassLint.format`. It doesn't look like the `sassLint.format` method ever defined any arguments or did anything with the `arguments` variable. That being the case, our sending it an instance of the 'stylish' ESLint reporter did nothing in the previous version but this wasn't obvious because sass-lint defaults to 'stylish' for its output styling. The latest version (1.4.0) introduced an argument of a writable stream which, if defined, will be used to write the output to. This caused a problem with our sending in the instance of 'stylish'. This moves the selection of stylish into the sass-lint config, as described in the [sass-lint docs](https://github.com/sasstools/gulp-sass-lint/tree/master#sasslintformatwritable). --- gulpfile.babel.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 69567cbd7..c48c87985 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -148,8 +148,10 @@ const lint = { paths.src + 'stylesheets/components/*.scss', paths.src + 'stylesheets/views/*.scss', ]) - .pipe(plugins.sassLint()) - .pipe(plugins.sassLint.format(stylish)) + .pipe(plugins.sassLint({ + 'options': { 'formatter': 'stylish' } + })) + .pipe(plugins.sassLint.format()) .pipe(plugins.sassLint.failOnError()); }, 'js': (cb) => { From 71463182f17358aea895059a425df6478947438a Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Mon, 1 Apr 2019 10:06:50 +0100 Subject: [PATCH 04/11] Stop using Babel to transpile gulpfile Bumping NodeJS to 10.15.3 removes the need to transpile `gulpfile.js` as this version includes all the ES6 features used.. Also removes .babelrc file. This was included to ensure the gulpfile was transpiled correctly so it is no longer needed. --- .babelrc | 3 --- gulpfile.babel.js => gulpfile.js | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 .babelrc rename gulpfile.babel.js => gulpfile.js (99%) diff --git a/.babelrc b/.babelrc deleted file mode 100644 index c13c5f627..000000000 --- a/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "presets": ["es2015"] -} diff --git a/gulpfile.babel.js b/gulpfile.js similarity index 99% rename from gulpfile.babel.js rename to gulpfile.js index c48c87985..4539934db 100644 --- a/gulpfile.babel.js +++ b/gulpfile.js @@ -138,7 +138,7 @@ const watchForChanges = () => { return watch(paths.src + 'javascripts/**/*', ['javascripts']) .watch(paths.src + 'stylesheets/**/*', ['sass']) .watch(paths.src + 'images/**/*', ['images']) - .watch('gulpfile.babel.js', ['default']); + .watch('gulpfile.js', ['default']); }; const lint = { From fed3381209f7b6e5dc403a47007f2f59e188515b Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Mon, 1 Apr 2019 12:09:38 +0100 Subject: [PATCH 05/11] Bump Babel to 7.4.0 Requires replacing `babel-preset-es2015` for `babel-preset-env` as Babel switched to this as of version 6: https://babeljs.io/docs/en/babel-preset-es2015 Note: this also moves all Babel packages to using the scoped packages syntax, descended from the `@babel` namespace. https://docs.npmjs.com/about-scopes --- gulpfile.js | 2 +- package.json | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 4539934db..7009c9a93 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -90,7 +90,7 @@ const javascripts = () => { ]) .pipe(plugins.prettyerror()) .pipe(plugins.babel({ - presets: ['es2015'] + presets: ['@babel/preset-env'] })) .pipe(plugins.addSrc.prepend([ paths.npm + 'hogan.js/dist/hogan-3.0.2.js', diff --git a/package.json b/package.json index 7397f0486..c7f9ba78e 100644 --- a/package.json +++ b/package.json @@ -18,15 +18,15 @@ "license": "MIT", "homepage": "https://github.com/alphagov/notifications-admin#readme", "dependencies": { - "babel-core": "6.26.0", - "babel-preset-es2015": "6.24.1", + "@babel/core": "7.4.0", + "@babel/preset-env": "7.4.2", "diff-dom": "2.3.1", "govuk-elements-sass": "3.1.2", "govuk_frontend_toolkit": "7.2.0", "govuk_template_jinja": "0.24.0", "gulp": "4.0.0", "gulp-add-src": "1.0.0", - "gulp-babel": "7.0.0", + "gulp-babel": "8.0.0", "gulp-base64": "0.1.3", "gulp-concat": "2.6.1", "gulp-include": "2.3.1", From 05f3cb6797a0c6dfe439533a593b3a8059cdbe54 Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Mon, 1 Apr 2019 16:41:23 +0100 Subject: [PATCH 06/11] Bump JSHint --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c7f9ba78e..26ec1bedb 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "gulp-jshint": "2.1.0", "gulp-prettyerror": "1.2.1", "gulp-sass-lint": "1.4.0", - "jshint": "2.9.5", + "jshint": "2.10.2", "jshint-stylish": "2.2.1" } } From 01b97986f6b24c956d20e1b4b6db8445b75c157f Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Wed, 3 Apr 2019 16:02:23 +0100 Subject: [PATCH 07/11] Update diff-dom package to 3.1.0 Since it moved to ES Modules in version 2.3.1, diff-dom stopped including the `diffDOM.js` file in its NPM package. We don't do any kind of bundling in our build yet, just concatenation of our scripts and some minification of the results so we can't take advantage of this yet. The `diffDOM.js` file is still available in the Github release so this moves to referencing that in the `package.json` instead, until we start using a bundler. I opened an issue to check this is what the author intended: https://github.com/fiduswriter/diffDOM/issues/84 The latest version also adds Rollup as a peer dependency. --- app/assets/javascripts/updateContent.js | 2 +- gulpfile.js | 2 +- package.json | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/updateContent.js b/app/assets/javascripts/updateContent.js index 516bd913f..eb94f33eb 100644 --- a/app/assets/javascripts/updateContent.js +++ b/app/assets/javascripts/updateContent.js @@ -2,7 +2,7 @@ "use strict"; var queues = {}; - var dd = new diffDOM(); + var dd = new diffDOM.DiffDOM(); var getRenderer = $component => response => dd.apply( $component.get(0), diff --git a/gulpfile.js b/gulpfile.js index 7009c9a93..7f3347b79 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -96,7 +96,7 @@ const javascripts = () => { paths.npm + 'hogan.js/dist/hogan-3.0.2.js', paths.npm + 'jquery/dist/jquery.min.js', paths.npm + 'query-command-supported/dist/queryCommandSupported.min.js', - paths.npm + 'diff-dom/diffDOM.js', + paths.npm + 'diff-dom/browser/diffDOM.js', paths.npm + 'timeago/jquery.timeago.js', paths.npm + 'textarea-caret/index.js' ])) diff --git a/package.json b/package.json index 26ec1bedb..0105d04da 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "dependencies": { "@babel/core": "7.4.0", "@babel/preset-env": "7.4.2", - "diff-dom": "2.3.1", + "diff-dom": "https://github.com/fiduswriter/diffDOM/archive/v3.1.0.tar.gz", "govuk-elements-sass": "3.1.2", "govuk_frontend_toolkit": "7.2.0", "govuk_template_jinja": "0.24.0", @@ -46,5 +46,8 @@ "gulp-sass-lint": "1.4.0", "jshint": "2.10.2", "jshint-stylish": "2.2.1" + }, + "peerDependencies": { + "rollup": "1.10.0" } } From fa851dcfecc3c148d097851c0b5a919529c7c005 Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Mon, 1 Apr 2019 14:57:47 +0100 Subject: [PATCH 08/11] Bump remaining NPM packages used on client-side Means that only the following packages will now be out of date: 1. govuk_template_jinja 2. jquery Reasons: GOVUK Template Jinja This bumps it to 0.24.1, after which the only changes are to add analytics tracking to the GOV.UK logo and cookie banner. We don't need to track either of these and they were added for GOVUK analytics work. jQuery jQuery stops supporting IE<9 after version 1.12. This is pretty much our support now but if we move to IE>8 we shouldn't do it by bumping the version. This would just increase the amount of broken JS we ship to IE8. Also: both are deprecated and we will move off them in the near future. --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 0105d04da..f596c195e 100644 --- a/package.json +++ b/package.json @@ -21,9 +21,9 @@ "@babel/core": "7.4.0", "@babel/preset-env": "7.4.2", "diff-dom": "https://github.com/fiduswriter/diffDOM/archive/v3.1.0.tar.gz", - "govuk-elements-sass": "3.1.2", - "govuk_frontend_toolkit": "7.2.0", - "govuk_template_jinja": "0.24.0", + "govuk-elements-sass": "3.1.3", + "govuk_frontend_toolkit": "8.1.0", + "govuk_template_jinja": "0.24.1", "gulp": "4.0.0", "gulp-add-src": "1.0.0", "gulp-babel": "8.0.0", @@ -37,7 +37,7 @@ "jquery": "1.12.4", "query-command-supported": "1.0.0", "textarea-caret": "3.1.0", - "timeago": "1.6.1" + "timeago": "1.6.5" }, "devDependencies": { "gulp-css-url-adjuster": "0.2.3", From a8a29698cb376cc747586c829cb434234a17cc4d Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Fri, 5 Apr 2019 13:16:12 +0100 Subject: [PATCH 09/11] Replace gulp-base64 with gulp-base64-inline The gulp-base64 package has 11 dependencies with vulnerabilities listed against them as of this time. It also doesn't seem to be maintained any more. The last commit was in 2015 and there are issues and pull requests up to bump the dependencies. This replaces it with gulp-base64-inline. gulp-base64-inline takes a single path, which it prepends to any image paths it finds. Our image paths are actually URLs, not filesystem paths so we need to send it a relative path to repoint the URL. This commit includes changes that remove a few `@import`s from one of our sass partials. They aren't needed as those files are imported further up the stack and `_typography.scss` has an import in it that overwrites the new `_url-helpers.scss` we added here. --- app/assets/stylesheets/_url-helpers.scss | 14 ++++++++++++++ .../vendor/previous-next-navigation.scss | 2 -- app/assets/stylesheets/main.scss | 4 +++- gulpfile.js | 6 ++++-- package.json | 2 +- 5 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 app/assets/stylesheets/_url-helpers.scss diff --git a/app/assets/stylesheets/_url-helpers.scss b/app/assets/stylesheets/_url-helpers.scss new file mode 100644 index 000000000..9643d295a --- /dev/null +++ b/app/assets/stylesheets/_url-helpers.scss @@ -0,0 +1,14 @@ +// Copy of _url-helpers.scss in govuk_frontend_toolkit +// to allow us to use gulp-base64-inline on all our images +// gulp-base64-inline requires you to specify which of your +// images you want encoded by using the `inline()` function +// see https://github.com/goschevski/gulp-base64-inline +@function file-url($file) { + $url: ''; + @if $path { + $url: inline($path + $file); + } @else { + $url: image-url($file); + } + @return $url; +} diff --git a/app/assets/stylesheets/components/vendor/previous-next-navigation.scss b/app/assets/stylesheets/components/vendor/previous-next-navigation.scss index 5f8f9f4d9..0e060f12c 100644 --- a/app/assets/stylesheets/components/vendor/previous-next-navigation.scss +++ b/app/assets/stylesheets/components/vendor/previous-next-navigation.scss @@ -4,8 +4,6 @@ https://github.com/alphagov/static/blob/3d93a762b9d7af54615c77ae3e479131c03b8175 and https://github.com/alphagov/static/blob/da8aeeaa749093eab30286d7fc9f965533b66f47/app/assets/stylesheets/styleguide/_conditionals2.scss */ -@import "_colours.scss"; -@import "_typography.scss"; // Media query helpers. These make producing IE layouts // super easy. diff --git a/app/assets/stylesheets/main.scss b/app/assets/stylesheets/main.scss index a12340dca..8799cbf73 100644 --- a/app/assets/stylesheets/main.scss +++ b/app/assets/stylesheets/main.scss @@ -11,9 +11,11 @@ $path: '/static/images/'; @import 'typography'; @import 'grid_layout'; @import 'helpers'; -@import 'url-helpers'; @import 'design-patterns/buttons'; +// Dependencies from GOVU.UK Frontend Toolkit, rewritten for this application +@import 'url-helpers'; + // Dependencies from GOV.UK Elements // https://github.com/alphagov/govuk_elements @import 'elements/helpers'; diff --git a/gulpfile.js b/gulpfile.js index 7f3347b79..9e09de08d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -9,7 +9,9 @@ const { src, pipe, dest, series, parallel } = require('gulp'); const loadPlugins = require('gulp-load-plugins'); const stylish = require('jshint-stylish'); -const plugins = loadPlugins(); +const plugins = loadPlugins({ + 'rename': { 'gulp-base64-inline': 'base64' } +}); // 2. CONFIGURATION // - - - - - - - - - - - - - - - @@ -116,7 +118,7 @@ const sass = () => { paths.toolkit + 'stylesheets/' ] })) - .pipe(plugins.base64({baseDir: 'app'})) + .pipe(plugins.base64('../..')) .pipe(dest(paths.dist + 'stylesheets/')) }; diff --git a/package.json b/package.json index f596c195e..640989964 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "gulp": "4.0.0", "gulp-add-src": "1.0.0", "gulp-babel": "8.0.0", - "gulp-base64": "0.1.3", + "gulp-base64-inline": "1.0.4", "gulp-concat": "2.6.1", "gulp-include": "2.3.1", "gulp-load-plugins": "1.5.0", From 4766390f178555cc859f3b664ce7ea5fa3a50c4d Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Fri, 5 Apr 2019 13:31:13 +0100 Subject: [PATCH 10/11] Remove gulp-load-plugins It's not being updated at the moment and has a few vulnerabilities listed against its dependencies. --- gulpfile.js | 15 +++++++++++---- package.json | 1 - 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 9e09de08d..60533475f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -6,12 +6,19 @@ // 1. LIBRARIES // - - - - - - - - - - - - - - - const { src, pipe, dest, series, parallel } = require('gulp'); -const loadPlugins = require('gulp-load-plugins'); const stylish = require('jshint-stylish'); -const plugins = loadPlugins({ - 'rename': { 'gulp-base64-inline': 'base64' } -}); +const plugins = {}; +plugins.addSrc = require('gulp-add-src'); +plugins.babel = require('gulp-babel'); +plugins.base64 = require('gulp-base64-inline'); +plugins.concat = require('gulp-concat'); +plugins.cssUrlAdjuster = require('gulp-css-url-adjuster'); +plugins.jshint = require('gulp-jshint'); +plugins.prettyerror = require('gulp-prettyerror'); +plugins.sass = require('gulp-sass'); +plugins.sassLint = require('gulp-sass-lint'); +plugins.uglify = require('gulp-uglify'); // 2. CONFIGURATION // - - - - - - - - - - - - - - - diff --git a/package.json b/package.json index 640989964..3306a0f6b 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,6 @@ "gulp-base64-inline": "1.0.4", "gulp-concat": "2.6.1", "gulp-include": "2.3.1", - "gulp-load-plugins": "1.5.0", "gulp-sass": "4.0.2", "gulp-uglify": "3.0.2", "hogan": "1.0.2", From a4bca73b80a395b1fd67e1e595643545b1e03e13 Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Thu, 4 Apr 2019 14:30:06 +0100 Subject: [PATCH 11/11] Make Jenkins use Node 10 --- docker/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 4c41b9185..c9464a30b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -6,7 +6,7 @@ ARG NO_PROXY ENV PYTHONUNBUFFERED=1 \ DEBIAN_FRONTEND=noninteractive \ - NODEJS_VERSION=6.3.1-1nodesource1~jessie1 \ + NODEJS_VERSION=10.x \ GOSU_VERSION=1.10 RUN \ @@ -42,8 +42,8 @@ RUN \ && echo "Install nodejs" \ && cd /tmp \ - && curl -x "$HTTP_PROXY" -sSLO https://deb.nodesource.com/node_6.x/pool/main/n/nodejs/nodejs_${NODEJS_VERSION}_amd64.deb \ - && dpkg -i /tmp/nodejs_${NODEJS_VERSION}_amd64.deb \ + && curl -x "$HTTP_PROXY" -sL https://deb.nodesource.com/setup_${NODEJS_VERSION} | bash - \ + && apt-get install -y --no-install-recommends nodejs \ && echo "Clean up" \ && rm -rf /var/lib/apt/lists/* /tmp/*