@@ -6,6 +6,7 @@ import { resolvePaths } from './util/path';
66import { createProject } from './util/project' ;
77import { findIssues } from './runner' ;
88import { ConfigurationError } from './util/errors' ;
9+ import { debugLogObject , debugLogFiles , debugLogSourceFiles } from './util/debug' ;
910import type { UnresolvedConfiguration , Configuration } from './types' ;
1011
1112export const main = async ( options : UnresolvedConfiguration ) => {
@@ -21,8 +22,11 @@ export const main = async (options: UnresolvedConfiguration) => {
2122 isDev,
2223 isShowProgress,
2324 jsDoc,
25+ debug,
2426 } = options ;
2527
28+ debugLogObject ( options , 1 , 'Unresolved onfiguration' , options ) ;
29+
2630 const localConfigurationPath = configFilePath && ( await findFile ( workingDir , configFilePath ) ) ;
2731 const manifestPath = await findFile ( workingDir , 'package.json' ) ;
2832 const localConfiguration = localConfigurationPath && require ( localConfigurationPath ) ;
@@ -36,6 +40,8 @@ export const main = async (options: UnresolvedConfiguration) => {
3640 const dir = path . relative ( cwd , workingDir ) ;
3741 const resolvedConfig = resolveConfig ( manifest . knip ?? localConfiguration , { workingDir : dir , isDev } ) ;
3842
43+ debugLogObject ( options , 1 , 'Resolved onfiguration' , resolvedConfig ) ;
44+
3945 if ( ! resolvedConfig ) {
4046 throw new ConfigurationError ( 'Unable to find `entryFiles` and/or `projectFiles` in configuration.' ) ;
4147 }
@@ -61,29 +67,38 @@ export const main = async (options: UnresolvedConfiguration) => {
6167
6268 const projectOptions = tsConfigPath ? { tsConfigFilePath : tsConfigPath } : { compilerOptions : { allowJs : true } } ;
6369
64- // Create workspace for entry files + resolved dependencies
6570 const entryPaths = await resolvePaths ( {
6671 cwd,
6772 workingDir,
6873 patterns : resolvedConfig . entryFiles ,
6974 ignore,
7075 gitignore,
7176 } ) ;
77+ debugLogFiles ( options , 1 , 'Globbed entry paths' , entryPaths ) ;
78+
79+ // Create workspace for entry files, but don't resolve dependencies yet
7280 const production = createProject ( { projectOptions, paths : entryPaths } ) ;
7381 const entryFiles = production . getSourceFiles ( ) ;
82+ debugLogSourceFiles ( options , 1 , 'Included entry source files' , entryFiles ) ;
83+
84+ // Now resolve dependencies of entry files to find all production files
7485 production . resolveSourceFileDependencies ( ) ;
7586 const productionFiles = production . getSourceFiles ( ) ;
87+ debugLogSourceFiles ( options , 1 , 'Included production source files' , productionFiles ) ;
7688
77- // Create workspace for the entire project
7889 const projectPaths = await resolvePaths ( {
7990 cwd,
8091 workingDir,
8192 patterns : resolvedConfig . projectFiles ,
8293 ignore,
8394 gitignore,
8495 } ) ;
96+ debugLogFiles ( options , 1 , 'Globbed project paths' , projectPaths ) ;
97+
98+ // Create workspace for the entire project
8599 const project = createProject ( { projectOptions, paths : projectPaths } ) ;
86100 const projectFiles = project . getSourceFiles ( ) ;
101+ debugLogSourceFiles ( options , 1 , 'Included project source files' , projectFiles ) ;
87102
88103 const config : Configuration = {
89104 workingDir,
@@ -99,9 +114,12 @@ export const main = async (options: UnresolvedConfiguration) => {
99114 jsDocOptions : {
100115 isReadPublicTag : jsDoc . includes ( 'public' ) ,
101116 } ,
117+ debug,
102118 } ;
103119
104120 const { issues, counters } = await findIssues ( config ) ;
105121
122+ debugLogObject ( options , 2 , 'Issues' , issues ) ;
123+
106124 return { report, issues, counters } ;
107125} ;
0 commit comments