Skip to content

Commit 375146b

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. The tool is used to validate the project's npm package.json configuration file. In general, it is preferable (and for some schemas even mandatory) to use the latest version 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]. The package.json schema has now been updated to use the "Draft-07" schema specification. So the code for using [email protected] is removed from the task, and it will now instead use the standard project level version of ajv-cli.
1 parent d46e207 commit 375146b

File tree

1 file changed

+19
-31
lines changed

1 file changed

+19
-31
lines changed

Taskfile.yml

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ vars:
2828
|| \
2929
echo '"ERROR: Unable to discover Go packages"' \
3030
)
31-
# Last version of ajv-cli with support for the JSON schema "Draft 4" specification
32-
SCHEMA_DRAFT_4_AJV_CLI_VERSION: 3.3.0
3331
# build vars
3432
COMMIT:
3533
sh: |
@@ -508,6 +506,8 @@ tasks:
508506
Validate npm configuration files against their JSON schema.
509507
Environment variable parameters:
510508
- PROJECT_PATH: Path of the npm-managed project (default: {{.DEFAULT_NPM_PROJECT_PATH}}).
509+
deps:
510+
- task: npm:install-deps
511511
vars:
512512
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/package.json
513513
SCHEMA_URL: https://json.schemastore.org/package.json
@@ -551,10 +551,6 @@ tasks:
551551
sh: task utility:mktemp-file TEMPLATE="stylelintrc-schema-XXXXXXXXXX.json"
552552
INSTANCE_PATH: >-
553553
{{default .DEFAULT_NPM_PROJECT_PATH .PROJECT_PATH}}/package.json
554-
PROJECT_FOLDER:
555-
sh: pwd
556-
WORKING_FOLDER:
557-
sh: task utility:mktemp-folder TEMPLATE="dependabot-validate-XXXXXXXXXX"
558554
cmds:
559555
- wget --quiet --output-document="{{.SCHEMA_PATH}}" {{.SCHEMA_URL}}
560556
- wget --quiet --output-document="{{.AVA_SCHEMA_PATH}}" {{.AVA_SCHEMA_URL}}
@@ -567,20 +563,23 @@ tasks:
567563
- wget --quiet --output-document="{{.SEMANTIC_RELEASE_SCHEMA_PATH}}" {{.SEMANTIC_RELEASE_SCHEMA_URL}}
568564
- wget --quiet --output-document="{{.STYLELINTRC_SCHEMA_PATH}}" {{.STYLELINTRC_SCHEMA_URL}}
569565
- |
570-
cd "{{.WORKING_FOLDER}}" # Workaround for https://github.com/npm/cli/issues/3210
571-
npx ajv-cli@{{.SCHEMA_DRAFT_4_AJV_CLI_VERSION}} validate \
572-
--all-errors \
573-
-s "{{.SCHEMA_PATH}}" \
574-
-r "{{.AVA_SCHEMA_PATH}}" \
575-
-r "{{.BASE_SCHEMA_PATH}}" \
576-
-r "{{.ESLINTRC_SCHEMA_PATH}}" \
577-
-r "{{.JSCPD_SCHEMA_PATH}}" \
578-
-r "{{.NPM_BADGES_SCHEMA_PATH}}" \
579-
-r "{{.PARTIAL_ESLINT_PLUGINS_PATH}}" \
580-
-r "{{.PRETTIERRC_SCHEMA_PATH}}" \
581-
-r "{{.SEMANTIC_RELEASE_SCHEMA_PATH}}" \
582-
-r "{{.STYLELINTRC_SCHEMA_PATH}}" \
583-
-d "{{.PROJECT_FOLDER}}/{{.INSTANCE_PATH}}"
566+
npx \
567+
--package=ajv-cli \
568+
--package=ajv-formats \
569+
ajv validate \
570+
--all-errors \
571+
--strict=false \
572+
-s "{{.SCHEMA_PATH}}" \
573+
-r "{{.AVA_SCHEMA_PATH}}" \
574+
-r "{{.BASE_SCHEMA_PATH}}" \
575+
-r "{{.ESLINTRC_SCHEMA_PATH}}" \
576+
-r "{{.JSCPD_SCHEMA_PATH}}" \
577+
-r "{{.NPM_BADGES_SCHEMA_PATH}}" \
578+
-r "{{.PARTIAL_ESLINT_PLUGINS_PATH}}" \
579+
-r "{{.PRETTIERRC_SCHEMA_PATH}}" \
580+
-r "{{.SEMANTIC_RELEASE_SCHEMA_PATH}}" \
581+
-r "{{.STYLELINTRC_SCHEMA_PATH}}" \
582+
-d "{{.INSTANCE_PATH}}"
584583
585584
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
586585
poetry:install:
@@ -744,17 +743,6 @@ tasks:
744743
vars:
745744
RAW_PATH: "{{.RAW_PATH}}"
746745

747-
# Make a temporary folder named according to the passed TEMPLATE variable and print the path passed to stdout
748-
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/windows-task/Taskfile.yml
749-
utility:mktemp-folder:
750-
vars:
751-
RAW_PATH:
752-
sh: mktemp --directory --tmpdir "{{.TEMPLATE}}"
753-
cmds:
754-
- task: utility:normalize-path
755-
vars:
756-
RAW_PATH: "{{.RAW_PATH}}"
757-
758746
# Print a normalized version of the path to stdout.
759747
# Environment variable parameters:
760748
# - RAW_PATH: the path to be normalized.

0 commit comments

Comments
 (0)