@soulla/woocommerce-address-validator

1.5.0 • Public • Published

WooCommerce Address Validator

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.

Features

  • 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.

Installation

You can install the woocommerce-address-validator via npm, yarn, or pnpm.

Using pnpm:

pnpm add @soulla/woocommerce-address-validator

Using npm:

npm install @soulla/woocommerce-address-validator

Installation & Setup

Before you start using this project, follow these steps to install pnpm and the necessary dependencies.

1. Install pnpm

If you don't have pnpm installed, you can install it globally using the following command:

Using npm:

npm install -g pnpm

2. Clone the Repository & Install Dependencies

Once pnpm is installed, clone the repository and install the project dependencies.

Clone the repository:

git clone https://github.com/TooCodeSavvy/woocommerce-address-validator.git
cd woocommerce-address-validator

Install dependencies:

pnpm install

This will install all the required dependencies listed in package.json.

3. Build the Project

Once dependencies are installed, you can build the project:

pnpm build

This will transpile and prepare the project for production.

4. Running Commands

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.

5. Publishing to NPM (Optional)

If you plan to contribute and push changes to NPM, you'll need to set up your NPM credentials.

Steps to set up publishing:

  1. 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.
  2. 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.

CI/CD Pipeline

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:

Workflow for Releases

  • 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.

Explanation:

  1. Checkout Repo: Clones the repository.
  2. Setup pnpm and Node.js: Installs the required versions of pnpm and Node.js.
  3. Install Dependencies: Installs the project dependencies using pnpm install.
  4. Build Project: Runs the build script to prepare the code for deployment.
  5. Versioning: Uses changesets to handle versioning and changelog updates.
  6. Publishing to NPM: If an NPM_TOKEN is available, it creates an .npmrc file for authentication and pushes the package to NPM.
  7. Create Git Tag: Once the release is complete, a Git tag is created and pushed to the remote repository.

How the Workflow Works:

  • 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 the main branch, the workflow runs again and publishes the package to NPM if everything is correct.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Readme

Keywords

none

Package Sidebar

Install

npm i @soulla/woocommerce-address-validator

Weekly Downloads

0

Version

1.5.0

License

ISC

Unpacked Size

23.7 kB

Total Files

16

Last publish

Collaborators

  • soulasscraper