From a39486100556b3c5c6fde6e09e30f758e3ad2924 Mon Sep 17 00:00:00 2001 From: swk777 Date: Wed, 11 Sep 2024 10:41:38 +0800 Subject: [PATCH] change shortcut & install prettier in dev --- packages/api/exec.mts | 16 ++++++++++++---- packages/api/session.mts | 1 + packages/web/src/components/cells/code.tsx | 2 +- .../src/components/keyboard-shortcuts-dialog.tsx | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/api/exec.mts b/packages/api/exec.mts index ec0555a1..84aea713 100644 --- a/packages/api/exec.mts +++ b/packages/api/exec.mts @@ -15,6 +15,7 @@ export type NodeRequestType = BaseExecRequestType & { export type NPMInstallRequestType = BaseExecRequestType & { packages?: Array; + args?: Array; }; type SpawnCallRequestType = { @@ -132,10 +133,17 @@ export function tsx(options: NodeRequestType) { */ export function npmInstall(options: NPMInstallRequestType) { const { cwd, stdout, stderr, onExit } = options; - const args = options.packages - ? ['install', '--include=dev', ...options.packages] - : ['install', '--include=dev']; + ? ['install', '--include=dev', ...(options.args || []), ...options.packages] + : ['install', '--include=dev', ...(options.args || [])]; - return spawnCall({ command: 'npm', cwd, args, stdout, stderr, onExit, env: process.env }); + return spawnCall({ + command: 'npm', + cwd, + args, + stdout, + stderr, + onExit, + env: process.env, + }); } diff --git a/packages/api/session.mts b/packages/api/session.mts index 04a87984..c6abc950 100644 --- a/packages/api/session.mts +++ b/packages/api/session.mts @@ -310,6 +310,7 @@ async function ensurePrettierInstalled(dir: string): Promise { npmInstall({ cwd: dir, packages: ['prettier'], + args: ['--save-dev'], stdout: () => {}, stderr: (err) => console.error(err), onExit: (exitCode) => { diff --git a/packages/web/src/components/cells/code.tsx b/packages/web/src/components/cells/code.tsx index 8e6dcde9..2ca12226 100644 --- a/packages/web/src/components/cells/code.tsx +++ b/packages/web/src/components/cells/code.tsx @@ -719,7 +719,7 @@ function CodeEditor({ keymap.of([ { key: 'Mod-Enter', run: evaluateModEnter }, { - key: 'Mod-Shift-f', + key: 'Shift-Alt-f', run: () => { formatCell(); return true; diff --git a/packages/web/src/components/keyboard-shortcuts-dialog.tsx b/packages/web/src/components/keyboard-shortcuts-dialog.tsx index fee83917..85846fd0 100644 --- a/packages/web/src/components/keyboard-shortcuts-dialog.tsx +++ b/packages/web/src/components/keyboard-shortcuts-dialog.tsx @@ -44,7 +44,7 @@ export default function KeyboardShortcutsDialog({ - +