Skip to content

Commit

Permalink
Add comments and install jsdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
daern91 committed Feb 4, 2018
1 parent 7beb0b9 commit a4cda7e
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ build/Release
node_modules/
jspm_packages/
.vscode/
out/

# Typescript v1 declaration files
typings/
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
[![Coverage Status](https://coveralls.io/repos/github/daern91/build-actions/badge.svg?branch=master)](https://coveralls.io/github/daern91/build-actions?branch=master)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)


A small library to diff Customers and build update actions.

## Installation
Expand All @@ -25,13 +24,14 @@ Execute these commands in the project's root directory:

* `npm run generate-data` - Generate a data.json file with test customers.
* Duplicate the data.json file and change some of the customer info in the new copy, e.g. `email`.
* `clitest import --file testCustomers/<newFileName.json>`
* `buildactions import --file testCustomers/<newFileName.json>`

## Setup (npm)

`npm install @daern91/build-actions`

## Usage

```javascript
const buildActions = require('@daern91/build-actions');

Expand All @@ -40,9 +40,12 @@ const actions = buildActions(oldCustomerObject, newCustomerObject);
// Output should be an array of update actions
```

**NOTE: You may also use CLI by installing package globally with `npm install @daern91/build-actions -g`**

## Tests

* `npm test` or `npm run cover` for full testing including coverage.
* `npm test` for full testing including lint.
* `npm run cover` for full testing including coverage.

### Requirements

Expand Down
119 changes: 119 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@daern91/build-actions",
"version": "0.0.6",
"version": "0.1.0",
"description": "",
"main": "src/index.js",
"bin": {
"clitest": "bin/cli.js"
"buildactions": "bin/cli.js"
},
"scripts": {
"test": "standard && mocha --reporter spec",
Expand Down Expand Up @@ -34,6 +34,7 @@
"faker": "^4.1.0",
"husky": "^0.14.3",
"istanbul": "^0.4.5",
"jsdoc": "^3.5.5",
"lint-staged": "^6.1.0",
"make-dir": "^1.1.0",
"mocha": "^5.0.0",
Expand Down
6 changes: 3 additions & 3 deletions src/buildActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ function getActionType (oldValue, newValue, isDeleted) {
} else if (!_.isNil(oldValue) && !_.isNil(newValue)) {
return 'change'
} else {
throw new Error(
'Incorrect data type (Object value should be crowded string).'
)
throw new Error('Incorrect data type')
}
}

Expand All @@ -25,6 +23,8 @@ function getActionFromDiff (diff, field) {
if (field.indexOf('address') >= 0 && operation === 'set') {
operation = 'add'
}

// TODO: Add rest of allowed calls from docs
const allowedFields = [
'firstName',
'lastName',
Expand Down

0 comments on commit a4cda7e

Please sign in to comment.