diff --git a/src/examples/Example.ts b/src/examples/Example.ts index 792258c89..3bb1b2836 100644 --- a/src/examples/Example.ts +++ b/src/examples/Example.ts @@ -27,12 +27,14 @@ export interface IExampleCategory { } export function getExamplesList( - targetFrameworkFolder: string + targetFrameworkFolder: string, + examplesContainer: string = "examples" ): IExampleCategory { - const examplesRoot = path.join(targetFrameworkFolder, "examples"); + const rootName = path.basename(targetFrameworkFolder); + const examplesRoot = path.join(targetFrameworkFolder, examplesContainer); const examplesPathList = utils.getSubProjects(examplesRoot); const rootFolder: IExampleCategory = { - name: examplesRoot, + name: rootName, examples: [], subcategories: [], }; @@ -42,8 +44,10 @@ export function getExamplesList( .split(path.sep); addSubCategory(rootFolder, examplePath, pathSegments); } - const getStarted = rootFolder.subcategories.findIndex((subCat) => subCat.name === "get-started"); - rootFolder.subcategories.splice(0, 0, rootFolder.subcategories.splice(getStarted, 1)[0]); + const getStartedIndex = rootFolder.subcategories.findIndex((subCat) => subCat.name === "get-started"); + if (getStartedIndex !== -1) { + rootFolder.subcategories.splice(0, 0, rootFolder.subcategories.splice(getStartedIndex, 1)[0]); + } return rootFolder; } diff --git a/src/extension.ts b/src/extension.ts index 79c3e310b..8d0eb964e 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1446,7 +1446,10 @@ export async function activate(context: vscode.ExtensionContext) { cancelToken: vscode.CancellationToken ) => { try { - const newProjectArgs = await getNewProjectArgs(progress); + const newProjectArgs = await getNewProjectArgs( + context.extensionPath, + progress + ); if (!newProjectArgs || !newProjectArgs.targetList) { throw new Error("Could not find ESP-IDF Targets"); } diff --git a/src/newProject/newProjectInit.ts b/src/newProject/newProjectInit.ts index cf18ad91a..f0d82dfb1 100644 --- a/src/newProject/newProjectInit.ts +++ b/src/newProject/newProjectInit.ts @@ -106,6 +106,7 @@ export async function getBoards() { } export async function getNewProjectArgs( + extensionPath: string, progress: Progress<{ message: string; increment: number }> ) { progress.report({ increment: 10, message: "Loading ESP-IDF components..." }); @@ -131,7 +132,8 @@ export async function getNewProjectArgs( const espIdfPath = idfConf.readParameter("idf.espIdfPath") as string; const espAdfPath = idfConf.readParameter("idf.espAdfPath") as string; const espMdfPath = idfConf.readParameter("idf.espMdfPath") as string; - let templates: { [key:string]: IExampleCategory} = {}; + let templates: { [key: string]: IExampleCategory } = {}; + templates["Extension"] = getExamplesList(extensionPath, "templates"); const idfExists = await dirExistPromise(espIdfPath); if (idfExists) { const idfTemplates = getExamplesList(espIdfPath); diff --git a/src/views/new-project/Templates.vue b/src/views/new-project/Templates.vue index 65ff6a387..dec73a9c6 100644 --- a/src/views/new-project/Templates.vue +++ b/src/views/new-project/Templates.vue @@ -67,7 +67,7 @@ export default class Templates extends Vue { this.storeTemplatesRootPath && this.storeTemplatesRootPath[this.selectedFramework] ) { - return this.storeTemplatesRootPath[this.selectedFramework].subcategories; + return [this.storeTemplatesRootPath[this.selectedFramework]]; } } diff --git a/src/views/new-project/components/templateList.vue b/src/views/new-project/components/templateList.vue index 1f926e50d..e9c0899c5 100644 --- a/src/views/new-project/components/templateList.vue +++ b/src/views/new-project/components/templateList.vue @@ -1,7 +1,10 @@