UNPKG

5.61 kBPlain TextView Raw
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 doc -name '*.md' | grep -v 'index') README.md
8
9html_docdeps = html/dochead.html \
10 html/docfoot.html \
11 scripts/doc-build.sh \
12 package.json
13
14cli_mandocs = $(shell find doc/cli -name '*.md' \
15 |sed 's|.md|.1|g' \
16 |sed 's|doc/cli/|man/man1/|g' ) \
17 man/man1/npm-README.1 \
18 man/man1/npx.1
19
20files_mandocs = $(shell find doc/files -name '*.md' \
21 |sed 's|.md|.5|g' \
22 |sed 's|doc/files/|man/man5/|g' ) \
23 man/man5/npm-json.5 \
24 man/man5/npm-global.5
25
26misc_mandocs = $(shell find doc/misc -name '*.md' \
27 |sed 's|.md|.7|g' \
28 |sed 's|doc/misc/|man/man7/|g' ) \
29 man/man7/npm-index.7
30
31cli_htmldocs = $(shell find doc/cli -name '*.md' \
32 |sed 's|.md|.html|g' \
33 |sed 's|doc/cli/|html/doc/cli/|g' ) \
34 html/doc/README.html
35
36files_htmldocs = $(shell find doc/files -name '*.md' \
37 |sed 's|.md|.html|g' \
38 |sed 's|doc/files/|html/doc/files/|g' ) \
39 html/doc/files/npm-json.html \
40 html/doc/files/npm-global.html
41
42misc_htmldocs = $(shell find doc/misc -name '*.md' \
43 |sed 's|.md|.html|g' \
44 |sed 's|doc/misc/|html/doc/misc/|g' ) \
45 html/doc/index.html
46
47mandocs = $(cli_mandocs) $(files_mandocs) $(misc_mandocs)
48
49htmldocs = $(cli_htmldocs) $(files_htmldocs) $(misc_htmldocs)
50
51all: doc
52
53latest:
54 @echo "Installing latest published npm"
55 @echo "Use 'make install' or 'make link' to install the code"
56 @echo "in this folder that you're looking at right now."
57 node bin/npm-cli.js install -g -f npm ${NPMOPTS}
58
59install: all
60 node bin/npm-cli.js install -g -f ${NPMOPTS} $(shell node bin/npm-cli.js pack | tail -1)
61
62# backwards compat
63dev: install
64
65link: uninstall
66 node bin/npm-cli.js link -f
67
68clean: markedclean marked-manclean doc-clean
69 rm -rf npmrc
70 node bin/npm-cli.js cache clean --force
71
72uninstall:
73 node bin/npm-cli.js rm npm -g -f
74
75doc: $(mandocs) $(htmldocs)
76
77markedclean:
78 rm -rf node_modules/marked node_modules/.bin/marked .building_marked
79
80marked-manclean:
81 rm -rf node_modules/marked-man node_modules/.bin/marked-man .building_marked-man
82
83docclean: doc-clean
84doc-clean:
85 rm -rf \
86 .building_marked \
87 .building_marked-man \
88 html/doc \
89 man
90
91## build-time tools for the documentation
92build-doc-tools := node_modules/.bin/marked \
93 node_modules/.bin/marked-man
94
95# use `npm install marked-man` for this to work.
96man/man1/npm-README.1: README.md scripts/doc-build.sh package.json $(build-doc-tools)
97 @[ -d man/man1 ] || mkdir -p man/man1
98 scripts/doc-build.sh $< $@
99
100man/man1/%.1: doc/cli/%.md scripts/doc-build.sh package.json $(build-doc-tools)
101 @[ -d man/man1 ] || mkdir -p man/man1
102 scripts/doc-build.sh $< $@
103
104man/man1/npx.1: node_modules/libnpx/libnpx.1
105 cat $< | sed s/libnpx/npx/ > $@
106
107man/man5/npm-json.5: man/man5/package.json.5
108 cp $< $@
109
110man/man5/npm-global.5: man/man5/npm-folders.5
111 cp $< $@
112
113man/man5/%.5: doc/files/%.md scripts/doc-build.sh package.json $(build-doc-tools)
114 @[ -d man/man5 ] || mkdir -p man/man5
115 scripts/doc-build.sh $< $@
116
117doc/misc/npm-index.md: scripts/index-build.js package.json $(build-doc-tools)
118 node scripts/index-build.js > $@
119
120html/doc/index.html: doc/misc/npm-index.md $(html_docdeps) $(build-doc-tools)
121 @[ -d html/doc ] || mkdir -p html/doc
122 scripts/doc-build.sh $< $@
123
124man/man7/%.7: doc/misc/%.md scripts/doc-build.sh package.json $(build-doc-tools)
125 @[ -d man/man7 ] || mkdir -p man/man7
126 scripts/doc-build.sh $< $@
127
128html/doc/README.html: README.md $(html_docdeps) $(build-doc-tools)
129 @[ -d html/doc ] || mkdir -p html/doc
130 scripts/doc-build.sh $< $@
131
132html/doc/cli/%.html: doc/cli/%.md $(html_docdeps) $(build-doc-tools)
133 @[ -d html/doc/cli ] || mkdir -p html/doc/cli
134 scripts/doc-build.sh $< $@
135
136html/doc/files/npm-json.html: html/doc/files/package.json.html
137 cp $< $@
138
139html/doc/files/npm-global.html: html/doc/files/npm-folders.html
140 cp $< $@
141
142html/doc/files/%.html: doc/files/%.md $(html_docdeps) $(build-doc-tools)
143 @[ -d html/doc/files ] || mkdir -p html/doc/files
144 scripts/doc-build.sh $< $@
145
146html/doc/misc/%.html: doc/misc/%.md $(html_docdeps) $(build-doc-tools)
147 @[ -d html/doc/misc ] || mkdir -p html/doc/misc
148 scripts/doc-build.sh $< $@
149
150
151marked: node_modules/.bin/marked
152
153node_modules/.bin/marked:
154 node bin/npm-cli.js install marked --no-global --no-timing --no-save
155
156marked-man: node_modules/.bin/marked-man
157
158node_modules/.bin/marked-man:
159 node bin/npm-cli.js install marked-man --no-global --no-timing --no-save
160
161doc: man
162
163man: $(cli_docs)
164
165test: doc
166 node bin/npm-cli.js test
167
168tag:
169 node bin/npm-cli.js tag npm@$(PUBLISHTAG) latest
170
171ls-ok:
172 node . ls >/dev/null
173
174gitclean:
175 git clean -fd
176
177publish: gitclean ls-ok link doc-clean doc
178 @git push origin :v$(shell node bin/npm-cli.js --no-timing -v) 2>&1 || true
179 git push origin $(BRANCH) &&\
180 git push origin --tags &&\
181 node bin/npm-cli.js publish --tag=$(PUBLISHTAG)
182
183release: gitclean ls-ok markedclean marked-manclean doc-clean doc
184 node bin/npm-cli.js prune --production --no-save
185 @bash scripts/release.sh
186
187sandwich:
188 @[ $$(whoami) = "root" ] && (echo "ok"; echo "ham" > sandwich) || (echo "make it yourself" && exit 13)
189
190.PHONY: all latest install dev link doc clean uninstall test man doc-clean docclean release ls-ok realclean