Skip to content

Commit

Permalink
docs: modify docs to comply with new standard
Browse files Browse the repository at this point in the history
  • Loading branch information
Javimtib92 committed Jul 8, 2024
1 parent 59292bd commit 48a406d
Show file tree
Hide file tree
Showing 14 changed files with 191 additions and 154 deletions.
7 changes: 7 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
VITE_APP_API_URL=http://localhost:3000
VITE_APP_ANOTHER_API_URL=http://localhost:3000
VITE_APP_GRAPHQL_PROXY_ENDPOINT=https://graphqlzero.almansi.me
VITE_APP_REST_PROXY_ENDPOINT=https://jsonplaceholder.typicode.com
VITE_APP_SENTRY_DSN=project_dsn
VITE_APP_SENTRY_ENABLED=false
SENTRY_ENVIRONMENT=dev
7 changes: 7 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
VITE_APP_API_URL=http://localhost:3000
VITE_APP_ANOTHER_API_URL=http://localhost:3000
VITE_APP_GRAPHQL_PROXY_ENDPOINT=https://graphqlzero.almansi.me
VITE_APP_REST_PROXY_ENDPOINT=https://jsonplaceholder.typicode.com
VITE_APP_SENTRY_DSN=project_dsn
VITE_APP_SENTRY_ENABLED=false
SENTRY_ENVIRONMENT=dev
121 changes: 31 additions & 90 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,90 +1,31 @@

## Base Mr. Milu: React.js

### Index and features

- [Vite](https://github.com/vitejs/vite)
- Clean architecture
- Dependency Injection ([Inversify](https://github.com/inversify/InversifyJS))
- Typescript
- [Class transformers](https://github.com/typestack/class-transformer)
- [Zustand](https://github.com/pmndrs/zustand)
- [Apollo Client (GraphQL)](https://github.com/apollographql/apollo-client)
- [Commitlint](docs/comitlint.md) (with [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) config)
- [Vanilla extract](https://vanilla-extract.style/)
- ESLint (with TypeScript config)
- Prettier
- [Error boundary](docs/error_boundary.md)
- [react-i18next](docs/i18next.md) ([i18next react official documentation](https://react.i18next.com/))
- [Development proxy server](docs/dev_proxy.md)
- [React Router 6](https://reactrouter.com/en/main)
- Sentry

### Prerequisites

This project uses the following packages

- [nvm](https://github.com/nvm-sh/nvm) (Node version manager)
- [Just](https://just.systems/man/en/chapter_4.html) (For justfile usage)

Run the following command to install the node version declared in the `.nvmrc`
file for this project:

```shell
nvm install
```

Finally, enable [corepack](https://github.com/nodejs/corepack) so the correct
version of pnpm is used.

```shell
just corepack-enable
```

### First steps

**Install dependencies**

```shell
just install-deps
```

**Run project**

In one terminal shell

```shell
just dev
```

And in another shell

```shell
just ioc-generate-watch
```

**See a list of available commands**

```shell
just
```

**Proxy commands through nvm**

```shell
just nvm-exec "pnpm add @front_web_mrmilu/hooks"
```

### Environment variables

Create a `.env.development.local` file with your environment variables with the following defaults for dev server

```
VITE_APP_API_URL=http://localhost:3000
VITE_APP_ANOTHER_API_URL=http://localhost:3000
VITE_APP_GRAPHQL_PROXY_ENDPOINT=https://graphqlzero.almansi.me
VITE_APP_REST_PROXY_ENDPOINT=https://jsonplaceholder.typicode.com
VITE_APP_SENTRY_DSN=project_dsn
VITE_APP_SENTRY_ENABLED=false
SENTRY_ENVIRONMENT=dev
```
# React Base

Milú React base project

## Docs
- [Clean Architecture] (to include link to front.docs)
- [Commit Lint] (to include link to front.docs)
- [Craco](./docs/craco.md)
- [Dependencies](./docs/dependencies.md)
- [Development environment setup](./docs/dev-environment-setup.md)
- [Development proxy](./docs/dev-proxy.md)
- [Environment variables](./docs/environment-variables.md)
- [ErrorBoundary](./docs/error-boundary.md)
- [Internationalization](./docs/i18next.md)
- [Justfile Commands](./docs/justfile-commands.md)
- [Run development server](./docs/run-development-server.md)
- [Run production build](./docs/run-production-build.md)

## Versions

This project uses the following versions and has been tested in this context
(please check if that works with yours):

| Service | Version | Usage |
|------------|----------|--------------------|
| `node` | `20.x` | `*` |
| `pnpm` | `9.4.0` | `package.json` |
| `just` | `1.x` | `justfile` |

### Authors
By Milú
60 changes: 0 additions & 60 deletions docs/comitlint.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/craco.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## CRACO
# CRACO

CRACO stands for: **Create React App Configuration Override**. This boilerplate is created with CRA to get all the
benefits from `react-scripts`. The issue with CRA configured projects it's that, although they offer many out of the box
Expand Down
20 changes: 20 additions & 0 deletions docs/dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dependencies

## Relevant used dependencies

- [Vite](https://github.com/vitejs/vite)
- Clean architecture
- Dependency Injection ([Inversify](https://github.com/inversify/InversifyJS))
- Typescript
- [Class transformers](https://github.com/typestack/class-transformer)
- [Zustand](https://github.com/pmndrs/zustand)
- [Apollo Client (GraphQL)](https://github.com/apollographql/apollo-client)
- [Commitlint](docs/comitlint.md) (with [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) config)
- [Vanilla extract](https://vanilla-extract.style/)
- ESLint (with TypeScript config)
- Prettier
- [Error boundary](docs/error_boundary.md)
- [react-i18next](docs/i18next.md) ([i18next react official documentation](https://react.i18next.com/))
- [Development proxy server](docs/dev_proxy.md)
- [React Router 6](https://reactrouter.com/en/main)
- Sentry
34 changes: 34 additions & 0 deletions docs/dev-environment-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Dev environment setup

## Requirements
These are the requirements to run a development environment:

- [nvm](https://github.com/nvm-sh/nvm) (Node version manager)
- [just](https://github.com/casey/just)

## Steps

1. Run the following command to install the node version declared in the `.nvmrc` file for this project:

```shell
nvm install
```

2. Enable [corepack](https://github.com/nodejs/corepack) so the correct
version of [pnpm](https://pnpm.io/motivation) is used.

```shell
just corepack-enable
```

3. Install the project dependencies.

```shell
just install-deps
```

4. Generate the GQL schemas.

```shell
just graphql-codegen
```
2 changes: 1 addition & 1 deletion docs/dev_proxy.md → docs/dev-proxy.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Development Proxy
# Development Proxy

Due to the nature of front end development and their tooling (hot reload, bundlers, dependency installation)
most of the time our development server will run better in our local machines; in comparison with a docker environment.
Expand Down
30 changes: 30 additions & 0 deletions docs/environment-variables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Environment variables

> ℹ️ .env variables are loaded automatically by Vite. Refer to this documentation for more information. [Loading Environment Variables](https://vitejs.dev/guide/env-and-mode#env-files).
> Good to know: `.env`, `.env.development`, and `.env.production` files should be included in your repository as they define defaults. .env*.local should be added to .gitignore, as those files are intended to be ignored. .env.local is where secrets can be stored.
## Values

| Key | Responsible | Type | Secret | Policy | Default value | Description | Docs |
| --------------------------------- | ----------- | --------- | ------ | ------------------------- | ----------------------- | ---------------------------------- | ---------------------------------------------------------------------- |
| `VITE_APP_API_URL` | DevOps | `string` | No | `DEFAULT` | `http://localhost:3000` | GQL API URL URL |
| `VITE_APP_ANOTHER_API_URL` | DevOps | `string` | No | `DEFAULT` | `http://localhost:3000` | REST API URL URL | - |
| `VITE_APP_GRAPHQL_PROXY_ENDPOINT` | DevOps | `string` | No | `REQUIRED-IN-RELEASE-ENV` | - | GQL Proxy Endpoint URL | - |
| `VITE_APP_REST_PROXY_ENDPOINT` | DevOps | `string` | No | `REQUIRED-IN-RELEASE-ENV` | - | REST Proxy Endpoint DSN | |
| `VITE_APP_SENTRY_DSN` | DevOps | `string` | No | `REQUIRED-IN-RELEASE-ENV` | - | Sentry DSN | [Sentry DSN](https://docs.sentry.io/concepts/key-terms/dsn-explainer/) |
| `VITE_APP_SENTRY_ENABLED` | DevOps | `boolean` | No | `FEATURE-FLAG` | - | Enables/Disables Sentry monitoring | - |

## Policies
- `DEFAULT`: This environment variable has a default value that works on most common usages
- `REQUIRED`: This environment variable must be set, otherwise the application will not start throwing an exception
- `REQUIRED-IN-RELEASE-ENV`: This environment variable must be set in release environments, the application will start but won't comply requirements: security, functionality, integration, performance, etc
- `FEATURE-FLAG`: This environment variable changes a feature behavior
- `DEPRECATED`: Deprecated variables, see deprecated variables section

## Types
- `boolean`: string variable containing a boolean value
- `string`: string variable
- `fs_path`: string variable containing a path in the file system
- `email`: string variable containing an email
- `string-list-by-comma`: list string values extracted by: split (using `,` as the separator) and trim
2 changes: 1 addition & 1 deletion docs/error_boundary.md → docs/error-boundary.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Error boundaries
# Error boundaries

To avoid ui errors breaking the app and make it unusable we are going to implement error boundaries at
page level (in our routes object). This way we can guarantee if a page breaks the user can still navigate it's way out and the application
Expand Down
27 changes: 27 additions & 0 deletions docs/justfile-commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# React Base Justfile Commands 🦀 🚀

Run `just` to display the list of available commands.

## What is just?

`just` is a handy way to save and run project-specific commands. Commands, called recipes, are stored in a file called `justfile` with syntax inspired by `make`.

## Commands List

- `just corepack-enable`: Enables Corepack in Node.js.
- `just install-deps`: Installs the dependencies listed in the project's package.json.
- `just dev`: Starts the vite development server.
- `just debug`: Starts the vite debug server.
- `just build`: Builds the vite application.
- `just preview`: Builds the vite application in preview mode.
- `just clean`: Cleans the vite cache
- `just start`: Starts the server for the built Next.js application.
- `just prettier-fix:`: Runs formatting.
- `just ioc-generate`: Generates Inversify bindings.
- `just ioc-generate-watch`: Generates Inversify bindings and watches for changes.
- `just commit`: Commits changes using commitlint.
- `just graphql-codegen`: Downloads schema and generates corresponding ts types.
- `just e2e-run`: Runs E2E tests.
- `just e2e-open`: Runs E2E tests UI.
- `just commit`: Commit files using commitlint.
- `just nvm exec {{command}}`: Proxies a command through nvm. Replace `{{command}}` with the desired command to execute.
6 changes: 6 additions & 0 deletions docs/run-development-server.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Run development server

```shell
just ioc-generate-watch # in one terminal
just dev # in another
```
25 changes: 25 additions & 0 deletions docs/run-production-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Run production build

First generate the dependency injection files:
```shell
just ioc-generate
```

Then generate the graphql types:
```shell
just graphql-codegen
```

Next run a production build:

```shell
just build
```

Finally execute the `vite preview` server:

```shell
just preview
```

This command uses under the hood the `vite preview` command. For more information refer to [Deploying a Static Site](https://vitejs.dev/guide/static-deploy.html#deploying-a-static-site) documentation where `vite preview` is explained.
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ e2e-run:
e2e-open:
./nvm_exec.sh pnpm e2e:open

# Opens E2E tests UI
# Commits changes using commitlint.
commit:
./nvm_exec.sh pnpm commit

Expand Down

0 comments on commit 48a406d

Please sign in to comment.