playcademy 0.16.7 → 0.16.8

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.16.6",
2968
+ version: "0.16.7",
2969
2969
  type: "module",
2970
2970
  exports: {
2971
2971
  ".": {
package/dist/index.js CHANGED
@@ -3996,7 +3996,7 @@ import { join as join12 } from "path";
3996
3996
  // package.json with { type: 'json' }
3997
3997
  var package_default2 = {
3998
3998
  name: "playcademy",
3999
- version: "0.16.6",
3999
+ version: "0.16.7",
4000
4000
  type: "module",
4001
4001
  exports: {
4002
4002
  ".": {
@@ -4841,9 +4841,10 @@ async function saveDeploymentState(game, backendMetadata, context2) {
4841
4841
  deploymentState.backendDeployedAt = backendMetadata.deployedAt;
4842
4842
  if (backendMetadata.schemaSnapshot !== void 0) {
4843
4843
  deploymentState.schemaSnapshot = backendMetadata.schemaSnapshot;
4844
- }
4845
- if (backendMetadata.lastAppliedMigrationTag !== void 0) {
4844
+ deploymentState.lastAppliedMigrationTag = void 0;
4845
+ } else if (backendMetadata.lastAppliedMigrationTag !== void 0) {
4846
4846
  deploymentState.lastAppliedMigrationTag = backendMetadata.lastAppliedMigrationTag;
4847
+ deploymentState.schemaSnapshot = void 0;
4847
4848
  }
4848
4849
  } else if (context2.deployedGameInfo) {
4849
4850
  deploymentState.backendBundleHash = context2.deployedGameInfo.backendBundleHash;
@@ -7412,11 +7413,8 @@ import { join as join30 } from "path";
7412
7413
  import { existsSync as existsSync21 } from "fs";
7413
7414
  import { readFile as readFile4 } from "fs/promises";
7414
7415
  import { join as join29 } from "path";
7415
- var DB_RELATIVE_CANDIDATES = ["migrations", join29("..", "migrations"), "drizzle"];
7416
- var ROOT_RELATIVE_CANDIDATES = [join29("db", "migrations"), "drizzle"];
7417
- var META_DIR = "meta";
7418
- var JOURNAL_FILE = "_journal.json";
7419
- var STATEMENT_BREAKPOINT_RE = /--> statement-breakpoint/g;
7416
+
7417
+ // src/lib/deploy/utils.ts
7420
7418
  async function getDatabaseDirectory() {
7421
7419
  try {
7422
7420
  const config = await loadConfig();
@@ -7429,6 +7427,17 @@ async function getDatabaseDirectory() {
7429
7427
  return DEFAULT_DATABASE_DIRECTORY;
7430
7428
  }
7431
7429
  }
7430
+ function getDeploymentId(gameSlug) {
7431
+ const environment = getEnvironment();
7432
+ return environment === "production" ? gameSlug : `${WORKER_NAMING.STAGING_PREFIX}${gameSlug}`;
7433
+ }
7434
+
7435
+ // src/lib/deploy/migrations.ts
7436
+ var DB_RELATIVE_CANDIDATES = ["migrations", join29("..", "migrations"), "drizzle"];
7437
+ var ROOT_RELATIVE_CANDIDATES = [join29("db", "migrations"), "drizzle"];
7438
+ var META_DIR = "meta";
7439
+ var JOURNAL_FILE = "_journal.json";
7440
+ var STATEMENT_BREAKPOINT_RE = /--> statement-breakpoint/g;
7432
7441
  async function getMigrationsDirectory() {
7433
7442
  const workspace = getWorkspace();
7434
7443
  const dbDirectory = await getDatabaseDirectory();
@@ -7492,7 +7501,10 @@ async function getUnappliedMigrations(lastAppliedTag) {
7492
7501
  return null;
7493
7502
  }
7494
7503
  const journal = await readMigrationJournal();
7495
- if (!journal || journal.entries.length === 0) {
7504
+ if (!journal) {
7505
+ throw new Error("Failed to read migration journal. Check that _journal.json is valid JSON.");
7506
+ }
7507
+ if (journal.entries.length === 0) {
7496
7508
  return [];
7497
7509
  }
7498
7510
  const sorted = [...journal.entries].sort((a, b) => a.idx - b.idx);
@@ -7517,8 +7529,10 @@ async function getUnappliedMigrations(lastAppliedTag) {
7517
7529
  for (const entry of unapplied) {
7518
7530
  const sqlPath = join29(migrationsDir, `${entry.tag}.sql`);
7519
7531
  if (!existsSync21(sqlPath)) {
7520
- logger.warn(`Migration file not found: ${sqlPath}`);
7521
- return null;
7532
+ throw new Error(
7533
+ `Migration file not found: ${sqlPath}
7534
+ The journal references migration "${entry.tag}" but the .sql file is missing.`
7535
+ );
7522
7536
  }
7523
7537
  const raw = await readFile4(sqlPath, "utf-8");
7524
7538
  const sql2 = raw.replace(STATEMENT_BREAKPOINT_RE, "").trim();
@@ -7549,18 +7563,6 @@ async function buildMigrationSchemaInfo(lastAppliedTag) {
7549
7563
  }
7550
7564
 
7551
7565
  // src/lib/deploy/schema.ts
7552
- async function getDatabaseDirectory2() {
7553
- try {
7554
- const config = await loadConfig();
7555
- const dbIntegration = config.integrations?.database;
7556
- if (!dbIntegration || dbIntegration === true) {
7557
- return DEFAULT_DATABASE_DIRECTORY;
7558
- }
7559
- return dbIntegration.directory ?? DEFAULT_DATABASE_DIRECTORY;
7560
- } catch {
7561
- return DEFAULT_DATABASE_DIRECTORY;
7562
- }
7563
- }
7564
7566
  function getDrizzleKitApiExports() {
7565
7567
  const require2 = createRequire(import.meta.url);
7566
7568
  const drizzleKitApi = require2("drizzle-kit/api");
@@ -7572,7 +7574,7 @@ function getDrizzleKitApiExports() {
7572
7574
  }
7573
7575
  async function getPushSchemaInfo(previousSchemaSnapshot) {
7574
7576
  const workspace = getWorkspace();
7575
- const dbDirectory = await getDatabaseDirectory2();
7577
+ const dbDirectory = await getDatabaseDirectory();
7576
7578
  const schemaPath = join30(workspace, dbDirectory, SCHEMA_SUBDIRECTORY, DB_FILES.SCHEMA_INDEX);
7577
7579
  if (!existsSync22(schemaPath)) {
7578
7580
  return null;
@@ -7598,20 +7600,22 @@ async function getPushSchemaInfo(previousSchemaSnapshot) {
7598
7600
  return null;
7599
7601
  }
7600
7602
  }
7601
- function extractLastAppliedTag(previousSchemaSnapshot) {
7602
- if (typeof previousSchemaSnapshot === "string") {
7603
- return previousSchemaSnapshot;
7604
- }
7605
- return void 0;
7606
- }
7607
7603
  async function getSchemaInfo(previousSchemaSnapshot, lastAppliedMigrationTag) {
7608
7604
  if (!hasDatabaseSetup()) {
7609
7605
  return null;
7610
7606
  }
7611
7607
  const strategy = await resolveSchemaStrategy();
7612
7608
  if (strategy === "migrate") {
7613
- const tag = lastAppliedMigrationTag ?? extractLastAppliedTag(previousSchemaSnapshot);
7614
- return buildMigrationSchemaInfo(tag);
7609
+ if (previousSchemaSnapshot && !lastAppliedMigrationTag) {
7610
+ logger.error(
7611
+ "Your project was previously deployed with push-mode but migration files were detected."
7612
+ );
7613
+ logger.remark(
7614
+ "Run `playcademy db migrate-from-push` to mark the baseline migration as applied before deploying."
7615
+ );
7616
+ return null;
7617
+ }
7618
+ return buildMigrationSchemaInfo(lastAppliedMigrationTag);
7615
7619
  }
7616
7620
  return getPushSchemaInfo(previousSchemaSnapshot);
7617
7621
  }
@@ -7619,10 +7623,13 @@ async function hasSchemaChanged(previousSchemaSnapshot, lastAppliedMigrationTag)
7619
7623
  const schemaInfo = await getSchemaInfo(previousSchemaSnapshot, lastAppliedMigrationTag);
7620
7624
  return schemaInfo !== null;
7621
7625
  }
7626
+ function countSqlStatements(sql2) {
7627
+ return sql2.split(";").filter((stmt) => stmt.trim()).length;
7628
+ }
7622
7629
  async function getSchemaStatementCount(previousSchemaSnapshot, lastAppliedMigrationTag) {
7623
7630
  const schemaInfo = await getSchemaInfo(previousSchemaSnapshot, lastAppliedMigrationTag);
7624
7631
  if (!schemaInfo) return 0;
7625
- return schemaInfo.sql.split(";").filter((stmt) => stmt.trim()).length;
7632
+ return countSqlStatements(schemaInfo.sql);
7626
7633
  }
7627
7634
 
7628
7635
  // src/lib/deploy/validate.ts
@@ -8792,12 +8799,6 @@ async function bundleStubWorker() {
8792
8799
  return result.outputFiles[0].text;
8793
8800
  }
8794
8801
 
8795
- // src/lib/deploy/utils.ts
8796
- function getDeploymentId(gameSlug) {
8797
- const environment = getEnvironment();
8798
- return environment === "production" ? gameSlug : `${WORKER_NAMING.STAGING_PREFIX}${gameSlug}`;
8799
- }
8800
-
8801
8802
  // src/lib/deploy/steps.ts
8802
8803
  function prepareGameMetadata(config) {
8803
8804
  return {
@@ -11183,7 +11184,7 @@ var getStatusCommand = new Command13("status").description("Check your developer
11183
11184
  });
11184
11185
 
11185
11186
  // package.json
11186
- var version2 = "0.16.6";
11187
+ var version2 = "0.16.7";
11187
11188
 
11188
11189
  // src/commands/dev/server.ts
11189
11190
  function setupCleanupHandlers(workspace, getServer) {
@@ -11602,7 +11603,7 @@ async function runDbDiff() {
11602
11603
  logger.bold(line, 1);
11603
11604
  });
11604
11605
  logger.newLine();
11605
- const statementCount = await getSchemaStatementCount(previousSnapshot, lastMigrationTag);
11606
+ const statementCount = countSqlStatements(schemaInfo.sql);
11606
11607
  logger.data("SQL Statements", String(statementCount), 1);
11607
11608
  logger.newLine();
11608
11609
  } catch (error) {
@@ -12006,15 +12007,17 @@ async function runDbSchema(options = {}) {
12006
12007
  logger.bold(line, 1);
12007
12008
  });
12008
12009
  logger.newLine();
12009
- const statementCount = await getSchemaStatementCount();
12010
+ const statementCount = countSqlStatements(schemaInfo.sql);
12010
12011
  logger.data("SQL Statements", String(statementCount), 1);
12011
12012
  if (options.full) {
12012
- logger.highlight("Schema Hash");
12013
- logger.newLine();
12014
12013
  if (strategy === "migrate" && schemaInfo.migrationTag) {
12015
- logger.data("Migration Tag", schemaInfo.migrationTag, 1);
12014
+ logger.highlight("Migration Tag", 1);
12015
+ logger.newLine();
12016
+ logger.data("Tag", schemaInfo.migrationTag, 2);
12016
12017
  } else {
12017
- logger.json(JSON.parse(schemaInfo.hash), 1);
12018
+ logger.highlight("Schema Hash", 1);
12019
+ logger.newLine();
12020
+ logger.json(JSON.parse(schemaInfo.hash), 2);
12018
12021
  }
12019
12022
  }
12020
12023
  logger.newLine();
@@ -15594,6 +15597,7 @@ export {
15594
15597
  computeSecretsHashes,
15595
15598
  confirmDeploymentPlan,
15596
15599
  connectToLogStream,
15600
+ countSqlStatements,
15597
15601
  createClient,
15598
15602
  createProjectDirectory,
15599
15603
  createSeedWorkerEntry,
@@ -15650,6 +15654,7 @@ export {
15650
15654
  getContentType,
15651
15655
  getCurrentProfile,
15652
15656
  getCustomRoutesDirectory,
15657
+ getDatabaseDirectory,
15653
15658
  getDeployedGame,
15654
15659
  getDeploymentId,
15655
15660
  getDirectorySize,
package/dist/utils.js CHANGED
@@ -2358,7 +2358,7 @@ import { join as join12 } from "path";
2358
2358
  // package.json with { type: 'json' }
2359
2359
  var package_default2 = {
2360
2360
  name: "playcademy",
2361
- version: "0.16.6",
2361
+ version: "0.16.7",
2362
2362
  type: "module",
2363
2363
  exports: {
2364
2364
  ".": {
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.16.6",
4
+ version: "0.16.7",
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.7",
3
+ "version": "0.16.8",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {