Skip to content

Commit 72fc2c0

Browse files
committed
Minor cleanup.
1 parent 7dae22f commit 72fc2c0

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

common/reviews/api/rush-amazon-s3-build-cache-plugin.api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class AmazonS3Client {
2626
// (undocumented)
2727
uploadObjectAsync(objectName: string, objectBuffer: Buffer): Promise<void>;
2828
// (undocumented)
29-
static URIEncode(input: string): string;
29+
static UriEncode(input: string): string;
3030
}
3131

3232
// @public

rush-plugins/rush-amazon-s3-build-cache-plugin/src/AmazonS3Client.ts

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4-
import { ColorValue, IColorableSequence, ITerminal, TextAttribute } from '@rushstack/node-core-library';
4+
import { Colors, IColorableSequence, ITerminal } from '@rushstack/node-core-library';
55
import * as crypto from 'crypto';
66
import * as fetch from 'node-fetch';
77

@@ -14,7 +14,7 @@ const HOST_HEADER_NAME: 'host' = 'host';
1414
const SECURITY_TOKEN_HEADER_NAME: 'x-amz-security-token' = 'x-amz-security-token';
1515

1616
/**
17-
* Credentials for authorizaing and signing requests to an Amazon S3 endpoint.
17+
* Credentials for authorizing and signing requests to an Amazon S3 endpoint.
1818
*
1919
* @public
2020
*/
@@ -65,7 +65,7 @@ export class AmazonS3Client {
6565

6666
// https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html#create-signature-presign-entire-payload
6767
// We want to keep all slashes non encoded
68-
public static URIEncode(input: string): string {
68+
public static UriEncode(input: string): string {
6969
let output: string = '';
7070
for (let i: number = 0; i < input.length; i += 1) {
7171
const ch: string = input[i];
@@ -148,8 +148,8 @@ export class AmazonS3Client {
148148

149149
// the host can be e.g. https://s3.aws.com or http://localhost:9000
150150
const host: string = this._s3Endpoint.replace(protocolRegex, '');
151-
const canonicalUri: string = AmazonS3Client.URIEncode(`/${objectName}`);
152-
this._writeDebugLine({ text: 'Canonical URI: ', textAttributes: [TextAttribute.Bold] }, canonicalUri);
151+
const canonicalUri: string = AmazonS3Client.UriEncode(`/${objectName}`);
152+
this._writeDebugLine(Colors.bold('Canonical URI: '), canonicalUri);
153153

154154
if (this._credentials) {
155155
// Compute the authorization header. See https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html
@@ -248,14 +248,11 @@ export class AmazonS3Client {
248248

249249
const url: string = `${this._s3Endpoint}${canonicalUri}`;
250250

251-
this._writeDebugLine({
252-
text: 'Sending request to S3',
253-
textAttributes: [TextAttribute.Bold, TextAttribute.Underline]
254-
});
255-
this._writeDebugLine({ text: 'HOST: ', textAttributes: [TextAttribute.Bold] }, url);
256-
this._writeDebugLine({ text: 'Headers: ', textAttributes: [TextAttribute.Bold] });
251+
this._writeDebugLine(Colors.bold(Colors.underline('Sending request to S3')));
252+
this._writeDebugLine(Colors.bold('HOST: '), url);
253+
this._writeDebugLine(Colors.bold('Headers: '));
257254
headers.forEach((value, name) => {
258-
this._writeDebugLine({ text: `\t${name}: ${value}`, foregroundColor: ColorValue.Cyan });
255+
this._writeDebugLine(Colors.cyan(`\t${name}: ${value}`));
259256
});
260257

261258
const response: fetch.Response = await this._webClient.fetchAsync(url, webFetchOptions);

rush-plugins/rush-amazon-s3-build-cache-plugin/src/test/AmazonS3Client.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ describe('AmazonS3Client', () => {
472472
describe('URIEncode', () => {
473473
it('can encode', () => {
474474
expect(
475-
AmazonS3Client.URIEncode(
475+
AmazonS3Client.UriEncode(
476476
'/@rushstack+rush-azure-storage-build-cache-plugin-_phase_test-5d4149e2298bc927fd33355fb168e6a89ba88fa6'
477477
)
478478
).toBe(

0 commit comments

Comments
 (0)