{ "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://unpkg.com/cmdsync/cmdsync.schema.json", "title": "cmdsync config", "description": "Config for cmdsync, in cmdsync.json or the \"cmdsync\" key of package.json", "type": "object", "additionalProperties": false, "definitions": { "marker": { "type": "string", "pattern": "^[\\w.-]+$" }, "endMarker": { "type": "string", "pattern": "^[\\w./-]+( [\\w./-]+)*$" }, "comment": { "type": "array", "items": { "type": "string" }, "minItems": 1, "maxItems": 2, "description": "Comment delimiters: [\"#\"] for line comments, [\"/*\", \"*/\"] for block comments" } }, "properties": { "$schema": { "type": "string" }, "marker": { "$ref": "#/definitions/marker", "default": "CMDSYNC", "description": "Starts a directive: " }, "endMarker": { "$ref": "#/definitions/endMarker", "description": "End of a region: (default: marker + \" end\")" }, "shell": { "type": "string", "minLength": 1, "default": "auto", "description": "Shell binary used to run each command (invoked as ` -c `), or \"auto\" (the default): the shell cmdsync was started from, found by walking up the parent processes ($CMDSYNC_SHELL overrides it), else $SHELL, else sh" }, "commands": { "type": "array", "items": { "type": "string" }, "default": [], "description": "Command binaries directives may run. Every command in a pipeline/list must be listed. Empty allows anything." }, "install": { "type": "object", "additionalProperties": { "type": "string", "minLength": 1 }, "default": {}, "description": "How to install a binary that directives run, keyed by binary name. Runs (with `shell`, `cwd` and `env`) the first time a directive needs a binary that isn't on PATH." }, "include": { "type": "array", "items": { "type": "string" }, "default": [ "**/*.md", "**/*.mdx" ], "description": "Globs (relative to the config's directory) of files to scan" }, "exclude": { "type": "array", "items": { "type": "string" }, "default": [ "**/node_modules/**", "**/.git/**" ], "description": "Globs (relative to the config's directory) to skip" }, "syntax": { "type": "array", "default": [], "description": "Comment syntax per glob, checked before the built-in table. The first matching rule wins.", "items": { "type": "object", "additionalProperties": false, "required": [ "include", "comment" ], "properties": { "include": { "type": "array", "items": { "type": "string" }, "minItems": 1, "description": "Globs (relative to the config's directory) this rule applies to" }, "comment": { "$ref": "#/definitions/comment" }, "marker": { "$ref": "#/definitions/marker", "description": "Start marker for these files" }, "endMarker": { "$ref": "#/definitions/endMarker", "description": "End marker for these files" }, "fences": { "type": "boolean", "default": false, "description": "Treat as markdown: skip fenced/inline code, allow the fenced code block form" } } } }, "comment": { "$ref": "#/definitions/comment", "description": "Comment delimiters for every file, overriding `syntax` and the built-in table" }, "cwd": { "type": "string", "default": ".", "description": "Working directory for commands, relative to the config's directory" }, "timeout": { "type": "number", "exclusiveMinimum": 0, "default": 60000, "description": "Per-command timeout in milliseconds" }, "env": { "type": "object", "additionalProperties": { "type": "string" }, "default": {}, "description": "Extra environment variables passed to every command" }, "postUpdate": { "type": "array", "items": { "type": "string", "minLength": 1 }, "default": [], "description": "Commands run in order after an update wrote at least one file. Same shell, cwd and env as directives, plus CMDSYNC_CHANGED_FILES (written files, one per line, relative to the config root)." }, "directives": { "type": "object", "default": {}, "description": "Custom directives by name, used like a mode: . The command runs, then formatter and/or template turn its output into what's written.", "propertyNames": { "pattern": "^[a-z][\\w-]*$", "not": { "enum": [ "region", "line", "codeblock", "console", "console-pretty", "start", "end" ] } }, "additionalProperties": { "type": "object", "additionalProperties": false, "properties": { "mode": { "enum": [ "region", "line", "codeblock", "console", "console-pretty" ], "default": "region", "description": "The built-in mode that writes the result" }, "command": { "type": "string", "minLength": 1, "description": "The command to run, with {cmd} for what the directive says (default: {cmd})" }, "lang": { "type": "string", "pattern": "^[\\w.+#-]+$", "description": "Default lang=" }, "format": { "enum": [ "md-table", "html-table" ], "description": "Default format=, applied before formatter and template" }, "template": { "type": "string", "description": "Text written, with placeholders ({output}, {cmd}, {command}, {lang}, {file}, {line}, {date}, {env.NAME}, {params.NAME}, ...) and filters ({output|trim|quote}, {output|code:txt}, ...)" }, "formatter": { "type": "string", "minLength": 1, "description": "JS/TS module, relative to the config root, whose default export (ctx: FormatterContext) => string returns what's written" }, "description": { "type": "string" } } } } } }