chore: pnpm migration

This commit is contained in:
Ben Allfree 2023-11-03 09:38:22 -07:00
parent 2c05bf5ff8
commit ce97108c62
22 changed files with 7530 additions and 9204 deletions

View File

@ -4,7 +4,7 @@
branch="$(git rev-parse --abbrev-ref HEAD)"
if [ "$branch" = "master" ]; then
yarn check:types
yarn lint
pnpm check:types
pnpm lint
fi

View File

@ -1,5 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
yarn check:types
yarn lint
pnpm check:types
pnpm lint

View File

@ -24,16 +24,16 @@ If you're still interested in creating a PocketHost hosting environment for your
```
apt-get update
apt-get install -y nginx nodejs npm
npm i -g n yarn
npm i -g n pnpm
n lts
hash -r
git clone git@github.com:benallfree/pockethost.git pockethost-latest
cd pockethost-latest
yarn
pnpm
cd ..
git clone git@github.com:benallfree/pockethost.git pockethost-lts
cd pockethost-lts
yarn
pnpm
cd ..
```

View File

@ -6,7 +6,7 @@
- `sudo ./scripts/build.sh`
- `sudo ./scripts/prod.sh`
- Finalize readme
- `yarn version --patch`
- `pnpm version --patch`
- `sudo ./scripts/pm2.sh`
- `sudo crontab -e`
- Create new discussion in PocketHost and PocketBase
@ -18,7 +18,7 @@
```bash
git clone git@github.com:benallfree/pockethost.git
cd pockethost
yarn
pnpm
cp .env-template .env # modify as needed
scripts/build.sh
```
@ -46,7 +46,7 @@ If all goes well:
- Update `./gitbook/releases` with latest relevant fixes.
- Create a new discussion on PocketHost forum
- If major release, create announcement on PocketBase forum
- Use `yarn version --patch` for patch release and tag with git
- Use `pnpm version --patch` for patch release and tag with git
- Use `scripts/build.sh` to rebuild everything
- Use `scripts/pm2.sh` to run in prod mode

View File

@ -7,10 +7,10 @@ PocketHost is designed to run full stack on your local development machine.
```bash
git clone git@github.com:benallfree/pockethost.git
cd pockethost
yarn
yarn dev:www # Marketing site only, talks to pockethost.io
yarn dev:dashboard # Dashboard site only, talks to pockethost.io
yarn dev # Everything, talks to pockethost.lvh.me
pnpm
pnpm dev:www # Marketing site only, talks to pockethost.io
pnpm dev:dashboard # Dashboard site only, talks to pockethost.io
pnpm dev # Everything, talks to pockethost.lvh.me
```
## Just the Frontend
@ -24,7 +24,7 @@ If you're only doing frontend development, it is much easier to point these at t
## All Our Base
You can run the complete PocketHost stack locally. A simple `yarn dev` will fire up:
You can run the complete PocketHost stack locally. A simple `pnpm dev` will fire up:
- `https://pockethost.lvh.me` - Marketing/blog
- `https://app.pockethost.lvh.me` - Dashboard (app)

View File

@ -1,17 +0,0 @@
For security, PocketHost does not allow modification of records by the frontend PocketBase client. Instead, the frontend must send an RPC request which the backend will securely process. This allows for many security vulnerabilities to be addressed which PocketBase admin security rules cannot. In particular, PocketBase admin security rules fall short in these scenarios:
- When the incoming data cannot be validated declaratively
- When multiple records and/or tables must be updated as a transaction
- When side effects (ie, other mutations) are required under specific conditions
Therefore, PocketHost uses an RPC pattern instead.
## Creating a new RPC Call
1. From the command line, run `npx hygen rpc new <FunctionName>`. This will generate all necessary files for both frontend and backend support of your RPC call.
2. Edit `./packages/common/src/schema/Rpc/<FunctionName>.ts` to suit the schema you want.
3. Edit `./packages/daemon/services/RpcService/commands.ts` to respond to the RPC command
## Getting the result from an RPC call
RPC results are currently not supported. RPC commands are run asynchronously.

View File

@ -5,4 +5,3 @@ node_modules
/package
dist-server
.idea
yarn-error.log

View File

@ -6,7 +6,7 @@ Description about PocketHost goes here!
## Developing Locally
To run this project, navigate to the `/packages/dashboard` folder and run `yarn dev`.
To run this project, navigate to the `/frontends/dashboard` folder and run `pnpm dev`.
It will start up the server here: [http://127.0.0.1:5173/](http://127.0.0.1:5173/) and now you're ready to code!

View File

@ -7,7 +7,7 @@
"check:types": "svelte-check",
"preview": "npx http-server@latest ./build -P \"http://localhost:8080?\"",
"dev": "vite dev --force",
"build": "yarn && vite build",
"build": "NODE_ENV=production vite build",
"lint": "prettier --check .",
"format": "prettier --write ."
},

File diff suppressed because it is too large Load Diff

View File

@ -5,8 +5,8 @@ Built with 11ty, Tailwind, Daisy UI, and Markdown
## Getting Started
- Clone the repo
- Run `yarn install` at the project root
- Navigate to `packages/www/`
- Run `pnpm install` at the project root
- Navigate to `frontends/www/`
- Run `npx @11ty/eleventy --serve --quiet` to start the development server
- Access the site at http://localhost:8080/
@ -16,7 +16,7 @@ Built with 11ty, Tailwind, Daisy UI, and Markdown
### Creating Variables
You can use the `set` function from nunjucks to create variables.
You can use the `set` function from nunjucks to create variables.
```twig
{% set linkCSS = "block py-2 px-3 rounded hover:text-white hover:bg-zinc-800" %}
@ -52,7 +52,7 @@ You can use the `macro` command to create reusable functions. An example looks l
{% endmacro %}
```
Now that your component has been built with the three properties: `text`, `url`, and the optional `icon`, you can import it wherever you want. Note that imports by default start in the `_includes` folder, so no need to reference through the folder tree to get to it.
Now that your component has been built with the three properties: `text`, `url`, and the optional `icon`, you can import it wherever you want. Note that imports by default start in the `_includes` folder, so no need to reference through the folder tree to get to it.
```twig
{# /content/about.njk #}
@ -64,7 +64,6 @@ Now that your component has been built with the three properties: `text`, `url`,
You can also make macros, or reusable functions, within the page itself, as long as that component is only being used on that specific page. If you need to use it in multiple pages, it is best to put it in its own file in the `_includes/components` folder.
### Reference Page Data
Within each page, you can add metadata at the very top like so:
@ -91,7 +90,7 @@ New post! Read the description below:
{{ description }}
```
The metadata will be injected into the template, and rendered as static html.
The metadata will be injected into the template, and rendered as static html.
### Folder Structure
@ -113,46 +112,45 @@ public/ # This folder is copied into the _site folder at compile time. Images an
└── webfonts # This holds the Font Awesome icon system
```
## 11ty Advanced Features
- 11ty "Get Started" Documentation: https://www.11ty.dev/docs/getting-started/
- Using [Eleventy v2.0](https://www.11ty.dev/blog/eleventy-v2/) with zero-JavaScript output.
- Content is exclusively pre-rendered (this is a static site).
- Can easily [deploy to a subfolder without changing any content](https://www.11ty.dev/docs/plugins/html-base/)
- All URLs are decoupled from the contents location on the file system.
- Configure templates via the [Eleventy Data Cascade](https://www.11ty.dev/docs/data-cascade/)
- Content is exclusively pre-rendered (this is a static site).
- Can easily [deploy to a subfolder without changing any content](https://www.11ty.dev/docs/plugins/html-base/)
- All URLs are decoupled from the contents location on the file system.
- Configure templates via the [Eleventy Data Cascade](https://www.11ty.dev/docs/data-cascade/)
- **Performance focused** with no client-side javascript
- Local development live reload provided by [Eleventy Dev Server](https://www.11ty.dev/docs/dev-server/).
- Content-driven [navigation menu](https://www.11ty.dev/docs/plugins/navigation/)
- [Image optimization](https://www.11ty.dev/docs/plugins/image/) via the `{% image %}` shortcode.
- Zero-JavaScript output.
- Support for modern image formats automatically (e.g. AVIF and WebP)
- Prefers `<img>` markup if possible (single image format) but switches automatically to `<picture>` for multiple image formats.
- Automated `<picture>` syntax markup with `srcset` and optional `sizes`
- Includes `width`/`height` attributes to avoid [content layout shift](https://web.dev/cls/).
- Includes `loading="lazy"` for native lazy loading without JavaScript.
- Includes [`decoding="async"`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/decoding)
- Images can be co-located with blog post files.
- View the [Image plugin source code](https://github.com/11ty/eleventy-base-blog/blob/main/eleventy.config.images.js)
- Zero-JavaScript output.
- Support for modern image formats automatically (e.g. AVIF and WebP)
- Prefers `<img>` markup if possible (single image format) but switches automatically to `<picture>` for multiple image formats.
- Automated `<picture>` syntax markup with `srcset` and optional `sizes`
- Includes `width`/`height` attributes to avoid [content layout shift](https://web.dev/cls/).
- Includes `loading="lazy"` for native lazy loading without JavaScript.
- Includes [`decoding="async"`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/decoding)
- Images can be co-located with blog post files.
- View the [Image plugin source code](https://github.com/11ty/eleventy-base-blog/blob/main/eleventy.config.images.js)
- Per page CSS bundles [via `eleventy-plugin-bundle`](https://github.com/11ty/eleventy-plugin-bundle).
- Built-in [syntax highlighter](https://www.11ty.dev/docs/plugins/syntaxhighlight/) (zero-JavaScript output).
- Blog Posts
- Draft posts: use `draft: true` to mark a blog post as a draft. Drafts are **only** included during `--serve`/`--watch` and are excluded from full builds. View the [Drafts plugin source code](https://github.com/11ty/eleventy-base-blog/blob/main/eleventy.config.drafts.js).
- Automated next/previous links
- Accessible deep links to headings
- Draft posts: use `draft: true` to mark a blog post as a draft. Drafts are **only** included during `--serve`/`--watch` and are excluded from full builds. View the [Drafts plugin source code](https://github.com/11ty/eleventy-base-blog/blob/main/eleventy.config.drafts.js).
- Automated next/previous links
- Accessible deep links to headings
- Generated Pages
- Home, Archive, and About pages.
- [Feeds for Atom and JSON](https://www.11ty.dev/docs/plugins/rss/)
- `sitemap.xml`
- Zero-maintenance tag pages ([View on the Demo](https://eleventy-base-blog.netlify.app/tags/))
- Content not found (404) page
- Home, Archive, and About pages.
- [Feeds for Atom and JSON](https://www.11ty.dev/docs/plugins/rss/)
- `sitemap.xml`
- Zero-maintenance tag pages ([View on the Demo](https://eleventy-base-blog.netlify.app/tags/))
- Content not found (404) page
- `content/blog/` has the blog posts, but really they can live in any directory. They need only the `posts` tag to be included in the blog posts [collection](https://www.11ty.dev/docs/collections/).
- Content can be in _any template format_ (blog posts neednt exclusively be markdown, for example). Configure your projects supported templates in `eleventy.config.js` -> `templateFormats`.
- The `public` folder in your input directory will be copied to the output folder (via `addPassthroughCopy` in the `eleventy.config.js` file). This means `./public/css/*` will live at `./_site/css/*` after your build completes.
- Provides two content feeds:
- `content/feed/feed.njk`
- `content/feed/json.njk`
- `content/feed/feed.njk`
- `content/feed/json.njk`
- This project uses multiple [Eleventy Layouts](https://www.11ty.dev/docs/layouts/):
- `_includes/components/postslist.njk` is a Nunjucks include and is a reusable component used to display a list of all the posts. `content/index.njk` has an example of how to use it.
@ -163,4 +161,4 @@ public/ # This folder is copied into the _site folder at compile time. Images an
- [Daisy UI Documentation](https://daisyui.com/)
- [Font Awesome Documentation](https://fontawesome.com/v5.15/how-to-use/on-the-web/referencing-icons/basic-use)
- [Markdown Cheatsheet](https://www.markdownguide.org/cheat-sheet/)
- [Nunjucks Documentation](https://mozilla.github.io/nunjucks/templating.html)
- [Nunjucks Documentation](https://mozilla.github.io/nunjucks/templating.html)

View File

@ -1,4 +1,6 @@
require('dotenv').config({ path: '.env' })
if (process.env.NODE_ENV !== 'production') {
require('dotenv').config({ path: '.env' })
}
/**
* These environment variables default to pointing to the production build so frontend development is easy.

View File

@ -3,7 +3,7 @@
"version": "8.0.0",
"description": "A starter repository for a blog web site using the Eleventy site generator.",
"scripts": {
"build": "npx @11ty/eleventy",
"build": "NODE_ENV=production npx @11ty/eleventy",
"build-ghpages": "npx @11ty/eleventy --pathprefix=/eleventy-base-blog/",
"start:tailwind": "tailwind -i ./public/css/index.css -o ./_site/css/index.css --watch",
"start": "npx @11ty/eleventy --serve --quiet",

File diff suppressed because it is too large Load Diff

View File

@ -4,28 +4,28 @@
"author": "Ben Allfree <ben@benallfree.com>",
"license": "MIT",
"scripts": {
"check:types": "concurrently 'yarn:check:types:*'",
"check:types:dashboard": "cd frontends/dashboard && yarn check:types",
"check:types": "concurrently 'pnpm:check:types:*'",
"check:types:dashboard": "cd frontends/dashboard && pnpm check:types",
"check:types:pockethost": "tsc --noEmit --skipLibCheck",
"lint": "prettier -c \"./**/*.{ts,js,cjs,svelte,json}\"",
"lint:fix": "prettier -w \"./**/*.{ts,js,cjs,svelte,json}\"",
"build": "concurrently 'yarn:build:*'",
"build:dashboard": "cd frontends/dashboard && yarn build",
"build:www": "cd frontends/www && yarn build",
"build:mothership": "concurrently 'yarn:build:mothership:*'",
"build": "concurrently 'pnpm:build:*'",
"build-mothership": "concurrently 'pnpm:build:mothership:*'",
"build-pockethost": "concurrently 'pnpm:build:pockethost:*'",
"build:dashboard": "cd frontends/dashboard && pnpm build",
"build:www": "cd frontends/www && pnpm build",
"build:mothership:migrations": "cd src/mothership-app/migrations && copyfiles '*' ../../../dist/mothership-app/migrations",
"build:mothership:hooks": "esbuild --platform=node --format=cjs --bundle --outfile=./dist/mothership-app/pb_hooks/index.pb.js ./src/mothership-app/pb_hooks/src/index.ts ",
"build:pockethost": "concurrently 'yarn:build:pockethost:*'",
"build:pockethost:docker": "cd src/services/PocketBaseService && docker build -t benallfree/pockethost-instance .",
"push:docker": "docker tag benallfree/pockethost-instance benallfree/pockethost-instance:latest && docker push benallfree/pockethost-instance:latest",
"dev": "concurrently 'yarn:dev:*'",
"dev:www": "cd frontends/www && yarn start",
"dev:dashboard": "cd frontends/dashboard && yarn dev",
"dev:daemon": "concurrently 'yarn:dev:daemon:*'",
"dev": "concurrently 'pnpm:dev:*'",
"dev-daemon": "concurrently 'pnpm:dev:daemon:*'",
"dev:www": "cd frontends/www && pnpm start",
"dev:dashboard": "cd frontends/dashboard && pnpm dev",
"dev:daemon:server": "tsx watch src/server.ts",
"dev:daemon:hooks": "chokidar './src/mothership-app/pb_hooks/**' -c 'yarn build:mothership:hooks' --initial",
"dev:daemon:hooks": "chokidar './src/mothership-app/pb_hooks/**' -c 'pnpm build:mothership:hooks' --initial",
"start": "tsx src/server.ts",
"pm2": "pm2 stop all; pm2 del daemon ; pm2 start \"yarn start\" --name=daemon -l /home/pockethost/logs/daemon-`date +%s`.log",
"pm2": "pm2 stop all; pm2 del daemon ; pm2 start \"pnpm start\" --name=daemon -l /home/pockethost/logs/daemon-`date +%s`.log",
"plop": "plop",
"prepare": "[ -d '.git' ] && husky install || echo 'skipping husky'"
},
@ -54,6 +54,7 @@
"event-source-polyfill": "^1.0.31",
"eventsource": "^2.0.2",
"exit-hook": "^4.0.0",
"find-up": "^6.3.0",
"ftp-srv": "https://github.com/pockethost/ftp-srv.git#0fc708bae0d5d7a55ce948767f082d6fcfb2af59",
"get-port": "^6.1.2",
"glob": "^10.3.10",

7443
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

4
pnpm-workspace.yaml Normal file
View File

@ -0,0 +1,4 @@
packages:
# all packages in direct subdirs of packages/
- 'frontends/*'
- '!live-data'

View File

@ -51,9 +51,9 @@ If you just want to work on the UI/frontend client apps, they are configured to
```bash
git clone git@github.com:benallfree/pockethost.git
cd pockethost
yarn
yarn dev:www # Marketing/blog area
yarn dev:dashboard # Dashboard/control panel
pnpm
pnpm dev:www # Marketing/blog area
pnpm dev:dashboard # Dashboard/control panel
```
## All our base
@ -75,14 +75,14 @@ Then:
```bash
git clone git@github.com:benallfree/pockethost.git
cd pockethost
yarn
pnpm
cp .env-template .env
```
`.env-template` is preconfigured to make all of PocketHost run locally using `lvh.me` as follows:
```bash
yarn dev
pnpm dev
# marketing/blog
open https://pockethost.lvh.me
@ -132,17 +132,17 @@ That's it! You can control all this and much more from the `.env-template` file.
The Mothership is a set of backend services, including a central `pocketbase` instance, that is the source of truth for the state of PocketHost.
| Name | Default | Discussion |
| ------------------------- | ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| MOTHERSHIP_MIGRATIONS_DIR | `<root>/packages/daemon/migrations` | The directory where the Mothership migrations live. This is typically kept in revision control, so the default location is within the project directory structure. |
| MOTHERSHIP_HOOKS_DIR | `<root>/packages/daemon/pb_hooks` | The directory where the Mothership `pb_hooks` live. This is typically kept in revision control, so the default location is within the project directory structure. |
| MOTHERSHIP_ADMIN_USERNAME | `admin@pockethost.lvh.me` | This admin login is created the first time PocketHost runs. |
| MOTHERSHIP_ADMIN_PASSWORD | `password` | |
| DEMO_USER_USERNAME | `user@pockethost.lvh.me` | This login is created the first time PocketHost runs |
| DEMO_USER_PASSWORD | `password` | |
| MOTHERSHIP_PORT | `8091` | The port the Mothership service will listen on. |
| MOTHERSHIP_SEMVER | `(blank)` | The semver used to lock the Mothership to a specific `pocketbase` version range. The Mothership will never launch with a `pocketbase` binary version outside this range. |
| MOTHERSHIP_PRIVATE_URL | `http://mothership.pockdthost.lvh.me` | This should be set to an intranet IP address in production settings. |
| Name | Default | Discussion |
| ------------------------- | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| MOTHERSHIP_MIGRATIONS_DIR | `<root>/src/mothership-app/migrations` | The directory where the Mothership migrations live. This is typically kept in revision control, so the default location is within the project directory structure. |
| MOTHERSHIP_HOOKS_DIR | `<root>/src/mothership-app/pb_hooks` | The directory where the Mothership `pb_hooks` live. This is typically kept in revision control, so the default location is within the project directory structure. |
| MOTHERSHIP_ADMIN_USERNAME | `admin@pockethost.lvh.me` | This admin login is created the first time PocketHost runs. |
| MOTHERSHIP_ADMIN_PASSWORD | `password` | |
| DEMO_USER_USERNAME | `user@pockethost.lvh.me` | This login is created the first time PocketHost runs |
| DEMO_USER_PASSWORD | `password` | |
| MOTHERSHIP_PORT | `8091` | The port the Mothership service will listen on. |
| MOTHERSHIP_SEMVER | `(blank)` | The semver used to lock the Mothership to a specific `pocketbase` version range. The Mothership will never launch with a `pocketbase` binary version outside this range. |
| MOTHERSHIP_PRIVATE_URL | `http://mothership.pockdthost.lvh.me` | This should be set to an intranet IP address in production settings. |
## Edge Variables (backend only)

View File

@ -8,4 +8,4 @@ set +a
pm2 stop all
docker kill $(docker ps -q)
docker rm $(docker ps -a -q)
yarn dev
pnpm dev

View File

@ -15,4 +15,4 @@ chown pockethost:pockethost -R $LOG_ROOT
pm2 stop all
docker kill $(docker ps -q)
docker rm $(docker ps -a -q)
yarn pm2
pnpm pm2

View File

@ -7,4 +7,4 @@ set +a
pm2 stop all
docker kill $(docker ps -q)
docker rm $(docker ps -a -q)
yarn start
pnpm start

5135
yarn.lock

File diff suppressed because it is too large Load Diff