This repository has been archived by the owner on Jul 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
78 lines (63 loc) · 2.9 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
# https://stackoverflow.com/questions/3931741/why-does-make-think-the-target-is-up-to-date
.PHONY: docs
# Install NPM packages
prep:
npm i
# Build the code with tsc npx = Node Package Execute
build:
# --build is needed to use --verbose, --verbose is needed so that tsc isn't totally silent
npx tsc --build --verbose
# Run the already compiled code
run:
node --enable-source-maps ./target/core/main.js
# Start the bot without typechecking, outside of docker
start: build
# --enable-source-maps uses the `.map` files to make stack traces point towards the typescript files
# instead of the compiled js
node --enable-source-maps ./target/core/main.js
# Start the bot, without compiling, running using the production node profile
# (will start more slowly, but have better performance afterwords)
# https://nodejs.dev/en/learn/nodejs-the-difference-between-development-and-production/
# (will only work in linux)
prod-run:
NODE_ENV=production node --enable-source-maps ./target/core/main.js
# Compile code and run unit tests https://nodejs.org/api/test.html#test-runner
test: build
node --test ./target/tests
# Format whole project
format:
# https://github.com/google/gts
npx prettier -w src/ && npx eslint --fix src/
# look for formatting errors
lint:
npx gts lint
# start the bot with a profiler running.
profile:
npx 0x -o --output-dir profile_results.0x ./target/core/main.js
# Build a docker container (requires dev deps)
docker-build: build
docker build . -t turingbot
# Start a pre-existing docker container in daemon mode
# This may not work on windows, try copy pasting the command directly into powershell
docker-run:
# --rm: remove the container once it finishes running
# --name: docker will randomly generate a name if not manually specified
# -d: run in daemon mode and start in the background
# --mount type=bind...: take the config file in this directory, and mount it to the equivalent directory in the docker container
# turingbot: the container to run
docker run --rm --name turingbot -d --mount type=bind,source=$(pwd)/config.jsonc,target=/usr/src/turingbot/config.jsonc --mount type=bind,source=$(pwd)/secrets.jsonc,target=/usr/src/turingbot/secrets.jsonc turingbot
# Make a bot docker container and start it in daemon mode
docker-start: docker-build
make docker-run
# Generate jsdoc documentation (https://github.com/ankitskvmdam/clean-jsdoc-theme-example)
docs:
npx jsdoc --configure jsdoc.json --verbose
# Build JSDOC documentation, create an nginx docker container, and start the docker container
# (on port 8080)
docker-docs: docs
# -t assigns the tag to turingdocs, ./docs/ indicates where the dockerfile is located
docker build -t turingdocs ./docs/
# --rm removes the container once it's finished running,
# -d means to run in daemon mode, -p 8080:80 indicates that we want to
# take port 80 inside the container and map it to port 8080 on the outside
docker run --rm -d -p 8080:80 --name turingdocs turingdocs