diff --git a/.github/actions/set-up-job/action.yml b/.github/actions/set-up-job/action.yml index 082f60a181..04bc58b997 100644 --- a/.github/actions/set-up-job/action.yml +++ b/.github/actions/set-up-job/action.yml @@ -33,7 +33,7 @@ runs: - name: ⬢ Set up Node.js uses: actions/setup-node@v4 with: - node-version: 20 + node-version: 24 # We have to enable Corepack again for Windows. 🤷 # In general, we're waiting on [this issue](https://github.com/actions/setup-node/issues/531) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 77facd53d4..15ff2c6ca3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,14 +83,14 @@ jobs: matrix: os: [ubuntu-latest, windows-latest] - name: 🏗 Build, lint, test / ${{ matrix.os }} / node 20 latest + name: 🏗 Build, lint, test / ${{ matrix.os }} / node 24 latest uses: ./.github/workflows/build-lint-test.yml with: os: ${{ matrix.os }} tutorial-e2e: needs: check - name: 🌲 Tutorial E2E / node 20 latest + name: 🌲 Tutorial E2E / node 24 latest uses: ./.github/workflows/tutorial-e2e.yml smoke-tests: @@ -100,7 +100,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest] - name: 🔄 Smoke tests / ${{ matrix.os }} / node 20 latest + name: 🔄 Smoke tests / ${{ matrix.os }} / node 24 latest uses: ./.github/workflows/smoke-tests-test.yml with: os: ${{ matrix.os }} @@ -112,7 +112,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest] - name: 🔄 Smoke tests React 18 / ${{ matrix.os }} / node 20 latest + name: 🔄 Smoke tests React 18 / ${{ matrix.os }} / node 24 latest uses: ./.github/workflows/smoke-tests-react-18-test.yml with: os: ${{ matrix.os }} @@ -124,7 +124,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest] - name: 🔄 Smoke tests ESM / ${{ matrix.os }} / node 20 latest + name: 🔄 Smoke tests ESM / ${{ matrix.os }} / node 24 latest uses: ./.github/workflows/smoke-tests-test-esm.yml with: os: ${{ matrix.os }} @@ -136,7 +136,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest] - name: 🔄 CLI smoke tests / ${{ matrix.os }} / node 20 latest + name: 🔄 CLI smoke tests / ${{ matrix.os }} / node 24 latest uses: ./.github/workflows/cli-smoke-tests.yml with: os: ${{ matrix.os }} @@ -148,7 +148,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest] - name: 🔭 Telemetry check / ${{ matrix.os }} / node 20 latest + name: 🔭 Telemetry check / ${{ matrix.os }} / node 24 latest uses: ./.github/workflows/telemetry-check.yml with: os: ${{ matrix.os }} diff --git a/.github/workflows/create-cedar-app-test.yml b/.github/workflows/create-cedar-app-test.yml index 79a222dd15..126fbc92a0 100644 --- a/.github/workflows/create-cedar-app-test.yml +++ b/.github/workflows/create-cedar-app-test.yml @@ -55,7 +55,7 @@ jobs: - name: ⬢ Set up Node.js uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: - node-version: 18 + node-version: 20 - name: Prompt tests run: ./tests/e2e_prompts_node_less.sh @@ -66,7 +66,7 @@ jobs: - name: ⬢ Set up Node.js uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: - node-version: 21 + node-version: 25 - name: Prompt tests run: ./tests/e2e_prompts_node_greater.sh diff --git a/.github/workflows/publish-release-candidate.yml b/.github/workflows/publish-release-candidate.yml index 9c9f6b2ce3..642527c730 100644 --- a/.github/workflows/publish-release-candidate.yml +++ b/.github/workflows/publish-release-candidate.yml @@ -33,7 +33,7 @@ jobs: - name: ⬢ Set up Node.js uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: - node-version: 20 + node-version: 24 - name: 🏷 Check git tags run: | diff --git a/.github/workflows/require-milestone.yml b/.github/workflows/require-milestone.yml index 4346cd545a..8ea5ae209c 100644 --- a/.github/workflows/require-milestone.yml +++ b/.github/workflows/require-milestone.yml @@ -24,7 +24,7 @@ jobs: - name: ⬢ Set up Node.js uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: - node-version: 20 + node-version: 24 - name: ✅ Check milestone uses: ./.github/actions/require-milestone diff --git a/.github/workflows/require-release-label.yml b/.github/workflows/require-release-label.yml index ef329d57ad..2edf368b38 100644 --- a/.github/workflows/require-release-label.yml +++ b/.github/workflows/require-release-label.yml @@ -26,7 +26,7 @@ jobs: - name: ⬢ Set up Node.js uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: - node-version: 20 + node-version: 24 - name: ✅ Check release label requirement uses: ./.github/actions/require-release-label-or-cc-message diff --git a/README.md b/README.md index 768e450100..4ac892f5de 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,7 @@ what you use so I know what to keep and what to remove! - [ ] Future major version: Make it possible to switch existing Cedar apps to ESM - [ ] Enable strict mode for new Cedar TypeScript apps. -- [ ] Upgrade to Node 24 +- [x] Upgrade to Node 24 - [x] Setup dependabot/renovate to automatically merge PRs that pass all checks - [x] Move to Vitest for Cedar ESM apps diff --git a/__fixtures__/esm-fragment-test-project/package.json b/__fixtures__/esm-fragment-test-project/package.json index e403c327ae..1e4546131f 100644 --- a/__fixtures__/esm-fragment-test-project/package.json +++ b/__fixtures__/esm-fragment-test-project/package.json @@ -18,7 +18,7 @@ "root": true }, "engines": { - "node": "=20.x" + "node": "=24.x" }, "prisma": { "seed": "yarn rw exec seed" diff --git a/__fixtures__/esm-test-project/package.json b/__fixtures__/esm-test-project/package.json index b6623fdc29..3a19e807ee 100644 --- a/__fixtures__/esm-test-project/package.json +++ b/__fixtures__/esm-test-project/package.json @@ -19,7 +19,7 @@ "root": true }, "engines": { - "node": "=20.x" + "node": "=24.x" }, "prisma": { "seed": "yarn rw exec seed" diff --git a/__fixtures__/fragment-test-project/package.json b/__fixtures__/fragment-test-project/package.json index 5cabb12f83..6885df607b 100644 --- a/__fixtures__/fragment-test-project/package.json +++ b/__fixtures__/fragment-test-project/package.json @@ -16,7 +16,7 @@ "root": true }, "engines": { - "node": "=20.x" + "node": "=24.x" }, "prisma": { "seed": "yarn rw exec seed" diff --git a/__fixtures__/rsc-caching/package.json b/__fixtures__/rsc-caching/package.json index f9878c8e77..5fa81a7ecd 100644 --- a/__fixtures__/rsc-caching/package.json +++ b/__fixtures__/rsc-caching/package.json @@ -15,7 +15,7 @@ "root": true }, "engines": { - "node": "=20.x" + "node": "=24.x" }, "prisma": { "seed": "yarn rw exec seed" diff --git a/__fixtures__/test-project-rsa/package.json b/__fixtures__/test-project-rsa/package.json index eef76d09ac..da343dbb20 100644 --- a/__fixtures__/test-project-rsa/package.json +++ b/__fixtures__/test-project-rsa/package.json @@ -14,7 +14,7 @@ "root": true }, "engines": { - "node": "=20.x" + "node": "=24.x" }, "prisma": { "seed": "yarn rw exec seed" diff --git a/__fixtures__/test-project-rsc-kitchen-sink/package.json b/__fixtures__/test-project-rsc-kitchen-sink/package.json index f9878c8e77..5fa81a7ecd 100644 --- a/__fixtures__/test-project-rsc-kitchen-sink/package.json +++ b/__fixtures__/test-project-rsc-kitchen-sink/package.json @@ -15,7 +15,7 @@ "root": true }, "engines": { - "node": "=20.x" + "node": "=24.x" }, "prisma": { "seed": "yarn rw exec seed" diff --git a/__fixtures__/test-project/package.json b/__fixtures__/test-project/package.json index 3c71316fbd..6929c0b074 100644 --- a/__fixtures__/test-project/package.json +++ b/__fixtures__/test-project/package.json @@ -17,7 +17,7 @@ "root": true }, "engines": { - "node": "=20.x" + "node": "=24.x" }, "prisma": { "seed": "yarn rw exec seed" diff --git a/docs/.node-version b/docs/.node-version deleted file mode 100644 index d4b7699d36..0000000000 --- a/docs/.node-version +++ /dev/null @@ -1 +0,0 @@ -20.18.1 diff --git a/docs/docs/how-to/test-in-github-actions.md b/docs/docs/how-to/test-in-github-actions.md index 575c776891..d9ea36945b 100644 --- a/docs/docs/how-to/test-in-github-actions.md +++ b/docs/docs/how-to/test-in-github-actions.md @@ -204,7 +204,7 @@ jobs: strategy: matrix: - node-version: [20.x] + node-version: [24.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ services: @@ -302,7 +302,7 @@ jobs: strategy: matrix: - node-version: [20.x] + node-version: [24.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ services: diff --git a/docs/docs/quick-start.md b/docs/docs/quick-start.md index 7aec63e9de..941c8383d3 100644 --- a/docs/docs/quick-start.md +++ b/docs/docs/quick-start.md @@ -6,7 +6,7 @@ description: CedarJS quick start :::info Prerequisites -- CedarJS requires [Node.js](https://nodejs.org/en/) (=20.19.x) and +- CedarJS requires [Node.js](https://nodejs.org/en/) (=24.x) and [Yarn](https://yarnpkg.com/) (>=1.22.21) - Are you on Windows? For best results, follow our [Windows development setup](how-to/windows-development-setup.md) guide diff --git a/packages/cli/src/lib/background.js b/packages/cli/src/lib/background.js index e9efcf6847..f21bc7675c 100644 --- a/packages/cli/src/lib/background.js +++ b/packages/cli/src/lib/background.js @@ -43,22 +43,28 @@ export function spawnBackgroundProcess(name, cmd, args) { fs.writeSync(stderr, logHeader) // We must account for some platform specific behaviour - const spawnOptions = - os.type() === 'Windows_NT' - ? { - // The following options run the process in the background without a console window, even though they don't look like they would. - // See https://github.com/nodejs/node/issues/21825#issuecomment-503766781 for information - detached: false, - windowsHide: false, - shell: true, - stdio: ['ignore', stdout, stderr], - } - : { - detached: true, - stdio: ['ignore', stdout, stderr], - } + if (os.type() === 'Windows_NT') { + const spawnOptions = { + // The following options run the process in the background without a + // console window, even though they don't look like they would. + // See https://github.com/nodejs/node/issues/21825#issuecomment-503766781 + // for information. + detached: false, + windowsHide: false, + shell: true, + stdio: ['ignore', stdout, stderr], + } - // Spawn and detach the process - const child = spawn(cmd, args, spawnOptions) - child.unref() + // Spawn and detach the process + const child = spawn(cmd + ' ' + args.join(' '), spawnOptions) + child.unref() + } else { + const spawnOptions = { + detached: true, + stdio: ['ignore', stdout, stderr], + } + // Spawn and detach the process + const child = spawn(cmd, args, spawnOptions) + child.unref() + } } diff --git a/packages/cli/src/middleware/checkNodeVersion.js b/packages/cli/src/middleware/checkNodeVersion.js index 05c1556119..ab1cd953ee 100644 --- a/packages/cli/src/middleware/checkNodeVersion.js +++ b/packages/cli/src/middleware/checkNodeVersion.js @@ -7,19 +7,18 @@ 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) + const LOWER_BOUND = 'v24.0.0' - if (semver.gt(pVersionC, LOWER_BOUND_C)) { + if (semver.gte(pVersionC, LOWER_BOUND)) { return checks } checks.ok = false checks.message = [ - `Your Node.js version is ${c.warning( - pVersion, - )}, but Redwood requires ${c.important(`>=${LOWER_BOUND}`)}.`, - 'Upgrade your Node.js version using `nvm` or a similar tool. See https://redwoodjs.com/docs/how-to/using-nvm.', + `Your Node.js version is ${c.warning(pVersion)}, but Cedar requires ` + + `${c.important(`>= ${LOWER_BOUND}`)}.`, + 'Upgrade your Node.js version using `nvm`, `n`, or a similar tool. See ' + + 'https://cedarjs.com/docs/how-to/using-nvm.', ].join('\n') return checks diff --git a/packages/create-cedar-app/src/create-cedar-app.js b/packages/create-cedar-app/src/create-cedar-app.js index f490661263..766e3375ed 100644 --- a/packages/create-cedar-app/src/create-cedar-app.js +++ b/packages/create-cedar-app/src/create-cedar-app.js @@ -168,8 +168,8 @@ async function executeCompatibilityCheck(templateDir) { } /** - * - * This type has to be updated if the engines field in the create redwood app template package.json is updated. + * This type has to be updated if the engines field in the create cedar app + * template package.json is updated. * @returns [boolean, Record<'node' | 'yarn', any>] */ function checkNodeVersion(templateDir) { diff --git a/packages/create-cedar-app/templates/esm-js/package.json b/packages/create-cedar-app/templates/esm-js/package.json index 1b74c5fff9..09a95eba2e 100644 --- a/packages/create-cedar-app/templates/esm-js/package.json +++ b/packages/create-cedar-app/templates/esm-js/package.json @@ -18,7 +18,7 @@ "root": true }, "engines": { - "node": "=20.x" + "node": "=24.x" }, "prisma": { "seed": "yarn rw exec seed" diff --git a/packages/create-cedar-app/templates/esm-ts/package.json b/packages/create-cedar-app/templates/esm-ts/package.json index 1b74c5fff9..09a95eba2e 100644 --- a/packages/create-cedar-app/templates/esm-ts/package.json +++ b/packages/create-cedar-app/templates/esm-ts/package.json @@ -18,7 +18,7 @@ "root": true }, "engines": { - "node": "=20.x" + "node": "=24.x" }, "prisma": { "seed": "yarn rw exec seed" diff --git a/packages/create-cedar-app/templates/js/package.json b/packages/create-cedar-app/templates/js/package.json index d127ee09bb..5c97300416 100644 --- a/packages/create-cedar-app/templates/js/package.json +++ b/packages/create-cedar-app/templates/js/package.json @@ -16,7 +16,7 @@ "root": true }, "engines": { - "node": "=20.x" + "node": "=24.x" }, "prisma": { "seed": "yarn rw exec seed" diff --git a/packages/create-cedar-app/templates/ts/package.json b/packages/create-cedar-app/templates/ts/package.json index d127ee09bb..5c97300416 100644 --- a/packages/create-cedar-app/templates/ts/package.json +++ b/packages/create-cedar-app/templates/ts/package.json @@ -16,7 +16,7 @@ "root": true }, "engines": { - "node": "=20.x" + "node": "=24.x" }, "prisma": { "seed": "yarn rw exec seed" diff --git a/packages/create-cedar-rsc-app/src/latest.ts b/packages/create-cedar-rsc-app/src/latest.ts index d50ff0cbec..69fa3a855d 100644 --- a/packages/create-cedar-rsc-app/src/latest.ts +++ b/packages/create-cedar-rsc-app/src/latest.ts @@ -5,12 +5,12 @@ import process from 'node:process' import type { Config } from './config.js' import { ExitCodeError } from './error.js' -import { getCrxrscaVersion } from './version.js' +import { getCcrscaVersion } from './version.js' export function shouldRelaunch(config: Config) { if (config.verbose) { console.log('shouldRelaunch process.argv', process.argv) - console.log('shouldRelaunch crwrsca version', getCrxrscaVersion()) + console.log('shouldRelaunch crwrsca version', getCcrscaVersion()) } if (process.argv.includes('--no-check-latest')) { diff --git a/packages/create-cedar-rsc-app/src/messages.ts b/packages/create-cedar-rsc-app/src/messages.ts index 547f980977..535731c4a7 100644 --- a/packages/create-cedar-rsc-app/src/messages.ts +++ b/packages/create-cedar-rsc-app/src/messages.ts @@ -1,7 +1,7 @@ import ansis from 'ansis' import type { Config } from './config.js' -import { getCrxrscaVersion } from './version.js' +import { getCcrscaVersion } from './version.js' export function printWelcome() { console.log() @@ -10,7 +10,7 @@ export function printWelcome() { .hex('#bf4722') .bold( '🌲 Welcome to the Cedar RSC quick-start installer ' + - `v${getCrxrscaVersion()} 🌲`, + `v${getCcrscaVersion()} 🌲`, ), ) console.log() diff --git a/packages/create-cedar-rsc-app/src/prerequisites.ts b/packages/create-cedar-rsc-app/src/prerequisites.ts index ec639ef9c6..bd495556b9 100644 --- a/packages/create-cedar-rsc-app/src/prerequisites.ts +++ b/packages/create-cedar-rsc-app/src/prerequisites.ts @@ -26,12 +26,9 @@ export function checkNodeVersion(config: Config) { console.log('Node version:', version) } - // https://github.com/redwoodjs/redwood/issues/10492#issuecomment-2076063552 - // The comment above and the one after explains why we check specifically - // for >= 20.10.0 - if (!semver.satisfies(version, '>=20.10')) { - console.error('❌Your Node.js version must be >=20.10.0') - console.error('Please install or switch to a newer version of Node') + if (!semver.satisfies(version, '=24')) { + console.error('❌You must be using Node.js version 24') + console.error('Please install or switch to the correct version of Node') console.error( 'We recommend using a Node version manager like `fnm`, `nvm` or `n`', ) diff --git a/packages/create-cedar-rsc-app/src/version.ts b/packages/create-cedar-rsc-app/src/version.ts index 81863e9c6c..152aef546d 100644 --- a/packages/create-cedar-rsc-app/src/version.ts +++ b/packages/create-cedar-rsc-app/src/version.ts @@ -1,6 +1,6 @@ import fs from 'node:fs' -export function getCrxrscaVersion() { +export function getCcrscaVersion() { const packageJson = JSON.parse( fs.readFileSync(new URL('../package.json', import.meta.url), 'utf-8'), ) @@ -10,5 +10,5 @@ export function getCrxrscaVersion() { } export function printVersion() { - console.log(`create-cedar-rsc-app v${getCrxrscaVersion()}`) + console.log(`create-cedar-rsc-app v${getCcrscaVersion()}`) } diff --git a/packages/storybook/package.json b/packages/storybook/package.json index d213a0dc4b..0806c4ef3f 100644 --- a/packages/storybook/package.json +++ b/packages/storybook/package.json @@ -78,7 +78,7 @@ "storybook": "7.6.20" }, "engines": { - "node": "=20.x" + "node": "=24.x" }, "publishConfig": { "access": "public" diff --git a/tasks/e2e-background-jobs/run.mts b/tasks/e2e-background-jobs/run.mts index d593d8b41e..b9000b3b0d 100644 --- a/tasks/e2e-background-jobs/run.mts +++ b/tasks/e2e-background-jobs/run.mts @@ -2,6 +2,24 @@ import process from 'node:process' import { $, cd, path, ProcessOutput, fs } from 'zx' +// Suppress DEP0190 warning on Windows for zx shell usage +// This warning occurs because zx uses `shell: true` with child processes on Windows +// which triggers Node.js DEP0190: "Passing args to a child process with shell option true +// can lead to security vulnerabilities, as the arguments are not escaped, only concatenated." +// Since zx handles argument escaping internally, this warning is safe to suppress for our use case. +if (process.platform === 'win32') { + process.removeAllListeners('warning') + process.on('warning', (warning) => { + if ( + warning.name === 'DeprecationWarning' && + warning.message.includes('DEP0190') + ) { + return // Ignore DEP0190 warnings + } + console.warn(warning) + }) +} + import { JOBS_SCRIPT, PRISMA_SCRIPT, @@ -138,10 +156,8 @@ async function runJobsSetup(projectPath: string) { } console.log('Confirmed: job config file exists') - const jobsTs = fs.readFileSync( - path.join(projectPath, 'api/src/lib/jobs.ts'), - 'utf8', - ) + const jobsPath = path.join(projectPath, 'api/src/lib/jobs.ts') + const jobsTs = fs.readFileSync(jobsPath, 'utf8') if (!/import \{.*JobManager.*\} from ['"]@cedarjs\/jobs['"]/.test(jobsTs)) { console.error( @@ -162,11 +178,7 @@ async function runJobsSetup(projectPath: string) { console.log('Action: Altering the JobManager config to poll more often') const updatedJobsTs = jobsTs.replace('sleepDelay: 5', 'sleepDelay: 1') - fs.writeFileSync( - path.join(projectPath, 'api/src/lib/jobs.ts'), - updatedJobsTs, - 'utf8', - ) + fs.writeFileSync(jobsPath, updatedJobsTs, 'utf8') // Confirm jobs directory if ( diff --git a/tasks/server-tests/fixtures/redwood-app/package.json b/tasks/server-tests/fixtures/redwood-app/package.json index dafd12c5a2..408e44b742 100644 --- a/tasks/server-tests/fixtures/redwood-app/package.json +++ b/tasks/server-tests/fixtures/redwood-app/package.json @@ -22,7 +22,7 @@ }, "packageManager": "yarn@4.9.4", "engines": { - "node": "=20.x" + "node": "=24.x" }, "prisma": { "seed": "yarn rw exec seed" diff --git a/tasks/test-project/rebuild-test-project-fixture-esm.ts b/tasks/test-project/rebuild-test-project-fixture-esm.ts index c758f5e1e3..c81a23aa88 100755 --- a/tasks/test-project/rebuild-test-project-fixture-esm.ts +++ b/tasks/test-project/rebuild-test-project-fixture-esm.ts @@ -13,31 +13,45 @@ import { RedwoodTUI, ReactiveTUIContent, RedwoodStyling } from '@cedarjs/tui' import { addFrameworkDepsToProject, copyFrameworkPackages, -} from './frameworkLinking' -import { webTasks, apiTasks } from './tui-tasks' -import { isAwaitable, isTuiError } from './typing' -import type { TuiTaskDef } from './typing' +} from './frameworkLinking.js' +import { webTasks, apiTasks } from './tui-tasks.js' +import { isAwaitable, isTuiError } from './typing.js' +import type { TuiTaskDef } from './typing.js' import { getExecaOptions as utilGetExecaOptions, updatePkgJsonScripts, ExecaError, exec, -} from './util' +} from './util.js' const ansis = require('ansis') +function recommendedNodeVersion() { + const templatePackageJsonPath = path.join( + __dirname, + '..', + '..', + 'packages', + 'create-cedar-app', + 'templates', + 'ts', + 'package.json', + ) + console.log('templatePackageJsonPath:', templatePackageJsonPath) + const json = JSON.parse(fs.readFileSync(templatePackageJsonPath, 'utf8')) + + return json.engines.node +} + // If the current Node.js version is outside of the recommended range the Cedar // setup command will pause and ask the user if they want to continue. This // hangs this script without any information to the user that tries to rebuild // the test-project. It's better to fail early so the correct node version can // be installed. -if ( - semver.lt(process.version, '20.0.0') || - semver.gte(process.version, '21.0.0') -) { +if (!semver.satisfies(process.version, recommendedNodeVersion())) { console.error('Unsupported Node.js version') console.error(' You are using:', process.version) - console.error(' Supported version:', 'v20') + console.error(' Supported version:', recommendedNodeVersion()) process.exit(1) } diff --git a/tasks/test-project/rebuild-test-project-fixture.ts b/tasks/test-project/rebuild-test-project-fixture.ts index c38dcccb54..14d4d7a49d 100755 --- a/tasks/test-project/rebuild-test-project-fixture.ts +++ b/tasks/test-project/rebuild-test-project-fixture.ts @@ -26,18 +26,32 @@ import { const ansis = require('ansis') +function recommendedNodeVersion() { + const templatePackageJsonPath = path.join( + __dirname, + '..', + '..', + 'packages', + 'create-cedar-app', + 'templates', + 'ts', + 'package.json', + ) + console.log('templatePackageJsonPath:', templatePackageJsonPath) + const json = JSON.parse(fs.readFileSync(templatePackageJsonPath, 'utf8')) + + return json.engines.node +} + // If the current Node.js version is outside of the recommended range the Cedar // setup command will pause and ask the user if they want to continue. This // hangs this script without any information to the user that tries to rebuild // the test-project. It's better to fail early so the correct node version can // be installed. -if ( - semver.lt(process.version, '20.0.0') || - semver.gte(process.version, '21.0.0') -) { +if (!semver.satisfies(process.version, recommendedNodeVersion())) { console.error('Unsupported Node.js version') console.error(' You are using:', process.version) - console.error(' Supported version:', 'v20') + console.error(' Supported version:', recommendedNodeVersion()) process.exit(1) }