Skip to content

Commit 64dbf93

Browse files
committed
Use project version of ajv-cli in npm:validate task
The ajv-cli command line tool is used for validating data files against their JSON schema. In general, it is preferable, and for some schemas even mandatory, to use the modern versions of ajv-cli. However, support for the "Draft-04" schema specification was dropped in ajv-cli version 4.0.0. So when working with JSON schemas that specify that draft, it is necessary to use ajv-cli 3.3.0, the last compatible version. Previously, the package.json schema specified the "Draft-04" specification. For this reason, the `npm:validate` task was configured to use [email protected] in that specific task. The package.json schema has now been updated to use "Draft-07". So the code for using [email protected] is removed from the task, and the standard project level version of ajv-cli will now be used by this task.
1 parent 5f55851 commit 64dbf93

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

Taskfile.yml

+19-16
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ vars:
3333
DEFAULT_GO_PACKAGES:
3434
sh: |
3535
echo $(cd {{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}} && go list ./... | tr '\n' ' ' || echo '"ERROR: Unable to discover Go packages"')
36-
# Last version of ajv-cli with support for the JSON schema "Draft 4" specification
37-
SCHEMA_DRAFT_4_AJV_CLI_VERSION: 3.3.0
3836
3937
tasks:
4038
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-workflows-task/Taskfile.yml
@@ -256,6 +254,8 @@ tasks:
256254
Validate npm configuration files against their JSON schema.
257255
Environment variable parameters:
258256
PROJECT_PATH: Path of the npm-managed project (default: {{.DEFAULT_NPM_PROJECT_PATH}}).
257+
deps:
258+
- task: npm:install-deps
259259
vars:
260260
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/package.json
261261
SCHEMA_URL: https://json.schemastore.org/package.json
@@ -315,20 +315,23 @@ tasks:
315315
- wget --quiet --output-document="{{.SEMANTIC_RELEASE_SCHEMA_PATH}}" {{.SEMANTIC_RELEASE_SCHEMA_URL}}
316316
- wget --quiet --output-document="{{.STYLELINTRC_SCHEMA_PATH}}" {{.STYLELINTRC_SCHEMA_URL}}
317317
- |
318-
cd "{{.WORKING_FOLDER}}" # Workaround for https://github.com/npm/cli/issues/3210
319-
npx ajv-cli@{{.SCHEMA_DRAFT_4_AJV_CLI_VERSION}} validate \
320-
--all-errors \
321-
-s "{{.SCHEMA_PATH}}" \
322-
-r "{{.AVA_SCHEMA_PATH}}" \
323-
-r "{{.BASE_SCHEMA_PATH}}" \
324-
-r "{{.ESLINTRC_SCHEMA_PATH}}" \
325-
-r "{{.JSCPD_SCHEMA_PATH}}" \
326-
-r "{{.NPM_BADGES_SCHEMA_PATH}}" \
327-
-r "{{.PARTIAL_ESLINT_PLUGINS_PATH}}" \
328-
-r "{{.PRETTIERRC_SCHEMA_PATH}}" \
329-
-r "{{.SEMANTIC_RELEASE_SCHEMA_PATH}}" \
330-
-r "{{.STYLELINTRC_SCHEMA_PATH}}" \
331-
-d "{{.PROJECT_FOLDER}}/{{.INSTANCE_PATH}}"
318+
npx \
319+
--package=ajv-cli \
320+
--package=ajv-formats \
321+
ajv validate \
322+
--all-errors \
323+
--strict=false \
324+
-s "{{.SCHEMA_PATH}}" \
325+
-r "{{.AVA_SCHEMA_PATH}}" \
326+
-r "{{.BASE_SCHEMA_PATH}}" \
327+
-r "{{.ESLINTRC_SCHEMA_PATH}}" \
328+
-r "{{.JSCPD_SCHEMA_PATH}}" \
329+
-r "{{.NPM_BADGES_SCHEMA_PATH}}" \
330+
-r "{{.PARTIAL_ESLINT_PLUGINS_PATH}}" \
331+
-r "{{.PRETTIERRC_SCHEMA_PATH}}" \
332+
-r "{{.SEMANTIC_RELEASE_SCHEMA_PATH}}" \
333+
-r "{{.STYLELINTRC_SCHEMA_PATH}}" \
334+
-d "{{.INSTANCE_PATH}}"
332335
333336
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
334337
poetry:install-deps:

0 commit comments

Comments
 (0)