From f1010a875164ac8e8dcf12a7881fbc32b376c07c Mon Sep 17 00:00:00 2001 From: Lucas <116588+hairmare@users.noreply.github.com> Date: Thu, 26 Dec 2024 20:00:16 +0100 Subject: [PATCH] feat: Backstage 1.34.2 (#355) --- .dockerignore | 1 - .github/workflows/test.yaml | 3 +- .gitignore | 2 +- Dockerfile | 12 +- README.md | 2 +- app-config.production.yaml | 10 + app-config.yaml | 16 +- backstage.json | 2 +- lerna.json | 6 - package.json | 14 +- packages/app/e2e-tests/app.test.ts | 5 + packages/app/package.json | 70 +- packages/app/public/index.html | 2 +- packages/app/src/App.tsx | 11 +- packages/app/src/apis.ts | 13 +- .../app/src/components/catalog/EntityPage.tsx | 6 +- packages/backend/package.json | 75 +- packages/backend/src/index.test.ts | 8 - packages/backend/src/index.ts | 64 +- packages/backend/src/plugins/auth.ts | 88 - packages/backend/src/plugins/catalog.ts | 71 - packages/backend/src/plugins/permission.ts | 87 - packages/backend/src/plugins/scaffolder.ts | 35 - packages/backend/src/types.ts | 25 - playwright.config.ts | 2 +- .../.eslintrc.js | 1 + .../README.md | 6 + .../package.json | 42 + .../src/index.ts | 8 + .../src/module.ts | 50 + .../.eslintrc.js | 1 + .../permission-backend-module-rabe/README.md | 5 + .../package.json | 46 + .../src/index.ts | 8 + .../src/module.ts | 19 + .../src/policy.ts | 36 + tsconfig.json | 2 + yarn.lock | 11137 ++++++++-------- 38 files changed, 5876 insertions(+), 6115 deletions(-) delete mode 100644 lerna.json delete mode 100644 packages/backend/src/index.test.ts delete mode 100644 packages/backend/src/plugins/auth.ts delete mode 100644 packages/backend/src/plugins/catalog.ts delete mode 100644 packages/backend/src/plugins/permission.ts delete mode 100644 packages/backend/src/plugins/scaffolder.ts delete mode 100644 packages/backend/src/types.ts create mode 100644 plugins/catalog-backend-module-transformer/.eslintrc.js create mode 100644 plugins/catalog-backend-module-transformer/README.md create mode 100644 plugins/catalog-backend-module-transformer/package.json create mode 100644 plugins/catalog-backend-module-transformer/src/index.ts create mode 100644 plugins/catalog-backend-module-transformer/src/module.ts create mode 100644 plugins/permission-backend-module-rabe/.eslintrc.js create mode 100644 plugins/permission-backend-module-rabe/README.md create mode 100644 plugins/permission-backend-module-rabe/package.json create mode 100644 plugins/permission-backend-module-rabe/src/index.ts create mode 100644 plugins/permission-backend-module-rabe/src/module.ts create mode 100644 plugins/permission-backend-module-rabe/src/policy.ts diff --git a/.dockerignore b/.dockerignore index ab0b67d..9b46c19 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,7 +2,6 @@ .yarn/install-state.gz node_modules packages/*/node_modules -plugins *.local.yaml trivy.* eslint_report.json diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 1b98ae4..627bf28 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -22,7 +22,7 @@ jobs: id-token: none strategy: matrix: - node-version: [20] + node-version: [22] steps: - uses: actions/checkout@v4 with: @@ -41,4 +41,5 @@ jobs: report-json: "eslint_report.json" only-pr-files: false continue-on-error: true + - run: yarn tsc - run: yarn test diff --git a/.gitignore b/.gitignore index 9267554..17acc2b 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,7 @@ coverage # Dependencies node_modules -# Yarn 3 files +# Yarn files .pnp.* .yarn/* !.yarn/patches diff --git a/Dockerfile b/Dockerfile index d6bfe2d..877d6b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Stage 1 - Install dependencies -FROM registry.access.redhat.com/ubi9/nodejs-20:latest AS deps +FROM registry.access.redhat.com/ubi9/nodejs-22:latest AS deps USER 0 # Install yarn and libs for building isolated-vm with node-gyp @@ -8,17 +8,18 @@ RUN curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/ COPY ./package.json ./yarn.lock ./ COPY ./packages ./packages +COPY ./plugins ./plugins COPY .yarnrc.yml ./ COPY .yarn/ ./.yarn # Remove all files except package.json -RUN find packages -mindepth 2 -maxdepth 2 \! -name "package.json" -exec rm -rf {} \+ +RUN find packages plugins -mindepth 2 -maxdepth 2 \! -name "package.json" -exec rm -rf {} \+ RUN yarn install --immutable --network-timeout 600000 RUN chown 1001:0 ".yarn/install-state.gz" # Stage 2 - Build packages -FROM registry.access.redhat.com/ubi9/nodejs-20:latest AS build +FROM registry.access.redhat.com/ubi9/nodejs-22:latest AS build USER 0 # Install yarn @@ -33,14 +34,14 @@ RUN yarn tsc RUN yarn build:backend # Stage 3 - Build the actual backend image and install production dependencies -FROM ghcr.io/radiorabe/ubi9-minimal:0.6.6 +FROM ghcr.io/radiorabe/ubi9-minimal:0.8.0 ENV APP_ROOT=/opt/app-root \ # The $HOME is not set by default, but some applications need this variable HOME=/opt/app-root/src \ NPM_RUN=start \ PLATFORM="el9" \ - NODEJS_VERSION=20 \ + NODEJS_VERSION=22 \ NPM_RUN=start \ NAME=backstage @@ -91,6 +92,7 @@ RUN microdnf -y module disable nodejs \ mkdocs-autorefs \ 'mkdocstrings[python]' \ mkdocs-techdocs-core \ + mkdocs-monorepo-plugin \ && microdnf clean all \ && useradd -u 1001 -r -g 0 -s /sbin/nologin \ -c "Default Application User" default \ diff --git a/README.md b/README.md index 3b683ee..9c51177 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ yarn dev To keep it updated, run: ```sh -yarn backstage-cli versions:bump --pattern '@{backstage,roadiehq,janus-idp}/*' +yarn backstage-cli versions:bump --pattern '@{backstage,backstage-community,roadiehq,janus-idp}/*' ``` ## Release Management diff --git a/app-config.production.yaml b/app-config.production.yaml index ddafeda..51fbd47 100644 --- a/app-config.production.yaml +++ b/app-config.production.yaml @@ -30,6 +30,16 @@ backend: cache: store: memory +integrations: + github: + - host: github.com + # This is a GitHub App that was generated using the backstage-cli. You can find out how to generate the credentials + # file, and more information about setting up the GitHub integration here: + # * https://backstage.io/docs/integrations/github/locations#configuration + # * https://backstage.io/docs/integrations/github/github-apps + apps: + - $include: github-app-backstage-credentials.yaml + auth: environment: production diff --git a/app-config.yaml b/app-config.yaml index a79c0ad..b9504cc 100644 --- a/app-config.yaml +++ b/app-config.yaml @@ -2,12 +2,12 @@ app: title: RaBe Backstage baseUrl: http://localhost:3000 support: - url: https://github.com/radiorabe/backstage/issues + url: https://github.com/radiorabe/rabe-backstage/issues items: - title: Issues icon: github links: - - url: https://github.com/radiorabe/backstage/issues + - url: https://github.com/radiorabe/rabe-backstage/issues title: GitHub Issues organization: @@ -40,13 +40,6 @@ backend: connection: ":memory:" # workingDirectory: /tmp # Use this to configure a working directory for the scaffolder, defaults to the OS temp-dir -integrations: - github: - - host: github.com - # This is a Personal Access Token or PAT from GitHub. You can find out how to generate this token, and more information - # about setting up the GitHub integration here: https://backstage.io/docs/getting-started/configuration#setting-up-a-github-integration - token: ${GITHUB_TOKEN} - proxy: endpoints: ### Allow calling github api from scaffolder-backend-module-http-request @@ -71,12 +64,15 @@ auth: session: secret: ${SESSION_SECRET} providers: - keycloak: + oidc: production: prompt: auto metadataUrl: ${AUTH_KEYCLOAK_METADATA_URL} clientId: ${AUTH_KEYCLOAK_CLIENT_ID} clientSecret: ${AUTH_KEYCLOAK_CLIENT_SECRET} + signIn: + resolvers: + - resolver: emailMatchingUserEntityProfileEmail github: production: clientId: ${AUTH_GITHUB_CLIENT_ID} diff --git a/backstage.json b/backstage.json index dd15498..22366f4 100644 --- a/backstage.json +++ b/backstage.json @@ -1,3 +1,3 @@ { - "version": "1.23.4" + "version": "1.34.2" } diff --git a/lerna.json b/lerna.json deleted file mode 100644 index 529a62f..0000000 --- a/lerna.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "packages": ["packages/*", "plugins/*"], - "npmClient": "yarn", - "version": "0.1.0", - "$schema": "node_modules/lerna/schemas/lerna-schema.json" -} diff --git a/package.json b/package.json index 0a9db4e..9b7bc81 100644 --- a/package.json +++ b/package.json @@ -3,10 +3,10 @@ "version": "1.0.0", "private": true, "engines": { - "node": "18 || 20" + "node": "22" }, "scripts": { - "dev": "concurrently \"yarn start\" \"yarn start-backend\"", + "dev": "yarn workspaces foreach -A --include backend --include app --parallel -v -i run start", "start": "yarn workspace app start", "start-backend": "yarn workspace backend start", "build:backend": "yarn workspace backend build", @@ -32,20 +32,18 @@ "@backstage/cli": "^0.29.4", "@backstage/e2e-test-utils": "^0.1.1", "@playwright/test": "^1.41.2", - "@spotify/prettier-config": "^15.0.0", "@types/react": "^18", "@types/react-dom": "^18", - "concurrently": "^8.2.2", - "lerna": "^8.1.2", - "node-gyp": "^10.0.1", + "eslint-plugin-jest": "^28.10.0", + "node-gyp": "^11.0.0", "prettier": "^3.2.5", - "typescript": "~5.4.2" + "typescript": "~5.7.2" }, "resolutions": { "@types/react": "^18", "@types/react-dom": "^18" }, - "prettier": "@spotify/prettier-config", + "prettier": "@backstage/cli/config/prettier", "lint-staged": { "*.{js,jsx,ts,tsx,mjs,cjs}": [ "eslint --fix", diff --git a/packages/app/e2e-tests/app.test.ts b/packages/app/e2e-tests/app.test.ts index b02ff3e..f5af45c 100644 --- a/packages/app/e2e-tests/app.test.ts +++ b/packages/app/e2e-tests/app.test.ts @@ -17,5 +17,10 @@ import { test, expect } from '@playwright/test'; test('App should render the welcome page', async ({ page }) => { await page.goto('/'); + + const enterButton = page.getByRole('button', { name: 'Enter' }); + await expect(enterButton).toBeVisible(); + await enterButton.click(); + await expect(page.getByText('My Company Catalog')).toBeVisible(); }); diff --git a/packages/app/package.json b/packages/app/package.json index 24bd1d5..f5e1629 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -14,55 +14,53 @@ "lint": "backstage-cli package lint" }, "dependencies": { - "@backstage/app-defaults": "^1.5.0", - "@backstage/catalog-model": "^1.4.4", + "@backstage-community/plugin-github-actions": "^0.7.0", + "@backstage-community/plugin-github-pull-requests-board": "^0.3.0", + "@backstage-community/plugin-todo": "^0.3.0", + "@backstage/app-defaults": "^1.5.15", + "@backstage/catalog-model": "^1.7.2", "@backstage/cli": "^0.29.4", - "@backstage/core-app-api": "^1.12.0", - "@backstage/core-components": "^0.14.0", - "@backstage/core-plugin-api": "^1.9.0", - "@backstage/integration-react": "^1.1.24", - "@backstage/plugin-api-docs": "^0.11.0", - "@backstage/plugin-catalog": "^1.17.0", - "@backstage/plugin-catalog-common": "^1.0.21", - "@backstage/plugin-catalog-graph": "^0.4.0", - "@backstage/plugin-catalog-import": "^0.10.6", - "@backstage/plugin-catalog-react": "^1.10.0", - "@backstage/plugin-catalog-unprocessed-entities": "^0.1.8", - "@backstage/plugin-devtools": "^0.1.9", - "@backstage/plugin-devtools-common": "^0.1.8", - "@backstage/plugin-github-actions": "^0.6.11", - "@backstage/plugin-github-pull-requests-board": "^0.1.24", - "@backstage/plugin-home": "^0.6.2", - "@backstage/plugin-org": "^0.6.20", - "@backstage/plugin-permission-react": "^0.4.20", - "@backstage/plugin-scaffolder": "^1.18.0", - "@backstage/plugin-search": "^1.4.6", - "@backstage/plugin-search-react": "^1.7.6", - "@backstage/plugin-tech-radar": "^0.6.13", - "@backstage/plugin-techdocs": "^1.10.0", - "@backstage/plugin-techdocs-module-addons-contrib": "^1.1.5", - "@backstage/plugin-techdocs-react": "^1.1.16", - "@backstage/plugin-todo": "^0.2.34", - "@backstage/plugin-user-settings": "^0.8.1", - "@backstage/theme": "^0.5.1", + "@backstage/core-app-api": "^1.15.3", + "@backstage/core-components": "^0.16.2", + "@backstage/core-plugin-api": "^1.10.2", + "@backstage/integration-react": "^1.2.2", + "@backstage/plugin-api-docs": "^0.12.2", + "@backstage/plugin-catalog": "^1.26.0", + "@backstage/plugin-catalog-common": "^1.1.2", + "@backstage/plugin-catalog-graph": "^0.4.14", + "@backstage/plugin-catalog-import": "^0.12.8", + "@backstage/plugin-catalog-react": "^1.15.0", + "@backstage/plugin-catalog-unprocessed-entities": "^0.2.12", + "@backstage/plugin-devtools": "^0.1.22", + "@backstage/plugin-devtools-common": "^0.1.14", + "@backstage/plugin-home": "^0.8.3", + "@backstage/plugin-org": "^0.6.34", + "@backstage/plugin-permission-react": "^0.4.29", + "@backstage/plugin-scaffolder": "^1.27.3", + "@backstage/plugin-search": "^1.4.21", + "@backstage/plugin-search-react": "^1.8.4", + "@backstage/plugin-techdocs": "^1.12.0", + "@backstage/plugin-techdocs-module-addons-contrib": "^1.1.19", + "@backstage/plugin-techdocs-react": "^1.2.12", + "@backstage/plugin-user-settings": "^0.8.17", + "@backstage/theme": "^0.6.3", "@material-ui/core": "^4.12.4", "@material-ui/icons": "^4.11.3", - "@roadiehq/backstage-plugin-github-insights": "^2.3.27", - "history": "^5.3.0", + "@roadiehq/backstage-plugin-github-insights": "^2.5.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-router": "^6.22.1", - "react-router-dom": "^6.22.1", - "react-use": "^17.5.0" + "react-router-dom": "^6.22.1" }, "devDependencies": { - "@backstage/test-utils": "^1.5.0", + "@backstage/test-utils": "^1.7.3", "@playwright/test": "^1.41.2", "@testing-library/dom": "^10.0.0", "@testing-library/jest-dom": "^6.4.2", "@testing-library/react": "^16.1.0", "@testing-library/user-event": "^14.5.2", - "@types/node": "^20", + "@types/node": "^22", + "@types/react": "^18", "@types/react-dom": "^18", "cross-env": "^7.0.3" }, diff --git a/packages/app/public/index.html b/packages/app/public/index.html index 3337729..0c5fc4b 100644 --- a/packages/app/public/index.html +++ b/packages/app/public/index.html @@ -6,7 +6,7 @@