You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| --type | String | Empty (match all types in path) | Apply transformation to only passed type. The type can be one of `services`, `routes`, `components`, `controllers`|
| --classic-decorator | boolean | true | Enable/disable adding the [`@classic` decorator](https://github.com/pzuraq/ember-classic-decorator), which helps with transitioning Ember Octane |
25
+
| --type | String | Empty (match all types in path) | Apply transformation to only passed type. The type can be one of `services`, `routes`, `components`, `controllers`|
26
+
| --quote | String | 'single' | Whether to use double or single quotes by default for new statements that are added during the codemod. |
23
27
24
-
### Class Fields
28
+
### Gathering Runtime Data
25
29
26
-
Class fields are currently defined as a [stage 3 proposal](https://github.com/tc39/proposal-class-fields) in the [ECMA TC39 process](https://tc39.github.io/process-document/). As such, they are added as a configurable option in the transforms, enabled by default. If set to **false**, it will NOT transform the object properties to class fields but instead error out.
30
+
The first argument that you must pass to the codemod is the URL of a running
31
+
instance of your application. The codemod opens up your application and analyzes
32
+
the classes directly, so it can transform them, which is why it needs this URL.
33
+
Any classes that were not analyzed will not be transformed. This includes
34
+
classes that are private to a module and never exported.
27
35
28
-
For example, the below declaration
29
-
30
-
```
31
-
const Foo = EmberObject.extend({
32
-
prop: "defaultValue",
33
-
});
34
-
```
35
-
36
-
Will be transformed to
37
-
38
-
```
39
-
class Foo extends EmberObject {
40
-
prop = "defaultValue";
41
-
}
42
-
```
43
-
44
-
### Decorators
45
-
46
-
Decorators are currently a [stage 2 proposal](https://github.com/tc39/proposal-decorators) in the [ECMA TC39 process](https://tc39.github.io/process-document/). They are added as a configurable option in the transforms. If set to true, it will transform the object's properties to decorators wherever required.
47
-
48
-
For example, the below declaration
49
-
50
-
```
51
-
import { inject as service } from "@ember/service";
52
-
const Foo = EmberObject.extend({
53
-
store: service(),
54
-
});
55
-
```
56
-
57
-
Will be transformed to
58
-
59
-
```
60
-
import { service } from "@ember-decorators/service";
61
-
class Foo extends EmberObject {
62
-
@service store;
63
-
}
64
-
```
65
-
66
-
**Note** The decorators support is built into Ember by way of [email protected] or higher.
36
+
If you have any _lazily loaded_ modules, such as modules from Ember Engines,
37
+
you'll need to make sure that the URL you provide loads these modules as well.
38
+
Otherwise, the codemod will not be able to detect them or analyze them.
67
39
68
40
### Types
69
41
70
-
The option `type` can be used to further target transforms to a particular type of ember object within the application or addon. The types can be any of the following:
42
+
The `type` option can be used to further transforms to a particular type of
43
+
ember object within the application or addon. The types can be any of the
44
+
following:
71
45
72
46
| Type | Option |
73
47
| ----------- | ------------------ |
@@ -76,35 +50,39 @@ The option `type` can be used to further target transforms to a particular type
76
50
| Components | --type=components |
77
51
| Controllers | --type=controllers |
78
52
79
-
The path of the file being transformed is matched against the glob pattern of the type to determine whether to run the specific transforms.
80
-
81
-
If a type is not provided, the codemods will run against all the **_types_** in the path provided.
82
-
83
-
### Runtime Config
53
+
The path of the file being transformed is matched against the glob pattern of
54
+
the type to determine whether to run the specific transforms.
84
55
85
-
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.
86
-
87
-
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.
56
+
If a type is not provided, the codemods will run against all the **_types_** in
57
+
the path provided.
88
58
89
59
## Debugging
90
60
91
-
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.
61
+
The codemods log execution information in the `codemods.log` file in the current
62
+
directory where the codemods are being executed. Specifically, details such as
63
+
failures and reasons for failures, are logged. This would be the recommended
64
+
starting point for debugging issues related to these codemods.
92
65
93
66
## Unsupported Types
94
67
95
-
While the codemods transforms all types of ember objects, it does not support transformation of
68
+
While the codemods transforms many types of ember objects, it does not support
69
+
transformation of
96
70
97
-
-`ember-data`entities for example`DS.Model`, `DS.Adapter` etc
71
+
-`ember-data`classes such as`DS.Model`, `DS.Adapter` etc
98
72
- Mixins
99
-
- Ember Object having a property with `ObjectExpression` as value (`actions` and `queryParams` are exception) See `eslint-plugin-ember/avoid-leaking-state-in-ember-objects` for more details.
100
-
- Ember object having property with `meta` or `property` modifiers
73
+
- Ember Objects with objects or arrays as direct properties (`actions` and
74
+
`queryParams` are the exception). See `eslint-plugin-ember/avoid-leaking-state-in-ember-objects`
75
+
for more details.
76
+
- Ember objects with computed properties that use the `meta` or `property`
0 commit comments