Skip to content

Commit

Permalink
feat(cli-utils): add scan adoption script
Browse files Browse the repository at this point in the history
  • Loading branch information
andresin87 committed Apr 23, 2024
1 parent b088cb8 commit 203e05e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Empty file added .spark-ui.cjs
Empty file.
4 changes: 2 additions & 2 deletions packages/utils/cli/src/index.doc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ spark scan adoption -c "./spark-ui.cjs"
module.exports = {
adoption: {
details: true,
alpha: false,
sort: 'count', // 'count' or 'alphabetical'
imports: ['@spark-ui'],
extensions: ['.tsx', '.ts'],
directory: './packages',
Expand All @@ -86,7 +86,7 @@ module.exports = {
/***
- `details` (boolean) - whether to show the details of the adoption or not. Default: false
- `alpha` (boolean) - packages are sorted alphabetically. Default: false means sorted by adoption number
- `sort` ('count' | 'alphabetical') - packages are sorted alphabetically. Default: false means sorted by adoption number
- `imports` (array) - the imports to be scanned.
- `extensions` (array) - the extensions to be scanned
- `directory` (string) - the directory to be scanned. Default: '.' means the current directory
Expand Down
6 changes: 3 additions & 3 deletions packages/utils/cli/src/scan/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { scanDirectories } from './utils/scan-directories.mjs'
const DEFAULT_CONFIG = {
adoption: {
details: false,
alpha: false,
sort: 'count',
imports: ['@spark-ui'],
extensions: ['.tsx', '.ts'],
directory: '.',
Expand Down Expand Up @@ -60,7 +60,7 @@ export async function adoption(options) {
})

// Sort importsUsed by alphabet
if (config.adoption.alpha) {
if (config.adoption.sort === 'alphabetical') {
importsUsed = Object.fromEntries(
Object.entries(importsUsed)
.sort(([pkgNameA], [pkgNameB]) => pkgNameA.localeCompare(pkgNameB))
Expand All @@ -79,7 +79,7 @@ export async function adoption(options) {
]
})
)
} else {
} else if (config.adoption.sort === 'count') {
// Sort importsUsed by most used
importsUsed = Object.fromEntries(
Object.entries(importsUsed)
Expand Down

0 comments on commit 203e05e

Please sign in to comment.