Socket
Socket
Sign inDemoInstall

pure-index

Package Overview
Dependencies
7
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.38 to 0.0.39

21

bin/index.js

@@ -6,2 +6,8 @@ #!/usr/bin/env node

import { baseFlow } from '../src/baseFlow.js'
import {
createStatusAPI,
printSet,
printError,
createSpinner
} from '../src/utils/index.js'

@@ -11,5 +17,18 @@ const config = await getConfig()

if (config.collectUsages) {
await collectUsages({ config })
const pkgName = config.collectUsages
const spinner = createSpinner(`Collecting usages of ${pkgName}`)
const result = await collectUsages({ config })
if (result.success) {
spinner.success()
printSet(result.value.usages)
process.exit(0)
}
spinner.error()
printError(`Nothing is used from ${pkgName}. Remove it.`)
process.exit(1)
}
await baseFlow({ config })

2

package.json
{
"name": "pure-index",
"type": "module",
"version": "0.0.38",
"version": "0.0.39",
"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": "./src/index.js",

import { fileTraversal } from './fileTraversal/index.js'
import { createStatusAPI } from './utils/index.js'
import { Result } from './utils/index.js'

@@ -15,10 +15,5 @@ /**

* }}
*
* @returns {Promise<void>}
*/
const collectUsages = async ({ config }) => {
const pkg = { name: config.collectUsages, path: '' }
const statusApi = createStatusAPI({
title: `Collecting usages of ${pkg.name}`
})
const usages = new Set()

@@ -28,11 +23,5 @@

if (usages.size === 0) {
statusApi.failed({
msg: `Nothing is used from ${pkg.name}. Remove it.`
})
}
statusApi.succeed({ set: usages })
return usages.size === 0 ? Result.Err({ usages }) : Result.Ok({ usages })
}
export { collectUsages }
import { baseFlow } from './baseFlow.js'
import { collectUsages } from './collectUsages.js'

@@ -19,3 +20,3 @@ /**

*/
const find = ({ config }) => {
const find = async ({ config }) => {
const unusedExports = new Set()

@@ -39,2 +40,15 @@

const findUsages = ({ config, list }) => {
const tasks = list.map(x =>
collectUsages({
...config,
...x
})
)
const result = await Promise.all(tasks)
console.log(result)
}
export { find }

@@ -47,5 +47,6 @@ import fs from 'node:fs/promises'

export { readFile, readJSON, createStatusAPI }
export { readFile, readJSON, createStatusAPI, printSet, printError }
export { getRepoRoot } from './getRepoRoot.js'
export { ObservableSet } from './observableSet.js'
export { Result } from './result.js'
export { createSpinner } from 'nanospinner'
class Result {
constructor(isSuccess, value, error) {
this.isSuccess = isSuccess
constructor(success, value, error) {
this.success = success
this.value = value

@@ -5,0 +5,0 @@ this.error = error

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc