Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/caseywatts/ember-cli-mirage-faker-codemod
https://github.com/caseywatts/ember-cli-mirage-faker-codemod
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/caseywatts/ember-cli-mirage-faker-codemod
- Owner: caseywatts
- Created: 2018-08-20T19:22:17.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-04-23T22:42:08.000Z (over 5 years ago)
- Last Synced: 2024-08-02T07:22:45.865Z (3 months ago)
- Language: JavaScript
- Size: 110 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-codemods - ember-cli-mirage-faker-codemod
README
This codemod is to help transition from importing `faker` through `ember-cli-mirage`, to instead import it directly from `faker`.
For more background on the situation, see [this github issue](https://github.com/samselikoff/ember-cli-mirage/issues/1037#issuecomment-411452618).
## How To Remove The Faker Dependency
### Install faker and ember-auto-import
```
yarn add faker
git add . && git commit -m "adding faker package"
ember install ember-auto-import
git add . && git commit -m "installing ember-auto-import package"
```add to your `ember-cli-build.js`:
```
autoImport: {
alias: {
'faker': 'build/build/faker'
}
}
``````
git add . && git commit -m "telling ember-cli-build where to find faker"
```### Run the codemod
This example will run the codemod on all files in the `./tests` folder. Then you can selectively check in as many changes as you'd like to keep (try `git add -p`!).```
npm install -g jscodeshift
jscodeshift -t https://raw.githubusercontent.com/caseywatts/ember-cli-mirage-faker-codemod/master/transform.js ./tests
```- If you find additional edge cases, please clone this repo and contribute :D
- Don't be afraid of codemods, check out Casey's [tutorial](https://caseywatts.com/2018/08/23/codemods.html)## How do codemods even?
If this is your first codemod (it's mine!), [I wrote a lot about how I got up and running with codemods - check it out!](https://caseywatts.com/2018/08/23/codemods.html)
## Development
```
git clone https://github.com/caseywatts/ember-cli-mirage-faker-codemod`
cd ember-cli-mirage-faker-codemod`
npm install
npm test
npm run codemod path/to/directories/or/files/you/want
```Make sure to add test cases to the `__testfixtures__` (see the [tutorial](https://caseywatts.com/2018/08/23/codemods.html) for details).