Skip to content

Commit 7e51c42

Browse files
authored
feat: enhance tool listing to support ordered extra tools (#95)
1 parent f59d6ad commit 7e51c42

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/index.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,19 @@ function logHelpMessage(
105105
templates: string[],
106106
extraTools?: ExtraTool[],
107107
) {
108-
const extraToolNames = extraTools?.map((tool) => tool.value) ?? [];
109-
const toolsList = [...BUILTIN_TOOLS, ...extraToolNames].join(', ');
108+
const toolsList = [...BUILTIN_TOOLS];
109+
if (extraTools) {
110+
for (const tool of extraTools) {
111+
if (!tool.value) {
112+
continue;
113+
}
114+
if (tool.order === 'pre') {
115+
toolsList.unshift(tool.value);
116+
} else {
117+
toolsList.push(tool.value);
118+
}
119+
}
120+
}
110121

111122
logger.log(`
112123
Usage: create-${name} [dir] [options]
@@ -116,13 +127,15 @@ function logHelpMessage(
116127
-h, --help display help for command
117128
-d, --dir <dir> create project in specified directory
118129
-t, --template <tpl> specify the template to use
119-
--tools <tool> select additional tools (${toolsList})
130+
--tools <tool> add additional tools, comma separated
120131
--override override files in target directory
121132
--packageName <name> specify the package name
122133
123-
Templates:
124-
134+
Available templates:
125135
${templates.join(', ')}
136+
137+
Optional tools:
138+
${toolsList.join(', ')}
126139
`);
127140
}
128141

test/help.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,5 @@ test('help message includes extra tools', async () => {
2828
}
2929

3030
const logOutput = logs.join('\n');
31-
expect(logOutput).toContain(
32-
'--tools <tool> select additional tools (biome, eslint, prettier, custom-tool)',
33-
);
31+
expect(logOutput).toContain('biome, eslint, prettier, custom-tool');
3432
});

0 commit comments

Comments
 (0)