@rushstack/rush-http-build-cache-plugin 5.150.0 → 5.152.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 (66) hide show
  1. package/LICENSE +24 -0
  2. package/lib/HttpBuildCacheProvider.d.ts +0 -2
  3. package/lib/HttpBuildCacheProvider.d.ts.map +1 -1
  4. package/lib/HttpBuildCacheProvider.js +5 -2
  5. package/lib/HttpBuildCacheProvider.js.map +1 -1
  6. package/lib/RushHttpBuildCachePlugin.js +17 -7
  7. package/lib/RushHttpBuildCachePlugin.js.map +1 -1
  8. package/package.json +7 -7
  9. package/rush-plugin-manifest.json +1 -1
  10. package/.eslintrc.js +0 -12
  11. package/.rush/temp/chunked-rush-logs/rush-http-build-cache-plugin._phase_build.chunks.jsonl +0 -7
  12. package/.rush/temp/chunked-rush-logs/rush-http-build-cache-plugin._phase_test.chunks.jsonl +0 -15
  13. package/.rush/temp/operation/_phase_build/all.log +0 -7
  14. package/.rush/temp/operation/_phase_build/log-chunks.jsonl +0 -7
  15. package/.rush/temp/operation/_phase_build/state.json +0 -3
  16. package/.rush/temp/operation/_phase_test/all.log +0 -15
  17. package/.rush/temp/operation/_phase_test/log-chunks.jsonl +0 -15
  18. package/.rush/temp/operation/_phase_test/state.json +0 -3
  19. package/.rush/temp/rushstack+rush-http-build-cache-plugin-_phase_build-2024be7372f51761b010f9514adf1d86d16d703b.tar.log +0 -32
  20. package/.rush/temp/rushstack+rush-http-build-cache-plugin-_phase_test-070a8df8efa2a6dea51faad619eb159c90c69c2c.tar.log +0 -25
  21. package/.rush/temp/shrinkwrap-deps.json +0 -9
  22. package/config/jest.config.json +0 -14
  23. package/config/rig.json +0 -18
  24. package/coverage/HttpBuildCacheProvider.ts.html +0 -1426
  25. package/coverage/RushHttpBuildCachePlugin.ts.html +0 -328
  26. package/coverage/base.css +0 -224
  27. package/coverage/block-navigation.js +0 -87
  28. package/coverage/cobertura-coverage.xml +0 -641
  29. package/coverage/favicon.png +0 -0
  30. package/coverage/index.html +0 -146
  31. package/coverage/index.ts.html +0 -106
  32. package/coverage/junit.xml +0 -9
  33. package/coverage/prettify.css +0 -1
  34. package/coverage/prettify.js +0 -2
  35. package/coverage/sort-arrow-sprite.png +0 -0
  36. package/coverage/sorter.js +0 -196
  37. package/lib/test/HttpBuildCacheProvider.test.d.ts +0 -2
  38. package/lib/test/HttpBuildCacheProvider.test.d.ts.map +0 -1
  39. package/lib/test/HttpBuildCacheProvider.test.js +0 -94
  40. package/lib/test/HttpBuildCacheProvider.test.js.map +0 -1
  41. package/rush-logs/rush-http-build-cache-plugin._phase_build.cache.log +0 -3
  42. package/rush-logs/rush-http-build-cache-plugin._phase_build.log +0 -7
  43. package/rush-logs/rush-http-build-cache-plugin._phase_test.cache.log +0 -3
  44. package/rush-logs/rush-http-build-cache-plugin._phase_test.log +0 -15
  45. package/src/HttpBuildCacheProvider.ts +0 -447
  46. package/src/RushHttpBuildCachePlugin.ts +0 -81
  47. package/src/index.ts +0 -7
  48. package/src/schemas/plugin-config.schema.json +0 -52
  49. package/src/test/HttpBuildCacheProvider.test.ts +0 -128
  50. package/temp/build/lint/_eslint-it73M-Rx.json +0 -4
  51. package/temp/build/typescript/file-copy.json +0 -1
  52. package/temp/build/typescript/ts_l9Fw4VUO.json +0 -1
  53. package/temp/test/jest/haste-map-8bff56e236187dbf28a94cdea7ee2158-1f8f3a8b20228094c245723445dd2c9a-e95bfd62c357a87bf3c5f47c6c3a2910 +0 -0
  54. package/temp/test/jest/jest-transform-cache-8bff56e236187dbf28a94cdea7ee2158-79ef2876fae7ca75eedb2aa53dc48338/33/core_3305ad7ebc3e67008b0e3d5efb3c89fa +0 -159
  55. package/temp/test/jest/jest-transform-cache-8bff56e236187dbf28a94cdea7ee2158-79ef2876fae7ca75eedb2aa53dc48338/66/data_662ee7a852684a50b5465ea7d1610925 +0 -14
  56. package/temp/test/jest/jest-transform-cache-8bff56e236187dbf28a94cdea7ee2158-79ef2876fae7ca75eedb2aa53dc48338/74/jsonschemadraft07_74eae8d0e8c71a9be8c8f3e605321373 +0 -152
  57. package/temp/test/jest/jest-transform-cache-8bff56e236187dbf28a94cdea7ee2158-79ef2876fae7ca75eedb2aa53dc48338/7b/data_7bd2e7b754ae682e8489f2e419bf314d +0 -14
  58. package/temp/test/jest/jest-transform-cache-8bff56e236187dbf28a94cdea7ee2158-79ef2876fae7ca75eedb2aa53dc48338/b7/jsonschemadraft04_b75c7627c284f64550e887c2057ef2b6 +0 -139
  59. package/temp/test/jest/jest-transform-cache-8bff56e236187dbf28a94cdea7ee2158-79ef2876fae7ca75eedb2aa53dc48338/c2/core_c2aa2d30a753f979fb7064944ea7e770 +0 -163
  60. package/temp/test/jest/jest-transform-cache-8bff56e236187dbf28a94cdea7ee2158-79ef2876fae7ca75eedb2aa53dc48338/d5/core_d54674276357d38b544776746c491fe4 +0 -159
  61. package/temp/test/jest/jest-transform-cache-8bff56e236187dbf28a94cdea7ee2158-79ef2876fae7ca75eedb2aa53dc48338/e0/core_e0f97ce5582728aab20c89fda7e102ec +0 -163
  62. package/temp/test/jest/jest-transform-cache-8bff56e236187dbf28a94cdea7ee2158-79ef2876fae7ca75eedb2aa53dc48338/ef/jsonschemadraft07_ef987ddfbeb03ba4a34e7532df7928e0 +0 -152
  63. package/temp/test/jest/jest-transform-cache-8bff56e236187dbf28a94cdea7ee2158-79ef2876fae7ca75eedb2aa53dc48338/f8/jsonschemadraft04_f814157dc4b13278270c74e697ca146f +0 -139
  64. package/temp/test/jest/perf-cache-8bff56e236187dbf28a94cdea7ee2158-da39a3ee5e6b4b0d3255bfef95601890 +0 -1
  65. package/tsconfig.json +0 -3
  66. /package/lib/schemas/{plugin-config.schema.json → http-config.schema.json} +0 -0
package/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ @rushstack/rush-http-build-cache-plugin
2
+
3
+ Copyright (c) Microsoft Corporation. All rights reserved.
4
+
5
+ MIT License
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ "Software"), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import type { ITerminal } from '@rushstack/terminal';
4
2
  import { type ICloudBuildCacheProvider, type RushSession } from '@rushstack/rush-sdk';
5
3
  export interface IHttpBuildCacheTokenHandler {
@@ -1 +1 @@
1
- {"version":3,"file":"HttpBuildCacheProvider.d.ts","sourceRoot":"","sources":["../src/HttpBuildCacheProvider.ts"],"names":[],"mappings":";;AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EACL,KAAK,wBAAwB,EAG7B,KAAK,WAAW,EAEjB,MAAM,qBAAqB,CAAC;AAkB7B,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CA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. Re-attempt the request, requiring credentials this time.
165
165
  //
166
166
  // This counts as part of the "first attempt", so it is not included in the max attempts
167
- return await this._makeHttpRequestAsync(Object.assign(Object.assign({}, options), { credentialOptions: CredentialsOptions.Required }));
167
+ return await this._makeHttpRequestAsync({
168
+ ...options,
169
+ credentialOptions: CredentialsOptions.Required
170
+ });
168
171
  }
169
172
  if (options.maxAttempts > 1) {
170
173
  // Pause a bit before retrying in case the server is busy
@@ -173,7 +176,7 @@ class HttpBuildCacheProvider {
173
176
  const factor = 1.0 + Math.random(); // A random number between 1.0 and 2.0
174
177
  const retryDelay = Math.floor(factor * this._minHttpRetryDelayMs);
175
178
  await node_core_library_1.Async.sleepAsync(retryDelay);
176
- return await this._makeHttpRequestAsync(Object.assign(Object.assign({}, options), { maxAttempts: options.maxAttempts - 1 }));
179
+ return await this._makeHttpRequestAsync({ ...options, maxAttempts: options.maxAttempts - 1 });
177
180
  }
178
181
  this._reportFailure(terminal, method, response, false, warningText);
179
182
  return false;
@@ -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;IACP,+CAAK,CAAA;IACL,iEAAc,CAAA;AAChB,CAAC,EANI,WAAW,KAAX,WAAW,QAMf;AA2BD,MAAM,uBAAuB,GAAW,CAAC,CAAC;AAC1C,MAAM,+BAA+B,GAAW,IAAI,CAAC;AAErD,MAAa,sBAAsB;IAajC,IAAW,mBAAmB;;QA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Q,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,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;IACP,+CAAK,CAAA;IACL,iEAAc,CAAA;AAChB,CAAC,EANI,WAAW,KAAX,WAAW,QA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,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"]}
@@ -17,13 +17,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
17
17
  }) : function(o, v) {
18
18
  o["default"] = v;
19
19
  });
20
- var __importStar = (this && this.__importStar) || function (mod) {
21
- if (mod && mod.__esModule) return mod;
22
- var result = {};
23
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
- __setModuleDefault(result, mod);
25
- return result;
26
- };
20
+ var __importStar = (this && this.__importStar) || (function () {
21
+ var ownKeys = function(o) {
22
+ ownKeys = Object.getOwnPropertyNames || function (o) {
23
+ var ar = [];
24
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
+ return ar;
26
+ };
27
+ return ownKeys(o);
28
+ };
29
+ return function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ })();
27
37
  Object.defineProperty(exports, "__esModule", { value: true });
28
38
  exports.RushHttpBuildCachePlugin = void 0;
29
39
  const PLUGIN_NAME = 'HttpBuildCachePlugin';
@@ -1 +1 @@
1
- {"version":3,"file":"RushHttpBuildCachePlugin.js","sourceRoot":"","sources":["../src/RushHttpBuildCachePlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAK3D,MAAM,WAAW,GAAW,sBAAsB,CAAC;AAyCnD;;GAEG;AACH,MAAa,wBAAwB;IAArC;QACkB,eAAU,GAAW,WAAW,CAAC;IA6BnD,CAAC;IA3BQ,KAAK,CAAC,WAAwB,EAAE,UAA6B;QAClE,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE;YACrD,WAAW,CAAC,sCAAsC,CAAC,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE;gBACpF,MAAM,MAAM,GACV,gBAGD,CAAC,iBAAiB,CAAC;gBAEpB,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,GAAG,MAAM,CAAC;gBAEjG,MAAM,OAAO,GAAmC;oBAC9C,UAAU,EAAE,IAAI,CAAC,UAAU;oBAC3B,cAAc,EAAE,UAAU,CAAC,cAAc;oBACzC,GAAG,EAAE,GAAG;oBACR,YAAY,EAAE,YAAY;oBAC1B,OAAO,EAAE,OAAO;oBAChB,YAAY,EAAE,YAAY;oBAC1B,cAAc,EAAE,cAAc;oBAC9B,mBAAmB,EAAE,CAAC,CAAC,mBAAmB;iBAC3C,CAAC;gBAEF,MAAM,EAAE,sBAAsB,EAAE,GAAG,wDAAa,0BAA0B,GAAC,CAAC;gBAC5E,OAAO,IAAI,sBAAsB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YAC1D,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA9BD,4DA8BC","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 type { IRushPlugin, RushSession, RushConfiguration } from '@rushstack/rush-sdk';\nimport type { IHttpBuildCacheProviderOptions, UploadMethod } from './HttpBuildCacheProvider';\n\nconst PLUGIN_NAME: string = 'HttpBuildCachePlugin';\n\n/**\n * @public\n */\nexport interface IRushHttpBuildCachePluginConfig {\n /**\n * The URL of the server that stores the caches (e.g. \"https://build-caches.example.com\").\n */\n url: string;\n\n /**\n * The HTTP method to use when writing to the cache (defaults to PUT).\n */\n uploadMethod?: UploadMethod;\n\n /**\n * An optional set of HTTP headers to pass to the cache server.\n */\n headers?: Record<string, string>;\n\n /**\n * An optional command that prints the endpoint's credentials to stdout. Provide the\n * command or script to execute and, optionally, any arguments to pass to the script.\n */\n tokenHandler?: {\n exec: string;\n args?: string[];\n };\n\n /**\n * Prefix for cache keys.\n */\n cacheKeyPrefix?: string;\n\n /**\n * If set to true, allow writing to the cache. Defaults to false.\n */\n isCacheWriteAllowed?: boolean;\n}\n\n/**\n * @public\n */\nexport class RushHttpBuildCachePlugin implements IRushPlugin {\n public readonly pluginName: string = PLUGIN_NAME;\n\n public apply(rushSession: RushSession, rushConfig: RushConfiguration): void {\n rushSession.hooks.initialize.tap(this.pluginName, () => {\n rushSession.registerCloudBuildCacheProviderFactory('http', async (buildCacheConfig) => {\n const config: IRushHttpBuildCachePluginConfig = (\n buildCacheConfig as typeof buildCacheConfig & {\n httpConfiguration: IRushHttpBuildCachePluginConfig;\n }\n ).httpConfiguration;\n\n const { url, uploadMethod, headers, tokenHandler, cacheKeyPrefix, isCacheWriteAllowed } = config;\n\n const options: IHttpBuildCacheProviderOptions = {\n pluginName: this.pluginName,\n rushJsonFolder: rushConfig.rushJsonFolder,\n url: url,\n uploadMethod: uploadMethod,\n headers: headers,\n tokenHandler: tokenHandler,\n cacheKeyPrefix: cacheKeyPrefix,\n isCacheWriteAllowed: !!isCacheWriteAllowed\n };\n\n const { HttpBuildCacheProvider } = await import('./HttpBuildCacheProvider');\n return new HttpBuildCacheProvider(options, rushSession);\n });\n });\n }\n}\n"]}
1
+ {"version":3,"file":"RushHttpBuildCachePlugin.js","sourceRoot":"","sources":["../src/RushHttpBuildCachePlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAK3D,MAAM,WAAW,GAAW,sBAAsB,CAAC;AAyCnD;;GAEG;AACH,MAAa,wBAAwB;IAArC;QACkB,eAAU,GAAW,WAAW,CAAC;IA6BnD,CAAC;IA3BQ,KAAK,CAAC,WAAwB,EAAE,UAA6B;QAClE,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE;YACrD,WAAW,CAAC,sCAAsC,CAAC,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE;gBACpF,MAAM,MAAM,GACV,gBAGD,CAAC,iBAAiB,CAAC;gBAEpB,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,GAAG,MAAM,CAAC;gBAEjG,MAAM,OAAO,GAAmC;oBAC9C,UAAU,EAAE,IAAI,CAAC,UAAU;oBAC3B,cAAc,EAAE,UAAU,CAAC,cAAc;oBACzC,GAAG,EAAE,GAAG;oBACR,YAAY,EAAE,YAAY;oBAC1B,OAAO,EAAE,OAAO;oBAChB,YAAY,EAAE,YAAY;oBAC1B,cAAc,EAAE,cAAc;oBAC9B,mBAAmB,EAAE,CAAC,CAAC,mBAAmB;iBAC3C,CAAC;gBAEF,MAAM,EAAE,sBAAsB,EAAE,GAAG,wDAAa,0BAA0B,GAAC,CAAC;gBAC5E,OAAO,IAAI,sBAAsB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YAC1D,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA9BD,4DA8BC","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 type { IRushPlugin, RushSession, RushConfiguration } from '@rushstack/rush-sdk';\nimport type { IHttpBuildCacheProviderOptions, UploadMethod } from './HttpBuildCacheProvider';\n\nconst PLUGIN_NAME: string = 'HttpBuildCachePlugin';\n\n/**\n * @public\n */\nexport interface IRushHttpBuildCachePluginConfig {\n /**\n * The URL of the server that stores the caches (e.g. \"https://build-caches.example.com\").\n */\n url: string;\n\n /**\n * The HTTP method to use when writing to the cache (defaults to PUT).\n */\n uploadMethod?: UploadMethod;\n\n /**\n * An optional set of HTTP headers to pass to the cache server.\n */\n headers?: Record<string, string>;\n\n /**\n * An optional command that prints the endpoint's credentials to stdout. Provide the\n * command or script to execute and, optionally, any arguments to pass to the script.\n */\n tokenHandler?: {\n exec: string;\n args?: string[];\n };\n\n /**\n * Prefix for cache keys.\n */\n cacheKeyPrefix?: string;\n\n /**\n * If set to true, allow writing to the cache. Defaults to false.\n */\n isCacheWriteAllowed?: boolean;\n}\n\n/**\n * @public\n */\nexport class RushHttpBuildCachePlugin implements IRushPlugin {\n public readonly pluginName: string = PLUGIN_NAME;\n\n public apply(rushSession: RushSession, rushConfig: RushConfiguration): void {\n rushSession.hooks.initialize.tap(this.pluginName, () => {\n rushSession.registerCloudBuildCacheProviderFactory('http', async (buildCacheConfig) => {\n const config: IRushHttpBuildCachePluginConfig = (\n buildCacheConfig as typeof buildCacheConfig & {\n httpConfiguration: IRushHttpBuildCachePluginConfig;\n }\n ).httpConfiguration;\n\n const { url, uploadMethod, headers, tokenHandler, cacheKeyPrefix, isCacheWriteAllowed } = config;\n\n const options: IHttpBuildCacheProviderOptions = {\n pluginName: this.pluginName,\n rushJsonFolder: rushConfig.rushJsonFolder,\n url: url,\n uploadMethod: uploadMethod,\n headers: headers,\n tokenHandler: tokenHandler,\n cacheKeyPrefix: cacheKeyPrefix,\n isCacheWriteAllowed: !!isCacheWriteAllowed\n };\n\n const { HttpBuildCacheProvider } = await import('./HttpBuildCacheProvider');\n return new HttpBuildCacheProvider(options, rushSession);\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.150.0",
3
+ "version": "5.152.0",
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/rush-sdk": "5.150.0",
17
- "@rushstack/node-core-library": "5.11.0"
16
+ "@rushstack/node-core-library": "5.13.0",
17
+ "@rushstack/rush-sdk": "5.152.0"
18
18
  },
19
19
  "devDependencies": {
20
- "@microsoft/rush-lib": "5.150.0",
21
- "@rushstack/heft": "0.69.1",
22
- "local-node-rig": "1.0.0",
23
- "@rushstack/terminal": "0.15.0"
20
+ "@microsoft/rush-lib": "5.152.0",
21
+ "@rushstack/terminal": "0.15.2",
22
+ "@rushstack/heft": "0.71.2",
23
+ "local-node-rig": "1.0.0"
24
24
  },
25
25
  "scripts": {
26
26
  "build": "heft build --clean",
@@ -5,7 +5,7 @@
5
5
  "pluginName": "rush-http-build-cache-plugin",
6
6
  "description": "Rush plugin for generic HTTP build cache",
7
7
  "entryPoint": "lib/index.js",
8
- "optionsSchema": "lib/schemas/plugin-config.schema.json"
8
+ "optionsSchema": "lib/schemas/http-config.schema.json"
9
9
  }
10
10
  ]
11
11
  }
package/.eslintrc.js DELETED
@@ -1,12 +0,0 @@
1
- // This is a workaround for https://github.com/eslint/eslint/issues/3458
2
- require('local-node-rig/profiles/default/includes/eslint/patch/modern-module-resolution');
3
- // This is a workaround for https://github.com/microsoft/rushstack/issues/3021
4
- require('local-node-rig/profiles/default/includes/eslint/patch/custom-config-package-names');
5
-
6
- module.exports = {
7
- extends: [
8
- 'local-node-rig/profiles/default/includes/eslint/profile/node-trusted-tool',
9
- 'local-node-rig/profiles/default/includes/eslint/mixins/friendly-locals'
10
- ],
11
- parserOptions: { tsconfigRootDir: __dirname }
12
- };
@@ -1,7 +0,0 @@
1
- {"kind":"O","text":"Invoking: heft run --only build -- --clean --production\n"}
2
- {"kind":"O","text":" ---- build started ---- \n"}
3
- {"kind":"O","text":"[build:typescript] Using TypeScript version 5.4.2\n"}
4
- {"kind":"O","text":"[build:lint] Using ESLint version 8.57.0\n"}
5
- {"kind":"O","text":"[build:typescript] Copied 1 file and linked 0 files\n"}
6
- {"kind":"O","text":" ---- build finished (10.268s) ---- \n"}
7
- {"kind":"O","text":"\u001b[1m\u001b[32m-------------------- Finished (10.274s) --------------------\u001b[39m\u001b[22m\n"}
@@ -1,15 +0,0 @@
1
- {"kind":"O","text":"Invoking: heft run --only test -- --clean --production\n"}
2
- {"kind":"O","text":"\u001b[1mThe provided list of phases does not contain all phase dependencies. You may need to run the excluded phases manually.\u001b[22m\n"}
3
- {"kind":"O","text":" ---- test started ---- \n"}
4
- {"kind":"O","text":"[test:jest] Using Jest version 29.5.0\n"}
5
- {"kind":"O","text":"[test:jest] \u001b[0m\n"}
6
- {"kind":"O","text":"[test:jest] Run start. 1 test suite\n"}
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: 1.623s, 2 passed, 0 failed)\n"}
9
- {"kind":"O","text":"[test:jest] \n"}
10
- {"kind":"O","text":"[test:jest] Tests finished:\n"}
11
- {"kind":"O","text":"[test:jest] \u001b[32m Successes: 2\u001b[39m\n"}
12
- {"kind":"O","text":"[test:jest] Failures: 0\n"}
13
- {"kind":"O","text":"[test:jest] Total: 2\n"}
14
- {"kind":"O","text":" ---- test finished (3.315s) ---- \n"}
15
- {"kind":"O","text":"\u001b[1m\u001b[32m-------------------- Finished (3.323s) --------------------\u001b[39m\u001b[22m\n"}
@@ -1,7 +0,0 @@
1
- Invoking: heft run --only build -- --clean --production
2
- ---- build started ----
3
- [build:typescript] Using TypeScript version 5.4.2
4
- [build:lint] Using ESLint version 8.57.0
5
- [build:typescript] Copied 1 file and linked 0 files
6
- ---- build finished (10.268s) ----
7
- -------------------- Finished (10.274s) --------------------
@@ -1,7 +0,0 @@
1
- {"kind":"O","text":"Invoking: heft run --only build -- --clean --production\n"}
2
- {"kind":"O","text":" ---- build started ---- \n"}
3
- {"kind":"O","text":"[build:typescript] Using TypeScript version 5.4.2\n"}
4
- {"kind":"O","text":"[build:lint] Using ESLint version 8.57.0\n"}
5
- {"kind":"O","text":"[build:typescript] Copied 1 file and linked 0 files\n"}
6
- {"kind":"O","text":" ---- build finished (10.268s) ---- \n"}
7
- {"kind":"O","text":"\u001b[1m\u001b[32m-------------------- Finished (10.274s) --------------------\u001b[39m\u001b[22m\n"}
@@ -1,3 +0,0 @@
1
- {
2
- "nonCachedDurationMs": 11203.556677000015
3
- }
@@ -1,15 +0,0 @@
1
- Invoking: heft run --only test -- --clean --production
2
- The provided list of phases does not contain all phase dependencies. You may need to run the excluded phases manually.
3
- ---- test started ----
4
- [test:jest] Using Jest version 29.5.0
5
- [test:jest]
6
- [test:jest] Run start. 1 test suite
7
- [test:jest] START lib/test/HttpBuildCacheProvider.test.js
8
- [test:jest] PASS lib/test/HttpBuildCacheProvider.test.js (duration: 1.623s, 2 passed, 0 failed)
9
- [test:jest]
10
- [test:jest] Tests finished:
11
- [test:jest] Successes: 2
12
- [test:jest] Failures: 0
13
- [test:jest] Total: 2
14
- ---- test finished (3.315s) ----
15
- -------------------- Finished (3.323s) --------------------
@@ -1,15 +0,0 @@
1
- {"kind":"O","text":"Invoking: heft run --only test -- --clean --production\n"}
2
- {"kind":"O","text":"\u001b[1mThe provided list of phases does not contain all phase dependencies. You may need to run the excluded phases manually.\u001b[22m\n"}
3
- {"kind":"O","text":" ---- test started ---- \n"}
4
- {"kind":"O","text":"[test:jest] Using Jest version 29.5.0\n"}
5
- {"kind":"O","text":"[test:jest] \u001b[0m\n"}
6
- {"kind":"O","text":"[test:jest] Run start. 1 test suite\n"}
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: 1.623s, 2 passed, 0 failed)\n"}
9
- {"kind":"O","text":"[test:jest] \n"}
10
- {"kind":"O","text":"[test:jest] Tests finished:\n"}
11
- {"kind":"O","text":"[test:jest] \u001b[32m Successes: 2\u001b[39m\n"}
12
- {"kind":"O","text":"[test:jest] Failures: 0\n"}
13
- {"kind":"O","text":"[test:jest] Total: 2\n"}
14
- {"kind":"O","text":" ---- test finished (3.315s) ---- \n"}
15
- {"kind":"O","text":"\u001b[1m\u001b[32m-------------------- Finished (3.323s) --------------------\u001b[39m\u001b[22m\n"}
@@ -1,3 +0,0 @@
1
- {
2
- "nonCachedDurationMs": 4267.00884200001
3
- }
@@ -1,32 +0,0 @@
1
- Start time: Thu Feb 27 2025 17:39:51 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-2024be7372f51761b010f9514adf1d86d16d703b-fca94d3cce304127.temp -z --files-from=-"
3
-
4
- ======= BEGIN PROCESS INPUT ======
5
- .rush/temp/operation/_phase_build/all.log
6
- .rush/temp/operation/_phase_build/log-chunks.jsonl
7
- .rush/temp/operation/_phase_build/state.json
8
- lib/HttpBuildCacheProvider.d.ts
9
- lib/HttpBuildCacheProvider.d.ts.map
10
- lib/HttpBuildCacheProvider.js
11
- lib/HttpBuildCacheProvider.js.map
12
- lib/RushHttpBuildCachePlugin.d.ts
13
- lib/RushHttpBuildCachePlugin.d.ts.map
14
- lib/RushHttpBuildCachePlugin.js
15
- lib/RushHttpBuildCachePlugin.js.map
16
- lib/index.d.ts
17
- lib/index.d.ts.map
18
- lib/index.js
19
- lib/index.js.map
20
- lib/schemas/plugin-config.schema.json
21
- lib/test/HttpBuildCacheProvider.test.d.ts
22
- lib/test/HttpBuildCacheProvider.test.d.ts.map
23
- lib/test/HttpBuildCacheProvider.test.js
24
- lib/test/HttpBuildCacheProvider.test.js.map
25
- temp/build/lint/_eslint-it73M-Rx.json
26
- temp/build/typescript/file-copy.json
27
- temp/build/typescript/ts_l9Fw4VUO.json
28
- ======== END PROCESS INPUT =======
29
- ======= BEGIN PROCESS OUTPUT =======
30
- ======== END PROCESS OUTPUT ========
31
-
32
- Exited with code "0"
@@ -1,25 +0,0 @@
1
- Start time: Thu Feb 27 2025 17:39:55 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-070a8df8efa2a6dea51faad619eb159c90c69c2c-6cdc61bdab1cc318.temp -z --files-from=-"
3
-
4
- ======= BEGIN PROCESS INPUT ======
5
- .rush/temp/operation/_phase_test/all.log
6
- .rush/temp/operation/_phase_test/log-chunks.jsonl
7
- .rush/temp/operation/_phase_test/state.json
8
- coverage/HttpBuildCacheProvider.ts.html
9
- coverage/RushHttpBuildCachePlugin.ts.html
10
- coverage/base.css
11
- coverage/block-navigation.js
12
- coverage/cobertura-coverage.xml
13
- coverage/favicon.png
14
- coverage/index.html
15
- coverage/index.ts.html
16
- coverage/junit.xml
17
- coverage/prettify.css
18
- coverage/prettify.js
19
- coverage/sort-arrow-sprite.png
20
- coverage/sorter.js
21
- ======== END PROCESS INPUT =======
22
- ======= BEGIN PROCESS OUTPUT =======
23
- ======== END PROCESS OUTPUT ========
24
-
25
- Exited with code "0"
@@ -1,9 +0,0 @@
1
- {
2
- "../../../rush-plugins/rush-http-build-cache-plugin": "../../../rush-plugins/rush-http-build-cache-plugin:c67osaye76DDfIHh56yPqMYuRdMqQpaN/fzI6wsRuHo=:",
3
- "/agent-base@6.0.2": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
4
- "/debug@4.3.4(supports-color@8.1.1)": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
5
- "/has-flag@4.0.0": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
6
- "/https-proxy-agent@5.0.1": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==",
7
- "/ms@2.1.2": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
8
- "/supports-color@8.1.1": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q=="
9
- }
@@ -1,14 +0,0 @@
1
- {
2
- "extends": "local-node-rig/profiles/default/config/jest.config.json",
3
- "clearMocks": true,
4
- "restoreMocks": true,
5
- "collectCoverage": true,
6
- "coverageThreshold": {
7
- "global": {
8
- "branches": 4,
9
- "functions": 15,
10
- "lines": 4,
11
- "statements": 4
12
- }
13
- }
14
- }
package/config/rig.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- // The "rig.json" file directs tools to look for their config files in an external package.
3
- // Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
4
- "$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",
5
-
6
- /**
7
- * (Required) The name of the rig package to inherit from.
8
- * It should be an NPM package name with the "-rig" suffix.
9
- */
10
- "rigPackageName": "local-node-rig",
11
-
12
- /**
13
- * (Optional) Selects a config profile from the rig package. The name must consist of
14
- * lowercase alphanumeric words separated by hyphens, for example "sample-profile".
15
- * If omitted, then the "default" profile will be used."
16
- */
17
- "rigProfile": "default"
18
- }