mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix: resolve lint problems
This commit is contained in:
parent
9354a80b1a
commit
bc60b426b5
11 changed files with 66 additions and 79 deletions
|
|
@ -1,11 +1,9 @@
|
|||
import * as vscode from "vscode"
|
||||
import { ClineProvider } from "./ClineProvider"
|
||||
import { WebviewMessage } from "../../shared/WebviewMessage"
|
||||
import { ExtensionMessage } from "../../shared/ExtensionMessage"
|
||||
import {
|
||||
MarketplaceManager,
|
||||
ComponentType,
|
||||
MarketplaceItem,
|
||||
MarketplaceSource,
|
||||
validateSources,
|
||||
ValidationError,
|
||||
|
|
@ -42,7 +40,7 @@ export async function handleMarketplaceMessages(
|
|||
}
|
||||
|
||||
// Check if we need to force refresh using type assertion
|
||||
const forceRefresh = (message as any).forceRefresh === true
|
||||
// const forceRefresh = (message as any).forceRefresh === true
|
||||
try {
|
||||
marketplaceManager.isFetching = true
|
||||
|
||||
|
|
@ -59,9 +57,6 @@ export async function handleMarketplaceMessages(
|
|||
await provider.contextProxy.setValue("marketplaceSources", sources)
|
||||
}
|
||||
|
||||
// Add timing information
|
||||
const startTime = Date.now()
|
||||
|
||||
// Fetch items from all enabled sources
|
||||
const enabledSources = sources.filter((s) => s.enabled)
|
||||
|
||||
|
|
@ -92,8 +87,6 @@ export async function handleMarketplaceMessages(
|
|||
marketplaceManager.isFetching = false
|
||||
}
|
||||
|
||||
const endTime = Date.now()
|
||||
|
||||
// The items are already stored in PackageManagerManager's currentItems
|
||||
// No need to store in global state
|
||||
|
||||
|
|
|
|||
|
|
@ -234,7 +234,8 @@ export class GitFetcher {
|
|||
}
|
||||
|
||||
// Get current branch using existing git instance
|
||||
const branch = (await this.git?.revparse(["--abbrev-ref", "HEAD"])) || "main"
|
||||
// const branch =
|
||||
;(await this.git?.revparse(["--abbrev-ref", "HEAD"])) || "main"
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
`Failed to clone/pull repository: ${error instanceof Error ? error.message : String(error)}`,
|
||||
|
|
|
|||
|
|
@ -11,13 +11,12 @@ import {
|
|||
LocalizationOptions,
|
||||
InstallMarketplaceItemOptions,
|
||||
} from "./types"
|
||||
import { validateSource, validateSources } from "../../shared/MarketplaceValidation"
|
||||
import { getUserLocale } from "./utils"
|
||||
import { GlobalFileNames } from "src/shared/globalFileNames"
|
||||
import { TerminalRegistry } from "src/integrations/terminal/TerminalRegistry"
|
||||
import { assertsMpContext, createHookable, MarketplaceContext, registerMarketplaceHooks } from "roo-rocket"
|
||||
import { unpackFromUint8 } from "config-rocket/cli"
|
||||
import { uint8IsConfigPackWithParameters } from 'config-rocket/cli'
|
||||
import { uint8IsConfigPackWithParameters } from "config-rocket/cli"
|
||||
|
||||
/**
|
||||
* Service for managing marketplace data
|
||||
|
|
@ -572,32 +571,32 @@ export class MarketplaceManager {
|
|||
}
|
||||
|
||||
async installMarketplaceItem(item: MarketplaceItem, options?: InstallMarketplaceItemOptions) {
|
||||
const {
|
||||
target = 'project'
|
||||
} = options || {}
|
||||
const { target = "project" } = options || {}
|
||||
|
||||
vscode.window.showInformationMessage(`Installing item: "${item.name}"`)
|
||||
|
||||
if (target === 'project' && !vscode.workspace.workspaceFolders?.length)
|
||||
if (target === "project" && !vscode.workspace.workspaceFolders?.length)
|
||||
return vscode.window.showErrorMessage("Cannot load current workspace folder")
|
||||
|
||||
const cwd = target === 'project'
|
||||
? vscode.workspace.workspaceFolders![0].uri.fsPath
|
||||
: await this.ensureSettingsDirectoryExists()
|
||||
const cwd =
|
||||
target === "project"
|
||||
? vscode.workspace.workspaceFolders![0].uri.fsPath
|
||||
: await this.ensureSettingsDirectoryExists()
|
||||
|
||||
if (!item.binaryUrl || !item.binaryHash)
|
||||
return vscode.window.showErrorMessage("Item does not have a binary URL or hash")
|
||||
|
||||
// Creates `mpContext` to delegate context to `roo-rocket`
|
||||
const mpContext = (target === 'project'
|
||||
? { target }
|
||||
: {
|
||||
target,
|
||||
globalFileNames: {
|
||||
mcp: GlobalFileNames.mcpSettings,
|
||||
mode: GlobalFileNames.customModes,
|
||||
}
|
||||
}
|
||||
const mpContext = (
|
||||
target === "project"
|
||||
? { target }
|
||||
: {
|
||||
target,
|
||||
globalFileNames: {
|
||||
mcp: GlobalFileNames.mcpSettings,
|
||||
mode: GlobalFileNames.customModes,
|
||||
},
|
||||
}
|
||||
) satisfies MarketplaceContext
|
||||
assertsMpContext(mpContext)
|
||||
|
||||
|
|
@ -611,29 +610,34 @@ export class MarketplaceManager {
|
|||
let pResult: string[] = []
|
||||
let pExitCode: number | undefined
|
||||
// We don't want to create a new terminal at the global dir, so I'm not using cwd here
|
||||
const terminalClass = await TerminalRegistry.getOrCreateTerminal(vscode.workspace.workspaceFolders?.[0]?.uri?.fsPath ?? '', false, `IMI-${item.name}`)
|
||||
const terminalClass = await TerminalRegistry.getOrCreateTerminal(
|
||||
vscode.workspace.workspaceFolders?.[0]?.uri?.fsPath ?? "",
|
||||
false,
|
||||
`IMI-${item.name}`,
|
||||
)
|
||||
terminalClass.terminal.show()
|
||||
await terminalClass.runCommand(`npx --yes roo-rocket@latest --mp="${JSON.stringify(mpContext).replaceAll(/"/g, '\\"')}" --cwd="${cwd}" --sha256="${item.binaryHash}" --url="${item.binaryUrl}"`, {
|
||||
onLine: (line) => {
|
||||
pResult.push(line)
|
||||
await terminalClass.runCommand(
|
||||
`npx --yes roo-rocket@latest --mp="${JSON.stringify(mpContext).replaceAll(/"/g, '\\"')}" --cwd="${cwd}" --sha256="${item.binaryHash}" --url="${item.binaryUrl}"`,
|
||||
{
|
||||
onLine: (line) => {
|
||||
pResult.push(line)
|
||||
},
|
||||
onShellExecutionComplete: (details) => {
|
||||
pExitCode = details.exitCode
|
||||
},
|
||||
},
|
||||
onShellExecutionComplete: (details) => {
|
||||
pExitCode = details.exitCode
|
||||
},
|
||||
})
|
||||
)
|
||||
|
||||
if (pExitCode === 0)
|
||||
vscode.window.showInformationMessage(`"${item.name}" CLI reported success!`)
|
||||
if (pExitCode === 0) vscode.window.showInformationMessage(`"${item.name}" CLI reported success!`)
|
||||
else {
|
||||
console.error(pResult)
|
||||
// Revert so error search is potentially faster
|
||||
pResult.reverse()
|
||||
// Search for error line in the result
|
||||
const errorLine = (
|
||||
pResult.find(line => /^((\r)?\n)+ ERROR /.test(line)) ?? // Prefer formatting error
|
||||
pResult.find(line => /error/i.test(line)) ?? // General error
|
||||
'N/A'
|
||||
)
|
||||
const errorLine =
|
||||
pResult.find((line) => /^((\r)?\n)+ ERROR /.test(line)) ?? // Prefer formatting error
|
||||
pResult.find((line) => /error/i.test(line)) ?? // General error
|
||||
"N/A"
|
||||
return vscode.window.showErrorMessage(`"${item.name}" CLI reported error: (${pExitCode}): ${errorLine}`)
|
||||
}
|
||||
}
|
||||
|
|
@ -648,12 +652,11 @@ export class MarketplaceManager {
|
|||
hookable: customHookable,
|
||||
nonAssemblyBehavior: true,
|
||||
sha256: item.binaryHash,
|
||||
cwd
|
||||
cwd,
|
||||
})
|
||||
vscode.window.showInformationMessage(`"${item.name}" installed successfully`)
|
||||
}
|
||||
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
@ -669,8 +672,7 @@ export class MarketplaceManager {
|
|||
|
||||
async function fetchBinary(url: string) {
|
||||
const res = await fetch(url)
|
||||
if (!res.ok)
|
||||
throw new Error(`Failed to download binary from ${url}`)
|
||||
if (!res.ok) throw new Error(`Failed to download binary from ${url}`)
|
||||
|
||||
return new Uint8Array(await res.arrayBuffer())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,7 @@ import * as vscode from "vscode"
|
|||
import { GitFetcher } from "../GitFetcher"
|
||||
import * as fs from "fs/promises"
|
||||
import * as path from "path"
|
||||
import { Dirent, Stats } from "fs"
|
||||
import simpleGit, { SimpleGit } from "simple-git"
|
||||
import { MetadataScanner } from "../MetadataScanner"
|
||||
import { exec, ChildProcess } from "child_process"
|
||||
import { promisify } from "util"
|
||||
import { EventEmitter } from "events"
|
||||
|
||||
// Mock simpleGit
|
||||
jest.mock("simple-git", () => {
|
||||
|
|
@ -54,21 +49,21 @@ const mockContext = {
|
|||
} as vscode.ExtensionContext
|
||||
|
||||
// Create mock Dirent objects
|
||||
const createMockDirent = (name: string, isDir: boolean): Dirent => {
|
||||
return {
|
||||
name,
|
||||
isDirectory: () => isDir,
|
||||
isFile: () => !isDir,
|
||||
isBlockDevice: () => false,
|
||||
isCharacterDevice: () => false,
|
||||
isFIFO: () => false,
|
||||
isSocket: () => false,
|
||||
isSymbolicLink: () => false,
|
||||
// These are readonly in the real Dirent
|
||||
path: "",
|
||||
parentPath: "",
|
||||
} as Dirent
|
||||
}
|
||||
// const createMockDirent = (name: string, isDir: boolean): Dirent => {
|
||||
// return {
|
||||
// name,
|
||||
// isDirectory: () => isDir,
|
||||
// isFile: () => !isDir,
|
||||
// isBlockDevice: () => false,
|
||||
// isCharacterDevice: () => false,
|
||||
// isFIFO: () => false,
|
||||
// isSocket: () => false,
|
||||
// isSymbolicLink: () => false,
|
||||
// // These are readonly in the real Dirent
|
||||
// path: "",
|
||||
// parentPath: "",
|
||||
// } as Dirent
|
||||
// }
|
||||
|
||||
describe("GitFetcher", () => {
|
||||
let gitFetcher: GitFetcher
|
||||
|
|
@ -341,7 +336,7 @@ describe("GitFetcher", () => {
|
|||
|
||||
it("should pass when metadata.en.yml exists", async () => {
|
||||
// Mock fs.stat to simulate existing file
|
||||
;(fs.stat as jest.Mock).mockImplementation((path: string) => {
|
||||
;(fs.stat as jest.Mock).mockImplementation(() => {
|
||||
return Promise.resolve({} as any)
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -112,13 +112,12 @@ describe("PackageManagerManager", () => {
|
|||
|
||||
let manager: MarketplaceManager
|
||||
let metadataScanner: MetadataScanner
|
||||
let realItems: MarketplaceItem[]
|
||||
|
||||
beforeAll(async () => {
|
||||
// Load real data from the template
|
||||
const templatePath = path.resolve(__dirname, "../../../../marketplace-template")
|
||||
metadataScanner = new MetadataScanner()
|
||||
realItems = await metadataScanner.scanDirectory(templatePath, "https://example.com")
|
||||
await metadataScanner.scanDirectory(templatePath, "https://example.com")
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
|
|
@ -674,7 +673,8 @@ describe("Concurrency Control", () => {
|
|||
const operation2 = manager.getMarketplaceItems([source])
|
||||
|
||||
// Wait for both to complete
|
||||
const [result1, result2] = await Promise.all([operation1, operation2])
|
||||
// const [result1, result2] =
|
||||
await Promise.all([operation1, operation2])
|
||||
|
||||
// Verify getRepositoryData was only called once
|
||||
expect(getRepoSpy).toHaveBeenCalledTimes(1)
|
||||
|
|
@ -698,7 +698,8 @@ describe("Concurrency Control", () => {
|
|||
let metadataScanDuringGit = false
|
||||
|
||||
// Mock git operation to resolve immediately
|
||||
const fetchRepoSpy = jest.spyOn(GitFetcher.prototype, "fetchRepository").mockImplementation(async () => {
|
||||
// const fetchRepoSpy =
|
||||
jest.spyOn(GitFetcher.prototype, "fetchRepository").mockImplementation(async () => {
|
||||
isGitOperationActive = true
|
||||
isGitOperationActive = false
|
||||
return {
|
||||
|
|
@ -709,7 +710,8 @@ describe("Concurrency Control", () => {
|
|||
})
|
||||
|
||||
// Mock metadata scanner to check if git operation is active
|
||||
const scanDirSpy = jest.spyOn(MetadataScanner.prototype, "scanDirectory").mockImplementation(async () => {
|
||||
// const scanDirSpy =
|
||||
jest.spyOn(MetadataScanner.prototype, "scanDirectory").mockImplementation(async () => {
|
||||
if (isGitOperationActive) {
|
||||
metadataScanDuringGit = true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import {
|
|||
validateSourceDuplicates,
|
||||
validateSource,
|
||||
validateSources,
|
||||
ValidationError,
|
||||
} from "../../../shared/MarketplaceValidation"
|
||||
import { MarketplaceSource } from "../types"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import * as path from "path"
|
||||
import { MetadataScanner } from "../MetadataScanner"
|
||||
import { GitFetcher } from "../GitFetcher"
|
||||
import * as vscode from "vscode"
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import { jest } from "@jest/globals"
|
|||
import { Dirent, Stats } from "fs"
|
||||
import { MetadataScanner } from "../MetadataScanner"
|
||||
import { SimpleGit } from "simple-git"
|
||||
import { ComponentMetadata, LocalizationOptions, LocalizedMetadata, PackageMetadata } from "../types"
|
||||
import * as fs from "fs/promises"
|
||||
|
||||
// Helper function to normalize paths for test assertions
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { z } from "zod"
|
||||
import { ComponentType } from "./types"
|
||||
|
||||
/**
|
||||
* Base metadata schema with common fields
|
||||
|
|
|
|||
|
|
@ -120,8 +120,6 @@ export function validateSourceDuplicates(
|
|||
newSource?: MarketplaceSource,
|
||||
): ValidationError[] {
|
||||
const errors: ValidationError[] = []
|
||||
const urlMap = new Map<string, number>()
|
||||
const nameMap = new Map<string, number>()
|
||||
|
||||
// Process existing sources
|
||||
const seen = new Set<string>()
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ interface MarketplaceViewProps {
|
|||
onDone?: () => void
|
||||
stateManager: MarketplaceViewStateManager
|
||||
}
|
||||
const MarketplaceView: React.FC<MarketplaceViewProps> = ({ onDone, stateManager }) => {
|
||||
const MarketplaceView: React.FC<MarketplaceViewProps> = ({ stateManager }) => {
|
||||
const { t } = useAppTranslation()
|
||||
const [state, manager] = useStateManager(stateManager)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue