Socket
Socket
Sign inDemoInstall

plop

Package Overview
Dependencies
Maintainers
2
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

plop

Micro-generator framework that makes it easy for an entire team to create files with a level of uniformity


Version published
Weekly downloads
684K
increased by1.92%
Maintainers
2
Weekly downloads
 
Created

What is plop?

Plop is a micro-generator framework that helps you create consistent and repeatable code snippets, files, or projects. It allows you to define templates and automate the creation of boilerplate code, making it easier to maintain consistency across your codebase.

What are plop's main functionalities?

File Generation

This feature allows you to generate files based on templates. In this example, a new component file is created using a Handlebars template. The user is prompted for the component name, and the file is generated in the specified path.

module.exports = function (plop) {
  plop.setGenerator('component', {
    description: 'Create a new component',
    prompts: [
      {
        type: 'input',
        name: 'name',
        message: 'Component name?'
      }
    ],
    actions: [
      {
        type: 'add',
        path: 'src/components/{{pascalCase name}}/{{pascalCase name}}.js',
        templateFile: 'plop-templates/component.hbs'
      }
    ]
  });
};

Custom Actions

Plop allows you to define custom actions that can be executed as part of the generation process. In this example, a custom action type is defined and used in a generator.

module.exports = function (plop) {
  plop.setActionType('customAction', function (answers, config, plop) {
    // Custom action logic here
    return 'Custom action executed';
  });
  plop.setGenerator('custom', {
    description: 'Run a custom action',
    prompts: [],
    actions: [
      {
        type: 'customAction'
      }
    ]
  });
};

Template Rendering

This feature allows you to render templates with dynamic data. In this example, a README file is generated using a Handlebars template, with the project name provided by the user.

module.exports = function (plop) {
  plop.setGenerator('readme', {
    description: 'Create a README file',
    prompts: [
      {
        type: 'input',
        name: 'projectName',
        message: 'Project name?'
      }
    ],
    actions: [
      {
        type: 'add',
        path: 'README.md',
        templateFile: 'plop-templates/readme.hbs'
      }
    ]
  });
};

Other packages similar to plop

Keywords

FAQs

Package last updated on 22 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc