1 | import { SemVer } from 'semver-utils';
|
2 |
|
3 | /** Supported function for the --filter and --reject options. */
|
4 | declare type FilterFunction = (packageName: string, versionRange: SemVer[]) => boolean;
|
5 |
|
6 | declare type FilterResultsFunction = (packageName: string, versioningMetadata: {
|
7 | currentVersion: VersionSpec;
|
8 | currentVersionSemver: SemVer[];
|
9 | upgradedVersion: Version;
|
10 | upgradedVersionSemver: SemVer;
|
11 | }) => boolean;
|
12 |
|
13 | /** Customize how packages are divided into groups when using `--format group`. Run "ncu --help --groupFunction" for details. */
|
14 | declare type GroupFunction = (packageName: string, defaultGroup: UpgradeGroup, currentVersionSpec: SemVer[], upgradedVersionSpec: SemVer[], upgradedVersion: SemVer | null) => UpgradeGroup | string;
|
15 |
|
16 | /** A very generic object. */
|
17 | declare type Index<T = any> = Record<string, T>;
|
18 |
|
19 | declare type NestedVersionSpecs = {
|
20 | [name: string]: VersionSpec | NestedVersionSpecs;
|
21 | };
|
22 |
|
23 | /** The relevant bits of a parsed package.json file. */
|
24 | declare interface PackageFile {
|
25 | dependencies?: Index<VersionSpec>;
|
26 | devDependencies?: Index<VersionSpec>;
|
27 | imports?: Index<VersionSpec>;
|
28 | engines?: Index<VersionSpec>;
|
29 | name?: string;
|
30 | packageManager?: string;
|
31 | optionalDependencies?: Index<VersionSpec>;
|
32 | overrides?: NestedVersionSpecs;
|
33 | peerDependencies?: Index<VersionSpec>;
|
34 | repository?: string | PackageFileRepository;
|
35 | scripts?: Index<string>;
|
36 | workspaces?: string[] | {
|
37 | packages: string[];
|
38 | };
|
39 | version?: string;
|
40 | }
|
41 |
|
42 | /** Represents the repository field in package.json. */
|
43 | declare interface PackageFileRepository {
|
44 | url: string;
|
45 | directory?: string;
|
46 | }
|
47 |
|
48 | /** Main entry point.
|
49 | *
|
50 | * @returns Promise<
|
51 | * PackageFile Default returns upgraded package file.
|
52 | * | Index<VersionSpec> --jsonUpgraded returns only upgraded dependencies.
|
53 | * | void --global upgrade returns void.
|
54 | * >
|
55 | */
|
56 | declare function run_2(runOptions?: RunOptions, { cli }?: {
|
57 | cli?: boolean;
|
58 | }): Promise<PackageFile | Index<VersionSpec> | void>;
|
59 | export default run_2;
|
60 | export { run_2 as run }
|
61 |
|
62 | /** Options that can be given on the CLI or passed to the ncu module to control all behavior. */
|
63 | export declare interface RunOptions {
|
64 | /** Cache versions to a local cache file. Default `--cacheFile` is ~/.ncu-cache.json and default `--cacheExpiration` is 10 minutes. */
|
65 | cache?: boolean;
|
66 | /** Clear the default cache, or the cache file specified by `--cacheFile`. */
|
67 | cacheClear?: boolean;
|
68 | /** Cache expiration in minutes. Only works with `--cache`.
|
69 | *
|
70 | * @default 10
|
71 | */
|
72 | cacheExpiration?: number;
|
73 | /** Filepath for the cache file. Only works with `--cache`.
|
74 | *
|
75 | * @default "~/.ncu-cache.json"
|
76 | */
|
77 | cacheFile?: string;
|
78 | /** Force color in terminal. */
|
79 | color?: boolean;
|
80 | /** Max number of concurrent HTTP requests to registry.
|
81 | *
|
82 | * @default 8
|
83 | */
|
84 | concurrency?: number;
|
85 | /** Config file name. (default: .ncurc.{json,yml,js,cjs}) */
|
86 | configFileName?: string;
|
87 | /** Directory of .ncurc config file. (default: directory of `packageFile`) */
|
88 | configFilePath?: string;
|
89 | /** Working directory in which npm will be executed. */
|
90 | cwd?: string;
|
91 | /** Run recursively in current working directory. Alias of (`--packageFile '**\/package.json'`). */
|
92 | deep?: boolean;
|
93 | /** Check one or more sections of dependencies only: dev, optional, peer, prod, or packageManager (comma-delimited).
|
94 | *
|
95 | * @default ["prod","dev","optional","packageManager"]
|
96 | */
|
97 | dep?: string | string[];
|
98 | /** Include deprecated packages. Use `--no-deprecated` to exclude deprecated packages (uses more bandwidth).
|
99 | *
|
100 | * @default true
|
101 | */
|
102 | deprecated?: boolean;
|
103 | /** Iteratively installs upgrades and runs tests to identify breaking upgrades. Requires `-u` to execute. Run "ncu --help --doctor" for details. */
|
104 | doctor?: boolean;
|
105 | /** Specifies the install script to use in doctor mode. (default: `npm install` or the equivalent for your package manager) */
|
106 | doctorInstall?: string;
|
107 | /** Specifies the test script to use in doctor mode. (default: `npm test`) */
|
108 | doctorTest?: string;
|
109 | /** Include only packages that satisfy engines.node as specified in the package file. */
|
110 | enginesNode?: boolean;
|
111 | /** Set the error level. 1: exits with error code 0 if no errors occur. 2: exits with error code 0 if no packages need updating (useful for continuous integration).
|
112 | *
|
113 | * @default 1
|
114 | */
|
115 | errorLevel?: number;
|
116 | /** 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. */
|
117 | filter?: string | RegExp | (string | RegExp)[] | FilterFunction;
|
118 | /** Filters out upgrades based on a user provided function. Run "ncu --help --filterResults" for details. */
|
119 | filterResults?: FilterResultsFunction;
|
120 | /** Filter on package version using comma-or-space-delimited list, /regex/, or predicate function. Run "ncu --help --filterVersion" for details. */
|
121 | filterVersion?: string | RegExp | (string | RegExp)[] | FilterFunction;
|
122 | /** 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. */
|
123 | format?: string[];
|
124 | /** Check global packages instead of in the current project. */
|
125 | global?: boolean;
|
126 | /** Customize how packages are divided into groups when using `--format group`. Run "ncu --help --groupFunction" for details. */
|
127 | groupFunction?: GroupFunction;
|
128 | /** Control the auto-install behavior: always, never, prompt. Run "ncu --help --install" for details.
|
129 | *
|
130 | * @default "prompt"
|
131 | */
|
132 | install?: 'always' | 'never' | 'prompt';
|
133 | /** Enable interactive prompts for each dependency; implies `-u` unless one of the json options are set. */
|
134 | interactive?: boolean;
|
135 | /** Output new package file instead of human-readable message. */
|
136 | jsonAll?: boolean;
|
137 | /** Like `jsonAll` but only lists `dependencies`, `devDependencies`, `optionalDependencies`, etc of the new package data. */
|
138 | jsonDeps?: boolean;
|
139 | /** Output upgraded dependencies in json. */
|
140 | jsonUpgraded?: boolean;
|
141 | /** Amount to log: silent, error, minimal, warn, info, verbose, silly.
|
142 | *
|
143 | * @default "warn"
|
144 | */
|
145 | loglevel?: string;
|
146 | /** Merges nested configs with the root config file for `--deep` or `--packageFile` options. (default: false) */
|
147 | mergeConfig?: boolean;
|
148 | /** Do not upgrade newer versions that are already satisfied by the version range according to semver. */
|
149 | minimal?: boolean;
|
150 | /** Package file data (you can also use stdin). */
|
151 | packageData?: string | PackageFile;
|
152 | /** Package file(s) location. (default: ./package.json) */
|
153 | packageFile?: string;
|
154 | /** npm, yarn, pnpm, deno, bun, staticRegistry (default: npm). Run "ncu --help --packageManager" for details. */
|
155 | packageManager?: 'npm' | 'yarn' | 'pnpm' | 'deno' | 'bun' | 'staticRegistry';
|
156 | /** Check peer dependencies of installed packages and filter updates to compatible versions. Run "ncu --help --peer" for details. */
|
157 | peer?: boolean;
|
158 | /** Include prerelease versions, e.g. -alpha.0, -beta.5, -rc.2. Automatically set to 1 when `--target` is newest or greatest, or when the current version is a prerelease. (default: 0) */
|
159 | pre?: boolean;
|
160 | /** Current working directory of npm. */
|
161 | prefix?: string;
|
162 | /** Specify the registry to use when looking up package versions. */
|
163 | registry?: string;
|
164 | /** Specify whether --registry refers to a full npm registry or a simple JSON file or url: npm, json. (default: npm) Run "ncu --help --registryType" for details. */
|
165 | registryType?: 'npm' | 'json';
|
166 | /** Exclude packages matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. Run "ncu --help --reject" for details. */
|
167 | reject?: string | RegExp | (string | RegExp)[] | FilterFunction;
|
168 | /** Exclude package.json versions using comma-or-space-delimited list, /regex/, or predicate function. Run "ncu --help --rejectVersion" for details. */
|
169 | rejectVersion?: string | RegExp | (string | RegExp)[] | FilterFunction;
|
170 | /** Remove version ranges from the final package version. */
|
171 | removeRange?: boolean;
|
172 | /** Number of times to retry failed requests for package info.
|
173 | *
|
174 | * @default 3
|
175 | */
|
176 | retry?: number;
|
177 | /** Runs updates on the root project in addition to specified workspaces. Only allowed with `--workspace` or `--workspaces`.
|
178 | *
|
179 | * @default true
|
180 | */
|
181 | root?: boolean;
|
182 | /** Don't output anything. Alias for `--loglevel` silent. */
|
183 | silent?: boolean;
|
184 | /** Read package.json from stdin. */
|
185 | stdin?: string;
|
186 | /** Determines the version to upgrade to: latest, newest, greatest, minor, patch, semver, `@[tag]`, or [function]. (default: latest) Run "ncu --help --target" for details. */
|
187 | target?: 'latest' | 'newest' | 'greatest' | 'minor' | 'patch' | 'semver' | `@${string}` | TargetFunction;
|
188 | /** Global timeout in milliseconds. (default: no global timeout and 30 seconds per npm-registry-fetch) */
|
189 | timeout?: number;
|
190 | /** Overwrite package file with upgraded versions instead of just outputting to console. */
|
191 | upgrade?: boolean;
|
192 | /** Log additional information for debugging. Alias for `--loglevel` verbose. */
|
193 | verbose?: boolean;
|
194 | /** Run on one or more specified workspaces. Add `--root` to also upgrade the root project. */
|
195 | workspace?: string[];
|
196 | /** Run on all workspaces. Add `--root` to also upgrade the root project. */
|
197 | workspaces?: boolean;
|
198 | }
|
199 |
|
200 | /** A function that can be provided to the --target option for custom filtering. */
|
201 | declare type TargetFunction = (packageName: string, versionRange: SemVer[]) => string;
|
202 |
|
203 | declare type UpgradeGroup = 'major' | 'minor' | 'patch' | 'majorVersionZero' | 'none';
|
204 |
|
205 | /** An exact version number or value. Includes SemVer and some nonstandard variants for convenience. */
|
206 | declare type Version = string;
|
207 |
|
208 | /** A version specification or range supported as a value in package.json dependencies. Includes SemVer, git urls, npm urls, etc. */
|
209 | declare type VersionSpec = string;
|
210 |
|
211 | export { }
|