ember-codemod-v1-to-v2 0.1.5 → 0.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/package.json
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
2
|
-
|
|
3
1
|
import glob from 'glob';
|
|
4
2
|
|
|
5
3
|
import { decideVersion } from '../../../utils/blueprints.js';
|
|
4
|
+
import { renameDirectory } from '../../../utils/files.js';
|
|
6
5
|
|
|
7
6
|
function getAppReexports(options) {
|
|
8
7
|
const { projectRoot } = options;
|
|
9
8
|
|
|
10
|
-
const filePaths = glob.sync('
|
|
11
|
-
cwd:
|
|
9
|
+
const filePaths = glob.sync('app/**/*.js', {
|
|
10
|
+
cwd: projectRoot,
|
|
12
11
|
});
|
|
13
12
|
|
|
14
|
-
return filePaths
|
|
13
|
+
return filePaths.map((filePath) => {
|
|
14
|
+
return renameDirectory(filePath, {
|
|
15
|
+
from: 'app',
|
|
16
|
+
to: '',
|
|
17
|
+
});
|
|
18
|
+
});
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
function getProjectRootDevDependencies(options) {
|
|
@@ -24,11 +28,26 @@ function getProjectRootDevDependencies(options) {
|
|
|
24
28
|
function getPublicEntrypoints(options) {
|
|
25
29
|
const { projectRoot } = options;
|
|
26
30
|
|
|
27
|
-
const filePaths = glob.sync('
|
|
28
|
-
cwd:
|
|
31
|
+
const filePaths = glob.sync('{addon,addon-test-support}/**/*.{js,ts}', {
|
|
32
|
+
cwd: projectRoot,
|
|
29
33
|
});
|
|
30
34
|
|
|
31
|
-
return filePaths
|
|
35
|
+
return filePaths
|
|
36
|
+
.map((filePath) => {
|
|
37
|
+
return renameDirectory(filePath, {
|
|
38
|
+
from: 'addon',
|
|
39
|
+
to: '',
|
|
40
|
+
});
|
|
41
|
+
})
|
|
42
|
+
.map((filePath) => {
|
|
43
|
+
return renameDirectory(filePath, {
|
|
44
|
+
from: 'addon-test-support',
|
|
45
|
+
to: 'test-support',
|
|
46
|
+
});
|
|
47
|
+
})
|
|
48
|
+
.map((filePath) => {
|
|
49
|
+
return filePath.replace(/ts$/, 'js');
|
|
50
|
+
});
|
|
32
51
|
}
|
|
33
52
|
|
|
34
53
|
export function analyzeAddon(options) {
|
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
);
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
|
|
3
|
+
export function renameDirectory(oldPath, { from, to }) {
|
|
4
|
+
if (from === '') {
|
|
5
|
+
return join(to, oldPath);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
if (!oldPath.startsWith(`${from}/`)) {
|
|
9
|
+
return oldPath;
|
|
10
|
+
}
|
|
10
11
|
|
|
11
|
-
return
|
|
12
|
+
return join(to, oldPath.replace(`${from}/`, ''));
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export function mapFilePaths(filePaths, directory) {
|
|
15
16
|
const { from, to } = directory;
|
|
16
17
|
|
|
17
18
|
return new Map(
|
|
18
|
-
filePaths.map((filePath) =>
|
|
19
|
+
filePaths.map((filePath) => {
|
|
20
|
+
const newPath = renameDirectory(filePath, { from, to });
|
|
21
|
+
|
|
22
|
+
return [filePath, newPath];
|
|
23
|
+
})
|
|
19
24
|
);
|
|
20
25
|
}
|