{"id":21007640,"url":"https://github.com/lucaspereirasouzat/cli-template-node","last_synced_at":"2026-01-28T13:01:04.729Z","repository":{"id":65907812,"uuid":"574200200","full_name":"lucaspereirasouzat/cli-template-node","owner":"lucaspereirasouzat","description":"This cli is a tool for generate clean code using template from Rodrigo Manguinhos clean-typescript","archived":false,"fork":false,"pushed_at":"2025-06-27T18:00:02.000Z","size":867,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-06T17:41:53.818Z","etag":null,"topics":["clean","clean-architecture","clean-code","cli","jest","template","typescript","vitest"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lucaspereirasouzat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-12-04T18:23:41.000Z","updated_at":"2025-06-10T12:44:43.000Z","dependencies_parsed_at":"2023-11-26T23:23:17.703Z","dependency_job_id":"25095a35-815e-4a56-8d7e-4bb6c1daf13e","html_url":"https://github.com/lucaspereirasouzat/cli-template-node","commit_stats":{"total_commits":107,"total_committers":1,"mean_commits":107.0,"dds":0.0,"last_synced_commit":"2b3e935fef3bda1cfd5fcfa005d1ac9062312ca3"},"previous_names":["lucaspereirasouzat/cli-template-node","warmachine13/cli-template-node"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lucaspereirasouzat/cli-template-node","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucaspereirasouzat%2Fcli-template-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucaspereirasouzat%2Fcli-template-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucaspereirasouzat%2Fcli-template-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucaspereirasouzat%2Fcli-template-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucaspereirasouzat","download_url":"https://codeload.github.com/lucaspereirasouzat/cli-template-node/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucaspereirasouzat%2Fcli-template-node/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28845760,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T12:37:07.070Z","status":"ssl_error","status_checked_at":"2026-01-28T12:37:06.657Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clean","clean-architecture","clean-code","cli","jest","template","typescript","vitest"],"created_at":"2024-11-19T09:09:27.948Z","updated_at":"2026-01-28T13:01:04.714Z","avatar_url":"https://github.com/lucaspereirasouzat.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n\u003c!-- markdownlint-configure-file {\n\n\"MD013\": {\n\n\"code_blocks\": false,\n\n\"tables\": false\n\n},\n\n\"MD033\": false,\n\n\"MD041\": false\n\n} --\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n\n\n# Clean code Template cli\n\n\n\n\u003c/div\u003e\n\n\n\n![npm](https://img.shields.io/npm/dw/clean_code_template_cli) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/clean_code_template_cli)\n\n![npm](https://img.shields.io/npm/v/clean_code_template_cli)\n\n\n\n## Getting started\n\n\n\nThis cli is a tool for generate clean code using template from Rodrigo Manguinhos clean-typescript\n\n\n\n\n\n\n\n# 1. **Install command**\n\n  Global install\n\n```bash\n\nnpm i clean_code_template_cli -g\n\n```\n\nOR with npx\n\n\n```bash\n\nnpx clean_code_template_cli\n\n```\n\n\n\n# 2. Name File\n\n\n\nThe name of the file must be used with camel Case or snake case or  to put inside classNames and transfom correctly name of files like Like NameOfFile\n\n\n\n# 3. Sub Folders\n\n\n\nThe sub folders can be created adding pre paths like /path/NameOfFile\n\n\n\n# 4. Commands\n\n\n\nall commands will be uses with clean_code_template_cli create\n\n\n\nCREATING\n\n\n\nAll commands must used with folder name like /name/ArquiveName\n\n\n## Controller\n\n\n\nWill create a controller inside a folder /src/application/controllers\n\n\n\n```sh\n\nclean_code_template_cli create {{nameFile}} -ctl\n\n```\n\n\n\nwill create\n\n\n\n```ts\n\nimport { Controller } from '@/application/controllers'\n\nimport { HttpResponse, ok } from '@/application/helpers'\n\nimport { ValidationBuilder as Builder, Validator } from 'library-validators'\n\nimport { CreateCustomer } from '@/domain/contracts/repos'\n\nimport { {{ className }}UseCase } from '@/domain/use-cases'\n\n\n\ntype HttpRequest = {\n\nname: string\n\nnickname: string\n\nemail: string\n\ninscription: string\n\nfirstName: string\n\nlastName: string\n\npassword: string\n\ndomain: string\n\n}\n\ntype Model = Error | CreateCustomer.Output\n\n\n\nexport class {{ className }}Controller extends Controller {\n\nconstructor (private readonly {{ className }}: {{ className }}UseCase) {\n\nsuper()\n\n}\n\n\n\nasync perform (input: HttpRequest): Promise\u003cHttpResponse\u003cModel\u003e\u003e {\n\nconst data = await this.{{ className }}(input)\n\nreturn ok(data)\n\n}\n\n\n\noverride buildValidators ({ name, email, inscription, firstName, lastName, password, domain }: HttpRequest): Validator[] {\n\nreturn [\n\n...Builder.of({ value: name, fieldName: 'name' }).required().build(),\n\n...Builder.of({ value: email, fieldName: 'email' }).required().build(),\n\n...Builder.of({ value: firstName, fieldName: 'firstName' }).required().build(),\n\n...Builder.of({ value: lastName, fieldName: 'lastName' }).required().build(),\n\n...Builder.of({ value: inscription, fieldName: 'inscription' }).required().build(),\n\n...Builder.of({ value: password, fieldName: 'password' }).required().build(),\n\n...Builder.of({ value: domain, fieldName: 'domain' }).required().build()\n\n]\n\n}\n\n}\n\n\n\n```\n\n\n\n## Contract\n\n\n\nWill generate a contract file to use for a repository or gateway, does't have test file\n\n```sh\n\nclean_code_template_cli create {{nameFile}} -cta\n\n```\n\n\n\nwill create\n\n\n\n```ts\n\nexport interface {{ className }} {\n\n{{ classNameLower }}: (input: {{ className }}.Input) =\u003e Promise\u003c{{ className }}.Output\u003e\n\n}\n\n\n\nexport namespace {{ className }} {\n\nexport type Input = {\n\n{{ properties }}\n\n}\n\nexport type Output = undefined | {\n\n{{ properties }}\n\n}\n\n}\n\n\n\n```\n\n\n## UseCase\n\nThis command will generate Usecase file inside /src/domain/use-cases\n\n```sh\n\nclean_code_template_cli create {{nameFile}} -use\n\n```\n\nwill create\n\n```ts\n\n//import { LoadFacebookUser, TokenGenerator } from '@/domain/contracts/gateways'\n\n//import { LoadUserAccount, SaveFacebookAccount } from '@/domain/contracts/repos'\n\n//import { AccessToken, FacebookAccount, AuthenticationError } from '@/domain/entities'\n\n\n\ntype Setup = () =\u003e {{ className }}\n\ntype Input = { {{ properties }} }\n\ntype Output = { accessToken: string }\n\nexport type {{ className }} = (input: Input) =\u003e Promise\u003cOutput\u003e\n\n\n\nexport const setup{{ className }}: Setup = () =\u003e async input =\u003e {\n\n\n\n}\n\n```\n\n## Gateway\n\nThis command will generate Gateway file inside /src/infra/gateways\n\n\n```sh\n\nclean_code_template_cli create {{nameFile}} -gat\n\n```\n\nwill create\n\n```ts\n\n//import { {{ className }} } from '@/infra/gateways'\n\n\n\nexport class {{ className }} // implements\n\n{\n\nconstructor(\n\n// private readonly httpClient: HttpGetClient,\n\n){}\n\n\n\nasync handle(input: {{ className }}.Input): Promise\u003c{{ className }}.Output\u003e{\n\n\n\n}\n\n}\n\n\n\n```\n## Repository\n\n\nThis command will generate Repository file inside /src/infra/repos/postgres\n\n```sh\n\nclean_code_template_cli create {{nameFile}} -rep\n\n```\n\nwill create\n\n```ts\n\n//import { {{ className }}Show, {{ className }}Update } from '@/domain/contracts/repos'\n\nimport { PgRepository } from '@/infra/repos/postgres/repository'\n\nimport { Pg{{ className }} } from './entities'\n\n\n\nexport class Pg{{ className }}Repository extends PgRepository // implements {\n\nasync {{ className }} (input: {{ className }}.Input): Promise\u003c{{ className }}.Output\u003e {\n\n\n\n}\n\n\n\nasync show ({ id }: {{ className }}Show.Input): Promise\u003c{{ className }}Show.Output\u003e {\n\nconst pg{{classNameLower}}Repo = await this.getRepository(Pg{{className}})\n\nconst {{classNameLower}} = await pg{{className}}Repo.findOne({ id })\n\n\n\nif ({{classNameLower}} !== undefined) {\n\nreturn {\n\nid: {{classNameLower}}.id,\n\ncontactId: {{classNameLower}}.contactId,\n\nemail: {{classNameLower}}.email,\n\ndefault: {{classNameLower}}.default as boolean,\n\ncreated_at: {{classNameLower}}.createdAt,\n\nupdated_at: {{classNameLower}}.updatedAt\n\n}\n\n}\n\n}\n\nasync store (input: {{ className }}Store.Input): Promise\u003c{{ className }}Store.Output\u003e {\n\nconst pg{{ className }}Repo = await this.getRepository(Pg{{ className }})\n\nconst contactEmail = await pg{{ className }}Repo.save(input)\n\n\n\nreturn {\n\nid: contactEmail.id,\n\ncontactId: contactEmail.contactId,\n\nemail: contactEmail.email,\n\ndefault: contactEmail.default as boolean,\n\ncreated_at: contactEmail.createdAt\n\n}\n\n}\n\n\n\nasync update ({ emailId, ...input }: {{ className }}Update.Input): Promise\u003c{{ className }}Update.Output\u003e {\n\nconst pg{{ className }}Repo = await this.getRepository(Pg{{ className }})\n\n\n\nconst result = await pg{{ className }}.update({ id: emailId }, input)\n\n\n\nreturn result.affected != null \u0026\u0026 result.affected \u003e 0\n\n}\n\n\n\nasync delete ({ id }: {{ className }}Delete.Input): Promise\u003c{{ className }}Delete.Output\u003e {\n\nconst pg{{ className }}Repo = await this.getRepository(Pg{{ className }})\n\n\n\nconst result = await pg{{ className }}Repo.delete({ id })\n\n\n\nreturn result.affected != null \u0026\u0026 result.affected \u003e 0\n\n}\n\n}\n\n\n\n```\n\n## Entities\n\nThis command will generate Entities file inside /src/domain/entities\n\n```sh\n\nclean_code_template_cli create {{nameFile}} -ent\n\n```\n\nwill create\n\n```ts\n\nexport class {{ className }} {\n\nconstructor( {{ properties }} ){}\n\n\n\nexecute(): Promise\u003cvoid\u003e{}\n\n}\n\n\n\n```\n## Error\n\nThis command will generate Error file inside /src/domain/entities/errors\n\n\n```sh\n\nclean_code_template_cli create {{nameFile}} -err\n\n```\n\nwill create\n\n```ts\n\nexport class {{ className }} extends Error {\n\nconstructor () {\n\nsuper('{{ className }}')\n\nthis.name = '{{ className }}'\n\n}\n\n}\n\n```\n\n\n## Adapter\n\n\n\nThis command will generate Adapter file inside /src/main/adapter\n\n\n\n```sh\n\nclean_code_template_cli create {{nameFile}} -adp\n\n```\n\n\n\nwill create\n\n```ts\n\nimport { Controller } from '@/application/controllers'\n\n\n\nimport { RequestHandler } from 'express'\n\n\n\ntype Adapter = (controller: Controller) =\u003e RequestHandler\n\n\n\nexport const adapt{{ className }}: Adapter = controller =\u003e async (req, res) =\u003e {\n\nconst { statusCode, data } = await controller.handle({ ...req.body, ...req.locals, ...req.params, ...req.query })\n\nconst json = [200, 204].includes(statusCode) ? data : { error: data.message }\n\nres.status(statusCode).json(json)\n\n}\n\n```\n\n\n## Decorator\n\n```sh\n\nclean_code_template_cli create {{nameFile}} -dec\n\n```\n\nThis command will generate Decorator file inside /src/aplication/decorator\n\n```ts\nimport { {{ className }} } from '@/application/contracts'\n\nimport { Controller } from '@/application/controllers'\n\nimport { HttpResponse } from '@/application/helpers'\n\nimport { Validator } from '@/domain/contracts'\n\n\n\nexport class {{ className }}Controller extends Controller {\n\nconstructor (\n\nprivate readonly decoratee: Controller,\n\nprivate readonly db: {{ className }}\n\n) {\n\nsuper()\n\n}\n\n\n\noverride buildValidators (httpRequest: any): Validator[] {\n\nreturn this.decoratee.buildValidators(httpRequest)\n\n}\n\n\n\nasync perform (httpRequest: any): Promise\u003cHttpResponse\u003e {\n\nawait this.db.openTransaction()\n\n\n\ntry {\n\nconst httpResponse = await this.decoratee.perform(httpRequest)\n\nawait this.db.commit()\n\nreturn httpResponse\n\n} catch (error) {\n\nawait this.db.rollback()\n\nthrow error\n\n} finally {\n\nawait this.db.closeTransaction()\n\n}\n\n}\n\n}\n```\n\n\n## Route\n\n```sh\n\nclean_code_template_cli create {{nameFile}} -rot\n\n```\n\nThis command will generate Decorator file inside /src/main/routes\n\n```ts\nimport { adaptExpressRoute as adapt } from '@/main/adapters'\n\nimport { make{{ className }} } from '@/main/factories/application/controllers'\n\n\n\nimport { Router } from 'express'\n\n\n\nexport default (router: Router): void =\u003e {\n\nrouter.post('/message/send', adapt(make{{ className }}()))\n\n}\n```\n\n## Validation\n\n```sh\n\nclean_code_template_cli create {{nameFile}} -val\n\n```\n\nThis command will generate Decorator file inside /src/main/routes\n\n```ts\n// import { InvalidFieldError } from '@/application/errors'\n\nimport { Validator } from './validator'\n\n\n\nexport class {{ className }} implements Validator {\n\nconstructor (\n\nprivate readonly value: Date,\n\nprivate readonly field: string\n\n) { }\n\n\n\nvalidate (): Error | undefined {\n\n// if (isNaN(Date.parse(this.value.toString()))) return new InvalidFieldError(this.field)\n\n}\n\n}\n```\n\n# 5. Combined Commands\n\n## Test\n\n\n\nThis command need be combined with ctl,use,gat,rep,ent to generate a test\n\n```sh\n\nclean_code_template_cli create {{nameFile}} -ctl -test\n\n```\n\n\n\n## Properties\n\n\n\nThis command need be combined with ctl,use,gat,rep,ent and add properties file\n\n\n\n```sh\n\nclean_code_template_cli create {{nameFile}} -pro\n\n```\n\n## OnlyTest\n\n\n\nThis command need be combined with ctl,use,gat,rep,ent to generate only a test file\n\n\n\n```sh\n\nclean_code_template_cli create {{nameFile}} -onlyTest\n\n```\n\n\n\n# Author\n\n- **Lucas Pereira**\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucaspereirasouzat%2Fcli-template-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucaspereirasouzat%2Fcli-template-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucaspereirasouzat%2Fcli-template-node/lists"}