@photostructure/fs-metadata 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/CHANGELOG.md +11 -6
  2. package/CLAUDE.md +160 -136
  3. package/CODE_OF_CONDUCT.md +11 -11
  4. package/CONTRIBUTING.md +2 -2
  5. package/README.md +34 -84
  6. package/binding.gyp +98 -23
  7. package/claude.sh +23 -0
  8. package/dist/index.cjs +53 -22
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +5 -0
  11. package/dist/index.d.mts +5 -0
  12. package/dist/index.d.ts +5 -0
  13. package/dist/index.mjs +52 -21
  14. package/dist/index.mjs.map +1 -1
  15. package/{C++_REVIEW_TODO.md → doc/C++_REVIEW_TODO.md} +97 -25
  16. package/doc/GPG_RELEASE_HOWTO.md +505 -0
  17. package/doc/MACOS_API_REFERENCE.md +469 -0
  18. package/doc/SECURITY_AUDIT_2025.md +809 -0
  19. package/doc/SSH_RELEASE_HOWTO.md +207 -0
  20. package/doc/WINDOWS_API_REFERENCE.md +422 -0
  21. package/doc/WINDOWS_ARM64_SECURITY.md +161 -0
  22. package/doc/WINDOWS_DEBUG_GUIDE.md +96 -0
  23. package/doc/examples.md +267 -0
  24. package/doc/gotchas.md +297 -0
  25. package/doc/logo.png +0 -0
  26. package/doc/logo.svg +85 -0
  27. package/doc/macos-asan-sip-issue.md +71 -0
  28. package/doc/social.png +0 -0
  29. package/doc/social.svg +125 -0
  30. package/doc/windows-build.md +226 -0
  31. package/doc/windows-clang-tidy.md +72 -0
  32. package/doc/windows-memory-testing.md +108 -0
  33. package/doc/windows-prebuildify-arm64.md +232 -0
  34. package/jest.config.cjs +24 -0
  35. package/package.json +68 -44
  36. package/prebuilds/darwin-arm64/@photostructure+fs-metadata.glibc.node +0 -0
  37. package/prebuilds/darwin-x64/@photostructure+fs-metadata.glibc.node +0 -0
  38. package/prebuilds/linux-arm64/@photostructure+fs-metadata.glibc.node +0 -0
  39. package/prebuilds/linux-arm64/@photostructure+fs-metadata.musl.node +0 -0
  40. package/prebuilds/linux-x64/@photostructure+fs-metadata.glibc.node +0 -0
  41. package/prebuilds/linux-x64/@photostructure+fs-metadata.musl.node +0 -0
  42. package/prebuilds/win32-arm64/@photostructure+fs-metadata.glibc.node +0 -0
  43. package/prebuilds/win32-x64/@photostructure+fs-metadata.glibc.node +0 -0
  44. package/scripts/check-memory.ts +186 -0
  45. package/scripts/clang-tidy.ts +832 -0
  46. package/scripts/install.cjs +42 -0
  47. package/scripts/is-platform.mjs +1 -1
  48. package/scripts/macos-asan.sh +155 -0
  49. package/scripts/post-build.mjs +3 -3
  50. package/scripts/prebuild-linux-glibc.sh +119 -0
  51. package/scripts/prebuildify-wrapper.ts +77 -0
  52. package/scripts/precommit.ts +70 -0
  53. package/scripts/sanitizers-test.sh +7 -1
  54. package/scripts/{configure.mjs → setup-native.mjs} +4 -1
  55. package/src/binding.cpp +1 -1
  56. package/src/common/error_utils.h +0 -6
  57. package/src/common/volume_metadata.h +6 -0
  58. package/src/darwin/hidden.cpp +73 -25
  59. package/src/darwin/path_security.h +149 -0
  60. package/src/darwin/raii_utils.h +104 -4
  61. package/src/darwin/volume_metadata.cpp +132 -58
  62. package/src/darwin/volume_mount_points.cpp +80 -47
  63. package/src/hidden.ts +36 -13
  64. package/src/linux/gio_mount_points.cpp +17 -18
  65. package/src/linux/gio_utils.cpp +92 -37
  66. package/src/linux/gio_utils.h +11 -5
  67. package/src/linux/gio_volume_metadata.cpp +111 -48
  68. package/src/linux/volume_metadata.cpp +67 -4
  69. package/src/object.ts +1 -0
  70. package/src/options.ts +6 -0
  71. package/src/path.ts +11 -0
  72. package/src/platform.ts +25 -0
  73. package/src/remote_info.ts +5 -3
  74. package/src/stack_path.ts +8 -6
  75. package/src/string_enum.ts +1 -0
  76. package/src/test-utils/benchmark-harness.ts +192 -0
  77. package/src/test-utils/debuglog-child.ts +30 -2
  78. package/src/test-utils/debuglog-enabled-child.ts +38 -8
  79. package/src/test-utils/jest-setup.ts +14 -0
  80. package/src/test-utils/memory-test-core.ts +336 -0
  81. package/src/test-utils/memory-test-runner.ts +108 -0
  82. package/src/test-utils/platform.ts +46 -1
  83. package/src/test-utils/worker-thread-helper.cjs +157 -26
  84. package/src/types/native_bindings.ts +1 -1
  85. package/src/types/options.ts +6 -0
  86. package/src/windows/drive_status.h +133 -163
  87. package/src/windows/error_utils.h +54 -3
  88. package/src/windows/fs_meta.h +1 -1
  89. package/src/windows/hidden.cpp +60 -43
  90. package/src/windows/security_utils.h +250 -0
  91. package/src/windows/string.h +68 -11
  92. package/src/windows/system_volume.h +1 -1
  93. package/src/windows/thread_pool.h +206 -0
  94. package/src/windows/volume_metadata.cpp +11 -6
  95. package/src/windows/volume_mount_points.cpp +8 -7
  96. package/src/windows/windows_arch.h +39 -0
  97. package/scripts/check-memory.mjs +0 -123
  98. package/scripts/clang-tidy.mjs +0 -73
package/CHANGELOG.md CHANGED
@@ -14,7 +14,13 @@ Fixed for any bug fixes.
14
14
  Security in case of vulnerabilities.
15
15
  -->
16
16
 
17
- ## [0.6.0] - 2025-06-03
17
+ ## 0.7.0 - 2025-10-24
18
+
19
+ - Audit and address [several resource handling issues](./doc/SECURITY_AUDIT_2025.md)
20
+ - Added support for Node.js v25
21
+ - Updated dev dependencies
22
+
23
+ ## 0.6.0 - 2025-06-09
18
24
 
19
25
  ### Added
20
26
 
@@ -24,6 +30,8 @@ Security in case of vulnerabilities.
24
30
  - Clang-tidy integration for C++ code analysis
25
31
  - Worker thread helper for volume metadata operations
26
32
  - NAPI_VERSION=9 definition for improved compatibility
33
+ - Dynamic test timeout configuration based on environment (CI, platform, architecture)
34
+ - Prebuild script for Linux GLIBC compatibility in Docker environments
27
35
 
28
36
  ### Breaking
29
37
 
@@ -36,6 +44,7 @@ Security in case of vulnerabilities.
36
44
  - Updated all imports to use `node:` prefix for built-in modules
37
45
  - Reorganized build and test scripts for better clarity
38
46
  - Improved memory test workflow for cross-platform compatibility
47
+ - Renamed native module target from `node_fs_meta` to `fs_metadata` for consistency
39
48
 
40
49
  ### Fixed
41
50
 
@@ -44,13 +53,9 @@ Security in case of vulnerabilities.
44
53
  - Fixed buffer allocation issues in Windows networking and volume operations
45
54
  - Enhanced resource management with better validation for empty mount points
46
55
  - Made `SystemPathPatternsDefault` values visible in TypeScript typings
47
- - Improved test reliability across different CI environments
48
56
  - Added Napi::HandleScope to OnOK and OnError methods for proper scope management
49
57
  - Removed unnecessary std::move operations in worker implementations
50
- - Updated filesystem metadata tests to verify type and existence instead of specific values
51
- - Improved error handling and messages in various components
52
- - Enhanced error message validation for file access in worker thread tests
53
- - Updated tests to use healthy mount points for volume metadata retrieval
58
+ - Resolved CI test reliability issues across different environments, particularly Alpine ARM64 emulation timeouts
54
59
 
55
60
  ## [0.4.0] - 2025-01-09
56
61
 
package/CLAUDE.md CHANGED
@@ -4,173 +4,197 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
4
4
 
5
5
  ## Project Overview
6
6
 
7
- This is @photostructure/fs-metadata - a cross-platform native Node.js module for retrieving filesystem metadata, including mount points, volume information, and space utilization statistics.
8
-
9
- ### Key Features
10
- - Cross-platform support: Windows 10+ (x64), macOS 14+, Ubuntu 22+ (x64, arm64)
11
- - Lists all mounted volumes/drives
12
- - Gets detailed volume metadata (size, usage, filesystem type, etc.)
13
- - Hidden file/directory attribute support (get/set)
14
- - Non-blocking async native implementations
15
- - Timeout handling for unresponsive network volumes
16
- - ESM and CJS module support
17
- - Full TypeScript type definitions
18
- - Worker threads support with proper context isolation
19
-
20
- ### Platform-Specific Notes
21
- - **Linux**: Optional GIO/GVfs mount support via Gnome libraries
22
- - **Windows**: Uses separate threads per mountpoint for health checks to handle blocked system calls
23
- - **System Volumes**: Each platform handles system volumes differently; the library uses heuristics to identify them
24
-
25
- ## Common Commands
26
-
27
- ### Build and Development
28
- ```bash
29
- # Install dependencies and build native modules
30
- npm install
7
+ @photostructure/fs-metadata - Cross-platform native Node.js module for filesystem metadata retrieval.
31
8
 
32
- # Configure platform-specific build settings
33
- npm run configure:native
9
+ ### Directory Structure
34
10
 
35
- # Build native bindings
36
- npm run node-gyp-rebuild
11
+ - `src/` - Source code (TypeScript and C++)
12
+ - `dist/` - Compiled JavaScript output (gitignored)
13
+ - `doc/` - Static documentation (manually written, checked into git)
14
+ - `build/` - All build artifacts (gitignored)
15
+ - `build/docs/` - Generated API documentation from TypeDoc (deployed to GitHub Pages)
16
+ - `scripts/` - Build and utility scripts
17
+ - `prebuilds/` - Prebuilt native binaries for different platforms
37
18
 
38
- # Create prebuilds for distribution
39
- npm run prebuild
19
+ ### Script Preferences
40
20
 
41
- # Assemble TypeScript to dist/
42
- npm run build:dist
43
- ```
21
+ **Always** use TypeScript (`.ts`) scripts executed with `tsx` instead of:
44
22
 
45
- ### Testing
46
- ```bash
47
- # Run all tests with coverage (includes memory tests on Linux)
48
- npm run test:all
23
+ - `.js` scripts (require compilation or older Node.js syntax)
24
+ - `.mjs` scripts (ESM-only, compatibility issues)
25
+ - `.cjs` scripts (CommonJS-only, less type safety)
49
26
 
50
- # Run CommonJS tests
51
- npm test:cjs
27
+ TypeScript with tsx provides type safety, modern syntax, and seamless execution.
52
28
 
53
- # Run ESM tests
54
- npm test:esm
29
+ ## Critical Knowledge
55
30
 
56
- # Test memory leaks (JavaScript)
57
- npm run test:memory
31
+ ### Testing File System Metadata
58
32
 
59
- # Run valgrind memory analysis (Linux only)
60
- bash scripts/valgrind-test.sh
33
+ **Never** expect exact equality for dynamic values (`available`, `used`) between calls. Only verify:
61
34
 
62
- # Run AddressSanitizer and LeakSanitizer (Linux only)
63
- bash scripts/sanitizers-test.sh
35
+ - Value exists and has correct type: `typeof result.available === 'number'`
36
+ - Test static properties (`size`, `mountFrom`, `fstype`) for exact equality
37
+ - Avoid range assertions (`available > 0`) - file changes can be dramatic
64
38
 
65
- # Run comprehensive memory tests (JavaScript + valgrind + sanitizers)
66
- npm run test:memory
39
+ ### Cross-Module Compatibility
67
40
 
68
- # Run a specific test file (no coverage)
69
- npm test volume_metadata
70
- ```
41
+ Use `_dirname()` from `./dirname` instead of `__dirname` - works in both CommonJS and ESM contexts.
71
42
 
72
- ### Code Quality
73
- ```bash
74
- # Run ESLint
75
- npm run lint
43
+ ### Node.js Version Compatibility
76
44
 
77
- # Fix ESLint issues
78
- npm run lint:fix
45
+ Jest 30 doesn't support Node.js 23. Use Node.js 20, 22, or 24.
79
46
 
80
- # Format code (all formats)
81
- npm run fmt
47
+ ## Windows-Specific Issues
82
48
 
83
- # Format C++ code only
84
- npm run fmt:cpp
49
+ ### Windows CI Jest Worker Failures
85
50
 
86
- # Format TypeScript only
87
- npm run fmt:ts
51
+ **Problem**: Jest worker processes fail on Windows CI environments (both x64 and ARM64) with "Jest worker encountered 4 child process exceptions".
88
52
 
89
- # Type checking
90
- npm run build:ts
91
- ```
53
+ **Solution for Memory Tests**:
92
54
 
93
- ### Pre-commit
94
- ```bash
95
- # Full precommit check (fmt, clean, prebuild, tests)
96
- npm run precommit
97
- ```
55
+ Memory tests now use a standalone TypeScript runner (`src/test-utils/memory-test-runner.ts`) that bypasses Jest entirely on all platforms. This provides more accurate memory measurements without Jest overhead and avoids worker process issues.
56
+
57
+ - Run full memory check suite (includes native tools): `npm run check:memory`
58
+ - Memory test logic is in `src/test-utils/memory-test-core.ts`
59
+
60
+ **Workaround for Other Tests**:
61
+
62
+ 1. Jest is configured to use single worker mode (`maxWorkers: 1`) for all Windows CI environments
63
+ 2. Tests that stress worker threads or concurrency are skipped on Windows CI using `describeSkipWindowsCI` or `describePlatformStable`:
64
+
65
+ - `worker_threads.test.ts` - Worker thread integration tests
66
+ - `thread_safety.test.ts` - Concurrent operations stress tests
67
+ - `windows-memory-check.test.ts` - Memory leak detection (Windows only)
68
+ - `windows-resource-security.test.ts` - Resource handle leak tests (Windows only)
69
+
70
+ **Note**: These tests pass locally but fail in CI. The native module loads correctly, but Jest's worker process management has fundamental incompatibilities with these specific tests on GitHub Actions Windows runners.
71
+
72
+ ### Build Architecture Issue
73
+
74
+ **Problem**: "No Target Architecture" error from Windows SDK headers when building with node-gyp/prebuildify.
75
+
76
+ **Solution**: Use `scripts/prebuildify-wrapper.ts` which sets the `CL` environment variable with architecture defines:
77
+
78
+ - For x64: `CL=/D_M_X64 /D_WIN64 /D_AMD64_`
79
+ - For ARM64: `CL=/D_M_ARM64 /D_WIN64`
80
+
81
+ **Why This is Necessary**:
82
+
83
+ - Prebuildify doesn't properly pass architecture defines from binding.gyp conditions
84
+ - The Windows SDK requires these macros before including `<windows.h>`
85
+ - Projects like node-sqlite avoid this by not using Windows headers directly
86
+
87
+ **Why Other Approaches Failed**:
88
+
89
+ - **Source file defines**: Would hardcode x64 defines, breaking ARM64 builds
90
+ - **windows_compat.h wrapper**: Can't distinguish x64 from ARM64 at compile time
91
+ - **binding.gyp conditions**: Not evaluated properly by prebuildify
92
+ - **msvs_settings defines**: Not passed through to the compiler
93
+
94
+ ### Memory Testing Limitations
95
+
96
+ Traditional Windows tools **do not work** with Node.js native modules:
97
+
98
+ - **Dr. Memory**: Fails with "Unable to load client library: ucrtbase.dll"
99
+ - **Debug CRT builds**: Cannot be loaded by Node.js (missing debug runtime + UNC path issues)
100
+ - **Visual Leak Detector**: Requires debug builds which don't work
101
+ - **Application Verifier**: Cannot hook into Node.js memory management
102
+
103
+ Use JavaScript-based memory testing (`src/windows-memory-check.test.ts`) instead.
104
+
105
+ ### Static Analysis (clang-tidy) Limitations
106
+
107
+ **clang-tidy on Windows** has limited effectiveness due to MSVC header incompatibility:
108
+
109
+ - Generates many false errors about missing std namespace members
110
+ - Still provides valuable warnings about your code
111
+ - See `doc/windows-clang-tidy.md` for details
112
+ - Consider using Visual Studio Code Analysis as an alternative
113
+
114
+ ### WSL Development
115
+
116
+ Run Windows commands from WSL:
98
117
 
99
- ### Documentation
100
118
  ```bash
101
- # Generate API documentation
102
- npm run docs
119
+ cmd.exe /c "cd C:\\Users\\matth\\src\\fs-metadata && npm test"
120
+ # Or create helper: echo 'cmd.exe /c "cd C:\\Users\\matth\\src\\fs-metadata && $@"' > ~/bin/win-run
103
121
  ```
104
122
 
105
- ## Architecture Overview
123
+ ## Memory Leak Detection
106
124
 
107
- ### Core Structure
108
- - **Native binding layer** (`src/binding.cpp`): Node-API v9 bridge between JavaScript and platform-specific implementations
109
- - **Platform abstractions** in `src/common/`: Shared C++ interfaces for cross-platform functionality
110
- - **Platform implementations**:
111
- - `src/darwin/`: macOS-specific code using Core Foundation APIs
112
- - `src/linux/`: Linux-specific code with optional GIO support for GNOME/GVfs
113
- - `src/windows/`: Windows-specific code using Win32 APIs
125
+ Run `npm run check:memory` for comprehensive platform-specific testing:
114
126
 
115
- ### Key Features
116
- - **Volume Metadata**: Retrieves filesystem information (mount points, disk usage, health status)
117
- - **Hidden File Support**: Cross-platform hidden file detection and manipulation
118
- - **Async Operations**: All native operations use Worker threads to avoid blocking
127
+ - **All platforms**: JavaScript memory tests with GC triggers
128
+ - **Windows**: Handle count monitoring via `process.report`
129
+ - **Linux**: Valgrind + AddressSanitizer/LeakSanitizer
130
+ - **macOS**: AddressSanitizer (may fail due to SIP - expected)
119
131
 
120
- ### Build System
121
- - Uses `node-gyp` for native compilation
122
- - Conditionally enables GIO support on Linux via `scripts/configure.mjs`
123
- - Provides prebuilt binaries via `prebuildify` for common platforms
124
- - Supports both ESM and CJS module formats
132
+ ## CI/CD Test Reliability
125
133
 
126
- ### Cross-Module Compatibility
127
- - **Directory Path Resolution**: Use `_dirname()` from `./dirname` instead of `__dirname`
128
- - Works in both CommonJS and ESM contexts
129
- - Handles Jest test environments correctly
130
- - Example: `const dir = _dirname()` instead of `const dir = __dirname`
134
+ ### Critical Anti-Patterns
131
135
 
132
- ### Testing Strategy
133
- - Jest for both CJS and ESM test suites
134
- - Platform-specific test expectations handled via `isWindows`, `isMacOS`, `isLinux` helpers
135
- - Memory leak testing with garbage collection monitoring
136
- - Coverage thresholds: 80% for all metrics
136
+ **Never** use these to "fix" async issues:
137
137
 
138
- ### Testing File System Metadata
139
- - **Important**: File system metadata like `available` space, `used` space, and other dynamic properties change continuously as other processes run on the machine
140
- - Tests should **never** expect exact equality for these values between multiple calls
141
- - **Do not** make range assertions (e.g., `available > 0` or `used < size`) because:
142
- - Files can be created or deleted between calls (potentially gigabytes)
143
- - The changes can be dramatic and unpredictable
144
- - Instead, for dynamic metadata:
145
- - Only verify the value exists and has the correct type
146
- - Use `typeof result.available === 'number'` rather than range checks
147
- - Focus on testing static properties (e.g., `size`, `mountFrom`, `fstype`) for exact equality
148
- - Consider using snapshot testing only for stable properties
149
-
150
- ### Timeout Handling
151
- - Default timeout for volume operations to handle unresponsive network mounts
152
- - Windows uses separate threads per mountpoint for health checks
153
- - Configurable via `Options` interface
154
-
155
- ### Debug Logging
156
- - Enable with `NODE_DEBUG=fs-meta` or `NODE_DEBUG=photostructure:fs-metadata`
157
- - Debug messages from both JavaScript and native code are sent to `stderr`
158
- - Uses native Node.js debuglog for determining if logging is enabled
159
-
160
- ## Example Usage
138
+ ```javascript
139
+ // BAD: Arbitrary timeouts
140
+ await new Promise((resolve) => setTimeout(resolve, 100));
141
+ // BAD: Forcing GC
142
+ if (global.gc) global.gc();
143
+ // BAD: setImmediate in afterAll
144
+ afterAll(async () => {
145
+ await new Promise((resolve) => setImmediate(resolve));
146
+ });
147
+ ```
148
+
149
+ ### Windows Directory Cleanup
150
+
151
+ Always use retry logic:
161
152
 
162
153
  ```typescript
163
- import { getVolumeMountPoints, getVolumeMetadata } from "@photostructure/fs-metadata";
154
+ await fsp.rm(tempDir, {
155
+ recursive: true,
156
+ force: true,
157
+ maxRetries: process.platform === "win32" ? 3 : 1,
158
+ retryDelay: process.platform === "win32" ? 100 : 0,
159
+ });
160
+ ```
161
+
162
+ ### Platform Performance Multipliers
163
+
164
+ - Alpine Linux (musl): 2x slower
165
+ - ARM64 emulation: 5x slower
166
+ - Windows processes: 4x slower
167
+ - macOS VMs: 4x slower
168
+
169
+ ### Multi-Process Synchronization
170
+
171
+ Use explicit signals:
172
+
173
+ ```javascript
174
+ console.log("READY"); // Signal readiness
175
+ console.log("RESULT:" + outcome); // Signal result
176
+ ```
177
+
178
+ ## Release Process
179
+
180
+ Requires repository secrets:
181
+
182
+ - `NPM_TOKEN`: npm authentication
183
+ - `GPG_PRIVATE_KEY`: ASCII-armored GPG key
184
+ - `GPG_PASSPHRASE`: GPG passphrase
185
+
186
+ Automated via GitHub Actions workflow dispatch or manual:
187
+
188
+ ```bash
189
+ npm run prepare-release
190
+ git config commit.gpgsign true
191
+ npm version patch|minor|major
192
+ npm publish
193
+ git push origin main --follow-tags
194
+ ```
164
195
 
165
- // List all mounted volumes
166
- const mountPoints = await getVolumeMountPoints();
167
- console.dir({ mountPoints });
196
+ ## General guidance
168
197
 
169
- // Get metadata for a specific volume
170
- const volumeMetadata = await getVolumeMetadata(mountPoints[0]);
171
- console.dir({ volumeMetadata });
198
+ Never do inline imports like `const { mkdirSync } = await import("node:fs");` -- just use standard imports.
172
199
 
173
- // Check if a file is hidden
174
- import { isHidden } from "@photostructure/fs-metadata";
175
- const hidden = await isHidden("/path/to/file");
176
- ```
200
+ Never include claude code messages in git commits
@@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
17
17
  Examples of behavior that contributes to a positive environment for our
18
18
  community include:
19
19
 
20
- * Demonstrating empathy and kindness toward other people
21
- * Being respectful of differing opinions, viewpoints, and experiences
22
- * Giving and gracefully accepting constructive feedback
23
- * Accepting responsibility and apologizing to those affected by our mistakes,
20
+ - Demonstrating empathy and kindness toward other people
21
+ - Being respectful of differing opinions, viewpoints, and experiences
22
+ - Giving and gracefully accepting constructive feedback
23
+ - Accepting responsibility and apologizing to those affected by our mistakes,
24
24
  and learning from the experience
25
- * Focusing on what is best not just for us as individuals, but for the
25
+ - Focusing on what is best not just for us as individuals, but for the
26
26
  overall community
27
27
 
28
28
  Examples of unacceptable behavior include:
29
29
 
30
- * The use of sexualized language or imagery, and sexual attention or
30
+ - The use of sexualized language or imagery, and sexual attention or
31
31
  advances of any kind
32
- * Trolling, insulting or derogatory comments, and personal or political attacks
33
- * Public or private harassment
34
- * Publishing others' private information, such as a physical or email
32
+ - Trolling, insulting or derogatory comments, and personal or political attacks
33
+ - Public or private harassment
34
+ - Publishing others' private information, such as a physical or email
35
35
  address, without their explicit permission
36
- * Other conduct which could reasonably be considered inappropriate in a
36
+ - Other conduct which could reasonably be considered inappropriate in a
37
37
  professional setting
38
38
 
39
39
  ## Enforcement Responsibilities
@@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
106
106
  ### 4. Permanent Ban
107
107
 
108
108
  **Community Impact**: Demonstrating a pattern of violation of community
109
- standards, including sustained inappropriate behavior, harassment of an
109
+ standards, including sustained inappropriate behavior, harassment of an
110
110
  individual, or aggression toward or disparagement of classes of individuals.
111
111
 
112
112
  **Consequence**: A permanent ban from any sort of public interaction within
package/CONTRIBUTING.md CHANGED
@@ -26,7 +26,7 @@ Install the Xcode Command Line Tools, and then
26
26
 
27
27
  ### On Ubuntu/Debian
28
28
 
29
- sudo apt-get install build-essential clang-format libglib2.0-dev libblkid-dev uuid-dev
29
+ sudo apt-get install bear build-essential clang-format libglib2.0-dev libblkid-dev uuid-dev
30
30
 
31
31
  ## Before submitting your PR
32
32
 
@@ -106,7 +106,7 @@ Actions that have multiple targets can be run in parallel using wildcards:
106
106
 
107
107
  ### Naming Guidelines
108
108
 
109
- - Use explicit names to avoid ambiguity (e.g., `configure:native` instead of just `configure`)
109
+ - Use explicit names to avoid ambiguity (e.g., `setup:native` instead of just `setup`)
110
110
  - Group related scripts by action prefix for easy wildcard execution
111
111
  - Avoid names that could cause npm lifecycle conflicts (e.g., `prebuild` vs `build`)
112
112
  - Use descriptive suffixes that clearly indicate the target or purpose
package/README.md CHANGED
@@ -1,55 +1,19 @@
1
- # @photostructure/fs-metadata
1
+ ![PhotoStructure fs-metadata logo](https://raw.githubusercontent.com/photostructure/fs-metadata/main/doc/logo.svg)
2
2
 
3
- A cross-platform native Node.js module for retrieving filesystem metadata, including mount points, volume information, and space utilization statistics.
4
-
5
- Built and supported by [PhotoStructure](https://photostructure.com).
3
+ Cross-platform native Node.js module for filesystem metadata, mount points, and volume information.
6
4
 
7
5
  [![npm version](https://img.shields.io/npm/v/@photostructure/fs-metadata.svg)](https://www.npmjs.com/package/@photostructure/fs-metadata)
8
6
  [![Build](https://github.com/photostructure/fs-metadata/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/photostructure/fs-metadata/actions/workflows/build.yml)
9
- [![GitHub issues](https://img.shields.io/github/issues/photostructure/fs-metadata.svg)](https://github.com/photostructure/fs-metadata/issues)
10
- [![Known Vulnerabilities](https://snyk.io/test/github/photostructure/fs-metadata/badge.svg?targetFile=package.json)](https://snyk.io/test/github/photostructure/fs-metadata?targetFile=package.json)
11
7
  [![Node-API v9 Badge](https://raw.githubusercontent.com/nodejs/abi-stable-node/refs/heads/doc/assets/Node-API%20v9%20Badge.svg)](https://nodejs.org/dist/latest/docs/api/n-api.html#node-api-version-matrix)
12
8
  [![View on GitHub](https://img.shields.io/badge/View%20on-GitHub-blue)](https://github.com/photostructure/fs-metadata)
13
9
 
14
- ## Features
15
-
16
- - Cross-platform support:
17
- - Windows 10+ (x64)
18
- - macOS 14+
19
- - Ubuntu 22+ (x64, arm64) (with Gnome GIO/`GVfs` mount support where available)
20
-
21
- - [List all mounted volumes/drives](https://photostructure.github.io/fs-metadata/functions/getVolumeMountPoints.html)
22
-
23
- - [Get detailed volume metadata](https://photostructure.github.io/fs-metadata/functions/getVolumeMetadata.html)
24
-
25
- - File and directory hidden attribute support:
26
- - [Get](https://photostructure.github.io/fs-metadata/functions/isHidden.html) and [set](https://photostructure.github.io/fs-metadata/functions/setHidden.html) hidden attributes
27
- - POSIX-style support (macOS and Linux)
28
- - Filesystem metadata support (macOS and Windows)
29
- - [Recursive hidden checks](https://photostructure.github.io/fs-metadata/functions/isHiddenRecursive.html)
30
- - [Hidden metadata queries](https://photostructure.github.io/fs-metadata/functions/getHiddenMetadata.html)
31
-
32
- - ESM and CJS support
33
-
34
- - Full TypeScript type definitions
35
-
36
- - Non-blocking async native implementations
37
-
38
- - Timeout handling for wedged network volumes
39
-
40
- - Compatible with all current Node.js and Electron versions via [Node-API v9](https://nodejs.org/api/n-api.html#node-api) and [prebuildify](https://github.com/prebuild/prebuildify)
41
-
42
- - Comprehensive test coverage
43
-
44
- ## Installation
10
+ ## Quick Start
45
11
 
46
12
  ```bash
47
13
  npm install @photostructure/fs-metadata
48
14
  ```
49
15
 
50
- ## Usage
51
-
52
- ```ts
16
+ ```typescript
53
17
  import {
54
18
  getVolumeMountPoints,
55
19
  getVolumeMetadata,
@@ -57,62 +21,48 @@ import {
57
21
 
58
22
  // List all mounted volumes
59
23
  const mountPoints = await getVolumeMountPoints();
60
- console.dir({ mountPoints });
24
+ console.log(mountPoints);
61
25
 
62
26
  // Get metadata for a specific volume
63
- const volumeMetadata = await getVolumeMetadata(mountPoints[0]);
64
- console.dir({ volumeMetadata });
27
+ const metadata = await getVolumeMetadata("/");
28
+ console.log(metadata);
65
29
  ```
66
30
 
67
- If you're using CommonJS:
68
-
69
- ```js
70
- const {
71
- getVolumeMountPoints,
72
- getVolumeMetadata,
73
- } = require("@photostructure/fs-metadata");
74
-
75
- // Usage is the same as the ESM example above
76
- // (except of course no top-level awaits!)
77
- ```
78
-
79
- ## API
80
-
81
- [Read the API here](https://photostructure.github.io/fs-metadata/modules.html)
82
-
83
- ## Options
84
-
85
- ### Debug Logging
86
-
87
- Set `NODE_DEBUG=fs-meta` or `NODE_DEBUG=photostructure:fs-metadata`. The native [debuglog](https://nodejs.org/api/util.html#utildebuglogsection-callback) determines if debug logging is enabled. Debug messages from both JavaScript and native code are sent to `stderr`.
88
-
89
- ### Timeouts
90
-
91
- Operations use a [default timeout](https://photostructure.github.io/fs-metadata/variables/TimeoutMsDefault.html), which may need adjustment for slower devices like optical drives (which can take 30+ seconds to spin up).
92
-
93
- Windows can block system calls when remote filesystems are unhealthy due to host downtime or network issues. To handle this, we use a separate thread per mountpoint to check volume health status. While this approach uses more resources than the async N-API thread, it enables reliable timeouts for operations that would otherwise hang indefinitely.
94
-
95
- Timeout duration may apply per-operation or per-system call, depending on the implementation.
31
+ ## Key Features
96
32
 
97
- ### System Volumes
33
+ - **Volume Management**: List mount points, get volume metadata, space usage
34
+ - **Hidden Files**: Get/set hidden attributes, recursive checks, cross-platform support
35
+ - **Performance**: Non-blocking async operations with timeout protection
36
+ - **TypeScript**: Full type definitions with ESM and CommonJS support
98
37
 
99
- Each platform handles system volumes differently:
38
+ ## Supported Platforms
100
39
 
101
- - Windows provides explicit metadata for "system" or "reserved" devices, though `C:\` is both a system volume and typical user storage
102
- - Linux and macOS include various system-only mountpoints: pseudo devices, snap loopback devices, virtual memory partitions, and recovery partitions
40
+ | Platform | Architecture | Node.js | OS Version |
41
+ | ------------- | ------------ | ------- | ------------------------- |
42
+ | Windows | x64, arm64 | 20+ | Windows 10+ |
43
+ | macOS | x64, arm64 | 20+ | macOS 14+ |
44
+ | Linux (glibc) | x64, arm64 | 20+ | Debian 11+, Ubuntu 20.04+ |
45
+ | Linux (musl) | x64, arm64 | 20+ | Alpine 3.21+ |
103
46
 
104
- This library uses heuristics to identify system volumes. See [Options](https://photostructure.github.io/fs-metadata/interfaces/Options.html) for default values and customization.
47
+ > **Note**: Linux binaries require GLIBC 2.31+. The `node:20` Docker image is not supported.
105
48
 
106
- Note: [`getAllVolumeMetadata()`](https://photostructure.github.io/fs-metadata/functions/getAllVolumeMetadata.html) returns all volumes on Windows but only non-system volumes elsewhere by default.
49
+ ## Documentation
107
50
 
108
- ## License
51
+ - 📖 [API Reference](https://photostructure.github.io/fs-metadata/modules.html)
52
+ - 💡 [Examples](./doc/examples.md) - Common usage patterns and recipes
53
+ - ⚠️ [Gotchas](./doc/gotchas.md) - Platform quirks, timeouts, and troubleshooting
54
+ - 🔧 [Contributing](./CONTRIBUTING.md) - Build instructions and development guide
109
55
 
110
- This project is licensed under the [MIT License](https://github.com/photostructure/fs-metadata/blob/main/LICENSE.txt).
56
+ ### Options
111
57
 
112
- ## Contributing
58
+ - **Debug**: Set `NODE_DEBUG=fs-meta` for debug output
59
+ - **Timeouts**: Configure [timeout duration](https://photostructure.github.io/fs-metadata/variables/TimeoutMsDefault.html) for slow devices
60
+ - **System Volumes**: Control [system volume filtering](https://photostructure.github.io/fs-metadata/interfaces/Options.html)
113
61
 
114
- We welcome contributions! Please see our [Contributing Guide](https://github.com/photostructure/fs-metadata/blob/main/CONTRIBUTING.md) for more details.
62
+ ## Support
115
63
 
116
- ## Security
64
+ Built and supported by [PhotoStructure](https://photostructure.com)
117
65
 
118
- For security-related issues, please refer to our [Security Policy](https://github.com/photostructure/fs-metadata/blob/main/SECURITY.md).
66
+ - [GitHub Issues](https://github.com/photostructure/fs-metadata/issues)
67
+ - [Security Policy](./SECURITY.md)
68
+ - [MIT License](./LICENSE.txt)