knip 5.44.2 → 5.44.4
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/ConfigurationChief.js +3 -2
- package/dist/ProjectPrincipal.d.ts +1 -1
- package/dist/ProjectPrincipal.js +2 -2
- package/dist/graph/build.js +2 -2
- package/dist/util/create-workspace-graph.d.ts +2 -7
- package/dist/util/create-workspace-graph.js +4 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
1
2
|
import picomatch from 'picomatch';
|
|
2
3
|
import { partitionCompilers } from './compilers/index.js';
|
|
3
4
|
import { DEFAULT_EXTENSIONS, KNIP_CONFIG_LOCATIONS, ROOT_WORKSPACE_NAME } from './constants.js';
|
|
@@ -14,7 +15,7 @@ import { defaultRules } from './util/issue-initializers.js';
|
|
|
14
15
|
import { _load } from './util/loader.js';
|
|
15
16
|
import mapWorkspaces from './util/map-workspaces.js';
|
|
16
17
|
import { getKeysByValue } from './util/object.js';
|
|
17
|
-
import { join, relative
|
|
18
|
+
import { join, relative } from './util/path.js';
|
|
18
19
|
import { normalizePluginConfig } from './util/plugin.js';
|
|
19
20
|
import { toRegexOrString } from './util/regex.js';
|
|
20
21
|
import { unwrapFunction } from './util/unwrap-function.js';
|
|
@@ -205,7 +206,7 @@ export class ConfigurationChief {
|
|
|
205
206
|
}
|
|
206
207
|
getIncludedWorkspaces() {
|
|
207
208
|
if (this.workspace) {
|
|
208
|
-
const dir = resolve(this.workspace);
|
|
209
|
+
const dir = path.resolve(this.cwd, this.workspace);
|
|
209
210
|
if (!isDirectory(dir))
|
|
210
211
|
throw new ConfigurationError('Workspace is not a directory');
|
|
211
212
|
if (!isFile(join(dir, 'package.json')))
|
|
@@ -50,7 +50,7 @@ export declare class ProjectPrincipal {
|
|
|
50
50
|
getUsedResolvedFiles(): string[];
|
|
51
51
|
private getProgramSourceFiles;
|
|
52
52
|
getUnreferencedFiles(): string[];
|
|
53
|
-
analyzeSourceFile(filePath: string, options: Omit<GetImportsAndExportsOptions, 'skipExports'>, isGitIgnored: (filePath: string) => boolean,
|
|
53
|
+
analyzeSourceFile(filePath: string, options: Omit<GetImportsAndExportsOptions, 'skipExports'>, isGitIgnored: (filePath: string) => boolean, isInternalWorkspace: (packageName: string) => boolean, getPrincipalByFilePath: (filePath: string) => undefined | ProjectPrincipal): FileNode;
|
|
54
54
|
invalidateFile(filePath: string): void;
|
|
55
55
|
findUnusedMembers(filePath: string, members: ExportMember[]): ExportMember[];
|
|
56
56
|
hasExternalReferences(filePath: string, exportedItem: Export): boolean;
|
package/dist/ProjectPrincipal.js
CHANGED
|
@@ -143,7 +143,7 @@ export class ProjectPrincipal {
|
|
|
143
143
|
const sourceFiles = this.getProgramSourceFiles();
|
|
144
144
|
return Array.from(this.projectPaths).filter(filePath => !sourceFiles.has(filePath));
|
|
145
145
|
}
|
|
146
|
-
analyzeSourceFile(filePath, options, isGitIgnored,
|
|
146
|
+
analyzeSourceFile(filePath, options, isGitIgnored, isInternalWorkspace, getPrincipalByFilePath) {
|
|
147
147
|
const fd = this.cache.getFileDescriptor(filePath);
|
|
148
148
|
if (!fd.changed && fd.meta?.data)
|
|
149
149
|
return fd.meta.data;
|
|
@@ -160,7 +160,7 @@ export class ProjectPrincipal {
|
|
|
160
160
|
const unresolvedImports = new Set();
|
|
161
161
|
for (const [specifier, specifierFilePath] of specifiers) {
|
|
162
162
|
const packageName = getPackageNameFromModuleSpecifier(specifier);
|
|
163
|
-
if (packageName &&
|
|
163
|
+
if (packageName && isInternalWorkspace(packageName)) {
|
|
164
164
|
external.add(packageName);
|
|
165
165
|
const principal = getPrincipalByFilePath(specifierFilePath);
|
|
166
166
|
if (principal && !isGitIgnored(specifierFilePath))
|
package/dist/graph/build.js
CHANGED
|
@@ -172,7 +172,7 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
172
172
|
const analyzedFiles = new Set();
|
|
173
173
|
const unreferencedFiles = new Set();
|
|
174
174
|
const entryPaths = new Set();
|
|
175
|
-
const
|
|
175
|
+
const isInternalWorkspace = (packageName) => chief.availableWorkspacePkgNames.has(packageName);
|
|
176
176
|
const getPrincipalByFilePath = (filePath) => {
|
|
177
177
|
const workspace = chief.findWorkspaceByFilePath(filePath);
|
|
178
178
|
if (workspace)
|
|
@@ -191,7 +191,7 @@ export async function build({ cacheLocation, chief, collector, cwd, deputy, fact
|
|
|
191
191
|
ignoreExportsUsedInFile: chief.config.ignoreExportsUsedInFile,
|
|
192
192
|
isReportClassMembers,
|
|
193
193
|
tags,
|
|
194
|
-
}, isGitIgnored,
|
|
194
|
+
}, isGitIgnored, isInternalWorkspace, getPrincipalByFilePath);
|
|
195
195
|
const node = getOrCreateFileNode(graph, filePath);
|
|
196
196
|
node.imports = imports;
|
|
197
197
|
node.exports = exports;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
interface Package {
|
|
3
|
-
manifest: PackageJson;
|
|
4
|
-
dir: string;
|
|
5
|
-
}
|
|
1
|
+
import type { WorkspacePackage } from '../types/package-json.js';
|
|
6
2
|
export type WorkspaceGraph = Record<string, Set<string>>;
|
|
7
|
-
export declare function createWorkspaceGraph(cwd: string, wsNames: string[], wsPkgNames: Set<string>, wsPackages: Map<string,
|
|
8
|
-
export {};
|
|
3
|
+
export declare function createWorkspaceGraph(cwd: string, wsNames: string[], wsPkgNames: Set<string>, wsPackages: Map<string, WorkspacePackage>): WorkspaceGraph;
|
|
@@ -2,13 +2,14 @@ import { join } from './path.js';
|
|
|
2
2
|
const types = ['peerDependencies', 'devDependencies', 'optionalDependencies', 'dependencies'];
|
|
3
3
|
export function createWorkspaceGraph(cwd, wsNames, wsPkgNames, wsPackages) {
|
|
4
4
|
const graph = {};
|
|
5
|
-
const
|
|
5
|
+
const packages = Array.from(wsPackages.values());
|
|
6
|
+
const getWorkspaceDirs = (pkg) => {
|
|
6
7
|
const dirs = new Set();
|
|
7
8
|
for (const type of types) {
|
|
8
9
|
if (pkg.manifest[type]) {
|
|
9
10
|
for (const pkgName in pkg.manifest[type]) {
|
|
10
11
|
if (wsPkgNames.has(pkgName)) {
|
|
11
|
-
const wsPackage =
|
|
12
|
+
const wsPackage = packages.find(pkg => pkg.pkgName === pkgName);
|
|
12
13
|
if (wsPackage)
|
|
13
14
|
dirs.add(wsPackage.dir);
|
|
14
15
|
}
|
|
@@ -20,7 +21,7 @@ export function createWorkspaceGraph(cwd, wsNames, wsPkgNames, wsPackages) {
|
|
|
20
21
|
for (const name of wsNames) {
|
|
21
22
|
const pkg = wsPackages.get(name);
|
|
22
23
|
if (pkg)
|
|
23
|
-
graph[join(cwd, name)] = getWorkspaceDirs(pkg
|
|
24
|
+
graph[join(cwd, name)] = getWorkspaceDirs(pkg);
|
|
24
25
|
}
|
|
25
26
|
return graph;
|
|
26
27
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.44.
|
|
1
|
+
export declare const version = "5.44.4";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.44.
|
|
1
|
+
export const version = '5.44.4';
|