playcademy 0.14.0 → 0.14.2-alpha.1

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 (3) hide show
  1. package/dist/db.js +0 -8
  2. package/dist/index.js +105 -100
  3. package/package.json +1 -3
package/dist/db.js CHANGED
@@ -21,7 +21,6 @@ var init_file_loader = __esm({
21
21
  // src/lib/db/path.ts
22
22
  import { copyFileSync, existsSync, mkdirSync, readdirSync, unlinkSync } from "fs";
23
23
  import { join as join2 } from "path";
24
- import Database from "better-sqlite3";
25
24
 
26
25
  // src/constants/config.ts
27
26
  var ENV_FILES = [
@@ -108,10 +107,6 @@ var ensureDirectoryExists = (dir) => {
108
107
  mkdirSync(dir, { recursive: true });
109
108
  }
110
109
  };
111
- var createEmptyDatabase = (path) => {
112
- const db = new Database(path);
113
- db.close();
114
- };
115
110
  var findMiniflareDatabase = (dbDir) => {
116
111
  const miniflareDir = join2(dbDir, MINIFLARE_D1_DIRECTORY);
117
112
  if (!existsSync(miniflareDir)) return null;
@@ -132,9 +127,6 @@ function getDevDbPath() {
132
127
  migrateInitialDbToTarget(initialDbPath, miniflareDbPath);
133
128
  return miniflareDbPath;
134
129
  }
135
- if (!existsSync(initialDbPath)) {
136
- createEmptyDatabase(initialDbPath);
137
- }
138
130
  return initialDbPath;
139
131
  }
140
132
 
package/dist/index.js CHANGED
@@ -4882,7 +4882,6 @@ init_core();
4882
4882
  init_constants2();
4883
4883
  import { copyFileSync, existsSync as existsSync6, mkdirSync, readdirSync as readdirSync3, unlinkSync } from "fs";
4884
4884
  import { join as join7 } from "path";
4885
- import Database from "better-sqlite3";
4886
4885
  var DB_DIRECTORY = CLI_DIRECTORIES.DATABASE;
4887
4886
  var INITIAL_DB_NAME = CLI_FILES.INITIAL_DATABASE;
4888
4887
  var ensureDirectoryExists = (dir) => {
@@ -4890,10 +4889,6 @@ var ensureDirectoryExists = (dir) => {
4890
4889
  mkdirSync(dir, { recursive: true });
4891
4890
  }
4892
4891
  };
4893
- var createEmptyDatabase = (path2) => {
4894
- const db = new Database(path2);
4895
- db.close();
4896
- };
4897
4892
  var findMiniflareDatabase = (dbDir) => {
4898
4893
  const miniflareDir = join7(dbDir, MINIFLARE_D1_DIRECTORY);
4899
4894
  if (!existsSync6(miniflareDir)) return null;
@@ -4914,9 +4909,6 @@ function getDevDbPath() {
4914
4909
  migrateInitialDbToTarget(initialDbPath, miniflareDbPath);
4915
4910
  return miniflareDbPath;
4916
4911
  }
4917
- if (!existsSync6(initialDbPath)) {
4918
- createEmptyDatabase(initialDbPath);
4919
- }
4920
4912
  return initialDbPath;
4921
4913
  }
4922
4914
 
@@ -5108,9 +5100,11 @@ async function setupPackageJson(workspace, gameName) {
5108
5100
  };
5109
5101
  const dbScripts = {
5110
5102
  "db:generate": "drizzle-kit generate",
5103
+ "db:migrate": "drizzle-kit migrate",
5111
5104
  "db:push": "drizzle-kit push",
5112
5105
  "db:studio": "drizzle-kit studio",
5113
- "db:seed": "playcademy db seed"
5106
+ "db:seed": "playcademy db seed",
5107
+ "db:reset": "playcademy db reset"
5114
5108
  };
5115
5109
  if (existsSync7(pkgPath)) {
5116
5110
  await runStep(
@@ -6693,6 +6687,36 @@ async function deployGameBackend(client, slug, config, projectPath, previousCust
6693
6687
  return null;
6694
6688
  }
6695
6689
  }
6690
+ async function deployBackendIfNeeded(game, context2) {
6691
+ const {
6692
+ client,
6693
+ config,
6694
+ projectPath,
6695
+ previousCustomRoutesHash,
6696
+ previousIntegrationKeys,
6697
+ deployBackend,
6698
+ fullConfig,
6699
+ forceBackend,
6700
+ debug
6701
+ } = context2;
6702
+ if (!deployBackend) {
6703
+ return null;
6704
+ }
6705
+ const backendDeployment = await deployGameBackend(
6706
+ client,
6707
+ game.slug,
6708
+ config,
6709
+ projectPath,
6710
+ previousCustomRoutesHash,
6711
+ fullConfig,
6712
+ forceBackend,
6713
+ previousIntegrationKeys,
6714
+ context2.deployedGameInfo?.schemaSnapshot,
6715
+ debug,
6716
+ context2.deployedGameInfo?.deployedSecrets
6717
+ );
6718
+ return backendDeployment;
6719
+ }
6696
6720
 
6697
6721
  // src/lib/deploy/config.ts
6698
6722
  init_file_loader();
@@ -7318,7 +7342,7 @@ function reportDeploymentSuccess(result, context2) {
7318
7342
  logger.success(`${game.displayName} ${action} successfully!`);
7319
7343
  logger.newLine();
7320
7344
  const baseUrl = getWebBaseUrl(client.getBaseUrl());
7321
- logger.data("Game URL", underline(`${baseUrl}/g/${game.slug}`), 1);
7345
+ logger.data("Game URL", underline(`${baseUrl}/play/${game.slug}`), 1);
7322
7346
  if (backendDeployment || previousCustomRoutesHash) {
7323
7347
  const env = getEnvironment();
7324
7348
  const subdomain = env === "staging" ? `${game.slug}-staging` : game.slug;
@@ -7872,6 +7896,59 @@ async function removeDeployedGame(projectPath) {
7872
7896
  delete store[projectPath];
7873
7897
  await saveGameStore(store);
7874
7898
  }
7899
+ async function saveDeploymentState(game, backendDeployment, context2) {
7900
+ const { projectPath, buildHash, buildSize, config, fullConfig } = context2;
7901
+ if (config.gameType === "external") {
7902
+ await saveDeployedGame(projectPath, {
7903
+ gameId: game.id,
7904
+ lastDeployedAt: (/* @__PURE__ */ new Date()).toISOString()
7905
+ });
7906
+ return;
7907
+ }
7908
+ const deploymentState = {
7909
+ gameId: game.id,
7910
+ lastDeployedAt: (/* @__PURE__ */ new Date()).toISOString(),
7911
+ buildPath: config.buildPath,
7912
+ buildHash,
7913
+ buildSize
7914
+ };
7915
+ if (backendDeployment) {
7916
+ deploymentState.integrationKeys = backendDeployment.integrationKeys;
7917
+ if (backendDeployment.integrationsHash) {
7918
+ deploymentState.integrationsHash = backendDeployment.integrationsHash;
7919
+ }
7920
+ } else if (fullConfig?.integrations) {
7921
+ deploymentState.integrationKeys = getIntegrationKeys(fullConfig.integrations);
7922
+ const hash = hashContent(fullConfig.integrations);
7923
+ if (hash) deploymentState.integrationsHash = hash;
7924
+ } else {
7925
+ deploymentState.integrationKeys = [];
7926
+ }
7927
+ if (backendDeployment) {
7928
+ deploymentState.customRoutesHash = backendDeployment.customRoutesHash ?? void 0;
7929
+ deploymentState.customRoutesSize = backendDeployment.customRoutesSize ?? void 0;
7930
+ deploymentState.backendSize = backendDeployment.backendSize;
7931
+ deploymentState.backendDeployedAt = backendDeployment.deployedAt;
7932
+ if (backendDeployment.schemaSnapshot !== void 0) {
7933
+ deploymentState.schemaSnapshot = backendDeployment.schemaSnapshot;
7934
+ }
7935
+ if (backendDeployment.deployedSecrets !== void 0) {
7936
+ deploymentState.deployedSecrets = backendDeployment.deployedSecrets;
7937
+ }
7938
+ } else if (context2.deployedGameInfo) {
7939
+ deploymentState.customRoutesHash = context2.deployedGameInfo.customRoutesHash;
7940
+ deploymentState.customRoutesSize = context2.deployedGameInfo.customRoutesSize;
7941
+ deploymentState.backendSize = context2.deployedGameInfo.backendSize;
7942
+ deploymentState.backendDeployedAt = context2.deployedGameInfo.backendDeployedAt;
7943
+ if (context2.deployedGameInfo.schemaSnapshot !== void 0) {
7944
+ deploymentState.schemaSnapshot = context2.deployedGameInfo.schemaSnapshot;
7945
+ }
7946
+ if (context2.deployedGameInfo.deployedSecrets !== void 0) {
7947
+ deploymentState.deployedSecrets = context2.deployedGameInfo.deployedSecrets;
7948
+ }
7949
+ }
7950
+ await saveDeployedGame(projectPath, deploymentState);
7951
+ }
7875
7952
 
7876
7953
  // src/lib/deploy/preparation.ts
7877
7954
  async function prepareDeploymentContext(options) {
@@ -8267,84 +8344,6 @@ async function handleIntegrationConfigChanges(game, context2) {
8267
8344
  }
8268
8345
  }
8269
8346
  }
8270
- async function deployBackendIfNeeded(game, context2) {
8271
- const {
8272
- client,
8273
- config,
8274
- projectPath,
8275
- previousCustomRoutesHash,
8276
- previousIntegrationKeys,
8277
- deployBackend,
8278
- fullConfig,
8279
- forceBackend,
8280
- debug
8281
- } = context2;
8282
- if (!deployBackend) {
8283
- return null;
8284
- }
8285
- const backendDeployment = await deployGameBackend(
8286
- client,
8287
- game.slug,
8288
- config,
8289
- projectPath,
8290
- previousCustomRoutesHash,
8291
- fullConfig,
8292
- forceBackend,
8293
- previousIntegrationKeys,
8294
- context2.deployedGameInfo?.schemaSnapshot,
8295
- debug,
8296
- context2.deployedGameInfo?.deployedSecrets
8297
- );
8298
- return backendDeployment;
8299
- }
8300
- async function saveDeploymentState(game, backendDeployment, context2) {
8301
- const { projectPath, buildHash, buildSize, config, fullConfig } = context2;
8302
- if (config.gameType === "external") {
8303
- await saveDeployedGame(projectPath, {
8304
- gameId: game.id,
8305
- lastDeployedAt: (/* @__PURE__ */ new Date()).toISOString()
8306
- });
8307
- } else {
8308
- let integrationKeys;
8309
- let integrationsHash;
8310
- if (backendDeployment) {
8311
- integrationKeys = backendDeployment.integrationKeys;
8312
- integrationsHash = backendDeployment.integrationsHash ?? void 0;
8313
- } else if (fullConfig?.integrations) {
8314
- integrationKeys = getIntegrationKeys(fullConfig.integrations);
8315
- integrationsHash = hashContent(fullConfig.integrations);
8316
- } else {
8317
- integrationKeys = [];
8318
- integrationsHash = void 0;
8319
- }
8320
- await saveDeployedGame(projectPath, {
8321
- gameId: game.id,
8322
- lastDeployedAt: (/* @__PURE__ */ new Date()).toISOString(),
8323
- buildPath: config.buildPath,
8324
- buildHash,
8325
- buildSize,
8326
- ...backendDeployment && {
8327
- customRoutesHash: backendDeployment.customRoutesHash ?? void 0,
8328
- customRoutesSize: backendDeployment.customRoutesSize ?? void 0,
8329
- backendSize: backendDeployment.backendSize,
8330
- backendDeployedAt: backendDeployment.deployedAt,
8331
- schemaSnapshot: backendDeployment.schemaSnapshot,
8332
- deployedSecrets: backendDeployment.deployedSecrets
8333
- },
8334
- ...!backendDeployment && context2.deployedGameInfo && {
8335
- customRoutesHash: context2.deployedGameInfo.customRoutesHash,
8336
- customRoutesSize: context2.deployedGameInfo.customRoutesSize,
8337
- backendSize: context2.deployedGameInfo.backendSize,
8338
- backendDeployedAt: context2.deployedGameInfo.backendDeployedAt,
8339
- schemaSnapshot: context2.deployedGameInfo.schemaSnapshot,
8340
- deployedSecrets: context2.deployedGameInfo.deployedSecrets
8341
- },
8342
- integrationKeys,
8343
- // Always save (even if empty array)
8344
- ...integrationsHash && { integrationsHash }
8345
- });
8346
- }
8347
- }
8348
8347
 
8349
8348
  // src/lib/dev/backend.ts
8350
8349
  init_constants2();
@@ -9650,7 +9649,6 @@ async function runDevServer(options) {
9650
9649
  const serverRef = { current: null };
9651
9650
  setupCleanupHandlers(workspace, () => serverRef.current);
9652
9651
  try {
9653
- logger.newLine();
9654
9652
  const config = await loadConfig();
9655
9653
  const hasIntegrations = !!config.integrations;
9656
9654
  const hasRoutes = hasCustomRoutes(config);
@@ -9972,7 +9970,6 @@ async function runDbResetLocal(options) {
9972
9970
  logger.newLine();
9973
9971
  return;
9974
9972
  }
9975
- logger.newLine();
9976
9973
  if (isServerRunning("backend", workspace)) {
9977
9974
  logger.admonition("warning", "Stop Dev Server First", [
9978
9975
  "The development server must be stopped before resetting the database.",
@@ -9981,15 +9978,18 @@ async function runDbResetLocal(options) {
9981
9978
  logger.newLine();
9982
9979
  process.exit(1);
9983
9980
  }
9984
- const shouldReset = await confirm6({
9985
- message: "This will delete all local database data. Continue?",
9986
- default: false
9987
- });
9988
- if (!shouldReset) {
9989
- logger.newLine();
9990
- logger.remark("Nothing to do");
9981
+ if (!options.force) {
9991
9982
  logger.newLine();
9992
- return;
9983
+ const shouldReset = await confirm6({
9984
+ message: "This will delete all local database data. Continue?",
9985
+ default: false
9986
+ });
9987
+ if (!shouldReset) {
9988
+ logger.newLine();
9989
+ logger.remark("Nothing to do");
9990
+ logger.newLine();
9991
+ return;
9992
+ }
9993
9993
  }
9994
9994
  if (!hasDatabaseSetup()) {
9995
9995
  logger.remark("No drizzle config found, skipping schema setup");
@@ -10195,8 +10195,13 @@ async function runDbSeed(options = {}) {
10195
10195
  // src/commands/db/index.ts
10196
10196
  var dbCommand = new Command14("db").description("Database management commands");
10197
10197
  dbCommand.command("init").description("Add database to your project").action(runDbInit);
10198
- dbCommand.command("reset").description("Reset database").option("--remote", "Reset remote deployed database").option("--env <environment>", "Environment: staging (default) or production").option("--debug", "Enable debug mode").action(
10199
- (options) => runDbReset({ debug: options.debug, remote: options.remote, env: options.env })
10198
+ dbCommand.command("reset").description("Reset database").option("--remote", "Reset remote deployed database").option("--env <environment>", "Environment: staging (default) or production").option("-f, --force", "Skip confirmation prompt (local only)").option("--debug", "Enable debug mode").action(
10199
+ (options) => runDbReset({
10200
+ debug: options.debug,
10201
+ remote: options.remote,
10202
+ env: options.env,
10203
+ force: options.force
10204
+ })
10200
10205
  );
10201
10206
  dbCommand.command("seed [file]").description("Seed database with initial data").option("--no-reset", "Skip database reset before seeding").option("--remote", "Seed remote deployed database").option("--debug", "Enable debug mode").option("--env <environment>", "Environment: staging (default) or production").action(
10202
10207
  (file, options) => runDbSeed({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playcademy",
3
- "version": "0.14.0",
3
+ "version": "0.14.2-alpha.1",
4
4
  "type": "module",
5
5
  "module": "./dist/index.js",
6
6
  "main": "./dist/index.js",
@@ -41,7 +41,6 @@
41
41
  "dependencies": {
42
42
  "@inquirer/prompts": "^7.8.6",
43
43
  "@playcademy/sdk": "0.1.12",
44
- "better-sqlite3": "^12.4.1",
45
44
  "chokidar": "^4.0.3",
46
45
  "colorette": "^2.0.20",
47
46
  "commander": "^14.0.1",
@@ -61,7 +60,6 @@
61
60
  "@playcademy/edge-play": "0.0.0",
62
61
  "@playcademy/timeback": "0.0.1",
63
62
  "@playcademy/utils": "0.0.1",
64
- "@types/better-sqlite3": "^7.6.13",
65
63
  "@types/bun": "latest",
66
64
  "bumpp": "^10.2.3",
67
65
  "rollup": "^4.50.2",