@actions/artifact 1.1.1 → 2.0.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.
Files changed (126) hide show
  1. package/README.md +111 -174
  2. package/lib/artifact.d.ts +6 -0
  3. package/lib/artifact.js +23 -0
  4. package/lib/artifact.js.map +1 -0
  5. package/lib/generated/google/protobuf/timestamp.d.ts +145 -0
  6. package/lib/generated/google/protobuf/timestamp.js +136 -0
  7. package/lib/generated/google/protobuf/timestamp.js.map +1 -0
  8. package/lib/generated/google/protobuf/wrappers.d.ts +307 -0
  9. package/lib/generated/google/protobuf/wrappers.js +609 -0
  10. package/lib/generated/google/protobuf/wrappers.js.map +1 -0
  11. package/lib/generated/index.d.ts +4 -0
  12. package/lib/generated/index.js +21 -0
  13. package/lib/generated/index.js.map +1 -0
  14. package/lib/generated/results/api/v1/artifact.d.ts +286 -0
  15. package/lib/generated/results/api/v1/artifact.js +588 -0
  16. package/lib/generated/results/api/v1/artifact.js.map +1 -0
  17. package/lib/generated/results/api/v1/artifact.twirp.d.ts +43 -0
  18. package/lib/generated/results/api/v1/artifact.twirp.js +416 -0
  19. package/lib/generated/results/api/v1/artifact.twirp.js.map +1 -0
  20. package/lib/internal/client.d.ts +61 -0
  21. package/lib/internal/client.js +121 -0
  22. package/lib/internal/client.js.map +1 -0
  23. package/lib/internal/download/download-artifact.d.ts +3 -0
  24. package/lib/internal/download/download-artifact.js +168 -0
  25. package/lib/internal/download/download-artifact.js.map +1 -0
  26. package/lib/internal/find/get-artifact.d.ts +3 -0
  27. package/lib/internal/find/get-artifact.js +118 -0
  28. package/lib/internal/find/get-artifact.js.map +1 -0
  29. package/lib/internal/find/list-artifacts.d.ts +3 -0
  30. package/lib/internal/find/list-artifacts.js +139 -0
  31. package/lib/internal/find/list-artifacts.js.map +1 -0
  32. package/lib/internal/find/retry-options.d.ts +7 -0
  33. package/lib/internal/find/retry-options.js +50 -0
  34. package/lib/internal/find/retry-options.js.map +1 -0
  35. package/lib/internal/shared/artifact-twirp-client.d.ts +6 -0
  36. package/lib/internal/shared/artifact-twirp-client.js +153 -0
  37. package/lib/internal/shared/artifact-twirp-client.js.map +1 -0
  38. package/lib/internal/shared/config.d.ts +6 -0
  39. package/lib/internal/shared/config.js +55 -0
  40. package/lib/internal/shared/config.js.map +1 -0
  41. package/lib/internal/shared/errors.d.ts +22 -0
  42. package/lib/internal/shared/errors.js +70 -0
  43. package/lib/internal/shared/errors.js.map +1 -0
  44. package/lib/internal/shared/interfaces.d.ts +136 -0
  45. package/lib/internal/{contracts.js → shared/interfaces.js} +1 -1
  46. package/lib/internal/shared/interfaces.js.map +1 -0
  47. package/lib/internal/shared/user-agent.d.ts +4 -0
  48. package/lib/internal/shared/user-agent.js +13 -0
  49. package/lib/internal/shared/user-agent.js.map +1 -0
  50. package/lib/internal/shared/util.d.ts +5 -0
  51. package/lib/internal/shared/util.js +81 -0
  52. package/lib/internal/shared/util.js.map +1 -0
  53. package/lib/internal/upload/blob-upload.d.ts +12 -0
  54. package/lib/internal/upload/blob-upload.js +87 -0
  55. package/lib/internal/upload/blob-upload.js.map +1 -0
  56. package/lib/internal/upload/path-and-artifact-name-validation.d.ts +8 -0
  57. package/lib/internal/{path-and-artifact-name-validation.js → upload/path-and-artifact-name-validation.js} +12 -12
  58. package/lib/internal/upload/path-and-artifact-name-validation.js.map +1 -0
  59. package/lib/internal/upload/retention.d.ts +2 -0
  60. package/lib/internal/upload/retention.js +54 -0
  61. package/lib/internal/upload/retention.js.map +1 -0
  62. package/lib/internal/upload/upload-artifact.d.ts +2 -0
  63. package/lib/internal/upload/upload-artifact.js +103 -0
  64. package/lib/internal/upload/upload-artifact.js.map +1 -0
  65. package/lib/internal/upload/upload-zip-specification.d.ts +21 -0
  66. package/lib/internal/upload/upload-zip-specification.js +113 -0
  67. package/lib/internal/upload/upload-zip-specification.js.map +1 -0
  68. package/lib/internal/upload/zip.d.ts +9 -0
  69. package/lib/internal/upload/zip.js +113 -0
  70. package/lib/internal/upload/zip.js.map +1 -0
  71. package/package.json +27 -11
  72. package/lib/artifact-client.d.ts +0 -10
  73. package/lib/artifact-client.js +0 -12
  74. package/lib/artifact-client.js.map +0 -1
  75. package/lib/internal/artifact-client.d.ts +0 -41
  76. package/lib/internal/artifact-client.js +0 -178
  77. package/lib/internal/artifact-client.js.map +0 -1
  78. package/lib/internal/config-variables.d.ts +0 -11
  79. package/lib/internal/config-variables.js +0 -72
  80. package/lib/internal/config-variables.js.map +0 -1
  81. package/lib/internal/contracts.d.ts +0 -67
  82. package/lib/internal/contracts.js.map +0 -1
  83. package/lib/internal/crc64.d.ts +0 -21
  84. package/lib/internal/crc64.js +0 -303
  85. package/lib/internal/crc64.js.map +0 -1
  86. package/lib/internal/download-http-client.d.ts +0 -39
  87. package/lib/internal/download-http-client.js +0 -292
  88. package/lib/internal/download-http-client.js.map +0 -1
  89. package/lib/internal/download-options.d.ts +0 -7
  90. package/lib/internal/download-options.js +0 -3
  91. package/lib/internal/download-options.js.map +0 -1
  92. package/lib/internal/download-response.d.ts +0 -10
  93. package/lib/internal/download-response.js +0 -3
  94. package/lib/internal/download-response.js.map +0 -1
  95. package/lib/internal/download-specification.d.ts +0 -19
  96. package/lib/internal/download-specification.js +0 -74
  97. package/lib/internal/download-specification.js.map +0 -1
  98. package/lib/internal/http-manager.d.ts +0 -12
  99. package/lib/internal/http-manager.js +0 -32
  100. package/lib/internal/http-manager.js.map +0 -1
  101. package/lib/internal/path-and-artifact-name-validation.d.ts +0 -8
  102. package/lib/internal/path-and-artifact-name-validation.js.map +0 -1
  103. package/lib/internal/requestUtils.d.ts +0 -3
  104. package/lib/internal/requestUtils.js +0 -88
  105. package/lib/internal/requestUtils.js.map +0 -1
  106. package/lib/internal/status-reporter.d.ts +0 -21
  107. package/lib/internal/status-reporter.js +0 -52
  108. package/lib/internal/status-reporter.js.map +0 -1
  109. package/lib/internal/upload-gzip.d.ts +0 -14
  110. package/lib/internal/upload-gzip.js +0 -121
  111. package/lib/internal/upload-gzip.js.map +0 -1
  112. package/lib/internal/upload-http-client.d.ts +0 -48
  113. package/lib/internal/upload-http-client.js +0 -409
  114. package/lib/internal/upload-http-client.js.map +0 -1
  115. package/lib/internal/upload-options.d.ts +0 -34
  116. package/lib/internal/upload-options.js +0 -3
  117. package/lib/internal/upload-options.js.map +0 -1
  118. package/lib/internal/upload-response.d.ts +0 -19
  119. package/lib/internal/upload-response.js +0 -3
  120. package/lib/internal/upload-response.js.map +0 -1
  121. package/lib/internal/upload-specification.d.ts +0 -11
  122. package/lib/internal/upload-specification.js +0 -101
  123. package/lib/internal/upload-specification.js.map +0 -1
  124. package/lib/internal/utils.d.ts +0 -70
  125. package/lib/internal/utils.js +0 -292
  126. package/lib/internal/utils.js.map +0 -1
@@ -1,70 +0,0 @@
1
- /// <reference types="node" />
2
- import { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http';
3
- import { HttpClient, HttpClientResponse } from '@actions/http-client';
4
- /**
5
- * Returns a retry time in milliseconds that exponentially gets larger
6
- * depending on the amount of retries that have been attempted
7
- */
8
- export declare function getExponentialRetryTimeInMilliseconds(retryCount: number): number;
9
- /**
10
- * Parses a env variable that is a number
11
- */
12
- export declare function parseEnvNumber(key: string): number | undefined;
13
- /**
14
- * Various utility functions to help with the necessary API calls
15
- */
16
- export declare function getApiVersion(): string;
17
- export declare function isSuccessStatusCode(statusCode?: number): boolean;
18
- export declare function isForbiddenStatusCode(statusCode?: number): boolean;
19
- export declare function isRetryableStatusCode(statusCode: number | undefined): boolean;
20
- export declare function isThrottledStatusCode(statusCode?: number): boolean;
21
- /**
22
- * Attempts to get the retry-after value from a set of http headers. The retry time
23
- * is originally denoted in seconds, so if present, it is converted to milliseconds
24
- * @param headers all the headers received when making an http call
25
- */
26
- export declare function tryGetRetryAfterValueTimeInMilliseconds(headers: IncomingHttpHeaders): number | undefined;
27
- export declare function getContentRange(start: number, end: number, total: number): string;
28
- /**
29
- * Sets all the necessary headers when downloading an artifact
30
- * @param {string} contentType the type of content being uploaded
31
- * @param {boolean} isKeepAlive is the same connection being used to make multiple calls
32
- * @param {boolean} acceptGzip can we accept a gzip encoded response
33
- * @param {string} acceptType the type of content that we can accept
34
- * @returns appropriate headers to make a specific http call during artifact download
35
- */
36
- export declare function getDownloadHeaders(contentType: string, isKeepAlive?: boolean, acceptGzip?: boolean): OutgoingHttpHeaders;
37
- /**
38
- * Sets all the necessary headers when uploading an artifact
39
- * @param {string} contentType the type of content being uploaded
40
- * @param {boolean} isKeepAlive is the same connection being used to make multiple calls
41
- * @param {boolean} isGzip is the connection being used to upload GZip compressed content
42
- * @param {number} uncompressedLength the original size of the content if something is being uploaded that has been compressed
43
- * @param {number} contentLength the length of the content that is being uploaded
44
- * @param {string} contentRange the range of the content that is being uploaded
45
- * @returns appropriate headers to make a specific http call during artifact upload
46
- */
47
- export declare function getUploadHeaders(contentType: string, isKeepAlive?: boolean, isGzip?: boolean, uncompressedLength?: number, contentLength?: number, contentRange?: string, digest?: StreamDigest): OutgoingHttpHeaders;
48
- export declare function createHttpClient(userAgent: string): HttpClient;
49
- export declare function getArtifactUrl(): string;
50
- /**
51
- * Uh oh! Something might have gone wrong during either upload or download. The IHtttpClientResponse object contains information
52
- * about the http call that was made by the actions http client. This information might be useful to display for diagnostic purposes, but
53
- * this entire object is really big and most of the information is not really useful. This function takes the response object and displays only
54
- * the information that we want.
55
- *
56
- * Certain information such as the TLSSocket and the Readable state are not really useful for diagnostic purposes so they can be avoided.
57
- * Other information such as the headers, the response code and message might be useful, so this is displayed.
58
- */
59
- export declare function displayHttpDiagnostics(response: HttpClientResponse): void;
60
- export declare function createDirectoriesForArtifact(directories: string[]): Promise<void>;
61
- export declare function createEmptyFilesForArtifact(emptyFilesToCreate: string[]): Promise<void>;
62
- export declare function getFileSize(filePath: string): Promise<number>;
63
- export declare function rmFile(filePath: string): Promise<void>;
64
- export declare function getProperRetention(retentionInput: number, retentionSetting: string | undefined): number;
65
- export declare function sleep(milliseconds: number): Promise<void>;
66
- export interface StreamDigest {
67
- crc64: string;
68
- md5: string;
69
- }
70
- export declare function digestForStream(stream: NodeJS.ReadableStream): Promise<StreamDigest>;
@@ -1,292 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.digestForStream = exports.sleep = exports.getProperRetention = exports.rmFile = exports.getFileSize = exports.createEmptyFilesForArtifact = exports.createDirectoriesForArtifact = exports.displayHttpDiagnostics = exports.getArtifactUrl = exports.createHttpClient = exports.getUploadHeaders = exports.getDownloadHeaders = exports.getContentRange = exports.tryGetRetryAfterValueTimeInMilliseconds = exports.isThrottledStatusCode = exports.isRetryableStatusCode = exports.isForbiddenStatusCode = exports.isSuccessStatusCode = exports.getApiVersion = exports.parseEnvNumber = exports.getExponentialRetryTimeInMilliseconds = void 0;
16
- const crypto_1 = __importDefault(require("crypto"));
17
- const fs_1 = require("fs");
18
- const core_1 = require("@actions/core");
19
- const http_client_1 = require("@actions/http-client");
20
- const auth_1 = require("@actions/http-client/lib/auth");
21
- const config_variables_1 = require("./config-variables");
22
- const crc64_1 = __importDefault(require("./crc64"));
23
- /**
24
- * Returns a retry time in milliseconds that exponentially gets larger
25
- * depending on the amount of retries that have been attempted
26
- */
27
- function getExponentialRetryTimeInMilliseconds(retryCount) {
28
- if (retryCount < 0) {
29
- throw new Error('RetryCount should not be negative');
30
- }
31
- else if (retryCount === 0) {
32
- return config_variables_1.getInitialRetryIntervalInMilliseconds();
33
- }
34
- const minTime = config_variables_1.getInitialRetryIntervalInMilliseconds() * config_variables_1.getRetryMultiplier() * retryCount;
35
- const maxTime = minTime * config_variables_1.getRetryMultiplier();
36
- // returns a random number between the minTime (inclusive) and the maxTime (exclusive)
37
- return Math.trunc(Math.random() * (maxTime - minTime) + minTime);
38
- }
39
- exports.getExponentialRetryTimeInMilliseconds = getExponentialRetryTimeInMilliseconds;
40
- /**
41
- * Parses a env variable that is a number
42
- */
43
- function parseEnvNumber(key) {
44
- const value = Number(process.env[key]);
45
- if (Number.isNaN(value) || value < 0) {
46
- return undefined;
47
- }
48
- return value;
49
- }
50
- exports.parseEnvNumber = parseEnvNumber;
51
- /**
52
- * Various utility functions to help with the necessary API calls
53
- */
54
- function getApiVersion() {
55
- return '6.0-preview';
56
- }
57
- exports.getApiVersion = getApiVersion;
58
- function isSuccessStatusCode(statusCode) {
59
- if (!statusCode) {
60
- return false;
61
- }
62
- return statusCode >= 200 && statusCode < 300;
63
- }
64
- exports.isSuccessStatusCode = isSuccessStatusCode;
65
- function isForbiddenStatusCode(statusCode) {
66
- if (!statusCode) {
67
- return false;
68
- }
69
- return statusCode === http_client_1.HttpCodes.Forbidden;
70
- }
71
- exports.isForbiddenStatusCode = isForbiddenStatusCode;
72
- function isRetryableStatusCode(statusCode) {
73
- if (!statusCode) {
74
- return false;
75
- }
76
- const retryableStatusCodes = [
77
- http_client_1.HttpCodes.BadGateway,
78
- http_client_1.HttpCodes.GatewayTimeout,
79
- http_client_1.HttpCodes.InternalServerError,
80
- http_client_1.HttpCodes.ServiceUnavailable,
81
- http_client_1.HttpCodes.TooManyRequests,
82
- 413 // Payload Too Large
83
- ];
84
- return retryableStatusCodes.includes(statusCode);
85
- }
86
- exports.isRetryableStatusCode = isRetryableStatusCode;
87
- function isThrottledStatusCode(statusCode) {
88
- if (!statusCode) {
89
- return false;
90
- }
91
- return statusCode === http_client_1.HttpCodes.TooManyRequests;
92
- }
93
- exports.isThrottledStatusCode = isThrottledStatusCode;
94
- /**
95
- * Attempts to get the retry-after value from a set of http headers. The retry time
96
- * is originally denoted in seconds, so if present, it is converted to milliseconds
97
- * @param headers all the headers received when making an http call
98
- */
99
- function tryGetRetryAfterValueTimeInMilliseconds(headers) {
100
- if (headers['retry-after']) {
101
- const retryTime = Number(headers['retry-after']);
102
- if (!isNaN(retryTime)) {
103
- core_1.info(`Retry-After header is present with a value of ${retryTime}`);
104
- return retryTime * 1000;
105
- }
106
- core_1.info(`Returned retry-after header value: ${retryTime} is non-numeric and cannot be used`);
107
- return undefined;
108
- }
109
- core_1.info(`No retry-after header was found. Dumping all headers for diagnostic purposes`);
110
- // eslint-disable-next-line no-console
111
- console.log(headers);
112
- return undefined;
113
- }
114
- exports.tryGetRetryAfterValueTimeInMilliseconds = tryGetRetryAfterValueTimeInMilliseconds;
115
- function getContentRange(start, end, total) {
116
- // Format: `bytes start-end/fileSize
117
- // start and end are inclusive
118
- // For a 200 byte chunk starting at byte 0:
119
- // Content-Range: bytes 0-199/200
120
- return `bytes ${start}-${end}/${total}`;
121
- }
122
- exports.getContentRange = getContentRange;
123
- /**
124
- * Sets all the necessary headers when downloading an artifact
125
- * @param {string} contentType the type of content being uploaded
126
- * @param {boolean} isKeepAlive is the same connection being used to make multiple calls
127
- * @param {boolean} acceptGzip can we accept a gzip encoded response
128
- * @param {string} acceptType the type of content that we can accept
129
- * @returns appropriate headers to make a specific http call during artifact download
130
- */
131
- function getDownloadHeaders(contentType, isKeepAlive, acceptGzip) {
132
- const requestOptions = {};
133
- if (contentType) {
134
- requestOptions['Content-Type'] = contentType;
135
- }
136
- if (isKeepAlive) {
137
- requestOptions['Connection'] = 'Keep-Alive';
138
- // keep alive for at least 10 seconds before closing the connection
139
- requestOptions['Keep-Alive'] = '10';
140
- }
141
- if (acceptGzip) {
142
- // if we are expecting a response with gzip encoding, it should be using an octet-stream in the accept header
143
- requestOptions['Accept-Encoding'] = 'gzip';
144
- requestOptions['Accept'] = `application/octet-stream;api-version=${getApiVersion()}`;
145
- }
146
- else {
147
- // default to application/json if we are not working with gzip content
148
- requestOptions['Accept'] = `application/json;api-version=${getApiVersion()}`;
149
- }
150
- return requestOptions;
151
- }
152
- exports.getDownloadHeaders = getDownloadHeaders;
153
- /**
154
- * Sets all the necessary headers when uploading an artifact
155
- * @param {string} contentType the type of content being uploaded
156
- * @param {boolean} isKeepAlive is the same connection being used to make multiple calls
157
- * @param {boolean} isGzip is the connection being used to upload GZip compressed content
158
- * @param {number} uncompressedLength the original size of the content if something is being uploaded that has been compressed
159
- * @param {number} contentLength the length of the content that is being uploaded
160
- * @param {string} contentRange the range of the content that is being uploaded
161
- * @returns appropriate headers to make a specific http call during artifact upload
162
- */
163
- function getUploadHeaders(contentType, isKeepAlive, isGzip, uncompressedLength, contentLength, contentRange, digest) {
164
- const requestOptions = {};
165
- requestOptions['Accept'] = `application/json;api-version=${getApiVersion()}`;
166
- if (contentType) {
167
- requestOptions['Content-Type'] = contentType;
168
- }
169
- if (isKeepAlive) {
170
- requestOptions['Connection'] = 'Keep-Alive';
171
- // keep alive for at least 10 seconds before closing the connection
172
- requestOptions['Keep-Alive'] = '10';
173
- }
174
- if (isGzip) {
175
- requestOptions['Content-Encoding'] = 'gzip';
176
- requestOptions['x-tfs-filelength'] = uncompressedLength;
177
- }
178
- if (contentLength) {
179
- requestOptions['Content-Length'] = contentLength;
180
- }
181
- if (contentRange) {
182
- requestOptions['Content-Range'] = contentRange;
183
- }
184
- if (digest) {
185
- requestOptions['x-actions-results-crc64'] = digest.crc64;
186
- requestOptions['x-actions-results-md5'] = digest.md5;
187
- }
188
- return requestOptions;
189
- }
190
- exports.getUploadHeaders = getUploadHeaders;
191
- function createHttpClient(userAgent) {
192
- return new http_client_1.HttpClient(userAgent, [
193
- new auth_1.BearerCredentialHandler(config_variables_1.getRuntimeToken())
194
- ]);
195
- }
196
- exports.createHttpClient = createHttpClient;
197
- function getArtifactUrl() {
198
- const artifactUrl = `${config_variables_1.getRuntimeUrl()}_apis/pipelines/workflows/${config_variables_1.getWorkFlowRunId()}/artifacts?api-version=${getApiVersion()}`;
199
- core_1.debug(`Artifact Url: ${artifactUrl}`);
200
- return artifactUrl;
201
- }
202
- exports.getArtifactUrl = getArtifactUrl;
203
- /**
204
- * Uh oh! Something might have gone wrong during either upload or download. The IHtttpClientResponse object contains information
205
- * about the http call that was made by the actions http client. This information might be useful to display for diagnostic purposes, but
206
- * this entire object is really big and most of the information is not really useful. This function takes the response object and displays only
207
- * the information that we want.
208
- *
209
- * Certain information such as the TLSSocket and the Readable state are not really useful for diagnostic purposes so they can be avoided.
210
- * Other information such as the headers, the response code and message might be useful, so this is displayed.
211
- */
212
- function displayHttpDiagnostics(response) {
213
- core_1.info(`##### Begin Diagnostic HTTP information #####
214
- Status Code: ${response.message.statusCode}
215
- Status Message: ${response.message.statusMessage}
216
- Header Information: ${JSON.stringify(response.message.headers, undefined, 2)}
217
- ###### End Diagnostic HTTP information ######`);
218
- }
219
- exports.displayHttpDiagnostics = displayHttpDiagnostics;
220
- function createDirectoriesForArtifact(directories) {
221
- return __awaiter(this, void 0, void 0, function* () {
222
- for (const directory of directories) {
223
- yield fs_1.promises.mkdir(directory, {
224
- recursive: true
225
- });
226
- }
227
- });
228
- }
229
- exports.createDirectoriesForArtifact = createDirectoriesForArtifact;
230
- function createEmptyFilesForArtifact(emptyFilesToCreate) {
231
- return __awaiter(this, void 0, void 0, function* () {
232
- for (const filePath of emptyFilesToCreate) {
233
- yield (yield fs_1.promises.open(filePath, 'w')).close();
234
- }
235
- });
236
- }
237
- exports.createEmptyFilesForArtifact = createEmptyFilesForArtifact;
238
- function getFileSize(filePath) {
239
- return __awaiter(this, void 0, void 0, function* () {
240
- const stats = yield fs_1.promises.stat(filePath);
241
- core_1.debug(`${filePath} size:(${stats.size}) blksize:(${stats.blksize}) blocks:(${stats.blocks})`);
242
- return stats.size;
243
- });
244
- }
245
- exports.getFileSize = getFileSize;
246
- function rmFile(filePath) {
247
- return __awaiter(this, void 0, void 0, function* () {
248
- yield fs_1.promises.unlink(filePath);
249
- });
250
- }
251
- exports.rmFile = rmFile;
252
- function getProperRetention(retentionInput, retentionSetting) {
253
- if (retentionInput < 0) {
254
- throw new Error('Invalid retention, minimum value is 1.');
255
- }
256
- let retention = retentionInput;
257
- if (retentionSetting) {
258
- const maxRetention = parseInt(retentionSetting);
259
- if (!isNaN(maxRetention) && maxRetention < retention) {
260
- core_1.warning(`Retention days is greater than the max value allowed by the repository setting, reduce retention to ${maxRetention} days`);
261
- retention = maxRetention;
262
- }
263
- }
264
- return retention;
265
- }
266
- exports.getProperRetention = getProperRetention;
267
- function sleep(milliseconds) {
268
- return __awaiter(this, void 0, void 0, function* () {
269
- return new Promise(resolve => setTimeout(resolve, milliseconds));
270
- });
271
- }
272
- exports.sleep = sleep;
273
- function digestForStream(stream) {
274
- return __awaiter(this, void 0, void 0, function* () {
275
- return new Promise((resolve, reject) => {
276
- const crc64 = new crc64_1.default();
277
- const md5 = crypto_1.default.createHash('md5');
278
- stream
279
- .on('data', data => {
280
- crc64.update(data);
281
- md5.update(data);
282
- })
283
- .on('end', () => resolve({
284
- crc64: crc64.digest('base64'),
285
- md5: md5.digest('base64')
286
- }))
287
- .on('error', reject);
288
- });
289
- });
290
- }
291
- exports.digestForStream = digestForStream;
292
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/internal/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAA2B;AAC3B,2BAAiC;AAEjC,wCAAkD;AAClD,sDAA8E;AAC9E,wDAAqE;AACrE,yDAM2B;AAC3B,oDAA2B;AAE3B;;;GAGG;AACH,SAAgB,qCAAqC,CACnD,UAAkB;IAElB,IAAI,UAAU,GAAG,CAAC,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAA;KACrD;SAAM,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