diff --git a/package.json b/package.json index 855ee4c..e8b9a98 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "expressots": "bin/cli.js" }, "engines": { - "node": ">=18.18.0" + "node": ">=18.0.0" }, "funding": { "type": "github", @@ -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", @@ -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": { diff --git a/src/new/cli.ts b/src/new/cli.ts index 7b02655..c808078 100644 --- a/src/new/cli.ts +++ b/src/new/cli.ts @@ -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; @@ -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); } }; diff --git a/src/new/form.ts b/src/new/form.ts index 51ddd62..b90d2e3 100644 --- a/src/new/form.ts +++ b/src/new/form.ts @@ -25,6 +25,7 @@ async function packageManagerInstall({ const installProcess = spawn(command, ["install"], { cwd: directory, + shell: true, }); installProcess.on("error", (error) => { diff --git a/src/utils/cli-ui.ts b/src/utils/cli-ui.ts index e5bb64a..08f7755 100644 --- a/src/utils/cli-ui.ts +++ b/src/utils/cli-ui.ts @@ -1,4 +1,5 @@ import chalk from "chalk"; +import { stdout } from "process"; export function printError(message: string, component: string): void { console.error( @@ -6,6 +7,19 @@ export function printError(message: string, component: string): void { ); } +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( " ",