generate-barrels
Generate Barrel Files
Generate barrel index.ts files for TypeScript directories to simplify imports.
Note: Generation commands (
model gen,aptx functions,react-query,vue-query) automatically update barrel files after generation. Use this command only for manual fixes or special cases.
When to Use This Command
| Scenario | Action |
|---|---|
| Normal generation | Barrel files are auto-updated - no action needed |
| Fixing corrupted barrel files | Use this command |
| Processing non-standard directory structures | Use this command |
| One-time batch updates across multiple directories | Use this command |
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.
More from haibaraaiaptx/frontend-openapi-skills
download-openapi
Download remote OpenAPI/Swagger JSON specification from a URL to local file using aptx-ft CLI. TRIGGER when user mentions: (1) fetch/pull/download swagger or openapi from URL, (2) save API spec to openapi.json locally, (3) get API documentation from server, or (4) prepare local input for code generation. DO NOT TRIGGER when: generating code/types from local file, reading existing openapi.json, downloading non-OpenAPI files, or authentication is required.
25generate-artifacts
Generate frontend artifacts from OpenAPI via aptx-ft, including models and request clients. Use when user wants: (1) to generate API code from OpenAPI/Swagger, (2) React Query hooks from API spec, (3) Vue Query composables from API spec, (4) function-based API clients, (5) a standard flow for frontend projects without framework-specific business adaptation, (6) track generated files with manifest, (7) preview changes before generation, or (8) update barrel files automatically.
24generate-models
Generate TypeScript interfaces and enums from OpenAPI schemas using aptx-ft CLI. Use when user asks to: (1) generate types/models from OpenAPI/Swagger, (2) create TypeScript interfaces from API schema, (3) extract type definitions from openapi.json, (4) generate selective models with --name filter, (5) preserve translated enum values, (6) track generated files with manifest, (7) preview changes before generation, or (8) update barrel files automatically. Do NOT use for full artifact generation with request layer or Material UI enum adaptation.
23adapt-materal-enums
Materal-specific enum adaptation workflow: fetch enum values from provider API, let LLM fill suggested_name, then apply patch with aptx-ft. Use ONLY when: (1) user mentions Materal framework, (2) Materal naming rules are required, or (3) adapting Materal enum semantics. Do NOT use for generic OpenAPI projects.
23download-swagger-file
从 URL 下载 OpenAPI 3.x JSON 规范文件。用于:(1)从远程服务器获取 API 规范,(2)将 OpenAPI JSON 保存到本地,(3)为 TypeScript 模型生成准备规范。
6generate-ts-models
Use when you have an OpenAPI/Swagger JSON specification and need TypeScript type definitions for schemas, enums, with automatic index.ts barrel file generation
5