@codemation/cli 0.0.4 → 0.0.7
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/README.md +20 -26
- package/dist/{CliBin-900C8Din.js → CliBin-Bx1lFBi5.js} +1125 -340
- package/dist/bin.js +1 -1
- package/dist/index.d.ts +669 -197
- package/dist/index.js +1 -1
- package/package.json +9 -6
- package/src/CliProgramFactory.ts +23 -8
- package/src/Program.ts +7 -3
- package/src/bootstrap/CodemationCliApplicationSession.ts +17 -19
- package/src/commands/DevCommand.ts +302 -158
- package/src/commands/ServeWebCommand.ts +26 -1
- package/src/commands/ServeWorkerCommand.ts +46 -30
- package/src/commands/devCommandLifecycle.types.ts +7 -9
- package/src/database/ConsumerDatabaseConnectionResolver.ts +55 -9
- package/src/database/DatabaseMigrationsApplyService.ts +2 -2
- package/src/dev/Builder.ts +3 -14
- package/src/dev/CliDevProxyServer.ts +447 -0
- package/src/dev/CliDevProxyServerFactory.ts +7 -0
- package/src/dev/DevApiRuntimeFactory.ts +44 -0
- package/src/dev/DevApiRuntimeHost.ts +130 -0
- package/src/dev/DevApiRuntimeServer.ts +107 -0
- package/src/dev/DevApiRuntimeTypes.ts +24 -0
- package/src/dev/DevAuthSettingsLoader.ts +9 -3
- package/src/dev/DevBootstrapSummaryFetcher.ts +1 -1
- package/src/dev/DevHttpProbe.ts +8 -4
- package/src/dev/DevNextHostEnvironmentBuilder.ts +65 -3
- package/src/dev/DevRebuildQueue.ts +54 -0
- package/src/dev/DevRebuildQueueFactory.ts +7 -0
- package/src/dev/DevSessionPortsResolver.ts +2 -2
- package/src/dev/DevSessionServices.ts +2 -4
- package/src/dev/DevSourceChangeClassifier.ts +59 -0
- package/src/dev/WatchRootsResolver.ts +6 -4
- package/src/runtime/NextHostConsumerServerCommandFactory.ts +11 -2
- package/src/runtime/TypeScriptRuntimeConfigurator.ts +7 -0
- package/src/user/CliDatabaseUrlDescriptor.ts +2 -2
- package/src/user/UserAdminCliBootstrap.ts +9 -21
- package/codemation-cli-0.0.3.tgz +0 -0
- package/src/dev/DevSourceRestartCoordinator.ts +0 -48
- package/src/dev/DevelopmentGatewayNotifier.ts +0 -35
- package/src/dev/RuntimeToolEntrypointResolver.ts +0 -47
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { Logger } from "@codemation/host/next/server";
|
|
2
|
-
import process from "node:process";
|
|
3
|
-
|
|
4
|
-
import { DevelopmentGatewayNotifier } from "./DevelopmentGatewayNotifier";
|
|
5
|
-
|
|
6
|
-
export class DevSourceRestartCoordinator {
|
|
7
|
-
constructor(
|
|
8
|
-
private readonly gatewayNotifier: DevelopmentGatewayNotifier,
|
|
9
|
-
private readonly performanceDiagnosticsLogger: Logger,
|
|
10
|
-
private readonly cliLogger: Logger,
|
|
11
|
-
) {}
|
|
12
|
-
|
|
13
|
-
async runHandshakeAfterSourceChange(gatewayBaseUrl: string, developmentServerToken: string): Promise<void> {
|
|
14
|
-
const restartStarted = performance.now();
|
|
15
|
-
try {
|
|
16
|
-
await this.gatewayNotifier.notify({
|
|
17
|
-
gatewayBaseUrl,
|
|
18
|
-
developmentServerToken,
|
|
19
|
-
payload: {
|
|
20
|
-
kind: "buildStarted",
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
await this.gatewayNotifier.notify({
|
|
24
|
-
gatewayBaseUrl,
|
|
25
|
-
developmentServerToken,
|
|
26
|
-
payload: {
|
|
27
|
-
kind: "buildCompleted",
|
|
28
|
-
buildVersion: `${Date.now()}-${process.pid}`,
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
const totalMs = performance.now() - restartStarted;
|
|
32
|
-
this.performanceDiagnosticsLogger.info(
|
|
33
|
-
`triggered source-based runtime restart timingMs={total:${totalMs.toFixed(1)}}`,
|
|
34
|
-
);
|
|
35
|
-
} catch (error) {
|
|
36
|
-
const exception = error instanceof Error ? error : new Error(String(error));
|
|
37
|
-
await this.gatewayNotifier.notify({
|
|
38
|
-
gatewayBaseUrl,
|
|
39
|
-
developmentServerToken,
|
|
40
|
-
payload: {
|
|
41
|
-
kind: "buildFailed",
|
|
42
|
-
message: exception.message,
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
this.cliLogger.error("source-based runtime restart request failed", exception);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ApiPaths } from "@codemation/host";
|
|
2
|
-
import type { Logger } from "@codemation/host/next/server";
|
|
3
|
-
|
|
4
|
-
export class DevelopmentGatewayNotifier {
|
|
5
|
-
constructor(private readonly cliLogger: Logger) {}
|
|
6
|
-
|
|
7
|
-
async notify(
|
|
8
|
-
args: Readonly<{
|
|
9
|
-
gatewayBaseUrl: string;
|
|
10
|
-
developmentServerToken: string;
|
|
11
|
-
payload: Readonly<{
|
|
12
|
-
kind: "buildStarted" | "buildCompleted" | "buildFailed";
|
|
13
|
-
buildVersion?: string;
|
|
14
|
-
message?: string;
|
|
15
|
-
}>;
|
|
16
|
-
}>,
|
|
17
|
-
): Promise<void> {
|
|
18
|
-
const targetUrl = `${args.gatewayBaseUrl.replace(/\/$/, "")}${ApiPaths.devGatewayNotify()}`;
|
|
19
|
-
try {
|
|
20
|
-
const response = await fetch(targetUrl, {
|
|
21
|
-
method: "POST",
|
|
22
|
-
headers: {
|
|
23
|
-
"content-type": "application/json",
|
|
24
|
-
"x-codemation-dev-token": args.developmentServerToken,
|
|
25
|
-
},
|
|
26
|
-
body: JSON.stringify(args.payload),
|
|
27
|
-
});
|
|
28
|
-
if (!response.ok) {
|
|
29
|
-
this.cliLogger.warn(`failed to notify dev gateway status=${response.status}`);
|
|
30
|
-
}
|
|
31
|
-
} catch (error) {
|
|
32
|
-
this.cliLogger.warn(`failed to notify dev gateway: ${error instanceof Error ? error.message : String(error)}`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { access } from "node:fs/promises";
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import process from "node:process";
|
|
5
|
-
|
|
6
|
-
export type ResolvedRuntimeToolEntrypoint = Readonly<{
|
|
7
|
-
args: ReadonlyArray<string>;
|
|
8
|
-
command: string;
|
|
9
|
-
env: Readonly<Record<string, string>>;
|
|
10
|
-
}>;
|
|
11
|
-
|
|
12
|
-
export class RuntimeToolEntrypointResolver {
|
|
13
|
-
private readonly require = createRequire(import.meta.url);
|
|
14
|
-
|
|
15
|
-
async resolve(
|
|
16
|
-
args: Readonly<{
|
|
17
|
-
packageName: string;
|
|
18
|
-
repoRoot: string;
|
|
19
|
-
sourceEntrypoint: string;
|
|
20
|
-
}>,
|
|
21
|
-
): Promise<ResolvedRuntimeToolEntrypoint> {
|
|
22
|
-
const sourceEntrypointPath = path.resolve(args.repoRoot, args.sourceEntrypoint);
|
|
23
|
-
if (await this.exists(sourceEntrypointPath)) {
|
|
24
|
-
return {
|
|
25
|
-
command: process.execPath,
|
|
26
|
-
args: ["--import", "tsx", sourceEntrypointPath],
|
|
27
|
-
env: {
|
|
28
|
-
TSX_TSCONFIG_PATH: path.resolve(args.repoRoot, "tsconfig.codemation-tsx.json"),
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
command: process.execPath,
|
|
34
|
-
args: [this.require.resolve(args.packageName)],
|
|
35
|
-
env: {},
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
private async exists(filePath: string): Promise<boolean> {
|
|
40
|
-
try {
|
|
41
|
-
await access(filePath);
|
|
42
|
-
return true;
|
|
43
|
-
} catch {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|