packages/scripts/README.md
A comprehensive tool for managing versions and publishing packages in the Elementor monorepo.
The version manager is organized into a modular structure for better maintainability:
scripts/version-manager/
├── index.js # Main entry point
├── cli.js # CLI interface and argument parsing
├── constants.js # Constants and configuration
├── logger.js # Logging utilities
├── package-discovery.js # Package discovery and filtering
├── version-utils.js # Version manipulation utilities
├── version-operations.js # Version setting and bumping operations
├── validation.js # Package validation logic
├── publishing.js # Publishing functionality
└── listing.js # Package listing and display
Set an exact version for all packages:
node scripts/version-manager/index.js set <version> [options]
Examples:
# Set all packages to version 3.31.0
node scripts/version-manager/index.js set 3.31.0
# Set with pre-release tag
node scripts/version-manager/index.js set 3.31.0 --tag beta.1
# Dry run to see what would change
node scripts/version-manager/index.js set 3.31.0 --dry-run
# Set only specific packages
node scripts/version-manager/index.js set 3.31.0 --packages "packages/core/*"
Increment version using semantic versioning:
node scripts/version-manager/index.js bump <type> [options]
Types: patch, minor, major
Examples:
# Bump patch version
node scripts/version-manager/index.js bump patch
# Bump minor version with release candidate tag
node scripts/version-manager/index.js bump minor --tag rc.1
# Bump from specific base version
node scripts/version-manager/index.js bump patch --base-version 3.30.0
List all packages and their versions:
node scripts/version-manager/index.js list [options]
Examples:
# List all packages
node scripts/version-manager/index.js list
# List only publishable packages
node scripts/version-manager/index.js list --publishable
# List specific packages
node scripts/version-manager/index.js list --packages "packages/libs/*"
Get version of a package matching a regex pattern with clean output (useful for scripts):
node scripts/version-manager/index.js get-version <pattern> [options]
Options:
--release-type <type>: Calculate new version by release type (patch, minor, major)Examples:
# Get version of a specific package
node scripts/version-manager/index.js get-version "@elementor/editor-controls"
# Get version of first package matching pattern
node scripts/version-manager/index.js get-version "editor-.*"
# Get next patch version of a package
node scripts/version-manager/index.js get-version "@elementor/editor-controls" --release-type patch
# Get next minor version of first matching package
node scripts/version-manager/index.js get-version "editor-.*" --release-type minor
# Use in scripts
VERSION=$(node scripts/version-manager/index.js get-version "@elementor/.*")
NEXT_VERSION=$(node scripts/version-manager/index.js get-version "@elementor/.*" --release-type patch)
The command outputs only the version number without any formatting, making it ideal for use in scripts. It returns:
Check that all packages have consistent versioning:
node scripts/version-manager/index.js validate [options]
Publish packages to npm (only non-private packages):
node scripts/version-manager/index.js publish [options]
Important: Only packages with "private": false in their package.json will be published.
Examples:
# Publish all packages (with confirmation)
node scripts/version-manager/index.js publish
# Publish without confirmation
node scripts/version-manager/index.js publish --yes
# Dry run to see what would be published
node scripts/version-manager/index.js publish --dry-run
# Publish specific packages
node scripts/version-manager/index.js publish --packages "packages/libs/*"
# Publish with specific access level
node scripts/version-manager/index.js publish --access public
# Publish with two-factor authentication
node scripts/version-manager/index.js publish --otp <token>
Before publishing, the script performs comprehensive validation:
dist directory exists and contains files--dry-run: Show what would be changed without making changes--packages <pattern>: Glob pattern for packages to process (default: all)--tag <suffix>: Add version suffix (e.g., beta, rc, alpha)--yes: Assume "yes" to prompts and confirmations--access <public|restricted>: Access level for published packages--otp <token>: Two-factor authentication token for npm--base-version <version>: Base version to bump from (for bump command)To make a package publishable, ensure its package.json has:
{
"name": "@elementor/your-package",
"version": "1.0.0",
"private": false,
"publishConfig": {
"access": "public"
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"README.md",
"CHANGELOG.md",
"/dist",
"/src",
"!**/__tests__"
]
}
To keep a package private, set:
{
"private": true
}
Build packages:
npm run build
Bump versions:
node scripts/version-manager/index.js bump patch
Validate:
node scripts/version-manager/index.js validate
Preview publishing:
node scripts/version-manager/index.js publish --dry-run
Publish:
node scripts/version-manager/index.js publish --yes
Set pre-release version:
node scripts/version-manager/index.js set 3.31.0 --tag beta.1
Publish pre-release:
node scripts/version-manager/index.js publish --tag beta --yes
The version manager integrates with existing npm scripts:
{
"scripts": {
"version": "node scripts/version-manager/index.js set",
"version:list": "node scripts/version-manager/index.js list",
"version:validate": "node scripts/version-manager/index.js validate",
"version:bump": "node scripts/version-manager/index.js bump",
"version:set": "node scripts/version-manager/index.js set",
"version:get": "node scripts/version-manager/index.js get-version",
"release": "npm run build && node scripts/version-manager/index.js publish"
}
}
The script provides clear error messages and exits with appropriate codes:
npm run build firstFor detailed debugging, you can add console.log statements or use Node.js debugger:
node --inspect scripts/version-manager/index.js publish --dry-run