A JavaScript library designed to validate and clean address input fields in WooCommerce forms. This tool helps ensure that street names and house numbers are entered in the correct format.
- Validates if the street name and house number are entered correctly.
- Handles edge cases such as extra text after house numbers and street names.
- Provides real-time input validation with custom error messages.
- Automatically updates the house number field based on the street name and vice versa.
You can install the woocommerce-address-validator
via npm, yarn, or pnpm.
pnpm add @soulla/woocommerce-address-validator
npm install @soulla/woocommerce-address-validator
Before you start using this project, follow these steps to install pnpm
and the necessary dependencies.
If you don't have pnpm
installed, you can install it globally using the following command:
npm install -g pnpm
Once pnpm
is installed, clone the repository and install the project dependencies.
git clone https://github.com/TooCodeSavvy/woocommerce-address-validator.git
cd woocommerce-address-validator
pnpm install
This will install all the required dependencies listed in package.json.
Once dependencies are installed, you can build the project:
pnpm build
This will transpile and prepare the project for production.
Here are the available commands you can run during development:
-
pnpm changeset
: Create a changeset for versioning and changelog updates. -
pnpm build
: Build the project, typically to prepare for production or testing. -
pnpm check
: Run TypeScript checks without emitting any files. -
pnpm lint
: Run ESLint to check the code for style and quality issues. -
pnpm lint:fix
: Run ESLint and automatically fix any fixable issues.
If you plan to contribute and push changes to NPM, you'll need to set up your NPM credentials.
-
Create an NPM Token:
- Go to NPM's website and log in or create an account.
- Navigate to your profile, and under the "Access Tokens" section, generate a new "Automation" token.
-
Add NPM Token to GitHub Secrets:
- Go to your repository on GitHub.
- Under "Settings" > "Secrets" > "New repository secret", add your NPM token as
NPM_TOKEN
. - This will allow the CI pipeline to automatically publish the package to NPM when changes are pushed to the
main
branch.
This repository has a CI/CD pipeline set up using GitHub Actions to automatically handle versioning, linting, and publishing to NPM. Here's a breakdown of the process:
-
Trigger: The pipeline runs when a pull request is opened or merged into the
main
branch. - Check for Changes: The pipeline runs checks such as linting and build to ensure code quality.
- Versioning: If a changeset has been created, it automatically updates the version and changelog.
-
Publish to NPM: If there is an
NPM_TOKEN
secret in the repository, the pipeline will publish the package to NPM. - Git Tag: After publishing, a new Git tag is created and pushed.
- Checkout Repo: Clones the repository.
-
Setup pnpm and Node.js: Installs the required versions of
pnpm
and Node.js. -
Install Dependencies: Installs the project dependencies using
pnpm install
. - Build Project: Runs the build script to prepare the code for deployment.
-
Versioning: Uses
changesets
to handle versioning and changelog updates. -
Publishing to NPM: If an
NPM_TOKEN
is available, it creates an.npmrc
file for authentication and pushes the package to NPM. - Create Git Tag: Once the release is complete, a Git tag is created and pushed to the remote repository.
- Pull Request: When a pull request is opened, the workflow checks for linting issues, builds the project, and checks if there are any version changes or unpublished packages.
-
Merging to
main
: Once the pull request is merged into themain
branch, the workflow runs again and publishes the package to NPM if everything is correct.
This project is licensed under the MIT License - see the LICENSE file for details.