From 6191ce91a9c57bbc76a653a66a21d219aa96e6ad Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 13 Dec 2025 12:44:22 +0800 Subject: [PATCH 1/4] feat:support specify order for extra tools --- src/index.ts | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/index.ts b/src/index.ts index f448efd..583b121 100644 --- a/src/index.ts +++ b/src/index.ts @@ -147,18 +147,22 @@ async function getTools( } const options = [ - { value: 'biome', label: 'Biome (linting & formatting)' }, - { value: 'eslint', label: 'ESLint (linting)' }, - { value: 'prettier', label: 'Prettier (formatting)' }, + { value: 'biome', label: 'Biome - linting & formatting' }, + { value: 'eslint', label: 'ESLint - linting' }, + { value: 'prettier', label: 'Prettier - formatting' }, ]; if (extraTools) { + const normalize = (tool: ExtraTool) => ({ + value: tool.value, + label: tool.label, + hint: tool.command, + }); + options.unshift( + ...extraTools.filter((tool) => tool.order === 'pre').map(normalize), + ); options.push( - ...extraTools.map((tool) => ({ - value: tool.value, - label: tool.label, - hint: tool.command, - })), + ...extraTools.filter((tool) => tool.order !== 'pre').map(normalize), ); } @@ -230,6 +234,10 @@ type ExtraTool = { * The custom command to run when the tool is selected. */ command?: string; + /** + * Specify the display order + */ + order?: 'pre' | 'post'; }; function runCommand(command: string, cwd: string, packageManager: string) { From 01ab7f432d44ec9ea97f11476f8048c266a095f3 Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 13 Dec 2025 12:46:06 +0800 Subject: [PATCH 2/4] fix --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 583b121..ef838c5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -252,9 +252,9 @@ function runCommand(command: string, cwd: string, packageManager: string) { const replacement = createReplacements[packageManager]; if (replacement) { command = command - .replace(/^npm create /, replacement) + .replace('npm create ', replacement) // other package managers don't need the extra `--` - .replace(/ -- --/, ' --'); + .replace(' -- --', ' --'); } // Yarn v1 does not support `@latest` tag if (packageManager === 'yarn') { From faeece4b012db426f0826432fd3c6b291742c31e Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 13 Dec 2025 12:51:07 +0800 Subject: [PATCH 3/4] Update src/index.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index ef838c5..57b82c4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -235,8 +235,8 @@ type ExtraTool = { */ command?: string; /** - * Specify the display order - */ + * Specify where to display this tool. + * If undefined, the tool will be displayed after built-in tools. order?: 'pre' | 'post'; }; From 9dadc27ac17b85586e35eb44b13110512e389587 Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 13 Dec 2025 12:51:33 +0800 Subject: [PATCH 4/4] Apply suggestion from @chenjiahan --- src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.ts b/src/index.ts index 57b82c4..a537d50 100644 --- a/src/index.ts +++ b/src/index.ts @@ -237,6 +237,7 @@ type ExtraTool = { /** * Specify where to display this tool. * If undefined, the tool will be displayed after built-in tools. + */ order?: 'pre' | 'post'; };