From 5f7bb623d9eb7d23fe717130e3a780f1ba66970e Mon Sep 17 00:00:00 2001 From: Luis Valgoi Date: Mon, 21 Sep 2020 13:55:56 -0300 Subject: [PATCH 1/3] chore: added env for start as well --- .env | 1 - .env.development | 2 ++ .env.production | 2 ++ package.json | 4 ++-- template.json | 4 ++-- 5 files changed, 8 insertions(+), 5 deletions(-) delete mode 100644 .env create mode 100644 .env.development create mode 100644 .env.production diff --git a/.env b/.env deleted file mode 100644 index 9bd8a0f..0000000 --- a/.env +++ /dev/null @@ -1 +0,0 @@ -REACT_APP_API_URL=http://localhost:3001/api diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..8dbddf4 --- /dev/null +++ b/.env.development @@ -0,0 +1,2 @@ +REACT_APP_BASE_URL_STATE=http://localhost:3001/ +REACT_APP_BASE_URL_PATH=api diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..976e61c --- /dev/null +++ b/.env.production @@ -0,0 +1,2 @@ +REACT_APP_BASE_URL_STATE=/ +REACT_APP_BASE_URL_PATH=api diff --git a/package.json b/package.json index b204213..523fc4e 100644 --- a/package.json +++ b/package.json @@ -70,8 +70,8 @@ }, "scripts": { "build": "react-scripts build", - "mock": "env-cmd -f .env npm-run-all --parallel start:mock start:react", - "start": "env-cmd -f .env npm-run-all --parallel start:react", + "mock": "env-cmd -f .env.development npm-run-all --parallel start:mock start:react", + "start": "env-cmd -f .env.production npm-run-all --parallel start:react", "start:react": "react-scripts start", "start:mock": "nodemon --watch server/data --exec npx json-server --p 3001 server/mockserver.js --routes server/routes.json", "test": "react-scripts test --silent --env=jest-environment-jsdom-sixteen", diff --git a/template.json b/template.json index e8c6d1c..69d0529 100644 --- a/template.json +++ b/template.json @@ -36,8 +36,8 @@ }, "scripts": { "build": "react-scripts build", - "mock": "env-cmd -f .env npm-run-all --parallel start:mock start:react", - "start": "env-cmd -f .env npm-run-all --parallel start:react", + "mock": "env-cmd -f .env.development npm-run-all --parallel start:mock start:react", + "start": "env-cmd -f .env.production npm-run-all --parallel start:react", "start:react": "react-scripts start", "start:mock": "nodemon --watch server/data --exec npx json-server --p 3001 server/mockserver.js --routes server/routes.json", "test": "react-scripts test --silent --env=jest-environment-jsdom-sixteen", From 081ed889f6d6da01109e1f8c78f6168cb242a3dc Mon Sep 17 00:00:00 2001 From: Luis Valgoi Date: Mon, 21 Sep 2020 14:04:38 -0300 Subject: [PATCH 2/3] fix: equest engine to serve correctly --- src/util/Request.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/Request.js b/src/util/Request.js index 4e9f988..546d7b3 100644 --- a/src/util/Request.js +++ b/src/util/Request.js @@ -1,7 +1,7 @@ import axios from 'axios'; const Request = axios.create({ - baseURL: process.env.REACT_APP_API_URL, + baseURL: process.env.REACT_APP_BASE_URL_STATE + process.env.REACT_APP_BASE_URL_PATH, }); export default Request; From eccd0ac4de31b315f96d5d7b3d167198c025d198 Mon Sep 17 00:00:00 2001 From: Luis Valgoi Date: Mon, 21 Sep 2020 14:04:48 -0300 Subject: [PATCH 3/3] docs: readme --- README.md | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index c21c339..31e60f3 100644 --- a/README.md +++ b/README.md @@ -29,41 +29,41 @@ - `npx create-react-app PROJECT_NAME --template ui5-webcomponents-react-seed`; - cd into `PROJECT_NAME`; - (no need to run `yarn install` since it already installs it for you); -- run the available scripts; +- run the available scripts. PS.: It is important to add the `--template ui5-webcomponents-react-seed` at the end to get our template. # Configuration Included -- JEST Up & Runnning. +- JEST Up & Runnning; -- ESLint & EditorConfig Up & Running. +- ESLint & EditorConfig Up & Running; -- CommitLint Up & Running. +- CommitLint Up & Running; -- Enviroment Variables Up & Running. +- Enviroment Variables Up & Running; -- Internalization Up & Running. +- Internalization Up & Running; -- PR Template. +- PR Template; -- IE Support. +- IE Support; - Multiple Scripts. # Engine Included -- Fallback Engine (``, `` and ``). +- Fallback Engine (``, `` and ``); -- MockServer Engine (w/ `json-server`). +- MockServer Engine (w/ `json-server`); -- HTTP Request Engine (w/ `Request` and `URLProvider`). +- HTTP Request Engine (w/ `Request` and `URLProvider`); -- Permission Engine (w/ `RouteValidator` and `ComponentValidator`) +- Permission Engine (w/ `RouteValidator` and `ComponentValidator`). # Hooks Included -- `useRequest`: Which includes `get`, `post`, `patch`, `delete`, `put` HTTP helpers. +- `useRequest`: Which includes `get`, `post`, `patch`, `delete`, `put` HTTP helpers; - `useAuthority`: Which includes `hasAccess` helpers. @@ -75,7 +75,9 @@ In the project directory, you can run: ### `yarn start` -Runs the app in the development mode @ [http://localhost:3000](http://localhost:3000) (⚠️ currently not supported). +Runs the app in the development mode @ [http://localhost:3000](http://localhost:3000). + +⚠️ It requires an AppRouter or a BackEnd up & running @ `:/api`. ### `yarn mock`