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

vite-react-cli-tool

v1.0.2

Published

Create a react project with a folder structure that respects the hexagonal architecture

Downloads

21

Readme

vite-react-cli-tool

vite-react-cli-tool is a command-line tool designed to scaffold React projects with a predefined hexagonal architecture. It sets up essential folders and integrates optional dependencies like Tailwind CSS, Redux Toolkit, and React Router, allowing for a faster and more structured development process.

Features

  • Scaffold React projects with a Vite + React template.
  • Hexagonal architecture setup with standard folders for modular organization: assets, components, modules, routes, store.
  • Optional dependency setup for Tailwind CSS, Redux Toolkit, and React Router with simple flags.

Installation

To install vite-react-cli-tool globally run:

npm install -g vite-react-cli-tool

Usage

To create a new React project with the hexagonal architecture:

vbc create <project-name> [options]

Replace <project-name> with the desired name of your project. You can add optional flags to include Tailwind CSS, Redux Toolkit, and React Router.

Available Flags

  • --tw: Adds Tailwind CSS setup, with the main CSS file configured as index.css.
  • --rtk: Sets up Redux Toolkit with a basic store and example slice.
  • --rr: Configures React Router with basic routing and sample pages.

Example Command

vbc create my-new-app --tw --rtk --rr

This command will create a new Vite React project named my-new-app with Tailwind CSS, Redux Toolkit, and React Router preconfigured.

Explanation of the Flags

Tailwind CSS (--tw flag)

When using the --tw flag, the tool will:

  1. Install Tailwind CSS and required dependencies (postcss and autoprefixer).
  2. Generate a tailwind.config.js file and configure it with the content paths for Tailwind to scan.
  3. Add an index.css file in src/assets/ with the necessary Tailwind directives (@tailwind base, @tailwind components, and @tailwind utilities).

NB: the index.css file in src/assets/ is the file you should import in App.tsx

Redux Toolkit (--rtk flag)

When using the --rtk flag, the tool will:

  1. Install Redux Toolkit (@reduxjs/toolkit) and React-Redux (react-redux).
  2. Create a Redux store configuration in src/store/create-store.ts.
  3. Add an example slice (exampleSlice.ts) in src/modules/slice/ with basic actions, demonstrating Redux setup.

React Router (--rr flag)

When using the --rr flag, the tool will:

  1. Install react-router-dom for routing.
  2. Set up routing in src/routes/ROUTER.tsx with sample paths.
  3. Create route definitions in src/routes/routes.ts.
  4. Add two sample pages (Home.tsx and About.tsx) in src/pages/ to demonstrate routing.

Project Structure

The generated project will have the following structure:

my-new-app/
├── src/
│   ├── __e2e__/                 # End-to-end testing files
│   ├── assets/                  # Static files (images, fonts, etc.)
│   ├── components/              # Reusable UI components
│   ├── modules/                 # Core application logic, organized by domain
│   │   ├── __tests__/           # Unit and integration tests for modules
│   │   ├── infra/               # Infrastructure layer (APIs, data sources)
│   │   ├── models/              # Data models and types
│   │   ├── slice/               # Redux slices and state
│   │   │   └── exampleSlice.ts  # Example Redux slice with actions
│   │   ├── use-case/            # Business logic and use cases
│   └── reducer.ts           # Root reducer that combines the module reducers
│   ├── routes/                  # Routing configuration
│   │   ├── ROUTER.tsx           # Main router component
│   │   └── routes.ts            # Route definitions and path configurations
│   └── pages/                   # Application pages (e.g., Home, About)
│       ├── Home.tsx             # Sample Home page
│       └── About.tsx            # Sample About page
│   └── store/                   # Redux store setup
│       └── create-store.ts      # Store configuration

Commands

create <project-name>

Scaffolds a new React project with a hexagonal architecture and optional configurations.

Example:

vbc create my-new-app --tw --rtk --rr

This initializes a Vite React project named my-new-app with Tailwind CSS, Redux Toolkit, and React Router configurations.

Contributing

To contribute to vite-react-cli-tool, follow these steps:

  1. Fork the repository.
  2. Clone your forked repository.
  3. Make your changes and commit them.
  4. Create a pull request.

Development Setup

To work on the tool locally:

  1. Clone the repository:

    git clone <your-fork-url>
  2. Install dependencies:

    npm install
  3. Build the TypeScript files:

    npm run build
  4. Link the package locally to test it:

    npm link
  5. Test the tool by running vbc commands from anywhere on your system.

License

This project is licensed under the ISC License.