From 775ff3b5f316209d0aebdbc55f806bd04cc500a2 Mon Sep 17 00:00:00 2001 From: Trevor Brindle Date: Tue, 29 May 2018 18:00:14 -0400 Subject: [PATCH 1/4] Add envinfo to gatsby-cli, issue template --- .github/ISSUE_TEMPLATE/bug_report.md | 7 +++--- packages/gatsby-cli/README.md | 5 ++++ packages/gatsby-cli/package.json | 1 + packages/gatsby-cli/src/create-cli.js | 33 +++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index ae7c18037e272..f17fc890e3809 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -30,12 +30,11 @@ 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..f2381c139d109 100644 --- a/packages/gatsby-cli/README.md +++ b/packages/gatsby-cli/README.md @@ -49,3 +49,8 @@ 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 +and 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..29528119baef4 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() { From b7733fd94da33cd73a6f89f5528ba91071e24576 Mon Sep 17 00:00:00 2001 From: Mike Allanson Date: Thu, 31 May 2018 14:50:29 +0100 Subject: [PATCH 2/4] Remove extra extra word --- packages/gatsby-cli/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/gatsby-cli/README.md b/packages/gatsby-cli/README.md index f2381c139d109..18eaeff143cee 100644 --- a/packages/gatsby-cli/README.md +++ b/packages/gatsby-cli/README.md @@ -52,5 +52,4 @@ the site for testing. ### Info -At the root of a Gatsby site run `gatsby info` to get helpful environment information which -and will be required when reporting a bug. +At the root of a Gatsby site run `gatsby info` to get helpful environment information which will be required when reporting a bug. From 12e06441660ba9b3f148a45e89dda05fe77fe1c3 Mon Sep 17 00:00:00 2001 From: Mike Allanson Date: Thu, 31 May 2018 15:25:06 +0100 Subject: [PATCH 3/4] Fix lint warning --- packages/gatsby-cli/src/create-cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gatsby-cli/src/create-cli.js b/packages/gatsby-cli/src/create-cli.js index 29528119baef4..0c8f5f15caa8b 100644 --- a/packages/gatsby-cli/src/create-cli.js +++ b/packages/gatsby-cli/src/create-cli.js @@ -201,7 +201,7 @@ function buildLocalCommands(cli, isLocalSite) { } ) } catch (err) { - console.log("Error: unable to print environment info") + console.log(`Error: unable to print environment info`) console.log(err) } }, From 15b057a5c5956b8b5b222211890ca85e544c0c05 Mon Sep 17 00:00:00 2001 From: Trevor Brindle Date: Fri, 1 Jun 2018 11:30:28 -0400 Subject: [PATCH 4/4] add warning to update gatsby-cli --- .github/ISSUE_TEMPLATE/bug_report.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index f17fc890e3809..ccbf0982351fa 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -31,7 +31,10 @@ What happened. ### Environment - + ### File contents (if changed)