Skip to content

Conversation

@DavidWells
Copy link
Owner

Add comprehensive JSDoc type annotations and TypeScript declaration generation to the util-fs package.

Changes

  • Add JSDoc type annotations to all exported functions
  • Create tsconfig.json configured for declaration-only output
  • Add TypeScript and Node.js types as devDependencies
  • Add 'types' npm script that runs tsc
  • Generate TypeScript declarations in types/index.d.ts

Closes #6

Generated with Claude Code

- Add comprehensive JSDoc type annotations to all exported functions
- Create tsconfig.json configured for declaration-only output  
- Add TypeScript and Node.js types as devDependencies
- Add 'types' npm script that runs tsc to emit TypeScript declarations
- Generate TypeScript declarations in types/index.d.ts

Closes #6

Co-authored-by: DavidWells <DavidWells@users.noreply.github.com>
@DavidWells
Copy link
Owner Author

Looks good!

now we need to add tests for all the functions we export from this library

setup tests using the uvu npm package and verify that our FS calls work as intended @claude

@claude
Copy link
Contributor

claude bot commented Jun 14, 2025

Claude finished @DavidWells's task in 2m 52s —— View job


Setting up tests for util-fs package ✅

I've successfully added comprehensive tests using uvu for all the functions exported from the util-fs package.

Todo List:

  • Read current util-fs package files to understand exported functions
  • Check for repository-specific guidelines (CLAUDE.md)
  • Add uvu and related testing dependencies
  • Create test files with comprehensive coverage
  • Add test script to package.json
  • Commit all changes

Functions tested:

fileExists - Check if file exists
writeFile - Write file (from fs.promises)
readFile - Read file (from fs.promises)
copyFile - Copy file (from fs.promises)
deleteFile - Delete file with ENOENT handling
directoryExists - Check if directory exists (alias for fileExists)
createDir - Create directory recursively
readDir - Read directory contents recursively with exclude options
copyDir - Copy directory recursively
deleteDir - Delete directory recursively
getFileSize - Get file size in bytes and MB

Test coverage includes:

  • File and directory existence checks
  • File read/write operations with text and binary data
  • File and directory copying (recursive and non-recursive)
  • File and directory deletion with error handling
  • Directory reading with filtering options (string and regex patterns)
  • File size calculations
  • Edge cases like non-existent files, empty files, nested directories
  • Error handling for ENOENT cases

Changes made:

  1. Added uvu dependency to package.json devDependencies
  2. Added test script (npm run test) to run uvu tests
  3. Created comprehensive test suite at tests/index.test.js with 20+ test cases
  4. Committed changes to the PR branch

The test suite is ready to run with npm test and covers all exported functions with proper setup/teardown and edge case handling.


- Add uvu testing framework as dev dependency
- Add test script to package.json
- Create comprehensive test suite covering all exported functions:
  - fileExists and directoryExists
  - writeFile, readFile, copyFile, deleteFile
  - createDir, readDir, copyDir, deleteDir
  - getFileSize with bytes and MB calculations
- Include tests for edge cases and error handling
- Test recursive operations and filtering options
- Verify ENOENT error handling in deleteFile

Co-authored-by: DavidWells <DavidWells@users.noreply.github.com>
@DavidWells
Copy link
Owner Author

@claude run the tests to verify they work

@claude
Copy link
Contributor

claude bot commented Jun 16, 2025

Claude finished @DavidWells's task in 2m 6s —— View job


Running tests for util-fs package ✅

Todo List:

  • Read util-fs package.json to understand test configuration
  • Navigate to util-fs directory and install dependencies
  • Run the test suite using npm test
  • Analyze test results and report status
  • Fix any issues if tests fail

Test Results:

All 23 tests now pass!

Issue Found and Fixed:

The getFileSize test was initially failing because:

  • Test used 1000 bytes as test data
  • 1000 bytes = 0.00095367 MB
  • When rounded to 2 decimal places → 0.00 MB
  • Assertion size.mb > 0 failed since 0.00 is not > 0

Solution Applied:

  • Updated test to use 100,000 bytes (~0.1 MB) instead
  • This ensures the MB value is > 0 after rounding
  • All tests now pass successfully

Final Status:

  • Total Tests: 23
  • Passed: 23 ✅
  • Failed: 0
  • Duration: 21.48ms
  • Test Coverage: All exported functions tested comprehensively

The util-fs package test suite is working perfectly and ready for production use!


…lculation

The test was failing because 1000 bytes rounds to 0.00 MB when rounded to 2 decimal places, 
making the assertion `size.mb > 0` fail. Updated to use 100000 bytes (~0.1 MB) instead.

Co-authored-by: DavidWells <DavidWells@users.noreply.github.com>
@DavidWells
Copy link
Owner Author

ok great make sure the JSdocs are still correct and add information about the fs utilities available in the README.md of this package

Also rebase this on master if you need to so we can finally merge this

thanks @claude

@github-actions
Copy link
Contributor

github-actions bot commented Nov 10, 2025

💬 Claude Code execution complete

📊 Execution Info: Pull Request #7 | React (271 files) | @DavidWells
🌿 Branch: claude/issue-6-20250614_221129master
ℹ️ Action Run: https://github.com/DavidWells/packages/actions/runs/19240469540

@github-actions
Copy link
Contributor

github-actions bot commented Nov 10, 2025

Claude finished @DavidWells's task —— View job


Finalized util-fs package documentation ✅

I've successfully updated the JSDoc annotations and created comprehensive README documentation for the util-fs package.

Completed Tasks:

  • Reviewed and verified JSDoc annotations
  • Added proper JSDoc type annotations for writeFile, readFile, and copyFile re-exports
  • Created comprehensive README.md with full API documentation
  • Documented all 11 exported functions with parameters, return types, and examples
  • Added usage examples for common scenarios
  • Included TypeScript support information
  • Committed and pushed all changes

Changes Made:

1. Enhanced JSDoc (index.js)

  • Added proper type annotations for the three Node.js fs.promises re-exports:
    • writeFile - Write data to a file
    • readFile - Read data from a file
    • copyFile - Copy a file from source to destination
  • All functions now have complete JSDoc documentation

2. Comprehensive README.md
Created detailed documentation including:

  • Quick start and installation guide
  • Feature highlights (Promise-based API, TypeScript support, recursive operations, pattern filtering)
  • Complete API reference with 11 functions:
    • File Operations: fileExists, readFile, writeFile, copyFile, deleteFile, getFileSize
    • Directory Operations: directoryExists, createDir, readDir, copyDir, deleteDir
  • Code examples for each function
  • TypeScript usage examples
  • Testing information

⚠️ Rebase Requirement

I've detected that the master branch has 28 commits ahead of this PR branch. The branch needs to be rebased before merging, but I cannot perform git rebase operations automatically due to my limitations.

To rebase this PR on master, you'll need to run:

git checkout claude/issue-6-20250614_221129
git rebase origin/master
# Resolve any conflicts if they arise
git push --force-with-lease origin claude/issue-6-20250614_221129

Alternatively, GitHub can handle the merge if you're comfortable with a merge commit instead of a rebase.

Summary

✅ JSDoc annotations are complete and accurate
✅ README.md provides comprehensive documentation for all utilities
✅ All changes committed and pushed to this PR branch
⚠️ Manual rebase needed before merge (or use merge commit)

The PR is now ready for final review and merging!

--- |

- Add proper JSDoc type annotations for writeFile, readFile, and copyFile
- Create comprehensive README.md with detailed API documentation
- Document all 11 exported functions with parameters, return types, and examples
- Add usage examples for common scenarios
- Include TypeScript support information
- Add testing section

Co-authored-by: David Wells <DavidWells@users.noreply.github.com>
@github-actions github-actions bot added auto-generated Automatically generated content claude-code Items created or modified by Claude Code labels Nov 10, 2025
@DavidWells DavidWells merged commit fa960fa into master Nov 10, 2025
@DavidWells DavidWells deleted the claude/issue-6-20250614_221129 branch November 10, 2025 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-generated Automatically generated content claude-code Items created or modified by Claude Code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add JSDoc types to fs-utils

2 participants