@seriousgaming/sdk-tools 1.9.0 → 1.11.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.
- package/dist/agent/guidance.md +31 -23
- package/dist/{cli-KJV3GGBA.js → cli-226ZJ72R.js} +1 -1
- package/dist/{cli-VRGVHSXH.js → cli-25SJZI7N.js} +44 -9
- package/dist/{cli-YI3WZF3C.js → cli-27TQVLVF.js} +11 -11
- package/dist/cli-27Z5T52R.js +30 -0
- package/dist/cli-3VLBFWHN.js +36 -0
- package/dist/{cli-DXHPYN4N.js → cli-44CM2AH2.js} +1 -1
- package/dist/{cli-2PMLR6WG.js → cli-4F24FUW6.js} +15 -15
- package/dist/{cli-6GDPO5VU.js → cli-4FJL3KQZ.js} +2 -2
- package/dist/{cli-2BF7KBBJ.js → cli-5ATO27Z4.js} +15 -15
- package/dist/{cli-AA5GMEUL.js → cli-5EH4WTH4.js} +4 -4
- package/dist/{cli-MPWTXNF6.js → cli-5M6KDNVX.js} +2 -2
- package/dist/{cli-J2OTL6JH.js → cli-5O7XENQY.js} +5 -5
- package/dist/{cli-XA4IL7IM.js → cli-5RRPUL6V.js} +11 -11
- package/dist/{cli-JEMWAIAA.js → cli-5TTJWM2R.js} +15 -15
- package/dist/{cli-S3YIYAXC.js → cli-5UKWX3IU.js} +12 -12
- package/dist/{cli-AEAFLZGY.js → cli-5VZBFMCK.js} +5 -1
- package/dist/{cli-AGYCXRPR.js → cli-5Z4D3F6Y.js} +3 -3
- package/dist/{cli-ZHFHOWJI.js → cli-6AMK3DYS.js} +11 -11
- package/dist/{cli-G7JTIP5G.js → cli-6BLVI2JM.js} +11 -7
- package/dist/{cli-SBKTGFY4.js → cli-6JWDFCUV.js} +17 -17
- package/dist/{cli-7OCEVQQN.js → cli-6O7YCK2M.js} +2 -2
- package/dist/{cli-GZE4V7RC.js → cli-6P6V2EHY.js} +19 -19
- package/dist/{cli-KD2RQS35.js → cli-77T4LJQF.js} +22 -19
- package/dist/{cli-IC5FOT2J.js → cli-7JUNA74L.js} +1 -1
- package/dist/{cli-2FXZZLCL.js → cli-AH6AMAIB.js} +1 -1
- package/dist/{cli-NTI22MRE.js → cli-ATAJSIXH.js} +16 -16
- package/dist/{cli-OOTGO3KW.js → cli-ATHATKI5.js} +49 -49
- package/dist/{cli-QWO3XJR3.js → cli-ATWJCB2G.js} +4 -4
- package/dist/{cli-QIHVXDMW.js → cli-B2QAJ5RQ.js} +15 -15
- package/dist/{cli-MN7X4UG2.js → cli-B3EFE7ZF.js} +1 -1
- package/dist/{cli-HJPNNORV.js → cli-BC67QHD5.js} +2 -2
- package/dist/cli-BINVO5R7.js +36 -0
- package/dist/{cli-PJO4BKSV.js → cli-BJFYGVJV.js} +16 -16
- package/dist/{cli-C45A5VX6.js → cli-BQ36DV5C.js} +3 -3
- package/dist/{cli-IJPRZSJ5.js → cli-BZOKZ7LP.js} +24 -22
- package/dist/{cli-GHIMH6JU.js → cli-C32Q5E5I.js} +1 -1
- package/dist/{cli-35K37SYY.js → cli-D3S7NJZ3.js} +14 -14
- package/dist/{cli-KGJHEDR2.js → cli-DBMEH4Y5.js} +23 -21
- package/dist/{cli-A7PITFRR.js → cli-DH35TZ2Q.js} +5 -3
- package/dist/{cli-A3P3PO6Z.js → cli-DQE7ITIR.js} +15 -15
- package/dist/{cli-BV7MX7JE.js → cli-EEO5ZPAZ.js} +3 -3
- package/dist/{cli-3RMP4HKZ.js → cli-ERJNDBDH.js} +2 -2
- package/dist/{cli-2JEICVMA.js → cli-F3YJKP6D.js} +3 -3
- package/dist/{cli-2VV5IPSY.js → cli-FT3X3D4P.js} +15 -15
- package/dist/{cli-LZFUSEJT.js → cli-FYPW25VD.js} +13 -13
- package/dist/{cli-CVOLMK3Z.js → cli-G2GLW5Z4.js} +1 -1
- package/dist/{cli-BYXNPBVG.js → cli-G3TU6CP6.js} +15 -15
- package/dist/{cli-4L7S27XO.js → cli-GO64NABP.js} +1 -1
- package/dist/{cli-XRVH5WV6.js → cli-GSOV26O5.js} +13 -13
- package/dist/{cli-2UOUIVHW.js → cli-H6PP2MZT.js} +24 -12
- package/dist/{cli-6Y4XIVQS.js → cli-HGCOEL5T.js} +3 -3
- package/dist/cli-HLI5UEKX.js +36 -0
- package/dist/{cli-B5LZEFLU.js → cli-HMDYG6PS.js} +15 -15
- package/dist/{cli-7CW2BBJG.js → cli-HNDFANQG.js} +1 -1
- package/dist/{cli-MSSJLABW.js → cli-IKSLPAZN.js} +3 -3
- package/dist/{cli-AJ5CABGJ.js → cli-JHLWBRXB.js} +15 -15
- package/dist/{cli-5PTCQTS6.js → cli-JXQLHJO2.js} +1 -1
- package/dist/{cli-H7T6E7OA.js → cli-K4HSQWXC.js} +2 -2
- package/dist/{cli-WJO75KP7.js → cli-KIZTASLL.js} +3 -3
- package/dist/{cli-MX7GFQ6N.js → cli-KJA6GLZI.js} +14 -14
- package/dist/{cli-KINJAQTJ.js → cli-L7F4XKCB.js} +19 -19
- package/dist/{cli-BC4KKNLA.js → cli-LHMRUJVN.js} +4 -2
- package/dist/{cli-CQUSM3SF.js → cli-LPFSJ625.js} +19 -19
- package/dist/{cli-BNN36WZJ.js → cli-MDVC5ZNM.js} +13 -13
- package/dist/{cli-TLRTLTGK.js → cli-MSNSXVGF.js} +18 -18
- package/dist/{cli-5BPQ73OM.js → cli-NKKCDO6K.js} +15 -15
- package/dist/{cli-L5ZKQNMI.js → cli-OBLEROSC.js} +15 -15
- package/dist/cli-OF36EA62.js +36 -0
- package/dist/{cli-MZM4MW7C.js → cli-OM32UURE.js} +19 -19
- package/dist/{cli-J75EBRAJ.js → cli-OMTHTWYJ.js} +17 -17
- package/dist/{cli-K6M6YB67.js → cli-OTBCA54D.js} +1 -1
- package/dist/cli-OVIJRBFI.js +36 -0
- package/dist/{cli-IVZ7AHUJ.js → cli-OXLOGXT3.js} +3 -3
- package/dist/{cli-NU4SCD5D.js → cli-P3NUTOPK.js} +1 -1
- package/dist/{cli-D6AC3ZCX.js → cli-PNS4KWWC.js} +22 -19
- package/dist/{cli-7N7WFRWA.js → cli-PXQYY6KM.js} +0 -0
- package/dist/{cli-MTAGL3QE.js → cli-Q7QSWNY2.js} +15 -15
- package/dist/{cli-7V6GUIIS.js → cli-QDBYFITU.js} +2 -2
- package/dist/{cli-QK2OD24J.js → cli-QEFYDXMH.js} +9 -2
- package/dist/{cli-MYBDWJP7.js → cli-QPV3TYOM.js} +20 -20
- package/dist/{cli-W4BHSBAX.js → cli-QTCTWYCM.js} +3 -3
- package/dist/{cli-HCMVZXWK.js → cli-R5SNTPND.js} +17 -17
- package/dist/{cli-RHYQYXE2.js → cli-REAM7LSC.js} +18 -18
- package/dist/{cli-GHQIATHP.js → cli-RHL4B4H7.js} +6 -5
- package/dist/{cli-RL5EBZL7.js → cli-RKPQLB7J.js} +3 -3
- package/dist/{cli-E77R7ZYB.js → cli-RMD5WSUQ.js} +15 -15
- package/dist/{cli-OX3254NS.js → cli-S3NHXAJM.js} +17 -17
- package/dist/{cli-6COAU7JR.js → cli-SRXDLMXY.js} +17 -17
- package/dist/{cli-DMKRP33X.js → cli-TCQJL2GY.js} +1 -1
- package/dist/{cli-KO26S2CL.js → cli-TEBV2OIW.js} +31 -14
- package/dist/{cli-USBJQAYI.js → cli-TI2FOFPA.js} +13 -13
- package/dist/{cli-7RLZIWFP.js → cli-TLSTSZAC.js} +19 -19
- package/dist/{cli-2CSI2UU2.js → cli-UEQMK4WX.js} +1 -1
- package/dist/cli-UIYKPSIY.js +36 -0
- package/dist/{cli-2I6UN6C3.js → cli-UQC46YSV.js} +3 -3
- package/dist/{cli-BF6L37O3.js → cli-UULZSQBV.js} +3 -3
- package/dist/{cli-OK6XWVIN.js → cli-UVIURDZC.js} +17 -17
- package/dist/{cli-6KL5B7EC.js → cli-VXLHOZSO.js} +15 -15
- package/dist/{cli-UR63LFVK.js → cli-W3RG2MRI.js} +2 -2
- package/dist/{cli-G54355N5.js → cli-WJVPSVF2.js} +22 -19
- package/dist/{cli-YD4SBAHQ.js → cli-WNBP3LOD.js} +19 -19
- package/dist/{cli-DJCQ5XFR.js → cli-WNHMJM3Z.js} +15 -15
- package/dist/{cli-CL3KF5KS.js → cli-WQ7JBZNW.js} +2 -2
- package/dist/{cli-VTLFQHDO.js → cli-WW54THXN.js} +1 -1
- package/dist/cli-WZNIW6ZO.js +16 -0
- package/dist/{cli-BT47H36C.js → cli-X3TSTTYI.js} +2 -2
- package/dist/{cli-ICLCA6VD.js → cli-X52TXCNF.js} +19 -19
- package/dist/{cli-ZZSPFLTK.js → cli-X64BNBQH.js} +26 -4
- package/dist/{cli-CKV44U7P.js → cli-XJ7JESC2.js} +19 -19
- package/dist/{cli-EDZF5Q2E.js → cli-XKAIDYIE.js} +14 -14
- package/dist/{cli-CPX4YA3P.js → cli-XNOAO6DY.js} +11 -11
- package/dist/{cli-R6YAZP6E.js → cli-XOYUTNER.js} +19 -19
- package/dist/{cli-3VV2JLHX.js → cli-XW3JLRSA.js} +1 -1
- package/dist/{cli-S7PLSPGE.js → cli-YYXAGJQR.js} +15 -15
- package/dist/{cli-LFUKHLHI.js → cli-ZGCG6C22.js} +17 -17
- package/dist/{cli-QRAYIXNE.js → cli-ZJW6HQ6N.js} +5 -5
- package/dist/{cli-Y33ULHYO.js → cli-ZNQBF4Z3.js} +1 -1
- package/dist/cli.js +52 -52
- package/dist/client/index.d.ts +1 -1
- package/dist/client/test-session.d.ts +44 -6
- package/dist/client.js +100 -12
- package/dist/dev/console/assets/{index-CVNjiRUh.js → index-Ch6HHb2T.js} +1 -1
- package/dist/dev/console/index.html +1 -1
- package/dist/dev/surfaces.d.ts +8 -2
- package/dist/docs/api/index.md +3 -1
- package/dist/docs/api/sdk-tools-client.md +38 -6
- package/dist/docs/api/sdk-tools-vite.md +21 -0
- package/dist/docs/api/sdk.md +2 -0
- package/dist/docs/changelog.md +49 -0
- package/dist/docs/cli-error-codes.md +41 -39
- package/dist/docs/cli-reference.md +2 -1
- package/dist/docs/guides/endpoints.md +1 -1
- package/dist/docs/guides/engine-testing.md +49 -14
- package/dist/docs/guides/engine.md +2 -2
- package/dist/docs/guides/scenario-editor.md +1 -1
- package/dist/docs/guides/setup.md +22 -5
- package/dist/docs/guides/testing.md +3 -8
- package/dist/docs/guides/upgrading.md +15 -0
- package/dist/docs/page-index.md +6 -5
- package/dist/docs/recipes/create-game.md +1 -1
- package/dist/docs/recipes/fix-duplicate-packages.md +8 -19
- package/dist/docs/recipes/give-setup-a-menu.md +7 -1
- package/dist/docs/recipes/write-setup-notes.md +2 -2
- package/dist/host/protocol.d.ts +8 -5
- package/dist/oxlint/logic.json +184 -0
- package/dist/playwright.js +100 -12
- package/dist/runtime/manifest-version.d.ts +1 -1
- package/dist/runtime.js +1 -1
- package/dist/schema.json +20 -0
- package/dist/templates/package/README.md.liquid +1 -0
- package/dist/templates/package/claude/rules/workflow-create-engine.md +1 -1
- package/dist/templates/package/claude/rules/workflow-create-user-interface.md +1 -1
- package/dist/templates/package/claude/rules/workflow-test-engine-or-ui.md +1 -1
- package/dist/templates/package/claude/rules/workflow-update-sdk-version.md +2 -2
- package/dist/templates/package/claude/settings.json.template +1 -0
- package/dist/templates/package/oxfmtrc.json.template +8 -1
- package/dist/templates/package/oxlintrc.json.template +1 -180
- package/dist/templates/package/package.json.liquid +1 -0
- package/dist/templates/package/vite.config.ts.liquid +2 -8
- package/dist/templates/package/vitest.config.ts.liquid +2 -8
- package/dist/templates/starter-game/package.json +2 -1
- package/dist/templates/starter-game/testing/engine/game.engine.test.ts +62 -37
- package/dist/templates/starter-game/vite.config.ts +2 -8
- package/dist/templates/starter-game/vitest.config.ts +4 -3
- package/dist/utils/error-codes.d.ts +6 -2
- package/dist/utils/resource-scan.d.ts +5 -0
- package/dist/vite/index.d.ts +30 -0
- package/dist/vite.js +12 -0
- package/package.json +12 -4
- package/dist/cli-3I6AI4AA.js +0 -36
- package/dist/cli-3YGNWZC6.js +0 -30
- package/dist/cli-4X3X4HB2.js +0 -16
- package/dist/cli-6ZBQELF2.js +0 -36
- package/dist/cli-CUZUIYCQ.js +0 -36
- package/dist/cli-DNCJURUU.js +0 -36
- package/dist/cli-UKC7KXWU.js +0 -36
- package/dist/cli-WA2PDQUB.js +0 -36
package/dist/runtime.js
CHANGED
|
@@ -305,7 +305,7 @@ function readTickControllerResult(label, result) {
|
|
|
305
305
|
|
|
306
306
|
// cli/runtime/manifest-version.ts
|
|
307
307
|
var MANIFEST_VERSION = 3;
|
|
308
|
-
var SPEC_REVISION = "1.
|
|
308
|
+
var SPEC_REVISION = "1.9";
|
|
309
309
|
function isLaterSpecRevision(revision, than) {
|
|
310
310
|
const [major, minor] = revision.split(".").map(Number);
|
|
311
311
|
const [thanMajor, thanMinor] = than.split(".").map(Number);
|
package/dist/schema.json
CHANGED
|
@@ -418,6 +418,16 @@
|
|
|
418
418
|
"uniqueItems": true,
|
|
419
419
|
"default": []
|
|
420
420
|
},
|
|
421
|
+
"settings": {
|
|
422
|
+
"type": "array",
|
|
423
|
+
"description": "Identifiers of settings resources this setup user interface reads but does not edit, the built-in `game` included. It is sent their resolved values through `setSettings` beside those it configures, and a host refuses an `updateSettings` that names one. List a resource here, not in `configures`, when the screen only needs to see it, such as the list of what the scenario offers",
|
|
424
|
+
"items": {
|
|
425
|
+
"type": "string",
|
|
426
|
+
"pattern": "^[a-z][a-z0-9_]*$"
|
|
427
|
+
},
|
|
428
|
+
"uniqueItems": true,
|
|
429
|
+
"default": []
|
|
430
|
+
},
|
|
421
431
|
"endpoints": {
|
|
422
432
|
"type": "array",
|
|
423
433
|
"description": "Endpoint identifiers this setup user interface is permitted to call via `callbacks.endpoints[<identifier>]`. The host throws when this UI requests an endpoint whose identifier is not listed here.",
|
|
@@ -451,6 +461,16 @@
|
|
|
451
461
|
"uniqueItems": true,
|
|
452
462
|
"default": []
|
|
453
463
|
},
|
|
464
|
+
"settings": {
|
|
465
|
+
"type": "array",
|
|
466
|
+
"description": "Identifiers of settings resources this scenario editor reads but does not edit, the built-in `game` included. It is sent their resolved values through `setSettings` beside those it configures, and a host refuses an `updateSettings` that names one. List a resource here, not in `configures`, when the screen only needs to see it, such as the list of what the scenario offers",
|
|
467
|
+
"items": {
|
|
468
|
+
"type": "string",
|
|
469
|
+
"pattern": "^[a-z][a-z0-9_]*$"
|
|
470
|
+
},
|
|
471
|
+
"uniqueItems": true,
|
|
472
|
+
"default": []
|
|
473
|
+
},
|
|
454
474
|
"endpoints": {
|
|
455
475
|
"type": "array",
|
|
456
476
|
"description": "Endpoint identifiers this scenario editor is permitted to call via `callbacks.endpoints[<identifier>]`. The host throws when this UI requests an endpoint whose identifier is not listed here.",
|
|
@@ -91,6 +91,7 @@ pnpm run build
|
|
|
91
91
|
## Running the tests
|
|
92
92
|
|
|
93
93
|
```bash
|
|
94
|
+
pnpm check # everything below but the browser tests, after validating, typechecking and linting
|
|
94
95
|
pnpm test:run # the engine's arithmetic, and every surface
|
|
95
96
|
pnpm test:engine # the whole game, day by day, in-process
|
|
96
97
|
pnpm test:e2e # the surfaces in a browser, against a dev server of its own
|
|
@@ -18,7 +18,7 @@ The engine runs each tick. It reads from capabilities and returns the ones it wr
|
|
|
18
18
|
4. **Implement `Init` and `Run`** in `engine/logic.ts`. Both are async, both take `{ context, settings, callbacks, meta }`, and both return `{ capabilities: Context }`. Never mutate `context`: always spread. Optionally, return `state` beside `capabilities` for memory only the engine needs between ticks (it comes back as `state`; type it with `RunFunction`'s fourth parameter), and return `complete: true` from `Run` to end the game for that team. A simulation with several steps calls them as plain functions from its one `Run`: type each as `StepFunction<Context, Settings>`, pass the context along flat, and wrap only the final one.
|
|
19
19
|
5. **Check the types.** `new` and `update` regenerate `engine/types.ts`; run `pnpm run generate` yourself only after editing the bundle by hand.
|
|
20
20
|
6. **Test it.** Unit tests go in `engine/logic.test.ts`, covering at least the happy path and every branch in `Run`. Whole-game behaviour across several ticks goes in `testing/engine/` and runs with `pnpm test:engine`.
|
|
21
|
-
7. **Verify**: `pnpm
|
|
21
|
+
7. **Verify**: `pnpm check`, which validates the package, typechecks, lints and runs the unit and engine tests, stopping at the first that fails. The engine tests run the logic in the restricted production runtime, so keep one that plays a tick of every scenario. `pnpm run --silent sdk tick --no-server --summary` plays one tick by hand. A running dev server picks up the edit from its next tick, without a reset.
|
|
22
22
|
|
|
23
23
|
## Things that almost always go wrong
|
|
24
24
|
|
|
@@ -18,7 +18,7 @@ A user interface is a React app that reads game state and (optionally) sends dec
|
|
|
18
18
|
4. **Implement the components** under `ui/src/` (the entry component is `App.tsx`), with `useUserInterfaceData()` for `data`, `settings`, `setData` and `completedTicks`. Default to MUI; another library must integrate with `useUserInterfaceTheme` so dark mode and colour palettes work, and text on a theme colour uses that colour's `contrastText`. Remember a viewer's own choices with `useViewerStorage`, never `localStorage`. Put every string in `src/i18n.ts`. `pnpm run --silent sdk docs view guides/ui.md` is the reference for every hook, with the topic pages it links.
|
|
19
19
|
5. **Await every write.** `setData` returns a promise that rejects when the host refuses the write. Route writes through `useMutationReporter`, as the starter game's `ui/src/writes.ts` does, so the participant sees the refusal. Never retry a write automatically: on a `conflict` the host has already retried and given up, so offer `failure.retry` behind a 'Try again' button instead.
|
|
20
20
|
6. **Add a test** beside the component (`App.test.tsx`), rendered with `renderUserInterface()` (or `renderSessionUserInterface<SessionData>()`, `renderSettingsEditor()`) from `@seriousgaming/sdk/ui/testing`, as the starter game's tests do. `pnpm run --silent sdk docs view guides/testing.md` has the harness.
|
|
21
|
-
7. **Verify**: `pnpm
|
|
21
|
+
7. **Verify**: `pnpm check`, then `pnpm run build`. A running dev server hot-reloads the UI. The user starts the dev server (`pnpm run sdk dev`) when they want to see it; never start it yourself.
|
|
22
22
|
|
|
23
23
|
## Things that almost always go wrong
|
|
24
24
|
|
|
@@ -18,7 +18,7 @@ Unit and component tests live next to the source they cover: the engine's `engin
|
|
|
18
18
|
2. **For logic**, call `Init`, `Run`, a hook, an endpoint or a validator directly with arguments built by `logicArgs` from `@seriousgaming/sdk/testing` (`logicArgs.run({ context, settings: defaultSettings })`), and assert on the returned `capabilities`. For behaviour across several ticks, hooks, validators, endpoints, participants, undo or automatic ticks, use `createTestSession<Context, SharedContext>` in `testing/engine/`: it runs the session the dev server runs, in-process, with offline stubs for `generateText`, `generateSpeech` and `extractText`. The references are `pnpm run --silent sdk docs view guides/testing.md` and `guides/engine-testing.md`.
|
|
19
19
|
3. **For UI components**, render with `renderUserInterface()` (or `renderSessionUserInterface()`, or `renderSettingsEditor()` for setup and the scenario editor) from `@seriousgaming/sdk/ui/testing`, which supplies every provider the host does. Never `vi.mock` the SDK contexts, and never wire the providers by hand. For a session UI, pass the generated types: `renderSessionUserInterface<SessionData>()`, with fixtures from `createMockTeamState<TeamContext>()` and `createMockSharedState<SharedContext>()`, so a shared capability left on a team fixture fails to compile.
|
|
20
20
|
4. **Cover the branches.** One test per code path: the happy path plus each failure mode, each option flag, each conditional in `Run`.
|
|
21
|
-
5. **Run the tests**: `pnpm test:run` and `pnpm test:engine
|
|
21
|
+
5. **Run the tests**: `pnpm test:run` and `pnpm test:engine`, or `pnpm check` for both after validating, typechecking and linting. `pnpm test` is watch mode, so leave it to the user. `pnpm test:e2e` starts an isolated dev server for each Playwright worker on free ports, beside any the user has running, and serves them surfaces built once by `testing/e2e/global-setup.ts`. Import `test` from `@seriousgaming/sdk-tools/playwright` in a spec, not from `@playwright/test`.
|
|
22
22
|
|
|
23
23
|
## Things that almost always go wrong
|
|
24
24
|
|
|
@@ -26,9 +26,9 @@ The SDK ships as three npm packages: `@seriousgaming/sdk` (runtime), `@seriousga
|
|
|
26
26
|
The package also lists `@seriousgaming/sdk` under `peerDependencies`; move that range to match.
|
|
27
27
|
4. **Regenerate types**: `pnpm run generate`. New schema fields, renames, or removed fields all surface through the generated `types.ts` files.
|
|
28
28
|
5. **Build and address breakages**: `pnpm run build`. Work through type errors and address each Breaking Changes entry from step 2.
|
|
29
|
-
6. **Run the
|
|
29
|
+
6. **Run the checks**: `pnpm check`, or `pnpm test:run` and `pnpm test:engine` in a package that has no `check` script yet.
|
|
30
30
|
7. **Adopt updated scaffold guidance**. The SDK's own guidance ships in `node_modules/@seriousgaming/sdk-tools/dist/agent/guidance.md`, and `CLAUDE.md` imports it with its first line, so it updates with the version you just installed and needs no merging. The `.claude/rules/` files are copied into the package, so it keeps whatever it was scaffolded with. The new version ships its templates inside the installed package, so both sides of the diff are on disk. Check three places and fold in anything relevant:
|
|
31
|
-
1. The
|
|
31
|
+
1. The **Scaffold changes** section of every release between the old and new version (from step 2; releases from 1.11 carry one whenever a scaffolded file, a shipped rule or the guidance changed). Each line names a file, says what changed and why, and ends with `Adopt:` and whether to. Work through them in order, oldest release first, applying each `Adopt: yes` to the local file and weighing each `Adopt: optional`. For a release before 1.11, read its entries for anything mentioning scaffold, guidance, rules, or `CLAUDE.md`.
|
|
32
32
|
2. The shipped rules in `node_modules/@seriousgaming/sdk-tools/dist/templates/package/claude/rules/` against the local `.claude/rules/`: copy rule files that don't exist locally; for rules that do exist, diff the two and incorporate new guidance while keeping local edits.
|
|
33
33
|
3. The first line of the local `CLAUDE.md`. If it is not `@node_modules/@seriousgaming/sdk-tools/dist/agent/guidance.md`, the package predates the import: replace the SDK's text in `CLAUDE.md` (everything copied from the old template) with the first three lines of `node_modules/@seriousgaming/sdk-tools/dist/templates/package/CLAUDE.md.template`, and keep what the package wrote about itself below them. There is no command that refreshes it.
|
|
34
34
|
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "./node_modules/oxfmt/configuration_schema.json",
|
|
3
|
-
"ignorePatterns": [
|
|
3
|
+
"ignorePatterns": [
|
|
4
|
+
"**/*.sdk.json",
|
|
5
|
+
"seriousgaming.sdk.json",
|
|
6
|
+
"**/types.ts",
|
|
7
|
+
"lib/",
|
|
8
|
+
"test-results/",
|
|
9
|
+
"playwright-report/"
|
|
10
|
+
],
|
|
4
11
|
"semi": true,
|
|
5
12
|
"trailingComma": "es5",
|
|
6
13
|
"singleQuote": true,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
3
|
+
"extends": ["./node_modules/@seriousgaming/sdk-tools/dist/oxlint/logic.json"],
|
|
3
4
|
"plugins": null,
|
|
4
5
|
"categories": {},
|
|
5
6
|
"rules": {
|
|
@@ -41,186 +42,6 @@
|
|
|
41
42
|
"globals": {},
|
|
42
43
|
"ignorePatterns": ["**/types.ts"],
|
|
43
44
|
"overrides": [
|
|
44
|
-
{
|
|
45
|
-
"files": [
|
|
46
|
-
"engine/**/*.ts",
|
|
47
|
-
"tick_controller/**/*.ts",
|
|
48
|
-
"**/hooks/*/logic/**/*.ts",
|
|
49
|
-
"**/validators/*/logic/**/*.ts",
|
|
50
|
-
"**/endpoints/*/logic/**/*.ts"
|
|
51
|
-
],
|
|
52
|
-
"rules": {
|
|
53
|
-
"no-restricted-globals": [
|
|
54
|
-
"error",
|
|
55
|
-
{
|
|
56
|
-
"name": "structuredClone",
|
|
57
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics. Context is JSON-serialisable, so JSON.parse(JSON.stringify(value)) is the portable equivalent."
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
"name": "TextEncoder",
|
|
61
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics. Import encodeUtf8 from @seriousgaming/sdk instead."
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
"name": "TextDecoder",
|
|
65
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics. Import decodeUtf8 from @seriousgaming/sdk instead."
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
"name": "fetch",
|
|
69
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics. Reach external services through the injected callbacks, or through an endpoint."
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
"name": "XMLHttpRequest",
|
|
73
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics. Reach external services through the injected callbacks, or through an endpoint."
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
"name": "setTimeout",
|
|
77
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics. Ticks are the scheduling primitive: logic must run to completion within one tick."
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
"name": "setInterval",
|
|
81
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics. Ticks are the scheduling primitive: logic must run to completion within one tick."
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
"name": "setImmediate",
|
|
85
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics. Ticks are the scheduling primitive: logic must run to completion within one tick."
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
"name": "queueMicrotask",
|
|
89
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics. Ticks are the scheduling primitive: logic must run to completion within one tick."
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
"name": "process",
|
|
93
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics. Settings reach logic through the `settings` argument."
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
"name": "Buffer",
|
|
97
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics. Use Uint8Array, with the SDK's encodeUtf8 / decodeUtf8 for string conversion."
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
"name": "URL",
|
|
101
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics. Build asset URLs from the references and callbacks the runtime injects."
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
"name": "clearTimeout",
|
|
105
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
"name": "clearInterval",
|
|
109
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
"name": "clearImmediate",
|
|
113
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
"name": "URLSearchParams",
|
|
117
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
"name": "crypto",
|
|
121
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
"name": "atob",
|
|
125
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
"name": "btoa",
|
|
129
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
"name": "performance",
|
|
133
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
"name": "ReadableStream",
|
|
137
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
"name": "WritableStream",
|
|
141
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
"name": "TransformStream",
|
|
145
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
"name": "Blob",
|
|
149
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
"name": "File",
|
|
153
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
"name": "FormData",
|
|
157
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
"name": "Headers",
|
|
161
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
"name": "Request",
|
|
165
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
"name": "Response",
|
|
169
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
"name": "AbortController",
|
|
173
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
"name": "EventTarget",
|
|
177
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
"name": "WebSocket",
|
|
181
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
"name": "localStorage",
|
|
185
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
"name": "sessionStorage",
|
|
189
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
"name": "window",
|
|
193
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
"name": "document",
|
|
197
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
"name": "navigator",
|
|
201
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
"name": "require",
|
|
205
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
"name": "__dirname",
|
|
209
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
"name": "__filename",
|
|
213
|
-
"message": "Not available in the production runtime, which is a bare V8 isolate exposing only the ECMAScript intrinsics."
|
|
214
|
-
}
|
|
215
|
-
]
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
"files": ["**/*.test.ts", "**/*.spec.ts"],
|
|
220
|
-
"rules": {
|
|
221
|
-
"no-restricted-globals": "off"
|
|
222
|
-
}
|
|
223
|
-
},
|
|
224
45
|
{
|
|
225
46
|
"files": ["**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/testing/**"],
|
|
226
47
|
"rules": {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"generate": "pnpm run sdk generate",
|
|
13
13
|
"build": "pnpm run sdk build",
|
|
14
|
+
"check": "pnpm run --silent sdk build --validate-only && pnpm run --silent typecheck && pnpm run --silent lint && pnpm run --silent test:run --passWithNoTests && pnpm run --silent test:engine --passWithNoTests",
|
|
14
15
|
"start": "pnpm run sdk dev",
|
|
15
16
|
"test": "vitest",
|
|
16
17
|
"test:run": "vitest run",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { REACT_CONTEXT_PACKAGES } from '@seriousgaming/sdk-tools/vite';
|
|
1
2
|
import { defineConfig } from 'vite';
|
|
2
3
|
|
|
3
4
|
export default defineConfig({
|
|
@@ -7,13 +8,6 @@ export default defineConfig({
|
|
|
7
8
|
// hook reads empty data: React's "Invalid hook call" when MUI bundles
|
|
8
9
|
// its own React, or an SDK hook in a shared package of yours that
|
|
9
10
|
// finds none of the providers the host set up.
|
|
10
|
-
dedupe: [
|
|
11
|
-
'react',
|
|
12
|
-
'react-dom',
|
|
13
|
-
'@emotion/react',
|
|
14
|
-
'@emotion/styled',
|
|
15
|
-
'@seriousgaming/sdk',
|
|
16
|
-
'@seriousgaming/deck',
|
|
17
|
-
],
|
|
11
|
+
dedupe: [...REACT_CONTEXT_PACKAGES],
|
|
18
12
|
},
|
|
19
13
|
});
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
+
import { REACT_CONTEXT_PACKAGES } from '@seriousgaming/sdk-tools/vite';
|
|
1
2
|
import { defineConfig } from 'vitest/config';
|
|
2
3
|
|
|
3
4
|
export default defineConfig({
|
|
4
5
|
resolve: {
|
|
5
6
|
// The same single copies vite.config.ts asks for, so a test renders
|
|
6
7
|
// with the providers the component reads.
|
|
7
|
-
dedupe: [
|
|
8
|
-
'react',
|
|
9
|
-
'react-dom',
|
|
10
|
-
'@emotion/react',
|
|
11
|
-
'@emotion/styled',
|
|
12
|
-
'@seriousgaming/sdk',
|
|
13
|
-
'@seriousgaming/deck',
|
|
14
|
-
],
|
|
8
|
+
dedupe: [...REACT_CONTEXT_PACKAGES],
|
|
15
9
|
},
|
|
16
10
|
esbuild: {
|
|
17
11
|
jsx: 'automatic',
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"generate": "pnpm run sdk generate",
|
|
15
15
|
"build": "pnpm run sdk build",
|
|
16
|
+
"check": "pnpm run --silent sdk build --validate-only && pnpm run --silent typecheck && pnpm run --silent lint && pnpm run --silent test:run --passWithNoTests && pnpm run --silent test:engine --passWithNoTests",
|
|
16
17
|
"start": "pnpm run sdk dev",
|
|
17
18
|
"test": "vitest",
|
|
18
19
|
"test:run": "vitest run",
|
|
@@ -22,7 +23,7 @@
|
|
|
22
23
|
"lint:fix": "oxlint --fix",
|
|
23
24
|
"format": "oxfmt",
|
|
24
25
|
"format:check": "oxfmt --check",
|
|
25
|
-
"typecheck": "tsc --noEmit",
|
|
26
|
+
"typecheck": "tsc --noEmit --incremental --tsBuildInfoFile node_modules/.cache/tsc/typecheck.tsbuildinfo",
|
|
26
27
|
"sdk": "vite-node node_modules/@seriousgaming/sdk-tools/cli/cli.ts",
|
|
27
28
|
"test:e2e": "playwright test"
|
|
28
29
|
},
|
|
@@ -12,29 +12,25 @@
|
|
|
12
12
|
* Run with: pnpm test:engine
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
import { readdirSync } from 'fs';
|
|
16
|
+
import { join } from 'path';
|
|
15
17
|
import { fileURLToPath } from 'url';
|
|
16
18
|
|
|
17
19
|
import { createTestSession, type TestSession } from '@seriousgaming/sdk-tools/client';
|
|
18
20
|
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/** The context is untyped here, so each read says what it expects to find. */
|
|
25
|
-
const cap = (context: Context, key: string) => context[key] as Record<string, unknown>;
|
|
26
|
-
|
|
27
|
-
const numberField = (context: Context, key: string, field: string) =>
|
|
28
|
-
cap(context, key)[field] as number;
|
|
22
|
+
// The engine's generated `Context` holds the capabilities the engine reads and
|
|
23
|
+
// writes, which are the ones these tests play. A capability only a hook or a
|
|
24
|
+
// surface writes is in the team's context too, and not in this type.
|
|
25
|
+
import type { Context } from '../../engine/types';
|
|
29
26
|
|
|
30
|
-
const
|
|
31
|
-
cap(context, key)[field] as Record<string, number>;
|
|
27
|
+
const PACKAGE_PATH = fileURLToPath(new URL('../..', import.meta.url));
|
|
32
28
|
|
|
33
29
|
describe('Lemonade Stand', () => {
|
|
34
|
-
let game: TestSession
|
|
30
|
+
let game: TestSession<Context>;
|
|
35
31
|
|
|
36
32
|
beforeEach(async () => {
|
|
37
|
-
game = await createTestSession({ packagePath: PACKAGE_PATH });
|
|
33
|
+
game = await createTestSession<Context>({ packagePath: PACKAGE_PATH });
|
|
38
34
|
});
|
|
39
35
|
|
|
40
36
|
afterEach(async () => {
|
|
@@ -52,8 +48,14 @@ describe('Lemonade Stand', () => {
|
|
|
52
48
|
|
|
53
49
|
/** Open the stall for a day, and fail loudly if the session refused. */
|
|
54
50
|
const tick = async (): Promise<Context> => {
|
|
55
|
-
const result = await game.
|
|
56
|
-
if (!result.ok)
|
|
51
|
+
const result = await game.tick();
|
|
52
|
+
if (!result.ok) {
|
|
53
|
+
// When the engine threw, the result says where: the same file,
|
|
54
|
+
// line, tick and team `sdk tick` reports.
|
|
55
|
+
const at = result.logicError;
|
|
56
|
+
const where = at ? ` at ${at.file}:${at.line} (tick ${at.tick})` : '';
|
|
57
|
+
throw new Error(`The day was refused: ${result.outcome.kind}${where}`);
|
|
58
|
+
}
|
|
57
59
|
return stall();
|
|
58
60
|
};
|
|
59
61
|
|
|
@@ -67,11 +69,10 @@ describe('Lemonade Stand', () => {
|
|
|
67
69
|
expect(result.ok).toBe(true);
|
|
68
70
|
};
|
|
69
71
|
|
|
70
|
-
const lines = (context: Context) =>
|
|
71
|
-
cap(context, 'results').Lines as Record<string, Record<string, number>>;
|
|
72
|
+
const lines = (context: Context) => context.results.Lines;
|
|
72
73
|
|
|
73
74
|
it('starts every item on the menu at a number the stall can make', () => {
|
|
74
|
-
const plan =
|
|
75
|
+
const plan = stall().plan.Make;
|
|
75
76
|
|
|
76
77
|
expect(Object.keys(plan).sort()).toEqual(['cookies', 'icedtea', 'lemonade']);
|
|
77
78
|
expect(Object.values(plan).reduce((sum, count) => sum + count, 0)).toBeLessThanOrEqual(120);
|
|
@@ -79,8 +80,8 @@ describe('Lemonade Stand', () => {
|
|
|
79
80
|
|
|
80
81
|
it('opens with nothing traded and a forecast for the first day', () => {
|
|
81
82
|
expect(day()).toBe(0);
|
|
82
|
-
expect(
|
|
83
|
-
expect(['sunny', 'cloudy', 'rainy']).toContain(
|
|
83
|
+
expect(stall().results.Day).toBe(0);
|
|
84
|
+
expect(['sunny', 'cloudy', 'rainy']).toContain(stall().weather.Today);
|
|
84
85
|
});
|
|
85
86
|
|
|
86
87
|
it('sells what it made, and turns the rest away', async () => {
|
|
@@ -98,32 +99,30 @@ describe('Lemonade Stand', () => {
|
|
|
98
99
|
|
|
99
100
|
expect(lines(context).cookies!.PouredAway).toBeGreaterThan(0);
|
|
100
101
|
// 100 cookies at 25p, whatever the day did.
|
|
101
|
-
expect(
|
|
102
|
-
expect(
|
|
102
|
+
expect(context.results.Spent).toBe(100 * 25);
|
|
103
|
+
expect(context.results.Profit).toBeLessThan(0);
|
|
103
104
|
});
|
|
104
105
|
|
|
105
106
|
it('makes more money matching the forecast than ignoring it', async () => {
|
|
106
|
-
await make(
|
|
107
|
+
await make(stall().weather.Expected);
|
|
107
108
|
for (let round = 0; round < 5; round += 1) await tick();
|
|
108
|
-
const matched =
|
|
109
|
+
const matched = stall().results.Purse;
|
|
109
110
|
|
|
110
111
|
expect((await game.send({ type: 'reinitialise' })).ok).toBe(true);
|
|
111
112
|
await make({ lemonade: 0, icedtea: 0, cookies: 0 });
|
|
112
113
|
for (let round = 0; round < 5; round += 1) await tick();
|
|
113
|
-
const nothing =
|
|
114
|
+
const nothing = stall().results.Purse;
|
|
114
115
|
|
|
115
116
|
expect(matched).toBeGreaterThan(nothing);
|
|
116
117
|
});
|
|
117
118
|
|
|
118
119
|
it('keeps a running purse across days', async () => {
|
|
119
|
-
await make(
|
|
120
|
+
await make(stall().weather.Expected);
|
|
120
121
|
|
|
121
122
|
const first = await tick();
|
|
122
123
|
const second = await tick();
|
|
123
124
|
|
|
124
|
-
expect(
|
|
125
|
-
numberField(first, 'results', 'Profit') + numberField(second, 'results', 'Profit')
|
|
126
|
-
);
|
|
125
|
+
expect(second.results.Purse).toBe(first.results.Profit + second.results.Profit);
|
|
127
126
|
});
|
|
128
127
|
|
|
129
128
|
it('labels each day with its own number', async () => {
|
|
@@ -131,31 +130,31 @@ describe('Lemonade Stand', () => {
|
|
|
131
130
|
await tick();
|
|
132
131
|
await tick();
|
|
133
132
|
|
|
134
|
-
expect(
|
|
133
|
+
expect(stall().results.Day).toBe(3);
|
|
135
134
|
});
|
|
136
135
|
|
|
137
136
|
it('plays the day it forecast, not a different one', async () => {
|
|
138
|
-
const forecastForDayOne =
|
|
137
|
+
const forecastForDayOne = stall().weather.Today;
|
|
139
138
|
|
|
140
139
|
const context = await tick();
|
|
141
140
|
|
|
142
|
-
expect(
|
|
141
|
+
expect(context.results.Weather).toBe(forecastForDayOne);
|
|
143
142
|
// And it has moved on to forecasting day two.
|
|
144
|
-
expect(['sunny', 'cloudy', 'rainy']).toContain(
|
|
143
|
+
expect(['sunny', 'cloudy', 'rainy']).toContain(context.weather.Today);
|
|
145
144
|
});
|
|
146
145
|
|
|
147
146
|
it('leaves the plan alone, so yesterday carries into today', async () => {
|
|
148
147
|
await make({ lemonade: 44, icedtea: 0, cookies: 0 });
|
|
149
148
|
const context = await tick();
|
|
150
149
|
|
|
151
|
-
expect(
|
|
150
|
+
expect(context.plan.Make).toEqual({ lemonade: 44, icedtea: 0, cookies: 0 });
|
|
152
151
|
});
|
|
153
152
|
|
|
154
153
|
it('trades its ten days', async () => {
|
|
155
154
|
for (let round = 0; round < 10; round += 1) await tick();
|
|
156
155
|
|
|
157
156
|
expect(day()).toBe(10);
|
|
158
|
-
expect(
|
|
157
|
+
expect(stall().results.Day).toBe(10);
|
|
159
158
|
});
|
|
160
159
|
|
|
161
160
|
it('undo takes back the last day', async () => {
|
|
@@ -165,7 +164,33 @@ describe('Lemonade Stand', () => {
|
|
|
165
164
|
expect((await game.send({ type: 'undo' })).ok).toBe(true);
|
|
166
165
|
|
|
167
166
|
expect(day()).toBe(0);
|
|
168
|
-
expect(
|
|
169
|
-
expect(
|
|
167
|
+
expect(stall().results.Purse).toBe(0);
|
|
168
|
+
expect(stall().results.Day).toBe(0);
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Every scenario has to start and play a day. A scenario overrides settings,
|
|
174
|
+
* and a value the engine cannot work with (a menu with no items, a demand of
|
|
175
|
+
* zero it divides by) only shows when the game is played on it. Read from disk
|
|
176
|
+
* rather than listed, so a new scenario is covered the day it is added.
|
|
177
|
+
*/
|
|
178
|
+
describe('every scenario', () => {
|
|
179
|
+
const scenarios = readdirSync(join(PACKAGE_PATH, 'scenarios'), { withFileTypes: true })
|
|
180
|
+
.filter((entry) => entry.isDirectory())
|
|
181
|
+
.map((entry) => entry.name);
|
|
182
|
+
|
|
183
|
+
it('is a set this test can see', () => {
|
|
184
|
+
expect(scenarios.length).toBeGreaterThan(0);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it.each(scenarios)('%s starts and plays a day', async (scenarioId) => {
|
|
188
|
+
const game = await createTestSession<Context>({ packagePath: PACKAGE_PATH, scenarioId });
|
|
189
|
+
try {
|
|
190
|
+
expect(await game.tick()).toMatchObject({ ok: true });
|
|
191
|
+
expect(game.team(0).context.results.Day).toBe(1);
|
|
192
|
+
} finally {
|
|
193
|
+
await game.close();
|
|
194
|
+
}
|
|
170
195
|
});
|
|
171
196
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { REACT_CONTEXT_PACKAGES } from '@seriousgaming/sdk-tools/vite';
|
|
1
2
|
import { defineConfig } from 'vite';
|
|
2
3
|
|
|
3
4
|
export default defineConfig({
|
|
@@ -7,13 +8,6 @@ export default defineConfig({
|
|
|
7
8
|
// hook reads empty data: React's "Invalid hook call" when MUI bundles
|
|
8
9
|
// its own React, or an SDK hook in a shared package of yours that
|
|
9
10
|
// finds none of the providers the host set up.
|
|
10
|
-
dedupe: [
|
|
11
|
-
'react',
|
|
12
|
-
'react-dom',
|
|
13
|
-
'@emotion/react',
|
|
14
|
-
'@emotion/styled',
|
|
15
|
-
'@seriousgaming/sdk',
|
|
16
|
-
'@seriousgaming/deck',
|
|
17
|
-
],
|
|
11
|
+
dedupe: [...REACT_CONTEXT_PACKAGES],
|
|
18
12
|
},
|
|
19
13
|
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { REACT_CONTEXT_PACKAGES } from '@seriousgaming/sdk-tools/vite';
|
|
1
2
|
import { defineConfig } from 'vitest/config';
|
|
2
3
|
|
|
3
4
|
export default defineConfig({
|
|
4
5
|
resolve: {
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
dedupe: [
|
|
6
|
+
// The same single copies vite.config.ts asks for, so a test renders
|
|
7
|
+
// with the providers the component reads.
|
|
8
|
+
dedupe: [...REACT_CONTEXT_PACKAGES],
|
|
8
9
|
},
|
|
9
10
|
test: {
|
|
10
11
|
// Exclude engine tests (node env, separate config) and Playwright specs
|