-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(deploy): Move Firebase's npm scripts to Makefile (#30)
Goal: make the bot more agnostic => make it easy to integrate on glitch.io, for instance. * clean-up makefile * fix: move npm firebase-related scripts to Makefile * fix: no need to lint before deploy * add "release" target in makefile
- Loading branch information
1 parent
8d5cd11
commit 3414377
Showing
6 changed files
with
51 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,48 @@ | ||
#!make | ||
|
||
include .env | ||
|
||
.DEFAULT_GOAL := help | ||
|
||
install: ## Fetch JS dependencies. | ||
@cd functions; npm install | ||
|
||
build: install | ||
build: install ## Transpile TypeScript files into JavaScript | ||
@cd functions; npm run build | ||
|
||
test: build ## Run tests | ||
test: install ## Run automated tests | ||
@cd functions; npm test | ||
|
||
lint: install ## Run ESLint | ||
@cd functions; npm run lint | ||
|
||
deploy: install ## Run ESLint | ||
@cd functions; npm run deploy:setup | ||
@cd functions; npm run deploy:config | ||
@cd functions; npm run deploy | ||
release: install test build | ||
@echo "Making sure that you're on the main branch..." | ||
@git checkout | grep "master" | ||
@cd functions; npx release-it | ||
|
||
deploy-firebase: setup-firebase install test build ## Deploy to Firebase Functions | ||
@cd functions; node tools/bot-config-firebase.js | ||
@cd functions; npx firebase deploy --only functions | ||
|
||
setup-firebase: ## Logs you into your Firebase account | ||
@cd functions; npx firebase 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 '{}' | ||
|
||
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 functions:log | ||
|
||
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: fetch-deps install build test lint deploy help | ||
.PHONY: install build test lint release deploy-firebase setup-firebase test-firebase bind-firebase-webhook test-firebase-webhook firebase-logs help |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
{ | ||
"functions": { | ||
"predeploy": [ | ||
"npm --prefix \"$RESOURCE_DIR\" run lint", | ||
"npm --prefix \"$RESOURCE_DIR\" run build" | ||
] | ||
"predeploy": ["npm --prefix \"$RESOURCE_DIR\" run build"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// To setup the chatbot on Firebase Functions, run this command from the parent directory: | ||
// $ node tools/bot-config-for-firebase.js | ||
|
||
const { execSync } = require('child_process') // eslint-disable-line @typescript-eslint/no-var-requires | ||
const botConfig = require(`${__dirname}/bot-config.js`) // eslint-disable-line @typescript-eslint/no-var-requires | ||
const json = JSON.stringify(botConfig, null, 2) | ||
execSync(`npx firebase functions:config:set config='${json}'`, { | ||
stdio: 'inherit', | ||
}) |
This file was deleted.
Oops, something went wrong.