This repository is a monorepo example demonstrating how to extend the x‑fidelity framework (v3 and above) with custom plugins. It is organized using Yarn workspaces, where each package implements a plugin that integrates seamlessly into the x‑fidelity ecosystem.
-
packages/api-validator
Purpose: Validates repository files by extracting version information using a regex and then verifying it through an external API.
Key Components:- Operator:
regexExtract
- Fact:
externalApiCall
- Operator:
-
packages/security-scanner
Purpose: Scans files for sensitive data (e.g., API keys, passwords, private keys) and ensures that such content is not present.
Key Components:- Operator:
securityRuleCheck
- Fact:
sensitiveDataScan
- Operator:
-
packages/performance-check
Purpose: Measures API response times to verify that performance thresholds are met.
Key Components:- Operator:
thresholdCheck
- Fact:
responseTime
- Operator:
Additionally, the demoConfig folder provides sample rule definitions (for example, in apiValidator-iterative-rule.json
, security-scan-iterative-rule.json
, and performance-check-global-rule.json
) that show how to combine these plugins within an x‑fidelity configuration. The demoConfig/node-fullstack.json
file further demonstrates how to integrate multiple plugins for full‐stack validation.
Each plugin is built to comply with the x‑fidelity framework:
- Structure: Every plugin exports an object with
name
,version
,facts
,operators
, and anonError
handler. - Logic:
- Facts compute or retrieve data (for example, extracting a value from file content or measuring response time).
- Operators act upon the fact results (for example, checking that an extracted value exists or validating that response times are within thresholds).
- Error Handling: Plugins implement a standardized
onError
function that categorizes and logs errors consistently using x‑fidelity’s logger.
Make sure you have Yarn installed, then run:
yarn install
To compile all packages:
yarn build
Run the tests for all plugins:
yarn test
To run x-fidelity including these plugins and rules locally, you can run:
xfidelity . --localConfigPath demoConfig/ --extensions @xfi-plugins/api-validator @xfi-plugins/security-scanner @xfi-plugins/performance-check
This monorepo serves as a template for developing new plugins:
- Create a New Plugin: Add a new package under
packages/
following the established structure (including atsconfig.json
and appropriate test files). - Define Facts & Operators: Implement your logic inside your plugin to extract data or perform validations, ensuring you also provide an
onError
function. - Update Configurations: Add your new facts and operators to a demo configuration (similar to those in
demoConfig/
) to see them in action.
For more details on plugin development, refer to the x‑fidelity documentation.
This repository illustrates a modular, plugin-based approach to extending x‑fidelity. It provides a solid starting point for developing custom plugins that enhance repository validation and monitoring workflows in your projects.