@rushstack/rush-http-build-cache-plugin 5.144.0-pr5031.0 → 5.144.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/.rush/temp/chunked-rush-logs/rush-http-build-cache-plugin._phase_build.chunks.jsonl +2 -2
- package/.rush/temp/chunked-rush-logs/rush-http-build-cache-plugin._phase_test.chunks.jsonl +3 -3
- package/.rush/temp/operation/_phase_build/all.log +2 -2
- package/.rush/temp/operation/_phase_build/log-chunks.jsonl +2 -2
- package/.rush/temp/operation/_phase_build/state.json +1 -1
- package/.rush/temp/operation/_phase_test/all.log +3 -3
- package/.rush/temp/operation/_phase_test/log-chunks.jsonl +3 -3
- package/.rush/temp/operation/_phase_test/state.json +1 -1
- package/.rush/temp/{rushstack+rush-http-build-cache-plugin-_phase_build-e5bdc25d5c8f425409702fbcb4e3922a3441bb64.tar.log → rushstack+rush-http-build-cache-plugin-_phase_build-ad0665ff21c993746ce2ee20280627970419284e.tar.log} +2 -2
- package/.rush/temp/{rushstack+rush-http-build-cache-plugin-_phase_test-3aa55baa8e6c6d87e33f45a16e648daac095955a.tar.log → rushstack+rush-http-build-cache-plugin-_phase_test-eff33e429016638e7614530b8c4b50864798503a.tar.log} +2 -2
- package/coverage/HttpBuildCacheProvider.ts.html +8 -8
- package/coverage/RushHttpBuildCachePlugin.ts.html +1 -1
- package/coverage/cobertura-coverage.xml +4 -4
- package/coverage/index.html +5 -5
- package/coverage/index.ts.html +1 -1
- package/coverage/junit.xml +4 -4
- package/lib/HttpBuildCacheProvider.js +1 -1
- package/lib/HttpBuildCacheProvider.js.map +1 -1
- package/package.json +7 -7
- package/rush-logs/rush-http-build-cache-plugin._phase_build.cache.log +1 -1
- package/rush-logs/rush-http-build-cache-plugin._phase_build.log +2 -2
- package/rush-logs/rush-http-build-cache-plugin._phase_test.cache.log +1 -1
- package/rush-logs/rush-http-build-cache-plugin._phase_test.log +3 -3
- package/src/HttpBuildCacheProvider.ts +5 -5
- package/temp/build/typescript/ts_l9Fw4VUO.json +1 -1
- package/temp/test/jest/haste-map-8bff56e236187dbf28a94cdea7ee2158-1f8f3a8b20228094c245723445dd2c9a-e95bfd62c357a87bf3c5f47c6c3a2910 +0 -0
- package/temp/test/jest/jest-transform-cache-8bff56e236187dbf28a94cdea7ee2158-79ef2876fae7ca75eedb2aa53dc48338/85/mappingTable_8501b32035641eb039dd5a743553850f +2 -0
- package/temp/test/jest/perf-cache-8bff56e236187dbf28a94cdea7ee2158-da39a3ee5e6b4b0d3255bfef95601890 +1 -1
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
{"kind":"O","text":"[build:typescript] Using TypeScript version 5.4.2\n"}
|
|
4
4
|
{"kind":"O","text":"[build:lint] Using ESLint version 8.57.0\n"}
|
|
5
5
|
{"kind":"O","text":"[build:typescript] Copied 1 file and linked 0 files\n"}
|
|
6
|
-
{"kind":"O","text":" ---- build finished (10.
|
|
7
|
-
{"kind":"O","text":"\u001b[1m\u001b[32m-------------------- Finished (10.
|
|
6
|
+
{"kind":"O","text":" ---- build finished (10.440s) ---- \n"}
|
|
7
|
+
{"kind":"O","text":"\u001b[1m\u001b[32m-------------------- Finished (10.446s) --------------------\u001b[39m\u001b[22m\n"}
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
{"kind":"O","text":"[test:jest] \u001b[0m\n"}
|
|
6
6
|
{"kind":"O","text":"[test:jest] Run start. 1 test suite\n"}
|
|
7
7
|
{"kind":"O","text":"[test:jest] \u001b[47m\u001b[30mSTART\u001b[39m\u001b[49m lib/test/HttpBuildCacheProvider.test.js\n"}
|
|
8
|
-
{"kind":"O","text":"[test:jest] \u001b[42m\u001b[30mPASS\u001b[39m\u001b[49m lib/test/HttpBuildCacheProvider.test.js (duration: 2.
|
|
8
|
+
{"kind":"O","text":"[test:jest] \u001b[42m\u001b[30mPASS\u001b[39m\u001b[49m lib/test/HttpBuildCacheProvider.test.js (duration: 2.064s, 2 passed, 0 failed)\n"}
|
|
9
9
|
{"kind":"O","text":"[test:jest] \n"}
|
|
10
10
|
{"kind":"O","text":"[test:jest] Tests finished:\n"}
|
|
11
11
|
{"kind":"O","text":"[test:jest] \u001b[32m Successes: 2\u001b[39m\n"}
|
|
12
12
|
{"kind":"O","text":"[test:jest] Failures: 0\n"}
|
|
13
13
|
{"kind":"O","text":"[test:jest] Total: 2\n"}
|
|
14
|
-
{"kind":"O","text":" ---- test finished (3.
|
|
15
|
-
{"kind":"O","text":"\u001b[1m\u001b[32m-------------------- Finished (3.
|
|
14
|
+
{"kind":"O","text":" ---- test finished (3.804s) ---- \n"}
|
|
15
|
+
{"kind":"O","text":"\u001b[1m\u001b[32m-------------------- Finished (3.811s) --------------------\u001b[39m\u001b[22m\n"}
|
|
@@ -3,5 +3,5 @@ Invoking: heft run --only build -- --clean --production
|
|
|
3
3
|
[build:typescript] Using TypeScript version 5.4.2
|
|
4
4
|
[build:lint] Using ESLint version 8.57.0
|
|
5
5
|
[build:typescript] Copied 1 file and linked 0 files
|
|
6
|
-
---- build finished (10.
|
|
7
|
-
-------------------- Finished (10.
|
|
6
|
+
---- build finished (10.440s) ----
|
|
7
|
+
-------------------- Finished (10.446s) --------------------
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
{"kind":"O","text":"[build:typescript] Using TypeScript version 5.4.2\n"}
|
|
4
4
|
{"kind":"O","text":"[build:lint] Using ESLint version 8.57.0\n"}
|
|
5
5
|
{"kind":"O","text":"[build:typescript] Copied 1 file and linked 0 files\n"}
|
|
6
|
-
{"kind":"O","text":" ---- build finished (10.
|
|
7
|
-
{"kind":"O","text":"\u001b[1m\u001b[32m-------------------- Finished (10.
|
|
6
|
+
{"kind":"O","text":" ---- build finished (10.440s) ---- \n"}
|
|
7
|
+
{"kind":"O","text":"\u001b[1m\u001b[32m-------------------- Finished (10.446s) --------------------\u001b[39m\u001b[22m\n"}
|
|
@@ -5,11 +5,11 @@ The provided list of phases does not contain all phase dependencies. You may nee
|
|
|
5
5
|
[test:jest]
|
|
6
6
|
[test:jest] Run start. 1 test suite
|
|
7
7
|
[test:jest] START lib/test/HttpBuildCacheProvider.test.js
|
|
8
|
-
[test:jest] PASS lib/test/HttpBuildCacheProvider.test.js (duration: 2.
|
|
8
|
+
[test:jest] PASS lib/test/HttpBuildCacheProvider.test.js (duration: 2.064s, 2 passed, 0 failed)
|
|
9
9
|
[test:jest]
|
|
10
10
|
[test:jest] Tests finished:
|
|
11
11
|
[test:jest] Successes: 2
|
|
12
12
|
[test:jest] Failures: 0
|
|
13
13
|
[test:jest] Total: 2
|
|
14
|
-
---- test finished (3.
|
|
15
|
-
-------------------- Finished (3.
|
|
14
|
+
---- test finished (3.804s) ----
|
|
15
|
+
-------------------- Finished (3.811s) --------------------
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
{"kind":"O","text":"[test:jest] \u001b[0m\n"}
|
|
6
6
|
{"kind":"O","text":"[test:jest] Run start. 1 test suite\n"}
|
|
7
7
|
{"kind":"O","text":"[test:jest] \u001b[47m\u001b[30mSTART\u001b[39m\u001b[49m lib/test/HttpBuildCacheProvider.test.js\n"}
|
|
8
|
-
{"kind":"O","text":"[test:jest] \u001b[42m\u001b[30mPASS\u001b[39m\u001b[49m lib/test/HttpBuildCacheProvider.test.js (duration: 2.
|
|
8
|
+
{"kind":"O","text":"[test:jest] \u001b[42m\u001b[30mPASS\u001b[39m\u001b[49m lib/test/HttpBuildCacheProvider.test.js (duration: 2.064s, 2 passed, 0 failed)\n"}
|
|
9
9
|
{"kind":"O","text":"[test:jest] \n"}
|
|
10
10
|
{"kind":"O","text":"[test:jest] Tests finished:\n"}
|
|
11
11
|
{"kind":"O","text":"[test:jest] \u001b[32m Successes: 2\u001b[39m\n"}
|
|
12
12
|
{"kind":"O","text":"[test:jest] Failures: 0\n"}
|
|
13
13
|
{"kind":"O","text":"[test:jest] Total: 2\n"}
|
|
14
|
-
{"kind":"O","text":" ---- test finished (3.
|
|
15
|
-
{"kind":"O","text":"\u001b[1m\u001b[32m-------------------- Finished (3.
|
|
14
|
+
{"kind":"O","text":" ---- test finished (3.804s) ---- \n"}
|
|
15
|
+
{"kind":"O","text":"\u001b[1m\u001b[32m-------------------- Finished (3.811s) --------------------\u001b[39m\u001b[22m\n"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
Start time: Mon Dec 09 2024
|
|
2
|
-
Invoking "/usr/bin/tar -c -f /mnt/vss/_work/1/s/common/temp/build-cache/rushstack+rush-http-build-cache-plugin-_phase_build-
|
|
1
|
+
Start time: Mon Dec 09 2024 20:30:07 GMT+0000 (Coordinated Universal Time)
|
|
2
|
+
Invoking "/usr/bin/tar -c -f /mnt/vss/_work/1/s/common/temp/build-cache/rushstack+rush-http-build-cache-plugin-_phase_build-ad0665ff21c993746ce2ee20280627970419284e-1fa3c725293dbf11.temp -z --files-from=-"
|
|
3
3
|
|
|
4
4
|
======= BEGIN PROCESS INPUT ======
|
|
5
5
|
.rush/temp/operation/_phase_build/all.log
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
Start time: Mon Dec 09 2024
|
|
2
|
-
Invoking "/usr/bin/tar -c -f /mnt/vss/_work/1/s/common/temp/build-cache/rushstack+rush-http-build-cache-plugin-_phase_test-
|
|
1
|
+
Start time: Mon Dec 09 2024 20:30:12 GMT+0000 (Coordinated Universal Time)
|
|
2
|
+
Invoking "/usr/bin/tar -c -f /mnt/vss/_work/1/s/common/temp/build-cache/rushstack+rush-http-build-cache-plugin-_phase_test-eff33e429016638e7614530b8c4b50864798503a-633e2d88d4b5a29e.temp -z --files-from=-"
|
|
3
3
|
|
|
4
4
|
======= BEGIN PROCESS INPUT ======
|
|
5
5
|
.rush/temp/operation/_phase_test/all.log
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">
|
|
33
|
+
<span class="strong">55.17% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>32/
|
|
35
|
+
<span class='fraction'>32/58</span>
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
38
|
|
|
@@ -969,7 +969,7 @@ import {
|
|
|
969
969
|
type RushSession,
|
|
970
970
|
EnvironmentConfiguration
|
|
971
971
|
} from '@rushstack/rush-sdk';
|
|
972
|
-
import { WebClient, type
|
|
972
|
+
import { WebClient, type WebClientResponse } from '@rushstack/rush-sdk/lib/utilities/WebClient';
|
|
973
973
|
import type { SpawnSyncReturns } from 'child_process';
|
|
974
974
|
|
|
975
975
|
enum CredentialsOptions {
|
|
@@ -1202,7 +1202,7 @@ export class HttpBuildCacheProvider implements ICloudBuildCacheProvider {
|
|
|
1202
1202
|
terminal.writeDebugLine(`[http-build-cache] request: ${method} ${url} ${bodyLength} bytes`);
|
|
1203
1203
|
|
|
1204
1204
|
const webClient: WebClient = new WebClient();
|
|
1205
|
-
const response:
|
|
1205
|
+
const response: WebClientResponse = await webClient.fetchAsync(url, {
|
|
1206
1206
|
verb: method,
|
|
1207
1207
|
headers: headers,
|
|
1208
1208
|
body: body,
|
|
@@ -1245,7 +1245,7 @@ export class HttpBuildCacheProvider implements ICloudBuildCacheProvider {
|
|
|
1245
1245
|
return false;
|
|
1246
1246
|
}
|
|
1247
1247
|
<span class="cstat-no" title="statement not covered" ><span class="branch-0 cbranch-no" title="branch not covered" ></span></span>
|
|
1248
|
-
const result: Buffer | boolean = readBody ? await response.
|
|
1248
|
+
const result: Buffer | boolean = readBody ? Buffer.from(await response.arrayBuffer()) <span class="branch-0 cbranch-no" title="branch not covered" >: true;</span>
|
|
1249
1249
|
|
|
1250
1250
|
terminal.writeDebugLine(
|
|
1251
1251
|
`[http-build-cache] actual response: ${response.status} ${url} ${
|
|
@@ -1310,7 +1310,7 @@ export class HttpBuildCacheProvider implements ICloudBuildCacheProvider {
|
|
|
1310
1310
|
|
|
1311
1311
|
private _getFailureType(
|
|
1312
1312
|
requestMethod: string,
|
|
1313
|
-
response:
|
|
1313
|
+
response: WebClientResponse,
|
|
1314
1314
|
isRedirect: boolean
|
|
1315
1315
|
): FailureType {
|
|
1316
1316
|
if (response.ok) <span class="branch-0 cbranch-no" title="branch not covered" >{</span>
|
|
@@ -1362,7 +1362,7 @@ export class HttpBuildCacheProvider implements ICloudBuildCacheProvider {
|
|
|
1362
1362
|
private _reportFailure(
|
|
1363
1363
|
terminal: ITerminal,
|
|
1364
1364
|
requestMethod: string,
|
|
1365
|
-
response:
|
|
1365
|
+
response: WebClientResponse,
|
|
1366
1366
|
isRedirect: boolean,
|
|
1367
1367
|
message: string
|
|
1368
1368
|
): void {
|
|
@@ -1411,7 +1411,7 @@ export class HttpBuildCacheProvider implements ICloudBuildCacheProvider {
|
|
|
1411
1411
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
1412
1412
|
Code coverage generated by
|
|
1413
1413
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
1414
|
-
at 2024-12-
|
|
1414
|
+
at 2024-12-09T20:30:12.874Z
|
|
1415
1415
|
</div>
|
|
1416
1416
|
<script src="prettify.js"></script>
|
|
1417
1417
|
<script>
|
|
@@ -313,7 +313,7 @@
|
|
|
313
313
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
314
314
|
Code coverage generated by
|
|
315
315
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
316
|
-
at 2024-12-
|
|
316
|
+
at 2024-12-09T20:30:12.874Z
|
|
317
317
|
</div>
|
|
318
318
|
<script src="prettify.js"></script>
|
|
319
319
|
<script>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<?xml version="1.0" ?>
|
|
2
2
|
<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
|
|
3
|
-
<coverage lines-valid="535" lines-covered="295" line-rate="0.5514" branches-valid="
|
|
3
|
+
<coverage lines-valid="535" lines-covered="295" line-rate="0.5514" branches-valid="60" branches-covered="32" branch-rate="0.5333" timestamp="1733776212826" complexity="0" version="0.1">
|
|
4
4
|
<sources>
|
|
5
5
|
<source>/mnt/vss/_work/1/s/rush-plugins/rush-http-build-cache-plugin</source>
|
|
6
6
|
</sources>
|
|
7
7
|
<packages>
|
|
8
|
-
<package name="main" line-rate="0.5514" branch-rate="0.
|
|
8
|
+
<package name="main" line-rate="0.5514" branch-rate="0.5333">
|
|
9
9
|
<classes>
|
|
10
|
-
<class name="HttpBuildCacheProvider.ts" filename="src/HttpBuildCacheProvider.ts" line-rate="0.6598999999999999" branch-rate="0.
|
|
10
|
+
<class name="HttpBuildCacheProvider.ts" filename="src/HttpBuildCacheProvider.ts" line-rate="0.6598999999999999" branch-rate="0.5517">
|
|
11
11
|
<methods>
|
|
12
12
|
<method name="get isCacheWriteAllowed" hits="0" signature="()V">
|
|
13
13
|
<lines>
|
|
@@ -364,7 +364,7 @@
|
|
|
364
364
|
<line number="286" hits="1" branch="false"/>
|
|
365
365
|
<line number="287" hits="1" branch="false"/>
|
|
366
366
|
<line number="288" hits="0" branch="true" condition-coverage="0% (0/1)"/>
|
|
367
|
-
<line number="289" hits="5" branch="
|
|
367
|
+
<line number="289" hits="5" branch="true" condition-coverage="0% (0/1)"/>
|
|
368
368
|
<line number="290" hits="5" branch="false"/>
|
|
369
369
|
<line number="291" hits="5" branch="false"/>
|
|
370
370
|
<line number="292" hits="5" branch="false"/>
|
package/coverage/index.html
CHANGED
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">
|
|
33
|
+
<span class="strong">53.33% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>32/
|
|
35
|
+
<span class='fraction'>32/60</span>
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
38
|
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
</td>
|
|
86
86
|
<td data-value="65.99" class="pct high">65.99%</td>
|
|
87
87
|
<td data-value="447" class="abs high">295/447</td>
|
|
88
|
-
<td data-value="
|
|
89
|
-
<td data-value="
|
|
88
|
+
<td data-value="55.17" class="pct high">55.17%</td>
|
|
89
|
+
<td data-value="58" class="abs high">32/58</td>
|
|
90
90
|
<td data-value="61.53" class="pct high">61.53%</td>
|
|
91
91
|
<td data-value="13" class="abs high">8/13</td>
|
|
92
92
|
<td data-value="65.99" class="pct high">65.99%</td>
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
132
132
|
Code coverage generated by
|
|
133
133
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
134
|
-
at 2024-12-
|
|
134
|
+
at 2024-12-09T20:30:12.874Z
|
|
135
135
|
</div>
|
|
136
136
|
<script src="prettify.js"></script>
|
|
137
137
|
<script>
|
package/coverage/index.ts.html
CHANGED
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
92
92
|
Code coverage generated by
|
|
93
93
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
94
|
-
at 2024-12-
|
|
94
|
+
at 2024-12-09T20:30:12.874Z
|
|
95
95
|
</div>
|
|
96
96
|
<script src="prettify.js"></script>
|
|
97
97
|
<script>
|
package/coverage/junit.xml
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<testsuites name="jest tests" tests="2" failures="0" errors="0" time="2.
|
|
3
|
-
<testsuite name="HttpBuildCacheProvider" errors="0" failures="0" skipped="0" timestamp="2024-12-
|
|
4
|
-
<testcase classname="HttpBuildCacheProvider tryGetCacheEntryBufferByIdAsync > " name="prints warning if read credentials are not available (lib/test/HttpBuildCacheProvider.test.js)" time="0.
|
|
2
|
+
<testsuites name="jest tests" tests="2" failures="0" errors="0" time="2.426">
|
|
3
|
+
<testsuite name="HttpBuildCacheProvider" errors="0" failures="0" skipped="0" timestamp="2024-12-09T20:30:10" time="2.064" tests="2">
|
|
4
|
+
<testcase classname="HttpBuildCacheProvider tryGetCacheEntryBufferByIdAsync > " name="prints warning if read credentials are not available (lib/test/HttpBuildCacheProvider.test.js)" time="0.055">
|
|
5
5
|
</testcase>
|
|
6
|
-
<testcase classname="HttpBuildCacheProvider tryGetCacheEntryBufferByIdAsync > " name="attempts up to 3 times to download a cache entry (lib/test/HttpBuildCacheProvider.test.js)" time="0.
|
|
6
|
+
<testcase classname="HttpBuildCacheProvider tryGetCacheEntryBufferByIdAsync > " name="attempts up to 3 times to download a cache entry (lib/test/HttpBuildCacheProvider.test.js)" time="0.01">
|
|
7
7
|
</testcase>
|
|
8
8
|
</testsuite>
|
|
9
9
|
</testsuites>
|
|
@@ -178,7 +178,7 @@ class HttpBuildCacheProvider {
|
|
|
178
178
|
this._reportFailure(terminal, method, response, false, warningText);
|
|
179
179
|
return false;
|
|
180
180
|
}
|
|
181
|
-
const result = readBody ? await response.
|
|
181
|
+
const result = readBody ? Buffer.from(await response.arrayBuffer()) : true;
|
|
182
182
|
terminal.writeDebugLine(`[http-build-cache] actual response: ${response.status} ${url} ${result === true ? 'true' : result.length} bytes`);
|
|
183
183
|
return result;
|
|
184
184
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpBuildCacheProvider.js","sourceRoot":"","sources":["../src/HttpBuildCacheProvider.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAAiE;AAEjE,kDAM6B;AAC7B,2EAAiG;AAGjG,IAAK,kBAIJ;AAJD,WAAK,kBAAkB;IACrB,mEAAQ,CAAA;IACR,mEAAQ,CAAA;IACR,2DAAI,CAAA;AACN,CAAC,EAJI,kBAAkB,KAAlB,kBAAkB,QAItB;AAED,IAAK,WAMJ;AAND,WAAK,WAAW;IACd,6CAAI,CAAA;IACJ,+DAAa,CAAA;IACb,mDAAO,CAAA;I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;gBACzB,QAAQ,CAAC,gBAAgB,CAAC,GAAG,OAAO,UAAU,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;gBACzF,MAAM;YACR,CAAC;YAED,KAAK,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;gBAC/B,QAAQ,CAAC,SAAS,CAAC,GAAG,OAAO,UAAU,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;gBAClF,MAAM;YACR,CAAC;YAED,KAAK,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;gBACtB,QAAQ,CAAC,cAAc,CAAC,GAAG,OAAO,UAAU,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;gBACvF,MAAM;YACR,CAAC;YAED,KAAK,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC;gBAChC,MAAM,IAAI,KAAK,CACb;oBACE,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,mBAAmB,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,GAAG;oBAC9E,mDAAmD;oBACnD,6FAA6F;oBAC7F,EAAE;oBACF,4BAA4B;oBAC5B,EAAE;oBACF,iDAAiD;oBACjD,EAAE;iBACH,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF;AArYD,wDAqYC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { Executable, Async } from '@rushstack/node-core-library';\nimport type { ITerminal } from '@rushstack/terminal';\nimport {\n type ICloudBuildCacheProvider,\n type ICredentialCacheEntry,\n CredentialCache,\n type RushSession,\n EnvironmentConfiguration\n} from '@rushstack/rush-sdk';\nimport { WebClient, type IWebClientResponse } from '@rushstack/rush-sdk/lib/utilities/WebClient';\nimport type { SpawnSyncReturns } from 'child_process';\n\nenum CredentialsOptions {\n Optional,\n Required,\n Omit\n}\n\nenum FailureType {\n None,\n Informational,\n Warning,\n Error,\n Authentication\n}\n\nexport interface IHttpBuildCacheTokenHandler {\n exec: string;\n args?: string[];\n}\n\n/**\n * @public\n */\nexport type UploadMethod = 'PUT' | 'POST' | 'PATCH';\n\n/**\n * @public\n */\nexport interface IHttpBuildCacheProviderOptions {\n url: string;\n tokenHandler?: IHttpBuildCacheTokenHandler;\n uploadMethod?: UploadMethod;\n minHttpRetryDelayMs?: number;\n headers?: Record<string, string>;\n cacheKeyPrefix?: string;\n isCacheWriteAllowed: boolean;\n pluginName: string;\n rushJsonFolder: string;\n}\n\nconst MAX_HTTP_CACHE_ATTEMPTS: number = 3;\nconst DEFAULT_MIN_HTTP_RETRY_DELAY_MS: number = 2500;\n\nexport class HttpBuildCacheProvider implements ICloudBuildCacheProvider {\n private readonly _pluginName: string;\n private readonly _rushProjectRoot: string;\n private readonly _environmentCredential: string | undefined;\n private readonly _isCacheWriteAllowedByConfiguration: boolean;\n private readonly _url: URL;\n private readonly _uploadMethod: UploadMethod;\n private readonly _headers: Record<string, string>;\n private readonly _cacheKeyPrefix: string;\n private readonly _tokenHandler: IHttpBuildCacheTokenHandler | undefined;\n private readonly _minHttpRetryDelayMs: number;\n private __credentialCacheId: string | undefined;\n\n public get isCacheWriteAllowed(): boolean {\n return EnvironmentConfiguration.buildCacheWriteAllowed ?? this._isCacheWriteAllowedByConfiguration;\n }\n\n public constructor(options: IHttpBuildCacheProviderOptions, rushSession: RushSession) {\n this._pluginName = options.pluginName;\n this._rushProjectRoot = options.rushJsonFolder;\n\n this._environmentCredential = EnvironmentConfiguration.buildCacheCredential;\n this._isCacheWriteAllowedByConfiguration = options.isCacheWriteAllowed;\n this._url = new URL(options.url.endsWith('/') ? options.url : options.url + '/');\n this._uploadMethod = options.uploadMethod ?? 'PUT';\n this._headers = options.headers ?? {};\n this._tokenHandler = options.tokenHandler;\n this._cacheKeyPrefix = options.cacheKeyPrefix ?? '';\n this._minHttpRetryDelayMs = options.minHttpRetryDelayMs ?? DEFAULT_MIN_HTTP_RETRY_DELAY_MS;\n }\n\n public async tryGetCacheEntryBufferByIdAsync(\n terminal: ITerminal,\n cacheId: string\n ): Promise<Buffer | undefined> {\n try {\n const result: boolean | Buffer = await this._makeHttpRequestAsync({\n terminal: terminal,\n relUrl: `${this._cacheKeyPrefix}${cacheId}`,\n method: 'GET',\n body: undefined,\n warningText: 'Could not get cache entry',\n readBody: true,\n maxAttempts: MAX_HTTP_CACHE_ATTEMPTS\n });\n\n return Buffer.isBuffer(result) ? result : undefined;\n } catch (e) {\n terminal.writeWarningLine(`Error getting cache entry: ${e}`);\n return undefined;\n }\n }\n\n public async trySetCacheEntryBufferAsync(\n terminal: ITerminal,\n cacheId: string,\n objectBuffer: Buffer\n ): Promise<boolean> {\n if (!this.isCacheWriteAllowed) {\n terminal.writeErrorLine('Writing to cache is not allowed in the current configuration.');\n return false;\n }\n\n terminal.writeDebugLine('Uploading object with cacheId: ', cacheId);\n\n try {\n const result: boolean | Buffer = await this._makeHttpRequestAsync({\n terminal: terminal,\n relUrl: `${this._cacheKeyPrefix}${cacheId}`,\n method: this._uploadMethod,\n body: objectBuffer,\n warningText: 'Could not write cache entry',\n readBody: false,\n maxAttempts: MAX_HTTP_CACHE_ATTEMPTS\n });\n\n return result !== false;\n } catch (e) {\n terminal.writeWarningLine(`Error uploading cache entry: ${e}`);\n return false;\n }\n }\n\n public async updateCachedCredentialAsync(terminal: ITerminal, credential: string): Promise<void> {\n await CredentialCache.usingAsync(\n {\n supportEditing: true\n },\n async (credentialsCache: CredentialCache) => {\n credentialsCache.setCacheEntry(this._credentialCacheId, {\n credential: credential\n });\n await credentialsCache.saveIfModifiedAsync();\n }\n );\n }\n\n public async updateCachedCredentialInteractiveAsync(terminal: ITerminal): Promise<void> {\n if (!this._tokenHandler) {\n throw new Error(\n `The interactive cloud credentials flow is not configured.\\n` +\n `Set the 'tokenHandler' setting in 'common/config/rush-plugins/${this._pluginName}.json' to a command that writes your credentials to standard output and exits with code 0 ` +\n `or provide your credentials to rush using the --credential flag instead. Credentials must be the ` +\n `'Authorization' header expected by ${this._url.href}`\n );\n }\n\n const cmd: string = `${this._tokenHandler.exec} ${(this._tokenHandler.args || []).join(' ')}`;\n terminal.writeVerboseLine(`Running '${cmd}' to get credentials`);\n const result: SpawnSyncReturns<string> = Executable.spawnSync(\n this._tokenHandler.exec,\n this._tokenHandler.args || [],\n {\n currentWorkingDirectory: this._rushProjectRoot\n }\n );\n\n terminal.writeErrorLine(result.stderr);\n\n if (result.error) {\n throw new Error(`Could not obtain credentials. The command '${cmd}' failed.`);\n }\n\n const credential: string = result.stdout.trim();\n terminal.writeVerboseLine('Got credentials');\n\n await this.updateCachedCredentialAsync(terminal, credential);\n\n terminal.writeLine('Updated credentials cache');\n }\n\n public async deleteCachedCredentialsAsync(terminal: ITerminal): Promise<void> {\n await CredentialCache.usingAsync(\n {\n supportEditing: true\n },\n async (credentialsCache: CredentialCache) => {\n credentialsCache.deleteCacheEntry(this._credentialCacheId);\n await credentialsCache.saveIfModifiedAsync();\n }\n );\n }\n\n private get _credentialCacheId(): string {\n if (!this.__credentialCacheId) {\n const cacheIdParts: string[] = [this._url.href];\n\n if (this._isCacheWriteAllowedByConfiguration) {\n cacheIdParts.push('cacheWriteAllowed');\n }\n\n this.__credentialCacheId = cacheIdParts.join('|');\n }\n\n return this.__credentialCacheId;\n }\n\n private async _makeHttpRequestAsync(options: {\n terminal: ITerminal;\n relUrl: string;\n method: 'GET' | UploadMethod;\n body: Buffer | undefined;\n warningText: string;\n readBody: boolean;\n maxAttempts: number;\n credentialOptions?: CredentialsOptions;\n }): Promise<Buffer | boolean> {\n const { terminal, relUrl, method, body, warningText, readBody, credentialOptions } = options;\n const safeCredentialOptions: CredentialsOptions = credentialOptions ?? CredentialsOptions.Optional;\n const credentials: string | undefined = await this._tryGetCredentialsAsync(safeCredentialOptions);\n const url: string = new URL(relUrl, this._url).href;\n\n const headers: Record<string, string> = {};\n if (typeof credentials === 'string') {\n headers.Authorization = credentials;\n }\n\n for (const [key, value] of Object.entries(this._headers)) {\n if (typeof value === 'string') {\n headers[key] = value;\n }\n }\n\n const bodyLength: number | 'unknown' = (body as { length: number })?.length || 'unknown';\n\n terminal.writeDebugLine(`[http-build-cache] request: ${method} ${url} ${bodyLength} bytes`);\n\n const webClient: WebClient = new WebClient();\n const response: IWebClientResponse = await webClient.fetchAsync(url, {\n verb: method,\n headers: headers,\n body: body,\n redirect: 'follow',\n timeoutMs: 0 // Use the default timeout\n });\n\n if (!response.ok) {\n const isNonCredentialResponse: boolean = response.status >= 500 && response.status < 600;\n\n if (\n !isNonCredentialResponse &&\n typeof credentials !== 'string' &&\n safeCredentialOptions === CredentialsOptions.Optional\n ) {\n // If we don't already have credentials yet, and we got a response from the server\n // that is a \"normal\" failure (4xx), then we assume that credentials are probably\n // required. Re-attempt the request, requiring credentials this time.\n //\n // This counts as part of the \"first attempt\", so it is not included in the max attempts\n return await this._makeHttpRequestAsync({\n ...options,\n credentialOptions: CredentialsOptions.Required\n });\n }\n\n if (options.maxAttempts > 1) {\n // Pause a bit before retrying in case the server is busy\n // Add some random jitter to the retry so we can spread out load on the remote service\n // A proper solution might add exponential back off in case the retry count is high (10 or more)\n const factor: number = 1.0 + Math.random(); // A random number between 1.0 and 2.0\n const retryDelay: number = Math.floor(factor * this._minHttpRetryDelayMs);\n\n await Async.sleepAsync(retryDelay);\n\n return await this._makeHttpRequestAsync({ ...options, maxAttempts: options.maxAttempts - 1 });\n }\n\n this._reportFailure(terminal, method, response, false, warningText);\n return false;\n }\n\n const result: Buffer | boolean = readBody ? await response.getBufferAsync() : true;\n\n terminal.writeDebugLine(\n `[http-build-cache] actual response: ${response.status} ${url} ${\n result === true ? 'true' : result.length\n } bytes`\n );\n\n return result;\n }\n\n private async _tryGetCredentialsAsync(options: CredentialsOptions.Required): Promise<string>;\n private async _tryGetCredentialsAsync(options: CredentialsOptions.Optional): Promise<string | undefined>;\n private async _tryGetCredentialsAsync(options: CredentialsOptions.Omit): Promise<undefined>;\n private async _tryGetCredentialsAsync(options: CredentialsOptions): Promise<string | undefined>;\n private async _tryGetCredentialsAsync(options: CredentialsOptions): Promise<string | undefined> {\n if (options === CredentialsOptions.Omit) {\n return;\n }\n\n let credentials: string | undefined = this._environmentCredential;\n\n if (credentials === undefined) {\n credentials = await this._tryGetCredentialsFromCacheAsync();\n }\n\n if (typeof credentials !== 'string' && options === CredentialsOptions.Required) {\n throw new Error(\n [\n `Credentials for ${this._url.href} have not been provided.`,\n `In CI, verify that RUSH_BUILD_CACHE_CREDENTIAL contains a valid Authorization header value.`,\n ``,\n `For local developers, run:`,\n ``,\n ` rush update-cloud-credentials --interactive`,\n ``\n ].join('\\n')\n );\n }\n\n return credentials;\n }\n\n private async _tryGetCredentialsFromCacheAsync(): Promise<string | undefined> {\n let cacheEntry: ICredentialCacheEntry | undefined;\n\n await CredentialCache.usingAsync(\n {\n supportEditing: false\n },\n (credentialsCache: CredentialCache) => {\n cacheEntry = credentialsCache.tryGetCacheEntry(this._credentialCacheId);\n }\n );\n\n if (cacheEntry) {\n const expirationTime: number | undefined = cacheEntry.expires?.getTime();\n if (!expirationTime || expirationTime >= Date.now()) {\n return cacheEntry.credential;\n }\n }\n }\n\n private _getFailureType(\n requestMethod: string,\n response: IWebClientResponse,\n isRedirect: boolean\n ): FailureType {\n if (response.ok) {\n return FailureType.None;\n }\n\n switch (response.status) {\n case 503: {\n // We select 503 specifically because this represents \"service unavailable\" and\n // \"rate limit throttle\" errors, which are transient issues.\n //\n // There are other 5xx errors, such as 501, that can occur if the request is\n // malformed, so as a general rule we want to let through other 5xx errors\n // so the user can troubleshoot.\n\n // Don't fail production builds with warnings for transient issues\n return FailureType.Informational;\n }\n\n case 401:\n case 403:\n case 407: {\n if (requestMethod === 'GET' && (isRedirect || response.redirected)) {\n // Cache misses for GET requests are not errors\n // This is a workaround behavior where a server can issue a redirect and we fail to authenticate at the new location.\n // We do not want to signal this as an authentication failure because the authorization header is not passed on to redirects.\n // i.e The authentication header was accepted for the first request and therefore subsequent failures\n // where it was not present should not be attributed to the header.\n // This scenario usually comes up with services that redirect to pre-signed URLS that don't actually exist.\n // Those services then usually treat the 404 as a 403 to prevent leaking information.\n return FailureType.None;\n }\n\n return FailureType.Authentication;\n }\n\n case 404: {\n if (requestMethod === 'GET') {\n // Cache misses for GET requests are not errors\n return FailureType.None;\n }\n }\n }\n\n // Let dev builds succeed, let Prod builds fail\n return FailureType.Warning;\n }\n\n private _reportFailure(\n terminal: ITerminal,\n requestMethod: string,\n response: IWebClientResponse,\n isRedirect: boolean,\n message: string\n ): void {\n switch (this._getFailureType(requestMethod, response, isRedirect)) {\n default: {\n terminal.writeErrorLine(`${message}: HTTP ${response.status}: ${response.statusText}`);\n break;\n }\n\n case FailureType.Warning: {\n terminal.writeWarningLine(`${message}: HTTP ${response.status}: ${response.statusText}`);\n break;\n }\n\n case FailureType.Informational: {\n terminal.writeLine(`${message}: HTTP ${response.status}: ${response.statusText}`);\n break;\n }\n\n case FailureType.None: {\n terminal.writeDebugLine(`${message}: HTTP ${response.status}: ${response.statusText}`);\n break;\n }\n\n case FailureType.Authentication: {\n throw new Error(\n [\n `${this._url.href} responded with ${response.status}: ${response.statusText}.`,\n `Credentials may be misconfigured or have expired.`,\n `In CI, verify that RUSH_BUILD_CACHE_CREDENTIAL contains a valid Authorization header value.`,\n ``,\n `For local developers, run:`,\n ``,\n ` rush update-cloud-credentials --interactive`,\n ``\n ].join('\\n')\n );\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"HttpBuildCacheProvider.js","sourceRoot":"","sources":["../src/HttpBuildCacheProvider.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAAiE;AAEjE,kDAM6B;AAC7B,2EAAgG;AAGhG,IAAK,kBAIJ;AAJD,WAAK,kBAAkB;IACrB,mEAAQ,CAAA;IACR,mEAAQ,CAAA;IACR,2DAAI,CAAA;AACN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C,cAAc,CAAC,GAAG,OAAO,UAAU,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;gBACvF,MAAM;YACR,CAAC;YAED,KAAK,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;gBACzB,QAAQ,CAAC,gBAAgB,CAAC,GAAG,OAAO,UAAU,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;gBACzF,MAAM;YACR,CAAC;YAED,KAAK,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC;gBAC/B,QAAQ,CAAC,SAAS,CAAC,GAAG,OAAO,UAAU,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;gBAClF,MAAM;YACR,CAAC;YAED,KAAK,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;gBACtB,QAAQ,CAAC,cAAc,CAAC,GAAG,OAAO,UAAU,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;gBACvF,MAAM;YACR,CAAC;YAED,KAAK,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC;gBAChC,MAAM,IAAI,KAAK,CACb;oBACE,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,mBAAmB,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,GAAG;oBAC9E,mDAAmD;oBACnD,6FAA6F;oBAC7F,EAAE;oBACF,4BAA4B;oBAC5B,EAAE;oBACF,iDAAiD;oBACjD,EAAE;iBACH,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF;AArYD,wDAqYC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { Executable, Async } from '@rushstack/node-core-library';\nimport type { ITerminal } from '@rushstack/terminal';\nimport {\n type ICloudBuildCacheProvider,\n type ICredentialCacheEntry,\n CredentialCache,\n type RushSession,\n EnvironmentConfiguration\n} from '@rushstack/rush-sdk';\nimport { WebClient, type WebClientResponse } from '@rushstack/rush-sdk/lib/utilities/WebClient';\nimport type { SpawnSyncReturns } from 'child_process';\n\nenum CredentialsOptions {\n Optional,\n Required,\n Omit\n}\n\nenum FailureType {\n None,\n Informational,\n Warning,\n Error,\n Authentication\n}\n\nexport interface IHttpBuildCacheTokenHandler {\n exec: string;\n args?: string[];\n}\n\n/**\n * @public\n */\nexport type UploadMethod = 'PUT' | 'POST' | 'PATCH';\n\n/**\n * @public\n */\nexport interface IHttpBuildCacheProviderOptions {\n url: string;\n tokenHandler?: IHttpBuildCacheTokenHandler;\n uploadMethod?: UploadMethod;\n minHttpRetryDelayMs?: number;\n headers?: Record<string, string>;\n cacheKeyPrefix?: string;\n isCacheWriteAllowed: boolean;\n pluginName: string;\n rushJsonFolder: string;\n}\n\nconst MAX_HTTP_CACHE_ATTEMPTS: number = 3;\nconst DEFAULT_MIN_HTTP_RETRY_DELAY_MS: number = 2500;\n\nexport class HttpBuildCacheProvider implements ICloudBuildCacheProvider {\n private readonly _pluginName: string;\n private readonly _rushProjectRoot: string;\n private readonly _environmentCredential: string | undefined;\n private readonly _isCacheWriteAllowedByConfiguration: boolean;\n private readonly _url: URL;\n private readonly _uploadMethod: UploadMethod;\n private readonly _headers: Record<string, string>;\n private readonly _cacheKeyPrefix: string;\n private readonly _tokenHandler: IHttpBuildCacheTokenHandler | undefined;\n private readonly _minHttpRetryDelayMs: number;\n private __credentialCacheId: string | undefined;\n\n public get isCacheWriteAllowed(): boolean {\n return EnvironmentConfiguration.buildCacheWriteAllowed ?? this._isCacheWriteAllowedByConfiguration;\n }\n\n public constructor(options: IHttpBuildCacheProviderOptions, rushSession: RushSession) {\n this._pluginName = options.pluginName;\n this._rushProjectRoot = options.rushJsonFolder;\n\n this._environmentCredential = EnvironmentConfiguration.buildCacheCredential;\n this._isCacheWriteAllowedByConfiguration = options.isCacheWriteAllowed;\n this._url = new URL(options.url.endsWith('/') ? options.url : options.url + '/');\n this._uploadMethod = options.uploadMethod ?? 'PUT';\n this._headers = options.headers ?? {};\n this._tokenHandler = options.tokenHandler;\n this._cacheKeyPrefix = options.cacheKeyPrefix ?? '';\n this._minHttpRetryDelayMs = options.minHttpRetryDelayMs ?? DEFAULT_MIN_HTTP_RETRY_DELAY_MS;\n }\n\n public async tryGetCacheEntryBufferByIdAsync(\n terminal: ITerminal,\n cacheId: string\n ): Promise<Buffer | undefined> {\n try {\n const result: boolean | Buffer = await this._makeHttpRequestAsync({\n terminal: terminal,\n relUrl: `${this._cacheKeyPrefix}${cacheId}`,\n method: 'GET',\n body: undefined,\n warningText: 'Could not get cache entry',\n readBody: true,\n maxAttempts: MAX_HTTP_CACHE_ATTEMPTS\n });\n\n return Buffer.isBuffer(result) ? result : undefined;\n } catch (e) {\n terminal.writeWarningLine(`Error getting cache entry: ${e}`);\n return undefined;\n }\n }\n\n public async trySetCacheEntryBufferAsync(\n terminal: ITerminal,\n cacheId: string,\n objectBuffer: Buffer\n ): Promise<boolean> {\n if (!this.isCacheWriteAllowed) {\n terminal.writeErrorLine('Writing to cache is not allowed in the current configuration.');\n return false;\n }\n\n terminal.writeDebugLine('Uploading object with cacheId: ', cacheId);\n\n try {\n const result: boolean | Buffer = await this._makeHttpRequestAsync({\n terminal: terminal,\n relUrl: `${this._cacheKeyPrefix}${cacheId}`,\n method: this._uploadMethod,\n body: objectBuffer,\n warningText: 'Could not write cache entry',\n readBody: false,\n maxAttempts: MAX_HTTP_CACHE_ATTEMPTS\n });\n\n return result !== false;\n } catch (e) {\n terminal.writeWarningLine(`Error uploading cache entry: ${e}`);\n return false;\n }\n }\n\n public async updateCachedCredentialAsync(terminal: ITerminal, credential: string): Promise<void> {\n await CredentialCache.usingAsync(\n {\n supportEditing: true\n },\n async (credentialsCache: CredentialCache) => {\n credentialsCache.setCacheEntry(this._credentialCacheId, {\n credential: credential\n });\n await credentialsCache.saveIfModifiedAsync();\n }\n );\n }\n\n public async updateCachedCredentialInteractiveAsync(terminal: ITerminal): Promise<void> {\n if (!this._tokenHandler) {\n throw new Error(\n `The interactive cloud credentials flow is not configured.\\n` +\n `Set the 'tokenHandler' setting in 'common/config/rush-plugins/${this._pluginName}.json' to a command that writes your credentials to standard output and exits with code 0 ` +\n `or provide your credentials to rush using the --credential flag instead. Credentials must be the ` +\n `'Authorization' header expected by ${this._url.href}`\n );\n }\n\n const cmd: string = `${this._tokenHandler.exec} ${(this._tokenHandler.args || []).join(' ')}`;\n terminal.writeVerboseLine(`Running '${cmd}' to get credentials`);\n const result: SpawnSyncReturns<string> = Executable.spawnSync(\n this._tokenHandler.exec,\n this._tokenHandler.args || [],\n {\n currentWorkingDirectory: this._rushProjectRoot\n }\n );\n\n terminal.writeErrorLine(result.stderr);\n\n if (result.error) {\n throw new Error(`Could not obtain credentials. The command '${cmd}' failed.`);\n }\n\n const credential: string = result.stdout.trim();\n terminal.writeVerboseLine('Got credentials');\n\n await this.updateCachedCredentialAsync(terminal, credential);\n\n terminal.writeLine('Updated credentials cache');\n }\n\n public async deleteCachedCredentialsAsync(terminal: ITerminal): Promise<void> {\n await CredentialCache.usingAsync(\n {\n supportEditing: true\n },\n async (credentialsCache: CredentialCache) => {\n credentialsCache.deleteCacheEntry(this._credentialCacheId);\n await credentialsCache.saveIfModifiedAsync();\n }\n );\n }\n\n private get _credentialCacheId(): string {\n if (!this.__credentialCacheId) {\n const cacheIdParts: string[] = [this._url.href];\n\n if (this._isCacheWriteAllowedByConfiguration) {\n cacheIdParts.push('cacheWriteAllowed');\n }\n\n this.__credentialCacheId = cacheIdParts.join('|');\n }\n\n return this.__credentialCacheId;\n }\n\n private async _makeHttpRequestAsync(options: {\n terminal: ITerminal;\n relUrl: string;\n method: 'GET' | UploadMethod;\n body: Buffer | undefined;\n warningText: string;\n readBody: boolean;\n maxAttempts: number;\n credentialOptions?: CredentialsOptions;\n }): Promise<Buffer | boolean> {\n const { terminal, relUrl, method, body, warningText, readBody, credentialOptions } = options;\n const safeCredentialOptions: CredentialsOptions = credentialOptions ?? CredentialsOptions.Optional;\n const credentials: string | undefined = await this._tryGetCredentialsAsync(safeCredentialOptions);\n const url: string = new URL(relUrl, this._url).href;\n\n const headers: Record<string, string> = {};\n if (typeof credentials === 'string') {\n headers.Authorization = credentials;\n }\n\n for (const [key, value] of Object.entries(this._headers)) {\n if (typeof value === 'string') {\n headers[key] = value;\n }\n }\n\n const bodyLength: number | 'unknown' = (body as { length: number })?.length || 'unknown';\n\n terminal.writeDebugLine(`[http-build-cache] request: ${method} ${url} ${bodyLength} bytes`);\n\n const webClient: WebClient = new WebClient();\n const response: WebClientResponse = await webClient.fetchAsync(url, {\n verb: method,\n headers: headers,\n body: body,\n redirect: 'follow',\n timeoutMs: 0 // Use the default timeout\n });\n\n if (!response.ok) {\n const isNonCredentialResponse: boolean = response.status >= 500 && response.status < 600;\n\n if (\n !isNonCredentialResponse &&\n typeof credentials !== 'string' &&\n safeCredentialOptions === CredentialsOptions.Optional\n ) {\n // If we don't already have credentials yet, and we got a response from the server\n // that is a \"normal\" failure (4xx), then we assume that credentials are probably\n // required. Re-attempt the request, requiring credentials this time.\n //\n // This counts as part of the \"first attempt\", so it is not included in the max attempts\n return await this._makeHttpRequestAsync({\n ...options,\n credentialOptions: CredentialsOptions.Required\n });\n }\n\n if (options.maxAttempts > 1) {\n // Pause a bit before retrying in case the server is busy\n // Add some random jitter to the retry so we can spread out load on the remote service\n // A proper solution might add exponential back off in case the retry count is high (10 or more)\n const factor: number = 1.0 + Math.random(); // A random number between 1.0 and 2.0\n const retryDelay: number = Math.floor(factor * this._minHttpRetryDelayMs);\n\n await Async.sleepAsync(retryDelay);\n\n return await this._makeHttpRequestAsync({ ...options, maxAttempts: options.maxAttempts - 1 });\n }\n\n this._reportFailure(terminal, method, response, false, warningText);\n return false;\n }\n\n const result: Buffer | boolean = readBody ? Buffer.from(await response.arrayBuffer()) : true;\n\n terminal.writeDebugLine(\n `[http-build-cache] actual response: ${response.status} ${url} ${\n result === true ? 'true' : result.length\n } bytes`\n );\n\n return result;\n }\n\n private async _tryGetCredentialsAsync(options: CredentialsOptions.Required): Promise<string>;\n private async _tryGetCredentialsAsync(options: CredentialsOptions.Optional): Promise<string | undefined>;\n private async _tryGetCredentialsAsync(options: CredentialsOptions.Omit): Promise<undefined>;\n private async _tryGetCredentialsAsync(options: CredentialsOptions): Promise<string | undefined>;\n private async _tryGetCredentialsAsync(options: CredentialsOptions): Promise<string | undefined> {\n if (options === CredentialsOptions.Omit) {\n return;\n }\n\n let credentials: string | undefined = this._environmentCredential;\n\n if (credentials === undefined) {\n credentials = await this._tryGetCredentialsFromCacheAsync();\n }\n\n if (typeof credentials !== 'string' && options === CredentialsOptions.Required) {\n throw new Error(\n [\n `Credentials for ${this._url.href} have not been provided.`,\n `In CI, verify that RUSH_BUILD_CACHE_CREDENTIAL contains a valid Authorization header value.`,\n ``,\n `For local developers, run:`,\n ``,\n ` rush update-cloud-credentials --interactive`,\n ``\n ].join('\\n')\n );\n }\n\n return credentials;\n }\n\n private async _tryGetCredentialsFromCacheAsync(): Promise<string | undefined> {\n let cacheEntry: ICredentialCacheEntry | undefined;\n\n await CredentialCache.usingAsync(\n {\n supportEditing: false\n },\n (credentialsCache: CredentialCache) => {\n cacheEntry = credentialsCache.tryGetCacheEntry(this._credentialCacheId);\n }\n );\n\n if (cacheEntry) {\n const expirationTime: number | undefined = cacheEntry.expires?.getTime();\n if (!expirationTime || expirationTime >= Date.now()) {\n return cacheEntry.credential;\n }\n }\n }\n\n private _getFailureType(\n requestMethod: string,\n response: WebClientResponse,\n isRedirect: boolean\n ): FailureType {\n if (response.ok) {\n return FailureType.None;\n }\n\n switch (response.status) {\n case 503: {\n // We select 503 specifically because this represents \"service unavailable\" and\n // \"rate limit throttle\" errors, which are transient issues.\n //\n // There are other 5xx errors, such as 501, that can occur if the request is\n // malformed, so as a general rule we want to let through other 5xx errors\n // so the user can troubleshoot.\n\n // Don't fail production builds with warnings for transient issues\n return FailureType.Informational;\n }\n\n case 401:\n case 403:\n case 407: {\n if (requestMethod === 'GET' && (isRedirect || response.redirected)) {\n // Cache misses for GET requests are not errors\n // This is a workaround behavior where a server can issue a redirect and we fail to authenticate at the new location.\n // We do not want to signal this as an authentication failure because the authorization header is not passed on to redirects.\n // i.e The authentication header was accepted for the first request and therefore subsequent failures\n // where it was not present should not be attributed to the header.\n // This scenario usually comes up with services that redirect to pre-signed URLS that don't actually exist.\n // Those services then usually treat the 404 as a 403 to prevent leaking information.\n return FailureType.None;\n }\n\n return FailureType.Authentication;\n }\n\n case 404: {\n if (requestMethod === 'GET') {\n // Cache misses for GET requests are not errors\n return FailureType.None;\n }\n }\n }\n\n // Let dev builds succeed, let Prod builds fail\n return FailureType.Warning;\n }\n\n private _reportFailure(\n terminal: ITerminal,\n requestMethod: string,\n response: WebClientResponse,\n isRedirect: boolean,\n message: string\n ): void {\n switch (this._getFailureType(requestMethod, response, isRedirect)) {\n default: {\n terminal.writeErrorLine(`${message}: HTTP ${response.status}: ${response.statusText}`);\n break;\n }\n\n case FailureType.Warning: {\n terminal.writeWarningLine(`${message}: HTTP ${response.status}: ${response.statusText}`);\n break;\n }\n\n case FailureType.Informational: {\n terminal.writeLine(`${message}: HTTP ${response.status}: ${response.statusText}`);\n break;\n }\n\n case FailureType.None: {\n terminal.writeDebugLine(`${message}: HTTP ${response.status}: ${response.statusText}`);\n break;\n }\n\n case FailureType.Authentication: {\n throw new Error(\n [\n `${this._url.href} responded with ${response.status}: ${response.statusText}.`,\n `Credentials may be misconfigured or have expired.`,\n `In CI, verify that RUSH_BUILD_CACHE_CREDENTIAL contains a valid Authorization header value.`,\n ``,\n `For local developers, run:`,\n ``,\n ` rush update-cloud-credentials --interactive`,\n ``\n ].join('\\n')\n );\n }\n }\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/rush-http-build-cache-plugin",
|
|
3
|
-
"version": "5.144.
|
|
3
|
+
"version": "5.144.1",
|
|
4
4
|
"description": "Rush plugin for generic HTTP cloud build cache",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"https-proxy-agent": "~5.0.0",
|
|
16
|
-
"@rushstack/
|
|
17
|
-
"@rushstack/
|
|
16
|
+
"@rushstack/node-core-library": "5.10.0",
|
|
17
|
+
"@rushstack/rush-sdk": "5.144.1"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@
|
|
21
|
-
"@
|
|
22
|
-
"
|
|
23
|
-
"
|
|
20
|
+
"@rushstack/heft": "0.68.10",
|
|
21
|
+
"@microsoft/rush-lib": "5.144.1",
|
|
22
|
+
"@rushstack/terminal": "0.14.3",
|
|
23
|
+
"local-node-rig": "1.0.0"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "heft build --clean",
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
Caching build output folders: .rush/temp/operation/_phase_build, lib, temp
|
|
2
2
|
Successfully set cache entry.
|
|
3
|
-
Cache key: rushstack+rush-http-build-cache-plugin-_phase_build-
|
|
3
|
+
Cache key: rushstack+rush-http-build-cache-plugin-_phase_build-ad0665ff21c993746ce2ee20280627970419284e
|
|
@@ -3,5 +3,5 @@ Invoking: heft run --only build -- --clean --production
|
|
|
3
3
|
[build:typescript] Using TypeScript version 5.4.2
|
|
4
4
|
[build:lint] Using ESLint version 8.57.0
|
|
5
5
|
[build:typescript] Copied 1 file and linked 0 files
|
|
6
|
-
---- build finished (10.
|
|
7
|
-
-------------------- Finished (10.
|
|
6
|
+
---- build finished (10.440s) ----
|
|
7
|
+
-------------------- Finished (10.446s) --------------------
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
Caching build output folders: .rush/temp/operation/_phase_test, coverage
|
|
2
2
|
Successfully set cache entry.
|
|
3
|
-
Cache key: rushstack+rush-http-build-cache-plugin-_phase_test-
|
|
3
|
+
Cache key: rushstack+rush-http-build-cache-plugin-_phase_test-eff33e429016638e7614530b8c4b50864798503a
|
|
@@ -5,11 +5,11 @@ The provided list of phases does not contain all phase dependencies. You may nee
|
|
|
5
5
|
[test:jest]
|
|
6
6
|
[test:jest] Run start. 1 test suite
|
|
7
7
|
[test:jest] START lib/test/HttpBuildCacheProvider.test.js
|
|
8
|
-
[test:jest] PASS lib/test/HttpBuildCacheProvider.test.js (duration: 2.
|
|
8
|
+
[test:jest] PASS lib/test/HttpBuildCacheProvider.test.js (duration: 2.064s, 2 passed, 0 failed)
|
|
9
9
|
[test:jest]
|
|
10
10
|
[test:jest] Tests finished:
|
|
11
11
|
[test:jest] Successes: 2
|
|
12
12
|
[test:jest] Failures: 0
|
|
13
13
|
[test:jest] Total: 2
|
|
14
|
-
---- test finished (3.
|
|
15
|
-
-------------------- Finished (3.
|
|
14
|
+
---- test finished (3.804s) ----
|
|
15
|
+
-------------------- Finished (3.811s) --------------------
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
type RushSession,
|
|
11
11
|
EnvironmentConfiguration
|
|
12
12
|
} from '@rushstack/rush-sdk';
|
|
13
|
-
import { WebClient, type
|
|
13
|
+
import { WebClient, type WebClientResponse } from '@rushstack/rush-sdk/lib/utilities/WebClient';
|
|
14
14
|
import type { SpawnSyncReturns } from 'child_process';
|
|
15
15
|
|
|
16
16
|
enum CredentialsOptions {
|
|
@@ -243,7 +243,7 @@ export class HttpBuildCacheProvider implements ICloudBuildCacheProvider {
|
|
|
243
243
|
terminal.writeDebugLine(`[http-build-cache] request: ${method} ${url} ${bodyLength} bytes`);
|
|
244
244
|
|
|
245
245
|
const webClient: WebClient = new WebClient();
|
|
246
|
-
const response:
|
|
246
|
+
const response: WebClientResponse = await webClient.fetchAsync(url, {
|
|
247
247
|
verb: method,
|
|
248
248
|
headers: headers,
|
|
249
249
|
body: body,
|
|
@@ -286,7 +286,7 @@ export class HttpBuildCacheProvider implements ICloudBuildCacheProvider {
|
|
|
286
286
|
return false;
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
-
const result: Buffer | boolean = readBody ? await response.
|
|
289
|
+
const result: Buffer | boolean = readBody ? Buffer.from(await response.arrayBuffer()) : true;
|
|
290
290
|
|
|
291
291
|
terminal.writeDebugLine(
|
|
292
292
|
`[http-build-cache] actual response: ${response.status} ${url} ${
|
|
@@ -351,7 +351,7 @@ export class HttpBuildCacheProvider implements ICloudBuildCacheProvider {
|
|
|
351
351
|
|
|
352
352
|
private _getFailureType(
|
|
353
353
|
requestMethod: string,
|
|
354
|
-
response:
|
|
354
|
+
response: WebClientResponse,
|
|
355
355
|
isRedirect: boolean
|
|
356
356
|
): FailureType {
|
|
357
357
|
if (response.ok) {
|
|
@@ -403,7 +403,7 @@ export class HttpBuildCacheProvider implements ICloudBuildCacheProvider {
|
|
|
403
403
|
private _reportFailure(
|
|
404
404
|
terminal: ITerminal,
|
|
405
405
|
requestMethod: string,
|
|
406
|
-
response:
|
|
406
|
+
response: WebClientResponse,
|
|
407
407
|
isRedirect: boolean,
|
|
408
408
|
message: string
|
|
409
409
|
): void {
|