diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index ae7c18037e272..ccbf0982351fa 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -30,12 +30,14 @@ What should happen? What happened. ### Environment -* Gatsby version (`npm list gatsby`): -* gatsby-cli version (`gatsby --version`): -* Node.js version: -* Operating System: + + ### File contents (if changed) + `gatsby-config.js`: N/A `package.json`: N/A `gatsby-node.js`: N/A diff --git a/packages/gatsby-cli/README.md b/packages/gatsby-cli/README.md index 354eb709ab0b1..18eaeff143cee 100644 --- a/packages/gatsby-cli/README.md +++ b/packages/gatsby-cli/README.md @@ -49,3 +49,7 @@ site. At the root of a Gatsby site run `gatsby serve` to serve the production build of the site for testing. + +### Info + +At the root of a Gatsby site run `gatsby info` to get helpful environment information which will be required when reporting a bug. diff --git a/packages/gatsby-cli/package.json b/packages/gatsby-cli/package.json index 37fca85f1fddb..c3774938f5beb 100644 --- a/packages/gatsby-cli/package.json +++ b/packages/gatsby-cli/package.json @@ -16,6 +16,7 @@ "common-tags": "^1.4.0", "convert-hrtime": "^2.0.0", "core-js": "^2.5.0", + "envinfo": "^5.8.1", "execa": "^0.8.0", "fs-extra": "^4.0.1", "hosted-git-info": "^2.5.0", diff --git a/packages/gatsby-cli/src/create-cli.js b/packages/gatsby-cli/src/create-cli.js index ee4d71ddc704e..0c8f5f15caa8b 100644 --- a/packages/gatsby-cli/src/create-cli.js +++ b/packages/gatsby-cli/src/create-cli.js @@ -3,6 +3,7 @@ const resolveCwd = require(`resolve-cwd`) const yargs = require(`yargs`) const report = require(`./reporter`) const fs = require(`fs`) +const envinfo = require(`envinfo`) const DEFAULT_BROWSERS = [`> 1%`, `last 2 versions`, `IE >= 9`] @@ -173,6 +174,38 @@ function buildLocalCommands(cli, isLocalSite) { handler: getCommandHandler(`serve`), }) + + cli.command({ + command: `info`, + desc: `Get environment information for debugging and issue reporting`, + builder: _ => + _.option(`C`, { + alias: `clipboard`, + type: `boolean`, + default: false, + describe: `Automagically copy environment information to clipboard`, + }), + handler: args => { + try { + envinfo.run( + { + System: [`OS`, `CPU`, `Shell`], + Binaries: [`Node`, `npm`, `Yarn`], + Browsers: [`Chrome`, `Edge`, `Firefox`, `Safari`], + npmPackages: `gatsby*`, + npmGlobalPackages: `gatsby*`, + }, + { + console: true, + clipboard: args.clipboard, + } + ) + } catch (err) { + console.log(`Error: unable to print environment info`) + console.log(err) + } + }, + }) } function isLocalGatsbySite() {