-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
47 lines (41 loc) · 1.19 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
PWD=$(shell pwd)
SOURCE=$(shell jq -r .source secrets/secrets.json)
ORIGINAL=$(PWD)/migrate/original
RESHAPE=$(PWD)/migrate/reshape
GENERATE=$(PWD)/migrate/generate
SERVER=$(PWD)/migrate/server
.PHONY: clean
clean:
@-rm -rf $(RESHAPE)
@-rm -rf $(DATASTORE)
@-rm -rf $(SERVER)
.PHONY: sync
sync:
INPUT=$(SOURCE) OUTPUT=$(ORIGINAL) ./src/sync/run.sh
.PHONY: reshape
reshape:
mkdir -p $(RESHAPE)
./src/reshape/extract-schema.sh $(ORIGINAL)/db.sqlite3 > $(RESHAPE)/original.json
go run \
./src/reshape/gen.go \
$(ORIGINAL)/db.sqlite3 \
$(RESHAPE)/original.json \
$(PWD)/src/reshape/reshape.sql.gotmpl \
> $(RESHAPE)/reshape.sql
rm -f $(RESHAPE)/db.sqlite3
sqlite3 $(RESHAPE)/db.sqlite3 < $(RESHAPE)/reshape.sql
./src/reshape/extract-schema.sh $(RESHAPE)/db.sqlite3 > $(RESHAPE)/shape.json
.PHONY: generate
generate:
mkdir -p $(GENERATE)
go run ./src/generate/generate.go \
-input $(RESHAPE)/shape.json \
-templates $(PWD)/src/generate \
-output $(GENERATE)
.PHONY: server
server:
mkdir -p $(SERVER)/datastore
cp $(GENERATE)/datastore.go $(SERVER)/datastore
cp $(GENERATE)/schema.graphql $(SERVER)
cp -R ./src/server/* $(SERVER)
(cd $(SERVER) && go run github.com/99designs/gqlgen -v)