diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index f45c0945..0e3a68b8 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -18,7 +18,6 @@ jobs: package: runs-on: ubuntu-latest steps: - - uses: sourcemeta/jsonschema@v12.6.0 - uses: actions/checkout@v4 - run: make lint - run: make test diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f557c918..4ff27840 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,6 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: sourcemeta/jsonschema@v12.6.0 - uses: actions/checkout@v4 - run: make lint - run: make test diff --git a/.gitignore b/.gitignore index 9a8cd445..fc24d70e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store /build /dist +/node_modules diff --git a/Makefile b/Makefile index 566b19c3..fa1454c1 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .DEFAULT_GOAL := all -JSONSCHEMA ?= jsonschema +JSONSCHEMA ?= ./node_modules/@sourcemeta/jsonschema/cli.js JQ ?= jq SHELLCHECK ?= shellcheck TAR ?= tar @@ -15,30 +15,30 @@ NPM ?= npm include generated.mk # TODO: Make `jsonschema fmt` automatically detect test files -all: common test - $(JSONSCHEMA) fmt schemas meta - $(JSONSCHEMA) fmt test --default-dialect "https://json-schema.org/draft/2020-12/schema" +all: common test node_modules + $(NODE) $(JSONSCHEMA) fmt schemas meta + $(NODE) $(JSONSCHEMA) fmt test --default-dialect "https://json-schema.org/draft/2020-12/schema" .PHONY: common -common: $(GENERATED) - $(JSONSCHEMA) metaschema schemas meta - $(JSONSCHEMA) lint schemas meta - $(JSONSCHEMA) validate meta/schemas-root.json schemas - $(JSONSCHEMA) validate meta/schemas.json schemas - $(JSONSCHEMA) validate meta/test.json test +common: $(GENERATED) node_modules + $(NODE) $(JSONSCHEMA) metaschema schemas meta + $(NODE) $(JSONSCHEMA) lint schemas meta + $(NODE) $(JSONSCHEMA) validate meta/schemas-root.json schemas + $(NODE) $(JSONSCHEMA) validate meta/schemas.json schemas + $(NODE) $(JSONSCHEMA) validate meta/test.json test $(SHELLCHECK) scripts/*.sh ./scripts/quality-schemas-tests-mirror.sh ./scripts/quality-templates-xbrl-utr-mirror.sh # TODO: Make `jsonschema fmt` automatically detect test files .PHONY: lint -lint: common - $(JSONSCHEMA) fmt schemas meta --check - $(JSONSCHEMA) fmt test --check --default-dialect "https://json-schema.org/draft/2020-12/schema" +lint: common node_modules + $(NODE) $(JSONSCHEMA) fmt schemas meta --check + $(NODE) $(JSONSCHEMA) fmt test --check --default-dialect "https://json-schema.org/draft/2020-12/schema" .PHONY: test -test: - $(JSONSCHEMA) test ./test +test: node_modules + $(NODE) $(JSONSCHEMA) test ./test $(NODE) npm/cjs.test.js $(NODE) npm/esm.test.mjs @@ -58,3 +58,6 @@ dist: $(MKDIRP) $@/npm $(NPM) version --no-git-tag-version --allow-same-version "$(VERSION)" $(NPM) pack --pack-destination $@/npm + +node_modules: package.json package-lock.json + $(NPM) ci diff --git a/generated.mk b/generated.mk index f0310ea6..cc072428 100644 --- a/generated.mk +++ b/generated.mk @@ -1,10 +1,10 @@ PYTHON ?= python3 define MAKE_SCHEMA -schemas/$1.json: templates/schemas/$1.jq $2.json +schemas/$1.json: templates/schemas/$1.jq $2.json node_modules $(MKDIRP) $$(dir $$@) $(JQ) --from-file $$< $$(word 2,$$^) > $$@ - $(JSONSCHEMA) fmt $$@ + $(NODE) $(JSONSCHEMA) fmt $$@ GENERATED += schemas/$1.json endef diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..c6282a0f --- /dev/null +++ b/package-lock.json @@ -0,0 +1,44 @@ +{ + "name": "@sourcemeta/std", + "version": "0.3.1", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@sourcemeta/std", + "version": "0.3.1", + "license": "UNLICENSED", + "devDependencies": { + "@sourcemeta/jsonschema": "^12.7.1" + }, + "funding": { + "url": "https://github.com/sponsors/sourcemeta" + } + }, + "node_modules/@sourcemeta/jsonschema": { + "version": "12.7.1", + "resolved": "https://registry.npmjs.org/@sourcemeta/jsonschema/-/jsonschema-12.7.1.tgz", + "integrity": "sha512-sFdDTeLMPX1L1ZHQF9lltBzTYWRi2KI4l+KEA+vlThjObc7Y41JWbzacQzWbiOyG6rBufvXJ3dUjGVoeO1Ux6w==", + "cpu": [ + "x64", + "arm64" + ], + "dev": true, + "license": "AGPL-3.0", + "os": [ + "darwin", + "linux", + "win32" + ], + "bin": { + "jsonschema": "cli.js" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sourcemeta" + } + } + } +} diff --git a/package.json b/package.json index 77e8a5aa..60990355 100644 --- a/package.json +++ b/package.json @@ -49,5 +49,8 @@ "publishConfig": { "provenance": true, "access": "public" + }, + "devDependencies": { + "@sourcemeta/jsonschema": "^12.7.1" } }