ihimnm 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +3 -0
  3. package/index.js +18 -14
  4. package/package.json +3 -3
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Bjorn Lu
3
+ Copyright (c) 2025 Bjorn Lu
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -11,6 +11,9 @@ npx ihimnm
11
11
  # Search nested package.json files and find deps matching the criteria
12
12
  # (useful for monorepos)
13
13
  npx ihimnm -r
14
+
15
+ # In case there's someone else you want to look for
16
+ npx ihimnm -u <npm-username>
14
17
  ```
15
18
 
16
19
  ## License
package/index.js CHANGED
@@ -3,17 +3,19 @@
3
3
  import fs from 'node:fs'
4
4
  import path from 'node:path'
5
5
 
6
+ const user = getUser()
6
7
  const isRecursive = process.argv.includes('-r')
7
8
  const ignoredFileNameRe = /^(\.|node_modules|dist|build|output|cache)/
8
9
  const maxNestedDepth = 10
9
10
  /** @type {Map<string, number>} */
10
11
  const allFoundDeps = new Map()
12
+ const cwd = process.cwd()
11
13
 
12
14
  // If not recursive, use closest package.json
13
15
  if (!isRecursive) {
14
- const packageJsonPath = findClosestPkgJsonPath(process.cwd())
16
+ const packageJsonPath = findClosestPkgJsonPath(cwd)
15
17
  if (!packageJsonPath) {
16
- console.error(`No closest package.json found from ${process.cwd()}`)
18
+ console.error(`No closest package.json found from ${cwd}`)
17
19
  process.exit(1)
18
20
  }
19
21
 
@@ -22,9 +24,9 @@ if (!isRecursive) {
22
24
  }
23
25
  // If recursive, use nested package.json from cwd
24
26
  else {
25
- const packageJsonPaths = findNestedPkgJsonPathsFromDir(process.cwd())
27
+ const packageJsonPaths = findNestedPkgJsonPathsFromDir(cwd)
26
28
  if (!packageJsonPaths.length) {
27
- console.error(`No nested package.json found from ${process.cwd()}`)
29
+ console.error(`No nested package.json found from ${cwd}`)
28
30
  process.exit(1)
29
31
  }
30
32
 
@@ -42,9 +44,7 @@ if (allFoundDeps.size) {
42
44
  for (let i = 0; i < sortedDepNames.length; i++) {
43
45
  const depName = sortedDepNames[i]
44
46
  const numStr = dim(`${i + 1}.`.padStart(padNum))
45
- console.log(
46
- `${numStr} ${red(depName)} ${dim(`(${allFoundDeps.get(depName)})`)}`
47
- )
47
+ console.log(`${numStr} ${red(depName)} ${dim(`(${allFoundDeps.get(depName)})`)}`)
48
48
  }
49
49
  }
50
50
 
@@ -66,7 +66,7 @@ function crawlDependencies(pkgJsonPath, parentDepNames, isRoot = false) {
66
66
  // - from github url
67
67
  // - from contributors list
68
68
  // - from @.../eslint-config dev dep
69
- else if (pkgJsonContent.includes('ljharb')) {
69
+ else if (pkgJsonContent.includes(user)) {
70
70
  logDep(pkgJson.name, parentDepNames)
71
71
  found = true
72
72
  const foundCount = allFoundDeps.get(pkgJson.name) || 0
@@ -142,23 +142,27 @@ function findNestedPkgJsonPathsFromDir(dir, currentDepth = 0) {
142
142
  if (stat.isFile() && file === 'package.json') {
143
143
  pkgJsonPaths.push(filePath)
144
144
  } else if (stat.isDirectory() && currentDepth < maxNestedDepth) {
145
- pkgJsonPaths.push(
146
- ...findNestedPkgJsonPathsFromDir(filePath, currentDepth + 1)
147
- )
145
+ pkgJsonPaths.push(...findNestedPkgJsonPathsFromDir(filePath, currentDepth + 1))
148
146
  }
149
147
  }
150
148
  }
151
149
  return pkgJsonPaths
152
150
  }
153
151
 
152
+ function getUser() {
153
+ const userIndex = process.argv.indexOf('-u')
154
+ if (userIndex !== -1 && process.argv.length > userIndex + 1) {
155
+ return process.argv[userIndex + 1]
156
+ }
157
+ return atob('bGpoYXJi')
158
+ }
159
+
154
160
  /**
155
161
  * @param {string} depName
156
162
  * @param {string[]} parentPackageNames
157
163
  */
158
164
  function logDep(depName, parentPackageNames) {
159
- console.log(
160
- dim(parentPackageNames.map((n) => n + ' > ').join('')) + red(depName)
161
- )
165
+ console.log(dim(parentPackageNames.map((n) => n + ' > ').join('')) + red(depName))
162
166
  }
163
167
 
164
168
  /**
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "ihimnm",
3
- "version": "0.1.0",
3
+ "version": "1.0.0",
4
4
  "type": "module",
5
5
  "author": "Bjorn Lu",
6
6
  "license": "MIT",
7
- "bin": "./index.js",
7
+ "bin": "index.js",
8
8
  "files": ["index.js"],
9
9
  "funding": "https://bjornlu.com/sponsor",
10
10
  "repository": {
@@ -14,4 +14,4 @@
14
14
  "bugs": {
15
15
  "url": "https://github.com/bluwy/ihimnm/issues"
16
16
  }
17
- }
17
+ }