Skip to content

Commit ce81472

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 ajv-cli@3.3.0. The package.json schema has now been updated to use the "Draft-07" schema specification. So the code for using ajv-cli@3.3.0 is removed from the task, and it will now instead use the standard project level version of ajv-cli.
1 parent e752f27 commit ce81472

File tree

3 files changed

+38
-54
lines changed

3 files changed

+38
-54
lines changed

Taskfile.yml

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ vars:
99
CLANG_FORMAT_GOLDEN_TEST_DATA_FOLDER: "{{.CLANG_FORMAT_TEST_DATA_FOLDER}}/golden"
1010
# See: https://github.com/arduino/arduino-ide/blob/main/arduino-ide-extension/package.json
1111
DEFAULT_CLANG_FORMAT_VERSION: 14.0.0
12-
# Last version of ajv-cli with support for the JSON schema "Draft 4" specification
13-
SCHEMA_DRAFT_4_AJV_CLI_VERSION: 3.3.0
1412

1513
tasks:
1614
check:
@@ -729,6 +727,8 @@ tasks:
729727
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-npm-task/Taskfile.yml
730728
npm:validate:
731729
desc: Validate npm configuration files against their JSON schema
730+
deps:
731+
- task: npm:install-deps
732732
vars:
733733
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/package.json
734734
SCHEMA_URL: https://json.schemastore.org/package.json
@@ -772,10 +772,6 @@ tasks:
772772
sh: task utility:mktemp-file TEMPLATE="stylelintrc-schema-XXXXXXXXXX.json"
773773
INSTANCE_PATH: >-
774774
{{default "." .PROJECT_PATH}}/package.json
775-
PROJECT_FOLDER:
776-
sh: pwd
777-
WORKING_FOLDER:
778-
sh: task utility:mktemp-folder TEMPLATE="dependabot-validate-XXXXXXXXXX"
779775
cmds:
780776
- wget --quiet --output-document="{{.SCHEMA_PATH}}" {{.SCHEMA_URL}}
781777
- wget --quiet --output-document="{{.AVA_SCHEMA_PATH}}" {{.AVA_SCHEMA_URL}}
@@ -788,20 +784,23 @@ tasks:
788784
- wget --quiet --output-document="{{.SEMANTIC_RELEASE_SCHEMA_PATH}}" {{.SEMANTIC_RELEASE_SCHEMA_URL}}
789785
- wget --quiet --output-document="{{.STYLELINTRC_SCHEMA_PATH}}" {{.STYLELINTRC_SCHEMA_URL}}
790786
- |
791-
cd "{{.WORKING_FOLDER}}" # Workaround for https://github.com/npm/cli/issues/3210
792-
npx ajv-cli@{{.SCHEMA_DRAFT_4_AJV_CLI_VERSION}} validate \
793-
--all-errors \
794-
-s "{{.SCHEMA_PATH}}" \
795-
-r "{{.AVA_SCHEMA_PATH}}" \
796-
-r "{{.BASE_SCHEMA_PATH}}" \
797-
-r "{{.ESLINTRC_SCHEMA_PATH}}" \
798-
-r "{{.JSCPD_SCHEMA_PATH}}" \
799-
-r "{{.NPM_BADGES_SCHEMA_PATH}}" \
800-
-r "{{.PARTIAL_ESLINT_PLUGINS_PATH}}" \
801-
-r "{{.PRETTIERRC_SCHEMA_PATH}}" \
802-
-r "{{.SEMANTIC_RELEASE_SCHEMA_PATH}}" \
803-
-r "{{.STYLELINTRC_SCHEMA_PATH}}" \
804-
-d "{{.PROJECT_FOLDER}}/{{.INSTANCE_PATH}}"
787+
npx \
788+
--package=ajv-cli \
789+
--package=ajv-formats \
790+
ajv validate \
791+
--all-errors \
792+
--strict=false \
793+
-s "{{.SCHEMA_PATH}}" \
794+
-r "{{.AVA_SCHEMA_PATH}}" \
795+
-r "{{.BASE_SCHEMA_PATH}}" \
796+
-r "{{.ESLINTRC_SCHEMA_PATH}}" \
797+
-r "{{.JSCPD_SCHEMA_PATH}}" \
798+
-r "{{.NPM_BADGES_SCHEMA_PATH}}" \
799+
-r "{{.PARTIAL_ESLINT_PLUGINS_PATH}}" \
800+
-r "{{.PRETTIERRC_SCHEMA_PATH}}" \
801+
-r "{{.SEMANTIC_RELEASE_SCHEMA_PATH}}" \
802+
-r "{{.STYLELINTRC_SCHEMA_PATH}}" \
803+
-d "{{.INSTANCE_PATH}}"
805804
806805
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
807806
poetry:install-deps:
@@ -907,7 +906,6 @@ tasks:
907906
RAW_PATH: "{{.RAW_PATH}}"
908907

909908
# Make a temporary folder named according to the passed TEMPLATE variable and print the path passed to stdout
910-
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/windows-task/Taskfile.yml
911909
utility:mktemp-folder:
912910
vars:
913911
RAW_PATH:

workflow-templates/assets/check-npm-task/Taskfile.yml

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
# See: https://taskfile.dev/#/usage
22
version: "3"
33

4-
vars:
5-
# Last version of ajv-cli with support for the JSON schema "Draft 4" specification
6-
SCHEMA_DRAFT_4_AJV_CLI_VERSION: 3.3.0
7-
84
tasks:
95
# Parameter variables:
106
# - PROJECT_PATH: path of the npm-managed project. Default value: "./"
117
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-npm-task/Taskfile.yml
128
npm:validate:
139
desc: Validate npm configuration files against their JSON schema
10+
deps:
11+
- task: npm:install-deps
1412
vars:
1513
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/package.json
1614
SCHEMA_URL: https://json.schemastore.org/package.json
@@ -54,10 +52,6 @@ tasks:
5452
sh: task utility:mktemp-file TEMPLATE="stylelintrc-schema-XXXXXXXXXX.json"
5553
INSTANCE_PATH: >-
5654
{{default "." .PROJECT_PATH}}/package.json
57-
PROJECT_FOLDER:
58-
sh: pwd
59-
WORKING_FOLDER:
60-
sh: task utility:mktemp-folder TEMPLATE="dependabot-validate-XXXXXXXXXX"
6155
cmds:
6256
- wget --quiet --output-document="{{.SCHEMA_PATH}}" {{.SCHEMA_URL}}
6357
- wget --quiet --output-document="{{.AVA_SCHEMA_PATH}}" {{.AVA_SCHEMA_URL}}
@@ -70,17 +64,20 @@ tasks:
7064
- wget --quiet --output-document="{{.SEMANTIC_RELEASE_SCHEMA_PATH}}" {{.SEMANTIC_RELEASE_SCHEMA_URL}}
7165
- wget --quiet --output-document="{{.STYLELINTRC_SCHEMA_PATH}}" {{.STYLELINTRC_SCHEMA_URL}}
7266
- |
73-
cd "{{.WORKING_FOLDER}}" # Workaround for https://github.com/npm/cli/issues/3210
74-
npx ajv-cli@{{.SCHEMA_DRAFT_4_AJV_CLI_VERSION}} validate \
75-
--all-errors \
76-
-s "{{.SCHEMA_PATH}}" \
77-
-r "{{.AVA_SCHEMA_PATH}}" \
78-
-r "{{.BASE_SCHEMA_PATH}}" \
79-
-r "{{.ESLINTRC_SCHEMA_PATH}}" \
80-
-r "{{.JSCPD_SCHEMA_PATH}}" \
81-
-r "{{.NPM_BADGES_SCHEMA_PATH}}" \
82-
-r "{{.PARTIAL_ESLINT_PLUGINS_PATH}}" \
83-
-r "{{.PRETTIERRC_SCHEMA_PATH}}" \
84-
-r "{{.SEMANTIC_RELEASE_SCHEMA_PATH}}" \
85-
-r "{{.STYLELINTRC_SCHEMA_PATH}}" \
86-
-d "{{.PROJECT_FOLDER}}/{{.INSTANCE_PATH}}"
67+
npx \
68+
--package=ajv-cli \
69+
--package=ajv-formats \
70+
ajv validate \
71+
--all-errors \
72+
--strict=false \
73+
-s "{{.SCHEMA_PATH}}" \
74+
-r "{{.AVA_SCHEMA_PATH}}" \
75+
-r "{{.BASE_SCHEMA_PATH}}" \
76+
-r "{{.ESLINTRC_SCHEMA_PATH}}" \
77+
-r "{{.JSCPD_SCHEMA_PATH}}" \
78+
-r "{{.NPM_BADGES_SCHEMA_PATH}}" \
79+
-r "{{.PARTIAL_ESLINT_PLUGINS_PATH}}" \
80+
-r "{{.PRETTIERRC_SCHEMA_PATH}}" \
81+
-r "{{.SEMANTIC_RELEASE_SCHEMA_PATH}}" \
82+
-r "{{.STYLELINTRC_SCHEMA_PATH}}" \
83+
-d "{{.INSTANCE_PATH}}"

workflow-templates/assets/windows-task/Taskfile.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,6 @@ tasks:
1313
vars:
1414
RAW_PATH: "{{.RAW_PATH}}"
1515

16-
# Make a temporary folder named according to the passed TEMPLATE variable and print the path passed to stdout
17-
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/windows-task/Taskfile.yml
18-
utility:mktemp-folder:
19-
vars:
20-
RAW_PATH:
21-
sh: mktemp --directory --tmpdir "{{.TEMPLATE}}"
22-
cmds:
23-
- task: utility:normalize-path
24-
vars:
25-
RAW_PATH: "{{.RAW_PATH}}"
26-
2716
# Print a normalized version of the path passed via the RAW_PATH variable to stdout
2817
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/windows-task/Taskfile.yml
2918
utility:normalize-path:

0 commit comments

Comments
 (0)