CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-plop

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

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

cli.mddocs/

Command Line Interface

Plop's CLI provides a comprehensive interface for running generators, managing plopfiles, and getting help information.

Capabilities

Basic Commands

Run plop generators through simple command line interface.

# Show available generators and select one
plop

# Run specific generator by name
plop <generator-name>

# Run generator with bypass arguments
plop <generator-name> [arguments...]

# Run generator with named arguments
plop <generator-name> -- --arg1=value1 --arg2=value2

Usage Examples:

# Interactive generator selection
plop

# Run component generator
plop component

# Run component generator with name bypass
plop component "MyComponent"

# Skip first prompt, provide second argument
plop component _ "react"

# Use named arguments
plop component -- --name "MyComponent" --type "react"

Help and Information

Get help and version information.

# Show help screen
plop --help
plop -h

# Show version information
plop --version
plop -v

Initialization

Create initial plopfile configurations.

# Generate basic plopfile.js
plop --init
plop -i

# Generate TypeScript plopfile.ts
plop --init-ts

# Force overwrite existing plopfile
plop --init --force
plop -i -f

Generator Options

Options that modify generator behavior.

# Show full type names instead of symbols
plop --show-type-names
plop -t

# Force overwrite existing files
plop --force
plop -f

# Disable progress bar
plop --no-progress

Advanced Options

Advanced configuration options for specialized use cases.

# Specify custom plopfile path
plop --plopfile /path/to/plopfile.js

# Set working directory for plopfile discovery
plop --cwd /path/to/directory

# Preload modules before execution (comma-separated)
plop --preload module1,module2

# Override output destination directory
plop --dest /path/to/output

# Disable progress spinner
plop --no-progress

# Enable shell completion support
plop --completion

Command Processing

Argument Handling

/**
 * Handles all basic argument flags
 * @param env - Values parsed by Liftoff containing configuration paths
 */
function handleArgFlags(env);

The CLI processes arguments in the following order:

  1. Parse command line arguments using minimist
  2. Handle special flags (--help, --version, --init)
  3. Check for plopfile existence
  4. Pass remaining arguments to generator selection

Generator Selection

/**
 * Parses user input to identify generator and bypass data
 * @param plop - The plop context with available generators
 * @param passArgsBeforeDashes - Whether to pass args before '--' to generator
 * @returns Object containing generator name, bypass array, and parsed arguments
 */
function getBypassAndGenerator(plop, passArgsBeforeDashes);

Exit Codes

  • 0: Successful execution
  • 1: Error occurred (no plopfile, generator not found, action failed, validation error)

Error Handling

The CLI handles various error scenarios:

  • No plopfile found: Shows error message and help screen, exits with code 1
  • No generators defined: Shows error message, exits with code 1
  • Generator not found: Shows error with fuzzy name matching, exits with code 1
  • Too many bypass arguments: Shows generator help, exits with code 1
  • Invalid named arguments: Shows error and generator help, exits with code 1
  • Action failures: Can abort execution based on generator configuration

Install with Tessl CLI

npx tessl i tessl/npm-plop

docs

action-system.md

cli.md

console.md

generator-api.md

index.md

programmatic.md

template-system.md

tile.json