forked from Adyen/adyen-ruby-api-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
78 lines (67 loc) · 3.01 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
generator:=ruby
openapi-generator-version:=6.4.0
openapi-generator-url:=https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/$(openapi-generator-version)/openapi-generator-cli-$(openapi-generator-version).jar
openapi-generator-jar:=build/openapi-generator-cli.jar
openapi-generator-cli:=java -jar build/openapi-generator-cli.jar
output:=build/out
services:=balancePlatform checkout legalEntityManagement management payout transfers
singleFileServices:=balanceControlService binLookup dataProtection recurring storedValue payment posTerminalManagement
binLookup: spec=BinLookupService-v54
checkout: spec=CheckoutService-v70
dataProtection: spec=DataProtectionService-v1
storedValue: spec=StoredValueService-v46
posTerminalManagement: spec=TfmAPIService-v1
payment: spec=PaymentService-v68
recurring: spec=RecurringService-v68
payout: spec=PayoutService-v68
management: spec=ManagementService-v1
legalEntityManagement: spec=LegalEntityService-v3
balancePlatform: spec=BalancePlatformService-v2
balanceControlService: spec=BalanceControlService-v1
transfers: spec=TransferService-v3
allServices: $(services) $(singleFileServices)
$(services): build/spec $(openapi-generator-jar)
wget $(openapi-generator-url) -O build/openapi-generator-cli.jar
rm -rf $(output)
$(openapi-generator-cli) generate \
-i build/spec/json/$(spec).json \
-g $(generator) \
-c ./templates/config.yaml \
-o $(output) \
--global-property apis,apiTests=false,apiDocs=false,supportingFiles=api-single.rb\
--additional-properties serviceName=$@\
--skip-validate-spec
rm -f $(output)/lib/openapi_client/api/*-small.rb
mkdir -p lib/adyen/services/$@
mv $(output)/lib/openapi_client/api/*.rb lib/adyen/services/$@
mv $(output)/api/api-single.rb lib/adyen/services/[email protected]
rm -rf $(output)
$(singleFileServices): build/spec
wget $(openapi-generator-url) -O build/openapi-generator-cli.jar
jq -e 'del(.paths[][].tags)' build/spec/json/$(spec).json > build/spec/json/$(spec).tmp
mv build/spec/json/$(spec).tmp build/spec/json/$(spec).json
rm -rf $(output)
$(openapi-generator-cli) generate \
-i build/spec/json/$(spec).json \
-g $(generator) \
-c ./templates/config.yaml \
-o $(output) \
--global-property apis,apiTests=false,apiDocs=false\
--additional-properties serviceName=$@\
--skip-validate-spec
mv $(output)/lib/openapi_client/api/*-small.rb lib/adyen/services/[email protected]
rm -rf $(output)
templates: $(openapi-generator-jar)
$(openapi-generator-cli) author template -g $(generator) -o build/templates
# Download the generator
$(openapi-generator-jar):
wget --quiet -o /dev/null $(openapi-generator-url) -O $(openapi-generator-jar)
build/spec:
git clone https://github.com/Adyen/adyen-openapi.git build/spec
perl -i -pe's/"openapi" : "3.[0-9].[0-9]"/"openapi" : "3.0.0"/' build/spec/json/*.json
# Releases
version:
perl -lne 'print "currentVersion=$$1" if /(\d+\.\d+\.\d+)/' < lib/adyen/version.rb >> "$$GITHUB_OUTPUT"
version_files:=lib/adyen/version.rb
bump:
perl -i -pe 's/$$ENV{"CURRENT_VERSION"}/$$ENV{"NEXT_VERSION"}/' $(version_files)