mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
remove ugly emojis
This commit is contained in:
5
.changeset/metal-actors-talk.md
Normal file
5
.changeset/metal-actors-talk.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"create-better-t-stack": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
remove ugly emojis
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
"url": "git+https://github.com/better-t-stack/create-better-t-stack.git",
|
"url": "git+https://github.com/better-t-stack/create-better-t-stack.git",
|
||||||
"directory": "apps/cli"
|
"directory": "apps/cli"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/better-t-stack/create-better-t-stack/tree/main/apps/cli#readme",
|
"homepage": "https://better-t-stack.pages.dev/",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsup",
|
"build": "tsup",
|
||||||
"dev": "tsup --watch",
|
"dev": "tsup --watch",
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ export async function createProject(options: ProjectConfig) {
|
|||||||
try {
|
try {
|
||||||
const tasksList = [
|
const tasksList = [
|
||||||
{
|
{
|
||||||
title: "📁 Creating project directory",
|
title: "Creating project directory",
|
||||||
task: async () => {
|
task: async () => {
|
||||||
await fs.ensureDir(projectDir);
|
await fs.ensureDir(projectDir);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "📥 Cloning template repository",
|
title: "Cloning template repository",
|
||||||
task: async () => {
|
task: async () => {
|
||||||
try {
|
try {
|
||||||
const emitter = degit("better-t-stack/Better-T-Stack#bare");
|
const emitter = degit("better-t-stack/Better-T-Stack#bare");
|
||||||
@@ -39,7 +39,7 @@ export async function createProject(options: ProjectConfig) {
|
|||||||
|
|
||||||
if (options.git) {
|
if (options.git) {
|
||||||
tasksList.push({
|
tasksList.push({
|
||||||
title: "🗃️ Initializing git repository",
|
title: "Initializing git repository",
|
||||||
task: async () => {
|
task: async () => {
|
||||||
await $({
|
await $({
|
||||||
cwd: projectDir,
|
cwd: projectDir,
|
||||||
@@ -55,7 +55,7 @@ export async function createProject(options: ProjectConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const installDepsResponse = await confirm({
|
const installDepsResponse = await confirm({
|
||||||
message: `📦 Install dependencies with ${pc.magenta(options.packageManager)}?`,
|
message: `Install dependencies with ${options.packageManager}?`,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isCancel(installDepsResponse)) {
|
if (isCancel(installDepsResponse)) {
|
||||||
@@ -66,14 +66,12 @@ export async function createProject(options: ProjectConfig) {
|
|||||||
shouldInstallDeps = installDepsResponse;
|
shouldInstallDeps = installDepsResponse;
|
||||||
|
|
||||||
if (shouldInstallDeps) {
|
if (shouldInstallDeps) {
|
||||||
s.start(
|
s.start(`Installing dependencies using ${options.packageManager}...`);
|
||||||
`📦 Installing dependencies using ${pc.magenta(options.packageManager)}...`,
|
|
||||||
);
|
|
||||||
try {
|
try {
|
||||||
await $({
|
await $({
|
||||||
cwd: projectDir,
|
cwd: projectDir,
|
||||||
})`${options.packageManager} install`;
|
})`${options.packageManager} install`;
|
||||||
s.stop("✅ Dependencies installed successfully");
|
s.stop("Dependencies installed successfully");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
s.stop(pc.red("Failed to install dependencies"));
|
s.stop(pc.red("Failed to install dependencies"));
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
|
|||||||
@@ -1,14 +1,6 @@
|
|||||||
import os from "node:os";
|
import os from "node:os";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import {
|
import { cancel, confirm, isCancel, log, spinner, text } from "@clack/prompts";
|
||||||
cancel,
|
|
||||||
confirm,
|
|
||||||
isCancel,
|
|
||||||
log,
|
|
||||||
outro,
|
|
||||||
spinner,
|
|
||||||
text,
|
|
||||||
} from "@clack/prompts";
|
|
||||||
import { $ } from "execa";
|
import { $ } from "execa";
|
||||||
import fs from "fs-extra";
|
import fs from "fs-extra";
|
||||||
import pc from "picocolors";
|
import pc from "picocolors";
|
||||||
@@ -22,9 +14,9 @@ interface TursoConfig {
|
|||||||
async function loginToTurso() {
|
async function loginToTurso() {
|
||||||
const s = spinner();
|
const s = spinner();
|
||||||
try {
|
try {
|
||||||
s.start("🔄 Logging in to Turso...");
|
s.start("Logging in to Turso...");
|
||||||
await $`turso auth login`;
|
await $`turso auth login`;
|
||||||
s.stop("✅ Logged in to Turso successfully!");
|
s.stop("Logged in to Turso successfully!");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
s.stop(pc.red("Failed to log in to Turso"));
|
s.stop(pc.red("Failed to log in to Turso"));
|
||||||
throw error;
|
throw error;
|
||||||
@@ -34,7 +26,7 @@ async function loginToTurso() {
|
|||||||
async function installTursoCLI(isMac: boolean) {
|
async function installTursoCLI(isMac: boolean) {
|
||||||
const s = spinner();
|
const s = spinner();
|
||||||
try {
|
try {
|
||||||
s.start("🔄 Installing Turso CLI...");
|
s.start("Installing Turso CLI...");
|
||||||
|
|
||||||
if (isMac) {
|
if (isMac) {
|
||||||
await $`brew install tursodatabase/tap/turso`;
|
await $`brew install tursodatabase/tap/turso`;
|
||||||
@@ -44,7 +36,7 @@ async function installTursoCLI(isMac: boolean) {
|
|||||||
await $`bash -c '${installScript}'`;
|
await $`bash -c '${installScript}'`;
|
||||||
}
|
}
|
||||||
|
|
||||||
s.stop("✅ Turso CLI installed successfully!");
|
s.stop("Turso CLI installed successfully!");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof Error && error.message.includes("User force closed")) {
|
if (error instanceof Error && error.message.includes("User force closed")) {
|
||||||
s.stop();
|
s.stop();
|
||||||
@@ -87,7 +79,7 @@ TURSO_AUTH_TOKEN=`;
|
|||||||
}
|
}
|
||||||
|
|
||||||
function displayManualSetupInstructions() {
|
function displayManualSetupInstructions() {
|
||||||
log.info(`🔧 Manual Turso Setup Instructions:
|
log.info(`Manual Turso Setup Instructions:
|
||||||
|
|
||||||
1. Visit https://turso.tech and create an account
|
1. Visit https://turso.tech and create an account
|
||||||
2. Create a new database from the dashboard
|
2. Create a new database from the dashboard
|
||||||
@@ -115,7 +107,7 @@ export async function setupTurso(projectDir: string) {
|
|||||||
|
|
||||||
if (!isCliInstalled) {
|
if (!isCliInstalled) {
|
||||||
const shouldInstall = await confirm({
|
const shouldInstall = await confirm({
|
||||||
message: "🔧 Would you like to install Turso CLI?",
|
message: "Would you like to install Turso CLI?",
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isCancel(shouldInstall)) {
|
if (isCancel(shouldInstall)) {
|
||||||
@@ -130,7 +122,7 @@ export async function setupTurso(projectDir: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const s = spinner();
|
const s = spinner();
|
||||||
s.start("🔄 Installing Turso CLI...");
|
s.start("Installing Turso CLI...");
|
||||||
try {
|
try {
|
||||||
if (isMac) {
|
if (isMac) {
|
||||||
await $`brew install tursodatabase/tap/turso`;
|
await $`brew install tursodatabase/tap/turso`;
|
||||||
@@ -139,7 +131,7 @@ export async function setupTurso(projectDir: string) {
|
|||||||
await $`curl -sSfL https://get.tur.so/install.sh`;
|
await $`curl -sSfL https://get.tur.so/install.sh`;
|
||||||
await $`bash -c '${installScript}'`;
|
await $`bash -c '${installScript}'`;
|
||||||
}
|
}
|
||||||
s.stop("✅ Turso CLI installed successfully!");
|
s.stop("Turso CLI installed successfully!");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
s.stop(pc.red("Failed to install Turso CLI"));
|
s.stop(pc.red("Failed to install Turso CLI"));
|
||||||
throw error;
|
throw error;
|
||||||
@@ -149,10 +141,10 @@ export async function setupTurso(projectDir: string) {
|
|||||||
const isLoggedIn = await isTursoLoggedIn();
|
const isLoggedIn = await isTursoLoggedIn();
|
||||||
if (!isLoggedIn) {
|
if (!isLoggedIn) {
|
||||||
const s = spinner();
|
const s = spinner();
|
||||||
s.start("🔄 Logging in to Turso...");
|
s.start("Logging in to Turso...");
|
||||||
try {
|
try {
|
||||||
await $`turso auth login`;
|
await $`turso auth login`;
|
||||||
s.stop("✅ Logged in to Turso successfully!");
|
s.stop("Logged in to Turso successfully!");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
s.stop(pc.red("Failed to log in to Turso"));
|
s.stop(pc.red("Failed to log in to Turso"));
|
||||||
throw error;
|
throw error;
|
||||||
@@ -165,7 +157,7 @@ export async function setupTurso(projectDir: string) {
|
|||||||
|
|
||||||
while (!success) {
|
while (!success) {
|
||||||
const dbNameResponse = await text({
|
const dbNameResponse = await text({
|
||||||
message: "📝 Enter a name for your database:",
|
message: "Enter a name for your database:",
|
||||||
defaultValue: suggestedName,
|
defaultValue: suggestedName,
|
||||||
initialValue: suggestedName,
|
initialValue: suggestedName,
|
||||||
placeholder: suggestedName,
|
placeholder: suggestedName,
|
||||||
@@ -180,10 +172,10 @@ export async function setupTurso(projectDir: string) {
|
|||||||
const s = spinner();
|
const s = spinner();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
s.start(`🔄 Creating Turso database "${dbName}"...`);
|
s.start(`Creating Turso database "${dbName}"...`);
|
||||||
const config = await createTursoDatabase(dbName);
|
const config = await createTursoDatabase(dbName);
|
||||||
await writeEnvFile(projectDir, config);
|
await writeEnvFile(projectDir, config);
|
||||||
s.stop("✅ Turso database configured successfully!");
|
s.stop("Turso database configured successfully!");
|
||||||
success = true;
|
success = true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof Error && error.message === "DATABASE_EXISTS") {
|
if (error instanceof Error && error.message === "DATABASE_EXISTS") {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ async function gatherConfig(
|
|||||||
|
|
||||||
while (!isValid) {
|
while (!isValid) {
|
||||||
const response = await text({
|
const response = await text({
|
||||||
message: "📝 What is your project named? (directory name or path)",
|
message: "What is your project named? (directory name or path)",
|
||||||
placeholder: defaultName,
|
placeholder: defaultName,
|
||||||
initialValue: flags.projectName,
|
initialValue: flags.projectName,
|
||||||
defaultValue: defaultName,
|
defaultValue: defaultName,
|
||||||
@@ -87,7 +87,7 @@ async function gatherConfig(
|
|||||||
flags.database !== undefined
|
flags.database !== undefined
|
||||||
? Promise.resolve(flags.database)
|
? Promise.resolve(flags.database)
|
||||||
: select<ProjectDatabase>({
|
: select<ProjectDatabase>({
|
||||||
message: "💾 Which database would you like to use?",
|
message: "Which database would you like to use?",
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
value: "libsql",
|
value: "libsql",
|
||||||
@@ -105,15 +105,14 @@ async function gatherConfig(
|
|||||||
flags.auth !== undefined
|
flags.auth !== undefined
|
||||||
? Promise.resolve(flags.auth)
|
? Promise.resolve(flags.auth)
|
||||||
: confirm({
|
: confirm({
|
||||||
message:
|
message: "Would you like to add authentication with Better-Auth?",
|
||||||
"🔐 Would you like to add authentication with Better-Auth?",
|
|
||||||
initialValue: DEFAULT_CONFIG.auth,
|
initialValue: DEFAULT_CONFIG.auth,
|
||||||
}),
|
}),
|
||||||
features: () =>
|
features: () =>
|
||||||
flags.features !== undefined
|
flags.features !== undefined
|
||||||
? Promise.resolve(flags.features)
|
? Promise.resolve(flags.features)
|
||||||
: multiselect<ProjectFeature>({
|
: multiselect<ProjectFeature>({
|
||||||
message: "✨ Which features would you like to add?",
|
message: "Which features would you like to add?",
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
value: "docker",
|
value: "docker",
|
||||||
@@ -137,7 +136,7 @@ async function gatherConfig(
|
|||||||
flags.git !== undefined
|
flags.git !== undefined
|
||||||
? Promise.resolve(flags.git)
|
? Promise.resolve(flags.git)
|
||||||
: confirm({
|
: confirm({
|
||||||
message: "🗃️ Initialize a new git repository?",
|
message: "Initialize a new git repository?",
|
||||||
initialValue: DEFAULT_CONFIG.git,
|
initialValue: DEFAULT_CONFIG.git,
|
||||||
}),
|
}),
|
||||||
packageManager: async () => {
|
packageManager: async () => {
|
||||||
@@ -147,13 +146,13 @@ async function gatherConfig(
|
|||||||
const detectedPackageManager = getUserPkgManager();
|
const detectedPackageManager = getUserPkgManager();
|
||||||
|
|
||||||
const useDetected = await confirm({
|
const useDetected = await confirm({
|
||||||
message: `📦 Use ${detectedPackageManager} as your package manager?`,
|
message: `Use ${detectedPackageManager} as your package manager?`,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (useDetected) return detectedPackageManager;
|
if (useDetected) return detectedPackageManager;
|
||||||
|
|
||||||
return select<PackageManager>({
|
return select<PackageManager>({
|
||||||
message: "📦 Which package manager would you like to use?",
|
message: "Which package manager would you like to use?",
|
||||||
options: [
|
options: [
|
||||||
{ value: "npm", label: "npm", hint: "Node Package Manager" },
|
{ value: "npm", label: "npm", hint: "Node Package Manager" },
|
||||||
{
|
{
|
||||||
@@ -198,25 +197,23 @@ function displayConfig(config: Partial<ProjectConfig>) {
|
|||||||
const configDisplay = [];
|
const configDisplay = [];
|
||||||
|
|
||||||
if (config.projectName) {
|
if (config.projectName) {
|
||||||
configDisplay.push(`${pc.blue("📝 Project Name:")} ${config.projectName}`);
|
configDisplay.push(`${pc.blue("Project Name:")} ${config.projectName}`);
|
||||||
}
|
}
|
||||||
if (config.database) {
|
if (config.database) {
|
||||||
configDisplay.push(`${pc.blue("💾 Database:")} ${config.database}`);
|
configDisplay.push(`${pc.blue("Database:")} ${config.database}`);
|
||||||
}
|
}
|
||||||
if (config.auth !== undefined) {
|
if (config.auth !== undefined) {
|
||||||
configDisplay.push(`${pc.blue("🔐 Authentication:")} ${config.auth}`);
|
configDisplay.push(`${pc.blue("Authentication:")} ${config.auth}`);
|
||||||
}
|
}
|
||||||
if (config.features?.length) {
|
if (config.features?.length) {
|
||||||
configDisplay.push(
|
configDisplay.push(`${pc.blue("Features:")} ${config.features.join(", ")}`);
|
||||||
`${pc.blue("✨ Features:")} ${config.features.join(", ")}`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if (config.git !== undefined) {
|
if (config.git !== undefined) {
|
||||||
configDisplay.push(`${pc.blue("🗃️ Git Init:")} ${config.git}`);
|
configDisplay.push(`${pc.blue("Git Init:")} ${config.git}`);
|
||||||
}
|
}
|
||||||
if (config.packageManager) {
|
if (config.packageManager) {
|
||||||
configDisplay.push(
|
configDisplay.push(
|
||||||
`${pc.blue("📦 Package Manager:")} ${config.packageManager}`,
|
`${pc.blue("Package Manager:")} ${config.packageManager}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,7 +225,7 @@ async function main() {
|
|||||||
try {
|
try {
|
||||||
process.stdout.write("\x1Bc");
|
process.stdout.write("\x1Bc");
|
||||||
renderTitle();
|
renderTitle();
|
||||||
intro(pc.magenta("✨ Creating a new Better-T-Stack project"));
|
intro(pc.magenta("Creating a new Better-T-Stack project"));
|
||||||
program
|
program
|
||||||
.name("create-better-t-stack")
|
.name("create-better-t-stack")
|
||||||
.description("Create a new Better-T Stack project")
|
.description("Create a new Better-T Stack project")
|
||||||
@@ -280,7 +277,7 @@ async function main() {
|
|||||||
!options.yes &&
|
!options.yes &&
|
||||||
Object.values(flagConfig).some((v) => v !== undefined)
|
Object.values(flagConfig).some((v) => v !== undefined)
|
||||||
) {
|
) {
|
||||||
log.info(pc.yellow("🎯 Using these pre-selected options:"));
|
log.info(pc.yellow("Using these pre-selected options:"));
|
||||||
log.message(displayConfig(flagConfig));
|
log.message(displayConfig(flagConfig));
|
||||||
log.message("");
|
log.message("");
|
||||||
}
|
}
|
||||||
@@ -304,7 +301,7 @@ async function main() {
|
|||||||
: await gatherConfig(flagConfig);
|
: await gatherConfig(flagConfig);
|
||||||
|
|
||||||
if (options.yes) {
|
if (options.yes) {
|
||||||
log.info(pc.yellow("🎯 Using these default options:"));
|
log.info(pc.yellow("Using these default options:"));
|
||||||
log.message(displayConfig(config));
|
log.message(displayConfig(config));
|
||||||
log.message("");
|
log.message("");
|
||||||
}
|
}
|
||||||
@@ -319,7 +316,7 @@ async function main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
outro(pc.magenta("🎉 Project created successfully!"));
|
outro(pc.magenta("Project created successfully!"));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
s.stop(pc.red("Failed"));
|
s.stop(pc.red("Failed"));
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ export type ProjectFeature = "docker" | "github-actions" | "SEO";
|
|||||||
|
|
||||||
export type ProjectDatabase = "libsql" | "postgres";
|
export type ProjectDatabase = "libsql" | "postgres";
|
||||||
|
|
||||||
|
export type PackageManager = "npm" | "yarn" | "pnpm" | "bun";
|
||||||
|
|
||||||
export type ProjectConfig = {
|
export type ProjectConfig = {
|
||||||
yes?: boolean;
|
yes?: boolean;
|
||||||
projectName: string;
|
projectName: string;
|
||||||
@@ -11,5 +13,3 @@ export type ProjectConfig = {
|
|||||||
packageManager: PackageManager;
|
packageManager: PackageManager;
|
||||||
features: ProjectFeature[];
|
features: ProjectFeature[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type PackageManager = "npm" | "yarn" | "pnpm" | "bun";
|
|
||||||
|
|||||||
Reference in New Issue
Block a user