From ce3e20403885565bc086ad7f2b7cb751f4dd0576 Mon Sep 17 00:00:00 2001 From: Kiran Date: Tue, 12 Jan 2021 02:56:05 +0000 Subject: [PATCH 1/5] fix(create-app): fix user-settings routing in create-app --- .../create-app/templates/default-app/packages/app/src/App.tsx | 2 ++ .../templates/default-app/packages/app/src/plugins.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/packages/create-app/templates/default-app/packages/app/src/App.tsx b/packages/create-app/templates/default-app/packages/app/src/App.tsx index 693e66e0c6..13880f9ee3 100644 --- a/packages/create-app/templates/default-app/packages/app/src/App.tsx +++ b/packages/create-app/templates/default-app/packages/app/src/App.tsx @@ -15,6 +15,7 @@ import { Router as DocsRouter } from '@backstage/plugin-techdocs'; import { Router as ImportComponentRouter } from '@backstage/plugin-catalog-import'; import { Router as TechRadarRouter } from '@backstage/plugin-tech-radar'; import { SearchPage as SearchRouter } from '@backstage/plugin-search'; +import { Router as SettingsRouter } from '@backstage/plugin-user-settings'; import { EntityPage } from './components/catalog/EntityPage'; @@ -59,6 +60,7 @@ const App = () => ( path="/search" element={} /> + } /> {deprecatedAppRoutes} diff --git a/packages/create-app/templates/default-app/packages/app/src/plugins.ts b/packages/create-app/templates/default-app/packages/app/src/plugins.ts index d3c9d6e2f3..28b42d5be2 100644 --- a/packages/create-app/templates/default-app/packages/app/src/plugins.ts +++ b/packages/create-app/templates/default-app/packages/app/src/plugins.ts @@ -6,3 +6,5 @@ export { plugin as GithubActions } from '@backstage/plugin-github-actions'; export { plugin as ScaffolderPlugin } from '@backstage/plugin-scaffolder'; export { plugin as TechDocsPlugin } from '@backstage/plugin-techdocs'; export { plugin as TechRadar } from '@backstage/plugin-tech-radar'; +export { plugin as UserSettings } from '@backstage/plugin-user-settings'; + From b87c7447409d018177cd185a771a114f69f3a8c3 Mon Sep 17 00:00:00 2001 From: Kiran Date: Tue, 12 Jan 2021 04:51:50 +0000 Subject: [PATCH 2/5] feat(create-app): synch backend/scaffolder.js with master --- .../backend/src/plugins/scaffolder.ts | 78 +------------------ 1 file changed, 2 insertions(+), 76 deletions(-) diff --git a/packages/create-app/templates/default-app/packages/backend/src/plugins/scaffolder.ts b/packages/create-app/templates/default-app/packages/backend/src/plugins/scaffolder.ts index 2dc69feb45..196d48ec78 100644 --- a/packages/create-app/templates/default-app/packages/backend/src/plugins/scaffolder.ts +++ b/packages/create-app/templates/default-app/packages/backend/src/plugins/scaffolder.ts @@ -1,21 +1,13 @@ import { CookieCutter, createRouter, - FilePreparer, - GithubPreparer, - GitlabPreparer, Preparers, Publishers, - GithubPublisher, - GitlabPublisher, CreateReactAppTemplater, Templaters, - RepoVisibilityOptions, CatalogEntityClient, } from '@backstage/plugin-scaffolder-backend'; import { SingleHostDiscovery } from '@backstage/backend-common'; -import { Octokit } from '@octokit/rest'; -import { Gitlab } from '@gitbeaker/node'; import type { PluginEnvironment } from '../types'; import Docker from 'dockerode'; @@ -29,74 +21,8 @@ export default async function createPlugin({ templaters.register('cookiecutter', cookiecutterTemplater); templaters.register('cra', craTemplater); - const filePreparer = new FilePreparer(); - const githubPreparer = new GithubPreparer(); - const gitlabPreparer = new GitlabPreparer(config); - const preparers = new Preparers(); - - preparers.register('file', filePreparer); - preparers.register('github', githubPreparer); - preparers.register('gitlab', gitlabPreparer); - preparers.register('gitlab/api', gitlabPreparer); - - const publishers = new Publishers(); - - const githubConfig = config.getOptionalConfig('scaffolder.github'); - - if (githubConfig) { - try { - const repoVisibility = githubConfig.getString( - 'visibility', - ) as RepoVisibilityOptions; - - const githubToken = githubConfig.getString('token'); - const githubHost = githubConfig.getOptionalString('host'); - const githubClient = new Octokit({ auth: githubToken, baseUrl: githubHost }); - const githubPublisher = new GithubPublisher({ - client: githubClient, - token: githubToken, - repoVisibility, - }); - publishers.register('file', githubPublisher); - publishers.register('github', githubPublisher); - } catch (e) { - const providerName = 'github'; - if (process.env.NODE_ENV !== 'development') { - throw new Error( - `Failed to initialize ${providerName} scaffolding provider, ${e.message}`, - ); - } - - logger.warn( - `Skipping ${providerName} scaffolding provider, ${e.message}`, - ); - } - } - - const gitLabConfig = config.getOptionalConfig('scaffolder.gitlab.api'); - if (gitLabConfig) { - try { - const gitLabToken = gitLabConfig.getString('token'); - const gitLabClient = new Gitlab({ - host: gitLabConfig.getOptionalString('baseUrl'), - token: gitLabToken, - }); - const gitLabPublisher = new GitlabPublisher(gitLabClient, gitLabToken); - publishers.register('gitlab', gitLabPublisher); - publishers.register('gitlab/api', gitLabPublisher); - } catch (e) { - const providerName = 'gitlab'; - if (process.env.NODE_ENV !== 'development') { - throw new Error( - `Failed to initialize ${providerName} scaffolding provider, ${e.message}`, - ); - } - - logger.warn( - `Skipping ${providerName} scaffolding provider, ${e.message}`, - ); - } - } + const preparers = await Preparers.fromConfig(config, { logger }); + const publishers = await Publishers.fromConfig(config, { logger }); const dockerClient = new Docker(); From 10b22d6c706a456a9f60e672c6f4a62d2e3276c2 Mon Sep 17 00:00:00 2001 From: Kiran Date: Wed, 13 Jan 2021 02:28:24 +0000 Subject: [PATCH 3/5] Revert "feat(create-app): synch backend/scaffolder.js with master" This reverts commit 087e90cf8baeeff60d4cee7d503a84a88ee87fd1. --- .../backend/src/plugins/scaffolder.ts | 78 ++++++++++++++++++- 1 file changed, 76 insertions(+), 2 deletions(-) diff --git a/packages/create-app/templates/default-app/packages/backend/src/plugins/scaffolder.ts b/packages/create-app/templates/default-app/packages/backend/src/plugins/scaffolder.ts index 196d48ec78..2dc69feb45 100644 --- a/packages/create-app/templates/default-app/packages/backend/src/plugins/scaffolder.ts +++ b/packages/create-app/templates/default-app/packages/backend/src/plugins/scaffolder.ts @@ -1,13 +1,21 @@ import { CookieCutter, createRouter, + FilePreparer, + GithubPreparer, + GitlabPreparer, Preparers, Publishers, + GithubPublisher, + GitlabPublisher, CreateReactAppTemplater, Templaters, + RepoVisibilityOptions, CatalogEntityClient, } from '@backstage/plugin-scaffolder-backend'; import { SingleHostDiscovery } from '@backstage/backend-common'; +import { Octokit } from '@octokit/rest'; +import { Gitlab } from '@gitbeaker/node'; import type { PluginEnvironment } from '../types'; import Docker from 'dockerode'; @@ -21,8 +29,74 @@ export default async function createPlugin({ templaters.register('cookiecutter', cookiecutterTemplater); templaters.register('cra', craTemplater); - const preparers = await Preparers.fromConfig(config, { logger }); - const publishers = await Publishers.fromConfig(config, { logger }); + const filePreparer = new FilePreparer(); + const githubPreparer = new GithubPreparer(); + const gitlabPreparer = new GitlabPreparer(config); + const preparers = new Preparers(); + + preparers.register('file', filePreparer); + preparers.register('github', githubPreparer); + preparers.register('gitlab', gitlabPreparer); + preparers.register('gitlab/api', gitlabPreparer); + + const publishers = new Publishers(); + + const githubConfig = config.getOptionalConfig('scaffolder.github'); + + if (githubConfig) { + try { + const repoVisibility = githubConfig.getString( + 'visibility', + ) as RepoVisibilityOptions; + + const githubToken = githubConfig.getString('token'); + const githubHost = githubConfig.getOptionalString('host'); + const githubClient = new Octokit({ auth: githubToken, baseUrl: githubHost }); + const githubPublisher = new GithubPublisher({ + client: githubClient, + token: githubToken, + repoVisibility, + }); + publishers.register('file', githubPublisher); + publishers.register('github', githubPublisher); + } catch (e) { + const providerName = 'github'; + if (process.env.NODE_ENV !== 'development') { + throw new Error( + `Failed to initialize ${providerName} scaffolding provider, ${e.message}`, + ); + } + + logger.warn( + `Skipping ${providerName} scaffolding provider, ${e.message}`, + ); + } + } + + const gitLabConfig = config.getOptionalConfig('scaffolder.gitlab.api'); + if (gitLabConfig) { + try { + const gitLabToken = gitLabConfig.getString('token'); + const gitLabClient = new Gitlab({ + host: gitLabConfig.getOptionalString('baseUrl'), + token: gitLabToken, + }); + const gitLabPublisher = new GitlabPublisher(gitLabClient, gitLabToken); + publishers.register('gitlab', gitLabPublisher); + publishers.register('gitlab/api', gitLabPublisher); + } catch (e) { + const providerName = 'gitlab'; + if (process.env.NODE_ENV !== 'development') { + throw new Error( + `Failed to initialize ${providerName} scaffolding provider, ${e.message}`, + ); + } + + logger.warn( + `Skipping ${providerName} scaffolding provider, ${e.message}`, + ); + } + } const dockerClient = new Docker(); From 5899e5ca3a9a1877e6e1b0c50c0e7ecf15966a97 Mon Sep 17 00:00:00 2001 From: Kiran Patel Date: Wed, 13 Jan 2021 16:33:39 +1100 Subject: [PATCH 4/5] fix(create-app): add changeset for user-settings routing fix --- .changeset/ninety-turtles-fix.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/ninety-turtles-fix.md diff --git a/.changeset/ninety-turtles-fix.md b/.changeset/ninety-turtles-fix.md new file mode 100644 index 0000000000..d0e16360ee --- /dev/null +++ b/.changeset/ninety-turtles-fix.md @@ -0,0 +1,5 @@ +--- +'@backstage/create-app': patch +--- + +fix routing and config for user-settings plugin From 26d3b24f3f3ffd781dfe511c63eb77f98317630e Mon Sep 17 00:00:00 2001 From: Kiran Patel Date: Sat, 16 Jan 2021 12:08:46 +1100 Subject: [PATCH 5/5] doc(create-app):enhance changelog for create-app settings routing --- .changeset/healthy-crews-remember.md | 19 +++++++++++++++++++ .changeset/ninety-turtles-fix.md | 5 ----- 2 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 .changeset/healthy-crews-remember.md delete mode 100644 .changeset/ninety-turtles-fix.md diff --git a/.changeset/healthy-crews-remember.md b/.changeset/healthy-crews-remember.md new file mode 100644 index 0000000000..c7cfdaaa6d --- /dev/null +++ b/.changeset/healthy-crews-remember.md @@ -0,0 +1,19 @@ +--- +'@backstage/create-app': patch +--- + +fix routing and config for user-settings plugin + +To make the corresponding change in your local app, add the following in your App.tsx + +``` +import { Router as SettingsRouter } from '@backstage/plugin-user-settings'; +... +} /> +``` + +and the following to your plugins.ts: + +``` +export { plugin as UserSettings } from '@backstage/plugin-user-settings'; +``` diff --git a/.changeset/ninety-turtles-fix.md b/.changeset/ninety-turtles-fix.md deleted file mode 100644 index d0e16360ee..0000000000 --- a/.changeset/ninety-turtles-fix.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@backstage/create-app': patch ---- - -fix routing and config for user-settings plugin