@codemation/cli 0.0.21 → 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/CHANGELOG.md +18 -0
- package/dist/{CliBin-BYHuUedo.js → CliBin-PdQvm7od.js} +17 -20
- package/dist/bin.js +1 -1
- package/dist/index.d.ts +1042 -535
- package/dist/index.js +1 -1
- package/package.json +3 -3
- package/src/bootstrap/CodemationCliApplicationSession.ts +3 -3
- package/src/database/ConsumerDatabaseConnectionResolver.ts +10 -10
- package/src/database/DatabaseMigrationsApplyService.ts +1 -1
- package/src/database/HostPackageRootResolver.ts +2 -2
- package/src/database/PrismaMigrateDeployInvoker.ts +3 -2
- package/src/dev/CliDevProxyServer.ts +3 -6
- package/src/dev/DevNextHostEnvironmentBuilder.ts +1 -0
- package/src/user/CliDatabaseUrlDescriptor.ts +1 -1
- package/src/user/UserAdminCliBootstrap.ts +1 -1
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-
|
|
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.
|
|
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
|
|
42
|
-
"@codemation/
|
|
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
|
|
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: "
|
|
24
|
-
|
|
23
|
+
kind: "sqlite",
|
|
24
|
+
databaseFilePath: this.resolveSqliteFilePath(database.sqliteFilePath, processEnv, consumerRoot),
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
private resolveDatabaseKind(
|
|
29
|
-
configuredKind: "postgresql" | "
|
|
29
|
+
configuredKind: "postgresql" | "sqlite" | undefined,
|
|
30
30
|
databaseUrl: string | undefined,
|
|
31
31
|
env: NodeJS.ProcessEnv,
|
|
32
|
-
): "postgresql" | "
|
|
32
|
+
): "postgresql" | "sqlite" {
|
|
33
33
|
const kindFromEnv = env.CODEMATION_DATABASE_KIND?.trim();
|
|
34
|
-
if (kindFromEnv === "postgresql" || kindFromEnv === "
|
|
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 "
|
|
44
|
+
return "sqlite";
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
private
|
|
47
|
+
private resolveSqliteFilePath(
|
|
48
48
|
configuredPath: string | undefined,
|
|
49
49
|
env: NodeJS.ProcessEnv,
|
|
50
50
|
consumerRoot: string,
|
|
51
51
|
): string {
|
|
52
|
-
const envPath = env.
|
|
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", "
|
|
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
|
|
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
|
|
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
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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 `
|
|
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
|
|
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({
|