2020-09-07 00:36:08 -05:00
# Contributing
2017-02-18 06:05:12 -05:00
2020-10-24 07:08:24 -05:00
> Any change matters, whatever the size, just do it.
2020-09-06 07:56:12 -05:00
2021-08-12 13:05:27 -05:00
We're happy that you're considering contributing! To help, we've prepared these
guidelines for you:
2020-10-24 07:08:24 -05:00
**Table of Contents**
- [Contributing ](#contributing )
- [How Do I Contribute? ](#how-do-i-contribute )
- [Development Setup ](#development-setup )
- [Building the project ](#building-the-project )
- [Running test ](#running-test )
- [Running and debugging ](#running-and-debugging )
- [Debugging compiled code ](#debugging-compiled-code )
- [Reporting Bugs ](#reporting-bugs )
- [Read the documentation ](#read-the-documentation )
- [What's is not considered a bug? ](#whats-is-not-considered-a-bug )
- [Issue Search ](#issue-search )
- [Chat ](#chat )
- [Request Features ](#request-features )
- [Contributing Guidelines ](#contributing-guidelines )
- [Submitting a Pull Request ](#submitting-a-pull-request )
- [Make Changes and Commit ](#make-changes-and-commit )
- [Caveats ](#caveats )
- [Before Commit ](#before-commit )
- [Commit Guidelines ](#commit-guidelines )
- [Adding a changeset ](#adding-a-changeset )
- [Update Tests ](#update-tests )
- [Develop Plugins ](#develop-plugins )
2017-05-14 03:14:32 -05:00
2018-10-31 09:58:16 -05:00
## How Do I Contribute?
2017-05-14 03:14:32 -05:00
2021-08-12 13:05:27 -05:00
There are many ways to contribute:
2017-05-14 03:14:32 -05:00
2021-08-12 13:05:27 -05:00
- Report a bug
- Request a feature you think would be great for Verdaccio
- Fix bugs
- Test and triage bugs reported by others
- Work on requested/approved features
- Improve the codebase (linting, naming, comments, test descriptions, etc...)
2017-05-14 03:14:32 -05:00
2021-08-12 13:05:27 -05:00
The Verdaccio project is split into several areas:
2020-09-07 00:36:08 -05:00
- **Core**: The [core ](https://github.com/verdaccio/verdaccio ) is the main repository, built with **Node.js** .
2021-08-12 13:05:27 -05:00
- **Website**: we use [**Docusaurus** ](https://docusaurus.io/ ) for the **website** and if you are familiar with this technology, you might become the official webmaster.
2020-09-07 00:36:08 -05:00
- **User Interface**: The [user Interface ](https://github.com/verdaccio/ui ) is based in **react** and **material-ui** and looking for front-end contributors.
- **Kubernetes and Helm**: Ts the official repository for the [**Helm chart** ](https://github.com/verdaccio/charts ).
2021-08-12 13:05:27 -05:00
> There are other areas to contribute, like documentation, translation which are
> not hosted on this repo but check the last section of this notes for further
> information.
2017-05-14 03:14:32 -05:00
2020-10-24 07:08:24 -05:00
## Development Setup
2017-05-11 17:39:07 -05:00
2021-08-12 13:05:27 -05:00
Verdaccio uses [_pnpm_ ](https://pnpm.js.org/ ) as package manager for development
in this repository. Please install the latest one:
2020-09-07 00:36:08 -05:00
```
npm i -g pnpm
```
2018-10-31 09:58:16 -05:00
2020-09-07 00:36:08 -05:00
First step is installing all dependencies:
2018-10-31 09:58:16 -05:00
2020-09-07 00:36:08 -05:00
```
pnpm install
```
2020-10-24 07:08:24 -05:00
### Building the project
2020-09-07 00:36:08 -05:00
To build the project run
```
pnpm build
```
### Running test
```
pnpm test
```
2021-08-12 13:05:27 -05:00
Verdaccio is a mono repository. To run the tests for for a specific package:
2020-09-07 00:36:08 -05:00
```
cd packages/store
pnpm test
```
2021-08-12 13:05:27 -05:00
or an specific test in that package:
2020-09-07 00:36:08 -05:00
```
pnpm test test/merge.dist.tags.spec.ts
```
2021-08-12 13:05:27 -05:00
or a single test unit:
2020-09-07 00:36:08 -05:00
2020-10-24 07:08:24 -05:00
```
2020-09-07 00:36:08 -05:00
pnpm test test/merge.dist.tags.spec.ts -- -t 'simple'
```
2021-08-12 13:05:27 -05:00
Coverage reporting is enabled by default, but you can turn it off to speed up
test runs:
2020-09-07 00:36:08 -05:00
```
pnpm test test/merge.dist.tags.spec.ts -- -t 'simple' --coverage=false
```
2021-08-12 13:05:27 -05:00
You can enable increased [`debug` ](https://www.npmjs.com/package/debug ) output:
2020-09-07 00:36:08 -05:00
```
2021-08-12 13:05:27 -05:00
DEBUG=verdaccio:* pnpm test
2020-09-07 00:36:08 -05:00
```
More details in the debug section
### Running and debugging
2021-08-12 13:05:27 -05:00
We use [`debug` ](https://www.npmjs.com/package/debug ) to add helpful debugging
output to the code. Each package has it owns namespace.
2020-09-07 00:36:08 -05:00
2021-08-12 13:05:27 -05:00
#### Debugging compiled code
2020-09-07 00:36:08 -05:00
2021-08-12 13:05:27 -05:00
Currently you can only run pre-compiled packages in debug mode. To enable debug
while running add the `verdaccio` namespace using the `DEBUG` environment
variable, like this:
2020-09-07 00:36:08 -05:00
```
DEBUG=verdaccio:* node packages/verdaccio/debug/bootstrap.js
```
2018-10-31 09:58:16 -05:00
2021-08-12 13:05:27 -05:00
You can filter this output to just the packages you're interested in using
namespaces:
2018-10-31 09:58:16 -05:00
2020-09-07 00:36:08 -05:00
```
DEBUG=verdaccio:plugin:* node packages/verdaccio/debug/bootstrap.js
```
2021-08-12 13:05:27 -05:00
The debug code is intended to analyze what is happening under the hood and none
of the output is sent to the logger module.
2020-09-07 00:36:08 -05:00
## Reporting Bugs
2021-08-12 13:05:27 -05:00
**Bugs are considered features that are not working as described in
documentation.**
2017-05-11 17:39:07 -05:00
2020-09-03 14:15:29 -05:00
If you've found a bug in Verdaccio **that isn't a security risk** , please file
2018-10-31 09:58:16 -05:00
a report in our [issue tracker ](https://github.com/verdaccio/verdaccio/issues ).
2017-05-11 17:39:07 -05:00
2020-09-07 00:36:08 -05:00
> **NOTE: Verdaccio still does not support all npm commands. Some were not
> considered important and others have not been requested yet.**
2017-05-11 17:39:07 -05:00
2020-09-07 00:36:08 -05:00
### What's is not considered a bug?
2018-10-31 09:58:16 -05:00
2021-08-12 13:05:27 -05:00
- _Third party integrations_: proxies integrations, external plugins
- _Package managers_: If a package manager does not support a specific command
or cannot be reproduced with another package manager
- _Features clearly flagged as not supported_
- _Node.js issues installation in any platform_: If you cannot install the
global package (this is considered external issue)
- Any ticket which has beed flagged as an [external issue
](https://github.com/verdaccio/verdaccio/labels/external-issue)
2020-09-03 14:15:29 -05:00
2021-08-12 13:05:27 -05:00
If you intend to report a **security** issue, please follow our [Security policy
guidelines](https://github.com/verdaccio/verdaccio/security/policy).
2018-10-31 09:58:16 -05:00
2020-09-07 00:36:08 -05:00
### Issue Search
2017-05-11 17:39:07 -05:00
2021-08-12 13:05:27 -05:00
Before reporting a bug please:
2017-05-11 17:39:07 -05:00
2021-08-12 13:05:27 -05:00
- Search for existing issues to see if it has already been reported
- Look for the **question** label: we have labelled questions for easy follow-up
as [questions ](https://github.com/verdaccio/verdaccio/labels/question )
2017-05-11 17:39:07 -05:00
2021-08-12 13:05:27 -05:00
In case any of those match with your search, up-vote it (using GitHub reactions)
or add additional helpful details to the existing issue to show that it's
affecting multiple people.
2017-05-11 17:39:07 -05:00
2020-09-07 00:36:08 -05:00
### Chat
2017-05-11 17:39:07 -05:00
2020-09-07 00:36:08 -05:00
Questions can be asked via [Discord ](http://chat.verdaccio.org/ )
**Please use the `#help` channel.**
2017-05-11 17:39:07 -05:00
## Request Features
2018-10-31 09:58:16 -05:00
New feature requests are welcome. Analyse whether the idea fits within scope of
2021-08-12 13:05:27 -05:00
the project. Adding in context and the use-case will really help!
2017-05-11 17:39:07 -05:00
2018-10-31 09:58:16 -05:00
**Please provide:**
2020-09-03 14:15:29 -05:00
- A detailed description the advantages of your request
2021-08-12 13:05:27 -05:00
- Whether or not it's compatible with `npm` , `pnpm` and [_yarn classic_
](https://github.com/yarnpkg/yarn) or [_yarn berry_
](https://github.com/yarnpkg/berry).
2020-09-03 14:15:29 -05:00
- A potential implementation or design
2021-08-12 13:05:27 -05:00
- Whatever else is on your mind! 🤓
2017-05-11 17:39:07 -05:00
2020-10-24 07:08:24 -05:00
## Contributing Guidelines
2020-09-07 00:36:08 -05:00
2021-08-12 13:05:27 -05:00
It's very exciting to become a Verdaccio contributor 🙌🏼. To ensure a fast code
review and merge, please follow the next guidelines:
2020-09-07 00:36:08 -05:00
2021-08-12 13:05:27 -05:00
> Any contribution gives you the right to be part of this organization as
> _collaborator_.
2020-09-07 00:36:08 -05:00
2017-05-12 07:46:39 -05:00
### Submitting a Pull Request
2018-10-31 09:58:16 -05:00
The following are the steps you should follow when creating a pull request.
Subsequent pull requests only need to follow step 3 and beyond.
2017-05-12 07:46:39 -05:00
1. Fork the repository on GitHub
2. Clone the forked repository to your machine
2018-03-10 11:30:56 -05:00
3. Make your changes and commit them to your local repository
4. Rebase and push your commits to your GitHub remote fork/repository
5. Issue a Pull Request to the official repository
6. Your Pull Request is reviewed by a committer and merged into the repository
2017-05-12 07:46:39 -05:00
2018-10-31 09:58:16 -05:00
**NOTE**: While there are other ways to accomplish the steps using other tools,
the examples here will assume most actions will be performed via `git` on
command line.
2017-05-12 07:46:39 -05:00
2018-10-31 09:58:16 -05:00
For more information on maintaining a fork, please see the GitHub Help article
titled [Fork a Repo ](https://help.github.com/articles/fork-a-repo/ ), and
information on [rebasing ](https://git-scm.com/book/en/v2/Git-Branching-Rebasing ).
2017-05-12 07:46:39 -05:00
2018-03-10 11:30:56 -05:00
### Make Changes and Commit
2017-05-12 07:46:39 -05:00
2020-10-24 07:08:24 -05:00
#### Caveats
2020-09-07 00:36:08 -05:00
2021-08-12 13:05:27 -05:00
Feel free to commit as much times you want in your branch, but keep on mind on
this repository we `git squash` on merge by default, as we like to maintain a
clean git history.
2020-09-07 00:36:08 -05:00
2018-10-31 09:58:16 -05:00
#### Before Commit
2017-05-12 07:46:39 -05:00
2018-10-31 09:58:16 -05:00
Before committing, **you must ensure there are no linting errors and
2021-08-12 13:05:27 -05:00
all tests pass.** To do this, run these commands before create the PR:
2017-05-11 17:39:07 -05:00
```bash
2020-09-07 00:36:08 -05:00
pnpm lint
pnpm format
pnpm build
pnpm test
2017-05-11 17:39:07 -05:00
```
2021-08-12 13:05:27 -05:00
> note: eslint and formatting are run separately, keep code formatting
> before push.
2018-10-31 09:58:16 -05:00
2021-08-12 13:05:27 -05:00
All good? Perfect! You should create the pull request.
2017-10-18 14:53:40 -05:00
2020-09-07 00:36:08 -05:00
#### Commit Guidelines
2017-10-18 14:53:40 -05:00
2018-10-31 09:58:16 -05:00
For example:
2017-10-18 14:53:40 -05:00
2020-09-03 14:15:29 -05:00
- `feat: A new feature`
- `fix: A bug fix`
2018-10-31 09:58:16 -05:00
2021-08-12 13:05:27 -05:00
A commit of the type feat introduces a new feature to the codebase (this
correlates with MINOR in semantic versioning).
2018-10-31 09:58:16 -05:00
e.g.:
2017-10-18 14:53:40 -05:00
```
feat: xxxxxxxxxx
2018-10-31 09:58:16 -05:00
```
2017-10-18 14:53:40 -05:00
2021-08-12 13:05:27 -05:00
A commit of the type fix patches a bug in your codebase (this correlates with
PATCH in semantic versioning).
2017-10-18 14:53:40 -05:00
2018-10-31 09:58:16 -05:00
e.g.:
2017-10-18 14:53:40 -05:00
```
2020-09-03 14:15:29 -05:00
fix: xxxxxxxxxxx
2018-10-31 09:58:16 -05:00
```
2021-08-12 13:05:27 -05:00
Commits types such as as `docs:` ,`style:`,`refactor:`,`perf:`,`test:` and
`chore:` are valid but have no effect on versioning: **please use them!**
2018-10-31 09:58:16 -05:00
2021-08-12 13:05:27 -05:00
All commits message are going to be validated when they are created using
_husky_ hooks.
2018-10-31 09:58:16 -05:00
2021-08-12 13:05:27 -05:00
> Please try to provide one single commit to help a clean and easy merge process
2020-09-07 00:36:08 -05:00
2020-10-24 07:08:24 -05:00
### Adding a changeset
2020-09-07 00:36:08 -05:00
2021-08-12 13:05:27 -05:00
We use [changesets ](https://github.com/atlassian/changesets ) in order to
generate a detailed Changelog as possible.
2020-09-07 00:36:08 -05:00
2021-08-12 13:05:27 -05:00
Adding a changeset with your Pull Request is essential if you want your
contribution to get merged (unless is a change that does not affect library
functionality, eg: typo, docs, readme, add additional test or linting code). To
create a changeset please run:
2020-09-07 00:36:08 -05:00
```
pnpm changeset
```
2021-08-12 13:05:27 -05:00
Then select the packages you want to include in your changeset navigating
through them and press the spacebar to check it, on finish press enter to move
to the next step.
2020-09-07 00:36:08 -05:00
```
🦋 Which packages would you like to include? …
✔ changed packages
changed packages
✔ @verdaccio/api
✔ @verdaccio/auth
✔ @verdaccio/cli
✔ @verdaccio/config
✔ @verdaccio/commons -api
```
2021-08-12 13:05:27 -05:00
The next question would be if you want a _major bump_ . This is not the usual
scenario, most likely you want a patch, and in that case press enter 2 times
(to skip minor)
2020-09-07 00:36:08 -05:00
```
🦋 Which packages should have a major bump? …
✔ all packages
✔ @verdaccio/config@5 .0.0-alpha.0
```
2021-08-12 13:05:27 -05:00
Once you have the desired bump you need, the CLI will ask for a summary. Here
you have full freedom on what to include:
2020-09-07 00:36:08 -05:00
```
🦋 Which packages would you like to include? · @verdaccio/config
🦋 Which packages should have a major bump? · No items were selected
🦋 Which packages should have a minor bump? · No items were selected
🦋 The following packages will be patch bumped:
🦋 @verdaccio/config@5 .0.0-alpha.0
🦋 Please enter a summary for this change (this will be in the changelogs). Submit empty line to open external editor
🦋 Summary ›
```
2021-08-12 13:05:27 -05:00
The last step is to confirm your changeset or abort the operation:
2020-09-07 00:36:08 -05:00
```
🦋 Is this your desired changeset? (Y/n) · true
🦋 Changeset added! - you can now commit it
🦋
🦋 If you want to modify or expand on the changeset summary, you can find it here
🦋 info /Users/user/verdaccio.clone/.changeset/light-scissors-smell.md
```
2021-08-12 13:05:27 -05:00
Once the changeset is added (all will have an unique name) you can freely edit
using markdown, adding additional information, code snippets or whatever else
you consider to be relevant.
2020-09-07 00:36:08 -05:00
2021-08-12 13:05:27 -05:00
All that information will be part of the **changelog** . Be concise but
informative! It's recommended to add your nickname and GitHub link to your
profile.
2020-09-07 00:36:08 -05:00
2018-10-31 09:58:16 -05:00
**PRs that do not follow the commit message guidelines will not be merged.**
2017-10-18 14:53:40 -05:00
2020-10-24 07:08:24 -05:00
### Update Tests
2017-10-18 14:53:40 -05:00
2018-10-31 09:58:16 -05:00
**Any change in source code must include test updates**.
2017-10-18 14:53:40 -05:00
2021-08-12 13:05:27 -05:00
If you need help with how testing works, please [refer to the following guide
](https://github.com/verdaccio/verdaccio/wiki/Running-and-Debugging-tests).
2017-05-12 07:46:39 -05:00
2018-10-31 09:58:16 -05:00
**If you are introducing new features, you MUST include new tests. PRs for
features without tests will not be merged.**
2017-05-12 07:46:39 -05:00
2018-10-31 09:58:16 -05:00
## Develop Plugins
2017-05-12 07:46:39 -05:00
2018-10-31 09:58:16 -05:00
Plugins are add-ons that extend the functionality of the application.
2017-05-11 17:39:07 -05:00
2018-10-31 09:58:16 -05:00
If you want to develop your own plugin:
2017-02-18 06:05:12 -05:00
2018-10-31 09:58:16 -05:00
1. Check whether there is a legacy Sinopia plugin for the feature that you need
2020-09-03 14:15:29 -05:00
via [npmjs ](https://www.npmjs.com/search?q=sinopia )
2021-08-12 13:05:27 -05:00
2. Keep in mind the [life-cycle to load a plugin
](https://verdaccio.org/docs/en/dev-plugins)
2020-09-07 00:36:08 -05:00
3. You are free to host your plugin in your repository
2021-08-12 13:05:27 -05:00
4. Provide a detailed description of your plugin to help users understand how to
use it