ember-codemod-pod-to-octane 2.0.8 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -13
- package/dist/bin/ember-codemod-pod-to-octane.js +1 -1
- package/dist/src/index.js +4 -8
- package/dist/src/migration/{ember-app → app}/index.js +1 -1
- package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/app/map-component-classes.js +3 -2
- package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/app/map-component-stylesheets.js +3 -2
- package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/app/map-component-templates.js +3 -2
- package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/app/map-route-adapters.js +3 -2
- package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/app/map-route-controllers.js +3 -2
- package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/app/map-route-models.js +3 -2
- package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/app/map-route-routes.js +3 -2
- package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/app/map-route-serializers.js +3 -2
- package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/app/map-route-stylesheets.js +4 -2
- package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/app/map-route-templates.js +4 -2
- package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/app/map-services.js +3 -2
- package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/tests/map-components.js +3 -2
- package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/tests/map-route-controllers.js +7 -4
- package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/tests/map-route-routes.js +7 -4
- package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/tests/map-services.js +4 -2
- package/dist/src/migration/index.js +2 -3
- package/dist/src/migration/{ember-addon → v1-addon}/index.js +1 -1
- package/dist/src/migration/{ember-engine → v1-addon}/steps/create-file-path-maps/addon/index.js +2 -0
- package/dist/src/migration/{ember-engine → v1-addon}/steps/create-file-path-maps/addon/map-component-classes.js +3 -2
- package/dist/src/migration/{ember-addon → v1-addon}/steps/create-file-path-maps/addon/map-component-stylesheets.js +3 -2
- package/dist/src/migration/{ember-engine → v1-addon}/steps/create-file-path-maps/addon/map-component-templates.js +3 -2
- package/dist/src/migration/{ember-engine → v1-addon}/steps/create-file-path-maps/addon/map-route-controllers.js +3 -2
- package/dist/src/migration/{ember-engine → v1-addon}/steps/create-file-path-maps/addon/map-route-routes.js +3 -2
- package/dist/src/migration/{ember-engine → v1-addon}/steps/create-file-path-maps/addon/map-route-stylesheets.js +4 -2
- package/dist/src/migration/{ember-engine → v1-addon}/steps/create-file-path-maps/addon/map-route-templates.js +4 -2
- package/dist/src/migration/v1-addon/steps/create-file-path-maps/addon/map-services.js +18 -0
- package/dist/src/migration/v1-addon/steps/create-file-path-maps/app/index.js +16 -0
- package/dist/src/migration/{ember-addon → v1-addon}/steps/create-file-path-maps/app/map-component-classes.js +3 -2
- package/dist/src/migration/{ember-addon → v1-addon}/steps/create-file-path-maps/app/map-component-templates.js +3 -2
- package/dist/src/migration/{ember-addon/steps/create-file-path-maps/app/map-component-stylesheets.js → v1-addon/steps/create-file-path-maps/app/map-route-controllers.js} +5 -4
- package/dist/src/migration/v1-addon/steps/create-file-path-maps/app/map-route-routes.js +18 -0
- package/dist/src/migration/{ember-addon/steps/create-file-path-maps/addon/map-component-templates.js → v1-addon/steps/create-file-path-maps/app/map-route-templates.js} +6 -4
- package/dist/src/migration/v1-addon/steps/create-file-path-maps/app/map-services.js +18 -0
- package/dist/src/migration/{ember-engine → v1-addon}/steps/create-file-path-maps/tests/index.js +2 -0
- package/dist/src/migration/{ember-addon → v1-addon}/steps/create-file-path-maps/tests/map-components.js +3 -2
- package/dist/src/migration/{ember-engine → v1-addon}/steps/create-file-path-maps/tests/map-route-controllers.js +7 -4
- package/dist/src/migration/{ember-engine → v1-addon}/steps/create-file-path-maps/tests/map-route-routes.js +7 -4
- package/dist/src/migration/{ember-addon/steps/create-file-path-maps/addon/map-component-classes.js → v1-addon/steps/create-file-path-maps/tests/map-services.js} +6 -4
- package/dist/src/utils/files/rename-pod-path.js +4 -4
- package/package.json +1 -1
- package/dist/src/migration/ember-addon/steps/create-file-path-maps/addon/index.js +0 -10
- package/dist/src/migration/ember-addon/steps/create-file-path-maps/app/index.js +0 -10
- package/dist/src/migration/ember-addon/steps/create-file-path-maps/tests/index.js +0 -4
- package/dist/src/migration/ember-engine/index.js +0 -13
- package/dist/src/migration/ember-engine/steps/create-file-path-maps/addon/map-component-stylesheets.js +0 -17
- package/dist/src/migration/ember-engine/steps/create-file-path-maps/tests/map-components.js +0 -17
- package/dist/src/migration/ember-engine/steps/create-file-path-maps.js +0 -8
- package/dist/src/migration/ember-engine/steps/create-options.js +0 -8
- package/dist/src/migration/ember-engine/steps/index.js +0 -2
- /package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/app/index.js +0 -0
- /package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/tests/index.js +0 -0
- /package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps.js +0 -0
- /package/dist/src/migration/{ember-addon → app}/steps/create-options.js +0 -0
- /package/dist/src/migration/{ember-app → app}/steps/index.js +0 -0
- /package/dist/src/migration/{ember-addon → v1-addon}/steps/create-file-path-maps.js +0 -0
- /package/dist/src/migration/{ember-app → v1-addon}/steps/create-options.js +0 -0
- /package/dist/src/migration/{ember-addon → v1-addon}/steps/index.js +0 -0
- /package/dist/src/migration/{ember-addon → v1-addon}/steps/update-paths-in-app-folder.js +0 -0
package/README.md
CHANGED
|
@@ -20,11 +20,28 @@ cd <path/to/your/project>
|
|
|
20
20
|
npx ember-codemod-pod-to-octane <arguments>
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
> [!NOTE]
|
|
24
|
+
>
|
|
25
|
+
> By default, Octane assumes the **flat component structure**. So does this codemod to help different Ember projects converge to one layout. If you want the **nested component structure** (also supported by Octane), you can run [`ember-flat-to-nested`](https://github.com/bertdeblock/ember-flat-to-nested) afterwards.
|
|
26
|
+
|
|
23
27
|
Step 2. Remove `podModulePrefix` from `config/environment.js` and `usePods` from `.ember-cli`.
|
|
24
28
|
|
|
25
29
|
Step 3. Update references originating from, as well as pointing to, the moved files. These can include `import` statement, `composes` property from `ember-css-modules`, etc.
|
|
26
30
|
|
|
27
|
-
|
|
31
|
+
> [!TIP]
|
|
32
|
+
>
|
|
33
|
+
> Linters can help you find the files that need to be updated.
|
|
34
|
+
>
|
|
35
|
+
> ```sh
|
|
36
|
+
> # With eslint-plugin-import
|
|
37
|
+
> [lint:js] /my-v1-addon/addon/index.ts
|
|
38
|
+
> [lint:js] 1:49 error Unable to resolve path to module './components/navigation-menu/component' import/no-unresolved
|
|
39
|
+
>
|
|
40
|
+
> # With typescript
|
|
41
|
+
> [lint:types] addon/index.ts:1:49 - error TS2307: Cannot find module './components/navigation-menu/component' or its corresponding type declarations.
|
|
42
|
+
> [lint:types]
|
|
43
|
+
> [lint:types] 1 export { default as NavigationMenu } from './components/navigation-menu/component';
|
|
44
|
+
> ```
|
|
28
45
|
|
|
29
46
|
|
|
30
47
|
### Arguments
|
|
@@ -32,9 +49,11 @@ Step 3. Update references originating from, as well as pointing to, the moved fi
|
|
|
32
49
|
You must pass `--type` to indicate what type of project you have.
|
|
33
50
|
|
|
34
51
|
```sh
|
|
52
|
+
# For classic apps
|
|
35
53
|
npx ember-codemod-pod-to-octane --type app
|
|
36
|
-
|
|
37
|
-
|
|
54
|
+
|
|
55
|
+
# For v1 addons (including engines)
|
|
56
|
+
npx ember-codemod-pod-to-octane --type v1-addon
|
|
38
57
|
```
|
|
39
58
|
|
|
40
59
|
|
|
@@ -103,16 +122,7 @@ To account for a bug (found when Ember CLI is combined with Ember Data), the cod
|
|
|
103
122
|
|
|
104
123
|
<summary>Addons</summary>
|
|
105
124
|
|
|
106
|
-
The codemod
|
|
107
|
-
|
|
108
|
-
</details>
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
<details>
|
|
112
|
-
|
|
113
|
-
<summary>Engines</summary>
|
|
114
|
-
|
|
115
|
-
The codemod assumes that an engine is used to define routes and route-specific components.
|
|
125
|
+
The codemod doesn't consider things related to Ember Data (i.e. adapters, models, and serializers).
|
|
116
126
|
|
|
117
127
|
</details>
|
|
118
128
|
|
|
@@ -129,6 +139,25 @@ pnpm build
|
|
|
129
139
|
./dist/bin/ember-codemod-pod-to-octane.js --root <path/to/your/project>
|
|
130
140
|
```
|
|
131
141
|
|
|
142
|
+
> [!TIP]
|
|
143
|
+
>
|
|
144
|
+
> You might clone the repo to migrate the project one component or one route at a time. For example, to migrate only the `<NavigationMenu>` component (and its subcomponents, if they exist), update the related file(s) in the `src` folder like this:
|
|
145
|
+
>
|
|
146
|
+
> ```diff
|
|
147
|
+
> export function mapComponentClasses(options: Options): FilePathMapEntries {
|
|
148
|
+
> const { podPath, projectRoot } = options;
|
|
149
|
+
>
|
|
150
|
+
> const podDir = join('app', podPath, 'components');
|
|
151
|
+
>
|
|
152
|
+
> - const filePaths = findFiles(`${podDir}/**/component.{d.ts,js,ts}`, {
|
|
153
|
+
> + const filePaths = findFiles(`${podDir}/navigation-menu/**/component.{d.ts,js,ts}`, {
|
|
154
|
+
>
|
|
155
|
+
> // ...
|
|
156
|
+
> }
|
|
157
|
+
> ```
|
|
158
|
+
>
|
|
159
|
+
> That is, look for `findFiles(`, then insert the component or route name between `podDir` and `**`.
|
|
160
|
+
|
|
132
161
|
|
|
133
162
|
## Compatibility
|
|
134
163
|
|
package/dist/src/index.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { migrateApp, migrateV1Addon } from './migration/index.js';
|
|
2
2
|
export function runCodemod(codemodOptions) {
|
|
3
3
|
switch (codemodOptions.projectType) {
|
|
4
|
-
case 'addon': {
|
|
5
|
-
migrateEmberAddon(codemodOptions);
|
|
6
|
-
break;
|
|
7
|
-
}
|
|
8
4
|
case 'app': {
|
|
9
|
-
|
|
5
|
+
migrateApp(codemodOptions);
|
|
10
6
|
break;
|
|
11
7
|
}
|
|
12
|
-
case '
|
|
13
|
-
|
|
8
|
+
case 'v1-addon': {
|
|
9
|
+
migrateV1Addon(codemodOptions);
|
|
14
10
|
break;
|
|
15
11
|
}
|
|
16
12
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { moveFiles } from '@codemod-utils/files';
|
|
2
2
|
import { createFilePathMaps, createOptions } from './steps/index.js';
|
|
3
|
-
export function
|
|
3
|
+
export function migrateApp(codemodOptions) {
|
|
4
4
|
const options = createOptions(codemodOptions);
|
|
5
5
|
const filePathMaps = createFilePathMaps(options);
|
|
6
6
|
if (options.testRun) {
|
|
@@ -3,12 +3,13 @@ import { findFiles } from '@codemod-utils/files';
|
|
|
3
3
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
4
4
|
export function mapComponentClasses(options) {
|
|
5
5
|
const { podPath, projectRoot } = options;
|
|
6
|
-
const
|
|
6
|
+
const podDir = join('app', podPath, 'components');
|
|
7
|
+
const filePaths = findFiles(`${podDir}/**/component.{d.ts,js,ts}`, {
|
|
7
8
|
projectRoot,
|
|
8
9
|
});
|
|
9
10
|
return filePaths.map((oldFilePath) => {
|
|
10
11
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
11
|
-
|
|
12
|
+
podDir,
|
|
12
13
|
replace: (key) => {
|
|
13
14
|
return `app/components/${key}`;
|
|
14
15
|
},
|
|
@@ -3,12 +3,13 @@ import { findFiles } from '@codemod-utils/files';
|
|
|
3
3
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
4
4
|
export function mapComponentStylesheets(options) {
|
|
5
5
|
const { podPath, projectRoot } = options;
|
|
6
|
-
const
|
|
6
|
+
const podDir = join('app', podPath, 'components');
|
|
7
|
+
const filePaths = findFiles(`${podDir}/**/styles.{css,scss}`, {
|
|
7
8
|
projectRoot,
|
|
8
9
|
});
|
|
9
10
|
return filePaths.map((oldFilePath) => {
|
|
10
11
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
11
|
-
|
|
12
|
+
podDir,
|
|
12
13
|
replace: (key) => {
|
|
13
14
|
return `app/components/${key}`;
|
|
14
15
|
},
|
|
@@ -3,12 +3,13 @@ import { findFiles } from '@codemod-utils/files';
|
|
|
3
3
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
4
4
|
export function mapComponentTemplates(options) {
|
|
5
5
|
const { podPath, projectRoot } = options;
|
|
6
|
-
const
|
|
6
|
+
const podDir = join('app', podPath, 'components');
|
|
7
|
+
const filePaths = findFiles(`${podDir}/**/template.hbs`, {
|
|
7
8
|
projectRoot,
|
|
8
9
|
});
|
|
9
10
|
return filePaths.map((oldFilePath) => {
|
|
10
11
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
11
|
-
|
|
12
|
+
podDir,
|
|
12
13
|
replace: (key) => {
|
|
13
14
|
return `app/components/${key}`;
|
|
14
15
|
},
|
package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/app/map-route-adapters.js
RENAMED
|
@@ -3,12 +3,13 @@ import { findFiles } from '@codemod-utils/files';
|
|
|
3
3
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
4
4
|
export function mapRouteAdapters(options) {
|
|
5
5
|
const { podPath, projectRoot } = options;
|
|
6
|
-
const
|
|
6
|
+
const podDir = join('app', podPath);
|
|
7
|
+
const filePaths = findFiles(`${podDir}/**/adapter.{js,ts}`, {
|
|
7
8
|
projectRoot,
|
|
8
9
|
});
|
|
9
10
|
return filePaths.map((oldFilePath) => {
|
|
10
11
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
11
|
-
|
|
12
|
+
podDir,
|
|
12
13
|
replace: (key) => {
|
|
13
14
|
return `app/adapters/${key}`;
|
|
14
15
|
},
|
|
@@ -3,12 +3,13 @@ import { findFiles } from '@codemod-utils/files';
|
|
|
3
3
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
4
4
|
export function mapRouteControllers(options) {
|
|
5
5
|
const { podPath, projectRoot } = options;
|
|
6
|
-
const
|
|
6
|
+
const podDir = join('app', podPath);
|
|
7
|
+
const filePaths = findFiles(`${podDir}/**/controller.{js,ts}`, {
|
|
7
8
|
projectRoot,
|
|
8
9
|
});
|
|
9
10
|
return filePaths.map((oldFilePath) => {
|
|
10
11
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
11
|
-
|
|
12
|
+
podDir,
|
|
12
13
|
replace: (key) => {
|
|
13
14
|
return `app/controllers/${key}`;
|
|
14
15
|
},
|
package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/app/map-route-models.js
RENAMED
|
@@ -3,12 +3,13 @@ import { findFiles } from '@codemod-utils/files';
|
|
|
3
3
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
4
4
|
export function mapRouteModels(options) {
|
|
5
5
|
const { podPath, projectRoot } = options;
|
|
6
|
-
const
|
|
6
|
+
const podDir = join('app', podPath);
|
|
7
|
+
const filePaths = findFiles(`${podDir}/**/model.{js,ts}`, {
|
|
7
8
|
projectRoot,
|
|
8
9
|
});
|
|
9
10
|
return filePaths.map((oldFilePath) => {
|
|
10
11
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
11
|
-
|
|
12
|
+
podDir,
|
|
12
13
|
replace: (key) => {
|
|
13
14
|
return `app/models/${key}`;
|
|
14
15
|
},
|
package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/app/map-route-routes.js
RENAMED
|
@@ -3,12 +3,13 @@ import { findFiles } from '@codemod-utils/files';
|
|
|
3
3
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
4
4
|
export function mapRouteRoutes(options) {
|
|
5
5
|
const { podPath, projectRoot } = options;
|
|
6
|
-
const
|
|
6
|
+
const podDir = join('app', podPath);
|
|
7
|
+
const filePaths = findFiles(`${podDir}/**/route.{js,ts}`, {
|
|
7
8
|
projectRoot,
|
|
8
9
|
});
|
|
9
10
|
return filePaths.map((oldFilePath) => {
|
|
10
11
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
11
|
-
|
|
12
|
+
podDir,
|
|
12
13
|
replace: (key) => {
|
|
13
14
|
return `app/routes/${key}`;
|
|
14
15
|
},
|
|
@@ -3,12 +3,13 @@ import { findFiles } from '@codemod-utils/files';
|
|
|
3
3
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
4
4
|
export function mapRouteSerializers(options) {
|
|
5
5
|
const { podPath, projectRoot } = options;
|
|
6
|
-
const
|
|
6
|
+
const podDir = join('app', podPath);
|
|
7
|
+
const filePaths = findFiles(`${podDir}/**/serializer.{js,ts}`, {
|
|
7
8
|
projectRoot,
|
|
8
9
|
});
|
|
9
10
|
return filePaths.map((oldFilePath) => {
|
|
10
11
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
11
|
-
|
|
12
|
+
podDir,
|
|
12
13
|
replace: (key) => {
|
|
13
14
|
return `app/serializers/${key}`;
|
|
14
15
|
},
|
|
@@ -3,12 +3,14 @@ import { findFiles } from '@codemod-utils/files';
|
|
|
3
3
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
4
4
|
export function mapRouteStylesheets(options) {
|
|
5
5
|
const { podPath, projectRoot } = options;
|
|
6
|
-
const
|
|
6
|
+
const podDir = join('app', podPath);
|
|
7
|
+
const filePaths = findFiles(`${podDir}/**/styles.{css,scss}`, {
|
|
8
|
+
ignoreList: [join('app', podPath, 'components/**')],
|
|
7
9
|
projectRoot,
|
|
8
10
|
});
|
|
9
11
|
return filePaths.map((oldFilePath) => {
|
|
10
12
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
11
|
-
|
|
13
|
+
podDir,
|
|
12
14
|
replace: (key) => {
|
|
13
15
|
return `app/styles/${key}`;
|
|
14
16
|
},
|
package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/app/map-route-templates.js
RENAMED
|
@@ -3,12 +3,14 @@ import { findFiles } from '@codemod-utils/files';
|
|
|
3
3
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
4
4
|
export function mapRouteTemplates(options) {
|
|
5
5
|
const { podPath, projectRoot } = options;
|
|
6
|
-
const
|
|
6
|
+
const podDir = join('app', podPath);
|
|
7
|
+
const filePaths = findFiles(`${podDir}/**/template.hbs`, {
|
|
8
|
+
ignoreList: [join('app', podPath, 'components/**')],
|
|
7
9
|
projectRoot,
|
|
8
10
|
});
|
|
9
11
|
return filePaths.map((oldFilePath) => {
|
|
10
12
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
11
|
-
|
|
13
|
+
podDir,
|
|
12
14
|
replace: (key) => {
|
|
13
15
|
return `app/templates/${key}`;
|
|
14
16
|
},
|
package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/app/map-services.js
RENAMED
|
@@ -3,12 +3,13 @@ import { findFiles } from '@codemod-utils/files';
|
|
|
3
3
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
4
4
|
export function mapServices(options) {
|
|
5
5
|
const { podPath, projectRoot } = options;
|
|
6
|
-
const
|
|
6
|
+
const podDir = join('app', podPath);
|
|
7
|
+
const filePaths = findFiles(`${podDir}/**/service.{js,ts}`, {
|
|
7
8
|
projectRoot,
|
|
8
9
|
});
|
|
9
10
|
return filePaths.map((oldFilePath) => {
|
|
10
11
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
11
|
-
|
|
12
|
+
podDir,
|
|
12
13
|
replace: (key) => {
|
|
13
14
|
return `app/services/${key}`;
|
|
14
15
|
},
|
package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/tests/map-components.js
RENAMED
|
@@ -3,12 +3,13 @@ import { findFiles } from '@codemod-utils/files';
|
|
|
3
3
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
4
4
|
export function mapComponents(options) {
|
|
5
5
|
const { podPath, projectRoot } = options;
|
|
6
|
-
const
|
|
6
|
+
const podDir = join('tests/integration', podPath, 'components');
|
|
7
|
+
const filePaths = findFiles(`${podDir}/**/component-test.{js,ts}`, {
|
|
7
8
|
projectRoot,
|
|
8
9
|
});
|
|
9
10
|
return filePaths.map((oldFilePath) => {
|
|
10
11
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
11
|
-
|
|
12
|
+
podDir,
|
|
12
13
|
replace: (key) => {
|
|
13
14
|
return `tests/integration/components/${key}-test`;
|
|
14
15
|
},
|
|
@@ -6,12 +6,14 @@ export function mapRouteControllers(options) {
|
|
|
6
6
|
/*
|
|
7
7
|
Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
|
|
8
8
|
*/
|
|
9
|
-
const
|
|
9
|
+
const podDir1 = join('tests/unit', podPath);
|
|
10
|
+
const filePaths1 = findFiles(`${podDir1}/**/controller-test.{js,ts}`, {
|
|
11
|
+
ignoreList: [join('tests/unit', podPath, 'controllers/**')],
|
|
10
12
|
projectRoot,
|
|
11
13
|
});
|
|
12
14
|
const filePathMap1 = filePaths1.map((oldFilePath) => {
|
|
13
15
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
14
|
-
|
|
16
|
+
podDir: podDir1,
|
|
15
17
|
replace: (key) => {
|
|
16
18
|
return `tests/unit/controllers/${key}-test`;
|
|
17
19
|
},
|
|
@@ -21,12 +23,13 @@ export function mapRouteControllers(options) {
|
|
|
21
23
|
/*
|
|
22
24
|
Case 2: Passed the --pod flag to Ember CLI
|
|
23
25
|
*/
|
|
24
|
-
const
|
|
26
|
+
const podDir2 = join('tests/unit', podPath, 'controllers');
|
|
27
|
+
const filePaths2 = findFiles(`${podDir2}/**/controller-test.{js,ts}`, {
|
|
25
28
|
projectRoot,
|
|
26
29
|
});
|
|
27
30
|
const filePathMap2 = filePaths2.map((oldFilePath) => {
|
|
28
31
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
29
|
-
|
|
32
|
+
podDir: podDir2,
|
|
30
33
|
replace: (key) => {
|
|
31
34
|
return `tests/unit/controllers/${key}-test`;
|
|
32
35
|
},
|
package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/tests/map-route-routes.js
RENAMED
|
@@ -6,12 +6,14 @@ export function mapRouteRoutes(options) {
|
|
|
6
6
|
/*
|
|
7
7
|
Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
|
|
8
8
|
*/
|
|
9
|
-
const
|
|
9
|
+
const podDir1 = join('tests/unit', podPath);
|
|
10
|
+
const filePaths1 = findFiles(`${podDir1}/**/route-test.{js,ts}`, {
|
|
11
|
+
ignoreList: [join('tests/unit', podPath, 'routes/**')],
|
|
10
12
|
projectRoot,
|
|
11
13
|
});
|
|
12
14
|
const filePathMap1 = filePaths1.map((oldFilePath) => {
|
|
13
15
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
14
|
-
|
|
16
|
+
podDir: podDir1,
|
|
15
17
|
replace: (key) => {
|
|
16
18
|
return `tests/unit/routes/${key}-test`;
|
|
17
19
|
},
|
|
@@ -21,12 +23,13 @@ export function mapRouteRoutes(options) {
|
|
|
21
23
|
/*
|
|
22
24
|
Case 2: Passed the --pod flag to Ember CLI
|
|
23
25
|
*/
|
|
24
|
-
const
|
|
26
|
+
const podDir2 = join('tests/unit', podPath, 'routes');
|
|
27
|
+
const filePaths2 = findFiles(`${podDir2}/**/route-test.{js,ts}`, {
|
|
25
28
|
projectRoot,
|
|
26
29
|
});
|
|
27
30
|
const filePathMap2 = filePaths2.map((oldFilePath) => {
|
|
28
31
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
29
|
-
|
|
32
|
+
podDir: podDir2,
|
|
30
33
|
replace: (key) => {
|
|
31
34
|
return `tests/unit/routes/${key}-test`;
|
|
32
35
|
},
|
package/dist/src/migration/{ember-app → app}/steps/create-file-path-maps/tests/map-services.js
RENAMED
|
@@ -3,12 +3,14 @@ import { findFiles } from '@codemod-utils/files';
|
|
|
3
3
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
4
4
|
export function mapServices(options) {
|
|
5
5
|
const { podPath, projectRoot } = options;
|
|
6
|
-
const
|
|
6
|
+
const podDir = join('tests/unit', podPath);
|
|
7
|
+
const filePaths = findFiles(`${podDir}/**/service-test.{js,ts}`, {
|
|
8
|
+
ignoreList: [join('tests/unit', podPath, 'services/**')],
|
|
7
9
|
projectRoot,
|
|
8
10
|
});
|
|
9
11
|
return filePaths.map((oldFilePath) => {
|
|
10
12
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
11
|
-
|
|
13
|
+
podDir,
|
|
12
14
|
replace: (key) => {
|
|
13
15
|
return `tests/unit/services/${key}-test`;
|
|
14
16
|
},
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './ember-engine/index.js';
|
|
1
|
+
export * from './app/index.js';
|
|
2
|
+
export * from './v1-addon/index.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { moveFiles } from '@codemod-utils/files';
|
|
2
2
|
import { createFilePathMaps, createOptions, updatePathsInAppFolder, } from './steps/index.js';
|
|
3
|
-
export function
|
|
3
|
+
export function migrateV1Addon(codemodOptions) {
|
|
4
4
|
const options = createOptions(codemodOptions);
|
|
5
5
|
const filePathMaps = createFilePathMaps(options);
|
|
6
6
|
if (options.testRun) {
|
package/dist/src/migration/{ember-engine → v1-addon}/steps/create-file-path-maps/addon/index.js
RENAMED
|
@@ -5,6 +5,7 @@ import { mapRouteControllers } from './map-route-controllers.js';
|
|
|
5
5
|
import { mapRouteRoutes } from './map-route-routes.js';
|
|
6
6
|
import { mapRouteStylesheets } from './map-route-stylesheets.js';
|
|
7
7
|
import { mapRouteTemplates } from './map-route-templates.js';
|
|
8
|
+
import { mapServices } from './map-services.js';
|
|
8
9
|
export function mapAddonFolder(options) {
|
|
9
10
|
return new Map([
|
|
10
11
|
...mapComponentClasses(options),
|
|
@@ -14,5 +15,6 @@ export function mapAddonFolder(options) {
|
|
|
14
15
|
...mapRouteRoutes(options),
|
|
15
16
|
...mapRouteStylesheets(options),
|
|
16
17
|
...mapRouteTemplates(options),
|
|
18
|
+
...mapServices(options),
|
|
17
19
|
]);
|
|
18
20
|
}
|
|
@@ -2,12 +2,13 @@ import { findFiles } from '@codemod-utils/files';
|
|
|
2
2
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
3
3
|
export function mapComponentClasses(options) {
|
|
4
4
|
const { projectRoot } = options;
|
|
5
|
-
const
|
|
5
|
+
const podDir = 'addon/components';
|
|
6
|
+
const filePaths = findFiles(`${podDir}/**/component.{d.ts,js,ts}`, {
|
|
6
7
|
projectRoot,
|
|
7
8
|
});
|
|
8
9
|
return filePaths.map((oldFilePath) => {
|
|
9
10
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
10
|
-
|
|
11
|
+
podDir,
|
|
11
12
|
replace: (key) => {
|
|
12
13
|
return `addon/components/${key}`;
|
|
13
14
|
},
|
|
@@ -2,12 +2,13 @@ import { findFiles } from '@codemod-utils/files';
|
|
|
2
2
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
3
3
|
export function mapComponentStylesheets(options) {
|
|
4
4
|
const { projectRoot } = options;
|
|
5
|
-
const
|
|
5
|
+
const podDir = 'addon/components';
|
|
6
|
+
const filePaths = findFiles(`${podDir}/**/styles.{css,scss}`, {
|
|
6
7
|
projectRoot,
|
|
7
8
|
});
|
|
8
9
|
return filePaths.map((oldFilePath) => {
|
|
9
10
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
10
|
-
|
|
11
|
+
podDir,
|
|
11
12
|
replace: (key) => {
|
|
12
13
|
return `addon/components/${key}`;
|
|
13
14
|
},
|
|
@@ -2,12 +2,13 @@ import { findFiles } from '@codemod-utils/files';
|
|
|
2
2
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
3
3
|
export function mapComponentTemplates(options) {
|
|
4
4
|
const { projectRoot } = options;
|
|
5
|
-
const
|
|
5
|
+
const podDir = 'addon/components';
|
|
6
|
+
const filePaths = findFiles(`${podDir}/**/template.hbs`, {
|
|
6
7
|
projectRoot,
|
|
7
8
|
});
|
|
8
9
|
return filePaths.map((oldFilePath) => {
|
|
9
10
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
10
|
-
|
|
11
|
+
podDir,
|
|
11
12
|
replace: (key) => {
|
|
12
13
|
return `addon/components/${key}`;
|
|
13
14
|
},
|
|
@@ -2,12 +2,13 @@ import { findFiles } from '@codemod-utils/files';
|
|
|
2
2
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
3
3
|
export function mapRouteControllers(options) {
|
|
4
4
|
const { projectRoot } = options;
|
|
5
|
-
const
|
|
5
|
+
const podDir = 'addon';
|
|
6
|
+
const filePaths = findFiles(`${podDir}/**/controller.{js,ts}`, {
|
|
6
7
|
projectRoot,
|
|
7
8
|
});
|
|
8
9
|
return filePaths.map((oldFilePath) => {
|
|
9
10
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
10
|
-
|
|
11
|
+
podDir,
|
|
11
12
|
replace: (key) => {
|
|
12
13
|
return `addon/controllers/${key}`;
|
|
13
14
|
},
|
|
@@ -2,12 +2,13 @@ import { findFiles } from '@codemod-utils/files';
|
|
|
2
2
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
3
3
|
export function mapRouteRoutes(options) {
|
|
4
4
|
const { projectRoot } = options;
|
|
5
|
-
const
|
|
5
|
+
const podDir = 'addon';
|
|
6
|
+
const filePaths = findFiles(`${podDir}/**/route.{js,ts}`, {
|
|
6
7
|
projectRoot,
|
|
7
8
|
});
|
|
8
9
|
return filePaths.map((oldFilePath) => {
|
|
9
10
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
10
|
-
|
|
11
|
+
podDir,
|
|
11
12
|
replace: (key) => {
|
|
12
13
|
return `addon/routes/${key}`;
|
|
13
14
|
},
|
|
@@ -2,12 +2,14 @@ import { findFiles } from '@codemod-utils/files';
|
|
|
2
2
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
3
3
|
export function mapRouteStylesheets(options) {
|
|
4
4
|
const { projectRoot } = options;
|
|
5
|
-
const
|
|
5
|
+
const podDir = 'addon';
|
|
6
|
+
const filePaths = findFiles(`${podDir}/**/styles.{css,scss}`, {
|
|
7
|
+
ignoreList: ['addon/components/**'],
|
|
6
8
|
projectRoot,
|
|
7
9
|
});
|
|
8
10
|
return filePaths.map((oldFilePath) => {
|
|
9
11
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
10
|
-
|
|
12
|
+
podDir,
|
|
11
13
|
replace: (key) => {
|
|
12
14
|
return `addon/styles/${key}`;
|
|
13
15
|
},
|
|
@@ -2,12 +2,14 @@ import { findFiles } from '@codemod-utils/files';
|
|
|
2
2
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
3
3
|
export function mapRouteTemplates(options) {
|
|
4
4
|
const { projectRoot } = options;
|
|
5
|
-
const
|
|
5
|
+
const podDir = 'addon';
|
|
6
|
+
const filePaths = findFiles(`${podDir}/**/template.hbs`, {
|
|
7
|
+
ignoreList: ['addon/components/**'],
|
|
6
8
|
projectRoot,
|
|
7
9
|
});
|
|
8
10
|
return filePaths.map((oldFilePath) => {
|
|
9
11
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
10
|
-
|
|
12
|
+
podDir,
|
|
11
13
|
replace: (key) => {
|
|
12
14
|
return `addon/templates/${key}`;
|
|
13
15
|
},
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { findFiles } from '@codemod-utils/files';
|
|
2
|
+
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
3
|
+
export function mapServices(options) {
|
|
4
|
+
const { projectRoot } = options;
|
|
5
|
+
const podDir = 'addon';
|
|
6
|
+
const filePaths = findFiles(`${podDir}/**/service.{js,ts}`, {
|
|
7
|
+
projectRoot,
|
|
8
|
+
});
|
|
9
|
+
return filePaths.map((oldFilePath) => {
|
|
10
|
+
const newFilePath = renamePodPath(oldFilePath, {
|
|
11
|
+
podDir,
|
|
12
|
+
replace: (key) => {
|
|
13
|
+
return `addon/services/${key}`;
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
return [oldFilePath, newFilePath];
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { mapComponentClasses } from './map-component-classes.js';
|
|
2
|
+
import { mapComponentTemplates } from './map-component-templates.js';
|
|
3
|
+
import { mapRouteControllers } from './map-route-controllers.js';
|
|
4
|
+
import { mapRouteRoutes } from './map-route-routes.js';
|
|
5
|
+
import { mapRouteTemplates } from './map-route-templates.js';
|
|
6
|
+
import { mapServices } from './map-services.js';
|
|
7
|
+
export function mapAppFolder(options) {
|
|
8
|
+
return new Map([
|
|
9
|
+
...mapComponentClasses(options),
|
|
10
|
+
...mapComponentTemplates(options),
|
|
11
|
+
...mapRouteControllers(options),
|
|
12
|
+
...mapRouteRoutes(options),
|
|
13
|
+
...mapRouteTemplates(options),
|
|
14
|
+
...mapServices(options),
|
|
15
|
+
]);
|
|
16
|
+
}
|
|
@@ -2,12 +2,13 @@ import { findFiles } from '@codemod-utils/files';
|
|
|
2
2
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
3
3
|
export function mapComponentClasses(options) {
|
|
4
4
|
const { projectRoot } = options;
|
|
5
|
-
const
|
|
5
|
+
const podDir = 'app/components';
|
|
6
|
+
const filePaths = findFiles(`${podDir}/**/component.js`, {
|
|
6
7
|
projectRoot,
|
|
7
8
|
});
|
|
8
9
|
return filePaths.map((oldFilePath) => {
|
|
9
10
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
10
|
-
|
|
11
|
+
podDir,
|
|
11
12
|
replace: (key) => {
|
|
12
13
|
return `app/components/${key}`;
|
|
13
14
|
},
|
|
@@ -2,12 +2,13 @@ import { findFiles } from '@codemod-utils/files';
|
|
|
2
2
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
3
3
|
export function mapComponentTemplates(options) {
|
|
4
4
|
const { projectRoot } = options;
|
|
5
|
-
const
|
|
5
|
+
const podDir = 'app/components';
|
|
6
|
+
const filePaths = findFiles(`${podDir}/**/template.js`, {
|
|
6
7
|
projectRoot,
|
|
7
8
|
});
|
|
8
9
|
return filePaths.map((oldFilePath) => {
|
|
9
10
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
10
|
-
|
|
11
|
+
podDir,
|
|
11
12
|
replace: (key) => {
|
|
12
13
|
return `app/components/${key}`;
|
|
13
14
|
},
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { findFiles } from '@codemod-utils/files';
|
|
2
2
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
3
|
-
export function
|
|
3
|
+
export function mapRouteControllers(options) {
|
|
4
4
|
const { projectRoot } = options;
|
|
5
|
-
const
|
|
5
|
+
const podDir = 'app';
|
|
6
|
+
const filePaths = findFiles(`${podDir}/**/controller.js`, {
|
|
6
7
|
projectRoot,
|
|
7
8
|
});
|
|
8
9
|
return filePaths.map((oldFilePath) => {
|
|
9
10
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
10
|
-
|
|
11
|
+
podDir,
|
|
11
12
|
replace: (key) => {
|
|
12
|
-
return `app/
|
|
13
|
+
return `app/controllers/${key}`;
|
|
13
14
|
},
|
|
14
15
|
});
|
|
15
16
|
return [oldFilePath, newFilePath];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { findFiles } from '@codemod-utils/files';
|
|
2
|
+
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
3
|
+
export function mapRouteRoutes(options) {
|
|
4
|
+
const { projectRoot } = options;
|
|
5
|
+
const podDir = 'app';
|
|
6
|
+
const filePaths = findFiles(`${podDir}/**/route.js`, {
|
|
7
|
+
projectRoot,
|
|
8
|
+
});
|
|
9
|
+
return filePaths.map((oldFilePath) => {
|
|
10
|
+
const newFilePath = renamePodPath(oldFilePath, {
|
|
11
|
+
podDir,
|
|
12
|
+
replace: (key) => {
|
|
13
|
+
return `app/routes/${key}`;
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
return [oldFilePath, newFilePath];
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { findFiles } from '@codemod-utils/files';
|
|
2
2
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
3
|
-
export function
|
|
3
|
+
export function mapRouteTemplates(options) {
|
|
4
4
|
const { projectRoot } = options;
|
|
5
|
-
const
|
|
5
|
+
const podDir = 'app';
|
|
6
|
+
const filePaths = findFiles(`${podDir}/**/template.js`, {
|
|
7
|
+
ignoreList: ['app/components/**'],
|
|
6
8
|
projectRoot,
|
|
7
9
|
});
|
|
8
10
|
return filePaths.map((oldFilePath) => {
|
|
9
11
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
10
|
-
|
|
12
|
+
podDir,
|
|
11
13
|
replace: (key) => {
|
|
12
|
-
return `
|
|
14
|
+
return `app/templates/${key}`;
|
|
13
15
|
},
|
|
14
16
|
});
|
|
15
17
|
return [oldFilePath, newFilePath];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { findFiles } from '@codemod-utils/files';
|
|
2
|
+
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
3
|
+
export function mapServices(options) {
|
|
4
|
+
const { projectRoot } = options;
|
|
5
|
+
const podDir = 'app';
|
|
6
|
+
const filePaths = findFiles(`${podDir}/**/service.js`, {
|
|
7
|
+
projectRoot,
|
|
8
|
+
});
|
|
9
|
+
return filePaths.map((oldFilePath) => {
|
|
10
|
+
const newFilePath = renamePodPath(oldFilePath, {
|
|
11
|
+
podDir,
|
|
12
|
+
replace: (key) => {
|
|
13
|
+
return `app/services/${key}`;
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
return [oldFilePath, newFilePath];
|
|
17
|
+
});
|
|
18
|
+
}
|
package/dist/src/migration/{ember-engine → v1-addon}/steps/create-file-path-maps/tests/index.js
RENAMED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { mapComponents } from './map-components.js';
|
|
2
2
|
import { mapRouteControllers } from './map-route-controllers.js';
|
|
3
3
|
import { mapRouteRoutes } from './map-route-routes.js';
|
|
4
|
+
import { mapServices } from './map-services.js';
|
|
4
5
|
export function mapTestsFolder(options) {
|
|
5
6
|
return new Map([
|
|
6
7
|
...mapComponents(options),
|
|
7
8
|
...mapRouteControllers(options),
|
|
8
9
|
...mapRouteRoutes(options),
|
|
10
|
+
...mapServices(options),
|
|
9
11
|
]);
|
|
10
12
|
}
|
|
@@ -2,12 +2,13 @@ import { findFiles } from '@codemod-utils/files';
|
|
|
2
2
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
3
3
|
export function mapComponents(options) {
|
|
4
4
|
const { projectRoot } = options;
|
|
5
|
-
const
|
|
5
|
+
const podDir = 'tests/integration/components';
|
|
6
|
+
const filePaths = findFiles(`${podDir}/**/component-test.{js,ts}`, {
|
|
6
7
|
projectRoot,
|
|
7
8
|
});
|
|
8
9
|
return filePaths.map((oldFilePath) => {
|
|
9
10
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
10
|
-
|
|
11
|
+
podDir,
|
|
11
12
|
replace: (key) => {
|
|
12
13
|
return `tests/integration/components/${key}-test`;
|
|
13
14
|
},
|
|
@@ -5,12 +5,14 @@ export function mapRouteControllers(options) {
|
|
|
5
5
|
/*
|
|
6
6
|
Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
|
|
7
7
|
*/
|
|
8
|
-
const
|
|
8
|
+
const podDir1 = 'tests/unit';
|
|
9
|
+
const filePaths1 = findFiles(`${podDir1}/**/controller-test.{js,ts}`, {
|
|
10
|
+
ignoreList: ['tests/unit/controllers/**'],
|
|
9
11
|
projectRoot,
|
|
10
12
|
});
|
|
11
13
|
const filePathMap1 = filePaths1.map((oldFilePath) => {
|
|
12
14
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
13
|
-
|
|
15
|
+
podDir: podDir1,
|
|
14
16
|
replace: (key) => {
|
|
15
17
|
return `tests/unit/controllers/${key}-test`;
|
|
16
18
|
},
|
|
@@ -20,12 +22,13 @@ export function mapRouteControllers(options) {
|
|
|
20
22
|
/*
|
|
21
23
|
Case 2: Passed the --pod flag to Ember CLI
|
|
22
24
|
*/
|
|
23
|
-
const
|
|
25
|
+
const podDir2 = 'tests/unit/controllers';
|
|
26
|
+
const filePaths2 = findFiles(`${podDir2}/**/controller-test.{js,ts}`, {
|
|
24
27
|
projectRoot,
|
|
25
28
|
});
|
|
26
29
|
const filePathMap2 = filePaths2.map((oldFilePath) => {
|
|
27
30
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
28
|
-
|
|
31
|
+
podDir: podDir2,
|
|
29
32
|
replace: (key) => {
|
|
30
33
|
return `tests/unit/controllers/${key}-test`;
|
|
31
34
|
},
|
|
@@ -5,12 +5,14 @@ export function mapRouteRoutes(options) {
|
|
|
5
5
|
/*
|
|
6
6
|
Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
|
|
7
7
|
*/
|
|
8
|
-
const
|
|
8
|
+
const podDir1 = 'tests/unit';
|
|
9
|
+
const filePaths1 = findFiles(`${podDir1}/**/route-test.{js,ts}`, {
|
|
10
|
+
ignoreList: ['tests/unit/routes/**'],
|
|
9
11
|
projectRoot,
|
|
10
12
|
});
|
|
11
13
|
const filePathMap1 = filePaths1.map((oldFilePath) => {
|
|
12
14
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
13
|
-
|
|
15
|
+
podDir: podDir1,
|
|
14
16
|
replace: (key) => {
|
|
15
17
|
return `tests/unit/routes/${key}-test`;
|
|
16
18
|
},
|
|
@@ -20,12 +22,13 @@ export function mapRouteRoutes(options) {
|
|
|
20
22
|
/*
|
|
21
23
|
Case 2: Passed the --pod flag to Ember CLI
|
|
22
24
|
*/
|
|
23
|
-
const
|
|
25
|
+
const podDir2 = 'tests/unit/routes';
|
|
26
|
+
const filePaths2 = findFiles(`${podDir2}/**/route-test.{js,ts}`, {
|
|
24
27
|
projectRoot,
|
|
25
28
|
});
|
|
26
29
|
const filePathMap2 = filePaths2.map((oldFilePath) => {
|
|
27
30
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
28
|
-
|
|
31
|
+
podDir: podDir2,
|
|
29
32
|
replace: (key) => {
|
|
30
33
|
return `tests/unit/routes/${key}-test`;
|
|
31
34
|
},
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { findFiles } from '@codemod-utils/files';
|
|
2
2
|
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
3
|
-
export function
|
|
3
|
+
export function mapServices(options) {
|
|
4
4
|
const { projectRoot } = options;
|
|
5
|
-
const
|
|
5
|
+
const podDir = 'tests/unit';
|
|
6
|
+
const filePaths = findFiles(`${podDir}/**/service-test.{js,ts}`, {
|
|
7
|
+
ignoreList: ['tests/unit/services/**'],
|
|
6
8
|
projectRoot,
|
|
7
9
|
});
|
|
8
10
|
return filePaths.map((oldFilePath) => {
|
|
9
11
|
const newFilePath = renamePodPath(oldFilePath, {
|
|
10
|
-
|
|
12
|
+
podDir,
|
|
11
13
|
replace: (key) => {
|
|
12
|
-
return `
|
|
14
|
+
return `tests/unit/services/${key}-test`;
|
|
13
15
|
},
|
|
14
16
|
});
|
|
15
17
|
return [oldFilePath, newFilePath];
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { parseFilePath } from '@codemod-utils/files';
|
|
2
2
|
export function renamePodPath(filePath, options) {
|
|
3
3
|
const { dir, ext, name } = parseFilePath(filePath);
|
|
4
|
-
const {
|
|
5
|
-
if (!dir.startsWith(
|
|
6
|
-
throw new RangeError(`ERROR: The provided path \`${filePath}\` doesn't match the directory pattern \`${
|
|
4
|
+
const { podDir, replace } = options;
|
|
5
|
+
if (!dir.startsWith(podDir)) {
|
|
6
|
+
throw new RangeError(`ERROR: The provided path \`${filePath}\` doesn't match the directory pattern \`${podDir}\`.\n`);
|
|
7
7
|
}
|
|
8
8
|
const key = filePath
|
|
9
|
-
.replace(new RegExp(`^${
|
|
9
|
+
.replace(new RegExp(`^${podDir}/`), '')
|
|
10
10
|
.replace(new RegExp(`/${name}${ext}$`), '');
|
|
11
11
|
return `${replace(key)}${ext}`;
|
|
12
12
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { mapComponentClasses } from './map-component-classes.js';
|
|
2
|
-
import { mapComponentStylesheets } from './map-component-stylesheets.js';
|
|
3
|
-
import { mapComponentTemplates } from './map-component-templates.js';
|
|
4
|
-
export function mapAddonFolder(options) {
|
|
5
|
-
return new Map([
|
|
6
|
-
...mapComponentClasses(options),
|
|
7
|
-
...mapComponentStylesheets(options),
|
|
8
|
-
...mapComponentTemplates(options),
|
|
9
|
-
]);
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { mapComponentClasses } from './map-component-classes.js';
|
|
2
|
-
import { mapComponentStylesheets } from './map-component-stylesheets.js';
|
|
3
|
-
import { mapComponentTemplates } from './map-component-templates.js';
|
|
4
|
-
export function mapAppFolder(options) {
|
|
5
|
-
return new Map([
|
|
6
|
-
...mapComponentClasses(options),
|
|
7
|
-
...mapComponentStylesheets(options),
|
|
8
|
-
...mapComponentTemplates(options),
|
|
9
|
-
]);
|
|
10
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { moveFiles } from '@codemod-utils/files';
|
|
2
|
-
import { createFilePathMaps, createOptions } from './steps/index.js';
|
|
3
|
-
export function migrateEmberEngine(codemodOptions) {
|
|
4
|
-
const options = createOptions(codemodOptions);
|
|
5
|
-
const filePathMaps = createFilePathMaps(options);
|
|
6
|
-
if (options.testRun) {
|
|
7
|
-
console.log(filePathMaps);
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
// Preserve code
|
|
11
|
-
moveFiles(filePathMaps.addon, options);
|
|
12
|
-
moveFiles(filePathMaps.tests, options);
|
|
13
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { findFiles } from '@codemod-utils/files';
|
|
2
|
-
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
3
|
-
export function mapComponentStylesheets(options) {
|
|
4
|
-
const { projectRoot } = options;
|
|
5
|
-
const filePaths = findFiles('addon/components/**/styles.{css,scss}', {
|
|
6
|
-
projectRoot,
|
|
7
|
-
});
|
|
8
|
-
return filePaths.map((oldFilePath) => {
|
|
9
|
-
const newFilePath = renamePodPath(oldFilePath, {
|
|
10
|
-
entityDir: 'addon/components',
|
|
11
|
-
replace: (key) => {
|
|
12
|
-
return `addon/components/${key}`;
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
return [oldFilePath, newFilePath];
|
|
16
|
-
});
|
|
17
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { findFiles } from '@codemod-utils/files';
|
|
2
|
-
import { renamePodPath } from '../../../../../utils/files/index.js';
|
|
3
|
-
export function mapComponents(options) {
|
|
4
|
-
const { projectRoot } = options;
|
|
5
|
-
const filePaths = findFiles('tests/integration/components/**/component-test.{js,ts}', {
|
|
6
|
-
projectRoot,
|
|
7
|
-
});
|
|
8
|
-
return filePaths.map((oldFilePath) => {
|
|
9
|
-
const newFilePath = renamePodPath(oldFilePath, {
|
|
10
|
-
entityDir: 'tests/integration/components',
|
|
11
|
-
replace: (key) => {
|
|
12
|
-
return `tests/integration/components/${key}-test`;
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
return [oldFilePath, newFilePath];
|
|
16
|
-
});
|
|
17
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { mapAddonFolder } from './create-file-path-maps/addon/index.js';
|
|
2
|
-
import { mapTestsFolder } from './create-file-path-maps/tests/index.js';
|
|
3
|
-
export function createFilePathMaps(options) {
|
|
4
|
-
return {
|
|
5
|
-
addon: mapAddonFolder(options),
|
|
6
|
-
tests: mapTestsFolder(options),
|
|
7
|
-
};
|
|
8
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|