@octalmesh/seagull 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +128 -25
- package/dist/cli.mjs +5 -48
- package/dist/cli.mjs.map +1 -1
- package/dist/dist-Ou2inxGj.mjs +16783 -0
- package/dist/dist-Ou2inxGj.mjs.map +1 -0
- package/dist/index.d.mts +1207 -42
- package/dist/index.mjs +2 -4
- package/package.json +13 -9
- package/dist/serve-docs-BZaITOD0.mjs +0 -1567
- package/dist/serve-docs-BZaITOD0.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,19 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
import { z } from "zod";
|
|
1
|
+
//#region packages/core/dist/index.d.mts
|
|
3
2
|
//#region src/config/schema.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The seagull config *schema* version - not the npm package's own version.
|
|
5
|
+
* Bumped only when the shape of `seagull.yaml` changes in a breaking way, so
|
|
6
|
+
* older configs fail with a clear "this config targets schema vN, seagull
|
|
7
|
+
* expects vM" error instead of a confusing validation failure on some
|
|
8
|
+
* unrelated field once the schema moves on.
|
|
9
|
+
*/
|
|
10
|
+
declare const CONFIG_SCHEMA_VERSION = 1;
|
|
4
11
|
/**
|
|
5
12
|
* A free-form tree of leaf values, used for the `vars:` block in the CLI config.
|
|
6
13
|
* Nest however deep is useful - every leaf becomes addressable as
|
|
7
14
|
* `{vars.<dot.path>}` in templated fields.
|
|
8
15
|
*/
|
|
9
|
-
|
|
16
|
+
interface VarsTree {
|
|
10
17
|
[key: string]: string | number | boolean | VarsTree;
|
|
11
|
-
}
|
|
18
|
+
}
|
|
12
19
|
//#endregion
|
|
13
20
|
//#region src/config/types.d.ts
|
|
14
21
|
type SdkTool = "openapi-generator" | "openapi-typescript";
|
|
15
22
|
type SdkLang = "typescript" | "go" | "java";
|
|
16
23
|
type SdkKind = "client" | "server";
|
|
24
|
+
/**
|
|
25
|
+
* Fully resolved publishing conventions for one artifact.
|
|
26
|
+
*/
|
|
27
|
+
interface ResolvedPublishing {
|
|
28
|
+
/** Fully resolved git branch name (no runtime-only placeholders left). */
|
|
29
|
+
branch: string;
|
|
30
|
+
/**
|
|
31
|
+
* Raw tag template - still contains `{version}`, resolved at publish
|
|
32
|
+
* time via `renderArtifactTag()` in `config/publishing.ts`.
|
|
33
|
+
*/
|
|
34
|
+
tagTemplate: string;
|
|
35
|
+
/** Resolved `repository.url` for generated package.json / README examples. */
|
|
36
|
+
repositoryUrl: string;
|
|
37
|
+
npmRegistry: string;
|
|
38
|
+
npmAccess: "public" | "restricted";
|
|
39
|
+
mavenRepositoryId: string;
|
|
40
|
+
mavenRepositoryUrl: string;
|
|
41
|
+
}
|
|
17
42
|
/**
|
|
18
43
|
* A single artifact a contract generates: a generator recipe from the CLI
|
|
19
44
|
* config, fully resolved (templates interpolated, overrides merged, paths made
|
|
@@ -33,10 +58,16 @@ interface ResolvedArtifact {
|
|
|
33
58
|
generator?: string;
|
|
34
59
|
/** Absolute output directory: `<sdkDir>/<contract>/<id>`. */
|
|
35
60
|
outputDir: string;
|
|
36
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* Fully resolved git branch name - convenience alias for
|
|
63
|
+
* `publishing.branch`.
|
|
64
|
+
*/
|
|
37
65
|
branch: string;
|
|
38
|
-
/**
|
|
39
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Publishing conventions (branch/tag/registry) for this artifact - see
|
|
68
|
+
* {@link ResolvedPublishing}.
|
|
69
|
+
*/
|
|
70
|
+
publishing: ResolvedPublishing;
|
|
40
71
|
additionalProperties: Record<string, string | number | boolean>;
|
|
41
72
|
package?: string;
|
|
42
73
|
goModule?: string;
|
|
@@ -73,6 +104,11 @@ interface ResolvedArtifactEntry {
|
|
|
73
104
|
artifact: ResolvedArtifact;
|
|
74
105
|
}
|
|
75
106
|
interface ResolvedConfig {
|
|
107
|
+
/**
|
|
108
|
+
* The config schema version this file targets - see `CONFIG_SCHEMA_VERSION`
|
|
109
|
+
* in `config/schema.ts`.
|
|
110
|
+
*/
|
|
111
|
+
configVersion: number;
|
|
76
112
|
/**
|
|
77
113
|
* Directory containing the config file - every relative path in the config
|
|
78
114
|
* (entrypoints, `paths.*`, `readme` templates, ...) resolves against this.
|
|
@@ -115,16 +151,39 @@ interface ResolvedConfig {
|
|
|
115
151
|
* point every command uses to get its configuration.
|
|
116
152
|
*
|
|
117
153
|
* Unlike a build tool bundled into the consumer's own repo, seagull is
|
|
118
|
-
* installed as a dependency, so it has no way to guess where the
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
154
|
+
* installed as a dependency, so it has no way to guess where the consumer's
|
|
155
|
+
* config lives on its own - `configPath` must be supplied by the caller (the
|
|
156
|
+
* CLI resolves it via `resolveConfigPath()` in `config/resolve-config-file.ts`,
|
|
157
|
+
* or `--config`).
|
|
122
158
|
*
|
|
123
159
|
* @param configPath - Absolute path to the CLI config file.
|
|
124
160
|
* @returns The fully resolved config.
|
|
125
161
|
*/
|
|
126
162
|
declare function loadConfig(configPath: string): ResolvedConfig;
|
|
127
163
|
//#endregion
|
|
164
|
+
//#region src/config/publishing.d.ts
|
|
165
|
+
/**
|
|
166
|
+
* Renders an artifact's final git tag from its `publishing.tagTemplate` -
|
|
167
|
+
* the one piece of `publishing:` config that can't be resolved at config-load
|
|
168
|
+
* time, since it needs the artifact's version, which is only known once the
|
|
169
|
+
* contract's spec has been bundled.
|
|
170
|
+
*
|
|
171
|
+
* @param artifact - The resolved artifact (for `id` and
|
|
172
|
+
* `publishing.tagTemplate`).
|
|
173
|
+
* @param contractName - The owning contract's name, exposed to the template as
|
|
174
|
+
* `{service}`.
|
|
175
|
+
* @param version - The resolved SDK version, exposed to the template as
|
|
176
|
+
* `{version}`.
|
|
177
|
+
* @param github - `{ owner, repo }`, exposed as `{github.owner}`/
|
|
178
|
+
* `{github.repo}`.
|
|
179
|
+
* @param vars - The config's `vars:` tree, exposed as `{vars.*}`.
|
|
180
|
+
* @returns The rendered tag name.
|
|
181
|
+
*/
|
|
182
|
+
declare function renderArtifactTag(artifact: ResolvedArtifact, contractName: string, version: string, github: {
|
|
183
|
+
owner: string;
|
|
184
|
+
repo: string;
|
|
185
|
+
}, vars: VarsTree): string;
|
|
186
|
+
//#endregion
|
|
128
187
|
//#region src/config/resolve-config-file.d.ts
|
|
129
188
|
/**
|
|
130
189
|
* Config filenames CLI recognizes, checked in this order.
|
|
@@ -142,7 +201,7 @@ declare const CONFIG_FILENAMES: readonly [".seagull", ".seagull.yaml", ".seagull
|
|
|
142
201
|
*/
|
|
143
202
|
declare function resolveConfigPath(cwd: string): string;
|
|
144
203
|
//#endregion
|
|
145
|
-
//#region src/
|
|
204
|
+
//#region src/generator/types.d.ts
|
|
146
205
|
/** Passed once per tool to {@link Generator.prepare}, before any of that
|
|
147
206
|
* tool's {@link Generator.generate} calls run. */
|
|
148
207
|
interface PrepareContext {
|
|
@@ -170,7 +229,7 @@ interface GenerateContext {
|
|
|
170
229
|
specInputPath: string;
|
|
171
230
|
}
|
|
172
231
|
//#endregion
|
|
173
|
-
//#region src/
|
|
232
|
+
//#region src/generator/generator.d.ts
|
|
174
233
|
/**
|
|
175
234
|
* The root primitive every concrete SDK generator implements.
|
|
176
235
|
*
|
|
@@ -200,7 +259,7 @@ declare abstract class Generator {
|
|
|
200
259
|
abstract generate(ctx: GenerateContext): Promise<void>;
|
|
201
260
|
}
|
|
202
261
|
//#endregion
|
|
203
|
-
//#region src/
|
|
262
|
+
//#region src/generator/registry.d.ts
|
|
204
263
|
/**
|
|
205
264
|
* Looks up the concrete {@link Generator} implementation for a given tool name.
|
|
206
265
|
*/
|
|
@@ -229,25 +288,7 @@ declare class GeneratorRegistry {
|
|
|
229
288
|
tools(): SdkTool[];
|
|
230
289
|
}
|
|
231
290
|
//#endregion
|
|
232
|
-
//#region src/
|
|
233
|
-
/**
|
|
234
|
-
* Resolves the absolute path to an installed npm package's own CLI entrypoint
|
|
235
|
-
* script, using Node's standard module resolution algorithm - so it works the
|
|
236
|
-
* same way regardless of which package manager (npm/pnpm/yarn) installed CLI
|
|
237
|
-
* and its dependencies, or how deeply they get hoisted. Shelling out to
|
|
238
|
-
* `pnpm exec`/`npx` instead would assume a specific package manager and a
|
|
239
|
-
* particular install layout, which doesn't hold once CLI is just another
|
|
240
|
-
* dependency in someone else's project.
|
|
241
|
-
*
|
|
242
|
-
* @param pkgName - The npm package name, e.g. `"@org/cli"`.
|
|
243
|
-
* @param binName - Which entry to resolve from that package's `bin` field.
|
|
244
|
-
* Defaults to the package's own unscoped name.
|
|
245
|
-
* @returns The absolute path to the resolved bin script.
|
|
246
|
-
* @throws Error if the package or the requested bin entry can't be found.
|
|
247
|
-
*/
|
|
248
|
-
declare function resolveBinPath(pkgName: string, binName?: string): string;
|
|
249
|
-
//#endregion
|
|
250
|
-
//#region src/core/process/exec.d.ts
|
|
291
|
+
//#region src/process/exec.d.ts
|
|
251
292
|
/**
|
|
252
293
|
* Runs a command to completion, streaming its stdio straight through
|
|
253
294
|
* (`inherit`), and rejects if it exits non-zero.
|
|
@@ -274,6 +315,173 @@ declare function run(command: string, args: string[], cwd: string): Promise<void
|
|
|
274
315
|
*/
|
|
275
316
|
declare function runSync(command: string, args: string[], cwd: string): number;
|
|
276
317
|
//#endregion
|
|
318
|
+
//#region src/process/resolve-bin.d.ts
|
|
319
|
+
/**
|
|
320
|
+
* Resolves the absolute path to an installed npm package's own CLI entrypoint
|
|
321
|
+
* script, using Node's standard module resolution algorithm - so it works the
|
|
322
|
+
* same way regardless of which package manager (npm/pnpm/yarn) installed CLI
|
|
323
|
+
* and its dependencies, or how deeply they get hoisted. Shelling out to
|
|
324
|
+
* `pnpm exec`/`npx` instead would assume a specific package manager and a
|
|
325
|
+
* particular install layout, which doesn't hold once CLI is just another
|
|
326
|
+
* dependency in someone else's project.
|
|
327
|
+
*
|
|
328
|
+
* @param pkgName - The npm package name, e.g. `"@org/cli"`.
|
|
329
|
+
* @param binName - Which entry to resolve from that package's `bin` field.
|
|
330
|
+
* Defaults to the package's own unscoped name.
|
|
331
|
+
* @returns The absolute path to the resolved bin script.
|
|
332
|
+
* @throws Error if the package or the requested bin entry can't be found.
|
|
333
|
+
*/
|
|
334
|
+
declare function resolveBinPath(pkgName: string, binName?: string): string;
|
|
335
|
+
//#endregion
|
|
336
|
+
//#region src/git/git.d.ts
|
|
337
|
+
/**
|
|
338
|
+
* The result of executing a git command.
|
|
339
|
+
*
|
|
340
|
+
* @see {@link git} - The function that executes the git command.
|
|
341
|
+
*/
|
|
342
|
+
interface GitResult {
|
|
343
|
+
status: number;
|
|
344
|
+
stdout: string;
|
|
345
|
+
stderr: string;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Execute a git command in a given working directory and return the result.
|
|
349
|
+
*
|
|
350
|
+
* @param args - The command-line arguments to pass to the git command.
|
|
351
|
+
* @param cwd - The working directory in which to execute the git command.
|
|
352
|
+
* @returns The result of the git command.
|
|
353
|
+
*
|
|
354
|
+
* @see {@link GitResult} - The result of executing the git command.
|
|
355
|
+
*/
|
|
356
|
+
declare function git(args: string[], cwd: string): GitResult;
|
|
357
|
+
/**
|
|
358
|
+
* Check if a remote branch exists in the given repository.
|
|
359
|
+
*
|
|
360
|
+
* @param repoRoot - The root directory of the repository.
|
|
361
|
+
* @param branch - The name of the branch to check.
|
|
362
|
+
* @returns Whether the remote branch exists (true) or not (false).
|
|
363
|
+
*/
|
|
364
|
+
declare function remoteBranchExists(repoRoot: string, branch: string): boolean;
|
|
365
|
+
/**
|
|
366
|
+
* Check if a remote tag exists in the given repository.
|
|
367
|
+
*
|
|
368
|
+
* @param repoRoot - The root directory of the repository.
|
|
369
|
+
* @param tag - The name of the tag to check.
|
|
370
|
+
* @returns Whether the remote tag exists (true) or not (false).
|
|
371
|
+
*/
|
|
372
|
+
declare function tagExists(repoRoot: string, tag: string): boolean;
|
|
373
|
+
/**
|
|
374
|
+
* Read a single file's content as it existed at a given git tag, without
|
|
375
|
+
* checking out a worktree.
|
|
376
|
+
*
|
|
377
|
+
* Returns `null` (rather than throwing) both when the tag can't be fetched and
|
|
378
|
+
* when the tag exists but doesn't contain the requested file - the latter is
|
|
379
|
+
* expected for tags published before that file was introduced, and callers
|
|
380
|
+
* should treat "unknown" the same as "no mismatch to report".
|
|
381
|
+
*
|
|
382
|
+
* @param repoRoot - The root directory of the repository.
|
|
383
|
+
* @param tag - The tag to read the file from.
|
|
384
|
+
* @param filePath - The path of the file within that tag's tree.
|
|
385
|
+
* @returns The file's content, or `null` if it couldn't be read.
|
|
386
|
+
*/
|
|
387
|
+
declare function readFileAtTag(repoRoot: string, tag: string, filePath: string): string | null;
|
|
388
|
+
/**
|
|
389
|
+
* Require that a git command succeeded, throwing an error with the given
|
|
390
|
+
* message if it did not.
|
|
391
|
+
*
|
|
392
|
+
* @param result - The result of the git command to check.
|
|
393
|
+
* @param message - The error message to throw if the command failed.
|
|
394
|
+
* @throws Error if the git command failed (non-zero exit code).
|
|
395
|
+
*/
|
|
396
|
+
declare function requireOk(result: GitResult, message: string): void;
|
|
397
|
+
//#endregion
|
|
398
|
+
//#region src/version/version.d.ts
|
|
399
|
+
/**
|
|
400
|
+
* Shape of a bundled OpenAPI document, narrowed to the one field this module
|
|
401
|
+
* cares about.
|
|
402
|
+
*/
|
|
403
|
+
interface BundledSpec {
|
|
404
|
+
info?: {
|
|
405
|
+
version?: string;
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Resolves the version to stamp onto a single contract's generated SDK
|
|
410
|
+
* artifacts (npm/Maven packages, Go module tags, git branches, etc.).
|
|
411
|
+
*
|
|
412
|
+
* The single source of truth is that contract's own `info.version` field in its
|
|
413
|
+
* `openapi.yaml` - bump it there and every artifact, package, and git tag for
|
|
414
|
+
* that contract picks up the new version on the next release. Versions are
|
|
415
|
+
* resolved independently per contract: two services can be at different
|
|
416
|
+
* versions at the same time.
|
|
417
|
+
*
|
|
418
|
+
* `SDK_VERSION_OVERRIDE` (wired up from the release workflow's manual `version`
|
|
419
|
+
* input) bypasses the spec entirely and stamps every contract with the same
|
|
420
|
+
* given value. It exists for one-off emergency republishes, not routine
|
|
421
|
+
* releases. Routine releases should always go through `info.version`.
|
|
422
|
+
*
|
|
423
|
+
* @param spec - The parsed, bundled OpenAPI document for the contract.
|
|
424
|
+
* @param contractName - The contract name, used only for the error message.
|
|
425
|
+
* @returns The resolved version string (no leading `v`).
|
|
426
|
+
* @throws Error if no override is set and the spec has no `info.version`.
|
|
427
|
+
*/
|
|
428
|
+
declare function resolveVersion(spec: BundledSpec, contractName: string): string;
|
|
429
|
+
/**
|
|
430
|
+
* Computes a stable content hash of a bundled OpenAPI document's raw JSON text.
|
|
431
|
+
* Stamped alongside `VERSION` into every generated SDK package so
|
|
432
|
+
* `publish-sdk.ts` can tell a genuine no-op republish (same spec, same version)
|
|
433
|
+
* apart from a spec that changed without its `info.version` being bumped.
|
|
434
|
+
*
|
|
435
|
+
* @param raw - The raw bundled spec file contents (JSON text).
|
|
436
|
+
* @returns A `sha256` hex digest of the raw contents.
|
|
437
|
+
*/
|
|
438
|
+
declare function hashSpec(raw: string): string;
|
|
439
|
+
//#endregion
|
|
440
|
+
//#region src/readme/readme-renderer.d.ts
|
|
441
|
+
interface RenderReadmeArgs {
|
|
442
|
+
contract: ResolvedContract;
|
|
443
|
+
artifact: ResolvedArtifact;
|
|
444
|
+
version: string;
|
|
445
|
+
github: {
|
|
446
|
+
owner: string;
|
|
447
|
+
repo: string;
|
|
448
|
+
};
|
|
449
|
+
vars: VarsTree;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Renders the root-level `README.md` for a generated SDK package.
|
|
453
|
+
*
|
|
454
|
+
* If the artifact has a `readme:` path configured (resolved at config-load time
|
|
455
|
+
* to `artifact.readmeTemplate`), that file is read and interpolated with the
|
|
456
|
+
* same `{...}` placeholder engine naming templates use - `{service}`,
|
|
457
|
+
* `{title}`, `{version}`, `{vars.*}`, `{github.owner}`, `{github.repo}`, plus
|
|
458
|
+
* `{artifact.*}` (id/lang/kind/package/goModule/goPackageName/maven.groupId/
|
|
459
|
+
* maven.artifactId/branch/tag/npmRegistry/mavenRepositoryUrl). Otherwise,
|
|
460
|
+
* falls back to a built-in default template for the artifact's language/kind.
|
|
461
|
+
*
|
|
462
|
+
* @param args - The contract, artifact, version, and github/vars context to
|
|
463
|
+
* render for.
|
|
464
|
+
* @returns The rendered README content.
|
|
465
|
+
*/
|
|
466
|
+
declare function renderReadme(args: RenderReadmeArgs): Promise<string>;
|
|
467
|
+
//#endregion
|
|
468
|
+
//#region src/redocly/redocly-sync.d.ts
|
|
469
|
+
/**
|
|
470
|
+
* Regenerates `redocly.yaml`'s `apis:` section from the resolved CLI config,
|
|
471
|
+
* merging it with the hand-authored `extends`/`rules` in `redocly.base.yaml`.
|
|
472
|
+
*
|
|
473
|
+
* The CLI config stays the single source of truth for which APIs exist and
|
|
474
|
+
* where their TypeScript server types land, instead of that being duplicated
|
|
475
|
+
* by hand into `redocly.yaml`.
|
|
476
|
+
*
|
|
477
|
+
* Called at the start of every command that shells out to `redocly` or
|
|
478
|
+
* `openapi-typescript` (both read `redocly.yaml` directly), so it's always
|
|
479
|
+
* up to date before those tools run.
|
|
480
|
+
*
|
|
481
|
+
* @param config - The resolved CLI config.
|
|
482
|
+
*/
|
|
483
|
+
declare function syncRedoclyConfig(config: ResolvedConfig): Promise<void>;
|
|
484
|
+
//#endregion
|
|
277
485
|
//#region src/generators/openapi-generator-cli/openapi-generator-cli.generator.d.ts
|
|
278
486
|
/**
|
|
279
487
|
* Wraps `openapi-generator-cli` - the single tool implementation behind every
|
|
@@ -301,14 +509,944 @@ declare class OpenApiGeneratorCli extends Generator {
|
|
|
301
509
|
declare class OpenApiTypescriptGenerator extends Generator {
|
|
302
510
|
readonly tool: SdkTool;
|
|
303
511
|
prepare({ rootDir, entries }: PrepareContext): Promise<void>;
|
|
304
|
-
generate({ contract, artifact, version
|
|
512
|
+
generate({ contract, artifact, version }: GenerateContext): Promise<void>;
|
|
305
513
|
}
|
|
306
514
|
//#endregion
|
|
515
|
+
//#region node_modules/.pnpm/commander@15.0.0/node_modules/commander/typings/index.d.ts
|
|
516
|
+
// Type definitions for commander
|
|
517
|
+
// Original definitions by: Alan Agius <https://github.com/alan-agius4>, Marcelo Dezem <https://github.com/mdezem>, vvakame <https://github.com/vvakame>, Jules Randolph <https://github.com/sveinburne>
|
|
518
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
519
|
+
// This is a trick to encourage editor to suggest the known literals while still
|
|
520
|
+
// allowing any BaseType value.
|
|
521
|
+
// References:
|
|
522
|
+
// - https://github.com/microsoft/TypeScript/issues/29729
|
|
523
|
+
// - https://github.com/sindresorhus/type-fest/blob/main/source/literal-union.d.ts
|
|
524
|
+
// - https://github.com/sindresorhus/type-fest/blob/main/source/primitive.d.ts
|
|
525
|
+
type LiteralUnion<LiteralType, BaseType extends string | number> = LiteralType | (BaseType & Record<never, never>);
|
|
526
|
+
declare class CommanderError extends Error {
|
|
527
|
+
code: string;
|
|
528
|
+
exitCode: number;
|
|
529
|
+
message: string;
|
|
530
|
+
nestedError?: string;
|
|
531
|
+
/**
|
|
532
|
+
* Constructs the CommanderError class
|
|
533
|
+
* @param exitCode - suggested exit code which could be used with process.exit
|
|
534
|
+
* @param code - an id string representing the error
|
|
535
|
+
* @param message - human-readable description of the error
|
|
536
|
+
*/
|
|
537
|
+
constructor(exitCode: number, code: string, message: string);
|
|
538
|
+
}
|
|
539
|
+
interface ErrorOptions {
|
|
540
|
+
// optional parameter for error()
|
|
541
|
+
/** an id string representing the error */
|
|
542
|
+
code?: string;
|
|
543
|
+
/** suggested exit code which could be used with process.exit */
|
|
544
|
+
exitCode?: number;
|
|
545
|
+
}
|
|
546
|
+
declare class Argument {
|
|
547
|
+
description: string;
|
|
548
|
+
required: boolean;
|
|
549
|
+
variadic: boolean;
|
|
550
|
+
defaultValue?: any;
|
|
551
|
+
defaultValueDescription?: string;
|
|
552
|
+
parseArg?: <T>(value: string, previous: T) => T;
|
|
553
|
+
argChoices?: string[];
|
|
554
|
+
/**
|
|
555
|
+
* Initialize a new command argument with the given name and description.
|
|
556
|
+
* The default is that the argument is required, and you can explicitly
|
|
557
|
+
* indicate this with <> around the name. Put [] around the name for an optional argument.
|
|
558
|
+
*/
|
|
559
|
+
constructor(arg: string, description?: string);
|
|
560
|
+
/**
|
|
561
|
+
* Return argument name.
|
|
562
|
+
*/
|
|
563
|
+
name(): string;
|
|
564
|
+
/**
|
|
565
|
+
* Set the default value, and optionally supply the description to be displayed in the help.
|
|
566
|
+
*/
|
|
567
|
+
default(value: unknown, description?: string): this;
|
|
568
|
+
/**
|
|
569
|
+
* Set the custom handler for processing CLI command arguments into argument values.
|
|
570
|
+
*/
|
|
571
|
+
argParser<T>(fn: (value: string, previous: T) => T): this;
|
|
572
|
+
/**
|
|
573
|
+
* Only allow argument value to be one of choices.
|
|
574
|
+
*/
|
|
575
|
+
choices(values: readonly string[]): this;
|
|
576
|
+
/**
|
|
577
|
+
* Make argument required.
|
|
578
|
+
*/
|
|
579
|
+
argRequired(): this;
|
|
580
|
+
/**
|
|
581
|
+
* Make argument optional.
|
|
582
|
+
*/
|
|
583
|
+
argOptional(): this;
|
|
584
|
+
}
|
|
585
|
+
declare class Option {
|
|
586
|
+
flags: string;
|
|
587
|
+
description: string;
|
|
588
|
+
required: boolean; // A value must be supplied when the option is specified.
|
|
589
|
+
optional: boolean; // A value is optional when the option is specified.
|
|
590
|
+
variadic: boolean;
|
|
591
|
+
mandatory: boolean; // The option must have a value after parsing, which usually means it must be specified on command line.
|
|
592
|
+
short?: string;
|
|
593
|
+
long?: string;
|
|
594
|
+
negate: boolean;
|
|
595
|
+
defaultValue?: any;
|
|
596
|
+
defaultValueDescription?: string;
|
|
597
|
+
presetArg?: unknown;
|
|
598
|
+
envVar?: string;
|
|
599
|
+
parseArg?: <T>(value: string, previous: T) => T;
|
|
600
|
+
hidden: boolean;
|
|
601
|
+
argChoices?: string[];
|
|
602
|
+
helpGroupHeading?: string;
|
|
603
|
+
constructor(flags: string, description?: string);
|
|
604
|
+
/**
|
|
605
|
+
* Set the default value, and optionally supply the description to be displayed in the help.
|
|
606
|
+
*/
|
|
607
|
+
default(value: unknown, description?: string): this;
|
|
608
|
+
/**
|
|
609
|
+
* Preset to use when option used without option-argument, especially optional but also boolean and negated.
|
|
610
|
+
* The custom processing (parseArg) is called.
|
|
611
|
+
*
|
|
612
|
+
* @example
|
|
613
|
+
* ```ts
|
|
614
|
+
* new Option('--color').default('GREYSCALE').preset('RGB');
|
|
615
|
+
* new Option('--donate [amount]').preset('20').argParser(parseFloat);
|
|
616
|
+
* ```
|
|
617
|
+
*/
|
|
618
|
+
preset(arg: unknown): this;
|
|
619
|
+
/**
|
|
620
|
+
* Add option name(s) that conflict with this option.
|
|
621
|
+
* An error will be displayed if conflicting options are found during parsing.
|
|
622
|
+
*
|
|
623
|
+
* @example
|
|
624
|
+
* ```ts
|
|
625
|
+
* new Option('--rgb').conflicts('cmyk');
|
|
626
|
+
* new Option('--js').conflicts(['ts', 'jsx']);
|
|
627
|
+
* ```
|
|
628
|
+
*/
|
|
629
|
+
conflicts(names: string | string[]): this;
|
|
630
|
+
/**
|
|
631
|
+
* Specify implied option values for when this option is set and the implied options are not.
|
|
632
|
+
*
|
|
633
|
+
* The custom processing (parseArg) is not called on the implied values.
|
|
634
|
+
*
|
|
635
|
+
* @example
|
|
636
|
+
* program
|
|
637
|
+
* .addOption(new Option('--log', 'write logging information to file'))
|
|
638
|
+
* .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));
|
|
639
|
+
*/
|
|
640
|
+
implies(optionValues: OptionValues): this;
|
|
641
|
+
/**
|
|
642
|
+
* Set environment variable to check for option value.
|
|
643
|
+
*
|
|
644
|
+
* An environment variables is only used if when processed the current option value is
|
|
645
|
+
* undefined, or the source of the current value is 'default' or 'config' or 'env'.
|
|
646
|
+
*/
|
|
647
|
+
env(name: string): this;
|
|
648
|
+
/**
|
|
649
|
+
* Set the custom handler for processing CLI option arguments into option values.
|
|
650
|
+
*/
|
|
651
|
+
argParser<T>(fn: (value: string, previous: T) => T): this;
|
|
652
|
+
/**
|
|
653
|
+
* Whether the option is mandatory and must have a value after parsing.
|
|
654
|
+
*/
|
|
655
|
+
makeOptionMandatory(mandatory?: boolean): this;
|
|
656
|
+
/**
|
|
657
|
+
* Hide option in help.
|
|
658
|
+
*/
|
|
659
|
+
hideHelp(hide?: boolean): this;
|
|
660
|
+
/**
|
|
661
|
+
* Only allow option value to be one of choices.
|
|
662
|
+
*/
|
|
663
|
+
choices(values: readonly string[]): this;
|
|
664
|
+
/**
|
|
665
|
+
* Return option name.
|
|
666
|
+
*/
|
|
667
|
+
name(): string;
|
|
668
|
+
/**
|
|
669
|
+
* Return option name, in a camelcase format that can be used
|
|
670
|
+
* as an object attribute key.
|
|
671
|
+
*/
|
|
672
|
+
attributeName(): string;
|
|
673
|
+
/**
|
|
674
|
+
* Set the help group heading.
|
|
675
|
+
*/
|
|
676
|
+
helpGroup(heading: string): this;
|
|
677
|
+
/**
|
|
678
|
+
* Return whether a boolean option.
|
|
679
|
+
*
|
|
680
|
+
* Options are one of boolean, negated, required argument, or optional argument.
|
|
681
|
+
*/
|
|
682
|
+
isBoolean(): boolean;
|
|
683
|
+
}
|
|
684
|
+
declare class Help {
|
|
685
|
+
/** output helpWidth, long lines are wrapped to fit */
|
|
686
|
+
helpWidth?: number;
|
|
687
|
+
minWidthToWrap: number;
|
|
688
|
+
sortSubcommands: boolean;
|
|
689
|
+
sortOptions: boolean;
|
|
690
|
+
showGlobalOptions: boolean;
|
|
691
|
+
constructor();
|
|
692
|
+
/*
|
|
693
|
+
* prepareContext is called by Commander after applying overrides from `Command.configureHelp()`
|
|
694
|
+
* and just before calling `formatHelp()`.
|
|
695
|
+
*
|
|
696
|
+
* Commander just uses the helpWidth and the others are provided for subclasses.
|
|
697
|
+
*/
|
|
698
|
+
prepareContext(contextOptions: {
|
|
699
|
+
error?: boolean;
|
|
700
|
+
helpWidth?: number;
|
|
701
|
+
outputHasColors?: boolean;
|
|
702
|
+
}): void;
|
|
703
|
+
/** Get the command term to show in the list of subcommands. */
|
|
704
|
+
subcommandTerm(cmd: Command): string;
|
|
705
|
+
/** Get the command summary to show in the list of subcommands. */
|
|
706
|
+
subcommandDescription(cmd: Command): string;
|
|
707
|
+
/** Get the option term to show in the list of options. */
|
|
708
|
+
optionTerm(option: Option): string;
|
|
709
|
+
/** Get the option description to show in the list of options. */
|
|
710
|
+
optionDescription(option: Option): string;
|
|
711
|
+
/** Get the argument term to show in the list of arguments. */
|
|
712
|
+
argumentTerm(argument: Argument): string;
|
|
713
|
+
/** Get the argument description to show in the list of arguments. */
|
|
714
|
+
argumentDescription(argument: Argument): string;
|
|
715
|
+
/** Get the command usage to be displayed at the top of the built-in help. */
|
|
716
|
+
commandUsage(cmd: Command): string;
|
|
717
|
+
/** Get the description for the command. */
|
|
718
|
+
commandDescription(cmd: Command): string;
|
|
719
|
+
/** Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one. */
|
|
720
|
+
visibleCommands(cmd: Command): Command[];
|
|
721
|
+
/** Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one. */
|
|
722
|
+
visibleOptions(cmd: Command): Option[];
|
|
723
|
+
/** Get an array of the visible global options. (Not including help.) */
|
|
724
|
+
visibleGlobalOptions(cmd: Command): Option[];
|
|
725
|
+
/** Get an array of the arguments which have descriptions. */
|
|
726
|
+
visibleArguments(cmd: Command): Argument[];
|
|
727
|
+
/** Get the longest command term length. */
|
|
728
|
+
longestSubcommandTermLength(cmd: Command, helper: Help): number;
|
|
729
|
+
/** Get the longest option term length. */
|
|
730
|
+
longestOptionTermLength(cmd: Command, helper: Help): number;
|
|
731
|
+
/** Get the longest global option term length. */
|
|
732
|
+
longestGlobalOptionTermLength(cmd: Command, helper: Help): number;
|
|
733
|
+
/** Get the longest argument term length. */
|
|
734
|
+
longestArgumentTermLength(cmd: Command, helper: Help): number;
|
|
735
|
+
/** Return display width of string, ignoring ANSI escape sequences. Used in padding and wrapping calculations. */
|
|
736
|
+
displayWidth(str: string): number;
|
|
737
|
+
/** Style the titles. Called with 'Usage:', 'Options:', etc. */
|
|
738
|
+
styleTitle(title: string): string;
|
|
739
|
+
/** Usage: <str> */
|
|
740
|
+
styleUsage(str: string): string;
|
|
741
|
+
/** Style for command name in usage string. */
|
|
742
|
+
styleCommandText(str: string): string;
|
|
743
|
+
styleCommandDescription(str: string): string;
|
|
744
|
+
styleOptionDescription(str: string): string;
|
|
745
|
+
styleSubcommandDescription(str: string): string;
|
|
746
|
+
styleArgumentDescription(str: string): string;
|
|
747
|
+
/** Base style used by descriptions. */
|
|
748
|
+
styleDescriptionText(str: string): string;
|
|
749
|
+
styleOptionTerm(str: string): string;
|
|
750
|
+
styleSubcommandTerm(str: string): string;
|
|
751
|
+
styleArgumentTerm(str: string): string;
|
|
752
|
+
/** Base style used in terms and usage for options. */
|
|
753
|
+
styleOptionText(str: string): string;
|
|
754
|
+
/** Base style used in terms and usage for subcommands. */
|
|
755
|
+
styleSubcommandText(str: string): string;
|
|
756
|
+
/** Base style used in terms and usage for arguments. */
|
|
757
|
+
styleArgumentText(str: string): string;
|
|
758
|
+
/** Calculate the pad width from the maximum term length. */
|
|
759
|
+
padWidth(cmd: Command, helper: Help): number;
|
|
760
|
+
/**
|
|
761
|
+
* Wrap a string at whitespace, preserving existing line breaks.
|
|
762
|
+
* Wrapping is skipped if the width is less than `minWidthToWrap`.
|
|
763
|
+
*/
|
|
764
|
+
boxWrap(str: string, width: number): string;
|
|
765
|
+
/** Detect manually wrapped and indented strings by checking for line break followed by whitespace. */
|
|
766
|
+
preformatted(str: string): boolean;
|
|
767
|
+
/**
|
|
768
|
+
* Format the "item", which consists of a term and description. Pad the term and wrap the description, indenting the following lines.
|
|
769
|
+
*
|
|
770
|
+
* So "TTT", 5, "DDD DDDD DD DDD" might be formatted for this.helpWidth=17 like so:
|
|
771
|
+
* TTT DDD DDDD
|
|
772
|
+
* DD DDD
|
|
773
|
+
*/
|
|
774
|
+
formatItem(term: string, termWidth: number, description: string, helper: Help): string;
|
|
775
|
+
/**
|
|
776
|
+
* Format a list of items, given a heading and an array of formatted items.
|
|
777
|
+
*/
|
|
778
|
+
formatItemList(heading: string, items: string[], helper: Help): string[];
|
|
779
|
+
/**
|
|
780
|
+
* Group items by their help group heading.
|
|
781
|
+
*/
|
|
782
|
+
groupItems<T extends Command | Option>(unsortedItems: T[], visibleItems: T[], getGroup: (item: T) => string): Map<string, T[]>;
|
|
783
|
+
/** Generate the built-in help text. */
|
|
784
|
+
formatHelp(cmd: Command, helper: Help): string;
|
|
785
|
+
}
|
|
786
|
+
type HelpConfiguration = Partial<Help>;
|
|
787
|
+
interface ParseOptions {
|
|
788
|
+
from: 'node' | 'electron' | 'user';
|
|
789
|
+
}
|
|
790
|
+
interface HelpContext {
|
|
791
|
+
// optional parameter for .help() and .outputHelp()
|
|
792
|
+
error: boolean;
|
|
793
|
+
}
|
|
794
|
+
interface AddHelpTextContext {
|
|
795
|
+
// passed to text function used with .addHelpText()
|
|
796
|
+
error: boolean;
|
|
797
|
+
command: Command;
|
|
798
|
+
}
|
|
799
|
+
interface OutputConfiguration {
|
|
800
|
+
writeOut?(str: string): void;
|
|
801
|
+
writeErr?(str: string): void;
|
|
802
|
+
outputError?(str: string, write: (str: string) => void): void;
|
|
803
|
+
getOutHelpWidth?(): number;
|
|
804
|
+
getErrHelpWidth?(): number;
|
|
805
|
+
getOutHasColors?(): boolean;
|
|
806
|
+
getErrHasColors?(): boolean;
|
|
807
|
+
stripColor?(str: string): string;
|
|
808
|
+
}
|
|
809
|
+
type AddHelpTextPosition = 'beforeAll' | 'before' | 'after' | 'afterAll';
|
|
810
|
+
type HookEvent = 'preSubcommand' | 'preAction' | 'postAction';
|
|
811
|
+
// The source is a string so author can define their own too.
|
|
812
|
+
type OptionValueSource = LiteralUnion<'default' | 'config' | 'env' | 'cli' | 'implied', string> | undefined;
|
|
813
|
+
type OptionValues = Record<string, any>;
|
|
814
|
+
declare class Command {
|
|
815
|
+
args: string[];
|
|
816
|
+
processedArgs: any[];
|
|
817
|
+
readonly commands: readonly Command[];
|
|
818
|
+
readonly options: readonly Option[];
|
|
819
|
+
readonly registeredArguments: readonly Argument[];
|
|
820
|
+
parent: Command | null;
|
|
821
|
+
constructor(name?: string);
|
|
822
|
+
/**
|
|
823
|
+
* Set the program version to `str`.
|
|
824
|
+
*
|
|
825
|
+
* This method auto-registers the "-V, --version" flag
|
|
826
|
+
* which will print the version number when passed.
|
|
827
|
+
*
|
|
828
|
+
* You can optionally supply the flags and description to override the defaults.
|
|
829
|
+
*/
|
|
830
|
+
version(str: string, flags?: string, description?: string): this;
|
|
831
|
+
/**
|
|
832
|
+
* Get the program version.
|
|
833
|
+
*/
|
|
834
|
+
version(): string | undefined;
|
|
835
|
+
/**
|
|
836
|
+
* Define a command, implemented using an action handler.
|
|
837
|
+
*
|
|
838
|
+
* @remarks
|
|
839
|
+
* The command description is supplied using `.description`, not as a parameter to `.command`.
|
|
840
|
+
*
|
|
841
|
+
* @example
|
|
842
|
+
* ```ts
|
|
843
|
+
* program
|
|
844
|
+
* .command('clone <source> [destination]')
|
|
845
|
+
* .description('clone a repository into a newly created directory')
|
|
846
|
+
* .action((source, destination) => {
|
|
847
|
+
* console.log('clone command called');
|
|
848
|
+
* });
|
|
849
|
+
* ```
|
|
850
|
+
*
|
|
851
|
+
* @param nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
|
|
852
|
+
* @param opts - configuration options
|
|
853
|
+
* @returns new command
|
|
854
|
+
*/
|
|
855
|
+
command(nameAndArgs: string, opts?: CommandOptions): ReturnType<this['createCommand']>;
|
|
856
|
+
/**
|
|
857
|
+
* Define a command, implemented in a separate executable file.
|
|
858
|
+
*
|
|
859
|
+
* @remarks
|
|
860
|
+
* The command description is supplied as the second parameter to `.command`.
|
|
861
|
+
*
|
|
862
|
+
* @example
|
|
863
|
+
* ```ts
|
|
864
|
+
* program
|
|
865
|
+
* .command('start <service>', 'start named service')
|
|
866
|
+
* .command('stop [service]', 'stop named service, or all if no name supplied');
|
|
867
|
+
* ```
|
|
868
|
+
*
|
|
869
|
+
* @param nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
|
|
870
|
+
* @param description - description of executable command
|
|
871
|
+
* @param opts - configuration options
|
|
872
|
+
* @returns `this` command for chaining
|
|
873
|
+
*/
|
|
874
|
+
command(nameAndArgs: string, description: string, opts?: ExecutableCommandOptions): this;
|
|
875
|
+
/**
|
|
876
|
+
* Factory routine to create a new unattached command.
|
|
877
|
+
*
|
|
878
|
+
* See .command() for creating an attached subcommand, which uses this routine to
|
|
879
|
+
* create the command. You can override createCommand to customise subcommands.
|
|
880
|
+
*/
|
|
881
|
+
createCommand(name?: string): Command;
|
|
882
|
+
/**
|
|
883
|
+
* Add a prepared subcommand.
|
|
884
|
+
*
|
|
885
|
+
* See .command() for creating an attached subcommand which inherits settings from its parent.
|
|
886
|
+
*
|
|
887
|
+
* @returns `this` command for chaining
|
|
888
|
+
*/
|
|
889
|
+
addCommand(cmd: Command, opts?: CommandOptions): this;
|
|
890
|
+
/**
|
|
891
|
+
* Factory routine to create a new unattached argument.
|
|
892
|
+
*
|
|
893
|
+
* See .argument() for creating an attached argument, which uses this routine to
|
|
894
|
+
* create the argument. You can override createArgument to return a custom argument.
|
|
895
|
+
*/
|
|
896
|
+
createArgument(name: string, description?: string): Argument;
|
|
897
|
+
/**
|
|
898
|
+
* Define argument syntax for command.
|
|
899
|
+
*
|
|
900
|
+
* The default is that the argument is required, and you can explicitly
|
|
901
|
+
* indicate this with <> around the name. Put [] around the name for an optional argument.
|
|
902
|
+
*
|
|
903
|
+
* @example
|
|
904
|
+
* ```
|
|
905
|
+
* program.argument('<input-file>');
|
|
906
|
+
* program.argument('[output-file]');
|
|
907
|
+
* ```
|
|
908
|
+
*
|
|
909
|
+
* @returns `this` command for chaining
|
|
910
|
+
*/
|
|
911
|
+
argument<T>(flags: string, description: string, parseArg: (value: string, previous: T) => T, defaultValue?: T): this;
|
|
912
|
+
argument(name: string, description?: string, defaultValue?: unknown): this;
|
|
913
|
+
/**
|
|
914
|
+
* Define argument syntax for command, adding a prepared argument.
|
|
915
|
+
*
|
|
916
|
+
* @returns `this` command for chaining
|
|
917
|
+
*/
|
|
918
|
+
addArgument(arg: Argument): this;
|
|
919
|
+
/**
|
|
920
|
+
* Define argument syntax for command, adding multiple at once (without descriptions).
|
|
921
|
+
*
|
|
922
|
+
* See also .argument().
|
|
923
|
+
*
|
|
924
|
+
* @example
|
|
925
|
+
* ```
|
|
926
|
+
* program.arguments('<cmd> [env]');
|
|
927
|
+
* ```
|
|
928
|
+
*
|
|
929
|
+
* @returns `this` command for chaining
|
|
930
|
+
*/
|
|
931
|
+
arguments(names: string): this;
|
|
932
|
+
/**
|
|
933
|
+
* Customise or override default help command. By default a help command is automatically added if your command has subcommands.
|
|
934
|
+
*
|
|
935
|
+
* @example
|
|
936
|
+
* ```ts
|
|
937
|
+
* program.helpCommand('help [cmd]');
|
|
938
|
+
* program.helpCommand('help [cmd]', 'show help');
|
|
939
|
+
* program.helpCommand(false); // suppress default help command
|
|
940
|
+
* program.helpCommand(true); // add help command even if no subcommands
|
|
941
|
+
* ```
|
|
942
|
+
*/
|
|
943
|
+
helpCommand(nameAndArgs: string, description?: string): this;
|
|
944
|
+
helpCommand(enable: boolean): this;
|
|
945
|
+
/**
|
|
946
|
+
* Add prepared custom help command.
|
|
947
|
+
*/
|
|
948
|
+
addHelpCommand(cmd: Command): this;
|
|
949
|
+
/** @deprecated since v12, instead use helpCommand */
|
|
950
|
+
addHelpCommand(nameAndArgs: string, description?: string): this;
|
|
951
|
+
/** @deprecated since v12, instead use helpCommand */
|
|
952
|
+
addHelpCommand(enable?: boolean): this;
|
|
953
|
+
/**
|
|
954
|
+
* Add hook for life cycle event.
|
|
955
|
+
*/
|
|
956
|
+
hook(event: HookEvent, listener: (thisCommand: Command, actionCommand: Command) => void | Promise<void>): this;
|
|
957
|
+
/**
|
|
958
|
+
* Register callback to use as replacement for calling process.exit.
|
|
959
|
+
*/
|
|
960
|
+
exitOverride(callback?: (err: CommanderError) => never | void): this;
|
|
961
|
+
/**
|
|
962
|
+
* Display error message and exit (or call exitOverride).
|
|
963
|
+
*/
|
|
964
|
+
error(message: string, errorOptions?: ErrorOptions): never;
|
|
965
|
+
/**
|
|
966
|
+
* You can customise the help with a subclass of Help by overriding createHelp,
|
|
967
|
+
* or by overriding Help properties using configureHelp().
|
|
968
|
+
*/
|
|
969
|
+
createHelp(): Help;
|
|
970
|
+
/**
|
|
971
|
+
* You can customise the help by overriding Help properties using configureHelp(),
|
|
972
|
+
* or with a subclass of Help by overriding createHelp().
|
|
973
|
+
*/
|
|
974
|
+
configureHelp(configuration: HelpConfiguration): this;
|
|
975
|
+
/** Get configuration */
|
|
976
|
+
configureHelp(): HelpConfiguration;
|
|
977
|
+
/**
|
|
978
|
+
* The default output goes to stdout and stderr. You can customise this for special
|
|
979
|
+
* applications. You can also customise the display of errors by overriding outputError.
|
|
980
|
+
*
|
|
981
|
+
* The configuration properties are all functions:
|
|
982
|
+
* ```
|
|
983
|
+
* // functions to change where being written, stdout and stderr
|
|
984
|
+
* writeOut(str)
|
|
985
|
+
* writeErr(str)
|
|
986
|
+
* // matching functions to specify width for wrapping help
|
|
987
|
+
* getOutHelpWidth()
|
|
988
|
+
* getErrHelpWidth()
|
|
989
|
+
* // functions based on what is being written out
|
|
990
|
+
* outputError(str, write) // used for displaying errors, and not used for displaying help
|
|
991
|
+
* ```
|
|
992
|
+
*/
|
|
993
|
+
configureOutput(configuration: OutputConfiguration): this;
|
|
994
|
+
/** Get configuration */
|
|
995
|
+
configureOutput(): OutputConfiguration;
|
|
996
|
+
/**
|
|
997
|
+
* Copy settings that are useful to have in common across root command and subcommands.
|
|
998
|
+
*
|
|
999
|
+
* (Used internally when adding a command using `.command()` so subcommands inherit parent settings.)
|
|
1000
|
+
*/
|
|
1001
|
+
copyInheritedSettings(sourceCommand: Command): this;
|
|
1002
|
+
/**
|
|
1003
|
+
* Display the help or a custom message after an error occurs.
|
|
1004
|
+
*/
|
|
1005
|
+
showHelpAfterError(displayHelp?: boolean | string): this;
|
|
1006
|
+
/**
|
|
1007
|
+
* Display suggestion of similar commands for unknown commands, or options for unknown options.
|
|
1008
|
+
*/
|
|
1009
|
+
showSuggestionAfterError(displaySuggestion?: boolean): this;
|
|
1010
|
+
/**
|
|
1011
|
+
* Register callback `fn` for the command.
|
|
1012
|
+
*
|
|
1013
|
+
* @example
|
|
1014
|
+
* ```
|
|
1015
|
+
* program
|
|
1016
|
+
* .command('serve')
|
|
1017
|
+
* .description('start service')
|
|
1018
|
+
* .action(function() {
|
|
1019
|
+
* // do work here
|
|
1020
|
+
* });
|
|
1021
|
+
* ```
|
|
1022
|
+
*
|
|
1023
|
+
* @returns `this` command for chaining
|
|
1024
|
+
*/
|
|
1025
|
+
action(fn: (this: this, ...args: any[]) => void | Promise<void>): this;
|
|
1026
|
+
/**
|
|
1027
|
+
* Define option with `flags`, `description`, and optional argument parsing function or `defaultValue` or both.
|
|
1028
|
+
*
|
|
1029
|
+
* The `flags` string contains the short and/or long flags, separated by comma, a pipe or space. A required
|
|
1030
|
+
* option-argument is indicated by `<>` and an optional option-argument by `[]`.
|
|
1031
|
+
*
|
|
1032
|
+
* See the README for more details, and see also addOption() and requiredOption().
|
|
1033
|
+
*
|
|
1034
|
+
* @example
|
|
1035
|
+
*
|
|
1036
|
+
* ```js
|
|
1037
|
+
* program
|
|
1038
|
+
* .option('-p, --pepper', 'add pepper')
|
|
1039
|
+
* .option('--pt, --pizza-type <TYPE>', 'type of pizza') // required option-argument
|
|
1040
|
+
* .option('-c, --cheese [CHEESE]', 'add extra cheese', 'mozzarella') // optional option-argument with default
|
|
1041
|
+
* .option('-t, --tip <VALUE>', 'add tip to purchase cost', parseFloat) // custom parse function
|
|
1042
|
+
* ```
|
|
1043
|
+
*
|
|
1044
|
+
* @returns `this` command for chaining
|
|
1045
|
+
*/
|
|
1046
|
+
option(flags: string, description?: string, defaultValue?: string | boolean | string[]): this;
|
|
1047
|
+
option<T>(flags: string, description: string, parseArg: (value: string, previous: T) => T, defaultValue?: T): this;
|
|
1048
|
+
/** @deprecated since v7, instead use choices or a custom function */
|
|
1049
|
+
option(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean | string[]): this;
|
|
1050
|
+
/**
|
|
1051
|
+
* Define a required option, which must have a value after parsing. This usually means
|
|
1052
|
+
* the option must be specified on the command line. (Otherwise the same as .option().)
|
|
1053
|
+
*
|
|
1054
|
+
* The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
|
|
1055
|
+
*/
|
|
1056
|
+
requiredOption(flags: string, description?: string, defaultValue?: string | boolean | string[]): this;
|
|
1057
|
+
requiredOption<T>(flags: string, description: string, parseArg: (value: string, previous: T) => T, defaultValue?: T): this;
|
|
1058
|
+
/** @deprecated since v7, instead use choices or a custom function */
|
|
1059
|
+
requiredOption(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean | string[]): this;
|
|
1060
|
+
/**
|
|
1061
|
+
* Factory routine to create a new unattached option.
|
|
1062
|
+
*
|
|
1063
|
+
* See .option() for creating an attached option, which uses this routine to
|
|
1064
|
+
* create the option. You can override createOption to return a custom option.
|
|
1065
|
+
*/
|
|
1066
|
+
createOption(flags: string, description?: string): Option;
|
|
1067
|
+
/**
|
|
1068
|
+
* Add a prepared Option.
|
|
1069
|
+
*
|
|
1070
|
+
* See .option() and .requiredOption() for creating and attaching an option in a single call.
|
|
1071
|
+
*/
|
|
1072
|
+
addOption(option: Option): this;
|
|
1073
|
+
/**
|
|
1074
|
+
* Whether to store option values as properties on command object,
|
|
1075
|
+
* or store separately (specify false). In both cases the option values can be accessed using .opts().
|
|
1076
|
+
*
|
|
1077
|
+
* @returns `this` command for chaining
|
|
1078
|
+
*/
|
|
1079
|
+
storeOptionsAsProperties<T extends OptionValues>(): this & T;
|
|
1080
|
+
storeOptionsAsProperties<T extends OptionValues>(storeAsProperties: true): this & T;
|
|
1081
|
+
storeOptionsAsProperties(storeAsProperties?: boolean): this;
|
|
1082
|
+
/**
|
|
1083
|
+
* Retrieve option value.
|
|
1084
|
+
*/
|
|
1085
|
+
getOptionValue(key: string): any;
|
|
1086
|
+
/**
|
|
1087
|
+
* Store option value.
|
|
1088
|
+
*/
|
|
1089
|
+
setOptionValue(key: string, value: unknown): this;
|
|
1090
|
+
/**
|
|
1091
|
+
* Store option value and where the value came from.
|
|
1092
|
+
*/
|
|
1093
|
+
setOptionValueWithSource(key: string, value: unknown, source: OptionValueSource): this;
|
|
1094
|
+
/**
|
|
1095
|
+
* Get source of option value.
|
|
1096
|
+
*/
|
|
1097
|
+
getOptionValueSource(key: string): OptionValueSource | undefined;
|
|
1098
|
+
/**
|
|
1099
|
+
* Get source of option value. See also .optsWithGlobals().
|
|
1100
|
+
*/
|
|
1101
|
+
getOptionValueSourceWithGlobals(key: string): OptionValueSource | undefined;
|
|
1102
|
+
/**
|
|
1103
|
+
* Alter parsing of short flags with optional values.
|
|
1104
|
+
*
|
|
1105
|
+
* @example
|
|
1106
|
+
* ```
|
|
1107
|
+
* // for `.option('-f,--flag [value]'):
|
|
1108
|
+
* .combineFlagAndOptionalValue(true) // `-f80` is treated like `--flag=80`, this is the default behaviour
|
|
1109
|
+
* .combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b`
|
|
1110
|
+
* ```
|
|
1111
|
+
*
|
|
1112
|
+
* @returns `this` command for chaining
|
|
1113
|
+
*/
|
|
1114
|
+
combineFlagAndOptionalValue(combine?: boolean): this;
|
|
1115
|
+
/**
|
|
1116
|
+
* Allow unknown options on the command line.
|
|
1117
|
+
*
|
|
1118
|
+
* @returns `this` command for chaining
|
|
1119
|
+
*/
|
|
1120
|
+
allowUnknownOption(allowUnknown?: boolean): this;
|
|
1121
|
+
/**
|
|
1122
|
+
* Allow excess command-arguments on the command line. Pass false to make excess arguments an error.
|
|
1123
|
+
*
|
|
1124
|
+
* @returns `this` command for chaining
|
|
1125
|
+
*/
|
|
1126
|
+
allowExcessArguments(allowExcess?: boolean): this;
|
|
1127
|
+
/**
|
|
1128
|
+
* Enable positional options. Positional means global options are specified before subcommands which lets
|
|
1129
|
+
* subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.
|
|
1130
|
+
*
|
|
1131
|
+
* The default behaviour is non-positional and global options may appear anywhere on the command line.
|
|
1132
|
+
*
|
|
1133
|
+
* @returns `this` command for chaining
|
|
1134
|
+
*/
|
|
1135
|
+
enablePositionalOptions(positional?: boolean): this;
|
|
1136
|
+
/**
|
|
1137
|
+
* Pass through options that come after command-arguments rather than treat them as command-options,
|
|
1138
|
+
* so actual command-options come before command-arguments. Turning this on for a subcommand requires
|
|
1139
|
+
* positional options to have been enabled on the program (parent commands).
|
|
1140
|
+
*
|
|
1141
|
+
* The default behaviour is non-positional and options may appear before or after command-arguments.
|
|
1142
|
+
*
|
|
1143
|
+
* @returns `this` command for chaining
|
|
1144
|
+
*/
|
|
1145
|
+
passThroughOptions(passThrough?: boolean): this;
|
|
1146
|
+
/**
|
|
1147
|
+
* Parse `argv`, setting options and invoking commands when defined.
|
|
1148
|
+
*
|
|
1149
|
+
* Use parseAsync instead of parse if any of your action handlers are async.
|
|
1150
|
+
*
|
|
1151
|
+
* Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
|
|
1152
|
+
*
|
|
1153
|
+
* Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
|
|
1154
|
+
* - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
|
|
1155
|
+
* - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
|
|
1156
|
+
* - `'user'`: just user arguments
|
|
1157
|
+
*
|
|
1158
|
+
* @example
|
|
1159
|
+
* ```
|
|
1160
|
+
* program.parse(); // parse process.argv and auto-detect electron and special node flags
|
|
1161
|
+
* program.parse(process.argv); // assume argv[0] is app and argv[1] is script
|
|
1162
|
+
* program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
|
1163
|
+
* ```
|
|
1164
|
+
*
|
|
1165
|
+
* @returns `this` command for chaining
|
|
1166
|
+
*/
|
|
1167
|
+
parse(argv?: readonly string[], parseOptions?: ParseOptions): this;
|
|
1168
|
+
/**
|
|
1169
|
+
* Parse `argv`, setting options and invoking commands when defined.
|
|
1170
|
+
*
|
|
1171
|
+
* Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
|
|
1172
|
+
*
|
|
1173
|
+
* Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
|
|
1174
|
+
* - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
|
|
1175
|
+
* - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
|
|
1176
|
+
* - `'user'`: just user arguments
|
|
1177
|
+
*
|
|
1178
|
+
* @example
|
|
1179
|
+
* ```
|
|
1180
|
+
* await program.parseAsync(); // parse process.argv and auto-detect electron and special node flags
|
|
1181
|
+
* await program.parseAsync(process.argv); // assume argv[0] is app and argv[1] is script
|
|
1182
|
+
* await program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
|
1183
|
+
* ```
|
|
1184
|
+
*
|
|
1185
|
+
* @returns Promise
|
|
1186
|
+
*/
|
|
1187
|
+
parseAsync(argv?: readonly string[], parseOptions?: ParseOptions): Promise<this>;
|
|
1188
|
+
/**
|
|
1189
|
+
* Called the first time parse is called to save state and allow a restore before subsequent calls to parse.
|
|
1190
|
+
* Not usually called directly, but available for subclasses to save their custom state.
|
|
1191
|
+
*
|
|
1192
|
+
* This is called in a lazy way. Only commands used in parsing chain will have state saved.
|
|
1193
|
+
*/
|
|
1194
|
+
saveStateBeforeParse(): void;
|
|
1195
|
+
/**
|
|
1196
|
+
* Restore state before parse for calls after the first.
|
|
1197
|
+
* Not usually called directly, but available for subclasses to save their custom state.
|
|
1198
|
+
*
|
|
1199
|
+
* This is called in a lazy way. Only commands used in parsing chain will have state restored.
|
|
1200
|
+
*/
|
|
1201
|
+
restoreStateBeforeParse(): void;
|
|
1202
|
+
/**
|
|
1203
|
+
* Parse options from `argv` removing known options,
|
|
1204
|
+
* and return argv split into operands and unknown arguments.
|
|
1205
|
+
*
|
|
1206
|
+
* Side effects: modifies command by storing options. Does not reset state if called again.
|
|
1207
|
+
*
|
|
1208
|
+
* argv => operands, unknown
|
|
1209
|
+
* --known kkk op => [op], []
|
|
1210
|
+
* op --known kkk => [op], []
|
|
1211
|
+
* sub --unknown uuu op => [sub], [--unknown uuu op]
|
|
1212
|
+
* sub -- --unknown uuu op => [sub --unknown uuu op], []
|
|
1213
|
+
*/
|
|
1214
|
+
parseOptions(argv: string[]): ParseOptionsResult;
|
|
1215
|
+
/**
|
|
1216
|
+
* Return an object containing local option values as key-value pairs
|
|
1217
|
+
*/
|
|
1218
|
+
opts<T extends OptionValues>(): T;
|
|
1219
|
+
/**
|
|
1220
|
+
* Return an object containing merged local and global option values as key-value pairs.
|
|
1221
|
+
*/
|
|
1222
|
+
optsWithGlobals<T extends OptionValues>(): T;
|
|
1223
|
+
/**
|
|
1224
|
+
* Set the description.
|
|
1225
|
+
*
|
|
1226
|
+
* @returns `this` command for chaining
|
|
1227
|
+
*/
|
|
1228
|
+
description(str: string): this;
|
|
1229
|
+
/** @deprecated since v8, instead use .argument to add command argument with description */
|
|
1230
|
+
description(str: string, argsDescription: Record<string, string>): this;
|
|
1231
|
+
/**
|
|
1232
|
+
* Get the description.
|
|
1233
|
+
*/
|
|
1234
|
+
description(): string;
|
|
1235
|
+
/**
|
|
1236
|
+
* Set the summary. Used when listed as subcommand of parent.
|
|
1237
|
+
*
|
|
1238
|
+
* @returns `this` command for chaining
|
|
1239
|
+
*/
|
|
1240
|
+
summary(str: string): this;
|
|
1241
|
+
/**
|
|
1242
|
+
* Get the summary.
|
|
1243
|
+
*/
|
|
1244
|
+
summary(): string;
|
|
1245
|
+
/**
|
|
1246
|
+
* Set an alias for the command.
|
|
1247
|
+
*
|
|
1248
|
+
* You may call more than once to add multiple aliases. Only the first alias is shown in the auto-generated help.
|
|
1249
|
+
*
|
|
1250
|
+
* @returns `this` command for chaining
|
|
1251
|
+
*/
|
|
1252
|
+
alias(alias: string): this;
|
|
1253
|
+
/**
|
|
1254
|
+
* Get alias for the command.
|
|
1255
|
+
*/
|
|
1256
|
+
alias(): string;
|
|
1257
|
+
/**
|
|
1258
|
+
* Set aliases for the command.
|
|
1259
|
+
*
|
|
1260
|
+
* Only the first alias is shown in the auto-generated help.
|
|
1261
|
+
*
|
|
1262
|
+
* @returns `this` command for chaining
|
|
1263
|
+
*/
|
|
1264
|
+
aliases(aliases: readonly string[]): this;
|
|
1265
|
+
/**
|
|
1266
|
+
* Get aliases for the command.
|
|
1267
|
+
*/
|
|
1268
|
+
aliases(): string[];
|
|
1269
|
+
/**
|
|
1270
|
+
* Set the command usage.
|
|
1271
|
+
*
|
|
1272
|
+
* @returns `this` command for chaining
|
|
1273
|
+
*/
|
|
1274
|
+
usage(str: string): this;
|
|
1275
|
+
/**
|
|
1276
|
+
* Get the command usage.
|
|
1277
|
+
*/
|
|
1278
|
+
usage(): string;
|
|
1279
|
+
/**
|
|
1280
|
+
* Set the name of the command.
|
|
1281
|
+
*
|
|
1282
|
+
* @returns `this` command for chaining
|
|
1283
|
+
*/
|
|
1284
|
+
name(str: string): this;
|
|
1285
|
+
/**
|
|
1286
|
+
* Get the name of the command.
|
|
1287
|
+
*/
|
|
1288
|
+
name(): string;
|
|
1289
|
+
/**
|
|
1290
|
+
* Set the name of the command from script filename, such as process.argv[1],
|
|
1291
|
+
* or import.meta.filename.
|
|
1292
|
+
*
|
|
1293
|
+
* (Used internally and public although not documented in README.)
|
|
1294
|
+
*
|
|
1295
|
+
* @example
|
|
1296
|
+
* ```ts
|
|
1297
|
+
* program.nameFromFilename(import.meta.filename);
|
|
1298
|
+
* ```
|
|
1299
|
+
*
|
|
1300
|
+
* @returns `this` command for chaining
|
|
1301
|
+
*/
|
|
1302
|
+
nameFromFilename(filename: string): this;
|
|
1303
|
+
/**
|
|
1304
|
+
* Set the directory for searching for executable subcommands of this command.
|
|
1305
|
+
*
|
|
1306
|
+
* @example
|
|
1307
|
+
* ```ts
|
|
1308
|
+
* program.executableDir(import.meta.dirname);
|
|
1309
|
+
* // or
|
|
1310
|
+
* program.executableDir('subcommands');
|
|
1311
|
+
* ```
|
|
1312
|
+
*
|
|
1313
|
+
* @returns `this` command for chaining
|
|
1314
|
+
*/
|
|
1315
|
+
executableDir(path: string): this;
|
|
1316
|
+
/**
|
|
1317
|
+
* Get the executable search directory.
|
|
1318
|
+
*/
|
|
1319
|
+
executableDir(): string | null;
|
|
1320
|
+
/**
|
|
1321
|
+
* Set the help group heading for this subcommand in parent command's help.
|
|
1322
|
+
*
|
|
1323
|
+
* @returns `this` command for chaining
|
|
1324
|
+
*/
|
|
1325
|
+
helpGroup(heading: string): this;
|
|
1326
|
+
/**
|
|
1327
|
+
* Get the help group heading for this subcommand in parent command's help.
|
|
1328
|
+
*/
|
|
1329
|
+
helpGroup(): string;
|
|
1330
|
+
/**
|
|
1331
|
+
* Set the default help group heading for subcommands added to this command.
|
|
1332
|
+
* (This does not override a group set directly on the subcommand using .helpGroup().)
|
|
1333
|
+
*
|
|
1334
|
+
* @example
|
|
1335
|
+
* program.commandsGroup('Development Commands:);
|
|
1336
|
+
* program.command('watch')...
|
|
1337
|
+
* program.command('lint')...
|
|
1338
|
+
* ...
|
|
1339
|
+
*
|
|
1340
|
+
* @returns `this` command for chaining
|
|
1341
|
+
*/
|
|
1342
|
+
commandsGroup(heading: string): this;
|
|
1343
|
+
/**
|
|
1344
|
+
* Get the default help group heading for subcommands added to this command.
|
|
1345
|
+
*/
|
|
1346
|
+
commandsGroup(): string;
|
|
1347
|
+
/**
|
|
1348
|
+
* Set the default help group heading for options added to this command.
|
|
1349
|
+
* (This does not override a group set directly on the option using .helpGroup().)
|
|
1350
|
+
*
|
|
1351
|
+
* @example
|
|
1352
|
+
* program
|
|
1353
|
+
* .optionsGroup('Development Options:')
|
|
1354
|
+
* .option('-d, --debug', 'output extra debugging')
|
|
1355
|
+
* .option('-p, --profile', 'output profiling information')
|
|
1356
|
+
*
|
|
1357
|
+
* @returns `this` command for chaining
|
|
1358
|
+
*/
|
|
1359
|
+
optionsGroup(heading: string): this;
|
|
1360
|
+
/**
|
|
1361
|
+
* Get the default help group heading for options added to this command.
|
|
1362
|
+
*/
|
|
1363
|
+
optionsGroup(): string;
|
|
1364
|
+
/**
|
|
1365
|
+
* Output help information for this command.
|
|
1366
|
+
*
|
|
1367
|
+
* Outputs built-in help, and custom text added using `.addHelpText()`.
|
|
1368
|
+
*
|
|
1369
|
+
*/
|
|
1370
|
+
outputHelp(context?: HelpContext): void;
|
|
1371
|
+
/** @deprecated since v7 */
|
|
1372
|
+
outputHelp(cb: (str: string) => string): void;
|
|
1373
|
+
/**
|
|
1374
|
+
* Return command help documentation.
|
|
1375
|
+
*/
|
|
1376
|
+
helpInformation(context?: HelpContext): string;
|
|
1377
|
+
/**
|
|
1378
|
+
* You can pass in flags and a description to override the help
|
|
1379
|
+
* flags and help description for your command. Pass in false
|
|
1380
|
+
* to disable the built-in help option.
|
|
1381
|
+
*/
|
|
1382
|
+
helpOption(flags?: string | boolean, description?: string): this;
|
|
1383
|
+
/**
|
|
1384
|
+
* Supply your own option to use for the built-in help option.
|
|
1385
|
+
* This is an alternative to using helpOption() to customise the flags and description etc.
|
|
1386
|
+
*/
|
|
1387
|
+
addHelpOption(option: Option): this;
|
|
1388
|
+
/**
|
|
1389
|
+
* Output help information and exit.
|
|
1390
|
+
*
|
|
1391
|
+
* Outputs built-in help, and custom text added using `.addHelpText()`.
|
|
1392
|
+
*/
|
|
1393
|
+
help(context?: HelpContext): never;
|
|
1394
|
+
/** @deprecated since v7 */
|
|
1395
|
+
help(cb: (str: string) => string): never;
|
|
1396
|
+
/**
|
|
1397
|
+
* Add additional text to be displayed with the built-in help.
|
|
1398
|
+
*
|
|
1399
|
+
* Position is 'before' or 'after' to affect just this command,
|
|
1400
|
+
* and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.
|
|
1401
|
+
*/
|
|
1402
|
+
addHelpText(position: AddHelpTextPosition, text: string): this;
|
|
1403
|
+
addHelpText(position: AddHelpTextPosition, text: (context: AddHelpTextContext) => string): this;
|
|
1404
|
+
/**
|
|
1405
|
+
* Add a listener (callback) for when events occur. (Implemented using EventEmitter.)
|
|
1406
|
+
*/
|
|
1407
|
+
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
1408
|
+
}
|
|
1409
|
+
interface CommandOptions {
|
|
1410
|
+
hidden?: boolean;
|
|
1411
|
+
isDefault?: boolean;
|
|
1412
|
+
/** @deprecated since v7, replaced by hidden */
|
|
1413
|
+
noHelp?: boolean;
|
|
1414
|
+
}
|
|
1415
|
+
interface ExecutableCommandOptions extends CommandOptions {
|
|
1416
|
+
executableFile?: string;
|
|
1417
|
+
}
|
|
1418
|
+
interface ParseOptionsResult {
|
|
1419
|
+
operands: string[];
|
|
1420
|
+
unknown: string[];
|
|
1421
|
+
}
|
|
1422
|
+
//#endregion
|
|
1423
|
+
//#region packages/cli/dist/index.d.mts
|
|
1424
|
+
//#region src/program.d.ts
|
|
1425
|
+
interface ProgramMetadata {
|
|
1426
|
+
name: string;
|
|
1427
|
+
version: string;
|
|
1428
|
+
description: string;
|
|
1429
|
+
}
|
|
1430
|
+
/**
|
|
1431
|
+
* Builds the seagull commander program - every subcommand, wired up to the
|
|
1432
|
+
* pipeline command functions. Pure and side-effect-free (doesn't parse
|
|
1433
|
+
* `process.argv` or read any file itself) so it's usable both by the real
|
|
1434
|
+
* CLI entrypoint and by anything that wants to drive it programmatically or
|
|
1435
|
+
* test it.
|
|
1436
|
+
*
|
|
1437
|
+
* @param metadata - `{ name, version, description }` shown in `--help`/`--version`
|
|
1438
|
+
* - the caller's own `package.json` fields, since this
|
|
1439
|
+
* package doesn't read its own (it's bundled into
|
|
1440
|
+
* `@octalmesh/seagull`, whose metadata is what should show).
|
|
1441
|
+
* @returns The configured commander `Command`, ready for `.parseAsync()`.
|
|
1442
|
+
*/
|
|
1443
|
+
declare function createProgram(metadata: ProgramMetadata): Command;
|
|
1444
|
+
//#endregion
|
|
307
1445
|
//#region src/commands/bundle.d.ts
|
|
308
1446
|
/**
|
|
309
1447
|
* Bundles every contract's OpenAPI spec into `dist/specs/<contract>.json`.
|
|
310
1448
|
*
|
|
311
|
-
* @param config - The resolved
|
|
1449
|
+
* @param config - The resolved seagull config.
|
|
312
1450
|
*/
|
|
313
1451
|
declare function bundleCommand(config: ResolvedConfig): Promise<void>;
|
|
314
1452
|
//#endregion
|
|
@@ -316,15 +1454,17 @@ declare function bundleCommand(config: ResolvedConfig): Promise<void>;
|
|
|
316
1454
|
/**
|
|
317
1455
|
* Removes the entire `dist` output directory.
|
|
318
1456
|
*
|
|
319
|
-
* @param config - The resolved
|
|
1457
|
+
* @param config - The resolved seagull config.
|
|
320
1458
|
*/
|
|
321
1459
|
declare function cleanCommand(config: ResolvedConfig): Promise<void>;
|
|
322
1460
|
//#endregion
|
|
323
1461
|
//#region src/commands/generate-docs.d.ts
|
|
324
1462
|
/**
|
|
325
1463
|
* Generates the documentation website for every contract into `dist/docs`.
|
|
1464
|
+
* Delegates to `@octalmesh/seagull-docs` - see that package for the actual
|
|
1465
|
+
* implementation.
|
|
326
1466
|
*
|
|
327
|
-
* @param config - The resolved
|
|
1467
|
+
* @param config - The resolved seagull config.
|
|
328
1468
|
*/
|
|
329
1469
|
declare function generateDocsCommand(config: ResolvedConfig): Promise<void>;
|
|
330
1470
|
//#endregion
|
|
@@ -341,7 +1481,7 @@ declare function generateSdkCommand(config: ResolvedConfig): Promise<void>;
|
|
|
341
1481
|
* Lints every contract's OpenAPI spec.
|
|
342
1482
|
* Sets `process.exitCode = 1` if any contract fails.
|
|
343
1483
|
*
|
|
344
|
-
* @param config - The resolved
|
|
1484
|
+
* @param config - The resolved seagull config.
|
|
345
1485
|
*/
|
|
346
1486
|
declare function lintCommand(config: ResolvedConfig): Promise<void>;
|
|
347
1487
|
//#endregion
|
|
@@ -370,7 +1510,8 @@ interface PublishSdkOptions {
|
|
|
370
1510
|
}
|
|
371
1511
|
/**
|
|
372
1512
|
* Redistributes each generated artifact's `dist/sdk/<contract>/<artifact-id>`
|
|
373
|
-
* into its own orphan branch (
|
|
1513
|
+
* into its own orphan branch (per the artifact's resolved `publishing.branch`)
|
|
1514
|
+
* and tags the
|
|
374
1515
|
* publish.
|
|
375
1516
|
*
|
|
376
1517
|
* @param config - The resolved CLI config.
|
|
@@ -381,11 +1522,35 @@ declare function publishSdkCommand(config: ResolvedConfig, options?: PublishSdkO
|
|
|
381
1522
|
//#region src/commands/serve-docs.d.ts
|
|
382
1523
|
/**
|
|
383
1524
|
* Serves the generated documentation site (`dist/docs`) over plain HTTP for
|
|
384
|
-
* local previewing.
|
|
1525
|
+
* local previewing. Delegates to `@octalmesh/seagull-docs`.
|
|
385
1526
|
*
|
|
386
|
-
* @param config - The resolved
|
|
1527
|
+
* @param config - The resolved seagull config.
|
|
387
1528
|
*/
|
|
388
1529
|
declare function serveDocsCommand(config: ResolvedConfig): Promise<void>;
|
|
389
1530
|
//#endregion
|
|
390
|
-
|
|
1531
|
+
//#region packages/docs/dist/index.d.mts
|
|
1532
|
+
//#region src/generate-docs.d.ts
|
|
1533
|
+
/**
|
|
1534
|
+
* Generates the documentation website for every contract into `dist/docs`.
|
|
1535
|
+
*
|
|
1536
|
+
* Currently, a thin wrapper around Scalar's standalone bundle - a placeholder
|
|
1537
|
+
* pending a fully custom docs UI. The `generateDocsSite`/`serveDocsSite`
|
|
1538
|
+
* function signatures are the stable boundary the CLI's `docs generate`/
|
|
1539
|
+
* `docs serve` commands call through, so that future rewrite stays contained
|
|
1540
|
+
* to this package.
|
|
1541
|
+
*
|
|
1542
|
+
* @param config - The resolved seagull config.
|
|
1543
|
+
*/
|
|
1544
|
+
declare function generateDocsSite(config: ResolvedConfig): Promise<void>;
|
|
1545
|
+
//#endregion
|
|
1546
|
+
//#region src/serve-docs.d.ts
|
|
1547
|
+
/**
|
|
1548
|
+
* Serves the generated documentation site (`dist/docs`) over plain HTTP for
|
|
1549
|
+
* local previewing.
|
|
1550
|
+
*
|
|
1551
|
+
* @param config - The resolved seagull config.
|
|
1552
|
+
*/
|
|
1553
|
+
declare function serveDocsSite(config: ResolvedConfig): Promise<void>;
|
|
1554
|
+
//#endregion
|
|
1555
|
+
export { type BundledSpec, CONFIG_FILENAMES, CONFIG_SCHEMA_VERSION, type GenerateContext, Generator, GeneratorRegistry, type GitResult, OpenApiGeneratorCli, OpenApiTypescriptGenerator, type PrepareContext, type ProgramMetadata, type PublishRegistriesOptions, type PublishSdkOptions, type RenderReadmeArgs, type ResolvedArtifact, type ResolvedArtifactEntry, type ResolvedConfig, type ResolvedContract, type ResolvedPublishing, type SdkKind, type SdkLang, type SdkTool, type VarsTree, bundleCommand, cleanCommand, createProgram, generateDocsCommand, generateDocsSite, generateSdkCommand, git, hashSpec, lintCommand, loadConfig, publishRegistriesCommand, publishSdkCommand, readFileAtTag, remoteBranchExists, renderArtifactTag, renderReadme, requireOk, resolveBinPath, resolveConfigPath, resolveVersion, run, runSync, serveDocsCommand, serveDocsSite, syncRedoclyConfig, tagExists };
|
|
391
1556
|
//# sourceMappingURL=index.d.mts.map
|