Socket
Socket
Sign inDemoInstall

pure-index

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pure-index - npm Package Compare versions

Comparing version 0.0.32 to 0.0.33

bin/__tests__/__snapshots__/search-dir.test.js.snap

6

bin/__tests__/getConfig/cli.test.js

@@ -15,3 +15,4 @@ import { expect, test, mock, vi } from 'vitest'

babelPlugins: 'decorators-legacy,classPrivateProperties',
exclude: 'biba,boba,.cache,www/assets,__tests__'
exclude: 'biba,boba,.cache,www/assets,__tests__',
searchDir: 'dir-from-cli'
}

@@ -37,3 +38,4 @@ }))

'__tests__'
])
]),
searchDir: 'dir-from-cli'
})

@@ -40,0 +42,0 @@

@@ -15,3 +15,4 @@ import { expect, test, mock, vi } from 'vitest'

exclude: ['build'],
extensions: ['js', 'jsx']
extensions: ['js', 'jsx'],
searchDir: 'dir-from-cli'
}

@@ -30,3 +31,4 @@ })

babelPlugins: 'decorators-legacy,classPrivateProperties',
exclude: 'biba,boba,.cache,www/assets,__tests__'
exclude: 'biba,boba,.cache,www/assets,__tests__',
searchDir: 'dir-from-config'
}

@@ -52,3 +54,4 @@ }))

'__tests__'
])
]),
searchDir: 'dir-from-cli'
})

@@ -55,0 +58,0 @@

@@ -7,3 +7,4 @@ export const CONFIG = {

exclude: new Set(['node_modules']),
extensions: ['ts', 'tsx']
extensions: ['ts', 'tsx'],
searchDir: 'repo-root'
}

@@ -1,2 +0,2 @@

import { expect, test } from 'vitest'
import { expect, test, mock, vi } from 'vitest'

@@ -7,2 +7,6 @@ import { getConfig } from '../../getConfig.js'

test('default value', async () => {
vi.mock('../../../bin/utils/getRepoRoot.js', () => ({
getRepoRoot: () => 'repo-root'
}))
const config = await getConfig()

@@ -9,0 +13,0 @@

@@ -15,3 +15,4 @@ import { expect, test, mock, vi } from 'vitest'

exclude: ['build'],
extensions: ['js', 'jsx']
extensions: ['js', 'jsx'],
searchDir: 'dir-from-config'
}

@@ -30,3 +31,4 @@ })

extensions: ['js', 'jsx'],
exclude: new Set([...CONFIG.exclude, 'build'])
exclude: new Set([...CONFIG.exclude, 'build']),
searchDir: 'dir-from-config'
})

@@ -33,0 +35,0 @@

@@ -0,1 +1,2 @@

import { getRoot } from 'package-d'
import { createRoot } from 'react-dom/client'

@@ -5,2 +6,2 @@

createRoot(document.getElementById('root')).render(Component)
createRoot(getRoot()).render(Component)

@@ -1,3 +0,8 @@

const identity = <T>(x: T) => x
import { ususedFn } from 'package-d'
const identity = <T>(x: T) => {
ususedFn()
return x
}
export { identity }

@@ -12,2 +12,3 @@ import { fileTraversal } from './fileTraversal/index.js'

* extensions: Array<string>
* searchDir: string
* },

@@ -14,0 +15,0 @@ * }}

@@ -1,8 +0,4 @@

import { execSync } from 'node:child_process'
import { join } from 'node:path'
import { fdir } from 'fdir'
const getRepoRoot = () =>
execSync('git rev-parse --show-toplevel', { encoding: 'utf8' }).trim()
const formattedExtensions = list =>

@@ -16,2 +12,3 @@ list.reduce((acc, ext) => acc + (acc ? ',' : '') + ext, '')

* extensions: Array<string>
* searchDir: string
* }

@@ -37,3 +34,2 @@ * pkg: {

const excludeRegExp = new RegExp(exclude)
const repoRoot = getRepoRoot()
const source = join('**', `*.{${formattedExtensions(config.extensions)}}`)

@@ -45,3 +41,3 @@

.withFullPaths()
.crawl(repoRoot)
.crawl(config.searchDir)
.sync()

@@ -48,0 +44,0 @@

@@ -12,2 +12,3 @@ import { processBatch } from './processBatch/index.js'

* extensions: Array<string>
* searchDir: string
* }

@@ -14,0 +15,0 @@ * pkg: {

@@ -5,2 +5,4 @@ import { join } from 'node:path'

import { getRepoRoot } from './utils/index.js'
const BASE_CONFIG = {

@@ -11,2 +13,3 @@ babelPlugins: ['typescript'],

entry: 'index.ts',
searchDir: null,
exclude: new Set(['node_modules']),

@@ -22,2 +25,3 @@ extensions: ['ts', 'tsx']

--extensions, -x list of file extensions to be considered during the search
--search-dir, -s path to the directory where imports should be searched for
--babel-plugins, -p list of babel plugins that will be used when parsing files

@@ -35,2 +39,3 @@ --batch, -b number of files to be traversed in parallel

extensions: { type: 'string', shortFlag: 'x' },
searchDir: { type: 'string', shortFlag: 's' },
babelPlugins: { type: 'string', shortFlag: 'p' },

@@ -58,3 +63,4 @@ batch: { type: 'number', shortFlag: 'b' },

batch = BASE_CONFIG.batch,
extensions = BASE_CONFIG.extensions
extensions = BASE_CONFIG.extensions,
searchDir
} = result.config

@@ -76,3 +82,4 @@

? cli.flags.extensions.split(',')
: extensions
: extensions,
searchDir: cli.flags.searchDir || searchDir || getRepoRoot()
}

@@ -79,0 +86,0 @@ }

@@ -13,2 +13,3 @@ import { getExports } from './getExports.js'

* extensions: Array<string>
* searchDir: string
* },

@@ -15,0 +16,0 @@ * }}

@@ -26,3 +26,4 @@ import { join } from 'node:path'

if (set) {
process.stdout.write(`${JSON.stringify([...set], undefined, 2)} \n\n`)
const list = [...set]
process.stdout.write(`${JSON.stringify(list, undefined, 2)} \n\n`)
}

@@ -38,3 +39,4 @@

if (set) {
process.stdout.write(`${JSON.stringify([...set], undefined, 2)} \n\n`)
const list = [...set]
process.stdout.write(`${JSON.stringify(list, undefined, 2)} \n\n`)
}

@@ -49,2 +51,3 @@

export { readFile, readJSON, createStatusAPI }
export { getRepoRoot } from './getRepoRoot.js'
export { ObservableSet } from './observableSet.js'
{
"name": "pure-index",
"type": "module",
"version": "0.0.32",
"version": "0.0.33",
"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",

@@ -61,2 +61,3 @@ # 🌿 Pure Index

"extensions": ["ts", "tsx"],
"searchDir": "my-path",
"babelPlugins": ["typescript"],

@@ -74,2 +75,3 @@ "batch": 100

"extensions": ["ts", "tsx"],
"searchDir": "my-path",
"babelPlugins": ["typescript"],

@@ -87,2 +89,3 @@ "batch": 100

extensions: ['ts', 'tsx'],
searchDir: 'my-path',
babelPlugins: ['typescript'],

@@ -98,2 +101,3 @@ batch: 100

- `exclude (Array<string>)` — list of directories that will be excluded when searching for imports.
- `searchDir (String)` — path to the directory where imports should be searched for.
- `babelPlugins (Array<string>)` — list of babel plugins that will be used when parsing files.

@@ -108,2 +112,4 @@ - `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.

<details><summary><b>Show instructions</b></summary>
```diff

@@ -118,4 +124,8 @@ "scripts": {

</details>
### `--extensions, -x`
<details><summary><b>Show instructions</b></summary>
```diff

@@ -130,4 +140,8 @@ "scripts": {

</details>
### `--exclude, -i`
<details><summary><b>Show instructions</b></summary>
```diff

@@ -142,4 +156,23 @@ "scripts": {

</details>
### `--search-dir, -s`
<details><summary><b>Show instructions</b></summary>
```diff
"scripts": {
"build": "webpack ./webpack.config.js",
- "check-exports": "pure-index",
+ "check-exports": "pure-index --search-dir /Users/user/another-repo",
"test": "vitest"
}
```
</details>
### `--babel-plugins, -p`
<details><summary><b>Show instructions</b></summary>
```diff

@@ -154,4 +187,8 @@ "scripts": {

</details>
### `--batch, -b`
<details><summary><b>Show instructions</b></summary>
```diff

@@ -166,2 +203,4 @@ "scripts": {

</details>
### `--collect-usages, -u`

@@ -168,0 +207,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc