@photostructure/fs-metadata 0.5.0 → 0.6.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.
- package/C++_REVIEW_TODO.md +1 -1
- package/CHANGELOG.md +11 -1
- package/CLAUDE.md +30 -23
- package/CONTRIBUTING.md +41 -0
- package/binding.gyp +2 -1
- package/dist/index.cjs +1439 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +360 -0
- package/dist/index.d.mts +360 -0
- package/dist/index.d.ts +360 -0
- package/dist/index.mjs +1397 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +19 -22
- package/prebuilds/darwin-arm64/@photostructure+fs-metadata.glibc.node +0 -0
- package/prebuilds/linux-arm64/@photostructure+fs-metadata.musl.node +0 -0
- package/prebuilds/linux-x64/@photostructure+fs-metadata.glibc.node +0 -0
- package/prebuilds/linux-x64/@photostructure+fs-metadata.musl.node +0 -0
- package/prebuilds/win32-x64/@photostructure+fs-metadata.glibc.node +0 -0
- package/scripts/check-memory.mjs +53 -173
- package/scripts/clang-tidy.mjs +1 -1
- package/scripts/sanitizers-test.sh +151 -0
- package/scripts/valgrind-test.mjs +1 -1
- package/scripts/{valgrind.sh → valgrind-test.sh} +15 -0
- package/src/common/error_utils.h +23 -0
- package/src/common/metadata_worker.h +4 -1
- package/src/darwin/hidden.cpp +13 -6
- package/src/darwin/volume_metadata.cpp +2 -2
- package/src/darwin/volume_mount_points.cpp +8 -1
- package/src/linux/blkid_cache.cpp +8 -2
- package/src/linux/volume_metadata.cpp +1 -1
- package/src/test-utils/worker-thread-helper.cjs +88 -0
- package/src/windows/hidden.cpp +20 -11
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -131
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -131
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/src/array.ts.html +0 -217
- package/coverage/lcov-report/src/async.ts.html +0 -547
- package/coverage/lcov-report/src/debuglog.ts.html +0 -187
- package/coverage/lcov-report/src/defer.ts.html +0 -175
- package/coverage/lcov-report/src/dirname.ts.html +0 -124
- package/coverage/lcov-report/src/error.ts.html +0 -322
- package/coverage/lcov-report/src/fs.ts.html +0 -316
- package/coverage/lcov-report/src/glob.ts.html +0 -472
- package/coverage/lcov-report/src/hidden.ts.html +0 -724
- package/coverage/lcov-report/src/index.html +0 -521
- package/coverage/lcov-report/src/index.ts.html +0 -676
- package/coverage/lcov-report/src/linux/dev_disk.ts.html +0 -316
- package/coverage/lcov-report/src/linux/index.html +0 -146
- package/coverage/lcov-report/src/linux/mount_points.ts.html +0 -364
- package/coverage/lcov-report/src/linux/mtab.ts.html +0 -493
- package/coverage/lcov-report/src/mount_point.ts.html +0 -106
- package/coverage/lcov-report/src/number.ts.html +0 -148
- package/coverage/lcov-report/src/object.ts.html +0 -265
- package/coverage/lcov-report/src/options.ts.html +0 -475
- package/coverage/lcov-report/src/path.ts.html +0 -268
- package/coverage/lcov-report/src/platform.ts.html +0 -112
- package/coverage/lcov-report/src/random.ts.html +0 -205
- package/coverage/lcov-report/src/remote_info.ts.html +0 -553
- package/coverage/lcov-report/src/stack_path.ts.html +0 -298
- package/coverage/lcov-report/src/string.ts.html +0 -382
- package/coverage/lcov-report/src/string_enum.ts.html +0 -208
- package/coverage/lcov-report/src/system_volume.ts.html +0 -301
- package/coverage/lcov-report/src/unc.ts.html +0 -274
- package/coverage/lcov-report/src/units.ts.html +0 -274
- package/coverage/lcov-report/src/uuid.ts.html +0 -157
- package/coverage/lcov-report/src/volume_health_status.ts.html +0 -259
- package/coverage/lcov-report/src/volume_metadata.ts.html +0 -787
- package/coverage/lcov-report/src/volume_mount_points.ts.html +0 -388
- package/coverage/lcov.info +0 -3581
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -196
- package/coverage/src/array.ts.html +0 -217
- package/coverage/src/async.ts.html +0 -547
- package/coverage/src/debuglog.ts.html +0 -187
- package/coverage/src/defer.ts.html +0 -175
- package/coverage/src/dirname.ts.html +0 -124
- package/coverage/src/error.ts.html +0 -322
- package/coverage/src/fs.ts.html +0 -316
- package/coverage/src/glob.ts.html +0 -472
- package/coverage/src/hidden.ts.html +0 -724
- package/coverage/src/index.html +0 -521
- package/coverage/src/index.ts.html +0 -676
- package/coverage/src/linux/dev_disk.ts.html +0 -316
- package/coverage/src/linux/index.html +0 -146
- package/coverage/src/linux/mount_points.ts.html +0 -364
- package/coverage/src/linux/mtab.ts.html +0 -493
- package/coverage/src/mount_point.ts.html +0 -106
- package/coverage/src/number.ts.html +0 -148
- package/coverage/src/object.ts.html +0 -265
- package/coverage/src/options.ts.html +0 -475
- package/coverage/src/path.ts.html +0 -268
- package/coverage/src/platform.ts.html +0 -112
- package/coverage/src/random.ts.html +0 -205
- package/coverage/src/remote_info.ts.html +0 -553
- package/coverage/src/stack_path.ts.html +0 -298
- package/coverage/src/string.ts.html +0 -382
- package/coverage/src/string_enum.ts.html +0 -208
- package/coverage/src/system_volume.ts.html +0 -301
- package/coverage/src/unc.ts.html +0 -274
- package/coverage/src/units.ts.html +0 -274
- package/coverage/src/uuid.ts.html +0 -157
- package/coverage/src/volume_health_status.ts.html +0 -259
- package/coverage/src/volume_metadata.ts.html +0 -787
- package/coverage/src/volume_mount_points.ts.html +0 -388
- package/scripts/run-asan.sh +0 -92
package/C++_REVIEW_TODO.md
CHANGED
|
@@ -243,7 +243,7 @@ This document outlines a comprehensive review of all C++ files in the fs-metadat
|
|
|
243
243
|
3. **Memory Testing Infrastructure**
|
|
244
244
|
- Created comprehensive memory testing documentation (`docs/MEMORY_TESTING.md`)
|
|
245
245
|
- Improved ASan configuration with proper suppressions
|
|
246
|
-
- Created standalone test runner (`scripts/
|
|
246
|
+
- Created standalone test runner (`scripts/sanitizers-test.sh`)
|
|
247
247
|
- Updated `scripts/check-memory.mjs` with better ASan support
|
|
248
248
|
- All memory tests integrated into CI/CD
|
|
249
249
|
|
package/CHANGELOG.md
CHANGED
|
@@ -14,7 +14,7 @@ Fixed for any bug fixes.
|
|
|
14
14
|
Security in case of vulnerabilities.
|
|
15
15
|
-->
|
|
16
16
|
|
|
17
|
-
## [0.
|
|
17
|
+
## [0.6.0] - 2025-06-03
|
|
18
18
|
|
|
19
19
|
### Added
|
|
20
20
|
|
|
@@ -22,6 +22,8 @@ Security in case of vulnerabilities.
|
|
|
22
22
|
- Thread safety tests for Windows platform
|
|
23
23
|
- Platform-specific build scripts with automatic OS detection
|
|
24
24
|
- Clang-tidy integration for C++ code analysis
|
|
25
|
+
- Worker thread helper for volume metadata operations
|
|
26
|
+
- NAPI_VERSION=9 definition for improved compatibility
|
|
25
27
|
|
|
26
28
|
### Breaking
|
|
27
29
|
|
|
@@ -32,6 +34,8 @@ Security in case of vulnerabilities.
|
|
|
32
34
|
- Simplified ESM/CJS dual module support with unified build configuration
|
|
33
35
|
- Enhanced test coverage with additional error handling and edge case tests
|
|
34
36
|
- Updated all imports to use `node:` prefix for built-in modules
|
|
37
|
+
- Reorganized build and test scripts for better clarity
|
|
38
|
+
- Improved memory test workflow for cross-platform compatibility
|
|
35
39
|
|
|
36
40
|
### Fixed
|
|
37
41
|
|
|
@@ -41,6 +45,12 @@ Security in case of vulnerabilities.
|
|
|
41
45
|
- Enhanced resource management with better validation for empty mount points
|
|
42
46
|
- Made `SystemPathPatternsDefault` values visible in TypeScript typings
|
|
43
47
|
- Improved test reliability across different CI environments
|
|
48
|
+
- Added Napi::HandleScope to OnOK and OnError methods for proper scope management
|
|
49
|
+
- 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
|
|
44
54
|
|
|
45
55
|
## [0.4.0] - 2025-01-09
|
|
46
56
|
|
package/CLAUDE.md
CHANGED
|
@@ -15,6 +15,7 @@ This is @photostructure/fs-metadata - a cross-platform native Node.js module for
|
|
|
15
15
|
- Timeout handling for unresponsive network volumes
|
|
16
16
|
- ESM and CJS module support
|
|
17
17
|
- Full TypeScript type definitions
|
|
18
|
+
- Worker threads support with proper context isolation
|
|
18
19
|
|
|
19
20
|
### Platform-Specific Notes
|
|
20
21
|
- **Linux**: Optional GIO/GVfs mount support via Gnome libraries
|
|
@@ -29,7 +30,7 @@ This is @photostructure/fs-metadata - a cross-platform native Node.js module for
|
|
|
29
30
|
npm install
|
|
30
31
|
|
|
31
32
|
# Configure platform-specific build settings
|
|
32
|
-
npm run configure
|
|
33
|
+
npm run configure:native
|
|
33
34
|
|
|
34
35
|
# Build native bindings
|
|
35
36
|
npm run node-gyp-rebuild
|
|
@@ -37,32 +38,32 @@ npm run node-gyp-rebuild
|
|
|
37
38
|
# Create prebuilds for distribution
|
|
38
39
|
npm run prebuild
|
|
39
40
|
|
|
40
|
-
#
|
|
41
|
-
npm run
|
|
41
|
+
# Assemble TypeScript to dist/
|
|
42
|
+
npm run build:dist
|
|
42
43
|
```
|
|
43
44
|
|
|
44
45
|
### Testing
|
|
45
46
|
```bash
|
|
46
47
|
# Run all tests with coverage (includes memory tests on Linux)
|
|
47
|
-
npm run
|
|
48
|
+
npm run test:all
|
|
48
49
|
|
|
49
50
|
# Run CommonJS tests
|
|
50
|
-
npm test
|
|
51
|
+
npm test:cjs
|
|
51
52
|
|
|
52
53
|
# Run ESM tests
|
|
53
|
-
npm test
|
|
54
|
+
npm test:esm
|
|
54
55
|
|
|
55
56
|
# Test memory leaks (JavaScript)
|
|
56
57
|
npm run test:memory
|
|
57
58
|
|
|
58
59
|
# Run valgrind memory analysis (Linux only)
|
|
59
|
-
|
|
60
|
+
bash scripts/valgrind-test.sh
|
|
60
61
|
|
|
61
|
-
# Run
|
|
62
|
-
|
|
62
|
+
# Run AddressSanitizer and LeakSanitizer (Linux only)
|
|
63
|
+
bash scripts/sanitizers-test.sh
|
|
63
64
|
|
|
64
|
-
# Run
|
|
65
|
-
npm run
|
|
65
|
+
# Run comprehensive memory tests (JavaScript + valgrind + sanitizers)
|
|
66
|
+
npm run test:memory
|
|
66
67
|
|
|
67
68
|
# Run a specific test file (no coverage)
|
|
68
69
|
npm test volume_metadata
|
|
@@ -86,7 +87,7 @@ npm run fmt:cpp
|
|
|
86
87
|
npm run fmt:ts
|
|
87
88
|
|
|
88
89
|
# Type checking
|
|
89
|
-
npm run
|
|
90
|
+
npm run build:ts
|
|
90
91
|
```
|
|
91
92
|
|
|
92
93
|
### Pre-commit
|
|
@@ -122,23 +123,29 @@ npm run docs
|
|
|
122
123
|
- Provides prebuilt binaries via `prebuildify` for common platforms
|
|
123
124
|
- Supports both ESM and CJS module formats
|
|
124
125
|
|
|
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`
|
|
131
|
+
|
|
125
132
|
### Testing Strategy
|
|
126
133
|
- Jest for both CJS and ESM test suites
|
|
127
134
|
- Platform-specific test expectations handled via `isWindows`, `isMacOS`, `isLinux` helpers
|
|
128
135
|
- Memory leak testing with garbage collection monitoring
|
|
129
136
|
- Coverage thresholds: 80% for all metrics
|
|
130
137
|
|
|
131
|
-
###
|
|
132
|
-
-
|
|
133
|
-
-
|
|
134
|
-
-
|
|
135
|
-
-
|
|
136
|
-
-
|
|
137
|
-
-
|
|
138
|
-
-
|
|
139
|
-
-
|
|
140
|
-
-
|
|
141
|
-
-
|
|
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
|
|
142
149
|
|
|
143
150
|
### Timeout Handling
|
|
144
151
|
- Default timeout for volume operations to handle unresponsive network mounts
|
package/CONTRIBUTING.md
CHANGED
|
@@ -54,18 +54,59 @@ into account both Windows and POSIX systems.
|
|
|
54
54
|
**Why**: Windows Command Prompt/PowerShell parses the entire command line before execution, including the Unix-specific parts that would never run on Windows. Even though constructs like `node scripts/is-platform.mjs win32 || <unix-command>` would exit early on Windows, the shell still tries to parse the syntax after `||`.
|
|
55
55
|
|
|
56
56
|
**Solution**: For platform-specific npm scripts that use shell operators:
|
|
57
|
+
|
|
57
58
|
- Create a wrapper Node.js script that handles platform detection internally (see `scripts/clang-tidy.mjs`)
|
|
58
59
|
- The wrapper can use `process.platform` or `os.platform()` to detect Windows and exit early
|
|
59
60
|
- Unix-specific commands can then be spawned using `child_process.spawn()` with `sh -c`
|
|
60
61
|
|
|
61
62
|
**Example**: The `clang-tidy` npm script was moved from:
|
|
63
|
+
|
|
62
64
|
```json
|
|
63
65
|
"clang-tidy": "node scripts/is-platform.mjs win32 || (npm run configure && bear -- npm run node-gyp-rebuild && find src -name '*.cpp' -o -name '*.h' | grep -E '\\.(cpp|h)$' | grep -v -E '(windows|darwin)/' | xargs clang-tidy)"
|
|
64
66
|
```
|
|
65
67
|
|
|
66
68
|
To:
|
|
69
|
+
|
|
67
70
|
```json
|
|
68
71
|
"clang-tidy": "node scripts/clang-tidy.mjs"
|
|
69
72
|
```
|
|
70
73
|
|
|
71
74
|
Where the script handles platform detection and command execution internally.
|
|
75
|
+
|
|
76
|
+
## npm Script Naming Conventions
|
|
77
|
+
|
|
78
|
+
This project follows consistent naming patterns for npm scripts to improve discoverability and maintainability:
|
|
79
|
+
|
|
80
|
+
### Action:Target Format
|
|
81
|
+
|
|
82
|
+
Scripts follow an `action:target` pattern where:
|
|
83
|
+
|
|
84
|
+
- **action**: The operation being performed (`build`, `clean`, `lint`, `test`)
|
|
85
|
+
- **target**: What the action operates on (`native`, `ts`, `dist`)
|
|
86
|
+
|
|
87
|
+
Examples:
|
|
88
|
+
|
|
89
|
+
- `build:native` - Build native C++ code
|
|
90
|
+
- `lint:ts` - Lint TypeScript code
|
|
91
|
+
- `clean:dist` - Clean distribution files
|
|
92
|
+
|
|
93
|
+
### Parallel Execution
|
|
94
|
+
|
|
95
|
+
Actions that have multiple targets can be run in parallel using wildcards:
|
|
96
|
+
|
|
97
|
+
- `npm run clean` runs all `clean:*` scripts
|
|
98
|
+
- `npm run lint` runs all `lint:*` scripts
|
|
99
|
+
- Uses `run-p` from npm-run-all for parallel execution
|
|
100
|
+
|
|
101
|
+
### Special Namespaces
|
|
102
|
+
|
|
103
|
+
- **memory:\*** - Memory testing scripts that should not run automatically with `test:*`
|
|
104
|
+
- `memory:test` - Comprehensive memory testing suite
|
|
105
|
+
- Run with `ENABLE_ASAN=1` to include sanitizer tests
|
|
106
|
+
|
|
107
|
+
### Naming Guidelines
|
|
108
|
+
|
|
109
|
+
- Use explicit names to avoid ambiguity (e.g., `configure:native` instead of just `configure`)
|
|
110
|
+
- Group related scripts by action prefix for easy wildcard execution
|
|
111
|
+
- Avoid names that could cause npm lifecycle conflicts (e.g., `prebuild` vs `build`)
|
|
112
|
+
- Use descriptive suffixes that clearly indicate the target or purpose
|