Skip to content

Commit 968ee2f

Browse files
committed
added dependency checker
1 parent 9c4793c commit 968ee2f

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

dependency-checker.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
const { spawnSync } = require( 'child_process' );
2+
const outdatedCmd = spawnSync( 'npm', [ 'outdated' ] );
3+
4+
const lines = outdatedCmd.stdout.toString().split( '\n' );
5+
6+
const columnIndexes = [ 0, 0, 0, 0 ];
7+
8+
console.log(
9+
'<p align="center">\n' +
10+
' <a href="http://opentemplatehub.com">\n' +
11+
' <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' +
12+
' </a>\n' +
13+
'</p>\n' +
14+
'\n' +
15+
'\n' +
16+
'<h1 align="center">\n' +
17+
'Open Template Hub - Company Profile UI Template v2\n' +
18+
' <br/>\n' +
19+
'(outdated packages)\n' +
20+
'</h1>\n' +
21+
'\n' +
22+
'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'
23+
);
24+
25+
for ( const line of lines ) {
26+
if ( line.length === 0 ) {
27+
continue;
28+
}
29+
30+
if ( lines.indexOf( line ) === 0 ) {
31+
columnIndexes[ 0 ] = line.indexOf( 'Current' );
32+
columnIndexes[ 1 ] = line.indexOf( 'Wanted' ) + 3;
33+
columnIndexes[ 2 ] = line.indexOf( 'Latest' ) + 6;
34+
columnIndexes[ 3 ] = line.indexOf( 'Location' ) + 9;
35+
}
36+
37+
let modifiedLine = line;
38+
39+
if ( columnIndexes [ 0 ] >= 0 ) {
40+
for ( const columnIndex of columnIndexes ) {
41+
modifiedLine = modifiedLine.substring( 0, columnIndex ) + ' | ' + modifiedLine.substring( columnIndex, modifiedLine.length );
42+
}
43+
console.log( '| ' + modifiedLine + ' |' );
44+
} else {
45+
console.log( modifiedLine );
46+
}
47+
48+
if ( lines.indexOf( line ) === 0 ) {
49+
console.log( '| --- | --- | --- | --- | --- |' );
50+
}
51+
}
52+
53+
console.log(
54+
'\n' +
55+
'<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'
56+
);

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"main": "dist/index.js",
88
"scripts": {
99
"start": "ts-node src/index.ts",
10-
"build": "tsc"
10+
"build": "tsc",
11+
"outdated": "node dependency-checker.ts > docs/OUTDATED.md"
1112
},
1213
"bin": {
1314
"open-template-hub-server-generator": "dist/index.js"

0 commit comments

Comments
 (0)