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
14 changes: 10 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,11 @@ export async function create({
skipFiles?: string[];
templates: string[];
getTemplateName: (argv: Argv) => Promise<string>;
mapESLintTemplate: (
/**
* Map the template name to the ESLint template name.
* If not provided, defaults to 'vanilla-ts' for all templates.
*/
mapESLintTemplate?: (
templateName: string,
context: { distFolder: string },
) => ESLintTemplateName | null;
Expand Down Expand Up @@ -351,9 +355,11 @@ export async function create({
const toolFolder = path.join(packageRoot, `template-${tool}`);

if (tool === 'eslint') {
const eslintTemplateName = mapESLintTemplate(templateName, {
distFolder,
});
const eslintTemplateName = mapESLintTemplate
? mapESLintTemplate(templateName, {
distFolder,
})
: 'vanilla-ts';

if (!eslintTemplateName) {
continue;
Expand Down
3 changes: 0 additions & 3 deletions test/agents.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ test('should generate AGENTS.md with no tools selected', async () => {
root: fixturesDir,
templates: ['vanilla'],
getTemplateName: async () => 'vanilla',
mapESLintTemplate: () => null,
});

const agentsPath = path.join(projectDir, 'AGENTS.md');
Expand Down Expand Up @@ -92,7 +91,6 @@ test('should generate AGENTS.md with single tool selected', async () => {
root: fixturesDir,
templates: ['vanilla'],
getTemplateName: async () => 'vanilla',
mapESLintTemplate: () => null,
});

const agentsPath = path.join(projectDir, 'AGENTS.md');
Expand Down Expand Up @@ -205,7 +203,6 @@ test('should merge top-level sections from AGENTS.md files', async () => {
root: fixturesDir,
templates: ['vanilla'],
getTemplateName: async () => 'vanilla',
mapESLintTemplate: () => null,
});

const agentsPath = path.join(projectDir, 'AGENTS.md');
Expand Down
8 changes: 3 additions & 5 deletions test/custom-tools.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { assert, beforeEach, test } from '@rstest/core';
import { beforeEach, expect, test } from '@rstest/core';
import fse from 'fs-extra';
import { create } from '../dist/index.js';

Expand Down Expand Up @@ -45,7 +45,6 @@ test('should run extra tool action', async () => {
root: fixturesDir,
templates: ['vanilla'],
getTemplateName: async () => 'vanilla',
mapESLintTemplate: () => null,
extraTools: [
{
value: 'custom-action',
Expand All @@ -57,7 +56,7 @@ test('should run extra tool action', async () => {
],
});

assert.strictEqual(actionCalled, true);
expect(actionCalled).toBe(true);
});

test('should run extra tool command', async () => {
Expand All @@ -82,7 +81,6 @@ test('should run extra tool command', async () => {
root: fixturesDir,
templates: ['vanilla'],
getTemplateName: async () => 'vanilla',
mapESLintTemplate: () => null,
extraTools: [
{
value: 'custom-command',
Expand All @@ -92,5 +90,5 @@ test('should run extra tool command', async () => {
],
});

assert.strictEqual(fs.existsSync(touchedFile), true);
expect(fs.existsSync(touchedFile)).toBe(true);
});