analyze-ember-project-dependencies
Advanced tools
Comparing version 0.3.1 to 0.4.0
@@ -10,2 +10,7 @@ #!/usr/bin/env node | ||
const argv = yargs(hideBin(process.argv)) | ||
.option('component-structure', { | ||
choices: ['flat', 'nested'], | ||
describe: 'Component structure (how your components are colocated)', | ||
type: 'string', | ||
}) | ||
.option('root', { | ||
@@ -17,4 +22,5 @@ describe: 'Where to run the codemod', | ||
const codemodOptions = { | ||
componentStructure: argv['component-structure'] ?? 'flat', | ||
projectRoot: argv['root'] ?? process.cwd(), | ||
}; | ||
analyzeEmberProjectDependencies(codemodOptions); |
@@ -12,6 +12,3 @@ import { readPackageJson } from '@codemod-utils/json'; | ||
const { dependencies, devDependencies, packageType } = analyzePackageJson(packageJson); | ||
const entities = analyzeEntities({ | ||
packageRoot, | ||
packageType, | ||
}); | ||
const entities = analyzeEntities(packageRoot, packageType, options); | ||
projectData.set(packageJson['name'], { | ||
@@ -18,0 +15,0 @@ dependencies, |
@@ -15,4 +15,3 @@ import { doubleColonize } from '@codemod-utils/ember'; | ||
]; | ||
export function analyzeEntities(options) { | ||
const { packageRoot, packageType } = options; | ||
export function analyzeEntities(packageRoot, packageType, options) { | ||
const source = SOURCE[packageType]; | ||
@@ -29,2 +28,3 @@ const entities = { | ||
} | ||
const { componentStructure } = options; | ||
ENTITY_TYPES.forEach((entityType) => { | ||
@@ -42,2 +42,7 @@ const filePaths = findFiles(`${source}/${entityType}/**/*.{gjs,gts,hbs,js,ts}`, { | ||
entityNames = Array.from(new Set(entityNames)); | ||
if (componentStructure === 'nested') { | ||
entityNames = entityNames.map((entityName) => { | ||
return entityName.replace(/\/index$/, ''); | ||
}); | ||
} | ||
entities['components'] = entityNames; | ||
@@ -44,0 +49,0 @@ entities['componentsDoubleColonized'] = entityNames.map(doubleColonize); |
export function createOptions(codemodOptions) { | ||
const { projectRoot } = codemodOptions; | ||
const { componentStructure, projectRoot } = codemodOptions; | ||
return { | ||
componentStructure, | ||
projectRoot, | ||
}; | ||
} |
{ | ||
"name": "analyze-ember-project-dependencies", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"description": "Analyze dependencies of an Ember project", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -37,2 +37,14 @@ # analyze-ember-project-dependencies | ||
<summary>Optional: Specify the component structure</summary> | ||
By default, apps and addons follow the flat component structure for components. Pass `--component-structure` to indicate otherwise. | ||
```sh | ||
npx analyze-ember-project-dependencies --component-structure nested | ||
``` | ||
</details> | ||
<details> | ||
<summary>Optional: Specify the project root</summary> | ||
@@ -43,3 +55,3 @@ | ||
```sh | ||
npx ember-codemod-remove-inject-as-service --root <path/to/your/project> | ||
npx analyze-ember-project-dependencies --root <path/to/your/project> | ||
``` | ||
@@ -46,0 +58,0 @@ |
36530
1045
115