Skip to content

Commit

Permalink
update dependency checker
Browse files Browse the repository at this point in the history
  • Loading branch information
furknyavuz committed Jun 16, 2022
1 parent 6385bd9 commit 695315a
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions dependency-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ const lines = outdatedCmd.stdout.toString().split( '\n' );

const columnIndexes = [ 0, 0, 0, 0 ];

let indexOfDependedBy = -1;

console.log(
'<p align="center">\n' +
' <a href="https://opentemplatehub.com">\n' +
' <img src="https://raw.githubusercontent.com/open-template-hub/open-template-hub.github.io/master/assets/logo/generator/server-generator-logo.png" alt="Logo" width=200>\n' +
' <img src="https://raw.githubusercontent.com/open-template-hub/open-template-hub.github.io/master/assets/logo/ui/web-ui-logo.png" alt="Logo" width=200>\n' +
' </a>\n' +
'</p>\n' +
'\n' +
'\n' +
'<h1 align="center">\n' +
'Open Template Hub - Server Generator v4\n' +
'Open Template Hub - Company Profile UI Template v4\n' +
' <br/>\n' +
'(outdated packages)\n' +
'</h1>\n' +
Expand All @@ -26,36 +28,46 @@ 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 part of stringParts ) {

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( '| --- | --- | --- | --- | --- |' );
}
Expand Down

0 comments on commit 695315a

Please sign in to comment.