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 bac3776 commit b0ab16a
Showing 1 changed file with 41 additions and 29 deletions.
70 changes: 41 additions & 29 deletions dependency-checker.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
const { spawnSync } = require( "child_process" );
const outdatedCmd = spawnSync( "npm", [ "outdated" ] );
const { spawnSync } = require( 'child_process' );
const outdatedCmd = spawnSync( 'npm', [ 'outdated' ] );

const lines = outdatedCmd.stdout.toString().split( "\n" );
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/ui/mobile-ui-logo.png\" alt=\"Logo\" width=\"200\">\n" +
" </a>\n" +
"</p>\n" +
"\n" +
"\n" +
"<h1 align=\"center\">\n" +
"Open Template Hub - Mobile UI Template v4\n" +
" <br/>\n" +
"(outdated packages)\n" +
"</h1>\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",
'<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/ui/web-ui-logo.png" alt="Logo" width=200>\n' +
' </a>\n' +
'</p>\n' +
'\n' +
'\n' +
'<h1 align="center">\n' +
'Open Template Hub - Company Profile UI Template v4\n' +
' <br/>\n' +
'(outdated packages)\n' +
'</h1>\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 ) {
Expand All @@ -28,40 +30,50 @@ for ( const line of lines ) {
}

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;
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 = "";
let modifiedLine = '';

if ( columnIndexes [ 0 ] >= 0 ) {
const stringParts = line.split( /(\s+)/ );

modifiedLine += "| ";
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;
}

for ( let part of stringParts ) {
if ( part.match( /\s+/ ) ) {
modifiedLine += " | ";
modifiedLine += ' | ';
} else {
modifiedLine += part;
}
}

modifiedLine += " |";
modifiedLine += ' |';

console.log( modifiedLine );
} else {
console.log( modifiedLine );
}

if ( lines.indexOf( line ) === 0 ) {
console.log( "| --- | --- | --- | --- | --- |" );
console.log( '| --- | --- | --- | --- | --- |' );
}
}

console.log(
"\n" +
"<table align=\"right\"><tr><td><a href=\"https://opentemplatehub.com\"><img src=\"https://raw.githubusercontent.com/open-template-hub/open-template-hub.github.io/master/assets/logo/brand-logo.png\" width=\"50px\" alt=\"oth\"/></a></td><td><b>Open Template Hub © 2021</b></td></tr></table>\n",
'\n' +
'<table align="right"><tr><td><a href="https://opentemplatehub.com"><img src="https://raw.githubusercontent.com/open-template-hub/open-template-hub.github.io/master/assets/logo/brand-logo.png" width="50px" alt="oth"/></a></td><td><b>Open Template Hub © 2021</b></td></tr></table>\n'
);

0 comments on commit b0ab16a

Please sign in to comment.