Skip to content

Commit 7346c37

Browse files
authored
chore(docs): Add Installation.md and updated Contributing.md (#889)
* chore(docs): add Installation.md * chore(docs): updated README.md file * chore(docs): updated contributing.md
1 parent 147fde5 commit 7346c37

File tree

4 files changed

+320
-174
lines changed

4 files changed

+320
-174
lines changed

CONTRIBUTING.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ If you don't have time to contribute, that's fine. There are other easy ways to
2121
- 📋 [Improving the Documentation](#-improving-the-documentation)
2222
- 🌐 [Improving the website](#-improving-the-website)
2323
- 🎨 [Improving the Design](#-improving-the-design)
24+
- 🚀 [Contributing to CI/CD Pipeline](#-contributing-to-cicd-pipeline)
25+
- 🧪 [Contributing to Testing](#-contributing-to-testing)
2426
- ⌨️ [Pull requests](#%EF%B8%8F-pull-requests)
2527
- 🏛 [License](#-license)
2628

29+
2730
## 🌱 Code of Conduct
2831

2932
Before making your first contribution, please ensure you are familiar with our [Code of Conduct](https://github.com/json-schema-org/.github/blob/main/CODE_OF_CONDUCT.md).
@@ -60,14 +63,41 @@ To publish a case study, we encourage you to join `#adopters` channel in our [Sl
6063

6164
If you would like to join the efforts to improve the JSON Schema Documentation, we encourage you to check our [documentation board](https://github.com/orgs/json-schema-org/projects/16) to get a sense of the pending issues and who is doing what. We encourage you to join the discussion on the [issue #421](https://github.com/json-schema-org/community/issues/421) so you can see the long term vision for our docs. We also invite you to join the discussion in `#documentation` channel in our [Slack workspace](https://json-schema.org/slack).
6265

63-
### 📋 Improving the Website
66+
### 🌐 Improving the Website
6467

6568
If you would like to join the efforts to improve the JSON Schema Website, we encourage you to check our [website contribution board](https://github.com/orgs/json-schema-org/projects/11) to get a sense of the pending issues and bugs and who is doing what. We also invite you to join the discussion in `#website` channel in our [Slack workspace](https://json-schema.org/slack).
6669

6770
### 🎨 Improving the Design
6871

6972
If you would like to contribute with designs, we encourage you to join `#design` channel in our [Slack workspace](https://json-schema.org/slack) and read the [contributing guidelines](https://github.com/json-schema-org/brand/blob/master/CONTRIBUTING.md) in the [Brand](https://github.com/json-schema-org/brand) repository.
7073

74+
### 🚀 Contributing to CI/CD Pipeline
75+
76+
If you would like to contribute to our CI/CD pipeline, we encourage you to review our current setup in the [workflows README](https://github.com/json-schema-org/website/blob/main/.github/workflows/README.md).
77+
78+
### 🧪 Contributing to Testing
79+
80+
We value contributions to our testing efforts. Here are ways you can help improve our test coverage and quality:
81+
82+
1. **Writing Tests**: If you're adding new features or fixing bugs, please include relevant tests. We use Cypress for both end-to-end (E2E) and component testing.
83+
84+
- For new components, add component tests in the `cypress/components` directory.
85+
- For new features or bug fixes affecting user interactions, add E2E tests in the `cypress/e2e` directory.
86+
87+
2. **Improving Existing Tests**: Review and enhance our existing test suite. Look for areas where test coverage could be improved or where tests could be made more robust.
88+
89+
3. **Test Documentation**: Help improve our testing documentation, making it easier for new contributors to understand and write tests.
90+
91+
4. **Running Tests**: Before submitting a pull request, ensure all tests pass by running:
92+
```
93+
yarn cypress:run:all
94+
```
95+
96+
5. **Reporting Test Issues**: If you find inconsistencies or problems with our tests, please open an issue describing the problem and how to reproduce it.
97+
98+
For more details on our testing setup and how to run tests, please refer to the Testing section in our [INSTALLATION.md](./INSTALLATION.md#testing) file.
99+
100+
71101
### ⌨️ Pull requests
72102

73103
We welcome pull requests for editorial suggestions and resolving open issues.

INSTALLATION.md

Lines changed: 286 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
1+
# JSON Schema Website: Installation and Development Guide
2+
3+
This guide provides step-by-step instructions for installing the JSON Schema Website on your local machine. Follow each section in order without skipping any steps.
4+
5+
## Table of Contents
6+
7+
1. [Setting Up the Project](#setting-up-the-project)
8+
- [Requirements](#requirements)
9+
- [Cloning the Repository](#cloning-the-repository)
10+
- [Setting Up Environment Variables](#setting-up-environment-variables)
11+
2. [Corepack Configuration](#corepack-configuration)
12+
- [What is Corepack?](#what-is-corepack)
13+
- [Installing Corepack](#installing-corepack)
14+
- [Using Corepack with This Project](#using-corepack-with-this-project)
15+
- [Updating Yarn Version](#updating-yarn-version)
16+
- [Troubleshooting](#troubleshooting)
17+
3. [Post-Configuration Steps](#post-configuration-steps)
18+
- [Installing Dependencies](#installing-dependencies)
19+
- [Running the Development Server](#running-the-development-server)
20+
- [Building Static Files](#building-static-files)
21+
4. [Testing](#testing)
22+
- [Running Tests](#running-tests)
23+
- [Test Coverage](#test-coverage)
24+
- [Writing Tests](#writing-tests)
25+
5. [Code Quality](#code-quality)
26+
- [Formatting](#formatting)
27+
- [Linting](#linting)
28+
- [Husky for Git Hooks](#husky-for-git-hooks)
29+
6. [Run locally using Docker](#docker-deployment)
30+
- [Prerequisites](#prerequisites)
31+
- [Steps](#steps)
32+
33+
34+
## Setting up Project
35+
36+
## Configuration
37+
38+
### Requirements
39+
Use the following tools to set up the project:
40+
41+
Node.js v20.9.0+
42+
43+
### Cloning the repository
44+
This project uses git submodules, so you will need to run the following commands to fully clone the repo.
45+
```
46+
git submodule init
47+
git submodule update
48+
```
49+
50+
### Setting Up Environment Variables
51+
52+
1. Create a new `.env` file by copying the contents of the `.env.example` into `.env` file. Use this command:
53+
```
54+
cp .env.example .env
55+
```
56+
2. Open .env and fill in your actual values for each variable.
57+
58+
3. Save the file.
59+
60+
4. Ensure .env is in your .gitignore.
61+
62+
### Corepack Configuration
63+
64+
This project uses modern Yarn ([email protected]), which requires Corepack for proper setup and management of package managers. Corepack is a tool that comes with Node.js 14.19.0 and later, allowing for consistent package manager versions across your project.
65+
66+
#### What is Corepack?
67+
68+
Corepack is an experimental tool to help with managing versions of your package managers. It exposes binary proxies for each supported package manager that, when called, will identify whatever package manager is configured for the current project, download it if needed, and finally run it.
69+
70+
71+
#### Installing Corepack
72+
73+
If you're using Node.js version 14.19.0 or later, Corepack is included but might need to be enabled. For Node.js 16.10 or later, Corepack is available by default but might still need to be enabled.
74+
75+
To enable Corepack, run:
76+
77+
```bash
78+
corepack enable
79+
```
80+
81+
If you're using an older version of Node.js or if the above command doesn't work, you can install Corepack globally using npm:
82+
83+
```bash
84+
npm install -g corepack
85+
```
86+
87+
#### Using Corepack with This Project
88+
89+
Once Corepack is enabled or installed, it will automatically use the correct version of Yarn specified in the project's `package.json` file. You don't need to manually install Yarn.
90+
91+
To use Yarn commands, simply run them as usual:
92+
93+
```bash
94+
yarn install
95+
yarn run build
96+
yarn run dev
97+
```
98+
99+
Corepack will ensure that the correct version of Yarn is used for these commands.
100+
101+
#### Updating Yarn Version
102+
103+
If you need to update the Yarn version used in the project:
104+
105+
1. Update the `packageManager` field in `package.json`:
106+
```json
107+
{
108+
"packageManager": "[email protected]"
109+
}
110+
```
111+
2. Run `yarn set version x.y.z` to update the local Yarn version.
112+
113+
#### Troubleshooting
114+
115+
If you encounter any issues with Yarn commands, try running:
116+
117+
```bash
118+
corepack prepare
119+
```
120+
121+
This will ensure that the correct version of Yarn is downloaded and prepared for use.
122+
123+
For more information about Corepack, refer to the [official Node.js documentation](https://nodejs.org/api/corepack.html).
124+
125+
## Post-Configuration Steps
126+
127+
### Installing Dependencies
128+
129+
Install dependencies
130+
```
131+
yarn
132+
```
133+
134+
### Running the Development Server
135+
136+
Run the development server on http://localhost:3000
137+
```
138+
yarn dev
139+
```
140+
141+
### Building Static Files
142+
143+
Build static files on `/out` folder
144+
```
145+
yarn build
146+
```
147+
## Testing
148+
149+
We use Cypress for both end-to-end (E2E) testing and component testing. This document will guide you through the process of running tests and generating coverage reports.
150+
151+
### Running Tests
152+
153+
154+
#### Opening Cypress Test Runner
155+
156+
To open the Cypress Test Runner, which allows you to run tests interactively, use:
157+
158+
```
159+
yarn cypress:open
160+
```
161+
162+
This command will open a GUI where you can select and run specific tests.
163+
164+
#### Running All Tests Headlessly
165+
166+
To run all tests in headless mode (useful for CI/CD pipelines), use:
167+
168+
```
169+
yarn cypress:run:all
170+
```
171+
172+
### Test Coverage
173+
174+
We use NYC (Istanbul) for code coverage reporting. Here's how to generate coverage reports:
175+
176+
#### E2E Test Coverage
177+
178+
To run E2E tests with coverage:
179+
180+
```
181+
yarn test:coverage:e2e
182+
```
183+
184+
#### Component Test Coverage
185+
186+
To run component tests with coverage:
187+
188+
```
189+
yarn test:coverage:component
190+
```
191+
192+
#### Full Test Coverage
193+
194+
To run all tests and generate a combined coverage report:
195+
196+
```
197+
yarn test:coverage:all
198+
```
199+
200+
This command will:
201+
1. Run E2E tests with coverage
202+
2. Run component tests with coverage
203+
3. Merge the coverage results
204+
4. Generate an HTML and text report
205+
206+
You can find the HTML report in the `coverage` directory after running this command.
207+
208+
### Writing Tests
209+
210+
When contributing new features or fixing bugs, please consider adding or updating tests:
211+
212+
- For new components, add component tests in the relevant `cypress/components` directory.
213+
- For new features or bug fixes affecting user interactions, add E2E tests in the `cypress/e2e` directory.
214+
215+
## Code Quality
216+
217+
We use ESLint for linting and Prettier for code formatting. This section will guide you through the process of checking and fixing code quality issues.
218+
219+
### Formatting
220+
221+
you can check code formatting using the following command:
222+
223+
```
224+
yarn run format:check
225+
```
226+
227+
you can format the code using the following command:
228+
229+
```
230+
yarn run format:fix
231+
```
232+
233+
### Linting
234+
235+
you can check linting issues using the following command:
236+
237+
```
238+
yarn run lint
239+
```
240+
241+
you can fix linting issues using the following command:
242+
243+
```
244+
yarn run lint:fix
245+
```
246+
247+
### Husky for git hooks
248+
249+
This project uses Husky to run checks for the formatting, linting, typecheck and build commands before committing the code.
250+
251+
#### pre-commit hook
252+
pre-commit hook will run the following commands:
253+
254+
```
255+
yarn run lint
256+
yarn run typecheck
257+
yarn run build
258+
```
259+
260+
If you don't want these pre-commit checks running on each commit, you can manually opt out of it using the `--no-verify` flag with your commit message as shown:-
261+
```
262+
git commit -m "commit message" --no-verify
263+
```
264+
265+
### Run locally using Docker
266+
267+
If you are a Docker lover, you have the option to use it following these instructions.
268+
269+
#### Prerequisites:
270+
271+
- [Install Docker](https://docs.docker.com/get-docker/)
272+
273+
After cloning repository to your local, perform the following steps from the root of the repository.
274+
275+
#### Steps:
276+
1. Build the Docker image:
277+
```bash
278+
make install
279+
```
280+
281+
2. Start the container:
282+
```bash
283+
make run
284+
```
285+
286+
Now you're running JSON Schema website in a development mode. Container is mapped with your local copy of the website. Whenever you make changes to the code, the website will refresh and changes visible in `http://localhost:3000`.

0 commit comments

Comments
 (0)