Coder Social home page Coder Social logo

rajasegar / ember-native-class-codemod Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ember-codemods/ember-native-class-codemod

0.0 2.0 0.0 967 KB

A codemod-cli project for converting Ember objects to es6 native classes

JavaScript 100.00%

ember-native-class-codemod's Introduction

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 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

ember-native-class-codemod's People

Contributors

dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar eventualbuddha avatar pzuraq avatar rwjblue avatar scalvert avatar ssutar avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.