forked from tower-archive/tower
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
175 lines (134 loc) · 4.33 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
SRC = $(shell find test/cases -name client -prune -o -name '*Test.coffee' -print)
STORES = memory mongodb
CMD = node_modules/mocha/bin/mocha
DIR = $(shell pwd)
GRUNT = grunt
FOREVER = forever
PORT = 3210
TEST_URL = http://localhost:$(PORT)/?test=support,application,store,model
CLIENT_PID = null
TEST_SERVER_PATH = test/example/server
# if node version is less than 8 (if you know how to clean this up, would love to know).
NODE_VERSION = $(shell node --version)
NODE_VERSION_LT_8 = $(shell node -e "console.log(process.version < 'v0.8.0')")
NODE_VERSION_LT_6 = $(shell node -e "console.log(process.version < 'v0.6.0')")
PATH_SEP = $(shell node -e "console.log(require('path').sep)")
# darwin (mac), linux, win32 (windows)
OS = $(shell node -e "console.log(process.platform)")
INSTALL = bin$(PATH_SEP)install
ifeq (win32,$(OS))
# Windows:
RUN =
else
# Unix
RUN = ./
endif
all: clean
$(GRUNT) --config $(RUN)grunt.coffee
# watch more files on mac
watch-more:
ulimit -n 65536
install-dependencies:
@$(shell $(INSTALL) dependencies)
install-message:
@$(INSTALL) message
post-install: install-dependencies install-message
check-grunt:
ifeq ($(shell which $(GRUNT)),)
$(eval GRUNT = $(shell pwd)$(PATH_SEP)node_modules$(PATH_SEP)grunt$(PATH_SEP)bin$(PATH_SEP)grunt)
ifeq ($(shell which $(RUN)node_modules$(PATH_SEP)grunt$(PATH_SEP)bin$(PATH_SEP)grunt),)
npm install grunt
endif
endif
# ps -ef | awk '/node server -p 3210/{print $2}' | wc -l | awk '{print $1}'
# check-server: check-forever
check-phantomjs:
ifeq ($(shell which phantomjs),) # if it's blank
$(error PhantomJS is not installed. Download from http://phantomjs.org or run `brew install phantomjs` if you have Homebrew)
endif
test: test-server test-client
test-server: test-memory test-mongodb
test-memory:
$(CMD) $(SRC) --store memory
test-mongodb:
$(CMD) $(SRC) --store mongodb
test-client:
phantomjs test$(PATH_SEP)client.coffee $(TEST_URL)
build-test-client: check-phantomjs check-grunt
rm -rf test$(PATH_SEP)example$(PATH_SEP)vendor
$(RUN)bin$(PATH_SEP)tower new example
mv example$(PATH_SEP)vendor test$(PATH_SEP)example
rm -rf $(RUN)example
$(GRUNT) --config $(RUN)grunt.coffee
cd test$(PATH_SEP)example && pwd && npm install .
$(GRUNT) --config $(RUN)test$(PATH_SEP)example$(PATH_SEP)grunt.coffee
freeze-vendor-files:
@echo Downloading client files to $(RUN)vendor ...
@rm -rf $(RUN)vendor
@rm -rf $(RUN)example
@$(RUN)bin$(PATH_SEP)tower new example --quiet
@mv example$(PATH_SEP)vendor vendor
@mv example$(PATH_SEP)public/images vendor
start-test-client:
node $(TEST_SERVER_PATH) -p $(PORT)
start-test-client-conditionally: test-client-pid
ifeq ($(CLIENT_PID),)
$(shell node $(TEST_SERVER_PATH) -p $(PORT) &)
else
@echo Server already running on port $(PORT)
endif
test-client-pid:
$(eval CLIENT_PID = $(call get-pids,node $(TEST_SERVER_PATH)))
@echo $(CLIENT_PID): node $(TEST_SERVER_PATH) -p $(PORT)
stop-test-client: test-client-pid
client: start-test-client test-client
define open-browser
open -a "$(1)" $(TEST_URL)\&complete=close
endef
test-firefox:
$(call open-browser,Firefox)
test-safari:
$(call open-browser,Safari)
test-chrome:
$(call open-browser,"Google\ Chrome")
test-opera:
$(call open-browser,Opera)
test-all:
for i in $(STORES); do $(RUN)node_modules$(PATH_SEP)mocha$(PATH_SEP)bin$(PATH_SEP)mocha $(SRC) --store $$i; done
# make push message='Committing changes'
push:
cd wiki && git add . && git commit -a -m 'updates' && git push
git add .
git commit -a -m '$(message)'
git push origin master
clean:
rm -rf dist/*
rm -rf lib/*
whitespace:
cake clean
install:
npm install
npm install-dev
watch: clean
$(GRUNT) start --config $(RUN)grunt.coffee
build:
$(GRUNT) build:client --config $(RUN)grunt.coffee
dist:
$(GRUNT) dist --config $(RUN)grunt.coffee
publish: dist
npm publish
docs:
rm -rf doc/*
codo $(shell find packages/* -name templates -prune -o -name '*.coffee' -print) --title 'Tower API Documentation'
define kill-processes
@echo 'killing processes...'
@echo $(call get-processes,$(1))
kill -9 $(call get-pids,$(1))
endef
define get-pids
$(shell ps -ef | grep -e '$(1)' | grep -v grep | awk '{print $$2}')
endef
define get-processes
$(shell ps -ef | grep -e '$(1)' | grep -v grep)
endef
.PHONY: all test-memory test-mongodb test test-all test-client build dist check-phantomjs check-grunt build-test-client start-test-client post-install