本站源代码
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

525 líneas
19KB

  1. DIST := dist
  2. IMPORT := code.gitea.io/gitea
  3. export GO111MODULE=off
  4. GO ?= go
  5. SED_INPLACE := sed -i
  6. SHASUM ?= shasum -a 256
  7. export PATH := $($(GO) env GOPATH)/bin:$(PATH)
  8. ifeq ($(OS), Windows_NT)
  9. EXECUTABLE ?= gitea.exe
  10. else
  11. EXECUTABLE ?= gitea
  12. UNAME_S := $(shell uname -s)
  13. ifeq ($(UNAME_S),Darwin)
  14. SED_INPLACE := sed -i ''
  15. endif
  16. endif
  17. BINDATA := modules/{options,public,templates}/bindata.go
  18. GOFILES := $(shell find . -name "*.go" -type f ! -path "./vendor/*" ! -path "*/bindata.go")
  19. GOFMT ?= gofmt -s
  20. GOFLAGS := -v
  21. EXTRA_GOFLAGS ?=
  22. MAKE_VERSION := $(shell make -v | head -n 1)
  23. ifneq ($(DRONE_TAG),)
  24. VERSION ?= $(subst v,,$(DRONE_TAG))
  25. GITEA_VERSION ?= $(VERSION)
  26. else
  27. ifneq ($(DRONE_BRANCH),)
  28. VERSION ?= $(subst release/v,,$(DRONE_BRANCH))
  29. else
  30. VERSION ?= master
  31. endif
  32. GITEA_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
  33. endif
  34. LDFLAGS := $(LDFLAGS) -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)"
  35. PACKAGES ?= $(filter-out code.gitea.io/gitea/integrations/migration-test,$(filter-out code.gitea.io/gitea/integrations,$(shell GO111MODULE=on $(GO) list -mod=vendor ./... | grep -v /vendor/)))
  36. SOURCES ?= $(shell find . -name "*.go" -type f)
  37. TAGS ?=
  38. TMPDIR := $(shell mktemp -d 2>/dev/null || mktemp -d -t 'gitea-temp')
  39. #To update swagger use: GO111MODULE=on go get -u github.com/go-swagger/go-swagger/cmd/swagger@v0.20.1
  40. SWAGGER := GO111MODULE=on $(GO) run -mod=vendor github.com/go-swagger/go-swagger/cmd/swagger
  41. SWAGGER_SPEC := templates/swagger/v1_json.tmpl
  42. SWAGGER_SPEC_S_TMPL := s|"basePath": *"/api/v1"|"basePath": "{{AppSubUrl}}/api/v1"|g
  43. SWAGGER_SPEC_S_JSON := s|"basePath": *"{{AppSubUrl}}/api/v1"|"basePath": "/api/v1"|g
  44. SWAGGER_NEWLINE_COMMAND := -e '$$a\'
  45. TEST_MYSQL_HOST ?= mysql:3306
  46. TEST_MYSQL_DBNAME ?= testgitea
  47. TEST_MYSQL_USERNAME ?= root
  48. TEST_MYSQL_PASSWORD ?=
  49. TEST_MYSQL8_HOST ?= mysql8:3306
  50. TEST_MYSQL8_DBNAME ?= testgitea
  51. TEST_MYSQL8_USERNAME ?= root
  52. TEST_MYSQL8_PASSWORD ?=
  53. TEST_PGSQL_HOST ?= pgsql:5432
  54. TEST_PGSQL_DBNAME ?= testgitea
  55. TEST_PGSQL_USERNAME ?= postgres
  56. TEST_PGSQL_PASSWORD ?= postgres
  57. TEST_MSSQL_HOST ?= mssql:1433
  58. TEST_MSSQL_DBNAME ?= gitea
  59. TEST_MSSQL_USERNAME ?= sa
  60. TEST_MSSQL_PASSWORD ?= MwantsaSecurePassword1
  61. # $(call strip-suffix,filename)
  62. strip-suffix = $(firstword $(subst ., ,$(1)))
  63. .PHONY: all
  64. all: build
  65. include docker/Makefile
  66. .PHONY: clean
  67. clean:
  68. $(GO) clean -i ./...
  69. rm -rf $(EXECUTABLE) $(DIST) $(BINDATA) \
  70. integrations*.test \
  71. integrations/gitea-integration-pgsql/ integrations/gitea-integration-mysql/ integrations/gitea-integration-mysql8/ integrations/gitea-integration-sqlite/ \
  72. integrations/gitea-integration-mssql/ integrations/indexers-mysql/ integrations/indexers-mysql8/ integrations/indexers-pgsql integrations/indexers-sqlite \
  73. integrations/indexers-mssql integrations/mysql.ini integrations/mysql8.ini integrations/pgsql.ini integrations/mssql.ini
  74. .PHONY: fmt
  75. fmt:
  76. $(GOFMT) -w $(GOFILES)
  77. .PHONY: vet
  78. vet:
  79. $(GO) vet $(PACKAGES)
  80. .PHONY: generate
  81. generate:
  82. GO111MODULE=on $(GO) generate -mod=vendor $(PACKAGES)
  83. .PHONY: generate-swagger
  84. generate-swagger:
  85. $(SWAGGER) generate spec -o './$(SWAGGER_SPEC)'
  86. $(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
  87. $(SED_INPLACE) $(SWAGGER_NEWLINE_COMMAND) './$(SWAGGER_SPEC)'
  88. .PHONY: swagger-check
  89. swagger-check: generate-swagger
  90. @diff=$$(git diff '$(SWAGGER_SPEC)'); \
  91. if [ -n "$$diff" ]; then \
  92. echo "Please run 'make generate-swagger' and commit the result:"; \
  93. echo "$${diff}"; \
  94. exit 1; \
  95. fi;
  96. .PHONY: swagger-validate
  97. swagger-validate:
  98. $(SED_INPLACE) '$(SWAGGER_SPEC_S_JSON)' './$(SWAGGER_SPEC)'
  99. $(SWAGGER) validate './$(SWAGGER_SPEC)'
  100. $(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
  101. .PHONY: errcheck
  102. errcheck:
  103. @hash errcheck > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  104. $(GO) get -u github.com/kisielk/errcheck; \
  105. fi
  106. errcheck $(PACKAGES)
  107. .PHONY: lint
  108. lint:
  109. @echo 'make lint is depricated. Use "make revive" if you want to use the old lint tool, or "make golangci-lint" to run a complete code check.'
  110. .PHONY: revive
  111. revive:
  112. @hash revive > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  113. $(GO) get -u github.com/mgechev/revive; \
  114. fi
  115. revive -config .revive.toml -exclude=./vendor/... ./... || exit 1
  116. .PHONY: misspell-check
  117. misspell-check:
  118. @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  119. $(GO) get -u github.com/client9/misspell/cmd/misspell; \
  120. fi
  121. misspell -error -i unknwon,destory $(GOFILES)
  122. .PHONY: misspell
  123. misspell:
  124. @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  125. $(GO) get -u github.com/client9/misspell/cmd/misspell; \
  126. fi
  127. misspell -w -i unknwon $(GOFILES)
  128. .PHONY: fmt-check
  129. fmt-check:
  130. # get all go files and run go fmt on them
  131. @diff=$$($(GOFMT) -d $(GOFILES)); \
  132. if [ -n "$$diff" ]; then \
  133. echo "Please run 'make fmt' and commit the result:"; \
  134. echo "$${diff}"; \
  135. exit 1; \
  136. fi;
  137. .PHONY: test
  138. test:
  139. GO111MODULE=on $(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' $(PACKAGES)
  140. .PHONY: test\#%
  141. test\#%:
  142. GO111MODULE=on $(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' -run $* $(PACKAGES)
  143. .PHONY: coverage
  144. coverage:
  145. @hash gocovmerge > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  146. $(GO) get -u github.com/wadey/gocovmerge; \
  147. fi
  148. gocovmerge integration.coverage.out $(shell find . -type f -name "coverage.out") > coverage.all;\
  149. .PHONY: unit-test-coverage
  150. unit-test-coverage:
  151. $(GO) test -tags='sqlite sqlite_unlock_notify' -cover -coverprofile coverage.out $(PACKAGES) && echo "\n==>\033[32m Ok\033[m\n" || exit 1
  152. .PHONY: vendor
  153. vendor:
  154. GO111MODULE=on $(GO) mod tidy && GO111MODULE=on $(GO) mod vendor
  155. .PHONY: test-vendor
  156. test-vendor: vendor
  157. @diff=$$(git diff vendor/); \
  158. if [ -n "$$diff" ]; then \
  159. echo "Please run 'make vendor' and commit the result:"; \
  160. echo "$${diff}"; \
  161. exit 1; \
  162. fi;
  163. .PHONY: test-sqlite
  164. test-sqlite: integrations.sqlite.test
  165. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test
  166. .PHONY: test-sqlite\#%
  167. test-sqlite\#%: integrations.sqlite.test
  168. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test -test.run $*
  169. .PHONY: test-sqlite-migration
  170. test-sqlite-migration: migrations.sqlite.test
  171. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./migrations.sqlite.test
  172. generate-ini-mysql:
  173. sed -e 's|{{TEST_MYSQL_HOST}}|${TEST_MYSQL_HOST}|g' \
  174. -e 's|{{TEST_MYSQL_DBNAME}}|${TEST_MYSQL_DBNAME}|g' \
  175. -e 's|{{TEST_MYSQL_USERNAME}}|${TEST_MYSQL_USERNAME}|g' \
  176. -e 's|{{TEST_MYSQL_PASSWORD}}|${TEST_MYSQL_PASSWORD}|g' \
  177. integrations/mysql.ini.tmpl > integrations/mysql.ini
  178. .PHONY: test-mysql
  179. test-mysql: integrations.mysql.test generate-ini-mysql
  180. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test
  181. .PHONY: test-mysql\#%
  182. test-mysql\#%: integrations.mysql.test generate-ini-mysql
  183. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test -test.run $*
  184. .PHONY: test-mysql-migration
  185. test-mysql-migration: migrations.mysql.test generate-ini-mysql
  186. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./migrations.mysql.test
  187. generate-ini-mysql8:
  188. sed -e 's|{{TEST_MYSQL8_HOST}}|${TEST_MYSQL8_HOST}|g' \
  189. -e 's|{{TEST_MYSQL8_DBNAME}}|${TEST_MYSQL8_DBNAME}|g' \
  190. -e 's|{{TEST_MYSQL8_USERNAME}}|${TEST_MYSQL8_USERNAME}|g' \
  191. -e 's|{{TEST_MYSQL8_PASSWORD}}|${TEST_MYSQL8_PASSWORD}|g' \
  192. integrations/mysql8.ini.tmpl > integrations/mysql8.ini
  193. .PHONY: test-mysql8
  194. test-mysql8: integrations.mysql8.test generate-ini-mysql8
  195. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql8.ini ./integrations.mysql8.test
  196. .PHONY: test-mysql8\#%
  197. test-mysql8\#%: integrations.mysql8.test generate-ini-mysql8
  198. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql8.ini ./integrations.mysql8.test -test.run $*
  199. .PHONY: test-mysql8-migration
  200. test-mysql8-migration: migrations.mysql8.test generate-ini-mysql8
  201. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql8.ini ./migrations.mysql8.test
  202. generate-ini-pgsql:
  203. sed -e 's|{{TEST_PGSQL_HOST}}|${TEST_PGSQL_HOST}|g' \
  204. -e 's|{{TEST_PGSQL_DBNAME}}|${TEST_PGSQL_DBNAME}|g' \
  205. -e 's|{{TEST_PGSQL_USERNAME}}|${TEST_PGSQL_USERNAME}|g' \
  206. -e 's|{{TEST_PGSQL_PASSWORD}}|${TEST_PGSQL_PASSWORD}|g' \
  207. integrations/pgsql.ini.tmpl > integrations/pgsql.ini
  208. .PHONY: test-pgsql
  209. test-pgsql: integrations.pgsql.test generate-ini-pgsql
  210. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test
  211. .PHONY: test-pgsql\#%
  212. test-pgsql\#%: integrations.pgsql.test generate-ini-pgsql
  213. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test -test.run $*
  214. .PHONY: test-pgsql-migration
  215. test-pgsql-migration: migrations.pgsql.test generate-ini-pgsql
  216. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./migrations.pgsql.test
  217. generate-ini-mssql:
  218. sed -e 's|{{TEST_MSSQL_HOST}}|${TEST_MSSQL_HOST}|g' \
  219. -e 's|{{TEST_MSSQL_DBNAME}}|${TEST_MSSQL_DBNAME}|g' \
  220. -e 's|{{TEST_MSSQL_USERNAME}}|${TEST_MSSQL_USERNAME}|g' \
  221. -e 's|{{TEST_MSSQL_PASSWORD}}|${TEST_MSSQL_PASSWORD}|g' \
  222. integrations/mssql.ini.tmpl > integrations/mssql.ini
  223. .PHONY: test-mssql
  224. test-mssql: integrations.mssql.test generate-ini-mssql
  225. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mssql.ini ./integrations.mssql.test
  226. .PHONY: test-mssql\#%
  227. test-mssql\#%: integrations.mssql.test generate-ini-mssql
  228. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mssql.ini ./integrations.mssql.test -test.run $*
  229. .PHONY: test-mssql-migration
  230. test-mssql-migration: migrations.mssql.test generate-ini-mssql
  231. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mssql.ini ./migrations.mssql.test
  232. .PHONY: bench-sqlite
  233. bench-sqlite: integrations.sqlite.test
  234. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
  235. .PHONY: bench-mysql
  236. bench-mysql: integrations.mysql.test generate-ini-mysql
  237. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
  238. .PHONY: bench-mssql
  239. bench-mssql: integrations.mssql.test generate-ini-mssql
  240. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mssql.ini ./integrations.mssql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
  241. .PHONY: bench-pgsql
  242. bench-pgsql: integrations.pgsql.test generate-ini-pgsql
  243. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
  244. .PHONY: integration-test-coverage
  245. integration-test-coverage: integrations.cover.test generate-ini-mysql
  246. GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.cover.test -test.coverprofile=integration.coverage.out
  247. integrations.mysql.test: $(SOURCES)
  248. GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mysql.test
  249. integrations.mysql8.test: $(SOURCES)
  250. GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mysql8.test
  251. integrations.pgsql.test: $(SOURCES)
  252. GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.pgsql.test
  253. integrations.mssql.test: $(SOURCES)
  254. GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mssql.test
  255. integrations.sqlite.test: $(SOURCES)
  256. GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.sqlite.test -tags 'sqlite sqlite_unlock_notify'
  257. integrations.cover.test: $(SOURCES)
  258. GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -coverpkg $(shell echo $(PACKAGES) | tr ' ' ',') -o integrations.cover.test
  259. .PHONY: migrations.mysql.test
  260. migrations.mysql.test: $(SOURCES)
  261. $(GO) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.mysql.test
  262. .PHONY: migrations.mysql8.test
  263. migrations.mysql8.test: $(SOURCES)
  264. $(GO) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.mysql8.test
  265. .PHONY: migrations.pgsql.test
  266. migrations.pgsql.test: $(SOURCES)
  267. $(GO) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.pgsql.test
  268. .PHONY: migrations.mssql.test
  269. migrations.mssql.test: $(SOURCES)
  270. $(GO) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.mssql.test
  271. .PHONY: migrations.sqlite.test
  272. migrations.sqlite.test: $(SOURCES)
  273. $(GO) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.sqlite.test -tags 'sqlite sqlite_unlock_notify'
  274. .PHONY: check
  275. check: test
  276. .PHONY: install
  277. install: $(wildcard *.go)
  278. $(GO) install -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)'
  279. .PHONY: build
  280. build: $(EXECUTABLE)
  281. $(EXECUTABLE): $(SOURCES)
  282. GO111MODULE=on $(GO) build -mod=vendor $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
  283. .PHONY: release
  284. release: release-dirs release-windows release-linux release-darwin release-copy release-compress release-check
  285. .PHONY: release-dirs
  286. release-dirs:
  287. mkdir -p $(DIST)/binaries $(DIST)/release
  288. .PHONY: release-windows
  289. release-windows:
  290. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  291. $(GO) get -u src.techknowlogick.com/xgo; \
  292. fi
  293. xgo -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION) .
  294. ifeq ($(CI),drone)
  295. cp /build/* $(DIST)/binaries
  296. endif
  297. .PHONY: release-linux
  298. release-linux:
  299. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  300. $(GO) get -u src.techknowlogick.com/xgo; \
  301. fi
  302. xgo -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64,linux/mips64le,linux/mips,linux/mipsle' -out gitea-$(VERSION) .
  303. ifeq ($(CI),drone)
  304. cp /build/* $(DIST)/binaries
  305. endif
  306. .PHONY: release-darwin
  307. release-darwin:
  308. @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  309. $(GO) get -u src.techknowlogick.com/xgo; \
  310. fi
  311. xgo -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin/*' -out gitea-$(VERSION) .
  312. ifeq ($(CI),drone)
  313. cp /build/* $(DIST)/binaries
  314. endif
  315. .PHONY: release-copy
  316. release-copy:
  317. cd $(DIST); for file in `find /build -type f -name "*"`; do cp $${file} ./release/; done;
  318. .PHONY: release-check
  319. release-check:
  320. cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "checksumming $${file}" && $(SHASUM) `echo $${file} | sed 's/^..//'` > $${file}.sha256; done;
  321. .PHONY: release-compress
  322. release-compress:
  323. @hash gxz > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  324. $(GO) get -u github.com/ulikunitz/xz/cmd/gxz; \
  325. fi
  326. cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && gxz -k -9 $${file}; done;
  327. npm-check:
  328. @hash npm > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  329. echo "Please install Node.js 8.x or greater with npm"; \
  330. exit 1; \
  331. fi;
  332. @hash npx > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  333. echo "Please install Node.js 8.x or greater with npm"; \
  334. exit 1; \
  335. fi;
  336. .PHONY: npm
  337. npm: npm-check
  338. npm install --no-save
  339. .PHONY: npm-update
  340. npm-update: npm-check
  341. npx updates -cu
  342. rm -rf node_modules package-lock.json
  343. npm install --package-lock
  344. .PHONY: js
  345. js: npm
  346. npx eslint public/js
  347. .PHONY: css
  348. css: npm
  349. npx stylelint public/less
  350. npx lessc --clean-css="--s0 -b" public/less/index.less public/css/index.css
  351. $(foreach file, $(filter-out public/less/themes/_base.less, $(wildcard public/less/themes/*)),npx lessc --clean-css="--s0 -b" public/less/themes/$(notdir $(file)) > public/css/theme-$(notdir $(call strip-suffix,$(file))).css;)
  352. npx postcss --use autoprefixer --no-map --replace public/css/*
  353. @diff=$$(git diff public/css/*); \
  354. if ([ -n "$$CI" ] && [ -n "$$diff" ]); then \
  355. echo "Generated files in public/css have changed, please commit the result:"; \
  356. echo "$${diff}"; \
  357. exit 1; \
  358. fi;
  359. .PHONY: javascripts
  360. javascripts:
  361. echo "'make javascripts' is deprecated, please use 'make js'"
  362. $(MAKE) js
  363. .PHONY: stylesheets-check
  364. stylesheets-check:
  365. echo "'make stylesheets-check' is deprecated, please use 'make css'"
  366. $(MAKE) css
  367. .PHONY: generate-stylesheets
  368. generate-stylesheets:
  369. echo "'make generate-stylesheets' is deprecated, please use 'make css'"
  370. $(MAKE) css
  371. .PHONY: swagger-ui
  372. swagger-ui:
  373. rm -Rf public/vendor/assets/swagger-ui
  374. git clone --depth=10 -b v3.13.4 --single-branch https://github.com/swagger-api/swagger-ui.git $(TMPDIR)/swagger-ui
  375. mv $(TMPDIR)/swagger-ui/dist public/vendor/assets/swagger-ui
  376. rm -Rf $(TMPDIR)/swagger-ui
  377. $(SED_INPLACE) "s;http://petstore.swagger.io/v2/swagger.json;../../../swagger.v1.json;g" public/vendor/assets/swagger-ui/index.html
  378. .PHONY: update-translations
  379. update-translations:
  380. mkdir -p ./translations
  381. cd ./translations && curl -L https://crowdin.com/download/project/gitea.zip > gitea.zip && unzip gitea.zip
  382. rm ./translations/gitea.zip
  383. $(SED_INPLACE) -e 's/="/=/g' -e 's/"$$//g' ./translations/*.ini
  384. $(SED_INPLACE) -e 's/\\"/"/g' ./translations/*.ini
  385. mv ./translations/*.ini ./options/locale/
  386. rmdir ./translations
  387. .PHONY: generate-images
  388. generate-images:
  389. mkdir -p $(TMPDIR)/images
  390. inkscape -f $(PWD)/assets/logo.svg -w 880 -h 880 -e $(PWD)/public/img/gitea-lg.png
  391. inkscape -f $(PWD)/assets/logo.svg -w 512 -h 512 -e $(PWD)/public/img/gitea-512.png
  392. inkscape -f $(PWD)/assets/logo.svg -w 192 -h 192 -e $(PWD)/public/img/gitea-192.png
  393. inkscape -f $(PWD)/assets/logo.svg -w 120 -h 120 -jC -i layer1 -e $(TMPDIR)/images/sm-1.png
  394. inkscape -f $(PWD)/assets/logo.svg -w 120 -h 120 -jC -i layer2 -e $(TMPDIR)/images/sm-2.png
  395. composite -compose atop $(TMPDIR)/images/sm-2.png $(TMPDIR)/images/sm-1.png $(PWD)/public/img/gitea-sm.png
  396. inkscape -f $(PWD)/assets/logo.svg -w 200 -h 200 -e $(PWD)/public/img/avatar_default.png
  397. inkscape -f $(PWD)/assets/logo.svg -w 180 -h 180 -e $(PWD)/public/img/favicon.png
  398. inkscape -f $(PWD)/assets/logo.svg -w 128 -h 128 -e $(TMPDIR)/images/128-raw.png
  399. inkscape -f $(PWD)/assets/logo.svg -w 64 -h 64 -e $(TMPDIR)/images/64-raw.png
  400. inkscape -f $(PWD)/assets/logo.svg -w 32 -h 32 -jC -i layer1 -e $(TMPDIR)/images/32-1.png
  401. inkscape -f $(PWD)/assets/logo.svg -w 32 -h 32 -jC -i layer2 -e $(TMPDIR)/images/32-2.png
  402. composite -compose atop $(TMPDIR)/images/32-2.png $(TMPDIR)/images/32-1.png $(TMPDIR)/images/32-raw.png
  403. inkscape -f $(PWD)/assets/logo.svg -w 16 -h 16 -jC -i layer1 -e $(TMPDIR)/images/16-raw.png
  404. zopflipng -m -y $(TMPDIR)/images/128-raw.png $(TMPDIR)/images/128.png
  405. zopflipng -m -y $(TMPDIR)/images/64-raw.png $(TMPDIR)/images/64.png
  406. zopflipng -m -y $(TMPDIR)/images/32-raw.png $(TMPDIR)/images/32.png
  407. zopflipng -m -y $(TMPDIR)/images/16-raw.png $(TMPDIR)/images/16.png
  408. rm -f $(TMPDIR)/images/*-*.png
  409. convert $(TMPDIR)/images/16.png $(TMPDIR)/images/32.png \
  410. $(TMPDIR)/images/64.png $(TMPDIR)/images/128.png \
  411. $(PWD)/public/img/favicon.ico
  412. rm -rf $(TMPDIR)/images
  413. $(foreach file, $(shell find public/img -type f -name '*.png'),zopflipng -m -y $(file) $(file);)
  414. .PHONY: pr
  415. pr:
  416. $(GO) run contrib/pr/checkout.go $(PR)
  417. .PHONY: golangci-lint
  418. golangci-lint:
  419. @hash golangci-lint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  420. export BINARY="golangci-lint"; \
  421. curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.20.0; \
  422. fi
  423. golangci-lint run
上海开阖软件有限公司 沪ICP备12045867号-1