Skip to content

Commit

Permalink
fix(cli): add all available options to cli commands, format them cons…
Browse files Browse the repository at this point in the history
…istently (#48708)

### What?
Add all available options to cli commands
Consistent formatting for all options

### Why?
Options were not consistent across all commands, some were missing



Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
  • Loading branch information
3 people committed Jun 14, 2023
1 parent 691598e commit 0bda628
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 16 deletions.
2 changes: 1 addition & 1 deletion errors/invalid-i18n-config.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Invalid i18n config

#### Why This Error
#### Why This Error Occurred

In your `next.config.js` file you provided an invalid config for the `i18n` field. This could mean the limit for 100 locale items was exceeded.

Expand Down
10 changes: 6 additions & 4 deletions packages/next/src/cli/next-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ const nextBuild: CliCommand = (argv) => {
If no directory is provided, the current directory will be used.
Options
--profile Can be used to enable React Production Profiling
--no-lint Disable linting
--no-mangling Disable mangling
--experimental-app-only Only build 'app' routes
--profile Can be used to enable React Production Profiling
--no-lint Disable linting
--no-mangling Disable mangling
--experimental-app-only Only build 'app' routes
--experimental-turbo Enable experimental turbo mode
--help, -h Displays this message
`,
0
)
Expand Down
17 changes: 12 additions & 5 deletions packages/next/src/cli/next-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { resolve, join } from 'path'
import { existsSync } from 'fs'
import arg from 'next/dist/compiled/arg/index.js'
import chalk from 'next/dist/compiled/chalk'
import exportApp, { ExportError, ExportOptions } from '../export'
import * as Log from '../build/output/log'
import { printAndExit } from '../server/lib/utils'
Expand All @@ -21,8 +22,8 @@ const nextExport: CliCommand = (argv) => {

// Aliases
'-h': '--help',
'-s': '--silent',
'-o': '--outdir',
'-s': '--silent',
}
let args: arg.Result<arg.Spec>
try {
Expand All @@ -36,7 +37,7 @@ const nextExport: CliCommand = (argv) => {
if (args['--help']) {
console.log(`
Description
Exports the application for production deployment
[DEPRECATED] Exports a static version of the application for production deployment
Usage
$ next export [options] <dir>
Expand All @@ -45,9 +46,15 @@ const nextExport: CliCommand = (argv) => {
If no directory is provided, the current directory will be used.
Options
-h - list this help
-o - set the output dir (defaults to 'out')
-s - do not print any messages to console
--outdir, -o Set the output dir (defaults to 'out')
--silent, -s Do not print any messages to console
--threads Max number of threads to use
--help, -h List this help
The "next export" command is deprecated in favor of "output: export" in next.config.js
Learn more: ${chalk.cyan(
'https://nextjs.org/docs/advanced-features/static-html-export'
)}
`)
process.exit(0)
}
Expand Down
3 changes: 3 additions & 0 deletions packages/next/src/cli/next-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ const nextInfo: CliCommand = async (argv) => {
Usage
$ next info
Options
--help, -h Displays this message
Learn more: ${chalk.cyan(
'https://nextjs.org/docs/api-reference/cli#info'
)}`
Expand Down
6 changes: 3 additions & 3 deletions packages/next/src/cli/next-start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ const nextStart: CliCommand = async (argv) => {
If no directory is provided, the current directory will be used.
Options
--port, -p A port number on which to start the application
--hostname, -H Hostname on which to start the application (default: 0.0.0.0)
--port, -p A port number on which to start the application
--hostname, -H Hostname on which to start the application (default: 0.0.0.0)
--keepAliveTimeout Max milliseconds to wait before closing inactive connections
--help, -h Displays this message
--help, -h Displays this message
`)
process.exit(0)
}
Expand Down
7 changes: 6 additions & 1 deletion packages/next/src/cli/next-telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import isError from '../lib/is-error'
const nextTelemetry: CliCommand = (argv) => {
const validArgs: arg.Spec = {
// Types
'--help': Boolean,
'--enable': Boolean,
'--disable': Boolean,
'--help': Boolean,
// Aliases
'-h': '--help',
}
Expand All @@ -36,6 +36,11 @@ const nextTelemetry: CliCommand = (argv) => {
You may pass the 'enable' or 'disable' argument to turn Next.js' telemetry collection on or off.
Options
--enable Enables Next.js' telemetry collection
--disable Disables Next.js' telemetry collection
--help, -h Displays this message
Learn more: ${chalk.cyan('https://nextjs.org/telemetry')}
`
)
Expand Down
4 changes: 2 additions & 2 deletions test/integration/cli/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,14 +580,14 @@ describe('CLI Usage', () => {
const help = await runNextCommand(['export', '--help'], {
stdout: true,
})
expect(help.stdout).toMatch(/Exports the application/)
expect(help.stdout).toMatch(/Exports a static version of the application/)
})

test('-h', async () => {
const help = await runNextCommand(['export', '-h'], {
stdout: true,
})
expect(help.stdout).toMatch(/Exports the application/)
expect(help.stdout).toMatch(/Exports a static version of the application/)
})

test('should warn when unknown argument provided', async () => {
Expand Down

0 comments on commit 0bda628

Please sign in to comment.