Skip to content
A codemod-cli project for converting Ember objects to es6 native classes
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin update prettierrc and run eslint --fix Jun 20, 2019
lib update prettierrc and run eslint --fix Jun 20, 2019
test Fix in-repo addon acceptance test. Jun 20, 2019
transforms Fixup typo in method name closet -> closest. (#151) Jun 24, 2019
.eslintignore Add integration test app Jun 18, 2019
.eslintrc.js Split apart and add unit tests for getTelemetryFor. (#127) Jun 20, 2019
.gitignore Add logger for codemods (#24) Nov 2, 2018
.prettierrc.js
.travis.yml bump node version in travis Jun 18, 2019
CHANGELOG.md Release 1.0.1 Jun 23, 2019
README.md Possible typo in the readme (#164) Jul 8, 2019
RELEASE.md Add automated release setup and documentation. Jun 18, 2019
package.json Bump eslint-config-prettier from 5.0.0 to 6.0.0 Jun 26, 2019
yarn.lock

README.md

ember-native-class-codemod

Build Status npm version

A codemod for transforming your ember app code to native JavaScript class syntax with decorators!

Usage

First, install the dependencies that the codemod relies on. These are addons that the codemod will add imports from:

ember install ember-classic-decorator
ember install ember-decorators 

Then, boot up your application. Then, the codemod can be run using the following command:

npx ember-native-class-codemod http://localhost:4200/path/to/server [OPTIONS] path/of/files/ or/some**/*glob.js

The codemod accepts the following options:

Option Value Default Details
--class-fields boolean true Enable/disable transformation using class fields
--decorators boolean true Enable/disable transformation using decorators
--classic-decorator boolean true Enable/disable adding the @classic decorator, which helps with transitioning Ember Octane
--type String Empty (match all types in path) Apply transformation to only passed type. The type can be one of services, routes, components, controllers
--quote String 'single' Whether to use double or single quotes by default for new statements that are added during the codemod.

Gathering Runtime Data

The first argument that you must pass to the codemod is the URL of a running instance of your application. The codemod opens up your application and analyzes the classes directly, so it can transform them, which is why it needs this URL. Any classes that were not analyzed will not be transformed. This includes classes that are private to a module and never exported.

If you have any lazily loaded modules, such as modules from Ember Engines, you'll need to make sure that the URL you provide loads these modules as well. Otherwise, the codemod will not be able to detect them or analyze them.

Types

The type option can be used to further narrow down transforms to a particular type of ember object within the application or addon. The types can be any of the following:

Type Option
Services --type=services
Routes --type=routes
Components --type=components
Controllers --type=controllers

The path of the file being transformed is matched against the glob pattern of the type to determine whether to run the specific transforms.

If a type is not provided, the codemods will run against all the types in the path provided.

Debugging

The codemods log execution information in the codemods.log file in the current directory where the codemods are being executed. Specifically, details such as failures and reasons for failures, are logged. This would be the recommended starting point for debugging issues related to these codemods.

Unsupported Types

While the codemods transforms many types of ember objects, it does not support transformation of

  • ember-data classes such as DS.Model, DS.Adapter etc
  • Mixins
  • Ember Objects with objects or arrays as direct properties (actions and queryParams are the exception). See eslint-plugin-ember/avoid-leaking-state-in-ember-objects for more details.
  • Ember objects with computed properties that use the meta or property modifiers.

More Transform Examples

Contributing

Installation

  • clone the repo
  • change into the repo directory
  • yarn

Running Tests

  • yarn test

Update Documentation

  • yarn update-docs
You can’t perform that action at this time.