generate-barrels
4
总安装量
4
周安装量
#54469
全站排名
安装命令
npx skills add https://github.com/haibaraaiaptx/frontend-openapi-skills --skill generate-barrels
Agent 安装分布
opencode
4
gemini-cli
4
claude-code
4
github-copilot
4
codex
4
kimi-cli
4
Skill 文档
Generate Barrel Files
Generate barrel index.ts files for TypeScript directories to simplify imports.
Prerequisites
pnpm add -D @aptx/frontend-tk-cli
Usage
pnpm exec aptx-ft barrel gen -i <input-dir>
Alternative (without pnpm):
npx aptx-ft barrel gen -i ./src/functions
Workflow
- Ask user for target directory path
- Show complete command and confirm with user
- Execute and report results
Common Directories
| Directory | Purpose |
|---|---|
./src/functions |
Function modules |
./src/api |
API modules |
./src |
Entire source directory |
Examples
# Generate for functions directory
pnpm exec aptx-ft barrel gen -i ./src/functions
# Generate for entire src directory
pnpm exec aptx-ft barrel gen -i ./src
# Generate for specific module
pnpm exec aptx-ft barrel gen -i ./src/api
Output
Recursively scans directory and generates barrel files at all levels:
src/
âââ index.ts # Exports functions, react-query, spec
âââ functions/
â âââ index.ts # Exports application, assignment, ...
â âââ application/
â âââ index.ts # Exports getXXX, setXXX, ...
âââ react-query/
â âââ index.ts # Exports application, assignment, ...
â âââ application/
â âââ index.ts # Exports *.query.ts, *.mutation.ts
âââ spec/
âââ ...
Boundaries
- Only generates index.ts barrel files, no other code
- Subdirectory index.ts files are overwritten
- Root index.ts is NOT overwritten if it exists with different content (protects manual entry files)
- Automatically skips
node_modulesand hidden directories (starting with.) - Only processes
.tsfiles, not.tsx,.js, etc.