From 939734757aab333dbe0b771c5d7965efd5b6086e Mon Sep 17 00:00:00 2001 From: Jonathan Cammisuli Date: Fri, 8 Apr 2022 11:41:58 -0400 Subject: [PATCH] fix: properly check positional argument for generating with UI --- libs/schema/src/index.ts | 1 + .../src/lib/task-execution-form.component.ts | 7 +++++-- libs/vscode/webview/src/lib/get-task-execution-schema.ts | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/libs/schema/src/index.ts b/libs/schema/src/index.ts index d4846fad5f..556d3d200b 100644 --- a/libs/schema/src/index.ts +++ b/libs/schema/src/index.ts @@ -24,6 +24,7 @@ export interface Option extends CliOption { items?: string[] | ItemsWithEnum; aliases: string[]; isRequired: boolean; + 'x-dropdown'?: 'projects'; } export interface ItemTooltips { diff --git a/libs/vscode-ui/feature-task-execution-form/src/lib/task-execution-form.component.ts b/libs/vscode-ui/feature-task-execution-form/src/lib/task-execution-form.component.ts index acce1d41c6..e267730bf0 100644 --- a/libs/vscode-ui/feature-task-execution-form/src/lib/task-execution-form.component.ts +++ b/libs/vscode-ui/feature-task-execution-form/src/lib/task-execution-form.component.ts @@ -463,7 +463,10 @@ export class TaskExecutionFormComponent implements OnInit, AfterViewChecked { architect: TaskExecutionSchema, configurationName?: string ): string[] { - const fields = architect.options.filter((s) => value[s.name]); + const fields = architect.options + .filter((s) => value[s.name]) + .sort((a, b) => (a?.positional ?? 0) - (b?.positional ?? 0)); + const defaultValues = this.getDefaultValuesForConfiguration( architect, configurationName @@ -480,7 +483,7 @@ export class TaskExecutionFormComponent implements OnInit, AfterViewChecked { ) return; - if (f.positional) { + if (f.positional !== undefined && typeof f.positional === 'number') { args.add(sanitizeWhitespace(value[f.name])); } else if (f.type === OptionType.Boolean) { args.add(value[f.name] === 'false' ? `--no-${f.name}` : `--${f.name}`); diff --git a/libs/vscode/webview/src/lib/get-task-execution-schema.ts b/libs/vscode/webview/src/lib/get-task-execution-schema.ts index 205ae510c9..215ece5fd2 100644 --- a/libs/vscode/webview/src/lib/get-task-execution-schema.ts +++ b/libs/vscode/webview/src/lib/get-task-execution-schema.ts @@ -217,6 +217,7 @@ function isProjectOption(option: Option) { return ( option.name === 'project' || option.name === 'projectName' || - (option.$default && option.$default.$source === 'projectName') + option.$default?.$source === 'projectName' || + option['x-dropdown'] === 'projects' ); }