Skip to content

Commit

Permalink
Merge pull request #65 from expressots/feature/add-versions
Browse files Browse the repository at this point in the history
Feature/add versions
  • Loading branch information
rsaz authored Nov 26, 2024
2 parents c6eef65 + bf6455a commit 1a74eed
Show file tree
Hide file tree
Showing 101 changed files with 13,101 additions and 2,141 deletions.
18 changes: 18 additions & 0 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ const config: Config = {
remarkPlugins: [
[require("@docusaurus/remark-plugin-npm2yarn"), { sync: true }],
],
lastVersion: "3.0.0",
versions: {
current: {
label: "NEXT",
},
"3.0.0": {
label: "3.0.0",
},
"2.16.2": {
label: "2.16.2",
},
},
},
theme: {
customCss: require.resolve("./src/css/custom.css"),
Expand Down Expand Up @@ -75,6 +87,12 @@ const config: Config = {
position: "right",
label: "Governance",
},
{
type: "docsVersionDropdown",
label: "latest",
position: "right",
dropdownActiveClassDisabled: true,
},
{
href: "https://github.com/expressots/expressots",
position: "right",
Expand Down
6,553 changes: 4,440 additions & 2,113 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 13 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,27 @@
"serve": "docusaurus serve",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids",
"version": "npx docusaurus docs:version next_version",
"cache": "npx docusaurus cache clear",
"typecheck": "tsc"
},
"dependencies": {
"@docusaurus/core": "^3.5.2",
"@docusaurus/preset-classic": "^3.5.2",
"@docusaurus/remark-plugin-npm2yarn": "^3.5.2",
"@docusaurus/theme-mermaid": "^3.5.2",
"@mdx-js/react": "3.0.1",
"axios": "^1.7.5",
"@docusaurus/core": "^3.6.3",
"@docusaurus/preset-classic": "^3.6.3",
"@docusaurus/remark-plugin-npm2yarn": "^3.6.3",
"@docusaurus/theme-mermaid": "^3.6.3",
"@mdx-js/react": "3.1.0",
"axios": "1.7.8",
"clsx": "2.1.1",
"mermaid": "10.9.1",
"prism-react-renderer": "2.3.1",
"mermaid": "10.9.2",
"prism-react-renderer": "2.4.0",
"react": "18.3.1",
"react-dom": "18.3.1"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "^3.5.2",
"@docusaurus/tsconfig": "^3.5.2",
"@docusaurus/types": "^3.5.2",
"@docusaurus/module-type-aliases": "^3.6.3",
"@docusaurus/tsconfig": "^3.6.3",
"@docusaurus/types": "^3.6.3",
"@types/react": "18.3.3",
"typescript": "5.5.4"
},
Expand Down
14 changes: 0 additions & 14 deletions sidebars.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
import type { SidebarsConfig } from "@docusaurus/plugin-content-docs";

const sidebars: SidebarsConfig = {
// By default, Docusaurus generates a sidebar from the docs folder structure
tutorialSidebar: [{ type: "autogenerated", dirName: "." }],

// But you can create a sidebar manually
/*
tutorialSidebar: [
'intro',
'hello',
{
type: 'category',
label: 'Tutorial',
items: ['tutorial-basics/create-a-document'],
},
],
*/
};

export default sidebars;
8 changes: 8 additions & 0 deletions versioned_docs/version-2.16.2/cli/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "CLI",
"position": 3,
"link": {
"type": "generated-index",
"description": "Expresso TS CLI Tool Overview."
}
}
166 changes: 166 additions & 0 deletions versioned_docs/version-2.16.2/cli/generate.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
---
sidebar_position: 1
title: Generate
description: Scaffold ExpressoTS resources using the CLI.
---

import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";

# Generate

In order to provide a better developer experience, the ExpressoTS CLI provides a set of commands to help you scaffold the application resources such as use cases, controllers, DTO's, providers and services.

This command allows developers to stay ahead of the curve by generating the boilerplate code for the application, so they can focus on the business logic.

## Command syntax

One big advantage of the ExpressoTS CLI is the ability to scaffold resources using two different structures: the <span class="span-table">shorthand</span> and
the <span class="span-table">folder/subfolder/resource</span>. The shorthand operation is a more concise way to scaffold resources (recommended to be used in the opinionated template), while
the folder/subfolder/resource structure is more flexible and can be used in both templates.

The generate command can be executed as follows:

```bash
expressots generate <resource> <structure> [options]
```

Or in its short form:

```bash
expressots g <resource-alias> <structure> [options]
```

<Tabs>
<TabItem label="Non Opinionated" value="non-opinionated">
```bash title="Full form"
expressots generate service user/create
```

```bash title="Short form"
expressots g s user/create
```

</TabItem>
<TabItem label="Opinionated" value="opinionated">

```bash title="Full form"
expressots generate service user-create
```

```bash title="Short form"
expressots g s user-create
```

```bash title="Passing http parameter as option"
expressots g s user-create -m post
```

</TabItem>

</Tabs>

## Command structure

We provide two different structures to scaffold the resources, the **shorthand** and the **folder/subfolder/resource**.
These scaffold strategies work differently based on the project template used. The `opinionated` template provides a more structured project, while the `non-opinionated` template provides a more flexible project structure.

#### Using single name

```bash
expressots g c user
```

```bash title="Output"
src
└── user.controller.ts
```

#### Using the shorthand operation

```bash
expressots g c user-create
```

```bash title="Output"
src
└── user
└── create
└── user-create.controller.ts
```

#### Using the folder/subfolder/resource structure

```bash
expressots g c user/create
```

```bash title="Output"
src
└── user
└── create.controller.ts
```

If you add `/` at the end of the structure, the CLI will create the resource inside of the folder. Example: `expressots g c user/create/`

```bash title="Output"
src
└── user
└── create
└── create.controller.ts
```

:::info
Opinionated templates come with predefined folder structures for each resource type, ensuring that resources are always created in the following designated folders:

- useCases
- entities
- providers

:::

The root folder for all resources is the `src` folder. This can be changed in the `expressots.config.ts` file.

## Resource types

Resources available to be scaffolded are:

| Long form | short | Command | Expected result |
| ---------- | ----- | -------------------------- | ---------------------------------------------------------------------------------------- |
| usecase | u | expressots g u user/find | Use case to be created in the folder `useCases` with this folder structure: user/find |
| controller | c | expressots g c user/find | Controller to be created in the folder `useCases` inside of user/find |
| dto | d | expressots g d user/find | DTO to be created in the folder `useCases` inside of user/find |
| provider | p | expressots g p email/email | Provider to be created in the folder `providers` inside of user/find |
| service | s | expressots g s user/find | Service creates usecase, controller and DTO and add them in the desired folder user/find |
| entity | e | expressots g e user | Entity to be created in the folder `entities` with this folder structure: user |
| middleware | mi | expressots g mi auth | Middleware to be created in the folder `middlewares` with this folder structure: auth |
| module | mo | expressots g mo user | Module to be created in the folder where `controllers` and `usecases` are located |

For services, you can take advantage of creating the use case, controller and DTO at once.

```bash
expressots g s user-create
```

```bash title="Output for the non opinionated template"
src
└── user
└── create
β”œβ”€β”€ user-create.controller.ts
β”œβ”€β”€ user-create.dto.ts
β”œβ”€β”€ user-create.usecase.ts
└── user-create.usecase.ts
```

:::info
The `expressots.config.ts` file, located in the project root folder, defines where all resources will be created and specifies the naming conventions for each type of resource.
:::

Read more about the [ExpressoTS Config File](../features/expressots-config.mdx).

---

## Support us ❀️

ExpressoTS is an MIT-licensed open source project. It's an independent project with ongoing development made possible thanks to your support.
If you'd like to help, please read our **[support guide](../support-us.mdx)**.
Loading

0 comments on commit 1a74eed

Please sign in to comment.