Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hiding govuk-frontend uninstall until we deal with dependent plugins #2172

Merged
merged 3 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
- [#2150: Prevent CSURF deprecated warning](https://github.com/alphagov/govuk-prototype-kit/pull/2150)

- [#2130: Create our own file store functionality in place of the session-file-store package](https://github.com/alphagov/govuk-prototype-kit/pull/2130)
-
- [#2172: Hiding govuk-frontend uninstall until we deal with dependent plugins](https://github.com/alphagov/govuk-prototype-kit/pull/2172)

## 13.6.2

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
const { managePluginsPagePath, performPluginAction } = require('../plugin-utils')
const { uninstallPlugin, installPlugin } = require('../../utils')
const path = require('path')

const plugin = 'govuk-frontend'
const pluginName = 'GOV.UK Frontend'
const dependentPlugin = '@govuk-prototype-kit/common-templates'
const appConfigPath = path.join('app', 'config.json')

describe('Manage prototype pages without govuk-frontend', () => {
before(() => {
cy.task('copyFromStarterFiles', { filename: appConfigPath })
cy.task('addToConfigJson', { allowGovukFrontendUninstall: true })
})
after(() => {
cy.task('copyFromStarterFiles', { filename: appConfigPath })
})
it('Uninstall govuk-frontend', () => {
uninstallPlugin(dependentPlugin)

Expand Down
10 changes: 10 additions & 0 deletions cypress/events/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// core dependencies
const fs = require('fs')
const fsp = fs.promises
const fse = require('fs-extra')
const path = require('path')

// npm dependencies
Expand Down Expand Up @@ -283,6 +284,15 @@ module.exports = function setupNodeEvents (on, config) {
.then(makeSureCypressCanInterpretTheResult)
},

addToConfigJson: (additionalConfig) => {
log(`Adding config JSON => ${downloadsFolder}`)
const appConfigPath = path.join(config.env.projectFolder, 'app', 'config.json')
return fse.readJson(appConfigPath)
.then(existingConfig => Object.assign({}, existingConfig, additionalConfig))
.then(newConfig => fse.writeJson(appConfigPath, newConfig))
.then(makeSureCypressCanInterpretTheResult)
},

log: (message) => {
log(message)
return makeSureCypressCanInterpretTheResult()
Expand Down
1 change: 1 addition & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ function getConfig (config, swallowError = true) {
overrideOrDefault('logPerformanceSummary', 'LOG_PERFORMANCE_SUMMARY', asNumber, undefined)
overrideOrDefault('verbose', 'VERBOSE', asBoolean, false)
overrideOrDefault('showPrereleases', 'SHOW_PRERELEASES', asBoolean, false)
overrideOrDefault('allowGovukFrontendUninstall', 'ALLOW_GOVUK_FRONTEND_UNINSTALL', asBoolean, false)

if (config.serviceName === undefined) {
config.serviceName = 'GOV.UK Prototype Kit'
Expand Down
1 change: 1 addition & 0 deletions lib/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('config', () => {
useNjkExtensions: false,
logPerformance: false,
showPrereleases: false,
allowGovukFrontendUninstall: false,
verbose: false
})

Expand Down
6 changes: 5 additions & 1 deletion lib/manage-prototype-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,11 @@ async function getPluginDetails () {
const pluginPkgPath = path.join(projectDir, 'node_modules', pack.packageName, 'package.json')
const pluginPkg = await fse.pathExists(pluginPkgPath) ? await fse.readJson(pluginPkgPath) : {}
pack.installedVersion = pluginPkg.version
if (!['govuk-prototype-kit'].includes(pack.packageName)) {
const mandatoryPlugins = ['govuk-prototype-kit']
if (!config.getConfig().allowGovukFrontendUninstall) {
mandatoryPlugins.push('govuk-frontend')
}
if (!mandatoryPlugins.includes(pack.packageName)) {
pack.uninstallLink = `${contextPath}/plugins/uninstall?package=${encodeURIComponent(pack.packageName)}`
}
}
Expand Down