UNPKG

ember-codemod-css-modules

Version:

Codemod to replace ember-component-css with ember-css-modules (compatible with embroider-css-modules)

24 lines (23 loc) 818 B
import { findFiles } from '@codemod-utils/files'; export function findStyles(options) { const { projectRoot } = options; return findFiles('{app,addon}/styles/component-styles/**/*.{css,scss}', { projectRoot, }); } export function analyzeApp(options) { return findStyles(options).map(oldPath => { const newPath = oldPath.replace('styles/component-styles', 'components').replace(/\.(.+)$/i, `.module.$1`); const jsPath = newPath.replace(/\.(.+)$/i, '.js'); const hbsPath = newPath.replace(/\.(.+)$/i, '.hbs'); const entityName = jsPath.split('components/')[1]?.replace('.js', '') || ''; return { entityName, oldPath, newPath, jsPath, hbsPath, hasHbsUsage: false, }; }); }