ember-codemod-v1-to-v2 0.2.0 → 0.3.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 +3 -3
- package/src/blueprints/ember-addon/__addonLocation__/{addon-main.js → addon-main.cjs} +0 -0
- package/src/blueprints/ember-addon/__addonLocation__/rollup.config.mjs +12 -3
- package/src/migration/ember-addon/steps/analyze-addon.js +2 -1
- package/src/migration/ember-addon/steps/create-files-from-blueprint.js +1 -4
- package/src/migration/ember-addon/steps/move-project-root-files.js +20 -23
- package/src/migration/ember-addon/steps/update-addon-package-json.js +29 -10
- package/src/utils/blueprints/decide-version.js +18 -7
- package/src/blueprints/ember-addon/__addonLocation__/rollup.config.js +0 -58
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-codemod-v1-to-v2",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Codemod to convert Ember addons to v2 addon format",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codemod",
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@sondr3/minitest": "^0.1.1",
|
|
57
|
-
"eslint": "^8.
|
|
57
|
+
"eslint": "^8.33.0",
|
|
58
58
|
"eslint-config-prettier": "^8.6.0",
|
|
59
59
|
"eslint-plugin-prettier": "^4.2.1",
|
|
60
|
-
"eslint-plugin-simple-import-sort": "^
|
|
60
|
+
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
61
61
|
"fixturify": "^3.0.0",
|
|
62
62
|
"lerna-changelog": "^2.2.0",
|
|
63
63
|
"prettier": "^2.8.3"
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import typescript from 'rollup-plugin-ts'
|
|
1
|
+
<% if (options.packages.addon.hasTypeScript) { %>import typescript from 'rollup-plugin-ts';<% } else { %>import { babel } from '@rollup/plugin-babel';<% } %>
|
|
2
2
|
import copy from 'rollup-plugin-copy';
|
|
3
3
|
import { Addon } from '@embroider/addon-dev/rollup';
|
|
4
4
|
|
|
@@ -27,13 +27,22 @@ export default {
|
|
|
27
27
|
// package names.
|
|
28
28
|
addon.dependencies(),
|
|
29
29
|
|
|
30
|
-
// compile TypeScript to latest JavaScript, including Babel transpilation
|
|
30
|
+
<% if (options.packages.addon.hasTypeScript) { %> // compile TypeScript to latest JavaScript, including Babel transpilation
|
|
31
31
|
typescript({
|
|
32
32
|
transpiler: 'babel',
|
|
33
33
|
browserslist: false,
|
|
34
34
|
transpileOnly: false,
|
|
35
35
|
}),
|
|
36
|
-
|
|
36
|
+
<% } else { %> // This babel config should *not* apply presets or compile away ES modules.
|
|
37
|
+
// It exists only to provide development niceties for you, like automatic
|
|
38
|
+
// template colocation.
|
|
39
|
+
//
|
|
40
|
+
// By default, this will load the actual babel config from the file
|
|
41
|
+
// babel.config.json.
|
|
42
|
+
babel({
|
|
43
|
+
babelHelpers: 'bundled',
|
|
44
|
+
}),
|
|
45
|
+
<% } %>
|
|
37
46
|
// Ensure that standalone .hbs files are properly integrated as Javascript.
|
|
38
47
|
addon.hbs(),
|
|
39
48
|
|
|
@@ -30,10 +30,7 @@ function getFilesToSkip(options) {
|
|
|
30
30
|
|
|
31
31
|
const files = new Set();
|
|
32
32
|
|
|
33
|
-
if (packages.addon.hasTypeScript) {
|
|
34
|
-
files.add('__addonLocation__/rollup.config.js');
|
|
35
|
-
} else {
|
|
36
|
-
files.add('__addonLocation__/rollup.config.mjs');
|
|
33
|
+
if (!packages.addon.hasTypeScript) {
|
|
37
34
|
files.add('__addonLocation__/unpublished-development-types/index.d.ts');
|
|
38
35
|
files.add('__testAppLocation__/types/global.d.ts');
|
|
39
36
|
}
|
|
@@ -35,30 +35,27 @@ function copyToAddon(options) {
|
|
|
35
35
|
function moveToAddonAndTestApp(options) {
|
|
36
36
|
const { locations, packages, projectRoot } = options;
|
|
37
37
|
|
|
38
|
-
const files =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
'.template-lintrc.js',
|
|
58
|
-
'package.json',
|
|
59
|
-
];
|
|
38
|
+
const files = new Set([
|
|
39
|
+
'.eslintignore',
|
|
40
|
+
'.eslintrc.cjs',
|
|
41
|
+
'.eslintrc.js',
|
|
42
|
+
'.gitignore',
|
|
43
|
+
'.prettierignore',
|
|
44
|
+
'.prettierrc.cjs',
|
|
45
|
+
'.prettierrc.js',
|
|
46
|
+
'.stylelintignore',
|
|
47
|
+
'.stylelintrc.cjs',
|
|
48
|
+
'.stylelintrc.js',
|
|
49
|
+
'.template-lintrc.cjs',
|
|
50
|
+
'.template-lintrc.js',
|
|
51
|
+
'package.json',
|
|
52
|
+
]);
|
|
53
|
+
|
|
54
|
+
if (packages.addon.hasTypeScript) {
|
|
55
|
+
files.add('tsconfig.json');
|
|
56
|
+
}
|
|
60
57
|
|
|
61
|
-
const filePaths = glob.sync(globPattern(files), {
|
|
58
|
+
const filePaths = glob.sync(globPattern([...files]), {
|
|
62
59
|
cwd: projectRoot,
|
|
63
60
|
});
|
|
64
61
|
|
|
@@ -76,21 +76,40 @@ function updateDevDependencies(packageJson, options) {
|
|
|
76
76
|
packageJson['devDependencies'] = convertToObject(devDependencies);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
function updateOtherFields(packageJson) {
|
|
79
|
+
function updateOtherFields(packageJson, options) {
|
|
80
|
+
const { packages } = options;
|
|
81
|
+
|
|
80
82
|
packageJson['ember-addon'] = {
|
|
81
83
|
'app-js': {},
|
|
82
|
-
main: 'addon-main.
|
|
84
|
+
main: 'addon-main.cjs',
|
|
83
85
|
type: 'addon',
|
|
84
86
|
version: 2,
|
|
85
87
|
};
|
|
86
88
|
|
|
87
|
-
packageJson['exports'] =
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
packageJson['exports'] = packages.addon.hasTypeScript
|
|
90
|
+
? {
|
|
91
|
+
'.': './dist/index.js',
|
|
92
|
+
'./*': {
|
|
93
|
+
default: './dist/*.js',
|
|
94
|
+
types: './dist/*.d.ts',
|
|
95
|
+
},
|
|
96
|
+
'./addon-main.js': './addon-main.cjs',
|
|
97
|
+
}
|
|
98
|
+
: {
|
|
99
|
+
'.': './dist/index.js',
|
|
100
|
+
'./*': './dist/*.js',
|
|
101
|
+
'./addon-main.js': './addon-main.cjs',
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
packageJson['files'] = ['addon-main.cjs', 'dist'];
|
|
105
|
+
|
|
106
|
+
if (packages.addon.hasTypeScript) {
|
|
107
|
+
packageJson['typesVersions'] = {
|
|
108
|
+
'*': {
|
|
109
|
+
'*': ['dist/*'],
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
94
113
|
}
|
|
95
114
|
|
|
96
115
|
function updateScripts(packageJson) {
|
|
@@ -117,7 +136,7 @@ export function updateAddonPackageJson(options) {
|
|
|
117
136
|
updateDependencies(packageJson, options);
|
|
118
137
|
updateDevDependencies(packageJson, options);
|
|
119
138
|
updateScripts(packageJson);
|
|
120
|
-
updateOtherFields(packageJson);
|
|
139
|
+
updateOtherFields(packageJson, options);
|
|
121
140
|
|
|
122
141
|
const newFile = JSON.stringify(packageJson, null, 2) + '\n';
|
|
123
142
|
|
|
@@ -1,26 +1,37 @@
|
|
|
1
1
|
const latestVersions = new Map([
|
|
2
2
|
['@babel/core', '7.20.12'],
|
|
3
3
|
['@babel/plugin-proposal-class-properties', '7.18.6'],
|
|
4
|
-
['@babel/plugin-proposal-decorators', '7.20.
|
|
4
|
+
['@babel/plugin-proposal-decorators', '7.20.13'],
|
|
5
5
|
['@babel/preset-typescript', '7.18.6'],
|
|
6
6
|
['@embroider/addon-dev', '3.0.0'],
|
|
7
7
|
['@embroider/addon-shim', '1.8.4'],
|
|
8
8
|
['@rollup/plugin-babel', '6.0.3'],
|
|
9
9
|
['concurrently', '7.6.0'],
|
|
10
|
-
['ember-auto-import', '2.
|
|
10
|
+
['ember-auto-import', '2.6.0'],
|
|
11
11
|
['ember-cli-babel', '7.26.11'],
|
|
12
|
-
['ember-cli-htmlbars', '6.
|
|
12
|
+
['ember-cli-htmlbars', '6.2.0'],
|
|
13
13
|
['prettier', '2.8.3'],
|
|
14
|
-
['rollup', '3.
|
|
14
|
+
['rollup', '3.12.0'],
|
|
15
15
|
['rollup-plugin-copy', '3.4.0'],
|
|
16
|
-
['rollup-plugin-ts', '3.
|
|
16
|
+
['rollup-plugin-ts', '3.2.0'],
|
|
17
17
|
]);
|
|
18
18
|
|
|
19
19
|
export function decideVersion(packageName, options) {
|
|
20
20
|
const { packages } = options;
|
|
21
21
|
|
|
22
22
|
const installedVersion = packages.addon.dependencies.get(packageName);
|
|
23
|
-
const latestVersion = `^${latestVersions.get(packageName)}`;
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
if (installedVersion) {
|
|
25
|
+
return installedVersion;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const latestVersion = latestVersions.get(packageName);
|
|
29
|
+
|
|
30
|
+
if (!latestVersion) {
|
|
31
|
+
throw new RangeError(
|
|
32
|
+
`ERROR: The latest version of \`${packageName}\` is unknown.\n`
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return `^${latestVersion}`;
|
|
26
37
|
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import babel from '@rollup/plugin-babel';
|
|
2
|
-
import copy from 'rollup-plugin-copy';
|
|
3
|
-
import { Addon } from '@embroider/addon-dev/rollup';
|
|
4
|
-
|
|
5
|
-
const addon = new Addon({
|
|
6
|
-
srcDir: 'src',
|
|
7
|
-
destDir: 'dist',
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
// This provides defaults that work well alongside `publicEntrypoints` below.
|
|
12
|
-
// You can augment this if you need to.
|
|
13
|
-
output: addon.output(),
|
|
14
|
-
|
|
15
|
-
plugins: [
|
|
16
|
-
// These are the modules that users should be able to import from your
|
|
17
|
-
// addon. Anything not listed here may get optimized away.
|
|
18
|
-
addon.publicEntrypoints([<%= context.addon.publicEntrypoints.map((filePath) => `'${filePath}'`).join(', ') %>]),
|
|
19
|
-
|
|
20
|
-
// These are the modules that should get reexported into the traditional
|
|
21
|
-
// "app" tree. Things in here should also be in publicEntrypoints above, but
|
|
22
|
-
// not everything in publicEntrypoints necessarily needs to go here.
|
|
23
|
-
addon.appReexports([<%= context.addon.appReexports.map((filePath) => `'${filePath}'`).join(', ') %>]),
|
|
24
|
-
|
|
25
|
-
// Follow the V2 Addon rules about dependencies. Your code can import from
|
|
26
|
-
// `dependencies` and `peerDependencies` as well as standard Ember-provided
|
|
27
|
-
// package names.
|
|
28
|
-
addon.dependencies(),
|
|
29
|
-
|
|
30
|
-
// This babel config should *not* apply presets or compile away ES modules.
|
|
31
|
-
// It exists only to provide development niceties for you, like automatic
|
|
32
|
-
// template colocation.
|
|
33
|
-
//
|
|
34
|
-
// By default, this will load the actual babel config from the file
|
|
35
|
-
// babel.config.json.
|
|
36
|
-
babel({
|
|
37
|
-
babelHelpers: 'bundled',
|
|
38
|
-
}),
|
|
39
|
-
|
|
40
|
-
// Ensure that standalone .hbs files are properly integrated as Javascript.
|
|
41
|
-
addon.hbs(),
|
|
42
|
-
|
|
43
|
-
// addons are allowed to contain imports of .css files, which we want rollup
|
|
44
|
-
// to leave alone and keep in the published output.
|
|
45
|
-
addon.keepAssets(['**/*.css']),
|
|
46
|
-
|
|
47
|
-
// Remove leftover build artifacts when starting a new build.
|
|
48
|
-
addon.clean(),
|
|
49
|
-
|
|
50
|
-
// Copy Readme and License into published package
|
|
51
|
-
copy({
|
|
52
|
-
targets: [
|
|
53
|
-
{ src: '../README.md', dest: '.' },
|
|
54
|
-
{ src: '../LICENSE.md', dest: '.' },
|
|
55
|
-
],
|
|
56
|
-
}),
|
|
57
|
-
],
|
|
58
|
-
};
|