Skip to content

Environment Management Module #4

@acreeger

Description

@acreeger

Port .env file manipulation functionality from bash scripts.

Key Files to Create:

  • src/lib/EnvironmentManager.ts
  • src/utils/env.ts

Functions to Port:

  • setEnvVar() from env-utils.sh
  • Port assignment logic (3000 + issue/PR number)
  • .env file copying between worktrees

Features:

  • Read/write/update .env files
  • Set environment variables in target file
  • Copy .env files between directories
  • Calculate and assign unique ports
  • Validate environment configurations

Logging Integration:

Testing Requirements:

  • Unit tests for .env file parsing and manipulation
  • File system mocking for atomic file operations
  • Property-based tests for environment variable validation
  • Port calculation tests including conflict detection
  • Environment variable validation tests
  • Cross-platform file handling tests
  • Concurrent access and file locking tests
  • Backup and recovery mechanism tests

Acceptance Criteria:

  • .env file manipulation works identically to bash scripts verified through regression tests
  • Atomic file updates tested with concurrency scenarios
  • Port calculation matches existing logic with comprehensive test coverage
  • Proper error handling for file operations tested extensively
  • File system mock factory working for all scenarios
  • Property-based tests revealing no edge cases
  • Cross-platform compatibility validated through testing
  • Logging integration working

Enhancement Summary: Integrated structured logging using logger utility (see Issue #27).

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreCore functionalityenhancementNew feature or requestphase-1Phase 1: Core Foundation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions