From f087d8f47d9066d73c8568cf143f8b0cf727a95d Mon Sep 17 00:00:00 2001 From: Kurt King Date: Wed, 23 Nov 2022 06:46:44 -0600 Subject: [PATCH 01/35] add base file structure for web-library plugin Signed-off-by: Kurt King --- .../src/lib/new/factories/webLibraryPlugin.ts | 129 ++++++++++++++++++ .../web-library-plugin/package.json.hbs | 57 ++++++++ 2 files changed, 186 insertions(+) create mode 100644 packages/cli/src/lib/new/factories/webLibraryPlugin.ts create mode 100644 packages/cli/templates/web-library-plugin/package.json.hbs diff --git a/packages/cli/src/lib/new/factories/webLibraryPlugin.ts b/packages/cli/src/lib/new/factories/webLibraryPlugin.ts new file mode 100644 index 0000000000..3f6e875c08 --- /dev/null +++ b/packages/cli/src/lib/new/factories/webLibraryPlugin.ts @@ -0,0 +1,129 @@ +/* + * Copyright 2021 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 fs from 'fs-extra'; +import chalk from 'chalk'; +import camelCase from 'lodash/camelCase'; +import upperFirst from 'lodash/upperFirst'; +import { paths } from '../../paths'; +import { addCodeownersEntry, getCodeownersFilePath } from '../../codeowners'; +import { createFactory, CreateContext } from '../types'; +import { addPackageDependency, Task } from '../../tasks'; +import { ownerPrompt, pluginIdPrompt } from './common/prompts'; +import { executePluginPackageTemplate } from './common/tasks'; + +type Options = { + id: string; + owner?: string; + codeOwnersPath?: string; +}; + +export const webLibraryPlugin = createFactory({ + name: 'plugin', + description: 'A new web-library plugin', + optionsDiscovery: async () => ({ + codeOwnersPath: await getCodeownersFilePath(paths.targetRoot), + }), + optionsPrompts: [pluginIdPrompt(), ownerPrompt()], + async create(options: Options, ctx: CreateContext) { + const { id } = options; + + const name = ctx.scope + ? `@${ctx.scope}/plugin-${id}` + : `backstage-plugin-${id}`; + const extensionName = `${upperFirst(camelCase(id))}Page`; + + Task.log(); + Task.log(`Creating web-library plugin ${chalk.cyan(name)}`); + + const targetDir = ctx.isMonoRepo + ? paths.resolveTargetRoot('plugins', id) + : paths.resolveTargetRoot(`backstage-plugin-${id}`); + + await executePluginPackageTemplate(ctx, { + targetDir, + templateName: 'default-plugin', + values: { + id, + name, + extensionName, + pluginVar: `${camelCase(id)}Plugin`, + pluginVersion: ctx.defaultVersion, + privatePackage: ctx.private, + npmRegistry: ctx.npmRegistry, + }, + }); + + if (await fs.pathExists(paths.resolveTargetRoot('packages/app'))) { + await Task.forItem('app', 'adding dependency', async () => { + await addPackageDependency( + paths.resolveTargetRoot('packages/app/package.json'), + { + dependencies: { + [name]: `^${ctx.defaultVersion}`, + }, + }, + ); + }); + + await Task.forItem('app', 'adding import', async () => { + const pluginsFilePath = paths.resolveTargetRoot( + 'packages/app/src/App.tsx', + ); + if (!(await fs.pathExists(pluginsFilePath))) { + return; + } + + const content = await fs.readFile(pluginsFilePath, 'utf8'); + const revLines = content.split('\n').reverse(); + + const lastImportIndex = revLines.findIndex(line => + line.match(/ from ("|').*("|')/), + ); + const lastRouteIndex = revLines.findIndex(line => + line.match(/<\/FlatRoutes/), + ); + + if (lastImportIndex !== -1 && lastRouteIndex !== -1) { + const importLine = `import { ${extensionName} } from '${name}';`; + if (!content.includes(importLine)) { + revLines.splice(lastImportIndex, 0, importLine); + } + + const componentLine = `} />`; + if (!content.includes(componentLine)) { + const [indentation] = + revLines[lastRouteIndex + 1].match(/^\s*/) ?? []; + revLines.splice(lastRouteIndex + 1, 0, indentation + componentLine); + } + + const newContent = revLines.reverse().join('\n'); + await fs.writeFile(pluginsFilePath, newContent, 'utf8'); + } + }); + } + + if (options.owner) { + await addCodeownersEntry(`/plugins/${id}`, options.owner); + } + + await Task.forCommand('yarn install', { cwd: targetDir, optional: true }); + await Task.forCommand('yarn lint --fix', { + cwd: targetDir, + optional: true, + }); + }, +}); diff --git a/packages/cli/templates/web-library-plugin/package.json.hbs b/packages/cli/templates/web-library-plugin/package.json.hbs new file mode 100644 index 0000000000..c60ba63f2b --- /dev/null +++ b/packages/cli/templates/web-library-plugin/package.json.hbs @@ -0,0 +1,57 @@ +{ + "name": "{{name}}", + "version": "{{pluginVersion}}", + "main": "src/index.ts", + "types": "src/index.ts", + "license": "Apache-2.0", +{{#if privatePackage}} + "private": {{privatePackage}}, +{{/if}} + "publishConfig": { +{{#if npmRegistry}} + "registry": "{{npmRegistry}}", +{{/if}} + "access": "public", + "main": "dist/index.esm.js", + "types": "dist/index.d.ts" + }, + "backstage": { + "role": "frontend-plugin" + }, + "scripts": { + "start": "backstage-cli package start", + "build": "backstage-cli package build", + "lint": "backstage-cli package lint", + "test": "backstage-cli package test", + "clean": "backstage-cli package clean", + "prepack": "backstage-cli package prepack", + "postpack": "backstage-cli package postpack" + }, + "dependencies": { + "@backstage/core-components": "{{versionQuery '@backstage/core-components'}}", + "@backstage/core-plugin-api": "{{versionQuery '@backstage/core-plugin-api'}}", + "@backstage/theme": "{{versionQuery '@backstage/theme'}}", + "@material-ui/core": "{{versionQuery '@material-ui/core' '4.12.2'}}", + "@material-ui/icons": "{{versionQuery '@material-ui/icons' '4.9.1'}}", + "@material-ui/lab": "{{versionQuery '@material-ui/lab' '4.0.0-alpha.57'}}", + "react-use": "{{versionQuery 'react-use' '17.2.4'}}" + }, + "peerDependencies": { + "react": "{{versionQuery 'react' '^16.13.1 || ^17.0.0'}}" + }, + "devDependencies": { + "@backstage/cli": "{{versionQuery '@backstage/cli'}}", + "@backstage/core-app-api": "{{versionQuery '@backstage/core-app-api'}}", + "@backstage/dev-utils": "{{versionQuery '@backstage/dev-utils'}}", + "@backstage/test-utils": "{{versionQuery '@backstage/test-utils'}}", + "@testing-library/jest-dom": "{{versionQuery '@testing-library/jest-dom' '5.10.1'}}", + "@testing-library/react": "{{versionQuery '@testing-library/react' '12.1.3'}}", + "@testing-library/user-event": "{{versionQuery '@testing-library/user-event' '14.0.0'}}", + "@types/node": "{{versionQuery '@types/node' '16.11.26'}}", + "msw": "{{versionQuery 'msw' '0.47.0'}}", + "cross-fetch": "{{versionQuery 'cross-fetch' '3.1.5'}}" + }, + "files": [ + "dist" + ] +} From 989c62ec504a8d028f47b4a591c8c455b8bed588 Mon Sep 17 00:00:00 2001 From: Kurt King Date: Wed, 23 Nov 2022 07:04:55 -0600 Subject: [PATCH 02/35] 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": "." + } +} From 77a854785985f2cc63a55393dd37d2cc90d3eb9a Mon Sep 17 00:00:00 2001 From: Kurt King Date: Wed, 23 Nov 2022 07:07:05 -0600 Subject: [PATCH 03/35] update role to web-library Signed-off-by: Kurt King --- .../cli/templates/default-web-library-plugin/package.json.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/templates/default-web-library-plugin/package.json.hbs b/packages/cli/templates/default-web-library-plugin/package.json.hbs index c60ba63f2b..666b3859e3 100644 --- a/packages/cli/templates/default-web-library-plugin/package.json.hbs +++ b/packages/cli/templates/default-web-library-plugin/package.json.hbs @@ -16,7 +16,7 @@ "types": "dist/index.d.ts" }, "backstage": { - "role": "frontend-plugin" + "role": "web-library" }, "scripts": { "start": "backstage-cli package start", From f98dd32d5cd106946d9930860c5c9b9d40ed9eff Mon Sep 17 00:00:00 2001 From: Kurt King Date: Thu, 24 Nov 2022 10:34:46 -0600 Subject: [PATCH 04/35] add setupTests Signed-off-by: Kurt King --- .../cli/templates/default-web-library-plugin/src/setupTests.ts | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 packages/cli/templates/default-web-library-plugin/src/setupTests.ts diff --git a/packages/cli/templates/default-web-library-plugin/src/setupTests.ts b/packages/cli/templates/default-web-library-plugin/src/setupTests.ts new file mode 100644 index 0000000000..48c09b5346 --- /dev/null +++ b/packages/cli/templates/default-web-library-plugin/src/setupTests.ts @@ -0,0 +1,2 @@ +import '@testing-library/jest-dom'; +import 'cross-fetch/polyfill'; From d2553e630b9a0768db16944baf5ac20679858aab Mon Sep 17 00:00:00 2001 From: Kurt King Date: Thu, 24 Nov 2022 10:35:40 -0600 Subject: [PATCH 05/35] add webLibrayPlugin export to index file Signed-off-by: Kurt King --- packages/cli/src/lib/new/factories/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/cli/src/lib/new/factories/index.ts b/packages/cli/src/lib/new/factories/index.ts index 0764d33e2c..f9fb77c994 100644 --- a/packages/cli/src/lib/new/factories/index.ts +++ b/packages/cli/src/lib/new/factories/index.ts @@ -16,5 +16,6 @@ export { frontendPlugin } from './frontendPlugin'; export { backendPlugin } from './backendPlugin'; +export { webLibraryPlugin } from './webLibraryPlugin'; export { pluginCommon } from './pluginCommon'; export { scaffolderModule } from './scaffolderModule'; From b935b6206dbc918d3f68b6afaf952b923f35e336 Mon Sep 17 00:00:00 2001 From: Kurt King Date: Thu, 24 Nov 2022 11:04:39 -0600 Subject: [PATCH 06/35] update web library factory Signed-off-by: Kurt King --- packages/cli/src/lib/new/factories/webLibraryPlugin.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/lib/new/factories/webLibraryPlugin.ts b/packages/cli/src/lib/new/factories/webLibraryPlugin.ts index 3f6e875c08..162dd72fa2 100644 --- a/packages/cli/src/lib/new/factories/webLibraryPlugin.ts +++ b/packages/cli/src/lib/new/factories/webLibraryPlugin.ts @@ -32,7 +32,7 @@ type Options = { }; export const webLibraryPlugin = createFactory({ - name: 'plugin', + name: 'web-library-plugin', description: 'A new web-library plugin', optionsDiscovery: async () => ({ codeOwnersPath: await getCodeownersFilePath(paths.targetRoot), @@ -55,7 +55,7 @@ export const webLibraryPlugin = createFactory({ await executePluginPackageTemplate(ctx, { targetDir, - templateName: 'default-plugin', + templateName: 'default-web-library-plugin', values: { id, name, From b3322504215106548edd553b7c7a8e0f8344c07c Mon Sep 17 00:00:00 2001 From: Kurt King Date: Mon, 28 Nov 2022 12:40:25 -0600 Subject: [PATCH 07/35] rename to web-library-package Signed-off-by: Kurt King --- .../{webLibraryPlugin.ts => webLibraryPackage.ts} | 8 ++++---- packages/cli/templates/web-library-package/.eslintrc.js | 1 + .../README.md.hbs | 0 .../package.json.hbs | 0 .../src/index.ts.hbs | 0 .../src/plugin.test.ts.hbs | 0 .../src/plugin.ts.hbs | 0 .../src/setupTests.ts | 0 .../tsconfig.json | 0 9 files changed, 5 insertions(+), 4 deletions(-) rename packages/cli/src/lib/new/factories/{webLibraryPlugin.ts => webLibraryPackage.ts} (95%) create mode 100644 packages/cli/templates/web-library-package/.eslintrc.js rename packages/cli/templates/{default-web-library-plugin => web-library-package}/README.md.hbs (100%) rename packages/cli/templates/{default-web-library-plugin => web-library-package}/package.json.hbs (100%) rename packages/cli/templates/{default-web-library-plugin => web-library-package}/src/index.ts.hbs (100%) rename packages/cli/templates/{default-web-library-plugin => web-library-package}/src/plugin.test.ts.hbs (100%) rename packages/cli/templates/{default-web-library-plugin => web-library-package}/src/plugin.ts.hbs (100%) rename packages/cli/templates/{default-web-library-plugin => web-library-package}/src/setupTests.ts (100%) rename packages/cli/templates/{default-web-library-plugin => web-library-package}/tsconfig.json (100%) diff --git a/packages/cli/src/lib/new/factories/webLibraryPlugin.ts b/packages/cli/src/lib/new/factories/webLibraryPackage.ts similarity index 95% rename from packages/cli/src/lib/new/factories/webLibraryPlugin.ts rename to packages/cli/src/lib/new/factories/webLibraryPackage.ts index 162dd72fa2..097a3af685 100644 --- a/packages/cli/src/lib/new/factories/webLibraryPlugin.ts +++ b/packages/cli/src/lib/new/factories/webLibraryPackage.ts @@ -32,8 +32,8 @@ type Options = { }; export const webLibraryPlugin = createFactory({ - name: 'web-library-plugin', - description: 'A new web-library plugin', + name: 'web-library-package', + description: 'A new web-library package', optionsDiscovery: async () => ({ codeOwnersPath: await getCodeownersFilePath(paths.targetRoot), }), @@ -47,7 +47,7 @@ export const webLibraryPlugin = createFactory({ const extensionName = `${upperFirst(camelCase(id))}Page`; Task.log(); - Task.log(`Creating web-library plugin ${chalk.cyan(name)}`); + Task.log(`Creating web-library package ${chalk.cyan(name)}`); const targetDir = ctx.isMonoRepo ? paths.resolveTargetRoot('plugins', id) @@ -55,7 +55,7 @@ export const webLibraryPlugin = createFactory({ await executePluginPackageTemplate(ctx, { targetDir, - templateName: 'default-web-library-plugin', + templateName: 'web-library-package', values: { id, name, diff --git a/packages/cli/templates/web-library-package/.eslintrc.js b/packages/cli/templates/web-library-package/.eslintrc.js new file mode 100644 index 0000000000..e2a53a6ad2 --- /dev/null +++ b/packages/cli/templates/web-library-package/.eslintrc.js @@ -0,0 +1 @@ +module.exports = require('@backstage/cli/config/eslint-factory')(__dirname); diff --git a/packages/cli/templates/default-web-library-plugin/README.md.hbs b/packages/cli/templates/web-library-package/README.md.hbs similarity index 100% rename from packages/cli/templates/default-web-library-plugin/README.md.hbs rename to packages/cli/templates/web-library-package/README.md.hbs diff --git a/packages/cli/templates/default-web-library-plugin/package.json.hbs b/packages/cli/templates/web-library-package/package.json.hbs similarity index 100% rename from packages/cli/templates/default-web-library-plugin/package.json.hbs rename to packages/cli/templates/web-library-package/package.json.hbs diff --git a/packages/cli/templates/default-web-library-plugin/src/index.ts.hbs b/packages/cli/templates/web-library-package/src/index.ts.hbs similarity index 100% rename from packages/cli/templates/default-web-library-plugin/src/index.ts.hbs rename to packages/cli/templates/web-library-package/src/index.ts.hbs diff --git a/packages/cli/templates/default-web-library-plugin/src/plugin.test.ts.hbs b/packages/cli/templates/web-library-package/src/plugin.test.ts.hbs similarity index 100% rename from packages/cli/templates/default-web-library-plugin/src/plugin.test.ts.hbs rename to packages/cli/templates/web-library-package/src/plugin.test.ts.hbs diff --git a/packages/cli/templates/default-web-library-plugin/src/plugin.ts.hbs b/packages/cli/templates/web-library-package/src/plugin.ts.hbs similarity index 100% rename from packages/cli/templates/default-web-library-plugin/src/plugin.ts.hbs rename to packages/cli/templates/web-library-package/src/plugin.ts.hbs diff --git a/packages/cli/templates/default-web-library-plugin/src/setupTests.ts b/packages/cli/templates/web-library-package/src/setupTests.ts similarity index 100% rename from packages/cli/templates/default-web-library-plugin/src/setupTests.ts rename to packages/cli/templates/web-library-package/src/setupTests.ts diff --git a/packages/cli/templates/default-web-library-plugin/tsconfig.json b/packages/cli/templates/web-library-package/tsconfig.json similarity index 100% rename from packages/cli/templates/default-web-library-plugin/tsconfig.json rename to packages/cli/templates/web-library-package/tsconfig.json From b063ad50c2aa9319b24cd859b7b680aa5acf10ec Mon Sep 17 00:00:00 2001 From: Kurt King Date: Mon, 28 Nov 2022 12:44:16 -0600 Subject: [PATCH 08/35] rename export to webLibraryPackage Signed-off-by: Kurt King --- packages/cli/src/lib/new/factories/index.ts | 2 +- packages/cli/src/lib/new/factories/webLibraryPackage.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/lib/new/factories/index.ts b/packages/cli/src/lib/new/factories/index.ts index f9fb77c994..80a24702e0 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 { webLibraryPlugin } from './webLibraryPlugin'; +export { webLibraryPackage } from './webLibraryPackage'; 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/webLibraryPackage.ts index 097a3af685..32cb2e135d 100644 --- a/packages/cli/src/lib/new/factories/webLibraryPackage.ts +++ b/packages/cli/src/lib/new/factories/webLibraryPackage.ts @@ -31,7 +31,7 @@ type Options = { codeOwnersPath?: string; }; -export const webLibraryPlugin = createFactory({ +export const webLibraryPackage = createFactory({ name: 'web-library-package', description: 'A new web-library package', optionsDiscovery: async () => ({ From b028a2a2289f3f75b967aaca26a91682afa25031 Mon Sep 17 00:00:00 2001 From: Kurt King Date: Tue, 6 Dec 2022 07:49:16 -0600 Subject: [PATCH 09/35] update default web-library files Signed-off-by: Kurt King Signed-off-by: Kurt King --- packages/app/package.json | 1 + packages/app/src/App.tsx | 1 + packages/cli/src/lib/new/factories/index.ts | 2 +- .../{webLibraryPackage.ts => webLibrary.ts} | 10 +++---- .../web-library-package/README.md.hbs | 16 +++++------ .../web-library-package/src/index.ts.hbs | 24 ++++++++++++++++- .../src/plugin.test.ts.hbs | 7 ----- .../web-library-package/src/plugin.ts.hbs | 19 ------------- .../web-library-package/src/setupTests.ts | 16 +++++++++++ yarn.lock | 27 +++++++++++++++++++ 10 files changed, 81 insertions(+), 42 deletions(-) rename packages/cli/src/lib/new/factories/{webLibraryPackage.ts => webLibrary.ts} (94%) delete mode 100644 packages/cli/templates/web-library-package/src/plugin.test.ts.hbs delete mode 100644 packages/cli/templates/web-library-package/src/plugin.ts.hbs 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:^" From 9ddf68ff12204c938f36e467f6bb381989ba758e Mon Sep 17 00:00:00 2001 From: Kurt King Date: Tue, 6 Dec 2022 08:27:00 -0600 Subject: [PATCH 10/35] remove unused test imports Signed-off-by: Kurt King Signed-off-by: Kurt King --- packages/app/package.json | 1 - yarn.lock | 27 --------------------------- 2 files changed, 28 deletions(-) diff --git a/packages/app/package.json b/packages/app/package.json index 020290f55d..e953838a2f 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -60,7 +60,6 @@ "@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/yarn.lock b/yarn.lock index 30f01f3639..62ead1eefe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8280,32 +8280,6 @@ __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" @@ -22013,7 +21987,6 @@ __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:^" From 34ddb3bb67d062af1d878ff743a4f012a0fd41d5 Mon Sep 17 00:00:00 2001 From: Kurt King Date: Tue, 6 Dec 2022 08:33:32 -0600 Subject: [PATCH 11/35] remove new line Signed-off-by: Kurt King Signed-off-by: Kurt King --- packages/app/src/App.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/app/src/App.tsx b/packages/app/src/App.tsx index 0680cd620a..f4a50a0902 100644 --- a/packages/app/src/App.tsx +++ b/packages/app/src/App.tsx @@ -108,7 +108,6 @@ 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), From c2faab650cd2dcb0b6514e9e6aae614e450a9e30 Mon Sep 17 00:00:00 2001 From: Kurt King Date: Tue, 6 Dec 2022 08:41:21 -0600 Subject: [PATCH 12/35] remove adding to packages/app Signed-off-by: Kurt King Signed-off-by: Kurt King --- .../cli/src/lib/new/factories/webLibrary.ts | 56 +------------------ .../web-library-package/package.json.hbs | 15 ----- 2 files changed, 2 insertions(+), 69 deletions(-) diff --git a/packages/cli/src/lib/new/factories/webLibrary.ts b/packages/cli/src/lib/new/factories/webLibrary.ts index a58e9f2935..b0010c377d 100644 --- a/packages/cli/src/lib/new/factories/webLibrary.ts +++ b/packages/cli/src/lib/new/factories/webLibrary.ts @@ -14,14 +14,13 @@ * limitations under the License. */ -import fs from 'fs-extra'; import chalk from 'chalk'; import camelCase from 'lodash/camelCase'; import upperFirst from 'lodash/upperFirst'; import { paths } from '../../paths'; import { addCodeownersEntry, getCodeownersFilePath } from '../../codeowners'; import { createFactory, CreateContext } from '../types'; -import { addPackageDependency, Task } from '../../tasks'; +import { Task } from '../../tasks'; import { ownerPrompt, pluginIdPrompt } from './common/prompts'; import { executePluginPackageTemplate } from './common/tasks'; @@ -41,9 +40,7 @@ export const webLibrary = createFactory({ async create(options: Options, ctx: CreateContext) { const { id } = options; - const name = ctx.scope - ? `@${ctx.scope}/${id}` - : `backstage-plugin-${id}`; + const name = ctx.scope ? `@${ctx.scope}/${id}` : `backstage-plugin-${id}`; const extensionName = `${upperFirst(camelCase(id))}Page`; Task.log(); @@ -67,55 +64,6 @@ export const webLibrary = createFactory({ }, }); - if (await fs.pathExists(paths.resolveTargetRoot('packages/app'))) { - await Task.forItem('app', 'adding dependency', async () => { - await addPackageDependency( - paths.resolveTargetRoot('packages/app/package.json'), - { - dependencies: { - [name]: `^${ctx.defaultVersion}`, - }, - }, - ); - }); - - await Task.forItem('app', 'adding import', async () => { - const pluginsFilePath = paths.resolveTargetRoot( - 'packages/app/src/App.tsx', - ); - if (!(await fs.pathExists(pluginsFilePath))) { - return; - } - - const content = await fs.readFile(pluginsFilePath, 'utf8'); - const revLines = content.split('\n').reverse(); - - const lastImportIndex = revLines.findIndex(line => - line.match(/ from ("|').*("|')/), - ); - const lastRouteIndex = revLines.findIndex(line => - line.match(/<\/FlatRoutes/), - ); - - if (lastImportIndex !== -1 && lastRouteIndex !== -1) { - const importLine = `import { ${extensionName} } from '${name}';`; - if (!content.includes(importLine)) { - revLines.splice(lastImportIndex, 0, importLine); - } - - const componentLine = `} />`; - if (!content.includes(componentLine)) { - const [indentation] = - revLines[lastRouteIndex + 1].match(/^\s*/) ?? []; - revLines.splice(lastRouteIndex + 1, 0, indentation + componentLine); - } - - const newContent = revLines.reverse().join('\n'); - await fs.writeFile(pluginsFilePath, newContent, 'utf8'); - } - }); - } - if (options.owner) { await addCodeownersEntry(`/packages/${id}`, options.owner); } diff --git a/packages/cli/templates/web-library-package/package.json.hbs b/packages/cli/templates/web-library-package/package.json.hbs index 666b3859e3..d364dba9e1 100644 --- a/packages/cli/templates/web-library-package/package.json.hbs +++ b/packages/cli/templates/web-library-package/package.json.hbs @@ -27,29 +27,14 @@ "prepack": "backstage-cli package prepack", "postpack": "backstage-cli package postpack" }, - "dependencies": { - "@backstage/core-components": "{{versionQuery '@backstage/core-components'}}", - "@backstage/core-plugin-api": "{{versionQuery '@backstage/core-plugin-api'}}", - "@backstage/theme": "{{versionQuery '@backstage/theme'}}", - "@material-ui/core": "{{versionQuery '@material-ui/core' '4.12.2'}}", - "@material-ui/icons": "{{versionQuery '@material-ui/icons' '4.9.1'}}", - "@material-ui/lab": "{{versionQuery '@material-ui/lab' '4.0.0-alpha.57'}}", - "react-use": "{{versionQuery 'react-use' '17.2.4'}}" - }, "peerDependencies": { "react": "{{versionQuery 'react' '^16.13.1 || ^17.0.0'}}" }, "devDependencies": { "@backstage/cli": "{{versionQuery '@backstage/cli'}}", - "@backstage/core-app-api": "{{versionQuery '@backstage/core-app-api'}}", - "@backstage/dev-utils": "{{versionQuery '@backstage/dev-utils'}}", - "@backstage/test-utils": "{{versionQuery '@backstage/test-utils'}}", "@testing-library/jest-dom": "{{versionQuery '@testing-library/jest-dom' '5.10.1'}}", "@testing-library/react": "{{versionQuery '@testing-library/react' '12.1.3'}}", "@testing-library/user-event": "{{versionQuery '@testing-library/user-event' '14.0.0'}}", - "@types/node": "{{versionQuery '@types/node' '16.11.26'}}", - "msw": "{{versionQuery 'msw' '0.47.0'}}", - "cross-fetch": "{{versionQuery 'cross-fetch' '3.1.5'}}" }, "files": [ "dist" From c27eabef6b92256a1f4f24dc36b3b1421796e0fd Mon Sep 17 00:00:00 2001 From: Kurt King Date: Tue, 6 Dec 2022 08:46:11 -0600 Subject: [PATCH 13/35] add changeset Signed-off-by: Kurt King Signed-off-by: Kurt King --- .changeset/nice-hairs-lick.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/nice-hairs-lick.md diff --git a/.changeset/nice-hairs-lick.md b/.changeset/nice-hairs-lick.md new file mode 100644 index 0000000000..0512b61c7b --- /dev/null +++ b/.changeset/nice-hairs-lick.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': minor +--- + +Adds new web-library package option when generating a new plugin From e9dd1f756bf81b7f51ba9f0f594ebc7b8e1e5fac Mon Sep 17 00:00:00 2001 From: Kurt King Date: Tue, 6 Dec 2022 09:22:12 -0600 Subject: [PATCH 14/35] update default files for web-library-package Signed-off-by: Kurt King Signed-off-by: Kurt King --- packages/cli/src/lib/new/factories/index.ts | 2 +- .../new/factories/{webLibrary.ts => webLibraryPackage.ts} | 2 +- packages/cli/templates/web-library-package/package.json.hbs | 5 +++-- packages/cli/templates/web-library-package/src/index.ts.hbs | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) rename packages/cli/src/lib/new/factories/{webLibrary.ts => webLibraryPackage.ts} (97%) diff --git a/packages/cli/src/lib/new/factories/index.ts b/packages/cli/src/lib/new/factories/index.ts index 7900f4672f..80a24702e0 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 { webLibrary } from './webLibrary'; +export { webLibraryPackage } from './webLibraryPackage'; export { pluginCommon } from './pluginCommon'; export { scaffolderModule } from './scaffolderModule'; diff --git a/packages/cli/src/lib/new/factories/webLibrary.ts b/packages/cli/src/lib/new/factories/webLibraryPackage.ts similarity index 97% rename from packages/cli/src/lib/new/factories/webLibrary.ts rename to packages/cli/src/lib/new/factories/webLibraryPackage.ts index b0010c377d..52c1a68aa2 100644 --- a/packages/cli/src/lib/new/factories/webLibrary.ts +++ b/packages/cli/src/lib/new/factories/webLibraryPackage.ts @@ -30,7 +30,7 @@ type Options = { codeOwnersPath?: string; }; -export const webLibrary = createFactory({ +export const webLibraryPackage = createFactory({ name: 'web-library', description: 'A new web-library package', optionsDiscovery: async () => ({ diff --git a/packages/cli/templates/web-library-package/package.json.hbs b/packages/cli/templates/web-library-package/package.json.hbs index d364dba9e1..95608c97e7 100644 --- a/packages/cli/templates/web-library-package/package.json.hbs +++ b/packages/cli/templates/web-library-package/package.json.hbs @@ -32,9 +32,10 @@ }, "devDependencies": { "@backstage/cli": "{{versionQuery '@backstage/cli'}}", + "@backstage/test-utils": "{{versionQuery '@backstage/test-utils'}}", "@testing-library/jest-dom": "{{versionQuery '@testing-library/jest-dom' '5.10.1'}}", - "@testing-library/react": "{{versionQuery '@testing-library/react' '12.1.3'}}", - "@testing-library/user-event": "{{versionQuery '@testing-library/user-event' '14.0.0'}}", + "msw": "{{versionQuery 'msw' '0.47.0'}}", + "cross-fetch": "{{versionQuery 'cross-fetch' '3.1.5'}}" }, "files": [ "dist" 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 70c8b077df..361e389fef 100644 --- a/packages/cli/templates/web-library-package/src/index.ts.hbs +++ b/packages/cli/templates/web-library-package/src/index.ts.hbs @@ -20,4 +20,4 @@ * @packageDocumentation */ -// export as needed from this file +export {} From a05c7fcfb5b9a50ababe7f599dc6e7865b06767c Mon Sep 17 00:00:00 2001 From: Kurt King Date: Tue, 6 Dec 2022 09:25:13 -0600 Subject: [PATCH 15/35] update readme to use @backstage Signed-off-by: Kurt King Signed-off-by: Kurt King --- packages/cli/templates/web-library-package/README.md.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/templates/web-library-package/README.md.hbs b/packages/cli/templates/web-library-package/README.md.hbs index ac18b06c04..a5c62caa4b 100644 --- a/packages/cli/templates/web-library-package/README.md.hbs +++ b/packages/cli/templates/web-library-package/README.md.hbs @@ -8,5 +8,5 @@ Install the package via Yarn: ```sh cd # if within a monorepo - yarn add @internal/{{id}} + yarn add @backstage/{{id}} ``` From 799d33f841130c2afdc264c621b4cb2b6aa088ce Mon Sep 17 00:00:00 2001 From: Kurt King Date: Wed, 7 Dec 2022 06:42:01 -0600 Subject: [PATCH 16/35] remove comment Signed-off-by: Kurt King Signed-off-by: Kurt King --- packages/cli/templates/web-library-package/src/index.ts.hbs | 1 - 1 file changed, 1 deletion(-) 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 361e389fef..287d260d7b 100644 --- a/packages/cli/templates/web-library-package/src/index.ts.hbs +++ b/packages/cli/templates/web-library-package/src/index.ts.hbs @@ -15,7 +15,6 @@ */ /** -* Core API used by Backstage plugins * * @packageDocumentation */ From 5d4503c2d299bf97add020c918ea5be27d01edf5 Mon Sep 17 00:00:00 2001 From: Kurt King Date: Thu, 8 Dec 2022 08:16:09 -0600 Subject: [PATCH 17/35] remove unused dependencies Signed-off-by: Kurt King Signed-off-by: Kurt King --- .../cli/templates/web-library-package/package.json.hbs | 9 +-------- .../cli/templates/web-library-package/src/setupTests.ts | 4 ++-- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/packages/cli/templates/web-library-package/package.json.hbs b/packages/cli/templates/web-library-package/package.json.hbs index 95608c97e7..4beb568586 100644 --- a/packages/cli/templates/web-library-package/package.json.hbs +++ b/packages/cli/templates/web-library-package/package.json.hbs @@ -27,15 +27,8 @@ "prepack": "backstage-cli package prepack", "postpack": "backstage-cli package postpack" }, - "peerDependencies": { - "react": "{{versionQuery 'react' '^16.13.1 || ^17.0.0'}}" - }, "devDependencies": { - "@backstage/cli": "{{versionQuery '@backstage/cli'}}", - "@backstage/test-utils": "{{versionQuery '@backstage/test-utils'}}", - "@testing-library/jest-dom": "{{versionQuery '@testing-library/jest-dom' '5.10.1'}}", - "msw": "{{versionQuery 'msw' '0.47.0'}}", - "cross-fetch": "{{versionQuery 'cross-fetch' '3.1.5'}}" + "@backstage/cli": "{{versionQuery '@backstage/cli'}}" }, "files": [ "dist" diff --git a/packages/cli/templates/web-library-package/src/setupTests.ts b/packages/cli/templates/web-library-package/src/setupTests.ts index c1d649f2ad..6a37ad1afb 100644 --- a/packages/cli/templates/web-library-package/src/setupTests.ts +++ b/packages/cli/templates/web-library-package/src/setupTests.ts @@ -14,5 +14,5 @@ * limitations under the License. */ -import '@testing-library/jest-dom'; -import 'cross-fetch/polyfill'; +// remove this line and add imports as required for your package +export {} From a27839e33db9f5b4003f1a759170f26f3856bc66 Mon Sep 17 00:00:00 2001 From: Kurt King Date: Thu, 8 Dec 2022 09:11:12 -0600 Subject: [PATCH 18/35] fix indentation Signed-off-by: Kurt King Signed-off-by: Kurt King --- packages/cli/templates/web-library-package/README.md.hbs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/templates/web-library-package/README.md.hbs b/packages/cli/templates/web-library-package/README.md.hbs index a5c62caa4b..fb866284b2 100644 --- a/packages/cli/templates/web-library-package/README.md.hbs +++ b/packages/cli/templates/web-library-package/README.md.hbs @@ -8,5 +8,5 @@ Install the package via Yarn: ```sh cd # if within a monorepo - yarn add @backstage/{{id}} - ``` +yarn add @backstage/{{id}} +``` From 0c50ef44019944a2a0fb40172499e27949f07e33 Mon Sep 17 00:00:00 2001 From: Kurt King Date: Thu, 8 Dec 2022 09:13:35 -0600 Subject: [PATCH 19/35] add jest-dom dependency Signed-off-by: Kurt King Signed-off-by: Kurt King --- packages/cli/templates/web-library-package/package.json.hbs | 3 ++- packages/cli/templates/web-library-package/src/setupTests.ts | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cli/templates/web-library-package/package.json.hbs b/packages/cli/templates/web-library-package/package.json.hbs index 4beb568586..edddc2a5d8 100644 --- a/packages/cli/templates/web-library-package/package.json.hbs +++ b/packages/cli/templates/web-library-package/package.json.hbs @@ -28,7 +28,8 @@ "postpack": "backstage-cli package postpack" }, "devDependencies": { - "@backstage/cli": "{{versionQuery '@backstage/cli'}}" + "@backstage/cli": "{{versionQuery '@backstage/cli'}}", + "@testing-library/jest-dom": "{{versionQuery '@testing-library/jest-dom' '5.10.1'}}", }, "files": [ "dist" diff --git a/packages/cli/templates/web-library-package/src/setupTests.ts b/packages/cli/templates/web-library-package/src/setupTests.ts index 6a37ad1afb..963c0f188b 100644 --- a/packages/cli/templates/web-library-package/src/setupTests.ts +++ b/packages/cli/templates/web-library-package/src/setupTests.ts @@ -14,5 +14,4 @@ * limitations under the License. */ -// remove this line and add imports as required for your package -export {} +import '@testing-library/jest-dom'; From 84fafa72633200e237ccf31b3864a55b298d9b50 Mon Sep 17 00:00:00 2001 From: Kurt King Date: Thu, 8 Dec 2022 09:16:26 -0600 Subject: [PATCH 20/35] update pattern for non-scoped packages to use Signed-off-by: Kurt King Signed-off-by: Kurt King --- packages/cli/src/lib/new/factories/webLibraryPackage.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/lib/new/factories/webLibraryPackage.ts b/packages/cli/src/lib/new/factories/webLibraryPackage.ts index 52c1a68aa2..c449ec87eb 100644 --- a/packages/cli/src/lib/new/factories/webLibraryPackage.ts +++ b/packages/cli/src/lib/new/factories/webLibraryPackage.ts @@ -40,7 +40,7 @@ export const webLibraryPackage = createFactory({ async create(options: Options, ctx: CreateContext) { const { id } = options; - const name = ctx.scope ? `@${ctx.scope}/${id}` : `backstage-plugin-${id}`; + const name = ctx.scope ? `@${ctx.scope}/${id}` : `${id}`; const extensionName = `${upperFirst(camelCase(id))}Page`; Task.log(); @@ -48,7 +48,7 @@ export const webLibraryPackage = createFactory({ const targetDir = ctx.isMonoRepo ? paths.resolveTargetRoot('packages', id) - : paths.resolveTargetRoot(`backstage-plugin-${id}`); + : paths.resolveTargetRoot(`${id}`); await executePluginPackageTemplate(ctx, { targetDir, From ac10e61d3fa90b16e9b7106b26bacc7fd709d60e Mon Sep 17 00:00:00 2001 From: Kurt King Date: Thu, 8 Dec 2022 09:18:23 -0600 Subject: [PATCH 21/35] remove unused imports and vars Signed-off-by: Kurt King Signed-off-by: Kurt King --- packages/cli/src/lib/new/factories/webLibraryPackage.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/cli/src/lib/new/factories/webLibraryPackage.ts b/packages/cli/src/lib/new/factories/webLibraryPackage.ts index c449ec87eb..b4f940ab8f 100644 --- a/packages/cli/src/lib/new/factories/webLibraryPackage.ts +++ b/packages/cli/src/lib/new/factories/webLibraryPackage.ts @@ -15,8 +15,6 @@ */ import chalk from 'chalk'; -import camelCase from 'lodash/camelCase'; -import upperFirst from 'lodash/upperFirst'; import { paths } from '../../paths'; import { addCodeownersEntry, getCodeownersFilePath } from '../../codeowners'; import { createFactory, CreateContext } from '../types'; @@ -39,9 +37,7 @@ export const webLibraryPackage = createFactory({ optionsPrompts: [pluginIdPrompt(), ownerPrompt()], async create(options: Options, ctx: CreateContext) { const { id } = options; - const name = ctx.scope ? `@${ctx.scope}/${id}` : `${id}`; - const extensionName = `${upperFirst(camelCase(id))}Page`; Task.log(); Task.log(`Creating web-library package ${chalk.cyan(name)}`); @@ -56,8 +52,6 @@ export const webLibraryPackage = createFactory({ values: { id, name, - extensionName, - pluginVar: `${camelCase(id)}Plugin`, pluginVersion: ctx.defaultVersion, privatePackage: ctx.private, npmRegistry: ctx.npmRegistry, From 864d905b951f581627b94e9d592f263affa924e5 Mon Sep 17 00:00:00 2001 From: Kurt King Date: Thu, 8 Dec 2022 09:31:22 -0600 Subject: [PATCH 22/35] add dependency Signed-off-by: Kurt King Signed-off-by: Kurt King --- packages/cli/templates/web-library-package/package.json.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/templates/web-library-package/package.json.hbs b/packages/cli/templates/web-library-package/package.json.hbs index edddc2a5d8..957efef167 100644 --- a/packages/cli/templates/web-library-package/package.json.hbs +++ b/packages/cli/templates/web-library-package/package.json.hbs @@ -29,7 +29,7 @@ }, "devDependencies": { "@backstage/cli": "{{versionQuery '@backstage/cli'}}", - "@testing-library/jest-dom": "{{versionQuery '@testing-library/jest-dom' '5.10.1'}}", + "@testing-library/jest-dom": "{{versionQuery '@testing-library/jest-dom' '5.10.1'}}" }, "files": [ "dist" From 84ee95bbb2e27300f6222896686151e6d71a9e5d Mon Sep 17 00:00:00 2001 From: Kurt King Date: Thu, 8 Dec 2022 09:31:46 -0600 Subject: [PATCH 23/35] add create test case Signed-off-by: Kurt King Signed-off-by: Kurt King --- .../new/factories/webLibraryPackage.test.ts | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 packages/cli/src/lib/new/factories/webLibraryPackage.test.ts diff --git a/packages/cli/src/lib/new/factories/webLibraryPackage.test.ts b/packages/cli/src/lib/new/factories/webLibraryPackage.test.ts new file mode 100644 index 0000000000..ba209ce1ef --- /dev/null +++ b/packages/cli/src/lib/new/factories/webLibraryPackage.test.ts @@ -0,0 +1,110 @@ +/* + * Copyright 2021 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 fs from 'fs-extra'; +import mockFs from 'mock-fs'; +import { resolve as resolvePath } from 'path'; +import { paths } from '../../paths'; +import { Task } from '../../tasks'; +import { FactoryRegistry } from '../FactoryRegistry'; +import { createMockOutputStream, mockPaths } from './common/testUtils'; +import { webLibraryPackage } from './webLibraryPackage'; + +describe('webLibraryPackage factory', () => { + beforeEach(() => { + mockPaths({ + targetRoot: '/root', + }); + }); + + afterEach(() => { + mockFs.restore(); + jest.resetAllMocks(); + }); + + it('should create a web library package', async () => { + const expectedwebLibraryPackageName = 'test'; + + mockFs({ + '/root': { + packages: mockFs.directory(), + }, + [paths.resolveOwn('templates')]: mockFs.load( + paths.resolveOwn('templates'), + ), + }); + + const options = await FactoryRegistry.populateOptions(webLibraryPackage, { + id: 'test', // name of web library package + }); + + let modified = false; + + const [output, mockStream] = createMockOutputStream(); + jest.spyOn(process, 'stderr', 'get').mockReturnValue(mockStream); + jest.spyOn(Task, 'forCommand').mockResolvedValue(); + + await webLibraryPackage.create(options, { + private: true, + isMonoRepo: true, + defaultVersion: '1.0.0', + markAsModified: () => { + modified = true; + }, + createTemporaryDirectory: () => fs.mkdtemp('test'), + }); + + expect(modified).toBe(true); + + expect(output).toEqual([ + '', + `Creating web-library package ${expectedwebLibraryPackageName}`, + 'Checking Prerequisites:', + `availability packages/${expectedwebLibraryPackageName}`, + 'creating temp dir', + 'Executing Template:', + 'copying .eslintrc.js', + 'templating README.md.hbs', + 'templating package.json.hbs', + 'templating index.ts.hbs', + 'copying setupTests.ts', + 'Installing:', + `moving packages/${expectedwebLibraryPackageName}`, + ]); + + await expect( + fs.readJson( + `/root/packages/${expectedwebLibraryPackageName}/package.json`, + ), + ).resolves.toEqual( + expect.objectContaining({ + name: expectedwebLibraryPackageName, + private: true, + version: '1.0.0', + }), + ); + + expect(Task.forCommand).toHaveBeenCalledTimes(2); + expect(Task.forCommand).toHaveBeenCalledWith('yarn install', { + cwd: resolvePath(`/root/packages/${expectedwebLibraryPackageName}`), + optional: true, + }); + expect(Task.forCommand).toHaveBeenCalledWith('yarn lint --fix', { + cwd: resolvePath(`/root/packages/${expectedwebLibraryPackageName}`), + optional: true, + }); + }); +}); From 64bfdcea3ee1eafe570aa730c0ae6621796cc661 Mon Sep 17 00:00:00 2001 From: Kurt King Date: Thu, 8 Dec 2022 09:32:35 -0600 Subject: [PATCH 24/35] Update .changeset/nice-hairs-lick.md Co-authored-by: Patrik Oldsberg Signed-off-by: Kurt King --- .changeset/nice-hairs-lick.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/nice-hairs-lick.md b/.changeset/nice-hairs-lick.md index 0512b61c7b..4229b5aa98 100644 --- a/.changeset/nice-hairs-lick.md +++ b/.changeset/nice-hairs-lick.md @@ -1,5 +1,5 @@ --- -'@backstage/cli': minor +'@backstage/cli': patch --- Adds new web-library package option when generating a new plugin From c9e8579da7260a4f80d72b25bfab37e3cb4b65f1 Mon Sep 17 00:00:00 2001 From: Kurt King Date: Thu, 8 Dec 2022 10:24:59 -0600 Subject: [PATCH 25/35] add test for options and codeowners Signed-off-by: Kurt King Signed-off-by: Kurt King --- .../new/factories/webLibraryPackage.test.ts | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/packages/cli/src/lib/new/factories/webLibraryPackage.test.ts b/packages/cli/src/lib/new/factories/webLibraryPackage.test.ts index ba209ce1ef..2e766f7dd3 100644 --- a/packages/cli/src/lib/new/factories/webLibraryPackage.test.ts +++ b/packages/cli/src/lib/new/factories/webLibraryPackage.test.ts @@ -107,4 +107,46 @@ describe('webLibraryPackage factory', () => { optional: true, }); }); + + it('should create a web library plugin with options and codeowners', async () => { + const expectedwebLibraryPackageName = 'test'; + + mockFs({ + '/root': { + CODEOWNERS: '', + packages: mockFs.directory(), + }, + [paths.resolveOwn('templates')]: mockFs.load( + paths.resolveOwn('templates'), + ), + }); + + const options = await FactoryRegistry.populateOptions(webLibraryPackage, { + id: 'test', + owner: '@backstage/test-owners', + }); + + const [, mockStream] = createMockOutputStream(); + jest.spyOn(process, 'stderr', 'get').mockReturnValue(mockStream); + jest.spyOn(Task, 'forCommand').mockResolvedValue(); + + await webLibraryPackage.create(options, { + scope: 'internal', + private: true, + isMonoRepo: true, + defaultVersion: '1.0.0', + markAsModified: () => {}, + createTemporaryDirectory: () => fs.mkdtemp('test'), + }); + + expect(Task.forCommand).toHaveBeenCalledTimes(2); + expect(Task.forCommand).toHaveBeenCalledWith('yarn install', { + cwd: resolvePath(`/root/packages/${expectedwebLibraryPackageName}`), + optional: true, + }); + expect(Task.forCommand).toHaveBeenCalledWith('yarn lint --fix', { + cwd: resolvePath(`/root/packages/${expectedwebLibraryPackageName}`), + optional: true, + }); + }); }); From b2aedb6b3226ee7a77edf62eb76f880f77e421ce Mon Sep 17 00:00:00 2001 From: Kurt King Date: Thu, 8 Dec 2022 10:26:03 -0600 Subject: [PATCH 26/35] add test for options and codeowners Signed-off-by: Kurt King Signed-off-by: Kurt King --- .../cli/src/lib/new/factories/webLibraryPackage.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/lib/new/factories/webLibraryPackage.test.ts b/packages/cli/src/lib/new/factories/webLibraryPackage.test.ts index 2e766f7dd3..0fb2e2d5bb 100644 --- a/packages/cli/src/lib/new/factories/webLibraryPackage.test.ts +++ b/packages/cli/src/lib/new/factories/webLibraryPackage.test.ts @@ -133,7 +133,7 @@ describe('webLibraryPackage factory', () => { await webLibraryPackage.create(options, { scope: 'internal', private: true, - isMonoRepo: true, + isMonoRepo: false, defaultVersion: '1.0.0', markAsModified: () => {}, createTemporaryDirectory: () => fs.mkdtemp('test'), @@ -141,11 +141,11 @@ describe('webLibraryPackage factory', () => { expect(Task.forCommand).toHaveBeenCalledTimes(2); expect(Task.forCommand).toHaveBeenCalledWith('yarn install', { - cwd: resolvePath(`/root/packages/${expectedwebLibraryPackageName}`), + cwd: resolvePath(`/root/${expectedwebLibraryPackageName}`), optional: true, }); expect(Task.forCommand).toHaveBeenCalledWith('yarn lint --fix', { - cwd: resolvePath(`/root/packages/${expectedwebLibraryPackageName}`), + cwd: resolvePath(`/root/${expectedwebLibraryPackageName}`), optional: true, }); }); From bfe30cfbb3f2dd271fcd591a54061fb675650c2b Mon Sep 17 00:00:00 2001 From: Kurt King Date: Fri, 9 Dec 2022 06:55:41 -0600 Subject: [PATCH 27/35] update {{id}} to {{name}} Signed-off-by: Kurt King --- packages/cli/templates/web-library-package/README.md.hbs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/templates/web-library-package/README.md.hbs b/packages/cli/templates/web-library-package/README.md.hbs index fb866284b2..0e2813c87a 100644 --- a/packages/cli/templates/web-library-package/README.md.hbs +++ b/packages/cli/templates/web-library-package/README.md.hbs @@ -1,4 +1,4 @@ -# {{id}} +# {{name}} _This package was created through the Backstage CLI_. @@ -8,5 +8,5 @@ Install the package via Yarn: ```sh cd # if within a monorepo -yarn add @backstage/{{id}} +yarn add {{name}} ``` From 305a47216246873e948d8a8b235438d5626cf627 Mon Sep 17 00:00:00 2001 From: Kurt King Date: Mon, 12 Dec 2022 14:56:37 -0600 Subject: [PATCH 28/35] Update packages/cli/src/lib/new/factories/webLibraryPackage.ts Co-authored-by: Camila Belo Signed-off-by: Kurt King --- packages/cli/src/lib/new/factories/webLibraryPackage.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/lib/new/factories/webLibraryPackage.ts b/packages/cli/src/lib/new/factories/webLibraryPackage.ts index b4f940ab8f..a160220cab 100644 --- a/packages/cli/src/lib/new/factories/webLibraryPackage.ts +++ b/packages/cli/src/lib/new/factories/webLibraryPackage.ts @@ -1,5 +1,5 @@ /* - * Copyright 2021 The Backstage Authors + * Copyright 2022 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. From 0594b88691696934111d5a25a5058635f0b7f313 Mon Sep 17 00:00:00 2001 From: Kurt King Date: Mon, 12 Dec 2022 14:56:47 -0600 Subject: [PATCH 29/35] Update packages/cli/templates/web-library-package/src/setupTests.ts Co-authored-by: Camila Belo Signed-off-by: Kurt King --- packages/cli/templates/web-library-package/src/setupTests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/templates/web-library-package/src/setupTests.ts b/packages/cli/templates/web-library-package/src/setupTests.ts index 963c0f188b..7a459ed24e 100644 --- a/packages/cli/templates/web-library-package/src/setupTests.ts +++ b/packages/cli/templates/web-library-package/src/setupTests.ts @@ -1,5 +1,5 @@ /* - * Copyright 2020 The Backstage Authors + * Copyright 2022 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. From 6b40174cb255b78cda0d8f242ad81642cf758414 Mon Sep 17 00:00:00 2001 From: Kurt King Date: Mon, 12 Dec 2022 14:56:56 -0600 Subject: [PATCH 30/35] Update packages/cli/templates/web-library-package/src/index.ts.hbs Co-authored-by: Camila Belo Signed-off-by: Kurt King --- packages/cli/templates/web-library-package/src/index.ts.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 287d260d7b..4697d8f640 100644 --- a/packages/cli/templates/web-library-package/src/index.ts.hbs +++ b/packages/cli/templates/web-library-package/src/index.ts.hbs @@ -1,5 +1,5 @@ /* -* Copyright 2020 The Backstage Authors +* Copyright 2022 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. From 67df84b9eb1da8ac47c26a92d1dd2e536f9dc635 Mon Sep 17 00:00:00 2001 From: Kurt King Date: Mon, 12 Dec 2022 14:57:02 -0600 Subject: [PATCH 31/35] Update packages/cli/src/lib/new/factories/webLibraryPackage.test.ts Co-authored-by: Camila Belo Signed-off-by: Kurt King --- packages/cli/src/lib/new/factories/webLibraryPackage.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/lib/new/factories/webLibraryPackage.test.ts b/packages/cli/src/lib/new/factories/webLibraryPackage.test.ts index 0fb2e2d5bb..03be32dbaa 100644 --- a/packages/cli/src/lib/new/factories/webLibraryPackage.test.ts +++ b/packages/cli/src/lib/new/factories/webLibraryPackage.test.ts @@ -1,5 +1,5 @@ /* - * Copyright 2021 The Backstage Authors + * Copyright 2022 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. From 23158b71736e4e6ef68da1a65c780ec1650817cc Mon Sep 17 00:00:00 2001 From: Kurt King Date: Mon, 12 Dec 2022 15:03:21 -0600 Subject: [PATCH 32/35] remove dev folder Signed-off-by: Kurt King --- packages/cli/templates/web-library-package/tsconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/cli/templates/web-library-package/tsconfig.json b/packages/cli/templates/web-library-package/tsconfig.json index b61e496175..ce3409d31f 100644 --- a/packages/cli/templates/web-library-package/tsconfig.json +++ b/packages/cli/templates/web-library-package/tsconfig.json @@ -2,7 +2,6 @@ "extends": "@backstage/cli/config/tsconfig.json", "include": [ "src", - "dev" ], "exclude": ["node_modules"], "compilerOptions": { From 6275016cf2363e6115dcefe24cb883686888b5e6 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 13 Dec 2022 17:06:52 +0100 Subject: [PATCH 33/35] Update packages/cli/templates/web-library-package/src/index.ts.hbs Signed-off-by: Patrik Oldsberg --- .../web-library-package/src/index.ts.hbs | 21 ------------------- 1 file changed, 21 deletions(-) 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 4697d8f640..336ce12bb9 100644 --- a/packages/cli/templates/web-library-package/src/index.ts.hbs +++ b/packages/cli/templates/web-library-package/src/index.ts.hbs @@ -1,22 +1 @@ -/* -* Copyright 2022 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. -*/ - -/** -* -* @packageDocumentation -*/ - export {} From 06f2a7110fce5b25b73f702c0a227d9df4cdc6f3 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 13 Dec 2022 17:07:00 +0100 Subject: [PATCH 34/35] Update packages/cli/templates/web-library-package/src/setupTests.ts Signed-off-by: Patrik Oldsberg --- .../web-library-package/src/setupTests.ts | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/packages/cli/templates/web-library-package/src/setupTests.ts b/packages/cli/templates/web-library-package/src/setupTests.ts index 7a459ed24e..7b0828bfa8 100644 --- a/packages/cli/templates/web-library-package/src/setupTests.ts +++ b/packages/cli/templates/web-library-package/src/setupTests.ts @@ -1,17 +1 @@ -/* - * Copyright 2022 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'; From a0f454ed7c861e60e21e9f6491f4746f90b4ba89 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 13 Dec 2022 17:08:23 +0100 Subject: [PATCH 35/35] cli: add missing semi in web-library index.ts template Signed-off-by: Patrik Oldsberg --- packages/cli/templates/web-library-package/src/index.ts.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 336ce12bb9..cb0ff5c3b5 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 @@ -export {} +export {};