Skip to content

Commit

Permalink
fix: update nodejs latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
rsaz committed Aug 1, 2024
1 parent c2300e4 commit 565a069
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"expressots": "bin/cli.js"
},
"engines": {
"node": ">=18.18.0"
"node": ">=18.0.0"
},
"funding": {
"type": "github",
Expand All @@ -31,7 +31,7 @@
"Scaffolding"
],
"scripts": {
"prepare": "husky install",
"prepare": "husky",
"start:build": "npm run build && npm run start",
"start": "node ./bin/cli.js",
"start:dev": "tsnd ./src/cli.ts",
Expand All @@ -58,6 +58,7 @@
"inquirer": "8.2.6",
"mustache": "4.2.0",
"semver": "7.6.2",
"ts-node": "10.9.2",
"yargs": "17.7.2"
},
"devDependencies": {
Expand Down
10 changes: 5 additions & 5 deletions src/new/cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Argv, CommandModule } from "yargs";
import { projectForm } from "./form";
import semver from "semver";
import { printWarning } from "../utils/cli-ui";
import chalk from "chalk";

type CommandModuleArgs = object;

Expand Down Expand Up @@ -40,14 +42,12 @@ const commandOptions = (yargs: Argv): Argv => {

const checkNodeVersion = (): void => {
const minVersion = "18.0.0";
const maxVersion = "20.7.0";
const maxVersion = "22.5.1";
const currentVersion = process.version;

if (!semver.satisfies(currentVersion, `>=${minVersion} <=${maxVersion}`)) {
console.error(
`Node.js version ${currentVersion} is not supported. Please use a version between ${minVersion} and ${maxVersion}.`,
);
process.exit(1);
const msg: string = `Node.js version [${chalk.bold(chalk.white(currentVersion))}] is not tested. Please use a version between ${minVersion} and ${maxVersion}.`;
printWarning(msg);
}
};

Expand Down
1 change: 1 addition & 0 deletions src/new/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ async function packageManagerInstall({

const installProcess = spawn(command, ["install"], {
cwd: directory,
shell: true,
});

installProcess.on("error", (error) => {
Expand Down
14 changes: 14 additions & 0 deletions src/utils/cli-ui.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import chalk from "chalk";
import { stdout } from "process";

export function printError(message: string, component: string): void {
console.error(
chalk.red(`${message}:`, chalk.bold(chalk.white(`[${component}] ❌`))),
);
}

export function printWarning(message: string, component?: string): void {
if (component === undefined) {
stdout.write(chalk.yellow(`${message} ⚠️\n`));
return;
}
stdout.write(
chalk.yellow(
`${message}:`,
chalk.bold(chalk.white(`[${component}] ⚠️\n`)),
),
);
}

export async function printGenerateError(schematic: string, file: string) {
console.error(
" ",
Expand Down

0 comments on commit 565a069

Please sign in to comment.