diff --git a/package-lock.json b/package-lock.json index 7205f2c5f8..4b3c557da0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,7 @@ "cheerio": "^1.0.0", "chokidar": "^4.0.1", "clone-deep": "^4.0.1", - "config-rocket": "^0.3.19", + "config-rocket": "^0.3.20", "default-shell": "^2.2.0", "delay": "^6.0.0", "diff": "^5.2.0", @@ -11073,9 +11073,9 @@ "license": "MIT" }, "node_modules/config-rocket": { - "version": "0.3.19", - "resolved": "https://registry.npmjs.org/config-rocket/-/config-rocket-0.3.19.tgz", - "integrity": "sha512-6VwCdqHH5G/Q4D5byHiZsFbF3Dp2RYYNrA3RPreYYTmxvkuaGYy+KcWm7yfdwwoyVPFkuIeN5LTOHJjGMtW+rw==", + "version": "0.3.20", + "resolved": "https://registry.npmjs.org/config-rocket/-/config-rocket-0.3.20.tgz", + "integrity": "sha512-Zim3CGz4Psu2OvLU3U7dGhtj+Nzr+fAh51S2/YUO6vAjQUQa1Ll06+I53W1xMQFI4TcLBYKSpJV/jy+YfUZnHg==", "license": "MIT", "dependencies": { "c12": "^3.0.3", diff --git a/package.json b/package.json index 88da6e6f34..ee8b38ee37 100644 --- a/package.json +++ b/package.json @@ -447,7 +447,7 @@ "cheerio": "^1.0.0", "chokidar": "^4.0.1", "clone-deep": "^4.0.1", - "config-rocket": "^0.3.19", + "config-rocket": "^0.3.20", "default-shell": "^2.2.0", "delay": "^6.0.0", "diff": "^5.2.0", diff --git a/src/services/marketplace/MarketplaceManager.ts b/src/services/marketplace/MarketplaceManager.ts index dfb9e0e5b7..c360fe97a6 100644 --- a/src/services/marketplace/MarketplaceManager.ts +++ b/src/services/marketplace/MarketplaceManager.ts @@ -15,6 +15,8 @@ import { validateSource, validateSources } from "../../shared/MarketplaceValidat import { getUserLocale } from "./utils" import { GlobalFileNames } from "src/shared/globalFileNames" import { assertsMpContext, MarketplaceContext, registerMarketplaceHooks } from "roo-rocket" +import { uint8IsConfigPackWithParameters } from 'config-rocket' +import { unpackFromUint8 } from "config-rocket/cli" /** * Service for managing marketplace data @@ -573,6 +575,8 @@ export class MarketplaceManager { target = 'project' } = options || {} + vscode.window.showInformationMessage(`Installing item: "${item.name}"`) + if (target === 'project' && !vscode.workspace.workspaceFolders?.length) return vscode.window.showErrorMessage("Cannot load current workspace folder") @@ -598,18 +602,29 @@ export class MarketplaceManager { ) satisfies MarketplaceContext assertsMpContext(mpContext) - // Create a custom hookable instance to support global installations - const customHookable = createHookable() - registerMarketplaceHooks(customHookable, mpContext) + const binaryUint8 = await fetchBinary(item.binaryUrl) + + // Install via CLI if binary is a configurable pack. + if (await uint8IsConfigPackWithParameters(binaryUint8)) { + vscode.window.showInformationMessage(`"${item.name}" is a configurable pack, invoking CLI to install...`) + vscode.window.showInformationMessage(`*CLI install WIP*`) + } + // Fast install for non-configurable packs. + else { + // Create a custom hookable instance to support global installations + const customHookable = createHookable() + registerMarketplaceHooks(customHookable, mpContext) + + vscode.window.showInformationMessage(`"${item.name}" is non-configurable, fast install...`) + await unpackFromUint8(binaryUint8, { + hookable: customHookable, + nonAssemblyBehavior: true, + sha256: item.binaryHash, + cwd + }) + vscode.window.showInformationMessage(`"${item.name}" installed successfully`) + } - vscode.window.showInformationMessage(`Installing item: "${item.name}"`) - await unpackFromUrl(item.binaryUrl, { - hookable: customHookable, - nonAssemblyBehavior: true, - sha256: item.binaryHash, - cwd - }) - vscode.window.showInformationMessage(`Item "${item.name}" installed successfully`) return true } @@ -623,3 +638,11 @@ export class MarketplaceManager { return settingsDir } } + +async function fetchBinary(url: string) { + const res = await fetch(url) + if (!res.ok) + throw new Error(`Failed to download binary from ${url}`) + + return new Uint8Array(await res.arrayBuffer()) +}