cli: deprecate use of react 16

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-05-11 13:36:05 +02:00
parent 734cf86028
commit d548886872
2 changed files with 31 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---
Deprecated the use of React 16
@@ -32,6 +32,30 @@ interface StartAppOptions {
configPaths: string[];
}
function checkReactVersion() {
try {
// Make sure we're looking at the root of the target repo
const reactPkgPath = require.resolve('react/package.json', {
paths: [paths.targetRoot],
});
const reactPkg = require(reactPkgPath);
if (reactPkg.version.startsWith('16.')) {
console.log(
chalk.yellow(
`
⚠️ ⚠️
⚠️ You are using React version 16, which is deprecated for use in Backstage. ⚠️
⚠️ Please upgrade to at React 17 by updating your packages/app dependencies. ⚠️
⚠️ ⚠️
`,
),
);
}
} catch {
/* ignored */
}
}
export async function startFrontend(options: StartAppOptions) {
if (options.verifyVersions) {
const lockfile = await Lockfile.load(paths.resolveTargetRoot('yarn.lock'));
@@ -65,6 +89,8 @@ export async function startFrontend(options: StartAppOptions) {
}
}
checkReactVersion();
const { name } = await fs.readJson(paths.resolveTarget('package.json'));
const config = await loadCliConfig({
args: options.configPaths,