@playcraft/cli 0.0.30 → 0.0.31

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.
@@ -294,12 +294,53 @@ function writeMetaDataDefaults(projectDir, extensionName, values) {
294
294
  }
295
295
  writeFileSync(metaPath, JSON.stringify(metaData, null, 2), 'utf-8');
296
296
  }
297
+ /**
298
+ * Get the main scene ID from manifest.json.
299
+ *
300
+ * Priority:
301
+ * 1. Scene with isMain: true
302
+ * 2. If only one scene exists, use that scene
303
+ * 3. If multiple scenes without isMain, return null (caller should fallback)
304
+ */
305
+ function getMainSceneId(projectDir) {
306
+ if (!fileExists(projectDir, MANIFEST_PATH))
307
+ return null;
308
+ try {
309
+ const manifestJson = JSON.parse(readLocalFile(projectDir, MANIFEST_PATH));
310
+ const scenes = manifestJson?.scenes;
311
+ if (!Array.isArray(scenes) || scenes.length === 0)
312
+ return null;
313
+ // Priority 1: Find scene with isMain: true
314
+ const mainScene = scenes.find((s) => s.isMain === true);
315
+ if (mainScene?.id)
316
+ return String(mainScene.id);
317
+ // Priority 2: If only one scene, use it
318
+ if (scenes.length === 1 && scenes[0]?.id) {
319
+ return String(scenes[0].id);
320
+ }
321
+ // Multiple scenes without isMain → cannot determine
322
+ return null;
323
+ }
324
+ catch {
325
+ return null;
326
+ }
327
+ }
328
+ /**
329
+ * Resolve the GameConfig file path for a given variant (scene).
330
+ *
331
+ * If variantId is not provided, automatically detect the current scene:
332
+ * 1. Scene with isMain: true in manifest.json
333
+ * 2. If only one scene exists, use that scene
334
+ * 3. If multiple scenes without isMain, return null (fallback to MetaData.json)
335
+ */
297
336
  function resolveGameConfigPathForVariant(projectDir, variantId) {
298
- if (!variantId)
337
+ // Auto-detect scene if not specified
338
+ const sceneId = variantId ?? getMainSceneId(projectDir);
339
+ if (!sceneId)
299
340
  return null;
300
- if (!fileExists(projectDir, scenePath(variantId)))
341
+ if (!fileExists(projectDir, scenePath(sceneId)))
301
342
  return null;
302
- const sceneJson = JSON.parse(readLocalFile(projectDir, scenePath(variantId)));
343
+ const sceneJson = JSON.parse(readLocalFile(projectDir, scenePath(sceneId)));
303
344
  if (!fileExists(projectDir, ASSETS_JSON_PATH))
304
345
  return null;
305
346
  const assetsJson = JSON.parse(readLocalFile(projectDir, ASSETS_JSON_PATH));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcraft/cli",
3
- "version": "0.0.30",
3
+ "version": "0.0.31",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {
@@ -23,8 +23,8 @@
23
23
  "release": "node scripts/release.js"
24
24
  },
25
25
  "dependencies": {
26
- "@playcraft/build": "^0.0.31",
27
- "@playcraft/common": "^0.0.19",
26
+ "@playcraft/build": "^0.0.32",
27
+ "@playcraft/common": "^0.0.20",
28
28
  "chokidar": "^4.0.3",
29
29
  "commander": "^13.1.0",
30
30
  "cors": "^2.8.6",