Skip to content

Commit 1859faa

Browse files
author
alexlee-dev
committed
✏️ Add Warning about old Node version
1 parent f3c70c2 commit 1859faa

5 files changed

Lines changed: 57 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- Warning about unusable Node version (less than v10.0.0)
13+
1214
### Changed
1315

1416
- Format of website in `author` field of `package.json`

package-lock.json

Lines changed: 33 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"@types/fs-extra": "^9.0.1",
4040
"@types/inquirer": "^6.5.0",
4141
"@types/node": "^14.0.5",
42+
"@types/semver": "^7.2.0",
4243
"@types/update-notifier": "^4.1.0",
4344
"@types/validate-npm-package-name": "^3.0.0",
4445
"@types/yargs": "^15.0.5",
@@ -56,6 +57,7 @@
5657
"fs-extra": "^9.0.0",
5758
"inquirer": "^7.1.0",
5859
"ora": "^4.0.4",
60+
"semver": "^7.3.2",
5961
"update-notifier": "^4.1.0",
6062
"validate-npm-package-name": "^3.0.0"
6163
}

src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ import {
2323
replaceTemplateValues,
2424
} from "./init";
2525
import { handleIncorrectApplicationName } from "./program";
26-
import { cleanupError, validateApplicationName } from "./util";
26+
import {
27+
cleanupError,
28+
validateApplicationName,
29+
verifyNodeVersion,
30+
} from "./util";
2731

2832
/**
2933
* Main CLI Program
@@ -71,6 +75,9 @@ const main = async (): Promise<void> => {
7175
})
7276
.parse(process.argv);
7377

78+
// * Very Node Version (>=10.0.0)
79+
verifyNodeVersion();
80+
7481
// * Application Name must exist, and not consist of illegal characters
7582
validateApplicationName(applicationName);
7683
if (!applicationName) return;

src/util.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import chalk from "chalk";
22
import { spawn } from "child_process";
33
import fs from "fs-extra";
44
import path from "path";
5+
import semver from "semver";
56
import validateProjectName from "validate-npm-package-name";
67

78
/**
@@ -105,3 +106,14 @@ export const validateApplicationName = (applicationName: any) => {
105106
process.exit(1);
106107
}
107108
};
109+
110+
export const verifyNodeVersion = (): void => {
111+
if (!semver.satisfies(process.version, ">=10.0.0")) {
112+
console.error(
113+
chalk.red(`create-cli-application requires Node v10 or higher.`)
114+
);
115+
console.error(chalk.red(`You are running Node ${process.version}.`));
116+
console.error(chalk.red(`Please update your version of Node.`));
117+
process.exit(1);
118+
}
119+
};

0 commit comments

Comments
 (0)