ember-codemod-remove-ember-css-modules 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,9 @@
1
- import { join, parse } from 'node:path';
1
+ import { join } from 'node:path';
2
+ import { parseFilePath } from '@codemod-utils/files';
2
3
  export function analyzeFilePaths(filePaths) {
3
4
  const entities = new Map();
4
5
  filePaths.forEach((filePath) => {
5
- const { dir, ext, name } = parse(filePath);
6
+ const { dir, ext, name } = parseFilePath(filePath);
6
7
  const entityName = join(dir, name);
7
8
  if (entities.has(entityName)) {
8
9
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -1,12 +1,17 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { processTemplate } from '@codemod-utils/blueprints';
4
- import { createFiles } from '@codemod-utils/files';
4
+ import { classify, doubleColonize } from '@codemod-utils/ember-cli-string';
5
+ import { createFiles, parseFilePath } from '@codemod-utils/files';
5
6
  import { blueprintsRoot } from '../../../../utils/blueprints.js';
6
- import { parseEntityName } from '../../../../utils/string.js';
7
7
  export function createClass(entityName, { customizations, options }) {
8
8
  const { blueprintFilePaths, getFilePath } = customizations;
9
- const entity = parseEntityName(entityName);
9
+ const entity = {
10
+ classifiedName: classify(entityName),
11
+ doubleColonizedName: doubleColonize(entityName),
12
+ fileName: parseFilePath(entityName).name,
13
+ name: entityName,
14
+ };
10
15
  const filePath = getFilePath(entityName);
11
16
  const fileMap = new Map(blueprintFilePaths.map((blueprintFilePath) => {
12
17
  const blueprintFile = readFileSync(join(blueprintsRoot, blueprintFilePath), 'utf8');
@@ -1,8 +1,8 @@
1
- /* eslint-disable @typescript-eslint/ban-ts-comment */
1
+ /* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access */
2
2
  import { readFileSync } from 'node:fs';
3
- import { join, parse } from 'node:path';
4
- import { ASTJavaScript as AST } from '@codemod-utils/ast';
5
- import { createFiles } from '@codemod-utils/files';
3
+ import { join } from 'node:path';
4
+ import { AST } from '@codemod-utils/ast-javascript';
5
+ import { createFiles, parseFilePath } from '@codemod-utils/files';
6
6
  function removeTemplateOnlyComponentMethod(file, data) {
7
7
  const traverse = AST.traverse(data.isTypeScript);
8
8
  const ast = traverse(file, {
@@ -81,11 +81,11 @@ export function updateClass(entityName, { customizations, options }) {
81
81
  const { getFilePath } = customizations;
82
82
  const { __styles__, projectRoot } = options;
83
83
  const filePath = getFilePath(entityName);
84
- const { ext: fileExtension, name: fileName } = parse(filePath);
84
+ const { ext, name } = parseFilePath(filePath);
85
85
  const data = {
86
86
  __styles__,
87
- fileName,
88
- isTypeScript: fileExtension === '.ts',
87
+ fileName: name,
88
+ isTypeScript: ext === '.ts',
89
89
  };
90
90
  try {
91
91
  let file = readFileSync(join(projectRoot, filePath), 'utf8');
@@ -1,6 +1,6 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import { extname, join } from 'node:path';
3
- import { ASTJavaScript as AST } from '@codemod-utils/ast';
3
+ import { AST } from '@codemod-utils/ast-javascript';
4
4
  import { createFiles, findFiles } from '@codemod-utils/files';
5
5
  function addCssEntryPoint(file, data) {
6
6
  const traverse = AST.traverse(data.isTypeScript);
@@ -10,6 +10,7 @@ function addCssEntryPoint(file, data) {
10
10
  AST.builders.importDeclaration([], AST.builders.literal('./assets/app.css')),
11
11
  AST.builders.noop(),
12
12
  ];
13
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
13
14
  path.value.body.unshift(...nodesToAdd);
14
15
  return false;
15
16
  },
@@ -26,6 +26,7 @@ function updateDevDependencies(packageJson, options) {
26
26
  const version = getVersion(packageName, options);
27
27
  devDependencies.set(packageName, version);
28
28
  });
29
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
29
30
  packageJson['devDependencies'] = convertToObject(devDependencies);
30
31
  }
31
32
  function updateScripts(packageJson, options) {
@@ -34,6 +35,7 @@ function updateScripts(packageJson, options) {
34
35
  if (project.hasTypeScript) {
35
36
  scripts.set('prelint:types', 'type-css-modules --src app');
36
37
  }
38
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
37
39
  packageJson['scripts'] = convertToObject(scripts);
38
40
  }
39
41
  export function updatePackageJson(options) {
@@ -1,7 +1,7 @@
1
- /* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-non-null-assertion */
1
+ /* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access */
2
2
  import { readFileSync } from 'node:fs';
3
3
  import { join } from 'node:path';
4
- import { ASTHandlebars as AST } from '@codemod-utils/ast';
4
+ import { AST } from '@codemod-utils/ast-template';
5
5
  import { createFiles } from '@codemod-utils/files';
6
6
  function sanitizeClassAndLocalClassAttributes(file) {
7
7
  function removeAttributeWithoutValue(attributeName, attributes) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-codemod-remove-ember-css-modules",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Codemod to replace ember-css-modules with embroider-css-modules",
5
5
  "keywords": [
6
6
  "codemod",
@@ -26,24 +26,26 @@
26
26
  "dist"
27
27
  ],
28
28
  "dependencies": {
29
- "@codemod-utils/ast": "^0.2.0",
30
- "@codemod-utils/blueprints": "^0.2.0",
31
- "@codemod-utils/files": "^0.4.1",
32
- "@codemod-utils/json": "^0.3.1",
29
+ "@codemod-utils/ast-javascript": "^0.3.2",
30
+ "@codemod-utils/ast-template": "^0.3.1",
31
+ "@codemod-utils/blueprints": "^0.2.1",
32
+ "@codemod-utils/ember-cli-string": "^0.1.1",
33
+ "@codemod-utils/files": "^0.5.2",
34
+ "@codemod-utils/json": "^0.4.0",
33
35
  "yargs": "^17.7.2"
34
36
  },
35
37
  "devDependencies": {
36
- "@codemod-utils/tests": "^0.2.2",
38
+ "@codemod-utils/tests": "^0.2.5",
37
39
  "@sondr3/minitest": "^0.1.1",
38
- "@types/node": "^16.11.7",
40
+ "@types/node": "^16.18.39",
39
41
  "@types/yargs": "^17.0.24",
40
42
  "concurrently": "^8.2.0",
41
- "eslint": "^8.43.0",
42
- "prettier": "^2.8.8",
43
- "typescript": "^5.1.3",
43
+ "eslint": "^8.46.0",
44
+ "prettier": "^3.0.0",
45
+ "typescript": "^5.1.6",
44
46
  "@shared-configs/eslint-config-node": "0.0.0",
45
- "@shared-configs/typescript": "0.0.0",
46
- "@shared-configs/prettier": "0.0.0"
47
+ "@shared-configs/prettier": "0.0.0",
48
+ "@shared-configs/typescript": "0.0.0"
47
49
  },
48
50
  "engines": {
49
51
  "node": "16.* || >= 18"
@@ -1,11 +0,0 @@
1
- /* https://github.com/ember-cli/ember-cli-string-utils/blob/v1.1.0/index.js */
2
- const STRING_CAMELIZE_REGEXP = /(-|_|\.|\s)+(.)?/g;
3
- export function camelize(value) {
4
- return value
5
- .replace(STRING_CAMELIZE_REGEXP, function (_match, _separator, character) {
6
- return character ? character.toUpperCase() : '';
7
- })
8
- .replace(/^([A-Z])/, function (match) {
9
- return match.toLowerCase();
10
- });
11
- }
@@ -1,10 +0,0 @@
1
- /* https://github.com/ember-cli/ember-cli-string-utils/blob/v1.1.0/index.js */
2
- import { camelize } from './camelize.js';
3
- export function classify(value) {
4
- const tokens = value.split('.');
5
- const tokensTransformed = tokens.map((token) => {
6
- const camelized = camelize(token);
7
- return camelized.charAt(0).toUpperCase() + camelized.substring(1);
8
- });
9
- return tokensTransformed.join('.');
10
- }
@@ -1,5 +0,0 @@
1
- /* https://github.com/emberjs/ember.js/blob/v4.12.0/blueprints/component/index.js#L255-L256 */
2
- import { classify } from '../ember-cli-string-utils/classify.js';
3
- export function classifyEntityName(entityName) {
4
- return classify(entityName.replace(/\//g, '-'));
5
- }
@@ -1,7 +0,0 @@
1
- /* https://github.com/emberjs/ember.js/blob/v4.12.0/blueprints/component-test/index.js#L13-L16 */
2
- import { classify } from '../ember-cli-string-utils/classify.js';
3
- export function doubleColonizeEntityName(entityName) {
4
- const tokens = entityName.split('/');
5
- const tokensTransformed = tokens.map(classify);
6
- return tokensTransformed.join('::');
7
- }
@@ -1,15 +0,0 @@
1
- import { parse } from 'node:path';
2
- import { classifyEntityName } from './classify.js';
3
- import { doubleColonizeEntityName } from './double-colonize.js';
4
- export function parseEntityName(entityName) {
5
- const classifiedName = classifyEntityName(entityName);
6
- const doubleColonizedName = doubleColonizeEntityName(entityName);
7
- const { name: fileName } = parse(entityName);
8
- const entity = {
9
- classifiedName,
10
- doubleColonizedName,
11
- fileName,
12
- name: entityName,
13
- };
14
- return entity;
15
- }
@@ -1,5 +0,0 @@
1
- export * from './string/ember-cli-string-utils/camelize.js';
2
- export * from './string/ember-cli-string-utils/classify.js';
3
- export * from './string/entity-name/classify.js';
4
- export * from './string/entity-name/double-colonize.js';
5
- export * from './string/entity-name/parse.js';