Add component category field to template manifest#184
Add component category field to template manifest#184nick-pape merged 5 commits intoSharePoint:mainfrom
Conversation
Add a required `category` field to template.json with allowed values: webpart, extension, ace, library. This enables grouping and filtering templates by component type for the future list-templates command. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a required category field to SPFx template.json manifests and surfaces it through the @microsoft/spfx-template-api object model, enabling templates to be grouped/filtered by component type.
Changes:
- Introduces
SPFX_TEMPLATE_CATEGORIES+SPFxTemplateCategory, and makescategoryrequired inISPFxTemplateJson+ Zod schema validation. - Exposes
categoryonSPFxTemplateJsonFileandSPFxTemplateand includes it inSPFxTemplate.toString()output. - Updates all template manifests and refreshes unit/integration test snapshots and API docs/README.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/spfx-template-test/test-template/template.json | Adds category to the test template manifest. |
| tests/spfx-template-test/src/tests/snapshots/templates.test.ts.snap | Updates snapshots to include the new “Category” line in template output. |
| tests/spfx-template-test/src/tests/snapshots/multi-component.test.ts.snap | Updates multi-component snapshots to include the new “Category” line. |
| templates/ace-data-visualization/template.json | Adds category: "ace" to the template manifest. |
| templates/ace-generic-card/template.json | Adds category: "ace" to the template manifest. |
| templates/ace-generic-image-card/template.json | Adds category: "ace" to the template manifest. |
| templates/ace-generic-primarytext-card/template.json | Adds category: "ace" to the template manifest. |
| templates/ace-search-card/template.json | Adds category: "ace" to the template manifest. |
| templates/extension-application-customizer/template.json | Adds category: "extension" to the template manifest. |
| templates/extension-fieldcustomizer-minimal/template.json | Adds category: "extension" to the template manifest. |
| templates/extension-fieldcustomizer-noframework/template.json | Adds category: "extension" to the template manifest. |
| templates/extension-fieldcustomizer-react/template.json | Adds category: "extension" to the template manifest. |
| templates/extension-formcustomizer-noframework/template.json | Adds category: "extension" to the template manifest. |
| templates/extension-formcustomizer-react/template.json | Adds category: "extension" to the template manifest. |
| templates/extension-listviewcommandset/template.json | Adds category: "extension" to the template manifest. |
| templates/extension-search-query-modifier/template.json | Adds category: "extension" to the template manifest. |
| templates/library/template.json | Adds category: "library" to the template manifest. |
| templates/webpart-minimal/template.json | Adds category: "webpart" to the template manifest. |
| templates/webpart-noframework/template.json | Adds category: "webpart" to the template manifest. |
| templates/webpart-react/template.json | Adds category: "webpart" to the template manifest. |
| common/changes/@microsoft/spfx-cli/add-template-category_2026-03-24.json | Adds a Rush change file for the PR. |
| api/spfx-template-api/src/templating/test/SPFxTemplateJsonFile.test.ts | Updates tests for required category + adds schema/category test coverage. |
| api/spfx-template-api/src/templating/test/SPFxTemplate.test.ts | Updates template tests to require/expose category and validates toString() output. |
| api/spfx-template-api/src/templating/index.ts | Re-exports new public category symbols from the templating barrel. |
| api/spfx-template-api/src/templating/SPFxTemplateJsonFile.ts | Defines category constants/types; makes category required and validates via Zod enum; adds getter. |
| api/spfx-template-api/src/templating/SPFxTemplate.ts | Adds category getter and includes it in toString(). |
| api/spfx-template-api/src/repositories/test/SPFxTemplateRepositoryManager.test.ts | Updates repository manager tests to include required category. |
| api/spfx-template-api/src/repositories/test/SPFxTemplateCollection.test.ts | Updates template collection tests to include required category. |
| api/spfx-template-api/src/index.ts | Exports new category symbols from the public API entrypoint. |
| api/spfx-template-api/etc/spfx-template-api.api.md | Updates API Extractor output to include new category API surface. |
| api/spfx-template-api/README.md | Updates the API reference table to document category and category-related exports. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
common/changes/@microsoft/spfx-cli/add-template-category_2026-03-24.json
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 31 out of 31 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…t in test - Remove unnecessary \| escaping inside backtick code spans in README table - Use SPFX_TEMPLATE_CATEGORIES constant in category validation test Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Manual Test ResultsRan a manual test pass against the built artifacts on this branch. All tests pass. Schema Validation
Property Getters
toString() Output
Public API Exports
Template Loading (all 17 templates from disk)
End-to-End Rendering
Note on CLIThe |
Description
Adds a required
categoryfield to thetemplate.jsonmanifest schema, enabling templates to be grouped and filtered by component type. This implements issue #97.Categories:
webpart,extension,ace,libraryChanges:
SPFX_TEMPLATE_CATEGORIESconst array andSPFxTemplateCategorytypecategorytoISPFxTemplateJsoninterface andSPFxTemplateDefinitionSchema(Zod enum, required)categorygetter toSPFxTemplateJsonFileandSPFxTemplateSPFxTemplate.toString()to include the category linetemplate.jsonfiles with appropriate category valuesHow was this tested
rush build— all 22 projects build cleanly with no warningsrushx buildinapi/spfx-template-api— all 220 unit tests pass (including new category getter tests, schema validation tests for valid/invalid/missing categories)rushx buildinapps/spfx-cli— all 46 CLI tests passtests/spfx-template-test) — all 19 tests pass with updated snapshotsType of change
Closes #97
🤖 Generated with Claude Code