-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
75 lines (60 loc) · 2.17 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
NPM ?= npm
define GetFromPkg
$(shell node -p "require('./src/manifest.json').$(1)")
endef
APP_ID := $(call GetFromPkg, app_id)
VERSION := $(call GetFromPkg, version)
BUNDLE_NAME := app_$(APP_ID)_$(VERSION)
DIST_DIR := dist
DEFAULT_BUNDLE_NAME := bundle
# should be the same as the one in tsconfig.json
TS_DIST_DIR := dist-ts
.PHONY: build dist watch clean help
## build: build the app
build: node_modules
$(NPM) run build
## dist: creates the bundle file for dev deployment
dist-dev: build
rm -rf $(DIST_DIR)/$(DEFAULT_BUNDLE_NAME) && mkdir -p $(DIST_DIR)/$(DEFAULT_BUNDLE_NAME)
mv $(TS_DIST_DIR)/* $(DIST_DIR)/$(DEFAULT_BUNDLE_NAME)
rm -r $(TS_DIST_DIR)
mv node_modules $(DIST_DIR)/$(DEFAULT_BUNDLE_NAME)
cp -r src/locales $(DIST_DIR)/$(DEFAULT_BUNDLE_NAME)
cp src/manifest.json $(DIST_DIR)
cp -r static $(DIST_DIR)
cd $(DIST_DIR) ; \
zip -rm $(DEFAULT_BUNDLE_NAME).zip $(DEFAULT_BUNDLE_NAME) ; \
zip -rm ../$(BUNDLE_NAME).zip manifest.json static $(DEFAULT_BUNDLE_NAME).zip
rm -rf ./$(DIST_DIR)/* && mv ./$(BUNDLE_NAME).zip ./$(DIST_DIR)
## dist: creates the bundle file for deployment
dist: build
rm -rf ./$(DIST_DIR)/* && mkdir -p ./$(DIST_DIR)/$(DEFAULT_BUNDLE_NAME)
mv $(TS_DIST_DIR)/* $(DIST_DIR)/$(DEFAULT_BUNDLE_NAME)
rm -r $(TS_DIST_DIR)
mv node_modules $(DIST_DIR)/$(DEFAULT_BUNDLE_NAME)
cp -r src/locales $(DIST_DIR)/$(DEFAULT_BUNDLE_NAME)
cp src/manifest.json $(DIST_DIR)
cp -r static $(DIST_DIR)
cd $(DIST_DIR) ; \
zip -rm $(DEFAULT_BUNDLE_NAME).zip $(DEFAULT_BUNDLE_NAME) ; \
zip -rm ../$(DEFAULT_BUNDLE_NAME).zip manifest.json static $(DEFAULT_BUNDLE_NAME).zip
rm -rf ./$(DIST_DIR)/* && mv ./$(DEFAULT_BUNDLE_NAME).zip ./$(DIST_DIR)
## build: build the app when changed
watch: node_modules
$(NPM) run dev
run:
docker-compose up
stop:
docker-compose stop
restart:
docker-compose stop && docker-compose up
## clean: deletes all
clean:
$(NPM) run clean
## node_modules: ensures NPM dependencies are installed without having to run this all the time
node_modules: $(wildcard package.json)
$(NPM) install
touch $@
help: ## help: prints this help message
@echo "Usage:"
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'