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

Commit 1dc8f54

Browse files
Merge pull request #141 from topcoder-platform/qa
PROD-2087 Platform MVP Prod Deployment 2022-06-01 qa -> master
2 parents 4c51bb0 + 367bdf9 commit 1dc8f54

File tree

14 files changed

+2624
-25001
lines changed

14 files changed

+2624
-25001
lines changed

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
10.22.1
1+
14.19.2

README.md

Lines changed: 212 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,83 @@
22

33
This is a [single-spa](https://single-spa.js.org/) microapp which shows the main top bar for Topcoder websites and handles user authorization.
44

5-
> NOTE. This application have been configured to be run as child app of a single-spa application. So while this app can be deployed and run independently, we would need some frame [single-spa](https://single-spa.js.org/) which would load it. While technically we can achieve running this app as standalone app it's strongly not recommended by the author of the `single-spa` approch, see this [GitHub Issue](https://github.com/single-spa/single-spa/issues/640) for details.
5+
> **NOTE:** This application has been configured to be run as child app of a single-spa application. So while this app can be deployed and run independently, we would need some frame [single-spa](https://single-spa.js.org/) which would load it. While technically we can achieve running this app as standalone app it's strongly not recommended by the author of the `single-spa` approch, see this [GitHub Issue](https://github.com/single-spa/single-spa/issues/640) for details.
6+
7+
>**NOTE:** To successfully run this application, you must first run the `mfe-core` app. Please see its corresponding README for instructions.
68
79
## Requirements
810

911
- node - v10.22.1
1012
- npm - v6.14.6
1113

14+
## Local Environment Setup
15+
16+
### IDE
17+
18+
Use the [VS Code](https://code.visualstudio.com/download) IDE for MFE development.
19+
20+
### NVM
21+
Use the node version manager [nvm](https://github.com/nvm-sh/nvm/blob/master/README.md) to easily and safely manage the required version of NodeJS (aka, node). Download and install it per the instructions for your development operating system. Installing a version of node via `nvm` will also install `npm`.
22+
23+
Once nvm is installed, run:
24+
```
25+
$ nvm install <insert node version>
26+
```
27+
28+
>**NOTE:** the node version required at the time of this writing is `10.22.1`
29+
30+
At the root of the project directory you'll notice a file called `.nvmrc` which specifies the node version used by the project. The command `nvm use` will use the version specified in the file if no version is supplied on the command line.
31+
See [the nvm Github README](https://github.com/nvm-sh/nvm/blob/master/README.md#nvmrc) for more information on setting this up.
32+
33+
You can verify the versions of `nvm`, `node`, and `npm` using the commands below.
34+
| Command | Supported Version |
35+
| ----------------- | -------- |
36+
| `$ npm -v` | 6.14.6 |
37+
| `$ node -v` | v10.22.1 |
38+
| `$ nvm --version` | 0.39.1 |
39+
| `$ nvm current` | v10.22.1 |
40+
41+
### Hosting
42+
You will need to add the following line to your hosts file. The hosts file is normally located at `/etc/hosts` (Mac). Do not overwrite the existing localhost entry also pointing to 127.0.0.1.
43+
44+
```
45+
127.0.0.1 local.topcoder-dev.com
46+
```
47+
48+
The MFE can run in a non-ssl environment, but auth0 will complain and throw errors. In order to bypass this, you will need to install [local-ssl-proxy](https://www.npmjs.com/package/local-ssl-proxy) to run the site in ssl. The following command will install it globally:
49+
```
50+
$ npm i -g local-ssl-proxy
51+
```
52+
53+
### Terminal Configuration
54+
55+
This navbar app needs to run a server and SSL proxy, each on a separate terminal session. The MFE Core Frame also needs to run two separate terminal sessions for its local server and client processes. Finally, each of the other micro front-end applications you want to run will also each run in their own terminal session.
56+
57+
When developing one of the micro front-end applications you will therefore have 5 terminal sessions running at the same time:
58+
59+
- `mfe-core` server
60+
- `mfe-core` client
61+
- `mfe-header` application
62+
- `local-ssl-proxy` server
63+
- the MFE app you're developing
64+
65+
Given this complexity, it is recommended that you use a tool like [iTerm2](https://iterm2.com) (on Mac) or an equivalent terminal shell on Windows to make terminal management simpler. iTerm2 allows you to setup a pre-defined window layout of terminal sessions, including the directory in which the session starts. This setup, along with simple shell scripts in each project that configure and start the environment, will allow you to get your development environment up and running quickly and easily.
66+
67+
## Git
68+
### Branching
69+
When working on Jira tickets, we link associated Git PRs and branches to the tickets. Use the following naming convention for branches:
70+
71+
`[TICKET #]_short-description`
72+
73+
e.g.: `PROD-1516_work-issue`
74+
75+
### Commits
76+
We use [Smart Commits](https://bigbrassband.com/git-integration-for-jira/documentation/smart-commits.html#bbb-nav-basic-examples) to link comments and time tracking to tickets. You would enter the following as your commit message:
77+
78+
`[TICKET #] #comment <commit message> #time <jira-formatted time>`
79+
80+
e.g.: `PLAT-001 #comment adding readme notes #time 45m`
81+
1282
## Config
1383

1484
There are 2 config file for production and development environment in the `config` folder.
@@ -19,6 +89,8 @@ Set environment variable `APPENV=dev` to use development config, or `APPENV=prod
1989
| Command | Description |
2090
| --------------------- | ----------------------------------------------------------------- |
2191
| `npm start` | Run server which serves production ready build from `dist` folder |
92+
| `npm start-local` | Run the application locally |
93+
| `npm start-local-proxy` | Run the local SSL proxy |
2294
| `npm run dev` | Run app in the development mode |
2395
| `npm run dev-https` | Run app in the development mode using HTTPS protocol |
2496
| `npm run build` | Build app for production and puts files to the `dist` folder |
@@ -31,11 +103,27 @@ Set environment variable `APPENV=dev` to use development config, or `APPENV=prod
31103

32104
## Local Deployment
33105

34-
Inside the project folder run:
106+
To run the app locally, run the following commands from the project root `./mfe-header`:
35107

36-
- `npm i` - install dependencies
37-
- `npm run dev` - run app in development mode
38-
- As this app can be loaded only inside a frame single-spa, you have to run a `mfe-core` frame app and configure it to use the URL `http://localhost:8080/topcoder-mfe-header.js`.
108+
**macOS**
109+
110+
Terminal 1:
111+
```
112+
$ npm run start-local
113+
```
114+
115+
Terminal 2:
116+
```
117+
$ npm run start-local-proxy
118+
```
119+
120+
**Windows**
121+
122+
Copy the contents of the Bash scripts `start-local.sh` and `start-local-proxy.sh` and paste them in two separate Command Prompts.
123+
124+
The site should now be available at https://local.topcoder-dev.com
125+
126+
>**NOTE:** To successfully run this application, you must first run `mfe-core`. Please see its corresponding README for instructions.
39127
40128
## Deployment to Production
41129

@@ -136,3 +224,122 @@ For example see https://github.com/topcoder-platform/micro-frontends-angular-app
136224
```
137225

138226
3. TODO: How to make e2e tests work for Angular? So far they fail with error `Module not found: Error: Can't resolve '@topcoder/mfe-header'`
227+
228+
## Linting
229+
230+
We use linting to enforce standardization. Please make sure all lint rules pass before creating PRs.
231+
232+
Use the following command to check for lint errors:
233+
```
234+
$ npm run lint
235+
```
236+
237+
## Styling
238+
239+
We use [Sass](https://sass-lang.com/) for styling, which is a preprocessor scripting language that compiles to CSS and allows for the use of variables, nested rules, mixins, functions, etc.
240+
241+
**Variables** can be used to store any CSS value that you want to reuse throughout your stylesheets. Variables are prefixed with the $ symbol.
242+
243+
e.g. styles.scss
244+
```
245+
$primary-color: #333;
246+
247+
body {
248+
color: $primary-color;
249+
}
250+
```
251+
252+
**Mixins** let you create groups of CSS declarations that you want to reuse throughout your site. You can also pass in values to make your mixin more flexible, and you call them using `@include`.
253+
254+
e.g. styles.scss
255+
```
256+
@mixin theme($theme: DarkGray) {
257+
background: $theme;
258+
color: #fff;
259+
}
260+
261+
.info {
262+
@include theme;
263+
}
264+
.alert {
265+
@include theme($theme: DarkRed);
266+
}
267+
```
268+
269+
Shared stylesheets are located in `src/styles/`. We use variables and mixins for handling padding, colors and breakpoints in the application, among others. To reference these in your SCSS files, simply add the following line at the top of your file.
270+
271+
```
272+
@import '[path to]/styles';
273+
```
274+
275+
### Colors
276+
277+
Colors are defined as variables in `src/styles/_variables.scss`.
278+
279+
### Breakpoints
280+
281+
Breakpoint mixins (mobile and desktop) are defined in `src/styles/_mixins.scss` and can be used to apply different styling based on the screen width.
282+
283+
Here is an example that applies a different height value than the default to a css class selector if the screen is considered that of a mobile device (max 1199px).
284+
285+
_mixins.scss
286+
```
287+
@mixin mobile {
288+
@media (max-width: 1199px) {
289+
@content;
290+
}
291+
}
292+
```
293+
294+
example.scss
295+
```
296+
@import '../styles';
297+
298+
.example {
299+
height: 100px;
300+
@include mobile {
301+
height: 50px;
302+
}
303+
}
304+
```
305+
306+
### Topcoder UI Kit
307+
Additionally, this site uses the [Topcoder UI Kit](https://www.npmjs.com/package/tc-ui), which houses Topcoder's style guide and component library. Please see [here](https://app.frontify.com/d/zEXqGHFD1YN2/ui-library) for additional documentation.
308+
309+
## Icons
310+
311+
### Custom SVGs
312+
Custom SVGs can be imported and used directly as a React component. Save your SVG in its own file within `src/assets/icons` or `src/assets/images`, and then import the SVG as a React component.
313+
314+
e.g.:
315+
```
316+
import IconNotificationWarning from "../../../assets/icons/notification-warning.svg";
317+
318+
...
319+
320+
return (
321+
<div>
322+
<IconNotificationWarning className={className}>
323+
</div>
324+
)
325+
```
326+
327+
### Styling Icons
328+
329+
You can style an SVG icon by overwritting its properties with CSS (height, width, fill, etc.).
330+
331+
e.g.:
332+
```
333+
.logo-link {
334+
svg {
335+
width: calc($pad-xxl + $pad-xxxxl);
336+
height: $pad-xl;
337+
fill: none;
338+
339+
path {
340+
fill: $tc-white;
341+
}
342+
}
343+
}
344+
```
345+

0 commit comments

Comments
 (0)