feat: add validation and semver utility modules#70
Open
AdekunleBamz wants to merge 1 commit intoExodusMovement:masterfrom
Open
feat: add validation and semver utility modules#70AdekunleBamz wants to merge 1 commit intoExodusMovement:masterfrom
AdekunleBamz wants to merge 1 commit intoExodusMovement:masterfrom
Conversation
- Add validation.ts with input validation utilities: - Package name validation (npm naming conventions) - Package scope extraction - CSV package list validation - Git branch name validation - GitHub token format validation - Workflow ID validation - Commit type validation for conventional commits - Shell input sanitization - Add semver.ts with semantic versioning utilities: - SemVer parsing and formatting - Version comparison and sorting - Version bumping (major/minor/patch/pre*) - Prerelease detection and filtering - Tag version extraction - Version range checking - Add comprehensive test suites: - 47 tests for validation utilities - 46 tests for semver utilities
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds two comprehensive utility modules to enhance input validation and semantic versioning operations for the lerna release action.
Changes
New Files
src/utils/validation.ts- Input validation utilities:isValidPackageName()- Validates npm package naming conventions (scoped and unscoped)getPackageScope()- Extracts scope from scoped package namesgetUnscopedName()- Gets the unscoped portion of a package nameisNonEmptyString()- Type guard for non-empty stringsvalidatePackagesCsv()- Parses and validates comma-separated package listsisValidBranchName()- Validates git branch naming rulesisValidGitHubTokenFormat()- Validates GitHub token format (PAT, OAuth, App tokens)sanitizeForShell()- Removes dangerous shell characters from inputisValidWorkflowId()- Validates workflow filename or numeric ID formatisValidCommitType()- Validates conventional commit typesassertInput()- Assertion helper with descriptive error messagessrc/utils/semver.ts- Semantic versioning utilities:isValidSemVer()- Validates semantic version stringsparseSemVer()/formatSemVer()- Parse and format SemVer objectscompareSemVer()- Compare two versions (supports prereleases)sortSemVer()- Sort version arrays ascending or descendinggetHighestVersion()/getLowestVersion()- Find version extremesbumpVersion()- Increment versions (major/minor/patch/pre*)satisfiesGte()/satisfiesLt()- Version range checkingisPrerelease()- Detect prerelease versionsextractVersionFromTag()- Extract version from git tags like@scope/pkg@1.0.0getStableVersions()/getPrereleaseVersions()- Filter version listsgetPrereleaseIdentifier()- Extract prerelease identifier (alpha, beta, etc.)Test Coverage
Benefits