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.
Files changed (226) hide show
  1. package/dist/ConfigurationChief.d.ts +23 -1033
  2. package/dist/ConfigurationChief.js +71 -15
  3. package/dist/DependencyDeputy.d.ts +10 -6
  4. package/dist/DependencyDeputy.js +51 -27
  5. package/dist/IssueCollector.d.ts +14 -11
  6. package/dist/IssueCollector.js +25 -20
  7. package/dist/IssueFixer.js +1 -1
  8. package/dist/PackagePeeker.d.ts +6 -0
  9. package/dist/PackagePeeker.js +43 -14
  10. package/dist/ProjectPrincipal.d.ts +6 -3
  11. package/dist/ProjectPrincipal.js +83 -32
  12. package/dist/WorkspaceWorker.d.ts +5 -1
  13. package/dist/WorkspaceWorker.js +39 -22
  14. package/dist/binaries/bash-parser.js +1 -7
  15. package/dist/binaries/command.d.ts +3 -3
  16. package/dist/binaries/command.js +6 -2
  17. package/dist/binaries/fallback.js +1 -1
  18. package/dist/binaries/plugins.d.ts +4 -1
  19. package/dist/binaries/plugins.js +66 -18
  20. package/dist/binaries/resolvers/npm.js +7 -5
  21. package/dist/binaries/resolvers/npx.js +8 -40
  22. package/dist/binaries/util.d.ts +13 -1
  23. package/dist/binaries/util.js +35 -1
  24. package/dist/cli.js +10 -84
  25. package/dist/configuration-hints.d.ts +16 -0
  26. package/dist/configuration-hints.js +64 -0
  27. package/dist/constants.d.ts +2 -1
  28. package/dist/constants.js +2 -0
  29. package/dist/graph/SubpathReferences.d.ts +33 -0
  30. package/dist/graph/SubpathReferences.js +114 -0
  31. package/dist/graph/analyze.d.ts +4 -1
  32. package/dist/graph/analyze.js +16 -5
  33. package/dist/graph/build.d.ts +3 -1
  34. package/dist/graph/build.js +47 -23
  35. package/dist/graph-explorer/operations/resolve-export-origins.js +1 -1
  36. package/dist/plugins/angular/index.js +10 -17
  37. package/dist/plugins/aws-cdk/index.d.ts +3 -0
  38. package/dist/plugins/aws-cdk/index.js +32 -0
  39. package/dist/plugins/aws-cdk/types.d.ts +5 -0
  40. package/dist/plugins/aws-cdk/types.js +1 -0
  41. package/dist/plugins/babel/index.d.ts +1 -1
  42. package/dist/plugins/babel/index.js +19 -5
  43. package/dist/plugins/bun/index.js +8 -7
  44. package/dist/plugins/c8/index.js +17 -4
  45. package/dist/plugins/changesets/index.js +3 -2
  46. package/dist/plugins/commitizen/index.js +6 -3
  47. package/dist/plugins/commitlint/index.js +10 -11
  48. package/dist/plugins/cypress/index.js +4 -2
  49. package/dist/plugins/danger/index.js +1 -1
  50. package/dist/plugins/docusaurus/helpers.js +6 -6
  51. package/dist/plugins/docusaurus/index.js +2 -2
  52. package/dist/plugins/electron-forge/index.js +2 -2
  53. package/dist/plugins/electron-vite/index.js +2 -2
  54. package/dist/plugins/eleventy/index.js +3 -2
  55. package/dist/plugins/eslint/helpers.js +4 -3
  56. package/dist/plugins/eslint/resolveFromAST.js +2 -2
  57. package/dist/plugins/evalite/index.d.ts +3 -0
  58. package/dist/plugins/evalite/index.js +26 -0
  59. package/dist/plugins/flue/index.js +2 -2
  60. package/dist/plugins/github-action/index.js +2 -2
  61. package/dist/plugins/github-actions/index.js +2 -2
  62. package/dist/plugins/graphql-codegen/index.js +13 -9
  63. package/dist/plugins/index.d.ts +5 -0
  64. package/dist/plugins/index.js +10 -0
  65. package/dist/plugins/jest/index.js +5 -5
  66. package/dist/plugins/knex/index.js +2 -2
  67. package/dist/plugins/laravel-vite-plugin/resolveFromAST.js +2 -2
  68. package/dist/plugins/lunaria/index.js +5 -2
  69. package/dist/plugins/markdownlint/index.js +8 -2
  70. package/dist/plugins/marko/index.js +2 -2
  71. package/dist/plugins/marko/taglibs.d.ts +1 -1
  72. package/dist/plugins/marko/taglibs.js +4 -28
  73. package/dist/plugins/mdx/index.d.ts +2 -1
  74. package/dist/plugins/mdx/index.js +7 -4
  75. package/dist/plugins/mdxlint/index.js +18 -15
  76. package/dist/plugins/mikro-orm/index.d.ts +3 -0
  77. package/dist/plugins/mikro-orm/index.js +77 -0
  78. package/dist/plugins/mikro-orm/types.d.ts +21 -0
  79. package/dist/plugins/mikro-orm/types.js +1 -0
  80. package/dist/plugins/msw/index.js +6 -3
  81. package/dist/plugins/msw/types.d.ts +1 -1
  82. package/dist/plugins/netlify/index.js +7 -3
  83. package/dist/plugins/next/index.js +63 -9
  84. package/dist/plugins/next/types.d.ts +5 -0
  85. package/dist/plugins/next-mdx/resolveFromAST.js +15 -10
  86. package/dist/plugins/nitro/index.js +5 -6
  87. package/dist/plugins/node/index.js +4 -4
  88. package/dist/plugins/npm-package-json-lint/index.js +10 -3
  89. package/dist/plugins/nuxt/index.js +18 -10
  90. package/dist/plugins/nuxt/types.d.ts +4 -0
  91. package/dist/plugins/nx/index.js +6 -3
  92. package/dist/plugins/openclaw/index.js +11 -11
  93. package/dist/plugins/oxlint/index.js +2 -2
  94. package/dist/plugins/panda-css/index.js +5 -0
  95. package/dist/plugins/payload/index.js +1 -1
  96. package/dist/plugins/playwright/index.js +3 -3
  97. package/dist/plugins/pm2/index.js +7 -7
  98. package/dist/plugins/prettier/index.js +2 -1
  99. package/dist/plugins/prisma/index.js +2 -2
  100. package/dist/plugins/quasar/resolveFromAST.js +14 -9
  101. package/dist/plugins/react-router/index.js +2 -2
  102. package/dist/plugins/release-it/index.js +6 -2
  103. package/dist/plugins/remix/index.js +3 -3
  104. package/dist/plugins/retry-cli/index.d.ts +3 -0
  105. package/dist/plugins/retry-cli/index.js +14 -0
  106. package/dist/plugins/rollup/index.js +1 -4
  107. package/dist/plugins/rstest/index.js +3 -3
  108. package/dist/plugins/semantic-release/index.js +3 -3
  109. package/dist/plugins/serverless-framework/index.js +10 -8
  110. package/dist/plugins/solidjs-vite-plugin/resolveFromAST.js +2 -2
  111. package/dist/plugins/stencil/resolveFromAST.js +5 -5
  112. package/dist/plugins/stryker/index.js +2 -2
  113. package/dist/plugins/swc/index.js +4 -3
  114. package/dist/plugins/tailwind/index.js +2 -2
  115. package/dist/plugins/tanstack-router/index.js +2 -2
  116. package/dist/plugins/ts-node/index.js +6 -1
  117. package/dist/plugins/turbo/index.js +3 -3
  118. package/dist/plugins/typedoc/index.js +2 -2
  119. package/dist/plugins/typescript/content-mappers.d.ts +1 -1
  120. package/dist/plugins/typescript/index.js +6 -9
  121. package/dist/plugins/varlock/scan.js +1 -1
  122. package/dist/plugins/vite/helpers.d.ts +1 -0
  123. package/dist/plugins/vite/helpers.js +13 -3
  124. package/dist/plugins/vite/index.js +5 -2
  125. package/dist/plugins/vite-plugin-pwa/resolveFromAST.js +2 -2
  126. package/dist/plugins/vitest/index.js +14 -16
  127. package/dist/plugins/vue/index.js +1 -1
  128. package/dist/plugins/web-test-runner/index.d.ts +3 -0
  129. package/dist/plugins/web-test-runner/index.js +86 -0
  130. package/dist/plugins/webdriver-io/index.js +22 -17
  131. package/dist/plugins/webdriver-io/types.d.ts +3 -2
  132. package/dist/plugins/wrangler/index.js +3 -3
  133. package/dist/plugins/yarn/index.js +5 -5
  134. package/dist/plugins.js +2 -5
  135. package/dist/reporters/github-actions.js +3 -7
  136. package/dist/reporters/json.d.ts +1 -0
  137. package/dist/reporters/json.js +1 -0
  138. package/dist/reporters/util/configuration-hints.d.ts +3 -1
  139. package/dist/reporters/util/configuration-hints.js +40 -21
  140. package/dist/reporters/util/util.d.ts +1 -1
  141. package/dist/run-cli.d.ts +2 -0
  142. package/dist/run-cli.js +82 -0
  143. package/dist/run.js +12 -0
  144. package/dist/session/incremental.d.ts +1 -0
  145. package/dist/session/incremental.js +1 -0
  146. package/dist/session/index.d.ts +1 -0
  147. package/dist/session/index.js +1 -0
  148. package/dist/session/watch.js +2 -1
  149. package/dist/types/PluginNames.d.ts +2 -2
  150. package/dist/types/PluginNames.js +5 -0
  151. package/dist/types/args.d.ts +3 -1
  152. package/dist/types/config.d.ts +17 -10
  153. package/dist/types/configuration.d.ts +45 -0
  154. package/dist/types/configuration.js +1 -0
  155. package/dist/types/issues.d.ts +4 -0
  156. package/dist/types/module-graph.d.ts +1 -0
  157. package/dist/types/options.d.ts +1 -0
  158. package/dist/types/package-json.d.ts +3 -8
  159. package/dist/types/workspace.d.ts +1 -0
  160. package/dist/typescript/ast-nodes.js +47 -1
  161. package/dist/typescript/get-imports-and-exports.js +18 -6
  162. package/dist/typescript/resolve-module-names.js +7 -45
  163. package/dist/typescript/visitors/calls.d.ts +1 -1
  164. package/dist/typescript/visitors/calls.js +14 -10
  165. package/dist/typescript/visitors/exports.js +16 -26
  166. package/dist/typescript/visitors/imports.d.ts +2 -1
  167. package/dist/typescript/visitors/imports.js +41 -24
  168. package/dist/typescript/visitors/members.d.ts +1 -1
  169. package/dist/typescript/visitors/members.js +38 -24
  170. package/dist/typescript/visitors/shadow.d.ts +2 -0
  171. package/dist/typescript/visitors/shadow.js +25 -0
  172. package/dist/typescript/visitors/walk.d.ts +20 -12
  173. package/dist/typescript/visitors/walk.js +78 -48
  174. package/dist/util/Performance.d.ts +25 -3
  175. package/dist/util/Performance.js +51 -27
  176. package/dist/util/cli-arguments.d.ts +2 -1
  177. package/dist/util/cli-arguments.js +4 -2
  178. package/dist/util/create-input-handler.js +138 -119
  179. package/dist/util/create-options.d.ts +4 -2071
  180. package/dist/util/create-options.js +6 -4
  181. package/dist/util/create-workspace-graph.js +2 -1
  182. package/dist/util/errors.d.ts +5 -2
  183. package/dist/util/errors.js +11 -18
  184. package/dist/util/fs.js +4 -2
  185. package/dist/util/get-included-issue-types.js +1 -0
  186. package/dist/util/input.d.ts +2 -2
  187. package/dist/util/input.js +2 -2
  188. package/dist/util/is-plugin-name.d.ts +2 -0
  189. package/dist/util/is-plugin-name.js +3 -0
  190. package/dist/util/jiti.d.ts +2 -1
  191. package/dist/util/jiti.js +10 -3
  192. package/dist/util/load-config.d.ts +1 -1
  193. package/dist/util/load-config.js +3 -2
  194. package/dist/util/loader.js +3 -2
  195. package/dist/util/map-workspaces.js +23 -1
  196. package/dist/util/module-graph.js +1 -0
  197. package/dist/util/modules.d.ts +2 -0
  198. package/dist/util/modules.js +78 -0
  199. package/dist/util/package-json.d.ts +12 -5
  200. package/dist/util/package-json.js +54 -26
  201. package/dist/util/parse-and-convert-gitignores.d.ts +2 -2
  202. package/dist/util/parse-and-convert-gitignores.js +5 -5
  203. package/dist/util/parse-configuration.d.ts +2 -0
  204. package/dist/util/parse-configuration.js +66 -0
  205. package/dist/util/plugin.js +8 -12
  206. package/dist/util/regex.js +10 -1
  207. package/dist/util/resolve.d.ts +1 -0
  208. package/dist/util/resolve.js +3 -2
  209. package/dist/util/scripts.d.ts +0 -5
  210. package/dist/util/scripts.js +1 -32
  211. package/dist/util/to-source-path.d.ts +4 -1
  212. package/dist/util/to-source-path.js +2 -2
  213. package/dist/util/unhandled-rejection.d.ts +8 -0
  214. package/dist/util/unhandled-rejection.js +29 -0
  215. package/dist/util/validation.d.ts +11 -0
  216. package/dist/util/validation.js +68 -0
  217. package/dist/util/watch.d.ts +3 -1
  218. package/dist/util/watch.js +5 -2
  219. package/dist/version.d.ts +1 -1
  220. package/dist/version.js +1 -1
  221. package/package.json +6 -7
  222. package/schema.json +34 -0
  223. package/dist/schema/configuration.d.ts +0 -3103
  224. package/dist/schema/configuration.js +0 -94
  225. package/dist/schema/plugins.d.ts +0 -1019
  226. package/dist/schema/plugins.js +0 -215
@@ -1,134 +1,153 @@
1
- import { IGNORED_GLOBAL_BINARIES, IGNORED_RUNTIME_DEPENDENCIES } from '../constants.js';
1
+ import { IGNORED_GLOBAL_BINARIES } from '../constants.js';
2
2
  import { debugLog } from './debug.js';
3
- import { fromBinary, isBinary, isConfig, isDeferResolve, isDeferResolveEntry, isDependency, toDebugString, } from './input.js';
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 !== 35 && char !== 126 && char !== 64 && !isAbsolute(specifier);
12
+ return char !== CHAR_HASH && char !== CHAR_TILDE && char !== CHAR_AT && !isAbsolute(specifier);
10
13
  };
11
- const getWorkspaceFor = (input, chief, workspace) => (input.dir && chief.findWorkspaceByFilePath(`${input.dir}/`)) ||
12
- (input.containingFilePath && chief.findWorkspaceByFilePath(input.containingFilePath)) ||
13
- workspace;
14
- const addExternalRef = (map, containingFilePath, ref) => {
15
- if (!map.has(containingFilePath))
16
- map.set(containingFilePath, new Set());
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
- if (input.optional || (inputWorkspace.config.ignoreGlobalBinaries && IGNORED_GLOBAL_BINARIES.has(binaryName)))
36
- return;
37
- addIssue({
38
- type: 'binaries',
39
- filePath: containingFilePath,
40
- workspace: inputWorkspace.name,
41
- symbol: binaryName,
42
- specifier,
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
- if (externalRefs && !isWorkspace) {
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
- if (isDeferResolve(input) && deputy.isProduction && !input.production) {
100
- return;
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
- debugLog(workspace.name, `Unable to resolve ${toDebugString(input, options.cwd)}`);
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
  };