develop— all contributions and feature work go heremain— release branch, always reflects the latest stable version
Create pull requests targeting develop. When ready to release, merge develop into main and run the release script.
# Install dependencies
npm install
# Build the library
npm run build
# Run tests
npm test
# Run tests in watch mode
npm run test:watchMaintainers must prepare release metadata locally on main before pushing a release tag. CI no longer mutates release files automatically; it now validates metadata and then handles release automation (GitHub Release creation, asset upload, NPM publish, and GitHub Pages deploy).
- NPM publish requires a
NPM_TOKENsecret configured in the repository settings.
# On main branch, after merging develop:
# Bumps package version/package-lock and promotes CHANGELOG.md [Unreleased] notes
npm run release patch # 1.0.0 → 1.0.1
npm run release minor # 1.0.0 → 1.1.0
npm run release major # 1.0.0 → 2.0.0
# Then push commit + tag to trigger the pipeline:
git push origin main --tagsWhen a v* tag is pushed to main, the release pipeline will:
- Validate release metadata from the tagged commit (
package.jsonversion +CHANGELOG.mdsection must match the tag) - Build the full bundle (
js-validation.js+.min.js+ ESM variants) - Create a GitHub Release with auto-generated release notes and attach all dist files
- Publish to NPM registry (skips publish if that version already exists)
- Deploy docs and compiled assets to GitHub Pages
After NPM publish, the package is also available via CDN:
https://cdn.jsdelivr.net/npm/@phpdevsr/js-validation/dist/js-validation.min.js
develop (contributions) → PR → main (releases)
↓
tag v1.x.x
↓
CI: metadata validation → build → GitHub Release → NPM publish → Pages deploy
The release build produces:
| File | Format | Description |
|---|---|---|
dist/js-validation.js |
UMD | Unminified, for development |
dist/js-validation.min.js |
UMD | Minified, for production |
dist/js-validation.esm.js |
ES Module | Unminified, for bundlers |
dist/js-validation.esm.min.js |
ES Module | Minified, for bundlers |
-
Create a new file in
src/rules/(e.g.,src/rules/myRule.js):import { VanillaValidator } from '../core.js'; VanillaValidator.addMethod( 'myRule', (value, param, field, validator) => { // Return true if valid, false otherwise return value.length > 0; }, 'Default error message.' );
-
Import the rule in
src/index.js:import './rules/myRule.js';
-
Add tests in
test/js-validation.test.js. -
Run
npm testto verify, thennpm run buildto confirm the bundle compiles.