Skip to content

Commit ce177ae

Browse files
committed
Install referenced schema in "npm:validate" task
The "npm:validate" task validates the repository's `package.json` npm manifest file against its JSON schema to catch any problems with its data format. In order to avoid duplication of content, JSON schemas may reference other schemas via the `$ref` keyword. The `package.json` schema was recently updated to share resources with the "base" configuration schema, which caused the validation to start failing: schema /tmp/package-json-schema-m3x8Uu4NED.json is invalid error: can't resolve reference https://json.schemastore.org/base.json#/definitions/license from id https://json.schemastore.org/package.json# The solution is to configure the task to download that schema as well and also to provide its path to the avj-cli validator via a `-r` flag.
1 parent adc67c4 commit ce177ae

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Taskfile.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ tasks:
188188
AVA_SCHEMA_URL: https://json.schemastore.org/ava.json
189189
AVA_SCHEMA_PATH:
190190
sh: task utility:mktemp-file TEMPLATE="ava-schema-XXXXXXXXXX.json"
191+
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/base.json
192+
BASE_SCHEMA_URL: https://json.schemastore.org/base.json
193+
BASE_SCHEMA_PATH:
194+
sh: task utility:mktemp-file TEMPLATE="base-schema-XXXXXXXXXX.json"
191195
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/eslintrc.json
192196
ESLINTRC_SCHEMA_URL: https://json.schemastore.org/eslintrc.json
193197
ESLINTRC_SCHEMA_PATH:
@@ -224,6 +228,7 @@ tasks:
224228
cmds:
225229
- wget --quiet --output-document="{{.SCHEMA_PATH}}" {{.SCHEMA_URL}}
226230
- wget --quiet --output-document="{{.AVA_SCHEMA_PATH}}" {{.AVA_SCHEMA_URL}}
231+
- wget --quiet --output-document="{{.BASE_SCHEMA_PATH}}" {{.BASE_SCHEMA_URL}}
227232
- wget --quiet --output-document="{{.ESLINTRC_SCHEMA_PATH}}" {{.ESLINTRC_SCHEMA_URL}}
228233
- wget --quiet --output-document="{{.JSCPD_SCHEMA_PATH}}" {{.JSCPD_SCHEMA_URL}}
229234
- wget --quiet --output-document="{{.NPM_BADGES_SCHEMA_PATH}}" {{.NPM_BADGES_SCHEMA_URL}}
@@ -237,6 +242,7 @@ tasks:
237242
--all-errors \
238243
-s "{{.SCHEMA_PATH}}" \
239244
-r "{{.AVA_SCHEMA_PATH}}" \
245+
-r "{{.BASE_SCHEMA_PATH}}" \
240246
-r "{{.ESLINTRC_SCHEMA_PATH}}" \
241247
-r "{{.JSCPD_SCHEMA_PATH}}" \
242248
-r "{{.NPM_BADGES_SCHEMA_PATH}}" \

0 commit comments

Comments
 (0)