knip 3.7.1 → 3.8.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/cli.js +2 -1
- package/dist/index.js +1 -1
- package/dist/util/Performance.d.ts +7 -1
- package/dist/util/Performance.js +24 -4
- package/dist/util/cli-arguments.d.ts +1 -1
- package/dist/util/cli-arguments.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -52,7 +52,8 @@ const run = async () => {
|
|
|
52
52
|
if (isObservePerf) {
|
|
53
53
|
await perfObserver.finalize();
|
|
54
54
|
console.log('\n' + perfObserver.getTable());
|
|
55
|
-
|
|
55
|
+
const mem = Math.round((perfObserver.getMemHeapUsage() / 1024 / 1024) * 100) / 100;
|
|
56
|
+
console.log('\nTotal running time:', prettyMilliseconds(perfObserver.getTotalTime()), `(mem: ${mem}MB)`);
|
|
56
57
|
perfObserver.reset();
|
|
57
58
|
}
|
|
58
59
|
if (!noExitCode && totalErrorCount > Number(maxIssues)) {
|
package/dist/index.js
CHANGED
|
@@ -183,7 +183,7 @@ export const main = async (unresolvedConfiguration) => {
|
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
const principals = factory.getPrincipals();
|
|
186
|
-
debugLog('*', `
|
|
186
|
+
debugLog('*', `Created ${principals.length} programs for ${workspaces.length} workspaces`);
|
|
187
187
|
const analyzedFiles = new Set();
|
|
188
188
|
const exportedSymbols = new Map();
|
|
189
189
|
const importedSymbols = new Map();
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
3
|
import { PerformanceObserver, PerformanceEntry } from 'node:perf_hooks';
|
|
4
|
+
import { memoryUsage } from 'node:process';
|
|
3
5
|
import type { TimerifyOptions } from 'node:perf_hooks';
|
|
4
6
|
type Timerify = <T extends (...params: any[]) => any>(fn: T, options?: TimerifyOptions) => T;
|
|
5
7
|
export declare const timerify: Timerify;
|
|
@@ -9,7 +11,10 @@ export declare class Performance {
|
|
|
9
11
|
endTime: number;
|
|
10
12
|
entries: PerformanceEntry[];
|
|
11
13
|
instanceId?: number;
|
|
12
|
-
|
|
14
|
+
fnObserver?: PerformanceObserver;
|
|
15
|
+
gcObserver?: PerformanceObserver;
|
|
16
|
+
memoryUsageStart?: ReturnType<typeof memoryUsage>;
|
|
17
|
+
memoryUsageEnd?: ReturnType<typeof memoryUsage>;
|
|
13
18
|
constructor(isEnabled: boolean);
|
|
14
19
|
private setMark;
|
|
15
20
|
private clearMark;
|
|
@@ -17,6 +22,7 @@ export declare class Performance {
|
|
|
17
22
|
private getEntriesByName;
|
|
18
23
|
getTable(): string;
|
|
19
24
|
getTotalTime(): number;
|
|
25
|
+
getMemHeapUsage(): number;
|
|
20
26
|
finalize(): Promise<void>;
|
|
21
27
|
reset(): void;
|
|
22
28
|
}
|
package/dist/util/Performance.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { performance, PerformanceObserver, PerformanceEntry } from 'node:perf_hooks';
|
|
2
|
+
import { constants } from 'node:perf_hooks';
|
|
3
|
+
import { memoryUsage } from 'node:process';
|
|
2
4
|
import EasyTable from 'easy-table';
|
|
5
|
+
import prettyMilliseconds from 'pretty-ms';
|
|
3
6
|
import Summary from 'summary';
|
|
4
7
|
import parsedArgValues from './cli-arguments.js';
|
|
8
|
+
import { debugLog } from './debug.js';
|
|
5
9
|
const { performance: isEnabled = false } = parsedArgValues;
|
|
6
10
|
export const timerify = fn => (isEnabled ? performance.timerify(fn) : fn);
|
|
7
11
|
export class Performance {
|
|
@@ -10,17 +14,29 @@ export class Performance {
|
|
|
10
14
|
endTime = 0;
|
|
11
15
|
entries = [];
|
|
12
16
|
instanceId;
|
|
13
|
-
|
|
17
|
+
fnObserver;
|
|
18
|
+
gcObserver;
|
|
19
|
+
memoryUsageStart;
|
|
20
|
+
memoryUsageEnd;
|
|
14
21
|
constructor(isEnabled) {
|
|
15
22
|
if (isEnabled) {
|
|
16
23
|
this.startTime = performance.now();
|
|
17
24
|
this.instanceId = Math.floor(performance.now() * 100);
|
|
18
|
-
this.
|
|
25
|
+
this.fnObserver = new PerformanceObserver(items => {
|
|
19
26
|
items.getEntries().forEach(entry => {
|
|
20
27
|
this.entries.push(entry);
|
|
21
28
|
});
|
|
22
29
|
});
|
|
23
|
-
this.
|
|
30
|
+
this.fnObserver.observe({ entryTypes: ['function'] });
|
|
31
|
+
this.gcObserver = new PerformanceObserver(items => {
|
|
32
|
+
for (const item of items.getEntries()) {
|
|
33
|
+
if (item.detail?.kind === constants.NODE_PERFORMANCE_GC_MAJOR) {
|
|
34
|
+
debugLog('*', `GC (after ${prettyMilliseconds(item.startTime)} in ${prettyMilliseconds(item.duration)})`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
this.gcObserver.observe({ entryTypes: ['gc'] });
|
|
39
|
+
this.memoryUsageStart = memoryUsage();
|
|
24
40
|
}
|
|
25
41
|
this.isEnabled = isEnabled;
|
|
26
42
|
}
|
|
@@ -67,14 +83,18 @@ export class Performance {
|
|
|
67
83
|
getTotalTime() {
|
|
68
84
|
return this.endTime - this.startTime;
|
|
69
85
|
}
|
|
86
|
+
getMemHeapUsage() {
|
|
87
|
+
return (this.memoryUsageEnd?.heapUsed ?? 0) - (this.memoryUsageStart?.heapUsed ?? 0);
|
|
88
|
+
}
|
|
70
89
|
async finalize() {
|
|
71
90
|
if (!this.isEnabled)
|
|
72
91
|
return;
|
|
73
92
|
this.endTime = performance.now();
|
|
93
|
+
this.memoryUsageEnd = memoryUsage();
|
|
74
94
|
await this.flush();
|
|
75
95
|
}
|
|
76
96
|
reset() {
|
|
77
97
|
this.entries = [];
|
|
78
|
-
this.
|
|
98
|
+
this.fnObserver?.disconnect();
|
|
79
99
|
}
|
|
80
100
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const helpText = "\u2702\uFE0F Find unused files, dependencies and exports in your JavaScript and TypeScript projects\n\nUsage: knip [options]\n\nOptions:\n -c, --config [file] Configuration file path (default: [.]knip.json[c], knip.js, knip.ts or package.json#knip)\n -t, --tsConfig [file] TypeScript configuration path (default: tsconfig.json)\n --production Analyze only production source files (e.g. no tests, devDependencies, exported types)\n --strict Consider only direct dependencies of workspace (not devDependencies, not other workspaces)\n -W, --workspace [dir] Analyze a single workspace (default: analyze all configured workspaces)\n --directory [dir] Run process from a different directory (default: cwd)\n --no-gitignore Don't use .gitignore\n --include Report only provided issue type(s), can be comma-separated or repeated (1)\n --exclude Exclude provided issue type(s) from report, can be comma-separated or repeated (1)\n --dependencies Shortcut for --include dependencies,unlisted,binaries,unresolved\n --exports Shortcut for --include exports,nsExports,classMembers,types,nsTypes,enumMembers,duplicates\n --fix Fix issues\n --fix-type Fix only issues of type, can be comma-separated or repeated (2)\n --include-entry-exports Include entry files when reporting unused exports\n --isolate-workspaces
|
|
1
|
+
export declare const helpText = "\u2702\uFE0F Find unused files, dependencies and exports in your JavaScript and TypeScript projects\n\nUsage: knip [options]\n\nOptions:\n -c, --config [file] Configuration file path (default: [.]knip.json[c], knip.js, knip.ts or package.json#knip)\n -t, --tsConfig [file] TypeScript configuration path (default: tsconfig.json)\n --production Analyze only production source files (e.g. no tests, devDependencies, exported types)\n --strict Consider only direct dependencies of workspace (not devDependencies, not other workspaces)\n -W, --workspace [dir] Analyze a single workspace (default: analyze all configured workspaces)\n --directory [dir] Run process from a different directory (default: cwd)\n --no-gitignore Don't use .gitignore\n --include Report only provided issue type(s), can be comma-separated or repeated (1)\n --exclude Exclude provided issue type(s) from report, can be comma-separated or repeated (1)\n --dependencies Shortcut for --include dependencies,unlisted,binaries,unresolved\n --exports Shortcut for --include exports,nsExports,classMembers,types,nsTypes,enumMembers,duplicates\n --fix Fix issues\n --fix-type Fix only issues of type, can be comma-separated or repeated (2)\n --include-entry-exports Include entry files when reporting unused exports\n --isolate-workspaces Isolate workspaces into separate programs (default: false)\n -n, --no-progress Don't show dynamic progress updates (automatically enabled in CI environments)\n --preprocessor Preprocess the results before providing it to the reporter(s), can be repeated\n --preprocessor-options Pass extra options to the preprocessor (as JSON string, see --reporter-options example)\n --reporter Select reporter: symbols, compact, codeowners, json, can be repeated (default: symbols)\n --reporter-options Pass extra options to the reporter (as JSON string, see example)\n --no-config-hints Suppress configuration hints\n --no-exit-code Always exit with code zero (0)\n --max-issues Maximum number of issues before non-zero exit code (default: 0)\n -d, --debug Show debug output\n --performance Measure count and running time of expensive functions and display stats table\n -h, --help Print this help text\n -V, --version Print version\n\n(1) Issue types: files, dependencies, unlisted, unresolved, exports, nsExports, classMembers, types, nsTypes, enumMembers, duplicates\n(2) Fixable issue types: dependencies, exports, types\n\nExamples:\n\n$ knip\n$ knip --production\n$ knip --workspace packages/client --include files,dependencies\n$ knip -c ./config/knip.json --reporter compact\n$ knip --reporter codeowners --reporter-options '{\"path\":\".github/CODEOWNERS\"}'\n\nWebsite: https://knip.dev";
|
|
2
2
|
declare const _default: {
|
|
3
3
|
config: string | undefined;
|
|
4
4
|
debug: boolean | undefined;
|
|
@@ -18,7 +18,7 @@ Options:
|
|
|
18
18
|
--fix Fix issues
|
|
19
19
|
--fix-type Fix only issues of type, can be comma-separated or repeated (2)
|
|
20
20
|
--include-entry-exports Include entry files when reporting unused exports
|
|
21
|
-
--isolate-workspaces
|
|
21
|
+
--isolate-workspaces Isolate workspaces into separate programs (default: false)
|
|
22
22
|
-n, --no-progress Don't show dynamic progress updates (automatically enabled in CI environments)
|
|
23
23
|
--preprocessor Preprocess the results before providing it to the reporter(s), can be repeated
|
|
24
24
|
--preprocessor-options Pass extra options to the preprocessor (as JSON string, see --reporter-options example)
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "3.
|
|
1
|
+
export declare const version = "3.8.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '3.
|
|
1
|
+
export const version = '3.8.0';
|