Skip to content

Commit 87b45de

Browse files
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]>
1 parent a255c95 commit 87b45de

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

packages/build/src/esbuild.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as fs from "fs"
22
import * as path from "path"
33
import { execSync } from "child_process"
44

5-
import { ViewsContainer, Views, Menus, Configuration, contributesSchema } from "./types.js"
5+
import { ViewsContainer, Views, Menus, Configuration, Keybindings, contributesSchema } from "./types.js"
66

77
function copyDir(srcDir: string, dstDir: string, count: number): number {
88
const entries = fs.readdirSync(srcDir, { withFileTypes: true })
@@ -216,10 +216,12 @@ export function generatePackageJson({
216216
overrideJson: Record<string, any> // eslint-disable-line @typescript-eslint/no-explicit-any
217217
substitution: [string, string]
218218
}) {
219-
const { viewsContainers, views, commands, menus, submenus, configuration } = contributesSchema.parse(contributes)
219+
const { viewsContainers, views, commands, menus, submenus, keybindings, configuration } =
220+
contributesSchema.parse(contributes)
220221
const [from, to] = substitution
221222

222-
return {
223+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
224+
const result: Record<string, any> = {
223225
...packageJson,
224226
...overrideJson,
225227
contributes: {
@@ -234,6 +236,13 @@ export function generatePackageJson({
234236
},
235237
},
236238
}
239+
240+
// Only add keybindings if they exist
241+
if (keybindings) {
242+
result.contributes.keybindings = transformArray<Keybindings>(keybindings, from, to, "command")
243+
}
244+
245+
return result
237246
}
238247

239248
// eslint-disable-next-line @typescript-eslint/no-explicit-any

packages/build/src/types.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,19 @@ const submenusSchema = z.array(
5959

6060
export type Submenus = z.infer<typeof submenusSchema>
6161

62+
const keybindingsSchema = z.array(
63+
z.object({
64+
command: z.string(),
65+
key: z.string().optional(),
66+
mac: z.string().optional(),
67+
win: z.string().optional(),
68+
linux: z.string().optional(),
69+
when: z.string().optional(),
70+
}),
71+
)
72+
73+
export type Keybindings = z.infer<typeof keybindingsSchema>
74+
6275
const configurationPropertySchema = z.object({
6376
type: z.union([
6477
z.literal("string"),
@@ -92,6 +105,7 @@ export const contributesSchema = z.object({
92105
commands: commandsSchema,
93106
menus: menusSchema,
94107
submenus: submenusSchema,
108+
keybindings: keybindingsSchema.optional(),
95109
configuration: configurationSchema,
96110
})
97111

0 commit comments

Comments
 (0)