@@ -5,6 +5,7 @@ import spawn from '@npmcli/promise-spawn'
55import { Spinner } from '@socketsecurity/registry/lib/spinner'
66
77import { safeReadFile } from '../../utils/fs'
8+ import { logger } from '../../utils/logging'
89
910export async function convertSbtToMaven (
1011 target : string ,
@@ -36,23 +37,22 @@ export async function convertSbtToMaven(
3637 spinner . start ( `Converting sbt to maven from \`${ bin } \` on \`${ target } \`...` )
3738
3839 try {
39- // Run sbt with the init script we provide which should yield zero or more pom files.
40- // We have to figure out where to store those pom files such that we can upload them and predict them through the GitHub API.
41- // We could do a .socket folder. We could do a socket.pom.gz with all the poms, although I'd prefer something plain-text if it is to be committed.
42-
40+ // Run sbt with the init script we provide which should yield zero or more
41+ // pom files. We have to figure out where to store those pom files such that
42+ // we can upload them and predict them through the GitHub API. We could do a
43+ // .socket folder. We could do a socket.pom.gz with all the poms, although
44+ // I'd prefer something plain-text if it is to be committed.
4345 const output = await spawn ( bin , [ 'makePom' ] . concat ( sbtOpts ) , {
4446 cwd : target || '.'
4547 } )
46- spinner . successAndStop ( )
48+ spinner . stop ( )
4749 if ( verbose ) {
4850 console . group ( '[VERBOSE] sbt stdout:' )
4951 console . log ( output )
5052 console . groupEnd ( )
5153 }
52-
5354 if ( output . stderr ) {
54- spinner . start ( )
55- spinner . errorAndStop ( 'There were errors while running sbt' )
55+ logger . error ( 'There were errors while running sbt' )
5656 // (In verbose mode, stderr was printed above, no need to repeat it)
5757 if ( ! verbose ) {
5858 console . group ( '[VERBOSE] stderr:' )
@@ -61,50 +61,45 @@ export async function convertSbtToMaven(
6161 }
6262 process . exit ( 1 )
6363 }
64-
6564 const poms : Array < string > = [ ]
6665 output . stdout . replace ( / W r o t e ( .* ?.p o m ) \n / g, ( _all : string , fn : string ) => {
6766 poms . push ( fn )
6867 return fn
6968 } )
70-
7169 if ( ! poms . length ) {
72- spinner . errorAndStop (
70+ logger . error (
7371 'There were no errors from sbt but it seems to not have generated any poms either'
7472 )
7573 process . exit ( 1 )
7674 }
77-
7875 // Move the pom file to ...? initial cwd? loc will be an absolute path, or dump to stdout
7976 // TODO: what to do with multiple output files? Do we want to dump them to stdout? Raw or with separators or ?
8077 // TODO: maybe we can add an option to target a specific file to dump to stdout
8178 if ( out === '-' && poms . length === 1 ) {
82- spinner . start ( 'Result:\n```' ) . success ( )
79+ console . log ( 'Result:\n```' )
8380 console . log ( await safeReadFile ( poms [ 0 ] as string , 'utf8' ) )
8481 console . log ( '```' )
85- spinner . start ( ) . success ( `OK` )
82+ logger . success ( `OK` )
8683 } else if ( out === '-' ) {
87- spinner
88- . start ( )
89- . error (
90- 'Requested out target was stdout but there are multiple generated files'
91- )
84+ logger . error (
85+ 'Requested out target was stdout but there are multiple generated files'
86+ )
9287 poms . forEach ( fn => console . error ( '-' , fn ) )
9388 console . error ( 'Exiting now...' )
9489 process . exit ( 1 )
9590 } else {
9691 // if (verbose) {
97- // spinner.start (
92+ // console.log (
9893 // `Moving manifest file from \`${loc.replace(/^\/home\/[^/]*?\//, '~/')}\` to \`${out}\``
9994 // )
10095 // } else {
101- // spinner.start ('Moving output pom file')
96+ // console.log ('Moving output pom file')
10297 // }
10398 // TODO: do we prefer fs-extra? renaming can be gnarly on windows and fs-extra's version is better
10499 // await renamep(loc, out)
105- spinner . start ( ) . success ( `Generated ${ poms . length } pom files` )
100+ logger . success ( `Generated ${ poms . length } pom files` )
106101 poms . forEach ( fn => console . log ( '-' , fn ) )
107- spinner . start ( ) . success ( `OK` )
102+ logger . success ( `OK` )
108103 }
109104 } catch ( e ) {
110105 spinner . errorAndStop (
0 commit comments