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

@mohalla-tech/atomizer-tailwindcss-migrator

v1.0.2

Published

A CLI tool to migrate from atomizer to tailwindcss

Downloads

17

Readme

Atomizer Tailwindcss Migrator

CLI tool to refactor atomizer codebases to tailwindcss

Screen Recording 2023-12-12 at 3 15 36 PM

Features

  • Transform atomizer classes to tailwindcss classes
  • Works with jsx, tsx, svelte, vue, html files
  • Generate report of all the changes
  • Dry run mode
  • Customizable mappings - you can pass json file with mappings from atomizer classes to tailwindcss classes
  • Customizable plugins - you can pass js file with plugins which will be loaded by the migrator

Installation

npm

npm install @mohalla-tech/atomizer-tailwindcss-migrator -g

yarn

yarn add @mohalla-tech/atomizer-tailwindcss-migrator -g

pnpm

pnpm add @mohalla-tech/atomizer-tailwindcss-migrator -g

Now you can run the migrator using tw-mg command

Options

-h, --help

Show help

-s, --style - required

Path to atomizer generated css file, it contains all the generated classes

-t, --target - required

Target files to transform, supports glob pattern

-d, --dry-run

Dry run mode, will only generate report and open it

-no, --no-open

Do not open report in browser

-m, --mappings

Path to json file with mappings from atomizer classes to tailwindcss classes, for example we may want to replace $fzTitle variable with title in tailwindcss variable so any class like Fz($fzTitle) will be replaced with text-title

Ex:

{
  "$fzTitle": "title"
}

-p, --plugins

Path to js file with plugins which will be loaded by the migrator this can be helpful if you want to do some custom transformation for help on writing plugins see Writing Plugins

Usage

if we want to run without any mappings or plugins

tw-mg -s ./path/to/atomizer.css -t ./path/to/target/files

with mappings

tw-mg -s ./path/to/atomizer.css -t ./path/to/target/files -m ./path/to/mappings.json

with plugins

tw-mg -s ./path/to/atomizer.css -t ./path/to/target/files -p ./path/to/plugins.js

with mappings and plugins

tw-mg -s ./path/to/atomizer.css -t ./path/to/target/files -m ./path/to/mappings.json -p ./path/to/plugins.js

dry run mode - it will only generate report and open it

tw-mg -s ./path/to/atomizer.css -t ./path/to/target/files -d

Example

we have a file /src/styles/main.css with atomizer classes

.Fz($fzTitle) {
  font-size: $fzTitle;
}

.D\(f\) {
  display: flex;
}

.Bgc\(c\) {
  background-color: $c;
}

we want to transform all the atomizer classes to tailwindcss classes within /src/components directory

tw-mg -s ./src/styles/main.css -t ./src/components/**/*.jsx -d

this will generate a report and open it in browser, you can then review the changes and apply them by removing -d flag

tw-mg -s ./src/styles/main.css -t ./src/components/**/*.jsx

Writing Plugins

Plugin file must export an array of plugins which will be loaded by the migrator, plugins must be an object with name and plugin keys where name is the name of the plugin and plugin is a function which will be called for each atomizer class with className and mappings as arguments, className is the atomizer class and mappings is the mappings object passed to the migrator

module.exports = [
  {
    name: 'plugin-name',
    plugin: function (className, mappings) {
      // do something with atomizer
      // return null in case you want to skip this plugin
      return newClassName;
    },
  },
];