playcademy 0.14.14-alpha.2 → 0.14.15

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
@@ -690,7 +690,14 @@ interface DeployedGameInfo {
690
690
  deployedSecrets?: string[];
691
691
  }
692
692
  interface GameStore {
693
- [projectPath: string]: DeployedGameInfo;
693
+ /** Staging environment game deployments, keyed by absolute project path */
694
+ staging: {
695
+ [projectPath: string]: DeployedGameInfo;
696
+ };
697
+ /** Production environment game deployments, keyed by absolute project path */
698
+ production: {
699
+ [projectPath: string]: DeployedGameInfo;
700
+ };
694
701
  }
695
702
  /**
696
703
  * Deployment context containing all information needed for deployment
package/dist/index.js CHANGED
@@ -8980,6 +8980,7 @@ init_context();
8980
8980
 
8981
8981
  // src/lib/games/storage.ts
8982
8982
  init_constants2();
8983
+ init_config2();
8983
8984
  import { existsSync as existsSync19 } from "node:fs";
8984
8985
  import { mkdir as mkdir3, readFile as readFile3, writeFile as writeFile3 } from "node:fs/promises";
8985
8986
  import { homedir as homedir2 } from "node:os";
@@ -8997,33 +8998,82 @@ async function loadGameStore() {
8997
8998
  const storePath = getGamesStorePath();
8998
8999
  if (existsSync19(storePath)) {
8999
9000
  const content = await readFile3(storePath, "utf-8");
9000
- return JSON.parse(content);
9001
+ const parsed = JSON.parse(content);
9002
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
9003
+ return { staging: {}, production: {} };
9004
+ }
9005
+ const parsedObj = parsed;
9006
+ if (!("staging" in parsedObj) && !("production" in parsedObj)) {
9007
+ const entries = Object.entries(parsedObj);
9008
+ const looksValidLegacy = entries.every(
9009
+ ([, v]) => v !== null && typeof v === "object" && !Array.isArray(v)
9010
+ );
9011
+ if (!looksValidLegacy) {
9012
+ return { staging: {}, production: {} };
9013
+ }
9014
+ const migrated = { staging: {}, production: {} };
9015
+ for (const [key, value] of entries) {
9016
+ const info = value;
9017
+ if (typeof key === "string" && key.includes(":")) {
9018
+ const idx = key.lastIndexOf(":");
9019
+ const basePath = key.slice(0, idx);
9020
+ const envSuffix = key.slice(idx + 1);
9021
+ if (envSuffix === "staging") {
9022
+ migrated.staging[basePath] = info;
9023
+ continue;
9024
+ }
9025
+ if (envSuffix === "production") {
9026
+ migrated.production[basePath] = info;
9027
+ continue;
9028
+ }
9029
+ }
9030
+ migrated.staging[key] = info;
9031
+ }
9032
+ await saveGameStore(migrated);
9033
+ return migrated;
9034
+ }
9035
+ const store = parsedObj;
9036
+ return {
9037
+ staging: store.staging ?? {},
9038
+ production: store.production ?? {}
9039
+ };
9001
9040
  }
9002
9041
  } catch {
9003
9042
  }
9004
- return {};
9043
+ return {
9044
+ staging: {},
9045
+ production: {}
9046
+ };
9005
9047
  }
9006
9048
  async function saveGameStore(store) {
9007
9049
  await ensureConfigDir();
9008
9050
  const storePath = getGamesStorePath();
9009
9051
  await writeFile3(storePath, JSON.stringify(store, null, 2), "utf-8");
9010
9052
  }
9011
- async function getDeployedGame(projectPath) {
9053
+ async function getDeployedGame(projectPath, environment) {
9012
9054
  const store = await loadGameStore();
9013
- return store[projectPath] || null;
9055
+ const env = environment ?? getEnvironment();
9056
+ const bucket = env === "production" ? store.production : store.staging;
9057
+ return bucket[projectPath] || null;
9014
9058
  }
9015
- async function saveDeployedGame(projectPath, gameInfo) {
9059
+ async function saveDeployedGame(projectPath, gameInfo, environment) {
9016
9060
  const store = await loadGameStore();
9017
- store[projectPath] = {
9018
- ...store[projectPath],
9061
+ const env = environment ?? getEnvironment();
9062
+ const bucket = env === "production" ? store.production : store.staging;
9063
+ bucket[projectPath] = {
9064
+ ...bucket[projectPath],
9019
9065
  ...gameInfo
9020
9066
  };
9021
9067
  await saveGameStore(store);
9022
9068
  }
9023
- async function removeDeployedGame(projectPath) {
9069
+ async function removeDeployedGame(projectPath, environment) {
9024
9070
  const store = await loadGameStore();
9025
- delete store[projectPath];
9026
- await saveGameStore(store);
9071
+ const env = environment ?? getEnvironment();
9072
+ const bucket = env === "production" ? store.production : store.staging;
9073
+ if (bucket[projectPath]) {
9074
+ delete bucket[projectPath];
9075
+ await saveGameStore(store);
9076
+ }
9027
9077
  }
9028
9078
  async function saveDeploymentState(game, backendMetadata, context2) {
9029
9079
  const { projectPath, buildHash, buildSize, config, fullConfig } = context2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playcademy",
3
- "version": "0.14.14-alpha.2",
3
+ "version": "0.14.15",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {