Last Updated: February 25, 2016
·
1.011K
· durango

Private NPM deployment with npm-reggie

For private NPMs, instead of paying Gemfury $9/month, just setup your own server with npm-reggie

URL ?= http://fake.com
NAME_CMD := cat package.json | grep -m 1 -o '"name":\s*"\([^"]\)*"' | sed 's/"name":[^"]*"\(.*\)"$$/\1/'
VERSION_CMD := cat package.json | grep -m 1 -o '"version":\s*"\([^"]\)*"' | sed 's/"version":[^"]*"\(.*\)"$$/\1/'

publish delete clean : PACKAGE_NAME:=$(shell ${NAME_CMD})
publish delete : PACKAGE_VERSION:=$(shell ${VERSION_CMD})

clean:
    rm -rf ./node_modules
    rm -rf ./${PACKAGE_NAME}*.tgz
    rm -rf *.log
    rm -rf .DS_STORE

pack: clean
    npm pack

publish: clean delete
    reggie -u ${URL}/ publish

delete:
    # npm --registry=${URL}/ unpublish ${PACKAGE_NAME}@${PACKAGE_VERSION} # Not supported yet...
    curl -X DELETE ${URL}/package/${PACKAGE_NAME}/${PACKAGE_VERSION}

.PHONY: clean pack delete publish

Simply type in make publish when you want to publish your package.