ember-codemod-v1-to-v2 0.4.1 → 0.5.1
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 +2 -0
- package/package.json +9 -10
- package/src/blueprints/ember-addon/__gitignore__ +8 -9
- package/src/blueprints/ember-addon/package.json +3 -6
- package/src/migration/ember-addon/steps/analyze-addon.js +0 -1
- package/src/migration/ember-addon/steps/create-files-from-blueprint.js +6 -5
- package/src/migration/ember-addon/steps/create-options.js +5 -4
- package/src/migration/ember-addon/steps/move-test-app-files.js +1 -1
- package/src/migration/ember-addon/steps/update-addon-package-json.js +3 -2
- package/src/migration/ember-addon/steps/update-test-app-package-json.js +1 -1
- package/src/utils/blueprints/{blueprint-root.js → blueprints-root.js} +3 -3
- package/src/utils/blueprints/decide-version.js +7 -7
- package/src/utils/blueprints.js +1 -1
- package/src/utils/files/map-file-paths.js +1 -1
- package/src/blueprints/ember-addon/.prettierignore +0 -25
- package/src/blueprints/ember-addon/.prettierrc.js +0 -5
package/README.md
CHANGED
|
@@ -115,6 +115,8 @@ You can also look at another codemod called [`ember-addon-migrator`](https://git
|
|
|
115
115
|
|
|
116
116
|
## Contributing
|
|
117
117
|
|
|
118
|
+
See the [Contributing](CONTRIBUTING.md) guide for details.
|
|
119
|
+
|
|
118
120
|
If you have an open-sourced addon (v1 or v2) 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. ⭐
|
|
119
121
|
|
|
120
122
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-codemod-v1-to-v2",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Codemod to convert Ember addons to v2 addon format",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codemod",
|
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
"changelog": "lerna-changelog",
|
|
32
32
|
"lint": "eslint . --cache",
|
|
33
33
|
"lint:fix": "eslint . --fix",
|
|
34
|
-
"start": "node ./src/index.js",
|
|
35
34
|
"test": "mt tests --quiet"
|
|
36
35
|
},
|
|
37
36
|
"changelog": {
|
|
@@ -45,24 +44,24 @@
|
|
|
45
44
|
}
|
|
46
45
|
},
|
|
47
46
|
"dependencies": {
|
|
48
|
-
"
|
|
49
|
-
"@babel/eslint-parser": "^7.19.1",
|
|
50
|
-
"glob": "^9.2.1",
|
|
47
|
+
"glob": "^10.2.2",
|
|
51
48
|
"lodash.template": "^4.5.0",
|
|
52
49
|
"strip-json-comments": "^5.0.0",
|
|
53
|
-
"yargs": "^17.7.
|
|
50
|
+
"yargs": "^17.7.2"
|
|
54
51
|
},
|
|
55
52
|
"devDependencies": {
|
|
53
|
+
"@babel/core": "^7.21.8",
|
|
54
|
+
"@babel/eslint-parser": "^7.21.8",
|
|
56
55
|
"@sondr3/minitest": "^0.1.1",
|
|
57
|
-
"eslint": "^8.
|
|
58
|
-
"eslint-config-prettier": "^8.
|
|
56
|
+
"eslint": "^8.39.0",
|
|
57
|
+
"eslint-config-prettier": "^8.8.0",
|
|
59
58
|
"eslint-plugin-import": "^2.27.5",
|
|
60
|
-
"eslint-plugin-n": "^15.
|
|
59
|
+
"eslint-plugin-n": "^15.7.0",
|
|
61
60
|
"eslint-plugin-prettier": "^4.2.1",
|
|
62
61
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
63
62
|
"fixturify": "^3.0.0",
|
|
64
63
|
"lerna-changelog": "^2.2.0",
|
|
65
|
-
"prettier": "^2.8.
|
|
64
|
+
"prettier": "^2.8.8"
|
|
66
65
|
},
|
|
67
66
|
"engines": {
|
|
68
67
|
"node": ">= 16"
|
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
# See https://help.github.com/ignore-files/ for more about ignoring files.
|
|
2
|
-
|
|
3
1
|
# compiled output
|
|
4
|
-
dist/
|
|
2
|
+
/dist/
|
|
5
3
|
|
|
6
4
|
# dependencies
|
|
7
|
-
node_modules/
|
|
5
|
+
/node_modules/
|
|
8
6
|
|
|
9
7
|
# misc
|
|
10
8
|
/.env*
|
|
11
9
|
/.pnp*
|
|
12
|
-
/.
|
|
13
|
-
/.sass-cache
|
|
14
|
-
.eslintcache
|
|
15
|
-
/connect.lock
|
|
10
|
+
/.eslintcache
|
|
16
11
|
/coverage/
|
|
17
|
-
/libpeerconnection.log
|
|
18
12
|
/npm-debug.log*
|
|
19
13
|
/testem.log
|
|
20
14
|
/yarn-error.log
|
|
21
15
|
|
|
22
16
|
# ember-try
|
|
23
17
|
/.node_modules.ember-try/
|
|
18
|
+
/npm-shrinkwrap.json.ember-try
|
|
24
19
|
/package.json.ember-try
|
|
20
|
+
/package-lock.json.ember-try
|
|
25
21
|
/yarn.lock.ember-try
|
|
22
|
+
|
|
23
|
+
# broccoli-debug
|
|
24
|
+
/DEBUG/
|
|
@@ -20,8 +20,7 @@
|
|
|
20
20
|
"test": "npm run test --workspaces --if-present"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"concurrently": "<%= context.projectRoot.devDependencies['concurrently'] %>"
|
|
24
|
-
"prettier": "<%= context.projectRoot.devDependencies['prettier'] %>"
|
|
23
|
+
"concurrently": "<%= context.projectRoot.devDependencies['concurrently'] %>"
|
|
25
24
|
}
|
|
26
25
|
}<% } else if (options.packageManager.isPnpm) { %>{
|
|
27
26
|
"name": "<%= options.packages.addon.name %>",
|
|
@@ -41,8 +40,7 @@
|
|
|
41
40
|
"test": "pnpm --filter '*' test"
|
|
42
41
|
},
|
|
43
42
|
"devDependencies": {
|
|
44
|
-
"concurrently": "<%= context.projectRoot.devDependencies['concurrently'] %>"
|
|
45
|
-
"prettier": "<%= context.projectRoot.devDependencies['prettier'] %>"
|
|
43
|
+
"concurrently": "<%= context.projectRoot.devDependencies['concurrently'] %>"
|
|
46
44
|
}
|
|
47
45
|
}<% } else if (options.packageManager.isYarn) { %>{
|
|
48
46
|
"name": "<%= options.packages.addon.name %>",
|
|
@@ -66,7 +64,6 @@
|
|
|
66
64
|
"test": "yarn workspaces run test"
|
|
67
65
|
},
|
|
68
66
|
"devDependencies": {
|
|
69
|
-
"concurrently": "<%= context.projectRoot.devDependencies['concurrently'] %>"
|
|
70
|
-
"prettier": "<%= context.projectRoot.devDependencies['prettier'] %>"
|
|
67
|
+
"concurrently": "<%= context.projectRoot.devDependencies['concurrently'] %>"
|
|
71
68
|
}
|
|
72
69
|
}<% } %>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { blueprintsRoot, processTemplate } from '../../../utils/blueprints.js';
|
|
5
5
|
import { createFiles, findFiles } from '../../../utils/files.js';
|
|
6
6
|
|
|
7
7
|
function getFilePath(blueprintFilePath, options) {
|
|
@@ -32,9 +32,10 @@ function getFilesToSkip(options) {
|
|
|
32
32
|
|
|
33
33
|
export function createFilesFromBlueprint(context, options) {
|
|
34
34
|
const filesToSkip = getFilesToSkip(options);
|
|
35
|
+
const emberAddonBlueprintsRoot = join(blueprintsRoot, 'ember-addon');
|
|
35
36
|
|
|
36
37
|
const blueprintFilePaths = findFiles('**/*', {
|
|
37
|
-
cwd:
|
|
38
|
+
cwd: emberAddonBlueprintsRoot,
|
|
38
39
|
ignoreList: filesToSkip,
|
|
39
40
|
});
|
|
40
41
|
|
|
@@ -43,8 +44,8 @@ export function createFilesFromBlueprint(context, options) {
|
|
|
43
44
|
const filePath = getFilePath(blueprintFilePath, options);
|
|
44
45
|
|
|
45
46
|
const blueprintFile = readFileSync(
|
|
46
|
-
join(
|
|
47
|
-
'utf8'
|
|
47
|
+
join(emberAddonBlueprintsRoot, blueprintFilePath),
|
|
48
|
+
'utf8',
|
|
48
49
|
);
|
|
49
50
|
|
|
50
51
|
const file = processTemplate(blueprintFile, {
|
|
@@ -53,7 +54,7 @@ export function createFilesFromBlueprint(context, options) {
|
|
|
53
54
|
});
|
|
54
55
|
|
|
55
56
|
return [filePath, file];
|
|
56
|
-
})
|
|
57
|
+
}),
|
|
57
58
|
);
|
|
58
59
|
|
|
59
60
|
createFiles(fileMapping, options);
|
|
@@ -28,7 +28,7 @@ function analyzePackageJson(codemodOptions) {
|
|
|
28
28
|
try {
|
|
29
29
|
const packageJsonFile = readFileSync(
|
|
30
30
|
join(projectRoot, 'package.json'),
|
|
31
|
-
'utf8'
|
|
31
|
+
'utf8',
|
|
32
32
|
);
|
|
33
33
|
|
|
34
34
|
const {
|
|
@@ -56,7 +56,7 @@ function analyzePackageJson(codemodOptions) {
|
|
|
56
56
|
};
|
|
57
57
|
} catch (e) {
|
|
58
58
|
throw new SyntaxError(
|
|
59
|
-
`ERROR: package.json is missing or is not valid. (${e.message})\n
|
|
59
|
+
`ERROR: package.json is missing or is not valid. (${e.message})\n`,
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -96,8 +96,9 @@ function analyzePackageManager(codemodOptions) {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
function deriveAddonLocation(addonPackage) {
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
const hasScope = addonPackage.name.includes('/');
|
|
100
|
+
|
|
101
|
+
if (!hasScope) {
|
|
101
102
|
return addonPackage.name;
|
|
102
103
|
}
|
|
103
104
|
|
|
@@ -50,6 +50,7 @@ function updateDevDependencies(packageJson, options) {
|
|
|
50
50
|
'@babel/core',
|
|
51
51
|
'@babel/plugin-proposal-class-properties',
|
|
52
52
|
'@babel/plugin-proposal-decorators',
|
|
53
|
+
'@babel/runtime',
|
|
53
54
|
'@embroider/addon-dev',
|
|
54
55
|
'@rollup/plugin-babel',
|
|
55
56
|
'rollup',
|
|
@@ -85,7 +86,7 @@ function updateOtherFields(packageJson, context, options) {
|
|
|
85
86
|
|
|
86
87
|
return accumulator;
|
|
87
88
|
},
|
|
88
|
-
{}
|
|
89
|
+
{},
|
|
89
90
|
);
|
|
90
91
|
|
|
91
92
|
packageJson['ember-addon'] = {
|
|
@@ -147,7 +148,7 @@ function updateScripts(packageJson) {
|
|
|
147
148
|
scripts.set('start', 'rollup --config --watch');
|
|
148
149
|
scripts.set(
|
|
149
150
|
'test',
|
|
150
|
-
"echo 'A v2 addon does not have tests, run tests in test-app'"
|
|
151
|
+
"echo 'A v2 addon does not have tests, run tests in test-app'",
|
|
151
152
|
);
|
|
152
153
|
|
|
153
154
|
packageJson['scripts'] = convertToObject(scripts);
|
|
@@ -63,7 +63,7 @@ function updateOtherFields(packageJson, options) {
|
|
|
63
63
|
delete packageJson['ember-addon'];
|
|
64
64
|
|
|
65
65
|
packageJson['keywords'] = (packageJson['keywords'] ?? []).filter(
|
|
66
|
-
(keyword) => keyword !== 'ember-addon'
|
|
66
|
+
(keyword) => keyword !== 'ember-addon',
|
|
67
67
|
);
|
|
68
68
|
|
|
69
69
|
packageJson['name'] = packages.testApp.name;
|
|
@@ -4,10 +4,10 @@ import { fileURLToPath } from 'node:url';
|
|
|
4
4
|
const __filename = fileURLToPath(import.meta.url);
|
|
5
5
|
const __dirname = dirname(__filename);
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function getBlueprintsRoot() {
|
|
8
8
|
const srcDirectory = join(__dirname, '../..');
|
|
9
9
|
|
|
10
|
-
return join(srcDirectory, 'blueprints
|
|
10
|
+
return join(srcDirectory, 'blueprints');
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export const
|
|
13
|
+
export const blueprintsRoot = getBlueprintsRoot();
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
const latestVersions = new Map([
|
|
2
|
-
['@babel/core', '7.21.
|
|
2
|
+
['@babel/core', '7.21.8'],
|
|
3
3
|
['@babel/plugin-proposal-class-properties', '7.18.6'],
|
|
4
4
|
['@babel/plugin-proposal-decorators', '7.21.0'],
|
|
5
|
-
['@babel/preset-typescript', '7.21.
|
|
5
|
+
['@babel/preset-typescript', '7.21.5'],
|
|
6
|
+
['@babel/runtime', '7.21.5'],
|
|
6
7
|
['@embroider/addon-dev', '3.0.0'],
|
|
7
8
|
['@embroider/addon-shim', '1.8.4'],
|
|
8
9
|
['@rollup/plugin-babel', '6.0.3'],
|
|
9
|
-
['concurrently', '
|
|
10
|
-
['ember-auto-import', '2.6.
|
|
10
|
+
['concurrently', '8.0.1'],
|
|
11
|
+
['ember-auto-import', '2.6.3'],
|
|
11
12
|
['ember-cli-babel', '7.26.11'],
|
|
12
13
|
['ember-cli-htmlbars', '6.2.0'],
|
|
13
|
-
['
|
|
14
|
-
['rollup', '3.18.0'],
|
|
14
|
+
['rollup', '3.21.3'],
|
|
15
15
|
['rollup-plugin-copy', '3.4.0'],
|
|
16
16
|
['rollup-plugin-ts', '3.2.0'],
|
|
17
17
|
]);
|
|
@@ -29,7 +29,7 @@ export function decideVersion(packageName, options) {
|
|
|
29
29
|
|
|
30
30
|
if (!latestVersion) {
|
|
31
31
|
throw new RangeError(
|
|
32
|
-
`ERROR: The latest version of \`${packageName}\` is unknown.\n
|
|
32
|
+
`ERROR: The latest version of \`${packageName}\` is unknown.\n`,
|
|
33
33
|
);
|
|
34
34
|
}
|
|
35
35
|
|
package/src/utils/blueprints.js
CHANGED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# unconventional js
|
|
2
|
-
/blueprints/*/files/
|
|
3
|
-
/vendor/
|
|
4
|
-
|
|
5
|
-
# compiled output
|
|
6
|
-
/dist/
|
|
7
|
-
/tmp/
|
|
8
|
-
|
|
9
|
-
# dependencies
|
|
10
|
-
/bower_components/
|
|
11
|
-
/node_modules/
|
|
12
|
-
|
|
13
|
-
# misc
|
|
14
|
-
/coverage/
|
|
15
|
-
!.*
|
|
16
|
-
.eslintcache
|
|
17
|
-
.lint-todo/
|
|
18
|
-
|
|
19
|
-
# ember-try
|
|
20
|
-
/.node_modules.ember-try/
|
|
21
|
-
/bower.json.ember-try
|
|
22
|
-
/npm-shrinkwrap.json.ember-try
|
|
23
|
-
/package.json.ember-try
|
|
24
|
-
/package-lock.json.ember-try
|
|
25
|
-
/yarn.lock.ember-try
|