Skip to content

Commit

Permalink
fix: avoid redefining --json option in commands
Browse files Browse the repository at this point in the history
  • Loading branch information
serhalp committed Feb 21, 2025
1 parent 8f86eb1 commit 349a31b
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/commands/base-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export default class BaseCommand extends Command {
.addOption(new Option('--json', 'Output return values as JSON').hideHelp(true))
.addOption(new Option('--silent', 'Silence CLI output').hideHelp(true))
.addOption(new Option('--cwd <cwd>').hideHelp(true))
.addOption(new Option('-o, --offline').hideHelp(true))
.addOption(new Option('-o, --offline').default(false).hideHelp(true))
.addOption(new Option('--auth <token>', 'Netlify auth token').hideHelp(true))
.addOption(
new Option(
Expand Down
5 changes: 3 additions & 2 deletions src/commands/blobs/blobs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OptionValues } from 'commander'
import { Option, OptionValues } from 'commander'

import requiresSiteInfo from '../../utils/hooks/requires-site-info.js'
import BaseCommand from '../base-command.js'
Expand Down Expand Up @@ -53,7 +53,8 @@ export const createBlobsCommand = (program: BaseCommand) => {
'-p, --prefix <prefix>',
`A string for filtering down the entries; when specified, only the entries whose key starts with that prefix are returned`,
)
.option('--json', `Output list contents as JSON`)
// The BaseCommand defines a `--json` option which is hidden from the help by default
.addHelpOption(new Option('--json', 'Output list contents as JSON'))
.alias('blob:list')
.hook('preAction', requiresSiteInfo)
.action(async (storeName: string, options: OptionValues, command: BaseCommand) => {
Expand Down
3 changes: 2 additions & 1 deletion src/commands/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import process from 'process'

import { normalizeContext } from '../../utils/env/index.js'
import BaseCommand from '../base-command.js'
import { Option } from 'commander'

export const createBuildCommand = (program: BaseCommand) =>
program
Expand All @@ -14,7 +15,7 @@ export const createBuildCommand = (program: BaseCommand) =>
process.env.CONTEXT || 'production',
)
.option('--dry', 'Dry run: show instructions without running them', false)
.option('-o, --offline', 'disables any features that require network access', false)
.addHelpOption(new Option('-o, --offline', 'Disables any features that require network access'))
.addExamples(['netlify build'])
.action(async (options, command) => {
const { build } = await import('./build.js')
Expand Down
2 changes: 1 addition & 1 deletion src/commands/dev/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export const createDevCommand = (program: BaseCommand) => {
.option('--framework <name>', 'framework to use. Defaults to #auto which automatically detects a framework')
.option('-d ,--dir <path>', 'dir with static files')
.option('-f ,--functions <folder>', 'specify a functions folder to serve')
.option('-o ,--offline', 'disables any features that require network access')
.addHelpOption(new Option('-o, --offline', 'Disables any features that require network access'))
.addOption(
new Option('--offline-env', 'disables fetching environment variables from the Netlify API').hideHelp(true),
)
Expand Down
4 changes: 2 additions & 2 deletions src/commands/functions/functions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OptionValues } from 'commander'
import { Option, OptionValues } from 'commander'

import { chalk } from '../../utils/command-helpers.js'
import requiresSiteInfo from '../../utils/hooks/requires-site-info.js'
Expand Down Expand Up @@ -97,7 +97,7 @@ NOT the same as listing the functions that have been deployed. For that info you
.description('Serve functions locally')
.option('-f, --functions <dir>', 'Specify a functions directory to serve')
.option('-p, --port <port>', 'Specify a port for the functions server', (value) => Number.parseInt(value))
.option('-o, --offline', 'disables any features that require network access')
.addHelpOption(new Option('-o, --offline', 'Disables any features that require network access'))
.addHelpText('after', 'Helpful for debugging functions.')
.action(async (options: OptionValues, command: BaseCommand) => {
const { functionsServe } = await import('./functions-serve.js')
Expand Down
2 changes: 1 addition & 1 deletion src/commands/serve/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const createServeCommand = (program: BaseCommand) =>
.option('-p ,--port <port>', 'port of netlify dev', (value) => Number.parseInt(value))
.option('-d ,--dir <path>', 'dir with static files')
.option('-f ,--functions <folder>', 'specify a functions folder to serve')
.option('-o ,--offline', 'disables any features that require network access')
.addHelpOption(new Option('-o, --offline', 'Disables any features that require network access'))
.addOption(
new Option(
'--internal-disable-edge-functions',
Expand Down

0 comments on commit 349a31b

Please sign in to comment.