-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscaffold-honojs.sh
More file actions
executable file
·112 lines (85 loc) · 2.38 KB
/
scaffold-honojs.sh
File metadata and controls
executable file
·112 lines (85 loc) · 2.38 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env bash
# checking we the user has bun or node or deno install
declare -A INSTALL_HINTS=(
[node]="https://nodejs.org"
[bun]="https://bun.sh"
)
declare -A PACKAGE_MANAGER=(
[node]="pnpm"
[bun]="bunx"
)
project_name="${1:-.}"
project_name="${project_name// /-}"
TOOLS=(node bun)
found=false
found_tool=""
BASE_DIR="$(pwd)"
for tool in "${TOOLS[@]}"; do
if command -v "$tool" >/dev/null 2>&1; then
found=true
found_tool="$tool"
break
fi
done
if ! $found;then
for tool in "${TOOLS[@]}";do
echo "$tool missing, download from -> ${INSTALL_HINTS[$tool]}"
done
exit 1
fi
if ! "${PACKAGE_MANAGER[$found_tool]}" create hono@latest "$project_name"; then
echo "fail to create the hono app"
exit 1
fi
# moving in to the project root dir
cd "$BASE_DIR/$project_name"
# adding zod, drizzle stuff bun-types
if ! "${PACKAGE_MANAGER[$found_tool]}" add zod drizzle-orm pg; then
echo "fail to install zod, drizzle-orm pg"
exit 1
fi
if ! "${PACKAGE_MANAGER[$found_tool]}" -D add @types/bun @biomejs/biome drizzle-kit @types/pg; then
echo "fail to install @types/bun drizzle-kit @biomejs/biome and @types/pg"
exit 1
fi
#setting up biome
if ! "${PACKAGE_MANAGER[$found_tool]}" exec biome init; then
echo "fail to initialize biome"
exit 1
fi
# adding the test dir
if ! mkdir test; then
echo "fail to create the test dir"
exit 1
fi
# adding the .gitignore, env and env.example drizzle.config.ts, docker-compose.yml
if ! touch .gitignore .env .env.example drizzle.config.ts docker-compose.yml; then
echo "fail to create needed files"
exit 1
fi
#moving in to the test dir
cd test
if ! mkdir unit e2e; then
echo "fail to create the unit and e2e dir"
exit 1
fi
# moving to root of the project again
cd ../
#making the different folders in the src
cd src/
if ! mkdir validator routes db middlewares lib types scripts utils; then
echo "fail to create the validator routes types scripts db middleware libs and utils folders"
exit 1
fi
# making the db files needed
cd db/
if ! touch drizzle.ts schema.ts; then
echo "fail to created the needed db files"
exit 1
fi
# going back to the root
cd ../../
# finish creating the app
echo " "
echo "..............Hono APP Created.............."
echo " "