azure-pipelines-task-lib 5.0.1-preview.0 → 5.1.0
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.
- package/Strings/resources.resjson/de-DE/resources.resjson +35 -34
- package/Strings/resources.resjson/en-US/resources.resjson +24 -20
- package/Strings/resources.resjson/es-ES/resources.resjson +35 -34
- package/Strings/resources.resjson/fr-FR/resources.resjson +35 -34
- package/Strings/resources.resjson/it-IT/resources.resjson +2 -1
- package/Strings/resources.resjson/ja-JP/resources.resjson +35 -34
- package/Strings/resources.resjson/ko-KR/resources.resjson +2 -1
- package/Strings/resources.resjson/ru-RU/resources.resjson +2 -1
- package/Strings/resources.resjson/zh-CN/resources.resjson +2 -1
- package/Strings/resources.resjson/zh-TW/resources.resjson +2 -1
- package/internal.d.ts +13 -2
- package/internal.js +73 -20
- package/lib.json +26 -22
- package/mock-answer.d.ts +4 -1
- package/mock-answer.js +2 -2
- package/mock-task.d.ts +3 -0
- package/mock-task.js +20 -2
- package/mock-test.js +29 -34
- package/mock-toolrunner.d.ts +7 -0
- package/mock-toolrunner.js +95 -1
- package/package.json +2 -2
- package/task.d.ts +121 -33
- package/task.js +628 -287
- package/toolrunner.d.ts +15 -1
- package/toolrunner.js +360 -43
package/internal.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a, _b;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._exposeCertSettings = exports._exposeProxySettings = exports._normalizeSeparators = exports._isRooted = exports._getDirectoryName = exports._ensureRooted = exports._isUncPath = exports._loadData = exports._ensurePatternRooted = exports._getFindInfoFromPattern = exports._cloneMatchOptions = exports._legacyFindFiles_convertPatternToRegExp = exports._which = exports._checkPath = exports._exist = exports._debug = exports._error = exports._warning = exports._command = exports._getVariableKey = exports._getVariable = exports._loc = exports._setResourcePath = exports._setErrStream = exports._setStdStream = exports._writeLine = exports._endsWith = exports._startsWith = exports._vault = exports._knownVariableMap = void 0;
|
|
4
|
+
exports.isSigPipeError = exports._exposeCertSettings = exports._exposeProxySettings = exports._normalizeSeparators = exports._isRooted = exports._getDirectoryName = exports._ensureRooted = exports._isUncPath = exports._loadData = exports._ensurePatternRooted = exports._getFindInfoFromPattern = exports._cloneMatchOptions = exports._legacyFindFiles_convertPatternToRegExp = exports._which = exports._checkPath = exports._exist = exports._debug = exports._error = exports._warning = exports._command = exports._getVariableKey = exports._getVariable = exports._loc = exports._setResourcePath = exports._setErrStream = exports._setStdStream = exports._writeLine = exports._truncateBeforeSensitiveKeyword = exports._endsWith = exports._startsWith = exports.IssueAuditAction = exports.IssueSource = exports._vault = exports._knownVariableMap = void 0;
|
|
4
5
|
var fs = require("fs");
|
|
5
6
|
var path = require("path");
|
|
6
7
|
var os = require("os");
|
|
@@ -20,12 +21,26 @@ var crypto = require("crypto");
|
|
|
20
21
|
* 3) to know the real variable name and not just the formatted env var name.
|
|
21
22
|
*/
|
|
22
23
|
exports._knownVariableMap = {};
|
|
24
|
+
var _commandCorrelationId;
|
|
25
|
+
//-----------------------------------------------------
|
|
26
|
+
// Enums
|
|
27
|
+
//-----------------------------------------------------
|
|
28
|
+
var IssueSource;
|
|
29
|
+
(function (IssueSource) {
|
|
30
|
+
IssueSource["CustomerScript"] = "CustomerScript";
|
|
31
|
+
IssueSource["TaskInternal"] = "TaskInternal";
|
|
32
|
+
})(IssueSource = exports.IssueSource || (exports.IssueSource = {}));
|
|
33
|
+
var IssueAuditAction;
|
|
34
|
+
(function (IssueAuditAction) {
|
|
35
|
+
IssueAuditAction[IssueAuditAction["Unknown"] = 0] = "Unknown";
|
|
36
|
+
IssueAuditAction[IssueAuditAction["ShellTasksValidation"] = 1] = "ShellTasksValidation";
|
|
37
|
+
})(IssueAuditAction = exports.IssueAuditAction || (exports.IssueAuditAction = {}));
|
|
23
38
|
//-----------------------------------------------------
|
|
24
39
|
// Validation Checks
|
|
25
40
|
//-----------------------------------------------------
|
|
26
41
|
// async await needs generators in node 4.x+
|
|
27
42
|
if (semver.lt(process.versions.node, '4.2.0')) {
|
|
28
|
-
_warning('Tasks require a new agent. Upgrade your agent or node to 4.2.0 or later');
|
|
43
|
+
_warning('Tasks require a new agent. Upgrade your agent or node to 4.2.0 or later', IssueSource.TaskInternal);
|
|
29
44
|
}
|
|
30
45
|
//-----------------------------------------------------
|
|
31
46
|
// String convenience
|
|
@@ -38,6 +53,17 @@ function _endsWith(str, end) {
|
|
|
38
53
|
return str.slice(-end.length) == end;
|
|
39
54
|
}
|
|
40
55
|
exports._endsWith = _endsWith;
|
|
56
|
+
function _truncateBeforeSensitiveKeyword(str, sensitiveKeywordsPattern) {
|
|
57
|
+
if (!str) {
|
|
58
|
+
return str;
|
|
59
|
+
}
|
|
60
|
+
var index = str.search(sensitiveKeywordsPattern);
|
|
61
|
+
if (index <= 0) {
|
|
62
|
+
return str;
|
|
63
|
+
}
|
|
64
|
+
return "".concat(str.substring(0, index), "...");
|
|
65
|
+
}
|
|
66
|
+
exports._truncateBeforeSensitiveKeyword = _truncateBeforeSensitiveKeyword;
|
|
41
67
|
//-----------------------------------------------------
|
|
42
68
|
// General Helpers
|
|
43
69
|
//-----------------------------------------------------
|
|
@@ -116,7 +142,7 @@ function _loadLocStrings(resourceFile, culture) {
|
|
|
116
142
|
}
|
|
117
143
|
}
|
|
118
144
|
else {
|
|
119
|
-
_warning('LIB_ResourceFile does not exist');
|
|
145
|
+
_warning('LIB_ResourceFile does not exist', IssueSource.TaskInternal);
|
|
120
146
|
}
|
|
121
147
|
return locStrings;
|
|
122
148
|
}
|
|
@@ -148,10 +174,9 @@ function _setResourcePath(path, ignoreWarnings) {
|
|
|
148
174
|
}
|
|
149
175
|
else {
|
|
150
176
|
if (ignoreWarnings) {
|
|
151
|
-
_debug(_loc('LIB_ResourceFileAlreadySet', path));
|
|
152
177
|
}
|
|
153
178
|
else {
|
|
154
|
-
_warning(_loc('LIB_ResourceFileAlreadySet', path));
|
|
179
|
+
_warning(_loc('LIB_ResourceFileAlreadySet', path), IssueSource.TaskInternal);
|
|
155
180
|
}
|
|
156
181
|
}
|
|
157
182
|
}
|
|
@@ -185,10 +210,10 @@ function _loc(key) {
|
|
|
185
210
|
}
|
|
186
211
|
else {
|
|
187
212
|
if (Object.keys(_resourceFiles).length <= 0) {
|
|
188
|
-
_warning("Resource file haven't been set, can't find loc string for key: "
|
|
213
|
+
_warning("Resource file haven't been set, can't find loc string for key: ".concat(key), IssueSource.TaskInternal);
|
|
189
214
|
}
|
|
190
215
|
else {
|
|
191
|
-
_warning("Can't find loc string for key: "
|
|
216
|
+
_warning("Can't find loc string for key: ".concat(key));
|
|
192
217
|
}
|
|
193
218
|
locString = key;
|
|
194
219
|
}
|
|
@@ -248,16 +273,33 @@ function _command(command, properties, message) {
|
|
|
248
273
|
_writeLine(taskCmd.toString());
|
|
249
274
|
}
|
|
250
275
|
exports._command = _command;
|
|
251
|
-
function _warning(message) {
|
|
252
|
-
|
|
276
|
+
function _warning(message, source, auditAction) {
|
|
277
|
+
if (source === void 0) { source = IssueSource.TaskInternal; }
|
|
278
|
+
_command('task.issue', {
|
|
279
|
+
'type': 'warning',
|
|
280
|
+
'source': source,
|
|
281
|
+
'correlationId': _commandCorrelationId,
|
|
282
|
+
'auditAction': auditAction
|
|
283
|
+
}, message);
|
|
253
284
|
}
|
|
254
285
|
exports._warning = _warning;
|
|
255
|
-
function _error(message) {
|
|
256
|
-
|
|
286
|
+
function _error(message, source, auditAction) {
|
|
287
|
+
if (source === void 0) { source = IssueSource.TaskInternal; }
|
|
288
|
+
_command('task.issue', {
|
|
289
|
+
'type': 'error',
|
|
290
|
+
'source': source,
|
|
291
|
+
'correlationId': _commandCorrelationId,
|
|
292
|
+
'auditAction': auditAction
|
|
293
|
+
}, message);
|
|
257
294
|
}
|
|
258
295
|
exports._error = _error;
|
|
296
|
+
var debugMode = ((_a = _getVariable('system.debug')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'true';
|
|
297
|
+
var shouldCheckDebugMode = ((_b = _getVariable('DistributedTask.Tasks.Node.SkipDebugLogsWhenDebugModeOff')) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'true';
|
|
259
298
|
function _debug(message) {
|
|
260
|
-
|
|
299
|
+
if (!shouldCheckDebugMode
|
|
300
|
+
|| (shouldCheckDebugMode && debugMode)) {
|
|
301
|
+
_command('task.debug', null, message);
|
|
302
|
+
}
|
|
261
303
|
}
|
|
262
304
|
exports._debug = _debug;
|
|
263
305
|
// //-----------------------------------------------------
|
|
@@ -327,7 +369,7 @@ function _which(tool, check) {
|
|
|
327
369
|
}
|
|
328
370
|
}
|
|
329
371
|
}
|
|
330
|
-
_debug("which '"
|
|
372
|
+
_debug("which '".concat(tool, "'"));
|
|
331
373
|
try {
|
|
332
374
|
// build the list of extensions to try
|
|
333
375
|
var extensions = [];
|
|
@@ -343,7 +385,7 @@ function _which(tool, check) {
|
|
|
343
385
|
if (_isRooted(tool)) {
|
|
344
386
|
var filePath = _tryGetExecutablePath(tool, extensions);
|
|
345
387
|
if (filePath) {
|
|
346
|
-
_debug("found: '"
|
|
388
|
+
_debug("found: '".concat(filePath, "'"));
|
|
347
389
|
return filePath;
|
|
348
390
|
}
|
|
349
391
|
_debug('not found');
|
|
@@ -374,7 +416,7 @@ function _which(tool, check) {
|
|
|
374
416
|
var directory = directories_1[_d];
|
|
375
417
|
var filePath = _tryGetExecutablePath(directory + path.sep + tool, extensions);
|
|
376
418
|
if (filePath) {
|
|
377
|
-
_debug("found: '"
|
|
419
|
+
_debug("found: '".concat(filePath, "'"));
|
|
378
420
|
return filePath;
|
|
379
421
|
}
|
|
380
422
|
}
|
|
@@ -418,7 +460,7 @@ function _tryGetExecutablePath(filePath, extensions) {
|
|
|
418
460
|
}
|
|
419
461
|
catch (err) {
|
|
420
462
|
if (err.code != 'ENOENT') {
|
|
421
|
-
_debug("Unexpected error attempting to determine if executable file exists '"
|
|
463
|
+
_debug("Unexpected error attempting to determine if executable file exists '".concat(filePath, "': ").concat(err));
|
|
422
464
|
}
|
|
423
465
|
}
|
|
424
466
|
// try each extension
|
|
@@ -444,7 +486,7 @@ function _tryGetExecutablePath(filePath, extensions) {
|
|
|
444
486
|
}
|
|
445
487
|
}
|
|
446
488
|
catch (err) {
|
|
447
|
-
_debug("Unexpected error attempting to determine the actual case of the file '"
|
|
489
|
+
_debug("Unexpected error attempting to determine the actual case of the file '".concat(filePath_1, "': ").concat(err));
|
|
448
490
|
}
|
|
449
491
|
return filePath_1;
|
|
450
492
|
}
|
|
@@ -457,7 +499,7 @@ function _tryGetExecutablePath(filePath, extensions) {
|
|
|
457
499
|
}
|
|
458
500
|
catch (err) {
|
|
459
501
|
if (err.code != 'ENOENT') {
|
|
460
|
-
_debug("Unexpected error attempting to determine if executable file exists '"
|
|
502
|
+
_debug("Unexpected error attempting to determine if executable file exists '".concat(filePath_1, "': ").concat(err));
|
|
461
503
|
}
|
|
462
504
|
}
|
|
463
505
|
}
|
|
@@ -476,7 +518,7 @@ function _legacyFindFiles_convertPatternToRegExp(pattern) {
|
|
|
476
518
|
.replace(/\\\*\\\*/g, '.*') // replace remaining globstars with a wildcard that can span directory separators, e.g. /hello/**dll
|
|
477
519
|
.replace(/\\\*/g, '[^\/]*') // replace asterisks with a wildcard that cannot span directory separators, e.g. /hello/*.dll
|
|
478
520
|
.replace(/\\\?/g, '[^\/]'); // replace single character wildcards, e.g. /hello/log?.dll
|
|
479
|
-
pattern = "^"
|
|
521
|
+
pattern = "^".concat(pattern, "$");
|
|
480
522
|
var flags = process.platform == 'win32' ? 'i' : '';
|
|
481
523
|
return new RegExp(pattern, flags);
|
|
482
524
|
}
|
|
@@ -642,6 +684,9 @@ function _loadData() {
|
|
|
642
684
|
}
|
|
643
685
|
}
|
|
644
686
|
_debug('loaded ' + loaded);
|
|
687
|
+
var correlationId = process.env["COMMAND_CORRELATION_ID"];
|
|
688
|
+
delete process.env["COMMAND_CORRELATION_ID"];
|
|
689
|
+
_commandCorrelationId = correlationId ? String(correlationId) : "";
|
|
645
690
|
// store public variable metadata
|
|
646
691
|
var names;
|
|
647
692
|
try {
|
|
@@ -876,10 +921,18 @@ function _exposeTaskLibSecret(keyFile, secret) {
|
|
|
876
921
|
if (secret) {
|
|
877
922
|
var encryptKey = crypto.randomBytes(256);
|
|
878
923
|
var cipher = crypto.createCipher("aes-256-ctr", encryptKey);
|
|
879
|
-
var encryptedContent = cipher.update(secret, "utf8", "hex");
|
|
924
|
+
var encryptedContent = cipher.update(secret, "utf8", "hex"); // CodeQL [SM01511] agent need to retrieve password later to connect to proxy server
|
|
880
925
|
encryptedContent += cipher.final("hex");
|
|
881
926
|
var storageFile = path.join(_getVariable('Agent.TempDirectory') || _getVariable("agent.workFolder") || process.cwd(), keyFile);
|
|
882
927
|
fs.writeFileSync(storageFile, encryptKey.toString('base64'), { encoding: 'utf8' });
|
|
883
928
|
return new Buffer(storageFile).toString('base64') + ':' + new Buffer(encryptedContent).toString('base64');
|
|
884
929
|
}
|
|
885
930
|
}
|
|
931
|
+
function isSigPipeError(e) {
|
|
932
|
+
var _a;
|
|
933
|
+
if (!e || typeof e !== 'object') {
|
|
934
|
+
return false;
|
|
935
|
+
}
|
|
936
|
+
return e.code === 'EPIPE' && ((_a = e.syscall) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === 'WRITE';
|
|
937
|
+
}
|
|
938
|
+
exports.isSigPipeError = isSigPipeError;
|
package/lib.json
CHANGED
|
@@ -1,37 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"messages": {
|
|
3
|
-
"
|
|
3
|
+
"LIB_CopyFileFailed": "Error while copying the file. Attempts left: %s",
|
|
4
|
+
"LIB_DirectoryStackEmpty": "Directory stack is empty",
|
|
5
|
+
"LIB_EndpointAuthNotExist": "Endpoint auth data not present: %s",
|
|
6
|
+
"LIB_EndpointDataNotExist": "Endpoint data parameter %s not present: %s",
|
|
7
|
+
"LIB_EndpointNotExist": "Endpoint not present: %s",
|
|
4
8
|
"LIB_FailOnCode": "Failure return code: %d",
|
|
9
|
+
"LIB_InputRequired": "Input required: %s",
|
|
10
|
+
"LIB_InvalidEndpointAuth": "Invalid endpoint auth: %s",
|
|
11
|
+
"LIB_InvalidPattern": "Invalid pattern: '%s'",
|
|
12
|
+
"LIB_InvalidSecureFilesInput": "Invalid secure file input: %s",
|
|
13
|
+
"LIB_LocStringNotFound": "Can\\'t find loc string for key: %s",
|
|
14
|
+
"LIB_MergeTestResultNotSupported": "Merging test results from multiple files to one test run is not supported on this version of build agent for OSX/Linux, each test result file will be published as a separate test run in VSO/TFS.",
|
|
5
15
|
"LIB_MkdirFailed": "Unable to create directory '%s'. %s",
|
|
6
16
|
"LIB_MkdirFailedFileExists": "Unable to create directory '%s'. Conflicting file exists: '%s'",
|
|
7
17
|
"LIB_MkdirFailedInvalidDriveRoot": "Unable to create directory '%s'. Root directory does not exist: '%s'",
|
|
8
18
|
"LIB_MkdirFailedInvalidShare": "Unable to create directory '%s'. Unable to verify the directory exists: '%s'. If directory is a file share, please verify the share name is correct, the share is online, and the current process has permission to access the share.",
|
|
9
19
|
"LIB_MultilineSecret": "Secrets cannot contain multiple lines",
|
|
20
|
+
"LIB_NotFoundPreviousDirectory": "Could not find previous directory",
|
|
21
|
+
"LIB_OperationFailed": "Failed %s: %s",
|
|
22
|
+
"LIB_ParameterIsRequired": "%s not supplied",
|
|
23
|
+
"LIB_PathHasNullByte": "Path cannot contain null bytes",
|
|
24
|
+
"LIB_PathIsNotADirectory": "Path is not a directory: %s",
|
|
25
|
+
"LIB_PathNotFound": "Not found %s: %s",
|
|
26
|
+
"LIB_PlatformNotSupported": "Platform not supported: %s",
|
|
10
27
|
"LIB_ProcessError": "There was an error when attempting to execute the process '%s'. This may indicate the process failed to start. Error: %s",
|
|
11
28
|
"LIB_ProcessExitCode": "The process '%s' failed with exit code %s",
|
|
12
29
|
"LIB_ProcessStderr": "The process '%s' failed because one or more lines were written to the STDERR stream",
|
|
13
|
-
"LIB_ReturnCode": "Return code: %d",
|
|
14
|
-
"LIB_ResourceFileNotExist": "Resource file doesn\\'t exist: %s",
|
|
15
30
|
"LIB_ResourceFileAlreadySet": "Resource file has already set to: %s",
|
|
31
|
+
"LIB_ResourceFileNotExist": "Resource file doesn\\'t exist: %s",
|
|
16
32
|
"LIB_ResourceFileNotSet": "Resource file haven\\'t set, can\\'t find loc string for key: %s",
|
|
33
|
+
"LIB_ReturnCode": "Return code: %d",
|
|
17
34
|
"LIB_StdioNotClosed": "The STDIO streams did not close within %s seconds of the exit event from process '%s'. This may indicate a child process inherited the STDIO streams and has not yet exited.",
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"LIB_LocStringNotFound": "Can\\'t find loc string for key: %s",
|
|
21
|
-
"LIB_ParameterIsRequired": "%s not supplied",
|
|
22
|
-
"LIB_InputRequired": "Input required: %s",
|
|
23
|
-
"LIB_InvalidPattern": "Invalid pattern: '%s'",
|
|
24
|
-
"LIB_EndpointNotExist": "Endpoint not present: %s",
|
|
25
|
-
"LIB_EndpointDataNotExist": "Endpoint data parameter %s not present: %s",
|
|
26
|
-
"LIB_EndpointAuthNotExist": "Endpoint auth data not present: %s",
|
|
27
|
-
"LIB_InvalidEndpointAuth": "Invalid endpoint auth: %s",
|
|
28
|
-
"LIB_InvalidSecureFilesInput": "Invalid secure file input: %s",
|
|
29
|
-
"LIB_PathNotFound": "Not found %s: %s",
|
|
30
|
-
"LIB_PathHasNullByte": "Path cannot contain null bytes",
|
|
31
|
-
"LIB_OperationFailed": "Failed %s: %s",
|
|
35
|
+
"LIB_UndefinedNodeVersion": "Node version is undefined.",
|
|
36
|
+
"LIB_UnhandledEx": "Unhandled: %s",
|
|
32
37
|
"LIB_UseFirstGlobMatch": "Multiple workspace matches. using first.",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
+
"LIB_WhichNotFound_Linux": "Unable to locate executable file: '%s'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.",
|
|
39
|
+
"LIB_WhichNotFound_Win": "Unable to locate executable file: '%s'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file."
|
|
40
|
+
}
|
|
41
|
+
}
|
package/mock-answer.d.ts
CHANGED
|
@@ -26,6 +26,9 @@ export interface TaskLibAnswers {
|
|
|
26
26
|
getPlatform?: {
|
|
27
27
|
[key: string]: task.Platform;
|
|
28
28
|
};
|
|
29
|
+
getNodeMajorVersion?: {
|
|
30
|
+
[key: string]: Number;
|
|
31
|
+
};
|
|
29
32
|
getAgentMode?: {
|
|
30
33
|
[key: string]: task.AgentHostedMode;
|
|
31
34
|
};
|
|
@@ -50,7 +53,7 @@ export interface TaskLibAnswers {
|
|
|
50
53
|
[key: string]: string;
|
|
51
54
|
};
|
|
52
55
|
}
|
|
53
|
-
export
|
|
56
|
+
export type MockedCommand = keyof TaskLibAnswers;
|
|
54
57
|
export declare class MockAnswers {
|
|
55
58
|
private _answers;
|
|
56
59
|
initialize(answers: TaskLibAnswers): void;
|
package/mock-answer.js
CHANGED
|
@@ -11,12 +11,12 @@ var MockAnswers = /** @class */ (function () {
|
|
|
11
11
|
this._answers = answers;
|
|
12
12
|
};
|
|
13
13
|
MockAnswers.prototype.getResponse = function (cmd, key, debug) {
|
|
14
|
-
debug("looking up mock answers for "
|
|
14
|
+
debug("looking up mock answers for ".concat(JSON.stringify(cmd), ", key '").concat(JSON.stringify(key), "'"));
|
|
15
15
|
if (!this._answers) {
|
|
16
16
|
throw new Error('Must initialize');
|
|
17
17
|
}
|
|
18
18
|
if (!this._answers[cmd]) {
|
|
19
|
-
debug("no mock responses registered for "
|
|
19
|
+
debug("no mock responses registered for ".concat(JSON.stringify(cmd)));
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
22
22
|
var cmd_answer = this._answers[cmd];
|
package/mock-task.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import Q = require('q');
|
|
3
4
|
import fs = require('fs');
|
|
4
5
|
import task = require('./task');
|
|
@@ -58,6 +59,7 @@ export interface FsOptions {
|
|
|
58
59
|
export declare function writeFile(file: string, data: string | Buffer, options?: string | FsOptions): void;
|
|
59
60
|
export declare function osType(): string;
|
|
60
61
|
export declare function getPlatform(): task.Platform;
|
|
62
|
+
export declare function getNodeMajorVersion(): Number;
|
|
61
63
|
export declare function getAgentMode(): task.AgentHostedMode;
|
|
62
64
|
export declare function cwd(): string;
|
|
63
65
|
export declare function cd(path: string): void;
|
|
@@ -74,6 +76,7 @@ export declare function find(findPath: string): string[];
|
|
|
74
76
|
export declare function rmRF(path: string): void;
|
|
75
77
|
export declare function mv(source: string, dest: string, force: boolean, continueOnError?: boolean): boolean;
|
|
76
78
|
export declare function exec(tool: string, args: any, options?: trm.IExecOptions): Q.Promise<number>;
|
|
79
|
+
export declare function execAsync(tool: string, args: any, options?: trm.IExecOptions): Promise<number>;
|
|
77
80
|
export declare function execSync(tool: string, args: any, options?: trm.IExecSyncOptions): trm.IExecSyncResult;
|
|
78
81
|
export declare function tool(tool: string): trm.ToolRunner;
|
|
79
82
|
export interface MatchOptions {
|
package/mock-task.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getHttpCertConfiguration = exports.getHttpProxyConfiguration = exports.CodeCoverageEnabler = exports.CodeCoveragePublisher = exports.TestPublisher = exports.legacyFindFiles = exports.findMatch = exports.tool = exports.execSync = exports.exec = exports.mv = exports.rmRF = exports.find = exports.retry = exports.cp = exports.ls = exports.which = exports.resolve = exports.mkdirP = exports.checkPath = exports.popd = exports.pushd = exports.cd = exports.cwd = exports.getAgentMode = exports.getPlatform = exports.osType = exports.writeFile = exports.exist = exports.stats = exports.FsStats = exports.loc = exports.setResourcePath = exports.setAnswers = void 0;
|
|
3
|
+
exports.getHttpCertConfiguration = exports.getHttpProxyConfiguration = exports.CodeCoverageEnabler = exports.CodeCoveragePublisher = exports.TestPublisher = exports.legacyFindFiles = exports.findMatch = exports.tool = exports.execSync = exports.execAsync = exports.exec = exports.mv = exports.rmRF = exports.find = exports.retry = exports.cp = exports.ls = exports.which = exports.resolve = exports.mkdirP = exports.checkPath = exports.popd = exports.pushd = exports.cd = exports.cwd = exports.getAgentMode = exports.getNodeMajorVersion = exports.getPlatform = exports.osType = exports.writeFile = exports.exist = exports.stats = exports.FsStats = exports.loc = exports.setResourcePath = exports.setAnswers = void 0;
|
|
4
4
|
var path = require("path");
|
|
5
5
|
var task = require("./task");
|
|
6
6
|
var tcm = require("./taskcommand");
|
|
@@ -27,6 +27,7 @@ module.exports.Platform = task.Platform;
|
|
|
27
27
|
module.exports.setStdStream = task.setStdStream;
|
|
28
28
|
module.exports.setErrStream = task.setErrStream;
|
|
29
29
|
module.exports.setResult = task.setResult;
|
|
30
|
+
module.exports.setSanitizedResult = task.setSanitizedResult;
|
|
30
31
|
//-----------------------------------------------------
|
|
31
32
|
// Loc Helpers
|
|
32
33
|
//-----------------------------------------------------
|
|
@@ -60,6 +61,7 @@ module.exports.getInput = task.getInput;
|
|
|
60
61
|
module.exports.getInputRequired = task.getInputRequired;
|
|
61
62
|
module.exports.getBoolInput = task.getBoolInput;
|
|
62
63
|
module.exports.getBoolFeatureFlag = task.getBoolFeatureFlag;
|
|
64
|
+
module.exports.getPipelineFeature = task.getPipelineFeature;
|
|
63
65
|
module.exports.getDelimitedInput = task.getDelimitedInput;
|
|
64
66
|
module.exports.filePathSupplied = task.filePathSupplied;
|
|
65
67
|
function getPathInput(name, required, check) {
|
|
@@ -189,6 +191,10 @@ function getPlatform() {
|
|
|
189
191
|
return mock.getResponse('getPlatform', 'getPlatform', module.exports.debug);
|
|
190
192
|
}
|
|
191
193
|
exports.getPlatform = getPlatform;
|
|
194
|
+
function getNodeMajorVersion() {
|
|
195
|
+
return mock.getResponse('getNodeMajorVersion', 'getNodeMajorVersion', module.exports.debug);
|
|
196
|
+
}
|
|
197
|
+
exports.getNodeMajorVersion = getNodeMajorVersion;
|
|
192
198
|
function getAgentMode() {
|
|
193
199
|
return mock.getResponse('getAgentMode', 'getAgentMode', module.exports.debug);
|
|
194
200
|
}
|
|
@@ -267,7 +273,7 @@ function cp(source, dest) {
|
|
|
267
273
|
}
|
|
268
274
|
exports.cp = cp;
|
|
269
275
|
function retry(func, args, retryOptions) {
|
|
270
|
-
module.exports.debug("trying to execute "
|
|
276
|
+
module.exports.debug("trying to execute ".concat(func === null || func === void 0 ? void 0 : func.name, "(").concat(args.toString(), ") with ").concat(retryOptions.retryCount, " retries"));
|
|
271
277
|
}
|
|
272
278
|
exports.retry = retry;
|
|
273
279
|
function find(findPath) {
|
|
@@ -299,6 +305,18 @@ function exec(tool, args, options) {
|
|
|
299
305
|
return tr.exec(options);
|
|
300
306
|
}
|
|
301
307
|
exports.exec = exec;
|
|
308
|
+
//-----------------------------------------------------
|
|
309
|
+
// Exec convenience wrapper
|
|
310
|
+
//-----------------------------------------------------
|
|
311
|
+
function execAsync(tool, args, options) {
|
|
312
|
+
var toolPath = which(tool, true);
|
|
313
|
+
var tr = this.tool(toolPath);
|
|
314
|
+
if (args) {
|
|
315
|
+
tr.arg(args);
|
|
316
|
+
}
|
|
317
|
+
return tr.execAsync(options);
|
|
318
|
+
}
|
|
319
|
+
exports.execAsync = execAsync;
|
|
302
320
|
function execSync(tool, args, options) {
|
|
303
321
|
var toolPath = which(tool, true);
|
|
304
322
|
var tr = this.tool(toolPath);
|
package/mock-test.js
CHANGED
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
18
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -191,7 +191,7 @@ var MockTestRunner = /** @class */ (function () {
|
|
|
191
191
|
// don't print task.debug commands to console - too noisy.
|
|
192
192
|
// otherwise omit command details - can interfere during CI.
|
|
193
193
|
else if (cmd && cmd.command != 'task.debug') {
|
|
194
|
-
console.log(cmd.command
|
|
194
|
+
console.log("".concat(cmd.command, " details omitted"));
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
});
|
|
@@ -210,23 +210,20 @@ var MockTestRunner = /** @class */ (function () {
|
|
|
210
210
|
// Returns a path to node.exe with the correct version for this task (based on if its node10 or node)
|
|
211
211
|
MockTestRunner.prototype.getNodePath = function (nodeVersion) {
|
|
212
212
|
return __awaiter(this, void 0, void 0, function () {
|
|
213
|
-
var version, downloadVersion, downloadDestination, pathToExe, result;
|
|
213
|
+
var version, versions, downloadVersion, downloadDestination, pathToExe, result;
|
|
214
214
|
return __generator(this, function (_a) {
|
|
215
215
|
switch (_a.label) {
|
|
216
216
|
case 0:
|
|
217
217
|
version = nodeVersion || this.getNodeVersion();
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
break;
|
|
228
|
-
default:
|
|
229
|
-
throw new Error('Invalid node version, must be 6, 10, or 16 (received ' + version + ')');
|
|
218
|
+
versions = {
|
|
219
|
+
20: 'v20.13.1',
|
|
220
|
+
16: 'v16.20.2',
|
|
221
|
+
10: 'v10.24.1',
|
|
222
|
+
6: 'v6.17.1',
|
|
223
|
+
};
|
|
224
|
+
downloadVersion = versions[version];
|
|
225
|
+
if (!downloadVersion) {
|
|
226
|
+
throw new Error('Invalid node version, must be 6, 10, 16 or 20 (received ' + version + ')');
|
|
230
227
|
}
|
|
231
228
|
downloadDestination = path.join(downloadDirectory, 'node' + version);
|
|
232
229
|
pathToExe = this.getPathToNodeExe(downloadVersion, downloadDestination);
|
|
@@ -249,29 +246,27 @@ var MockTestRunner = /** @class */ (function () {
|
|
|
249
246
|
}
|
|
250
247
|
var taskJsonContents = fs.readFileSync(taskJsonPath, { encoding: 'utf-8' });
|
|
251
248
|
var taskJson = JSON.parse(taskJsonContents);
|
|
252
|
-
var
|
|
253
|
-
var
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
else if (keys[i].toLowerCase() == 'node') {
|
|
267
|
-
nodeVersionFound = true;
|
|
249
|
+
var nodeVersion = 0;
|
|
250
|
+
var executors = ['execution', 'prejobexecution', 'postjobexecution'];
|
|
251
|
+
for (var _i = 0, executors_1 = executors; _i < executors_1.length; _i++) {
|
|
252
|
+
var executor = executors_1[_i];
|
|
253
|
+
if (!taskJson[executor])
|
|
254
|
+
continue;
|
|
255
|
+
for (var _a = 0, _b = Object.keys(taskJson[executor]); _a < _b.length; _a++) {
|
|
256
|
+
var key = _b[_a];
|
|
257
|
+
var currExecutor = key.toLocaleLowerCase();
|
|
258
|
+
if (!currExecutor.startsWith('node'))
|
|
259
|
+
continue;
|
|
260
|
+
var version = currExecutor.replace('node', '');
|
|
261
|
+
var intVersion = parseInt(version) || 6; // node handler is node v6 by default
|
|
262
|
+
nodeVersion = Math.max(intVersion, nodeVersion);
|
|
268
263
|
}
|
|
269
264
|
}
|
|
270
|
-
if (
|
|
265
|
+
if (nodeVersion === 0) {
|
|
271
266
|
console.warn('Unable to determine execution type from task.json, defaulting to use Node 16');
|
|
272
267
|
return 16;
|
|
273
268
|
}
|
|
274
|
-
return
|
|
269
|
+
return nodeVersion;
|
|
275
270
|
};
|
|
276
271
|
// Returns the path to the task.json for the task being tested. Returns null if unable to find it.
|
|
277
272
|
// Searches by moving up the directory structure from the initial starting point and checking at each level.
|
|
@@ -383,7 +378,7 @@ var MockTestRunner = /** @class */ (function () {
|
|
|
383
378
|
originalCwd = process.cwd();
|
|
384
379
|
process.chdir(downloadDestination);
|
|
385
380
|
try {
|
|
386
|
-
cp.execSync("tar -xzf \""
|
|
381
|
+
cp.execSync("tar -xzf \"".concat(path.join(downloadDestination, tarGzName), "\""));
|
|
387
382
|
}
|
|
388
383
|
catch (_b) {
|
|
389
384
|
throw new Error('Failed to unzip node tar.gz from ' + url);
|
package/mock-toolrunner.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import Q = require('q');
|
|
3
4
|
import events = require('events');
|
|
4
5
|
import ma = require('./mock-answer');
|
|
@@ -36,6 +37,12 @@ export declare class ToolRunner extends events.EventEmitter {
|
|
|
36
37
|
line(val: string): ToolRunner;
|
|
37
38
|
pipeExecOutputToTool(tool: ToolRunner): ToolRunner;
|
|
38
39
|
private ignoreTempPath;
|
|
40
|
+
execAsync(options?: IExecOptions): Promise<number>;
|
|
41
|
+
/**
|
|
42
|
+
* Exec - use for long running tools where you need to stream live output as it runs
|
|
43
|
+
* @deprecated use `execAsync` instead
|
|
44
|
+
* @returns a promise with return code.
|
|
45
|
+
*/
|
|
39
46
|
exec(options?: IExecOptions): Q.Promise<number>;
|
|
40
47
|
execSync(options?: IExecSyncOptions): IExecSyncResult;
|
|
41
48
|
}
|
package/mock-toolrunner.js
CHANGED
|
@@ -7,6 +7,8 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -130,6 +132,99 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
130
132
|
// Exec - use for long running tools where you need to stream live output as it runs
|
|
131
133
|
// returns a promise with return code.
|
|
132
134
|
//
|
|
135
|
+
ToolRunner.prototype.execAsync = function (options) {
|
|
136
|
+
var _this = this;
|
|
137
|
+
this._debug('exec tool: ' + this.toolPath);
|
|
138
|
+
this._debug('Arguments:');
|
|
139
|
+
this.args.forEach(function (arg) {
|
|
140
|
+
_this._debug(' ' + arg);
|
|
141
|
+
});
|
|
142
|
+
var success = true;
|
|
143
|
+
options = options || {};
|
|
144
|
+
var ops = {
|
|
145
|
+
cwd: options.cwd || process.cwd(),
|
|
146
|
+
env: options.env || process.env,
|
|
147
|
+
silent: options.silent || false,
|
|
148
|
+
outStream: options.outStream || process.stdout,
|
|
149
|
+
errStream: options.errStream || process.stderr,
|
|
150
|
+
failOnStdErr: options.failOnStdErr || false,
|
|
151
|
+
ignoreReturnCode: options.ignoreReturnCode || false,
|
|
152
|
+
windowsVerbatimArguments: options.windowsVerbatimArguments
|
|
153
|
+
};
|
|
154
|
+
var argString = this.args.join(' ') || '';
|
|
155
|
+
var cmdString = this.toolPath;
|
|
156
|
+
if (argString) {
|
|
157
|
+
cmdString += (' ' + argString);
|
|
158
|
+
}
|
|
159
|
+
// Using split/join to replace the temp path
|
|
160
|
+
cmdString = this.ignoreTempPath(cmdString);
|
|
161
|
+
if (!ops.silent) {
|
|
162
|
+
if (this.pipeOutputToTool) {
|
|
163
|
+
var pipeToolArgString = this.pipeOutputToTool.args.join(' ') || '';
|
|
164
|
+
var pipeToolCmdString = this.ignoreTempPath(this.pipeOutputToTool.toolPath);
|
|
165
|
+
if (pipeToolArgString) {
|
|
166
|
+
pipeToolCmdString += (' ' + pipeToolArgString);
|
|
167
|
+
}
|
|
168
|
+
cmdString += ' | ' + pipeToolCmdString;
|
|
169
|
+
}
|
|
170
|
+
ops.outStream.write('[command]' + cmdString + os.EOL);
|
|
171
|
+
}
|
|
172
|
+
// TODO: filter process.env
|
|
173
|
+
var res = mock.getResponse('exec', cmdString, debug);
|
|
174
|
+
if (res.stdout) {
|
|
175
|
+
this.emit('stdout', res.stdout);
|
|
176
|
+
if (!ops.silent) {
|
|
177
|
+
ops.outStream.write(res.stdout + os.EOL);
|
|
178
|
+
}
|
|
179
|
+
var stdLineArray = res.stdout.split(os.EOL);
|
|
180
|
+
for (var _i = 0, _a = stdLineArray.slice(0, -1); _i < _a.length; _i++) {
|
|
181
|
+
var line = _a[_i];
|
|
182
|
+
this.emit('stdline', line);
|
|
183
|
+
}
|
|
184
|
+
if (stdLineArray.length > 0 && stdLineArray[stdLineArray.length - 1].length > 0) {
|
|
185
|
+
this.emit('stdline', stdLineArray[stdLineArray.length - 1]);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (res.stderr) {
|
|
189
|
+
this.emit('stderr', res.stderr);
|
|
190
|
+
success = !ops.failOnStdErr;
|
|
191
|
+
if (!ops.silent) {
|
|
192
|
+
var s = ops.failOnStdErr ? ops.errStream : ops.outStream;
|
|
193
|
+
s.write(res.stderr + os.EOL);
|
|
194
|
+
}
|
|
195
|
+
var stdErrArray = res.stderr.split(os.EOL);
|
|
196
|
+
for (var _b = 0, _c = stdErrArray.slice(0, -1); _b < _c.length; _b++) {
|
|
197
|
+
var line = _c[_b];
|
|
198
|
+
this.emit('errline', line);
|
|
199
|
+
}
|
|
200
|
+
if (stdErrArray.length > 0 && stdErrArray[stdErrArray.length - 1].length > 0) {
|
|
201
|
+
this.emit('errline', stdErrArray[stdErrArray.length - 1]);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
var code = res.code;
|
|
205
|
+
if (!ops.silent) {
|
|
206
|
+
ops.outStream.write('rc:' + res.code + os.EOL);
|
|
207
|
+
}
|
|
208
|
+
if (code != 0 && !ops.ignoreReturnCode) {
|
|
209
|
+
success = false;
|
|
210
|
+
}
|
|
211
|
+
if (!ops.silent) {
|
|
212
|
+
ops.outStream.write('success:' + success + os.EOL);
|
|
213
|
+
}
|
|
214
|
+
return new Promise(function (resolve, reject) {
|
|
215
|
+
if (success) {
|
|
216
|
+
resolve(code);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
reject(new Error(_this.toolPath + ' failed with return code: ' + code));
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* Exec - use for long running tools where you need to stream live output as it runs
|
|
225
|
+
* @deprecated use `execAsync` instead
|
|
226
|
+
* @returns a promise with return code.
|
|
227
|
+
*/
|
|
133
228
|
ToolRunner.prototype.exec = function (options) {
|
|
134
229
|
var _this = this;
|
|
135
230
|
var defer = Q.defer();
|
|
@@ -224,7 +319,6 @@ var ToolRunner = /** @class */ (function (_super) {
|
|
|
224
319
|
//
|
|
225
320
|
ToolRunner.prototype.execSync = function (options) {
|
|
226
321
|
var _this = this;
|
|
227
|
-
var defer = Q.defer();
|
|
228
322
|
this._debug('exec tool: ' + this.toolPath);
|
|
229
323
|
this._debug('Arguments:');
|
|
230
324
|
this.args.forEach(function (arg) {
|