@reliverse/relifso 1.1.3 → 1.2.1

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 (122) hide show
  1. package/README.md +6 -1
  2. package/bin/impl/copy.d.ts +28 -0
  3. package/bin/impl/copy.js +64 -0
  4. package/bin/impl/create-file.d.ts +2 -0
  5. package/bin/impl/create-file.js +21 -0
  6. package/bin/impl/dive.d.ts +17 -0
  7. package/bin/impl/dive.js +56 -0
  8. package/bin/impl/empty-dir.d.ts +2 -0
  9. package/bin/impl/empty-dir.js +24 -0
  10. package/bin/impl/mkdirs.d.ts +2 -0
  11. package/bin/impl/mkdirs.js +19 -0
  12. package/bin/impl/move.d.ts +15 -0
  13. package/bin/impl/move.js +93 -0
  14. package/bin/impl/output-file.d.ts +16 -0
  15. package/bin/impl/output-file.js +15 -0
  16. package/bin/impl/output-json.d.ts +16 -0
  17. package/bin/impl/output-json.js +15 -0
  18. package/bin/impl/path-exists.d.ts +2 -0
  19. package/bin/impl/path-exists.js +16 -0
  20. package/bin/impl/read-file.d.ts +30 -0
  21. package/bin/impl/read-file.js +30 -0
  22. package/bin/impl/read-json.d.ts +22 -0
  23. package/bin/impl/read-json.js +50 -0
  24. package/bin/impl/remove.d.ts +2 -0
  25. package/bin/impl/remove.js +8 -0
  26. package/bin/impl/write-file.d.ts +20 -0
  27. package/bin/impl/write-file.js +23 -0
  28. package/bin/impl/write-json.d.ts +28 -0
  29. package/bin/impl/write-json.js +22 -0
  30. package/bin/mod.d.ts +36 -2
  31. package/bin/mod.js +144 -2
  32. package/package.json +11 -9
  33. package/bin/d.ts.txt +0 -1000
  34. package/bin/impl/args-impl.d.ts +0 -0
  35. package/bin/impl/args-impl.js +0 -0
  36. package/bin/impl/array-polyfill.d.ts +0 -15
  37. package/bin/impl/external/path-is-inside.d.ts +0 -1
  38. package/bin/impl/external/path-is-inside.js +0 -16
  39. package/bin/impl/external/vacuum.d.ts +0 -26
  40. package/bin/impl/external/vacuum.js +0 -95
  41. package/bin/impl/fs/dive.d.ts +0 -8
  42. package/bin/impl/fs/dive.js +0 -91
  43. package/bin/impl/fs/exists.d.ts +0 -31
  44. package/bin/impl/fs/exists.js +0 -10
  45. package/bin/impl/fs/for-each-child.d.ts +0 -34
  46. package/bin/impl/fs/for-each-child.js +0 -37
  47. package/bin/impl/fs/index.d.ts +0 -1118
  48. package/bin/impl/fs/index.js +0 -66
  49. package/bin/impl/fs/is-directory.d.ts +0 -14
  50. package/bin/impl/fs/is-directory.js +0 -16
  51. package/bin/impl/fs/map-children.d.ts +0 -17
  52. package/bin/impl/fs/map-children.js +0 -31
  53. package/bin/impl/fs/map-structure.d.ts +0 -35
  54. package/bin/impl/fs/map-structure.js +0 -44
  55. package/bin/impl/fs/read-lines.d.ts +0 -16
  56. package/bin/impl/fs/read-lines.js +0 -32
  57. package/bin/impl/fs/read-text.d.ts +0 -13
  58. package/bin/impl/fs/read-text.js +0 -10
  59. package/bin/impl/fs/universalify.d.ts +0 -18
  60. package/bin/impl/fs/universalify.js +0 -38
  61. package/bin/impl/fs/write-file.d.ts +0 -93
  62. package/bin/impl/fs/write-file.js +0 -47
  63. package/bin/impl/helpers.d.ts +0 -1
  64. package/bin/impl/helpers.js +0 -37
  65. package/bin/impl/json.d.ts +0 -16
  66. package/bin/impl/json.js +0 -90
  67. package/bin/impl/lib/copy/copy-sync.d.ts +0 -25
  68. package/bin/impl/lib/copy/copy-sync.js +0 -119
  69. package/bin/impl/lib/copy/copy.d.ts +0 -7
  70. package/bin/impl/lib/copy/copy.js +0 -144
  71. package/bin/impl/lib/copy/index.d.ts +0 -5
  72. package/bin/impl/lib/copy/index.js +0 -2
  73. package/bin/impl/lib/empty/index.d.ts +0 -1
  74. package/bin/impl/lib/empty/index.js +0 -29
  75. package/bin/impl/lib/ensure/file.d.ts +0 -2
  76. package/bin/impl/lib/ensure/file.js +0 -56
  77. package/bin/impl/lib/ensure/index.d.ts +0 -8
  78. package/bin/impl/lib/ensure/index.js +0 -12
  79. package/bin/impl/lib/ensure/link.d.ts +0 -2
  80. package/bin/impl/lib/ensure/link.js +0 -53
  81. package/bin/impl/lib/ensure/symlink-paths.d.ts +0 -5
  82. package/bin/impl/lib/ensure/symlink-paths.js +0 -63
  83. package/bin/impl/lib/ensure/symlink-type.d.ts +0 -2
  84. package/bin/impl/lib/ensure/symlink-type.js +0 -23
  85. package/bin/impl/lib/ensure/symlink.d.ts +0 -2
  86. package/bin/impl/lib/ensure/symlink.js +0 -59
  87. package/bin/impl/lib/fs/index.d.ts +0 -1
  88. package/bin/impl/lib/fs/index.js +0 -1
  89. package/bin/impl/lib/index.d.ts +0 -15
  90. package/bin/impl/lib/index.js +0 -34
  91. package/bin/impl/lib/index_rollup.d.ts +0 -10
  92. package/bin/impl/lib/index_rollup.js +0 -10
  93. package/bin/impl/lib/json/index.d.ts +0 -3
  94. package/bin/impl/lib/json/index.js +0 -10
  95. package/bin/impl/lib/json/output-json-sync.d.ts +0 -1
  96. package/bin/impl/lib/json/output-json-sync.js +0 -6
  97. package/bin/impl/lib/json/output-json.d.ts +0 -1
  98. package/bin/impl/lib/json/output-json.js +0 -6
  99. package/bin/impl/lib/mkdirs/index.d.ts +0 -1
  100. package/bin/impl/lib/mkdirs/index.js +0 -4
  101. package/bin/impl/lib/mkdirs/make-dir.d.ts +0 -2
  102. package/bin/impl/lib/mkdirs/make-dir.js +0 -21
  103. package/bin/impl/lib/mkdirs/utils.d.ts +0 -1
  104. package/bin/impl/lib/mkdirs/utils.js +0 -13
  105. package/bin/impl/lib/move/index.d.ts +0 -30
  106. package/bin/impl/lib/move/index.js +0 -2
  107. package/bin/impl/lib/move/move-sync.d.ts +0 -8
  108. package/bin/impl/lib/move/move-sync.js +0 -51
  109. package/bin/impl/lib/move/move.d.ts +0 -6
  110. package/bin/impl/lib/move/move.js +0 -48
  111. package/bin/impl/lib/output-file/index.d.ts +0 -1
  112. package/bin/impl/lib/output-file/index.js +0 -24
  113. package/bin/impl/lib/remove/index.d.ts +0 -53
  114. package/bin/impl/lib/remove/index.js +0 -8
  115. package/bin/impl/lib/util/stat.d.ts +0 -39
  116. package/bin/impl/lib/util/stat.js +0 -140
  117. package/bin/impl/lib/util/utimes.d.ts +0 -7
  118. package/bin/impl/lib/util/utimes.js +0 -31
  119. package/bin/impl/subindex.d.ts +0 -43
  120. package/bin/impl/subindex.js +0 -161
  121. package/bin/types.d.ts +0 -100
  122. package/bin/types.js +0 -1
@@ -0,0 +1,28 @@
1
+ import type { Mode, OpenMode } from "node:fs";
2
+ export interface JsonStringifyOptions {
3
+ replacer?: (key: string, value: unknown) => unknown | (number | string)[] | null;
4
+ space?: string | number;
5
+ }
6
+ export interface WriteJsonOptions {
7
+ encoding?: BufferEncoding | null;
8
+ mode?: Mode;
9
+ flag?: OpenMode;
10
+ replacer?: (key: string, value: unknown) => unknown | (number | string)[] | null;
11
+ space?: string | number;
12
+ }
13
+ /**
14
+ * Synchronously writes an object to a JSON file.
15
+ *
16
+ * @param file - The path to the file.
17
+ * @param object - The object to stringify and write.
18
+ * @param options - Options for stringifying JSON or writing the file.
19
+ */
20
+ export declare function writeJsonSync(file: string, object: unknown, options?: WriteJsonOptions): void;
21
+ /**
22
+ * Asynchronously writes an object to a JSON file.
23
+ *
24
+ * @param file - The path to the file.
25
+ * @param object - The object to stringify and write.
26
+ * @param options - Options for stringifying JSON or writing the file.
27
+ */
28
+ export declare function writeJson(file: string, object: unknown, options?: WriteJsonOptions): Promise<void>;
@@ -0,0 +1,22 @@
1
+ import { writeFileSync } from "./write-file.js";
2
+ import { writeFile } from "./write-file.js";
3
+ export function writeJsonSync(file, object, options = {}) {
4
+ const replacer = options.replacer === void 0 ? null : options.replacer;
5
+ const space = options.space === void 0 ? 2 : options.space;
6
+ const fileWriteOpts = {};
7
+ if (options.encoding !== void 0) fileWriteOpts.encoding = options.encoding;
8
+ if (options.mode !== void 0) fileWriteOpts.mode = options.mode;
9
+ if (options.flag !== void 0) fileWriteOpts.flag = options.flag.toString();
10
+ const str = JSON.stringify(object, replacer, space);
11
+ writeFileSync(file, str, fileWriteOpts);
12
+ }
13
+ export async function writeJson(file, object, options = {}) {
14
+ const replacer = options.replacer === void 0 ? null : options.replacer;
15
+ const space = options.space === void 0 ? 2 : options.space;
16
+ const fileWriteOpts = {};
17
+ if (options.encoding !== void 0) fileWriteOpts.encoding = options.encoding;
18
+ if (options.mode !== void 0) fileWriteOpts.mode = options.mode;
19
+ if (options.flag !== void 0) fileWriteOpts.flag = options.flag.toString();
20
+ const str = JSON.stringify(object, replacer, space);
21
+ await writeFile(file, str, fileWriteOpts);
22
+ }
package/bin/mod.d.ts CHANGED
@@ -1,2 +1,36 @@
1
- export * from "./impl/subindex.js";
2
- export * as default from "./impl/subindex.js";
1
+ import type { Stats } from "node:fs";
2
+ import { readdir, stat } from "node:fs/promises";
3
+ import type { DiveOptions } from "./impl/dive.js";
4
+ import { copy, copySync } from "./impl/copy.js";
5
+ import { createFile, createFileSync } from "./impl/create-file.js";
6
+ import { diveSync } from "./impl/dive.js";
7
+ import { emptyDir, emptyDirSync } from "./impl/empty-dir.js";
8
+ import { mkdirs, mkdirsSync } from "./impl/mkdirs.js";
9
+ import { move, moveSync } from "./impl/move.js";
10
+ import { outputFile, outputFileSync } from "./impl/output-file.js";
11
+ import { outputJson, outputJsonSync } from "./impl/output-json.js";
12
+ import { pathExists, pathExistsSync } from "./impl/path-exists.js";
13
+ import { readFile, readFileSync } from "./impl/read-file.js";
14
+ import { readJson, readJsonSync } from "./impl/read-json.js";
15
+ import { remove, removeSync } from "./impl/remove.js";
16
+ import { writeFile, writeFileSync } from "./impl/write-file.js";
17
+ import { writeJson, writeJsonSync } from "./impl/write-json.js";
18
+ export declare function dive(directory: string, action: (file: string, stat: Stats) => void | Promise<void>, options?: DiveOptions): Promise<void>;
19
+ export declare function dive(directory: string, options?: DiveOptions): Promise<string[]>;
20
+ declare const mkdirp: typeof mkdirs;
21
+ declare const ensureDir: typeof mkdirs;
22
+ declare const ensureFile: typeof createFile;
23
+ declare const rimraf: typeof remove;
24
+ declare const ncp: typeof copy;
25
+ declare const mkdirpSync: typeof mkdirsSync;
26
+ declare const ensureDirSync: typeof mkdirsSync;
27
+ declare const ensureFileSync: typeof createFileSync;
28
+ declare const rimrafSync: typeof removeSync;
29
+ declare const ncpSync: typeof copySync;
30
+ export { readJson, writeJson, createFile, writeFile, readFile, mkdirs, emptyDir, pathExists, copy, move, remove, readdir, stat, readJsonSync, writeJsonSync, createFileSync, writeFileSync, readFileSync, mkdirsSync, emptyDirSync, pathExistsSync, copySync, moveSync, removeSync, mkdirp, mkdirpSync, rimraf, rimrafSync, ncp, ncpSync, ensureDir, ensureDirSync, ensureFile, ensureFileSync, outputJson, outputJsonSync, outputFile, outputFileSync, diveSync, };
31
+ export type { CopyOptions } from "./impl/copy.js";
32
+ export type { MoveOptions } from "./impl/move.js";
33
+ export type { ReadFileOptions } from "./impl/read-file.js";
34
+ export type { ReadJsonOptions } from "./impl/read-json.js";
35
+ export type { JsonStringifyOptions } from "./impl/write-json.js";
36
+ export type { WriteJsonOptions } from "./impl/write-json.js";
package/bin/mod.js CHANGED
@@ -1,2 +1,144 @@
1
- export * from "./impl/subindex.js";
2
- export * as default from "./impl/subindex.js";
1
+ import { readdir as nodeReaddirInternal, stat as nodeStatInternal, readdir, stat } from "node:fs/promises";
2
+ import { join as pathJoin } from "node:path";
3
+ import { copy, copySync } from "./impl/copy.js";
4
+ import { createFile, createFileSync } from "./impl/create-file.js";
5
+ import { diveSync } from "./impl/dive.js";
6
+ import { emptyDir, emptyDirSync } from "./impl/empty-dir.js";
7
+ import { mkdirs, mkdirsSync } from "./impl/mkdirs.js";
8
+ import { move, moveSync } from "./impl/move.js";
9
+ import { outputFile, outputFileSync } from "./impl/output-file.js";
10
+ import { outputJson, outputJsonSync } from "./impl/output-json.js";
11
+ import { pathExists, pathExistsSync } from "./impl/path-exists.js";
12
+ import { readFile, readFileSync } from "./impl/read-file.js";
13
+ import { readJson, readJsonSync } from "./impl/read-json.js";
14
+ import { remove, removeSync } from "./impl/remove.js";
15
+ import { writeFile, writeFileSync } from "./impl/write-file.js";
16
+ import { writeJson, writeJsonSync } from "./impl/write-json.js";
17
+ async function* _diveWorker(currentPath, options, currentDepth) {
18
+ const maxDepth = options.depth ?? Number.POSITIVE_INFINITY;
19
+ if (currentDepth > maxDepth) {
20
+ return;
21
+ }
22
+ let entries;
23
+ try {
24
+ entries = await nodeReaddirInternal(currentPath, { withFileTypes: true });
25
+ } catch (_err) {
26
+ return;
27
+ }
28
+ for (const entry of entries) {
29
+ const entryPath = pathJoin(currentPath, entry.name);
30
+ if (!(options.all ?? false) && entry.name.startsWith(".")) {
31
+ continue;
32
+ }
33
+ if (options.ignore) {
34
+ if (Array.isArray(options.ignore) && options.ignore.some((pattern) => entry.name.includes(pattern))) {
35
+ continue;
36
+ }
37
+ if (options.ignore instanceof RegExp && options.ignore.test(entryPath)) {
38
+ continue;
39
+ }
40
+ }
41
+ let entryStat;
42
+ try {
43
+ entryStat = await nodeStatInternal(entryPath);
44
+ } catch (_err) {
45
+ continue;
46
+ }
47
+ if (entry.isDirectory()) {
48
+ if (options.directories ?? false) {
49
+ yield { file: entryPath, stat: entryStat };
50
+ }
51
+ if (options.recursive ?? true) {
52
+ if (currentDepth < maxDepth) {
53
+ yield* _diveWorker(entryPath, options, currentDepth + 1);
54
+ }
55
+ }
56
+ } else if (entry.isFile()) {
57
+ if (options.files ?? true) {
58
+ yield { file: entryPath, stat: entryStat };
59
+ }
60
+ }
61
+ }
62
+ }
63
+ export async function dive(directory, actionOrOptions, optionsOnly) {
64
+ let action;
65
+ let options;
66
+ if (typeof actionOrOptions === "function") {
67
+ action = actionOrOptions;
68
+ options = optionsOnly;
69
+ } else {
70
+ options = actionOrOptions;
71
+ }
72
+ const currentOptions = {
73
+ recursive: true,
74
+ files: true,
75
+ directories: false,
76
+ all: false,
77
+ depth: Number.POSITIVE_INFINITY,
78
+ ...options
79
+ // User options override defaults
80
+ };
81
+ if (action) {
82
+ for await (const { file, stat: entryStat } of _diveWorker(directory, currentOptions, 0)) {
83
+ await action(file, entryStat);
84
+ }
85
+ return;
86
+ } else {
87
+ const results = [];
88
+ for await (const { file } of _diveWorker(directory, currentOptions, 0)) {
89
+ results.push(file);
90
+ }
91
+ return results;
92
+ }
93
+ }
94
+ const mkdirp = mkdirs;
95
+ const ensureDir = mkdirs;
96
+ const ensureFile = createFile;
97
+ const rimraf = remove;
98
+ const ncp = copy;
99
+ const mkdirpSync = mkdirsSync;
100
+ const ensureDirSync = mkdirsSync;
101
+ const ensureFileSync = createFileSync;
102
+ const rimrafSync = removeSync;
103
+ const ncpSync = copySync;
104
+ export {
105
+ readJson,
106
+ writeJson,
107
+ createFile,
108
+ writeFile,
109
+ readFile,
110
+ mkdirs,
111
+ emptyDir,
112
+ pathExists,
113
+ copy,
114
+ move,
115
+ remove,
116
+ readdir,
117
+ stat,
118
+ readJsonSync,
119
+ writeJsonSync,
120
+ createFileSync,
121
+ writeFileSync,
122
+ readFileSync,
123
+ mkdirsSync,
124
+ emptyDirSync,
125
+ pathExistsSync,
126
+ copySync,
127
+ moveSync,
128
+ removeSync,
129
+ mkdirp,
130
+ mkdirpSync,
131
+ rimraf,
132
+ rimrafSync,
133
+ ncp,
134
+ ncpSync,
135
+ ensureDir,
136
+ ensureDirSync,
137
+ ensureFile,
138
+ ensureFileSync,
139
+ outputJson,
140
+ outputJsonSync,
141
+ outputFile,
142
+ outputFileSync,
143
+ diveSync
144
+ };
package/package.json CHANGED
@@ -1,14 +1,18 @@
1
1
  {
2
2
  "dependencies": {
3
+ "@reliverse/relinka": "^1.4.5",
3
4
  "fs-extra": "^11.3.0",
4
- "jsonfile": "^6.1.0"
5
+ "jsonfile": "^6.1.0",
6
+ "magic-string": "^0.30.17",
7
+ "p-map": "^7.0.3",
8
+ "zeptomatch": "^2.0.1"
5
9
  },
6
- "description": "@reliverse/relifso is a modern filesystem toolkit for builders. Drop-in replacement for node:fs and fs-extra — powered by native promises, built with ES modules, and packed with Bun-specific features and DX-focused utilities.",
10
+ "description": "@reliverse/relifso is a modern filesystem toolkit for builders. Drop-in replacement for node:fs and fs-extra — powered by native promises, built with ES modules, and packed with DX-focused utilities.",
7
11
  "homepage": "https://docs.reliverse.org",
8
12
  "license": "MIT",
9
13
  "name": "@reliverse/relifso",
10
14
  "type": "module",
11
- "version": "1.1.3",
15
+ "version": "1.2.1",
12
16
  "keywords": [
13
17
  "fs",
14
18
  "file",
@@ -37,10 +41,8 @@
37
41
  "@babel/plugin-transform-block-scoping": "^7.27.1",
38
42
  "@biomejs/biome": "1.9.4",
39
43
  "@cspotcode/source-map-support": "^0.8.1",
40
- "@eslint/js": "^9.26.0",
41
- "@reliverse/cli-cfg": "^1.6.5",
42
- "@reliverse/dler": "^1.2.6",
43
- "@reliverse/relidler-cfg": "^1.1.3",
44
+ "@eslint/js": "^9.27.0",
45
+ "@reliverse/dler": "^1.3.6",
44
46
  "@rollup/plugin-alias": "^5.1.1",
45
47
  "@rollup/plugin-babel": "^6.0.4",
46
48
  "@rollup/plugin-commonjs": "^28.0.3",
@@ -64,7 +66,7 @@
64
66
  "@typescript-eslint/eslint-plugin": "^8.32.1",
65
67
  "@typescript-eslint/parser": "^8.32.1",
66
68
  "@uwx/fsxt-rollup-plugin-dts": "^6.0.2",
67
- "eslint": "^9.26.0",
69
+ "eslint": "^9.27.0",
68
70
  "eslint-config-google": "^0.14.0",
69
71
  "eslint-plugin-no-relative-import-paths": "^1.6.1",
70
72
  "eslint-plugin-perfectionist": "^4.13.0",
@@ -78,7 +80,7 @@
78
80
  "proxyquire": "^2.1.3",
79
81
  "read-dir-files": "^0.1.1",
80
82
  "rimraf": "^6.0.1",
81
- "rollup": "^4.40.2",
83
+ "rollup": "^4.41.0",
82
84
  "rollup-plugin-bundle-size": "^1.0.3",
83
85
  "rollup-plugin-typescript-paths": "^1.5.0",
84
86
  "ts-node": "^10.9.2",