44 *--------------------------------------------------------------------------------------------*/
55
66import { type IActionContext } from '@microsoft/vscode-azext-utils' ;
7- import { composeArgs , withArg , withNamedArg , withQuotedArg , type CommandLineArgs } from '@microsoft/vscode-processutils' ;
7+ import { composeArgs , withArg , withNamedArg , withQuotedArg } from '@microsoft/vscode-processutils' ;
88import * as fs from 'fs' ;
99import * as os from 'os' ;
1010import * as path from 'path' ;
@@ -18,30 +18,12 @@ import { findShortNameByIdentity, parseTemplatesFromNupkg } from './parseNupkgTe
1818const itemNupkgFileName = 'item.nupkg' ;
1919const projectNupkgFileName = 'project.nupkg' ;
2020
21- export enum DotnetTemplateOperation {
22- List = 'list' ,
23- Create = 'create' ,
24- }
25-
2621/**
2722 * Lists templates by parsing nupkg files directly (no longer uses the JsonCli DLL).
2823 */
29- export async function executeDotnetTemplateCommand ( context : IActionContext , version : FuncVersion , projTemplateKey : string , workingDirectory : string | undefined , operation : DotnetTemplateOperation . List , additionalArgs ?: CommandLineArgs ) : Promise < string > ;
30- /**
31- * @deprecated For 'create' operations, use {@link executeDotnetTemplateCreate} instead.
32- */
33- export async function executeDotnetTemplateCommand ( context : IActionContext , version : FuncVersion , projTemplateKey : string , workingDirectory : string | undefined , operation : DotnetTemplateOperation , additionalArgs ?: CommandLineArgs ) : Promise < string > ;
34- export async function executeDotnetTemplateCommand ( context : IActionContext , version : FuncVersion , projTemplateKey : string , workingDirectory : string | undefined , operation : DotnetTemplateOperation , additionalArgs ?: CommandLineArgs ) : Promise < string > {
24+ export async function executeDotnetTemplateCommand ( context : IActionContext , version : FuncVersion , projTemplateKey : string ) : Promise < string > {
3525 const templateDir = getDotnetTemplateDir ( context , version , projTemplateKey ) ;
36-
37- if ( operation === DotnetTemplateOperation . List ) {
38- return await listDotnetTemplates ( templateDir ) ;
39- } else {
40- // Fallback for any remaining callers that haven't migrated to executeDotnetTemplateCreate
41- const { identity, templateArgs } = parseJsonCliStyleArgs ( additionalArgs ?? [ ] ) ;
42- await executeDotnetTemplateCreate ( context , version , projTemplateKey , workingDirectory , identity , templateArgs ) ;
43- return '' ;
44- }
26+ return await listDotnetTemplates ( templateDir ) ;
4527}
4628
4729/**
@@ -141,30 +123,6 @@ export async function executeDotnetTemplateCreate(
141123 }
142124}
143125
144- /**
145- * Parses JSON Cli-style arguments (--identity, --arg:name, etc.) into structured data.
146- * Used only as a compatibility shim for callers that have not yet migrated to executeDotnetTemplateCreate.
147- */
148- function parseJsonCliStyleArgs ( args : CommandLineArgs ) : { identity : string ; templateArgs : Record < string , string > } {
149- const flatArgs : string [ ] = ( Array . isArray ( args ) ? args : [ args ] ) . map ( String ) ;
150- let identity = '' ;
151- const templateArgs : Record < string , string > = { } ;
152-
153- for ( let i = 0 ; i < flatArgs . length ; i ++ ) {
154- const arg = flatArgs [ i ] ;
155- if ( arg === '--identity' && i + 1 < flatArgs . length ) {
156- identity = flatArgs [ i + 1 ] . replace ( / ^ " | " $ / g, '' ) ;
157- i ++ ;
158- } else if ( arg . startsWith ( '--arg:' ) && i + 1 < flatArgs . length ) {
159- const paramName = arg . replace ( '--arg:' , '' ) ;
160- templateArgs [ paramName ] = flatArgs [ i + 1 ] . replace ( / ^ " | " $ / g, '' ) ;
161- i ++ ;
162- }
163- }
164-
165- return { identity, templateArgs } ;
166- }
167-
168126export function getDotnetItemTemplatePath ( context : IActionContext , version : FuncVersion , projTemplateKey : string ) : string {
169127 return path . join ( getDotnetTemplateDir ( context , version , projTemplateKey ) , itemNupkgFileName ) ;
170128}
0 commit comments