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 doc -name '*.md' | grep -v 'index') README.md
|
8 |
|
9 | html_docdeps = html/dochead.html \
|
10 | html/docfoot.html \
|
11 | scripts/doc-build.sh \
|
12 | package.json
|
13 |
|
14 | cli_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 |
|
19 | files_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 |
|
25 | misc_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 |
|
30 | cli_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 |
|
35 | files_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 |
|
41 | misc_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 |
|
46 | mandocs = $(cli_mandocs) $(files_mandocs) $(misc_mandocs)
|
47 |
|
48 | htmldocs = $(cli_htmldocs) $(files_htmldocs) $(misc_htmldocs)
|
49 |
|
50 | all: doc
|
51 |
|
52 | latest:
|
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 |
|
58 | install: all
|
59 | node bin/npm-cli.js install -g -f ${NPMOPTS}
|
60 |
|
61 | # backwards compat
|
62 | dev: install
|
63 |
|
64 | link: uninstall
|
65 | node bin/npm-cli.js link -f
|
66 |
|
67 | clean: markedclean marked-manclean doc-clean uninstall
|
68 | rm -rf npmrc
|
69 | node bin/npm-cli.js cache clean
|
70 |
|
71 | uninstall:
|
72 | node bin/npm-cli.js rm npm -g -f
|
73 |
|
74 | doc: $(mandocs) $(htmldocs)
|
75 |
|
76 | markedclean:
|
77 | rm -rf node_modules/marked node_modules/.bin/marked .building_marked
|
78 |
|
79 | marked-manclean:
|
80 | rm -rf node_modules/marked-man node_modules/.bin/marked-man .building_marked-man
|
81 |
|
82 | docclean: doc-clean
|
83 | doc-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.
|
91 | man/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 |
|
95 | man/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 |
|
99 | man/man5/npm-json.5: man/man5/package.json.5
|
100 | cp $< $@
|
101 |
|
102 | man/man5/npm-global.5: man/man5/npm-folders.5
|
103 | cp $< $@
|
104 |
|
105 | man/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 |
|
109 | doc/misc/npm-index.md: scripts/index-build.js package.json
|
110 | node scripts/index-build.js > $@
|
111 |
|
112 | html/doc/index.html: doc/misc/npm-index.md $(html_docdeps)
|
113 | @[ -d html/doc ] || mkdir -p html/doc
|
114 | scripts/doc-build.sh $< $@
|
115 |
|
116 | man/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 |
|
120 | html/doc/README.html: README.md $(html_docdeps)
|
121 | @[ -d html/doc ] || mkdir -p html/doc
|
122 | scripts/doc-build.sh $< $@
|
123 |
|
124 | html/doc/cli/%.html: doc/cli/%.md $(html_docdeps)
|
125 | @[ -d html/doc/cli ] || mkdir -p html/doc/cli
|
126 | scripts/doc-build.sh $< $@
|
127 |
|
128 | html/doc/files/npm-json.html: html/doc/files/package.json.html
|
129 | cp $< $@
|
130 |
|
131 | html/doc/files/npm-global.html: html/doc/files/npm-folders.html
|
132 | cp $< $@
|
133 |
|
134 | html/doc/files/%.html: doc/files/%.md $(html_docdeps)
|
135 | @[ -d html/doc/files ] || mkdir -p html/doc/files
|
136 | scripts/doc-build.sh $< $@
|
137 |
|
138 | html/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 |
|
143 | marked: node_modules/.bin/marked
|
144 |
|
145 | node_modules/.bin/marked:
|
146 | node bin/npm-cli.js install marked --no-global --no-timing
|
147 |
|
148 | marked-man: node_modules/.bin/marked-man
|
149 |
|
150 | node_modules/.bin/marked-man:
|
151 | node bin/npm-cli.js install marked-man --no-global --no-timing
|
152 |
|
153 | doc: man
|
154 |
|
155 | man: $(cli_docs)
|
156 |
|
157 | test: doc
|
158 | node bin/npm-cli.js test
|
159 |
|
160 | tag:
|
161 | node bin/npm-cli.js tag npm@$(PUBLISHTAG) latest
|
162 |
|
163 | ls-ok:
|
164 | node . ls >/dev/null
|
165 |
|
166 | gitclean:
|
167 | git clean -fd
|
168 |
|
169 | publish: 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 |
|
175 | release: gitclean ls-ok markedclean marked-manclean doc-clean doc
|
176 | node bin/npm-cli.js prune --production
|
177 | @bash scripts/release.sh
|
178 |
|
179 | sandwich:
|
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
|