From 5f10defe9d58f206e8350cdbe2ce9524b85f05db Mon Sep 17 00:00:00 2001 From: Logan Yang Date: Fri, 6 Sep 2024 06:29:38 -0700 Subject: [PATCH] 2.6.4 (#611) Fix add custom prompt when no folder exists, update readme --- README.md | 6 ++++++ manifest.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- src/customPromptProcessor.ts | 13 +++++++++++-- versions.json | 3 ++- 6 files changed, 23 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 92174f4f..171e2fcc 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,12 @@ SPECIAL THANKS TO OUR TOP SPONSORS: [Changelog](https://github.com/logancyang/obsidian-copilot/releases) +#### Announcement 🚨 + +We are migrating off of PouchDB for better Obsidian Sync and mobile support (starting from v2.6.3). Your existing custom prompts MUST be dumped to markdown using the command _"Copilot: Dump custom prompts to markdown files"_. After running it you should be able to use your Add/Edit/Apply/Delete custom prompts as usual. + +Please make sure you run it, or you will lose all your old prompts when PouchDB is removed! + #### v2.6.0: MOBILE SUPPORT is here! 🎉🎉🎉 diff --git a/manifest.json b/manifest.json index 87a948c5..5ca52eb0 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "copilot", "name": "Copilot", - "version": "2.6.3", + "version": "2.6.4", "minAppVersion": "0.15.0", "description": "A ChatGPT Copilot in Obsidian.", "author": "Logan Yang", diff --git a/package-lock.json b/package-lock.json index 72b49cbe..ab0b1e7e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "obsidian-copilot", - "version": "2.6.3", + "version": "2.6.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "obsidian-copilot", - "version": "2.6.3", + "version": "2.6.4", "license": "AGPL-3.0", "dependencies": { "@esbuild-plugins/node-globals-polyfill": "^0.2.3", diff --git a/package.json b/package.json index 819797b0..67130d18 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-copilot", - "version": "2.6.3", + "version": "2.6.4", "description": "ChatGPT integration for Obsidian", "main": "main.js", "scripts": { diff --git a/src/customPromptProcessor.ts b/src/customPromptProcessor.ts index d1262b49..b42513e6 100644 --- a/src/customPromptProcessor.ts +++ b/src/customPromptProcessor.ts @@ -6,7 +6,7 @@ import { getNotesFromTags, processVariableNameForNotePath, } from "@/utils"; -import { Notice, TFile, Vault } from "obsidian"; +import { normalizePath, Notice, TFile, Vault } from "obsidian"; // TODO: To be deprecated once PouchDB is removed export interface CustomPromptDB { @@ -65,7 +65,16 @@ export class CustomPromptProcessor { } async savePrompt(title: string, content: string): Promise { - const filePath = `${this.settings.customPromptsFolder}/${title}.md`; + const folderPath = normalizePath(this.settings.customPromptsFolder); + const filePath = `${folderPath}/${title}.md`; + + // Check if the folder exists and create it if it doesn't + const folderExists = await this.vault.adapter.exists(folderPath); + if (!folderExists) { + await this.vault.createFolder(folderPath); + } + + // Create the file await this.vault.create(filePath, content); } diff --git a/versions.json b/versions.json index 516b705d..80b331b2 100644 --- a/versions.json +++ b/versions.json @@ -49,5 +49,6 @@ "2.6.0": "0.15.0", "2.6.1": "0.15.0", "2.6.2": "0.15.0", - "2.6.3": "0.15.0" + "2.6.3": "0.15.0", + "2.6.4": "0.15.0" }