pure-index
Advanced tools
Comparing version 0.0.23 to 0.0.24
@@ -1,10 +0,4 @@ | ||
import { execSync } from 'node:child_process' | ||
import { join } from 'node:path' | ||
import fg from 'fast-glob' | ||
import { processBatch } from './processBatch/index.js' | ||
import { getFiles } from './getFiles.js' | ||
const getRepoRoot = () => | ||
execSync('git rev-parse --show-toplevel', { encoding: 'utf8' }).trim() | ||
/** | ||
@@ -29,15 +23,8 @@ * @param {{ | ||
const fileTraversal = async ({ config, pkg, cmd }) => { | ||
const files = await getFiles({ config, pkg }) | ||
const tokens = [`from '${pkg.name}'`, `from "${pkg.name}"`] | ||
const repoRoot = getRepoRoot() | ||
const source = join(repoRoot, '**', '*.{ts,tsx}') | ||
const ignore = [ | ||
...[...config.exclude].map(x => join('**', x, '**')), | ||
pkg.path ? join(pkg.path, '**') : '' | ||
] | ||
let batch = [] | ||
for await (const entry of fg.stream(source, { ignore })) { | ||
batch.push(entry) | ||
for (const file of files) { | ||
batch.push(file) | ||
@@ -44,0 +31,0 @@ if (batch.length >= config.batch.default) { |
@@ -17,2 +17,3 @@ import { join } from 'node:path' | ||
--entry, -e path to the package index file. relative to the package directory | ||
--collect-usages, -u outputs a list of all unique uses of the package | ||
`, | ||
@@ -19,0 +20,0 @@ { |
@@ -14,3 +14,5 @@ import cp from 'node:child_process' | ||
return promisify(cp.exec)(`${params.cmd} --prefix ${prefix}`) | ||
return promisify(cp.exec)( | ||
`${params.cmd} ${params.noPrefix ? '' : `--prefix ${prefix}`}` | ||
) | ||
} |
{ | ||
"name": "pure-index", | ||
"type": "module", | ||
"version": "0.0.23", | ||
"version": "0.0.24", | ||
"description": "Utility for monorepos. It helps to find unused exports from packages.", | ||
@@ -16,6 +16,7 @@ "main": "./bin/index.js", | ||
"babel-walk": "3.0.0", | ||
"fast-glob": "3.3.2", | ||
"fdir": "6.1.1", | ||
"lilconfig": "3.0.0", | ||
"meow": "13.0.0", | ||
"nanospinner": "1.1.0" | ||
"nanospinner": "1.1.0", | ||
"picomatch": "^3.0.1" | ||
}, | ||
@@ -22,0 +23,0 @@ "engines": { |
# 🌿 Pure Index | ||
Pure Index is utility for monorepos. It helps to find unused exports from packages. | ||
Pure Index is utility for monorepos. It helps to find unused exports from packages or get a list of all unique uses of any package. | ||
@@ -104,4 +104,6 @@ ## Motivation | ||
- `--entry, -e` — sets specific value for _entry_ | ||
### `--entry, -e` | ||
Sets specific value for _entry_ | ||
```diff | ||
@@ -116,2 +118,16 @@ "scripts": { | ||
### `--collect-usages, -u` | ||
Outputs a list of all unique uses of the package. | ||
```sh | ||
npx pure-index --collect-usages my-package | ||
npx pure-index -u my-package | ||
npx pure-index --collect-usages react-spring | ||
npx pure-index -u react-spring | ||
``` | ||
Useful if the package index file contains `export *` syntax. Or to search for all uses of an external package. [More info](#export-) | ||
## Tips | ||
@@ -140,1 +156,7 @@ | ||
3. there is an instant exit with success as soon as the size of _exports Set_ is equal to zero | ||
## Limitations | ||
### export \* | ||
Pure Index when getting a list of exports does not parse `export *` to find out what is exported from there. For projects with this syntax, it may result in an inability to use the library. But Pure Index can help with replacing `export *`. Just run it with the [--collect-usages flag](#--collect-usages--u) and replace `export *` with named exports. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22346
32
488
160
7
+ Addedfdir@6.1.1
+ Addedpicomatch@^3.0.1
+ Addedfdir@6.1.1(transitive)
+ Addedpicomatch@3.0.1(transitive)
- Removedfast-glob@3.3.2
- Removed@nodelib/fs.scandir@2.1.5(transitive)
- Removed@nodelib/fs.stat@2.0.5(transitive)
- Removed@nodelib/fs.walk@1.2.8(transitive)
- Removedbraces@3.0.3(transitive)
- Removedfast-glob@3.3.2(transitive)
- Removedfastq@1.17.1(transitive)
- Removedfill-range@7.1.1(transitive)
- Removedglob-parent@5.1.2(transitive)
- Removedis-extglob@2.1.1(transitive)
- Removedis-glob@4.0.3(transitive)
- Removedis-number@7.0.0(transitive)
- Removedmerge2@1.4.1(transitive)
- Removedmicromatch@4.0.8(transitive)
- Removedpicomatch@2.3.1(transitive)
- Removedqueue-microtask@1.2.3(transitive)
- Removedreusify@1.0.4(transitive)
- Removedrun-parallel@1.2.0(transitive)
- Removedto-regex-range@5.0.1(transitive)