-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
118 lines (97 loc) · 3.23 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
#
# Makefile
# RealmTaskTracker
#
################################################################################
#
# Variables
#
ATLAS_PUBLIC_API_KEY := $(shell cat .atlas_public_api_key)
ATLAS_PRIVATE_API_KEY := $(shell cat .atlas_private_api_key)
MONGODB_USERNAME := $(shell cat .mongodb_username)
MONGODB_PASSWORD := $(shell cat .mongodb_password)
CLUSTER = sandbox.5exqq.mongodb.net
DATABASE = tracker
REALM_APP_ID := $(shell cat .realm_app_id)
REALM_CLI = $(shell npm bin)/realm-cli
SWIFT_VERSION = 5.4
ATLAS_FOLDER = Atlas
MONGODB_FOLDER = $(ATLAS_FOLDER)/mongodb
REALM_FOLDER = $(ATLAS_FOLDER)/realm
################################################################################
#
# Targets
#
.PHONY: version
version:
xcodebuild -version
swift --version
mongo --version
mongodump --version
mongorestore --version
mongoexport --version
mongoimport --version
node --version
npm --version
$(REALM_CLI) --version
.PHONY: init
init:
- brew bundle install
# nvm use
npm install
.PHONY: clean
clean:
rm -rf Packages
xcodebuild clean
#
# MongoDB
#
.PHONY: shell
shell:
mongo "mongodb+srv://$(CLUSTER)/$(DATABASE)" --username $(MONGODB_USERNAME) --password $(MONGODB_PASSWORD)
.PHONY: dump
dump:
mongodump --uri "mongodb+srv://$(MONGODB_USERNAME):$(MONGODB_PASSWORD)@$(CLUSTER)/$(DATABASE)" --out=$(MONGODB_FOLDER)
.PHONY: restore
restore:
mongorestore --uri "mongodb+srv://$(MONGODB_USERNAME):$(MONGODB_PASSWORD)@$(CLUSTER)/$(DATABASE)" --drop $(MONGODB_FOLDER)
.PHONY: export
export:
mongoexport --uri="mongodb+srv://$(MONGODB_USERNAME):$(MONGODB_PASSWORD)@$(CLUSTER)/$(DATABASE)" --collection=users --out=$(MONGODB_FOLDER)/users.json
mongoexport --uri="mongodb+srv://$(MONGODB_USERNAME):$(MONGODB_PASSWORD)@$(CLUSTER)/$(DATABASE)" --collection=tasks --out=$(MONGODB_FOLDER)/tasks.json
.PHONY: import
import:
mongoimport --uri="mongodb+srv://$(MONGODB_USERNAME):$(MONGODB_PASSWORD)@$(CLUSTER)/$(DATABASE)" --collection=users --drop $(MONGODB_FOLDER)/users.json
mongoimport --uri="mongodb+srv://$(MONGODB_USERNAME):$(MONGODB_PASSWORD)@$(CLUSTER)/$(DATABASE)" --collection=tasks --drop $(MONGODB_FOLDER)/tasks.json
#
# Realm CLI
# https://docs.mongodb.com/realm/deploy/realm-cli-reference/
# Note: v2 beta syntax does not match documented CLI reference.
#
.PHONY: login
login:
$(REALM_CLI) login --api-key="$(ATLAS_PUBLIC_API_KEY)" --private-api-key="$(ATLAS_PRIVATE_API_KEY)"
.PHONY: whoami
whoami:
$(REALM_CLI) whoami
.PHONY: list
list:
$(REALM_CLI) apps list
.PHONY: users
users:
$(REALM_CLI) users list --app $(REALM_APP_ID)
.PHONY: realmdiff
realmdiff:
$(REALM_CLI) app diff --remote $(REALM_APP_ID) --local $(REALM_FOLDER)
.PHONY: realmpull
realmpull:
$(REALM_CLI) pull --remote $(REALM_APP_ID) --local $(REALM_FOLDER)
# FIXME: Errors out
# node_modules/.bin/realm-cli import --app-id=task-tracker-seidr --path Atlas/realm --strategy=replace
# failed to diff app with currently deployed instance: error: error validating Service: mongodb-atlas: only [wireProtocolEnabled, readPreference, readPreferenceTagSets] are allowed config options
.PHONY: realmpush
realmpush:
$(REALM_CLI) push --remote $(REALM_APP_ID) --local $(REALM_FOLDER)
.PHONY: realmpushtest
realmpushtest:
$(REALM_CLI) push --remote $(REALM_APP_ID) --local $(REALM_FOLDER) --dry-run