@seriousgaming/sdk-tools 1.4.0 → 1.6.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/bundling/ui-bundler.d.ts +12 -0
- package/dist/cli-25RWY5BQ.js +41 -0
- package/dist/cli-272KBNJH.js +97 -0
- package/dist/cli-2BH7FX27.js +52 -0
- package/dist/cli-2GOFEW26.js +81 -0
- package/dist/cli-3E3MD5U4.js +21 -0
- package/dist/cli-3HE4AVZG.js +115 -0
- package/dist/cli-4AKVLEC4.js +1387 -0
- package/dist/cli-4BV45LBH.js +126 -0
- package/dist/cli-4LKXZQ2B.js +48 -0
- package/dist/cli-4UWFQNGF.js +54 -0
- package/dist/cli-4YB3ROVR.js +78 -0
- package/dist/cli-57RXC3HQ.js +36 -0
- package/dist/cli-5JEGTVTG.js +96 -0
- package/dist/cli-6AMT3BUO.js +97 -0
- package/dist/cli-6RRVEGFB.js +80 -0
- package/dist/cli-6WXLXJVX.js +36 -0
- package/dist/cli-7OGYADZ3.js +97 -0
- package/dist/cli-AK7OIPWY.js +229 -0
- package/dist/cli-B4TN6PJP.js +124 -0
- package/dist/cli-B6YHEKIJ.js +248 -0
- package/dist/cli-BPYMTOUL.js +89 -0
- package/dist/cli-BWX5E7TQ.js +23 -0
- package/dist/cli-BYJWFFCF.js +37 -0
- package/dist/cli-C3NVCKO6.js +43 -0
- package/dist/cli-C47GJATR.js +42 -0
- package/dist/cli-C5QOJJWX.js +46 -0
- package/dist/cli-C6TH5S7K.js +6417 -0
- package/dist/cli-DL2CVMRF.js +89 -0
- package/dist/cli-DMW2OQIJ.js +76 -0
- package/dist/cli-DZW3XD5F.js +143 -0
- package/dist/cli-E2NLWIFE.js +1331 -0
- package/dist/cli-E33CJRRQ.js +36 -0
- package/dist/cli-E6DJIMYD.js +142 -0
- package/dist/cli-EEFJKIGL.js +151 -0
- package/dist/cli-EVFS55WN.js +185 -0
- package/dist/cli-F2D4GGUA.js +549 -0
- package/dist/cli-FBTRTIZJ.js +226 -0
- package/dist/cli-FWFRKQNE.js +11 -0
- package/dist/cli-FYINNRML.js +760 -0
- package/dist/cli-G522CPRL.js +88 -0
- package/dist/cli-G6KELFSX.js +2847 -0
- package/dist/cli-G6UE5NL4.js +90 -0
- package/dist/cli-GBFM76BF.js +16 -0
- package/dist/cli-GDQ6ILJY.js +101 -0
- package/dist/cli-GFBGYFYD.js +50 -0
- package/dist/cli-GGPDQNM3.js +35 -0
- package/dist/cli-GTSGLN3Z.js +307 -0
- package/dist/cli-GUXKQMJ7.js +13641 -0
- package/dist/cli-GXD36NF2.js +60 -0
- package/dist/cli-HCRTYQQS.js +16 -0
- package/dist/cli-HYY64SUD.js +185 -0
- package/dist/cli-I355WTAF.js +463 -0
- package/dist/cli-IDKYF5XB.js +59 -0
- package/dist/cli-ILKCQNM6.js +8 -0
- package/dist/cli-IRZ5KB7D.js +36 -0
- package/dist/cli-IUS2YCD3.js +31 -0
- package/dist/cli-J4DKUUTK.js +138 -0
- package/dist/cli-JFU22EJ2.js +187 -0
- package/dist/cli-JMZLT65J.js +226 -0
- package/dist/cli-JZM7XTNV.js +89 -0
- package/dist/cli-K2B6WHKA.js +81 -0
- package/dist/cli-KL3756X6.js +126 -0
- package/dist/cli-KNOOKGYW.js +88 -0
- package/dist/cli-LFGRFIEO.js +226 -0
- package/dist/cli-LFM7GJHI.js +0 -0
- package/dist/cli-LMDJCHHD.js +304 -0
- package/dist/cli-LXYPE3L5.js +99 -0
- package/dist/cli-M6BCQRID.js +153 -0
- package/dist/cli-MBNMPVDC.js +367 -0
- package/dist/cli-MJUYJIEP.js +13 -0
- package/dist/cli-MMN4BPO4.js +145 -0
- package/dist/cli-MYJGMA6U.js +40 -0
- package/dist/cli-N6H6T2E2.js +616 -0
- package/dist/cli-O5KP4OVN.js +61 -0
- package/dist/cli-O6PWMJTZ.js +25 -0
- package/dist/cli-ORIG557O.js +141 -0
- package/dist/cli-PFFCNGHI.js +243 -0
- package/dist/cli-PNLYX6R6.js +131 -0
- package/dist/cli-PQBXVLEU.js +649 -0
- package/dist/cli-PTT5RGKO.js +62 -0
- package/dist/cli-Q2XJF5AS.js +127 -0
- package/dist/cli-QEVDDBNO.js +60 -0
- package/dist/cli-QEVE5HUM.js +167 -0
- package/dist/cli-QUIJCBYB.js +391 -0
- package/dist/cli-QUNIRH7A.js +57 -0
- package/dist/cli-QVASWX2A.js +187 -0
- package/dist/cli-QWQMPCL6.js +253 -0
- package/dist/cli-R4PCG5YX.js +131 -0
- package/dist/cli-RA673NGF.js +53 -0
- package/dist/cli-RN6IWTL2.js +36 -0
- package/dist/cli-ROT3DRKU.js +145 -0
- package/dist/cli-RZITKPJX.js +367 -0
- package/dist/cli-S5IVGDDD.js +32 -0
- package/dist/cli-S5QDONIQ.js +218 -0
- package/dist/cli-SIPDUBFL.js +36 -0
- package/dist/cli-SMFSZF2G.js +4009 -0
- package/dist/cli-SRHBXZCN.js +159 -0
- package/dist/cli-TCY5LJ7E.js +88 -0
- package/dist/cli-TDSQSCX4.js +131 -0
- package/dist/cli-TIDQ4WUE.js +257 -0
- package/dist/cli-TLLA6KAP.js +79 -0
- package/dist/cli-TPU4TUR6.js +132 -0
- package/dist/cli-U2UE7I7J.js +30 -0
- package/dist/cli-UELGBQG7.js +101 -0
- package/dist/cli-UHSZBKYO.js +97 -0
- package/dist/cli-UJ4UCL2Z.js +38 -0
- package/dist/cli-UKQYZYFK.js +31 -0
- package/dist/cli-UMFFURZ7.js +81 -0
- package/dist/cli-UNAJ2OTE.js +15 -0
- package/dist/cli-UNJ5X6BU.js +89 -0
- package/dist/cli-UTJU4IYG.js +117 -0
- package/dist/cli-V4GHRWOV.js +1837 -0
- package/dist/cli-VCI3CG36.js +73 -0
- package/dist/cli-VCKOC2EV.js +256 -0
- package/dist/cli-VL2P354N.js +46 -0
- package/dist/cli-WAE26SVW.js +72 -0
- package/dist/cli-WOGIAU2E.js +100 -0
- package/dist/cli-WU43JT4T.js +52 -0
- package/dist/cli-XCO2VQOH.js +122 -0
- package/dist/cli-XSVGKI3R.js +39 -0
- package/dist/cli-YOTGR3NB.js +82 -0
- package/dist/cli-YVVXUD2G.js +197 -0
- package/dist/cli-ZISJ36MM.js +89 -0
- package/dist/cli-ZTWOE3ZT.js +65 -0
- package/dist/cli-ZVSFYDPQ.js +205 -0
- package/dist/cli-ZWPYIXNI.js +68 -0
- package/dist/cli.js +171 -42385
- package/dist/client/build-surfaces.d.ts +33 -0
- package/dist/client/dev-server.d.ts +6 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/playwright.d.ts +62 -0
- package/dist/client.js +339 -56
- package/dist/core/session.d.ts +15 -1
- package/dist/dev/console/assets/{index-BvB-LFQZ.js → index-CuMOOH9m.js} +21 -21
- package/dist/dev/console/index.html +1 -1
- package/dist/dev/public-origins.d.ts +61 -0
- package/dist/dev/shell.d.ts +51 -4
- package/dist/dev/surfaces.d.ts +7 -0
- package/dist/docs/ai-agents.md +5 -0
- package/dist/docs/api/index.md +14 -12
- package/dist/docs/api/sdk-tools-client.md +29 -0
- package/dist/docs/api/sdk-tools-playwright.md +104 -0
- package/dist/docs/changelog-0.x.md +2 -2
- package/dist/docs/changelog.md +56 -4
- package/dist/docs/cli-and-dev-server.md +79 -0
- package/dist/docs/cli-error-codes.md +39 -36
- package/dist/docs/cli-reference.md +93 -32
- package/dist/docs/environment-variables.md +16 -5
- package/dist/docs/guides/ai-facilitation.md +2 -0
- package/dist/docs/guides/capabilities.md +2 -0
- package/dist/docs/guides/designing-a-game.md +31 -4
- package/dist/docs/guides/designing-screens.md +133 -0
- package/dist/docs/guides/endpoints.md +2 -0
- package/dist/docs/guides/engine-testing.md +5 -1
- package/dist/docs/guides/engine.md +2 -0
- package/dist/docs/guides/file-handling.md +3 -1
- package/dist/docs/guides/games.md +3 -1
- package/dist/docs/guides/global-settings.md +2 -0
- package/dist/docs/guides/guide.md +2 -0
- package/dist/docs/guides/hooks.md +2 -0
- package/dist/docs/guides/index.md +9 -0
- package/dist/docs/guides/internationalization.md +2 -0
- package/dist/docs/guides/llm-integration.md +4 -2
- package/dist/docs/guides/multi-team-games.md +3 -1
- package/dist/docs/guides/patterns.md +2 -0
- package/dist/docs/guides/presentation.md +1 -1
- package/dist/docs/guides/production-constraints.md +2 -0
- package/dist/docs/guides/scenario-editor.md +2 -0
- package/dist/docs/guides/scenarios.md +6 -2
- package/dist/docs/guides/session-game-flow.md +365 -0
- package/dist/docs/guides/session-hooks.md +205 -0
- package/dist/docs/guides/session.md +27 -565
- package/dist/docs/guides/settings.md +2 -0
- package/dist/docs/guides/setup.md +3 -1
- package/dist/docs/guides/speech-generation.md +2 -0
- package/dist/docs/guides/starter-game.md +63 -23
- package/dist/docs/guides/testing.md +35 -18
- package/dist/docs/guides/tick-controller.md +3 -1
- package/dist/docs/guides/type-safety.md +2 -0
- package/dist/docs/guides/ui-files-and-llms.md +328 -0
- package/dist/docs/guides/ui-participants.md +281 -0
- package/dist/docs/guides/ui-styling.md +263 -0
- package/dist/docs/guides/ui-ticks.md +247 -0
- package/dist/docs/guides/ui.md +11 -1092
- package/dist/docs/guides/upgrading.md +2 -0
- package/dist/docs/guides/validators.md +2 -0
- package/dist/docs/guides/waiting-room.md +1 -1
- package/dist/docs/index.md +2 -1
- package/dist/docs/page-index.md +146 -0
- package/dist/docs/recipes/adapt-a-game-for-walkthroughs.md +1 -1
- package/dist/docs/recipes/adapt-ui-for-observers.md +1 -1
- package/dist/docs/recipes/create-presentation.md +11 -0
- package/dist/docs/recipes/create-scenario-editor.md +1 -0
- package/dist/docs/recipes/create-session-ui.md +2 -1
- package/dist/docs/recipes/create-setup.md +1 -0
- package/dist/docs/recipes/create-user-interface.md +1 -0
- package/dist/docs/recipes/create-waiting-room-ui.md +1 -0
- package/dist/docs/recipes/design-state-for-concurrent-writes.md +1 -1
- package/dist/docs/recipes/e2e-testing.md +19 -20
- package/dist/docs/recipes/fix-duplicate-packages.md +2 -2
- package/dist/docs/recipes/index.md +3 -0
- package/dist/docs/recipes/screenshot-a-surface.md +80 -0
- package/dist/docs/recipes/test-a-multi-role-game.md +1 -1
- package/dist/docs/recipes/use-request-tick.md +2 -2
- package/dist/execution/config-resolver.d.ts +4 -1
- package/dist/playwright.js +32232 -0
- package/dist/runtime/manifest-version.d.ts +1 -1
- package/dist/runtime.js +1 -1
- package/dist/templates/package/CLAUDE.md.template +14 -5
- package/dist/templates/package/DESIGN.md.liquid +39 -7
- package/dist/templates/package/README.md.liquid +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/global-setup.ts.template +7 -18
- package/dist/templates/package/playwright.config.ts.liquid +8 -11
- package/dist/templates/package/pnpm-workspace.yaml.template +13 -0
- package/dist/templates/starter-game/capabilities/pacing/capability.sdk.json +18 -0
- package/dist/templates/starter-game/package.json +2 -0
- package/dist/templates/starter-game/playwright.config.ts +8 -11
- package/dist/templates/starter-game/presentation/defaults.ts +52 -0
- package/dist/templates/starter-game/presentation/index.html +20 -0
- package/dist/templates/starter-game/presentation/presentation.sdk.json +10 -0
- package/dist/templates/starter-game/presentation/src/App.tsx +55 -0
- package/dist/templates/starter-game/presentation/src/Band.tsx +40 -0
- package/dist/templates/starter-game/presentation/src/Slides.tsx +415 -0
- package/dist/templates/starter-game/presentation/src/WeatherIcon.tsx +21 -0
- package/dist/templates/starter-game/presentation/src/i18n.ts +88 -0
- package/dist/templates/starter-game/presentation/src/main.tsx +15 -0
- package/dist/templates/starter-game/presentation/src/stalls.test.ts +196 -0
- package/dist/templates/starter-game/presentation/src/stalls.ts +199 -0
- package/dist/templates/starter-game/presentation/types.ts +94 -0
- package/dist/templates/starter-game/seriousgaming.sdk.json +2 -1
- package/dist/templates/starter-game/session/defaults.ts +6 -0
- package/dist/templates/starter-game/session/index.html +1 -1
- package/dist/templates/starter-game/session/session.sdk.json +2 -2
- package/dist/templates/starter-game/session/src/App.test.tsx +436 -115
- package/dist/templates/starter-game/session/src/App.tsx +372 -222
- package/dist/templates/starter-game/session/src/JoinCodes.tsx +184 -0
- package/dist/templates/starter-game/session/src/ManagePanel.tsx +188 -0
- package/dist/templates/starter-game/session/src/Results.tsx +340 -0
- package/dist/templates/starter-game/session/src/SessionBar.tsx +179 -0
- package/dist/templates/starter-game/session/src/SessionPanels.tsx +105 -0
- package/dist/templates/starter-game/session/src/SidePanel.tsx +89 -0
- package/dist/templates/starter-game/session/src/StallCard.tsx +253 -0
- package/dist/templates/starter-game/session/src/TopBar.tsx +36 -0
- package/dist/templates/starter-game/session/src/i18n.ts +91 -24
- package/dist/templates/starter-game/session/src/status.ts +28 -0
- package/dist/templates/starter-game/session/types.ts +8 -2
- package/dist/templates/starter-game/shared/Awning.tsx +31 -0
- package/dist/templates/starter-game/shared/HostLogo.test.tsx +38 -0
- package/dist/templates/starter-game/shared/HostLogo.tsx +48 -0
- package/dist/templates/starter-game/shared/StallIcons.tsx +83 -0
- package/dist/templates/starter-game/shared/days.ts +11 -0
- package/dist/templates/starter-game/shared/format.test.ts +13 -0
- package/dist/templates/starter-game/{ui/src → shared}/format.ts +1 -1
- package/dist/templates/starter-game/testing/e2e/game.spec.ts +43 -9
- package/dist/templates/starter-game/testing/e2e/global-setup.ts +7 -18
- package/dist/templates/starter-game/ui/defaults.ts +3 -0
- package/dist/templates/starter-game/ui/src/App.test.tsx +197 -29
- package/dist/templates/starter-game/ui/src/App.tsx +176 -99
- package/dist/templates/starter-game/ui/src/DayBar.test.tsx +50 -7
- package/dist/templates/starter-game/ui/src/DayBar.tsx +96 -38
- package/dist/templates/starter-game/ui/src/DaysTable.tsx +69 -0
- package/dist/templates/starter-game/ui/src/FirstDay.tsx +37 -0
- package/dist/templates/starter-game/ui/src/Header.tsx +257 -0
- package/dist/templates/starter-game/ui/src/Lesson.tsx +63 -0
- package/dist/templates/starter-game/ui/src/MakeRow.tsx +98 -71
- package/dist/templates/starter-game/ui/src/Notices.tsx +59 -0
- package/dist/templates/starter-game/ui/src/PastDay.tsx +88 -0
- package/dist/templates/starter-game/ui/src/Section.tsx +26 -26
- package/dist/templates/starter-game/ui/src/ThemeToggle.tsx +25 -11
- package/dist/templates/starter-game/ui/src/TodayPanel.test.tsx +37 -33
- package/dist/templates/starter-game/ui/src/TodayPanel.tsx +66 -52
- package/dist/templates/starter-game/ui/src/WeatherCard.tsx +47 -0
- package/dist/templates/starter-game/ui/src/WeekOver.tsx +145 -0
- package/dist/templates/starter-game/ui/src/YesterdayPanel.tsx +65 -114
- package/dist/templates/starter-game/ui/src/days.ts +58 -0
- package/dist/templates/starter-game/ui/src/i18n.ts +86 -32
- package/dist/templates/starter-game/ui/src/test-helpers.ts +1 -0
- package/dist/templates/starter-game/ui/src/theme.ts +8 -8
- package/dist/templates/starter-game/ui/types.ts +6 -0
- package/dist/templates/starter-game/ui/ui.sdk.json +1 -1
- package/dist/templates/starter-game/validators/daylimit/defaults.ts +13 -0
- package/dist/templates/starter-game/validators/daylimit/logic/logic.test.ts +20 -0
- package/dist/templates/starter-game/validators/daylimit/logic/logic.ts +23 -0
- package/dist/templates/starter-game/validators/daylimit/types.ts +23 -0
- package/dist/templates/starter-game/validators/daylimit/validator.sdk.json +10 -0
- package/dist/templates/starter-game/waiting_room/src/App.test.tsx +83 -5
- package/dist/templates/starter-game/waiting_room/src/App.tsx +262 -119
- package/dist/templates/starter-game/waiting_room/src/i18n.ts +8 -4
- package/dist/utils/error-codes.d.ts +12 -0
- package/dist/utils/prompt.d.ts +5 -5
- package/dist/utils/resource-scan.d.ts +39 -0
- package/package.json +15 -4
- package/dist/templates/starter-game/session/src/Section.tsx +0 -37
- package/dist/templates/starter-game/session/src/TeamDoor.tsx +0 -96
- package/dist/templates/starter-game/session/src/format.ts +0 -8
- package/dist/templates/starter-game/ui/src/HistoryPanel.test.tsx +0 -74
- package/dist/templates/starter-game/ui/src/HistoryPanel.tsx +0 -120
- package/dist/templates/starter-game/ui/src/HostLogo.test.tsx +0 -25
- package/dist/templates/starter-game/ui/src/HostLogo.tsx +0 -38
|
@@ -0,0 +1,760 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
readSdkToolsVersion
|
|
4
|
+
} from "./cli-IUS2YCD3.js";
|
|
5
|
+
import {
|
|
6
|
+
normalizeVariablesSchema
|
|
7
|
+
} from "./cli-QUNIRH7A.js";
|
|
8
|
+
import {
|
|
9
|
+
copyStaticFile,
|
|
10
|
+
createResourceFiles,
|
|
11
|
+
deleteResourceFiles,
|
|
12
|
+
findResourceReferences,
|
|
13
|
+
presentFields,
|
|
14
|
+
renderAndWriteTemplate,
|
|
15
|
+
updateResourceFiles,
|
|
16
|
+
writeJsonFile
|
|
17
|
+
} from "./cli-MBNMPVDC.js";
|
|
18
|
+
import {
|
|
19
|
+
getPluralResourceMeta,
|
|
20
|
+
getResourceMeta,
|
|
21
|
+
validatePackageManifest
|
|
22
|
+
} from "./cli-SMFSZF2G.js";
|
|
23
|
+
import {
|
|
24
|
+
isJsonOutput
|
|
25
|
+
} from "./cli-N6H6T2E2.js";
|
|
26
|
+
|
|
27
|
+
// cli/templating/package.ts
|
|
28
|
+
import { spawn } from "child_process";
|
|
29
|
+
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
30
|
+
import { dirname as dirname2, join as join2 } from "path";
|
|
31
|
+
import { isDeepStrictEqual } from "util";
|
|
32
|
+
|
|
33
|
+
// cli/templating/starter-game.ts
|
|
34
|
+
import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "fs";
|
|
35
|
+
import { dirname, join, relative, sep } from "path";
|
|
36
|
+
import { fileURLToPath } from "url";
|
|
37
|
+
var NOT_THE_GAME = /* @__PURE__ */ new Set([
|
|
38
|
+
"package.json",
|
|
39
|
+
"tsconfig.json",
|
|
40
|
+
".oxlintrc.json",
|
|
41
|
+
".oxfmtrc.json",
|
|
42
|
+
".gitignore",
|
|
43
|
+
"globals.d.ts",
|
|
44
|
+
"pnpm-workspace.yaml",
|
|
45
|
+
"vite.config.ts",
|
|
46
|
+
"vitest.config.ts",
|
|
47
|
+
"vitest.engine.config.ts",
|
|
48
|
+
"playwright.config.ts",
|
|
49
|
+
join("testing", "e2e", "global-setup.ts"),
|
|
50
|
+
"test-setup.ts",
|
|
51
|
+
"README.md",
|
|
52
|
+
"DESIGN.md",
|
|
53
|
+
"CLAUDE.md",
|
|
54
|
+
// The manifest is not copied: `createPackageFiles` has already written one
|
|
55
|
+
// carrying the identifier and name the author gave, and the game's settings
|
|
56
|
+
// are merged onto it from `starterGameSettings()`.
|
|
57
|
+
"seriousgaming.sdk.json"
|
|
58
|
+
]);
|
|
59
|
+
var ARTEFACTS = /* @__PURE__ */ new Set([
|
|
60
|
+
"node_modules",
|
|
61
|
+
"dist",
|
|
62
|
+
".seriousgaming-sdk",
|
|
63
|
+
"test-results",
|
|
64
|
+
"playwright-report",
|
|
65
|
+
".claude"
|
|
66
|
+
]);
|
|
67
|
+
var STARTER_NAME = "Lemonade Stand";
|
|
68
|
+
var SUBSTITUTABLE = /\.(ts|tsx|md|html|json)$/;
|
|
69
|
+
function starterDirectory() {
|
|
70
|
+
const here = fileURLToPath(import.meta.url);
|
|
71
|
+
const isDev = here.includes(`${sep}cli${sep}templating${sep}`) || here.includes("/cli/templating/");
|
|
72
|
+
return isDev ? join(dirname(here), "../../../examples/lemonade") : join(dirname(here), "./templates/starter-game");
|
|
73
|
+
}
|
|
74
|
+
function starterGameSettings() {
|
|
75
|
+
const manifest = JSON.parse(
|
|
76
|
+
readFileSync(join(starterDirectory(), "seriousgaming.sdk.json"), "utf-8")
|
|
77
|
+
);
|
|
78
|
+
const { identifier, locales, supportedLocales, ...settings } = manifest;
|
|
79
|
+
void identifier;
|
|
80
|
+
void locales;
|
|
81
|
+
void supportedLocales;
|
|
82
|
+
return settings;
|
|
83
|
+
}
|
|
84
|
+
function scaffoldStarterGame(options) {
|
|
85
|
+
const { packagePath, name } = options;
|
|
86
|
+
const filesCreated = [];
|
|
87
|
+
const warnings = [];
|
|
88
|
+
const source = starterDirectory();
|
|
89
|
+
if (!existsSync(source)) {
|
|
90
|
+
return {
|
|
91
|
+
filesCreated,
|
|
92
|
+
warnings: [`The starter game is missing from ${source}`]
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
for (const path of gameFiles(source)) {
|
|
96
|
+
const from = join(source, path);
|
|
97
|
+
const to = join(packagePath, path);
|
|
98
|
+
mkdirSync(dirname(to), { recursive: true });
|
|
99
|
+
if (SUBSTITUTABLE.test(path) && name !== STARTER_NAME) {
|
|
100
|
+
writeFileSync(to, readFileSync(from, "utf-8").split(STARTER_NAME).join(name), "utf-8");
|
|
101
|
+
} else {
|
|
102
|
+
copyFileSync(from, to);
|
|
103
|
+
}
|
|
104
|
+
filesCreated.push(to);
|
|
105
|
+
}
|
|
106
|
+
return { filesCreated, warnings };
|
|
107
|
+
}
|
|
108
|
+
function gameFiles(root) {
|
|
109
|
+
const found = [];
|
|
110
|
+
const walk = (directory) => {
|
|
111
|
+
for (const entry of readdirSync(directory, { withFileTypes: true }).sort(
|
|
112
|
+
(a, b) => a.name.localeCompare(b.name)
|
|
113
|
+
)) {
|
|
114
|
+
if (ARTEFACTS.has(entry.name)) continue;
|
|
115
|
+
const full = join(directory, entry.name);
|
|
116
|
+
const path = relative(root, full);
|
|
117
|
+
if (entry.isDirectory()) {
|
|
118
|
+
walk(full);
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (NOT_THE_GAME.has(path)) continue;
|
|
122
|
+
if (entry.name === "types.ts") continue;
|
|
123
|
+
found.push(path);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
walk(root);
|
|
127
|
+
return found;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// cli/templating/package.ts
|
|
131
|
+
function getSDKVersion() {
|
|
132
|
+
try {
|
|
133
|
+
return readSdkToolsVersion();
|
|
134
|
+
} catch {
|
|
135
|
+
console.warn("Warning: Could not read SDK version, defaulting to 0.0.0");
|
|
136
|
+
return "0.0.0";
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async function createPackageFiles(options) {
|
|
140
|
+
const { packagePath, identifier, name, version, empty = false } = options;
|
|
141
|
+
const filesCreated = [];
|
|
142
|
+
try {
|
|
143
|
+
const configPath = join2(packagePath, "seriousgaming.sdk.json");
|
|
144
|
+
const packageJsonPath = join2(packagePath, "package.json");
|
|
145
|
+
const tsconfigPath = join2(packagePath, "tsconfig.json");
|
|
146
|
+
const readmePath = join2(packagePath, "README.md");
|
|
147
|
+
const gitignorePath = join2(packagePath, ".gitignore");
|
|
148
|
+
const pnpmWorkspacePath = join2(packagePath, "pnpm-workspace.yaml");
|
|
149
|
+
const claudeMdPath = join2(packagePath, "CLAUDE.md");
|
|
150
|
+
if (existsSync2(configPath)) {
|
|
151
|
+
return {
|
|
152
|
+
success: false,
|
|
153
|
+
error: "seriousgaming.sdk.json already exists in this directory"
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
if (existsSync2(packageJsonPath)) {
|
|
157
|
+
return {
|
|
158
|
+
success: false,
|
|
159
|
+
error: "package.json already exists in this directory"
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
const sdkVersion = getSDKVersion();
|
|
163
|
+
const sdkConfig = {
|
|
164
|
+
identifier,
|
|
165
|
+
supportedLocales: ["en"],
|
|
166
|
+
locales: { en: { name } }
|
|
167
|
+
};
|
|
168
|
+
writeJsonFile(configPath, sdkConfig);
|
|
169
|
+
filesCreated.push(configPath);
|
|
170
|
+
await renderAndWriteTemplate("package/package.json.liquid", packageJsonPath, {
|
|
171
|
+
identifier,
|
|
172
|
+
version,
|
|
173
|
+
name,
|
|
174
|
+
sdkVersion
|
|
175
|
+
});
|
|
176
|
+
filesCreated.push(packageJsonPath);
|
|
177
|
+
await renderAndWriteTemplate("package/tsconfig.json.liquid", tsconfigPath, {});
|
|
178
|
+
filesCreated.push(tsconfigPath);
|
|
179
|
+
await renderAndWriteTemplate("package/README.md.liquid", readmePath, {
|
|
180
|
+
name,
|
|
181
|
+
identifier,
|
|
182
|
+
version
|
|
183
|
+
});
|
|
184
|
+
filesCreated.push(readmePath);
|
|
185
|
+
const oxfmtPath = join2(packagePath, ".oxfmtrc.json");
|
|
186
|
+
copyStaticFile("package/oxfmtrc.json.template", oxfmtPath);
|
|
187
|
+
filesCreated.push(oxfmtPath);
|
|
188
|
+
const oxlintPath = join2(packagePath, ".oxlintrc.json");
|
|
189
|
+
copyStaticFile("package/oxlintrc.json.template", oxlintPath);
|
|
190
|
+
filesCreated.push(oxlintPath);
|
|
191
|
+
copyStaticFile("package/gitignore.template", gitignorePath);
|
|
192
|
+
filesCreated.push(gitignorePath);
|
|
193
|
+
copyStaticFile("package/pnpm-workspace.yaml.template", pnpmWorkspacePath);
|
|
194
|
+
filesCreated.push(pnpmWorkspacePath);
|
|
195
|
+
const globalsDtsPath = join2(packagePath, "globals.d.ts");
|
|
196
|
+
copyStaticFile("package/globals.d.ts.template", globalsDtsPath);
|
|
197
|
+
filesCreated.push(globalsDtsPath);
|
|
198
|
+
copyStaticFile("package/CLAUDE.md.template", claudeMdPath);
|
|
199
|
+
filesCreated.push(claudeMdPath);
|
|
200
|
+
const claudeRulesDir = join2(packagePath, ".claude", "rules");
|
|
201
|
+
mkdirSync2(claudeRulesDir, { recursive: true });
|
|
202
|
+
const claudeRules = [
|
|
203
|
+
"workflow-create-capability.md",
|
|
204
|
+
"workflow-create-engine.md",
|
|
205
|
+
"workflow-create-user-interface.md",
|
|
206
|
+
"workflow-create-endpoint.md",
|
|
207
|
+
"workflow-create-guide.md",
|
|
208
|
+
"workflow-create-presentation.md",
|
|
209
|
+
"workflow-update-sdk-version.md",
|
|
210
|
+
"workflow-test-engine-or-ui.md",
|
|
211
|
+
"workflow-publish-package.md"
|
|
212
|
+
];
|
|
213
|
+
for (const rule of claudeRules) {
|
|
214
|
+
const dest = join2(claudeRulesDir, rule);
|
|
215
|
+
copyStaticFile(`package/claude/rules/${rule}`, dest);
|
|
216
|
+
filesCreated.push(dest);
|
|
217
|
+
}
|
|
218
|
+
const claudeSettingsPath = join2(packagePath, ".claude", "settings.json");
|
|
219
|
+
copyStaticFile("package/claude/settings.json.template", claudeSettingsPath);
|
|
220
|
+
filesCreated.push(claudeSettingsPath);
|
|
221
|
+
const designMdPath = join2(packagePath, "DESIGN.md");
|
|
222
|
+
await renderAndWriteTemplate("package/DESIGN.md.liquid", designMdPath, {
|
|
223
|
+
name,
|
|
224
|
+
identifier
|
|
225
|
+
});
|
|
226
|
+
filesCreated.push(designMdPath);
|
|
227
|
+
const viteConfigPath = join2(packagePath, "vite.config.ts");
|
|
228
|
+
await renderAndWriteTemplate("package/vite.config.ts.liquid", viteConfigPath, {});
|
|
229
|
+
filesCreated.push(viteConfigPath);
|
|
230
|
+
const vitestConfigPath = join2(packagePath, "vitest.config.ts");
|
|
231
|
+
await renderAndWriteTemplate("package/vitest.config.ts.liquid", vitestConfigPath, {});
|
|
232
|
+
filesCreated.push(vitestConfigPath);
|
|
233
|
+
const testSetupPath = join2(packagePath, "test-setup.ts");
|
|
234
|
+
await renderAndWriteTemplate("package/test-setup.ts.liquid", testSetupPath, {});
|
|
235
|
+
filesCreated.push(testSetupPath);
|
|
236
|
+
const playwrightConfigPath = join2(packagePath, "playwright.config.ts");
|
|
237
|
+
await renderAndWriteTemplate(
|
|
238
|
+
"package/playwright.config.ts.liquid",
|
|
239
|
+
playwrightConfigPath,
|
|
240
|
+
{}
|
|
241
|
+
);
|
|
242
|
+
filesCreated.push(playwrightConfigPath);
|
|
243
|
+
const globalSetupPath = join2(packagePath, "testing", "e2e", "global-setup.ts");
|
|
244
|
+
mkdirSync2(dirname2(globalSetupPath), { recursive: true });
|
|
245
|
+
copyStaticFile("package/global-setup.ts.template", globalSetupPath);
|
|
246
|
+
filesCreated.push(globalSetupPath);
|
|
247
|
+
const vitestEngineConfigPath = join2(packagePath, "vitest.engine.config.ts");
|
|
248
|
+
await renderAndWriteTemplate(
|
|
249
|
+
"package/vitest.engine.config.ts.liquid",
|
|
250
|
+
vitestEngineConfigPath,
|
|
251
|
+
{}
|
|
252
|
+
);
|
|
253
|
+
filesCreated.push(vitestEngineConfigPath);
|
|
254
|
+
let installFailed = false;
|
|
255
|
+
if (!options.skipInstall) {
|
|
256
|
+
console.error("\nInstalling dependencies...");
|
|
257
|
+
installFailed = !await runNpmInstall(packagePath);
|
|
258
|
+
}
|
|
259
|
+
if (!empty) {
|
|
260
|
+
const starter = scaffoldStarterGame({ packagePath, name });
|
|
261
|
+
filesCreated.push(...starter.filesCreated);
|
|
262
|
+
for (const warning of starter.warnings) console.warn(`Warning: ${warning}`);
|
|
263
|
+
const settings = updatePackageFiles({
|
|
264
|
+
packagePath,
|
|
265
|
+
newSettings: {
|
|
266
|
+
identifier,
|
|
267
|
+
supportedLocales: ["en"],
|
|
268
|
+
locales: { en: { name } },
|
|
269
|
+
...starterGameSettings()
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
if (!settings.success) {
|
|
273
|
+
console.warn(
|
|
274
|
+
`Warning: Failed to write the starter game settings: ${settings.error}`
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return {
|
|
279
|
+
success: true,
|
|
280
|
+
filesCreated,
|
|
281
|
+
...installFailed ? { installFailed } : {}
|
|
282
|
+
};
|
|
283
|
+
} catch (error) {
|
|
284
|
+
return {
|
|
285
|
+
success: false,
|
|
286
|
+
error: error instanceof Error ? error.message : "Unknown error occurred",
|
|
287
|
+
filesCreated
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
async function runNpmInstall(packagePath) {
|
|
292
|
+
return new Promise((resolve) => {
|
|
293
|
+
const npm = spawn("pnpm", ["install"], {
|
|
294
|
+
cwd: packagePath,
|
|
295
|
+
shell: true,
|
|
296
|
+
stdio: isJsonOutput() ? ["ignore", 2, "inherit"] : "inherit"
|
|
297
|
+
});
|
|
298
|
+
npm.on("close", (code) => {
|
|
299
|
+
resolve(code === 0);
|
|
300
|
+
});
|
|
301
|
+
npm.on("error", (error) => {
|
|
302
|
+
console.error("Failed to run pnpm install:", error.message);
|
|
303
|
+
resolve(false);
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
function updatePackageFiles(options) {
|
|
308
|
+
try {
|
|
309
|
+
const configPath = join2(options.packagePath, "seriousgaming.sdk.json");
|
|
310
|
+
if (!existsSync2(configPath)) {
|
|
311
|
+
return { success: false, error: "seriousgaming.sdk.json not found" };
|
|
312
|
+
}
|
|
313
|
+
const config = JSON.parse(readFileSync2(configPath, "utf-8"));
|
|
314
|
+
const existingIdentifier = config.identifier;
|
|
315
|
+
if (typeof existingIdentifier !== "string") {
|
|
316
|
+
return {
|
|
317
|
+
success: false,
|
|
318
|
+
error: "Invalid seriousgaming.sdk.json: identifier not found"
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
const validation = validatePackageManifest(options.newSettings);
|
|
322
|
+
if (!validation.valid) {
|
|
323
|
+
return {
|
|
324
|
+
success: false,
|
|
325
|
+
error: `Validation failed: ${validation.errors}`
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
if (isDeepStrictEqual(config, options.newSettings)) {
|
|
329
|
+
return { success: true, filesUpdated: [] };
|
|
330
|
+
}
|
|
331
|
+
writeFileSync2(configPath, JSON.stringify(options.newSettings, null, 4) + "\n", "utf-8");
|
|
332
|
+
return { success: true, filesUpdated: [configPath] };
|
|
333
|
+
} catch (error) {
|
|
334
|
+
return {
|
|
335
|
+
success: false,
|
|
336
|
+
error: error instanceof Error ? error.message : "Unknown error occurred"
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// cli/templating/capability.ts
|
|
342
|
+
var capabilityMeta = getResourceMeta("capability");
|
|
343
|
+
function createCapabilityFiles(options) {
|
|
344
|
+
const { variablesSchema, scope } = options;
|
|
345
|
+
const normalizedSchema = normalizeVariablesSchema(variablesSchema);
|
|
346
|
+
const definition = {
|
|
347
|
+
variablesSchema: normalizedSchema ?? variablesSchema,
|
|
348
|
+
...presentFields({ scope })
|
|
349
|
+
};
|
|
350
|
+
return createResourceFiles(capabilityMeta, options, { definition });
|
|
351
|
+
}
|
|
352
|
+
function updateCapabilityFiles(options) {
|
|
353
|
+
return updateResourceFiles(capabilityMeta, options);
|
|
354
|
+
}
|
|
355
|
+
function deleteCapabilityFiles(options) {
|
|
356
|
+
return deleteResourceFiles(capabilityMeta, options);
|
|
357
|
+
}
|
|
358
|
+
function findCapabilityReferences(options) {
|
|
359
|
+
return findResourceReferences(capabilityMeta, options);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// cli/templating/engine.ts
|
|
363
|
+
var engineMeta = getResourceMeta("engine");
|
|
364
|
+
function createEngineFiles(options) {
|
|
365
|
+
const { reads, writes, uses, settings, aggregate = false } = options;
|
|
366
|
+
return createResourceFiles(engineMeta, options, {
|
|
367
|
+
definition: presentFields({
|
|
368
|
+
reads,
|
|
369
|
+
writes,
|
|
370
|
+
uses,
|
|
371
|
+
settings
|
|
372
|
+
}),
|
|
373
|
+
files: [
|
|
374
|
+
{
|
|
375
|
+
path: "logic.ts",
|
|
376
|
+
template: aggregate ? "engine/logic-aggregate.ts.liquid" : "engine/logic.ts.liquid"
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
path: "logic.test.ts",
|
|
380
|
+
template: aggregate ? "engine/logic-aggregate.test.ts.liquid" : "engine/logic.test.ts.liquid",
|
|
381
|
+
data: { identifier: "engine" }
|
|
382
|
+
}
|
|
383
|
+
],
|
|
384
|
+
alreadyExists: (dir) => `This game already has an engine, at ${dir}. A game holds one: change it with \`update engine\``
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
function updateEngineFiles(options) {
|
|
388
|
+
return updateResourceFiles(engineMeta, options);
|
|
389
|
+
}
|
|
390
|
+
function deleteEngineFiles(options) {
|
|
391
|
+
return deleteResourceFiles(engineMeta, options);
|
|
392
|
+
}
|
|
393
|
+
function findEngineReferences(options) {
|
|
394
|
+
return findResourceReferences(engineMeta, options);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// cli/templating/ui.ts
|
|
398
|
+
var userInterfaceMeta = getResourceMeta("ui");
|
|
399
|
+
function createUserInterfaceFiles(options) {
|
|
400
|
+
const { name, reads, writes, crossTeamReads, settings } = options;
|
|
401
|
+
const data = { name };
|
|
402
|
+
return createResourceFiles(userInterfaceMeta, options, {
|
|
403
|
+
definition: presentFields({
|
|
404
|
+
reads,
|
|
405
|
+
crossTeamReads,
|
|
406
|
+
writes,
|
|
407
|
+
settings
|
|
408
|
+
}),
|
|
409
|
+
files: [
|
|
410
|
+
{ path: "index.html", template: "ui/index.html.liquid", data },
|
|
411
|
+
{ path: "src/main.tsx", template: "ui/src/main.tsx.liquid", data },
|
|
412
|
+
{ path: "src/App.tsx", template: "ui/src/App.tsx.liquid", data },
|
|
413
|
+
{ path: "src/App.test.tsx", template: "ui/src/App.test.tsx.liquid", data },
|
|
414
|
+
{ path: "src/i18n.ts", template: "ui/src/i18n.ts.liquid", data },
|
|
415
|
+
{ path: "src/theme.ts", template: "ui/src/theme.ts.liquid", data }
|
|
416
|
+
]
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
function updateUserInterfaceFiles(options) {
|
|
420
|
+
return updateResourceFiles(userInterfaceMeta, options);
|
|
421
|
+
}
|
|
422
|
+
function deleteUserInterfaceFiles(options) {
|
|
423
|
+
return deleteResourceFiles(userInterfaceMeta, options);
|
|
424
|
+
}
|
|
425
|
+
function findUserInterfaceReferences(options) {
|
|
426
|
+
return findResourceReferences(userInterfaceMeta, options);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// cli/templating/session.ts
|
|
430
|
+
var sessionUserInterfaceMeta = getResourceMeta("session");
|
|
431
|
+
function createSessionUserInterfaceFiles(options) {
|
|
432
|
+
const { name, reads, writes, settings } = options;
|
|
433
|
+
const data = { name };
|
|
434
|
+
return createResourceFiles(sessionUserInterfaceMeta, options, {
|
|
435
|
+
definition: presentFields({
|
|
436
|
+
reads,
|
|
437
|
+
writes,
|
|
438
|
+
settings
|
|
439
|
+
}),
|
|
440
|
+
files: [
|
|
441
|
+
{ path: "index.html", template: "ui/index.html.liquid", data },
|
|
442
|
+
{ path: "src/main.tsx", template: "session/src/main.tsx.liquid", data },
|
|
443
|
+
{ path: "src/App.tsx", template: "session/src/App.tsx.liquid", data },
|
|
444
|
+
{ path: "src/App.test.tsx", template: "session/src/App.test.tsx.liquid", data },
|
|
445
|
+
{ path: "src/i18n.ts", template: "session/src/i18n.ts.liquid", data },
|
|
446
|
+
{ path: "src/theme.ts", template: "session/src/theme.ts.liquid", data }
|
|
447
|
+
]
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
function updateSessionUserInterfaceFiles(options) {
|
|
451
|
+
return updateResourceFiles(sessionUserInterfaceMeta, options);
|
|
452
|
+
}
|
|
453
|
+
function deleteSessionUserInterfaceFiles(options) {
|
|
454
|
+
return deleteResourceFiles(sessionUserInterfaceMeta, options);
|
|
455
|
+
}
|
|
456
|
+
function findSessionUserInterfaceReferences(options) {
|
|
457
|
+
return findResourceReferences(sessionUserInterfaceMeta, options);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// cli/templating/waiting-room.ts
|
|
461
|
+
var waitingRoomUserInterfaceMeta = getResourceMeta("waiting_room");
|
|
462
|
+
function createWaitingRoomUserInterfaceFiles(options) {
|
|
463
|
+
const { name, reads, crossTeamReads, writes, endpoints, settings } = options;
|
|
464
|
+
const data = { name };
|
|
465
|
+
return createResourceFiles(waitingRoomUserInterfaceMeta, options, {
|
|
466
|
+
definition: presentFields({
|
|
467
|
+
reads,
|
|
468
|
+
crossTeamReads,
|
|
469
|
+
writes,
|
|
470
|
+
endpoints,
|
|
471
|
+
settings
|
|
472
|
+
}),
|
|
473
|
+
files: [
|
|
474
|
+
{ path: "index.html", template: "waiting-room/index.html.liquid", data },
|
|
475
|
+
{ path: "src/main.tsx", template: "waiting-room/src/main.tsx.liquid", data },
|
|
476
|
+
{ path: "src/App.tsx", template: "waiting-room/src/App.tsx.liquid", data },
|
|
477
|
+
{ path: "src/App.test.tsx", template: "waiting-room/src/App.test.tsx.liquid", data },
|
|
478
|
+
{ path: "src/i18n.ts", template: "waiting-room/src/i18n.ts.liquid", data },
|
|
479
|
+
{ path: "src/theme.ts", template: "waiting-room/src/theme.ts.liquid", data }
|
|
480
|
+
]
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
function updateWaitingRoomUserInterfaceFiles(options) {
|
|
484
|
+
return updateResourceFiles(waitingRoomUserInterfaceMeta, options);
|
|
485
|
+
}
|
|
486
|
+
function deleteWaitingRoomUserInterfaceFiles(options) {
|
|
487
|
+
return deleteResourceFiles(waitingRoomUserInterfaceMeta, options);
|
|
488
|
+
}
|
|
489
|
+
function findWaitingRoomUserInterfaceReferences(options) {
|
|
490
|
+
return findResourceReferences(waitingRoomUserInterfaceMeta, options);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// cli/templating/presentation.ts
|
|
494
|
+
var presentationMeta = getResourceMeta("presentation");
|
|
495
|
+
function createPresentationFiles(options) {
|
|
496
|
+
const { name, locales, reads, settings } = options;
|
|
497
|
+
const data = { name };
|
|
498
|
+
return createResourceFiles(presentationMeta, options, {
|
|
499
|
+
definition: presentFields({
|
|
500
|
+
locales,
|
|
501
|
+
reads,
|
|
502
|
+
settings
|
|
503
|
+
}),
|
|
504
|
+
files: [
|
|
505
|
+
{ path: "index.html", template: "presentation/index.html.liquid", data },
|
|
506
|
+
...["main.tsx", "App.tsx", "Slides.tsx", "i18n.ts"].map((file) => ({
|
|
507
|
+
path: `src/${file}`,
|
|
508
|
+
template: `presentation/src/${file}.liquid`,
|
|
509
|
+
data
|
|
510
|
+
}))
|
|
511
|
+
]
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
function updatePresentationFiles(options) {
|
|
515
|
+
return updateResourceFiles(presentationMeta, options);
|
|
516
|
+
}
|
|
517
|
+
function deletePresentationFiles(options) {
|
|
518
|
+
return deleteResourceFiles(presentationMeta, options);
|
|
519
|
+
}
|
|
520
|
+
function findPresentationReferences(options) {
|
|
521
|
+
return findResourceReferences(presentationMeta, options);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
// cli/templating/tick-controller.ts
|
|
525
|
+
var tickControllerMeta = getResourceMeta("tick_controller");
|
|
526
|
+
function createTickControllerFiles(options) {
|
|
527
|
+
const { reads, uses, settings } = options;
|
|
528
|
+
return createResourceFiles(tickControllerMeta, options, {
|
|
529
|
+
definition: presentFields({
|
|
530
|
+
reads,
|
|
531
|
+
uses,
|
|
532
|
+
settings
|
|
533
|
+
}),
|
|
534
|
+
files: [{ path: "logic.ts", template: "tick-controller/logic.ts.liquid" }]
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
function deleteTickControllerFiles(options) {
|
|
538
|
+
return deleteResourceFiles(tickControllerMeta, options);
|
|
539
|
+
}
|
|
540
|
+
function findTickControllerReferences(options) {
|
|
541
|
+
return findResourceReferences(tickControllerMeta, options);
|
|
542
|
+
}
|
|
543
|
+
function updateTickControllerFiles(options) {
|
|
544
|
+
return updateResourceFiles(tickControllerMeta, options);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// cli/templating/hook.ts
|
|
548
|
+
var hookMeta = getResourceMeta("hook");
|
|
549
|
+
function createHookFiles(options) {
|
|
550
|
+
const { identifier, signal, reads, writes, uses, settings } = options;
|
|
551
|
+
const definition = {
|
|
552
|
+
signal,
|
|
553
|
+
...presentFields({ reads, writes, uses, settings })
|
|
554
|
+
};
|
|
555
|
+
return createResourceFiles(hookMeta, options, {
|
|
556
|
+
definition,
|
|
557
|
+
files: [
|
|
558
|
+
{ path: "logic/logic.ts", template: "hook/logic.ts.liquid" },
|
|
559
|
+
{
|
|
560
|
+
path: "logic/logic.test.ts",
|
|
561
|
+
template: "hook/logic.test.ts.liquid",
|
|
562
|
+
data: { identifier, signal }
|
|
563
|
+
}
|
|
564
|
+
]
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
function deleteHookFiles(options) {
|
|
568
|
+
return deleteResourceFiles(hookMeta, options);
|
|
569
|
+
}
|
|
570
|
+
function findHookReferences(options) {
|
|
571
|
+
return findResourceReferences(hookMeta, options);
|
|
572
|
+
}
|
|
573
|
+
function updateHookFiles(options) {
|
|
574
|
+
return updateResourceFiles(hookMeta, options);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// cli/templating/validator.ts
|
|
578
|
+
var validatorMeta = getResourceMeta("validator");
|
|
579
|
+
function createValidatorFiles(options) {
|
|
580
|
+
const { identifier, reads, settings } = options;
|
|
581
|
+
return createResourceFiles(validatorMeta, options, {
|
|
582
|
+
definition: presentFields({ reads, settings }),
|
|
583
|
+
files: [
|
|
584
|
+
{ path: "logic/logic.ts", template: "validator/logic.ts.liquid" },
|
|
585
|
+
{
|
|
586
|
+
path: "logic/logic.test.ts",
|
|
587
|
+
template: "validator/logic.test.ts.liquid",
|
|
588
|
+
data: { identifier }
|
|
589
|
+
}
|
|
590
|
+
]
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
function deleteValidatorFiles(options) {
|
|
594
|
+
return deleteResourceFiles(validatorMeta, options);
|
|
595
|
+
}
|
|
596
|
+
function findValidatorReferences(options) {
|
|
597
|
+
return findResourceReferences(validatorMeta, options);
|
|
598
|
+
}
|
|
599
|
+
function updateValidatorFiles(options) {
|
|
600
|
+
return updateResourceFiles(validatorMeta, options);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
// cli/templating/endpoint.ts
|
|
604
|
+
var endpointMeta = getResourceMeta("endpoint");
|
|
605
|
+
function createEndpointFiles(options) {
|
|
606
|
+
const { identifier, displayName, description, requestSchema, responseSchema } = options;
|
|
607
|
+
const { reads, uses, scope, visibility, writes, settings } = options;
|
|
608
|
+
const definition = {
|
|
609
|
+
...presentFields({ displayName, description }),
|
|
610
|
+
requestSchema: { ...requestSchema },
|
|
611
|
+
responseSchema: { ...responseSchema },
|
|
612
|
+
...presentFields({ scope, visibility, reads, writes, uses, settings })
|
|
613
|
+
};
|
|
614
|
+
return createResourceFiles(endpointMeta, options, {
|
|
615
|
+
definition,
|
|
616
|
+
files: [
|
|
617
|
+
{
|
|
618
|
+
path: "logic/logic.ts",
|
|
619
|
+
template: "endpoint/logic.ts.liquid",
|
|
620
|
+
data: {
|
|
621
|
+
writes: Boolean(writes && writes.length > 0),
|
|
622
|
+
scenario: scope === "scenario"
|
|
623
|
+
}
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
path: "logic/logic.test.ts",
|
|
627
|
+
template: "endpoint/logic.test.ts.liquid",
|
|
628
|
+
data: {
|
|
629
|
+
identifier,
|
|
630
|
+
hasSettings: Boolean(settings && settings.length > 0),
|
|
631
|
+
scenario: scope === "scenario"
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
]
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
function deleteEndpointFiles(options) {
|
|
638
|
+
return deleteResourceFiles(endpointMeta, options);
|
|
639
|
+
}
|
|
640
|
+
function findEndpointReferences(options) {
|
|
641
|
+
return findResourceReferences(endpointMeta, options);
|
|
642
|
+
}
|
|
643
|
+
function updateEndpointFiles(options) {
|
|
644
|
+
return updateResourceFiles(endpointMeta, options);
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
// cli/templating/settings.ts
|
|
648
|
+
var settingsMeta = getPluralResourceMeta("settings");
|
|
649
|
+
function normalizeSettingsSchema(schema) {
|
|
650
|
+
const input = schema;
|
|
651
|
+
const normalized = normalizeVariablesSchema(input) ?? input;
|
|
652
|
+
if (normalized === input) return input;
|
|
653
|
+
const { required: _required, ...wrapped } = normalized;
|
|
654
|
+
return wrapped;
|
|
655
|
+
}
|
|
656
|
+
function createSettingsFiles(options) {
|
|
657
|
+
const definition = {
|
|
658
|
+
settingsSchema: normalizeSettingsSchema(options.settingsSchema)
|
|
659
|
+
};
|
|
660
|
+
return createResourceFiles(settingsMeta, options, { definition });
|
|
661
|
+
}
|
|
662
|
+
function updateSettingsFiles(options) {
|
|
663
|
+
return updateResourceFiles(settingsMeta, {
|
|
664
|
+
...options,
|
|
665
|
+
newDefinition: {
|
|
666
|
+
...options.newDefinition,
|
|
667
|
+
settingsSchema: normalizeSettingsSchema(options.newDefinition.settingsSchema)
|
|
668
|
+
}
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
function deleteSettingsFiles(options) {
|
|
672
|
+
return deleteResourceFiles(settingsMeta, options);
|
|
673
|
+
}
|
|
674
|
+
function findSettingsReferences(options) {
|
|
675
|
+
return findResourceReferences(settingsMeta, options);
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
// cli/templating/settings-editor.ts
|
|
679
|
+
function createSettingsEditorFiles(options) {
|
|
680
|
+
const { slot, name, configures = [], endpoints } = options;
|
|
681
|
+
const data = { name };
|
|
682
|
+
const definition = {
|
|
683
|
+
configures,
|
|
684
|
+
...presentFields({ endpoints })
|
|
685
|
+
};
|
|
686
|
+
return createResourceFiles(getResourceMeta(slot), options, {
|
|
687
|
+
definition,
|
|
688
|
+
files: [
|
|
689
|
+
{ path: "index.html", template: "settings-editor/index.html.liquid", data },
|
|
690
|
+
{ path: "src/main.tsx", template: "settings-editor/src/main.tsx.liquid", data },
|
|
691
|
+
{ path: "src/theme.ts", template: "settings-editor/src/theme.ts.liquid", data },
|
|
692
|
+
{ path: "src/App.tsx", template: `${slot}/src/App.tsx.liquid`, data },
|
|
693
|
+
{ path: "src/App.test.tsx", template: `${slot}/src/App.test.tsx.liquid`, data },
|
|
694
|
+
{ path: "src/i18n.ts", template: `${slot}/src/i18n.ts.liquid`, data }
|
|
695
|
+
]
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
function updateSettingsEditorFiles(slot, options) {
|
|
699
|
+
return updateResourceFiles(getResourceMeta(slot), options);
|
|
700
|
+
}
|
|
701
|
+
function deleteSettingsEditorFiles(slot, options) {
|
|
702
|
+
return deleteResourceFiles(getResourceMeta(slot), options);
|
|
703
|
+
}
|
|
704
|
+
function findSettingsEditorReferences(slot, options) {
|
|
705
|
+
return findResourceReferences(getResourceMeta(slot), options);
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
export {
|
|
709
|
+
createPackageFiles,
|
|
710
|
+
updatePackageFiles,
|
|
711
|
+
createCapabilityFiles,
|
|
712
|
+
updateCapabilityFiles,
|
|
713
|
+
deleteCapabilityFiles,
|
|
714
|
+
findCapabilityReferences,
|
|
715
|
+
createEngineFiles,
|
|
716
|
+
updateEngineFiles,
|
|
717
|
+
deleteEngineFiles,
|
|
718
|
+
findEngineReferences,
|
|
719
|
+
createUserInterfaceFiles,
|
|
720
|
+
updateUserInterfaceFiles,
|
|
721
|
+
deleteUserInterfaceFiles,
|
|
722
|
+
findUserInterfaceReferences,
|
|
723
|
+
createSettingsEditorFiles,
|
|
724
|
+
updateSettingsEditorFiles,
|
|
725
|
+
deleteSettingsEditorFiles,
|
|
726
|
+
findSettingsEditorReferences,
|
|
727
|
+
createSessionUserInterfaceFiles,
|
|
728
|
+
updateSessionUserInterfaceFiles,
|
|
729
|
+
deleteSessionUserInterfaceFiles,
|
|
730
|
+
findSessionUserInterfaceReferences,
|
|
731
|
+
createWaitingRoomUserInterfaceFiles,
|
|
732
|
+
updateWaitingRoomUserInterfaceFiles,
|
|
733
|
+
deleteWaitingRoomUserInterfaceFiles,
|
|
734
|
+
findWaitingRoomUserInterfaceReferences,
|
|
735
|
+
createPresentationFiles,
|
|
736
|
+
updatePresentationFiles,
|
|
737
|
+
deletePresentationFiles,
|
|
738
|
+
findPresentationReferences,
|
|
739
|
+
createTickControllerFiles,
|
|
740
|
+
deleteTickControllerFiles,
|
|
741
|
+
findTickControllerReferences,
|
|
742
|
+
updateTickControllerFiles,
|
|
743
|
+
createHookFiles,
|
|
744
|
+
deleteHookFiles,
|
|
745
|
+
findHookReferences,
|
|
746
|
+
updateHookFiles,
|
|
747
|
+
createValidatorFiles,
|
|
748
|
+
deleteValidatorFiles,
|
|
749
|
+
findValidatorReferences,
|
|
750
|
+
updateValidatorFiles,
|
|
751
|
+
createEndpointFiles,
|
|
752
|
+
deleteEndpointFiles,
|
|
753
|
+
findEndpointReferences,
|
|
754
|
+
updateEndpointFiles,
|
|
755
|
+
normalizeSettingsSchema,
|
|
756
|
+
createSettingsFiles,
|
|
757
|
+
updateSettingsFiles,
|
|
758
|
+
deleteSettingsFiles,
|
|
759
|
+
findSettingsReferences
|
|
760
|
+
};
|