/rustywind

CLI for organizing Tailwind CSS classes

Primary LanguageRust

RustyWind Build Status Travis Build Status Appveyor npm version

Install

Available via npm

yarn global add rustywind

or

npm install -g rustywind

or

Install from a github release:

curl -LSfs https://avencera.github.io/rustywind/install.sh | sh -s -- --git avencera/rustywind

or

Download a release directly from github: github.com/avencera/rustywind/releases

Usage

Run rustywind with a path to output updated file contents to the terminal:

  • rustywind .

If you want to reorganize all classes in place, and change the files run with the --write flag

  • rustywind --write .

Run rustywind with a path and the --dry-run to get a list of files that will be changed:

  • rustywind --dry-run .

Run rustywind on your STDIN:

  • echo "<FILE CONTENTS>" | rustywind --stdin

For more options run help

  • rustywind --help

What

Inspired by Ryan Heybourn's headwind vscode plugin. This is a CLI tool that will look through your project and sort all Tailwind CSS classes.

It will also delete any duplicate classes it finds.

Why?

When Ryan released his vscode extension some people expressed an interest in having a CLI version.

In addition, I've had an interest in learning rust. I usually learn by doing. I thought this would be the perfect opportunity to make a small useful tool while learning rust.

Keep in mind this is my first rust project. My code here is most likely going to be ugly and not idiomatic rust. If you are a rust expert you're help in making the code nicer and more idiomatic will be greatly appreciated.

Any and all feedback and criticism is very welcome. If im doing anything stupid please let me know.

The Plan

MVP

  1. Run on current directory
  2. Order all classes in all files in directory (except for gitignored ones)

Development Plan

  1. Get a list of all files in current directory recursively. #1
  2. Ignore all files in .gitignore #1
  3. Get all contents from the list of files 1 by 1 #2
  4. Run regex on all file contents and get all class names #3
  5. Figure out how to sort class names using sorter array #4
  6. Replace old class names with new list of class names #5
  7. Save file #6
  8. Release via NPM (available via npm npm install rustywind -g)

Phase 2 (CLI)

  1. Add CLI parser #8
  2. Use CLI parser to choose directory or file to run on #8
  3. Add --write option which will change the files, change default to printing results to the terminal #8

Phase 3 (More CLI)

  1. Add --allow-duplicates to allow duplicate class name #10
  2. Add --dry-run option to print out all changes to console c975d1

Phase 4 (Performance)

  1. Search and change files in parallel (parallel map?) #9

Phase 5 (Match Headwind Features)

  1. Add custom sorter via CLI args --customer-sorter=...
  2. Add custom regex via CLI args --custom-regex=...

Later Possibilities...

  • Add ability to add custom sorter
  • Derive sorter from evaluation generated CSS from tailwind config file
  • Add ability to exclude folders, or files using regex pattern
  • Add argument for only searching in certain file types