diff --git a/.changeset/short-badgers-collect.md b/.changeset/short-badgers-collect.md new file mode 100644 index 0000000000..25f5a4044f --- /dev/null +++ b/.changeset/short-badgers-collect.md @@ -0,0 +1,5 @@ +--- +'@backstage/techdocs-common': patch +--- + +AWS SDK version bump for TechDocs. diff --git a/packages/techdocs-common/__mocks__/@aws-sdk/client-s3.ts b/packages/techdocs-common/__mocks__/@aws-sdk/client-s3.ts index 8aa5f0a32b..2d2581a6cd 100644 --- a/packages/techdocs-common/__mocks__/@aws-sdk/client-s3.ts +++ b/packages/techdocs-common/__mocks__/@aws-sdk/client-s3.ts @@ -52,14 +52,10 @@ export class S3 { } headBucket() { - return new Promise(resolve => { - resolve(''); - }); + return ''; } putObject() { - return new Promise(resolve => { - resolve(''); - }); + return ''; } } diff --git a/packages/techdocs-common/src/stages/publish/awsS3.test.ts b/packages/techdocs-common/src/stages/publish/awsS3.test.ts old mode 100644 new mode 100755 index 57dec83c04..c157a7c205 --- a/packages/techdocs-common/src/stages/publish/awsS3.test.ts +++ b/packages/techdocs-common/src/stages/publish/awsS3.test.ts @@ -14,6 +14,7 @@ * limitations under the License. */ import mockFs from 'mock-fs'; +import path from 'path'; import * as winston from 'winston'; import { ConfigReader } from '@backstage/config'; import { AwsS3Publish } from './awsS3'; @@ -45,7 +46,7 @@ const getEntityRootDir = (entity: Entity) => { kind, metadata: { namespace, name }, } = entity; - const entityRootDir = `${namespace}/${kind}/${name}`; + const entityRootDir = path.join(namespace as string, kind, name); return entityRootDir; }; @@ -171,14 +172,17 @@ describe('AwsS3Publish', () => { it('should return an error if the techdocs_metadata.json file is not present', async () => { const entityNameMock = createMockEntityName(); const entity = createMockEntity(); - const entityRootDir = getEntityRootDir(entity); + const { + metadata: { name, namespace }, + kind, + } = entity; await publisher .fetchTechDocsMetadata(entityNameMock) .catch(error => expect(error).toEqual( new Error( - `TechDocs metadata fetch failed, The file ${entityRootDir}/techdocs_metadata.json doest not exist.`, + `TechDocs metadata fetch failed, The file ${namespace}/${kind}/${name}/techdocs_metadata.json doest not exist.`, ), ), ); diff --git a/packages/techdocs-common/src/stages/publish/awsS3.ts b/packages/techdocs-common/src/stages/publish/awsS3.ts index 031658bd47..b7982a9ccd 100644 --- a/packages/techdocs-common/src/stages/publish/awsS3.ts +++ b/packages/techdocs-common/src/stages/publish/awsS3.ts @@ -25,16 +25,16 @@ import fs from 'fs-extra'; import { Readable } from 'stream'; const streamToString = (stream: Readable): Promise => { - try { - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { + try { const chunks: any[] = []; stream.on('data', chunk => chunks.push(chunk)); stream.on('error', reject); stream.on('end', () => resolve(Buffer.concat(chunks).toString('utf8'))); - }); - } catch (e) { - throw new Error(`Unable to parse the response data, ${e.message}`); - } + } catch (e) { + throw new Error(`Unable to parse the response data, ${e.message}`); + } + }); }; export class AwsS3Publish implements PublisherBase {