@socketsecurity/lib 3.0.2 → 3.0.4

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 (261) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/dist/abort.js +60 -1
  3. package/dist/abort.js.map +2 -2
  4. package/dist/agent.js +289 -1
  5. package/dist/agent.js.map +2 -2
  6. package/dist/ansi.js +60 -1
  7. package/dist/ansi.js.map +2 -2
  8. package/dist/argv/flags.js +282 -1
  9. package/dist/argv/flags.js.map +2 -2
  10. package/dist/argv/parse.js +171 -1
  11. package/dist/argv/parse.js.map +2 -2
  12. package/dist/arrays.js +85 -1
  13. package/dist/arrays.js.map +2 -2
  14. package/dist/bin.js +419 -5
  15. package/dist/bin.js.map +2 -2
  16. package/dist/cacache.js +139 -1
  17. package/dist/cacache.js.map +2 -2
  18. package/dist/cache-with-ttl.js +223 -1
  19. package/dist/cache-with-ttl.js.map +2 -2
  20. package/dist/constants/agents.js +126 -1
  21. package/dist/constants/agents.js.map +2 -2
  22. package/dist/constants/core.js +57 -2
  23. package/dist/constants/core.js.map +2 -2
  24. package/dist/constants/encoding.js +48 -1
  25. package/dist/constants/encoding.js.map +2 -2
  26. package/dist/constants/github.js +30 -1
  27. package/dist/constants/github.js.map +2 -2
  28. package/dist/constants/licenses.js +66 -1
  29. package/dist/constants/licenses.js.map +2 -2
  30. package/dist/constants/node.js +185 -1
  31. package/dist/constants/node.js.map +2 -2
  32. package/dist/constants/packages.js +128 -1
  33. package/dist/constants/packages.js.map +2 -2
  34. package/dist/constants/paths.js +150 -1
  35. package/dist/constants/paths.js.map +2 -2
  36. package/dist/constants/platform.js +41 -1
  37. package/dist/constants/platform.js.map +2 -2
  38. package/dist/constants/process.js +52 -1
  39. package/dist/constants/process.js.map +2 -2
  40. package/dist/constants/socket.js +102 -1
  41. package/dist/constants/socket.js.map +2 -2
  42. package/dist/constants/testing.js +36 -1
  43. package/dist/constants/testing.js.map +2 -2
  44. package/dist/constants/time.js +39 -1
  45. package/dist/constants/time.js.map +2 -2
  46. package/dist/constants/typescript.js +54 -1
  47. package/dist/constants/typescript.js.map +2 -2
  48. package/dist/cover/code.js +135 -1
  49. package/dist/cover/code.js.map +2 -2
  50. package/dist/cover/formatters.js +101 -11
  51. package/dist/cover/formatters.js.map +2 -2
  52. package/dist/cover/type.js +63 -1
  53. package/dist/cover/type.js.map +2 -2
  54. package/dist/cover/types.js +15 -1
  55. package/dist/cover/types.js.map +2 -2
  56. package/dist/debug.js +337 -2
  57. package/dist/debug.js.map +2 -2
  58. package/dist/dlx-binary.js +408 -7
  59. package/dist/dlx-binary.js.map +2 -2
  60. package/dist/dlx-package.js +278 -7
  61. package/dist/dlx-package.js.map +2 -2
  62. package/dist/dlx.js +214 -7
  63. package/dist/dlx.js.map +3 -3
  64. package/dist/effects/pulse-frames.js +64 -1
  65. package/dist/effects/pulse-frames.js.map +2 -2
  66. package/dist/effects/text-shimmer.js +174 -1
  67. package/dist/effects/text-shimmer.js.map +2 -2
  68. package/dist/effects/types.js +15 -1
  69. package/dist/effects/types.js.map +2 -2
  70. package/dist/effects/ultra.js +61 -1
  71. package/dist/effects/ultra.js.map +2 -2
  72. package/dist/env/ci.js +31 -1
  73. package/dist/env/ci.js.map +2 -2
  74. package/dist/env/debug.js +30 -1
  75. package/dist/env/debug.js.map +2 -2
  76. package/dist/env/github.js +65 -1
  77. package/dist/env/github.js.map +2 -2
  78. package/dist/env/helpers.js +47 -1
  79. package/dist/env/helpers.js.map +2 -2
  80. package/dist/env/home.js +30 -1
  81. package/dist/env/home.js.map +2 -2
  82. package/dist/env/locale.js +40 -1
  83. package/dist/env/locale.js.map +2 -2
  84. package/dist/env/node-auth-token.js +30 -1
  85. package/dist/env/node-auth-token.js.map +2 -2
  86. package/dist/env/node-env.js +30 -1
  87. package/dist/env/node-env.js.map +2 -2
  88. package/dist/env/npm.js +50 -1
  89. package/dist/env/npm.js.map +2 -2
  90. package/dist/env/package-manager.js +73 -1
  91. package/dist/env/package-manager.js.map +2 -2
  92. package/dist/env/path.js +30 -1
  93. package/dist/env/path.js.map +2 -2
  94. package/dist/env/pre-commit.js +31 -1
  95. package/dist/env/pre-commit.js.map +2 -2
  96. package/dist/env/rewire.js +72 -1
  97. package/dist/env/rewire.js.map +2 -2
  98. package/dist/env/shell.js +30 -1
  99. package/dist/env/shell.js.map +2 -2
  100. package/dist/env/socket-cli-shadow.js +51 -1
  101. package/dist/env/socket-cli-shadow.js.map +2 -2
  102. package/dist/env/socket-cli.js +86 -1
  103. package/dist/env/socket-cli.js.map +2 -2
  104. package/dist/env/socket.js +101 -1
  105. package/dist/env/socket.js.map +2 -2
  106. package/dist/env/temp-dir.js +40 -1
  107. package/dist/env/temp-dir.js.map +2 -2
  108. package/dist/env/term.js +30 -1
  109. package/dist/env/term.js.map +2 -2
  110. package/dist/env/test.js +43 -1
  111. package/dist/env/test.js.map +2 -2
  112. package/dist/env/windows.js +45 -1
  113. package/dist/env/windows.js.map +2 -2
  114. package/dist/env/xdg.js +40 -1
  115. package/dist/env/xdg.js.map +2 -2
  116. package/dist/env.js +170 -1
  117. package/dist/env.js.map +2 -2
  118. package/dist/external/@socketregistry/packageurl-js.js +12 -2
  119. package/dist/fs.js +670 -7
  120. package/dist/fs.js.map +2 -2
  121. package/dist/functions.js +68 -1
  122. package/dist/functions.js.map +2 -2
  123. package/dist/git.js +329 -2
  124. package/dist/git.js.map +2 -2
  125. package/dist/github.js +202 -1
  126. package/dist/github.js.map +2 -2
  127. package/dist/globs.js +149 -1
  128. package/dist/globs.js.map +2 -2
  129. package/dist/http-request.js +335 -3
  130. package/dist/http-request.js.map +2 -2
  131. package/dist/index.js +69 -1
  132. package/dist/index.js.map +2 -2
  133. package/dist/ipc.js +244 -1
  134. package/dist/ipc.js.map +2 -2
  135. package/dist/json.js +73 -1
  136. package/dist/json.js.map +2 -2
  137. package/dist/links/index.js +60 -1
  138. package/dist/links/index.js.map +2 -2
  139. package/dist/logger.js +1383 -6
  140. package/dist/logger.js.map +2 -2
  141. package/dist/maintained-node-versions.js +35 -1
  142. package/dist/maintained-node-versions.js.map +2 -2
  143. package/dist/memoization.js +210 -1
  144. package/dist/memoization.js.map +2 -2
  145. package/dist/objects.js +311 -1
  146. package/dist/objects.js.map +3 -3
  147. package/dist/packages/editable.js +356 -9
  148. package/dist/packages/editable.js.map +2 -2
  149. package/dist/packages/exports.js +162 -1
  150. package/dist/packages/exports.js.map +2 -2
  151. package/dist/packages/isolation.js +187 -1
  152. package/dist/packages/isolation.js.map +2 -2
  153. package/dist/packages/licenses.js +214 -1
  154. package/dist/packages/licenses.js.map +2 -2
  155. package/dist/packages/manifest.js +190 -1
  156. package/dist/packages/manifest.js.map +2 -2
  157. package/dist/packages/normalize.js +132 -1
  158. package/dist/packages/normalize.js.map +2 -2
  159. package/dist/packages/operations.js +320 -1
  160. package/dist/packages/operations.js.map +2 -2
  161. package/dist/packages/paths.js +53 -1
  162. package/dist/packages/paths.js.map +2 -2
  163. package/dist/packages/provenance.js +178 -1
  164. package/dist/packages/provenance.js.map +2 -2
  165. package/dist/packages/specs.js +83 -1
  166. package/dist/packages/specs.js.map +2 -2
  167. package/dist/packages/validation.js +51 -1
  168. package/dist/packages/validation.js.map +2 -2
  169. package/dist/packages.js +129 -1
  170. package/dist/packages.js.map +2 -2
  171. package/dist/path.js +446 -1
  172. package/dist/path.js.map +2 -2
  173. package/dist/paths/rewire.js +79 -1
  174. package/dist/paths/rewire.js.map +2 -2
  175. package/dist/paths.js +190 -1
  176. package/dist/paths.js.map +2 -2
  177. package/dist/performance.js +216 -15
  178. package/dist/performance.js.map +2 -2
  179. package/dist/process-lock.js +287 -8
  180. package/dist/process-lock.js.map +2 -2
  181. package/dist/promise-queue.js +109 -1
  182. package/dist/promise-queue.js.map +2 -2
  183. package/dist/promises.js +267 -1
  184. package/dist/promises.js.map +2 -2
  185. package/dist/prompts/index.js +45 -1
  186. package/dist/prompts/index.js.map +2 -2
  187. package/dist/prompts.js +58 -1
  188. package/dist/prompts.js.map +2 -2
  189. package/dist/regexps.js +30 -1
  190. package/dist/regexps.js.map +2 -2
  191. package/dist/sea.js +44 -1
  192. package/dist/sea.js.map +2 -2
  193. package/dist/shadow.js +58 -1
  194. package/dist/shadow.js.map +2 -2
  195. package/dist/signal-exit.js +248 -1
  196. package/dist/signal-exit.js.map +2 -2
  197. package/dist/sorts.js +94 -1
  198. package/dist/sorts.js.map +2 -2
  199. package/dist/spawn.js +200 -1
  200. package/dist/spawn.js.map +2 -2
  201. package/dist/spinner.js +965 -1
  202. package/dist/spinner.js.map +3 -3
  203. package/dist/ssri.js +71 -1
  204. package/dist/ssri.js.map +2 -2
  205. package/dist/stdio/clear.js +82 -1
  206. package/dist/stdio/clear.js.map +2 -2
  207. package/dist/stdio/divider.js +89 -3
  208. package/dist/stdio/divider.js.map +2 -2
  209. package/dist/stdio/footer.js +94 -2
  210. package/dist/stdio/footer.js.map +2 -2
  211. package/dist/stdio/header.js +100 -2
  212. package/dist/stdio/header.js.map +2 -2
  213. package/dist/stdio/mask.js +207 -5
  214. package/dist/stdio/mask.js.map +2 -2
  215. package/dist/stdio/progress.js +209 -2
  216. package/dist/stdio/progress.js.map +2 -2
  217. package/dist/stdio/prompts.js +88 -1
  218. package/dist/stdio/prompts.js.map +2 -2
  219. package/dist/stdio/stderr.js +89 -2
  220. package/dist/stdio/stderr.js.map +2 -2
  221. package/dist/stdio/stdout.js +103 -2
  222. package/dist/stdio/stdout.js.map +2 -2
  223. package/dist/streams.js +78 -1
  224. package/dist/streams.js.map +2 -2
  225. package/dist/strings.js +251 -3
  226. package/dist/strings.js.map +2 -2
  227. package/dist/suppress-warnings.js +98 -1
  228. package/dist/suppress-warnings.js.map +2 -2
  229. package/dist/tables.js +128 -3
  230. package/dist/tables.js.map +2 -2
  231. package/dist/temporary-executor.js +53 -1
  232. package/dist/temporary-executor.js.map +2 -2
  233. package/dist/themes/context.js +71 -1
  234. package/dist/themes/context.js.map +3 -3
  235. package/dist/themes/index.d.ts +2 -2
  236. package/dist/themes/index.js +57 -1
  237. package/dist/themes/index.js.map +3 -3
  238. package/dist/themes/themes.d.ts +5 -5
  239. package/dist/themes/themes.js +204 -1
  240. package/dist/themes/themes.js.map +3 -3
  241. package/dist/themes/types.js +15 -1
  242. package/dist/themes/types.js.map +2 -2
  243. package/dist/themes/utils.js +116 -1
  244. package/dist/themes/utils.js.map +2 -2
  245. package/dist/types.js +59 -1
  246. package/dist/types.js.map +2 -2
  247. package/dist/url.js +142 -1
  248. package/dist/url.js.map +2 -2
  249. package/dist/utils/get-ipc.js +58 -1
  250. package/dist/utils/get-ipc.js.map +2 -2
  251. package/dist/validation/json-parser.js +127 -1
  252. package/dist/validation/json-parser.js.map +2 -2
  253. package/dist/validation/types.js +15 -1
  254. package/dist/validation/types.js.map +2 -2
  255. package/dist/versions.js +154 -1
  256. package/dist/versions.js.map +2 -2
  257. package/dist/words.js +50 -1
  258. package/dist/words.js.map +2 -2
  259. package/dist/zod.js +27 -1
  260. package/dist/zod.js.map +2 -2
  261. package/package.json +2 -2
package/dist/fs.js CHANGED
@@ -1,9 +1,672 @@
1
1
  /* Socket Lib - Built with esbuild */
2
- var F=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var $=(n,e)=>{for(var t in e)F(n,t,{get:e[t],enumerable:!0})},B=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of W(e))!M.call(n,o)&&o!==t&&F(n,o,{get:()=>e[o],enumerable:!(i=T(e,o))||i.enumerable});return n};var q=n=>B(F({},"__esModule",{value:!0}),n);var ye={};$(ye,{findUp:()=>V,findUpSync:()=>G,invalidatePathCache:()=>I,isDir:()=>z,isDirEmptySync:()=>j,isDirSync:()=>X,isSymLinkSync:()=>K,readDirNames:()=>Q,readDirNamesSync:()=>Y,readFileBinary:()=>Z,readFileBinarySync:()=>ne,readFileUtf8:()=>ee,readFileUtf8Sync:()=>te,readJson:()=>ie,readJsonSync:()=>re,safeDelete:()=>oe,safeDeleteSync:()=>se,safeMkdir:()=>ae,safeMkdirSync:()=>ce,safeReadFile:()=>de,safeReadFileSync:()=>fe,safeStats:()=>U,safeStatsSync:()=>C,uniqueSync:()=>le,validateFiles:()=>H,writeJson:()=>ue,writeJsonSync:()=>pe});module.exports=q(ye);var v=require("#constants/process"),_=require("./arrays"),S=require("./globs"),b=require("./json"),D=require("./objects"),p=require("./path"),E=require("./paths/rewire"),R=require("./sorts");const w=(0,v.getAbortSignal)(),L=(0,D.objectFreeze)({__proto__:null,force:!0,maxRetries:3,recursive:!0,retryDelay:200});let P;function f(){return P===void 0&&(P=require("node:fs")),P}let k;function m(){return k===void 0&&(k=require("node:path")),k}function J(n,e,t){const{ignore:i,includeEmpty:o=!0,sort:s=!0}={__proto__:null,...t},c=m(),a=n.filter(r=>r.isDirectory()&&(o||!j(c.join(e||r.parentPath,r.name),{ignore:i}))).map(r=>r.name);return s?a.sort(R.naturalCompare):a}function A(n,e,t,i,o=2){const s=t?e:"";return`${JSON.stringify(n,i,o).replace(/\n/g,e)}${s}`}async function V(n,e){const{cwd:t=process.cwd(),signal:i=w}={__proto__:null,...e};let{onlyDirectories:o=!1,onlyFiles:s=!0}={__proto__:null,...e};o&&(s=!1),s&&(o=!1);const c=f(),a=m();let r=a.resolve(t);const{root:d}=a.parse(r),l=(0,_.isArray)(n)?n:[n];for(;r&&r!==d;){for(const g of l){if(i?.aborted)return;const u=a.join(r,g);try{const y=await c.promises.stat(u);if(!o&&y.isFile())return(0,p.normalizePath)(u);if(!s&&y.isDirectory())return(0,p.normalizePath)(u)}catch{}}r=a.dirname(r)}}function G(n,e){const{cwd:t=process.cwd(),stopAt:i}={__proto__:null,...e};let{onlyDirectories:o=!1,onlyFiles:s=!0}={__proto__:null,...e};o&&(s=!1),s&&(o=!1);const c=f(),a=m();let r=a.resolve(t);const{root:d}=a.parse(r),l=i?a.resolve(i):void 0,g=(0,_.isArray)(n)?n:[n];for(;r&&r!==d;){if(l&&r===l){for(const u of g){const y=a.join(r,u);try{const h=c.statSync(y);if(!o&&h.isFile())return(0,p.normalizePath)(y);if(!s&&h.isDirectory())return(0,p.normalizePath)(y)}catch{}}return}for(const u of g){const y=a.join(r,u);try{const h=c.statSync(y);if(!o&&h.isFile())return(0,p.normalizePath)(y);if(!s&&h.isDirectory())return(0,p.normalizePath)(y)}catch{}}r=a.dirname(r)}}async function z(n){return!!(await U(n))?.isDirectory()}function X(n){return!!C(n)?.isDirectory()}function j(n,e){const{ignore:t=S.defaultIgnore}={__proto__:null,...e},i=f();try{const o=i.readdirSync(n),{length:s}=o;if(s===0)return!0;const c=(0,S.getGlobMatcher)(t,{cwd:(0,p.pathLikeToString)(n)});let a=0;for(let r=0;r<s;r+=1){const d=o[r];d&&c(d)&&(a+=1)}return a===s}catch{return!1}}function K(n){const e=f();try{return e.lstatSync(n).isSymbolicLink()}catch{}return!1}function H(n){const e=f(),t=[],i=[],{R_OK:o}=e.constants;for(const s of n)try{e.accessSync(s,o),t.push(s)}catch{i.push(s)}return{__proto__:null,validPaths:t,invalidPaths:i}}async function Q(n,e){const t=f();try{return J(await t.promises.readdir(n,{__proto__:null,encoding:"utf8",withFileTypes:!0}),String(n),e)}catch{}return[]}function Y(n,e){const t=f();try{return J(t.readdirSync(n,{__proto__:null,encoding:"utf8",withFileTypes:!0}),String(n),e)}catch{}return[]}async function Z(n,e){const t=typeof e=="string"?{encoding:e}:e;return await f().promises.readFile(n,{signal:w,...t,encoding:null})}async function ee(n,e){const t=typeof e=="string"?{encoding:e}:e;return await f().promises.readFile(n,{signal:w,...t,encoding:"utf8"})}function ne(n,e){const t=typeof e=="string"?{encoding:e}:e;return f().readFileSync(n,{...t,encoding:null})}function te(n,e){const t=typeof e=="string"?{encoding:e}:e;return f().readFileSync(n,{...t,encoding:"utf8"})}async function ie(n,e){const t=typeof e=="string"?{encoding:e}:e,{reviver:i,throws:o,...s}={__proto__:null,...t},c=o===void 0||!!o,a=f();let r="";try{r=await a.promises.readFile(n,{__proto__:null,encoding:"utf8",...s})}catch(d){if(c){const l=d.code;throw l==="ENOENT"?new Error(`JSON file not found: ${n}
3
- Ensure the file exists or create it with the expected structure.`,{cause:d}):l==="EACCES"||l==="EPERM"?new Error(`Permission denied reading JSON file: ${n}
4
- Check file permissions or run with appropriate access.`,{cause:d}):d}return}return(0,b.jsonParse)(r,{filepath:String(n),reviver:i,throws:c})}function re(n,e){const t=typeof e=="string"?{encoding:e}:e,{reviver:i,throws:o,...s}={__proto__:null,...t},c=o===void 0||!!o,a=f();let r="";try{r=a.readFileSync(n,{__proto__:null,encoding:"utf8",...s})}catch(d){if(c){const l=d.code;throw l==="ENOENT"?new Error(`JSON file not found: ${n}
5
- Ensure the file exists or create it with the expected structure.`,{cause:d}):l==="EACCES"||l==="EPERM"?new Error(`Permission denied reading JSON file: ${n}
6
- Check file permissions or run with appropriate access.`,{cause:d}):d}return}return(0,b.jsonParse)(r,{filepath:String(n),reviver:i,throws:c})}let O;function N(){if(O===void 0){const n=m(),{getOsTmpDir:e,getSocketCacacheDir:t,getSocketUserDir:i}=require("#lib/paths");O=[n.resolve(e()),n.resolve(t()),n.resolve(i())]}return O}function I(){O=void 0}(0,E.registerCacheInvalidation)(I);async function oe(n,e){const t=require("./external/del"),{deleteAsync:i}=t,o={__proto__:null,...e},s=(0,_.isArray)(n)?n.map(p.pathLikeToString):[(0,p.pathLikeToString)(n)];let c=o.force!==!1;if(!c&&s.length>0){const a=m(),r=N();s.every(l=>{const g=a.resolve(l);for(const u of r){const y=g.startsWith(u+a.sep)||g===u,x=a.relative(u,g).startsWith("..");if(y&&!x)return!0}return!1})&&(c=!0)}await i(s,{concurrency:o.maxRetries||L.maxRetries,dryRun:!1,force:c,onlyFiles:!1})}function se(n,e){const t=require("./external/del"),{deleteSync:i}=t,o={__proto__:null,...e},s=(0,_.isArray)(n)?n.map(p.pathLikeToString):[(0,p.pathLikeToString)(n)];let c=o.force!==!1;if(!c&&s.length>0){const a=m(),r=N();s.every(l=>{const g=a.resolve(l);for(const u of r){const y=g.startsWith(u+a.sep)||g===u,x=a.relative(u,g).startsWith("..");if(y&&!x)return!0}return!1})&&(c=!0)}i(s,{concurrency:o.maxRetries||L.maxRetries,dryRun:!1,force:c,onlyFiles:!1})}async function ae(n,e){const t=f();try{await t.promises.mkdir(n,e)}catch(i){if(typeof i=="object"&&i!==null&&"code"in i&&i.code!=="EEXIST")throw i}}function ce(n,e){const t=f();try{t.mkdirSync(n,e)}catch(i){if(typeof i=="object"&&i!==null&&"code"in i&&i.code!=="EEXIST")throw i}}async function de(n,e){const t=typeof e=="string"?{encoding:e}:e,i=f();try{return await i.promises.readFile(n,{signal:w,...t})}catch{}}function fe(n,e){const t=typeof e=="string"?{encoding:e}:e,i=f();try{return i.readFileSync(n,{__proto__:null,...t})}catch{}}async function U(n){const e=f();try{return await e.promises.stat(n)}catch{}}function C(n,e){const t=typeof e=="string"?{encoding:e}:e,i=f();try{return i.statSync(n,{__proto__:null,throwIfNoEntry:!1,...t})}catch{}}function le(n){const e=f(),t=m(),i=String(n);if(!e.existsSync(i))return(0,p.normalizePath)(i);const o=t.dirname(i),s=t.extname(i),c=t.basename(i,s);let a=1,r;do r=t.join(o,`${c}-${a}${s}`),a++;while(e.existsSync(r));return(0,p.normalizePath)(r)}async function ue(n,e,t){const i=typeof t=="string"?{encoding:t}:t,{EOL:o,finalEOL:s,replacer:c,spaces:a,...r}={__proto__:null,...i},d=f(),l=A(e,o||`
7
- `,s!==void 0?s:!0,c,a);await d.promises.writeFile(n,l,{encoding:"utf8",...r,__proto__:null})}function pe(n,e,t){const i=typeof t=="string"?{encoding:t}:t,{EOL:o,finalEOL:s,replacer:c,spaces:a,...r}={__proto__:null,...i},d=f(),l=A(e,o||`
8
- `,s!==void 0?s:!0,c,a);d.writeFileSync(n,l,{encoding:"utf8",...r,__proto__:null})}0&&(module.exports={findUp,findUpSync,invalidatePathCache,isDir,isDirEmptySync,isDirSync,isSymLinkSync,readDirNames,readDirNamesSync,readFileBinary,readFileBinarySync,readFileUtf8,readFileUtf8Sync,readJson,readJsonSync,safeDelete,safeDeleteSync,safeMkdir,safeMkdirSync,safeReadFile,safeReadFileSync,safeStats,safeStatsSync,uniqueSync,validateFiles,writeJson,writeJsonSync});
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var fs_exports = {};
20
+ __export(fs_exports, {
21
+ findUp: () => findUp,
22
+ findUpSync: () => findUpSync,
23
+ invalidatePathCache: () => invalidatePathCache,
24
+ isDir: () => isDir,
25
+ isDirEmptySync: () => isDirEmptySync,
26
+ isDirSync: () => isDirSync,
27
+ isSymLinkSync: () => isSymLinkSync,
28
+ readDirNames: () => readDirNames,
29
+ readDirNamesSync: () => readDirNamesSync,
30
+ readFileBinary: () => readFileBinary,
31
+ readFileBinarySync: () => readFileBinarySync,
32
+ readFileUtf8: () => readFileUtf8,
33
+ readFileUtf8Sync: () => readFileUtf8Sync,
34
+ readJson: () => readJson,
35
+ readJsonSync: () => readJsonSync,
36
+ safeDelete: () => safeDelete,
37
+ safeDeleteSync: () => safeDeleteSync,
38
+ safeMkdir: () => safeMkdir,
39
+ safeMkdirSync: () => safeMkdirSync,
40
+ safeReadFile: () => safeReadFile,
41
+ safeReadFileSync: () => safeReadFileSync,
42
+ safeStats: () => safeStats,
43
+ safeStatsSync: () => safeStatsSync,
44
+ uniqueSync: () => uniqueSync,
45
+ validateFiles: () => validateFiles,
46
+ writeJson: () => writeJson,
47
+ writeJsonSync: () => writeJsonSync
48
+ });
49
+ module.exports = __toCommonJS(fs_exports);
50
+ var import_process = require("#constants/process");
51
+ var import_arrays = require("./arrays");
52
+ var import_globs = require("./globs");
53
+ var import_json = require("./json");
54
+ var import_objects = require("./objects");
55
+ var import_path = require("./path");
56
+ var import_rewire = require("./paths/rewire");
57
+ var import_sorts = require("./sorts");
58
+ const abortSignal = (0, import_process.getAbortSignal)();
59
+ const defaultRemoveOptions = (0, import_objects.objectFreeze)({
60
+ __proto__: null,
61
+ force: true,
62
+ maxRetries: 3,
63
+ recursive: true,
64
+ retryDelay: 200
65
+ });
66
+ let _fs;
67
+ // @__NO_SIDE_EFFECTS__
68
+ function getFs() {
69
+ if (_fs === void 0) {
70
+ _fs = require("node:fs");
71
+ }
72
+ return _fs;
73
+ }
74
+ let _path;
75
+ // @__NO_SIDE_EFFECTS__
76
+ function getPath() {
77
+ if (_path === void 0) {
78
+ _path = require("node:path");
79
+ }
80
+ return _path;
81
+ }
82
+ // @__NO_SIDE_EFFECTS__
83
+ function innerReadDirNames(dirents, dirname, options) {
84
+ const {
85
+ ignore,
86
+ includeEmpty = true,
87
+ sort = true
88
+ } = { __proto__: null, ...options };
89
+ const path = /* @__PURE__ */ getPath();
90
+ const names = dirents.filter(
91
+ (d) => d.isDirectory() && (includeEmpty || !/* @__PURE__ */ isDirEmptySync(path.join(dirname || d.parentPath, d.name), {
92
+ ignore
93
+ }))
94
+ ).map((d) => d.name);
95
+ return sort ? names.sort(import_sorts.naturalCompare) : names;
96
+ }
97
+ // @__NO_SIDE_EFFECTS__
98
+ function stringify(json, EOL, finalEOL, replacer, spaces = 2) {
99
+ const EOF = finalEOL ? EOL : "";
100
+ const str = JSON.stringify(json, replacer, spaces);
101
+ return `${str.replace(/\n/g, EOL)}${EOF}`;
102
+ }
103
+ // @__NO_SIDE_EFFECTS__
104
+ async function findUp(name, options) {
105
+ const { cwd = process.cwd(), signal = abortSignal } = {
106
+ __proto__: null,
107
+ ...options
108
+ };
109
+ let { onlyDirectories = false, onlyFiles = true } = {
110
+ __proto__: null,
111
+ ...options
112
+ };
113
+ if (onlyDirectories) {
114
+ onlyFiles = false;
115
+ }
116
+ if (onlyFiles) {
117
+ onlyDirectories = false;
118
+ }
119
+ const fs = /* @__PURE__ */ getFs();
120
+ const path = /* @__PURE__ */ getPath();
121
+ let dir = path.resolve(cwd);
122
+ const { root } = path.parse(dir);
123
+ const names = (0, import_arrays.isArray)(name) ? name : [name];
124
+ while (dir && dir !== root) {
125
+ for (const n of names) {
126
+ if (signal?.aborted) {
127
+ return void 0;
128
+ }
129
+ const thePath = path.join(dir, n);
130
+ try {
131
+ const stats = await fs.promises.stat(thePath);
132
+ if (!onlyDirectories && stats.isFile()) {
133
+ return (0, import_path.normalizePath)(thePath);
134
+ }
135
+ if (!onlyFiles && stats.isDirectory()) {
136
+ return (0, import_path.normalizePath)(thePath);
137
+ }
138
+ } catch {
139
+ }
140
+ }
141
+ dir = path.dirname(dir);
142
+ }
143
+ return void 0;
144
+ }
145
+ // @__NO_SIDE_EFFECTS__
146
+ function findUpSync(name, options) {
147
+ const { cwd = process.cwd(), stopAt } = {
148
+ __proto__: null,
149
+ ...options
150
+ };
151
+ let { onlyDirectories = false, onlyFiles = true } = {
152
+ __proto__: null,
153
+ ...options
154
+ };
155
+ if (onlyDirectories) {
156
+ onlyFiles = false;
157
+ }
158
+ if (onlyFiles) {
159
+ onlyDirectories = false;
160
+ }
161
+ const fs = /* @__PURE__ */ getFs();
162
+ const path = /* @__PURE__ */ getPath();
163
+ let dir = path.resolve(cwd);
164
+ const { root } = path.parse(dir);
165
+ const stopDir = stopAt ? path.resolve(stopAt) : void 0;
166
+ const names = (0, import_arrays.isArray)(name) ? name : [name];
167
+ while (dir && dir !== root) {
168
+ if (stopDir && dir === stopDir) {
169
+ for (const n of names) {
170
+ const thePath = path.join(dir, n);
171
+ try {
172
+ const stats = fs.statSync(thePath);
173
+ if (!onlyDirectories && stats.isFile()) {
174
+ return (0, import_path.normalizePath)(thePath);
175
+ }
176
+ if (!onlyFiles && stats.isDirectory()) {
177
+ return (0, import_path.normalizePath)(thePath);
178
+ }
179
+ } catch {
180
+ }
181
+ }
182
+ return void 0;
183
+ }
184
+ for (const n of names) {
185
+ const thePath = path.join(dir, n);
186
+ try {
187
+ const stats = fs.statSync(thePath);
188
+ if (!onlyDirectories && stats.isFile()) {
189
+ return (0, import_path.normalizePath)(thePath);
190
+ }
191
+ if (!onlyFiles && stats.isDirectory()) {
192
+ return (0, import_path.normalizePath)(thePath);
193
+ }
194
+ } catch {
195
+ }
196
+ }
197
+ dir = path.dirname(dir);
198
+ }
199
+ return void 0;
200
+ }
201
+ // @__NO_SIDE_EFFECTS__
202
+ async function isDir(filepath) {
203
+ return !!(await /* @__PURE__ */ safeStats(filepath))?.isDirectory();
204
+ }
205
+ // @__NO_SIDE_EFFECTS__
206
+ function isDirSync(filepath) {
207
+ return !!(/* @__PURE__ */ safeStatsSync(filepath))?.isDirectory();
208
+ }
209
+ // @__NO_SIDE_EFFECTS__
210
+ function isDirEmptySync(dirname, options) {
211
+ const { ignore = import_globs.defaultIgnore } = {
212
+ __proto__: null,
213
+ ...options
214
+ };
215
+ const fs = /* @__PURE__ */ getFs();
216
+ try {
217
+ const files = fs.readdirSync(dirname);
218
+ const { length } = files;
219
+ if (length === 0) {
220
+ return true;
221
+ }
222
+ const matcher = (0, import_globs.getGlobMatcher)(
223
+ ignore,
224
+ {
225
+ cwd: (0, import_path.pathLikeToString)(dirname)
226
+ }
227
+ );
228
+ let ignoredCount = 0;
229
+ for (let i = 0; i < length; i += 1) {
230
+ const file = files[i];
231
+ if (file && matcher(file)) {
232
+ ignoredCount += 1;
233
+ }
234
+ }
235
+ return ignoredCount === length;
236
+ } catch {
237
+ return false;
238
+ }
239
+ }
240
+ // @__NO_SIDE_EFFECTS__
241
+ function isSymLinkSync(filepath) {
242
+ const fs = /* @__PURE__ */ getFs();
243
+ try {
244
+ return fs.lstatSync(filepath).isSymbolicLink();
245
+ } catch {
246
+ }
247
+ return false;
248
+ }
249
+ // @__NO_SIDE_EFFECTS__
250
+ function validateFiles(filepaths) {
251
+ const fs = /* @__PURE__ */ getFs();
252
+ const validPaths = [];
253
+ const invalidPaths = [];
254
+ const { R_OK } = fs.constants;
255
+ for (const filepath of filepaths) {
256
+ try {
257
+ fs.accessSync(filepath, R_OK);
258
+ validPaths.push(filepath);
259
+ } catch {
260
+ invalidPaths.push(filepath);
261
+ }
262
+ }
263
+ return { __proto__: null, validPaths, invalidPaths };
264
+ }
265
+ // @__NO_SIDE_EFFECTS__
266
+ async function readDirNames(dirname, options) {
267
+ const fs = /* @__PURE__ */ getFs();
268
+ try {
269
+ return /* @__PURE__ */ innerReadDirNames(
270
+ await fs.promises.readdir(dirname, {
271
+ __proto__: null,
272
+ encoding: "utf8",
273
+ withFileTypes: true
274
+ }),
275
+ String(dirname),
276
+ options
277
+ );
278
+ } catch {
279
+ }
280
+ return [];
281
+ }
282
+ // @__NO_SIDE_EFFECTS__
283
+ function readDirNamesSync(dirname, options) {
284
+ const fs = /* @__PURE__ */ getFs();
285
+ try {
286
+ return /* @__PURE__ */ innerReadDirNames(
287
+ fs.readdirSync(dirname, {
288
+ __proto__: null,
289
+ encoding: "utf8",
290
+ withFileTypes: true
291
+ }),
292
+ String(dirname),
293
+ options
294
+ );
295
+ } catch {
296
+ }
297
+ return [];
298
+ }
299
+ // @__NO_SIDE_EFFECTS__
300
+ async function readFileBinary(filepath, options) {
301
+ const opts = typeof options === "string" ? { encoding: options } : options;
302
+ const fs = /* @__PURE__ */ getFs();
303
+ return await fs.promises.readFile(filepath, {
304
+ signal: abortSignal,
305
+ ...opts,
306
+ encoding: null
307
+ });
308
+ }
309
+ // @__NO_SIDE_EFFECTS__
310
+ async function readFileUtf8(filepath, options) {
311
+ const opts = typeof options === "string" ? { encoding: options } : options;
312
+ const fs = /* @__PURE__ */ getFs();
313
+ return await fs.promises.readFile(filepath, {
314
+ signal: abortSignal,
315
+ ...opts,
316
+ encoding: "utf8"
317
+ });
318
+ }
319
+ // @__NO_SIDE_EFFECTS__
320
+ function readFileBinarySync(filepath, options) {
321
+ const opts = typeof options === "string" ? { encoding: options } : options;
322
+ const fs = /* @__PURE__ */ getFs();
323
+ return fs.readFileSync(filepath, {
324
+ ...opts,
325
+ encoding: null
326
+ });
327
+ }
328
+ // @__NO_SIDE_EFFECTS__
329
+ function readFileUtf8Sync(filepath, options) {
330
+ const opts = typeof options === "string" ? { encoding: options } : options;
331
+ const fs = /* @__PURE__ */ getFs();
332
+ return fs.readFileSync(filepath, {
333
+ ...opts,
334
+ encoding: "utf8"
335
+ });
336
+ }
337
+ // @__NO_SIDE_EFFECTS__
338
+ async function readJson(filepath, options) {
339
+ const opts = typeof options === "string" ? { encoding: options } : options;
340
+ const { reviver, throws, ...fsOptions } = {
341
+ __proto__: null,
342
+ ...opts
343
+ };
344
+ const shouldThrow = throws === void 0 || !!throws;
345
+ const fs = /* @__PURE__ */ getFs();
346
+ let content = "";
347
+ try {
348
+ content = await fs.promises.readFile(filepath, {
349
+ __proto__: null,
350
+ encoding: "utf8",
351
+ ...fsOptions
352
+ });
353
+ } catch (e) {
354
+ if (shouldThrow) {
355
+ const code = e.code;
356
+ if (code === "ENOENT") {
357
+ throw new Error(
358
+ `JSON file not found: ${filepath}
359
+ Ensure the file exists or create it with the expected structure.`,
360
+ { cause: e }
361
+ );
362
+ }
363
+ if (code === "EACCES" || code === "EPERM") {
364
+ throw new Error(
365
+ `Permission denied reading JSON file: ${filepath}
366
+ Check file permissions or run with appropriate access.`,
367
+ { cause: e }
368
+ );
369
+ }
370
+ throw e;
371
+ }
372
+ return void 0;
373
+ }
374
+ return (0, import_json.jsonParse)(content, {
375
+ filepath: String(filepath),
376
+ reviver,
377
+ throws: shouldThrow
378
+ });
379
+ }
380
+ // @__NO_SIDE_EFFECTS__
381
+ function readJsonSync(filepath, options) {
382
+ const opts = typeof options === "string" ? { encoding: options } : options;
383
+ const { reviver, throws, ...fsOptions } = {
384
+ __proto__: null,
385
+ ...opts
386
+ };
387
+ const shouldThrow = throws === void 0 || !!throws;
388
+ const fs = /* @__PURE__ */ getFs();
389
+ let content = "";
390
+ try {
391
+ content = fs.readFileSync(filepath, {
392
+ __proto__: null,
393
+ encoding: "utf8",
394
+ ...fsOptions
395
+ });
396
+ } catch (e) {
397
+ if (shouldThrow) {
398
+ const code = e.code;
399
+ if (code === "ENOENT") {
400
+ throw new Error(
401
+ `JSON file not found: ${filepath}
402
+ Ensure the file exists or create it with the expected structure.`,
403
+ { cause: e }
404
+ );
405
+ }
406
+ if (code === "EACCES" || code === "EPERM") {
407
+ throw new Error(
408
+ `Permission denied reading JSON file: ${filepath}
409
+ Check file permissions or run with appropriate access.`,
410
+ { cause: e }
411
+ );
412
+ }
413
+ throw e;
414
+ }
415
+ return void 0;
416
+ }
417
+ return (0, import_json.jsonParse)(content, {
418
+ filepath: String(filepath),
419
+ reviver,
420
+ throws: shouldThrow
421
+ });
422
+ }
423
+ let _cachedAllowedDirs;
424
+ function getAllowedDirectories() {
425
+ if (_cachedAllowedDirs === void 0) {
426
+ const path = /* @__PURE__ */ getPath();
427
+ const {
428
+ getOsTmpDir,
429
+ getSocketCacacheDir,
430
+ getSocketUserDir
431
+ } = require("#lib/paths");
432
+ _cachedAllowedDirs = [
433
+ path.resolve(getOsTmpDir()),
434
+ path.resolve(getSocketCacacheDir()),
435
+ path.resolve(getSocketUserDir())
436
+ ];
437
+ }
438
+ return _cachedAllowedDirs;
439
+ }
440
+ function invalidatePathCache() {
441
+ _cachedAllowedDirs = void 0;
442
+ }
443
+ (0, import_rewire.registerCacheInvalidation)(invalidatePathCache);
444
+ // @__NO_SIDE_EFFECTS__
445
+ async function safeDelete(filepath, options) {
446
+ const del = require("./external/del");
447
+ const { deleteAsync } = del;
448
+ const opts = { __proto__: null, ...options };
449
+ const patterns = (0, import_arrays.isArray)(filepath) ? filepath.map(import_path.pathLikeToString) : [(0, import_path.pathLikeToString)(filepath)];
450
+ let shouldForce = opts.force !== false;
451
+ if (!shouldForce && patterns.length > 0) {
452
+ const path = /* @__PURE__ */ getPath();
453
+ const allowedDirs = getAllowedDirectories();
454
+ const allInAllowedDirs = patterns.every((pattern) => {
455
+ const resolvedPath = path.resolve(pattern);
456
+ for (const allowedDir of allowedDirs) {
457
+ const isInAllowedDir = resolvedPath.startsWith(allowedDir + path.sep) || resolvedPath === allowedDir;
458
+ const relativePath = path.relative(allowedDir, resolvedPath);
459
+ const isGoingBackward = relativePath.startsWith("..");
460
+ if (isInAllowedDir && !isGoingBackward) {
461
+ return true;
462
+ }
463
+ }
464
+ return false;
465
+ });
466
+ if (allInAllowedDirs) {
467
+ shouldForce = true;
468
+ }
469
+ }
470
+ await deleteAsync(patterns, {
471
+ concurrency: opts.maxRetries || defaultRemoveOptions.maxRetries,
472
+ dryRun: false,
473
+ force: shouldForce,
474
+ onlyFiles: false
475
+ });
476
+ }
477
+ // @__NO_SIDE_EFFECTS__
478
+ function safeDeleteSync(filepath, options) {
479
+ const del = require("./external/del");
480
+ const { deleteSync } = del;
481
+ const opts = { __proto__: null, ...options };
482
+ const patterns = (0, import_arrays.isArray)(filepath) ? filepath.map(import_path.pathLikeToString) : [(0, import_path.pathLikeToString)(filepath)];
483
+ let shouldForce = opts.force !== false;
484
+ if (!shouldForce && patterns.length > 0) {
485
+ const path = /* @__PURE__ */ getPath();
486
+ const allowedDirs = getAllowedDirectories();
487
+ const allInAllowedDirs = patterns.every((pattern) => {
488
+ const resolvedPath = path.resolve(pattern);
489
+ for (const allowedDir of allowedDirs) {
490
+ const isInAllowedDir = resolvedPath.startsWith(allowedDir + path.sep) || resolvedPath === allowedDir;
491
+ const relativePath = path.relative(allowedDir, resolvedPath);
492
+ const isGoingBackward = relativePath.startsWith("..");
493
+ if (isInAllowedDir && !isGoingBackward) {
494
+ return true;
495
+ }
496
+ }
497
+ return false;
498
+ });
499
+ if (allInAllowedDirs) {
500
+ shouldForce = true;
501
+ }
502
+ }
503
+ deleteSync(patterns, {
504
+ concurrency: opts.maxRetries || defaultRemoveOptions.maxRetries,
505
+ dryRun: false,
506
+ force: shouldForce,
507
+ onlyFiles: false
508
+ });
509
+ }
510
+ // @__NO_SIDE_EFFECTS__
511
+ async function safeMkdir(path, options) {
512
+ const fs = /* @__PURE__ */ getFs();
513
+ try {
514
+ await fs.promises.mkdir(path, options);
515
+ } catch (e) {
516
+ if (typeof e === "object" && e !== null && "code" in e && e.code !== "EEXIST") {
517
+ throw e;
518
+ }
519
+ }
520
+ }
521
+ // @__NO_SIDE_EFFECTS__
522
+ function safeMkdirSync(path, options) {
523
+ const fs = /* @__PURE__ */ getFs();
524
+ try {
525
+ fs.mkdirSync(path, options);
526
+ } catch (e) {
527
+ if (typeof e === "object" && e !== null && "code" in e && e.code !== "EEXIST") {
528
+ throw e;
529
+ }
530
+ }
531
+ }
532
+ // @__NO_SIDE_EFFECTS__
533
+ async function safeReadFile(filepath, options) {
534
+ const opts = typeof options === "string" ? { encoding: options } : options;
535
+ const fs = /* @__PURE__ */ getFs();
536
+ try {
537
+ return await fs.promises.readFile(filepath, {
538
+ signal: abortSignal,
539
+ ...opts
540
+ });
541
+ } catch {
542
+ }
543
+ return void 0;
544
+ }
545
+ // @__NO_SIDE_EFFECTS__
546
+ function safeReadFileSync(filepath, options) {
547
+ const opts = typeof options === "string" ? { encoding: options } : options;
548
+ const fs = /* @__PURE__ */ getFs();
549
+ try {
550
+ return fs.readFileSync(filepath, {
551
+ __proto__: null,
552
+ ...opts
553
+ });
554
+ } catch {
555
+ }
556
+ return void 0;
557
+ }
558
+ // @__NO_SIDE_EFFECTS__
559
+ async function safeStats(filepath) {
560
+ const fs = /* @__PURE__ */ getFs();
561
+ try {
562
+ return await fs.promises.stat(filepath);
563
+ } catch {
564
+ }
565
+ return void 0;
566
+ }
567
+ // @__NO_SIDE_EFFECTS__
568
+ function safeStatsSync(filepath, options) {
569
+ const opts = typeof options === "string" ? { encoding: options } : options;
570
+ const fs = /* @__PURE__ */ getFs();
571
+ try {
572
+ return fs.statSync(filepath, {
573
+ __proto__: null,
574
+ throwIfNoEntry: false,
575
+ ...opts
576
+ });
577
+ } catch {
578
+ }
579
+ return void 0;
580
+ }
581
+ // @__NO_SIDE_EFFECTS__
582
+ function uniqueSync(filepath) {
583
+ const fs = /* @__PURE__ */ getFs();
584
+ const path = /* @__PURE__ */ getPath();
585
+ const filepathStr = String(filepath);
586
+ if (!fs.existsSync(filepathStr)) {
587
+ return (0, import_path.normalizePath)(filepathStr);
588
+ }
589
+ const dirname = path.dirname(filepathStr);
590
+ const ext = path.extname(filepathStr);
591
+ const basename = path.basename(filepathStr, ext);
592
+ let counter = 1;
593
+ let uniquePath;
594
+ do {
595
+ uniquePath = path.join(dirname, `${basename}-${counter}${ext}`);
596
+ counter++;
597
+ } while (fs.existsSync(uniquePath));
598
+ return (0, import_path.normalizePath)(uniquePath);
599
+ }
600
+ // @__NO_SIDE_EFFECTS__
601
+ async function writeJson(filepath, jsonContent, options) {
602
+ const opts = typeof options === "string" ? { encoding: options } : options;
603
+ const { EOL, finalEOL, replacer, spaces, ...fsOptions } = {
604
+ __proto__: null,
605
+ ...opts
606
+ };
607
+ const fs = /* @__PURE__ */ getFs();
608
+ const jsonString = /* @__PURE__ */ stringify(
609
+ jsonContent,
610
+ EOL || "\n",
611
+ finalEOL !== void 0 ? finalEOL : true,
612
+ replacer,
613
+ spaces
614
+ );
615
+ await fs.promises.writeFile(filepath, jsonString, {
616
+ encoding: "utf8",
617
+ ...fsOptions,
618
+ __proto__: null
619
+ });
620
+ }
621
+ // @__NO_SIDE_EFFECTS__
622
+ function writeJsonSync(filepath, jsonContent, options) {
623
+ const opts = typeof options === "string" ? { encoding: options } : options;
624
+ const { EOL, finalEOL, replacer, spaces, ...fsOptions } = {
625
+ __proto__: null,
626
+ ...opts
627
+ };
628
+ const fs = /* @__PURE__ */ getFs();
629
+ const jsonString = /* @__PURE__ */ stringify(
630
+ jsonContent,
631
+ EOL || "\n",
632
+ finalEOL !== void 0 ? finalEOL : true,
633
+ replacer,
634
+ spaces
635
+ );
636
+ fs.writeFileSync(filepath, jsonString, {
637
+ encoding: "utf8",
638
+ ...fsOptions,
639
+ __proto__: null
640
+ });
641
+ }
642
+ // Annotate the CommonJS export names for ESM import in node:
643
+ 0 && (module.exports = {
644
+ findUp,
645
+ findUpSync,
646
+ invalidatePathCache,
647
+ isDir,
648
+ isDirEmptySync,
649
+ isDirSync,
650
+ isSymLinkSync,
651
+ readDirNames,
652
+ readDirNamesSync,
653
+ readFileBinary,
654
+ readFileBinarySync,
655
+ readFileUtf8,
656
+ readFileUtf8Sync,
657
+ readJson,
658
+ readJsonSync,
659
+ safeDelete,
660
+ safeDeleteSync,
661
+ safeMkdir,
662
+ safeMkdirSync,
663
+ safeReadFile,
664
+ safeReadFileSync,
665
+ safeStats,
666
+ safeStatsSync,
667
+ uniqueSync,
668
+ validateFiles,
669
+ writeJson,
670
+ writeJsonSync
671
+ });
9
672
  //# sourceMappingURL=fs.js.map