Skip to content

Commit d798c67

Browse files
author
Nathan Turinski
committed
Remove uneeded shims
1 parent 3017ff0 commit d798c67

File tree

2 files changed

+5
-47
lines changed

2 files changed

+5
-47
lines changed

src/templates/dotnet/DotnetTemplateProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { type IBindingTemplate } from '../IBindingTemplate';
1919
import { type IFunctionTemplate } from '../IFunctionTemplate';
2020
import { type ITemplates } from '../ITemplates';
2121
import { TemplateProviderBase, TemplateSchemaVersion, TemplateType } from '../TemplateProviderBase';
22-
import { DotnetTemplateOperation, executeDotnetTemplateCommand, getDotnetItemTemplatePath, getDotnetProjectTemplatePath, getDotnetTemplateDir, validateDotnetInstalled } from './executeDotnetTemplateCommand';
22+
import { executeDotnetTemplateCommand, getDotnetItemTemplatePath, getDotnetProjectTemplatePath, getDotnetTemplateDir, validateDotnetInstalled } from './executeDotnetTemplateCommand';
2323
import { parseDotnetTemplates } from './parseDotnetTemplates';
2424

2525
export class DotnetTemplateProvider extends TemplateProviderBase {
@@ -165,7 +165,7 @@ export class DotnetTemplateProvider extends TemplateProviderBase {
165165
}
166166

167167
private async parseTemplates(context: IActionContext, projKey: string): Promise<ITemplates> {
168-
this._rawTemplates = parseJson(await executeDotnetTemplateCommand(context, this.version, projKey, undefined, DotnetTemplateOperation.List));
168+
this._rawTemplates = parseJson(await executeDotnetTemplateCommand(context, this.version, projKey));
169169
return parseDotnetTemplates(this._rawTemplates, this.version);
170170
}
171171

src/templates/dotnet/executeDotnetTemplateCommand.ts

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { 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';
88
import * as fs from 'fs';
99
import * as os from 'os';
1010
import * as path from 'path';
@@ -18,30 +18,12 @@ import { findShortNameByIdentity, parseTemplatesFromNupkg } from './parseNupkgTe
1818
const itemNupkgFileName = 'item.nupkg';
1919
const 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-
168126
export function getDotnetItemTemplatePath(context: IActionContext, version: FuncVersion, projTemplateKey: string): string {
169127
return path.join(getDotnetTemplateDir(context, version, projTemplateKey), itemNupkgFileName);
170128
}

0 commit comments

Comments
 (0)