Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 40 additions & 33 deletions packages/@aws-cdk/user-input-gen/lib/user-input-gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,46 +65,53 @@ export async function renderUserInputType(config: CliConfig): Promise<string> {

// add command-specific options
for (const [commandName, command] of Object.entries(config.commands)) {
const commandType = new StructType(scope, {
export: true,
name: `${kebabToPascal(commandName)}Options`,
docs: {
summary: command.description,
remarks: command.aliases ? `aliases: ${command.aliases.join(' ')}` : undefined,
},
});

// add command level options
for (const [optionName, option] of Object.entries(command.options ?? {})) {
commandType.addProperty({
name: kebabToCamelCase(optionName),
type: convertType(option.type, option.count),
let commandType: Type = Type.anonymousInterface([]);
const commandOptions = Object.entries(command.options ?? {});

// if we have something to add to an interface
if (command.arg || commandOptions.length) {
const commandStruct = new StructType(scope, {
export: true,
name: `${kebabToPascal(commandName)}Options`,
docs: {
// Notification Arns is a special property where undefined and [] mean different things
default: optionName === 'notification-arns' ? 'undefined' : normalizeDefault(option.default),
summary: option.desc,
deprecated: option.deprecated ? String(option.deprecated) : undefined,
remarks: option.alias ? `aliases: ${Array.isArray(option.alias) ? option.alias.join(' ') : option.alias}` : undefined,
summary: command.description,
remarks: command.aliases ? `aliases: ${command.aliases.join(' ')}` : undefined,
},
optional: true,
});
}

// add positional argument associated with the command
if (command.arg) {
commandType.addProperty({
name: command.arg.name,
type: command.arg.variadic ? Type.arrayOf(Type.STRING) : Type.STRING,
docs: {
summary: `Positional argument for ${commandName}`,
},
optional: true,
});
commandType = Type.fromName(scope, commandStruct.name);

// add command level options
for (const [optionName, option] of commandOptions) {
commandStruct.addProperty({
name: kebabToCamelCase(optionName),
type: convertType(option.type, option.count),
docs: {
// Notification Arns is a special property where undefined and [] mean different things
default: optionName === 'notification-arns' ? 'undefined' : normalizeDefault(option.default),
summary: option.desc,
deprecated: option.deprecated ? String(option.deprecated) : undefined,
remarks: option.alias ? `aliases: ${Array.isArray(option.alias) ? option.alias.join(' ') : option.alias}` : undefined,
},
optional: true,
});
}

// add positional argument associated with the command
if (command.arg) {
commandStruct.addProperty({
name: command.arg.name,
type: command.arg.variadic ? Type.arrayOf(Type.STRING) : Type.STRING,
docs: {
summary: `Positional argument for ${commandName}`,
},
optional: true,
});
}
}

userInputType.addProperty({
name: kebabToCamelCase(commandName),
type: Type.fromName(scope, commandType.name),
type: commandType,
docs: {
summary: command.description,
remarks: command.aliases ? `aliases: ${command.aliases.join(' ')}` : undefined,
Expand Down
10 changes: 1 addition & 9 deletions packages/aws-cdk/lib/cli/user-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export interface UserInput {
/**
* Check your set-up for potential problems
*/
readonly doctor?: DoctorOptions;
readonly doctor?: {};
}

/**
Expand Down Expand Up @@ -1325,11 +1325,3 @@ export interface DocsOptions {
*/
readonly browser?: string;
}

/**
* Check your set-up for potential problems
*
* @struct
*/
export interface DoctorOptions {
}
Loading