@codemation/cli 0.0.1
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 +148 -0
- package/bin/codemation.js +24 -0
- package/bin/codemation.ts +5 -0
- package/dist/CliBin-vjSSUDWE.js +2304 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +9 -0
- package/dist/index.d.ts +23456 -0
- package/dist/index.js +4 -0
- package/package.json +56 -0
- package/src/CliBin.ts +17 -0
- package/src/CliProgramFactory.ts +118 -0
- package/src/Program.ts +157 -0
- package/src/bin.ts +6 -0
- package/src/bootstrap/CodemationCliApplicationSession.ts +60 -0
- package/src/build/ConsumerBuildArtifactsPublisher.ts +77 -0
- package/src/build/ConsumerBuildOptionsParser.ts +26 -0
- package/src/commands/BuildCommand.ts +31 -0
- package/src/commands/DbMigrateCommand.ts +19 -0
- package/src/commands/DevCommand.ts +391 -0
- package/src/commands/ServeWebCommand.ts +72 -0
- package/src/commands/ServeWorkerCommand.ts +40 -0
- package/src/commands/UserCreateCommand.ts +25 -0
- package/src/commands/UserListCommand.ts +59 -0
- package/src/commands/devCommandLifecycle.types.ts +32 -0
- package/src/consumer/ConsumerCliTsconfigPreparation.ts +26 -0
- package/src/consumer/ConsumerEnvLoader.ts +47 -0
- package/src/consumer/ConsumerOutputBuilder.ts +898 -0
- package/src/consumer/Loader.ts +8 -0
- package/src/consumer/consumerBuildOptions.types.ts +12 -0
- package/src/database/ConsumerDatabaseConnectionResolver.ts +18 -0
- package/src/database/DatabaseMigrationsApplyService.ts +76 -0
- package/src/database/HostPackageRootResolver.ts +26 -0
- package/src/database/PrismaMigrateDeployInvoker.ts +24 -0
- package/src/dev/Builder.ts +45 -0
- package/src/dev/ConsumerEnvDotenvFilePredicate.ts +12 -0
- package/src/dev/DevAuthSettingsLoader.ts +27 -0
- package/src/dev/DevBootstrapSummaryFetcher.ts +15 -0
- package/src/dev/DevCliBannerRenderer.ts +106 -0
- package/src/dev/DevConsumerPublishBootstrap.ts +30 -0
- package/src/dev/DevHttpProbe.ts +54 -0
- package/src/dev/DevLock.ts +98 -0
- package/src/dev/DevNextHostEnvironmentBuilder.ts +49 -0
- package/src/dev/DevSessionPortsResolver.ts +23 -0
- package/src/dev/DevSessionServices.ts +29 -0
- package/src/dev/DevSourceRestartCoordinator.ts +48 -0
- package/src/dev/DevSourceWatcher.ts +102 -0
- package/src/dev/DevTrackedProcessTreeKiller.ts +107 -0
- package/src/dev/DevelopmentGatewayNotifier.ts +35 -0
- package/src/dev/Factory.ts +7 -0
- package/src/dev/LoopbackPortAllocator.ts +20 -0
- package/src/dev/Runner.ts +7 -0
- package/src/dev/RuntimeToolEntrypointResolver.ts +47 -0
- package/src/dev/WatchRootsResolver.ts +26 -0
- package/src/index.ts +12 -0
- package/src/path/CliPathResolver.ts +41 -0
- package/src/runtime/ListenPortResolver.ts +35 -0
- package/src/runtime/SourceMapNodeOptions.ts +12 -0
- package/src/runtime/TypeScriptRuntimeConfigurator.ts +8 -0
- package/src/user/CliDatabaseUrlDescriptor.ts +33 -0
- package/src/user/LocalUserCreator.ts +29 -0
- package/src/user/UserAdminCliBootstrap.ts +67 -0
- package/src/user/UserAdminCliOptionsParser.ts +24 -0
- package/src/user/UserAdminConsumerDotenvLoader.ts +24 -0
- package/tsconfig.json +10 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { parse } from "dotenv";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Loads the consumer project's dotenv files so `codemation dev` can forward them to the Next host.
|
|
7
|
+
* Next.js runs from `packages/next-host` and does not read `apps/<consumer>/.env` automatically.
|
|
8
|
+
*/
|
|
9
|
+
export class ConsumerEnvLoader {
|
|
10
|
+
load(consumerRoot: string): Readonly<Record<string, string>> {
|
|
11
|
+
const merged: Record<string, string> = {};
|
|
12
|
+
for (const relativeName of [".env", ".env.local"] as const) {
|
|
13
|
+
const absolutePath = path.resolve(consumerRoot, relativeName);
|
|
14
|
+
if (!existsSync(absolutePath)) {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
const parsed = parse(readFileSync(absolutePath, "utf8"));
|
|
18
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
19
|
+
if (value !== undefined) {
|
|
20
|
+
merged[key] = value;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return merged;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Merges consumer `.env` / `.env.local` values into a process environment snapshot.
|
|
29
|
+
* Consumer keys override the base snapshot for most variables. `DATABASE_URL` and `AUTH_SECRET`
|
|
30
|
+
* prefer the base (shell) when set, matching the dev Next host spawn behavior.
|
|
31
|
+
*/
|
|
32
|
+
mergeIntoProcessEnvironment(
|
|
33
|
+
processEnv: NodeJS.ProcessEnv,
|
|
34
|
+
consumerEnv: Readonly<Record<string, string>>,
|
|
35
|
+
): NodeJS.ProcessEnv {
|
|
36
|
+
return {
|
|
37
|
+
...processEnv,
|
|
38
|
+
...consumerEnv,
|
|
39
|
+
DATABASE_URL: processEnv.DATABASE_URL ?? consumerEnv.DATABASE_URL,
|
|
40
|
+
AUTH_SECRET: processEnv.AUTH_SECRET ?? consumerEnv.AUTH_SECRET,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
mergeConsumerRootIntoProcessEnvironment(consumerRoot: string, processEnv: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
|
|
45
|
+
return this.mergeIntoProcessEnvironment(processEnv, this.load(consumerRoot));
|
|
46
|
+
}
|
|
47
|
+
}
|