@seriousgaming/sdk-tools 1.5.0 → 1.6.1
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 +350 -0
- package/dist/bundling/ui-bundler.d.ts +12 -0
- package/dist/cli-25RWY5BQ.js +41 -0
- package/dist/cli-2BH7FX27.js +52 -0
- package/dist/cli-2GZYGRVL.js +36 -0
- package/dist/cli-2NU2LPEE.js +97 -0
- package/dist/cli-3BRC32CP.js +132 -0
- package/dist/cli-3D3ZXWOV.js +111 -0
- package/dist/cli-3ZKWV3PN.js +96 -0
- package/dist/cli-45OCBG53.js +60 -0
- package/dist/cli-4LKXZQ2B.js +48 -0
- package/dist/cli-4PXNOJQX.js +81 -0
- package/dist/cli-4SIWLHQO.js +717 -0
- package/dist/cli-4UWFQNGF.js +54 -0
- package/dist/cli-4VFZHLDG.js +202 -0
- package/dist/cli-4YB3ROVR.js +78 -0
- package/dist/cli-5ACDPCXI.js +21 -0
- package/dist/cli-5IAW3LIF.js +38 -0
- package/dist/cli-5SM367K7.js +30 -0
- package/dist/cli-64AB62PM.js +25 -0
- package/dist/cli-6K3VQQUS.js +307 -0
- package/dist/cli-6QB2VFPY.js +80 -0
- package/dist/cli-6SGCYEEC.js +649 -0
- package/dist/cli-6UTPHWRQ.js +207 -0
- package/dist/cli-6VNKQ3OX.js +391 -0
- package/dist/cli-72XDEFU3.js +61 -0
- package/dist/cli-7A6MKCUJ.js +463 -0
- package/dist/cli-7XLHO2FE.js +226 -0
- package/dist/cli-AV2FYC5G.js +225 -0
- package/dist/cli-B6YHEKIJ.js +248 -0
- package/dist/cli-BJMS3VX3.js +1837 -0
- package/dist/cli-BUQI5UU4.js +43 -0
- package/dist/cli-BWX5E7TQ.js +23 -0
- package/dist/cli-BYCHKSSH.js +1331 -0
- package/dist/cli-C3CMJSNL.js +89 -0
- package/dist/cli-C47GJATR.js +42 -0
- package/dist/cli-C5QOJJWX.js +46 -0
- package/dist/cli-C6ZLPK2U.js +124 -0
- package/dist/cli-CD5CIJZI.js +72 -0
- package/dist/cli-DDJYUKQG.js +36 -0
- package/dist/cli-DFBTZEBX.js +167 -0
- package/dist/cli-DOXRQ3S5.js +60 -0
- package/dist/cli-EVI36HEM.js +79 -0
- package/dist/cli-F2D4GGUA.js +549 -0
- package/dist/cli-FQRVFGN6.js +0 -0
- package/dist/cli-FWFRKQNE.js +11 -0
- package/dist/cli-G6CANSPL.js +88 -0
- package/dist/cli-GFNDW2DL.js +124 -0
- package/dist/cli-HCRTYQQS.js +16 -0
- package/dist/cli-HFX3YPUL.js +76 -0
- package/dist/cli-HKORECAG.js +53 -0
- package/dist/cli-HOE3WLFH.js +73 -0
- package/dist/cli-HSIHDN6K.js +187 -0
- package/dist/cli-HW53ICZC.js +89 -0
- package/dist/cli-IDVUHGKG.js +218 -0
- package/dist/cli-IEMKI7J7.js +1387 -0
- package/dist/cli-ILFDANBR.js +101 -0
- package/dist/cli-ILKCQNM6.js +8 -0
- package/dist/cli-IP4RXGHM.js +2847 -0
- package/dist/cli-IUS2YCD3.js +31 -0
- package/dist/cli-J4DKUUTK.js +138 -0
- package/dist/cli-J4UBELKF.js +37 -0
- package/dist/cli-JJSWBW4H.js +89 -0
- package/dist/cli-JVI24FI6.js +68 -0
- package/dist/cli-JZCLIT3O.js +135 -0
- package/dist/cli-JZOZOEZM.js +131 -0
- package/dist/cli-KGM6RRQW.js +185 -0
- package/dist/cli-KGT5L7VZ.js +13641 -0
- package/dist/cli-KOGRWFN7.js +89 -0
- package/dist/cli-KSGB2ZLK.js +101 -0
- package/dist/cli-L7VYSXQK.js +243 -0
- package/dist/cli-LK3V4RI5.js +36 -0
- package/dist/cli-LQOHATY2.js +126 -0
- package/dist/cli-MJUYJIEP.js +13 -0
- package/dist/cli-MJV47HKI.js +143 -0
- package/dist/cli-MMN4BPO4.js +145 -0
- package/dist/cli-MOPSZ3CS.js +88 -0
- package/dist/cli-MU5LB43S.js +136 -0
- package/dist/cli-MYJGMA6U.js +40 -0
- package/dist/cli-N24OHSAN.js +36 -0
- package/dist/cli-N45DREM4.js +99 -0
- package/dist/cli-N6H6T2E2.js +616 -0
- package/dist/cli-NROTDF5Y.js +182 -0
- package/dist/cli-O5ABH2WK.js +226 -0
- package/dist/cli-OMWC75CC.js +256 -0
- package/dist/cli-OXAUOWCN.js +50 -0
- package/dist/cli-PGCIHPU7.js +143 -0
- package/dist/cli-Q6ZBZYK2.js +35 -0
- package/dist/cli-QUNIRH7A.js +57 -0
- package/dist/cli-QUSCIUOM.js +142 -0
- package/dist/cli-QVASWX2A.js +187 -0
- package/dist/cli-QWQMPCL6.js +253 -0
- package/dist/cli-QY5NZAR7.js +97 -0
- package/dist/cli-R2MUZQE2.js +62 -0
- package/dist/cli-RCIWBCXD.js +36 -0
- package/dist/cli-RLEGRWFM.js +81 -0
- package/dist/cli-RSW6EBBD.js +89 -0
- package/dist/cli-RZITKPJX.js +367 -0
- package/dist/cli-S5IVGDDD.js +32 -0
- package/dist/cli-SRHBXZCN.js +159 -0
- package/dist/cli-TDSQSCX4.js +131 -0
- package/dist/cli-TIDQ4WUE.js +257 -0
- package/dist/cli-TT36JCU5.js +370 -0
- package/dist/cli-TTKICM5P.js +100 -0
- package/dist/cli-TTMBBEJC.js +131 -0
- package/dist/cli-UMEBPAZQ.js +16 -0
- package/dist/cli-UNAJ2OTE.js +15 -0
- package/dist/cli-UZZFNXRX.js +226 -0
- package/dist/cli-VDBW23SS.js +81 -0
- package/dist/cli-VL2P354N.js +46 -0
- package/dist/cli-VPRRICZA.js +304 -0
- package/dist/cli-VQ6HVQW4.js +4010 -0
- package/dist/cli-WR3NOY74.js +36 -0
- package/dist/cli-WU43JT4T.js +52 -0
- package/dist/cli-XAT25PRU.js +117 -0
- package/dist/cli-XOTNXEJA.js +124 -0
- package/dist/cli-XSLNH5PR.js +6417 -0
- package/dist/cli-XSVGKI3R.js +39 -0
- package/dist/cli-XZCJIKIV.js +124 -0
- package/dist/cli-Y3DDNMPX.js +97 -0
- package/dist/cli-Y3O5F4JN.js +90 -0
- package/dist/cli-YOTGR3NB.js +82 -0
- package/dist/cli-Z56ZIVA6.js +97 -0
- package/dist/cli-ZBN5KAIB.js +59 -0
- package/dist/cli-ZDOTXEKL.js +31 -0
- package/dist/cli-ZDUADFBY.js +88 -0
- package/dist/cli-ZJFQ7EEA.js +131 -0
- package/dist/cli-ZTWOE3ZT.js +65 -0
- package/dist/cli.js +148 -43093
- 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 +228 -48
- package/dist/core/session.d.ts +15 -1
- package/dist/dev/console/assets/{index-BVF8exas.js → index-CuMOOH9m.js} +1 -1
- package/dist/dev/console/index.html +1 -1
- package/dist/dev/shell.d.ts +19 -0
- package/dist/dev/surfaces.d.ts +7 -0
- package/dist/docs/ai-agents.md +1 -1
- 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.md +34 -0
- package/dist/docs/cli-and-dev-server.md +21 -0
- package/dist/docs/cli-reference.md +45 -31
- package/dist/docs/environment-variables.md +6 -0
- package/dist/docs/getting-started.md +1 -1
- package/dist/docs/guides/designing-a-game.md +29 -4
- package/dist/docs/guides/starter-game.md +3 -3
- package/dist/docs/guides/testing.md +33 -18
- package/dist/docs/guides/upgrading.md +19 -2
- package/dist/docs/page-index.md +10 -9
- package/dist/docs/recipes/e2e-testing.md +19 -20
- package/dist/playwright.js +32232 -0
- package/dist/templates/package/CLAUDE.md.template +7 -346
- package/dist/templates/package/claude/rules/workflow-create-engine.md +2 -2
- package/dist/templates/package/claude/rules/workflow-create-guide.md +2 -2
- 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 +3 -3
- package/dist/templates/package/global-setup.ts.template +7 -18
- package/dist/templates/package/playwright.config.ts.liquid +8 -11
- package/dist/templates/starter-game/playwright.config.ts +8 -11
- package/dist/templates/starter-game/testing/e2e/game.spec.ts +1 -1
- package/dist/templates/starter-game/testing/e2e/global-setup.ts +7 -18
- package/dist/utils/prompt.d.ts +5 -5
- package/dist/utils/resource-scan.d.ts +39 -0
- package/package.json +7 -3
|
@@ -0,0 +1,649 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
validatePackage
|
|
4
|
+
} from "./cli-BJMS3VX3.js";
|
|
5
|
+
import "./cli-ILKCQNM6.js";
|
|
6
|
+
import "./cli-7XLHO2FE.js";
|
|
7
|
+
import "./cli-KGT5L7VZ.js";
|
|
8
|
+
import "./cli-4LKXZQ2B.js";
|
|
9
|
+
import {
|
|
10
|
+
readSdkToolsVersion
|
|
11
|
+
} from "./cli-IUS2YCD3.js";
|
|
12
|
+
import {
|
|
13
|
+
distPath
|
|
14
|
+
} from "./cli-OXAUOWCN.js";
|
|
15
|
+
import {
|
|
16
|
+
generateAllTypes
|
|
17
|
+
} from "./cli-IEMKI7J7.js";
|
|
18
|
+
import "./cli-OMWC75CC.js";
|
|
19
|
+
import "./cli-BYCHKSSH.js";
|
|
20
|
+
import "./cli-25RWY5BQ.js";
|
|
21
|
+
import "./cli-QWQMPCL6.js";
|
|
22
|
+
import {
|
|
23
|
+
LOGIC_NODE_BUILTIN,
|
|
24
|
+
MANIFEST_VERSION,
|
|
25
|
+
SPEC_REVISION,
|
|
26
|
+
Transpile,
|
|
27
|
+
getResourceMeta,
|
|
28
|
+
loadConfig
|
|
29
|
+
} from "./cli-VQ6HVQW4.js";
|
|
30
|
+
import "./cli-F2D4GGUA.js";
|
|
31
|
+
import {
|
|
32
|
+
getVerboseMode,
|
|
33
|
+
logger
|
|
34
|
+
} from "./cli-4YB3ROVR.js";
|
|
35
|
+
import {
|
|
36
|
+
CliError,
|
|
37
|
+
diagnosticLocation,
|
|
38
|
+
isJsonOutput,
|
|
39
|
+
recordDiagnostic,
|
|
40
|
+
reportResult
|
|
41
|
+
} from "./cli-N6H6T2E2.js";
|
|
42
|
+
|
|
43
|
+
// cli/commands/build.ts
|
|
44
|
+
import { existsSync as existsSync3 } from "fs";
|
|
45
|
+
import { cp as cp3, mkdir as mkdir8, rm, writeFile as writeFile6 } from "fs/promises";
|
|
46
|
+
import { resolve as resolve7, join as join9, sep } from "path";
|
|
47
|
+
|
|
48
|
+
// cli/bundling/endpoint-bundler.ts
|
|
49
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
50
|
+
import { join, resolve } from "path";
|
|
51
|
+
async function bundleEndpoint(endpoint, workingDir, buildDir) {
|
|
52
|
+
logger.debug(`Bundling ${endpoint.definition.identifier}...`);
|
|
53
|
+
const endpointSourceDir = join(workingDir, endpoint.rootDirectory);
|
|
54
|
+
const endpointOutputDir = join(
|
|
55
|
+
buildDir,
|
|
56
|
+
distPath(getResourceMeta("endpoint"), endpoint.definition.identifier)
|
|
57
|
+
);
|
|
58
|
+
await mkdir(endpointOutputDir, { recursive: true });
|
|
59
|
+
const isVerbose = getVerboseMode();
|
|
60
|
+
const originalLog = console.log;
|
|
61
|
+
const originalError = console.error;
|
|
62
|
+
if (!isVerbose) {
|
|
63
|
+
console.log = () => {
|
|
64
|
+
};
|
|
65
|
+
console.error = () => {
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
const logicDirectory = resolve(endpointSourceDir, endpoint.logic.directory);
|
|
70
|
+
const logicEntrypoint = resolve(logicDirectory, endpoint.logic.entrypoint);
|
|
71
|
+
const bundledCode = await Transpile({
|
|
72
|
+
entrypoint: logicEntrypoint,
|
|
73
|
+
packageRoot: workingDir
|
|
74
|
+
});
|
|
75
|
+
const logicOutputDir = join(endpointOutputDir, endpoint.logic.directory);
|
|
76
|
+
await mkdir(logicOutputDir, { recursive: true });
|
|
77
|
+
const outputPath = join(logicOutputDir, "logic.js");
|
|
78
|
+
await writeFile(outputPath, bundledCode, "utf-8");
|
|
79
|
+
logger.debug(` Bundled ${logicEntrypoint} -> ${outputPath}`);
|
|
80
|
+
} finally {
|
|
81
|
+
console.log = originalLog;
|
|
82
|
+
console.error = originalError;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// cli/bundling/engine-bundler.ts
|
|
87
|
+
import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
|
|
88
|
+
import { join as join2, resolve as resolve2 } from "path";
|
|
89
|
+
async function bundleEngine(engine, workingDir, buildDir) {
|
|
90
|
+
logger.debug(`Bundling ${engine.definition.identifier}...`);
|
|
91
|
+
const engineSourceDir = join2(workingDir, engine.rootDirectory);
|
|
92
|
+
const engineOutputDir = join2(
|
|
93
|
+
buildDir,
|
|
94
|
+
distPath(getResourceMeta("engine"), engine.definition.identifier)
|
|
95
|
+
);
|
|
96
|
+
await mkdir2(engineOutputDir, { recursive: true });
|
|
97
|
+
const isVerbose = getVerboseMode();
|
|
98
|
+
const originalLog = console.log;
|
|
99
|
+
const originalError = console.error;
|
|
100
|
+
if (!isVerbose) {
|
|
101
|
+
console.log = () => {
|
|
102
|
+
};
|
|
103
|
+
console.error = () => {
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
const logicDirectory = resolve2(engineSourceDir, engine.logic.directory);
|
|
108
|
+
const logicEntrypoint = resolve2(logicDirectory, engine.logic.entrypoint);
|
|
109
|
+
const bundledCode = await Transpile({
|
|
110
|
+
entrypoint: logicEntrypoint,
|
|
111
|
+
packageRoot: workingDir
|
|
112
|
+
});
|
|
113
|
+
const logicOutputDir = join2(engineOutputDir, engine.logic.directory);
|
|
114
|
+
await mkdir2(logicOutputDir, { recursive: true });
|
|
115
|
+
const outputPath = join2(logicOutputDir, "logic.js");
|
|
116
|
+
await writeFile2(outputPath, bundledCode, "utf-8");
|
|
117
|
+
logger.debug(` Bundled ${logicEntrypoint} -> ${outputPath}`);
|
|
118
|
+
} finally {
|
|
119
|
+
console.log = originalLog;
|
|
120
|
+
console.error = originalError;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// cli/bundling/facilitator-guide-bundler.ts
|
|
125
|
+
import { existsSync } from "fs";
|
|
126
|
+
import { cp, mkdir as mkdir3 } from "fs/promises";
|
|
127
|
+
import { join as join3 } from "path";
|
|
128
|
+
async function bundleFacilitatorGuide(guide, workingDir, buildDir) {
|
|
129
|
+
logger.debug(`Bundling facilitator guide ${guide.definition.identifier}...`);
|
|
130
|
+
const guideSourceDir = join3(workingDir, guide.rootDirectory);
|
|
131
|
+
const guideOutputDir = join3(
|
|
132
|
+
buildDir,
|
|
133
|
+
distPath(getResourceMeta("guide"), guide.definition.identifier)
|
|
134
|
+
);
|
|
135
|
+
await mkdir3(guideOutputDir, { recursive: true });
|
|
136
|
+
for (const dir of ["content", "assets"]) {
|
|
137
|
+
const source = join3(guideSourceDir, dir);
|
|
138
|
+
if (existsSync(source)) {
|
|
139
|
+
const output = join3(guideOutputDir, dir);
|
|
140
|
+
await cp(source, output, { recursive: true });
|
|
141
|
+
logger.debug(` Copied ${dir} -> ${output}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// cli/bundling/hook-bundler.ts
|
|
147
|
+
import { mkdir as mkdir4, writeFile as writeFile3 } from "fs/promises";
|
|
148
|
+
import { join as join4, resolve as resolve3 } from "path";
|
|
149
|
+
async function bundleHook(hook, workingDir, buildDir) {
|
|
150
|
+
logger.debug(`Bundling ${hook.definition.identifier}...`);
|
|
151
|
+
const hookSourceDir = join4(workingDir, hook.rootDirectory);
|
|
152
|
+
const hookOutputDir = join4(
|
|
153
|
+
buildDir,
|
|
154
|
+
distPath(getResourceMeta("hook"), hook.definition.identifier)
|
|
155
|
+
);
|
|
156
|
+
await mkdir4(hookOutputDir, { recursive: true });
|
|
157
|
+
const isVerbose = getVerboseMode();
|
|
158
|
+
const originalLog = console.log;
|
|
159
|
+
const originalError = console.error;
|
|
160
|
+
if (!isVerbose) {
|
|
161
|
+
console.log = () => {
|
|
162
|
+
};
|
|
163
|
+
console.error = () => {
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
try {
|
|
167
|
+
const logicDirectory = resolve3(hookSourceDir, hook.logic.directory);
|
|
168
|
+
const logicEntrypoint = resolve3(logicDirectory, hook.logic.entrypoint);
|
|
169
|
+
const bundledCode = await Transpile({
|
|
170
|
+
entrypoint: logicEntrypoint,
|
|
171
|
+
packageRoot: workingDir
|
|
172
|
+
});
|
|
173
|
+
const logicOutputDir = join4(hookOutputDir, hook.logic.directory);
|
|
174
|
+
await mkdir4(logicOutputDir, { recursive: true });
|
|
175
|
+
const outputPath = join4(logicOutputDir, "logic.js");
|
|
176
|
+
await writeFile3(outputPath, bundledCode, "utf-8");
|
|
177
|
+
logger.debug(` Bundled ${logicEntrypoint} -> ${outputPath}`);
|
|
178
|
+
} finally {
|
|
179
|
+
console.log = originalLog;
|
|
180
|
+
console.error = originalError;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// cli/bundling/scenario-bundler.ts
|
|
185
|
+
import { existsSync as existsSync2 } from "fs";
|
|
186
|
+
import { cp as cp2, mkdir as mkdir5 } from "fs/promises";
|
|
187
|
+
import { join as join5 } from "path";
|
|
188
|
+
async function bundleScenario(scenario, workingDir, buildDir) {
|
|
189
|
+
logger.debug(`Bundling scenario ${scenario.definition.identifier}...`);
|
|
190
|
+
const scenarioSourceDir = join5(workingDir, scenario.rootDirectory);
|
|
191
|
+
const assetsSource = join5(scenarioSourceDir, "assets");
|
|
192
|
+
const scenarioOutputDir = join5(
|
|
193
|
+
buildDir,
|
|
194
|
+
distPath(getResourceMeta("scenario"), scenario.definition.identifier)
|
|
195
|
+
);
|
|
196
|
+
await mkdir5(scenarioOutputDir, { recursive: true });
|
|
197
|
+
if (existsSync2(assetsSource)) {
|
|
198
|
+
const assetsOutput = join5(scenarioOutputDir, "assets");
|
|
199
|
+
await cp2(assetsSource, assetsOutput, { recursive: true });
|
|
200
|
+
logger.debug(` Copied assets -> ${assetsOutput}`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// cli/bundling/tick-controller-bundler.ts
|
|
205
|
+
import { mkdir as mkdir6, writeFile as writeFile4 } from "fs/promises";
|
|
206
|
+
import { join as join6, resolve as resolve4 } from "path";
|
|
207
|
+
async function bundleTickController(tickController, workingDir, buildDir) {
|
|
208
|
+
logger.debug(`Bundling ${tickController.definition.identifier}...`);
|
|
209
|
+
const tickControllerSourceDir = join6(workingDir, tickController.rootDirectory);
|
|
210
|
+
const tickControllerOutputDir = join6(
|
|
211
|
+
buildDir,
|
|
212
|
+
distPath(getResourceMeta("tick_controller"), tickController.definition.identifier)
|
|
213
|
+
);
|
|
214
|
+
await mkdir6(tickControllerOutputDir, { recursive: true });
|
|
215
|
+
const isVerbose = getVerboseMode();
|
|
216
|
+
const originalLog = console.log;
|
|
217
|
+
const originalError = console.error;
|
|
218
|
+
if (!isVerbose) {
|
|
219
|
+
console.log = () => {
|
|
220
|
+
};
|
|
221
|
+
console.error = () => {
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
try {
|
|
225
|
+
const logicDirectory = resolve4(tickControllerSourceDir, tickController.logic.directory);
|
|
226
|
+
const logicEntrypoint = resolve4(logicDirectory, tickController.logic.entrypoint);
|
|
227
|
+
const bundledCode = await Transpile({
|
|
228
|
+
entrypoint: logicEntrypoint,
|
|
229
|
+
packageRoot: workingDir
|
|
230
|
+
});
|
|
231
|
+
const logicOutputDir = join6(tickControllerOutputDir, tickController.logic.directory);
|
|
232
|
+
await mkdir6(logicOutputDir, { recursive: true });
|
|
233
|
+
const outputPath = join6(logicOutputDir, "logic.js");
|
|
234
|
+
await writeFile4(outputPath, bundledCode, "utf-8");
|
|
235
|
+
logger.debug(` Bundled ${logicEntrypoint} -> ${outputPath}`);
|
|
236
|
+
} finally {
|
|
237
|
+
console.log = originalLog;
|
|
238
|
+
console.error = originalError;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// cli/bundling/ui-bundler.ts
|
|
243
|
+
import { realpathSync } from "fs";
|
|
244
|
+
import { join as join7, resolve as resolve5 } from "path";
|
|
245
|
+
import react from "@vitejs/plugin-react";
|
|
246
|
+
import { build, loadConfigFromFile, mergeConfig } from "vite";
|
|
247
|
+
async function bundleUserInterface(ui, workingDir, buildDir, type) {
|
|
248
|
+
const uiOutputDir = join7(buildDir, distPath(getResourceMeta(type), ui.definition.identifier));
|
|
249
|
+
const uiRootDir = join7(workingDir, ui.rootDirectory);
|
|
250
|
+
const uiDir = realpathSync(uiRootDir);
|
|
251
|
+
logger.debug(`Building ${ui.definition.identifier}...`);
|
|
252
|
+
const isVerbose = getVerboseMode();
|
|
253
|
+
const configEnv = { command: "build", mode: "production" };
|
|
254
|
+
const rootConfigResult = await loadConfigFromFile(configEnv, void 0, workingDir);
|
|
255
|
+
const uiConfigResult = await loadConfigFromFile(configEnv, void 0, uiDir);
|
|
256
|
+
if (rootConfigResult?.path && uiConfigResult?.path) {
|
|
257
|
+
logger.warn(
|
|
258
|
+
`Both ${rootConfigResult.path} and ${uiConfigResult.path} exist. They will be merged (per-UI overrides package-root), but this is almost certainly a mistake \u2014 choose one location and delete the other.`
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
const inlineConfig = {
|
|
262
|
+
base: "./",
|
|
263
|
+
// Relative paths, must use this for iframes to work
|
|
264
|
+
root: uiDir,
|
|
265
|
+
// We've already loaded both user configs explicitly above. Disable
|
|
266
|
+
// Vite's own config-file auto-discovery so it doesn't load
|
|
267
|
+
// `uiDir/vite.config.ts` a second time.
|
|
268
|
+
configFile: false,
|
|
269
|
+
plugins: [react()],
|
|
270
|
+
resolve: {
|
|
271
|
+
dedupe: ["react", "react-dom", "@emotion/react", "@emotion/styled"]
|
|
272
|
+
},
|
|
273
|
+
build: {
|
|
274
|
+
outDir: uiOutputDir,
|
|
275
|
+
emptyOutDir: true,
|
|
276
|
+
rollupOptions: {
|
|
277
|
+
input: resolve5(uiDir, ui.ui.entrypoint)
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
logLevel: isVerbose ? "info" : "silent"
|
|
281
|
+
};
|
|
282
|
+
const mergedUserConfig = mergeConfig(
|
|
283
|
+
rootConfigResult?.config ?? {},
|
|
284
|
+
uiConfigResult?.config ?? {}
|
|
285
|
+
);
|
|
286
|
+
const finalConfig = mergeConfig(mergedUserConfig, inlineConfig);
|
|
287
|
+
try {
|
|
288
|
+
await build(finalConfig);
|
|
289
|
+
logger.debug(` Built ${ui.definition.identifier} -> ${uiOutputDir}`);
|
|
290
|
+
} catch (error) {
|
|
291
|
+
logger.error(
|
|
292
|
+
`Failed to build ${ui.definition.identifier}: ${error instanceof Error ? error.message : String(error)}`
|
|
293
|
+
);
|
|
294
|
+
throw error;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// cli/bundling/validator-bundler.ts
|
|
299
|
+
import { mkdir as mkdir7, writeFile as writeFile5 } from "fs/promises";
|
|
300
|
+
import { join as join8, resolve as resolve6 } from "path";
|
|
301
|
+
async function bundleValidator(validator, workingDir, buildDir) {
|
|
302
|
+
logger.debug(`Bundling ${validator.definition.identifier}...`);
|
|
303
|
+
const validatorSourceDir = join8(workingDir, validator.rootDirectory);
|
|
304
|
+
const validatorOutputDir = join8(
|
|
305
|
+
buildDir,
|
|
306
|
+
distPath(getResourceMeta("validator"), validator.definition.identifier)
|
|
307
|
+
);
|
|
308
|
+
await mkdir7(validatorOutputDir, { recursive: true });
|
|
309
|
+
const isVerbose = getVerboseMode();
|
|
310
|
+
const originalLog = console.log;
|
|
311
|
+
const originalError = console.error;
|
|
312
|
+
if (!isVerbose) {
|
|
313
|
+
console.log = () => {
|
|
314
|
+
};
|
|
315
|
+
console.error = () => {
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
try {
|
|
319
|
+
const logicDirectory = resolve6(validatorSourceDir, validator.logic.directory);
|
|
320
|
+
const logicEntrypoint = resolve6(logicDirectory, validator.logic.entrypoint);
|
|
321
|
+
const bundledCode = await Transpile({
|
|
322
|
+
entrypoint: logicEntrypoint,
|
|
323
|
+
packageRoot: workingDir
|
|
324
|
+
});
|
|
325
|
+
const logicOutputDir = join8(validatorOutputDir, validator.logic.directory);
|
|
326
|
+
await mkdir7(logicOutputDir, { recursive: true });
|
|
327
|
+
const outputPath = join8(logicOutputDir, "logic.js");
|
|
328
|
+
await writeFile5(outputPath, bundledCode, "utf-8");
|
|
329
|
+
logger.debug(` Bundled ${logicEntrypoint} -> ${outputPath}`);
|
|
330
|
+
} finally {
|
|
331
|
+
console.log = originalLog;
|
|
332
|
+
console.error = originalError;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// cli/commands/build.ts
|
|
337
|
+
function printValidationResults(output) {
|
|
338
|
+
for (const result of output.resources) {
|
|
339
|
+
if (result.errors.length === 0 && result.warnings.length === 0) {
|
|
340
|
+
console.log(` ${result.type} "${result.identifier}" ... ok`);
|
|
341
|
+
} else {
|
|
342
|
+
if (result.errors.length > 0) {
|
|
343
|
+
console.log(` ${result.type} "${result.identifier}" ... FAILED`);
|
|
344
|
+
for (const error of result.errors) {
|
|
345
|
+
const indented = error.split("\n").map((line, i) => i === 0 ? ` - ${line}` : ` ${line}`).join("\n");
|
|
346
|
+
console.log(indented);
|
|
347
|
+
const at = locationLine(
|
|
348
|
+
result.diagnostics.find(
|
|
349
|
+
(d) => d.severity === "error" && d.message === error
|
|
350
|
+
),
|
|
351
|
+
" "
|
|
352
|
+
);
|
|
353
|
+
if (at) console.log(at);
|
|
354
|
+
}
|
|
355
|
+
} else {
|
|
356
|
+
console.log(` ${result.type} "${result.identifier}" ... ok (with warnings)`);
|
|
357
|
+
}
|
|
358
|
+
for (const warning of result.warnings) {
|
|
359
|
+
const indented = warning.split("\n").map((line, i) => i === 0 ? ` warning: ${line}` : ` ${line}`).join("\n");
|
|
360
|
+
console.log(indented);
|
|
361
|
+
const at = locationLine(
|
|
362
|
+
result.diagnostics.find(
|
|
363
|
+
(d) => d.severity === "warning" && d.message === warning
|
|
364
|
+
),
|
|
365
|
+
" "
|
|
366
|
+
);
|
|
367
|
+
if (at) console.log(at);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
console.log(
|
|
372
|
+
`
|
|
373
|
+
${output.summary.total} resources validated: ${output.summary.passed} passed, ${output.summary.failed} failed` + (output.summary.warnings > 0 ? `, ${output.summary.warnings} with warnings` : "")
|
|
374
|
+
);
|
|
375
|
+
if (output.resources.some((r) => r.type === "tick_controller")) {
|
|
376
|
+
console.log(`
|
|
377
|
+
${TICK_INTERVAL_STATIC_NOTE}`);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
var TICK_INTERVAL_STATIC_NOTE = "Note: tick interval bounds are checked statically (declared and schema-default values only). Runtime-computed intervals are enforced by the dev server and the production runtime.";
|
|
381
|
+
function slot(resource) {
|
|
382
|
+
return resource ? [resource] : [];
|
|
383
|
+
}
|
|
384
|
+
async function buildCommand(options) {
|
|
385
|
+
const configPath = resolve7(options.workingDir, options.config);
|
|
386
|
+
if (options.validateOnly) {
|
|
387
|
+
const output = await validatePackage(options);
|
|
388
|
+
if (!output.success) {
|
|
389
|
+
if (!isJsonOutput()) {
|
|
390
|
+
console.log("");
|
|
391
|
+
printValidationResults(output);
|
|
392
|
+
console.log("");
|
|
393
|
+
}
|
|
394
|
+
throw validationFailure(output);
|
|
395
|
+
}
|
|
396
|
+
recordWarnings(output);
|
|
397
|
+
reportResult(withoutDiagnostics(output), () => {
|
|
398
|
+
console.log("");
|
|
399
|
+
printValidationResults(output);
|
|
400
|
+
console.log("");
|
|
401
|
+
});
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
logger.section("Step 1: Loading configuration...");
|
|
405
|
+
const buildDir = resolve7(options.workingDir, options.buildDir);
|
|
406
|
+
const config = await loadConfig(configPath);
|
|
407
|
+
const capabilities = config.capabilities || [];
|
|
408
|
+
const engines = slot(config.engine);
|
|
409
|
+
const userInterfaces = slot(config.ui);
|
|
410
|
+
const setupBuild = slot(config.setup);
|
|
411
|
+
const scenarioEditorBuild = slot(config.scenario_editor);
|
|
412
|
+
const sessionUserInterfaces = slot(config.session);
|
|
413
|
+
const waitingRoomUserInterfacesBuild = slot(config.waiting_room);
|
|
414
|
+
const presentationsBuild = slot(config.presentation);
|
|
415
|
+
const tickControllers = slot(config.tick_controller);
|
|
416
|
+
const hooks = config.hooks || [];
|
|
417
|
+
const validators = config.validators || [];
|
|
418
|
+
const scenarios = config.scenarios || [];
|
|
419
|
+
const facilitatorGuidesBuild = slot(config.guide);
|
|
420
|
+
const endpoints = config.endpoints || [];
|
|
421
|
+
logger.debug(
|
|
422
|
+
`Found ${capabilities.length} capabilities, ${engines.length === 1 ? "an engine" : "no engine"}, ${userInterfaces.length} user interfaces, ${setupBuild.length + scenarioEditorBuild.length} settings editors, ${tickControllers.length} tick controllers, ${hooks.length} hooks, and ${validators.length} validators`
|
|
423
|
+
);
|
|
424
|
+
logger.newline();
|
|
425
|
+
logger.section("Step 2: Validating...");
|
|
426
|
+
const validationOutput = await validatePackage(options);
|
|
427
|
+
if (!validationOutput.success) {
|
|
428
|
+
for (const result of validationOutput.resources) {
|
|
429
|
+
if (result.errors.length > 0) {
|
|
430
|
+
logger.error(`${result.type} "${result.identifier}" has errors:`);
|
|
431
|
+
for (const error of result.errors) {
|
|
432
|
+
logger.error(` - ${error}`);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
throw validationFailure(validationOutput);
|
|
437
|
+
}
|
|
438
|
+
recordWarnings(validationOutput);
|
|
439
|
+
for (const result of validationOutput.resources) {
|
|
440
|
+
if (result.warnings.length > 0) {
|
|
441
|
+
logger.warn(`${result.type} "${result.identifier}" has warnings:`);
|
|
442
|
+
for (const warning of result.warnings) {
|
|
443
|
+
logger.warn(` - ${warning}`);
|
|
444
|
+
}
|
|
445
|
+
} else {
|
|
446
|
+
logger.debug(` ${result.type} "${result.identifier}" is valid`);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
if (validationOutput.resources.some((r) => r.type === "tick_controller")) {
|
|
450
|
+
console.log(TICK_INTERVAL_STATIC_NOTE);
|
|
451
|
+
}
|
|
452
|
+
logger.newline();
|
|
453
|
+
logger.section("Step 3: Generating types...");
|
|
454
|
+
await generateAllTypes(config, { workingDir: options.workingDir, verbose: true });
|
|
455
|
+
logger.newline();
|
|
456
|
+
logger.section("Step 4: Creating build directory structure...");
|
|
457
|
+
const workingDirResolved = resolve7(options.workingDir);
|
|
458
|
+
const buildDirIsUnsafe = buildDir === workingDirResolved || workingDirResolved.startsWith(buildDir + sep);
|
|
459
|
+
if (buildDirIsUnsafe) {
|
|
460
|
+
logger.warn(
|
|
461
|
+
`Skipping clean of build directory "${buildDir}" because it overlaps the working directory. Stale artefacts may remain.`
|
|
462
|
+
);
|
|
463
|
+
} else {
|
|
464
|
+
await rm(buildDir, { recursive: true, force: true });
|
|
465
|
+
}
|
|
466
|
+
await mkdir8(buildDir, { recursive: true });
|
|
467
|
+
const wd = options.workingDir;
|
|
468
|
+
const bundleStep = (subdir, label, resources, bundle) => {
|
|
469
|
+
return {
|
|
470
|
+
subdir,
|
|
471
|
+
hasContent: resources.length > 0,
|
|
472
|
+
run: async () => {
|
|
473
|
+
if (resources.length === 0) return;
|
|
474
|
+
logger.section(`Bundling ${label}...`);
|
|
475
|
+
for (const resource of resources) {
|
|
476
|
+
await bundle(resource);
|
|
477
|
+
}
|
|
478
|
+
logger.newline();
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
};
|
|
482
|
+
const scaffoldDir = (type) => {
|
|
483
|
+
const meta = getResourceMeta(type);
|
|
484
|
+
return meta.slot ?? meta.pluralDir;
|
|
485
|
+
};
|
|
486
|
+
const bundleSteps = [
|
|
487
|
+
bundleStep(
|
|
488
|
+
scaffoldDir("engine"),
|
|
489
|
+
"the engine",
|
|
490
|
+
engines,
|
|
491
|
+
(r) => bundleEngine(r, wd, buildDir)
|
|
492
|
+
),
|
|
493
|
+
bundleStep(
|
|
494
|
+
scaffoldDir("ui"),
|
|
495
|
+
"user interfaces",
|
|
496
|
+
userInterfaces,
|
|
497
|
+
(r) => bundleUserInterface(r, wd, buildDir, "ui")
|
|
498
|
+
),
|
|
499
|
+
bundleStep(
|
|
500
|
+
scaffoldDir("setup"),
|
|
501
|
+
"the setup user interface",
|
|
502
|
+
setupBuild,
|
|
503
|
+
(r) => bundleUserInterface(r, wd, buildDir, "setup")
|
|
504
|
+
),
|
|
505
|
+
bundleStep(
|
|
506
|
+
scaffoldDir("scenario_editor"),
|
|
507
|
+
"the scenario editor",
|
|
508
|
+
scenarioEditorBuild,
|
|
509
|
+
(r) => bundleUserInterface(r, wd, buildDir, "scenario_editor")
|
|
510
|
+
),
|
|
511
|
+
bundleStep(
|
|
512
|
+
scaffoldDir("session"),
|
|
513
|
+
"session user interfaces",
|
|
514
|
+
sessionUserInterfaces,
|
|
515
|
+
(r) => bundleUserInterface(r, wd, buildDir, "session")
|
|
516
|
+
),
|
|
517
|
+
bundleStep(
|
|
518
|
+
scaffoldDir("waiting_room"),
|
|
519
|
+
"waiting room user interfaces",
|
|
520
|
+
waitingRoomUserInterfacesBuild,
|
|
521
|
+
(r) => bundleUserInterface(r, wd, buildDir, "waiting_room")
|
|
522
|
+
),
|
|
523
|
+
bundleStep(
|
|
524
|
+
scaffoldDir("presentation"),
|
|
525
|
+
"presentations",
|
|
526
|
+
presentationsBuild,
|
|
527
|
+
(r) => bundleUserInterface(r, wd, buildDir, "presentation")
|
|
528
|
+
),
|
|
529
|
+
bundleStep(
|
|
530
|
+
scaffoldDir("tick_controller"),
|
|
531
|
+
"tick controllers",
|
|
532
|
+
tickControllers,
|
|
533
|
+
(r) => bundleTickController(r, wd, buildDir)
|
|
534
|
+
),
|
|
535
|
+
bundleStep(scaffoldDir("hook"), "hooks", hooks, (r) => bundleHook(r, wd, buildDir)),
|
|
536
|
+
bundleStep(
|
|
537
|
+
scaffoldDir("validator"),
|
|
538
|
+
"validators",
|
|
539
|
+
validators,
|
|
540
|
+
(r) => bundleValidator(r, wd, buildDir)
|
|
541
|
+
),
|
|
542
|
+
bundleStep(
|
|
543
|
+
scaffoldDir("endpoint"),
|
|
544
|
+
"endpoints",
|
|
545
|
+
endpoints,
|
|
546
|
+
(r) => bundleEndpoint(r, wd, buildDir)
|
|
547
|
+
),
|
|
548
|
+
bundleStep(
|
|
549
|
+
scaffoldDir("scenario"),
|
|
550
|
+
"scenarios",
|
|
551
|
+
scenarios,
|
|
552
|
+
(r) => bundleScenario(r, wd, buildDir)
|
|
553
|
+
),
|
|
554
|
+
bundleStep(
|
|
555
|
+
scaffoldDir("guide"),
|
|
556
|
+
"facilitator guides",
|
|
557
|
+
facilitatorGuidesBuild,
|
|
558
|
+
(r) => bundleFacilitatorGuide(r, wd, buildDir)
|
|
559
|
+
)
|
|
560
|
+
];
|
|
561
|
+
for (const step of bundleSteps.filter((step2) => step2.hasContent)) {
|
|
562
|
+
await mkdir8(join9(buildDir, step.subdir), { recursive: true });
|
|
563
|
+
}
|
|
564
|
+
logger.debug(` Created ${buildDir}`);
|
|
565
|
+
logger.newline();
|
|
566
|
+
for (const step of bundleSteps) {
|
|
567
|
+
await step.run();
|
|
568
|
+
}
|
|
569
|
+
const sharedAssetsSource = resolve7(options.workingDir, "shared-assets");
|
|
570
|
+
if (existsSync3(sharedAssetsSource)) {
|
|
571
|
+
logger.section("Step 5: Copying shared assets...");
|
|
572
|
+
const sharedAssetsOutput = join9(buildDir, "shared-assets");
|
|
573
|
+
await cp3(sharedAssetsSource, sharedAssetsOutput, { recursive: true });
|
|
574
|
+
logger.debug(` Copied shared-assets -> ${sharedAssetsOutput}`);
|
|
575
|
+
logger.newline();
|
|
576
|
+
}
|
|
577
|
+
logger.section("Step 6: Generating runtime configuration...");
|
|
578
|
+
const logicBundle = (resource) => ({
|
|
579
|
+
...resource,
|
|
580
|
+
logic: { directory: resource.logic.directory, entrypoint: "logic.js" }
|
|
581
|
+
});
|
|
582
|
+
const configuration = {
|
|
583
|
+
manifestVersion: MANIFEST_VERSION,
|
|
584
|
+
...config.requires?.length ? { requires: config.requires } : {},
|
|
585
|
+
...config.scenarioFormat === void 0 ? {} : { scenarioFormat: config.scenarioFormat },
|
|
586
|
+
builtWith: { sdk: readSdkToolsVersion(), specRevision: SPEC_REVISION },
|
|
587
|
+
package: config.package,
|
|
588
|
+
game: config.game,
|
|
589
|
+
...config.engine ? { engine: logicBundle(config.engine) } : {},
|
|
590
|
+
...config.ui ? { ui: config.ui } : {},
|
|
591
|
+
...config.session ? { session: config.session } : {},
|
|
592
|
+
...config.waiting_room ? { waiting_room: config.waiting_room } : {},
|
|
593
|
+
...config.presentation ? { presentation: config.presentation } : {},
|
|
594
|
+
...config.setup ? { setup: config.setup } : {},
|
|
595
|
+
...config.scenario_editor ? { scenario_editor: config.scenario_editor } : {},
|
|
596
|
+
...config.tick_controller ? { tick_controller: logicBundle(config.tick_controller) } : {},
|
|
597
|
+
...config.guide ? { guide: config.guide } : {},
|
|
598
|
+
capabilities,
|
|
599
|
+
settings: config.settings ?? [],
|
|
600
|
+
scenarios,
|
|
601
|
+
hooks: hooks.map(logicBundle),
|
|
602
|
+
validators: validators.map(logicBundle),
|
|
603
|
+
endpoints: endpoints.map(logicBundle)
|
|
604
|
+
};
|
|
605
|
+
const configOutputPath = join9(buildDir, "seriousgaming.json");
|
|
606
|
+
await writeFile6(configOutputPath, JSON.stringify(configuration, null, 4), "utf-8");
|
|
607
|
+
logger.debug(` Generated ${configOutputPath}`);
|
|
608
|
+
logger.success("Build complete!");
|
|
609
|
+
reportResult({
|
|
610
|
+
buildDir,
|
|
611
|
+
manifest: configOutputPath,
|
|
612
|
+
validation: withoutDiagnostics(validationOutput)
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
function validationFailure(output) {
|
|
616
|
+
const failed = output.resources.filter((resource) => resource.errors.length > 0);
|
|
617
|
+
const diagnostics = output.resources.flatMap((resource) => resource.diagnostics);
|
|
618
|
+
const errors = diagnostics.filter((entry) => entry.severity === "error");
|
|
619
|
+
return new CliError(
|
|
620
|
+
errors.length > 0 && errors.every((entry) => entry.code === LOGIC_NODE_BUILTIN) ? LOGIC_NODE_BUILTIN : "PACKAGE_INVALID",
|
|
621
|
+
`Validation failed: ${failed.length} of ${output.summary.total} resources have errors.`,
|
|
622
|
+
{
|
|
623
|
+
hint: "Fix the errors listed and run the command again.",
|
|
624
|
+
diagnostics,
|
|
625
|
+
details: { summary: output.summary }
|
|
626
|
+
}
|
|
627
|
+
);
|
|
628
|
+
}
|
|
629
|
+
function recordWarnings(output) {
|
|
630
|
+
for (const resource of output.resources) {
|
|
631
|
+
for (const diagnostic of resource.diagnostics) {
|
|
632
|
+
if (diagnostic.severity === "warning") recordDiagnostic(diagnostic);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
function withoutDiagnostics(output) {
|
|
637
|
+
return {
|
|
638
|
+
...output,
|
|
639
|
+
resources: output.resources.map(({ diagnostics: _diagnostics, ...resource }) => resource)
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
function locationLine(diagnostic, indent) {
|
|
643
|
+
if (!diagnostic) return void 0;
|
|
644
|
+
const location = diagnosticLocation(diagnostic);
|
|
645
|
+
return location === void 0 ? void 0 : `${indent}at ${location}`;
|
|
646
|
+
}
|
|
647
|
+
export {
|
|
648
|
+
buildCommand
|
|
649
|
+
};
|