ember-codemod-v1-to-v2 1.7.0 → 2.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.
Files changed (40) hide show
  1. package/README.md +8 -8
  2. package/dist/src/blueprints/ember-addon/__addonLocation__/.prettierignore +1 -7
  3. package/dist/src/blueprints/ember-addon/__addonLocation__/.stylelintignore +3 -0
  4. package/dist/src/blueprints/ember-addon/__addonLocation__/.stylelintrc.mjs +1 -0
  5. package/dist/src/blueprints/ember-addon/__addonLocation__/.template-lintrc.cjs +1 -3
  6. package/dist/src/blueprints/ember-addon/__addonLocation__/__gitignore__ +9 -13
  7. package/dist/src/blueprints/ember-addon/__addonLocation__/eslint.config.mjs +1 -0
  8. package/dist/src/blueprints/ember-addon/__addonLocation__/prettier.config.mjs +1 -0
  9. package/dist/src/blueprints/ember-addon/__addonLocation__/rollup.config.mjs +7 -1
  10. package/dist/src/blueprints/ember-addon/__addonLocation__/tsconfig.json +1 -4
  11. package/dist/src/blueprints/ember-addon/__gitignore__ +6 -4
  12. package/dist/src/blueprints/ember-addon/__testAppLocation__/.prettierignore +7 -0
  13. package/dist/src/blueprints/ember-addon/__testAppLocation__/.stylelintignore +3 -0
  14. package/dist/src/blueprints/ember-addon/__testAppLocation__/.stylelintrc.mjs +1 -0
  15. package/dist/src/blueprints/ember-addon/__testAppLocation__/.template-lintrc.cjs +3 -0
  16. package/dist/src/blueprints/ember-addon/__testAppLocation__/__gitignore__ +16 -0
  17. package/dist/src/blueprints/ember-addon/__testAppLocation__/ember-cli-build.js +7 -2
  18. package/dist/src/blueprints/ember-addon/__testAppLocation__/eslint.config.mjs +1 -0
  19. package/dist/src/blueprints/ember-addon/__testAppLocation__/prettier.config.mjs +1 -0
  20. package/dist/src/blueprints/ember-addon/__testAppLocation__/tsconfig.json +25 -0
  21. package/dist/src/index.js +1 -2
  22. package/dist/src/steps/analyze-addon.js +3 -1
  23. package/dist/src/steps/create-files-from-blueprints.js +1 -0
  24. package/dist/src/steps/create-options.js +2 -2
  25. package/dist/src/steps/index.js +0 -1
  26. package/dist/src/steps/move-project-root-files.js +15 -8
  27. package/dist/src/steps/update-addon-package-json/update-dev-dependencies.js +9 -15
  28. package/dist/src/steps/update-addon-package-json/update-other-fields.js +2 -2
  29. package/dist/src/steps/update-addon-package-json/update-scripts.js +10 -17
  30. package/dist/src/steps/update-test-app-package-json/index.js +1 -0
  31. package/dist/src/steps/update-test-app-package-json/update-dependencies.js +1 -4
  32. package/dist/src/steps/update-test-app-package-json/update-dev-dependencies.js +32 -0
  33. package/dist/src/steps/update-test-app-package-json/update-scripts.js +29 -0
  34. package/dist/src/steps/update-test-app-package-json.js +2 -1
  35. package/dist/src/utils/blueprints/get-version.js +25 -24
  36. package/package.json +19 -36
  37. package/dist/src/blueprints/ember-addon/__addonLocation__/.eslintignore +0 -9
  38. package/dist/src/blueprints/ember-addon/__addonLocation__/.eslintrc.cjs +0 -104
  39. package/dist/src/blueprints/ember-addon/__addonLocation__/.prettierrc.cjs +0 -5
  40. package/dist/src/steps/update-test-app-tsconfig-json.js +0 -30
package/README.md CHANGED
@@ -7,7 +7,7 @@ _Codemod to convert Ember addons to v2 addon format_
7
7
 
8
8
  ## Features
9
9
 
10
- - Scaffolds files according to [`@embroider/addon-blueprint`](https://github.com/embroider-build/addon-blueprint)
10
+ - Follows closely [`@embroider/addon-blueprint`](https://github.com/embroider-build/addon-blueprint)
11
11
  - Preserves your code whenever possible
12
12
  - Supports [`ember-cli-typescript`](https://docs.ember-cli-typescript.com/) and [`glint`](https://typed-ember.gitbook.io/glint/)
13
13
  - Focuses on maintainability and extensibility
@@ -17,7 +17,7 @@ _Codemod to convert Ember addons to v2 addon format_
17
17
 
18
18
  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).
19
19
 
20
- Step 1. Quickly migrate to [v2 format](https://github.com/embroider-build/embroider/blob/v4.3.1-%40embroider/addon-dev/docs/addon-author-guide.md).
20
+ Step 1. Quickly migrate to [v2 format](https://github.com/embroider-build/embroider/blob/v7.1.3-%40embroider/addon-dev/docs/addon-author-guide.md).
21
21
 
22
22
  ```sh
23
23
  cd <path/to/your/project>
@@ -30,14 +30,14 @@ npx ember-codemod-v1-to-v2 <arguments>
30
30
  >
31
31
  > Here are examples of what you may want to work on first:
32
32
  >
33
- > - [Meet prerequisites for v2 addon](https://github.com/embroider-build/embroider/blob/v4.3.1-%40embroider/addon-dev/docs/porting-addons-to-v2.md#part-3-prerequisites-for-v2-addon).
33
+ > - [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
34
  > - [Un-pod v1 addon](https://github.com/ijlee2/ember-codemod-pod-to-octane).
35
35
  > - Update dependencies.
36
36
  > - Switch `npm` or `yarn` to `pnpm`.
37
37
 
38
38
  Step 2. Review the addon package.
39
39
 
40
- - [x] Update the configuration files.<sup>1</sup>
40
+ - [x] Update configuration files.<sup>1</sup>
41
41
  - [x] Install missing dependencies.
42
42
  - [x] Relative import paths must specify the file extension `.js` or `.ts`.
43
43
  - [x] Colocate stylesheets (if any). Let each component import the relevant stylesheet in the backing class.
@@ -45,13 +45,13 @@ Step 2. Review the addon package.
45
45
 
46
46
  Step 3. Review the test-app package.
47
47
 
48
- - [x] Update the configuration files.<sup>1</sup>
48
+ - [x] Update configuration files.<sup>1</sup>
49
49
  - [x] Rename the remaining instances of `dummy` to `test-app`.
50
50
  - [x] Confirm that you can run all scripts in `package.json`.
51
51
 
52
52
  Step 4. Review the workspace root including CI/CD.
53
53
 
54
- <sup>1. 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>
54
+ <sup>1. Files such as `eslint.config.mjs`, `.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>
55
55
 
56
56
 
57
57
  ### Arguments
@@ -131,7 +131,7 @@ You can also look at another codemod called [`ember-addon-migrator`](https://git
131
131
 
132
132
  ## Compatibility
133
133
 
134
- - Node.js v18 or above
134
+ - Node.js v20 or above
135
135
 
136
136
 
137
137
  ## Contributing
@@ -143,7 +143,7 @@ If you have an open-sourced addon (v1 or v2) that I can use as a reference, reac
143
143
 
144
144
  ## Credits
145
145
 
146
- The codemod steps were based on [Migrating an Ember addon to the next-gen v2 format](https://www.kaliber5.de/de/blog/v2-addon_en) and [Guide: Porting an Addon to v2](https://github.com/embroider-build/embroider/blob/v4.3.1-%40embroider/addon-dev/docs/porting-addons-to-v2.md). The blueprints were derived from [`@embroider/addon-blueprint`](https://github.com/embroider-build/addon-blueprint).
146
+ The codemod steps were based on [Migrating an Ember addon to the next-gen v2 format](https://www.kaliber5.de/de/blog/v2-addon_en) and [Guide: Porting an Addon to v2](https://github.com/embroider-build/embroider/blob/v7.1.3-%40embroider/addon-dev/docs/porting-addons-to-v2.md). The blueprints were derived from [`@embroider/addon-blueprint`](https://github.com/embroider-build/addon-blueprint).
147
147
 
148
148
 
149
149
  ## License
@@ -1,9 +1,3 @@
1
- # unconventional js
2
- /blueprints/*/files/
3
-
4
1
  # compiled output
5
- /dist/
6
2
  /declarations/
7
-
8
- # misc
9
- /coverage/
3
+ /dist/
@@ -0,0 +1,3 @@
1
+ # compiled output
2
+ /declarations/
3
+ /dist/
@@ -0,0 +1 @@
1
+ export { default } from '@ijlee2-frontend-configs/stylelint';
@@ -1,5 +1,3 @@
1
1
  'use strict';
2
2
 
3
- module.exports = {
4
- extends: 'recommended',
5
- };
3
+ module.exports = require('@ijlee2-frontend-configs/ember-template-lint');
@@ -1,17 +1,13 @@
1
- # The authoritative copies of these live in the monorepo root (because they're
2
- # more useful on github that way), but the build copies them into here so they
3
- # will also appear in published NPM packages.
4
- /README.md
5
- /LICENSE.md
6
-
7
1
  # compiled output
8
- dist/
9
- declarations/
2
+ /declarations/
3
+ /dist/
4
+
5
+ # dependencies
6
+ /node_modules/
7
+
8
+ # misc
9
+ /.eslintcache
10
+ /.stylelintcache
10
11
 
11
12
  # npm/pnpm/yarn pack output
12
13
  *.tgz
13
-
14
- # deps & caches
15
- node_modules/
16
- .eslintcache
17
- .prettiercache
@@ -0,0 +1 @@
1
+ export { default } from '@ijlee2-frontend-configs/eslint-config-ember/v2-addon';
@@ -0,0 +1 @@
1
+ export { default } from '@ijlee2-frontend-configs/prettier';
@@ -60,7 +60,13 @@ export default {
60
60
 
61
61
  // addons are allowed to contain imports of .css files, which we want rollup
62
62
  // to leave alone and keep in the published output.
63
- addon.keepAssets(['**/*.css']),
63
+ addon.keepAssets(['**/*.css']),<% if (context.addon.hasPublicAssets) { %>
64
+
65
+ // Update public-assets field in package.json
66
+ addon.publicAssets('public/assets', {
67
+ exclude: ['**/.*'],
68
+ namespace: '<%= options.packages.addon.name %>',
69
+ }),<% } %>
64
70
 
65
71
  // Remove leftover build artifacts when starting a new build.
66
72
  addon.clean(),
@@ -1,12 +1,9 @@
1
1
  {
2
- "extends": "@tsconfig/ember/tsconfig.json",
2
+ "extends": "@ijlee2-frontend-configs/typescript/ember",
3
3
  "compilerOptions": {
4
4
  "allowImportingTsExtensions": true,
5
5
  "allowJs": true,
6
6
  "declarationDir": "declarations",
7
- "emitDeclarationOnly": true,
8
- "noEmit": false,
9
- "noEmitOnError": false,
10
7
  "rootDir": "./src",
11
8
  "types": [
12
9
  "ember-source/types"
@@ -1,10 +1,12 @@
1
- # See https://help.github.com/ignore-files/ for more about ignoring files.
1
+ # compiled output
2
+ dist/
3
+ tmp/
2
4
 
3
5
  # dependencies
4
6
  node_modules/
5
7
 
6
8
  # misc
9
+ .DS_Store
7
10
  .env*
8
- .pnpm-debug.log
9
- npm-debug.log*
10
- yarn-error.log
11
+ .eslintcache
12
+ <% if (options.packageManager === 'npm') { %>npm-debug.log*<% } else if (options.packageManager === 'pnpm') { %>pnpm-debug.log<% } else if (options.packageManager === 'yarn') { %>yarn-error.log<% } %>
@@ -0,0 +1,7 @@
1
+ # compiled output
2
+ /dist/
3
+
4
+ # misc
5
+ /coverage/
6
+ !.*
7
+ .*/
@@ -0,0 +1,3 @@
1
+ # compiled output
2
+ /declarations/
3
+ /dist/
@@ -0,0 +1 @@
1
+ export { default } from '@ijlee2-frontend-configs/stylelint';
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ module.exports = require('@ijlee2-frontend-configs/ember-template-lint');
@@ -0,0 +1,16 @@
1
+ # compiled output
2
+ /dist/
3
+
4
+ # dependencies
5
+ /node_modules/
6
+
7
+ # misc
8
+ /.env*
9
+ /.pnp*
10
+ /.eslintcache
11
+ /.stylelintcache
12
+ /coverage/
13
+ /testem.log
14
+
15
+ # broccoli-debug
16
+ /DEBUG/
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ const sideWatch = require('@embroider/broccoli-side-watch');
4
+ const { maybeEmbroider } = require('@embroider/test-setup');
3
5
  const EmberApp = require('ember-cli/lib/broccoli/ember-app');
4
6
 
5
7
  module.exports = function (defaults) {
@@ -11,9 +13,12 @@ module.exports = function (defaults) {
11
13
  'ember-cli-babel': {
12
14
  enableTypeScriptTransform: true,
13
15
  },<% } %>
16
+ trees: {
17
+ app: sideWatch('app', {
18
+ watching: ['<%= options.packages.addon.name %>'],
19
+ }),
20
+ },
14
21
  });
15
22
 
16
- const { maybeEmbroider } = require('@embroider/test-setup');
17
-
18
23
  return maybeEmbroider(app);
19
24
  };
@@ -0,0 +1 @@
1
+ export { default } from '@ijlee2-frontend-configs/eslint-config-ember/v1-app';
@@ -0,0 +1 @@
1
+ export { default } from '@ijlee2-frontend-configs/prettier';
@@ -0,0 +1,25 @@
1
+ {
2
+ "extends": "@ijlee2-frontend-configs/typescript/ember",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "paths": {
6
+ "<%= options.packages.testApp.name %>/tests/*": ["tests/*"],
7
+ "<%= options.packages.testApp.name %>/*": ["app/*"],
8
+ "*": ["types/*"]
9
+ },
10
+ "types": [
11
+ "ember-source/types"
12
+ ]
13
+ },
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
+ }<% } %>
25
+ }
package/dist/src/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { analyzeAddon, createFilesFromBlueprints, createOptions, moveAddonFiles, moveProjectRootFiles, moveTestAppFiles, updateAddonPackageJson, updateTestAppPackageJson, updateTestAppTsConfigJson, } from './steps/index.js';
1
+ import { analyzeAddon, createFilesFromBlueprints, createOptions, moveAddonFiles, moveProjectRootFiles, moveTestAppFiles, updateAddonPackageJson, updateTestAppPackageJson, } from './steps/index.js';
2
2
  export function runCodemod(codemodOptions) {
3
3
  const options = createOptions(codemodOptions);
4
4
  const { isV1Addon } = options.packages.addon;
@@ -17,5 +17,4 @@ export function runCodemod(codemodOptions) {
17
17
  // Fine-tune individual files
18
18
  updateAddonPackageJson(context, options);
19
19
  updateTestAppPackageJson(options);
20
- updateTestAppTsConfigJson(options);
21
20
  }
@@ -25,10 +25,12 @@ function hasBlueprints(options) {
25
25
  return filePaths.length > 0;
26
26
  }
27
27
  export function analyzeAddon(options) {
28
+ const publicAssets = getPublicAssets(options);
28
29
  return {
29
30
  addon: {
30
31
  hasBlueprints: hasBlueprints(options),
31
- publicAssets: getPublicAssets(options),
32
+ hasPublicAssets: Object.keys(publicAssets).length > 0,
33
+ publicAssets,
32
34
  },
33
35
  projectRoot: {
34
36
  devDependencies: getProjectRootDevDependencies(options),
@@ -9,6 +9,7 @@ function getFilesToSkip(options) {
9
9
  if (!packages.addon.hasTypeScript) {
10
10
  files.add('__addonLocation__/tsconfig.json');
11
11
  files.add('__addonLocation__/unpublished-development-types/index.d.ts');
12
+ files.add('__testAppLocation__/tsconfig.json');
12
13
  files.add('__testAppLocation__/types/global.d.ts');
13
14
  }
14
15
  if (packageManager !== 'pnpm') {
@@ -14,8 +14,8 @@ function analyzePackageJson(codemodOptions) {
14
14
  hasGlint: projectDependencies.has('@glint/core'),
15
15
  hasTypeScript: projectDependencies.has('typescript'),
16
16
  isV1Addon: Boolean(emberAddon),
17
- name: name,
18
- version: version,
17
+ name,
18
+ version,
19
19
  };
20
20
  }
21
21
  function analyzePackageManager(codemodOptions) {
@@ -6,4 +6,3 @@ export * from './move-project-root-files.js';
6
6
  export * from './move-test-app-files.js';
7
7
  export * from './update-addon-package-json.js';
8
8
  export * from './update-test-app-package-json.js';
9
- export * from './update-test-app-tsconfig-json.js';
@@ -13,7 +13,7 @@ function copyToAddon(options) {
13
13
  }
14
14
  function moveToAddonAndTestApp(options) {
15
15
  const { locations, projectRoot } = options;
16
- const files = ['.stylelintignore', '.stylelintrc.{cjs,js}', 'package.json'];
16
+ const files = ['package.json'];
17
17
  const filePaths = findFiles(files, {
18
18
  projectRoot,
19
19
  });
@@ -33,16 +33,10 @@ function moveToTestApp(options) {
33
33
  const { locations, projectRoot } = options;
34
34
  const files = [
35
35
  '.ember-cli',
36
- '.eslintignore',
37
- '.eslintrc.{cjs,js}',
38
36
  '.gitignore',
39
- '.prettierignore',
40
- '.prettierrc.{cjs,js}',
41
- '.template-lintrc.{cjs,js}',
42
37
  '.watchmanconfig',
43
38
  'ember-cli-build.js',
44
39
  'testem.js',
45
- 'tsconfig.json',
46
40
  ];
47
41
  const filePaths = findFiles(files, {
48
42
  projectRoot,
@@ -55,7 +49,20 @@ function moveToTestApp(options) {
55
49
  }
56
50
  function removeFromProjectRoot(options) {
57
51
  const { projectRoot } = options;
58
- const files = ['.npmignore', 'index.js'];
52
+ const files = [
53
+ '.eslintignore',
54
+ '.eslintrc.{cjs,js}',
55
+ '.npmignore',
56
+ '.prettierignore',
57
+ '.prettierrc.{cjs,js}',
58
+ '.stylelintignore',
59
+ '.stylelintrc.{cjs,js,mjs}',
60
+ '.template-lintrc.{cjs,js}',
61
+ 'eslint.config.mjs',
62
+ 'index.js',
63
+ 'prettier.config.mjs',
64
+ 'tsconfig.json',
65
+ ];
59
66
  const filePaths = findFiles(files, {
60
67
  projectRoot,
61
68
  });
@@ -3,36 +3,31 @@ 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
- /*
7
- The codemod sets the development dependencies that v2 addons need.
8
- End-developers must add dependencies that their v1 addon needed.
9
- */
6
+ // Start over
10
7
  devDependencies.clear();
11
8
  const packagesToInstall = new Set([
12
9
  '@babel/core',
13
- '@babel/eslint-parser',
14
10
  '@babel/runtime',
15
11
  '@embroider/addon-dev',
12
+ '@eslint/js',
13
+ '@ijlee2-frontend-configs/ember-template-lint',
14
+ '@ijlee2-frontend-configs/eslint-config-ember',
15
+ '@ijlee2-frontend-configs/prettier',
16
+ '@ijlee2-frontend-configs/stylelint',
16
17
  '@rollup/plugin-babel',
17
18
  'babel-plugin-ember-template-compilation',
18
19
  'concurrently',
19
20
  'ember-template-lint',
20
21
  'eslint',
21
- 'eslint-config-prettier',
22
- 'eslint-plugin-ember',
23
- 'eslint-plugin-import',
24
- 'eslint-plugin-n',
25
- 'eslint-plugin-prettier',
26
22
  'prettier',
23
+ 'stylelint',
27
24
  'rollup',
28
25
  'rollup-plugin-copy',
29
26
  ]);
30
27
  if (packages.addon.hasTypeScript) {
31
- packagesToInstall.delete('@babel/eslint-parser');
32
28
  packagesToInstall.add('@babel/plugin-transform-typescript');
33
- packagesToInstall.add('@tsconfig/ember');
34
- packagesToInstall.add('@typescript-eslint/eslint-plugin');
35
- packagesToInstall.add('@typescript-eslint/parser');
29
+ packagesToInstall.add('@ijlee2-frontend-configs/typescript');
30
+ packagesToInstall.add('ember-source');
36
31
  packagesToInstall.add('typescript');
37
32
  }
38
33
  if (packages.addon.hasGlint) {
@@ -40,7 +35,6 @@ export function updateDevDependencies(packageJson, options) {
40
35
  packagesToInstall.add('@glint/environment-ember-loose');
41
36
  packagesToInstall.add('@glint/environment-ember-template-imports');
42
37
  packagesToInstall.add('@glint/template');
43
- packagesToInstall.add('ember-source');
44
38
  }
45
39
  Array.from(packagesToInstall).forEach((packageName) => {
46
40
  const version = getLatestVersion(packageName);
@@ -68,11 +68,11 @@ function updateTypesVersions(packageJson, data) {
68
68
  };
69
69
  }
70
70
  export function updateOtherFields(packageJson, context, options) {
71
- const { hasBlueprints, publicAssets } = context.addon;
71
+ const { hasBlueprints, hasPublicAssets, publicAssets } = context.addon;
72
72
  const { hasTypeScript } = options.packages.addon;
73
73
  const data = {
74
74
  hasBlueprints,
75
- hasPublicAssets: Object.keys(publicAssets).length > 0,
75
+ hasPublicAssets,
76
76
  hasTypeScript,
77
77
  publicAssets,
78
78
  };
@@ -1,30 +1,23 @@
1
+ /* eslint-disable no-useless-escape */
1
2
  import { convertToMap, convertToObject } from '@codemod-utils/json';
2
3
  export function updateScripts(packageJson, options) {
3
- const { locations, packageManager, packages } = options;
4
+ const { packageManager, packages } = options;
4
5
  const scripts = convertToMap(packageJson['scripts']);
5
- /*
6
- The codemod sets the scripts that v2 addons need. End-developers
7
- must add scripts that their v1 addon needed.
8
- */
6
+ // Start over
9
7
  scripts.clear();
10
8
  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:\"`);
17
- scripts.set('lint:hbs', 'ember-template-lint . --no-error-on-unmatched-pattern');
18
- scripts.set('lint:hbs:fix', 'ember-template-lint . --fix --no-error-on-unmatched-pattern');
9
+ scripts.set('lint', `concurrently \"${packageManager}:lint:*(!fix)\" --names \"lint:\"`);
10
+ scripts.set('lint:css', 'stylelint \"**/*.css\" --allow-empty-input --cache"');
11
+ scripts.set('lint:css:fix', 'stylelint \"**/*.css\" --allow-empty-input --fix');
12
+ scripts.set('lint:fix', `concurrently \"${packageManager}:lint:*:fix\" --names \"fix:\"`);
13
+ scripts.set('lint:hbs', 'ember-template-lint .');
14
+ scripts.set('lint:hbs:fix', 'ember-template-lint . --fix');
19
15
  scripts.set('lint:js', 'eslint . --cache');
20
16
  scripts.set('lint:js:fix', 'eslint . --fix');
21
17
  scripts.set('prepack', 'rollup --config');
22
18
  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}\"`);
19
+ scripts.set('test', `echo \"A v2 addon does not have tests, run tests in ${packages.testApp.name}\"`);
26
20
  if (packages.addon.hasTypeScript) {
27
- scripts.delete('postpack');
28
21
  if (packages.addon.hasGlint) {
29
22
  scripts.set('lint:types', 'glint');
30
23
  }
@@ -2,3 +2,4 @@ export * from './move-dev-dependencies-to-dependencies.js';
2
2
  export * from './update-dependencies.js';
3
3
  export * from './update-dev-dependencies.js';
4
4
  export * from './update-other-fields.js';
5
+ export * from './update-scripts.js';
@@ -1,10 +1,7 @@
1
1
  import { convertToMap, convertToObject } from '@codemod-utils/json';
2
2
  export function updateDependencies(packageJson) {
3
3
  const dependencies = convertToMap(packageJson['dependencies']);
4
- /*
5
- For the time being, we'll take the approach of starting over and
6
- adding back the dependencies that are required.
7
- */
4
+ // Start over
8
5
  dependencies.clear();
9
6
  packageJson['dependencies'] = convertToObject(dependencies);
10
7
  }
@@ -1,7 +1,39 @@
1
1
  import { convertToMap, convertToObject } from '@codemod-utils/json';
2
+ import { getLatestVersion } from '../../utils/blueprints.js';
2
3
  export function updateDevDependencies(packageJson, options) {
3
4
  const { packages } = options;
4
5
  const devDependencies = convertToMap(packageJson['devDependencies']);
6
+ const packagesToInstall = new Set([
7
+ '@embroider/broccoli-side-watch',
8
+ '@eslint/js',
9
+ '@ijlee2-frontend-configs/ember-template-lint',
10
+ '@ijlee2-frontend-configs/eslint-config-ember',
11
+ '@ijlee2-frontend-configs/prettier',
12
+ '@ijlee2-frontend-configs/stylelint',
13
+ 'concurrently',
14
+ 'ember-cli',
15
+ 'ember-source',
16
+ 'ember-template-lint',
17
+ 'ember-try',
18
+ 'eslint',
19
+ 'prettier',
20
+ 'stylelint',
21
+ ]);
22
+ if (packages.addon.hasTypeScript) {
23
+ packagesToInstall.add('@ijlee2-frontend-configs/typescript');
24
+ packagesToInstall.add('typescript');
25
+ }
26
+ if (packages.addon.hasGlint) {
27
+ packagesToInstall.add('@glint/core');
28
+ packagesToInstall.add('@glint/environment-ember-loose');
29
+ packagesToInstall.add('@glint/environment-ember-template-imports');
30
+ packagesToInstall.add('@glint/template');
31
+ }
32
+ Array.from(packagesToInstall).forEach((packageName) => {
33
+ const version = getLatestVersion(packageName);
34
+ devDependencies.set(packageName, version);
35
+ });
36
+ // Install addon
5
37
  devDependencies.set(packages.addon.name, packages.addon.version);
6
38
  packageJson['devDependencies'] = convertToObject(devDependencies);
7
39
  }
@@ -0,0 +1,29 @@
1
+ /* eslint-disable no-useless-escape */
2
+ import { convertToMap, convertToObject } from '@codemod-utils/json';
3
+ export function updateScripts(packageJson, options) {
4
+ const { packageManager, packages } = options;
5
+ const scripts = convertToMap(packageJson['scripts']);
6
+ // Start over
7
+ scripts.clear();
8
+ scripts.set('build', 'ember build --environment=production');
9
+ scripts.set('lint', `concurrently \"${packageManager}:lint:*(!fix)\" --names \"lint:\"`);
10
+ scripts.set('lint:fix', `concurrently \"${packageManager}:lint:*:fix\" --names \"fix:\"`);
11
+ scripts.set('lint:css', 'stylelint \"**/*.css\" --allow-empty-input --cache"');
12
+ scripts.set('lint:css:fix', 'stylelint \"**/*.css\" --allow-empty-input --fix');
13
+ scripts.set('lint:hbs', 'ember-template-lint .');
14
+ scripts.set('lint:hbs:fix', 'ember-template-lint . --fix');
15
+ scripts.set('lint:js', 'eslint . --cache');
16
+ scripts.set('lint:js:fix', 'eslint . --fix');
17
+ scripts.set('start', 'ember serve');
18
+ scripts.set('test', 'ember test');
19
+ scripts.set('test:ember-compatibility', 'ember try:one');
20
+ if (packages.addon.hasTypeScript) {
21
+ if (packages.addon.hasGlint) {
22
+ scripts.set('lint:types', 'glint');
23
+ }
24
+ else {
25
+ scripts.set('lint:types', 'tsc --noEmit');
26
+ }
27
+ }
28
+ packageJson['scripts'] = convertToObject(scripts);
29
+ }
@@ -1,7 +1,7 @@
1
1
  import { writeFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { readPackageJson } from '@codemod-utils/json';
4
- import { moveDependenciesToDevDependencies, updateDependencies, updateDevDependencies, updateOtherFields, } from './update-test-app-package-json/index.js';
4
+ import { moveDependenciesToDevDependencies, updateDependencies, updateDevDependencies, updateOtherFields, updateScripts, } from './update-test-app-package-json/index.js';
5
5
  export function updateTestAppPackageJson(options) {
6
6
  const { locations, projectRoot } = options;
7
7
  const packageJson = readPackageJson({
@@ -10,6 +10,7 @@ export function updateTestAppPackageJson(options) {
10
10
  moveDependenciesToDevDependencies(packageJson, options);
11
11
  updateDependencies(packageJson);
12
12
  updateDevDependencies(packageJson, options);
13
+ updateScripts(packageJson, options);
13
14
  updateOtherFields(packageJson, options);
14
15
  const destination = join(projectRoot, locations.testApp, 'package.json');
15
16
  const file = JSON.stringify(packageJson, null, 2) + '\n';
@@ -1,38 +1,39 @@
1
1
  import { decideVersion } from '@codemod-utils/blueprints';
2
2
  const latestVersions = new Map([
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'],
3
+ ['@babel/core', '7.26.10'],
4
+ ['@babel/plugin-transform-typescript', '7.26.8'],
5
+ ['@babel/runtime', '7.26.10'],
6
+ ['@embroider/addon-dev', '7.1.3'],
8
7
  ['@embroider/addon-shim', '1.9.0'],
8
+ ['@embroider/broccoli-side-watch', '1.0.1'],
9
9
  ['@embroider/test-setup', '4.0.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'],
10
+ ['@eslint/js', '9.23.0'],
11
+ ['@glint/core', '1.5.2'],
12
+ ['@glint/environment-ember-loose', '1.5.2'],
13
+ ['@glint/environment-ember-template-imports', '1.5.2'],
14
+ ['@glint/template', '1.5.2'],
15
+ ['@ijlee2-frontend-configs/ember-template-lint', '0.5.2'],
16
+ ['@ijlee2-frontend-configs/eslint-config-ember', '0.4.0'],
17
+ ['@ijlee2-frontend-configs/prettier', '0.2.3'],
18
+ ['@ijlee2-frontend-configs/stylelint', '0.2.3'],
19
+ ['@ijlee2-frontend-configs/typescript', '0.4.0'],
14
20
  ['@rollup/plugin-babel', '6.0.4'],
15
- ['@tsconfig/ember', '3.0.8'],
16
- ['@typescript-eslint/eslint-plugin', '8.20.0'],
17
- ['@typescript-eslint/parser', '8.20.0'],
18
- ['babel-plugin-ember-template-compilation', '2.3.0'],
21
+ ['babel-plugin-ember-template-compilation', '2.4.0'],
19
22
  ['concurrently', '9.1.2'],
20
23
  ['decorator-transforms', '2.3.0'],
21
24
  ['ember-auto-import', '2.10.0'],
25
+ ['ember-cli', '6.2.0'],
22
26
  ['ember-cli-babel', '8.2.0'],
23
27
  ['ember-cli-htmlbars', '6.3.0'],
24
- ['ember-source', '6.1.0'],
25
- ['ember-template-lint', '6.0.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'],
28
+ ['ember-source', '6.2.0'],
29
+ ['ember-template-lint', '7.0.1'],
30
+ ['ember-try', '4.0.0'],
31
+ ['eslint', '9.23.0'],
32
+ ['prettier', '3.5.3'],
33
+ ['rollup', '4.37.0'],
34
34
  ['rollup-plugin-copy', '3.5.0'],
35
- ['typescript', '5.7.3'],
35
+ ['stylelint', '16.16.0'],
36
+ ['typescript', '5.8.2'],
36
37
  ]);
37
38
  export function getLatestVersion(packageName) {
38
39
  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.7.0",
3
+ "version": "2.0.0",
4
4
  "description": "Codemod to convert Ember addons to v2 addon format",
5
5
  "keywords": [
6
6
  "codemod",
@@ -27,56 +27,39 @@
27
27
  "dist"
28
28
  ],
29
29
  "dependencies": {
30
- "@codemod-utils/blueprints": "^1.1.6",
31
- "@codemod-utils/files": "^2.0.5",
32
- "@codemod-utils/json": "^1.1.10",
30
+ "@codemod-utils/blueprints": "^1.1.9",
31
+ "@codemod-utils/files": "^2.1.0",
32
+ "@codemod-utils/json": "^1.2.0",
33
33
  "strip-json-comments": "^5.0.1",
34
34
  "yargs": "^17.7.2"
35
35
  },
36
36
  "devDependencies": {
37
- "@babel/core": "^7.26.0",
38
- "@codemod-utils/tests": "^1.1.8",
37
+ "@changesets/cli": "^2.28.1",
38
+ "@changesets/get-github-info": "^0.6.0",
39
+ "@codemod-utils/tests": "^1.1.11",
40
+ "@ijlee2-frontend-configs/eslint-config-node": "^0.3.0",
41
+ "@ijlee2-frontend-configs/prettier": "^0.2.3",
42
+ "@ijlee2-frontend-configs/typescript": "^0.4.0",
39
43
  "@sondr3/minitest": "^0.1.2",
40
- "@tsconfig/node18": "^18.2.4",
41
- "@tsconfig/strictest": "^2.0.5",
42
- "@types/node": "^18.19.70",
44
+ "@types/node": "^20.17.27",
43
45
  "@types/yargs": "^17.0.33",
44
- "@typescript-eslint/eslint-plugin": "^8.20.0",
45
- "@typescript-eslint/parser": "^8.20.0",
46
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
- "eslint-plugin-simple-import-sort": "^12.1.1",
54
- "eslint-plugin-typescript-sort-keys": "^3.3.0",
55
- "lerna-changelog": "^2.2.0",
56
- "prettier": "^3.4.2",
57
- "typescript": "^5.7.3"
47
+ "eslint": "^9.23.0",
48
+ "prettier": "^3.5.3",
49
+ "typescript": "^5.8.2"
58
50
  },
59
51
  "engines": {
60
- "node": "18.* || >= 20"
61
- },
62
- "changelog": {
63
- "labels": {
64
- "breaking": "Breaking Change",
65
- "bug": "Bug Fix",
66
- "enhance: code": "Enhancement",
67
- "enhance: dependency": "Internal",
68
- "enhance: documentation": "Documentation"
69
- }
52
+ "node": "20.* || >= 22"
70
53
  },
71
54
  "scripts": {
72
55
  "build": "./build.sh --production",
73
- "lint": "concurrently 'pnpm:lint:*(!fix)' --names 'lint:'",
74
- "lint:fix": "concurrently 'pnpm:lint:*:fix' --names 'fix:'",
56
+ "lint": "concurrently \"pnpm:lint:*(!fix)\" --names \"lint:\"",
57
+ "lint:fix": "concurrently \"pnpm:lint:*:fix\" --names \"fix:\"",
75
58
  "lint:js": "eslint . --cache",
76
59
  "lint:js:fix": "eslint . --fix",
77
60
  "lint:types": "tsc --noEmit",
78
- "release:changelog": "lerna-changelog",
79
- "release:publish": "pnpm publish",
61
+ "release:prepare": "changeset version",
62
+ "release:publish": "pnpm build && changeset publish",
80
63
  "test": "./build.sh --test && mt dist-for-testing --quiet"
81
64
  }
82
65
  }
@@ -1,9 +0,0 @@
1
- # unconventional js
2
- /blueprints/*/files/
3
-
4
- # compiled output
5
- /dist/
6
- /declarations/
7
-
8
- # misc
9
- /coverage/
@@ -1,104 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- root: true,
5
- // Only use overrides
6
- // https://github.com/ember-cli/eslint-plugin-ember?tab=readme-ov-file#gtsgjs
7
- overrides: [
8
- {
9
- files: ['**/*.js'<%= options.packages.addon.hasTypeScript ? ", '**/*.ts'" : '' %>],
10
- env: { browser: true },
11
- parser: '<%= options.packages.addon.hasTypeScript ? '@typescript-eslint/parser' : '@babel/eslint-parser' %>',
12
- parserOptions: {
13
- ecmaVersion: 'latest',<% if (!options.packages.addon.hasTypeScript) { %>
14
- sourceType: 'module',
15
- babelOptions: {
16
- root: __dirname,
17
- },<% } %>
18
- },
19
- plugins: ['ember', 'import'],
20
- extends: [
21
- 'eslint:recommended',
22
- 'plugin:ember/recommended',
23
- 'plugin:prettier/recommended',
24
- ],
25
- rules: {
26
- // require relative imports use full extensions
27
- 'import/extensions': ['error', 'always', { ignorePackages: true }],
28
- // Add any custom rules here
29
- },
30
- },
31
- <% if (options.packages.addon.hasTypeScript) { %> // ts files
32
- {
33
- files: ['**/*.ts'],
34
- extends: [
35
- 'eslint:recommended',
36
- 'plugin:ember/recommended',
37
- 'plugin:@typescript-eslint/eslint-recommended',
38
- 'plugin:@typescript-eslint/recommended',
39
- 'plugin:prettier/recommended',
40
- ],
41
- rules: {
42
- // require relative imports use full extensions
43
- 'import/extensions': ['error', 'always', { ignorePackages: true }],
44
- // Add any custom rules here
45
- },
46
- },
47
- {
48
- files: ['**/*.gts'],
49
- parser: 'ember-eslint-parser',
50
- plugins: ['ember', 'import'],
51
- extends: [
52
- 'eslint:recommended',
53
- 'plugin:@typescript-eslint/eslint-recommended',
54
- 'plugin:@typescript-eslint/recommended',
55
- 'plugin:ember/recommended',
56
- 'plugin:ember/recommended-gts',
57
- 'plugin:prettier/recommended',
58
- ],
59
- rules: {
60
- // require relative imports use full extensions
61
- 'import/extensions': ['error', 'always', { ignorePackages: true }],
62
- // Add any custom rules here
63
- },
64
- },
65
- <% } %> {
66
- files: ['**/*.gjs'],
67
- parser: 'ember-eslint-parser',
68
- plugins: ['ember', 'import'],
69
- extends: [
70
- 'eslint:recommended',
71
- 'plugin:ember/recommended',
72
- 'plugin:ember/recommended-gjs',
73
- 'plugin:prettier/recommended',
74
- ],
75
- rules: {
76
- // require relative imports use full extensions
77
- 'import/extensions': ['error', 'always', { ignorePackages: true }],
78
- // Add any custom rules here
79
- },
80
- },
81
- // node files
82
- {
83
- files: [
84
- './.eslintrc.cjs',
85
- './.prettierrc.cjs',
86
- './.template-lintrc.cjs',
87
- './addon-main.cjs',
88
- ],
89
- parserOptions: {
90
- sourceType: 'script',
91
- },
92
- env: {
93
- browser: false,
94
- node: true,
95
- },
96
- plugins: ['n'],
97
- extends: [
98
- 'eslint:recommended',
99
- 'plugin:n/recommended',
100
- 'plugin:prettier/recommended',
101
- ],
102
- },
103
- ],
104
- };
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- singleQuote: true,
5
- };
@@ -1,30 +0,0 @@
1
- import { readFileSync, writeFileSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- import { convertToMap, convertToObject } from '@codemod-utils/json';
4
- import { sanitizeJson } from '../utils/json.js';
5
- function updateCompilerOptions(tsConfigJson, options) {
6
- const { packages } = options;
7
- const compilerOptions = convertToMap(tsConfigJson['compilerOptions']);
8
- compilerOptions.set('paths', {
9
- [`${packages.testApp.name}/tests/*`]: ['tests/*'],
10
- [`${packages.testApp.name}/*`]: ['app/*'],
11
- '*': ['types/*'],
12
- });
13
- tsConfigJson['compilerOptions'] = convertToObject(compilerOptions);
14
- }
15
- function removeInclude(tsConfigJson) {
16
- delete tsConfigJson['include'];
17
- }
18
- export function updateTestAppTsConfigJson(options) {
19
- const { locations, packages, projectRoot } = options;
20
- if (!packages.addon.hasTypeScript) {
21
- return;
22
- }
23
- const oldPath = join(projectRoot, locations.testApp, 'tsconfig.json');
24
- const oldFile = readFileSync(oldPath, 'utf8');
25
- const tsConfigJson = JSON.parse(sanitizeJson(oldFile));
26
- updateCompilerOptions(tsConfigJson, options);
27
- removeInclude(tsConfigJson);
28
- const newFile = JSON.stringify(tsConfigJson, null, 2) + '\n';
29
- writeFileSync(oldPath, newFile, 'utf8');
30
- }