create-user-hub 0.4.3 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-user-hub",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "Start a TanStack Start + Convex app with User Hub sign-in: bun create user-hub@latest my-app",
5
5
  "type": "module",
6
6
  "bin": {
@@ -4,5 +4,6 @@ HUB_URL=https://hub.example.com
4
4
  HUB_API_KEY=
5
5
 
6
6
  # Written by bun run setup and the Convex CLI:
7
- # CONVEX_DEPLOYMENT, VITE_CONVEX_URL, VITE_HUB_URL. The app's event, name and
8
- # URLs in the hub go to user-hub.json, which is committed.
7
+ # CONVEX_DEPLOYMENT, VITE_CONVEX_URL, VITE_HUB_URL. The app's hub, event and
8
+ # name go to user-hub.json, which is committed; its URLs live in the hub
9
+ # (bunx user-hub dev, bunx user-hub prod).
@@ -5,7 +5,7 @@ A TanStack Start + Convex app whose sign-in comes from User Hub: people scan the
5
5
  ## How it is wired
6
6
 
7
7
  - `convex/hub.ts`: this app's key in the hub (`APP_KEY`, made from its event's slug and its name), written by `bun run setup`.
8
- - The app belongs to one hub **event** (a workshop): its slug is `event` in `user-hub.json` (with the app's name and URLs in the hub), saved by `bun run setup`. Commit it; it holds nothing secret.
8
+ - The app belongs to one hub **event** (a workshop): its slug is `event` in `user-hub.json` (with the hub and the app's name; its URLs live in the hub), saved by `bun run setup`. Commit it; it holds nothing secret.
9
9
  - `convex/auth.config.ts`: `hubAuth({ app: APP_KEY })`; Convex trusts hub tokens through `HUB_ISSUER` and `HUB_JWKS` on the deployment.
10
10
  - `src/routes/__root.tsx`: `ConvexHubAuthProvider` and `HubSignedIn` inside `<body>`. Never move them outside `<html>` or into the router's `Wrap`. Its `beforeLoad` reads the person's token on the server (`getHubToken`) and passes it as `initialToken`, so pages render signed in from the server: keep page components safe to render there (no `window` or `document` outside effects).
11
11
  - People: `useHubUser()` in components; `requireHubUser(ctx)` / `requireFacilitator(ctx)` in Convex functions. Key data on the person's hub id; check roles on the server.
@@ -27,6 +27,6 @@ A TanStack Start + Convex app whose sign-in comes from User Hub: people scan the
27
27
 
28
28
  ## Commands
29
29
 
30
- `bun run setup` (`user-hub setup`; once; signs the folder in first when run in a terminal and it is not; in a terminal it asks which hub event the app is for, or creates one, and saves it in `user-hub.json`), `bun run setup --event <slug>` (the event without asking: an agent asks the human which event and passes it, `bunx user-hub events list` lists them; never create an event unless the human asks, and then ask for its time zone too; with another event or `--name` than the ones in `user-hub.json`, the app is registered anew with a new app key and the earlier registration is left as it was), `bun run setup --prod <url>` (once deployed: registers the production URL so badge scans can reach the app; see the skill's "Production URL"), `bun run setup --dev <url>` (change where the hub opens the app for developers; first registered as `http://localhost:` plus the port in the `dev` script, kept on later runs; change the port in the `dev` script too: it is defined only there, and `server.strictPort` in `vite.config.ts` makes the dev server stop when the port is taken rather than move to another one the hub does not know), `bun run setup --unlisted` / `--listed` (keep the app out of the hub's badge app list, or put it back; new apps are listed), `bun run dev`, `bun run check` (`vp check`: format, lint and type-check), `bun run fix` (`vp check --fix`), `bun run typecheck`, `bun run build`, `just build` / `just push` (deploy Convex to production and build the Docker image against it; `IMAGE` sets the registry path; the container needs no env). Lint and format rules live in `vite.config.ts` (Vite+); `vp` is project-local, so run it through the scripts or `bunx vp`.
30
+ `bun run setup` (`user-hub setup`; once; signs the folder in first when run in a terminal and it is not; in a terminal it asks which hub event the app is for, or creates one, and saves it in `user-hub.json`), `bun run setup --event <slug>` (the event without asking: an agent asks the human which event and passes it, `bunx user-hub events list` lists them; never create an event unless the human asks, and then ask for its time zone too; with another event or `--name` than the ones in `user-hub.json`, the app is registered anew with a new app key and the earlier registration is left as it was), `bunx user-hub prod set <url>` (once deployed: registers the production URL so badge scans can reach the app and sets `HUB_ISSUER`/`HUB_JWKS` on the production Convex deployment; see the skill's "Production URL"; `bunx user-hub prod` shows it, `prod remove` removes it), `bunx user-hub dev list` / `dev add <url>` / `dev remove <url>` (the app has a list of development URLs, where the hub opens it for developers; the first is `http://localhost:` plus the port in the `dev` script; when changing the port, change the `dev` script too and add the new URL: the port is defined only there, and `server.strictPort` in `vite.config.ts` makes the dev server stop when the port is taken rather than move to another one the hub does not know), `bun run setup --unlisted` / `--listed` (keep the app out of the hub's badge app list, or put it back; new apps are listed), `bun run dev`, `bun run check` (`vp check`: format, lint and type-check), `bun run fix` (`vp check --fix`), `bun run typecheck`, `bun run build`, `just build` / `just push` (deploy Convex to production and build the Docker image against it; `IMAGE` sets the registry path; the container needs no env). Lint and format rules live in `vite.config.ts` (Vite+); `vp` is project-local, so run it through the scripts or `bunx vp`.
31
31
 
32
32
  **Hub moved:** sign the folder in to the new hub (`bunx user-hub login --hub <new url>`, replacing `HUB_URL` and `HUB_API_KEY`), run `bun run setup --hub-moved` (with `--event <slug>` when the new hub has no event with this app's saved event; it updates this app's registration and sets `HUB_ISSUER`/`HUB_JWKS` on Convex, production included once a production URL is known, and `VITE_HUB_URL`), then `just push`, because `VITE_HUB_URL` is built into the frontend.
@@ -12,9 +12,9 @@ A TanStack Start + Convex app with User Hub sign-in: people scan their badge and
12
12
 
13
13
  Paste an API key from the hub's account page, or press Enter and approve the sign-in in your browser. It saves `HUB_URL` and `HUB_API_KEY` to `.env.local`. Skip this if you signed in when the app was created; `bun run setup` also asks when this folder is not signed in.
14
14
 
15
- 2. `bun run setup` (`user-hub setup`): creates your Convex project, registers the app with the hub and sets everything up. The hub runs many workshops, called events, and the app belongs to one: setup lists the active events and asks which (or creates a new one, asking for its name and time zone). Without a terminal, pass it: `bun run setup --event <slug>` (`bunx user-hub events list` lists the slugs). If another app already has this name in the event, it asks you for a new one (or run `bun run setup --name <name>`). New apps show in the hub's badge app list once they have a production URL; `bun run setup --unlisted` keeps this one out and `--listed` puts it back. Safe to run again. Setup saves the app's event, name and URLs to `user-hub.json`: commit it. `--name` or `--event` with another name or event than the saved ones registers the app anew, with a new app key; setup leaves the earlier registration as it was.
16
- 3. `bun run dev`, then open http://localhost:3000. You are sent to the hub to pick who to be, then back signed in. If something else already uses that port, the dev server stops with an error instead of moving to another port, because the hub only sends you back to the registered URL. To use another port, change it in `package.json`'s `dev` script and run `bun run setup --dev http://localhost:<port>`; later runs of setup keep the development URL.
17
- 4. Once the app is deployed: `bun run setup --prod https://your-app.example.com`, so badge scans can reach it. Setup asks for this the first time; press Enter to skip until you deploy.
15
+ 2. `bun run setup` (`user-hub setup`): creates your Convex project, registers the app with the hub and sets everything up. The hub runs many workshops, called events, and the app belongs to one: setup lists the active events and asks which (or creates a new one, asking for its name and time zone). Without a terminal, pass it: `bun run setup --event <slug>` (`bunx user-hub events list` lists the slugs). If another app already has this name in the event, it asks you for a new one (or run `bun run setup --name <name>`). New apps show in the hub's badge app list once they have a production URL; `bun run setup --unlisted` keeps this one out and `--listed` puts it back. Safe to run again. Setup saves the app's event and name to `user-hub.json`: commit it. The app's URLs live in the hub: a list of development URLs (`bunx user-hub dev list`, `dev add <url>`, `dev remove <url>`) and a production URL (`bunx user-hub prod`, `prod set <url>`, `prod remove`). `--name` or `--event` with another name or event than the saved ones registers the app anew, with a new app key; setup leaves the earlier registration as it was.
16
+ 3. `bun run dev`, then open http://localhost:3000. You are sent to the hub to pick who to be, then back signed in. If something else already uses that port, the dev server stops with an error instead of moving to another port, because the hub only sends you back to a registered URL. To use another port, change it in `package.json`'s `dev` script and add it to the app's development URLs: `bunx user-hub dev add http://localhost:<port>`.
17
+ 4. Once the app is deployed: `bunx user-hub prod set https://your-app.example.com`, so badge scans can reach it. It also sets `HUB_ISSUER` and `HUB_JWKS` on the production Convex deployment.
18
18
 
19
19
  ## Deploy
20
20
 
@@ -23,7 +23,7 @@ The app ships as a Docker image served by Bun (`Dockerfile`, `server.ts`); it ne
23
23
  - `just build`: deploys the Convex functions to production, then builds the image against that deployment and loads it into Docker. Try it with `docker run -p 3000:3000 __APP_KEY__`.
24
24
  - `just push`: the same, built for servers (amd64) and pushed. Set your registry path first: `IMAGE=registry.example.com/team/__APP_KEY__ just push`, or edit `image` at the top of the `justfile`.
25
25
 
26
- Then serve the container (port 3000) at your production URL and make sure the hub knows that URL (`bun run setup --prod <url>`). Badge scans reach the app once it is scheduled or forced live in the hub, or straight away while badges go to the hub's app list, if the app is listed (new apps are).
26
+ Then serve the container (port 3000) at your production URL and make sure the hub knows that URL (`bunx user-hub prod set <url>`). Badge scans reach the app once it is scheduled or forced live in the hub, or straight away while badges go to the hub's app list, if the app is listed (new apps are).
27
27
 
28
28
  ### Hub moved
29
29
 
@@ -37,7 +37,7 @@
37
37
  "@vitejs/plugin-react": "^6.3.0",
38
38
  "oxc-transform-react": "^0.158.0",
39
39
  "typescript": "^7.0.2",
40
- "user-hub": "^0.1.0",
40
+ "user-hub": "^0.2.0",
41
41
  "vite": "npm:@voidzero-dev/vite-plus-core@8.3.8000",
42
42
  "vite-plus": "1.7.0"
43
43
  },
@@ -19,9 +19,9 @@ const ignorePatterns = [
19
19
  export default defineConfig({
20
20
  resolve: { tsconfigPaths: true },
21
21
  // The port lives in package.json's dev script, where `bun run setup` reads
22
- // it to register the development URL. The hub only sends people back to
23
- // that URL, so stop with an error when the port is taken instead of moving
24
- // to the next free one.
22
+ // it to register the first development URL. The hub only sends people back
23
+ // to registered URLs, so stop with an error when the port is taken instead
24
+ // of moving to the next free one.
25
25
  server: { strictPort: true },
26
26
  // One convex/react in the browser: the hub provider gives the Convex
27
27
  // client to the same context the app's Convex hooks read. Pre-bundled