1 | import { Target } from '@diez/engine';
|
2 | import { Command } from 'commander';
|
3 | /**
|
4 | * A CLI action. Receives the arguments of a CLI command.
|
5 | */
|
6 | export declare type CliAction = (command: any, ...args: any[]) => Promise<void>;
|
7 | /**
|
8 | * A generic interface for a CLI command option validator. Options can be either a boolean
|
9 | * (for flags like `--option`) or a string (for flags like `--option <option-value>`).
|
10 | */
|
11 | export declare type CliOptionValidator = (commandFlags: any) => Promise<void>;
|
12 | /**
|
13 | * Provides a ledger for registered commands and their validators.
|
14 | * @ignore
|
15 | */
|
16 | export interface ValidatedCommand {
|
17 | command: Command;
|
18 | validators: CliOptionValidator[];
|
19 | }
|
20 | /**
|
21 | * A generic interface for a CLI command option.
|
22 | */
|
23 | export interface CliCommandOption {
|
24 | /**
|
25 | * The full name (`--longName`) of the command option. Should be specified without the leading dashes.
|
26 | */
|
27 | longName: string;
|
28 | /**
|
29 | * The description for the command option. Printed when the associated command is run with `--help`.
|
30 | */
|
31 | description?: string;
|
32 | /**
|
33 | * An optional, one-character option alias. e.g. `-t` for `--target`. Should be specified without the leading dash.
|
34 | */
|
35 | shortName?: string;
|
36 | /**
|
37 | * If provided, indicates that the option receives a string value. Without a value name, the option is assumed to
|
38 | * receive a boolean.
|
39 | */
|
40 | valueName?: string;
|
41 | /**
|
42 | * An optional validator which receives the call-time option. Errors emitted during validation will bubble up and
|
43 | * terminate the command.
|
44 | */
|
45 | validator?: CliOptionValidator;
|
46 | }
|
47 | /**
|
48 | * A module-wrapped CliAction.
|
49 | * @ignore
|
50 | */
|
51 | export interface ModuleWrappedCliAction {
|
52 | default: CliAction;
|
53 | }
|
54 | /**
|
55 | * Provides a generic interface for a CLI command.
|
56 | */
|
57 | export interface CliCommandProvider {
|
58 | /**
|
59 | * The name of the command.
|
60 | */
|
61 | name: string;
|
62 | /**
|
63 | * The action that should be executed when the command is invoked by name.
|
64 | */
|
65 | loadAction(): Promise<CliAction | ModuleWrappedCliAction>;
|
66 | /**
|
67 | * The command description.
|
68 | */
|
69 | description: string;
|
70 | /**
|
71 | * A set of options the command should receive. These are passed into the action as properties
|
72 | * of the first argument.
|
73 | */
|
74 | options?: CliCommandOption[];
|
75 | /**
|
76 | * An optional pre-registration hook to modify the command before it's bootstrapped.
|
77 | */
|
78 | preinstall?: (provider?: CliCommandProvider) => Promise<void>;
|
79 | }
|
80 | /**
|
81 | * Provides a generic interface for a CLI command extension.
|
82 | */
|
83 | export interface CliCommandExtension {
|
84 | /**
|
85 | * The name of the command to extend.
|
86 | */
|
87 | names: string[];
|
88 | /**
|
89 | * A set of _additional_ options the command should receive.
|
90 | */
|
91 | options?: CliCommandOption[];
|
92 | }
|
93 | /**
|
94 | * A specification for a Component compiler target binding.
|
95 | */
|
96 | export interface TargetBinding {
|
97 | [targetName: string]: string;
|
98 | }
|
99 | /**
|
100 | * Config-style default command options for `.diezrc`.
|
101 | */
|
102 | export interface CliDefaultOptions {
|
103 | [command: string]: any;
|
104 | }
|
105 | /**
|
106 | * The full Diez configuration.
|
107 | */
|
108 | export interface FullDiezConfiguration {
|
109 | /**
|
110 | * Paths to local providers associated
|
111 | */
|
112 | providers: Partial<{
|
113 | assemblers: {
|
114 | [target in Target]?: string;
|
115 | };
|
116 | commands: Iterable<string>;
|
117 | extensions: Iterable<string>;
|
118 | extractors: Iterable<string>;
|
119 | targets: Iterable<string>;
|
120 | }>;
|
121 | commandOptions: CliDefaultOptions;
|
122 | }
|
123 | /**
|
124 | * A Diez configuration, which can be provided by a module either as the `"diez"` key in `package.json` or in a separate
|
125 | * `.diezrc` file located at the project root.
|
126 | *
|
127 | * See [here](https://github.com/diez/diez/blob/master/src/compiler/targets/.diezrc) for an example.
|
128 | */
|
129 | export declare type DiezConfiguration = Partial<FullDiezConfiguration>;
|
130 | /**
|
131 | * Valid options that can be provided to the pager.
|
132 | */
|
133 | export interface PagerOptions {
|
134 | source: string;
|
135 | }
|
136 | /**
|
137 | * Supported package managers
|
138 | */
|
139 | export declare enum PackageManagers {
|
140 | Npm = "npm",
|
141 | Yarn = "yarn"
|
142 | }
|
143 | /**
|
144 | * Describes package manager commands grouped by package manager.
|
145 | */
|
146 | export declare type PackageManagerCommands = {
|
147 | [key in PackageManagers]: {
|
148 | [key: string]: string;
|
149 | };
|
150 | };
|
151 | //# sourceMappingURL=api.d.ts.map |
\ | No newline at end of file |