-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
60 lines (49 loc) · 1.99 KB
/
Copy pathMakefile
File metadata and controls
60 lines (49 loc) · 1.99 KB
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
USER_SCRIPTS := $(shell find . -maxdepth 1 -name '*.js'; find scripts -name '*.user.js' 2>/dev/null)
.PHONY: help list changed-versions all-versions patch minor major test check install-hooks
install-hooks:
git config core.hooksPath .githooks
help:
@printf '%s\n' 'Available targets:'
@printf ' %-10s %s\n' 'help' 'Show this help.'
@printf ' %-10s %s\n' 'list' 'Show userscript versions.'
@printf ' %-16s %s\n' 'changed-versions' 'Increment patch versions for changed userscripts.'
@printf ' %-16s %s\n' 'all-versions' 'Increment patch versions for all userscripts.'
@printf ' %-10s %s\n' 'patch' 'Increment patch versions.'
@printf ' %-10s %s\n' 'minor' 'Increment minor versions.'
@printf ' %-10s %s\n' 'major' 'Increment major versions.'
@printf ' %-10s %s\n' 'test' 'Run userscript checks.'
@printf ' %-10s %s\n' 'check' 'Run tests and JavaScript syntax checks.'
list:
@printf '%s\n' 'Current versions:'
@for file in $(USER_SCRIPTS); do \
version=$$(awk '/\/\/ @version/ {print $$3; exit}' "$$file"); \
printf ' %s: %s\n' "$$file" "$${version:-none}"; \
done
changed-versions:
node scripts/bump-userscript-versions.mjs --changed
all-versions:
node scripts/bump-userscript-versions.mjs --all
patch:
@for file in $(USER_SCRIPTS); do \
awk '/\/\/ @version/ {split($$3, v, "."); $$3 = v[1] "." v[2] "." (v[3] + 1)} 1' "$$file" > "$$file.tmp" && mv "$$file.tmp" "$$file"; \
done
@$(MAKE) list
minor:
@for file in $(USER_SCRIPTS); do \
awk '/\/\/ @version/ {split($$3, v, "."); $$3 = v[1] "." (v[2] + 1) ".0"} 1' "$$file" > "$$file.tmp" && mv "$$file.tmp" "$$file"; \
done
@$(MAKE) list
major:
@for file in $(USER_SCRIPTS); do \
awk '/\/\/ @version/ {split($$3, v, "."); $$3 = (v[1] + 1) ".0.0"} 1' "$$file" > "$$file.tmp" && mv "$$file.tmp" "$$file"; \
done
@$(MAKE) list
test:
npm test
check:
npm test
node --check scripts/bump-userscript-versions.mjs
node --check scripts/check-userscript-version-bumps.mjs
@for file in $(USER_SCRIPTS); do \
node --check "$$file"; \
done