or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-10/

Commit Type Configuration Manager

Overview

Build a tool that manages custom commit types for a team's Git workflow. The tool should allow teams to define their own commit types beyond the standard conventional commit types, configure their display properties, and validate commit messages against these custom types.

Requirements

1. Type Configuration System

Create a configuration system that allows users to:

  • Define custom commit types with unique identifiers and display names
  • Optionally associate emoji icons with each type
  • Store multiple custom types in a configuration structure
  • Support both adding new types and completely replacing the default type list

2. Type Validation

Implement validation logic that:

  • Checks if a commit message starts with a valid commit type
  • Extracts the type from a commit message in the format type(scope): subject or type: subject
  • Returns validation results indicating whether the type is valid
  • Provides helpful error messages for invalid types

3. Type Display

Create a display function that:

  • Shows all available commit types in a readable format
  • Includes the type value, display name, and emoji (if configured)
  • Formats the output for terminal display

4. Configuration Loading

Implement a configuration loader that:

  • Reads type configurations from a JavaScript object or JSON structure
  • Merges custom types with default types when needed
  • Handles missing or invalid configuration gracefully

Implementation Details

Your solution should include:

  1. A TypeConfig interface or type definition that represents a single commit type with:

    • value: The type identifier (e.g., "feat", "fix")
    • name: Human-readable description
    • emoji: Optional emoji icon
  2. A loadTypeConfig function that accepts configuration and returns a list of available types

  3. A validateCommitType function that checks if a commit message uses a valid type

  4. A displayTypes function that formats and returns a string showing all available types

Test Cases

Test 1: Loading Custom Types { .test-case @test }

Input:

const config = {
  typesAppend: [
    { value: "workflow", name: "workflow: CI/CD changes", emoji: "🔄" },
    { value: "security", name: "security: Security fixes", emoji: "🔒" }
  ]
}

Expected Behavior: The loader should merge these custom types with the default conventional commit types (feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert), resulting in a total of 13 available types.

Test 2: Validating Commit Messages { .test-case @test }

Input:

validateCommitType("workflow(ci): add GitHub Actions config")
validateCommitType("invalid: some message")
validateCommitType("feat: add new feature")

Expected Output:

  • First message: valid (assuming "workflow" is a custom type)
  • Second message: invalid (assuming "invalid" is not a configured type)
  • Third message: valid (assuming "feat" is available)

Test 3: Displaying Types { .test-case @test }

Input:

const types = [
  { value: "feat", name: "feat: A new feature", emoji: "✨" },
  { value: "fix", name: "fix: A bug fix", emoji: "🐛" }
]
displayTypes(types)

Expected Output: Should return a formatted string showing each type with its emoji and description, suitable for terminal display.

Dependencies { .dependencies }

cz-git { .dependency }

Provides commit message generation and type management capabilities for Git workflows.

Testing

Create a test file named type-manager.test.ts that validates:

  • Custom type loading and merging
  • Commit message type validation
  • Type display formatting
  • Error handling for invalid configurations