a11yflow-cli
v1.0.0
Published
A11yFlow CLI Tool for CI/CD Integration
Downloads
4
Maintainers
Readme
A11yFlow CLI Tool
Command-line interface tool for A11yFlow accessibility scanning, designed for CI/CD integration.
Installation
Global Installation
npm install -g a11yflow-cliLocal Installation (for CI/CD)
npm install a11yflow-cli --save-devFrom Source
cd cli
npm install
npm run build
npm link # For global accessNote: Nếu package chưa được publish lên npm, bạn có thể install từ source hoặc sử dụng
npm linkđể test local.
Usage
Basic Scan
a11yflow scan --url https://example.com --api-key YOUR_API_KEYFail on Serious Violations (for CI/CD)
a11yflow scan \
--url https://example.com \
--api-key YOUR_API_KEY \
--fail-on seriousFail on Critical Only
a11yflow scan \
--url https://example.com \
--api-key YOUR_API_KEY \
--fail-on criticalJSON Output
a11yflow scan \
--url https://example.com \
--api-key YOUR_API_KEY \
--output jsonCustom API URL
a11yflow scan \
--url https://example.com \
--api-key YOUR_API_KEY \
--api-url https://api.a11yflow.comOptions
-u, --url <url>- URL to scan (required)-k, --api-key <key>- API Key for authentication (required)-f, --fail-on <level>- Fail on violations at this level or higher (default:serious)- Valid levels:
critical,serious,moderate,minor
- Valid levels:
-o, --output <format>- Output format:textorjson(default:text)--api-url <url>- API base URL (default:http://localhost:3001orA11YFLOW_API_URLenv var)--no-color- Disable colored output
Exit Codes
0- Scan completed successfully, no violations at fail-on level or higher1- Error occurred or violations found at fail-on level or higher
CI/CD Integration Examples
GitHub Actions
name: Accessibility Check
on: [push, pull_request]
jobs:
a11y-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install A11yFlow CLI
run: npm install -g a11yflow-cli
- name: Run accessibility scan
run: |
a11yflow scan \
--url ${{ secrets.SITE_URL }} \
--api-key ${{ secrets.A11YFLOW_API_KEY }} \
--fail-on seriousGitLab CI
a11y-check:
image: node:18
before_script:
- npm install -g a11yflow-cli
script:
- a11yflow scan
--url $SITE_URL
--api-key $A11YFLOW_API_KEY
--fail-on serious
only:
- merge_requests
- mainCircleCI
version: 2.1
jobs:
a11y-check:
docker:
- image: cimg/node:18.0
steps:
- checkout
- run:
name: Install A11yFlow CLI
command: npm install -g a11yflow-cli
- run:
name: Run accessibility scan
command: |
a11yflow scan \
--url $SITE_URL \
--api-key $A11YFLOW_API_KEY \
--fail-on seriousJenkins Pipeline
pipeline {
agent any
stages {
stage('Accessibility Check') {
steps {
sh '''
npm install -g a11yflow-cli
a11yflow scan \
--url ${SITE_URL} \
--api-key ${A11YFLOW_API_KEY} \
--fail-on serious
'''
}
}
}
}Environment Variables
A11YFLOW_API_URL- Default API base URL (overridden by--api-url)
Getting Your API Key
- Sign up at A11yFlow
- Go to Settings > API Keys
- Create a new API key
- Copy the key and use it with the
--api-keyoption
Examples
Scan and fail on any serious or critical violations
a11yflow scan \
--url https://mywebsite.com \
--api-key abc123... \
--fail-on seriousScan and only fail on critical violations
a11yflow scan \
--url https://mywebsite.com \
--api-key abc123... \
--fail-on criticalGet JSON output for parsing
a11yflow scan \
--url https://mywebsite.com \
--api-key abc123... \
--output json | jq '.summary'Troubleshooting
Connection Error
If you get a connection error, make sure:
- The API URL is correct (use
--api-urlif needed) - The API server is running and accessible
- Your network/firewall allows connections to the API
Authentication Error
If you get an authentication error:
- Verify your API key is correct
- Check that your API key is active in your account settings
- Ensure you're using the correct API key for your subscription plan
Exit Code Issues
- Exit code
1means violations were found at the--fail-onlevel or higher - To only fail on critical issues, use
--fail-on critical - To see all violations without failing, use
--fail-on minor(will only fail if there are minor issues)
