Skip to content

Commit

Permalink
chore: release of accentuate plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
dweber019 committed Mar 23, 2024
1 parent 502a9b0 commit 9322ce0
Show file tree
Hide file tree
Showing 78 changed files with 6,475 additions and 3,960 deletions.
7 changes: 7 additions & 0 deletions .changeset/large-moles-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@dweber019/backstage-plugin-accentuate-backend': patch
'@dweber019/backstage-plugin-accentuate-common': patch
'@dweber019/backstage-plugin-accentuate': patch
---

Initial release of accentuate plugins.
7 changes: 6 additions & 1 deletion app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ scaffolder:

catalog:
rules:
- allow: [Component, System, API, Resource, Location]
- allow: [Component, System, API, Resource, Location, User, Group]
locations:
# Local example data, file locations are relative to the backend process, typically `packages/backend`
- type: file
Expand All @@ -85,7 +85,12 @@ catalog:
- type: file
target: ../../plugins/api-docs-spectral-linter/dev/openapi-zalando-example-api.yaml

- type: file
target: ../../plugins/accentuate-backend/examples/all.yaml

spectralLinter:
openApiRulesetUrl: https://gist.githubusercontent.com/dweber019/a368819668a76363849db6378792e907/raw/backstage-spectral-linter-openapi-ruleset.yaml
asyncApiRulesetUrl: https://gist.githubusercontent.com/dweber019/a368819668a76363849db6378792e907/raw/backstage-spectral-linter-asyncapi-ruleset.yaml

accentuate:
allowedKinds: ['User', 'Group', 'Component', 'Resource', 'System', 'Domain']
1 change: 1 addition & 0 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@backstage/plugin-techdocs-react": "^1.1.15",
"@backstage/plugin-user-settings": "^0.8.0",
"@backstage/theme": "^0.5.0",
"@dweber019/backstage-plugin-accentuate": "^0.0.0",
"@dweber019/backstage-plugin-api-docs-module-wsdl": "^0.0.5",
"@dweber019/backstage-plugin-api-docs-spectral-linter": "^0.2.11",
"@dweber019/backstage-plugin-endoflife": "^0.0.3",
Expand Down
2 changes: 2 additions & 0 deletions packages/app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { AppRouter, FlatRoutes } from '@backstage/core-app-api';
import { CatalogGraphPage } from '@backstage/plugin-catalog-graph';
import { RequirePermission } from '@backstage/plugin-permission-react';
import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common/alpha';
import { AccentuatePage } from '@dweber019/backstage-plugin-accentuate';

const app = createApp({
apis,
Expand Down Expand Up @@ -103,6 +104,7 @@ const routes = (
</Route>
<Route path="/settings" element={<UserSettingsPage />} />
<Route path="/catalog-graph" element={<CatalogGraphPage />} />
<Route path="/accentuate" element={<AccentuatePage />} />
</FlatRoutes>
);

Expand Down
2 changes: 2 additions & 0 deletions packages/app/src/components/Root/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { makeStyles } from '@material-ui/core';
import HomeIcon from '@material-ui/icons/Home';
import ExtensionIcon from '@material-ui/icons/Extension';
import MapIcon from '@material-ui/icons/MyLocation';
import BrushIcon from '@material-ui/icons/Brush';
import LibraryBooks from '@material-ui/icons/LibraryBooks';
import CreateComponentIcon from '@material-ui/icons/AddCircleOutline';
import LogoFull from './LogoFull';
Expand Down Expand Up @@ -73,6 +74,7 @@ export const Root = ({ children }: PropsWithChildren<{}>) => (
<SidebarDivider />
<SidebarScrollWrapper>
<SidebarItem icon={MapIcon} to="tech-radar" text="Tech Radar" />
<SidebarItem icon={BrushIcon} to="accentuate" text="Accentuate" />
</SidebarScrollWrapper>
</SidebarGroup>
<SidebarSpace />
Expand Down
21 changes: 17 additions & 4 deletions packages/app/src/components/catalog/EntityPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ import {
isEndOfLifeAvailable,
} from '@dweber019/backstage-plugin-endoflife';
import { EntityTipsDialog } from '@dweber019/backstage-plugin-tips';
import {
EntityAccentuateInfo,
isAccentuateEnabled,
EntityLayoutWrapper,
} from '@dweber019/backstage-plugin-accentuate';

const techdocsContent = <EntityTechdocsContent />;

Expand Down Expand Up @@ -111,6 +116,14 @@ const entityWarningContent = (
</EntitySwitch.Case>
</EntitySwitch>

<EntitySwitch>
<EntitySwitch.Case if={isAccentuateEnabled}>
<Grid item xs={12}>
<EntityAccentuateInfo />
</Grid>
</EntitySwitch.Case>
</EntitySwitch>

<EntityTipsDialog />
</>
);
Expand All @@ -135,7 +148,7 @@ const overviewContent = (
);

const serviceEntityPage = (
<EntityLayout>
<EntityLayoutWrapper>
<EntityLayout.Route path="/" title="Overview">
{overviewContent}
</EntityLayout.Route>
Expand Down Expand Up @@ -177,7 +190,7 @@ const serviceEntityPage = (
>
<EntityEndOfLifeCard />
</EntityLayout.Route>
</EntityLayout>
</EntityLayoutWrapper>
);

const websiteEntityPage = (
Expand Down Expand Up @@ -249,7 +262,7 @@ const componentPage = (
);

const apiPage = (
<EntityLayout>
<EntityLayoutWrapper>
<EntityLayout.Route path="/" title="Overview">
<Grid container spacing={3}>
{entityWarningContent}
Expand Down Expand Up @@ -288,7 +301,7 @@ const apiPage = (
>
<EntityApiDocsSpectralLinterContent />
</EntityLayout.Route>
</EntityLayout>
</EntityLayoutWrapper>
);

const userPage = (
Expand Down
1 change: 1 addition & 0 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@backstage/plugin-search-backend-module-techdocs": "^0.1.13",
"@backstage/plugin-search-backend-node": "^1.2.13",
"@backstage/plugin-techdocs-backend": "^1.9.2",
"@dweber019/backstage-plugin-accentuate-backend": "^0.0.0",
"@dweber019/backstage-plugin-api-docs-module-wsdl-backend": "^0.0.7",
"@dweber019/backstage-plugin-endoflife-backend": "^0.0.2",
"app": "link:../app",
Expand Down
5 changes: 4 additions & 1 deletion packages/backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { ServerPermissionClient } from '@backstage/plugin-permission-node';
import { DefaultIdentityClient } from '@backstage/plugin-auth-node';
import apiDocsModuleWsdlDoc from './plugins/apiDocsModuleWsdl';
import endOfLife from './plugins/endoflife';
import accentuate from './plugins/accentuate';

function makeCreateEnv(config: Config) {
const root = getRootLogger();
Expand Down Expand Up @@ -91,9 +92,10 @@ async function main() {
createEnv('apiDocsModuleWsdl'),
);
const endOfLifeEnv = useHotMemoize(module, () => createEnv('endoflife'));
const accentuateEnv = useHotMemoize(module, () => createEnv('accentuate'));

const apiRouter = Router();
apiRouter.use('/catalog', await catalog(catalogEnv));
apiRouter.use('/catalog', await catalog(catalogEnv, accentuateEnv));
apiRouter.use('/scaffolder', await scaffolder(scaffolderEnv));
apiRouter.use('/auth', await auth(authEnv));
apiRouter.use('/techdocs', await techdocs(techdocsEnv));
Expand All @@ -104,6 +106,7 @@ async function main() {
await apiDocsModuleWsdlDoc(apiDocsModuleWsdlDocEnv),
);
apiRouter.use('/endoflife', await endOfLife(endOfLifeEnv));
apiRouter.use('/accentuate', await accentuate(accentuateEnv));

// Add backends ABOVE this line; this 404 handler is the catch-all fallback
apiRouter.use(notFoundHandler());
Expand Down
13 changes: 13 additions & 0 deletions packages/backend/src/plugins/accentuate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { createRouter } from '@dweber019/backstage-plugin-accentuate-backend';
import { Router } from 'express';
import { PluginEnvironment } from '../types';

export default async function createPlugin(
env: PluginEnvironment,
): Promise<Router> {
return await createRouter({
logger: env.logger,
database: env.database,
identity: env.identity,
});
}
5 changes: 5 additions & 0 deletions packages/backend/src/plugins/catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@ import { CatalogBuilder } from '@backstage/plugin-catalog-backend';
import { ScaffolderEntitiesProcessor } from '@backstage/plugin-catalog-backend-module-scaffolder-entity-model';
import { Router } from 'express';
import { PluginEnvironment } from '../types';
import { AccentuateEntitiesProcessor } from '@dweber019/backstage-plugin-accentuate-backend';

export default async function createPlugin(
env: PluginEnvironment,
envAccentuate: PluginEnvironment,
): Promise<Router> {
const builder = await CatalogBuilder.create(env);
builder.addProcessor(new ScaffolderEntitiesProcessor());
builder.addProcessor(
await AccentuateEntitiesProcessor.fromEnv(envAccentuate),
);
const { processingEngine, router } = await builder.build();
await processingEngine.start();
return router;
Expand Down
1 change: 1 addition & 0 deletions plugins/accentuate-backend/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);
92 changes: 92 additions & 0 deletions plugins/accentuate-backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Accentuate backend plugin

The accentuate backend plugin merges data stored in the database with the ingested entities mostly ingested from
SCM.

Additionally, the plugin will provide an API to manage the data for the [accentuate frontend plugin](../accentuate/README.md).

## Install

### Setup plugin

First we need to add the `@dweber019/backstage-plugin-accentuate-backend` package:

```sh
# From your Backstage root directory
yarn add --cwd packages/backend @dweber019/backstage-plugin-accentuate-backend
```

Then we open the file named `packages/backend/src/plugins/catalog.ts`, and extend it with:

```ts
import { AccentuateEntitiesProcessor } from '@dweber019/backstage-plugin-accentuate-backend';

export default async function createPlugin(
env: PluginEnvironment,
envAccentuate: PluginEnvironment, // required that the correct database is used in AccentuateEntitiesProcessor
): Promise<Router> {
const builder = await CatalogBuilder.create(env);

builder.addProcessor(
await AccentuateEntitiesProcessor.fromEnv(envAccentuate),
);

const { processingEngine, router } = await builder.build();
// ..
}
```

Then create a file at `packages/backend/src/plugins/accentuate.ts` with

```ts
import { createRouter } from '@dweber019/backstage-plugin-accentuate-backend';
import { Router } from 'express';
import { PluginEnvironment } from '../types';

export default async function createPlugin(
env: PluginEnvironment,
): Promise<Router> {
return await createRouter({
logger: env.logger,
database: env.database,
identity: env.identity,
});
}
```

Next we wire this into the overall backend router, edit `packages/backend/src/index.ts`:

```ts
import accentuate from './plugins/accentuate';
// ...
async function main() {
// ...
// Add this line under the other lines that follow the useHotMemoize pattern
const accentuateEnv = useHotMemoize(module, () => createEnv('accentuate'));
// ...
// Extend the catalog to provide the accentuateEnv
apiRouter.use('/catalog', await catalog(catalogEnv, accentuateEnv));
// Insert this line under the other lines that add their routers to apiRouter in the same way
apiRouter.use('/accentuate', await accentuate(accentuateEnv));
```
### New Backend System
The backend plugin has support for the [new backend system](https://backstage.io/docs/backend-system/), here's how you can set that up:
In your `packages/backend/src/index.ts` make the following changes:
```diff

+ import { accentuatePlugin, catalogModuleAccentuateProcessor } from '@dweber019/backstage-plugin-accentuate-backend';
const backend = createBackend();

+ backend.add(accentuatePlugin());
+ backend.add(catalogModuleAccentuateProcessor());

// ... other feature additions

backend.start();
```
> This was not tested and is here for reference
9 changes: 9 additions & 0 deletions plugins/accentuate-backend/config.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export interface Config {
accentuate?: {
/**
* The kinds allowed to be accentuated
* @visibility frontend
*/
allowedKinds?: string[];
};
}
13 changes: 13 additions & 0 deletions plugins/accentuate-backend/examples/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: backstage.io/v1alpha1
kind: Location
metadata:
name: accentuate
description: Examples of standard kinds with accentuate
spec:
targets:
- ./group-1.yaml
- ./user-1.yaml
- ./user-2.yaml
- ./component-1.yaml
- ./resource-1.yaml
- ./system-1.yaml
11 changes: 11 additions & 0 deletions plugins/accentuate-backend/examples/component-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: component-accentuate
spec:
type: service
lifecycle: production
owner: group:default/group-accentuate
# system
# dependsOn

9 changes: 9 additions & 0 deletions plugins/accentuate-backend/examples/group-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: backstage.io/v1alpha1
kind: Group
metadata:
name: group-accentuate
spec:
type: team
children: []
members: # add user-accentuate
- user:default/user-accentuate-2
8 changes: 8 additions & 0 deletions plugins/accentuate-backend/examples/resource-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
name: resource-accentuate
spec:
type: db
owner: group:default/group-1 # user-1
# system
6 changes: 6 additions & 0 deletions plugins/accentuate-backend/examples/system-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: backstage.io/v1alpha1
kind: System
metadata:
name: system-accentuate
spec:
owner: group:default/group-accentuate # user
9 changes: 9 additions & 0 deletions plugins/accentuate-backend/examples/user-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: backstage.io/v1alpha1
kind: User
metadata:
name: user-accentuate
spec:
profile:
displayName: John Doe (accentuate)
# email: [email protected]
memberOf: []
9 changes: 9 additions & 0 deletions plugins/accentuate-backend/examples/user-2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: backstage.io/v1alpha1
kind: User
metadata:
name: user-accentuate-2
spec:
profile:
displayName: John Doe (accentuate) 2
# email: [email protected]
memberOf: []
Loading

0 comments on commit 9322ce0

Please sign in to comment.