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 committed Apr 14, 2022
1 parent 073d703 commit d1a5109
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 104 deletions.
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 @@ -3,7 +3,6 @@
"public": "public/",
"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 @@ -40,19 +40,3 @@ gulp.task('sass-documentation', function () {
.pipe(sass.sync({ outputStyle: 'expanded', logger: sass.compiler.Logger.silent }).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',
logger: sass.compiler.Logger.silent,
includePaths: [
'node_modules/govuk_frontend_toolkit/stylesheets',
'node_modules/govuk-elements-sass/public/sass',
'node_modules/govuk_template_jinja/assets/stylesheets'
]
}).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
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 glitchEnv = (process.env.PROJECT_REMIX_CHAIN) ? 'production' : false // glitch.com
Expand Down Expand Up @@ -173,38 +156,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 @@ -260,18 +218,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 @@ -297,13 +243,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 d1a5109

Please sign in to comment.