@photostructure/fs-metadata 0.3.2 → 0.3.3
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 +13 -3
- package/README.md +3 -3
- package/dist/index.cjs +324 -215
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +329 -215
- package/dist/index.mjs.map +1 -1
- package/dist/types/debuglog.d.ts +2 -6
- package/dist/types/defer.d.ts +1 -2
- package/dist/types/dirname.d.ts +1 -0
- package/dist/types/hidden.d.ts +5 -42
- package/dist/types/index.d.ts +91 -2
- package/dist/types/linux/mount_points.d.ts +2 -2
- package/dist/types/linux/mtab.d.ts +2 -2
- package/dist/types/mount_point.d.ts +1 -46
- package/dist/types/options.d.ts +1 -47
- package/dist/types/platform.d.ts +1 -0
- package/dist/types/remote_info.d.ts +2 -34
- package/dist/types/stack_path.d.ts +2 -0
- package/dist/types/system_volume.d.ts +2 -2
- package/dist/types/types/hidden_metadata.d.ts +32 -0
- package/dist/types/types/mount_point.d.ts +46 -0
- package/dist/types/types/native_bindings.d.ts +3 -3
- package/dist/types/types/options.d.ts +47 -0
- package/dist/types/types/remote_info.d.ts +33 -0
- package/dist/types/types/volume_metadata.d.ts +46 -0
- package/dist/types/unc.d.ts +1 -1
- package/dist/types/units.d.ts +25 -3
- package/dist/types/volume_metadata.d.ts +4 -50
- package/dist/types/volume_mount_points.d.ts +3 -6
- package/jest.config.base.cjs +63 -0
- package/jest.config.cjs +3 -16
- package/package.json +12 -15
- package/prebuilds/darwin-arm64/@photostructure+fs-metadata.glibc.node +0 -0
- package/prebuilds/win32-x64/@photostructure+fs-metadata.glibc.node +0 -0
- package/src/async.ts +9 -0
- package/src/debuglog.ts +6 -2
- package/src/defer.ts +1 -1
- package/src/dirname.ts +13 -0
- package/src/global.d.ts +1 -0
- package/src/hidden.ts +6 -42
- package/src/{exports.ts → index.ts} +75 -30
- package/src/linux/mount_points.ts +4 -2
- package/src/linux/mtab.ts +3 -3
- package/src/mount_point.ts +2 -53
- package/src/options.ts +4 -53
- package/src/path.ts +12 -5
- package/src/platform.ts +5 -5
- package/src/remote_info.ts +44 -49
- package/src/stack_path.ts +71 -0
- package/src/system_volume.ts +3 -6
- package/src/test-utils/assert.ts +1 -1
- package/src/test-utils/debuglog-child.ts +15 -0
- package/src/types/hidden_metadata.ts +38 -0
- package/src/types/mount_point.ts +53 -0
- package/src/types/native_bindings.ts +3 -3
- package/src/types/options.ts +54 -0
- package/src/types/remote_info.ts +35 -0
- package/src/types/volume_metadata.ts +52 -0
- package/src/unc.ts +1 -1
- package/src/units.ts +39 -7
- package/src/volume_metadata.ts +9 -66
- package/src/volume_mount_points.ts +3 -6
- package/tsup.config.ts +1 -0
- package/dist/types/exports.d.ts +0 -99
- package/dist/types/setup.d.ts +0 -2
- package/src/index.cts +0 -15
- package/src/index.mts +0 -17
- package/src/setup.ts +0 -69
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// src/types/volume_metadata.ts
|
|
2
|
+
|
|
3
|
+
import type { MountPoint } from "./mount_point.js";
|
|
4
|
+
import type { RemoteInfo } from "./remote_info.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Metadata associated to a volume.
|
|
8
|
+
*
|
|
9
|
+
* @see https://en.wikipedia.org/wiki/Volume_(computing)
|
|
10
|
+
*/
|
|
11
|
+
export interface VolumeMetadata extends RemoteInfo, MountPoint {
|
|
12
|
+
/**
|
|
13
|
+
* The name of the partition
|
|
14
|
+
*/
|
|
15
|
+
label?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Total size in bytes
|
|
18
|
+
*/
|
|
19
|
+
size?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Used size in bytes
|
|
22
|
+
*/
|
|
23
|
+
used?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Available size in bytes
|
|
26
|
+
*/
|
|
27
|
+
available?: number;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Path to the device or service that the mountpoint is from.
|
|
31
|
+
*
|
|
32
|
+
* Examples include `/dev/sda1`, `nfs-server:/export`,
|
|
33
|
+
* `//username@remoteHost/remoteShare`, or `//cifs-server/share`.
|
|
34
|
+
*
|
|
35
|
+
* May be undefined for remote volumes.
|
|
36
|
+
*/
|
|
37
|
+
mountFrom?: string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The name of the mount. This may match the resolved mountPoint.
|
|
41
|
+
*/
|
|
42
|
+
mountName?: string;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* UUID for the volume, like "c9b08f6e-b392-11ef-bf19-4b13bb7db4b4".
|
|
46
|
+
*
|
|
47
|
+
* On windows, this _may_ be the 128-bit volume UUID, but if that is not
|
|
48
|
+
* available, like in the case of remote volumes, we fallback to the 32-bit
|
|
49
|
+
* volume serial number, rendered in lowercase hexadecimal.
|
|
50
|
+
*/
|
|
51
|
+
uuid?: string;
|
|
52
|
+
}
|
package/src/unc.ts
CHANGED
package/src/units.ts
CHANGED
|
@@ -1,31 +1,63 @@
|
|
|
1
1
|
// src/units.ts
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Milliseconds in a second
|
|
5
|
+
*/
|
|
6
|
+
export const SecondMs = 1000;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Milliseconds in a minute
|
|
10
|
+
*/
|
|
11
|
+
export const MinuteMs = 60 * SecondMs;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Milliseconds in an hour
|
|
15
|
+
*/
|
|
16
|
+
export const HourMs = 60 * MinuteMs;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Milliseconds in a day
|
|
20
|
+
*/
|
|
21
|
+
export const DayMs = 24 * HourMs;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Kibibyte (KiB) = 1024 bytes
|
|
5
25
|
* @see https://en.wikipedia.org/wiki/Kibibyte
|
|
6
26
|
*/
|
|
7
27
|
export const KiB = 1024;
|
|
8
28
|
|
|
9
29
|
/**
|
|
10
|
-
* MiB = 1024 KiB
|
|
30
|
+
* Mebibyte (MiB) = 1024 KiB
|
|
11
31
|
* @see https://en.wikipedia.org/wiki/Mebibyte
|
|
12
32
|
*/
|
|
13
33
|
export const MiB = 1024 * KiB;
|
|
14
34
|
|
|
15
35
|
/**
|
|
16
|
-
* GiB
|
|
36
|
+
* Gibibyte (GiB)= 1024 MiB
|
|
17
37
|
* @see https://en.wikipedia.org/wiki/Gibibyte
|
|
18
38
|
*/
|
|
19
39
|
export const GiB = 1024 * MiB;
|
|
20
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Tebibyte (TiB) = 1024 GiB
|
|
43
|
+
*
|
|
44
|
+
* @see https://en.wikipedia.org/wiki/Byte#Multiple-byte_units
|
|
45
|
+
*/
|
|
46
|
+
export const TiB = 1024 * GiB;
|
|
47
|
+
|
|
48
|
+
const f = 1023.995 / 1024;
|
|
49
|
+
|
|
21
50
|
export function fmtBytes(bytes: number): string {
|
|
22
|
-
if (bytes <
|
|
51
|
+
if (bytes < 1023.5) {
|
|
52
|
+
bytes = Math.round(bytes);
|
|
23
53
|
return `${bytes} B`;
|
|
24
|
-
} else if (bytes < MiB) {
|
|
54
|
+
} else if (bytes < MiB * f) {
|
|
25
55
|
return `${(bytes / KiB).toFixed(2)} KiB`;
|
|
26
|
-
} else if (bytes < GiB) {
|
|
56
|
+
} else if (bytes < GiB * f) {
|
|
27
57
|
return `${(bytes / MiB).toFixed(2)} MiB`;
|
|
28
|
-
} else {
|
|
58
|
+
} else if (bytes < TiB * f) {
|
|
29
59
|
return `${(bytes / GiB).toFixed(2)} GiB`;
|
|
60
|
+
} else {
|
|
61
|
+
return `${(bytes / TiB).toFixed(2)} TiB`;
|
|
30
62
|
}
|
|
31
63
|
}
|
package/src/volume_metadata.ts
CHANGED
|
@@ -9,83 +9,28 @@ import {
|
|
|
9
9
|
type MtabVolumeMetadata,
|
|
10
10
|
mountEntryToPartialVolumeMetadata,
|
|
11
11
|
} from "./linux/mtab.js";
|
|
12
|
-
import type { MountPoint } from "./mount_point.js";
|
|
13
12
|
import { compactValues } from "./object.js";
|
|
14
|
-
import {
|
|
15
|
-
IncludeSystemVolumesDefault,
|
|
16
|
-
type Options,
|
|
17
|
-
optionsWithDefaults,
|
|
18
|
-
} from "./options.js";
|
|
13
|
+
import { IncludeSystemVolumesDefault, optionsWithDefaults } from "./options.js";
|
|
19
14
|
import { normalizePath } from "./path.js";
|
|
20
15
|
import { isLinux, isWindows } from "./platform.js";
|
|
21
|
-
import {
|
|
22
|
-
type RemoteInfo,
|
|
23
|
-
extractRemoteInfo,
|
|
24
|
-
isRemoteFsType,
|
|
25
|
-
} from "./remote_info.js";
|
|
16
|
+
import { extractRemoteInfo, isRemoteFsType } from "./remote_info.js";
|
|
26
17
|
import { isBlank, isNotBlank } from "./string.js";
|
|
27
18
|
import { assignSystemVolume } from "./system_volume.js";
|
|
28
19
|
import type {
|
|
29
20
|
GetVolumeMetadataOptions,
|
|
30
21
|
NativeBindingsFn,
|
|
31
22
|
} from "./types/native_bindings.js";
|
|
23
|
+
import type { Options } from "./types/options.js";
|
|
24
|
+
import type { VolumeMetadata } from "./types/volume_metadata.js";
|
|
32
25
|
import { parseUNCPath } from "./unc.js";
|
|
33
26
|
import { extractUUID } from "./uuid.js";
|
|
34
27
|
import {
|
|
35
28
|
VolumeHealthStatuses,
|
|
36
29
|
directoryStatus,
|
|
37
30
|
} from "./volume_health_status.js";
|
|
38
|
-
import {
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Metadata associated to a volume.
|
|
42
|
-
*
|
|
43
|
-
* @see https://en.wikipedia.org/wiki/Volume_(computing)
|
|
44
|
-
*/
|
|
45
|
-
export interface VolumeMetadata extends RemoteInfo, MountPoint {
|
|
46
|
-
/**
|
|
47
|
-
* The name of the partition
|
|
48
|
-
*/
|
|
49
|
-
label?: string;
|
|
50
|
-
/**
|
|
51
|
-
* Total size in bytes
|
|
52
|
-
*/
|
|
53
|
-
size?: number;
|
|
54
|
-
/**
|
|
55
|
-
* Used size in bytes
|
|
56
|
-
*/
|
|
57
|
-
used?: number;
|
|
58
|
-
/**
|
|
59
|
-
* Available size in bytes
|
|
60
|
-
*/
|
|
61
|
-
available?: number;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Path to the device or service that the mountpoint is from.
|
|
65
|
-
*
|
|
66
|
-
* Examples include `/dev/sda1`, `nfs-server:/export`,
|
|
67
|
-
* `//username@remoteHost/remoteShare`, or `//cifs-server/share`.
|
|
68
|
-
*
|
|
69
|
-
* May be undefined for remote volumes.
|
|
70
|
-
*/
|
|
71
|
-
mountFrom?: string;
|
|
31
|
+
import { getVolumeMountPointsImpl } from "./volume_mount_points.js";
|
|
72
32
|
|
|
73
|
-
|
|
74
|
-
* The name of the mount. This may match the resolved mountPoint.
|
|
75
|
-
*/
|
|
76
|
-
mountName?: string;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* UUID for the volume, like "c9b08f6e-b392-11ef-bf19-4b13bb7db4b4".
|
|
80
|
-
*
|
|
81
|
-
* On windows, this _may_ be the 128-bit volume UUID, but if that is not
|
|
82
|
-
* available, like in the case of remote volumes, we fallback to the 32-bit
|
|
83
|
-
* volume serial number, rendered in lowercase hexadecimal.
|
|
84
|
-
*/
|
|
85
|
-
uuid?: string;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export async function getVolumeMetadata(
|
|
33
|
+
export async function getVolumeMetadataImpl(
|
|
89
34
|
o: GetVolumeMetadataOptions & Options,
|
|
90
35
|
nativeFn: NativeBindingsFn,
|
|
91
36
|
): Promise<VolumeMetadata> {
|
|
@@ -211,7 +156,7 @@ async function _getVolumeMetadata(
|
|
|
211
156
|
return compactValues(result) as VolumeMetadata;
|
|
212
157
|
}
|
|
213
158
|
|
|
214
|
-
export async function
|
|
159
|
+
export async function getAllVolumeMetadataImpl(
|
|
215
160
|
opts: Required<Options> & {
|
|
216
161
|
includeSystemVolumes?: boolean;
|
|
217
162
|
maxConcurrency?: number;
|
|
@@ -221,7 +166,7 @@ export async function getAllVolumeMetadata(
|
|
|
221
166
|
const o = optionsWithDefaults(opts);
|
|
222
167
|
debug("[getAllVolumeMetadata] starting with options: %o", o);
|
|
223
168
|
|
|
224
|
-
const arr = await
|
|
169
|
+
const arr = await getVolumeMountPointsImpl(o, nativeFn);
|
|
225
170
|
debug("[getAllVolumeMetadata] found %d mount points", arr.length);
|
|
226
171
|
|
|
227
172
|
const unhealthyMountPoints = arr
|
|
@@ -269,7 +214,7 @@ export async function getAllVolumeMetadata(
|
|
|
269
214
|
? healthy
|
|
270
215
|
: healthy.filter((ea) => !ea.isSystemVolume),
|
|
271
216
|
fn: async (mp) =>
|
|
272
|
-
|
|
217
|
+
getVolumeMetadataImpl({ ...mp, ...o }, nativeFn).catch((error) => ({
|
|
273
218
|
mountPoint: mp.mountPoint,
|
|
274
219
|
error,
|
|
275
220
|
})),
|
|
@@ -290,5 +235,3 @@ export async function getAllVolumeMetadata(
|
|
|
290
235
|
}) as VolumeMetadata,
|
|
291
236
|
);
|
|
292
237
|
}
|
|
293
|
-
|
|
294
|
-
export const _ = undefined;
|
|
@@ -4,9 +4,7 @@ import { uniqBy } from "./array.js";
|
|
|
4
4
|
import { mapConcurrent, withTimeout } from "./async.js";
|
|
5
5
|
import { debug } from "./debuglog.js";
|
|
6
6
|
import { getLinuxMountPoints } from "./linux/mount_points.js";
|
|
7
|
-
import { MountPoint } from "./mount_point.js";
|
|
8
7
|
import { compactValues } from "./object.js";
|
|
9
|
-
import { Options } from "./options.js";
|
|
10
8
|
import { isMacOS, isWindows } from "./platform.js";
|
|
11
9
|
import {
|
|
12
10
|
isBlank,
|
|
@@ -15,7 +13,9 @@ import {
|
|
|
15
13
|
toNotBlank,
|
|
16
14
|
} from "./string.js";
|
|
17
15
|
import { assignSystemVolume, SystemVolumeConfig } from "./system_volume.js";
|
|
16
|
+
import type { MountPoint } from "./types/mount_point.js";
|
|
18
17
|
import type { NativeBindingsFn } from "./types/native_bindings.js";
|
|
18
|
+
import type { Options } from "./types/options.js";
|
|
19
19
|
import { directoryStatus } from "./volume_health_status.js";
|
|
20
20
|
|
|
21
21
|
export type GetVolumeMountPointOptions = Partial<
|
|
@@ -29,10 +29,7 @@ export type GetVolumeMountPointOptions = Partial<
|
|
|
29
29
|
SystemVolumeConfig
|
|
30
30
|
>;
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
* Helper function for {@link getVolumeMountPoints}.
|
|
34
|
-
*/
|
|
35
|
-
export async function getVolumeMountPoints(
|
|
32
|
+
export async function getVolumeMountPointsImpl(
|
|
36
33
|
opts: Required<GetVolumeMountPointOptions>,
|
|
37
34
|
nativeFn: NativeBindingsFn,
|
|
38
35
|
): Promise<MountPoint[]> {
|
package/tsup.config.ts
CHANGED
package/dist/types/exports.d.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import type { HiddenMetadata, HideMethod, SetHiddenResult } from "./hidden.js";
|
|
2
|
-
import type { MountPoint } from "./mount_point.js";
|
|
3
|
-
import type { Options } from "./options.js";
|
|
4
|
-
import { IncludeSystemVolumesDefault, LinuxMountTablePathsDefault, OptionsDefault, optionsWithDefaults, SystemFsTypesDefault, SystemPathPatternsDefault, TimeoutMsDefault } from "./options.js";
|
|
5
|
-
import type { StringEnum, StringEnumKeys, StringEnumType } from "./string_enum.js";
|
|
6
|
-
import type { SystemVolumeConfig } from "./system_volume.js";
|
|
7
|
-
import type { VolumeHealthStatus } from "./volume_health_status.js";
|
|
8
|
-
import { VolumeHealthStatuses } from "./volume_health_status.js";
|
|
9
|
-
import type { VolumeMetadata } from "./volume_metadata.js";
|
|
10
|
-
import type { GetVolumeMountPointOptions } from "./volume_mount_points.js";
|
|
11
|
-
export type { GetVolumeMountPointOptions, HiddenMetadata, HideMethod, MountPoint, Options, SetHiddenResult, StringEnum, StringEnumKeys, StringEnumType, SystemVolumeConfig, VolumeHealthStatus, VolumeMetadata, };
|
|
12
|
-
/**
|
|
13
|
-
* List all active local and remote mount points on the system.
|
|
14
|
-
*
|
|
15
|
-
* Only readable directories are included in the results.
|
|
16
|
-
*
|
|
17
|
-
* Note that on Windows, `timeoutMs` will be used **per system call** and not
|
|
18
|
-
* for the entire operation.
|
|
19
|
-
*
|
|
20
|
-
* @param opts Optional filesystem operation settings to override default values
|
|
21
|
-
*/
|
|
22
|
-
export declare function getVolumeMountPoints(opts?: Partial<GetVolumeMountPointOptions>): Promise<MountPoint[]>;
|
|
23
|
-
/**
|
|
24
|
-
* Get metadata for the volume at the given mount point.
|
|
25
|
-
*
|
|
26
|
-
* @param mountPoint Must be a non-blank string
|
|
27
|
-
* @param opts Optional filesystem operation settings
|
|
28
|
-
*/
|
|
29
|
-
export declare function getVolumeMetadata(mountPoint: string, opts?: Partial<Pick<Options, "timeoutMs">>): Promise<VolumeMetadata>;
|
|
30
|
-
/**
|
|
31
|
-
* Retrieves metadata for all mounted volumes with optional filtering and
|
|
32
|
-
* concurrency control.
|
|
33
|
-
*
|
|
34
|
-
* @param opts - Optional configuration object
|
|
35
|
-
* @param opts.includeSystemVolumes - If true, includes system volumes in the
|
|
36
|
-
* results. Defaults to true on Windows and false elsewhere.
|
|
37
|
-
* @param opts.maxConcurrency - Maximum number of concurrent operations.
|
|
38
|
-
* Defaults to the system's available parallelism: see
|
|
39
|
-
* {@link https://nodejs.org/api/os.html#osavailableparallelism | os.availableParallelism()}
|
|
40
|
-
* @param opts.timeoutMs - Maximum time to wait for
|
|
41
|
-
* {@link getVolumeMountPoints}, as well as **each** {@link getVolumeMetadata}
|
|
42
|
-
* to complete. Defaults to {@link TimeoutMsDefault}
|
|
43
|
-
* @returns Promise that resolves to an array of either VolumeMetadata objects
|
|
44
|
-
* or error objects containing the mount point and error
|
|
45
|
-
* @throws Never - errors are caught and returned as part of the result array
|
|
46
|
-
*/
|
|
47
|
-
export declare function getAllVolumeMetadata(opts?: Partial<Options> & {
|
|
48
|
-
includeSystemVolumes?: boolean;
|
|
49
|
-
}): Promise<VolumeMetadata[]>;
|
|
50
|
-
/**
|
|
51
|
-
* Check if a file or directory is hidden.
|
|
52
|
-
*
|
|
53
|
-
* Note that `path` may be _effectively_ hidden if any of the ancestor
|
|
54
|
-
* directories are hidden: use {@link isHiddenRecursive} to check for this.
|
|
55
|
-
*
|
|
56
|
-
* @param pathname Path to file or directory
|
|
57
|
-
* @returns Promise resolving to boolean indicating hidden state
|
|
58
|
-
*/
|
|
59
|
-
export declare function isHidden(pathname: string): Promise<boolean>;
|
|
60
|
-
/**
|
|
61
|
-
* Check if a file or directory is hidden, or if any of its ancestor
|
|
62
|
-
* directories are hidden.
|
|
63
|
-
*
|
|
64
|
-
* @param pathname Path to file or directory
|
|
65
|
-
* @returns Promise resolving to boolean indicating hidden state
|
|
66
|
-
*/
|
|
67
|
-
export declare function isHiddenRecursive(pathname: string): Promise<boolean>;
|
|
68
|
-
/**
|
|
69
|
-
* Get detailed metadata about the hidden state of a file or directory.
|
|
70
|
-
*
|
|
71
|
-
* @param pathname Path to file or directory
|
|
72
|
-
* @returns Promise resolving to metadata about the hidden state
|
|
73
|
-
*/
|
|
74
|
-
export declare function getHiddenMetadata(pathname: string): Promise<HiddenMetadata>;
|
|
75
|
-
/**
|
|
76
|
-
* Set the hidden state of a file or directory
|
|
77
|
-
*
|
|
78
|
-
* @param pathname Path to file or directory
|
|
79
|
-
* @param hidden - Whether the item should be hidden (true) or visible (false)
|
|
80
|
-
* @param method Method to use for hiding the file or directory. The default
|
|
81
|
-
* is "auto", which is "dotPrefix" on Linux and macOS, and "systemFlag" on
|
|
82
|
-
* Windows. "all" will attempt to use all relevant methods for the current
|
|
83
|
-
* operating system.
|
|
84
|
-
* @returns Promise resolving the final name of the file or directory (as it
|
|
85
|
-
* will change on POSIX systems), and the action(s) taken.
|
|
86
|
-
* @throws {Error} If the file doesn't exist, permissions are insufficient, or
|
|
87
|
-
* the requested method is unsupported
|
|
88
|
-
*/
|
|
89
|
-
export declare function setHidden(pathname: string, hidden: boolean, method?: HideMethod): Promise<SetHiddenResult>;
|
|
90
|
-
export type ExportedFunctions = {
|
|
91
|
-
getVolumeMountPoints: typeof getVolumeMountPoints;
|
|
92
|
-
getVolumeMetadata: typeof getVolumeMetadata;
|
|
93
|
-
getAllVolumeMetadata: typeof getAllVolumeMetadata;
|
|
94
|
-
isHidden: typeof isHidden;
|
|
95
|
-
isHiddenRecursive: typeof isHiddenRecursive;
|
|
96
|
-
getHiddenMetadata: typeof getHiddenMetadata;
|
|
97
|
-
setHidden: typeof setHidden;
|
|
98
|
-
};
|
|
99
|
-
export { IncludeSystemVolumesDefault, LinuxMountTablePathsDefault, OptionsDefault, optionsWithDefaults, SystemFsTypesDefault, SystemPathPatternsDefault, TimeoutMsDefault, VolumeHealthStatuses, };
|
package/dist/types/setup.d.ts
DELETED
package/src/index.cts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// src/index.cts
|
|
2
|
-
|
|
3
|
-
import { setup } from "./setup.js";
|
|
4
|
-
|
|
5
|
-
export * from "./exports.js";
|
|
6
|
-
|
|
7
|
-
export const {
|
|
8
|
-
getVolumeMountPoints,
|
|
9
|
-
getVolumeMetadata,
|
|
10
|
-
getAllVolumeMetadata,
|
|
11
|
-
isHidden,
|
|
12
|
-
isHiddenRecursive,
|
|
13
|
-
getHiddenMetadata,
|
|
14
|
-
setHidden,
|
|
15
|
-
} = setup(__dirname);
|
package/src/index.mts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// src/index.mts
|
|
2
|
-
|
|
3
|
-
import { dirname } from "node:path";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
-
import { setup } from "./setup.js";
|
|
6
|
-
|
|
7
|
-
export * from "./exports.js";
|
|
8
|
-
|
|
9
|
-
export const {
|
|
10
|
-
getVolumeMountPoints,
|
|
11
|
-
getVolumeMetadata,
|
|
12
|
-
getAllVolumeMetadata,
|
|
13
|
-
isHidden,
|
|
14
|
-
isHiddenRecursive,
|
|
15
|
-
getHiddenMetadata,
|
|
16
|
-
setHidden,
|
|
17
|
-
} = setup(dirname(fileURLToPath(import.meta.url)));
|
package/src/setup.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// src/exports.ts
|
|
2
|
-
|
|
3
|
-
import NodeGypBuild from "node-gyp-build";
|
|
4
|
-
import { debug, debugLogContext, isDebugEnabled } from "./debuglog.js";
|
|
5
|
-
import { defer } from "./defer.js";
|
|
6
|
-
import { ExportedFunctions } from "./exports.js";
|
|
7
|
-
import { findAncestorDir } from "./fs.js";
|
|
8
|
-
import {
|
|
9
|
-
getHiddenMetadata,
|
|
10
|
-
HideMethod,
|
|
11
|
-
isHidden,
|
|
12
|
-
isHiddenRecursive,
|
|
13
|
-
setHidden,
|
|
14
|
-
} from "./hidden.js";
|
|
15
|
-
import { optionsWithDefaults } from "./options.js";
|
|
16
|
-
import type { NativeBindings } from "./types/native_bindings.js";
|
|
17
|
-
import { getAllVolumeMetadata, getVolumeMetadata } from "./volume_metadata.js";
|
|
18
|
-
import {
|
|
19
|
-
getVolumeMountPoints,
|
|
20
|
-
type GetVolumeMountPointOptions,
|
|
21
|
-
} from "./volume_mount_points.js";
|
|
22
|
-
|
|
23
|
-
export function setup(dirname: string): ExportedFunctions {
|
|
24
|
-
const nativeFn = defer<Promise<NativeBindings>>(async () => {
|
|
25
|
-
const start = Date.now();
|
|
26
|
-
try {
|
|
27
|
-
const dir = await findAncestorDir(dirname, "binding.gyp");
|
|
28
|
-
if (dir == null) {
|
|
29
|
-
throw new Error(
|
|
30
|
-
"Could not find bindings.gyp in any ancestor directory of " + dirname,
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
const bindings = NodeGypBuild(dir) as NativeBindings;
|
|
34
|
-
bindings.setDebugLogging(isDebugEnabled());
|
|
35
|
-
bindings.setDebugPrefix(debugLogContext() + ":native");
|
|
36
|
-
return bindings;
|
|
37
|
-
} catch (error) {
|
|
38
|
-
debug("Loading native bindings failed: %s", error);
|
|
39
|
-
throw error;
|
|
40
|
-
} finally {
|
|
41
|
-
debug(`Native bindings took %d ms to load`, Date.now() - start);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
getVolumeMountPoints: (opts: Partial<GetVolumeMountPointOptions> = {}) =>
|
|
47
|
-
getVolumeMountPoints(optionsWithDefaults(opts), nativeFn),
|
|
48
|
-
|
|
49
|
-
getVolumeMetadata: (mountPoint: string, opts = {}) =>
|
|
50
|
-
getVolumeMetadata({ ...optionsWithDefaults(opts), mountPoint }, nativeFn),
|
|
51
|
-
|
|
52
|
-
getAllVolumeMetadata: (opts = {}) =>
|
|
53
|
-
getAllVolumeMetadata(optionsWithDefaults(opts), nativeFn),
|
|
54
|
-
|
|
55
|
-
isHidden: (pathname: string) => isHidden(pathname, nativeFn),
|
|
56
|
-
|
|
57
|
-
isHiddenRecursive: (pathname: string) =>
|
|
58
|
-
isHiddenRecursive(pathname, nativeFn),
|
|
59
|
-
|
|
60
|
-
getHiddenMetadata: (pathname: string) =>
|
|
61
|
-
getHiddenMetadata(pathname, nativeFn),
|
|
62
|
-
|
|
63
|
-
setHidden: (
|
|
64
|
-
pathname: string,
|
|
65
|
-
hidden: boolean,
|
|
66
|
-
method: HideMethod = "auto",
|
|
67
|
-
) => setHidden(pathname, hidden, method, nativeFn),
|
|
68
|
-
} as const;
|
|
69
|
-
}
|