@visulima/fs 5.0.0-alpha.7 → 5.0.0-alpha.9

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 (125) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/LICENSE.md +155 -126
  3. package/dist/eol.d.ts +6 -35
  4. package/dist/error.d.ts +43 -7
  5. package/dist/glob-parent.d.ts +5 -0
  6. package/dist/glob-parent.js +90 -0
  7. package/dist/glob.d.ts +5 -0
  8. package/dist/glob.js +2 -0
  9. package/dist/index.d.ts +81 -36
  10. package/dist/index.js +16 -11
  11. package/dist/ini.d.ts +10 -0
  12. package/dist/ini.js +4 -0
  13. package/dist/is-glob.d.ts +5 -0
  14. package/dist/is-glob.js +9 -0
  15. package/dist/json5.d.ts +12 -0
  16. package/dist/json5.js +4 -0
  17. package/dist/jsonc.d.ts +10 -0
  18. package/dist/jsonc.js +4 -0
  19. package/dist/match.d.ts +5 -0
  20. package/dist/match.js +15 -0
  21. package/dist/packem_shared/_commonjsHelpers-BqLXS_qQ.js +5 -0
  22. package/dist/packem_shared/build-rm-options-Cl3VDY4O.js +12 -0
  23. package/dist/packem_shared/{collect-BnUYRrRI.js → collect-CqQ3eVab.js} +1 -1
  24. package/dist/packem_shared/{collectSync-D5G2RGDI.js → collectSync-noE08NNv.js} +1 -1
  25. package/dist/packem_shared/{emptyDir-Df4Tfjtk.js → emptyDir-DnwENOaV.js} +3 -1
  26. package/dist/packem_shared/{emptyDirSync-BD8-1Ytl.js → emptyDirSync-6WiHBo8a.js} +3 -1
  27. package/dist/packem_shared/glob-DY8l7izD.js +5 -0
  28. package/dist/packem_shared/glob-sync.d-B83kqwUd.d.ts +4 -0
  29. package/dist/packem_shared/globSync-5P2KJf_g.js +5 -0
  30. package/dist/packem_shared/index-C8W8sfzP.js +830 -0
  31. package/dist/packem_shared/index-bhgnhm4u.js +167 -0
  32. package/dist/packem_shared/index-xe4o3cYi.js +1784 -0
  33. package/dist/packem_shared/{parseJson-BedVi91S.js → indexToLineColumn-BUb0GPKl-BF770uX7.js} +1 -62
  34. package/dist/packem_shared/ini-preserve-Dq_Q_Jgb.js +251 -0
  35. package/dist/packem_shared/{isFsCaseSensitive-D-ayleCy.js → isFsCaseSensitive-DunL7Iry.js} +6 -6
  36. package/dist/packem_shared/json-error.d-DgKaeuIf.d.ts +10 -0
  37. package/dist/packem_shared/jsonc-merge-C6jWcfWh.js +72 -0
  38. package/dist/packem_shared/parseJson-BIp89Xjo.js +63 -0
  39. package/dist/packem_shared/readIni-CJ2xfpjB.js +10 -0
  40. package/dist/packem_shared/readIniSync-9LUjaSSp.js +10 -0
  41. package/dist/packem_shared/{readJson-D0G0ndHL.js → readJson-C_rwm-wq.js} +1 -1
  42. package/dist/packem_shared/readJson5-mBoTZppy.js +15 -0
  43. package/dist/packem_shared/readJson5Sync-8WS2yUok.js +15 -0
  44. package/dist/packem_shared/{readJsonSync-B7oicPaL.js → readJsonSync-BMEmCcJ6.js} +1 -1
  45. package/dist/packem_shared/readJsonc-j-OS-APg.js +28 -0
  46. package/dist/packem_shared/readJsoncSync-Aw6EMlWO.js +16 -0
  47. package/dist/packem_shared/readToml-B2MHaSes.js +9 -0
  48. package/dist/packem_shared/readTomlSync-DNbK8NEb.js +9 -0
  49. package/dist/packem_shared/{remove-CNkjFFkQ.js → remove-C8_gl3jF.js} +2 -1
  50. package/dist/packem_shared/{removeSync-AnawYpPv.js → removeSync-BJR_wTwN.js} +2 -1
  51. package/dist/packem_shared/types.d-dP-lAGNn.d.ts +145 -0
  52. package/dist/packem_shared/{walk-D5yHruvk.js → walk-CSZgCuDx.js} +10 -3
  53. package/dist/packem_shared/{walkSync-09nKPVw4.js → walkSync-C4Cy28xb.js} +10 -3
  54. package/dist/packem_shared/writeIni-i55QrL8y.js +65 -0
  55. package/dist/packem_shared/writeIniSync-CLqJE5t3.js +64 -0
  56. package/dist/packem_shared/writeJson5-vVmHUQOd.js +53 -0
  57. package/dist/packem_shared/writeJson5Sync-oJ546h5k.js +53 -0
  58. package/dist/packem_shared/writeJsonc-BufH_oC5.js +60 -0
  59. package/dist/packem_shared/writeJsoncSync-DB9be1YL.js +59 -0
  60. package/dist/packem_shared/writeToml-DgTW_-7F.js +8 -0
  61. package/dist/packem_shared/writeTomlSync-DiBiE9ja.js +8 -0
  62. package/dist/size.d.ts +10 -254
  63. package/dist/toml.d.ts +9 -0
  64. package/dist/toml.js +4 -0
  65. package/dist/utils.d.ts +15 -6
  66. package/dist/utils.js +1 -1
  67. package/dist/yaml.d.ts +14 -5
  68. package/package.json +58 -4
  69. package/dist/constants.d.ts +0 -42
  70. package/dist/ensure/ensure-dir-sync.d.ts +0 -14
  71. package/dist/ensure/ensure-dir.d.ts +0 -14
  72. package/dist/ensure/ensure-file-sync.d.ts +0 -15
  73. package/dist/ensure/ensure-file.d.ts +0 -27
  74. package/dist/ensure/ensure-link-sync.d.ts +0 -16
  75. package/dist/ensure/ensure-link.d.ts +0 -16
  76. package/dist/ensure/ensure-symlink-sync.d.ts +0 -23
  77. package/dist/ensure/ensure-symlink.d.ts +0 -23
  78. package/dist/ensure/utils/get-file-info-type.d.ts +0 -7
  79. package/dist/ensure/utils/is-stats-identical.d.ts +0 -3
  80. package/dist/ensure/utils/resolve-symlink-target.d.ts +0 -2
  81. package/dist/error/already-exists-error.d.ts +0 -39
  82. package/dist/error/directory-error.d.ts +0 -47
  83. package/dist/error/json-error.d.ts +0 -52
  84. package/dist/error/not-empty-error.d.ts +0 -51
  85. package/dist/error/not-found-error.d.ts +0 -44
  86. package/dist/error/permission-error.d.ts +0 -45
  87. package/dist/error/walk-error.d.ts +0 -51
  88. package/dist/find/collect-sync.d.ts +0 -31
  89. package/dist/find/collect.d.ts +0 -35
  90. package/dist/find/find-up-sync.d.ts +0 -42
  91. package/dist/find/find-up.d.ts +0 -46
  92. package/dist/find/utils/glob-to-regexp.d.ts +0 -2
  93. package/dist/find/utils/walk-include.d.ts +0 -2
  94. package/dist/find/walk-sync.d.ts +0 -34
  95. package/dist/find/walk.d.ts +0 -37
  96. package/dist/is-accessible-sync.d.ts +0 -3
  97. package/dist/is-accessible.d.ts +0 -29
  98. package/dist/move/index.d.ts +0 -68
  99. package/dist/move/types.d.ts +0 -36
  100. package/dist/move/utils/internal-move-file-sync.d.ts +0 -3
  101. package/dist/move/utils/internal-move-file.d.ts +0 -3
  102. package/dist/move/utils/validate-same-directory.d.ts +0 -2
  103. package/dist/read/read-file-sync.d.ts +0 -37
  104. package/dist/read/read-file.d.ts +0 -41
  105. package/dist/read/read-json-sync.d.ts +0 -5
  106. package/dist/read/read-json.d.ts +0 -5
  107. package/dist/read/read-yaml-sync.d.ts +0 -4
  108. package/dist/read/read-yaml.d.ts +0 -4
  109. package/dist/remove/empty-dir-sync.d.ts +0 -23
  110. package/dist/remove/empty-dir.d.ts +0 -28
  111. package/dist/remove/remove-sync.d.ts +0 -27
  112. package/dist/remove/remove.d.ts +0 -32
  113. package/dist/sanitize.d.ts +0 -31
  114. package/dist/types.d.ts +0 -304
  115. package/dist/utils/assert-valid-file-contents.d.ts +0 -27
  116. package/dist/utils/assert-valid-file-or-directory-path.d.ts +0 -26
  117. package/dist/utils/parse-json.d.ts +0 -5
  118. package/dist/utils/strip-json-comments.d.ts +0 -44
  119. package/dist/write/utils/to-uint-8-array.d.ts +0 -2
  120. package/dist/write/write-file-sync.d.ts +0 -30
  121. package/dist/write/write-file.d.ts +0 -30
  122. package/dist/write/write-json-sync.d.ts +0 -29
  123. package/dist/write/write-json.d.ts +0 -30
  124. package/dist/write/write-yaml-sync.d.ts +0 -4
  125. package/dist/write/write-yaml.d.ts +0 -4
@@ -1,68 +0,0 @@
1
- /**
2
- * Modified functions from https://github.com/sindresorhus/move-file
3
- *
4
- * The original functions are licensed under the MIT License:
5
- *
6
- * MIT License
7
- *
8
- * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
9
- */
10
- import type { Options } from './types.d.ts';
11
- /**
12
- * Move a file asynchronously.
13
- * @param sourcePath The file you want to move.
14
- * @param destinationPath Where you want the file moved.
15
- * @param options Configuration options.
16
- * @returns A `Promise` that resolves when the file has been moved.
17
- * @example
18
- * ```
19
- * import { move } from '@visulima/fs';
20
- *
21
- * await move('source/test.png', 'destination/test.png');
22
- * console.log('The file has been moved');
23
- * ```
24
- */
25
- export declare const move: (sourcePath: string, destinationPath: string, options?: Options) => Promise<void>;
26
- /**
27
- * Move a file synchronously.
28
- * @param sourcePath The file you want to move.
29
- * @param destinationPath Where you want the file moved.
30
- * @param options Configuration options.
31
- * @example
32
- * ```
33
- * import { moveSync } from '@visulima/fs';
34
- *
35
- * moveSync('source/test.png', 'destination/test.png');
36
- * console.log('The file has been moved');
37
- * ```
38
- */
39
- export declare const moveSync: (sourcePath: string, destinationPath: string, options?: Options) => void;
40
- /**
41
- * Rename a file asynchronously.
42
- * @param source The file you want to rename.
43
- * @param destination The name of the renamed file.
44
- * @param options Configuration options.
45
- * @returns A `Promise` that resolves when the file has been renamed.
46
- * @example
47
- * ```
48
- * import { rename } from '@visulima/fs';
49
- *
50
- * await rename('test.png', 'tests.png', {cwd: 'source'});
51
- * console.log('The file has been renamed');
52
- * ```
53
- */
54
- export declare const rename: (source: string, destination: string, options?: Options) => Promise<void>;
55
- /**
56
- * Rename a file synchronously.
57
- * @param source The file you want to rename.
58
- * @param destination The name of the renamed file.
59
- * @param options Configuration options.
60
- * @example
61
- * ```
62
- * import { renameSync } from '@visulima/fs';
63
- *
64
- * renameSync('test.png', 'tests.png', {cwd: 'source'});
65
- * console.log('The file has been renamed');
66
- * ```
67
- */
68
- export declare const renameSync: (source: string, destination: string, options?: Options) => void;
@@ -1,36 +0,0 @@
1
- export type Options = {
2
- /**
3
- * The working directory to find source files.
4
- * The source and destination path are relative to this.
5
- * @default process.cwd()
6
- */
7
- cwd?: URL | string;
8
- /**
9
- * [Permissions](https://en.wikipedia.org/wiki/File-system_permissions#Numeric_notation) for created directories.
10
- *
11
- * It has no effect on Windows.
12
- * @default 0o777
13
- */
14
- readonly directoryMode?: number;
15
- /**
16
- * Overwrite existing destination file.
17
- * @default true
18
- */
19
- readonly overwrite?: boolean;
20
- };
21
- /**
22
- * Internal options used by the move/rename implementation.
23
- * Extends the public Options type with additional internal properties.
24
- */
25
- export type InternalOptions = Options & {
26
- /**
27
- * Resolved working directory path.
28
- * URLs from the Options type are converted to string paths.
29
- */
30
- cwd: string;
31
- /**
32
- * Whether to validate the directory structure before operation.
33
- * @internal
34
- */
35
- validateDirectory?: boolean;
36
- };
@@ -1,3 +0,0 @@
1
- import type { InternalOptions } from "../types.d.ts";
2
- declare const internalMoveFileSync: (sourcePath: string, destinationPath: string, { cwd, directoryMode, overwrite, validateDirectory }: InternalOptions) => void;
3
- export default internalMoveFileSync;
@@ -1,3 +0,0 @@
1
- import type { InternalOptions } from "../types.d.ts";
2
- declare const internalMoveFile: (sourcePath: string, destinationPath: string, { cwd, directoryMode, overwrite, validateDirectory }: InternalOptions) => Promise<void>;
3
- export default internalMoveFile;
@@ -1,2 +0,0 @@
1
- declare const validateSameDirectory: (source: string, destination: string) => void;
2
- export default validateSameDirectory;
@@ -1,37 +0,0 @@
1
- import type { ContentType, ReadFileOptions } from "../types.d.ts";
2
- type DecompressionMethod = (buffer: Buffer) => Buffer;
3
- declare const decompressionMethods: Record<string, DecompressionMethod>;
4
- /**
5
- * Synchronously reads the entire contents of a file.
6
- * It can also decompress the file content if a `compression` option is provided.
7
- * @template O - The type of the options object, extending {@link ReadFileOptions}.
8
- * @param path The path to the file to read. Can be a file URL or a string path.
9
- * @param options Optional configuration for reading the file. See {@link ReadFileOptions}.
10
- * Available `compression` methods: "brotli", "gzip", "none" (default).
11
- * @returns The file content. The type of the content (string or Buffer)
12
- * depends on the `buffer` option (defaults to string if `buffer` is false or not set).
13
- * @example
14
- * ```javascript
15
- * import { readFileSync } from "@visulima/fs";
16
- * import { join } from "node:path";
17
- *
18
- * try {
19
- * // Read a regular text file
20
- * const content = readFileSync(join("path", "to", "my-file.txt"));
21
- * console.log("File content:", content);
22
- *
23
- * // Read a file as a Buffer
24
- * const bufferContent = readFileSync(join("path", "to", "another-file.bin"), { buffer: true });
25
- * console.log("Buffer length:", bufferContent.length);
26
- *
27
- * // Read and decompress a gzipped file
28
- * // Assume my-archive.txt.gz exists
29
- * // const decompressedContent = readFileSync(join("path", "to", "my-archive.txt.gz"), { compression: "gzip", encoding: "utf8" });
30
- * // console.log("Decompressed content:", decompressedContent);
31
- * } catch (error) {
32
- * console.error("Failed to read file:", error);
33
- * }
34
- * ```
35
- */
36
- declare const readFileSync: <O extends ReadFileOptions<keyof typeof decompressionMethods> | undefined = undefined>(path: URL | string, options?: O) => ContentType<O>;
37
- export default readFileSync;
@@ -1,41 +0,0 @@
1
- import type { ContentType, ReadFileOptions } from "../types.d.ts";
2
- type DecompressionMethod = (buffer: Buffer, callback: (error: Error | null, result: Buffer) => void) => void;
3
- declare const decompressionMethods: Record<string, DecompressionMethod>;
4
- /**
5
- * Asynchronously reads the entire contents of a file.
6
- * It can also decompress the file content if a `compression` option is provided.
7
- * @template O - The type of the options object, extending {@link ReadFileOptions}.
8
- * @param path The path to the file to read. Can be a file URL or a string path.
9
- * @param options Optional configuration for reading the file. See {@link ReadFileOptions}.
10
- * Available `compression` methods: "brotli", "gzip", "none" (default).
11
- * @returns A promise that resolves with the file content. The type of the content (string or Buffer)
12
- * depends on the `buffer` option (defaults to string if `buffer` is false or not set).
13
- * @example
14
- * ```javascript
15
- * import { readFile } from "@visulima/fs";
16
- * import { join } from "node:path";
17
- *
18
- * const readMyFile = async () => {
19
- * try {
20
- * // Read a regular text file
21
- * const content = await readFile(join("path", "to", "my-file.txt"));
22
- * console.log("File content:", content);
23
- *
24
- * // Read a file as a Buffer
25
- * const bufferContent = await readFile(join("path", "to", "another-file.bin"), { buffer: true });
26
- * console.log("Buffer length:", bufferContent.length);
27
- *
28
- * // Read and decompress a gzipped file
29
- * // Assume my-archive.txt.gz exists
30
- * // const decompressedContent = await readFile(join("path", "to", "my-archive.txt.gz"), { compression: "gzip", encoding: "utf8" });
31
- * // console.log("Decompressed content:", decompressedContent);
32
- * } catch (error) {
33
- * console.error("Failed to read file:", error);
34
- * }
35
- * };
36
- *
37
- * readMyFile();
38
- * ```
39
- */
40
- declare const readFile: <O extends ReadFileOptions<keyof typeof decompressionMethods> | undefined = undefined>(path: URL | string, options?: O) => Promise<ContentType<O>>;
41
- export default readFile;
@@ -1,5 +0,0 @@
1
- import type { JsonValue } from "type-fest";
2
- import type { JsonReviver, ReadJsonOptions } from "../types.d.ts";
3
- declare function readJsonSync(path: URL | string, options?: ReadJsonOptions): JsonValue;
4
- declare function readJsonSync(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): JsonValue;
5
- export default readJsonSync;
@@ -1,5 +0,0 @@
1
- import type { JsonValue } from "type-fest";
2
- import type { JsonReviver, ReadJsonOptions } from "../types.d.ts";
3
- declare function readJson<T extends JsonValue>(path: URL | string, options?: ReadJsonOptions): Promise<T>;
4
- declare function readJson<T extends JsonValue>(path: URL | string, reviver: JsonReviver, options?: ReadJsonOptions): Promise<T>;
5
- export default readJson;
@@ -1,4 +0,0 @@
1
- import type { CompressionType, ReadYamlOptions, YamlReviver } from "../types.d.ts";
2
- declare function readYamlSync(path: URL | string, options?: ReadYamlOptions<CompressionType>): Record<string, unknown>;
3
- declare function readYamlSync(path: URL | string, reviver?: YamlReviver, options?: ReadYamlOptions<CompressionType>): Record<string, unknown>;
4
- export default readYamlSync;
@@ -1,4 +0,0 @@
1
- import type { CompressionType, ReadYamlOptions, YamlReviver } from "../types.d.ts";
2
- declare function readYaml<R = Record<string, unknown>>(path: URL | string, options?: ReadYamlOptions<CompressionType>): Promise<R>;
3
- declare function readYaml<R = Record<string, unknown>>(path: URL | string, reviver?: YamlReviver, options?: ReadYamlOptions<CompressionType>): Promise<R>;
4
- export default readYaml;
@@ -1,23 +0,0 @@
1
- import type { RetryOptions } from "../types.d.ts";
2
- /**
3
- * Ensures that a directory is empty.
4
- * Deletes directory contents if the directory is not empty.
5
- * If the directory does not exist, it is created.
6
- * The directory itself is not deleted.
7
- * @param dir The path to the directory to empty.
8
- * @param options Optional configuration for the operation. See {@link RetryOptions}.
9
- * @example
10
- * ```javascript
11
- * import { emptyDirSync } from "@visulima/fs";
12
- * import { join } from "node:path";
13
- *
14
- * try {
15
- * emptyDirSync(join("/tmp", "my-app-temp"));
16
- * console.log("Temporary directory emptied or created.");
17
- * } catch (error) {
18
- * console.error("Failed to empty directory:", error);
19
- * }
20
- * ```
21
- */
22
- declare const emptyDirSync: (dir: URL | string, options?: RetryOptions) => void;
23
- export default emptyDirSync;
@@ -1,28 +0,0 @@
1
- import type { RetryOptions } from "../types.d.ts";
2
- /**
3
- * Ensures that a directory is empty.
4
- * Deletes directory contents if the directory is not empty.
5
- * If the directory does not exist, it is created.
6
- * The directory itself is not deleted.
7
- * @param dir The path to the directory to empty.
8
- * @param options Optional configuration for the operation. See {@link RetryOptions}.
9
- * @returns A promise that resolves when the directory is empty.
10
- * @example
11
- * ```javascript
12
- * import { emptyDir } from "@visulima/fs";
13
- * import { join } from "node:path";
14
- *
15
- * const clearTempDir = async () => {
16
- * try {
17
- * await emptyDir(join("/tmp", "my-app-temp"));
18
- * console.log("Temporary directory emptied or created.");
19
- * } catch (error) {
20
- * console.error("Failed to empty directory:", error);
21
- * }
22
- * };
23
- *
24
- * clearTempDir();
25
- * ```
26
- */
27
- declare const emptyDir: (dir: URL | string, options?: RetryOptions) => Promise<void>;
28
- export default emptyDir;
@@ -1,27 +0,0 @@
1
- import type { RetryOptions } from "../types.d.ts";
2
- /**
3
- * Synchronously removes a file or directory (recursively).
4
- * If the path does not exist, it does nothing.
5
- * @param path The path to the file or directory to remove.
6
- * @param options Optional configuration for the operation. See {@link RetryOptions}.
7
- * @example
8
- * ```javascript
9
- * import { removeSync } from "@visulima/fs";
10
- * import { join } from "node:path";
11
- *
12
- * try {
13
- * removeSync(join("/tmp", "my-file.txt"));
14
- * console.log("File /tmp/my-file.txt removed.");
15
- *
16
- * removeSync(join("/tmp", "my-empty-dir"));
17
- * console.log("Directory /tmp/my-empty-dir removed.");
18
- *
19
- * removeSync(join("/tmp", "my-dir-with-contents"));
20
- * console.log("Directory /tmp/my-dir-with-contents and its contents removed.");
21
- * } catch (error) {
22
- * console.error("Failed to remove path:", error);
23
- * }
24
- * ```
25
- */
26
- declare const removeSync: (path: URL | string, options?: RetryOptions) => void;
27
- export default removeSync;
@@ -1,32 +0,0 @@
1
- import type { RetryOptions } from "../types.d.ts";
2
- /**
3
- * Asynchronously removes a file or directory (recursively).
4
- * If the path does not exist, it does nothing.
5
- * @param path The path to the file or directory to remove.
6
- * @param options Optional configuration for the operation. See {@link RetryOptions}.
7
- * @returns A promise that resolves when the path has been removed.
8
- * @example
9
- * ```javascript
10
- * import { remove } from "@visulima/fs";
11
- * import { join } from "node:path";
12
- *
13
- * const deleteFileOrDir = async () => {
14
- * try {
15
- * await remove(join("/tmp", "my-file.txt"));
16
- * console.log("File /tmp/my-file.txt removed.");
17
- *
18
- * await remove(join("/tmp", "my-empty-dir"));
19
- * console.log("Directory /tmp/my-empty-dir removed.");
20
- *
21
- * await remove(join("/tmp", "my-dir-with-contents"));
22
- * console.log("Directory /tmp/my-dir-with-contents and its contents removed.");
23
- * } catch (error) {
24
- * console.error("Failed to remove path:", error);
25
- * }
26
- * };
27
- *
28
- * deleteFileOrDir();
29
- * ```
30
- */
31
- declare const remove: (path: URL | string, options?: RetryOptions) => Promise<void>;
32
- export default remove;
@@ -1,31 +0,0 @@
1
- /**
2
- * Supported filesystem types
3
- */
4
- export type FileSystemType = "win32" | "unix" | "darwin" | "fat32" | "auto";
5
- /**
6
- * Options for the sanitize function
7
- */
8
- export interface SanitizeOptions {
9
- /**
10
- * Target filesystem type for sanitization rules
11
- * - "win32": Windows filesystem rules (reserved names, Windows forbidden chars, no trailing periods/spaces)
12
- * - "unix": Unix/Linux filesystem rules (only / and null forbidden)
13
- * - "darwin": macOS filesystem rules (same as unix)
14
- * - "fat32": FAT32 filesystem rules (Windows rules + no leading/trailing spaces/periods in name part)
15
- * - "auto": Automatically detect from process.platform
16
- * @default "auto"
17
- */
18
- filesystem?: FileSystemType;
19
- /**
20
- * Maximum length of the sanitized name
21
- * @default 128
22
- */
23
- maxLength?: number;
24
- }
25
- /**
26
- * Sanitizes a filename by removing or replacing forbidden characters.
27
- * @param name The filename to sanitize.
28
- * @param options Optional configuration.
29
- * @returns The sanitized filename, or "unnamed" if the result would be empty.
30
- */
31
- export declare const sanitize: (name: string, options?: Partial<SanitizeOptions>) => string;
package/dist/types.d.ts DELETED
@@ -1,304 +0,0 @@
1
- import type { Dirent, PathLike } from "node:fs";
2
- import type { CreateNodeOptions, DocumentOptions, ParseOptions, SchemaOptions, ToJSOptions, ToStringOptions } from "yaml";
3
- import type { FIND_UP_STOP } from "./constants.d.ts";
4
- type ColorizeMethod = (value: string) => string;
5
- /**
6
- * Options for the `walk` and `walkSync` functions.
7
- */
8
- export interface WalkOptions {
9
- /**
10
- * List of file extensions used to filter entries.
11
- * If specified, entries without the file extension specified by this option are excluded.
12
- * @default {undefined}
13
- */
14
- extensions?: string[];
15
- /**
16
- * Indicates whether symlinks should be resolved or not.
17
- * @default {false}
18
- */
19
- followSymlinks?: boolean;
20
- /**
21
- * Indicates whether directory entries should be included or not.
22
- * @default {true}
23
- */
24
- includeDirs?: boolean;
25
- /**
26
- * Indicates whether file entries should be included or not.
27
- * @default {true}
28
- */
29
- includeFiles?: boolean;
30
- /**
31
- * Indicates whether symlink entries should be included or not.
32
- * This option is meaningful only if `followSymlinks` is set to `false`.
33
- * @default {true}
34
- */
35
- includeSymlinks?: boolean;
36
- /**
37
- * List of regular expression or glob patterns used to filter entries.
38
- * If specified, entries that do not match the patterns specified by this option are excluded.
39
- * @default {undefined}
40
- */
41
- match?: (RegExp | string)[];
42
- /**
43
- * The maximum depth of the file tree to be walked recursively.
44
- * @default {Infinity}
45
- */
46
- maxDepth?: number;
47
- /**
48
- * List of regular expression or glob patterns used to filter entries.
49
- * If specified, entries matching the patterns specified by this option are excluded.
50
- * @default {undefined}
51
- */
52
- skip?: (RegExp | string)[];
53
- }
54
- /**
55
- * Represents an entry found by `walk` or `walkSync`.
56
- */
57
- export interface WalkEntry extends Pick<Dirent, "isDirectory" | "isFile" | "isSymbolicLink" | "name"> {
58
- /** The full path to the entry. */
59
- path: string;
60
- }
61
- /**
62
- * Supported compression types for file operations.
63
- */
64
- export type CompressionType = "brotli" | "gzip" | "none";
65
- /**
66
- * Supported file encodings for reading files.
67
- */
68
- export type ReadFileEncoding = "ascii" | "base64" | "base64url" | "hex" | "latin1" | "ucs-2" | "ucs2" | "utf-8" | "utf-16le" | "utf8" | "utf16le";
69
- /**
70
- * Options for reading files.
71
- * @template C - The type of compression used.
72
- */
73
- export type ReadFileOptions<C> = {
74
- /**
75
- * Return content as a Buffer. Default: `false`
76
- */
77
- buffer?: boolean;
78
- /**
79
- * Compression method to decompress the file against. Default: `none`
80
- */
81
- compression?: C;
82
- /**
83
- * The encoding to use. Default: `utf8`
84
- * @see https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings
85
- */
86
- encoding?: ReadFileEncoding;
87
- /**
88
- * The flag used to open the file. Default: `r`
89
- */
90
- flag?: number | string;
91
- };
92
- /**
93
- * Represents the content type of a read file, which can be a Buffer or a string based on options.
94
- * @template O - The ReadFileOptions type.
95
- */
96
- export type ContentType<O = undefined> = O extends {
97
- buffer: true;
98
- } ? Buffer : string;
99
- /**
100
- * Type for the `reviver` parameter of `JSON.parse()`.
101
- * A function that transforms the results. This function is called for each member of the object.
102
- * If a member contains nested objects, the nested objects are transformed before the parent object is.
103
- */
104
- export type JsonReviver = Parameters<(typeof JSON)["parse"]>["1"];
105
- /**
106
- * Specifies a location (line and column) in a file for code frame generation.
107
- */
108
- export type CodeFrameLocation = {
109
- /** The column number. */
110
- column?: number;
111
- /** The line number. */
112
- line: number;
113
- };
114
- /**
115
- * Options for customizing the appearance of code frames.
116
- */
117
- export type CodeFrameOptions = {
118
- /** Colorization methods for different parts of the code frame. */
119
- color?: {
120
- /** Color for the gutter (line numbers). */
121
- gutter?: ColorizeMethod;
122
- /** Color for the marker (pointing to the error). */
123
- marker?: ColorizeMethod;
124
- /** Color for the message. */
125
- message?: ColorizeMethod;
126
- };
127
- };
128
- /**
129
- * Options for reading and parsing JSON files.
130
- * Extends {@link CodeFrameOptions}.
131
- */
132
- export type ReadJsonOptions = CodeFrameOptions & {
133
- /**
134
- * A function to transform the string content before parsing.
135
- * @param source The raw string content of the file.
136
- * @returns The transformed string content.
137
- */
138
- beforeParse?: (source: string) => string;
139
- };
140
- /**
141
- * Options for writing files.
142
- */
143
- export type WriteFileOptions = {
144
- /**
145
- * The group and user ID used to set the file ownership. Default: `undefined`
146
- */
147
- chown?: {
148
- gid: number;
149
- uid: number;
150
- };
151
- /**
152
- * The encoding to use. Default: `utf8`
153
- */
154
- encoding?: BufferEncoding | null;
155
- /**
156
- * The flag used to write the file. Default: `w`
157
- */
158
- flag?: string;
159
- /**
160
- * The file mode (permission and sticky bits). Default: `0o666`
161
- */
162
- mode?: number;
163
- /**
164
- * Indicates whether the file should be overwritten if it already exists. Default: `false`
165
- */
166
- overwrite?: boolean;
167
- /**
168
- * Recursively create parent directories if needed. Default: `true`
169
- */
170
- recursive?: boolean;
171
- };
172
- /**
173
- * Type for the `replacer` parameter of `JSON.stringify()`.
174
- * Can be a function that alters the behavior of the stringification process,
175
- * or an array of strings and numbers that acts as a whitelist for selecting
176
- * the properties of the value object to be included in the JSON string.
177
- * If this value is null or not provided, all properties of the object are included in the resulting JSON string.
178
- */
179
- export type JsonReplacer = (number | string)[] | ((this: unknown, key: string, value: unknown) => unknown) | null;
180
- /**
181
- * Type for the `replacer` parameter used in YAML serialization, similar to `JSON.stringify`'s replacer.
182
- * @deprecated Use {@link JsonReplacer} directly instead.
183
- */
184
- export type YamlReplacer = JsonReplacer;
185
- /**
186
- * Options for writing JSON files.
187
- * Extends {@link WriteFileOptions}.
188
- */
189
- export type WriteJsonOptions = WriteFileOptions & {
190
- /**
191
- * Detect indentation automatically if the file exists. Default: `false`
192
- */
193
- detectIndent?: boolean;
194
- /**
195
- * The space used for pretty-printing.
196
- *
197
- * Pass in `undefined` for no formatting.
198
- */
199
- indent?: number | string;
200
- /**
201
- * Passed into `JSON.stringify`.
202
- */
203
- replacer?: JsonReplacer;
204
- /**
205
- * Override the default `JSON.stringify` method.
206
- */
207
- stringify?: (data: unknown, replacer: JsonReplacer, space: number | string | undefined) => string;
208
- };
209
- /**
210
- * Options for the `findUp` and `findUpSync` functions.
211
- */
212
- export type FindUpOptions = {
213
- /**
214
- * Whether to follow symbolic links.
215
- * @default undefined (behaves like `true` for `findUp`, `false` for `findUpSync` due to `fs.stat` vs `fs.lstat`)
216
- */
217
- allowSymlinks?: boolean;
218
- /**
219
- * The current working directory.
220
- * @default process.cwd()
221
- */
222
- cwd?: URL | string;
223
- /**
224
- * The directory to stop searching at.
225
- * @default path.parse(cwd).root
226
- */
227
- stopAt?: URL | string;
228
- /**
229
- * The type of path to find.
230
- * @default "file"
231
- */
232
- type?: "directory" | "file";
233
- };
234
- /**
235
- * The result type for the name matcher function used in `findUp`.
236
- * It can be a `PathLike` (string, Buffer, or URL), a Promise resolving to `PathLike` or `FIND_UP_STOP`,
237
- * `FIND_UP_STOP` to stop the search, or `undefined` to continue.
238
- */
239
- export type FindUpNameFnResult = PathLike | Promise<PathLike | typeof FIND_UP_STOP> | typeof FIND_UP_STOP | undefined;
240
- /**
241
- * Specifies the name(s) of the file or directory to search for in `findUp`.
242
- * Can be a single name, an array of names, or a function that returns a name or `FIND_UP_STOP`.
243
- */
244
- export type FindUpName = string[] | string | ((directory: string) => FindUpNameFnResult);
245
- /**
246
- * The result type for the name matcher function used in `findUpSync`.
247
- * It can be a `PathLike` (string, Buffer, or URL), `FIND_UP_STOP` to stop the search,
248
- * or `undefined` to continue.
249
- */
250
- export type FindUpNameSyncFnResult = PathLike | typeof FIND_UP_STOP | undefined;
251
- /**
252
- * Specifies the name(s) of the file or directory to search for in `findUpSync`.
253
- * Can be a single name, an array of names, or a function that returns a name or `FIND_UP_STOP`.
254
- */
255
- export type FindUpNameSync = string[] | string | ((directory: string) => FindUpNameSyncFnResult);
256
- /**
257
- * Options for operations that might require retries, like `emptyDir` or `remove`.
258
- */
259
- export type RetryOptions = {
260
- /**
261
- * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
262
- * `EPERM` error is encountered, Node.js will retry the operation with a linear
263
- * backoff wait of `retryDelay` ms longer on each try. This option represents the
264
- * number of retries. This option is ignored if the `recursive` option is not
265
- * `true` for operations that support it (like `rm`).
266
- * @default 0
267
- */
268
- maxRetries?: number;
269
- /**
270
- * The amount of time in milliseconds to wait between retries.
271
- * This option is ignored if the `recursive` option is not `true` for operations that support it.
272
- * @default 100
273
- */
274
- retryDelay?: number;
275
- };
276
- /**
277
- * Options for reading YAML files.
278
- * Combines options from `yaml` library (DocumentOptions, ParseOptions, SchemaOptions, ToJSOptions)
279
- * and custom {@link ReadFileOptions}.
280
- * @template C - The type of compression used.
281
- */
282
- export type ReadYamlOptions<C> = DocumentOptions & ParseOptions & ReadFileOptions<C> & SchemaOptions & ToJSOptions;
283
- /**
284
- * Type for the `reviver` parameter used in YAML deserialization, similar to `JSON.parse`'s reviver.
285
- * A function that transforms the results. This function is called for each member of the object.
286
- * If a member contains nested objects, the nested objects are transformed before the parent object is.
287
- */
288
- export type YamlReviver = (key: unknown, value: unknown) => unknown;
289
- /**
290
- * Options for writing YAML files.
291
- * Extends {@link WriteFileOptions} and includes options from the `yaml` library for stringification.
292
- */
293
- export type WriteYamlOptions = CreateNodeOptions & DocumentOptions & ParseOptions & SchemaOptions & ToStringOptions & WriteFileOptions & {
294
- /**
295
- * Passed into `yaml.stringify` as the replacer argument.
296
- */
297
- replacer?: JsonReplacer;
298
- /**
299
- * Passed into `yaml.stringify` as the space argument for indentation.
300
- * Can be a number of spaces or a string (e.g., a tab character).
301
- */
302
- space?: number | string;
303
- };
304
- export {};