go-react

command module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2023 License: MIT Imports: 1 Imported by: 0

README

Go React

Wanted to learn Go so started with a simple CLI to can create the boilerplate for files.

Install

go install github.com/wbroberts/go-react

Use

go-react

Component

Creates a component and component test file.

go-react component <ComponentName>

Options:

  • --props or -p adds an empty props type for component
  • --skip-tests skips adding the test file
  • --dir or -d sets the path for the directory the component should be added to. Will create the directory if it does not exist yet
Example
go-react component Example
  • Component ./components/Example.component.tsx
import React from 'react';

export const Example = () => {
  return <div>Example renders</div>;
}
  • Component test ./components/Example.component.test.tsx
import { screen, render } from '@testing-library/react';

import { Example } from './Example.component';

describe('Example', () => {
  it('renders', () => {
    render(<Example />);
  
    expect(screen.getByText(/Example renders/)).toBeDefined();
  });
});

Optional Config File for Defaults

Can add a config file to set default flags when running commands.

touch go-react.yaml

# All values are optional
component:
  dir: src/components
  props: true
  skip-tests: false

Documentation

Overview

Copyright © 2022 NAME HERE <EMAIL ADDRESS>

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL