Skip to content

Commit af3a14f

Browse files
committed
style: improve code formatting and readability in project.commands.ts, form.ts, and various generator files
1 parent da69da5 commit af3a14f

File tree

6 files changed

+60
-35
lines changed

6 files changed

+60
-35
lines changed

src/commands/project.commands.ts

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -445,41 +445,67 @@ async function runContainerDev(options: ContainerDevOptions): Promise<void> {
445445

446446
// Step 1.5: Check bootstrap config and create missing env files if needed
447447
try {
448-
const { analyzeBootstrapConfig, shouldCopyEnvFiles, getEnvFileForEnvironment } =
449-
await import("../containerize/analyzers/bootstrap-analyzer");
448+
const {
449+
analyzeBootstrapConfig,
450+
shouldCopyEnvFiles,
451+
getEnvFileForEnvironment,
452+
} = await import("../containerize/analyzers/bootstrap-analyzer");
450453
const bootstrapConfig = await analyzeBootstrapConfig();
451454

452-
if (bootstrapConfig.hasEnvFileConfig && shouldCopyEnvFiles(bootstrapConfig)) {
453-
const devEnvFile = getEnvFileForEnvironment(bootstrapConfig, "development");
455+
if (
456+
bootstrapConfig.hasEnvFileConfig &&
457+
shouldCopyEnvFiles(bootstrapConfig)
458+
) {
459+
const devEnvFile = getEnvFileForEnvironment(
460+
bootstrapConfig,
461+
"development",
462+
);
454463

455464
// Check if required env file is missing
456465
if (bootstrapConfig.missingEnvFiles.includes(devEnvFile)) {
457466
console.log(
458-
chalk.yellow(`⚠️ Required env file missing: ${devEnvFile}`),
467+
chalk.yellow(
468+
`⚠️ Required env file missing: ${devEnvFile}`,
469+
),
459470
);
460471

461472
// Auto-create template if configured or prompt user
462473
if (bootstrapConfig.autoCreateTemplate) {
463-
console.log(chalk.gray(` Creating template ${devEnvFile}...`));
464-
await createEnvTemplate(cwd, devEnvFile, "development", bootstrapConfig.requiredVariables);
474+
console.log(
475+
chalk.gray(` Creating template ${devEnvFile}...`),
476+
);
477+
await createEnvTemplate(
478+
cwd,
479+
devEnvFile,
480+
"development",
481+
bootstrapConfig.requiredVariables,
482+
);
465483
console.log(chalk.green(` ✓ Created ${devEnvFile}`));
466484
} else {
467485
// Provide helpful instructions
468486
console.log(chalk.cyan("\n💡 To fix this, either:"));
469487
console.log(
470-
chalk.gray(` 1. Create ${devEnvFile} with your environment variables`),
488+
chalk.gray(
489+
` 1. Create ${devEnvFile} with your environment variables`,
490+
),
471491
);
472492
console.log(
473-
chalk.gray(` 2. Add autoCreateTemplate: true to envFileConfig in bootstrap`),
493+
chalk.gray(
494+
` 2. Add autoCreateTemplate: true to envFileConfig in bootstrap`,
495+
),
474496
);
475497
console.log(
476-
chalk.gray(` 3. Use skipFileLoading: true for container deployments`),
498+
chalk.gray(
499+
` 3. Use skipFileLoading: true for container deployments`,
500+
),
477501
);
478502
console.log();
479503

480504
// Still continue - the container might work if env vars are set in docker-compose
481505
console.log(
482-
chalk.yellow(` ⚠️ Container may fail if ${devEnvFile} is required`),
506+
chalk.yellow(
507+
` ⚠️ Container may fail if ${devEnvFile} is required`,
508+
),
483509
);
484510
console.log();
485511
}
@@ -492,16 +518,16 @@ async function runContainerDev(options: ContainerDevOptions): Promise<void> {
492518
console.log(chalk.gray(` • ${varName}`));
493519
});
494520
console.log(
495-
chalk.gray(` Set these in ${devEnvFile} or docker-compose.development.yml`),
521+
chalk.gray(
522+
` Set these in ${devEnvFile} or docker-compose.development.yml`,
523+
),
496524
);
497525
console.log();
498526
}
499527
}
500528
} catch (error) {
501529
// Non-fatal - continue with container startup
502-
console.log(
503-
chalk.gray(" (Bootstrap analysis skipped)"),
504-
);
530+
console.log(chalk.gray(" (Bootstrap analysis skipped)"));
505531
}
506532

507533
// Step 2: Auto-run docker:setup if local dependencies exist

src/containerize/analyzers/bootstrap-analyzer.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,7 @@ function parseBootstrapConfig(content: string, result: BootstrapConfig): void {
129129
}
130130

131131
// Extract files mapping
132-
const filesMatch = content.match(
133-
/files\s*:\s*\{([^}]+)\}/s,
134-
);
132+
const filesMatch = content.match(/files\s*:\s*\{([^}]+)\}/s);
135133
if (filesMatch) {
136134
const filesContent = filesMatch[1];
137135
// Match key-value pairs like: development: ".env.dev"
@@ -144,9 +142,7 @@ function parseBootstrapConfig(content: string, result: BootstrapConfig): void {
144142
}
145143

146144
// Extract required variables
147-
const requiredMatch = content.match(
148-
/required\s*:\s*\[([^\]]+)\]/s,
149-
);
145+
const requiredMatch = content.match(/required\s*:\s*\[([^\]]+)\]/s);
150146
if (requiredMatch) {
151147
const requiredContent = requiredMatch[1];
152148
const variables = requiredContent.matchAll(/["'`]([^"'`]+)["'`]/g);

src/containerize/form.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import chalk from "chalk";
22
import Compiler from "../utils/compiler";
33
import { printError, printSuccess } from "../utils/cli-ui";
4-
import { analyzeProject, type ProjectAnalysis } from "./analyzers/project-analyzer";
4+
import {
5+
analyzeProject,
6+
type ProjectAnalysis,
7+
} from "./analyzers/project-analyzer";
58
import { generateDockerfiles } from "./generators/dockerfile-generator";
69
import { generateKubernetesConfigs } from "./generators/kubernetes-generator";
710
import { generateDockerCompose } from "./generators/docker-compose-generator";
@@ -166,9 +169,7 @@ function printBootstrapAnalysis(analysis: ProjectAnalysis): void {
166169

167170
// Show detected env file config
168171
if (bootstrapConfig.skipFileLoading || bootstrapConfig.ciMode) {
169-
console.log(
170-
chalk.green(" ✓ Container-ready configuration detected"),
171-
);
172+
console.log(chalk.green(" ✓ Container-ready configuration detected"));
172173
console.log(
173174
chalk.gray(
174175
` Using ${bootstrapConfig.skipFileLoading ? "skipFileLoading" : "ciMode"} mode`,
@@ -181,7 +182,9 @@ function printBootstrapAnalysis(analysis: ProjectAnalysis): void {
181182
const copyEnvFiles = shouldCopyEnvFiles(bootstrapConfig);
182183

183184
if (copyEnvFiles) {
184-
console.log(chalk.yellow(" ⚠️ Environment file configuration detected"));
185+
console.log(
186+
chalk.yellow(" ⚠️ Environment file configuration detected"),
187+
);
185188

186189
// Show existing env files
187190
if (bootstrapConfig.existingEnvFiles.length > 0) {
@@ -229,9 +232,7 @@ function printBootstrapAnalysis(analysis: ProjectAnalysis): void {
229232
chalk.gray(" 1. Create the missing env files before building"),
230233
);
231234
console.log(
232-
chalk.gray(
233-
" 2. Update bootstrap to use skipFileLoading: true",
234-
),
235+
chalk.gray(" 2. Update bootstrap to use skipFileLoading: true"),
235236
);
236237
console.log(
237238
chalk.gray(

src/containerize/generators/docker-compose-generator.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ function generateAppService(
135135
const envFile = bootstrapConfig
136136
? getEnvFileForEnvironment(bootstrapConfig, environment)
137137
: null;
138-
const envFileExists = envFile && bootstrapConfig?.existingEnvFiles.includes(envFile);
138+
const envFileExists =
139+
envFile && bootstrapConfig?.existingEnvFiles.includes(envFile);
139140

140141
let service = ` app:
141142
build:

src/containerize/generators/dockerfile-generator.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@ function generateDevelopmentDockerfile(
206206

207207
// Bootstrap config analysis for env files
208208
const bootstrapConfig = analysis?.bootstrapConfig;
209-
const copyEnvFiles =
210-
bootstrapConfig && shouldCopyEnvFiles(bootstrapConfig);
209+
const copyEnvFiles = bootstrapConfig && shouldCopyEnvFiles(bootstrapConfig);
211210
const envFileCopies = copyEnvFiles
212211
? generateEnvFileCopies(bootstrapConfig!, "development")
213212
: "";
@@ -525,8 +524,7 @@ function generateLocalDependencyCopies(localDependencyPaths: string[]): string {
525524
function generateDockerignoreContent(analysis?: ProjectAnalysis): string {
526525
// Bootstrap config determines which env files should NOT be ignored
527526
const bootstrapConfig = analysis?.bootstrapConfig;
528-
const copyEnvFiles =
529-
bootstrapConfig && shouldCopyEnvFiles(bootstrapConfig);
527+
const copyEnvFiles = bootstrapConfig && shouldCopyEnvFiles(bootstrapConfig);
530528

531529
// Build env file exclusions based on bootstrap config
532530
let envFileSection = `# Environment files

src/containerize/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ export {
77
type BootstrapConfig,
88
type EnvFileMapping,
99
} from "./analyzers/bootstrap-analyzer";
10-
export { analyzeProject, type ProjectAnalysis } from "./analyzers/project-analyzer";
10+
export {
11+
analyzeProject,
12+
type ProjectAnalysis,
13+
} from "./analyzers/project-analyzer";

0 commit comments

Comments
 (0)