test(bgm): cover emitted shape and multi-package collection

Add a SerializedPackage type for the JSON the plugin emits, and tests
that assert the maps serialize to plain objects, that the packages module
returns every package, and that buildStart watches def files. Add a
second fixture package to exercise multi-package collection.
This commit is contained in:
2026-08-09 19:23:50 +08:00
parent 845d510948
commit 7f3f758c52
7 changed files with 120 additions and 14 deletions
@@ -0,0 +1,52 @@
# Azul
A second tiny example game, used to exercise the loader's collection of
multiple packages.
```yaml file=azul.yaml
role: package
id: azul
title: Azul
designer: Michael Kiesling
players: 4
language: en
include: ['**/azul/**/*.yaml']
```
```yaml file=parts/tiles.yaml
role: part
type: tile
id: blue
face: ./assets/tiles.png
faceCrop: [0, 0, 5, 5]
size: [20, 20, 3]
fillet: 1
```
```yaml file=parts/board.yaml
type: board
id: azul
role: surface
size: [400, 300]
layout:
- route: /factory/:n
candidates:
$variants: ./factories.csv
```
```csv file=parts/factories.csv
n,x,y,rotation
string,number,number,number
0,-150,0,0
1,-50,0,0
2,50,0,0
3,150,0,0
```
```yaml file=setup/main.yaml
role: setup
type: game
id: main
setup:
/factory/0: azul:tile#blue
```
@@ -10,6 +10,7 @@ title: Harbor
designer: Jane Doe
players: 2
language: en
include: ['**/harbor/**/*.yaml']
```
```yaml file=parts/tokens.yaml
@@ -1,11 +1,13 @@
import harbor from 'virtual:bgm/package/harbor';
import azul from 'virtual:bgm/package/azul';
import packages from 'virtual:bgm/packages';
// Re-export the package data so the test can assert the bundled output.
export const parts = [...harbor.parts.keys()];
export const surfaces = [...harbor.surfaces.keys()];
export const setups = [...harbor.setups.keys()];
export const parts = Object.keys(harbor.parts);
export const surfaces = Object.keys(harbor.surfaces);
export const setups = Object.keys(harbor.setups);
export const title = harbor.meta.title;
export const azulTitle = azul.meta.title;
export const allIds = packages.map((p) => p.meta.id);
console.log(title, parts, surfaces, setups, allIds);
console.log(title, parts, surfaces, setups, allIds, azulTitle);