render svg diagrams using d2
This commit is contained in:
parent
7cfded56a8
commit
ce00da10a5
4 changed files with 102 additions and 37 deletions
59
Makefile
Normal file
59
Makefile
Normal file
|
@ -0,0 +1,59 @@
|
|||
DENO := deno
|
||||
COV := $(DENO) coverage cov_profile
|
||||
FMT := $(DENO) fmt *.ts examples/*.ts
|
||||
NPM_PUB := npm publish
|
||||
|
||||
D2 := nix run git+https://git.pleshevski.ru/mynix/tools\\\#d2_unstable --
|
||||
DIAGRAMS := \
|
||||
turnstile
|
||||
|
||||
turnstile_theme_args := --layout elk --theme 101
|
||||
|
||||
dev: fmt tests cov
|
||||
|
||||
ci: fmt-check tests-cov
|
||||
|
||||
tests: clean
|
||||
$(DENO) test --coverage=cov_profile *.test.ts
|
||||
|
||||
tests-cov: tests
|
||||
$(COV) --lcov > cov_profile/cov.lcov
|
||||
|
||||
cov:
|
||||
$(COV)
|
||||
|
||||
fmt:
|
||||
$(FMT)
|
||||
|
||||
fmt-check:
|
||||
$(FMT) --check
|
||||
|
||||
build: clean | $(DIAGRAMS)
|
||||
tsc && tsc -p tsconfig.cjs.json
|
||||
|
||||
clean:
|
||||
@echo clean test coverage data
|
||||
rm -rf cov_profile
|
||||
@echo clean build target
|
||||
rm -rf dist
|
||||
@echo clean diagrams
|
||||
rm -rf assets/*.svg
|
||||
|
||||
define d2rule
|
||||
d2_$(1)_args := $(D2) $$($(1)_theme_args) assets/$(1).d2 assets/$(1).svg
|
||||
|
||||
$(1): ; $$($(1)_args)
|
||||
$(1)-w: ; $$($(1)_args) -w
|
||||
endef
|
||||
|
||||
$(foreach d2name,$(DIAGRAMS),$(eval $(call d2rule,$(d2name))))
|
||||
|
||||
dry-pub:
|
||||
$(NPM_PUB) --dry-run
|
||||
|
||||
pub:
|
||||
$(NPM_PUB)
|
||||
|
||||
help:
|
||||
cat Makefile
|
||||
|
6
assets/turnstile.d2
Normal file
6
assets/turnstile.d2
Normal file
|
@ -0,0 +1,6 @@
|
|||
direction: right
|
||||
|
||||
Turnstile: {
|
||||
Locked -> Unlocked: coin
|
||||
Unlocked -> Locked: push
|
||||
}
|
37
assets/turnstile.svg
Normal file
37
assets/turnstile.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 468 KiB |
37
makefile
37
makefile
|
@ -1,37 +0,0 @@
|
|||
DENO := deno
|
||||
COV := $(DENO) coverage cov_profile
|
||||
FMT := $(DENO) fmt *.ts examples/*.ts
|
||||
NPM_PUB := npm publish
|
||||
|
||||
dev: fmt tests cov
|
||||
|
||||
ci: fmt-check tests-cov
|
||||
|
||||
tests: clean
|
||||
$(DENO) test --coverage=cov_profile *.test.ts
|
||||
|
||||
tests-cov: tests
|
||||
$(COV) --lcov > cov_profile/cov.lcov
|
||||
|
||||
cov:
|
||||
$(COV)
|
||||
|
||||
fmt:
|
||||
$(FMT)
|
||||
|
||||
fmt-check:
|
||||
$(FMT) --check
|
||||
|
||||
clean:
|
||||
rm -rf cov_profile dist
|
||||
|
||||
build: clean
|
||||
tsc && tsc -p tsconfig.cjs.json
|
||||
|
||||
dry-pub:
|
||||
$(NPM_PUB) --dry-run
|
||||
|
||||
pub:
|
||||
$(NPM_PUB)
|
||||
|
||||
|
Loading…
Reference in a new issue