-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
173 lines (137 loc) · 5.9 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
PYTHON_BINARY := python3
PYTHON_VIRTUAL_ENV := venv
PYTHON_VIRTUAL_BIN := $(PYTHON_VIRTUAL_ENV)/bin
GO_BIN := $(shell go env GOPATH)/bin
## help - Display help about make targets for this Makefile
help:
@cat Makefile | grep '^## ' --color=never | cut -c4- | sed -e "`printf 's/ - /\t- /;'`" | column -s "`printf '\t'`" -t
## clean - Remove the virtual environment and clear out .pyc files along with node_modules and vendor folders
clean: | clean-go clean-java clean-node clean-php clean-python
## clean-go - Cleans the Go environment
clean-go:
rm -rf vendor
## clean-java - Cleans the Java environment
clean-java:
rm -rf target
find . -name '*.jar' -delete
## clean-python - Cleans the Python environment
clean-python:
rm -rf $(PYTHON_VIRTUAL_ENV) dist *.egg-info .coverage
find . -name '*.pyc' -delete
## clean-node - Cleans the Node environment
clean-node:
rm -rf node_modules
## clean-php - Cleans the PHP environment
clean-php:
rm -rf vendor bin
## install - install all dependencies for each language
install: | install-csharp install-go install-java install-node install-php install-python install-ruby
## install-csharp - install C# dependencies
install-csharp:
sh ./symlink_directory_files.sh style_guides/csharp .
dotnet tool install -g dotnet-format || exit 0
## install-go - Install and vendor Go dependencies
install-go:
sh ./symlink_directory_files.sh style_guides/golang .
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GO_BIN) v1.60.3
go mod vendor
## install-java - installs Java dependencies
install-java:
sh ./symlink_directory_files.sh style_guides/java .
curl -LJs https://github.com/checkstyle/checkstyle/releases/download/checkstyle-10.3.1/checkstyle-10.3.1-all.jar -o checkstyle.jar
mvn dependency:resolve
## install-node - installs Node dependencies
install-node:
sh ./symlink_directory_files.sh style_guides/node .
npm install
## install-php - installs PHP dependencies
install-php:
sh ./symlink_directory_files.sh style_guides/php .
composer install
## install-python - install Python dependencies
install-python:
sh ./symlink_directory_files.sh style_guides/python .
$(PYTHON_BINARY) -m venv $(PYTHON_VIRTUAL_ENV)
$(PYTHON_VIRTUAL_BIN)/pip install -e ."[dev]"
## install-ruby - installs Ruby dependencies
install-ruby:
sh ./symlink_directory_files.sh style_guides/ruby .
bundle install
## lint - lints the entire project
lint: | lint-csharp lint-go lint-java lint-node lint-php lint-python lint-ruby lint-shell
## lint-csharp - lint C# files
lint-csharp:
dotnet format whitespace --include official/docs/csharp/ --folder --verify-no-changes
dotnet format whitespace --include official/guides/ --folder --verify-no-changes
## lint-go - Lint Go files
lint-go:
$(GO_BIN)/golangci-lint run official/docs/golang/current/... community/... official/guides/...
## lint-java - lints Java files
lint-java:
java -jar checkstyle.jar src -c easypost_java_style.xml -d official/docs/java/*
java -jar checkstyle.jar src -c easypost_java_style.xml -d official/guides/*
## lint-node - lints Node files
lint-node:
npm run lint
## lint-php - lints PHP files
lint-php:
composer lint
## lint-python - lint Python files
lint-python:
$(PYTHON_VIRTUAL_BIN)/flake8 official/docs/python/
$(PYTHON_VIRTUAL_BIN)/flake8 official/guides/
$(PYTHON_VIRTUAL_BIN)/flake8 official/landing_pages/
## lint-ruby - lints Ruby files
lint-ruby:
bundle exec rubocop
## lint-shell - lints shell files
lint-shell:
shellcheck official/docs/curl/current/**/*.sh -e SC2148,SC2034
shfmt -i 2 -d official/docs/curl
shellcheck official/guides/**/curl/*.sh -e SC2148,SC2034
shfmt -i 2 -d official/guides/**/curl
## format - formats the entire project
format: | format-csharp format-go format-java format-node format-php format-python format-ruby format-shell
## format-csharp - formats C# files
format-csharp:
dotnet format whitespace --include official/docs/csharp/ --folder
dotnet format whitespace --include official/guides/ --folder
## format-go - formats Go files
format-go:
$(GO_BIN)/golangci-lint run --fix
## format-java - formats Java files
format-java:
echo "Not implemented"
## format-node - formats Node files
format-node:
npm run format
## format-php - formats PHP files
format-php:
composer fix
## format-python - formats Python files
format-python:
$(PYTHON_VIRTUAL_BIN)/black official/docs/python/
$(PYTHON_VIRTUAL_BIN)/isort official/docs/python/ --lines-after-imports -1 --no-sections
$(PYTHON_VIRTUAL_BIN)/black official/guides/
$(PYTHON_VIRTUAL_BIN)/isort official/guides/ --lines-after-imports -1 --no-sections
$(PYTHON_VIRTUAL_BIN)/black official/landing_pages/
$(PYTHON_VIRTUAL_BIN)/isort official/landing_pages/ --lines-after-imports -1 --no-sections
## format-ruby - formats Ruby files
format-ruby:
bundle exec rubocop -a
## format-shell - formats shell files
format-shell:
shfmt -i 2 -w official/docs/curl/*
shfmt -i 2 -w official/guides/**/curl/*
## format-node-check - checks that Node files conform to the correct format
format-node-check:
npm run check
## format-python-check - checks that Python files conform to the correct format
format-python-check:
$(PYTHON_VIRTUAL_BIN)/black official/docs/python/ --check
$(PYTHON_VIRTUAL_BIN)/isort official/docs/python/ --lines-after-imports -1 --no-sections --check-only
$(PYTHON_VIRTUAL_BIN)/black official/guides/ --check
$(PYTHON_VIRTUAL_BIN)/isort official/guides/ --lines-after-imports -1 --no-sections --check-only
$(PYTHON_VIRTUAL_BIN)/black official/landing_pages/ --check
$(PYTHON_VIRTUAL_BIN)/isort official/landing_pages/ --lines-after-imports -1 --no-sections --check-only
.PHONY: help install install-csharp install-go install-java install-node install-php install-python install-ruby install-shell lint lint-csharp lint-go lint-java lint-node lint-php lint-python lint-ruby lint-shell format format-csharp format-go format-java format-node format-php format-python format-ruby format-shell format-node-check format-python-check