ember-codemod-v1-to-v2 0.6.1 → 0.6.3
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 +8 -8
- package/src/migration/ember-addon/steps/analyze-addon.js +8 -8
- package/src/migration/ember-addon/steps/create-files-from-blueprint.js +1 -1
- package/src/migration/ember-addon/steps/create-options.js +9 -3
- package/src/migration/ember-addon/steps/move-addon-files.js +5 -5
- package/src/migration/ember-addon/steps/move-project-root-files.js +4 -4
- package/src/migration/ember-addon/steps/move-test-app-files.js +5 -5
- package/src/migration/ember-addon/steps/update-addon-package-json.js +12 -7
- package/src/migration/ember-addon/steps/update-test-app-package-json.js +12 -7
- package/src/utils/blueprints/get-version.js +7 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-codemod-v1-to-v2",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Codemod to convert Ember addons to v2 addon format",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codemod",
|
|
@@ -28,18 +28,18 @@
|
|
|
28
28
|
"src/"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@codemod-utils/blueprints": "^0.1.
|
|
32
|
-
"@codemod-utils/files": "^0.1
|
|
33
|
-
"@codemod-utils/json": "^0.
|
|
31
|
+
"@codemod-utils/blueprints": "^0.1.2",
|
|
32
|
+
"@codemod-utils/files": "^0.3.1",
|
|
33
|
+
"@codemod-utils/json": "^0.2.0",
|
|
34
34
|
"strip-json-comments": "^5.0.0",
|
|
35
35
|
"yargs": "^17.7.2"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@babel/core": "^7.22.
|
|
39
|
-
"@babel/eslint-parser": "^7.
|
|
40
|
-
"@codemod-utils/tests": "^0.1.
|
|
38
|
+
"@babel/core": "^7.22.5",
|
|
39
|
+
"@babel/eslint-parser": "^7.22.5",
|
|
40
|
+
"@codemod-utils/tests": "^0.1.2",
|
|
41
41
|
"@sondr3/minitest": "^0.1.1",
|
|
42
|
-
"eslint": "^8.
|
|
42
|
+
"eslint": "^8.42.0",
|
|
43
43
|
"eslint-config-prettier": "^8.8.0",
|
|
44
44
|
"eslint-plugin-import": "^2.27.5",
|
|
45
45
|
"eslint-plugin-n": "^16.0.0",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { findFiles,
|
|
1
|
+
import { findFiles, renamePathByDirectory } from '@codemod-utils/files';
|
|
2
2
|
|
|
3
3
|
import { getVersion } from '../../../utils/blueprints.js';
|
|
4
4
|
|
|
@@ -6,12 +6,12 @@ function getAppReexports(options) {
|
|
|
6
6
|
const { projectRoot } = options;
|
|
7
7
|
|
|
8
8
|
const filePaths = findFiles('app/**/*.js', {
|
|
9
|
-
|
|
9
|
+
projectRoot,
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
return filePaths
|
|
13
13
|
.map((filePath) => {
|
|
14
|
-
return
|
|
14
|
+
return renamePathByDirectory(filePath, {
|
|
15
15
|
from: 'app',
|
|
16
16
|
to: '',
|
|
17
17
|
});
|
|
@@ -29,12 +29,12 @@ function getPublicAssets(options) {
|
|
|
29
29
|
const { projectRoot } = options;
|
|
30
30
|
|
|
31
31
|
const filePaths = findFiles('public/**/*', {
|
|
32
|
-
|
|
32
|
+
projectRoot,
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
return filePaths
|
|
36
36
|
.map((filePath) => {
|
|
37
|
-
return
|
|
37
|
+
return renamePathByDirectory(filePath, {
|
|
38
38
|
from: 'public',
|
|
39
39
|
to: '',
|
|
40
40
|
});
|
|
@@ -46,18 +46,18 @@ function getPublicEntrypoints(options) {
|
|
|
46
46
|
const { projectRoot } = options;
|
|
47
47
|
|
|
48
48
|
const filePaths = findFiles('{addon,addon-test-support}/**/*.{js,ts}', {
|
|
49
|
-
|
|
49
|
+
projectRoot,
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
return filePaths
|
|
53
53
|
.map((filePath) => {
|
|
54
|
-
return
|
|
54
|
+
return renamePathByDirectory(filePath, {
|
|
55
55
|
from: 'addon',
|
|
56
56
|
to: '',
|
|
57
57
|
});
|
|
58
58
|
})
|
|
59
59
|
.map((filePath) => {
|
|
60
|
-
return
|
|
60
|
+
return renamePathByDirectory(filePath, {
|
|
61
61
|
from: 'addon-test-support',
|
|
62
62
|
to: 'test-support',
|
|
63
63
|
});
|
|
@@ -37,8 +37,8 @@ export function createFilesFromBlueprint(context, options) {
|
|
|
37
37
|
const cwd = join(blueprintsRoot, 'ember-addon');
|
|
38
38
|
|
|
39
39
|
const blueprintFilePaths = findFiles('**/*', {
|
|
40
|
-
cwd,
|
|
41
40
|
ignoreList: filesToSkip,
|
|
41
|
+
projectRoot: cwd,
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
const fileMap = new Map(
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { findFiles, unionize } from '@codemod-utils/files';
|
|
2
|
-
import { readPackageJson } from '@codemod-utils/json';
|
|
2
|
+
import { readPackageJson, validatePackageJson } from '@codemod-utils/json';
|
|
3
3
|
|
|
4
4
|
function analyzePackageJson(codemodOptions) {
|
|
5
|
+
const { projectRoot } = codemodOptions;
|
|
6
|
+
|
|
7
|
+
const packageJson = readPackageJson({ projectRoot });
|
|
8
|
+
|
|
9
|
+
validatePackageJson(packageJson);
|
|
10
|
+
|
|
5
11
|
const {
|
|
6
12
|
dependencies,
|
|
7
13
|
devDependencies,
|
|
8
14
|
'ember-addon': emberAddon,
|
|
9
15
|
name,
|
|
10
16
|
version,
|
|
11
|
-
} =
|
|
17
|
+
} = packageJson;
|
|
12
18
|
|
|
13
19
|
const projectDependencies = new Map([
|
|
14
20
|
...Object.entries(dependencies ?? {}),
|
|
@@ -37,7 +43,7 @@ function analyzePackageManager(codemodOptions) {
|
|
|
37
43
|
const lockFiles = [...mapping.keys()];
|
|
38
44
|
|
|
39
45
|
const filePaths = findFiles(unionize(lockFiles), {
|
|
40
|
-
|
|
46
|
+
projectRoot,
|
|
41
47
|
});
|
|
42
48
|
|
|
43
49
|
if (filePaths.length !== 1) {
|
|
@@ -9,7 +9,7 @@ function moveAddonFolder(options) {
|
|
|
9
9
|
const { locations, projectRoot } = options;
|
|
10
10
|
|
|
11
11
|
const filePaths = findFiles('addon/**/*', {
|
|
12
|
-
|
|
12
|
+
projectRoot,
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
const filePathMap = mapFilePaths(filePaths, {
|
|
@@ -24,7 +24,7 @@ function moveAddonTestSupportFolder(options) {
|
|
|
24
24
|
const { locations, projectRoot } = options;
|
|
25
25
|
|
|
26
26
|
const filePaths = findFiles('addon-test-support/**/*', {
|
|
27
|
-
|
|
27
|
+
projectRoot,
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
const filePathMap = mapFilePaths(filePaths, {
|
|
@@ -39,7 +39,7 @@ function moveBlueprintsFolder(options) {
|
|
|
39
39
|
const { locations, projectRoot } = options;
|
|
40
40
|
|
|
41
41
|
const filePaths = findFiles('blueprints/**/*', {
|
|
42
|
-
|
|
42
|
+
projectRoot,
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
const filePathMap = mapFilePaths(filePaths, {
|
|
@@ -54,7 +54,7 @@ function movePublicFolder(options) {
|
|
|
54
54
|
const { locations, projectRoot } = options;
|
|
55
55
|
|
|
56
56
|
const filePaths = findFiles('public/**/*', {
|
|
57
|
-
|
|
57
|
+
projectRoot,
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
const filePathMap = mapFilePaths(filePaths, {
|
|
@@ -69,7 +69,7 @@ function removeAppFolder(options) {
|
|
|
69
69
|
const { projectRoot } = options;
|
|
70
70
|
|
|
71
71
|
const filePaths = findFiles('app/**/*', {
|
|
72
|
-
|
|
72
|
+
projectRoot,
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
removeFiles(filePaths, options);
|
|
@@ -13,7 +13,7 @@ function copyToAddon(options) {
|
|
|
13
13
|
const files = ['LICENSE.md', 'README.md'];
|
|
14
14
|
|
|
15
15
|
const filePaths = findFiles(unionize(files), {
|
|
16
|
-
|
|
16
|
+
projectRoot,
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
const filePathMap = mapFilePaths(filePaths, {
|
|
@@ -48,7 +48,7 @@ function moveToAddonAndTestApp(options) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
const filePaths = findFiles(unionize([...files]), {
|
|
51
|
-
|
|
51
|
+
projectRoot,
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
let filePathMap = mapFilePaths(filePaths, {
|
|
@@ -79,7 +79,7 @@ function moveToTestApp(options) {
|
|
|
79
79
|
];
|
|
80
80
|
|
|
81
81
|
const filePaths = findFiles(unionize(files), {
|
|
82
|
-
|
|
82
|
+
projectRoot,
|
|
83
83
|
});
|
|
84
84
|
|
|
85
85
|
const filePathMap = mapFilePaths(filePaths, {
|
|
@@ -96,7 +96,7 @@ function removeFromProjectRoot(options) {
|
|
|
96
96
|
const files = ['.npmignore', 'index.js'];
|
|
97
97
|
|
|
98
98
|
const filePaths = findFiles(unionize(files), {
|
|
99
|
-
|
|
99
|
+
projectRoot,
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
removeFiles(filePaths, options);
|
|
@@ -7,7 +7,7 @@ function moveTestsFolder(options) {
|
|
|
7
7
|
const { locations, projectRoot } = options;
|
|
8
8
|
|
|
9
9
|
let filePaths = findFiles('tests/dummy/**/*', {
|
|
10
|
-
|
|
10
|
+
projectRoot,
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
let filePathMap = mapFilePaths(filePaths, {
|
|
@@ -18,8 +18,8 @@ function moveTestsFolder(options) {
|
|
|
18
18
|
moveFiles(filePathMap, options);
|
|
19
19
|
|
|
20
20
|
filePaths = findFiles('tests/**/*', {
|
|
21
|
-
cwd: projectRoot,
|
|
22
21
|
ignoreList: ['tests/dummy/**/*'],
|
|
22
|
+
projectRoot,
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
filePathMap = mapFilePaths(filePaths, {
|
|
@@ -38,7 +38,7 @@ function moveTypesFolder(options) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
let filePaths = findFiles('types/dummy/**/*', {
|
|
41
|
-
|
|
41
|
+
projectRoot,
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
let filePathMap = mapFilePaths(filePaths, {
|
|
@@ -49,8 +49,8 @@ function moveTypesFolder(options) {
|
|
|
49
49
|
moveFiles(filePathMap, options);
|
|
50
50
|
|
|
51
51
|
filePaths = findFiles('types/**/*', {
|
|
52
|
-
cwd: projectRoot,
|
|
53
52
|
ignoreList: ['types/dummy/**/*'],
|
|
53
|
+
projectRoot,
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
filePathMap = mapFilePaths(filePaths, {
|
|
@@ -67,7 +67,7 @@ function renameDummy(options) {
|
|
|
67
67
|
// File extensions had been specified, partly to encode assumptions
|
|
68
68
|
// about Ember, and partly to avoid corrupting non-text files
|
|
69
69
|
const filePaths = findFiles(`${locations.testApp}/**/*.{d.ts,html,js,ts}`, {
|
|
70
|
-
|
|
70
|
+
projectRoot,
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
filePaths.forEach((filePath) => {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { writeFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
convertToMap,
|
|
6
|
+
convertToObject,
|
|
7
|
+
readPackageJson,
|
|
8
|
+
} from '@codemod-utils/json';
|
|
5
9
|
|
|
6
10
|
import { getVersion } from '../../../utils/blueprints.js';
|
|
7
11
|
|
|
@@ -158,16 +162,17 @@ function updateScripts(packageJson) {
|
|
|
158
162
|
export function updateAddonPackageJson(context, options) {
|
|
159
163
|
const { locations, projectRoot } = options;
|
|
160
164
|
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
165
|
+
const packageJson = readPackageJson({
|
|
166
|
+
projectRoot: join(projectRoot, locations.addon),
|
|
167
|
+
});
|
|
164
168
|
|
|
165
169
|
updateDependencies(packageJson, options);
|
|
166
170
|
updateDevDependencies(packageJson, options);
|
|
167
171
|
updateScripts(packageJson);
|
|
168
172
|
updateOtherFields(packageJson, context, options);
|
|
169
173
|
|
|
170
|
-
const
|
|
174
|
+
const destination = join(projectRoot, locations.addon, 'package.json');
|
|
175
|
+
const file = JSON.stringify(packageJson, null, 2) + '\n';
|
|
171
176
|
|
|
172
|
-
writeFileSync(
|
|
177
|
+
writeFileSync(destination, file, 'utf8');
|
|
173
178
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { writeFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
convertToMap,
|
|
6
|
+
convertToObject,
|
|
7
|
+
readPackageJson,
|
|
8
|
+
} from '@codemod-utils/json';
|
|
5
9
|
|
|
6
10
|
import { getVersion } from '../../../utils/blueprints.js';
|
|
7
11
|
|
|
@@ -75,16 +79,17 @@ function updateOtherFields(packageJson, options) {
|
|
|
75
79
|
export function updateTestAppPackageJson(options) {
|
|
76
80
|
const { locations, projectRoot } = options;
|
|
77
81
|
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
const packageJson = readPackageJson({
|
|
83
|
+
projectRoot: join(projectRoot, locations.testApp),
|
|
84
|
+
});
|
|
81
85
|
|
|
82
86
|
moveDependenciesToDevDependencies(packageJson, options);
|
|
83
87
|
updateDependencies(packageJson);
|
|
84
88
|
updateDevDependencies(packageJson, options);
|
|
85
89
|
updateOtherFields(packageJson, options);
|
|
86
90
|
|
|
87
|
-
const
|
|
91
|
+
const destination = join(projectRoot, locations.testApp, 'package.json');
|
|
92
|
+
const file = JSON.stringify(packageJson, null, 2) + '\n';
|
|
88
93
|
|
|
89
|
-
writeFileSync(
|
|
94
|
+
writeFileSync(destination, file, 'utf8');
|
|
90
95
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { decideVersion } from '@codemod-utils/blueprints';
|
|
2
2
|
|
|
3
3
|
const latestVersions = new Map([
|
|
4
|
-
['@babel/core', '7.22.
|
|
4
|
+
['@babel/core', '7.22.5'],
|
|
5
5
|
['@babel/plugin-proposal-class-properties', '7.18.6'],
|
|
6
|
-
['@babel/plugin-proposal-decorators', '7.22.
|
|
7
|
-
['@babel/preset-typescript', '7.
|
|
8
|
-
['@babel/runtime', '7.22.
|
|
9
|
-
['@embroider/addon-dev', '3.1.
|
|
6
|
+
['@babel/plugin-proposal-decorators', '7.22.5'],
|
|
7
|
+
['@babel/preset-typescript', '7.22.5'],
|
|
8
|
+
['@babel/runtime', '7.22.5'],
|
|
9
|
+
['@embroider/addon-dev', '3.1.1'],
|
|
10
10
|
['@embroider/addon-shim', '1.8.5'],
|
|
11
11
|
['@rollup/plugin-babel', '6.0.3'],
|
|
12
|
-
['concurrently', '8.0
|
|
12
|
+
['concurrently', '8.2.0'],
|
|
13
13
|
['ember-auto-import', '2.6.3'],
|
|
14
14
|
['ember-cli-babel', '7.26.11'],
|
|
15
15
|
['ember-cli-htmlbars', '6.2.0'],
|
|
16
|
-
['rollup', '3.
|
|
16
|
+
['rollup', '3.24.1'],
|
|
17
17
|
['rollup-plugin-copy', '3.4.0'],
|
|
18
18
|
['rollup-plugin-ts', '3.2.0'],
|
|
19
19
|
]);
|