@seriousgaming/sdk-tools 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundling/ui-bundler.d.ts +12 -0
- package/dist/cli-25RWY5BQ.js +41 -0
- package/dist/cli-272KBNJH.js +97 -0
- package/dist/cli-2BH7FX27.js +52 -0
- package/dist/cli-2GOFEW26.js +81 -0
- package/dist/cli-3E3MD5U4.js +21 -0
- package/dist/cli-3HE4AVZG.js +115 -0
- package/dist/cli-4AKVLEC4.js +1387 -0
- package/dist/cli-4BV45LBH.js +126 -0
- package/dist/cli-4LKXZQ2B.js +48 -0
- package/dist/cli-4UWFQNGF.js +54 -0
- package/dist/cli-4YB3ROVR.js +78 -0
- package/dist/cli-57RXC3HQ.js +36 -0
- package/dist/cli-5JEGTVTG.js +96 -0
- package/dist/cli-6AMT3BUO.js +97 -0
- package/dist/cli-6RRVEGFB.js +80 -0
- package/dist/cli-6WXLXJVX.js +36 -0
- package/dist/cli-7OGYADZ3.js +97 -0
- package/dist/cli-AK7OIPWY.js +229 -0
- package/dist/cli-B4TN6PJP.js +124 -0
- package/dist/cli-B6YHEKIJ.js +248 -0
- package/dist/cli-BPYMTOUL.js +89 -0
- package/dist/cli-BWX5E7TQ.js +23 -0
- package/dist/cli-BYJWFFCF.js +37 -0
- package/dist/cli-C3NVCKO6.js +43 -0
- package/dist/cli-C47GJATR.js +42 -0
- package/dist/cli-C5QOJJWX.js +46 -0
- package/dist/cli-C6TH5S7K.js +6417 -0
- package/dist/cli-DL2CVMRF.js +89 -0
- package/dist/cli-DMW2OQIJ.js +76 -0
- package/dist/cli-DZW3XD5F.js +143 -0
- package/dist/cli-E2NLWIFE.js +1331 -0
- package/dist/cli-E33CJRRQ.js +36 -0
- package/dist/cli-E6DJIMYD.js +142 -0
- package/dist/cli-EEFJKIGL.js +151 -0
- package/dist/cli-EVFS55WN.js +185 -0
- package/dist/cli-F2D4GGUA.js +549 -0
- package/dist/cli-FBTRTIZJ.js +226 -0
- package/dist/cli-FWFRKQNE.js +11 -0
- package/dist/cli-FYINNRML.js +760 -0
- package/dist/cli-G522CPRL.js +88 -0
- package/dist/cli-G6KELFSX.js +2847 -0
- package/dist/cli-G6UE5NL4.js +90 -0
- package/dist/cli-GBFM76BF.js +16 -0
- package/dist/cli-GDQ6ILJY.js +101 -0
- package/dist/cli-GFBGYFYD.js +50 -0
- package/dist/cli-GGPDQNM3.js +35 -0
- package/dist/cli-GTSGLN3Z.js +307 -0
- package/dist/cli-GUXKQMJ7.js +13641 -0
- package/dist/cli-GXD36NF2.js +60 -0
- package/dist/cli-HCRTYQQS.js +16 -0
- package/dist/cli-HYY64SUD.js +185 -0
- package/dist/cli-I355WTAF.js +463 -0
- package/dist/cli-IDKYF5XB.js +59 -0
- package/dist/cli-ILKCQNM6.js +8 -0
- package/dist/cli-IRZ5KB7D.js +36 -0
- package/dist/cli-IUS2YCD3.js +31 -0
- package/dist/cli-J4DKUUTK.js +138 -0
- package/dist/cli-JFU22EJ2.js +187 -0
- package/dist/cli-JMZLT65J.js +226 -0
- package/dist/cli-JZM7XTNV.js +89 -0
- package/dist/cli-K2B6WHKA.js +81 -0
- package/dist/cli-KL3756X6.js +126 -0
- package/dist/cli-KNOOKGYW.js +88 -0
- package/dist/cli-LFGRFIEO.js +226 -0
- package/dist/cli-LFM7GJHI.js +0 -0
- package/dist/cli-LMDJCHHD.js +304 -0
- package/dist/cli-LXYPE3L5.js +99 -0
- package/dist/cli-M6BCQRID.js +153 -0
- package/dist/cli-MBNMPVDC.js +367 -0
- package/dist/cli-MJUYJIEP.js +13 -0
- package/dist/cli-MMN4BPO4.js +145 -0
- package/dist/cli-MYJGMA6U.js +40 -0
- package/dist/cli-N6H6T2E2.js +616 -0
- package/dist/cli-O5KP4OVN.js +61 -0
- package/dist/cli-O6PWMJTZ.js +25 -0
- package/dist/cli-ORIG557O.js +141 -0
- package/dist/cli-PFFCNGHI.js +243 -0
- package/dist/cli-PNLYX6R6.js +131 -0
- package/dist/cli-PQBXVLEU.js +649 -0
- package/dist/cli-PTT5RGKO.js +62 -0
- package/dist/cli-Q2XJF5AS.js +127 -0
- package/dist/cli-QEVDDBNO.js +60 -0
- package/dist/cli-QEVE5HUM.js +167 -0
- package/dist/cli-QUIJCBYB.js +391 -0
- package/dist/cli-QUNIRH7A.js +57 -0
- package/dist/cli-QVASWX2A.js +187 -0
- package/dist/cli-QWQMPCL6.js +253 -0
- package/dist/cli-R4PCG5YX.js +131 -0
- package/dist/cli-RA673NGF.js +53 -0
- package/dist/cli-RN6IWTL2.js +36 -0
- package/dist/cli-ROT3DRKU.js +145 -0
- package/dist/cli-RZITKPJX.js +367 -0
- package/dist/cli-S5IVGDDD.js +32 -0
- package/dist/cli-S5QDONIQ.js +218 -0
- package/dist/cli-SIPDUBFL.js +36 -0
- package/dist/cli-SMFSZF2G.js +4009 -0
- package/dist/cli-SRHBXZCN.js +159 -0
- package/dist/cli-TCY5LJ7E.js +88 -0
- package/dist/cli-TDSQSCX4.js +131 -0
- package/dist/cli-TIDQ4WUE.js +257 -0
- package/dist/cli-TLLA6KAP.js +79 -0
- package/dist/cli-TPU4TUR6.js +132 -0
- package/dist/cli-U2UE7I7J.js +30 -0
- package/dist/cli-UELGBQG7.js +101 -0
- package/dist/cli-UHSZBKYO.js +97 -0
- package/dist/cli-UJ4UCL2Z.js +38 -0
- package/dist/cli-UKQYZYFK.js +31 -0
- package/dist/cli-UMFFURZ7.js +81 -0
- package/dist/cli-UNAJ2OTE.js +15 -0
- package/dist/cli-UNJ5X6BU.js +89 -0
- package/dist/cli-UTJU4IYG.js +117 -0
- package/dist/cli-V4GHRWOV.js +1837 -0
- package/dist/cli-VCI3CG36.js +73 -0
- package/dist/cli-VCKOC2EV.js +256 -0
- package/dist/cli-VL2P354N.js +46 -0
- package/dist/cli-WAE26SVW.js +72 -0
- package/dist/cli-WOGIAU2E.js +100 -0
- package/dist/cli-WU43JT4T.js +52 -0
- package/dist/cli-XCO2VQOH.js +122 -0
- package/dist/cli-XSVGKI3R.js +39 -0
- package/dist/cli-YOTGR3NB.js +82 -0
- package/dist/cli-YVVXUD2G.js +197 -0
- package/dist/cli-ZISJ36MM.js +89 -0
- package/dist/cli-ZTWOE3ZT.js +65 -0
- package/dist/cli-ZVSFYDPQ.js +205 -0
- package/dist/cli-ZWPYIXNI.js +68 -0
- package/dist/cli.js +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/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 +19 -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/guides/designing-a-game.md +29 -4
- package/dist/docs/guides/starter-game.md +2 -2
- package/dist/docs/guides/testing.md +33 -18
- package/dist/docs/page-index.md +8 -7
- package/dist/docs/recipes/e2e-testing.md +19 -20
- package/dist/playwright.js +32232 -0
- package/dist/templates/package/claude/rules/workflow-test-engine-or-ui.md +1 -1
- package/dist/templates/package/global-setup.ts.template +7 -18
- package/dist/templates/package/playwright.config.ts.liquid +8 -11
- package/dist/templates/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,122 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
assertEveryPropertyHasDefault
|
|
4
|
+
} from "./cli-O6PWMJTZ.js";
|
|
5
|
+
import {
|
|
6
|
+
promptForSchemaProperties
|
|
7
|
+
} from "./cli-RZITKPJX.js";
|
|
8
|
+
import {
|
|
9
|
+
readAuthoredBundle
|
|
10
|
+
} from "./cli-YVVXUD2G.js";
|
|
11
|
+
import {
|
|
12
|
+
resolveInputSource
|
|
13
|
+
} from "./cli-4UWFQNGF.js";
|
|
14
|
+
import {
|
|
15
|
+
createSettingsFiles
|
|
16
|
+
} from "./cli-FYINNRML.js";
|
|
17
|
+
import "./cli-IUS2YCD3.js";
|
|
18
|
+
import "./cli-QUNIRH7A.js";
|
|
19
|
+
import "./cli-BYJWFFCF.js";
|
|
20
|
+
import {
|
|
21
|
+
loadPackageContext
|
|
22
|
+
} from "./cli-XSVGKI3R.js";
|
|
23
|
+
import "./cli-MBNMPVDC.js";
|
|
24
|
+
import "./cli-GFBGYFYD.js";
|
|
25
|
+
import {
|
|
26
|
+
BUILD_COMMAND,
|
|
27
|
+
generateTypes,
|
|
28
|
+
operationError,
|
|
29
|
+
printOperationResult
|
|
30
|
+
} from "./cli-UELGBQG7.js";
|
|
31
|
+
import {
|
|
32
|
+
input
|
|
33
|
+
} from "./cli-ZTWOE3ZT.js";
|
|
34
|
+
import "./cli-4BV45LBH.js";
|
|
35
|
+
import "./cli-4AKVLEC4.js";
|
|
36
|
+
import "./cli-VCKOC2EV.js";
|
|
37
|
+
import "./cli-E2NLWIFE.js";
|
|
38
|
+
import "./cli-25RWY5BQ.js";
|
|
39
|
+
import "./cli-QWQMPCL6.js";
|
|
40
|
+
import {
|
|
41
|
+
GAME_SETTINGS,
|
|
42
|
+
validateSDKSettings
|
|
43
|
+
} from "./cli-SMFSZF2G.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 settingsSchema;
|
|
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
|
+
settingsSchema = settingsInput.definition.settingsSchema;
|
|
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
|
+
settingsSchema = { type: "object", properties, additionalProperties: false };
|
|
93
|
+
}
|
|
94
|
+
if (identifier === GAME_SETTINGS) {
|
|
95
|
+
throw new CliError(
|
|
96
|
+
"SETTINGS_RESERVED",
|
|
97
|
+
`"${GAME_SETTINGS}" is reserved for the built-in game settings, whose schema is the SDK's.`,
|
|
98
|
+
{
|
|
99
|
+
hint: "Set the game's own values in seriousgaming.sdk.json (`maxTicks`, `teams`, `waitingRoom`), and give these settings another name."
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
assertEveryPropertyHasDefault(settingsSchema);
|
|
104
|
+
logger.info("Creating settings files...\n");
|
|
105
|
+
const result = await createSettingsFiles({
|
|
106
|
+
packagePath: options.workingDir,
|
|
107
|
+
identifier,
|
|
108
|
+
settingsSchema
|
|
109
|
+
});
|
|
110
|
+
if (!result.success) {
|
|
111
|
+
throw operationError(result, "Failed to create settings files");
|
|
112
|
+
}
|
|
113
|
+
logger.success("Settings created successfully!");
|
|
114
|
+
printOperationResult(result);
|
|
115
|
+
await generateTypes(options.workingDir);
|
|
116
|
+
logger.info("Next steps:");
|
|
117
|
+
logger.info(` 1. List "${identifier}" in the settings of each resource that reads it`);
|
|
118
|
+
logger.info(` 2. Run "${BUILD_COMMAND}" to build your package`);
|
|
119
|
+
}
|
|
120
|
+
export {
|
|
121
|
+
createSettings
|
|
122
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
CliError
|
|
4
|
+
} from "./cli-N6H6T2E2.js";
|
|
5
|
+
|
|
6
|
+
// cli/utils/package-context.ts
|
|
7
|
+
import { existsSync, readFileSync } from "fs";
|
|
8
|
+
import { join } from "path";
|
|
9
|
+
function loadPackageContext(workingDir, options = {}) {
|
|
10
|
+
const configPath = join(workingDir, "seriousgaming.sdk.json");
|
|
11
|
+
if (!existsSync(configPath)) {
|
|
12
|
+
let message = "seriousgaming.sdk.json not found.\nThis command must be run in a Serious Gaming package directory.";
|
|
13
|
+
if (options.suggestNewPackage) {
|
|
14
|
+
message += '\nUse "new package" to create a new package first.';
|
|
15
|
+
}
|
|
16
|
+
throw new CliError("MANIFEST_NOT_FOUND", message);
|
|
17
|
+
}
|
|
18
|
+
let config;
|
|
19
|
+
try {
|
|
20
|
+
config = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
21
|
+
} catch (error) {
|
|
22
|
+
throw new CliError(
|
|
23
|
+
"MANIFEST_INVALID",
|
|
24
|
+
"Could not read seriousgaming.sdk.json\n" + (error instanceof Error ? error.message : "Unknown error")
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
const packageIdentifier = config?.identifier;
|
|
28
|
+
if (typeof packageIdentifier !== "string" || !packageIdentifier) {
|
|
29
|
+
throw new CliError(
|
|
30
|
+
"MANIFEST_INVALID",
|
|
31
|
+
"Could not read package identifier from seriousgaming.sdk.json"
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
return { configPath, packageIdentifier };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
loadPackageContext
|
|
39
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
CliError
|
|
4
|
+
} from "./cli-N6H6T2E2.js";
|
|
5
|
+
|
|
6
|
+
// cli/dev/public-origins.ts
|
|
7
|
+
var PUBLIC_URL_ENV_VAR = "SERIOUSGAMING_DEV_PUBLIC_URL";
|
|
8
|
+
var PUBLIC_ASSET_URL_ENV_VAR = "SERIOUSGAMING_DEV_PUBLIC_ASSET_URL";
|
|
9
|
+
var PUBLIC_HMR_URL_ENV_VAR = "SERIOUSGAMING_DEV_PUBLIC_HMR_URL";
|
|
10
|
+
function parsePublicOrigin(value, flag, kind) {
|
|
11
|
+
const allowed = kind === "http" ? ["http:", "https:"] : ["http:", "https:", "ws:", "wss:"];
|
|
12
|
+
let url;
|
|
13
|
+
try {
|
|
14
|
+
url = new URL(value.trim());
|
|
15
|
+
} catch {
|
|
16
|
+
throw badOrigin(value, flag, kind);
|
|
17
|
+
}
|
|
18
|
+
if (!allowed.includes(url.protocol) || url.pathname !== "/" && url.pathname !== "") {
|
|
19
|
+
throw badOrigin(value, flag, kind);
|
|
20
|
+
}
|
|
21
|
+
if (url.search || url.hash || url.username || url.password) throw badOrigin(value, flag, kind);
|
|
22
|
+
if (kind === "ws") {
|
|
23
|
+
const secure = url.protocol === "https:" || url.protocol === "wss:";
|
|
24
|
+
return `${secure ? "wss" : "ws"}://${url.host}`;
|
|
25
|
+
}
|
|
26
|
+
return url.origin;
|
|
27
|
+
}
|
|
28
|
+
function badOrigin(value, flag, kind) {
|
|
29
|
+
const example = kind === "http" ? "https://game.example.com" : "wss://hmr.example.com";
|
|
30
|
+
return new CliError(
|
|
31
|
+
"USAGE_BAD_FLAG",
|
|
32
|
+
`"${value}" is not an origin ${flag} can take. Pass a scheme, a host and, where it is not the default, a port, with no path: ${example}.`
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
function resolvePublicOrigins(flags, env = process.env) {
|
|
36
|
+
const pick = (flag, name) => flag || env[name] || void 0;
|
|
37
|
+
const publicUrl = pick(flags.publicUrl, PUBLIC_URL_ENV_VAR);
|
|
38
|
+
const publicAssetUrl = pick(flags.publicAssetUrl, PUBLIC_ASSET_URL_ENV_VAR);
|
|
39
|
+
const publicHmrUrl = pick(flags.publicHmrUrl, PUBLIC_HMR_URL_ENV_VAR);
|
|
40
|
+
return {
|
|
41
|
+
...publicUrl ? { publicUrl: parsePublicOrigin(publicUrl, "--public-url", "http") } : {},
|
|
42
|
+
...publicAssetUrl ? {
|
|
43
|
+
publicAssetUrl: parsePublicOrigin(publicAssetUrl, "--public-asset-url", "http")
|
|
44
|
+
} : {},
|
|
45
|
+
...publicHmrUrl ? { publicHmrUrl: parsePublicOrigin(publicHmrUrl, "--public-hmr-url", "ws") } : {}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function publicAssetOrigin(origins, assetPort) {
|
|
49
|
+
if (origins.publicAssetUrl) return origins.publicAssetUrl;
|
|
50
|
+
if (!origins.publicUrl) return null;
|
|
51
|
+
const url = new URL(origins.publicUrl);
|
|
52
|
+
return `${url.protocol}//${url.hostname}:${assetPort}`;
|
|
53
|
+
}
|
|
54
|
+
function publicHmrOrigin(origins, assetPort, vitePort) {
|
|
55
|
+
if (origins.publicHmrUrl) return origins.publicHmrUrl;
|
|
56
|
+
const asset = publicAssetOrigin(origins, assetPort);
|
|
57
|
+
if (!asset) return null;
|
|
58
|
+
const url = new URL(asset);
|
|
59
|
+
return `${url.protocol === "https:" ? "wss" : "ws"}://${url.hostname}:${vitePort}`;
|
|
60
|
+
}
|
|
61
|
+
function hmrClientTarget(origin) {
|
|
62
|
+
const url = new URL(origin);
|
|
63
|
+
const protocol = url.protocol === "wss:" ? "wss" : "ws";
|
|
64
|
+
const clientPort = url.port ? Number(url.port) : protocol === "wss" ? 443 : 80;
|
|
65
|
+
return { protocol, host: url.hostname, clientPort };
|
|
66
|
+
}
|
|
67
|
+
function publicHostnames(origins) {
|
|
68
|
+
return [
|
|
69
|
+
...new Set(origins.filter((o) => Boolean(o)).map((o) => new URL(o).hostname))
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export {
|
|
74
|
+
PUBLIC_URL_ENV_VAR,
|
|
75
|
+
PUBLIC_ASSET_URL_ENV_VAR,
|
|
76
|
+
PUBLIC_HMR_URL_ENV_VAR,
|
|
77
|
+
resolvePublicOrigins,
|
|
78
|
+
publicAssetOrigin,
|
|
79
|
+
publicHmrOrigin,
|
|
80
|
+
hmrClientTarget,
|
|
81
|
+
publicHostnames
|
|
82
|
+
};
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
REMOVED_CONFIGURATION_SCHEMA,
|
|
4
|
+
REMOVED_CONFIGURATION_SURFACES,
|
|
5
|
+
REMOVED_DEMO,
|
|
6
|
+
REMOVED_GAME_CONFIGURATION,
|
|
7
|
+
REMOVED_UI_USES,
|
|
8
|
+
RENAMED_SCENARIO_CONFIGURATION,
|
|
9
|
+
findResourceMeta,
|
|
10
|
+
isNamelessInterface
|
|
11
|
+
} from "./cli-SMFSZF2G.js";
|
|
12
|
+
import {
|
|
13
|
+
resourceExample
|
|
14
|
+
} from "./cli-F2D4GGUA.js";
|
|
15
|
+
import {
|
|
16
|
+
CliError
|
|
17
|
+
} from "./cli-N6H6T2E2.js";
|
|
18
|
+
|
|
19
|
+
// cli/utils/validators.ts
|
|
20
|
+
var PACKAGE_IDENTIFIER_PATTERN = /^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$/;
|
|
21
|
+
var RESOURCE_IDENTIFIER_PATTERN = /^[a-z][a-z0-9_]*$/;
|
|
22
|
+
function getPackageIdentifierError(identifier) {
|
|
23
|
+
if (!identifier || !identifier.trim()) {
|
|
24
|
+
return "Identifier is required";
|
|
25
|
+
}
|
|
26
|
+
const trimmed = identifier.trim();
|
|
27
|
+
if (!trimmed.includes(".")) {
|
|
28
|
+
return "Identifier must contain at least one dot (e.g., com.example.name)";
|
|
29
|
+
}
|
|
30
|
+
if (trimmed.startsWith(".") || trimmed.endsWith(".")) {
|
|
31
|
+
return "Identifier cannot start or end with a dot";
|
|
32
|
+
}
|
|
33
|
+
if (/^\d/.test(trimmed)) {
|
|
34
|
+
return "Identifier must start with a lowercase letter";
|
|
35
|
+
}
|
|
36
|
+
if (/[A-Z]/.test(trimmed)) {
|
|
37
|
+
return "Identifier must be lowercase only";
|
|
38
|
+
}
|
|
39
|
+
if (!PACKAGE_IDENTIFIER_PATTERN.test(trimmed)) {
|
|
40
|
+
return "Identifier must be in namespace format: lowercase segments separated by dots";
|
|
41
|
+
}
|
|
42
|
+
return "";
|
|
43
|
+
}
|
|
44
|
+
function getResourceIdentifierError(identifier) {
|
|
45
|
+
if (!identifier || !identifier.trim()) {
|
|
46
|
+
return "Identifier is required";
|
|
47
|
+
}
|
|
48
|
+
const trimmed = identifier.trim();
|
|
49
|
+
if (trimmed.includes(".")) {
|
|
50
|
+
return "A resource is named by its directory, so its identifier is a single name with no dots";
|
|
51
|
+
}
|
|
52
|
+
if (!RESOURCE_IDENTIFIER_PATTERN.test(trimmed)) {
|
|
53
|
+
return "Identifier must start with a lowercase letter and contain only lowercase letters, numbers, and underscores";
|
|
54
|
+
}
|
|
55
|
+
return "";
|
|
56
|
+
}
|
|
57
|
+
var VERSION_PATTERN = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
58
|
+
function getVersionError(version) {
|
|
59
|
+
if (!version || !version.trim()) {
|
|
60
|
+
return "Version is required";
|
|
61
|
+
}
|
|
62
|
+
if (!VERSION_PATTERN.test(version.trim())) {
|
|
63
|
+
return "Version must be in semantic version format (e.g., 1.0.0)";
|
|
64
|
+
}
|
|
65
|
+
return "";
|
|
66
|
+
}
|
|
67
|
+
function assertShortIdentifier(identifier) {
|
|
68
|
+
if (typeof identifier !== "string" || !identifier.includes(".")) return;
|
|
69
|
+
throw new CliError(
|
|
70
|
+
"USAGE_BAD_ARGUMENT",
|
|
71
|
+
`Identifier "${identifier}" is in the old long form. A resource is named by its directory inside its package, so use "${identifier.split(".").pop()}".`
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// cli/commands/resources/shared/authored-input.ts
|
|
76
|
+
function withExample(message, type, command) {
|
|
77
|
+
return new CliError(
|
|
78
|
+
"INPUT_INVALID",
|
|
79
|
+
`${message}
|
|
80
|
+
|
|
81
|
+
Expected format:
|
|
82
|
+
${resourceExample(type, command)}`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
function parseAuthoredInput(json, type, command) {
|
|
86
|
+
let input;
|
|
87
|
+
try {
|
|
88
|
+
input = JSON.parse(json);
|
|
89
|
+
} catch (error) {
|
|
90
|
+
throw withExample(
|
|
91
|
+
"Failed to parse JSON definition\n" + (error instanceof Error ? error.message : "Unknown error"),
|
|
92
|
+
type,
|
|
93
|
+
command
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
if (input === null || typeof input !== "object" || Array.isArray(input)) {
|
|
97
|
+
throw withExample("A definition is a JSON object.", type, command);
|
|
98
|
+
}
|
|
99
|
+
const bundle = input;
|
|
100
|
+
const meta = findResourceMeta(type);
|
|
101
|
+
if (meta) assertAuthorable(bundle, meta, type, command);
|
|
102
|
+
else assertNoRemovedManifestFields(bundle, (message) => withExample(message, type, command));
|
|
103
|
+
return bundle;
|
|
104
|
+
}
|
|
105
|
+
function assertNoRemovedManifestFields(manifest, toError = (message) => new CliError("INPUT_INVALID", message)) {
|
|
106
|
+
if (manifest.configuration !== void 0) throw toError(REMOVED_GAME_CONFIGURATION);
|
|
107
|
+
if (manifest.demo !== void 0) throw toError(REMOVED_DEMO);
|
|
108
|
+
if (manifest.configurationSurfaces !== void 0) {
|
|
109
|
+
throw toError(REMOVED_CONFIGURATION_SURFACES);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function readAuthoredBundle(request) {
|
|
113
|
+
const bundle = parseAuthoredInput(request.json, request.type, request.command);
|
|
114
|
+
const definition = bundle.definition ?? {};
|
|
115
|
+
const slot = findResourceMeta(request.type)?.slot;
|
|
116
|
+
const named = {
|
|
117
|
+
...bundle,
|
|
118
|
+
definition: {
|
|
119
|
+
...definition,
|
|
120
|
+
identifier: slot ?? definition.identifier ?? request.identifier
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const validation = request.validate(named);
|
|
124
|
+
if (!validation.valid) {
|
|
125
|
+
throw new CliError(
|
|
126
|
+
"INPUT_INVALID",
|
|
127
|
+
`Validation error:
|
|
128
|
+
${validation.errors}` + (request.validationHint ? `
|
|
129
|
+
${request.validationHint}` : "")
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
return named;
|
|
133
|
+
}
|
|
134
|
+
function assertAuthorable(bundle, meta, type, command) {
|
|
135
|
+
const definition = bundle.definition;
|
|
136
|
+
const fields = definition !== null && typeof definition === "object" && !Array.isArray(definition) ? definition : {};
|
|
137
|
+
const label = meta.label.toLowerCase();
|
|
138
|
+
const Article = /^[aeiou]/.test(label) ? "An" : "A";
|
|
139
|
+
if (meta.slot && fields.identifier !== void 0) {
|
|
140
|
+
throw withExample(
|
|
141
|
+
`A game holds one ${label}, so it takes no \`identifier\`: it lives in the "${meta.slot}" slot, and the slot is the name everything downstream reads. Delete the field.`,
|
|
142
|
+
type,
|
|
143
|
+
command
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
if (!meta.slot) assertShortIdentifier(fields.identifier);
|
|
147
|
+
if (fields.configurationSchema !== void 0) {
|
|
148
|
+
throw withExample(REMOVED_CONFIGURATION_SCHEMA, type, command);
|
|
149
|
+
}
|
|
150
|
+
if (meta.type === "scenario" && fields.configuration !== void 0) {
|
|
151
|
+
throw withExample(RENAMED_SCENARIO_CONFIGURATION, type, command);
|
|
152
|
+
}
|
|
153
|
+
if (meta.type === "scenario" && fields.demo !== void 0) {
|
|
154
|
+
throw withExample(REMOVED_DEMO, type, command);
|
|
155
|
+
}
|
|
156
|
+
if (meta.kind === "ui" && fields.uses !== void 0) {
|
|
157
|
+
throw withExample(REMOVED_UI_USES, type, command);
|
|
158
|
+
}
|
|
159
|
+
if (meta.type === "engine" && fields.aggregate !== void 0) {
|
|
160
|
+
throw withExample(
|
|
161
|
+
"An engine is aggregate because it exports `InitAggregate` and `RunAggregate`, and the build reads that from the code, so it takes no `aggregate`. Delete the field, and pass `--aggregate` to scaffold logic with the pair.",
|
|
162
|
+
type,
|
|
163
|
+
command
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
if (isNamelessInterface(meta) && fields.locales !== void 0) {
|
|
167
|
+
throw withExample(
|
|
168
|
+
`A game holds one ${label}, so nothing labels it and the name is never shown. Delete \`locales\`; the screen's own strings belong in its \`src/i18n.ts\`.`,
|
|
169
|
+
type,
|
|
170
|
+
command
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
const layout = meta.layout;
|
|
174
|
+
if (!layout) return;
|
|
175
|
+
const [key, expected] = "logic" in layout ? ["logic", layout.logic] : ["ui", layout.ui];
|
|
176
|
+
if (bundle[key] === void 0) return;
|
|
177
|
+
const directory = "directory" in expected ? expected.directory : null;
|
|
178
|
+
const authored = bundle[key];
|
|
179
|
+
if (authored.entrypoint === expected.entrypoint && (directory === null ? authored.directory === void 0 : authored.directory === directory)) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const where = directory === null ? expected.entrypoint : `${directory}/${expected.entrypoint}`;
|
|
183
|
+
throw withExample(
|
|
184
|
+
`${Article} ${label} keeps its ${key === "logic" ? "code" : "entrypoint"} at "${where}", and the CLI writes that block itself. A different \`${key}\` is read by nothing, so it must say what is actually there.`,
|
|
185
|
+
type,
|
|
186
|
+
command
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export {
|
|
191
|
+
getPackageIdentifierError,
|
|
192
|
+
getResourceIdentifierError,
|
|
193
|
+
getVersionError,
|
|
194
|
+
parseAuthoredInput,
|
|
195
|
+
assertNoRemovedManifestFields,
|
|
196
|
+
readAuthoredBundle
|
|
197
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
deleteTickControllerFiles,
|
|
4
|
+
findTickControllerReferences
|
|
5
|
+
} from "./cli-FYINNRML.js";
|
|
6
|
+
import "./cli-IUS2YCD3.js";
|
|
7
|
+
import "./cli-QUNIRH7A.js";
|
|
8
|
+
import "./cli-BYJWFFCF.js";
|
|
9
|
+
import {
|
|
10
|
+
loadPackageContext
|
|
11
|
+
} from "./cli-XSVGKI3R.js";
|
|
12
|
+
import "./cli-MBNMPVDC.js";
|
|
13
|
+
import "./cli-GFBGYFYD.js";
|
|
14
|
+
import {
|
|
15
|
+
operationError,
|
|
16
|
+
recordOperationResult
|
|
17
|
+
} from "./cli-UELGBQG7.js";
|
|
18
|
+
import {
|
|
19
|
+
confirmAction
|
|
20
|
+
} from "./cli-ZTWOE3ZT.js";
|
|
21
|
+
import {
|
|
22
|
+
generateCommand
|
|
23
|
+
} from "./cli-4BV45LBH.js";
|
|
24
|
+
import "./cli-4AKVLEC4.js";
|
|
25
|
+
import "./cli-VCKOC2EV.js";
|
|
26
|
+
import "./cli-E2NLWIFE.js";
|
|
27
|
+
import "./cli-25RWY5BQ.js";
|
|
28
|
+
import "./cli-QWQMPCL6.js";
|
|
29
|
+
import "./cli-SMFSZF2G.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/tick-controller/delete.ts
|
|
37
|
+
async function deleteTickController(options) {
|
|
38
|
+
logger.info("\nDeleting tick controller...\n");
|
|
39
|
+
const identifier = "tick_controller";
|
|
40
|
+
loadPackageContext(options.workingDir);
|
|
41
|
+
const references = findTickControllerReferences({
|
|
42
|
+
packagePath: options.workingDir,
|
|
43
|
+
identifier
|
|
44
|
+
});
|
|
45
|
+
logger.info(`Tick Controller: ${identifier}`);
|
|
46
|
+
if (references.length > 0) {
|
|
47
|
+
logger.info("\nThis tick controller is referenced in:");
|
|
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 tick controller?" },
|
|
55
|
+
options.yes
|
|
56
|
+
);
|
|
57
|
+
if (!confirmed) {
|
|
58
|
+
logger.info("\nDeletion cancelled.\n");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
logger.info("");
|
|
62
|
+
const result = deleteTickControllerFiles({
|
|
63
|
+
packagePath: options.workingDir,
|
|
64
|
+
identifier
|
|
65
|
+
});
|
|
66
|
+
if (!result.success) {
|
|
67
|
+
throw operationError(result, "Failed to delete tick controller 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("Tick controller deleted successfully!");
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
deleteTickController
|
|
89
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
CliError,
|
|
4
|
+
isJsonOutput
|
|
5
|
+
} from "./cli-N6H6T2E2.js";
|
|
6
|
+
|
|
7
|
+
// cli/utils/prompt.ts
|
|
8
|
+
var inquirer = () => import("@inquirer/prompts");
|
|
9
|
+
var override = null;
|
|
10
|
+
var assumeYes = false;
|
|
11
|
+
var usage;
|
|
12
|
+
function promptBlocker() {
|
|
13
|
+
if (override !== null) return override ? null : "prompts are disabled";
|
|
14
|
+
if (isJsonOutput()) return "JSON output is on";
|
|
15
|
+
if (process.env.CI) return "CI is set";
|
|
16
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) return "there is no terminal to ask on";
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
function setAssumeYes(value) {
|
|
20
|
+
assumeYes = value;
|
|
21
|
+
}
|
|
22
|
+
function setPromptUsage(value) {
|
|
23
|
+
usage = value;
|
|
24
|
+
}
|
|
25
|
+
function refusal(message) {
|
|
26
|
+
const blocker = promptBlocker();
|
|
27
|
+
if (blocker === null) return void 0;
|
|
28
|
+
return Promise.reject(promptRequired(message, blocker));
|
|
29
|
+
}
|
|
30
|
+
function promptRequired(message, blocker) {
|
|
31
|
+
return new CliError(
|
|
32
|
+
"PROMPT_REQUIRED",
|
|
33
|
+
`This command needs an answer to "${message.trim()}", and ${blocker}.`,
|
|
34
|
+
{
|
|
35
|
+
hint: "Pass the input instead: as an argument, with --file, or on stdin" + (usage ? `, e.g. ${usage}` : "") + "."
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
var input = ((config, context) => refusal(config.message) ?? inquirer().then((prompts) => prompts.input(config, context)));
|
|
40
|
+
var select = ((config, context) => refusal(config.message) ?? inquirer().then((prompts) => prompts.select(config, context)));
|
|
41
|
+
var checkbox = ((config, context) => refusal(config.message) ?? inquirer().then((prompts) => prompts.checkbox(config, context)));
|
|
42
|
+
var confirm = ((config, context) => refusal(config.message) ?? inquirer().then((prompts) => prompts.confirm(config, context)));
|
|
43
|
+
async function confirmAction(config, yes = false) {
|
|
44
|
+
if (yes || assumeYes) return true;
|
|
45
|
+
const blocker = promptBlocker();
|
|
46
|
+
if (blocker !== null) {
|
|
47
|
+
throw new CliError(
|
|
48
|
+
"PROMPT_REQUIRED",
|
|
49
|
+
`This command asks "${config.message.trim()}" before it continues, and ${blocker}.`,
|
|
50
|
+
{ hint: "Pass --yes to confirm." }
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
const prompts = await inquirer();
|
|
54
|
+
return prompts.confirm({ message: config.message, default: config.default ?? false });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export {
|
|
58
|
+
setAssumeYes,
|
|
59
|
+
setPromptUsage,
|
|
60
|
+
input,
|
|
61
|
+
select,
|
|
62
|
+
checkbox,
|
|
63
|
+
confirm,
|
|
64
|
+
confirmAction
|
|
65
|
+
};
|