Skip to content

Commit 68fc88e

Browse files
author
Michael Perrotte
committed
docs: updated the CONTRIBUTING file; added references to benchmarking
PR-URL: #689 Credit: @mikemimik Close: #689 Reviewed-by: @mikemimik
1 parent 1ce0344 commit 68fc88e

File tree

1 file changed

+156
-46
lines changed

1 file changed

+156
-46
lines changed

CONTRIBUTING.md

Lines changed: 156 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,80 +3,190 @@
33
## Table of Contents
44

55
* [Introduction](#introduction)
6-
* [Roles](#roles)
7-
* [Community Members](#community-members)
8-
* [Collaborators](#collaborators)
9-
* [npm, Inc Employees](#npm-inc-employees)
10-
6+
* [Code Structure](#code-structure)
7+
* [Running Tests](#running-tests)
8+
* [Debugging](#debugging)
9+
* [Coverage](#coverage)
10+
* [Benchmarking](#benchmarking)
11+
* [Types of Contributions](#types-of-contributions)
12+
* [Contributing an Issue?](#contributing-an-issue)
13+
* [Contributing a Question?](#contributing-a-question)
14+
* [Contributing a Bug Fix?](#contributing-a-bug-fix)
15+
* [Contributing a Feature?](#contributing-a-bug-feature)
16+
* [Development Dependencies](#development-dependencies)
17+
* [Dependencies](#dependencies)
1118

1219
## Introduction
1320

14-
Welcome to the npm CLI Contributor Guide! This document outlines the npm CLI repository's process for community interaction and contribution. This includes the issue tracker, pull requests, wiki pages, and, to a certain extent, outside communication in the context of the npm CLI. It defines roles, responsibilities, and procedures, and is an entry point for anyone wishing to contribute their time and effort to making npm a better tool for the JavaScript community!
21+
Welcome to the npm CLI Contributor Guide! This document outlines the npm CLI repository's process for community interaction and contribution. This includes the issue tracker, pull requests, wiki pages, and, to a certain extent, outside communication in the context of the npm CLI. This is an entry point for anyone wishing to contribute their time and effort to making npm a better tool for the JavaScript community!
1522

1623
All interactions in the npm repository are covered by the [npm Code of Conduct](https://www.npmjs.com/policies/conduct)
1724

18-
## Roles
1925

20-
There are three main roles for people participating in the npm issue tracker. Each has a specific set of abilities and responsibilities: [Community members](#community-members), [Collaborators](#collaborators), and [npm, Inc employees](#npm-inc-employees).
26+
## Code Structure
27+
```
28+
/
29+
├── bin/
30+
│ │ # Directory for executable files. It's very rare that you
31+
│ │ # will need to update a file in this directory.
32+
│ │
33+
│ ├── npm # npm-cli entrypoint for bourne shell
34+
│ ├── npm-cli.js # npm-cli entrypoint for node
35+
│ ├── npm.cmd # npm-cli entrypoint for windows
36+
│ ├── npx # npx entrypoint for bourne shell
37+
│ ├── npx-cli.js # npx entrypoint for node
38+
│ └── npx.cmd # npx entrypoint for windows
39+
40+
├── docs/ 📖
41+
│ │ # Directory that contains the documentation website for
42+
│ │ # the npm-cli. You can run this website locally, and have
43+
│ │ # offline docs! 🔥📖🤓
44+
│ │
45+
│ ├── content/ # Markdown files for site content
46+
│ ├── src/ # Source files for the website; gatsby related
47+
│ └── package.json # Site manifest; scripts and dependencies
48+
49+
├── lib/ 📦
50+
│ # All the Good Bits(tm) of the CLI project live here
51+
52+
├── node_modules/ 🔋
53+
│ # Vendored dependencies for the CLI project (See the
54+
│ # dependencies section below for more details).
55+
56+
├── scripts/ 📜
57+
│ # We've created some helper scripts for working with the
58+
│ # CLI project, specifically around managing our vendored
59+
│ # dependencies, merging in pull-requests, and publishing
60+
│ # releases.
61+
62+
├── test/ 🧪
63+
│ # All the tests for the CLI live in this folder. We've
64+
│ # got a lot of tests 🤓🧪🩺
65+
66+
├── CONTRIBUTING.md # This file! 🎉
67+
└── package.json # The projects main manifest file 📃
68+
```
69+
70+
## Running Tests
71+
72+
```
73+
# Make sure you install the dependencies first before running tests.
74+
$ npm install
75+
76+
# Run tests for the CLI (it could take awhile).
77+
$ npm run test
78+
```
79+
80+
## Debugging
81+
82+
It can be tricky to track down issues in the CLI. It's a large code base that has been evolving for over a decade. There is a handy `make` command that will connect the **cloned repository** you have on your machine with the global command, so you can add `console.log` statements or debug any other way you feel most comfortable with.
83+
84+
```
85+
# Clone the repository to start with
86+
$ git clone [email protected]:npm/cli.git
87+
88+
# Change working directories into the repository
89+
$ cd cli
90+
91+
# Make sure you have the latest code (if that's what you're trying to debug)
92+
$ git fetch origin latest
93+
94+
# Connect repository to the global namespace
95+
$ make link
96+
97+
#################
98+
# ALTERNATIVELY
99+
#################
100+
# If ou're working on a feature or bug, you can run the same command on your
101+
# working branch and link that code.
102+
103+
# Create new branch to work from (there are many ways)
104+
$ git checkout -b feature/awesome-feature
105+
106+
# Connect repository to global namespace
107+
$ make link
108+
```
109+
110+
## Coverage
111+
112+
We try and make sure that each new feature or bug fix has tests to go along with them in order to keep code coverages consistent and increasing. We are actively striving for 100% code coverage!
113+
114+
```
115+
# You can run the following command to find out coverage
116+
$ npm run test-coverage
117+
```
118+
119+
## Benchmarking
120+
121+
We often want to know if the bug we've fixed for the feature we've added has any sort of performance impact. We've created a [benchmark suite](https://github.com/npm/benchmarks) to run against the CLI project from pull-requests. If you would like to know if there are any performance impacts to the work you're contributing, simply do the following:
122+
123+
1. Make a pull-request against this repository
124+
2. Add the following comment to the pull-request: "`test this please ✅`"
125+
126+
This will trigger the [benmark suite](https://github.com/npm/benchmarks) to run against your pull-request, and when it's finished running it will post a comment on your pull-request just like bellow. You'll be able to see the results from the suite inline in your pull-request.
127+
128+
> You'll notice that the bot-user will also add a 🚀 reaction to your comment to
129+
let you know that it's sent the request to start the benchmark suite.
130+
131+
![image](https://user-images.githubusercontent.com/2818462/72312698-e2e57f80-3656-11ea-9fcf-4a8f6b97b0d1.png)
132+
133+
If you've updated your pull-reuqest and you'd like to run the the benchmark suite again, simple update your original comment, by adding `test this please ✅` again, or simply just adding another emoji to the **end**. _(The trigger is the phrase "test this please ✅" at the beginning of a comment. Updates will trigger as well, so long as the phrase stays at the beginning.)_.
134+
135+
![image](https://user-images.githubusercontent.com/2818462/72313006-ec231c00-3657-11ea-9bd9-227634d67362.png)
136+
137+
## Types of Contributions
138+
139+
### Contributing an Issue?
21140

22-
Failure to comply with the expected responsibilities of each role, or violating the Code of Conduct will result in punitive action relative to the transgression, ranging from a warning to full removal from the project, at the discretion of npm employees.
141+
Great!! Is your [new issue](https://github.com/npm/cli/issues/new/choose) a [bug](https://github.com/npm/cli/issues/new?template=bug.md&title=%5BBUG%5D+%3Ctitle%3E), a [feature](https://github.com/npm/cli/issues/new?template=feature.md&title=%5BFEATURE%5D+%3Ctitle%3E), or a [question](https://github.com/npm/cli/issues/new?template=question.md&title=%5BQUESTION%5D+%3Ctitle%3E)?
23142

24-
### Community Members
143+
### Contributing a Question?
25144

26-
This includes anyone who may show up to the npm/npm repo with issues, PRs, comments etc. They may not have any other involvement with npm.
145+
Huh? 🤔 Got a situation you're not sure about?! Perfect! We've got some resources you can use.
27146

28-
#### Abilities
147+
* Our [documentation site](https://docs.npmjs.com/)
148+
* The local docs that come with the CLI project
29149

30-
* Open issues and PRs
31-
* Comment on issues and PRs
150+
> **Example**: `npm help install --viewer browser`
32151
33-
#### Responsibilities
152+
* The man pages that are built and shipped with the CLI
34153

35-
* Comment on issues when they have a reference to the answer.
36-
* If community members aren't sure they are correct and don't have a reference to the answer, please leave the issue and try another one.
37-
* Defer to collaborators and npm employees for answers.
38-
* Make sure to search for [the troubleshooting posts on npm.community](https://npm.community/c/support/troubleshooting) and search on the issue tracker for similar issues before opening a new one.
39-
* Any users with urgent support needs are welcome to email [email protected], and our dedicated support team will be happy to help.
154+
> **Example**: `man npm-install` (only on linux/macOS)
40155
41-
PLEASE don't @ collaborators or npm employees on issues. The CLI team is small, and has many outstanding commitments to fulfill.
156+
* Search of the [current issues](https://github.com/npm/cli/issues)
42157

43-
### Collaborators
158+
### Contributing a Bug Fix?
44159

45-
These are folks who have the ability to label and close issues. The role of collaborators may expand over time, but for now it is a limited (& important) role. This is an excellent way to contribute to npm without writing code.
160+
We'd be happy to triage and help! Head over to the issues and [create a new one](https://github.com/npm/cli/issues/new?template=bug.md&title=%5BBUG%5D+%3Ctitle%3E)!
46161

47-
Community members may become collaborators by showing consistent, proven track record of quality contributions to the project, a reasonable level of proficiency with the CLI, and regular participation through the tracker and other related mediums, including regular contact with the CLI team itself. This role entails a higher level of responsibility than community member, so we ask for a higher level of understanding and commitment.
162+
> We'll need a little bit of information about what happened, rather than "it broke". Such as:
163+
* When did/does this bug happen?
164+
* Can you reproduce it? _(Can you make it happen more than once.)_
165+
* What version of `node`/`npm` are you running on your computer?
166+
* What did you expect it to do?
167+
* What did it _actually do?
168+
* etc...
48169

49-
Collaborators who become inactive for 3 months or longer may have their collaborator privileges removed until they are ready to return.
170+
### Contributing a Feature?
50171

51-
#### Abilities
172+
Snazzy, we're always up for fancy new things! If the feature is fairly minor, the team can triage it and prioritize it into our backlog. However, if the feature is a little more complex, then it's best to create an [RFC](https://en.wikipedia.org/wiki/Request_for_Comments) in our [RFC repository](https://github.com/npm/rfcs). Exactly how to do that is outlined in that repository. If you're not sure _exactly_ how to implement your idea, or don't want to make a document about your idea, then please create an issue on that repository. We consider these RRFC's, or a "Requesting Request For Comment".
52173

53-
* Label/triage new issues
54-
* Respond to ongoing issues
55-
* Close resolved issues.
174+
## Development Dependencies
56175

57-
#### Responsibilities
176+
You'll need a few things installed in order to update and test the CLI project during development:
58177

59-
* Only answer questions when they know the answer, and provide a reference to the answer.
60-
* If collaborators aren't totally confident about their answer, please leave the issue and try another one.
61-
* If they've responded to an issue, it becomes their responsibility to see it to resolution.
62-
* Defer to fellow Collaborators & npm employees for answers (Again, please don't @ collaborators or npm employees, thank you!)
63-
* Make sure to search [the troubleshooting posts on npm.community](https://npm.community/c/support/troubleshooting) and search the rest of the forum for similar topics.
178+
* [node](https://nodejs.org/) v8 or greater
64179

65-
### npm, Inc Employees
180+
> We recommend that you have a [node version manager](https://github.com/nvm-sh/nvm) installed if you plan on fixing bugs that might be present in a specific version of node. With a version manager you can easily switch versions of node and test if your changes to the CLI project are working.
66181
67-
Folks who work at npm, Inc, who have a responsibility to ensure the stability and functionality of the tools npm offers.
182+
* [git](https://git-scm.com/) v2.11+
68183

69-
#### Abilities
70184

71-
* Label/triage new issues
72-
* Respond to ongoing issues
73-
* Close resolved issues
74-
* Land PRs
185+
## Dependencies
75186

76-
Please note that this is a living document, and the CLI team will put up PRs to it as needed.
187+
> Package vendoring is commonly referred to as the case where dependent packages are stored in the same place as your project. That usually means you dependencies are checked into your source management system, such as Git.
77188
78-
#### Responsibilities
189+
The CLI project vendors it's dependencies in the `node_modules/` folder. Meaning all the dependencies that the CLI project uses are contained withing the project itself. This is represented by the `bundledDependencies` section in the root level `package.json` file. The main reason for this is because the `npm` CLI project is distributed with the NodeJS runtime and needs to work out of the box, which means all dependencies need to be available after the runtime is installed.
79190

80-
* Preserve and promote the health of the CLI, the registry, the website, etc.
191+
There are a couple scripts created to help manage this process in the `scripts/` folder.
81192

82-
In special cases, [Collaborators](#collaborators) may request time to speak with an npm employee directly, by contacting them and coordinating a time/place.

0 commit comments

Comments
 (0)