Skip to content

Commit 8c7ad19

Browse files
committed
feat: add validate and fix command for task management
- Introduced `ValidateAndFixCommand` for validating tasks and applying automatic fixes. - Implemented `ValidateTasksCommand` for validating all tasks against the schema. - Enhanced date, owner, priority, and status fixers to return updated task objects. - Added unit tests for array and date helper functions. - Refactored environment variable access with `EnvironmentAccessor` interface. - Improved task validation services and context handling. - Updated task-related types to include priority and validation options. - Cleaned up imports and ensured consistent code structure across modules.
1 parent 8e5ce9d commit 8c7ad19

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+382
-261
lines changed

src/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
import { Command } from 'commander';
33
import pino from 'pino';
44

5+
import { ConsoleOutputWriter } from './core/rendering/console-output.writer';
56
import { getLogger } from './core/system/logger';
67
import { ObservabilityLogger } from './core/system/observability.logger';
7-
import { CommandFactory } from './commands/shared/command.factory';
88
import { EXIT_CODES } from './types/core';
9-
import { ConsoleOutputWriter } from './core/rendering/console-output.writer';
9+
import { CommandFactory } from './commands/command.factory';
1010

1111
/**
1212
* Main CLI entry point for the Documentation-Driven Development toolkit.

src/commands/task-management/add-task.command.test.ts renamed to src/commands/add-task.command.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { Command } from 'commander';
22

3-
import { ILogger } from '../../types/observability';
4-
import { TaskManager } from '../../core/storage/task.manager';
5-
import { AddTaskArgs } from '../../types/tasks';
6-
import { EXIT_CODES } from '../../types/core';
7-
import { IOutputWriter } from '../../types/rendering';
8-
import { CommandName } from '../../types';
3+
import { TaskManager } from '../core/storage';
4+
import { AddTaskArgs, CommandName, EXIT_CODES, ILogger, IOutputWriter } from '../types';
95

106
import { AddTaskCommand } from './add-task.command';
117

src/commands/task-management/add-task.command.ts renamed to src/commands/add-task.command.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { Command } from 'commander';
22

3-
import { ConsoleOutputWriter } from '../../core/rendering';
4-
import { TaskManager } from '../../core/storage';
5-
import { CommandName, ILogger, IOutputWriter, AddTaskArgs, EXIT_CODES } from '../../types';
6-
import { BaseCommand } from '../shared/base.command';
3+
import { ConsoleOutputWriter } from '../core/rendering';
4+
import { TaskManager } from '../core/storage';
5+
import { AddTaskArgs, CommandName, EXIT_CODES, ILogger, IOutputWriter } from '../types';
6+
7+
import { BaseCommand } from './base.command';
78

89
/**
910
* Command for adding a new task from a file to the TODO.md.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ILogger, IOutputWriter } from '../../types';
1+
import { ILogger, IOutputWriter } from '../types';
22

33
import { BaseCommand } from './base.command';
44

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ConsoleOutputWriter } from '../../core/rendering';
2-
import { ICommand, ILogger, IOutputWriter } from '../../types';
1+
import { ConsoleOutputWriter } from '../core/rendering';
2+
import { ICommand, ILogger, IOutputWriter } from '../types';
33

44
export abstract class BaseCommand implements ICommand {
55
abstract name: string;

src/commands/shared/command.factory.test.ts renamed to src/commands/command.factory.test.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
import { Command } from 'commander';
22

3-
import { ILogger } from '../../types/observability';
4-
import { AddTaskCommand } from '../task-management/add-task.command';
5-
import { CompleteTaskCommand } from '../task-management/complete-task.command';
6-
import { ListTasksCommand } from '../task-management/list-tasks.command';
7-
import { ShowTaskCommand } from '../task-management/show-task.command';
8-
import { ValidateAndFixCommand } from '../validation/validate-and-fix.command';
9-
import { ValidateTasksCommand } from '../validation/validate-tasks.command';
10-
import { NextCommand } from '../rendering/next.command';
11-
import { RenderCommand } from '../rendering/render.command';
12-
import { RefAuditCommand } from '../audit/ref-audit.command';
13-
import { SupersedeCommand } from '../audit/supersede.command';
14-
import { IOutputWriter } from '../../types/rendering';
3+
import { ILogger, IOutputWriter } from '../types';
154

5+
import { AddTaskCommand } from './add-task.command';
166
import { CommandFactory } from './command.factory';
7+
import { CompleteTaskCommand } from './complete-task.command';
8+
import { ListTasksCommand } from './list-tasks.command';
9+
import { NextCommand } from './next.command';
10+
import { RefAuditCommand } from './ref-audit.command';
11+
import { RenderCommand } from './render.command';
12+
import { ShowTaskCommand } from './show-task.command';
13+
import { SupersedeCommand } from './supersede.command';
14+
import { ValidateAndFixCommand } from './validate-and-fix.command';
15+
import { ValidateTasksCommand } from './validate-tasks.command';
1716

1817
// Mock chalk to handle ES module import issues
1918
jest.mock('chalk', () => ({
Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import { Command } from 'commander';
22

3-
import { ILogger, IOutputWriter } from '../../types';
4-
import { RefAuditCommand } from '../audit/ref-audit.command';
5-
import { SupersedeCommand } from '../audit/supersede.command';
6-
import { NextCommand } from '../rendering/next.command';
7-
import { RenderCommand } from '../rendering/render.command';
8-
import { AddTaskCommand } from '../task-management/add-task.command';
9-
import { CompleteTaskCommand } from '../task-management/complete-task.command';
10-
import { ListTasksCommand } from '../task-management/list-tasks.command';
11-
import { ShowTaskCommand } from '../task-management/show-task.command';
12-
import { ValidateAndFixCommand } from '../validation/validate-and-fix.command';
13-
import { ValidateTasksCommand } from '../validation/validate-tasks.command';
3+
import { ILogger, IOutputWriter } from '../types';
4+
5+
import { AddTaskCommand } from './add-task.command';
6+
import { CompleteTaskCommand } from './complete-task.command';
7+
import { ListTasksCommand } from './list-tasks.command';
8+
import { NextCommand } from './next.command';
9+
import { RefAuditCommand } from './ref-audit.command';
10+
import { RenderCommand } from './render.command';
11+
import { ShowTaskCommand } from './show-task.command';
12+
import { SupersedeCommand } from './supersede.command';
13+
import { ValidateAndFixCommand } from './validate-and-fix.command';
14+
import { ValidateTasksCommand } from './validate-tasks.command';
1415

1516
/**
1617
* Factory for creating and configuring CLI commands following Command pattern.

src/commands/task-management/complete-task.command.ts renamed to src/commands/complete-task.command.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { Command } from 'commander';
22

3-
import { ConsoleOutputWriter } from '../../core/rendering';
4-
import { TaskManager } from '../../core/storage';
3+
import { ConsoleOutputWriter } from '../core/rendering';
4+
import { TaskManager } from '../core/storage';
55
import {
6-
ICommand,
76
CommandName,
8-
ILogger,
9-
IOutputWriter,
107
CompleteTaskArgs,
118
CompleteTaskOptions,
129
EXIT_CODES,
13-
} from '../../types';
10+
ICommand,
11+
ILogger,
12+
IOutputWriter,
13+
} from '../types';
1414

1515
/**
1616
* Command for completing a task by removing it

src/commands/task-management/list-tasks.command.ts renamed to src/commands/list-tasks.command.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Command } from 'commander';
22

3-
import { TaskManager } from '../../core/storage';
4-
import { CommandName, ILogger, IOutputWriter } from '../../types';
5-
import { BaseCommand } from '../shared/base.command';
3+
import { TaskManager } from '../core/storage';
4+
import { CommandName, ILogger, IOutputWriter } from '../types';
5+
6+
import { BaseCommand } from './base.command';
67

78
/**
89
* Modern command for listing all tasks from the TODO.md file.

src/commands/rendering/next.command.telemetry.test.ts renamed to src/commands/next.command.telemetry.test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
/* eslint-disable no-undefined */
2-
import { CommandName } from '../../types';
3-
import { IObservabilityLogger } from '../../types/observability';
4-
import { IHydrationOptions, TaskProviderType } from '../../types/tasks';
2+
import {
3+
CommandName,
4+
IHydrationOptions,
5+
IObservabilityLogger,
6+
OperationContext,
7+
TaskProviderType,
8+
} from '../types';
59

6-
import { NextCommandTelemetry, OperationContext } from './next.command.telemetry';
10+
import { NextCommandTelemetry } from './next.command.telemetry';
711

812
describe('NextCommandTelemetry', () => {
913
let telemetry: NextCommandTelemetry;

0 commit comments

Comments
 (0)