@theia/task 1.45.1 → 1.46.0-next.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/README.md +193 -193
  2. package/lib/browser/index.d.ts +6 -6
  3. package/lib/browser/index.js +33 -33
  4. package/lib/browser/process/process-task-contribution.d.ts +6 -6
  5. package/lib/browser/process/process-task-contribution.js +43 -43
  6. package/lib/browser/process/process-task-frontend-module.d.ts +2 -2
  7. package/lib/browser/process/process-task-frontend-module.js +27 -27
  8. package/lib/browser/process/process-task-resolver.d.ts +17 -17
  9. package/lib/browser/process/process-task-resolver.js +101 -101
  10. package/lib/browser/provided-task-configurations.d.ts +43 -43
  11. package/lib/browser/provided-task-configurations.js +213 -213
  12. package/lib/browser/provided-task-configurations.spec.d.ts +1 -1
  13. package/lib/browser/provided-task-configurations.spec.js +43 -43
  14. package/lib/browser/quick-open-task.d.ts +144 -144
  15. package/lib/browser/quick-open-task.d.ts.map +1 -1
  16. package/lib/browser/quick-open-task.js +752 -748
  17. package/lib/browser/quick-open-task.js.map +1 -1
  18. package/lib/browser/task-configuration-manager.d.ts +64 -64
  19. package/lib/browser/task-configuration-manager.js +261 -261
  20. package/lib/browser/task-configuration-model.d.ts +32 -32
  21. package/lib/browser/task-configuration-model.js +79 -79
  22. package/lib/browser/task-configurations.d.ts +127 -127
  23. package/lib/browser/task-configurations.js +486 -486
  24. package/lib/browser/task-contribution.d.ts +182 -182
  25. package/lib/browser/task-contribution.js +206 -206
  26. package/lib/browser/task-definition-registry.d.ts +38 -38
  27. package/lib/browser/task-definition-registry.js +134 -134
  28. package/lib/browser/task-definition-registry.spec.d.ts +1 -1
  29. package/lib/browser/task-definition-registry.spec.js +170 -170
  30. package/lib/browser/task-frontend-contribution.d.ts +56 -56
  31. package/lib/browser/task-frontend-contribution.js +358 -358
  32. package/lib/browser/task-frontend-module.d.ts +5 -5
  33. package/lib/browser/task-frontend-module.js +79 -79
  34. package/lib/browser/task-name-resolver.d.ts +13 -13
  35. package/lib/browser/task-name-resolver.js +67 -67
  36. package/lib/browser/task-node.d.ts +9 -9
  37. package/lib/browser/task-node.js +17 -17
  38. package/lib/browser/task-preferences.d.ts +4 -4
  39. package/lib/browser/task-preferences.js +40 -40
  40. package/lib/browser/task-problem-matcher-registry.d.ts +40 -40
  41. package/lib/browser/task-problem-matcher-registry.js +309 -309
  42. package/lib/browser/task-problem-pattern-registry.d.ts +23 -23
  43. package/lib/browser/task-problem-pattern-registry.js +210 -210
  44. package/lib/browser/task-schema-updater.d.ts +58 -58
  45. package/lib/browser/task-schema-updater.js +688 -688
  46. package/lib/browser/task-service.d.ts +279 -279
  47. package/lib/browser/task-service.js +1119 -1119
  48. package/lib/browser/task-source-resolver.d.ts +9 -9
  49. package/lib/browser/task-source-resolver.js +51 -51
  50. package/lib/browser/task-templates.d.ts +13 -13
  51. package/lib/browser/task-templates.js +161 -161
  52. package/lib/browser/task-terminal-widget-manager.d.ts +44 -44
  53. package/lib/browser/task-terminal-widget-manager.js +228 -228
  54. package/lib/browser/tasks-monaco-contribution.d.ts +1 -1
  55. package/lib/browser/tasks-monaco-contribution.js +27 -27
  56. package/lib/common/index.d.ts +4 -4
  57. package/lib/common/index.js +31 -31
  58. package/lib/common/problem-matcher-protocol.d.ts +124 -124
  59. package/lib/common/problem-matcher-protocol.js +132 -132
  60. package/lib/common/process/task-protocol.d.ts +68 -68
  61. package/lib/common/process/task-protocol.js +33 -33
  62. package/lib/common/task-common-module.d.ts +7 -7
  63. package/lib/common/task-common-module.js +33 -33
  64. package/lib/common/task-protocol.d.ts +192 -192
  65. package/lib/common/task-protocol.js +137 -137
  66. package/lib/common/task-util.d.ts +22 -22
  67. package/lib/common/task-util.js +46 -46
  68. package/lib/common/task-watcher.d.ts +17 -17
  69. package/lib/common/task-watcher.js +86 -86
  70. package/lib/node/custom/custom-task-runner-backend-module.d.ts +2 -2
  71. package/lib/node/custom/custom-task-runner-backend-module.js +36 -36
  72. package/lib/node/custom/custom-task-runner-contribution.d.ts +6 -6
  73. package/lib/node/custom/custom-task-runner-contribution.js +42 -42
  74. package/lib/node/custom/custom-task-runner.d.ts +15 -15
  75. package/lib/node/custom/custom-task-runner.js +69 -69
  76. package/lib/node/custom/custom-task.d.ts +20 -20
  77. package/lib/node/custom/custom-task.js +78 -78
  78. package/lib/node/index.d.ts +3 -3
  79. package/lib/node/index.js +30 -30
  80. package/lib/node/process/process-task-runner-backend-module.d.ts +2 -2
  81. package/lib/node/process/process-task-runner-backend-module.js +36 -36
  82. package/lib/node/process/process-task-runner-contribution.d.ts +6 -6
  83. package/lib/node/process/process-task-runner-contribution.js +43 -43
  84. package/lib/node/process/process-task-runner.d.ts +60 -60
  85. package/lib/node/process/process-task-runner.js +355 -355
  86. package/lib/node/process/process-task.d.ts +26 -26
  87. package/lib/node/process/process-task.js +135 -135
  88. package/lib/node/process/process-task.spec.d.ts +1 -1
  89. package/lib/node/process/process-task.spec.js +29 -29
  90. package/lib/node/task-abstract-line-matcher.d.ts +49 -49
  91. package/lib/node/task-abstract-line-matcher.js +273 -273
  92. package/lib/node/task-backend-application-contribution.d.ts +8 -8
  93. package/lib/node/task-backend-application-contribution.js +48 -48
  94. package/lib/node/task-backend-module.d.ts +3 -3
  95. package/lib/node/task-backend-module.js +50 -50
  96. package/lib/node/task-line-matchers.d.ts +27 -27
  97. package/lib/node/task-line-matchers.js +121 -121
  98. package/lib/node/task-manager.d.ts +55 -55
  99. package/lib/node/task-manager.js +135 -135
  100. package/lib/node/task-problem-collector.d.ts +10 -10
  101. package/lib/node/task-problem-collector.js +57 -57
  102. package/lib/node/task-problem-collector.spec.d.ts +1 -1
  103. package/lib/node/task-problem-collector.spec.js +310 -310
  104. package/lib/node/task-runner-protocol.d.ts +16 -16
  105. package/lib/node/task-runner-protocol.js +19 -19
  106. package/lib/node/task-runner.d.ts +50 -50
  107. package/lib/node/task-runner.js +97 -97
  108. package/lib/node/task-server.d.ts +39 -39
  109. package/lib/node/task-server.js +237 -237
  110. package/lib/node/task-server.slow-spec.d.ts +1 -1
  111. package/lib/node/task-server.slow-spec.js +395 -395
  112. package/lib/node/task.d.ts +50 -50
  113. package/lib/node/task.js +77 -77
  114. package/lib/node/test/task-test-container.d.ts +2 -2
  115. package/lib/node/test/task-test-container.js +58 -58
  116. package/package.json +14 -14
  117. package/src/browser/index.ts +22 -22
  118. package/src/browser/process/process-task-contribution.ts +31 -31
  119. package/src/browser/process/process-task-frontend-module.ts +27 -27
  120. package/src/browser/process/process-task-resolver.ts +89 -89
  121. package/src/browser/provided-task-configurations.spec.ts +46 -46
  122. package/src/browser/provided-task-configurations.ts +213 -213
  123. package/src/browser/quick-open-task.ts +831 -827
  124. package/src/browser/style/index.css +19 -19
  125. package/src/browser/task-configuration-manager.ts +256 -256
  126. package/src/browser/task-configuration-model.ts +101 -101
  127. package/src/browser/task-configurations.ts +508 -508
  128. package/src/browser/task-contribution.ts +266 -266
  129. package/src/browser/task-definition-registry.spec.ts +203 -203
  130. package/src/browser/task-definition-registry.ts +131 -131
  131. package/src/browser/task-frontend-contribution.ts +402 -402
  132. package/src/browser/task-frontend-module.ts +86 -86
  133. package/src/browser/task-name-resolver.ts +55 -55
  134. package/src/browser/task-node.ts +37 -37
  135. package/src/browser/task-preferences.ts +40 -40
  136. package/src/browser/task-problem-matcher-registry.ts +308 -308
  137. package/src/browser/task-problem-pattern-registry.ts +196 -196
  138. package/src/browser/task-schema-updater.ts +701 -701
  139. package/src/browser/task-service.ts +1164 -1164
  140. package/src/browser/task-source-resolver.ts +36 -36
  141. package/src/browser/task-templates.ts +168 -168
  142. package/src/browser/task-terminal-widget-manager.ts +224 -224
  143. package/src/browser/tasks-monaco-contribution.ts +27 -27
  144. package/src/common/index.ts +20 -20
  145. package/src/common/problem-matcher-protocol.ts +234 -234
  146. package/src/common/process/task-protocol.ts +97 -97
  147. package/src/common/task-common-module.ts +34 -34
  148. package/src/common/task-protocol.ts +317 -317
  149. package/src/common/task-util.ts +43 -43
  150. package/src/common/task-watcher.ts +78 -78
  151. package/src/node/custom/custom-task-runner-backend-module.ts +37 -37
  152. package/src/node/custom/custom-task-runner-contribution.ts +30 -30
  153. package/src/node/custom/custom-task-runner.ts +60 -60
  154. package/src/node/custom/custom-task.ts +73 -73
  155. package/src/node/index.ts +19 -19
  156. package/src/node/process/process-task-runner-backend-module.ts +37 -37
  157. package/src/node/process/process-task-runner-contribution.ts +31 -31
  158. package/src/node/process/process-task-runner.ts +371 -371
  159. package/src/node/process/process-task.spec.ts +30 -30
  160. package/src/node/process/process-task.ts +144 -144
  161. package/src/node/task-abstract-line-matcher.ts +312 -312
  162. package/src/node/task-backend-application-contribution.ts +36 -36
  163. package/src/node/task-backend-module.ts +57 -57
  164. package/src/node/task-line-matchers.ts +127 -127
  165. package/src/node/task-manager.ts +129 -129
  166. package/src/node/task-problem-collector.spec.ts +338 -338
  167. package/src/node/task-problem-collector.ts +62 -62
  168. package/src/node/task-runner-protocol.ts +33 -33
  169. package/src/node/task-runner.ts +96 -96
  170. package/src/node/task-server.slow-spec.ts +444 -444
  171. package/src/node/task-server.ts +263 -263
  172. package/src/node/task.ts +103 -103
  173. package/src/node/test/task-test-container.ts +63 -63
@@ -1,689 +1,689 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2019 Red Hat, Inc. and others.
4
- //
5
- // This program and the accompanying materials are made available under the
6
- // terms of the Eclipse Public License v. 2.0 which is available at
7
- // http://www.eclipse.org/legal/epl-2.0.
8
- //
9
- // This Source Code may also be made available under the following Secondary
10
- // Licenses when the conditions for such availability set forth in the Eclipse
11
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
- // with the GNU Classpath Exception which is available at
13
- // https://www.gnu.org/software/classpath/license.html.
14
- //
15
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- // This file is inspired by VSCode and partially copied from https://github.com/Microsoft/vscode/blob/1.33.1/src/vs/workbench/contrib/tasks/common/problemMatcher.ts
18
- // 'problemMatcher.ts' copyright:
19
- /*---------------------------------------------------------------------------------------------
20
- * Copyright (c) Microsoft Corporation. All rights reserved.
21
- * Licensed under the MIT License. See License.txt in the project root for license information.
22
- *--------------------------------------------------------------------------------------------*/
23
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
24
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
25
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
26
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
27
- return c > 3 && r && Object.defineProperty(target, key, r), r;
28
- };
29
- var __metadata = (this && this.__metadata) || function (k, v) {
30
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
31
- };
32
- Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.TaskSchemaUpdater = exports.taskSchemaId = void 0;
34
- const Ajv = require("@theia/core/shared/ajv");
35
- const debounce = require("p-debounce");
36
- const inversify_1 = require("@theia/core/shared/inversify");
37
- const common_1 = require("@theia/core/lib/common");
38
- const variable_input_schema_1 = require("@theia/variable-resolver/lib/browser/variable-input-schema");
39
- const uri_1 = require("@theia/core/lib/common/uri");
40
- const task_problem_matcher_registry_1 = require("./task-problem-matcher-registry");
41
- const task_definition_registry_1 = require("./task-definition-registry");
42
- const common_2 = require("../common");
43
- const browser_1 = require("@theia/userstorage/lib/browser");
44
- const browser_2 = require("@theia/workspace/lib/browser");
45
- exports.taskSchemaId = 'vscode://schemas/tasks';
46
- let TaskSchemaUpdater = class TaskSchemaUpdater {
47
- constructor() {
48
- this.onDidChangeTaskSchemaEmitter = new common_1.Emitter();
49
- this.onDidChangeTaskSchema = this.onDidChangeTaskSchemaEmitter.event;
50
- this.uri = new uri_1.default(exports.taskSchemaId);
51
- this.update = debounce(() => this.doUpdate(), 0);
52
- }
53
- init() {
54
- const resource = this.inmemoryResources.add(this.uri, '');
55
- if (resource.onDidChangeContents) {
56
- resource.onDidChangeContents(() => {
57
- this.onDidChangeTaskSchemaEmitter.fire(undefined);
58
- });
59
- }
60
- this.updateProblemMatcherNames();
61
- this.updateSupportedTaskTypes();
62
- // update problem matcher names in the task schema every time a problem matcher is added or disposed
63
- this.problemMatcherRegistry.onDidChangeProblemMatcher(() => this.updateProblemMatcherNames());
64
- // update supported task types in the task schema every time a task definition is registered or removed
65
- this.taskDefinitionRegistry.onDidRegisterTaskDefinition(() => this.updateSupportedTaskTypes());
66
- this.taskDefinitionRegistry.onDidUnregisterTaskDefinition(() => this.updateSupportedTaskTypes());
67
- }
68
- registerSchemas(context) {
69
- context.registerSchema({
70
- fileMatch: ['tasks.json', browser_1.UserStorageUri.resolve('tasks.json').toString()],
71
- url: this.uri.toString()
72
- });
73
- this.workspaceService.updateSchema('tasks', { $ref: this.uri.toString() });
74
- }
75
- doUpdate() {
76
- taskConfigurationSchema.anyOf = [processTaskConfigurationSchema, ...customizedDetectedTasks, ...customSchemas];
77
- const schema = this.getTaskSchema();
78
- this.doValidate = new Ajv().compile(schema);
79
- const schemaContent = JSON.stringify(schema);
80
- this.inmemoryResources.update(this.uri, schemaContent);
81
- }
82
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
83
- validate(data) {
84
- return !!this.doValidate && !!this.doValidate(data);
85
- }
86
- /**
87
- * Adds given task schema to `taskConfigurationSchema` as `oneOf` subschema.
88
- * Replaces existed subschema by given schema if the corresponding `$id` properties are equal.
89
- *
90
- * Note: please provide `$id` property for subschema to have ability remove/replace it.
91
- * @param schema subschema for adding to `taskConfigurationSchema`
92
- */
93
- addSubschema(schema) {
94
- const schemaId = schema.$id;
95
- if (schemaId) {
96
- this.doRemoveSubschema(schemaId);
97
- }
98
- customSchemas.push(schema);
99
- this.update();
100
- }
101
- /**
102
- * Removes task subschema from `taskConfigurationSchema`.
103
- *
104
- * @param arg `$id` property of subschema
105
- */
106
- removeSubschema(arg) {
107
- const isRemoved = this.doRemoveSubschema(arg);
108
- if (isRemoved) {
109
- this.update();
110
- }
111
- }
112
- /**
113
- * Removes task subschema from `customSchemas`, use `update()` to apply the changes for `taskConfigurationSchema`.
114
- *
115
- * @param arg `$id` property of subschema
116
- * @returns `true` if subschema was removed, `false` otherwise
117
- */
118
- doRemoveSubschema(arg) {
119
- const index = customSchemas.findIndex(existed => !!existed.$id && existed.$id === arg);
120
- if (index > -1) {
121
- customSchemas.splice(index, 1);
122
- return true;
123
- }
124
- return false;
125
- }
126
- /** Returns an array of task types that are registered, including the default types */
127
- async getRegisteredTaskTypes() {
128
- const serverSupportedTypes = await this.taskServer.getRegisteredTaskTypes();
129
- const browserSupportedTypes = this.taskDefinitionRegistry.getAll().map(def => def.taskType);
130
- const allTypes = new Set([...serverSupportedTypes, ...browserSupportedTypes]);
131
- return Array.from(allTypes.values()).sort();
132
- }
133
- updateSchemasForRegisteredTasks() {
134
- customizedDetectedTasks.length = 0;
135
- const definitions = this.taskDefinitionRegistry.getAll();
136
- definitions.forEach(def => {
137
- const customizedDetectedTask = {
138
- type: 'object',
139
- required: ['type'],
140
- properties: {}
141
- };
142
- const taskType = {
143
- ...defaultTaskType,
144
- enum: [def.taskType],
145
- default: def.taskType,
146
- description: 'The task type to customize'
147
- };
148
- customizedDetectedTask.properties.type = taskType;
149
- const required = def.properties.required || [];
150
- def.properties.all.forEach(taskProp => {
151
- if (required.find(requiredProp => requiredProp === taskProp)) { // property is mandatory
152
- customizedDetectedTask.required.push(taskProp);
153
- }
154
- customizedDetectedTask.properties[taskProp] = { ...def.properties.schema.properties[taskProp] };
155
- });
156
- customizedDetectedTask.properties.label = taskLabel;
157
- customizedDetectedTask.properties.problemMatcher = problemMatcher;
158
- customizedDetectedTask.properties.presentation = presentation;
159
- customizedDetectedTask.properties.options = commandOptionsSchema;
160
- customizedDetectedTask.properties.group = group;
161
- customizedDetectedTask.properties.detail = detail;
162
- customizedDetectedTask.additionalProperties = true;
163
- customizedDetectedTasks.push(customizedDetectedTask);
164
- });
165
- }
166
- /** Returns the task's JSON schema */
167
- getTaskSchema() {
168
- return {
169
- type: 'object',
170
- default: { version: '2.0.0', tasks: [] },
171
- properties: {
172
- version: {
173
- type: 'string',
174
- default: '2.0.0'
175
- },
176
- tasks: {
177
- type: 'array',
178
- items: {
179
- ...(0, common_1.deepClone)(taskConfigurationSchema)
180
- }
181
- },
182
- inputs: variable_input_schema_1.inputsSchema.definitions.inputs
183
- },
184
- additionalProperties: false,
185
- allowComments: true,
186
- allowTrailingCommas: true,
187
- };
188
- }
189
- /** Gets the most up-to-date names of problem matchers from the registry and update the task schema */
190
- updateProblemMatcherNames() {
191
- const matcherNames = this.problemMatcherRegistry.getAll().map(m => (0, common_2.asVariableName)(m.name));
192
- problemMatcherNames.length = 0;
193
- problemMatcherNames.push(...matcherNames);
194
- this.update();
195
- }
196
- async updateSupportedTaskTypes() {
197
- this.updateSchemasForRegisteredTasks();
198
- this.update();
199
- }
200
- };
201
- __decorate([
202
- (0, inversify_1.inject)(common_1.InMemoryResources),
203
- __metadata("design:type", common_1.InMemoryResources)
204
- ], TaskSchemaUpdater.prototype, "inmemoryResources", void 0);
205
- __decorate([
206
- (0, inversify_1.inject)(task_problem_matcher_registry_1.ProblemMatcherRegistry),
207
- __metadata("design:type", task_problem_matcher_registry_1.ProblemMatcherRegistry)
208
- ], TaskSchemaUpdater.prototype, "problemMatcherRegistry", void 0);
209
- __decorate([
210
- (0, inversify_1.inject)(task_definition_registry_1.TaskDefinitionRegistry),
211
- __metadata("design:type", task_definition_registry_1.TaskDefinitionRegistry)
212
- ], TaskSchemaUpdater.prototype, "taskDefinitionRegistry", void 0);
213
- __decorate([
214
- (0, inversify_1.inject)(common_2.TaskServer),
215
- __metadata("design:type", Object)
216
- ], TaskSchemaUpdater.prototype, "taskServer", void 0);
217
- __decorate([
218
- (0, inversify_1.inject)(browser_2.WorkspaceService),
219
- __metadata("design:type", browser_2.WorkspaceService)
220
- ], TaskSchemaUpdater.prototype, "workspaceService", void 0);
221
- __decorate([
222
- (0, inversify_1.postConstruct)(),
223
- __metadata("design:type", Function),
224
- __metadata("design:paramtypes", []),
225
- __metadata("design:returntype", void 0)
226
- ], TaskSchemaUpdater.prototype, "init", null);
227
- TaskSchemaUpdater = __decorate([
228
- (0, inversify_1.injectable)()
229
- ], TaskSchemaUpdater);
230
- exports.TaskSchemaUpdater = TaskSchemaUpdater;
231
- const commandSchema = {
232
- type: 'string',
233
- description: 'The actual command or script to execute'
234
- };
235
- const commandArgSchema = {
236
- type: 'array',
237
- description: 'A list of strings, each one being one argument to pass to the command',
238
- items: {
239
- type: 'string'
240
- }
241
- };
242
- const commandOptionsSchema = {
243
- type: 'object',
244
- description: 'The command options used when the command is executed',
245
- properties: {
246
- cwd: {
247
- type: 'string',
248
- description: 'The directory in which the command will be executed',
249
- default: '${workspaceFolder}'
250
- },
251
- env: {
252
- type: 'object',
253
- description: 'The environment of the executed program or shell. If omitted the parent process\' environment is used'
254
- },
255
- shell: {
256
- type: 'object',
257
- description: 'Configuration of the shell when task type is `shell`',
258
- properties: {
259
- executable: {
260
- type: 'string',
261
- description: 'The shell to use'
262
- },
263
- args: {
264
- type: 'array',
265
- description: `The arguments to be passed to the shell executable to run in command mode
266
- (e.g ['-c'] for bash or ['/S', '/C'] for cmd.exe)`,
267
- items: {
268
- type: 'string'
269
- }
270
- }
271
- }
272
- }
273
- }
274
- };
275
- const problemMatcherNames = [];
276
- const defaultTaskTypes = ['shell', 'process'];
277
- const supportedTaskTypes = [...defaultTaskTypes];
278
- const taskLabel = {
279
- type: 'string',
280
- description: 'A unique string that identifies the task that is also used as task\'s user interface label'
281
- };
282
- const defaultTaskType = {
283
- type: 'string',
284
- enum: supportedTaskTypes,
285
- default: defaultTaskTypes[0],
286
- description: 'Determines what type of process will be used to execute the task. Only shell types will have output shown on the user interface'
287
- };
288
- const commandAndArgs = {
289
- command: commandSchema,
290
- args: commandArgSchema,
291
- options: commandOptionsSchema
292
- };
293
- const group = {
294
- oneOf: [
295
- {
296
- type: 'string',
297
- enum: ['build', 'test', 'none'],
298
- enumDescriptions: [
299
- 'Marks the task as a build task accessible through the \'Run Build Task\' command.',
300
- 'Marks the task as a test task accessible through the \'Run Test Task\' command.',
301
- 'Assigns the task to no group'
302
- ]
303
- },
304
- {
305
- type: 'object',
306
- properties: {
307
- kind: {
308
- type: 'string',
309
- default: 'none',
310
- description: 'The task\'s execution group.',
311
- enum: ['build', 'test', 'none'],
312
- enumDescriptions: [
313
- 'Marks the task as a build task accessible through the \'Run Build Task\' command.',
314
- 'Marks the task as a test task accessible through the \'Run Test Task\' command.',
315
- 'Assigns the task to no group'
316
- ]
317
- },
318
- isDefault: {
319
- type: 'boolean',
320
- default: false,
321
- description: 'Defines if this task is the default task in the group.'
322
- }
323
- }
324
- }
325
- ],
326
- // eslint-disable-next-line max-len
327
- description: 'Defines to which execution group this task belongs to. It supports "build" to add it to the build group and "test" to add it to the test group.'
328
- };
329
- const problemPattern = {
330
- default: {
331
- regexp: '^([^\\\\s].*)\\\\((\\\\d+,\\\\d+)\\\\):\\\\s*(.*)$',
332
- file: 1,
333
- location: 2,
334
- message: 3
335
- },
336
- type: 'object',
337
- properties: {
338
- regexp: {
339
- type: 'string',
340
- description: 'The regular expression to find an error, warning or info in the output.'
341
- },
342
- kind: {
343
- type: 'string',
344
- description: 'whether the pattern matches a location (file and line) or only a file.'
345
- },
346
- file: {
347
- type: 'integer',
348
- description: 'The match group index of the filename. If omitted 1 is used.'
349
- },
350
- location: {
351
- type: 'integer',
352
- // eslint-disable-next-line max-len
353
- description: 'The match group index of the problem\'s location. Valid location patterns are: (line), (line,column) and (startLine,startColumn,endLine,endColumn). If omitted (line,column) is assumed.'
354
- },
355
- line: {
356
- type: 'integer',
357
- description: 'The match group index of the problem\'s line. Defaults to 2'
358
- },
359
- column: {
360
- type: 'integer',
361
- description: 'The match group index of the problem\'s line character. Defaults to 3'
362
- },
363
- endLine: {
364
- type: 'integer',
365
- description: 'The match group index of the problem\'s end line. Defaults to undefined'
366
- },
367
- endColumn: {
368
- type: 'integer',
369
- description: 'The match group index of the problem\'s end line character. Defaults to undefined'
370
- },
371
- severity: {
372
- type: 'integer',
373
- description: 'The match group index of the problem\'s severity. Defaults to undefined'
374
- },
375
- code: {
376
- type: 'integer',
377
- description: 'The match group index of the problem\'s code. Defaults to undefined'
378
- },
379
- message: {
380
- type: 'integer',
381
- description: 'The match group index of the message. If omitted it defaults to 4 if location is specified. Otherwise it defaults to 5.'
382
- },
383
- loop: {
384
- type: 'boolean',
385
- // eslint-disable-next-line max-len
386
- description: 'In a multi line matcher loop indicated whether this pattern is executed in a loop as long as it matches. Can only specified on a last pattern in a multi line pattern.'
387
- }
388
- }
389
- };
390
- const multiLineProblemPattern = {
391
- type: 'array',
392
- items: problemPattern
393
- };
394
- const watchingPattern = {
395
- type: 'object',
396
- additionalProperties: false,
397
- properties: {
398
- regexp: {
399
- type: 'string',
400
- description: 'The regular expression to detect the begin or end of a background task.'
401
- },
402
- file: {
403
- type: 'integer',
404
- description: 'The match group index of the filename. Can be omitted.'
405
- },
406
- }
407
- };
408
- const patternType = {
409
- anyOf: [
410
- {
411
- type: 'string',
412
- description: 'The name of a contributed or predefined pattern'
413
- },
414
- problemPattern,
415
- multiLineProblemPattern
416
- ],
417
- description: 'A problem pattern or the name of a contributed or predefined problem pattern. Can be omitted if base is specified.'
418
- };
419
- const problemMatcherObject = {
420
- type: 'object',
421
- properties: {
422
- base: {
423
- type: 'string',
424
- enum: problemMatcherNames,
425
- description: 'The name of a base problem matcher to use.'
426
- },
427
- owner: {
428
- type: 'string',
429
- description: 'The owner of the problem inside Code. Can be omitted if base is specified. Defaults to \'external\' if omitted and base is not specified.'
430
- },
431
- source: {
432
- type: 'string',
433
- description: 'A human-readable string describing the source of this diagnostic, e.g. \'typescript\' or \'super lint\'.'
434
- },
435
- severity: {
436
- type: 'string',
437
- enum: ['error', 'warning', 'info'],
438
- description: 'The default severity for captures problems. Is used if the pattern doesn\'t define a match group for severity.'
439
- },
440
- applyTo: {
441
- type: 'string',
442
- enum: ['allDocuments', 'openDocuments', 'closedDocuments'],
443
- description: 'Controls if a problem reported on a text document is applied only to open, closed or all documents.'
444
- },
445
- pattern: patternType,
446
- fileLocation: {
447
- oneOf: [
448
- {
449
- type: 'string',
450
- enum: ['absolute', 'relative', 'autoDetect']
451
- },
452
- {
453
- type: 'array',
454
- items: {
455
- type: 'string'
456
- }
457
- }
458
- ],
459
- description: 'Defines how file names reported in a problem pattern should be interpreted.'
460
- },
461
- background: {
462
- type: 'object',
463
- additionalProperties: false,
464
- description: 'Patterns to track the begin and end of a matcher active on a background task.',
465
- properties: {
466
- activeOnStart: {
467
- type: 'boolean',
468
- description: 'If set to true the background monitor is in active mode when the task starts. This is equals of issuing a line that matches the beginsPattern'
469
- },
470
- beginsPattern: {
471
- oneOf: [
472
- {
473
- type: 'string'
474
- },
475
- watchingPattern
476
- ],
477
- description: 'If matched in the output the start of a background task is signaled.'
478
- },
479
- endsPattern: {
480
- oneOf: [
481
- {
482
- type: 'string'
483
- },
484
- watchingPattern
485
- ],
486
- description: 'If matched in the output the end of a background task is signaled.'
487
- }
488
- }
489
- },
490
- watching: {
491
- type: 'object',
492
- additionalProperties: false,
493
- deprecationMessage: 'The watching property is deprecated. Use background instead.',
494
- description: 'Patterns to track the begin and end of a watching matcher.',
495
- properties: {
496
- activeOnStart: {
497
- type: 'boolean',
498
- description: 'If set to true the watcher is in active mode when the task starts. This is equals of issuing a line that matches the beginPattern'
499
- },
500
- beginsPattern: {
501
- oneOf: [
502
- {
503
- type: 'string'
504
- },
505
- watchingPattern
506
- ],
507
- description: 'If matched in the output the start of a watching task is signaled.'
508
- },
509
- endsPattern: {
510
- oneOf: [
511
- {
512
- type: 'string'
513
- },
514
- watchingPattern
515
- ],
516
- description: 'If matched in the output the end of a watching task is signaled.'
517
- }
518
- }
519
- }
520
- }
521
- };
522
- const problemMatcher = {
523
- anyOf: [
524
- {
525
- type: 'string',
526
- description: 'Name of the problem matcher to parse the output of the task',
527
- enum: problemMatcherNames
528
- },
529
- {
530
- type: 'array',
531
- description: 'Name(s) of the problem matcher(s) to parse the output of the task',
532
- items: {
533
- type: 'string',
534
- enum: problemMatcherNames
535
- }
536
- },
537
- problemMatcherObject,
538
- {
539
- type: 'array',
540
- description: 'User defined problem matcher(s) to parse the output of the task',
541
- items: problemMatcherObject
542
- }
543
- ]
544
- };
545
- const presentation = {
546
- type: 'object',
547
- default: {
548
- echo: true,
549
- reveal: 'always',
550
- focus: false,
551
- panel: 'shared',
552
- showReuseMessage: true,
553
- clear: false
554
- },
555
- description: 'Configures the panel that is used to present the task\'s output and reads its input.',
556
- additionalProperties: true,
557
- properties: {
558
- echo: {
559
- type: 'boolean',
560
- default: true,
561
- description: 'Controls whether the executed command is echoed to the panel. Default is true.'
562
- },
563
- focus: {
564
- type: 'boolean',
565
- default: false,
566
- description: 'Controls whether the panel takes focus. Default is false. If set to true the panel is revealed as well.'
567
- },
568
- reveal: {
569
- type: 'string',
570
- enum: ['always', 'silent', 'never'],
571
- enumDescriptions: [
572
- 'Always reveals the terminal when this task is executed.',
573
- 'Only reveals the terminal if the task exits with an error or the problem matcher finds an error.',
574
- 'Never reveals the terminal when this task is executed.'
575
- ],
576
- default: 'always',
577
- description: 'Controls whether the terminal running the task is revealed or not. May be overridden by option \"revealProblems\". Default is \"always\".'
578
- },
579
- panel: {
580
- type: 'string',
581
- enum: ['shared', 'dedicated', 'new'],
582
- enumDescriptions: [
583
- 'The terminal is shared and the output of other task runs are added to the same terminal.',
584
- // eslint-disable-next-line max-len
585
- 'The terminal is dedicated to a specific task. If that task is executed again, the terminal is reused. However, the output of a different task is presented in a different terminal.',
586
- 'Every execution of that task is using a new clean terminal.'
587
- ],
588
- default: 'shared',
589
- description: 'Controls if the panel is shared between tasks, dedicated to this task or a new one is created on every run.'
590
- },
591
- showReuseMessage: {
592
- type: 'boolean',
593
- default: true,
594
- description: 'Controls whether to show the "Terminal will be reused by tasks" message.'
595
- },
596
- clear: {
597
- type: 'boolean',
598
- default: false,
599
- description: 'Controls whether the terminal is cleared before this task is run.'
600
- }
601
- }
602
- };
603
- const detail = {
604
- type: 'string',
605
- description: 'An optional description of a task that shows in the Run Task quick pick as a detail.'
606
- };
607
- const taskIdentifier = {
608
- type: 'object',
609
- additionalProperties: true,
610
- properties: {
611
- type: {
612
- type: 'string',
613
- description: 'The task identifier.'
614
- }
615
- }
616
- };
617
- const processTaskConfigurationSchema = {
618
- type: 'object',
619
- required: ['type', 'label', 'command'],
620
- properties: {
621
- label: taskLabel,
622
- type: defaultTaskType,
623
- ...commandAndArgs,
624
- isBackground: {
625
- type: 'boolean',
626
- default: false,
627
- description: 'Whether the executed task is kept alive and is running in the background.'
628
- },
629
- dependsOn: {
630
- anyOf: [
631
- {
632
- type: 'string',
633
- description: 'Another task this task depends on.'
634
- },
635
- taskIdentifier,
636
- {
637
- type: 'array',
638
- description: 'The other tasks this task depends on.',
639
- items: {
640
- anyOf: [
641
- {
642
- type: 'string'
643
- },
644
- taskIdentifier
645
- ]
646
- }
647
- }
648
- ],
649
- description: 'Either a string representing another task or an array of other tasks that this task depends on.'
650
- },
651
- dependsOrder: {
652
- type: 'string',
653
- enum: ['parallel', 'sequence'],
654
- enumDescriptions: [
655
- 'Run all dependsOn tasks in parallel.',
656
- 'Run all dependsOn tasks in sequence.'
657
- ],
658
- default: 'parallel',
659
- description: 'Determines the order of the dependsOn tasks for this task. Note that this property is not recursive.'
660
- },
661
- windows: {
662
- type: 'object',
663
- description: 'Windows specific command configuration that overrides the command, args, and options',
664
- properties: commandAndArgs
665
- },
666
- osx: {
667
- type: 'object',
668
- description: 'MacOS specific command configuration that overrides the command, args, and options',
669
- properties: commandAndArgs
670
- },
671
- linux: {
672
- type: 'object',
673
- description: 'Linux specific command configuration that overrides the default command, args, and options',
674
- properties: commandAndArgs
675
- },
676
- group,
677
- problemMatcher,
678
- presentation,
679
- detail,
680
- },
681
- additionalProperties: true
682
- };
683
- const customizedDetectedTasks = [];
684
- const customSchemas = [];
685
- const taskConfigurationSchema = {
686
- $id: exports.taskSchemaId,
687
- anyOf: [processTaskConfigurationSchema, ...customizedDetectedTasks, ...customSchemas]
688
- };
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2019 Red Hat, Inc. and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ // This file is inspired by VSCode and partially copied from https://github.com/Microsoft/vscode/blob/1.33.1/src/vs/workbench/contrib/tasks/common/problemMatcher.ts
18
+ // 'problemMatcher.ts' copyright:
19
+ /*---------------------------------------------------------------------------------------------
20
+ * Copyright (c) Microsoft Corporation. All rights reserved.
21
+ * Licensed under the MIT License. See License.txt in the project root for license information.
22
+ *--------------------------------------------------------------------------------------------*/
23
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
24
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
25
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
26
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
27
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
28
+ };
29
+ var __metadata = (this && this.__metadata) || function (k, v) {
30
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
31
+ };
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ exports.TaskSchemaUpdater = exports.taskSchemaId = void 0;
34
+ const Ajv = require("@theia/core/shared/ajv");
35
+ const debounce = require("p-debounce");
36
+ const inversify_1 = require("@theia/core/shared/inversify");
37
+ const common_1 = require("@theia/core/lib/common");
38
+ const variable_input_schema_1 = require("@theia/variable-resolver/lib/browser/variable-input-schema");
39
+ const uri_1 = require("@theia/core/lib/common/uri");
40
+ const task_problem_matcher_registry_1 = require("./task-problem-matcher-registry");
41
+ const task_definition_registry_1 = require("./task-definition-registry");
42
+ const common_2 = require("../common");
43
+ const browser_1 = require("@theia/userstorage/lib/browser");
44
+ const browser_2 = require("@theia/workspace/lib/browser");
45
+ exports.taskSchemaId = 'vscode://schemas/tasks';
46
+ let TaskSchemaUpdater = class TaskSchemaUpdater {
47
+ constructor() {
48
+ this.onDidChangeTaskSchemaEmitter = new common_1.Emitter();
49
+ this.onDidChangeTaskSchema = this.onDidChangeTaskSchemaEmitter.event;
50
+ this.uri = new uri_1.default(exports.taskSchemaId);
51
+ this.update = debounce(() => this.doUpdate(), 0);
52
+ }
53
+ init() {
54
+ const resource = this.inmemoryResources.add(this.uri, '');
55
+ if (resource.onDidChangeContents) {
56
+ resource.onDidChangeContents(() => {
57
+ this.onDidChangeTaskSchemaEmitter.fire(undefined);
58
+ });
59
+ }
60
+ this.updateProblemMatcherNames();
61
+ this.updateSupportedTaskTypes();
62
+ // update problem matcher names in the task schema every time a problem matcher is added or disposed
63
+ this.problemMatcherRegistry.onDidChangeProblemMatcher(() => this.updateProblemMatcherNames());
64
+ // update supported task types in the task schema every time a task definition is registered or removed
65
+ this.taskDefinitionRegistry.onDidRegisterTaskDefinition(() => this.updateSupportedTaskTypes());
66
+ this.taskDefinitionRegistry.onDidUnregisterTaskDefinition(() => this.updateSupportedTaskTypes());
67
+ }
68
+ registerSchemas(context) {
69
+ context.registerSchema({
70
+ fileMatch: ['tasks.json', browser_1.UserStorageUri.resolve('tasks.json').toString()],
71
+ url: this.uri.toString()
72
+ });
73
+ this.workspaceService.updateSchema('tasks', { $ref: this.uri.toString() });
74
+ }
75
+ doUpdate() {
76
+ taskConfigurationSchema.anyOf = [processTaskConfigurationSchema, ...customizedDetectedTasks, ...customSchemas];
77
+ const schema = this.getTaskSchema();
78
+ this.doValidate = new Ajv().compile(schema);
79
+ const schemaContent = JSON.stringify(schema);
80
+ this.inmemoryResources.update(this.uri, schemaContent);
81
+ }
82
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
83
+ validate(data) {
84
+ return !!this.doValidate && !!this.doValidate(data);
85
+ }
86
+ /**
87
+ * Adds given task schema to `taskConfigurationSchema` as `oneOf` subschema.
88
+ * Replaces existed subschema by given schema if the corresponding `$id` properties are equal.
89
+ *
90
+ * Note: please provide `$id` property for subschema to have ability remove/replace it.
91
+ * @param schema subschema for adding to `taskConfigurationSchema`
92
+ */
93
+ addSubschema(schema) {
94
+ const schemaId = schema.$id;
95
+ if (schemaId) {
96
+ this.doRemoveSubschema(schemaId);
97
+ }
98
+ customSchemas.push(schema);
99
+ this.update();
100
+ }
101
+ /**
102
+ * Removes task subschema from `taskConfigurationSchema`.
103
+ *
104
+ * @param arg `$id` property of subschema
105
+ */
106
+ removeSubschema(arg) {
107
+ const isRemoved = this.doRemoveSubschema(arg);
108
+ if (isRemoved) {
109
+ this.update();
110
+ }
111
+ }
112
+ /**
113
+ * Removes task subschema from `customSchemas`, use `update()` to apply the changes for `taskConfigurationSchema`.
114
+ *
115
+ * @param arg `$id` property of subschema
116
+ * @returns `true` if subschema was removed, `false` otherwise
117
+ */
118
+ doRemoveSubschema(arg) {
119
+ const index = customSchemas.findIndex(existed => !!existed.$id && existed.$id === arg);
120
+ if (index > -1) {
121
+ customSchemas.splice(index, 1);
122
+ return true;
123
+ }
124
+ return false;
125
+ }
126
+ /** Returns an array of task types that are registered, including the default types */
127
+ async getRegisteredTaskTypes() {
128
+ const serverSupportedTypes = await this.taskServer.getRegisteredTaskTypes();
129
+ const browserSupportedTypes = this.taskDefinitionRegistry.getAll().map(def => def.taskType);
130
+ const allTypes = new Set([...serverSupportedTypes, ...browserSupportedTypes]);
131
+ return Array.from(allTypes.values()).sort();
132
+ }
133
+ updateSchemasForRegisteredTasks() {
134
+ customizedDetectedTasks.length = 0;
135
+ const definitions = this.taskDefinitionRegistry.getAll();
136
+ definitions.forEach(def => {
137
+ const customizedDetectedTask = {
138
+ type: 'object',
139
+ required: ['type'],
140
+ properties: {}
141
+ };
142
+ const taskType = {
143
+ ...defaultTaskType,
144
+ enum: [def.taskType],
145
+ default: def.taskType,
146
+ description: 'The task type to customize'
147
+ };
148
+ customizedDetectedTask.properties.type = taskType;
149
+ const required = def.properties.required || [];
150
+ def.properties.all.forEach(taskProp => {
151
+ if (required.find(requiredProp => requiredProp === taskProp)) { // property is mandatory
152
+ customizedDetectedTask.required.push(taskProp);
153
+ }
154
+ customizedDetectedTask.properties[taskProp] = { ...def.properties.schema.properties[taskProp] };
155
+ });
156
+ customizedDetectedTask.properties.label = taskLabel;
157
+ customizedDetectedTask.properties.problemMatcher = problemMatcher;
158
+ customizedDetectedTask.properties.presentation = presentation;
159
+ customizedDetectedTask.properties.options = commandOptionsSchema;
160
+ customizedDetectedTask.properties.group = group;
161
+ customizedDetectedTask.properties.detail = detail;
162
+ customizedDetectedTask.additionalProperties = true;
163
+ customizedDetectedTasks.push(customizedDetectedTask);
164
+ });
165
+ }
166
+ /** Returns the task's JSON schema */
167
+ getTaskSchema() {
168
+ return {
169
+ type: 'object',
170
+ default: { version: '2.0.0', tasks: [] },
171
+ properties: {
172
+ version: {
173
+ type: 'string',
174
+ default: '2.0.0'
175
+ },
176
+ tasks: {
177
+ type: 'array',
178
+ items: {
179
+ ...(0, common_1.deepClone)(taskConfigurationSchema)
180
+ }
181
+ },
182
+ inputs: variable_input_schema_1.inputsSchema.definitions.inputs
183
+ },
184
+ additionalProperties: false,
185
+ allowComments: true,
186
+ allowTrailingCommas: true,
187
+ };
188
+ }
189
+ /** Gets the most up-to-date names of problem matchers from the registry and update the task schema */
190
+ updateProblemMatcherNames() {
191
+ const matcherNames = this.problemMatcherRegistry.getAll().map(m => (0, common_2.asVariableName)(m.name));
192
+ problemMatcherNames.length = 0;
193
+ problemMatcherNames.push(...matcherNames);
194
+ this.update();
195
+ }
196
+ async updateSupportedTaskTypes() {
197
+ this.updateSchemasForRegisteredTasks();
198
+ this.update();
199
+ }
200
+ };
201
+ __decorate([
202
+ (0, inversify_1.inject)(common_1.InMemoryResources),
203
+ __metadata("design:type", common_1.InMemoryResources)
204
+ ], TaskSchemaUpdater.prototype, "inmemoryResources", void 0);
205
+ __decorate([
206
+ (0, inversify_1.inject)(task_problem_matcher_registry_1.ProblemMatcherRegistry),
207
+ __metadata("design:type", task_problem_matcher_registry_1.ProblemMatcherRegistry)
208
+ ], TaskSchemaUpdater.prototype, "problemMatcherRegistry", void 0);
209
+ __decorate([
210
+ (0, inversify_1.inject)(task_definition_registry_1.TaskDefinitionRegistry),
211
+ __metadata("design:type", task_definition_registry_1.TaskDefinitionRegistry)
212
+ ], TaskSchemaUpdater.prototype, "taskDefinitionRegistry", void 0);
213
+ __decorate([
214
+ (0, inversify_1.inject)(common_2.TaskServer),
215
+ __metadata("design:type", Object)
216
+ ], TaskSchemaUpdater.prototype, "taskServer", void 0);
217
+ __decorate([
218
+ (0, inversify_1.inject)(browser_2.WorkspaceService),
219
+ __metadata("design:type", browser_2.WorkspaceService)
220
+ ], TaskSchemaUpdater.prototype, "workspaceService", void 0);
221
+ __decorate([
222
+ (0, inversify_1.postConstruct)(),
223
+ __metadata("design:type", Function),
224
+ __metadata("design:paramtypes", []),
225
+ __metadata("design:returntype", void 0)
226
+ ], TaskSchemaUpdater.prototype, "init", null);
227
+ TaskSchemaUpdater = __decorate([
228
+ (0, inversify_1.injectable)()
229
+ ], TaskSchemaUpdater);
230
+ exports.TaskSchemaUpdater = TaskSchemaUpdater;
231
+ const commandSchema = {
232
+ type: 'string',
233
+ description: 'The actual command or script to execute'
234
+ };
235
+ const commandArgSchema = {
236
+ type: 'array',
237
+ description: 'A list of strings, each one being one argument to pass to the command',
238
+ items: {
239
+ type: 'string'
240
+ }
241
+ };
242
+ const commandOptionsSchema = {
243
+ type: 'object',
244
+ description: 'The command options used when the command is executed',
245
+ properties: {
246
+ cwd: {
247
+ type: 'string',
248
+ description: 'The directory in which the command will be executed',
249
+ default: '${workspaceFolder}'
250
+ },
251
+ env: {
252
+ type: 'object',
253
+ description: 'The environment of the executed program or shell. If omitted the parent process\' environment is used'
254
+ },
255
+ shell: {
256
+ type: 'object',
257
+ description: 'Configuration of the shell when task type is `shell`',
258
+ properties: {
259
+ executable: {
260
+ type: 'string',
261
+ description: 'The shell to use'
262
+ },
263
+ args: {
264
+ type: 'array',
265
+ description: `The arguments to be passed to the shell executable to run in command mode
266
+ (e.g ['-c'] for bash or ['/S', '/C'] for cmd.exe)`,
267
+ items: {
268
+ type: 'string'
269
+ }
270
+ }
271
+ }
272
+ }
273
+ }
274
+ };
275
+ const problemMatcherNames = [];
276
+ const defaultTaskTypes = ['shell', 'process'];
277
+ const supportedTaskTypes = [...defaultTaskTypes];
278
+ const taskLabel = {
279
+ type: 'string',
280
+ description: 'A unique string that identifies the task that is also used as task\'s user interface label'
281
+ };
282
+ const defaultTaskType = {
283
+ type: 'string',
284
+ enum: supportedTaskTypes,
285
+ default: defaultTaskTypes[0],
286
+ description: 'Determines what type of process will be used to execute the task. Only shell types will have output shown on the user interface'
287
+ };
288
+ const commandAndArgs = {
289
+ command: commandSchema,
290
+ args: commandArgSchema,
291
+ options: commandOptionsSchema
292
+ };
293
+ const group = {
294
+ oneOf: [
295
+ {
296
+ type: 'string',
297
+ enum: ['build', 'test', 'none'],
298
+ enumDescriptions: [
299
+ 'Marks the task as a build task accessible through the \'Run Build Task\' command.',
300
+ 'Marks the task as a test task accessible through the \'Run Test Task\' command.',
301
+ 'Assigns the task to no group'
302
+ ]
303
+ },
304
+ {
305
+ type: 'object',
306
+ properties: {
307
+ kind: {
308
+ type: 'string',
309
+ default: 'none',
310
+ description: 'The task\'s execution group.',
311
+ enum: ['build', 'test', 'none'],
312
+ enumDescriptions: [
313
+ 'Marks the task as a build task accessible through the \'Run Build Task\' command.',
314
+ 'Marks the task as a test task accessible through the \'Run Test Task\' command.',
315
+ 'Assigns the task to no group'
316
+ ]
317
+ },
318
+ isDefault: {
319
+ type: 'boolean',
320
+ default: false,
321
+ description: 'Defines if this task is the default task in the group.'
322
+ }
323
+ }
324
+ }
325
+ ],
326
+ // eslint-disable-next-line max-len
327
+ description: 'Defines to which execution group this task belongs to. It supports "build" to add it to the build group and "test" to add it to the test group.'
328
+ };
329
+ const problemPattern = {
330
+ default: {
331
+ regexp: '^([^\\\\s].*)\\\\((\\\\d+,\\\\d+)\\\\):\\\\s*(.*)$',
332
+ file: 1,
333
+ location: 2,
334
+ message: 3
335
+ },
336
+ type: 'object',
337
+ properties: {
338
+ regexp: {
339
+ type: 'string',
340
+ description: 'The regular expression to find an error, warning or info in the output.'
341
+ },
342
+ kind: {
343
+ type: 'string',
344
+ description: 'whether the pattern matches a location (file and line) or only a file.'
345
+ },
346
+ file: {
347
+ type: 'integer',
348
+ description: 'The match group index of the filename. If omitted 1 is used.'
349
+ },
350
+ location: {
351
+ type: 'integer',
352
+ // eslint-disable-next-line max-len
353
+ description: 'The match group index of the problem\'s location. Valid location patterns are: (line), (line,column) and (startLine,startColumn,endLine,endColumn). If omitted (line,column) is assumed.'
354
+ },
355
+ line: {
356
+ type: 'integer',
357
+ description: 'The match group index of the problem\'s line. Defaults to 2'
358
+ },
359
+ column: {
360
+ type: 'integer',
361
+ description: 'The match group index of the problem\'s line character. Defaults to 3'
362
+ },
363
+ endLine: {
364
+ type: 'integer',
365
+ description: 'The match group index of the problem\'s end line. Defaults to undefined'
366
+ },
367
+ endColumn: {
368
+ type: 'integer',
369
+ description: 'The match group index of the problem\'s end line character. Defaults to undefined'
370
+ },
371
+ severity: {
372
+ type: 'integer',
373
+ description: 'The match group index of the problem\'s severity. Defaults to undefined'
374
+ },
375
+ code: {
376
+ type: 'integer',
377
+ description: 'The match group index of the problem\'s code. Defaults to undefined'
378
+ },
379
+ message: {
380
+ type: 'integer',
381
+ description: 'The match group index of the message. If omitted it defaults to 4 if location is specified. Otherwise it defaults to 5.'
382
+ },
383
+ loop: {
384
+ type: 'boolean',
385
+ // eslint-disable-next-line max-len
386
+ description: 'In a multi line matcher loop indicated whether this pattern is executed in a loop as long as it matches. Can only specified on a last pattern in a multi line pattern.'
387
+ }
388
+ }
389
+ };
390
+ const multiLineProblemPattern = {
391
+ type: 'array',
392
+ items: problemPattern
393
+ };
394
+ const watchingPattern = {
395
+ type: 'object',
396
+ additionalProperties: false,
397
+ properties: {
398
+ regexp: {
399
+ type: 'string',
400
+ description: 'The regular expression to detect the begin or end of a background task.'
401
+ },
402
+ file: {
403
+ type: 'integer',
404
+ description: 'The match group index of the filename. Can be omitted.'
405
+ },
406
+ }
407
+ };
408
+ const patternType = {
409
+ anyOf: [
410
+ {
411
+ type: 'string',
412
+ description: 'The name of a contributed or predefined pattern'
413
+ },
414
+ problemPattern,
415
+ multiLineProblemPattern
416
+ ],
417
+ description: 'A problem pattern or the name of a contributed or predefined problem pattern. Can be omitted if base is specified.'
418
+ };
419
+ const problemMatcherObject = {
420
+ type: 'object',
421
+ properties: {
422
+ base: {
423
+ type: 'string',
424
+ enum: problemMatcherNames,
425
+ description: 'The name of a base problem matcher to use.'
426
+ },
427
+ owner: {
428
+ type: 'string',
429
+ description: 'The owner of the problem inside Code. Can be omitted if base is specified. Defaults to \'external\' if omitted and base is not specified.'
430
+ },
431
+ source: {
432
+ type: 'string',
433
+ description: 'A human-readable string describing the source of this diagnostic, e.g. \'typescript\' or \'super lint\'.'
434
+ },
435
+ severity: {
436
+ type: 'string',
437
+ enum: ['error', 'warning', 'info'],
438
+ description: 'The default severity for captures problems. Is used if the pattern doesn\'t define a match group for severity.'
439
+ },
440
+ applyTo: {
441
+ type: 'string',
442
+ enum: ['allDocuments', 'openDocuments', 'closedDocuments'],
443
+ description: 'Controls if a problem reported on a text document is applied only to open, closed or all documents.'
444
+ },
445
+ pattern: patternType,
446
+ fileLocation: {
447
+ oneOf: [
448
+ {
449
+ type: 'string',
450
+ enum: ['absolute', 'relative', 'autoDetect']
451
+ },
452
+ {
453
+ type: 'array',
454
+ items: {
455
+ type: 'string'
456
+ }
457
+ }
458
+ ],
459
+ description: 'Defines how file names reported in a problem pattern should be interpreted.'
460
+ },
461
+ background: {
462
+ type: 'object',
463
+ additionalProperties: false,
464
+ description: 'Patterns to track the begin and end of a matcher active on a background task.',
465
+ properties: {
466
+ activeOnStart: {
467
+ type: 'boolean',
468
+ description: 'If set to true the background monitor is in active mode when the task starts. This is equals of issuing a line that matches the beginsPattern'
469
+ },
470
+ beginsPattern: {
471
+ oneOf: [
472
+ {
473
+ type: 'string'
474
+ },
475
+ watchingPattern
476
+ ],
477
+ description: 'If matched in the output the start of a background task is signaled.'
478
+ },
479
+ endsPattern: {
480
+ oneOf: [
481
+ {
482
+ type: 'string'
483
+ },
484
+ watchingPattern
485
+ ],
486
+ description: 'If matched in the output the end of a background task is signaled.'
487
+ }
488
+ }
489
+ },
490
+ watching: {
491
+ type: 'object',
492
+ additionalProperties: false,
493
+ deprecationMessage: 'The watching property is deprecated. Use background instead.',
494
+ description: 'Patterns to track the begin and end of a watching matcher.',
495
+ properties: {
496
+ activeOnStart: {
497
+ type: 'boolean',
498
+ description: 'If set to true the watcher is in active mode when the task starts. This is equals of issuing a line that matches the beginPattern'
499
+ },
500
+ beginsPattern: {
501
+ oneOf: [
502
+ {
503
+ type: 'string'
504
+ },
505
+ watchingPattern
506
+ ],
507
+ description: 'If matched in the output the start of a watching task is signaled.'
508
+ },
509
+ endsPattern: {
510
+ oneOf: [
511
+ {
512
+ type: 'string'
513
+ },
514
+ watchingPattern
515
+ ],
516
+ description: 'If matched in the output the end of a watching task is signaled.'
517
+ }
518
+ }
519
+ }
520
+ }
521
+ };
522
+ const problemMatcher = {
523
+ anyOf: [
524
+ {
525
+ type: 'string',
526
+ description: 'Name of the problem matcher to parse the output of the task',
527
+ enum: problemMatcherNames
528
+ },
529
+ {
530
+ type: 'array',
531
+ description: 'Name(s) of the problem matcher(s) to parse the output of the task',
532
+ items: {
533
+ type: 'string',
534
+ enum: problemMatcherNames
535
+ }
536
+ },
537
+ problemMatcherObject,
538
+ {
539
+ type: 'array',
540
+ description: 'User defined problem matcher(s) to parse the output of the task',
541
+ items: problemMatcherObject
542
+ }
543
+ ]
544
+ };
545
+ const presentation = {
546
+ type: 'object',
547
+ default: {
548
+ echo: true,
549
+ reveal: 'always',
550
+ focus: false,
551
+ panel: 'shared',
552
+ showReuseMessage: true,
553
+ clear: false
554
+ },
555
+ description: 'Configures the panel that is used to present the task\'s output and reads its input.',
556
+ additionalProperties: true,
557
+ properties: {
558
+ echo: {
559
+ type: 'boolean',
560
+ default: true,
561
+ description: 'Controls whether the executed command is echoed to the panel. Default is true.'
562
+ },
563
+ focus: {
564
+ type: 'boolean',
565
+ default: false,
566
+ description: 'Controls whether the panel takes focus. Default is false. If set to true the panel is revealed as well.'
567
+ },
568
+ reveal: {
569
+ type: 'string',
570
+ enum: ['always', 'silent', 'never'],
571
+ enumDescriptions: [
572
+ 'Always reveals the terminal when this task is executed.',
573
+ 'Only reveals the terminal if the task exits with an error or the problem matcher finds an error.',
574
+ 'Never reveals the terminal when this task is executed.'
575
+ ],
576
+ default: 'always',
577
+ description: 'Controls whether the terminal running the task is revealed or not. May be overridden by option \"revealProblems\". Default is \"always\".'
578
+ },
579
+ panel: {
580
+ type: 'string',
581
+ enum: ['shared', 'dedicated', 'new'],
582
+ enumDescriptions: [
583
+ 'The terminal is shared and the output of other task runs are added to the same terminal.',
584
+ // eslint-disable-next-line max-len
585
+ 'The terminal is dedicated to a specific task. If that task is executed again, the terminal is reused. However, the output of a different task is presented in a different terminal.',
586
+ 'Every execution of that task is using a new clean terminal.'
587
+ ],
588
+ default: 'shared',
589
+ description: 'Controls if the panel is shared between tasks, dedicated to this task or a new one is created on every run.'
590
+ },
591
+ showReuseMessage: {
592
+ type: 'boolean',
593
+ default: true,
594
+ description: 'Controls whether to show the "Terminal will be reused by tasks" message.'
595
+ },
596
+ clear: {
597
+ type: 'boolean',
598
+ default: false,
599
+ description: 'Controls whether the terminal is cleared before this task is run.'
600
+ }
601
+ }
602
+ };
603
+ const detail = {
604
+ type: 'string',
605
+ description: 'An optional description of a task that shows in the Run Task quick pick as a detail.'
606
+ };
607
+ const taskIdentifier = {
608
+ type: 'object',
609
+ additionalProperties: true,
610
+ properties: {
611
+ type: {
612
+ type: 'string',
613
+ description: 'The task identifier.'
614
+ }
615
+ }
616
+ };
617
+ const processTaskConfigurationSchema = {
618
+ type: 'object',
619
+ required: ['type', 'label', 'command'],
620
+ properties: {
621
+ label: taskLabel,
622
+ type: defaultTaskType,
623
+ ...commandAndArgs,
624
+ isBackground: {
625
+ type: 'boolean',
626
+ default: false,
627
+ description: 'Whether the executed task is kept alive and is running in the background.'
628
+ },
629
+ dependsOn: {
630
+ anyOf: [
631
+ {
632
+ type: 'string',
633
+ description: 'Another task this task depends on.'
634
+ },
635
+ taskIdentifier,
636
+ {
637
+ type: 'array',
638
+ description: 'The other tasks this task depends on.',
639
+ items: {
640
+ anyOf: [
641
+ {
642
+ type: 'string'
643
+ },
644
+ taskIdentifier
645
+ ]
646
+ }
647
+ }
648
+ ],
649
+ description: 'Either a string representing another task or an array of other tasks that this task depends on.'
650
+ },
651
+ dependsOrder: {
652
+ type: 'string',
653
+ enum: ['parallel', 'sequence'],
654
+ enumDescriptions: [
655
+ 'Run all dependsOn tasks in parallel.',
656
+ 'Run all dependsOn tasks in sequence.'
657
+ ],
658
+ default: 'parallel',
659
+ description: 'Determines the order of the dependsOn tasks for this task. Note that this property is not recursive.'
660
+ },
661
+ windows: {
662
+ type: 'object',
663
+ description: 'Windows specific command configuration that overrides the command, args, and options',
664
+ properties: commandAndArgs
665
+ },
666
+ osx: {
667
+ type: 'object',
668
+ description: 'MacOS specific command configuration that overrides the command, args, and options',
669
+ properties: commandAndArgs
670
+ },
671
+ linux: {
672
+ type: 'object',
673
+ description: 'Linux specific command configuration that overrides the default command, args, and options',
674
+ properties: commandAndArgs
675
+ },
676
+ group,
677
+ problemMatcher,
678
+ presentation,
679
+ detail,
680
+ },
681
+ additionalProperties: true
682
+ };
683
+ const customizedDetectedTasks = [];
684
+ const customSchemas = [];
685
+ const taskConfigurationSchema = {
686
+ $id: exports.taskSchemaId,
687
+ anyOf: [processTaskConfigurationSchema, ...customizedDetectedTasks, ...customSchemas]
688
+ };
689
689
  //# sourceMappingURL=task-schema-updater.js.map