Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,15 @@ module.exports = {
].flat(),
},
overrides: [
{
// .cjs is not matched by **/*.[jt]s?(x); without this, espree defaults to ES5 and
// modern syntax (const, class fields) in e.g. jest-environment-*.cjs fails parsing.
files: ['**/*.cjs'],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'script',
},
},
{
files: ['**/*.[jt]s?(x)'],
excludedFiles: '**/*.{test,spec}.[jt]s?(x)',
Expand Down
43 changes: 43 additions & 0 deletions workspaces/app-defaults/.lintstagedrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

const path = require('path');

/**
* ESLint ignores config-style dotfiles by default; passing them on the CLI only
* produces noise. Skip eslint/prettier for those; still format via other globs if needed.
*/
function skipLintStagedEslintPrettier(file) {
const base = path.basename(file.replace(/\\/g, '/'));
return base === '.eslintrc.js' || base === '.lintstagedrc.cjs';
}

module.exports = {
'*.{js,jsx,ts,tsx,mjs,cjs}': filenames => {
const filtered = filenames.filter(f => !skipLintStagedEslintPrettier(f));
if (!filtered.length) {
return [];
}
const quoted = filtered.map(f => JSON.stringify(f));
return [
`eslint --fix ${quoted.join(' ')}`,
`prettier --write ${quoted.join(' ')}`,
];
},
'*.{json,md}': ['prettier --write'],
};
29 changes: 26 additions & 3 deletions workspaces/app-defaults/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
# [Backstage](https://backstage.io)

This is your newly scaffolded Backstage App, Good Luck!
RHDH **app-defaults** workspace: sample new-frontend-system app plus shared plugins (`app-react`, `app-auth`, `app-integrations`).

To start the app, run:
## Local app shell

To start the app from this directory:

```sh
yarn install
yarn dev
yarn start
```

### Static `app-auth` wiring

The sample app in [`packages/app`](packages/app) loads RHDH sign-in and OIDC/Auth0/SAML frontend APIs by importing **`appAuthModule`** from `@red-hat-developer-hub/backstage-plugin-app-auth/alpha` and passing it to `createApp({ features: [...] })`. That mirrors how you can mount the module **statically** for local development and tests.

In **RHDH**, the same module is intended to be loaded **dynamically** via `@backstage/frontend-dynamic-feature-loader` and your export/overlays pipeline—not by editing the product `app-next` shell.

### Static `app-integrations` wiring

The sample app imports **`appIntegrationsModule`** from `@red-hat-developer-hub/backstage-plugin-app-integrations/alpha` and adds it to `createApp({ features: [...] })` (after `appAuthModule`). It registers **`scmIntegrationsApiRef`** and **`scmAuthApiRef`** on `pluginId: 'app'`, matching the classic RHDH [`packages/app` `apis.ts`](https://github.com/redhat-developer/rhdh/blob/main/packages/app/src/apis.ts) SCM factories—so catalog import, scaffolder, and similar features get the same default SCM auth behavior.

Deployments that want different SCM wiring can omit this module and supply their own dynamic (or static) module that registers those refs instead.

In **RHDH**, this module is expected to ship and load **dynamically** alongside `app-auth`, not via edits to `app-next`.

### Config for `app-auth`

- **`auth.environment`**: set to `development` locally so the RHDH sign-in page includes the **guest** provider (needed for [`App.test.tsx`](packages/app/src/App.test.tsx) inline `APP_CONFIG`, [`app-config.yaml`](app-config.yaml) for `yarn start` / Playwright, and typical dev flows).
- **`signInPage`** (optional, root key): string or list of provider ids (e.g. `github`, `oidc`) for the RHDH multi-provider sign-in page. Schema lives on the `backstage-plugin-app-auth` package.

## Other commands

To generate knip reports for this app, run:

```sh
Expand Down
2 changes: 2 additions & 0 deletions workspaces/app-defaults/app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ techdocs:
type: 'local' # Alternatives - 'googleGcs' or 'awsS3'. Read documentation for using alternatives.

auth:
# Required for RHDH app-auth SignInPage (guest in dev) and local e2e
environment: development
# see https://backstage.io/docs/auth/ to learn about auth providers
providers:
# See https://backstage.io/docs/auth/guest/provider
Expand Down
12 changes: 2 additions & 10 deletions workspaces/app-defaults/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"fix": "backstage-cli repo fix",
"lint": "backstage-cli repo lint --since origin/main",
"lint:all": "backstage-cli repo lint",
"prettier:fix": "prettier --write .",
"prettier:check": "prettier --check .",
"new": "backstage-cli new --scope @red-hat-developer-hub",
"postinstall": "cd ../../ && yarn install"
Expand Down Expand Up @@ -51,14 +52,5 @@
"@types/react": "^18",
"@types/react-dom": "^18"
},
"prettier": "@spotify/prettier-config",
"lint-staged": {
"*.{js,jsx,ts,tsx,mjs,cjs}": [
"eslint --fix",
"prettier --write"
],
"*.{json,md}": [
"prettier --write"
]
}
"prettier": "@spotify/prettier-config"
}
15 changes: 11 additions & 4 deletions workspaces/app-defaults/packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"backstage": {
"role": "frontend"
},
"jest": {
"testEnvironment": "@internal/jest-environment-jsdom-suppress-css"
},
"scripts": {
"start": "backstage-cli package start",
"build": "backstage-cli package build",
Expand Down Expand Up @@ -44,6 +47,8 @@
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
"@mui/material": "^5.18.0",
"@red-hat-developer-hub/backstage-plugin-app-auth": "workspace:^",
"@red-hat-developer-hub/backstage-plugin-app-integrations": "workspace:^",
"@red-hat-developer-hub/backstage-plugin-app-react": "workspace:^",
"react": "^18.0.2",
"react-dom": "^18.0.2",
Expand All @@ -52,13 +57,15 @@
},
"devDependencies": {
"@backstage/frontend-test-utils": "^0.5.1",
"@playwright/test": "^1.32.3",
"@testing-library/dom": "^9.0.0",
"@internal/jest-environment-jsdom-suppress-css": "workspace:^",
"@playwright/test": "^1.58.2",
"@testing-library/dom": "^10.0.0",
"@testing-library/jest-dom": "^6.0.0",
"@testing-library/react": "^14.0.0",
"@testing-library/react": "^16.0.0",
"@testing-library/user-event": "^14.0.0",
"@types/react-dom": "*",
"cross-env": "^7.0.0"
"cross-env": "^10.0.0",
"cross-fetch": "^4.0.0"
},
"browserslist": {
"production": [
Expand Down
1 change: 1 addition & 0 deletions workspaces/app-defaults/packages/app/src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('App', () => {
{
data: {
app: { title: 'Test' },
auth: { environment: 'development' },
backend: { baseUrl: 'http://localhost:7007' },
techdocs: {
storageUrl: 'http://localhost:7007/api/techdocs/static/docs',
Expand Down
11 changes: 10 additions & 1 deletion workspaces/app-defaults/packages/app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,19 @@

import { createApp } from '@backstage/frontend-defaults';
import catalogPlugin from '@backstage/plugin-catalog/alpha';
import { appAuthModule } from '@red-hat-developer-hub/backstage-plugin-app-auth/alpha';
import { appIntegrationsModule } from '@red-hat-developer-hub/backstage-plugin-app-integrations/alpha';
import { appDrawerModule } from '@red-hat-developer-hub/backstage-plugin-app-react/alpha';
import { navModule } from './modules/nav';
import { drawerDemoModule } from './modules/drawer-demo';

export default createApp({
features: [catalogPlugin, navModule, appDrawerModule, drawerDemoModule],
features: [
catalogPlugin,
navModule,
appAuthModule,
appIntegrationsModule,
appDrawerModule,
drawerDemoModule,
],
});
3 changes: 3 additions & 0 deletions workspaces/app-defaults/packages/app/src/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@
* limitations under the License.
*/

// Still needed when testEnvironment is not the default jsdom (Backstage only injects
// cross-fetch for the stock jest-environment-jsdom).
import 'cross-fetch/polyfill';
import '@testing-library/jest-dom';
Loading
Loading