The Node.js® Website
1# Node.js Website Contributing Guide 2 3Thank you for your interest in contributing to the Node.js Website. Before you proceed, briefly go through the following: 4 5- [Code of Conduct](https://github.com/nodejs/node/blob/HEAD/CODE_OF_CONDUCT.md) 6- [Contributing](#contributing) 7 - [Becoming a collaborator](#becoming-a-collaborator) 8- [Getting started](#getting-started) 9 - [CLI Commands](#cli-commands) 10- [Commit Guidelines](#commit-guidelines) 11- [Pull Request Policy](#pull-request-policy) 12- [Developer's Certificate of Origin 1.1](#developers-certificate-of-origin-11) 13 14## Contributing 15 16Any individual is welcome to contribute to the Node.js Website. The repository currently has two kinds of contribution personas: 17 18- A **Contributor** is any individual who creates an issue/PR, comments on an issue/PR, or contributes in some other way. 19- A **Collaborator** is a contributor with write access to the repository. See [here](#becoming-a-collaborator) on how to become a collaborator. 20 21You can find more details and guides about Collaborating with this repository through our [Collaborator Guide](./COLLABORATOR_GUIDE.md). 22 23### Becoming a Collaborator 24 25A collaborator of the Node.js Website repository is a member of the Node.js Website Team. 26 27The Website Team is responsible for the technical development of the Node.js Website; thus, it is expected 28that team members have significant knowledge about modern Web Technologies and Web Standards. 29 30Note that regular contributors do not need to become "Collaborators" as any contribution is appreciated (even without a status), and a Collaborator status 31is a formality that comes with obligations. 32 33If you're an active contributor seeking to become a member, we recommend you contact one of the existing Team Members for guidance. 34 35<details> 36 <summary><b>What's the process for becoming a Collaborator?</b></summary> 37 38- You must be actively contributing to this repository. 39- Contributions must include significant code reviews or code contributions. 40- A nomination must be done by an existing Team Member of the Website Team with an Issue 41 - The Issue must explain and describe why the nominated person is a good addition to the team 42 - The Issue must contain links to relevant contributions through: 43 - Code Reviews 44 - Comments on Issues and PRs 45 - Authoring of PRs or Issues 46 - Comments or Authoring of Discussions 47- The nomination must have at least three existing members of the Website Team agree with the nomination. 48 - This can be done through commenting with "agreement" (showing support) or reacting to the Issue with a :+1: (Thumbs-up Emoji) 49- The Issue must be open for at least 72 hours without an objection from an existing member of the Website Team 50 - The nomination cannot pass until all open objections are resolved. 51 - Objections from the TSC or Core Collaborators are also counted as valid objections. 52 53</details> 54 55## Getting started 56 57The steps below will give you a general idea of how to prepare your local environment for the Node.js Website and general steps 58for getting things done and landing your contribution. 59 601. Click the fork button in the top right to clone the [Node.js Website Repository](https://github.com/nodejs/nodejs.org/fork) 61 622. Clone your fork using SSH, GitHub CLI, or HTTPS. 63 64 ```bash 65 git clone git@github.com:<YOUR_GITHUB_USERNAME>/nodejs.org.git # SSH 66 git clone https://github.com/<YOUR_GITHUB_USERNAME>/nodejs.org.git # HTTPS 67 gh repo clone <YOUR_GITHUB_USERNAME>/nodejs.org # GitHub CLI 68 ``` 69 703. Change into the nodejs.org directory. 71 72 ```bash 73 cd nodejs.org 74 ``` 75 764. Create a remote to keep your fork and local clone up-to-date. 77 78 ```bash 79 git remote add upstream git@github.com:nodejs/nodejs.org.git # SSH 80 git remote add upstream https://github.com/nodejs/nodejs.org.git # HTTPS 81 gh repo sync nodejs/nodejs.org # GitHub CLI 82 ``` 83 845. Create a new branch for your work. 85 86 ```bash 87 git checkout -b name-of-your-branch 88 ``` 89 906. Run the following to install the dependencies and start a local preview of your work. 91 92 ```bash 93 npm ci # installs this project's dependencies 94 npx turbo serve # starts a preview of your local changes 95 ``` 96 977. Perform your changes. In case you're unfamiliar with the structure of this repository, we recommend a read on the [Collaborator Guide](./COLLABORATOR_GUIDE.md) 98 998. Perform a merge to sync your current branch with the upstream branch. 100 101 ```bash 102 git fetch upstream 103 git merge upstream/main 104 ``` 105 1069. Run `npx turbo format` to confirm that linting and formatting are passing. 107 108 ```bash 109 npx turbo format 110 ``` 111 11210. Once you're happy with your changes, add and commit them to your branch, then push the branch to your fork. 113 114 ```bash 115 cd ~/nodejs.org 116 git add . 117 git commit -m "some message" 118 git push -u origin name-of-your-branch 119 ``` 120 121 > [!NOTE]\ 122 > By default if you run the Website (either via `npm run serve` or `npm run build`) two files on the `public` folder will be generated. 123 > 124 > You don't need to reset/discard these files, as by default we use Git Hooks that simply ignore these files during commit. 125 > Note that these files are generated and should **not** be committed. (`public/node-release-data.json` and `public/blog-posts-data.json`) 126 127 > [!IMPORTANT]\ 128 > Before committing and opening a Pull Request, please go first through our [Commit](#commit-guidelines) and [Pull Request](#pull-request-policy) guidelines outlined below. 129 13011. Create a Pull Request. 131 132> [!NOTE]\ 133> We ask for PR authors to avoid to rebase/update their PRs with the base branch (`main`) unnecessarily. 134> We use [GitHub Merge Queues](https://github.blog/2023-07-12-github-merge-queue-is-generally-available/) 135> which means that before merge the PRs get automatically updated and checked against the latest changes on the base branch. 136> 137> This also reduces the amount of times we need to run our CI checks, as every new push requires freshly new CI-checks. 138 139### CLI Commands 140 141This repository contains several scripts and commands for performing numerous tasks. The most relevant ones are described below. 142 143<details> 144 <summary>Commands for Running & Building the Website</summary> 145 146- `npx turbo serve` runs Next.js's Local Development Server, listening by default on `http://localhost:3000/`. 147- `npx turbo build` builds the Application on Production mode. The output is by default within `.next` folder. 148 - This is used for the Node.js Vercel Deployments (Preview & Production) 149- `npx turbo deploy` builds the Application on Export Production Mode. The output is by default within `build` folder. 150 - This is used for the Node.js Legacy Website Server (DigitalOcean) 151- `npx turbo start` starts a web server running serving the built content from `npx turbo build` 152 153</details> 154 155<details> 156 <summary>Commands for Maintenance Tasks and Tests</summary> 157 158- `npx turbo lint` runs the linter for all the js files. 159 - `npx turbo lint:fix` attempts to fix any linting errors 160- `npx turbo prettier` runs the prettier for all the js files. 161 - `npx turbo prettier:fix` attempts to fix any style errors 162- `npx turbo format` formats and fixes the whole codebase 163- `npx turbo scripts:release-post` generates a release post for the current release 164 - **Usage:** `npx turbo scripts:release-post -- --version=vXX.X.X --force` 165- `npx turbo storybook` starts Storybook's local server 166- `npx turbo storybook:build` builds Storybook as a static web application for publishing 167- `npx turbo test` runs all tests locally 168 - `npx turbo test:unit` runs jest (unit-tests) locally 169 170</details> 171 172## Commit Guidelines 173 174This project follows the [Conventional Commits][] specification. 175 176Commits should be signed. You can read more about [Commit Signing][] here. 177 178### Commit Message Guidelines 179 180- Commit messages must include a "type" as described on Conventional Commits 181- Commit messages **must** start with a capital letter 182- Commit messages **must not** end with a period `.` 183 184### Pre-commit Hooks 185 186This project uses [Husky][] for Git pre-commit hooks. 187 188- Some JSON files are generated during Build time with empty files as placeholders. Build time happens when you run `npx turbo serve` or `npx turbo build`. 189- We don't want to commit those unnecessary changes. Since these files exist in the repository, `.gitignore` won't work for them. As a workaround, we have a pre-commit hook to discard those changes. 190 191## Pull Request Policy 192 193This policy governs how contributions should land within this repository. The lines below state the checks and policies to be followed before merging and in the act of merging. 194 195### Before merging 196 197We recommend a read on our [Collaborator Guide](COLLABORATOR_GUIDE.md#accepting-modifications) for in-depth details on how we accept contributions into this repository. 198The list below describes some merging and approval rules adopted in this repository. 199 200- Pull Requests must be open for at least 48 hours (Or 72 hours if the PR was authored on the weekend). 201 - Pull requests might be immediately merged if they contain critical bug fixes, short errata (e.g., typos from previous PRs), or any critical change considered a "showstopper" for the website's operation. 202 - This kind of PRs should only be done by existing collaborators with write-access and/or signed off by administrators/maintainers. 203 - This rule cannot be used for updates on the `COLLABORATOR_GUIDE.md`, `CONTRIBUTING.md` guide, `CODEOWNERS`, GitHub Actions, or any security-impacting file or document that changes the governing policies of this repository. 204 - Pull requests might be "fast-tracked", meaning they can be merged before the usual 48 hours' notice if a "fast-track" label is added. 205 - The person that is fast-tracking the PR (adding the label) must also comment on the PR that they're requesting the PR to be fast-tracked 206 - The comment must mention `@nodejs/nodejs-website` and must have at least one 👍 (or any other sort of approval reaction) if the person fast-tracking the PR is the author of the PR. 207 - Fast-tracking is only allowed for small bug fixes, small feature changes, localization changes, or other non-critical/highly-impacting changes not covered by the previous rule that allows PRs to be merged immediately. 208 - Fast-tracking cannot be used for updates on the `COLLABORATOR_GUIDE.md`, `CONTRIBUTING.md` guide, `CODEOWNERS`, GitHub Actions, or any security-impacting file or document that changes the governing policies of this repository. 209- There must be no objections after forty-eight (48) hours (Or seventy-two (72) hours if the PR was authored on the weekend). 210 - If there are disagreements consensus should be sought. Lack of consensus might require escalation to the Website Team Maintainers. 211- At least one approval is required for any PR to be merged. 212- Tests must be included in Pull Requests for new features or bug fixes. You are responsible for fixing any test(s) that fail. 213 214Each contribution is accepted only if there is no objection to it by a collaborator. During the review, collaborators may request that a specific contributor who is an expert in a particular area give an "LGTM" before the PR can be merged. 215 216If an objection is raised in a pull request by another collaborator, all collaborators involved should try to arrive at a consensus by addressing the concerns through discussion, compromise, or withdrawal of the proposed change(s). 217 218### When merging 219 220- All required Status-checks must have passed. 221 - **Note:** If you're a collaborator, remember to run the CI checks by labeling the PR with the `github_actions:pull-request` label. 222- Please make sure that all discussions are resolved. 223- [`squash`][] pull requests made up of multiple commits 224 225## Developer's Certificate of Origin 1.1 226 227``` 228By contributing to this project, I certify that: 229 230- (a) The contribution was created in whole or in part by me and I have the right to 231 submit it under the open source license indicated in the file; or 232- (b) The contribution is based upon previous work that, to the best of my knowledge, 233 is covered under an appropriate open source license and I have the right under that 234 license to submit that work with modifications, whether created in whole or in part 235 by me, under the same open source license (unless I am permitted to submit under a 236 different license), as indicated in the file; or 237- (c) The contribution was provided directly to me by some other person who certified 238 (a), (b) or (c) and I have not modified it. 239- (d) I understand and agree that this project and the contribution are public and that 240 a record of the contribution (including all personal information I submit with it, 241 including my sign-off) is maintained indefinitely and may be redistributed consistent 242 with this project or the open source license(s) involved. 243 244``` 245 246[`squash`]: https://help.github.com/en/articles/about-pull-request-merges#squash-and-merge-your-pull-request-commits 247[Conventional Commits]: https://www.conventionalcommits.org/ 248[Commit Signing]: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits 249[Husky]: https://typicode.github.io/husky/