Skip to content

Latest commit

 

History

History
83 lines (49 loc) · 5.18 KB

File metadata and controls

83 lines (49 loc) · 5.18 KB
graph LR
    CLI_Bootstrap["CLI Bootstrap"]
    Middleware_Pipeline["Middleware Pipeline"]
    CLI_Command_Handlers["CLI Command Handlers"]
    Api_Service["Api Service"]
    Global_Config_Store["Global Config Store"]
    Unclassified["Unclassified"]
    CLI_Bootstrap -- "applies" --> Middleware_Pipeline
    CLI_Bootstrap -- "dispatches" --> CLI_Command_Handlers
    Middleware_Pipeline -- "loads / writes" --> Global_Config_Store
    CLI_Command_Handlers -- "reads / writes" --> Global_Config_Store
    CLI_Command_Handlers -- "invokes" --> Api_Service
    Api_Service -- "initialises with" --> Global_Config_Store
Loading

CodeBoardingDemoContact

Details

The napi CLI is built around a thin Bootstrap (src/cli/index.ts) that creates a yargs command‑line program. At start‑up it attaches a Middleware Pipeline—an ordered series of middlewares (version check, global‑config loading, authentication guard) that enrich the parsed arguments with a Global Config Store (a JSON file located in the user’s OS‑specific config directory). After the pipeline, the Bootstrap registers the CLI Command Handlers (login, init, extract, manifest‑generate, set). Each handler receives the enriched context, reads the persisted configuration, and, when needed, creates an Api Service instance that is pre‑configured with the host and JWT/token from the Global Config. The Api Service performs the required HTTP calls to the remote NanoAPI, while the handlers persist any new credentials or artefacts back to the Global Config or the project’s .napirc file. This layered architecture cleanly separates entry‑point orchestration, cross‑cutting context preparation, pure command logic, and external service interaction.

CLI Bootstrap

Entry point; creates yargs, registers global options, attaches middlewares, and registers command handlers.

Related Classes/Methods:

Middleware Pipeline

Executes ordered middlewares (version check, global‑config loading, auth guard) to build an enriched execution context.

Related Classes/Methods:

CLI Command Handlers

Implements concrete commands (login, init, extract, manifest‑generate, set). Each handler validates input, calls the Api Service, and persists results.

Related Classes/Methods:

Api Service

Thin wrapper around fetch; instantiated with Global Config and provides performRequest for remote NanoAPI calls.

Related Classes/Methods:

Global Config Store

Persistent JSON configuration file handling read/write of API host, JWT/token, and optional labeling keys.

Related Classes/Methods:

Unclassified

Component for all unclassified files and utility functions (Utility functions/External Libraries/Dependencies)

Related Classes/Methods: None