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

Support for the new Node LTS (version 20) #2363

Merged
merged 7 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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: 1 addition & 1 deletion .github/workflows/test-acceptance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false # continue other tests if one test in matrix fails
matrix:
node-version: [18.x]
node-version: [20.x]
os: [macos-latest, windows-latest, ubuntu-latest]
type: [smoke, plugins, styles, dev, prod, errors]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-heroku.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: actions/setup-node@v3
with:
cache: 'npm'
node-version: '18'
node-version: '20'
- name: Cache Cypress binary
uses: actions/cache@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false # continue other tests if one test in matrix fails
matrix:
node-version: [16.x, 18.x]
node-version: [16.x, 18.x, 20.x]
os: [macos-latest, windows-latest, ubuntu-latest]

name: Test kit on Node v${{ matrix.node-version }} (${{ matrix.os }})
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lts/*
lts/iron
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### New features

- [#2363: Support for the new Node LTS (version 20)](https://github.com/alphagov/govuk-prototype-kit/pull/2363)

## 13.13.6

### Fixes
Expand Down
8 changes: 4 additions & 4 deletions bin/cli
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

if (process.argv.indexOf('--suppress-node-version-warning') === -1 || (process.argv[2] === 'migrate' && process.argv[3] === '--')) {
const majorNodeVersion = parseInt(process.version.split('.')[0].substring(1), 10)
const versionIsWithinRecommendation = majorNodeVersion === 18 || majorNodeVersion === 16
const versionIsWithinRecommendation = [16, 18, 20].includes(majorNodeVersion)
if (!versionIsWithinRecommendation) {
const nodeVersionIsTooOldToUse = majorNodeVersion < 14
const updateOrDownload = majorNodeVersion < 18 ? 'update to' : 'download'
const updateOrDownload = majorNodeVersion < 20 ? 'update to' : 'download'
const printLn = nodeVersionIsTooOldToUse ? console.error.bind(console) : console.warn.bind(console)
const additionalText = nodeVersionIsTooOldToUse ? '' : ' Some features may not work with your version.'

printLn('\nYou\'re using Node', process.version)
printLn('The GOV.UK Prototype Kit only supports Node v16 and v18.' + additionalText + '\n')
printLn('You can', updateOrDownload, 'Node v18 at https://nodejs.org/en/download\n')
printLn('The GOV.UK Prototype Kit only supports Node v18 and v20.' + additionalText + '\n')
colinrotherham marked this conversation as resolved.
Show resolved Hide resolved
printLn('You can', updateOrDownload, 'Node v20 at https://nodejs.org/en/download\n')

if (nodeVersionIsTooOldToUse) {
process.exit(0)
Expand Down
5 changes: 4 additions & 1 deletion lib/plugins/plugin-validator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ describe('plugin-validator', () => {

beforeEach(() => {
const mockFileSystemRoot = path.join(process.cwd(), 'example-plugin')
const exitCodeSetterSpy = jest.spyOn(process, 'exitCode', 'set').mockImplementation(() => {})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

testScope = {
mockFileSystemRoot,
fileSystem: mockFileSystem(mockFileSystemRoot),
stdLogs: [],
errLogs: []
errLogs: [],
exitCodeSetterSpy
}
jest.spyOn(console, 'log').mockImplementation((message, ...args) => {
if (args.length > 0) {
Expand Down Expand Up @@ -50,6 +52,7 @@ describe('plugin-validator', () => {
await validatePlugin(testScope.mockFileSystemRoot)
expect(testScope.errLogs).toEqual([ansiColors.red('Error: The following invalid keys exist in your config: myExample')])
expect(testScope.stdLogs).toEqual(phaseOneSuccessMessages)
expect(testScope.exitCodeSetterSpy).toHaveBeenCalledWith(100)
})
it('should allow a single unknown key when specified', async () => {
testScope.fileSystem.writeFile(['govuk-prototype-kit.config.json'], JSON.stringify({
Expand Down
2 changes: 1 addition & 1 deletion npm-shrinkwrap.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Rapidly create HTML prototypes of GOV.UK services",
"version": "13.13.6",
"engines": {
"node": "^16.x || >= 18.x"
"node": "^16.x || ^18.x || >= 20.x"
},
"main": "index.js",
"bin": {
Expand Down
Loading