asycli
v1.0.5
Published
CLI tool to generate TypeScript module files
Maintainers
Readme
AsyCLI
A CLI tool for generating TypeScript module files with NestJS, React, and React Native structure.
Features
- Generate complete module structure with a single command
- Support for multiple frameworks:
- NestJS: Creates module structure with:
[module].service.ts[module].repository.ts[module].resolver.ts[module].schema.ts[module].dto.ts[module].module.ts
- React: Creates various React components and structures:
- Pages:
[page].tsx(with routing and layout) - Screens:
[screen].tsx(for screen components) - Components:
- Table components
- Create form components
- Context:
[context].tsx(for state management) - Models:
[model].ts(for TypeScript interfaces) - GraphQL:
- Queries
- Fragments
- Pages:
- NestJS: Creates module structure with:
- Pre-populated with framework-specific decorators and basic structure
- Template-based system for easy customization
Installation
Prerequisites
- Node.js (v14 or higher)
- npm (v6 or higher)
Global Installation
- Clone the repository:
git clone https://github.com/yourusername/asycli.git
cd asycli- Install dependencies:
npm install- Build the project:
npm run build- Install globally:
npm install -g .Local Installation
- Clone the repository:
git clone https://github.com/yourusername/asycli.git
cd asycli- Install dependencies:
npm install- Build the project:
npm run buildUsage
Basic Usage
asycli generate -d ./src -m userThis will create a user directory with all the necessary files in the src directory.
Options
-d, --dir <directory>: Target directory for generated files (required)-m, --module <name>: Name of the module to generate (required)
Example
asycli generate -d ./src -m userThis will create the following structure:
src/
└── user/
├── user.service.ts
├── user.repository.ts
├── user.resolver.ts
├── user.schema.ts
├── user.dto.ts
└── user.module.tsExamples
NestJS Example
asycli generate -d ./src -m user -f nestThis will create the following structure:
src/
└── user/
├── user.service.ts
├── user.repository.ts
├── user.resolver.ts
├── user.schema.ts
├── user.dto.ts
└── user.module.tsDevelopment
Building the Project
The build process includes:
- Cleaning the dist directory
- Compiling TypeScript files
- Copying template files to dist directory
npm run buildRunning in Development Mode
npm run devTesting the CLI
npm run dev -- -d ./src -m testAvailable Scripts
npm run clean: Remove the dist directorynpm run copy-templates: Copy template files to dist directorynpm run build: Full build processnpm run start: Run the compiled versionnpm run dev: Run in development mode with ts-nodenpm run prepare: Run before npm install (automatically builds the project)
Project Structure
.
├── bin/
│ └── asycli # CLI entry point
├── src/
│ ├── templates/ # Template files
│ │ ├── nest/ # NestJS templates
│ │ │ ├── service.template.txt
│ │ │ ├── repository.template.txt
│ │ │ ├── resolver.template.txt
│ │ │ ├── schema.template.txt
│ │ │ ├── dto.template.txt
│ │ │ └── module.template.txt
│ │ ├── react/ # React templates
│ │ │ ├── page.template.tsx.txt
│ │ │ ├── screen.template.tsx.txt
│ │ │ ├── context.template.tsx.txt
│ │ │ ├── model.template.ts.txt
│ │ │ ├── components/
│ │ │ │ ├── table.template.tsx.txt
│ │ │ │ └── create.template.tsx.txt
│ │ │ └── gql/
│ │ │ ├── query.template.ts.txt
│ │ │ └── fragment.template.ts.txt
│ │ └── react-native/ # React Native templates
│ │ ├── component.template.txt
│ │ ├── styles.template.txt
│ │ ├── test.template.txt
│ │ └── types.template.txt
│ └── index.ts # Main CLI logic
├── dist/ # Compiled JavaScript files
├── package.json
└── tsconfig.jsonDependencies
@nestjs/common: For NestJS decorators and utilities@nestjs/graphql: For GraphQL supportcommander: For CLI argument parsingtypescript: For TypeScript compilation
License
ISC
