azure-pipelines-task-lib 3.2.1 → 3.4.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/mock-task.js CHANGED
@@ -1,447 +1,451 @@
1
- "use strict";
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.getPlatform = exports.osType = exports.writeFile = exports.exist = exports.stats = exports.FsStats = exports.loc = exports.setResourcePath = exports.setAnswers = void 0;
4
- var path = require("path");
5
- var task = require("./task");
6
- var tcm = require("./taskcommand");
7
- var trm = require("./mock-toolrunner");
8
- var ma = require("./mock-answer");
9
- var mock = new ma.MockAnswers();
10
- function setAnswers(answers) {
11
- mock.initialize(answers);
12
- trm.setAnswers(answers);
13
- }
14
- exports.setAnswers = setAnswers;
15
- //-----------------------------------------------------
16
- // Enums
17
- //-----------------------------------------------------
18
- module.exports.TaskResult = task.TaskResult;
19
- module.exports.TaskState = task.TaskState;
20
- module.exports.IssueType = task.IssueType;
21
- module.exports.ArtifactType = task.ArtifactType;
22
- module.exports.FieldType = task.FieldType;
23
- module.exports.Platform = task.Platform;
24
- //-----------------------------------------------------
25
- // Results and Exiting
26
- //-----------------------------------------------------
27
- module.exports.setStdStream = task.setStdStream;
28
- module.exports.setErrStream = task.setErrStream;
29
- module.exports.setResult = task.setResult;
30
- //-----------------------------------------------------
31
- // Loc Helpers
32
- //-----------------------------------------------------
33
- function setResourcePath(path) {
34
- // nothing in mock
35
- }
36
- exports.setResourcePath = setResourcePath;
37
- function loc(key) {
38
- var args = [];
39
- for (var _i = 1; _i < arguments.length; _i++) {
40
- args[_i - 1] = arguments[_i];
41
- }
42
- var str = 'loc_mock_' + key;
43
- if (args.length) {
44
- str += ' ' + args.join(' ');
45
- }
46
- return str;
47
- }
48
- exports.loc = loc;
49
- //-----------------------------------------------------
50
- // Input Helpers
51
- //-----------------------------------------------------
52
- module.exports.assertAgent = task.assertAgent;
53
- module.exports.getVariable = task.getVariable;
54
- module.exports.getVariables = task.getVariables;
55
- module.exports.setVariable = task.setVariable;
56
- module.exports.setSecret = task.setSecret;
57
- module.exports.getTaskVariable = task.getTaskVariable;
58
- module.exports.setTaskVariable = task.setTaskVariable;
59
- module.exports.getInput = task.getInput;
60
- module.exports.getInputRequired = task.getInputRequired;
61
- module.exports.getBoolInput = task.getBoolInput;
62
- module.exports.getDelimitedInput = task.getDelimitedInput;
63
- module.exports.filePathSupplied = task.filePathSupplied;
64
- function getPathInput(name, required, check) {
65
- var inval = module.exports.getInput(name, required);
66
- if (inval) {
67
- if (check) {
68
- checkPath(inval, name);
69
- }
70
- }
71
- return inval;
72
- }
73
- module.exports.getPathInput = getPathInput;
74
- function getPathInputRequired(name, check) {
75
- return getPathInput(name, true, check);
76
- }
77
- module.exports.getPathInputRequired = getPathInputRequired;
78
- //-----------------------------------------------------
79
- // Endpoint Helpers
80
- //-----------------------------------------------------
81
- module.exports.getEndpointUrl = task.getEndpointUrl;
82
- module.exports.getEndpointUrlRequired = task.getEndpointUrlRequired;
83
- module.exports.getEndpointDataParameter = task.getEndpointDataParameter;
84
- module.exports.getEndpointDataParameterRequired = task.getEndpointDataParameterRequired;
85
- module.exports.getEndpointAuthorizationScheme = task.getEndpointAuthorizationScheme;
86
- module.exports.getEndpointAuthorizationSchemeRequired = task.getEndpointAuthorizationSchemeRequired;
87
- module.exports.getEndpointAuthorizationParameter = task.getEndpointAuthorizationParameter;
88
- module.exports.getEndpointAuthorizationParameterRequired = task.getEndpointAuthorizationParameterRequired;
89
- module.exports.getEndpointAuthorization = task.getEndpointAuthorization;
90
- //-----------------------------------------------------
91
- // SecureFile Helpers
92
- //-----------------------------------------------------
93
- module.exports.getSecureFileName = task.getSecureFileName;
94
- module.exports.getSecureFileTicket = task.getSecureFileTicket;
95
- //-----------------------------------------------------
96
- // Fs Helpers
97
- //-----------------------------------------------------
98
- var FsStats = /** @class */ (function () {
99
- function FsStats() {
100
- this.m_isFile = false;
101
- this.m_isDirectory = false;
102
- this.m_isBlockDevice = false;
103
- this.m_isCharacterDevice = false;
104
- this.m_isSymbolicLink = false;
105
- this.m_isFIFO = false;
106
- this.m_isSocket = false;
107
- this.dev = 0;
108
- this.ino = 0;
109
- this.mode = 0;
110
- this.nlink = 0;
111
- this.uid = 0;
112
- this.gid = 0;
113
- this.rdev = 0;
114
- this.size = 0;
115
- this.blksize = 0;
116
- this.blocks = 0;
117
- this.atime = new Date();
118
- this.mtime = new Date();
119
- this.ctime = new Date();
120
- this.birthtime = new Date();
121
- }
122
- FsStats.prototype.setAnswers = function (mockResponses) {
123
- this.m_isFile = mockResponses['isFile'] || this.m_isFile;
124
- this.m_isDirectory = mockResponses['isDirectory'] || this.m_isDirectory;
125
- this.m_isBlockDevice = mockResponses['isBlockDevice'] || this.m_isBlockDevice;
126
- this.m_isCharacterDevice = mockResponses['isCharacterDevice'] || this.m_isCharacterDevice;
127
- this.m_isSymbolicLink = mockResponses['isSymbolicLink'] || this.m_isSymbolicLink;
128
- this.m_isFIFO = mockResponses['isFIFO'] || this.m_isFIFO;
129
- this.m_isSocket = mockResponses['isSocket'] || this.m_isSocket;
130
- this.dev = mockResponses['dev'] || this.dev;
131
- this.ino = mockResponses['ino'] || this.ino;
132
- this.mode = mockResponses['mode'] || this.mode;
133
- this.nlink = mockResponses['nlink'] || this.nlink;
134
- this.uid = mockResponses['uid'] || this.uid;
135
- this.gid = mockResponses['gid'] || this.gid;
136
- this.rdev = mockResponses['rdev'] || this.rdev;
137
- this.size = mockResponses['size'] || this.size;
138
- this.blksize = mockResponses['blksize'] || this.blksize;
139
- this.blocks = mockResponses['blocks'] || this.blocks;
140
- this.atime = mockResponses['atime'] || this.atime;
141
- this.mtime = mockResponses['mtime'] || this.mtime;
142
- this.ctime = mockResponses['ctime'] || this.ctime;
143
- this.m_isSocket = mockResponses['isSocket'] || this.m_isSocket;
144
- };
145
- FsStats.prototype.isFile = function () {
146
- return this.m_isFile;
147
- };
148
- FsStats.prototype.isDirectory = function () {
149
- return this.m_isDirectory;
150
- };
151
- FsStats.prototype.isBlockDevice = function () {
152
- return this.m_isBlockDevice;
153
- };
154
- FsStats.prototype.isCharacterDevice = function () {
155
- return this.m_isCharacterDevice;
156
- };
157
- FsStats.prototype.isSymbolicLink = function () {
158
- return this.m_isSymbolicLink;
159
- };
160
- FsStats.prototype.isFIFO = function () {
161
- return this.m_isFIFO;
162
- };
163
- FsStats.prototype.isSocket = function () {
164
- return this.m_isSocket;
165
- };
166
- return FsStats;
167
- }());
168
- exports.FsStats = FsStats;
169
- function stats(path) {
170
- var fsStats = new FsStats();
171
- fsStats.setAnswers(mock.getResponse('stats', path, module.exports.debug) || {});
172
- return fsStats;
173
- }
174
- exports.stats = stats;
175
- function exist(path) {
176
- return mock.getResponse('exist', path, module.exports.debug) || false;
177
- }
178
- exports.exist = exist;
179
- function writeFile(file, data, options) {
180
- //do nothing
181
- }
182
- exports.writeFile = writeFile;
183
- function osType() {
184
- return mock.getResponse('osType', 'osType', module.exports.debug);
185
- }
186
- exports.osType = osType;
187
- function getPlatform() {
188
- return mock.getResponse('getPlatform', 'getPlatform', module.exports.debug);
189
- }
190
- exports.getPlatform = getPlatform;
191
- function cwd() {
192
- return mock.getResponse('cwd', 'cwd', module.exports.debug);
193
- }
194
- exports.cwd = cwd;
195
- //-----------------------------------------------------
196
- // Cmd Helpers
197
- //-----------------------------------------------------
198
- module.exports.command = task.command;
199
- module.exports.warning = task.warning;
200
- module.exports.error = task.error;
201
- module.exports.debug = task.debug;
202
- function cd(path) {
203
- // do nothing. TODO: keep stack with asserts
204
- }
205
- exports.cd = cd;
206
- function pushd(path) {
207
- // do nothing. TODO: keep stack with asserts
208
- }
209
- exports.pushd = pushd;
210
- function popd() {
211
- // do nothing. TODO: keep stack with asserts
212
- }
213
- exports.popd = popd;
214
- //------------------------------------------------
215
- // Validation Helpers
216
- //------------------------------------------------
217
- function checkPath(p, name) {
218
- module.exports.debug('check path : ' + p);
219
- if (!p || !mock.getResponse('checkPath', p, module.exports.debug)) {
220
- throw new Error('Not found ' + p);
221
- }
222
- }
223
- exports.checkPath = checkPath;
224
- //-----------------------------------------------------
225
- // Shell/File I/O Helpers
226
- // Abstract these away so we can
227
- // - default to good error handling
228
- // - inject system.debug info
229
- // - have option to switch internal impl (shelljs now)
230
- //-----------------------------------------------------
231
- function mkdirP(p) {
232
- module.exports.debug('creating path: ' + p);
233
- }
234
- exports.mkdirP = mkdirP;
235
- function resolve() {
236
- // we can't do ...param if we target ES6 and node 5. This is what <=ES5 compiles down to.
237
- //return the posix implementation in the mock, so paths will be consistent when L0 tests are run on Windows or Mac/Linux
238
- var absolutePath = path.posix.resolve.apply(this, arguments);
239
- module.exports.debug('Absolute path for pathSegments: ' + arguments + ' = ' + absolutePath);
240
- return absolutePath;
241
- }
242
- exports.resolve = resolve;
243
- function which(tool, check) {
244
- var response = mock.getResponse('which', tool, module.exports.debug);
245
- if (check) {
246
- checkPath(response, tool);
247
- }
248
- return response;
249
- }
250
- exports.which = which;
251
- function ls(options, paths) {
252
- var response = mock.getResponse('ls', paths[0], module.exports.debug);
253
- if (!response) {
254
- return [];
255
- }
256
- return response;
257
- }
258
- exports.ls = ls;
259
- function cp(source, dest) {
260
- module.exports.debug('###copying###');
261
- module.exports.debug('copying ' + source + ' to ' + dest);
262
- }
263
- exports.cp = cp;
264
- function retry(func, args, retryOptions) {
265
- module.exports.debug("trying to execute " + (func === null || func === void 0 ? void 0 : func.name) + "(" + args.toString() + ") with " + retryOptions.retryCount + " retries");
266
- }
267
- exports.retry = retry;
268
- function find(findPath) {
269
- return mock.getResponse('find', findPath, module.exports.debug);
270
- }
271
- exports.find = find;
272
- function rmRF(path) {
273
- module.exports.debug('rmRF ' + path);
274
- var response = mock.getResponse('rmRF', path, module.exports.debug);
275
- if (!response['success']) {
276
- module.exports.setResult(1, response['message']);
277
- }
278
- }
279
- exports.rmRF = rmRF;
280
- function mv(source, dest, force, continueOnError) {
281
- module.exports.debug('moving ' + source + ' to ' + dest);
282
- return true;
283
- }
284
- exports.mv = mv;
285
- //-----------------------------------------------------
286
- // Exec convenience wrapper
287
- //-----------------------------------------------------
288
- function exec(tool, args, options) {
289
- var toolPath = which(tool, true);
290
- var tr = this.tool(toolPath);
291
- if (args) {
292
- tr.arg(args);
293
- }
294
- return tr.exec(options);
295
- }
296
- exports.exec = exec;
297
- function execSync(tool, args, options) {
298
- var toolPath = which(tool, true);
299
- var tr = this.tool(toolPath);
300
- if (args) {
301
- tr.arg(args);
302
- }
303
- return tr.execSync(options);
304
- }
305
- exports.execSync = execSync;
306
- function tool(tool) {
307
- var tr = new trm.ToolRunner(tool);
308
- tr.on('debug', function (message) {
309
- module.exports.debug(message);
310
- });
311
- return tr;
312
- }
313
- exports.tool = tool;
314
- //-----------------------------------------------------
315
- // Matching helpers
316
- //-----------------------------------------------------
317
- module.exports.filter = task.filter;
318
- module.exports.match = task.match;
319
- function findMatch(defaultRoot, patterns) {
320
- var responseKey = typeof patterns == 'object' ? patterns.join('\n') : patterns;
321
- return mock.getResponse('findMatch', responseKey, module.exports.debug);
322
- }
323
- exports.findMatch = findMatch;
324
- function legacyFindFiles(rootDirectory, pattern, includeFiles, includeDirectories) {
325
- return mock.getResponse('legacyFindFiles', pattern, module.exports.debug);
326
- }
327
- exports.legacyFindFiles = legacyFindFiles;
328
- //-----------------------------------------------------
329
- // Test Publisher
330
- //-----------------------------------------------------
331
- var TestPublisher = /** @class */ (function () {
332
- function TestPublisher(testRunner) {
333
- this.testRunner = testRunner;
334
- }
335
- TestPublisher.prototype.publish = function (resultFiles, mergeResults, platform, config, runTitle, publishRunAttachments) {
336
- var properties = {};
337
- properties['type'] = this.testRunner;
338
- if (mergeResults) {
339
- properties['mergeResults'] = mergeResults;
340
- }
341
- if (platform) {
342
- properties['platform'] = platform;
343
- }
344
- if (config) {
345
- properties['config'] = config;
346
- }
347
- if (runTitle) {
348
- properties['runTitle'] = runTitle;
349
- }
350
- if (publishRunAttachments) {
351
- properties['publishRunAttachments'] = publishRunAttachments;
352
- }
353
- if (resultFiles) {
354
- properties['resultFiles'] = resultFiles;
355
- }
356
- module.exports.command('results.publish', properties, '');
357
- };
358
- return TestPublisher;
359
- }());
360
- exports.TestPublisher = TestPublisher;
361
- //-----------------------------------------------------
362
- // Code Coverage Publisher
363
- //-----------------------------------------------------
364
- var CodeCoveragePublisher = /** @class */ (function () {
365
- function CodeCoveragePublisher() {
366
- }
367
- CodeCoveragePublisher.prototype.publish = function (codeCoverageTool, summaryFileLocation, reportDirectory, additionalCodeCoverageFiles) {
368
- var properties = {};
369
- if (codeCoverageTool) {
370
- properties['codecoveragetool'] = codeCoverageTool;
371
- }
372
- if (summaryFileLocation) {
373
- properties['summaryfile'] = summaryFileLocation;
374
- }
375
- if (reportDirectory) {
376
- properties['reportdirectory'] = reportDirectory;
377
- }
378
- if (additionalCodeCoverageFiles) {
379
- properties['additionalcodecoveragefiles'] = additionalCodeCoverageFiles;
380
- }
381
- module.exports.command('codecoverage.publish', properties, "");
382
- };
383
- return CodeCoveragePublisher;
384
- }());
385
- exports.CodeCoveragePublisher = CodeCoveragePublisher;
386
- //-----------------------------------------------------
387
- // Code coverage Publisher
388
- //-----------------------------------------------------
389
- var CodeCoverageEnabler = /** @class */ (function () {
390
- function CodeCoverageEnabler(buildTool, ccTool) {
391
- this.buildTool = buildTool;
392
- this.ccTool = ccTool;
393
- }
394
- CodeCoverageEnabler.prototype.enableCodeCoverage = function (buildProps) {
395
- buildProps['buildtool'] = this.buildTool;
396
- buildProps['codecoveragetool'] = this.ccTool;
397
- module.exports.command('codecoverage.enable', buildProps, "");
398
- };
399
- return CodeCoverageEnabler;
400
- }());
401
- exports.CodeCoverageEnabler = CodeCoverageEnabler;
402
- //-----------------------------------------------------
403
- // Task Logging Commands
404
- //-----------------------------------------------------
405
- exports.uploadFile = task.uploadFile;
406
- exports.prependPath = task.prependPath;
407
- exports.uploadSummary = task.uploadSummary;
408
- exports.addAttachment = task.addAttachment;
409
- exports.setEndpoint = task.setEndpoint;
410
- exports.setProgress = task.setProgress;
411
- exports.logDetail = task.logDetail;
412
- exports.logIssue = task.logIssue;
413
- //-----------------------------------------------------
414
- // Artifact Logging Commands
415
- //-----------------------------------------------------
416
- exports.uploadArtifact = task.uploadArtifact;
417
- exports.associateArtifact = task.associateArtifact;
418
- //-----------------------------------------------------
419
- // Build Logging Commands
420
- //-----------------------------------------------------
421
- exports.uploadBuildLog = task.uploadBuildLog;
422
- exports.updateBuildNumber = task.updateBuildNumber;
423
- exports.addBuildTag = task.addBuildTag;
424
- //-----------------------------------------------------
425
- // Release Logging Commands
426
- //-----------------------------------------------------
427
- exports.updateReleaseName = task.updateReleaseName;
428
- //-----------------------------------------------------
429
- // Tools
430
- //-----------------------------------------------------
431
- exports.TaskCommand = tcm.TaskCommand;
432
- exports.commandFromString = tcm.commandFromString;
433
- exports.ToolRunner = trm.ToolRunner;
434
- //-----------------------------------------------------
435
- // Http Proxy Helper
436
- //-----------------------------------------------------
437
- function getHttpProxyConfiguration(requestUrl) {
438
- return null;
439
- }
440
- exports.getHttpProxyConfiguration = getHttpProxyConfiguration;
441
- //-----------------------------------------------------
442
- // Http Certificate Helper
443
- //-----------------------------------------------------
444
- function getHttpCertConfiguration() {
445
- return null;
446
- }
447
- exports.getHttpCertConfiguration = getHttpCertConfiguration;
1
+ "use strict";
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;
4
+ var path = require("path");
5
+ var task = require("./task");
6
+ var tcm = require("./taskcommand");
7
+ var trm = require("./mock-toolrunner");
8
+ var ma = require("./mock-answer");
9
+ var mock = new ma.MockAnswers();
10
+ function setAnswers(answers) {
11
+ mock.initialize(answers);
12
+ trm.setAnswers(answers);
13
+ }
14
+ exports.setAnswers = setAnswers;
15
+ //-----------------------------------------------------
16
+ // Enums
17
+ //-----------------------------------------------------
18
+ module.exports.TaskResult = task.TaskResult;
19
+ module.exports.TaskState = task.TaskState;
20
+ module.exports.IssueType = task.IssueType;
21
+ module.exports.ArtifactType = task.ArtifactType;
22
+ module.exports.FieldType = task.FieldType;
23
+ module.exports.Platform = task.Platform;
24
+ //-----------------------------------------------------
25
+ // Results and Exiting
26
+ //-----------------------------------------------------
27
+ module.exports.setStdStream = task.setStdStream;
28
+ module.exports.setErrStream = task.setErrStream;
29
+ module.exports.setResult = task.setResult;
30
+ //-----------------------------------------------------
31
+ // Loc Helpers
32
+ //-----------------------------------------------------
33
+ function setResourcePath(path) {
34
+ // nothing in mock
35
+ }
36
+ exports.setResourcePath = setResourcePath;
37
+ function loc(key) {
38
+ var args = [];
39
+ for (var _i = 1; _i < arguments.length; _i++) {
40
+ args[_i - 1] = arguments[_i];
41
+ }
42
+ var str = 'loc_mock_' + key;
43
+ if (args.length) {
44
+ str += ' ' + args.join(' ');
45
+ }
46
+ return str;
47
+ }
48
+ exports.loc = loc;
49
+ //-----------------------------------------------------
50
+ // Input Helpers
51
+ //-----------------------------------------------------
52
+ module.exports.assertAgent = task.assertAgent;
53
+ module.exports.getVariable = task.getVariable;
54
+ module.exports.getVariables = task.getVariables;
55
+ module.exports.setVariable = task.setVariable;
56
+ module.exports.setSecret = task.setSecret;
57
+ module.exports.getTaskVariable = task.getTaskVariable;
58
+ module.exports.setTaskVariable = task.setTaskVariable;
59
+ module.exports.getInput = task.getInput;
60
+ module.exports.getInputRequired = task.getInputRequired;
61
+ module.exports.getBoolInput = task.getBoolInput;
62
+ module.exports.getDelimitedInput = task.getDelimitedInput;
63
+ module.exports.filePathSupplied = task.filePathSupplied;
64
+ function getPathInput(name, required, check) {
65
+ var inval = module.exports.getInput(name, required);
66
+ if (inval) {
67
+ if (check) {
68
+ checkPath(inval, name);
69
+ }
70
+ }
71
+ return inval;
72
+ }
73
+ module.exports.getPathInput = getPathInput;
74
+ function getPathInputRequired(name, check) {
75
+ return getPathInput(name, true, check);
76
+ }
77
+ module.exports.getPathInputRequired = getPathInputRequired;
78
+ //-----------------------------------------------------
79
+ // Endpoint Helpers
80
+ //-----------------------------------------------------
81
+ module.exports.getEndpointUrl = task.getEndpointUrl;
82
+ module.exports.getEndpointUrlRequired = task.getEndpointUrlRequired;
83
+ module.exports.getEndpointDataParameter = task.getEndpointDataParameter;
84
+ module.exports.getEndpointDataParameterRequired = task.getEndpointDataParameterRequired;
85
+ module.exports.getEndpointAuthorizationScheme = task.getEndpointAuthorizationScheme;
86
+ module.exports.getEndpointAuthorizationSchemeRequired = task.getEndpointAuthorizationSchemeRequired;
87
+ module.exports.getEndpointAuthorizationParameter = task.getEndpointAuthorizationParameter;
88
+ module.exports.getEndpointAuthorizationParameterRequired = task.getEndpointAuthorizationParameterRequired;
89
+ module.exports.getEndpointAuthorization = task.getEndpointAuthorization;
90
+ //-----------------------------------------------------
91
+ // SecureFile Helpers
92
+ //-----------------------------------------------------
93
+ module.exports.getSecureFileName = task.getSecureFileName;
94
+ module.exports.getSecureFileTicket = task.getSecureFileTicket;
95
+ //-----------------------------------------------------
96
+ // Fs Helpers
97
+ //-----------------------------------------------------
98
+ var FsStats = /** @class */ (function () {
99
+ function FsStats() {
100
+ this.m_isFile = false;
101
+ this.m_isDirectory = false;
102
+ this.m_isBlockDevice = false;
103
+ this.m_isCharacterDevice = false;
104
+ this.m_isSymbolicLink = false;
105
+ this.m_isFIFO = false;
106
+ this.m_isSocket = false;
107
+ this.dev = 0;
108
+ this.ino = 0;
109
+ this.mode = 0;
110
+ this.nlink = 0;
111
+ this.uid = 0;
112
+ this.gid = 0;
113
+ this.rdev = 0;
114
+ this.size = 0;
115
+ this.blksize = 0;
116
+ this.blocks = 0;
117
+ this.atime = new Date();
118
+ this.mtime = new Date();
119
+ this.ctime = new Date();
120
+ this.birthtime = new Date();
121
+ }
122
+ FsStats.prototype.setAnswers = function (mockResponses) {
123
+ this.m_isFile = mockResponses['isFile'] || this.m_isFile;
124
+ this.m_isDirectory = mockResponses['isDirectory'] || this.m_isDirectory;
125
+ this.m_isBlockDevice = mockResponses['isBlockDevice'] || this.m_isBlockDevice;
126
+ this.m_isCharacterDevice = mockResponses['isCharacterDevice'] || this.m_isCharacterDevice;
127
+ this.m_isSymbolicLink = mockResponses['isSymbolicLink'] || this.m_isSymbolicLink;
128
+ this.m_isFIFO = mockResponses['isFIFO'] || this.m_isFIFO;
129
+ this.m_isSocket = mockResponses['isSocket'] || this.m_isSocket;
130
+ this.dev = mockResponses['dev'] || this.dev;
131
+ this.ino = mockResponses['ino'] || this.ino;
132
+ this.mode = mockResponses['mode'] || this.mode;
133
+ this.nlink = mockResponses['nlink'] || this.nlink;
134
+ this.uid = mockResponses['uid'] || this.uid;
135
+ this.gid = mockResponses['gid'] || this.gid;
136
+ this.rdev = mockResponses['rdev'] || this.rdev;
137
+ this.size = mockResponses['size'] || this.size;
138
+ this.blksize = mockResponses['blksize'] || this.blksize;
139
+ this.blocks = mockResponses['blocks'] || this.blocks;
140
+ this.atime = mockResponses['atime'] || this.atime;
141
+ this.mtime = mockResponses['mtime'] || this.mtime;
142
+ this.ctime = mockResponses['ctime'] || this.ctime;
143
+ this.m_isSocket = mockResponses['isSocket'] || this.m_isSocket;
144
+ };
145
+ FsStats.prototype.isFile = function () {
146
+ return this.m_isFile;
147
+ };
148
+ FsStats.prototype.isDirectory = function () {
149
+ return this.m_isDirectory;
150
+ };
151
+ FsStats.prototype.isBlockDevice = function () {
152
+ return this.m_isBlockDevice;
153
+ };
154
+ FsStats.prototype.isCharacterDevice = function () {
155
+ return this.m_isCharacterDevice;
156
+ };
157
+ FsStats.prototype.isSymbolicLink = function () {
158
+ return this.m_isSymbolicLink;
159
+ };
160
+ FsStats.prototype.isFIFO = function () {
161
+ return this.m_isFIFO;
162
+ };
163
+ FsStats.prototype.isSocket = function () {
164
+ return this.m_isSocket;
165
+ };
166
+ return FsStats;
167
+ }());
168
+ exports.FsStats = FsStats;
169
+ function stats(path) {
170
+ var fsStats = new FsStats();
171
+ fsStats.setAnswers(mock.getResponse('stats', path, module.exports.debug) || {});
172
+ return fsStats;
173
+ }
174
+ exports.stats = stats;
175
+ function exist(path) {
176
+ return mock.getResponse('exist', path, module.exports.debug) || false;
177
+ }
178
+ exports.exist = exist;
179
+ function writeFile(file, data, options) {
180
+ //do nothing
181
+ }
182
+ exports.writeFile = writeFile;
183
+ function osType() {
184
+ return mock.getResponse('osType', 'osType', module.exports.debug);
185
+ }
186
+ exports.osType = osType;
187
+ function getPlatform() {
188
+ return mock.getResponse('getPlatform', 'getPlatform', module.exports.debug);
189
+ }
190
+ exports.getPlatform = getPlatform;
191
+ function getAgentMode() {
192
+ return mock.getResponse('getAgentMode', 'getAgentMode', module.exports.debug);
193
+ }
194
+ exports.getAgentMode = getAgentMode;
195
+ function cwd() {
196
+ return mock.getResponse('cwd', 'cwd', module.exports.debug);
197
+ }
198
+ exports.cwd = cwd;
199
+ //-----------------------------------------------------
200
+ // Cmd Helpers
201
+ //-----------------------------------------------------
202
+ module.exports.command = task.command;
203
+ module.exports.warning = task.warning;
204
+ module.exports.error = task.error;
205
+ module.exports.debug = task.debug;
206
+ function cd(path) {
207
+ // do nothing. TODO: keep stack with asserts
208
+ }
209
+ exports.cd = cd;
210
+ function pushd(path) {
211
+ // do nothing. TODO: keep stack with asserts
212
+ }
213
+ exports.pushd = pushd;
214
+ function popd() {
215
+ // do nothing. TODO: keep stack with asserts
216
+ }
217
+ exports.popd = popd;
218
+ //------------------------------------------------
219
+ // Validation Helpers
220
+ //------------------------------------------------
221
+ function checkPath(p, name) {
222
+ module.exports.debug('check path : ' + p);
223
+ if (!p || !mock.getResponse('checkPath', p, module.exports.debug)) {
224
+ throw new Error('Not found ' + p);
225
+ }
226
+ }
227
+ exports.checkPath = checkPath;
228
+ //-----------------------------------------------------
229
+ // Shell/File I/O Helpers
230
+ // Abstract these away so we can
231
+ // - default to good error handling
232
+ // - inject system.debug info
233
+ // - have option to switch internal impl (shelljs now)
234
+ //-----------------------------------------------------
235
+ function mkdirP(p) {
236
+ module.exports.debug('creating path: ' + p);
237
+ }
238
+ exports.mkdirP = mkdirP;
239
+ function resolve() {
240
+ // we can't do ...param if we target ES6 and node 5. This is what <=ES5 compiles down to.
241
+ //return the posix implementation in the mock, so paths will be consistent when L0 tests are run on Windows or Mac/Linux
242
+ var absolutePath = path.posix.resolve.apply(this, arguments);
243
+ module.exports.debug('Absolute path for pathSegments: ' + arguments + ' = ' + absolutePath);
244
+ return absolutePath;
245
+ }
246
+ exports.resolve = resolve;
247
+ function which(tool, check) {
248
+ var response = mock.getResponse('which', tool, module.exports.debug);
249
+ if (check) {
250
+ checkPath(response, tool);
251
+ }
252
+ return response;
253
+ }
254
+ exports.which = which;
255
+ function ls(options, paths) {
256
+ var response = mock.getResponse('ls', paths[0], module.exports.debug);
257
+ if (!response) {
258
+ return [];
259
+ }
260
+ return response;
261
+ }
262
+ exports.ls = ls;
263
+ function cp(source, dest) {
264
+ module.exports.debug('###copying###');
265
+ module.exports.debug('copying ' + source + ' to ' + dest);
266
+ }
267
+ exports.cp = cp;
268
+ function retry(func, args, retryOptions) {
269
+ module.exports.debug("trying to execute " + (func === null || func === void 0 ? void 0 : func.name) + "(" + args.toString() + ") with " + retryOptions.retryCount + " retries");
270
+ }
271
+ exports.retry = retry;
272
+ function find(findPath) {
273
+ return mock.getResponse('find', findPath, module.exports.debug);
274
+ }
275
+ exports.find = find;
276
+ function rmRF(path) {
277
+ module.exports.debug('rmRF ' + path);
278
+ var response = mock.getResponse('rmRF', path, module.exports.debug);
279
+ if (!response['success']) {
280
+ module.exports.setResult(1, response['message']);
281
+ }
282
+ }
283
+ exports.rmRF = rmRF;
284
+ function mv(source, dest, force, continueOnError) {
285
+ module.exports.debug('moving ' + source + ' to ' + dest);
286
+ return true;
287
+ }
288
+ exports.mv = mv;
289
+ //-----------------------------------------------------
290
+ // Exec convenience wrapper
291
+ //-----------------------------------------------------
292
+ function exec(tool, args, options) {
293
+ var toolPath = which(tool, true);
294
+ var tr = this.tool(toolPath);
295
+ if (args) {
296
+ tr.arg(args);
297
+ }
298
+ return tr.exec(options);
299
+ }
300
+ exports.exec = exec;
301
+ function execSync(tool, args, options) {
302
+ var toolPath = which(tool, true);
303
+ var tr = this.tool(toolPath);
304
+ if (args) {
305
+ tr.arg(args);
306
+ }
307
+ return tr.execSync(options);
308
+ }
309
+ exports.execSync = execSync;
310
+ function tool(tool) {
311
+ var tr = new trm.ToolRunner(tool);
312
+ tr.on('debug', function (message) {
313
+ module.exports.debug(message);
314
+ });
315
+ return tr;
316
+ }
317
+ exports.tool = tool;
318
+ //-----------------------------------------------------
319
+ // Matching helpers
320
+ //-----------------------------------------------------
321
+ module.exports.filter = task.filter;
322
+ module.exports.match = task.match;
323
+ function findMatch(defaultRoot, patterns) {
324
+ var responseKey = typeof patterns == 'object' ? patterns.join('\n') : patterns;
325
+ return mock.getResponse('findMatch', responseKey, module.exports.debug);
326
+ }
327
+ exports.findMatch = findMatch;
328
+ function legacyFindFiles(rootDirectory, pattern, includeFiles, includeDirectories) {
329
+ return mock.getResponse('legacyFindFiles', pattern, module.exports.debug);
330
+ }
331
+ exports.legacyFindFiles = legacyFindFiles;
332
+ //-----------------------------------------------------
333
+ // Test Publisher
334
+ //-----------------------------------------------------
335
+ var TestPublisher = /** @class */ (function () {
336
+ function TestPublisher(testRunner) {
337
+ this.testRunner = testRunner;
338
+ }
339
+ TestPublisher.prototype.publish = function (resultFiles, mergeResults, platform, config, runTitle, publishRunAttachments) {
340
+ var properties = {};
341
+ properties['type'] = this.testRunner;
342
+ if (mergeResults) {
343
+ properties['mergeResults'] = mergeResults;
344
+ }
345
+ if (platform) {
346
+ properties['platform'] = platform;
347
+ }
348
+ if (config) {
349
+ properties['config'] = config;
350
+ }
351
+ if (runTitle) {
352
+ properties['runTitle'] = runTitle;
353
+ }
354
+ if (publishRunAttachments) {
355
+ properties['publishRunAttachments'] = publishRunAttachments;
356
+ }
357
+ if (resultFiles) {
358
+ properties['resultFiles'] = resultFiles;
359
+ }
360
+ module.exports.command('results.publish', properties, '');
361
+ };
362
+ return TestPublisher;
363
+ }());
364
+ exports.TestPublisher = TestPublisher;
365
+ //-----------------------------------------------------
366
+ // Code Coverage Publisher
367
+ //-----------------------------------------------------
368
+ var CodeCoveragePublisher = /** @class */ (function () {
369
+ function CodeCoveragePublisher() {
370
+ }
371
+ CodeCoveragePublisher.prototype.publish = function (codeCoverageTool, summaryFileLocation, reportDirectory, additionalCodeCoverageFiles) {
372
+ var properties = {};
373
+ if (codeCoverageTool) {
374
+ properties['codecoveragetool'] = codeCoverageTool;
375
+ }
376
+ if (summaryFileLocation) {
377
+ properties['summaryfile'] = summaryFileLocation;
378
+ }
379
+ if (reportDirectory) {
380
+ properties['reportdirectory'] = reportDirectory;
381
+ }
382
+ if (additionalCodeCoverageFiles) {
383
+ properties['additionalcodecoveragefiles'] = additionalCodeCoverageFiles;
384
+ }
385
+ module.exports.command('codecoverage.publish', properties, "");
386
+ };
387
+ return CodeCoveragePublisher;
388
+ }());
389
+ exports.CodeCoveragePublisher = CodeCoveragePublisher;
390
+ //-----------------------------------------------------
391
+ // Code coverage Publisher
392
+ //-----------------------------------------------------
393
+ var CodeCoverageEnabler = /** @class */ (function () {
394
+ function CodeCoverageEnabler(buildTool, ccTool) {
395
+ this.buildTool = buildTool;
396
+ this.ccTool = ccTool;
397
+ }
398
+ CodeCoverageEnabler.prototype.enableCodeCoverage = function (buildProps) {
399
+ buildProps['buildtool'] = this.buildTool;
400
+ buildProps['codecoveragetool'] = this.ccTool;
401
+ module.exports.command('codecoverage.enable', buildProps, "");
402
+ };
403
+ return CodeCoverageEnabler;
404
+ }());
405
+ exports.CodeCoverageEnabler = CodeCoverageEnabler;
406
+ //-----------------------------------------------------
407
+ // Task Logging Commands
408
+ //-----------------------------------------------------
409
+ exports.uploadFile = task.uploadFile;
410
+ exports.prependPath = task.prependPath;
411
+ exports.uploadSummary = task.uploadSummary;
412
+ exports.addAttachment = task.addAttachment;
413
+ exports.setEndpoint = task.setEndpoint;
414
+ exports.setProgress = task.setProgress;
415
+ exports.logDetail = task.logDetail;
416
+ exports.logIssue = task.logIssue;
417
+ //-----------------------------------------------------
418
+ // Artifact Logging Commands
419
+ //-----------------------------------------------------
420
+ exports.uploadArtifact = task.uploadArtifact;
421
+ exports.associateArtifact = task.associateArtifact;
422
+ //-----------------------------------------------------
423
+ // Build Logging Commands
424
+ //-----------------------------------------------------
425
+ exports.uploadBuildLog = task.uploadBuildLog;
426
+ exports.updateBuildNumber = task.updateBuildNumber;
427
+ exports.addBuildTag = task.addBuildTag;
428
+ //-----------------------------------------------------
429
+ // Release Logging Commands
430
+ //-----------------------------------------------------
431
+ exports.updateReleaseName = task.updateReleaseName;
432
+ //-----------------------------------------------------
433
+ // Tools
434
+ //-----------------------------------------------------
435
+ exports.TaskCommand = tcm.TaskCommand;
436
+ exports.commandFromString = tcm.commandFromString;
437
+ exports.ToolRunner = trm.ToolRunner;
438
+ //-----------------------------------------------------
439
+ // Http Proxy Helper
440
+ //-----------------------------------------------------
441
+ function getHttpProxyConfiguration(requestUrl) {
442
+ return null;
443
+ }
444
+ exports.getHttpProxyConfiguration = getHttpProxyConfiguration;
445
+ //-----------------------------------------------------
446
+ // Http Certificate Helper
447
+ //-----------------------------------------------------
448
+ function getHttpCertConfiguration() {
449
+ return null;
450
+ }
451
+ exports.getHttpCertConfiguration = getHttpCertConfiguration;