ember-codemod-v1-to-v2 1.1.1 → 1.2.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/dist/src/blueprints/ember-addon/__addonLocation__/babel.config.json +8 -3
- package/dist/src/blueprints/ember-addon/__addonLocation__/unpublished-development-types/index.d.ts +1 -0
- package/dist/src/steps/analyze-addon.js +16 -10
- package/dist/src/steps/update-addon-package-json/update-dependencies.js +1 -1
- package/dist/src/steps/update-addon-package-json/update-dev-dependencies.js +0 -3
- package/dist/src/steps/update-addon-package-json/update-other-fields.js +13 -15
- package/dist/src/steps/update-addon-tsconfig-json.js +1 -0
- package/dist/src/utils/blueprints/get-version.js +11 -13
- package/package.json +3 -3
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
<% } %> "@embroider/addon-dev/template-colocation-plugin",
|
|
12
|
-
"@babel/plugin-transform-class-static-block",
|
|
13
12
|
[
|
|
14
13
|
"babel-plugin-ember-template-compilation",
|
|
15
14
|
{
|
|
@@ -17,7 +16,13 @@
|
|
|
17
16
|
"transforms": []
|
|
18
17
|
}
|
|
19
18
|
],
|
|
20
|
-
[
|
|
21
|
-
|
|
19
|
+
[
|
|
20
|
+
"module:decorator-transforms",
|
|
21
|
+
{
|
|
22
|
+
"runtime": {
|
|
23
|
+
"import": "decorator-transforms/runtime"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
]
|
|
22
27
|
]
|
|
23
28
|
}
|
package/dist/src/blueprints/ember-addon/__addonLocation__/unpublished-development-types/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// These will *not* be published as part of your addon, so be careful that your published code does not rely on them!
|
|
3
3
|
<% if (options.packages.addon.hasGlint) { %>
|
|
4
4
|
import '@glint/environment-ember-loose';
|
|
5
|
+
// import '@glint/environment-ember-template-imports';
|
|
5
6
|
|
|
6
7
|
declare module '@glint/environment-ember-loose/registry' {
|
|
7
8
|
// Remove this once entries have been added! 👇
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { findFiles
|
|
1
|
+
import { findFiles } from '@codemod-utils/files';
|
|
2
2
|
import { getVersion } from '../utils/blueprints.js';
|
|
3
3
|
function getProjectRootDevDependencies(options) {
|
|
4
4
|
return {
|
|
@@ -6,22 +6,28 @@ function getProjectRootDevDependencies(options) {
|
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
8
|
function getPublicAssets(options) {
|
|
9
|
-
const { projectRoot } = options;
|
|
9
|
+
const { packages, projectRoot } = options;
|
|
10
10
|
const filePaths = findFiles('public/**/*', {
|
|
11
11
|
projectRoot,
|
|
12
12
|
});
|
|
13
|
-
return filePaths
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
return filePaths.reduce((accumulator, filePath) => {
|
|
14
|
+
const from = `./${filePath}`;
|
|
15
|
+
const to = `/${packages.addon.name}/${filePath.replace(/^public\//, '')}`;
|
|
16
|
+
accumulator[from] = to;
|
|
17
|
+
return accumulator;
|
|
18
|
+
}, {});
|
|
19
|
+
}
|
|
20
|
+
function hasBlueprints(options) {
|
|
21
|
+
const { projectRoot } = options;
|
|
22
|
+
const filePaths = findFiles('blueprints/**/*', {
|
|
23
|
+
projectRoot,
|
|
24
|
+
});
|
|
25
|
+
return filePaths.length > 0;
|
|
21
26
|
}
|
|
22
27
|
export function analyzeAddon(options) {
|
|
23
28
|
return {
|
|
24
29
|
addon: {
|
|
30
|
+
hasBlueprints: hasBlueprints(options),
|
|
25
31
|
publicAssets: getPublicAssets(options),
|
|
26
32
|
},
|
|
27
33
|
projectRoot: {
|
|
@@ -14,7 +14,7 @@ export function updateDependencies(packageJson, options) {
|
|
|
14
14
|
Array.from(packagesToDelete).forEach((packageName) => {
|
|
15
15
|
dependencies.delete(packageName);
|
|
16
16
|
});
|
|
17
|
-
const packagesToInstall = ['@embroider/addon-shim'];
|
|
17
|
+
const packagesToInstall = ['@embroider/addon-shim', 'decorator-transforms'];
|
|
18
18
|
packagesToInstall.forEach((packageName) => {
|
|
19
19
|
const version = getVersion(packageName, options);
|
|
20
20
|
dependencies.set(packageName, version);
|
|
@@ -16,9 +16,6 @@ export function updateDevDependencies(packageJson, options) {
|
|
|
16
16
|
devDependencies.clear();
|
|
17
17
|
const packagesToInstall = new Set([
|
|
18
18
|
'@babel/core',
|
|
19
|
-
'@babel/plugin-proposal-decorators',
|
|
20
|
-
'@babel/plugin-transform-class-properties',
|
|
21
|
-
'@babel/plugin-transform-class-static-block',
|
|
22
19
|
'@babel/runtime',
|
|
23
20
|
'@embroider/addon-dev',
|
|
24
21
|
'@rollup/plugin-babel',
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
function updateEmberAddon(packageJson, data) {
|
|
2
|
-
const { hasPublicAssets,
|
|
3
|
-
if (
|
|
2
|
+
const { hasPublicAssets, publicAssets } = data;
|
|
3
|
+
if (hasPublicAssets) {
|
|
4
4
|
packageJson['ember-addon'] = {
|
|
5
5
|
'app-js': {},
|
|
6
6
|
main: 'addon-main.cjs',
|
|
7
|
+
'public-assets': publicAssets,
|
|
7
8
|
type: 'addon',
|
|
8
9
|
version: 2,
|
|
9
10
|
};
|
|
@@ -12,7 +13,6 @@ function updateEmberAddon(packageJson, data) {
|
|
|
12
13
|
packageJson['ember-addon'] = {
|
|
13
14
|
'app-js': {},
|
|
14
15
|
main: 'addon-main.cjs',
|
|
15
|
-
'public-assets': publicAssetMapping,
|
|
16
16
|
type: 'addon',
|
|
17
17
|
version: 2,
|
|
18
18
|
};
|
|
@@ -43,8 +43,11 @@ function updateExports(packageJson, data) {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
function updateFiles(packageJson, data) {
|
|
46
|
-
const { hasPublicAssets, hasTypeScript } = data;
|
|
46
|
+
const { hasBlueprints, hasPublicAssets, hasTypeScript } = data;
|
|
47
47
|
const files = new Set(['addon-main.cjs', 'dist']);
|
|
48
|
+
if (hasBlueprints) {
|
|
49
|
+
files.add('blueprints');
|
|
50
|
+
}
|
|
48
51
|
if (hasPublicAssets) {
|
|
49
52
|
files.add('public');
|
|
50
53
|
}
|
|
@@ -65,18 +68,13 @@ function updateTypesVersions(packageJson, data) {
|
|
|
65
68
|
};
|
|
66
69
|
}
|
|
67
70
|
export function updateOtherFields(packageJson, context, options) {
|
|
68
|
-
const {
|
|
69
|
-
const
|
|
70
|
-
const from = `./public/${filePath}`;
|
|
71
|
-
const to = `/${packages.addon.name}/${filePath}`;
|
|
72
|
-
accumulator[from] = to;
|
|
73
|
-
return accumulator;
|
|
74
|
-
}, {});
|
|
75
|
-
const hasPublicAssets = Object.keys(publicAssetMapping).length > 0;
|
|
71
|
+
const { hasBlueprints, publicAssets } = context.addon;
|
|
72
|
+
const { hasTypeScript } = options.packages.addon;
|
|
76
73
|
const data = {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
hasBlueprints,
|
|
75
|
+
hasPublicAssets: Object.keys(publicAssets).length > 0,
|
|
76
|
+
hasTypeScript,
|
|
77
|
+
publicAssets,
|
|
80
78
|
};
|
|
81
79
|
updateEmberAddon(packageJson, data);
|
|
82
80
|
updateExports(packageJson, data);
|
|
@@ -11,6 +11,7 @@ function setCompilerOptions(tsConfigJson, options) {
|
|
|
11
11
|
compilerOptions.set('allowImportingTsExtensions', true);
|
|
12
12
|
compilerOptions.set('allowJs', true);
|
|
13
13
|
compilerOptions.set('declarationDir', 'declarations');
|
|
14
|
+
compilerOptions.set('rootDir', './src');
|
|
14
15
|
if (!packages.addon.hasGlint) {
|
|
15
16
|
compilerOptions.set('declaration', true);
|
|
16
17
|
compilerOptions.set('emitDeclarationOnly', true);
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { decideVersion } from '@codemod-utils/blueprints';
|
|
2
2
|
const latestVersions = new Map([
|
|
3
|
-
['@babel/core', '7.23.
|
|
4
|
-
['@babel/plugin-
|
|
5
|
-
['@babel/
|
|
6
|
-
['@
|
|
7
|
-
['@
|
|
8
|
-
['@
|
|
9
|
-
['@embroider/addon-dev', '4.1.1'],
|
|
10
|
-
['@embroider/addon-shim', '1.8.6'],
|
|
11
|
-
['@embroider/test-setup', '3.0.2'],
|
|
3
|
+
['@babel/core', '7.23.6'],
|
|
4
|
+
['@babel/plugin-transform-typescript', '7.23.6'],
|
|
5
|
+
['@babel/runtime', '7.23.6'],
|
|
6
|
+
['@embroider/addon-dev', '4.1.3'],
|
|
7
|
+
['@embroider/addon-shim', '1.8.7'],
|
|
8
|
+
['@embroider/test-setup', '3.0.3'],
|
|
12
9
|
['@rollup/plugin-babel', '6.0.4'],
|
|
13
|
-
['@tsconfig/ember', '3.0.
|
|
10
|
+
['@tsconfig/ember', '3.0.3'],
|
|
14
11
|
['babel-plugin-ember-template-compilation', '2.2.1'],
|
|
15
12
|
['concurrently', '8.2.2'],
|
|
16
|
-
['
|
|
13
|
+
['decorator-transforms', '1.0.1'],
|
|
14
|
+
['ember-auto-import', '2.7.1'],
|
|
17
15
|
['ember-cli-babel', '8.1.0'],
|
|
18
16
|
['ember-cli-htmlbars', '6.3.0'],
|
|
19
|
-
['rollup', '4.
|
|
17
|
+
['rollup', '4.9.1'],
|
|
20
18
|
['rollup-plugin-copy', '3.5.0'],
|
|
21
|
-
['typescript', '5.
|
|
19
|
+
['typescript', '5.3.3'],
|
|
22
20
|
]);
|
|
23
21
|
export function getVersion(packageName, options) {
|
|
24
22
|
const { packages } = options;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-codemod-v1-to-v2",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Codemod to convert Ember addons to v2 addon format",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codemod",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"eslint-config-prettier": "^9.1.0",
|
|
49
49
|
"eslint-import-resolver-typescript": "^3.6.1",
|
|
50
50
|
"eslint-plugin-import": "^2.29.1",
|
|
51
|
-
"eslint-plugin-n": "^16.
|
|
52
|
-
"eslint-plugin-prettier": "^5.0
|
|
51
|
+
"eslint-plugin-n": "^16.5.0",
|
|
52
|
+
"eslint-plugin-prettier": "^5.1.0",
|
|
53
53
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
54
54
|
"eslint-plugin-typescript-sort-keys": "^3.1.0",
|
|
55
55
|
"lerna-changelog": "^2.2.0",
|