From 705794def590c02a9242b52ee1c76d2097edddfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Mon, 12 Aug 2024 10:25:35 +0200 Subject: [PATCH] rename the role to frontend-extensions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/cold-tomatoes-vanish.md | 2 +- docs/tooling/cli/02-build-system.md | 26 ++++++------- .../catalog-info.yaml | 2 +- .../app-next-example-extensions/package.json | 38 +++++++++---------- packages/cli-node/src/roles/PackageRoles.ts | 2 +- packages/cli-node/src/roles/types.ts | 2 +- packages/cli/config/eslint-factory.js | 2 +- packages/cli/config/jest.js | 2 +- packages/cli/src/commands/repo/fix.ts | 4 +- packages/cli/src/commands/start/command.ts | 2 +- .../cli/src/lib/bundler/packageDetection.ts | 2 +- .../rules/no-undeclared-imports.js | 2 +- ...list-no-top-level-material-ui-4-imports.js | 2 +- scripts/verify-local-dependencies.js | 6 +-- 14 files changed, 47 insertions(+), 47 deletions(-) diff --git a/.changeset/cold-tomatoes-vanish.md b/.changeset/cold-tomatoes-vanish.md index 729ff2ecb5..1ffd701e9b 100644 --- a/.changeset/cold-tomatoes-vanish.md +++ b/.changeset/cold-tomatoes-vanish.md @@ -4,4 +4,4 @@ '@backstage/eslint-plugin': patch --- -Added support for the `frontend-extensions-bundle` role, which is used in conjunction with the new frontend system to ship extensions to your apps. +Added support for the `frontend-extensions` role, which is used in conjunction with the new frontend system to ship extensions to your apps. diff --git a/docs/tooling/cli/02-build-system.md b/docs/tooling/cli/02-build-system.md index 5cc672788e..ced3385b1e 100644 --- a/docs/tooling/cli/02-build-system.md +++ b/docs/tooling/cli/02-build-system.md @@ -93,19 +93,19 @@ defined in the `package.json` of each package like this: These are the available roles that are currently supported by the Backstage build system: -| Role | Description | Example | -| -------------------------- | -------------------------------------------- | -------------------------------------------- | -| frontend | Bundled frontend application | `packages/app` | -| backend | Bundled backend application | `packages/backend` | -| cli | Package used as a command-line interface | `@backstage/cli`, `@backstage/codemods` | -| web-library | Web library for use by other packages | `@backstage/plugin-catalog-react` | -| node-library | Node.js library for use by other packages | `@backstage/plugin-techdocs-node` | -| common-library | Isomorphic library for use by other packages | `@backstage/plugin-permission-common` | -| frontend-plugin | Backstage frontend plugin | `@backstage/plugin-scaffolder` | -| frontend-extensions-bundle | Extensions for the Backstage frontend | Typically only appears in adopter repos | -| frontend-plugin-module | Backstage frontend plugin module | `@backstage/plugin-analytics-module-ga` | -| backend-plugin | Backstage backend plugin | `@backstage/plugin-auth-backend` | -| backend-plugin-module | Backstage backend plugin module | `@backstage/plugin-search-backend-module-pg` | +| Role | Description | Example | +| ---------------------- | ----------------------------------------------------------------------------- | -------------------------------------------- | +| frontend | Bundled frontend application | `packages/app` | +| backend | Bundled backend application | `packages/backend` | +| cli | Package used as a command-line interface | `@backstage/cli`, `@backstage/codemods` | +| web-library | Web library for use by other packages | `@backstage/plugin-catalog-react` | +| node-library | Node.js library for use by other packages | `@backstage/plugin-techdocs-node` | +| common-library | Isomorphic library for use by other packages | `@backstage/plugin-permission-common` | +| frontend-plugin | Backstage frontend plugin | `@backstage/plugin-scaffolder` | +| frontend-extensions | Extensions (customizations, private additions etc) for the Backstage frontend | Typically only appears in adopter repos | +| frontend-plugin-module | Backstage frontend plugin module | `@backstage/plugin-analytics-module-ga` | +| backend-plugin | Backstage backend plugin | `@backstage/plugin-auth-backend` | +| backend-plugin-module | Backstage backend plugin module | `@backstage/plugin-search-backend-module-pg` | Most of the steps that we cover below have an accompanying command that is intended to be used as a package script. The commands are all available under the `backstage-cli package` category, and many of the commands will behave differently depending on the role of the package. The commands are intended to be used like this: diff --git a/packages/app-next-example-extensions/catalog-info.yaml b/packages/app-next-example-extensions/catalog-info.yaml index 43fe837fe0..32acdd0317 100644 --- a/packages/app-next-example-extensions/catalog-info.yaml +++ b/packages/app-next-example-extensions/catalog-info.yaml @@ -5,5 +5,5 @@ metadata: title: '@internal/app-next-example-extensions' spec: lifecycle: experimental - type: backstage-frontend-extensions-bundle + type: backstage-frontend-extensions owner: maintainers diff --git a/packages/app-next-example-extensions/package.json b/packages/app-next-example-extensions/package.json index b888c0a57d..e4534adcc5 100644 --- a/packages/app-next-example-extensions/package.json +++ b/packages/app-next-example-extensions/package.json @@ -1,27 +1,30 @@ { "name": "@internal/app-next-example-extensions", "version": "0.0.0", - "private": true, - "main": "src/index.ts", - "types": "src/index.ts", - "license": "Apache-2.0", + "backstage": { + "role": "frontend-extensions" + }, "publishConfig": { "access": "public", "main": "dist/index.esm.js", "types": "dist/index.d.ts" }, - "backstage": { - "role": "frontend-extensions-bundle" - }, + "private": true, + "license": "Apache-2.0", "sideEffects": false, + "main": "src/index.ts", + "types": "src/index.ts", + "files": [ + "dist" + ], "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", + "lint": "backstage-cli package lint", "prepack": "backstage-cli package prepack", - "postpack": "backstage-cli package postpack" + "postpack": "backstage-cli package postpack", + "start": "backstage-cli package start", + "test": "backstage-cli package test" }, "dependencies": { "@backstage/core-components": "workspace:^", @@ -34,11 +37,6 @@ "@material-ui/lab": "^4.0.0-alpha.61", "react-use": "^17.2.4" }, - "peerDependencies": { - "react": "^16.13.1 || ^17.0.0 || ^18.0.0", - "react-dom": "^16.13.1 || ^17.0.0 || ^18.0.0", - "react-router-dom": "6.0.0-beta.0 || ^6.3.0" - }, "devDependencies": { "@backstage/cli": "workspace:^", "@backstage/core-app-api": "workspace:^", @@ -49,7 +47,9 @@ "@testing-library/user-event": "^14.0.0", "msw": "^1.0.0" }, - "files": [ - "dist" - ] + "peerDependencies": { + "react": "^16.13.1 || ^17.0.0 || ^18.0.0", + "react-dom": "^16.13.1 || ^17.0.0 || ^18.0.0", + "react-router-dom": "6.0.0-beta.0 || ^6.3.0" + } } diff --git a/packages/cli-node/src/roles/PackageRoles.ts b/packages/cli-node/src/roles/PackageRoles.ts index 76114b7261..0a7e6142cf 100644 --- a/packages/cli-node/src/roles/PackageRoles.ts +++ b/packages/cli-node/src/roles/PackageRoles.ts @@ -54,7 +54,7 @@ const packageRoleInfos: PackageRoleInfo[] = [ output: ['types', 'esm'], }, { - role: 'frontend-extensions-bundle', + role: 'frontend-extensions', platform: 'web', output: ['types', 'esm'], }, diff --git a/packages/cli-node/src/roles/types.ts b/packages/cli-node/src/roles/types.ts index ebb417e614..1cd374f1e7 100644 --- a/packages/cli-node/src/roles/types.ts +++ b/packages/cli-node/src/roles/types.ts @@ -27,7 +27,7 @@ export type PackageRole = | 'node-library' | 'common-library' | 'frontend-plugin' - | 'frontend-extensions-bundle' + | 'frontend-extensions' | 'frontend-plugin-module' | 'backend-plugin' | 'backend-plugin-module'; diff --git a/packages/cli/config/eslint-factory.js b/packages/cli/config/eslint-factory.js index 460fa166d1..7a55ad464f 100644 --- a/packages/cli/config/eslint-factory.js +++ b/packages/cli/config/eslint-factory.js @@ -200,7 +200,7 @@ function createConfigForRole(dir, role, extraConfig = {}) { case 'web-library': case 'frontend': case 'frontend-plugin': - case 'frontend-extensions-bundle': + case 'frontend-extensions': case 'frontend-plugin-module': case 'frontend-dynamic-container': return createConfig(dir, { diff --git a/packages/cli/config/jest.js b/packages/cli/config/jest.js index 22c89f6782..8c97516667 100644 --- a/packages/cli/config/jest.js +++ b/packages/cli/config/jest.js @@ -54,7 +54,7 @@ function getRoleConfig(role) { case 'web-library': case 'common-library': case 'frontend-plugin': - case 'frontend-extensions-bundle': + case 'frontend-extensions': case 'frontend-plugin-module': return { testEnvironment: require.resolve('jest-environment-jsdom') }; case 'cli': diff --git a/packages/cli/src/commands/repo/fix.ts b/packages/cli/src/commands/repo/fix.ts index 68f857798e..d670552bbc 100644 --- a/packages/cli/src/commands/repo/fix.ts +++ b/packages/cli/src/commands/repo/fix.ts @@ -246,7 +246,7 @@ function guessPluginId(role: PackageRole, pkgName: string): string | undefined { case 'frontend': case 'frontend-plugin': return pkgName.match(/plugin-(.*)/)?.[1]; - case 'frontend-extensions-bundle': + case 'frontend-extensions': return undefined; case 'frontend-plugin-module': return pkgName.match(/plugin-(.*)-module-/)?.[1]; @@ -366,7 +366,7 @@ export function fixPluginPackages( role === 'common-library' || role === 'web-library' || role === 'node-library' || - role === 'frontend-extensions-bundle' || + role === 'frontend-extensions' || role === 'frontend-plugin-module' // TODO(Rugvip): Remove this once frontend modules are required to have a plugin ID ) { return; diff --git a/packages/cli/src/commands/start/command.ts b/packages/cli/src/commands/start/command.ts index ac2bb20be7..12631b75b5 100644 --- a/packages/cli/src/commands/start/command.ts +++ b/packages/cli/src/commands/start/command.ts @@ -46,7 +46,7 @@ export async function command(opts: OptionValues): Promise { }); case 'web-library': case 'frontend-plugin': - case 'frontend-extensions-bundle': + case 'frontend-extensions': case 'frontend-plugin-module': return startFrontend({ entry: 'dev/index', ...options }); case 'frontend-dynamic-container' as PackageRole: // experimental diff --git a/packages/cli/src/lib/bundler/packageDetection.ts b/packages/cli/src/lib/bundler/packageDetection.ts index 22713ff3c9..fe362b196d 100644 --- a/packages/cli/src/lib/bundler/packageDetection.ts +++ b/packages/cli/src/lib/bundler/packageDetection.ts @@ -86,7 +86,7 @@ async function detectPackages( if ( [ 'frontend-plugin', - 'frontend-extensions-bundle', + 'frontend-extensions', 'frontend-plugin-module', ].includes(depPackageJson.backstage?.role ?? '') ) { diff --git a/packages/eslint-plugin/rules/no-undeclared-imports.js b/packages/eslint-plugin/rules/no-undeclared-imports.js index 7756b82cc2..76331939df 100644 --- a/packages/eslint-plugin/rules/no-undeclared-imports.js +++ b/packages/eslint-plugin/rules/no-undeclared-imports.js @@ -48,7 +48,7 @@ function getExpectedDepType( case 'common-library': case 'web-library': case 'frontend-plugin': - case 'frontend-extensions-bundle': + case 'frontend-extensions': case 'frontend-plugin-module': case 'node-library': case 'backend-plugin': diff --git a/scripts/list-no-top-level-material-ui-4-imports.js b/scripts/list-no-top-level-material-ui-4-imports.js index c92d4515fa..fc2fc6c92e 100644 --- a/scripts/list-no-top-level-material-ui-4-imports.js +++ b/scripts/list-no-top-level-material-ui-4-imports.js @@ -28,7 +28,7 @@ async function main() { if ( pkgRole === 'frontend-plugin' || pkgRole === 'web-library' || - pkgRole === 'frontend-extensions-bundle' + pkgRole === 'frontend-extensions' ) { const depKeys = Object.keys(pkg.packageJson.dependencies); if (depKeys.findIndex(d => d.includes('@material-ui')) !== -1) { diff --git a/scripts/verify-local-dependencies.js b/scripts/verify-local-dependencies.js index c82e978475..2d38e8dc07 100755 --- a/scripts/verify-local-dependencies.js +++ b/scripts/verify-local-dependencies.js @@ -45,7 +45,7 @@ const roleRules = [ 'frontend-plugin', 'web-library', 'frontend-plugin-module', - 'frontend-extensions-bundle', + 'frontend-extensions', ], message: `Package SOURCE_NAME with backend role SOURCE_ROLE has a dependency on package TARGET_NAME with frontend role TARGET_ROLE, which is not permitted`, }, @@ -55,7 +55,7 @@ const roleRules = [ 'frontend-plugin', 'web-library', 'frontend-plugin-module', - 'frontend-extensions-bundle', + 'frontend-extensions', 'backend-plugin', 'node-library', 'backend-plugin-module', @@ -67,7 +67,7 @@ const roleRules = [ targetRole: [ 'frontend-plugin', 'frontend-plugin-module', - 'frontend-extensions-bundle', + 'frontend-extensions', ], except: [ // TODO(freben): Address these