Skip to content

Commit

Permalink
Preheat 2 (#1739)
Browse files Browse the repository at this point in the history
* re-writes preheat in node

* updates readme with more simple instructions

* removes rust startup script in favor of preheat

* add dotenv-expand; add create/update to preheat (#1740)

* removes comments a tweaks seeding code

---------

Co-authored-by: CJ <[email protected]>
  • Loading branch information
stolinski and w3cj authored Jul 12, 2024
1 parent f05345b commit 0644b8a
Show file tree
Hide file tree
Showing 9 changed files with 311 additions and 3,063 deletions.
75 changes: 43 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,55 @@ This site is built on SvelteKit.

## Prerequisite

* Install Node - https://nodejs.org/en
* Install pnpm - https://pnpm.io/installation
* If you are on a Mac, there is an issue with the curl install.
* Preferably, use homebrew to install:
* `brew install pnpm`
* Install mysql or use docker with the provided `docker-compose.yml` file.
- Install Node - https://nodejs.org/en
- Install pnpm - https://pnpm.io/installation
- If you are on a Mac, there is an issue with the curl install.
- Preferably, use homebrew to install:
- `brew install pnpm`
- Install mysql or use docker with the provided `docker-compose.yml` file.

This site uses MySQL via Prisma, so you will need a valid MySQL connection string.

## Getting Started

### Without Docker

Have your database connection string handy.

1. `pnpm install`
2. `pnpm preheat`
3. `pnpm dev`

That's it!

### With Docker

1. Read Prerequisites above ^^ before starting
1. Copy `.env.example` to `.env` and specify env variables (needs at least `DATABASE_URL`, see [here](#where-to-get-your-own-environment-variables) for how to get the others)
* If using Docker, add the following at the top of your `.env` file to share variables with the `docker-compose.yml` (replace the existing DATABASE_URL with the one below)
```sh
# required to run the seed commands within the container
DOCKER=true
# any value other than "true" is considered false
DATABASE_HOST=localhost
DATABASE_PORT=3306
DATABASE_USER=syntax
DATABASE_PASSWORD=syntax
DATABASE_NAME=syntax
DATABASE_ROOT_PASSWORD=syntax
DATABASE_URL=mysql://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}
```
- If using Docker, add the following at the top of your `.env` file to share variables with the `docker-compose.yml` (replace the existing DATABASE_URL with the one below)
```sh
# required to run the seed commands within the container
DOCKER=true
# any value other than "true" is considered false
DATABASE_HOST=localhost
DATABASE_PORT=3306
DATABASE_USER=syntax
DATABASE_PASSWORD=syntax
DATABASE_NAME=syntax
DATABASE_ROOT_PASSWORD=syntax
DATABASE_URL=mysql://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}
```
1. If using docker, in a separate tab run -> `docker compose up`
1. Run -> `pnpm preheat`
1. Run -> `pnpm db:push`
1. Run -> `pnpm dev`
1. Visit `http://localhost:5173`

### Scripts

* Generate Types `pnpm db:generate`
* DB studio `pnpm db:studio`
* DB Migrations `pnpm db:push`
* DB Seed `pnpm db:seed`
- Generate Types `pnpm db:generate`
- DB studio `pnpm db:studio`
- DB Migrations `pnpm db:push`
- DB Seed `pnpm db:seed`

### About this codebase

Expand Down Expand Up @@ -89,14 +100,14 @@ These are the available media queries:

### Where to get your own Environment Variables

| Variable | Where to get it | Notes |
| -- | -- | -- |
| PUBLIC_GITHUB_ID, GH_SECRET | [Github Oauth Apps](https://github.com/settings/developers) | Create new OAuth App, set `http://localhost:5173/api/oauth/github/callback` as the redirect URL |
| DEEPGRAM_SECRET | [Deepgram](https://console.deepgram.com/) | |
| SENTRY_AUTH_TOKEN | [Sentry](https://docs.sentry.io/product/accounts/auth-tokens/) | |
| OPENAI_API_KEY | [Open AI](https://platform.openai.com/account/api-keys) | |
| UPSPLASH_TOKEN, UPSPLASH_URL | [https://upstash.com/](https://upstash.com/) | Create a redis DB after sign up in the console |
| YOUTUBE_API_KEY | [Google API Console](https://console.cloud.google.com/apis/credentials) | Create an API key, visit the library and enable "YouTube Data API v3" |
| Variable | Where to get it | Notes |
| ---------------------------- | ----------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| PUBLIC_GITHUB_ID, GH_SECRET | [Github Oauth Apps](https://github.com/settings/developers) | Create new OAuth App, set `http://localhost:5173/api/oauth/github/callback` as the redirect URL |
| DEEPGRAM_SECRET | [Deepgram](https://console.deepgram.com/) | |
| SENTRY_AUTH_TOKEN | [Sentry](https://docs.sentry.io/product/accounts/auth-tokens/) | |
| OPENAI_API_KEY | [Open AI](https://platform.openai.com/account/api-keys) | |
| UPSPLASH_TOKEN, UPSPLASH_URL | [https://upstash.com/](https://upstash.com/) | Create a redis DB after sign up in the console |
| YOUTUBE_API_KEY | [Google API Console](https://console.cloud.google.com/apis/credentials) | Create an API key, visit the library and enable "YouTube Data API v3" |

# Our Contributors

Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "2.1.78",
"private": true,
"scripts": {
"dev": "./scripts/syntax_website_go",
"preheat": "./scripts/syntax_website_go --env-only",
"dev": "node ./scripts/preheat.js",
"preheat": "node ./scripts/preheat.js --env-only",
"vite-dev": "vite dev",
"copy-files": "zx ./why_do_i_need_this.mjs",
"build": "run-s --print-name build:svelte copy-files",
Expand Down Expand Up @@ -36,9 +36,11 @@
"@types/speakingurl": "^13.0.6",
"@typescript-eslint/eslint-plugin": "^7.14.1",
"@typescript-eslint/parser": "^7.14.1",
"dotenv": "^16.4.5",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.41.0",
"mysql2": "^3.10.2",
"postcss": "^8.4.38",
"postcss-custom-media": "^10.0.6",
"postcss-import": "^16.1.0",
Expand All @@ -48,6 +50,7 @@
"prettier": "^3.3.2",
"prettier-plugin-svelte": "^3.2.5",
"prisma": "5.12.0",
"semver": "^7.6.2",
"svelte": "^4.2.18",
"svelte-check": "^3.8.4",
"svelte-preprocess": "^5.1.4",
Expand Down Expand Up @@ -79,6 +82,7 @@
"chroma-js": "^2.4.2",
"core-js": "^3.37.1",
"date-fns": "^3.6.0",
"dotenv-expand": "^11.0.6",
"flexsearch": "^0.7.43",
"gpt-3-encoder": "^1.1.4",
"gray-matter": "^4.0.3",
Expand Down Expand Up @@ -111,4 +115,4 @@
"prisma": {
"seed": "node --loader ts-node/esm prisma/seed.ts"
}
}
}
Loading

0 comments on commit 0644b8a

Please sign in to comment.