@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,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
updateSettingsEditor
|
|
4
|
+
} from "./cli-AV2FYC5G.js";
|
|
5
|
+
import "./cli-Q6ZBZYK2.js";
|
|
6
|
+
import "./cli-5IAW3LIF.js";
|
|
7
|
+
import "./cli-S5IVGDDD.js";
|
|
8
|
+
import "./cli-4VFZHLDG.js";
|
|
9
|
+
import "./cli-4UWFQNGF.js";
|
|
10
|
+
import "./cli-4SIWLHQO.js";
|
|
11
|
+
import "./cli-IUS2YCD3.js";
|
|
12
|
+
import "./cli-QUNIRH7A.js";
|
|
13
|
+
import "./cli-J4UBELKF.js";
|
|
14
|
+
import "./cli-XSVGKI3R.js";
|
|
15
|
+
import "./cli-TT36JCU5.js";
|
|
16
|
+
import "./cli-OXAUOWCN.js";
|
|
17
|
+
import "./cli-KSGB2ZLK.js";
|
|
18
|
+
import "./cli-ZTWOE3ZT.js";
|
|
19
|
+
import "./cli-LQOHATY2.js";
|
|
20
|
+
import "./cli-IEMKI7J7.js";
|
|
21
|
+
import "./cli-OMWC75CC.js";
|
|
22
|
+
import "./cli-BYCHKSSH.js";
|
|
23
|
+
import "./cli-25RWY5BQ.js";
|
|
24
|
+
import "./cli-QWQMPCL6.js";
|
|
25
|
+
import "./cli-VQ6HVQW4.js";
|
|
26
|
+
import "./cli-F2D4GGUA.js";
|
|
27
|
+
import "./cli-4YB3ROVR.js";
|
|
28
|
+
import "./cli-N6H6T2E2.js";
|
|
29
|
+
|
|
30
|
+
// cli/commands/resources/setup/update.ts
|
|
31
|
+
function updateSetup(definitionInput, options) {
|
|
32
|
+
return updateSettingsEditor("setup", definitionInput, options);
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
updateSetup
|
|
36
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
isAlive,
|
|
4
|
+
lockOnDisk,
|
|
5
|
+
removeLockFile
|
|
6
|
+
} from "./cli-SRHBXZCN.js";
|
|
7
|
+
import {
|
|
8
|
+
CliError
|
|
9
|
+
} from "./cli-N6H6T2E2.js";
|
|
10
|
+
|
|
11
|
+
// cli/dev/stop-server.ts
|
|
12
|
+
var GRACE_MS = 5e3;
|
|
13
|
+
var KILL_TIMEOUT_MS = 5e3;
|
|
14
|
+
async function stopLockedServer(packagePath, lock, options = {}) {
|
|
15
|
+
signal(lock, "SIGTERM");
|
|
16
|
+
if (await released(packagePath, lock, options.graceMs ?? GRACE_MS)) return;
|
|
17
|
+
if (isAlive(lock.pid)) signal(lock, "SIGKILL");
|
|
18
|
+
if (!await released(packagePath, lock, KILL_TIMEOUT_MS)) {
|
|
19
|
+
throw new CliError(
|
|
20
|
+
"DEV_SERVER_STOP_FAILED",
|
|
21
|
+
`The dev server (pid ${lock.pid}) did not stop, even when killed.`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function signal(lock, name) {
|
|
26
|
+
try {
|
|
27
|
+
process.kill(lock.pid, name);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
if (error.code === "ESRCH") return;
|
|
30
|
+
throw new CliError(
|
|
31
|
+
"DEV_SERVER_STOP_FAILED",
|
|
32
|
+
`Could not stop the dev server (pid ${lock.pid}): ${error.message}`
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function released(packagePath, lock, timeoutMs) {
|
|
37
|
+
const deadline = Date.now() + timeoutMs;
|
|
38
|
+
for (; ; ) {
|
|
39
|
+
const current = await lockOnDisk(packagePath);
|
|
40
|
+
if (!current || current.instanceId !== lock.instanceId) return true;
|
|
41
|
+
if (!isAlive(lock.pid)) {
|
|
42
|
+
await removeLockFile(packagePath, lock.instanceId);
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
if (Date.now() >= deadline) return false;
|
|
46
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
stopLockedServer
|
|
52
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
readAuthoredBundle
|
|
4
|
+
} from "./cli-4VFZHLDG.js";
|
|
5
|
+
import {
|
|
6
|
+
resolveInputSource
|
|
7
|
+
} from "./cli-4UWFQNGF.js";
|
|
8
|
+
import {
|
|
9
|
+
createScenarioFiles
|
|
10
|
+
} from "./cli-J4UBELKF.js";
|
|
11
|
+
import {
|
|
12
|
+
loadPackageContext
|
|
13
|
+
} from "./cli-XSVGKI3R.js";
|
|
14
|
+
import "./cli-TT36JCU5.js";
|
|
15
|
+
import "./cli-OXAUOWCN.js";
|
|
16
|
+
import {
|
|
17
|
+
operationError,
|
|
18
|
+
printOperationResult
|
|
19
|
+
} from "./cli-KSGB2ZLK.js";
|
|
20
|
+
import {
|
|
21
|
+
input
|
|
22
|
+
} from "./cli-ZTWOE3ZT.js";
|
|
23
|
+
import "./cli-LQOHATY2.js";
|
|
24
|
+
import "./cli-IEMKI7J7.js";
|
|
25
|
+
import "./cli-OMWC75CC.js";
|
|
26
|
+
import "./cli-BYCHKSSH.js";
|
|
27
|
+
import "./cli-25RWY5BQ.js";
|
|
28
|
+
import "./cli-QWQMPCL6.js";
|
|
29
|
+
import {
|
|
30
|
+
validateSDKScenario
|
|
31
|
+
} from "./cli-VQ6HVQW4.js";
|
|
32
|
+
import "./cli-F2D4GGUA.js";
|
|
33
|
+
import {
|
|
34
|
+
logger
|
|
35
|
+
} from "./cli-4YB3ROVR.js";
|
|
36
|
+
import "./cli-N6H6T2E2.js";
|
|
37
|
+
|
|
38
|
+
// cli/commands/resources/scenario/new.ts
|
|
39
|
+
async function createScenario(definitionInput, options) {
|
|
40
|
+
logger.info("\nCreating new scenario...\n");
|
|
41
|
+
loadPackageContext(options.workingDir, {
|
|
42
|
+
suggestNewPackage: true
|
|
43
|
+
});
|
|
44
|
+
const inputSource = await resolveInputSource(definitionInput, options.file);
|
|
45
|
+
const jsonDefinition = inputSource.kind === "json" ? inputSource.json : null;
|
|
46
|
+
if (jsonDefinition) {
|
|
47
|
+
const scenarioInput = readAuthoredBundle({
|
|
48
|
+
json: jsonDefinition,
|
|
49
|
+
type: "scenario",
|
|
50
|
+
command: "new",
|
|
51
|
+
validate: validateSDKScenario
|
|
52
|
+
});
|
|
53
|
+
logger.info("Creating scenario files...\n");
|
|
54
|
+
const result2 = await createScenarioFiles({
|
|
55
|
+
packagePath: options.workingDir,
|
|
56
|
+
identifier: scenarioInput.definition.identifier,
|
|
57
|
+
definition: scenarioInput.definition,
|
|
58
|
+
rootDirectory: scenarioInput.rootDirectory
|
|
59
|
+
});
|
|
60
|
+
if (!result2.success) {
|
|
61
|
+
throw operationError(result2, "Failed to create scenario files");
|
|
62
|
+
}
|
|
63
|
+
logger.success("Scenario created successfully!");
|
|
64
|
+
printOperationResult(result2);
|
|
65
|
+
logger.info("\nNext steps:");
|
|
66
|
+
logger.info(" 1. Add assets to scenarios/<id>/assets/shared/");
|
|
67
|
+
logger.info(" 2. Add settings overrides to the scenario definition");
|
|
68
|
+
logger.info(" 3. Reference this scenario in a game definition");
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
logger.info("No JSON definition provided. Starting interactive mode...\n");
|
|
72
|
+
const scenarioName = await input({
|
|
73
|
+
message: 'Scenario name (last segment, e.g., "ai_influence"):',
|
|
74
|
+
default: "myscenario",
|
|
75
|
+
validate: (value) => {
|
|
76
|
+
if (!value.trim()) return "Scenario name is required";
|
|
77
|
+
if (!/^[a-z][a-z0-9_]*$/.test(value.trim())) {
|
|
78
|
+
return "Scenario name must start with a lowercase letter and contain only lowercase letters, numbers, and underscores";
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const identifier = scenarioName.trim();
|
|
84
|
+
const displayName = await input({
|
|
85
|
+
message: "Display name (English):",
|
|
86
|
+
default: scenarioName.trim().split("_").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ")
|
|
87
|
+
});
|
|
88
|
+
const description = await input({
|
|
89
|
+
message: "Description (optional, press Enter to skip):",
|
|
90
|
+
default: ""
|
|
91
|
+
});
|
|
92
|
+
const locales = {
|
|
93
|
+
en: { name: displayName }
|
|
94
|
+
};
|
|
95
|
+
if (description) {
|
|
96
|
+
locales.en.description = description;
|
|
97
|
+
}
|
|
98
|
+
logger.info("\nCreating scenario files...\n");
|
|
99
|
+
const result = await createScenarioFiles({
|
|
100
|
+
packagePath: options.workingDir,
|
|
101
|
+
identifier,
|
|
102
|
+
definition: { locales },
|
|
103
|
+
rootDirectory: "."
|
|
104
|
+
});
|
|
105
|
+
if (!result.success) {
|
|
106
|
+
throw operationError(result, "Failed to create scenario files");
|
|
107
|
+
}
|
|
108
|
+
logger.success("Scenario created successfully!");
|
|
109
|
+
printOperationResult(result);
|
|
110
|
+
logger.info("\nNext steps:");
|
|
111
|
+
logger.info(" 1. Add assets to scenarios/<id>/assets/shared/");
|
|
112
|
+
logger.info(" 2. Add settings overrides to the scenario definition");
|
|
113
|
+
logger.info(" 3. Reference this scenario in a game definition");
|
|
114
|
+
}
|
|
115
|
+
export {
|
|
116
|
+
createScenario
|
|
117
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
promptForSettings
|
|
4
|
+
} from "./cli-ZDOTXEKL.js";
|
|
5
|
+
import {
|
|
6
|
+
loadResourceIdentifiers
|
|
7
|
+
} from "./cli-Q6ZBZYK2.js";
|
|
8
|
+
import {
|
|
9
|
+
readAuthoredBundle
|
|
10
|
+
} from "./cli-4VFZHLDG.js";
|
|
11
|
+
import {
|
|
12
|
+
resolveInputSource
|
|
13
|
+
} from "./cli-4UWFQNGF.js";
|
|
14
|
+
import {
|
|
15
|
+
createPresentationFiles
|
|
16
|
+
} from "./cli-4SIWLHQO.js";
|
|
17
|
+
import "./cli-IUS2YCD3.js";
|
|
18
|
+
import "./cli-QUNIRH7A.js";
|
|
19
|
+
import "./cli-J4UBELKF.js";
|
|
20
|
+
import {
|
|
21
|
+
loadPackageContext
|
|
22
|
+
} from "./cli-XSVGKI3R.js";
|
|
23
|
+
import {
|
|
24
|
+
presentFields
|
|
25
|
+
} from "./cli-TT36JCU5.js";
|
|
26
|
+
import "./cli-OXAUOWCN.js";
|
|
27
|
+
import {
|
|
28
|
+
BUILD_COMMAND,
|
|
29
|
+
generateTypes,
|
|
30
|
+
operationError,
|
|
31
|
+
printOperationResult
|
|
32
|
+
} from "./cli-KSGB2ZLK.js";
|
|
33
|
+
import {
|
|
34
|
+
checkbox,
|
|
35
|
+
input
|
|
36
|
+
} from "./cli-ZTWOE3ZT.js";
|
|
37
|
+
import "./cli-LQOHATY2.js";
|
|
38
|
+
import "./cli-IEMKI7J7.js";
|
|
39
|
+
import "./cli-OMWC75CC.js";
|
|
40
|
+
import "./cli-BYCHKSSH.js";
|
|
41
|
+
import "./cli-25RWY5BQ.js";
|
|
42
|
+
import "./cli-QWQMPCL6.js";
|
|
43
|
+
import {
|
|
44
|
+
validateSDKPresentation
|
|
45
|
+
} from "./cli-VQ6HVQW4.js";
|
|
46
|
+
import "./cli-F2D4GGUA.js";
|
|
47
|
+
import {
|
|
48
|
+
logger
|
|
49
|
+
} from "./cli-4YB3ROVR.js";
|
|
50
|
+
import "./cli-N6H6T2E2.js";
|
|
51
|
+
|
|
52
|
+
// cli/commands/resources/presentation/new.ts
|
|
53
|
+
async function finishCreate(workingDir) {
|
|
54
|
+
await generateTypes(workingDir);
|
|
55
|
+
logger.info("Next steps:");
|
|
56
|
+
logger.info(" 1. Edit the slides: presentation/src/Slides.tsx");
|
|
57
|
+
logger.info(` 2. Run "${BUILD_COMMAND}" to build your package`);
|
|
58
|
+
}
|
|
59
|
+
async function createPresentation(definitionInput, options) {
|
|
60
|
+
logger.info("\nCreating new presentation...\n");
|
|
61
|
+
loadPackageContext(options.workingDir, {
|
|
62
|
+
suggestNewPackage: true
|
|
63
|
+
});
|
|
64
|
+
const inputSource = await resolveInputSource(definitionInput, options.file);
|
|
65
|
+
const jsonDefinition = inputSource.kind === "json" ? inputSource.json : null;
|
|
66
|
+
if (jsonDefinition) {
|
|
67
|
+
const presentationInput = readAuthoredBundle({
|
|
68
|
+
json: jsonDefinition,
|
|
69
|
+
type: "presentation",
|
|
70
|
+
command: "new",
|
|
71
|
+
validate: validateSDKPresentation
|
|
72
|
+
});
|
|
73
|
+
logger.info("Creating presentation files...\n");
|
|
74
|
+
const result2 = await createPresentationFiles({
|
|
75
|
+
packagePath: options.workingDir,
|
|
76
|
+
name: "Presentation",
|
|
77
|
+
definition: presentationInput.definition
|
|
78
|
+
});
|
|
79
|
+
if (!result2.success) {
|
|
80
|
+
throw operationError(result2, "Failed to create presentation files");
|
|
81
|
+
}
|
|
82
|
+
logger.success("Presentation created successfully!");
|
|
83
|
+
printOperationResult(result2);
|
|
84
|
+
await finishCreate(options.workingDir);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
logger.info("No JSON definition provided. Starting interactive mode...\n");
|
|
88
|
+
const name = await input({
|
|
89
|
+
message: "Display name (human-readable):",
|
|
90
|
+
default: "Presentation"
|
|
91
|
+
});
|
|
92
|
+
logger.info("");
|
|
93
|
+
const availableCapabilities = loadResourceIdentifiers(options.workingDir, "capability");
|
|
94
|
+
const reads = [];
|
|
95
|
+
if (availableCapabilities.length > 0) {
|
|
96
|
+
logger.info("Select the capabilities this presentation reads.\n");
|
|
97
|
+
logger.info("Tip: Use arrow keys to navigate, space to select, enter to continue.\n");
|
|
98
|
+
const readCapabilities = await checkbox({
|
|
99
|
+
message: "Capabilities this presentation reads from:",
|
|
100
|
+
choices: availableCapabilities.map((id) => ({ name: id, value: id })),
|
|
101
|
+
pageSize: 10
|
|
102
|
+
});
|
|
103
|
+
reads.push(...readCapabilities);
|
|
104
|
+
logger.info("");
|
|
105
|
+
} else {
|
|
106
|
+
logger.info("No existing capabilities found in this package.\n");
|
|
107
|
+
}
|
|
108
|
+
const settings = await promptForSettings(options.workingDir, "presentation");
|
|
109
|
+
logger.info("Creating presentation files...\n");
|
|
110
|
+
const result = await createPresentationFiles({
|
|
111
|
+
packagePath: options.workingDir,
|
|
112
|
+
name,
|
|
113
|
+
definition: presentFields({ reads, settings })
|
|
114
|
+
});
|
|
115
|
+
if (!result.success) {
|
|
116
|
+
throw operationError(result, "Failed to create presentation files");
|
|
117
|
+
}
|
|
118
|
+
logger.success("Presentation created successfully!");
|
|
119
|
+
printOperationResult(result);
|
|
120
|
+
await finishCreate(options.workingDir);
|
|
121
|
+
}
|
|
122
|
+
export {
|
|
123
|
+
createPresentation
|
|
124
|
+
};
|