GithubHelp home page GithubHelp logo

gabrielduartem / copy-paste-component Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 0.0 1.74 MB

A tool to create components, by copying and pasting existing ones.

Home Page: https://www.npmjs.com/package/copy-paste-component

License: MIT License

JavaScript 86.18% HTML 7.21% CSS 6.61%
cli frontend front-end development web generate generator component components copy paste tool scaffold boilerplate pattern convention conventions patterns

copy-paste-component's Introduction

copy-paste-component

travis appveyor codecov npm downloads npm version PRs Welcome styled with prettier

A tool to create components, by copying and pasting existing ones.

Usage

If you have the structure below:

src/components/App/App.js
src/components/App/App.test.js
src/components/App/App.stories.js
src/components/App/index.js

and run the tool, it will create the following structure, replacing occurrences of the word App inside the files to NewApp:

src/components/NewApp/NewApp.js
src/components/NewApp/NewApp.test.js
src/components/NewApp/NewApp.stories.js
src/components/NewApp/index.js

Installation

yarn global add copy-paste-component or npm i -g copy-paste-component

Editor integration

Are you looking for an editor extension? Check the ones available:

Usage

On the root of your project, run cpc or copy-paste-component.

It will prompt you three questions:

  • Which component would you like to copy?
  • What is the name of the new component?
  • What is the location of the new component?

When you answer those questions, it will generate a structure that is the same as the one that the selected component uses, but it will change the filename to the one you provided on the second question. It will look too inside the file for occurrences of the filename, and if it finds, it replaces with the content of the second question.

So, given the following file:

App.js

import React from 'react'

const App = () => <div>Hello World</div>

export default App

Becomes the following:

NewApp.js

import React from 'react'

const NewApp = () => <div>Hello World</div>

export default NewApp

There is also an option to skip the questions, providing them directly when you call the package, using the copy command, like cpc copy src/components/App/App.js NewApp src/components/NewApp. The first argument is the path of the component you want to copy, the second is the name of the new component, and the last one is the path where the component will be created.

Roadmap

See Roadmap

Changelog

See Releases

License

MIT

copy-paste-component's People

Contributors

gabeduartem avatar greenkeeper[bot] avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

copy-paste-component's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • fix(deps): update dependency glob to v8
  • fix(deps): update dependency inquirer to v9
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

npm
package.json
  • fs-extra 7.0.1
  • glob 7.1.3
  • inquirer 6.2.2
  • klaw-sync 6.0.0
  • yargs 13.2.2
  • codecov 3.3.0
  • gd-scripts 5.0.3
  • semantic-release 15.13.3
  • node >=6.14.3
travis
.travis.yml

  • Check this box to trigger a request for Renovate to run again on this repository

Add Typescript definitions

Expected Behavior

copy-paste-component should have typescript definitions for every method that it exports

Current Behavior

copy-paste-component does not have any type definitions

Context

For better integration with tools that utilizes typescript, this package should implement typescript definitions for each method that it exports.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.