Skip to content

Instantly share code, notes, and snippets.

@ryanhanwu
Created March 23, 2020 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanhanwu/347859674ac2036b8efb67caa204048b to your computer and use it in GitHub Desktop.
Save ryanhanwu/347859674ac2036b8efb67caa204048b to your computer and use it in GitHub Desktop.
const csv = require('csv-parser');
const fs = require('fs');
const endPoints = {}
console.log("digraph g{")
console.log("rankdir=LR;")
console.log("node [style=filled];")
fs.createReadStream('data.csv')
.pipe(csv())
.on('data', (row) => {
endPoints[row.Endpoint] = {}
const depts = row['Internal Dependencies'].split('\n').filter(Boolean)
const testDepts = row['Integration Test Dependencies'].split('\n').filter(Boolean)
const tableDepts = row['Major Internal Table Dependencies'] ?
row['Major Internal Table Dependencies'].split('\n').filter(Boolean) :
[]
const tables = []
depts.forEach((dept) => {
console.log(`"${row.Endpoint}"->"${dept}" [color="0.002 0.999 0.999"]`);
})
tableDepts.forEach((table) => {
console.log(`"${row.Endpoint}"->"${table}"`);
tables.push(table)
})
testDepts.forEach((dept) => {
console.log(`"${row.Endpoint}"->"${row.Endpoint} Integration Test"->"${dept}" [color="0.348 0.839 0.839"]`);
// console.log(`"${row.Endpoint}"->"Integration Test"->"${dept}"`);
})
tables.forEach((table) => {
console.log(`${table} [color="0.650 0.200 1.000"]`);
})
//
})
.on('end', () => {
console.log("}")
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment