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

@financial-times/ft-sass-to-css

v0.3.0

Published

A CLI tool that reports on usage of Origami Sass functions, mixins and variables.

Downloads

10

Readme

ft-sass-to-css

A CLI tool that reports on usage of Origami Sass functions, mixins and variables and provides a set of codemods to convert to o3 web tokens.

Installation

npm i -g @financial-times/ft-sass-to-css

Usage

Report

The report function can be used to view a breakdown of the component usage for a given path, broken down into mixins, functions and variables.

ft-sass-to-css report --path="./path/to/sass/**/*"

Example output:

Origami Sass Report:
┌────────────────────────┬────────┬───────────┬───────────┬───────┐
│        (index)         │ Mixins │ Functions │ Variables │ Total │
├────────────────────────┼────────┼───────────┼───────────┼───────┤
│        o-colors        │   5    │    20     │     1     │  26   │
│ o-editorial-typography │   5    │     0     │     0     │   5   │
│        o-fonts         │   0    │     1     │     0     │   1   │
│          ---           │        │           │           │       │
│         Total          │  10    │    21     │     1     │  32   │
└────────────────────────┴────────┴───────────┴───────────┴───────┘

The --path uses a glob pattern to capture scss files. Here's a few examples of the most common patterns:

ft-sass-to-css report --path="./**/*" # all scss files within active directory

ft-sass-to-css report --path="src/*" # all scss files within the src directory ONLY

ft-sass-to-css report --path="src/components/styles.scss" # single file

Dryrun

The dryrun command will attempt to perform the available codemods against a given path and return the modified file's content to the console. It will not modify any files. To learn about which components are currently supported view the Support section below.

ft-sass-to-css dryrun --path="src/*" --component="component-name" --brand="brand-name"

You may get a lot of content back from this command, as it'll return the entire Sass file's contents. It might be easier to pipe the output from the command to a text file to validate the changes.

ft-sass-to-css dryrun --path="src/*" --component="component-name" --brand="brand-name" > output.txt

[!IMPORTANT] Supported Brands: core, internal, professional, whitelabel.

Modify

We recommend running the dryrun command before this step.

The modify command will perform the available codemods and overwrite your Sass files with the updated values. To learn about which components are currently supported view the Support section below.

ft-sass-to-css modify --path="./**/*" --component="component-name" --brand="brand-name"

[!IMPORTANT] Supported Brands: core, internal, professional, whitelabel.

Once the process is complete you'll see an output in the console breaking down how many files were modified.

Support

Please refer to the list below to see which components and their respective functions, mixins and variables are currently supported by the dryrun and modify commands. We're continually working on adding more components.

o-colors

Functions:

  • oColorsByName()
  • oColorsByUseCase()
  • oColorsMix()
    • There is only some (~20%) support for oColorsMix. You may be mixing a color that doesn't exist as a new Origami variable token. Please refer to the o-colors Migration Guide for more info.

o-fonts

Funtions:

  • oFontsWeight()

o-spacing

Funtions:

  • oSpacingByName()
  • oSpacingByIncrement()*

o-typography

Mixins:

  • oTypographySans()
  • oTypographySerif()
  • oTypographyDisplay()

* These codemods replace the function with its compiled output, as they have no direct equivalent in o3-foundation.

Local Development

Installation and configuration

git clone [email protected]:Financial-Times/ft-sass-to-css.git
cd ft-sass-to-css
npm install
npm link

Execution

You can run the report, dryrun and modify CLI commands against the files within the demo directory with the following shortcuts:

npm run report-demo
npm run dryrun-demo
npm run modify-demo

Testing

The following command:

npm run test

runs Jest and tests core functionality. These tests are executed as part of the CircleCI process; it will not deploy with failing tests.

Coding Standards

We drive secure maintainable code through the use of ESlint and Snyk via regular execution of the following commands:

npm run lint                  # View linting errors
npm run lint:fix         # Attempt to fix linting errors automatically

Deploying the Application

You can release a new version to NPM by creating a Github release following semantic version numbering, preceeded by a v, e.g v0.0.1