@pikku/queue-pg-boss 0.12.11 → 0.12.12

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 (3) hide show
  1. package/package.json +13 -7
  2. package/CHANGELOG.md +0 -437
  3. package/run-tests.sh +0 -68
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/queue-pg-boss",
3
- "version": "0.12.11",
3
+ "version": "0.12.12",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/pikkujs/pikku.git",
@@ -16,17 +16,23 @@
16
16
  "tsc": "tsc",
17
17
  "test": "bash run-tests.sh",
18
18
  "ncu": "npx npm-check-updates",
19
- "build": "tsc -b",
19
+ "build": "bun run clean && tsc -b",
20
20
  "release": "npm run build && npm test",
21
- "prepublishOnly": "bun run build"
21
+ "prepublishOnly": "bun run build",
22
+ "clean": "rm -rf dist tsconfig.tsbuildinfo"
22
23
  },
23
24
  "peerDependencies": {
24
- "@pikku/core": "^0.12.108"
25
+ "@pikku/core": "^0.12.144"
25
26
  },
26
27
  "dependencies": {
27
- "pg-boss": "^12.27.0"
28
+ "pg-boss": "^12.38.0"
28
29
  },
29
30
  "exports": {
30
- ".": "./dist/index.js"
31
- }
31
+ ".": "./dist/index.js",
32
+ "./package.json": "./package.json"
33
+ },
34
+ "files": [
35
+ "dist",
36
+ "!dist/**/*.tsbuildinfo"
37
+ ]
32
38
  }
package/CHANGELOG.md DELETED
@@ -1,437 +0,0 @@
1
- ## 0.12.11
2
-
3
- ### Patch Changes
4
-
5
- - 4c7a1b5: Run the monorepo's own scripts through bun instead of yarn. What moves is the
6
- package manager each package's `prepublishOnly` and build scripts invoke, plus
7
- the two manifest fixes bun needs to resolve the tree: `uWebSockets.js` is
8
- declared with an explicit `github:` specifier, and `@pikku/uws-handler` marks
9
- its `uWebSockets.js` peer optional so a bun install of a consumer that brings
10
- its own uWS app does not try to fetch it from the registry.
11
-
12
- Three published behaviours change, all of them cases where an isolated
13
- `node_modules` or bun as the runtime had been papered over by yarn's hoisting:
14
-
15
- - `@pikku/migrator-sql` turns foreign keys on when it opens a sqlite database
16
- through bun. `node:sqlite` enforces them by default and `bun:sqlite` does not,
17
- which silently turned every `ON DELETE CASCADE` into a no-op under
18
- `bunx --bun pikku`.
19
- - `@pikku/cli` resolves a deploy provider against the project being deployed
20
- rather than against wherever the CLI itself is installed, which is what its
21
- own "is not installed" error asks the user to arrange.
22
- - `@pikku/cli` treats a specifier a runtime hands straight back — bun does this
23
- for the modules it implements itself — as not resolved from the project, so
24
- it falls back rather than loading the runtime's own copy.
25
-
26
- - Updated dependencies [4c7a1b5]
27
- - @pikku/core@0.12.108
28
-
29
- ## 0.12.10
30
-
31
- ### Patch Changes
32
-
33
- - 266e3bc: One door per name: `@pikku/core/ecosystem/*` and the package root are gone
34
-
35
- `@pikku/core` published every module twice. `ecosystem/http` re-exported
36
- `./http`, `ecosystem/services` re-exported `./services`, and a name was
37
- reachable through either — so every addition had to be made in two places, and a
38
- consumer's import said nothing about what it actually used. The package root was
39
- the same problem at a larger scale: a single barrel of 206 names that no bundler
40
- could take apart, and the one specifier that revealed nothing at all.
41
-
42
- Both are deleted. Every name now lives on the subpath that owns it, and every
43
- import carries that subpath — `@pikku/core/http`, `@pikku/core/services`,
44
- `@pikku/core/errors`, `@pikku/core/types`.
45
-
46
- Deleting the facades meant the raw subpaths had to become a superset of them,
47
- which they were not: the facade tree had accumulated 25 names with no raw home
48
- and about 26 more filed under a different area than the module they came from.
49
- Those names moved to the area that owns them, and three areas were published as
50
- new entry points rather than left on a root that is going away — `./types` (the
51
- shared type surface, the largest single destination), `./state` and
52
- `./classification`.
53
-
54
- `./classification` is one door onto one subject: what a value is and how it must
55
- be handled. Its three halves would each have been an entry point — the brands
56
- and manifest types, the stored-form helpers (`hashToken`, `unsafeAsSealed` and
57
- friends), and `SecretValue` — split by whether a name happens to be a type or a
58
- value, which is the same defect as the facades. The duration and versioned-id
59
- helpers went to `./utils`, which already published, and `PikkuRequest` went to
60
- `./function`: it is the transport-agnostic request base, not an HTTP one — HTTP
61
- has `PikkuHTTPAbstractRequest`, and the only thing outside core that extends
62
- `PikkuRequest` is Azure's timer request.
63
-
64
- `./types` inherited the root barrel's habit before it inherited its contents, so
65
- the names with an owner elsewhere were moved off it. The middleware types and the
66
- five middleware factories — `pikkuMiddleware`, `pikkuMiddlewareFactory`,
67
- `pikkuChannelMiddleware`, `pikkuChannelMiddlewareFactory` and
68
- `pikkuAgentMiddleware`, runtime values on a types entry point — are now
69
- `@pikku/core/middleware`; the function meta types are `@pikku/core/function`;
70
- `SerializedError` is `@pikku/core/errors`; and the generic TypeScript helpers
71
- (`MakeRequired`, `PickRequired`, `PickOptional`, `RequireAtLeastOne`,
72
- `JSONPrimitive`, `JSONValue`) are `@pikku/core/utils`. What is left on `./types`
73
- is the vocabulary the wirings share, which no single module owns.
74
-
75
- `pikku` was itself a root barrel — `export * from '@pikku/core'` — and
76
- now exports only the services it bundles.
77
-
78
- One module survives at the old specifier, and only for the bootstrap:
79
- `packages/cli` is generated by the _published_ CLI pinned in its `build.sh`, and
80
- that CLI still writes a bare `@pikku/core` into the files it generates for the
81
- CLI itself. `bootstrap-compat/root.ts` carries the eight types it names, a test
82
- in core fails if that list grows, and it goes when the pin moves to a CLI
83
- released from this branch. The adapter names the pinned CLI reaches for —
84
- `pikkuState` and `CreateWireServices` — are rewritten to `@pikku/core/state` and
85
- `@pikku/core/types` by the same `build.sh` patch pass, so no second shim is
86
- needed for them.
87
-
88
- A guard test keeps the root shut: it parses imports and rejects a bare
89
- `@pikku/core` rather than grepping for it, because several tests hold a user's
90
- file as a template literal, where `import … from '@pikku/core'` is fixture text
91
- rather than an import this repo makes.
92
-
93
- An agent scaffold a project generated under an older CLI is refreshed rather
94
- than left to fail: `pikku all` already deleted one importing an entry point
95
- `@pikku/core` no longer publishes, and the `#pikku` hub joins that list.
96
- Without it a project that scaffolds the agent endpoint but
97
- declares no agents keeps the old file forever — the generator that would rewrite
98
- it only runs when agents exist, and the file being present is what stops it
99
- being regenerated as missing.
100
-
101
- `pikku new addon` also wrote a tsconfig `paths` map naming only the deleted hub.
102
- An addon's `imports` map points into `dist`, so `paths` is what resolves
103
- `#pikku/<leaf>` for the addon's own source build — it now names the two leaf
104
- patterns, in both the addon and its test harness.
105
-
106
- - 6eef0a0: Bump every dependency to its latest compatible minor/patch across the monorepo.
107
- - Updated dependencies [7722ceb]
108
- - Updated dependencies [375c1ff]
109
- - Updated dependencies [02a70cd]
110
- - Updated dependencies [aeef159]
111
- - Updated dependencies [a281de6]
112
- - Updated dependencies [266e3bc]
113
- - Updated dependencies [02a70cd]
114
- - Updated dependencies [786dae5]
115
- - Updated dependencies [6eef0a0]
116
- - Updated dependencies [3561d67]
117
- - Updated dependencies [a91c433]
118
- - Updated dependencies [02a70cd]
119
- - Updated dependencies [9537f74]
120
- - Updated dependencies [2b57ca8]
121
- - Updated dependencies [266e3bc]
122
- - Updated dependencies [9fce0f1]
123
- - Updated dependencies [83683a0]
124
- - Updated dependencies [456c88b]
125
- - Updated dependencies [456c88b]
126
- - Updated dependencies [c127273]
127
- - @pikku/core@0.12.85
128
-
129
- ## 0.12.9
130
-
131
- ### Patch Changes
132
-
133
- - 6794681: Publish the ecosystem surface as per-area sub-barrels under `@pikku/core/ecosystem/*`, and point generated code, the CLI, the inspector and the runtime adapters at them.
134
-
135
- 348 names that only generated code, the toolchain or a runtime adapter ever imports now have a second home on `@pikku/core/ecosystem/<area>` — one sub-barrel per area, matching how core already publishes its entrypoints, so no single barrel grows without bound and a consumer only pulls in the area it uses.
136
-
137
- This step is additive: every name is still exported from the entrypoint it was published from before, so nothing downstream breaks. Removing them from the app-facing barrels is a later change, and needs a release carrying `./ecosystem/*` first.
138
-
139
- - Updated dependencies [7406bfe]
140
- - Updated dependencies [6794681]
141
- - @pikku/core@0.12.84
142
-
143
- ## 0.12.8
144
-
145
- ### Patch Changes
146
-
147
- - 6847338: Stop one slow job from holding an entire queue (head-of-line blocking).
148
-
149
- The worker mapped pikku's parallelism to pg-boss `batchSize`, whose handler
150
- receives the whole fetched batch and only fetches again once that handler
151
- resolves. Because the handler `Promise.all`s the batch, a single long-running
152
- job blocked every sibling in its batch _and_ stalled the next fetch — so on a
153
- shared queue one slow job could freeze the worker and starve everything behind
154
- it (observed with workflow-orchestrator jobs, where a long step pinned all 10
155
- slots for tens of minutes).
156
-
157
- Parallelism now maps to pg-boss `localConcurrency` with `batchSize: 1`: N
158
- independent workers each fetch and process a single job and refill the instant
159
- they finish, so a slow job never holds up the others. Same effective
160
- concurrency, no head-of-line blocking.
161
-
162
- - e3d4454: Add job groups, so one shared queue can stay fair without splitting into one
163
- queue per producer.
164
-
165
- A job may now carry `group: { id, tier }`, and a worker may cap how many jobs
166
- of any one group run at once via `groupConcurrency`. On pg-boss this maps to
167
- `localGroupConcurrency`, which excludes at-capacity groups from the fetch query
168
- itself, so a capped group costs nothing rather than being fetched and restored.
169
- BullMQ declares it unsupported (groups are a BullMQ Pro feature) — being
170
- push-based, it can simply use a queue per group at no polling cost.
171
-
172
- Workflow services accept a `queueStrategy`. The default `'per-workflow'` is
173
- unchanged: every workflow gets its own `wf-orchestrator-*` / `wf-step-*` queue,
174
- which is also what lets serverless providers deploy one unit per workflow. The
175
- new `'shared-groups'` routes every workflow through the shared
176
- orchestrator/step-worker queues and isolates them by group instead, so a
177
- monolith runs one set of pollers rather than one per workflow — on a
178
- pull-based backend with dozens of workflows that is the difference between
179
- hundreds of poll loops and twenty. It is for single-process runtimes only; a
180
- per-unit serverless deploy still needs the per-workflow queues to route to its
181
- units.
182
-
183
- - Updated dependencies [24252b8]
184
- - Updated dependencies [e3d4454]
185
- - @pikku/core@0.12.69
186
-
187
- ## 0.12.7
188
-
189
- ### Patch Changes
190
-
191
- - 6c30861: fix workflow step retry backoff firing immediately
192
- - `@pikku/queue-pg-boss`: `backoff: 'exponential'` mapped to `retryBackoff: true` without a base `retryDelay`; pg-boss computes exponential backoff as `retry_delay * 2^n` with a queue default of 0, so every retry fired immediately. Exponential backoff now gets a 1s base delay, and sub-second fixed delays round up to 1s instead of flooring to 0 (= immediate).
193
- - `@pikku/core`: a duration-string `retryDelay` (e.g. `'15s'`) on a workflow step was silently dropped (only numbers were honored) and fell back to exponential. It now resolves to a fixed backoff via `getDurationInMilliseconds`.
194
-
195
- - Updated dependencies [6c30861]
196
- - @pikku/core@0.12.56
197
-
198
- ## 0.12.6
199
-
200
- ### Patch Changes
201
-
202
- - 41ce2cb: Upgrade to TypeScript 6 and raise the minimum Node.js version to 22.
203
-
204
- All packages now build against `typescript@^6.0.3` and declare `engines.node >= 22`. Internal tooling (`ts-json-schema-generator`, `zod-to-ts`) was bumped to TypeScript 6-compatible releases.
205
-
206
- - Updated dependencies [41ce2cb]
207
- - @pikku/core@0.12.44
208
-
209
- ## 0.12.5
210
-
211
- ### Patch Changes
212
-
213
- - 05aba57: fix(scheduler): prune orphaned recurring-task schedules on start
214
-
215
- When a scheduled task is removed from code, its pg-boss schedule row survived and
216
- kept producing jobs into a queue with no registered worker — the jobs piled up as
217
- 'created' forever and could flood the queue (thousands of stuck jobs). `start()`
218
- now drops any `pikku-recurring-scheduled-task_*` schedule and queue that is no
219
- longer registered, so task removals self-heal on the next boot.
220
-
221
- - Updated dependencies [a8022e5]
222
- - @pikku/core@0.12.43
223
-
224
- ## 0.12.4
225
-
226
- ### Patch Changes
227
-
228
- - 92cd5b1: feat(workflow): workflow-owned step retries + stable invocationId
229
-
230
- The workflow — not the queue — now owns step retry policy, and each step
231
- invocation gets a stable idempotency key.
232
- - **Default `retries: 5` with exponential backoff.** A step with no `retries`
233
- previously inherited the queue's bare default (e.g. pg-boss `retry_limit 2`,
234
- no backoff) so retries fired instantly and couldn't outlast a transient
235
- outage. Retries now default to 5 with backoff, resolved at the workflow layer.
236
- - **`retries: 0` is honored.** Dispatch previously passed `undefined` options
237
- for `retries: 0`, letting the queue re-run a non-idempotent step up to its own
238
- default. The resolved policy now always sets `attempts` (`retries: 0` →
239
- `attempts: 1`), so the queue never second-guesses the workflow. The persisted
240
- step retries and the dispatched `attempts` are resolved together so
241
- "retries exhausted" and "no more redeliveries" are the same event.
242
- - **`workflowStep.invocationId`** — a deterministic, dependency-free
243
- `uuidv5(runId:stepName)` handed to every step. Unlike `stepId` (minted per
244
- attempt), it is identical across retries, so a step can dedupe on it
245
- (`ON CONFLICT (invocationId)`, Stripe idempotency keys, etc.).
246
- - **queue-bullmq**: `mapPikkuJobToBull` now maps `backoff` (previously dropped,
247
- so a step's backoff silently never applied on Redis), and `registerQueues`
248
- throws a clear error when no logger is available (matching queue-pg-boss).
249
- - **Dispatch failures are recoverable, not fatal.** A step is now marked
250
- `scheduled` only _after_ it is successfully handed to its transport (queue or
251
- scheduler) — a failed hand-off leaves it `pending` so a replay re-dispatches
252
- it, instead of stranding it in `scheduled` (replay would pause forever on a
253
- job that was never enqueued). A transport outage (e.g. pg-boss momentarily
254
- down) is surfaced as a new `WorkflowDispatchException`, which the orchestrator
255
- treats as transient: the run is left running and the orchestrator job is
256
- rethrown for redelivery (it replays idempotently from the snapshot) rather
257
- than the whole run being marked `failed`. The orchestrator job now also
258
- carries its own retry policy, so this holds even when the orchestrator queue
259
- is configured `retry_limit 0`. A genuine step error still fails the run.
260
- - **Same step name can be invoked multiple times in one run.** Step rows are now
261
- keyed per _invocation_: the Nth reach of a step name in a replay resolves to a
262
- physical key (`name` for the first, `name#N` for repeats), so a literal
263
- duplicate name no longer clobbers the earlier step's state. The first reach
264
- keeps the bare name, so existing rows, graph-node matching and `invocationId`s
265
- are unchanged. Ordinals are derived deterministically from DSL execution order
266
- and reset each replay.
267
- - **Step provenance (`fromStepName`) + graph cycles.** Every step now records
268
- the predecessor it was scheduled from (`fromStepName`; entry steps have none),
269
- persisted on the step row across all stores (in-memory, kysely, redis,
270
- mongodb, cloudflare DO) and carried in the queued payload. The DSL wire
271
- exposes the derived `fromInvocationId` (`uuidv5(runId:fromStepName)`) so
272
- consumers get the stable predecessor key without a second persisted id —
273
- `fromStepName` is the source of truth (it is replay-deterministic; `stepId`,
274
- minted per row, is not). This makes the walked path reconstructable even when
275
- a node is reached more than once: in `a → b → a → c` the second `a` is a
276
- distinct ordinal instance (`a#1`) whose `fromStepName` is `b`.
277
- The graph runner now supports **cycles**: a forward edge into an
278
- already-started node still collapses to a single run (joins/diamonds are
279
- unchanged), but a _back-edge_ — one whose target can reach its source — fires
280
- a fresh ordinal instance, so a node can loop back to itself. Termination is
281
- the graph's responsibility (branch routing must converge); the engine enforces
282
- no visit cap.
283
-
284
- - Updated dependencies [92cd5b1]
285
- - @pikku/core@0.12.38
286
-
287
- ## 0.12.0
288
-
289
- ## 0.12.3
290
-
291
- ### Patch Changes
292
-
293
- - 8b9b2e9: Accept optional logger parameter in `registerQueues()` instead of reaching into pikku state directly. Falls back to `getSingletonServices()` for backwards compatibility.
294
- - 8b9b2e9: Fix child workflow completion in queued execution mode. When a sub-workflow completes, the parent step is now marked as succeeded and the parent orchestrator resumes automatically via `onChildWorkflowCompleted`. Adds `parentStepId` to `WorkflowRunWire` to track the parent step without querying. Retains advisory locks in PgKyselyWorkflowService for concurrency safety. Fixes pgboss `registerQueues` to accept an optional logger parameter.
295
- - Updated dependencies [e412b4d]
296
- - Updated dependencies [53dc8c8]
297
- - Updated dependencies [0a1cc51]
298
- - Updated dependencies [0a1cc51]
299
- - Updated dependencies [0a1cc51]
300
- - Updated dependencies [0a1cc51]
301
- - Updated dependencies [0a1cc51]
302
- - Updated dependencies [0a1cc51]
303
- - Updated dependencies [0a1cc51]
304
- - Updated dependencies [0a1cc51]
305
- - Updated dependencies [0a1cc51]
306
- - Updated dependencies [8b9b2e9]
307
- - Updated dependencies [8b9b2e9]
308
- - Updated dependencies [b973d44]
309
- - Updated dependencies [8b9b2e9]
310
- - Updated dependencies [8b9b2e9]
311
- - @pikku/core@0.12.9
312
-
313
- ## 0.12.2
314
-
315
- ### Patch Changes
316
-
317
- - 3e04565: chore: update dependencies to latest minor/patch versions
318
- - Updated dependencies [cc4c9e9]
319
- - Updated dependencies [3e04565]
320
- - @pikku/core@0.12.2
321
-
322
- ## 0.12.1
323
-
324
- ### Patch Changes
325
-
326
- - 62a8725: Fix pg-boss queue initialisation: create the queue before registering a worker to avoid a race condition on first startup. Also sanitise scheduler names to meet pg-boss naming constraints.
327
- - Updated dependencies [62a8725]
328
- - Updated dependencies [a3bdb0d]
329
- - Updated dependencies [e0349ff]
330
- - Updated dependencies [62a8725]
331
- - Updated dependencies [e04531f]
332
- - Updated dependencies [62a8725]
333
- - Updated dependencies [a83efb8]
334
- - Updated dependencies [8eed717]
335
- - Updated dependencies [62a8725]
336
- - Updated dependencies [62a8725]
337
- - Updated dependencies [62a8725]
338
- - @pikku/core@0.12.1
339
-
340
- ### New Features
341
-
342
- - `setServices()`, `start()`, `stop()` lifecycle methods on scheduler and queue workers
343
-
344
- ## 0.11.0
345
-
346
- ## 0.11.2
347
-
348
- ### Patch Changes
349
-
350
- - db9c7bf: Simplify CreateWireServices type signature for custom Config compatibility
351
- - Updated dependencies [db9c7bf]
352
- - @pikku/core@0.11.2
353
-
354
- ### Fixes
355
-
356
- - ddd87eaf: Simplify CreateWireServices type signature for custom Config compatibility
357
-
358
- ## 0.11.1
359
-
360
- ### Patch Changes
361
-
362
- - 4b811db: chore: updating all dependencies
363
- - 06e1a31: breaking: change session services to wire services
364
- - Updated dependencies [4b811db]
365
- - Updated dependencies [e12a00c]
366
- - Updated dependencies [4579434]
367
- - Updated dependencies [28aeb7f]
368
- - Updated dependencies [ce902b1]
369
- - Updated dependencies [06e1a31]
370
- - @pikku/core@0.11.1
371
-
372
- ### Minor Changes
373
-
374
- - Add scheduler service implementation
375
- - Add service factory for queue and scheduler creation
376
-
377
- # @pikku/queue-pg-boss
378
-
379
- ## 0.10.0
380
-
381
- This release includes significant improvements across the framework including tree-shaking support, middleware/permission factories, enhanced CLI functionality, improved TypeScript type safety, and comprehensive test strategies.
382
-
383
- For complete details, see https://pikku.dev/changelogs/0_10_0.md
384
-
385
- ## 0.9.5-next.0
386
-
387
- ### Patch Changes
388
-
389
- - Updated dependencies
390
- - @pikku/core@0.9.12-next.0
391
-
392
- ## 0.9.4
393
-
394
- ### Patch Changes
395
-
396
- - 3bb5824: fix: forcing release to see if dist is generated
397
- - Updated dependencies [99c2b3a]
398
- - @pikku/core@0.9.9
399
-
400
- ## 0.9.3
401
-
402
- ### Patch Changes
403
-
404
- - c18800d: feat: adding queue and scheduledTask to interactions
405
- - Updated dependencies [c18800d]
406
- - @pikku/core@0.9.4
407
-
408
- ## 0.9.2
409
-
410
- ### Patch Changes
411
-
412
- - a5905a9: chore: updating all dependencies
413
- - Updated dependencies [1256238]
414
- - Updated dependencies [6cf8efd]
415
- - Updated dependencies [d3a9a09]
416
- - Updated dependencies [840e078]
417
- - Updated dependencies [667d23c]
418
- - Updated dependencies [a5905a9]
419
- - @pikku/core@0.9.2
420
-
421
- ## 0.9.1
422
-
423
- ### Patch Changes
424
-
425
- - fdb1593: core: bumping everything with a patch to sync up the major release inconsistencies in dependencies
426
- - Updated dependencies [fdb1593]
427
- - @pikku/core@0.9.1
428
-
429
- ## 0.9.0
430
-
431
- ### Breaking Changes
432
-
433
- - Normalized all transports to use "wirings" instead of events/routes/transports for consistency across the framework
434
-
435
- ## 0.8.0
436
-
437
- - **PG Boss integration**: Postgres queue service implementation
package/run-tests.sh DELETED
@@ -1,68 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Enable nullglob to handle cases where no files match the pattern
4
- shopt -s nullglob
5
-
6
- # Initialize variables for options
7
- watch_mode=false
8
- coverage_mode=false
9
-
10
- # Parse command-line options
11
- while [[ $# -gt 0 ]]; do
12
- case $1 in
13
- --watch)
14
- watch_mode=true
15
- shift
16
- ;;
17
- --coverage)
18
- coverage_mode=true
19
- shift
20
- ;;
21
- *)
22
- echo "Unknown option: $1"
23
- exit 1
24
- ;;
25
- esac
26
- done
27
-
28
- # Define the pattern to match your test files
29
- pattern="src/*.test.ts"
30
-
31
- # Expand the pattern into an array of files
32
- files=($(find src -type f -name "*.test.ts"))
33
-
34
- # Check if any files matched the pattern
35
- if [ ${#files[@]} -eq 0 ]; then
36
- echo "No test files found matching pattern: $pattern"
37
- if [ "${STRICT_TEST_DISCOVERY}" = "1" ]; then
38
- exit 1
39
- fi
40
- exit 0
41
- fi
42
-
43
- # Construct the bun command
44
- #
45
- # --parallel gives every test file its own worker process, which is what node's
46
- # `--test` did. Several suites keep module-level caches (a TypeScript program, a
47
- # temp fixture directory) that a shared process would leak between files.
48
- #
49
- # --timeout because bun caps a test at 5s by default where node had no cap, and
50
- # the suites that build real TypeScript programs run well past that.
51
- bun_cmd=(bun test --parallel --timeout 120000)
52
-
53
- # Append options based on flags
54
- if [ "$watch_mode" = true ]; then
55
- # --watch reruns in one process; parallel workers have nothing to watch.
56
- bun_cmd=(bun test --watch --timeout 120000)
57
- fi
58
-
59
- if [ "$coverage_mode" = true ]; then
60
- # --coverage-dir=. keeps lcov.info at the package root: CI merges every
61
- # package's report by prefixing its SF paths with the file's own directory,
62
- # so a nested coverage/ directory would re-root them one level too deep.
63
- bun_cmd+=(--coverage --coverage-reporter=lcov --coverage-reporter=text --coverage-dir=.)
64
- export PIKKU_TEST_COVERAGE=1
65
- fi
66
-
67
- # Execute the bun command with the expanded list of files
68
- "${bun_cmd[@]}" "${files[@]}"