1.2.5 • Published 1 year ago

create-react-js-component-cli v1.2.5

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

create-react-component

A simple CLI tool to create react components with a single command.

Note:

  • You should install Node.js first.
  • This tool is only for React.js projects.
  • You shoudl install this tool globally by adding -g flag.

Installation

npm i create-react-js-component-cli -g

Options:

  • You can run the following command to see the available options:
crc --help
  • The tool will show you the following options:
Options:
  --version  Show version number                                       [boolean]
  --name     The name of the component                                  [string]
  --path     The path to the component directory                        [string]
  --js       Use JavaScript file extesnion            [boolean] [default: false]
  --ts       Use TypeScript file extension            [boolean] [default: false]
  --css      Whether to use a CSS file                [boolean] [default: false]
  --scss     Whether to use a SCSS file               [boolean] [default: false]
  --test     Whether to include a test file           [boolean] [default: false]
  --help     Show help                                                 [boolean]

Usage:

  • There are 2 ways to use this tool:

    The first way:

    • The first way is to run the following command and follow the instructions:

      crc
    • crc: stands for "create-react-component"

    • The tool will ask you for some information about the component you want to create:

      Welcome to the Create-React-Component-cli version #.#.###
      
      -------------------------
      Component name: MyComponent
      -------------------------
      Enter component path (to use the current directory press ENTER): src
      
      -------------------------
      Select language:
      
      1. JavaScript
      2. TypeScript
      
      Please enter 1 or 2 (Default is JavaScript): 2
      -------------------------
      Select stylesheet format:
      
      1. CSS
      2. SCSS
      
      Please enter 1 or 2 (Default is CSS): 2
      -------------------------
      Include TEST file?
      
      1. Yes
      2. No
      
      Please enter 1 or 2 (Default is No): 2
      -------------------------
      Creating all necessary folder and files...
      
      -------------------------
      Your directory structure is:
      
        src/
        └── myComponent
            ├── hooks
                ├── useMyComponent.tsx
            ├── style
                ├── myComponent.scss
            ├── MyComponent.tsx
            └──  index.ts
      
      -------------------------
      Thank you for using create-react-js-component-cli
      
      Created by @ Ali Helmi: ahelmi365@gmail.com
      
      -------------------------

    The second way:

    • The second way is to run the following command:

      crc --name "MyComponent" --path "/src" --js --css --test
    • The tool will create the component with the following options:

      • Component name: MyComponent
      • Component path: /src
      • Language: JavaScript
      • Stylesheet language: CSS
      • Test file: Yes
    • The tool will create the following files inside the path you specified:

        Your direwctory structure is:
      
        src
          └── myComponent
              ├── hooks
                  ├── useMyComponent.jsx
              ├── style
                  ├── myComponent.css
              ├── MyComponent.jsx
              ├── index.js
              └── myComponent.test.js
      
        -------------------------
        Thank you for using create-react-js-component-cli
      
        Created by @ Ali Helmi: ahelmi365@gmail.com
      
        -------------------------

Files Content:

  • The tool will create the following files content:

  • MyComponent.jsx

import "./style/myComponent.css";
import useMyComponent from "./hooks/useMyComponent";

const MyComponent = () => {
  return <div className={"myComponent-container"}>MyComponent works!</div>;
};

export default MyComponent;
  • useMyComponent.jsx
const useMyComponent = () => {};

export default useMyComponent;
  • index.js
export { default } from "./MyComponent";
  • myComponent.css
.myComponent-container {
}
  • myComponent.test.js
import React from "react";
import { render, screen } from "@testing-library/react";
import MyComponent from "./MyComponent";

describe("MyComponent", () => {
  it("should render successfully", () => {});
});

License

This project is licensed under the MIT License - see the LICENSE file for details.

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.0.131

1 year ago

1.0.134

1 year ago

1.0.130

1 year ago

1.0.136

1 year ago

1.0.137

1 year ago

1.0.106

1 year ago

1.0.109

1 year ago

1.0.103

1 year ago

1.0.105

1 year ago

1.0.104

1 year ago

1.0.121

1 year ago

1.0.120

1 year ago

1.0.123

1 year ago

1.0.122

1 year ago

1.0.128

1 year ago

1.0.125

1 year ago

1.0.124

1 year ago

1.0.127

1 year ago

1.0.126

1 year ago

1.0.118

1 year ago

1.0.117

1 year ago

1.0.114

1 year ago

1.0.113

1 year ago

1.0.116

1 year ago

1.0.115

1 year ago

1.0.101

2 years ago

1.0.102

2 years ago

1.0.88

2 years ago

1.0.87

2 years ago

1.0.86

2 years ago

1.0.89

2 years ago

1.0.91

2 years ago

1.0.90

2 years ago

1.0.94

2 years ago

1.0.92

2 years ago

1.0.99

2 years ago

1.0.97

2 years ago

1.0.96

2 years ago

1.0.77

2 years ago

1.0.79

2 years ago

1.0.78

2 years ago

1.0.80

2 years ago

1.0.84

2 years ago

1.0.83

2 years ago

1.0.82

2 years ago

1.0.81

2 years ago

1.0.76

2 years ago

1.0.75

2 years ago

1.0.74

2 years ago

1.0.73

2 years ago

1.0.72

2 years ago

1.0.71

2 years ago

1.0.70

2 years ago

1.0.69

2 years ago

1.0.68

2 years ago

1.0.67

2 years ago

1.0.66

2 years ago

1.0.65

2 years ago

1.0.64

2 years ago

1.0.63

2 years ago

1.0.62

2 years ago

1.0.61

2 years ago

1.0.60

2 years ago

1.0.59

2 years ago

1.0.58

2 years ago

1.0.55

2 years ago

1.0.54

2 years ago

1.0.52

2 years ago

1.0.51

2 years ago

1.0.50

2 years ago

1.0.49

2 years ago

1.0.48

2 years ago

1.0.47

2 years ago

1.0.46

2 years ago

1.0.45

2 years ago

1.0.44

2 years ago

1.0.43

2 years ago

1.0.42

2 years ago

1.0.41

2 years ago

1.0.40

2 years ago

1.0.39

2 years ago

1.0.38

2 years ago

1.0.37

2 years ago

1.0.36

2 years ago

1.0.35

2 years ago

1.0.34

2 years ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

1.0.29

2 years ago

1.0.28

2 years ago

1.0.27

2 years ago

1.0.26

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago