Overview
The plugins package (@tempad-dev/plugins) is a public SDK that provides types, hooks, and helpers for plugin authors to customize TemPad Dev’s code generation behavior.
Location: packages/plugins/
NPM Package: @tempad-dev/plugins
Repository: https://github.com/ecomfe/tempad-dev
Responsibilities
- Stable, documented plugin APIs
- Types and helpers safe for external users
- Transform hooks for code generation
- Maintaining README examples
Tech Stack
- Language: TypeScript
- Build Tool: tsdown
- Output: ESM + TypeScript declarations
Directory Structure
Key Commands
Building
dist/index.js- ESM exportdist/index.d.ts- TypeScript types
Testing
Quality Checks
Publishing
build runs automatically via prepublishOnly
Public API
Transform Hooks
Plugins provide transform hooks for customizing code generation:Example Usage
Type Exports
All public types are exported fromsrc/index.ts:
Code Style Guidelines
Additive API Changes
Good: Add optional fieldsAlways Update README
When public types change, update both:README.md(English)README.zh-Hans.md(Chinese)
Testing Strategy
Coverage Focus
Coverage focused onsrc/index.ts:
Test Files
Location:tests/
Pattern: *.test.ts (Node runtime only)
Example Test
Boundaries and Constraints
Never Introduce Extension Internals
Do not expose extension-specific concepts:No Runtime Dependencies
Do not add runtime dependencies without approval. The package should be lightweight.No Breaking Changes
Treat every change as public-facing. Do not make breaking changes unless explicitly planned.Verification Checklist
Always Run
README Updates
When changing public types:- Update
README.mdexamples - Update
README.zh-Hans.mdexamples - Verify code examples compile
Coverage Check
Publishing Workflow
- Update version in
package.json - Update README if API changed
- Build:
- Verify:
- Publish:
build automatically.
Package Configuration
Exports
Frompackage.json:
Files
Onlydist/ and README.md are published:
Versioning
Follow semantic versioning:- Patch: Bug fixes, documentation updates
- Minor: New optional fields, backward-compatible additions
- Major: Breaking changes, removed/renamed fields
Related Documentation
In source repo:- Testing architecture:
docs/testing/architecture.md