azure-pipelines-task-lib 5.2.8 → 5.2.11

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
@@ -199,6 +199,7 @@ function getAgentMode() {
199
199
  return mock.getResponse('getAgentMode', 'getAgentMode', module.exports.debug);
200
200
  }
201
201
  exports.getAgentMode = getAgentMode;
202
+ module.exports.getSprint = task.getSprint;
202
203
  function cwd() {
203
204
  return mock.getResponse('cwd', 'cwd', module.exports.debug);
204
205
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azure-pipelines-task-lib",
3
- "version": "5.2.8",
3
+ "version": "5.2.11",
4
4
  "description": "Azure Pipelines Task SDK",
5
5
  "main": "./task.js",
6
6
  "typings": "./task.d.ts",
package/task.d.ts CHANGED
@@ -47,6 +47,10 @@ export declare enum AgentHostedMode {
47
47
  SelfHosted = 1,
48
48
  MsHosted = 2
49
49
  }
50
+ export interface SprintInfo {
51
+ sprint: number;
52
+ week: number;
53
+ }
50
54
  export declare const setStdStream: typeof im._setStdStream;
51
55
  export declare const setErrStream: typeof im._setErrStream;
52
56
  /**
@@ -357,6 +361,13 @@ export declare function getNodeMajorVersion(): Number;
357
361
  * @returns {AgentHostedMode}
358
362
  */
359
363
  export declare function getAgentMode(): AgentHostedMode;
364
+ /**
365
+ * Calculates sprint and week using the same cadence as whatsprintis.it.
366
+ *
367
+ * @param date Optional date to evaluate. Defaults to the current date/time.
368
+ * @returns SprintInfo with `sprint` and `week` properties.
369
+ */
370
+ export declare function getSprint(date?: Date): SprintInfo;
360
371
  /**
361
372
  * Returns the process's current working directory.
362
373
  * see [process.cwd](https://nodejs.org/api/process.html#process_process_cwd)
package/task.js CHANGED
@@ -10,7 +10,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  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.getPipelineFeature = exports.getBoolFeatureFlag = exports.getBoolInput = exports.getInputRequired = exports.getInput = exports.setSecret = exports.setVariable = exports.getVariables = exports.assertAgent = exports.getVariable = exports.loc = exports.setResourcePath = exports.setSanitizedResult = exports.setResult = exports.setErrStream = exports.setStdStream = exports.AgentHostedMode = exports.Platform = exports.IssueSource = exports.FieldType = exports.ArtifactType = exports.IssueType = exports.TaskState = exports.TaskResult = void 0;
13
- 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.execAsync = 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.getNodeMajorVersion = void 0;
13
+ 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.execAsync = 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.getSprint = exports.getAgentMode = exports.getNodeMajorVersion = void 0;
14
14
  var childProcess = require("child_process");
15
15
  var fs = require("fs");
16
16
  var path = require("path");
@@ -68,6 +68,10 @@ var AgentHostedMode;
68
68
  AgentHostedMode[AgentHostedMode["SelfHosted"] = 1] = "SelfHosted";
69
69
  AgentHostedMode[AgentHostedMode["MsHosted"] = 2] = "MsHosted";
70
70
  })(AgentHostedMode = exports.AgentHostedMode || (exports.AgentHostedMode = {}));
71
+ var SPRINT_ONE_START_UTC_MS = Date.UTC(2010, 7, 14, 0, 0, 0, 0);
72
+ var DAYS_PER_WEEK = 7;
73
+ var DAYS_PER_SPRINT = 21;
74
+ var MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;
71
75
  //-----------------------------------------------------
72
76
  // General Helpers
73
77
  //-----------------------------------------------------
@@ -118,7 +122,7 @@ process.on('uncaughtException', function (err) {
118
122
  });
119
123
  //
120
124
  // Catching unhandled rejections from promises and rethrowing them as exceptions
121
- // For example, a promise that is rejected but not handled by a .catch() handler in node 10
125
+ // For example, a promise that is rejected but not handled by a .catch() handler in node 10
122
126
  // doesn't cause an uncaughtException but causes in Node 16.
123
127
  // For types definitions(Error | Any) see https://nodejs.org/docs/latest-v16.x/api/process.html#event-unhandledrejection
124
128
  //
@@ -684,6 +688,23 @@ function getAgentMode() {
684
688
  return AgentHostedMode.SelfHosted;
685
689
  }
686
690
  exports.getAgentMode = getAgentMode;
691
+ /**
692
+ * Calculates sprint and week using the same cadence as whatsprintis.it.
693
+ *
694
+ * @param date Optional date to evaluate. Defaults to the current date/time.
695
+ * @returns SprintInfo with `sprint` and `week` properties.
696
+ */
697
+ function getSprint(date) {
698
+ var targetDate = date || new Date();
699
+ var elapsedDays = Math.floor((targetDate.getTime() - SPRINT_ONE_START_UTC_MS) / MILLISECONDS_PER_DAY);
700
+ var sprintIndex = Math.floor(elapsedDays / DAYS_PER_SPRINT);
701
+ var dayWithinSprint = ((elapsedDays % DAYS_PER_SPRINT) + DAYS_PER_SPRINT) % DAYS_PER_SPRINT;
702
+ return {
703
+ sprint: sprintIndex + 1,
704
+ week: Math.floor(dayWithinSprint / DAYS_PER_WEEK) + 1
705
+ };
706
+ }
707
+ exports.getSprint = getSprint;
687
708
  /**
688
709
  * Returns the process's current working directory.
689
710
  * see [process.cwd](https://nodejs.org/api/process.html#process_process_cwd)
@@ -1042,20 +1063,20 @@ function cp(sourceOrOptions, destinationOrSource, optionsOrDestination, continue
1042
1063
  if (!fs.existsSync(destination) && !force) {
1043
1064
  throw new Error((0, exports.loc)('LIB_PathNotFound', 'cp', destination));
1044
1065
  }
1045
- var hasGlobPattern = /[*?{[!@#]/.test(source);
1046
- if (hasGlobPattern) {
1047
- var sourcesToProcess = [];
1048
- var sourceDir = path.dirname(source);
1049
- sourceDir = sourceDir == '.' ? path.resolve() : sourceDir;
1050
- sourcesToProcess = findMatch(sourceDir, [path.basename(source)]);
1051
- if (sourcesToProcess.length === 0) {
1052
- (0, exports.debug)("No matches found for glob pattern: ".concat(source));
1066
+ var isPattern = /[*?{\[]/.test(source) || /[@+!]\(/.test(source);
1067
+ if (isPattern) {
1068
+ var defaultRoot = (0, exports.getVariable)('system.defaultWorkingDirectory') || process.cwd();
1069
+ var sourcesToProcess = findMatch(defaultRoot, [source], undefined, { nonegate: true, nocomment: true });
1070
+ if (sourcesToProcess.length > 0) {
1071
+ for (var _i = 0, sourcesToProcess_1 = sourcesToProcess; _i < sourcesToProcess_1.length; _i++) {
1072
+ var src = sourcesToProcess_1[_i];
1073
+ cp(src, destination, options, continueOnError, retryCount);
1074
+ }
1075
+ return;
1053
1076
  }
1054
- for (var _i = 0, sourcesToProcess_1 = sourcesToProcess; _i < sourcesToProcess_1.length; _i++) {
1055
- var src = sourcesToProcess_1[_i];
1056
- cp(src, destination, options, continueOnError, retryCount);
1077
+ else {
1078
+ (0, exports.debug)("No matches found for the pattern: ".concat(source, ". Fallback to check for the literal path."));
1057
1079
  }
1058
- return;
1059
1080
  }
1060
1081
  var lstatSource = fs.lstatSync(source);
1061
1082
  if (!recursive && lstatSource.isDirectory()) {