@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.
Files changed (169) hide show
  1. package/dist/agent/guidance.md +350 -0
  2. package/dist/bundling/ui-bundler.d.ts +12 -0
  3. package/dist/cli-25RWY5BQ.js +41 -0
  4. package/dist/cli-2BH7FX27.js +52 -0
  5. package/dist/cli-2GZYGRVL.js +36 -0
  6. package/dist/cli-2NU2LPEE.js +97 -0
  7. package/dist/cli-3BRC32CP.js +132 -0
  8. package/dist/cli-3D3ZXWOV.js +111 -0
  9. package/dist/cli-3ZKWV3PN.js +96 -0
  10. package/dist/cli-45OCBG53.js +60 -0
  11. package/dist/cli-4LKXZQ2B.js +48 -0
  12. package/dist/cli-4PXNOJQX.js +81 -0
  13. package/dist/cli-4SIWLHQO.js +717 -0
  14. package/dist/cli-4UWFQNGF.js +54 -0
  15. package/dist/cli-4VFZHLDG.js +202 -0
  16. package/dist/cli-4YB3ROVR.js +78 -0
  17. package/dist/cli-5ACDPCXI.js +21 -0
  18. package/dist/cli-5IAW3LIF.js +38 -0
  19. package/dist/cli-5SM367K7.js +30 -0
  20. package/dist/cli-64AB62PM.js +25 -0
  21. package/dist/cli-6K3VQQUS.js +307 -0
  22. package/dist/cli-6QB2VFPY.js +80 -0
  23. package/dist/cli-6SGCYEEC.js +649 -0
  24. package/dist/cli-6UTPHWRQ.js +207 -0
  25. package/dist/cli-6VNKQ3OX.js +391 -0
  26. package/dist/cli-72XDEFU3.js +61 -0
  27. package/dist/cli-7A6MKCUJ.js +463 -0
  28. package/dist/cli-7XLHO2FE.js +226 -0
  29. package/dist/cli-AV2FYC5G.js +225 -0
  30. package/dist/cli-B6YHEKIJ.js +248 -0
  31. package/dist/cli-BJMS3VX3.js +1837 -0
  32. package/dist/cli-BUQI5UU4.js +43 -0
  33. package/dist/cli-BWX5E7TQ.js +23 -0
  34. package/dist/cli-BYCHKSSH.js +1331 -0
  35. package/dist/cli-C3CMJSNL.js +89 -0
  36. package/dist/cli-C47GJATR.js +42 -0
  37. package/dist/cli-C5QOJJWX.js +46 -0
  38. package/dist/cli-C6ZLPK2U.js +124 -0
  39. package/dist/cli-CD5CIJZI.js +72 -0
  40. package/dist/cli-DDJYUKQG.js +36 -0
  41. package/dist/cli-DFBTZEBX.js +167 -0
  42. package/dist/cli-DOXRQ3S5.js +60 -0
  43. package/dist/cli-EVI36HEM.js +79 -0
  44. package/dist/cli-F2D4GGUA.js +549 -0
  45. package/dist/cli-FQRVFGN6.js +0 -0
  46. package/dist/cli-FWFRKQNE.js +11 -0
  47. package/dist/cli-G6CANSPL.js +88 -0
  48. package/dist/cli-GFNDW2DL.js +124 -0
  49. package/dist/cli-HCRTYQQS.js +16 -0
  50. package/dist/cli-HFX3YPUL.js +76 -0
  51. package/dist/cli-HKORECAG.js +53 -0
  52. package/dist/cli-HOE3WLFH.js +73 -0
  53. package/dist/cli-HSIHDN6K.js +187 -0
  54. package/dist/cli-HW53ICZC.js +89 -0
  55. package/dist/cli-IDVUHGKG.js +218 -0
  56. package/dist/cli-IEMKI7J7.js +1387 -0
  57. package/dist/cli-ILFDANBR.js +101 -0
  58. package/dist/cli-ILKCQNM6.js +8 -0
  59. package/dist/cli-IP4RXGHM.js +2847 -0
  60. package/dist/cli-IUS2YCD3.js +31 -0
  61. package/dist/cli-J4DKUUTK.js +138 -0
  62. package/dist/cli-J4UBELKF.js +37 -0
  63. package/dist/cli-JJSWBW4H.js +89 -0
  64. package/dist/cli-JVI24FI6.js +68 -0
  65. package/dist/cli-JZCLIT3O.js +135 -0
  66. package/dist/cli-JZOZOEZM.js +131 -0
  67. package/dist/cli-KGM6RRQW.js +185 -0
  68. package/dist/cli-KGT5L7VZ.js +13641 -0
  69. package/dist/cli-KOGRWFN7.js +89 -0
  70. package/dist/cli-KSGB2ZLK.js +101 -0
  71. package/dist/cli-L7VYSXQK.js +243 -0
  72. package/dist/cli-LK3V4RI5.js +36 -0
  73. package/dist/cli-LQOHATY2.js +126 -0
  74. package/dist/cli-MJUYJIEP.js +13 -0
  75. package/dist/cli-MJV47HKI.js +143 -0
  76. package/dist/cli-MMN4BPO4.js +145 -0
  77. package/dist/cli-MOPSZ3CS.js +88 -0
  78. package/dist/cli-MU5LB43S.js +136 -0
  79. package/dist/cli-MYJGMA6U.js +40 -0
  80. package/dist/cli-N24OHSAN.js +36 -0
  81. package/dist/cli-N45DREM4.js +99 -0
  82. package/dist/cli-N6H6T2E2.js +616 -0
  83. package/dist/cli-NROTDF5Y.js +182 -0
  84. package/dist/cli-O5ABH2WK.js +226 -0
  85. package/dist/cli-OMWC75CC.js +256 -0
  86. package/dist/cli-OXAUOWCN.js +50 -0
  87. package/dist/cli-PGCIHPU7.js +143 -0
  88. package/dist/cli-Q6ZBZYK2.js +35 -0
  89. package/dist/cli-QUNIRH7A.js +57 -0
  90. package/dist/cli-QUSCIUOM.js +142 -0
  91. package/dist/cli-QVASWX2A.js +187 -0
  92. package/dist/cli-QWQMPCL6.js +253 -0
  93. package/dist/cli-QY5NZAR7.js +97 -0
  94. package/dist/cli-R2MUZQE2.js +62 -0
  95. package/dist/cli-RCIWBCXD.js +36 -0
  96. package/dist/cli-RLEGRWFM.js +81 -0
  97. package/dist/cli-RSW6EBBD.js +89 -0
  98. package/dist/cli-RZITKPJX.js +367 -0
  99. package/dist/cli-S5IVGDDD.js +32 -0
  100. package/dist/cli-SRHBXZCN.js +159 -0
  101. package/dist/cli-TDSQSCX4.js +131 -0
  102. package/dist/cli-TIDQ4WUE.js +257 -0
  103. package/dist/cli-TT36JCU5.js +370 -0
  104. package/dist/cli-TTKICM5P.js +100 -0
  105. package/dist/cli-TTMBBEJC.js +131 -0
  106. package/dist/cli-UMEBPAZQ.js +16 -0
  107. package/dist/cli-UNAJ2OTE.js +15 -0
  108. package/dist/cli-UZZFNXRX.js +226 -0
  109. package/dist/cli-VDBW23SS.js +81 -0
  110. package/dist/cli-VL2P354N.js +46 -0
  111. package/dist/cli-VPRRICZA.js +304 -0
  112. package/dist/cli-VQ6HVQW4.js +4010 -0
  113. package/dist/cli-WR3NOY74.js +36 -0
  114. package/dist/cli-WU43JT4T.js +52 -0
  115. package/dist/cli-XAT25PRU.js +117 -0
  116. package/dist/cli-XOTNXEJA.js +124 -0
  117. package/dist/cli-XSLNH5PR.js +6417 -0
  118. package/dist/cli-XSVGKI3R.js +39 -0
  119. package/dist/cli-XZCJIKIV.js +124 -0
  120. package/dist/cli-Y3DDNMPX.js +97 -0
  121. package/dist/cli-Y3O5F4JN.js +90 -0
  122. package/dist/cli-YOTGR3NB.js +82 -0
  123. package/dist/cli-Z56ZIVA6.js +97 -0
  124. package/dist/cli-ZBN5KAIB.js +59 -0
  125. package/dist/cli-ZDOTXEKL.js +31 -0
  126. package/dist/cli-ZDUADFBY.js +88 -0
  127. package/dist/cli-ZJFQ7EEA.js +131 -0
  128. package/dist/cli-ZTWOE3ZT.js +65 -0
  129. package/dist/cli.js +148 -43093
  130. package/dist/client/build-surfaces.d.ts +33 -0
  131. package/dist/client/dev-server.d.ts +6 -0
  132. package/dist/client/index.d.ts +1 -0
  133. package/dist/client/playwright.d.ts +62 -0
  134. package/dist/client.js +228 -48
  135. package/dist/core/session.d.ts +15 -1
  136. package/dist/dev/console/assets/{index-BVF8exas.js → index-CuMOOH9m.js} +1 -1
  137. package/dist/dev/console/index.html +1 -1
  138. package/dist/dev/shell.d.ts +19 -0
  139. package/dist/dev/surfaces.d.ts +7 -0
  140. package/dist/docs/ai-agents.md +1 -1
  141. package/dist/docs/api/index.md +14 -12
  142. package/dist/docs/api/sdk-tools-client.md +29 -0
  143. package/dist/docs/api/sdk-tools-playwright.md +104 -0
  144. package/dist/docs/changelog.md +34 -0
  145. package/dist/docs/cli-and-dev-server.md +21 -0
  146. package/dist/docs/cli-reference.md +45 -31
  147. package/dist/docs/environment-variables.md +6 -0
  148. package/dist/docs/getting-started.md +1 -1
  149. package/dist/docs/guides/designing-a-game.md +29 -4
  150. package/dist/docs/guides/starter-game.md +3 -3
  151. package/dist/docs/guides/testing.md +33 -18
  152. package/dist/docs/guides/upgrading.md +19 -2
  153. package/dist/docs/page-index.md +10 -9
  154. package/dist/docs/recipes/e2e-testing.md +19 -20
  155. package/dist/playwright.js +32232 -0
  156. package/dist/templates/package/CLAUDE.md.template +7 -346
  157. package/dist/templates/package/claude/rules/workflow-create-engine.md +2 -2
  158. package/dist/templates/package/claude/rules/workflow-create-guide.md +2 -2
  159. package/dist/templates/package/claude/rules/workflow-create-user-interface.md +1 -1
  160. package/dist/templates/package/claude/rules/workflow-test-engine-or-ui.md +1 -1
  161. package/dist/templates/package/claude/rules/workflow-update-sdk-version.md +3 -3
  162. package/dist/templates/package/global-setup.ts.template +7 -18
  163. package/dist/templates/package/playwright.config.ts.liquid +8 -11
  164. package/dist/templates/starter-game/playwright.config.ts +8 -11
  165. package/dist/templates/starter-game/testing/e2e/game.spec.ts +1 -1
  166. package/dist/templates/starter-game/testing/e2e/global-setup.ts +7 -18
  167. package/dist/utils/prompt.d.ts +5 -5
  168. package/dist/utils/resource-scan.d.ts +39 -0
  169. package/package.json +7 -3
@@ -0,0 +1,124 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ assertEveryPropertyHasDefault
4
+ } from "./cli-64AB62PM.js";
5
+ import {
6
+ promptForSchemaProperties
7
+ } from "./cli-RZITKPJX.js";
8
+ import {
9
+ readAuthoredBundle
10
+ } from "./cli-4VFZHLDG.js";
11
+ import {
12
+ resolveInputSource
13
+ } from "./cli-4UWFQNGF.js";
14
+ import {
15
+ createSettingsFiles
16
+ } from "./cli-4SIWLHQO.js";
17
+ import "./cli-IUS2YCD3.js";
18
+ import "./cli-QUNIRH7A.js";
19
+ import "./cli-J4UBELKF.js";
20
+ import {
21
+ loadPackageContext
22
+ } from "./cli-XSVGKI3R.js";
23
+ import "./cli-TT36JCU5.js";
24
+ import "./cli-OXAUOWCN.js";
25
+ import {
26
+ BUILD_COMMAND,
27
+ generateTypes,
28
+ operationError,
29
+ printOperationResult
30
+ } from "./cli-KSGB2ZLK.js";
31
+ import {
32
+ input
33
+ } from "./cli-ZTWOE3ZT.js";
34
+ import "./cli-LQOHATY2.js";
35
+ import "./cli-IEMKI7J7.js";
36
+ import "./cli-OMWC75CC.js";
37
+ import "./cli-BYCHKSSH.js";
38
+ import "./cli-25RWY5BQ.js";
39
+ import "./cli-QWQMPCL6.js";
40
+ import {
41
+ GAME_SETTINGS,
42
+ validateSDKSettings
43
+ } from "./cli-VQ6HVQW4.js";
44
+ import "./cli-F2D4GGUA.js";
45
+ import {
46
+ logger
47
+ } from "./cli-4YB3ROVR.js";
48
+ import {
49
+ CliError
50
+ } from "./cli-N6H6T2E2.js";
51
+
52
+ // cli/commands/resources/settings/new.ts
53
+ async function createSettings(definitionInput, options) {
54
+ logger.info("\nCreating new settings...\n");
55
+ loadPackageContext(options.workingDir, {
56
+ suggestNewPackage: true
57
+ });
58
+ const inputSource = await resolveInputSource(definitionInput, options.file);
59
+ let identifier;
60
+ let definition;
61
+ if (inputSource.kind === "json") {
62
+ const settingsInput = readAuthoredBundle({
63
+ json: inputSource.json,
64
+ type: "settings",
65
+ command: "new",
66
+ validate: validateSDKSettings
67
+ });
68
+ identifier = settingsInput.definition.identifier;
69
+ definition = settingsInput.definition;
70
+ } else {
71
+ logger.info("No JSON definition provided. Starting interactive mode...\n");
72
+ const name = await input({
73
+ message: 'Settings name (e.g., "demand", "pricing"):',
74
+ default: "mysettings",
75
+ validate: (value) => {
76
+ const trimmed = value.trim();
77
+ if (!trimmed) return "Settings name is required";
78
+ if (!/^[a-z][a-z0-9_]*$/.test(trimmed)) {
79
+ return "Settings name must start with a lowercase letter and contain only lowercase letters, numbers, and underscores";
80
+ }
81
+ return true;
82
+ }
83
+ });
84
+ identifier = name.trim();
85
+ logger.info(
86
+ "Every settings property needs a default: it is the value a game plays with.\n"
87
+ );
88
+ const properties = await promptForSchemaProperties({
89
+ context: "setting",
90
+ minProperties: 1
91
+ });
92
+ definition = {
93
+ settingsSchema: { type: "object", properties, additionalProperties: false }
94
+ };
95
+ }
96
+ if (identifier === GAME_SETTINGS) {
97
+ throw new CliError(
98
+ "SETTINGS_RESERVED",
99
+ `"${GAME_SETTINGS}" is reserved for the built-in game settings, whose schema is the SDK's.`,
100
+ {
101
+ hint: "Set the game's own values in seriousgaming.sdk.json (`maxTicks`, `teams`, `waitingRoom`), and give these settings another name."
102
+ }
103
+ );
104
+ }
105
+ assertEveryPropertyHasDefault(definition.settingsSchema);
106
+ logger.info("Creating settings files...\n");
107
+ const result = await createSettingsFiles({
108
+ packagePath: options.workingDir,
109
+ identifier,
110
+ definition
111
+ });
112
+ if (!result.success) {
113
+ throw operationError(result, "Failed to create settings files");
114
+ }
115
+ logger.success("Settings created successfully!");
116
+ printOperationResult(result);
117
+ await generateTypes(options.workingDir);
118
+ logger.info("Next steps:");
119
+ logger.info(` 1. List "${identifier}" in the settings of each resource that reads it`);
120
+ logger.info(` 2. Run "${BUILD_COMMAND}" to build your package`);
121
+ }
122
+ export {
123
+ createSettings
124
+ };
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ readSdkToolsVersion
4
+ } from "./cli-IUS2YCD3.js";
5
+ import {
6
+ reportResult
7
+ } from "./cli-N6H6T2E2.js";
8
+
9
+ // cli/commands/version.ts
10
+ async function versionCommand() {
11
+ const version = readSdkToolsVersion();
12
+ reportResult({ version }, () => console.log(version));
13
+ }
14
+ export {
15
+ versionCommand
16
+ };
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ beginOperationCapture,
4
+ endOperationCapture
5
+ } from "./cli-KSGB2ZLK.js";
6
+ import {
7
+ setPromptUsage
8
+ } from "./cli-ZTWOE3ZT.js";
9
+ import {
10
+ reportResult
11
+ } from "./cli-N6H6T2E2.js";
12
+
13
+ // cli/commands/resources/shared/resource-command.ts
14
+ import { isAbsolute, relative, resolve, sep } from "path";
15
+ function mergeChanges(results, packagePath) {
16
+ const root = resolve(packagePath);
17
+ const local = (path) => isAbsolute(path) ? relative(root, path).split(sep).join("/") : path;
18
+ const locals = (paths) => (paths ?? []).map(local);
19
+ const changes = {
20
+ filesCreated: [],
21
+ filesUpdated: [],
22
+ filesDeleted: [],
23
+ referencesUpdated: [],
24
+ referencesRemoved: [],
25
+ directoriesRenamed: []
26
+ };
27
+ for (const result of results) {
28
+ changes.filesCreated.push(...locals(result.filesCreated));
29
+ changes.filesUpdated.push(...locals(result.filesUpdated));
30
+ changes.filesDeleted.push(...locals(result.filesDeleted));
31
+ changes.referencesUpdated.push(...result.referencesUpdated ?? []);
32
+ changes.referencesRemoved.push(...result.referencesRemoved ?? []);
33
+ changes.directoriesRenamed.push(
34
+ ...(result.directoriesRenamed ?? []).map(({ from, to }) => ({
35
+ from: local(from),
36
+ to: local(to)
37
+ }))
38
+ );
39
+ }
40
+ return changes;
41
+ }
42
+ function usageFor({
43
+ command,
44
+ resourceType,
45
+ identifier
46
+ }) {
47
+ switch (command) {
48
+ case "new":
49
+ return `seriousgaming-sdk new ${resourceType} '{...}'`;
50
+ case "update":
51
+ return identifier ? `seriousgaming-sdk update ${resourceType} ${identifier} --patch '[...]'` : `seriousgaming-sdk update ${resourceType} '{...}'`;
52
+ case "delete":
53
+ return void 0;
54
+ }
55
+ }
56
+ async function runResourceCommand(context, run) {
57
+ setPromptUsage(usageFor(context));
58
+ beginOperationCapture();
59
+ let results;
60
+ try {
61
+ await run();
62
+ } finally {
63
+ results = endOperationCapture();
64
+ setPromptUsage(void 0);
65
+ }
66
+ const result = {
67
+ resourceType: context.resourceType,
68
+ ...context.identifier ? { identifier: context.identifier } : {},
69
+ ...mergeChanges(results, context.packagePath)
70
+ };
71
+ reportResult(result);
72
+ }
73
+
74
+ export {
75
+ runResourceCommand
76
+ };
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ createResourceFiles,
4
+ deleteResourceFiles,
5
+ findResourceReferences,
6
+ updateResourceFiles
7
+ } from "./cli-TT36JCU5.js";
8
+ import {
9
+ getResourceMeta
10
+ } from "./cli-VQ6HVQW4.js";
11
+
12
+ // cli/templating/guide.ts
13
+ var guideMeta = getResourceMeta("guide");
14
+ var SCAFFOLD_CHAPTERS = [
15
+ { file: "01-at-a-glance.md", template: "guide/01-at-a-glance.md.liquid" },
16
+ { file: "02-preparation.md", template: "guide/02-preparation.md.liquid" },
17
+ {
18
+ file: "03-running-the-session.md",
19
+ template: "guide/03-running-the-session.md.liquid"
20
+ }
21
+ ];
22
+ function createFacilitatorGuideFiles(options) {
23
+ const { definition, rootDirectory } = options;
24
+ const { locales } = definition;
25
+ return createResourceFiles(guideMeta, options, {
26
+ definition,
27
+ rootDirectory,
28
+ directories: ["assets"],
29
+ files: Object.keys(locales).flatMap(
30
+ (locale) => SCAFFOLD_CHAPTERS.map((chapter) => ({
31
+ path: `content/${locale}/${chapter.file}`,
32
+ template: chapter.template,
33
+ data: { name: locales[locale]?.name ?? "guide" }
34
+ }))
35
+ )
36
+ });
37
+ }
38
+ function updateFacilitatorGuideFiles(options) {
39
+ return updateResourceFiles(guideMeta, options);
40
+ }
41
+ function deleteFacilitatorGuideFiles(options) {
42
+ return deleteResourceFiles(guideMeta, options);
43
+ }
44
+ function findFacilitatorGuideReferences(options) {
45
+ return findResourceReferences(guideMeta, options);
46
+ }
47
+
48
+ export {
49
+ createFacilitatorGuideFiles,
50
+ updateFacilitatorGuideFiles,
51
+ deleteFacilitatorGuideFiles,
52
+ findFacilitatorGuideReferences
53
+ };
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ deleteFacilitatorGuideFiles,
4
+ findFacilitatorGuideReferences
5
+ } from "./cli-HKORECAG.js";
6
+ import {
7
+ loadPackageContext
8
+ } from "./cli-XSVGKI3R.js";
9
+ import "./cli-TT36JCU5.js";
10
+ import "./cli-OXAUOWCN.js";
11
+ import {
12
+ operationError,
13
+ recordOperationResult
14
+ } from "./cli-KSGB2ZLK.js";
15
+ import {
16
+ confirmAction
17
+ } from "./cli-ZTWOE3ZT.js";
18
+ import "./cli-LQOHATY2.js";
19
+ import "./cli-IEMKI7J7.js";
20
+ import "./cli-OMWC75CC.js";
21
+ import "./cli-BYCHKSSH.js";
22
+ import "./cli-25RWY5BQ.js";
23
+ import "./cli-QWQMPCL6.js";
24
+ import "./cli-VQ6HVQW4.js";
25
+ import "./cli-F2D4GGUA.js";
26
+ import {
27
+ logger
28
+ } from "./cli-4YB3ROVR.js";
29
+ import "./cli-N6H6T2E2.js";
30
+
31
+ // cli/commands/resources/guide/delete.ts
32
+ async function deleteFacilitatorGuide(options) {
33
+ logger.info("\nDeleting facilitator guide...\n");
34
+ const identifier = "guide";
35
+ loadPackageContext(options.workingDir);
36
+ const references = findFacilitatorGuideReferences({
37
+ packagePath: options.workingDir,
38
+ identifier
39
+ });
40
+ logger.info(`Facilitator guide: ${identifier}`);
41
+ if (references.length > 0) {
42
+ logger.info("\nThis facilitator guide is referenced by:");
43
+ for (const ref of references) {
44
+ logger.info(` - ${ref}`);
45
+ }
46
+ logger.info("\nYou will need to remove these references manually.");
47
+ }
48
+ const confirmed = await confirmAction(
49
+ { message: "Are you sure you want to delete this facilitator guide?" },
50
+ options.yes
51
+ );
52
+ if (!confirmed) {
53
+ logger.info("\nDeletion cancelled.\n");
54
+ return;
55
+ }
56
+ logger.info("");
57
+ const result = deleteFacilitatorGuideFiles({
58
+ packagePath: options.workingDir,
59
+ identifier
60
+ });
61
+ if (!result.success) {
62
+ throw operationError(result, "Failed to delete facilitator guide files");
63
+ }
64
+ recordOperationResult(result);
65
+ for (const file of result.filesDeleted || []) {
66
+ logger.info(` \u2713 Deleted: ${file}`);
67
+ }
68
+ logger.info(" \u2713 Updated seriousgaming.sdk.json");
69
+ logger.success("Facilitator guide deleted successfully!");
70
+ }
71
+ export {
72
+ deleteFacilitatorGuide
73
+ };
@@ -0,0 +1,187 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ applyJsonPatch
4
+ } from "./cli-S5IVGDDD.js";
5
+ import {
6
+ assertNoRemovedManifestFields,
7
+ getPackageIdentifierError
8
+ } from "./cli-4VFZHLDG.js";
9
+ import {
10
+ resolveInputSource
11
+ } from "./cli-4UWFQNGF.js";
12
+ import {
13
+ updatePackageFiles
14
+ } from "./cli-4SIWLHQO.js";
15
+ import "./cli-IUS2YCD3.js";
16
+ import "./cli-QUNIRH7A.js";
17
+ import "./cli-J4UBELKF.js";
18
+ import "./cli-TT36JCU5.js";
19
+ import "./cli-OXAUOWCN.js";
20
+ import {
21
+ operationError,
22
+ recordOperationResult
23
+ } from "./cli-KSGB2ZLK.js";
24
+ import {
25
+ confirmAction,
26
+ input
27
+ } from "./cli-ZTWOE3ZT.js";
28
+ import "./cli-LQOHATY2.js";
29
+ import "./cli-IEMKI7J7.js";
30
+ import "./cli-OMWC75CC.js";
31
+ import "./cli-BYCHKSSH.js";
32
+ import "./cli-25RWY5BQ.js";
33
+ import "./cli-QWQMPCL6.js";
34
+ import "./cli-VQ6HVQW4.js";
35
+ import "./cli-F2D4GGUA.js";
36
+ import {
37
+ logger
38
+ } from "./cli-4YB3ROVR.js";
39
+ import {
40
+ CliError
41
+ } from "./cli-N6H6T2E2.js";
42
+
43
+ // cli/commands/resources/package/update.ts
44
+ import { existsSync, readFileSync } from "fs";
45
+ import { join } from "path";
46
+ var IDENTIFIER_CHANGE_WARNING = "\n\u26A0\uFE0F WARNING: The package identifier names the game everywhere it is published.\nA new identifier is a new game to a runtime, not a new version of this one.\n";
47
+ async function updatePackage(definitionInput, options) {
48
+ logger.info("\nUpdating package...\n");
49
+ const configPath = join(options.workingDir, "seriousgaming.sdk.json");
50
+ if (!existsSync(configPath)) {
51
+ throw new CliError(
52
+ "MANIFEST_NOT_FOUND",
53
+ "seriousgaming.sdk.json not found.\nThis command must be run in a Serious Gaming package directory."
54
+ );
55
+ }
56
+ let manifest;
57
+ try {
58
+ manifest = JSON.parse(readFileSync(configPath, "utf-8"));
59
+ } catch (error) {
60
+ throw new CliError(
61
+ "MANIFEST_INVALID",
62
+ "Could not read seriousgaming.sdk.json\n" + (error instanceof Error ? error.message : "Unknown error")
63
+ );
64
+ }
65
+ const existing = manifest;
66
+ const currentIdentifier = existing.identifier;
67
+ const locale = existing.supportedLocales?.[0] ?? "en";
68
+ const currentName = existing.locales?.[locale]?.name ?? currentIdentifier;
69
+ let settings = null;
70
+ if (options.patch) {
71
+ let operations;
72
+ try {
73
+ operations = JSON.parse(options.patch);
74
+ } catch {
75
+ throw new CliError("INPUT_INVALID", "--patch must be a valid JSON Patch array");
76
+ }
77
+ try {
78
+ settings = applyJsonPatch(manifest, operations);
79
+ } catch (error) {
80
+ throw new CliError(
81
+ "INPUT_INVALID",
82
+ `Failed to apply patch: ${error.message}`
83
+ );
84
+ }
85
+ } else {
86
+ const inputSource = await resolveInputSource(definitionInput, options.file);
87
+ if (inputSource.kind === "json") {
88
+ try {
89
+ settings = JSON.parse(inputSource.json);
90
+ } catch (error) {
91
+ throw new CliError(
92
+ "INPUT_INVALID",
93
+ "Failed to parse JSON definition\n" + (error instanceof Error ? error.message : "Unknown error")
94
+ );
95
+ }
96
+ }
97
+ }
98
+ if (settings) {
99
+ assertNoRemovedManifestFields(settings);
100
+ if (settings.identifier !== currentIdentifier) {
101
+ logger.info(IDENTIFIER_CHANGE_WARNING);
102
+ }
103
+ applyUpdate(options.workingDir, settings, currentIdentifier);
104
+ return;
105
+ }
106
+ logger.info("No JSON definition provided. Starting interactive mode...\n");
107
+ logger.info("Current package values:");
108
+ logger.info(` Identifier: ${currentIdentifier}`);
109
+ logger.info(` Name (${locale}): ${currentName}`);
110
+ logger.info(` Max ticks: ${existing.maxTicks ?? "(unset)"}`);
111
+ logger.info("");
112
+ const newIdentifier = await input({
113
+ message: "Package identifier (namespace-style):",
114
+ default: currentIdentifier,
115
+ validate: (value) => getPackageIdentifierError(value) || true
116
+ });
117
+ const newName = await input({
118
+ message: `Game name (${locale}):`,
119
+ default: currentName,
120
+ validate: (value) => value.trim() ? true : "A name is required"
121
+ });
122
+ const newTicks = await input({
123
+ message: "Number of ticks (maxTicks):",
124
+ default: existing.maxTicks === void 0 ? void 0 : String(existing.maxTicks),
125
+ validate: (value) => {
126
+ const num = Number(value);
127
+ if (isNaN(num)) return "Ticks must be a number";
128
+ if (num < 1) return "Ticks must be at least 1";
129
+ if (!Number.isInteger(num)) return "Ticks must be a whole number";
130
+ return true;
131
+ }
132
+ });
133
+ if (newIdentifier !== currentIdentifier) {
134
+ logger.info("");
135
+ logger.info(IDENTIFIER_CHANGE_WARNING);
136
+ const confirmChange = await confirmAction({
137
+ message: "Do you want to continue with this identifier change?",
138
+ default: false
139
+ });
140
+ if (!confirmChange) {
141
+ logger.info("\nPackage update cancelled.\n");
142
+ return;
143
+ }
144
+ }
145
+ applyUpdate(
146
+ options.workingDir,
147
+ {
148
+ ...existing,
149
+ identifier: newIdentifier,
150
+ locales: {
151
+ ...existing.locales,
152
+ [locale]: { name: newName }
153
+ },
154
+ maxTicks: Number(newTicks)
155
+ },
156
+ currentIdentifier
157
+ );
158
+ }
159
+ function applyUpdate(workingDir, settings, currentIdentifier) {
160
+ logger.info("Updating package files...\n");
161
+ const result = updatePackageFiles({ packagePath: workingDir, newSettings: settings });
162
+ if (!result.success) {
163
+ throw operationError(result, "Failed to update package files");
164
+ }
165
+ logger.success("Package updated successfully!");
166
+ recordOperationResult(result);
167
+ if (result.filesUpdated && result.filesUpdated.length > 0) {
168
+ logger.info("Files updated:");
169
+ for (const file of result.filesUpdated) {
170
+ logger.info(` \u2713 ${file}`);
171
+ }
172
+ }
173
+ if (result.directoriesRenamed && result.directoriesRenamed.length > 0) {
174
+ logger.info("\nDirectories renamed:");
175
+ for (const rename of result.directoriesRenamed) {
176
+ logger.info(` \u2713 ${rename.from} \u2192 ${rename.to}`);
177
+ }
178
+ }
179
+ if (settings.identifier !== currentIdentifier) {
180
+ logger.info("\nChanges:");
181
+ logger.info(` Identifier: ${currentIdentifier} \u2192 ${settings.identifier}`);
182
+ }
183
+ logger.info("");
184
+ }
185
+ export {
186
+ updatePackage
187
+ };
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ deletePresentationFiles,
4
+ findPresentationReferences
5
+ } from "./cli-4SIWLHQO.js";
6
+ import "./cli-IUS2YCD3.js";
7
+ import "./cli-QUNIRH7A.js";
8
+ import "./cli-J4UBELKF.js";
9
+ import {
10
+ loadPackageContext
11
+ } from "./cli-XSVGKI3R.js";
12
+ import "./cli-TT36JCU5.js";
13
+ import "./cli-OXAUOWCN.js";
14
+ import {
15
+ operationError,
16
+ recordOperationResult
17
+ } from "./cli-KSGB2ZLK.js";
18
+ import {
19
+ confirmAction
20
+ } from "./cli-ZTWOE3ZT.js";
21
+ import {
22
+ generateCommand
23
+ } from "./cli-LQOHATY2.js";
24
+ import "./cli-IEMKI7J7.js";
25
+ import "./cli-OMWC75CC.js";
26
+ import "./cli-BYCHKSSH.js";
27
+ import "./cli-25RWY5BQ.js";
28
+ import "./cli-QWQMPCL6.js";
29
+ import "./cli-VQ6HVQW4.js";
30
+ import "./cli-F2D4GGUA.js";
31
+ import {
32
+ logger
33
+ } from "./cli-4YB3ROVR.js";
34
+ import "./cli-N6H6T2E2.js";
35
+
36
+ // cli/commands/resources/presentation/delete.ts
37
+ async function deletePresentation(options) {
38
+ logger.info("\nDeleting presentation...\n");
39
+ const identifier = "presentation";
40
+ loadPackageContext(options.workingDir);
41
+ const references = findPresentationReferences({
42
+ packagePath: options.workingDir,
43
+ identifier
44
+ });
45
+ logger.info(`Presentation: ${identifier}`);
46
+ if (references.length > 0) {
47
+ logger.info("\nThis presentation is referenced by:");
48
+ for (const ref of references) {
49
+ logger.info(` - ${ref}`);
50
+ }
51
+ logger.info("\nThese references will be removed.");
52
+ }
53
+ const confirmed = await confirmAction(
54
+ { message: "Are you sure you want to delete this presentation?" },
55
+ options.yes
56
+ );
57
+ if (!confirmed) {
58
+ logger.info("\nDeletion cancelled.\n");
59
+ return;
60
+ }
61
+ logger.info("");
62
+ const result = deletePresentationFiles({
63
+ packagePath: options.workingDir,
64
+ identifier
65
+ });
66
+ if (!result.success) {
67
+ throw operationError(result, "Failed to delete presentation files");
68
+ }
69
+ recordOperationResult(result);
70
+ for (const file of result.filesDeleted || []) {
71
+ logger.info(` \u2713 Deleted: ${file}`);
72
+ }
73
+ for (const ref of result.referencesRemoved || []) {
74
+ logger.info(` \u2713 Removed reference from: ${ref}`);
75
+ }
76
+ logger.info(" \u2713 Updated seriousgaming.sdk.json");
77
+ logger.info("\nRegenerating TypeScript types...\n");
78
+ try {
79
+ await generateCommand({ workingDir: options.workingDir });
80
+ logger.success("TypeScript types regenerated successfully!");
81
+ } catch (error) {
82
+ logger.warn("\nWarning: Failed to regenerate TypeScript types:");
83
+ logger.warn(error instanceof Error ? error.message : "Unknown error");
84
+ }
85
+ logger.success("Presentation deleted successfully!");
86
+ }
87
+ export {
88
+ deletePresentation
89
+ };