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

@syncify/ansi

v0.2.2

Published

ANSI Colors, Symbols and TUI related terminal enchancements for Syncify.

Downloads

67

Readme

@syncify/ansi

Terminal utilities for the Syncify CLI Shopify theme development tool. This module provides CLI enhancements, helpers and various other TUI logic which are used in console logging and reporting for Syncify.

Installation

$ pnpm add @syncify/ansi -D

Colors

Terminal colors are exposed and made available using Ansis. There are custom colors and raw access to Ansis is available.

Standard Colors

Bright Colors

Custom Colors

Symbols

There are various symbols (characters) available as named exports. Symbols in the CLI are color wrapped and injected into strings when composing logs and messaged etc.

Character Helpers

Character are const exports, they are output in darkGray by default.

import {
  PIP // |
  HSH // #
  PLS // +
  MIN // -
  COM // ,
  CHK // ✓
  BAD // 𐄂
  COL // :
  ARR // →
  CHV // ▸
  ARL // ⥂
  TLD // ~
  DSH // —
} from '@syncify/ansi'

Infix Wrappers

Infix wrappers are const exports, they are output in darkGray by default.

import {
  LPR // (
  RPR // )
  LCB // {
  RCB // }
  LSB // [
  RSB // ]
  LAN // <
  RAN // >
} from '@syncify/ansi'

Tree Characters

Tree characters available on the Tree named export and are output in darkGray by default. Characters are also available in red and yellow colors.

import { Tree } from '@syncify/ansi';

Tree.open         // ┌─
Tree.stub         // ├
Tree.dash         // ├─
Tree.line         // │
Tree.base         // └─
Tree.next         // \n│
Tree.after        // │\n
Tree.wrap         // \n│\n

Tree.indent.edge  // ├──┬─
Tree.indent.line  // │  │
Tree.indent.stub  // │  ├
Tree.indent.dash  // │  ├─
Tree.indent.base  // │  └─
Tree.indent.fall  // ├──┐

Tree Create

Log message generator instance which can be used to compose a complex output log.

import { Create } from '@syncify/ansi';

const message = Create();

message.BR;
message.NL;
message.Break();
message.Context();
message.Dash();
message.End();
message.Error();
message.Get();
message.Inline();
message.Insert();
message.Line();
message.Newline();
message.Pop();
message.Remove();
message.Ruler();
message.Top();
message.Trim();
message.Warn();
message.Wrap();
message.toLine();
message.toRaw();
message.toString();

Spinner

Symbol Spinner utility which will persist a terminal animation.

import { spinner } from '@syncify/ansi';

spinner('loading', {
  line: true,
  action: {},
  color: 'pink',
  style: 'spinning'
});

spinner.update('');
spinner.stop();

Progress

Progress bar utility is available on the progress named export. This function returns an instance with methods.

▰▰▰▰▰▰▰▰▰▰▱▱▱▱▱▱▱▱▱▱ 50%

Usage

import { progress } from '@syncify/ansi';

const loading = progress(25, {
  showPercentage: true,
  barColor: 'neonGreen',
  percentColor: 'whiteBright',
  barSize: 40,
  clearOnComplete: false
});

loading.increment(1);  // Increment progress
loading.decrement(1);  // Decrement progress
loading.render()       // Render the progress bar, returns string
loading.stop()         // Stop progress
loading.percent        // Returns loading percentage

Terminal Size

The module also exposes a helper utility for obtaining the developers terminal size and will return some information about the terminal dimensions.

import { tsize } from '@syncify/ansi';

const {
  wrap, // number
  cols, // number
  row // number
} = size();

Contributing

This package is designed for usage within Syncify. Contributions are not accepted unless they pertain to the core Syncify module. If contributions fall into that category, fork the Syncify project.