Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions .devops-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "DevOps PowerTools Configuration",
"description": "Schema for DevOps application configuration files",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Application name"
},
"version": {
"type": "string",
"description": "Application version",
"pattern": "^\\d+\\.\\d+\\.\\d+$"
},
"environment": {
"type": "string",
"description": "Deployment environment",
"enum": ["development", "staging", "production"]
},
"services": {
"type": "array",
"description": "List of services",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Service name"
},
"port": {
"type": "integer",
"description": "Service port",
"minimum": 1,
"maximum": 65535
},
"replicas": {
"type": "integer",
"description": "Number of replicas",
"minimum": 1,
"default": 1
},
"healthCheck": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean",
"default": true
},
"path": {
"type": "string",
"default": "/health"
},
"interval": {
"type": "integer",
"description": "Health check interval in seconds",
"minimum": 1,
"default": 30
}
}
}
},
"required": ["name", "port"]
}
},
"database": {
"type": "object",
"description": "Database configuration",
"properties": {
"type": {
"type": "string",
"enum": ["mysql", "postgresql", "mongodb", "redis"]
},
"host": {
"type": "string"
},
"port": {
"type": "integer",
"minimum": 1,
"maximum": 65535
},
"name": {
"type": "string"
}
},
"required": ["type", "host"]
}
},
"required": ["name", "version", "environment"]
}
19 changes: 19 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
},
plugins: [
'@typescript-eslint',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
],
rules: {
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
},
};
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
}
]
}
18 changes: 18 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
10 changes: 10 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.vscode/**
.vscode-test/**
src/**
.gitignore
.yarnrc
.eslintrc.js
**/*.map
**/*.ts
tsconfig.json
node_modules/**
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Changelog

All notable changes to the "DevOps PowerTools" extension will be documented in this file.

## [1.0.0] - 2025-12-21

### Added
- Initial release of DevOps PowerTools VSCode extension
- YAML file scaffolding command with predefined template
- YAML file validation against custom JSON schema
- Automatic validation on save for DevOps configuration files
- Default schema for DevOps application configurations
- Support for custom schema files via workspace settings
- Real-time validation feedback in VSCode Problems panel
- Diagnostics for schema validation errors

### Features
- **Scaffold YAML Files**: Create new YAML configuration files with a template structure
- **Schema Validation**: Validate YAML files against JSON Schema Draft 07
- **Configurable Schema Path**: Customize schema location in workspace settings
- **Auto-validation**: Automatically validate on file save
- **Error Reporting**: Clear error messages in the Problems panel

### Schema Support
- Application metadata (name, version, environment)
- Service configurations with health checks
- Database configurations
- Port and replica management
- Extensible schema structure
201 changes: 201 additions & 0 deletions IMPLEMENTATION_SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
# Implementation Summary - DevOps PowerTools VSCode Extension

## Overview
Successfully implemented a complete Visual Studio Code extension that enables developers to scaffold and validate YAML configuration files with custom JSON schemas for DevOps applications.

## What Was Built

### 1. Core Extension (`src/extension.ts`)
- **Scaffold Command**: Creates new YAML files from predefined templates
- **Validate Command**: Validates YAML files against JSON Schema
- **Auto-validation**: Automatically validates on file save for DevOps config files
- **Diagnostics Integration**: Shows validation errors in VSCode Problems panel
- **Smart Error Positioning**: Attempts to locate errors at specific line numbers
- **Proper Lifecycle**: Correctly manages extension activation and deactivation

### 2. Schema Definition (`.devops-schema.json`)
Comprehensive JSON Schema (Draft 07) supporting:
- Application metadata (name, version, environment)
- Service configurations with health checks
- Database configurations with type validation
- Port and replica management
- Pattern matching for semantic versioning
- Enum validation for environments and database types

### 3. Documentation
- **README.md**: Main documentation with features and usage
- **USAGE.md**: Comprehensive guide with examples and troubleshooting
- **QUICKSTART.md**: Quick installation and first steps guide
- **CHANGELOG.md**: Version history and feature documentation

### 4. Testing & Examples
- **example-config.yaml**: Valid configuration example
- **invalid-example.yaml**: Invalid configuration for testing
- **test-validation.js**: Automated validation test script

### 5. Development Setup
- **TypeScript Configuration**: Proper tsconfig.json for compilation
- **ESLint Configuration**: Code quality and consistency
- **VSCode Settings**: Debug configuration and build tasks
- **Package Configuration**: Complete package.json with dependencies

## Key Features Implemented

✅ **YAML Scaffolding**
- Command: "DevOps PowerTools: Scaffold YAML File"
- Creates files with predefined template structure
- Prompts for filename with sensible defaults
- Prevents accidental overwrite with confirmation

✅ **Schema Validation**
- Command: "DevOps PowerTools: Validate YAML File"
- Validates against JSON Schema Draft 07
- Uses AJV validator for comprehensive error detection
- Supports both manual and automatic validation

✅ **Smart Error Reporting**
- Integrates with VSCode Problems panel
- Attempts to identify error line numbers
- Clears diagnostics per-document (not globally)
- Provides clear, actionable error messages

✅ **Configurable Schema**
- Default schema included
- Configurable schema path via workspace settings
- Falls back to default if custom schema not found

✅ **Auto-Validation**
- Triggers on file save
- Detects DevOps config files by naming patterns
- Non-intrusive for unrelated YAML files

## Technical Implementation

### Dependencies
- **vscode**: ^1.75.0 - VSCode API
- **js-yaml**: ^4.1.0 - YAML parsing
- **ajv**: ^8.12.0 - JSON Schema validation
- **TypeScript**: ^5.0.0 - Type-safe development

### Architecture Decisions
1. **Module-level diagnostics collection**: Initialized in activate() and disposed in deactivate()
2. **Per-document clearing**: Prevents clearing errors from other files
3. **Line number detection**: Attempts to find actual error locations in YAML
4. **Pattern-based auto-validation**: Only validates files matching DevOps patterns

## Quality Assurance

### Testing Results
✅ TypeScript compilation successful
✅ ESLint passes with no errors
✅ Validation tests pass (6 error types detected)
✅ npm audit: 0 vulnerabilities
✅ CodeQL: 0 security issues

### Code Review
All code review feedback addressed:
- Fixed diagnostics collection lifecycle
- Improved error positioning
- Per-document diagnostics clearing

## Usage Example

```typescript
// 1. User runs: "DevOps PowerTools: Scaffold YAML File"
// 2. Extension creates file with template:

name: my-application
version: 1.0.0
environment: development

services:
- name: web-service
port: 8080
replicas: 2

database:
type: postgresql
host: localhost
port: 5432

// 3. User saves file
// 4. Extension validates automatically
// 5. Errors appear in Problems panel if any
```

## Schema Validation Examples

### Valid Properties
```yaml
version: "1.2.3" # ✓ Matches semver pattern
environment: "production" # ✓ Valid enum value
port: 8080 # ✓ Within range 1-65535
```

### Invalid Properties (Detected)
```yaml
version: "invalid" # ✗ Must match pattern ^\d+\.\d+\.\d+$
environment: "testing" # ✗ Must be development/staging/production
port: 99999 # ✗ Must be <= 65535
replicas: -1 # ✗ Must be >= 1
```

## Files Structure

```
devops-powertools/
├── .devops-schema.json # Default JSON schema
├── .eslintrc.js # ESLint config
├── .vscode/ # VSCode settings
│ ├── launch.json # Debug config
│ └── tasks.json # Build tasks
├── .vscodeignore # VSIX exclusions
├── CHANGELOG.md # Version history
├── QUICKSTART.md # Quick start guide
├── README.md # Main docs
├── USAGE.md # Detailed guide
├── example-config.yaml # Valid example
├── invalid-example.yaml # Invalid example
├── package.json # Extension manifest
├── src/
│ └── extension.ts # Main extension code
├── test-validation.js # Test script
└── tsconfig.json # TypeScript config
```

## Installation & Usage

### For Development
```bash
npm install
npm run compile
# Press F5 in VSCode to test
```

### For Production
```bash
npm install -g vsce
vsce package
# Install generated .vsix in VSCode
```

## Future Enhancement Opportunities

1. **Enhanced Line Detection**: Use YAML parser with position tracking
2. **Quick Fixes**: Provide code actions to auto-fix common errors
3. **Schema Editor**: Visual schema editor for non-technical users
4. **Templates**: Multiple template options for different app types
5. **Snippets**: YAML snippets for common patterns
6. **Import/Export**: Schema import from OpenAPI/Swagger

## Conclusion

Successfully delivered a complete, production-ready VSCode extension that meets all requirements:
- ✅ Scaffolds YAML files with custom schema
- ✅ Validates schema files in current project
- ✅ Provides excellent developer experience
- ✅ Well-documented and tested
- ✅ No security vulnerabilities
- ✅ Follows VSCode extension best practices

The extension is ready for use and can be published to the VSCode marketplace or distributed as a VSIX package.
Loading