CPS-IT/project-builder

View on GitHub
resources/config.schema.json

Summary

Maintainability
Test Coverage
{
    "$schema": "https://json-schema.org/draft/2019-09/schema#",
    "type": "object",
    "title": "Project builder template configuration",
    "properties": {
        "$schema": {
            "type": "string",
            "title": "Public URL to this JSON schema file"
        },
        "name": {
            "type": "string",
            "title": "Project template name",
            "description": "Will be shown to the user when collecting build instructions"
        },
        "steps": {
            "type": "array",
            "title": "Project build steps",
            "description": "Will be processed to generate a new project from a template",
            "items": {
                "$ref": "#/definitions/step"
            },
            "minItems": 1
        },
        "properties": {
            "type": "array",
            "title": "Additional template properties",
            "description": "Will be collected and used as template variables",
            "items": {
                "$ref": "#/definitions/property"
            }
        }
    },
    "additionalProperties": false,
    "required": [
        "name",
        "steps"
    ],
    "definitions": {
        "property": {
            "type": "object",
            "title": "A single template property",
            "description": "Will be passed as template variable to the template renderer",
            "allOf": [
                {
                    "properties": {
                        "identifier": {
                            "type": "string",
                            "title": "The property identifier",
                            "description": "Will be used as variable name in the template renderer"
                        },
                        "name": {
                            "type": "string",
                            "title": "The property name",
                            "description": "Will be shown to the user when collecting build instructions"
                        },
                        "path": {
                            "$ref": "#/definitions/path"
                        },
                        "if": {
                            "$ref": "#/definitions/condition"
                        }
                    },
                    "required": [
                        "identifier",
                        "name"
                    ]
                },
                {
                    "oneOf": [
                        {
                            "properties": {
                                "properties": {
                                    "type": "array",
                                    "title": "A list of sub-properties",
                                    "items": {
                                        "$ref": "#/definitions/sub-property"
                                    },
                                    "minItems": 1
                                }
                            },
                            "required": [
                                "properties"
                            ]
                        },
                        {
                            "properties": {
                                "value": {
                                    "$ref": "#/definitions/value"
                                }
                            },
                            "required": [
                                "value"
                            ]
                        }
                    ]
                }
            ],
            "unevaluatedProperties": false
        },
        "sub-property": {
            "type": "object",
            "title": "A sub-property of a template property",
            "description": "Will be used as sub-array of the parent property's template variable",
            "properties": {
                "identifier": {
                    "type": "string",
                    "title": "The sub-property identifier",
                    "description": "Will be used as identifier within the parent property's template variable"
                },
                "name": {
                    "type": "string",
                    "title": "The name of the sub-property",
                    "description": "Will be shown to the user when collecting build instructions"
                },
                "type": {
                    "type": "string",
                    "title": "The sub-property type",
                    "description": "Will be used to determine how to apply a sub-property",
                    "enum": [
                        "dynamicSelect",
                        "select",
                        "staticValue",
                        "question"
                    ]
                },
                "path": {
                    "$ref": "#/definitions/path"
                },
                "if": {
                    "$ref": "#/definitions/condition"
                },
                "options": {
                    "type": "array",
                    "title": "The sub-property options",
                    "description": "Will be used for selectable sub-property types",
                    "items": {
                        "$ref": "#/definitions/option"
                    }
                },
                "multiple": {
                    "type": "boolean",
                    "title": "Allow selection of multiple sub-property options",
                    "description": "Will only be respected for sub-property type \"select\""
                },
                "defaultValue": {
                    "title": "The default (fallback) value of the sub-property",
                    "oneOf": [
                        {
                            "type": "boolean"
                        },
                        {
                            "type": "string"
                        }
                    ]
                },
                "validators": {
                    "$ref": "#/definitions/validators"
                }
            },
            "additionalProperties": false,
            "required": [
                "identifier",
                "name",
                "type"
            ]
        },
        "option": {
            "type": "object",
            "title": "A selectable property option",
            "properties": {
                "if": {
                    "$ref": "#/definitions/condition"
                },
                "value": {
                    "$ref": "#/definitions/value"
                }
            },
            "additionalProperties": false,
            "required": [
                "value"
            ]
        },
        "validators": {
            "type": "array",
            "title": "A list of optional property validators",
            "items": {
                "$ref": "#/definitions/validator"
            },
            "minItems": 1
        },
        "validator": {
            "type": "object",
            "title": "A property validator",
            "properties": {
                "type": {
                    "type": "string",
                    "enum": [
                        "email",
                        "notEmpty",
                        "regex",
                        "url"
                    ]
                },
                "options": {
                    "type": "object"
                }
            },
            "additionalProperties": false,
            "required": [
                "type"
            ]
        },
        "step": {
            "type": "object",
            "title": "A single project generation step",
            "oneOf": [
                {
                    "properties": {
                        "type": {
                            "type": "string",
                            "enum": [
                                "collectBuildInstructions",
                                "installComposerDependencies",
                                "mirrorProcessedFiles"
                            ]
                        }
                    }
                },
                {
                    "properties": {
                        "type": {
                            "type": "string",
                            "enum": [
                                "processSourceFiles",
                                "processSharedSourceFiles"
                            ]
                        },
                        "options": {
                            "type": "object",
                            "properties": {
                                "fileConditions": {
                                    "type": "array",
                                    "title": "A list of optional file conditions",
                                    "items": {
                                        "$ref": "#/definitions/file-condition"
                                    }
                                }
                            }
                        }
                    }
                },
                {
                    "properties": {
                        "type": {
                            "const": "generateBuildArtifact"
                        },
                        "options": {
                            "type": "object",
                            "properties": {
                                "artifactPath": {
                                    "type": "string",
                                    "title": "Path to build artifact in generated project",
                                    "description": "Must be a JSON file, relative to the project root",
                                    "default": ".build/build-artifact.json",
                                    "pattern": "\\.json$"
                                }
                            }
                        }
                    }
                },
                {
                    "properties": {
                        "type": {
                            "const": "showNextSteps"
                        },
                        "options": {
                            "type": "object",
                            "properties": {
                                "templateFile": {
                                    "type": "string",
                                    "title": "Path to a template file",
                                    "description": "Should contain a Twig template with next steps shown to the user"
                                }
                            },
                            "required": [
                                "templateFile"
                            ]
                        }
                    },
                    "required": [
                        "options"
                    ]
                },
                {
                    "properties": {
                        "type": {
                            "const": "runCommand"
                        },
                        "options": {
                            "type": "object",
                            "properties": {
                                "command": {
                                    "type": "string",
                                    "title": "Shell command to be executed",
                                    "description": "Specify the command that should be run in the project or temporary directory"
                                },
                                "skipConfirmation": {
                                    "type": "boolean",
                                    "title": "Do not ask for confirmation",
                                    "description": "Skip user confirmation to run the configured command",
                                    "default": false
                                },
                                "allowFailure": {
                                    "type": "boolean",
                                    "title": "Allow command execution failure",
                                    "description": "Ignore errors occurred during command execution and continue as normal",
                                    "default": false
                                },
                                "required": {
                                    "type": "boolean",
                                    "title": "Enforce command execution",
                                    "description": "If set to true, the command must be executed and cannot be skipped, otherwise project generation fails",
                                    "default": true
                                }
                            },
                            "required": [
                                "command"
                            ]
                        }
                    },
                    "required": [
                        "options"
                    ]
                }
            ],
            "unevaluatedProperties": false,
            "required": [
                "type"
            ]
        },
        "file-condition": {
            "type": "object",
            "title": "A condition to include or exclude a file",
            "allOf": [
                {
                    "properties": {
                        "if": {
                            "$ref": "#/definitions/condition"
                        },
                        "path": {
                            "type": "string",
                            "title": "Relative path to a file, can contain symbols processable by `fnmatch`",
                            "description": "Can also be a directory ending with `/*`, to recursively match all files below"
                        }
                    }
                },
                {
                    "oneOf": [
                        {
                            "not": {
                                "required": [
                                    "target"
                                ]
                            },
                            "required": [
                                "path",
                                "if"
                            ]
                        },
                        {
                            "properties": {
                                "target": {
                                    "type": "string",
                                    "title": "Relative path to target file, can be used to override the default path",
                                    "description": "Can also be a directory ending with `/*`, to exchange the base source path"
                                }
                            },
                            "oneOf": [
                                {
                                    "properties": {
                                        "path": {
                                            "pattern": "/\\*$"
                                        },
                                        "target": {
                                            "pattern": "/\\*$"
                                        }
                                    }
                                },
                                {
                                    "properties": {
                                        "path": {
                                            "pattern": "(?<!\\*)$"
                                        },
                                        "target": {
                                            "pattern": "(?<!\\*)$"
                                        }
                                    }
                                }
                            ],
                            "required": [
                                "path",
                                "target"
                            ]
                        }
                    ]
                }
            ],
            "unevaluatedProperties": false
        },
        "condition": {
            "type": "string",
            "title": "A condition to include or exclude the current object",
            "description": "Will be parsed with Symfony Expression Language"
        },
        "path": {
            "type": "string",
            "title": "The property path",
            "description": "Will be used as variable identifier in templates"
        },
        "value": {
            "title": "A static value",
            "oneOf": [
                {
                    "type": "number"
                },
                {
                    "type": "string"
                }
            ]
        }
    }
}