Skip to content

Commit 1d8ef94

Browse files
authored
Use the v1 index.json for all templates not just v2 (#4652)
1 parent 8a6bfd8 commit 1d8ef94

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

src/templates/script/PysteinTemplateProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class PysteinTemplateProvider extends ScriptBundleTemplateProvider {
3232
protected _language: string;
3333

3434
public async getLatestTemplates(context: IActionContext, latestTemplateVersion: string): Promise<ITemplates> {
35-
const release: bundleFeedUtils.ITemplatesReleaseV2 = await bundleFeedUtils.getReleaseV2(latestTemplateVersion);
35+
const release = await bundleFeedUtils.getRelease(latestTemplateVersion, 'v2') as bundleFeedUtils.ITemplatesReleaseV2;
3636
const language = this.getResourcesLanguage();
3737
const resourcesUrl: string = release.resources.replace('{locale}', language);
3838
const urls: string[] = [release.userPrompts ?? release.bindings, resourcesUrl, release.functions];

src/templates/script/ScriptBundleTemplateProvider.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ export class ScriptBundleTemplateProvider extends ScriptTemplateProvider {
3131
}
3232

3333
public async getLatestTemplates(context: IActionContext, latestTemplateVersion: string): Promise<ITemplates> {
34-
const bundleMetadata: IBundleMetadata | undefined = await this.getBundleInfo();
35-
const release: bundleFeedUtils.ITemplatesReleaseV1 = await bundleFeedUtils.getRelease(context, bundleMetadata, latestTemplateVersion);
34+
const release = await bundleFeedUtils.getRelease(latestTemplateVersion, 'v1') as bundleFeedUtils.ITemplatesReleaseV1;
3635

3736
const language: string = this.getResourcesLanguage();
3837
const resourcesUrl: string = release.resources.replace('{locale}', language);

src/utils/bundleFeedUtils.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,17 @@ export namespace bundleFeedUtils {
6161
}
6262
}
6363

64-
export async function getRelease(context: IActionContext, bundleMetadata: IBundleMetadata | undefined, templateVersion: string): Promise<ITemplatesReleaseV1> {
65-
const feed: IBundleFeed = await getBundleFeed(context, bundleMetadata);
66-
return feed.templates.v1[templateVersion];
67-
}
68-
69-
export async function getReleaseV2(templateVersion: string): Promise<ITemplatesReleaseV2> {
70-
// build the url ourselves because the index-v2.json file is no longer publishing version updates for v2 templates
64+
export async function getRelease(templateVersion: string, version: 'v1' | 'v2'): Promise<ITemplatesReleaseV1 | ITemplatesReleaseV2> {
65+
// build the url ourselves because the index-v2.json file is no longer publishing version updates
7166
const functionsCdn: string = 'https://cdn.functions.azure.com/public/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle/';
67+
if (version === 'v1') {
68+
return {
69+
functions: `${functionsCdn}${templateVersion}/StaticContent/v1/templates/templates.json`,
70+
bindings: `${functionsCdn}${templateVersion}/StaticContent/v1/bindings/bindings.json`,
71+
resources: `${functionsCdn}${templateVersion}/StaticContent/v1/resources/Resources.{locale}.json`,
72+
};
73+
}
74+
7275
return {
7376
functions: `${functionsCdn}${templateVersion}/StaticContent/v2/templates/templates.json`,
7477
bindings: `${functionsCdn}${templateVersion}/StaticContent/v2/bindings/userPrompts.json`,

0 commit comments

Comments
 (0)