{"id":20904694,"url":"https://github.com/sage/carbon-codemod","last_synced_at":"2025-12-29T04:10:09.819Z","repository":{"id":38174746,"uuid":"224166892","full_name":"Sage/carbon-codemod","owner":"Sage","description":"A collection of codemods to help you upgrade carbon-react","archived":false,"fork":false,"pushed_at":"2023-07-18T22:31:54.000Z","size":1992,"stargazers_count":2,"open_issues_count":3,"forks_count":0,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-01-19T14:16:40.472Z","etag":null,"topics":["carbon","carbon-react","codemod","jscodeshift"],"latest_commit_sha":null,"homepage":"http://carbon.sage.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sage.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-26T10:41:57.000Z","updated_at":"2024-07-12T17:34:46.000Z","dependencies_parsed_at":"2024-11-18T13:20:40.024Z","dependency_job_id":null,"html_url":"https://github.com/Sage/carbon-codemod","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sage%2Fcarbon-codemod","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sage%2Fcarbon-codemod/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sage%2Fcarbon-codemod/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sage%2Fcarbon-codemod/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sage","download_url":"https://codeload.github.com/Sage/carbon-codemod/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243295395,"owners_count":20268373,"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":["carbon","carbon-react","codemod","jscodeshift"],"created_at":"2024-11-18T13:18:32.055Z","updated_at":"2025-12-29T04:10:04.787Z","avatar_url":"https://github.com/Sage.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# carbon-codemod [![npm](https://img.shields.io/npm/v/carbon-codemod.svg)](https://www.npmjs.com/package/carbon-codemod)\n\nThis is a collection of codemods that help you upgrade to a new version of `carbon-react`.\nThe release notes of `carbon-react` will indicate which codemod you should use.\n\n## Usage\n\n```\nnpx carbon-codemod \u003cname-of-codemod\u003e \u003ctarget\u003e\n```\n\n- [`add-prop`](./transforms/add-prop)\n- [`button-destructive`](./transforms/button-destructive)\n- [`deprecate-create`](./transforms/deprecate-create)\n- [`dialog-full-screen-app-wrapper`](./transforms/dialog-full-screen-app-wrapper)\n- [`message-remove-classic-theme`](./transforms/message-remove-classic-theme)\n- [`move-experimental-components`](./transforms/move-experimental-components)\n- [`move-pod-description-to-content`](./transforms/move-pod-description-to-content)\n- [`remove-prop`](./transforms/remove-prop)\n- [`rename-prop`](./transforms/rename-prop)\n- [`replace-collapsible-pod-with-accordion`](./transforms/replace-collapsible-pod-with-accordion)\n- [`replace-flash-with-toast`](./transforms/replace-flash-with-toast)\n- [`replace-prop-value`](./transforms/replace-prop-value)\n- [`replace-row-column-with-grid`](./transforms/replace-row-column-with-grid)\n- [`tile-update-padding-prop`](./transforms/tile-update-padding-prop)\n\nNote that `\u003ctarget\u003e` is worked out relative to the current working directory.\n\nMake sure that the codemod is not being run in a folder containing a `package.json` file,\nas it may fail reporting missing dependencies.\n\nFor TypeScript codebase conversion use the `--typescript` option:\n\n```\nnpx carbon-codemod \u003cname-of-codemod\u003e \u003ctarget\u003e --typescript\n```\n\nList of codemods with TypeScript support:\n\n- [`message-remove-classic-theme`](./transforms/message-remove-classic-theme)\n- [`move-experimental-components`](./transforms/move-experimental-components)\n- [`rename-prop`](./transforms/rename-prop)\n- [`remove-prop`](./transforms/remove-prop)\n- [`replace-row-column-with-grid`](./transforms/replace-row-column-with-grid)\n\n\n## Development\n\n`carbon-codemod` is a wrapper around [`jscodeshift`](https://github.com/facebook/jscodeshift).\n\n### Running locally\n\n- `npm link`\n- `cd my-other-project`\n- `npm link carbon-codemod`\n- `npx carbon-codemod \u003cname-of-codemod\u003e \u003ctarget\u003e`\n\n### Debugging\n\nTo debug the CLI\n\n- `node --inspect-brk ./bin/carbon-codemod`\n- Open the command palette and select \"\u003e Debug: Attach to Node Process (preview)\"\n- You can add addition arguments as required e.g. `node --inspect-brk ./bin/carbon-codemod --version`\n\nIt's also possible to debug the tests\n\n- Open the spec file\n- Use `Run Current Spec` in the \"Run\" pane\n- You can use the \"Debug Console\" to interact with the debugger\n\nYou can use [astexplorer.net](https://astexplorer.net/) to help understand the existing structure of files. You should use the following settings:\n\n- parser: `esprima` for js or `@babel/parser` for TypeScript\n- transform: `jscodeshift`\n\n### Transformation Status\n\nThe return value of the function determines the status of the transformation:\n\n| Status     | Condition                                                          | Successful         |\n| ---------- | ------------------------------------------------------------------ | ------------------ |\n| ok         | A string is returned and it is different from passed source        | :white_check_mark: |\n| skipped    | If nothing is returned, the file is not supposed to be transformed | :white_check_mark: |\n| unmodified | If a string is returned but it's the same as the source            | :x:                |\n| error      | If the transform throws an Exception                               | :x:                |\n\n### Testing\n\n- `npm test`\n- It's important to test that each codemod is idempotent.\n- Use `defineTest` to write new tests, this will create a fixture test and an idempotent test.\n- A codemod should convert both javascript and TypeScript projects.\n\n### Releasing\n\n- This project publishes using [`semantic-release`](https://semantic-release.gitbook.io/semantic-release/).\n- It follows [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/).\n- When a pull request is merged to master Github Actions will run `semantic-release`.\n- `semantic-release` will decide, based on the commits that have been merged, if a new release\n  is required.\n- If a new release is required, a new version will be published to [npm](https://www.npmjs.com/package/carbon-codemod) and [GitHub releases](https://github.com/Sage/carbon-codemod/releases).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsage%2Fcarbon-codemod","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsage%2Fcarbon-codemod","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsage%2Fcarbon-codemod/lists"}