proton-WebClients/packages/codeshift
2025-10-11 11:05:17 +00:00
..
src Remove Chargebee migration code 2025-08-29 13:46:18 +00:00
.gitignore Move payment components to payments package batch N + 1 2025-01-31 11:07:29 +00:00
eslint.config.mjs Update packages eslint config 2025-08-27 09:36:07 +00:00
package.json Update dependency typescript to ^5.9.3 2025-10-11 11:05:17 +00:00
README.md Payments refactoring batch n+2 2025-02-05 09:39:53 +00:00
tsconfig.json Move payment components to payments package batch N + 1 2025-01-31 11:07:29 +00:00
tsconfig.transform.json Move payment components to payments package batch N + 1 2025-01-31 11:07:29 +00:00

Codeshift

This package uses jscodeshift to transform code. It can help with large refactors.

Example

Check for example move-coupons. This file changes the COUPON_CODE to @proton/payments package.

How to create a new codemod

  1. Create a new folder in the src directory. Put transform.ts and files.txt in it. In my case, I compiled the list of files manually by running yarn check-types in affected pacakges and then pasting to files.txt and editing the result.

  2. Add new script to package.json, see move:coupons an example. See yarn jscodeshift --help for available options. In particular, you might find --dry and --print helpful during development of the command.

  3. Run the command, e.g. yarn move:coupons. See if it's applied correctly, repeat until done.