From 9e4fbf0ff491648b4d4b2360450e5a4fb063eb9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?MALIN=20WID=C3=88N?= Date: Mon, 21 Nov 2022 17:20:14 +0100 Subject: [PATCH 1/6] Remove some deprecations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MALIN WIDÈN --- .../src/scaffolder/actions/builtin/createBuiltinActions.ts | 5 ----- .../src/scaffolder/actions/builtin/publish/index.ts | 1 - .../components/TemplateEditorPage/DryRunContext.test.tsx | 4 ++-- .../src/components/TemplateEditorPage/DryRunContext.tsx | 6 +++--- .../DryRunResults/DryRunResultsView.test.tsx | 3 ++- 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts index e388a70f00..6f4543673f 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts @@ -45,7 +45,6 @@ import { } from './github'; import { createPublishAzureAction, - createPublishBitbucketAction, createPublishBitbucketCloudAction, createPublishBitbucketServerAction, createPublishGerritAction, @@ -142,10 +141,6 @@ export const createBuiltinActions = ( createPublishGitlabMergeRequestAction({ integrations, }), - createPublishBitbucketAction({ - integrations, - config, - }), createPublishBitbucketCloudAction({ integrations, config, diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/index.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/index.ts index a8a40ab1df..37969c18c0 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/index.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/index.ts @@ -15,7 +15,6 @@ */ export { createPublishAzureAction } from './azure'; -export { createPublishBitbucketAction } from './bitbucket'; export { createPublishBitbucketCloudAction } from './bitbucketCloud'; export { createPublishBitbucketServerAction } from './bitbucketServer'; export { createPublishGerritAction } from './gerrit'; diff --git a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunContext.test.tsx b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunContext.test.tsx index 184118914a..91fb3d934f 100644 --- a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunContext.test.tsx +++ b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunContext.test.tsx @@ -25,7 +25,7 @@ describe('base64EncodeContent', () => { it('encodes text files', () => { expect(base64EncodeContent('abc')).toBe('YWJj'); expect(base64EncodeContent('abc'.repeat(1000000))).toBe( - btoa(''), + Buffer.from('').toString('base64'), ); }); @@ -38,7 +38,7 @@ describe('base64EncodeContent', () => { ); // Triggers size check expect(base64EncodeContent('😅'.repeat(1000000))).toBe( - btoa(''), + Buffer.from('').toString('base64'), ); }); }); diff --git a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunContext.tsx b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunContext.tsx index b592e3cecd..17e077e47c 100644 --- a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunContext.tsx +++ b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunContext.tsx @@ -59,11 +59,11 @@ interface DryRunProviderProps { export function base64EncodeContent(content: string): string { if (content.length > MAX_CONTENT_SIZE) { - return btoa(''); + return Buffer.from('').toString('base64'); } try { - return btoa(content); + return Buffer.from(content).toString('base64'); } catch { const decoder = new TextEncoder(); const buffer = decoder.encode(content); @@ -74,7 +74,7 @@ export function base64EncodeContent(content: string): string { String.fromCharCode(...buffer.slice(offset, offset + CHUNK_SIZE)), ); } - return btoa(chunks.join('')); + return Buffer.from(chunks.join('')).toString('base64'); } } diff --git a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.test.tsx b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.test.tsx index bc6b5d8f6f..106ee0379f 100644 --- a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.test.tsx +++ b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.test.tsx @@ -58,7 +58,8 @@ describe('DryRunResultsView', () => { directoryContents: [ { path: 'foo.txt', - base64Content: btoa('Foo Content'), + base64Content: + Buffer.from('Foo Content').toString('base64'), executable: false, }, ], From 8a19bd7c1a0abe077bb1a115b1699db2720952ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?MALIN=20WID=C3=88N?= Date: Tue, 22 Nov 2022 14:38:15 +0100 Subject: [PATCH 2/6] add changeset to @backstage/plugin-scaffolder and @backstage/plugin-scaffolder-backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MALIN WIDÈN --- .changeset/cyan-pears-yawn.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/cyan-pears-yawn.md diff --git a/.changeset/cyan-pears-yawn.md b/.changeset/cyan-pears-yawn.md new file mode 100644 index 0000000000..d1329ce154 --- /dev/null +++ b/.changeset/cyan-pears-yawn.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-scaffolder': minor +'@backstage/plugin-scaffolder-backend': minor +--- + +Fixed deprecations in plugin/scaffolder and /plugin/scaffolder-backend From f45c3017ba3a84c9e5aa575e367bc0e921040c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?MALIN=20WID=C3=88N?= Date: Tue, 22 Nov 2022 14:48:34 +0100 Subject: [PATCH 3/6] Put back createPublishBitbucketAction in index.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MALIN WIDÈN --- .../src/scaffolder/actions/builtin/publish/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/index.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/index.ts index 37969c18c0..a8a40ab1df 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/index.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/index.ts @@ -15,6 +15,7 @@ */ export { createPublishAzureAction } from './azure'; +export { createPublishBitbucketAction } from './bitbucket'; export { createPublishBitbucketCloudAction } from './bitbucketCloud'; export { createPublishBitbucketServerAction } from './bitbucketServer'; export { createPublishGerritAction } from './gerrit'; From ddd5c87ffb49fc313d27181d8855dbd3054cb016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?MALIN=20WID=C3=88N?= Date: Tue, 22 Nov 2022 15:35:50 +0100 Subject: [PATCH 4/6] Change Buffer.from to window.btoa MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MALIN WIDÈN --- .../components/TemplateEditorPage/DryRunContext.test.tsx | 4 ++-- .../src/components/TemplateEditorPage/DryRunContext.tsx | 6 +++--- .../DryRunResults/DryRunResultsView.test.tsx | 3 +-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunContext.test.tsx b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunContext.test.tsx index 91fb3d934f..36a62f1b8a 100644 --- a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunContext.test.tsx +++ b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunContext.test.tsx @@ -25,7 +25,7 @@ describe('base64EncodeContent', () => { it('encodes text files', () => { expect(base64EncodeContent('abc')).toBe('YWJj'); expect(base64EncodeContent('abc'.repeat(1000000))).toBe( - Buffer.from('').toString('base64'), + window.btoa(''), ); }); @@ -38,7 +38,7 @@ describe('base64EncodeContent', () => { ); // Triggers size check expect(base64EncodeContent('😅'.repeat(1000000))).toBe( - Buffer.from('').toString('base64'), + window.btoa(''), ); }); }); diff --git a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunContext.tsx b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunContext.tsx index 17e077e47c..3534b62c39 100644 --- a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunContext.tsx +++ b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunContext.tsx @@ -59,11 +59,11 @@ interface DryRunProviderProps { export function base64EncodeContent(content: string): string { if (content.length > MAX_CONTENT_SIZE) { - return Buffer.from('').toString('base64'); + return window.btoa(''); } try { - return Buffer.from(content).toString('base64'); + return window.btoa(content); } catch { const decoder = new TextEncoder(); const buffer = decoder.encode(content); @@ -74,7 +74,7 @@ export function base64EncodeContent(content: string): string { String.fromCharCode(...buffer.slice(offset, offset + CHUNK_SIZE)), ); } - return Buffer.from(chunks.join('')).toString('base64'); + return window.btoa(chunks.join('')); } } diff --git a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.test.tsx b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.test.tsx index 106ee0379f..c709adfd68 100644 --- a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.test.tsx +++ b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.test.tsx @@ -58,8 +58,7 @@ describe('DryRunResultsView', () => { directoryContents: [ { path: 'foo.txt', - base64Content: - Buffer.from('Foo Content').toString('base64'), + base64Content: window.btoa('Foo Content'), executable: false, }, ], From 3bc5ee61297120e82d4084d4c0df76096c2f890b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?MALIN=20WID=C3=88N?= Date: Tue, 22 Nov 2022 15:36:53 +0100 Subject: [PATCH 5/6] Put back createPublishBitbucketAction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MALIN WIDÈN --- .../src/scaffolder/actions/builtin/createBuiltinActions.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts index 6f4543673f..e388a70f00 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/createBuiltinActions.ts @@ -45,6 +45,7 @@ import { } from './github'; import { createPublishAzureAction, + createPublishBitbucketAction, createPublishBitbucketCloudAction, createPublishBitbucketServerAction, createPublishGerritAction, @@ -141,6 +142,10 @@ export const createBuiltinActions = ( createPublishGitlabMergeRequestAction({ integrations, }), + createPublishBitbucketAction({ + integrations, + config, + }), createPublishBitbucketCloudAction({ integrations, config, From 59cb5ef9f4b91923b7c56ce97d6adca52272d00b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?MALIN=20WID=C3=88N?= Date: Tue, 22 Nov 2022 16:07:59 +0100 Subject: [PATCH 6/6] remove changeset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MALIN WIDÈN --- .changeset/cyan-pears-yawn.md | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .changeset/cyan-pears-yawn.md diff --git a/.changeset/cyan-pears-yawn.md b/.changeset/cyan-pears-yawn.md deleted file mode 100644 index d1329ce154..0000000000 --- a/.changeset/cyan-pears-yawn.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@backstage/plugin-scaffolder': minor -'@backstage/plugin-scaffolder-backend': minor ---- - -Fixed deprecations in plugin/scaffolder and /plugin/scaffolder-backend