forked from nodeca/nodeca
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
157 lines (119 loc) · 4.52 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
PATH := ./node_modules/.bin:${PATH}
NPM_PACKAGE := $(shell node -e 'process.stdout.write(require("./package.json").name)')
NPM_VERSION := $(shell node -e 'process.stdout.write(require("./package.json").version)')
TMP_PATH := /tmp/${NPM_PACKAGE}-$(shell date +%s)
REMOTE_NAME ?= origin
REMOTE_REPO ?= $(shell git config --get remote.${REMOTE_NAME}.url)
CURR_HEAD := $(firstword $(shell git show-ref --hash HEAD | cut --bytes=-6) master)
GITHUB_PROJ := nodeca/${NPM_PACKAGE}
SRC_URL_FMT := https://github.com/${GITHUB_PROJ}/blob/${CURR_HEAD}/{file}\#L{line}
APPLICATIONS = nodeca.core nodeca.users nodeca.forum nodeca.blogs nodeca.editor
NODE_MODULES = $(foreach app,$(APPLICATIONS),node_modules/$(app))
CONFIG_FILES = $(basename $(wildcard ./config/*.yml.example))
INSTALL_DEPS := $(shell test -d ./node_modules ; echo $$?)
help:
echo "make help - Print this help"
echo "make lint - Lint sources with JSHint"
echo "make test - Lint sources and run all tests"
echo "make doc - Build API docs"
echo "make dev-deps - Install developer dependencies"
echo "make gh-pages - Build and push API docs into gh-pages branch"
echo "make publish - Set new version tag and publish npm package"
echo "make todo - Find and list all TODOs"
echo "make pull - Updates all sub-apps"
lint:
if test ! `which jshint` ; then \
echo "You need 'jshint' installed in order to run lint." >&2 ; \
echo " $ make dev-deps" >&2 ; \
exit 128 ; \
fi
jshint . --show-non-errors
$(CONFIG_FILES):
test -f $@.example && ( test -f $@ || cp $@.example $@ )
test: lint $(CONFIG_FILES)
NODECA_ENV=test node nodeca.js migrate --all
NODECA_ENV=test node nodeca.js test $(NODECA_APP)
doc:
@if test ! `which ndoc` ; then \
echo "You need 'ndoc' installed in order to generate docs." >&2 ; \
echo " $ npm install -g ndoc" >&2 ; \
exit 128 ; \
fi
rm -rf ./doc
ndoc --output ./doc --linkFormat "${SRC_URL_FMT}" ./lib
dev-deps:
npm install
dev-server:
if test ! `which inotifywait` ; then \
echo "You need 'inotifywait' installed in order to run dev-server." >&2 ; \
echo " sudo apt-get install inotify-tools" >&2 ; \
exit 128 ; \
fi
./support/forever.sh
gh-pages:
@if test -z ${REMOTE_REPO} ; then \
echo 'Remote repo URL not found' >&2 ; \
exit 128 ; \
fi
$(MAKE) doc && \
cp -r ./doc ${TMP_PATH} && \
touch ${TMP_PATH}/.nojekyll
cd ${TMP_PATH} && \
git init && \
git add . && \
git commit -q -m 'Recreated docs'
cd ${TMP_PATH} && \
git remote add remote ${REMOTE_REPO} && \
git push --force remote +master:gh-pages
rm -rf ${TMP_PATH}
publish:
@if test 0 -ne `git status --porcelain | wc -l` ; then \
echo "Unclean working tree. Commit or stash changes first." >&2 ; \
exit 128 ; \
fi
@if test 0 -ne `git tag -l ${NPM_VERSION} | wc -l` ; then \
echo "Tag ${NPM_VERSION} exists. Update package.json" >&2 ; \
exit 128 ; \
fi
git tag ${NPM_VERSION} && git push origin ${NPM_VERSION}
npm publish https://github.com/${GITHUB_PROJ}/tarball/${NPM_VERSION}
todo:
grep 'TODO' -n -r ./lib 2>/dev/null || test true
node_modules/nodeca.core: REPO_RW=git@github.com:nodeca/nodeca.core.git
node_modules/nodeca.users: REPO_RW=git@github.com:nodeca/nodeca.users.git
node_modules/nodeca.forum: REPO_RW=git@github.com:nodeca/nodeca.forum.git
node_modules/nodeca.blogs: REPO_RW=git@github.com:nodeca/nodeca.blogs.git
node_modules/nodeca.editor: REPO_RW=git@github.com:nodeca/nodeca.editor.git
node_modules/nodeca.core: REPO_RO=git://github.com/nodeca/nodeca.core.git
node_modules/nodeca.users: REPO_RO=git://github.com/nodeca/nodeca.users.git
node_modules/nodeca.forum: REPO_RO=git://github.com/nodeca/nodeca.forum.git
node_modules/nodeca.blogs: REPO_RO=git://github.com/nodeca/nodeca.blogs.git
node_modules/nodeca.editor: REPO_RO=git://github.com/nodeca/nodeca.editor.git
$(NODE_MODULES):
mkdir -p node_modules
echo "*** $@"
if test ! -d $@/.git && test -d $@ ; then \
echo "Module already exists. Remove it first." >&2 ; \
exit 128 ; \
fi
if test ! -d $@/.git ; then \
rm -rf $@ && \
git clone $($(shell echo ${REPO})) $@ && \
cd $@ && \
npm install ; \
fi
cd $@ && git pull
pull-ro: REPO="REPO_RO"
pull-ro: $(NODE_MODULES)
git pull
@if test $(INSTALL_DEPS) -ne 0 ; then \
npm install ; \
fi
pull: REPO="REPO_RW"
pull: $(NODE_MODULES)
git pull
@if test $(INSTALL_DEPS) -ne 0 ; then \
npm install ; \
fi
.PHONY: $(NODE_MODULES) publish lint test doc dev-deps gh-pages todo
.SILENT: $(NODE_MODULES) help lint test doc todo