{"_id":"@ai.kozlov/file-tools","_rev":"3-9a85c1b8c0ed29e96d37c503aa1899d1","name":"@ai.kozlov/file-tools","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@ai.kozlov/file-tools","version":"1.0.0","keywords":["copy","folder","files","replace","file-operations","utilities"],"author":{"name":"MPenny"},"license":"MIT","_id":"@ai.kozlov/file-tools@1.0.0","maintainers":[{"name":"ai.kozlov","email":"akozlov@dogezer.com"}],"homepage":"https://github.com/yourusername/mpenny-tools#readme","bugs":{"url":"https://github.com/yourusername/mpenny-tools/issues"},"dist":{"shasum":"b8b3caab4db6eac57348e69d3b49c25c08d6dd80","tarball":"https://registry.npmjs.org/@ai.kozlov/file-tools/-/file-tools-1.0.0.tgz","fileCount":5,"integrity":"sha512-S5/AIPS0R/BibaJV4SKQFpY0GA9mFOCQzT9UAJuWDqA4JvtdtiXoQaGiOBQw6bbwby8HxPhykUx6+WdVoqEK2Q==","signatures":[{"sig":"MEYCIQDlN7dgvgIWm/Esq9WS94Ocx15/V2g5MuGCDWXkJyCBOAIhALk6mHwzWZE1ZUa6MHML9TDKcjOdWQJD3ryyIuzZTxPQ","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":13057},"main":"src/index.js","types":"index.d.ts","engines":{"node":">=14.0.0"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"ai.kozlov","email":"akozlov@dogezer.com"},"repository":{"url":"git+https://github.com/yourusername/mpenny-tools.git","type":"git"},"_npmVersion":"10.9.3","description":"A Node.js library for copying folders and performing file content replacements","directories":{},"_nodeVersion":"22.20.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/file-tools_1.0.0_1765787240681_0.07481817555167902","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@ai.kozlov/file-tools","version":"1.0.1","keywords":["copy","folder","files","replace","file-operations","utilities"],"author":{"name":"MPenny"},"license":"MIT","_id":"@ai.kozlov/file-tools@1.0.1","maintainers":[{"name":"ai.kozlov","email":"akozlov@dogezer.com"}],"homepage":"https://bitbucket.org/alexkozlovwearehere/mpenny-public#readme","bugs":{"url":"https://bitbucket.org/alexkozlovwearehere/mpenny-public/issues"},"dist":{"shasum":"84bd832654db46cee5ea09959fee389766b12203","tarball":"https://registry.npmjs.org/@ai.kozlov/file-tools/-/file-tools-1.0.1.tgz","fileCount":5,"integrity":"sha512-/E9f+bMPjKbnpaXr96wB5fTlbJ2EUG1OqD5hrL9BzPRv5oU7COMYbN5dQhoG1ShIsZKVBOXzCo5/7z9nUTZ/iQ==","signatures":[{"sig":"MEUCIQCmWEuhgfKNmy50LyEb1ZGKx4/ByW555OAwZWMguBeIUQIgOf5H29R5mWWel3zHbiQz6po5nfPVnR2Hz2jHV1bz624=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":13068},"main":"src/index.js","types":"index.d.ts","engines":{"node":">=14.0.0"},"gitHead":"4a128f30d8ead62f7e7b8f9dab590e2a6898ee74","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"ai.kozlov","email":"akozlov@dogezer.com"},"repository":{"url":"git+https://bitbucket.org/alexkozlovwearehere/mpenny-public.git","type":"git"},"_npmVersion":"10.9.3","description":"A Node.js library for copying folders and performing file content replacements","directories":{},"_nodeVersion":"22.20.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/file-tools_1.0.1_1765788493849_0.7256789606544591","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@ai.kozlov/file-tools","version":"1.0.2","description":"A Node.js library for copying folders and performing file content replacements","main":"src/index.js","types":"index.d.ts","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":["copy","folder","files","replace","file-operations","utilities"],"author":{"name":"MPenny"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/wearehere-labs/mpenny-tools.git"},"engines":{"node":">=14.0.0"},"_id":"@ai.kozlov/file-tools@1.0.2","gitHead":"925a707f00fc03ba3ceae9fe6212f1f9c611dbd6","bugs":{"url":"https://github.com/wearehere-labs/mpenny-tools/issues"},"homepage":"https://github.com/wearehere-labs/mpenny-tools#readme","_nodeVersion":"22.20.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-koY6Q8fbPC/oTcCLo9vQPJwb8SGQhbDy+OvZmZ0i4zScZ8yJNtdxlBIckXIvQv9iBKaohkOJTPNy59cJTwC39w==","shasum":"5a3ef635b289c5ef946a27fa31307f7258bd2c1b","tarball":"https://registry.npmjs.org/@ai.kozlov/file-tools/-/file-tools-1.0.2.tgz","fileCount":5,"unpackedSize":13059,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD9gRdABG4yQXlvQl7H2bX7Sj5+/Qi+I74SS0F/nnStxQIhAMlGv8LYqsr703wvxCaD1Mk1lQfjC4lxyHTUAyOtz8TY"}]},"_npmUser":{"name":"ai.kozlov","email":"akozlov@dogezer.com"},"directories":{},"maintainers":[{"name":"ai.kozlov","email":"akozlov@dogezer.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/file-tools_1.0.2_1765790554847_0.1372065030398657"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-15T08:27:20.597Z","modified":"2025-12-15T09:22:35.203Z","1.0.0":"2025-12-15T08:27:20.821Z","1.0.1":"2025-12-15T08:48:14.039Z","1.0.2":"2025-12-15T09:22:34.986Z"},"bugs":{"url":"https://github.com/wearehere-labs/mpenny-tools/issues"},"author":{"name":"MPenny"},"license":"MIT","homepage":"https://github.com/wearehere-labs/mpenny-tools#readme","keywords":["copy","folder","files","replace","file-operations","utilities"],"repository":{"type":"git","url":"git+https://github.com/wearehere-labs/mpenny-tools.git"},"description":"A Node.js library for copying folders and performing file content replacements","maintainers":[{"name":"ai.kozlov","email":"akozlov@dogezer.com"}],"readme":"# @mpenny/file-tools\r\n\r\nA lightweight Node.js library for copying folders and performing text replacements across all files in a folder structure.\r\n\r\n## Features\r\n\r\n- 📁 Copy entire folder structures recursively\r\n- 🔄 Copy folders with automatic text/pattern replacement in all files\r\n- 🎯 Filter files by extension (include/exclude)\r\n- 📊 Get detailed statistics about copy operations\r\n- 🔒 Safe handling of binary files\r\n- ⚡ Built on native Node.js fs promises API\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install @mpenny/file-tools\r\n```\r\n\r\n## Usage\r\n\r\n### Import the library\r\n\r\n```javascript\r\nconst { copyFolder, copyFolderWithReplace } = require('@mpenny/file-tools');\r\n```\r\n\r\nOr with ES6 imports:\r\n\r\n```javascript\r\nimport { copyFolder, copyFolderWithReplace } from '@mpenny/file-tools';\r\n```\r\n\r\n### Copy a folder\r\n\r\nSimple folder copy operation:\r\n\r\n```javascript\r\nconst { copyFolder } = require('@mpenny/file-tools');\r\n\r\nasync function example() {\r\n  try {\r\n    await copyFolder('./source-folder', './destination-folder');\r\n    console.log('Folder copied successfully!');\r\n  } catch (error) {\r\n    console.error('Error copying folder:', error);\r\n  }\r\n}\r\n\r\nexample();\r\n```\r\n\r\n### Copy a folder with text replacement\r\n\r\nCopy a folder and replace text in all files:\r\n\r\n```javascript\r\nconst { copyFolderWithReplace } = require('@mpenny/file-tools');\r\n\r\nasync function example() {\r\n  try {\r\n    const stats = await copyFolderWithReplace(\r\n      './template-project',\r\n      './new-project',\r\n      'PLACEHOLDER_NAME',\r\n      'MyAwesomeProject'\r\n    );\r\n    \r\n    console.log('Copy complete!');\r\n    console.log(`Files processed: ${stats.filesProcessed}`);\r\n    console.log(`Files modified: ${stats.filesModified}`);\r\n    console.log(`Files skipped: ${stats.filesSkipped}`);\r\n    console.log(`Directories created: ${stats.directoriesCopied}`);\r\n  } catch (error) {\r\n    console.error('Error:', error);\r\n  }\r\n}\r\n\r\nexample();\r\n```\r\n\r\n### Using regular expressions for replacement\r\n\r\nReplace using regex patterns:\r\n\r\n```javascript\r\nconst { copyFolderWithReplace } = require('@mpenny/file-tools');\r\n\r\nasync function example() {\r\n  const stats = await copyFolderWithReplace(\r\n    './source',\r\n    './destination',\r\n    /version:\\s*\\d+\\.\\d+\\.\\d+/g,\r\n    'version: 2.0.0'\r\n  );\r\n  \r\n  console.log(`Modified ${stats.filesModified} files`);\r\n}\r\n\r\nexample();\r\n```\r\n\r\n### Filter files by extension\r\n\r\nOnly process specific file types or exclude certain extensions:\r\n\r\n```javascript\r\nconst { copyFolderWithReplace } = require('@mpenny/file-tools');\r\n\r\nasync function example() {\r\n  // Only replace in .js and .json files\r\n  const stats = await copyFolderWithReplace(\r\n    './source',\r\n    './destination',\r\n    'oldValue',\r\n    'newValue',\r\n    {\r\n      includeExtensions: ['.js', '.json']\r\n    }\r\n  );\r\n\r\n  // Or exclude binary files\r\n  const stats2 = await copyFolderWithReplace(\r\n    './source',\r\n    './destination',\r\n    'oldValue',\r\n    'newValue',\r\n    {\r\n      excludeExtensions: ['.jpg', '.png', '.pdf', '.zip']\r\n    }\r\n  );\r\n}\r\n\r\nexample();\r\n```\r\n\r\n## API Reference\r\n\r\n### `copyFolder(source, destination)`\r\n\r\nRecursively copies a folder from source to destination.\r\n\r\n**Parameters:**\r\n- `source` (string): Source folder path\r\n- `destination` (string): Destination folder path\r\n\r\n**Returns:** `Promise<void>`\r\n\r\n**Throws:** Error if copy operation fails\r\n\r\n---\r\n\r\n### `copyFolderWithReplace(source, destination, searchValue, replaceValue, options)`\r\n\r\nRecursively copies a folder and replaces text in all files.\r\n\r\n**Parameters:**\r\n- `source` (string): Source folder path\r\n- `destination` (string): Destination folder path\r\n- `searchValue` (string | RegExp): Text or pattern to search for\r\n- `replaceValue` (string): Text to replace with\r\n- `options` (object, optional):\r\n  - `excludeExtensions` (string[]): File extensions to exclude from replacement\r\n  - `includeExtensions` (string[]): Only process files with these extensions\r\n\r\n**Returns:** `Promise<CopyFolderWithReplaceStats>`\r\n\r\n**Stats Object:**\r\n```typescript\r\n{\r\n  filesProcessed: number;    // Files checked for replacements\r\n  filesModified: number;      // Files where replacements were made\r\n  filesSkipped: number;       // Files skipped (binary or excluded)\r\n  directoriesCopied: number;  // Directories created\r\n}\r\n```\r\n\r\n**Throws:** Error if operation fails\r\n\r\n## Use Cases\r\n\r\n- **Project Templates**: Create project templates with placeholders and generate new projects with replaced values\r\n- **Code Generation**: Copy boilerplate code and customize it for different contexts\r\n- **Configuration Management**: Duplicate configuration directories with environment-specific values\r\n- **Documentation**: Generate customized documentation from templates\r\n- **Build Processes**: Create modified copies of source code for different build targets\r\n\r\n## Requirements\r\n\r\n- Node.js >= 14.0.0\r\n\r\n## License\r\n\r\nMIT\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Please feel free to submit a Pull Request.\r\n\r\n## Support\r\n\r\nIf you encounter any issues or have questions, please file an issue on the GitHub repository.\r\n","readmeFilename":"README.md"}