ember-codemod-pod-to-octane 1.1.5 → 1.2.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/dist/bin/ember-codemod-pod-to-octane.d.ts +1 -0
- package/{bin → dist/bin}/ember-codemod-pod-to-octane.js +14 -20
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +20 -0
- package/dist/src/migration/ember-addon/addon/component-classes.d.ts +2 -0
- package/dist/src/migration/ember-addon/addon/component-classes.js +19 -0
- package/dist/src/migration/ember-addon/addon/component-stylesheets.d.ts +2 -0
- package/dist/src/migration/ember-addon/addon/component-stylesheets.js +19 -0
- package/dist/src/migration/ember-addon/addon/component-templates.d.ts +2 -0
- package/dist/src/migration/ember-addon/addon/component-templates.js +19 -0
- package/dist/src/migration/ember-addon/addon/index.d.ts +2 -0
- package/{src → dist/src}/migration/ember-addon/addon/index.js +5 -6
- package/dist/src/migration/ember-addon/app/component-classes.d.ts +2 -0
- package/dist/src/migration/ember-addon/app/component-classes.js +19 -0
- package/dist/src/migration/ember-addon/app/component-stylesheets.d.ts +2 -0
- package/dist/src/migration/ember-addon/app/component-stylesheets.js +19 -0
- package/dist/src/migration/ember-addon/app/component-templates.d.ts +2 -0
- package/dist/src/migration/ember-addon/app/component-templates.js +19 -0
- package/dist/src/migration/ember-addon/app/index.d.ts +2 -0
- package/{src → dist/src}/migration/ember-addon/app/index.js +5 -6
- package/dist/src/migration/ember-addon/index.d.ts +2 -0
- package/dist/src/migration/ember-addon/index.js +24 -0
- package/dist/src/migration/ember-addon/steps/create-options.d.ts +2 -0
- package/dist/src/migration/ember-addon/steps/create-options.js +15 -0
- package/dist/src/migration/ember-addon/tests/components.d.ts +2 -0
- package/dist/src/migration/ember-addon/tests/components.js +19 -0
- package/dist/src/migration/ember-addon/tests/index.d.ts +2 -0
- package/{src → dist/src}/migration/ember-addon/tests/index.js +1 -2
- package/dist/src/migration/ember-app/app/component-classes.d.ts +2 -0
- package/dist/src/migration/ember-app/app/component-classes.js +20 -0
- package/dist/src/migration/ember-app/app/component-stylesheets.d.ts +2 -0
- package/dist/src/migration/ember-app/app/component-stylesheets.js +20 -0
- package/dist/src/migration/ember-app/app/component-templates.d.ts +2 -0
- package/dist/src/migration/ember-app/app/component-templates.js +20 -0
- package/dist/src/migration/ember-app/app/index.d.ts +2 -0
- package/{src → dist/src}/migration/ember-app/app/index.js +13 -14
- package/dist/src/migration/ember-app/app/route-adapters.d.ts +2 -0
- package/dist/src/migration/ember-app/app/route-adapters.js +20 -0
- package/dist/src/migration/ember-app/app/route-controllers.d.ts +2 -0
- package/dist/src/migration/ember-app/app/route-controllers.js +20 -0
- package/dist/src/migration/ember-app/app/route-models.d.ts +2 -0
- package/dist/src/migration/ember-app/app/route-models.js +20 -0
- package/dist/src/migration/ember-app/app/route-routes.d.ts +2 -0
- package/dist/src/migration/ember-app/app/route-routes.js +20 -0
- package/dist/src/migration/ember-app/app/route-serializers.d.ts +2 -0
- package/dist/src/migration/ember-app/app/route-serializers.js +20 -0
- package/dist/src/migration/ember-app/app/route-stylesheets.d.ts +2 -0
- package/dist/src/migration/ember-app/app/route-stylesheets.js +20 -0
- package/dist/src/migration/ember-app/app/route-templates.d.ts +2 -0
- package/dist/src/migration/ember-app/app/route-templates.js +20 -0
- package/dist/src/migration/ember-app/app/services.d.ts +2 -0
- package/dist/src/migration/ember-app/app/services.js +20 -0
- package/dist/src/migration/ember-app/index.d.ts +2 -0
- package/dist/src/migration/ember-app/index.js +18 -0
- package/dist/src/migration/ember-app/steps/create-options.d.ts +2 -0
- package/dist/src/migration/ember-app/steps/create-options.js +15 -0
- package/dist/src/migration/ember-app/steps/index.d.ts +1 -0
- package/dist/src/migration/ember-app/steps/index.js +1 -0
- package/dist/src/migration/ember-app/tests/components.d.ts +2 -0
- package/dist/src/migration/ember-app/tests/components.js +20 -0
- package/dist/src/migration/ember-app/tests/index.d.ts +2 -0
- package/{src → dist/src}/migration/ember-app/tests/index.js +6 -7
- package/dist/src/migration/ember-app/tests/route-controllers.d.ts +2 -0
- package/dist/src/migration/ember-app/tests/route-controllers.js +42 -0
- package/dist/src/migration/ember-app/tests/route-routes.d.ts +2 -0
- package/dist/src/migration/ember-app/tests/route-routes.js +42 -0
- package/dist/src/migration/ember-app/tests/services.d.ts +2 -0
- package/dist/src/migration/ember-app/tests/services.js +20 -0
- package/dist/src/migration/ember-engine/addon/component-classes.d.ts +2 -0
- package/dist/src/migration/ember-engine/addon/component-classes.js +19 -0
- package/dist/src/migration/ember-engine/addon/component-stylesheets.d.ts +2 -0
- package/dist/src/migration/ember-engine/addon/component-stylesheets.js +19 -0
- package/dist/src/migration/ember-engine/addon/component-templates.d.ts +2 -0
- package/dist/src/migration/ember-engine/addon/component-templates.js +19 -0
- package/dist/src/migration/ember-engine/addon/index.d.ts +2 -0
- package/{src → dist/src}/migration/ember-engine/addon/index.js +9 -10
- package/dist/src/migration/ember-engine/addon/route-controllers.d.ts +2 -0
- package/dist/src/migration/ember-engine/addon/route-controllers.js +19 -0
- package/dist/src/migration/ember-engine/addon/route-routes.d.ts +2 -0
- package/dist/src/migration/ember-engine/addon/route-routes.js +19 -0
- package/dist/src/migration/ember-engine/addon/route-stylesheets.d.ts +2 -0
- package/dist/src/migration/ember-engine/addon/route-stylesheets.js +19 -0
- package/dist/src/migration/ember-engine/addon/route-templates.d.ts +2 -0
- package/dist/src/migration/ember-engine/addon/route-templates.js +19 -0
- package/dist/src/migration/ember-engine/index.d.ts +2 -0
- package/dist/src/migration/ember-engine/index.js +25 -0
- package/dist/src/migration/ember-engine/steps/create-options.d.ts +2 -0
- package/dist/src/migration/ember-engine/steps/create-options.js +16 -0
- package/dist/src/migration/ember-engine/steps/index.js +4 -0
- package/dist/src/migration/ember-engine/steps/update-absolute-paths.d.ts +2 -0
- package/dist/src/migration/ember-engine/steps/update-absolute-paths.js +73 -0
- package/dist/src/migration/ember-engine/steps/use-absolute-paths.d.ts +2 -0
- package/dist/src/migration/ember-engine/steps/use-absolute-paths.js +41 -0
- package/dist/src/migration/ember-engine/steps/use-relative-paths.d.ts +2 -0
- package/dist/src/migration/ember-engine/steps/use-relative-paths.js +85 -0
- package/dist/src/migration/ember-engine/tests/components.d.ts +2 -0
- package/dist/src/migration/ember-engine/tests/components.js +19 -0
- package/dist/src/migration/ember-engine/tests/index.d.ts +2 -0
- package/{src → dist/src}/migration/ember-engine/tests/index.js +5 -6
- package/dist/src/migration/ember-engine/tests/route-controllers.d.ts +2 -0
- package/dist/src/migration/ember-engine/tests/route-controllers.js +41 -0
- package/dist/src/migration/ember-engine/tests/route-routes.d.ts +2 -0
- package/dist/src/migration/ember-engine/tests/route-routes.js +41 -0
- package/dist/src/migration/index.js +3 -0
- package/dist/src/types/index.d.ts +19 -0
- package/dist/src/types/index.js +1 -0
- package/dist/src/utils/ember-addon/app/components.d.ts +2 -0
- package/dist/src/utils/ember-addon/app/components.js +19 -0
- package/package.json +37 -15
- package/src/index.js +0 -28
- package/src/migration/ember-addon/addon/component-classes.js +0 -23
- package/src/migration/ember-addon/addon/component-stylesheets.js +0 -23
- package/src/migration/ember-addon/addon/component-templates.js +0 -23
- package/src/migration/ember-addon/app/component-classes.js +0 -23
- package/src/migration/ember-addon/app/component-stylesheets.js +0 -23
- package/src/migration/ember-addon/app/component-templates.js +0 -23
- package/src/migration/ember-addon/index.js +0 -31
- package/src/migration/ember-addon/steps/create-options.js +0 -19
- package/src/migration/ember-addon/tests/components.js +0 -26
- package/src/migration/ember-app/app/component-classes.js +0 -28
- package/src/migration/ember-app/app/component-stylesheets.js +0 -28
- package/src/migration/ember-app/app/component-templates.js +0 -28
- package/src/migration/ember-app/app/route-adapters.js +0 -25
- package/src/migration/ember-app/app/route-controllers.js +0 -28
- package/src/migration/ember-app/app/route-models.js +0 -25
- package/src/migration/ember-app/app/route-routes.js +0 -25
- package/src/migration/ember-app/app/route-serializers.js +0 -28
- package/src/migration/ember-app/app/route-stylesheets.js +0 -28
- package/src/migration/ember-app/app/route-templates.js +0 -28
- package/src/migration/ember-app/app/services.js +0 -25
- package/src/migration/ember-app/index.js +0 -24
- package/src/migration/ember-app/steps/create-options.js +0 -19
- package/src/migration/ember-app/tests/components.js +0 -34
- package/src/migration/ember-app/tests/route-controllers.js +0 -63
- package/src/migration/ember-app/tests/route-routes.js +0 -57
- package/src/migration/ember-app/tests/services.js +0 -28
- package/src/migration/ember-engine/addon/component-classes.js +0 -23
- package/src/migration/ember-engine/addon/component-stylesheets.js +0 -23
- package/src/migration/ember-engine/addon/component-templates.js +0 -23
- package/src/migration/ember-engine/addon/route-controllers.js +0 -23
- package/src/migration/ember-engine/addon/route-routes.js +0 -23
- package/src/migration/ember-engine/addon/route-stylesheets.js +0 -23
- package/src/migration/ember-engine/addon/route-templates.js +0 -23
- package/src/migration/ember-engine/index.js +0 -39
- package/src/migration/ember-engine/steps/create-options.js +0 -21
- package/src/migration/ember-engine/steps/update-absolute-paths.js +0 -102
- package/src/migration/ember-engine/steps/use-absolute-paths.js +0 -58
- package/src/migration/ember-engine/steps/use-relative-paths.js +0 -110
- package/src/migration/ember-engine/tests/components.js +0 -26
- package/src/migration/ember-engine/tests/route-controllers.js +0 -55
- package/src/migration/ember-engine/tests/route-routes.js +0 -49
- package/src/utils/ember-addon/app/components.js +0 -24
- /package/{src/migration/ember-addon/steps/index.js → dist/src/migration/ember-addon/steps/index.d.ts} +0 -0
- /package/{src/migration/ember-app → dist/src/migration/ember-addon}/steps/index.js +0 -0
- /package/{src/migration/ember-engine/steps/index.js → dist/src/migration/ember-engine/steps/index.d.ts} +0 -0
- /package/{src/migration/index.js → dist/src/migration/index.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,42 +1,36 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
'use strict';
|
|
3
|
-
|
|
4
2
|
import yargs from 'yargs';
|
|
5
3
|
import { hideBin } from 'yargs/helpers';
|
|
6
|
-
|
|
7
4
|
import { runCodemod } from '../src/index.js';
|
|
8
|
-
|
|
9
5
|
// Provide a title to the process in `ps`
|
|
10
6
|
process.title = 'ember-codemod-pod-to-octane';
|
|
11
|
-
|
|
12
7
|
// Set codemod options
|
|
13
|
-
const
|
|
14
|
-
|
|
8
|
+
const argv = yargs(hideBin(process.argv))
|
|
9
|
+
.option('pod-path', {
|
|
15
10
|
default: '',
|
|
16
11
|
describe: 'Namespace used for the pod layout',
|
|
17
12
|
type: 'string',
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
})
|
|
14
|
+
.option('root', {
|
|
20
15
|
describe: 'Location of your Ember project',
|
|
21
16
|
type: 'string',
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
})
|
|
18
|
+
.option('test', {
|
|
24
19
|
default: false,
|
|
25
20
|
describe: 'Do a test run?',
|
|
26
21
|
type: 'boolean',
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
})
|
|
23
|
+
.option('type', {
|
|
29
24
|
choices: ['addon', 'app', 'engine'],
|
|
30
25
|
demandOption: true,
|
|
31
26
|
describe: 'Type of your Ember project',
|
|
32
27
|
type: 'string',
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
})
|
|
29
|
+
.parseSync();
|
|
35
30
|
const codemodOptions = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
podPath: argv['pod-path'],
|
|
32
|
+
projectRoot: argv['root'] ?? process.cwd(),
|
|
33
|
+
projectType: argv['type'],
|
|
34
|
+
testRun: argv['test'],
|
|
40
35
|
};
|
|
41
|
-
|
|
42
36
|
runCodemod(codemodOptions);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { migrateEmberAddon, migrateEmberApp, migrateEmberEngine, } from './migration/index.js';
|
|
2
|
+
export function runCodemod(codemodOptions) {
|
|
3
|
+
switch (codemodOptions.projectType) {
|
|
4
|
+
case 'addon': {
|
|
5
|
+
migrateEmberAddon(codemodOptions);
|
|
6
|
+
break;
|
|
7
|
+
}
|
|
8
|
+
case 'app': {
|
|
9
|
+
migrateEmberApp(codemodOptions);
|
|
10
|
+
break;
|
|
11
|
+
}
|
|
12
|
+
case 'engine': {
|
|
13
|
+
migrateEmberEngine(codemodOptions);
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
default: {
|
|
17
|
+
console.error(`Unknown project type: ${codemodOptions.projectType}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { findFiles, renamePathByFile } from '@codemod-utils/files';
|
|
2
|
+
export function migrationStrategyForComponentClasses(options) {
|
|
3
|
+
const { projectRoot } = options;
|
|
4
|
+
const filePaths = findFiles('addon/components/**/component.{d.ts,js,ts}', {
|
|
5
|
+
projectRoot,
|
|
6
|
+
});
|
|
7
|
+
return filePaths.map((oldFilePath) => {
|
|
8
|
+
const newFilePath = renamePathByFile(oldFilePath, {
|
|
9
|
+
find: {
|
|
10
|
+
directory: 'addon/components',
|
|
11
|
+
file: 'component',
|
|
12
|
+
},
|
|
13
|
+
replace: (key) => {
|
|
14
|
+
return `addon/components/${key}`;
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
return [oldFilePath, newFilePath];
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { findFiles, renamePathByFile } from '@codemod-utils/files';
|
|
2
|
+
export function migrationStrategyForComponentStylesheets(options) {
|
|
3
|
+
const { projectRoot } = options;
|
|
4
|
+
const filePaths = findFiles('addon/components/**/styles.{css,scss}', {
|
|
5
|
+
projectRoot,
|
|
6
|
+
});
|
|
7
|
+
return filePaths.map((oldFilePath) => {
|
|
8
|
+
const newFilePath = renamePathByFile(oldFilePath, {
|
|
9
|
+
find: {
|
|
10
|
+
directory: 'addon/components',
|
|
11
|
+
file: 'styles',
|
|
12
|
+
},
|
|
13
|
+
replace: (key) => {
|
|
14
|
+
return `addon/components/${key}`;
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
return [oldFilePath, newFilePath];
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { findFiles, renamePathByFile } from '@codemod-utils/files';
|
|
2
|
+
export function migrationStrategyForComponentTemplates(options) {
|
|
3
|
+
const { projectRoot } = options;
|
|
4
|
+
const filePaths = findFiles('addon/components/**/template.hbs', {
|
|
5
|
+
projectRoot,
|
|
6
|
+
});
|
|
7
|
+
return filePaths.map((oldFilePath) => {
|
|
8
|
+
const newFilePath = renamePathByFile(oldFilePath, {
|
|
9
|
+
find: {
|
|
10
|
+
directory: 'addon/components',
|
|
11
|
+
file: 'template',
|
|
12
|
+
},
|
|
13
|
+
replace: (key) => {
|
|
14
|
+
return `addon/components/${key}`;
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
return [oldFilePath, newFilePath];
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { migrationStrategyForComponentClasses } from './component-classes.js';
|
|
2
2
|
import { migrationStrategyForComponentStylesheets } from './component-stylesheets.js';
|
|
3
3
|
import { migrationStrategyForComponentTemplates } from './component-templates.js';
|
|
4
|
-
|
|
5
4
|
export function migrationStrategyForAddonFolder(options) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
return new Map([
|
|
6
|
+
...migrationStrategyForComponentClasses(options),
|
|
7
|
+
...migrationStrategyForComponentStylesheets(options),
|
|
8
|
+
...migrationStrategyForComponentTemplates(options),
|
|
9
|
+
]);
|
|
11
10
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { findFiles, renamePathByFile } from '@codemod-utils/files';
|
|
2
|
+
export function migrationStrategyForComponentClasses(options) {
|
|
3
|
+
const { projectRoot } = options;
|
|
4
|
+
const filePaths = findFiles('app/components/**/component.js', {
|
|
5
|
+
projectRoot,
|
|
6
|
+
});
|
|
7
|
+
return filePaths.map((oldFilePath) => {
|
|
8
|
+
const newFilePath = renamePathByFile(oldFilePath, {
|
|
9
|
+
find: {
|
|
10
|
+
directory: 'app/components',
|
|
11
|
+
file: 'component',
|
|
12
|
+
},
|
|
13
|
+
replace: (key) => {
|
|
14
|
+
return `app/components/${key}`;
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
return [oldFilePath, newFilePath];
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { findFiles, renamePathByFile } from '@codemod-utils/files';
|
|
2
|
+
export function migrationStrategyForComponentStylesheets(options) {
|
|
3
|
+
const { projectRoot } = options;
|
|
4
|
+
const filePaths = findFiles('app/components/**/styles.js', {
|
|
5
|
+
projectRoot,
|
|
6
|
+
});
|
|
7
|
+
return filePaths.map((oldFilePath) => {
|
|
8
|
+
const newFilePath = renamePathByFile(oldFilePath, {
|
|
9
|
+
find: {
|
|
10
|
+
directory: 'app/components',
|
|
11
|
+
file: 'styles',
|
|
12
|
+
},
|
|
13
|
+
replace: (key) => {
|
|
14
|
+
return `app/components/${key}`;
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
return [oldFilePath, newFilePath];
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { findFiles, renamePathByFile } from '@codemod-utils/files';
|
|
2
|
+
export function migrationStrategyForComponentTemplates(options) {
|
|
3
|
+
const { projectRoot } = options;
|
|
4
|
+
const filePaths = findFiles('app/components/**/template.js', {
|
|
5
|
+
projectRoot,
|
|
6
|
+
});
|
|
7
|
+
return filePaths.map((oldFilePath) => {
|
|
8
|
+
const newFilePath = renamePathByFile(oldFilePath, {
|
|
9
|
+
find: {
|
|
10
|
+
directory: 'app/components',
|
|
11
|
+
file: 'template',
|
|
12
|
+
},
|
|
13
|
+
replace: (key) => {
|
|
14
|
+
return `app/components/${key}`;
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
return [oldFilePath, newFilePath];
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { migrationStrategyForComponentClasses } from './component-classes.js';
|
|
2
2
|
import { migrationStrategyForComponentStylesheets } from './component-stylesheets.js';
|
|
3
3
|
import { migrationStrategyForComponentTemplates } from './component-templates.js';
|
|
4
|
-
|
|
5
4
|
export function migrationStrategyForAppFolder(options) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
return new Map([
|
|
6
|
+
...migrationStrategyForComponentClasses(options),
|
|
7
|
+
...migrationStrategyForComponentStylesheets(options),
|
|
8
|
+
...migrationStrategyForComponentTemplates(options),
|
|
9
|
+
]);
|
|
11
10
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { moveFiles } from '@codemod-utils/files';
|
|
2
|
+
import { updatePathsInAppFolder } from '../../utils/ember-addon/app/components.js';
|
|
3
|
+
import { migrationStrategyForAddonFolder } from './addon/index.js';
|
|
4
|
+
import { migrationStrategyForAppFolder } from './app/index.js';
|
|
5
|
+
import { createOptions } from './steps/index.js';
|
|
6
|
+
import { migrationStrategyForTestsFolder } from './tests/index.js';
|
|
7
|
+
export function migrateEmberAddon(codemodOptions) {
|
|
8
|
+
const options = createOptions(codemodOptions);
|
|
9
|
+
const migrationStrategyAddon = migrationStrategyForAddonFolder(options);
|
|
10
|
+
const migrationStrategyApp = migrationStrategyForAppFolder(options);
|
|
11
|
+
const migrationStrategyTests = migrationStrategyForTestsFolder(options);
|
|
12
|
+
if (options.testRun) {
|
|
13
|
+
console.log({
|
|
14
|
+
migrationStrategyAddon,
|
|
15
|
+
migrationStrategyApp,
|
|
16
|
+
migrationStrategyTests,
|
|
17
|
+
});
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
moveFiles(migrationStrategyAddon, options);
|
|
21
|
+
moveFiles(migrationStrategyApp, options);
|
|
22
|
+
moveFiles(migrationStrategyTests, options);
|
|
23
|
+
updatePathsInAppFolder(migrationStrategyApp, options);
|
|
24
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { readPackageJson } from '@codemod-utils/json';
|
|
2
|
+
function analyzePackageJson(codemodOptions) {
|
|
3
|
+
const packageJson = readPackageJson(codemodOptions);
|
|
4
|
+
return packageJson.name;
|
|
5
|
+
}
|
|
6
|
+
export function createOptions(codemodOptions) {
|
|
7
|
+
const projectName = analyzePackageJson(codemodOptions);
|
|
8
|
+
return {
|
|
9
|
+
podPath: codemodOptions.podPath,
|
|
10
|
+
projectName,
|
|
11
|
+
projectRoot: codemodOptions.projectRoot,
|
|
12
|
+
projectType: codemodOptions.projectType,
|
|
13
|
+
testRun: codemodOptions.testRun,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { findFiles, renamePathByFile } from '@codemod-utils/files';
|
|
2
|
+
export function migrationStrategyForComponents(options) {
|
|
3
|
+
const { projectRoot } = options;
|
|
4
|
+
const filePaths = findFiles('tests/integration/components/**/component-test.{js,ts}', {
|
|
5
|
+
projectRoot,
|
|
6
|
+
});
|
|
7
|
+
return filePaths.map((oldFilePath) => {
|
|
8
|
+
const newFilePath = renamePathByFile(oldFilePath, {
|
|
9
|
+
find: {
|
|
10
|
+
directory: 'tests/integration/components',
|
|
11
|
+
file: 'component-test',
|
|
12
|
+
},
|
|
13
|
+
replace: (key) => {
|
|
14
|
+
return `tests/integration/components/${key}-test`;
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
return [oldFilePath, newFilePath];
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { findFiles, renamePathByFile } from '@codemod-utils/files';
|
|
3
|
+
export function migrationStrategyForComponentClasses(options) {
|
|
4
|
+
const { podPath, projectRoot } = options;
|
|
5
|
+
const filePaths = findFiles(join('app', podPath, 'components', '**', 'component.{d.ts,js,ts}'), {
|
|
6
|
+
projectRoot,
|
|
7
|
+
});
|
|
8
|
+
return filePaths.map((oldFilePath) => {
|
|
9
|
+
const newFilePath = renamePathByFile(oldFilePath, {
|
|
10
|
+
find: {
|
|
11
|
+
directory: join('app', podPath, 'components'),
|
|
12
|
+
file: 'component',
|
|
13
|
+
},
|
|
14
|
+
replace: (key) => {
|
|
15
|
+
return `app/components/${key}`;
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
return [oldFilePath, newFilePath];
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { findFiles, renamePathByFile } from '@codemod-utils/files';
|
|
3
|
+
export function migrationStrategyForComponentStylesheets(options) {
|
|
4
|
+
const { podPath, projectRoot } = options;
|
|
5
|
+
const filePaths = findFiles(join('app', podPath, 'components', '**', 'styles.{css,scss}'), {
|
|
6
|
+
projectRoot,
|
|
7
|
+
});
|
|
8
|
+
return filePaths.map((oldFilePath) => {
|
|
9
|
+
const newFilePath = renamePathByFile(oldFilePath, {
|
|
10
|
+
find: {
|
|
11
|
+
directory: join('app', podPath, 'components'),
|
|
12
|
+
file: 'styles',
|
|
13
|
+
},
|
|
14
|
+
replace: (key) => {
|
|
15
|
+
return `app/components/${key}`;
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
return [oldFilePath, newFilePath];
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { findFiles, renamePathByFile } from '@codemod-utils/files';
|
|
3
|
+
export function migrationStrategyForComponentTemplates(options) {
|
|
4
|
+
const { podPath, projectRoot } = options;
|
|
5
|
+
const filePaths = findFiles(join('app', podPath, 'components', '**', 'template.hbs'), {
|
|
6
|
+
projectRoot,
|
|
7
|
+
});
|
|
8
|
+
return filePaths.map((oldFilePath) => {
|
|
9
|
+
const newFilePath = renamePathByFile(oldFilePath, {
|
|
10
|
+
find: {
|
|
11
|
+
directory: join('app', podPath, 'components'),
|
|
12
|
+
file: 'template',
|
|
13
|
+
},
|
|
14
|
+
replace: (key) => {
|
|
15
|
+
return `app/components/${key}`;
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
return [oldFilePath, newFilePath];
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -9,19 +9,18 @@ import { migrationStrategyForRouteSerializers } from './route-serializers.js';
|
|
|
9
9
|
import { migrationStrategyForRouteStylesheets } from './route-stylesheets.js';
|
|
10
10
|
import { migrationStrategyForRouteTemplates } from './route-templates.js';
|
|
11
11
|
import { migrationStrategyForServices } from './services.js';
|
|
12
|
-
|
|
13
12
|
export function migrationStrategyForAppFolder(options) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
13
|
+
return new Map([
|
|
14
|
+
...migrationStrategyForComponentClasses(options),
|
|
15
|
+
...migrationStrategyForComponentStylesheets(options),
|
|
16
|
+
...migrationStrategyForComponentTemplates(options),
|
|
17
|
+
...migrationStrategyForRouteAdapters(options),
|
|
18
|
+
...migrationStrategyForRouteControllers(options),
|
|
19
|
+
...migrationStrategyForRouteModels(options),
|
|
20
|
+
...migrationStrategyForRouteRoutes(options),
|
|
21
|
+
...migrationStrategyForRouteSerializers(options),
|
|
22
|
+
...migrationStrategyForRouteStylesheets(options),
|
|
23
|
+
...migrationStrategyForRouteTemplates(options),
|
|
24
|
+
...migrationStrategyForServices(options),
|
|
25
|
+
]);
|
|
27
26
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { findFiles, renamePathByFile } from '@codemod-utils/files';
|
|
3
|
+
export function migrationStrategyForRouteAdapters(options) {
|
|
4
|
+
const { podPath, projectRoot } = options;
|
|
5
|
+
const filePaths = findFiles(join('app', podPath, '**', 'adapter.{js,ts}'), {
|
|
6
|
+
projectRoot,
|
|
7
|
+
});
|
|
8
|
+
return filePaths.map((oldFilePath) => {
|
|
9
|
+
const newFilePath = renamePathByFile(oldFilePath, {
|
|
10
|
+
find: {
|
|
11
|
+
directory: join('app', podPath),
|
|
12
|
+
file: 'adapter',
|
|
13
|
+
},
|
|
14
|
+
replace: (key) => {
|
|
15
|
+
return `app/adapters/${key}`;
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
return [oldFilePath, newFilePath];
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { findFiles, renamePathByFile } from '@codemod-utils/files';
|
|
3
|
+
export function migrationStrategyForRouteControllers(options) {
|
|
4
|
+
const { podPath, projectRoot } = options;
|
|
5
|
+
const filePaths = findFiles(join('app', podPath, '**', 'controller.{js,ts}'), {
|
|
6
|
+
projectRoot,
|
|
7
|
+
});
|
|
8
|
+
return filePaths.map((oldFilePath) => {
|
|
9
|
+
const newFilePath = renamePathByFile(oldFilePath, {
|
|
10
|
+
find: {
|
|
11
|
+
directory: join('app', podPath),
|
|
12
|
+
file: 'controller',
|
|
13
|
+
},
|
|
14
|
+
replace: (key) => {
|
|
15
|
+
return `app/controllers/${key}`;
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
return [oldFilePath, newFilePath];
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { findFiles, renamePathByFile } from '@codemod-utils/files';
|
|
3
|
+
export function migrationStrategyForRouteModels(options) {
|
|
4
|
+
const { podPath, projectRoot } = options;
|
|
5
|
+
const filePaths = findFiles(join('app', podPath, '**', 'model.{js,ts}'), {
|
|
6
|
+
projectRoot,
|
|
7
|
+
});
|
|
8
|
+
return filePaths.map((oldFilePath) => {
|
|
9
|
+
const newFilePath = renamePathByFile(oldFilePath, {
|
|
10
|
+
find: {
|
|
11
|
+
directory: join('app', podPath),
|
|
12
|
+
file: 'model',
|
|
13
|
+
},
|
|
14
|
+
replace: (key) => {
|
|
15
|
+
return `app/models/${key}`;
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
return [oldFilePath, newFilePath];
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { findFiles, renamePathByFile } from '@codemod-utils/files';
|
|
3
|
+
export function migrationStrategyForRouteRoutes(options) {
|
|
4
|
+
const { podPath, projectRoot } = options;
|
|
5
|
+
const filePaths = findFiles(join('app', podPath, '**', 'route.{js,ts}'), {
|
|
6
|
+
projectRoot,
|
|
7
|
+
});
|
|
8
|
+
return filePaths.map((oldFilePath) => {
|
|
9
|
+
const newFilePath = renamePathByFile(oldFilePath, {
|
|
10
|
+
find: {
|
|
11
|
+
directory: join('app', podPath),
|
|
12
|
+
file: 'route',
|
|
13
|
+
},
|
|
14
|
+
replace: (key) => {
|
|
15
|
+
return `app/routes/${key}`;
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
return [oldFilePath, newFilePath];
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { findFiles, renamePathByFile } from '@codemod-utils/files';
|
|
3
|
+
export function migrationStrategyForRouteSerializers(options) {
|
|
4
|
+
const { podPath, projectRoot } = options;
|
|
5
|
+
const filePaths = findFiles(join('app', podPath, '**', 'serializer.{js,ts}'), {
|
|
6
|
+
projectRoot,
|
|
7
|
+
});
|
|
8
|
+
return filePaths.map((oldFilePath) => {
|
|
9
|
+
const newFilePath = renamePathByFile(oldFilePath, {
|
|
10
|
+
find: {
|
|
11
|
+
directory: join('app', podPath),
|
|
12
|
+
file: 'serializer',
|
|
13
|
+
},
|
|
14
|
+
replace: (key) => {
|
|
15
|
+
return `app/serializers/${key}`;
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
return [oldFilePath, newFilePath];
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { findFiles, renamePathByFile } from '@codemod-utils/files';
|
|
3
|
+
export function migrationStrategyForRouteStylesheets(options) {
|
|
4
|
+
const { podPath, projectRoot } = options;
|
|
5
|
+
const filePaths = findFiles(join('app', podPath, '!(components)', '**', 'styles.{css,scss}'), {
|
|
6
|
+
projectRoot,
|
|
7
|
+
});
|
|
8
|
+
return filePaths.map((oldFilePath) => {
|
|
9
|
+
const newFilePath = renamePathByFile(oldFilePath, {
|
|
10
|
+
find: {
|
|
11
|
+
directory: join('app', podPath),
|
|
12
|
+
file: 'styles',
|
|
13
|
+
},
|
|
14
|
+
replace: (key) => {
|
|
15
|
+
return `app/styles/${key}`;
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
return [oldFilePath, newFilePath];
|
|
19
|
+
});
|
|
20
|
+
}
|