azure-pipelines-task-lib 5.2.7 → 5.2.10
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/Strings/resources.resjson/en-US/resources.resjson +1 -0
- package/lib.json +1 -0
- package/mock-task.js +1 -0
- package/package.json +1 -1
- package/task.d.ts +11 -0
- package/task.js +73 -48
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
+
"loc.messages.LIB_CopyDirectoryWithoutRecursiveOption": "cp: cannot copy a directory '%s' without the recursive option",
|
|
2
3
|
"loc.messages.LIB_CopyFileFailed": "Error while copying the file. Attempts left: %s",
|
|
3
4
|
"loc.messages.LIB_DirectoryStackEmpty": "Directory stack is empty",
|
|
4
5
|
"loc.messages.LIB_EndpointAuthNotExist": "Endpoint auth data not present: %s",
|
package/lib.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"messages": {
|
|
3
|
+
"LIB_CopyDirectoryWithoutRecursiveOption": "cp: cannot copy a directory '%s' without the recursive option",
|
|
3
4
|
"LIB_CopyFileFailed": "Error while copying the file. Attempts left: %s",
|
|
4
5
|
"LIB_DirectoryStackEmpty": "Directory stack is empty",
|
|
5
6
|
"LIB_EndpointAuthNotExist": "Endpoint auth data not present: %s",
|
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
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,30 +1063,33 @@ 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
|
}
|
|
1066
|
+
var isPattern = /[*?{\[]/.test(source) || /^[#!]/.test(source) || /[@+!]\(/.test(source);
|
|
1067
|
+
if (isPattern) {
|
|
1068
|
+
var sourcesToProcess = [];
|
|
1069
|
+
var sourceDir = path.dirname(source);
|
|
1070
|
+
sourceDir = sourceDir == '.' ? path.resolve() : sourceDir;
|
|
1071
|
+
sourcesToProcess = findMatch(sourceDir, [path.basename(source)]);
|
|
1072
|
+
if (sourcesToProcess.length === 0) {
|
|
1073
|
+
(0, exports.debug)("No matches found for pattern: ".concat(source));
|
|
1074
|
+
}
|
|
1075
|
+
for (var _i = 0, sourcesToProcess_1 = sourcesToProcess; _i < sourcesToProcess_1.length; _i++) {
|
|
1076
|
+
var src = sourcesToProcess_1[_i];
|
|
1077
|
+
cp(src, destination, options, continueOnError, retryCount);
|
|
1078
|
+
}
|
|
1079
|
+
return;
|
|
1080
|
+
}
|
|
1045
1081
|
var lstatSource = fs.lstatSync(source);
|
|
1082
|
+
if (!recursive && lstatSource.isDirectory()) {
|
|
1083
|
+
throw new Error((0, exports.loc)('LIB_CopyDirectoryWithoutRecursiveOption', source));
|
|
1084
|
+
}
|
|
1046
1085
|
if (!force && fs.existsSync(destination)) {
|
|
1047
1086
|
return;
|
|
1048
1087
|
}
|
|
1049
1088
|
try {
|
|
1050
|
-
if (
|
|
1051
|
-
|
|
1052
|
-
source = path.resolve(path.dirname(source), symlinkTarget);
|
|
1053
|
-
lstatSource = fs.lstatSync(source);
|
|
1054
|
-
}
|
|
1055
|
-
if (lstatSource.isFile()) {
|
|
1056
|
-
if (fs.existsSync(destination) && fs.lstatSync(destination).isDirectory()) {
|
|
1057
|
-
destination = path.join(destination, path.basename(source));
|
|
1058
|
-
}
|
|
1059
|
-
if (force) {
|
|
1060
|
-
fs.copyFileSync(source, destination);
|
|
1061
|
-
}
|
|
1062
|
-
else {
|
|
1063
|
-
fs.copyFileSync(source, destination, fs.constants.COPYFILE_EXCL);
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
else {
|
|
1067
|
-
copyDirectoryWithResolvedSymlinks(source, path.join(destination, path.basename(source)), force);
|
|
1089
|
+
if (fs.existsSync(destination) && fs.lstatSync(destination).isDirectory()) {
|
|
1090
|
+
destination = path.join(destination, path.basename(source));
|
|
1068
1091
|
}
|
|
1092
|
+
copyWithPreservedSymlinks(source, destination, force);
|
|
1069
1093
|
}
|
|
1070
1094
|
catch (error) {
|
|
1071
1095
|
throw new Error((0, exports.loc)('LIB_OperationFailed', 'cp', error));
|
|
@@ -1073,38 +1097,39 @@ function cp(sourceOrOptions, destinationOrSource, optionsOrDestination, continue
|
|
|
1073
1097
|
}, [], { retryCount: retryCount, continueOnError: continueOnError });
|
|
1074
1098
|
}
|
|
1075
1099
|
exports.cp = cp;
|
|
1076
|
-
var
|
|
1077
|
-
var
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
1085
|
-
entry = entries_1[_i];
|
|
1086
|
-
srcPath = path.join(src, entry.name);
|
|
1087
|
-
destPath = path.join(dest, entry.name);
|
|
1088
|
-
if (entry.isSymbolicLink()) {
|
|
1089
|
-
// Resolve the symbolic link and copy the target
|
|
1090
|
-
var symlinkTarget = fs.readlinkSync(srcPath);
|
|
1091
|
-
var resolvedPath = path.resolve(path.dirname(srcPath), symlinkTarget);
|
|
1092
|
-
var stat = fs.lstatSync(resolvedPath);
|
|
1093
|
-
if (stat.isFile()) {
|
|
1094
|
-
// Use the actual target file's name instead of the symbolic link's name
|
|
1095
|
-
var targetFileName = path.basename(resolvedPath);
|
|
1096
|
-
var targetDestPath = path.join(dest, targetFileName);
|
|
1097
|
-
fs.copyFileSync(resolvedPath, targetDestPath);
|
|
1100
|
+
var copyWithPreservedSymlinks = function (source, destination, force) {
|
|
1101
|
+
var lstatSource = fs.lstatSync(source);
|
|
1102
|
+
if (lstatSource.isSymbolicLink()) {
|
|
1103
|
+
var symlinkTarget = fs.readlinkSync(source);
|
|
1104
|
+
if (force && fs.existsSync(destination)) {
|
|
1105
|
+
var destStats = fs.lstatSync(destination);
|
|
1106
|
+
if (destStats.isSymbolicLink()) {
|
|
1107
|
+
fs.unlinkSync(destination);
|
|
1098
1108
|
}
|
|
1099
|
-
else
|
|
1100
|
-
|
|
1109
|
+
else {
|
|
1110
|
+
fs.rmSync(destination, { recursive: true, force: true });
|
|
1101
1111
|
}
|
|
1102
1112
|
}
|
|
1103
|
-
|
|
1104
|
-
|
|
1113
|
+
fs.symlinkSync(symlinkTarget, destination);
|
|
1114
|
+
}
|
|
1115
|
+
else if (lstatSource.isFile()) {
|
|
1116
|
+
if (force) {
|
|
1117
|
+
fs.copyFileSync(source, destination);
|
|
1118
|
+
}
|
|
1119
|
+
else {
|
|
1120
|
+
fs.copyFileSync(source, destination, fs.constants.COPYFILE_EXCL);
|
|
1105
1121
|
}
|
|
1106
|
-
|
|
1107
|
-
|
|
1122
|
+
}
|
|
1123
|
+
else {
|
|
1124
|
+
var entries = fs.readdirSync(source, { withFileTypes: true });
|
|
1125
|
+
if (!fs.existsSync(destination)) {
|
|
1126
|
+
fs.mkdirSync(destination, { recursive: true });
|
|
1127
|
+
}
|
|
1128
|
+
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
1129
|
+
var entry = entries_1[_i];
|
|
1130
|
+
var srcPath = path.join(source, entry.name);
|
|
1131
|
+
var destPath = path.join(destination, entry.name);
|
|
1132
|
+
copyWithPreservedSymlinks(srcPath, destPath, force);
|
|
1108
1133
|
}
|
|
1109
1134
|
}
|
|
1110
1135
|
};
|