import { mkdir, readFile, writeFile } from 'node:fs/promises'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; const currentDirname = dirname(fileURLToPath(import.meta.url)); const toolsDir = join(currentDirname, '..', 'src', 'tools'); const toolName = process.argv[2]; if (!toolName) { throw new Error('Please specify a toolname.'); } const toolCategory = process.argv[3] || 'Default'; const toolNameTitleCase = toolName[0].toUpperCase() + toolName.slice(1).replace(/-/g, ' '); const toolDir = join(toolsDir, toolName); await mkdir(toolDir); console.log(`Directory created: ${toolDir}`); async function createToolFile(name, content) { const filePath = join(toolDir, name); await writeFile(filePath, content.trim()); console.log(`File created: ${filePath}`); } createToolFile( `${toolName}.vue`, ` `, ); createToolFile( 'index.ts', ` import { ArrowsShuffle } from '@vicons/tabler'; import { defineTool } from '../tool'; export const tool = defineTool({ name: '${toolNameTitleCase}', path: '/${toolName}', description: '', keywords: ['${toolName.split('-').join('\', \'')}'], component: () => import('./${toolName}.vue'), icon: ArrowsShuffle, createdAt: new Date('${new Date().toISOString().split('T')[0]}'), category: '${toolCategory}', }); `, ); createToolFile(`${toolName}.service.ts`, ''); createToolFile( `${toolName}.service.test.ts`, ` import { expect, describe, it } from 'vitest'; // import { } from './${toolName}.service'; // // describe('${toolName}', () => { // // }) `, ); createToolFile( `${toolName}.e2e.spec.ts`, ` import { test, expect } from '@playwright/test'; test.describe('Tool - ${toolNameTitleCase}', () => { test.beforeEach(async ({ page }) => { await page.goto('/${toolName}'); }); test('Has correct title', async ({ page }) => { await expect(page).toHaveTitle('${toolNameTitleCase} - IT Tools'); }); test('', async ({ page }) => { }); }); `, );