Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bwittenbrook3/ember-computed-decorators-codemod
Codemod to update ember-computed-decorators to ember-decorators
https://github.com/bwittenbrook3/ember-computed-decorators-codemod
Last synced: 3 months ago
JSON representation
Codemod to update ember-computed-decorators to ember-decorators
- Host: GitHub
- URL: https://github.com/bwittenbrook3/ember-computed-decorators-codemod
- Owner: bwittenbrook3
- License: mit
- Created: 2018-09-07T01:53:45.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-10T19:01:04.000Z (over 6 years ago)
- Last Synced: 2024-07-23T19:41:49.946Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 63.5 KB
- Stars: 2
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-codemods - ember-computed-decorators-codemod - Codemod to update ember-computed-decorators to ember-decorators. (Frameworks / Ember.js)
README
# ember-computed-decorators-codemod
This codemod uses [`jscodeshift`](https://github.com/facebook/jscodeshift) to update an Ember application using [`ember-computed-decorators`](https://github.com/ember-decorators/ember-decorators/tree/v0.3.0) to [`ember-decorators`](https://github.com/ember-decorators/ember-decorators). This update allows applications to migrate to babel 6 and beyond without having to rely on the [`babel-plugin-transform-decorators-legacy`](https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy).
For example, it will rewrite code that looks like this:
```js
import Ember from 'ember';
import computed, { alias } from 'ember-computed-decorators';const { Component } = Ember;
export default Component.extend({
@alias('fullName') myFullName,
@computed('firstName', 'lastName')
fullName() {
return `${this.get('firstName')} + ${this.get('lastName')}`
}
})
```Into this:
```js
import Ember from 'ember';
import { computed } from '@ember-decorators/object';
import { alias } from '@ember-decorators/object/computed';const { Component } = Ember;
export default Component.extend({
@alias('fullName') myFullName,
@computed('firstName', 'lastName')
fullName() {
return `${this.get('firstName')} + ${this.get('lastName')}`
}
})
```## Usage
**WARNING**: `jscodeshift`, and thus this codemod, **edit your files in place**.
It does not make a copy. Make sure your code is checked into a source control
repository like Git and that you have no outstanding changes to commit before
running this tool.The simplest way to use the codemod is like this:
```sh
yarn global add ember-computed-decorators-codemod
cd my-ember-app
ember-computed-decorators-codemod
```https://github.com/ember-decorators/auto-computed
### Running Tests
```sh
yarn test // run all tests once
yarn test -- --watchAll // continuously run tests
```Tests for this codemod work by comparing a paired input and output file in the `__testfixtures__` directory. Pre-transform files should be of format `.input.js`, expected output after the transform should be named `.output.js`. Files must use the same `` in their names so they can be compared.
## Credit
All code present in this repo was derived from the excellent work in [`ember-modules-codemod`](https://github.com/ember-cli/ember-modules-codemod).