pure-index
Advanced tools
Comparing version 0.0.28 to 0.0.29
@@ -12,3 +12,6 @@ import { expect, test, mock, vi } from 'vitest' | ||
extensions: 'js,jsx', | ||
collectUsages: 'package-a' | ||
collectUsages: 'package-a', | ||
batch: 1, | ||
babelPlugins: 'decorators-legacy,classPrivateProperties', | ||
exclude: 'biba,boba,.cache,www/assets,__tests__' | ||
} | ||
@@ -24,3 +27,13 @@ })) | ||
extensions: ['js', 'jsx'], | ||
collectUsages: 'package-a' | ||
collectUsages: 'package-a', | ||
batch: 1, | ||
babelPlugins: ['decorators-legacy', 'classPrivateProperties'], | ||
exclude: new Set([ | ||
'node_modules', | ||
'biba', | ||
'boba', | ||
'.cache', | ||
'www/assets', | ||
'__tests__' | ||
]) | ||
}) | ||
@@ -27,0 +40,0 @@ |
@@ -12,3 +12,3 @@ import { expect, test, mock, vi } from 'vitest' | ||
babelPlugins: ['jsx'], | ||
batch: { default: 500 }, | ||
batch: 500, | ||
entry: 'src/index.ts', | ||
@@ -27,3 +27,6 @@ exclude: ['build'], | ||
extensions: 'js,jsx,ts,tsx', | ||
collectUsages: 'package-a' | ||
collectUsages: 'package-a', | ||
batch: 1, | ||
babelPlugins: 'decorators-legacy,classPrivateProperties', | ||
exclude: 'biba,boba,.cache,www/assets,__tests__' | ||
} | ||
@@ -37,8 +40,15 @@ })) | ||
...CONFIG, | ||
babelPlugins: new Set([...CONFIG.babelPlugins, 'jsx']), | ||
batch: { default: 500 }, | ||
babelPlugins: ['decorators-legacy', 'classPrivateProperties'], | ||
batch: 1, | ||
collectUsages: 'package-a', | ||
entry: 'src/main.js', | ||
extensions: ['js', 'jsx', 'ts', 'tsx'], | ||
exclude: new Set([...CONFIG.exclude, 'build']) | ||
exclude: new Set([ | ||
'node_modules', | ||
'biba', | ||
'boba', | ||
'.cache', | ||
'www/assets', | ||
'__tests__' | ||
]) | ||
}) | ||
@@ -45,0 +55,0 @@ |
export const CONFIG = { | ||
babelPlugins: new Set(['typescript']), | ||
batch: { default: 100 }, | ||
babelPlugins: ['typescript'], | ||
batch: 100, | ||
collectUsages: null, | ||
@@ -5,0 +5,0 @@ entry: 'index.ts', |
@@ -12,3 +12,3 @@ import { expect, test, mock, vi } from 'vitest' | ||
babelPlugins: ['jsx'], | ||
batch: { default: 500 }, | ||
batch: 500, | ||
entry: 'src/index.ts', | ||
@@ -26,4 +26,4 @@ exclude: ['build'], | ||
...CONFIG, | ||
babelPlugins: new Set([...CONFIG.babelPlugins, 'jsx']), | ||
batch: { default: 500 }, | ||
babelPlugins: ['jsx'], | ||
batch: 500, | ||
entry: 'src/index.ts', | ||
@@ -30,0 +30,0 @@ extensions: ['js', 'jsx'], |
@@ -7,6 +7,4 @@ import { fileTraversal } from './fileTraversal/index.js' | ||
* config: { | ||
* babelPlugins: Set<string> | ||
* batch: { | ||
* default: number | ||
* } | ||
* babelPlugins: Array<string> | ||
* batch: number | ||
* collectUsages: string | ||
@@ -13,0 +11,0 @@ * exclude: Set<string> |
@@ -8,6 +8,4 @@ import { processBatch } from './processBatch/index.js' | ||
* config: { | ||
* babelPlugins: Set<string> | ||
* batch: { | ||
* default: number | ||
* } | ||
* babelPlugins: Array<string> | ||
* batch: number | ||
* exclude: Set<string> | ||
@@ -32,3 +30,3 @@ * extensions: Array<string> | ||
if (batch.length >= config.batch.default) { | ||
if (batch.length >= config.batch) { | ||
await processBatch({ config, cmd, files: batch, pkg, tokens }) | ||
@@ -35,0 +33,0 @@ batch = [] |
@@ -9,3 +9,3 @@ import { findImport } from './findImport.js' | ||
* config: { | ||
* babelPlugins: Set<string> | ||
* babelPlugins: Array<string> | ||
* } | ||
@@ -12,0 +12,0 @@ * pkg: { |
@@ -10,3 +10,3 @@ import { parse } from '@babel/parser' | ||
* config: { | ||
* babelPlugins: Set<string> | ||
* babelPlugins: Array<string> | ||
* } | ||
@@ -23,3 +23,3 @@ * pkg: { | ||
sourceType: 'module', | ||
plugins: [...config.babelPlugins] | ||
plugins: config.babelPlugins | ||
}) | ||
@@ -26,0 +26,0 @@ |
@@ -6,4 +6,4 @@ import { join } from 'node:path' | ||
const BASE_CONFIG = { | ||
babelPlugins: new Set(['typescript']), | ||
batch: { default: 100 }, | ||
babelPlugins: ['typescript'], | ||
batch: 100, | ||
collectUsages: null, | ||
@@ -19,4 +19,7 @@ entry: 'index.ts', | ||
--entry, -e path to the package index file. relative to the package directory | ||
--exclude, -i list of directories that will be excluded when searching for imports | ||
--extensions, -x list of file extensions to be considered during the search | ||
--babel-plugins, -p list of babel plugins that will be used when parsing files | ||
--batch, -b number of files to be traversed in parallel | ||
--collect-usages, -u outputs a list of all unique uses of the package | ||
--extensions , -x list of file extensions to be considered during the search | ||
`, | ||
@@ -29,3 +32,6 @@ { | ||
entry: { type: 'string', shortFlag: 'e' }, | ||
exclude: { type: 'string', shortFlag: 'i' }, | ||
extensions: { type: 'string', shortFlag: 'x' }, | ||
babelPlugins: { type: 'string', shortFlag: 'p' }, | ||
batch: { type: 'number', shortFlag: 'b' }, | ||
collectUsages: { type: 'string', shortFlag: 'u' } | ||
@@ -48,5 +54,5 @@ } | ||
exclude = [], | ||
babelPlugins = [], | ||
babelPlugins = BASE_CONFIG.babelPlugins, | ||
entry = BASE_CONFIG.entry, | ||
batch = {}, | ||
batch = BASE_CONFIG.batch, | ||
extensions = BASE_CONFIG.extensions | ||
@@ -59,7 +65,9 @@ } = result.config | ||
entry: cli.flags.entry || entry, | ||
exclude: new Set([...BASE_CONFIG.exclude, ...exclude]), | ||
babelPlugins: new Set([...BASE_CONFIG.babelPlugins, ...babelPlugins]), | ||
batch: { | ||
default: batch.default || BASE_CONFIG.batch.defaul | ||
}, | ||
exclude: cli.flags.exclude | ||
? new Set([...BASE_CONFIG.exclude, ...cli.flags.exclude.split(',')]) | ||
: new Set([...BASE_CONFIG.exclude, ...exclude]), | ||
babelPlugins: cli.flags.babelPlugins | ||
? cli.flags.babelPlugins.split(',') | ||
: babelPlugins, | ||
batch: cli.flags.batch || batch, | ||
collectUsages: cli.flags.collectUsages || BASE_CONFIG.collectUsages, | ||
@@ -66,0 +74,0 @@ extensions: cli.flags.extensions |
@@ -9,3 +9,3 @@ import { join } from 'node:path' | ||
* config: { | ||
* babelPlugins: Set<string> | ||
* babelPlugins: Array<string> | ||
* entry: string | ||
@@ -26,3 +26,3 @@ * } | ||
sourceType: 'module', | ||
plugins: [...config.babelPlugins] | ||
plugins: config.babelPlugins | ||
}) | ||
@@ -29,0 +29,0 @@ |
@@ -8,6 +8,4 @@ import { getExports } from './getExports.js' | ||
* config: { | ||
* babelPlugins: Set<string> | ||
* batch: { | ||
* default: number | ||
* } | ||
* babelPlugins: Array<string> | ||
* batch: number | ||
* entry: string | ||
@@ -14,0 +12,0 @@ * exclude: Set<string> |
{ | ||
"name": "pure-index", | ||
"type": "module", | ||
"version": "0.0.28", | ||
"version": "0.0.29", | ||
"description": "Utility for monorepos. It helps to find unused exports from packages or get a list of all unique uses of any package", | ||
@@ -6,0 +6,0 @@ "main": "./bin/index.js", |
@@ -62,5 +62,3 @@ # 🌿 Pure Index | ||
"babelPlugins": ["typescript"], | ||
"batch": { | ||
"default": 100 | ||
} | ||
"batch": 100 | ||
} | ||
@@ -77,5 +75,3 @@ ``` | ||
"babelPlugins": ["typescript"], | ||
"batch": { | ||
"default": 100 | ||
} | ||
"batch": 100 | ||
} | ||
@@ -92,5 +88,3 @@ ``` | ||
babelPlugins: ['typescript'], | ||
batch: { | ||
default: 100 | ||
} | ||
batch: 100 | ||
} | ||
@@ -102,6 +96,6 @@ ``` | ||
- `entry (String)` — path to the package index file. relative to the package directory. | ||
- `extensions (Array<string>)` — list of file extensions to be considered during the search. | ||
- `exclude (Array<string>)` — list of directories that will be excluded when searching for imports. | ||
- `extensions (Array<string>)` — list of file extensions to be considered during the search. | ||
- `babelPlugins (Array<string>)` — list of babel plugins that will be used when parsing files. | ||
- `batch.default (Number)` — number of files to be traversed in parallel. changing the value may speed up or slow down the script. choose the value yourself. | ||
- `batch (Number)` — number of files to be traversed in parallel. Changing the value may speed up or slow down the script. Choose the value yourself. | ||
@@ -134,2 +128,35 @@ ## CLI | ||
### `--exclude, -i` | ||
```diff | ||
"scripts": { | ||
"build": "webpack ./webpack.config.js", | ||
- "check-exports": "pure-index", | ||
+ "check-exports": "pure-index --exclude .cache,www/assets", | ||
"test": "vitest" | ||
} | ||
``` | ||
### `--babel-plugins, -p` | ||
```diff | ||
"scripts": { | ||
"build": "webpack ./webpack.config.js", | ||
- "check-exports": "pure-index", | ||
+ "check-exports": "pure-index --babel-plugins typescript,classPrivateProperties", | ||
"test": "vitest" | ||
} | ||
``` | ||
### `--batch, -b` | ||
```diff | ||
"scripts": { | ||
"build": "webpack ./webpack.config.js", | ||
- "check-exports": "pure-index", | ||
+ "check-exports": "pure-index --batch 500", | ||
"test": "vitest" | ||
} | ||
``` | ||
### `--collect-usages, -u` | ||
@@ -136,0 +163,0 @@ |
28159
38
632
200