@crossdelta/platform-sdk 0.7.22 → 0.8.1
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/README.md
CHANGED
|
@@ -11,7 +11,12 @@
|
|
|
11
11
|
<p align="center">
|
|
12
12
|
<strong>Opinionated platform toolkit for event-driven microservices.</strong><br />
|
|
13
13
|
Scaffold <a href="https://turbo.build/repo">Turborepo</a> workspaces, generate services from natural language,<br />
|
|
14
|
-
and deploy via <a href="https://www.pulumi.com">Pulumi</a> — DigitalOcean-first,
|
|
14
|
+
and deploy via <a href="https://www.pulumi.com">Pulumi</a> — DigitalOcean-first for speed and simplicity, providers replaceable by design.
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<em>Platform SDK (<code>pf</code>) is a platform opinion, not a generator.<br />
|
|
19
|
+
It encodes architectural decisions so teams don't have to rediscover them.</em>
|
|
15
20
|
</p>
|
|
16
21
|
|
|
17
22
|
<p align="center">
|
|
@@ -26,11 +31,23 @@
|
|
|
26
31
|
</p>
|
|
27
32
|
|
|
28
33
|
<p align="center">
|
|
29
|
-
<
|
|
34
|
+
<img src="https://img.shields.io/badge/Hono-E36002?style=flat-square&logo=hono&logoColor=white" alt="Hono" />
|
|
35
|
+
<img src="https://img.shields.io/badge/NestJS-E0234E?style=flat-square&logo=nestjs&logoColor=white" alt="NestJS" />
|
|
36
|
+
<img src="https://img.shields.io/badge/NATS-27AAE1?style=flat-square&logo=natsdotio&logoColor=white" alt="NATS" />
|
|
30
37
|
</p>
|
|
31
38
|
|
|
32
39
|
---
|
|
33
40
|
|
|
41
|
+
## Who is this for?
|
|
42
|
+
|
|
43
|
+
- **Teams building event-driven backends** — NATS, CloudEvents, type-safe contracts
|
|
44
|
+
- **Startups & internal platforms** that want long-term consistency over short-term speed
|
|
45
|
+
- **Engineers tired of infra & app drift** — ports, env vars, deployments always in sync
|
|
46
|
+
|
|
47
|
+
You can start without understanding all the pieces. The depth reveals itself as you grow.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
34
51
|
## Installation
|
|
35
52
|
|
|
36
53
|
```bash
|
|
@@ -41,12 +58,25 @@ bun add -g @crossdelta/platform-sdk
|
|
|
41
58
|
<details>
|
|
42
59
|
<summary>Alternative: Auto-installer or run without installing</summary>
|
|
43
60
|
|
|
61
|
+
**Unix/macOS:**
|
|
44
62
|
```bash
|
|
45
63
|
# Auto-installer (installs CLI globally, prompts to install Bun if missing)
|
|
46
64
|
curl -fsSL https://unpkg.com/@crossdelta/platform-sdk@latest/install.sh | bash
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Windows:**
|
|
68
|
+
```powershell
|
|
69
|
+
# Recommended: Use npm directly
|
|
70
|
+
npm install -g @crossdelta/platform-sdk
|
|
71
|
+
|
|
72
|
+
# Or use WSL (Windows Subsystem for Linux)
|
|
73
|
+
wsl bash -c "curl -fsSL https://unpkg.com/@crossdelta/platform-sdk@latest/install.sh | bash"
|
|
74
|
+
```
|
|
47
75
|
|
|
48
|
-
|
|
76
|
+
**Run without installing:**
|
|
77
|
+
```bash
|
|
49
78
|
bunx @crossdelta/platform-sdk new workspace my-platform
|
|
79
|
+
# or: npx @crossdelta/platform-sdk new workspace my-platform
|
|
50
80
|
```
|
|
51
81
|
|
|
52
82
|
</details>
|
|
@@ -73,49 +103,59 @@ pf dev
|
|
|
73
103
|
|
|
74
104
|
---
|
|
75
105
|
|
|
76
|
-
##
|
|
106
|
+
## 5-Minute Tutorial
|
|
77
107
|
|
|
78
|
-
|
|
108
|
+
After running Quick Start, add services and wire events:
|
|
79
109
|
|
|
80
110
|
```bash
|
|
81
|
-
|
|
82
|
-
|
|
111
|
+
# 1. Add two services
|
|
112
|
+
pf new hono-micro services/orders
|
|
113
|
+
pf new hono-micro services/notifications
|
|
114
|
+
|
|
115
|
+
# 2. Wire an event between them
|
|
116
|
+
pf event add orders.created --service services/notifications
|
|
117
|
+
|
|
118
|
+
# 3. Restart to pick up new services
|
|
83
119
|
pf dev
|
|
120
|
+
|
|
121
|
+
# 4. Publish a test event — watch notifications react
|
|
122
|
+
pf event publish orders.created
|
|
84
123
|
```
|
|
85
124
|
|
|
86
|
-
|
|
125
|
+
That's it. Two services, one event contract, auto-discovered handlers, no manual wiring.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 🧭 Commands & Options
|
|
87
130
|
|
|
88
|
-
###
|
|
131
|
+
### Service generators
|
|
89
132
|
|
|
133
|
+
**Hono** (lightweight, Bun-optimized):
|
|
90
134
|
```bash
|
|
91
135
|
pf new hono-micro services/orders
|
|
92
136
|
```
|
|
93
137
|
|
|
94
|
-
|
|
95
|
-
|
|
138
|
+
**NestJS** (full-featured, decorator-based):
|
|
96
139
|
```bash
|
|
97
|
-
pf new
|
|
140
|
+
pf new nest-micro services/orders
|
|
98
141
|
```
|
|
99
142
|
|
|
100
143
|
Both generate the service structure, Pulumi config in `infra/services/`, and wire everything automatically.
|
|
101
144
|
|
|
102
|
-
###
|
|
103
|
-
|
|
104
|
-
Configure your AI provider once:
|
|
145
|
+
### AI-assisted generation (optional)
|
|
105
146
|
|
|
147
|
+
Configure once:
|
|
106
148
|
```bash
|
|
107
149
|
pf setup --ai # OpenAI or Anthropic
|
|
108
150
|
```
|
|
109
151
|
|
|
110
|
-
Then use `--ai` with any
|
|
111
|
-
|
|
152
|
+
Then use `--ai` with any generator:
|
|
112
153
|
```bash
|
|
113
154
|
pf new hono-micro services/notifications --ai -d "Send emails on order events"
|
|
114
155
|
```
|
|
115
156
|
|
|
116
157
|
AI generates: service code, event handlers, use cases, tests, and documentation.
|
|
117
|
-
|
|
118
|
-
AI is a productivity layer — all generated code follows the same conventions and can be written manually without loss of functionality.
|
|
158
|
+
All generated code follows the same conventions and can be written manually.
|
|
119
159
|
|
|
120
160
|
### Daily commands
|
|
121
161
|
|
|
@@ -125,6 +165,9 @@ AI is a productivity layer — all generated code follows the same conventions a
|
|
|
125
165
|
| `pf test` | Run tests across the monorepo |
|
|
126
166
|
| `pf lint` | Lint and format with Biome |
|
|
127
167
|
| `pf build` | Build all packages and services |
|
|
168
|
+
| `pf event add <type> --service <path>` | Add contract, mock, handler + wire stream |
|
|
169
|
+
| `pf event list` | List available events and their consumers |
|
|
170
|
+
| `pf event publish <type>` | Publish mock event to NATS |
|
|
128
171
|
| `pf pulumi up` | Deploy infrastructure (runs in `infra/`) |
|
|
129
172
|
|
|
130
173
|
`pf` proxies to Turborepo from any subdirectory.
|
|
@@ -192,7 +235,7 @@ See [@crossdelta/infrastructure](https://www.npmjs.com/package/@crossdelta/infra
|
|
|
192
235
|
|
|
193
236
|
**Solution:** Services auto-generate `infra/services/*.ts`, ports/env derived automatically, event handlers type-safe and auto-discovered.
|
|
194
237
|
|
|
195
|
-
In short: docker-compose starts services — `pf` prevents systems from drifting apart over time
|
|
238
|
+
**In short: docker-compose starts services — `pf` prevents systems from drifting apart over time.**
|
|
196
239
|
|
|
197
240
|
---
|
|
198
241
|
|
|
@@ -203,11 +246,11 @@ In short: docker-compose starts services — `pf` prevents systems from drifting
|
|
|
203
246
|
- Turborepo scaffolder with Pulumi IaC and NATS messaging built-in
|
|
204
247
|
- AI-assisted code generator from natural language descriptions
|
|
205
248
|
- Unified dev workflow — one command to run everything
|
|
206
|
-
- DigitalOcean-first
|
|
249
|
+
- DigitalOcean-first for speed and simplicity — providers replaceable by design
|
|
207
250
|
|
|
208
251
|
**❌ pf is not:**
|
|
209
252
|
- Generic microservice generator — makes architectural choices for you
|
|
210
|
-
- Multi-cloud
|
|
253
|
+
- Multi-cloud out of the box — DigitalOcean first, extensible to other providers
|
|
211
254
|
- Runtime manager — scaffolds code, you deploy with Pulumi
|
|
212
255
|
|
|
213
256
|
**Note:** `pf` runs nothing implicitly. No hidden daemons, no automatic deployments. You control when code runs and infrastructure deploys.
|
|
@@ -249,6 +292,26 @@ my-platform/
|
|
|
249
292
|
|
|
250
293
|
### Event-Driven Pattern
|
|
251
294
|
|
|
295
|
+
**Add events with one command:**
|
|
296
|
+
```bash
|
|
297
|
+
# Creates contract, mock, handler, and wires the stream automatically
|
|
298
|
+
pf event add orders.created --service services/notifications
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
This generates:
|
|
302
|
+
- `packages/contracts/src/events/orders-created.ts` (contract)
|
|
303
|
+
- `packages/contracts/src/events/orders-created.mock.json` (test data)
|
|
304
|
+
- `services/notifications/src/events/orders-created.event.ts` (handler)
|
|
305
|
+
- Adds stream to service `index.ts` if needed
|
|
306
|
+
|
|
307
|
+
**Test events locally:**
|
|
308
|
+
```bash
|
|
309
|
+
pf event list # Show available events
|
|
310
|
+
pf event publish orders.created # Publish mock event to NATS
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
**Manual pattern (if you prefer):**
|
|
314
|
+
|
|
252
315
|
**1. Define contract:**
|
|
253
316
|
```typescript
|
|
254
317
|
// packages/contracts/src/events/orders-created.ts
|
|
@@ -313,6 +376,7 @@ pulumi login && pulumi up --stack dev
|
|
|
313
376
|
| `PULUMI_ACCESS_TOKEN` | [Pulumi Cloud token](https://app.pulumi.com/account/tokens) |
|
|
314
377
|
| `DIGITALOCEAN_TOKEN` | [DO API token](https://cloud.digitalocean.com/account/api/tokens) |
|
|
315
378
|
| `GHCR_TOKEN` | GitHub Container Registry PAT |
|
|
379
|
+
| `NPM_TOKEN` | [npm access token](https://www.npmjs.com/settings/~/tokens) (only for `publish-packages.yml`) |
|
|
316
380
|
|
|
317
381
|
</details>
|
|
318
382
|
|