@@ -8,60 +8,84 @@ import { logger } from "./utils/logger";
88
99const program = new Command ( ) ;
1010
11- async function main ( ) {
11+ type CliOptions = {
12+ yes : boolean ;
13+ } ;
14+
15+ async function main ( options : CliOptions ) {
1216 try {
1317 renderTitle ( ) ;
14-
1518 console . log ( chalk . bold ( "\n🚀 Creating a new Better-T Stack project...\n" ) ) ;
1619
17- const projectName = await input ( {
18- message : "Project name:" ,
19- default : "my-better-t-app" ,
20- } ) ;
20+ const defaults = {
21+ projectName : "my-better-t-app" ,
22+ database : "libsql" as ProjectDatabase ,
23+ auth : true ,
24+ features : [ ] as ProjectFeature [ ] ,
25+ } ;
26+
27+ const projectName = options . yes
28+ ? defaults . projectName
29+ : await input ( {
30+ message : "Project name:" ,
31+ default : defaults . projectName ,
32+ } ) ;
33+
34+ const database = options . yes
35+ ? defaults . database
36+ : await select < ProjectDatabase > ( {
37+ message : chalk . cyan ( "Select database:" ) ,
38+ choices : [
39+ {
40+ value : "libsql" ,
41+ name : "libSQL" ,
42+ description : chalk . dim (
43+ "(Recommended) - Turso's embedded SQLite database" ,
44+ ) ,
45+ } ,
46+ {
47+ value : "postgres" ,
48+ name : "PostgreSQL" ,
49+ description : chalk . dim ( "Traditional relational database" ) ,
50+ } ,
51+ ] ,
52+ } ) ;
2153
22- const database = await select < ProjectDatabase > ( {
23- message : chalk . cyan ( "Select database:" ) ,
24- choices : [
25- {
26- value : "libsql" ,
27- name : "libSQL" ,
28- description : chalk . dim (
29- "(Recommended) - Turso's embedded SQLite database" ,
30- ) ,
31- } ,
32- {
33- value : "postgres" ,
34- name : "PostgreSQL" ,
35- description : chalk . dim ( "Traditional relational database" ) ,
36- } ,
37- ] ,
38- } ) ;
54+ const auth = options . yes
55+ ? defaults . auth
56+ : await confirm ( {
57+ message : "Add authentication with Better-Auth?" ,
58+ default : defaults . auth ,
59+ } ) ;
3960
40- const auth = await confirm ( {
41- message : "Add authentication with Better-Auth?" ,
42- default : true ,
43- } ) ;
61+ const features = options . yes
62+ ? defaults . features
63+ : await checkbox < ProjectFeature > ( {
64+ message : chalk . cyan ( "Select additional features:" ) ,
65+ choices : [
66+ {
67+ value : "docker" ,
68+ name : "Docker setup" ,
69+ description : chalk . dim ( "Containerize your application" ) ,
70+ } ,
71+ {
72+ value : "github-actions" ,
73+ name : "GitHub Actions" ,
74+ description : chalk . dim ( "CI/CD workflows" ) ,
75+ } ,
76+ {
77+ value : "SEO" ,
78+ name : "Basic SEO setup" ,
79+ description : chalk . dim (
80+ "Search engine optimization configuration" ,
81+ ) ,
82+ } ,
83+ ] ,
84+ } ) ;
4485
45- const features = await checkbox < ProjectFeature > ( {
46- message : chalk . cyan ( "Select additional features:" ) ,
47- choices : [
48- {
49- value : "docker" ,
50- name : "Docker setup" ,
51- description : chalk . dim ( "Containerize your application" ) ,
52- } ,
53- {
54- value : "github-actions" ,
55- name : "GitHub Actions" ,
56- description : chalk . dim ( "CI/CD workflows" ) ,
57- } ,
58- {
59- value : "SEO" ,
60- name : "Basic SEO setup" ,
61- description : chalk . dim ( "Search engine optimization configuration" ) ,
62- } ,
63- ] ,
64- } ) ;
86+ if ( options . yes ) {
87+ logger . info ( "Using default values due to -y flag" ) ;
88+ }
6589
6690 const projectOptions = {
6791 projectName,
@@ -93,6 +117,7 @@ program
93117 . name ( "create-better-t-stack" )
94118 . description ( "Create a new Better-T Stack project" )
95119 . version ( "1.0.0" )
96- . action ( main ) ;
120+ . option ( "-y, --yes" , "Accept all defaults" )
121+ . action ( ( options ) => main ( options ) ) ;
97122
98123program . parse ( ) ;
0 commit comments