Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ function logHelpMessage(
extraTools?: ExtraTool[],
) {
const extraToolNames = extraTools?.map((tool) => tool.value) ?? [];
const toolsList = [...BUILTIN_TOOLS, ...extraToolNames].join(
', ',
);
const toolsList = [...BUILTIN_TOOLS, ...extraToolNames].join(', ');

logger.log(`
Usage: create-${name} [dir] [options]
Expand Down Expand Up @@ -222,7 +220,11 @@ type ExtraTool = {
/**
* The action to perform when the tool is selected.
*/
action?: () => unknown;
action?: (context: {
templateName: string;
distFolder: string;
addAgentsMdSearchDirs: (dir: string) => void;
}) => unknown;
/**
* The custom command to run when the tool is selected.
*/
Expand Down Expand Up @@ -368,7 +370,12 @@ export async function create({
);
if (matchedTool) {
if (matchedTool.action) {
await matchedTool.action();
await matchedTool.action({
templateName,
distFolder,
addAgentsMdSearchDirs: (dir: string) =>
agentsMdSearchDirs.push(dir),
});
}
if (matchedTool.command) {
runCommand(matchedTool.command, distFolder);
Expand Down
4 changes: 3 additions & 1 deletion test/custom-tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ test('should run extra tool action', async () => {
{
value: 'custom-action',
label: 'Custom Action',
action: () => {
action: ({ templateName, distFolder }) => {
expect(templateName).toBe('vanilla');
expect(distFolder).toBe(projectDir);
actionCalled = true;
},
},
Expand Down