Skip to content

Commit

Permalink
Merge branch 'master' into add-node12-travis
Browse files Browse the repository at this point in the history
  • Loading branch information
misterdev committed May 5, 2019
2 parents b26abd1 + f0031fd commit 89b307a
Show file tree
Hide file tree
Showing 40 changed files with 2,352 additions and 2,656 deletions.
170 changes: 103 additions & 67 deletions .github/CONTRIBUTING.md
Expand Up @@ -5,6 +5,34 @@ appreciated and welcomed. If you're planning a new feature or changing
the API, please create an issue first. This way we can ensure that your precious
work is not in vain.

Table of Contents

- [Issues](#issues)
- [Your first Contribution](#your-first-contribution)
- [Setup](#setup)
- [Using npm](#using-npm)
- [Using yarn](#using-yarn)
- [Running Tests](#running-tests)
- [Using npm](#using-npm-1)
- [Using yarn](#using-yarn-1)
- [Editor Config](#editor-config)
- [Dependencies](#dependencies)
- [Branching Model](#branching-model)
- [Naming a branch](#naming-a-branch)
- [Features](#features)
- [Fixes](#fixes)
- [Testing](#testing)
- [Pull Requests](#pull-requests)
- [Submitting a good Pull Request](#submitting-a-good-pull-request)
- [Commit message](#commit-message)
- [Commit Message Format](#commit-message-format)
- [Migrate with the CLI](#migrate-with-the-cli)
- [How it's being done](#how-its-being-done)
- [Structure of a transform](#structure-of-a-transform)
- [Further Work](#further-work)
- [Contributor License Agreement](#contributor-license-agreement)
- [Documentation](#documentation)

## Issues

Most of the time, when webpack does not work correctly, it might be a configuration issue.
Expand All @@ -19,30 +47,30 @@ that include your `webpack.config.js` and relevant files. This way you help othe

First of all, you will need to create an issue in Github for the feature or bugfix that you want to work on. When you open a new issue, there will be a template that will be automatically added to the text of the issue, which you would need to fill in. Doing this will help us to understand better what the ticket is about.

After you've created the issue, we will have a look, and provide feedback to your ticket.
After you've created the issue, we will have a look, and provide feedback to your ticket.

In case it is a bug that you want to fix, we might help you with background information about the issue, so you can make an informed fix.

In case you are suggesting a new feature, we will match your idea with our current roadmap, and will open conversations about it. Once the discussion has been done, and the tasks cleared, then you're ready to code.

## Setup

* Install [Node.js](https://nodejs.org/) if you don't have it already.
*Note: Node 6 or greater would be better for "best results".*
* Fork the **webpack-cli** repo at [https://github.com/webpack/webpack-cli](https://github.com/webpack/webpack-cli).
* `git clone <your-clone-url> && cd webpack-cli`
- Install [Node.js](https://nodejs.org/) if you don't have it already.
_Note: Node 6 or greater would be better for "best results"._
- Fork the **webpack-cli** repo at [https://github.com/webpack/webpack-cli](https://github.com/webpack/webpack-cli).
- `git clone <your-clone-url> && cd webpack-cli`

### Using npm

* Install the dependencies and link them:
- Install the dependencies and link them:

```bash
npm install
npm link
npm link webpack-cli
```

* Bootstrap all the submodules before building for the first time
- Bootstrap all the submodules before building for the first time

```bash
npm run bootstrap
Expand All @@ -51,103 +79,102 @@ In case you are suggesting a new feature, we will match your idea with our curre

### Using yarn

* If you don't have yarn yet:
- If you don't have yarn yet:

```bash
npm install -g yarn
```
* Install the dependencies and link them

- Install the dependencies and link them

```bash
yarn
yarn link
yarn link webpack-cli
```

* Bootstrap all the submodules before building for the first time
- Bootstrap all the submodules before building for the first time

```bash
yarn bootstrap
yarn build
```


## Testing
## Running Tests

### Using npm

* Run all the tests with:
- Run all the tests with:

```bash
npm run test
```

* Run CLI tests with:
- Run CLI tests with:

```bash
npm run test:cli
```

* Run tests of all packages:
- Run tests of all packages:

```bash
npm run test:packages
```

* Test a single CLI test case:
- Test a single CLI test case:

```bash
npx jest path/to/my-test.js
npx jest path/to/my-test.js
```

* You can also install jest globally and run tests without npx:
- You can also install jest globally and run tests without npx:

```bash
npm i -g jest
jest path/to/my-test.js
```

* You can run the linters:
- You can run the linters:

```bash
npm run lint
```

### Using yarn

* Run all the tests with:
- Run all the tests with:

```bash
yarn test
```

* Run CLI tests with:
- Run CLI tests with:

```bash
yarn test:cli`
```

* Run tests of all packages:
- Run tests of all packages:

```bash
yarn test:packages
```

* Test a single CLI test case:
- Test a single CLI test case:

```bash
yarn jest path/to/my-test.js
```
* You can also install jest globally and run tests:

- You can also install jest globally and run tests:

```bash
yarn global add jest
jest path/to/my-test.js
```

* You can run the linters:
- You can run the linters:

```bash
yarn lint
Expand All @@ -157,6 +184,12 @@ In case you are suggesting a new feature, we will match your idea with our curre

The [.editorconfig](https://github.com/webpack/webpack-cli/blob/master/.editorconfig) in the root should ensure consistent formatting. Please make sure you've [installed the plugin](http://editorconfig.org/#download) if your text editor needs one.
## Dependencies
This is a multi-package repository and dependencies are managed using [lerna](https://lerna.js.org/)
> If you are adding or updating any dependency, please commit the updated `package-lock.json` file.
## Branching Model
We base our branching model on [git flow](http://nvie.com/posts/a-successful-git-branching-model/). Instead of working with a `develop` base branch, we use the `master` branch. We do it to ease the workflow a bit. However, we find that adding prefixes to the branches is useful.
Expand All @@ -165,15 +198,15 @@ We base our branching model on [git flow](http://nvie.com/posts/a-successful-git
Making a branch in your fork for your contribution is helpful in the following ways:
* It allows you to submit more than one contribution in a single PR.
* It allows us to identify what your contribution is about from the branch name.
- It allows you to submit more than one contribution in a single PR.
- It allows us to identify what your contribution is about from the branch name.
You will want to checkout the `master` branch locally before creating your new branch.
There are two types of branches:
* Feature
* Bugfix
- Feature
- Bugfix
### Features
Expand All @@ -189,7 +222,7 @@ If you are fixing an existing bug, you can create a branch with the following pr
## Testing
Every bugfix or feature that you submit, needs to be tested. Writing tests for code is very important to prevent future bugs, and help to discover possible new bugs promptly.
Every bugfix or feature that you submit, needs to be tested. Writing tests for the code is very important to prevent future bugs, and help to discover possible new bugs promptly.
It is important that you test the logic of the code you're writing, and that your tests really go through all your lines, branches and statements. This is the only way to ensure that the code coverage is high enough to ensure the users of the cli, that they are using a solid tool.

Expand All @@ -204,11 +237,11 @@ In case you've got a small change in most of the cases, your pull request would
## Submitting a good Pull Request
* Write tests
* Follow the existing coding style
* Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
- Write tests
- Follow the existing coding style
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
## Commit message format
## Commit message
Our commit messages format follows the [angular.js commits format](https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#commit-message-format).
Expand All @@ -217,27 +250,30 @@ You can use `npm run commit` script to have an interactive way of making commits
We don't use the scope. The template of a commit would look like this:

### Commit Message Format
Each commit message consists of a **header**, a **body** and a **footer**. The header has a special

Each commit message consists of a **header**, a **body** and a **footer**. The header has a special
format that includes a **type** and a **subject**:

```
```md
<type>: <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
```

This is the list of *type* of commits that we accept:
* ast
* break
* chore
* cli
* docs
* feat
* fix
* misc
* tests
This is the list of _type_ of commits that we accept:

- ast
- break
- chore
- cli
- docs
- feat
- fix
- misc
- tests

The **header** is mandatory.

Expand All @@ -247,11 +283,11 @@ to read on GitHub as well as in several git tools.
For more information about what each part of the template mean, head up to the documentation in the
[angular repo](https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#commit-message-format)

## --migrate with the CLI
## Migrate with the CLI

This is a new feature in development for the CLI.

```
```sh
webpack --migrate <your-config-name>
```

Expand Down Expand Up @@ -293,30 +329,30 @@ This is where you declare a new test case for your transformation.
Each test will refer to an input webpack config snippet.
Conventionally we write them in `\_\_testfixtures\_\_`.

```
const defineTest = require('../defineTest');
```js
const defineTest = require("../defineTest");
defineTest(__dirname, 'transform-name.input1.js');
defineTest(__dirname, 'transform-name.input2.js');
defineTest(__dirname, "transform-name.input1.js");
defineTest(__dirname, "transform-name.input2.js");
```

`defineTest` is a helper test method which helps us to run tests on all the transforms uniformly.
It takes the input file given as parameter and uses jest to create a snapshot of the output. This effectively tests the correctness of our transformation.

### TODO
### Further Work

This is still in a very raw form. We'd like to take this as close to a truly useful tool as possible.
We will still need to
- Support all kinds of webpack configuration(made using merge tools)
- Test these transforms against real-world configurations.
- Support all kinds of webpack configuration(made using merge tools)
- Test these transforms against real-world configurations.
## Contributor License Agreement
When submitting your contribution, a CLA (Contributor License Agreement) bot will come by to verify that you signed the CLA. If you are submitting a PR for the first time, it will link you to the right place to sign it. If you have committed your contributions using an email that is not the same as your email used on GitHub, the CLA bot can't accept your contribution.

Run `git config user.email` to see your Git email, and verify it with [your GitHub email](https://github.com/settings/emails).


## Documentation

webpack is feature rich and documentation is a time sink. We
Expand Down

0 comments on commit 89b307a

Please sign in to comment.