@@ -3,7 +3,6 @@ import path from 'node:path'
33import { logger } from '@socketsecurity/registry/lib/logger'
44
55import { extractBazelToMaven } from './bazel/extract_bazel_to_maven.mts'
6- import { extractBazelToPypi } from './bazel/extract_bazel_to_pypi.mts'
76import { convertGradleToMaven } from './convert_gradle_to_maven.mts'
87import { convertSbtToMaven } from './convert_sbt_to_maven.mts'
98import { handleManifestConda } from './handle-manifest-conda.mts'
@@ -87,14 +86,6 @@ export async function generateAutoManifest({
8786
8887 if ( ! sockJson ?. defaults ?. manifest ?. bazel ?. disabled && detected . bazel ) {
8988 const bazelConfig = sockJson ?. defaults ?. manifest ?. bazel
90- type EcosystemOutcome = {
91- ecosystem : 'maven' | 'pypi'
92- ok : boolean
93- noEcosystemFound ?: boolean
94- hardFailure ?: boolean
95- manifestPath ?: string | undefined
96- }
97- const outcomes : EcosystemOutcome [ ] = [ ]
9889
9990 logger . log (
10091 'Detected a Bazel workspace, extracting Maven dependencies via bazel query...' ,
@@ -109,63 +100,15 @@ export async function generateAutoManifest({
109100 outLayout : 'flat' ,
110101 verbose : Boolean ( bazelConfig ?. verbose ) || verbose ,
111102 } )
112- outcomes . push ( {
113- ecosystem : 'maven' ,
114- noEcosystemFound : Boolean ( mavenResult . noEcosystemFound ) ,
115- ok : mavenResult . ok ,
116- manifestPath : mavenResult . manifestPath ,
117- } )
118-
119- const configuredEcosystems = bazelConfig ?. ecosystem
120- const requestedEcosystems = Array . isArray ( configuredEcosystems )
121- ? configuredEcosystems
122- : configuredEcosystems
123- ? [ configuredEcosystems ]
124- : [ ]
125- const shouldRunPypi = requestedEcosystems . includes ( 'pypi' )
126-
127- if ( shouldRunPypi ) {
128- logger . log ( 'Extracting PyPI dependencies via bazel query...' )
129- const pypiResult = await extractBazelToPypi ( {
130- bazelFlags : bazelConfig ?. bazelFlags ,
131- bazelOutputBase : bazelConfig ?. bazelOutputBase ,
132- bazelRc : bazelConfig ?. bazelRc ,
133- bin : bazelConfig ?. bazel ?? bazelConfig ?. bin ,
134- cwd,
135- explicitEcosystem : true ,
136- out : bazelConfig ?. out ?? cwd ,
137- outLayout : 'flat' ,
138- verbose : Boolean ( bazelConfig ?. verbose ) || verbose ,
139- } )
140- outcomes . push ( {
141- ecosystem : 'pypi' ,
142- ok : pypiResult . ok ,
143- noEcosystemFound : Boolean ( pypiResult . noEcosystemFound ) ,
144- manifestPath : pypiResult . manifestPath ,
145- } )
146- } else if ( verbose ) {
147- logger . info (
148- 'Skipping Bazel PyPI auto-manifest extraction; set defaults.manifest.bazel.ecosystem to include "pypi" to opt in.' ,
149- )
150- }
151-
152- // Auto-manifest outcome matrix: hard failures are fatal, no-discovery is
153- // informational, and successes are returned only when nothing hard-failed.
154- const successes = outcomes . filter ( o => o . ok && o . manifestPath )
155- const hardFailures = outcomes . filter ( o => ! o . ok && ! o . noEcosystemFound )
156- const noDiscoveries = outcomes . filter ( o => o . noEcosystemFound )
157103
158- if ( hardFailures . length ) {
159- const ecosystems = hardFailures . map ( f => f . ecosystem ) . join ( ', ' )
104+ if ( ! mavenResult . ok && ! mavenResult . noEcosystemFound ) {
160105 throw new Error (
161- ` Bazel auto-manifest generation failed for ecosystem(s): ${ ecosystems } ` ,
106+ ' Bazel auto-manifest generation failed for ecosystem(s): maven' ,
162107 )
163108 }
164- if ( successes . length ) {
165- for ( const s of successes ) {
166- generatedFiles . push ( s . manifestPath ! )
167- }
168- } else if ( noDiscoveries . length === outcomes . length ) {
109+ if ( mavenResult . ok && mavenResult . manifestPath ) {
110+ generatedFiles . push ( mavenResult . manifestPath )
111+ } else if ( mavenResult . noEcosystemFound ) {
169112 logger . info ( 'No supported Bazel Maven ecosystem detected.' )
170113 }
171114 }
0 commit comments