Skip to content

Commit 070c727

Browse files
committed
docs: lead with fn init in the toolkit README and main README
Wave 8 of the portable-functions toolkit. Updates user-facing docs so that `fn init` is the first thing a new user sees, not the last. - docs/portable-functions-toolkit.md: replace the "Customer repo experience" section with a "Quick start" that begins with `fn init send-welcome --no-tty` rather than assuming the user has hand-authored a handler.json. Add the full CLI surface table including `init` and its flags. Note the genomic-via-pgpm-init alignment so users who know `pgpm init` carry their knowledge over. - README.md: lead with the in-another-repo flow. The brasilia-as- dogfood instructions stay below as the second quick-start. New paragraph at top points at the toolkit guide. The starter-kit / pgpm init scaffold-the-whole-project flow is deliberately left as future work — the addendum in the plan file documents it but it lands in its own follow-on.
1 parent bfc9e15 commit 070c727

2 files changed

Lines changed: 50 additions & 12 deletions

File tree

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,22 @@
22

33
Functions playground for Constructive — isolated workspace for building, testing, and deploying Knative-style HTTP functions.
44

5-
## Quick Start
5+
This repo is also the source of the **Portable Functions Toolkit**: a set of `@constructive-io/fn-*` npm packages that any external repo can `pnpm add` to get the same code-gen + Docker + k8s pipeline against its own `functions/` directory. See [docs/portable-functions-toolkit.md](docs/portable-functions-toolkit.md) for the full toolkit guide.
6+
7+
## Quick start (in another repo)
8+
9+
```bash
10+
pnpm add -D @constructive-io/fn-cli
11+
pnpm add @constructive-io/fn-runtime
12+
13+
pnpm fn init send-welcome --no-tty # scaffold functions/send-welcome/
14+
pnpm fn generate # stamp out generated/<name>/ packages
15+
pnpm install # link the new workspaces
16+
pnpm fn build # compile
17+
pnpm fn dev # run functions as local Node processes
18+
```
19+
20+
## Quick start (this repo, dogfood)
621

722
```bash
823
# Install dependencies

docs/portable-functions-toolkit.md

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,54 @@ knative-job-fn (fn-app) (low-level Express middleware)
1919
| `@constructive-io/knative-job-fn` | Low-level Express middleware for Knative job request/response shape. fn-runtime depends on it. |
2020
| `@constructive-io/fn-generator` | Programmatic builders that emit Dockerfiles, k8s YAML, configmaps, skaffold profiles, manifest registry. Pure functions; idempotent file I/O at the boundary. |
2121
| `@constructive-io/fn-client` | Importable `FnClient` API — config loading, manifest reading, `pnpm build`, child-process orchestration for `dev`. |
22-
| `@constructive-io/fn-cli` | The `fn` executable. Subcommands: `generate`, `build`, `dev`, `manifest`, `verify`. |
22+
| `@constructive-io/fn-cli` | The `fn` executable. Subcommands: `init`, `generate`, `build`, `dev`, `manifest`, `verify`. |
2323

24-
## Customer repo experience
24+
## Quick start
25+
26+
```bash
27+
# In a fresh project
28+
pnpm add -D @constructive-io/fn-cli
29+
pnpm add @constructive-io/fn-runtime
30+
31+
# Scaffold a function
32+
pnpm fn init send-welcome --no-tty --description "Welcome email sender"
33+
# → functions/send-welcome/{handler.json, handler.ts}
34+
35+
# Stamp out the workspace package, build, run
36+
pnpm fn generate
37+
pnpm install # link the just-created generated/* workspaces
38+
pnpm fn build
39+
pnpm fn dev # functions run as local Node processes
40+
```
41+
42+
`fn init` uses [`genomic`](https://www.npmjs.com/package/genomic) under the hood — the same template engine `pgpm init` uses — so the prompt conventions and `--no-tty` flag-mapping match the rest of the Constructive ecosystem. Two handler types ship today: `--type=node-graphql` (default) and `--type=python`.
43+
44+
## Repo layout the toolkit expects
2545

2646
```
2747
my-app/
2848
├── functions/
2949
│ └── send-welcome/
3050
│ ├── handler.json # {"name":"send-welcome","version":"0.1.0","type":"node-graphql"}
3151
│ └── handler.ts # default-exported FunctionHandler
32-
├── fn.config.json # FnConfig (typed via fn-types)
52+
├── fn.config.json # FnConfig (typed via fn-types) — optional
3353
└── package.json
3454
```
3555

36-
```bash
37-
pnpm add -D @constructive-io/fn-cli
38-
pnpm add @constructive-io/fn-runtime
56+
## CLI surface
3957

40-
pnpm fn generate # write generated/<name>/ + manifest + skaffold
41-
pnpm fn build # pnpm -r build
42-
pnpm fn manifest # cat generated/functions-manifest.json
43-
pnpm fn verify # check manifest matches functions/
44-
pnpm fn dev # spawn each function as a Node child
58+
```bash
59+
fn init <name> [--type=node-graphql|python] [--description=<d>] [--force] [--no-tty]
60+
fn generate [--only=<name>] [--packages-only]
61+
fn build [--only=<name>]
62+
fn dev [--only=<name>]
63+
fn manifest # print on-disk functions-manifest.json
64+
fn verify # check manifest matches functions/
65+
fn --version # print fn-cli version
4566
```
4667

68+
Common flags: `--root=<dir>`, `--config=<file>`.
69+
4770
## Job-service registry (when running the `jobs-bundle` preset)
4871

4972
The job-service no longer hardcodes function names. It loads its registry at startup from one of three sources, in priority order:

0 commit comments

Comments
 (0)