Skip to content

Commit ae19b67

Browse files
committed
Deprecate CRA
1 parent dd420a6 commit ae19b67

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
# Create React App [![Build & Test](https://github.com/facebook/create-react-app/actions/workflows/build-and-test.yml/badge.svg?branch=main)](https://github.com/facebook/create-react-app/actions/workflows/build-and-test.yml) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-green.svg)](https://github.com/facebook/create-react-app/blob/main/CONTRIBUTING.md)
1+
# Create React App is Deprecated
2+
3+
Create React App was one of the key tools for getting a React project up-and-running in 2017-2021, it is now in long-term stasis and we recommend that you migrate to one of React frameworks documented on ["Start a New React Project"](https://react.dev/learn/start-a-new-react-project).
4+
5+
If you are following a tutorial to learn React, there is still value in continuing your tutorial, but we do not recommend starting production apps based on Create React App.
6+
7+
---
8+
9+
## Create React App [![Build & Test](https://github.com/facebook/create-react-app/actions/workflows/build-and-test.yml/badge.svg?branch=main)](https://github.com/facebook/create-react-app/actions/workflows/build-and-test.yml) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-green.svg)](https://github.com/facebook/create-react-app/blob/main/CONTRIBUTING.md)
210

311
<img alt="Logo" align="right" src="https://create-react-app.dev/img/logo.svg" width="20%" />
412

packages/create-react-app/createReactApp.js

+34
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,43 @@ function isUsingYarn() {
5353
return (process.env.npm_config_user_agent || '').indexOf('yarn') === 0;
5454
}
5555

56+
function hasGivenWarning() {
57+
const ourPackageInNodeModules = path.join('node_modules', packageJson.name);
58+
const warningFilePath = path.join(
59+
ourPackageInNodeModules,
60+
'given-deprecation-warning'
61+
);
62+
return fs.existsSync(warningFilePath);
63+
}
64+
65+
function writeWarningFile() {
66+
const ourPackageInNodeModules = path.join('node_modules', packageJson.name);
67+
const warningFilePath = path.join(
68+
ourPackageInNodeModules,
69+
'given-deprecation-warning'
70+
);
71+
fs.writeFileSync(warningFilePath, 'true');
72+
}
73+
5674
let projectName;
5775

5876
function init() {
77+
if (!hasGivenWarning()) {
78+
console.log(chalk.yellow.bold('create-react-app is deprecated.'));
79+
console.log('');
80+
console.log(
81+
'You can find a list of up-to-date React frameworks on react.dev'
82+
);
83+
console.log(
84+
chalk.underline('https://react.dev/learn/start-a-new-react-project')
85+
);
86+
console.log('');
87+
console.log(
88+
chalk.grey('This error message will only be shown once per install.')
89+
);
90+
writeWarningFile();
91+
}
92+
5993
const program = new commander.Command(packageJson.name)
6094
.version(packageJson.version)
6195
.arguments('<project-directory>')

packages/create-react-app/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-react-app",
3-
"version": "5.0.1",
3+
"version": "5.0.2",
44
"keywords": [
55
"react"
66
],

0 commit comments

Comments
 (0)