forked from dnote/dnote
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
192 lines (156 loc) · 4.6 KB
/
Copy pathMakefile
File metadata and controls
192 lines (156 loc) · 4.6 KB
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
PACKR2 := $(shell command -v packr2 2> /dev/null)
NPM := $(shell command -v npm 2> /dev/null)
HUB := $(shell command -v hub 2> /dev/null)
currentDir = $(shell pwd)
serverOutputDir = ${currentDir}/build/server
cliOutputDir = ${currentDir}/build/cli
cliHomebrewDir = ${currentDir}/../homebrew-dnote
## installation
install: install-go install-js
.PHONY: install
install-go:
ifndef PACKR2
@echo "==> installing packr2"
@go get -u github.com/gobuffalo/packr/v2/packr2
endif
@echo "==> installing go dependencies"
@go mod download
.PHONY: install-go
install-js:
ifndef NPM
$(error npm is not installed)
endif
@echo "==> installing js dependencies"
ifeq ($(CI), true)
@(cd ${currentDir} && npm ci --cache $(NPM_CACHE_DIR) --prefer-offline --unsafe-perm=true)
@(cd ${currentDir}/web && npm ci --cache $(NPM_CACHE_DIR) --prefer-offline --unsafe-perm=true)
@(cd ${currentDir}/browser && npm ci --cache $(NPM_CACHE_DIR) --prefer-offline --unsafe-perm=true)
@(cd ${currentDir}/jslib && npm ci --cache $(NPM_CACHE_DIR) --prefer-offline --unsafe-perm=true)
else
@(cd ${currentDir} && npm install)
@(cd ${currentDir}/web && npm install)
@(cd ${currentDir}/browser && npm install)
@(cd ${currentDir}/jslib && npm install)
endif
.PHONY: install-js
lint:
@(cd ${currentDir}/web && npm run lint)
@(cd ${currentDir}/jslib && npm run lint)
@(cd ${currentDir}/browser && npm run lint)
.PHONY: lint
lint-fix:
@(cd ${currentDir}/web && npm run lint:fix)
@(cd ${currentDir}/jslib && npm run lint:fix)
@(cd ${currentDir}/browser && npm run lint:fix)
.PHONY: lint
## test
test: test-cli test-api test-web test-jslib
.PHONY: test
test-cli:
@echo "==> running CLI test"
@(${currentDir}/scripts/cli/test.sh)
.PHONY: test-cli
test-api:
@echo "==> running API test"
@(${currentDir}/scripts/server/test-local.sh)
.PHONY: test-api
test-web:
@echo "==> running web test"
ifeq ($(WATCH), true)
@(cd ${currentDir}/web && npm run test:watch)
else
@(cd ${currentDir}/web && npm run test)
endif
.PHONY: test-web
test-jslib:
@echo "==> running jslib test"
ifeq ($(WATCH), true)
@(cd ${currentDir}/jslib && npm run test:watch)
else
@(cd ${currentDir}/jslib && npm run test)
endif
.PHONY: test-jslib
test-selfhost:
@echo "==> running a smoke test for self-hosting"
@${currentDir}/host/smoketest/run_test.sh ${tarballPath}
.PHONY: test-jslib
# development
dev-server:
@echo "==> running dev environment"
@VERSION=master ${currentDir}/scripts/web/dev.sh
.PHONY: dev-server
## build
build-web:
ifndef version
$(error version is required. Usage: make version=0.1.0 build-web)
endif
@echo "==> building web"
@VERSION=${version} ${currentDir}/scripts/web/build-prod.sh
.PHONY: build-web
build-server: build-web
ifndef version
$(error version is required. Usage: make version=0.1.0 build-server)
endif
@echo "==> building server"
@${currentDir}/scripts/server/build.sh $(version)
.PHONY: build-server
build-cli:
ifeq ($(debug), true)
@echo "==> building cli in dev mode"
@${currentDir}/scripts/cli/dev.sh
else
ifndef version
$(error version is required. Usage: make version=0.1.0 build-cli)
endif
@echo "==> building cli"
@${currentDir}/scripts/cli/build.sh $(version)
endif
.PHONY: build-cli
## release
release-cli: clean build-cli
ifndef version
$(error version is required. Usage: make version=0.1.0 release-cli)
endif
ifndef HUB
$(error please install hub)
endif
if [ ! -d ${cliHomebrewDir} ]; then \
@echo "homebrew-dnote not found locally. did you clone it?"; \
@exit 1; \
fi
@echo "==> releasing cli"
@${currentDir}/scripts/release.sh cli $(version) ${cliOutputDir}
@echo "===> releading on Homebrew"
@(cd "${cliHomebrewDir}" && \
./release.sh "$(version)" "${cliOutputDir}/dnote_$(version)_darwin_amd64.tar.gz")
.PHONY: release-cli
release-server:
ifndef version
$(error version is required. Usage: make version=0.1.0 release-server)
endif
ifndef HUB
$(error please install hub)
endif
@echo "==> releasing server"
@${currentDir}/scripts/release.sh server $(version) ${serverOutputDir}
@echo "==> building and releasing docker image"
@(cd ${currentDir}/host/docker && ./build.sh $(version))
@(cd ${currentDir}/host/docker && ./release.sh $(version))
.PHONY: release-server
# migrations
create-migration:
ifndef filename
$(error filename is required. Usage: make filename=your-filename create-migration)
endif
@(cd ${currentDir}/pkg/server/database && ./scripts/create-migration.sh $(filename))
.PHONY: create-migration
clean:
@git clean -f
@rm -rf build
@rm -rf web/public
.PHONY: clean
clean-dep:
@rm -rf ${currentDir}/web/node_modules
@rm -rf ${currentDir}/jslib/node_modules
@rm -rf ${currentDir}/browser/node_modules
.PHONY: clean-dep