@codemation/cli 0.0.5 → 0.0.11
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-C3ar49fj.js → CliBin-BAnFX1wL.js} +1105 -366
- package/dist/bin.js +1 -1
- package/dist/index.d.ts +655 -207
- package/dist/index.js +1 -1
- package/package.json +14 -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 +203 -171
- package/src/commands/ServeWebCommand.ts +26 -1
- package/src/commands/ServeWorkerCommand.ts +46 -30
- package/src/commands/devCommandLifecycle.types.ts +7 -11
- package/src/database/ConsumerDatabaseConnectionResolver.ts +55 -9
- package/src/database/DatabaseMigrationsApplyService.ts +2 -2
- package/src/dev/Builder.ts +1 -14
- package/src/dev/CliDevProxyServer.ts +457 -0
- package/src/dev/CliDevProxyServerFactory.ts +10 -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 +2 -2
- package/src/dev/DevNextHostEnvironmentBuilder.ts +35 -5
- 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 +0 -4
- package/src/dev/DevSourceChangeClassifier.ts +33 -13
- package/src/dev/ListenPortConflictDescriber.ts +83 -0
- package/src/dev/WatchRootsResolver.ts +6 -4
- package/src/runtime/NextHostConsumerServerCommandFactory.ts +11 -2
- 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
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-BAnFX1wL.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,11 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codemation/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"author": "Made Relevant B.V.",
|
|
8
8
|
"homepage": "https://www.maderelevant.com",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/MadeRelevant/codemation",
|
|
12
|
+
"directory": "packages/cli"
|
|
13
|
+
},
|
|
9
14
|
"type": "module",
|
|
10
15
|
"main": "./dist/index.js",
|
|
11
16
|
"types": "./dist/index.d.ts",
|
|
@@ -19,6 +24,7 @@
|
|
|
19
24
|
}
|
|
20
25
|
},
|
|
21
26
|
"dependencies": {
|
|
27
|
+
"@hono/node-server": "^1.19.9",
|
|
22
28
|
"bcryptjs": "^3.0.3",
|
|
23
29
|
"boxen": "^8.0.1",
|
|
24
30
|
"chalk": "^5.6.2",
|
|
@@ -26,16 +32,18 @@
|
|
|
26
32
|
"commander": "^14.0.3",
|
|
27
33
|
"dotenv": "^17.3.1",
|
|
28
34
|
"figlet": "^1.11.0",
|
|
35
|
+
"hono": "^4.12.8",
|
|
36
|
+
"http-proxy": "^1.18.1",
|
|
29
37
|
"reflect-metadata": "^0.2.2",
|
|
30
38
|
"typescript": "^5.9.3",
|
|
31
|
-
"
|
|
32
|
-
"@codemation/host": "0.0.
|
|
33
|
-
"@codemation/next-host": "0.0.
|
|
34
|
-
"@codemation/runtime-dev": "0.0.5",
|
|
35
|
-
"@codemation/worker-cli": "0.0.5"
|
|
39
|
+
"ws": "^8.19.0",
|
|
40
|
+
"@codemation/host": "0.0.11",
|
|
41
|
+
"@codemation/next-host": "0.0.11"
|
|
36
42
|
},
|
|
37
43
|
"devDependencies": {
|
|
44
|
+
"@types/http-proxy": "^1.17.15",
|
|
38
45
|
"@types/node": "^25.3.5",
|
|
46
|
+
"@types/ws": "^8.18.1",
|
|
39
47
|
"eslint": "^10.0.3",
|
|
40
48
|
"tsdown": "^0.15.5",
|
|
41
49
|
"tsx": "^4.21.0",
|
package/src/CliProgramFactory.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
AppConfigLoader,
|
|
3
|
+
CodemationConsumerConfigLoader,
|
|
4
|
+
CodemationFrontendAuthSnapshotFactory,
|
|
5
|
+
CodemationPluginDiscovery,
|
|
6
|
+
FrontendAppConfigJsonCodec,
|
|
7
|
+
} from "@codemation/host/server";
|
|
8
|
+
import { AppContainerFactory } from "@codemation/host";
|
|
2
9
|
import { logLevelPolicyFactory, ServerLoggerFactory } from "@codemation/host/next/server";
|
|
3
10
|
|
|
4
11
|
import { ConsumerBuildArtifactsPublisher } from "./build/ConsumerBuildArtifactsPublisher";
|
|
@@ -16,10 +23,13 @@ import { ConsumerOutputBuilderLoader } from "./consumer/Loader";
|
|
|
16
23
|
import { ConsumerDatabaseConnectionResolver } from "./database/ConsumerDatabaseConnectionResolver";
|
|
17
24
|
import { DatabaseMigrationsApplyService } from "./database/DatabaseMigrationsApplyService";
|
|
18
25
|
import { HostPackageRootResolver } from "./database/HostPackageRootResolver";
|
|
19
|
-
import {
|
|
26
|
+
import { PrismaMigrationDeployer } from "@codemation/host/persistence";
|
|
20
27
|
import { DevBootstrapSummaryFetcher } from "./dev/DevBootstrapSummaryFetcher";
|
|
21
28
|
import { DevCliBannerRenderer } from "./dev/DevCliBannerRenderer";
|
|
22
29
|
import { DevConsumerPublishBootstrap } from "./dev/DevConsumerPublishBootstrap";
|
|
30
|
+
import { CliDevProxyServerFactory } from "./dev/CliDevProxyServerFactory";
|
|
31
|
+
import { DevApiRuntimeFactory } from "./dev/DevApiRuntimeFactory";
|
|
32
|
+
import { DevRebuildQueueFactory } from "./dev/DevRebuildQueueFactory";
|
|
23
33
|
import { DevSessionServicesBuilder } from "./dev/Builder";
|
|
24
34
|
import { DevLockFactory } from "./dev/Factory";
|
|
25
35
|
import { ConsumerEnvDotenvFilePredicate } from "./dev/ConsumerEnvDotenvFilePredicate";
|
|
@@ -46,6 +56,7 @@ const loggerFactory = new ServerLoggerFactory(logLevelPolicyFactory);
|
|
|
46
56
|
export class CliProgramFactory {
|
|
47
57
|
create(): CliProgram {
|
|
48
58
|
const cliLogger = loggerFactory.create("codemation-cli");
|
|
59
|
+
const appConfigLoader = new AppConfigLoader();
|
|
49
60
|
const pathResolver = new CliPathResolver();
|
|
50
61
|
const pluginDiscovery = new CodemationPluginDiscovery();
|
|
51
62
|
const artifactsPublisher = new ConsumerBuildArtifactsPublisher();
|
|
@@ -53,14 +64,13 @@ export class CliProgramFactory {
|
|
|
53
64
|
const outputBuilderLoader = new ConsumerOutputBuilderLoader();
|
|
54
65
|
const sourceMapNodeOptions = new SourceMapNodeOptions();
|
|
55
66
|
const nextHostConsumerServerCommandFactory = new NextHostConsumerServerCommandFactory();
|
|
67
|
+
const devSessionServices = new DevSessionServicesBuilder().build();
|
|
56
68
|
const tsconfigPreparation = new ConsumerCliTsconfigPreparation();
|
|
57
|
-
const databasePersistenceResolver = new DatabasePersistenceResolver();
|
|
58
69
|
const userAdminBootstrap = new UserAdminCliBootstrap(
|
|
59
|
-
|
|
70
|
+
appConfigLoader,
|
|
60
71
|
pathResolver,
|
|
61
72
|
new UserAdminConsumerDotenvLoader(),
|
|
62
73
|
tsconfigPreparation,
|
|
63
|
-
databasePersistenceResolver,
|
|
64
74
|
);
|
|
65
75
|
const hostPackageRoot = new HostPackageRootResolver().resolveHostPackageRoot();
|
|
66
76
|
const userAdminCliOptionsParser = new UserAdminCliOptionsParser();
|
|
@@ -88,12 +98,11 @@ export class CliProgramFactory {
|
|
|
88
98
|
new BuildCommand(cliLogger, pathResolver, pluginDiscovery, artifactsPublisher, tsRuntime, outputBuilderLoader),
|
|
89
99
|
new DevCommand(
|
|
90
100
|
pathResolver,
|
|
91
|
-
pluginDiscovery,
|
|
92
101
|
tsRuntime,
|
|
93
102
|
new DevLockFactory(),
|
|
94
103
|
new DevSourceWatcherFactory(),
|
|
95
104
|
cliLogger,
|
|
96
|
-
|
|
105
|
+
devSessionServices,
|
|
97
106
|
databaseMigrationsApplyService,
|
|
98
107
|
new DevBootstrapSummaryFetcher(),
|
|
99
108
|
new DevCliBannerRenderer(),
|
|
@@ -101,9 +110,13 @@ export class CliProgramFactory {
|
|
|
101
110
|
new ConsumerEnvDotenvFilePredicate(),
|
|
102
111
|
new DevTrackedProcessTreeKiller(),
|
|
103
112
|
nextHostConsumerServerCommandFactory,
|
|
113
|
+
new DevApiRuntimeFactory(devSessionServices.loopbackPortAllocator, appConfigLoader, pluginDiscovery),
|
|
114
|
+
new CliDevProxyServerFactory(),
|
|
115
|
+
new DevRebuildQueueFactory(),
|
|
104
116
|
),
|
|
105
117
|
new ServeWebCommand(
|
|
106
118
|
pathResolver,
|
|
119
|
+
new CodemationConsumerConfigLoader(),
|
|
107
120
|
pluginDiscovery,
|
|
108
121
|
artifactsPublisher,
|
|
109
122
|
tsRuntime,
|
|
@@ -112,8 +125,10 @@ export class CliProgramFactory {
|
|
|
112
125
|
new ConsumerEnvLoader(),
|
|
113
126
|
new ListenPortResolver(),
|
|
114
127
|
nextHostConsumerServerCommandFactory,
|
|
128
|
+
new CodemationFrontendAuthSnapshotFactory(),
|
|
129
|
+
new FrontendAppConfigJsonCodec(),
|
|
115
130
|
),
|
|
116
|
-
new ServeWorkerCommand(
|
|
131
|
+
new ServeWorkerCommand(pathResolver, appConfigLoader, new AppContainerFactory()),
|
|
117
132
|
new DbMigrateCommand(databaseMigrationsApplyService),
|
|
118
133
|
new UserCreateCommand(new LocalUserCreator(userAdminBootstrap), userAdminCliOptionsParser),
|
|
119
134
|
new UserListCommand(cliLogger, userAdminBootstrap, new CliDatabaseUrlDescriptor(), userAdminCliOptionsParser),
|
package/src/Program.ts
CHANGED
|
@@ -57,11 +57,15 @@ export class CliProgram {
|
|
|
57
57
|
program
|
|
58
58
|
.command("dev", { isDefault: true })
|
|
59
59
|
.description(
|
|
60
|
-
"Start the dev
|
|
60
|
+
"Start the stable dev endpoint and disposable API runtime. Uses the packaged Codemation UI by default.",
|
|
61
61
|
)
|
|
62
62
|
.option("--consumer-root <path>", "Path to the consumer project root (defaults to cwd)")
|
|
63
|
-
.
|
|
64
|
-
|
|
63
|
+
.option("--watch-framework", "Use Next dev HMR for framework UI work inside this repository.")
|
|
64
|
+
.action(async (opts: Readonly<{ consumerRoot?: string; watchFramework?: boolean }>) => {
|
|
65
|
+
await this.devCommand.execute({
|
|
66
|
+
consumerRoot: resolveConsumerRoot(opts.consumerRoot),
|
|
67
|
+
watchFramework: opts.watchFramework === true,
|
|
68
|
+
});
|
|
65
69
|
});
|
|
66
70
|
|
|
67
71
|
const serve = program.command("serve").description("Run production web or worker processes (no dev watchers).");
|
|
@@ -1,37 +1,35 @@
|
|
|
1
1
|
import { type Container } from "@codemation/core";
|
|
2
2
|
import {
|
|
3
3
|
ApplicationTokens,
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
AppContainerFactory,
|
|
5
|
+
AppContainerLifecycle,
|
|
6
|
+
type AppConfig,
|
|
7
|
+
DatabaseMigrations,
|
|
6
8
|
PrismaClient,
|
|
7
9
|
type CommandBus,
|
|
8
10
|
type QueryBus,
|
|
9
11
|
} from "@codemation/host";
|
|
10
|
-
import type { CodemationConsumerConfigResolution } from "@codemation/host/server";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
|
-
* Opens
|
|
14
|
+
* Opens an app container with persistence + command/query buses (no HTTP/WebSocket servers),
|
|
14
15
|
* for CLI tools that dispatch application commands or queries (e.g. user admin).
|
|
15
16
|
*/
|
|
16
17
|
export class CodemationCliApplicationSession {
|
|
17
|
-
private constructor(private readonly
|
|
18
|
+
private constructor(private readonly container: Container) {}
|
|
18
19
|
|
|
19
20
|
static async open(
|
|
20
21
|
args: Readonly<{
|
|
21
|
-
|
|
22
|
-
bootstrap: CodemationBootstrapRequest;
|
|
22
|
+
appConfig: AppConfig;
|
|
23
23
|
}>,
|
|
24
24
|
): Promise<CodemationCliApplicationSession> {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
);
|
|
34
|
-
return new CodemationCliApplicationSession(app);
|
|
25
|
+
const container = await new AppContainerFactory().create({
|
|
26
|
+
appConfig: args.appConfig,
|
|
27
|
+
sharedWorkflowWebsocketServer: null,
|
|
28
|
+
});
|
|
29
|
+
if (args.appConfig.env.CODEMATION_SKIP_STARTUP_MIGRATIONS !== "true") {
|
|
30
|
+
await container.resolve(DatabaseMigrations).migrate();
|
|
31
|
+
}
|
|
32
|
+
return new CodemationCliApplicationSession(container);
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
getPrismaClient(): PrismaClient | undefined {
|
|
@@ -51,10 +49,10 @@ export class CodemationCliApplicationSession {
|
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
async close(): Promise<void> {
|
|
54
|
-
await this.
|
|
52
|
+
await this.container.resolve(AppContainerLifecycle).stop({ stopWebsocketServer: false });
|
|
55
53
|
}
|
|
56
54
|
|
|
57
55
|
private getContainer(): Container {
|
|
58
|
-
return this.
|
|
56
|
+
return this.container;
|
|
59
57
|
}
|
|
60
58
|
}
|