Skip to content

Commit

Permalink
Merge pull request #3 from moonlight-mod/eva/prettify
Browse files Browse the repository at this point in the history
design: add ✨ colors ✨
  • Loading branch information
NotNite authored Jan 16, 2025
2 parents 72e9089 + 7a544d8 commit 6c3ad43
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
23 changes: 14 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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")}`);
}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6c3ad43

Please sign in to comment.