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

@cmj526/mason

v1.0.8

Published

Mason is a tool for creating new React components and pages for your project.

Downloads

509

Readme

Mason Banner

@cmj526/mason

Mason is a lightweight and efficient tool designed to help developers create React components, pages, and sub-components effortlessly. Written in Python, this CLI tool automates the process of generating boilerplate code, enabling you to focus on building features rather than repetitive setup tasks.


Features

  • Generate React Pages: Quickly scaffold fully functional React pages with components, hooks, styles, and tests.
  • Create Components: Easily create reusable React components with styles and test files.
  • Sub-component Support: Add sub-components to existing pages for better modularization.

Installation

To use Mason, first ensure you have Python 3 installed on your system. You can install Mason either globally or locally using npm:

Global Installation

Install Mason as a global npm package to use it across all your projects:

npm install -g @cmj526/mason

Local Installation

Install Mason as a local npm package to use it in a specific project:

npm install @cmj526/mason

Usage

Once installed globally, you can use Mason by running the following command:

mason

You will be prompted to choose what to create: a page, component, or sub-component. Follow the prompts to complete the process.

Alternatively, you can integrate Mason into your project’s workflow using yarn or npm scripts:

Add Mason to Your package.json Scripts

  1. Open your package.json.

  2. Add the following script:

    {
      "scripts": {
        "create": "mason"
      }
    }
  3. Run the script:

    npm run create

    or

    yarn run create

CLI Workflow

When you run mason, Mason will guide you through the creation process with prompts:

  1. Select the type of entity:
    You will be asked to choose between:

    • P: Create a new page
    • C: Create a new component
    • S: Create a sub-component within an existing page.
  2. Enter the name of the entity:
    Provide the name of the page, component, or sub-component.

  3. Output:
    Mason generates the necessary files and folders under the appropriate directories (src/pages/, src/components/, etc.).


Example

Creating a Page

  1. Run:
    mason
  2. Select P (for a new page).
  3. Enter a name for the page, e.g., Home.
  4. Mason will create a folder src/pages/Home with the following files:
    src/pages/Home/
    ├── Component.tsx
    ├── Hooks.tsx
    ├── Styles.scss
    ├── Home.test.tsx
    └── index.tsx

Creating a Component

  1. Run:
    mason
  2. Select C (for a new component).
  3. Enter a name for the component, e.g., Button.
  4. Mason will create a folder src/components/Button with the following files:
    src/components/Button/
    ├── index.tsx
    ├── styles.scss
    └── Button.test.tsx

Adding a Sub-component

  1. Run:
    mason
  2. Select S (for a new sub-component).
  3. Enter the parent page’s name (e.g., Home) and the sub-component name (e.g., Footer).
  4. Mason will add a folder under the Home page for the sub-component:
    src/pages/Home/components/Footer/
    ├── index.tsx
    ├── styles.scss
    └── Footer.test.tsx

Directory Structure

Mason assumes the following project structure:

src/
├── pages/
│   └── [PageName]/
│       ├── Component.tsx
│       ├── Hooks.tsx
│       ├── Styles.scss
│       ├── [PageName].test.tsx
│       └── index.tsx
├── components/
│   └── [ComponentName]/
│       ├── index.tsx
│       ├── styles.scss
│       └── [ComponentName].test.tsx

If the structure doesn’t exist, Mason will create the necessary folders.


Requirements

  • Python 3.6 or later
  • npm or Yarn installed on your system

Troubleshooting

Common Errors

  1. python3: command not found:
    Ensure Python 3 is installed and available in your system's PATH.
    Test by running:

    python3 --version
  2. Module not found:
    Ensure all necessary Python modules are installed. You can install missing modules using pip.

  3. File not found in .bin:
    If you encounter an error where create.py is not found, verify that the package is correctly installed globally and create.py is included in the package files.


Contributing

We welcome contributions to Mason! If you’d like to add features or fix bugs:

  1. Fork the repository.
  2. Make your changes.
  3. Submit a pull request on GitHub.

License

This project is licensed under the ISC License.


Contact

For issues or feedback, please visit our GitHub issues page. """

Write to README.md

with open("README.md", "w") as file: file.write(readme_content)

"README.md file has been created successfully!"