Created
January 13, 2023 15:15
-
-
Save xenophy/1cb9eaeb7ee78d35c7497655e86f6126 to your computer and use it in GitHub Desktop.
Setup Nuxt3 + Prisma(SQLite)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -ne 1 ]; then | |
echo "プロジェクト名を設定設定してください。" 1>&2 | |
exit 1 | |
fi | |
# プロジェクト名設定 | |
PROJECT_NAME=$1 | |
# Nuxt3 セットアップ | |
npx nuxi init ${PROJECT_NAME} | |
# ディレクトリ移動 | |
cd ${PROJECT_NAME} | |
# パッケージインストール | |
npm install | |
# ディレクトリ作成 | |
ADD_DIRS=( | |
"assets" | |
"components" | |
"composables" | |
"layouts" | |
"middleware" | |
"pages" | |
"plugins" | |
"server" | |
"server/api" | |
) | |
for ADD_DIRS in "${ADD_DIRS[@]}" ; do | |
mkdir ${ADD_DIRS} | |
touch ${ADD_DIRS}/.gitkeep | |
done | |
rm server/api/.gitkeep | |
# レイアウトファイル作成 | |
cat << EOT >> layouts/default.vue | |
<template> | |
<div> | |
<slot /> | |
</div> | |
</template> | |
EOT | |
# メインページファイル作成 | |
cat << EOT >> pages/index.vue | |
<script setup> | |
const { data } = useFetch('/api/hello'); | |
</script> | |
<template> | |
<div> | |
<h1>Main Page</h1> | |
<h2>{{ data }}</h2> | |
</div> | |
</template> | |
EOT | |
# HelloAPIファイル作成 | |
cat << EOT >> server/api/hello.ts | |
export default defineEventHandler(() => "Hello World"); | |
EOT | |
# app.vue 削除 | |
rm app.vue | |
# Prisma インストール | |
npm install prisma | |
npx prisma init | |
sed -i s/postgresql/sqlite/g prisma/schema.prisma | |
echo "DATABASE_URL=\"file:./dev.db\"" >> .env | |
# ブラウザ表示 | |
npm run dev -- -o | |
# EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment