Skip to content

Commit

Permalink
Remove v6 compatibility
Browse files Browse the repository at this point in the history
It adds complexity to the codebase that we no longer need
  • Loading branch information
joelanman authored and lfdebrux committed May 18, 2022
1 parent f0badb5 commit 4f619b8
Show file tree
Hide file tree
Showing 11 changed files with 6 additions and 225 deletions.
5 changes: 1 addition & 4 deletions __tests__/spec/update-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,15 +374,12 @@ describe('update.sh', () => {
const updateDir = path.join(testDir, 'update')
fs.unlinkSync(path.join(updateDir, 'docs', 'documentation', 'session.md'))
fs.unlinkSync(path.join(updateDir, 'gulp', 'clean.js'))
fs.unlinkSync(path.join(updateDir, 'lib', 'v6', 'govuk_template_unbranded.html'))
fs.rmdirSync(path.join(updateDir, 'lib', 'v6'))

runScriptSyncAndExpectSuccess('copy', { testDir })

expect(execGitStatusSync(testDir)).toEqual([
' D docs/documentation/session.md',
' D gulp/clean.js',
' D lib/v6/govuk_template_unbranded.html'
' D gulp/clean.js'
])
})

Expand Down
4 changes: 3 additions & 1 deletion docs/documentation/backwards-compatibility.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
---
title: Use backwards compatibility to upgrade from version 6
---
# Use backwards compatibility to upgrade from version 6
# Use backwards compatibility to upgrade from version 6 (legacy)

Note: backwards compatibility was removed in v13

Version 7 of the Prototype Kit uses the new GOV.UK Design System. It is not compatible with prototypes built with older versions by default.

Expand Down
1 change: 0 additions & 1 deletion gulp/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"cypress": "cypress/",
"assets" : "app/assets/",
"docsAssets" : "docs/assets/",
"v6Assets": "app/v6/assets/",
"nodeModules": "node_modules/",
"lib": "lib/"
}
Expand Down
8 changes: 0 additions & 8 deletions gulp/copy-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,3 @@ gulp.task('copy-assets-documentation', function () {
])
.pipe(gulp.dest(config.paths.public))
})

gulp.task('copy-assets-v6', function () {
return gulp.src([
`${config.paths.v6Assets}/**`,
`!${config.paths.v6Assets}/sass/**`
])
.pipe(gulp.dest(config.paths.public + '/v6'))
})
16 changes: 0 additions & 16 deletions gulp/sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,3 @@ gulp.task('sass-documentation', function () {
}).on('error', sass.logError))
.pipe(gulp.dest(config.paths.public + '/stylesheets/', { sourcemaps: true }))
})

// Backward compatibility with Elements

gulp.task('sass-v6', function () {
return gulp.src(config.paths.v6Assets + '/sass/*.scss', { sourcemaps: true })
.pipe(sass.sync({
outputStyle: 'expanded',
includePaths: [
'node_modules/govuk_frontend_toolkit/stylesheets',
'node_modules/govuk-elements-sass/public/sass',
'node_modules/govuk_template_jinja/assets/stylesheets'
],
quietDeps: true
}).on('error', sass.logError))
.pipe(gulp.dest(config.paths.public + '/v6/stylesheets/', { sourcemaps: true }))
})
11 changes: 0 additions & 11 deletions gulp/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,3 @@ gulp.task('watch-assets', function () {
return gulp.watch([config.paths.assets + 'images/**',
config.paths.assets + 'javascripts/**'], { cwd: './' }, gulp.task('copy-assets'))
})

// Backward compatibility with Elements

gulp.task('watch-sass-v6', function () {
return gulp.watch(config.paths.v6Assets + 'sass/**', { cwd: './' }, gulp.task('sass-v6'))
})

gulp.task('watch-assets-v6', function () {
return gulp.watch([config.paths.v6Assets + 'images/**',
config.paths.v6Assets + 'javascripts/**'], { cwd: './' }, gulp.task('copy-assets-v6'))
})
8 changes: 2 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@ gulp.task('generate-assets', gulp.series(
'sass',
'copy-assets',
'sass-documentation',
'copy-assets-documentation',
'sass-v6',
'copy-assets-v6'
'copy-assets-documentation'
)
))
gulp.task('watch', gulp.parallel(
'watch-sass',
'watch-assets',
'watch-sass-v6',
'watch-assets-v6'
'watch-assets'
))
gulp.task('default', gulp.series(
'generate-assets',
Expand Down
74 changes: 0 additions & 74 deletions lib/v6/govuk_template_unbranded.html

This file was deleted.

42 changes: 0 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"express": "^4.17.1",
"express-session": "^1.13.0",
"fancy-log": "^1.3.3",
"govuk-elements-sass": "^3.1.3",
"govuk-frontend": "^4.0.1",
"govuk_frontend_toolkit": "^7.5.0",
"govuk_template_jinja": "^0.24.1",
Expand Down
61 changes: 0 additions & 61 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Core dependencies
const fs = require('fs')
const path = require('path')
const url = require('url')

Expand Down Expand Up @@ -28,25 +27,9 @@ const routes = require('./app/routes.js')
const utils = require('./lib/utils.js')
const extensions = require('./lib/extensions/extensions.js')

// Variables for v6 backwards compatibility
// Set false by default, then turn on if we find /app/v6/routes.js
var useV6 = false
var v6App
var v6Routes

if (fs.existsSync('./app/v6/routes.js')) {
v6Routes = require('./app/v6/routes.js')
useV6 = true
}

const app = express()
const documentationApp = express()

if (useV6) {
console.log('/app/v6/routes.js detected - using v6 compatibility mode')
v6App = express()
}

// Set up configuration variables
var releaseVersion = packageJson.version
var env = utils.getNodeEnv()
Expand Down Expand Up @@ -172,38 +155,13 @@ app.use(bodyParser.urlencoded({
extended: true
}))

// Set up v6 app for backwards compatibility
if (useV6) {
var v6Views = [
path.join(__dirname, '/node_modules/govuk_template_jinja/views/layouts'),
path.join(__dirname, '/app/v6/views/'),
path.join(__dirname, '/lib/v6') // for old unbranded template
]
nunjucksConfig.express = v6App
var nunjucksV6Env = nunjucks.configure(v6Views, nunjucksConfig)

// Nunjucks filters
utils.addNunjucksFilters(nunjucksV6Env)

// Set views engine
v6App.set('view engine', 'html')

// Backward compatibility with GOV.UK Elements
app.use('/public/v6/', express.static(path.join(__dirname, '/node_modules/govuk_template_jinja/assets')))
app.use('/public/v6/', express.static(path.join(__dirname, '/node_modules/govuk_frontend_toolkit')))
app.use('/public/v6/javascripts/govuk/', express.static(path.join(__dirname, '/node_modules/govuk_frontend_toolkit/javascripts/govuk/')))
}

// Automatically store all data users enter
if (useAutoStoreData === 'true') {
app.use(utils.autoStoreData)
utils.addCheckedFunction(nunjucksAppEnv)
if (useDocumentation) {
utils.addCheckedFunction(nunjucksDocumentationEnv)
}
if (useV6) {
utils.addCheckedFunction(nunjucksV6Env)
}
}

// Load prototype admin routes
Expand Down Expand Up @@ -259,18 +217,6 @@ if (useDocumentation) {
documentationApp.use('/', documentationRoutes)
}

if (useV6) {
// Clone app locals to v6 app locals
v6App.locals = Object.assign({}, app.locals)
v6App.locals.asset_path = '/public/v6/'

// Create separate router for v6
app.use('/', v6App)

// Docs under the /docs namespace
v6App.use('/', v6Routes)
}

// Strip .html and .htm if provided
app.get(/\.html?$/i, function (req, res) {
var path = req.path
Expand All @@ -296,13 +242,6 @@ if (useDocumentation) {
})
}

if (useV6) {
// App folder routes get priority
v6App.get(/^([^.]+)$/, function (req, res, next) {
utils.matchRoutes(req, res, next)
})
}

// Redirect all POSTs to GETs - this allows users to use POST for autoStoreData
app.post(/^\/([^.]+)$/, function (req, res) {
res.redirect(url.format({
Expand Down

0 comments on commit 4f619b8

Please sign in to comment.