forked from json-schema-faker/json-schema-faker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
82 lines (64 loc) · 1.97 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
76
77
78
79
80
81
82
# current working directory
PWD=$(shell pwd)
# defaults
src := dist
target := gh-pages
message := Release: $(shell date)
# environment vars
PORT ?= 8080
NODE_ENV ?= development
VERSION ?= $(shell cat package.json | jq .version | xargs)
ifneq ($(wildcard .env),)
include .env
endif
# export vars
.EXPORT_ALL_VARIABLES:
# targets
.PHONY: ? deps purge all clean deploy
# utils
define iif
@(($(1) > /dev/null 2>&1) && printf "\r* $(2)\n") || printf "\r* $(3)\n"
endef
# display all targets-with-help in this file
?: Makefile
@awk -F':.*?##' '/^[a-z\\%!:-]+:.*##/{gsub("%","*",$$1);gsub("\\\\",":*",$$1);printf "\033[36m%8s\033[0m %s\n",$$1,$$2}' $<
ci: deps clean
@npm run build -- -ymain
@npm run test:integration
@npm test
ifneq ($(CI),)
@npm run codecov
endif
lib: deps ## Build library output only
@npm run build -- -ymain
dev: deps ## Watch and start development server
@npm run watch
test: deps ## Run tests like if we're in CI ;-)
@npm run test:schema
build: deps ## Build scripts for dist
@npm run build
all: deps ## Build artifact for production envs
@(git worktree remove $(src) --force > /dev/null 2>&1) || true
@git worktree add $(src) $(target)
@cd $(src) && rm -rf *
@cp -r public/* $(src)
@npm run build
clean: ## Remove cache and generated artifacts
@$(call iif,rm -r $(src),Built artifacts were deleted,Artifacts already deleted)
@$(call iif,unlink cache.json,Cache file was deleted,Cache file already deleted)
deploy: ## Push built artifacts to github!
@cd $(src) && rm -rf js/lib lib
@cd $(src) && git add . && git commit -m "$(message)"
@git push origin $(target) -f
deps: ## Check for installed dependencies
@(((ls node_modules | grep .) > /dev/null 2>&1) || npm i) || true
prune: clean ## Remove all from node_modules/*
@printf "\r* Removing all dependencies... "
@rm -rf node_modules/.{bin,cache}
@rm -rf node_modules/*
@echo "OK"
release: deps
ifneq ($(CI),)
@echo '//registry.npmjs.org/:_authToken=$${NODE_AUTH_TOKEN}' > .npmrc
@npm version patch
endif