-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-nextjs-project.sh
More file actions
98 lines (79 loc) · 2.95 KB
/
Copy pathcreate-nextjs-project.sh
File metadata and controls
98 lines (79 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#
# Create new next.js project.
# Author: @MaeWolff - Maxence WOLFF
#
##### COLORS #####
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
GREY='\033[0;90m'
NOCOLOR='\033[0m'
####################
choose_package_manager() {
echo "Which package manager do you want to use?"
echo "a) npm"
echo "b) yarn"
echo "c) pnpm"
echo "d) bun"
read -p "Select an option (a-d): " package_manager_option
case $package_manager_option in
a)
package_manager="npm"
;;
b)
package_manager="yarn"
;;
c)
package_manager="pnpm"
;;
d)
package_manager="bun"
;;
*)
echo -e "${RED}Invalid option. Using npm by default.${NOCOLOR}"
package_manager="npm"
;;
esac
}
remove_file() {
local file_path=$1
if [ -f "$file_path" ]; then
rm "$file_path"
echo "File $file_path removed."
else
echo "File $file_path does not exist."
fi
}
#
# MAIN
#
echo -e "${BLUE}–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––${NOCOLOR}"
choose_package_manager
read -p "What is your project named? " project_name
npx create-next-app@latest "--use-$package_manager" "$project_name"
cd $project_name
echo -e "${GREY}Fixing styles files...${NOCOLOR}"
remove_file "src/app/globals.css"
mkdir -p src/styles
echo '@tailwind base;
@tailwind components;
@tailwind utilities;' >src/styles/tailwind.css
sed -i '' -e 's|import \("./globals.css"\);|import \"../styles/tailwind.css"\;|' src/app/layout.tsx
echo -e "${BLUE}–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––${NOCOLOR}"
echo -e "${GREY}Adding prettier plugins...${NOCOLOR}"
$package_manager install -D prettier prettier-plugin-tailwindcss
echo '{
"plugins": ["prettier-plugin-tailwindcss"]
}' >.prettierrc
echo -e "${BLUE}–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––${NOCOLOR}"
echo -e "${GREY}Managing dependencies installation...${NOCOLOR}"
read -p "Do you want to install react-query and zod? (y/n): " install_react_query
if [ "$install_react_query" == "y" ]; then
$package_manager install @tanstack/react-query zod @types/react-query
fi
read -p "Do you want to install vitest? (y/n): " install_vitest
if [ "$install_vitest" == "y" ]; then
$package_manager install vitest -D
fi
echo -e "${GREEN} Done! ${NOCOLOR}"
echo -e "${GREEN}–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––${NOCOLOR}"