ember-codemod-pod-to-octane 1.1.0 → 1.1.2
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 +10 -3
- package/package.json +18 -18
- package/src/migration/ember-addon/addon/component-classes.js +2 -2
- package/src/migration/ember-addon/addon/component-stylesheets.js +2 -2
- package/src/migration/ember-addon/addon/component-templates.js +2 -2
- package/src/migration/ember-addon/app/component-classes.js +2 -2
- package/src/migration/ember-addon/app/component-stylesheets.js +2 -2
- package/src/migration/ember-addon/app/component-templates.js +2 -2
- package/src/migration/ember-addon/index.js +2 -1
- package/src/migration/ember-addon/steps/create-options.js +2 -2
- package/src/migration/ember-addon/tests/components.js +3 -3
- package/src/migration/ember-app/app/component-classes.js +3 -3
- package/src/migration/ember-app/app/component-stylesheets.js +3 -3
- package/src/migration/ember-app/app/component-templates.js +3 -3
- package/src/migration/ember-app/app/route-adapters.js +2 -2
- package/src/migration/ember-app/app/route-controllers.js +2 -2
- package/src/migration/ember-app/app/route-models.js +2 -2
- package/src/migration/ember-app/app/route-routes.js +2 -2
- package/src/migration/ember-app/app/route-serializers.js +2 -2
- package/src/migration/ember-app/app/route-stylesheets.js +3 -3
- package/src/migration/ember-app/app/route-templates.js +3 -3
- package/src/migration/ember-app/app/services.js +2 -2
- package/src/migration/ember-app/index.js +2 -1
- package/src/migration/ember-app/steps/create-options.js +2 -2
- package/src/migration/ember-app/tests/components.js +4 -4
- package/src/migration/ember-app/tests/route-controllers.js +6 -6
- package/src/migration/ember-app/tests/route-routes.js +5 -5
- package/src/migration/ember-app/tests/services.js +3 -3
- package/src/migration/ember-engine/addon/component-classes.js +2 -2
- package/src/migration/ember-engine/addon/component-stylesheets.js +2 -2
- package/src/migration/ember-engine/addon/component-templates.js +2 -2
- package/src/migration/ember-engine/addon/route-controllers.js +2 -2
- package/src/migration/ember-engine/addon/route-routes.js +2 -2
- package/src/migration/ember-engine/addon/route-stylesheets.js +2 -2
- package/src/migration/ember-engine/addon/route-templates.js +2 -2
- package/src/migration/ember-engine/index.js +2 -1
- package/src/migration/ember-engine/steps/create-options.js +2 -2
- package/src/migration/ember-engine/steps/update-absolute-paths.js +3 -5
- package/src/migration/ember-engine/steps/use-absolute-paths.js +3 -5
- package/src/migration/ember-engine/steps/use-relative-paths.js +5 -11
- package/src/migration/ember-engine/tests/components.js +3 -3
- package/src/migration/ember-engine/tests/route-controllers.js +5 -5
- package/src/migration/ember-engine/tests/route-routes.js +3 -3
- package/src/utils/files/map-file-path.js +1 -1
- package/src/utils/files.js +0 -2
- package/src/utils/files/move-files.js +0 -22
- package/src/utils/files/remove-directory-if-empty.js +0 -19
package/README.md
CHANGED
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
_Codemod to un-pod Ember apps, addons, and engines_
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- Preserves your code whenever possible
|
|
11
|
+
- Supports [`ember-css-modules`](https://github.com/salsify/ember-css-modules)
|
|
12
|
+
|
|
13
|
+
|
|
8
14
|
## Usage
|
|
9
15
|
|
|
10
16
|
Step 1. Quickly return to [default Octane](https://cli.emberjs.com/release/advanced-use/project-layouts/#classiclayout).<sup>1</sup>
|
|
@@ -35,7 +41,7 @@ npx ember-codemod-pod-to-octane --type=engine
|
|
|
35
41
|
<details>
|
|
36
42
|
<summary>Optional: Do a test run</summary>
|
|
37
43
|
|
|
38
|
-
Pass `--test` to preview how the codemod will move files
|
|
44
|
+
Pass `--test` to preview how the codemod will move files.
|
|
39
45
|
|
|
40
46
|
```sh
|
|
41
47
|
npx ember-codemod-pod-to-octane --test
|
|
@@ -116,12 +122,13 @@ cd <your/cloned/repo>
|
|
|
116
122
|
## Compatibility
|
|
117
123
|
|
|
118
124
|
* Node.js v16 or above
|
|
119
|
-
* [`ember-css-modules`](https://github.com/salsify/ember-css-modules)
|
|
120
125
|
|
|
121
126
|
|
|
122
127
|
## Contributing
|
|
123
128
|
|
|
124
|
-
|
|
129
|
+
See the [Contributing](CONTRIBUTING.md) guide for details.
|
|
130
|
+
|
|
131
|
+
If you have an open-sourced app or addon that I can use as a reference, reach out to me on [Discord](https://discord.gg/emberjs) at `ijlee2`. Please star this project so that I can gauge its importance to you and the Ember community. ⭐
|
|
125
132
|
|
|
126
133
|
|
|
127
134
|
## Credits
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-codemod-pod-to-octane",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Codemod to un-pod Ember apps, addons, and engines",
|
|
5
5
|
"keywords": [
|
|
6
|
+
"codemod",
|
|
6
7
|
"ember-codemod",
|
|
7
8
|
"ember-octane",
|
|
8
9
|
"emberjs"
|
|
@@ -23,30 +24,23 @@
|
|
|
23
24
|
"bin/",
|
|
24
25
|
"src/"
|
|
25
26
|
],
|
|
26
|
-
"scripts": {
|
|
27
|
-
"changelog": "lerna-changelog",
|
|
28
|
-
"lint": "eslint . --cache",
|
|
29
|
-
"lint:fix": "eslint . --fix",
|
|
30
|
-
"start": "node ./src/index.js",
|
|
31
|
-
"test": "mt tests --quiet"
|
|
32
|
-
},
|
|
33
27
|
"dependencies": {
|
|
34
|
-
"@
|
|
35
|
-
"
|
|
36
|
-
"glob": "^8.1.0",
|
|
37
|
-
"yargs": "^17.7.1"
|
|
28
|
+
"@codemod-utils/files": "^0.1.0",
|
|
29
|
+
"yargs": "^17.7.2"
|
|
38
30
|
},
|
|
39
31
|
"devDependencies": {
|
|
32
|
+
"@babel/core": "^7.21.8",
|
|
33
|
+
"@babel/eslint-parser": "^7.21.8",
|
|
34
|
+
"@codemod-utils/tests": "^0.1.0",
|
|
40
35
|
"@sondr3/minitest": "^0.1.1",
|
|
41
|
-
"eslint": "^8.
|
|
42
|
-
"eslint-config-prettier": "^8.
|
|
36
|
+
"eslint": "^8.40.0",
|
|
37
|
+
"eslint-config-prettier": "^8.8.0",
|
|
43
38
|
"eslint-plugin-import": "^2.27.5",
|
|
44
|
-
"eslint-plugin-n": "^
|
|
39
|
+
"eslint-plugin-n": "^16.0.0",
|
|
45
40
|
"eslint-plugin-prettier": "^4.2.1",
|
|
46
41
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
47
|
-
"fixturify": "^3.0.0",
|
|
48
42
|
"lerna-changelog": "^2.2.0",
|
|
49
|
-
"prettier": "^2.8.
|
|
43
|
+
"prettier": "^2.8.8"
|
|
50
44
|
},
|
|
51
45
|
"engines": {
|
|
52
46
|
"node": ">= 16"
|
|
@@ -60,5 +54,11 @@
|
|
|
60
54
|
"enhance: documentation": "Documentation",
|
|
61
55
|
"user feedback": "User Feedback"
|
|
62
56
|
}
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"changelog": "lerna-changelog",
|
|
60
|
+
"lint": "eslint . --cache",
|
|
61
|
+
"lint:fix": "eslint . --fix",
|
|
62
|
+
"test": "mt tests --quiet"
|
|
63
63
|
}
|
|
64
|
-
}
|
|
64
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { findFiles } from '@codemod-utils/files';
|
|
2
2
|
|
|
3
3
|
import { mapFilePath } from '../../../utils/files.js';
|
|
4
4
|
|
|
5
5
|
export function migrationStrategyForComponentClasses(options) {
|
|
6
6
|
const { projectRoot } = options;
|
|
7
7
|
|
|
8
|
-
const oldPaths =
|
|
8
|
+
const oldPaths = findFiles('addon/components/**/component.{d.ts,js,ts}', {
|
|
9
9
|
cwd: projectRoot,
|
|
10
10
|
});
|
|
11
11
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { findFiles } from '@codemod-utils/files';
|
|
2
2
|
|
|
3
3
|
import { mapFilePath } from '../../../utils/files.js';
|
|
4
4
|
|
|
5
5
|
export function migrationStrategyForComponentStylesheets(options) {
|
|
6
6
|
const { projectRoot } = options;
|
|
7
7
|
|
|
8
|
-
const oldPaths =
|
|
8
|
+
const oldPaths = findFiles('addon/components/**/styles.{css,scss}', {
|
|
9
9
|
cwd: projectRoot,
|
|
10
10
|
});
|
|
11
11
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { findFiles } from '@codemod-utils/files';
|
|
2
2
|
|
|
3
3
|
import { mapFilePath } from '../../../utils/files.js';
|
|
4
4
|
|
|
5
5
|
export function migrationStrategyForComponentTemplates(options) {
|
|
6
6
|
const { projectRoot } = options;
|
|
7
7
|
|
|
8
|
-
const oldPaths =
|
|
8
|
+
const oldPaths = findFiles('addon/components/**/template.hbs', {
|
|
9
9
|
cwd: projectRoot,
|
|
10
10
|
});
|
|
11
11
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { findFiles } from '@codemod-utils/files';
|
|
2
2
|
|
|
3
3
|
import { mapFilePath } from '../../../utils/files.js';
|
|
4
4
|
|
|
5
5
|
export function migrationStrategyForComponentClasses(options) {
|
|
6
6
|
const { projectRoot } = options;
|
|
7
7
|
|
|
8
|
-
const oldPaths =
|
|
8
|
+
const oldPaths = findFiles('app/components/**/component.js', {
|
|
9
9
|
cwd: projectRoot,
|
|
10
10
|
});
|
|
11
11
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { findFiles } from '@codemod-utils/files';
|
|
2
2
|
|
|
3
3
|
import { mapFilePath } from '../../../utils/files.js';
|
|
4
4
|
|
|
5
5
|
export function migrationStrategyForComponentStylesheets(options) {
|
|
6
6
|
const { projectRoot } = options;
|
|
7
7
|
|
|
8
|
-
const oldPaths =
|
|
8
|
+
const oldPaths = findFiles('app/components/**/styles.js', {
|
|
9
9
|
cwd: projectRoot,
|
|
10
10
|
});
|
|
11
11
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { findFiles } from '@codemod-utils/files';
|
|
2
2
|
|
|
3
3
|
import { mapFilePath } from '../../../utils/files.js';
|
|
4
4
|
|
|
5
5
|
export function migrationStrategyForComponentTemplates(options) {
|
|
6
6
|
const { projectRoot } = options;
|
|
7
7
|
|
|
8
|
-
const oldPaths =
|
|
8
|
+
const oldPaths = findFiles('app/components/**/template.js', {
|
|
9
9
|
cwd: projectRoot,
|
|
10
10
|
});
|
|
11
11
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { moveFiles } from '@codemod-utils/files';
|
|
2
|
+
|
|
1
3
|
import { updatePathsInAppFolder } from '../../utils/ember-addon/app/components.js';
|
|
2
|
-
import { moveFiles } from '../../utils/files.js';
|
|
3
4
|
import { migrationStrategyForAddonFolder } from './addon/index.js';
|
|
4
5
|
import { migrationStrategyForAppFolder } from './app/index.js';
|
|
5
6
|
import { createOptions } from './steps/index.js';
|
|
@@ -7,7 +7,7 @@ function analyzePackageJson(codemodOptions) {
|
|
|
7
7
|
try {
|
|
8
8
|
const packageJsonFile = readFileSync(
|
|
9
9
|
join(projectRoot, 'package.json'),
|
|
10
|
-
'utf8'
|
|
10
|
+
'utf8',
|
|
11
11
|
);
|
|
12
12
|
|
|
13
13
|
const { name } = JSON.parse(packageJsonFile);
|
|
@@ -28,7 +28,7 @@ function analyzePackageJson(codemodOptions) {
|
|
|
28
28
|
return name;
|
|
29
29
|
} catch (e) {
|
|
30
30
|
throw new SyntaxError(
|
|
31
|
-
`ERROR: package.json is missing or is not valid. (${e.message})\n
|
|
31
|
+
`ERROR: package.json is missing or is not valid. (${e.message})\n`,
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { findFiles } from '@codemod-utils/files';
|
|
2
2
|
|
|
3
3
|
import { mapFilePath } from '../../../utils/files.js';
|
|
4
4
|
|
|
5
5
|
export function migrationStrategyForComponents(options) {
|
|
6
6
|
const { projectRoot } = options;
|
|
7
7
|
|
|
8
|
-
const oldPaths =
|
|
8
|
+
const oldPaths = findFiles(
|
|
9
9
|
'tests/integration/components/**/component-test.{js,ts}',
|
|
10
10
|
{
|
|
11
11
|
cwd: projectRoot,
|
|
12
|
-
}
|
|
12
|
+
},
|
|
13
13
|
);
|
|
14
14
|
|
|
15
15
|
return oldPaths.map((oldPath) => {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { findFiles } from '@codemod-utils/files';
|
|
4
4
|
|
|
5
5
|
import { mapFilePath } from '../../../utils/files.js';
|
|
6
6
|
|
|
7
7
|
export function migrationStrategyForComponentClasses(options) {
|
|
8
8
|
const { podPath, projectRoot } = options;
|
|
9
9
|
|
|
10
|
-
const oldPaths =
|
|
10
|
+
const oldPaths = findFiles(
|
|
11
11
|
join('app', podPath, 'components', '**', 'component.{d.ts,js,ts}'),
|
|
12
12
|
{
|
|
13
13
|
cwd: projectRoot,
|
|
14
|
-
}
|
|
14
|
+
},
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
return oldPaths.map((oldPath) => {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { findFiles } from '@codemod-utils/files';
|
|
4
4
|
|
|
5
5
|
import { mapFilePath } from '../../../utils/files.js';
|
|
6
6
|
|
|
7
7
|
export function migrationStrategyForComponentStylesheets(options) {
|
|
8
8
|
const { podPath, projectRoot } = options;
|
|
9
9
|
|
|
10
|
-
const oldPaths =
|
|
10
|
+
const oldPaths = findFiles(
|
|
11
11
|
join('app', podPath, 'components', '**', 'styles.{css,scss}'),
|
|
12
12
|
{
|
|
13
13
|
cwd: projectRoot,
|
|
14
|
-
}
|
|
14
|
+
},
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
return oldPaths.map((oldPath) => {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { findFiles } from '@codemod-utils/files';
|
|
4
4
|
|
|
5
5
|
import { mapFilePath } from '../../../utils/files.js';
|
|
6
6
|
|
|
7
7
|
export function migrationStrategyForComponentTemplates(options) {
|
|
8
8
|
const { podPath, projectRoot } = options;
|
|
9
9
|
|
|
10
|
-
const oldPaths =
|
|
10
|
+
const oldPaths = findFiles(
|
|
11
11
|
join('app', podPath, 'components', '**', 'template.hbs'),
|
|
12
12
|
{
|
|
13
13
|
cwd: projectRoot,
|
|
14
|
-
}
|
|
14
|
+
},
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
return oldPaths.map((oldPath) => {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { findFiles } from '@codemod-utils/files';
|
|
4
4
|
|
|
5
5
|
import { mapFilePath } from '../../../utils/files.js';
|
|
6
6
|
|
|
7
7
|
export function migrationStrategyForRouteAdapters(options) {
|
|
8
8
|
const { podPath, projectRoot } = options;
|
|
9
9
|
|
|
10
|
-
const oldPaths =
|
|
10
|
+
const oldPaths = findFiles(join('app', podPath, '**', 'adapter.{js,ts}'), {
|
|
11
11
|
cwd: projectRoot,
|
|
12
12
|
});
|
|
13
13
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { findFiles } from '@codemod-utils/files';
|
|
4
4
|
|
|
5
5
|
import { mapFilePath } from '../../../utils/files.js';
|
|
6
6
|
|
|
7
7
|
export function migrationStrategyForRouteControllers(options) {
|
|
8
8
|
const { podPath, projectRoot } = options;
|
|
9
9
|
|
|
10
|
-
const oldPaths =
|
|
10
|
+
const oldPaths = findFiles(join('app', podPath, '**', 'controller.{js,ts}'), {
|
|
11
11
|
cwd: projectRoot,
|
|
12
12
|
});
|
|
13
13
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { findFiles } from '@codemod-utils/files';
|
|
4
4
|
|
|
5
5
|
import { mapFilePath } from '../../../utils/files.js';
|
|
6
6
|
|
|
7
7
|
export function migrationStrategyForRouteModels(options) {
|
|
8
8
|
const { podPath, projectRoot } = options;
|
|
9
9
|
|
|
10
|
-
const oldPaths =
|
|
10
|
+
const oldPaths = findFiles(join('app', podPath, '**', 'model.{js,ts}'), {
|
|
11
11
|
cwd: projectRoot,
|
|
12
12
|
});
|
|
13
13
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { findFiles } from '@codemod-utils/files';
|
|
4
4
|
|
|
5
5
|
import { mapFilePath } from '../../../utils/files.js';
|
|
6
6
|
|
|
7
7
|
export function migrationStrategyForRouteRoutes(options) {
|
|
8
8
|
const { podPath, projectRoot } = options;
|
|
9
9
|
|
|
10
|
-
const oldPaths =
|
|
10
|
+
const oldPaths = findFiles(join('app', podPath, '**', 'route.{js,ts}'), {
|
|
11
11
|
cwd: projectRoot,
|
|
12
12
|
});
|
|
13
13
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { findFiles } from '@codemod-utils/files';
|
|
4
4
|
|
|
5
5
|
import { mapFilePath } from '../../../utils/files.js';
|
|
6
6
|
|
|
7
7
|
export function migrationStrategyForRouteSerializers(options) {
|
|
8
8
|
const { podPath, projectRoot } = options;
|
|
9
9
|
|
|
10
|
-
const oldPaths =
|
|
10
|
+
const oldPaths = findFiles(join('app', podPath, '**', 'serializer.{js,ts}'), {
|
|
11
11
|
cwd: projectRoot,
|
|
12
12
|
});
|
|
13
13
|
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { findFiles } from '@codemod-utils/files';
|
|
4
4
|
|
|
5
5
|
import { mapFilePath } from '../../../utils/files.js';
|
|
6
6
|
|
|
7
7
|
export function migrationStrategyForRouteStylesheets(options) {
|
|
8
8
|
const { podPath, projectRoot } = options;
|
|
9
9
|
|
|
10
|
-
const oldPaths =
|
|
10
|
+
const oldPaths = findFiles(
|
|
11
11
|
join('app', podPath, '!(components)', '**', 'styles.{css,scss}'),
|
|
12
12
|
{
|
|
13
13
|
cwd: projectRoot,
|
|
14
|
-
}
|
|
14
|
+
},
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
return oldPaths.map((oldPath) => {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { findFiles } from '@codemod-utils/files';
|
|
4
4
|
|
|
5
5
|
import { mapFilePath } from '../../../utils/files.js';
|
|
6
6
|
|
|
7
7
|
export function migrationStrategyForRouteTemplates(options) {
|
|
8
8
|
const { podPath, projectRoot } = options;
|
|
9
9
|
|
|
10
|
-
const oldPaths =
|
|
10
|
+
const oldPaths = findFiles(
|
|
11
11
|
join('app', podPath, '!(components)', '**', 'template.hbs'),
|
|
12
12
|
{
|
|
13
13
|
cwd: projectRoot,
|
|
14
|
-
}
|
|
14
|
+
},
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
return oldPaths.map((oldPath) => {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { findFiles } from '@codemod-utils/files';
|
|
4
4
|
|
|
5
5
|
import { mapFilePath } from '../../../utils/files.js';
|
|
6
6
|
|
|
7
7
|
export function migrationStrategyForServices(options) {
|
|
8
8
|
const { podPath, projectRoot } = options;
|
|
9
9
|
|
|
10
|
-
const oldPaths =
|
|
10
|
+
const oldPaths = findFiles(join('app', podPath, '**', 'service.{js,ts}'), {
|
|
11
11
|
cwd: projectRoot,
|
|
12
12
|
});
|
|
13
13
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { moveFiles } from '
|
|
1
|
+
import { moveFiles } from '@codemod-utils/files';
|
|
2
|
+
|
|
2
3
|
import { migrationStrategyForAppFolder } from './app/index.js';
|
|
3
4
|
import { createOptions } from './steps/index.js';
|
|
4
5
|
import { migrationStrategyForTestsFolder } from './tests/index.js';
|
|
@@ -7,7 +7,7 @@ function analyzePackageJson(codemodOptions) {
|
|
|
7
7
|
try {
|
|
8
8
|
const packageJsonFile = readFileSync(
|
|
9
9
|
join(projectRoot, 'package.json'),
|
|
10
|
-
'utf8'
|
|
10
|
+
'utf8',
|
|
11
11
|
);
|
|
12
12
|
|
|
13
13
|
const { name } = JSON.parse(packageJsonFile);
|
|
@@ -28,7 +28,7 @@ function analyzePackageJson(codemodOptions) {
|
|
|
28
28
|
return name;
|
|
29
29
|
} catch (e) {
|
|
30
30
|
throw new SyntaxError(
|
|
31
|
-
`ERROR: package.json is missing or is not valid. (${e.message})\n
|
|
31
|
+
`ERROR: package.json is missing or is not valid. (${e.message})\n`,
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { findFiles } from '@codemod-utils/files';
|
|
4
4
|
|
|
5
5
|
import { mapFilePath } from '../../../utils/files.js';
|
|
6
6
|
|
|
7
7
|
export function migrationStrategyForComponents(options) {
|
|
8
8
|
const { podPath, projectRoot } = options;
|
|
9
9
|
|
|
10
|
-
const oldPaths =
|
|
10
|
+
const oldPaths = findFiles(
|
|
11
11
|
join(
|
|
12
12
|
'tests/integration',
|
|
13
13
|
podPath,
|
|
14
14
|
'components',
|
|
15
15
|
'**',
|
|
16
|
-
'component-test.{js,ts}'
|
|
16
|
+
'component-test.{js,ts}',
|
|
17
17
|
),
|
|
18
18
|
{
|
|
19
19
|
cwd: projectRoot,
|
|
20
|
-
}
|
|
20
|
+
},
|
|
21
21
|
);
|
|
22
22
|
|
|
23
23
|
return oldPaths.map((oldPath) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { findFiles } from '@codemod-utils/files';
|
|
4
4
|
|
|
5
5
|
import { mapFilePath } from '../../../utils/files.js';
|
|
6
6
|
|
|
@@ -10,17 +10,17 @@ export function migrationStrategyForRouteControllers(options) {
|
|
|
10
10
|
/*
|
|
11
11
|
Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
|
|
12
12
|
*/
|
|
13
|
-
const oldPaths1 =
|
|
13
|
+
const oldPaths1 = findFiles(
|
|
14
14
|
join(
|
|
15
15
|
'tests/unit',
|
|
16
16
|
podPath,
|
|
17
17
|
'!(controllers)',
|
|
18
18
|
'**',
|
|
19
|
-
'controller-test.{js,ts}'
|
|
19
|
+
'controller-test.{js,ts}',
|
|
20
20
|
),
|
|
21
21
|
{
|
|
22
22
|
cwd: projectRoot,
|
|
23
|
-
}
|
|
23
|
+
},
|
|
24
24
|
);
|
|
25
25
|
|
|
26
26
|
const newPaths1 = oldPaths1.map((oldPath) => {
|
|
@@ -50,11 +50,11 @@ export function migrationStrategyForRouteControllers(options) {
|
|
|
50
50
|
/*
|
|
51
51
|
Case 2: Passed the --pod flag to Ember CLI
|
|
52
52
|
*/
|
|
53
|
-
const oldPaths2 =
|
|
53
|
+
const oldPaths2 = findFiles(
|
|
54
54
|
join('tests/unit', podPath, 'controllers/**/controller-test.{js,ts}'),
|
|
55
55
|
{
|
|
56
56
|
cwd: projectRoot,
|
|
57
|
-
}
|
|
57
|
+
},
|
|
58
58
|
);
|
|
59
59
|
|
|
60
60
|
const newPaths2 = oldPaths2.map((oldPath) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { findFiles } from '@codemod-utils/files';
|
|
4
4
|
|
|
5
5
|
import { mapFilePath } from '../../../utils/files.js';
|
|
6
6
|
|
|
@@ -10,11 +10,11 @@ export function migrationStrategyForRouteRoutes(options) {
|
|
|
10
10
|
/*
|
|
11
11
|
Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
|
|
12
12
|
*/
|
|
13
|
-
const oldPaths1 =
|
|
13
|
+
const oldPaths1 = findFiles(
|
|
14
14
|
join('tests/unit', podPath, '!(routes)', '**', 'route-test.{js,ts}'),
|
|
15
15
|
{
|
|
16
16
|
cwd: projectRoot,
|
|
17
|
-
}
|
|
17
|
+
},
|
|
18
18
|
);
|
|
19
19
|
|
|
20
20
|
const newPaths1 = oldPaths1.map((oldPath) => {
|
|
@@ -44,11 +44,11 @@ export function migrationStrategyForRouteRoutes(options) {
|
|
|
44
44
|
/*
|
|
45
45
|
Case 2: Passed the --pod flag to Ember CLI
|
|
46
46
|
*/
|
|
47
|
-
const oldPaths2 =
|
|
47
|
+
const oldPaths2 = findFiles(
|
|
48
48
|
join('tests/unit', podPath, 'routes/**/route-test.{js,ts}'),
|
|
49
49
|
{
|
|
50
50
|
cwd: projectRoot,
|
|
51
|
-
}
|
|
51
|
+
},
|
|
52
52
|
);
|
|
53
53
|
|
|
54
54
|
const newPaths2 = oldPaths2.map((oldPath) => {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { findFiles } from '@codemod-utils/files';
|
|
4
4
|
|
|
5
5
|
import { mapFilePath } from '../../../utils/files.js';
|
|
6
6
|
|
|
7
7
|
export function migrationStrategyForServices(options) {
|
|
8
8
|
const { podPath, projectRoot } = options;
|
|
9
9
|
|
|
10
|
-
const oldPaths =
|
|
10
|
+
const oldPaths = findFiles(
|
|
11
11
|
join('tests/unit', podPath, '!(services)', '**', 'service-test.{js,ts}'),
|
|
12
12
|
{
|
|
13
13
|
cwd: projectRoot,
|
|
14
|
-
}
|
|
14
|
+
},
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
return oldPaths.map((oldPath) => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { findFiles } from '@codemod-utils/files';
|
|
2
2
|
|
|
3
3
|
import { mapFilePath } from '../../../utils/files.js';
|
|
4
4
|
|
|
5
5
|
export function migrationStrategyForComponentClasses(options) {
|
|
6
6
|
const { projectRoot } = options;
|
|
7
7
|
|
|
8
|
-
const oldPaths =
|
|
8
|
+
const oldPaths = findFiles('addon/components/**/component.{d.ts,js,ts}', {
|
|
9
9
|
cwd: projectRoot,
|
|
10
10
|
});
|
|
11
11
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { findFiles } from '@codemod-utils/files';
|
|
2
2
|
|
|
3
3
|
import { mapFilePath } from '../../../utils/files.js';
|
|
4
4
|
|
|
5
5
|
export function migrationStrategyForComponentStylesheets(options) {
|
|
6
6
|
const { projectRoot } = options;
|
|
7
7
|
|
|
8
|
-
const oldPaths =
|
|
8
|
+
const oldPaths = findFiles('addon/components/**/styles.{css,scss}', {
|
|
9
9
|
cwd: projectRoot,
|
|
10
10
|
});
|
|
11
11
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { findFiles } from '@codemod-utils/files';
|
|
2
2
|
|
|
3
3
|
import { mapFilePath } from '../../../utils/files.js';
|
|
4
4
|
|
|
5
5
|
export function migrationStrategyForComponentTemplates(options) {
|
|
6
6
|
const { projectRoot } = options;
|
|
7
7
|
|
|
8
|
-
const oldPaths =
|
|
8
|
+
const oldPaths = findFiles('addon/components/**/template.hbs', {
|
|
9
9
|
cwd: projectRoot,
|
|
10
10
|
});
|
|
11
11
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { findFiles } from '@codemod-utils/files';
|
|
2
2
|
|
|
3
3
|
import { mapFilePath } from '../../../utils/files.js';
|
|
4
4
|
|
|
5
5
|
export function migrationStrategyForRouteControllers(options) {
|
|
6
6
|
const { projectRoot } = options;
|
|
7
7
|
|
|
8
|
-
const oldPaths =
|
|
8
|
+
const oldPaths = findFiles('addon/**/controller.{js,ts}', {
|
|
9
9
|
cwd: projectRoot,
|
|
10
10
|
});
|
|
11
11
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { findFiles } from '@codemod-utils/files';
|
|
2
2
|
|
|
3
3
|
import { mapFilePath } from '../../../utils/files.js';
|
|
4
4
|
|
|
5
5
|
export function migrationStrategyForRouteRoutes(options) {
|
|
6
6
|
const { projectRoot } = options;
|
|
7
7
|
|
|
8
|
-
const oldPaths =
|
|
8
|
+
const oldPaths = findFiles('addon/**/route.{js,ts}', {
|
|
9
9
|
cwd: projectRoot,
|
|
10
10
|
});
|
|
11
11
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { findFiles } from '@codemod-utils/files';
|
|
2
2
|
|
|
3
3
|
import { mapFilePath } from '../../../utils/files.js';
|
|
4
4
|
|
|
5
5
|
export function migrationStrategyForRouteStylesheets(options) {
|
|
6
6
|
const { projectRoot } = options;
|
|
7
7
|
|
|
8
|
-
const oldPaths =
|
|
8
|
+
const oldPaths = findFiles('addon/!(components)/**/styles.{css,scss}', {
|
|
9
9
|
cwd: projectRoot,
|
|
10
10
|
});
|
|
11
11
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { findFiles } from '@codemod-utils/files';
|
|
2
2
|
|
|
3
3
|
import { mapFilePath } from '../../../utils/files.js';
|
|
4
4
|
|
|
5
5
|
export function migrationStrategyForRouteTemplates(options) {
|
|
6
6
|
const { projectRoot } = options;
|
|
7
7
|
|
|
8
|
-
const oldPaths =
|
|
8
|
+
const oldPaths = findFiles('addon/!(components)/**/template.hbs', {
|
|
9
9
|
cwd: projectRoot,
|
|
10
10
|
});
|
|
11
11
|
|
|
@@ -7,7 +7,7 @@ function analyzePackageJson(codemodOptions) {
|
|
|
7
7
|
try {
|
|
8
8
|
const packageJsonFile = readFileSync(
|
|
9
9
|
join(projectRoot, 'package.json'),
|
|
10
|
-
'utf8'
|
|
10
|
+
'utf8',
|
|
11
11
|
);
|
|
12
12
|
|
|
13
13
|
const { name } = JSON.parse(packageJsonFile);
|
|
@@ -28,7 +28,7 @@ function analyzePackageJson(codemodOptions) {
|
|
|
28
28
|
return name;
|
|
29
29
|
} catch (e) {
|
|
30
30
|
throw new SyntaxError(
|
|
31
|
-
`ERROR: package.json is missing or is not valid. (${e.message})\n
|
|
31
|
+
`ERROR: package.json is missing or is not valid. (${e.message})\n`,
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join, parse } from 'node:path';
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { findFiles } from '@codemod-utils/files';
|
|
5
5
|
|
|
6
6
|
function removeFileExtension(path) {
|
|
7
7
|
const { dir, name } = parse(path);
|
|
@@ -16,7 +16,7 @@ function createMapping(migrationStrategy) {
|
|
|
16
16
|
const after = removeFileExtension(newPath);
|
|
17
17
|
|
|
18
18
|
return [before, after];
|
|
19
|
-
})
|
|
19
|
+
}),
|
|
20
20
|
);
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -73,10 +73,8 @@ function updatePaths(mapping, options) {
|
|
|
73
73
|
|
|
74
74
|
// File extensions had been specified, partly to encode assumptions
|
|
75
75
|
// about Ember, and partly to avoid corrupting non-text files
|
|
76
|
-
const filePaths =
|
|
76
|
+
const filePaths = findFiles('{addon,tests}/**/*.{d.ts,js,ts}', {
|
|
77
77
|
cwd: projectRoot,
|
|
78
|
-
dot: true,
|
|
79
|
-
nodir: true,
|
|
80
78
|
});
|
|
81
79
|
|
|
82
80
|
filePaths.forEach((filePath) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { dirname, join, relative, resolve } from 'node:path';
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { findFiles } from '@codemod-utils/files';
|
|
5
5
|
|
|
6
6
|
function removeRelativePaths(oldFile, { filePath, projectName, projectRoot }) {
|
|
7
7
|
const regex = new RegExp(`(?:'|")(.{1,2}/(.*))(?:'|")`, 'g');
|
|
@@ -15,7 +15,7 @@ function removeRelativePaths(oldFile, { filePath, projectName, projectRoot }) {
|
|
|
15
15
|
|
|
16
16
|
let newPath = relative(
|
|
17
17
|
projectRoot,
|
|
18
|
-
resolve(projectRoot, dirname(filePath), oldPath)
|
|
18
|
+
resolve(projectRoot, dirname(filePath), oldPath),
|
|
19
19
|
);
|
|
20
20
|
|
|
21
21
|
if (newPath.startsWith('addon')) {
|
|
@@ -35,10 +35,8 @@ function updatePaths(options) {
|
|
|
35
35
|
|
|
36
36
|
// File extensions had been specified, partly to encode assumptions
|
|
37
37
|
// about Ember, and partly to avoid corrupting non-text files
|
|
38
|
-
const filePaths =
|
|
38
|
+
const filePaths = findFiles('{addon,tests}/**/*.{d.ts,js,ts}', {
|
|
39
39
|
cwd: projectRoot,
|
|
40
|
-
dot: true,
|
|
41
|
-
nodir: true,
|
|
42
40
|
});
|
|
43
41
|
|
|
44
42
|
filePaths.forEach((filePath) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { dirname, join, relative } from 'node:path';
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { findFiles } from '@codemod-utils/files';
|
|
5
5
|
|
|
6
6
|
function normalizeRelativePath(relativePath) {
|
|
7
7
|
if (relativePath.startsWith('..')) {
|
|
@@ -38,10 +38,8 @@ function useRelativePathInAddonFolder(options) {
|
|
|
38
38
|
|
|
39
39
|
// File extensions had been specified, partly to encode assumptions
|
|
40
40
|
// about Ember, and partly to avoid corrupting non-text files
|
|
41
|
-
const filePaths =
|
|
41
|
+
const filePaths = findFiles('addon/**/*.{d.ts,js,ts}', {
|
|
42
42
|
cwd: projectRoot,
|
|
43
|
-
dot: true,
|
|
44
|
-
nodir: true,
|
|
45
43
|
});
|
|
46
44
|
|
|
47
45
|
filePaths.forEach((filePath) => {
|
|
@@ -63,11 +61,9 @@ function useRelativePathInTestsFolder(options) {
|
|
|
63
61
|
|
|
64
62
|
// File extensions had been specified, partly to encode assumptions
|
|
65
63
|
// about Ember, and partly to avoid corrupting non-text files
|
|
66
|
-
const filePaths =
|
|
64
|
+
const filePaths = findFiles('tests/**/*.{d.ts,js,ts}', {
|
|
67
65
|
cwd: projectRoot,
|
|
68
|
-
|
|
69
|
-
ignore: 'tests/dummy/**/*',
|
|
70
|
-
nodir: true,
|
|
66
|
+
ignoreList: ['tests/dummy/**/*'],
|
|
71
67
|
});
|
|
72
68
|
|
|
73
69
|
filePaths.forEach((filePath) => {
|
|
@@ -89,10 +85,8 @@ function useRelativePathInTestsDummyFolder(options) {
|
|
|
89
85
|
|
|
90
86
|
// File extensions had been specified, partly to encode assumptions
|
|
91
87
|
// about Ember, and partly to avoid corrupting non-text files
|
|
92
|
-
const filePaths =
|
|
88
|
+
const filePaths = findFiles('tests/dummy/**/*.{d.ts,js,ts}', {
|
|
93
89
|
cwd: projectRoot,
|
|
94
|
-
dot: true,
|
|
95
|
-
nodir: true,
|
|
96
90
|
});
|
|
97
91
|
|
|
98
92
|
filePaths.forEach((filePath) => {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { findFiles } from '@codemod-utils/files';
|
|
2
2
|
|
|
3
3
|
import { mapFilePath } from '../../../utils/files.js';
|
|
4
4
|
|
|
5
5
|
export function migrationStrategyForComponents(options) {
|
|
6
6
|
const { projectRoot } = options;
|
|
7
7
|
|
|
8
|
-
const oldPaths =
|
|
8
|
+
const oldPaths = findFiles(
|
|
9
9
|
'tests/integration/components/**/component-test.{js,ts}',
|
|
10
10
|
{
|
|
11
11
|
cwd: projectRoot,
|
|
12
|
-
}
|
|
12
|
+
},
|
|
13
13
|
);
|
|
14
14
|
|
|
15
15
|
return oldPaths.map((oldPath) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { findFiles } from '@codemod-utils/files';
|
|
2
2
|
|
|
3
3
|
import { mapFilePath } from '../../../utils/files.js';
|
|
4
4
|
|
|
@@ -8,11 +8,11 @@ export function migrationStrategyForRouteControllers(options) {
|
|
|
8
8
|
/*
|
|
9
9
|
Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
|
|
10
10
|
*/
|
|
11
|
-
const oldPaths1 =
|
|
11
|
+
const oldPaths1 = findFiles(
|
|
12
12
|
'tests/unit/!(controllers)/**/controller-test.{js,ts}',
|
|
13
13
|
{
|
|
14
14
|
cwd: projectRoot,
|
|
15
|
-
}
|
|
15
|
+
},
|
|
16
16
|
);
|
|
17
17
|
|
|
18
18
|
const newPaths1 = oldPaths1.map((oldPath) => {
|
|
@@ -42,11 +42,11 @@ export function migrationStrategyForRouteControllers(options) {
|
|
|
42
42
|
/*
|
|
43
43
|
Case 2: Passed the --pod flag to Ember CLI
|
|
44
44
|
*/
|
|
45
|
-
const oldPaths2 =
|
|
45
|
+
const oldPaths2 = findFiles(
|
|
46
46
|
'tests/unit/controllers/**/controller-test.{js,ts}',
|
|
47
47
|
{
|
|
48
48
|
cwd: projectRoot,
|
|
49
|
-
}
|
|
49
|
+
},
|
|
50
50
|
);
|
|
51
51
|
|
|
52
52
|
const newPaths2 = oldPaths2.map((oldPath) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { findFiles } from '@codemod-utils/files';
|
|
2
2
|
|
|
3
3
|
import { mapFilePath } from '../../../utils/files.js';
|
|
4
4
|
|
|
@@ -8,7 +8,7 @@ export function migrationStrategyForRouteRoutes(options) {
|
|
|
8
8
|
/*
|
|
9
9
|
Case 1: Didn't pass the --pod flag, but configured { usePods: true } in .ember-cli
|
|
10
10
|
*/
|
|
11
|
-
const oldPaths1 =
|
|
11
|
+
const oldPaths1 = findFiles('tests/unit/!(routes)/**/route-test.{js,ts}', {
|
|
12
12
|
cwd: projectRoot,
|
|
13
13
|
});
|
|
14
14
|
|
|
@@ -39,7 +39,7 @@ export function migrationStrategyForRouteRoutes(options) {
|
|
|
39
39
|
/*
|
|
40
40
|
Case 2: Passed the --pod flag to Ember CLI
|
|
41
41
|
*/
|
|
42
|
-
const oldPaths2 =
|
|
42
|
+
const oldPaths2 = findFiles('tests/unit/routes/**/route-test.{js,ts}', {
|
|
43
43
|
cwd: projectRoot,
|
|
44
44
|
});
|
|
45
45
|
|
|
@@ -3,7 +3,7 @@ export function mapFilePath(oldPath, { find, replace }) {
|
|
|
3
3
|
|
|
4
4
|
if (!oldPath.endsWith(file)) {
|
|
5
5
|
throw new RangeError(
|
|
6
|
-
`ERROR: The provided path \`${oldPath}\` does not end with \`${file}\`.\n
|
|
6
|
+
`ERROR: The provided path \`${oldPath}\` does not end with \`${file}\`.\n`,
|
|
7
7
|
);
|
|
8
8
|
}
|
|
9
9
|
|
package/src/utils/files.js
CHANGED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, renameSync } from 'node:fs';
|
|
2
|
-
import { dirname, join } from 'node:path';
|
|
3
|
-
|
|
4
|
-
import { removeDirectoryIfEmpty } from './remove-directory-if-empty.js';
|
|
5
|
-
|
|
6
|
-
export function moveFiles(pathMapping, options) {
|
|
7
|
-
const { projectRoot } = options;
|
|
8
|
-
|
|
9
|
-
pathMapping.forEach((newPath, oldPath) => {
|
|
10
|
-
const oldAbsolutePath = join(projectRoot, oldPath);
|
|
11
|
-
|
|
12
|
-
const newAbsolutePath = join(projectRoot, newPath);
|
|
13
|
-
const newDirectory = dirname(newAbsolutePath);
|
|
14
|
-
|
|
15
|
-
if (!existsSync(newDirectory)) {
|
|
16
|
-
mkdirSync(newDirectory, { recursive: true });
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
renameSync(oldAbsolutePath, newAbsolutePath);
|
|
20
|
-
removeDirectoryIfEmpty({ oldPath, projectRoot });
|
|
21
|
-
});
|
|
22
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { readdirSync, rmSync } from 'node:fs';
|
|
2
|
-
import { dirname, join } from 'node:path';
|
|
3
|
-
|
|
4
|
-
export function removeDirectoryIfEmpty({ oldPath, projectRoot }) {
|
|
5
|
-
const directories = dirname(oldPath).split('/');
|
|
6
|
-
const depth = directories.length;
|
|
7
|
-
|
|
8
|
-
for (let i = 0; i < depth; i++) {
|
|
9
|
-
const directory = join(projectRoot, ...directories);
|
|
10
|
-
const numFilesLeft = readdirSync(directory).length;
|
|
11
|
-
|
|
12
|
-
if (numFilesLeft > 0) {
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
rmSync(directory, { recursive: true });
|
|
17
|
-
directories.pop();
|
|
18
|
-
}
|
|
19
|
-
}
|