@genex-ai/cli-demo 0.41.0 → 0.42.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.
Files changed (2) hide show
  1. package/dist/index.js +53 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -652,9 +652,6 @@ function tokenizeCommand(input) {
652
652
  return tokens;
653
653
  }
654
654
 
655
- // src/lib/project.ts
656
- import crypto2 from "crypto";
657
-
658
655
  // src/utils/colors.ts
659
656
  var useColor = Boolean(process.stdout.isTTY) && process.env.NO_COLOR === void 0 && process.env.TERM !== "dumb";
660
657
  var ESC = String.fromCharCode(27);
@@ -753,8 +750,21 @@ async function apiFetch(url, init2 = {}) {
753
750
  }
754
751
  return res;
755
752
  }
753
+ async function fetchSignedInEmail(apiUrl, token) {
754
+ try {
755
+ const res = await apiFetch(`${apiUrl}/api/auth/get-session`, {
756
+ headers: { Authorization: `Bearer ${token}` }
757
+ });
758
+ if (!res.ok) return null;
759
+ const data = await res.json().catch(() => null);
760
+ return data?.user?.email ?? null;
761
+ } catch {
762
+ return null;
763
+ }
764
+ }
756
765
 
757
766
  // src/lib/project.ts
767
+ import crypto2 from "crypto";
758
768
  async function createDraftProject(opts) {
759
769
  const { apiUrl, token, colyseusUrl, dashboardUrl, log } = opts;
760
770
  log.step("Creating your project\u2026");
@@ -798,7 +808,7 @@ async function createDraftProject(opts) {
798
808
  }
799
809
  log.success(`Created project ${c.cyan(project.slug)}.`);
800
810
  log.plain(
801
- ` your game's page (live now \u2014 share this link): ${c.cyan(`${new URL(dashboardUrl).origin}/draft/${project.slug}`)}`
811
+ ` \u279C Send this link to the user right now \u2014 their game's page is already live (a placeholder world until the first preview): ${c.cyan(`${new URL(dashboardUrl).origin}/draft/${project.slug}`)}`
802
812
  );
803
813
  if (project.playUrl) log.dim(` play (after preview/publish): ${project.playUrl}`);
804
814
  log.dim(` dashboard: ${dashboardUrl}/dashboard`);
@@ -821,6 +831,19 @@ async function createDraftProject(opts) {
821
831
  function randomSuffix() {
822
832
  return crypto2.randomBytes(3).toString("hex");
823
833
  }
834
+ async function fetchProjectStatus(apiUrl, token, slug) {
835
+ try {
836
+ const res = await apiFetch(`${apiUrl}/api/projects/by-slug/${encodeURIComponent(slug)}`, {
837
+ headers: { Authorization: `Bearer ${token}` }
838
+ });
839
+ if (!res.ok) return null;
840
+ const data = await res.json().catch(() => null);
841
+ if (!data?.project) return null;
842
+ return data.project.status ?? "draft";
843
+ } catch {
844
+ return null;
845
+ }
846
+ }
824
847
 
825
848
  // src/lib/ssh.ts
826
849
  import fs4 from "fs/promises";
@@ -1099,6 +1122,8 @@ async function runInit(opts) {
1099
1122
  await writeGitignore(process.cwd(), log);
1100
1123
  const apiUrl = getApiUrl(opts.apiUrl);
1101
1124
  const colyseusUrl = getColyseusUrl(opts.colyseusUrl);
1125
+ const signedInEmail = await fetchSignedInEmail(apiUrl, token);
1126
+ if (signedInEmail) log.plain(` signed in as ${c.cyan(signedInEmail)}`);
1102
1127
  const projectName = opts.name?.trim() || path8.basename(process.cwd());
1103
1128
  const meta = await createDraftProject({
1104
1129
  apiUrl,
@@ -1157,6 +1182,8 @@ async function runLink(opts) {
1157
1182
  log.plain("");
1158
1183
  }
1159
1184
  const apiUrl = getApiUrl(opts.apiUrl);
1185
+ const email = await fetchSignedInEmail(apiUrl, token);
1186
+ if (email) log.plain(` signed in as ${c.cyan(email)}`);
1160
1187
  log.step(`Looking up ${c.cyan(slug)}\u2026`);
1161
1188
  const project = await fetchOwnProject(apiUrl, token, slug, log);
1162
1189
  if (!project) {
@@ -1382,6 +1409,16 @@ async function getUploadToken(ctx, commit, log) {
1382
1409
  log.error(`Couldn't reach the API at ${ctx.apiUrl}: ${String(err)}`);
1383
1410
  return null;
1384
1411
  }
1412
+ if (res.status === 401) {
1413
+ log.error("Not authorized (HTTP 401) \u2014 your sign-in expired or was revoked.");
1414
+ log.plain(" Fix: run `genex link <your-game>` and sign in as the game's owner, then re-run this command.");
1415
+ return null;
1416
+ }
1417
+ if (res.status === 404) {
1418
+ log.error("This account doesn't own this game (HTTP 404) \u2014 you're signed in as a different account.");
1419
+ log.plain(" Fix: run `genex link <your-game>` and sign in as the OWNER account, then re-run this command.");
1420
+ return null;
1421
+ }
1385
1422
  if (!res.ok) {
1386
1423
  log.error(`Couldn't get an upload token (HTTP ${res.status}).`);
1387
1424
  return null;
@@ -1831,11 +1868,21 @@ async function runPreview(opts) {
1831
1868
  process.exitCode = 1;
1832
1869
  return;
1833
1870
  }
1871
+ const freshStatus = await fetchProjectStatus(apiUrl, token, meta.slug);
1872
+ if (freshStatus && freshStatus !== meta.status) {
1873
+ meta.status = freshStatus;
1874
+ await writeProject(meta);
1875
+ }
1876
+ const published = meta.status === "published";
1834
1877
  log.plain("");
1835
- log.success("Preview deployed \u2014 unlisted draft (run `genex publish` to list it).");
1878
+ if (published) {
1879
+ log.success("Update deployed \u2014 this game is PUBLISHED, so the new build is already live for everyone.");
1880
+ } else {
1881
+ log.success("Preview deployed \u2014 unlisted draft (run `genex publish` to list it).");
1882
+ }
1836
1883
  const dashboard = meta.dashboardOrigins?.[0];
1837
1884
  if (dashboard) {
1838
- const page = meta.status === "published" ? "world" : "draft";
1885
+ const page = published ? "world" : "draft";
1839
1886
  log.plain(` your game's page (share this link): ${c.cyan(`${dashboard}/${page}/${meta.slug}`)}`);
1840
1887
  }
1841
1888
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genex-ai/cli-demo",
3
- "version": "0.41.0",
3
+ "version": "0.42.0",
4
4
  "description": "Set up your ~/.claude workspace, authorize, create a game project, generate AI assets, and publish (genex CLI).",
5
5
  "type": "module",
6
6
  "bin": {