npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@contract-js/cli

v1.0.10

Published

[//]: # (contract-js CLI - Command Line Interface)

Downloads

54

Readme

⚡ contract-js CLI

Command Line Interface for PDF Contract Generation

Generate, sign, and verify PDF contracts from the command line with a beautiful and user-friendly interface.

npm version License: Apache-2.0 TypeScript


🎯 Purpose

Provide a command-line interface for generating PDF contracts from EJS templates with digital signature support, featuring an intuitive and visually appealing user experience.

✨ Features

  • 📄 PDF Generation – Generate PDF contracts from EJS templates
  • ✍️ Digital Signing – Create digital signatures for PDF contracts
  • 🔍 Signature Verification – Verify digital signatures
  • 🔐 Hash Generation – Generate cryptographic hashes for PDF files
  • 🎨 Beautiful UI – Colorful and interactive command-line interface
  • ⚙️ Flexible Options – Comprehensive configuration options

🚀 Installation

# Install globally
npm install -g contract-js

# Or use with npx
npx contract-js --help

📋 Commands

Generate PDF Contract

# Basic generation
contract-js generate template.ejs

# With data and output
contract-js generate template.ejs -d data.json -o contract.pdf

# With custom output directory
contract-js generate template.ejs -o ./output/contract.pdf

# With browser options for Docker/server environments
contract-js generate template.ejs --disable-dev-shm-usage --disable-gpu

# With custom Chrome executable path
contract-js generate template.ejs --executable-path /usr/bin/chromium

Options:

  • -d, --data <data> – JSON data file path for template variables
  • -o, --output <output> – Output PDF file path (default: contract.pdf)
  • --executable-path <path> – Custom Chrome/Chromium executable path
  • --disable-dev-shm-usage – Disable /dev/shm usage (recommended for Docker)
  • --disable-gpu – Disable GPU acceleration (recommended for headless servers)
  • --single-process – Run in single process mode (for memory-constrained environments)

Sign PDF Contract

# Generate new keys and sign
contract-js sign contract.pdf

# Use existing private key
contract-js sign contract.pdf -k ./keys/private.pem

# Custom output directory
contract-js sign contract.pdf -o ./my-keys

# Different hash algorithm
contract-js sign contract.pdf -a sha256

Options:

  • -k, --key <key> – Private key file path (PEM format)
  • -o, --output <output> – Output directory for keys (default: ./keys)
  • -a, --algorithm <algorithm> – Hash algorithm (default: sha256)

Verify Digital Signature

# Verify signature
contract-js verify contract.pdf -p ./keys/public.pem -s ./keys/signature.txt

# Different hash algorithm
contract-js verify contract.pdf -a sha256 -p ./keys/public.pem -s ./keys/signature.txt

Options:

  • -p, --public-key <publicKey> – Public key file path (PEM format)
  • -s, --signature <signature> – Signature file path (TXT format)
  • -a, --algorithm <algorithm> – Hash algorithm (default: sha256)

Generate Hash

# Generate hash for PDF
contract-js hash contract.pdf

# Different hash algorithm
contract-js hash contract.pdf -a sha256

Options:

  • -a, --algorithm <algorithm> – Hash algorithm (default: sha256)

🎨 User Interface

The CLI features a beautiful and interactive interface with:

  • Colorful Output – Different colors for different types of information
  • Progress Indicators – Spinners and progress bars for long operations
  • Step-by-step Feedback – Clear indication of what's happening
  • Error Handling – User-friendly error messages
  • Success Confirmation – Clear success messages with details

📁 File Structure

keys/
├── public.pem      # Public key
├── private.pem     # Private key (keep secure!)
└── signature.txt   # Digital signature

🔒 Security Considerations

  • Private Key Security – Never share or expose private keys
  • File Permissions – Ensure proper file permissions for key files
  • Algorithm Choice – Use SHA-256 or higher for new implementations
  • Key Rotation – Regularly rotate key pairs for enhanced security

📦 Dependencies

  • @clack/prompts – Beautiful command-line prompts
  • picocolors – Tiny color library
  • cac – Command and option parser
  • zod – Schema validation

🌐 Browser Options

The generate command supports various browser options to optimize PDF generation in different environments:

Docker Environments

# Recommended for Docker containers
contract-js generate template.ejs --disable-dev-shm-usage --disable-gpu

Headless Servers

# Recommended for servers without display
contract-js generate template.ejs --disable-gpu --single-process

Custom Chrome Installation

# Use custom Chrome/Chromium executable
contract-js generate template.ejs --executable-path /usr/bin/chromium

Memory-Constrained Environments

# Use single process mode to reduce memory usage
contract-js generate template.ejs --single-process

🛠️ Development

# Install dependencies
pnpm install

# Build the CLI
pnpm build

# Run locally
pnpm dev

# Test commands
pnpm test

📝 License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright © Jeonhui