-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile-frontend
136 lines (109 loc) · 4.24 KB
/
Makefile-frontend
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
FRONTEND_ROOT = src
FRONTEND_DEPENDENCIES_MARK = node_modules/.dependencies
FRONTEND_PUBLISHED = www/built
FRONTEND_BUILT_MARK = $(FRONTEND_PUBLISHED)/.built
FRONTEND_BUILD_TMP = legacy/built
frontend: frontend-dump frontend-dependencies frontend-test frontend-lint ok
frontend-full: clear clean-files dc-build dc-up frontend-dump frontend-dependencies frontend-lint frontend-build frontend-test ok
.PHONY: frontend-clean
clean: frontend-clean
frontend-clean: frontend-clean-files
rm -fr "$(ROOT)/node_modules"
rm -fr "$(ROOT)/$(FRONTEND_DEPENDENCIES_MARK)"
@echo "!! Removed dependencies, so husky (commit) will not work anymore. Please make dependencies-node to enable it again"
.PHONY: frontend-clean-files
clean-files: frontend-clean-files
frontend-clean-files:
rm -fr "$(ROOT)/$(TMP)/frontend"
rm -f "$(ROOT)/www/index.html"
rm -fr "$(ROOT)/$(FRONTEND_PUBLISHED)"
rm -fr "$(ROOT)/$(FRONTEND_BUILD_TMP)"
rm -fr "$(FRONTEND_BUILT_MARK)"
.PHONY: frontend-dump
dump: frontend-dump
frontend-dump:
@echo ""
@echo "****************"
@echo "*** Frontend ***"
@echo ""
@echo "FRONTEND_ROOT: $(FRONTEND_ROOT)"
@echo "FRONTEND_DEPENDENCIES_MARK: $(FRONTEND_DEPENDENCIES_MARK)"
@echo "FRONTEND_PUBLISHED: $(FRONTEND_PUBLISHED)"
@echo "FRONTEND_BUILT_MARK: $(FRONTEND_BUILT_MARK)"
@echo "FRONTEND_BUILD_TMP: $(FRONTEND_BUILD_TMP)"
@echo "NodeJS: $(shell node --version 2>&1 )"
@echo "NPM: $(shell npm --version 2>&1 )"
.PHONY: frontend-dependencies
dependencies: frontend-dependencies
frontend-dependencies: $(FRONTEND_DEPENDENCIES_MARK)
$(FRONTEND_DEPENDENCIES_MARK): package-lock.json
npm ci
@mkdir -p "$(dir $@)"
@touch "$@"
package-lock.json: package.json
npm install --package-lock-only --ignore-scripts
@touch "$@"
.PHONY: frontend-lint
lint: frontend-lint
frontend-lint: frontend-build frontend-lint-es frontend-lint-css frontend-lint-html frontend-lint-unused-exports
.PHONY: frontend-lint-es
frontend-lint-es: $(FRONTEND_DEPENDENCIES_MARK)
node_modules/.bin/eslint .
.PHONY: frontend-lint-css
frontend-lint-css: $(FRONTEND_DEPENDENCIES_MARK)
node_modules/.bin/stylelint src/**/*.css legacy/**/*.css
.PHONY: frontend-lint-html
frontend-lint-html: $(FRONTEND_DEPENDENCIES_MARK)
node_modules/.bin/htmlhint src/**/*.html legacy/**/*.html tests/**/*.html --format=compact
.PHONY: frontend-lint-unused-exports
frontend-lint-unused-exports: $(FRONTEND_DEPENDENCIES_MARK)
# Todo: enforce ts-unused-exports analysis
node_modules/.bin/ts-unused-exports ./tsconfig.json
.PHONY: frontend-build
build: frontend-build
frontend-build: $(FRONTEND_BUILT_MARK)
$(FRONTEND_BUILT_MARK): \
$(FRONTEND_PUBLISHED)/frontend/ng1x.html \
$(FRONTEND_PUBLISHED)/.htaccess
@mkdir -p "$(dir $@)"
@touch "$@"
$(FRONTEND_PUBLISHED)/frontend/ng1x.html: \
$(FRONTEND_DEPENDENCIES_MARK) \
$(shell find src/ ) \
$(shell find legacy/app-old/ ) \
$(FRONTEND_BUILD_TMP)/axios.js \
$(FRONTEND_BUILD_TMP)/platform.js \
webpack.config.js \
tsconfig.json
@mkdir -p "$(dir $@)"
# TODO: should not be here... (need rework of getHTMLNameOfClass)
CRYPTOMEDIC_DEV=true node_modules/.bin/webpack
@touch "$@"
dev: frontend-dev
.PHONY: frontend-dev
frontend-dev: \
$(FRONTEND_PUBLISHED)/.htaccess
@mkdir -p "$(dir $@)"
CRYPTOMEDIC_DEV=true node_modules/.bin/webpack --watch
@touch "$@"
$(FRONTEND_PUBLISHED)/.htaccess: src/build.htaccess
@mkdir -p "$(dir $@)"
cp "$<" "$@"
@touch "$@"
# Dependencies are used in the build !
$(FRONTEND_BUILD_TMP)/axios.js: node_modules/axios/dist/axios.js $(FRONTEND_DEPENDENCIES_MARK)
node_modules/.bin/babel --out-file="$@" --plugins=transform-commonjs "$<"
# Dependencies are used in the build !
$(FRONTEND_BUILD_TMP)/platform.js: node_modules/platform/platform.js $(FRONTEND_DEPENDENCIES_MARK)
node_modules/.bin/babel --out-file="$@" --plugins=transform-commonjs "$<"
.PHONY: frontend-test
test: frontend-test
frontend-test: $(FRONTEND_DEPENDENCIES_MARK)
#
# Check reporters: https://nodejs.org/api/test.html#test-reporters
# --experimental-test-coverage
node --import tsx/esm --test "src/**/*.test.ts" "src/**/*.test.tsx"
.PHONY: frontend-github
github: frontend-github
frontend-github:
$(call rehydrate,$(FRONTEND_DEPENDENCIES_MARK),package-lock.json)