This repository has been archived by the owner on Dec 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
codegen.sh
executable file
·155 lines (128 loc) · 6.86 KB
/
codegen.sh
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
#!/bin/bash
set -e
find ./build -name gen-* -delete
_PWD=$PWD
function yellow {
echo -e "\033[33m$@\033[39m"
}
function green {
echo -e "\033[32m$@\033[39m"
}
function gofmt {
yellow "> go fmt ./..."
go fmt ./...
green "OK"
}
function types {
yellow "> types"
if [ ! -f "build/gen-type-set" ]; then
CGO_ENABLED=0 go build -o ./build/gen-type-set codegen/v2/type-set.go
fi
if [ ! -f "build/gen-type-set-test" ]; then
CGO_ENABLED=0 go build -o ./build/gen-type-set-test codegen/v2/type-set-test.go
fi
./build/gen-type-set --types Namespace --output compose/types/namespace.gen.go
./build/gen-type-set --types Attachment --output compose/types/attachment.gen.go
./build/gen-type-set --types Module --output compose/types/module.gen.go
./build/gen-type-set --types Page --output compose/types/page.gen.go
./build/gen-type-set --types Chart --output compose/types/chart.gen.go
./build/gen-type-set --types Trigger --output compose/types/trigger.gen.go
./build/gen-type-set --types Record --output compose/types/record.gen.go
./build/gen-type-set --types ModuleField --output compose/types/module_field.gen.go
./build/gen-type-set-test --types Namespace --output compose/types/namespace.gen_test.go
./build/gen-type-set-test --types Attachment --output compose/types/attachment.gen_test.go
./build/gen-type-set-test --types Module --output compose/types/module.gen_test.go
./build/gen-type-set-test --types Page --output compose/types/page.gen_test.go
./build/gen-type-set-test --types Chart --output compose/types/chart.gen_test.go
./build/gen-type-set-test --types Trigger --output compose/types/trigger.gen_test.go
./build/gen-type-set-test --types Record --output compose/types/record.gen_test.go
./build/gen-type-set-test --types ModuleField --output compose/types/module_field.gen_test.go
./build/gen-type-set --with-primary-key=false --types RecordValue --output compose/types/record_value.gen.go
./build/gen-type-set-test --with-primary-key=false --types RecordValue --output compose/types/record_value.gen_test.go
./build/gen-type-set --types MessageAttachment --output messaging/types/attachment.gen.go
./build/gen-type-set --types Mention --output messaging/types/mention.gen.go
./build/gen-type-set --types MessageFlag --output messaging/types/message_flag.gen.go
./build/gen-type-set --types Message --output messaging/types/message.gen.go
./build/gen-type-set --types Channel --output messaging/types/channel.gen.go
./build/gen-type-set --types Webhook --output messaging/types/webhook.gen.go
./build/gen-type-set-test --types MessageAttachment --output messaging/types/attachment.gen_test.go
./build/gen-type-set-test --types Mention --output messaging/types/mention.gen_test.go
./build/gen-type-set-test --types MessageFlag --output messaging/types/message_flag.gen_test.go
./build/gen-type-set-test --types Message --output messaging/types/message.gen_test.go
./build/gen-type-set-test --types Channel --output messaging/types/channel.gen_test.go
./build/gen-type-set-test --types Webhook --output messaging/types/webhook.gen_test.go
./build/gen-type-set --with-primary-key=false --types ChannelMember --output messaging/types/channel_member.gen.go
./build/gen-type-set --with-primary-key=false --types Command --output messaging/types/command.gen.go
./build/gen-type-set --with-primary-key=false --types CommandParam --output messaging/types/command_param.gen.go
./build/gen-type-set --with-primary-key=false --types Unread --output messaging/types/unread.gen.go
./build/gen-type-set-test --with-primary-key=false --types ChannelMember --output messaging/types/channel_member.gen_test.go
./build/gen-type-set-test --with-primary-key=false --types Command --output messaging/types/command.gen_test.go
./build/gen-type-set-test --with-primary-key=false --types CommandParam --output messaging/types/command_param.gen_test.go
./build/gen-type-set-test --with-primary-key=false --types Unread --output messaging/types/unread.gen_test.go
./build/gen-type-set --types User --output system/types/user.gen.go
./build/gen-type-set --types Application --output system/types/application.gen.go
./build/gen-type-set --types Role --output system/types/role.gen.go
./build/gen-type-set --types Organisation --output system/types/organisation.gen.go
./build/gen-type-set --types Credentials --output system/types/credentials.gen.go
./build/gen-type-set-test --types User --output system/types/user.gen_test.go
./build/gen-type-set-test --types Application --output system/types/application.gen_test.go
./build/gen-type-set-test --types Role --output system/types/role.gen_test.go
./build/gen-type-set-test --types Organisation --output system/types/organisation.gen_test.go
./build/gen-type-set-test --types Credentials --output system/types/credentials.gen_test.go
./build/gen-type-set --types Value --output internal/settings/types.gen.go --with-primary-key=false --package settings
./build/gen-type-set-test --types Value --output internal/settings/types.gen_test.go --with-primary-key=false --package settings
./build/gen-type-set --types Rule --output internal/permissions/rule.gen.go --with-primary-key=false --package permissions
./build/gen-type-set --types Resource --output internal/permissions/resource.gen.go --with-primary-key=false --package permissions
./build/gen-type-set-test --types Rule --output internal/permissions/rule.gen_test.go --with-primary-key=false --package permissions
./build/gen-type-set-test --types Resource --output internal/permissions/resource.gen_test.go --with-primary-key=false --package permissions
green "OK"
}
types
function database {
yellow "> database"
FOLDERS=$(find . -type d -wholename '*/schema/mysql')
for FOLDER in $FOLDERS; do
FOLDER=$(dirname $(dirname $FOLDER))
FOLDER=${FOLDER:2}
echo $FOLDER
cd $FOLDER && $GOPATH/bin/statik -p mysql -m -Z -f -src=schema/mysql && cd $_PWD
done
green "OK"
}
database
function files {
yellow "> files"
FOLDERS=$(find . -type d -wholename '*/data')
for FOLDER in $FOLDERS; do
FOLDER=$(dirname $FOLDER)
FOLDER=${FOLDER:2}
echo $FOLDER
cd $FOLDER && $GOPATH/bin/statik -p files -m -Z -f -src=data && cd $_PWD
done
green "OK"
}
files
function specs {
yellow "> specs"
if [ ! -f "build/gen-spec" ]; then
CGO_ENABLED=0 go build -o ./build/gen-spec codegen/v2/spec.go
fi
_PWD=$PWD
SPECS=$(find $PWD -name 'spec.json' | xargs -n1 dirname)
for SPEC in $SPECS; do
yellow "> spec $SPEC"
cd $SPEC && rm -rf spec && ../../build/gen-spec && cd $_PWD
green "OK"
done
for SPEC in $SPECS; do
SRC=$(basename $SPEC)
if [ -d "codegen/$SRC" ]; then
yellow "> README $SRC"
codegen/codegen.php $SRC
rsync -a codegen/common/ $SRC/
green "OK"
fi
done
}
specs
gofmt