-
Notifications
You must be signed in to change notification settings - Fork 0
Release v1.1.0: Grep Format for Automated Link Fixing #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add branch filter to workflow trigger (only main branch) - Add verification step to check tag is on main branch - Fetch full git history for branch verification - Prevents accidental releases from feature/develop branches This ensures npm releases only happen from the main branch, protecting against accidental releases from other branches.
Add literal link text and resolved path reporting to mdite lint errors,
enabling automated fix scripts with grep/sed without reverse-engineering paths.
## What Changed
### Error Type Enhancement
- Extended LintError interface with three new optional fields:
- literal: The literal link text from source files (e.g., '../../../docs/file.md')
- endColumn: End column position for range extraction
- resolvedPath: Resolved path relative to basePath (e.g., 'features/docs/file.md')
- All fields optional for backward compatibility
### Link Validator Updates
- Capture literal text and position from markdown AST (remark/unified)
- Create complete error messages at source: "Dead link: 'literal' resolves to 'resolved'"
- Pass literal, endColumn, resolvedPath to all error objects
- Applies to dead-link, dead-anchor, and external-link errors
### Reporter Enhancements
- Text format: Shows 'literal' resolves to 'resolved' inline (uses error.message directly)
- JSON format: Includes literal, endColumn, resolvedPath fields (flat structure)
- **NEW grep format**: Tab-delimited output for Unix tool parsing
- Field order: file, line, column, endColumn, severity, ruleId, literal, resolvedPath
- Parseable with cut/awk/sed for automated fixes
- Example: `mdite lint --format grep | cut -d$'\t' -f7` extracts all literal paths
- Clean architecture: LinkValidator creates messages, Reporter presents them (no parsing)
### CLI Updates
- Added 'grep' as valid format option: --format text|json|grep
- Auto-disables colors for grep format (machine-readable)
### Testing
- Added 11 new integration tests (tests/integration/lint-literal-paths.test.ts)
- Text format literal display
- JSON format field structure
- Grep format tab-delimited parsing
- Backward compatibility
- Complex scenarios (multiple errors, anchors)
- Fixed 1 existing test updated for new format
- All 625 tests passing (614 existing + 11 new)
- All 38 smoke tests passing
### Documentation
- Updated CHANGELOG.md with feature details and examples
- Added README.md workflow 7: "Automated Link Fixing with Grep Format"
- Updated lint command documentation with grep format examples
## Use Cases
**Automated fix scripts**:
```bash
# Extract all literal paths
mdite lint --format grep | cut -d$'\t' -f7
# Process dead links
mdite lint --format grep | awk -F'\t' '$6=="dead-link" {print $1, $7}'
# Automated fix workflow
mdite lint --format grep | while IFS=$'\t' read file line col endCol severity rule literal resolved; do
if [ "$rule" = "dead-link" ]; then
sed -i "${line}s|$literal|correct-path|" "$file"
fi
done
```
## Architecture
Clean separation of concerns achieved through iterative refinement:
1. LinkValidator creates complete error messages with literal/resolved at source
2. Reporter presents messages without any parsing or manipulation
3. Error type carries all necessary fields (literal, resolvedPath, endColumn)
4. All formats use error object fields directly (no regex, no brittleness)
## Breaking Changes
None - all new fields are optional and formats are additive.
…ands - Add CLI help text standards section to CONTRIBUTING.md • Documents hybrid architecture (shared vs command-specific) • Provides templates for DESCRIPTION, EXAMPLES, OUTPUT, SEE_ALSO • Includes formatting guidelines and checklists • References industry best practices (git, docker, npm, ripgrep) - Enhance help text across all commands • Add detailed OUTPUT sections (8-10 bullets each) • Improve SEE_ALSO organization (Core workflow, Configuration, Global tiers) • Standardize cross-references between related commands - Improve shared help text (help-text.ts) • Expand ENVIRONMENT_VARS with detailed descriptions • Add context for NO_COLOR, FORCE_COLOR, CI usage • Document precedence and equivalents - Update tests to match new help structure • Fix JMESPath reference check for new External tier • Maintain all existing coverage
The .npmignore file was redundant because the 'files' field in package.json takes absolute precedence according to npm documentation. When a 'files' field is present, .npmignore is completely ignored. This change: - Eliminates technical debt and maintainer confusion - Establishes package.json 'files' as single source of truth - No impact on package contents (verified with npm pack --dry-run) Package size remains: 87.6 kB Files included remain unchanged: dist/src/, README.md, CHANGELOG.md, LICENSE Resolves: scratch/release-ready-20251104-140123/ISSUE-npmignore-conflicts-with-files.md
- Move unreleased changes to v1.1.0 section dated 2025-11-04 - Reorganize from "Enhanced" to proper "Added" section - Add grep format as headline feature (new machine-parseable output) - Document literal path error reporting enhancements - Include CLI help system improvements across all commands - Add Fixed section for CI/CD branch restriction - Add Changed section for .npmignore removal - Comprehensive release notes covering all 5 commits since v1.0.2
- Replace 5 instances of `any` type with proper `LintError` type - Add import for LintError interface - Improves type safety and eliminates ESLint warnings
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Release v1.1.0: Grep Format for Automated Link Fixing
Summary
This release introduces the new grep format for
mdite lint, enabling automated link fixing workflows with standard Unix tools. The format provides tab-delimited output that can be parsed with cut, awk, and sed to programmatically fix broken links without manual intervention or path reverse-engineering.Key Improvements
--format grepoption for machine-parseable, tab-delimited outputWhat's Changed
Added
🆕 Grep Format for Lint Output
New
--format grepoption provides machine-parseable, tab-delimited output for automated link fixing.Format specification:
\t)Example usage:
Impact: Users can now build automated scripts to fix broken links using standard Unix tools, without needing to parse human-readable error messages or reverse-engineer file paths.
CLI changes:
--format text|json|grepsrc/commands/lint.ts🔍 Literal Path Error Reporting
Enhanced error reporting that captures and reports literal link text exactly as written in source files.
What changed:
LintErrorinterface with three new optional fields:literal: The literal link text from source (e.g.,'../../../docs/file.md')endColumn: End column position for range extractionresolvedPath: Resolved path relative to basePath (e.g.,'features/docs/file.md')'literal' resolves to 'resolved'inline for clarityImpact: Error messages now provide both the literal text (for automated fixes) and the resolved path (for human understanding), eliminating the need to reverse-engineer paths from error messages.
Modified files:
src/types/errors.ts- Extended LintError interfacesrc/core/link-validator.ts- Capture literal text and position from ASTsrc/core/reporter.ts- Format grep output, enhanced text/JSON formatsREADME.md- Added "Automated Link Fixing with Grep Format" workflow sectionTesting:
tests/integration/lint-literal-paths.test.ts📖 Enhanced CLI Help System
Comprehensive help documentation following Unix CLI best practices from git, docker, npm, and ripgrep.
What changed:
src/utils/help-text.ts:Modified files (9 files, 403 insertions):
CONTRIBUTING.md- New standards sectionsrc/commands/*.ts- All 6 command files enhancedsrc/utils/help-text.ts- Expanded shared helptests/integration/cli-help.test.ts- Updated testsImpact: Developers can discover features and usage patterns directly from
--helpoutput without consulting external documentation. Help text is now comprehensive, consistent, and follows industry best practices.Fixed
🔒 CI/CD: Release Workflow Restricted to Main Branch
Security improvement prevents accidental releases from feature or develop branches.
What changed:
mainbranch)Impact: npm releases can only happen from the main branch, eliminating risk of publishing pre-release or development code.
Modified:
.github/workflows/release.ymlChanged
📦 Package Publishing: Removed Redundant .npmignore
Technical debt cleanup - removed .npmignore file that was overridden by package.json.
What changed:
.npmignorefile completelyfilesfield is now the single source of truth (per npm documentation)Impact: Eliminates maintainer confusion about which file controls package contents. No functional change - package contents and size remain identical (87.6 kB).
Verification:
npm pack --dry-runconfirms unchanged package contentsBreaking Changes
None - This release is fully backward compatible:
Testing
Documentation Updates
Commits
aec6bae- chore: remove redundant .npmignore (files field takes precedence)38da5b0- docs(help): add comprehensive CLI help standards and enhance all commandsb03c970- feat(lint): add literal path error reporting with grep format ⭐ NEW FORMAT763790d- fix(ci): restrict release workflow to main branch only0e6bef6- fix: eliminate timing flakiness in delay test (merged from v1.0.2)Migration Guide
No migration needed - this release is fully backward compatible.
To use new features: