From a680571d0400caa068dcd0ae1e69bbb6ffd41f02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C5=A9=20V=C4=83n=20D=C5=A9ng?= Date: Fri, 22 Sep 2023 01:26:43 +0700 Subject: [PATCH] Remove the left padding in `next info` output (#55704) ## Why? Although the left padding makes the output looks good in the terminal, it causes this weird alignment in almost all bug reports: ```yaml Operating System: Platform: win32 Arch: x64 Version: Windows 10 Pro Binaries: Node: 18.12.0 npm: N/A Yarn: N/A pnpm: N/A Relevant Packages: next: 13.5.2-canary.2 eslint-config-next: 13.5.2 react: 18.2.0 react-dom: 18.2.0 typescript: 5.2.2 Next.js Config: output: N/A ``` If I want it to look nice in the bug report ```yaml Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.0.0: Thu Aug 17 21:23:02 PDT 2023; root:xnu-10002.1.11~3/RELEASE_ARM64_T8112 Binaries: Node: 20.3.1 npm: 9.6.7 Yarn: 1.22.19 pnpm: 8.6.12 Relevant Packages: next: 13.5.2 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: 5.2.2 Next.js Config: output: N/A ``` I have to paste this to a text editor and manually remove the first four spaces on every lines. ### How? This PR removes that four-space padding to make future bug reports look a bit nicer. --- docs/02-app/02-api-reference/08-next-cli.mdx | 26 +++++----- packages/next/src/cli/next-info.ts | 50 ++++++++++---------- test/integration/cli/test/index.test.js | 34 ++++++------- 3 files changed, 55 insertions(+), 55 deletions(-) diff --git a/docs/02-app/02-api-reference/08-next-cli.mdx b/docs/02-app/02-api-reference/08-next-cli.mdx index b96d016359..9f1eb2eaf0 100644 --- a/docs/02-app/02-api-reference/08-next-cli.mdx +++ b/docs/02-app/02-api-reference/08-next-cli.mdx @@ -158,19 +158,19 @@ will give you information like this example: ```bash filename="Terminal" - Operating System: - Platform: linux - Arch: x64 - Version: #22-Ubuntu SMP Fri Nov 5 13:21:36 UTC 2021 - Binaries: - Node: 16.13.0 - npm: 8.1.0 - Yarn: 1.22.17 - pnpm: 6.24.2 - Relevant packages: - next: 12.0.8 - react: 17.0.2 - react-dom: 17.0.2 +Operating System: + Platform: linux + Arch: x64 + Version: #22-Ubuntu SMP Fri Nov 5 13:21:36 UTC 2021 +Binaries: + Node: 16.13.0 + npm: 8.1.0 + Yarn: 1.22.17 + pnpm: 6.24.2 +Relevant packages: + next: 12.0.8 + react: 17.0.2 + react-dom: 17.0.2 ``` diff --git a/packages/next/src/cli/next-info.ts b/packages/next/src/cli/next-info.ts index 4cc35517dd..be1490fdfb 100755 --- a/packages/next/src/cli/next-info.ts +++ b/packages/next/src/cli/next-info.ts @@ -83,17 +83,17 @@ function getBinaryVersion(binaryName: string) { function printHelp() { console.log( ` - Description - Prints relevant details about the current system which can be used to report Next.js bugs +Description + Prints relevant details about the current system which can be used to report Next.js bugs - Usage - $ next info +Usage + $ next info - Options - --help, -h Displays this message - --verbose Collect additional information for debugging +Options + --help, -h Displays this message + --verbose Collect additional information for debugging - Learn more: ${chalk.cyan('https://nextjs.org/docs/api-reference/cli#info')}` +Learn more: ${chalk.cyan('https://nextjs.org/docs/api-reference/cli#info')}` ) } @@ -105,23 +105,23 @@ async function printDefaultInfo() { const nextConfig = await getNextConfig() console.log(` - Operating System: - Platform: ${os.platform()} - Arch: ${os.arch()} - Version: ${os.version()} - Binaries: - Node: ${process.versions.node} - npm: ${getBinaryVersion('npm')} - Yarn: ${getBinaryVersion('yarn')} - pnpm: ${getBinaryVersion('pnpm')} - Relevant Packages: - next: ${installedRelease} - eslint-config-next: ${getPackageVersion('eslint-config-next')} - react: ${getPackageVersion('react')} - react-dom: ${getPackageVersion('react-dom')} - typescript: ${getPackageVersion('typescript')} - Next.js Config: - output: ${nextConfig.output} +Operating System: + Platform: ${os.platform()} + Arch: ${os.arch()} + Version: ${os.version()} +Binaries: + Node: ${process.versions.node} + npm: ${getBinaryVersion('npm')} + Yarn: ${getBinaryVersion('yarn')} + pnpm: ${getBinaryVersion('pnpm')} +Relevant Packages: + next: ${installedRelease} + eslint-config-next: ${getPackageVersion('eslint-config-next')} + react: ${getPackageVersion('react')} + react-dom: ${getPackageVersion('react-dom')} + typescript: ${getPackageVersion('typescript')} +Next.js Config: + output: ${nextConfig.output} `) diff --git a/test/integration/cli/test/index.test.js b/test/integration/cli/test/index.test.js index e1b7e70283..4c9f9bac53 100644 --- a/test/integration/cli/test/index.test.js +++ b/test/integration/cli/test/index.test.js @@ -792,23 +792,23 @@ describe('CLI Usage', () => { function matchInfoOutput(stdout, { nextConfigOutput = '.*' } = {}) { expect(stdout).toMatch( new RegExp(` - Operating System: - Platform: .* - Arch: .* - Version: .* - Binaries: - Node: .* - npm: .* - Yarn: .* - pnpm: .* - Relevant Packages: - next: .* - eslint-config-next: .* - react: .* - react-dom: .* - typescript: .* - Next.js Config: - output: ${nextConfigOutput} +Operating System: + Platform: .* + Arch: .* + Version: .* +Binaries: + Node: .* + npm: .* + Yarn: .* + pnpm: .* +Relevant Packages: + next: .* + eslint-config-next: .* + react: .* + react-dom: .* + typescript: .* +Next.js Config: + output: ${nextConfigOutput} `) ) }