@decohere/create 0.0.1-dev.20261123.379 → 0.0.1-dev.20261123.404

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.
Files changed (2) hide show
  1. package/README.md +30 -9
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -50,6 +50,8 @@ The scaffolded Dev Container asks no questions. `gh` is installed in it: run `gh
50
50
 
51
51
  Scaffolds a full web API using `@decohere/http` (HTTP), `@decohere/crucible` (DI), `@decohere/config` (configuration) and Scribe (logging), plus a Dev Container workspace.
52
52
 
53
+ What it writes is checked-in files, not code generated on the fly: the workspace every project starts with, then the **web API recipe**, a complete app on Fastify that the Decohere repo boots and tests as it is ([scaffold](../scaffold/README.md)). Only names and ports change. `--database` and `--auth` are the same [add steps](#add-to-a-project) you can run later, applied on top of the recipe.
54
+
53
55
  ```bash
54
56
  npx @decohere/create webapi -d my-app
55
57
  npx @decohere/create webapi -d my-app --name billing
@@ -78,7 +80,7 @@ my-app/
78
80
  .devcontainer/
79
81
  projects/
80
82
  api/ # or projects/<name> when --name is set
81
- package.json # private: true (app, not an npm package)
83
+ package.json # private: true; "decohere" records the recipe and the steps added
82
84
  Dockerfile # copies .package/ (written by `forge package`)
83
85
  .dockerignore
84
86
  src/
@@ -127,20 +129,39 @@ export default app;
127
129
  | `package` / `package:<name>` | release build, then `forge package` (all APIs, or that one) | Before `docker build` |
128
130
  | `start` | `node dist/release/projects/<first>/es6/src/main.js` | Production default API (`pnpm start`) |
129
131
  | `start:<name>` | same path for that API | Deploy that API (`pnpm run start:billing`) |
130
- | `dev` | `flux serve --env-file-if-exists .env` (plus `--project @<app>/<first>` when named) | Local HMR for the first API; loads `.env` if present |
132
+ | `dev` | `PORT=3000 flux serve --env-file-if-exists .env --project @<app>/<first>` | Local HMR for the first API; loads `.env` if present |
131
133
  | `dev:<name>` | `PORT=<3000+n> flux serve --env-file-if-exists .env --project @<app>/<name>` | Local HMR for that API |
132
134
  | `lint` | `oxlint --fix`, then `prettier --write .`, skipping `.devcontainer` | Fix and format |
133
135
  | `lint:check` / `typecheck` / `test` | oxlint and Prettier / forge typecheck / vitest | CI |
134
136
 
135
- #### Multiple APIs / add later
137
+ #### Add to a project
138
+
139
+ Each part a project can have is an add step. `create` runs the ones you choose on top of the recipe; in the project's Dev Container you can run any of them later:
136
140
 
137
141
  ```bash
138
- decohere add api billing
139
- # empty machine / npm create still maps `webapi add`:
140
- npx @decohere/create webapi add billing -d my-app
142
+ pnpm decohere add api billing # the web API recipe again, as projects/billing (asks for its steps)
143
+ pnpm decohere add postgres # Postgres in the Dev Container, a database and sample table per API
144
+ pnpm decohere add postgres --orm typeorm # the same, mapped with TypeORM instead of MikroORM
145
+ pnpm decohere add auth0 # Auth0: every route needs a token (see below)
146
+ pnpm decohere add users # with Postgres and Auth0: a local profile per user, admin seeded
141
147
  ```
142
148
 
143
- Adds `projects/billing`, `start:billing` / `package:billing` / `dev:billing`, and `projects/billing/Dockerfile`. Does not rewrite the first API or workspace files like `.prettierrc.json`.
149
+ | `create` option | Is the recipe, plus |
150
+ |---|---|
151
+ | `--database postgres/mikro-orm` | `add postgres` |
152
+ | `--database postgres/typeorm` | `add postgres --orm typeorm` |
153
+ | `--auth auth0` | `add auth0` |
154
+ | both | `add postgres`, `add auth0`, then `add users` |
155
+
156
+ Every step:
157
+
158
+ - **Adds, and never takes away.** A file the project doesn't have is copied in. One it has is merged: `package.json`, `devcontainer.json`, `docker-compose.yml` and `config/*.yaml` get only the keys and list items they lack (a data source by its `name`), `.env` only the variables it doesn't set, `.gitignore` only missing lines, `README.md` only missing `##` sections.
159
+ - **Changes nothing when run again.** `--dry-run` lists what it would change and writes nothing (and touches no Auth0 tenant).
160
+ - **Edits `app.ts` only in the shape it generated.** It inserts its lines (`.use(auth())` after `.use(config(…))`, the data provider before `.build()`, and so on). If one can't go in, it leaves the file as it is and prints every line to add.
161
+ - **Replaces a sample file only if you haven't touched it.** `add auth0` and `add users` rewrite `hello.controller.ts` and its test only while they are exactly what the recipe (or `add auth0`) wrote; otherwise they print where their version is.
162
+ - **Records itself** in the API's `package.json`, under `"decohere": { "recipe", "steps" }`.
163
+
164
+ `add api billing` adds `projects/billing`, `start:billing` / `package:billing` / `dev:billing`, its port in the Dev Container, and `projects/billing/Dockerfile`. It doesn't rewrite the first API or workspace files like `.prettierrc.json`. From an empty machine, `npx @decohere/create webapi add billing -d my-app` does the same.
144
165
 
145
166
  Each API is a separate deploy: package it (`pnpm run package:billing`) and build the image from its folder (`docker build projects/billing`), or set the start command to `pnpm run start:billing`. Workspace `config/` is shared; each API still has its own named datasource and `{PREFIX}_DB_*` env (host/port default to the Compose Postgres).
146
167
 
@@ -169,7 +190,7 @@ In the project's Dev Container:
169
190
  pnpm decohere add auth0
170
191
  ```
171
192
 
172
- This logs in if needed, creates the Auth0 API and a `<project> Dev` login app, writes `AUTH0_ISSUER_BASE_URL`, `AUTH0_AUDIENCE` and `AUTH0_CLIENT_ID` to `.env`, adds the `auth` section to `config/config.yaml`, and adds `.use(auth())` to each API's `app.ts`. Running it again changes nothing. If an `app.ts` no longer has the generated shape, the command leaves it alone and prints the lines to add. It also creates a `<project> Token` machine app (written to `.env` as `AUTH0_TOKEN_CLIENT_ID`). It doesn't add the local user profile a new project with Postgres gets.
193
+ This logs in if needed, creates the Auth0 API and a `<project> Dev` login app, writes `AUTH0_ISSUER_BASE_URL`, `AUTH0_AUDIENCE` and `AUTH0_CLIENT_ID` to `.env`, adds the `auth` section to `config/config.yaml`, and adds `.use(auth())` to each API's `app.ts`. It gives the Hello controller `@Authorize` permissions and its test a token check of its own. It also creates a `<project> Token` machine app (written to `.env` as `AUTH0_TOKEN_CLIENT_ID`). With Postgres too, `pnpm decohere add users` adds the local user profile a new project with both gets; with `DECOHERE_ADMIN_PASSWORD` set, it also creates the admin user on Auth0.
173
194
 
174
195
  Once Auth0 is added, **every route needs a token** unless it has `@AllowAnonymous()`, because `auth()` is secure by default. To call one, in the Dev Container:
175
196
 
@@ -319,4 +340,4 @@ For contributors to Decohere: how the package is laid out and tested. Using it n
319
340
  - `runner.ts`: `launch` runs the command here when this container has Decohere's tools (`tools.ts`, `DECOHERE_TOOLS`), otherwise `runInBuilder` runs it in the scaffolder image, `ghcr.io/typesmiths/decohere/create:<version>`, and copies the project out.
320
341
  - `cli.ts` is the bin, and `version.ts` the version the image and scaffold package are pinned to. The image is built from `Dockerfile`, with `pack-builder-tgz.mjs` packing the scaffolder into it.
321
342
 
322
- The canonical suite for what a user installs is `e2e/real-install.e2e.spec.ts`, against a temporary registry, in CI's `verify-release` job on `main`; `runInBuilder` and its argv are covered in `tests/runner.spec.ts` ([testing](../../docs/contributing/testing/README.md#canonical-suite-ownership)). Specs are in `tests/` today and move beside the code ([ADR 0027](../../docs/contributing/adr/0027-code-design.md)).
343
+ The canonical suite for what a user installs is `e2e/real-install.e2e.spec.ts`, against a temporary registry, in CI's `verify-release` job in the merge queue; `runInBuilder` and its argv are covered in `tests/runner.spec.ts` ([testing](../../docs/contributing/testing/README.md#canonical-suite-ownership)). Specs are in `tests/` today and move beside the code ([ADR 0027](../../docs/contributing/adr/0027-code-design.md)).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decohere/create",
3
- "version": "0.0.1-dev.20261123.379",
3
+ "version": "0.0.1-dev.20261123.404",
4
4
  "description": "Download the Decohere scaffolder image and run it (npm create @decohere)",
5
5
  "keywords": [
6
6
  "decohere",