@tiveor/scg 0.1.6 → 0.5.0

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.
Files changed (52) hide show
  1. package/README.md +303 -49
  2. package/dist/chunk-XKYTW4HW.js +589 -0
  3. package/dist/chunk-XKYTW4HW.js.map +1 -0
  4. package/dist/cli.cjs +779 -0
  5. package/dist/cli.cjs.map +1 -0
  6. package/dist/cli.d.cts +1 -0
  7. package/dist/cli.d.ts +1 -0
  8. package/dist/cli.js +173 -0
  9. package/dist/cli.js.map +1 -0
  10. package/dist/index.cjs +991 -0
  11. package/dist/index.cjs.map +1 -0
  12. package/dist/index.d.cts +653 -0
  13. package/dist/index.d.ts +653 -0
  14. package/dist/index.js +373 -0
  15. package/dist/index.js.map +1 -0
  16. package/package.json +63 -6
  17. package/templates/express-route/controller.ejs +35 -0
  18. package/templates/express-route/routes.ejs +10 -0
  19. package/templates/express-route/scaffold.json +13 -0
  20. package/templates/express-route/service.ejs +16 -0
  21. package/templates/github-action/scaffold.json +12 -0
  22. package/templates/github-action/workflow.ejs +33 -0
  23. package/templates/react-component/component.ejs +25 -0
  24. package/templates/react-component/index.ejs +2 -0
  25. package/templates/react-component/scaffold.json +15 -0
  26. package/templates/react-component/styles.ejs +4 -0
  27. package/templates/react-component/test.ejs +14 -0
  28. package/templates/vue-component/component.ejs +19 -0
  29. package/templates/vue-component/scaffold.json +12 -0
  30. package/templates/vue-component/test.ejs +16 -0
  31. package/.prettierignore +0 -1
  32. package/.prettierrc +0 -13
  33. package/.travis.yml +0 -9
  34. package/.vscode/settings.json +0 -5
  35. package/example/ejs/conditional.ejs +0 -9
  36. package/example/ejs/hello.ejs +0 -8
  37. package/example/handlebars/conditional.handlebars +0 -9
  38. package/example/handlebars/hello.handlebars +0 -6
  39. package/example/index.js +0 -180
  40. package/example/pug/conditional.pug +0 -4
  41. package/example/pug/hello.pug +0 -3
  42. package/index.js +0 -15
  43. package/src/command_helper.js +0 -42
  44. package/src/ejs_helper.js +0 -30
  45. package/src/file_helper.js +0 -142
  46. package/src/handlebars_helper.js +0 -32
  47. package/src/param_helper.js +0 -25
  48. package/src/pug_helper.js +0 -28
  49. package/src/string_helper.js +0 -12
  50. package/src/template_builder.js +0 -38
  51. package/src/template_handlers.js +0 -7
  52. package/test/test.js +0 -11
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/string_helper.ts","../src/file_helper.ts","../src/command_helper.ts","../src/param_helper.ts","../src/handlebars_helper.ts","../src/ejs_helper.ts","../src/pug_helper.ts","../src/template_handlers.ts","../src/template_builder.ts","../src/pipeline.ts","../src/scaffold.ts","../src/watcher.ts"],"sourcesContent":["/**\n * SCG - Simple Code Generator\n *\n * A utility library for code generation and template processing in Node.js.\n * Provides helpers for template rendering (EJS, Handlebars, Pug), string manipulation,\n * file operations, command execution, CLI parameter parsing, a scaffold engine,\n * a template pipeline, and a file watcher.\n *\n * @packageDocumentation\n */\n\nexport { StringHelper } from './string_helper.js';\nexport { FileHelper } from './file_helper.js';\nexport type { Replacement, CreateFileOptions, CreateStringOptions } from './file_helper.js';\nexport { CommandHelper } from './command_helper.js';\nexport { ParamHelper } from './param_helper.js';\nexport { TemplateBuilder } from './template_builder.js';\nexport type { TemplateEngine } from './template_builder.js';\nexport { TEMPLATE_HANDLERS } from './template_handlers.js';\nexport type { TemplateHandler } from './template_handlers.js';\nexport { Pipeline } from './pipeline.js';\nexport type { TransformFn } from './pipeline.js';\nexport { Scaffold } from './scaffold.js';\nexport type { ScaffoldFile, ScaffoldOptions, ScaffoldResult } from './scaffold.js';\nexport { Watcher } from './watcher.js';\nexport type { WatcherOptions } from './watcher.js';\n","/**\n * Utility class for common string manipulation operations.\n *\n * @example\n * ```typescript\n * StringHelper.replace('Hello {{name}}!', '{{name}}', 'World');\n * // => \"Hello World!\"\n *\n * StringHelper.capitalize('hello');\n * // => \"Hello\"\n * ```\n */\nexport class StringHelper {\n /**\n * Escapes all regex special characters in a string.\n *\n * @param string - The string to escape\n * @returns The escaped string safe for use in `new RegExp()`\n *\n * @example\n * ```typescript\n * StringHelper.escapeRegex('$100.00 (test)');\n * // => \"\\\\$100\\\\.00 \\\\(test\\\\)\"\n * ```\n */\n static escapeRegex(string: string): string {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n }\n\n /**\n * Replaces all occurrences of a token in a string. The token is treated\n * as a literal string (regex special characters are escaped automatically).\n *\n * @param line - The source string to search in. Returns `''` if not a string.\n * @param token - The token to search for. Returns `line` unchanged if not a string.\n * @param value - The replacement value\n * @returns The string with all occurrences replaced\n *\n * @example\n * ```typescript\n * StringHelper.replace('Price: $10.00', '$10.00', '$20.00');\n * // => \"Price: $20.00\"\n * ```\n */\n static replace(line: unknown, token: unknown, value: string): string {\n if (typeof line !== 'string') return '';\n if (typeof token !== 'string') return line;\n return line.replace(\n new RegExp(StringHelper.escapeRegex(token), 'g'),\n value\n );\n }\n\n /**\n * Capitalizes the first character of a string.\n *\n * @param s - The string to capitalize. Returns `''` if not a string.\n * @returns The string with the first character uppercased\n *\n * @example\n * ```typescript\n * StringHelper.capitalize('hello world');\n * // => \"Hello world\"\n * ```\n */\n static capitalize(s: unknown): string {\n if (typeof s !== 'string') return '';\n return s.charAt(0).toUpperCase() + s.slice(1);\n }\n}\n","import fs from 'fs';\nimport path from 'path';\nimport readline from 'readline';\nimport { StringHelper } from './string_helper.js';\n\n/** Defines a single token replacement with optional template-based dynamic replacement. */\nexport interface Replacement {\n /** The token string to search for in the template (e.g., `'{{name}}'`). */\n token: string;\n /** The static value to replace the token with. */\n value?: string;\n /** Path to a sub-template for dynamic replacement. */\n template?: string;\n /** Variables for dynamic replacement keyed by identifier. */\n variables?: Record<string, Replacement[]>;\n}\n\n/** Options for creating a file from a template with variable replacements. */\nexport interface CreateFileOptions {\n /** Path to the template file. */\n template: string;\n /** Path for the output file. */\n newFile: string;\n /** Array of token replacements to apply. */\n variables: Replacement[];\n}\n\n/** Options for creating a string from a template with variable replacements. */\nexport interface CreateStringOptions {\n /** Path to the template file. */\n template: string;\n /** Array of token replacements to apply. */\n variables: Replacement[];\n}\n\n/**\n * Utility class for file system operations, both synchronous and asynchronous.\n *\n * Provides methods for reading, writing, creating, and removing files and directories,\n * as well as template-based file generation with variable replacement.\n *\n * @example\n * ```typescript\n * // Sync\n * const content = FileHelper.readFileToString('config.txt');\n * const config = FileHelper.convertJsonFileToObject('config.json');\n *\n * // Async\n * const data = await FileHelper.readFileAsync('config.txt');\n * await FileHelper.writeFileAsync('output.txt', 'content');\n * ```\n */\nexport class FileHelper {\n // --- Sync methods ---\n\n /**\n * Reads a file synchronously and returns its content as a UTF-8 string.\n *\n * @param fileName - Path to the file to read\n * @returns The file content as a string\n */\n static readFileToString(fileName: string): string {\n return fs.readFileSync(fileName, 'utf8');\n }\n\n /**\n * Reads a JSON file synchronously and parses it into an object.\n *\n * @typeParam T - The expected type of the parsed object\n * @param fileName - Path to the JSON file\n * @returns The parsed object\n */\n static convertJsonFileToObject<T = unknown>(fileName: string): T {\n const rawString = FileHelper.readFileToString(fileName);\n return JSON.parse(rawString) as T;\n }\n\n /**\n * Creates a directory (and any parent directories) if it doesn't exist.\n *\n * @param folderName - Path to the directory to create\n */\n static createFolder(folderName: string): void {\n const resolved = path.resolve(folderName);\n if (!fs.existsSync(resolved)) {\n fs.mkdirSync(resolved, { recursive: true });\n }\n }\n\n /**\n * Removes a directory and all its contents recursively.\n *\n * @param folderName - Path to the directory to remove\n */\n static removeFolder(folderName: string): void {\n const resolved = path.resolve(folderName);\n if (fs.existsSync(resolved)) {\n fs.rmSync(resolved, { recursive: true, force: true });\n }\n }\n\n /**\n * Removes a file if it exists.\n *\n * @param filename - Path to the file to remove\n */\n static removeFile(filename: string): void {\n const resolved = path.resolve(filename);\n if (fs.existsSync(resolved)) {\n fs.rmSync(resolved, { force: true });\n }\n }\n\n // --- Async methods ---\n\n /**\n * Reads a file asynchronously and returns its content as a UTF-8 string.\n *\n * @param fileName - Path to the file to read\n * @returns A promise resolving to the file content\n */\n static async readFileAsync(fileName: string): Promise<string> {\n return fs.promises.readFile(fileName, 'utf8');\n }\n\n /**\n * Reads a JSON file asynchronously and parses it into an object.\n *\n * @typeParam T - The expected type of the parsed object\n * @param fileName - Path to the JSON file\n * @returns A promise resolving to the parsed object\n */\n static async readJsonFileAsync<T = unknown>(fileName: string): Promise<T> {\n const raw = await fs.promises.readFile(fileName, 'utf8');\n return JSON.parse(raw) as T;\n }\n\n /**\n * Writes content to a file asynchronously, creating parent directories as needed.\n *\n * @param fileName - Path to the file to write\n * @param content - The string content to write\n */\n static async writeFileAsync(\n fileName: string,\n content: string\n ): Promise<void> {\n const dir = path.dirname(fileName);\n await fs.promises.mkdir(dir, { recursive: true });\n await fs.promises.writeFile(fileName, content, 'utf8');\n }\n\n /**\n * Creates a directory asynchronously (with recursive parent creation).\n *\n * @param folderName - Path to the directory to create\n */\n static async createFolderAsync(folderName: string): Promise<void> {\n const resolved = path.resolve(folderName);\n await fs.promises.mkdir(resolved, { recursive: true });\n }\n\n /**\n * Removes a directory and its contents recursively (async).\n *\n * @param folderName - Path to the directory to remove\n */\n static async removeFolderAsync(folderName: string): Promise<void> {\n const resolved = path.resolve(folderName);\n await fs.promises.rm(resolved, { recursive: true, force: true });\n }\n\n /**\n * Removes a file asynchronously.\n *\n * @param filename - Path to the file to remove\n */\n static async removeFileAsync(filename: string): Promise<void> {\n const resolved = path.resolve(filename);\n await fs.promises.rm(resolved, { force: true });\n }\n\n /**\n * Checks whether a file or directory exists asynchronously.\n *\n * @param filePath - Path to check\n * @returns `true` if the path exists, `false` otherwise\n */\n static async existsAsync(filePath: string): Promise<boolean> {\n try {\n await fs.promises.access(filePath);\n return true;\n } catch {\n return false;\n }\n }\n\n // --- Template processing methods ---\n\n /**\n * Performs a simple token replacement on a single line.\n *\n * @param line - The source line\n * @param replacement - The replacement definition (uses `token` and `value`)\n * @returns The line with the token replaced\n */\n static simpleReplace(line: string, replacement: Replacement): string {\n return StringHelper.replace(line, replacement.token, replacement.value!);\n }\n\n /**\n * Performs dynamic replacement using a sub-template and variables.\n * Reads the sub-template line by line and applies all variable replacements.\n *\n * @param replacement - The replacement definition with `template` and `variables`\n * @returns A promise resolving to the processed string\n */\n static async dynamicReplace(replacement: Replacement): Promise<string> {\n let res = '';\n for (const v in replacement.variables) {\n const properties = replacement.variables[v];\n await FileHelper.readLineByLine(\n replacement.template!,\n (line: string) => {\n let newLine = line;\n for (const x in properties) {\n const property = properties[x];\n if (line.indexOf(property.token) >= 0) {\n if (property.value) {\n newLine = FileHelper.simpleReplace(newLine, property);\n }\n }\n }\n res += newLine;\n }\n );\n }\n return res;\n }\n\n /**\n * Creates a new file from a template file, applying variable replacements line by line.\n * The special token `@date` is automatically replaced with the current UTC date.\n *\n * @param options - The template path, output path, and variables to apply\n *\n * @example\n * ```typescript\n * await FileHelper.createFileFromFile({\n * template: 'templates/component.txt',\n * newFile: 'output/Button.tsx',\n * variables: [\n * { token: '{{name}}', value: 'Button' },\n * { token: '{{style}}', value: 'primary' }\n * ]\n * });\n * ```\n */\n static async createFileFromFile({\n template,\n newFile,\n variables\n }: CreateFileOptions): Promise<void> {\n const writer = FileHelper.writer(newFile);\n\n await FileHelper.readLineByLine(template, async (line: string) => {\n let newLine = StringHelper.replace(\n line,\n '@date',\n new Date().toUTCString()\n );\n\n for (const v in variables) {\n const replacement = variables[v];\n\n if (newLine.indexOf(replacement.token) > 0) {\n if (replacement.template) {\n newLine = await FileHelper.dynamicReplace(replacement);\n break;\n } else if (replacement.value) {\n newLine = FileHelper.simpleReplace(newLine, replacement);\n }\n }\n }\n\n await FileHelper.writeLineByLine(writer, newLine);\n });\n writer.end();\n }\n\n /**\n * Creates a string from a template file, applying variable replacements line by line.\n * The special token `@date` is automatically replaced with the current UTC date.\n *\n * @param options - The template path and variables to apply\n * @returns A promise resolving to the processed string\n */\n static async createStringFromFile({\n template,\n variables\n }: CreateStringOptions): Promise<string> {\n let res = '';\n\n await FileHelper.readLineByLine(template, async (line: string) => {\n let newLine = StringHelper.replace(\n line,\n '@date',\n new Date().toUTCString()\n );\n\n for (const v in variables) {\n const replacement = variables[v];\n\n if (newLine.indexOf(replacement.token) > 0) {\n if (replacement.template) {\n newLine = await FileHelper.dynamicReplace(replacement);\n break;\n } else if (replacement.value) {\n newLine = FileHelper.simpleReplace(newLine, replacement);\n }\n }\n }\n res += newLine + '\\n';\n });\n return res;\n }\n\n /**\n * Reads a file line by line and invokes a callback for each line.\n *\n * @param fileName - Path to the file to read\n * @param callback - Function called for each line\n */\n static async readLineByLine(\n fileName: string,\n callback: (line: string) => void | Promise<void>\n ): Promise<void> {\n const fileStream = fs.createReadStream(fileName);\n\n const rl = readline.createInterface({\n input: fileStream,\n crlfDelay: Infinity\n });\n\n for await (const line of rl) {\n await callback(line);\n }\n }\n\n /**\n * Creates a writable stream for appending to a file.\n *\n * @param filename - Path to the file\n * @returns A writable stream in append mode\n */\n static writer(filename: string): fs.WriteStream {\n return fs.createWriteStream(filename, {\n flags: 'a'\n });\n }\n\n /**\n * Writes a single line to a writable stream with CRLF line ending.\n *\n * @param writer - The writable stream\n * @param newLine - The line content to write\n */\n static async writeLineByLine(\n writer: fs.WriteStream,\n newLine: string\n ): Promise<void> {\n writer.write(`${newLine}\\r\\n`);\n }\n}\n","import { exec } from 'child_process';\n\n/** @internal Patterns that indicate potentially unsafe shell commands. */\nconst FORBIDDEN_PATTERNS = [\n /[;&|`$]/, // shell metacharacters\n /\\$\\(/, // command substitution\n />\\s*\\//, // redirect to absolute path\n /\\.\\.\\// // path traversal\n];\n\n/**\n * Utility class for executing shell commands as promises with input sanitization.\n *\n * Commands are validated against a set of forbidden patterns (shell metacharacters,\n * command substitution, path traversal) before execution.\n *\n * @example\n * ```typescript\n * const output = await CommandHelper.run('.', 'echo hello');\n * const version = await CommandHelper.runClean('.', 'node --version');\n * ```\n */\nexport class CommandHelper {\n /**\n * Executes one or more shell commands in the given directory.\n * Multiple commands are joined with `&&` (sequential execution).\n *\n * @param directory - Working directory for command execution\n * @param command - One or more command strings to execute\n * @returns A promise resolving to the command's stdout (or stderr if stdout is empty)\n * @throws If the directory is empty, no commands are provided, or a command matches a forbidden pattern\n *\n * @example\n * ```typescript\n * const output = await CommandHelper.run('.', 'echo hello');\n * // => \"hello\\n\"\n *\n * const result = await CommandHelper.run('.', 'git add .', 'git status');\n * ```\n */\n static run(directory: string, ...command: string[]): Promise<string> {\n if (!directory) {\n return Promise.reject(new Error('directory is required'));\n }\n if (command.length === 0) {\n return Promise.reject(new Error('at least one command is required'));\n }\n\n for (const cmd of command) {\n for (const pattern of FORBIDDEN_PATTERNS) {\n if (pattern.test(cmd)) {\n return Promise.reject(\n new Error(\n `potentially unsafe command rejected: \"${cmd}\" matches forbidden pattern ${pattern}`\n )\n );\n }\n }\n }\n\n return new Promise((resolve, reject) => {\n const cmd = command.join(' && ');\n exec(\n cmd,\n { cwd: directory, maxBuffer: 1024 * 1024 * 100 },\n (err, stdout, stderr) => {\n if (err) {\n reject(err);\n return;\n }\n\n if (stderr) {\n resolve(stderr);\n return;\n }\n\n resolve(stdout);\n }\n );\n });\n }\n\n /**\n * Executes commands and returns the output with newlines stripped.\n *\n * @param folder - Working directory for command execution\n * @param command - One or more command strings to execute\n * @returns A promise resolving to the cleaned output (no newlines)\n *\n * @example\n * ```typescript\n * const version = await CommandHelper.runClean('.', 'node --version');\n * // => \"v20.10.0\"\n * ```\n */\n static runClean(folder: string, ...command: string[]): Promise<string> {\n return CommandHelper.run(folder, ...command).then((result) => {\n return result ? result.replace(/\\r?\\n|\\r/g, '') : '';\n });\n }\n}\n","/**\n * Utility class for parsing CLI parameters from `process.argv`.\n *\n * @example\n * ```typescript\n * // node script.js --name=Alice --port=3000\n * const params = ParamHelper.getParams();\n * // => { name: \"Alice\", port: \"3000\" }\n * ```\n */\nexport class ParamHelper {\n /**\n * Appends a custom parameter string to `process.argv`.\n *\n * @param customParam - The parameter to add (e.g., `'--env=production'`)\n */\n static addCustomParam(customParam: string): void {\n process.argv.push(customParam);\n }\n\n /**\n * Retrieves the command-line argument at the given index.\n *\n * @param index - Zero-based index into `process.argv`\n * @returns The argument at the given index, or `''` if out of bounds\n */\n static getCommandByIndex(index: number): string {\n return process.argv.length > index ? process.argv[index] : '';\n }\n\n /**\n * Parses all `--key=value` parameters from `process.argv` into an object.\n * Surrounding quotes on values are stripped automatically.\n *\n * @returns An object mapping parameter names to their string values\n *\n * @example\n * ```typescript\n * // node script.js --name=Alice --port=3000\n * ParamHelper.getParams();\n * // => { name: \"Alice\", port: \"3000\" }\n * ```\n */\n static getParams(): Record<string, string> {\n const paramsObj: Record<string, string> = {};\n process.argv.slice(2).forEach((element) => {\n const matches = element.match('--([a-zA-Z0-9]+)=(.*)');\n if (matches) {\n paramsObj[matches[1]] = matches[2]\n .replace(/^['\"]/, '')\n .replace(/['\"]$/, '');\n }\n });\n return paramsObj;\n }\n}\n","import Handlebars from 'handlebars';\nimport { FileHelper } from './file_helper.js';\n\nexport class HandlebarsHelper {\n static render(\n source: string,\n data: Record<string, unknown>,\n options?: CompileOptions\n ): Promise<string> {\n return new Promise((resolve, reject) => {\n try {\n const template = Handlebars.compile(source, options);\n const res = template(data);\n resolve(res);\n } catch (error) {\n reject(error);\n }\n });\n }\n\n static renderFile(\n fileName: string,\n data: Record<string, unknown>,\n options?: CompileOptions\n ): Promise<string> {\n return new Promise((resolve, reject) => {\n try {\n const source = FileHelper.readFileToString(fileName);\n const template = Handlebars.compile(source, options);\n const res = template(data);\n resolve(res);\n } catch (error) {\n reject(error);\n }\n });\n }\n}\n","import ejs from 'ejs';\n\nexport class EjsHelper {\n static render(\n source: string,\n data: Record<string, unknown>,\n options?: ejs.Options\n ): Promise<string> {\n return new Promise((resolve, reject) => {\n try {\n const template = ejs.render(source, data, options);\n resolve(template);\n } catch (error) {\n reject(error);\n }\n });\n }\n\n static renderFile(\n fileName: string,\n data: Record<string, unknown>,\n options?: ejs.Options\n ): Promise<string> {\n return new Promise((resolve, reject) => {\n ejs.renderFile(fileName, data, options ?? {}, (err, str) => {\n if (err) {\n reject(err);\n return;\n }\n resolve(str!);\n });\n });\n }\n}\n","import pug from 'pug';\n\nexport class PugHelper {\n static render(\n source: string,\n data: Record<string, unknown>,\n options?: pug.Options\n ): Promise<string> {\n return new Promise((resolve, reject) => {\n try {\n const template = pug.compile(source, options);\n resolve(template(data));\n } catch (error) {\n reject(error);\n }\n });\n }\n\n static renderFile(\n fileName: string,\n data: Record<string, unknown>,\n options?: pug.Options\n ): Promise<string> {\n return new Promise((resolve, reject) => {\n try {\n const template = pug.compileFile(fileName, options);\n resolve(template(data));\n } catch (error) {\n reject(error);\n }\n });\n }\n}\n","/**\n * Enum-like object defining the built-in template engine identifiers.\n *\n * @example\n * ```typescript\n * const builder = new TemplateBuilder(TEMPLATE_HANDLERS.EJS);\n * ```\n */\nexport const TEMPLATE_HANDLERS = {\n HANDLEBARS: 'HANDLEBARS',\n EJS: 'EJS',\n PUG: 'PUG'\n} as const;\n\n/**\n * Union type of all valid built-in template handler names.\n */\nexport type TemplateHandler =\n (typeof TEMPLATE_HANDLERS)[keyof typeof TEMPLATE_HANDLERS];\n","import { HandlebarsHelper } from './handlebars_helper.js';\nimport { EjsHelper } from './ejs_helper.js';\nimport { PugHelper } from './pug_helper.js';\nimport { TEMPLATE_HANDLERS, type TemplateHandler } from './template_handlers.js';\n\n/**\n * Interface that custom template engines must implement to be registered\n * with {@link TemplateBuilder.registerEngine}.\n */\nexport interface TemplateEngine {\n /** Renders a template from a source string with the given data. */\n render: (\n source: string,\n data: Record<string, unknown>,\n options?: Record<string, unknown>\n ) => Promise<string>;\n /** Renders a template from a file path with the given data. */\n renderFile: (\n fileName: string,\n data: Record<string, unknown>,\n options?: Record<string, unknown>\n ) => Promise<string>;\n}\n\nconst builtInEngines: Record<string, TemplateEngine> = {\n [TEMPLATE_HANDLERS.HANDLEBARS]: HandlebarsHelper,\n [TEMPLATE_HANDLERS.EJS]: EjsHelper,\n [TEMPLATE_HANDLERS.PUG]: PugHelper\n};\n\nconst customEngines: Record<string, TemplateEngine> = {};\n\n/**\n * Unified interface to render templates with EJS, Handlebars, Pug, or any custom engine.\n *\n * Supports a plugin system for registering custom template engines at runtime.\n *\n * @example\n * ```typescript\n * // Built-in engines\n * const builder = new TemplateBuilder(TEMPLATE_HANDLERS.EJS);\n * const html = await builder.render('Hello <%= name %>', { name: 'World' });\n *\n * // Custom engine\n * TemplateBuilder.registerEngine('nunjucks', {\n * render: async (source, data) => nunjucks.renderString(source, data),\n * renderFile: async (file, data) => nunjucks.render(file, data),\n * });\n * const nj = new TemplateBuilder('nunjucks');\n * ```\n */\nexport class TemplateBuilder {\n private templateHandler: string;\n\n /**\n * Creates a new TemplateBuilder for the specified engine.\n *\n * @param templateHandler - The engine name (e.g., `'EJS'`, `'HANDLEBARS'`, `'PUG'`, or a custom name)\n */\n constructor(templateHandler: TemplateHandler | string) {\n this.templateHandler = templateHandler;\n }\n\n /**\n * Registers a custom template engine that can be used with `new TemplateBuilder(name)`.\n *\n * @param name - A unique name for the engine\n * @param engine - An object implementing the {@link TemplateEngine} interface\n * @throws If `name` is empty or `engine` doesn't implement `render()` and `renderFile()`\n *\n * @example\n * ```typescript\n * TemplateBuilder.registerEngine('nunjucks', {\n * render: async (source, data) => nunjucks.renderString(source, data),\n * renderFile: async (file, data) => nunjucks.render(file, data),\n * });\n * ```\n */\n static registerEngine(name: string, engine: TemplateEngine): void {\n if (!name || typeof name !== 'string') {\n throw new Error('engine name must be a non-empty string');\n }\n if (!engine || typeof engine.render !== 'function' || typeof engine.renderFile !== 'function') {\n throw new Error('engine must implement render() and renderFile() methods');\n }\n customEngines[name] = engine;\n }\n\n /**\n * Retrieves a registered engine by name (custom engines take precedence over built-in).\n *\n * @param name - The engine name to look up\n * @returns The engine implementation, or `undefined` if not found\n */\n static getEngine(name: string): TemplateEngine | undefined {\n return customEngines[name] ?? builtInEngines[name];\n }\n\n /**\n * Returns an array of all registered engine names (built-in + custom).\n *\n * @returns Array of engine name strings\n *\n * @example\n * ```typescript\n * TemplateBuilder.getRegisteredEngines();\n * // => ['HANDLEBARS', 'EJS', 'PUG']\n * ```\n */\n static getRegisteredEngines(): string[] {\n return [\n ...Object.keys(builtInEngines),\n ...Object.keys(customEngines)\n ];\n }\n\n private resolveEngine(): TemplateEngine {\n const engine =\n customEngines[this.templateHandler] ??\n builtInEngines[this.templateHandler] ??\n builtInEngines[TEMPLATE_HANDLERS.HANDLEBARS];\n return engine;\n }\n\n /**\n * Renders a template from a source string.\n *\n * @param source - The template source string\n * @param data - Data object to pass to the template\n * @param options - Optional engine-specific options\n * @returns A promise resolving to the rendered string\n */\n render(\n source: string,\n data: Record<string, unknown>,\n options?: Record<string, unknown>\n ): Promise<string> {\n return this.resolveEngine().render(source, data, options);\n }\n\n /**\n * Renders a template from a file path.\n *\n * @param fileName - Path to the template file\n * @param data - Data object to pass to the template\n * @param options - Optional engine-specific options\n * @returns A promise resolving to the rendered string\n */\n renderFile(\n fileName: string,\n data: Record<string, unknown>,\n options?: Record<string, unknown>\n ): Promise<string> {\n return this.resolveEngine().renderFile(fileName, data, options);\n }\n}\n","import fs from 'fs';\nimport path from 'path';\nimport { TemplateBuilder } from './template_builder.js';\nimport { type TemplateHandler } from './template_handlers.js';\n\n/** A function that transforms a string, optionally returning a promise. */\nexport type TransformFn = (content: string) => string | Promise<string>;\n\n/**\n * Chainable pipeline for composing template rendering and string transformations.\n *\n * Supports multiple input sources (string, file, template) and sequential\n * transforms before writing the result to a file or returning it.\n *\n * @example\n * ```typescript\n * const result = await new Pipeline()\n * .fromTemplate('component.ejs', { name: 'Button' }, 'EJS')\n * .transform((content) => content.toUpperCase())\n * .writeTo('src/components/Button.tsx');\n * ```\n */\nexport class Pipeline {\n private content: string | null = null;\n private contentPromise: Promise<string> | null = null;\n private transforms: TransformFn[] = [];\n\n /**\n * Sets the pipeline content from a raw string.\n *\n * @param source - The string content\n * @returns This pipeline instance for chaining\n */\n fromString(source: string): Pipeline {\n this.content = source;\n this.contentPromise = null;\n return this;\n }\n\n /**\n * Sets the pipeline content by reading a file synchronously.\n *\n * @param filePath - Path to the file to read\n * @returns This pipeline instance for chaining\n */\n fromFile(filePath: string): Pipeline {\n this.content = fs.readFileSync(filePath, 'utf8');\n this.contentPromise = null;\n return this;\n }\n\n /**\n * Sets the pipeline content by rendering a template file.\n * If no engine is specified, it is auto-detected from the file extension.\n *\n * @param templatePath - Path to the template file\n * @param data - Data to pass to the template\n * @param engine - Template engine name (auto-detected if omitted)\n * @param options - Optional engine-specific options\n * @returns This pipeline instance for chaining\n */\n fromTemplate(\n templatePath: string,\n data: Record<string, unknown>,\n engine?: TemplateHandler | string,\n options?: Record<string, unknown>\n ): Pipeline {\n const ext = engine ?? extToEngine(templatePath);\n const builder = new TemplateBuilder(ext);\n this.contentPromise = builder.renderFile(templatePath, data, options);\n this.content = null;\n return this;\n }\n\n /**\n * Sets the pipeline content by rendering a template from a source string.\n *\n * @param source - The template source string\n * @param data - Data to pass to the template\n * @param engine - The template engine name\n * @param options - Optional engine-specific options\n * @returns This pipeline instance for chaining\n */\n fromTemplateString(\n source: string,\n data: Record<string, unknown>,\n engine: TemplateHandler | string,\n options?: Record<string, unknown>\n ): Pipeline {\n const builder = new TemplateBuilder(engine);\n this.contentPromise = builder.render(source, data, options);\n this.content = null;\n return this;\n }\n\n /**\n * Adds a transformation function to the pipeline.\n * Transforms are executed sequentially in the order they are added.\n *\n * @param fn - A sync or async function that receives and returns a string\n * @returns This pipeline instance for chaining\n */\n transform(fn: TransformFn): Pipeline {\n this.transforms.push(fn);\n return this;\n }\n\n /**\n * Executes the pipeline: resolves the content and applies all transforms.\n *\n * @returns A promise resolving to the final transformed string\n * @throws If no content source has been set\n */\n async execute(): Promise<string> {\n let result: string;\n\n if (this.contentPromise) {\n result = await this.contentPromise;\n } else if (this.content !== null) {\n result = this.content;\n } else {\n throw new Error(\n 'Pipeline has no content. Call fromString(), fromFile(), or fromTemplate() first.'\n );\n }\n\n for (const fn of this.transforms) {\n result = await fn(result);\n }\n\n return result;\n }\n\n /**\n * Executes the pipeline and writes the result to a file.\n * Creates parent directories automatically if they don't exist.\n *\n * @param filePath - Path to the output file\n * @returns A promise resolving to the written content\n */\n async writeTo(filePath: string): Promise<string> {\n const result = await this.execute();\n const dir = path.dirname(filePath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n fs.writeFileSync(filePath, result, 'utf8');\n return result;\n }\n}\n\n/** @internal Maps file extensions to engine names. */\nfunction extToEngine(filePath: string): string {\n const ext = path.extname(filePath).toLowerCase();\n switch (ext) {\n case '.ejs':\n return 'EJS';\n case '.hbs':\n case '.handlebars':\n return 'HANDLEBARS';\n case '.pug':\n case '.jade':\n return 'PUG';\n default:\n return 'HANDLEBARS';\n }\n}\n","import fs from 'fs';\nimport path from 'path';\nimport { TemplateBuilder } from './template_builder.js';\nimport { StringHelper } from './string_helper.js';\n\n/** Defines a single file in a scaffold structure. */\nexport interface ScaffoldFile {\n /** Relative path to the template file (within `templateDir`). */\n template: string;\n /** Output filename pattern (supports `{{variable}}` interpolation). */\n output: string;\n}\n\n/** Configuration options for scaffold generation. */\nexport interface ScaffoldOptions {\n /** Template engine to use (e.g., `'EJS'`, `'HANDLEBARS'`, `'PUG'`). */\n engine: string;\n /** Base directory containing the template files. */\n templateDir: string;\n /** Output directory pattern (supports `{{variable}}` interpolation). */\n outputDir: string;\n /** Variables for template rendering and path interpolation. */\n variables: Record<string, string>;\n /** List of files to generate. */\n structure: ScaffoldFile[];\n /** If `true`, returns the file list without writing files. */\n dryRun?: boolean;\n}\n\n/** Result of a scaffold generation operation. */\nexport interface ScaffoldResult {\n /** List of file paths that were created (or would be created in dry-run mode). */\n files: string[];\n /** Whether this was a dry-run execution. */\n dryRun: boolean;\n}\n\n/**\n * Generates directory structures from a manifest configuration.\n *\n * Reads template files, renders them with the specified engine, and writes\n * the output to a directory structure with variable-interpolated paths.\n *\n * @example\n * ```typescript\n * const result = await Scaffold.from({\n * engine: 'EJS',\n * templateDir: './templates/react-component',\n * outputDir: './src/components/{{name}}',\n * variables: { name: 'UserProfile', style: 'module' },\n * structure: [\n * { template: 'component.ejs', output: '{{name}}.tsx' },\n * { template: 'styles.ejs', output: '{{name}}.module.css' },\n * { template: 'test.ejs', output: '{{name}}.test.tsx' },\n * ]\n * });\n *\n * console.log(result.files); // List of created file paths\n * ```\n */\nexport class Scaffold {\n /**\n * Generates files from a scaffold manifest.\n *\n * @param options - The scaffold configuration\n * @returns A promise resolving to a {@link ScaffoldResult} with the list of created files\n */\n static async from(options: ScaffoldOptions): Promise<ScaffoldResult> {\n const {\n engine,\n templateDir,\n outputDir,\n variables,\n structure,\n dryRun = false\n } = options;\n\n const builder = new TemplateBuilder(engine);\n const resolvedOutputDir = resolveVariables(outputDir, variables);\n const createdFiles: string[] = [];\n\n for (const file of structure) {\n const templatePath = path.join(templateDir, file.template);\n const outputFileName = resolveVariables(file.output, variables);\n const outputPath = path.join(resolvedOutputDir, outputFileName);\n\n if (dryRun) {\n createdFiles.push(outputPath);\n continue;\n }\n\n const dir = path.dirname(outputPath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n\n const content = await builder.renderFile(\n templatePath,\n variables as unknown as Record<string, unknown>,\n {}\n );\n fs.writeFileSync(outputPath, content, 'utf8');\n createdFiles.push(outputPath);\n }\n\n return { files: createdFiles, dryRun };\n }\n}\n\n/** @internal Replaces `{{key}}` tokens in a string with variable values. */\nfunction resolveVariables(\n template: string,\n variables: Record<string, string>\n): string {\n let result = template;\n for (const [key, value] of Object.entries(variables)) {\n result = StringHelper.replace(result, `{{${key}}}`, value);\n }\n return result;\n}\n","import fs from 'fs';\nimport path from 'path';\nimport { TemplateBuilder } from './template_builder.js';\n\n/** Configuration options for the file watcher. */\nexport interface WatcherOptions {\n /** Directory containing template files to watch. */\n templateDir: string;\n /** Directory where rendered output files are written. */\n outputDir: string;\n /** Template engine to use for rendering (e.g., `'EJS'`, `'HANDLEBARS'`, `'PUG'`). */\n engine: string;\n /** Variables to pass to the template engine during rendering. */\n variables: Record<string, unknown>;\n /** File extensions to watch (defaults to `['.ejs', '.hbs', '.handlebars', '.pug']`). */\n extensions?: string[];\n /** Callback invoked after a file is successfully rebuilt. */\n onRebuild?: (file: string) => void;\n /** Callback invoked when a rebuild error occurs. */\n onError?: (error: Error, file: string) => void;\n}\n\n/**\n * Watches a template directory and automatically re-renders templates when they change.\n *\n * Uses `fs.watch()` with `AbortController` for clean start/stop lifecycle.\n *\n * @example\n * ```typescript\n * const watcher = new Watcher({\n * templateDir: './templates',\n * outputDir: './generated',\n * engine: 'EJS',\n * variables: { project: 'MyApp' },\n * onRebuild: (file) => console.log(`Rebuilt: ${file}`),\n * onError: (err, file) => console.error(`Error in ${file}: ${err.message}`),\n * });\n *\n * watcher.start();\n * // Later: watcher.stop();\n * ```\n */\nexport class Watcher {\n private options: WatcherOptions;\n private abortController: AbortController | null = null;\n\n /**\n * Creates a new Watcher instance.\n *\n * @param options - Watcher configuration\n */\n constructor(options: WatcherOptions) {\n this.options = {\n extensions: ['.ejs', '.hbs', '.handlebars', '.pug'],\n ...options\n };\n }\n\n /**\n * Starts watching the template directory for changes.\n * Does nothing if the watcher is already running.\n */\n start(): void {\n if (this.abortController) {\n return;\n }\n\n this.abortController = new AbortController();\n const { signal } = this.abortController;\n\n if (!fs.existsSync(this.options.outputDir)) {\n fs.mkdirSync(this.options.outputDir, { recursive: true });\n }\n\n try {\n const watcher = fs.watch(this.options.templateDir, {\n recursive: true,\n signal\n });\n\n watcher.on('change', (_eventType, filename) => {\n if (!filename) return;\n const filePath = path.join(\n this.options.templateDir,\n filename.toString()\n );\n this.handleChange(filePath);\n });\n\n watcher.on('error', (err) => {\n if ((err as NodeJS.ErrnoException).code !== 'ABORT_ERR') {\n this.options.onError?.(err, '');\n }\n });\n } catch {\n // fs.watch not available\n }\n }\n\n /**\n * Stops watching for changes and cleans up resources.\n */\n stop(): void {\n if (this.abortController) {\n this.abortController.abort();\n this.abortController = null;\n }\n }\n\n /**\n * Whether the watcher is currently active.\n */\n get isRunning(): boolean {\n return this.abortController !== null;\n }\n\n private async handleChange(filePath: string): Promise<void> {\n const ext = path.extname(filePath).toLowerCase();\n if (!this.options.extensions!.includes(ext)) {\n return;\n }\n\n if (!fs.existsSync(filePath)) {\n return;\n }\n\n try {\n const builder = new TemplateBuilder(this.options.engine);\n const content = await builder.renderFile(\n filePath,\n this.options.variables,\n {}\n );\n\n const relativePath = path.relative(this.options.templateDir, filePath);\n const outputName = relativePath.replace(ext, '.html');\n const outputPath = path.join(this.options.outputDir, outputName);\n\n const outputDir = path.dirname(outputPath);\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true });\n }\n\n fs.writeFileSync(outputPath, content, 'utf8');\n this.options.onRebuild?.(outputPath);\n } catch (error) {\n this.options.onError?.(error as Error, filePath);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACYO,IAAM,eAAN,MAAM,cAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaxB,OAAO,YAAY,QAAwB;AACzC,WAAO,OAAO,QAAQ,uBAAuB,MAAM;AAAA,EACrD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBA,OAAO,QAAQ,MAAe,OAAgB,OAAuB;AACnE,QAAI,OAAO,SAAS,SAAU,QAAO;AACrC,QAAI,OAAO,UAAU,SAAU,QAAO;AACtC,WAAO,KAAK;AAAA,MACV,IAAI,OAAO,cAAa,YAAY,KAAK,GAAG,GAAG;AAAA,MAC/C;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AAqB;AACvB,WAAO,KAAK,oBAAoB;AAAA,EAClC;AAAA,EAEA,MAAc,aAAa,UAAiC;AAC1D,UAAM,MAAM,aAAAA,QAAK,QAAQ,QAAQ,EAAE,YAAY;AAC/C,QAAI,CAAC,KAAK,QAAQ,WAAY,SAAS,GAAG,GAAG;AAC3C;AAAA,IACF;AAEA,QAAI,CAAC,WAAAD,QAAG,WAAW,QAAQ,GAAG;AAC5B;AAAA,IACF;AAEA,QAAI;AACF,YAAM,UAAU,IAAI,gBAAgB,KAAK,QAAQ,MAAM;AACvD,YAAM,UAAU,MAAM,QAAQ;AAAA,QAC5B;AAAA,QACA,KAAK,QAAQ;AAAA,QACb,CAAC;AAAA,MACH;AAEA,YAAM,eAAe,aAAAC,QAAK,SAAS,KAAK,QAAQ,aAAa,QAAQ;AACrE,YAAM,aAAa,aAAa,QAAQ,KAAK,OAAO;AACpD,YAAM,aAAa,aAAAA,QAAK,KAAK,KAAK,QAAQ,WAAW,UAAU;AAE/D,YAAM,YAAY,aAAAA,QAAK,QAAQ,UAAU;AACzC,UAAI,CAAC,WAAAD,QAAG,WAAW,SAAS,GAAG;AAC7B,mBAAAA,QAAG,UAAU,WAAW,EAAE,WAAW,KAAK,CAAC;AAAA,MAC7C;AAEA,iBAAAA,QAAG,cAAc,YAAY,SAAS,MAAM;AAC5C,WAAK,QAAQ,YAAY,UAAU;AAAA,IACrC,SAAS,OAAO;AACd,WAAK,QAAQ,UAAU,OAAgB,QAAQ;AAAA,IACjD;AAAA,EACF;AACF;","names":["fs","path","readline","Handlebars","ejs","pug","import_fs","import_path","fs","path","import_fs","import_path","path","fs","import_fs","import_path","fs","path"]}