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.
- package/LICENSE +1 -1
- package/README.md +3 -0
- package/index.js +18 -14
- package/package.json +3 -3
package/LICENSE
CHANGED
package/README.md
CHANGED
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(
|
|
16
|
+
const packageJsonPath = findClosestPkgJsonPath(cwd)
|
|
15
17
|
if (!packageJsonPath) {
|
|
16
|
-
console.error(`No closest package.json found from ${
|
|
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(
|
|
27
|
+
const packageJsonPaths = findNestedPkgJsonPathsFromDir(cwd)
|
|
26
28
|
if (!packageJsonPaths.length) {
|
|
27
|
-
console.error(`No nested package.json found from ${
|
|
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(
|
|
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": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "Bjorn Lu",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"bin": "
|
|
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
|
+
}
|