-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (45 loc) · 1.84 KB
/
Makefile
File metadata and controls
55 lines (45 loc) · 1.84 KB
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
.PHONY: all help install_base install_deps build_docs build test run build_wasm build_docker run_docker
all: help
help:
@echo "Available commands:"
@echo " make install_base - Install Node.js"
@echo " make install_deps - Install dependencies (npm install)"
@echo " make build_docs - Build API docs and put them in 'docs' directory (or dir given in DOCS_DIR)"
@echo " make build - Build the CLI binary (or to dir given in BIN_DIR)"
@echo " make test - Run tests locally"
@echo " make run - Run the CLI. E.g., make run ARGS='--version'"
@echo " make build_wasm - Build the WASM output"
@echo " make build_docker - Build Docker images"
@echo " make run_docker - Run Docker images"
install_base:
@echo "Please install Node.js >= 18.0.0 manually if not installed."
npm --version || echo "npm not found. Please install Node.js."
install_deps:
npm install
DOCS_DIR ?= docs
build_docs:
npm run docs
BIN_DIR ?= dist
build:
npm run build
@if [ "$(BIN_DIR)" != "dist" ]; then \
mkdir -p $(BIN_DIR); \
cp -r dist/* $(BIN_DIR)/; \
fi
test:
npm run test
run: build
node $(BIN_DIR)/cli.js $(ARGS)
build_wasm:
@echo "Building WASM (browser bundle)..."
npx esbuild dist/index.js --bundle --platform=browser --target=es2020 --external:node:fs --external:node:path --external:node:url --external:node:crypto --external:node:os --outfile=bin/cdd-ts.js
@echo "Compiling to WebAssembly..."
npx -y javy-cli compile bin/cdd-ts.js -o bin/cdd-ts.wasm
build_docker:
docker build -f debian.Dockerfile -t cdd-ts:debian .
docker build -f alpine.Dockerfile -t cdd-ts:alpine .
run_docker:
docker run -d -p 8080:8080 --name cdd-ts-test cdd-ts:alpine
sleep 2
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"version","id":1}' http://localhost:8080
docker stop cdd-ts-test && docker rm cdd-ts-test