azure-pipelines-task-lib 4.1.0 → 4.3.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/README.md CHANGED
@@ -13,9 +13,9 @@ Cross platform tasks are written in TypeScript. It is the preferred way to writ
13
13
 
14
14
  Step by Step: [Create Task](https://docs.microsoft.com/en-us/azure/devops/extend/develop/add-build-task?view=vsts)
15
15
 
16
- Documentation: [TypeScript API](docs/azure-pipelines-task-lib.md), [task JSON schema](https://aka.ms/vsts-tasks.schema.json)
16
+ Documentation: [TypeScript API](https://github.com/microsoft/azure-pipelines-task-lib/blob/master/node/docs/azure-pipelines-task-lib.md), [task JSON schema](https://aka.ms/vsts-tasks.schema.json)
17
17
 
18
- Guidance: [Finding Files](docs/findingfiles.md), [Minimum agent version](docs/minagent.md), [Proxy](docs/proxy.md), [Certificate](docs/cert.md)
18
+ Guidance: [Finding Files](https://github.com/microsoft/azure-pipelines-task-lib/blob/master/node/docs/findingfiles.md), [Minimum agent version](https://github.com/microsoft/azure-pipelines-task-lib/blob/master/node/docs/minagent.md), [Proxy](https://github.com/microsoft/azure-pipelines-task-lib/blob/master/node/docs/proxy.md), [Certificate](https://github.com/microsoft/azure-pipelines-task-lib/blob/master/node/docs/cert.md)
19
19
 
20
20
  ## Node 10 Upgrade Notice
21
21
 
@@ -37,7 +37,7 @@ The [ShellScript Task](https://github.com/Microsoft/azure-pipelines-tasks/tree/m
37
37
 
38
38
  We are accepting contributions and we try to stay on top of issues.
39
39
 
40
- [Contribution Guide](../CONTRIBUTING.md).
40
+ [Contribution Guide](https://github.com/microsoft/azure-pipelines-task-lib/blob/master/CONTRIBUTING.md).
41
41
 
42
42
  [Logging Issues](https://github.com/Microsoft/azure-pipelines-task-lib/issues)
43
43
 
@@ -63,9 +63,9 @@ Set environment variable TASK_TEST_TRACE=1 to display test output.
63
63
 
64
64
  We also maintain a PowerShell library for Windows task development.
65
65
 
66
- Library: [Powershell Library](../powershell)
66
+ Library: [Powershell Library](https://github.com/microsoft/azure-pipelines-task-lib/tree/master/powershell)
67
67
 
68
- Usage: [Consuming the SDK](../powershell/Docs/Consuming.md)
68
+ Usage: [Consuming the SDK](https://github.com/microsoft/azure-pipelines-task-lib/blob/master/powershell/Docs/Consuming.md)
69
69
 
70
70
  ## Third Party Notices
71
71
  To generate/update third party notice file run:
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
+ getAgentMode?: {
30
+ [key: string]: task.AgentHostedMode;
31
+ };
29
32
  legacyFindFiles?: {
30
33
  [key: string]: string[];
31
34
  };
package/mock-task.d.ts CHANGED
@@ -58,6 +58,7 @@ export interface FsOptions {
58
58
  export declare function writeFile(file: string, data: string | Buffer, options?: string | FsOptions): void;
59
59
  export declare function osType(): string;
60
60
  export declare function getPlatform(): task.Platform;
61
+ export declare function getAgentMode(): task.AgentHostedMode;
61
62
  export declare function cwd(): string;
62
63
  export declare function cd(path: string): void;
63
64
  export declare function pushd(path: string): void;
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.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.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
4
  var path = require("path");
5
5
  var task = require("./task");
6
6
  var tcm = require("./taskcommand");
@@ -188,6 +188,10 @@ function getPlatform() {
188
188
  return mock.getResponse('getPlatform', 'getPlatform', module.exports.debug);
189
189
  }
190
190
  exports.getPlatform = getPlatform;
191
+ function getAgentMode() {
192
+ return mock.getResponse('getAgentMode', 'getAgentMode', module.exports.debug);
193
+ }
194
+ exports.getAgentMode = getAgentMode;
191
195
  function cwd() {
192
196
  return mock.getResponse('cwd', 'cwd', module.exports.debug);
193
197
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azure-pipelines-task-lib",
3
- "version": "4.1.0",
3
+ "version": "4.3.0",
4
4
  "description": "Azure Pipelines Task SDK",
5
5
  "main": "./task.js",
6
6
  "typings": "./task.d.ts",
package/task.d.ts CHANGED
@@ -38,6 +38,11 @@ export declare enum Platform {
38
38
  MacOS = 1,
39
39
  Linux = 2
40
40
  }
41
+ export declare enum AgentHostedMode {
42
+ Unknown = 0,
43
+ SelfHosted = 1,
44
+ MsHosted = 2
45
+ }
41
46
  export declare const setStdStream: typeof im._setStdStream;
42
47
  export declare const setErrStream: typeof im._setErrStream;
43
48
  /**
@@ -311,6 +316,11 @@ export declare function osType(): string;
311
316
  * @throws {Error} Platform is not supported by our agent
312
317
  */
313
318
  export declare function getPlatform(): Platform;
319
+ /**
320
+ * Return hosted type of Agent
321
+ * @returns {AgentHostedMode}
322
+ */
323
+ export declare function getAgentMode(): AgentHostedMode;
314
324
  /**
315
325
  * Returns the process's current working directory.
316
326
  * see [process.cwd](https://nodejs.org/api/process.html#process_process_cwd)
package/task.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateReleaseName = exports.addBuildTag = exports.updateBuildNumber = exports.uploadBuildLog = exports.associateArtifact = exports.uploadArtifact = exports.logIssue = exports.logDetail = exports.setProgress = exports.setEndpoint = exports.addAttachment = exports.uploadSummary = exports.prependPath = exports.uploadFile = exports.CodeCoverageEnabler = exports.CodeCoveragePublisher = exports.TestPublisher = exports.getHttpCertConfiguration = exports.getHttpProxyConfiguration = exports.findMatch = exports.filter = exports.match = exports.tool = exports.execSync = exports.exec = exports.rmRF = exports.legacyFindFiles = exports.find = exports.retry = exports.mv = exports.cp = exports.ls = exports.which = exports.resolve = exports.mkdirP = exports.popd = exports.pushd = exports.cd = exports.checkPath = exports.cwd = exports.getPlatform = exports.osType = exports.writeFile = exports.exist = exports.stats = exports.debug = exports.error = exports.warning = exports.command = exports.setTaskVariable = exports.getTaskVariable = exports.getSecureFileTicket = exports.getSecureFileName = exports.getEndpointAuthorization = exports.getEndpointAuthorizationParameterRequired = exports.getEndpointAuthorizationParameter = exports.getEndpointAuthorizationSchemeRequired = exports.getEndpointAuthorizationScheme = exports.getEndpointDataParameterRequired = exports.getEndpointDataParameter = exports.getEndpointUrlRequired = exports.getEndpointUrl = exports.getPathInputRequired = exports.getPathInput = exports.filePathSupplied = exports.getDelimitedInput = exports.getBoolInput = exports.getInputRequired = exports.getInput = exports.setSecret = exports.setVariable = exports.getVariables = exports.assertAgent = exports.getVariable = exports.loc = exports.setResourcePath = exports.setResult = exports.setErrStream = exports.setStdStream = exports.Platform = exports.FieldType = exports.ArtifactType = exports.IssueType = exports.TaskState = exports.TaskResult = void 0;
3
+ exports.updateReleaseName = exports.addBuildTag = exports.updateBuildNumber = exports.uploadBuildLog = exports.associateArtifact = exports.uploadArtifact = exports.logIssue = exports.logDetail = exports.setProgress = exports.setEndpoint = exports.addAttachment = exports.uploadSummary = exports.prependPath = exports.uploadFile = exports.CodeCoverageEnabler = exports.CodeCoveragePublisher = exports.TestPublisher = exports.getHttpCertConfiguration = exports.getHttpProxyConfiguration = exports.findMatch = exports.filter = exports.match = exports.tool = exports.execSync = exports.exec = exports.rmRF = exports.legacyFindFiles = exports.find = exports.retry = exports.mv = exports.cp = exports.ls = exports.which = exports.resolve = exports.mkdirP = exports.popd = exports.pushd = exports.cd = exports.checkPath = exports.cwd = exports.getAgentMode = exports.getPlatform = exports.osType = exports.writeFile = exports.exist = exports.stats = exports.debug = exports.error = exports.warning = exports.command = exports.setTaskVariable = exports.getTaskVariable = exports.getSecureFileTicket = exports.getSecureFileName = exports.getEndpointAuthorization = exports.getEndpointAuthorizationParameterRequired = exports.getEndpointAuthorizationParameter = exports.getEndpointAuthorizationSchemeRequired = exports.getEndpointAuthorizationScheme = exports.getEndpointDataParameterRequired = exports.getEndpointDataParameter = exports.getEndpointUrlRequired = exports.getEndpointUrl = exports.getPathInputRequired = exports.getPathInput = exports.filePathSupplied = exports.getDelimitedInput = exports.getBoolInput = exports.getInputRequired = exports.getInput = exports.setSecret = exports.setVariable = exports.getVariables = exports.assertAgent = exports.getVariable = exports.loc = exports.setResourcePath = exports.setResult = exports.setErrStream = exports.setStdStream = exports.AgentHostedMode = exports.Platform = exports.FieldType = exports.ArtifactType = exports.IssueType = exports.TaskState = exports.TaskResult = void 0;
4
4
  var shell = require("shelljs");
5
5
  var childProcess = require("child_process");
6
6
  var fs = require("fs");
@@ -52,6 +52,12 @@ var Platform;
52
52
  Platform[Platform["MacOS"] = 1] = "MacOS";
53
53
  Platform[Platform["Linux"] = 2] = "Linux";
54
54
  })(Platform = exports.Platform || (exports.Platform = {}));
55
+ var AgentHostedMode;
56
+ (function (AgentHostedMode) {
57
+ AgentHostedMode[AgentHostedMode["Unknown"] = 0] = "Unknown";
58
+ AgentHostedMode[AgentHostedMode["SelfHosted"] = 1] = "SelfHosted";
59
+ AgentHostedMode[AgentHostedMode["MsHosted"] = 2] = "MsHosted";
60
+ })(AgentHostedMode = exports.AgentHostedMode || (exports.AgentHostedMode = {}));
55
61
  //-----------------------------------------------------
56
62
  // General Helpers
57
63
  //-----------------------------------------------------
@@ -97,6 +103,20 @@ process.on('uncaughtException', function (err) {
97
103
  setResult(TaskResult.Failed, exports.loc('LIB_UnhandledEx', err.message));
98
104
  exports.error(String(err.stack));
99
105
  });
106
+ //
107
+ // Catching unhandled rejections from promises and rethrowing them as exceptions
108
+ // For example, a promise that is rejected but not handled by a .catch() handler in node 10
109
+ // doesn't cause an uncaughtException but causes in Node 16.
110
+ // For types definitions(Error | Any) see https://nodejs.org/docs/latest-v16.x/api/process.html#event-unhandledrejection
111
+ //
112
+ process.on('unhandledRejection', function (reason) {
113
+ if (reason instanceof Error) {
114
+ throw reason;
115
+ }
116
+ else {
117
+ throw new Error(reason);
118
+ }
119
+ });
100
120
  //-----------------------------------------------------
101
121
  // Loc Helpers
102
122
  //-----------------------------------------------------
@@ -594,6 +614,19 @@ function getPlatform() {
594
614
  }
595
615
  }
596
616
  exports.getPlatform = getPlatform;
617
+ /**
618
+ * Return hosted type of Agent
619
+ * @returns {AgentHostedMode}
620
+ */
621
+ function getAgentMode() {
622
+ var agentCloudId = exports.getVariable('Agent.CloudId');
623
+ if (agentCloudId === undefined)
624
+ return AgentHostedMode.Unknown;
625
+ if (agentCloudId)
626
+ return AgentHostedMode.MsHosted;
627
+ return AgentHostedMode.SelfHosted;
628
+ }
629
+ exports.getAgentMode = getAgentMode;
597
630
  /**
598
631
  * Returns the process's current working directory.
599
632
  * see [process.cwd](https://nodejs.org/api/process.html#process_process_cwd)
package/toolrunner.d.ts CHANGED
@@ -122,7 +122,7 @@ export declare class ToolRunner extends events.EventEmitter {
122
122
  * @param val string cmdline or array of strings
123
123
  * @returns ToolRunner
124
124
  */
125
- argIf(condition: any, val: any): this;
125
+ argIf(condition: unknown, val: string | string[]): ToolRunner;
126
126
  /**
127
127
  * Pipe output of exec() to another tool
128
128
  * @param tool