Skip to content

Latest commit

Β 

History

History
96 lines (67 loc) Β· 2.95 KB

File metadata and controls

96 lines (67 loc) Β· 2.95 KB

Node.js Implementation

Building, running, and testing the Node.js implementation of outlook-cli.

Prerequisites

  • Node.js 20+ (see engines in package.json)
  • npm (bundled with Node.js)

Install Dependencies

cd outlook-cli
npm install

Run

# Run directly
node bin/outlook-cli.js <command>

# Or create a global symlink for convenience
npm link
outlook-cli <command>

# Or use npx (from the project directory)
npx outlook-cli <command>

Test

npm test                  # Run all tests (vitest)
npm run test:verbose      # Verbose output
npm run test:watch        # Watch mode (re-run on change)
npm run test:coverage     # With coverage report

See src-tests.md for test architecture details.

Build

No build step is required. The Node.js implementation uses ESM modules directly β€” source files are executed as-is by the Node.js runtime.

Project Structure

src/node/
β”œβ”€β”€ accounts/        # Multi-account management (add, remove, list, set-default)
β”œβ”€β”€ auth/            # MSAL authentication (login, logout, status, token cache)
β”œβ”€β”€ cli/             # Commander.js command definitions
β”œβ”€β”€ contacts/        # Contact search and alias management
β”œβ”€β”€ graph/           # Microsoft Graph API HTTP client
β”œβ”€β”€ output/          # Output formatters (text, json, markdown, html)
β”œβ”€β”€ security/        # Permission validation, forbidden scopes, send_to whitelist
β”œβ”€β”€ watch/           # Delta query watch mode, rules engine
β”œβ”€β”€ config.js        # Configuration loading (~/.outlook-cli/)
└── input.js         # JSON input file parsing (--input flag)

Key Dependencies

Package Purpose
@azure/msal-node Microsoft Authentication Library β€” OAuth 2.0 flows, token caching
commander CLI framework β€” commands, options, help generation

Dev dependencies:

Package Purpose
vitest Test runner β€” describe/it/expect, mocking, coverage

Module System

The project uses ES Modules ("type": "module" in package.json). All imports use the import/export syntax:

import { getAccounts } from '../accounts/store.js';
import { acquireToken } from '../auth/token.js';

Entry Point

bin/outlook-cli.js is the main entry point. It imports the Commander.js program from src/node/cli/ and invokes program.parse().

Configuration

The Node.js implementation reads and writes configuration files in ~/.outlook-cli/. See architecture.md for the shared configuration format used by both implementations.

Related Documentation