ember-codemod-v1-to-v2 2.2.0 → 3.0.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 +3 -12
- package/dist/src/blueprints/ember-addon/__addonLocation__/.prettierignore +7 -0
- package/dist/src/blueprints/ember-addon/__addonLocation__/__gitignore__ +1 -1
- package/dist/src/blueprints/ember-addon/__addonLocation__/babel.config.cjs +31 -0
- package/dist/src/blueprints/ember-addon/__addonLocation__/prettier.config.mjs +1 -1
- package/dist/src/blueprints/ember-addon/__addonLocation__/rollup.config.mjs +13 -12
- package/dist/src/blueprints/ember-addon/__addonLocation__/tsconfig.json +13 -15
- package/dist/src/blueprints/ember-addon/__addonLocation__/unpublished-development-types/index.d.ts +0 -13
- package/dist/src/blueprints/ember-addon/__gitignore__ +1 -1
- package/dist/src/blueprints/ember-addon/__npmrc__ +4 -0
- package/dist/src/blueprints/ember-addon/__testAppLocation__/.prettierignore +4 -0
- package/dist/src/blueprints/ember-addon/__testAppLocation__/.stylelintignore +0 -1
- package/dist/src/blueprints/ember-addon/__testAppLocation__/ember-cli-build.js +5 -3
- package/dist/src/blueprints/ember-addon/__testAppLocation__/prettier.config.mjs +1 -1
- package/dist/src/blueprints/ember-addon/__testAppLocation__/tsconfig.json +9 -15
- package/dist/src/blueprints/ember-addon/__testAppLocation__/types/global.d.ts +0 -3
- package/dist/src/blueprints/ember-addon/package.json +7 -49
- package/dist/src/steps/analyze-addon.js +5 -7
- package/dist/src/steps/create-files-from-blueprints.js +2 -4
- package/dist/src/steps/create-options.js +2 -22
- package/dist/src/steps/move-addon-files.js +1 -1
- package/dist/src/steps/update-addon-package-json/update-dev-dependencies.js +6 -6
- package/dist/src/steps/update-addon-package-json/update-scripts.js +6 -4
- package/dist/src/steps/update-test-app-package-json/move-dev-dependencies-to-dependencies.js +0 -4
- package/dist/src/steps/update-test-app-package-json/update-dev-dependencies.js +11 -4
- package/dist/src/steps/update-test-app-package-json/update-scripts.js +6 -4
- package/dist/src/utils/blueprints/get-version.js +31 -29
- package/package.json +6 -6
- package/dist/src/blueprints/ember-addon/__addonLocation__/babel.config.json +0 -28
package/README.md
CHANGED
|
@@ -5,14 +5,6 @@
|
|
|
5
5
|
_Codemod to convert Ember addons to v2 addon format_
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
## Features
|
|
9
|
-
|
|
10
|
-
- Follows closely [`@embroider/addon-blueprint`](https://github.com/embroider-build/addon-blueprint)
|
|
11
|
-
- Preserves your code whenever possible
|
|
12
|
-
- Supports [`ember-cli-typescript`](https://docs.ember-cli-typescript.com/) and [`glint`](https://typed-ember.gitbook.io/glint/)
|
|
13
|
-
- Focuses on maintainability and extensibility
|
|
14
|
-
|
|
15
|
-
|
|
16
8
|
## Usage
|
|
17
9
|
|
|
18
10
|
For examples, see [`ember-container-query`](https://github.com/ijlee2/ember-container-query/pull/151/commits) and [`ember-render-helpers`](https://github.com/buschtoens/ember-render-helpers/pull/447/commits).
|
|
@@ -32,6 +24,7 @@ npx ember-codemod-v1-to-v2 <arguments>
|
|
|
32
24
|
>
|
|
33
25
|
> - [Meet prerequisites for v2 addon](https://github.com/embroider-build/embroider/blob/v7.1.3-%40embroider/addon-dev/docs/porting-addons-to-v2.md#part-3-prerequisites-for-v2-addon).
|
|
34
26
|
> - [Un-pod v1 addon](https://github.com/ijlee2/ember-codemod-pod-to-octane).
|
|
27
|
+
> - [Convert templates to strict mode](https://github.com/ijlee2/ember-codemod-add-template-tags).
|
|
35
28
|
> - Update dependencies.
|
|
36
29
|
> - Switch `npm` or `yarn` to `pnpm`.
|
|
37
30
|
|
|
@@ -51,7 +44,7 @@ Step 3. Review the test-app package.
|
|
|
51
44
|
|
|
52
45
|
Step 4. Review the workspace root including CI/CD.
|
|
53
46
|
|
|
54
|
-
<sup>1. Files such as `eslint.config.mjs`, `.gitignore`, `babel.config.
|
|
47
|
+
<sup>1. Files such as `eslint.config.mjs`, `.gitignore`, `babel.config.cjs` (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>
|
|
55
48
|
|
|
56
49
|
|
|
57
50
|
### Arguments
|
|
@@ -126,7 +119,7 @@ pnpm build
|
|
|
126
119
|
./dist/bin/ember-codemod-v1-to-v2.js --root <path/to/your/project>
|
|
127
120
|
```
|
|
128
121
|
|
|
129
|
-
|
|
122
|
+
If you'd rather start over, you can use [`create-v2-addon-repo`](https://github.com/ijlee2/create-v2-addon-repo).
|
|
130
123
|
|
|
131
124
|
|
|
132
125
|
## Compatibility
|
|
@@ -138,8 +131,6 @@ You can also look at another codemod called [`ember-addon-migrator`](https://git
|
|
|
138
131
|
|
|
139
132
|
See the [Contributing](CONTRIBUTING.md) guide for details.
|
|
140
133
|
|
|
141
|
-
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. ⭐
|
|
142
|
-
|
|
143
134
|
|
|
144
135
|
## Credits
|
|
145
136
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
generatorOpts: {
|
|
3
|
+
compact: false,
|
|
4
|
+
},
|
|
5
|
+
plugins: [
|
|
6
|
+
<% if (options.packages.addon.hasTypeScript) { %> [
|
|
7
|
+
'@babel/plugin-transform-typescript',
|
|
8
|
+
{
|
|
9
|
+
allExtensions: true,
|
|
10
|
+
allowDeclareFields: true,
|
|
11
|
+
onlyRemoveTypeImports: true,
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
<% } %> '@embroider/addon-dev/template-colocation-plugin',
|
|
15
|
+
[
|
|
16
|
+
'babel-plugin-ember-template-compilation',
|
|
17
|
+
{
|
|
18
|
+
targetFormat: 'hbs',
|
|
19
|
+
transforms: [],
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
[
|
|
23
|
+
'module:decorator-transforms',
|
|
24
|
+
{
|
|
25
|
+
runtime: {
|
|
26
|
+
import: 'decorator-transforms/runtime-esm',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
],
|
|
31
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from '@ijlee2-frontend-configs/prettier';
|
|
1
|
+
export { default } from '@ijlee2-frontend-configs/prettier/ember';
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
+
import { dirname, resolve } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
|
|
1
4
|
import { Addon } from '@embroider/addon-dev/rollup';
|
|
2
5
|
import { babel } from '@rollup/plugin-babel';
|
|
3
|
-
import copy from 'rollup-plugin-copy';
|
|
4
6
|
|
|
5
7
|
const addon = new Addon({
|
|
6
8
|
srcDir: 'src',
|
|
7
9
|
destDir: 'dist',
|
|
8
10
|
});
|
|
9
11
|
|
|
12
|
+
const rootDirectory = dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
const babelConfig = resolve(rootDirectory, './babel.config.cjs');<% if (options.packages.addon.hasTypeScript) { %>
|
|
14
|
+
const tsConfig = resolve(rootDirectory, './tsconfig.json');<% } %>
|
|
15
|
+
|
|
10
16
|
export default {
|
|
11
17
|
// This provides defaults that work well alongside `publicEntrypoints` below.
|
|
12
18
|
// You can augment this if you need to.
|
|
@@ -30,7 +36,6 @@ export default {
|
|
|
30
36
|
'helpers/**/*.js',
|
|
31
37
|
'modifiers/**/*.js',
|
|
32
38
|
'services/**/*.js',
|
|
33
|
-
'utils/**/*.js',
|
|
34
39
|
]),
|
|
35
40
|
|
|
36
41
|
// Follow the V2 Addon rules about dependencies. Your code can import from
|
|
@@ -46,7 +51,8 @@ export default {
|
|
|
46
51
|
// babel.config.json.
|
|
47
52
|
babel({
|
|
48
53
|
babelHelpers: 'bundled',
|
|
49
|
-
|
|
54
|
+
configFile: babelConfig,
|
|
55
|
+
extensions: <% if (options.packages.addon.hasTypeScript) { %>['.gjs', '.gts', '.js', '.ts']<% } else { %>['.gjs', '.js']<% } %>,
|
|
50
56
|
}),
|
|
51
57
|
|
|
52
58
|
// Ensure that standalone .hbs files are properly integrated as Javascript.
|
|
@@ -56,7 +62,10 @@ export default {
|
|
|
56
62
|
addon.gjs(),<% if (options.packages.addon.hasTypeScript) { %>
|
|
57
63
|
|
|
58
64
|
// Emit .d.ts declaration files
|
|
59
|
-
addon.declarations(
|
|
65
|
+
addon.declarations(
|
|
66
|
+
'declarations',
|
|
67
|
+
`pnpm ember-tsc --declaration --project ${tsConfig}`,
|
|
68
|
+
),<% } %>
|
|
60
69
|
|
|
61
70
|
// addons are allowed to contain imports of .css files, which we want rollup
|
|
62
71
|
// to leave alone and keep in the published output.
|
|
@@ -70,13 +79,5 @@ export default {
|
|
|
70
79
|
|
|
71
80
|
// Remove leftover build artifacts when starting a new build.
|
|
72
81
|
addon.clean(),
|
|
73
|
-
|
|
74
|
-
// Copy Readme and License into published package
|
|
75
|
-
copy({
|
|
76
|
-
targets: [
|
|
77
|
-
{ src: '../README.md', dest: '.' },
|
|
78
|
-
{ src: '../LICENSE.md', dest: '.' },
|
|
79
|
-
],
|
|
80
|
-
}),
|
|
81
82
|
],
|
|
82
83
|
};
|
|
@@ -2,21 +2,19 @@
|
|
|
2
2
|
"extends": "@tsconfig/ember/tsconfig.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"allowImportingTsExtensions": true,
|
|
5
|
-
"
|
|
5
|
+
"declaration": true,
|
|
6
6
|
"declarationDir": "declarations",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
"declarationMap": true,
|
|
8
|
+
"emitDeclarationOnly": true,
|
|
9
|
+
"noEmit": false,<% if (options.packages.addon.hasGlint) { %>
|
|
10
|
+
"plugins": [
|
|
11
|
+
{
|
|
12
|
+
"name": "@glint/tsserver-plugin"
|
|
13
|
+
}
|
|
14
|
+
],<% } %>
|
|
15
|
+
"rootDir": "./src",<% if (options.packages.addon.hasGlint) { %>
|
|
16
|
+
"types": ["ember-source/types", "@glint/ember-tsc/types"]<% } else { %>
|
|
17
|
+
"types": ["ember-source/types"]<% } %>
|
|
11
18
|
},
|
|
12
|
-
"include": [
|
|
13
|
-
"src/**/*",
|
|
14
|
-
"unpublished-development-types/**/*"
|
|
15
|
-
]<% if (options.packages.addon.hasGlint) { %>,
|
|
16
|
-
"glint": {
|
|
17
|
-
"environment": [
|
|
18
|
-
"ember-loose",
|
|
19
|
-
"ember-template-imports"
|
|
20
|
-
]
|
|
21
|
-
}<% } %>
|
|
19
|
+
"include": ["src/**/*", "unpublished-development-types/**/*"]
|
|
22
20
|
}
|
package/dist/src/blueprints/ember-addon/__addonLocation__/unpublished-development-types/index.d.ts
CHANGED
|
@@ -1,15 +1,2 @@
|
|
|
1
1
|
// Add any types here that you need for local development only.
|
|
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
|
-
<% if (options.packages.addon.hasGlint) { %>
|
|
4
|
-
import '@glint/environment-ember-loose';
|
|
5
|
-
import '@glint/environment-ember-template-imports';
|
|
6
|
-
|
|
7
|
-
// Uncomment if you need to support consuming projects in loose mode
|
|
8
|
-
//
|
|
9
|
-
// declare module '@glint/environment-ember-loose/registry' {
|
|
10
|
-
// export default interface Registry {
|
|
11
|
-
// // Add any registry entries from other addons here that your addon itself uses (in non-strict mode templates)
|
|
12
|
-
// // See https://typed-ember.gitbook.io/glint/using-glint/ember/using-addons
|
|
13
|
-
// }
|
|
14
|
-
// }
|
|
15
|
-
<% } %>
|
|
@@ -9,4 +9,4 @@ node_modules/
|
|
|
9
9
|
.DS_Store
|
|
10
10
|
.env*
|
|
11
11
|
.eslintcache
|
|
12
|
-
|
|
12
|
+
pnpm-debug.log
|
|
@@ -8,11 +8,13 @@ module.exports = function (defaults) {
|
|
|
8
8
|
const app = new EmberApp(defaults, {
|
|
9
9
|
// Add options here
|
|
10
10
|
autoImport: {
|
|
11
|
-
watchDependencies: [
|
|
12
|
-
}
|
|
11
|
+
watchDependencies: [],
|
|
12
|
+
},
|
|
13
|
+
<% if (options.packages.addon.hasTypeScript) { %>
|
|
13
14
|
'ember-cli-babel': {
|
|
14
15
|
enableTypeScriptTransform: true,
|
|
15
|
-
}
|
|
16
|
+
},
|
|
17
|
+
<% } %>
|
|
16
18
|
trees: {
|
|
17
19
|
app: sideWatch('app', {
|
|
18
20
|
watching: ['<%= options.packages.addon.name %>'],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from '@ijlee2-frontend-configs/prettier';
|
|
1
|
+
export { default } from '@ijlee2-frontend-configs/prettier/ember';
|
|
@@ -6,20 +6,14 @@
|
|
|
6
6
|
"<%= options.packages.testApp.name %>/tests/*": ["tests/*"],
|
|
7
7
|
"<%= options.packages.testApp.name %>/*": ["app/*"],
|
|
8
8
|
"*": ["types/*"]
|
|
9
|
-
}
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
},<% if (options.packages.addon.hasGlint) { %>
|
|
10
|
+
"plugins": [
|
|
11
|
+
{
|
|
12
|
+
"name": "@glint/tsserver-plugin"
|
|
13
|
+
}
|
|
14
|
+
],<% } %><% if (options.packages.addon.hasGlint) { %>
|
|
15
|
+
"types": ["ember-source/types", "@glint/ember-tsc/types"]<% } else { %>
|
|
16
|
+
"types": ["ember-source/types"]<% } %>
|
|
13
17
|
},
|
|
14
|
-
"include": [
|
|
15
|
-
"app/**/*",
|
|
16
|
-
"tests/**/*",
|
|
17
|
-
"types/**/*"
|
|
18
|
-
]<% if (options.packages.addon.hasGlint) { %>,
|
|
19
|
-
"glint": {
|
|
20
|
-
"environment": [
|
|
21
|
-
"ember-loose",
|
|
22
|
-
"ember-template-imports"
|
|
23
|
-
]
|
|
24
|
-
}<% } %>
|
|
18
|
+
"include": ["app/**/*", "tests/**/*", "types/**/*"]
|
|
25
19
|
}
|
|
@@ -1,28 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
"name": "workspace-root",
|
|
3
|
-
"version": "<%= options.packages.addon.version %>",
|
|
4
|
-
"private": true,
|
|
5
|
-
"repository": "",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"author": "",
|
|
8
|
-
"workspaces": [
|
|
9
|
-
"<%= options.locations.addon %>",
|
|
10
|
-
"<%= options.locations.testApp %>"
|
|
11
|
-
],
|
|
12
|
-
"scripts": {
|
|
13
|
-
"build": "npm run build --workspace <%= options.packages.addon.name %>",
|
|
14
|
-
"lint": "npm run lint --workspaces --if-present",
|
|
15
|
-
"lint:fix": "npm run lint:fix --workspaces --if-present",
|
|
16
|
-
"prepare": "npm run build",
|
|
17
|
-
"start": "concurrently \"npm:start:*\" --restart-after 5000 --prefix-colors cyan,white,yellow",
|
|
18
|
-
"start:addon": "npm start --workspace <%= options.packages.addon.name %>",
|
|
19
|
-
"start:test-app": "npm start --workspace <%= options.packages.testApp.name %>",
|
|
20
|
-
"test": "npm run test --workspaces --if-present"
|
|
21
|
-
},
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"concurrently": "<%= context.projectRoot.devDependencies['concurrently'] %>"
|
|
24
|
-
}
|
|
25
|
-
}<% } else if (options.packageManager === 'pnpm') { %>{
|
|
1
|
+
{
|
|
26
2
|
"name": "workspace-root",
|
|
27
3
|
"version": "<%= options.packages.addon.version %>",
|
|
28
4
|
"private": true,
|
|
@@ -31,6 +7,7 @@
|
|
|
31
7
|
"author": "",
|
|
32
8
|
"scripts": {
|
|
33
9
|
"build": "pnpm --filter <%= options.packages.addon.name %> build",
|
|
10
|
+
"format": "pnpm --filter \"*\" format",
|
|
34
11
|
"lint": "pnpm --filter \"*\" lint",
|
|
35
12
|
"lint:fix": "pnpm --filter \"*\" lint:fix",
|
|
36
13
|
"prepare": "pnpm build",
|
|
@@ -41,29 +18,10 @@
|
|
|
41
18
|
},
|
|
42
19
|
"devDependencies": {
|
|
43
20
|
"concurrently": "<%= context.projectRoot.devDependencies['concurrently'] %>"
|
|
44
|
-
}
|
|
45
|
-
}<% } else if (options.packageManager === 'yarn') { %>{
|
|
46
|
-
"name": "workspace-root",
|
|
47
|
-
"version": "<%= options.packages.addon.version %>",
|
|
48
|
-
"private": true,
|
|
49
|
-
"repository": "",
|
|
50
|
-
"license": "MIT",
|
|
51
|
-
"author": "",
|
|
52
|
-
"workspaces": [
|
|
53
|
-
"<%= options.locations.addon %>",
|
|
54
|
-
"<%= options.locations.testApp %>"
|
|
55
|
-
],
|
|
56
|
-
"scripts": {
|
|
57
|
-
"build": "yarn workspace <%= options.packages.addon.name %> run build",
|
|
58
|
-
"lint": "yarn workspaces run lint",
|
|
59
|
-
"lint:fix": "yarn workspaces run lint:fix",
|
|
60
|
-
"prepare": "yarn build",
|
|
61
|
-
"start": "concurrently \"yarn:start:*\" --restart-after 5000 --prefix-colors cyan,white,yellow",
|
|
62
|
-
"start:addon": "yarn workspace <%= options.packages.addon.name %> run start",
|
|
63
|
-
"start:test-app": "yarn workspace <%= options.packages.testApp.name %> run start",
|
|
64
|
-
"test": "yarn workspaces run test"
|
|
65
21
|
},
|
|
66
|
-
"
|
|
67
|
-
|
|
22
|
+
"packageManager": "pnpm@<%= context.projectRoot.devDependencies['pnpm'] %>",
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": "20.* || >= 22",
|
|
25
|
+
"pnpm": ">= 10"
|
|
68
26
|
}
|
|
69
|
-
}
|
|
27
|
+
}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { relative, sep } from 'node:path';
|
|
2
2
|
import { findFiles } from '@codemod-utils/files';
|
|
3
|
-
import {
|
|
4
|
-
function getProjectRootDevDependencies(options) {
|
|
5
|
-
return {
|
|
6
|
-
concurrently: getVersion('concurrently', options),
|
|
7
|
-
};
|
|
8
|
-
}
|
|
3
|
+
import { getLatestVersion } from '../utils/blueprints.js';
|
|
9
4
|
function getPublicAssets(options) {
|
|
10
5
|
const { packages, projectRoot } = options;
|
|
11
6
|
const filePaths = findFiles('public/**/*', {
|
|
@@ -34,7 +29,10 @@ export function analyzeAddon(options) {
|
|
|
34
29
|
publicAssets,
|
|
35
30
|
},
|
|
36
31
|
projectRoot: {
|
|
37
|
-
devDependencies:
|
|
32
|
+
devDependencies: {
|
|
33
|
+
concurrently: getLatestVersion('concurrently'),
|
|
34
|
+
pnpm: getLatestVersion('pnpm').replace('^', ''),
|
|
35
|
+
},
|
|
38
36
|
},
|
|
39
37
|
};
|
|
40
38
|
}
|
|
@@ -4,7 +4,7 @@ import { processTemplate } from '@codemod-utils/blueprints';
|
|
|
4
4
|
import { createFiles, findFiles } from '@codemod-utils/files';
|
|
5
5
|
import { blueprintsRoot } from '../utils/blueprints.js';
|
|
6
6
|
function getFilesToSkip(options) {
|
|
7
|
-
const {
|
|
7
|
+
const { packages } = options;
|
|
8
8
|
const files = new Set();
|
|
9
9
|
if (!packages.addon.hasTypeScript) {
|
|
10
10
|
files.add('__addonLocation__/tsconfig.json');
|
|
@@ -12,9 +12,6 @@ function getFilesToSkip(options) {
|
|
|
12
12
|
files.add('__testAppLocation__/tsconfig.json');
|
|
13
13
|
files.add('__testAppLocation__/types/global.d.ts');
|
|
14
14
|
}
|
|
15
|
-
if (packageManager !== 'pnpm') {
|
|
16
|
-
files.add('pnpm-workspace.yaml');
|
|
17
|
-
}
|
|
18
15
|
return Array.from(files);
|
|
19
16
|
}
|
|
20
17
|
function resolveBlueprintFilePath(blueprintFilePath, options) {
|
|
@@ -22,6 +19,7 @@ function resolveBlueprintFilePath(blueprintFilePath, options) {
|
|
|
22
19
|
return blueprintFilePath
|
|
23
20
|
.replace('__addonLocation__', locations.addon)
|
|
24
21
|
.replace('__gitignore__', '.gitignore')
|
|
22
|
+
.replace('__npmrc__', '.npmrc')
|
|
25
23
|
.replace('__testAppLocation__', locations.testApp);
|
|
26
24
|
}
|
|
27
25
|
export function createFilesFromBlueprints(context, options) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { findFiles } from '@codemod-utils/files';
|
|
2
1
|
import { getPackageType, readPackageJson, validatePackageJson, } from '@codemod-utils/package-json';
|
|
3
2
|
function analyzePackageJson(codemodOptions) {
|
|
4
3
|
const { projectRoot } = codemodOptions;
|
|
@@ -11,31 +10,14 @@ function analyzePackageJson(codemodOptions) {
|
|
|
11
10
|
]);
|
|
12
11
|
return {
|
|
13
12
|
dependencies: projectDependencies,
|
|
14
|
-
hasGlint: projectDependencies.has('@glint/core')
|
|
13
|
+
hasGlint: projectDependencies.has('@glint/core') ||
|
|
14
|
+
projectDependencies.has('@glint/ember-tsc'),
|
|
15
15
|
hasTypeScript: projectDependencies.has('typescript'),
|
|
16
16
|
isV1Addon: getPackageType(packageJson) === 'v1-addon',
|
|
17
17
|
name,
|
|
18
18
|
version,
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
function analyzePackageManager(codemodOptions) {
|
|
22
|
-
const { projectRoot } = codemodOptions;
|
|
23
|
-
const mapping = {
|
|
24
|
-
'package-lock.json': 'npm',
|
|
25
|
-
'pnpm-lock.yaml': 'pnpm',
|
|
26
|
-
'yarn.lock': 'yarn',
|
|
27
|
-
};
|
|
28
|
-
const lockFiles = Object.keys(mapping);
|
|
29
|
-
const filePaths = findFiles(lockFiles, {
|
|
30
|
-
projectRoot,
|
|
31
|
-
});
|
|
32
|
-
if (filePaths.length !== 1) {
|
|
33
|
-
console.warn('WARNING: Package manager is unknown. pnpm will be assumed.');
|
|
34
|
-
return 'pnpm';
|
|
35
|
-
}
|
|
36
|
-
const lockfile = filePaths[0];
|
|
37
|
-
return mapping[lockfile];
|
|
38
|
-
}
|
|
39
21
|
function deriveAddonLocation(addonPackage) {
|
|
40
22
|
const hasScope = addonPackage.name.includes('/');
|
|
41
23
|
if (!hasScope) {
|
|
@@ -46,13 +28,11 @@ function deriveAddonLocation(addonPackage) {
|
|
|
46
28
|
}
|
|
47
29
|
export function createOptions(codemodOptions) {
|
|
48
30
|
const addonPackage = analyzePackageJson(codemodOptions);
|
|
49
|
-
const packageManager = analyzePackageManager(codemodOptions);
|
|
50
31
|
return {
|
|
51
32
|
locations: {
|
|
52
33
|
addon: codemodOptions.addonLocation ?? deriveAddonLocation(addonPackage),
|
|
53
34
|
testApp: codemodOptions.testAppLocation ?? 'test-app',
|
|
54
35
|
},
|
|
55
|
-
packageManager,
|
|
56
36
|
packages: {
|
|
57
37
|
addon: addonPackage,
|
|
58
38
|
testApp: {
|
|
@@ -17,7 +17,7 @@ function moveAddonTestSupportFolder(options) {
|
|
|
17
17
|
});
|
|
18
18
|
if (filePaths.length === 1) {
|
|
19
19
|
const oldPath = filePaths[0];
|
|
20
|
-
const newPath = `${locations.addon}/src/test-support${oldPath.endsWith('.ts') ? '.ts' : 'js'}`;
|
|
20
|
+
const newPath = `${locations.addon}/src/test-support${oldPath.endsWith('.ts') ? '.ts' : '.js'}`;
|
|
21
21
|
moveFiles(new Map([[oldPath, newPath]]), options);
|
|
22
22
|
}
|
|
23
23
|
filePaths = findFiles('addon-test-support/**/*', {
|
|
@@ -9,7 +9,8 @@ export function updateDevDependencies(packageJson, options) {
|
|
|
9
9
|
'@babel/core',
|
|
10
10
|
'@babel/runtime',
|
|
11
11
|
'@embroider/addon-dev',
|
|
12
|
-
'@
|
|
12
|
+
'@glimmer/component',
|
|
13
|
+
'@glimmer/tracking',
|
|
13
14
|
'@ijlee2-frontend-configs/ember-template-lint',
|
|
14
15
|
'@ijlee2-frontend-configs/eslint-config-ember',
|
|
15
16
|
'@ijlee2-frontend-configs/prettier',
|
|
@@ -17,24 +18,23 @@ export function updateDevDependencies(packageJson, options) {
|
|
|
17
18
|
'@rollup/plugin-babel',
|
|
18
19
|
'babel-plugin-ember-template-compilation',
|
|
19
20
|
'concurrently',
|
|
21
|
+
'ember-modifier',
|
|
22
|
+
'ember-source',
|
|
20
23
|
'ember-template-lint',
|
|
21
24
|
'eslint',
|
|
22
25
|
'prettier',
|
|
23
26
|
'stylelint',
|
|
24
27
|
'rollup',
|
|
25
|
-
'rollup-plugin-copy',
|
|
26
28
|
]);
|
|
27
29
|
if (packages.addon.hasTypeScript) {
|
|
28
30
|
packagesToInstall.add('@babel/plugin-transform-typescript');
|
|
29
31
|
packagesToInstall.add('@tsconfig/ember');
|
|
30
|
-
packagesToInstall.add('ember-source');
|
|
31
32
|
packagesToInstall.add('typescript');
|
|
32
33
|
}
|
|
33
34
|
if (packages.addon.hasGlint) {
|
|
34
|
-
packagesToInstall.add('@glint/
|
|
35
|
-
packagesToInstall.add('@glint/environment-ember-loose');
|
|
36
|
-
packagesToInstall.add('@glint/environment-ember-template-imports');
|
|
35
|
+
packagesToInstall.add('@glint/ember-tsc');
|
|
37
36
|
packagesToInstall.add('@glint/template');
|
|
37
|
+
packagesToInstall.add('@glint/tsserver-plugin');
|
|
38
38
|
}
|
|
39
39
|
packagesToInstall.forEach((packageName) => {
|
|
40
40
|
const version = getLatestVersion(packageName);
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
/* eslint-disable no-useless-escape */
|
|
2
2
|
import { convertToMap, convertToObject } from '@codemod-utils/package-json';
|
|
3
3
|
export function updateScripts(packageJson, options) {
|
|
4
|
-
const {
|
|
4
|
+
const { packages } = options;
|
|
5
5
|
const scripts = convertToMap(packageJson['scripts']);
|
|
6
6
|
// Start over
|
|
7
7
|
scripts.clear();
|
|
8
8
|
scripts.set('build', 'rollup --config');
|
|
9
|
-
scripts.set('
|
|
9
|
+
scripts.set('format', 'prettier . --cache --write');
|
|
10
|
+
scripts.set('lint', `concurrently \"pnpm:lint:*(!fix)\" --names \"lint:\"`);
|
|
10
11
|
scripts.set('lint:css', 'stylelint \"**/*.css\" --allow-empty-input --cache"');
|
|
11
12
|
scripts.set('lint:css:fix', 'stylelint \"**/*.css\" --allow-empty-input --fix');
|
|
12
|
-
scripts.set('lint:fix', `concurrently \"
|
|
13
|
+
scripts.set('lint:fix', `concurrently \"pnpm:lint:*:fix\" --names \"fix:\" && pnpm format`);
|
|
14
|
+
scripts.set('lint:format', 'prettier . --cache --check');
|
|
13
15
|
scripts.set('lint:hbs', 'ember-template-lint .');
|
|
14
16
|
scripts.set('lint:hbs:fix', 'ember-template-lint . --fix');
|
|
15
17
|
scripts.set('lint:js', 'eslint . --cache');
|
|
@@ -19,7 +21,7 @@ export function updateScripts(packageJson, options) {
|
|
|
19
21
|
scripts.set('test', `echo \"A v2 addon does not have tests, run tests in ${packages.testApp.name}\"`);
|
|
20
22
|
if (packages.addon.hasTypeScript) {
|
|
21
23
|
if (packages.addon.hasGlint) {
|
|
22
|
-
scripts.set('lint:types', '
|
|
24
|
+
scripts.set('lint:types', 'ember-tsc --noEmit');
|
|
23
25
|
}
|
|
24
26
|
else {
|
|
25
27
|
scripts.set('lint:types', 'tsc --emitDeclarationOnly false --noEmit');
|
package/dist/src/steps/update-test-app-package-json/move-dev-dependencies-to-dependencies.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { convertToMap, convertToObject } from '@codemod-utils/package-json';
|
|
2
2
|
import { getVersion } from '../../utils/blueprints.js';
|
|
3
3
|
export function moveDependenciesToDevDependencies(packageJson, options) {
|
|
4
|
-
const { packages } = options;
|
|
5
4
|
const dependencies = convertToMap(packageJson['dependencies']);
|
|
6
5
|
const devDependencies = convertToMap(packageJson['devDependencies']);
|
|
7
6
|
const packagesToMove = new Set([
|
|
@@ -9,9 +8,6 @@ export function moveDependenciesToDevDependencies(packageJson, options) {
|
|
|
9
8
|
'ember-cli-babel',
|
|
10
9
|
'ember-cli-htmlbars',
|
|
11
10
|
]);
|
|
12
|
-
if (packages.addon.hasTypeScript) {
|
|
13
|
-
packagesToMove.add('ember-cli-typescript');
|
|
14
|
-
}
|
|
15
11
|
packagesToMove.forEach((packageName) => {
|
|
16
12
|
if (!dependencies.has(packageName)) {
|
|
17
13
|
return;
|
|
@@ -3,9 +3,17 @@ import { getLatestVersion } from '../../utils/blueprints.js';
|
|
|
3
3
|
export function updateDevDependencies(packageJson, options) {
|
|
4
4
|
const { packages } = options;
|
|
5
5
|
const devDependencies = convertToMap(packageJson['devDependencies']);
|
|
6
|
+
const packagesToDelete = new Set([
|
|
7
|
+
'@glint/core',
|
|
8
|
+
'@glint/environment-ember-loose',
|
|
9
|
+
'@glint/environment-ember-template-imports',
|
|
10
|
+
'ember-cli-typescript',
|
|
11
|
+
]);
|
|
12
|
+
packagesToDelete.forEach((packageName) => {
|
|
13
|
+
devDependencies.delete(packageName);
|
|
14
|
+
});
|
|
6
15
|
const packagesToInstall = new Set([
|
|
7
16
|
'@embroider/broccoli-side-watch',
|
|
8
|
-
'@eslint/js',
|
|
9
17
|
'@ijlee2-frontend-configs/ember-template-lint',
|
|
10
18
|
'@ijlee2-frontend-configs/eslint-config-ember',
|
|
11
19
|
'@ijlee2-frontend-configs/prettier',
|
|
@@ -24,10 +32,9 @@ export function updateDevDependencies(packageJson, options) {
|
|
|
24
32
|
packagesToInstall.add('typescript');
|
|
25
33
|
}
|
|
26
34
|
if (packages.addon.hasGlint) {
|
|
27
|
-
packagesToInstall.add('@glint/
|
|
28
|
-
packagesToInstall.add('@glint/environment-ember-loose');
|
|
29
|
-
packagesToInstall.add('@glint/environment-ember-template-imports');
|
|
35
|
+
packagesToInstall.add('@glint/ember-tsc');
|
|
30
36
|
packagesToInstall.add('@glint/template');
|
|
37
|
+
packagesToInstall.add('@glint/tsserver-plugin');
|
|
31
38
|
}
|
|
32
39
|
packagesToInstall.forEach((packageName) => {
|
|
33
40
|
const version = getLatestVersion(packageName);
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
/* eslint-disable no-useless-escape */
|
|
2
2
|
import { convertToMap, convertToObject } from '@codemod-utils/package-json';
|
|
3
3
|
export function updateScripts(packageJson, options) {
|
|
4
|
-
const {
|
|
4
|
+
const { packages } = options;
|
|
5
5
|
const scripts = convertToMap(packageJson['scripts']);
|
|
6
6
|
// Start over
|
|
7
7
|
scripts.clear();
|
|
8
8
|
scripts.set('build', 'ember build --environment=production');
|
|
9
|
-
scripts.set('
|
|
10
|
-
scripts.set('lint
|
|
9
|
+
scripts.set('format', 'prettier . --cache --write');
|
|
10
|
+
scripts.set('lint', `concurrently \"pnpm:lint:*(!fix)\" --names \"lint:\"`);
|
|
11
11
|
scripts.set('lint:css', 'stylelint \"**/*.css\" --allow-empty-input --cache"');
|
|
12
12
|
scripts.set('lint:css:fix', 'stylelint \"**/*.css\" --allow-empty-input --fix');
|
|
13
|
+
scripts.set('lint:fix', `concurrently \"pnpm:lint:*:fix\" --names \"fix:\" && pnpm format`);
|
|
14
|
+
scripts.set('lint:format', 'prettier . --cache --check');
|
|
13
15
|
scripts.set('lint:hbs', 'ember-template-lint .');
|
|
14
16
|
scripts.set('lint:hbs:fix', 'ember-template-lint . --fix');
|
|
15
17
|
scripts.set('lint:js', 'eslint . --cache');
|
|
@@ -19,7 +21,7 @@ export function updateScripts(packageJson, options) {
|
|
|
19
21
|
scripts.set('test:ember-compatibility', 'ember try:one');
|
|
20
22
|
if (packages.addon.hasTypeScript) {
|
|
21
23
|
if (packages.addon.hasGlint) {
|
|
22
|
-
scripts.set('lint:types', '
|
|
24
|
+
scripts.set('lint:types', 'ember-tsc --noEmit');
|
|
23
25
|
}
|
|
24
26
|
else {
|
|
25
27
|
scripts.set('lint:types', 'tsc --noEmit');
|
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
import { decideVersion } from '@codemod-utils/blueprints';
|
|
2
2
|
const latestVersions = new Map([
|
|
3
|
-
['@babel/core', '7.
|
|
4
|
-
['@babel/plugin-transform-typescript', '7.
|
|
5
|
-
['@babel/runtime', '7.
|
|
6
|
-
['@embroider/addon-dev', '8.
|
|
7
|
-
['@embroider/addon-shim', '1.10.
|
|
3
|
+
['@babel/core', '7.28.5'],
|
|
4
|
+
['@babel/plugin-transform-typescript', '7.28.5'],
|
|
5
|
+
['@babel/runtime', '7.28.4'],
|
|
6
|
+
['@embroider/addon-dev', '8.1.2'],
|
|
7
|
+
['@embroider/addon-shim', '1.10.2'],
|
|
8
8
|
['@embroider/broccoli-side-watch', '1.1.0'],
|
|
9
9
|
['@embroider/test-setup', '4.0.0'],
|
|
10
|
-
['@
|
|
11
|
-
['@
|
|
12
|
-
['@glint/
|
|
13
|
-
['@glint/
|
|
14
|
-
['@glint/
|
|
15
|
-
['@ijlee2-frontend-configs/ember-template-lint', '
|
|
16
|
-
['@ijlee2-frontend-configs/eslint-config-ember', '
|
|
17
|
-
['@ijlee2-frontend-configs/prettier', '
|
|
18
|
-
['@ijlee2-frontend-configs/stylelint', '
|
|
19
|
-
['@rollup/plugin-babel', '6.0
|
|
20
|
-
['@tsconfig/ember', '3.0.
|
|
21
|
-
['babel-plugin-ember-template-compilation', '
|
|
22
|
-
['concurrently', '9.1
|
|
10
|
+
['@glimmer/component', '2.0.0'],
|
|
11
|
+
['@glimmer/tracking', '1.1.2'],
|
|
12
|
+
['@glint/ember-tsc', '1.0.8'],
|
|
13
|
+
['@glint/template', '1.7.3'],
|
|
14
|
+
['@glint/tsserver-plugin', '2.0.8'],
|
|
15
|
+
['@ijlee2-frontend-configs/ember-template-lint', '2.3.0'],
|
|
16
|
+
['@ijlee2-frontend-configs/eslint-config-ember', '2.4.2'],
|
|
17
|
+
['@ijlee2-frontend-configs/prettier', '2.3.1'],
|
|
18
|
+
['@ijlee2-frontend-configs/stylelint', '2.2.0'],
|
|
19
|
+
['@rollup/plugin-babel', '6.1.0'],
|
|
20
|
+
['@tsconfig/ember', '3.0.12'],
|
|
21
|
+
['babel-plugin-ember-template-compilation', '3.0.1'],
|
|
22
|
+
['concurrently', '9.2.1'],
|
|
23
23
|
['decorator-transforms', '2.3.0'],
|
|
24
|
-
['ember-auto-import', '2.
|
|
25
|
-
['ember-cli', '6.
|
|
24
|
+
['ember-auto-import', '2.12.0'],
|
|
25
|
+
['ember-cli', '6.8.1'],
|
|
26
26
|
['ember-cli-babel', '8.2.0'],
|
|
27
|
-
['ember-cli-htmlbars', '
|
|
28
|
-
['ember-
|
|
29
|
-
['ember-
|
|
27
|
+
['ember-cli-htmlbars', '7.0.0'],
|
|
28
|
+
['ember-modifier', '4.2.2'],
|
|
29
|
+
['ember-source', '6.8.2'],
|
|
30
|
+
['ember-template-imports', '4.3.0'],
|
|
31
|
+
['ember-template-lint', '7.9.3'],
|
|
30
32
|
['ember-try', '4.0.0'],
|
|
31
|
-
['eslint', '9.
|
|
32
|
-
['
|
|
33
|
-
['
|
|
34
|
-
['rollup
|
|
35
|
-
['stylelint', '16.
|
|
36
|
-
['typescript', '5.
|
|
33
|
+
['eslint', '9.39.1'],
|
|
34
|
+
['pnpm', '10.25.0'],
|
|
35
|
+
['prettier', '3.7.4'],
|
|
36
|
+
['rollup', '4.53.3'],
|
|
37
|
+
['stylelint', '16.26.1'],
|
|
38
|
+
['typescript', '5.9.3'],
|
|
37
39
|
]);
|
|
38
40
|
export function getLatestVersion(packageName) {
|
|
39
41
|
if (!latestVersions.has(packageName)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-codemod-v1-to-v2",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Codemod to convert Ember addons to v2 addon format",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codemod",
|
|
@@ -29,19 +29,19 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@codemod-utils/blueprints": "^2.1.0",
|
|
31
31
|
"@codemod-utils/files": "^3.2.1",
|
|
32
|
-
"@codemod-utils/package-json": "^3.3.
|
|
32
|
+
"@codemod-utils/package-json": "^3.3.1",
|
|
33
33
|
"yargs": "^18.0.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@changesets/cli": "^2.29.8",
|
|
37
|
-
"@changesets/get-github-info": "^0.7.0",
|
|
38
37
|
"@codemod-utils/tests": "^2.2.0",
|
|
39
|
-
"@ijlee2-frontend-configs/
|
|
40
|
-
"@ijlee2-frontend-configs/
|
|
38
|
+
"@ijlee2-frontend-configs/changesets": "^1.0.0",
|
|
39
|
+
"@ijlee2-frontend-configs/eslint-config-node": "^2.3.1",
|
|
40
|
+
"@ijlee2-frontend-configs/prettier": "^2.3.1",
|
|
41
41
|
"@sondr3/minitest": "^0.1.2",
|
|
42
42
|
"@tsconfig/node20": "^20.1.8",
|
|
43
43
|
"@tsconfig/strictest": "^2.0.8",
|
|
44
|
-
"@types/node": "^20.19.
|
|
44
|
+
"@types/node": "^20.19.26",
|
|
45
45
|
"@types/yargs": "^17.0.35",
|
|
46
46
|
"concurrently": "^9.2.1",
|
|
47
47
|
"eslint": "^9.39.1",
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"plugins": [
|
|
3
|
-
<% if (options.packages.addon.hasTypeScript) { %> [
|
|
4
|
-
"@babel/plugin-transform-typescript",
|
|
5
|
-
{
|
|
6
|
-
"allExtensions": true,
|
|
7
|
-
"allowDeclareFields": true,
|
|
8
|
-
"onlyRemoveTypeImports": true
|
|
9
|
-
}
|
|
10
|
-
],
|
|
11
|
-
<% } %> "@embroider/addon-dev/template-colocation-plugin",
|
|
12
|
-
[
|
|
13
|
-
"babel-plugin-ember-template-compilation",
|
|
14
|
-
{
|
|
15
|
-
"targetFormat": "hbs",
|
|
16
|
-
"transforms": []
|
|
17
|
-
}
|
|
18
|
-
],
|
|
19
|
-
[
|
|
20
|
-
"module:decorator-transforms",
|
|
21
|
-
{
|
|
22
|
-
"runtime": {
|
|
23
|
-
"import": "decorator-transforms/runtime"
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
]
|
|
28
|
-
}
|