fix(tools): support tagPrefix as an array of tags#3153
Conversation
🦋 Changeset detectedLatest commit: 63ed2b4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
✅ Commitlint tests passed!More Info{
"valid": true,
"errors": [],
"warnings": [],
"input": "fix(tools): support tagPrefix as an array of tags"
} |
✅ Deploy Preview for patternfly-elements ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Arguably, these are both legitimately error states. This is so specified in the skill files
Ideally we'd import in situ instead of a big master barrel import. Could be done in a later pr |
There was a problem hiding this comment.
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
tagPrefixcan bestring | 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-toolswith 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.
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>
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>
Summary
Adds support for
tagPrefixasstring | string[]in.pfe.config.json, enabling bothpf-v5-*andpf-v6-*elements to coexist in the same repo during the v6 migration.Previously,
tagPrefixwas 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→.tsredirects in tests,correct prefix stripping in docs, or proper demo metadata.
Changes
.pfe.config.json— changedtagPrefixfrom"pf-v5"to["pf-v5", "pf-v6"]tools/pfe-tools/config.ts— updatedPfeConfig.tagPrefixtype tostring | string[]; updateddeslugify()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 arraytools/pfe-tools/custom-elements-manifest/lib/Manifest.ts— same prefix-matching pattern for demo metadatatools/pfe-tools/11ty/plugins/types.ts— updatedDemoRecord.tagPrefixtype tostring | string[]Known Issues
pf-v5-spinnerandpf-v6-spinnerboth map to/components/spinner/). Only one version should exist at a time— remove the v5 element when the v6 replacement is ready.
pf-v5-buttonimportspf-v5-spinner). When a v5 element is replaced by its v6 version, any v5 elements that depend onit must also be updated to import the v6 replacement, or the old v5 element must remain until all its consumers are migrated.
docs/main.mjsmanual 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 errorsnpx wtr elements/pf-v5-accordion/test/pf-accordion.spec.ts— v5 element tests still passpf-v6-*element into the repo and run its tests without pre-building —.js→.tsredirect worksTesting Instructions
Notes to Reviewers