const { spawnSync } = require( 'child_process' ); const outdatedCmd = spawnSync( 'npm', [ 'outdated' ] ); const lines = outdatedCmd.stdout.toString().split( '\n' ); const columnIndexes = [ 0, 0, 0, 0 ]; let indexOfDependedBy = -1; console.log( '

\n' + ' \n' + ' Logo\n' + ' \n' + '

\n' + '\n' + '\n' + '

\n' + 'Open Template Hub - Swagger Decorators v1\n' + '
\n' + '(outdated packages)\n' + '

\n' + '\n' + 'Following packages are not updated in the develop branch yet. So, if you want to update outdated packages on your own risk, update the package.json and install dependencies.\n' ); for ( const line of lines ) { if ( line.length === 0 ) { continue; } if ( lines.indexOf( line ) === 0 ) { columnIndexes[ 0 ] = line.indexOf( 'Current' ); columnIndexes[ 1 ] = line.indexOf( 'Wanted' ) + 3; columnIndexes[ 2 ] = line.indexOf( 'Latest' ) + 6; columnIndexes[ 3 ] = line.indexOf( 'Location' ) + 9; } let modifiedLine = ''; if ( columnIndexes [ 0 ] >= 0 ) { const stringParts = line.split( /(\s+)/ ); modifiedLine += '| '; for ( let i = 0; i < stringParts.length; ++i ) { const part = stringParts[ i ]; if ( lines.indexOf( line ) === 0 && i < stringParts.length - 1 && stringParts[ i + 1 ] === 'Depended' ) { indexOfDependedBy = i; } if ( indexOfDependedBy !== -1 && i >= indexOfDependedBy ) { continue; } if ( part.match( /\s+/ ) ) { modifiedLine += ' | '; } else { modifiedLine += part; } } modifiedLine += ' |'; console.log( modifiedLine ); } else { console.log( modifiedLine ); } if ( lines.indexOf( line ) === 0 ) { console.log( '| --- | --- | --- | --- | --- |' ); } } console.log( '\n' + '
othOpen Template Hub © 2023
\n' );