@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,138 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
logger
|
|
4
|
+
} from "./cli-4YB3ROVR.js";
|
|
5
|
+
import {
|
|
6
|
+
CliError,
|
|
7
|
+
reportResult
|
|
8
|
+
} from "./cli-N6H6T2E2.js";
|
|
9
|
+
|
|
10
|
+
// cli/commands/package-bundle.ts
|
|
11
|
+
import { existsSync, readdirSync, readFileSync, statSync } from "fs";
|
|
12
|
+
import { mkdir, rm } from "fs/promises";
|
|
13
|
+
import { dirname, join, relative, resolve, sep } from "path";
|
|
14
|
+
import AdmZip from "adm-zip";
|
|
15
|
+
function emptyDirectoryEntries(root, excluded) {
|
|
16
|
+
const empty = /* @__PURE__ */ new Set();
|
|
17
|
+
const walk = (absolute, prefix) => {
|
|
18
|
+
let holdsFile = false;
|
|
19
|
+
for (const child of readdirSync(absolute, { withFileTypes: true })) {
|
|
20
|
+
const childPath = join(absolute, child.name);
|
|
21
|
+
if (child.isDirectory()) {
|
|
22
|
+
if (walk(childPath, `${prefix}${child.name}/`)) holdsFile = true;
|
|
23
|
+
} else if (childPath !== excluded) {
|
|
24
|
+
holdsFile = true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (!holdsFile && prefix !== "") empty.add(prefix);
|
|
28
|
+
return holdsFile;
|
|
29
|
+
};
|
|
30
|
+
walk(root, "");
|
|
31
|
+
return empty;
|
|
32
|
+
}
|
|
33
|
+
function includeBundleEntry(entryPath, emptyDirectories, outputRelToBuildDir, separator = sep) {
|
|
34
|
+
const entryName = separator === "/" ? entryPath : entryPath.split(separator).join("/");
|
|
35
|
+
if (emptyDirectories.has(entryName)) return false;
|
|
36
|
+
if (outputRelToBuildDir === null) return true;
|
|
37
|
+
return entryPath !== outputRelToBuildDir;
|
|
38
|
+
}
|
|
39
|
+
function readManifest(buildDirAbs) {
|
|
40
|
+
const manifestPath = join(buildDirAbs, "seriousgaming.json");
|
|
41
|
+
if (!existsSync(manifestPath)) {
|
|
42
|
+
throw new CliError(
|
|
43
|
+
"BUILD_NOT_FOUND",
|
|
44
|
+
`Manifest not found at ${manifestPath}. Run "seriousgaming-sdk build" before "package bundle".`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
let raw;
|
|
48
|
+
try {
|
|
49
|
+
raw = readFileSync(manifestPath, "utf-8");
|
|
50
|
+
} catch (error) {
|
|
51
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
52
|
+
throw new CliError("BUILD_NOT_FOUND", `Failed to read ${manifestPath}: ${message}`);
|
|
53
|
+
}
|
|
54
|
+
let manifest;
|
|
55
|
+
try {
|
|
56
|
+
manifest = JSON.parse(raw);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
59
|
+
throw new CliError("BUILD_NOT_FOUND", `Failed to parse ${manifestPath}: ${message}`, {
|
|
60
|
+
hint: 'Run "seriousgaming-sdk build" again.'
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const identifier = manifest.package?.definition?.identifier;
|
|
64
|
+
const version = manifest.package?.definition?.version;
|
|
65
|
+
if (!identifier || !version) {
|
|
66
|
+
throw new CliError(
|
|
67
|
+
"BUILD_NOT_FOUND",
|
|
68
|
+
`Manifest at ${manifestPath} is missing package.definition.identifier or package.definition.version.`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
return { identifier, version };
|
|
72
|
+
}
|
|
73
|
+
async function bundlePackage(options) {
|
|
74
|
+
const buildDirAbs = resolve(options.workingDir, options.buildDir);
|
|
75
|
+
if (!existsSync(buildDirAbs)) {
|
|
76
|
+
throw new CliError(
|
|
77
|
+
"BUILD_NOT_FOUND",
|
|
78
|
+
`Build directory not found at ${buildDirAbs}. Run "seriousgaming-sdk build" first.`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
const manifest = readManifest(buildDirAbs);
|
|
82
|
+
const defaultOutputFile = join(
|
|
83
|
+
options.buildDir,
|
|
84
|
+
`${manifest.identifier}-${manifest.version}.zip`
|
|
85
|
+
);
|
|
86
|
+
const outputFileAbs = resolve(options.workingDir, options.outputFile ?? defaultOutputFile);
|
|
87
|
+
await mkdir(dirname(outputFileAbs), { recursive: true });
|
|
88
|
+
await rm(outputFileAbs, { force: true });
|
|
89
|
+
const outputRelToBuildDir = relative(buildDirAbs, outputFileAbs);
|
|
90
|
+
const outputIsInsideBuildDir = !outputRelToBuildDir.startsWith("..") && !outputRelToBuildDir.startsWith(sep);
|
|
91
|
+
const emptyDirectories = emptyDirectoryEntries(
|
|
92
|
+
buildDirAbs,
|
|
93
|
+
outputIsInsideBuildDir ? outputFileAbs : ""
|
|
94
|
+
);
|
|
95
|
+
const zip = new AdmZip();
|
|
96
|
+
zip.addLocalFolder(
|
|
97
|
+
buildDirAbs,
|
|
98
|
+
void 0,
|
|
99
|
+
(entryPath) => includeBundleEntry(
|
|
100
|
+
entryPath,
|
|
101
|
+
emptyDirectories,
|
|
102
|
+
outputIsInsideBuildDir ? outputRelToBuildDir : null
|
|
103
|
+
)
|
|
104
|
+
);
|
|
105
|
+
const fileCount = zip.getEntries().filter((entry) => !entry.isDirectory).length;
|
|
106
|
+
if (fileCount === 0) {
|
|
107
|
+
throw new CliError(
|
|
108
|
+
"BUILD_NOT_FOUND",
|
|
109
|
+
`Build directory ${buildDirAbs} contains no files to bundle.`
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
zip.writeZip(outputFileAbs);
|
|
113
|
+
const size = statSync(outputFileAbs).size;
|
|
114
|
+
const result = {
|
|
115
|
+
outputFile: outputFileAbs,
|
|
116
|
+
size,
|
|
117
|
+
fileCount,
|
|
118
|
+
identifier: manifest.identifier,
|
|
119
|
+
version: manifest.version
|
|
120
|
+
};
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
async function packageBundleCommand(options) {
|
|
124
|
+
const result = await bundlePackage(options);
|
|
125
|
+
reportResult(result, () => {
|
|
126
|
+
logger.success(`Bundle created at ${result.outputFile}`);
|
|
127
|
+
console.log(` identifier: ${result.identifier}`);
|
|
128
|
+
console.log(` version: ${result.version}`);
|
|
129
|
+
console.log(` files: ${result.fileCount}`);
|
|
130
|
+
console.log(` size: ${result.size} bytes`);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export {
|
|
135
|
+
includeBundleEntry,
|
|
136
|
+
bundlePackage,
|
|
137
|
+
packageBundleCommand
|
|
138
|
+
};
|
|
@@ -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-YVVXUD2G.js";
|
|
9
|
+
import {
|
|
10
|
+
resolveInputSource
|
|
11
|
+
} from "./cli-4UWFQNGF.js";
|
|
12
|
+
import {
|
|
13
|
+
updatePackageFiles
|
|
14
|
+
} from "./cli-FYINNRML.js";
|
|
15
|
+
import "./cli-IUS2YCD3.js";
|
|
16
|
+
import "./cli-QUNIRH7A.js";
|
|
17
|
+
import "./cli-BYJWFFCF.js";
|
|
18
|
+
import "./cli-MBNMPVDC.js";
|
|
19
|
+
import "./cli-GFBGYFYD.js";
|
|
20
|
+
import {
|
|
21
|
+
operationError,
|
|
22
|
+
recordOperationResult
|
|
23
|
+
} from "./cli-UELGBQG7.js";
|
|
24
|
+
import {
|
|
25
|
+
confirmAction,
|
|
26
|
+
input
|
|
27
|
+
} from "./cli-ZTWOE3ZT.js";
|
|
28
|
+
import "./cli-4BV45LBH.js";
|
|
29
|
+
import "./cli-4AKVLEC4.js";
|
|
30
|
+
import "./cli-VCKOC2EV.js";
|
|
31
|
+
import "./cli-E2NLWIFE.js";
|
|
32
|
+
import "./cli-25RWY5BQ.js";
|
|
33
|
+
import "./cli-QWQMPCL6.js";
|
|
34
|
+
import "./cli-SMFSZF2G.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,226 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
validateTickControllerResult
|
|
4
|
+
} from "./cli-4LKXZQ2B.js";
|
|
5
|
+
import {
|
|
6
|
+
LOGIC_NODE_BUILTIN,
|
|
7
|
+
bundleFileOf,
|
|
8
|
+
didYouMean,
|
|
9
|
+
pointerOf,
|
|
10
|
+
readLogicExports
|
|
11
|
+
} from "./cli-SMFSZF2G.js";
|
|
12
|
+
|
|
13
|
+
// cli/validation/resource-validator.ts
|
|
14
|
+
import { existsSync } from "fs";
|
|
15
|
+
import { relative, resolve, sep } from "path";
|
|
16
|
+
function checkCapabilityReferences(label, resource, definition, keys, config) {
|
|
17
|
+
const known = (config.capabilities ?? []).map((capability) => capability.definition.identifier);
|
|
18
|
+
const declared = new Set(known);
|
|
19
|
+
const errors = [];
|
|
20
|
+
const findings = [];
|
|
21
|
+
const file = bundleFileOf(resource.type, resource.identifier);
|
|
22
|
+
for (const key of keys) {
|
|
23
|
+
(definition[key] ?? []).forEach((capability, index) => {
|
|
24
|
+
if (declared.has(capability)) return;
|
|
25
|
+
const message = `${label} "${resource.identifier}" ${key} capability "${capability}" which is not found in configuration`;
|
|
26
|
+
const hint = didYouMean(capability, known) ?? "Create it with `pnpm run sdk new capability`, or remove the entry.";
|
|
27
|
+
errors.push(message);
|
|
28
|
+
findings.push({
|
|
29
|
+
code: "REFERENCE_UNKNOWN",
|
|
30
|
+
message,
|
|
31
|
+
...file === void 0 ? {} : { file },
|
|
32
|
+
pointer: pointerOf("definition", key, index),
|
|
33
|
+
resource,
|
|
34
|
+
hint
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return { success: errors.length === 0, errors, findings };
|
|
39
|
+
}
|
|
40
|
+
function validateEngine(engine, config) {
|
|
41
|
+
return checkCapabilityReferences(
|
|
42
|
+
"Engine",
|
|
43
|
+
{ type: "engine", identifier: engine.definition.identifier },
|
|
44
|
+
engine.definition,
|
|
45
|
+
["reads", "writes"],
|
|
46
|
+
config
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
function validateUserInterface(userInterface, config) {
|
|
50
|
+
const identifier = userInterface.definition.identifier;
|
|
51
|
+
return checkCapabilityReferences(
|
|
52
|
+
"User Interface",
|
|
53
|
+
{ type: identifier, identifier },
|
|
54
|
+
userInterface.definition,
|
|
55
|
+
["reads", "writes"],
|
|
56
|
+
config
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
function validateEndpoint(endpoint, config) {
|
|
60
|
+
return checkCapabilityReferences(
|
|
61
|
+
"Endpoint",
|
|
62
|
+
{ type: "endpoint", identifier: endpoint.definition.identifier },
|
|
63
|
+
endpoint.definition,
|
|
64
|
+
["reads"],
|
|
65
|
+
config
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
function validateHook(hook, config) {
|
|
69
|
+
return checkCapabilityReferences(
|
|
70
|
+
"Hook",
|
|
71
|
+
{ type: "hook", identifier: hook.definition.identifier },
|
|
72
|
+
hook.definition,
|
|
73
|
+
["reads", "writes"],
|
|
74
|
+
config
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
function validateValidator(validator, config) {
|
|
78
|
+
return checkCapabilityReferences(
|
|
79
|
+
"Validator",
|
|
80
|
+
{ type: "validator", identifier: validator.definition.identifier },
|
|
81
|
+
validator.definition,
|
|
82
|
+
["reads"],
|
|
83
|
+
config
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
function validateTickController(tc, config) {
|
|
87
|
+
const tcId = tc.definition.identifier;
|
|
88
|
+
const references = checkCapabilityReferences(
|
|
89
|
+
"Tick Controller",
|
|
90
|
+
{ type: "tick_controller", identifier: tcId },
|
|
91
|
+
tc.definition,
|
|
92
|
+
["reads"],
|
|
93
|
+
config
|
|
94
|
+
);
|
|
95
|
+
const errors = [...references.errors];
|
|
96
|
+
const declaredInterval = staticIntervalCandidate(tc, config);
|
|
97
|
+
if (declaredInterval !== void 0) {
|
|
98
|
+
const intervalError = validateTickControllerResult({ intervalMs: declaredInterval });
|
|
99
|
+
if (intervalError) {
|
|
100
|
+
errors.push(`Tick Controller "${tcId}" has an out-of-range interval: ${intervalError}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return { success: errors.length === 0, errors, findings: references.findings };
|
|
104
|
+
}
|
|
105
|
+
function staticIntervalCandidate(tc, config) {
|
|
106
|
+
for (const identifier of tc.definition.settings ?? []) {
|
|
107
|
+
const settings = config.settings?.find((s) => s.definition.identifier === identifier);
|
|
108
|
+
const schema = settings?.definition.settingsSchema;
|
|
109
|
+
const intervalProp = schema?.properties?.intervalMs;
|
|
110
|
+
const candidate = intervalProp?.const ?? intervalProp?.default;
|
|
111
|
+
if (typeof candidate === "number") return candidate;
|
|
112
|
+
}
|
|
113
|
+
return void 0;
|
|
114
|
+
}
|
|
115
|
+
function builtinRefusal(check) {
|
|
116
|
+
return check.failure?.includes(LOGIC_NODE_BUILTIN) ? check.failure : void 0;
|
|
117
|
+
}
|
|
118
|
+
function refusedResult(message, check, resource) {
|
|
119
|
+
const located = (check.failureDiagnostics ?? []).map(
|
|
120
|
+
({ severity: _severity, ...diagnostic }) => ({ ...diagnostic, resource })
|
|
121
|
+
);
|
|
122
|
+
return {
|
|
123
|
+
success: false,
|
|
124
|
+
errors: [message],
|
|
125
|
+
findings: located.length > 0 ? located.map((finding, i) => i === 0 ? { ...finding, message } : finding) : [{ code: "LOGIC_NODE_BUILTIN", message, resource }]
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function logicFileOf(workingDir, logicFile) {
|
|
129
|
+
return relative(workingDir, logicFile).split(sep).join("/");
|
|
130
|
+
}
|
|
131
|
+
async function validateEngineFiles(engine, workingDir) {
|
|
132
|
+
const errors = [];
|
|
133
|
+
const engineDir = resolve(workingDir, engine.rootDirectory);
|
|
134
|
+
const logicDir = resolve(engineDir, engine.logic.directory);
|
|
135
|
+
const logicFile = resolve(logicDir, engine.logic.entrypoint);
|
|
136
|
+
const isAggregate = engine.definition.aggregate === true;
|
|
137
|
+
const requiredExports = isAggregate ? ["InitAggregate", "RunAggregate"] : ["Run"];
|
|
138
|
+
const expectedExports = isAggregate ? "InitAggregate and RunAggregate" : "Run";
|
|
139
|
+
const check = await readLogicExports(logicFile, requiredExports, workingDir);
|
|
140
|
+
const resource = { type: "engine", identifier: engine.definition.identifier };
|
|
141
|
+
const file = logicFileOf(workingDir, logicFile);
|
|
142
|
+
const findings = [];
|
|
143
|
+
if (!check.exists) {
|
|
144
|
+
const message = `Engine "${engine.definition.identifier}": Logic file not found: ${logicFile}. Create it with exports for ${expectedExports} functions.`;
|
|
145
|
+
errors.push(message);
|
|
146
|
+
findings.push({ code: "LOGIC_EXPORT_MISSING", message, file, resource });
|
|
147
|
+
return { success: errors.length === 0, errors, findings };
|
|
148
|
+
}
|
|
149
|
+
const refused = builtinRefusal(check);
|
|
150
|
+
if (refused) {
|
|
151
|
+
return refusedResult(
|
|
152
|
+
`Engine "${engine.definition.identifier}": ${refused}`,
|
|
153
|
+
check,
|
|
154
|
+
resource
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
const missingExports = requiredExports.filter((name) => !check.present.has(name));
|
|
158
|
+
for (const name of missingExports) {
|
|
159
|
+
const why = isAggregate ? `This engine is aggregate because its logic exports the other of "InitAggregate" / "RunAggregate". An aggregate engine runs across every team at both initialisation and tick time, so it needs both.` : "A per-team engine must export `Run`; `Init` is optional.";
|
|
160
|
+
const message = `Engine "${engine.definition.identifier}": Logic file "${logicFile}" does not export "${name}". ` + why;
|
|
161
|
+
errors.push(message);
|
|
162
|
+
findings.push({ code: "LOGIC_EXPORT_MISSING", message, file, resource });
|
|
163
|
+
}
|
|
164
|
+
return errors.length === 0 ? { success: true, errors } : { success: false, errors, findings };
|
|
165
|
+
}
|
|
166
|
+
async function validateEndpointFiles(endpoint, workingDir) {
|
|
167
|
+
const logicFile = resolve(
|
|
168
|
+
workingDir,
|
|
169
|
+
endpoint.rootDirectory,
|
|
170
|
+
endpoint.logic.directory,
|
|
171
|
+
endpoint.logic.entrypoint
|
|
172
|
+
);
|
|
173
|
+
const identifier = endpoint.definition.identifier;
|
|
174
|
+
const check = await readLogicExports(logicFile, ["Handle", "Plan"], workingDir);
|
|
175
|
+
const resource = { type: "endpoint", identifier };
|
|
176
|
+
const missing = (message) => ({
|
|
177
|
+
success: false,
|
|
178
|
+
errors: [message],
|
|
179
|
+
findings: [
|
|
180
|
+
{
|
|
181
|
+
code: "LOGIC_EXPORT_MISSING",
|
|
182
|
+
message,
|
|
183
|
+
file: logicFileOf(workingDir, logicFile),
|
|
184
|
+
resource
|
|
185
|
+
}
|
|
186
|
+
]
|
|
187
|
+
});
|
|
188
|
+
if (!check.exists) {
|
|
189
|
+
return missing(
|
|
190
|
+
`Endpoint "${identifier}": Logic file not found: ${logicFile}. Create it exporting \`Handle\`, or \`Plan\` and \`Respond\`.`
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
const refused = builtinRefusal(check);
|
|
194
|
+
if (refused) {
|
|
195
|
+
return refusedResult(`Endpoint "${identifier}": ${refused}`, check, resource);
|
|
196
|
+
}
|
|
197
|
+
if (!check.present.has("Handle") && !check.present.has("Plan")) {
|
|
198
|
+
return missing(
|
|
199
|
+
`Endpoint "${identifier}": Logic file "${logicFile}" exports neither \`Handle\` nor \`Plan\`, so there is nothing to call. Export \`Handle\` to answer with the effects, or \`Plan\` and \`Respond\` to answer after they land.`
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
return { success: true, errors: [] };
|
|
203
|
+
}
|
|
204
|
+
function validateUIFiles(ui, workingDir) {
|
|
205
|
+
const errors = [];
|
|
206
|
+
const uiSourceDir = resolve(workingDir, ui.rootDirectory);
|
|
207
|
+
const entrypoint = resolve(uiSourceDir, ui.ui.entrypoint);
|
|
208
|
+
if (!existsSync(entrypoint)) {
|
|
209
|
+
errors.push(
|
|
210
|
+
`"${ui.definition.identifier}": UI entrypoint not found: ${entrypoint}. The UI directory "${uiSourceDir}" must contain "${ui.ui.entrypoint}".`
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
return { success: errors.length === 0, errors };
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export {
|
|
217
|
+
validateEngine,
|
|
218
|
+
validateUserInterface,
|
|
219
|
+
validateEndpoint,
|
|
220
|
+
validateHook,
|
|
221
|
+
validateValidator,
|
|
222
|
+
validateTickController,
|
|
223
|
+
validateEngineFiles,
|
|
224
|
+
validateEndpointFiles,
|
|
225
|
+
validateUIFiles
|
|
226
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
deleteSessionUserInterfaceFiles,
|
|
4
|
+
findSessionUserInterfaceReferences
|
|
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/session/delete.ts
|
|
37
|
+
async function deleteSessionUserInterface(options) {
|
|
38
|
+
logger.info("\nDeleting session user interface...\n");
|
|
39
|
+
const identifier = "session";
|
|
40
|
+
loadPackageContext(options.workingDir);
|
|
41
|
+
const references = findSessionUserInterfaceReferences({
|
|
42
|
+
packagePath: options.workingDir,
|
|
43
|
+
identifier
|
|
44
|
+
});
|
|
45
|
+
logger.info(`Session User Interface: ${identifier}`);
|
|
46
|
+
if (references.length > 0) {
|
|
47
|
+
logger.info("\nThis session user interface is used in games:");
|
|
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 session user interface?" },
|
|
55
|
+
options.yes
|
|
56
|
+
);
|
|
57
|
+
if (!confirmed) {
|
|
58
|
+
logger.info("\nDeletion cancelled.\n");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
logger.info("");
|
|
62
|
+
const result = deleteSessionUserInterfaceFiles({
|
|
63
|
+
packagePath: options.workingDir,
|
|
64
|
+
identifier
|
|
65
|
+
});
|
|
66
|
+
if (!result.success) {
|
|
67
|
+
throw operationError(result, "Failed to delete session user interface 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("Session user interface deleted successfully!");
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
deleteSessionUserInterface
|
|
89
|
+
};
|