azure-pipelines-task-lib 4.11.0 → 4.12.1

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/internal.d.ts CHANGED
@@ -16,6 +16,10 @@ export declare enum IssueSource {
16
16
  CustomerScript = "CustomerScript",
17
17
  TaskInternal = "TaskInternal"
18
18
  }
19
+ export declare enum IssueAuditAction {
20
+ Unknown = 0,
21
+ ShellTasksValidation = 1
22
+ }
19
23
  export declare function _startsWith(str: string, start: string): boolean;
20
24
  export declare function _endsWith(str: string, end: string): boolean;
21
25
  export declare function _truncateBeforeSensitiveKeyword(str: string, sensitiveKeywordsPattern: RegExp): string;
@@ -56,8 +60,8 @@ export interface _KnownVariableInfo {
56
60
  secret: boolean;
57
61
  }
58
62
  export declare function _command(command: string, properties: any, message: string): void;
59
- export declare function _warning(message: string, source?: IssueSource): void;
60
- export declare function _error(message: string, source?: IssueSource): void;
63
+ export declare function _warning(message: string, source?: IssueSource, auditAction?: IssueAuditAction): void;
64
+ export declare function _error(message: string, source?: IssueSource, auditAction?: IssueAuditAction): void;
61
65
  export declare function _debug(message: string): void;
62
66
  /**
63
67
  * Returns whether a path exists.
package/internal.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  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._truncateBeforeSensitiveKeyword = exports._endsWith = exports._startsWith = exports.IssueSource = exports._vault = exports._knownVariableMap = void 0;
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._truncateBeforeSensitiveKeyword = exports._endsWith = exports._startsWith = exports.IssueAuditAction = exports.IssueSource = exports._vault = exports._knownVariableMap = void 0;
4
4
  var fs = require("fs");
5
5
  var path = require("path");
6
6
  var os = require("os");
@@ -29,6 +29,11 @@ var IssueSource;
29
29
  IssueSource["CustomerScript"] = "CustomerScript";
30
30
  IssueSource["TaskInternal"] = "TaskInternal";
31
31
  })(IssueSource = exports.IssueSource || (exports.IssueSource = {}));
32
+ var IssueAuditAction;
33
+ (function (IssueAuditAction) {
34
+ IssueAuditAction[IssueAuditAction["Unknown"] = 0] = "Unknown";
35
+ IssueAuditAction[IssueAuditAction["ShellTasksValidation"] = 1] = "ShellTasksValidation";
36
+ })(IssueAuditAction = exports.IssueAuditAction || (exports.IssueAuditAction = {}));
32
37
  //-----------------------------------------------------
33
38
  // Validation Checks
34
39
  //-----------------------------------------------------
@@ -268,14 +273,24 @@ function _command(command, properties, message) {
268
273
  _writeLine(taskCmd.toString());
269
274
  }
270
275
  exports._command = _command;
271
- function _warning(message, source) {
276
+ function _warning(message, source, auditAction) {
272
277
  if (source === void 0) { source = IssueSource.TaskInternal; }
273
- _command('task.issue', { 'type': 'warning', 'source': source, 'correlationId': _commandCorrelationId }, message);
278
+ _command('task.issue', {
279
+ 'type': 'warning',
280
+ 'source': source,
281
+ 'correlationId': _commandCorrelationId,
282
+ 'auditAction': auditAction
283
+ }, message);
274
284
  }
275
285
  exports._warning = _warning;
276
- function _error(message, source) {
286
+ function _error(message, source, auditAction) {
277
287
  if (source === void 0) { source = IssueSource.TaskInternal; }
278
- _command('task.issue', { 'type': 'error', 'source': source, 'correlationId': _commandCorrelationId }, message);
288
+ _command('task.issue', {
289
+ 'type': 'error',
290
+ 'source': source,
291
+ 'correlationId': _commandCorrelationId,
292
+ 'auditAction': auditAction
293
+ }, message);
279
294
  }
280
295
  exports._error = _error;
281
296
  function _debug(message) {
package/mock-test.d.ts CHANGED
@@ -10,7 +10,7 @@ export declare class MockTestRunner {
10
10
  succeeded: boolean;
11
11
  errorIssues: string[];
12
12
  warningIssues: string[];
13
- LoadAsync(testPath: string, taskJsonPath?: string): Promise<MockTestRunner>;
13
+ LoadAsync(testPath?: string, taskJsonPath?: string): Promise<MockTestRunner>;
14
14
  get failed(): boolean;
15
15
  ran(cmdline: string): boolean;
16
16
  createdErrorIssue(message: string): boolean;
@@ -18,12 +18,7 @@ export declare class MockTestRunner {
18
18
  stdOutContained(message: string): boolean;
19
19
  stdErrContained(message: string): boolean;
20
20
  runAsync(nodeVersion?: number): Promise<void>;
21
- /**
22
- * @deprecated This method uses library which is not prefered to use on production
23
- */
24
- run(nodeVersion?: number): void;
25
21
  private getNodePath;
26
- private getNodePathSync;
27
22
  private getNodeVersion;
28
23
  private getTaskJsonPath;
29
24
  private downloadNode;
package/mock-test.js CHANGED
@@ -39,12 +39,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.MockTestRunner = void 0;
40
40
  var cp = require("child_process");
41
41
  var fs = require("fs");
42
- var ncp = require("child_process");
43
42
  var os = require("os");
44
43
  var path = require("path");
45
44
  var cmdm = require("./taskcommand");
46
45
  var shelljs = require("shelljs");
47
- var deasync = require("deasync");
48
46
  var Downloader = require("nodejs-file-downloader");
49
47
  var COMMAND_TAG = '[command]';
50
48
  var COMMAND_LENGTH = COMMAND_TAG.length;
@@ -65,7 +63,6 @@ var MockTestRunner = /** @class */ (function () {
65
63
  return;
66
64
  this._taskJsonPath = taskJsonPath || '';
67
65
  this._testPath = testPath;
68
- this.nodePath = this.getNodePathSync();
69
66
  }
70
67
  MockTestRunner.prototype.LoadAsync = function (testPath, taskJsonPath) {
71
68
  return __awaiter(this, void 0, void 0, function () {
@@ -80,8 +77,12 @@ var MockTestRunner = /** @class */ (function () {
80
77
  resolve(this);
81
78
  return [2 /*return*/];
82
79
  }
83
- this._taskJsonPath = taskJsonPath || '';
84
- this._testPath = testPath;
80
+ if (testPath) {
81
+ this._testPath = testPath;
82
+ }
83
+ if (taskJsonPath) {
84
+ this._taskJsonPath = taskJsonPath;
85
+ }
85
86
  _a = this;
86
87
  return [4 /*yield*/, this.getNodePath()];
87
88
  case 1:
@@ -133,8 +134,15 @@ var MockTestRunner = /** @class */ (function () {
133
134
  return [4 /*yield*/, this.getNodePath(nodeVersion)];
134
135
  case 1:
135
136
  nodePath = _a.sent();
136
- _a.label = 2;
137
+ return [3 /*break*/, 4];
137
138
  case 2:
139
+ if (!!nodePath) return [3 /*break*/, 4];
140
+ return [4 /*yield*/, this.getNodePath()];
141
+ case 3:
142
+ nodePath = _a.sent();
143
+ this.nodePath = nodePath;
144
+ _a.label = 4;
145
+ case 4:
138
146
  spawn = cp.spawnSync(nodePath, [this._testPath]);
139
147
  // Clean environment
140
148
  Object.keys(process.env)
@@ -199,14 +207,6 @@ var MockTestRunner = /** @class */ (function () {
199
207
  });
200
208
  });
201
209
  };
202
- /**
203
- * @deprecated This method uses library which is not prefered to use on production
204
- */
205
- MockTestRunner.prototype.run = function (nodeVersion) {
206
- var completeExecution = false;
207
- this.runAsync(nodeVersion).then(function (t) { return completeExecution = true; });
208
- deasync.loopWhile(function () { return !completeExecution; });
209
- };
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 () {
@@ -240,12 +240,6 @@ var MockTestRunner = /** @class */ (function () {
240
240
  });
241
241
  });
242
242
  };
243
- MockTestRunner.prototype.getNodePathSync = function (nodeVersion) {
244
- var nodePath = '';
245
- this.getNodePath(nodeVersion).then(function (t) { return nodePath = t; });
246
- deasync.loopWhile(function () { return nodePath == ''; });
247
- return nodePath;
248
- };
249
243
  // Determines the correct version of node to use based on the contents of the task's task.json. Defaults to Node 16.
250
244
  MockTestRunner.prototype.getNodeVersion = function () {
251
245
  var taskJsonPath = this.getTaskJsonPath();
@@ -389,7 +383,7 @@ var MockTestRunner = /** @class */ (function () {
389
383
  originalCwd = process.cwd();
390
384
  process.chdir(downloadDestination);
391
385
  try {
392
- ncp.execSync("tar -xzf \"" + path.join(downloadDestination, tarGzName) + "\"");
386
+ cp.execSync("tar -xzf \"" + path.join(downloadDestination, tarGzName) + "\"");
393
387
  }
394
388
  catch (_b) {
395
389
  throw new Error('Failed to unzip node tar.gz from ' + url);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azure-pipelines-task-lib",
3
- "version": "4.11.0",
3
+ "version": "4.12.1",
4
4
  "description": "Azure Pipelines Task SDK",
5
5
  "main": "./task.js",
6
6
  "typings": "./task.d.ts",
@@ -28,7 +28,6 @@
28
28
  "homepage": "https://github.com/Microsoft/azure-pipelines-task-lib",
29
29
  "dependencies": {
30
30
  "adm-zip": "^0.5.10",
31
- "deasync": "^0.1.28",
32
31
  "minimatch": "3.0.5",
33
32
  "nodejs-file-downloader": "^4.11.1",
34
33
  "q": "^1.5.1",