Theo CLI

January 20, 2019 · View on GitHub

Theo comes with a CLI that allows you to use theo to build one or multiple tokens. The CLI forwards on the formats and other relevant options to theo in order to build the token in the desired formats.

Basic usage

$ theo <[file]> [options]

Options

NameDescriptionDefault
--transformvalid theo transformraw
--formatComma separated list of valid theo formatsraw.json
--destThe path where the result should be writtenstdout
--setupThe path to an optional JS module that can set up Theo before transformation.
--resolveMetaAliasesResolve aliases in metadatafalse

transforms / formats

Formats are valid theo supported formats, check the documentation for a full list of supported transforms and formats.

Usage example with formats:

$ theo tokens.yml --transform web --format scss,cssmodules.css
$ theo tokens.yml --transform web --format scss,cssmodules.css --resolveMetaAliases

setup module

A valid setup module exports a function that takes theo as the first argument.

Example module (example.js):

module.exports = theo => {
  theo.registerValueTransform(
    'addpx',
    prop => prop.get('type') === 'size',
    prop => prop.get('value') + 'px'
  );
  theo.registerTransform("web", ['addpx']);
}

Usage example with setup

$ theo tokens.yml --setup example.js --transform web --format scss

npm scripts usage

Typically usage is within npm scripts:

{
  "scripts": {
    "build": "theo tokens.yml --format scss,cssmodules.css --dest ."
  }
}

the following result will be printed on your terminal:

✏️  scss tokens created at "./tokens.scss"
✏️  cssmodules.css tokens created at "./tokens.cssmodules.css"

and the following files will be written in your project directory:

yourTokenDir/
├── ...
├── tokens.scss
├── tokens.cssmodules.css
└── ...