fix: use yaml instead of js-yaml, fix config-rocket missing, solve lint warn failure

This commit is contained in:
NamesMT 2025-05-22 07:11:38 +00:00 committed by hannesrudolph
parent 0de49f2799
commit ab2e4bf039
13 changed files with 24 additions and 737 deletions

725
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
import * as vscode from "vscode"
import * as path from "path"
import * as fs from "fs/promises"
import * as yaml from "js-yaml"
import * as yaml from "yaml"
import simpleGit, { SimpleGit } from "simple-git"
import { MetadataScanner } from "./MetadataScanner"
import { validateAnyMetadata } from "./schemas"
@ -256,6 +256,7 @@ export class GitFetcher {
// Get current branch using existing git instance
// const branch =
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
;(await this.git?.revparse(["--abbrev-ref", "HEAD"])) || "main"
} catch (error) {
throw new Error(
@ -288,7 +289,7 @@ export class GitFetcher {
const metadataContent = await fs.readFile(metadataPath, "utf-8")
try {
const parsed = yaml.load(metadataContent) as Record<string, any>
const parsed = yaml.parse(metadataContent) as Record<string, any>
return validateAnyMetadata(parsed) as RepositoryMetadata
} catch (error) {
console.error("Failed to parse repository metadata:", error)

View file

@ -1,7 +1,7 @@
import * as vscode from "vscode"
import * as path from "path"
import * as fs from "fs/promises"
import * as yaml from "js-yaml"
import * as yaml from "yaml"
import { z } from "zod"
import { ensureSettingsDirectoryExists } from "../../utils/globalContext"
@ -43,7 +43,7 @@ export class InstalledMetadataManager {
private async loadMetadataFile(filePath: string): Promise<ScopeInstalledMetadata> {
try {
const content = await fs.readFile(filePath, "utf-8")
const data = yaml.load(content)
const data = yaml.parse(content)
const validationResult = ScopeInstalledMetadataSchema.safeParse(data)
@ -159,7 +159,7 @@ export class InstalledMetadataManager {
await fs.mkdir(path.dirname(filePath), { recursive: true })
// Serialize metadata to YAML
const yamlContent = yaml.dump(metadata)
const yamlContent = yaml.stringify(metadata)
// Write to file
await fs.writeFile(filePath, yamlContent, "utf-8")

View file

@ -1,7 +1,7 @@
import * as path from "path"
import * as fs from "fs/promises"
import * as vscode from "vscode"
import * as yaml from "js-yaml"
import * as yaml from "yaml"
import { SimpleGit } from "simple-git"
import { validateAnyMetadata } from "./schemas"
import {
@ -189,7 +189,7 @@ export class MetadataScanner {
try {
const content = await fs.readFile(metadataPath, "utf-8")
const parsed = yaml.load(content) as Record<string, any>
const parsed = yaml.parse(content) as Record<string, any>
// Add type field if missing but has a parent directory indicating type
if (!parsed.type) {
@ -318,7 +318,7 @@ export class MetadataScanner {
const metadataPath = path.join(packageDir, "metadata.en.yml")
try {
const content = await fs.readFile(metadataPath, "utf-8")
const parsed = yaml.load(content) as PackageMetadata
const parsed = yaml.parse(content) as PackageMetadata
if (parsed.items) {
for (const item of parsed.items) {

View file

@ -1,4 +1,4 @@
import { RocketConfig } from "config-rocket"
import type { RocketConfig } from "config-rocket"
/**
* Information about why an item matched search/filter criteria
@ -38,6 +38,7 @@ export interface BaseMetadata {
/**
* Repository root metadata
*/
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface RepositoryMetadata extends BaseMetadata {}
/**

View file

@ -38,6 +38,7 @@
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"cmdk": "^1.0.0",
"config-rocket": "^0.5.8",
"date-fns": "^4.1.0",
"debounce": "^2.1.1",
"fast-deep-equal": "^3.1.3",
@ -60,7 +61,6 @@
"rehype-highlight": "^7.0.0",
"remark-gfm": "^4.0.1",
"remove-markdown": "^0.6.0",
"rocket-config": "^1.0.7",
"shell-quote": "^1.8.2",
"shiki": "^3.2.1",
"source-map": "^0.7.4",
@ -69,8 +69,8 @@
"tailwindcss": "^4.0.0",
"tailwindcss-animate": "^1.0.7",
"unist-util-visit": "^5.0.0",
"vscode-material-icons": "^0.1.1",
"use-sound": "^5.0.0",
"vscode-material-icons": "^0.1.1",
"vscrui": "^0.2.2",
"zod": "^3.24.2"
},

View file

@ -1,7 +1,7 @@
import React, { useState } from "react"
import { VSCodeButton, VSCodeTextField, VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react"
import { MarketplaceItem } from "../../../../src/services/marketplace/types"
import { RocketConfig } from "config-rocket"
import type { RocketConfig } from "config-rocket"
interface MarketplaceInstallSidebarProps {
item: MarketplaceItem

View file

@ -34,6 +34,7 @@ export function MarketplaceSourcesConfig({ stateManager }: MarketplaceSourcesCon
/[\u2300-\u23FF]/.test(str) || // Miscellaneous Technical
/[\u2700-\u27FF]/.test(str) || // Dingbats
/[\u2B50\u2B55]/.test(str) || // Star, Circle
// eslint-disable-next-line no-misleading-character-class
/[\u203C\u2049\u20E3\u2122\u2139\u2194-\u2199\u21A9\u21AA]/.test(str)
) // Punctuation
}

View file

@ -9,7 +9,7 @@ import InstallSidebar from "./InstallSidebar"
import { useEvent } from "react-use"
import { ExtensionMessage } from "@roo/shared/ExtensionMessage"
import { vscode } from "@/utils/vscode"
import { RocketConfig } from "config-rocket"
import type { RocketConfig } from "config-rocket"
import { MarketplaceSourcesConfig } from "./MarketplaceSourcesConfigView"
import { MarketplaceListView } from "./MarketplaceListView"
import { cn } from "@/lib/utils"

View file

@ -103,7 +103,6 @@ export class MarketplaceViewStateManager {
private stateChangeHandlers: Set<StateChangeHandler> = new Set()
// Empty constructor is required for test initialization
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
constructor() {
// Initialize is now handled by the loadInitialState call in the property initialization
}

View file

@ -1,7 +1,7 @@
import { fireEvent, screen } from "@testing-library/react"
import InstallSidebar from "../InstallSidebar"
import { MarketplaceItem } from "../../../../../src/services/marketplace/types"
import { RocketConfig } from "config-rocket"
import type { RocketConfig } from "config-rocket"
import { renderWithProviders } from "@/test/test-utils"
// Mock VSCode components

View file

@ -4,7 +4,7 @@ import { MarketplaceItem } from "../../../../../src/services/marketplace/types"
import { ViewState } from "../MarketplaceViewStateManager"
import userEvent from "@testing-library/user-event"
import { TooltipProvider } from "@/components/ui/tooltip"
import { RocketConfig } from "config-rocket"
import type { RocketConfig } from "config-rocket"
import { ExtensionStateContext } from "@/context/ExtensionStateContext"
// Mock vscode API - IMPORTANT: This mock must be at the very top of the file

View file

@ -422,7 +422,7 @@ describe("MarketplaceViewStateManager", () => {
})
it("should handle invalid transition payloads", async () => {
// @ts-ignore - Testing invalid payload
// @ts-expect-error - Testing invalid payload
await manager.transition({ type: "UPDATE_FILTERS", payload: { invalid: true } })
const state = manager.getState()
expect(state.filters).toEqual({