Skip to content

Commit f43172e

Browse files
data-douserCopilotCopilot
authored
Add best-effort CDS extractor support for @sap/cds-indexer (#303)
* Add best-effort @sap/cds-indexer support to CDS extractor - Integrate indexer orchestration into cds-extractor.ts between dependency installation and compilation phases - New src/cds/indexer.ts: detect projects using @sap/cds-indexer and run `npx --yes @sap/cds-indexer` before compilation, with graceful error handling and diagnostic warnings on failure - Include @sap/cds-indexer in dependency cache when declared in project package.json (dependencies or devDependencies) - Add addCdsIndexerDiagnostic() to diagnostics.ts - Add unit tests to cover new indexer and diagnostic functions - Fix Jest localstorage-file warnings on Node.js v25+ * Update extractors/cds/tools/src/diagnostics.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Sync dist/cds-extractor.bundle.js.map * Increase @sap/cds-indexer timeout from 2 min to 10 min (#308) * Initial plan * Increase CDS indexer timeout from 120s to 600s (10 minutes) Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
1 parent 3e54dfa commit f43172e

File tree

11 files changed

+1182
-154
lines changed

11 files changed

+1182
-154
lines changed

extractors/cds/tools/cds-extractor.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { join } from 'path';
33
import { sync as globSync } from 'glob';
44

55
import { orchestrateCompilation } from './src/cds/compiler';
6+
import { orchestrateCdsIndexer } from './src/cds/indexer';
67
import { buildCdsProjectDependencyGraph, type CdsDependencyGraph } from './src/cds/parser';
78
import { handleEarlyExit, runJavaScriptExtractionWithMarker } from './src/codeql';
89
import {
@@ -206,6 +207,23 @@ if (projectCacheDirMap.size === 0) {
206207
);
207208
}
208209

210+
// Run cds-indexer for projects that use it (before compilation)
211+
logPerformanceTrackingStart('CDS Indexer');
212+
const cdsIndexerSummary = orchestrateCdsIndexer(
213+
dependencyGraph,
214+
sourceRoot,
215+
projectCacheDirMap,
216+
codeqlExePath,
217+
);
218+
logPerformanceTrackingStop('CDS Indexer');
219+
220+
if (cdsIndexerSummary.projectsRequiringIndexer > 0) {
221+
logPerformanceMilestone(
222+
'CDS indexer completed',
223+
`${cdsIndexerSummary.successfulRuns} succeeded, ${cdsIndexerSummary.failedRuns} failed`,
224+
);
225+
}
226+
209227
// Collect all CDS files to process
210228
const cdsFilePathsToProcess: string[] = [];
211229
for (const project of dependencyGraph.projects.values()) {

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

Lines changed: 229 additions & 75 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

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

extractors/cds/tools/jest.config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
// Suppress Node.js v25+ localStorage warning triggered by jest-environment-node
2+
// teardown accessing globalThis.localStorage before --localstorage-file is set.
3+
// Setting the env var here ensures it propagates to all Jest worker processes.
4+
const nodeVersion = parseInt(process.versions.node, 10);
5+
if (nodeVersion >= 25 && !process.env.NODE_OPTIONS?.includes('--localstorage-file')) {
6+
const localStoragePath = require('path').join(
7+
require('os').tmpdir(),
8+
'.jest-cds-extractor-localstorage',
9+
);
10+
process.env.NODE_OPTIONS = [
11+
process.env.NODE_OPTIONS,
12+
`--localstorage-file=${localStoragePath}`,
13+
]
14+
.filter(Boolean)
15+
.join(' ');
16+
}
17+
118
/** @type {import('ts-jest').JestConfigWithTsJest} */
219
module.exports = {
320
preset: 'ts-jest',

extractors/cds/tools/package-lock.json

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

0 commit comments

Comments
 (0)