Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 1d8afb1

Browse files
committed
docs: full local development guide
1 parent 67a21b3 commit 1d8afb1

File tree

7 files changed

+748
-201
lines changed

7 files changed

+748
-201
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,6 @@ dist
102102

103103
# TernJS port file
104104
.tern-port
105+
106+
# mac os cache files
107+
.DS_Store

README.md

+77-10
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ For application constants which don't depend on the running environment use `src
3939
| `npm run watch-tests` | Watch for file changes and run unit tests on changes |
4040
| `npm run coverage` | Generate test code coverage report |
4141

42-
## Local Deployment
43-
44-
Inside the project folder run:
45-
46-
- `npm i` - install dependencies
47-
- `npm run dev` - run app in development mode
48-
- As this app can be loaded only inside a frame single-spa, you have to run a `micro-frontends-frame` frame app and configure it to use the URL `http://localhost:8501/topcoder-micro-frontends-teams.js`.
49-
5042
## Deployment to Production
5143

5244
- `npm i` - install dependencies
@@ -65,6 +57,81 @@ Make sure you have [Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli
6557
- `git push heroku master` - push changes to Heroku and trigger deploying
6658
- Now you have to configure frame app to use the URL provided by Heroku like `https://<APP-NAME>.herokuapp.com/topcoder-micro-frontends-teams.js` to load this micro-app.
6759

68-
## Verification
60+
## How to run Locally for Development
61+
62+
TaaS App is done using Single SPA micro-frontend architecture https://single-spa.js.org/. So to start it, we would also have to run Frame App and Navbar App. Here I would show the steps to run locally everything we need.
63+
64+
### Local Authentication
65+
66+
First of all, to authenticate locally we have to run a local authentication service.
67+
- Clone this repository into `taas-app`.
68+
- Inside the folder `taas-app/local/login-locally` run `npm run start`.
69+
- You would need npm 5+ for it. This would start a local sever on port 5000 which could be used for local Authentication.
70+
71+
### Local Domain
72+
73+
Some config files are using domain `local.topcoder-dev.com`. You can change it to `localhost` in all the configs of each repo mentioned below. Or on your local machine, update file `/etc/hosts` add the line `127.0.0.1 local.topcoder-dev.com`. This file has another path on Windows.
74+
75+
### Run Applications
76+
77+
1. Run **Frame** App:
78+
```sh
79+
git clone https://github.com/topcoder-platform/micro-frontends-frame.git
80+
cd micro-frontends-frame
81+
82+
# inside folder "micro-frontends-frame" run:
83+
84+
nvm use # or make sure to use Node 10
85+
npm i # to install dependencies
86+
87+
# set environment variables:
88+
89+
export APPMODE="development"
90+
export APPENV="local-multi"
91+
92+
npm run local-server
93+
```
94+
95+
open one more terminal window in the same folder and run:
96+
97+
```sh
98+
# set environment variables:
99+
100+
export APPMODE="development"
101+
export APPENV="local-multi"
102+
103+
npm run local-client
104+
```
105+
106+
2. Run **Navbar** micro-app:
107+
```sh
108+
git clone https://github.com/topcoder-platform/micro-frontends-navbar-app.git
109+
cd micro-frontends-navbar-app
110+
```
111+
112+
Update in file `micro-frontends-navbar-app/blob/dev/config/dev.js` values for `ACCOUNTS_APP_CONNECTOR` and `AUTH` to `http://localhost:5000` so Navbar app which handles authentication uses our local Authentication service.
113+
114+
```sh
115+
# inside folder "micro-frontends-navbar-app" run:
116+
117+
nvm use # or make sure to use Node 10
118+
npm i # to install dependencies
119+
120+
npm run dev
121+
```
122+
123+
3. Run **TaaS** micro-app:
124+
```sh
125+
# inside folder "taas-app" run:
126+
127+
nvm use # or make sure to use Node 10
128+
npm i # to install dependencies
129+
130+
npm run dev
131+
```
132+
133+
- Now open in the browser http://localhost:8080/taas/myteams.
134+
- If you are not logged-in yet, you should be redirected to the login page.
135+
- If you cannot see the application and redirect doesn't happen, make sure that file "http://local.topcoder-dev.com:8501/taas-app/topcoder-micro-frontends-teams.js" is loaded successfully in the Network tab.
69136
70-
Please check [verification-guide.md](verification-guide.md)
137+
Congratulations, you successfully run the project. If you had some issue, please, try to go through README of https://github.com/topcoder-platform/micro-frontends-frame and https://github.com/topcoder-platform/micro-frontends-navbar-app.

local/login-locally/README

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
1. Run any static files server inside this directory, for example:
2+
- `npx http-server . -p 5000`
3+
- `php -S localhost:5000`
4+
2. Run your application on http://localhost:3000.
5+
3. Now you can open http://localhost:5000 in browser and click login (wait it a little bit, it may take time to redirect you). After you login, you should be redirected back to http://localhost:3000
6+
7+
PS. You may also download latest version of `setupAuth0WithRedirect.js` file from here - https://github.com/topcoder-platform/tc-auth-lib/blob/dev/web-assets/js/setupAuth0WithRedirect.js
8+
9+
10+
11+

local/login-locally/index.html

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<title>Auth0</title>
6+
<meta charset="utf-8" />
7+
<script language="javascript" type="text/javascript" src="./setupAuth0WithRedirect.js"></script>
8+
</head>
9+
10+
<body>
11+
Loaded...redirecting to auth0.(see browser console log)
12+
<script>
13+
window.onload = authSetup;
14+
</script>
15+
<a href="?retUrl=http://localhost:3000" >Login</a>
16+
</body>
17+
18+
</html>

local/login-locally/package.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "login-locally",
3+
"version": "1.0.0",
4+
"description": "Run any static files server inside this directory.",
5+
"scripts": {
6+
"start": "npx http-server . -p 5000"
7+
},
8+
"keywords": [],
9+
"author": "",
10+
"license": "ISC"
11+
}

0 commit comments

Comments
 (0)