ember-codemod-v1-to-v2 0.3.2 → 0.4.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/README.md +1 -1
- package/package.json +5 -5
- package/src/blueprints/ember-addon/.prettierignore +1 -1
- package/src/blueprints/ember-addon/__gitignore__ +4 -11
- package/src/blueprints/ember-addon/package.json +0 -4
- package/src/migration/ember-addon/index.js +1 -1
- package/src/migration/ember-addon/steps/analyze-addon.js +31 -9
- package/src/migration/ember-addon/steps/create-files-from-blueprint.js +2 -2
- package/src/migration/ember-addon/steps/create-options.js +2 -2
- package/src/migration/ember-addon/steps/move-addon-files.js +23 -5
- package/src/migration/ember-addon/steps/move-project-root-files.js +5 -5
- package/src/migration/ember-addon/steps/move-test-app-files.js +6 -6
- package/src/migration/ember-addon/steps/update-addon-package-json.js +73 -49
- package/src/migration/ember-addon/steps/update-test-app-package-json.js +20 -16
- package/src/migration/ember-addon/steps/use-relative-paths.js +3 -3
- package/src/utils/blueprints/decide-version.js +6 -6
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ Step 5. Celebrate.
|
|
|
43
43
|
|
|
44
44
|
<sup>1. Before running `ember-codemod-v1-to-v2`, consider [meeting the prerequisites](https://github.com/embroider-build/embroider/blob/v1.8.3/PORTING-ADDONS-TO-V2.md#part-3-prerequisites-for-v2-addon). You can run [`ember-codemod-pod-to-octane`](https://github.com/ijlee2/ember-codemod-pod-to-octane) to un-pod a v1 addon.</sup>
|
|
45
45
|
|
|
46
|
-
<sup>2. Files such as `.eslintrc.js`, `.gitignore`, `babel.config.json` (addon only), `config/environment.js` (test-app only), `ember-cli-build.js` (test-app only), `package.json`, `rollup.config.
|
|
46
|
+
<sup>2. Files such as `.eslintrc.js`, `.gitignore`, `babel.config.json` (addon only), `config/environment.js` (test-app only), `ember-cli-build.js` (test-app only), `package.json`, `rollup.config.mjs` (addon only), `tsconfig.json`, etc.</sup>
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
### Arguments
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-codemod-v1-to-v2",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Codemod to convert Ember addons to v2 addon format",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codemod",
|
|
@@ -45,16 +45,16 @@
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@babel/core": "^7.
|
|
48
|
+
"@babel/core": "^7.21.0",
|
|
49
49
|
"@babel/eslint-parser": "^7.19.1",
|
|
50
|
-
"glob": "^
|
|
50
|
+
"glob": "^9.2.1",
|
|
51
51
|
"lodash.template": "^4.5.0",
|
|
52
52
|
"strip-json-comments": "^5.0.0",
|
|
53
|
-
"yargs": "^17.
|
|
53
|
+
"yargs": "^17.7.1"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@sondr3/minitest": "^0.1.1",
|
|
57
|
-
"eslint": "^8.
|
|
57
|
+
"eslint": "^8.35.0",
|
|
58
58
|
"eslint-config-prettier": "^8.6.0",
|
|
59
59
|
"eslint-plugin-import": "^2.27.5",
|
|
60
60
|
"eslint-plugin-n": "^15.6.1",
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
# See https://help.github.com/ignore-files/ for more about ignoring files.
|
|
2
2
|
|
|
3
3
|
# compiled output
|
|
4
|
-
|
|
5
|
-
/tmp/
|
|
4
|
+
dist/
|
|
6
5
|
|
|
7
6
|
# dependencies
|
|
8
|
-
/
|
|
9
|
-
/node_modules/
|
|
7
|
+
node_modules/
|
|
10
8
|
|
|
11
9
|
# misc
|
|
12
10
|
/.env*
|
|
13
11
|
/.pnp*
|
|
12
|
+
/.pnpm-debug.log
|
|
14
13
|
/.sass-cache
|
|
15
|
-
|
|
14
|
+
.eslintcache
|
|
16
15
|
/connect.lock
|
|
17
16
|
/coverage/
|
|
18
17
|
/libpeerconnection.log
|
|
@@ -22,11 +21,5 @@
|
|
|
22
21
|
|
|
23
22
|
# ember-try
|
|
24
23
|
/.node_modules.ember-try/
|
|
25
|
-
/bower.json.ember-try
|
|
26
|
-
/npm-shrinkwrap.json.ember-try
|
|
27
24
|
/package.json.ember-try
|
|
28
|
-
/package-lock.json.ember-try
|
|
29
25
|
/yarn.lock.ember-try
|
|
30
|
-
|
|
31
|
-
# broccoli-debug
|
|
32
|
-
/DEBUG/
|
|
@@ -30,10 +30,6 @@
|
|
|
30
30
|
"repository": "",
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"author": "",
|
|
33
|
-
"workspaces": [
|
|
34
|
-
"<%= options.locations.addon %>",
|
|
35
|
-
"<%= options.locations.testApp %>"
|
|
36
|
-
],
|
|
37
33
|
"scripts": {
|
|
38
34
|
"build": "pnpm --filter <%= options.packages.addon.name %> build",
|
|
39
35
|
"lint": "pnpm --filter '*' lint",
|
|
@@ -34,7 +34,7 @@ export function migrateEmberAddon(codemodOptions) {
|
|
|
34
34
|
createFilesFromBlueprint(context, options);
|
|
35
35
|
|
|
36
36
|
// Fine-tune individual files
|
|
37
|
-
updateAddonPackageJson(options);
|
|
37
|
+
updateAddonPackageJson(context, options);
|
|
38
38
|
updateAddonTsconfigJson(options);
|
|
39
39
|
updateTestAppPackageJson(options);
|
|
40
40
|
updateTestAppTsconfigJson(options);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { globSync } from 'glob';
|
|
2
2
|
|
|
3
3
|
import { decideVersion } from '../../../utils/blueprints.js';
|
|
4
4
|
import { renameDirectory } from '../../../utils/files.js';
|
|
@@ -6,16 +6,18 @@ import { renameDirectory } from '../../../utils/files.js';
|
|
|
6
6
|
function getAppReexports(options) {
|
|
7
7
|
const { projectRoot } = options;
|
|
8
8
|
|
|
9
|
-
const filePaths =
|
|
9
|
+
const filePaths = globSync('app/**/*.js', {
|
|
10
10
|
cwd: projectRoot,
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
return filePaths
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
return filePaths
|
|
14
|
+
.map((filePath) => {
|
|
15
|
+
return renameDirectory(filePath, {
|
|
16
|
+
from: 'app',
|
|
17
|
+
to: '',
|
|
18
|
+
});
|
|
19
|
+
})
|
|
20
|
+
.sort();
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
function getProjectRootDevDependencies(options) {
|
|
@@ -25,10 +27,29 @@ function getProjectRootDevDependencies(options) {
|
|
|
25
27
|
};
|
|
26
28
|
}
|
|
27
29
|
|
|
30
|
+
function getPublicAssets(options) {
|
|
31
|
+
const { projectRoot } = options;
|
|
32
|
+
|
|
33
|
+
const filePaths = globSync('public/**/*', {
|
|
34
|
+
cwd: projectRoot,
|
|
35
|
+
dot: true,
|
|
36
|
+
nodir: true,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return filePaths
|
|
40
|
+
.map((filePath) => {
|
|
41
|
+
return renameDirectory(filePath, {
|
|
42
|
+
from: 'public',
|
|
43
|
+
to: '',
|
|
44
|
+
});
|
|
45
|
+
})
|
|
46
|
+
.sort();
|
|
47
|
+
}
|
|
48
|
+
|
|
28
49
|
function getPublicEntrypoints(options) {
|
|
29
50
|
const { projectRoot } = options;
|
|
30
51
|
|
|
31
|
-
const filePaths =
|
|
52
|
+
const filePaths = globSync('{addon,addon-test-support}/**/*.{js,ts}', {
|
|
32
53
|
cwd: projectRoot,
|
|
33
54
|
});
|
|
34
55
|
|
|
@@ -55,6 +76,7 @@ export function analyzeAddon(options) {
|
|
|
55
76
|
return {
|
|
56
77
|
addon: {
|
|
57
78
|
appReexports: getAppReexports(options),
|
|
79
|
+
publicAssets: getPublicAssets(options),
|
|
58
80
|
publicEntrypoints: getPublicEntrypoints(options),
|
|
59
81
|
},
|
|
60
82
|
projectRoot: {
|
|
@@ -2,7 +2,7 @@ import { readFileSync } from 'node:fs';
|
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import { globSync } from 'glob';
|
|
6
6
|
|
|
7
7
|
import { processTemplate } from '../../../utils/blueprints.js';
|
|
8
8
|
import { createFiles } from '../../../utils/files.js';
|
|
@@ -47,7 +47,7 @@ export function createFilesFromBlueprint(context, options) {
|
|
|
47
47
|
|
|
48
48
|
const filesToSkip = getFilesToSkip(options);
|
|
49
49
|
|
|
50
|
-
const blueprintFilePaths =
|
|
50
|
+
const blueprintFilePaths = globSync('**/*', {
|
|
51
51
|
cwd: blueprintRoot,
|
|
52
52
|
dot: true,
|
|
53
53
|
ignore: filesToSkip,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { globSync } from 'glob';
|
|
5
5
|
|
|
6
6
|
function analyzePackageJson(codemodOptions) {
|
|
7
7
|
const { projectRoot } = codemodOptions;
|
|
@@ -51,7 +51,7 @@ function analyzePackageJson(codemodOptions) {
|
|
|
51
51
|
function analyzePackageManager(codemodOptions) {
|
|
52
52
|
const { projectRoot } = codemodOptions;
|
|
53
53
|
|
|
54
|
-
const lockFiles =
|
|
54
|
+
const lockFiles = globSync('{package-lock.json,pnpm-lock.yaml,yarn.lock}', {
|
|
55
55
|
cwd: projectRoot,
|
|
56
56
|
});
|
|
57
57
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { globSync } from 'glob';
|
|
2
2
|
|
|
3
3
|
import { mapFilePaths, moveFiles, removeFiles } from '../../../utils/files.js';
|
|
4
4
|
|
|
5
5
|
function moveAddonFolder(options) {
|
|
6
6
|
const { locations, projectRoot } = options;
|
|
7
7
|
|
|
8
|
-
const filePaths =
|
|
8
|
+
const filePaths = globSync('addon/**/*', {
|
|
9
9
|
cwd: projectRoot,
|
|
10
10
|
dot: true,
|
|
11
11
|
nodir: true,
|
|
@@ -22,7 +22,7 @@ function moveAddonFolder(options) {
|
|
|
22
22
|
function moveAddonTestSupportFolder(options) {
|
|
23
23
|
const { locations, projectRoot } = options;
|
|
24
24
|
|
|
25
|
-
const filePaths =
|
|
25
|
+
const filePaths = globSync('addon-test-support/**/*', {
|
|
26
26
|
cwd: projectRoot,
|
|
27
27
|
dot: true,
|
|
28
28
|
nodir: true,
|
|
@@ -39,7 +39,7 @@ function moveAddonTestSupportFolder(options) {
|
|
|
39
39
|
function moveBlueprintsFolder(options) {
|
|
40
40
|
const { locations, projectRoot } = options;
|
|
41
41
|
|
|
42
|
-
const filePaths =
|
|
42
|
+
const filePaths = globSync('blueprints/**/*', {
|
|
43
43
|
cwd: projectRoot,
|
|
44
44
|
dot: true,
|
|
45
45
|
nodir: true,
|
|
@@ -53,10 +53,27 @@ function moveBlueprintsFolder(options) {
|
|
|
53
53
|
moveFiles(pathMapping, options);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
function movePublicFolder(options) {
|
|
57
|
+
const { locations, projectRoot } = options;
|
|
58
|
+
|
|
59
|
+
const filePaths = globSync('public/**/*', {
|
|
60
|
+
cwd: projectRoot,
|
|
61
|
+
dot: true,
|
|
62
|
+
nodir: true,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const pathMapping = mapFilePaths(filePaths, {
|
|
66
|
+
from: 'public',
|
|
67
|
+
to: `${locations.addon}/public`,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
moveFiles(pathMapping, options);
|
|
71
|
+
}
|
|
72
|
+
|
|
56
73
|
function removeAppFolder(options) {
|
|
57
74
|
const { projectRoot } = options;
|
|
58
75
|
|
|
59
|
-
const filePaths =
|
|
76
|
+
const filePaths = globSync('app/**/*', {
|
|
60
77
|
cwd: projectRoot,
|
|
61
78
|
dot: true,
|
|
62
79
|
nodir: true,
|
|
@@ -69,5 +86,6 @@ export function moveAddonFiles(options) {
|
|
|
69
86
|
moveAddonFolder(options);
|
|
70
87
|
moveAddonTestSupportFolder(options);
|
|
71
88
|
moveBlueprintsFolder(options);
|
|
89
|
+
movePublicFolder(options);
|
|
72
90
|
removeAppFolder(options);
|
|
73
91
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { globSync } from 'glob';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
copyFiles,
|
|
@@ -20,7 +20,7 @@ function copyToAddon(options) {
|
|
|
20
20
|
|
|
21
21
|
const files = ['LICENSE.md', 'README.md'];
|
|
22
22
|
|
|
23
|
-
const filePaths =
|
|
23
|
+
const filePaths = globSync(globPattern(files), {
|
|
24
24
|
cwd: projectRoot,
|
|
25
25
|
});
|
|
26
26
|
|
|
@@ -55,7 +55,7 @@ function moveToAddonAndTestApp(options) {
|
|
|
55
55
|
files.add('tsconfig.json');
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
const filePaths =
|
|
58
|
+
const filePaths = globSync(globPattern([...files]), {
|
|
59
59
|
cwd: projectRoot,
|
|
60
60
|
});
|
|
61
61
|
|
|
@@ -86,7 +86,7 @@ function moveToTestApp(options) {
|
|
|
86
86
|
'testem.js',
|
|
87
87
|
];
|
|
88
88
|
|
|
89
|
-
const filePaths =
|
|
89
|
+
const filePaths = globSync(globPattern(files), {
|
|
90
90
|
cwd: projectRoot,
|
|
91
91
|
});
|
|
92
92
|
|
|
@@ -103,7 +103,7 @@ function removeFromProjectRoot(options) {
|
|
|
103
103
|
|
|
104
104
|
const files = ['.npmignore', 'index.js'];
|
|
105
105
|
|
|
106
|
-
const filePaths =
|
|
106
|
+
const filePaths = globSync(globPattern(files), {
|
|
107
107
|
cwd: projectRoot,
|
|
108
108
|
});
|
|
109
109
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { globSync } from 'glob';
|
|
5
5
|
|
|
6
6
|
import { mapFilePaths, moveFiles } from '../../../utils/files.js';
|
|
7
7
|
|
|
8
8
|
function moveTestsFolder(options) {
|
|
9
9
|
const { locations, projectRoot } = options;
|
|
10
10
|
|
|
11
|
-
let filePaths =
|
|
11
|
+
let filePaths = globSync('tests/dummy/**/*', {
|
|
12
12
|
cwd: projectRoot,
|
|
13
13
|
dot: true,
|
|
14
14
|
nodir: true,
|
|
@@ -21,7 +21,7 @@ function moveTestsFolder(options) {
|
|
|
21
21
|
|
|
22
22
|
moveFiles(pathMapping, options);
|
|
23
23
|
|
|
24
|
-
filePaths =
|
|
24
|
+
filePaths = globSync('tests/**/*', {
|
|
25
25
|
cwd: projectRoot,
|
|
26
26
|
dot: true,
|
|
27
27
|
ignore: 'tests/dummy/**/*',
|
|
@@ -43,7 +43,7 @@ function moveTypesFolder(options) {
|
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
let filePaths =
|
|
46
|
+
let filePaths = globSync('types/dummy/**/*', {
|
|
47
47
|
cwd: projectRoot,
|
|
48
48
|
dot: true,
|
|
49
49
|
nodir: true,
|
|
@@ -56,7 +56,7 @@ function moveTypesFolder(options) {
|
|
|
56
56
|
|
|
57
57
|
moveFiles(pathMapping, options);
|
|
58
58
|
|
|
59
|
-
filePaths =
|
|
59
|
+
filePaths = globSync('types/**/*', {
|
|
60
60
|
cwd: projectRoot,
|
|
61
61
|
dot: true,
|
|
62
62
|
ignore: 'types/dummy/**/*',
|
|
@@ -76,7 +76,7 @@ function renameDummy(options) {
|
|
|
76
76
|
|
|
77
77
|
// File extensions had been specified, partly to encode assumptions
|
|
78
78
|
// about Ember, and partly to avoid corrupting non-text files
|
|
79
|
-
const filePaths =
|
|
79
|
+
const filePaths = globSync(`${locations.testApp}/**/*.{d.ts,html,js,ts}`, {
|
|
80
80
|
cwd: projectRoot,
|
|
81
81
|
dot: true,
|
|
82
82
|
nodir: true,
|
|
@@ -20,7 +20,7 @@ function updateDependencies(packageJson, options) {
|
|
|
20
20
|
|
|
21
21
|
const packagesToInstall = ['@embroider/addon-shim'];
|
|
22
22
|
|
|
23
|
-
packagesToInstall.forEach((packageName) => {
|
|
23
|
+
packagesToInstall.sort().forEach((packageName) => {
|
|
24
24
|
const version = decideVersion(packageName, options);
|
|
25
25
|
|
|
26
26
|
dependencies.set(packageName, version);
|
|
@@ -46,28 +46,23 @@ function updateDevDependencies(packageJson, options) {
|
|
|
46
46
|
*/
|
|
47
47
|
devDependencies.clear();
|
|
48
48
|
|
|
49
|
-
const packagesToInstall =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
'rollup',
|
|
67
|
-
'rollup-plugin-copy',
|
|
68
|
-
];
|
|
69
|
-
|
|
70
|
-
packagesToInstall.forEach((packageName) => {
|
|
49
|
+
const packagesToInstall = new Set([
|
|
50
|
+
'@babel/core',
|
|
51
|
+
'@babel/plugin-proposal-class-properties',
|
|
52
|
+
'@babel/plugin-proposal-decorators',
|
|
53
|
+
'@embroider/addon-dev',
|
|
54
|
+
'@rollup/plugin-babel',
|
|
55
|
+
'rollup',
|
|
56
|
+
'rollup-plugin-copy',
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
if (packages.addon.hasTypeScript) {
|
|
60
|
+
packagesToInstall.add('@babel/preset-typescript');
|
|
61
|
+
packagesToInstall.add('rollup-plugin-ts');
|
|
62
|
+
packagesToInstall.delete('@rollup/plugin-babel');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
[...packagesToInstall].sort().forEach((packageName) => {
|
|
71
66
|
const version = decideVersion(packageName, options);
|
|
72
67
|
|
|
73
68
|
devDependencies.set(packageName, version);
|
|
@@ -76,32 +71,61 @@ function updateDevDependencies(packageJson, options) {
|
|
|
76
71
|
packageJson['devDependencies'] = convertToObject(devDependencies);
|
|
77
72
|
}
|
|
78
73
|
|
|
79
|
-
function updateOtherFields(packageJson, options) {
|
|
74
|
+
function updateOtherFields(packageJson, context, options) {
|
|
80
75
|
const { packages } = options;
|
|
76
|
+
const hasPublicAssets = context.addon.publicAssets.length > 0;
|
|
77
|
+
|
|
78
|
+
if (hasPublicAssets) {
|
|
79
|
+
const publicAssetMapping = context.addon.publicAssets.reduce(
|
|
80
|
+
(accumulator, filePath) => {
|
|
81
|
+
const from = `./public/${filePath}`;
|
|
82
|
+
const to = `/${packages.addon.name}/${filePath}`;
|
|
83
|
+
|
|
84
|
+
accumulator[from] = to;
|
|
85
|
+
|
|
86
|
+
return accumulator;
|
|
87
|
+
},
|
|
88
|
+
{}
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
packageJson['ember-addon'] = {
|
|
92
|
+
'app-js': {},
|
|
93
|
+
main: 'addon-main.cjs',
|
|
94
|
+
'public-assets': publicAssetMapping,
|
|
95
|
+
type: 'addon',
|
|
96
|
+
version: 2,
|
|
97
|
+
};
|
|
98
|
+
} else {
|
|
99
|
+
packageJson['ember-addon'] = {
|
|
100
|
+
'app-js': {},
|
|
101
|
+
main: 'addon-main.cjs',
|
|
102
|
+
type: 'addon',
|
|
103
|
+
version: 2,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
81
106
|
|
|
82
|
-
|
|
83
|
-
'
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
packageJson['files'] = ['addon-main.cjs', 'dist'];
|
|
107
|
+
if (packages.addon.hasTypeScript) {
|
|
108
|
+
packageJson['exports'] = {
|
|
109
|
+
'.': './dist/index.js',
|
|
110
|
+
'./*': {
|
|
111
|
+
types: './dist/*.d.ts',
|
|
112
|
+
default: './dist/*.js',
|
|
113
|
+
},
|
|
114
|
+
'./addon-main.js': './addon-main.cjs',
|
|
115
|
+
};
|
|
116
|
+
} else {
|
|
117
|
+
packageJson['exports'] = {
|
|
118
|
+
'.': './dist/index.js',
|
|
119
|
+
'./*': './dist/*.js',
|
|
120
|
+
'./addon-main.js': './addon-main.cjs',
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (hasPublicAssets) {
|
|
125
|
+
packageJson['files'] = ['addon-main.cjs', 'dist', 'public'];
|
|
126
|
+
} else {
|
|
127
|
+
packageJson['files'] = ['addon-main.cjs', 'dist'];
|
|
128
|
+
}
|
|
105
129
|
|
|
106
130
|
if (packages.addon.hasTypeScript) {
|
|
107
131
|
packageJson['typesVersions'] = {
|
|
@@ -126,7 +150,7 @@ function updateScripts(packageJson) {
|
|
|
126
150
|
packageJson['scripts'] = convertToObject(scripts);
|
|
127
151
|
}
|
|
128
152
|
|
|
129
|
-
export function updateAddonPackageJson(options) {
|
|
153
|
+
export function updateAddonPackageJson(context, options) {
|
|
130
154
|
const { locations, projectRoot } = options;
|
|
131
155
|
|
|
132
156
|
const oldPath = join(projectRoot, locations.addon, 'package.json');
|
|
@@ -136,7 +160,7 @@ export function updateAddonPackageJson(options) {
|
|
|
136
160
|
updateDependencies(packageJson, options);
|
|
137
161
|
updateDevDependencies(packageJson, options);
|
|
138
162
|
updateScripts(packageJson);
|
|
139
|
-
updateOtherFields(packageJson, options);
|
|
163
|
+
updateOtherFields(packageJson, context, options);
|
|
140
164
|
|
|
141
165
|
const newFile = JSON.stringify(packageJson, null, 2) + '\n';
|
|
142
166
|
|
|
@@ -10,22 +10,26 @@ function moveDependenciesToDevDependencies(packageJson, options) {
|
|
|
10
10
|
const dependencies = convertToMap(packageJson['dependencies']);
|
|
11
11
|
const devDependencies = convertToMap(packageJson['devDependencies']);
|
|
12
12
|
|
|
13
|
-
const packagesToMove =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
13
|
+
const packagesToMove = new Set([
|
|
14
|
+
'ember-auto-import',
|
|
15
|
+
'ember-cli-babel',
|
|
16
|
+
'ember-cli-htmlbars',
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
if (packages.addon.hasTypeScript) {
|
|
20
|
+
packagesToMove.add('ember-cli-typescript');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
[...packagesToMove]
|
|
24
|
+
.filter((packageName) => dependencies.has(packageName))
|
|
25
|
+
.sort()
|
|
26
|
+
.forEach((packageName) => {
|
|
27
|
+
const version = decideVersion(packageName, options);
|
|
28
|
+
|
|
29
|
+
devDependencies.set(packageName, version);
|
|
30
|
+
|
|
31
|
+
dependencies.delete(packageName);
|
|
32
|
+
});
|
|
29
33
|
|
|
30
34
|
packageJson['dependencies'] = convertToObject(dependencies);
|
|
31
35
|
packageJson['devDependencies'] = convertToObject(devDependencies);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { dirname, join, relative } from 'node:path';
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { globSync } from 'glob';
|
|
5
5
|
|
|
6
6
|
function normalizeRelativePath(relativePath) {
|
|
7
7
|
if (!relativePath.startsWith('..')) {
|
|
@@ -38,7 +38,7 @@ function useRelativePathInAddonFolder(options) {
|
|
|
38
38
|
|
|
39
39
|
// File extensions had been specified, partly to encode assumptions
|
|
40
40
|
// about Ember, and partly to avoid corrupting non-text files
|
|
41
|
-
const filePaths =
|
|
41
|
+
const filePaths = globSync('addon/**/*.{d.ts,js,ts}', {
|
|
42
42
|
cwd: projectRoot,
|
|
43
43
|
dot: true,
|
|
44
44
|
nodir: true,
|
|
@@ -63,7 +63,7 @@ function useRelativePathInTestsDummyFolder(options) {
|
|
|
63
63
|
|
|
64
64
|
// File extensions had been specified, partly to encode assumptions
|
|
65
65
|
// about Ember, and partly to avoid corrupting non-text files
|
|
66
|
-
const filePaths =
|
|
66
|
+
const filePaths = globSync('tests/dummy/**/*.{d.ts,js,ts}', {
|
|
67
67
|
cwd: projectRoot,
|
|
68
68
|
dot: true,
|
|
69
69
|
nodir: true,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
const latestVersions = new Map([
|
|
2
|
-
['@babel/core', '7.
|
|
2
|
+
['@babel/core', '7.21.0'],
|
|
3
3
|
['@babel/plugin-proposal-class-properties', '7.18.6'],
|
|
4
|
-
['@babel/plugin-proposal-decorators', '7.
|
|
5
|
-
['@babel/preset-typescript', '7.
|
|
4
|
+
['@babel/plugin-proposal-decorators', '7.21.0'],
|
|
5
|
+
['@babel/preset-typescript', '7.21.0'],
|
|
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.6.
|
|
10
|
+
['ember-auto-import', '2.6.1'],
|
|
11
11
|
['ember-cli-babel', '7.26.11'],
|
|
12
12
|
['ember-cli-htmlbars', '6.2.0'],
|
|
13
|
-
['prettier', '2.8.
|
|
14
|
-
['rollup', '3.
|
|
13
|
+
['prettier', '2.8.4'],
|
|
14
|
+
['rollup', '3.18.0'],
|
|
15
15
|
['rollup-plugin-copy', '3.4.0'],
|
|
16
16
|
['rollup-plugin-ts', '3.2.0'],
|
|
17
17
|
]);
|