@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,100 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
resolveSession
|
|
4
|
+
} from "./cli-6K3VQQUS.js";
|
|
5
|
+
import "./cli-WU43JT4T.js";
|
|
6
|
+
import {
|
|
7
|
+
emit,
|
|
8
|
+
teamIndexFromArgument,
|
|
9
|
+
viewReport,
|
|
10
|
+
viewSummary,
|
|
11
|
+
warnIfStale
|
|
12
|
+
} from "./cli-L7VYSXQK.js";
|
|
13
|
+
import "./cli-FQRVFGN6.js";
|
|
14
|
+
import "./cli-XSLNH5PR.js";
|
|
15
|
+
import "./cli-TDSQSCX4.js";
|
|
16
|
+
import "./cli-SRHBXZCN.js";
|
|
17
|
+
import "./cli-KGT5L7VZ.js";
|
|
18
|
+
import "./cli-4LKXZQ2B.js";
|
|
19
|
+
import "./cli-MMN4BPO4.js";
|
|
20
|
+
import "./cli-QUNIRH7A.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 "./cli-4YB3ROVR.js";
|
|
27
|
+
import {
|
|
28
|
+
CliError
|
|
29
|
+
} from "./cli-N6H6T2E2.js";
|
|
30
|
+
|
|
31
|
+
// cli/commands/view.ts
|
|
32
|
+
async function viewCommand(options) {
|
|
33
|
+
const session = await resolveSession({
|
|
34
|
+
packagePath: options.workingDir,
|
|
35
|
+
...options.walkthrough ? { runKind: "walkthrough" } : {},
|
|
36
|
+
...options.server === false ? { noServer: true } : {}
|
|
37
|
+
});
|
|
38
|
+
try {
|
|
39
|
+
const state = await session.state();
|
|
40
|
+
warnIfStale(state);
|
|
41
|
+
const teamIndex = teamIndexFromArgument(state, options.team);
|
|
42
|
+
if (options.summary && (options.full || options.tick !== void 0)) {
|
|
43
|
+
throw new CliError(
|
|
44
|
+
"USAGE_BAD_FLAG",
|
|
45
|
+
`--summary reads the head in brief, so it cannot be combined with ${options.full ? "--full" : "--tick"}`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
if (options.summary) {
|
|
49
|
+
emit(viewSummary(state, teamIndex));
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (options.tick !== void 0) {
|
|
53
|
+
emit(await pastState(session, state, options, teamIndex));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (options.to !== void 0)
|
|
57
|
+
throw new CliError("USAGE_BAD_FLAG", "--to reads a range, so it needs --tick");
|
|
58
|
+
emit(options.full ? state : viewReport(state, teamIndex));
|
|
59
|
+
} finally {
|
|
60
|
+
await session.close();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function pastState(session, state, options, teamIndex) {
|
|
64
|
+
if (options.full)
|
|
65
|
+
throw new CliError(
|
|
66
|
+
"USAGE_BAD_FLAG",
|
|
67
|
+
"--full reads the head, so it cannot be combined with --tick"
|
|
68
|
+
);
|
|
69
|
+
const fromTick = tickFromArgument(options.tick, "--tick");
|
|
70
|
+
const toTick = options.to === void 0 ? void 0 : tickFromArgument(options.to, "--to");
|
|
71
|
+
if (toTick !== void 0 && toTick < fromTick) {
|
|
72
|
+
throw new CliError("USAGE_BAD_FLAG", `--to ${toTick} is before --tick ${fromTick}`);
|
|
73
|
+
}
|
|
74
|
+
if (fromTick >= state.session.completedTicks) {
|
|
75
|
+
throw new CliError(
|
|
76
|
+
"USAGE_BAD_ARGUMENT",
|
|
77
|
+
`Tick ${fromTick} is not in the past: the session has completed ${state.session.completedTicks} ticks. Use sdk view for the head`
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
const result = await session.send({
|
|
81
|
+
type: "getPastState",
|
|
82
|
+
query: {
|
|
83
|
+
fromTick,
|
|
84
|
+
...toTick === void 0 ? {} : { toTick },
|
|
85
|
+
teams: teamIndex === void 0 ? "all" : `team-${teamIndex + 1}`
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
if (!("type" in result) || result.type !== "pastState") {
|
|
89
|
+
throw new CliError("DEV_SERVER_OUTDATED", "The session did not answer with past state");
|
|
90
|
+
}
|
|
91
|
+
return { entries: result.entries };
|
|
92
|
+
}
|
|
93
|
+
function tickFromArgument(value, flag) {
|
|
94
|
+
if (!/^\d+$/.test(value))
|
|
95
|
+
throw new CliError("USAGE_BAD_ARGUMENT", `${flag} takes a tick number, and got "${value}"`);
|
|
96
|
+
return Number(value);
|
|
97
|
+
}
|
|
98
|
+
export {
|
|
99
|
+
viewCommand
|
|
100
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
resolvePatchedDefinition
|
|
4
|
+
} from "./cli-5IAW3LIF.js";
|
|
5
|
+
import "./cli-S5IVGDDD.js";
|
|
6
|
+
import {
|
|
7
|
+
getResourceIdentifierError,
|
|
8
|
+
readAuthoredBundle
|
|
9
|
+
} from "./cli-4VFZHLDG.js";
|
|
10
|
+
import {
|
|
11
|
+
resolveInputSource
|
|
12
|
+
} from "./cli-4UWFQNGF.js";
|
|
13
|
+
import {
|
|
14
|
+
updateValidatorFiles
|
|
15
|
+
} from "./cli-4SIWLHQO.js";
|
|
16
|
+
import "./cli-IUS2YCD3.js";
|
|
17
|
+
import "./cli-QUNIRH7A.js";
|
|
18
|
+
import "./cli-J4UBELKF.js";
|
|
19
|
+
import {
|
|
20
|
+
loadPackageContext
|
|
21
|
+
} from "./cli-XSVGKI3R.js";
|
|
22
|
+
import "./cli-TT36JCU5.js";
|
|
23
|
+
import {
|
|
24
|
+
findBundleFile
|
|
25
|
+
} from "./cli-OXAUOWCN.js";
|
|
26
|
+
import {
|
|
27
|
+
operationError,
|
|
28
|
+
printOperationResult,
|
|
29
|
+
regenerateTypes
|
|
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
|
+
validateSDKValidator
|
|
42
|
+
} from "./cli-VQ6HVQW4.js";
|
|
43
|
+
import "./cli-F2D4GGUA.js";
|
|
44
|
+
import {
|
|
45
|
+
logger
|
|
46
|
+
} from "./cli-4YB3ROVR.js";
|
|
47
|
+
import {
|
|
48
|
+
CliError
|
|
49
|
+
} from "./cli-N6H6T2E2.js";
|
|
50
|
+
|
|
51
|
+
// cli/commands/resources/validator/update.ts
|
|
52
|
+
import { readFileSync } from "fs";
|
|
53
|
+
async function updateValidator(identifier, definitionInput, options) {
|
|
54
|
+
logger.info("\nUpdating validator...\n");
|
|
55
|
+
loadPackageContext(options.workingDir);
|
|
56
|
+
let jsonDefinition = null;
|
|
57
|
+
if (options.patch) {
|
|
58
|
+
jsonDefinition = resolvePatchedDefinition({
|
|
59
|
+
patch: options.patch,
|
|
60
|
+
workingDir: options.workingDir,
|
|
61
|
+
type: "validator",
|
|
62
|
+
identifier,
|
|
63
|
+
resourceLabel: "Validator"
|
|
64
|
+
});
|
|
65
|
+
} else {
|
|
66
|
+
const inputSource = await resolveInputSource(definitionInput, options.file);
|
|
67
|
+
if (inputSource.kind === "json") jsonDefinition = inputSource.json;
|
|
68
|
+
}
|
|
69
|
+
if (jsonDefinition) {
|
|
70
|
+
const validatorInput = readAuthoredBundle({
|
|
71
|
+
json: jsonDefinition,
|
|
72
|
+
type: "validator",
|
|
73
|
+
command: "update",
|
|
74
|
+
validate: validateSDKValidator,
|
|
75
|
+
identifier
|
|
76
|
+
});
|
|
77
|
+
logger.info("Updating validator files...\n");
|
|
78
|
+
const result2 = updateValidatorFiles({
|
|
79
|
+
packagePath: options.workingDir,
|
|
80
|
+
oldIdentifier: identifier,
|
|
81
|
+
newDefinition: validatorInput.definition,
|
|
82
|
+
newIdentifier: validatorInput.definition?.identifier
|
|
83
|
+
});
|
|
84
|
+
if (!result2.success) {
|
|
85
|
+
throw operationError(result2, "Failed to update validator files");
|
|
86
|
+
}
|
|
87
|
+
logger.success("Validator updated successfully!");
|
|
88
|
+
printOperationResult(result2);
|
|
89
|
+
await regenerateTypes(options.workingDir);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
logger.info("No JSON definition provided. Starting interactive mode...\n");
|
|
93
|
+
const validatorFilePath = findBundleFile(options.workingDir, "validator", identifier);
|
|
94
|
+
if (!validatorFilePath) {
|
|
95
|
+
throw new CliError("RESOURCE_NOT_FOUND", `Validator "${identifier}" not found`);
|
|
96
|
+
}
|
|
97
|
+
let existingBundle;
|
|
98
|
+
try {
|
|
99
|
+
existingBundle = JSON.parse(readFileSync(validatorFilePath, "utf-8"));
|
|
100
|
+
} catch {
|
|
101
|
+
throw new CliError("BUNDLE_INVALID", "Could not read validator file");
|
|
102
|
+
}
|
|
103
|
+
const existingDef = { ...existingBundle.definition, identifier };
|
|
104
|
+
logger.info("Current values:");
|
|
105
|
+
logger.info(` Identifier: ${existingDef.identifier}`);
|
|
106
|
+
logger.info("");
|
|
107
|
+
const newIdentifier = await input({
|
|
108
|
+
message: "Validator name:",
|
|
109
|
+
default: existingDef.identifier,
|
|
110
|
+
validate: (value) => {
|
|
111
|
+
const error = getResourceIdentifierError(value);
|
|
112
|
+
return error || true;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
if (newIdentifier !== existingDef.identifier) {
|
|
116
|
+
logger.info("\n\u26A0\uFE0F Changing the identifier will update all game references.\n");
|
|
117
|
+
}
|
|
118
|
+
const result = updateValidatorFiles({
|
|
119
|
+
packagePath: options.workingDir,
|
|
120
|
+
oldIdentifier: identifier,
|
|
121
|
+
newDefinition: { ...existingDef, identifier: newIdentifier }
|
|
122
|
+
});
|
|
123
|
+
if (!result.success) {
|
|
124
|
+
throw operationError(result, "Failed to update validator files");
|
|
125
|
+
}
|
|
126
|
+
logger.success("Validator updated successfully!");
|
|
127
|
+
await regenerateTypes(options.workingDir);
|
|
128
|
+
}
|
|
129
|
+
export {
|
|
130
|
+
updateValidator
|
|
131
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
generateCommand
|
|
4
|
+
} from "./cli-LQOHATY2.js";
|
|
5
|
+
import "./cli-IEMKI7J7.js";
|
|
6
|
+
import "./cli-OMWC75CC.js";
|
|
7
|
+
import "./cli-BYCHKSSH.js";
|
|
8
|
+
import "./cli-25RWY5BQ.js";
|
|
9
|
+
import "./cli-QWQMPCL6.js";
|
|
10
|
+
import "./cli-VQ6HVQW4.js";
|
|
11
|
+
import "./cli-F2D4GGUA.js";
|
|
12
|
+
import "./cli-4YB3ROVR.js";
|
|
13
|
+
import "./cli-N6H6T2E2.js";
|
|
14
|
+
export {
|
|
15
|
+
generateCommand
|
|
16
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// cli/utils/docs-path.ts
|
|
4
|
+
import { dirname, join } from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
function resolveDocsPath() {
|
|
7
|
+
const currentFilePath = fileURLToPath(import.meta.url);
|
|
8
|
+
const currentDir = dirname(currentFilePath);
|
|
9
|
+
const fromSource = currentFilePath.includes("/cli/utils/") || currentFilePath.includes("\\cli\\utils\\");
|
|
10
|
+
return fromSource ? join(currentDir, "../../docs") : join(currentDir, "./docs");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
resolveDocsPath
|
|
15
|
+
};
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
reviewSchemaProperties
|
|
4
|
+
} from "./cli-RZITKPJX.js";
|
|
5
|
+
import {
|
|
6
|
+
resolvePatchedDefinition
|
|
7
|
+
} from "./cli-5IAW3LIF.js";
|
|
8
|
+
import "./cli-S5IVGDDD.js";
|
|
9
|
+
import {
|
|
10
|
+
getResourceIdentifierError,
|
|
11
|
+
readAuthoredBundle
|
|
12
|
+
} from "./cli-4VFZHLDG.js";
|
|
13
|
+
import {
|
|
14
|
+
resolveInputSource
|
|
15
|
+
} from "./cli-4UWFQNGF.js";
|
|
16
|
+
import {
|
|
17
|
+
updateCapabilityFiles
|
|
18
|
+
} from "./cli-4SIWLHQO.js";
|
|
19
|
+
import "./cli-IUS2YCD3.js";
|
|
20
|
+
import {
|
|
21
|
+
extractSchemaProperties,
|
|
22
|
+
wrapAsFullSchema
|
|
23
|
+
} from "./cli-QUNIRH7A.js";
|
|
24
|
+
import "./cli-J4UBELKF.js";
|
|
25
|
+
import {
|
|
26
|
+
loadPackageContext
|
|
27
|
+
} from "./cli-XSVGKI3R.js";
|
|
28
|
+
import "./cli-TT36JCU5.js";
|
|
29
|
+
import {
|
|
30
|
+
findBundleFile
|
|
31
|
+
} from "./cli-OXAUOWCN.js";
|
|
32
|
+
import {
|
|
33
|
+
operationError,
|
|
34
|
+
printOperationResult,
|
|
35
|
+
regenerateTypes
|
|
36
|
+
} from "./cli-KSGB2ZLK.js";
|
|
37
|
+
import {
|
|
38
|
+
confirmAction,
|
|
39
|
+
input
|
|
40
|
+
} from "./cli-ZTWOE3ZT.js";
|
|
41
|
+
import "./cli-LQOHATY2.js";
|
|
42
|
+
import "./cli-IEMKI7J7.js";
|
|
43
|
+
import "./cli-OMWC75CC.js";
|
|
44
|
+
import "./cli-BYCHKSSH.js";
|
|
45
|
+
import "./cli-25RWY5BQ.js";
|
|
46
|
+
import "./cli-QWQMPCL6.js";
|
|
47
|
+
import {
|
|
48
|
+
validateSDKCapability
|
|
49
|
+
} from "./cli-VQ6HVQW4.js";
|
|
50
|
+
import "./cli-F2D4GGUA.js";
|
|
51
|
+
import {
|
|
52
|
+
logger
|
|
53
|
+
} from "./cli-4YB3ROVR.js";
|
|
54
|
+
import {
|
|
55
|
+
CliError
|
|
56
|
+
} from "./cli-N6H6T2E2.js";
|
|
57
|
+
|
|
58
|
+
// cli/commands/resources/capability/update.ts
|
|
59
|
+
import { readFileSync } from "fs";
|
|
60
|
+
async function updateCapability(identifier, definitionInput, options) {
|
|
61
|
+
logger.info("\nUpdating capability...\n");
|
|
62
|
+
loadPackageContext(options.workingDir);
|
|
63
|
+
let jsonDefinition = null;
|
|
64
|
+
if (options.patch) {
|
|
65
|
+
jsonDefinition = resolvePatchedDefinition({
|
|
66
|
+
patch: options.patch,
|
|
67
|
+
workingDir: options.workingDir,
|
|
68
|
+
type: "capability",
|
|
69
|
+
identifier,
|
|
70
|
+
resourceLabel: "Capability"
|
|
71
|
+
});
|
|
72
|
+
} else {
|
|
73
|
+
const inputSource = await resolveInputSource(definitionInput, options.file);
|
|
74
|
+
if (inputSource.kind === "json") jsonDefinition = inputSource.json;
|
|
75
|
+
}
|
|
76
|
+
if (jsonDefinition) {
|
|
77
|
+
const capabilityInput = readAuthoredBundle({
|
|
78
|
+
json: jsonDefinition,
|
|
79
|
+
type: "capability",
|
|
80
|
+
command: "update",
|
|
81
|
+
validate: validateSDKCapability,
|
|
82
|
+
identifier,
|
|
83
|
+
validationHint: "Full replacement requires all fields to be specified."
|
|
84
|
+
});
|
|
85
|
+
logger.info("Updating capability files...\n");
|
|
86
|
+
const result2 = updateCapabilityFiles({
|
|
87
|
+
packagePath: options.workingDir,
|
|
88
|
+
oldIdentifier: identifier,
|
|
89
|
+
newDefinition: capabilityInput.definition,
|
|
90
|
+
newIdentifier: capabilityInput.definition?.identifier
|
|
91
|
+
});
|
|
92
|
+
if (!result2.success) {
|
|
93
|
+
throw operationError(result2, "Failed to update capability files");
|
|
94
|
+
}
|
|
95
|
+
logger.success("Capability updated successfully!");
|
|
96
|
+
printOperationResult(result2);
|
|
97
|
+
await regenerateTypes(options.workingDir);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
logger.info("No JSON definition provided. Starting interactive mode...\n");
|
|
101
|
+
const capabilityPath = findBundleFile(options.workingDir, "capability", identifier);
|
|
102
|
+
if (!capabilityPath) {
|
|
103
|
+
throw new CliError("RESOURCE_NOT_FOUND", `Capability "${identifier}" not found
|
|
104
|
+
`);
|
|
105
|
+
}
|
|
106
|
+
let existingBundle;
|
|
107
|
+
try {
|
|
108
|
+
const capabilityContent = readFileSync(capabilityPath, "utf-8");
|
|
109
|
+
existingBundle = JSON.parse(capabilityContent);
|
|
110
|
+
} catch (error) {
|
|
111
|
+
throw new CliError(
|
|
112
|
+
"BUNDLE_INVALID",
|
|
113
|
+
"Could not read capability file\n" + (error instanceof Error ? error.message : "Unknown error")
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
const validation = validateSDKCapability({
|
|
117
|
+
...existingBundle,
|
|
118
|
+
definition: { ...existingBundle.definition, identifier }
|
|
119
|
+
});
|
|
120
|
+
if (!validation.valid) {
|
|
121
|
+
throw new CliError(
|
|
122
|
+
"BUNDLE_INVALID",
|
|
123
|
+
`Invalid capability file format
|
|
124
|
+
${validation.errors}`
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
const existingDef = { ...existingBundle.definition, identifier };
|
|
128
|
+
logger.info("Current capability values:");
|
|
129
|
+
logger.info(` Identifier: ${existingDef.identifier}`);
|
|
130
|
+
const varProps = extractSchemaProperties(
|
|
131
|
+
existingDef.variablesSchema
|
|
132
|
+
);
|
|
133
|
+
const varCount = Object.keys(varProps).length;
|
|
134
|
+
logger.info(` Variables: ${varCount} defined`);
|
|
135
|
+
if (varCount > 0) {
|
|
136
|
+
logger.info(" Variable names:");
|
|
137
|
+
for (const varName of Object.keys(varProps)) {
|
|
138
|
+
const varDef = varProps[varName];
|
|
139
|
+
const varType = varDef?.type ?? "unknown";
|
|
140
|
+
logger.info(` - ${varName} (${varType})`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
logger.info("");
|
|
144
|
+
const newIdentifier = await input({
|
|
145
|
+
message: "Capability name:",
|
|
146
|
+
default: existingDef.identifier,
|
|
147
|
+
validate: (value) => {
|
|
148
|
+
const error = getResourceIdentifierError(value);
|
|
149
|
+
return error || true;
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
if (newIdentifier !== existingDef.identifier) {
|
|
153
|
+
logger.info("");
|
|
154
|
+
logger.info(
|
|
155
|
+
"\u26A0\uFE0F WARNING: Changing the identifier will update all references to this capability."
|
|
156
|
+
);
|
|
157
|
+
logger.info(
|
|
158
|
+
"This includes the engine, user interfaces and hooks that use this capability.\n"
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
logger.info("");
|
|
162
|
+
const { properties: newVariablesSchema, changes } = await reviewSchemaProperties(
|
|
163
|
+
extractSchemaProperties(existingDef.variablesSchema),
|
|
164
|
+
{
|
|
165
|
+
allowDelete: true,
|
|
166
|
+
allowAdd: true
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
logger.info("\nChanges to be made:");
|
|
170
|
+
if (newIdentifier !== existingDef.identifier) {
|
|
171
|
+
logger.info(` Identifier: ${existingDef.identifier} \u2192 ${newIdentifier} (CHANGED)`);
|
|
172
|
+
} else {
|
|
173
|
+
logger.info(` Identifier: ${existingDef.identifier} (unchanged)`);
|
|
174
|
+
}
|
|
175
|
+
logger.info(" Variables:");
|
|
176
|
+
if (changes.kept.length > 0) {
|
|
177
|
+
for (const name of changes.kept) {
|
|
178
|
+
logger.info(` - ${name}: UNCHANGED`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (changes.modified.length > 0) {
|
|
182
|
+
for (const mod of changes.modified) {
|
|
183
|
+
logger.info(` - ${mod.name}: MODIFIED (${mod.changes})`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (changes.deleted.length > 0) {
|
|
187
|
+
for (const name of changes.deleted) {
|
|
188
|
+
logger.info(` - ${name}: DELETED`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (changes.added.length > 0) {
|
|
192
|
+
for (const name of changes.added) {
|
|
193
|
+
logger.info(` + ${name}: ADDED`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (changes.kept.length === 0 && changes.modified.length === 0 && changes.deleted.length === 0 && changes.added.length === 0) {
|
|
197
|
+
logger.info(" (no variables)");
|
|
198
|
+
}
|
|
199
|
+
logger.info(
|
|
200
|
+
"\nThis will update 1 file and may update references in the engine, UIs and hooks."
|
|
201
|
+
);
|
|
202
|
+
logger.info("");
|
|
203
|
+
const confirmed = await confirmAction({ message: "Continue with update?", default: true });
|
|
204
|
+
if (!confirmed) {
|
|
205
|
+
logger.info("\nUpdate cancelled.\n");
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
logger.info("\nUpdating capability files...\n");
|
|
209
|
+
const result = updateCapabilityFiles({
|
|
210
|
+
packagePath: options.workingDir,
|
|
211
|
+
oldIdentifier: existingDef.identifier,
|
|
212
|
+
newDefinition: {
|
|
213
|
+
identifier: newIdentifier,
|
|
214
|
+
variablesSchema: wrapAsFullSchema(newVariablesSchema)
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
if (!result.success) {
|
|
218
|
+
throw operationError(result, "Failed to update capability files");
|
|
219
|
+
}
|
|
220
|
+
logger.success("Capability updated successfully!");
|
|
221
|
+
printOperationResult(result);
|
|
222
|
+
await regenerateTypes(options.workingDir);
|
|
223
|
+
}
|
|
224
|
+
export {
|
|
225
|
+
updateCapability
|
|
226
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
deleteUserInterfaceFiles,
|
|
4
|
+
findUserInterfaceReferences
|
|
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
|
+
regenerateTypes
|
|
18
|
+
} from "./cli-KSGB2ZLK.js";
|
|
19
|
+
import {
|
|
20
|
+
confirmAction
|
|
21
|
+
} from "./cli-ZTWOE3ZT.js";
|
|
22
|
+
import "./cli-LQOHATY2.js";
|
|
23
|
+
import "./cli-IEMKI7J7.js";
|
|
24
|
+
import "./cli-OMWC75CC.js";
|
|
25
|
+
import "./cli-BYCHKSSH.js";
|
|
26
|
+
import "./cli-25RWY5BQ.js";
|
|
27
|
+
import "./cli-QWQMPCL6.js";
|
|
28
|
+
import "./cli-VQ6HVQW4.js";
|
|
29
|
+
import "./cli-F2D4GGUA.js";
|
|
30
|
+
import {
|
|
31
|
+
logger
|
|
32
|
+
} from "./cli-4YB3ROVR.js";
|
|
33
|
+
import "./cli-N6H6T2E2.js";
|
|
34
|
+
|
|
35
|
+
// cli/commands/resources/ui/delete.ts
|
|
36
|
+
async function deleteUserInterface(options) {
|
|
37
|
+
logger.info("\nDeleting user interface...\n");
|
|
38
|
+
const identifier = "ui";
|
|
39
|
+
loadPackageContext(options.workingDir);
|
|
40
|
+
const references = findUserInterfaceReferences({
|
|
41
|
+
packagePath: options.workingDir,
|
|
42
|
+
identifier
|
|
43
|
+
});
|
|
44
|
+
logger.info(`User Interface: ${identifier}`);
|
|
45
|
+
if (references.length > 0) {
|
|
46
|
+
logger.info("\nThis user interface is used in games:");
|
|
47
|
+
for (const ref of references) {
|
|
48
|
+
logger.info(` - ${ref}`);
|
|
49
|
+
}
|
|
50
|
+
logger.info("\nThese references will be removed.");
|
|
51
|
+
}
|
|
52
|
+
const confirmed = await confirmAction(
|
|
53
|
+
{ message: "Are you sure you want to delete this user interface?" },
|
|
54
|
+
options.yes
|
|
55
|
+
);
|
|
56
|
+
if (!confirmed) {
|
|
57
|
+
logger.info("\nDeletion cancelled.\n");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
logger.info("");
|
|
61
|
+
const result = deleteUserInterfaceFiles({
|
|
62
|
+
packagePath: options.workingDir,
|
|
63
|
+
identifier
|
|
64
|
+
});
|
|
65
|
+
if (!result.success) {
|
|
66
|
+
throw operationError(result, "Failed to delete user interface files");
|
|
67
|
+
}
|
|
68
|
+
recordOperationResult(result);
|
|
69
|
+
for (const file of result.filesDeleted || []) {
|
|
70
|
+
logger.info(` \u2713 Deleted: ${file}`);
|
|
71
|
+
}
|
|
72
|
+
for (const ref of result.referencesRemoved || []) {
|
|
73
|
+
logger.info(` \u2713 Removed reference from: ${ref}`);
|
|
74
|
+
}
|
|
75
|
+
logger.info(" \u2713 Updated seriousgaming.sdk.json");
|
|
76
|
+
await regenerateTypes(options.workingDir);
|
|
77
|
+
logger.success("User interface deleted successfully!");
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
deleteUserInterface
|
|
81
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
getGlobalSetting,
|
|
4
|
+
loadGlobalSettings,
|
|
5
|
+
loadGlobalSettingsForWrite,
|
|
6
|
+
resolveGlobalSettingsPath,
|
|
7
|
+
saveGlobalSettings,
|
|
8
|
+
setGlobalSetting
|
|
9
|
+
} from "./cli-MMN4BPO4.js";
|
|
10
|
+
import {
|
|
11
|
+
logger
|
|
12
|
+
} from "./cli-4YB3ROVR.js";
|
|
13
|
+
import {
|
|
14
|
+
reportResult
|
|
15
|
+
} from "./cli-N6H6T2E2.js";
|
|
16
|
+
|
|
17
|
+
// cli/commands/config.ts
|
|
18
|
+
async function configPathCommand() {
|
|
19
|
+
const path = resolveGlobalSettingsPath();
|
|
20
|
+
reportResult({ path }, () => console.log(path));
|
|
21
|
+
}
|
|
22
|
+
async function configGetCommand(key) {
|
|
23
|
+
const settings = loadGlobalSettings();
|
|
24
|
+
const value = getGlobalSetting(settings, key);
|
|
25
|
+
reportResult({ key, value: value ?? null }, () => {
|
|
26
|
+
if (value !== void 0) console.log(value);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async function configSetCommand(key, value) {
|
|
30
|
+
const path = resolveGlobalSettingsPath();
|
|
31
|
+
const settings = loadGlobalSettingsForWrite(path);
|
|
32
|
+
const replaced = getGlobalSetting(settings, key) !== void 0;
|
|
33
|
+
const updated = setGlobalSetting(settings, key, value);
|
|
34
|
+
saveGlobalSettings(updated, path);
|
|
35
|
+
reportResult(
|
|
36
|
+
{ key, path, replaced },
|
|
37
|
+
() => logger.success(
|
|
38
|
+
replaced ? `Set ${key} in ${path} (replaced the previous value)` : `Set ${key} in ${path}`
|
|
39
|
+
)
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
configGetCommand,
|
|
44
|
+
configPathCommand,
|
|
45
|
+
configSetCommand
|
|
46
|
+
};
|