Skip to content

Conversation

@Mearman
Copy link
Member

@Mearman Mearman commented Jun 10, 2025

Summary

This PR implements a comprehensive programmatic API for markmv, adding TypeDoc documentation and enhancing CLI functionality with directory and glob support.

🚀 New Features

Programmatic API:

  • Complete library exports via src/index.ts with TypeScript support
  • Convenience functions: createMarkMv(), moveFile(), moveFiles(), validateOperation()
  • Proper package.json exports configuration for ESM/CommonJS compatibility

Enhanced CLI:

  • Directory move support: markmv move file.md ../target/
  • Full glob pattern support: markmv move '**/*.md' ./archive/
  • Intelligent destination resolution (preserves filenames when moving to directories)

TypeDoc Documentation:

  • Comprehensive JSDoc comments across core classes
  • Custom TypeDoc configuration with GitHub integration
  • Automated documentation deployment via GitHub Actions
  • Enhanced styling with custom CSS theme

🔧 Technical Improvements

  • Added extensive test coverage (40+ new tests for glob and directory functionality)
  • Resolved all linting and TypeScript compilation issues
  • Applied consistent code formatting with Biome
  • Maintained 100% backward compatibility with existing CLI

✅ Test Coverage

  • 245 tests passing across Node.js 18.x, 20.x, and 22.x
  • Comprehensive glob pattern testing (simple, recursive, multiple patterns)
  • Directory move validation and error handling
  • Programmatic API integration tests

📚 Documentation

  • Live API documentation will be available at: https://exadev.github.io/markmv/
  • Enhanced README with programmatic usage examples
  • Complete TypeScript type definitions and examples

🔄 Migration

No breaking changes - this is a purely additive release that enhances existing functionality while maintaining full CLI compatibility.

Test Plan

  • All existing tests pass (245/245)
  • New glob functionality tested with comprehensive test suite
  • Directory move operations validated
  • Programmatic API tested with TypeScript examples
  • CI/CD pipeline validates across multiple Node.js versions
  • Documentation generation tested locally and in CI

Related Issues

Closes programmatic API implementation requirements and completes TypeDoc documentation phase.

Mearman and others added 12 commits June 10, 2025 16:16
- Add src/index.ts with full library exports and convenience functions
- Export all core classes: FileOperations, LinkParser, LinkRefactorer, etc.
- Export all strategy classes and utility functions
- Export comprehensive TypeScript types for all operations
- Add createMarkMv() factory function for easy instantiation
- Add moveFile() and moveFiles() convenience functions
- Add validateOperation() helper for result validation
- Fix empty moves array handling in FileOperations.moveFiles()
- Add proper package.json exports configuration with types
- Create comprehensive test suite for programmatic API (14 tests)
- Add JavaScript and TypeScript usage examples
- Update package.json keywords for better discoverability
- Include examples in published package files

This enables developers to use markmv as a library:
import { createMarkMv, moveFile, FileOperations } from 'markmv';

Breaking changes: None - maintains full backward compatibility
- Add PathUtils.resolveDestination() to handle directory destinations
- Add PathUtils.isDirectory() and PathUtils.looksLikeDirectory() helpers
- Update FileOperations.moveFile() to resolve directory destinations
- Update FileOperations.moveFiles() to handle batch directory moves
- Fix empty moves array handling in moveFiles() method
- Add comprehensive test suite (16 tests) for directory move support
- Support CLI patterns: 'markmv move file.md dir/' and 'markmv move file.md dir'
- Support programmatic API: moveFile('file.md', './target/')

Examples now supported:
- markmv move foo.md ../          (preserves filename: ../foo.md)
- markmv move doc.md ./docs/      (creates: ./docs/doc.md)
- moveFile('test.md', targetDir)  (API support)

All 234 tests passing, maintains full backward compatibility
- Support multiple source files: markmv move file1.md file2.md ./target/
- Support glob patterns: markmv move '*.md' ./target/
- Support recursive globs: markmv move '**/*.md' ./archive/
- Support mixed patterns: markmv move file.md 'docs/*.md' ./target/
- Add intelligent destination validation for batch moves
- Add comprehensive glob expansion with markdown file filtering
- Add proper error handling for invalid destination types
- Add verbose output showing pattern expansion and file discovery
- Add 11 comprehensive tests for glob functionality
- Maintain full backward compatibility with single file moves

Examples now supported:
- markmv move '*.md' ./archive/           # Simple glob
- markmv move '**/*.md' ./archive/        # Recursive glob
- markmv move docs/*.md guides/*.md ./archive/  # Multiple patterns
- markmv move file1.md 'src/**/*.md' ./backup/ # Mixed patterns

All 245 tests passing, zero regressions
- Add TypeDoc v0.28.5 and missing exports plugin v4.0.0 as dev dependencies
- Add npm scripts for documentation: docs, docs:serve, docs:watch
- Prepare foundation for comprehensive API documentation
- Add typedoc.json with GitHub integration and categorized output
- Configure source linking to GitHub repository with line numbers
- Add custom CSS theme for enhanced documentation styling
- Enable missing exports plugin for complete API coverage
- Set up validation and search capabilities
- Add detailed class-level documentation with usage examples
- Document FileOperations with move operation examples and dry run patterns
- Document LinkParser with parsing and validation examples
- Document PathUtils with path resolution and relative path update examples
- Include category annotations for TypeDoc organization
- Provide practical code examples for each major method
- Create automated docs.yml workflow for TypeDoc generation
- Configure build job with Node.js 18 and npm ci installation
- Set up GitHub Pages deployment with proper permissions
- Deploy documentation to GitHub Pages on main branch pushes
- Include build artifact upload for GitHub Pages integration
- Exclude TypeDoc generated documentation from version control
- Prevent committing build artifacts that are deployed via GitHub Actions
- Keep repository clean by ignoring generated HTML documentation files
- Add Library Usage section with programmatic API examples
- Include TypeScript code examples for FileOperations, moveFile, and glob patterns
- Update Getting Help section with link to hosted API documentation
- Replace generic documentation links with specific TypeDoc documentation URL
- Provide practical examples for dry runs, directory moves, and validation
- Replace forEach with for...of loop for better performance
- Add explicit type annotation to result variable to prevent implicit any
- Maintain code quality standards with Biome linter
- Import OperationResult type from operations module
- Resolve TypeScript compilation error
- Ensure proper type checking for result variable
Copilot AI review requested due to automatic review settings June 10, 2025 17:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Implements a full programmatic API for markmv with TypeDoc docs and enhances the CLI to support directories and glob patterns.

  • Adds typedoc.json and a custom CSS theme for automated API documentation.
  • Introduces PathUtils helpers and exports a createMarkMv, moveFile, moveFiles, and validateOperation API in src/index.ts.
  • Updates FileOperations and the move command to handle directory targets and glob expansions.

Reviewed Changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.

Show a summary per file
File Description
typedoc.json Configures TypeDoc entry points, categories, and validation rules
typedoc-theme.css Defines custom CSS variables and styling for the docs
src/utils/path-utils.ts Adds path resolution and directory-detection utilities
src/core/file-operations.ts Integrates directory support by resolving destinations
src/commands/move.ts Implements glob expansion and batch-move logic for the CLI
src/index.ts Exposes the new programmatic API entry points
Comments suppressed due to low confidence (2)

src/commands/move.ts:26

  • PathUtils.isMarkdownFile is used here but not implemented in PathUtils; either add a static isMarkdownFile method (e.g. checking extname against known markdown extensions) or use the existing FileUtils.isMarkdownFile.
if (PathUtils.isMarkdownFile(pattern)) {

src/core/file-operations.ts:95

  • PathUtils is referenced here but not imported; add import { PathUtils } from '../utils/path-utils.js'; at the top of the file.
const resolvedDestination = PathUtils.resolveDestination(sourcePath, destinationPath);

@Mearman Mearman merged commit 32a76c8 into main Jun 10, 2025
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants