diff --git a/Makefile b/Makefile index 39d67645..3384e17e 100644 --- a/Makefile +++ b/Makefile @@ -17,15 +17,19 @@ common: $(GENERATED) node_modules $(TIME) $(NODE) $(JSONSCHEMA) lint schemas $(SHELLCHECK) scripts/*.sh ./scripts/quality-schemas-tests-mirror.sh - ./scripts/quality-templates-xbrl-utr-mirror.sh + JQ="$(JQ)" ./scripts/quality-templates-xbrl-utr-mirror.sh .PHONY: lint lint: common node_modules $(TIME) $(NODE) $(JSONSCHEMA) fmt schemas rules test --check .PHONY: test -test: node_modules +test: common node_modules $(TIME) $(NODE) $(JSONSCHEMA) test ./test +.PHONY: clean +clean: + rm -rf build + node_modules: package.json package-lock.json $(NPM) ci diff --git a/generated.mk b/generated.mk index 9ccedda2..b4f41c1f 100644 --- a/generated.mk +++ b/generated.mk @@ -3,7 +3,7 @@ MKDIRP ?= mkdir -p JQ ?= jq define MAKE_SCHEMA -schemas/$1.json: templates/schemas/$1.jq $2.json node_modules +schemas/$1.json: templates/schemas/$1.jq $2.json | node_modules $(MKDIRP) $$(dir $$@) $(JQ) --from-file $$< $$(word 2,$$^) > $$@ $(NODE) $(JSONSCHEMA) fmt $$@ @@ -11,7 +11,7 @@ GENERATED += schemas/$1.json endef define MAKE_SCHEMA_UTR -schemas/$1.json: templates/schemas/$1.jq $2.json templates/data/xbrl/utr-unit-iris.json node_modules +schemas/$1.json: templates/schemas/$1.jq $2.json templates/data/xbrl/utr-unit-iris.json | node_modules $(MKDIRP) $$(dir $$@) $(JQ) --from-file $$< --slurpfile unit_iris $$(word 3,$$^) $$(word 2,$$^) > $$@ $(NODE) $(JSONSCHEMA) fmt $$@ diff --git a/scripts/quality-templates-xbrl-utr-mirror.sh b/scripts/quality-templates-xbrl-utr-mirror.sh index 0285270e..b5a7eed3 100755 --- a/scripts/quality-templates-xbrl-utr-mirror.sh +++ b/scripts/quality-templates-xbrl-utr-mirror.sh @@ -28,7 +28,7 @@ fi # Extract all unique itemTypes from the data and convert to kebab-case # Store them in the temp file first, then validate -jq -r '.["{http://www.xbrl.org/2009/utr}utr"]["{http://www.xbrl.org/2009/utr}units"]["{http://www.xbrl.org/2009/utr}unit"][] | .["{http://www.xbrl.org/2009/utr}itemType"]' "$UTR_DATA" | sort -u > "$TMP/item_types.txt" +"${JQ:-jq}" -r '.["{http://www.xbrl.org/2009/utr}utr"]["{http://www.xbrl.org/2009/utr}units"]["{http://www.xbrl.org/2009/utr}unit"][] | .["{http://www.xbrl.org/2009/utr}itemType"]' "$UTR_DATA" | sort -u > "$TMP/item_types.txt" while IFS= read -r item_type do