1# vim: set softtabstop=2 shiftwidth=2: 2SHELL = bash 3 4PUBLISHTAG = $(shell node scripts/publish-tag.js) 5BRANCH = $(shell git rev-parse --abbrev-ref HEAD) 6 7markdowns = $(shell find docs -name '*.md' | grep -v 'index') README.md 8 9cli_mandocs = $(shell find docs/content/cli-commands -name '*.md' \ 10 |sed 's|.md|.1|g' \ 11 |sed 's|docs/content/cli-commands/|man/man1/|g' ) \ 12 man/man1/npm-README.1 \ 13 man/man1/npx.1 14 15files_mandocs = $(shell find docs/content/configuring-npm -name '*.md' \ 16 |sed 's|.md|.5|g' \ 17 |sed 's|docs/content/configuring-npm/|man/man5/|g' ) \ 18 19misc_mandocs = $(shell find docs/content/using-npm -name '*.md' \ 20 |sed 's|.md|.7|g' \ 21 |sed 's|docs/content/using-npm/|man/man7/|g' ) \ 22 23mandocs = $(cli_mandocs) $(files_mandocs) $(misc_mandocs) 24 25all: docs 26 27latest: 28 @echo "Installing latest published npm" 29 @echo "Use 'make install' or 'make link' to install the code" 30 @echo "in this folder that you're looking at right now." 31 node bin/npm-cli.js install -g -f npm ${NPMOPTS} 32 33install: all 34 node bin/npm-cli.js install -g -f ${NPMOPTS} $(shell node bin/npm-cli.js pack | tail -1) 35 36# backwards compat 37dev: install 38 39link: uninstall 40 node bin/npm-cli.js link -f 41 42clean: markedclean marked-manclean docs-clean 43 rm -rf npmrc 44 node bin/npm-cli.js cache clean --force 45 46uninstall: 47 node bin/npm-cli.js rm npm -g -f 48 49mandocs: $(mandocs) 50 51htmldocs: 52 cd docs && node ../bin/npm-cli.js install && \ 53 node ../bin/npm-cli.js --python=${PYTHON} run build:static echo>&2 && \ 54 rm -rf node_modules .cache public/*js public/*json public/404* public/page-data public/manifest* 55 56docs: mandocs # htmldocs 57 58markedclean: 59 rm -rf node_modules/marked node_modules/.bin/marked .building_marked 60 61marked-manclean: 62 rm -rf node_modules/marked-man node_modules/.bin/marked-man .building_marked-man 63 64docsclean: docs-clean 65docs-clean: 66 rm -rf \ 67 .building_marked \ 68 .building_marked-man \ 69 man \ 70 docs/node_modules \ 71 docs/public \ 72 docs/.cache 73 74## build-time tools for the documentation 75build-doc-tools := node_modules/.bin/marked \ 76 node_modules/.bin/marked-man 77 78# use `npm install marked-man` for this to work. 79man/man1/npm-README.1: README.md scripts/docs-build.js package.json $(build-doc-tools) 80 @[ -d man/man1 ] || mkdir -p man/man1 81 node scripts/docs-build.js $< $@ 82 83man/man1/%.1: docs/content/cli-commands/%.md scripts/docs-build.js package.json $(build-doc-tools) 84 @[ -d man/man1 ] || mkdir -p man/man1 85 node scripts/docs-build.js $< $@ 86 87man/man1/npx.1: node_modules/libnpx/libnpx.1 88 cat $< | sed s/libnpx/npx/ > $@ 89 90man/man5/npm-json.5: man/man5/package.json.5 91 cp $< $@ 92 93man/man5/npm-global.5: man/man5/folders.5 94 cp $< $@ 95 96man/man5/%.5: docs/content/configuring-npm/%.md scripts/docs-build.js package.json $(build-doc-tools) 97 @[ -d man/man5 ] || mkdir -p man/man5 98 node scripts/docs-build.js $< $@ 99 100man/man7/%.7: docs/content/using-npm/%.md scripts/docs-build.js package.json $(build-doc-tools) 101 @[ -d man/man7 ] || mkdir -p man/man7 102 node scripts/docs-build.js $< $@ 103 104marked: node_modules/.bin/marked 105 106node_modules/.bin/marked: 107 node bin/npm-cli.js install marked --no-global --no-timing --no-save 108 109marked-man: node_modules/.bin/marked-man 110 111node_modules/.bin/marked-man: 112 node bin/npm-cli.js install marked-man --no-global --no-timing --no-save 113 114test: docs 115 node bin/npm-cli.js test 116 117tag: 118 node bin/npm-cli.js tag npm@$(PUBLISHTAG) latest 119 120ls-ok: 121 node . ls >/dev/null 122 123gitclean: 124 git clean -fd 125 126publish: gitclean ls-ok link docs-clean docs 127 @git push origin :v$(shell node bin/npm-cli.js --no-timing -v) 2>&1 || true 128 git push origin $(BRANCH) &&\ 129 git push origin --tags &&\ 130 node bin/npm-cli.js publish --tag=$(PUBLISHTAG) 131 132release: gitclean ls-ok markedclean marked-manclean docs-clean docs 133 node bin/npm-cli.js prune --production --no-save 134 @bash scripts/release.sh 135 136sandwich: 137 @[ $$(whoami) = "root" ] && (echo "ok"; echo "ham" > sandwich) || (echo "make it yourself" && exit 13) 138 139.PHONY: all latest install dev link docs clean uninstall test man docs-clean docclean release ls-ok realclean 140