From 989c62ec504a8d028f47b4a591c8c455b8bed588 Mon Sep 17 00:00:00 2001 From: Kurt King Date: Wed, 23 Nov 2022 07:04:55 -0600 Subject: [PATCH] add more default files Signed-off-by: Kurt King --- .../default-web-library-plugin/README.md.hbs | 14 ++++++++++++++ .../package.json.hbs | 0 .../src/index.ts.hbs | 1 + .../src/plugin.test.ts.hbs | 7 +++++++ .../src/plugin.ts.hbs | 19 +++++++++++++++++++ .../default-web-library-plugin/tsconfig.json | 12 ++++++++++++ 6 files changed, 53 insertions(+) create mode 100644 packages/cli/templates/default-web-library-plugin/README.md.hbs rename packages/cli/templates/{web-library-plugin => default-web-library-plugin}/package.json.hbs (100%) create mode 100644 packages/cli/templates/default-web-library-plugin/src/index.ts.hbs create mode 100644 packages/cli/templates/default-web-library-plugin/src/plugin.test.ts.hbs create mode 100644 packages/cli/templates/default-web-library-plugin/src/plugin.ts.hbs create mode 100644 packages/cli/templates/default-web-library-plugin/tsconfig.json diff --git a/packages/cli/templates/default-web-library-plugin/README.md.hbs b/packages/cli/templates/default-web-library-plugin/README.md.hbs new file mode 100644 index 0000000000..be6116ca3a --- /dev/null +++ b/packages/cli/templates/default-web-library-plugin/README.md.hbs @@ -0,0 +1,14 @@ +# {{id}} + +Welcome to the {{id}} web-library plugin! + +_This plugin was created through the Backstage CLI_ + +## Getting started + +Your plugin has been added to the example app in this repository, meaning you'll be able to access it by running `yarn +start` in the root directory, and then navigating to [/{{id}}](http://localhost:3000/{{id}}). + +You can also serve the plugin in isolation by running `yarn start` in the plugin directory. +This method of serving the plugin provides quicker iteration speed and a faster startup and hot reloads. +It is only meant for local development, and the setup for it can be found inside the [/dev](./dev) directory. diff --git a/packages/cli/templates/web-library-plugin/package.json.hbs b/packages/cli/templates/default-web-library-plugin/package.json.hbs similarity index 100% rename from packages/cli/templates/web-library-plugin/package.json.hbs rename to packages/cli/templates/default-web-library-plugin/package.json.hbs diff --git a/packages/cli/templates/default-web-library-plugin/src/index.ts.hbs b/packages/cli/templates/default-web-library-plugin/src/index.ts.hbs new file mode 100644 index 0000000000..be4881efaf --- /dev/null +++ b/packages/cli/templates/default-web-library-plugin/src/index.ts.hbs @@ -0,0 +1 @@ +export { {{ pluginVar }}, {{ extensionName }} } from './plugin'; diff --git a/packages/cli/templates/default-web-library-plugin/src/plugin.test.ts.hbs b/packages/cli/templates/default-web-library-plugin/src/plugin.test.ts.hbs new file mode 100644 index 0000000000..9d44a9c497 --- /dev/null +++ b/packages/cli/templates/default-web-library-plugin/src/plugin.test.ts.hbs @@ -0,0 +1,7 @@ +import { {{ pluginVar }} } from './plugin'; + +describe('{{ id }}', () => { + it('should export plugin', () => { + expect({{ pluginVar }}).toBeDefined(); + }); +}); diff --git a/packages/cli/templates/default-web-library-plugin/src/plugin.ts.hbs b/packages/cli/templates/default-web-library-plugin/src/plugin.ts.hbs new file mode 100644 index 0000000000..86a8ed9507 --- /dev/null +++ b/packages/cli/templates/default-web-library-plugin/src/plugin.ts.hbs @@ -0,0 +1,19 @@ +import { createPlugin, createRoutableExtension } from '@backstage/core-plugin-api'; + +import { rootRouteRef } from './routes'; + +export const {{ pluginVar }} = createPlugin({ + id: '{{ id }}', + routes: { + root: rootRouteRef, + }, +}); + +export const {{ extensionName }} = {{ pluginVar }}.provide( + createRoutableExtension({ + name: '{{ extensionName }}', + component: () => + import('./components/ExampleComponent').then(m => m.ExampleComponent), + mountPoint: rootRouteRef, + }), +); diff --git a/packages/cli/templates/default-web-library-plugin/tsconfig.json b/packages/cli/templates/default-web-library-plugin/tsconfig.json new file mode 100644 index 0000000000..b61e496175 --- /dev/null +++ b/packages/cli/templates/default-web-library-plugin/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "@backstage/cli/config/tsconfig.json", + "include": [ + "src", + "dev" + ], + "exclude": ["node_modules"], + "compilerOptions": { + "outDir": "dist-types", + "rootDir": "." + } +}