Просмотр исходного кода

Fix: Transform keybindings in nightly build to fix command+y shortcut (#8070)

* fix: transform keybindings command references in nightly build

The keybindings section was not being transformed during the nightly build process, causing command+y keybinding to reference the wrong command name (roo-cline.addToContext instead of roo-code-nightly.addToContext).

- Added keybindings schema to types.ts
- Updated generatePackageJson to transform keybindings command references
- This ensures keybindings work correctly in the nightly build

* fix: only include keybindings in output when they exist

Updated generatePackageJson to conditionally add keybindings to avoid including undefined values in the generated package.json. Fixed eslint-disable comment placement.

---------

Co-authored-by: Roo Code <[email protected]>
roomote[bot] 3 месяцев назад
Родитель
Сommit
87b45def18
2 измененных файлов с 26 добавлено и 3 удалено
  1. 12 3
      packages/build/src/esbuild.ts
  2. 14 0
      packages/build/src/types.ts

+ 12 - 3
packages/build/src/esbuild.ts

@@ -2,7 +2,7 @@ import * as fs from "fs"
 import * as path from "path"
 import { execSync } from "child_process"
 
-import { ViewsContainer, Views, Menus, Configuration, contributesSchema } from "./types.js"
+import { ViewsContainer, Views, Menus, Configuration, Keybindings, contributesSchema } from "./types.js"
 
 function copyDir(srcDir: string, dstDir: string, count: number): number {
 	const entries = fs.readdirSync(srcDir, { withFileTypes: true })
@@ -216,10 +216,12 @@ export function generatePackageJson({
 	overrideJson: Record<string, any> // eslint-disable-line @typescript-eslint/no-explicit-any
 	substitution: [string, string]
 }) {
-	const { viewsContainers, views, commands, menus, submenus, configuration } = contributesSchema.parse(contributes)
+	const { viewsContainers, views, commands, menus, submenus, keybindings, configuration } =
+		contributesSchema.parse(contributes)
 	const [from, to] = substitution
 
-	return {
+	// eslint-disable-next-line @typescript-eslint/no-explicit-any
+	const result: Record<string, any> = {
 		...packageJson,
 		...overrideJson,
 		contributes: {
@@ -234,6 +236,13 @@ export function generatePackageJson({
 			},
 		},
 	}
+
+	// Only add keybindings if they exist
+	if (keybindings) {
+		result.contributes.keybindings = transformArray<Keybindings>(keybindings, from, to, "command")
+	}
+
+	return result
 }
 
 // eslint-disable-next-line @typescript-eslint/no-explicit-any

+ 14 - 0
packages/build/src/types.ts

@@ -59,6 +59,19 @@ const submenusSchema = z.array(
 
 export type Submenus = z.infer<typeof submenusSchema>
 
+const keybindingsSchema = z.array(
+	z.object({
+		command: z.string(),
+		key: z.string().optional(),
+		mac: z.string().optional(),
+		win: z.string().optional(),
+		linux: z.string().optional(),
+		when: z.string().optional(),
+	}),
+)
+
+export type Keybindings = z.infer<typeof keybindingsSchema>
+
 const configurationPropertySchema = z.object({
 	type: z.union([
 		z.literal("string"),
@@ -92,6 +105,7 @@ export const contributesSchema = z.object({
 	commands: commandsSchema,
 	menus: menusSchema,
 	submenus: submenusSchema,
+	keybindings: keybindingsSchema.optional(),
 	configuration: configurationSchema,
 })