jsonSchemaCommon.ts 9.7 KB
Newer Older
D
Dirk Baeumer 已提交
1 2 3 4 5 6 7 8
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import * as nls from 'vs/nls';
import { IJSONSchema } from 'vs/base/common/jsonSchema';

9
import { Schemas } from 'vs/workbench/contrib/tasks/common/problemMatcher';
10

D
Dirk Baeumer 已提交
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
const schema: IJSONSchema = {
	definitions: {
		showOutputType: {
			type: 'string',
			enum: ['always', 'silent', 'never']
		},
		options: {
			type: 'object',
			description: nls.localize('JsonSchema.options', 'Additional command options'),
			properties: {
				cwd: {
					type: 'string',
					description: nls.localize('JsonSchema.options.cwd', 'The current working directory of the executed program or script. If omitted Code\'s current workspace root is used.')
				},
				env: {
					type: 'object',
					additionalProperties: {
						type: 'string'
					},
					description: nls.localize('JsonSchema.options.env', 'The environment of the executed program or shell. If omitted the parent process\' environment is used.')
				}
			},
			additionalProperties: {
				type: ['string', 'array', 'object']
			}
		},
		problemMatcherType: {
			oneOf: [
				{
					type: 'string',
41
					errorMessage: nls.localize('JsonSchema.tasks.matcherError', 'Unrecognized problem matcher. Is the extension that contributes this problem matcher installed?')
D
Dirk Baeumer 已提交
42
				},
43
				Schemas.LegacyProblemMatcher,
D
Dirk Baeumer 已提交
44 45 46 47 48 49
				{
					type: 'array',
					items: {
						anyOf: [
							{
								type: 'string',
50
								errorMessage: nls.localize('JsonSchema.tasks.matcherError', 'Unrecognized problem matcher. Is the extension that contributes this problem matcher installed?')
51 52
							},
							Schemas.LegacyProblemMatcher
D
Dirk Baeumer 已提交
53 54 55 56 57 58 59 60
						]
					}
				}
			]
		},
		shellConfiguration: {
			type: 'object',
			additionalProperties: false,
61
			description: nls.localize('JsonSchema.shellConfiguration', 'Configures the shell to be used.'),
D
Dirk Baeumer 已提交
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
			properties: {
				executable: {
					type: 'string',
					description: nls.localize('JsonSchema.shell.executable', 'The shell to be used.')
				},
				args: {
					type: 'array',
					description: nls.localize('JsonSchema.shell.args', 'The shell arguments.'),
					items: {
						type: 'string'
					}
				}
			}
		},
		commandConfiguration: {
			type: 'object',
			additionalProperties: false,
			properties: {
				command: {
					type: 'string',
					description: nls.localize('JsonSchema.command', 'The command to be executed. Can be an external program or a shell command.')
				},
				args: {
					type: 'array',
					description: nls.localize('JsonSchema.tasks.args', 'Arguments passed to the command when this task is invoked.'),
					items: {
						type: 'string'
					}
				},
				options: {
					$ref: '#/definitions/options'
				}
			}
		},
		taskDescription: {
			type: 'object',
			required: ['taskName'],
			additionalProperties: false,
			properties: {
				taskName: {
					type: 'string',
					description: nls.localize('JsonSchema.tasks.taskName', "The task's name")
				},
				command: {
					type: 'string',
					description: nls.localize('JsonSchema.command', 'The command to be executed. Can be an external program or a shell command.')
				},
				args: {
					type: 'array',
					description: nls.localize('JsonSchema.tasks.args', 'Arguments passed to the command when this task is invoked.'),
					items: {
						type: 'string'
					}
				},
				options: {
					$ref: '#/definitions/options'
				},
				windows: {
120 121 122 123 124 125 126 127 128 129 130 131 132 133
					anyOf: [
						{
							$ref: '#/definitions/commandConfiguration',
							description: nls.localize('JsonSchema.tasks.windows', 'Windows specific command configuration'),
						},
						{
							properties: {
								problemMatcher: {
									$ref: '#/definitions/problemMatcherType',
									description: nls.localize('JsonSchema.tasks.matchers', 'The problem matcher(s) to use. Can either be a string or a problem matcher definition or an array of strings and problem matchers.')
								}
							}
						}
					]
D
Dirk Baeumer 已提交
134 135
				},
				osx: {
136 137 138 139 140 141 142 143 144 145 146 147 148 149
					anyOf: [
						{
							$ref: '#/definitions/commandConfiguration',
							description: nls.localize('JsonSchema.tasks.mac', 'Mac specific command configuration')
						},
						{
							properties: {
								problemMatcher: {
									$ref: '#/definitions/problemMatcherType',
									description: nls.localize('JsonSchema.tasks.matchers', 'The problem matcher(s) to use. Can either be a string or a problem matcher definition or an array of strings and problem matchers.')
								}
							}
						}
					]
D
Dirk Baeumer 已提交
150 151
				},
				linux: {
152 153 154 155 156 157 158 159 160 161 162 163 164 165
					anyOf: [
						{
							$ref: '#/definitions/commandConfiguration',
							description: nls.localize('JsonSchema.tasks.linux', 'Linux specific command configuration')
						},
						{
							properties: {
								problemMatcher: {
									$ref: '#/definitions/problemMatcherType',
									description: nls.localize('JsonSchema.tasks.matchers', 'The problem matcher(s) to use. Can either be a string or a problem matcher definition or an array of strings and problem matchers.')
								}
							}
						}
					]
D
Dirk Baeumer 已提交
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
				},
				suppressTaskName: {
					type: 'boolean',
					description: nls.localize('JsonSchema.tasks.suppressTaskName', 'Controls whether the task name is added as an argument to the command. If omitted the globally defined value is used.'),
					default: true
				},
				showOutput: {
					$ref: '#/definitions/showOutputType',
					description: nls.localize('JsonSchema.tasks.showOutput', 'Controls whether the output of the running task is shown or not. If omitted the globally defined value is used.')
				},
				echoCommand: {
					type: 'boolean',
					description: nls.localize('JsonSchema.echoCommand', 'Controls whether the executed command is echoed to the output. Default is false.'),
					default: true
				},
				isWatching: {
					type: 'boolean',
					deprecationMessage: nls.localize('JsonSchema.tasks.watching.deprecation', 'Deprecated. Use isBackground instead.'),
					description: nls.localize('JsonSchema.tasks.watching', 'Whether the executed task is kept alive and is watching the file system.'),
					default: true
				},
				isBackground: {
					type: 'boolean',
					description: nls.localize('JsonSchema.tasks.background', 'Whether the executed task is kept alive and is running in the background.'),
					default: true
				},
				promptOnClose: {
					type: 'boolean',
					description: nls.localize('JsonSchema.tasks.promptOnClose', 'Whether the user is prompted when VS Code closes with a running task.'),
					default: false
				},
				isBuildCommand: {
					type: 'boolean',
					description: nls.localize('JsonSchema.tasks.build', 'Maps this task to Code\'s default build command.'),
					default: true
				},
				isTestCommand: {
					type: 'boolean',
					description: nls.localize('JsonSchema.tasks.test', 'Maps this task to Code\'s default test command.'),
					default: true
				},
				problemMatcher: {
					$ref: '#/definitions/problemMatcherType',
					description: nls.localize('JsonSchema.tasks.matchers', 'The problem matcher(s) to use. Can either be a string or a problem matcher definition or an array of strings and problem matchers.')
				}
			}
		},
		taskRunnerConfiguration: {
			type: 'object',
215
			required: [],
D
Dirk Baeumer 已提交
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
			properties: {
				command: {
					type: 'string',
					description: nls.localize('JsonSchema.command', 'The command to be executed. Can be an external program or a shell command.')
				},
				args: {
					type: 'array',
					description: nls.localize('JsonSchema.args', 'Additional arguments passed to the command.'),
					items: {
						type: 'string'
					}
				},
				options: {
					$ref: '#/definitions/options'
				},
				showOutput: {
					$ref: '#/definitions/showOutputType',
					description: nls.localize('JsonSchema.showOutput', 'Controls whether the output of the running task is shown or not. If omitted \'always\' is used.')
				},
				isWatching: {
					type: 'boolean',
					deprecationMessage: nls.localize('JsonSchema.watching.deprecation', 'Deprecated. Use isBackground instead.'),
					description: nls.localize('JsonSchema.watching', 'Whether the executed task is kept alive and is watching the file system.'),
					default: true
				},
				isBackground: {
					type: 'boolean',
					description: nls.localize('JsonSchema.background', 'Whether the executed task is kept alive and is running in the background.'),
					default: true
				},
				promptOnClose: {
					type: 'boolean',
					description: nls.localize('JsonSchema.promptOnClose', 'Whether the user is prompted when VS Code closes with a running background task.'),
					default: false
				},
				echoCommand: {
					type: 'boolean',
					description: nls.localize('JsonSchema.echoCommand', 'Controls whether the executed command is echoed to the output. Default is false.'),
					default: true
				},
				suppressTaskName: {
					type: 'boolean',
					description: nls.localize('JsonSchema.suppressTaskName', 'Controls whether the task name is added as an argument to the command. Default is false.'),
					default: true
				},
				taskSelector: {
					type: 'string',
					description: nls.localize('JsonSchema.taskSelector', 'Prefix to indicate that an argument is task.')
				},
				problemMatcher: {
					$ref: '#/definitions/problemMatcherType',
					description: nls.localize('JsonSchema.matchers', 'The problem matcher(s) to use. Can either be a string or a problem matcher definition or an array of strings and problem matchers.')
				},
				tasks: {
					type: 'array',
					description: nls.localize('JsonSchema.tasks', 'The task configurations. Usually these are enrichments of task already defined in the external task runner.'),
					items: {
						type: 'object',
						$ref: '#/definitions/taskDescription'
					}
				}
			}
		}
	}
};

282
export default schema;