Skip to content

Commit

Permalink
logs
Browse files Browse the repository at this point in the history
  • Loading branch information
barnuri committed Apr 30, 2024
1 parent 56d2fcc commit cc22edf
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
},
"dependencies": {
"axios": "^1.4.0",
"colors-ext": "^1.0.3",
"jsonpath-plus": "^7.2.0",
"rimraf": "^5.0.1",
"swagger2openapi": "^7.0.8",
Expand All @@ -47,10 +48,10 @@
"cpy-cli": "^4.2.0",
"cross-env": "^7.0.3",
"nodemon": "^2.0.22",
"npm-check-updates": "^16.10.12",
"prettier": "^2.8.8",
"react-query": "^3.39.3",
"typescript": "^5.1.3",
"npm-check-updates": "^16.10.12"
"typescript": "^5.1.3"
},
"publishConfig": {
"registry": "https://registry.npmjs.org"
Expand Down
5 changes: 3 additions & 2 deletions src/cli-generate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env node
import 'colors-ext';
import { ServerGenerators } from './models/ServerGenerators';
import { ClientGenerators } from './models/ClientGenerators';
import { generate } from './generators';
Expand Down Expand Up @@ -50,8 +51,8 @@ yargs(process.argv.slice(2))
.default('debugLogs', true),
argv => {
generate(argv as any)
.then(() => console.log('done succssfully'))
.catch(err => console.error(`failed ${err}`));
.then(() => console.log('done succssfully'.green()))
.catch(err => console.error(`failed ${err}`.red()));
},
)
.command(
Expand Down
25 changes: 24 additions & 1 deletion src/generators/GeneratorAbstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,34 @@ export abstract class GeneratorAbstract {
for (const controllerPath of controllerPaths) {
const res = this.generateControllerMethodContent(controller, controllerPath);
content += res.methodContent;
console.log(`\t${controllerPath.method.toUpperCase()} - ${controllerPath.path} => ${controller}.${res.methodName}`);
console.log(`\t${controllerPath.method} - ${controllerPath.path} => ${controller}.${res.methodName}`);
}
return content;
}

private httpMethodFormat(httpMethod: string) {
httpMethod = httpMethod.toUpperCase();
if (httpMethod === 'GET') {
return httpMethod.blue();
}
if (httpMethod === 'POST') {
return httpMethod.green();
}
if (httpMethod === 'PUT') {
return httpMethod.yellow();
}
if (httpMethod === 'DELETE') {
return httpMethod.red();
}
if (httpMethod === 'PATCH') {
return httpMethod.magenta();
}
if (httpMethod === 'HEAD') {
return httpMethod.cyan();
}
return httpMethod;
}

getMethodName(controllerPath: ApiPath, prefix: string = '', suffix: string = '') {
const generateMethodName = () => {
let longName = controllerPath.method.toLowerCase() + capitalize(controllerPath.path);
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'colors-ext';
export * from './models';
export * from './helpers';
export * from './converters';
Expand Down

0 comments on commit cc22edf

Please sign in to comment.