Merge pull request #22761 from backstage/rugvip/allow-empty

cli: stop requiring configuration for the frontend build
This commit is contained in:
Patrik Oldsberg
2024-02-09 13:11:54 +01:00
committed by GitHub
10 changed files with 26 additions and 13 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/config-loader': patch
---
Make schema processing gracefully handle an empty config.
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/create-app': patch
---
Updated the default app index template at `packages/app/public/index.html` to have a fallback value for the `app.title` config.
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---
Make `http://localhost:3000` the default base URL for serving locally, and `/` the default public path for built apps. The app build no longer requires any configuration values to be present.
+1 -1
View File
@@ -41,7 +41,7 @@
href="<%= publicPath %>/safari-pinned-tab.svg"
color="#5bbad5"
/>
<title><%= config.getString('app.title') %></title>
<title><%= config.getOptionalString('app.title') ?? 'Backstage' %></title>
<% if (config.has('app.datadogRum')) { %>
<script>
+1 -2
View File
@@ -23,7 +23,7 @@ import {
printFileSizesAfterBuild,
} from 'react-dev-utils/FileSizeReporter';
import formatWebpackMessages from 'react-dev-utils/formatWebpackMessages';
import { createConfig, resolveBaseUrl } from './config';
import { createConfig } from './config';
import { BuildOptions } from './types';
import { resolveBundlingPaths, resolveOptionalBundlingPaths } from './paths';
import chalk from 'chalk';
@@ -51,7 +51,6 @@ export async function buildBundle(options: BuildOptions) {
...options,
checksEnabled: false,
isDev: false,
baseUrl: resolveBaseUrl(options.frontendConfig),
getFrontendAppConfigs: () => options.frontendAppConfigs,
};
const configs = [
+3 -4
View File
@@ -44,9 +44,9 @@ import { hasReactDomClient } from './hasReactDomClient';
const BUILD_CACHE_ENV_VAR = 'BACKSTAGE_CLI_EXPERIMENTAL_BUILD_CACHE';
export function resolveBaseUrl(config: Config): URL {
const baseUrl = config.getString('app.baseUrl');
const baseUrl = config.getOptionalString('app.baseUrl');
try {
return new URL(baseUrl);
return new URL(baseUrl ?? '/', 'http://localhost:3000');
} catch (error) {
throw new Error(`Invalid app.baseUrl, ${error}`);
}
@@ -100,8 +100,7 @@ export async function createConfig(
const { packages } = await getPackages(cliPaths.targetDir);
const externalPkgs = packages.filter(p => !isChildPath(paths.root, p.dir));
const baseUrl = frontendConfig.getString('app.baseUrl');
const validBaseUrl = new URL(baseUrl);
const validBaseUrl = resolveBaseUrl(frontendConfig);
let publicPath = validBaseUrl.pathname.replace(/\/$/, '');
if (publicSubPath) {
publicPath = `${publicPath}${publicSubPath}`.replace('//', '/');
+4 -3
View File
@@ -110,9 +110,10 @@ DEPRECATION WARNING: React Router Beta is deprecated and support for it will be
});
latestFrontendAppConfigs = cliConfig.frontendAppConfigs;
const appBaseUrl = cliConfig.frontendConfig.getString('app.baseUrl');
const backendBaseUrl = cliConfig.frontendConfig.getString('backend.baseUrl');
if (appBaseUrl === backendBaseUrl) {
const appBaseUrl = cliConfig.frontendConfig.getOptionalString('app.baseUrl');
const backendBaseUrl =
cliConfig.frontendConfig.getOptionalString('backend.baseUrl');
if (appBaseUrl && appBaseUrl === backendBaseUrl) {
console.log(
chalk.yellow(
`⚠️ Conflict between app baseUrl and backend baseUrl:
-1
View File
@@ -23,7 +23,6 @@ export type BundlingOptions = {
isDev: boolean;
frontendConfig: Config;
getFrontendAppConfigs(): AppConfig[];
baseUrl: URL;
parallelism?: number;
additionalEntryPoints?: string[];
// Path to append to the detected public path, e.g. '/public'
+1 -1
View File
@@ -190,7 +190,7 @@ export function compileConfigSchemas(
});
return configs => {
const config = ConfigReader.fromConfigs(configs).get();
const config = ConfigReader.fromConfigs(configs).getOptional();
visibilityByDataPath.clear();
deepVisibilityByDataPath.clear();
@@ -41,7 +41,7 @@
href="<%= publicPath %>/safari-pinned-tab.svg"
color="#5bbad5"
/>
<title><%= config.getString('app.title') %></title>
<title><%= config.getOptionalString('app.title') ?? 'Backstage' %></title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>