{"id":13532126,"url":"https://github.com/jurassix/refactoring-codemods","last_synced_at":"2025-05-09T01:33:57.169Z","repository":{"id":57352028,"uuid":"59240392","full_name":"jurassix/refactoring-codemods","owner":"jurassix","description":"Refactoring support for JavaScript via jscodeshift codemods","archived":false,"fork":false,"pushed_at":"2018-05-09T02:32:10.000Z","size":110,"stargazers_count":80,"open_issues_count":5,"forks_count":15,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-17T06:46:10.800Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jurassix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-19T20:29:39.000Z","updated_at":"2024-11-22T03:29:35.000Z","dependencies_parsed_at":"2022-09-15T02:02:02.258Z","dependency_job_id":null,"html_url":"https://github.com/jurassix/refactoring-codemods","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jurassix%2Frefactoring-codemods","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jurassix%2Frefactoring-codemods/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jurassix%2Frefactoring-codemods/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jurassix%2Frefactoring-codemods/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jurassix","download_url":"https://codeload.github.com/jurassix/refactoring-codemods/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253174978,"owners_count":21865949,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T07:01:08.388Z","updated_at":"2025-05-09T01:33:57.116Z","avatar_url":"https://github.com/jurassix.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","others"],"sub_categories":[],"readme":"# refactoring-codemods\n\nQuest for IDE refactoring support within JavaScript via jscodeshift codemods.\n\nRefactoring a large JavaScript codebase is no fun. Moving files around, renaming files or renaming exported functions simply breaks all dependents import/require paths, and is a huge pain to correct. Simple search and replace is NOT a good solution.\n\nCodemods to the rescue :rocket: With the power of an AST we can determine which files in our project have previously depended on either the rename/moved file or renamed export, and automatically update the dependent code.\n\nThree transforms are provided as low-level AST transforms for achieve either a file rename/move or a file export rename.\n\n_The API of this library is designed to be integrated with an IDE that leverages these transforms to update user code transparently._\n\n### Install\n\nInstall **codemods** via npm:\n\n```javascript\n\u003e yarn add refactoring-codemods\n```\n\n## Transforms\n\n### import-declaration-transform\n\nFix all dependent import/require paths when a file has been renamed/moved.\n\nCall this transform on your source/test files and all dependents import/require paths will be updated to match the new file name/location.\n\n_Note: prevFilePath and nextFilePath are absolute_\n\n```sh\n\u003e jscodeshift \\\n  -t import-declaration-transform \\\n  fileA fileB \\\n  --prevFilePath=/Users/jurassix/example/bar.js \\\n  --nextFilePath=/Users/jurassix/example/new/path/to/bar.js\n```\n\nExample:\n\n```js\nimport foo from './bar';\n```\n\n becomes\n\n ```js\nimport foo from './new/path/to/bar';\n ```\n\n### import-relative-transform\n\nFix all relative import/require paths when a file has been renamed/moved.\n\nCall this transform on the single file that is being moved to a new location and all relative import/require paths will be updated to match the new file name/location.\n\n_Note: prevFilePath and nextFilePath are absolute_\n\n```sh\n\u003e jscodeshift \\\n  -t import-relative-transform \\\n  bar.js \\\n  --prevFilePath=/Users/jurassix/example/old/path/to/bar.js \\\n  --nextFilePath=/Users/jurassix/example/new/path/to/bar.js\n```\n\nExample:\n\n```js\nimport foo from '../../foo';\n```\n\n becomes\n\n ```js\nimport foo from '../../../../old/path/foo';\n ```\n\n### import-specifier-transform\n\nFix all dependent import/require variables when a file export been renamed.\n\nCall this transform on your source/test files and all dependents import/require variables will be updated to match the new file export name.\n\n_Note: declarationFilePath is absolute_\n\n```js\n\u003e jscodeshift \\\n  -t import-specifier-transform \\\n  fileA fileB \\\n  --prevSpecifier=foo \\\n  --nextSpecifier=fooPrime \\\n  --declarationFilePath=/Users/jurassix/example/bar.js\n```\n\nExample:\n\n```js\nimport foo from './bar';\n\nfoo();\n```\n\n becomes\n\n ```js\nimport fooPrime from './bar';\n\nfooPrime();\n ```\n\n## Contribute\n\n### Build\n```sh\n\u003e yarn build\n```\n\n### Run tests\n```sh\n\u003e yarn test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjurassix%2Frefactoring-codemods","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjurassix%2Frefactoring-codemods","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjurassix%2Frefactoring-codemods/lists"}