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

token-transformer-cli

v1.1.4

Published

Token Transformer CLI: A versatile library that enables the transformation of token information into desired forms (e.g., converting design tokens into CSS, SCSS, and more).

Downloads

132

Readme

Token Transformer CLI

NPM License NPM Downloads

Token Transformer CLI: A versatile library that enables the transformation of token information into desired forms (e.g., converting design tokens into CSS, SCSS, and more).

Installation

The easiest way to install token-transformer-cli is with npm.

npm install token-transformer-cli token-transformer-presets -g

Alternately, download the source.

git clone https://github.com/stegano/token-transformer-cli.git

Quick Starts

Get started quickly with token-transformer-presets

  • Convert Zeplin design token to a CSS file.

    tt run -p token-transformer-presets/zeplin-css -t <tokenFilePath>
  • Convert Zeplin design token to a SCSS file.

    tt run -p token-transformer-presets/zeplin-scss -t <tokenFilePath>
  • Parsing JWT tokens and displaying them on the screen.

    tt run <token> -p token-transformer-presets/jwt-viewer # or `tt -p token-transformer-presets/jwt-viewer` -t <tokenFilePath>

Quick Setting Example

This configuration sets Token Transformer CLI to run with jwt-viewer preset as the default.

  • Create a dedicated CLI configuration file.

    cd ~ && tt init --cli 
  • Save the jwt-viewer preset configuration.

    tt config set -n presets -v token-transformer-presets/jwt-viewer
  • Runt Token Transformer CLI with jwt-viewer

    tt run "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ"

Commands

You can run Token Transformer CLI via tt or tt-cli command. To see the commands and options, run the following command line.

tt --help

Advanced

Configuration

If you want to use a complex transformation process, it is recommended to configure the configuration file.

Create a tt.config.js or tt.config.json file.

Create a default Token Transformer CLI configuration file(tt.config.js or tt.config.json)

Please refer to the Config interface

tt init # or tt init --cli

Customizing

You can create and use custom pre or post-processors and presets.

Pre-Processor

The pre-processor converts the input token string into object form for use in the template.

The pre-processor accepts either a token string or an object as an argument and returns an object. The first pre-processor receives a token string as an argument, and subsequent preprocessors receive an object that is the return value of the previously executed pre-processor.

Below is an example of converting the input token to JSON.

const preProcessor = (data: string | object, options?: Readonly<object>): object => {
  if(typeof data === "string") {
    return JSON.stringify(data);
  }
  return data;
}

Post-Processor

The post-processor can reprocess the template string converted by Transformer.

The post-processor receives the template string as the first argument and the data object used when constructing the template as the second argument, reprocesses it, and returns a string. The first preprocessor receives the converted template string as its first argument, but subsequent postprocessors receive as its argument the string that is the return value of the previously executed post-processor.

Below is an example of removing consecutive spaces in a string.

const postProcessor = (content: string, data: Readonly<object>, options?: Readonly<object>): string => {
  return template.replace(/\s{2,}/, " ");
}

Presets

Presets allow you to pre-configure a pre-processor post-processor and some settings. See Preset Interface for details.