CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-clean-publish

Clean your package before publish by removing development-specific files and configuration

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

cli-commands.mddocs/

CLI Commands

Clean Publish provides two main CLI commands for different use cases: full package cleaning and publishing workflow, and standalone package.json cleaning utility.

Capabilities

clean-publish Command

Main command for cleaning and publishing packages with comprehensive option support.

npx clean-publish [options]

Options:
  --help             Show help
  --version          Show version number
  --clean-docs       Keep only main section of README.md
  --clean-comments   Clean inline comments from JS files
  --files            One or more exclude files (comma-separated)
  --fields           One or more exclude package.json fields (comma-separated)
  --without-publish  Clean package without npm publish
  --dry-run          Reports what would have been published
  --package-manager  Package manager to use (npm, pnpm, yarn)
  --access           Package access level (public, restricted)
  --tag              Registers package with given tag
  --before-script    Run script on release dir before publish
  --temp-dir         Create temporary directory with given name
  --                 Pass next arguments as package manager options

Usage Examples:

# Basic usage
npx clean-publish

# Clean with specific files and fields
npx clean-publish --files "*.test.js,coverage/" --fields "devDependencies,scripts.test"

# Use different package manager with options
npx clean-publish --package-manager pnpm -- --no-git-checks

# Dry run to see what would be published
npx clean-publish --dry-run

# Clean README and remove comments
npx clean-publish --clean-docs --clean-comments

# Publish with tag
npx clean-publish --tag beta

# Run custom script before publish
npx clean-publish --before-script "npm run build"

clear-package-json Command

Standalone utility for cleaning package.json files without the full publish workflow.

npx clear-package-json <input> [options]

Arguments:
  input              Path to package.json file (or "-" for stdin)

Options:
  --help             Show help
  --version          Show version number  
  --fields           One or more exclude package.json fields (comma-separated)
  --output, -o       Output file name (defaults to stdout)

Usage Examples:

# Clean package.json and output to stdout
npx clear-package-json package.json

# Clean specific fields and save to file
npx clear-package-json package.json --fields "devDependencies,scripts" -o clean-package.json

# Clean from stdin
cat package.json | npx clear-package-json - --fields "devDependencies"

CLI Implementation Details

Option Parsing

Both commands implement custom argument parsing with support for:

  • Boolean flags (e.g., --clean-docs)
  • String arguments (e.g., --package-manager npm)
  • List arguments (e.g., --files "file1.js,file2.js")
  • Passthrough arguments after -- separator

Configuration Integration

CLI options are merged with configuration files and defaults in this order of precedence:

  1. CLI arguments (highest priority)
  2. Configuration files (.clean-publish, .clean-publish.js, etc.)
  3. package.json "clean-publish" section
  4. Built-in defaults (lowest priority)

Error Handling

Both commands provide:

  • Comprehensive help messages with --help
  • Version information with --version
  • Descriptive error messages for invalid configurations
  • Proper exit codes for CI/CD integration

Exit Behavior

  • Success: Exit code 0
  • Configuration errors: Exit code 1 with error message
  • Runtime errors: Exit code 1 with stack trace
  • Help/version: Exit code 0 after displaying information

docs

cli-commands.md

configuration.md

core-operations.md

file-processing.md

index.md

utilities.md

tile.json