playcademy 0.16.0 → 0.16.2

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/cli.js CHANGED
@@ -2965,7 +2965,7 @@ import { join as join13 } from "path";
2965
2965
  // package.json with { type: 'json' }
2966
2966
  var package_default2 = {
2967
2967
  name: "playcademy",
2968
- version: "0.15.6",
2968
+ version: "0.16.1",
2969
2969
  type: "module",
2970
2970
  exports: {
2971
2971
  ".": {
package/dist/index.d.ts CHANGED
@@ -1179,6 +1179,8 @@ interface DevServerOptions {
1179
1179
  platformUrl?: string;
1180
1180
  /** Custom logger for embedding (e.g., from vite plugin) */
1181
1181
  customLogger?: PluginLogger;
1182
+ /** Game UUID (if known). If not provided, falls back to slug. */
1183
+ gameId?: string;
1182
1184
  }
1183
1185
 
1184
1186
  /**
package/dist/index.js CHANGED
@@ -744,10 +744,6 @@ var BADGES = {
744
744
  EARLY_ADOPTER: ITEM_SLUGS.EARLY_ADOPTER_BADGE,
745
745
  FIRST_GAME: ITEM_SLUGS.FIRST_GAME_BADGE
746
746
  };
747
- var CORE_GAME_UUIDS = {
748
- /** Internal playground game for development and testing */
749
- PLAYGROUND: "00000000-0000-0000-0000-000000000001"
750
- };
751
747
 
752
748
  // ../constants/src/workers.ts
753
749
  var WORKER_NAMING = {
@@ -1533,6 +1529,23 @@ async function requireAuthenticatedClient() {
1533
1529
  const client = await createClient();
1534
1530
  return client;
1535
1531
  }
1532
+ async function requireDeveloperClient() {
1533
+ const client = await requireAuthenticatedClient();
1534
+ const environment = getEnvironment();
1535
+ const user = await client.users.me();
1536
+ if (user.role !== "developer" && user.role !== "admin") {
1537
+ const applyCommand2 = environment === "production" ? "Run `playcademy dev apply --env production` to apply for developer access." : "Run `playcademy dev apply` to apply for developer access.";
1538
+ logger.newLine();
1539
+ logger.admonition("warning", "Developer Access Required", [
1540
+ "This command requires developer access.",
1541
+ "",
1542
+ user.developerStatus === "pending" ? "Your developer application is pending review." : user.developerStatus === "none" ? applyCommand2 : "Contact support if you believe this is an error."
1543
+ ]);
1544
+ logger.newLine();
1545
+ process.exit(1);
1546
+ }
1547
+ return client;
1548
+ }
1536
1549
 
1537
1550
  // src/lib/core/debug.ts
1538
1551
  var PLAYCADEMY_ENV_VARS = [
@@ -3976,7 +3989,7 @@ import { join as join12 } from "path";
3976
3989
  // package.json with { type: 'json' }
3977
3990
  var package_default2 = {
3978
3991
  name: "playcademy",
3979
- version: "0.15.6",
3992
+ version: "0.16.1",
3980
3993
  type: "module",
3981
3994
  exports: {
3982
3995
  ".": {
@@ -6716,7 +6729,14 @@ var FilteredLog = class extends Log {
6716
6729
  }
6717
6730
  };
6718
6731
  async function startDevServer(options) {
6719
- const { port, config: _config, platformUrl, logger: logger2 = true, customLogger } = options;
6732
+ const {
6733
+ port,
6734
+ config: _config,
6735
+ platformUrl,
6736
+ logger: logger2 = true,
6737
+ customLogger,
6738
+ gameId: providedGameId
6739
+ } = options;
6720
6740
  await waitForPort(port, 1e3);
6721
6741
  const config = _config ?? await loadConfig();
6722
6742
  await ensurePlaycademyTypes();
@@ -6737,9 +6757,10 @@ async function startDevServer(options) {
6737
6757
  const filteredLog = logger2 ? new FilteredLog(LogLevel.INFO, customLogger) : new Log(LogLevel.NONE);
6738
6758
  const sandboxInfo = readServerInfo("sandbox", workspace);
6739
6759
  const baseUrl = platformUrl ?? sandboxInfo?.url ?? process.env.PLAYCADEMY_BASE_URL ?? `http://localhost:${DEFAULT_PORTS.SANDBOX}`;
6760
+ const gameId = providedGameId ?? getSlugFromConfig(config);
6740
6761
  const bindings = {
6741
- PLAYCADEMY_API_KEY: process.env.PLAYCADEMY_API_KEY || "dev-api-key",
6742
- GAME_ID: CORE_GAME_UUIDS.PLAYGROUND,
6762
+ PLAYCADEMY_API_KEY: process.env.PLAYCADEMY_API_KEY || "sandbox-game-backend-token",
6763
+ GAME_ID: gameId,
6743
6764
  PLAYCADEMY_BASE_URL: baseUrl
6744
6765
  };
6745
6766
  for (const [key, value] of Object.entries(envSecrets)) {
@@ -8023,7 +8044,7 @@ async function updateBuildMetadata(context2) {
8023
8044
  }
8024
8045
  }
8025
8046
  async function prepareDeploymentContext(options) {
8026
- const client = await requireAuthenticatedClient();
8047
+ const client = await requireDeveloperClient();
8027
8048
  const { config, configFileName } = await loadDeployConfig(options.config);
8028
8049
  const fullConfig = await loadConfig(options.config).catch(() => null);
8029
8050
  const finalConfig = {
@@ -8395,13 +8416,14 @@ async function checkTimebackSetup(context2, environment) {
8395
8416
  } catch (error) {
8396
8417
  const is404 = error && typeof error === "object" && "status" in error && error.status === 404;
8397
8418
  if (is404) {
8419
+ const setupCommand2 = environment === "production" ? "`playcademy timeback setup --env production`" : "`playcademy timeback setup`";
8398
8420
  logger.newLine();
8399
8421
  logger.admonition("warning", "TimeBack Integration Not Set Up", [
8400
8422
  "Your project has TimeBack integration enabled but setup has not been completed",
8401
8423
  "",
8402
8424
  "TimeBack features will not work until you run:",
8403
8425
  "",
8404
- ` \`playcademy timeback setup --env ${environment}\``
8426
+ ` ${setupCommand2}`
8405
8427
  ]);
8406
8428
  }
8407
8429
  }
@@ -10625,7 +10647,7 @@ var getStatusCommand = new Command13("status").description("Check your developer
10625
10647
  });
10626
10648
 
10627
10649
  // package.json
10628
- var version2 = "0.15.6";
10650
+ var version2 = "0.16.1";
10629
10651
 
10630
10652
  // src/commands/dev/server.ts
10631
10653
  function setupCleanupHandlers(workspace, getServer) {
@@ -11263,7 +11285,8 @@ async function runDbResetLocal(options) {
11263
11285
  }
11264
11286
  async function runDbReset(options = {}) {
11265
11287
  try {
11266
- if (options.remote) {
11288
+ const isRemote = options.remote || !!options.env;
11289
+ if (isRemote) {
11267
11290
  await runDbResetRemote(options);
11268
11291
  } else {
11269
11292
  await runDbResetLocal(options);
@@ -11528,7 +11551,8 @@ async function runDbSeed(options = {}) {
11528
11551
  logger.newLine();
11529
11552
  process.exit(1);
11530
11553
  }
11531
- if (options.remote) {
11554
+ const isRemote = options.remote || !!options.env;
11555
+ if (isRemote) {
11532
11556
  await runDbSeedRemote(seedFile, options);
11533
11557
  } else {
11534
11558
  await runDbSeedLocal(seedFile, options);
@@ -12386,24 +12410,24 @@ async function runKVListLocal(options) {
12386
12410
  try {
12387
12411
  const kv = await mf.getKVNamespace(CLOUDFLARE_BINDINGS.KV);
12388
12412
  const listResult = await kv.list({ prefix: options.prefix });
12389
- const keyNames = listResult.keys?.map((k) => k.name) || [];
12413
+ const keys = listResult.keys ?? [];
12390
12414
  if (options.json) {
12391
- logger.json(keyNames);
12415
+ logger.json(keys);
12392
12416
  return;
12393
12417
  }
12394
12418
  if (options.raw) {
12395
- for (const keyName of keyNames) {
12396
- logger.raw(keyName);
12419
+ for (const key of keys) {
12420
+ logger.raw(key.name);
12397
12421
  }
12398
12422
  return;
12399
12423
  }
12400
- if (keyNames.length === 0) {
12424
+ if (keys.length === 0) {
12401
12425
  logger.remark("No keys found in KV namespace");
12402
12426
  } else {
12403
- logger.success(`Found ${keyNames.length} ${pluralize(keyNames.length, "key")}`);
12427
+ logger.success(`Found ${keys.length} ${pluralize(keys.length, "key")}`);
12404
12428
  logger.newLine();
12405
- for (const keyName of keyNames) {
12406
- logger.bold(keyName, 1);
12429
+ for (const key of keys) {
12430
+ logger.bold(key.name, 1);
12407
12431
  }
12408
12432
  }
12409
12433
  logger.newLine();
@@ -12484,7 +12508,7 @@ async function runKVSeedRemote(seedFile, options) {
12484
12508
  logger.newLine();
12485
12509
  const confirmed = await confirm13({
12486
12510
  message: "Continue seeding?",
12487
- default: true
12511
+ default: false
12488
12512
  });
12489
12513
  if (!confirmed) {
12490
12514
  logger.remark("Cancelled");
@@ -14654,10 +14678,11 @@ var verifyCommand = new Command36("verify").description("Verify TimeBack integra
14654
14678
  } catch (error) {
14655
14679
  const is404 = error && typeof error === "object" && "status" in error && error.status === 404;
14656
14680
  if (is404) {
14681
+ const setupCommand2 = environment === "production" ? "`playcademy timeback setup --env production`" : "`playcademy timeback setup`";
14657
14682
  logger.admonition("info", "TimeBack Not Set Up", [
14658
14683
  "Run the setup command to get started:",
14659
14684
  "",
14660
- ` \`playcademy timeback setup --env ${environment}\``,
14685
+ ` ${setupCommand2}`,
14661
14686
  "",
14662
14687
  "Learn more: <<https://docs.playcademy.net/timeback>>"
14663
14688
  ]);
@@ -15031,6 +15056,7 @@ export {
15031
15056
  reportNoChanges,
15032
15057
  requireAuthenticatedClient,
15033
15058
  requireConfigFile,
15059
+ requireDeveloperClient,
15034
15060
  resetDatabase,
15035
15061
  runInit,
15036
15062
  saveAuthStore,
package/dist/utils.d.ts CHANGED
@@ -341,6 +341,8 @@ interface DevServerOptions {
341
341
  platformUrl?: string;
342
342
  /** Custom logger for embedding (e.g., from vite plugin) */
343
343
  customLogger?: PluginLogger;
344
+ /** Game UUID (if known). If not provided, falls back to slug. */
345
+ gameId?: string;
344
346
  }
345
347
 
346
348
  /**
package/dist/utils.js CHANGED
@@ -649,10 +649,6 @@ var BADGES = {
649
649
  EARLY_ADOPTER: ITEM_SLUGS.EARLY_ADOPTER_BADGE,
650
650
  FIRST_GAME: ITEM_SLUGS.FIRST_GAME_BADGE
651
651
  };
652
- var CORE_GAME_UUIDS = {
653
- /** Internal playground game for development and testing */
654
- PLAYGROUND: "00000000-0000-0000-0000-000000000001"
655
- };
656
652
 
657
653
  // ../utils/src/package-manager.ts
658
654
  import { execSync } from "child_process";
@@ -1645,6 +1641,11 @@ function pluralize(count, singular, plural) {
1645
1641
  // ../utils/src/pure/index.ts
1646
1642
  init_package_json();
1647
1643
 
1644
+ // ../utils/src/slug.ts
1645
+ function generateSlug(text) {
1646
+ return text.toString().toLowerCase().replace(/\s+/g, "-").replace(/[^\w-]+/g, "").replace(/--+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
1647
+ }
1648
+
1648
1649
  // src/lib/secrets/env.ts
1649
1650
  init_file_loader();
1650
1651
  import { existsSync as existsSync4, writeFileSync as writeFileSync2 } from "fs";
@@ -1711,6 +1712,11 @@ function loadTemplateString(filename) {
1711
1712
  throw new Error(`Template not found: ${filename}. Searched: ${candidatePaths.join(", ")}`);
1712
1713
  }
1713
1714
 
1715
+ // src/lib/core/game.ts
1716
+ function getSlugFromConfig(config) {
1717
+ return generateSlug(config.name);
1718
+ }
1719
+
1714
1720
  // src/lib/core/import.ts
1715
1721
  import { mkdtempSync, rmSync } from "fs";
1716
1722
  import { tmpdir } from "os";
@@ -2321,7 +2327,7 @@ import { join as join12 } from "path";
2321
2327
  // package.json with { type: 'json' }
2322
2328
  var package_default2 = {
2323
2329
  name: "playcademy",
2324
- version: "0.15.6",
2330
+ version: "0.16.1",
2325
2331
  type: "module",
2326
2332
  exports: {
2327
2333
  ".": {
@@ -2871,7 +2877,14 @@ var FilteredLog = class extends Log {
2871
2877
  }
2872
2878
  };
2873
2879
  async function startDevServer(options) {
2874
- const { port, config: _config, platformUrl, logger: logger2 = true, customLogger } = options;
2880
+ const {
2881
+ port,
2882
+ config: _config,
2883
+ platformUrl,
2884
+ logger: logger2 = true,
2885
+ customLogger,
2886
+ gameId: providedGameId
2887
+ } = options;
2875
2888
  await waitForPort(port, 1e3);
2876
2889
  const config = _config ?? await loadConfig();
2877
2890
  await ensurePlaycademyTypes();
@@ -2892,9 +2905,10 @@ async function startDevServer(options) {
2892
2905
  const filteredLog = logger2 ? new FilteredLog(LogLevel.INFO, customLogger) : new Log(LogLevel.NONE);
2893
2906
  const sandboxInfo = readServerInfo("sandbox", workspace);
2894
2907
  const baseUrl = platformUrl ?? sandboxInfo?.url ?? process.env.PLAYCADEMY_BASE_URL ?? `http://localhost:${DEFAULT_PORTS.SANDBOX}`;
2908
+ const gameId = providedGameId ?? getSlugFromConfig(config);
2895
2909
  const bindings = {
2896
- PLAYCADEMY_API_KEY: process.env.PLAYCADEMY_API_KEY || "dev-api-key",
2897
- GAME_ID: CORE_GAME_UUIDS.PLAYGROUND,
2910
+ PLAYCADEMY_API_KEY: process.env.PLAYCADEMY_API_KEY || "sandbox-game-backend-token",
2911
+ GAME_ID: gameId,
2898
2912
  PLAYCADEMY_BASE_URL: baseUrl
2899
2913
  };
2900
2914
  for (const [key, value] of Object.entries(envSecrets)) {
package/dist/version.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // package.json with { type: 'json' }
2
2
  var package_default = {
3
3
  name: "playcademy",
4
- version: "0.15.6",
4
+ version: "0.16.1",
5
5
  type: "module",
6
6
  exports: {
7
7
  ".": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playcademy",
3
- "version": "0.16.0",
3
+ "version": "0.16.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "@inquirer/prompts": "^7.8.6",
53
- "@playcademy/sdk": "0.2.7",
53
+ "@playcademy/sdk": "0.2.9",
54
54
  "chokidar": "^4.0.3",
55
55
  "colorette": "^2.0.20",
56
56
  "commander": "^14.0.1",