@crossdelta/platform-sdk 0.17.5 → 0.18.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.
@@ -129,14 +129,8 @@ const envSchema = z.object({
129
129
  MY_SERVICE_PORT: z.string().optional(),
130
130
  })
131
131
 
132
- const result = envSchema.safeParse(process.env)
133
- if (!result.success) {
134
- console.error('❌ Environment validation failed:')
135
- console.error(result.error.format())
136
- process.exit(1)
137
- }
138
-
139
- export const env = result.data
132
+ // Use .parse() - throws ZodError if validation fails
133
+ export const env = envSchema.parse(process.env)
140
134
  ```
141
135
 
142
136
  **Add required environment variables:**
@@ -154,21 +148,16 @@ const envSchema = z.object({
154
148
  REDIS_URL: z.string().url().optional(),
155
149
  })
156
150
 
157
- const result = envSchema.safeParse(process.env)
158
- if (!result.success) {
159
- console.error('❌ Environment validation failed:')
160
- console.error(result.error.format())
161
- process.exit(1)
162
- }
163
-
164
- export const env = result.data
151
+ // Use .parse() - throws ZodError if validation fails
152
+ export const env = envSchema.parse(process.env)
165
153
  ```
166
154
 
167
155
  **Rules:**
168
- - ✅ Use `safeParse()` + explicit error handling for better error messages
156
+ - ✅ Use `.parse()` - throws error automatically (better separation of concerns)
169
157
  - ✅ Export validated `env` object for type-safe access
170
158
  - ✅ Use Zod v4 syntax (no params on `.email()`, `.url()`, etc.)
171
159
  - ✅ Port is always optional (has fallback in index.ts)
160
+ - ❌ DO NOT use `safeParse()` + `process.exit()` - breaks testability
172
161
  - ❌ DO NOT add PORT to env schema - it's read directly from process.env
173
162
 
174
163
  ---
@@ -193,15 +182,9 @@ const envSchema = z.object({
193
182
 
194
183
  export type Env = z.infer<typeof envSchema>
195
184
 
196
- // Validate and crash process if invalid (like @nestjs/config)
197
- const result = envSchema.safeParse(process.env)
198
- if (!result.success) {
199
- console.error('❌ Environment validation failed:')
200
- console.error(result.error.format())
201
- process.exit(1) // ← Force crash with exit code 1
202
- }
203
-
204
- export const env = result.data
185
+ // Use .parse() - throws ZodError if validation fails
186
+ // Let the caller (index.ts) decide how to handle the error
187
+ export const env = envSchema.parse(process.env)
205
188
  ```
206
189
 
207
190
  ### 2️⃣ **CRITICAL: Import in `src/index.ts` early!**
@@ -235,8 +218,9 @@ console.log(`Service running on http://localhost:${port}`)
235
218
  **CRITICAL:**
236
219
  - ✅ **MUST import `env` in `src/index.ts`** - without import, validation never runs!
237
220
  - ✅ Import early (after telemetry, before everything else)
238
- - ✅ Use `safeParse()` + `process.exit(1)` - Bun doesn't crash on top-level throws
239
- - ✅ Explicit exit ensures Turbo shows red X (like NestJS)
221
+ - ✅ Use `.parse()` - throws ZodError automatically (better than process.exit!)
222
+ - ✅ Uncaught error causes process to crash with proper stack trace
223
+ - ❌ **DO NOT** use `safeParse()` + `process.exit()` - breaks separation of concerns
240
224
  - ❌ **DO NOT** include `SERVICE_NAME_PORT` in env schema - already handled by CLI template
241
225
  - ❌ **DO NOT** validate inside handlers or use-cases
242
226
 
@@ -134,14 +134,8 @@ const envSchema = z.object({
134
134
  MY_SERVICE_PORT: z.string().optional(),
135
135
  })
136
136
 
137
- const result = envSchema.safeParse(process.env)
138
- if (!result.success) {
139
- console.error('❌ Environment validation failed:')
140
- console.error(result.error.format())
141
- process.exit(1)
142
- }
143
-
144
- export const env = result.data
137
+ // Use .parse() - throws ZodError if validation fails
138
+ export const env = envSchema.parse(process.env)
145
139
  ```
146
140
 
147
141
  **Add required environment variables:**
@@ -159,21 +153,16 @@ const envSchema = z.object({
159
153
  REDIS_URL: z.string().url().optional(),
160
154
  })
161
155
 
162
- const result = envSchema.safeParse(process.env)
163
- if (!result.success) {
164
- console.error('❌ Environment validation failed:')
165
- console.error(result.error.format())
166
- process.exit(1)
167
- }
168
-
169
- export const env = result.data
156
+ // Use .parse() - throws ZodError if validation fails
157
+ export const env = envSchema.parse(process.env)
170
158
  ```
171
159
 
172
160
  **Rules:**
173
- - ✅ Use `safeParse()` + explicit error handling for better error messages
161
+ - ✅ Use `.parse()` - throws error automatically (better separation of concerns)
174
162
  - ✅ Export validated `env` object for type-safe access
175
163
  - ✅ Use Zod v4 syntax (no params on `.email()`, `.url()`, etc.)
176
164
  - ✅ Port is always optional (has fallback in index.ts)
165
+ - ❌ DO NOT use `safeParse()` + `process.exit()` - breaks testability
177
166
  - ❌ DO NOT add PORT to env schema - it's read directly from process.env
178
167
 
179
168
  ---
@@ -197,15 +186,9 @@ const envSchema = z.object({
197
186
 
198
187
  export type Env = z.infer<typeof envSchema>
199
188
 
200
- // Validate and crash process if invalid (like @nestjs/config)
201
- const result = envSchema.safeParse(process.env)
202
- if (!result.success) {
203
- console.error('❌ Environment validation failed:')
204
- console.error(result.error.format())
205
- process.exit(1) // ← Force crash with exit code 1
206
- }
207
-
208
- export const env = result.data
189
+ // Use .parse() - throws ZodError if validation fails
190
+ // Let the caller (index.ts) decide how to handle the error
191
+ export const env = envSchema.parse(process.env)
209
192
  ```
210
193
 
211
194
  ### 2️⃣ **CRITICAL: Import in `src/index.ts` early!**
@@ -215,7 +198,7 @@ export const env = result.data
215
198
  import '@crossdelta/telemetry' // ← MUST be first!
216
199
 
217
200
  // ⚠️ CRITICAL: Import env IMMEDIATELY after telemetry
218
- // This executes validation and crashes process if env invalid
201
+ // This executes validation and throws ZodError if invalid
219
202
  import { env } from './config/env' // ← THIS LINE IS REQUIRED!
220
203
 
221
204
  import { serve } from '@hono/node-server'
@@ -248,8 +231,9 @@ serve({ fetch: app.fetch, port }, (info) => {
248
231
  **CRITICAL:**
249
232
  - ✅ **MUST import `env` in `src/index.ts`** - without import, validation never runs!
250
233
  - ✅ Import early (after telemetry, before everything else)
251
- - ✅ Use `safeParse()` + `process.exit(1)` - ensures proper crash behavior
252
- - ✅ Explicit exit ensures Turbo shows red X (like NestJS)
234
+ - ✅ Use `.parse()` - throws ZodError automatically (better than process.exit!)
235
+ - ✅ Uncaught error causes process to crash with proper stack trace
236
+ - ❌ **DO NOT** use `safeParse()` + `process.exit()` - breaks separation of concerns
253
237
  - ❌ **DO NOT** include `SERVICE_NAME_PORT` in env schema - already handled by CLI template
254
238
  - ❌ **DO NOT** validate inside handlers or use-cases
255
239
 
@@ -62,6 +62,7 @@ jobs:
62
62
  [ ! -f "$dir/package.json" ] && continue
63
63
 
64
64
  slug=$(basename "$dir")
65
+ dir="${dir%/}" # Remove trailing slash
65
66
  name=$(jq -r '.name // empty' "$dir/package.json")
66
67
  is_private=$(jq -r '.private // false' "$dir/package.json")
67
68
 
@@ -115,12 +116,11 @@ jobs:
115
116
  path: |
116
117
  packages/*/dist
117
118
  packages/*/bin
118
- packages/*/README.md
119
- packages/*/CHANGELOG.md
119
+ packages/*/*.md
120
120
  packages/*/LICENSE
121
- packages/*/logo.png
121
+ packages/*/*.png
122
122
  packages/*/schemas
123
- packages/*/install.sh
123
+ packages/*/*.sh
124
124
  retention-days: 1
125
125
 
126
126
  # Publish packages sequentially (max-parallel: 1)
@@ -145,12 +145,16 @@ jobs:
145
145
  uses: actions/download-artifact@v4
146
146
  with:
147
147
  name: dist-packages
148
- path: packages/
148
+ path: packages
149
149
 
150
150
  - name: Verify build artifacts
151
151
  run: |
152
- if [ ! -d "${{ matrix.package.dir }}/dist" ]; then
152
+ echo "📂 Checking ${{ matrix.package.dir }}"
153
+ ls -la "${{ matrix.package.dir }}" || true
154
+ if [ ! -d "${{ matrix.package.dir }}/dist" ] && [ ! -d "${{ matrix.package.dir }}/bin" ]; then
153
155
  echo "❌ Build artifacts missing for ${{ matrix.package.name }}"
156
+ echo "📂 packages/ contents:"
157
+ ls -la packages/
154
158
  exit 1
155
159
  fi
156
160
  echo "✅ Build artifacts found for ${{ matrix.package.name }}"
@@ -2,7 +2,7 @@
2
2
  "name": "infra",
3
3
  "private": true,
4
4
  "scripts": {
5
- "generate-env": "bunx generate-env",
5
+ "generate-env": "generate-env",
6
6
  "lint": "biome lint --fix",
7
7
  "pulumi": "pulumi"
8
8
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crossdelta/platform-sdk",
3
- "version": "0.17.5",
3
+ "version": "0.18.1",
4
4
  "description": "Platform toolkit for event-driven microservices — keeping code and infrastructure in lockstep.",
5
5
  "keywords": [
6
6
  "cli",
@@ -33,6 +33,8 @@
33
33
  "!bin/**/*.map",
34
34
  "dist/",
35
35
  "README.md",
36
+ "CHANGELOG.md",
37
+ "LICENSE",
36
38
  "logo.png",
37
39
  "schemas",
38
40
  "install.sh"