Skip to content

Commit

Permalink
Merge pull request #24003 from storybookjs/better-storybook-info
Browse files Browse the repository at this point in the history
CLI: Add more information to `storybook info` command
  • Loading branch information
JReinhold authored Aug 30, 2023
2 parents 7b4f37f + 60e8ee0 commit 7b268e1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ body:
attributes:
label: System
description: Please paste the results of `npx storybook@latest info` here.
render: shell
render: bash
- type: textarea
id: context
attributes:
Expand Down
30 changes: 19 additions & 11 deletions code/lib/cli/src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { dev } from './dev';
import { build } from './build';
import { parseList, getEnvConfig } from './utils';
import versions from './versions';
import { JsPackageManagerFactory } from './js-package-manager';

addToGlobalContext('cliVersion', versions.storybook);

Expand Down Expand Up @@ -87,17 +88,24 @@ command('upgrade')

command('info')
.description('Prints debugging information about the local environment')
.action(() => {
consoleLogger.log(chalk.bold('\nEnvironment Info:'));
envinfo
.run({
System: ['OS', 'CPU'],
Binaries: ['Node', 'Yarn', 'npm'],
Browsers: ['Chrome', 'Edge', 'Firefox', 'Safari'],
npmPackages: '@storybook/*',
npmGlobalPackages: '@storybook/*',
})
.then(consoleLogger.log);
.action(async () => {
consoleLogger.log(chalk.bold('\nStorybook Environment Info:'));
const pkgManager = await JsPackageManagerFactory.getPackageManager();
const activePackageManager = pkgManager.type.replace(/\d/, ''); // 'yarn1' -> 'yarn'
const output = await envinfo.run({
System: ['OS', 'CPU', 'Shell'],
Binaries: ['Node', 'Yarn', 'npm', 'pnpm'],
Browsers: ['Chrome', 'Edge', 'Firefox', 'Safari'],
npmPackages: '{@storybook/*,*storybook*,sb,chromatic}',
npmGlobalPackages: '{@storybook/*,*storybook*,sb,chromatic}',
});
const activePackageManagerLine = output.match(new RegExp(`${activePackageManager}:.*`, 'i'));
consoleLogger.log(
output.replace(
activePackageManagerLine,
chalk.bold(`${activePackageManagerLine} <----- active`)
)
);
});

command('migrate [migration]')
Expand Down

0 comments on commit 7b268e1

Please sign in to comment.