Merge pull request #30096 from pfeifferj/gh-29512-add-browser-feedback

fix(cli): add user feedback when opening config docs in browser
This commit is contained in:
Fredrik Adelöw
2025-06-04 15:37:44 +02:00
committed by GitHub
2 changed files with 25 additions and 1 deletions
@@ -0,0 +1,5 @@
---
'@backstage/cli': patch
---
Added user feedback when opening config docs in browser. The command now clearly indicates what it's doing and provides fallback instructions if the browser fails to open.
@@ -19,6 +19,7 @@ import { mergeConfigSchemas } from '@backstage/config-loader';
import { OptionValues } from 'commander';
import { JSONSchema7 as JSONSchema } from 'json-schema';
import openBrowser from 'react-dev-utils/openBrowser';
import chalk from 'chalk';
import { loadCliConfig } from '../lib/config';
const DOCS_URL = 'https://config.backstage.io';
@@ -36,5 +37,23 @@ export default async (opts: OptionValues) => {
),
);
openBrowser(`${DOCS_URL}#schema=${JSON.stringify(schema)}`);
const url = `${DOCS_URL}#schema=${JSON.stringify(schema)}`;
console.log();
console.log(
chalk.cyan(
'Opening configuration reference documentation in your browser...',
),
);
console.log(` ${chalk.cyan(url)}`);
console.log();
const opened = openBrowser(url);
if (!opened) {
console.log(
chalk.yellow('⚠️ WARNING: Unable to open browser automatically.'),
);
console.log(chalk.yellow('Please open the URL manually in your browser.'));
}
};