Clean Publish provides two main CLI commands for different use cases: full package cleaning and publishing workflow, and standalone package.json cleaning utility.
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 optionsUsage 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"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"Both commands implement custom argument parsing with support for:
--clean-docs)--package-manager npm)--files "file1.js,file2.js")-- separatorCLI options are merged with configuration files and defaults in this order of precedence:
.clean-publish, .clean-publish.js, etc.)package.json "clean-publish" sectionBoth commands provide:
--help--version