Skip to content

fix(tools): support tagPrefix as an array of tags#3153

Merged
bennypowers merged 6 commits into
staging/pfv6from
fix/tag-prefix-array
May 25, 2026
Merged

fix(tools): support tagPrefix as an array of tags#3153
bennypowers merged 6 commits into
staging/pfv6from
fix/tag-prefix-array

Conversation

@zeroedin
Copy link
Copy Markdown
Collaborator

Summary

Adds support for tagPrefix as string | string[] in .pfe.config.json, enabling both pf-v5-* and pf-v6-* elements to coexist in the same repo during the v6 migration.

Previously, tagPrefix was a single string ("pf-v5"). The test runner middleware, docs pages, and manifest tooling all assumed a single prefix, so v6 elements couldn't get .js.ts redirects in tests,
correct prefix stripping in docs, or proper demo metadata.

Changes

  • .pfe.config.json — changed tagPrefix from "pf-v5" to ["pf-v5", "pf-v6"]
  • tools/pfe-tools/config.ts — updated PfeConfig.tagPrefix type to string | string[]; updated deslugify() to check all prefixes using [value].flat()
  • tools/pfe-tools/test/config.ts — normalized prefix to array; middleware now matches any prefix via .some()
  • tools/pfe-tools/11ty/DocsPage.ts — finds matching prefix for tagName from array
  • tools/pfe-tools/custom-elements-manifest/lib/Manifest.ts — same prefix-matching pattern for demo metadata
  • tools/pfe-tools/11ty/plugins/types.ts — updated DemoRecord.tagPrefix type to string | string[]

Known Issues

  • Permalink collisions: 11ty generates the same permalink for elements sharing a base name (e.g. pf-v5-spinner and pf-v6-spinner both map to /components/spinner/). Only one version should exist at a time
    — remove the v5 element when the v6 replacement is ready.
  • Cross-element dependencies: Some v5 elements import other v5 elements directly (e.g. pf-v5-button imports pf-v5-spinner). When a v5 element is replaced by its v6 version, any v5 elements that depend on
    it must also be updated to import the v6 replacement, or the old v5 element must remain until all its consumers are migrated.
  • docs/main.mjs manual updates: This file eagerly imports all elements for the 11ty docs site. When swapping a v5 element for its v6 replacement, the import must be manually updated.

Test plan

  • npm run build — no type errors
  • npx wtr elements/pf-v5-accordion/test/pf-accordion.spec.ts — v5 element tests still pass
  • Copy a pf-v6-* element into the repo and run its tests without pre-building — .js.ts redirect works
  • Dev server docs pages render correct element names for both prefixes

Testing Instructions

Notes to Reviewers

@zeroedin zeroedin requested a review from bennypowers May 19, 2026 20:00
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 19, 2026

🦋 Changeset detected

Latest commit: 63ed2b4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@patternfly/pfe-tools Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 19, 2026

✅ Commitlint tests passed!

More Info
{
  "valid": true,
  "errors": [],
  "warnings": [],
  "input": "fix(tools): support tagPrefix as an array of tags"
}

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 19, 2026

Deploy Preview for patternfly-elements ready!

Name Link
🔨 Latest commit ab11a45
😎 Deploy Preview https://deploy-preview-3153--patternfly-elements.netlify.app/

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions github-actions Bot added the AT passed Automated testing has passed label May 19, 2026
@github-actions
Copy link
Copy Markdown
Contributor

SSR Test Run for 172d1a0: Report

@github-actions
Copy link
Copy Markdown
Contributor

SSR Test Run for 2c4250b: Report

@bennypowers
Copy link
Copy Markdown
Member

  • Permalink collisions
  • Cross-element dependencies

Arguably, these are both legitimately error states. This is so specified in the skill files

  • docs/main.mjs manual updates

Ideally we'd import in situ instead of a big master barrel import. Could be done in a later pr

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds multi-prefix support for tagPrefix across pfe-tools so repositories can host both pf-v5-* and pf-v6-* elements during the v6 migration, while keeping test redirects, docs rendering, and demo metadata generation working.

Changes:

  • Update config typing and normalization so tagPrefix can be string | string[] (including .pfe.config.json).
  • Update test-runner middleware and docs/manifest tooling to match/strip the correct prefix from a set of prefixes.
  • Add a changeset to publish @patternfly/pfe-tools with the new capability.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tools/pfe-tools/config.ts Allows tagPrefix to be an array; updates deslugify() to recognize multiple prefixes.
tools/pfe-tools/test/config.ts Normalizes tagPrefix to an array and matches any configured prefix for .js.ts redirects.
tools/pfe-tools/11ty/DocsPage.ts Selects the matching prefix for a tag when generating titles/slugs.
tools/pfe-tools/custom-elements-manifest/lib/Manifest.ts Selects the matching prefix for demo metadata/title generation.
tools/pfe-tools/11ty/plugins/types.ts Updates DemoRecord.tagPrefix typing to `string
.pfe.config.json Switches repo config to ["pf-v5","pf-v6"].
.changeset/fancy-keys-hug.md Publishes a minor version bump documenting the new tagPrefix behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/pfe-tools/config.ts Outdated
Comment thread tools/pfe-tools/11ty/DocsPage.ts Outdated
Comment thread tools/pfe-tools/custom-elements-manifest/lib/Manifest.ts Outdated
Centralizes prefix normalization into two helpers in config.ts:
- `getPrefixes()`: normalizes tagPrefix to non-empty array, throws on empty
- `matchPrefix()`: finds matching prefix for a tag name with trailing dash

All callsites (DocsPage, Manifest, test config, deslugify) updated to use
helpers instead of inline `[].flat()` normalization, addressing Copilot
review feedback about `prefixes[0]` being undefined when tagPrefix is an
empty array.

Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ating

The DemoRecord interface in 11ty/plugins/types.ts was a separate copy
from the canonical one in Manifest.ts. Re-export it to maintain a single
source of truth. The CJS plugin's JSDoc type annotation still resolves
correctly.

Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Covers edge cases: empty array, undefined tagPrefix, empty string
filtering, prefix matching/fallback, trailing dash normalization,
and multi-prefix deslugify behavior.

Uses node:test + node:assert, run via `npx tsx --test`.

Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

SSR Test Run for e893be3: Report

config.spec.ts uses node:test and node:assert, which cannot run in
WTR's browser context. Exclude tools/pfe-tools/*.spec.ts from the
WTR file glob.

Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

SSR Test Run for ab11a45: Report

@bennypowers bennypowers merged commit 4fa7f28 into staging/pfv6 May 25, 2026
11 checks passed
@bennypowers bennypowers deleted the fix/tag-prefix-array branch May 25, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AT passed Automated testing has passed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants