replace chalk with picocolors

This commit is contained in:
Aman Varshney
2025-02-15 03:29:32 +05:30
parent 75d6255d21
commit f98216e642
8 changed files with 76 additions and 80 deletions

View File

@@ -1,4 +1,3 @@
import chalk from "chalk";
import { DEFAULT_CONFIG } from "../consts";
import type { ProjectConfig } from "../types";
@@ -12,37 +11,34 @@ export function generateReproducibleCommand(config: ProjectConfig): string {
});
if (isMainlyDefault) {
flags.push(chalk.gray("-y"));
flags.push("-y");
}
if (config.database !== DEFAULT_CONFIG.database) {
flags.push(chalk.cyan(`--database ${config.database}`));
flags.push(`--database ${config.database}`);
}
if (config.auth !== DEFAULT_CONFIG.auth) {
flags.push(chalk.yellow("--no-auth"));
flags.push("--no-auth");
}
if (!config.git) {
flags.push(chalk.red("--no-git"));
flags.push("--no-git");
}
// Updated package manager flag handling
if (
config.packageManager &&
config.packageManager !== DEFAULT_CONFIG.packageManager
) {
flags.push(chalk.magenta(`--${config.packageManager}`));
flags.push(`--${config.packageManager}`);
}
for (const feature of config.features) {
flags.push(chalk.green(`--${feature}`));
flags.push(`--${feature}`);
}
const baseCommand = chalk.bold("npx create-better-t-stack");
const projectName = config.projectName
? chalk.blue(` ${config.projectName}`)
: "";
const baseCommand = "npx create-better-t-stack";
const projectName = config.projectName ? ` ${config.projectName}` : "";
const flagString = flags.length > 0 ? ` ${flags.join(" ")}` : "";
return `${baseCommand}${projectName}${flagString}`;

View File

@@ -0,0 +1,58 @@
import gradient from "gradient-string";
export const TITLE_TEXT = `
╔════════════════════════════════════════════════════════════╗
║ ║
║ ██████╗ ███████╗████████╗████████╗███████╗██████╗ ║
║ ██╔══██╗██╔════╝╚══██╔══╝╚══██╔══╝██╔════╝██╔══██╗ ║
║ ██████╔╝█████╗ ██║ ██║ █████╗ ██████╔╝ ║
║ ██╔══██╗██╔══╝ ██║ ██║ ██╔══╝ ██╔══██╗ ║
║ ██████╔╝███████╗ ██║ ██║ ███████╗██║ ██║ ║
║ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═╝ ║
║ ║
║ ████████╗ ███████╗████████╗ █████╗ ██████╗██╗ ██╗ ║
║ ╚══██╔══╝ ██╔════╝╚══██╔══╝██╔══██╗██╔════╝██║ ██╔╝ ║
║ ██║ ███████╗ ██║ ███████║██║ █████╔╝ ║
║ ██║ ╚════██║ ██║ ██╔══██║██║ ██╔═██╗ ║
║ ██║ ███████║ ██║ ██║ ██║╚██████╗██║ ██╗ ║
║ ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ║
║ ║
║ The Modern Full-Stack Framework ║
║ ║
╚════════════════════════════════════════════════════════════╝
`;
const catppuccinTheme = {
rosewater: "#F5E0DC",
flamingo: "#F2CDCD",
pink: "#F5C2E7",
mauve: "#CBA6F7",
red: "#F38BA8",
maroon: "#E78284",
peach: "#FAB387",
yellow: "#F9E2AF",
green: "#A6E3A1",
teal: "#94E2D5",
sky: "#89DCEB",
sapphire: "#74C7EC",
lavender: "#B4BEFE",
};
export const renderTitle = () => {
const terminalWidth = process.stdout.columns || 80;
const titleLines = TITLE_TEXT.split("\n");
const titleWidth = Math.max(...titleLines.map((line) => line.length));
if (terminalWidth < titleWidth) {
const simplifiedTitle = `
╔══════════════════╗
║ Better T-Stack ║
╚══════════════════╝
`;
console.log(
gradient(Object.values(catppuccinTheme)).multiline(simplifiedTitle),
);
} else {
console.log(gradient(Object.values(catppuccinTheme)).multiline(TITLE_TEXT));
}
};