diff --git a/packages/app/package.json b/packages/app/package.json index e953838a2f..020290f55d 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -60,6 +60,7 @@ "@backstage/plugin-techdocs": "workspace:^", "@backstage/plugin-techdocs-module-addons-contrib": "workspace:^", "@backstage/plugin-techdocs-react": "workspace:^", + "@backstage/plugin-test": "^0.0.0", "@backstage/plugin-todo": "workspace:^", "@backstage/plugin-user-settings": "workspace:^", "@backstage/theme": "workspace:^", diff --git a/packages/app/src/App.tsx b/packages/app/src/App.tsx index f4a50a0902..0680cd620a 100644 --- a/packages/app/src/App.tsx +++ b/packages/app/src/App.tsx @@ -108,6 +108,7 @@ import { PlaylistIndexPage } from '@backstage/plugin-playlist'; import { TwoColumnLayout } from './components/scaffolder/customScaffolderLayouts'; import { ScoreBoardPage } from '@oriflame/backstage-plugin-score-card'; + const app = createApp({ apis, plugins: Object.values(plugins), diff --git a/packages/cli/src/lib/new/factories/index.ts b/packages/cli/src/lib/new/factories/index.ts index 80a24702e0..7900f4672f 100644 --- a/packages/cli/src/lib/new/factories/index.ts +++ b/packages/cli/src/lib/new/factories/index.ts @@ -16,6 +16,6 @@ export { frontendPlugin } from './frontendPlugin'; export { backendPlugin } from './backendPlugin'; -export { webLibraryPackage } from './webLibraryPackage'; +export { webLibrary } from './webLibrary'; export { pluginCommon } from './pluginCommon'; export { scaffolderModule } from './scaffolderModule'; diff --git a/packages/cli/src/lib/new/factories/webLibraryPackage.ts b/packages/cli/src/lib/new/factories/webLibrary.ts similarity index 94% rename from packages/cli/src/lib/new/factories/webLibraryPackage.ts rename to packages/cli/src/lib/new/factories/webLibrary.ts index 32cb2e135d..a58e9f2935 100644 --- a/packages/cli/src/lib/new/factories/webLibraryPackage.ts +++ b/packages/cli/src/lib/new/factories/webLibrary.ts @@ -31,8 +31,8 @@ type Options = { codeOwnersPath?: string; }; -export const webLibraryPackage = createFactory({ - name: 'web-library-package', +export const webLibrary = createFactory({ + name: 'web-library', description: 'A new web-library package', optionsDiscovery: async () => ({ codeOwnersPath: await getCodeownersFilePath(paths.targetRoot), @@ -42,7 +42,7 @@ export const webLibraryPackage = createFactory({ const { id } = options; const name = ctx.scope - ? `@${ctx.scope}/plugin-${id}` + ? `@${ctx.scope}/${id}` : `backstage-plugin-${id}`; const extensionName = `${upperFirst(camelCase(id))}Page`; @@ -50,7 +50,7 @@ export const webLibraryPackage = createFactory({ Task.log(`Creating web-library package ${chalk.cyan(name)}`); const targetDir = ctx.isMonoRepo - ? paths.resolveTargetRoot('plugins', id) + ? paths.resolveTargetRoot('packages', id) : paths.resolveTargetRoot(`backstage-plugin-${id}`); await executePluginPackageTemplate(ctx, { @@ -117,7 +117,7 @@ export const webLibraryPackage = createFactory({ } if (options.owner) { - await addCodeownersEntry(`/plugins/${id}`, options.owner); + await addCodeownersEntry(`/packages/${id}`, options.owner); } await Task.forCommand('yarn install', { cwd: targetDir, optional: true }); diff --git a/packages/cli/templates/web-library-package/README.md.hbs b/packages/cli/templates/web-library-package/README.md.hbs index be6116ca3a..ac18b06c04 100644 --- a/packages/cli/templates/web-library-package/README.md.hbs +++ b/packages/cli/templates/web-library-package/README.md.hbs @@ -1,14 +1,12 @@ # {{id}} -Welcome to the {{id}} web-library plugin! +_This package was created through the Backstage CLI_. -_This plugin was created through the Backstage CLI_ +## Installation -## Getting started +Install the package via Yarn: -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. +```sh +cd # if within a monorepo + yarn add @internal/{{id}} + ``` diff --git a/packages/cli/templates/web-library-package/src/index.ts.hbs b/packages/cli/templates/web-library-package/src/index.ts.hbs index be4881efaf..70c8b077df 100644 --- a/packages/cli/templates/web-library-package/src/index.ts.hbs +++ b/packages/cli/templates/web-library-package/src/index.ts.hbs @@ -1 +1,23 @@ -export { {{ pluginVar }}, {{ extensionName }} } from './plugin'; +/* +* Copyright 2020 The Backstage Authors +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/** +* Core API used by Backstage plugins +* +* @packageDocumentation +*/ + +// export as needed from this file diff --git a/packages/cli/templates/web-library-package/src/plugin.test.ts.hbs b/packages/cli/templates/web-library-package/src/plugin.test.ts.hbs deleted file mode 100644 index 9d44a9c497..0000000000 --- a/packages/cli/templates/web-library-package/src/plugin.test.ts.hbs +++ /dev/null @@ -1,7 +0,0 @@ -import { {{ pluginVar }} } from './plugin'; - -describe('{{ id }}', () => { - it('should export plugin', () => { - expect({{ pluginVar }}).toBeDefined(); - }); -}); diff --git a/packages/cli/templates/web-library-package/src/plugin.ts.hbs b/packages/cli/templates/web-library-package/src/plugin.ts.hbs deleted file mode 100644 index 86a8ed9507..0000000000 --- a/packages/cli/templates/web-library-package/src/plugin.ts.hbs +++ /dev/null @@ -1,19 +0,0 @@ -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/web-library-package/src/setupTests.ts b/packages/cli/templates/web-library-package/src/setupTests.ts index 48c09b5346..c1d649f2ad 100644 --- a/packages/cli/templates/web-library-package/src/setupTests.ts +++ b/packages/cli/templates/web-library-package/src/setupTests.ts @@ -1,2 +1,18 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import '@testing-library/jest-dom'; import 'cross-fetch/polyfill'; diff --git a/yarn.lock b/yarn.lock index 62ead1eefe..30f01f3639 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8280,6 +8280,32 @@ __metadata: languageName: unknown linkType: soft +"@backstage/plugin-test@^0.0.0, @backstage/plugin-test@workspace:plugins/test": + version: 0.0.0-use.local + resolution: "@backstage/plugin-test@workspace:plugins/test" + dependencies: + "@backstage/cli": "workspace:^" + "@backstage/core-app-api": "workspace:^" + "@backstage/core-components": "workspace:^" + "@backstage/core-plugin-api": "workspace:^" + "@backstage/dev-utils": "workspace:^" + "@backstage/test-utils": "workspace:^" + "@backstage/theme": "workspace:^" + "@material-ui/core": ^4.9.13 + "@material-ui/icons": ^4.9.1 + "@material-ui/lab": ^4.0.0-alpha.57 + "@testing-library/jest-dom": ^5.10.1 + "@testing-library/react": ^12.1.3 + "@testing-library/user-event": ^14.0.0 + "@types/node": "*" + cross-fetch: ^3.1.5 + msw: ^0.49.0 + react-use: ^17.2.4 + peerDependencies: + react: ^16.13.1 || ^17.0.0 + languageName: unknown + linkType: soft + "@backstage/plugin-todo-backend@workspace:^, @backstage/plugin-todo-backend@workspace:plugins/todo-backend": version: 0.0.0-use.local resolution: "@backstage/plugin-todo-backend@workspace:plugins/todo-backend" @@ -21987,6 +22013,7 @@ __metadata: "@backstage/plugin-techdocs": "workspace:^" "@backstage/plugin-techdocs-module-addons-contrib": "workspace:^" "@backstage/plugin-techdocs-react": "workspace:^" + "@backstage/plugin-test": ^0.0.0 "@backstage/plugin-todo": "workspace:^" "@backstage/plugin-user-settings": "workspace:^" "@backstage/test-utils": "workspace:^"