-
Notifications
You must be signed in to change notification settings - Fork 78
/
Makefile
70 lines (54 loc) · 2.37 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
POSTMAN_BASE_URL ?= http://localhost:8000
PROXY_TARGET ?= http://mock:4010
SPEC_FILE ?= specification/DigitalOcean-public.v2.yaml
BUNDLE_PATH ?= tests/openapi-bundled.yaml
COLLECTION_PATH ?= tests/postman.json
TMP_COLLECTION_PATH ?= tests/postman-temp.json
DO_TOKEN ?= XXXXXX
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: dev-dependencies
dev-dependencies: ## Install development tooling using npm
npm install
.PHONY: start-mockedproxy
start-mockedproxy: ## Start a prism proxy (port 8000) targeting a local mock api (port 4010)
PROXY_TARGET=$(PROXY_TARGET) docker-compose up -d
.PHONY: stop-services
stop-services: ## Stop the proxy with mock docker services
docker-compose down
.PHONY: start-prodproxy
start-prodproxy: ## Start a proxy to the production
PROXY_TARGET=https://api.digitalocean.com docker-compose up proxy
.PHONY: _sleep
_sleep:
sleep 3
.PHONY: test
test: dev-dependencies bundle collection start-mockedproxy _sleep ## Run Postman collection against local proxy with validation
npm run newman -- ${COLLECTION_PATH} \
--env-var baseUrl=${POSTMAN_BASE_URL} \
--env-var accessToken=${DO_TOKEN} \
--reporters json,cli \
--reporter-json-export newman-results.json
.PHONY: lint
lint: dev-dependencies bundle ## Lint the OpenAPI spec using Spectral
npm run lint -- ${SPEC_FILE}
npm run lint -- --ruleset spectral/bundled.spectral.yml ${BUNDLE_PATH}
.PHONY: collection
collection: dev-dependencies bundle ## Use openapi-to-postmanv2 to generate a collection
npm run collection -- -s ${BUNDLE_PATH} -o ${TMP_COLLECTION_PATH}
jq --argjson authToken '{"bearer":[{"key":"token","value":"{{accessToken}}","type":"string"}]}' \
'.auth += $$authToken' ${TMP_COLLECTION_PATH} > ${COLLECTION_PATH}
rm -f ${TMP_COLLECTION_PATH}
.PHONY: bundle
bundle: dev-dependencies ## Use openapi-cli to bundle the spec
npm run bundle -- ${SPEC_FILE} -o ${BUNDLE_PATH}
.PHONY: autorest-python
autorest-python: dev-dependencies bundle
npm run autorest -- auto.yaml --verbose --python --add-credential
.PHONY: autorest-typescript
autorest-typescript: dev-dependencies bundle
npm run autorest -- auto.yaml --verbose --typescript
.PHONY: preview
preview: dev-dependencies ## Launch the docs preview server (openapi) and watch for file changes
SPEC_FILE=${SPEC_FILE} npm run preview