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

feat(CLI): add check node version middleware, rm .nvmrc, yarn engines #9728

Merged
merged 13 commits into from
Dec 22, 2023
1 change: 0 additions & 1 deletion __fixtures__/test-project-rsa/.nvmrc

This file was deleted.

3 changes: 1 addition & 2 deletions __fixtures__/test-project-rsa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"root": true
},
"engines": {
"node": "=20.x",
"yarn": ">=1.22.21"
"node": "=20.x"
},
"prisma": {
"seed": "yarn rw exec seed"
Expand Down
1 change: 0 additions & 1 deletion __fixtures__/test-project-rsc-external-packages/.nvmrc

This file was deleted.

3 changes: 1 addition & 2 deletions __fixtures__/test-project-rsc-external-packages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"root": true
},
"engines": {
"node": "=20.x",
"yarn": ">=1.22.21"
"node": "=20.x"
},
"prisma": {
"seed": "yarn rw exec seed"
Expand Down
1 change: 0 additions & 1 deletion __fixtures__/test-project/.nvmrc

This file was deleted.

3 changes: 1 addition & 2 deletions __fixtures__/test-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"root": true
},
"engines": {
"node": "=20.x",
"yarn": ">=1.22.21"
"node": "=20.x"
},
"prisma": {
"seed": "yarn rw exec seed"
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/tutorial/chapter1/prerequisites.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ You could definitely learn them all at once, but it will be harder to determine

### Redwood Versions

You will want to be on at least version 5.0.0 to complete the tutorial. If this is your first time using Redwood then no worries: the latest version will be installed automatically when you create your app skeleton!
You will want to be on at least version 7.0.0 to complete the tutorial. If this is your first time using Redwood then no worries: the latest version will be installed automatically when you create your app skeleton!

If you have an existing site created with a prior version, you'll need to upgrade and (most likely) apply code modifications. Follow this two step process:

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/tutorial/foreword.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ It's usually something that goes into more detail about a specific point, refers

:::info

This tutorial assumes you are using version 5.0.0 or greater of RedwoodJS.
This tutorial assumes you are using version 7.0.0 or greater of RedwoodJS.

:::

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/build.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import terminalLink from 'terminal-link'

import { sides } from '../lib/project'
import checkForBabelConfig from '../middleware/checkForBabelConfig'
import { checkNodeVersion } from '../middleware/checkNodeVersion'

export const command = 'build [side..]'
export const description = 'Build for production'
Expand Down Expand Up @@ -47,7 +47,7 @@ export const builder = (yargs) => {
default: false,
description: 'Measure build performance',
})
.middleware(checkForBabelConfig)
.middleware(checkNodeVersion)
.epilogue(
`Also see the ${terminalLink(
'Redwood CLI Reference',
Expand Down
5 changes: 3 additions & 2 deletions packages/cli/src/commands/dev.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import terminalLink from 'terminal-link'

import checkForBabelConfig from '../middleware/checkForBabelConfig'
import { checkNodeVersion } from '../middleware/checkNodeVersion'

export const command = 'dev [side..]'
export const description = 'Start development servers for api, and web'

export const builder = (yargs) => {
yargs
.positional('side', {
Expand Down Expand Up @@ -32,7 +33,7 @@ export const builder = (yargs) => {
description:
'Port on which to expose API server debugger. If you supply the flag with no value it defaults to 18911.',
})
.middleware(checkForBabelConfig)
.middleware(checkNodeVersion)
.epilogue(
`Also see the ${terminalLink(
'Redwood CLI Reference',
Expand Down
41 changes: 0 additions & 41 deletions packages/cli/src/middleware/checkForBabelConfig.js

This file was deleted.

24 changes: 24 additions & 0 deletions packages/cli/src/middleware/checkNodeVersion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import semver from 'semver'

import c from '../lib/colors'

export function checkNodeVersion() {
const pVersion = process.version
const pVersionC = semver.clean(pVersion)
const LOWER_BOUND = 'v20.0.0'
const LOWER_BOUND_C = semver.clean(LOWER_BOUND)

if (semver.gt(pVersionC, LOWER_BOUND_C)) {
return
}

console.warn(
[
`${c.warning('Warning')}: Your Node.js version is ${c.warning(
pVersion
)}, but Redwood requires ${c.green(`>=${LOWER_BOUND}`)}.`,
'Upgrade your Node.js version using `nvm` or a similar tool. See https://redwoodjs.com/docs/how-to/using-nvm.',
'',
].join('\n')
)
}
1 change: 0 additions & 1 deletion packages/create-redwood-app/templates/js/.nvmrc

This file was deleted.

2 changes: 1 addition & 1 deletion packages/create-redwood-app/templates/js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Welcome to [RedwoodJS](https://redwoodjs.com)!

> **Prerequisites**
>
> - Redwood requires [Node.js](https://nodejs.org/en/) (=18.x) and [Yarn](https://yarnpkg.com/) (>=1.15)
> - Redwood requires [Node.js](https://nodejs.org/en/) (=20.x) and [Yarn](https://yarnpkg.com/).
> - Are you on Windows? For best results, follow our [Windows development setup](https://redwoodjs.com/docs/how-to/windows-development-setup) guide

Start by installing dependencies:
Expand Down
3 changes: 1 addition & 2 deletions packages/create-redwood-app/templates/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"root": true
},
"engines": {
"node": "=20.x",
"yarn": ">=1.22.21"
"node": "=20.x"
},
"prisma": {
"seed": "yarn rw exec seed"
Expand Down
1 change: 0 additions & 1 deletion packages/create-redwood-app/templates/ts/.nvmrc

This file was deleted.

2 changes: 1 addition & 1 deletion packages/create-redwood-app/templates/ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Welcome to [RedwoodJS](https://redwoodjs.com)!

> **Prerequisites**
>
> - Redwood requires [Node.js](https://nodejs.org/en/) (=18.x) and [Yarn](https://yarnpkg.com/) (>=1.15)
> - Redwood requires [Node.js](https://nodejs.org/en/) (=20.x) and [Yarn](https://yarnpkg.com/).
> - Are you on Windows? For best results, follow our [Windows development setup](https://redwoodjs.com/docs/how-to/windows-development-setup) guide

Start by installing dependencies:
Expand Down
3 changes: 1 addition & 2 deletions packages/create-redwood-app/templates/ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"root": true
},
"engines": {
"node": "=20.x",
"yarn": ">=1.22.21"
"node": "=20.x"
},
"prisma": {
"seed": "yarn rw exec seed"
Expand Down