1 | .PHONY: run run-sandbox setup test setup_upgrade install_node setup_nvm lint clean
|
2 |
|
3 | DESIRED_NODE_VERSION = v$(shell cat .node-version)
|
4 | CURRENT_NODE_VERSION = $(shell node --version)
|
5 |
|
6 | help:
|
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 |
|
16 | setup: install_node
|
17 | npm install
|
18 |
|
19 | run:
|
20 | npm run start_dev
|
21 |
|
22 | run-sandbox:
|
23 | npm run start_sandbox
|
24 |
|
25 | test:
|
26 | npm test
|
27 | $(MAKE) lint
|
28 |
|
29 | setup_upgrade: clean
|
30 | npm install
|
31 | npm shrinkwrap
|
32 |
|
33 | install_node:
|
34 | ifeq (${DESIRED_NODE_VERSION},${CURRENT_NODE_VERSION})
|
35 | @echo "You are using desired node version: ${DESIRED_NODE_VERSION}"
|
36 |
|
37 | else
|
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
|
50 | endif
|
51 |
|
52 | setup_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 |
|
59 | lint:
|
60 | npm run lint
|
61 |
|
62 | clean:
|
63 | -rm -rf node_modules
|
64 |
|
65 | docker_build:
|
66 | docker build -t globobackstage/functions .
|
67 |
|
68 | docker_push:
|
69 | docker push globobackstage/functions
|