npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@juparog/print-table

v1.0.1

Published

print-table is a simple library that allows you to print beautiful and customizable tables in the console using ANSI escape codes. It is ideal for displaying tabular data in a clear and visually appealing way.

Downloads

80

Readme

print-table

All Contributors Coverage Status

print-table is a simple library that allows you to print beautiful and customizable tables in the console using ANSI escape codes. It is ideal for displaying tabular data in a clear and visually appealing way.

Installation

npm install @juparog/print-table

Usage

Here is an example of how to use print-table:

import { AlignmentText, BgColor, ConsoleTable, ROUNDED_BOX_THEME, TableOptions } from '@juparog/print-table';

// Define your table options
const tableOptions: TableOptions = {
  columns: [
    {
      header: { name: 'Rule 📜' },
      key: 'Rule',
      width: 20,
      bold: true,
    },
    { header: 'Group 📂', key: 'Group', width: 25 },
    {
      header: 'Status 🚥',
      key: 'Status',
      width: 20,
      bgColor: (value) => {
        if (value === 'Succeeded') {
          return BgColor.GREEN;
        }
        return BgColor.RED;
      },
      align: AlignmentText.CENTER_MIDDLE,
      styleFullCell: true,
    },
    {
      header: 'Messages 💬',
      key: 'Messages',
      width: 50,
      truncate: false,
    },
  ],
  data: [ // Your data goes here
    {
      Rule: 'NAMING_STANDARD',
      Group: 'Configuration management',
      Status: 'Succeeded',
      Messages: '',
    },
    {
      Rule: 'DEPLOY_DEV',
      Group: 'Continuous deployment',
      Status: 'Succeeded',
      Messages: '',
    },
    {
      Rule: 'DEPLOY_PDN',
      Group: 'Continuous deployment',
      Status: 'Failed',
      Messages:
        'Failed configurations in stage Deploy PDN: [You need configure some task like: ROLLBACK_TASK, REST_CALL_TASK. At least one must be configured.]',
    },
    {
      Rule: 'BUILD_TASKS',
      Group: 'Continuous integration',
      Status: 'Failed',
      Messages:
        'Failed configurations in stage Build: [Prohibited enabled value on Unit Test, it must match the expression "true".]',
    },
    {
      Rule: 'ACCEPTANCE_TEST',
      Group: 'Continuous integration',
      Status: 'Failed',
      Messages: 'No stages to validate',
    },
  ],
  theme: ROUNDED_BOX_THEME, // You can choose different themes for your table
};

// Create an instance of ConsoleTable
const consoleTable = new ConsoleTable(tableOptions);

// Print the table to the console
consoleTable.printTable();

Output of example:

$ ts-node ./index.ts
╭──────────────────────┬───────────────────────────┬──────────────────────┬────────────────────────────────────────────────────╮
│ Rule 📜              │ Group 📂                  │ Status 🚥            │ Messages 💬                                        │
├──────────────────────┼───────────────────────────┼──────────────────────┼────────────────────────────────────────────────────┤
│ NAMING_STANDARD      │ Configuration management  │      Succeeded       │                                                    │
├──────────────────────┼───────────────────────────┼──────────────────────┼────────────────────────────────────────────────────┤
│ DEPLOY_DEV           │ Continuous deployment     │      Succeeded       │                                                    │
├──────────────────────┼───────────────────────────┼──────────────────────┼────────────────────────────────────────────────────┤
│                      │                           │                      │ Failed configurations in stage Deploy PDN: [You ne │
│ DEPLOY_PDN           │ Continuous deployment     │        Failed        │ ed configure some task like: ROLLBACK_TASK, REST_C │
│                      │                           │                      │ ALL_TASK. At least one must be configured.]        │
├──────────────────────┼───────────────────────────┼──────────────────────┼────────────────────────────────────────────────────┤
│ BUILD_TASKS          │ Continuous integration    │      Succeeded       │                                                    │
├──────────────────────┼───────────────────────────┼──────────────────────┼────────────────────────────────────────────────────┤
│ ACCEPTANCE_TEST      │ Continuous integration    │        Failed        │ No stages to validate                              │
╰──────────────────────┴───────────────────────────┴──────────────────────┴────────────────────────────────────────────────────╯

In this example, we define a table with specific columns, data, and a theme. Customize your table's appearance by adjusting options such as column width, text alignment, background color, and more.

Features

  • Simple and intuitive API
  • Customizable themes for different table styles
  • Support for text alignment, background colors, and other styling options
  • Easy integration with existing Node.js projects

Explore the full range of features and customization options by referring to the documentation or exploring the source code.

License

This library is licensed under the MIT License - see the LICENSE file for details. Feel free to use and modify it according to your needs.

We hope you find print-table helpful for presenting your tabular data in a visually appealing way!

Contributors ✨

Thanks goes to these wonderful people (emoji key):