Skip to content

Commit 9050fe1

Browse files
committed
Improve and cleanup CDS extractor packageManager
Improves the efficiency and logging of package dependency installation tasks in the "packageManager" package of the CDS extractor source code. Responds to peer feedback on related PR #195. Extends unit test coverage for the `src/packageManager` code.
1 parent cc29a54 commit 9050fe1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+6118
-471
lines changed

extractors/cds/tools/cds-extractor.ts

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ try {
108108
}
109109
} else {
110110
cdsExtractorLog(
111-
'warn',
112-
'No CDS projects were detected. This may indicate an issue with project detection logic.',
111+
'error',
112+
'No CDS projects were detected. This is an unrecoverable error as there is nothing to scan.',
113113
);
114114
// Let's also try to find CDS files directly as a backup check
115115
try {
@@ -129,10 +129,23 @@ try {
129129
'info',
130130
`Sample CDS files: ${allCdsFiles.slice(0, 5).join(', ')}${allCdsFiles.length > 5 ? ', ...' : ''}`,
131131
);
132+
cdsExtractorLog(
133+
'error',
134+
'CDS files were found but no projects were detected. This indicates a problem with project detection logic.',
135+
);
136+
} else {
137+
cdsExtractorLog(
138+
'info',
139+
'No CDS files found in the source tree. This may be expected if the source does not contain CAP/CDS projects.',
140+
);
132141
}
133142
} catch (globError) {
134143
cdsExtractorLog('warn', `Could not perform direct CDS file search: ${String(globError)}`);
135144
}
145+
146+
// Exit early since we have no CDS projects to process
147+
logExtractorStop(false, 'Terminated: No CDS projects detected');
148+
process.exit(1);
136149
}
137150
} catch (error) {
138151
cdsExtractorLog('error', `Failed to build enhanced dependency graph: ${String(error)}`);
@@ -145,6 +158,30 @@ startPerformanceTracking('Dependency Installation');
145158
const projectCacheDirMap = installDependencies(dependencyGraph, sourceRoot, codeqlExePath);
146159
endPerformanceTracking('Dependency Installation');
147160

161+
// Check if dependency installation resulted in any usable project mappings
162+
if (projectCacheDirMap.size === 0) {
163+
cdsExtractorLog(
164+
'error',
165+
'No project cache directory mappings were created. This indicates that dependency installation failed for all discovered projects.',
166+
);
167+
168+
// This is a critical error if we have projects but no cache mappings
169+
if (dependencyGraph.projects.size > 0) {
170+
cdsExtractorLog(
171+
'error',
172+
`Found ${dependencyGraph.projects.size} CDS projects but failed to install dependencies for any of them. Cannot proceed with compilation.`,
173+
);
174+
logExtractorStop(false, 'Terminated: Dependency installation failed for all projects');
175+
process.exit(1);
176+
}
177+
178+
// If we have no projects and no cache mappings, this should have been caught earlier
179+
cdsExtractorLog(
180+
'warn',
181+
'No projects and no cache mappings - this should have been detected earlier.',
182+
);
183+
}
184+
148185
const cdsFilePathsToProcess: string[] = [];
149186

150187
// Use the enhanced dependency graph to collect all `.cds` files from each project.

extractors/cds/tools/dist/cds-extractor.js

Lines changed: 20 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extractors/cds/tools/dist/cds-extractor.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)