@visulima/fs 4.1.0 → 5.0.0-alpha.10

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 (156) hide show
  1. package/CHANGELOG.md +188 -0
  2. package/LICENSE.md +157 -128
  3. package/README.md +32 -14
  4. package/dist/eol.d.ts +6 -35
  5. package/dist/error.d.ts +43 -7
  6. package/dist/error.js +1 -1
  7. package/dist/glob-parent.d.ts +5 -0
  8. package/dist/glob-parent.js +90 -0
  9. package/dist/glob.d.ts +5 -0
  10. package/dist/glob.js +2 -0
  11. package/dist/index.d.ts +81 -36
  12. package/dist/index.js +37 -32
  13. package/dist/ini.d.ts +10 -0
  14. package/dist/ini.js +4 -0
  15. package/dist/is-glob.d.ts +5 -0
  16. package/dist/is-glob.js +9 -0
  17. package/dist/json5.d.ts +12 -0
  18. package/dist/json5.js +4 -0
  19. package/dist/jsonc.d.ts +10 -0
  20. package/dist/jsonc.js +4 -0
  21. package/dist/match.d.ts +5 -0
  22. package/dist/match.js +15 -0
  23. package/dist/packem_shared/{F_OK-BalxCn9n.js → F_OK-MldBaGxb.js} +1 -1
  24. package/dist/packem_shared/{WalkError-DUdQd6FT.js → WalkError-DER5A43G.js} +1 -1
  25. package/dist/packem_shared/_commonjsHelpers-BqLXS_qQ.js +5 -0
  26. package/dist/packem_shared/build-rm-options-Cl3VDY4O.js +12 -0
  27. package/dist/packem_shared/{collect-DcBwsYYd.js → collect-CqQ3eVab.js} +1 -1
  28. package/dist/packem_shared/{collectSync-Bkjf9Dbm.js → collectSync-noE08NNv.js} +1 -1
  29. package/dist/packem_shared/{emptyDir-CYB5Tict.js → emptyDir-DnwENOaV.js} +5 -2
  30. package/dist/packem_shared/{emptyDirSync-BD8-1Ytl.js → emptyDirSync-6WiHBo8a.js} +3 -1
  31. package/dist/packem_shared/{ensureDir-C_kuQ5Ik.js → ensureDir-DNlPftys.js} +2 -2
  32. package/dist/packem_shared/{ensureDirSync-CI5g-uBI.js → ensureDirSync-DcPZFMy5.js} +2 -2
  33. package/dist/packem_shared/{ensureFile-BUtXGlGT.js → ensureFile-BRQpUOUM.js} +2 -2
  34. package/dist/packem_shared/{ensureFileSync-C8hASR-1.js → ensureFileSync-SBY7A9-C.js} +2 -2
  35. package/dist/packem_shared/{ensureLink-BPnAG5-P.js → ensureLink-DJQeauEn.js} +4 -3
  36. package/dist/packem_shared/{ensureLinkSync-B-Z7X0ub.js → ensureLinkSync-D9RVAglV.js} +4 -3
  37. package/dist/packem_shared/{ensureSymlink-U5B6J0BN.js → ensureSymlink-CoRYDRwr.js} +10 -3
  38. package/dist/packem_shared/{ensureSymlinkSync-DHnZj-9F.js → ensureSymlinkSync-CFimFlgh.js} +10 -3
  39. package/dist/packem_shared/{findUp-Lv9mZCIQ.js → findUp-YcNLKdfV.js} +4 -5
  40. package/dist/packem_shared/{findUpSync-BsK4Nrrq.js → findUpSync-BfA5fheN.js} +2 -4
  41. package/dist/packem_shared/glob-DY8l7izD.js +5 -0
  42. package/dist/packem_shared/glob-sync.d-CYiamQIr.d.ts +4 -0
  43. package/dist/packem_shared/globSync-5P2KJf_g.js +5 -0
  44. package/dist/packem_shared/index-C8W8sfzP.js +830 -0
  45. package/dist/packem_shared/index-bhgnhm4u.js +167 -0
  46. package/dist/packem_shared/index-xe4o3cYi.js +1784 -0
  47. package/dist/packem_shared/{parseJson-C8xb-3LR.js → indexToLineColumn-BUb0GPKl-BF770uX7.js} +8 -68
  48. package/dist/packem_shared/ini-preserve-Dq_Q_Jgb.js +251 -0
  49. package/dist/packem_shared/{isAccessible-iOp0Bou6.js → isAccessible-DuVrTNFV.js} +1 -1
  50. package/dist/packem_shared/{isAccessibleSync-38BmiIcx.js → isAccessibleSync-DI8mM0fA.js} +1 -1
  51. package/dist/packem_shared/{isFsCaseSensitive-D-ayleCy.js → isFsCaseSensitive-DunL7Iry.js} +6 -6
  52. package/dist/packem_shared/json-error.d-DgKaeuIf.d.ts +10 -0
  53. package/dist/packem_shared/jsonc-merge-C6jWcfWh.js +72 -0
  54. package/dist/packem_shared/{move-BD6JbYSu.js → move-DbpW5_vA.js} +2 -2
  55. package/dist/packem_shared/parseJson-BIp89Xjo.js +63 -0
  56. package/dist/packem_shared/{readFile-BcK0rkht.js → readFile-Iz7kvCCk.js} +2 -2
  57. package/dist/packem_shared/{readFileSync-BDgEnnqT.js → readFileSync-gm9yfIhh.js} +4 -3
  58. package/dist/packem_shared/readIni-CJ2xfpjB.js +10 -0
  59. package/dist/packem_shared/readIniSync-9LUjaSSp.js +10 -0
  60. package/dist/packem_shared/{readJson-ac6N9-5G.js → readJson-C_rwm-wq.js} +2 -2
  61. package/dist/packem_shared/readJson5-mBoTZppy.js +15 -0
  62. package/dist/packem_shared/readJson5Sync-8WS2yUok.js +15 -0
  63. package/dist/packem_shared/{readJsonSync-BTlwqLNV.js → readJsonSync-BMEmCcJ6.js} +2 -2
  64. package/dist/packem_shared/readJsonc-j-OS-APg.js +28 -0
  65. package/dist/packem_shared/readJsoncSync-Aw6EMlWO.js +16 -0
  66. package/dist/packem_shared/readToml-B2MHaSes.js +9 -0
  67. package/dist/packem_shared/readTomlSync-DNbK8NEb.js +9 -0
  68. package/dist/packem_shared/{readYaml-Cj6HxRoa.js → readYaml-D5q2a0e1.js} +1 -1
  69. package/dist/packem_shared/{readYamlSync-D3_iAKVv.js → readYamlSync-BKX-PAfq.js} +1 -1
  70. package/dist/packem_shared/{remove-_oDY3uKo.js → remove-C8_gl3jF.js} +2 -1
  71. package/dist/packem_shared/{removeSync-DETRj7Qn.js → removeSync-BJR_wTwN.js} +2 -1
  72. package/dist/packem_shared/{sanitize-lOzE6k2A.js → sanitize-BZoLN9Fg.js} +3 -3
  73. package/dist/packem_shared/{stripJsonComments-21XWVDwP.js → stripJsonComments-vo4k0mpF.js} +1 -1
  74. package/dist/packem_shared/types.d-BrSrwTmO.d.ts +145 -0
  75. package/dist/packem_shared/{walk-BhTbpr3y.js → walk-CSZgCuDx.js} +19 -10
  76. package/dist/packem_shared/{walkSync-DDBq95s8.js → walkSync-C4Cy28xb.js} +25 -16
  77. package/dist/packem_shared/{writeFile-NT1fLEEe.js → writeFile-B8HX0JIQ.js} +3 -5
  78. package/dist/packem_shared/{writeFileSync-Bj5UDSf0.js → writeFileSync-DB8vv8xR.js} +3 -5
  79. package/dist/packem_shared/writeIni-i55QrL8y.js +65 -0
  80. package/dist/packem_shared/writeIniSync-CLqJE5t3.js +64 -0
  81. package/dist/packem_shared/{writeJson-DQLdAi0d.js → writeJson-Bo7C2UHw.js} +3 -3
  82. package/dist/packem_shared/writeJson5-vVmHUQOd.js +53 -0
  83. package/dist/packem_shared/writeJson5Sync-oJ546h5k.js +53 -0
  84. package/dist/packem_shared/{writeJsonSync-DvTCjVUi.js → writeJsonSync-BKZ_9Acr.js} +3 -3
  85. package/dist/packem_shared/writeJsonc-BufH_oC5.js +60 -0
  86. package/dist/packem_shared/writeJsoncSync-DB9be1YL.js +59 -0
  87. package/dist/packem_shared/writeToml-DgTW_-7F.js +8 -0
  88. package/dist/packem_shared/writeTomlSync-DiBiE9ja.js +8 -0
  89. package/dist/packem_shared/{writeYaml-BMY0kOPf.js → writeYaml-BWCOome-.js} +3 -3
  90. package/dist/packem_shared/{writeYamlSync-DqPu8cCd.js → writeYamlSync-DBVnXmuY.js} +3 -3
  91. package/dist/size.d.ts +10 -254
  92. package/dist/size.js +6 -4
  93. package/dist/toml.d.ts +9 -0
  94. package/dist/toml.js +4 -0
  95. package/dist/utils.d.ts +15 -6
  96. package/dist/utils.js +2 -2
  97. package/dist/yaml.d.ts +14 -5
  98. package/dist/yaml.js +4 -4
  99. package/package.json +61 -7
  100. package/dist/constants.d.ts +0 -42
  101. package/dist/ensure/ensure-dir-sync.d.ts +0 -14
  102. package/dist/ensure/ensure-dir.d.ts +0 -14
  103. package/dist/ensure/ensure-file-sync.d.ts +0 -15
  104. package/dist/ensure/ensure-file.d.ts +0 -27
  105. package/dist/ensure/ensure-link-sync.d.ts +0 -16
  106. package/dist/ensure/ensure-link.d.ts +0 -16
  107. package/dist/ensure/ensure-symlink-sync.d.ts +0 -23
  108. package/dist/ensure/ensure-symlink.d.ts +0 -23
  109. package/dist/ensure/utils/get-file-info-type.d.ts +0 -7
  110. package/dist/ensure/utils/is-stats-identical.d.ts +0 -3
  111. package/dist/ensure/utils/resolve-symlink-target.d.ts +0 -2
  112. package/dist/error/already-exists-error.d.ts +0 -39
  113. package/dist/error/directory-error.d.ts +0 -47
  114. package/dist/error/json-error.d.ts +0 -52
  115. package/dist/error/not-empty-error.d.ts +0 -51
  116. package/dist/error/not-found-error.d.ts +0 -44
  117. package/dist/error/permission-error.d.ts +0 -45
  118. package/dist/error/walk-error.d.ts +0 -51
  119. package/dist/find/collect-sync.d.ts +0 -31
  120. package/dist/find/collect.d.ts +0 -35
  121. package/dist/find/find-up-sync.d.ts +0 -42
  122. package/dist/find/find-up.d.ts +0 -46
  123. package/dist/find/utils/glob-to-regexp.d.ts +0 -2
  124. package/dist/find/utils/walk-include.d.ts +0 -2
  125. package/dist/find/walk-sync.d.ts +0 -34
  126. package/dist/find/walk.d.ts +0 -37
  127. package/dist/is-accessible-sync.d.ts +0 -3
  128. package/dist/is-accessible.d.ts +0 -29
  129. package/dist/move/index.d.ts +0 -68
  130. package/dist/move/types.d.ts +0 -36
  131. package/dist/move/utils/internal-move-file-sync.d.ts +0 -3
  132. package/dist/move/utils/internal-move-file.d.ts +0 -3
  133. package/dist/move/utils/validate-same-directory.d.ts +0 -2
  134. package/dist/read/read-file-sync.d.ts +0 -37
  135. package/dist/read/read-file.d.ts +0 -41
  136. package/dist/read/read-json-sync.d.ts +0 -5
  137. package/dist/read/read-json.d.ts +0 -5
  138. package/dist/read/read-yaml-sync.d.ts +0 -4
  139. package/dist/read/read-yaml.d.ts +0 -4
  140. package/dist/remove/empty-dir-sync.d.ts +0 -23
  141. package/dist/remove/empty-dir.d.ts +0 -28
  142. package/dist/remove/remove-sync.d.ts +0 -27
  143. package/dist/remove/remove.d.ts +0 -32
  144. package/dist/sanitize.d.ts +0 -31
  145. package/dist/types.d.ts +0 -304
  146. package/dist/utils/assert-valid-file-contents.d.ts +0 -27
  147. package/dist/utils/assert-valid-file-or-directory-path.d.ts +0 -26
  148. package/dist/utils/parse-json.d.ts +0 -5
  149. package/dist/utils/strip-json-comments.d.ts +0 -44
  150. package/dist/write/utils/to-uint-8-array.d.ts +0 -2
  151. package/dist/write/write-file-sync.d.ts +0 -30
  152. package/dist/write/write-file.d.ts +0 -30
  153. package/dist/write/write-json-sync.d.ts +0 -29
  154. package/dist/write/write-json.d.ts +0 -30
  155. package/dist/write/write-yaml-sync.d.ts +0 -4
  156. package/dist/write/write-yaml.d.ts +0 -4
@@ -24,7 +24,7 @@ const {
24
24
  import { dirname } from '@visulima/path';
25
25
  import { toPath } from '@visulima/path/utils';
26
26
  import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
27
- import ensureDirSync from './ensureDirSync-CI5g-uBI.js';
27
+ import ensureDirSync from './ensureDirSync-DcPZFMy5.js';
28
28
  import { g as getFileInfoType } from './get-file-info-type-FD4-jsyg.js';
29
29
 
30
30
  const ensureFileSync = (filePath) => {
@@ -32,7 +32,7 @@ const ensureFileSync = (filePath) => {
32
32
  try {
33
33
  const stat = lstatSync(filePath);
34
34
  if (!stat.isFile()) {
35
- throw new Error(`Ensure path exists, expected 'file', got '${getFileInfoType(stat)}'`);
35
+ throw new Error(`Ensure path exists, expected 'file', got '${String(getFileInfoType(stat))}'`);
36
36
  }
37
37
  } catch (error) {
38
38
  if (error.code === "ENOENT") {
@@ -24,7 +24,7 @@ const {
24
24
  import { toNamespacedPath, dirname } from '@visulima/path';
25
25
  import { toPath } from '@visulima/path/utils';
26
26
  import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
27
- import ensureDir from './ensureDir-C_kuQ5Ik.js';
27
+ import ensureDir from './ensureDir-DNlPftys.js';
28
28
  import { i as isStatsIdentical } from './is-stats-identical-D8FxpvQU.js';
29
29
 
30
30
  const ensureLink = async (source, destination) => {
@@ -41,8 +41,9 @@ const ensureLink = async (source, destination) => {
41
41
  try {
42
42
  sourceStat = await lstat(source);
43
43
  } catch (error) {
44
- error.message = error.message.replace("lstat", "ensureLink");
45
- throw error;
44
+ const nodeError = error;
45
+ nodeError.message = nodeError.message.replace("lstat", "ensureLink");
46
+ throw nodeError;
46
47
  }
47
48
  if (destinationStat && isStatsIdentical(sourceStat, destinationStat)) {
48
49
  return;
@@ -24,7 +24,7 @@ const {
24
24
  import { toNamespacedPath, dirname } from '@visulima/path';
25
25
  import { toPath } from '@visulima/path/utils';
26
26
  import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
27
- import ensureDirSync from './ensureDirSync-CI5g-uBI.js';
27
+ import ensureDirSync from './ensureDirSync-DcPZFMy5.js';
28
28
  import { i as isStatsIdentical } from './is-stats-identical-D8FxpvQU.js';
29
29
 
30
30
  const ensureLinkSync = (source, destination) => {
@@ -41,8 +41,9 @@ const ensureLinkSync = (source, destination) => {
41
41
  try {
42
42
  sourceStat = lstatSync(source);
43
43
  } catch (error) {
44
- error.message = error.message.replace("lstat", "ensureLink");
45
- throw error;
44
+ const nodeError = error;
45
+ nodeError.message = nodeError.message.replace("lstat", "ensureLink");
46
+ throw nodeError;
46
47
  }
47
48
  if (destinationStat && isStatsIdentical(sourceStat, destinationStat)) {
48
49
  return;
@@ -26,7 +26,7 @@ const {
26
26
  import { toNamespacedPath, dirname, resolve } from '@visulima/path';
27
27
  import { toPath } from '@visulima/path/utils';
28
28
  import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
29
- import ensureDir from './ensureDir-C_kuQ5Ik.js';
29
+ import ensureDir from './ensureDir-DNlPftys.js';
30
30
  import { g as getFileInfoType } from './get-file-info-type-FD4-jsyg.js';
31
31
  import { i as isStatsIdentical } from './is-stats-identical-D8FxpvQU.js';
32
32
  import { r as resolveSymlinkTarget } from './resolve-symlink-target-Kh4GovFf.js';
@@ -51,7 +51,14 @@ const ensureSymlink = async (target, linkName, type) => {
51
51
  const sourceStatInfo = await lstat(targetRealPath);
52
52
  const sourceFilePathType = getFileInfoType(sourceStatInfo);
53
53
  await ensureDir(dirname(linkName));
54
- const symlinkType = type ?? (isWindows ? "junction" : sourceFilePathType === "dir" ? "dir" : "file");
54
+ let symlinkType = type ?? "file";
55
+ if (!type) {
56
+ if (isWindows) {
57
+ symlinkType = "junction";
58
+ } else {
59
+ symlinkType = sourceFilePathType === "dir" ? "dir" : "file";
60
+ }
61
+ }
55
62
  try {
56
63
  await symlink(toNamespacedPath(toPath(targetRealPath)), linkName, symlinkType);
57
64
  } catch (error) {
@@ -60,7 +67,7 @@ const ensureSymlink = async (target, linkName, type) => {
60
67
  }
61
68
  const linkStatInfo = await lstat(linkName);
62
69
  if (!linkStatInfo.isSymbolicLink()) {
63
- throw new AlreadyExistsError(`A ${getFileInfoType(linkStatInfo)} already exists at the path: ${linkName}`);
70
+ throw new AlreadyExistsError(`A ${String(getFileInfoType(linkStatInfo))} already exists at the path: ${linkName}`);
64
71
  }
65
72
  const linkPath = await readlink(linkName);
66
73
  const linkRealPath = toNamespacedPath(resolve(linkPath));
@@ -26,7 +26,7 @@ const {
26
26
  import { toNamespacedPath, dirname, resolve } from '@visulima/path';
27
27
  import { toPath } from '@visulima/path/utils';
28
28
  import assertValidFileOrDirectoryPath from './assertValidFileOrDirectoryPath-8HANmVjk.js';
29
- import ensureDirSync from './ensureDirSync-CI5g-uBI.js';
29
+ import ensureDirSync from './ensureDirSync-DcPZFMy5.js';
30
30
  import { g as getFileInfoType } from './get-file-info-type-FD4-jsyg.js';
31
31
  import { i as isStatsIdentical } from './is-stats-identical-D8FxpvQU.js';
32
32
  import { r as resolveSymlinkTarget } from './resolve-symlink-target-Kh4GovFf.js';
@@ -52,7 +52,14 @@ const ensureSymlinkSync = (target, linkName, type) => {
52
52
  const sourceStatInfo = lstatSync(targetRealPath);
53
53
  const sourceFilePathType = getFileInfoType(sourceStatInfo);
54
54
  ensureDirSync(dirname(linkName));
55
- const symlinkType = type ?? (isWindows ? "junction" : sourceFilePathType === "dir" ? "dir" : "file");
55
+ let symlinkType = type ?? "file";
56
+ if (!type) {
57
+ if (isWindows) {
58
+ symlinkType = "junction";
59
+ } else {
60
+ symlinkType = sourceFilePathType === "dir" ? "dir" : "file";
61
+ }
62
+ }
56
63
  try {
57
64
  symlinkSync(toNamespacedPath(toPath(targetRealPath)), linkName, symlinkType);
58
65
  } catch (error) {
@@ -61,7 +68,7 @@ const ensureSymlinkSync = (target, linkName, type) => {
61
68
  }
62
69
  const linkStatInfo = lstatSync(linkName);
63
70
  if (!linkStatInfo.isSymbolicLink()) {
64
- throw new AlreadyExistsError(`A ${getFileInfoType(linkStatInfo)} already exists at the path: ${linkName}`);
71
+ throw new AlreadyExistsError(`A ${String(getFileInfoType(linkStatInfo))} already exists at the path: ${linkName}`);
65
72
  }
66
73
  const linkPath = readlinkSync(linkName);
67
74
  const linkRealPath = toNamespacedPath(resolve(linkPath));
@@ -26,7 +26,7 @@ const {
26
26
  } = __cjs_getBuiltinModule("node:url");
27
27
  import { resolve, parse, isAbsolute, dirname } from '@visulima/path';
28
28
  import { toPath } from '@visulima/path/utils';
29
- import { FIND_UP_STOP } from './F_OK-BalxCn9n.js';
29
+ import { FIND_UP_STOP } from './F_OK-MldBaGxb.js';
30
30
 
31
31
  const findUp = async (name, options = {}) => {
32
32
  if (typeof name !== "string" && !Array.isArray(name) && typeof name !== "function") {
@@ -51,12 +51,11 @@ const findUp = async (name, options = {}) => {
51
51
  }
52
52
  return [name];
53
53
  };
54
- if (options.allowSymlinks === void 0) {
55
- options.allowSymlinks = true;
56
- }
54
+ options.allowSymlinks ??= true;
57
55
  const statFunction = options.allowSymlinks ? stat : lstat;
58
56
  while (directory && directory !== stopAt && directory !== root) {
59
- for await (let fileName of await getMatchers(directory)) {
57
+ const matchers = await getMatchers(directory);
58
+ for (let fileName of matchers) {
60
59
  if (fileName === FIND_UP_STOP) {
61
60
  return void 0;
62
61
  }
@@ -26,7 +26,7 @@ const {
26
26
  } = __cjs_getBuiltinModule("node:url");
27
27
  import { resolve, parse, isAbsolute, dirname } from '@visulima/path';
28
28
  import { toPath } from '@visulima/path/utils';
29
- import { FIND_UP_STOP } from './F_OK-BalxCn9n.js';
29
+ import { FIND_UP_STOP } from './F_OK-MldBaGxb.js';
30
30
 
31
31
  const findUpSync = (name, options = {}) => {
32
32
  if (typeof name !== "string" && !Array.isArray(name) && typeof name !== "function") {
@@ -51,9 +51,7 @@ const findUpSync = (name, options = {}) => {
51
51
  }
52
52
  return [name];
53
53
  };
54
- if (options.allowSymlinks === void 0) {
55
- options.allowSymlinks = true;
56
- }
54
+ options.allowSymlinks ??= true;
57
55
  const statFunction = options.allowSymlinks ? statSync : lstatSync;
58
56
  while (directory && directory !== stopAt && directory !== root) {
59
57
  for (let fileName of getMatchers(directory)) {
@@ -0,0 +1,5 @@
1
+ import { g as glob$1 } from './index-C8W8sfzP.js';
2
+
3
+ const glob = async (patterns, options) => await glob$1(patterns, options);
4
+
5
+ export { glob as default };
@@ -0,0 +1,4 @@
1
+ import { G as GlobOptions } from "./types.d-BrSrwTmO.js";
2
+ declare const glob: (patterns: string | ReadonlyArray<string>, options?: GlobOptions) => Promise<string[]>;
3
+ declare const globSync: (patterns: string | ReadonlyArray<string>, options?: GlobOptions) => string[];
4
+ export { globSync as a, glob as g };
@@ -0,0 +1,5 @@
1
+ import { a as globSync$1 } from './index-C8W8sfzP.js';
2
+
3
+ const globSync = (patterns, options) => globSync$1(patterns, options);
4
+
5
+ export { globSync as default };