diff --git a/index.js b/index.js index daa995b..572f967 100755 --- a/index.js +++ b/index.js @@ -3,6 +3,7 @@ import fs from "node:fs/promises"; import path from "node:path"; import { input } from "@inquirer/prompts"; import { buildBase, buildExt } from "./template.js"; +import chalk from "chalk"; const exists = (path) => fs @@ -29,7 +30,9 @@ if (await exists(packageJson)) { extId = await input({ message: "Choose an extension ID:", default: "sampleExtension" }); const extDir = path.join("./src", extId); if ((await exists(extDir)) && (await fs.readdir(extDir)).length !== 0) { - console.log("Extension already exists - please choose another."); + console.log( + `${chalk.bgRed("[error]")} Extension already exists ${chalk.grey("-")} please choose another directory.` + ); } else { break; } @@ -41,13 +44,15 @@ if (await exists(packageJson)) { console.log("Done."); } else { - console.log(`${moonEmoji} Creating new project.`); + console.log(`${moonEmoji} Creating new extension.`); let dir; while (true) { dir = await input({ message: "Choose a directory:", default: "./my-moonlight-extensions" }); if ((await exists(dir)) && (await fs.readdir(dir)).length !== 0) { - console.log("Directory already exists - please choose another."); + console.log( + `${chalk.bgRed("[error]")} Directory already exists ${chalk.grey("-")} please choose another directory.` + ); } else { break; } @@ -63,11 +68,11 @@ if (await exists(packageJson)) { await write(dir, tmpl); - console.log("Done. Now run:\n"); - console.log(`$ cd ${dir}`); - console.log("$ pnpm i"); - console.log("$ git init"); + console.log(`${chalk.green("Done!")} ${chalk.grey("Now run:")}\n`); + console.log(`${chalk.blue("$")} cd ${dir}`); + console.log(`${chalk.blue("$")} pnpm i`); + console.log(`${chalk.blue("$")} git init`); console.log("\nGood luck! Feel free to reach out:"); - console.log("Docs: https://moonlight-mod.github.io/ext-dev/getting-started"); - console.log("Discord server: https://discord.gg/FdZBTFCP6F"); + console.log(`${chalk.blueBright("Docs:")} ${chalk.grey("https://moonlight-mod.github.io/ext-dev/getting-started")}`); + console.log(`${chalk.blueBright("Discord:")} ${chalk.grey("https://discord.gg/FdZBTFCP6F")}`); } diff --git a/package.json b/package.json index c04dcdd..d64cb55 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,11 @@ "bin": "index.js", "type": "module", "dependencies": { - "@inquirer/prompts": "^7.2.3" + "@inquirer/prompts": "^7.2.3", + "chalk": "^5.4.1" }, "devDependencies": { "prettier": "^3.4.2" - } + }, + "packageManager": "pnpm@9.15.3+sha512.1f79bc245a66eb0b07c5d4d83131240774642caaa86ef7d0434ab47c0d16f66b04e21e0c086eb61e62c77efc4d7f7ec071afad3796af64892fae66509173893a" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ea7081f..99744d1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: '@inquirer/prompts': specifier: ^7.2.3 version: 7.2.3(@types/node@22.10.6) + chalk: + specifier: ^5.4.1 + version: 5.4.1 devDependencies: prettier: specifier: ^3.4.2 @@ -113,6 +116,10 @@ packages: resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} engines: {node: '>=8'} + chalk@5.4.1: + resolution: {integrity: sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==} + engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} + chardet@0.7.0: resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==} @@ -311,6 +318,8 @@ snapshots: dependencies: color-convert: 2.0.1 + chalk@5.4.1: {} + chardet@0.7.0: {} cli-width@4.1.0: {}