-
Notifications
You must be signed in to change notification settings - Fork 28.8k
feat(cli): introduce next info
CLI command
#32972
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
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
e5f647d
chore(deps): add
balazsorban44 7aba961
feat(cli): introduce
balazsorban44 c147d85
chore(deps): remove dependency
balazsorban44 6e737ac
chore(deps): add lowest supporting
balazsorban44 b71594a
feat(cli): print OS, Binary, npm package information
balazsorban44 86c19a8
docs(cli): document
balazsorban44 5fa6543
chore: remove v
balazsorban44 a13ffef
chore(deps): remove
balazsorban44 df3dd36
docs: update bug report issue template
balazsorban44 b8a68e0
Apply suggestions from code review
balazsorban44 4aea3d1
chore: fix typo
balazsorban44 c2cb0c8
Apply suggestions from code review
balazsorban44 e86d02f
chore: simplify
balazsorban44 ccf943c
chore: add back issue template fields
balazsorban44 094b5db
chore: print node version without "v" prefix
balazsorban44 5c89412
fix: try/catch if fails in
balazsorban44 6a1bd80
chore: specify availability
balazsorban44 e73145b
Add @types/node to root package.json
styfle 36b5cbf
Apply suggestions from code review
styfle b3da6b2
Merge branch 'canary' into feat/next-cli-info
styfle 84902a6
chore: run Prettier
balazsorban44 a9d7da0
chore: rename group to "Relevant packages"
balazsorban44 182e9ae
chore(cli): rephrase description to match API reference
balazsorban44 647eee9
test(cli): add tests
balazsorban44 4a26e7f
Merge branch 'canary' into feat/next-cli-info
kodiakhq[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/env node | ||
import os from 'os' | ||
import childProcess from 'child_process' | ||
|
||
import chalk from 'next/dist/compiled/chalk' | ||
import arg from 'next/dist/compiled/arg/index.js' | ||
import { printAndExit } from '../server/lib/utils' | ||
import { cliCommand } from '../bin/next' | ||
import isError from '../lib/is-error' | ||
|
||
const nextInfo: cliCommand = async (argv) => { | ||
const validArgs: arg.Spec = { | ||
// Types | ||
'--help': Boolean, | ||
// Aliases | ||
'-h': '--help', | ||
} | ||
let args: arg.Result<arg.Spec> | ||
try { | ||
args = arg(validArgs, { argv }) | ||
} catch (error) { | ||
if (isError(error) && error.code === 'ARG_UNKNOWN_OPTION') { | ||
return printAndExit(error.message, 1) | ||
} | ||
throw error | ||
} | ||
|
||
if (args['--help']) { | ||
console.log( | ||
` | ||
Description | ||
Prints relevant details about the current system which can be used to report Next.js bugs | ||
|
||
Usage | ||
$ next info | ||
|
||
Learn more: ${chalk.cyan( | ||
'https://nextjs.org/docs/api-reference/cli#info' | ||
)}` | ||
) | ||
return | ||
} | ||
|
||
console.log(` | ||
Operating System: | ||
balazsorban44 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Platform: ${os.platform()} | ||
Arch: ${os.arch()} | ||
Version: ${os.version()} | ||
balazsorban44 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Binaries: | ||
Node: ${process.versions.node} | ||
npm: ${getBinaryVersion('npm')} | ||
Yarn: ${getBinaryVersion('yarn')} | ||
pnpm: ${getBinaryVersion('pnpm')} | ||
balazsorban44 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Relevant packages: | ||
next: ${getPackageVersion('next')} | ||
react: ${getPackageVersion('react')} | ||
react-dom: ${getPackageVersion('react-dom')}`) | ||
} | ||
|
||
export { nextInfo } | ||
|
||
function getPackageVersion(packageName: string) { | ||
try { | ||
return require(`${packageName}/package.json`).version | ||
} catch { | ||
return 'N/A' | ||
} | ||
} | ||
|
||
function getBinaryVersion(binaryName: string) { | ||
try { | ||
return childProcess.execSync(`${binaryName} --version`).toString().trim() | ||
} catch { | ||
return 'N/A' | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4694,9 +4694,10 @@ | |
dependencies: | ||
"@types/node" "*" | ||
|
||
"@types/node@*", "@types/node@>= 8": | ||
version "13.1.4" | ||
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.1.4.tgz#4cfd90175a200ee9b02bd6b1cd19bc349741607e" | ||
"@types/node@*", "@types/[email protected]", "@types/node@>= 8": | ||
version "13.11.0" | ||
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.11.0.tgz#390ea202539c61c8fa6ba4428b57e05bc36dc47b" | ||
integrity sha512-uM4mnmsIIPK/yeO+42F2RQhGUIs39K2RFmugcJANppXe6J1nvH87PvzPZYpza7Xhhs8Yn9yIAVdLZ84z61+0xQ== | ||
|
||
"@types/[email protected]": | ||
version "10.12.18" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.