Skip to content

Commit 2832d2a

Browse files
authored
Merge pull request #182 from arminbro/dev
feat: improve CLI messaging and user experience
2 parents cffafaa + d760b0a commit 2832d2a

8 files changed

Lines changed: 703 additions & 1020 deletions

File tree

bin/generate-react.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
#!/usr/bin/env node
22
import cli from '../src/cli.js';
3+
import { error } from '../src/utils/messagesUtils.js';
34

4-
const isNotValidNodeVersion = () => {
5+
function isNotValidNodeVersion() {
56
const currentNodeVersion = process.versions.node;
67
const semver = currentNodeVersion.split('.');
78
const major = semver[0];
89

9-
if (major < 18) {
10-
console.error(
11-
// eslint-disable-next-line
12-
'You are running Node ' +
13-
currentNodeVersion +
14-
' Generate React CLI requires Node 18 or higher. Please update your version of Node.'
15-
);
10+
if (major < 22) {
11+
error(`Node ${currentNodeVersion} is not supported`, {
12+
details: 'Generate React CLI requires Node 22 or higher',
13+
suggestions: [
14+
'Update your Node.js version to 22 or higher',
15+
'Use nvm to manage multiple Node versions: nvm install 22',
16+
],
17+
});
1618

1719
return true;
1820
}
1921

2022
return false;
21-
};
23+
}
2224

2325
// --- Check if user is running Node 12 or higher.
2426

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ export default antfu({
2424
rules: {
2525
'no-console': 'off', // CLI tool - console output is expected
2626
'node/prefer-global/process': 'off', // process is always available in Node.js
27+
'style/brace-style': ['error', '1tbs', { allowSingleLine: true }],
2728
},
2829
});

0 commit comments

Comments
 (0)