@crossdelta/platform-sdk 0.2.30 β†’ 0.3.0

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 (25) hide show
  1. package/README.md +252 -87
  2. package/bin/cli.js +249 -154
  3. package/bin/integration.collection.json +1 -1
  4. package/bin/templates/workspace/.github/README.md +70 -0
  5. package/bin/templates/workspace/.github/actions/check-image-tag-exists/action.yml +27 -0
  6. package/bin/templates/workspace/.github/actions/check-image-tag-exists/index.js +179 -0
  7. package/bin/templates/workspace/.github/actions/check-path-changes/action.yml +21 -0
  8. package/bin/templates/workspace/.github/actions/check-path-changes/index.js +192 -0
  9. package/bin/templates/workspace/.github/actions/detect-skipped-services/action.yml +38 -0
  10. package/bin/templates/workspace/.github/actions/generate-scope-matrix/action.yml +17 -0
  11. package/bin/templates/workspace/.github/actions/generate-scope-matrix/index.js +355 -0
  12. package/bin/templates/workspace/.github/actions/prepare-build-context/action.yml +49 -0
  13. package/bin/templates/workspace/.github/actions/resolve-scope-tags/action.yml +31 -0
  14. package/bin/templates/workspace/.github/actions/resolve-scope-tags/index.js +400 -0
  15. package/bin/templates/workspace/.github/actions/setup-bun-install/action.yml.hbs +57 -0
  16. package/bin/templates/workspace/.github/copilot-chat-configuration.json +49 -0
  17. package/bin/templates/workspace/.github/copilot-instructions.md.hbs +202 -0
  18. package/bin/templates/workspace/.github/dependabot.yml +18 -0
  19. package/bin/templates/workspace/.github/workflows/build-and-deploy.yml.hbs +236 -0
  20. package/bin/templates/workspace/.github/workflows/lint-and-tests.yml.hbs +33 -0
  21. package/bin/templates/workspace/.github/workflows/publish-packages.yml +161 -0
  22. package/bin/templates/workspace/biome.json.hbs +2 -1
  23. package/bin/templates/workspace/infra/scripts/generate-env.ts.hbs +83 -0
  24. package/bin/templates/workspace/turbo.json +40 -0
  25. package/package.json +16 -4
package/README.md CHANGED
@@ -1,140 +1,305 @@
1
- # @crossdelta/platform-sdk
1
+ <p align="center">
2
+ <img src="logo.svg" alt="pf" width="120" />
3
+ </p>
2
4
 
3
- [![npm version](https://img.shields.io/npm/v/@crossdelta/platform-sdk.svg)](https://www.npmjs.com/package/@crossdelta/platform-sdk)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
+ <h1 align="center">Platform SDK</h1>
5
6
 
6
- > πŸš€ CLI toolkit for scaffolding and managing microservice platforms
7
+ <p align="center">
8
+ <code>@crossdelta/platform-sdk</code>
9
+ </p>
7
10
 
8
- Build event-driven microservice platforms with minimal boilerplate. This CLI scaffolds [Turborepo](https://turbo.build) workspaces with [Pulumi](https://pulumi.com) infrastructure, generates microservices (Hono or NestJS), and provides a unified dev experience across all services.
11
+ <p align="center">
12
+ <strong>Agentic CLI for event-driven microservice platforms</strong>
13
+ </p>
9
14
 
10
- ## Features
15
+ <p align="center">
16
+ <a href="https://www.npmjs.com/package/@crossdelta/platform-sdk"><img src="https://img.shields.io/npm/v/@crossdelta/platform-sdk.svg?style=flat-square" alt="npm version" /></a>
17
+ <img src="https://img.shields.io/badge/bun-%E2%9A%A1-f9f1e1?style=flat-square" alt="Bun" />
18
+ <img src="https://img.shields.io/badge/pulumi-ready-blueviolet?style=flat-square" alt="Pulumi" />
19
+ <img src="https://img.shields.io/badge/DigitalOcean-App_Platform_|_DOKS-0080FF?style=flat-square" alt="DigitalOcean" />
20
+ </p>
11
21
 
12
- - ⚑ **Quick Scaffolding** - Generate projects with best practices baked in
13
- - πŸ₯Ÿ **[Bun](https://bun.sh)-first** - Optimized for Bun runtime with npm/yarn/pnpm fallback
14
- - πŸ—οΈ **[Turborepo](https://turbo.build) Workspaces** - Monorepo setup with parallel builds and caching
15
- - πŸ”§ **Microservice Templates** - [Hono](https://hono.dev) (lightweight) & [NestJS](https://nestjs.com) (enterprise-grade)
16
- - πŸ“¦ **[Pulumi](https://www.pulumi.com) Ready** - Infrastructure-as-Code out of the box
17
- - πŸ”Œ **Auto Port Assignment** - Unique ports per service, no manual configuration
18
- - 🌍 **Env Generation** - `.env.local` auto-generated from `infra/services/*.ts` configs
22
+ <p align="center">
23
+ Your AI-powered platform engineer. Scaffold complete Turborepo workspaces,<br />
24
+ generate production-ready microservices with natural language,<br />
25
+ and deploy to DigitalOcean β€” all from one CLI.
26
+ </p>
19
27
 
20
- ## Installation
28
+ ---
21
29
 
22
- ```bash
23
- npm install -g @crossdelta/platform-sdk
30
+ > ⚠️ **Cloud Provider Support:** Currently only **DigitalOcean** is supported:
31
+ > - **App Platform** β€” Managed PaaS for simple deployments
32
+ > - **DOKS (Kubernetes)** β€” Full Kubernetes control for production workloads
33
+ >
34
+ > AWS and GCP support is planned for future releases.
24
35
 
25
- # or
26
- bun add -g @crossdelta/platform-sdk
27
- ```
36
+ ---
37
+
38
+ ## ✨ Features
39
+
40
+ | Feature | Description |
41
+ |---------|-------------|
42
+ | ⚑ **Instant Scaffolding** | Create fully wired platform workspaces with best practices baked in |
43
+ | οΏ½ **AI-Powered Generation** | Generate services with AI using `--ai` flag (OpenAI/Anthropic) |
44
+ | οΏ½πŸ₯Ÿ **Bun-first DX** | Ultra-fast dev workflow with fallback to npm/yarn/pnpm |
45
+ | πŸ—οΈ **Turborepo Monorepo** | Parallel builds, caching, and unified dev scripts |
46
+ | πŸ”§ **Service Generators** | [Hono](https://hono.dev/) (lightweight) and [NestJS](https://nestjs.com/) (enterprise-grade) templates |
47
+ | πŸ“¦ **Pulumi-Ready Infra** | Infrastructure-as-Code for DigitalOcean (App Platform or DOKS) |
48
+ | πŸš€ **GitHub Actions CI/CD** | Pre-configured workflows for build, test, deploy, and npm publish |
49
+ | 🌍 **Auto `.env.local`** | Environment variables derived from `infra/services/*.ts` |
50
+ | πŸ”Œ **Auto Port Assignment** | Unique ports per service, zero manual config |
51
+ | πŸ” **Smart Watch Mode** | Watches infra & services, regenerates env, reinstalls deps |
52
+
53
+ ---
54
+
55
+ ## πŸš€ Quick Start
28
56
 
29
- ## Quick Start
57
+ ### 1. Create a new workspace
30
58
 
31
59
  ```bash
32
- # Create a new workspace with infrastructure
33
60
  npx @crossdelta/platform-sdk new workspace my-platform
34
- cd my-platform
61
+ ```
35
62
 
36
- # Create a Hono microservice
37
- pf new hono-micro services/orders
63
+ Or with options:
38
64
 
39
- # Create a NestJS microservice
40
- pf new nest-micro services/api-gateway
65
+ ```bash
66
+ pf new workspace my-platform -y # Skip prompts
67
+ pf new workspace my-platform -o my-github-org # Set GitHub owner
68
+ pf new workspace my-platform --no-github # Without CI/CD
69
+ ```
41
70
 
42
- # Start development
43
- pf dev
71
+ **Options:**
72
+
73
+ | Flag | Description |
74
+ |------|-------------|
75
+ | `-y, --yes` | Skip prompts, use defaults |
76
+ | `-o, --github-owner <owner>` | GitHub org/user for GHCR registry |
77
+ | `-s, --pulumi-stack <name>` | Pulumi stack base name (org/project) |
78
+ | `--no-github` | Skip GitHub Actions workflows |
79
+
80
+ > πŸ’‘ `pf` is the CLI binary shipped with this package.
81
+ > It automatically works through `npx` β€” no global install required.
82
+
83
+ ---
84
+
85
+ ### 2. Generate microservices
86
+
87
+ ```bash
88
+ pf new hono-micro services/orders # Lightweight Hono service
89
+ pf new nest-micro services/api-gateway # Enterprise NestJS service
44
90
  ```
45
91
 
46
- ## Commands
92
+ Both generators:
93
+ - Auto-assign unique ports
94
+ - Create Pulumi service config in `infra/services/`
95
+ - Add Dockerfile for containerized deployment
96
+ - Wire up health checks
47
97
 
48
- ### `pf dev`
98
+ #### πŸ€– AI-Powered Generation
49
99
 
50
- Start the development environment with hot reload.
100
+ Generate services with AI assistance:
51
101
 
52
102
  ```bash
53
- pf dev # Start with watch mode (default)
54
- pf dev --no-watch # Start without watching for changes
103
+ # One-liner with description
104
+ pf new hono-micro services/payments --ai -d "Handle payment webhooks and process transactions"
105
+
106
+ # Interactive mode (prompts for description)
107
+ pf new hono-micro services/notifications --ai
55
108
  ```
56
109
 
57
- **What it does:**
58
- 1. Generates `.env.local` from service configurations in `infra/services/*.ts`
59
- 2. Starts all services in parallel via `turbo start:dev`
60
- 3. Watches for changes:
61
- - `infra/services/` β†’ Regenerates env and restarts on config changes
62
- - `services/` & `apps/` β†’ Detects new/deleted packages and reinstalls dependencies
63
-
64
- **Configuration via `package.json`:**
65
- ```json
66
- {
67
- "pf": {
68
- "dev": {
69
- "watchDirs": ["infra/services"],
70
- "watchPackages": ["services", "apps"]
71
- }
72
- }
73
- }
110
+ First-time setup:
111
+
112
+ ```bash
113
+ pf setup --ai # Configure OpenAI or Anthropic API key
74
114
  ```
75
115
 
76
- ### `pf new workspace [name]`
116
+ The AI reads your project's `copilot-instructions.md` and generates code following your conventions.
117
+
118
+ ---
77
119
 
78
- Scaffold a complete platform workspace with Pulumi infrastructure.
120
+ ### 3. Start local development
79
121
 
80
122
  ```bash
81
- pf new workspace my-platform
82
- pf new workspace my-platform -y # Skip prompts, use defaults
123
+ pf dev
83
124
  ```
84
125
 
85
- **Creates:**
126
+ What happens:
127
+
128
+ 1. `.env.local` is generated from all `infra/services/*.ts` configs
129
+ 2. Services are started in parallel via Turborepo
130
+ 3. **Watching:**
131
+ - `infra/services/` β†’ regenerate env + restart
132
+ - `services/` and `apps/` β†’ detect new/deleted packages and reinstall deps
133
+
134
+ ---
135
+
136
+ ## πŸ“ Generated Workspace Structure
137
+
86
138
  ```
87
139
  my-platform/
88
- β”œβ”€β”€ package.json
89
- β”œβ”€β”€ biome.json
90
- └── infra/
91
- β”œβ”€β”€ index.ts # Pulumi entry point
92
- β”œβ”€β”€ tsconfig.json
93
- β”œβ”€β”€ Pulumi.yaml
94
- β”œβ”€β”€ Pulumi.dev.yaml
95
- └── services/
96
- └── example.ts # Example service config
140
+ β”œβ”€β”€ .github/
141
+ β”‚ β”œβ”€β”€ workflows/
142
+ β”‚ β”‚ β”œβ”€β”€ lint-and-tests.yml # PR checks
143
+ β”‚ β”‚ β”œβ”€β”€ build-and-deploy.yml # Build & deploy on push to main
144
+ β”‚ β”‚ └── publish-packages.yml # Publish npm packages
145
+ β”‚ └── actions/
146
+ β”‚ β”œβ”€β”€ setup-bun-install/ # Cached Bun setup
147
+ β”‚ β”œβ”€β”€ generate-scope-matrix/ # Dynamic service detection
148
+ β”‚ β”œβ”€β”€ check-image-tag-exists/ # Skip unchanged builds
149
+ β”‚ └── ... # More reusable actions
150
+ β”œβ”€β”€ infra/
151
+ β”‚ β”œβ”€β”€ index.ts # Pulumi entry point
152
+ β”‚ β”œβ”€β”€ services/ # Service configs (auto-discovered)
153
+ β”‚ β”œβ”€β”€ Pulumi.yaml # Project config
154
+ β”‚ └── Pulumi.dev.yaml # Dev stack config
155
+ β”œβ”€β”€ services/ # Microservices
156
+ β”œβ”€β”€ apps/ # Frontend apps
157
+ β”œβ”€β”€ packages/ # Shared packages
158
+ β”œβ”€β”€ package.json # Root workspace config
159
+ β”œβ”€β”€ turbo.json # Turborepo config
160
+ └── biome.json # Linting config
161
+ ```
162
+
163
+ ---
164
+
165
+ ## πŸ›  CLI Commands
166
+
167
+ | Command | Description |
168
+ |---------|-------------|
169
+ | `pf new workspace <name>` | Scaffold a complete platform workspace |
170
+ | `pf new hono-micro <path>` | Generate a lightweight Hono microservice |
171
+ | `pf new nest-micro <path>` | Generate a NestJS microservice |
172
+ | `pf new hono-micro <path> --ai` | Generate with AI assistance |
173
+ | `pf setup --ai` | Configure AI provider (OpenAI/Anthropic) |
174
+ | `pf dev` | Start dev environment with watch mode |
175
+ | `pf dev --no-watch` | Start without file watching |
176
+ | `pf generate <schematic> <name>` | Generate code using schematics |
177
+
178
+ ---
179
+
180
+ ## πŸ”§ Configuration
181
+
182
+ ### Service Config Example
183
+
184
+ ```ts
185
+ // infra/services/orders.ts
186
+ import type { K8sServiceConfig } from '@crossdelta/infrastructure'
187
+
188
+ export const config: K8sServiceConfig = {
189
+ name: 'orders',
190
+ containerPort: 4001,
191
+ replicas: 1,
192
+ healthCheck: { port: 4001 },
193
+ resources: {
194
+ requests: { cpu: '50m', memory: '64Mi' },
195
+ limits: { cpu: '150m', memory: '128Mi' },
196
+ },
197
+ env: {
198
+ DATABASE_URL: databaseUrl,
199
+ NATS_URL: natsUrl,
200
+ },
201
+ }
202
+ ```
203
+
204
+ Running `pf dev` generates:
205
+
206
+ ```env
207
+ # .env.local
208
+ DATABASE_URL=postgres://...
209
+ NATS_URL=nats://localhost:4222
210
+ ORDERS_PORT=4001
97
211
  ```
98
212
 
99
- ### `pf new hono-micro [name]`
213
+ ---
214
+
215
+ ## 🚒 Deployment (DigitalOcean)
216
+
217
+ ### Prerequisites
218
+
219
+ 1. **Pulumi Account** – [Sign up free](https://app.pulumi.com/signup)
220
+ 2. **DigitalOcean Account** – [Create account](https://cloud.digitalocean.com/registrations/new)
221
+ 3. **GitHub Repository** – For CI/CD workflows
100
222
 
101
- Generate a lightweight Hono-based microservice.
223
+ ### GitHub Secrets
224
+
225
+ | Secret | Description |
226
+ |--------|-------------|
227
+ | `PULUMI_ACCESS_TOKEN` | Pulumi Cloud access token |
228
+ | `DIGITALOCEAN_TOKEN` | DigitalOcean API token |
229
+ | `NPM_TOKEN` | (optional) For private npm packages |
230
+
231
+ ### Deploy
102
232
 
103
233
  ```bash
104
- pf new hono-micro services/orders
234
+ pulumi login
235
+ pulumi up --stack dev
105
236
  ```
106
237
 
107
- ### `pf new nest-micro [name]`
238
+ ---
108
239
 
109
- Generate a NestJS microservice with full enterprise setup.
240
+ ## πŸ“¦ Installation
110
241
 
111
242
  ```bash
112
- pf new nest-micro services/api-gateway
243
+ # Via npx (recommended)
244
+ npx @crossdelta/platform-sdk new workspace my-platform
245
+
246
+ # Global install
247
+ bun add -g @crossdelta/platform-sdk
113
248
  ```
114
249
 
115
- **Includes:**
116
- - TypeScript configuration
117
- - Biome linting
118
- - Docker support
119
- - Health checks
250
+ ---
120
251
 
121
- ## Options
252
+ ## πŸ‘ When to use this
122
253
 
123
- | Flag | Description |
124
- |------|-------------|
125
- | `-y, --yes` | Skip all prompts, use defaults |
126
- | `-P, --package-manager <pm>` | Specify package manager (npm, yarn, pnpm, bun) |
127
- | `-h, --help` | Show help |
254
+ - βœ… **Bun-first microservice platform** with minimal boilerplate
255
+ - βœ… **Turborepo + Pulumi** as architectural baseline
256
+ - βœ… Fast **Hono/NestJS service scaffolding**
257
+ - βœ… **Unified dev workflow** for multiple services
258
+ - βœ… Deploy to **DigitalOcean App Platform**
259
+ - βœ… **GitHub Actions** for CI/CD
260
+
261
+ ---
262
+
263
+ ## ❌ When NOT to use this
264
+
265
+ - ❌ You need AWS, GCP, or other cloud providers (coming soon)
266
+ - ❌ You need a hosted PaaS (Render, Fly.io, Netlify)
267
+ - ❌ You are not using a monorepo
268
+ - ❌ You don't use Infrastructure-as-Code
269
+
270
+ ---
271
+
272
+ ## πŸ“š Requirements
273
+
274
+ | Requirement | Version |
275
+ |-------------|---------|
276
+ | Node.js | β‰₯ 21 |
277
+ | Bun | Latest (recommended) |
278
+ | Pulumi CLI | Latest |
279
+ | Docker | For local Supabase/NATS |
280
+
281
+ ---
282
+
283
+ ## πŸ”— Related Packages
284
+
285
+ | Package | Description |
286
+ |---------|-------------|
287
+ | [@crossdelta/infrastructure](https://www.npmjs.com/package/@crossdelta/infrastructure) | Pulumi helpers for DigitalOcean |
288
+ | [@crossdelta/cloudevents](https://www.npmjs.com/package/@crossdelta/cloudevents) | CloudEvents + NATS toolkit |
289
+ | [@crossdelta/telemetry](https://www.npmjs.com/package/@crossdelta/telemetry) | Zero-config OpenTelemetry |
128
290
 
129
- ## Requirements
291
+ ---
130
292
 
131
- - Node.js >= 21.0.0
132
- - Bun (recommended) or npm/yarn/pnpm
293
+ ## πŸ—ΊοΈ Roadmap
133
294
 
134
- ## Related
295
+ - [x] AI-powered service generation (OpenAI/Anthropic)
296
+ - [ ] AWS ECS/Fargate provider
297
+ - [ ] GCP Cloud Run provider
298
+ - [ ] Kubernetes (generic) provider
299
+ - [ ] `pf migrate` command for database migrations
135
300
 
136
- - [@crossdelta/infrastructure](https://www.npmjs.com/package/@crossdelta/infrastructure) - Infrastructure helpers for Pulumi + DigitalOcean
301
+ ---
137
302
 
138
- ## License
303
+ ## πŸ“„ License
139
304
 
140
305
  MIT Β© [Crossdelta](https://github.com/crossdelta)