Copypaster Has your project structure gotten so complex that to add a new feature you need to copy

Overview

Copypaster

Has your project structure gotten so complex that to add a new feature you need to copy, paste and rename tens or hundreds of files each time? And now you're thinking of writing a code generator to help you with that repetitive manual work?

This tool is a simple helper you might use instead, and it works this way:

  1. You identify all files and folders you want to use as template (let's say you have a module/user/user-settings folder)
  2. You tell the tool to replace all user occurences in the template with, let's say, dog
  3. The tool then copies the template files you specified, while replacing user with dog in all file names and their contents, preserving naming conventions (camelCase, pascalCase, snake_case, etc.)

How to use

  1. Install this tool globally npm install -g copypaster
  2. Run copypaster in your project's root directory, which will ask you to create a copypaster.config.json templates file
  3. Define which files or folders you want to use as templates in config file
  4. Run copypaster again and follow on-screen instructions to actually generate a code from template

How does config file work

You can see the example copypaster.config.json in example directory, but basically it's gonna look something like this: there's an arbitrary template name that you can set, followed by an object containing template logic:

  • replacementKey - string that will get replaced with whatever you tell the tool with. Must be in snake_case or kebab-case.
  • folders - array containing folders you want to copy
  • files - array containing files you want to copy
  • snippets - array of individual snippets you want to copy (new line gets inserted right after the specified one)
  • description - decorative text explaining what the template does, not used in generated code

Example:

{
    "someAppModuleThatYouWantToUseAsTemplate": {
        "replacementKey": "space_station",
        "description": "Template made from Space Station app module.",
        "folders": [
            "space-station/",
            "space-station/space-station-parts"
        ],
        "files": [
            "space-station/space-station.api.js",
            "space-station/SpaceStation.js",
            "space-station/space-station-parts/space-station-parts.service.js"
        ],
        "snippets": [
            {
                "file": "example.routes.js",
                "content": "\t\"space-station/space-station.api\","
            }
        ]
    },
    "someOtherModule": {
        "replacementKey": "station",
        "description": "Another template",
        "folders": [
            "space-station/"
        ],
        "files": [
            "space-station/space-station.api.js"
        ]
    }
}

Code structure

There's cli.ts as the entry point which handles user input, which then offloads the actual codegen part to generator.ts. All other files are helper stuff to do string or file manipulations.

Tool is currently not using any external dependencies. Typescript is used when developing locally, but built files get exported and ran as vanilla Javascript with zero dependencies.

You might also like...

Validate properties and well known annotations in your Backstage catalog-info.yaml files.

Backstage entity validator This package can be used as a GitHub action or a standalone node.js module GitHub action Inputs path Optional Path to the c

Dec 26, 2022

DiscordEmailVerifier - Quickly verify emails on your tokens for completely free using mail.tm's api.

DiscordEmailVerifier Quickly verify emails on your tokens for completely free using mail.tm's api. /* โ— No, this code doesn't verify the email for you

Jun 7, 2022

Codestamp - Stamp and verify your files and contents

A language-agnostic tool for signing and verifying your (codegen'd) files and contents.

Jan 26, 2022

The Vue form assembly tool that won't break your heart ๐Ÿ’”

The Vue form assembly tool that won't break your heart ๐Ÿ’”

Loveform The Vue form assembly tool that won't break your heart ๐Ÿ’” Loveform is a tool that helps you build validated forms in Vue 3 without the need t

Jun 10, 2022

Application structure for new adonis app, think of it as scaffolding a new project

AdonisJs Application This repo is the pre-configured project structure to be used for creating ambitious web servers using AdonisJs. Make sure to star

Oct 15, 2022

Awesome Books is a basic website that allows users to add/remove books from a list (including the title and author). It has threee different sections: 1. books list, 2. add new book, 3. contact.

awesomeBooks-modules Awesome Books is a basic website that allows users to add/remove books from a list (including the title and author). It has three

Aug 26, 2022

This is an Awesome Books web page where users can add or remove books from the site. It also displays a list of the books added to the collection. This was a continuous project, where in each milestone, new feature(s) was/were added to it.

This is an Awesome Books web page where  users can add or remove books from the site. It also displays a list of the books added to the collection. This was a continuous project, where in each milestone, new feature(s) was/were added to it.

Awesome Books This is an Awesome Books web page where a user can add or remove books from the site. It also displays a list of the books that are adde

Aug 1, 2022

In this project we build a TVSeries website using Javascript, HTML, CSS and the TVMAze API. Each movie list on the page has a like and comments feature

MicroFLIX This project is a development about TV series, we fetched all data from TVmaze API, Users can like movies and also give a comment. All data

Jul 25, 2022

Eventually* Everything you'll need for successful feature flagging

remix-flags Eventually* Everything you'll need for successful feature flagging What's inside? This repo uses npm as a package manager. It includes the

Jun 10, 2022

The website which can help you to organize your daily or weekly activities and review them when you need them. you can add, remove and delete an activity

To Do list To do project is webpack project that list activities someone can do at a specific time In this TO-DO list, you can add or remove you activ

Jul 21, 2022

A better way for new feature introduction and step-by-step users guide for your website and project.

A better way for new feature introduction and step-by-step users guide for your website and project.

Intro.js v3 Lightweight, user-friendly onboarding tour library Where to get You can obtain your local copy of Intro.js from: 1) This github repository

Jan 2, 2023

๐Ÿž๐Ÿ“…A JavaScript calendar that has everything you need.

๐Ÿž๐Ÿ“…A JavaScript calendar that has everything you need.

A JavaScript schedule calendar that is full featured. Now your service just got the customizable calendar. ๐Ÿšฉ Table of Contents Collect statistics on

Jan 3, 2023

๐Ÿž๐Ÿ“…A JavaScript calendar that has everything you need.

๐Ÿž๐Ÿ“…A JavaScript calendar that has everything you need.

A JavaScript schedule calendar that is full featured. Now your service just got the customizable calendar. ๐Ÿšฉ Table of Contents Collect statistics on

Jan 5, 2023

An NPM package to help frontend developers get started with using SASS and SCSS on your project easily. The Package follows the 7-1 architecture project structure.

Project Title - Create SASS APP Ever wanted to code up a frontend project with SASS & SCSS and you are stuck with building the acclaimed 7-1 architect

Sep 22, 2022

Microverse Module 02 Project: This is educational project is a tool that helps to organize your day. It simply lists the things that you need to do and allows you to mark them as complete. Built with HTML, Sass, JavaScript and Webpack.

Project Demo Live Demo Description To-do list is a tool that helps to organize your day. It simply lists the things that you need to do and allows you

Oct 21, 2022

Create a new project with Next.js, TypeScript, Eslint, Prettier in just 1 second and you don't need to setup anything.

Create a new project with Next.js, TypeScript, Eslint, Prettier in just 1 second and you don't need to setup anything.

Next + TypeScript + Eslint + Prettier Template ๐Ÿ”ฅ Create a new project with Next.js, TypeScript, Eslint, Prettier in just 1 second and you don't need

Oct 2, 2022

A small web app that tries to imitate the desktop web version of amazon site, you can add items to the basket, delete them, and have your user authentication feature thanks to Firebase.

A small web app that tries to imitate the desktop web version of amazon site, you can add items to the basket, delete them, and have your user authentication feature thanks to Firebase.

Features Here's the feature's included in this project ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ Login Page ๐Ÿ“ฆ Products Page ๐Ÿ›’ Cart and Checkout Page ๐Ÿ“ Sign up function with Goog

Aug 22, 2022
Owner
null
Themis is a validation and processing library that helps you always make sure your data is correct.

Dataffy Themis - The advanced validation library Themis is a validation and processing library that helps you always make sure your data is correct. ยท

Dataffy 14 Oct 27, 2022
Simple translation for your javascripts, yummy with your favorite templates engine like EJS.

jsperanto Simple translation for your javascripts, yummy with your favorite templates engine like EJS. Pluralization, interpolation & "nested lookup"

Jean-Philippe Joyal 62 Oct 21, 2021
This is a project based on redux of reactjs.

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

Zahid Hussain 1 Dec 18, 2021
Form next js 2022 - project for death valley.

Welcome to Death Valley 2022 base url https://form-next-js-2022-3snm4xixy-sungpah.vercel.app/ Download this repo git clone https://github.com/SUNGPA

SUNGPAH 2 Jul 1, 2022
Jquery-anyimagecomparisonslider-plugin - The any Image Comparison Slider is an extremely versatile yet slim slider for comparing images. You have a lot of options to configure the slider and it works just about everywhere.

any Image Comparison Slider (jquery-anyimagecomparisonslider-plugin ) Description The any Image Comparison Slider is an extremely versatile yet slim s

Niklas 6 Sep 12, 2022
Validate your forms, frontend, without writing a single line of javascript

Parsley JavaScript form validation, without actually writing a single line of JavaScript! Version 2.9.2 Doc See index.html and doc/ Requirements jQuer

Guillaume Potier 9k Dec 27, 2022
The best @jquery plugin to validate form fields. Designed to use with Bootstrap + Zurb Foundation + Pure + SemanticUI + UIKit + Your own frameworks.

FormValidation - Download http://formvalidation.io - The best jQuery plugin to validate form fields, designed to use with: Bootstrap Foundation Pure S

FormValidation 2.8k Mar 29, 2021
[DISCONTINUED] jQuery plugin that makes it easy to validate user input while keeping your HTML markup clean from javascript code.

jQuery Form Validator [DISCONTINUED] Validation framework that let's you configure, rather than code, your validation logic. I started writing this pl

Victor Jonsson 976 Dec 30, 2022