Files
enm-cli/util/logProject.js
Vyacheslav.Sviridov bcc0a42f73 bulk import creation
2022-06-26 21:09:48 +06:00

36 lines
1.1 KiB
JavaScript
Executable File

const chalk = require('chalk')
function logProject(data, nodeSummary) {
if (!data || !nodeSummary) {
throw new Error('No project data or node summary❗')
}
const {
id: projectId,
description,
creator,
creationDate,
nodes,
} = data
console.log(`
${chalk.italic.yellowBright('Project id')} : ${chalk.bold.inverse(projectId)}
${chalk.italic.yellowBright('Author')} : ${chalk.underline(creator)}
${chalk.italic.yellowBright('Creation Date')} : ${chalk.dim.gray(creationDate)}
${chalk.italic.yellowBright('Description')} : ${description}
${chalk.italic.yellowBright('Nodes')} :
`)
nodes.forEach(node => {
const { id: nodeId, type, identifier, ipAddress } = node
const { status, state } = nodeSummary.find(item => item.id === nodeId)
console.log(` ${chalk.cyan(nodeId)}
${type}
${identifier}
${ipAddress}
${status === 'Successful' ? chalk.greenBright(status) : chalk.redBright(status) }
${state}
`)
})
}
module.exports = logProject