@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.
- package/CHANGELOG.md +11 -6
- package/CLAUDE.md +160 -136
- package/CODE_OF_CONDUCT.md +11 -11
- package/CONTRIBUTING.md +2 -2
- package/README.md +34 -84
- package/binding.gyp +98 -23
- package/claude.sh +23 -0
- package/dist/index.cjs +53 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +52 -21
- package/dist/index.mjs.map +1 -1
- package/{C++_REVIEW_TODO.md → doc/C++_REVIEW_TODO.md} +97 -25
- package/doc/GPG_RELEASE_HOWTO.md +505 -0
- package/doc/MACOS_API_REFERENCE.md +469 -0
- package/doc/SECURITY_AUDIT_2025.md +809 -0
- package/doc/SSH_RELEASE_HOWTO.md +207 -0
- package/doc/WINDOWS_API_REFERENCE.md +422 -0
- package/doc/WINDOWS_ARM64_SECURITY.md +161 -0
- package/doc/WINDOWS_DEBUG_GUIDE.md +96 -0
- package/doc/examples.md +267 -0
- package/doc/gotchas.md +297 -0
- package/doc/logo.png +0 -0
- package/doc/logo.svg +85 -0
- package/doc/macos-asan-sip-issue.md +71 -0
- package/doc/social.png +0 -0
- package/doc/social.svg +125 -0
- package/doc/windows-build.md +226 -0
- package/doc/windows-clang-tidy.md +72 -0
- package/doc/windows-memory-testing.md +108 -0
- package/doc/windows-prebuildify-arm64.md +232 -0
- package/jest.config.cjs +24 -0
- package/package.json +68 -44
- package/prebuilds/darwin-arm64/@photostructure+fs-metadata.glibc.node +0 -0
- package/prebuilds/darwin-x64/@photostructure+fs-metadata.glibc.node +0 -0
- package/prebuilds/linux-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-arm64/@photostructure+fs-metadata.glibc.node +0 -0
- package/prebuilds/win32-x64/@photostructure+fs-metadata.glibc.node +0 -0
- package/scripts/check-memory.ts +186 -0
- package/scripts/clang-tidy.ts +832 -0
- package/scripts/install.cjs +42 -0
- package/scripts/is-platform.mjs +1 -1
- package/scripts/macos-asan.sh +155 -0
- package/scripts/post-build.mjs +3 -3
- package/scripts/prebuild-linux-glibc.sh +119 -0
- package/scripts/prebuildify-wrapper.ts +77 -0
- package/scripts/precommit.ts +70 -0
- package/scripts/sanitizers-test.sh +7 -1
- package/scripts/{configure.mjs → setup-native.mjs} +4 -1
- package/src/binding.cpp +1 -1
- package/src/common/error_utils.h +0 -6
- package/src/common/volume_metadata.h +6 -0
- package/src/darwin/hidden.cpp +73 -25
- package/src/darwin/path_security.h +149 -0
- package/src/darwin/raii_utils.h +104 -4
- package/src/darwin/volume_metadata.cpp +132 -58
- package/src/darwin/volume_mount_points.cpp +80 -47
- package/src/hidden.ts +36 -13
- package/src/linux/gio_mount_points.cpp +17 -18
- package/src/linux/gio_utils.cpp +92 -37
- package/src/linux/gio_utils.h +11 -5
- package/src/linux/gio_volume_metadata.cpp +111 -48
- package/src/linux/volume_metadata.cpp +67 -4
- package/src/object.ts +1 -0
- package/src/options.ts +6 -0
- package/src/path.ts +11 -0
- package/src/platform.ts +25 -0
- package/src/remote_info.ts +5 -3
- package/src/stack_path.ts +8 -6
- package/src/string_enum.ts +1 -0
- package/src/test-utils/benchmark-harness.ts +192 -0
- package/src/test-utils/debuglog-child.ts +30 -2
- package/src/test-utils/debuglog-enabled-child.ts +38 -8
- package/src/test-utils/jest-setup.ts +14 -0
- package/src/test-utils/memory-test-core.ts +336 -0
- package/src/test-utils/memory-test-runner.ts +108 -0
- package/src/test-utils/platform.ts +46 -1
- package/src/test-utils/worker-thread-helper.cjs +157 -26
- package/src/types/native_bindings.ts +1 -1
- package/src/types/options.ts +6 -0
- package/src/windows/drive_status.h +133 -163
- package/src/windows/error_utils.h +54 -3
- package/src/windows/fs_meta.h +1 -1
- package/src/windows/hidden.cpp +60 -43
- package/src/windows/security_utils.h +250 -0
- package/src/windows/string.h +68 -11
- package/src/windows/system_volume.h +1 -1
- package/src/windows/thread_pool.h +206 -0
- package/src/windows/volume_metadata.cpp +11 -6
- package/src/windows/volume_mount_points.cpp +8 -7
- package/src/windows/windows_arch.h +39 -0
- package/scripts/check-memory.mjs +0 -123
- package/scripts/clang-tidy.mjs +0 -73
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// windows_arch.h - Architecture defines for Windows builds
|
|
2
|
+
// This file ensures architecture macros are defined before including Windows
|
|
3
|
+
// headers
|
|
4
|
+
|
|
5
|
+
#ifndef FS_META_WINDOWS_ARCH_H
|
|
6
|
+
#define FS_META_WINDOWS_ARCH_H
|
|
7
|
+
|
|
8
|
+
// Define architecture macros based on predefined compiler macros
|
|
9
|
+
#if defined(_M_AMD64) || defined(_M_X64) || defined(_AMD64_) || \
|
|
10
|
+
defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) || \
|
|
11
|
+
defined(__amd64)
|
|
12
|
+
#ifndef _M_X64
|
|
13
|
+
#define _M_X64 100
|
|
14
|
+
#endif
|
|
15
|
+
#ifndef _WIN64
|
|
16
|
+
#define _WIN64
|
|
17
|
+
#endif
|
|
18
|
+
#ifndef _AMD64_
|
|
19
|
+
#define _AMD64_
|
|
20
|
+
#endif
|
|
21
|
+
#elif defined(_M_ARM64) || defined(__aarch64__) || defined(_ARM64_) || \
|
|
22
|
+
defined(__arm64)
|
|
23
|
+
#ifndef _M_ARM64
|
|
24
|
+
#define _M_ARM64 1
|
|
25
|
+
#endif
|
|
26
|
+
#ifndef _WIN64
|
|
27
|
+
#define _WIN64
|
|
28
|
+
#endif
|
|
29
|
+
#elif defined(_M_IX86) || defined(__i386__) || defined(__i386) || \
|
|
30
|
+
defined(_X86_) || defined(__X86__)
|
|
31
|
+
#ifndef _M_IX86
|
|
32
|
+
#define _M_IX86 600
|
|
33
|
+
#endif
|
|
34
|
+
#endif
|
|
35
|
+
|
|
36
|
+
// Now it's safe to include Windows headers
|
|
37
|
+
#include <windows.h>
|
|
38
|
+
|
|
39
|
+
#endif // FS_META_WINDOWS_ARCH_H
|
package/scripts/check-memory.mjs
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Cross-platform memory checking script
|
|
5
|
-
* Runs JavaScript memory tests on all platforms
|
|
6
|
-
* Runs valgrind and ASAN tests only on Linux
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { execFileSync, execSync } from "child_process";
|
|
10
|
-
import os from "os";
|
|
11
|
-
import path from "path";
|
|
12
|
-
import { fileURLToPath } from "url";
|
|
13
|
-
|
|
14
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
-
const __dirname = path.dirname(__filename);
|
|
16
|
-
|
|
17
|
-
// Colors for output
|
|
18
|
-
const colors = {
|
|
19
|
-
RED: "\x1b[31m",
|
|
20
|
-
GREEN: "\x1b[32m",
|
|
21
|
-
YELLOW: "\x1b[33m",
|
|
22
|
-
BLUE: "\x1b[34m",
|
|
23
|
-
RESET: "\x1b[0m",
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
// Use colors only if not on Windows
|
|
27
|
-
const isWindows = os.platform() === "win32";
|
|
28
|
-
const color = (colorCode, text) =>
|
|
29
|
-
isWindows ? text : `${colorCode}${text}${colors.RESET}`;
|
|
30
|
-
|
|
31
|
-
console.log(color(colors.BLUE, "=== Memory Leak Detection Suite ==="));
|
|
32
|
-
|
|
33
|
-
let exitCode = 0;
|
|
34
|
-
|
|
35
|
-
// 1. Run JavaScript memory tests (all platforms)
|
|
36
|
-
console.log(color(colors.YELLOW, "\nRunning JavaScript memory tests..."));
|
|
37
|
-
try {
|
|
38
|
-
// Use node to execute jest.js for cross-platform compatibility
|
|
39
|
-
const jestPath = path.join("node_modules", "jest", "bin", "jest.js");
|
|
40
|
-
const nodeExe = process.execPath;
|
|
41
|
-
const args = [jestPath, "--no-coverage", "src/memory.test.ts"];
|
|
42
|
-
|
|
43
|
-
// Debug output
|
|
44
|
-
console.log("Debug: Node executable:", nodeExe);
|
|
45
|
-
console.log("Debug: Jest path:", jestPath);
|
|
46
|
-
console.log("Debug: Full command:", nodeExe, args.join(" "));
|
|
47
|
-
console.log("Debug: Current directory:", process.cwd());
|
|
48
|
-
console.log("Debug: Platform:", os.platform());
|
|
49
|
-
console.log("Debug: Node version:", process.version);
|
|
50
|
-
|
|
51
|
-
execFileSync(nodeExe, args, {
|
|
52
|
-
stdio: "inherit",
|
|
53
|
-
env: {
|
|
54
|
-
...process.env,
|
|
55
|
-
TEST_MEMORY: "1",
|
|
56
|
-
TEST_ESM: "1",
|
|
57
|
-
NODE_OPTIONS: "--expose-gc --experimental-vm-modules --no-warnings",
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
console.log(color(colors.GREEN, "✓ JavaScript memory tests passed"));
|
|
61
|
-
} catch (error) {
|
|
62
|
-
console.log(color(colors.RED, "✗ JavaScript memory tests failed"));
|
|
63
|
-
console.error("Debug: Error details:", error.message);
|
|
64
|
-
if (error.code) {
|
|
65
|
-
console.error("Debug: Error code:", error.code);
|
|
66
|
-
}
|
|
67
|
-
if (error.signal) {
|
|
68
|
-
console.error("Debug: Error signal:", error.signal);
|
|
69
|
-
}
|
|
70
|
-
exitCode = 1;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// 2. Run valgrind if available and on Linux
|
|
74
|
-
if (os.platform() === "linux") {
|
|
75
|
-
try {
|
|
76
|
-
execFileSync("which", ["valgrind"], { stdio: "ignore" });
|
|
77
|
-
console.log(color(colors.YELLOW, "\nRunning valgrind memory analysis..."));
|
|
78
|
-
try {
|
|
79
|
-
const valgrindScript = path.join(__dirname, "valgrind-test.sh");
|
|
80
|
-
execSync(valgrindScript, { stdio: "inherit" });
|
|
81
|
-
console.log(color(colors.GREEN, "✓ Valgrind tests passed"));
|
|
82
|
-
} catch {
|
|
83
|
-
console.log(color(colors.RED, "✗ Valgrind tests failed"));
|
|
84
|
-
exitCode = 1;
|
|
85
|
-
}
|
|
86
|
-
} catch {
|
|
87
|
-
console.log(color(colors.YELLOW, "\nValgrind not available. Skipping."));
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// 3. Run Address Sanitizer and Leak Sanitizer if requested (Linux only)
|
|
92
|
-
if (os.platform() === "linux") {
|
|
93
|
-
console.log(
|
|
94
|
-
color(
|
|
95
|
-
colors.YELLOW,
|
|
96
|
-
"\nRunning AddressSanitizer and LeakSanitizer tests...",
|
|
97
|
-
),
|
|
98
|
-
);
|
|
99
|
-
try {
|
|
100
|
-
const asanScript = path.join(__dirname, "sanitizers-test.sh");
|
|
101
|
-
execSync(asanScript, { stdio: "inherit" });
|
|
102
|
-
console.log(
|
|
103
|
-
color(colors.GREEN, "✓ AddressSanitizer and LeakSanitizer tests passed"),
|
|
104
|
-
);
|
|
105
|
-
} catch {
|
|
106
|
-
console.log(
|
|
107
|
-
color(colors.RED, "✗ AddressSanitizer or LeakSanitizer tests failed"),
|
|
108
|
-
);
|
|
109
|
-
exitCode = 1;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (exitCode === 0) {
|
|
114
|
-
console.log(
|
|
115
|
-
color(colors.GREEN, "\n=== All memory tests completed successfully! ==="),
|
|
116
|
-
);
|
|
117
|
-
} else {
|
|
118
|
-
console.log(
|
|
119
|
-
color(colors.RED, "\n=== Memory tests failed! See output above. ==="),
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
process.exit(exitCode);
|
package/scripts/clang-tidy.mjs
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { execSync, spawn } from "child_process";
|
|
3
|
-
import { platform } from "os";
|
|
4
|
-
|
|
5
|
-
// Skip clang-tidy on Windows
|
|
6
|
-
if (platform() === "win32") {
|
|
7
|
-
console.log("Skipping clang-tidy on Windows platform");
|
|
8
|
-
process.exit(0);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// Check for required tools
|
|
12
|
-
function checkCommand(command, installHint) {
|
|
13
|
-
try {
|
|
14
|
-
execSync(`which ${command}`, { stdio: "ignore" });
|
|
15
|
-
return true;
|
|
16
|
-
} catch {
|
|
17
|
-
console.error(`Error: '${command}' not found in PATH.`);
|
|
18
|
-
console.error(`To install: ${installHint}`);
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const isMacOS = platform() === "darwin";
|
|
24
|
-
const isLinux = platform() === "linux";
|
|
25
|
-
|
|
26
|
-
let hasAllTools = true;
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
!checkCommand(
|
|
30
|
-
"bear",
|
|
31
|
-
isLinux
|
|
32
|
-
? "sudo apt-get install bear"
|
|
33
|
-
: isMacOS
|
|
34
|
-
? "brew install bear"
|
|
35
|
-
: "see https://github.com/rizsotto/Bear",
|
|
36
|
-
)
|
|
37
|
-
) {
|
|
38
|
-
hasAllTools = false;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (
|
|
42
|
-
!checkCommand(
|
|
43
|
-
"clang-tidy",
|
|
44
|
-
isLinux
|
|
45
|
-
? "sudo apt-get install clang-tidy"
|
|
46
|
-
: isMacOS
|
|
47
|
-
? "brew install llvm && alias clang-tidy=$(brew --prefix llvm)/bin/clang-tidy"
|
|
48
|
-
: "see https://clang.llvm.org/extra/clang-tidy/",
|
|
49
|
-
)
|
|
50
|
-
) {
|
|
51
|
-
hasAllTools = false;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (!hasAllTools) {
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Run the clang-tidy command on Unix platforms
|
|
59
|
-
const command = `npm run configure:native && 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`;
|
|
60
|
-
|
|
61
|
-
const shell = spawn("sh", ["-c", command], {
|
|
62
|
-
stdio: "inherit",
|
|
63
|
-
shell: false,
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
shell.on("exit", (code) => {
|
|
67
|
-
process.exit(code || 0);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
shell.on("error", (err) => {
|
|
71
|
-
console.error("Failed to run clang-tidy:", err);
|
|
72
|
-
process.exit(1);
|
|
73
|
-
});
|