{"name":"@atlaskit/codemod-utils","version":"4.2.4","author":{"name":"Atlassian Pty Ltd"},"license":"Apache-2.0","description":" jscodeshift-compatible codemod utilities","publishConfig":{"registry":"https://registry.npmjs.org/"},"atlassian":{"team":"UIP: Frontend Delivery","inPublicMirror":false,"releaseModel":"continuous"},"repository":{"type":"git","url":"git+https://bitbucket.org/atlassian/atlassian-frontend-mirror.git"},"main":"dist/cjs/index.js","module":"dist/esm/index.js","module:es2019":"dist/es2019/index.js","types":"dist/types/index.d.ts","typesVersions":{">=4.5 <4.9":{"*":["dist/types-ts4.5/*","dist/types-ts4.5/index.d.ts"]}},"sideEffects":false,"atlaskit:src":"src/index.ts","af:exports":{".":"./src/index.ts"},"dependencies":{"@babel/runtime":"^7.0.0"},"devDependencies":{"@atlassian/atlassian-frontend-prettier-config-1.0.0":"npm:@atlassian/atlassian-frontend-prettier-config@1.0.0","@types/jscodeshift":"^0.11.0","jscodeshift":"^0.13.0","typescript":"~5.4.2"},"techstack":{"@atlassian/frontend":{"import-structure":["atlassian-conventions"],"circular-dependencies":["file-and-folder-level"]},"@repo/internal":{"analytics":["analytics-next"],"design-tokens":["color"],"theming":["react-context"],"ui-components":["lite-mode"],"deprecation":["no-deprecated-imports"]}},"prettier":"@atlassian/atlassian-frontend-prettier-config-1.0.0","_id":"@atlaskit/codemod-utils@4.2.4","gitHead":"f2f44ca0109a519443a64d03cf61abbeb976e27b","bugs":{"url":"https://bitbucket.org/atlassian/atlassian-frontend-mirror/issues"},"homepage":"https://bitbucket.org/atlassian/atlassian-frontend-mirror#readme","_nodeVersion":"18.19.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-ETeLShTnEpLvsEhm0wmIlC7toRPy9hrMGbttdsiKzyUeGQQ3VqBxvOOPZNA6Uvi0660Jjd3lS7n5u7R/Ku0OHg==","shasum":"995a8060486f35bf77b8114b863688e551641eb1","tarball":"http://registry-npm.ywwl.com/@atlaskit/codemod-utils/download/@atlaskit/codemod-utils-4.2.4.tgz","fileCount":20,"unpackedSize":114932,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCFrPesPRqW4e0YM9jbVWD4vYFduijHnGN8Il21rhl1rQIgVfioQJPzp38lMQse4ULbRguYAsYtQh4rk9pUYEIxxL8="}],"size":15849,"noattachment":false,"key":"/@atlaskit/codemod-utils/-/@atlaskit/codemod-utils-4.2.4.tgz"},"_npmUser":{"name":"atlaskit","email":"afp-repo-bot@atlassian.com"},"directories":{},"maintainers":[{"name":"atlaskit","email":"afp-repo-bot@atlassian.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/codemod-utils_4.2.4_1710917628306_0.19176551247374207"},"_hasShrinkwrap":false,"readme":"## Home for codemods\n\nAs part of lite mode conversion for components in atlaskit, we found `codemods` with [jscodeshift](https://github.com/facebook/jscodeshift) are extremely helpful for migrating some breaking changes for our consumers. However, one pain point for us who need to write and maintain them is that we have to copy-paste the code snippet in many places.\n\nSo the purpose of this package is to relief that pain and centric all reusable `codemods` snippets into a single place, and all the further changes should happen in this repo only.\n\nThe goal is to release this repo as a npm package, so our users can simply introduce those generic functions and compose in their codebase.\n\n### Examples\n\nFor example, when you want to depracate a prop called `isLoading` from your consumer's codebase, you can introduce some helper function into a file `transformer.ts` from `@atlaskit/codemod-utils`:\n\n```js\nimport {\n  createRemoveFuncFor,\n  createTransformer,\n} from '@atlaskit/codemod-utils';\n\nconst removeIsLoading = createRemoveFuncFor(\n  '@atlaskit/fancycomponent',\n  'ComponentName',\n  'isLoading',\n);\n\nconst transformer = createTransformer([removeIsLoading]);\n\nexport default transformer;\n```\n\nAnd then run the `transformer` like:\n\n```sh\nnpx jscodeshift -t transformer.ts  --ignore-pattern node_modules --parser babel --extensions ts path/to/your/codebase\n```\n\n### Advanced usage\n\nIf you need more than one mutation against your codebase and want to apply all of them in one go, it's recommended to structure them properly into a separate folder.\n\nFor example, if you need 3 separate steps:\n\n- remove `isLoading` prop\n- rename `isDefaultChecked` to `defaultChecked`\n- add a new prop `title`\n\nthen you can have a folder called `migrates` that contains:\n\n- remove-isLoading.ts\n- rename-isDefaultChecked-to-defaultChecked.ts\n- add-title.ts\n\nand for each file, you can have some code like:\n\n```js\nimport { createAddingPropFor } from '@atlaskit/codemod-utils';\n\nexport const addTitle = createAddingPropFor('@atlaskit/fancycomponent', {\n  prop: 'title',\n  defaultValue: '',\n});\n```\n\nand in your entrypoint for `jscodeshift` to pick up, you can introduce all those migrates:\n\n```js\nimport { addTitle } from './migrates/add-title';\nimport { removeIsLoading } from './migrates/remove-isLoading';\nimport { renameDefaultChecked } from './migrates/rename-isDefaultChecked-to-defaultChecked.ts';\n\nimport { createTransformer } from './utils';\n\nconst transformer = createTransformer([\n  renameDefaultChecked,\n  removeIsLoading,\n  addTitle,\n]);\n\nexport default transformer;\n```\n\nThis way, you can easily test those migrates separately with all the possible scenario, and compose them freely as well to see if they can work together to make the whole transform.\n","publish_time":1710917628491,"_cnpm_publish_time":1710917628491,"dist-tags":{"latest":"5.1.0","next":"4.2.2"}}