ember-codemod-v1-to-v2 1.5.0 → 1.7.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/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2024 Isaac J. Lee
3
+ Copyright (c) 2025 Isaac J. Lee
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
@@ -30,6 +30,7 @@ export default {
30
30
  'helpers/**/*.js',
31
31
  'modifiers/**/*.js',
32
32
  'services/**/*.js',
33
+ 'utils/**/*.js',
33
34
  ]),
34
35
 
35
36
  // Follow the V2 Addon rules about dependencies. Your code can import from
@@ -52,7 +53,10 @@ export default {
52
53
  addon.hbs(),
53
54
 
54
55
  // Ensure that .gjs files are properly integrated as Javascript
55
- addon.gjs(),
56
+ addon.gjs(),<% if (options.packages.addon.hasTypeScript) { %>
57
+
58
+ // Emit .d.ts declaration files
59
+ addon.declarations('declarations'),<% } %>
56
60
 
57
61
  // addons are allowed to contain imports of .css files, which we want rollup
58
62
  // to leave alone and keep in the published output.
@@ -7,7 +7,10 @@
7
7
  "emitDeclarationOnly": true,
8
8
  "noEmit": false,
9
9
  "noEmitOnError": false,
10
- "rootDir": "./src"
10
+ "rootDir": "./src",
11
+ "types": [
12
+ "ember-source/types"
13
+ ]
11
14
  },
12
15
  "include": [
13
16
  "src/**/*",
@@ -15,7 +18,8 @@
15
18
  ]<% if (options.packages.addon.hasGlint) { %>,
16
19
  "glint": {
17
20
  "environment": [
18
- "ember-loose"
21
+ "ember-loose",
22
+ "ember-template-imports"
19
23
  ]
20
24
  }<% } %>
21
25
  }
@@ -2,13 +2,14 @@
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
- declare module '@glint/environment-ember-loose/registry' {
7
- // Remove this once entries have been added! 👇
8
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
9
- export default interface Registry {
10
- // Add any registry entries from other addons here that your addon itself uses (in non-strict mode templates)
11
- // See https://typed-ember.gitbook.io/glint/using-glint/ember/using-addons
12
- }
13
- }
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
+ // }
14
15
  <% } %>
@@ -1,7 +1,3 @@
1
- // Types for compiled templates
2
- declare module '<%= options.packages.testApp.name %>/templates/*' {
3
- import { TemplateFactory } from 'ember-cli-htmlbars';
4
-
5
- const tmpl: TemplateFactory;
6
- export default tmpl;
7
- }
1
+ <% if (options.packages.addon.hasGlint) { %>import '@glint/environment-ember-loose';
2
+ import '@glint/environment-ember-template-imports';
3
+ <% } %>
@@ -14,7 +14,7 @@
14
14
  "lint": "npm run lint --workspaces --if-present",
15
15
  "lint:fix": "npm run lint:fix --workspaces --if-present",
16
16
  "prepare": "npm run build",
17
- "start": "concurrently 'npm:start:*' --restart-after 5000 --prefix-colors cyan,white,yellow",
17
+ "start": "concurrently \"npm:start:*\" --restart-after 5000 --prefix-colors cyan,white,yellow",
18
18
  "start:addon": "npm start --workspace <%= options.packages.addon.name %>",
19
19
  "start:test-app": "npm start --workspace <%= options.packages.testApp.name %>",
20
20
  "test": "npm run test --workspaces --if-present"
@@ -31,13 +31,13 @@
31
31
  "author": "",
32
32
  "scripts": {
33
33
  "build": "pnpm --filter <%= options.packages.addon.name %> build",
34
- "lint": "pnpm --filter '*' lint",
35
- "lint:fix": "pnpm --filter '*' lint:fix",
34
+ "lint": "pnpm --filter \"*\" lint",
35
+ "lint:fix": "pnpm --filter \"*\" lint:fix",
36
36
  "prepare": "pnpm build",
37
- "start": "concurrently 'pnpm:start:*' --restart-after 5000 --prefix-colors cyan,white,yellow",
37
+ "start": "concurrently \"pnpm:start:*\" --restart-after 5000 --prefix-colors cyan,white,yellow",
38
38
  "start:addon": "pnpm --filter <%= options.packages.addon.name %> start",
39
39
  "start:test-app": "pnpm --filter <%= options.packages.testApp.name %> start",
40
- "test": "pnpm --filter '*' test"
40
+ "test": "pnpm --filter \"*\" test"
41
41
  },
42
42
  "devDependencies": {
43
43
  "concurrently": "<%= context.projectRoot.devDependencies['concurrently'] %>"
@@ -58,7 +58,7 @@
58
58
  "lint": "yarn workspaces run lint",
59
59
  "lint:fix": "yarn workspaces run lint:fix",
60
60
  "prepare": "yarn build",
61
- "start": "concurrently 'yarn:start:*' --restart-after 5000 --prefix-colors cyan,white,yellow",
61
+ "start": "concurrently \"yarn:start:*\" --restart-after 5000 --prefix-colors cyan,white,yellow",
62
62
  "start:addon": "yarn workspace <%= options.packages.addon.name %> run start",
63
63
  "start:test-app": "yarn workspace <%= options.packages.testApp.name %> run start",
64
64
  "test": "yarn workspaces run test"
@@ -30,8 +30,8 @@ function analyzePackageManager(codemodOptions) {
30
30
  projectRoot,
31
31
  });
32
32
  if (filePaths.length !== 1) {
33
- console.warn('WARNING: Package manager is unknown. Yarn will be assumed.');
34
- return 'yarn';
33
+ console.warn('WARNING: Package manager is unknown. pnpm will be assumed.');
34
+ return 'pnpm';
35
35
  }
36
36
  const lockfile = filePaths[0];
37
37
  return mapping[lockfile];
@@ -31,9 +31,6 @@ export function updateDevDependencies(packageJson, options) {
31
31
  packagesToInstall.delete('@babel/eslint-parser');
32
32
  packagesToInstall.add('@babel/plugin-transform-typescript');
33
33
  packagesToInstall.add('@tsconfig/ember');
34
- packagesToInstall.add('@types/ember__component');
35
- packagesToInstall.add('@types/ember__object');
36
- packagesToInstall.add('@types/ember__service');
37
34
  packagesToInstall.add('@typescript-eslint/eslint-plugin');
38
35
  packagesToInstall.add('@typescript-eslint/parser');
39
36
  packagesToInstall.add('typescript');
@@ -41,7 +38,9 @@ export function updateDevDependencies(packageJson, options) {
41
38
  if (packages.addon.hasGlint) {
42
39
  packagesToInstall.add('@glint/core');
43
40
  packagesToInstall.add('@glint/environment-ember-loose');
41
+ packagesToInstall.add('@glint/environment-ember-template-imports');
44
42
  packagesToInstall.add('@glint/template');
43
+ packagesToInstall.add('ember-source');
45
44
  }
46
45
  Array.from(packagesToInstall).forEach((packageName) => {
47
46
  const version = getLatestVersion(packageName);
@@ -7,35 +7,30 @@ export function updateScripts(packageJson, options) {
7
7
  must add scripts that their v1 addon needed.
8
8
  */
9
9
  scripts.clear();
10
- scripts.set('lint', `concurrently '${packageManager}:lint:*(!fix)' --names 'lint:'`);
11
- scripts.set('lint:fix', `concurrently '${packageManager}:lint:*:fix' --names 'fix:'`);
10
+ scripts.set('build', 'rollup --config');
11
+ scripts.set('lint',
12
+ // eslint-disable-next-line no-useless-escape
13
+ `concurrently \"${packageManager}:lint:*(!fix)\" --names \"lint:\"`);
14
+ scripts.set('lint:fix',
15
+ // eslint-disable-next-line no-useless-escape
16
+ `concurrently \"${packageManager}:lint:*:fix\" --names \"fix:\"`);
12
17
  scripts.set('lint:hbs', 'ember-template-lint . --no-error-on-unmatched-pattern');
13
18
  scripts.set('lint:hbs:fix', 'ember-template-lint . --fix --no-error-on-unmatched-pattern');
14
19
  scripts.set('lint:js', 'eslint . --cache');
15
20
  scripts.set('lint:js:fix', 'eslint . --fix');
16
- scripts.set('test', `echo 'A v2 addon does not have tests, run tests in ${locations.testApp}'`);
21
+ scripts.set('prepack', 'rollup --config');
22
+ scripts.set('start', 'rollup --config --watch');
23
+ scripts.set('test',
24
+ // eslint-disable-next-line no-useless-escape
25
+ `echo \"A v2 addon does not have tests, run tests in ${locations.testApp}\"`);
17
26
  if (packages.addon.hasTypeScript) {
18
- scripts.set('build', `concurrently '${packageManager}:build:*'`);
19
- scripts.set('build:js', 'rollup --config');
20
27
  scripts.delete('postpack');
21
- scripts.set('prepack', `concurrently '${packageManager}:build:*'`);
22
- scripts.set('start', `concurrently '${packageManager}:start:*'`);
23
- scripts.set('start:js', 'rollup --config --watch --no-watch.clearScreen');
24
28
  if (packages.addon.hasGlint) {
25
- scripts.set('build:types', 'glint --declaration');
26
29
  scripts.set('lint:types', 'glint');
27
- scripts.set('start:types', 'glint --declaration --watch');
28
30
  }
29
31
  else {
30
- scripts.set('build:types', 'tsc');
31
32
  scripts.set('lint:types', 'tsc --emitDeclarationOnly false --noEmit');
32
- scripts.set('start:types', 'tsc --watch');
33
33
  }
34
34
  }
35
- else {
36
- scripts.set('build', 'rollup --config');
37
- scripts.set('prepack', 'rollup --config');
38
- scripts.set('start', 'rollup --config --watch');
39
- }
40
35
  packageJson['scripts'] = convertToObject(scripts);
41
36
  }
@@ -1,39 +1,38 @@
1
1
  import { decideVersion } from '@codemod-utils/blueprints';
2
2
  const latestVersions = new Map([
3
- ['@babel/core', '7.25.2'],
4
- ['@babel/eslint-parser', '7.25.1'],
5
- ['@babel/plugin-transform-typescript', '7.25.2'],
6
- ['@babel/runtime', '7.25.0'],
7
- ['@embroider/addon-dev', '5.0.0'],
8
- ['@embroider/addon-shim', '1.8.9'],
3
+ ['@babel/core', '7.26.0'],
4
+ ['@babel/eslint-parser', '7.26.5'],
5
+ ['@babel/plugin-transform-typescript', '7.26.5'],
6
+ ['@babel/runtime', '7.26.0'],
7
+ ['@embroider/addon-dev', '7.1.1'],
8
+ ['@embroider/addon-shim', '1.9.0'],
9
9
  ['@embroider/test-setup', '4.0.0'],
10
- ['@glint/core', '1.4.0'],
11
- ['@glint/environment-ember-loose', '1.4.0'],
12
- ['@glint/template', '1.4.0'],
10
+ ['@glint/core', '1.5.1'],
11
+ ['@glint/environment-ember-loose', '1.5.1'],
12
+ ['@glint/environment-ember-template-imports', '1.5.1'],
13
+ ['@glint/template', '1.5.1'],
13
14
  ['@rollup/plugin-babel', '6.0.4'],
14
15
  ['@tsconfig/ember', '3.0.8'],
15
- ['@types/ember__component', '4.0.22'],
16
- ['@types/ember__object', '4.0.12'],
17
- ['@types/ember__service', '4.0.9'],
18
- ['@typescript-eslint/eslint-plugin', '8.1.0'],
19
- ['@typescript-eslint/parser', '8.1.0'],
20
- ['babel-plugin-ember-template-compilation', '2.2.5'],
21
- ['concurrently', '8.2.2'],
22
- ['decorator-transforms', '2.0.0'],
23
- ['ember-auto-import', '2.7.4'],
24
- ['ember-cli-babel', '8.1.0'],
16
+ ['@typescript-eslint/eslint-plugin', '8.20.0'],
17
+ ['@typescript-eslint/parser', '8.20.0'],
18
+ ['babel-plugin-ember-template-compilation', '2.3.0'],
19
+ ['concurrently', '9.1.2'],
20
+ ['decorator-transforms', '2.3.0'],
21
+ ['ember-auto-import', '2.10.0'],
22
+ ['ember-cli-babel', '8.2.0'],
25
23
  ['ember-cli-htmlbars', '6.3.0'],
24
+ ['ember-source', '6.1.0'],
26
25
  ['ember-template-lint', '6.0.0'],
27
- ['eslint', '8.57.0'],
28
- ['eslint-config-prettier', '9.1.0'],
29
- ['eslint-plugin-ember', '12.1.1'],
30
- ['eslint-plugin-import', '2.29.1'],
31
- ['eslint-plugin-n', '17.10.2'],
32
- ['eslint-plugin-prettier', '5.2.1'],
33
- ['prettier', '3.3.3'],
34
- ['rollup', '4.20.0'],
26
+ ['eslint', '8.57.1'],
27
+ ['eslint-config-prettier', '10.0.1'],
28
+ ['eslint-plugin-ember', '12.3.3'],
29
+ ['eslint-plugin-import', '2.31.0'],
30
+ ['eslint-plugin-n', '17.15.1'],
31
+ ['eslint-plugin-prettier', '5.2.2'],
32
+ ['prettier', '3.4.2'],
33
+ ['rollup', '4.30.1'],
35
34
  ['rollup-plugin-copy', '3.5.0'],
36
- ['typescript', '5.5.4'],
35
+ ['typescript', '5.7.3'],
37
36
  ]);
38
37
  export function getLatestVersion(packageName) {
39
38
  if (!latestVersions.has(packageName)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-codemod-v1-to-v2",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "Codemod to convert Ember addons to v2 addon format",
5
5
  "keywords": [
6
6
  "codemod",
@@ -27,34 +27,34 @@
27
27
  "dist"
28
28
  ],
29
29
  "dependencies": {
30
- "@codemod-utils/blueprints": "^1.1.5",
31
- "@codemod-utils/files": "^2.0.4",
32
- "@codemod-utils/json": "^1.1.9",
30
+ "@codemod-utils/blueprints": "^1.1.6",
31
+ "@codemod-utils/files": "^2.0.5",
32
+ "@codemod-utils/json": "^1.1.10",
33
33
  "strip-json-comments": "^5.0.1",
34
34
  "yargs": "^17.7.2"
35
35
  },
36
36
  "devDependencies": {
37
- "@babel/core": "^7.25.2",
38
- "@codemod-utils/tests": "^1.1.7",
37
+ "@babel/core": "^7.26.0",
38
+ "@codemod-utils/tests": "^1.1.8",
39
39
  "@sondr3/minitest": "^0.1.2",
40
40
  "@tsconfig/node18": "^18.2.4",
41
41
  "@tsconfig/strictest": "^2.0.5",
42
- "@types/node": "^18.19.47",
42
+ "@types/node": "^18.19.70",
43
43
  "@types/yargs": "^17.0.33",
44
- "@typescript-eslint/eslint-plugin": "^8.3.0",
45
- "@typescript-eslint/parser": "^8.3.0",
46
- "concurrently": "^8.2.2",
47
- "eslint": "^8.57.0",
48
- "eslint-config-prettier": "^9.1.0",
49
- "eslint-import-resolver-typescript": "^3.6.3",
50
- "eslint-plugin-import": "^2.29.1",
51
- "eslint-plugin-n": "^17.10.2",
52
- "eslint-plugin-prettier": "^5.2.1",
44
+ "@typescript-eslint/eslint-plugin": "^8.20.0",
45
+ "@typescript-eslint/parser": "^8.20.0",
46
+ "concurrently": "^9.1.2",
47
+ "eslint": "^8.57.1",
48
+ "eslint-config-prettier": "^10.0.1",
49
+ "eslint-import-resolver-typescript": "^3.7.0",
50
+ "eslint-plugin-import": "^2.31.0",
51
+ "eslint-plugin-n": "^17.15.1",
52
+ "eslint-plugin-prettier": "^5.2.2",
53
53
  "eslint-plugin-simple-import-sort": "^12.1.1",
54
- "eslint-plugin-typescript-sort-keys": "^3.2.0",
54
+ "eslint-plugin-typescript-sort-keys": "^3.3.0",
55
55
  "lerna-changelog": "^2.2.0",
56
- "prettier": "^3.3.3",
57
- "typescript": "^5.5.4"
56
+ "prettier": "^3.4.2",
57
+ "typescript": "^5.7.3"
58
58
  },
59
59
  "engines": {
60
60
  "node": "18.* || >= 20"