knip 6.44.2 → 6.45.1
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.d.ts +23 -1033
- package/dist/ConfigurationChief.js +71 -15
- package/dist/DependencyDeputy.d.ts +10 -6
- package/dist/DependencyDeputy.js +51 -27
- package/dist/IssueCollector.d.ts +14 -11
- package/dist/IssueCollector.js +25 -20
- package/dist/IssueFixer.js +1 -1
- package/dist/PackagePeeker.d.ts +6 -0
- package/dist/PackagePeeker.js +43 -14
- package/dist/ProjectPrincipal.d.ts +6 -3
- package/dist/ProjectPrincipal.js +83 -32
- package/dist/WorkspaceWorker.d.ts +5 -1
- package/dist/WorkspaceWorker.js +39 -22
- package/dist/binaries/bash-parser.js +1 -7
- package/dist/binaries/command.d.ts +3 -3
- package/dist/binaries/command.js +6 -2
- package/dist/binaries/fallback.js +1 -1
- package/dist/binaries/plugins.d.ts +4 -1
- package/dist/binaries/plugins.js +66 -18
- package/dist/binaries/resolvers/npm.js +7 -5
- package/dist/binaries/resolvers/npx.js +8 -40
- package/dist/binaries/util.d.ts +13 -1
- package/dist/binaries/util.js +35 -1
- package/dist/cli.js +10 -84
- package/dist/configuration-hints.d.ts +16 -0
- package/dist/configuration-hints.js +64 -0
- package/dist/constants.d.ts +2 -1
- package/dist/constants.js +2 -0
- package/dist/graph/SubpathReferences.d.ts +33 -0
- package/dist/graph/SubpathReferences.js +114 -0
- package/dist/graph/analyze.d.ts +4 -1
- package/dist/graph/analyze.js +16 -5
- package/dist/graph/build.d.ts +3 -1
- package/dist/graph/build.js +47 -23
- package/dist/graph-explorer/operations/resolve-export-origins.js +1 -1
- package/dist/plugins/angular/index.js +10 -17
- package/dist/plugins/aws-cdk/index.d.ts +3 -0
- package/dist/plugins/aws-cdk/index.js +32 -0
- package/dist/plugins/aws-cdk/types.d.ts +5 -0
- package/dist/plugins/aws-cdk/types.js +1 -0
- package/dist/plugins/babel/index.d.ts +1 -1
- package/dist/plugins/babel/index.js +19 -5
- package/dist/plugins/bun/index.js +8 -7
- package/dist/plugins/c8/index.js +17 -4
- package/dist/plugins/changesets/index.js +3 -2
- package/dist/plugins/commitizen/index.js +6 -3
- package/dist/plugins/commitlint/index.js +10 -11
- package/dist/plugins/cypress/index.js +4 -2
- package/dist/plugins/danger/index.js +1 -1
- package/dist/plugins/docusaurus/helpers.js +6 -6
- package/dist/plugins/docusaurus/index.js +2 -2
- package/dist/plugins/electron-forge/index.js +2 -2
- package/dist/plugins/electron-vite/index.js +2 -2
- package/dist/plugins/eleventy/index.js +3 -2
- package/dist/plugins/eslint/helpers.js +4 -3
- package/dist/plugins/eslint/resolveFromAST.js +2 -2
- package/dist/plugins/evalite/index.d.ts +3 -0
- package/dist/plugins/evalite/index.js +26 -0
- package/dist/plugins/flue/index.js +2 -2
- package/dist/plugins/github-action/index.js +2 -2
- package/dist/plugins/github-actions/index.js +2 -2
- package/dist/plugins/graphql-codegen/index.js +13 -9
- package/dist/plugins/index.d.ts +5 -0
- package/dist/plugins/index.js +10 -0
- package/dist/plugins/jest/index.js +5 -5
- package/dist/plugins/knex/index.js +2 -2
- package/dist/plugins/laravel-vite-plugin/resolveFromAST.js +2 -2
- package/dist/plugins/lunaria/index.js +5 -2
- package/dist/plugins/markdownlint/index.js +8 -2
- package/dist/plugins/marko/index.js +2 -2
- package/dist/plugins/marko/taglibs.d.ts +1 -1
- package/dist/plugins/marko/taglibs.js +4 -28
- package/dist/plugins/mdx/index.d.ts +2 -1
- package/dist/plugins/mdx/index.js +7 -4
- package/dist/plugins/mdxlint/index.js +18 -15
- package/dist/plugins/mikro-orm/index.d.ts +3 -0
- package/dist/plugins/mikro-orm/index.js +77 -0
- package/dist/plugins/mikro-orm/types.d.ts +21 -0
- package/dist/plugins/mikro-orm/types.js +1 -0
- package/dist/plugins/msw/index.js +6 -3
- package/dist/plugins/msw/types.d.ts +1 -1
- package/dist/plugins/netlify/index.js +7 -3
- package/dist/plugins/next/index.js +63 -9
- package/dist/plugins/next/types.d.ts +5 -0
- package/dist/plugins/next-mdx/resolveFromAST.js +15 -10
- package/dist/plugins/nitro/index.js +5 -6
- package/dist/plugins/node/index.js +4 -4
- package/dist/plugins/npm-package-json-lint/index.js +10 -3
- package/dist/plugins/nuxt/index.js +18 -10
- package/dist/plugins/nuxt/types.d.ts +4 -0
- package/dist/plugins/nx/index.js +6 -3
- package/dist/plugins/openclaw/index.js +11 -11
- package/dist/plugins/oxlint/index.js +2 -2
- package/dist/plugins/panda-css/index.js +5 -0
- package/dist/plugins/payload/index.js +1 -1
- package/dist/plugins/playwright/index.js +3 -3
- package/dist/plugins/pm2/index.js +7 -7
- package/dist/plugins/prettier/index.js +2 -1
- package/dist/plugins/prisma/index.js +2 -2
- package/dist/plugins/quasar/resolveFromAST.js +14 -9
- package/dist/plugins/react-router/index.js +2 -2
- package/dist/plugins/release-it/index.js +6 -2
- package/dist/plugins/remix/index.js +3 -3
- package/dist/plugins/retry-cli/index.d.ts +3 -0
- package/dist/plugins/retry-cli/index.js +14 -0
- package/dist/plugins/rollup/index.js +1 -4
- package/dist/plugins/rstest/index.js +3 -3
- package/dist/plugins/semantic-release/index.js +3 -3
- package/dist/plugins/serverless-framework/index.js +10 -8
- package/dist/plugins/solidjs-vite-plugin/resolveFromAST.js +2 -2
- package/dist/plugins/stencil/resolveFromAST.js +5 -5
- package/dist/plugins/stryker/index.js +2 -2
- package/dist/plugins/swc/index.js +4 -3
- package/dist/plugins/tailwind/index.js +2 -2
- package/dist/plugins/tanstack-router/index.js +2 -2
- package/dist/plugins/ts-node/index.js +6 -1
- package/dist/plugins/turbo/index.js +3 -3
- package/dist/plugins/typedoc/index.js +2 -2
- package/dist/plugins/typescript/content-mappers.d.ts +1 -1
- package/dist/plugins/typescript/index.js +6 -9
- package/dist/plugins/varlock/scan.js +1 -1
- package/dist/plugins/vite/helpers.d.ts +1 -0
- package/dist/plugins/vite/helpers.js +13 -3
- package/dist/plugins/vite/index.js +5 -2
- package/dist/plugins/vite-plugin-pwa/resolveFromAST.js +2 -2
- package/dist/plugins/vitest/index.js +14 -16
- package/dist/plugins/vue/index.js +1 -1
- package/dist/plugins/web-test-runner/index.d.ts +3 -0
- package/dist/plugins/web-test-runner/index.js +86 -0
- package/dist/plugins/webdriver-io/index.js +22 -17
- package/dist/plugins/webdriver-io/types.d.ts +3 -2
- package/dist/plugins/wrangler/index.js +3 -3
- package/dist/plugins/yarn/index.js +5 -5
- package/dist/plugins.js +2 -5
- package/dist/reporters/github-actions.js +3 -7
- package/dist/reporters/json.d.ts +1 -0
- package/dist/reporters/json.js +1 -0
- package/dist/reporters/util/configuration-hints.d.ts +3 -1
- package/dist/reporters/util/configuration-hints.js +40 -21
- package/dist/reporters/util/util.d.ts +1 -1
- package/dist/run-cli.d.ts +2 -0
- package/dist/run-cli.js +82 -0
- package/dist/run.js +12 -0
- package/dist/session/incremental.d.ts +1 -0
- package/dist/session/incremental.js +1 -0
- package/dist/session/index.d.ts +1 -0
- package/dist/session/index.js +1 -0
- package/dist/session/watch.js +2 -1
- package/dist/types/PluginNames.d.ts +2 -2
- package/dist/types/PluginNames.js +5 -0
- package/dist/types/args.d.ts +3 -1
- package/dist/types/config.d.ts +17 -10
- package/dist/types/configuration.d.ts +45 -0
- package/dist/types/configuration.js +1 -0
- package/dist/types/issues.d.ts +4 -0
- package/dist/types/module-graph.d.ts +1 -0
- package/dist/types/options.d.ts +1 -0
- package/dist/types/package-json.d.ts +3 -8
- package/dist/types/workspace.d.ts +1 -0
- package/dist/typescript/ast-nodes.js +47 -1
- package/dist/typescript/get-imports-and-exports.js +18 -6
- package/dist/typescript/resolve-module-names.js +7 -45
- package/dist/typescript/visitors/calls.d.ts +1 -1
- package/dist/typescript/visitors/calls.js +14 -10
- package/dist/typescript/visitors/exports.js +16 -26
- package/dist/typescript/visitors/imports.d.ts +2 -1
- package/dist/typescript/visitors/imports.js +41 -24
- package/dist/typescript/visitors/members.d.ts +1 -1
- package/dist/typescript/visitors/members.js +38 -24
- package/dist/typescript/visitors/shadow.d.ts +2 -0
- package/dist/typescript/visitors/shadow.js +25 -0
- package/dist/typescript/visitors/walk.d.ts +20 -12
- package/dist/typescript/visitors/walk.js +78 -48
- package/dist/util/Performance.d.ts +25 -3
- package/dist/util/Performance.js +51 -27
- package/dist/util/cli-arguments.d.ts +2 -1
- package/dist/util/cli-arguments.js +4 -2
- package/dist/util/create-input-handler.js +138 -119
- package/dist/util/create-options.d.ts +4 -2071
- package/dist/util/create-options.js +6 -4
- package/dist/util/create-workspace-graph.js +2 -1
- package/dist/util/errors.d.ts +5 -2
- package/dist/util/errors.js +11 -18
- package/dist/util/fs.js +4 -2
- package/dist/util/get-included-issue-types.js +1 -0
- package/dist/util/input.d.ts +2 -2
- package/dist/util/input.js +2 -2
- package/dist/util/is-plugin-name.d.ts +2 -0
- package/dist/util/is-plugin-name.js +3 -0
- package/dist/util/jiti.d.ts +2 -1
- package/dist/util/jiti.js +10 -3
- package/dist/util/load-config.d.ts +1 -1
- package/dist/util/load-config.js +3 -2
- package/dist/util/loader.js +3 -2
- package/dist/util/map-workspaces.js +23 -1
- package/dist/util/module-graph.js +1 -0
- package/dist/util/modules.d.ts +2 -0
- package/dist/util/modules.js +78 -0
- package/dist/util/package-json.d.ts +12 -5
- package/dist/util/package-json.js +54 -26
- package/dist/util/parse-and-convert-gitignores.d.ts +2 -2
- package/dist/util/parse-and-convert-gitignores.js +5 -5
- package/dist/util/parse-configuration.d.ts +2 -0
- package/dist/util/parse-configuration.js +66 -0
- package/dist/util/plugin.js +8 -12
- package/dist/util/regex.js +10 -1
- package/dist/util/resolve.d.ts +1 -0
- package/dist/util/resolve.js +3 -2
- package/dist/util/scripts.d.ts +0 -5
- package/dist/util/scripts.js +1 -32
- package/dist/util/to-source-path.d.ts +4 -1
- package/dist/util/to-source-path.js +2 -2
- package/dist/util/unhandled-rejection.d.ts +8 -0
- package/dist/util/unhandled-rejection.js +29 -0
- package/dist/util/validation.d.ts +11 -0
- package/dist/util/validation.js +68 -0
- package/dist/util/watch.d.ts +3 -1
- package/dist/util/watch.js +5 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -7
- package/schema.json +34 -0
- package/dist/schema/configuration.d.ts +0 -3103
- package/dist/schema/configuration.js +0 -94
- package/dist/schema/plugins.d.ts +0 -1019
- package/dist/schema/plugins.js +0 -215
|
@@ -1,134 +1,153 @@
|
|
|
1
|
-
import { IGNORED_GLOBAL_BINARIES
|
|
1
|
+
import { IGNORED_GLOBAL_BINARIES } from '../constants.js';
|
|
2
2
|
import { debugLog } from './debug.js';
|
|
3
|
-
import { fromBinary,
|
|
4
|
-
import { getPackageNameFromSpecifier } from './modules.js';
|
|
3
|
+
import { fromBinary, isConfig, isDeferResolveEntry, toDebugString } from './input.js';
|
|
4
|
+
import { getPackageNameFromFilePath, getPackageNameFromSpecifier } from './modules.js';
|
|
5
5
|
import { dirname, isAbsolute, isInNodeModules, isInternal, join } from './path.js';
|
|
6
|
-
import { _resolveModuleSync, _resolveSync } from './resolve.js';
|
|
6
|
+
import { _resolveModuleSync, _resolveSync, resolvePackageManifestPath } from './resolve.js';
|
|
7
|
+
const CHAR_HASH = 35;
|
|
8
|
+
const CHAR_AT = 64;
|
|
9
|
+
const CHAR_TILDE = 126;
|
|
7
10
|
const isJoinable = (specifier) => {
|
|
8
11
|
const char = specifier.charCodeAt(0);
|
|
9
|
-
return char !==
|
|
12
|
+
return char !== CHAR_HASH && char !== CHAR_TILDE && char !== CHAR_AT && !isAbsolute(specifier);
|
|
10
13
|
};
|
|
11
|
-
const
|
|
12
|
-
(input
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
map.get(containingFilePath).add(ref);
|
|
18
|
-
};
|
|
19
|
-
export const createInputHandler = (deputy, chief, isGitIgnored, addIssue, externalRefs, options) => (input, workspace) => {
|
|
20
|
-
const { specifier, containingFilePath } = input;
|
|
21
|
-
if (!containingFilePath)
|
|
22
|
-
return;
|
|
23
|
-
if (isBinary(input)) {
|
|
24
|
-
const binaryName = fromBinary(input);
|
|
25
|
-
const inputWorkspace = getWorkspaceFor(input, chief, workspace);
|
|
26
|
-
const dependencies = deputy.maybeAddReferencedBinary(inputWorkspace, binaryName);
|
|
27
|
-
if (dependencies) {
|
|
28
|
-
if (externalRefs) {
|
|
29
|
-
for (const dependency of dependencies) {
|
|
30
|
-
addExternalRef(externalRefs, containingFilePath, { specifier: dependency, identifier: binaryName });
|
|
31
|
-
}
|
|
32
|
-
}
|
|
14
|
+
export const createInputHandler = (deputy, chief, isGitIgnored, addIssue, externalRefs, options) => {
|
|
15
|
+
const getWorkspaceFor = (input, containingFilePath, workspace) => (input.dir && chief.findWorkspaceByFilePath(`${input.dir}/`)) ||
|
|
16
|
+
chief.findWorkspaceByFilePath(containingFilePath) ||
|
|
17
|
+
workspace;
|
|
18
|
+
const addExternalRef = (containingFilePath, specifier, identifier) => {
|
|
19
|
+
if (!externalRefs)
|
|
33
20
|
return;
|
|
21
|
+
const ref = { specifier, identifier };
|
|
22
|
+
const refs = externalRefs.get(containingFilePath);
|
|
23
|
+
if (refs)
|
|
24
|
+
refs.add(ref);
|
|
25
|
+
else
|
|
26
|
+
externalRefs.set(containingFilePath, new Set([ref]));
|
|
27
|
+
};
|
|
28
|
+
const isReportable = (input) => !input.optional && (!options.isProduction || input.production);
|
|
29
|
+
const report = (type, filePath, workspace, symbol) => addIssue({ type, filePath, workspace: workspace.name, symbol, specifier: symbol, fixes: [] });
|
|
30
|
+
const credit = (input, containingFilePath, workspace, packageName) => {
|
|
31
|
+
const reference = {
|
|
32
|
+
specifier: input.specifier,
|
|
33
|
+
isDevOnly: isConfig(input),
|
|
34
|
+
isTypeOnly: input.isTypeOnly,
|
|
35
|
+
isDevelopment: !input.production,
|
|
36
|
+
};
|
|
37
|
+
const isHandled = deputy.maybeAddReferencedExternalDependency(workspace, packageName, reference);
|
|
38
|
+
if (!input.alsoReferenceOwner)
|
|
39
|
+
return isHandled;
|
|
40
|
+
const owner = chief.findWorkspaceByFilePath(containingFilePath);
|
|
41
|
+
if (!owner || owner === workspace)
|
|
42
|
+
return isHandled;
|
|
43
|
+
const isOwnerHandled = deputy.maybeAddReferencedExternalDependency(owner, packageName, reference);
|
|
44
|
+
return isHandled || isOwnerHandled;
|
|
45
|
+
};
|
|
46
|
+
const resolveWorkspacePath = (specifier, containingFilePath) => {
|
|
47
|
+
const filePath = _resolveSync(specifier, dirname(containingFilePath));
|
|
48
|
+
if (filePath && isInternal(filePath) && !isGitIgnored(filePath))
|
|
49
|
+
return filePath;
|
|
50
|
+
};
|
|
51
|
+
const handleFile = (input, containingFilePath, workspace, recordedPackageName) => {
|
|
52
|
+
const { specifier } = input;
|
|
53
|
+
const basePath = input.dir ? join(input.dir, 'file.ts') : containingFilePath;
|
|
54
|
+
const filePath = isJoinable(specifier) ? join(input.dir ?? dirname(containingFilePath), specifier) : specifier;
|
|
55
|
+
const resolvedFilePath = _resolveModuleSync(filePath, basePath) ??
|
|
56
|
+
(filePath === specifier ? undefined : _resolveModuleSync(specifier, basePath));
|
|
57
|
+
if (resolvedFilePath && isInternal(resolvedFilePath)) {
|
|
58
|
+
return isGitIgnored(resolvedFilePath) ? undefined : resolvedFilePath;
|
|
34
59
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
fixes: [],
|
|
44
|
-
});
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
if (IGNORED_RUNTIME_DEPENDENCIES.has(specifier))
|
|
48
|
-
return;
|
|
49
|
-
const packageName = getPackageNameFromSpecifier(specifier);
|
|
50
|
-
if (packageName &&
|
|
51
|
-
(isDependency(input) ||
|
|
52
|
-
isDeferResolve(input) ||
|
|
53
|
-
(isDeferResolveEntry(input) && isInNodeModules(specifier)) ||
|
|
54
|
-
isConfig(input))) {
|
|
55
|
-
const isWorkspace = chief.workspacesByPkgName.has(packageName);
|
|
56
|
-
const inputWorkspace = getWorkspaceFor(input, chief, workspace);
|
|
57
|
-
if (inputWorkspace) {
|
|
58
|
-
let isHandled = deputy.maybeAddReferencedExternalDependency(inputWorkspace, packageName, {
|
|
59
|
-
specifier,
|
|
60
|
-
isDevOnly: isConfig(input),
|
|
61
|
-
isTypeOnly: input.isTypeOnly,
|
|
62
|
-
});
|
|
63
|
-
if (input.alsoReferenceOwner && input.containingFilePath) {
|
|
64
|
-
const owningWorkspace = chief.findWorkspaceByFilePath(input.containingFilePath);
|
|
65
|
-
if (owningWorkspace && owningWorkspace !== inputWorkspace) {
|
|
66
|
-
const isOwnerHandled = deputy.maybeAddReferencedExternalDependency(owningWorkspace, packageName, {
|
|
67
|
-
specifier,
|
|
68
|
-
isDevOnly: isConfig(input),
|
|
69
|
-
isTypeOnly: input.isTypeOnly,
|
|
70
|
-
});
|
|
71
|
-
isHandled = isHandled || isOwnerHandled;
|
|
60
|
+
const inputWorkspace = getWorkspaceFor(input, containingFilePath, workspace);
|
|
61
|
+
if (resolvedFilePath || !isInternal(filePath)) {
|
|
62
|
+
const packageName = resolvedFilePath
|
|
63
|
+
? getPackageNameFromFilePath(resolvedFilePath)
|
|
64
|
+
: getPackageNameFromSpecifier(specifier);
|
|
65
|
+
if (packageName) {
|
|
66
|
+
if (packageName !== recordedPackageName && !chief.findWorkspaceByPackageName(packageName, containingFilePath)) {
|
|
67
|
+
addExternalRef(containingFilePath, packageName);
|
|
72
68
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
addExternalRef(externalRefs, containingFilePath, { specifier: packageName, identifier: undefined });
|
|
76
|
-
}
|
|
77
|
-
if (isWorkspace || isDependency(input)) {
|
|
78
|
-
if (!isHandled) {
|
|
79
|
-
if (!input.optional && ((options.isProduction && input.production) || !options.isProduction)) {
|
|
80
|
-
addIssue({
|
|
81
|
-
type: 'unlisted',
|
|
82
|
-
filePath: containingFilePath,
|
|
83
|
-
workspace: inputWorkspace.name,
|
|
84
|
-
symbol: packageName,
|
|
85
|
-
specifier: packageName,
|
|
86
|
-
fixes: [],
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
return;
|
|
69
|
+
if (!credit(input, containingFilePath, inputWorkspace, packageName) && isReportable(input)) {
|
|
70
|
+
report('unlisted', containingFilePath, inputWorkspace, packageName);
|
|
90
71
|
}
|
|
91
|
-
const internalPath = _resolveSync(specifier, dirname(containingFilePath));
|
|
92
|
-
if (internalPath && isInternal(internalPath) && !isGitIgnored(internalPath))
|
|
93
|
-
return internalPath;
|
|
94
|
-
}
|
|
95
|
-
if (isHandled)
|
|
96
72
|
return;
|
|
73
|
+
}
|
|
97
74
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const filePath = isJoinable(specifier) ? join(input.dir ?? dirname(containingFilePath), specifier) : specifier;
|
|
103
|
-
const basePath = input.dir ? join(input.dir, 'file.ts') : containingFilePath;
|
|
104
|
-
const resolvedFilePath = _resolveModuleSync(filePath, basePath);
|
|
105
|
-
if (resolvedFilePath && isInternal(resolvedFilePath)) {
|
|
106
|
-
return isGitIgnored(resolvedFilePath) ? undefined : resolvedFilePath;
|
|
107
|
-
}
|
|
108
|
-
if (input.optional)
|
|
109
|
-
return;
|
|
110
|
-
if (!isInternal(filePath)) {
|
|
111
|
-
addIssue({
|
|
112
|
-
type: 'unlisted',
|
|
113
|
-
filePath: containingFilePath,
|
|
114
|
-
workspace: workspace.name,
|
|
115
|
-
symbol: packageName ?? specifier,
|
|
116
|
-
specifier: packageName ?? specifier,
|
|
117
|
-
fixes: [],
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
else if (!isGitIgnored(filePath)) {
|
|
121
|
-
if (!isDeferResolveEntry(input) && !isConfig(input)) {
|
|
122
|
-
addIssue({
|
|
123
|
-
type: 'unresolved',
|
|
124
|
-
filePath: containingFilePath,
|
|
125
|
-
workspace: workspace.name,
|
|
126
|
-
symbol: specifier,
|
|
127
|
-
fixes: [],
|
|
128
|
-
});
|
|
75
|
+
if ((isInternal(filePath) && isGitIgnored(filePath)) || !isReportable(input))
|
|
76
|
+
return;
|
|
77
|
+
if (isDeferResolveEntry(input) || isConfig(input)) {
|
|
78
|
+
debugLog(inputWorkspace.name, `Unable to resolve ${toDebugString(input, options.cwd)}`);
|
|
129
79
|
}
|
|
130
80
|
else {
|
|
131
|
-
|
|
81
|
+
report('unresolved', containingFilePath, inputWorkspace, specifier);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const handleBinary = (input, containingFilePath, workspace) => {
|
|
85
|
+
const binaryName = fromBinary(input);
|
|
86
|
+
const inputWorkspace = getWorkspaceFor(input, containingFilePath, workspace);
|
|
87
|
+
const dependencies = deputy.maybeAddReferencedBinary(inputWorkspace, binaryName, !input.production);
|
|
88
|
+
if (dependencies) {
|
|
89
|
+
for (const dependency of dependencies) {
|
|
90
|
+
addExternalRef(containingFilePath, dependency, binaryName);
|
|
91
|
+
}
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (!isReportable(input) ||
|
|
95
|
+
(inputWorkspace.config.ignoreGlobalBinaries && IGNORED_GLOBAL_BINARIES.has(binaryName))) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
report('binaries', containingFilePath, inputWorkspace, binaryName);
|
|
99
|
+
};
|
|
100
|
+
const handleDependency = (input, containingFilePath, workspace) => {
|
|
101
|
+
const packageName = getPackageNameFromSpecifier(input.specifier);
|
|
102
|
+
if (!packageName)
|
|
103
|
+
return handleFile(input, containingFilePath, workspace);
|
|
104
|
+
const inputWorkspace = getWorkspaceFor(input, containingFilePath, workspace);
|
|
105
|
+
if (externalRefs && !chief.findWorkspaceByPackageName(packageName, containingFilePath)) {
|
|
106
|
+
addExternalRef(containingFilePath, packageName);
|
|
107
|
+
}
|
|
108
|
+
if (credit(input, containingFilePath, inputWorkspace, packageName)) {
|
|
109
|
+
return resolveWorkspacePath(input.specifier, containingFilePath);
|
|
110
|
+
}
|
|
111
|
+
if (isReportable(input))
|
|
112
|
+
report('unlisted', containingFilePath, inputWorkspace, packageName);
|
|
113
|
+
};
|
|
114
|
+
const handlePackageOrFile = (input, containingFilePath, workspace) => {
|
|
115
|
+
const packageName = getPackageNameFromSpecifier(input.specifier);
|
|
116
|
+
if (!packageName)
|
|
117
|
+
return handleFile(input, containingFilePath, workspace);
|
|
118
|
+
const inputWorkspace = getWorkspaceFor(input, containingFilePath, workspace);
|
|
119
|
+
const isWorkspace = chief.findWorkspaceByPackageName(packageName, containingFilePath) !== undefined;
|
|
120
|
+
if (!isWorkspace)
|
|
121
|
+
addExternalRef(containingFilePath, packageName);
|
|
122
|
+
if (credit(input, containingFilePath, inputWorkspace, packageName)) {
|
|
123
|
+
return isWorkspace ? resolveWorkspacePath(input.specifier, containingFilePath) : undefined;
|
|
124
|
+
}
|
|
125
|
+
if (isWorkspace || resolvePackageManifestPath(packageName, input.dir ?? dirname(containingFilePath))) {
|
|
126
|
+
if (isReportable(input))
|
|
127
|
+
report('unlisted', containingFilePath, inputWorkspace, packageName);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
return handleFile(input, containingFilePath, workspace, packageName);
|
|
131
|
+
};
|
|
132
|
+
return (input, workspace) => {
|
|
133
|
+
const { specifier, containingFilePath } = input;
|
|
134
|
+
if (!containingFilePath)
|
|
135
|
+
return;
|
|
136
|
+
switch (input.type) {
|
|
137
|
+
case 'binary':
|
|
138
|
+
handleBinary(input, containingFilePath, workspace);
|
|
139
|
+
return;
|
|
140
|
+
case 'dependency':
|
|
141
|
+
return handleDependency(input, containingFilePath, workspace);
|
|
142
|
+
case 'deferResolve':
|
|
143
|
+
case 'config':
|
|
144
|
+
return handlePackageOrFile(input, containingFilePath, workspace);
|
|
145
|
+
case 'deferResolveEntry':
|
|
146
|
+
return isInNodeModules(specifier)
|
|
147
|
+
? handlePackageOrFile(input, containingFilePath, workspace)
|
|
148
|
+
: handleFile(input, containingFilePath, workspace);
|
|
149
|
+
case 'entry':
|
|
150
|
+
return handleFile(input, containingFilePath, workspace);
|
|
132
151
|
}
|
|
133
|
-
}
|
|
152
|
+
};
|
|
134
153
|
};
|