From 09e24464162ccb2a68b83aba30b44b392fabef83 Mon Sep 17 00:00:00 2001 From: Richard Zampieri Date: Sun, 4 Aug 2024 00:07:52 -0700 Subject: [PATCH] refactor: update cli 1.11.1 --- docs/cli/generate.md | 52 +--- docs/cli/overview.md | 162 ++++++++++- docs/overview/application.md | 20 +- docs/overview/expressots-config.md | 63 +++++ docs/providers/prisma.mdx | 235 ++++++++-------- .../current/cli/generate.md | 74 ++--- .../current/cli/overview.md | 170 ++++++++++-- .../current/overview/application.md | 20 +- .../current/overview/expressots-config.md | 59 ++++ .../current/providers/prisma.mdx | 254 +++++++++--------- package-lock.json | 58 ++-- package.json | 12 +- 12 files changed, 751 insertions(+), 428 deletions(-) create mode 100644 docs/overview/expressots-config.md create mode 100644 i18n/pt/docusaurus-plugin-content-docs/current/overview/expressots-config.md diff --git a/docs/cli/generate.md b/docs/cli/generate.md index b48cb6a9..2aaae698 100644 --- a/docs/cli/generate.md +++ b/docs/cli/generate.md @@ -13,20 +13,20 @@ This command allows developers to stay ahead of the curve by generating the boil The generate command can be executed as follows: ```bash -expressots generate +expressots generate [options] ``` Or in its short form: ```bash -expressots g +expressots g [options] ``` ### Command Structure We provide two different structures to scaffold the resources: -- **[entity-action]**: `expressots generate service user-create` +- **[shorthand]**: `expressots generate service user-create` This will create this folder structure: `/user/create` and the file: `user-create.[resource].ts` - **[folder/subfolder/resource]**: `expressots generate service user/create` @@ -58,49 +58,19 @@ Current available resources: All resources can be created using the structure `folder/subfolder/resource`. -## Scaffolding using hyphenated names +## Scaffolding Using Shorthand Operation -For services, you can take advantage of creating the use case, controller and DTO at once using the structure `entity_action` or `entity-action`. Example: `expressots g s user-create`. +For services, you can take advantage of creating the use case, controller and DTO at once using the structure `entity_action` or `entity-action`. Example: -:::info -The `expressots.config.ts` configuration file, located in the project root folder, determines where all resources will be created. -::: - -## ExpressoTS Config File - -The configuration file is located in the root folder of the project and it's called `expressots.config.ts`. This file is used to configure the CLI and the project. - -Here is the current configuration file with all the available options: - -```typescript -import { ExpressoConfig, Pattern } from "@expressots/core"; - -const config: ExpressoConfig = { - sourceRoot: "src", - scaffoldPattern: Pattern.KEBAB_CASE, - opinionated: true, - scaffoldSchematics: { - entity: "entity", - provider: "provider", - module: "module", - controller: "controller", - dto: "dto", - middleware: "middleware", - usecase: "useCases", - }, -}; - -export default config; +```bash +expressots g s user-create ``` -- **sourceRoot**: the root folder that will be used by the CLI to create the resources. Default: `src` -- **scaffoldPattern**: the pattern that will be used to create the resources. Default: `Pattern.KEBAB_CASE`. Example: `user-create` -- **opinionated**: if true, the CLI will create the resources using the opinionated folder structure -- **scaffoldSchematics**: the folder convention names for each resource. Default: `useCases`, `entities`, `providers`, `middlewares`, `controllers`, `dtos` - -## Recommendations +:::info +The `expressots.config.ts` configuration file, located in the project root folder, determines where all resources will be created. Also determine the resource names for each type of resource. +::: -Try to use as many different forms of creating resources as possible. This will help you to understand how the CLI works and how to use it in your favor. It also helps us improve the CLI to make it more robust. +Read more about the [ExpressoTS Config File](/docs/overview/expressots-config.md). --- diff --git a/docs/cli/overview.md b/docs/cli/overview.md index 7b79ad55..b6e875b4 100644 --- a/docs/cli/overview.md +++ b/docs/cli/overview.md @@ -4,10 +4,10 @@ sidebar_position: 1 # Overview -The ExpressoTS CLI is a command-line interface tool that helps you to `create` ExpressoTS projects and `scaffold` the application resources such as use cases, controllers, dto's, providers and services. +ExpressoTS CLI is a command-line interface tool that helps you to `create` ExpressoTS projects and `scaffold` ExpressoTS resources. :::info -We use the `npm` package manager in this tutorial, but you can use your favorite package manager, such as `yarn` or `pnpm`. +We use the `npm` package manager in this tutorial for simplicity. However, you can use `yarn` or `pnpm` as well. ::: ## Installation @@ -18,7 +18,28 @@ First install the CLI globally using the command below: npm install -g @expressots/cli ``` -## Basic usage +## Commands Available + +| Name | Alias | Description | +| ----------- | ------ | ----------------------------------------------------- | +| new project | new | Generate a new project | +| info | i | Provides project information | +| resources | r | Displays CLI commands and resources | +| help | h | Show command help | +| service | g s | Generate a service [controller, usecase, dto, module] | +| controller | g c | Generate a controller | +| usecase | g u | Generate a usecase | +| dto | g d | Generate a DTO | +| entity | g e | Generate an entity | +| provider | g p | Generate internal provider | +| provider | add | Add external provider to the project | +| provider | create | Create external provider | +| module | g mo | Generate a module | +| middleware | g mi | Generate a middleware | + +## Usage Examples + +The CLI has the following syntax: ```bash expressots [options] @@ -29,7 +50,7 @@ expressots [options] Verify the available commands and options: ```bash -expressots --help +expressots help ``` ### Info @@ -37,7 +58,7 @@ expressots --help Providers information about your Operational System, Project and CLI version: ```bash -expressots info or i +expressots info ``` ### Resources list @@ -45,12 +66,10 @@ expressots info or i List all available resources to scaffold: ```bash -expressots resources or r +expressots resources (Alias: r) ``` -![Resources](../overview/img/scaffold-resources.png) - -## Create a Project +### Create a Project There are two options to create a new project, interactively or silently (passing the options as arguments). Here is the complete command syntax: @@ -59,13 +78,13 @@ Here is the complete command syntax: expressots new -p -t