ember-codemod-v1-to-v2 1.2.0 → 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.
|
@@ -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: {
|
|
@@ -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);
|