From f9c75f7a93698ce8ea8d1145aa87e66777cff978 Mon Sep 17 00:00:00 2001 From: Podge Date: Fri, 26 Mar 2021 20:13:05 +0000 Subject: [PATCH 1/3] Enable non unicode character in catalog import. replaced btoa with js-base64 so the code can gracefully handle non unicode characters. Signed-off-by: Podge --- .changeset/old-spies-love.md | 5 +++++ plugins/catalog-import/package.json | 1 + plugins/catalog-import/src/api/CatalogImportClient.ts | 3 ++- yarn.lock | 5 +++++ 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .changeset/old-spies-love.md diff --git a/.changeset/old-spies-love.md b/.changeset/old-spies-love.md new file mode 100644 index 0000000000..e02d3acb6f --- /dev/null +++ b/.changeset/old-spies-love.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-import': patch +--- + +When importing components you will now have the ability to use non unicode characters in the entity owner field diff --git a/plugins/catalog-import/package.json b/plugins/catalog-import/package.json index 044483e2ba..ee1d40a590 100644 --- a/plugins/catalog-import/package.json +++ b/plugins/catalog-import/package.json @@ -43,6 +43,7 @@ "@octokit/rest": "^18.0.12", "@types/react": "^16.9", "git-url-parse": "^11.4.4", + "js-base64": "^3.6.0", "react": "^16.13.1", "react-dom": "^16.13.1", "react-hook-form": "^6.15.4", diff --git a/plugins/catalog-import/src/api/CatalogImportClient.ts b/plugins/catalog-import/src/api/CatalogImportClient.ts index f6e8cb69d4..6dd48d2aa7 100644 --- a/plugins/catalog-import/src/api/CatalogImportClient.ts +++ b/plugins/catalog-import/src/api/CatalogImportClient.ts @@ -21,6 +21,7 @@ import { GitHubIntegrationConfig, ScmIntegrationRegistry, } from '@backstage/integration'; +import { Base64 } from 'js-base64'; import { Octokit } from '@octokit/rest'; import { PartialEntity } from '../types'; import { AnalyzeResult, CatalogImportApi } from './CatalogImportApi'; @@ -300,7 +301,7 @@ export class CatalogImportClient implements CatalogImportApi { repo, path: fileName, message: title, - content: btoa(fileContent), + content: Base64.encode(fileContent), branch: branchName, }) .catch(e => { diff --git a/yarn.lock b/yarn.lock index 88f35fd4a4..fe9f7d5c2c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16882,6 +16882,11 @@ joycon@^2.2.5: resolved "https://registry.npmjs.org/joycon/-/joycon-2.2.5.tgz#8d4cf4cbb2544d7b7583c216fcdfec19f6be1615" integrity sha512-YqvUxoOcVPnCp0VU1/56f+iKSdvIRJYPznH22BdXV3xMk75SFXhWeJkZ8C9XxUWt1b5x2X1SxuFygW1U0FmkEQ== +js-base64@^3.6.0: + version "3.6.0" + resolved "https://registry.npmjs.org/js-base64/-/js-base64-3.6.0.tgz#773e1de628f4f298d65a7e9842c50244751f5756" + integrity sha512-wVdUBYQeY2gY73RIlPrysvpYx+2vheGo8Y1SNQv/BzHToWpAZzJU7Z6uheKMAe+GLSBig5/Ps2nxg/8tRB73xg== + js-cookie@^2.2.1: version "2.2.1" resolved "https://registry.npmjs.org/js-cookie/-/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8" From 5394703c36836535223168d3ea79ed3a2be8d25b Mon Sep 17 00:00:00 2001 From: Podge Date: Sat, 27 Mar 2021 21:53:40 +0000 Subject: [PATCH 2/3] Updating spelling of unicode to Unicode Signed-off-by: Podge --- .changeset/old-spies-love.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/old-spies-love.md b/.changeset/old-spies-love.md index e02d3acb6f..722d9d937e 100644 --- a/.changeset/old-spies-love.md +++ b/.changeset/old-spies-love.md @@ -2,4 +2,4 @@ '@backstage/plugin-catalog-import': patch --- -When importing components you will now have the ability to use non unicode characters in the entity owner field +When importing components you will now have the ability to use non Unicode characters in the entity owner field From 4ddd7b264225a7fe2a6b8f682b83888b25fcca29 Mon Sep 17 00:00:00 2001 From: Podge Date: Fri, 2 Apr 2021 18:38:04 +0100 Subject: [PATCH 3/3] modifying CatalogImportClient.test.ts last test to test for a non-Latin text by adding an emoji to the file content field Signed-off-by: Podge --- plugins/catalog-import/src/api/CatalogImportClient.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/catalog-import/src/api/CatalogImportClient.test.ts b/plugins/catalog-import/src/api/CatalogImportClient.test.ts index 9d3ca8d22a..ad856bd62b 100644 --- a/plugins/catalog-import/src/api/CatalogImportClient.test.ts +++ b/plugins/catalog-import/src/api/CatalogImportClient.test.ts @@ -307,7 +307,7 @@ describe('CatalogImportClient', () => { await expect( catalogImportClient.submitPullRequest({ repositoryUrl: 'https://github.com/backstage/backstage', - fileContent: 'some content', + fileContent: 'some content 🤖', title: 'A title/message', body: 'A body', }), @@ -333,7 +333,7 @@ describe('CatalogImportClient', () => { repo: 'backstage', path: 'catalog-info.yaml', message: 'A title/message', - content: 'c29tZSBjb250ZW50', + content: 'c29tZSBjb250ZW50IPCfpJY=', branch: 'backstage-integration', }); expect(