UNPKG

1.98 kBPlain TextView Raw
1.PHONY: run run-sandbox setup test setup_upgrade install_node setup_nvm lint clean
2
3DESIRED_NODE_VERSION = v$(shell cat .node-version)
4CURRENT_NODE_VERSION = $(shell node --version)
5
6help:
7 @echo ' setup .................... sets up project dependencies'
8 @echo ' run ...................... runs project'
9 @echo ' test ..................... runs tests'
10 @echo ' setup_upgrade ............ upgrades project dependencies'
11 @echo ' clean .................... deletes project dependencies'
12 @echo ' install_node.............. sets up node version'
13 @echo ' setup_nvm ................ sets up nvm'
14 @echo ' lint ..................... runs code linter'
15
16setup: install_node
17 npm install
18
19run:
20 npm run start_dev
21
22run-sandbox:
23 npm run start_sandbox
24
25test:
26 npm test
27 $(MAKE) lint
28
29setup_upgrade: clean
30 npm install
31 npm shrinkwrap
32
33install_node:
34ifeq (${DESIRED_NODE_VERSION},${CURRENT_NODE_VERSION})
35 @echo "You are using desired node version: ${DESIRED_NODE_VERSION}"
36
37else
38 @echo "You are not using the desired node version: ${DESIRED_NODE_VERSION}, your version: ${CURRENT_NODE_VERSION}"
39 @if test -d ~/.nodenv; then \
40 echo "Nodenv is already installed"; \
41 bash -c "nodenv install $(subst v,,${DESIRED_NODE_VERSION}) -s"; \
42 bash -c "nodenv global $(subst v,,${DESIRED_NODE_VERSION})"; \
43 else \
44 make setup_nvm; \
45 bash -c "source ~/.nvm/nvm.sh && nvm install ${DESIRED_NODE_VERSION} && nvm use ${DESIRED_NODE_VERSION}"; \
46 echo "Add these lines to your bash_profile, bashrc ..."; \
47 echo " source ~/.nvm/nvm.sh"; \
48 echo " [[ -r $NVM_DIR/bash_completion ]] && . $NVM_DIR/bash_completion"; \
49 fi
50endif
51
52setup_nvm:
53 @if [ test -d ~/.nvm ]; then \
54 echo "Nvm is already installed"; \
55 else \
56 curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash; \
57 fi
58
59lint:
60 npm run lint
61
62clean:
63 -rm -rf node_modules
64
65docker_build:
66 docker build -t globobackstage/functions .
67
68docker_push:
69 docker push globobackstage/functions