From dae7eb02bae7e2a18de3ce45882135dbcbcd2e21 Mon Sep 17 00:00:00 2001 From: Ian Schmitz Date: Sun, 3 May 2020 16:26:06 -0700 Subject: [PATCH 1/7] Drop Node 8 support --- azure-pipelines-test-job.yml | 8 +-- azure-pipelines.yml | 31 +++------- docusaurus/docs/getting-started.md | 2 +- packages/cra-template-typescript/package.json | 2 +- packages/cra-template/package.json | 2 +- packages/create-react-app/createReactApp.js | 16 ++--- packages/create-react-app/package.json | 2 +- packages/react-app-polyfill/package.json | 2 +- packages/react-dev-utils/package.json | 2 +- packages/react-scripts/package.json | 2 +- tasks/e2e-old-node.sh | 2 +- tasks/e2e-typescript-unsupported-node.sh | 61 ------------------- 12 files changed, 25 insertions(+), 107 deletions(-) delete mode 100755 tasks/e2e-typescript-unsupported-node.sh diff --git a/azure-pipelines-test-job.yml b/azure-pipelines-test-job.yml index 7073bf3eab6..9ea9c49f199 100644 --- a/azure-pipelines-test-job.yml +++ b/azure-pipelines-test-job.yml @@ -6,10 +6,10 @@ parameters: name: '' testScript: '' configurations: - LinuxNode8: { vmImage: 'ubuntu-16.04', nodeVersion: 8.x } - LinuxNode10: { vmImage: 'ubuntu-16.04', nodeVersion: 10.x } - # WindowsNode8: { vmImage: 'vs2017-win2016', nodeVersion: 8.x } - # WindowsNode10: { vmImage: 'vs2017-win2016', nodeVersion: 10.x } + LinuxNode10: { vmImage: 'ubuntu-latest', nodeVersion: 10.x } + LinuxNode12: { vmImage: 'ubuntu-latest', nodeVersion: 12.x } + # WindowsNode10: { vmImage: 'windows-latest', nodeVersion: 10.x } + # WindowsNode12: { vmImage: 'windows-latest', nodeVersion: 12.x } jobs: - job: ${{ parameters.name }} diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8021fb92668..1888e5aff03 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -57,36 +57,23 @@ jobs: name: Behavior testScript: tasks/e2e-behavior.sh configurations: - LinuxNode8: { vmImage: 'ubuntu-18.04', nodeVersion: 8.x } - LinuxNode10: { vmImage: 'ubuntu-18.04', nodeVersion: 10.x } - # WindowsNode8: { vmImage: 'vs2017-win2016', nodeVersion: 8.x } - # WindowsNode10: { vmImage: 'vs2017-win2016', nodeVersion: 10.x } - MacNode8: { vmImage: 'macOS-10.15', nodeVersion: 8.x } - MacNode10: { vmImage: 'macOS-10.15', nodeVersion: 10.x } + LinuxNode10: { vmImage: 'ubuntu-latest', nodeVersion: 10.x } + LinuxNode12: { vmImage: 'ubuntu-latest', nodeVersion: 12.x } + # WindowsNode10: { vmImage: 'windows-latest', nodeVersion: 10.x } + # WindowsNode12: { vmImage: 'windows-latest', nodeVersion: 12.x } + MacNode10: { vmImage: 'macOS-latest', nodeVersion: 10.x } + MacNode12: { vmImage: 'macOS-latest', nodeVersion: 12.x } # ****************************************************************************** # Old Node test suite # ****************************************************************************** - job: OldNode pool: - vmImage: ubuntu-16.04 + vmImage: ubuntu-latest steps: - task: NodeTool@0 inputs: - versionSpec: 6.x - displayName: 'Install Node.js 6.x' + versionSpec: 10.x + displayName: 'Install Node.js 10.x' - bash: tasks/e2e-old-node.sh displayName: 'Run tests' - # ****************************************************************************** - # Unsupported Node with TypeScript flag - # ****************************************************************************** - - job: UnsupportedNodeWithTypeScript - pool: - vmImage: ubuntu-16.04 - steps: - - task: NodeTool@0 - inputs: - versionSpec: 8.9.x - displayName: 'Install Node.js 8.9.x' - - bash: tasks/e2e-typescript-unsupported-node.sh - displayName: 'Run unsupported TypeScript test' diff --git a/docusaurus/docs/getting-started.md b/docusaurus/docs/getting-started.md index f23236110b3..9418ca03c07 100644 --- a/docusaurus/docs/getting-started.md +++ b/docusaurus/docs/getting-started.md @@ -34,7 +34,7 @@ Create a project, and you’re good to go. ## Creating an App -**You’ll need to have Node >= 8.10 on your local development machine** (but it’s not required on the server). You can use [nvm](https://github.com/creationix/nvm#installation) (macOS/Linux) or [nvm-windows](https://github.com/coreybutler/nvm-windows#node-version-manager-nvm-for-windows) to switch Node versions between different projects. +**You’ll need to have Node >= 10 on your local development machine** (but it’s not required on the server). You can use [nvm](https://github.com/creationix/nvm#installation) (macOS/Linux) or [nvm-windows](https://github.com/coreybutler/nvm-windows#node-version-manager-nvm-for-windows) to switch Node versions between different projects. To create a new app, you may choose one of the following methods: diff --git a/packages/cra-template-typescript/package.json b/packages/cra-template-typescript/package.json index 4c16d0c0a3a..5b3936acf4c 100644 --- a/packages/cra-template-typescript/package.json +++ b/packages/cra-template-typescript/package.json @@ -15,7 +15,7 @@ }, "license": "MIT", "engines": { - "node": ">=8.10" + "node": ">=10" }, "bugs": { "url": "https://github.com/facebook/create-react-app/issues" diff --git a/packages/cra-template/package.json b/packages/cra-template/package.json index f28004102ff..d34d8229b6f 100644 --- a/packages/cra-template/package.json +++ b/packages/cra-template/package.json @@ -14,7 +14,7 @@ }, "license": "MIT", "engines": { - "node": ">=8" + "node": ">=10" }, "bugs": { "url": "https://github.com/facebook/create-react-app/issues" diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index 4d39b208767..1aed5cb7887 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -203,20 +203,12 @@ function createApp( usePnp, useTypeScript ) { - const unsupportedNodeVersion = !semver.satisfies(process.version, '>=8.10.0'); - if (unsupportedNodeVersion && useTypeScript) { - console.error( - chalk.red( - `You are using Node ${process.version} with the TypeScript template. Node 8.10 or higher is required to use TypeScript.\n` - ) - ); - - process.exit(1); - } else if (unsupportedNodeVersion) { + const unsupportedNodeVersion = !semver.satisfies(process.version, '>=10'); + if (unsupportedNodeVersion) { console.log( chalk.yellow( `You are using Node ${process.version} so the project will be bootstrapped with an old unsupported version of tools.\n\n` + - `Please update to Node 8.10 or higher for a better, fully supported experience.\n` + `Please update to Node 10 or higher for a better, fully supported experience.\n` ) ); // Fall back to latest supported react-scripts on Node 4 @@ -516,7 +508,7 @@ function run( console.log( chalk.yellow( `\nNote: the project was bootstrapped with an old unsupported version of tools.\n` + - `Please update to Node >=8.10 and npm >=5 to get supported tools in new projects.\n` + `Please update to Node >=10 and npm >=6 to get supported tools in new projects.\n` ) ); } diff --git a/packages/create-react-app/package.json b/packages/create-react-app/package.json index 79bde839a0e..9f8f69cce6f 100644 --- a/packages/create-react-app/package.json +++ b/packages/create-react-app/package.json @@ -12,7 +12,7 @@ }, "license": "MIT", "engines": { - "node": ">=8" + "node": ">=10" }, "bugs": { "url": "https://github.com/facebook/create-react-app/issues" diff --git a/packages/react-app-polyfill/package.json b/packages/react-app-polyfill/package.json index b48d4f185e1..21fc0986a5f 100644 --- a/packages/react-app-polyfill/package.json +++ b/packages/react-app-polyfill/package.json @@ -12,7 +12,7 @@ "url": "https://github.com/facebook/create-react-app/issues" }, "engines": { - "node": ">=6" + "node": ">=10" }, "files": [ "ie9.js", diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 36ea5b34047..3051b2bf3a2 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -12,7 +12,7 @@ "url": "https://github.com/facebook/create-react-app/issues" }, "engines": { - "node": ">=8.10" + "node": ">=10" }, "files": [ "browsersHelper.js", diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index a5983f373c2..119dab883e2 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -9,7 +9,7 @@ }, "license": "MIT", "engines": { - "node": ">=8.10" + "node": ">=10" }, "bugs": { "url": "https://github.com/facebook/create-react-app/issues" diff --git a/tasks/e2e-old-node.sh b/tasks/e2e-old-node.sh index 8245dd24e50..1022662ce81 100755 --- a/tasks/e2e-old-node.sh +++ b/tasks/e2e-old-node.sh @@ -52,7 +52,7 @@ cd "$root_path"/packages/create-react-app npm install cd "$root_path" -# If the node version is < 6, the script should just give an error. +# If the node version is < 10, the script should just give an error. cd $temp_app_path err_output=`node "$root_path"/packages/create-react-app/index.js test-node-version 2>&1 > /dev/null || echo ''` [[ $err_output =~ You\ are\ running\ Node ]] && exit 0 || exit 1 diff --git a/tasks/e2e-typescript-unsupported-node.sh b/tasks/e2e-typescript-unsupported-node.sh deleted file mode 100755 index 0be6e6b4636..00000000000 --- a/tasks/e2e-typescript-unsupported-node.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash -# Copyright (c) 2015-present, Facebook, Inc. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -# ****************************************************************************** -# This is an end-to-end test intended to run on CI. -# You can also run it locally but it's slow. -# ****************************************************************************** - -# Start in tasks/ even if run from root directory -cd "$(dirname "$0")" - -temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'` - -function cleanup { - echo 'Cleaning up.' - cd "$root_path" - rm -rf $temp_app_path -} - -# Error messages are redirected to stderr -function handle_error { - echo "$(basename $0): ERROR! An error was encountered executing line $1." 1>&2; - cleanup - echo 'Exiting with error.' 1>&2; - exit 1 -} - -function handle_exit { - cleanup - echo 'Exiting without error.' 1>&2; - exit -} - -# Exit the script with a helpful error message when any error is encountered -trap 'set +x; handle_error $LINENO $BASH_COMMAND' ERR - -# Cleanup before exit on any termination signal -trap 'set +x; handle_exit' SIGQUIT SIGTERM SIGINT SIGKILL SIGHUP - -# Echo every command being executed -set -x - -# Go to root -cd .. -root_path=$PWD - -# We need to install create-react-app deps to test it -cd "$root_path"/packages/create-react-app -npm install -cd "$root_path" - -# If the node version is < 8.10 but greater then 8.0, the script with the typescript flag should just give an error. -cd $temp_app_path -err_output=`node "$root_path"/packages/create-react-app/index.js test-node-version --typescript 2>&1 > /dev/null || echo ''` -[[ $err_output =~ You\ are\ using\ Node ]] && exit 0 || exit 1 - -# Cleanup -cleanup From c89a789ada35eb058f5004ea4cb4335a082e66f7 Mon Sep 17 00:00:00 2001 From: Ian Schmitz Date: Sun, 3 May 2020 16:29:17 -0700 Subject: [PATCH 2/7] Fix node version for old node test suite --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1888e5aff03..6bfa268351c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -73,7 +73,7 @@ jobs: steps: - task: NodeTool@0 inputs: - versionSpec: 10.x - displayName: 'Install Node.js 10.x' + versionSpec: 8.x + displayName: 'Install Node.js 8.x' - bash: tasks/e2e-old-node.sh displayName: 'Run tests' From a16cec83f254159f2d39604d60486a93e46eca41 Mon Sep 17 00:00:00 2001 From: Ian Schmitz Date: Sun, 3 May 2020 16:45:23 -0700 Subject: [PATCH 3/7] Bump node-sass in test suite --- packages/react-scripts/fixtures/kitchensink/template.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/fixtures/kitchensink/template.json b/packages/react-scripts/fixtures/kitchensink/template.json index 954cb3b2d73..329c3393d56 100644 --- a/packages/react-scripts/fixtures/kitchensink/template.json +++ b/packages/react-scripts/fixtures/kitchensink/template.json @@ -3,7 +3,7 @@ "dependencies": { "bootstrap": "4.3.1", "jest": "24.9.0", - "node-sass": "4.12.0", + "node-sass": "4.x", "normalize.css": "7.0.0", "prop-types": "15.7.2", "test-integrity": "2.0.1" From 856b775b9fc1128f0b3a874ad23671e8572d4039 Mon Sep 17 00:00:00 2001 From: Ian Schmitz Date: Sun, 3 May 2020 16:49:20 -0700 Subject: [PATCH 4/7] Upgrade pupeteer --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 92a9291ecb3..1ce60fe1943 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "meow": "^5.0.0", "multimatch": "^3.0.0", "prettier": "1.19.1", - "puppeteer": "^2.0.0", + "puppeteer": "^3.0.2", "strip-ansi": "^5.1.0", "svg-term-cli": "^2.1.1", "tempy": "^0.2.1", From 258f12e769c10fec66353451ba5b5070c69a4570 Mon Sep 17 00:00:00 2001 From: Ian Schmitz Date: Sun, 3 May 2020 16:54:07 -0700 Subject: [PATCH 5/7] Fix CLI min node check --- packages/create-react-app/createReactApp.js | 4 ++-- packages/create-react-app/index.js | 4 ++-- tasks/local-test.sh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index 1aed5cb7887..f8c50fbd51d 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -252,7 +252,7 @@ function createApp( console.log( chalk.yellow( `You are using npm ${npmInfo.npmVersion} so the project will be bootstrapped with an old unsupported version of tools.\n\n` + - `Please update to npm 5 or higher for a better, fully supported experience.\n` + `Please update to npm 6 or higher for a better, fully supported experience.\n` ) ); } @@ -763,7 +763,7 @@ function checkNpmVersion() { npmVersion = execSync('npm --version') .toString() .trim(); - hasMinNpm = semver.gte(npmVersion, '5.0.0'); + hasMinNpm = semver.gte(npmVersion, '6.0.0'); } catch (err) { // ignore } diff --git a/packages/create-react-app/index.js b/packages/create-react-app/index.js index b26463f2e8a..1e068819f48 100755 --- a/packages/create-react-app/index.js +++ b/packages/create-react-app/index.js @@ -40,12 +40,12 @@ var currentNodeVersion = process.versions.node; var semver = currentNodeVersion.split('.'); var major = semver[0]; -if (major < 8) { +if (major < 10) { console.error( 'You are running Node ' + currentNodeVersion + '.\n' + - 'Create React App requires Node 8 or higher. \n' + + 'Create React App requires Node 10 or higher. \n' + 'Please update your version of Node.' ); process.exit(1); diff --git a/tasks/local-test.sh b/tasks/local-test.sh index 4a66726907a..d8005eda154 100755 --- a/tasks/local-test.sh +++ b/tasks/local-test.sh @@ -49,7 +49,7 @@ while [ "$1" != "" ]; do shift done -test_command="./tasks/e2e-simple.sh && ./tasks/e2e-kitchensink.sh && ./tasks/e2e-kitchensink-eject.sh && ./tasks/e2e-installs.sh" +test_command="./tasks/e2e-simple.sh && ./tasks/e2e-kitchensink.sh && ./tasks/e2e-kitchensink-eject.sh && ./tasks/e2e-installs.sh && ./tasks/e2e-behavior.sh" case ${test_suite} in "all") ;; From d5c6c4742649e4c549d04ff63bb6daa4950e3af3 Mon Sep 17 00:00:00 2001 From: Ian Schmitz Date: Sun, 3 May 2020 17:22:23 -0700 Subject: [PATCH 6/7] Revert to ubuntu 16.04 --- azure-pipelines-test-job.yml | 4 ++-- azure-pipelines.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/azure-pipelines-test-job.yml b/azure-pipelines-test-job.yml index 9ea9c49f199..e3b9d92b669 100644 --- a/azure-pipelines-test-job.yml +++ b/azure-pipelines-test-job.yml @@ -6,8 +6,8 @@ parameters: name: '' testScript: '' configurations: - LinuxNode10: { vmImage: 'ubuntu-latest', nodeVersion: 10.x } - LinuxNode12: { vmImage: 'ubuntu-latest', nodeVersion: 12.x } + LinuxNode10: { vmImage: 'ubuntu-16.04', nodeVersion: 10.x } + LinuxNode12: { vmImage: 'ubuntu-16.04', nodeVersion: 12.x } # WindowsNode10: { vmImage: 'windows-latest', nodeVersion: 10.x } # WindowsNode12: { vmImage: 'windows-latest', nodeVersion: 12.x } diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6bfa268351c..6f9f49df877 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -57,8 +57,8 @@ jobs: name: Behavior testScript: tasks/e2e-behavior.sh configurations: - LinuxNode10: { vmImage: 'ubuntu-latest', nodeVersion: 10.x } - LinuxNode12: { vmImage: 'ubuntu-latest', nodeVersion: 12.x } + LinuxNode10: { vmImage: 'ubuntu-16.04', nodeVersion: 10.x } + LinuxNode12: { vmImage: 'ubuntu-16.04', nodeVersion: 12.x } # WindowsNode10: { vmImage: 'windows-latest', nodeVersion: 10.x } # WindowsNode12: { vmImage: 'windows-latest', nodeVersion: 12.x } MacNode10: { vmImage: 'macOS-latest', nodeVersion: 10.x } From dfa1f89dd5f059565234ac61c62855260e4a50bf Mon Sep 17 00:00:00 2001 From: Ian Schmitz Date: Sun, 3 May 2020 17:53:50 -0700 Subject: [PATCH 7/7] Fix sass test --- .../__snapshots__/index.test.js.snap | 15 --------------- .../webpack-message-formatting/index.test.js | 6 +++++- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/test/fixtures/webpack-message-formatting/__snapshots__/index.test.js.snap b/test/fixtures/webpack-message-formatting/__snapshots__/index.test.js.snap index 9d67e100720..91042386d01 100644 --- a/test/fixtures/webpack-message-formatting/__snapshots__/index.test.js.snap +++ b/test/fixtures/webpack-message-formatting/__snapshots__/index.test.js.snap @@ -156,21 +156,6 @@ Failed to compile. Attempted import error: 'bar' is not exported from './AppUnknownExport'. -", - "stdout": "", -} -`; - -exports[`helps when users tries to use sass 1`] = ` -Object { - "stderr": "Creating an optimized production build... -Failed to compile. - -./src/AppSass.scss -To import Sass files, you first need to install node-sass. -Run \`npm install node-sass\` or \`yarn add node-sass\` inside your workspace. - - ", "stdout": "", } diff --git a/test/fixtures/webpack-message-formatting/index.test.js b/test/fixtures/webpack-message-formatting/index.test.js index f102b1cf381..977bf277a5e 100644 --- a/test/fixtures/webpack-message-formatting/index.test.js +++ b/test/fixtures/webpack-message-formatting/index.test.js @@ -97,7 +97,11 @@ test('helps when users tries to use sass', async () => { ); const { stdout, stderr } = await testSetup.scripts.build(); - expect({ stdout, stderr }).toMatchSnapshot(); + expect(stdout).toBeFalsy(); + // TODO: Snapshots differ between Node 10/12 as the call stack log output has changed. + expect(stderr).toContain( + 'To import Sass files, you first need to install node-sass.' + ); }); test('formats file not found error', async () => {