-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(npm): add backend to fetch data from private registries
Signed-off-by: Christoph Jerolimov <jerolimov+git@redhat.com>
- Loading branch information
1 parent
1fbf57e
commit 414cc3b
Showing
61 changed files
with
1,612 additions
and
342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,117 @@ | ||
# [Backstage](https://backstage.io) | ||
# npm plugin for Backstage | ||
|
||
This is your newly scaffolded Backstage App, Good Luck! | ||
A Backstage plugin that shows information and latest releases/versions from a npm registry | ||
for catalog entities. | ||
|
||
To start the app, run: | ||
## Screenshots | ||
|
||
```sh | ||
yarn install | ||
yarn dev | ||
### Npm info card | ||
|
||
![Screenshot](docs/npm-info-card.png) | ||
|
||
### Npm release overview card | ||
|
||
![Screenshot](docs/npm-release-overview-card.png) | ||
|
||
### Extended catalog entity overview tab (example) | ||
|
||
![Screenshot](docs/catalog-entity-overview-tab.png) | ||
|
||
### New catalog entity npm release tab | ||
|
||
![Screenshot](docs/catalog-entity-npm-release-tab.png) | ||
|
||
## For users | ||
|
||
### Enable npm cards for a catalog entity | ||
|
||
To enable the different npm cards you must add the `npm/package` annotation | ||
with the name of the npm package: | ||
|
||
```yaml | ||
apiVersion: backstage.io/v1alpha1 | ||
kind: Component | ||
metadata: | ||
name: react | ||
annotations: | ||
npm/package: react | ||
``` | ||
The "npm info" card shows the information of the latest 'stable' npm release | ||
and use the common `latest` tag by default. This could be changed with `npm/stable-tag`: | ||
|
||
```yaml | ||
apiVersion: backstage.io/v1alpha1 | ||
kind: Component | ||
metadata: | ||
name: react | ||
annotations: | ||
npm/package: react | ||
npm/stable-tag: latest, stable, next, etc. | ||
``` | ||
|
||
To generate knip reports for this app, run: | ||
## For administrators | ||
|
||
### Install on Backstage | ||
|
||
1. Install the frontend plugin: | ||
|
||
```sh | ||
yarn workspace app add @backstage-community/plugin-npm | ||
``` | ||
|
||
2. Add cards based on your needs to `packages/app/src/components/catalog/EntityPage.tsx`: | ||
|
||
After all other imports: | ||
|
||
```tsx | ||
import { | ||
isNpmAvailable, | ||
EntityNpmInfoCard, | ||
EntityNpmReleaseOverviewCard, | ||
EntityNpmReleaseTableCard, | ||
} from '@backstage-community/plugin-npm'; | ||
``` | ||
|
||
3. Add to `const overviewContent` after `EntityAboutCard`: | ||
|
||
```tsx | ||
<EntitySwitch> | ||
<EntitySwitch.Case if={isNpmAvailable}> | ||
<Grid container item md={6} xs={12}> | ||
<Grid item md={12}> | ||
<EntityNpmInfoCard /> | ||
</Grid> | ||
<Grid item md={12}> | ||
<EntityNpmReleaseOverviewCard /> | ||
</Grid> | ||
</Grid> | ||
</EntitySwitch.Case> | ||
</EntitySwitch> | ||
``` | ||
|
||
4. Add to `const serviceEntityPage` and `const websiteEntityPage` after the `/ci-cd` case | ||
and to `const defaultEntityPage` between the `/` and `/docs` routecase. | ||
|
||
```tsx | ||
<EntityLayout.Route | ||
if={isNpmAvailable} | ||
path="/npm-releases" | ||
title="NPM Releases" | ||
> | ||
<EntityNpmReleaseTableCard /> | ||
</EntityLayout.Route> | ||
``` | ||
|
||
### Test catalog entities | ||
|
||
For testing purpose you can import this catalog entities: | ||
|
||
```sh | ||
yarn backstage-repo-tools knip-reports | ||
```yaml | ||
catalog: | ||
locations: | ||
- type: url | ||
target: https://github.com/backstage/community-plugins/blob/main/workspaces/npm/examples/entities.yaml | ||
rules: | ||
- allow: [System, Component] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes
Empty file.
File renamed without changes
File renamed without changes
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
# https://backstage.io/docs/features/software-catalog/descriptor-format#kind-system | ||
apiVersion: backstage.io/v1alpha1 | ||
kind: System | ||
metadata: | ||
name: backstage | ||
spec: | ||
owner: guests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
# https://backstage.io/docs/features/software-catalog/descriptor-format#kind-component | ||
apiVersion: backstage.io/v1alpha1 | ||
kind: Component | ||
metadata: | ||
name: github-packages-examples | ||
annotations: | ||
npm/registry: github | ||
npm/package: '@github-packages-examples/npm-publish' | ||
spec: | ||
type: library | ||
lifecycle: production | ||
owner: guests | ||
system: backstage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
site_name: Backstage Community Npm Plugin | ||
site_description: A Backstage plugin that shows meta info and latest versions from a npm registry | ||
|
||
plugins: | ||
- techdocs-core | ||
|
||
nav: | ||
- Customization: index.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../README.md |
Oops, something went wrong.