This repository has been archived by the owner on Nov 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
IImperativeConfig.ts
329 lines (299 loc) · 12 KB
/
IImperativeConfig.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*
*/
import { ICommandDefinition, ICommandProfileTypeConfiguration } from "../../../cmd";
import { IImperativeLogsConfig } from "./IImperativeLogsConfig";
import { IImperativeOverrides } from "./IImperativeOverrides";
import { IImperativeAuthGroupConfig } from "./IImperativeAuthGroupConfig";
import { IApimlSvcAttrs } from "./IApimlSvcAttrs";
import { ICommandProfileAutoInitConfig } from "../../../cmd/src/doc/profiles/definition/ICommandProfileAutoInitConfig";
/**
* All of the configuration required to set up your Imperative CLI app
*/
export interface IImperativeConfig {
/**
* Boolean flag control whether plugins are enable or disable.
* This option is assumed to be true by default.
* @type {boolean}
* @memberof IImperativeConfig
*/
allowPlugins?: boolean;
/**
* Boolean flag control whether config command group is enabled or disabled.
* This option is assumed to be true by default.
* @type {boolean}
* @memberof IImperativeConfig
*/
allowConfigGroup?: boolean;
/**
* A path to a module (javascript file) that will return a complete IImperativeConfig
* object. If you use this option, anything else you specify in package.json
* or your manually provided config object (i.e. Imperative.init({...}) will
* be ignored.
* Relative to the file that you call Imperative.init() from, unless an absolute path is provided.
* @type {string}
* @memberof IImperativeConfig
*/
configurationModule?: string;
/**
* Array of globs (see npm glob package for details) relative to the file that
* you call Imperative.init() from.
* The globs should match modules (javascript files) that contain command definition trees as the default export.
* Each tree from each matching file will be treated as children of the root command
* Note: absolute file names will also work
* @type {string[]}
* @memberof IImperativeConfig
*/
commandModuleGlobs?: string[];
/**
* Rather than using modules, you can provide an array of definition trees of commands
* that will be treated as children of the root command.
*
* If your configuration object is being used for a plugin, these command definitions
* will be added to the set of commands of the CLI into which the plugin is installed.
* @type {ICommandDefinition[]}
* @memberof IImperativeConfig
*/
definitions?: ICommandDefinition[];
/**
* The description that will be displayed if the user issues your root command
* (e.g. if your CLI's main command, in the "bin" field of package.json,
* is "banana", they will see this when they issue "banana --help")
* Typically, this is an overview description of your CLI as a whole -- it's purpose,
* syntax, and information the user needs the first time they use your CLI
*
* If your configuration object is being used for a plugin, this property will
* be used as the description for the plugin's top-level group. For plugins,
* this property must be specified. Also see the 'name' property.
* @type {string}
* @memberof IImperativeConfig
*/
rootCommandDescription?: string;
/**
* A path to a module that implements the AbstractHelpGenerator.
* Use this
* @type {string}
* @memberof IImperativeConfig
*/
customHelpGenerator?: string;
/**
* characters that will be looped through in a progress bar e.g. "\|/-".
* If you don't specify this, a default spinner will be used.
* @type {string}
* @memberof IImperativeConfig
*/
progressBarSpinner?: string;
/**
* The home directory for your CLI's configuration, logging,
* extensions, etc.
* e.g. "~"/.myapp"
* Defaults to ~/.yourcliname
* @type {string}
* @memberof IImperativeConfig
*/
defaultHome?: string;
/**
* Environmental variable name prefix used to construct configuration environmental variables
* for your CLI. For example, <your_envVariablePrefix_IMPERATIVE_LOG_LEVEL>. Note that
* the prefix chosen should adhere to the platform env var naming standards for which your CLI
* is intended to run.
*
* Optional
*
* Default: "name" value in this config (which defaults from package.json "name")
* @type {string}
* @memberof IImperativeConfig
*/
envVariablePrefix?: string;
/**
* Identifier of your CLI following the convention of "name" as is required in a package.json.
*
* If your configuration object is being used for a plugin, the name property is used as the
* group name for your plugin. All plugin commands will be underneath this group. For example,
* if the name property is YourPluginName, the plugin supplies a command named YourPluginCmd,
* and you install YourPluginName into YourBaseCLI, you would issue a command like:
* YourBaseCLI YourPluginName YourPluginCmd
* Also see the 'rootCommandDescription' property.
*
* Optional
*
* Default: package.json ==> name
* @type {string}
* @memberof IImperativeConfig
*/
name?: string;
/**
* The display name for your CLI, used in messages
* @type {string}
* @memberof IImperativeConfig
*/
productDisplayName?: string;
/**
* Use this property to configure the available profile types for your CLI. The "type" indicates a homogeneous grouping
* of profiles (think 'category'). The "schema" dictates the structure of this profile type and assists Imperative
* with validating profile structure (on load) and helps imperative auto-generate profile manipulation commands.
*
* If your configuration object is being used for a plugin, these profiles
* will be added to the set of profiles of the CLI into which the plugin is installed.
* @type {ICommandProfileTypeConfiguration[]}
* @memberof IImperativeConfig
*/
profiles?: ICommandProfileTypeConfiguration[];
/**
* Use this property to configure a base profile for your CLI. A base profile can store shared values for fields
* used by other profile types.
* @type {ICommandProfileTypeConfiguration}
* @memberof IImperativeConfig
*/
baseProfile?: ICommandProfileTypeConfiguration;
/**
* Use this property to customize the command definitions for the auth command group.
* @type {IImperativeAuthGroupConfig}
* @memberof IImperativeConfig
*/
authGroupConfig?: IImperativeAuthGroupConfig;
/**
* Use this property to customize the command definition for the config init command.
* @type {ICommandProfileAutoInitConfig}
* @memberof IImperativeConfig
*/
configAutoInitCommandConfig?: ICommandProfileAutoInitConfig;
/**
* If you specify a list of profile configurations, you can set this to true to
* automatically add a set of commands to your CLI to create, update, delete, and otherwise
* manage user profiles.
* Set this to false to avoid generating these commands. l
* Default: true (will generate profile commands if you have defined any profiles)
* @type {boolean}
* @memberof IImperativeConfig
*/
autoGenerateProfileCommands?: boolean;
/**
* Use this property to configure imperative logs, your CLI logs, console logs, and create new logs.
* @type {IImperativeLogsConfig}
* @memberof IImperativeConfig
*/
logging?: IImperativeLogsConfig;
/**
* Optional - choose a color that will be used for help headings and other highlighting
*
* @type {string}
* @memberof IImperativeConfig
*/
primaryTextColor?: string;
/**
* Optional - choose a secondary color that will be used for things like highlighting search results
* and other rarer
* @type {string}
* @memberof IImperativeConfig
*/
secondaryTextColor?: string;
/**
* Optional - List of overrides you wish Imperative to use instead of the defaults.
* @type {IImperativeOverrides}
* @memberof IImperativeConfig
*/
overrides?: IImperativeOverrides;
/**
* A path to a module (javascript file) that will perform a health check for a plugin.
* The health check should verify the health of the plugin.
* The implementor of a plugin determines what actions
* can confirm that the plugin is in an operational state.
*
* This property is recommended for a plugin. The existence of this property
* and the existence of the specified file will be verified when the plugin
* is validated by the Imperative framework. Their absence will generate warnings.
*
* The health check should return true if all plugin health checks pass.
* It should return false otherwise.
*
* This property is unused for a base CLI.
*
* TODO: While the pluginHealthCheck property is validated, no Imperative command
* currently calls the health check function.
* @type {string}
* @memberof IImperativeConfig
*/
pluginHealthCheck?: string;
/**
* If the project you are configuring is an Imperative plugin,
* you can assign aliases to the group that is added when a user
* installs your plugin.
*
* So, if your plugin's name is "my-special-plugin" and you specify
* ["msp"] as your value for pluginAliases, users can issue the command
* "mycli my-special-plugin my-command" or "mycli msp my-command"
*
* Note: For plugins only. Ignored when specified on a core/base CLI
*
* @example const config: IImperativeConfig = {
* ...
* pluginAliases: ["msp"]
* ...
* }
* @type {string[]}
* @memberof IImperativeConfig
*/
pluginAliases?: string[];
/**
* If the project you are configuring is an Imperative plugin,
* you can assign a summary to the plugin that is showed in the
* root level help for the core CLI. The summary is a short
* description of your plugin's functionality.
*
* Note: For plugins only. Ignored when specified on a core/base CLI
*
* @example
* const config: IImperativeConfig = {
* ...
* pluginSummary: "a brief summary of your group"
* ...
* }
* @type {string}
* @memberof IImperativeConfig
*/
pluginSummary?: string;
/**
* Optionally override the block of text that appears in the help text
* for commands that are set to experimental:true in their definition.
* You can use this to describe what a command being experimental means to your CLI.
* If you omit this, a generic block of text (Constants.DEFAULT_EXPERIMENTAL_COMMAND_EXPLANATION)
* will be used by default.
* @type {string}
* @memberof IImperativeConfig
*/
experimentalCommandDescription?: string;
/**
* Optionally specify path to an image of logo for your CLI.
* It will be displayed at the top of web help pages.
*/
webHelpLogoImgPath?: string;
/**
* Optionally specify path to a custom CSS file for web help.
* It will replace the main.css file that controls the style of the page.
*/
webHelpCustomCssPath?: string;
/**
* The set of attributes used to lookup (within the API Mediation Layer)
* the connection properties for the REST service associated with this
* command group. We use an array of such attributes in case the command
* group is compatible with multiple versions of the associated REST service.
* @type {IApimlSvcAttrs[]}
* @memberof IImperativeConfig
*/
apimlConnLookup?: IApimlSvcAttrs[];
/**
* If Imperative should run in Daemon mode
* This should only be specified for CLIs
* @type {boolean}
* @memberof IImperativeConfig
*/
daemonMode?: boolean;
}