azure-pipelines-task-lib 4.0.0-preview → 4.0.1-preview

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,447 @@
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.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;