@rushstack/rush-amazon-s3-build-cache-plugin 5.97.1 → 5.99.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.
@@ -8,6 +8,10 @@ const AmazonS3Client_1 = require("./AmazonS3Client");
8
8
  const WebClient_1 = require("./WebClient");
9
9
  const DEFAULT_S3_REGION = 'us-east-1';
10
10
  class AmazonS3BuildCacheProvider {
11
+ get isCacheWriteAllowed() {
12
+ var _a;
13
+ return (_a = rush_sdk_1.EnvironmentConfiguration.buildCacheWriteAllowed) !== null && _a !== void 0 ? _a : this._isCacheWriteAllowedByConfiguration;
14
+ }
11
15
  constructor(options, rushSession) {
12
16
  this._rushSession = rushSession;
13
17
  this._options = options;
@@ -15,10 +19,6 @@ class AmazonS3BuildCacheProvider {
15
19
  this._environmentCredential = rush_sdk_1.EnvironmentConfiguration.buildCacheCredential;
16
20
  this._isCacheWriteAllowedByConfiguration = options.isCacheWriteAllowed;
17
21
  }
18
- get isCacheWriteAllowed() {
19
- var _a;
20
- return (_a = rush_sdk_1.EnvironmentConfiguration.buildCacheWriteAllowed) !== null && _a !== void 0 ? _a : this._isCacheWriteAllowedByConfiguration;
21
- }
22
22
  get _s3Endpoint() {
23
23
  const options = this._options;
24
24
  if ('s3Bucket' in options) {
@@ -1 +1 @@
1
- {"version":3,"file":"AmazonS3BuildCacheProvider.js","sourceRoot":"","sources":["../src/AmazonS3BuildCacheProvider.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,kDAQ6B;AAE7B,qDAAwE;AACxE,2CAAwC;AA0BxC,MAAM,iBAAiB,GAAgB,WAAW,CAAC;AACnD,MAAa,0BAA0B;IAgBrC,YACE,OAA8F,EAC9F,WAAwB;QAExB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,QAAQ,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BAAgB,CAAC,mBAAmB,EAAE,CAAC;QAC/C,CAAC,CACF,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,sCAAsC,CAAC,QAAmB;QACrE,MAAM,IAAI,KAAK,CACb,0EAA0E;YACxE,4FAA4F;YAC5F,wDAAwD;YACxD,sDAAsD,CACzD,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,4BAA4B,CAAC,QAAmB;QAC3D,MAAM,0BAAe,CAAC,UAAU,CAC9B;YACE,cAAc,EAAE,IAAI;SACrB,EACD,KAAK,EAAE,gBAAiC,EAAE,EAAE;YAC1C,gBAAgB,CAAC,gBAAgB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YAC3D,MAAM,gBAAgB,CAAC,mBAAmB,EAAE,CAAC;QAC/C,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AAhLD,gEAgLC","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 { ITerminal } from '@rushstack/node-core-library';\nimport {\n ICloudBuildCacheProvider,\n ICredentialCacheEntry,\n CredentialCache,\n RushSession,\n RushConstants,\n EnvironmentVariableNames,\n EnvironmentConfiguration\n} from '@rushstack/rush-sdk';\n\nimport { AmazonS3Client, IAmazonS3Credentials } from './AmazonS3Client';\nimport { WebClient } from './WebClient';\n\n/**\n * @public\n */\nexport interface IAmazonS3BuildCacheProviderOptionsBase {\n s3Region: string;\n s3Prefix: string | undefined;\n isCacheWriteAllowed: boolean;\n}\n\n/**\n * Advanced options where user has the specify the full http endpoint\n * @public\n */\nexport interface IAmazonS3BuildCacheProviderOptionsAdvanced extends IAmazonS3BuildCacheProviderOptionsBase {\n s3Endpoint: string;\n}\n/**\n * Simple options where user only provides the bucket and the endpoint is automatically built\n * @public\n */\nexport interface IAmazonS3BuildCacheProviderOptionsSimple extends IAmazonS3BuildCacheProviderOptionsBase {\n s3Bucket: string;\n}\n\nconst DEFAULT_S3_REGION: 'us-east-1' = 'us-east-1';\nexport class AmazonS3BuildCacheProvider implements ICloudBuildCacheProvider {\n private readonly _options:\n | IAmazonS3BuildCacheProviderOptionsSimple\n | IAmazonS3BuildCacheProviderOptionsAdvanced;\n private readonly _s3Prefix: string | undefined;\n private readonly _environmentCredential: string | undefined;\n private readonly _isCacheWriteAllowedByConfiguration: boolean;\n private __credentialCacheId: string | undefined;\n private _rushSession: RushSession;\n\n public get isCacheWriteAllowed(): boolean {\n return EnvironmentConfiguration.buildCacheWriteAllowed ?? this._isCacheWriteAllowedByConfiguration;\n }\n\n private __s3Client: AmazonS3Client | undefined;\n\n public constructor(\n options: IAmazonS3BuildCacheProviderOptionsSimple | IAmazonS3BuildCacheProviderOptionsAdvanced,\n rushSession: RushSession\n ) {\n this._rushSession = rushSession;\n this._options = options;\n this._s3Prefix = options.s3Prefix;\n this._environmentCredential = EnvironmentConfiguration.buildCacheCredential;\n this._isCacheWriteAllowedByConfiguration = options.isCacheWriteAllowed;\n }\n\n private get _s3Endpoint(): string {\n const options: IAmazonS3BuildCacheProviderOptionsSimple | IAmazonS3BuildCacheProviderOptionsAdvanced =\n this._options;\n if ('s3Bucket' in options) {\n // options: IAmazonS3BuildCacheProviderOptionsSimple\n const bucket: string = options.s3Bucket;\n if (options.s3Region === DEFAULT_S3_REGION) {\n return `https://${bucket}.s3.amazonaws.com`;\n } else {\n return `https://${bucket}.s3-${options.s3Region}.amazonaws.com`;\n }\n }\n // options: IAmazonS3BuildCacheProviderOptionsAdvanced\n return options.s3Endpoint;\n }\n\n private get _credentialCacheId(): string {\n if (!this.__credentialCacheId) {\n const cacheIdParts: string[] = ['aws-s3', this._options.s3Region, this._s3Endpoint];\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 _getS3ClientAsync(terminal: ITerminal): Promise<AmazonS3Client> {\n if (!this.__s3Client) {\n let credentials: IAmazonS3Credentials | undefined = AmazonS3Client.tryDeserializeCredentials(\n this._environmentCredential\n );\n\n if (!credentials) {\n let cacheEntry: ICredentialCacheEntry | undefined;\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 throw new Error(\n 'Cached Amazon S3 credentials have expired. ' +\n `Update the credentials by running \"rush ${RushConstants.updateCloudCredentialsCommandName}\".`\n );\n } else {\n credentials = AmazonS3Client.tryDeserializeCredentials(cacheEntry?.credential);\n }\n } else if (this._isCacheWriteAllowedByConfiguration) {\n throw new Error(\n \"An Amazon S3 credential hasn't been provided, or has expired. \" +\n `Update the credentials by running \"rush ${RushConstants.updateCloudCredentialsCommandName}\", ` +\n `or provide an <AccessKeyId>:<SecretAccessKey> pair in the ` +\n `${EnvironmentVariableNames.RUSH_BUILD_CACHE_CREDENTIAL} environment variable`\n );\n }\n }\n\n this.__s3Client = new AmazonS3Client(\n credentials,\n {\n ...this._options,\n // advanced options\n s3Endpoint: this._s3Endpoint\n },\n new WebClient(),\n terminal\n );\n }\n\n return this.__s3Client;\n }\n\n public async tryGetCacheEntryBufferByIdAsync(\n terminal: ITerminal,\n cacheId: string\n ): Promise<Buffer | undefined> {\n try {\n const client: AmazonS3Client = await this._getS3ClientAsync(terminal);\n return await client.getObjectAsync(this._s3Prefix ? `${this._s3Prefix}/${cacheId}` : cacheId);\n } catch (e) {\n terminal.writeWarningLine(`Error getting cache entry from S3: ${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 S3 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 client: AmazonS3Client = await this._getS3ClientAsync(terminal);\n await client.uploadObjectAsync(this._s3Prefix ? `${this._s3Prefix}/${cacheId}` : cacheId, objectBuffer);\n return true;\n } catch (e) {\n terminal.writeWarningLine(`Error uploading cache entry to S3: ${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, { credential });\n await credentialsCache.saveIfModifiedAsync();\n }\n );\n }\n\n public async updateCachedCredentialInteractiveAsync(terminal: ITerminal): Promise<void> {\n throw new Error(\n 'The interactive cloud credentials flow is not supported for Amazon S3.\\n' +\n 'Provide your credentials to rush using the --credential flag instead. Credentials must be ' +\n 'in the form of <ACCESS KEY ID>:<SECRET ACCESS KEY> or ' +\n '<ACCESS KEY ID>:<SECRET ACCESS KEY>:<SESSION TOKEN>.'\n );\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"]}
1
+ {"version":3,"file":"AmazonS3BuildCacheProvider.js","sourceRoot":"","sources":["../src/AmazonS3BuildCacheProvider.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,kDAQ6B;AAE7B,qDAAwE;AACxE,2CAAwC;AA0BxC,MAAM,iBAAiB,GAAgB,WAAW,CAAC;AACnD,MAAa,0BAA0B;IAUrC,IAAW,mBAAmB;;QAC5B,OAAO,MAAA,mCAAwB,CAAC,sBAAsB,mCAAI,IAAI,CAAC,mCAAmC,CAAC;IACrG,CAAC;IAID,YACE,OAA8F,EAC9F,WAAwB;QAExB,IAAI,CAAC,YAAY,GAAG,WA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AAC,mBAAmB,EAAE,CAAC;QAC/C,CAAC,CACF,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,sCAAsC,CAAC,QAAmB;QACrE,MAAM,IAAI,KAAK,CACb,0EAA0E;YACxE,4FAA4F;YAC5F,wDAAwD;YACxD,sDAAsD,CACzD,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,4BAA4B,CAAC,QAAmB;QAC3D,MAAM,0BAAe,CAAC,UAAU,CAC9B;YACE,cAAc,EAAE,IAAI;SACrB,EACD,KAAK,EAAE,gBAAiC,EAAE,EAAE;YAC1C,gBAAgB,CAAC,gBAAgB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YAC3D,MAAM,gBAAgB,CAAC,mBAAmB,EAAE,CAAC;QAC/C,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AAhLD,gEAgLC","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 { ITerminal } from '@rushstack/node-core-library';\nimport {\n ICloudBuildCacheProvider,\n ICredentialCacheEntry,\n CredentialCache,\n RushSession,\n RushConstants,\n EnvironmentVariableNames,\n EnvironmentConfiguration\n} from '@rushstack/rush-sdk';\n\nimport { AmazonS3Client, IAmazonS3Credentials } from './AmazonS3Client';\nimport { WebClient } from './WebClient';\n\n/**\n * @public\n */\nexport interface IAmazonS3BuildCacheProviderOptionsBase {\n s3Region: string;\n s3Prefix: string | undefined;\n isCacheWriteAllowed: boolean;\n}\n\n/**\n * Advanced options where user has the specify the full http endpoint\n * @public\n */\nexport interface IAmazonS3BuildCacheProviderOptionsAdvanced extends IAmazonS3BuildCacheProviderOptionsBase {\n s3Endpoint: string;\n}\n/**\n * Simple options where user only provides the bucket and the endpoint is automatically built\n * @public\n */\nexport interface IAmazonS3BuildCacheProviderOptionsSimple extends IAmazonS3BuildCacheProviderOptionsBase {\n s3Bucket: string;\n}\n\nconst DEFAULT_S3_REGION: 'us-east-1' = 'us-east-1';\nexport class AmazonS3BuildCacheProvider implements ICloudBuildCacheProvider {\n private readonly _options:\n | IAmazonS3BuildCacheProviderOptionsSimple\n | IAmazonS3BuildCacheProviderOptionsAdvanced;\n private readonly _s3Prefix: string | undefined;\n private readonly _environmentCredential: string | undefined;\n private readonly _isCacheWriteAllowedByConfiguration: boolean;\n private __credentialCacheId: string | undefined;\n private _rushSession: RushSession;\n\n public get isCacheWriteAllowed(): boolean {\n return EnvironmentConfiguration.buildCacheWriteAllowed ?? this._isCacheWriteAllowedByConfiguration;\n }\n\n private __s3Client: AmazonS3Client | undefined;\n\n public constructor(\n options: IAmazonS3BuildCacheProviderOptionsSimple | IAmazonS3BuildCacheProviderOptionsAdvanced,\n rushSession: RushSession\n ) {\n this._rushSession = rushSession;\n this._options = options;\n this._s3Prefix = options.s3Prefix;\n this._environmentCredential = EnvironmentConfiguration.buildCacheCredential;\n this._isCacheWriteAllowedByConfiguration = options.isCacheWriteAllowed;\n }\n\n private get _s3Endpoint(): string {\n const options: IAmazonS3BuildCacheProviderOptionsSimple | IAmazonS3BuildCacheProviderOptionsAdvanced =\n this._options;\n if ('s3Bucket' in options) {\n // options: IAmazonS3BuildCacheProviderOptionsSimple\n const bucket: string = options.s3Bucket;\n if (options.s3Region === DEFAULT_S3_REGION) {\n return `https://${bucket}.s3.amazonaws.com`;\n } else {\n return `https://${bucket}.s3-${options.s3Region}.amazonaws.com`;\n }\n }\n // options: IAmazonS3BuildCacheProviderOptionsAdvanced\n return options.s3Endpoint;\n }\n\n private get _credentialCacheId(): string {\n if (!this.__credentialCacheId) {\n const cacheIdParts: string[] = ['aws-s3', this._options.s3Region, this._s3Endpoint];\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 _getS3ClientAsync(terminal: ITerminal): Promise<AmazonS3Client> {\n if (!this.__s3Client) {\n let credentials: IAmazonS3Credentials | undefined = AmazonS3Client.tryDeserializeCredentials(\n this._environmentCredential\n );\n\n if (!credentials) {\n let cacheEntry: ICredentialCacheEntry | undefined;\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 throw new Error(\n 'Cached Amazon S3 credentials have expired. ' +\n `Update the credentials by running \"rush ${RushConstants.updateCloudCredentialsCommandName}\".`\n );\n } else {\n credentials = AmazonS3Client.tryDeserializeCredentials(cacheEntry?.credential);\n }\n } else if (this._isCacheWriteAllowedByConfiguration) {\n throw new Error(\n \"An Amazon S3 credential hasn't been provided, or has expired. \" +\n `Update the credentials by running \"rush ${RushConstants.updateCloudCredentialsCommandName}\", ` +\n `or provide an <AccessKeyId>:<SecretAccessKey> pair in the ` +\n `${EnvironmentVariableNames.RUSH_BUILD_CACHE_CREDENTIAL} environment variable`\n );\n }\n }\n\n this.__s3Client = new AmazonS3Client(\n credentials,\n {\n ...this._options,\n // advanced options\n s3Endpoint: this._s3Endpoint\n },\n new WebClient(),\n terminal\n );\n }\n\n return this.__s3Client;\n }\n\n public async tryGetCacheEntryBufferByIdAsync(\n terminal: ITerminal,\n cacheId: string\n ): Promise<Buffer | undefined> {\n try {\n const client: AmazonS3Client = await this._getS3ClientAsync(terminal);\n return await client.getObjectAsync(this._s3Prefix ? `${this._s3Prefix}/${cacheId}` : cacheId);\n } catch (e) {\n terminal.writeWarningLine(`Error getting cache entry from S3: ${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 S3 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 client: AmazonS3Client = await this._getS3ClientAsync(terminal);\n await client.uploadObjectAsync(this._s3Prefix ? `${this._s3Prefix}/${cacheId}` : cacheId, objectBuffer);\n return true;\n } catch (e) {\n terminal.writeWarningLine(`Error uploading cache entry to S3: ${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, { credential });\n await credentialsCache.saveIfModifiedAsync();\n }\n );\n }\n\n public async updateCachedCredentialInteractiveAsync(terminal: ITerminal): Promise<void> {\n throw new Error(\n 'The interactive cloud credentials flow is not supported for Amazon S3.\\n' +\n 'Provide your credentials to rush using the --credential flag instead. Credentials must be ' +\n 'in the form of <ACCESS KEY ID>:<SECRET ACCESS KEY> or ' +\n '<ACCESS KEY ID>:<SECRET ACCESS KEY>:<SESSION TOKEN>.'\n );\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"RushAmazonS3BuildCachePlugin.d.ts","sourceRoot":"","sources":["../src/RushAmazonS3BuildCachePlugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAcvF;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;GAEG;AACH,qBAAa,4BAA6B,YAAW,WAAW;IACvD,UAAU,EAAE,MAAM,CAAe;IAEjC,KAAK,CAAC,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,GAAG,IAAI;CAoD5E"}
1
+ {"version":3,"file":"RushAmazonS3BuildCachePlugin.d.ts","sourceRoot":"","sources":["../src/RushAmazonS3BuildCachePlugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAQvF;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;GAEG;AACH,qBAAa,4BAA6B,YAAW,WAAW;IACvD,UAAU,EAAE,MAAM,CAAe;IAEjC,KAAK,CAAC,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,GAAG,IAAI;CAmD5E"}
@@ -1,10 +1,31 @@
1
1
  "use strict";
2
2
  // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
3
3
  // See LICENSE in the project root for license information.
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
17
+ }) : function(o, v) {
18
+ o["default"] = v;
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
+ };
4
27
  Object.defineProperty(exports, "__esModule", { value: true });
5
28
  exports.RushAmazonS3BuildCachePlugin = void 0;
6
- const node_core_library_1 = require("@rushstack/node-core-library");
7
- const AmazonS3BuildCacheProviderModule = node_core_library_1.Import.lazy('./AmazonS3BuildCacheProvider', require);
8
29
  const PLUGIN_NAME = 'AmazonS3BuildCachePlugin';
9
30
  /**
10
31
  * @public
@@ -15,7 +36,7 @@ class RushAmazonS3BuildCachePlugin {
15
36
  }
16
37
  apply(rushSession, rushConfig) {
17
38
  rushSession.hooks.initialize.tap(PLUGIN_NAME, () => {
18
- rushSession.registerCloudBuildCacheProviderFactory('amazon-s3', (buildCacheConfig) => {
39
+ rushSession.registerCloudBuildCacheProviderFactory('amazon-s3', async (buildCacheConfig) => {
19
40
  const { amazonS3Configuration } = buildCacheConfig;
20
41
  let options;
21
42
  const { s3Endpoint, s3Bucket, s3Region } = amazonS3Configuration;
@@ -49,7 +70,8 @@ class RushAmazonS3BuildCachePlugin {
49
70
  if (!options) {
50
71
  throw new Error('You must provide either an s3Endpoint or s3Bucket');
51
72
  }
52
- return new AmazonS3BuildCacheProviderModule.AmazonS3BuildCacheProvider(options, rushSession);
73
+ const { AmazonS3BuildCacheProvider } = await Promise.resolve().then(() => __importStar(require('./AmazonS3BuildCacheProvider')));
74
+ return new AmazonS3BuildCacheProvider(options, rushSession);
53
75
  });
54
76
  });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;iBACH;gBACD,IAAI,QAAQ,EAAE;oBACZ,OAAO,GAAG;wBACR,2CAA2C;wBAC3C,QAAQ;wBACR,QAAQ;wBACR,QAAQ;wBACR,mBAAmB;qBACpB,CAAC;iBACH;gBACD,IAAI,CAAC,OAAO,EAAE;oBACZ,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;iBACtE;gBACD,OAAO,IAAI,gCAAgC,CAAC,0BAA0B,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YAC/F,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAvDD,oEAuDC","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 { Import } from '@rushstack/node-core-library';\nimport type { IRushPlugin, RushSession, RushConfiguration } from '@rushstack/rush-sdk';\nimport type {\n AmazonS3BuildCacheProvider,\n IAmazonS3BuildCacheProviderOptionsAdvanced,\n IAmazonS3BuildCacheProviderOptionsSimple\n} from './AmazonS3BuildCacheProvider';\n\nconst AmazonS3BuildCacheProviderModule: typeof import('./AmazonS3BuildCacheProvider') = Import.lazy(\n './AmazonS3BuildCacheProvider',\n require\n);\n\nconst PLUGIN_NAME: string = 'AmazonS3BuildCachePlugin';\n\n/**\n * @public\n */\nexport interface IAmazonS3ConfigurationJson {\n /**\n * (Required unless s3Endpoint is specified) The name of the bucket to use for build cache (e.g. \"my-bucket\").\n */\n s3Bucket?: string;\n\n /**\n * (Required unless s3Bucket is specified) The Amazon S3 endpoint of the bucket to use for build cache (e.g. \"my-bucket.s3.us-east-2.amazonaws.com\" or \"http://localhost:9000\").\n */\n s3Endpoint?: string;\n\n /**\n * The Amazon S3 region of the bucket to use for build cache (e.g. \"us-east-1\").\n */\n s3Region: string;\n\n /**\n * An optional prefix (\"folder\") for cache items.\n */\n s3Prefix?: 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 RushAmazonS3BuildCachePlugin implements IRushPlugin {\n public pluginName: string = PLUGIN_NAME;\n\n public apply(rushSession: RushSession, rushConfig: RushConfiguration): void {\n rushSession.hooks.initialize.tap(PLUGIN_NAME, () => {\n rushSession.registerCloudBuildCacheProviderFactory(\n 'amazon-s3',\n (buildCacheConfig): AmazonS3BuildCacheProvider => {\n type IBuildCache = typeof buildCacheConfig & {\n amazonS3Configuration: IAmazonS3ConfigurationJson;\n };\n const { amazonS3Configuration } = buildCacheConfig as IBuildCache;\n let options:\n | IAmazonS3BuildCacheProviderOptionsAdvanced\n | IAmazonS3BuildCacheProviderOptionsSimple\n | undefined;\n const { s3Endpoint, s3Bucket, s3Region } = amazonS3Configuration;\n const s3Prefix: undefined | string = amazonS3Configuration.s3Prefix || undefined;\n const isCacheWriteAllowed: boolean = !!amazonS3Configuration.isCacheWriteAllowed;\n\n if (s3Prefix && s3Prefix[0] === '/') {\n throw new Error('s3Prefix should not have a leading /');\n }\n\n // mutually exclusive\n if (s3Bucket && s3Endpoint) {\n throw new Error('Only one of \"s3Bucket\" or \"s3Endpoint\" must be provided.');\n }\n\n if (s3Endpoint) {\n options = {\n // IAmazonS3BuildCacheProviderOptionsAdvanced\n s3Region,\n s3Endpoint,\n s3Prefix,\n isCacheWriteAllowed\n };\n }\n if (s3Bucket) {\n options = {\n // IAmazonS3BuildCacheProviderOptionsSimple\n s3Region,\n s3Bucket,\n s3Prefix,\n isCacheWriteAllowed\n };\n }\n if (!options) {\n throw new Error('You must provide either an s3Endpoint or s3Bucket');\n }\n return new AmazonS3BuildCacheProviderModule.AmazonS3BuildCacheProvider(options, rushSession);\n }\n );\n });\n }\n}\n"]}
1
+ {"version":3,"file":"RushAmazonS3BuildCachePlugin.js","sourceRoot":"","sources":["../src/RushAmazonS3BuildCachePlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAQ3D,MAAM,WAA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AG,wDAAa,8BAA8B,GAAC,CAAC;gBACpF,OAAO,IAAI,0BAA0B,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;YAC9D,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAtDD,oEAsDC","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 {\n IAmazonS3BuildCacheProviderOptionsAdvanced,\n IAmazonS3BuildCacheProviderOptionsSimple\n} from './AmazonS3BuildCacheProvider';\n\nconst PLUGIN_NAME: string = 'AmazonS3BuildCachePlugin';\n\n/**\n * @public\n */\nexport interface IAmazonS3ConfigurationJson {\n /**\n * (Required unless s3Endpoint is specified) The name of the bucket to use for build cache (e.g. \"my-bucket\").\n */\n s3Bucket?: string;\n\n /**\n * (Required unless s3Bucket is specified) The Amazon S3 endpoint of the bucket to use for build cache (e.g. \"my-bucket.s3.us-east-2.amazonaws.com\" or \"http://localhost:9000\").\n */\n s3Endpoint?: string;\n\n /**\n * The Amazon S3 region of the bucket to use for build cache (e.g. \"us-east-1\").\n */\n s3Region: string;\n\n /**\n * An optional prefix (\"folder\") for cache items.\n */\n s3Prefix?: 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 RushAmazonS3BuildCachePlugin implements IRushPlugin {\n public pluginName: string = PLUGIN_NAME;\n\n public apply(rushSession: RushSession, rushConfig: RushConfiguration): void {\n rushSession.hooks.initialize.tap(PLUGIN_NAME, () => {\n rushSession.registerCloudBuildCacheProviderFactory('amazon-s3', async (buildCacheConfig) => {\n type IBuildCache = typeof buildCacheConfig & {\n amazonS3Configuration: IAmazonS3ConfigurationJson;\n };\n const { amazonS3Configuration } = buildCacheConfig as IBuildCache;\n let options:\n | IAmazonS3BuildCacheProviderOptionsAdvanced\n | IAmazonS3BuildCacheProviderOptionsSimple\n | undefined;\n const { s3Endpoint, s3Bucket, s3Region } = amazonS3Configuration;\n const s3Prefix: undefined | string = amazonS3Configuration.s3Prefix || undefined;\n const isCacheWriteAllowed: boolean = !!amazonS3Configuration.isCacheWriteAllowed;\n\n if (s3Prefix && s3Prefix[0] === '/') {\n throw new Error('s3Prefix should not have a leading /');\n }\n\n // mutually exclusive\n if (s3Bucket && s3Endpoint) {\n throw new Error('Only one of \"s3Bucket\" or \"s3Endpoint\" must be provided.');\n }\n\n if (s3Endpoint) {\n options = {\n // IAmazonS3BuildCacheProviderOptionsAdvanced\n s3Region,\n s3Endpoint,\n s3Prefix,\n isCacheWriteAllowed\n };\n }\n if (s3Bucket) {\n options = {\n // IAmazonS3BuildCacheProviderOptionsSimple\n s3Region,\n s3Bucket,\n s3Prefix,\n isCacheWriteAllowed\n };\n }\n if (!options) {\n throw new Error('You must provide either an s3Endpoint or s3Bucket');\n }\n\n const { AmazonS3BuildCacheProvider } = await import('./AmazonS3BuildCacheProvider');\n return new AmazonS3BuildCacheProvider(options, rushSession);\n });\n });\n }\n}\n"]}
@@ -5,7 +5,7 @@ import * as fetch from 'node-fetch';
5
5
  *
6
6
  * @public
7
7
  */
8
- export declare type WebClientResponse = fetch.Response;
8
+ export type WebClientResponse = fetch.Response;
9
9
  /**
10
10
  * For use with {@link WebClient}.
11
11
  *
@@ -1 +1 @@
1
- {"version":3,"file":"WebClient.d.ts","sourceRoot":"","sources":["../src/WebClient.ts"],"names":[],"mappings":";AAaA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAMpC;;;;GAIG;AACH,oBAAY,iBAAiB,GAAG,KAAK,CAAC,QAAQ,CAAC;AAE/C;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IACrB,OAAO,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC;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,gBAAiB,SAAQ,oBAAoB;IAC5D,IAAI,EAAE,KAAK,GAAG,KAAK,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAiB,SAAQ,oBAAoB;IAC5D,IAAI,EAAE,KAAK,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,oBAAY,cAAc;IACxB,IAAI,IAAA;IACJ,MAAM,IAAA;IACN,OAAO,IAAA;CACR;AAED;;;;GAIG;AACH,qBAAa,SAAS;IACpB,SAAgB,eAAe,EAAE,KAAK,CAAC,OAAO,CAAuB;IAE9D,MAAM,EAAE,MAAM,GAAG,SAAS,CAAS;IACnC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAgE;IAE7F,KAAK,EAAE,cAAc,CAAyB;;WAIvC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,OAAO,GAAG,IAAI;IAMvE,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAOtD,UAAU,CACrB,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,GAC5C,OAAO,CAAC,iBAAiB,CAAC;CAsD9B"}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.34.4"
8
+ "packageVersion": "7.35.1"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/rush-amazon-s3-build-cache-plugin",
3
- "version": "5.97.1",
3
+ "version": "5.99.0",
4
4
  "description": "Rush plugin for Amazon S3 cloud build cache",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,23 +14,23 @@
14
14
  "dependencies": {
15
15
  "https-proxy-agent": "~5.0.0",
16
16
  "node-fetch": "2.6.7",
17
- "@rushstack/node-core-library": "3.55.2",
18
- "@rushstack/rush-sdk": "5.97.1"
17
+ "@rushstack/node-core-library": "3.59.2",
18
+ "@rushstack/rush-sdk": "5.99.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/heft-jest": "1.0.1",
22
22
  "@types/node": "14.18.36",
23
23
  "@types/node-fetch": "2.6.2",
24
- "@microsoft/rush-lib": "5.97.1",
25
- "@rushstack/eslint-config": "3.2.0",
26
- "@rushstack/heft": "0.50.0",
27
- "@rushstack/heft-node-rig": "1.12.6"
24
+ "@microsoft/rush-lib": "5.99.0",
25
+ "@rushstack/eslint-config": "3.3.0",
26
+ "@rushstack/heft": "0.51.0",
27
+ "@rushstack/heft-node-rig": "2.0.0"
28
28
  },
29
29
  "scripts": {
30
30
  "build": "heft build --clean",
31
31
  "start": "heft test --clean --watch",
32
32
  "test": "heft test",
33
- "_phase:build": "heft build --clean",
34
- "_phase:test": "heft test --no-build"
33
+ "_phase:build": "heft run --only build -- --clean",
34
+ "_phase:test": "heft run --only test -- --clean"
35
35
  }
36
36
  }