Skip to content

Commit

Permalink
Refactor Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Jun 26, 2019
1 parent 4f9bb26 commit 95038d3
Showing 1 changed file with 13 additions and 43 deletions.
56 changes: 13 additions & 43 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,29 @@ COMMIT_DATE := $(shell git show -s --format=%ci ${HASH})
BUILD_DATE := $(shell date '+%Y-%m-%d %H:%M:%S')
VERSION := ${HASH} (${COMMIT_DATE})

.PHONY: build-frontend
build-frontend:
cd frontend && yarn install && yarn build

.PHONY: quickdev
quickdev:
@ if [ ! -d "frontend/node_modules" ]; then \
echo "Installing frontend deps"; \
cd frontend && yarn install; \
fi

@ if [ ! -d "frontend/build" ]; then \
echo "Creating build directory"; \
mkdir -p frontend/build; \
echo "Building frontend assets"; \
cd frontend && yarn build; \
fi

@ echo -e "\nBuilding go binary\n"
make build

@ echo -e "Editing database params inside config\n"
cp config.toml.sample config.toml

@ echo -n "Database user: "
@ read DBUSER; \
sed -i -e "s/user = \"listmonk\"/user = \"$${DBUSER}\"/g" config.toml

@ echo -n "Database password: "
@ read DBPASSWORD; \
sed -i -e "s/password = \"\"/password = \"$${DBPASSWORD}\"/g" config.toml

@ echo -n "Database name: "
@ read DBNAME; \
sed -i -e "s/database = \"listmonk\"/database = \"$${DBNAME}\"/g" config.toml; \
createdb $${DBNAME}

@ echo -e "Running installer\n"
./listmonk --install
# Dependencies.
.PHONY: deps
deps:
go get -u github.com/knadh/stuffbin/...
cd frontend && yarn install

# Build steps.
.PHONY: build
build:
go build -o ${BIN} -ldflags="-s -w -X 'main.buildVersion=${VERSION}' -X 'main.buildDate=${BUILD_DATE}'"

.PHONY: build-frontend
build-frontend:
cd frontend && yarn build

.PHONY: build-dist
build-dist:
stuffbin -a stuff -in ${BIN} -out ${BIN} ${STATIC}

.PHONY: run
run: build
./${BIN}

.PHONY: deps
deps:
go get -u github.com/knadh/stuffbin/...

.PHONY: test
test:
go test
Expand Down

0 comments on commit 95038d3

Please sign in to comment.