* Generate both mdbase.yaml and the task type definition.
()
| 44 | * Generate both mdbase.yaml and the task type definition. |
| 45 | */ |
| 46 | async generate(): Promise<void> { |
| 47 | try { |
| 48 | const vault = this.plugin.app.vault; |
| 49 | const typesFolder = await this.getTypesFolder(); |
| 50 | const taskTypePath = `${typesFolder}/task.md`; |
| 51 | |
| 52 | await this.ensureFolderPath(typesFolder); |
| 53 | |
| 54 | const taskTypeDef = this.buildTaskTypeDef(); |
| 55 | await this.writeFile(taskTypePath, taskTypeDef); |
| 56 | |
| 57 | // Only create mdbase.yaml if it doesn't already exist so that |
| 58 | // user customisations (extra excludes, description, etc.) are preserved. |
| 59 | const mdbaseExists = await vault.adapter.exists("mdbase.yaml"); |
| 60 | if (!mdbaseExists) { |
| 61 | const mdbaseYaml = this.buildMdbaseYaml(typesFolder); |
| 62 | await this.writeFile("mdbase.yaml", mdbaseYaml); |
| 63 | } |
| 64 | |
| 65 | tasknotesLogger.debug( |
| 66 | `[TaskNotes][mdbase-spec] Generated mdbase.yaml and ${taskTypePath}`, |
| 67 | { category: "configuration", operation: "generated-mdbase-yaml-and" } |
| 68 | ); |
| 69 | } catch (error) { |
| 70 | tasknotesLogger.error("[TaskNotes][mdbase-spec] Failed to generate files:", { |
| 71 | category: "configuration", |
| 72 | operation: "generate-files", |
| 73 | error: error, |
| 74 | }); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | private async getTypesFolder(): Promise<string> { |
| 79 | const vault = this.plugin.app.vault; |
no test coverage detected