Skip to content

Instantly share code, notes, and snippets.

@joshnuss
Last active March 24, 2023 14:45
Show Gist options
  • Save joshnuss/a287981b45cd88f9ec72b3db43b48052 to your computer and use it in GitHub Desktop.
Save joshnuss/a287981b45cd88f9ec72b3db43b48052 to your computer and use it in GitHub Desktop.

Revisions

  1. joshnuss revised this gist Mar 23, 2023. No changes.
  2. joshnuss created this gist Mar 23, 2023.
    29 changes: 29 additions & 0 deletions .bash_aliases
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    # Create a vanilla SvelteKit project
    # usage: sk <folder-name>
    sk() {
    pnpm create svelte@latest $1 \
    && cd $1 \
    && pnpm install \
    && git init \
    && git add . \
    && git commit -m 'Initial commit'
    }

    # Create a SvelteKit project with Prisma configured
    # usage: sk-prisma <folder-name>
    sk_prisma() {
    # replace dashes with underscores and add _dev suffix
    DB_NAME=$(echo "$1_dev" | sed s/-/_/g)
    DB_URL="postgresql://postgres:postgres@localhost:5432/$DB_NAME?schema=public"

    sk $1 \
    && pnpm install -D prisma @prisma/client \
    && pnpm prisma init --url "$DB_URL" \
    && mkdir -p src/lib \
    && echo -e "import { PrismaClient } from '@prisma/client'\n\nexport const db = new PrismaClient()" >> src/lib/db.server.js \
    && git add . \
    && git commit -m 'Added prisma'
    }

    # function names can't have dashes, but aliases can
    alias sk-prisma=sk_prisma