## This utility is for node and express. It formats the console output for easy readability and provides a node package.json version incrementor.
# Installation
Install by running npm install debug-tool-express --save-dev
. You will then need to require it into your project.
"chalk": "^1.1.3",
"dotenv": "^4.0.0"
#Using The Debugger
To add a debug message to your code pass the .debug
method an object. The following values can be defined but all are optional. There are three message levels. They are ERROR
, INFO
and DEBUG
.
{
logMsg = ''
method = ''
url = ''
ip = ''
level = 'Selected one of the levels above.'
}
The debugging logger messages for this application have 3 levels. They are error, info, and debug.
Set the DEBUG=opt
to one of the opt
below. This will output specific level messages to the console.
Debug Option | Debug Message Outputs |
---|---|
true | Outputs all debug messages. |
debug | Outputs all debug messages. |
info | Outputs the info, and error debug messages. |
error | Outputs the error debug messages. |
# Version Updater
The version updater has two different methods: updateManual and updateAuto. The class is exported as update.
This method takes two parameters: the current version and the type of release. The available release types are major, minor, and patch. The updateManual method will just return the value for the new current version based on your inputs. The following examples assume you have required the file with the variable v:
For Manual updates:
v.update.updateManual('1.0.1', major) returns: 2.0.0
v.update.updateManual('1.0.1', minor) returns: 1.1.1
v.update.updateManual('1.0.1', patch) returns: 1.0.2
This method accepts on parameter for the release type: major, minor, or patch. This method will pull the current release number from the package.json file and make the appropriate changes to the version based on the release parameter given. The following examples assume you have required the file with the variable v:
For Auto updates:
v.update.updateAuto('major') automatically updates the major release in package.json and resets minor and patch to zero
v.update.updateAuto('minor') automatically updates the minor release in package.json
v.update.updateAuto('patch') automatically updates the patch release in package.json
updateAuto will also return a status of 'package.json updated'.
When adding features to the URL Shorter the feature branch workflow should be used. This means the following steps should be taken.
-
git checkout master
- Switch to the master branch. -
git pull
- Pull any updates. -
git branch <feature-name>
- Create a new feature.branch replacing<feature-name>
with the feature name. -
git checkout <feature-name>
- Switch to that branches name. - Work on your code and push to the feature branch.
-
git checkout master
- When done switch to the master branch. -
git pull
- Pull any updates from the master -
git checkout <feature-name
- Switch back to the feature branch. -
git merge master
- Merge any changes from the master. - Commit and push any changes if necessary.
- Create a pull request for your feature into the master branch. Codeship must get a green build before this is allowed.
##Unit Testing To unit test the debugger run `mocha` in the packages main directory.
# Code Styling ## AirBnb JavaScript This projected follows the AirBnb Javascript styling conventions. Their documentation can be found at [https://github.com/airbnb/javascript](https://github.com/airbnb/javascript "AirBnb JavaScript Style Guide").