UNPKG

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