From 0feee2b1a96302c35e5e64f07002d266ff5cd786 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 9 Apr 2020 04:36:55 +0200 Subject: [PATCH 1/5] feat: fixes #523. Remove the default export from plugins --- packages/app/src/plugins.ts | 6 +++--- plugins/home-page/src/index.ts | 2 +- plugins/home-page/src/plugin.ts | 2 +- plugins/lighthouse/src/index.ts | 2 +- plugins/lighthouse/src/plugin.ts | 2 +- plugins/welcome/src/index.ts | 2 +- plugins/welcome/src/plugin.ts | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/app/src/plugins.ts b/packages/app/src/plugins.ts index 9f72242c80fac..e1ad92c0fa8e6 100644 --- a/packages/app/src/plugins.ts +++ b/packages/app/src/plugins.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { default as HomePagePlugin } from '@backstage/plugin-home-page'; -import { default as WelcomePlugin } from '@backstage/plugin-welcome'; -import { default as LighthousePlugin } from '@backstage/plugin-lighthouse'; +import { plugin as HomePagePlugin } from '@backstage/plugin-home-page'; +import { plugin as WelcomePlugin } from '@backstage/plugin-welcome'; +import { plugin as LighthousePlugin } from '@backstage/plugin-lighthouse'; export { HomePagePlugin, WelcomePlugin, LighthousePlugin }; diff --git a/plugins/home-page/src/index.ts b/plugins/home-page/src/index.ts index 0b2dc1b524903..3a0a0fe2d3cb6 100644 --- a/plugins/home-page/src/index.ts +++ b/plugins/home-page/src/index.ts @@ -14,4 +14,4 @@ * limitations under the License. */ -export { default } from './plugin'; +export { plugin } from './plugin'; diff --git a/plugins/home-page/src/plugin.ts b/plugins/home-page/src/plugin.ts index c3b4d30fe3dcc..7de760a8491a2 100644 --- a/plugins/home-page/src/plugin.ts +++ b/plugins/home-page/src/plugin.ts @@ -17,7 +17,7 @@ import { createPlugin } from '@backstage/core'; import HomePage from 'components/HomePage'; -export default createPlugin({ +export const plugin = createPlugin({ id: 'home-page', register({ router }) { router.registerRoute('/home', HomePage); diff --git a/plugins/lighthouse/src/index.ts b/plugins/lighthouse/src/index.ts index 1ef6bc4339d28..d67bc6a864002 100644 --- a/plugins/lighthouse/src/index.ts +++ b/plugins/lighthouse/src/index.ts @@ -14,5 +14,5 @@ * limitations under the License. */ -export { default } from './plugin'; +export { plugin } from './plugin'; export * from './api'; diff --git a/plugins/lighthouse/src/plugin.ts b/plugins/lighthouse/src/plugin.ts index 4d138a8ab5e34..f8da8d84ed1a6 100644 --- a/plugins/lighthouse/src/plugin.ts +++ b/plugins/lighthouse/src/plugin.ts @@ -19,7 +19,7 @@ import AuditList from './components/AuditList'; import AuditView from './components/AuditView'; import CreateAudit from './components/CreateAudit'; -export default createPlugin({ +export const plugin = createPlugin({ id: 'lighthouse', register({ router }) { router.registerRoute('/lighthouse', AuditList); diff --git a/plugins/welcome/src/index.ts b/plugins/welcome/src/index.ts index 0b2dc1b524903..3a0a0fe2d3cb6 100644 --- a/plugins/welcome/src/index.ts +++ b/plugins/welcome/src/index.ts @@ -14,4 +14,4 @@ * limitations under the License. */ -export { default } from './plugin'; +export { plugin } from './plugin'; diff --git a/plugins/welcome/src/plugin.ts b/plugins/welcome/src/plugin.ts index 740c6d2da3a3e..fbc1d14256f34 100644 --- a/plugins/welcome/src/plugin.ts +++ b/plugins/welcome/src/plugin.ts @@ -17,7 +17,7 @@ import { createPlugin } from '@backstage/core'; import WelcomePage from 'components/WelcomePage'; -export default createPlugin({ +export const plugin = createPlugin({ id: 'welcome', register({ router, featureFlags }) { router.registerRoute('/', WelcomePage); From 0d27c0dfda8759395dde38f81437b6e3c7d188e7 Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 9 Apr 2020 04:37:06 +0200 Subject: [PATCH 2/5] chore: need to fix the import on the tests --- plugins/home-page/src/plugin.test.ts | 2 +- plugins/lighthouse/src/plugin.test.ts | 2 +- plugins/welcome/src/plugin.test.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/home-page/src/plugin.test.ts b/plugins/home-page/src/plugin.test.ts index 76c1fb7a6c6b0..aea6b90d2a633 100644 --- a/plugins/home-page/src/plugin.test.ts +++ b/plugins/home-page/src/plugin.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import plugin from './plugin'; +import { plugin } from './plugin'; describe('home-page', () => { it('should export plugin', () => { diff --git a/plugins/lighthouse/src/plugin.test.ts b/plugins/lighthouse/src/plugin.test.ts index 58ea41bd60c8e..70b1844ec2c0b 100644 --- a/plugins/lighthouse/src/plugin.test.ts +++ b/plugins/lighthouse/src/plugin.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import plugin from './plugin'; +import { plugin } from './plugin'; describe('lighthouse', () => { it('should export plugin', () => { diff --git a/plugins/welcome/src/plugin.test.ts b/plugins/welcome/src/plugin.test.ts index f935f03edb6e1..d60c73ec68870 100644 --- a/plugins/welcome/src/plugin.test.ts +++ b/plugins/welcome/src/plugin.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import plugin from './plugin'; +import { plugin } from './plugin'; describe('welcome', () => { it('should export plugin', () => { From e805eafa420ba12b9f033446c0bcfb9985381d0c Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 9 Apr 2020 04:37:15 +0200 Subject: [PATCH 3/5] feat: update the templates to default to named exports for new plugins --- packages/cli/templates/default-app/plugins/welcome/src/index.ts | 2 +- .../templates/default-app/plugins/welcome/src/plugin.test.ts | 2 +- .../cli/templates/default-app/plugins/welcome/src/plugin.ts | 2 +- packages/cli/templates/default-plugin/src/index.ts | 2 +- packages/cli/templates/default-plugin/src/plugin.test.ts.hbs | 2 +- packages/cli/templates/default-plugin/src/plugin.ts.hbs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/cli/templates/default-app/plugins/welcome/src/index.ts b/packages/cli/templates/default-app/plugins/welcome/src/index.ts index b68aea57f992f..99edba26c3f21 100644 --- a/packages/cli/templates/default-app/plugins/welcome/src/index.ts +++ b/packages/cli/templates/default-app/plugins/welcome/src/index.ts @@ -1 +1 @@ -export { default } from './plugin'; +export { plugin } from './plugin'; diff --git a/packages/cli/templates/default-app/plugins/welcome/src/plugin.test.ts b/packages/cli/templates/default-app/plugins/welcome/src/plugin.test.ts index f61dee5690852..f5bf8e68c30e2 100644 --- a/packages/cli/templates/default-app/plugins/welcome/src/plugin.test.ts +++ b/packages/cli/templates/default-app/plugins/welcome/src/plugin.test.ts @@ -1,4 +1,4 @@ -import plugin from './plugin'; +import { plugin } from './plugin'; describe('welcome', () => { it('should export plugin', () => { diff --git a/packages/cli/templates/default-app/plugins/welcome/src/plugin.ts b/packages/cli/templates/default-app/plugins/welcome/src/plugin.ts index 35ceddd65fc10..a65fad53488fe 100644 --- a/packages/cli/templates/default-app/plugins/welcome/src/plugin.ts +++ b/packages/cli/templates/default-app/plugins/welcome/src/plugin.ts @@ -1,7 +1,7 @@ import { createPlugin } from '@backstage/core'; import WelcomePage from './components/WelcomePage'; -export default createPlugin({ +export const plugin = createPlugin({ id: 'welcome', register({ router }) { router.registerRoute('/', WelcomePage); diff --git a/packages/cli/templates/default-plugin/src/index.ts b/packages/cli/templates/default-plugin/src/index.ts index 0b2dc1b524903..3a0a0fe2d3cb6 100644 --- a/packages/cli/templates/default-plugin/src/index.ts +++ b/packages/cli/templates/default-plugin/src/index.ts @@ -14,4 +14,4 @@ * limitations under the License. */ -export { default } from './plugin'; +export { plugin } from './plugin'; diff --git a/packages/cli/templates/default-plugin/src/plugin.test.ts.hbs b/packages/cli/templates/default-plugin/src/plugin.test.ts.hbs index 4e94ca5d50810..e34204c9aeda5 100644 --- a/packages/cli/templates/default-plugin/src/plugin.test.ts.hbs +++ b/packages/cli/templates/default-plugin/src/plugin.test.ts.hbs @@ -14,7 +14,7 @@ * limitations under the License. */ -import plugin from './plugin'; +import { plugin } from './plugin'; describe('{{ id }}', () => { it('should export plugin', () => { diff --git a/packages/cli/templates/default-plugin/src/plugin.ts.hbs b/packages/cli/templates/default-plugin/src/plugin.ts.hbs index bb0b93ca2542a..61d82fca533c0 100644 --- a/packages/cli/templates/default-plugin/src/plugin.ts.hbs +++ b/packages/cli/templates/default-plugin/src/plugin.ts.hbs @@ -17,7 +17,7 @@ import { createPlugin } from '@backstage/core'; import ExampleComponent from './components/ExampleComponent'; -export default createPlugin({ +export const plugin = createPlugin({ id: '{{ id }}', register({ router }) { router.registerRoute('/{{ id }}', ExampleComponent); From 6104ff9988d6094f70cc5fa9e8896c9d506ac49a Mon Sep 17 00:00:00 2001 From: blam Date: Thu, 9 Apr 2020 04:56:08 +0200 Subject: [PATCH 4/5] chore: missed one small part --- packages/cli/src/commands/create-plugin/createPlugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/commands/create-plugin/createPlugin.ts b/packages/cli/src/commands/create-plugin/createPlugin.ts index 7efb29d270b20..df8b71f619d36 100644 --- a/packages/cli/src/commands/create-plugin/createPlugin.ts +++ b/packages/cli/src/commands/create-plugin/createPlugin.ts @@ -122,7 +122,7 @@ export async function addPluginToApp(rootDir: string, pluginName: string) { .split('-') .map(name => capitalize(name)) .join(''); - const pluginImport = `import { default as ${pluginNameCapitalized} } from '${pluginPackage}';`; + const pluginImport = `import { plugin as ${pluginNameCapitalized} } from '${pluginPackage}';`; const pluginExport = `export { ${pluginNameCapitalized} };`; const pluginsFilePath = 'packages/app/src/plugins.ts'; const pluginsFile = resolvePath(rootDir, pluginsFilePath); From 72c98655f3a4f3e9df30ca7b0770337210bfb9d6 Mon Sep 17 00:00:00 2001 From: blam Date: Fri, 10 Apr 2020 01:38:35 +0200 Subject: [PATCH 5/5] chore; fixing code review commenta and fix the import path --- packages/app/src/plugins.ts | 7 +++---- .../cli/templates/default-app/packages/app/src/plugins.ts | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/app/src/plugins.ts b/packages/app/src/plugins.ts index e1ad92c0fa8e6..919ea0666bc17 100644 --- a/packages/app/src/plugins.ts +++ b/packages/app/src/plugins.ts @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { plugin as HomePagePlugin } from '@backstage/plugin-home-page'; -import { plugin as WelcomePlugin } from '@backstage/plugin-welcome'; -import { plugin as LighthousePlugin } from '@backstage/plugin-lighthouse'; -export { HomePagePlugin, WelcomePlugin, LighthousePlugin }; +export { plugin as HomePagePlugin } from '@backstage/plugin-home-page'; +export { plugin as WelcomePlugin } from '@backstage/plugin-welcome'; +export { plugin as LighthousePlugin } from '@backstage/plugin-lighthouse'; diff --git a/packages/cli/templates/default-app/packages/app/src/plugins.ts b/packages/cli/templates/default-app/packages/app/src/plugins.ts index 6639319bbd07f..000bd79f3e8dd 100644 --- a/packages/cli/templates/default-app/packages/app/src/plugins.ts +++ b/packages/cli/templates/default-app/packages/app/src/plugins.ts @@ -1 +1 @@ -export { default as WelcomePlugin } from 'plugin-welcome'; +export { plugin as WelcomePlugin } from 'plugin-welcome';