-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
110 lines (87 loc) · 2.6 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
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
TMP_DIR = ./tmp
DEFAULT_OUTPUT_DIR = ./dist
OUTPUT_DIR = $(DEFAULT_OUTPUT_DIR)
PACKAGE_DIR = ./build
NODE_BIN = ./node_modules/.bin
start:
$(MAKE) -j2 start-docs start-assets
start-docs:
bundle exec jekyll serve --watch
start-assets: build-fonts build-images
npm run watch:docs
validate-gemfile-lock: Gemfile Gemfile.lock
@echo "Validating Gemfile.lock..."
@bundle check
@git diff-index --quiet HEAD Gemfile.lock || (echo "Error: There are uncommitted changes after running 'bundle install'"; exit 1)
validate-package-lock: package.json package-lock.json
@echo "Validating package-lock.json..."
@npm install --ignore-scripts
@(! git diff --name-only | grep package-lock.json) || (echo "Error: There are uncommitted changes after running 'npm install'"; exit 1)
validate-lockfiles: validate-gemfile-lock validate-package-lock
typecheck:
npm run typecheck
optimize-svg:
$(NODE_BIN)/svgo --config svgo.config.js --recursive --folder src/img
optimize-assets: optimize-svg
lint-optimized-assets: optimize-assets
(! git diff --name-only | grep "\.svg$$") || (echo "Error: Optimize assets using 'make optimize-assets'"; exit 1)
lint: build-package validate-lockfiles lint-optimized-assets typecheck
npm run lint
build: build-docs build-assets build-package
build-docs:
JEKYLL_ENV=production RUBY_YJIT_ENABLE=1 bundle exec jekyll build
build-assets: build-sass-and-js build-fonts build-images build-sass-packages
build-package:
npm run build:pkg
build-sass-and-js:
npm run build:docs
ifneq ($(OUTPUT_DIR),$(DEFAULT_OUTPUT_DIR))
mkdir -p $(OUTPUT_DIR)/assets
mv $(DEFAULT_OUTPUT_DIR)/assets/js $(DEFAULT_OUTPUT_DIR)/assets/css $(OUTPUT_DIR)/assets
endif
build-sass-packages:
mkdir -p packages
cp -r node_modules/@uswds/uswds/packages/* packages
cp -r src/scss/packages/* packages
build-fonts:
mkdir -p $(OUTPUT_DIR)/assets/fonts
cp -r node_modules/@uswds/uswds/dist/fonts $(OUTPUT_DIR)/assets
build-images:
mkdir -p $(OUTPUT_DIR)/assets/img
cp -r node_modules/@uswds/uswds/dist/img $(OUTPUT_DIR)/assets
cp -r src/img $(OUTPUT_DIR)/assets
create-snapshots:
node scripts/snapshot.js
test:
ifdef ONLY_VISUAL_REGRESSION_TEST
node --test test/screenshot.test.js
else
make build
node --test "test"
endif
clean:
rm -rf $(OUTPUT_DIR)
rm -rf $(TMP_DIR)
rm -rf $(PACKAGE_DIR)
.PHONY: \
start \
start-docs \
start-assets \
validate-gemfile-lock \
validate-package-lock \
validate-lockfiles \
typecheck \
optimize-svg \
optimize-assets \
lint-optimized-assets \
lint \
build \
build-docs \
build-assets \
build-package \
build-sass-and-js \
build-sass-packages \
build-fonts \
build-images \
test \
clean