aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 4ec39e85633feef482c3478b6f055e82fde6ec12 (plain)
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
137
138
139
140
141
142
143
CODECEPT  = composer/bin/codecept
CATALOGS  = locale/en/LC_MESSAGES/studip.mo locale/en/LC_MESSAGES/js-resources.json
RESOURCES = $(shell find resources -type f)

PHP_SOURCES = $(shell find app config lib public templates -name '*.php' \( ! -path 'public/plugins_packages/*' -o -path 'public/plugins_packages/core/*' \))
VUE_SOURCES = $(shell find resources -name '*.js' -o -name '*.vue')

STUDIP_UI_PATH = packages/studip-ui
UI_KIT_SOURCES = $(shell find $(STUDIP_UI_PATH)/src -type f)

# build all needed files
build: composer webpack-prod

# remove all generated files
clean: clean-composer clean-npm clean-webpack clean-doc

composer: composer/composer/installed.json

composer-dev: $(CODECEPT)

composer/composer/installed.json: composer.json composer.lock
	composer install --no-dev
	@touch $@

$(CODECEPT): composer.json composer.lock
	composer install
	@touch $@

clean-composer:
	rm -rf composer

npm: node_modules/.package-lock.json

node_modules/.package-lock.json: package.json package-lock.json
	npm install --no-save --no-audit --no-fund

clean-npm:
	rm -rf node_modules

webpack-dev: .webpack.dev

webpack-prod: .webpack.prod

webpack-watch: npm
	npm run webpack-watch

.webpack.dev: node_modules/.package-lock.json $(RESOURCES) $(UI_KIT_SOURCES)
	@rm -f .webpack.prod
	npm run webpack-dev
	@touch $@

.webpack.prod: node_modules/.package-lock.json $(RESOURCES) $(UI_KIT_SOURCES)
	@rm -f .webpack.dev
	npm run webpack-prod
	@touch $@

clean-webpack:
	@rm -f .webpack.dev .webpack.prod
	rm -rf public/assets/javascripts/*.js
	rm -rf public/assets/javascripts/*.js.map
	rm -rf public/assets/stylesheets/*.css
	rm -rf public/assets/stylesheets/*.css.map
	rm -rf $(STUDIP_UI_PATH)/dist/*

doc: force_update
	doxygen Doxyfile

clean-doc:
	rm -rf doc/html

test: test-unit

test-functional: $(CODECEPT)
	$(CODECEPT) run functional

test-jsonapi: $(CODECEPT)
	$(CODECEPT) run jsonapi

test-e2e: npm
	npx playwright test

test-unit: $(CODECEPT)
	$(CODECEPT) run unit

catalogs: npm $(CATALOGS)

clean-icons:
	find public/assets/images/icons -type f -not -path '*blue*' -delete

optimize-icons: npm
	find public/assets/images/icons/blue -type f | xargs -P0 npx svgo -q --config=config/svgo.config.js

icons: optimize-icons
	find public/assets/images/icons/blue -type f -print0 | xargs -0 -n1 -I{} echo 'sed "s/#28497c/#000000/g" {} > {}' | sed 's#icons/blue#icons/black#2' | sh
	find public/assets/images/icons/blue -type f -print0 | xargs -0 -n1 -I{} echo 'sed "s/#28497c/#00962d/g" {} > {}' | sed 's#icons/blue#icons/green#2' | sh
	find public/assets/images/icons/blue -type f -print0 | xargs -0 -n1 -I{} echo 'sed "s/#28497c/#6e6e6e/g" {} > {}' | sed 's#icons/blue#icons/grey#2' | sh
	find public/assets/images/icons/blue -type f -print0 | xargs -0 -n1 -I{} echo 'sed "s/#28497c/#cb1800/g" {} > {}' | sed 's#icons/blue#icons/red#2' | sh
	find public/assets/images/icons/blue -type f -print0 | xargs -0 -n1 -I{} echo 'sed "s/#28497c/#ffffff/g" {} > {}' | sed 's#icons/blue#icons/white#2' | sh
	find public/assets/images/icons/blue -type f -print0 | xargs -0 -n1 -I{} echo 'sed "s/#28497c/#ffad00/g" {} > {}' | sed 's#icons/blue#icons/yellow#2' | sh

# default rules for gettext handling
js-%.pot: $(VUE_SOURCES)
	npx gettext-extract --attribute v-translate --output $@ $(VUE_SOURCES)

js-%.po: js-%.pot
	msgmerge -qU -C $(dir $@)studip.po $@ $<

js-%.json: js-%.po
	npx gettext-compile --output $@ $<
	sed -i~ 's/^{[^{]*//;s/}$$//' $@

%.pot: $(PHP_SOURCES)
	xgettext -o $@ --from-code=UTF-8 $(PHP_SOURCES)

%.po: %.pot
	msgmerge -qU $@ $<

%.mo: %.po
	msgfmt -o $@ $<

# --- UI-Kit NPM Install ---

# Führt npm install im UI-Kit-Ordner aus
npm-ui:
	@echo "--- Installing studip-ui NPM dependencies ---"
	npm install --prefix $(STUDIP_UI_PATH)

# --- UI-Kit Targets ---

# Ruft das Build-Skript des UI-Kits auf (build: lint, vite build, icons)
build-ui: npm-ui
	@echo "--- Building studip-ui package ---"
	npm run --prefix $(STUDIP_UI_PATH) build

# --- Storybook Target ---

# Startet den Storybook-Dev-Server für die isolierte Entwicklung
storybook: build-ui
	@echo "--- Starting Storybook Development Server ---"
	npm run --prefix $(STUDIP_UI_PATH) storybook

# dummy target to force update of "doc" target
force_update: