Skip to content

Commit 7494c3e

Browse files
author
Robert Jackson
authored
Update README.md to match recent changes. (#121)
Update README.md to match recent changes.
2 parents d391c97 + 184db56 commit 7494c3e

File tree

2 files changed

+8
-52
lines changed

2 files changed

+8
-52
lines changed

README.md

Lines changed: 8 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,23 @@
33
[![Build Status](https://travis-ci.org/ember-codemods/ember-es6-class-codemod.svg?branch=master)](https://travis-ci.org/ember-codemods/ember-es6-class-codemod)
44
[![npm version](https://badge.fury.io/js/ember-es6-class-codemod.svg)](https://badge.fury.io/js/ember-es6-class-codemod)
55

6-
Codemods for transforming ember app code to native ES6 class syntax with decorators
7-
8-
## Installation
9-
10-
```
11-
yarn global add ember-es6-class-codemod
12-
```
6+
Codemods for transforming ember app code to native ES6 class syntax with decorators.
137

148
## Usage
159

16-
The Ember ES6 codemods can be run using the following command
10+
The Ember ES6 codemods can be run using the following command:
1711

1812
```
19-
ember-es6-class-codemod ember-object [OPTIONS] path/of/files/ or/some**/*glob.js
13+
npx ember-es6-class-codemod http://localhost:4200/path/to/server [OPTIONS] path/of/files/ or/some**/*glob.js
2014
```
2115

2216
The codemods accept the following options:
2317

2418
| Option | Value | Default | Details |
2519
| --------------------- | --------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
2620
| --class-fields | boolean | true | Enable/disable transformation using class fields |
27-
| --decorators | boolean | false | Enable/disable transformation using decorators |
21+
| --decorators | boolean | true | Enable/disable transformation using decorators |
2822
| --type | String | Empty (match all types in path) | Apply transformation to only passed type. The type can be one of `services`, `routes`, `components`, `controllers` |
29-
| --runtime-config-path | File path | Empty | Transformation using runtime configuration from the path |
3023

3124
### Class Fields
3225

@@ -57,7 +50,7 @@ For example, the below declaration
5750
```
5851
import { inject as service } from "@ember/service";
5952
const Foo = EmberObject.extend({
60-
b: service("store"),
53+
store: service(),
6154
});
6255
```
6356

@@ -66,12 +59,11 @@ Will be transformed to
6659
```
6760
import { service } from "@ember-decorators/service";
6861
class Foo extends EmberObject {
69-
@service("store")
70-
b;
62+
@service store;
7163
}
7264
```
7365

74-
**Note** The decorators support is not built in inside Ember. Decorators support requires the use of the [ember-decorators](https://github.com/ember-decorators/ember-decorators) addon and should be added as dependency to your application. The codemod takes care of importing required decorators from the `ember-decorators` addon.
66+
**Note** The decorators support is built into Ember by way of ember-cli-babel@7.7.0 or higher.
7567

7668
### Types
7769

@@ -88,47 +80,12 @@ The path of the file being transformed is matched against the glob pattern of th
8880

8981
If a type is not provided, the codemods will run against all the **_types_** in the path provided.
9082

91-
### Runtime Config Path
83+
### Runtime Config
9284

9385
As per conventional codemods, the code is converted from one API to another by statically analyzing patterns within it. While this works well most of the time, there are cases that can only be analyzed at runtime to determine the full shape of the code to transform. For example, if we need to determine the class hierarchy, it is not possible with static analysis to determine the parent classes and their properties.
9486

9587
The codemods are designed with `runtime data` as input to correctly transform the code. For each file currently being transformed, the codemods need a `configuration file`, which will provide additional metadata about the properties of the ember object.
9688

97-
The runtime config path must point to a JSON file containing runtime data of the format:
98-
99-
```
100-
{
101-
data: [{
102-
"/absolute/file/path": {
103-
"computedProperties": ['computedProp1', ...],
104-
"observedProperties": ['observedProp1', ...],
105-
"observerProperties": {
106-
"observerProp1": ["prop1", "prop2", ...]
107-
},
108-
"offProperties": {
109-
"offProp": ["prop3", ...]
110-
},
111-
"overriddenActions": ["overriddenAction1", ...],
112-
"overriddenProperties": ["overriddenProp1"],
113-
"ownProperties": ["prop1", ...],
114-
"type": "Component|Route|Controller|EmberObject",
115-
"unobservedProperties": {
116-
"unobservedProp1": ["prop1", ...]
117-
}
118-
}
119-
}]
120-
}
121-
```
122-
123-
_How to get this runtime data from an ember application_
124-
125-
There are tools available which provide various ways of extracting runtime data. The following are examples:
126-
127-
- [Dyfactor](https://github.com/dyfactor/dyfactor)
128-
- [code-to-json](https://github.com/mike-north/code-to-json)
129-
130-
A [dyfactor plugin](https://github.com/ssutar/ember-es6-class-codemod-dyfactor) has been developed to extract runtime data from an ember application. However any tool which provide the runtime data with the expected format can be used with these codemods.
131-
13289
## Debugging
13390

13491
The codemods log execution information in the `codemods.log` file in the current directory from 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.

transforms/helpers/util/get-telemetry-for.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ for (let packagePath of packagePaths) {
2222
/**
2323
* Get the runtime data for the file being transformed
2424
*
25-
* @param {String} runtimeConfigPath Configuration file path (Absolute)
2625
* @param {String} filePath Absolute path of the file to read data from
2726
* @returns {Object} Runtime configuration object
2827
*/

0 commit comments

Comments
 (0)