Skip to content

Commit

Permalink
chore: fix codemod runner
Browse files Browse the repository at this point in the history
  • Loading branch information
HeartSquared committed Oct 29, 2024
1 parent 2974a4e commit 7bdab38
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/components/bin/codemod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ echo "Attempting to run codemod '$codemodFileName' on the dir:"
echo "$TARGET_DIR"
echo ""

if npx tsx $CODEMOD_PATH $TARGET_DIR; then
if npm exec tsx@^4.19.2 -y $CODEMOD_PATH $TARGET_DIR; then
echo "Codemod '$codemodFileName' completed successfully in directory '$transformDir'"
else
echo "Codemod '$codemodFileName' could not be run in '$TARGET_DIR'"
Expand Down
9 changes: 4 additions & 5 deletions packages/components/codemods/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@ This directory is a collection of codemods that can be executed via CLI with the

## Prerequisites

- Install `@kaizen/components`
- The codemod runner script uses [npx](https://docs.npmjs.com/cli/v10/commands/npx) to run [tsx](https://tsx.is/getting-started)
Install `@kaizen/components`

## CLI pattern

_Note: This uses npx, so do not run this with pnpm/yarn_
_Note: Navigate into your package which has installed `@kaizen/components` then run the codemod script._

```
kaizen-codemod {DIR} {CODEMOD_NAME}
pnpm kaizen-codemod {DIR} {CODEMOD_NAME}
```

DIR - the directory to run the codemod for. Note that node_modules are excluded.
CODEMOD_NAME - the name of the codemod (refer to list below).

Example:
```
kaizen-codemod src migrateWellVariantToColor
pnpm kaizen-codemod src migrateWellVariantToColor
```

## Available codemods
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/Icon/bin/update-icons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

pnpm svgo -f ./assets/svgs/icons -o ./src/Icon/bin/built-svgs/

npx tsx ./src/Icon/bin/wrapSVGs.ts --source-dir ./src/Icon/bin/built-svgs --output-dir ./src/Icon --delete-source-dir
pnpm tsx ./src/Icon/bin/wrapSVGs.ts --source-dir ./src/Icon/bin/built-svgs --output-dir ./src/Icon --delete-source-dir

pnpm prettier -w ./src/Icon

0 comments on commit 7bdab38

Please sign in to comment.