Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add envinfo to gatsby-cli, issue template #5594

Merged
merged 4 commits into from
Jun 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

<!--
Required. Run `gatsby info --clipboard` in your gatsby project directory and paste its contents here.
Not working? You may need to update your global gatsby-cli - `npm install -g gatsby-cli`
-->

### File contents (if changed)

`gatsby-config.js`: N/A <!-- Please use a code block or just leave it as is if wasn't changed -->
`package.json`: N/A <!-- Please use a code block or just leave it as is if wasn't changed -->
`gatsby-node.js`: N/A <!-- Please use a code block or just leave it as is if wasn't changed -->
Expand Down
4 changes: 4 additions & 0 deletions packages/gatsby-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 1 addition & 0 deletions packages/gatsby-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
33 changes: 33 additions & 0 deletions packages/gatsby-cli/src/create-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`]

Expand Down Expand Up @@ -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() {
Expand Down