Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/teemukoivisto/sveltekit-monorepo-template
Monorepo with SvelteKit, pnpm, TypeScript, Express, Prisma, Postgres etc to supercharge your next project 🚀
https://github.com/teemukoivisto/sveltekit-monorepo-template
changesets express monorepo nodejs pnpm prisma svelte sveltekit tailwindcss typescript
Last synced: about 1 month ago
JSON representation
Monorepo with SvelteKit, pnpm, TypeScript, Express, Prisma, Postgres etc to supercharge your next project 🚀
- Host: GitHub
- URL: https://github.com/teemukoivisto/sveltekit-monorepo-template
- Owner: TeemuKoivisto
- License: mit
- Created: 2022-09-14T19:35:49.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-04T19:07:38.000Z (7 months ago)
- Last Synced: 2024-06-04T21:11:18.261Z (7 months ago)
- Topics: changesets, express, monorepo, nodejs, pnpm, prisma, svelte, sveltekit, tailwindcss, typescript
- Language: TypeScript
- Homepage: https://teemukoivisto.github.io/sveltekit-monorepo-template
- Size: 892 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [sveltekit-monorepo-template](https://github.com/teemukoivisto/sveltekit-monorepo-template)
Monorepo boilerplate that I use, transformed into its own template repository.
### [Cloudflare](https://sveltekit-monorepo-template.pages.dev/)
### [GitHub pages](https://teemukoivisto.github.io/sveltekit-monorepo-template/)
Not working as of 22.12.2022 due to how base paths are configured with SvelteKit
## How to setup
1. Copy the template using `Use this template`
2. Add [GH_ACTIONS_DEPLOY_KEY](https://docs.github.com/en/developers/overview/managing-deploy-keys#deploy-keys). Basically, run `ssh-keygen -t ed25519 -C "[email protected]"` and copy the public key to `Settings > Deploy keys > Add deploy key` (I named it `GH_ACTIONS_DEPLOY_KEY - public SSH key`). Then copy the private key to `Settings > Secrets > Actions` with name `GH_ACTIONS_DEPLOY_KEY`
3. (Optional) For default GITHUB_TOKEN permissions at `Settings > Actions > General` tick `Allow all actions and reusable workflows` `Read and write permissions` and check `Allow GitHub actions to create and approve pull requests`. This is required for the Changesets to create PRs and push tags (eg `@awesome-org/[email protected]`) from CI
4. Add also to secrets API_URL (the IP or URL of your deployed instance), [DOCKER_PAT](https://docs.docker.com/docker-hub/access-tokens/) & DOCKER_USER for pushing [API image to docker.io registry](https://hub.docker.com/r/tekkk/example-api) and optionally NPM_TOKEN if you want to publish packages to npm
5. Clone the repo
6. Run copy & replace for `@awesome-org` and `@teemukoivisto` using your own organization / username
7. Follow **How to run** instructions to run the app, then commit your changes preferably using https://www.conventionalcommits.org/en/v1.0.0/ This makes your CHANGELOGs much nicer## NPM packages
You can publish your component & other packages to npm. However, to use private npm packages you must either upgrade your npm account or use [Github package registry](https://docs.github.com/en/packages/learn-github-packages/introduction-to-github-packages). There's a one example package at `packages/private-pkg`. Basically, how it goes is you _must_ use your org/user name as the package's org. Then you must add a Github access token (I use the env GH_PAT) to the repository secrets which allows writing to package registry. Also anyone who wants to use that package will need an access token as well. Otherwise the flow is very much the same, use changesets to generate CHANGELOGs and code away!
## How to run
You must have `pnpm` >=9 installed globally: `npm i -g pnpm`. Also you need Docker. And if you want to access the Postgres instance `psql`.
1. `pnpm i`
2. `cp ./packages/api/.env-example ./packages/api/.env && cp ./packages/client/.env-example ./packages/client/.env && cp ./packages/db/.env-example ./packages/db/.env`
3. Generate JWT secrets with eg `openssl rand -base64 32`
4. `docker-compose up -d postgres`
5. `pnpm --filter db migrate`
6. `pnpm --filter db seed`
7. Build libraries: `pnpm lib`
8. Start the client in http://localhost:5577: `pnpm client`
9. In another terminal, start the API in http://localhost:7180: `pnpm api`## Commands
`pnpm` is a package manager that uses linking to reduce installation times.
It's pretty cool _but_ sometimes the linking might get funky, eg you remove a package from `packages/` and the links might not work anymore even after doing `pnpm i`. In that case trusty ol `rm -rf ./**/node_modules && pnpm i` helps.
- Install packages with: `pnpm --filter api add jsonwebtoken`.
- To install as devDependency use -D: `pnpm --filter client add -D rollup-svelte-plugin`
- Run commands with: `pnpm --filter client lint`
- To run command recursively in all packages: `pnpm -r lint`. NOTE: this will halt on first error so you might want to run it as script instead with `concurrently`.
- [You can use various filter options](https://pnpm.io/filtering): `pnpm --filter=!api lint`
- [Update dependencies to latest given their version range](https://pnpm.io/cli/update): `pnpm update`## Changesets
This project uses changesets https://github.com/changesets/changesets to generate changelogs but in short, when you commit from terminal the changeset prompt is opened in which you should write your functionality using conventional commits https://www.conventionalcommits.org/en/v1.0.0/ to create a changeset (which is for something that changes the library for the downstream users).