@@ -20,9 +20,9 @@ build_packages() {
2020 if [ -d " $package " ]; then
2121 echo " Building $package ..."
2222 cd " $package "
23- if ! yarn build; then
24- echo " yarn build failed for $package , trying yarn tsc..."
25- yarn tsc || true
23+ if ! yarn build 2> /dev/null ; then
24+ # echo "yarn build failed for $package, trying yarn tsc..."
25+ yarn tsc 2> /dev/null || true
2626 fi
2727 cd " $SCRIPT_DIR "
2828 fi
@@ -55,24 +55,27 @@ get_db_types() {
5555 fi
5656 fi
5757 done
58- echo " ${db_types[@]} "
58+ printf " %s\n " " ${db_types[@]} "
5959}
6060
6161# Function to create new project
6262create_project () {
6363 local app_name=$1
6464 local db_type=$2
65-
65+
6666 # If app_name is not provided, ask for it
6767 if [ -z " $app_name " ]; then
68- read -p " Enter the application name: " app_name
68+ read -r - p " Enter the application name: " app_name
6969 fi
70-
70+
7171 # If db_type is not provided, show selection menu
7272 if [ -z " $db_type " ]; then
7373 # Get available database types
74- readarray -t db_types < <( get_db_types)
75-
74+ db_types=()
75+ while IFS= read -r line; do
76+ db_types+=(" $line " )
77+ done < <( get_db_types)
78+
7679 echo " Available database types:"
7780 PS3=' Please select the database type: '
7881 select DB_TYPE in " ${db_types[@]} "
@@ -85,16 +88,20 @@ create_project() {
8588 fi
8689 done
8790 fi
88-
91+
8992 cd " $CURRENT_DIR "
9093 echo " Creating new project with name $app_name and database type $db_type ..."
9194 node " $SCRIPT_DIR /packages/cubejs-cli/dist/src/index.js" create " $app_name " -d " $db_type "
95+ link_project_packages " $app_name "
96+
97+ echo " Project setup completed!"
98+ echo " You can now run 'yarn dev' in the $app_name directory to start your project."
9299}
93100
94101# Function to link packages to new project
95102link_project_packages () {
96103 local app_name=$1
97-
104+
98105 echo " Linking packages in the new project..."
99106 cd " $CURRENT_DIR /$app_name "
100107 for package in " $SCRIPT_DIR " /packages/* ; do
@@ -110,15 +117,11 @@ link_project_packages() {
110117setup () {
111118 local app_name=$1
112119 local db_type=$2
113-
120+
114121 install_root_dependencies
115122 build_packages
116123 link_packages
117124 create_project " $app_name " " $db_type "
118- link_project_packages " $app_name "
119-
120- echo " Project setup completed!"
121- echo " You can now run 'yarn dev' in the $app_name directory to start your project."
122125}
123126
124127# Function to show help
@@ -174,16 +177,16 @@ case "$command" in
174177 ;;
175178 " link" )
176179 link_packages
177- link_project_packages " $1 "
180+ link_project_packages " $2 "
178181 ;;
179182 " drivers" )
180183 get_db_types
181184 ;;
182185 " create" )
183- create_project " $1 " " $2 "
186+ create_project " $2 " " $3 "
184187 ;;
185188 " setup" )
186- setup " $1 " " $2 "
189+ setup " $2 " " $3 "
187190 ;;
188191 " -h" |" --help" |" help" )
189192 show_help
@@ -197,3 +200,4 @@ case "$command" in
197200esac
198201
199202cd " $CURRENT_DIR "
203+
0 commit comments