diff --git a/package.json b/package.json index 724edb8..7b671a5 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ "test:int": "cross-env NODE_OPTIONS=--no-deprecation vitest run --config ./vitest.config.mts", "deploy": "bun pm version patch --message \"chore: update to %s\"", "preversion": "bun run build", - "postversion": "bun run generate:version-info && bash ./build/deploy.sh" + "postversion": "bun run generate:version-info && bash ./build/deploy.sh", + "u:reset-password": "bun run src/tools/cli/reset-password.ts" }, "dependencies": { "@ai-stack/payloadcms": "^3.2.30", @@ -69,6 +70,7 @@ "nodemailer": "^9.0.5", "payload": "3.88.0", "postcss": "8.5.18", + "prompt": "^1.3.0", "radix-ui": "^1.6.7", "react": "19.2.3", "react-dom": "19.2.3", diff --git a/src/tools/cli/_library.ts b/src/tools/cli/_library.ts new file mode 100644 index 0000000..82c36d7 --- /dev/null +++ b/src/tools/cli/_library.ts @@ -0,0 +1,43 @@ +export class CliFlow { + protected moduleName: string; + + constructor(moduleName: string) { + this.moduleName = moduleName; + } + + /** + * showHeader + */ + public showHeader(title: string, subtitle?: string) { + const LENGTH = Math.max(title.length, subtitle?.length ?? 0) + 5; + + // Chars: ╔═╗║╚═╝╬ + + // Draw the top border + let topStr = "╔"; + for (let i = 0; i < LENGTH; i++) { + topStr += "═"; + } + topStr += "╗"; + console.log(topStr); + + // Draw the title + console.log(`║ \x1B[33;1m${title}\x1B[0m ${"║".padStart(LENGTH - title.length - 1, " ")}`); + + // Draw the subtitle + subtitle && + console.log(`║ \x1B[2m${subtitle}\x1B[0m ${"║".padStart(LENGTH - subtitle.length - 1, " ")}`); + + // Draw the bottom border + let btmStr = "╚"; + for (let i = 0; i < LENGTH; i++) { + btmStr += "═"; + } + btmStr += "╝"; + console.log(btmStr + "\n"); + } + + log(...msg: string[]) { + console.log(`\t\x1B[33m[LOG]\x1B[0m ${msg.join(" ")}`); + } +} diff --git a/src/tools/cli/reset-password.ts b/src/tools/cli/reset-password.ts new file mode 100644 index 0000000..8198e43 --- /dev/null +++ b/src/tools/cli/reset-password.ts @@ -0,0 +1,7 @@ +import { CliFlow } from "./_library"; + +const prompt = require("prompt"); + +const flow = new CliFlow("reset-password"); + +flow.showHeader("Test", "Long subtitle test");