diff --git a/components.d.ts b/components.d.ts index 02aecea3..dd0b0ca1 100644 --- a/components.d.ts +++ b/components.d.ts @@ -129,6 +129,8 @@ declare module '@vue/runtime-core' { MenuLayout: typeof import('./src/components/MenuLayout.vue')['default'] MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default'] MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default'] + MyNewTool: typeof import('./src/tools/my-new-tool/my-new-tool.vue')['default'] + NardyEncTool: typeof import('./src/tools/nardy-enc-tool/nardy-enc-tool.vue')['default'] NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default'] NCheckbox: typeof import('naive-ui')['NCheckbox'] NCode: typeof import('naive-ui')['NCode'] diff --git a/scripts/create-tool.mjs b/scripts/create-tool.mjs index 94b70250..c7e08996 100644 --- a/scripts/create-tool.mjs +++ b/scripts/create-tool.mjs @@ -1,29 +1,30 @@ -import { mkdir, readFile, writeFile } from 'fs/promises'; -import { dirname, join } from 'path'; -import { fileURLToPath } from 'url'; +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'); -// eslint-disable-next-line no-undef + const toolName = process.argv[2]; if (!toolName) { throw new Error('Please specify a toolname.'); } -const toolNameCamelCase = toolName.replace(/-./g, (x) => x[1].toUpperCase()); +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}`); -const createToolFile = async (name, content) => { +async function createToolFile(name, content) { const filePath = join(toolDir, name); await writeFile(filePath, content.trim()); console.log(`File created: ${filePath}`); -}; +} createToolFile( `${toolName}.vue`, @@ -44,7 +45,7 @@ createToolFile( ); createToolFile( - `index.ts`, + 'index.ts', ` import { ArrowsShuffle } from '@vicons/tabler'; import { defineTool } from '../tool'; @@ -53,15 +54,16 @@ export const tool = defineTool({ name: '${toolNameTitleCase}', path: '/${toolName}', description: '', - keywords: ['${toolName.split('-').join("', '")}'], + 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.ts`, ''); createToolFile( `${toolName}.service.test.ts`, ` @@ -92,13 +94,6 @@ test.describe('Tool - ${toolNameTitleCase}', () => { }); }); - + `, ); - -const toolsIndex = join(toolsDir, 'index.ts'); -const indexContent = await readFile(toolsIndex, { encoding: 'utf-8' }).then((r) => r.split('\n')); - -indexContent.splice(3, 0, `import { tool as ${toolNameCamelCase} } from './${toolName}';`); -writeFile(toolsIndex, indexContent.join('\n')); -console.log(`Added import in: ${toolsIndex}`);