diff --git a/libs/schema/src/index.ts b/libs/schema/src/index.ts index c43d8d1064..2965feccd3 100644 --- a/libs/schema/src/index.ts +++ b/libs/schema/src/index.ts @@ -12,19 +12,18 @@ export type OptionPropertyDescription = Schema['properties'][number]; export type CliOption = { name: string; - required?: boolean; positional?: number; alias?: string; hidden?: boolean; deprecated?: boolean | string; } & OptionPropertyDescription; -export interface Option extends Omit { +export interface Option extends CliOption { tooltip?: string; itemTooltips?: ItemTooltips; items?: string[] | ItemsWithEnum; aliases: string[]; - default?: string[] | string | number | boolean | undefined; + isRequired: boolean; } export interface ItemTooltips { diff --git a/libs/server/src/lib/utils/utils.ts b/libs/server/src/lib/utils/utils.ts index 3dcec0daf5..60d84b1e09 100644 --- a/libs/server/src/lib/utils/utils.ts +++ b/libs/server/src/lib/utils/utils.ts @@ -219,7 +219,7 @@ export async function normalizeSchema( const nxOption: Option = { ...option, - required: isFieldRequired(requiredFields, option, xPrompt, $default), + isRequired: isFieldRequired(requiredFields, option, xPrompt, $default), aliases: option.alias ? [option.alias] : [], ...(workspaceDefault !== undefined && { default: workspaceDefault }), ...($default && { $default }), @@ -374,24 +374,27 @@ export function toWorkspaceFormat(w: any): WorkspaceJsonConfiguration { } function schemaToOptions(schema: Schema): CliOption[] { - return Object.keys(schema.properties).reduce((acc, curr) => { - const currentProperties = schema.properties[curr]; - const $default = currentProperties.$default; - const $defaultIndex = - $default?.['$source'] === 'argv' ? $default['index'] : undefined; - const positional: number | undefined = - typeof $defaultIndex === 'number' ? $defaultIndex : undefined; - - const visible = currentProperties.visible ?? true; - if (!visible || (currentProperties as any).hidden) { - return acc; - } + return Object.keys(schema.properties).reduce( + (cliOptions, option) => { + const currentProperties = schema.properties[option]; + const $default = currentProperties.$default; + const $defaultIndex = + $default?.['$source'] === 'argv' ? $default['index'] : undefined; + const positional: number | undefined = + typeof $defaultIndex === 'number' ? $defaultIndex : undefined; + + const visible = currentProperties.visible ?? true; + if (!visible || (currentProperties as any).hidden) { + return cliOptions; + } - acc.push({ - name: curr, - positional, - ...currentProperties, - }); - return acc; - }, []); + cliOptions.push({ + name: option, + positional, + ...currentProperties, + }); + return cliOptions; + }, + [] + ); } diff --git a/libs/vscode-ui/components/src/lib/field-tree/field-tree.component.html b/libs/vscode-ui/components/src/lib/field-tree/field-tree.component.html index d1cdef359f..27171a1447 100644 --- a/libs/vscode-ui/components/src/lib/field-tree/field-tree.component.html +++ b/libs/vscode-ui/components/src/lib/field-tree/field-tree.component.html @@ -9,5 +9,5 @@ [style.display]="filteredFields.has(field.name) ? 'block' : 'none'" > {{ camelToTitle(field.name) }} - * + * diff --git a/libs/vscode-ui/components/src/lib/field-tree/field-tree.component.ts b/libs/vscode-ui/components/src/lib/field-tree/field-tree.component.ts index bf8413ce3e..2182d74adf 100644 --- a/libs/vscode-ui/components/src/lib/field-tree/field-tree.component.ts +++ b/libs/vscode-ui/components/src/lib/field-tree/field-tree.component.ts @@ -16,11 +16,15 @@ import { Option } from '@nx-console/schema'; changeDetection: ChangeDetectionStrategy.OnPush, }) export class FieldTreeComponent implements OnChanges { - @Input() fields: Array