@hono-di/generate 0.0.6 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -338,5 +338,3 @@ function generate(input) {
338
338
  }
339
339
 
340
340
  exports.generate = generate;
341
- //# sourceMappingURL=index.cjs.map
342
- //# sourceMappingURL=index.cjs.map
package/dist/index.js CHANGED
@@ -331,5 +331,3 @@ function generate(input) {
331
331
  }
332
332
 
333
333
  export { generate };
334
- //# sourceMappingURL=index.js.map
335
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hono-di/generate",
3
- "version": "0.0.6",
3
+ "version": "0.0.9",
4
4
  "description": "Code generation API for Hono-DI",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/name.utils.ts","../src/utils/fs.utils.ts","../src/schematics/module.schematic.ts","../src/schematics/service.schematic.ts","../src/schematics/controller.schematic.ts","../src/schematics/class.schematic.ts","../src/schematics/interface.schematic.ts","../src/schematics/pipe.schematic.ts","../src/schematics/guard.schematic.ts","../src/schematics/filter.schematic.ts","../src/schematics/interceptor.schematic.ts","../src/schematics/decorator.schematic.ts","../src/utils/patch.utils.ts","../src/utils/path.utils.ts","../src/engine.ts"],"names":["fs","path"],"mappings":";;;;;;;;;;;;;AAAO,SAAS,YAAY,GAAA,EAAqB;AAC7C,EAAA,OAAO,GAAA,CACF,QAAQ,iBAAA,EAAmB,OAAO,EAClC,OAAA,CAAQ,SAAA,EAAW,GAAG,CAAA,CACtB,WAAA,EAAY;AACrB;AAEO,SAAS,aAAa,GAAA,EAAqB;AAC9C,EAAA,OAAO,GAAA,CACF,OAAA,CAAQ,qBAAA,EAAuB,CAAC,IAAA,KAAS,IAAA,CAAK,WAAA,EAAa,CAAA,CAC3D,OAAA,CAAQ,UAAA,EAAY,EAAE,CAAA;AAC/B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EAAM,UAAA;AAAA,YACN,OAAA,EAAS;AAAA,WACZ,CAAA;AAAA,QACL;AAAA,MACJ;AAAA,IACJ;AAAA,EAEJ,SAAS,KAAA,EAAY;AACjB,IAAA,MAAA,CAAO,OAAA,GAAU,KAAA;AACjB,IAAA,MAAA,CAAO,MAAA,EAAQ,IAAA,CAAK,KAAA,CAAM,OAAO,CAAA;AAAA,EACrC;AAEA,EAAA,OAAO,MAAA;AACX","file":"index.cjs","sourcesContent":["export function toKebabCase(str: string): string {\n return str\n .replace(/([a-z])([A-Z])/g, \"$1-$2\")\n .replace(/[\\s_]+/g, \"-\")\n .toLowerCase();\n}\n\nexport function toPascalCase(str: string): string {\n return str\n .replace(/(?:^\\w|[A-Z]|\\b\\w)/g, (word) => word.toUpperCase())\n .replace(/[\\s-_]+/g, \"\");\n}\n\nexport function toCamelCase(str: string): string {\n const pascal = toPascalCase(str);\n return pascal.charAt(0).toLowerCase() + pascal.slice(1);\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\n\nexport function ensureDirectoryExists(filePath: string) {\n const dirname = path.dirname(filePath);\n if (fs.existsSync(dirname)) {\n return true;\n }\n ensureDirectoryExists(dirname);\n fs.mkdirSync(dirname);\n}\n\nexport function writeFile(filePath: string, content: string) {\n ensureDirectoryExists(filePath);\n fs.writeFileSync(filePath, content, 'utf-8');\n}\n\nexport function fileExists(filePath: string): boolean {\n return fs.existsSync(filePath);\n}\n","import { toPascalCase } from '../utils/name.utils';\n\nexport function generateModule(name: string) {\n const pascalName = toPascalCase(name);\n return `import { Module } from '@hono-di/core';\n\n@Module({\n imports: [\n // hono-di:imports\n ],\n controllers: [\n // hono-di:controllers\n ],\n providers: [\n // hono-di:providers\n ],\n})\nexport class ${pascalName}Module {}\n`;\n}\n","import { toPascalCase } from '../utils/name.utils';\n\nexport function generateService(name: string) {\n const pascalName = toPascalCase(name);\n return `import { Injectable } from '@hono-di/core';\n\n@Injectable()\nexport class ${pascalName}Service {\n constructor() {}\n}\n`;\n}\n","import { toPascalCase } from '../utils/name.utils';\n\nexport function generateController(name: string) {\n const pascalName = toPascalCase(name);\n return `import { Controller, Get } from '@hono-di/core';\n\n@Controller('${name.toLowerCase()}')\nexport class ${pascalName}Controller {\n constructor() {}\n\n @Get('/')\n index() {\n return 'Hello ${pascalName}';\n }\n}\n`;\n}\n","import { toPascalCase } from '../utils/name.utils';\n\nexport function generateClass(name: string) {\n const pascalName = toPascalCase(name);\n return `export class ${pascalName} {}\n`;\n}\n","import { toPascalCase } from '../utils/name.utils';\n\nexport function generateInterface(name: string) {\n const pascalName = toPascalCase(name);\n return `export interface ${pascalName} {}\n`;\n}\n","import { toPascalCase } from '../utils/name.utils';\n\nexport function generatePipe(name: string) {\n return `import { PipeTransform, Injectable, ArgumentMetadata } from '@hono-di/core';\n\n@Injectable()\nexport class ${toPascalCase(name)}Pipe implements PipeTransform {\n transform(value: any, metadata: ArgumentMetadata) {\n return value;\n }\n}\n`;\n}\n","import { toPascalCase } from '../utils/name.utils';\n\nexport function generateGuard(name: string) {\n return `import { CanActivate, Injectable, ExecutionContext } from '@hono-di/core';\nimport { Observable } from 'rxjs';\n\n@Injectable()\nexport class ${toPascalCase(name)}Guard implements CanActivate {\n canActivate(\n context: ExecutionContext,\n ): boolean | Promise<boolean> | Observable<boolean> {\n return true;\n }\n}\n`;\n}\n","import { toPascalCase } from '../utils/name.utils';\n\nexport function generateFilter(name: string) {\n return `import { ArgumentsHost, Catch, ExceptionFilter } from '@hono-di/core';\n\n@Catch()\nexport class ${toPascalCase(name)}Filter<T> implements ExceptionFilter {\n catch(exception: T, host: ArgumentsHost) {}\n}\n`;\n}\n","import { toPascalCase } from '../utils/name.utils';\n\nexport function generateInterceptor(name: string) {\n return `import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@hono-di/core';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\n@Injectable()\nexport class ${toPascalCase(name)}Interceptor implements NestInterceptor {\n intercept(context: ExecutionContext, next: CallHandler): Observable<any> {\n return next.handle().pipe(map((data) => data));\n }\n}\n`;\n}\n","import { toCamelCase } from '../utils/name.utils';\n\nexport function generateDecorator(name: string) {\n // Camel case for decorator function\n return `import { SetMetadata } from '@hono-di/core';\n\nexport const ${toCamelCase(name)} = (...args: string[]) => SetMetadata('${toCamelCase(name)}', args);\n`;\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport { toPascalCase } from './name.utils';\nimport { normalizePath } from './path.utils';\n\nexport function findNearestModule(dir: string, rootDir: string = process.cwd()): string | null {\n let currentDir = dir;\n while (true) {\n if (fs.existsSync(currentDir)) {\n const files = fs.readdirSync(currentDir);\n const moduleFile = files.find((f) => f.endsWith('.module.ts'));\n if (moduleFile) {\n return path.join(currentDir, moduleFile);\n }\n }\n\n if (currentDir === rootDir || currentDir === path.parse(currentDir).root) {\n break;\n }\n currentDir = path.dirname(currentDir);\n }\n return null;\n}\n\nexport function patchModule(\n modulePath: string,\n className: string,\n importPath: string,\n type: 'controller' | 'provider' | 'import'\n): string | null {\n const content = fs.readFileSync(modulePath, 'utf-8');\n let newContent = content;\n\n // 1. Add Import\n const importLine = `import { ${className} } from '${importPath}';`;\n if (!content.includes(importLine)) {\n const lastImportMatches = content.match(/^import .*$/gm);\n if (lastImportMatches && lastImportMatches.length > 0) {\n const lastImport = lastImportMatches[lastImportMatches.length - 1];\n newContent = newContent.replace(lastImport, `${lastImport}\\n${importLine}`);\n } else {\n newContent = `${importLine}\\n${newContent}`;\n }\n }\n\n // 2. Add to Metadata\n const markerMap = {\n controller: '// hono-di:controllers',\n provider: '// hono-di:providers',\n import: '// hono-di:imports',\n };\n const marker = markerMap[type];\n\n if (content.includes(marker)) {\n newContent = newContent.replace(marker, `${className}, ${marker}`);\n return newContent;\n }\n\n return null; // Return null if no patch happened (no markers)\n}\n","import path from 'node:path';\n\nexport function normalizePath(p: string): string {\n return p.split(path.sep).join('/');\n}\n","import path from 'node:path';\nimport fs from 'node:fs';\nimport { GenerateInput, GenerateResult } from './types';\nimport { toKebabCase, toPascalCase } from './utils/name.utils';\nimport { ensureDirectoryExists, fileExists } from './utils/fs.utils';\nimport { generateModule } from './schematics/module.schematic';\nimport { generateService } from './schematics/service.schematic';\nimport { generateController } from './schematics/controller.schematic';\nimport { generateClass } from './schematics/class.schematic';\nimport { generateInterface } from './schematics/interface.schematic';\nimport { generatePipe } from './schematics/pipe.schematic';\nimport { generateGuard } from './schematics/guard.schematic';\nimport { generateFilter } from './schematics/filter.schematic';\nimport { generateInterceptor } from './schematics/interceptor.schematic';\nimport { generateDecorator } from './schematics/decorator.schematic';\nimport { findNearestModule, patchModule } from './utils/patch.utils';\nimport { normalizePath } from './utils/path.utils';\n\nexport function generate(input: GenerateInput): GenerateResult {\n const result: GenerateResult = {\n success: true,\n operations: [],\n errors: [],\n warnings: [],\n };\n\n try {\n const { type, name, path: inputPath = 'src', flat, force, dryRun, skipImport } = input;\n const kebabName = toKebabCase(name);\n const pascalName = toPascalCase(name);\n\n // Determine suffix and extension\n let suffix = '';\n let ext = '.ts';\n switch (type) {\n case 'module': suffix = '.module'; break;\n case 'controller': suffix = '.controller'; break;\n case 'service':\n case 'provider': suffix = '.service'; break; // Provider alias maps to service typically\n case 'class': suffix = ''; break;\n case 'interface': suffix = '.interface'; break;\n case 'pipe': suffix = '.pipe'; break;\n case 'guard': suffix = '.guard'; break;\n case 'filter': suffix = '.filter'; break;\n case 'interceptor': suffix = '.interceptor'; break;\n case 'decorator': suffix = '.decorator'; break;\n }\n\n // Determine target directory and file name\n const fileName = `${kebabName}${suffix}${ext}`;\n let targetDir = path.join(process.cwd(), inputPath);\n\n if (!flat) {\n targetDir = path.join(targetDir, kebabName);\n }\n\n const filePath = path.join(targetDir, fileName);\n\n // Check existence\n if (fileExists(filePath) && !force) {\n result.success = false;\n result.errors?.push(`File ${filePath} already exists.`);\n result.operations.push({ action: 'error', path: filePath });\n return result;\n }\n\n // Generate content\n let content = '';\n switch (type) {\n case 'module': content = generateModule(name); break;\n case 'controller': content = generateController(name); break;\n case 'service':\n case 'provider': content = generateService(name); break;\n case 'class': content = generateClass(name); break;\n case 'interface': content = generateInterface(name); break;\n case 'pipe': content = generatePipe(name); break;\n case 'guard': content = generateGuard(name); break;\n case 'filter': content = generateFilter(name); break;\n case 'interceptor': content = generateInterceptor(name); break;\n case 'decorator': content = generateDecorator(name); break;\n }\n\n // Add operation\n result.operations.push({\n action: fileExists(filePath) ? 'overwrite' : 'create',\n path: filePath,\n content: content\n });\n\n if (input.spec !== false) { // Default true\n const specName = `${kebabName}${suffix}.spec${ext}`;\n const specPath = path.join(targetDir, specName);\n if (!fileExists(specPath) || force) {\n result.operations.push({\n action: fileExists(specPath) ? 'overwrite' : 'create',\n path: specPath,\n content: `// Tests for ${name}`\n });\n }\n }\n\n // Auto-import logic\n if (!skipImport && type !== 'module' && type !== 'class' && type !== 'interface' && type !== 'decorator') {\n const modulePath = findNearestModule(targetDir);\n if (modulePath) {\n // Calculate relative path for import\n const moduleDir = path.dirname(modulePath);\n let relativePath = path.relative(moduleDir, filePath);\n // Remove extension for import\n relativePath = relativePath.replace(/\\.ts$/, '');\n if (!relativePath.startsWith('.')) {\n relativePath = `./${relativePath}`;\n }\n relativePath = normalizePath(relativePath);\n\n let importType: 'controller' | 'provider' | 'import' = 'provider';\n if (type === 'controller') importType = 'controller';\n\n // TODO: Handle module imports into other modules if newly generated is a module\n\n const patchedContent = patchModule(modulePath, `${pascalName}${toPascalCase(type === 'provider' ? 'Service' : type)}`, relativePath, importType);\n\n if (patchedContent) {\n result.operations.push({\n action: 'overwrite',\n path: modulePath,\n content: patchedContent\n });\n }\n }\n }\n\n } catch (error: any) {\n result.success = false;\n result.errors?.push(error.message);\n }\n\n return result;\n}\n"]}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/name.utils.ts","../src/utils/fs.utils.ts","../src/schematics/module.schematic.ts","../src/schematics/service.schematic.ts","../src/schematics/controller.schematic.ts","../src/schematics/class.schematic.ts","../src/schematics/interface.schematic.ts","../src/schematics/pipe.schematic.ts","../src/schematics/guard.schematic.ts","../src/schematics/filter.schematic.ts","../src/schematics/interceptor.schematic.ts","../src/schematics/decorator.schematic.ts","../src/utils/patch.utils.ts","../src/utils/path.utils.ts","../src/engine.ts"],"names":["fs","path"],"mappings":";;;;;;AAAO,SAAS,YAAY,GAAA,EAAqB;AAC7C,EAAA,OAAO,GAAA,CACF,QAAQ,iBAAA,EAAmB,OAAO,EAClC,OAAA,CAAQ,SAAA,EAAW,GAAG,CAAA,CACtB,WAAA,EAAY;AACrB;AAEO,SAAS,aAAa,GAAA,EAAqB;AAC9C,EAAA,OAAO,GAAA,CACF,OAAA,CAAQ,qBAAA,EAAuB,CAAC,IAAA,KAAS,IAAA,CAAK,WAAA,EAAa,CAAA,CAC3D,OAAA,CAAQ,UAAA,EAAY,EAAE,CAAA;AAC/B;AAEO,SAAS,YAAY,GAAA,EAAqB;AAC7C,EAAA,MAAM,MAAA,GAAS,aAAa,GAAG,CAAA;AAC/B,EAAA,OAAO,MAAA,CAAO,OAAO,CAAC,CAAA,CAAE,aAAY,GAAI,MAAA,CAAO,MAAM,CAAC,CAAA;AAC1D;ACCO,SAAS,WAAW,QAAA,EAA2B;AAClD,EAAA,OAAOA,GAAA,CAAG,WAAW,QAAQ,CAAA;AACjC;;;ACjBO,SAAS,eAAe,IAAA,EAAc;AACzC,EAAA,MAAM,UAAA,GAAa,aAAa,IAAI,CAAA;AACpC,EAAA,OAAO,CAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAAA,EAaI,UAAU,CAAA;AAAA,CAAA;AAEzB;;;ACjBO,SAAS,gBAAgB,IAAA,EAAc;AAC1C,EAAA,MAAM,UAAA,GAAa,aAAa,IAAI,CAAA;AACpC,EAAA,OAAO,CAAA;;AAAA;AAAA,aAAA,EAGI,UAAU,CAAA;AAAA;AAAA;AAAA,CAAA;AAIzB;;;ACTO,SAAS,mBA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AW,GAAG,CAAA,EAAG;AAC/B,UAAA,YAAA,GAAe,KAAK,YAAY,CAAA,CAAA;AAAA,QACpC;AACA,QAAA,YAAA,GAAe,cAAc,YAAY,CAAA;AAEzC,QAAA,IAAI,UAAA,GAAmD,UAAA;AACvD,QAAA,IAAI,IAAA,KAAS,cAAc,UAAA,GAAa,YAAA;AAIxC,QAAA,MAAM,cAAA,GAAiB,WAAA,CAAY,UAAA,EAAY,CAAA,EAAG,UAAU,CAAA,EAAG,YAAA,CAAa,IAAA,KAAS,UAAA,GAAa,SAAA,GAAY,IAAI,CAAC,CAAA,CAAA,EAAI,cAAc,UAAU,CAAA;AAE/I,QAAA,IAAI,cAAA,EAAgB;AAChB,UAAA,MAAA,CAAO,WAAW,IAAA,CAAK;AAAA,YACnB,MAAA,EAAQ,WAAA;AAAA,YACR,IAAA,EAAM,UAAA;AAAA,YACN,OAAA,EAAS;AAAA,WACZ,CAAA;AAAA,QACL;AAAA,MACJ;AAAA,IACJ;AAAA,EAEJ,SAAS,KAAA,EAAY;AACjB,IAAA,MAAA,CAAO,OAAA,GAAU,KAAA;AACjB,IAAA,MAAA,CAAO,MAAA,EAAQ,IAAA,CAAK,KAAA,CAAM,OAAO,CAAA;AAAA,EACrC;AAEA,EAAA,OAAO,MAAA;AACX","file":"index.js","sourcesContent":["export function toKebabCase(str: string): string {\n return str\n .replace(/([a-z])([A-Z])/g, \"$1-$2\")\n .replace(/[\\s_]+/g, \"-\")\n .toLowerCase();\n}\n\nexport function toPascalCase(str: string): string {\n return str\n .replace(/(?:^\\w|[A-Z]|\\b\\w)/g, (word) => word.toUpperCase())\n .replace(/[\\s-_]+/g, \"\");\n}\n\nexport function toCamelCase(str: string): string {\n const pascal = toPascalCase(str);\n return pascal.charAt(0).toLowerCase() + pascal.slice(1);\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\n\nexport function ensureDirectoryExists(filePath: string) {\n const dirname = path.dirname(filePath);\n if (fs.existsSync(dirname)) {\n return true;\n }\n ensureDirectoryExists(dirname);\n fs.mkdirSync(dirname);\n}\n\nexport function writeFile(filePath: string, content: string) {\n ensureDirectoryExists(filePath);\n fs.writeFileSync(filePath, content, 'utf-8');\n}\n\nexport function fileExists(filePath: string): boolean {\n return fs.existsSync(filePath);\n}\n","import { toPascalCase } from '../utils/name.utils';\n\nexport function generateModule(name: string) {\n const pascalName = toPascalCase(name);\n return `import { Module } from '@hono-di/core';\n\n@Module({\n imports: [\n // hono-di:imports\n ],\n controllers: [\n // hono-di:controllers\n ],\n providers: [\n // hono-di:providers\n ],\n})\nexport class ${pascalName}Module {}\n`;\n}\n","import { toPascalCase } from '../utils/name.utils';\n\nexport function generateService(name: string) {\n const pascalName = toPascalCase(name);\n return `import { Injectable } from '@hono-di/core';\n\n@Injectable()\nexport class ${pascalName}Service {\n constructor() {}\n}\n`;\n}\n","import { toPascalCase } from '../utils/name.utils';\n\nexport function generateController(name: string) {\n const pascalName = toPascalCase(name);\n return `import { Controller, Get } from '@hono-di/core';\n\n@Controller('${name.toLowerCase()}')\nexport class ${pascalName}Controller {\n constructor() {}\n\n @Get('/')\n index() {\n return 'Hello ${pascalName}';\n }\n}\n`;\n}\n","import { toPascalCase } from '../utils/name.utils';\n\nexport function generateClass(name: string) {\n const pascalName = toPascalCase(name);\n return `export class ${pascalName} {}\n`;\n}\n","import { toPascalCase } from '../utils/name.utils';\n\nexport function generateInterface(name: string) {\n const pascalName = toPascalCase(name);\n return `export interface ${pascalName} {}\n`;\n}\n","import { toPascalCase } from '../utils/name.utils';\n\nexport function generatePipe(name: string) {\n return `import { PipeTransform, Injectable, ArgumentMetadata } from '@hono-di/core';\n\n@Injectable()\nexport class ${toPascalCase(name)}Pipe implements PipeTransform {\n transform(value: any, metadata: ArgumentMetadata) {\n return value;\n }\n}\n`;\n}\n","import { toPascalCase } from '../utils/name.utils';\n\nexport function generateGuard(name: string) {\n return `import { CanActivate, Injectable, ExecutionContext } from '@hono-di/core';\nimport { Observable } from 'rxjs';\n\n@Injectable()\nexport class ${toPascalCase(name)}Guard implements CanActivate {\n canActivate(\n context: ExecutionContext,\n ): boolean | Promise<boolean> | Observable<boolean> {\n return true;\n }\n}\n`;\n}\n","import { toPascalCase } from '../utils/name.utils';\n\nexport function generateFilter(name: string) {\n return `import { ArgumentsHost, Catch, ExceptionFilter } from '@hono-di/core';\n\n@Catch()\nexport class ${toPascalCase(name)}Filter<T> implements ExceptionFilter {\n catch(exception: T, host: ArgumentsHost) {}\n}\n`;\n}\n","import { toPascalCase } from '../utils/name.utils';\n\nexport function generateInterceptor(name: string) {\n return `import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@hono-di/core';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\n@Injectable()\nexport class ${toPascalCase(name)}Interceptor implements NestInterceptor {\n intercept(context: ExecutionContext, next: CallHandler): Observable<any> {\n return next.handle().pipe(map((data) => data));\n }\n}\n`;\n}\n","import { toCamelCase } from '../utils/name.utils';\n\nexport function generateDecorator(name: string) {\n // Camel case for decorator function\n return `import { SetMetadata } from '@hono-di/core';\n\nexport const ${toCamelCase(name)} = (...args: string[]) => SetMetadata('${toCamelCase(name)}', args);\n`;\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport { toPascalCase } from './name.utils';\nimport { normalizePath } from './path.utils';\n\nexport function findNearestModule(dir: string, rootDir: string = process.cwd()): string | null {\n let currentDir = dir;\n while (true) {\n if (fs.existsSync(currentDir)) {\n const files = fs.readdirSync(currentDir);\n const moduleFile = files.find((f) => f.endsWith('.module.ts'));\n if (moduleFile) {\n return path.join(currentDir, moduleFile);\n }\n }\n\n if (currentDir === rootDir || currentDir === path.parse(currentDir).root) {\n break;\n }\n currentDir = path.dirname(currentDir);\n }\n return null;\n}\n\nexport function patchModule(\n modulePath: string,\n className: string,\n importPath: string,\n type: 'controller' | 'provider' | 'import'\n): string | null {\n const content = fs.readFileSync(modulePath, 'utf-8');\n let newContent = content;\n\n // 1. Add Import\n const importLine = `import { ${className} } from '${importPath}';`;\n if (!content.includes(importLine)) {\n const lastImportMatches = content.match(/^import .*$/gm);\n if (lastImportMatches && lastImportMatches.length > 0) {\n const lastImport = lastImportMatches[lastImportMatches.length - 1];\n newContent = newContent.replace(lastImport, `${lastImport}\\n${importLine}`);\n } else {\n newContent = `${importLine}\\n${newContent}`;\n }\n }\n\n // 2. Add to Metadata\n const markerMap = {\n controller: '// hono-di:controllers',\n provider: '// hono-di:providers',\n import: '// hono-di:imports',\n };\n const marker = markerMap[type];\n\n if (content.includes(marker)) {\n newContent = newContent.replace(marker, `${className}, ${marker}`);\n return newContent;\n }\n\n return null; // Return null if no patch happened (no markers)\n}\n","import path from 'node:path';\n\nexport function normalizePath(p: string): string {\n return p.split(path.sep).join('/');\n}\n","import path from 'node:path';\nimport fs from 'node:fs';\nimport { GenerateInput, GenerateResult } from './types';\nimport { toKebabCase, toPascalCase } from './utils/name.utils';\nimport { ensureDirectoryExists, fileExists } from './utils/fs.utils';\nimport { generateModule } from './schematics/module.schematic';\nimport { generateService } from './schematics/service.schematic';\nimport { generateController } from './schematics/controller.schematic';\nimport { generateClass } from './schematics/class.schematic';\nimport { generateInterface } from './schematics/interface.schematic';\nimport { generatePipe } from './schematics/pipe.schematic';\nimport { generateGuard } from './schematics/guard.schematic';\nimport { generateFilter } from './schematics/filter.schematic';\nimport { generateInterceptor } from './schematics/interceptor.schematic';\nimport { generateDecorator } from './schematics/decorator.schematic';\nimport { findNearestModule, patchModule } from './utils/patch.utils';\nimport { normalizePath } from './utils/path.utils';\n\nexport function generate(input: GenerateInput): GenerateResult {\n const result: GenerateResult = {\n success: true,\n operations: [],\n errors: [],\n warnings: [],\n };\n\n try {\n const { type, name, path: inputPath = 'src', flat, force, dryRun, skipImport } = input;\n const kebabName = toKebabCase(name);\n const pascalName = toPascalCase(name);\n\n // Determine suffix and extension\n let suffix = '';\n let ext = '.ts';\n switch (type) {\n case 'module': suffix = '.module'; break;\n case 'controller': suffix = '.controller'; break;\n case 'service':\n case 'provider': suffix = '.service'; break; // Provider alias maps to service typically\n case 'class': suffix = ''; break;\n case 'interface': suffix = '.interface'; break;\n case 'pipe': suffix = '.pipe'; break;\n case 'guard': suffix = '.guard'; break;\n case 'filter': suffix = '.filter'; break;\n case 'interceptor': suffix = '.interceptor'; break;\n case 'decorator': suffix = '.decorator'; break;\n }\n\n // Determine target directory and file name\n const fileName = `${kebabName}${suffix}${ext}`;\n let targetDir = path.join(process.cwd(), inputPath);\n\n if (!flat) {\n targetDir = path.join(targetDir, kebabName);\n }\n\n const filePath = path.join(targetDir, fileName);\n\n // Check existence\n if (fileExists(filePath) && !force) {\n result.success = false;\n result.errors?.push(`File ${filePath} already exists.`);\n result.operations.push({ action: 'error', path: filePath });\n return result;\n }\n\n // Generate content\n let content = '';\n switch (type) {\n case 'module': content = generateModule(name); break;\n case 'controller': content = generateController(name); break;\n case 'service':\n case 'provider': content = generateService(name); break;\n case 'class': content = generateClass(name); break;\n case 'interface': content = generateInterface(name); break;\n case 'pipe': content = generatePipe(name); break;\n case 'guard': content = generateGuard(name); break;\n case 'filter': content = generateFilter(name); break;\n case 'interceptor': content = generateInterceptor(name); break;\n case 'decorator': content = generateDecorator(name); break;\n }\n\n // Add operation\n result.operations.push({\n action: fileExists(filePath) ? 'overwrite' : 'create',\n path: filePath,\n content: content\n });\n\n if (input.spec !== false) { // Default true\n const specName = `${kebabName}${suffix}.spec${ext}`;\n const specPath = path.join(targetDir, specName);\n if (!fileExists(specPath) || force) {\n result.operations.push({\n action: fileExists(specPath) ? 'overwrite' : 'create',\n path: specPath,\n content: `// Tests for ${name}`\n });\n }\n }\n\n // Auto-import logic\n if (!skipImport && type !== 'module' && type !== 'class' && type !== 'interface' && type !== 'decorator') {\n const modulePath = findNearestModule(targetDir);\n if (modulePath) {\n // Calculate relative path for import\n const moduleDir = path.dirname(modulePath);\n let relativePath = path.relative(moduleDir, filePath);\n // Remove extension for import\n relativePath = relativePath.replace(/\\.ts$/, '');\n if (!relativePath.startsWith('.')) {\n relativePath = `./${relativePath}`;\n }\n relativePath = normalizePath(relativePath);\n\n let importType: 'controller' | 'provider' | 'import' = 'provider';\n if (type === 'controller') importType = 'controller';\n\n // TODO: Handle module imports into other modules if newly generated is a module\n\n const patchedContent = patchModule(modulePath, `${pascalName}${toPascalCase(type === 'provider' ? 'Service' : type)}`, relativePath, importType);\n\n if (patchedContent) {\n result.operations.push({\n action: 'overwrite',\n path: modulePath,\n content: patchedContent\n });\n }\n }\n }\n\n } catch (error: any) {\n result.success = false;\n result.errors?.push(error.message);\n }\n\n return result;\n}\n"]}