|
| 1 | +# Work Manager Dev Guide |
| 2 | + |
| 3 | +The Work Manager is a part of the Topcoder website for creating and managing challenges. This document covers the Windows 10, Linux and MacOS setup of the development environment in detail. |
| 4 | + |
| 5 | +## Local setup for work manager |
| 6 | + |
| 7 | +### Install VS Code |
| 8 | + |
| 9 | +[https://code.visualstudio.com/Download](https://code.visualstudio.com/Download) |
| 10 | + |
| 11 | +You can use the default options when installing VS Code. |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +### Install Git |
| 16 | + |
| 17 | +Before you begin contributing to the project, you'll need to have Git installed on your local machine. It’s essential for working in the community and contributing to the repository. |
| 18 | + |
| 19 | +Follow the installation guides below for your operating system: |
| 20 | + |
| 21 | +#### For Windows: |
| 22 | + |
| 23 | +1. **Download the Git Installer:** |
| 24 | + - Visit the [Windows Git Installation Guide](https://git-scm.com/downloads/win). |
| 25 | + - Click the link to download the Git installer. |
| 26 | + |
| 27 | +2. **Run the Installer:** |
| 28 | + - Launch the downloaded installer and follow the installation wizard. You can usually accept the default settings, but make sure to select the option to add Git to your system PATH during installation. This makes Git accessible from any command prompt window. |
| 29 | + |
| 30 | +3. **Verify the Installation:** |
| 31 | + - After installation is complete, open a command prompt or Git Bash and type the following command to check if Git was installed correctly: |
| 32 | + ``` |
| 33 | + git --version |
| 34 | + ``` |
| 35 | + - If Git is installed properly, you’ll see a version number displayed. |
| 36 | +
|
| 37 | +#### For Linux: |
| 38 | +
|
| 39 | +1. **Install Git via Package Manager:** |
| 40 | + - Most Linux distributions come with Git available in their package manager. You can install it by running one of the following commands based on your distribution: |
| 41 | + |
| 42 | + **For Ubuntu/Debian-based systems:** |
| 43 | + ``` |
| 44 | + sudo apt update |
| 45 | + sudo apt install git |
| 46 | + ``` |
| 47 | +
|
| 48 | + **For Fedora:** |
| 49 | + ``` |
| 50 | + sudo dnf install git |
| 51 | + ``` |
| 52 | +
|
| 53 | + **For CentOS/RHEL:** |
| 54 | + ``` |
| 55 | + sudo yum install git |
| 56 | + ``` |
| 57 | +
|
| 58 | +2. **Verify the Installation:** |
| 59 | + - Once Git is installed, open a terminal and run the following command to verify the installation: |
| 60 | + ``` |
| 61 | + git --version |
| 62 | + ``` |
| 63 | + - You should see the Git version number displayed in the terminal. |
| 64 | +
|
| 65 | +Make sure to check your installation after following these steps to confirm everything is set up correctly. |
| 66 | +
|
| 67 | +### Install NVM |
| 68 | +
|
| 69 | +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`. |
| 70 | +
|
| 71 | +> **NOTE:** If the nvm command is not working it might be because the installation failed to update your paths variable properly. To try and fix this try installing nvm again using sudo. |
| 72 | +Once nvm is installed, run: |
| 73 | +
|
| 74 | +```sh |
| 75 | +nvm install <insert node version> |
| 76 | +``` |
| 77 | + |
| 78 | +See [the nvm Github README](https://github.com/nvm-sh/nvm/blob/master/README.md#nvmrc) for more information on setting this up. |
| 79 | + |
| 80 | +To validate the nvm, node or npm versions, you can try this in terminal: |
| 81 | + |
| 82 | +```terminal |
| 83 | +nvm --version |
| 84 | +``` |
| 85 | + |
| 86 | +The output should look like this: |
| 87 | + |
| 88 | +```terminal |
| 89 | +copilot@DESKTOP-CEFAE6N MINGW64 ~ |
| 90 | +$ nvm --version |
| 91 | +0.39.1 |
| 92 | +
|
| 93 | +copilot@DESKTOP-CEFAE6N MINGW64 ~ |
| 94 | +$ |
| 95 | +``` |
| 96 | + |
| 97 | +### Hosts file update |
| 98 | + |
| 99 | +For windows, open the file `C:\Windows\System32\drivers\etc\hosts` in VS Code. We will add these two lines to the end of the file: |
| 100 | + |
| 101 | +```sh |
| 102 | +127.0.0.1 local.topcoder-dev.com |
| 103 | +127.0.0.1 local.topcoder.com |
| 104 | +``` |
| 105 | + |
| 106 | +You will need to save the file using admin privileges. The final file should look like this: |
| 107 | + |
| 108 | +```sh |
| 109 | +# Copyright (c) 1993-2000 Microsoft Corp. |
| 110 | +# |
| 111 | +# This is a sample HOSTS file used by Microsoft TCP/IP for Windows |
| 112 | +# |
| 113 | +# This file contains the mappings of iP addresses to host names. |
| 114 | +# entry should be kept on an individual line. The IP address should |
| 115 | +# be placed in the first column followed by the corresponding hosts |
| 116 | +# The IP address and the host name should be separated by at least |
| 117 | +# space. |
| 118 | +# |
| 119 | +# Additionaly, comments (such as these) may be inserted on individual |
| 120 | +# lines or following the machine name denoted by a '#' symbol. |
| 121 | +# |
| 122 | +# For example: |
| 123 | +# |
| 124 | +# 102.54.94.97 rhino.acme.com # source server |
| 125 | +# 38.25.63.10 x.acme.com # x client host |
| 126 | + |
| 127 | +# localhost name resolution is handled within DNS itself. |
| 128 | +# 127.0.0.1 localhost |
| 129 | +# ::1 localhost |
| 130 | +127.0.0.1 local.topcoder-dev.com |
| 131 | +127.0.0.1 local.topcoder.com |
| 132 | +``` |
| 133 | + |
| 134 | +For mac and linux, the hosts file is normally located at `/etc/hosts` and we add the same two lines to that file as well. |
| 135 | + |
| 136 | +This is how it should like: |
| 137 | + |
| 138 | +```sh |
| 139 | +## |
| 140 | +# Host Database |
| 141 | +# |
| 142 | +# localhost is used to configure the loopback interface |
| 143 | +# when the system is booting. Do not change this entry. |
| 144 | +## |
| 145 | +127.0.0.1 localhost |
| 146 | +255.255.255.255 broadcasthost |
| 147 | +::1 localhost |
| 148 | +127.0.0.1 local.topcoder-dev.com |
| 149 | +127.0.0.1 local.topcoder.com |
| 150 | +``` |
| 151 | + |
| 152 | +### Check out the code |
| 153 | + |
| 154 | +Now that all dependencies are set up, we can check out the code. Note that this command will check out the work-manager source code into a directory named `work-manager`. |
| 155 | + |
| 156 | +Run this command on the Git Bash command line: |
| 157 | + |
| 158 | +```terminal |
| 159 | +git clone https://github.com/topcoder-platform/work-manager.git |
| 160 | +``` |
| 161 | + |
| 162 | +```terminal |
| 163 | +copilot@DESKTOP-CEFAE6N MINGW64 |
| 164 | +$ git clone https://github.com/topcoder-platform/work-manager.git |
| 165 | +Cloning into 'work-manager'... |
| 166 | +remote: Enumerating objects: 9974, done. |
| 167 | +remote: Counting objects: 100% (1507/1507), done. |
| 168 | +remote: Compressing objects: 100% (507/507), done. |
| 169 | +remote: Total 9974 (delta 1162), reused 1027 (delta 1000), pack-reused 8467 (from 3) |
| 170 | +Receiving objects: 100% (9974/9974), 4.89 MiB | 2.82 MiB/s, done. |
| 171 | +Resolving deltas: 100% (6727/6727), done. |
| 172 | +
|
| 173 | +copilot@DESKTOP-CEFAE6N MINGW64 ~ |
| 174 | +$ |
| 175 | +``` |
| 176 | + |
| 177 | +### Build and run the code |
| 178 | + |
| 179 | +Now that we have the code, we can build it on the VS code terminal. |
| 180 | +The first `cd community-app` command just changes us to the directory we created above, after the code was cloned. |
| 181 | +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. |
| 182 | + |
| 183 | +* `cd work-manager` |
| 184 | +* `nvm use` will warn you to install v12.17.0 |
| 185 | +* `nvm install v12.17.0` |
| 186 | + |
| 187 | +```terminal |
| 188 | +$nvm use |
| 189 | +Found '/c/Users/copilot/work-manager/.nvmrc' with version <12.17.0> |
| 190 | +Now using node v12.17.0 (npm v6.14.4) |
| 191 | +``` |
| 192 | + |
| 193 | +Once we have the proper Node version installed (12.17.0), we will install the dependencies: |
| 194 | + |
| 195 | +```terminal |
| 196 | +npm i |
| 197 | +``` |
| 198 | +Once the dependencies have installed we run the app: |
| 199 | +```terminal |
| 200 | +npm run dev |
| 201 | +``` |
| 202 | + |
| 203 | + |
| 204 | +### Install the proxy and run it |
| 205 | + |
| 206 | +We need to proxy `https` requests through a local proxy since we don't have a valid SSL key. To do this, we use the `local-ssl-proxy` package. You can install this using this command. |
| 207 | + |
| 208 | +* `npm i -g local-ssl-proxy` You only have to run this once to install the package |
| 209 | +* `local-ssl-proxy -n local.topcoder-dev.com -s 443 -t 3000` Every time you want to run the proxy or work on the community app, you will need to run. You will need to grant the proxy admin access. |
| 210 | + |
| 211 | +**NOTE** - You should run the proxy in a *separate* terminal window, to ensure it's always running. |
| 212 | + |
| 213 | +```terminal |
| 214 | +$ npm i -g local-ss1-proxy |
| 215 | +npm WARN deprecated [email protected]: Package no longer supported. contact [email protected] for more info. |
| 216 | +npm WARN notice [SECURITY] underscore has the following vulnerability: 1 high. Go here for more details: https://github.com/advisories?query=underscore - Run `npm i npm@latest -g` to upgrade your pm version, and then `npm audit` to get more info. |
| 217 | +c:\users\copilot\.num\versions\node\v8.11.2\bin\local-ss1-proxy |
| 218 | +-> |
| 219 | +C:\Users\copilot\.nvm\versions\node\v8.11.2\bin\node_modules\local-ssl-proxy\bin\local-ssl-proxy + [email protected] |
| 220 | +added 18 packages in 3.321s |
| 221 | +
|
| 222 | +copilot@DESKTOP-CEFAE6N MINGW64 ~ |
| 223 | +$ local-ss1-proxy -n local.topcoder-dev.com -s 443 -t 3000 |
| 224 | +Started proxy: https://local.topcoder-dev.com: 443 -> http://local.topcoder-dev.com:3000 |
| 225 | +``` |
| 226 | + |
| 227 | +### Validation |
| 228 | + |
| 229 | +To validate, we'll run Chrome without web security to avoid it complaining about the local proxy redirects. It will redirect you the login page where you can use the sample test user to login. |
| 230 | + |
| 231 | +* Sample test user: `jcori` / `Appirio123` |
0 commit comments