|
1 | 1 | # vue-codemod
|
2 |
| -Vue codemod scripts |
| 2 | + |
| 3 | +**Current status: pre-MVP, not usable** |
| 4 | + |
| 5 | +This repository contains a collection of codemod scripts for use with [JSCodeshift](https://github.com/facebook/jscodeshift) that help update Vue.js APIs. |
| 6 | + |
| 7 | +Inspired by [react-codemod](https://github.com/reactjs/react-codemod). |
| 8 | + |
| 9 | +## Usage |
| 10 | + |
| 11 | +`npx vue-codemod -t <transformation> -f <path> [...options] |
| 12 | + |
| 13 | +- `transformation` - name of transformation, see available transformations below. Or you can provide a path to a custom transformation module. |
| 14 | +- `path` - files or directory to transform |
| 15 | +- use the `--dry` options for a dry-run |
| 16 | + |
| 17 | +## TODOs |
| 18 | + |
| 19 | +(Sort by priority) |
| 20 | + |
| 21 | +- [ ] Basic testing setup and an MVP |
| 22 | +- [ ] Define an interface for transformation of template blocks |
| 23 | +- [ ] Automatically apply transformations to `.vue` file without explicitly depending on `vue-jscodeshift-adapter` (should open source this repo after finishing this one) |
| 24 | +- [ ] A playground for writing transformations |
| 25 | +- [ ] Implement more transformations for [active RFCs](https://github.com/vuejs/rfcs/tree/master/active-rfcs) |
| 26 | +- [ ] Support `.ts` and `<script lang="ts">` |
| 27 | + |
| 28 | +## Included Transformations |
| 29 | + |
| 30 | +### rfc-0009 |
| 31 | + |
| 32 | +Alias of [`new-vue-to-create-app`](#new-vue-to-create-app) |
| 33 | + |
| 34 | +### rfc-0013 |
| 35 | + |
| 36 | +**WIP** |
| 37 | +Runs [`object-to-composition-api`](#object-to-composition-api) |
| 38 | + |
| 39 | +### new-vue-to-create-app |
| 40 | + |
| 41 | +Implements [RFC-0009 Global API Change](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0009-global-api-change.md). |
| 42 | +Converts `new Vue(...).$mount('#app')` calls to `createApp(...).mount(App, '#app')`. |
| 43 | + |
| 44 | +### object-to-composition-api |
| 45 | + |
| 46 | +**WIP** |
| 47 | +Implements [RFC-0013 Composition API](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0013-composition-api.md). |
| 48 | +Migrated from https://github.com/vuejs/function-api-converter |
| 49 | + |
| 50 | +## Custom Transformation |
| 51 | + |
| 52 | +TODO |
| 53 | + |
| 54 | +## Post Transformation |
| 55 | + |
| 56 | +- Running transformations will generally ruin the formatting of your files. A recommended way to solve that problem is by using [Prettier](https://prettier.io/) or `eslint --fix`. |
| 57 | +- Even after running prettier its possible to have unnecessary new lines added/removed. This can be solved by ignoring white spaces while staging the changes in git. |
| 58 | + |
| 59 | +```sh |
| 60 | +git diff --ignore-blank-lines | git apply --cached |
| 61 | +``` |
0 commit comments