knip 4.5.0 → 4.6.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/dist/plugins/husky/index.js +18 -3
- package/dist/util/git.d.ts +1 -1
- package/dist/util/git.js +2 -2
- package/package.json +6 -4
|
@@ -1,15 +1,30 @@
|
|
|
1
|
+
import semver from 'semver';
|
|
1
2
|
import { getGitHookPaths } from '../../util/git.js';
|
|
2
3
|
import { timerify } from '../../util/Performance.js';
|
|
3
4
|
import { getDependenciesFromScripts, hasDependency, loadFile } from '../../util/plugin.js';
|
|
4
5
|
const NAME = 'husky';
|
|
5
6
|
const ENABLERS = ['husky'];
|
|
6
7
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
7
|
-
const
|
|
8
|
-
const
|
|
8
|
+
const gitHooksPathInV8 = getGitHookPaths('.husky', true);
|
|
9
|
+
const gitHookPathsInV9 = getGitHookPaths('.husky', false);
|
|
10
|
+
const CONFIG_FILE_PATTERNS = [...gitHooksPathInV8, ...gitHookPathsInV9];
|
|
9
11
|
const findHuskyDependencies = async (configFilePath, options) => {
|
|
10
|
-
const { isProduction } = options;
|
|
12
|
+
const { isProduction, manifest } = options;
|
|
11
13
|
if (isProduction)
|
|
12
14
|
return [];
|
|
15
|
+
const huskyVersion = manifest.devDependencies?.husky ?? manifest.dependencies?.husky ?? '*';
|
|
16
|
+
const isV8OrLower = semver.intersects(huskyVersion, '<9', {
|
|
17
|
+
includePrerelease: true,
|
|
18
|
+
});
|
|
19
|
+
if (!isV8OrLower && gitHooksPathInV8.some(path => configFilePath.includes(path))) {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
const isV9OrHigher = semver.intersects(huskyVersion, '>=9', {
|
|
23
|
+
includePrerelease: true,
|
|
24
|
+
});
|
|
25
|
+
if (!isV9OrHigher && gitHookPathsInV9.some(path => configFilePath.includes(path))) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
13
28
|
const script = await loadFile(configFilePath);
|
|
14
29
|
if (!script)
|
|
15
30
|
return [];
|
package/dist/util/git.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getGitHookPaths: (defaultPath?: string) => string[];
|
|
1
|
+
export declare const getGitHookPaths: (defaultPath?: string, followGitConfig?: boolean) => string[];
|
package/dist/util/git.js
CHANGED
|
@@ -14,7 +14,7 @@ const getGitHooksPath = (defaultPath = '.git/hooks') => {
|
|
|
14
14
|
return defaultPath;
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
|
-
export const getGitHookPaths = (defaultPath = '.git/hooks') => {
|
|
18
|
-
const gitHooksPath = getGitHooksPath(defaultPath);
|
|
17
|
+
export const getGitHookPaths = (defaultPath = '.git/hooks', followGitConfig = true) => {
|
|
18
|
+
const gitHooksPath = followGitConfig ? getGitHooksPath(defaultPath) : defaultPath;
|
|
19
19
|
return hookFileNames.map(fileName => join(gitHooksPath, fileName));
|
|
20
20
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.0",
|
|
4
4
|
"description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
|
|
5
5
|
"homepage": "https://knip.dev",
|
|
6
6
|
"repository": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"lint": "eslint scripts src test",
|
|
37
37
|
"lint:fix": "eslint scripts src test --fix",
|
|
38
38
|
"format": "prettier scripts src test schema.json schema-jsonc.json --with-node-modules --write",
|
|
39
|
-
"pretest": "node rmdir.js tmp && swc src -d tmp
|
|
39
|
+
"pretest": "node rmdir.js tmp && swc src -d tmp && swc test -d tmp",
|
|
40
40
|
"test": "node --no-warnings --test tmp",
|
|
41
41
|
"coverage": "c8 --reporter html node --no-warnings --import tsx --test test/*.test.ts test/*/*.test.ts",
|
|
42
42
|
"watch": "npm link && tsc --watch",
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"picocolors": "1.0.0",
|
|
71
71
|
"picomatch": "4.0.1",
|
|
72
72
|
"pretty-ms": "9.0.0",
|
|
73
|
+
"semver": "7.6.0",
|
|
73
74
|
"smol-toml": "1.1.4",
|
|
74
75
|
"strip-json-comments": "5.0.1",
|
|
75
76
|
"summary": "2.1.0",
|
|
@@ -84,20 +85,21 @@
|
|
|
84
85
|
"@jest/types": "29.6.3",
|
|
85
86
|
"@knip/eslint-config": "0.0.0",
|
|
86
87
|
"@release-it/bumper": "^6.0.1",
|
|
87
|
-
"@swc/cli": "^0.
|
|
88
|
+
"@swc/cli": "^0.3.9",
|
|
88
89
|
"@swc/core": "^1.4.0",
|
|
89
90
|
"@types/js-yaml": "^4.0.9",
|
|
90
91
|
"@types/micromatch": "^4.0.6",
|
|
91
92
|
"@types/minimist": "^1.2.5",
|
|
92
93
|
"@types/npmcli__map-workspaces": "^3.0.4",
|
|
93
94
|
"@types/npmcli__package-json": "^4.0.3",
|
|
95
|
+
"@types/semver": "7.5.6",
|
|
94
96
|
"@types/webpack": "^5.28.5",
|
|
95
97
|
"c8": "9.1.0",
|
|
96
98
|
"eslint": "^8.56.0",
|
|
97
99
|
"playwright": "^1.41.2",
|
|
98
100
|
"prettier": "^3.2.5",
|
|
99
101
|
"release-it": "^17.0.3",
|
|
100
|
-
"tsx": "^4.7.
|
|
102
|
+
"tsx": "^4.7.1",
|
|
101
103
|
"type-fest": "^4.10.2",
|
|
102
104
|
"typescript": "5.3.3"
|
|
103
105
|
},
|