azdevops-cli
v1.0.1
Published
Azure DevOps CLI tool for sprint management and work item tracking
Downloads
8
Maintainers
Readme
Azure DevOps CLI Tool
A Node.js CLI tool for interacting with Azure DevOps services. Provides commands to manage sprints, work items, and team workflows through a simple command-line interface.
Developer Documentation
🚀 Quick Start for Developers
This document provides a clear workflow for developers working on the Azure DevOps CLI tool.
Prerequisites
- Node.js 18+
- npm
- Azure DevOps Personal Access Token (PAT)
Development Workflow
1. Initial Setup
# Clone the repository
git clone <repository-url>
cd azdevopscli-nodejs
# Install dependencies
npm install2. Configuration
Option 1: Interactive Setup (Recommended)
Run the setup command to configure your credentials interactively:
npm run start setupThis will prompt you for:
- Azure DevOps Organization
- Azure DevOps Project
- Azure DevOps Team
- Personal Access Token (PAT)
The configuration will be saved to ~/.azdevops/config.json.
Option 2: Environment Variables
Alternatively, you can use environment variables by editing the .env file:
AZURE_ORGANIZATION=your-organization-name
AZURE_PROJECT=PROJECT
AZURE_TEAM=TEAM
AZURE_PAT=your-personal-access-tokenTo generate a Personal Access Token (PAT):
- Go to Azure DevOps → User Settings → Personal Access Tokens
- Click "New Token"
- Set appropriate scopes (Work Items: Read, Code: Read)
- Copy the generated token to your configuration
3. Credential Management
For Development (Local)
- Use the interactive setup:
npm run start setup - Or use environment variables in
.envfile
For Production (npm install)
When users install your CLI from npm, they should:
Install the CLI globally:
npm install -g azdevopscli-nodejsRun the setup command:
azdevops setupUse the CLI:
azdevops follow-sprint
The configuration is automatically saved to ~/.azdevops/config.json and persists across sessions.
4. Running the Application
⚠️ IMPORTANT: Always use npm run start to run the application
# ✅ CORRECT - Use this command to run the application
npm run start follow-sprint
# ✅ CORRECT - With sprint parameter
npm run start -- follow-sprint -s "Sprint 47"❌ DO NOT use these commands:
node dist/index.js(bypasses build process)node src/index.ts(TypeScript files need compilation)ts-node src/index.ts(not configured for this project)
4. Development Workflow
Making Changes
- Edit TypeScript files in the
src/directory - Run the application with
npm run start(this automatically builds and runs) - Test your changes by executing commands
- Repeat until satisfied
Build Process
The npm run start command automatically:
- Cleans the
dist/directory - Compiles TypeScript to JavaScript using esbuild
- Runs the compiled application
# Manual build commands (if needed)
npm run build # Production build
npm run build:dev # Development build with sourcemaps
npm run clean # Clean dist directory5. Project Structure
src/
├── commands/ # CLI command implementations
│ └── follow-sprint/
│ ├── follow-sprint-command.ts # Command logic
│ └── follow-sprint-ui.ts # UI and display logic
├── services/ # Business logic and API services
│ ├── auth.ts # Authentication and configuration
│ ├── azure-client.ts # HTTP client wrapper
│ ├── azure-devops.ts # Azure DevOps API service
│ └── types.ts # TypeScript type definitions
└── index.ts # Main entry point6. Adding New Commands
- Create a new directory in
src/commands/ - Create command files following the existing pattern
- Register the command in
src/index.ts - Test with
npm run start your-new-command
Example command structure:
// src/commands/your-command/your-command-command.ts
export class YourCommand {
private program: Command;
constructor() {
this.program = new Command();
this.setupCommand();
}
private setupCommand(): void {
this.program
.name("your-command")
.description("Description of your command")
.action(async (options) => {
await this.run(options);
});
}
async run(options: any): Promise<void> {
// Your command implementation
}
getCommand(): Command {
return this.program;
}
}7. Available Scripts
| Script | Description | When to Use |
| ------------------- | --------------------------------- | ---------------------------------- |
| npm run start | Build and run the application | Always use this to run the app |
| npm run build | Compile TypeScript to JavaScript | Manual builds |
| npm run build:dev | Development build with sourcemaps | Debugging |
| npm run clean | Remove dist directory | Clean builds |
| npm test | Run tests | Testing (not implemented yet) |
8. Code Quality Standards
Error Handling
- Create custom error types that implement the Error interface
- Include error codes and user-friendly messages
- Never expose internal system errors to end users
- Log errors with sufficient context for debugging
Security
- Never log sensitive information (passwords, tokens, personal data)
- Validate all user inputs and sanitize data
- Store secrets in environment variables, never in code
9. Troubleshooting
Common Issues
"Command not found" errors
- Ensure you're using
npm run startnotnodedirectly - Check that dependencies are installed with
npm install
- Ensure you're using
TypeScript compilation errors
- Run
npm run buildto see detailed error messages - Check TypeScript configuration in
tsconfig.json
- Run
Authentication errors
- Check that your PAT has appropriate permissions
Build errors
- Run
npm run cleanthennpm run build - Check for syntax errors in TypeScript files
- Run
Debug Mode
To enable debug logging:
DEBUG=azdevopscli npm run start follow-sprint10. Git Workflow
Commit Standards
- Write meaningful commit messages following conventional commits
- Use feature branches and pull requests
- Never commit secrets or sensitive data
Before Committing
- Ensure all changes work with
npm run start - Test your changes thoroughly
- Update documentation if needed
- Check for any sensitive data in your changes
Summary
Key Points for Developers:
- Always use
npm run startto run the application - Never run TypeScript files directly - they must be compiled first
- Follow the established project structure when adding new features
- Test thoroughly before committing changes
- Keep the build process simple - let
npm run starthandle everything
Remember: The npm run start command is designed to handle the entire workflow from build to execution. Use it consistently to ensure a reliable development experience.
