EXAMPLES/mixed-plugins

Mixed Plugins

Demonstrates using multiple plugins together with path-based conflict resolution via pathMappings configuration. src/ files use JavaScript plugin, tutorials/ use YAML manifest.

meta-yml8 FILESpluginpathMappingsconflict-resolution

Mixed Plugins Example

This example demonstrates using multiple plugins together with conflict resolution via pathMappings.

Usage

bash
1# Scan and display examples
2npx functional-examples scan
3
4# Output as JSON
5npx functional-examples scan -f json

The Problem

When both JavaScript and YAML manifest plugins are active, they may both try to claim the same files:

  • JavaScript plugin claims any .ts file with frontmatter
  • YAML manifest plugin claims any directory with meta.yml

If a TypeScript file is inside a directory with meta.yml, both plugins want it.

The Solution: pathMappings

Use pathMappings in your config to specify which extractor wins for each path pattern:

{
  "$schema": "./.functional-examples/schema.json",
  "scan": {
    "include": ["src/**/*", "tutorials/*"],
    "exclude": ["**/node_modules/**"]
  },
  "pathMappings": [
    {
      "pattern": "src/**",
      "extractor": "javascript-extractor"
    },
    {
      "pattern": "tutorials/**",
      "extractor": "meta-yml"
    }
  ]
}
text
1## Project Structure

mixed-plugins/ ├── src/ # JavaScript plugin handles these │ └── utils.ts # Has frontmatter metadata └── tutorials/ # YAML manifest plugin handles these └── hello-world/ ├── meta.yml └── index.ts


## Extractor Names

- `javascript-extractor` — The JavaScript/TypeScript plugin
- `meta-yml` — The YAML manifest plugin

These names are defined by each plugin and used in `pathMappings`.

All Example Files

FILE EXPLORER
README.md
1# Mixed Plugins Example
2
3This example demonstrates using multiple plugins together with conflict resolution via `pathMappings`.
4
5## Usage
6
7```bash
8# Scan and display examples
9npx functional-examples scan
10
11# Output as JSON
12npx functional-examples scan -f json
13```
14
15## The Problem
16
17When both JavaScript and YAML manifest plugins are active, they may both try to claim the same files:
18
19- JavaScript plugin claims any `.ts` file with frontmatter
20- YAML manifest plugin claims any directory with `meta.yml`
21
22If a TypeScript file is inside a directory with `meta.yml`, both plugins want it.
23
24## The Solution: pathMappings
25
26Use `pathMappings` in your config to specify which extractor wins for each path pattern:
27
28<%= file('functional-examples.config.json') %>
29
30## Project Structure
31
32```
33mixed-plugins/
34├── src/                    # JavaScript plugin handles these
35│   └── utils.ts            # Has frontmatter metadata
36└── tutorials/              # YAML manifest plugin handles these
37    └── hello-world/
38        ├── meta.yml
39        └── index.ts
40```
41
42## Extractor Names
43
44- `javascript-extractor` — The JavaScript/TypeScript plugin
45- `meta-yml` — The YAML manifest plugin
46
47These names are defined by each plugin and used in `pathMappings`.
48