@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,307 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
stopLockedServer
|
|
4
|
+
} from "./cli-WU43JT4T.js";
|
|
5
|
+
import {
|
|
6
|
+
PENDING_CHANGES_HINT,
|
|
7
|
+
Session,
|
|
8
|
+
isQuery
|
|
9
|
+
} from "./cli-XSLNH5PR.js";
|
|
10
|
+
import {
|
|
11
|
+
loadEnvironmentConfig
|
|
12
|
+
} from "./cli-TDSQSCX4.js";
|
|
13
|
+
import {
|
|
14
|
+
readLockFile,
|
|
15
|
+
toolsIdentity
|
|
16
|
+
} from "./cli-SRHBXZCN.js";
|
|
17
|
+
import {
|
|
18
|
+
CliError,
|
|
19
|
+
JSON_ENV_VAR,
|
|
20
|
+
isErrorCode,
|
|
21
|
+
recordWarning
|
|
22
|
+
} from "./cli-N6H6T2E2.js";
|
|
23
|
+
|
|
24
|
+
// cli/client/session-client.ts
|
|
25
|
+
import { spawn } from "child_process";
|
|
26
|
+
import { dirname, join, resolve } from "path";
|
|
27
|
+
import { fileURLToPath } from "url";
|
|
28
|
+
var DEV_URL_ENV_VAR = "SERIOUSGAMING_DEV_URL";
|
|
29
|
+
async function resolveSession(options) {
|
|
30
|
+
const packagePath = resolve(options.packagePath);
|
|
31
|
+
const run = options.runKind ?? "session";
|
|
32
|
+
if (options.noServer) return startLocalSession(packagePath, options);
|
|
33
|
+
const named = process.env[DEV_URL_ENV_VAR]?.trim().replace(/\/+$/, "");
|
|
34
|
+
if (named) {
|
|
35
|
+
await relayNotices(named, run, {
|
|
36
|
+
hint: `${DEV_URL_ENV_VAR} names ${named}. Unset it to use this package's own dev server.`
|
|
37
|
+
});
|
|
38
|
+
return connect(named, run);
|
|
39
|
+
}
|
|
40
|
+
const running = await readLockFile(packagePath);
|
|
41
|
+
if (running) {
|
|
42
|
+
const mismatch = toolsMismatch(running);
|
|
43
|
+
if (mismatch === null) {
|
|
44
|
+
const url2 = `http://localhost:${running.port}`;
|
|
45
|
+
await relayNotices(url2, run);
|
|
46
|
+
return connect(url2, run);
|
|
47
|
+
}
|
|
48
|
+
if (!running.background || options.autoStart === false) {
|
|
49
|
+
throw new CliError(
|
|
50
|
+
"SESSION_STALE",
|
|
51
|
+
`The dev server running for this package (pid ${running.pid}) was started by different tools: ${mismatch}. Its answers may not match what is on disk.`,
|
|
52
|
+
{
|
|
53
|
+
hint: "Stop it with `sdk dev stop`, then start `sdk dev` again or rerun the command."
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
await stopLockedServer(packagePath, running);
|
|
58
|
+
const message = `The background dev server for this package was started by different tools (${mismatch}), so it was stopped and a fresh one started. Its session did not carry over.`;
|
|
59
|
+
recordWarning(message, "SESSION_RESTARTED");
|
|
60
|
+
console.error(`Warning: ${message}`);
|
|
61
|
+
}
|
|
62
|
+
if (options.autoStart === false) {
|
|
63
|
+
throw new CliError(
|
|
64
|
+
"NO_SESSION",
|
|
65
|
+
"No dev server is running for this package.\nStart one with `sdk dev`, or pass --no-server to run this command on its own."
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
const url = await startBackgroundServer(packagePath, options);
|
|
69
|
+
const session = connect(url, run);
|
|
70
|
+
if ((await session.state()).session.inSetup) {
|
|
71
|
+
await session.send({ type: "play" });
|
|
72
|
+
}
|
|
73
|
+
await relayNotices(url, run);
|
|
74
|
+
return session;
|
|
75
|
+
}
|
|
76
|
+
function toolsMismatch(lock) {
|
|
77
|
+
const mine = toolsIdentity();
|
|
78
|
+
if (lock.toolsVersion !== mine.version) {
|
|
79
|
+
return `version ${lock.toolsVersion ?? "unknown"}, where this CLI is ${mine.version}`;
|
|
80
|
+
}
|
|
81
|
+
if (lock.toolsPath !== mine.path) {
|
|
82
|
+
return `${lock.toolsPath ?? "an unknown install"}, where this CLI is ${mine.path}`;
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
async function relayNotices(url, run, unreachable) {
|
|
87
|
+
const query = run === "walkthrough" ? "?run=walkthrough" : "";
|
|
88
|
+
let notices = [];
|
|
89
|
+
try {
|
|
90
|
+
const response = await fetch(`${url}/api/session${query}`);
|
|
91
|
+
const body = await response.json();
|
|
92
|
+
notices = Array.isArray(body.warnings) ? body.warnings : [];
|
|
93
|
+
} catch (error) {
|
|
94
|
+
if (!unreachable) return;
|
|
95
|
+
throw new CliError(
|
|
96
|
+
"DEV_SERVER_UNREACHABLE",
|
|
97
|
+
`The dev server at ${url} did not answer: ${error instanceof Error ? error.message : String(error)}`,
|
|
98
|
+
{ hint: unreachable.hint }
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
for (const notice of notices) {
|
|
102
|
+
recordWarning(notice.message, notice.code);
|
|
103
|
+
console.error(
|
|
104
|
+
notice.code === "SETTINGS_STALE" ? `Warning: ${notice.message}.
|
|
105
|
+
${PENDING_CHANGES_HINT}` : `Warning: ${notice.message}`
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function connectSession(url, run = "session") {
|
|
110
|
+
return connect(url, run);
|
|
111
|
+
}
|
|
112
|
+
function connect(url, run) {
|
|
113
|
+
const query = run === "walkthrough" ? "?run=walkthrough" : "";
|
|
114
|
+
return {
|
|
115
|
+
url,
|
|
116
|
+
ephemeral: false,
|
|
117
|
+
async send(command) {
|
|
118
|
+
const response = await reach(url, `${url}/api/command${query}`, {
|
|
119
|
+
method: "POST",
|
|
120
|
+
headers: { "Content-Type": "application/json" },
|
|
121
|
+
body: JSON.stringify(command)
|
|
122
|
+
});
|
|
123
|
+
if (!response.ok) {
|
|
124
|
+
const body = await response.json().catch(() => ({}));
|
|
125
|
+
const message = body.error ?? `The session refused the command (HTTP ${response.status})`;
|
|
126
|
+
throw response.status === 400 ? new CliError("DEV_SERVER_OUTDATED", message, { hint: OUTDATED_HINT }) : new CliError("SESSION_ERROR", message);
|
|
127
|
+
}
|
|
128
|
+
return await response.json();
|
|
129
|
+
},
|
|
130
|
+
async state() {
|
|
131
|
+
const response = await reach(url, `${url}/api/state${query}`);
|
|
132
|
+
if (!response.ok) {
|
|
133
|
+
throw new CliError(
|
|
134
|
+
"DEV_SERVER_OUTDATED",
|
|
135
|
+
`Could not read the session state (HTTP ${response.status})`,
|
|
136
|
+
{ hint: OUTDATED_HINT }
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
return await response.json();
|
|
140
|
+
},
|
|
141
|
+
async close() {
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
var OUTDATED_HINT = "Restart the dev server: `sdk dev stop`, then run the command again.";
|
|
146
|
+
async function reach(url, input, init) {
|
|
147
|
+
try {
|
|
148
|
+
return await fetch(input, init);
|
|
149
|
+
} catch (error) {
|
|
150
|
+
throw new CliError(
|
|
151
|
+
"DEV_SERVER_UNREACHABLE",
|
|
152
|
+
`The dev server at ${url} did not answer: ${error instanceof Error ? error.message : String(error)}`,
|
|
153
|
+
{
|
|
154
|
+
hint: "If it has stopped, run `sdk dev stop` (or remove .seriousgaming-sdk/session.json), then try again."
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
async function startLocalSession(packagePath, options) {
|
|
160
|
+
const environment = loadEnvironmentConfig(packagePath);
|
|
161
|
+
const session = new Session({
|
|
162
|
+
packagePath,
|
|
163
|
+
...options.runKind === void 0 ? {} : { runKind: options.runKind },
|
|
164
|
+
...options.teams === void 0 ? {} : { teams: options.teams },
|
|
165
|
+
...options.participants === void 0 ? {} : { participants: options.participants },
|
|
166
|
+
...options.scenarioId === void 0 ? {} : { scenarioId: options.scenarioId },
|
|
167
|
+
...options.locale === void 0 ? {} : { locale: options.locale },
|
|
168
|
+
...environment.seriousGamingApiKey === void 0 ? {} : { seriousGamingApiKey: environment.seriousGamingApiKey },
|
|
169
|
+
...environment.seriousGamingApiHost === void 0 ? {} : { seriousGamingApiHost: environment.seriousGamingApiHost },
|
|
170
|
+
...environment.elevenLabsApiKey === void 0 ? {} : { elevenLabsApiKey: environment.elevenLabsApiKey }
|
|
171
|
+
});
|
|
172
|
+
try {
|
|
173
|
+
await session.start();
|
|
174
|
+
} catch (error) {
|
|
175
|
+
if (error instanceof CliError) throw error;
|
|
176
|
+
throw new CliError(
|
|
177
|
+
"SESSION_ERROR",
|
|
178
|
+
`The session could not start: ${error instanceof Error ? error.message : String(error)}`,
|
|
179
|
+
{ cause: error }
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
if (session.inSetup) await session.submit({ type: "play" });
|
|
183
|
+
return {
|
|
184
|
+
url: null,
|
|
185
|
+
ephemeral: true,
|
|
186
|
+
async send(command) {
|
|
187
|
+
return isQuery(command) ? session.query(command) : session.submit(command);
|
|
188
|
+
},
|
|
189
|
+
async state() {
|
|
190
|
+
return session.project();
|
|
191
|
+
},
|
|
192
|
+
async close() {
|
|
193
|
+
await session.stop();
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
var START_TIMEOUT_MS = 12e4;
|
|
198
|
+
async function startBackgroundServer(packagePath, options) {
|
|
199
|
+
const entry = cliEntryPoint();
|
|
200
|
+
const args = [
|
|
201
|
+
...entry.argv,
|
|
202
|
+
"dev",
|
|
203
|
+
"--no-open",
|
|
204
|
+
// So a failed start says why with a code, which this command reports
|
|
205
|
+
// as its own (an invalid package fails here with exit 3, not 5).
|
|
206
|
+
"--json",
|
|
207
|
+
// Recorded in its lock, so a later command from other tools may
|
|
208
|
+
// replace it rather than refusing.
|
|
209
|
+
"--background",
|
|
210
|
+
"-w",
|
|
211
|
+
packagePath,
|
|
212
|
+
...options.teams === void 0 ? [] : ["--teams", String(options.teams)],
|
|
213
|
+
...options.participants === void 0 ? [] : ["--participants", [options.participants].flat().join(",")],
|
|
214
|
+
...typeof options.scenarioId === "string" ? ["--scenario", options.scenarioId] : []
|
|
215
|
+
];
|
|
216
|
+
const environment = { ...process.env };
|
|
217
|
+
delete environment[JSON_ENV_VAR];
|
|
218
|
+
const child = spawn(entry.command, args, {
|
|
219
|
+
detached: true,
|
|
220
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
221
|
+
env: environment
|
|
222
|
+
});
|
|
223
|
+
let output = "";
|
|
224
|
+
let envelope = "";
|
|
225
|
+
child.stdout?.on("data", (chunk) => {
|
|
226
|
+
envelope += chunk.toString();
|
|
227
|
+
});
|
|
228
|
+
child.stderr?.on("data", (chunk) => {
|
|
229
|
+
output += chunk.toString();
|
|
230
|
+
});
|
|
231
|
+
let exited = null;
|
|
232
|
+
child.once("close", (code) => {
|
|
233
|
+
exited = { code };
|
|
234
|
+
});
|
|
235
|
+
const deadline = Date.now() + START_TIMEOUT_MS;
|
|
236
|
+
while (Date.now() < deadline) {
|
|
237
|
+
const lock = await readLockFile(packagePath, { unresponsive: "accept" });
|
|
238
|
+
if (lock) {
|
|
239
|
+
const url = `http://localhost:${lock.port}`;
|
|
240
|
+
if (await reachable(url)) {
|
|
241
|
+
child.stdout?.destroy();
|
|
242
|
+
child.stderr?.destroy();
|
|
243
|
+
child.unref();
|
|
244
|
+
announce(url);
|
|
245
|
+
return url;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (exited) throw startFailure(envelope, output);
|
|
249
|
+
await pause(100);
|
|
250
|
+
}
|
|
251
|
+
child.kill();
|
|
252
|
+
throw new CliError(
|
|
253
|
+
"DEV_SERVER_START_FAILED",
|
|
254
|
+
"Timed out starting a dev server for this package.\nStart one yourself with `sdk dev`, or pass --no-server to run without one."
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
function startFailure(envelope, output) {
|
|
258
|
+
try {
|
|
259
|
+
const parsed = JSON.parse(envelope);
|
|
260
|
+
if (parsed.ok === false && isErrorCode(parsed.error.code)) {
|
|
261
|
+
return new CliError(
|
|
262
|
+
parsed.error.code,
|
|
263
|
+
`The dev server could not start: ${parsed.error.message}`,
|
|
264
|
+
{
|
|
265
|
+
...parsed.error.hint === void 0 ? {} : { hint: parsed.error.hint },
|
|
266
|
+
...parsed.error.details === void 0 ? {} : { details: parsed.error.details },
|
|
267
|
+
diagnostics: parsed.diagnostics
|
|
268
|
+
}
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
} catch {
|
|
272
|
+
}
|
|
273
|
+
return new CliError(
|
|
274
|
+
"DEV_SERVER_START_FAILED",
|
|
275
|
+
`The dev server could not start.
|
|
276
|
+
|
|
277
|
+
${(output + envelope).trim() || "(it exited silently)"}`
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
function announce(url) {
|
|
281
|
+
console.error(
|
|
282
|
+
`No dev server was running, so this command started one at ${url}.
|
|
283
|
+
It stays up for the next command: stop it with \`sdk dev stop\`, or pass --no-server to run without one.
|
|
284
|
+
`
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
function cliEntryPoint() {
|
|
288
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
289
|
+
const fromSource = here.includes(join("cli", "client"));
|
|
290
|
+
const loader = process.argv[1];
|
|
291
|
+
return fromSource ? { command: process.execPath, argv: [loader, resolve(here, "..", "cli.ts"), "--"] } : { command: process.execPath, argv: [loader] };
|
|
292
|
+
}
|
|
293
|
+
async function reachable(url) {
|
|
294
|
+
try {
|
|
295
|
+
return (await fetch(`${url}/api/state`)).ok;
|
|
296
|
+
} catch {
|
|
297
|
+
return false;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
function pause(ms) {
|
|
301
|
+
return new Promise((resolve_) => setTimeout(resolve_, ms));
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export {
|
|
305
|
+
resolveSession,
|
|
306
|
+
connectSession
|
|
307
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
deleteCapabilityFiles,
|
|
4
|
+
findCapabilityReferences
|
|
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/capability/delete.ts
|
|
36
|
+
async function deleteCapability(identifier, options) {
|
|
37
|
+
logger.info("\nDeleting capability...\n");
|
|
38
|
+
loadPackageContext(options.workingDir);
|
|
39
|
+
const references = findCapabilityReferences({
|
|
40
|
+
packagePath: options.workingDir,
|
|
41
|
+
identifier
|
|
42
|
+
});
|
|
43
|
+
logger.info(`Capability: ${identifier}`);
|
|
44
|
+
if (references.length > 0) {
|
|
45
|
+
logger.info("\nThis capability is referenced by:");
|
|
46
|
+
for (const ref of references) {
|
|
47
|
+
logger.info(` - ${ref}`);
|
|
48
|
+
}
|
|
49
|
+
logger.info("\nThese references will be removed.");
|
|
50
|
+
}
|
|
51
|
+
const confirmed = await confirmAction(
|
|
52
|
+
{ message: "Are you sure you want to delete this capability?" },
|
|
53
|
+
options.yes
|
|
54
|
+
);
|
|
55
|
+
if (!confirmed) {
|
|
56
|
+
logger.info("\nDeletion cancelled.\n");
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
logger.info("");
|
|
60
|
+
const result = deleteCapabilityFiles({
|
|
61
|
+
packagePath: options.workingDir,
|
|
62
|
+
identifier
|
|
63
|
+
});
|
|
64
|
+
if (!result.success) {
|
|
65
|
+
throw operationError(result, "Failed to delete capability files");
|
|
66
|
+
}
|
|
67
|
+
recordOperationResult(result);
|
|
68
|
+
for (const file of result.filesDeleted || []) {
|
|
69
|
+
logger.info(` \u2713 Deleted: ${file}`);
|
|
70
|
+
}
|
|
71
|
+
for (const ref of result.referencesRemoved || []) {
|
|
72
|
+
logger.info(` \u2713 Removed reference from: ${ref}`);
|
|
73
|
+
}
|
|
74
|
+
logger.info(" \u2713 Updated seriousgaming.sdk.json");
|
|
75
|
+
await regenerateTypes(options.workingDir);
|
|
76
|
+
logger.success("Capability deleted successfully!");
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
deleteCapability
|
|
80
|
+
};
|