1.2.5 • Published 2 years ago

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

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years 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

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.0.131

2 years ago

1.0.134

2 years ago

1.0.130

2 years ago

1.0.136

2 years ago

1.0.137

2 years ago

1.0.106

2 years ago

1.0.109

2 years ago

1.0.103

2 years ago

1.0.105

2 years ago

1.0.104

2 years ago

1.0.121

2 years ago

1.0.120

2 years ago

1.0.123

2 years ago

1.0.122

2 years ago

1.0.128

2 years ago

1.0.125

2 years ago

1.0.124

2 years ago

1.0.127

2 years ago

1.0.126

2 years ago

1.0.118

2 years ago

1.0.117

2 years ago

1.0.114

2 years ago

1.0.113

2 years ago

1.0.116

2 years ago

1.0.115

2 years 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

3 years ago

1.0.79

3 years ago

1.0.78

3 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

3 years ago

1.0.75

3 years ago

1.0.74

3 years ago

1.0.73

3 years ago

1.0.72

3 years ago

1.0.71

3 years ago

1.0.70

3 years ago

1.0.69

3 years ago

1.0.68

3 years ago

1.0.67

3 years ago

1.0.66

3 years ago

1.0.65

3 years ago

1.0.64

3 years ago

1.0.63

3 years ago

1.0.62

3 years ago

1.0.61

3 years ago

1.0.60

3 years ago

1.0.59

3 years ago

1.0.58

3 years ago

1.0.55

3 years ago

1.0.54

3 years ago

1.0.52

3 years ago

1.0.51

3 years ago

1.0.50

3 years ago

1.0.49

3 years ago

1.0.48

3 years ago

1.0.47

3 years ago

1.0.46

3 years ago

1.0.45

3 years ago

1.0.44

3 years ago

1.0.43

3 years ago

1.0.42

3 years ago

1.0.41

3 years ago

1.0.40

3 years ago

1.0.39

3 years ago

1.0.38

3 years ago

1.0.37

3 years ago

1.0.36

3 years ago

1.0.35

3 years ago

1.0.34

3 years ago

1.0.33

3 years ago

1.0.32

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago