diff --git a/CHANGELOG.md b/CHANGELOG.md index f38591e..1993e8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +## [0.15.0] - 2022-04-25 + +- Add `--config-file` option, thanks [@mweiss-carerev](https://github.com/mweiss-carerev) [#58](https://github.com/avencera/rustywind/pull/58) + ## [0.14.0] - 2022-03-14 - `--ignore-files` option, thanks [@ftonato](https://github.com/neonowy) [#55](https://github.com/avencera/rustywind/pull/55) diff --git a/Cargo.lock b/Cargo.lock index 9a876f2..e6f3558 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -555,7 +555,7 @@ checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" [[package]] name = "rustywind" -version = "0.14.0" +version = "0.15.0" dependencies = [ "aho-corasick", "clap", diff --git a/Cargo.toml b/Cargo.toml index d9715a9..f856622 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ authors = ["Praveen Perera "] edition = "2021" name = "rustywind" -version = "0.14.0" +version = "0.15.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/README.MD b/README.MD index 9f3e61d..3d11983 100644 --- a/README.MD +++ b/README.MD @@ -48,73 +48,71 @@ Run in CI, exit with error if unsorted classes are found: - `rustywind --check-formatted .` -For more options run help +Run RustyWind with a custom sorter. The `config_file.json` should have a top level entry of `sortOrder` +which is an array with the classes listed in the order you want them sorted. -- `rustywind --help` +- `rustywind --config-file config_file.json` -## What - -Inspired by [Ryan Heybourn's](https://github.com/heybourn) [headwind](https://github.com/heybourn/headwind) -vscode plugin. This is a CLI tool that will look through your project and sort all [Tailwind CSS](https://tailwindcss.com) classes. - -It will also delete any duplicate classes it finds. +```shell +RustyWind 0.14.0 +Praveen Perera -## Why? +USAGE: + Run rustywind with a path to get a list of files that will be changed + rustywind . --dry-run -When Ryan released his vscode extension some people expressed an interest in having a CLI version. + If you want to reorganize all classes in place, and change the files run with the `--write` flag + rustywind --write . -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. + To print only the file names that would be changed run with the `--check-formatted` flag + rustywind --check-formatted . -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. + If you want to run it on your STDIN, you can do: + echo "" | rustywind --stdin -Any and all feedback and criticism is very welcome. If im doing anything stupid please let me know. + rustywind [FLAGS] -## The Plan +ARGS: + ... A file or directory to run on -### ✅ ~~MVP~~ +OPTIONS: + --allow-duplicates + When set, RustyWind will not delete duplicated classes -1. ~~Run on current directory~~ -2. ~~Order all classes in all files in directory (except for gitignored ones)~~ + --check-formatted + Checks if the files are already formatted, exits with 1 if not formatted -#### ✅ ~~Development Plan~~ + --config-file + When set, RustyWind will use the config file to derive configurations. The config file + current only supports json with one property sortOrder,e.g. { "sortOrder": ["class1", + ...] } -1. ~~Get a list of all files in current directory recursively.~~ [#1](https://github.com/avencera/rustywind/pull/1) -2. ~~Ignore all files in .gitignore~~ [#1](https://github.com/avencera/rustywind/pull/1) -3. ~~Get all contents from the list of files 1 by 1~~ [#2](https://github.com/avencera/rustywind/pull/2) -4. ~~Run regex on all file contents and get all class names~~ [#3](https://github.com/avencera/rustywind/pull/3) -5. ~~Figure out how to sort class names using sorter array~~ [#4](https://github.com/avencera/rustywind/pull/4) -6. ~~Replace old class names with new list of class names~~ [#5](https://github.com/avencera/rustywind/pull/5) -7. ~~Save file~~ [#6](https://github.com/avencera/rustywind/pull/6) -8. ~~Release via NPM~~ (available via [npm](https://www.npmjs.com/package/rustywind) `npm install rustywind -g`) - - ~~[How to Distribute a Rust Binary on NPM](https://dev.to/kennethlarsen/how-to-distribute-a-rust-binary-on-npm-75n)~~ - - ~~[Trust Repo](https://github.com/japaric/trust)~~ - - ~~[Example](https://github.com/kennethlarsen/baelte-npm)~~ + --custom-regex + Uses a custom regex instead of default one -### ✅ ~~Phase 2 (CLI)~~ + --dry-run + Prints out the new file content with the sorted classes to the terminal -1. ~~Add CLI parser~~ [#8](https://github.com/avencera/rustywind/pull/8) -2. ~~Use CLI parser to choose directory or file to run on~~ [#8](https://github.com/avencera/rustywind/pull/8) -3. ~~Add `--write` option which will change the files, change default to printing results to the terminal~~ [#8](https://github.com/avencera/rustywind/pull/8) + -h, --help + Print help information -### ✅ ~~Phase 3 (More CLI)~~ + --ignored-files + When set, RustyWind will ignore this list of files -1. ~~Add `--allow-duplicates` to allow duplicate class name~~ [#10](https://github.com/avencera/rustywind/pull/10) -2. ~~Add `--dry-run` option to print out all changes to console~~ [c975d1](https://github.com/avencera/rustywind/commit/c975d1f041f95b45e15760ccded24dbf62bf1f6f) + --stdin + Uses stdin instead of a file or folder -### ✅~~Phase 4 (Performance)~~ + -V, --version + Print version information -1. ~~Search and change files in parallel (parallel map?)~~ [#9](https://github.com/avencera/rustywind/pull/9) + --write + Changes the files in place with the reorganized classes -### Phase 5 (Match Headwind Features) +``` -1. Add custom sorter via CLI args `--customer-sorter=...` -2. ~~Add custom regex via CLI args `--custom-regex=...`~~ [#39](https://github.com/avencera/rustywind/pull/39) +## What -### Later Possibilities... +Inspired by [Ryan Heybourn's](https://github.com/heybourn) [headwind](https://github.com/heybourn/headwind) +vscode plugin. This is a CLI tool that will look through your project and sort all [Tailwind CSS](https://tailwindcss.com) classes. -- 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 +It will also delete any duplicate classes it finds. diff --git a/config.json b/config.json new file mode 100644 index 0000000..9e8a64c --- /dev/null +++ b/config.json @@ -0,0 +1 @@ +{ "sortOrder": [] } diff --git a/npm/README.MD b/npm/README.MD index 834f8a0..3d11983 100644 --- a/npm/README.MD +++ b/npm/README.MD @@ -1,5 +1,4 @@ -# RustyWind [![Build Status Travis](https://travis-ci.org/avencera/rustywind.svg?branch=master)](https://travis-ci.org/avencera/rustywind) [![Build Status Appveyor](https://ci.appveyor.com/api/projects/status/at89lbs7n35wqy96?svg=true)](https://ci.appveyor.com/project/praveenperera/rustywind) [![npm version](https://badge.fury.io/js/rustywind.svg)](https://badge.fury.io/js/rustywind) - +# RustyWind [![Mean Bean CI](https://github.com/avencera/rustywind/workflows/Mean%20Bean%20CI/badge.svg)](https://github.com/avencera/rustywind/actions?query=workflow%3A%22Mean+Bean+CI%22) [![npm version](https://badge.fury.io/js/rustywind.svg)](https://badge.fury.io/js/rustywind) ## Install @@ -11,91 +10,109 @@ or `npm install -g rustywind` -or +or Install from a github release: `curl -LSfs https://avencera.github.io/rustywind/install.sh | sh -s -- --git avencera/rustywind` -or +or Download a release directly from github: [github.com/avencera/rustywind/releases](https://github.com/avencera/rustywind/releases) +or + +You can use the dockerized version + +`docker run --rm -v $PWD:/app avencera/rustywind:latest ` + ## Usage Run rustywind with a path to output updated file contents to the terminal: - - `rustywind .` + +- `rustywind .` If you want to reorganize all classes in place, and change the files run with the `--write` flag - - `rustywind --write .` + +- `rustywind --write .` Run rustywind with a path and the `--dry-run` to get a list of files that will be changed: -- `rustywind --dry-run .` -For more options run help - - `rustywind --help` +- `rustywind --dry-run .` -## What +Run rustywind on your STDIN: -Inspired by [Ryan Heybourn's](https://github.com/heybourn) [headwind](https://github.com/heybourn/headwind) -vscode plugin. This is a CLI tool that will look through your project and sort all [Tailwind CSS](https://tailwindcss.com) classes. +- `echo "" | rustywind --stdin` -It will also delete any duplicate classes it finds. +Run in CI, exit with error if unsorted classes are found: + +- `rustywind --check-formatted .` + +Run RustyWind with a custom sorter. The `config_file.json` should have a top level entry of `sortOrder` +which is an array with the classes listed in the order you want them sorted. -## Why? +- `rustywind --config-file config_file.json` -When Ryan released his vscode extension some people expressed an interest in having a CLI version. +```shell +RustyWind 0.14.0 +Praveen Perera -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. +USAGE: + Run rustywind with a path to get a list of files that will be changed + rustywind . --dry-run -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. + If you want to reorganize all classes in place, and change the files run with the `--write` flag + rustywind --write . -Any and all feedback and criticism is very welcome. If im doing anything stupid please let me know. + To print only the file names that would be changed run with the `--check-formatted` flag + rustywind --check-formatted . -## The Plan + If you want to run it on your STDIN, you can do: + echo "" | rustywind --stdin -### ✅ ~~MVP~~ + rustywind [FLAGS] -1. ~~Run on current directory~~ -2. ~~Order all classes in all files in directory (except for gitignored ones)~~ +ARGS: + ... A file or directory to run on -#### ✅ ~~Development Plan~~ +OPTIONS: + --allow-duplicates + When set, RustyWind will not delete duplicated classes -1. ~~Get a list of all files in current directory recursively.~~ [#1](https://github.com/avencera/rustywind/pull/1) -2. ~~Ignore all files in .gitignore~~ [#1](https://github.com/avencera/rustywind/pull/1) -3. ~~Get all contents from the list of files 1 by 1~~ [#2](https://github.com/avencera/rustywind/pull/2) -4. ~~Run regex on all file contents and get all class names~~ [#3](https://github.com/avencera/rustywind/pull/3) -5. ~~Figure out how to sort class names using sorter array~~ [#4](https://github.com/avencera/rustywind/pull/4) -6. ~~Replace old class names with new list of class names~~ [#5](https://github.com/avencera/rustywind/pull/5) -7. ~~Save file~~ [#6](https://github.com/avencera/rustywind/pull/6) -8. ~~Release via NPM~~ (available via [npm](https://www.npmjs.com/package/rustywind) `npm install rustywind -g`) - - ~~[How to Distribute a Rust Binary on NPM](https://dev.to/kennethlarsen/how-to-distribute-a-rust-binary-on-npm-75n)~~ - - ~~[Trust Repo](https://github.com/japaric/trust)~~ - - ~~[Example](https://github.com/kennethlarsen/baelte-npm)~~ + --check-formatted + Checks if the files are already formatted, exits with 1 if not formatted -### ✅ ~~Phase 2 (CLI)~~ + --config-file + When set, RustyWind will use the config file to derive configurations. The config file + current only supports json with one property sortOrder,e.g. { "sortOrder": ["class1", + ...] } -1. ~~Add CLI parser~~ [#8](https://github.com/avencera/rustywind/pull/8) -2. ~~Use CLI parser to choose directory or file to run on~~ [#8](https://github.com/avencera/rustywind/pull/8) -3. ~~Add `--write` option which will change the files, change default to printing results to the terminal~~ [#8](https://github.com/avencera/rustywind/pull/8) + --custom-regex + Uses a custom regex instead of default one -### ✅ ~~Phase 3 (More CLI)~~ -1. ~~Add `--allow-duplicates` to allow duplicate class name~~ [#10](https://github.com/avencera/rustywind/pull/10) -2. ~~Add `--dry-run` option to print out all changes to console~~ [c975d1](https://github.com/avencera/rustywind/commit/c975d1f041f95b45e15760ccded24dbf62bf1f6f) + --dry-run + Prints out the new file content with the sorted classes to the terminal -### ✅~~Phase 4 (Performance)~~ + -h, --help + Print help information -1. ~~Search and change files in parallel (parallel map?)~~ [#9](https://github.com/avencera/rustywind/pull/9) + --ignored-files + When set, RustyWind will ignore this list of files -### Phase 5 (Match Headwind Features) -1. Add custom sorter via CLI args `--customer-sorter=...` -2. Add custom regex via CLI args `--custom-regex=...` + --stdin + Uses stdin instead of a file or folder -### Later Possibilities... + -V, --version + Print version information -- 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 + --write + Changes the files in place with the reorganized classes + +``` + +## What + +Inspired by [Ryan Heybourn's](https://github.com/heybourn) [headwind](https://github.com/heybourn/headwind) +vscode plugin. This is a CLI tool that will look through your project and sort all [Tailwind CSS](https://tailwindcss.com) classes. + +It will also delete any duplicate classes it finds. diff --git a/npm/lib/postinstall.js b/npm/lib/postinstall.js index 681137d..1627d8e 100644 --- a/npm/lib/postinstall.js +++ b/npm/lib/postinstall.js @@ -16,7 +16,7 @@ if (forceInstall) { console.log("--force, ignoring caches"); } -const VERSION = "v0.14.0"; +const VERSION = "v0.15.0"; const BIN_PATH = path.join(__dirname, "../bin"); process.on("unhandledRejection", (reason, promise) => { diff --git a/npm/package-lock.json b/npm/package-lock.json index 74a7790..734568a 100644 --- a/npm/package-lock.json +++ b/npm/package-lock.json @@ -1,12 +1,12 @@ { "name": "rustywind", - "version": "0.14.0", + "version": "0.15.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "rustywind", - "version": "0.14.0", + "version": "0.15.0", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/npm/package.json b/npm/package.json index 6d28029..93ea021 100644 --- a/npm/package.json +++ b/npm/package.json @@ -1,6 +1,6 @@ { "name": "rustywind", - "version": "0.14.0", + "version": "0.15.0", "description": "CLI for organizing Tailwind CSS classes", "main": "lib/index.js", "typings": "lib/index.d.ts",