Skip to content

Commit

Permalink
fix: readonly arrays on input options (#1498)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zamiell authored Feb 23, 2025
1 parent 35300f0 commit de0c152
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions src/cli-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ const cliOptions: CLIOption[] = [
'Check one or more sections of dependencies only: dev, optional, peer, prod, or packageManager (comma-delimited).',
default: ['prod', 'dev', 'optional', 'packageManager'],
parse: value => (value && typeof value === 'string' ? value.split(',') : value),
type: 'string | string[]',
type: 'string | readonly string[]',
},
{
long: 'deprecated',
Expand Down Expand Up @@ -666,7 +666,7 @@ const cliOptions: CLIOption[] = [
arg: 'p',
description:
'Include only package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function.',
type: 'string | RegExp | (string | RegExp)[] | FilterFunction',
type: 'string | RegExp | readonly (string | RegExp)[] | FilterFunction',
parse: (value, accum) => [...(accum || []), value],
help: extendedHelpFilterFunction,
},
Expand All @@ -682,7 +682,7 @@ const cliOptions: CLIOption[] = [
long: 'filterVersion',
arg: 'p',
description: 'Filter on package version using comma-or-space-delimited list, /regex/, or predicate function.',
type: 'string | RegExp | (string | RegExp)[] | FilterFunction',
type: 'string | RegExp | readonly (string | RegExp)[] | FilterFunction',
parse: (value, accum) => [...(accum || []), value],
help: extendedHelpFilterVersionFunction,
},
Expand All @@ -693,7 +693,7 @@ const cliOptions: CLIOption[] = [
'Modify the output formatting or show additional information. Specify one or more comma-delimited values: group, ownerChanged, repo, time, lines, installedVersion.',
parse: value => (typeof value === 'string' ? value.split(',') : value),
default: [],
type: 'string[]',
type: 'readonly string[]',
choices: ['group', 'ownerChanged', 'repo', 'time', 'lines', 'installedVersion'],
help: extendedHelpFormat,
},
Expand Down Expand Up @@ -824,15 +824,15 @@ const cliOptions: CLIOption[] = [
arg: 'p',
description:
'Exclude packages matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function.',
type: 'string | RegExp | (string | RegExp)[] | FilterFunction',
type: 'string | RegExp | readonly (string | RegExp)[] | FilterFunction',
parse: (value, accum) => [...(accum || []), value],
help: extendedHelpRejectFunction,
},
{
long: 'rejectVersion',
arg: 'p',
description: 'Exclude package.json versions using comma-or-space-delimited list, /regex/, or predicate function.',
type: 'string | RegExp | (string | RegExp)[] | FilterFunction',
type: 'string | RegExp | readonly (string | RegExp)[] | FilterFunction',
parse: (value, accum) => [...(accum || []), value],
help: extendedHelpRejectVersionFunction,
},
Expand Down Expand Up @@ -901,7 +901,7 @@ const cliOptions: CLIOption[] = [
parse: (value, accum) => [...accum, value],
default: [],
description: 'Run on one or more specified workspaces. Add `--root` to also upgrade the root project.',
type: 'string[]',
type: 'readonly string[]',
},
{
long: 'workspaces',
Expand Down
2 changes: 1 addition & 1 deletion src/lib/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export async function toDependencyTable({
}: {
from: Index<VersionSpec>
to: Index<VersionSpec>
format?: string[]
format?: readonly string[]
ownersChangedDeps?: Index<boolean>
/** See: logging/getPackageRepo pkgFile param. */
pkgFile?: string
Expand Down
2 changes: 1 addition & 1 deletion src/lib/resolveDepSections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const depAliases: Index<keyof PackageFile> = {
}

/** Gets a list of dependency sections based on options.dep. */
const resolveDepSections = (dep?: string | string[]): (keyof PackageFile)[] => {
const resolveDepSections = (dep?: string | readonly string[]): (keyof PackageFile)[] => {
// parse dep string and set default
const depOptions: string[] = dep ? (typeof dep === 'string' ? dep.split(',') : dep) : cliOptionsMap.dep.default

Expand Down
2 changes: 1 addition & 1 deletion src/types/FilterPattern.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FilterFunction } from './FilterFunction'

/** Supported patterns for the --filter and --reject options. */
export type FilterPattern = string | RegExp | (string | RegExp)[] | FilterFunction
export type FilterPattern = string | RegExp | readonly (string | RegExp)[] | FilterFunction
14 changes: 7 additions & 7 deletions src/types/RunOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export interface RunOptions {
*
* @default ["prod","dev","optional","packageManager"]
*/
dep?: string | string[]
dep?: string | readonly string[]

/** Include deprecated packages. Use `--no-deprecated` to exclude deprecated packages (uses more bandwidth).
*
Expand All @@ -77,16 +77,16 @@ export interface RunOptions {
errorLevel?: number

/** Include only package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. Run "ncu --help --filter" for details. */
filter?: string | RegExp | (string | RegExp)[] | FilterFunction
filter?: string | RegExp | readonly (string | RegExp)[] | FilterFunction

/** Filters out upgrades based on a user provided function. Run "ncu --help --filterResults" for details. */
filterResults?: FilterResultsFunction

/** Filter on package version using comma-or-space-delimited list, /regex/, or predicate function. Run "ncu --help --filterVersion" for details. */
filterVersion?: string | RegExp | (string | RegExp)[] | FilterFunction
filterVersion?: string | RegExp | readonly (string | RegExp)[] | FilterFunction

/** Modify the output formatting or show additional information. Specify one or more comma-delimited values: group, ownerChanged, repo, time, lines, installedVersion. Run "ncu --help --format" for details. */
format?: string[]
format?: readonly string[]

/** Check global packages instead of in the current project. */
global?: boolean
Expand Down Expand Up @@ -149,10 +149,10 @@ export interface RunOptions {
registryType?: 'npm' | 'json'

/** Exclude packages matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. Run "ncu --help --reject" for details. */
reject?: string | RegExp | (string | RegExp)[] | FilterFunction
reject?: string | RegExp | readonly (string | RegExp)[] | FilterFunction

/** Exclude package.json versions using comma-or-space-delimited list, /regex/, or predicate function. Run "ncu --help --rejectVersion" for details. */
rejectVersion?: string | RegExp | (string | RegExp)[] | FilterFunction
rejectVersion?: string | RegExp | readonly (string | RegExp)[] | FilterFunction

/** Remove version ranges from the final package version. */
removeRange?: boolean
Expand Down Expand Up @@ -188,7 +188,7 @@ export interface RunOptions {
verbose?: boolean

/** Run on one or more specified workspaces. Add `--root` to also upgrade the root project. */
workspace?: string[]
workspace?: readonly string[]

/** Run on all workspaces. Add `--root` to also upgrade the root project. */
workspaces?: boolean
Expand Down

0 comments on commit de0c152

Please sign in to comment.