@pikku/bun-server 0.12.14 → 0.12.15

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 -8
  2. package/CHANGELOG.md +0 -397
  3. package/run-tests.sh +0 -68
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/bun-server",
3
- "version": "0.12.14",
3
+ "version": "0.12.15",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/pikkujs/pikku.git",
@@ -11,18 +11,23 @@
11
11
  "author": "yasser.fadl@gmail.com",
12
12
  "module": "dist/index.js",
13
13
  "main": "dist/index.js",
14
+ "files": [
15
+ "dist",
16
+ "!dist/**/*.tsbuildinfo"
17
+ ],
14
18
  "type": "module",
15
19
  "scripts": {
16
20
  "tsc": "tsc",
17
- "build": "tsc -b",
21
+ "build": "bun run clean && tsc -b",
18
22
  "test": "bash run-tests.sh",
19
23
  "test:watch": "bash run-tests.sh --watch",
20
24
  "test:coverage": "bash run-tests.sh --coverage",
21
- "prepublishOnly": "bun run build"
25
+ "prepublishOnly": "bun run build",
26
+ "clean": "rm -rf dist tsconfig.tsbuildinfo"
22
27
  },
23
28
  "peerDependencies": {
24
- "@pikku/core": "^0.12.141",
25
- "@pikku/modelcontextprotocol": "^0.12.14"
29
+ "@pikku/core": "^0.12.144",
30
+ "@pikku/modelcontextprotocol": "^0.12.18"
26
31
  },
27
32
  "peerDependenciesMeta": {
28
33
  "@pikku/modelcontextprotocol": {
@@ -30,9 +35,9 @@
30
35
  }
31
36
  },
32
37
  "devDependencies": {
33
- "@pikku/core": "^0.12.141",
34
- "@pikku/modelcontextprotocol": "^0.12.14",
35
- "@types/bun": "^1.4.0"
38
+ "@pikku/core": "^0.12.144",
39
+ "@pikku/modelcontextprotocol": "^0.12.18",
40
+ "@types/bun": "^1.4.3"
36
41
  },
37
42
  "engines": {
38
43
  "bun": ">=1.4.0"
package/CHANGELOG.md DELETED
@@ -1,397 +0,0 @@
1
- # @pikku/bun-server
2
-
3
- ## 0.12.14
4
-
5
- ### Patch Changes
6
-
7
- - d3d8a98: Graceful shutdown ignores repeat signals. A second SIGTERM or SIGINT arriving while `beforeStop` and the service teardown are still running no longer falls through to the default handler and kills the process mid-cleanup. `@pikku/core/lifecycle` is a new entry point holding `onShutdownSignals`, `stopSingletonServices` and `pikkuServerLifecycle` (the latter two stay re-exported from `utils`), which the server runtimes now share.
8
- - Updated dependencies [b04e444]
9
- - Updated dependencies [d3d8a98]
10
- - Updated dependencies [658da50]
11
- - @pikku/core@0.12.141
12
-
13
- ## 0.12.13
14
-
15
- ### Patch Changes
16
-
17
- - b312867: A project can now serve several MCP endpoints, one per connector.
18
-
19
- Until now every MCP tool in a project was pooled onto a single `/mcp`, so a hub offering three connectors offered one endpoint listing all three connectors' tools at once. A client pointed at it saw tools it had no business calling, and the only way to give a connector an endpoint of its own was to give it a deployment of its own — three deploys, three bills, three service graphs.
20
-
21
- `wireAddon` gains `mcpEndpoint`. `true` serves that instance's tools at `/mcp/<name>`; a string is the path, used as given. Leaving it unset keeps the tools on the shared endpoint, which is where they have always been, so nothing existing moves.
22
-
23
- A surfaced instance now gets its own manifest (`.pikku/mcp/mcp.<name>.gen.json`, carrying the path it answers on), its own deploy unit (`mcp-<name>`, routed on that path), and its own MCP server — with its own tool list, so a client pointed at one endpoint never sees another's tools. The plumbing for the per-surface manifest and unit already existed in `deploy apply`; nothing had ever produced one.
24
-
25
- `pikku dev` mounts every endpoint the generated tree describes, not just the default one. Without that a project that moved its tools onto their own endpoints would have served nothing locally at all — the default manifest it reads is empty precisely because they moved — and the only way to try a connector would have been to deploy it.
26
-
27
- The node and bun transports take `mcpSurfaces` alongside `mcpJson` and mount each at its own path, longest path first. `/mcp` claims everything beneath `/mcp/`, so without that ordering the default endpoint answers `/mcp/weather` and the surface's tools are unreachable.
28
-
29
- OAuth discovery is split between the endpoints rather than duplicated across them. RFC 9728 folds a resource's path into its well-known route, so each endpoint's own document is already distinct, but the path-less `/.well-known/oauth-protected-resource` predates that and describes whichever resource answers it. Only the default endpoint claims it — otherwise every unit registers the same route and the provider's router decides which resource a client is told about, and in dev a client probing it is described whichever surface sorted first.
30
-
31
- - Updated dependencies [87971bd]
32
- - Updated dependencies [51bd35a]
33
- - Updated dependencies [b312867]
34
- - Updated dependencies [51bd35a]
35
- - @pikku/core@0.12.116
36
- - @pikku/modelcontextprotocol@0.12.14
37
-
38
- ## 0.12.12
39
-
40
- ### Patch Changes
41
-
42
- - dfd7019: An MCP call that needs a session is refused with an OAuth challenge
43
-
44
- A tool fronting a session-requiring function used to answer an unauthenticated
45
- caller with `200` and `isError: true`, which a client reads as a tool that
46
- broke rather than one it has not authenticated for — so OAuth discovery never
47
- began. Such a call now gets `401` with a `WWW-Authenticate: Bearer` challenge
48
- naming the resource metadata, and `/.well-known/oauth-protected-resource` is
49
- served alongside the MCP endpoint.
50
-
51
- The endpoint is not gated as a whole. `mcpTargetRequiresSession` reads the
52
- declarations the runner already enforces — a `pikkuFunc` needs a session, a
53
- `pikkuSessionlessFunc` needs one only where it says `auth: true` — so public
54
- and private tools can share one server and only the private ones are
55
- challenged.
56
-
57
- `createFetchHandler` and `createHTTPRequestHandler` take an optional `auth`
58
- describing what to advertise (`authorizationServers`, `scopesSupported`,
59
- `resourceName`), surfaced on both servers as an `mcpAuth` option. Every field
60
- defaults from the request, because a pikku app is usually its own
61
- authorization server. Both handlers now also return `ownsPath`, because the
62
- discovery document lives outside `mcpPath` and a host routing on the endpoint
63
- alone would 404 the document its own challenge points at.
64
-
65
- - Updated dependencies [c842054]
66
- - Updated dependencies [dfd7019]
67
- - Updated dependencies [dfd7019]
68
- - Updated dependencies [dfd7019]
69
- - Updated dependencies [dfd7019]
70
- - Updated dependencies [9b978e7]
71
- - Updated dependencies [1469e73]
72
- - @pikku/core@0.12.113
73
- - @pikku/modelcontextprotocol@0.12.12
74
-
75
- ## 0.12.11
76
-
77
- ### Patch Changes
78
-
79
- - 3d75643: Run the app's server lifecycle in generated entries, and make an out-of-band
80
- account signable-in.
81
-
82
- `pikkuServerLifecycle` was only ever called by `pikku dev` and `pikku serve`, so
83
- an app that seeds its first admin account, probes a dependency, or warms a cache
84
- in `beforeStart` did all of that in development and silently skipped it
85
- everywhere it was actually deployed. The standalone entry and the shared node
86
- server entry — the one behind every `target: 'server'` unit — now import the
87
- app's lifecycle and call it: `beforeStart` after `init` and before the port
88
- opens, so work that must finish before the first request has, `afterStart` once
89
- the server is listening, and the stop hooks handed to the signal handler that
90
- already owns shutdown rather than a second listener racing it. Each shutdown
91
- step is isolated from the ones after it, so a hook that throws is logged without
92
- taking the service teardown and the socket close down with it.
93
-
94
- Separately, `createAuthUser` and `setAuthUserPassword` wrote credential accounts
95
- with no `issuer`. From better-auth 1.7 a credential account is matched by its
96
- issuer as well as its provider, so those accounts were invisible to sign-in,
97
- `updatePassword` and `findCredentialAccount` — a user who plainly existed in the
98
- table was reported as "user not found". The field is written only when the
99
- resolved schema has it, so older better-auth keeps working, and
100
- `setAuthUserPassword` repairs an account that predates the fix.
101
-
102
- ## 0.12.10
103
-
104
- ### Patch Changes
105
-
106
- - 80eb5c0: Generate a desktop shell from `pikku deploy apply --desktop`
107
-
108
- `pikku deploy apply --provider standalone --runtime bun --desktop` now emits a
109
- `src-tauri/` crate that ships the compiled binary as a sidecar and opens a
110
- window on the server's own HTTP origin, so cookies, CORS and OAuth behave
111
- exactly as they do in a browser. Regeneration is idempotent and leaves an
112
- edited file alone rather than overwriting it.
113
-
114
- `--desktop-url https://app.example.com` builds the other shape: a shell that
115
- points at an already-deployed server. Nothing is bundled — no sidecar, no
116
- binary, and so no bun runtime to compile one — and the window is declared in
117
- `tauri.conf.json` rather than opened from Rust, because the origin is known up
118
- front. The url can also live in `pikku.config.json` as `deploy.desktop.url`,
119
- alongside `deploy.desktop.identifier`.
120
-
121
- Supporting changes: `SERVER_READY_MARKER` moved to `@pikku/deploy` (the CLI
122
- re-exports it from its old path), both HTTP runtimes expose the port they
123
- actually bound so `--port 0` reports a real port, and the generated server
124
- entry exits when its parent process goes away.
125
-
126
- - 80eb5c0: feat: serve a built frontend from the pikku server's own origin
127
-
128
- A new `frontend` key in `pikku.config.json` names a directory of built
129
- frontend output. `pikku serve` mounts it, and `pikku deploy` ships it inside
130
- the distributable — into a directory beside the bundle for the node runtime,
131
- and embedded in the binary for a `bun build --compile` standalone. `pikku dev`
132
- deliberately ignores it and says so, because the frontend's own dev server owns
133
- that job.
134
-
135
- Pikku reads the frontend's output and never builds it, so an unbuilt directory
136
- fails with a message that says which build to run rather than booting a server
137
- that answers every page with a 404.
138
-
139
- - Updated dependencies [80eb5c0]
140
- - Updated dependencies [2252016]
141
- - @pikku/core@0.12.98
142
-
143
- ## 0.12.9
144
-
145
- ### Patch Changes
146
-
147
- - 6ff72d3: Raise the supported Bun version to 1.4.
148
-
149
- `@pikku/bun-server` and `@pikku/kysely-bun-sqlite` now declare `engines.bun: >=1.4.0`
150
- and build against `@types/bun@^1.4.0`. `create-pikku` scaffolds
151
- `"packageManager": "bun@1.4.0"`, and the fabric `smoke`/`validate` commands default to
152
- and recommend the same version. CI pins `oven-sh/setup-bun` to 1.4.0 instead of
153
- tracking `latest`.
154
-
155
- ## 0.12.8
156
-
157
- ### Patch Changes
158
-
159
- - 266e3bc: One door per name: `@pikku/core/ecosystem/*` and the package root are gone
160
-
161
- `@pikku/core` published every module twice. `ecosystem/http` re-exported
162
- `./http`, `ecosystem/services` re-exported `./services`, and a name was
163
- reachable through either — so every addition had to be made in two places, and a
164
- consumer's import said nothing about what it actually used. The package root was
165
- the same problem at a larger scale: a single barrel of 206 names that no bundler
166
- could take apart, and the one specifier that revealed nothing at all.
167
-
168
- Both are deleted. Every name now lives on the subpath that owns it, and every
169
- import carries that subpath — `@pikku/core/http`, `@pikku/core/services`,
170
- `@pikku/core/errors`, `@pikku/core/types`.
171
-
172
- Deleting the facades meant the raw subpaths had to become a superset of them,
173
- which they were not: the facade tree had accumulated 25 names with no raw home
174
- and about 26 more filed under a different area than the module they came from.
175
- Those names moved to the area that owns them, and three areas were published as
176
- new entry points rather than left on a root that is going away — `./types` (the
177
- shared type surface, the largest single destination), `./state` and
178
- `./classification`.
179
-
180
- `./classification` is one door onto one subject: what a value is and how it must
181
- be handled. Its three halves would each have been an entry point — the brands
182
- and manifest types, the stored-form helpers (`hashToken`, `unsafeAsSealed` and
183
- friends), and `SecretValue` — split by whether a name happens to be a type or a
184
- value, which is the same defect as the facades. The duration and versioned-id
185
- helpers went to `./utils`, which already published, and `PikkuRequest` went to
186
- `./function`: it is the transport-agnostic request base, not an HTTP one — HTTP
187
- has `PikkuHTTPAbstractRequest`, and the only thing outside core that extends
188
- `PikkuRequest` is Azure's timer request.
189
-
190
- `./types` inherited the root barrel's habit before it inherited its contents, so
191
- the names with an owner elsewhere were moved off it. The middleware types and the
192
- five middleware factories — `pikkuMiddleware`, `pikkuMiddlewareFactory`,
193
- `pikkuChannelMiddleware`, `pikkuChannelMiddlewareFactory` and
194
- `pikkuAgentMiddleware`, runtime values on a types entry point — are now
195
- `@pikku/core/middleware`; the function meta types are `@pikku/core/function`;
196
- `SerializedError` is `@pikku/core/errors`; and the generic TypeScript helpers
197
- (`MakeRequired`, `PickRequired`, `PickOptional`, `RequireAtLeastOne`,
198
- `JSONPrimitive`, `JSONValue`) are `@pikku/core/utils`. What is left on `./types`
199
- is the vocabulary the wirings share, which no single module owns.
200
-
201
- `pikku` was itself a root barrel — `export * from '@pikku/core'` — and
202
- now exports only the services it bundles.
203
-
204
- One module survives at the old specifier, and only for the bootstrap:
205
- `packages/cli` is generated by the _published_ CLI pinned in its `build.sh`, and
206
- that CLI still writes a bare `@pikku/core` into the files it generates for the
207
- CLI itself. `bootstrap-compat/root.ts` carries the eight types it names, a test
208
- in core fails if that list grows, and it goes when the pin moves to a CLI
209
- released from this branch. The adapter names the pinned CLI reaches for —
210
- `pikkuState` and `CreateWireServices` — are rewritten to `@pikku/core/state` and
211
- `@pikku/core/types` by the same `build.sh` patch pass, so no second shim is
212
- needed for them.
213
-
214
- A guard test keeps the root shut: it parses imports and rejects a bare
215
- `@pikku/core` rather than grepping for it, because several tests hold a user's
216
- file as a template literal, where `import … from '@pikku/core'` is fixture text
217
- rather than an import this repo makes.
218
-
219
- An agent scaffold a project generated under an older CLI is refreshed rather
220
- than left to fail: `pikku all` already deleted one importing an entry point
221
- `@pikku/core` no longer publishes, and the `#pikku` hub joins that list.
222
- Without it a project that scaffolds the agent endpoint but
223
- declares no agents keeps the old file forever — the generator that would rewrite
224
- it only runs when agents exist, and the file being present is what stops it
225
- being regenerated as missing.
226
-
227
- `pikku new addon` also wrote a tsconfig `paths` map naming only the deleted hub.
228
- An addon's `imports` map points into `dist`, so `paths` is what resolves
229
- `#pikku/<leaf>` for the addon's own source build — it now names the two leaf
230
- patterns, in both the addon and its test harness.
231
-
232
- - Updated dependencies [7722ceb]
233
- - Updated dependencies [375c1ff]
234
- - Updated dependencies [02a70cd]
235
- - Updated dependencies [aeef159]
236
- - Updated dependencies [a281de6]
237
- - Updated dependencies [266e3bc]
238
- - Updated dependencies [02a70cd]
239
- - Updated dependencies [786dae5]
240
- - Updated dependencies [6eef0a0]
241
- - Updated dependencies [3561d67]
242
- - Updated dependencies [a91c433]
243
- - Updated dependencies [02a70cd]
244
- - Updated dependencies [9537f74]
245
- - Updated dependencies [2b57ca8]
246
- - Updated dependencies [266e3bc]
247
- - Updated dependencies [9fce0f1]
248
- - Updated dependencies [83683a0]
249
- - Updated dependencies [456c88b]
250
- - Updated dependencies [456c88b]
251
- - Updated dependencies [c127273]
252
- - @pikku/core@0.12.85
253
- - @pikku/modelcontextprotocol@0.12.10
254
-
255
- ## 0.12.7
256
-
257
- ### Patch Changes
258
-
259
- - 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.
260
-
261
- 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.
262
-
263
- 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.
264
-
265
- - Updated dependencies [7406bfe]
266
- - Updated dependencies [6794681]
267
- - @pikku/core@0.12.84
268
- - @pikku/modelcontextprotocol@0.12.9
269
-
270
- ## 0.12.6
271
-
272
- ### Patch Changes
273
-
274
- - fd9d834: Stop publishing internals that only their own package or file used. The declarations stay; only the entrypoint re-export is removed, so nothing that imported a name from where it is declared is affected.
275
- - Updated dependencies [063f43a]
276
- - Updated dependencies [ce66bf8]
277
- - Updated dependencies [d0307a8]
278
- - Updated dependencies [ce66bf8]
279
- - Updated dependencies [ce66bf8]
280
- - Updated dependencies [3ad2131]
281
- - Updated dependencies [b930dca]
282
- - Updated dependencies [b95e77d]
283
- - Updated dependencies [fd9d834]
284
- - Updated dependencies [8978fbd]
285
- - @pikku/core@0.12.82
286
- - @pikku/modelcontextprotocol@0.12.8
287
-
288
- ## 0.12.5
289
-
290
- ### Patch Changes
291
-
292
- - ea8aabf: Serve `LocalContent` uploads and signed reads under Bun.
293
-
294
- `LocalContent` hands the browser a `PUT <uploadUrlPrefix>/<key>` upload URL and a signed
295
- `GET <assetUrlPrefix>/<key>` read URL, but it is a `ContentService` and cannot answer
296
- either — something in the serving path has to. Only `@pikku/node-http-server` did. The
297
- same project served under Bun handed out upload URLs that 404ed, with nothing naming the
298
- cause: the config was accepted, the service was constructed, and the URLs looked right.
299
-
300
- `@pikku/core` now exports `createLocalContentRequestHandler` from
301
- `@pikku/core/services/local-content-request-handler` — the server half of `LocalContent`,
302
- expressed in Web `Request`/`Response` so every runtime shares one implementation of the
303
- signature check rather than each re-deriving it. It returns `null` for anything that is
304
- not a content request, which is the caller's signal to carry on with its normal routing.
305
-
306
- `PikkuBunServer` accepts `config.content` and a `contentSigningJWT` option, mirroring
307
- `PikkuNodeHTTPServer`, and answers both prefixes ahead of static mounts and routing.
308
- `BunServerRunner` was dropping `contentSigningJWT` on the floor, which silently disabled
309
- signed asset reads for every Bun project even once the prefixes were served — the config
310
- arrived, the service that verifies its signatures did not.
311
-
312
- Signed reads are refused unless every claim matches, the path included: without that, a
313
- signature minted for one asset would read any other.
314
-
315
- - Updated dependencies [32277d5]
316
- - Updated dependencies [ea8aabf]
317
- - Updated dependencies [33e96ab]
318
- - Updated dependencies [fd72e58]
319
- - Updated dependencies [fd72e58]
320
- - Updated dependencies [fd72e58]
321
- - Updated dependencies [894b2f8]
322
- - Updated dependencies [dd19aa7]
323
- - Updated dependencies [50ec500]
324
- - @pikku/core@0.12.75
325
-
326
- ## 0.12.4
327
-
328
- ### Patch Changes
329
-
330
- - d4a2503: Serve the console same-origin at /console (#861). Both dev servers gain
331
- `staticMounts` (prefix → directory static serving with SPA fallback and path
332
- traversal protection); `pikku serve` / `pikku dev` mount the bundled console
333
- app at `/console` on the API port whenever it is bundled, so auth cookies are
334
- first-party and no `?server=` param is needed. The console is built with
335
- `base: '/console/'` (its router already derives the basename from BASE_URL).
336
- The separate `--console <port>` static server is removed; `pikku console`
337
- serves the bundle under /console and redirects the root there.
338
- - Updated dependencies [61c9ce9]
339
- - Updated dependencies [f1f39f8]
340
- - Updated dependencies [c45e98d]
341
- - Updated dependencies [472a349]
342
- - @pikku/core@0.12.52
343
-
344
- ## 0.12.3
345
-
346
- ### Patch Changes
347
-
348
- - 6f6abfe: Mount MCP on the bun runtime. `@pikku/bun-server` now accepts `mcpJson`/`mcpPath`
349
- options and serves the MCP endpoint (default `/mcp`) via a new fetch-native
350
- handler on `PikkuMCPServer.createFetchHandler()`, which uses the MCP SDK's
351
- Web-Standard (`Request`→`Response`) streamable-HTTP transport — no `node:http`
352
- req/res. The standalone `--runtime bun` entry now wires the same `mcpImport` +
353
- `mcpJson` option the node entry already used, so a bun standalone build serves
354
- `/mcp` with the project's tools/resources/prompts instead of silently dropping
355
- them. `@pikku/modelcontextprotocol` is an optional peer dep of `@pikku/bun-server`
356
- (only imported when `mcpJson` is non-empty).
357
- - Updated dependencies [6f6abfe]
358
- - @pikku/modelcontextprotocol@0.12.6
359
-
360
- ## 0.12.2
361
-
362
- ### Patch Changes
363
-
364
- - 41ce2cb: Upgrade to TypeScript 6 and raise the minimum Node.js version to 22.
365
-
366
- 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.
367
-
368
- - Updated dependencies [41ce2cb]
369
- - @pikku/core@0.12.44
370
-
371
- ## 0.12.1
372
-
373
- ### Patch Changes
374
-
375
- - d5c3c85: feat: bun first-class support — new `@pikku/bun-server` runtime and `@pikku/kysely-bun-sqlite` dialect, bun template, CI matrix with `package-manager: [yarn, bun]`, and bun verifier.
376
- - e443e94: feat(deploy): standalone provider can target the bun runtime
377
-
378
- `pikku deploy plan|apply --provider standalone --runtime bun` now generates a
379
- `@pikku/bun-server` entry (native `Bun.serve` WebSockets, no `ws` package) and
380
- compiles the bundle into a single self-contained executable via
381
- `bun build --compile` — no runtime needed on the target host. The default
382
- remains `--runtime node`, which is unchanged (ships `bundle.js`, run with
383
- `node bundle.js`).
384
-
385
- `PikkuBunServer` now accepts an injectable `eventHub` in its options. Inject the
386
- same `BunEventHubService` you pass to `createSingletonServices` so functions and
387
- the WebSocket transport share one hub — otherwise a function's
388
- `eventHub.publish(...)` targets a different hub than the one holding the live
389
- sockets and broadcasts never reach connected clients. The standalone bun entry
390
- and the `bun` template now wire this shared hub, fixing cross-connection /
391
- cross-transport channel pub-sub on bun.
392
-
393
- Also removes the unused `@yao-pkg/pkg` dependency and its stale type shim from
394
- `@pikku/deploy-standalone` (the pkg-based binary path was dropped in #489).
395
-
396
- - Updated dependencies [92cd5b1]
397
- - @pikku/core@0.12.38
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[@]}"