mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
add -y flag to auto select the defaults
This commit is contained in:
5
.changeset/new-eggs-tell.md
Normal file
5
.changeset/new-eggs-tell.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"create-better-t-stack": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Add -y to auto select the defaults
|
||||||
@@ -8,60 +8,84 @@ import { logger } from "./utils/logger";
|
|||||||
|
|
||||||
const program = new Command();
|
const program = new Command();
|
||||||
|
|
||||||
async function main() {
|
type CliOptions = {
|
||||||
|
yes: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
async function main(options: CliOptions) {
|
||||||
try {
|
try {
|
||||||
renderTitle();
|
renderTitle();
|
||||||
|
|
||||||
console.log(chalk.bold("\n🚀 Creating a new Better-T Stack project...\n"));
|
console.log(chalk.bold("\n🚀 Creating a new Better-T Stack project...\n"));
|
||||||
|
|
||||||
const projectName = await input({
|
const defaults = {
|
||||||
message: "Project name:",
|
projectName: "my-better-t-app",
|
||||||
default: "my-better-t-app",
|
database: "libsql" as ProjectDatabase,
|
||||||
});
|
auth: true,
|
||||||
|
features: [] as ProjectFeature[],
|
||||||
|
};
|
||||||
|
|
||||||
const database = await select<ProjectDatabase>({
|
const projectName = options.yes
|
||||||
message: chalk.cyan("Select database:"),
|
? defaults.projectName
|
||||||
choices: [
|
: await input({
|
||||||
{
|
message: "Project name:",
|
||||||
value: "libsql",
|
default: defaults.projectName,
|
||||||
name: "libSQL",
|
});
|
||||||
description: chalk.dim(
|
|
||||||
"(Recommended) - Turso's embedded SQLite database",
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: "postgres",
|
|
||||||
name: "PostgreSQL",
|
|
||||||
description: chalk.dim("Traditional relational database"),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
const auth = await confirm({
|
const database = options.yes
|
||||||
message: "Add authentication with Better-Auth?",
|
? defaults.database
|
||||||
default: true,
|
: await select<ProjectDatabase>({
|
||||||
});
|
message: chalk.cyan("Select database:"),
|
||||||
|
choices: [
|
||||||
|
{
|
||||||
|
value: "libsql",
|
||||||
|
name: "libSQL",
|
||||||
|
description: chalk.dim(
|
||||||
|
"(Recommended) - Turso's embedded SQLite database",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "postgres",
|
||||||
|
name: "PostgreSQL",
|
||||||
|
description: chalk.dim("Traditional relational database"),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
const features = await checkbox<ProjectFeature>({
|
const auth = options.yes
|
||||||
message: chalk.cyan("Select additional features:"),
|
? defaults.auth
|
||||||
choices: [
|
: await confirm({
|
||||||
{
|
message: "Add authentication with Better-Auth?",
|
||||||
value: "docker",
|
default: defaults.auth,
|
||||||
name: "Docker setup",
|
});
|
||||||
description: chalk.dim("Containerize your application"),
|
|
||||||
},
|
const features = options.yes
|
||||||
{
|
? defaults.features
|
||||||
value: "github-actions",
|
: await checkbox<ProjectFeature>({
|
||||||
name: "GitHub Actions",
|
message: chalk.cyan("Select additional features:"),
|
||||||
description: chalk.dim("CI/CD workflows"),
|
choices: [
|
||||||
},
|
{
|
||||||
{
|
value: "docker",
|
||||||
value: "SEO",
|
name: "Docker setup",
|
||||||
name: "Basic SEO setup",
|
description: chalk.dim("Containerize your application"),
|
||||||
description: chalk.dim("Search engine optimization configuration"),
|
},
|
||||||
},
|
{
|
||||||
],
|
value: "github-actions",
|
||||||
});
|
name: "GitHub Actions",
|
||||||
|
description: chalk.dim("CI/CD workflows"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "SEO",
|
||||||
|
name: "Basic SEO setup",
|
||||||
|
description: chalk.dim(
|
||||||
|
"Search engine optimization configuration",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
if (options.yes) {
|
||||||
|
logger.info("Using default values due to -y flag");
|
||||||
|
}
|
||||||
|
|
||||||
const projectOptions = {
|
const projectOptions = {
|
||||||
projectName,
|
projectName,
|
||||||
@@ -93,6 +117,7 @@ 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")
|
||||||
.version("1.0.0")
|
.version("1.0.0")
|
||||||
.action(main);
|
.option("-y, --yes", "Accept all defaults")
|
||||||
|
.action((options) => main(options));
|
||||||
|
|
||||||
program.parse();
|
program.parse();
|
||||||
|
|||||||
Reference in New Issue
Block a user