@replaystage/cli 0.1.0 → 0.2.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/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Command } from 'commander';
2
+ import { SupportedPlatform } from '@replaystage/shared';
2
3
 
3
4
  interface UserInfo {
4
5
  id: string;
@@ -60,6 +61,9 @@ interface ValidationResult {
60
61
  fileHash?: string;
61
62
  files?: string[];
62
63
  aspectRatio?: string;
64
+ supportedPlatforms?: SupportedPlatform;
65
+ platforms?: SupportedPlatform;
66
+ hasPlatformMeta?: boolean;
63
67
  errors: string[];
64
68
  warnings: string[];
65
69
  }
@@ -86,6 +90,7 @@ interface UploadBundleOptions {
86
90
  prompt?: string;
87
91
  changelog?: string;
88
92
  aspectRatio?: string;
93
+ supportedPlatforms?: string;
89
94
  errorMsgFallback?: string;
90
95
  }
91
96
  interface UploadResponse {
@@ -105,6 +110,9 @@ interface UploadResponse {
105
110
  semver?: string;
106
111
  versionNumber?: number;
107
112
  promotedToPublic?: boolean;
113
+ supportedPlatforms?: string;
114
+ supported_platforms?: string;
115
+ platforms?: string;
108
116
  error?: string;
109
117
  message?: string;
110
118
  data?: any;
@@ -119,6 +127,7 @@ interface UpdateBundleOptions {
119
127
  visibility?: "draft" | "unlisted" | "public" | string;
120
128
  changelog?: string;
121
129
  aspectRatio?: string;
130
+ supportedPlatforms?: string;
122
131
  manageToken?: string;
123
132
  token?: string | null;
124
133
  errorMsgFallback?: string;
@@ -133,14 +142,16 @@ declare const updateGame: typeof updateGameBundle;
133
142
  declare function fetchWhoami(apiUrl: string, token: string): Promise<any>;
134
143
 
135
144
  interface ProjectConfig {
136
- slug: string;
145
+ slug?: string;
137
146
  manageToken?: string;
138
147
  apiUrl?: string;
139
- version: string;
148
+ version?: string;
140
149
  title?: string;
141
- updatedAt: string;
150
+ updatedAt?: string;
142
151
  visibility?: "draft" | "unlisted" | "public" | string;
143
152
  aspectRatio?: string;
153
+ supportedPlatforms?: string;
154
+ platforms?: string;
144
155
  }
145
156
  declare function resolveProjectDirectory(targetPath: string): string | null;
146
157
  declare function getProjectConfigPath(targetDir: string): string | null;
@@ -164,6 +175,9 @@ declare function printPublishSuccess(res: {
164
175
  claimUrl?: string;
165
176
  aiTool?: string;
166
177
  fileHash?: string;
178
+ aspectRatio?: string;
179
+ supportedPlatforms?: string;
180
+ platforms?: string;
167
181
  }): void;
168
182
 
169
183
  declare function createProgram(): Command;
package/dist/index.js CHANGED
@@ -44,6 +44,10 @@ async function uploadGameBundle(options) {
44
44
  if (options.fileHash) formData.append("file_hash", options.fileHash);
45
45
  if (options.changelog) formData.append("changelog", options.changelog);
46
46
  if (options.aspectRatio) formData.append("aspect_ratio", options.aspectRatio);
47
+ if (options.supportedPlatforms) {
48
+ formData.append("supportedPlatforms", options.supportedPlatforms);
49
+ formData.append("supported_platforms", options.supportedPlatforms);
50
+ }
47
51
  const headers = {
48
52
  ...options.extraHeaders
49
53
  };
@@ -94,6 +98,10 @@ async function updateGameBundle(slug, options) {
94
98
  if (options.visibility) formData.append("visibility", options.visibility);
95
99
  if (options.changelog) formData.append("changelog", options.changelog);
96
100
  if (options.aspectRatio) formData.append("aspect_ratio", options.aspectRatio);
101
+ if (options.supportedPlatforms) {
102
+ formData.append("supportedPlatforms", options.supportedPlatforms);
103
+ formData.append("supported_platforms", options.supportedPlatforms);
104
+ }
97
105
  const headers = {
98
106
  ...options.extraHeaders
99
107
  };
@@ -287,6 +295,15 @@ ${pc.yellow(`\u2554${border}\u2557`)}`);
287
295
  `${pc.yellow("\u2551")} ${pc.dim("AI Tool:")} ${res.aiTool.padEnd(48)}${pc.yellow("\u2551")}`
288
296
  );
289
297
  }
298
+ if (res.aspectRatio) {
299
+ console.log(
300
+ `${pc.yellow("\u2551")} ${pc.dim("Ratio:")} ${res.aspectRatio.padEnd(48)}${pc.yellow("\u2551")}`
301
+ );
302
+ }
303
+ const plat = res.supportedPlatforms || res.platforms;
304
+ if (plat) {
305
+ console.log(`${pc.yellow("\u2551")} ${pc.dim("Platforms:")} ${plat.padEnd(48)}${pc.yellow("\u2551")}`);
306
+ }
290
307
  console.log(
291
308
  `${pc.yellow("\u2551")} ${pc.dim("Play URL:")} ${pc.cyan(res.url).padEnd(57)}${pc.yellow("\u2551")}`
292
309
  );
@@ -517,6 +534,7 @@ var ASPECT_RATIO_PRESETS = [
517
534
  ];
518
535
  var MIN_ASPECT_RATIO = 0.25;
519
536
  var MAX_ASPECT_RATIO = 4;
537
+ var DEFAULT_SUPPORTED_PLATFORMS = "both";
520
538
 
521
539
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
522
540
  var external_exports = {};
@@ -4623,6 +4641,176 @@ function extractRawAspectRatioFromHtml(html) {
4623
4641
  return null;
4624
4642
  }
4625
4643
 
4644
+ // ../shared/src/platforms.ts
4645
+ var DESKTOP_TOKENS = /* @__PURE__ */ new Set(["desktop", "pc", "mac", "windows", "computer"]);
4646
+ var MOBILE_TOKENS = /* @__PURE__ */ new Set(["mobile", "touch", "phone", "tablet", "ios", "android"]);
4647
+ var UNIVERSAL_TOKENS = /* @__PURE__ */ new Set(["both", "all", "any"]);
4648
+ function normalizeSupportedPlatforms(input) {
4649
+ if (input === void 0 || input === null) {
4650
+ return { valid: true, normalized: DEFAULT_SUPPORTED_PLATFORMS };
4651
+ }
4652
+ const rawTokens = [];
4653
+ if (Array.isArray(input)) {
4654
+ for (const item of input) {
4655
+ if (typeof item === "string") {
4656
+ const split = item.trim().split(/[\s,+/|]+/);
4657
+ for (const s of split) {
4658
+ if (s) rawTokens.push(s.toLowerCase());
4659
+ }
4660
+ } else {
4661
+ return {
4662
+ valid: false,
4663
+ normalized: DEFAULT_SUPPORTED_PLATFORMS,
4664
+ error: "Invalid platform specification. Expected string or array of strings"
4665
+ };
4666
+ }
4667
+ }
4668
+ } else if (typeof input === "string") {
4669
+ const trimmed = input.trim();
4670
+ if (trimmed === "") {
4671
+ return { valid: true, normalized: DEFAULT_SUPPORTED_PLATFORMS };
4672
+ }
4673
+ const split = trimmed.split(/[\s,+/|]+/);
4674
+ for (const s of split) {
4675
+ if (s) rawTokens.push(s.toLowerCase());
4676
+ }
4677
+ } else {
4678
+ return {
4679
+ valid: false,
4680
+ normalized: DEFAULT_SUPPORTED_PLATFORMS,
4681
+ error: "Invalid platform specification. Expected string or array of strings"
4682
+ };
4683
+ }
4684
+ if (rawTokens.length === 0) {
4685
+ return { valid: true, normalized: DEFAULT_SUPPORTED_PLATFORMS };
4686
+ }
4687
+ let hasDesktop = false;
4688
+ let hasMobile = false;
4689
+ let hasBoth = false;
4690
+ for (const token of rawTokens) {
4691
+ if (UNIVERSAL_TOKENS.has(token)) {
4692
+ hasBoth = true;
4693
+ } else if (DESKTOP_TOKENS.has(token)) {
4694
+ hasDesktop = true;
4695
+ } else if (MOBILE_TOKENS.has(token)) {
4696
+ hasMobile = true;
4697
+ } else {
4698
+ return {
4699
+ valid: false,
4700
+ normalized: DEFAULT_SUPPORTED_PLATFORMS,
4701
+ error: `Invalid platform: "${token}". Expected "both", "desktop", "mobile", or combinations like "desktop, mobile"`
4702
+ };
4703
+ }
4704
+ }
4705
+ if (hasBoth || hasDesktop && hasMobile) {
4706
+ return { valid: true, normalized: "both" };
4707
+ }
4708
+ if (hasDesktop) {
4709
+ return { valid: true, normalized: "desktop" };
4710
+ }
4711
+ if (hasMobile) {
4712
+ return { valid: true, normalized: "mobile" };
4713
+ }
4714
+ return { valid: true, normalized: DEFAULT_SUPPORTED_PLATFORMS };
4715
+ }
4716
+ function extractRawPlatformsFromHtml(html) {
4717
+ if (!html || typeof html !== "string") return null;
4718
+ const cleanHtml = html.replace(/<!--[\s\S]*?-->/g, "");
4719
+ const metaTagRegex = /<meta\s+([^>]*?)>/gi;
4720
+ for (const match of cleanHtml.matchAll(metaTagRegex)) {
4721
+ const attrs = match[1];
4722
+ const isPlatformMeta = /(?:^|\s)name\s*=\s*(["']?)replaystage:platforms?\1(?:\s|$|\/)/i.test(
4723
+ attrs
4724
+ );
4725
+ if (!isPlatformMeta) continue;
4726
+ const contentMatch = /(?:^|\s)content\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i.exec(attrs);
4727
+ if (contentMatch) {
4728
+ const content = contentMatch[1] ?? contentMatch[2] ?? contentMatch[3] ?? "";
4729
+ return content.trim();
4730
+ }
4731
+ }
4732
+ return null;
4733
+ }
4734
+ var extractRawSupportedPlatformsFromHtml = extractRawPlatformsFromHtml;
4735
+ function isCandidateScriptFile(filePath) {
4736
+ const normalized = filePath.replace(/\\/g, "/").toLowerCase();
4737
+ if (normalized.includes("/vendor/") || normalized.startsWith("vendor/") || normalized.includes("/node_modules/") || normalized.startsWith("node_modules/") || normalized.includes("__macosx") || normalized.includes("/.git/")) {
4738
+ return false;
4739
+ }
4740
+ if (normalized.endsWith(".min.js") || normalized.endsWith(".min.mjs")) {
4741
+ return false;
4742
+ }
4743
+ const baseName = normalized.split("/").pop() || "";
4744
+ if (/^(three|phaser|pixi|babylon|playcanvas|matter|howler|cannon|tone)[^/]*\.js$/i.test(baseName)) {
4745
+ return false;
4746
+ }
4747
+ return normalized.endsWith(".html") || normalized.endsWith(".htm") || normalized.endsWith(".js") || normalized.endsWith(".mjs");
4748
+ }
4749
+ function stripComments(code) {
4750
+ return code.replace(/<!--[\s\S]*?-->/g, "").replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/[^\r\n]*/g, "");
4751
+ }
4752
+ function detectBundlePlatforms(files, options) {
4753
+ const fileList = [];
4754
+ const decoder = new TextDecoder("utf-8");
4755
+ if (Array.isArray(files)) {
4756
+ for (const item of files) {
4757
+ const strContent = typeof item.content === "string" ? item.content : decoder.decode(item.content);
4758
+ fileList.push({ path: item.path, content: strContent });
4759
+ }
4760
+ } else if (typeof files === "object" && files !== null) {
4761
+ for (const [filePath, content] of Object.entries(files)) {
4762
+ const strContent = typeof content === "string" ? content : decoder.decode(content);
4763
+ fileList.push({ path: filePath, content: strContent });
4764
+ }
4765
+ }
4766
+ let hasPointerLock = false;
4767
+ let hasKeyboard = false;
4768
+ let hasMousemove = false;
4769
+ let hasDesktopMouse = false;
4770
+ let hasTouch = false;
4771
+ let hasMotion = false;
4772
+ let hasUniversalPointerOrClick = false;
4773
+ const POINTER_LOCK_REGEX = /\b(?:requestPointerLock|mozRequestPointerLock|webkitRequestPointerLock|pointerlockchange|pointerlockerror)\b/;
4774
+ const KEYBOARD_REGEX = /\b(?:keydown|keyup|keypress)\b/i;
4775
+ const MOUSEMOVE_REGEX = /\b(?:mousemove)\b/i;
4776
+ const DESKTOP_MOUSE_REGEX = /\b(?:mousedown|mouseup|contextmenu|dblclick|wheel)\b/i;
4777
+ const TOUCH_REGEX = /\b(?:touchstart|touchmove|touchend|touchcancel)\b/i;
4778
+ const MOTION_REGEX = /\b(?:DeviceOrientationEvent|DeviceMotionEvent|devicemotion|deviceorientation)\b/i;
4779
+ const UNIVERSAL_POINTER_REGEX = /\b(?:pointerdown|pointermove|pointerup|click)\b/i;
4780
+ for (const file of fileList) {
4781
+ if (!isCandidateScriptFile(file.path)) continue;
4782
+ const clean = stripComments(file.content);
4783
+ if (POINTER_LOCK_REGEX.test(clean)) hasPointerLock = true;
4784
+ if (KEYBOARD_REGEX.test(clean)) hasKeyboard = true;
4785
+ if (MOUSEMOVE_REGEX.test(clean)) hasMousemove = true;
4786
+ if (DESKTOP_MOUSE_REGEX.test(clean)) hasDesktopMouse = true;
4787
+ if (TOUCH_REGEX.test(clean)) hasTouch = true;
4788
+ if (MOTION_REGEX.test(clean)) hasMotion = true;
4789
+ if (UNIVERSAL_POINTER_REGEX.test(clean)) hasUniversalPointerOrClick = true;
4790
+ }
4791
+ const usesTouchOrMotion = hasTouch || hasMotion;
4792
+ const usesKeyboardOrMousemove = hasKeyboard || hasMousemove;
4793
+ const usesDesktop = hasPointerLock || hasKeyboard || hasMousemove || hasDesktopMouse;
4794
+ let detected = "both";
4795
+ if (hasPointerLock && !usesTouchOrMotion) {
4796
+ detected = "desktop";
4797
+ } else if (usesKeyboardOrMousemove && !usesTouchOrMotion && !hasUniversalPointerOrClick) {
4798
+ detected = "desktop";
4799
+ } else if (usesTouchOrMotion && !usesDesktop && !hasUniversalPointerOrClick) {
4800
+ detected = "mobile";
4801
+ } else {
4802
+ detected = "both";
4803
+ }
4804
+ const hasMobileControls = typeof options?.controls?.mobile === "string" && Boolean(options.controls.mobile.trim());
4805
+ const hasDesktopControls = typeof options?.controls?.desktop === "string" && Boolean(options.controls.desktop.trim());
4806
+ if (detected === "desktop" && hasMobileControls) {
4807
+ detected = "both";
4808
+ } else if (detected === "mobile" && hasDesktopControls) {
4809
+ detected = "both";
4810
+ }
4811
+ return detected;
4812
+ }
4813
+
4626
4814
  // ../shared/src/schemas.ts
4627
4815
  var SLUG_REGEX = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
4628
4816
  var SHA256_REGEX = /^[a-f0-9]{64}$/;
@@ -4682,6 +4870,27 @@ var aspectRatioSchema = external_exports.preprocess((val) => {
4682
4870
  });
4683
4871
  }
4684
4872
  }).transform((val) => normalizeAspectRatio(val).normalized);
4873
+ var supportedPlatformsSchema = external_exports.preprocess((val) => {
4874
+ if (val === null || val === void 0 || val === "") {
4875
+ return DEFAULT_SUPPORTED_PLATFORMS;
4876
+ }
4877
+ return val;
4878
+ }, external_exports.unknown()).superRefine((val, ctx) => {
4879
+ if (typeof val !== "string" && !Array.isArray(val)) {
4880
+ ctx.addIssue({
4881
+ code: external_exports.ZodIssueCode.custom,
4882
+ message: "Invalid platform specification. Expected string or array of strings"
4883
+ });
4884
+ return;
4885
+ }
4886
+ const res = normalizeSupportedPlatforms(val);
4887
+ if (!res.valid) {
4888
+ ctx.addIssue({
4889
+ code: external_exports.ZodIssueCode.custom,
4890
+ message: res.error || "Invalid supported platform"
4891
+ });
4892
+ }
4893
+ }).transform((val) => normalizeSupportedPlatforms(val).normalized);
4685
4894
  var baseGameUploadObject = external_exports.object({
4686
4895
  title: external_exports.string().trim().min(2, "Title must be at least 2 characters").max(MAX_GAME_TITLE_LENGTH, `Title must be ${MAX_GAME_TITLE_LENGTH} characters or less`),
4687
4896
  tagline: external_exports.string({ required_error: "Tagline is required" }).trim().max(
@@ -4707,6 +4916,7 @@ var baseGameUploadObject = external_exports.object({
4707
4916
  visibility: external_exports.enum(UPLOAD_VISIBILITIES).optional(),
4708
4917
  bundleEntry: external_exports.string().trim().min(1).max(200).optional(),
4709
4918
  aspectRatio: aspectRatioSchema.default(DEFAULT_ASPECT_RATIO),
4919
+ supportedPlatforms: supportedPlatformsSchema.default(DEFAULT_SUPPORTED_PLATFORMS),
4710
4920
  changelog: external_exports.string().trim().max(500).optional(),
4711
4921
  slug: slugSchema.optional(),
4712
4922
  fileHash: external_exports.string().regex(SHA256_REGEX, "Invalid SHA-256 hash format").optional(),
@@ -4772,6 +4982,7 @@ var gameUpdateSchema = external_exports.object({
4772
4982
  visibility: external_exports.enum(UPLOAD_VISIBILITIES).optional(),
4773
4983
  bundleEntry: external_exports.string().trim().min(1).max(200).optional(),
4774
4984
  aspectRatio: aspectRatioSchema.optional(),
4985
+ supportedPlatforms: supportedPlatformsSchema.optional(),
4775
4986
  changelog: external_exports.string().trim().max(500).optional(),
4776
4987
  fileHash: external_exports.string().regex(SHA256_REGEX, "Invalid SHA-256 hash format").optional(),
4777
4988
  sourceCode: external_exports.string().max(MAX_HTML_SIZE_BYTES, "Single-file HTML cannot exceed 5MB").optional().nullable(),
@@ -5272,7 +5483,16 @@ function readProjectConfig(targetDir) {
5272
5483
  try {
5273
5484
  const raw = fs3.readFileSync(configPath, "utf-8");
5274
5485
  const parsed = JSON.parse(raw);
5275
- if (!parsed || typeof parsed !== "object" || typeof parsed.slug !== "string") {
5486
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
5487
+ return null;
5488
+ }
5489
+ if ("slug" in parsed) {
5490
+ if (typeof parsed.slug !== "string" || !parsed.slug.trim()) {
5491
+ return null;
5492
+ }
5493
+ }
5494
+ const hasValidKey = typeof parsed.slug === "string" && parsed.slug.trim().length > 0 || typeof parsed.supportedPlatforms === "string" || typeof parsed.platforms === "string" || typeof parsed.aspectRatio === "string";
5495
+ if (!hasValidKey) {
5276
5496
  return null;
5277
5497
  }
5278
5498
  return parsed;
@@ -5351,11 +5571,16 @@ async function validateGamePackage(targetPath) {
5351
5571
  const errors = [];
5352
5572
  const warnings = [];
5353
5573
  let detectedAspectRatio = "auto";
5574
+ let detectedPlatforms = DEFAULT_SUPPORTED_PLATFORMS;
5575
+ let hasPlatformMeta = false;
5354
5576
  if (!fs4.existsSync(resolved)) {
5355
5577
  return {
5356
5578
  valid: false,
5357
5579
  targetPath,
5358
5580
  aspectRatio: detectedAspectRatio,
5581
+ supportedPlatforms: detectedPlatforms,
5582
+ platforms: detectedPlatforms,
5583
+ hasPlatformMeta,
5359
5584
  errors: [`Target path does not exist: ${resolved}`],
5360
5585
  warnings: []
5361
5586
  };
@@ -5384,6 +5609,18 @@ async function validateGamePackage(targetPath) {
5384
5609
  detectedAspectRatio = norm.normalized;
5385
5610
  }
5386
5611
  }
5612
+ const rawPlatformMeta = extractRawSupportedPlatformsFromHtml(htmlStr);
5613
+ if (rawPlatformMeta) {
5614
+ const norm = normalizeSupportedPlatforms(rawPlatformMeta);
5615
+ if (!norm.valid) {
5616
+ errors.push(norm.error || `Invalid platform in HTML meta tag: '${rawPlatformMeta}'`);
5617
+ } else {
5618
+ detectedPlatforms = norm.normalized;
5619
+ hasPlatformMeta = true;
5620
+ }
5621
+ } else {
5622
+ detectedPlatforms = detectBundlePlatforms([{ path: "index.html", content: htmlStr }]);
5623
+ }
5387
5624
  } else if (ext === ".zip") {
5388
5625
  const content = fs4.readFileSync(resolved);
5389
5626
  if (content.length > MAX_BUNDLE_SIZE_BYTES) {
@@ -5410,6 +5647,18 @@ async function validateGamePackage(targetPath) {
5410
5647
  detectedAspectRatio = norm.normalized;
5411
5648
  }
5412
5649
  }
5650
+ const rawPlatformMeta = extractRawSupportedPlatformsFromHtml(htmlContent);
5651
+ if (rawPlatformMeta) {
5652
+ const norm = normalizeSupportedPlatforms(rawPlatformMeta);
5653
+ if (!norm.valid) {
5654
+ errors.push(norm.error || `Invalid platform in HTML meta tag: '${rawPlatformMeta}'`);
5655
+ } else {
5656
+ detectedPlatforms = norm.normalized;
5657
+ hasPlatformMeta = true;
5658
+ }
5659
+ } else {
5660
+ detectedPlatforms = detectBundlePlatforms(unzipped);
5661
+ }
5413
5662
  }
5414
5663
  } catch {
5415
5664
  }
@@ -5499,16 +5748,43 @@ async function validateGamePackage(targetPath) {
5499
5748
  detectedAspectRatio = norm.normalized;
5500
5749
  }
5501
5750
  }
5751
+ const rawPlatformMeta = extractRawSupportedPlatformsFromHtml(htmlContent);
5752
+ if (rawPlatformMeta) {
5753
+ const norm = normalizeSupportedPlatforms(rawPlatformMeta);
5754
+ if (!norm.valid) {
5755
+ errors.push(norm.error || `Invalid platform in HTML meta tag: '${rawPlatformMeta}'`);
5756
+ } else {
5757
+ detectedPlatforms = norm.normalized;
5758
+ hasPlatformMeta = true;
5759
+ }
5760
+ }
5502
5761
  } catch {
5503
5762
  }
5504
5763
  }
5505
5764
  }
5765
+ if (!hasPlatformMeta) {
5766
+ const candidateFiles = [];
5767
+ for (const relPath of collectedFiles) {
5768
+ const ext = path4.extname(relPath).toLowerCase();
5769
+ if (ext === ".html" || ext === ".htm" || ext === ".js" || ext === ".mjs") {
5770
+ try {
5771
+ const content = fs4.readFileSync(path4.join(resolved, relPath), "utf-8");
5772
+ candidateFiles.push({ path: relPath, content });
5773
+ } catch {
5774
+ }
5775
+ }
5776
+ }
5777
+ detectedPlatforms = detectBundlePlatforms(candidateFiles);
5778
+ }
5506
5779
  }
5507
5780
  if (errors.length > 0) {
5508
5781
  return {
5509
5782
  valid: false,
5510
5783
  targetPath,
5511
5784
  aspectRatio: detectedAspectRatio,
5785
+ supportedPlatforms: detectedPlatforms,
5786
+ platforms: detectedPlatforms,
5787
+ hasPlatformMeta,
5512
5788
  errors,
5513
5789
  warnings
5514
5790
  };
@@ -5533,6 +5809,9 @@ async function validateGamePackage(targetPath) {
5533
5809
  fileHash: deterministicHash,
5534
5810
  files: pkg.files,
5535
5811
  aspectRatio: detectedAspectRatio !== "auto" ? detectedAspectRatio : pkg.extractedAspectRatio ?? detectedAspectRatio,
5812
+ supportedPlatforms: detectedPlatforms,
5813
+ platforms: detectedPlatforms,
5814
+ hasPlatformMeta,
5536
5815
  errors: [],
5537
5816
  warnings
5538
5817
  };
@@ -5541,6 +5820,9 @@ async function validateGamePackage(targetPath) {
5541
5820
  valid: false,
5542
5821
  targetPath,
5543
5822
  aspectRatio: detectedAspectRatio,
5823
+ supportedPlatforms: detectedPlatforms,
5824
+ platforms: detectedPlatforms,
5825
+ hasPlatformMeta,
5544
5826
  errors: [err.message || String(err)],
5545
5827
  warnings
5546
5828
  };
@@ -5642,6 +5924,31 @@ async function handlePublish(targetPath = ".", options = {}) {
5642
5924
  } else if (existingConfig?.aspectRatio) {
5643
5925
  resolvedAspectRatio = existingConfig.aspectRatio;
5644
5926
  }
5927
+ let resolvedPlatforms = DEFAULT_SUPPORTED_PLATFORMS;
5928
+ if (options.platforms) {
5929
+ const norm = normalizeSupportedPlatforms(options.platforms);
5930
+ if (!norm.valid) {
5931
+ const errorMsg = norm.error || `Invalid platform: ${options.platforms}`;
5932
+ if (isJson) {
5933
+ printErrorJson("INVALID_OPTIONS", errorMsg, 1);
5934
+ } else {
5935
+ console.error(pc3.red(`
5936
+ \u2716 Invalid option: ${errorMsg}
5937
+ `));
5938
+ }
5939
+ process.exit(1);
5940
+ }
5941
+ resolvedPlatforms = norm.normalized;
5942
+ } else if (validation.hasPlatformMeta && validation.supportedPlatforms) {
5943
+ resolvedPlatforms = validation.supportedPlatforms;
5944
+ } else if (existingConfig?.supportedPlatforms || existingConfig?.platforms) {
5945
+ const norm = normalizeSupportedPlatforms(
5946
+ existingConfig.supportedPlatforms || existingConfig.platforms
5947
+ );
5948
+ resolvedPlatforms = norm.valid ? norm.normalized : DEFAULT_SUPPORTED_PLATFORMS;
5949
+ } else if (validation.supportedPlatforms) {
5950
+ resolvedPlatforms = validation.supportedPlatforms;
5951
+ }
5645
5952
  if (existingConfig?.slug) {
5646
5953
  logInfo(
5647
5954
  `Updating existing stage '${existingConfig.slug}' (current version: ${existingConfig.version || "0.1.0"})...`,
@@ -5657,6 +5964,7 @@ async function handlePublish(targetPath = ".", options = {}) {
5657
5964
  visibility,
5658
5965
  changelog: options.changelog,
5659
5966
  aspectRatio: resolvedAspectRatio,
5967
+ supportedPlatforms: resolvedPlatforms,
5660
5968
  manageToken: existingConfig.manageToken,
5661
5969
  token,
5662
5970
  errorMsgFallback: "Failed to update stage"
@@ -5671,7 +5979,9 @@ async function handlePublish(targetPath = ".", options = {}) {
5671
5979
  title: title || existingConfig.title,
5672
5980
  updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
5673
5981
  visibility: resolvedVis,
5674
- aspectRatio: resolvedAspectRatio
5982
+ aspectRatio: resolvedAspectRatio,
5983
+ supportedPlatforms: resolvedPlatforms,
5984
+ platforms: resolvedPlatforms
5675
5985
  };
5676
5986
  writeProjectConfig(resolvedPath, updatedConfig);
5677
5987
  if (isJson) {
@@ -5684,6 +5994,9 @@ async function handlePublish(targetPath = ".", options = {}) {
5684
5994
  semver: updatedConfig.version,
5685
5995
  versionNumber: updateResult.versionNumber,
5686
5996
  visibility: updatedConfig.visibility,
5997
+ aspectRatio: updatedConfig.aspectRatio,
5998
+ supportedPlatforms: resolvedPlatforms,
5999
+ platforms: resolvedPlatforms,
5687
6000
  promotedToPublic: updateResult.promotedToPublic,
5688
6001
  fileHash: updateResult.fileHash || bundle.fileHash,
5689
6002
  updated: true
@@ -5701,6 +6014,9 @@ async function handlePublish(targetPath = ".", options = {}) {
5701
6014
  if (updatedConfig.visibility) {
5702
6015
  console.log(` Visibility: ${pc3.bold(updatedConfig.visibility)}`);
5703
6016
  }
6017
+ if (updatedConfig.supportedPlatforms) {
6018
+ console.log(` Platforms: ${pc3.bold(updatedConfig.supportedPlatforms)}`);
6019
+ }
5704
6020
  if (options.changelog) {
5705
6021
  console.log(` Changelog: "${options.changelog}"`);
5706
6022
  }
@@ -5746,7 +6062,8 @@ async function handlePublish(targetPath = ".", options = {}) {
5746
6062
  visibility,
5747
6063
  prompt: options.prompt,
5748
6064
  changelog: options.changelog,
5749
- aspectRatio: resolvedAspectRatio
6065
+ aspectRatio: resolvedAspectRatio,
6066
+ supportedPlatforms: resolvedPlatforms
5750
6067
  });
5751
6068
  const initialVersion = result.semver || (visibility === "draft" ? "0.1.0" : "1.0.0");
5752
6069
  const initialVisibility = result.visibility || visibility || (token ? "public" : "unlisted_claimable");
@@ -5758,7 +6075,9 @@ async function handlePublish(targetPath = ".", options = {}) {
5758
6075
  title,
5759
6076
  updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
5760
6077
  visibility: initialVisibility,
5761
- aspectRatio: resolvedAspectRatio
6078
+ aspectRatio: resolvedAspectRatio,
6079
+ supportedPlatforms: resolvedPlatforms,
6080
+ platforms: resolvedPlatforms
5762
6081
  });
5763
6082
  if (isJson) {
5764
6083
  printJson({
@@ -5774,7 +6093,10 @@ async function handlePublish(targetPath = ".", options = {}) {
5774
6093
  expiresAt: result.expiresAt,
5775
6094
  status: result.status,
5776
6095
  semver: initialVersion,
5777
- visibility: initialVisibility
6096
+ visibility: initialVisibility,
6097
+ aspectRatio: resolvedAspectRatio,
6098
+ supportedPlatforms: resolvedPlatforms,
6099
+ platforms: resolvedPlatforms
5778
6100
  });
5779
6101
  } else {
5780
6102
  printPublishSuccess({
@@ -5785,7 +6107,9 @@ async function handlePublish(targetPath = ".", options = {}) {
5785
6107
  claim_token: result.claim_token,
5786
6108
  claimUrl: result.claimUrl,
5787
6109
  aiTool,
5788
- fileHash: bundle.fileHash
6110
+ fileHash: bundle.fileHash,
6111
+ aspectRatio: resolvedAspectRatio,
6112
+ supportedPlatforms: resolvedPlatforms
5789
6113
  });
5790
6114
  console.log(pc3.dim(" \u2139 Project initialized and saved to .replaystage.json"));
5791
6115
  console.log(
@@ -5833,6 +6157,7 @@ async function handleValidate(targetPath = ".", options = {}) {
5833
6157
  console.log(` ${pc4.dim("Format:")} ${result.format || "directory"}`);
5834
6158
  console.log(` ${pc4.dim("Entry Point:")} ${pc4.cyan(result.entryPoint || "index.html")}`);
5835
6159
  console.log(` ${pc4.dim("Aspect Ratio:")} ${result.aspectRatio || "auto"}`);
6160
+ console.log(` ${pc4.dim("Platforms:")} ${result.supportedPlatforms || "both"}`);
5836
6161
  console.log(` ${pc4.dim("File Count:")} ${result.fileCount || 0}`);
5837
6162
  const sizeMb = ((result.totalSizeBytes || 0) / (1024 * 1024)).toFixed(2);
5838
6163
  console.log(` ${pc4.dim("Bundle Size:")} ${sizeMb} MB (limit: 25 MB)`);
@@ -5862,7 +6187,7 @@ async function computeFileFingerprint(filePath) {
5862
6187
  // src/index.ts
5863
6188
  function createProgram() {
5864
6189
  const program = new Command();
5865
- program.name("replaystage").description("ReplayStage CLI: Deploy and share web games from command line and AI agents").version("0.1.0");
6190
+ program.name("replaystage").description("ReplayStage CLI: Deploy and share web games from command line and AI agents").version("0.2.0");
5866
6191
  program.command("publish [path]").description("Package and deploy a web game to ReplayStage").option("-t, --title <title>", "Game title (2-60 characters)").option("-g, --tagline <tagline>", "Catchy one-line arcade tagline (3-120 characters)").option("-d, --description <desc>", "Gameplay instructions or description").option(
5867
6192
  "--tool <tool>",
5868
6193
  "AI tool used to generate the game (claude, gemini, antigravity, cursor, etc.)"
@@ -5872,6 +6197,9 @@ function createProgram() {
5872
6197
  ).option(
5873
6198
  "--aspect-ratio <ratio>",
5874
6199
  "Display aspect ratio (auto, 16:9, 9:16, 4:3, 3:4, 1:1, or custom W:H)"
6200
+ ).option(
6201
+ "--platforms <platforms>",
6202
+ "Supported gaming platforms (both, desktop, mobile, desktop,mobile, all)"
5875
6203
  ).option("--prompt <prompt>", "Creation prompt used to synthesize the game").option("--draft", "Publish as draft preview (WIP, excluded from leaderboards)").option("--unlisted", "Publish as unlisted private stage (direct link only)").option("--public", "Publish directly to public leaderboard (or promote draft to public)").option("--changelog <message>", "Changelog note describing updates in this version").option("--fresh", "Force fresh upload instead of updating existing stage in .replaystage.json").option("--anonymous", "Publish as anonymous instant preview without credentials").option("--hunter", "Submit as hunter / curator rather than original maker").option("--maker-name <name>", "Original maker name when submitting as hunter").option("--token <token>", "ReplayStage API token").option("--api-url <url>", "API endpoint URL (defaults to https://replaystage.com)").option("--json", "Output machine-readable JSON").action(async (targetPath, options) => {
5876
6204
  await handlePublish(targetPath, options);
5877
6205
  });