diff --git a/__fixtures__/test-project-rsa/.nvmrc b/__fixtures__/test-project-rsa/.nvmrc deleted file mode 100644 index 3f430af82b3d..000000000000 --- a/__fixtures__/test-project-rsa/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -v18 diff --git a/__fixtures__/test-project-rsa/package.json b/__fixtures__/test-project-rsa/package.json index 60e4dd3738b1..d40992f2f0ac 100644 --- a/__fixtures__/test-project-rsa/package.json +++ b/__fixtures__/test-project-rsa/package.json @@ -14,8 +14,7 @@ "root": true }, "engines": { - "node": "=20.x", - "yarn": ">=1.22.21" + "node": "=20.x" }, "prisma": { "seed": "yarn rw exec seed" diff --git a/__fixtures__/test-project-rsc-external-packages/.nvmrc b/__fixtures__/test-project-rsc-external-packages/.nvmrc deleted file mode 100644 index 3f430af82b3d..000000000000 --- a/__fixtures__/test-project-rsc-external-packages/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -v18 diff --git a/__fixtures__/test-project-rsc-external-packages/package.json b/__fixtures__/test-project-rsc-external-packages/package.json index 6416ecdeea35..d98cfc67601b 100644 --- a/__fixtures__/test-project-rsc-external-packages/package.json +++ b/__fixtures__/test-project-rsc-external-packages/package.json @@ -14,8 +14,7 @@ "root": true }, "engines": { - "node": "=20.x", - "yarn": ">=1.22.21" + "node": "=20.x" }, "prisma": { "seed": "yarn rw exec seed" diff --git a/__fixtures__/test-project/.nvmrc b/__fixtures__/test-project/.nvmrc deleted file mode 100644 index 9a2a0e219c9b..000000000000 --- a/__fixtures__/test-project/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -v20 diff --git a/__fixtures__/test-project/package.json b/__fixtures__/test-project/package.json index 25e637ddcff7..1ab4a33bedab 100644 --- a/__fixtures__/test-project/package.json +++ b/__fixtures__/test-project/package.json @@ -14,8 +14,7 @@ "root": true }, "engines": { - "node": "=20.x", - "yarn": ">=1.22.21" + "node": "=20.x" }, "prisma": { "seed": "yarn rw exec seed" diff --git a/docs/docs/tutorial/chapter1/prerequisites.md b/docs/docs/tutorial/chapter1/prerequisites.md index a29c425adc04..2fe986a41784 100644 --- a/docs/docs/tutorial/chapter1/prerequisites.md +++ b/docs/docs/tutorial/chapter1/prerequisites.md @@ -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: diff --git a/docs/docs/tutorial/foreword.md b/docs/docs/tutorial/foreword.md index ec1f1810ed40..7fd872c1adfb 100644 --- a/docs/docs/tutorial/foreword.md +++ b/docs/docs/tutorial/foreword.md @@ -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. ::: diff --git a/packages/cli/src/commands/build.js b/packages/cli/src/commands/build.js index 5c7cb6ffffb3..d38568f6ba96 100644 --- a/packages/cli/src/commands/build.js +++ b/packages/cli/src/commands/build.js @@ -1,7 +1,9 @@ import terminalLink from 'terminal-link' +import c from '../lib/colors' +import { exitWithError } from '../lib/exit' 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' @@ -47,7 +49,18 @@ export const builder = (yargs) => { default: false, description: 'Measure build performance', }) - .middleware(checkForBabelConfig) + .middleware(() => { + const check = checkNodeVersion() + + if (check.ok) { + return + } + + exitWithError(undefined, { + message: `${c.error('Error')}: ${check.message}`, + includeEpilogue: false, + }) + }) .epilogue( `Also see the ${terminalLink( 'Redwood CLI Reference', diff --git a/packages/cli/src/commands/dev.js b/packages/cli/src/commands/dev.js index a9970971370a..de9b2946bb22 100644 --- a/packages/cli/src/commands/dev.js +++ b/packages/cli/src/commands/dev.js @@ -1,9 +1,11 @@ import terminalLink from 'terminal-link' -import checkForBabelConfig from '../middleware/checkForBabelConfig' +import c from '../lib/colors' +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', { @@ -32,7 +34,15 @@ 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(() => { + const check = checkNodeVersion() + + if (check.ok) { + return + } + + console.warn(`${c.warning('Warning')}: ${check.message}\n`) + }) .epilogue( `Also see the ${terminalLink( 'Redwood CLI Reference', diff --git a/packages/cli/src/commands/setup/deploy/__tests__/__snapshots__/netlify.test.js.snap b/packages/cli/src/commands/setup/deploy/__tests__/__snapshots__/netlify.test.js.snap index 35eb1324ffe4..10ceee2e1564 100644 --- a/packages/cli/src/commands/setup/deploy/__tests__/__snapshots__/netlify.test.js.snap +++ b/packages/cli/src/commands/setup/deploy/__tests__/__snapshots__/netlify.test.js.snap @@ -6,22 +6,27 @@ exports[`netlify should add netlify.toml 1`] = ` publish = "web/dist" functions = "api/dist/functions" -[dev] - # To use [Netlify Dev](https://www.netlify.com/products/dev/), - # install netlify-cli from https://docs.netlify.com/cli/get-started/#installation - # and then use netlify link https://docs.netlify.com/cli/get-started/#link-and-unlink-sites - # to connect your local project to a site already on Netlify - # then run netlify dev and our app will be accessible on the port specified below - framework = "redwoodjs" - # Set targetPort to the [web] side port as defined in redwood.toml - targetPort = 8910 - # Point your browser to this port to access your RedwoodJS app - port = 8888 + [build.environment] + NODE_VERSION = "20" [[redirects]] from = "/*" to = "/200.html" status = 200 + +# To use Netlify Dev, install Netlify's CLI (\`netlify-cli\`) from NPM and use \`netlify link\` +# to connect your local project to a site on Netlify. Then run \`netlify dev\`. +# +# Quick links to the docs: +# - Netlfy Dev https://www.netlify.com/products/dev +# - Netlify's CLI https://docs.netlify.com/cli/get-started/#installation +# - \`netlify link\` https://docs.netlify.com/cli/get-started/#link-and-unlink-sites +[dev] + framework = "redwoodjs" + # Make sure \`targetPort\` matches \`web.port\` in the \`redwood.toml\`: + targetPort = 8910 + # Point your browser to this port to access your app: + port = 8888 " `; @@ -31,21 +36,26 @@ exports[`netlify should call the handler without error 1`] = ` publish = "web/dist" functions = "api/dist/functions" -[dev] - # To use [Netlify Dev](https://www.netlify.com/products/dev/), - # install netlify-cli from https://docs.netlify.com/cli/get-started/#installation - # and then use netlify link https://docs.netlify.com/cli/get-started/#link-and-unlink-sites - # to connect your local project to a site already on Netlify - # then run netlify dev and our app will be accessible on the port specified below - framework = "redwoodjs" - # Set targetPort to the [web] side port as defined in redwood.toml - targetPort = 8910 - # Point your browser to this port to access your RedwoodJS app - port = 8888 + [build.environment] + NODE_VERSION = "20" [[redirects]] from = "/*" to = "/200.html" status = 200 + +# To use Netlify Dev, install Netlify's CLI (\`netlify-cli\`) from NPM and use \`netlify link\` +# to connect your local project to a site on Netlify. Then run \`netlify dev\`. +# +# Quick links to the docs: +# - Netlfy Dev https://www.netlify.com/products/dev +# - Netlify's CLI https://docs.netlify.com/cli/get-started/#installation +# - \`netlify link\` https://docs.netlify.com/cli/get-started/#link-and-unlink-sites +[dev] + framework = "redwoodjs" + # Make sure \`targetPort\` matches \`web.port\` in the \`redwood.toml\`: + targetPort = 8910 + # Point your browser to this port to access your app: + port = 8888 " `; diff --git a/packages/cli/src/commands/setup/deploy/templates/netlify.js b/packages/cli/src/commands/setup/deploy/templates/netlify.js index 21d4a52ee861..52f1f297fc2c 100644 --- a/packages/cli/src/commands/setup/deploy/templates/netlify.js +++ b/packages/cli/src/commands/setup/deploy/templates/netlify.js @@ -2,25 +2,31 @@ import { getConfig } from '../../../../lib' const config = getConfig() -export const NETLIFY_TOML = `[build] +export const NETLIFY_TOML = `\ +[build] command = "yarn rw deploy netlify" publish = "web/dist" functions = "api/dist/functions" -[dev] - # To use [Netlify Dev](https://www.netlify.com/products/dev/), - # install netlify-cli from https://docs.netlify.com/cli/get-started/#installation - # and then use netlify link https://docs.netlify.com/cli/get-started/#link-and-unlink-sites - # to connect your local project to a site already on Netlify - # then run netlify dev and our app will be accessible on the port specified below - framework = "redwoodjs" - # Set targetPort to the [web] side port as defined in redwood.toml - targetPort = ${config.web.port} - # Point your browser to this port to access your RedwoodJS app - port = 8888 + [build.environment] + NODE_VERSION = "20" [[redirects]] from = "/*" to = "/200.html" status = 200 + +# To use Netlify Dev, install Netlify's CLI (\`netlify-cli\`) from NPM and use \`netlify link\` +# to connect your local project to a site on Netlify. Then run \`netlify dev\`. +# +# Quick links to the docs: +# - Netlfy Dev https://www.netlify.com/products/dev +# - Netlify's CLI https://docs.netlify.com/cli/get-started/#installation +# - \`netlify link\` https://docs.netlify.com/cli/get-started/#link-and-unlink-sites +[dev] + framework = "redwoodjs" + # Make sure \`targetPort\` matches \`web.port\` in the \`redwood.toml\`: + targetPort = ${config.web.port} + # Point your browser to this port to access your app: + port = 8888 ` diff --git a/packages/cli/src/commands/setup/deploy/templates/render.js b/packages/cli/src/commands/setup/deploy/templates/render.js index 9c5373e225a8..9c04c8f857bb 100644 --- a/packages/cli/src/commands/setup/deploy/templates/render.js +++ b/packages/cli/src/commands/setup/deploy/templates/render.js @@ -5,31 +5,29 @@ import { getPaths } from '../../../../lib' export const PROJECT_NAME = path.basename(getPaths().base) export const RENDER_YAML = (database) => { - return `##### -# Documentation -# Redwood: https://render.com/docs/deploy-redwood -# YAML (all config values): https://render.com/docs/yaml-spec -##### + return `# Quick links to the docs: +# - Redwood on Render: https://render.com/docs/deploy-redwood +# - Render's Blueprint spec: https://render.com/docs/yaml-spec services: - name: ${PROJECT_NAME}-web type: web env: static - buildCommand: yarn install && yarn rw deploy render web + buildCommand: corepack enable && yarn install && yarn rw deploy render web staticPublishPath: ./web/dist + envVars: - - key: NODE_VERSION - value: 18 - key: SKIP_INSTALL_DEPS value: true + routes: - type: rewrite source: /.redwood/functions/* -##### -# NOTE: replace destination api url after first deploy to Render -# example: -# destination: https://myredwoodproject-api.onrender.com/* -##### + # Replace \`destination\` here after your first deploy: + # + # \`\`\` + # destination: https://my-redwood-project-api.onrender.com/* + # \`\`\` destination: replace_with_api_url/* - type: rewrite source: /* @@ -40,35 +38,37 @@ services: plan: free env: node region: oregon - buildCommand: yarn && yarn rw build api + buildCommand: corepack enable && yarn && yarn rw build api startCommand: yarn rw deploy render api + envVars: - - key: NODE_VERSION - value: 18 ${database} ` } -export const POSTGRES_YAML = ` - key: DATABASE_URL +export const POSTGRES_YAML = `\ + - key: DATABASE_URL fromDatabase: name: ${PROJECT_NAME}-db property: connectionString databases: - name: ${PROJECT_NAME}-db - region: oregon -` + region: oregon` -export const SQLITE_YAML = ` - key: DATABASE_URL +export const SQLITE_YAML = `\ + - key: DATABASE_URL value: file:./data/sqlite.db disk: name: sqlite-data mountPath: /opt/render/project/src/api/db/data sizeGB: 1` -export const RENDER_HEALTH_CHECK = `// render-health-check +export const RENDER_HEALTH_CHECK = `\ +// render-health-check export const handler = async () => { return { statusCode: 200, } -}` +} +` diff --git a/packages/cli/src/lib/exit.js b/packages/cli/src/lib/exit.js index 57c6b079c0a1..1c78cdabf8d9 100644 --- a/packages/cli/src/lib/exit.js +++ b/packages/cli/src/lib/exit.js @@ -39,19 +39,21 @@ export function exitWithError( const line = chalk.red('-'.repeat(process.stderr.columns)) // Generate and print a nice message to the user - const content = [ - line, - message, - includeEpilogue && `\n${line}`, - includeEpilogue && epilogue, - includeReferenceCode && - ` - Here's your unique error reference to quote: '${errorReferenceCode}'`, - line, - ] - .filter(Boolean) - .join('\n') - - console.error() + const content = !includeEpilogue + ? message + : [ + '', + line, + message, + `\n${line}`, + epilogue, + includeReferenceCode && + ` - Here's your unique error reference to quote: '${errorReferenceCode}'`, + line, + ] + .filter(Boolean) + .join('\n') + console.error(content) // Record the error in telemetry diff --git a/packages/cli/src/middleware/checkForBabelConfig.js b/packages/cli/src/middleware/checkForBabelConfig.js deleted file mode 100644 index dbe922e5fe1a..000000000000 --- a/packages/cli/src/middleware/checkForBabelConfig.js +++ /dev/null @@ -1,41 +0,0 @@ -import boxen from 'boxen' -import fg from 'fast-glob' - -import { getPaths } from '../lib' -import c from '../lib/colors' - -const isUsingBabelRc = () => { - return ( - fg.sync('{web,api}/.babelrc(.*)?', { - cwd: getPaths().base, - ignore: '**/node_modules', - }).length > 0 - ) -} -const BABEL_SETTINGS_LINK = - 'https://redwoodjs.com/docs/project-configuration-dev-test-build' - -const checkForBabelConfig = () => { - if (isUsingBabelRc()) { - const messages = [ - "Looks like you're trying to configure one of your sides with a .babelrc file.", - 'These settings will be ignored, unless you use a babel.config.js file', - '', - 'Your plugins and settings will be automatically merged with', - `the Redwood built-in config, more details here: ${c.warning( - BABEL_SETTINGS_LINK - )}`, - ] - - console.log( - boxen(messages.join('\n'), { - title: 'Incorrect project configuration', - padding: { top: 0, bottom: 0, right: 1, left: 1 }, - margin: 1, - borderColor: 'red', - }) - ) - } -} - -export default checkForBabelConfig diff --git a/packages/cli/src/middleware/checkNodeVersion.js b/packages/cli/src/middleware/checkNodeVersion.js new file mode 100644 index 000000000000..f884c4401950 --- /dev/null +++ b/packages/cli/src/middleware/checkNodeVersion.js @@ -0,0 +1,26 @@ +import semver from 'semver' + +import c from '../lib/colors' + +export function checkNodeVersion() { + const checks = { ok: true } + + 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 checks + } + + checks.ok = false + checks.message = [ + `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') + + return checks +} diff --git a/packages/create-redwood-app/templates/js/.nvmrc b/packages/create-redwood-app/templates/js/.nvmrc deleted file mode 100644 index 9a2a0e219c9b..000000000000 --- a/packages/create-redwood-app/templates/js/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -v20 diff --git a/packages/create-redwood-app/templates/js/README.md b/packages/create-redwood-app/templates/js/README.md index 08f58865b056..60a38fe2c6ac 100644 --- a/packages/create-redwood-app/templates/js/README.md +++ b/packages/create-redwood-app/templates/js/README.md @@ -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: diff --git a/packages/create-redwood-app/templates/js/package.json b/packages/create-redwood-app/templates/js/package.json index 25e637ddcff7..1ab4a33bedab 100644 --- a/packages/create-redwood-app/templates/js/package.json +++ b/packages/create-redwood-app/templates/js/package.json @@ -14,8 +14,7 @@ "root": true }, "engines": { - "node": "=20.x", - "yarn": ">=1.22.21" + "node": "=20.x" }, "prisma": { "seed": "yarn rw exec seed" diff --git a/packages/create-redwood-app/templates/ts/.nvmrc b/packages/create-redwood-app/templates/ts/.nvmrc deleted file mode 100644 index 9a2a0e219c9b..000000000000 --- a/packages/create-redwood-app/templates/ts/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -v20 diff --git a/packages/create-redwood-app/templates/ts/README.md b/packages/create-redwood-app/templates/ts/README.md index 08f58865b056..60a38fe2c6ac 100644 --- a/packages/create-redwood-app/templates/ts/README.md +++ b/packages/create-redwood-app/templates/ts/README.md @@ -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: diff --git a/packages/create-redwood-app/templates/ts/package.json b/packages/create-redwood-app/templates/ts/package.json index 25e637ddcff7..1ab4a33bedab 100644 --- a/packages/create-redwood-app/templates/ts/package.json +++ b/packages/create-redwood-app/templates/ts/package.json @@ -14,8 +14,7 @@ "root": true }, "engines": { - "node": "=20.x", - "yarn": ">=1.22.21" + "node": "=20.x" }, "prisma": { "seed": "yarn rw exec seed" diff --git a/packages/create-redwood-app/tests/template.test.js b/packages/create-redwood-app/tests/template.test.js index 6e7ade0722d5..be6cd2cc29c6 100644 --- a/packages/create-redwood-app/tests/template.test.js +++ b/packages/create-redwood-app/tests/template.test.js @@ -12,7 +12,6 @@ describe('template', () => { "/.env", "/.env.defaults", "/.env.example", - "/.nvmrc", "/.vscode", "/.vscode/extensions.json", "/.vscode/launch.json", @@ -96,7 +95,6 @@ describe('JS template', () => { "/.env", "/.env.defaults", "/.env.example", - "/.nvmrc", "/.vscode", "/.vscode/extensions.json", "/.vscode/launch.json",