2020-09-30 17:53:10 +00:00
## Running Client Codebase
2020-11-26 10:27:41 +00:00
2021-09-24 08:44:34 +00:00
Appsmith's client (UI/frontend) uses the ReactJS library and Typescript. The application also uses libraries like react-redux and redux-saga for workflows. We use VS Code Editor as our primary editor.
2020-10-05 04:05:23 +00:00
2021-07-09 10:24:34 +00:00
[](https://www.youtube.com/watch?v=FwJlVWVx0X0)
2020-09-30 17:53:10 +00:00
### Pre-requisites:
On your development machine, please ensure that:
1. You have `docker` installed in your system. If not, please visit: [https://docs.docker.com/get-docker/ ](https://docs.docker.com/get-docker/ )
2023-06-05 05:25:07 +00:00
1. You have `mkcert` installed. Please visit: [https://github.com/FiloSottile/mkcert#installation ](https://github.com/FiloSottile/mkcert#installation ) for details.
2024-06-04 07:56:09 +00:00
- For `mkcert` to work with Firefox, you may need to install the `nss` utility. Details are in the link above.
- On Linux, you can easily install `mkcert` using the following command
```
curl -s https://api.github.com/repos/FiloSottile/mkcert/releases/latest \
| grep "browser_download_url.*linux-amd64" \
| cut -d : -f 2,3 | tr -d \" \
| wget -i - -O mkcert
chmod +x mkcert
sudo mv mkcert /usr/local/bin
```
2021-06-11 08:55:46 +00:00
2021-09-24 08:44:34 +00:00
1. You have `envsubst` installed. Use `brew install gettext` on MacOS. Linux machines usually have this installed.
2020-11-26 10:27:41 +00:00
1. You have cloned the repo in your local machine.
2021-09-24 08:44:34 +00:00
1. You have yarn installed as a global npm package, i.e. `npm install -g yarn` .
2023-06-05 05:25:07 +00:00
1. < b > Create local HTTPS certificates</ b >
2020-09-30 17:53:10 +00:00
2024-06-04 07:56:09 +00:00
1. Run the following command from the project root.
2020-09-30 17:53:10 +00:00
2024-06-04 07:56:09 +00:00
```bash
cd app/client/docker & & mkcert -install & & mkcert "*.appsmith.com" & & cd ../../..
```
2020-09-30 17:53:10 +00:00
2024-06-04 07:56:09 +00:00
This command will create 2 files in the `docker/` directory:
2020-09-30 17:53:10 +00:00
2024-06-04 07:56:09 +00:00
- `_wildcard.appsmith.com-key.pem`
- `_wildcard.appsmith.com.pem`
2020-09-30 17:53:10 +00:00
2024-06-04 07:56:09 +00:00
1. Add the domain `dev.appsmith.com` to `/etc/hosts` .
2020-09-30 17:53:10 +00:00
2024-06-04 07:56:09 +00:00
```bash
echo "127.0.0.1 dev.appsmith.com" | sudo tee -a /etc/hosts
```
2020-09-30 17:53:10 +00:00
2024-06-04 07:56:09 +00:00
Note:
2020-10-13 10:54:34 +00:00
2024-06-04 07:56:09 +00:00
- Please be careful when copying the above string as space between the IP and the string goes missing sometimes.
- Please check that the string is copied properly
```
cat /etc/hosts | grep appsmith
```
2020-11-26 10:27:41 +00:00
1. Run cmd: `cp .env.example .env`
2023-06-05 05:25:07 +00:00
1. Run Backend server
2020-11-26 10:27:41 +00:00
2024-06-04 07:56:09 +00:00
- The backend server can be run in two ways
1. Use Appsmith's staging server hosted at `https://release.app.appsmith.com` for development purposes. < b > (Recommended)</ b >
1. Run the backend server locally. To setup the backend server locally, refer [here ](#running-backend-locally ).
- Run the script `start-https.sh` to start the nginx container that will proxy the frontend requests to the backend server.
- Pass the server name as an argument to this command to use that server as backend.
2023-04-04 12:21:55 +00:00
2024-06-04 07:56:09 +00:00
```bash
cd app/client
./start-https.sh https://release.app.appsmith.com // uses Appsmith's staging backend server as backend for your local frontend code
```
- If you want to use the backend server running on your local, you do not need to pass a parameter when running `start-https.sh` .
2020-10-13 10:54:34 +00:00
2020-09-30 17:53:10 +00:00
### Steps to build & run the code:
2020-11-26 10:27:41 +00:00
2021-09-24 08:44:34 +00:00
1. Run `yarn install` .
2020-10-28 12:43:37 +00:00
2022-05-26 10:35:02 +00:00
Note:
2020-11-26 10:27:41 +00:00
2022-05-26 10:35:02 +00:00
- On the Ubuntu Linux platform, please run the following cmd before step 2 below:
2020-11-26 10:27:41 +00:00
2022-05-26 10:35:02 +00:00
```
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf & & sudo sysctl -p
```
2020-11-26 10:27:41 +00:00
2023-06-05 05:25:07 +00:00
1. Run `yarn start` .
2020-09-30 17:53:10 +00:00
2023-06-05 05:25:07 +00:00
- 🎉 Your Appsmith client is now running on https://dev.appsmith.com.
- < b > This URL must be opened with https and not have port 3000 in it.</ b >
2020-09-30 17:53:10 +00:00
2023-06-05 05:25:07 +00:00
1. If yarn start throws mismatch node version error
2020-09-30 17:53:10 +00:00
2024-06-04 07:56:09 +00:00
- This error occurs because the node version is not compatible with the app environment. In this case, Node version manager can be used, allowing multiple node versions in different projects.
- Check below for installation and usage details:
2020-11-26 10:27:41 +00:00
2024-06-04 07:56:09 +00:00
1. Install a node version manager. For eg: check [nvm ](https://github.com/nvm-sh/nvm ) or [fnm ](https://github.com/Schniz/fnm ).
1. In the project's root, run `nvm use 18.17.1` or `fnm use 18.17.1` .
2020-09-30 17:53:10 +00:00
2023-06-05 05:25:07 +00:00
### Running Tests on Client
2020-11-26 10:27:41 +00:00
2023-06-05 05:25:07 +00:00
#### Integration Tests
2020-11-26 10:27:41 +00:00
2024-06-04 07:56:09 +00:00
##### Pre-flight checks
2020-10-15 06:25:12 +00:00
2024-06-04 07:56:09 +00:00
- The base URL can be updated on a temporary basis in the `cypress.config.ts` file based on the configuration you used for running the codebase locally. By default, it’ s `https://dev.appsmith.com` .
- If you wish to run Git test cases locally, please add `APPSMITH_GIT_ROOT=./container-volumes/git-storage` to the folder `app/server/.env` and run the server locally instead of via Docker container.
2024-01-22 09:36:08 +00:00
2024-06-04 07:56:09 +00:00
##### Setup Cypress configurations
To setup the configurations for running integration tests via Cypress, use these commands below,
```bash
cd app/client/cypress/scripts
yarn install
yarn run setup
```
##### Running Cypress tests locally
To run a specific test file in headless fashion, use the following command:
```bash
cd app/client/
yarn install
npx cypress run --spec < spec path > --browser chrome
```
2020-11-26 10:27:41 +00:00
2024-06-04 07:56:09 +00:00
To open Cypress in the browser and run the tests visually
```bash
cd app/client/
yarn install
npx cypress open
```
2020-11-26 10:27:41 +00:00
2023-06-05 05:25:07 +00:00
- < b >< a name = "running-backend-locally" > Running appsmith backend server locally</ a ></ b >
2024-06-04 07:56:09 +00:00
2023-06-05 05:25:07 +00:00
- There are two configurations available for running the backend server locally.
2024-06-04 07:56:09 +00:00
2023-06-05 05:25:07 +00:00
1. Running the server from source code.
- Refer to [documentation ](https://github.com/appsmithorg/appsmith/blob/release/contributions/ServerSetup.md ) for setting up backend to do this.
2024-06-04 07:56:09 +00:00
1. Running the server from a docker image. There are two ways to get a backend docker image
2020-11-26 10:27:41 +00:00
2024-06-04 07:56:09 +00:00
1. Pull latest release branch docker image from Appsmith's public docker hub account.
2020-11-26 10:27:41 +00:00
2024-06-04 07:56:09 +00:00
```
docker rm appsmith;
2023-06-05 05:25:07 +00:00
2024-06-04 07:56:09 +00:00
cd ~/appsmith;
2023-06-05 05:25:07 +00:00
2024-06-04 07:56:09 +00:00
rm -rf stacks;
2023-06-05 05:25:07 +00:00
2024-06-04 07:56:09 +00:00
docker pull appsmith/appsmith-ce
2023-06-05 05:25:07 +00:00
2024-06-04 07:56:09 +00:00
docker run -d --name appsmith -p 8000:80 appsmith/appsmith-ce:latest;
2023-06-05 05:25:07 +00:00
2024-06-04 07:56:09 +00:00
docker logs -f appsmith;
2024-01-22 09:36:08 +00:00
2024-06-04 07:56:09 +00:00
./start-https.sh http://localhost:8000 // if nginx is installed locally
./start-https.sh http://host.docker.internal:8000 // if nginx is running on docker
2024-01-22 09:36:08 +00:00
2024-06-04 07:56:09 +00:00
```
2023-06-05 05:25:07 +00:00
1. Create docker image from local source code
2024-06-04 07:56:09 +00:00
```
cd ~/appsmith
./scripts/local_testing.sh -l # This builds a fat docker image of local backend and frontend
# The docker image created above will show up in your docker desktop application
2023-06-05 05:25:07 +00:00
2024-06-04 07:56:09 +00:00
docker run -d --name appsmith -p 8000:80 appsmith/appsmith-ce:local-testing;
2024-01-22 09:36:08 +00:00
2024-06-04 07:56:09 +00:00
./start-https.sh http://localhost:8000 // if nginx is installed locally
./start-https.sh http://host.docker.internal:8000 // if nginx is running on docker
2023-06-05 05:25:07 +00:00
2024-06-04 07:56:09 +00:00
```
2023-06-05 05:25:07 +00:00
2024-06-04 07:56:09 +00:00
- Please check out our [Testing Contribution ](docs/TestAutomation.md ) guide for more details on setting up & troubleshooting Cypress runs on your machine.
2024-01-22 09:36:08 +00:00
2023-06-05 05:25:07 +00:00
### Running Unit Tests
- To run the Jest unit tests, run:
```bash
cd app/client
yarn run test:unit
2022-05-26 10:35:02 +00:00
```
2020-10-05 04:05:23 +00:00
2023-06-05 05:25:07 +00:00
- To run a single jest test,
2024-06-04 07:56:09 +00:00
2023-06-05 05:25:07 +00:00
```bash
cd app/client
2024-01-22 09:36:08 +00:00
2023-06-05 05:25:07 +00:00
# Run either command below to run a test
npx jest < file_path / file_name >
2024-01-22 09:36:08 +00:00
2023-06-05 05:25:07 +00:00
# or
yarn jest src/widgets/< filepath > /< filename > .test.ts --silent=false
```
2021-09-24 08:44:34 +00:00
2023-06-05 05:25:07 +00:00
- To run a single jest test in watch mode,
```bash
npx jest --watch < file_path / file_name >
```
2023-04-06 11:30:38 +00:00
2021-06-16 10:04:17 +00:00
### Windows WSL2 Setup
2021-10-14 10:57:15 +00:00
[](https://youtu.be/Od-qic69syA)
2021-06-16 10:04:17 +00:00
Before you follow the instructions above, make sure to check the following steps:
1. You have **WSL2** setup in your machine. If not, please visit: [https://docs.microsoft.com/en-us/windows/wsl/install-win10 ](https://docs.microsoft.com/en-us/windows/wsl/install-win10 ).
2021-06-16 13:05:24 +00:00
2. You have [Node.js ](https://www.geeksforgeeks.org/installation-of-node-js-on-linux/ ) installed on the WSL Distro.
2021-09-24 08:44:34 +00:00
3. You have **Docker Desktop** installed with the WSL2 backend. If not, please visit: [https://docs.docker.com/docker-for-windows/wsl/ ](https://docs.docker.com/docker-for-windows/wsl/ ).
2021-06-16 10:04:17 +00:00
2021-06-16 13:05:24 +00:00
In the above [Docker Desktop Setup ](https://docs.docker.com/docker-for-windows/wsl/ ) instructions, make sure to:
2022-05-26 10:35:02 +00:00
2021-06-16 10:04:17 +00:00
1. Set WSL Distro to run in WSL2 mode.
2. Enable integration with the WSL Distro in Docker Desktop.
3. Install [Remote-WSL ](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl ) extension in VSCode.
2021-09-24 08:44:34 +00:00
Make sure to Clone the Repo in the WSL file system instead of the Windows file system.
2021-06-16 10:04:17 +00:00
2021-06-16 13:05:24 +00:00
And finally, you can open the folder in VSCode with WSL by following the instructions in [Docker Desktop Setup ](https://docs.docker.com/docker-for-windows/wsl/ ),
2021-09-24 08:44:34 +00:00
or by,
2022-05-26 10:35:02 +00:00
2021-06-16 13:05:24 +00:00
1. Clicking on the Green button on the Bottom Left corner in VSCode.
2. Selecting **Open Folder in WSL** and navigating to the folder in WSL.
2021-09-24 08:44:34 +00:00
After this, you can continue Setting up from [here ](#pre-requisites ).
2020-11-26 10:27:41 +00:00
### Troubleshooting
#### I am on WSL and can't reach dev.appsmith.com
- You will need to add `dev.appsmith.com` to Windows' `C:\Windows\System32\drivers\etc\hosts` instead of `/etc/hosts` . Alternately, you can install a desktop environment in WSL to open `dev.appsmith.com` from a browser in WSL.
```
127.0.0.1 dev.appsmith.com
```
2021-09-24 08:44:34 +00:00
- WSL network with windows can be brittle; make sure you can reach http://127.0.0.1:3000 from windows. If not, restarting wsl usually resolves the issue.
2020-11-26 10:27:41 +00:00
#### Docker container doesn't work
2021-09-24 08:44:34 +00:00
- You can check logs with `docker logs wildcard-nginx` .
2020-11-26 10:27:41 +00:00
- If you see `Address already in use` errors, look for the service running on port 80 and 443 with `lsof -i tcp:80,443 | grep LISTEN` and stop the process.
2021-09-24 08:44:34 +00:00
**Example** : Some Linux distros have `apache2` listening on 80. Stop them with `sudo systemctl stop apache2`
2020-09-30 17:53:10 +00:00
2021-09-24 08:44:34 +00:00
#### I want to add dev.appsmith.com conf to my local Nginx without Docker.
2020-09-30 17:53:10 +00:00
2020-11-26 10:27:41 +00:00
1. Copy `app/client/docker/templates/nginx-app.conf.template` over to your nginx sites directory.
1. You can remove or replace values for all the `sub_filter` . None of those properties are required.
1. Change `proxy_pass` value for client from `__APPSMITH_CLIENT_PROXY_PASS__` to `http://localhost:3000`
2021-09-24 08:44:34 +00:00
1. Replace all occurrences of `__APPSMITH_SERVER_PROXY_PASS__` with `http://localhost:8080` (or the server you want to point to)
2020-11-26 10:27:41 +00:00
1. Generate the certificates manually via `mkcert` .
1. Change the value of the certificate location for keys `ssl_certificate` & `ssl_certificate_key` to the place where these certificates were generated.
1. Reload nginx! :tada:
2020-10-28 12:16:44 +00:00
2020-11-26 10:27:41 +00:00
## I still need help!
2020-10-28 12:16:44 +00:00
2021-09-24 08:44:34 +00:00
Please open a [Github issue ](https://github.com/appsmithorg/appsmith/issues/new/choose ) or join our [discord server ](https://discord.com/invite/rBTTVJp ).