Skip to content

Commit 33fd24b

Browse files
committed
Init
0 parents  commit 33fd24b

File tree

11 files changed

+260
-0
lines changed

11 files changed

+260
-0
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);

.github/workflows/ci.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: CI & Publish
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v3
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: 18
20+
cache: 'yarn'
21+
22+
- name: Install dependencies
23+
run: yarn install --frozen-lockfile
24+
25+
- name: Run TypeScript checks
26+
run: yarn tsc
27+
28+
- name: Lint the code
29+
run: yarn lint
30+
31+
- name: Run tests
32+
run: yarn test
33+
34+
- name: Build the plugin
35+
run: yarn build
36+
37+
- name: Upload build artifacts
38+
uses: actions/upload-artifact@v3
39+
with:
40+
name: backstage-plugin-build
41+
path: |
42+
.
43+
!node_modules
44+
45+
publish:
46+
needs: build
47+
runs-on: ubuntu-latest
48+
if: github.ref == 'refs/heads/main'
49+
steps:
50+
- name: Download build artifacts
51+
uses: actions/download-artifact@v3
52+
with:
53+
name: backstage-plugin-build
54+
55+
- name: Setup Node.js
56+
uses: actions/setup-node@v3
57+
with:
58+
node-version: 18
59+
registry-url: 'https://registry.npmjs.org/'
60+
61+
- name: Get package version
62+
id: package
63+
run: echo "version=$(jq -r .version package.json)" >> $GITHUB_ENV
64+
65+
- name: Publish to npm
66+
run: yarn publish --access public
67+
env:
68+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
69+
70+
- name: Create GitHub Release
71+
uses: ncipollo/release-action@v1
72+
with:
73+
tag: v${{ env.version }}
74+
name: Release v${{ env.version }}
75+
body: "Automated release of version v${{ env.version }}"
76+
draft: false
77+
prerelease: false
78+
token: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Language info card
2+
3+
Add a card component that add language info on the "Overview" page.
4+
5+
<img alt="header" src="./images/overview-card.png" />
6+
7+
# Getting started
8+
9+
1. Install the plugin
10+
11+
```
12+
yarn add @hpatoio/language-info
13+
```
14+
15+
2. Modify your entity page
16+
17+
Open `packages/app/src/components/catalog/EntityPage.tsx` and add
18+
19+
```tsx
20+
import { EntityLanguageInfoCard } from '@internal/plugin-language-info';
21+
```
22+
23+
then `EntityLanguageInfoCard` in `overviewContent`
24+
25+
```tsx
26+
<Grid item md={6}>
27+
<EntityLanguageInfoCard />
28+
</Grid>
29+
```
30+
31+
2. Tag your component with the right tag
32+
33+
For example if you want to extract the PHP version add `php` tag.
34+
35+
```
36+
apiVersion: backstage.io/v1alpha1
37+
kind: Component
38+
metadata:
39+
name: dummy-prj
40+
tags:
41+
- foo
42+
- php
43+
- bar
44+
[...]
45+
```
46+
47+
# Dependencies
48+
49+
This plugin requires `plugin-language-info-backend`.

dev/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { createDevApp } from '@backstage/dev-utils';
2+
import { languageInfoPlugin} from '../src/plugin';
3+
4+
createDevApp()
5+
.registerPlugin(languageInfoPlugin)
6+
.render();

images/overview-card.png

11.2 KB
Loading

package.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "@hpatoio/plugin-language-info",
3+
"version": "0.1.0",
4+
"license": "Apache-2.0",
5+
"private": true,
6+
"main": "src/index.ts",
7+
"types": "src/index.ts",
8+
"publishConfig": {
9+
"access": "public",
10+
"main": "dist/index.esm.js",
11+
"types": "dist/index.d.ts"
12+
},
13+
"backstage": {
14+
"role": "frontend-plugin"
15+
},
16+
"sideEffects": false,
17+
"scripts": {
18+
"start": "backstage-cli package start",
19+
"build": "backstage-cli package build",
20+
"lint": "backstage-cli package lint",
21+
"test": "backstage-cli package test",
22+
"clean": "backstage-cli package clean",
23+
"prepack": "backstage-cli package prepack",
24+
"postpack": "backstage-cli package postpack"
25+
},
26+
"dependencies": {
27+
"@backstage/core-components": "^0.16.4",
28+
"@backstage/core-plugin-api": "^1.10.4",
29+
"@backstage/plugin-catalog": "^1.27.0",
30+
"@backstage/plugin-catalog-react": "^1.15.2",
31+
"@backstage/theme": "^0.6.4",
32+
"@material-ui/core": "^4.9.13",
33+
"@material-ui/icons": "^4.9.1",
34+
"@material-ui/lab": "^4.0.0-alpha.61",
35+
"react-use": "^17.2.4"
36+
},
37+
"peerDependencies": {
38+
"react": "^16.13.1 || ^17.0.0 || ^18.0.0"
39+
},
40+
"devDependencies": {
41+
"@backstage/cli": "^0.30.0",
42+
"@backstage/core-app-api": "^1.15.5",
43+
"@backstage/dev-utils": "^1.1.7",
44+
"@backstage/test-utils": "^1.7.5",
45+
"@testing-library/jest-dom": "^6.0.0",
46+
"@testing-library/react": "^14.0.0",
47+
"@testing-library/user-event": "^14.0.0",
48+
"msw": "^1.0.0",
49+
"react": "^16.13.1 || ^17.0.0 || ^18.0.0"
50+
},
51+
"files": [
52+
"dist"
53+
]
54+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import {
2+
useEntity,
3+
} from '@backstage/plugin-catalog-react';
4+
import {
5+
AboutField
6+
} from '@backstage/plugin-catalog';
7+
8+
9+
import React from 'react';
10+
11+
import { Card, CardHeader, CardContent, Divider, Grid } from '@material-ui/core';
12+
13+
14+
/**
15+
* Card for the catalog (entity page) that shows the language info
16+
*
17+
* @public
18+
*/
19+
export const EntityLanguageInfoCard = () => {
20+
21+
const { entity } = useEntity();
22+
23+
return (
24+
<Card className="gridItemCard">
25+
<CardHeader
26+
title='Language Info'
27+
/>
28+
<Divider />
29+
<CardContent className="gridItemCardContent">
30+
<Grid container>
31+
<AboutField
32+
label='Language'
33+
value={entity.metadata.annotations?.["language-info/name"]}
34+
gridSizes={{ xs: 12, sm: 6, lg: 4 }}
35+
/>
36+
<AboutField
37+
label='Version'
38+
value={entity.metadata.annotations?.["language-info/version"]}
39+
gridSizes={{ xs: 12, sm: 6, lg: 4 }}
40+
/>
41+
</Grid>
42+
</CardContent>
43+
</Card>
44+
);
45+
};

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { languageInfoPlugin, EntityLanguageInfoCard } from './plugin';

src/plugin.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { languageInfoPlugin } from './plugin';
2+
3+
describe('language-info', () => {
4+
it('should export plugin', () => {
5+
expect(languageInfoPlugin).toBeDefined();
6+
});
7+
});

src/plugin.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {
2+
createPlugin,
3+
createComponentExtension,
4+
} from '@backstage/core-plugin-api';
5+
6+
export const languageInfoPlugin = createPlugin({
7+
id: 'language-info'
8+
});
9+
10+
export const EntityLanguageInfoCard = languageInfoPlugin.provide(
11+
createComponentExtension({
12+
name: 'EntityLanguageInfoCard',
13+
component: {
14+
lazy: () =>
15+
import('./components/EntityLanguageInfoCard').then(m => m.EntityLanguageInfoCard),
16+
},
17+
}),
18+
);

0 commit comments

Comments
 (0)