From d07fe356c79e43ebe08e6e0c9dda921ecc9ef354 Mon Sep 17 00:00:00 2001 From: Josephine Pfeiffer Date: Sat, 31 May 2025 12:05:08 +0200 Subject: [PATCH] fix(cli): add user feedback when opening config docs in browser The config:docs command previously only logged 'Loaded config from app-config.yaml' and silently attempted to open the browser, providing no feedback about what was happening. This change adds clear console output to indicate the browser is being opened and displays the URL. This approach provides better user experience by: - Showing users that the command is attempting to open their browser - Displaying the full URL being opened for transparency - Providing fallback instructions if the browser fails to open Fixes #29512 Signed-off-by: Josephine Pfeiffer --- .changeset/fix-cli-config-docs-feedback.md | 5 +++++ .../cli/src/modules/config/commands/docs.ts | 21 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 .changeset/fix-cli-config-docs-feedback.md diff --git a/.changeset/fix-cli-config-docs-feedback.md b/.changeset/fix-cli-config-docs-feedback.md new file mode 100644 index 0000000000..1e7298bafa --- /dev/null +++ b/.changeset/fix-cli-config-docs-feedback.md @@ -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. diff --git a/packages/cli/src/modules/config/commands/docs.ts b/packages/cli/src/modules/config/commands/docs.ts index 25e3a864f4..e7d3ac13ee 100644 --- a/packages/cli/src/modules/config/commands/docs.ts +++ b/packages/cli/src/modules/config/commands/docs.ts @@ -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.')); + } };