cli: allow running with no configuration files

Co-authored-by: Patrik Oldsberg <poldsberg@gmail.com>
Signed-off-by: MT Lewis <mtlewis@users.noreply.github.com>
This commit is contained in:
MT Lewis
2024-07-18 11:10:18 +01:00
parent f93ae496ce
commit 493feaca4d
6 changed files with 47 additions and 12 deletions
+5 -1
View File
@@ -48,8 +48,12 @@ const BUILD_CACHE_ENV_VAR = 'BACKSTAGE_CLI_EXPERIMENTAL_BUILD_CACHE';
export function resolveBaseUrl(config: Config): URL {
const baseUrl = config.getOptionalString('app.baseUrl');
try {
return new URL(baseUrl ?? '/', 'http://localhost:3000');
return new URL(
baseUrl ?? '/',
`http://localhost:${process.env.PORT ?? '3000'}`,
);
} catch (error) {
throw new Error(`Invalid app.baseUrl, ${error}`);
}
+5 -3
View File
@@ -96,11 +96,13 @@ export async function loadCliConfig(options: Options) {
},
});
const configurationLoadedMessage = appConfigs.length
? `Loaded config from ${appConfigs.map(c => c.context).join(', ')}`
: `No configuration files found, running without config`;
// printing to stderr to not clobber stdout in case the cli command
// outputs structured data (e.g. as config:schema does)
process.stderr.write(
`Loaded config from ${appConfigs.map(c => c.context).join(', ')}\n`,
);
process.stderr.write(`${configurationLoadedMessage}\n`);
try {
const frontendAppConfigs = schema.process(appConfigs, {