Skip to content

Contributing

Charl Gottschalk edited this page Aug 10, 2016 · 10 revisions

If you would like to contribute to ApproveJs, thank you. Here's how you do it.

  1. Fork your own copy of the repo.
  2. Clone your newly forked copy to your local machine.
  3. Open a terminal / command line and cd to the root directory.
  4. Install dev dependencies. In your terminal, run npm install.

Once NPM has finished installing all dependecies, you can make any changes you want.

Before you commit

1. Bump the version

ApproveJs uses semantic versioning (semver) and each change requires the version to be incremented depending on the type of change.

The version looks like the following:

1.0.2 or [major].[minor].[patch]

Bug / Issue

If you fixed a bug or an issue with the code you need to increment the [patch] by one (+1).

New Feature / Test

If you added a new feature or a new test, you need to increment the [minor] by one (+1).

Potential Incompatibillity

If you made a change that could possibly break previous versions of the library or is not backwards compatible, you need to increment the [major] by one (+1).

The version number needs to be bumped in the following files:

  • package.json version property
  • src/_01.pre.js top comment : * approve.js v...
  • src/_02.approve.js version property (line 29): approve.VERSION = '...';
  • README.md version badge stable x.x.x (line 3):
![stable x.x.x](https://img.shields.io/badge/stable-x.x.x-green.svg)
2. Lint

Before you compile the library, you need to lint to check for errors and potential problems in your code. Fix any problems that appear before continuing.

In your terminal, run:

gulp lint
```

*If you created an additional file, remember to add it to the `lintFiles` array in `gulpfile.js`.*

##### 3. Compile

Now you can compile the library. This will create the distribution (`dist/*`) files, and update the documentation.

In your terminal, run:

```
gulp
```

##### 4. Test

Now you need to make sure the code doesn't break. 

In your terminal, run:

```
gulp test
```

or

```
npm run-script test
```

Check to see if all tests pass, and fix any errors.

*If you created a new test or feature, make sure to add a `describe()` or `it()` for it in `test/tests.js`.*

ApproveJs uses [mocha](https://mochajs.org) and [chai](http://chaijs.com/) assertion library for testing.

##### 5. Commit

If everything checks out and all tests pass, commit the changes to your forked copy.

##### 6. Create a pull request

[Create a pull request](https://help.github.com/articles/creating-a-pull-request/) and describe in as much detail as possible the changes you made.

#### Note

###### Commenting

Please comment your code thoroughly, and use [JSDoc](http://usejsdoc.org/) comment blocks for additional / new methods. 

For an example, please see `src/_03.approve.creditcard.js`.

###### Additional Files

If your change includes an additional / new file inside the `src/` folder, please make sure you name it correctly. When the gulp task compiles the library, it appends each file according to an order, represented by a number in each file's name.

Each file's name starts with an underscore `_` followed by a number representing the order in which to compile the file, followed by `.approve`, followed by another dot `.`, followed by the name of the feature or test, followed by `.js`. For example:

```
_03.approve.creditcard.js
```

The following files should never be renamed:

- `src/_01.pre.js`
- `src/_02.approve.js`

The last file in the folder `_**.post.js` should be renamed so that its number is always last.