{"name":"@putout/plugin-filesystem","version":"8.0.0","keywords":["putout","putout-plugin","plugin","config"],"author":{"url":"https://github.com/coderaiser","name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"license":"MIT","_id":"@putout/plugin-filesystem@8.0.0","homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-filesystem#readme","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"tag":false,"dist":{"shasum":"5c936999e263a3c4579912d08e41044d420d90b2","tarball":"http://registry-npm.ywwl.com/@putout/plugin-filesystem/download/@putout/plugin-filesystem-8.0.0.tgz","fileCount":23,"integrity":"sha512-zCMGTvrasV7/pm8X+qpVBxsXS/9XM18pRV1TpMzwXSvrpy6YgKWRKX4vPiyjfoqYvk9OAnTcFda2jhftGwLrkw==","signatures":[{"sig":"MEUCIFybTSCZit+bXJuzqLkJqG9/XokJPsq6EcGF7V0k9o1YAiEAxM6aZWbVtRBRsAPeBwbC9pgcgD1yQwAFE1XRmy/eW+I=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":35602,"size":8909,"noattachment":false,"key":"/@putout/plugin-filesystem/-/@putout/plugin-filesystem-8.0.0.tgz"},"main":"lib/index.js","type":"commonjs","engines":{"node":">=18"},"exports":{".":"./lib/index.js","./to-simple":"./lib/convert-filesystem-to-simple-filesystem/index.js","./from-simple":"./lib/convert-simple-filesystem-to-filesystem/index.js","./replace-cwd":"./lib/replace-cwd/index.js","./read-all-files":"./lib/read-all-files/index.js","./write-all-files":"./lib/write-all-files/index.js"},"gitHead":"a47f16d795782bd21ea070dd2c9138d0e30e83dc","release":false,"scripts":{"lint":"madrun lint","test":"madrun test","report":"madrun report","coverage":"madrun coverage","fix:lint":"madrun fix:lint","fresh:lint":"madrun fresh:lint","lint:fresh":"madrun lint:fresh","watch:test":"madrun watch:test"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"changelog":false,"repository":{"url":"git+https://github.com/coderaiser/putout.git","type":"git"},"_npmVersion":"10.9.0","description":"🐊Putout plugin operates with filesystem","directories":{},"_nodeVersion":"22.13.1","dependencies":{"@putout/babel":"^3.0.0","@putout/operate":"^13.0.0","@putout/operator-json":"^2.0.0","@putout/operator-filesystem":"^5.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.0.0","lerna":"^6.0.1","eslint":"^9.0.0","madrun":"^10.0.0","nodemon":"^3.0.1","clean-css":"^5.3.3","supertape":"^10.0.0","try-catch":"^3.0.1","@putout/test":"^11.0.0","eslint-plugin-n":"^17.0.0","eslint-plugin-putout":"^24.0.0","@putout/plugin-webpack":"*"},"peerDependencies":{"putout":">=38"},"_npmOperationalInternal":{"tmp":"tmp/plugin-filesystem_8.0.0_1738847635983_0.7355467918771657","host":"s3://npm-registry-packages-npm-production"},"readme":"# @putout/plugin-filesystem [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-filesystem.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/plugin-filesystem\"npm\"\n\n🐊[**Putout**](https://github.com/coderaiser/putout) plugin helps to lint filesystem.\n\n## Install\n\n```\nnpm i @putout/plugin-filesystem -D\n```\n\n## Rules\n\n- ✅ [bundle](#bundle);\n- ✅ [convert-filesystem-to-simple-filesystem](#convert-filesystem-to-simple-filesystem);\n- ✅ [convert-js-to-json](#convert-js-to-json);\n- ✅ [convert-json-to-js](#convert-json-to-js);\n- ✅ [convert-simple-filesystem-to-filesystem](#convert-simple-filesystem-to-filesystem);\n- ✅ [move-referenced-file](#move-referenced-file);\n- ✅ [read-all-files](#read-all-files);\n- ✅ [rename-file](#rename-file);\n- ✅ [remove-empty-directory](#remove-empty-directory);\n- ✅ [remove-travis-yml-file](#remove-travis-yml-file);\n- ✅ [remove-vim-swap-file](#remove-vim-swap-file);\n- ✅ [remove-nyc-output-files](#remove-nyc-output-files);\n- ✅ [remove-files](#remove-files);\n- ✅ [rename-referenced-file](#rename-referenced-file);\n- ✅ [rename-spec-to-test](#rename-spec-to-test);\n- ✅ [rename-test-to-spec](#rename-test-to-spec);\n- ✅ [replace-cwd](#replace-cwd);\n- ✅ [write-all-files](#write-all-files);\n\n## Config\n\n```json\n{\n    \"rules\": {\n        \"filesystem/remove-empty-directory\": \"on\",\n        \"filesystem/remove-travis-yml-file\": \"on\",\n        \"filesystem/remove-vim-swap-file\": \"on\",\n        \"filesystem/remove-nyc-output-files\": \"on\",\n        \"filesystem/bundle\": \"off\",\n        \"filesystem/read-all-files\": [\"off\", {\n            \"mask\": \"*\"\n        }],\n        \"filesystem/write-all-files\": \"off\",\n        \"filesystem/rename-file\": \"off\",\n        \"filesystem/remove-files\": \"off\",\n        \"filesystem/rename-spec-to-test\": \"off\",\n        \"filesystem/rename-test-to-spec\": \"off\",\n        \"filesystem/rename-referenced-file\": \"off\",\n        \"filesystem/move-referenced-file\": \"off\",\n        \"filesystem/convert-simple-filesystem-to-filesystem\": \"off\",\n        \"filesystem/replace-cwd\": [\"off\", {\n            \"from\": \"/home/coderaiser/putout\",\n            \"to\": \"/\"\n        }],\n        \"filesystem/convert-json-to-js\": [\"off\", {\n            \"filename\": \"package.json\"\n        }],\n        \"filesystem/convert-js-to-json\": [\"off\", {\n            \"filename\": \"package.js\"\n        }]\n    }\n}\n```\n\n## rename-file\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/0614c2da35a1864b59ac284f18656328/66daa5b325666a0d5befa586965c56e9636a5db4).\n\nUpdate `.putout.json` to enable rule:\n\n```json\n{\n    \"rules\": {\n        \"filesystem/rename-file\": [\"on\", {\n            \"from\": \"README.md\",\n            \"to\": \"readme.md\"\n        }]\n    }\n}\n```\n\nIt will make next modifications to filesystem:\n\n```diff\n-README.md\n+readme.md\n```\n\nFor more sophisticated example, use `mask`:\n\n```json\n{\n    \"rules\": {\n        \"filesystem/rename-file\": [\"on\", {\n            \"mask\": \"*.test.*\",\n            \"from\": \"test\",\n            \"to\": \"spec\"\n        }]\n    }\n}\n```\n\nIt will rename 'test' to 'spec' in `*.test.*` files:\n\n```diff\n-index.test.js\n+index.spec.js\n```\n\n## remove-empty-directory\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/52d8126f3e41b687c6028852a1925db7/5efcb17493ad5ebe8f1786075a985e1dd35ea59e).\n\n```diff\n/\n-|-- hello/\n-|  `-- abc/\n-|      `-- def/\n```\n\n## remove-nyc-output-files\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/52d8126f3e41b687c6028852a1925db7/5efcb17493ad5ebe8f1786075a985e1dd35ea59e).\n\n```diff\n-.nyc_output\n```\n\n## remove-travis-yml-file\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/a495c6782ed8b512f37e757bafd02b08/5d0dc03f6be2653639bb22ea00c3ce91e8454940).\n\n```diff\n-.travis.yml\n```\n\n## remove-vim-swap-file\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/a495c6782ed8b512f37e757bafd02b08/5d0dc03f6be2653639bb22ea00c3ce91e8454940).\n\n```diff\n-readme.md.swap\n```\n\n## remove-files\n\nUpdate `.putout.json` to enable rule:\n\n```json\n{\n    \"rules\": {\n        \"filesystem/remove-files\": [\"on\", {\n            \"names\": [\"coverage\"]\n        }]\n    }\n}\n```\n\nIt will make next modifications to filesystem:\n\n```diff\n /\n |-- test/\n |   `-- hello.spec.js\n-|-- coverage/\n `-- lib/\n     `-- hello.js\n```\n\n## rename-spec-to-test\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/ab52a74195eeb2f689e7284a1c987a03/d3a0e2ffac0bb33cc243004975d242d07d6d0bff).\n\n```diff\n-index.spec.js\n+index.test.js\n```\n\n## rename-test-to-spec\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/28e4d3a847f0968401da67fff04fb784/1e3bfd4ddb241dd0de6c2402f49252af0806b719).\n\n```diff\n-index.test.js\n+index.spec.js\n```\n\n## rename-referenced-file\n\nUpdate `.putout.json` to enable rule:\n\n```json\n{\n    \"rules\": {\n        \"filesystem/rename-referenced-file\": [\"on\", {\n            \"from\": \"hello.js\",\n            \"to\": \"world.js\"\n        }]\n    }\n}\n```\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/688ef036984ed06a6b2ba349fdb84409/5597aa2b224d572b9204288f986ed06226a7c541).\n\nBefore:\n\n```js\n// hello.spec.js\nimport hello from './hello.js';\n```\n\n```js\n// hello.js\nexport const hello = 'world';\n```\n\nAfter:\n\n```diff\n-hello.js\n+world.js\n```\n\n```js\n// hello.spec.js\nimport hello from './world.js';\n```\n\n```js\n// world.js\nexport const hello = 'world';\n```\n\n## move-referenced-file\n\nUpdate `.putout.json` to enable rule:\n\n```json\n{\n    \"rules\": {\n        \"filesystem/move-referenced-file\": [\"on\", {\n            \"name\": \"hello.js\",\n            \"directory\": \"lib\"\n        }]\n    }\n}\n```\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/02d0fefd171f6552c611dc6c11d0bbec/2b530c289e16e3fae375d44ce69ab3f8143e092e).\n\nBefore:\n\n```\n/\n|-- test/\n|  `-- hello.spec.js\n|-- src/\n|   `-- hello.js\n`-- lib/\n```\n\n```js\n// test/hello.spec.js\nimport hello from '../src/hello.js';\n```\n\n```js\n// src/hello.js\nexport const hello = 'world';\n```\n\nAfter:\n\n```\n/\n|-- test/\n|   `-- hello.spec.js\n|-- src/\n`-- lib/\n    `-- hello.js\n```\n\n```diff\n-src/hello.js\n+lib/hello.js\n```\n\n```js\n// test/hello.spec.js\nimport hello from '../lib/hello.js';\n```\n\n```js\n// lib/hello.js\nexport const hello = 'world';\n```\n\n## convert-simple-filesystem-to-filesystem\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/e15d077626f832dd0b98458b1b8ff284/e2d9d2767c9bfab3e4d337f149069666d2aafe79).\n\n### ❌ Example of incorrect code\n\n```js\n__putout_processor_filesystem([\n    '/',\n    '/hello.txt',\n    [\n        '/world.txt',\n        'hello world',\n    ],\n    '/abc/',\n]);\n```\n\n### ✅ Example of correct code\n\n```js\n__putout_processor_filesystem({\n    type: 'directory',\n    filename: '/',\n    files: [{\n        type: 'file',\n        filename: '/hello.txt',\n    }, {\n        type: 'file',\n        filename: '/world.txt',\n        content: 'hello world',\n    }, {\n        type: 'directory',\n        filename: '/abc',\n        files: [],\n    }],\n});\n```\n\n## convert-filesystem-to-simple-filesystem\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/79ce3ebdd5878d9fdcf80b762ceb8e76/52c9a16861c541abd601b83ad1c2ae988f97b28f).\n\n### ❌ Example of incorrect code\n\n```js\n__putout_processor_filesystem({\n    type: 'directory',\n    filename: '/',\n    files: [{\n        type: 'file',\n        filename: '/hello.txt',\n    }, {\n        type: 'file',\n        filename: '/world.txt',\n        content: 'hello world',\n    }, {\n        type: 'directory',\n        filename: '/abc',\n        files: [],\n    }],\n});\n```\n\n### ✅ Example of correct code\n\n```js\n__putout_processor_filesystem([\n    '/',\n    '/hello.txt',\n    [\n        '/world.txt',\n        'hello world',\n    ],\n    '/abc/',\n]);\n```\n\n## bundle\n\nBundle and minify `css` files.\n\n```json\n{\n    \"rules\": {\n        \"filesystem/bundle\": [\"on\", {\n            \"groups\": [\n                [\"__:columns/__\", [\n                    \"name-size-date.css\",\n                    \"name-size.css\"\n                ]],\n                [\"main.css\", [\n                    \"hello.css\",\n                    \"world.css\"\n                ]],\n                \"1:1\"\n            ]\n        }]\n    }\n}\n```\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/547738d2faf984e50f12a1379c221c83/3f77d711f8acc4da50899d6ef0ebe5e7c0df1479).\n\nBefore:\n\n```\n/\n|-- css/\n|  `-- hello.css\n|  `-- world.css\n```\n\nAfter:\n\n```\n/\n|-- css/\n|  `-- hello.css\n|  `-- world.css\n|-- dist/\n|   `-- main.css\n```\n\nJust minify styles:\n\n```json\n{\n    \"rules\": {\n        \"filesystem/bundle\": [\"on\", {\n            \"groups\": [\"1:1\"]\n        }]\n    }\n}\n```\n\nBefore:\n\n```\n/\n|-- css/\n|  `-- hello.css\n|  `-- world.css\n```\n\nAfter:\n\n```\n/\n|-- css/\n|  `-- hello.css\n|  `-- world.css\n|-- dist/\n|   `-- hello.css\n|   `-- world.css\n```\n\nCreate subdirectory:\n\n```json\n{\n    \"rules\": {\n        \"filesystem/bundle\": [\"on\", {\n            \"groups\": [\n                [\"__:columns/__\", [\n                    \"name-size-date.css\",\n                    \"name-size.css\"\n                ]]\n            ]\n        }]\n    }\n}\n```\n\nBefore:\n\n```\n/\n|-- css/\n|  `-- hello.css\n|  `-- world.css\n```\n\nAfter:\n\n```\n/\n|-- css/\n|  `-- hello.css\n|  `-- world.css\n|-- dist/\n|   `-- columns\n|       `-- hello.css\n|       `-- world.css\n```\n\nFilter css files by mask:\n\n```json\n{\n    \"rules\": {\n        \"filesystem/bundle\": [\"on\", {\n            \"mask\": \"*.good.css\",\n            \"groups\": [\"1:1\"]\n        }]\n    }\n}\n```\n\nBefore:\n\n```\n/\n|-- css/\n|  `-- hello.css\n|  `-- world.good.css\n```\n\nAfter:\n\n```\n/\n|-- css/\n|  `-- hello.css\n|  `-- world.css\n|-- dist/\n|   `-- world.good.css\n```\n\nYou can even override `transform` with your own `config`:\n\n```ts\nputout(filesystem, {\n    rules: {\n        'filesystem/bundle': ['on', {\n            transform: (source: string | string[], config) => string,\n        }],\n    },\n});\n```\n\nConcreate files:\n\n```json\n{\n    \"rules\": {\n        \"filesystem/bundle\": [\"on\", {\n            \"groups\": [\"hello.css\"]\n        }]\n    }\n}\n```\n\nBefore:\n\n```\n/\n|-- css/\n|  `-- hello.css\n|  `-- world.css\n```\n\nAfter:\n\n```\n/\n|-- css/\n|  `-- hello.css\n|  `-- world.css\n|-- dist/\n|   `-- hello.css\n```\n\n## replace-cwd\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/97a4cb9bc9f79abc9585bf5b47392450/b6b9de0a407258643bfa469453d967e089648a59).\n\nWhen `from=/home/coderaiser/putout` and `to=/`:\n\n```json\n{\n    \"rules\": {\n        \"filesystem/replace-cwd\": [\"on\", {\n            \"from\": \"/home/coderaiser/putout\",\n            \"to\": \"/\"\n        }]\n    }\n}\n```\n\n### ❌ Example of incorrect code\n\n```js\n__putout_processor_filesystem(['/home/coderaiser/putout/', '/home/coderaiser/putout/README.md']);\n```\n\n### ✅ Example of correct code\n\n```js\n__putout_processor_filesystem(['/', '/README.md']);\n```\n\n## read-all-files\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/fb221770d2f35e89faf19d70eb945a1c/c857e8c2bf0511157f30a36f167266da3ea31647).\n\n### ❌ Example of incorrect code\n\n```json\n[\"/\", \"/hello.xyz\"]\n```\n\n### ✅ Example of correct code\n\n```json\n[\"/\", [\n    \"/hello.xyz\",\n    \"hello world\"\n]]\n```\n\n## write-all-files\n\nWrite all files that was read before to Filesystem.\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/2dda6b05987bbf91a1b18d7032489c05/286d2f04eb0e002cef14d102fa3e59bdf17bda47).\n\n```json\n[\"/\", [\n    \"/hello.xyz\",\n    \"hello world\"\n]]\n```\n\n## convert-json-to-js\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/f0b2fc640398820c5c25c13bcbfe8ae4/170eff778a433dc809e75158a6d8a9a0578c9cfd).\n\nFilesystem:\n\n```diff\n-[\"/\", \"/package.json\"]\n+[\"/\", \"/package.js\"]\n```\n\n### ❌ Example of incorrect code\n\n```json\n{\n    \"plugins\": []\n}\n```\n\n### ✅ Example of correct code\n\n```js\nexport default {\n    plugins: [],\n};\n```\n\n## convert-js-to-json\n\nCheckout in 🐊**Putout Editor**:\n\n- [**Replacer**](https://putout.cloudcmd.io/#/gist/1d24f6b52a49cfecbfe104982d292244/a469d79ca6bc296eeb94af0712e5841d79aac237);\n- [**Scanner**](https://putout.cloudcmd.io/#/gist/f0f290d79b06d718d13252d05ee739e7/3f063d9b62fe20fd26579792549a7deb32cd987a);\n\nFilesystem:\n\n```diff\n-[\"/\", \"/package.js\"]\n+[\"/\", \"/package.json\"]\n```\n\n### ❌ Example of incorrect code\n\n```json\n{\n    \"plugins\": []\n}\n```\n\n### ✅ Example of correct code\n\n```js\nexport default {\n    plugins: [],\n};\n```\n\n## License\n\nMIT\n","publish_time":1738847636197,"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"_cnpm_publish_time":1738847636197,"dist-tags":{"latest":"13.6.0"}}