@codemation/cli 0.0.20 → 0.0.22

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.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as CliProgram, i as CliPathResolver, n as CliProgramFactory, o as ConsumerOutputBuilder, r as CodemationCliApplicationSession, s as ConsumerBuildOptionsParser, t as CliBin } from "./CliBin-BYHuUedo.js";
1
+ import { a as CliProgram, i as CliPathResolver, n as CliProgramFactory, o as ConsumerOutputBuilder, r as CodemationCliApplicationSession, s as ConsumerBuildOptionsParser, t as CliBin } from "./CliBin-PdQvm7od.js";
2
2
  import { CodemationPluginDiscovery } from "@codemation/host/server";
3
3
 
4
4
  export { CliBin, CliPathResolver, CliProgram, CliProgramFactory, CodemationCliApplicationSession, CodemationPluginDiscovery, ConsumerBuildOptionsParser, ConsumerOutputBuilder };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemation/cli",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -38,8 +38,8 @@
38
38
  "reflect-metadata": "^0.2.2",
39
39
  "typescript": "^5.9.3",
40
40
  "ws": "^8.19.0",
41
- "@codemation/host": "0.0.19",
42
- "@codemation/next-host": "0.0.20"
41
+ "@codemation/next-host": "0.1.0",
42
+ "@codemation/host": "0.1.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/http-proxy": "^1.17.15",
@@ -5,7 +5,7 @@ import {
5
5
  AppContainerLifecycle,
6
6
  type AppConfig,
7
7
  DatabaseMigrations,
8
- PrismaClient,
8
+ type PrismaClient,
9
9
  type CommandBus,
10
10
  type QueryBus,
11
11
  } from "@codemation/host";
@@ -34,10 +34,10 @@ export class CodemationCliApplicationSession {
34
34
 
35
35
  getPrismaClient(): PrismaClient | undefined {
36
36
  const container = this.getContainer();
37
- if (!container.isRegistered(PrismaClient, true)) {
37
+ if (!container.isRegistered(ApplicationTokens.PrismaClient, true)) {
38
38
  return undefined;
39
39
  }
40
- return container.resolve(PrismaClient);
40
+ return container.resolve(ApplicationTokens.PrismaClient);
41
41
  }
42
42
 
43
43
  getCommandBus(): CommandBus {
@@ -3,7 +3,7 @@ import type { AppPersistenceConfig } from "@codemation/host/persistence";
3
3
  import path from "node:path";
4
4
 
5
5
  /**
6
- * Resolves TCP PostgreSQL vs PGlite vs none from env + {@link CodemationConfig} (same rules as the host runtime).
6
+ * Resolves TCP PostgreSQL vs SQLite vs none from env + {@link CodemationConfig} (same rules as the host runtime).
7
7
  */
8
8
  export class ConsumerDatabaseConnectionResolver {
9
9
  resolve(processEnv: NodeJS.ProcessEnv, config: CodemationConfig, consumerRoot: string): AppPersistenceConfig {
@@ -20,18 +20,18 @@ export class ConsumerDatabaseConnectionResolver {
20
20
  return { kind: "postgresql", databaseUrl };
21
21
  }
22
22
  return {
23
- kind: "pglite",
24
- dataDir: this.resolvePgliteDataDir(database.pgliteDataDir, processEnv, consumerRoot),
23
+ kind: "sqlite",
24
+ databaseFilePath: this.resolveSqliteFilePath(database.sqliteFilePath, processEnv, consumerRoot),
25
25
  };
26
26
  }
27
27
 
28
28
  private resolveDatabaseKind(
29
- configuredKind: "postgresql" | "pglite" | undefined,
29
+ configuredKind: "postgresql" | "sqlite" | undefined,
30
30
  databaseUrl: string | undefined,
31
31
  env: NodeJS.ProcessEnv,
32
- ): "postgresql" | "pglite" {
32
+ ): "postgresql" | "sqlite" {
33
33
  const kindFromEnv = env.CODEMATION_DATABASE_KIND?.trim();
34
- if (kindFromEnv === "postgresql" || kindFromEnv === "pglite") {
34
+ if (kindFromEnv === "postgresql" || kindFromEnv === "sqlite") {
35
35
  return kindFromEnv;
36
36
  }
37
37
  if (configuredKind) {
@@ -41,15 +41,15 @@ export class ConsumerDatabaseConnectionResolver {
41
41
  if (trimmedUrl && (trimmedUrl.startsWith("postgresql://") || trimmedUrl.startsWith("postgres://"))) {
42
42
  return "postgresql";
43
43
  }
44
- return "pglite";
44
+ return "sqlite";
45
45
  }
46
46
 
47
- private resolvePgliteDataDir(
47
+ private resolveSqliteFilePath(
48
48
  configuredPath: string | undefined,
49
49
  env: NodeJS.ProcessEnv,
50
50
  consumerRoot: string,
51
51
  ): string {
52
- const envPath = env.CODEMATION_PGLITE_DATA_DIR?.trim();
52
+ const envPath = env.CODEMATION_SQLITE_FILE_PATH?.trim();
53
53
  if (envPath && envPath.length > 0) {
54
54
  return path.isAbsolute(envPath) ? envPath : path.resolve(consumerRoot, envPath);
55
55
  }
@@ -59,6 +59,6 @@ export class ConsumerDatabaseConnectionResolver {
59
59
  ? trimmedConfiguredPath
60
60
  : path.resolve(consumerRoot, trimmedConfiguredPath);
61
61
  }
62
- return path.resolve(consumerRoot, ".codemation", "pglite");
62
+ return path.resolve(consumerRoot, ".codemation", "codemation.sqlite");
63
63
  }
64
64
  }
@@ -60,7 +60,7 @@ export class DatabaseMigrationsApplyService {
60
60
  if (persistence.kind === "none") {
61
61
  if (requirePersistence) {
62
62
  throw new Error(
63
- "Database persistence is not configured. Set CodemationConfig.runtime.database (postgresql URL or PGlite).",
63
+ "Database persistence is not configured. Set CodemationConfig.runtime.database (postgresql URL or SQLite file path).",
64
64
  );
65
65
  }
66
66
  return;
@@ -12,7 +12,7 @@ export class HostPackageRootResolver {
12
12
  const entry = fileURLToPath(entryUrl);
13
13
  let dir = path.dirname(entry);
14
14
  for (let depth = 0; depth < 8; depth += 1) {
15
- if (existsSync(path.join(dir, "prisma", "schema.prisma"))) {
15
+ if (existsSync(path.join(dir, "prisma", "schema.postgresql.prisma"))) {
16
16
  return dir;
17
17
  }
18
18
  const parent = path.dirname(dir);
@@ -21,6 +21,6 @@ export class HostPackageRootResolver {
21
21
  }
22
22
  dir = parent;
23
23
  }
24
- throw new Error(`Could not locate prisma/schema.prisma near @codemation/host entry: ${entry}`);
24
+ throw new Error(`Could not locate prisma/schema.postgresql.prisma near @codemation/host entry: ${entry}`);
25
25
  }
26
26
  }
@@ -9,11 +9,12 @@ export interface PrismaMigrateDeployRunner {
9
9
  }
10
10
 
11
11
  /**
12
- * Runs `pnpm exec prisma migrate deploy` in the host package (where the Prisma schema lives).
12
+ * Runs `pnpm exec prisma migrate deploy --config prisma.config.ts` in the host package
13
+ * so the selected PostgreSQL or SQLite Prisma track is respected.
13
14
  */
14
15
  export class PrismaMigrateDeployInvoker implements PrismaMigrateDeployRunner {
15
16
  run(args: Readonly<{ hostPackageRoot: string; env: NodeJS.ProcessEnv }>): PrismaMigrateDeployResult {
16
- const result = spawnSync("pnpm", ["exec", "prisma", "migrate", "deploy"], {
17
+ const result = spawnSync("pnpm", ["exec", "prisma", "migrate", "deploy", "--config", "prisma.config.ts"], {
17
18
  cwd: args.hostPackageRoot,
18
19
  env: args.env,
19
20
  stdio: "inherit",
@@ -165,12 +165,9 @@ export class CliDevProxyServer {
165
165
  );
166
166
  return;
167
167
  }
168
- if (uiProxyTarget && pathname.startsWith("/api/auth/")) {
169
- this.proxy.web(req, res, {
170
- target: uiProxyTarget.replace(/\/$/, ""),
171
- });
172
- return;
173
- }
168
+ // Host-owned `/api/auth/*` is served by the disposable Hono runtime (same DB as other APIs).
169
+ // Do not route it to the Next UI — that used to cause gateway → Next → gateway loops when Next
170
+ // proxied auth back through CODEMATION_RUNTIME_DEV_URL.
174
171
  if (pathname.startsWith("/api/")) {
175
172
  const runtimeTarget = this.activeRuntime;
176
173
  if (pathname === "/api/dev/bootstrap-summary" && runtimeTarget) {
@@ -42,6 +42,7 @@ export class DevNextHostEnvironmentBuilder {
42
42
  HOSTNAME: "127.0.0.1",
43
43
  AUTH_SECRET: args.authSecret,
44
44
  AUTH_URL: args.publicBaseUrl,
45
+ CODEMATION_PUBLIC_BASE_URL: args.publicBaseUrl,
45
46
  CODEMATION_PUBLIC_WS_PORT: String(publicWebsocketPort),
46
47
  NEXT_PUBLIC_CODEMATION_WS_PORT: String(publicWebsocketPort),
47
48
  };
@@ -11,7 +11,7 @@ export class CliDatabaseUrlDescriptor {
11
11
  if (persistence.kind === "postgresql") {
12
12
  return this.describeForDisplay(persistence.databaseUrl);
13
13
  }
14
- return `PGlite (${persistence.dataDir})`;
14
+ return `SQLite (${persistence.databaseFilePath})`;
15
15
  }
16
16
 
17
17
  describeForDisplay(databaseUrl: string | undefined): string {
@@ -40,7 +40,7 @@ export class UserAdminCliBootstrap {
40
40
  }
41
41
  if (loadResult.appConfig.persistence.kind === "none") {
42
42
  throw new Error(
43
- "Database persistence is not configured. Set CodemationConfig.runtime.database (postgresql URL or PGlite).",
43
+ "Database persistence is not configured. Set CodemationConfig.runtime.database (postgresql URL or SQLite file path).",
44
44
  );
45
45
  }
46
46
  const session = await CodemationCliApplicationSession.open({