1 | # vim: set softtabstop=2 shiftwidth=2:
|
2 | SHELL = bash
|
3 |
|
4 | PUBLISHTAG = $(shell node scripts/publish-tag.js)
|
5 | BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
|
6 |
|
7 | markdowns = $(shell find docs -name '*.md' | grep -v 'index') README.md
|
8 |
|
9 | cli_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 |
|
15 | files_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 |
|
19 | misc_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 |
|
23 | mandocs = $(cli_mandocs) $(files_mandocs) $(misc_mandocs)
|
24 |
|
25 | all: docs
|
26 |
|
27 | latest:
|
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 |
|
33 | install: all
|
34 | node bin/npm-cli.js install -g -f ${NPMOPTS} $(shell node bin/npm-cli.js pack | tail -1)
|
35 |
|
36 | # backwards compat
|
37 | dev: install
|
38 |
|
39 | link: uninstall
|
40 | node bin/npm-cli.js link -f
|
41 |
|
42 | clean: markedclean marked-manclean docs-clean
|
43 | rm -rf npmrc
|
44 | node bin/npm-cli.js cache clean --force
|
45 |
|
46 | uninstall:
|
47 | node bin/npm-cli.js rm npm -g -f
|
48 |
|
49 | mandocs: $(mandocs)
|
50 |
|
51 | htmldocs:
|
52 | cd docs && node ../bin/npm-cli.js install && \
|
53 | node ../bin/npm-cli.js run build:static echo>&2 && \
|
54 | rm -rf node_modules .cache public/*js public/*json public/404* public/page-data public/manifest*
|
55 |
|
56 | docs: mandocs htmldocs
|
57 |
|
58 | markedclean:
|
59 | rm -rf node_modules/marked node_modules/.bin/marked .building_marked
|
60 |
|
61 | marked-manclean:
|
62 | rm -rf node_modules/marked-man node_modules/.bin/marked-man .building_marked-man
|
63 |
|
64 | docsclean: docs-clean
|
65 | docs-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
|
75 | build-doc-tools := node_modules/.bin/marked \
|
76 | node_modules/.bin/marked-man
|
77 |
|
78 | # use `npm install marked-man` for this to work.
|
79 | man/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 |
|
83 | man/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 |
|
87 | man/man1/npx.1: node_modules/libnpx/libnpx.1
|
88 | cat $< | sed s/libnpx/npx/ > $@
|
89 |
|
90 | man/man5/npm-json.5: man/man5/package.json.5
|
91 | cp $< $@
|
92 |
|
93 | man/man5/npm-global.5: man/man5/folders.5
|
94 | cp $< $@
|
95 |
|
96 | man/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 |
|
100 | man/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 |
|
104 | marked: node_modules/.bin/marked
|
105 |
|
106 | node_modules/.bin/marked:
|
107 | node bin/npm-cli.js install marked --no-global --no-timing --no-save
|
108 |
|
109 | marked-man: node_modules/.bin/marked-man
|
110 |
|
111 | node_modules/.bin/marked-man:
|
112 | node bin/npm-cli.js install marked-man --no-global --no-timing --no-save
|
113 |
|
114 | test: docs
|
115 | node bin/npm-cli.js test
|
116 |
|
117 | tag:
|
118 | node bin/npm-cli.js tag npm@$(PUBLISHTAG) latest
|
119 |
|
120 | ls-ok:
|
121 | node . ls >/dev/null
|
122 |
|
123 | gitclean:
|
124 | git clean -fd
|
125 |
|
126 | publish: 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 |
|
132 | release: 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 |
|
136 | sandwich:
|
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
|