npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

cleanarch

v1.0.29

Published

A CLI to generate folders/files based on clean architecutre

Readme

cleanarch

A simple CLI tô generate typescript code based on uncle-bob clean architecture propose

Installation

npm i --save-dev cleanarch

Configure

You need creating in a root folder an a cleanarch-cli.config.json, thats a simple json with keys:

  • commands: an array of Command object
  • schema: an array of Schema object

Command Object: Owns 2 keys:

  • command: An Command following the syntax described at: https://www.npmjs.com/package/commander
  • comment: Textual Description Of command

Schema Object

  • sufix: Suffix for generated class. eg: "Usecase"
  • extensionSufix: Suffix for extension: eg: ".usecase"
  • languageSufix: We currently only supports typescript so: ".ts"
  • defaultImplements: If the class implements an other classes use an array to declare the sufix of them: ["Inteface", "OtherSuffix"]
  • defaultDependencies: If the class uses other classes use an array to declare the sufix of them: ["Protocol"]
  • useDecorators: If your class use decorators use an array: ["@Service()", "Other()"]
  • folder: Generate file into the folder. eg: "./src/core/usecases/"
  • abstract: If class is abstract class so true else false;

Full Simple

{
  "lintPreferences": {
    "useSemicolon": true
  },
  "commands": [
    {
      "command": "-it --interface [commands...]",
      "comment": "Generate an Interface"
    },
    {
      "command": "-uc --usecase [commands...]",
      "comment": "Generate an Usecase"
    },
    {
      "command": "-pc --protocol [commands...]",
      "comment": "Generate an Protocol"
    },
    {
      "command": "-ct --connector [commands...]",
      "comment": "Generate an Connector"
    }
  ],
  "schema": [
    {
      "sufix": "Strategy",
      "extensionSufix": ".strategy",
      "languageSufix": ".ts",
      "defaultImplementsSuffix": "",
      "defaultDependenciesSuffix": "",
      "useDecorators": [],
      "folder": "./core/strategies/",
      "abstract": true,
      "importsFrom": []
    },
    {
      "sufix": "Usecase",
      "extensionSufix": ".usecase",
      "languageSufix": ".ts",
      "defaultImplementsSuffix": "Strategy",
      "defaultDependenciesSuffix": "Protocol",
      "useDecorators": [
        "@Core.Injection()"
      ],
      "folder": "./core/usecases/",
      "abstract": false,
      "importsFrom": [
        {
          "path": "'../interfaces/interfaces.exports'",
          "defaultSuffix": "Interface"
        },
        {
          "path": "'../protocols/protocols.exports'",
          "defaultSuffix": "Protocol"
        }
      ]
    },
    {
      "sufix": "Protocol",
      "extensionSufix": ".protocol",
      "languageSufix": ".ts",
      "defaultImplementsSuffix": "",
      "defaultDependenciesSuffix": "",
      "useDecorators": [],
      "folder": "./core/protocols/",
      "abstract": true,
      "importsFrom": []
    },
    {
      "sufix": "Connector",
      "extensionSufix": ".connector",
      "languageSufix": ".ts",
      "defaultImplementsSuffix": "Protocol",
      "defaultDependenciesSuffix": "",
      "useDecorators": [
        "@Core.Injection()"
      ],
      "folder": "./adapters/connectors/",
      "abstract": false,
      "importsFrom": [
        {
          "path": "'../../core/protocols/protocols.exports'",
          "defaultSuffix": "Protocol"
        }
      ]
    }
  ],
  "exportsConfig": {
    "extensionType": ".ts"
  }
}

Default Commands:

-all

Generete a full and complete schema

usage: -all <classes...>

-u

Make the class use a set of classes begining with given classes names

usage: -u <classes...>

-us

Make the class use a set of classes with specified names

-i

Make the class implements a specific set of classes

usage: -i <classes...>

-exports

usage: -export [path] Make or update a export file from current path or a path based on relative path (starting in current path)

Usage

Generate a complete Schema :

cleanarch -all UserLogin UserLogout

Thats create a bellow structure:

src>
    core>
        strategy>
            user-login.strategy.ts
            user-logout.strategy.ts
        usecases>
            user-login.usecase.ts
            user-logout.usecese.ts
        protocols>
            user-login.protocol.ts
            user-logout.protocol.ts
    adapter>
        connectors>
            user-login.protocol.ts
            user-logout.protocol.ts

Generate an specify component

assuming it has been configured in cleanarch-cli.json as presented

Generate Usecase

cleanarch -uc Login

that's generete a content file be like

export class LoginUsecase implements LoginStrategy {
  constructor(private readonly loginProtocol: LoginProtocol) {}
}

Generate an Usecase with specific dependencies and implements

cleanarch -uc Login -i AuthStrategy JwtStrategy AnyAbstractClass -u AuthProtocol AnyClass 

generate:

export class LoginUsecase implements AuthStrategy, JwtStrategy, AnyAbstractClass {
  constructor(private readonly authProtocol: AuthProtocol, private readonly anyClass: AnyClass) { }
} 

If you run this cli in empty project

Run in your terminal:

npm init -y
npm i --save-dev @types/node @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint eslint-config-prettier eslint-plugin-prettier prettier ts-loader ts-node tsconfig-paths typescript

Add files on source folder

ts.config.json

{
  "compilerOptions": {
    "module": "commonjs",
    "outDir": "dist",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "resolveJsonModule": true,
    "target": "ES2020",
    "sourceMap": true,
    "incremental": true,
    "skipLibCheck": true,
    "noImplicitOverride": true,
    "noPropertyAccessFromIndexSignature": true,
    "noFallthroughCasesInSwitch": true,
    "strict": false,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "strictPropertyInitialization": true,
    "strictBindCallApply": true,
    "noImplicitThis": true,
    "noImplicitReturns": true,
    "alwaysStrict": true
  }
}
{
  "compilerOptions": {
    "module": "commonjs",
    "outDir": "dist",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "resolveJsonModule": true,
    "target": "ES2020",
    "sourceMap": true,
    "incremental": true,
    "skipLibCheck": true,
    "noImplicitOverride": true,
    "noPropertyAccessFromIndexSignature": true,
    "noFallthroughCasesInSwitch": true,
    "strict": false,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "strictPropertyInitialization": true,
    "strictBindCallApply": true,
    "noImplicitThis": true,
    "noImplicitReturns": true,
    "alwaysStrict": true
  }
}
// TODO: a partir de strict: true é configuração manual baseada nos padrões do angular

ts.config.build.json

{
  "extends": "./tsconfig.json",
  "exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
}