From 83f366681dd82c7bc82b8e1c284730bad6c38b60 Mon Sep 17 00:00:00 2001 From: AliReZa Sabouri <alirezanet@outlook.com> Date: Sun, 16 Jun 2024 00:18:10 +0200 Subject: [PATCH] feat: add task-runner schema --- .husky/task-runner.json | 10 +- docs/.vuepress/public/schema.json | 383 +++++++++++++++------------ src/Husky/templates/task-runner.json | 1 + 3 files changed, 210 insertions(+), 184 deletions(-) diff --git a/.husky/task-runner.json b/.husky/task-runner.json index 0312abb..7dcdcb6 100644 --- a/.husky/task-runner.json +++ b/.husky/task-runner.json @@ -1,4 +1,5 @@ { + "$schema": "https://alirezanet.github.io/Husky.Net/schema.json", "variables": [ { "name": "root-dir", @@ -12,13 +13,6 @@ "command": "dotnet", "args": ["husky", "exec", ".husky/csx/commit-lint.csx", "--args", "${args}"] }, -// { -// "name": "dotnet-format", -// "command": "dotnet", -// "group": "pre-commit", -// "args": ["dotnet-format", "--include" , "${staged}"], -// "include": ["**/*.cs"] -// }, { "name": "update-version", "command": "dotnet", @@ -29,7 +23,7 @@ "pathMode": "absolute", "command": "cmd", "group": "pre-commit", - "args": [ "/c", "echo", "${staged}"], + "args": [ "/c", "echo", "${staged}"] } ] } diff --git a/docs/.vuepress/public/schema.json b/docs/.vuepress/public/schema.json index 8277ce4..a808065 100644 --- a/docs/.vuepress/public/schema.json +++ b/docs/.vuepress/public/schema.json @@ -1,185 +1,216 @@ { - "$schema": "http://json-schema.org/draft-04/schema#", + "$schema": "http://json-schema.org/draft-07/schema#", "title": "TaskRunner", "type": "object", - "additionalProperties": false, - "required": [ - "tasks" - ], "properties": { - "$schema": { "type": "string" }, - "tasks": { - "type": "array", - "items": { - "$ref": "#/definitions/HuskyTask" - } - }, - "variables": { - "type": [ - "array", - "null" - ], - "items": { - "$ref": "#/definitions/VariableTask" - } - } + "tasks": { + "type": "array", + "items": { + "$ref": "#/definitions/huskyTask" + }, + "description": "A list of tasks that the runner will execute. Each task is defined with specific commands and configurations." + }, + "variables": { + "type": "array", + "items": { + "$ref": "#/definitions/variableTask" + }, + "description": "A list of variable tasks that can override default settings or provide new ones." + } }, + "required": ["tasks"], "definitions": { - "HuskyTask": { - "type": "object", - "additionalProperties": false, - "required": [ - "name", - "command" - ], - "properties": { - "name": { - "type": "string", - "minLength": 1 - }, - "command": { - "type": "string", - "minLength": 1 - }, - "args": { - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "output": { - "oneOf": [ - { - "type": "null" - }, - { - "$ref": "#/definitions/OutputTypes" - } - ] - }, - "pathMode": { - "oneOf": [ - { - "type": "null" - }, - { - "$ref": "#/definitions/PathModes" - } - ] - }, - "cwd": { - "type": [ - "null", - "string" - ] - }, - "group": { - "type": [ - "null", - "string" - ] - }, - "branch": { - "type": [ - "null", - "string" - ] - }, - "windows": { - "oneOf": [ - { - "type": "null" - }, - { - "$ref": "#/definitions/HuskyTask" - } - ] - }, - "include": { - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "exclude": { - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - } + "huskyTask": { + "type": "object", + "additionalProperties": false, + "properties": { + "name": { + "type": "string", + "minLength": 1, + "description": "The name of the task, recommended for identification." + }, + "command": { + "type": "string", + "minLength": 1, + "description": "Path to the executable file, script, or executable name to run." + }, + "args": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Array of command arguments. Built-in variables can be used, such as ${staged}, ${git-files}, ${last-commit}", + "examples": ["${staged}", "${git-files}", "${last-commit}", "${args}", "${all-files}"] + }, + "output": { + "$ref": "#/definitions/outputTypes", + "description": "Specifies the output log level. Can be 'always', 'verbose', or 'never'.", + "default": "always" + }, + "pathMode": { + "$ref": "#/definitions/pathModes", + "description": "Defines the file path style. Can be 'relative' or 'absolute'.", + "default": "relative" + }, + "cwd": { + "type": "string", + "description": "Current working directory for the command.", + "default": "." + }, + "group": { + "type": "string", + "description": "Group of the task, usually the hook name." + }, + "branch": { + "type": "string", + "description": "Regex to run the task on specific branches only." + }, + "include": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Glob pattern to select files." + }, + "exclude": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Glob pattern to exclude files." + }, + "windows": { + "$ref": "#/definitions/windowsOverrides", + "description": "Overrides all settings for Windows." + } + }, + "required": ["name", "command"] + }, + "windowsOverrides": { + "type": "object", + "additionalProperties": false, + "properties": { + "name": { + "type": "string", + "minLength": 1, + "description": "Override task name for Windows." + }, + "command": { + "type": "string", + "minLength": 1, + "description": "Override command for Windows." + }, + "args": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Override arguments for Windows. Built-in variables can be used, such as ${staged}, ${git-files}, ${last-commit}", + "examples": ["${staged}", "${git-files}", "${last-commit}"] + }, + "output": { + "$ref": "#/definitions/outputTypes", + "description": "Override output log level for Windows.", + "default": "always" + }, + "pathMode": { + "$ref": "#/definitions/pathModes", + "description": "Override path mode for Windows.", + "default": "relative" + }, + "cwd": { + "type": "string", + "description": "Override working directory for Windows.", + "default": "." + }, + "group": { + "type": "string", + "description": "Override group for Windows." + }, + "branch": { + "type": "string", + "description": "Override branch for Windows." + }, + "include": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Override include pattern for Windows." + }, + "exclude": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Override exclude pattern for Windows." + } + } + }, + "variableTask": { + "type": "object", + "additionalProperties": false, + "properties": { + "name": { + "type": "string", + "minLength": 1, + "description": "The name of the variable task." + }, + "command": { + "type": "string", + "minLength": 1, + "description": "Command for the variable task." + }, + "args": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Arguments for the variable task command. Built-in variables can be used, such as ${staged}, ${git-files}, ${last-commit}", + "examples": ["${staged}", "${git-files}", "${last-commit}"] + }, + "windows": { + "$ref": "#/definitions/variableTaskOverrides", + "description": "Overrides for the variable task on Windows." } - }, - "OutputTypes": { - "type": "string", - "description": "", - "x-enumNames": [ - "Always", - "Verbose", - "Never" - ], - "enum": [ - "Always", - "Verbose", - "Never" - ] - }, - "PathModes": { - "type": "string", - "description": "", - "x-enumNames": [ - "Relative", - "Absolute" - ], - "enum": [ - "Relative", - "Absolute" - ] - }, - "VariableTask": { - "type": "object", - "additionalProperties": false, - "required": [ - "name", - "command" - ], - "properties": { - "name": { - "type": "string", - "minLength": 1 - }, - "command": { - "type": "string", - "minLength": 1 - }, - "args": { - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "windows": { - "oneOf": [ - { - "type": "null" - }, - { - "$ref": "#/definitions/VariableTask" - } - ] - } + }, + "required": ["name", "command"] + }, + "variableTaskOverrides": { + "type": "object", + "additionalProperties": false, + "properties": { + "name": { + "type": "string", + "minLength": 1, + "description": "Override task name for Windows." + }, + "command": { + "type": "string", + "minLength": 1, + "description": "Override command for Windows." + }, + "args": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Override arguments for Windows. Built-in variables can be used, such as ${staged}, ${git-files}, ${last-commit}", + "examples": ["${staged}", "${git-files}", "${last-commit}"] } - } + } + }, + "outputTypes": { + "type": "string", + "enum": ["always", "verbose", "never"], + "description": "Specifies the output log level.", + "default": "always" + }, + "pathModes": { + "type": "string", + "enum": ["relative", "absolute"], + "description": "Specifies the file path style.", + "default": "relative" + } } -} + } diff --git a/src/Husky/templates/task-runner.json b/src/Husky/templates/task-runner.json index 2a016c4..b56ea27 100644 --- a/src/Husky/templates/task-runner.json +++ b/src/Husky/templates/task-runner.json @@ -1,4 +1,5 @@ { + "$schema": "https://alirezanet.github.io/Husky.Net/schema.json", "tasks": [ { "name": "welcome-message-example",