Skip to content

Commit 347b312

Browse files
committed
style: format code for improved readability across multiple files, including CLI, CICD, and containerization modules
1 parent 4989d30 commit 347b312

54 files changed

Lines changed: 2071 additions & 837 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/cicd/cli.ts

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@ import {
33
initCICD,
44
generateCICD,
55
listPlatforms,
6-
validatePipelines
6+
validatePipelines,
77
} from "./form";
88

99
// eslint-disable-next-line @typescript-eslint/ban-types
1010
type CommandModuleArgs = {};
1111

12-
export type CIPlatform = "github" | "gitlab" | "circleci" | "jenkins" | "bitbucket" | "azure";
12+
export type CIPlatform =
13+
| "github"
14+
| "gitlab"
15+
| "circleci"
16+
| "jenkins"
17+
| "bitbucket"
18+
| "azure";
1319
export type CIStrategy = "basic" | "comprehensive" | "security-focused";
1420

1521
const cicdCommand = (): CommandModule<CommandModuleArgs, any> => {
@@ -26,13 +32,25 @@ const cicdCommand = (): CommandModule<CommandModuleArgs, any> => {
2632
});
2733

2834
yargs.positional("platform", {
29-
choices: ["github", "gitlab", "circleci", "jenkins", "bitbucket", "azure", "all"] as const,
35+
choices: [
36+
"github",
37+
"gitlab",
38+
"circleci",
39+
"jenkins",
40+
"bitbucket",
41+
"azure",
42+
"all",
43+
] as const,
3044
describe: "CI/CD platform to generate for",
3145
type: "string",
3246
});
3347

3448
yargs.option("strategy", {
35-
choices: ["basic", "comprehensive", "security-focused"] as const,
49+
choices: [
50+
"basic",
51+
"comprehensive",
52+
"security-focused",
53+
] as const,
3654
describe: "CI/CD pipeline strategy",
3755
type: "string",
3856
alias: "s",
@@ -64,7 +82,15 @@ const cicdCommand = (): CommandModule<CommandModuleArgs, any> => {
6482
});
6583

6684
yargs.option("deploy-target", {
67-
choices: ["kubernetes", "ecs", "cloudrun", "railway", "render", "fly", "none"] as const,
85+
choices: [
86+
"kubernetes",
87+
"ecs",
88+
"cloudrun",
89+
"railway",
90+
"render",
91+
"fly",
92+
"none",
93+
] as const,
6894
describe: "Deployment target platform",
6995
type: "string",
7096
default: "none",

src/cicd/form.ts

Lines changed: 117 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,36 @@ export interface CICDOptions {
2727
}
2828

2929
const PLATFORMS: { id: CIPlatform; name: string; description: string }[] = [
30-
{ id: "github", name: "GitHub Actions", description: "CI/CD for GitHub repositories" },
31-
{ id: "gitlab", name: "GitLab CI", description: "CI/CD for GitLab repositories" },
32-
{ id: "circleci", name: "CircleCI", description: "Cloud-based CI/CD platform" },
33-
{ id: "jenkins", name: "Jenkins", description: "Self-hosted automation server" },
34-
{ id: "bitbucket", name: "Bitbucket Pipelines", description: "CI/CD for Bitbucket Cloud" },
35-
{ id: "azure", name: "Azure DevOps", description: "Microsoft Azure CI/CD platform" },
30+
{
31+
id: "github",
32+
name: "GitHub Actions",
33+
description: "CI/CD for GitHub repositories",
34+
},
35+
{
36+
id: "gitlab",
37+
name: "GitLab CI",
38+
description: "CI/CD for GitLab repositories",
39+
},
40+
{
41+
id: "circleci",
42+
name: "CircleCI",
43+
description: "Cloud-based CI/CD platform",
44+
},
45+
{
46+
id: "jenkins",
47+
name: "Jenkins",
48+
description: "Self-hosted automation server",
49+
},
50+
{
51+
id: "bitbucket",
52+
name: "Bitbucket Pipelines",
53+
description: "CI/CD for Bitbucket Cloud",
54+
},
55+
{
56+
id: "azure",
57+
name: "Azure DevOps",
58+
description: "Microsoft Azure CI/CD platform",
59+
},
3660
];
3761

3862
/**
@@ -43,28 +67,35 @@ export async function initCICD(options: CICDOptions): Promise<void> {
4367

4468
// Analyze project first
4569
const analysis = await analyzeProject();
46-
70+
4771
// Interactive prompts
4872
const answers = await inquirer.prompt([
4973
{
5074
type: "checkbox",
5175
name: "platforms",
5276
message: "Select CI/CD platforms to configure:",
53-
choices: PLATFORMS.map(p => ({
77+
choices: PLATFORMS.map((p) => ({
5478
name: `${p.name} - ${p.description}`,
5579
value: p.id,
5680
checked: p.id === "github",
5781
})),
58-
validate: (input) => input.length > 0 || "Select at least one platform",
82+
validate: (input) =>
83+
input.length > 0 || "Select at least one platform",
5984
},
6085
{
6186
type: "list",
6287
name: "strategy",
6388
message: "Select CI/CD strategy:",
6489
choices: [
6590
{ name: "Basic - Lint, test, build", value: "basic" },
66-
{ name: "Comprehensive - Full testing, security, coverage", value: "comprehensive" },
67-
{ name: "Security-Focused - Maximum security scanning", value: "security-focused" },
91+
{
92+
name: "Comprehensive - Full testing, security, coverage",
93+
value: "comprehensive",
94+
},
95+
{
96+
name: "Security-Focused - Maximum security scanning",
97+
value: "security-focused",
98+
},
6899
],
69100
default: "comprehensive",
70101
},
@@ -144,7 +175,11 @@ export async function generateCICD(options: CICDOptions): Promise<void> {
144175
console.log(chalk.cyan("\n🔧 ExpressoTS CI/CD Generator\n"));
145176

146177
if (!options.platform) {
147-
console.log(chalk.red("Error: Please specify a platform. Use 'expressots cicd list' to see available platforms."));
178+
console.log(
179+
chalk.red(
180+
"Error: Please specify a platform. Use 'expressots cicd list' to see available platforms.",
181+
),
182+
);
148183
return;
149184
}
150185

@@ -162,8 +197,10 @@ export async function generateCICD(options: CICDOptions): Promise<void> {
162197

163198
console.log(chalk.green("\n✅ CI/CD configuration generated!\n"));
164199
printNextSteps(
165-
options.platform === "all" ? PLATFORMS.map(p => p.id) : [options.platform],
166-
options
200+
options.platform === "all"
201+
? PLATFORMS.map((p) => p.id)
202+
: [options.platform],
203+
options,
167204
);
168205
}
169206

@@ -173,21 +210,25 @@ export async function generateCICD(options: CICDOptions): Promise<void> {
173210
export async function listPlatforms(): Promise<void> {
174211
console.log(chalk.cyan("\n📋 Available CI/CD Platforms\n"));
175212

176-
console.log(chalk.bold("Platform".padEnd(20) + "Description".padEnd(45) + "Status"));
213+
console.log(
214+
chalk.bold("Platform".padEnd(20) + "Description".padEnd(45) + "Status"),
215+
);
177216
console.log("-".repeat(80));
178217

179218
for (const platform of PLATFORMS) {
180219
const status = chalk.green("✓ Available");
181220
console.log(
182221
chalk.white(platform.name.padEnd(20)) +
183-
chalk.gray(platform.description.padEnd(45)) +
184-
status
222+
chalk.gray(platform.description.padEnd(45)) +
223+
status,
185224
);
186225
}
187226

188227
console.log(chalk.gray("\nUsage: expressots cicd generate <platform>"));
189228
console.log(chalk.gray(" expressots cicd generate all"));
190-
console.log(chalk.gray(" expressots cicd init (interactive wizard)\n"));
229+
console.log(
230+
chalk.gray(" expressots cicd init (interactive wizard)\n"),
231+
);
191232
}
192233

193234
/**
@@ -197,11 +238,23 @@ export async function validatePipelines(): Promise<void> {
197238
console.log(chalk.cyan("\n🔍 Validating CI/CD Configurations\n"));
198239

199240
const cwd = process.cwd();
200-
const validations: { platform: string; file: string; exists: boolean; valid: boolean; issues: string[] }[] = [];
241+
const validations: {
242+
platform: string;
243+
file: string;
244+
exists: boolean;
245+
valid: boolean;
246+
issues: string[];
247+
}[] = [];
201248

202249
// Check for each platform's config file
203250
const platformFiles: { platform: string; paths: string[] }[] = [
204-
{ platform: "GitHub Actions", paths: [".github/workflows/ci.yml", ".github/workflows/docker-deploy.yml"] },
251+
{
252+
platform: "GitHub Actions",
253+
paths: [
254+
".github/workflows/ci.yml",
255+
".github/workflows/docker-deploy.yml",
256+
],
257+
},
205258
{ platform: "GitLab CI", paths: [".gitlab-ci.yml"] },
206259
{ platform: "CircleCI", paths: [".circleci/config.yml"] },
207260
{ platform: "Jenkins", paths: ["Jenkinsfile"] },
@@ -213,58 +266,78 @@ export async function validatePipelines(): Promise<void> {
213266
for (const filePath of paths) {
214267
const fullPath = path.join(cwd, filePath);
215268
const exists = fs.existsSync(fullPath);
216-
269+
217270
if (exists) {
218271
const issues: string[] = [];
219272
let valid = true;
220273

221274
try {
222275
const content = fs.readFileSync(fullPath, "utf-8");
223-
276+
224277
// Basic validation checks
225278
if (content.length < 50) {
226279
issues.push("File seems too short");
227280
valid = false;
228281
}
229282

230283
// Check for common issues
231-
if (filePath.endsWith(".yml") || filePath.endsWith(".yaml")) {
284+
if (
285+
filePath.endsWith(".yml") ||
286+
filePath.endsWith(".yaml")
287+
) {
232288
if (content.includes("\t")) {
233-
issues.push("Contains tabs (YAML should use spaces)");
289+
issues.push(
290+
"Contains tabs (YAML should use spaces)",
291+
);
234292
}
235293
}
236294

237295
// Check for placeholder values
238-
if (content.includes("YOUR_") || content.includes("<REPLACE>")) {
239-
issues.push("Contains placeholder values that need to be replaced");
296+
if (
297+
content.includes("YOUR_") ||
298+
content.includes("<REPLACE>")
299+
) {
300+
issues.push(
301+
"Contains placeholder values that need to be replaced",
302+
);
240303
}
241-
242304
} catch (err) {
243305
issues.push("Failed to read file");
244306
valid = false;
245307
}
246308

247-
validations.push({ platform, file: filePath, exists, valid, issues });
309+
validations.push({
310+
platform,
311+
file: filePath,
312+
exists,
313+
valid,
314+
issues,
315+
});
248316
}
249317
}
250318
}
251319

252320
if (validations.length === 0) {
253321
console.log(chalk.yellow("No CI/CD configuration files found."));
254-
console.log(chalk.gray("\nRun 'expressots cicd init' to create CI/CD configurations.\n"));
322+
console.log(
323+
chalk.gray(
324+
"\nRun 'expressots cicd init' to create CI/CD configurations.\n",
325+
),
326+
);
255327
return;
256328
}
257329

258330
console.log(chalk.bold("File".padEnd(45) + "Status".padEnd(15) + "Issues"));
259331
console.log("-".repeat(80));
260332

261333
for (const v of validations) {
262-
const status = v.valid ? chalk.green("✓ Valid") : chalk.yellow("⚠ Warning");
263-
const issues = v.issues.length > 0 ? chalk.gray(v.issues.join(", ")) : "";
334+
const status = v.valid
335+
? chalk.green("✓ Valid")
336+
: chalk.yellow("⚠ Warning");
337+
const issues =
338+
v.issues.length > 0 ? chalk.gray(v.issues.join(", ")) : "";
264339
console.log(
265-
chalk.white(v.file.padEnd(45)) +
266-
status.padEnd(24) +
267-
issues
340+
chalk.white(v.file.padEnd(45)) + status.padEnd(24) + issues,
268341
);
269342
}
270343

@@ -277,7 +350,7 @@ export async function validatePipelines(): Promise<void> {
277350
async function generatePlatformConfig(
278351
platform: CIPlatform,
279352
options: CICDOptions,
280-
analysis: any
353+
analysis: any,
281354
): Promise<void> {
282355
const cwd = process.cwd();
283356
const outputDir = options.outputDir || cwd;
@@ -325,7 +398,9 @@ function printNextSteps(platforms: CIPlatform[], options: CICDOptions): void {
325398
console.log(chalk.bold("📖 Next Steps:\n"));
326399

327400
console.log(chalk.white("1. Review generated configuration files"));
328-
console.log(chalk.white("2. Configure required secrets in your CI/CD platform:\n"));
401+
console.log(
402+
chalk.white("2. Configure required secrets in your CI/CD platform:\n"),
403+
);
329404

330405
// Common secrets
331406
const secrets = [
@@ -356,6 +431,10 @@ function printNextSteps(platforms: CIPlatform[], options: CICDOptions): void {
356431
}
357432

358433
console.log(chalk.white("\n3. Commit and push to trigger the pipeline"));
359-
360-
console.log(chalk.gray("\n💡 Tip: Run 'expressots cicd validate' to check your configurations\n"));
434+
435+
console.log(
436+
chalk.gray(
437+
"\n💡 Tip: Run 'expressots cicd validate' to check your configurations\n",
438+
),
439+
);
361440
}

0 commit comments

Comments
 (0)