Skip to content

Commit

Permalink
upgrade: various dev deps and update Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
DonutEspresso committed Jun 13, 2018
1 parent c2234b4 commit b2ea120
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 120 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Thumbs.db

/node_modules/
npm-debug.log
yarn.lock
package-lock.json

# VIM viles #
#############
Expand All @@ -23,3 +25,4 @@ Session.vim
# Unit Test Coverage #
######################
coverage/
.nyc_output/
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
language: node_js
node_js:
- "4"
- "6"
- "node"
- "lts/*" # Active LTS release
- "node" # Latest stable release
before_install: 'make clean'
install: 'make'
script: 'make coverage'
after_success: 'make report-coverage'
105 changes: 53 additions & 52 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,114 +3,115 @@
#
ROOT_SLASH := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
ROOT := $(patsubst %/,%,$(ROOT_SLASH))
NODE_MODULES := $(ROOT)/node_modules
NODE_BIN := $(NODE_MODULES)/.bin
TEST := $(ROOT)/test
TOOLS := $(ROOT)/tools
GITHOOKS_SRC := $(TOOLS)/githooks
GITHOOKS_DEST := $(ROOT)/.git/hooks


#
# Generated Files & Directories
#
NODE_MODULES := $(ROOT)/node_modules
NODE_BIN := $(NODE_MODULES)/.bin
COVERAGE := $(ROOT)/.nyc_output
COVERAGE_RES := $(ROOT)/coverage
YARN_LOCK := $(ROOT)/yarn.lock
PACKAGE_LOCK := $(ROOT)/package-lock.json


#
# Tools and binaries
#
NPM := npm
YARN := yarn
ESLINT := $(NODE_BIN)/eslint
JSCS := $(NODE_BIN)/jscs
MOCHA := $(NODE_BIN)/mocha
_MOCHA := $(NODE_BIN)/_mocha
ISTANBUL := $(NODE_BIN)/istanbul
NYC := $(NODE_BIN)/nyc
COVERALLS := $(NODE_BIN)/coveralls
NSP := $(NODE_BIN)/nsp
NSP_BADGE := $(TOOLS)/nspBadge.js
CHANGELOG := $(TOOLS)/changelog.js


#
# Files
# Files and globs
#
PACKAGE_JSON := $(ROOT)/package.json
LIB_FILES := $(ROOT)/lib
TEST_FILES := $(ROOT)/test
COVERAGE_FILES := $(ROOT)/coverage
LCOV := $(ROOT)/coverage/lcov.info
SHRINKWRAP := $(ROOT)/npm-shrinkwrap.json
GITHOOKS := $(wildcard $(GITHOOKS_SRC)/*)
SRCS := $(shell find $(LIB_FILES) $(TEST_FILES) -name '*.js' -type f)

LCOV := $(COVERAGE)/lcov.info
ALL_FILES := $(shell find $(ROOT) \
-not \( -path $(NODE_MODULES) -prune \) \
-not \( -path $(COVERAGE) -prune \) \
-not \( -path $(COVERAGE_RES) -prune \) \
-name '*.js' -type f)
TEST_FILES := $(shell find $(TEST) -name '*.js' -type f)

#
# Targets
#

$(NODE_MODULES): $(PACKAGE_JSON) ## Install node_modules
$(NPM) install
@$(YARN)
@touch $(NODE_MODULES)


.PHONY: all
all: clean node_modules lint codestyle test
.PHONY: help
help:
@perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) \
| sort | awk 'BEGIN {FS = ":.*?## "}; \
{printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'


.PHONY: githooks
githooks: $(GITHOOKS)## Symlink githooks
githooks: $(GITHOOKS) ## Symlink githooks
@$(foreach hook,\
$(GITHOOKS),\
ln -sf $(hook) $(GITHOOKS_DEST)/$(hook##*/);\
)


.PHONY: lint
lint: $(NODE_MODULES) $(ESLINT) $(SRCS)
@$(ESLINT) $(SRCS)
.PHONY: changelog
changelog: $(NODE_MODULES) $(CHANGELOG) ## Run changelog
@$(CHANGELOG) generate


.PHONY: nsp
nsp: $(NODE_MODULES) $(NSP)
ifeq ($(wildcard $(SHRINKWRAP)),)
@$(NPM) shrinkwrap --dev
@($(NSP) check) | $(NSP_BADGE)
@rm $(SHRINKWRAP)
else
@($(NSP) check) | $(NSP_BADGE)
endif
.PHONY: release
release: $(NODE_MODULES) $(CHANGELOG) ## Create a release
@$(CHANGELOG) release


.PHONY: codestyle
codestyle: $(NODE_MODULES) $(JSCS) $(SRCS)
@$(JSCS) $(SRCS)
.PHONY: lint
lint: $(NODE_MODULES) $(ESLINT) $(ALL_FILES) ## Run lint checker (eslint).
@$(ESLINT) $(ALL_FILES)


.PHONY: codestyle-fix
codestyle-fix: $(NODE_MODULES) $(JSCS) $(SRCS)
@$(JSCS) $(SRCS) --fix
.PHONY: security
security: $(NODE_MODULES) ## Check for dependency vulnerabilities.
@$(NPM) install --package-lock-only
@$(NPM) audit


.PHONY: prepush
prepush: $(NODE_MODULES) lint codestyle test nsp
prepush: $(NODE_MODULES) lint coverage security ## Git pre-push hook task. Run before committing and pushing.


.PHONY: test
test: $(NODE_MODULES) $(MOCHA) $(SRCS)
@$(MOCHA) -R spec --full-trace
test: $(NODE_MODULES) $(MOCHA) ## Run unit tests.
@$(MOCHA) -R spec --full-trace --no-exit --no-timeouts $(TEST_FILES)


.PHONY: coverage
coverage: $(NODE_MODULES) $(ISTANBUL) $(SRCS)
@$(ISTANBUL) cover $(_MOCHA) --report lcovonly -- -R spec


.PHONY: report-coverage
report-coverage: coverage
@cat $(LCOV) | $(COVERALLS)
coverage: $(NODE_MODULES) $(NYC) ## Run unit tests with coverage reporting. Generates reports into /coverage.
@$(NYC) --reporter=html --reporter=text make test


.PHONY: clean-coverage
clean-coverage:
@rm -rf $(COVERAGE_FILES)
.PHONY: report-coverage ## Report unit test coverage to coveralls
report-coverage: $(NODE_MODULES) $(NYC) ## Run unit tests with coverage reporting. Generates reports into /coverage.
@$(NYC) report --reporter=text-lcov make test | $(COVERALLS)


.PHONY: clean
clean: clean-coverage
@rm -rf $(NODE_MODULES)
clean: ## Cleans unit test coverage files and node_modules.
@rm -rf $(NODE_MODULES) $(COVERAGE) $(COVERAGE_RES) $(YARN_LOCK) $(PACKAGE_LOCK)


#
Expand Down
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
[![Coverage Status](https://coveralls.io/repos/github/DonutEspresso/reissue/badge.svg?branch=master)](https://coveralls.io/github/DonutEspresso/reissue?branch=master)
[![Dependency Status](https://david-dm.org/DonutEspresso/reissue.svg)](https://david-dm.org/DonutEspresso/reissue)
[![devDependency Status](https://david-dm.org/DonutEspresso/reissue/dev-status.svg)](https://david-dm.org/DonutEspresso/reissue#info=devDependencies)
[![bitHound Score](https://www.bithound.io/github/DonutEspresso/reissue/badges/score.svg)](https://www.bithound.io/github/DonutEspresso/reissue/master)
[![NSP Status](https://img.shields.io/badge/NSP%20status-no%20vulnerabilities-green.svg)](https://travis-ci.org/DonutEspresso/reissue)

> setInterval with setTimeout semantics
Expand Down Expand Up @@ -130,14 +128,9 @@ Before committing, run the prepush hook:
make prepush
```

If you have style errors, you can auto fix whitespace issues by running:

```sh
make codestyle-fix
```

## License

Copyright (c) 2017 Alex Liu
Copyright (c) 2018 Alex Liu

Licensed under the MIT license.
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@
"prepush": "make prepush"
},
"devDependencies": {
"chai": "^3.4.1",
"coveralls": "^2.11.6",
"eslint": "^3.14.0",
"istanbul": "^0.4.2",
"jscs": "^3.0.7",
"mocha": "^3.2.0",
"nsp": "^2.2.0"
"chai": "^4.1.2",
"coveralls": "^3.0.1",
"eslint": "^4.19.1",
"is-stream": "^1.1.0",
"mocha": "^5.2.0",
"nyc": "^12.0.2"
},
"dependencies": {
"assert-plus": "^1.0.0"
Expand Down
51 changes: 0 additions & 51 deletions tools/nspBadge.js

This file was deleted.

0 comments on commit b2ea120

Please sign in to comment.