Example #1
0
function getAsTable(header, rows) {
  const table = new Table({
    chars: {
      bottom: '',
      'bottom-left': '',
      'bottom-mid': '',
      'bottom-right': '',
      left: '',
      'left-mid': '',
      mid: '',
      'mid-mid': '',
      middle: ' | ',
      right: '',
      'right-mid': '',
      top: '',
      'top-left': '',
      'top-mid': '',
      'top-right': '',
    },
    style: {
      border: [],
      'padding-left': 0,
      'padding-right': 0,
    },
  })
  table.push(header)
  table.push(...rows)
  return table.toString()
}
Example #2
0
    return through.obj(print, function (callback) {
        if (fileCount > 0) {
            // instantiate the table for printing sizes and space savings
            var sstable = new table({
                head: ['File', 'Original size', 'Minified size', 'Space savings'],
                colAligns: ['left', 'right', 'right', 'right'],
                style: {
                    head: ['cyan']
                }
            });

            // create the table rows
            var length = rows.length;
            for (var i = 0; i < length; i++) {
                sstable.push(rows[i]);
            }
            
            if (fileCount > 1) {
                // add footer with total sizes and space savings if there are more than one file
                var totalSpaceSaving = 1 - totalMinifiedSize / totalOriginalSize;
                totalSpaceSaving = parseFloat(totalSpaceSaving.toFixed(3)) + "%";
                sstable.push([
                    gutil.colors.cyan.bold('Total'),
                    gutil.colors.cyan.bold(prettyBytes(totalOriginalSize)),
                    gutil.colors.cyan.bold(prettyBytes(totalMinifiedSize)),
                    gutil.colors.cyan.bold(totalSpaceSaving)
                ]);
            }

            // print the whole table
            console.log(sstable.toString());
        }

        callback();
    });
Example #3
0
    .then((ctx) => {
      const resultTypes = Object.keys(ctx.data)
      if (resultTypes.length) {
        const resultTable = new Table()

        resultTable.push([{colSpan: 2, content: 'Exported entities'}])

        resultTypes.forEach((type) => {
          resultTable.push([startCase(type), ctx.data[type].length])
        })

        console.log(resultTable.toString())
      } else {
        console.log('No data was exported')
      }

      if ('assetDownloads' in ctx) {
        const downloadsTable = new Table()
        downloadsTable.push([{colSpan: 2, content: 'Asset file download results'}])
        downloadsTable.push(['Successful', ctx.assetDownloads.successCount])
        downloadsTable.push(['Warnings ', ctx.assetDownloads.warningCount])
        downloadsTable.push(['Errors ', ctx.assetDownloads.errorCount])
        console.log(downloadsTable.toString())
      }

      const durationHuman = options.startTime.fromNow(true)
      const durationSeconds = moment().diff(options.startTime, 'seconds')

      console.log(`The export took ${durationHuman} (${durationSeconds}s)`)
      if (options.saveFile) {
        console.log(`\nStored space data to json file at: ${options.logFilePath}`)
      }
      return ctx.data
    })
Example #4
0
function outputStartupInformation(options) {
  const {
    updateInfo,
    version,
    address,
    networkAddress,
    managerTotalTime,
    previewTotalTime,
  } = options;

  const updateMessage = createUpdateMessage(updateInfo, version);

  const serveMessage = new Table({
    chars: {
      top: '',
      'top-mid': '',
      'top-left': '',
      'top-right': '',
      bottom: '',
      'bottom-mid': '',
      'bottom-left': '',
      'bottom-right': '',
      left: '',
      'left-mid': '',
      mid: '',
      'mid-mid': '',
      right: '',
      'right-mid': '',
      middle: '',
    },
    paddingLeft: 0,
    paddingRight: 0,
    paddingTop: 0,
    paddingBottom: 0,
  });

  serveMessage.push(
    ['Local:', chalk.cyan(address)],
    ['On your network:', chalk.cyan(networkAddress)]
  );

  const timeStatement = previewTotalTime
    ? `${chalk.underline(prettyTime(managerTotalTime))} for manager and ${chalk.underline(
        prettyTime(previewTotalTime)
      )} for preview`
    : `${chalk.underline(prettyTime(managerTotalTime))}`;

  // eslint-disable-next-line no-console
  console.log(
    boxen(
      stripIndents`
          ${colors.green(`Storybook ${chalk.bold(version)} started`)}
          ${chalk.gray(timeStatement)}

          ${serveMessage.toString()}${updateMessage ? `\n\n${updateMessage}` : ''}
        `,
      { borderStyle: 'round', padding: 1, borderColor: '#F1618C' }
    )
  );
}
Example #5
0
exports.showBorderedMessage = function(cols, msg){
    var table = new Table({
        colWidths: [cols]
    });

    table.push([ msg ]);
    console.error(table.toString());
};
Example #6
0
  instance.on('done', (result) => {
    // the code below this `if` just renders the results table...
    // if the user doesn't want to render the table, we can just return early
    if (!opts.renderResultsTable) return

    const shortLatency = new Table({
      head: asColor(chalk.cyan, ['Stat', '2.5%', '50%', '97.5%', '99%', 'Avg', 'Stdev', 'Max'])
    })
    shortLatency.push(asLowRow(chalk.bold('Latency'), asMs(result.latency)))
    logToStream(shortLatency.toString())

    const requests = new Table({
      head: asColor(chalk.cyan, ['Stat', '1%', '2.5%', '50%', '97.5%', 'Avg', 'Stdev', 'Min'])
    })

    requests.push(asHighRow(chalk.bold('Req/Sec'), result.requests))
    requests.push(asHighRow(chalk.bold('Bytes/Sec'), asBytes(result.throughput)))
    logToStream(requests.toString())
    logToStream('')
    logToStream('Req/Bytes counts sampled once per second.\n')

    if (opts.renderLatencyTable) {
      const latencies = new Table({
        head: asColor(chalk.cyan, ['Percentile', 'Latency (ms)'])
      })
      percentiles.map((perc) => {
        const key = `p${perc}`.replace('.', '_')
        return [
          chalk.bold('' + perc),
          result.latency[key]
        ]
      }).forEach(row => {
        latencies.push(row)
      })
      logToStream(latencies.toString())
      logToStream('')
    }

    if (result.non2xx) {
      logToStream(`${result['2xx']} 2xx responses, ${result.non2xx} non 2xx responses`)
    }
    logToStream(`${format(result.requests.total)} requests in ${result.duration}s, ${prettyBytes(result.throughput.total)} read`)
    if (result.errors) {
      logToStream(`${format(result.errors)} errors (${format(result.timeouts)} timeouts)`)
    }
  })
Example #7
0
 tokens.forEach((token) => {
   table.push([
     token.id,
     token.token + '…',
     String(token.created).slice(0, 10),
     token.readonly ? 'yes' : 'no',
     token.cidr_whitelist ? token.cidr_whitelist.join(', ') : ''
   ])
 })
Example #8
0
//region private methods and helpers
/**
 * @private
 * @param line
 * @returns {*}
 */
function _lineToText(line) {
	/** @type {Object} **/
	let table = new Table();
	for (let k in line) {
		//noinspection JSUnfilteredForInLoop
		table.push({[k]: line[k] ? line[k].toString() : null});

	}

	return table;
}
Example #9
0
listCredChain.toText = function (list) {
	/** @type {Object} **/
	let table = new Table({
		head:      ['level', 'fqdn'],
		colWidths: [16, 64]
	});

	const _setStyle = (value, cred) => {
		let val = value || '';
		// noinspection JSUnresolvedFunction
		return cred.expired === true ? colors.red(val) : val;
	};
	for (let i = 0; i < list.length; i++) {
		table.push([_setStyle(list[i].metadata.level, list[i]), _setStyle(list[i].fqdn, list[i])]);
	}
	return table;
};
Example #10
0
function formatFinalStatsTable(totalStats) {

  var table = new Table({
    head: ['Metric', 'Result'],
    colWidths: [45, 15],
    style: {
      head: ['gray', 'bold']
    }
  });

  table.push(['Best response time'].concat(format_value((isNaN(totalStats.responseTime.min)) ? 'n/a' : totalStats.responseTime.min.toFixed(0), 1000, null, " ms")));
  table.push(['Slowest response time'].concat(format_value((isNaN(totalStats.responseTime.max))? 'n/a' : totalStats.responseTime.max.toFixed(0), 4000, null, " ms")));
  table.push(['Mean response time'].concat(format_value((isNaN(totalStats.responseTime.mean))? 'n/a' : totalStats.responseTime.mean.toFixed(0), 1000, null, " ms")));
  table.push(['Slowest response at 95%'].concat(format_value((!totalStats.responseTime.topAt) ? 'n/a' : totalStats.responseTime.topAt['0.05'].toFixed(0), 4000, null, " ms")));
  table.push(['Slowest response at 99%'].concat(format_value((!totalStats.responseTime.topAt) ? 'n/a' : totalStats.responseTime.topAt['0.01'].toFixed(0), 4000, null, " ms")));

  table.push(['Test run duration'].concat(format_value(totalStats.responseTime.testRunDurationInSec, null, null, " s")));
  table.push(['Requests completed'].concat(format_value(totalStats.responseTime.requestsCompleted, null, null)));
  table.push(['Completed transactions per sec'].concat(format_value(totalStats.responseTime.completedTransactionsPerSec.toFixed(0), null, null)));
  table.push(['Successfully completed requests'].concat(format_value(totalStats.responseTime.totalSuccessRate.toFixed(2)*100, null, null, "%")));


  return table.toString();
}
Example #11
0
function formatStatsTable2col(stats, dataCols, dataHeaderNames) {

  var table = new Table({
    head: ['Metric'].concat(dataHeaderNames),
    colWidths: [30].concat(dataCols.map(function(){return 15;})),
    style: {
      head: ['gray', 'bold']
    }
  });

  table.push(['Request sent'].concat(dataCols.map(function (dataCol) {
    return dataCol.requestSent;
  })));

  table.push(['Response received'].concat(dataCols.map(function (dataCol) {
    return dataCol.responseReceived;
  })));

  table.push(['Average response time'].concat(dataCols.map(function (dataCol) {
    return format_value(dataCol.avgResponseTime.toFixed(0), 1000, null, " ms");
  })));

  table.push(['Successfully completed'].concat(dataCols.map(function (dataCol) {
    return format_value(dataCol.responseSuccessRatio.toFixed(2)*100, null, 0.8, "%");
  })));

  if (stats.total.requestTimeouts && stats.total.requestTimeouts > 0) {
    table.push(['Request timeouts'].concat(dataCols.map(function (dataCol) {
      return format_value(dataCol.requestTimeouts, 0, null);
    })));
  }
  if (stats.total.unknownResponseErrors && stats.total.unknownResponseErrors > 0) {
    table.push(['Other response errors'].concat(dataCols.map(function (dataCol) {
      return format_value(dataCol.unknownResponseErrors, 0, null);
    })));
  }
  if (stats.total.non200HTTPResponses && stats.total.non200HTTPResponses > 0) {
    table.push(['HTTP status code is not 200'].concat(dataCols.map(function (dataCol) {
      return format_value(dataCol.non200HTTPResponses, 0, null);
    })));
  }

  if (stats.total.non200HTTPResponseBreakdown) {
    for(var key in stats.total.non200HTTPResponseBreakdown) {
      table.push(['HTTP status code ' + key].concat(dataCols.map(function (dataCol) {
        var val = (dataCol.non200HTTPResponseBreakdown) ? dataCol.non200HTTPResponseBreakdown[key] || 0 : 0;
        return format_value(val, 0, null);
      })));
    }
  }

  if (stats.total.custom) {
    for(var key in stats.total.custom) {
      table.push(['[custom] ' + key].concat(dataCols.map(function (dataCol) {
        return format_value((dataCol.custom[key] || 0), null, null);
      })));
    }
  }

  return table.toString();
}
Example #12
0
	creds.forEach(item => {
		table.push([_setStyle(item.name, item), _setStyle(item.fqdn, item)]);
	});
Example #13
0
	creds.forEach(item => {

		table.push([_setStyle(item.getMetadataKey("Name"), item), _setStyle(item.fqdn, item), _setStyle(item.getMetadataKey('PARENT_FQDN'), item), _setStyle(item.getCertEnd(), item), _setStyle(item.getKey('PRIVATE_KEY') ? 'Y' : 'N', item), _setStyle(!!(item.metadata.revoked) ? 'Bad' : 'Good', item)]);
	});
Example #14
0
	creds.forEach(item => {

		table.push([_setStyle(item.fqdn, item), _setStyle(item.notAfter.toLocaleString(), item), _setStyle(item.hasPrivateKey ? 'Y' : 'N', item), _setStyle(item.ocspStatus, item), _setStyle(CommonUtils.formatDate(item.lastLoginDate), item)]);
	});