-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (42 loc) · 2.71 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
#!make
include .env
.DEFAULT_GOAL := help
install: ## Fetch JS dependencies.
@cd functions; npm install
build: install ## Transpile TypeScript files into JavaScript
@cd functions; npm run build
test: install ## Run automated tests
@cd functions; npm test
test-bot: install ## Interact with the bot locally
@cd functions; npm run test:bot
lint: install ## Run ESLint
@cd functions; npm run lint
release: install test build
@echo "Making sure that you're on the main branch..."
@git checkout | grep "master"
@cd functions; npx release-it --no-npm.publish
@echo "Now, go to https://github.com/adrienjoly/telegram-scribe-bot/tags, to create the Release"
deploy-firebase: setup-firebase install test build ## Deploy to Firebase Functions
@cd functions; node tools/bot-config-firebase.js
@cd functions; npx firebase-tools deploy --no-gen2
emulate-firebase: build ## Starts a local Firebase server
@cd functions; node tools/bot-config-firebase.js
@cd functions; npx firebase-tools functions:config:get > .runtimeconfig.json
@cd functions; npx firebase-tools emulators:start
setup-firebase: ## Logs you into your Firebase account
@cd functions; npx firebase-tools login
@echo "Don't forget to specify your Firebase app id in .firebaserc, cf README.md"
test-firebase: ## Checks that the Firebase Function's responds
@curl --silent -X POST -H "Content-Type:application/json" ${ROUTER_URL} -d '{"message":{"chat":{"id":1},"from":{"id":199893686,"first_name":"test_name"},"entities":[{"type":"bot_command","offset":0,"length": 8}],"text":"/version"}}'
test-firebase-local: ## Checks that the Firebase Function's responds
@curl --silent -X POST -H "Content-Type:application/json" http://localhost:5001/telegram-scribe-bot/us-central1/router -d '{"message":{"chat":{"id":1},"from":{"id":199893686,"first_name":"test_name"},"entities":[{"type":"bot_command","offset":0,"length": 8}],"text":"/version"}}'
bind-firebase-webhook: ## Binds the Firebase Function to your Telegram bot
@curl --silent https://api.telegram.org/bot${BOT_TOKEN}/setWebhook?url=${ROUTER_URL} | grep --color=always "\"ok\":true"
test-firebase-webhook: ## Checks that the Firebase Function's router URL was properly bound to your Telegram bot
@curl --silent https://api.telegram.org/bot${BOT_TOKEN}/getWebhookInfo | grep --color=always "\"ok\":true"
firebase-logs: ## Reads logs from Firebase Functions
@cd functions; npx firebase-tools functions:log -n 1000
help: ## This help.
@echo 'Available targets:'
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
.PHONY: install build test test-bot lint release deploy-firebase setup-firebase test-firebase bind-firebase-webhook test-firebase-webhook firebase-logs help