| 1 |
NPM_PACKAGE := $(shell node -e 'process.stdout.write(require("./package.json").name)') |
| 2 |
NPM_VERSION := $(shell node -e 'process.stdout.write(require("./package.json").version)') |
| 3 |
|
| 4 |
TMP_PATH := /tmp/${NPM_PACKAGE}-$(shell date +%s) |
| 5 |
|
| 6 |
REMOTE_NAME ?= origin |
| 7 |
REMOTE_REPO ?= $(shell git config --get remote.${REMOTE_NAME}.url) |
| 8 |
|
| 9 |
CURR_HEAD := $(firstword $(shell git show-ref --hash HEAD | cut --bytes=-6) master) |
| 10 |
GITHUB_PROJ := https://github.com/nodeca/${NPM_PACKAGE} |
| 11 |
|
| 12 |
|
| 13 |
lint: |
| 14 |
./node_modules/.bin/eslint . |
| 15 |
|
| 16 |
|
| 17 |
test: lint |
| 18 |
rm -rf coverage |
| 19 |
./node_modules/.bin/istanbul cover node_modules/.bin/_mocha |
| 20 |
|
| 21 |
|
| 22 |
report-coverage: |
| 23 |
./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage |
| 24 |
|
| 25 |
|
| 26 |
demo: lint |
| 27 |
rm -rf ./demo |
| 28 |
mkdir ./demo |
| 29 |
./support/demodata.js > ./support/demo_template/sample.json |
| 30 |
./node_modules/.bin/jade ./support/demo_template/index.jade --pretty \ |
| 31 |
--obj ./support/demo_template/sample.json \ |
| 32 |
--out ./demo |
| 33 |
./node_modules/.bin/stylus -u autoprefixer-stylus \ |
| 34 |
< ./support/demo_template/index.styl \ |
| 35 |
> ./demo/index.css |
| 36 |
rm -rf ./support/demo_template/sample.json |
| 37 |
./node_modules/.bin/browserify ./support/demo_template/index.js > ./demo/index.js |
| 38 |
|
| 39 |
|
| 40 |
doc: |
| 41 |
rm -rf ./doc |
| 42 |
./node_modules/.bin/ndoc --link-format "{package.homepage}/blob/${CURR_HEAD}/{file}#L{line}" |
| 43 |
|
| 44 |
|
| 45 |
gh-pages: |
| 46 |
@if test -z ${REMOTE_REPO} ; then \ |
| 47 |
echo 'Remote repo URL not found' >&2 ; \ |
| 48 |
exit 128 ; \ |
| 49 |
fi |
| 50 |
$(MAKE) demo && \ |
| 51 |
cp -r ./demo ${TMP_PATH} && \ |
| 52 |
touch ${TMP_PATH}/.nojekyll |
| 53 |
$(MAKE) doc && \ |
| 54 |
cp -r ./doc ${TMP_PATH}/doc |
| 55 |
cd ${TMP_PATH} && \ |
| 56 |
git init && \ |
| 57 |
git add . && \ |
| 58 |
git commit -q -m 'Recreated docs' |
| 59 |
cd ${TMP_PATH} && \ |
| 60 |
git remote add remote ${REMOTE_REPO} && \ |
| 61 |
git push --force remote +master:gh-pages |
| 62 |
rm -rf ${TMP_PATH} |
| 63 |
|
| 64 |
|
| 65 |
publish: browserify |
| 66 |
# run browserify to make sure that browserified version is in sync |
| 67 |
@if test 0 -ne `git status --porcelain | wc -l` ; then \ |
| 68 |
echo "Unclean working tree. Commit or stash changes first." >&2 ; \ |
| 69 |
exit 128 ; \ |
| 70 |
fi |
| 71 |
@if test 0 -ne `git tag -l ${NPM_VERSION} | wc -l` ; then \ |
| 72 |
echo "Tag ${NPM_VERSION} exists. Update package.json" >&2 ; \ |
| 73 |
exit 128 ; \ |
| 74 |
fi |
| 75 |
git tag ${NPM_VERSION} && git push origin ${NPM_VERSION} |
| 76 |
npm publish ${GITHUB_PROJ}/tarball/${NPM_VERSION} |
| 77 |
|
| 78 |
|
| 79 |
.PHONY: publish lint test doc demo gh-pages coverage |
| 80 |
.SILENT: help lint test doc todo |