diff --git a/src/core/config/CustomModesManager.ts b/src/core/config/CustomModesManager.ts index efa3366aee..2a2a54ee2a 100644 --- a/src/core/config/CustomModesManager.ts +++ b/src/core/config/CustomModesManager.ts @@ -7,6 +7,7 @@ import { fileExistsAtPath } from "../../utils/fs" import { arePathsEqual, getWorkspacePath } from "../../utils/path" import { logger } from "../../utils/logging" import { GlobalFileNames } from "../../shared/globalFileNames" +import { ensureSettingsDirectoryExists } from "../../utils/globalContext" const ROOMODES_FILENAME = ".roomodes" @@ -114,7 +115,7 @@ export class CustomModesManager { } async getCustomModesFilePath(): Promise { - const settingsDir = await this.ensureSettingsDirectoryExists() + const settingsDir = await ensureSettingsDirectoryExists(this.context) const filePath = path.join(settingsDir, GlobalFileNames.customModes) const fileExists = await fileExistsAtPath(filePath) if (!fileExists) { @@ -329,12 +330,6 @@ export class CustomModesManager { } } - private async ensureSettingsDirectoryExists(): Promise { - const settingsDir = path.join(this.context.globalStorageUri.fsPath, "settings") - await fs.mkdir(settingsDir, { recursive: true }) - return settingsDir - } - async resetCustomModes(): Promise { try { const filePath = await this.getCustomModesFilePath() diff --git a/src/services/marketplace/MarketplaceManager.ts b/src/services/marketplace/MarketplaceManager.ts index a27a0c9136..b5c79190f9 100644 --- a/src/services/marketplace/MarketplaceManager.ts +++ b/src/services/marketplace/MarketplaceManager.ts @@ -12,10 +12,11 @@ import { InstallMarketplaceItemOptions, } from "./types" import { getUserLocale } from "./utils" -import { GlobalFileNames } from "../../../src/shared/globalFileNames" +import { GlobalFileNames } from "../../shared/globalFileNames" import { assertsMpContext, createHookable, MarketplaceContext, registerMarketplaceHooks } from "roo-rocket" import { assertsBinarySha256, unpackFromUint8, extractRocketConfigFromUint8 } from "config-rocket/cli" import { getPanel } from "../../activate/registerCommands" +import { ensureSettingsDirectoryExists } from "../../utils/globalContext" /** * Service for managing marketplace data @@ -584,7 +585,7 @@ export class MarketplaceManager { const cwd = target === "project" ? vscode.workspace.workspaceFolders![0].uri.fsPath - : await this.ensureSettingsDirectoryExists() + : await ensureSettingsDirectoryExists(this.context) if (!item.binaryUrl || !item.binaryHash) return vscode.window.showErrorMessage("Item does not have a binary URL or hash") @@ -658,15 +659,6 @@ export class MarketplaceManager { vscode.window.showInformationMessage(`"${item.name}" installed successfully`) } } - - /** - * Copied from `src/core/config/CustomModesManager.ts`, if in the future we add ClineProvider ref to this class, we can remove this and use the one from there. - */ - private async ensureSettingsDirectoryExists(): Promise { - const settingsDir = path.join(this.context.globalStorageUri.fsPath, "settings") - await fs.mkdir(settingsDir, { recursive: true }) - return settingsDir - } } async function fetchBinary(url: string) { diff --git a/src/utils/globalContext.ts b/src/utils/globalContext.ts new file mode 100644 index 0000000000..c86548d319 --- /dev/null +++ b/src/utils/globalContext.ts @@ -0,0 +1,9 @@ +import { mkdir } from "fs/promises" +import { join } from "path" +import { ExtensionContext } from "vscode" + +export async function ensureSettingsDirectoryExists(context: ExtensionContext): Promise { + const settingsDir = join(context.globalStorageUri.fsPath, "settings") + await mkdir(settingsDir, { recursive: true }) + return settingsDir +}