1.8 KiB
1.8 KiB
SHSF CLI Project Guidelines
Architecture
- Framework: Built with
commanderfor CLI management. - Dynamic Commands: Commands are dynamically loaded from
src/commands/using recursive directory scanning in src/commands.ts. - API Client: Centralized Axios instance in src/api.ts with standardized headers and singleton pattern for configuration injection.
- Configuration: Managed via
loadConfigin src/config.ts, typically using environment variables or local files.
Code Style
- TypeScript: Strict typing is preferred.
- ES Modules: The project uses
"type": "module". Always use.jsextensions in imports if required by the runtime/build (though TS usually handles this, be mindful of ESM requirements). - Output: Use
chalkfor terminal styling. Consistent color coding:- Green: Success/Healthy
- Red: Errors/Failures
- Yellow: Warnings/Pending
Build and Test
- Install:
pnpm install - Build:
pnpm build(runsrimraf dist && tsc) - Run:
pnpm start [command]ornode dist/index.js [command] - Binary: The CLI is named
shsf.
Conventions
- New Commands: To add a command, create a new file in
src/commands/(or a subfolder). It must export a definition object (default or named) withname,description, andaction. - Error Handling: Follow the pattern in src/commands/health.ts for handling Axios errors (check for
error.response,error.request, etc.). - No Global Scope: Keep command logic within the
actionfunction or extracted to utility modules to maintain testability.
Versioning
- Versioning: Always increment the version number in package.json whenever a change is merged into main. The version format is major.minor.patch.