@yaagoub/cli
v0.1.3
Published
The **YGB CLI Framework** is a custom command-line interface that leverages Angular CLI commands and utilities, organized by functional groups for easier access and execution. This tool allows developers to generate components, test code, create applicati
Downloads
102
Readme
YGB CLI Framework
The YGB CLI Framework is a custom command-line interface that leverages Angular CLI commands and utilities, organized by functional groups for easier access and execution. This tool allows developers to generate components, test code, create applications, and manage Angular configurations using simplified flags and commands.
Table of Contents
Installation
install it by command:
npm i @yaagoub/cli
Run the CLI:
ygb [command] [subcommand]
Usage
The ygb
CLI provides a simplified way to manage Angular projects, with commands grouped by functionality. To run a command, use the following syntax:
ygb <group> <command> [options]
Available Command Groups
- Generate: Quickly create components, services, modules, and other Angular entities.
- Test: Run, watch, and generate code coverage for your Angular tests.
Command Flags
Each command has a unique flag for shorthand access. For example, to generate a component, use the -c
flag.
Example Usage
To generate a new component:
ygb g -c MyComponent
To run tests with code coverage:
ygb t -tecov
Commands Overview
Generate Commands
The generate
group includes commands for creating a variety of Angular project elements, such as components, services, modules, and more.
| key | Flag | Description | |-----------------|-----------|-------------------------------------------------------| | nativeApp | -native-app | Creates a new Angular native application project. | | app | -app | Creates a new Angular application within the project.| | component | -c | Generates a new Angular component. | | directive | -d | Generates a new Angular directive. | | service | -s | Generates a new Angular service. | | module | -m | Generates a new Angular module. | | pipe | -p | Generates a new Angular pipe. | | guard | -g | Generates a new Angular guard. | | resolver | -res | Generates a new Angular resolver. | | interface | -i | Generates a new TypeScript interface. | | class | -cl | Generates a new TypeScript class. | | enum | -enu | Generates a new TypeScript enum. | | interceptor | -inter | Generates a new Angular interceptor. | | decorator | -dec | Generates a new TypeScript decorator. | | mixin | -mix | Generates a new TypeScript mixin. | | library | -lib | Generates a new Angular library. | | asset | -asset | Adds assets to the Angular project. | | environments | -envs | Sets up environments for the Angular project. | | schematic | -schc | Generates an Angular schematic. | | webWorker | -ww | Generates a new Angular web worker. |
Test Commands
The test
group includes commands for running tests, code coverage, and linting.
| key | Flag | Description | |---------------------|--------|-------------------------------------------------------| | lintCode | -li | Runs code linting. | | runTests | -te | Runs all unit tests. | | runTestsWithCoverage| -tecov | Runs tests with code coverage report. | | watchTests | -tew | Runs tests in watch mode. | | runE2E | -e2e | Runs end-to-end tests. |
Advanced Configuration
To add, modify, or customize commands and flags, update the routes
object in routes.ts
. Each route is structured as follows:
export const routes: { [key: string]: { [key: string]: { flag: string, command: string, func: (command: string) => Promise<void> } }[] }[] = [
{
[YgbGroupCommands.generate]: [
{
component: {
flag: '-c',
command: 'ng generate component ${componentName}',
func: (command: string) => component(command)
}
},
// More commands...
]
},
// More groups...
];
In this structure:
- flag: The shorthand used to execute the command.
- command: The Angular CLI command template.
- func: The function executed to run the command.
Notes
- Ensure
command
strings use template literals where applicable to inject names or other parameters (e.g.,${componentName}
). - To implement a custom function, add it to the
functions
folder and import it into the routes file.
This setup allows for flexibility in configuring commands and functions, ensuring that ygb
can adapt to various Angular project requirements.