Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Improve codemod related documentation #12582

Merged
merged 6 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ You can run `v7.0.0/data-grid/preset-safe` targeting only Data Grid or `v7.0.0/p

You can either run it on a specific file, folder, or your entire codebase when choosing the `<path>` argument.

<!-- #default-branch-switch -->

```bash
// Data Grid specific
npx @mui/x-codemod v7.0.0/data-grid/preset-safe <path>
npx @mui/x-codemod@latest v7.0.0/data-grid/preset-safe <path>
MBilalShafi marked this conversation as resolved.
Show resolved Hide resolved

// Target other MUI X components as well
npx @mui/x-codemod v7.0.0/preset-safe <path>
npx @mui/x-codemod@latest v7.0.0/preset-safe <path>
```

:::info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ The `preset-safe` codemod will automatically adjust the bulk of your code to acc

You can either run it on a specific file, folder, or your entire codebase when choosing the `<path>` argument.

<!-- #default-branch-switch -->

```bash
// Date and Time Pickers specific
npx @mui/x-codemod v7.0.0/pickers/preset-safe <path>
npx @mui/x-codemod@latest v7.0.0/pickers/preset-safe <path>

// Target Data Grid as well
npx @mui/x-codemod v7.0.0/preset-safe <path>
npx @mui/x-codemod@latest v7.0.0/preset-safe <path>
```

:::info
Expand Down Expand Up @@ -105,7 +107,7 @@ And are removed from the v7.
If not already done, this modification can be handled by the codemod

```bash
npx @mui/x-codemod v7.0.0/pickers/ <path>
npx @mui/x-codemod@latest v7.0.0/pickers/ <path>
```

Take a look at [the RFC](https://github.com/mui/material-ui/issues/33416) for more information.
Expand Down
34 changes: 17 additions & 17 deletions packages/x-codemod/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This repository contains a collection of codemod scripts based for use with
<!-- #default-branch-switch -->

```bash
npx @mui/x-codemod <codemod> <paths...>
npx @mui/x-codemod@latest <codemod> <paths...>

Applies a `@mui/x-codemod` to the specified paths

Expand All @@ -29,8 +29,8 @@ Options:
--jscodeshift Pass options directly to jscodeshift [array]

Examples:
npx @mui/x-codemod v6.0.0/preset-safe src
npx @mui/x-codemod v6.0.0/component-rename-prop src --
npx @mui/x-codemod@latest v7.0.0/preset-safe src
npx @mui/x-codemod@latest v6.0.0/component-rename-prop src --
--component=DataGrid --from=prop --to=newProp
```

Expand All @@ -40,9 +40,9 @@ To pass more options directly to jscodeshift, use `--jscodeshift=...`. For examp

```bash
// single option
npx @mui/x-codemod --jscodeshift=--run-in-band
npx @mui/x-codemod@latest --jscodeshift=--run-in-band
// multiple options
npx @mui/x-codemod --jscodeshift=--cpus=1 --jscodeshift=--print --jscodeshift=--dry --jscodeshift=--verbose=2
npx @mui/x-codemod@latest --jscodeshift=--cpus=1 --jscodeshift=--print --jscodeshift=--dry --jscodeshift=--verbose=2
```

See all available options [here](https://github.com/facebook/jscodeshift#usage-cli).
Expand All @@ -53,7 +53,7 @@ Options to [recast](https://github.com/benjamn/recast)'s printer can be provided
through jscodeshift's `printOptions` command line argument

```bash
npx @mui/x-codemod <transform> <path> --jscodeshift="--printOptions='{\"quote\":\"double\"}'"
npx @mui/x-codemod@latest <transform> <path> --jscodeshift="--printOptions='{\"quote\":\"double\"}'"
```

## v7.0.0
Expand All @@ -66,7 +66,7 @@ It runs codemods for both Data Grid and Date and Time Pickers packages.
To run codemods for a specific package, refer to the respective section.

```bash
npx @mui/x-codemod v7.0.0/preset-safe <path|folder>
npx @mui/x-codemod@latest v7.0.0/preset-safe <path|folder>
```

The corresponding sub-sections are listed below
Expand All @@ -82,7 +82,7 @@ The corresponding sub-sections are listed below
The `preset-safe` codemods for pickers.

```bash
npx @mui/x-codemod v7.0.0/pickers/preset-safe <path|folder>
npx @mui/x-codemod@latest v7.0.0/pickers/preset-safe <path|folder>
```

The list includes these transformers
Expand All @@ -108,7 +108,7 @@ This change only affects Date and Time Picker components.
```

```bash
npx @mui/x-codemod v7.0.0/pickers/rename-components-to-slots <path>
npx @mui/x-codemod@latest v7.0.0/pickers/rename-components-to-slots <path>
```

#### `rename-default-calendar-month-to-reference-date`
Expand All @@ -121,7 +121,7 @@ Replace the `defaultCalendarMonth` prop with the `referenceDate` prop.
```

```bash
npx @mui/x-codemod v7.0.0/pickers/rename-default-calendar-month-to-reference-date <path>
npx @mui/x-codemod@latest v7.0.0/pickers/rename-default-calendar-month-to-reference-date <path>
```

#### `rename-day-picker-classes`
Expand All @@ -134,7 +134,7 @@ Rename the `dayPickerClasses` variable to `dayCalendarClasses`.
```

```bash
npx @mui/x-codemod v7.0.0/pickers/rename-day-picker-classes <path>
npx @mui/x-codemod@latest v7.0.0/pickers/rename-day-picker-classes <path>
```

#### `rename-slots-types`
Expand All @@ -149,7 +149,7 @@ Replace types suffix `SlotsComponent` by `Slots` and `SlotsComponentsProps` by `
```

```bash
npx @mui/x-codemod v7.0.0/pickers/rename-slots-types <path>
npx @mui/x-codemod@latest v7.0.0/pickers/rename-slots-types <path>
```

### Data Grid codemods
Expand All @@ -159,7 +159,7 @@ npx @mui/x-codemod v7.0.0/pickers/rename-slots-types <path>
The `preset-safe` codemods for data grid.

```bash
npx @mui/x-codemod v7.0.0/data-grid/preset-safe <path|folder>
npx @mui/x-codemod@latest v7.0.0/data-grid/preset-safe <path|folder>
```

The list includes these transformers
Expand All @@ -184,7 +184,7 @@ This change only affects Data Grid components.
```

```bash
npx @mui/x-codemod v7.0.0/data-grid/rename-components-to-slots <path>
npx @mui/x-codemod@latest v7.0.0/data-grid/rename-components-to-slots <path>
```

#### `rename-cell-selection-props`
Expand All @@ -203,7 +203,7 @@ Rename props related to `cellSelection` feature.
```

```bash
npx @mui/x-codemod v7.0.0/data-grid/rename-cell-selection-props <path>
npx @mui/x-codemod@latest v7.0.0/data-grid/rename-cell-selection-props <path>
```

#### `remove-stabilized-v7-experimentalFeatures`
Expand All @@ -222,7 +222,7 @@ Remove feature flags for stabilized `experimentalFeatures`.
```

```bash
npx @mui/x-codemod@next v7.0.0/data-grid/remove-stabilized-experimentalFeatures <path>
npx @mui/x-codemod@latest v7.0.0/data-grid/remove-stabilized-experimentalFeatures <path>
```

### Tree View codemods
Expand All @@ -232,7 +232,7 @@ npx @mui/x-codemod@next v7.0.0/data-grid/remove-stabilized-experimentalFeatures
The `preset-safe` codemods for tree view.

```bash
npx @mui/x-codemod v7.0.0/tree-view/preset-safe <path|folder>
npx @mui/x-codemod@latest v7.0.0/tree-view/preset-safe <path|folder>
```

The list includes these transformers
Expand Down