Skip to content

Commit

Permalink
added dependency checker
Browse files Browse the repository at this point in the history
  • Loading branch information
furknyavuz committed Oct 4, 2021
1 parent 9c4793c commit 968ee2f
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
56 changes: 56 additions & 0 deletions dependency-checker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const { spawnSync } = require( 'child_process' );
const outdatedCmd = spawnSync( 'npm', [ 'outdated' ] );

const lines = outdatedCmd.stdout.toString().split( '\n' );

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

console.log(
'<p align="center">\n' +
' <a href="http://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 v2\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 ) {
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 = line;

if ( columnIndexes [ 0 ] >= 0 ) {
for ( const columnIndex of columnIndexes ) {
modifiedLine = modifiedLine.substring( 0, columnIndex ) + ' | ' + modifiedLine.substring( columnIndex, modifiedLine.length );
}
console.log( '| ' + modifiedLine + ' |' );
} else {
console.log( modifiedLine );
}

if ( lines.indexOf( line ) === 0 ) {
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'
);
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"main": "dist/index.js",
"scripts": {
"start": "ts-node src/index.ts",
"build": "tsc"
"build": "tsc",
"outdated": "node dependency-checker.ts > docs/OUTDATED.md"
},
"bin": {
"open-template-hub-server-generator": "dist/index.js"
Expand Down

0 comments on commit 968ee2f

Please sign in to comment.