@hyperfrontend/project-scope 0.2.1 → 0.2.2

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 (439) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/README.md +3 -4
  3. package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/array/index.cjs.js +7 -0
  4. package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/array/index.esm.js +5 -0
  5. package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/console/index.cjs.js +13 -0
  6. package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/console/index.esm.js +8 -0
  7. package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/date/index.cjs.js +10 -0
  8. package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/date/index.esm.js +8 -0
  9. package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/error/index.cjs.js +6 -0
  10. package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/error/index.esm.js +5 -0
  11. package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/json/index.cjs.js +7 -0
  12. package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/json/index.esm.js +5 -0
  13. package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/map/index.cjs.js +6 -0
  14. package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/map/index.esm.js +5 -0
  15. package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/math/index.cjs.js +9 -0
  16. package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/math/index.esm.js +6 -0
  17. package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/number/index.cjs.js +7 -0
  18. package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/number/index.esm.js +7 -0
  19. package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/object/index.cjs.js +15 -0
  20. package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/object/index.esm.js +9 -0
  21. package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/set/index.cjs.js +6 -0
  22. package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/set/index.esm.js +5 -0
  23. package/_dependencies/@hyperfrontend/logging/index.cjs.js +191 -0
  24. package/_dependencies/@hyperfrontend/logging/index.d.ts +151 -0
  25. package/_dependencies/@hyperfrontend/logging/index.esm.js +186 -0
  26. package/_shared/core/cache/index.cjs.js +135 -0
  27. package/_shared/core/cache/index.esm.js +128 -0
  28. package/_shared/core/errors/structured-errors/index.cjs.js +28 -0
  29. package/_shared/core/errors/structured-errors/index.esm.js +23 -0
  30. package/_shared/core/fs/stat/index.cjs.js +46 -0
  31. package/_shared/core/fs/stat/index.esm.js +40 -0
  32. package/_shared/core/path/join/index.cjs.js +13 -0
  33. package/_shared/core/path/join/index.esm.js +10 -0
  34. package/_shared/core/path/normalize/index.cjs.js +37 -0
  35. package/_shared/core/path/normalize/index.esm.js +31 -0
  36. package/_shared/core/path/resolve/index.cjs.js +47 -0
  37. package/_shared/core/path/resolve/index.esm.js +41 -0
  38. package/_shared/core/path/segments/index.cjs.js +38 -0
  39. package/_shared/core/path/segments/index.esm.js +31 -0
  40. package/_shared/core/patterns/glob/index.cjs.js +145 -0
  41. package/_shared/core/patterns/glob/index.esm.js +136 -0
  42. package/_shared/core/platform/detect/index.cjs.js +103 -0
  43. package/_shared/core/platform/detect/index.esm.js +95 -0
  44. package/_shared/core/platform/line-endings/index.cjs.js +52 -0
  45. package/_shared/core/platform/line-endings/index.esm.js +44 -0
  46. package/_shared/project/config/patterns/index.cjs.js +172 -0
  47. package/_shared/project/config/patterns/index.esm.js +169 -0
  48. package/_shared/tech/monorepo/pnpm-workspaces/index.cjs.js +33 -0
  49. package/_shared/tech/monorepo/pnpm-workspaces/index.esm.js +31 -0
  50. package/_shared/tech/shared-utils/detector-helpers/index.cjs.js +48 -0
  51. package/_shared/tech/shared-utils/detector-helpers/index.esm.js +43 -0
  52. package/_shared/vfs/types/index.cjs.js +14 -0
  53. package/_shared/vfs/types/index.esm.js +12 -0
  54. package/cli/index.cjs.js +1702 -1910
  55. package/cli/index.d.ts +273 -7
  56. package/cli/index.d.ts.map +1 -1
  57. package/cli/index.esm.js +1586 -1794
  58. package/core/encoding/index.cjs.js +86 -401
  59. package/core/encoding/index.d.ts +186 -3
  60. package/core/encoding/index.d.ts.map +1 -1
  61. package/core/encoding/index.esm.js +78 -392
  62. package/core/fs/index.cjs.js +231 -581
  63. package/core/fs/index.d.ts +479 -6
  64. package/core/fs/index.d.ts.map +1 -1
  65. package/core/fs/index.esm.js +221 -571
  66. package/core/index.cjs.js +518 -1748
  67. package/core/index.d.ts +486 -9
  68. package/core/index.d.ts.map +1 -1
  69. package/core/index.esm.js +501 -1728
  70. package/core/path/index.cjs.js +6 -234
  71. package/core/path/index.d.ts +306 -5
  72. package/core/path/index.d.ts.map +1 -1
  73. package/core/path/index.esm.js +4 -232
  74. package/core/platform/index.cjs.js +5 -216
  75. package/core/platform/index.d.ts +185 -3
  76. package/core/platform/index.d.ts.map +1 -1
  77. package/core/platform/index.esm.js +3 -212
  78. package/heuristics/dependencies/index.cjs.js +95 -492
  79. package/heuristics/dependencies/index.d.ts +99 -2
  80. package/heuristics/dependencies/index.d.ts.map +1 -1
  81. package/heuristics/dependencies/index.esm.js +69 -466
  82. package/heuristics/entry-points/index.cjs.js +91 -795
  83. package/heuristics/entry-points/index.d.ts +123 -2
  84. package/heuristics/entry-points/index.d.ts.map +1 -1
  85. package/heuristics/entry-points/index.esm.js +72 -776
  86. package/heuristics/framework/index.cjs.js +1481 -1410
  87. package/heuristics/framework/index.d.ts +104 -2
  88. package/heuristics/framework/index.d.ts.map +1 -1
  89. package/heuristics/framework/index.esm.js +1417 -1346
  90. package/heuristics/index.cjs.js +3206 -3301
  91. package/heuristics/index.d.ts +4 -5
  92. package/heuristics/index.d.ts.map +1 -1
  93. package/heuristics/index.esm.js +3231 -3326
  94. package/heuristics/project-type/index.cjs.js +1487 -1437
  95. package/heuristics/project-type/index.d.ts +64 -2
  96. package/heuristics/project-type/index.d.ts.map +1 -1
  97. package/heuristics/project-type/index.esm.js +1416 -1366
  98. package/index.cjs.js +3044 -3533
  99. package/index.d.ts +44 -10
  100. package/index.d.ts.map +1 -1
  101. package/index.esm.js +2900 -3377
  102. package/models/index.cjs.js +0 -1
  103. package/models/index.d.ts +20 -14
  104. package/models/index.d.ts.map +1 -1
  105. package/models/index.esm.js +0 -1
  106. package/nx/index.cjs.js +163 -577
  107. package/nx/index.d.ts +279 -4
  108. package/nx/index.d.ts.map +1 -1
  109. package/nx/index.esm.js +145 -554
  110. package/package.json +13 -12
  111. package/project/config/index.cjs.js +122 -1062
  112. package/project/config/index.d.ts +202 -4
  113. package/project/config/index.d.ts.map +1 -1
  114. package/project/config/index.esm.js +105 -1043
  115. package/project/index.cjs.js +323 -1100
  116. package/project/index.d.ts +4 -5
  117. package/project/index.d.ts.map +1 -1
  118. package/project/index.esm.js +302 -1076
  119. package/project/package/index.cjs.js +191 -472
  120. package/project/package/index.d.ts +280 -3
  121. package/project/package/index.d.ts.map +1 -1
  122. package/project/package/index.esm.js +178 -458
  123. package/project/root/index.cjs.js +107 -416
  124. package/project/root/index.d.ts +83 -2
  125. package/project/root/index.d.ts.map +1 -1
  126. package/project/root/index.esm.js +96 -405
  127. package/project/traversal/index.cjs.js +94 -621
  128. package/project/traversal/index.d.ts +165 -3
  129. package/project/traversal/index.d.ts.map +1 -1
  130. package/project/traversal/index.esm.js +80 -607
  131. package/tech/backend/index.cjs.js +221 -507
  132. package/tech/backend/index.d.ts +205 -8
  133. package/tech/backend/index.d.ts.map +1 -1
  134. package/tech/backend/index.esm.js +200 -486
  135. package/tech/build/index.cjs.js +348 -635
  136. package/tech/build/index.d.ts +276 -10
  137. package/tech/build/index.d.ts.map +1 -1
  138. package/tech/build/index.esm.js +326 -613
  139. package/tech/frontend/index.cjs.js +505 -684
  140. package/tech/frontend/index.d.ts +379 -15
  141. package/tech/frontend/index.d.ts.map +1 -1
  142. package/tech/frontend/index.esm.js +481 -660
  143. package/tech/index.cjs.js +1580 -1420
  144. package/tech/index.d.ts +55 -32
  145. package/tech/index.d.ts.map +1 -1
  146. package/tech/index.esm.js +1513 -1353
  147. package/tech/legacy/index.cjs.js +97 -448
  148. package/tech/legacy/index.d.ts +125 -7
  149. package/tech/legacy/index.d.ts.map +1 -1
  150. package/tech/legacy/index.esm.js +79 -430
  151. package/tech/linting/index.cjs.js +136 -522
  152. package/tech/linting/index.d.ts +129 -7
  153. package/tech/linting/index.d.ts.map +1 -1
  154. package/tech/linting/index.esm.js +116 -502
  155. package/tech/monorepo/index.cjs.js +244 -572
  156. package/tech/monorepo/index.d.ts +241 -10
  157. package/tech/monorepo/index.d.ts.map +1 -1
  158. package/tech/monorepo/index.esm.js +224 -552
  159. package/tech/testing/index.cjs.js +214 -570
  160. package/tech/testing/index.d.ts +176 -8
  161. package/tech/testing/index.d.ts.map +1 -1
  162. package/tech/testing/index.esm.js +196 -552
  163. package/tech/types/index.cjs.js +121 -505
  164. package/tech/types/index.d.ts +120 -2
  165. package/tech/types/index.d.ts.map +1 -1
  166. package/tech/types/index.esm.js +99 -483
  167. package/vfs/index.cjs.js +647 -1142
  168. package/vfs/index.d.ts +360 -6
  169. package/vfs/index.d.ts.map +1 -1
  170. package/vfs/index.esm.js +672 -1167
  171. package/ARCHITECTURE.md +0 -370
  172. package/analyze.d.ts +0 -33
  173. package/analyze.d.ts.map +0 -1
  174. package/cli/commands/analyze.d.ts +0 -28
  175. package/cli/commands/analyze.d.ts.map +0 -1
  176. package/cli/commands/config.d.ts +0 -27
  177. package/cli/commands/config.d.ts.map +0 -1
  178. package/cli/commands/deps.d.ts +0 -24
  179. package/cli/commands/deps.d.ts.map +0 -1
  180. package/cli/commands/tree.d.ts +0 -36
  181. package/cli/commands/tree.d.ts.map +0 -1
  182. package/cli/index.cjs.js.map +0 -1
  183. package/cli/index.esm.js.map +0 -1
  184. package/cli/run.d.ts +0 -25
  185. package/cli/run.d.ts.map +0 -1
  186. package/cli/types.d.ts +0 -55
  187. package/cli/types.d.ts.map +0 -1
  188. package/core/cache.d.ts +0 -158
  189. package/core/cache.d.ts.map +0 -1
  190. package/core/encoding/convert.d.ts +0 -32
  191. package/core/encoding/convert.d.ts.map +0 -1
  192. package/core/encoding/detect.d.ts +0 -91
  193. package/core/encoding/detect.d.ts.map +0 -1
  194. package/core/encoding/index.cjs.js.map +0 -1
  195. package/core/encoding/index.esm.js.map +0 -1
  196. package/core/errors/structured-errors.d.ts +0 -66
  197. package/core/errors/structured-errors.d.ts.map +0 -1
  198. package/core/fs/directory.d.ts +0 -91
  199. package/core/fs/directory.d.ts.map +0 -1
  200. package/core/fs/index.cjs.js.map +0 -1
  201. package/core/fs/index.esm.js.map +0 -1
  202. package/core/fs/read.d.ts +0 -94
  203. package/core/fs/read.d.ts.map +0 -1
  204. package/core/fs/stat.d.ts +0 -58
  205. package/core/fs/stat.d.ts.map +0 -1
  206. package/core/fs/traversal.d.ts +0 -26
  207. package/core/fs/traversal.d.ts.map +0 -1
  208. package/core/fs/write.d.ts +0 -75
  209. package/core/fs/write.d.ts.map +0 -1
  210. package/core/index.cjs.js.map +0 -1
  211. package/core/index.esm.js.map +0 -1
  212. package/core/logger.d.ts +0 -111
  213. package/core/logger.d.ts.map +0 -1
  214. package/core/path/index.cjs.js.map +0 -1
  215. package/core/path/index.esm.js.map +0 -1
  216. package/core/path/join.d.ts +0 -17
  217. package/core/path/join.d.ts.map +0 -1
  218. package/core/path/normalize.d.ts +0 -37
  219. package/core/path/normalize.d.ts.map +0 -1
  220. package/core/path/resolve.d.ts +0 -52
  221. package/core/path/resolve.d.ts.map +0 -1
  222. package/core/path/segments.d.ts +0 -59
  223. package/core/path/segments.d.ts.map +0 -1
  224. package/core/patterns/glob.d.ts +0 -42
  225. package/core/patterns/glob.d.ts.map +0 -1
  226. package/core/platform/detect.d.ts +0 -66
  227. package/core/platform/detect.d.ts.map +0 -1
  228. package/core/platform/index.cjs.js.map +0 -1
  229. package/core/platform/index.esm.js.map +0 -1
  230. package/core/platform/line-endings.d.ts +0 -48
  231. package/core/platform/line-endings.d.ts.map +0 -1
  232. package/heuristics/dependencies/analyze.d.ts +0 -77
  233. package/heuristics/dependencies/analyze.d.ts.map +0 -1
  234. package/heuristics/dependencies/index.cjs.js.map +0 -1
  235. package/heuristics/dependencies/index.esm.js.map +0 -1
  236. package/heuristics/entry-points/discover.d.ts +0 -113
  237. package/heuristics/entry-points/discover.d.ts.map +0 -1
  238. package/heuristics/entry-points/index.cjs.js.map +0 -1
  239. package/heuristics/entry-points/index.esm.js.map +0 -1
  240. package/heuristics/framework/identify.d.ts +0 -84
  241. package/heuristics/framework/identify.d.ts.map +0 -1
  242. package/heuristics/framework/index.cjs.js.map +0 -1
  243. package/heuristics/framework/index.esm.js.map +0 -1
  244. package/heuristics/index.cjs.js.map +0 -1
  245. package/heuristics/index.esm.js.map +0 -1
  246. package/heuristics/project-type/detect.d.ts +0 -61
  247. package/heuristics/project-type/detect.d.ts.map +0 -1
  248. package/heuristics/project-type/index.cjs.js.map +0 -1
  249. package/heuristics/project-type/index.esm.js.map +0 -1
  250. package/index.cjs.js.map +0 -1
  251. package/index.esm.js.map +0 -1
  252. package/models/index.cjs.js.map +0 -1
  253. package/models/index.esm.js.map +0 -1
  254. package/nx/detect.d.ts +0 -105
  255. package/nx/detect.d.ts.map +0 -1
  256. package/nx/devkit-loader.d.ts +0 -62
  257. package/nx/devkit-loader.d.ts.map +0 -1
  258. package/nx/index.cjs.js.map +0 -1
  259. package/nx/index.esm.js.map +0 -1
  260. package/nx/project-config.d.ts +0 -111
  261. package/nx/project-config.d.ts.map +0 -1
  262. package/project/config/detect.d.ts +0 -77
  263. package/project/config/detect.d.ts.map +0 -1
  264. package/project/config/index.cjs.js.map +0 -1
  265. package/project/config/index.esm.js.map +0 -1
  266. package/project/config/parse.d.ts +0 -53
  267. package/project/config/parse.d.ts.map +0 -1
  268. package/project/config/patterns.d.ts +0 -31
  269. package/project/config/patterns.d.ts.map +0 -1
  270. package/project/index.cjs.js.map +0 -1
  271. package/project/index.esm.js.map +0 -1
  272. package/project/package/dependencies.d.ts +0 -101
  273. package/project/package/dependencies.d.ts.map +0 -1
  274. package/project/package/index.cjs.js.map +0 -1
  275. package/project/package/index.esm.js.map +0 -1
  276. package/project/package/read.d.ts +0 -67
  277. package/project/package/read.d.ts.map +0 -1
  278. package/project/root/detect.d.ts +0 -65
  279. package/project/root/detect.d.ts.map +0 -1
  280. package/project/root/index.cjs.js.map +0 -1
  281. package/project/root/index.esm.js.map +0 -1
  282. package/project/traversal/index.cjs.js.map +0 -1
  283. package/project/traversal/index.esm.js.map +0 -1
  284. package/project/traversal/search.d.ts +0 -59
  285. package/project/traversal/search.d.ts.map +0 -1
  286. package/project/traversal/walk.d.ts +0 -63
  287. package/project/traversal/walk.d.ts.map +0 -1
  288. package/tech/backend/detect-all.d.ts +0 -13
  289. package/tech/backend/detect-all.d.ts.map +0 -1
  290. package/tech/backend/express.d.ts +0 -11
  291. package/tech/backend/express.d.ts.map +0 -1
  292. package/tech/backend/fastify.d.ts +0 -11
  293. package/tech/backend/fastify.d.ts.map +0 -1
  294. package/tech/backend/hono.d.ts +0 -11
  295. package/tech/backend/hono.d.ts.map +0 -1
  296. package/tech/backend/index.cjs.js.map +0 -1
  297. package/tech/backend/index.esm.js.map +0 -1
  298. package/tech/backend/koa.d.ts +0 -11
  299. package/tech/backend/koa.d.ts.map +0 -1
  300. package/tech/backend/nestjs.d.ts +0 -11
  301. package/tech/backend/nestjs.d.ts.map +0 -1
  302. package/tech/backend/types.d.ts +0 -31
  303. package/tech/backend/types.d.ts.map +0 -1
  304. package/tech/build/babel.d.ts +0 -13
  305. package/tech/build/babel.d.ts.map +0 -1
  306. package/tech/build/detect-all.d.ts +0 -13
  307. package/tech/build/detect-all.d.ts.map +0 -1
  308. package/tech/build/esbuild.d.ts +0 -11
  309. package/tech/build/esbuild.d.ts.map +0 -1
  310. package/tech/build/index.cjs.js.map +0 -1
  311. package/tech/build/index.esm.js.map +0 -1
  312. package/tech/build/parcel.d.ts +0 -13
  313. package/tech/build/parcel.d.ts.map +0 -1
  314. package/tech/build/rollup.d.ts +0 -13
  315. package/tech/build/rollup.d.ts.map +0 -1
  316. package/tech/build/swc.d.ts +0 -13
  317. package/tech/build/swc.d.ts.map +0 -1
  318. package/tech/build/types.d.ts +0 -31
  319. package/tech/build/types.d.ts.map +0 -1
  320. package/tech/build/vite.d.ts +0 -13
  321. package/tech/build/vite.d.ts.map +0 -1
  322. package/tech/build/webpack.d.ts +0 -13
  323. package/tech/build/webpack.d.ts.map +0 -1
  324. package/tech/frontend/angular.d.ts +0 -11
  325. package/tech/frontend/angular.d.ts.map +0 -1
  326. package/tech/frontend/astro.d.ts +0 -11
  327. package/tech/frontend/astro.d.ts.map +0 -1
  328. package/tech/frontend/detect-all.d.ts +0 -13
  329. package/tech/frontend/detect-all.d.ts.map +0 -1
  330. package/tech/frontend/gatsby.d.ts +0 -11
  331. package/tech/frontend/gatsby.d.ts.map +0 -1
  332. package/tech/frontend/index.cjs.js.map +0 -1
  333. package/tech/frontend/index.esm.js.map +0 -1
  334. package/tech/frontend/nextjs.d.ts +0 -11
  335. package/tech/frontend/nextjs.d.ts.map +0 -1
  336. package/tech/frontend/nuxt.d.ts +0 -11
  337. package/tech/frontend/nuxt.d.ts.map +0 -1
  338. package/tech/frontend/qwik.d.ts +0 -11
  339. package/tech/frontend/qwik.d.ts.map +0 -1
  340. package/tech/frontend/react.d.ts +0 -11
  341. package/tech/frontend/react.d.ts.map +0 -1
  342. package/tech/frontend/remix.d.ts +0 -11
  343. package/tech/frontend/remix.d.ts.map +0 -1
  344. package/tech/frontend/solid.d.ts +0 -11
  345. package/tech/frontend/solid.d.ts.map +0 -1
  346. package/tech/frontend/svelte.d.ts +0 -11
  347. package/tech/frontend/svelte.d.ts.map +0 -1
  348. package/tech/frontend/sveltekit.d.ts +0 -11
  349. package/tech/frontend/sveltekit.d.ts.map +0 -1
  350. package/tech/frontend/types.d.ts +0 -35
  351. package/tech/frontend/types.d.ts.map +0 -1
  352. package/tech/frontend/vue.d.ts +0 -11
  353. package/tech/frontend/vue.d.ts.map +0 -1
  354. package/tech/index.cjs.js.map +0 -1
  355. package/tech/index.esm.js.map +0 -1
  356. package/tech/legacy/angularjs.d.ts +0 -12
  357. package/tech/legacy/angularjs.d.ts.map +0 -1
  358. package/tech/legacy/backbone.d.ts +0 -11
  359. package/tech/legacy/backbone.d.ts.map +0 -1
  360. package/tech/legacy/detect-all.d.ts +0 -13
  361. package/tech/legacy/detect-all.d.ts.map +0 -1
  362. package/tech/legacy/ember.d.ts +0 -11
  363. package/tech/legacy/ember.d.ts.map +0 -1
  364. package/tech/legacy/index.cjs.js.map +0 -1
  365. package/tech/legacy/index.esm.js.map +0 -1
  366. package/tech/legacy/jquery.d.ts +0 -11
  367. package/tech/legacy/jquery.d.ts.map +0 -1
  368. package/tech/legacy/types.d.ts +0 -33
  369. package/tech/legacy/types.d.ts.map +0 -1
  370. package/tech/linting/biome.d.ts +0 -11
  371. package/tech/linting/biome.d.ts.map +0 -1
  372. package/tech/linting/detect-all.d.ts +0 -13
  373. package/tech/linting/detect-all.d.ts.map +0 -1
  374. package/tech/linting/eslint.d.ts +0 -13
  375. package/tech/linting/eslint.d.ts.map +0 -1
  376. package/tech/linting/index.cjs.js.map +0 -1
  377. package/tech/linting/index.esm.js.map +0 -1
  378. package/tech/linting/prettier.d.ts +0 -13
  379. package/tech/linting/prettier.d.ts.map +0 -1
  380. package/tech/linting/stylelint.d.ts +0 -13
  381. package/tech/linting/stylelint.d.ts.map +0 -1
  382. package/tech/linting/types.d.ts +0 -31
  383. package/tech/linting/types.d.ts.map +0 -1
  384. package/tech/monorepo/detect-all.d.ts +0 -13
  385. package/tech/monorepo/detect-all.d.ts.map +0 -1
  386. package/tech/monorepo/index.cjs.js.map +0 -1
  387. package/tech/monorepo/index.esm.js.map +0 -1
  388. package/tech/monorepo/lerna.d.ts +0 -11
  389. package/tech/monorepo/lerna.d.ts.map +0 -1
  390. package/tech/monorepo/npm-workspaces.d.ts +0 -11
  391. package/tech/monorepo/npm-workspaces.d.ts.map +0 -1
  392. package/tech/monorepo/nx.d.ts +0 -11
  393. package/tech/monorepo/nx.d.ts.map +0 -1
  394. package/tech/monorepo/pnpm-workspaces.d.ts +0 -9
  395. package/tech/monorepo/pnpm-workspaces.d.ts.map +0 -1
  396. package/tech/monorepo/rush.d.ts +0 -11
  397. package/tech/monorepo/rush.d.ts.map +0 -1
  398. package/tech/monorepo/turborepo.d.ts +0 -11
  399. package/tech/monorepo/turborepo.d.ts.map +0 -1
  400. package/tech/monorepo/types.d.ts +0 -39
  401. package/tech/monorepo/types.d.ts.map +0 -1
  402. package/tech/monorepo/yarn-workspaces.d.ts +0 -11
  403. package/tech/monorepo/yarn-workspaces.d.ts.map +0 -1
  404. package/tech/shared-utils/detector-helpers.d.ts +0 -52
  405. package/tech/shared-utils/detector-helpers.d.ts.map +0 -1
  406. package/tech/shared-utils/types.d.ts +0 -41
  407. package/tech/shared-utils/types.d.ts.map +0 -1
  408. package/tech/testing/cypress.d.ts +0 -13
  409. package/tech/testing/cypress.d.ts.map +0 -1
  410. package/tech/testing/detect-all.d.ts +0 -13
  411. package/tech/testing/detect-all.d.ts.map +0 -1
  412. package/tech/testing/index.cjs.js.map +0 -1
  413. package/tech/testing/index.esm.js.map +0 -1
  414. package/tech/testing/jest.d.ts +0 -13
  415. package/tech/testing/jest.d.ts.map +0 -1
  416. package/tech/testing/mocha.d.ts +0 -13
  417. package/tech/testing/mocha.d.ts.map +0 -1
  418. package/tech/testing/playwright.d.ts +0 -13
  419. package/tech/testing/playwright.d.ts.map +0 -1
  420. package/tech/testing/types.d.ts +0 -35
  421. package/tech/testing/types.d.ts.map +0 -1
  422. package/tech/testing/vitest.d.ts +0 -13
  423. package/tech/testing/vitest.d.ts.map +0 -1
  424. package/tech/types/detectors.d.ts +0 -67
  425. package/tech/types/detectors.d.ts.map +0 -1
  426. package/tech/types/index.cjs.js.map +0 -1
  427. package/tech/types/index.esm.js.map +0 -1
  428. package/vfs/commit.d.ts +0 -32
  429. package/vfs/commit.d.ts.map +0 -1
  430. package/vfs/diff.d.ts +0 -73
  431. package/vfs/diff.d.ts.map +0 -1
  432. package/vfs/factory.d.ts +0 -37
  433. package/vfs/factory.d.ts.map +0 -1
  434. package/vfs/fs-tree.d.ts +0 -13
  435. package/vfs/fs-tree.d.ts.map +0 -1
  436. package/vfs/index.cjs.js.map +0 -1
  437. package/vfs/index.esm.js.map +0 -1
  438. package/vfs/types.d.ts +0 -179
  439. package/vfs/types.d.ts.map +0 -1
package/core/index.esm.js CHANGED
@@ -1,420 +1,25 @@
1
- import { existsSync, readFileSync, mkdirSync, writeFileSync, statSync, lstatSync, readdirSync, rmSync, realpathSync, mkdtempSync, unlinkSync, rmdirSync } from 'node:fs';
2
- import { dirname, join as join$1, posix, normalize, sep, isAbsolute as isAbsolute$1, relative, resolve, basename, extname, parse as parse$1 } from 'node:path';
1
+ import { createMap } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/map/index.esm.js';
2
+ import { freeze, defineProperty, entries, keys, defineProperties } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/object/index.esm.js';
3
+ import { createSet } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/set/index.esm.js';
4
+ import { createError } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/error/index.esm.js';
5
+ import { isArray } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/array/index.esm.js';
6
+ import { error, warn, log, info, debug } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/console/index.esm.js';
7
+ import { stringify, parse } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/json/index.esm.js';
8
+ import { createLogger } from '../_dependencies/@hyperfrontend/logging/index.esm.js';
9
+ import { min } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/math/index.esm.js';
10
+ import { existsSync, readFileSync, statSync, lstatSync, mkdirSync, readdirSync, rmSync, realpathSync, writeFileSync, mkdtempSync, unlinkSync, rmdirSync } from 'node:fs';
11
+ import { join as join$1, posix, normalize, sep, isAbsolute as isAbsolute$1, relative, resolve, basename, dirname, extname, parse as parse$1 } from 'node:path';
3
12
  import { tmpdir, platform, arch } from 'node:os';
4
-
5
- /**
6
- * Safe copies of Error built-ins via factory functions.
7
- *
8
- * Since constructors cannot be safely captured via Object.assign, this module
9
- * provides factory functions that use Reflect.construct internally.
10
- *
11
- * These references are captured at module initialization time to protect against
12
- * prototype pollution attacks. Import only what you need for tree-shaking.
13
- *
14
- * @module @hyperfrontend/immutable-api-utils/built-in-copy/error
15
- */
16
- const _Error = globalThis.Error;
17
- const _Reflect$2 = globalThis.Reflect;
18
- /**
19
- * (Safe copy) Creates a new Error using the captured Error constructor.
20
- * Use this instead of `new Error()`.
21
- *
22
- * @param message - Optional error message.
23
- * @param options - Optional error options.
24
- * @returns A new Error instance.
25
- */
26
- const createError = (message, options) => _Reflect$2.construct(_Error, [message, options]);
27
-
28
- /**
29
- * Safe copies of JSON built-in methods.
30
- *
31
- * These references are captured at module initialization time to protect against
32
- * prototype pollution attacks. Import only what you need for tree-shaking.
33
- *
34
- * @module @hyperfrontend/immutable-api-utils/built-in-copy/json
35
- */
36
- const _JSON = globalThis.JSON;
37
- /**
38
- * (Safe copy) Converts a JavaScript Object Notation (JSON) string into an object.
39
- */
40
- const parse = _JSON.parse;
41
- /**
42
- * (Safe copy) Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
43
- */
44
- const stringify = _JSON.stringify;
45
-
46
- /**
47
- * Safe copies of Object built-in methods.
48
- *
49
- * These references are captured at module initialization time to protect against
50
- * prototype pollution attacks. Import only what you need for tree-shaking.
51
- *
52
- * @module @hyperfrontend/immutable-api-utils/built-in-copy/object
53
- */
54
- const _Object = globalThis.Object;
55
- /**
56
- * (Safe copy) Prevents modification of existing property attributes and values,
57
- * and prevents the addition of new properties.
58
- */
59
- const freeze = _Object.freeze;
60
- /**
61
- * (Safe copy) Returns the names of the enumerable string properties and methods of an object.
62
- */
63
- const keys = _Object.keys;
64
- /**
65
- * (Safe copy) Returns an array of key/values of the enumerable own properties of an object.
66
- */
67
- const entries = _Object.entries;
68
- /**
69
- * (Safe copy) Adds a property to an object, or modifies attributes of an existing property.
70
- */
71
- const defineProperty = _Object.defineProperty;
72
- /**
73
- * (Safe copy) Adds one or more properties to an object, and/or modifies attributes of existing properties.
74
- */
75
- const defineProperties = _Object.defineProperties;
76
-
77
- /**
78
- * Safe copies of Array built-in static methods.
79
- *
80
- * These references are captured at module initialization time to protect against
81
- * prototype pollution attacks. Import only what you need for tree-shaking.
82
- *
83
- * @module @hyperfrontend/immutable-api-utils/built-in-copy/array
84
- */
85
- const _Array = globalThis.Array;
86
- /**
87
- * (Safe copy) Determines whether the passed value is an Array.
88
- */
89
- const isArray = _Array.isArray;
90
-
91
- /**
92
- * Safe copies of Console built-in methods.
93
- *
94
- * These references are captured at module initialization time to protect against
95
- * prototype pollution attacks. Import only what you need for tree-shaking.
96
- *
97
- * @module @hyperfrontend/immutable-api-utils/built-in-copy/console
98
- */
99
- const _console = globalThis.console;
100
- /**
101
- * (Safe copy) Outputs a message to the console.
102
- */
103
- const log = _console.log.bind(_console);
104
- /**
105
- * (Safe copy) Outputs a warning message to the console.
106
- */
107
- const warn = _console.warn.bind(_console);
108
- /**
109
- * (Safe copy) Outputs an error message to the console.
110
- */
111
- const error = _console.error.bind(_console);
112
- /**
113
- * (Safe copy) Outputs an informational message to the console.
114
- */
115
- const info = _console.info.bind(_console);
116
- /**
117
- * (Safe copy) Outputs a debug message to the console.
118
- */
119
- const debug = _console.debug.bind(_console);
120
- /**
121
- * (Safe copy) Outputs a stack trace to the console.
122
- */
123
- _console.trace.bind(_console);
124
- /**
125
- * (Safe copy) Displays an interactive listing of the properties of a specified object.
126
- */
127
- _console.dir.bind(_console);
128
- /**
129
- * (Safe copy) Displays tabular data as a table.
130
- */
131
- _console.table.bind(_console);
132
- /**
133
- * (Safe copy) Writes an error message to the console if the assertion is false.
134
- */
135
- _console.assert.bind(_console);
136
- /**
137
- * (Safe copy) Clears the console.
138
- */
139
- _console.clear.bind(_console);
140
- /**
141
- * (Safe copy) Logs the number of times that this particular call to count() has been called.
142
- */
143
- _console.count.bind(_console);
144
- /**
145
- * (Safe copy) Resets the counter used with console.count().
146
- */
147
- _console.countReset.bind(_console);
148
- /**
149
- * (Safe copy) Creates a new inline group in the console.
150
- */
151
- _console.group.bind(_console);
152
- /**
153
- * (Safe copy) Creates a new inline group in the console that is initially collapsed.
154
- */
155
- _console.groupCollapsed.bind(_console);
156
- /**
157
- * (Safe copy) Exits the current inline group.
158
- */
159
- _console.groupEnd.bind(_console);
160
- /**
161
- * (Safe copy) Starts a timer with a name specified as an input parameter.
162
- */
163
- _console.time.bind(_console);
164
- /**
165
- * (Safe copy) Stops a timer that was previously started.
166
- */
167
- _console.timeEnd.bind(_console);
168
- /**
169
- * (Safe copy) Logs the current value of a timer that was previously started.
170
- */
171
- _console.timeLog.bind(_console);
172
-
173
- /**
174
- * Safe copies of Set built-in via factory function.
175
- *
176
- * Since constructors cannot be safely captured via Object.assign, this module
177
- * provides a factory function that uses Reflect.construct internally.
178
- *
179
- * These references are captured at module initialization time to protect against
180
- * prototype pollution attacks. Import only what you need for tree-shaking.
181
- *
182
- * @module @hyperfrontend/immutable-api-utils/built-in-copy/set
183
- */
184
- const _Set = globalThis.Set;
185
- const _Reflect$1 = globalThis.Reflect;
186
- /**
187
- * (Safe copy) Creates a new Set using the captured Set constructor.
188
- * Use this instead of `new Set()`.
189
- *
190
- * @param iterable - Optional iterable of values.
191
- * @returns A new Set instance.
192
- */
193
- const createSet = (iterable) => _Reflect$1.construct(_Set, iterable ? [iterable] : []);
194
-
195
- const registeredClasses = [];
196
-
197
- /**
198
- * Returns the data type of the target.
199
- * Uses native `typeof` operator, however, makes distinction between `null`, `array`, and `object`.
200
- * Also, when classes are registered via `registerClass`, it checks if objects are instance of any known registered class.
201
- *
202
- * @param target - The target to get the data type of.
203
- * @returns The data type of the target.
204
- */
205
- const getType = (target) => {
206
- if (target === null)
207
- return 'null';
208
- const nativeDataType = typeof target;
209
- if (nativeDataType === 'object') {
210
- if (isArray(target))
211
- return 'array';
212
- for (const registeredClass of registeredClasses) {
213
- if (target instanceof registeredClass)
214
- return registeredClass.name;
215
- }
216
- }
217
- return nativeDataType;
218
- };
219
-
220
- /**
221
- * Safe copies of Map built-in via factory function.
222
- *
223
- * Since constructors cannot be safely captured via Object.assign, this module
224
- * provides a factory function that uses Reflect.construct internally.
225
- *
226
- * These references are captured at module initialization time to protect against
227
- * prototype pollution attacks. Import only what you need for tree-shaking.
228
- *
229
- * @module @hyperfrontend/immutable-api-utils/built-in-copy/map
230
- */
231
- const _Map = globalThis.Map;
232
- const _Reflect = globalThis.Reflect;
233
- /**
234
- * (Safe copy) Creates a new Map using the captured Map constructor.
235
- * Use this instead of `new Map()`.
236
- *
237
- * @param iterable - Optional iterable of key-value pairs.
238
- * @returns A new Map instance.
239
- */
240
- const createMap = (iterable) => _Reflect.construct(_Map, iterable ? [iterable] : []);
241
-
242
- /**
243
- * Safe copies of Math built-in methods.
244
- *
245
- * These references are captured at module initialization time to protect against
246
- * prototype pollution attacks. Import only what you need for tree-shaking.
247
- *
248
- * @module @hyperfrontend/immutable-api-utils/built-in-copy/math
249
- */
250
- const _Math = globalThis.Math;
251
- /**
252
- * (Safe copy) Returns the smaller of zero or more numbers.
253
- */
254
- const min = _Math.min;
255
-
256
- /* eslint-disable @typescript-eslint/no-explicit-any */
257
- /**
258
- * Creates a wrapper function that only executes the wrapped function if the condition function returns true.
259
- *
260
- * @param func - The function to be conditionally executed.
261
- * @param conditionFunc - A function that returns a boolean, determining if `func` should be executed.
262
- * @returns A wrapped version of `func` that executes conditionally.
263
- */
264
- function createConditionalExecutionFunction(func, conditionFunc) {
265
- return function (...args) {
266
- if (conditionFunc()) {
267
- return func(...args);
268
- }
269
- };
270
- }
271
-
272
- /* eslint-disable @typescript-eslint/no-explicit-any */
273
- /**
274
- * Creates a wrapper function that silently ignores any errors thrown by the wrapped void function.
275
- * This function is specifically for wrapping functions that do not return a value (void functions).
276
- * Exceptions are swallowed without any logging or handling.
277
- *
278
- * @param func - The void function to be wrapped.
279
- * @returns A wrapped version of the input function that ignores errors.
280
- */
281
- function createErrorIgnoringFunction(func) {
282
- return function (...args) {
283
- try {
284
- func(...args);
285
- }
286
- catch {
287
- // Deliberately swallowing/ignoring the exception
288
- }
289
- };
290
- }
291
-
292
- /* eslint-disable @typescript-eslint/no-unused-vars */
293
- /**
294
- * A no-operation function (noop) that does nothing regardless of the arguments passed.
295
- * It is designed to be as permissive as possible in its typing without using the `Function` keyword.
296
- *
297
- * @param args - Any arguments passed to the function (ignored)
298
- */
299
- const noop = (...args) => {
300
- // Intentionally does nothing
301
- };
302
-
303
- const logLevels = ['none', 'error', 'warn', 'log', 'info', 'debug'];
304
- const priority = {
305
- error: 4,
306
- warn: 3,
307
- log: 2,
308
- info: 1,
309
- debug: 0,
310
- };
311
- /**
312
- * Validates whether a given string is a valid log level.
313
- *
314
- * @param level - The log level to validate
315
- * @returns True if the level is valid, false otherwise
316
- */
317
- function isValidLogLevel(level) {
318
- return logLevels.includes(level);
319
- }
320
- /**
321
- * Creates a log level configuration manager for controlling logging behavior.
322
- * Provides methods to get, set, and evaluate log levels based on priority.
323
- *
324
- * @param level - The initial log level (defaults to 'error')
325
- * @returns A configuration object with log level management methods
326
- * @throws {Error} When the provided level is not a valid log level
327
- */
328
- function createLogLevelConfig(level = 'error') {
329
- if (!isValidLogLevel(level)) {
330
- throw createError('Cannot create log level configuration with a valid default log level');
331
- }
332
- const state = { level };
333
- const getLogLevel = () => state.level;
334
- const setLogLevel = (level) => {
335
- if (!isValidLogLevel(level)) {
336
- throw createError(`Cannot set value '${level}' level. Expected levels are ${logLevels}.`);
337
- }
338
- state.level = level;
339
- };
340
- const shouldLog = (level) => {
341
- if (state.level === 'none' || level === 'none' || !isValidLogLevel(level)) {
342
- return false;
343
- }
344
- return priority[level] >= priority[state.level];
345
- };
346
- return freeze({
347
- getLogLevel,
348
- setLogLevel,
349
- shouldLog,
350
- });
351
- }
352
-
353
- /**
354
- * Creates a logger instance with configurable log level filtering.
355
- * Each log function is wrapped to respect the current log level setting.
356
- *
357
- * @param error - Function to handle error-level logs (required)
358
- * @param warn - Function to handle warning-level logs (optional, defaults to noop)
359
- * @param log - Function to handle standard logs (optional, defaults to noop)
360
- * @param info - Function to handle info-level logs (optional, defaults to noop)
361
- * @param debug - Function to handle debug-level logs (optional, defaults to noop)
362
- * @returns A frozen logger object with log methods and level control
363
- * @throws {ErrorLevelFn} When any provided log function is invalid
364
- */
365
- function createLogger(error, warn = noop, log = noop, info = noop, debug = noop) {
366
- if (notValidLogFn(error)) {
367
- throw createError(notFnMsg('error'));
368
- }
369
- if (notValidLogFn(warn)) {
370
- throw createError(notFnMsg('warn'));
371
- }
372
- if (notValidLogFn(log)) {
373
- throw createError(notFnMsg('log'));
374
- }
375
- if (notValidLogFn(info)) {
376
- throw createError(notFnMsg('info'));
377
- }
378
- if (notValidLogFn(debug)) {
379
- throw createError(notFnMsg('debug'));
380
- }
381
- const { setLogLevel, getLogLevel, shouldLog } = createLogLevelConfig();
382
- const wrapLogFn = (fn, level) => {
383
- if (fn === noop)
384
- return fn;
385
- const condition = () => shouldLog(level);
386
- return createConditionalExecutionFunction(createErrorIgnoringFunction(fn), condition);
387
- };
388
- return freeze({
389
- error: wrapLogFn(error, 'error'),
390
- warn: wrapLogFn(warn, 'warn'),
391
- log: wrapLogFn(log, 'log'),
392
- info: wrapLogFn(info, 'info'),
393
- debug: wrapLogFn(debug, 'debug'),
394
- setLogLevel,
395
- getLogLevel,
396
- });
397
- }
398
- /**
399
- * Validates whether a given value is a valid log function.
400
- *
401
- * @param fn - The value to validate
402
- * @returns True if the value is not a function (invalid), false if it is valid
403
- */
404
- function notValidLogFn(fn) {
405
- return getType(fn) !== 'function' && fn !== noop;
406
- }
407
- /**
408
- * Generates an error message for invalid log function parameters.
409
- *
410
- * @param label - The name of the log function that failed validation
411
- * @returns A formatted error message string
412
- */
413
- function notFnMsg(label) {
414
- return `Cannot create a logger when ${label} is not a function`;
415
- }
416
-
417
- createLogger(error, warn, log, info, debug);
13
+ import { getFileStat, isFile, isDirectory, isSymlink, exists } from '../_shared/core/fs/stat/index.esm.js';
14
+ import { join, joinPosix } from '../_shared/core/path/join/index.esm.js';
15
+ import { normalizePath, normalizeToForwardSlashes, normalizeToNative, removeTrailingSlash, ensureTrailingSlash } from '../_shared/core/path/normalize/index.esm.js';
16
+ import { resolvePath, resolveFromWorkspace, resolveRealPath, relativePath, joinPath, isAbsolute, offsetFromRoot } from '../_shared/core/path/resolve/index.esm.js';
17
+ import { pathSegments, getBasename, getDirname, getExtension, getFileNameWithoutExtension, parsePath } from '../_shared/core/path/segments/index.esm.js';
18
+ import { createStructuredError, createConfigError, createFsError, createParseError, createValidationError } from '../_shared/core/errors/structured-errors/index.esm.js';
19
+ import { createCache, clearAllCaches, getCacheCount, unregisterCache, memoize } from '../_shared/core/cache/index.esm.js';
20
+ import { matchGlobPattern, matchesAnyPattern, matchesExact } from '../_shared/core/patterns/glob/index.esm.js';
21
+ import { detectCaseSensitivity, isCaseSensitiveFs, getPlatformInfo, detectPlatform, isWindows } from '../_shared/core/platform/detect/index.esm.js';
22
+ import { LF, CRLF, getLineEnding, getPathSeparator, normalizeLineEndings, detectLineEnding, pathsEqual } from '../_shared/core/platform/line-endings/index.esm.js';
418
23
 
419
24
  /**
420
25
  * Global log level registry.
@@ -432,7 +37,7 @@ let globalLogLevel = null;
432
37
  *
433
38
  * @param level - The log level to set globally
434
39
  *
435
- * @example
40
+ * @example Enabling debug logging globally
436
41
  * ```typescript
437
42
  * import { setGlobalLogLevel } from '@hyperfrontend/project-scope/core'
438
43
  *
@@ -450,6 +55,13 @@ function setGlobalLogLevel(level) {
450
55
  * Get the current global log level.
451
56
  *
452
57
  * @returns The global log level, or null if not set
58
+ *
59
+ * @example Getting current log level
60
+ * ```typescript
61
+ * setGlobalLogLevel('debug')
62
+ * const level = getGlobalLogLevel()
63
+ * // => 'debug'
64
+ * ```
453
65
  */
454
66
  function getGlobalLogLevel() {
455
67
  return globalLogLevel;
@@ -457,6 +69,14 @@ function getGlobalLogLevel() {
457
69
  /**
458
70
  * Reset the global log level override.
459
71
  * Each logger will retain its current level but new loggers will use their default.
72
+ *
73
+ * @example Resetting the global log level
74
+ * ```typescript
75
+ * setGlobalLogLevel('debug')
76
+ * // ... perform debugging ...
77
+ * resetGlobalLogLevel()
78
+ * // Global override removed, loggers use individual levels
79
+ * ```
460
80
  */
461
81
  function resetGlobalLogLevel() {
462
82
  globalLogLevel = null;
@@ -494,6 +114,13 @@ function isSensitiveKey(key) {
494
114
  *
495
115
  * @param obj - Object to sanitize
496
116
  * @returns New object with sensitive values redacted
117
+ *
118
+ * @example Sanitizing sensitive data
119
+ * ```typescript
120
+ * const config = { apiKey: 'secret123', endpoint: 'https://api.example.com' }
121
+ * const safe = sanitize(config)
122
+ * // => { apiKey: '[REDACTED]', endpoint: 'https://api.example.com' }
123
+ * ```
497
124
  */
498
125
  function sanitize(obj) {
499
126
  if (obj === null || obj === undefined) {
@@ -544,7 +171,7 @@ function formatMessage(namespace, message, meta) {
544
171
  * @param options - Logger configuration options
545
172
  * @returns A configured scoped logger instance
546
173
  *
547
- * @example
174
+ * @example Creating a scoped logger
548
175
  * ```typescript
549
176
  * const logger = createScopedLogger('project-scope')
550
177
  * logger.setLogLevel('debug')
@@ -581,7 +208,7 @@ function createScopedLogger(namespace, options = {}) {
581
208
  * Default logger instance for the project-scope library.
582
209
  * Use this for general logging within the library.
583
210
  *
584
- * @example
211
+ * @example Using the default logger
585
212
  * ```typescript
586
213
  * import { logger } from '@hyperfrontend/project-scope/core'
587
214
  *
@@ -591,58 +218,322 @@ function createScopedLogger(namespace, options = {}) {
591
218
  */
592
219
  const logger = createScopedLogger('project-scope');
593
220
 
594
- const fsLogger = createScopedLogger('project-scope:fs');
221
+ const encodingLogger = createScopedLogger('project-scope:encoding');
222
+ /** UTF-8 BOM bytes */
223
+ const UTF8_BOM_BYTES = [0xef, 0xbb, 0xbf];
224
+ /** UTF-16 LE BOM bytes */
225
+ const UTF16_LE_BOM_BYTES = [0xff, 0xfe];
226
+ /** UTF-16 BE BOM bytes */
227
+ const UTF16_BE_BOM_BYTES = [0xfe, 0xff];
228
+ /** UTF-8 BOM string */
229
+ const UTF8_BOM = '\uFEFF';
595
230
  /**
596
- * Create a file system error with code and context.
597
- *
598
- * @param message - The error message describing what went wrong
599
- * @param code - The category code for this type of filesystem failure
600
- * @param context - Additional context including path, operation, and cause
601
- * @returns A configured Error object with code and context properties
231
+ * Common binary file signatures.
602
232
  */
603
- function createFileSystemError(message, code, context) {
604
- const error = createError(message);
605
- defineProperties(error, {
606
- code: { value: code, enumerable: true },
607
- context: { value: context, enumerable: true },
608
- });
609
- return error;
610
- }
233
+ const BINARY_SIGNATURES = [
234
+ { signature: [0x89, 0x50, 0x4e, 0x47], description: 'PNG' },
235
+ { signature: [0xff, 0xd8, 0xff], description: 'JPEG' },
236
+ { signature: [0x47, 0x49, 0x46, 0x38], description: 'GIF' },
237
+ { signature: [0x50, 0x4b, 0x03, 0x04], description: 'ZIP' },
238
+ { signature: [0x1f, 0x8b], description: 'GZIP' },
239
+ { signature: [0x42, 0x5a, 0x68], description: 'BZIP2' },
240
+ { signature: [0x7f, 0x45, 0x4c, 0x46], description: 'ELF' },
241
+ { signature: [0x4d, 0x5a], description: 'EXE' },
242
+ { signature: [0x25, 0x50, 0x44, 0x46], description: 'PDF' },
243
+ ];
611
244
  /**
612
- * Read file contents as string.
245
+ * Detect if content is likely text or binary with encoding information.
613
246
  *
614
- * @param filePath - Path to file
615
- * @param encoding - File encoding (default: utf-8)
616
- * @returns File contents as string
617
- * @throws {Error} If file doesn't exist or can't be read
247
+ * @param buffer - Buffer to analyze
248
+ * @returns Encoding information
618
249
  *
619
- * @example
250
+ * @example Detecting encoding and BOM info
620
251
  * ```typescript
621
- * import { readFileContent } from '@hyperfrontend/project-scope'
622
- *
623
- * const content = readFileContent('./package.json')
624
- * console.log(content) // JSON string
252
+ * const buffer = readFileSync('./document.txt')
253
+ * const info = detectEncodingInfo(buffer)
254
+ * if (info.type === 'text') {
255
+ * console.log(`Encoding: ${info.encoding}, BOM: ${info.hasBom}`)
256
+ * }
625
257
  * ```
626
258
  */
627
- function readFileContent(filePath, encoding = 'utf-8') {
628
- if (!existsSync(filePath)) {
629
- fsLogger.debug('File not found', { path: filePath });
630
- throw createFileSystemError(`File not found: ${filePath}`, 'FS_NOT_FOUND', { path: filePath, operation: 'read' });
631
- }
632
- try {
633
- return readFileSync(filePath, { encoding });
259
+ function detectEncodingInfo(buffer) {
260
+ encodingLogger.debug('Detecting encoding info', { bufferSize: buffer.length });
261
+ if (buffer.length >= 3) {
262
+ if (buffer[0] === UTF8_BOM_BYTES[0] && buffer[1] === UTF8_BOM_BYTES[1] && buffer[2] === UTF8_BOM_BYTES[2]) {
263
+ encodingLogger.debug('Detected UTF-8 BOM');
264
+ return { type: 'text', encoding: 'utf-8', hasBom: true };
265
+ }
634
266
  }
635
- catch (error) {
636
- fsLogger.warn('Failed to read file', { path: filePath });
637
- throw createFileSystemError(`Failed to read file: ${filePath}`, 'FS_READ_ERROR', { path: filePath, operation: 'read', cause: error });
267
+ if (buffer.length >= 2) {
268
+ if (buffer[0] === UTF16_BE_BOM_BYTES[0] && buffer[1] === UTF16_BE_BOM_BYTES[1]) {
269
+ encodingLogger.debug('Detected UTF-16 BE BOM');
270
+ return { type: 'text', encoding: 'utf16le', hasBom: true };
271
+ }
272
+ if (buffer[0] === UTF16_LE_BOM_BYTES[0] && buffer[1] === UTF16_LE_BOM_BYTES[1]) {
273
+ encodingLogger.debug('Detected UTF-16 LE BOM');
274
+ return { type: 'text', encoding: 'utf16le', hasBom: true };
275
+ }
638
276
  }
639
- }
277
+ for (const { signature, description } of BINARY_SIGNATURES) {
278
+ if (buffer.length >= signature.length) {
279
+ let matches = true;
280
+ for (let i = 0; i < signature.length; i++) {
281
+ if (buffer[i] !== signature[i]) {
282
+ matches = false;
283
+ break;
284
+ }
285
+ }
286
+ if (matches) {
287
+ encodingLogger.debug('Detected binary format by signature', { format: description });
288
+ return { type: 'binary', format: description };
289
+ }
290
+ }
291
+ }
292
+ const sampleSize = min(buffer.length, 8000);
293
+ for (let i = 0; i < sampleSize; i++) {
294
+ if (buffer[i] === 0) {
295
+ encodingLogger.debug('Detected binary content (null byte found)', { position: i });
296
+ return { type: 'binary' };
297
+ }
298
+ }
299
+ encodingLogger.debug('Detected text content (UTF-8 default)');
300
+ return { type: 'text', encoding: 'utf-8', hasBom: false };
301
+ }
302
+ /**
303
+ * Detect file encoding from BOM or content analysis.
304
+ *
305
+ * @param buffer - Buffer to analyze
306
+ * @returns Detected encoding, defaults to 'utf-8'
307
+ *
308
+ * @example Detecting encoding from buffer
309
+ * ```typescript
310
+ * const buffer = readFileSync('./data.txt')
311
+ * const encoding = detectEncoding(buffer)
312
+ * const content = buffer.toString(encoding)
313
+ * ```
314
+ */
315
+ function detectEncoding(buffer) {
316
+ if (buffer.length >= 3) {
317
+ if (buffer[0] === UTF8_BOM_BYTES[0] && buffer[1] === UTF8_BOM_BYTES[1] && buffer[2] === UTF8_BOM_BYTES[2]) {
318
+ return 'utf-8';
319
+ }
320
+ }
321
+ if (buffer.length >= 2) {
322
+ if (buffer[0] === UTF16_LE_BOM_BYTES[0] && buffer[1] === UTF16_LE_BOM_BYTES[1]) {
323
+ return 'utf16le';
324
+ }
325
+ if (buffer[0] === UTF16_BE_BOM_BYTES[0] && buffer[1] === UTF16_BE_BOM_BYTES[1]) {
326
+ return 'utf16le';
327
+ }
328
+ }
329
+ return 'utf-8';
330
+ }
331
+ /**
332
+ * Check if buffer starts with a BOM.
333
+ *
334
+ * @param buffer - Buffer to check
335
+ * @returns True if buffer has a BOM
336
+ *
337
+ * @example Checking if buffer has BOM
338
+ * ```typescript
339
+ * const buffer = readFileSync('./file.txt')
340
+ * if (hasBom(buffer)) {
341
+ * // Strip BOM before processing
342
+ * }
343
+ * ```
344
+ */
345
+ function hasBom(buffer) {
346
+ if (buffer.length >= 3) {
347
+ if (buffer[0] === UTF8_BOM_BYTES[0] && buffer[1] === UTF8_BOM_BYTES[1] && buffer[2] === UTF8_BOM_BYTES[2]) {
348
+ return true;
349
+ }
350
+ }
351
+ if (buffer.length >= 2) {
352
+ if ((buffer[0] === UTF16_LE_BOM_BYTES[0] && buffer[1] === UTF16_LE_BOM_BYTES[1]) ||
353
+ (buffer[0] === UTF16_BE_BOM_BYTES[0] && buffer[1] === UTF16_BE_BOM_BYTES[1])) {
354
+ return true;
355
+ }
356
+ }
357
+ return false;
358
+ }
359
+ /**
360
+ * Check if buffer represents text content.
361
+ *
362
+ * @param buffer - Buffer to check
363
+ * @returns True if the buffer appears to be text
364
+ *
365
+ * @example Checking if content is text
366
+ * ```typescript
367
+ * const buffer = readFileSync('./unknown-file')
368
+ * if (isTextFile(buffer)) {
369
+ * const content = buffer.toString('utf-8')
370
+ * }
371
+ * ```
372
+ */
373
+ function isTextFile(buffer) {
374
+ return detectEncodingInfo(buffer).type === 'text';
375
+ }
376
+
377
+ const convertLogger = createScopedLogger('project-scope:encoding:convert');
378
+ /**
379
+ * Convert content to UTF-8 string.
380
+ *
381
+ * @param content - Buffer or string content
382
+ * @param sourceEncoding - Source encoding (auto-detected if not provided)
383
+ * @returns UTF-8 string
384
+ *
385
+ * @example Converting a buffer to UTF-8 string
386
+ * ```typescript
387
+ * const buffer = Buffer.from('Hello', 'utf-8')
388
+ * const text = toUtf8(buffer)
389
+ * // => 'Hello'
390
+ * ```
391
+ */
392
+ function toUtf8(content, sourceEncoding = 'utf-8') {
393
+ if (typeof content === 'string') {
394
+ return content;
395
+ }
396
+ return content.toString(sourceEncoding);
397
+ }
398
+ /**
399
+ * Convert buffer to string with encoding detection.
400
+ *
401
+ * @param content - Buffer to convert
402
+ * @param encoding - Optional encoding override (auto-detected if not provided)
403
+ * @returns Converted string
404
+ * @throws {Error} If content is binary and cannot be converted
405
+ *
406
+ * @example Converting file buffer to string with auto-detection
407
+ * ```typescript
408
+ * const fileBuffer = readFileSync('./config.json')
409
+ * const content = bufferToString(fileBuffer)
410
+ * // => '{"key": "value"}'
411
+ * ```
412
+ */
413
+ function bufferToString(content, encoding) {
414
+ convertLogger.debug('Converting buffer to string', { bufferSize: content.length, providedEncoding: encoding });
415
+ if (encoding) {
416
+ convertLogger.debug('Using provided encoding', { encoding });
417
+ return content.toString(encoding);
418
+ }
419
+ const info = detectEncodingInfo(content);
420
+ if (info.type === 'text') {
421
+ let offset = 0;
422
+ if (info.hasBom) {
423
+ offset = info.encoding === 'utf-8' ? 3 : 2;
424
+ convertLogger.debug('Stripping BOM from buffer', { encoding: info.encoding, bomOffset: offset });
425
+ }
426
+ return content.subarray(offset).toString(info.encoding);
427
+ }
428
+ convertLogger.warn('Cannot convert binary content to string', { format: info.type === 'binary' ? info.format : undefined });
429
+ throw createError('Cannot convert binary content to string');
430
+ }
431
+ /**
432
+ * Strip BOM from start of string if present.
433
+ *
434
+ * @param content - String that may have BOM
435
+ * @returns String without BOM
436
+ *
437
+ * @example Stripping BOM from a string
438
+ * ```typescript
439
+ * const withBom = '\ufeffHello World'
440
+ * const clean = stripBom(withBom)
441
+ * // => 'Hello World'
442
+ * ```
443
+ */
444
+ function stripBom(content) {
445
+ if (content.charCodeAt(0) === 0xfeff) {
446
+ return content.slice(1);
447
+ }
448
+ return content;
449
+ }
450
+ /**
451
+ * Add UTF-8 BOM to string if not present.
452
+ *
453
+ * @param content - String to add BOM to
454
+ * @returns String with BOM
455
+ *
456
+ * @example Adding UTF-8 BOM to content
457
+ * ```typescript
458
+ * const content = 'Hello World'
459
+ * const withBom = addBom(content)
460
+ * // => '\ufeffHello World'
461
+ * ```
462
+ */
463
+ function addBom(content) {
464
+ if (content.charCodeAt(0) === 0xfeff) {
465
+ return content;
466
+ }
467
+ return UTF8_BOM + content;
468
+ }
469
+
470
+ const fsLogger = createScopedLogger('project-scope:fs');
471
+ /**
472
+ * Create a file system error with code and context.
473
+ *
474
+ * @param message - The error message describing what went wrong
475
+ * @param code - The category code for this type of filesystem failure
476
+ * @param context - Additional context including path, operation, and cause
477
+ * @returns A configured Error object with code and context properties
478
+ *
479
+ * @example Creating a file system error
480
+ * ```typescript
481
+ * throw createFileSystemError(
482
+ * 'Cannot read file',
483
+ * 'FS_READ_ERROR',
484
+ * { path: './missing.txt', operation: 'read' }
485
+ * )
486
+ * ```
487
+ */
488
+ function createFileSystemError(message, code, context) {
489
+ const error = createError(message);
490
+ defineProperties(error, {
491
+ code: { value: code, enumerable: true },
492
+ context: { value: context, enumerable: true },
493
+ });
494
+ return error;
495
+ }
496
+ /**
497
+ * Read file contents as string.
498
+ *
499
+ * @param filePath - Path to file
500
+ * @param encoding - File encoding (default: utf-8)
501
+ * @returns File contents as string
502
+ * @throws {Error} If file doesn't exist or can't be read
503
+ *
504
+ * @example Reading file contents
505
+ * ```typescript
506
+ * import { readFileContent } from '@hyperfrontend/project-scope'
507
+ *
508
+ * const content = readFileContent('./package.json')
509
+ * console.log(content) // JSON string
510
+ * ```
511
+ */
512
+ function readFileContent(filePath, encoding = 'utf-8') {
513
+ if (!existsSync(filePath)) {
514
+ fsLogger.debug('File not found', { path: filePath });
515
+ throw createFileSystemError(`File not found: ${filePath}`, 'FS_NOT_FOUND', { path: filePath, operation: 'read' });
516
+ }
517
+ try {
518
+ return readFileSync(filePath, { encoding });
519
+ }
520
+ catch (error) {
521
+ fsLogger.warn('Failed to read file', { path: filePath });
522
+ throw createFileSystemError(`Failed to read file: ${filePath}`, 'FS_READ_ERROR', { path: filePath, operation: 'read', cause: error });
523
+ }
524
+ }
640
525
  /**
641
526
  * Read file contents as Buffer.
642
527
  *
643
528
  * @param filePath - Path to file
644
529
  * @returns File contents as Buffer
645
530
  * @throws {Error} If file doesn't exist or can't be read
531
+ *
532
+ * @example Reading file as buffer
533
+ * ```typescript
534
+ * const buffer = readFileBuffer('./image.png')
535
+ * console.log(buffer.length) // File size in bytes
536
+ * ```
646
537
  */
647
538
  function readFileBuffer(filePath) {
648
539
  if (!existsSync(filePath)) {
@@ -661,6 +552,14 @@ function readFileBuffer(filePath) {
661
552
  * @param filePath - Path to file
662
553
  * @param encoding - File encoding (default: utf-8)
663
554
  * @returns File contents or null if file doesn't exist
555
+ *
556
+ * @example Reading file if it exists
557
+ * ```typescript
558
+ * const content = readFileIfExists('./optional-config.json')
559
+ * if (content) {
560
+ * // File existed, use content
561
+ * }
562
+ * ```
664
563
  */
665
564
  function readFileIfExists(filePath, encoding = 'utf-8') {
666
565
  if (!existsSync(filePath)) {
@@ -682,7 +581,7 @@ function readFileIfExists(filePath, encoding = 'utf-8') {
682
581
  * @returns Parsed JSON object
683
582
  * @throws {Error} If file doesn't exist (when no default provided) or contains invalid JSON
684
583
  *
685
- * @example
584
+ * @example Reading JSON file
686
585
  * ```typescript
687
586
  * import { readJsonFile } from '@hyperfrontend/project-scope'
688
587
  *
@@ -725,6 +624,13 @@ function readJsonFile(filePath, options) {
725
624
  *
726
625
  * @param filePath - Path to JSON file
727
626
  * @returns Parsed JSON object or null if file doesn't exist or is invalid
627
+ *
628
+ * @example Reading JSON file if it exists
629
+ * ```typescript
630
+ * interface UserSettings { theme: string }
631
+ * const settings = readJsonFileIfExists<UserSettings>('./user-settings.json')
632
+ * const theme = settings?.theme ?? 'default'
633
+ * ```
728
634
  */
729
635
  function readJsonFileIfExists(filePath) {
730
636
  if (!existsSync(filePath)) {
@@ -739,194 +645,17 @@ function readJsonFileIfExists(filePath) {
739
645
  }
740
646
  }
741
647
 
742
- const fsWriteLogger = createScopedLogger('project-scope:fs:write');
743
- /**
744
- * Ensure directory exists, create recursively if not.
745
- *
746
- * @param dirPath - Directory path to ensure exists
747
- */
748
- function ensureDir(dirPath) {
749
- if (!existsSync(dirPath)) {
750
- fsWriteLogger.debug('Creating directory recursively', { path: dirPath });
751
- mkdirSync(dirPath, { recursive: true });
752
- }
753
- }
648
+ const fsDirLogger = createScopedLogger('project-scope:fs:dir');
754
649
  /**
755
- * Write string content to file.
756
- * Creates parent directories if needed.
650
+ * List immediate contents of a directory.
757
651
  *
758
- * @param filePath - Absolute or relative path to the target file
759
- * @param content - String content to write to the file
760
- * @param options - Optional write configuration (encoding, mode)
761
- * @throws {Error} If write fails
652
+ * @param dirPath - Absolute or relative path to the directory
653
+ * @returns Array of entries with metadata for each file/directory
654
+ * @throws {Error} If directory doesn't exist or isn't a directory
762
655
  *
763
- * @example
656
+ * @example Listing directory contents
764
657
  * ```typescript
765
- * import { writeFileContent } from '@hyperfrontend/project-scope'
766
- *
767
- * // Write a simple text file
768
- * writeFileContent('./output/data.txt', 'Hello, World!')
769
- *
770
- * // Write with custom encoding
771
- * writeFileContent('./output/data.txt', 'Content', { encoding: 'utf-8' })
772
- * ```
773
- */
774
- function writeFileContent(filePath, content, options) {
775
- try {
776
- fsWriteLogger.debug('Writing file content', { path: filePath, size: content.length, encoding: options?.encoding ?? 'utf-8' });
777
- ensureDir(dirname(filePath));
778
- writeFileSync(filePath, content, {
779
- encoding: options?.encoding ?? 'utf-8',
780
- mode: options?.mode,
781
- });
782
- fsWriteLogger.debug('File written successfully', { path: filePath });
783
- }
784
- catch (error) {
785
- fsWriteLogger.warn('Failed to write file', { path: filePath, error: error instanceof Error ? error.message : String(error) });
786
- throw createFileSystemError(`Failed to write file: ${filePath}`, 'FS_WRITE_ERROR', { path: filePath, operation: 'write', cause: error });
787
- }
788
- }
789
- /**
790
- * Write Buffer to file.
791
- * Creates parent directories if needed.
792
- *
793
- * @param filePath - Absolute or relative path to the target file
794
- * @param content - Buffer containing binary data to write
795
- * @param options - Optional write configuration (mode)
796
- * @throws {Error} If write fails
797
- */
798
- function writeFileBuffer(filePath, content, options) {
799
- try {
800
- fsWriteLogger.debug('Writing file buffer', { path: filePath, size: content.length });
801
- ensureDir(dirname(filePath));
802
- writeFileSync(filePath, content, { mode: options?.mode });
803
- fsWriteLogger.debug('Buffer written successfully', { path: filePath });
804
- }
805
- catch (error) {
806
- fsWriteLogger.warn('Failed to write buffer', { path: filePath, error: error instanceof Error ? error.message : String(error) });
807
- throw createFileSystemError(`Failed to write file: ${filePath}`, 'FS_WRITE_ERROR', { path: filePath, operation: 'write', cause: error });
808
- }
809
- }
810
- /**
811
- * Write JSON data to file with formatting.
812
- * Creates parent directories if needed.
813
- *
814
- * @param filePath - Absolute or relative path to the target JSON file
815
- * @param data - Object or value to serialize as JSON
816
- * @param options - Optional write configuration (indent, encoding, mode)
817
- * @throws {Error} If write fails
818
- *
819
- * @example
820
- * ```typescript
821
- * import { writeJsonFile } from '@hyperfrontend/project-scope'
822
- *
823
- * // Write object to JSON file
824
- * writeJsonFile('./config.json', { port: 3000, debug: true })
825
- *
826
- * // Write with custom indentation
827
- * writeJsonFile('./config.json', data, { indent: 4 })
828
- * ```
829
- */
830
- function writeJsonFile(filePath, data, options) {
831
- try {
832
- fsWriteLogger.debug('Writing JSON file', { path: filePath, indent: options?.indent ?? 2 });
833
- const indent = options?.indent ?? 2;
834
- const content = stringify(data, null, indent) + '\n';
835
- writeFileContent(filePath, content, options);
836
- fsWriteLogger.debug('JSON file written successfully', { path: filePath });
837
- }
838
- catch (error) {
839
- if (error?.code === 'FS_WRITE_ERROR') {
840
- throw error;
841
- }
842
- fsWriteLogger.warn('Failed to write JSON file', { path: filePath, error: error instanceof Error ? error.message : String(error) });
843
- throw createFileSystemError(`Failed to write JSON file: ${filePath}`, 'FS_WRITE_ERROR', {
844
- path: filePath,
845
- operation: 'write',
846
- cause: error,
847
- });
848
- }
849
- }
850
-
851
- /**
852
- * Get file stats with error handling.
853
- *
854
- * @param filePath - Path to file
855
- * @param followSymlinks - Whether to follow symlinks (default: true)
856
- * @returns File stats or null if path doesn't exist
857
- */
858
- function getFileStat(filePath, followSymlinks = true) {
859
- if (!existsSync(filePath)) {
860
- return null;
861
- }
862
- try {
863
- const stat = followSymlinks ? statSync(filePath) : lstatSync(filePath);
864
- return {
865
- isFile: stat.isFile(),
866
- isDirectory: stat.isDirectory(),
867
- isSymlink: stat.isSymbolicLink(),
868
- size: stat.size,
869
- created: stat.birthtime,
870
- modified: stat.mtime,
871
- accessed: stat.atime,
872
- mode: stat.mode,
873
- };
874
- }
875
- catch {
876
- return null;
877
- }
878
- }
879
- /**
880
- * Check if path is a file.
881
- *
882
- * @param filePath - Path to check
883
- * @returns True if path is a file
884
- */
885
- function isFile(filePath) {
886
- const stats = getFileStat(filePath);
887
- return stats?.isFile ?? false;
888
- }
889
- /**
890
- * Check if path is a directory.
891
- *
892
- * @param dirPath - Path to check
893
- * @returns True if path is a directory
894
- */
895
- function isDirectory(dirPath) {
896
- const stats = getFileStat(dirPath);
897
- return stats?.isDirectory ?? false;
898
- }
899
- /**
900
- * Check if path is a symbolic link.
901
- *
902
- * @param linkPath - Path to check
903
- * @returns True if path is a symlink
904
- */
905
- function isSymlink(linkPath) {
906
- const stats = getFileStat(linkPath, false);
907
- return stats?.isSymlink ?? false;
908
- }
909
- /**
910
- * Check if path exists.
911
- *
912
- * @param filePath - Path to check
913
- * @returns True if path exists
914
- */
915
- function exists(filePath) {
916
- return existsSync(filePath);
917
- }
918
-
919
- const fsDirLogger = createScopedLogger('project-scope:fs:dir');
920
- /**
921
- * List immediate contents of a directory.
922
- *
923
- * @param dirPath - Absolute or relative path to the directory
924
- * @returns Array of entries with metadata for each file/directory
925
- * @throws {Error} If directory doesn't exist or isn't a directory
926
- *
927
- * @example
928
- * ```typescript
929
- * import { readDirectory } from '@hyperfrontend/project-scope'
658
+ * import { readDirectory } from '@hyperfrontend/project-scope'
930
659
  *
931
660
  * const entries = readDirectory('./src')
932
661
  * for (const entry of entries) {
@@ -971,7 +700,7 @@ function readDirectory(dirPath) {
971
700
  * @param options - Configuration for depth limit, hidden files, and symlinks
972
701
  * @returns Flat array of all entries found during traversal
973
702
  *
974
- * @example
703
+ * @example Recursive directory listing with options
975
704
  * ```typescript
976
705
  * import { readDirectoryRecursive } from '@hyperfrontend/project-scope'
977
706
  *
@@ -1032,6 +761,15 @@ function readDirectoryRecursive(dirPath, options) {
1032
761
  * @param dirPath - Path where the directory should be created
1033
762
  * @param options - Creation options
1034
763
  * @param options.recursive - Create parent directories if missing (default: true)
764
+ *
765
+ * @example Creating directories
766
+ * ```typescript
767
+ * // Create nested directories
768
+ * createDirectory('./output/reports/2024')
769
+ *
770
+ * // Create single directory without parents
771
+ * createDirectory('./logs', { recursive: false })
772
+ * ```
1035
773
  */
1036
774
  function createDirectory(dirPath, options) {
1037
775
  const recursive = options?.recursive ?? true;
@@ -1045,6 +783,15 @@ function createDirectory(dirPath, options) {
1045
783
  * @param options - Removal configuration
1046
784
  * @param options.recursive - Delete directory contents recursively
1047
785
  * @param options.force - Ignore errors if directory doesn't exist
786
+ *
787
+ * @example Removing directories
788
+ * ```typescript
789
+ * // Remove directory and all contents
790
+ * removeDirectory('./temp', { recursive: true })
791
+ *
792
+ * // Safe removal (no error if missing)
793
+ * removeDirectory('./cache', { recursive: true, force: true })
794
+ * ```
1048
795
  */
1049
796
  function removeDirectory(dirPath, options) {
1050
797
  fsDirLogger.debug('Removing directory', { path: dirPath, recursive: options?.recursive, force: options?.force });
@@ -1054,227 +801,6 @@ function removeDirectory(dirPath, options) {
1054
801
  });
1055
802
  }
1056
803
 
1057
- /**
1058
- * Join path segments.
1059
- * Uses platform-specific separators (e.g., / or \).
1060
- *
1061
- * @param paths - Path segments to join
1062
- * @returns Joined path
1063
- */
1064
- function join(...paths) {
1065
- return join$1(...paths);
1066
- }
1067
- /**
1068
- * Join path segments using POSIX separators (/).
1069
- * Always uses forward slashes regardless of platform.
1070
- *
1071
- * @param paths - Path segments to join
1072
- * @returns Joined path with forward slashes
1073
- */
1074
- function joinPosix(...paths) {
1075
- return posix.join(...paths);
1076
- }
1077
-
1078
- /**
1079
- * Normalize path separators to forward slashes.
1080
- *
1081
- * @param filePath - Path to normalize
1082
- * @returns Normalized path with forward slashes
1083
- */
1084
- function normalizePath(filePath) {
1085
- if (!filePath)
1086
- return '';
1087
- const normalized = normalize(filePath);
1088
- return sep === '\\' ? normalized.replace(/\\/g, '/') : normalized;
1089
- }
1090
- /**
1091
- * Convert path separators to forward slashes using POSIX style.
1092
- * Resolves `.` and `..` segments for cross-platform configuration.
1093
- *
1094
- * @param filePath - The input path to convert
1095
- * @returns Path with forward slashes and resolved segments
1096
- */
1097
- function normalizeToForwardSlashes(filePath) {
1098
- if (!filePath)
1099
- return '';
1100
- return normalize(filePath).split(sep).join('/');
1101
- }
1102
- /**
1103
- * Convert path to use the operating system's native separator.
1104
- *
1105
- * @param filePath - The input path to convert
1106
- * @returns Path with native separators (backslash on Windows, forward slash elsewhere)
1107
- */
1108
- function normalizeToNative(filePath) {
1109
- if (!filePath)
1110
- return '';
1111
- return normalize(filePath.replace(/[/\\]/g, sep));
1112
- }
1113
- /**
1114
- * Strip any trailing forward or back slashes from a path.
1115
- *
1116
- * @param filePath - Path that may have trailing slashes
1117
- * @returns Path with trailing slashes removed
1118
- */
1119
- function removeTrailingSlash(filePath) {
1120
- let i = filePath.length;
1121
- while (i > 0 && (filePath[i - 1] === '/' || filePath[i - 1] === '\\')) {
1122
- i--;
1123
- }
1124
- return filePath.slice(0, i);
1125
- }
1126
- /**
1127
- * Append a forward slash to the path if not already present.
1128
- *
1129
- * @param filePath - Path to process
1130
- * @returns Path with trailing forward slash
1131
- */
1132
- function ensureTrailingSlash(filePath) {
1133
- const normalized = removeTrailingSlash(filePath);
1134
- return normalized + '/';
1135
- }
1136
-
1137
- /**
1138
- * Resolve path segments to an absolute path.
1139
- *
1140
- * @param segments - Path segments to resolve
1141
- * @returns Resolved absolute path with normalized separators
1142
- */
1143
- function resolvePath(...segments) {
1144
- return normalizePath(resolve(...segments));
1145
- }
1146
- /**
1147
- * Resolve path relative to workspace root.
1148
- *
1149
- * @param workspaceRoot - Workspace root directory
1150
- * @param segments - Path segments relative to workspace
1151
- * @returns Resolved absolute path with normalized separators
1152
- */
1153
- function resolveFromWorkspace(workspaceRoot, ...segments) {
1154
- return normalizePath(resolve(workspaceRoot, ...segments));
1155
- }
1156
- /**
1157
- * Resolve symlinks to real path.
1158
- *
1159
- * @param filePath - Path to resolve
1160
- * @returns Real path or null if path doesn't exist
1161
- */
1162
- function resolveRealPath(filePath) {
1163
- if (!exists(filePath)) {
1164
- return null;
1165
- }
1166
- try {
1167
- return normalizePath(realpathSync(filePath));
1168
- }
1169
- catch {
1170
- return null;
1171
- }
1172
- }
1173
- /**
1174
- * Compute the normalized path from source directory to target.
1175
- *
1176
- * @param from - Source path (base directory)
1177
- * @param to - Target path to reach
1178
- * @returns Relative path from source to target with forward slashes
1179
- */
1180
- function relativePath(from, to) {
1181
- return normalizePath(relative(from, to));
1182
- }
1183
- /**
1184
- * Join path segments.
1185
- *
1186
- * @param segments - Path segments to join
1187
- * @returns Joined path with normalized separators
1188
- */
1189
- function joinPath(...segments) {
1190
- return normalizePath(join$1(...segments));
1191
- }
1192
- /**
1193
- * Check if path is absolute.
1194
- *
1195
- * @param filePath - Path to check
1196
- * @returns True if path is absolute
1197
- */
1198
- function isAbsolute(filePath) {
1199
- return isAbsolute$1(filePath);
1200
- }
1201
- /**
1202
- * Calculate offset from root (e.g., "../../../").
1203
- *
1204
- * @param filePath - Path to calculate offset for
1205
- * @returns Relative offset path (e.g., "../../")
1206
- */
1207
- function offsetFromRoot(filePath) {
1208
- const segments = normalizePath(filePath).split('/').filter(Boolean);
1209
- if (segments.length === 0)
1210
- return '';
1211
- return segments.map(() => '..').join('/') + '/';
1212
- }
1213
-
1214
- /**
1215
- * Split path into segments.
1216
- *
1217
- * @param filePath - Path to split
1218
- * @returns Array of path segments
1219
- */
1220
- function pathSegments(filePath) {
1221
- return filePath.split(/[/\\]/).filter((segment) => segment.length > 0);
1222
- }
1223
- /**
1224
- * Get basename of path.
1225
- *
1226
- * @param filePath - Path to extract basename from
1227
- * @param ext - Optional extension to strip
1228
- * @returns Basename of path
1229
- */
1230
- function getBasename(filePath, ext) {
1231
- return basename(filePath, ext);
1232
- }
1233
- /**
1234
- * Get directory name of path.
1235
- *
1236
- * @param filePath - Path to extract directory from
1237
- * @returns Directory name
1238
- */
1239
- function getDirname(filePath) {
1240
- return normalizePath(dirname(filePath));
1241
- }
1242
- /**
1243
- * Get file extension (including dot).
1244
- *
1245
- * @param filePath - Path to extract extension from
1246
- * @returns Extension including dot (e.g., '.ts')
1247
- */
1248
- function getExtension(filePath) {
1249
- return extname(filePath);
1250
- }
1251
- /**
1252
- * Get filename without extension.
1253
- *
1254
- * @param filePath - Path to extract name from
1255
- * @returns Filename without extension
1256
- */
1257
- function getFileNameWithoutExtension(filePath) {
1258
- const parsed = parse$1(filePath);
1259
- return parsed.name;
1260
- }
1261
- /**
1262
- * Parse path into components.
1263
- *
1264
- * @param filePath - Path to parse
1265
- * @returns Parsed path components
1266
- */
1267
- function parsePath(filePath) {
1268
- const parsed = parse$1(filePath);
1269
- return {
1270
- root: parsed.root,
1271
- dir: normalizePath(parsed.dir),
1272
- base: parsed.base,
1273
- ext: parsed.ext,
1274
- name: parsed.name,
1275
- };
1276
- }
1277
-
1278
804
  const fsTraversalLogger = createScopedLogger('project-scope:fs:traversal');
1279
805
  /**
1280
806
  * Generic upward directory traversal.
@@ -1283,6 +809,15 @@ const fsTraversalLogger = createScopedLogger('project-scope:fs:traversal');
1283
809
  * @param startPath - Starting directory
1284
810
  * @param predicate - Function to test each directory
1285
811
  * @returns First matching directory or null
812
+ *
813
+ * @example Finding directory containing README
814
+ * ```typescript
815
+ * // Find first directory containing a README
816
+ * const readmeDir = traverseUpward('./src/utils', (dir) =>
817
+ * existsSync(join(dir, 'README.md'))
818
+ * )
819
+ * // => '/project' or null
820
+ * ```
1286
821
  */
1287
822
  function traverseUpward(startPath, predicate) {
1288
823
  fsTraversalLogger.debug('Starting upward traversal', { startPath });
@@ -1308,6 +843,17 @@ function traverseUpward(startPath, predicate) {
1308
843
  * @param startPath - Starting directory
1309
844
  * @param markers - Array of marker file names to search for
1310
845
  * @returns First directory containing any marker, or null
846
+ *
847
+ * @example Finding project root by marker files
848
+ * ```typescript
849
+ * // Find project root by looking for common marker files
850
+ * const projectRoot = locateByMarkers('./src/components', [
851
+ * 'package.json',
852
+ * 'nx.json',
853
+ * 'tsconfig.base.json'
854
+ * ])
855
+ * // => '/workspace/my-project'
856
+ * ```
1311
857
  */
1312
858
  function locateByMarkers(startPath, markers) {
1313
859
  fsTraversalLogger.debug('Locating by markers', { startPath, markers });
@@ -1323,912 +869,139 @@ function locateByMarkers(startPath, markers) {
1323
869
  * @param startPath - Starting directory
1324
870
  * @param test - Function to test if directory matches criteria
1325
871
  * @returns Matching directory path or null
872
+ *
873
+ * @example Finding directory with specific config
874
+ * ```typescript
875
+ * // Find directory with a specific config
876
+ * const configDir = findUpwardWhere('./deep/nested/path', (dir) =>
877
+ * existsSync(join(dir, '.eslintrc.js'))
878
+ * )
879
+ * ```
1326
880
  */
1327
881
  function findUpwardWhere(startPath, test) {
1328
882
  fsTraversalLogger.debug('Finding upward where condition met', { startPath });
1329
883
  return traverseUpward(startPath, test);
1330
884
  }
1331
885
 
1332
- const encodingLogger = createScopedLogger('project-scope:encoding');
1333
- /** UTF-8 BOM bytes */
1334
- const UTF8_BOM_BYTES = [0xef, 0xbb, 0xbf];
1335
- /** UTF-16 LE BOM bytes */
1336
- const UTF16_LE_BOM_BYTES = [0xff, 0xfe];
1337
- /** UTF-16 BE BOM bytes */
1338
- const UTF16_BE_BOM_BYTES = [0xfe, 0xff];
1339
- /** UTF-8 BOM string */
1340
- const UTF8_BOM = '\uFEFF';
1341
- /**
1342
- * Common binary file signatures.
1343
- */
1344
- const BINARY_SIGNATURES = [
1345
- { signature: [0x89, 0x50, 0x4e, 0x47], description: 'PNG' },
1346
- { signature: [0xff, 0xd8, 0xff], description: 'JPEG' },
1347
- { signature: [0x47, 0x49, 0x46, 0x38], description: 'GIF' },
1348
- { signature: [0x50, 0x4b, 0x03, 0x04], description: 'ZIP' },
1349
- { signature: [0x1f, 0x8b], description: 'GZIP' },
1350
- { signature: [0x42, 0x5a, 0x68], description: 'BZIP2' },
1351
- { signature: [0x7f, 0x45, 0x4c, 0x46], description: 'ELF' },
1352
- { signature: [0x4d, 0x5a], description: 'EXE' },
1353
- { signature: [0x25, 0x50, 0x44, 0x46], description: 'PDF' },
1354
- ];
886
+ const fsWriteLogger = createScopedLogger('project-scope:fs:write');
1355
887
  /**
1356
- * Detect if content is likely text or binary with encoding information.
888
+ * Ensure directory exists, create recursively if not.
1357
889
  *
1358
- * @param buffer - Buffer to analyze
1359
- * @returns Encoding information
1360
- */
1361
- function detectEncodingInfo(buffer) {
1362
- encodingLogger.debug('Detecting encoding info', { bufferSize: buffer.length });
1363
- if (buffer.length >= 3) {
1364
- if (buffer[0] === UTF8_BOM_BYTES[0] && buffer[1] === UTF8_BOM_BYTES[1] && buffer[2] === UTF8_BOM_BYTES[2]) {
1365
- encodingLogger.debug('Detected UTF-8 BOM');
1366
- return { type: 'text', encoding: 'utf-8', hasBom: true };
1367
- }
1368
- }
1369
- if (buffer.length >= 2) {
1370
- if (buffer[0] === UTF16_BE_BOM_BYTES[0] && buffer[1] === UTF16_BE_BOM_BYTES[1]) {
1371
- encodingLogger.debug('Detected UTF-16 BE BOM');
1372
- return { type: 'text', encoding: 'utf16le', hasBom: true };
1373
- }
1374
- if (buffer[0] === UTF16_LE_BOM_BYTES[0] && buffer[1] === UTF16_LE_BOM_BYTES[1]) {
1375
- encodingLogger.debug('Detected UTF-16 LE BOM');
1376
- return { type: 'text', encoding: 'utf16le', hasBom: true };
1377
- }
1378
- }
1379
- for (const { signature, description } of BINARY_SIGNATURES) {
1380
- if (buffer.length >= signature.length) {
1381
- let matches = true;
1382
- for (let i = 0; i < signature.length; i++) {
1383
- if (buffer[i] !== signature[i]) {
1384
- matches = false;
1385
- break;
1386
- }
1387
- }
1388
- if (matches) {
1389
- encodingLogger.debug('Detected binary format by signature', { format: description });
1390
- return { type: 'binary', format: description };
1391
- }
1392
- }
1393
- }
1394
- const sampleSize = min(buffer.length, 8000);
1395
- for (let i = 0; i < sampleSize; i++) {
1396
- if (buffer[i] === 0) {
1397
- encodingLogger.debug('Detected binary content (null byte found)', { position: i });
1398
- return { type: 'binary' };
1399
- }
1400
- }
1401
- encodingLogger.debug('Detected text content (UTF-8 default)');
1402
- return { type: 'text', encoding: 'utf-8', hasBom: false };
1403
- }
1404
- /**
1405
- * Detect file encoding from BOM or content analysis.
1406
- *
1407
- * @param buffer - Buffer to analyze
1408
- * @returns Detected encoding, defaults to 'utf-8'
1409
- */
1410
- function detectEncoding(buffer) {
1411
- if (buffer.length >= 3) {
1412
- if (buffer[0] === UTF8_BOM_BYTES[0] && buffer[1] === UTF8_BOM_BYTES[1] && buffer[2] === UTF8_BOM_BYTES[2]) {
1413
- return 'utf-8';
1414
- }
1415
- }
1416
- if (buffer.length >= 2) {
1417
- if (buffer[0] === UTF16_LE_BOM_BYTES[0] && buffer[1] === UTF16_LE_BOM_BYTES[1]) {
1418
- return 'utf16le';
1419
- }
1420
- if (buffer[0] === UTF16_BE_BOM_BYTES[0] && buffer[1] === UTF16_BE_BOM_BYTES[1]) {
1421
- return 'utf16le';
1422
- }
1423
- }
1424
- return 'utf-8';
1425
- }
1426
- /**
1427
- * Check if buffer starts with a BOM.
1428
- *
1429
- * @param buffer - Buffer to check
1430
- * @returns True if buffer has a BOM
1431
- */
1432
- function hasBom(buffer) {
1433
- if (buffer.length >= 3) {
1434
- if (buffer[0] === UTF8_BOM_BYTES[0] && buffer[1] === UTF8_BOM_BYTES[1] && buffer[2] === UTF8_BOM_BYTES[2]) {
1435
- return true;
1436
- }
1437
- }
1438
- if (buffer.length >= 2) {
1439
- if ((buffer[0] === UTF16_LE_BOM_BYTES[0] && buffer[1] === UTF16_LE_BOM_BYTES[1]) ||
1440
- (buffer[0] === UTF16_BE_BOM_BYTES[0] && buffer[1] === UTF16_BE_BOM_BYTES[1])) {
1441
- return true;
1442
- }
1443
- }
1444
- return false;
1445
- }
1446
- /**
1447
- * Check if buffer represents text content.
1448
- *
1449
- * @param buffer - Buffer to check
1450
- * @returns True if the buffer appears to be text
1451
- */
1452
- function isTextFile(buffer) {
1453
- return detectEncodingInfo(buffer).type === 'text';
1454
- }
1455
- /**
1456
- * Check if buffer represents binary content.
1457
- *
1458
- * @param buffer - Buffer to check
1459
- * @returns True if the buffer appears to be binary
1460
- */
1461
- function isBinaryFile(buffer) {
1462
- return detectEncodingInfo(buffer).type === 'binary';
1463
- }
1464
-
1465
- const convertLogger = createScopedLogger('project-scope:encoding:convert');
1466
- /**
1467
- * Convert content to UTF-8 string.
1468
- *
1469
- * @param content - Buffer or string content
1470
- * @param sourceEncoding - Source encoding (auto-detected if not provided)
1471
- * @returns UTF-8 string
1472
- */
1473
- function toUtf8(content, sourceEncoding = 'utf-8') {
1474
- if (typeof content === 'string') {
1475
- return content;
1476
- }
1477
- return content.toString(sourceEncoding);
1478
- }
1479
- /**
1480
- * Convert buffer to string with encoding detection.
1481
- *
1482
- * @param content - Buffer to convert
1483
- * @param encoding - Optional encoding override (auto-detected if not provided)
1484
- * @returns Converted string
1485
- * @throws {Error} If content is binary and cannot be converted
1486
- */
1487
- function bufferToString(content, encoding) {
1488
- convertLogger.debug('Converting buffer to string', { bufferSize: content.length, providedEncoding: encoding });
1489
- if (encoding) {
1490
- convertLogger.debug('Using provided encoding', { encoding });
1491
- return content.toString(encoding);
1492
- }
1493
- const info = detectEncodingInfo(content);
1494
- if (info.type === 'text') {
1495
- let offset = 0;
1496
- if (info.hasBom) {
1497
- offset = info.encoding === 'utf-8' ? 3 : 2;
1498
- convertLogger.debug('Stripping BOM from buffer', { encoding: info.encoding, bomOffset: offset });
1499
- }
1500
- return content.subarray(offset).toString(info.encoding);
1501
- }
1502
- convertLogger.warn('Cannot convert binary content to string', { format: info.type === 'binary' ? info.format : undefined });
1503
- throw createError('Cannot convert binary content to string');
1504
- }
1505
- /**
1506
- * Strip BOM from start of string if present.
1507
- *
1508
- * @param content - String that may have BOM
1509
- * @returns String without BOM
1510
- */
1511
- function stripBom(content) {
1512
- if (content.charCodeAt(0) === 0xfeff) {
1513
- return content.slice(1);
1514
- }
1515
- return content;
1516
- }
1517
- /**
1518
- * Add UTF-8 BOM to string if not present.
1519
- *
1520
- * @param content - String to add BOM to
1521
- * @returns String with BOM
1522
- */
1523
- function addBom(content) {
1524
- if (content.charCodeAt(0) === 0xfeff) {
1525
- return content;
1526
- }
1527
- return UTF8_BOM + content;
1528
- }
1529
-
1530
- /**
1531
- * Cached platform info (computed once).
1532
- */
1533
- let cachedPlatformInfo = null;
1534
- /**
1535
- * Cached case sensitivity result.
1536
- */
1537
- let cachedCaseSensitive = null;
1538
- /**
1539
- * Detect if file system is case sensitive.
1540
- *
1541
- * @returns True if file system is case-sensitive
1542
- */
1543
- function detectCaseSensitivity() {
1544
- if (cachedCaseSensitive !== null) {
1545
- return cachedCaseSensitive;
1546
- }
1547
- if (process.platform === 'win32') {
1548
- cachedCaseSensitive = false;
1549
- return false;
1550
- }
1551
- if (process.platform === 'darwin') {
1552
- cachedCaseSensitive = false;
1553
- return false;
1554
- }
1555
- let secureTestDir = null;
1556
- try {
1557
- secureTestDir = mkdtempSync(join$1(tmpdir(), 'case-sensitivity-test-'));
1558
- const testFile = join$1(secureTestDir, 'A');
1559
- const testFileLower = join$1(secureTestDir, 'a');
1560
- writeFileSync(testFile, '');
1561
- cachedCaseSensitive = !existsSync(testFileLower);
1562
- unlinkSync(testFile);
1563
- }
1564
- catch {
1565
- cachedCaseSensitive = true;
1566
- }
1567
- finally {
1568
- if (secureTestDir) {
1569
- try {
1570
- rmdirSync(secureTestDir);
1571
- }
1572
- catch {
1573
- // Ignore cleanup errors
1574
- }
1575
- }
1576
- }
1577
- return cachedCaseSensitive;
1578
- }
1579
- /**
1580
- * Check if file system is case-sensitive.
1581
- *
1582
- * @returns True if file system is case-sensitive
1583
- */
1584
- function isCaseSensitiveFs() {
1585
- return detectCaseSensitivity();
1586
- }
1587
- /**
1588
- * Get comprehensive platform information.
1589
- *
1590
- * @returns Platform information object (cached after first call)
1591
- */
1592
- function getPlatformInfo() {
1593
- if (cachedPlatformInfo) {
1594
- return cachedPlatformInfo;
1595
- }
1596
- const os = platform();
1597
- const archInfo = arch();
1598
- let osName;
1599
- switch (os) {
1600
- case 'win32':
1601
- osName = 'win32';
1602
- break;
1603
- case 'darwin':
1604
- osName = 'darwin';
1605
- break;
1606
- case 'linux':
1607
- osName = 'linux';
1608
- break;
1609
- case 'freebsd':
1610
- osName = 'freebsd';
1611
- break;
1612
- case 'sunos':
1613
- osName = 'sunos';
1614
- break;
1615
- case 'aix':
1616
- osName = 'aix';
1617
- break;
1618
- default:
1619
- osName = 'other';
1620
- }
1621
- cachedPlatformInfo = {
1622
- os: osName,
1623
- arch: archInfo,
1624
- nodeVersion: process.versions.node,
1625
- isWindows: osName === 'win32',
1626
- isMac: osName === 'darwin',
1627
- isLinux: osName === 'linux',
1628
- caseSensitive: detectCaseSensitivity(),
1629
- pathSeparator: osName === 'win32' ? '\\' : '/',
1630
- lineEnding: osName === 'win32' ? '\r\n' : '\n',
1631
- };
1632
- return cachedPlatformInfo;
1633
- }
1634
- /**
1635
- * Detect current platform.
1636
- *
1637
- * @returns Platform information object
1638
- */
1639
- function detectPlatform() {
1640
- return getPlatformInfo();
1641
- }
1642
- /**
1643
- * Check if running on Windows.
1644
- *
1645
- * @returns True if running on Windows
1646
- */
1647
- function isWindows() {
1648
- return process.platform === 'win32';
1649
- }
1650
- /**
1651
- * Check if running on macOS.
1652
- *
1653
- * @returns True if running on macOS
1654
- */
1655
- function isMac() {
1656
- return process.platform === 'darwin';
1657
- }
1658
- /**
1659
- * Check if running on Linux.
1660
- *
1661
- * @returns True if running on Linux
1662
- */
1663
- function isLinux() {
1664
- return process.platform === 'linux';
1665
- }
1666
-
1667
- /** Unix line ending */
1668
- const LF = '\n';
1669
- /** Windows line ending */
1670
- const CRLF = '\r\n';
1671
- /**
1672
- * Get platform-appropriate line ending.
1673
- *
1674
- * @returns Line ending for current platform
1675
- */
1676
- function getLineEnding() {
1677
- return isWindows() ? CRLF : LF;
1678
- }
1679
- /**
1680
- * Get platform-appropriate path separator.
1681
- *
1682
- * @returns Path separator for current platform
1683
- */
1684
- function getPathSeparator() {
1685
- return isWindows() ? '\\' : '/';
1686
- }
1687
- /**
1688
- * Normalize line endings in content.
1689
- *
1690
- * @param content - Content to normalize
1691
- * @param style - Target line ending style ('lf', 'crlf', or 'auto' for platform default)
1692
- * @returns Content with normalized line endings
1693
- */
1694
- function normalizeLineEndings(content, style = 'lf') {
1695
- let target;
1696
- if (style === 'auto') {
1697
- target = isWindows() ? CRLF : LF;
1698
- }
1699
- else {
1700
- target = style === 'crlf' ? CRLF : LF;
1701
- }
1702
- const normalized = content.replace(/\r\n/g, LF).replace(/\r/g, LF);
1703
- if (target === LF) {
1704
- return normalized;
1705
- }
1706
- return normalized.replace(/\n/g, target);
1707
- }
1708
- /**
1709
- * Detect line ending style used in content.
1710
- *
1711
- * @param content - Content to analyze
1712
- * @returns Detected line ending style
1713
- */
1714
- function detectLineEnding(content) {
1715
- const hasCRLF = content.includes(CRLF);
1716
- const hasLFOnly = content.includes('\n') && content.replace(/\r\n/g, '').includes('\n');
1717
- if (hasCRLF && hasLFOnly)
1718
- return 'mixed';
1719
- if (hasCRLF)
1720
- return 'crlf';
1721
- if (content.includes('\n'))
1722
- return 'lf';
1723
- return 'none';
1724
- }
1725
- /**
1726
- * Compare paths with case sensitivity awareness.
1727
- *
1728
- * @param path1 - First path
1729
- * @param path2 - Second path
1730
- * @returns True if paths are equal (respecting case sensitivity)
1731
- */
1732
- function pathsEqual(path1, path2) {
1733
- const caseSensitive = detectCaseSensitivity();
1734
- if (caseSensitive) {
1735
- return path1 === path2;
1736
- }
1737
- return path1.toLowerCase() === path2.toLowerCase();
1738
- }
1739
-
1740
- /**
1741
- * Create a structured error with code and optional context.
1742
- *
1743
- * @param message - The human-readable error message
1744
- * @param code - The machine-readable error code for programmatic handling
1745
- * @param context - Additional contextual information about the error
1746
- * @returns Structured error instance with code and context properties
1747
- *
1748
- * @example
1749
- * ```typescript
1750
- * import { createStructuredError } from '@hyperfrontend/project-scope'
1751
- *
1752
- * throw createStructuredError(
1753
- * 'Configuration file not found',
1754
- * 'CONFIG_NOT_FOUND',
1755
- * { path: './config.json', searched: ['./config.json', './settings.json'] }
1756
- * )
1757
- * ```
1758
- */
1759
- function createStructuredError(message, code, context) {
1760
- const error = createError(message);
1761
- error.code = code;
1762
- error.context = context ?? {};
1763
- return error;
1764
- }
1765
- /**
1766
- * Create a configuration-related error.
1767
- *
1768
- * @param message - The human-readable error message
1769
- * @param code - The machine-readable error code for programmatic handling
1770
- * @param context - Additional contextual information (e.g., file path, config key)
1771
- * @returns Structured error instance tagged with type 'config'
1772
- */
1773
- function createConfigError(message, code, context) {
1774
- return createStructuredError(message, code, { ...context, type: 'config' });
1775
- }
1776
- /**
1777
- * Create a filesystem-related error.
1778
- *
1779
- * @param message - The human-readable error message
1780
- * @param code - The filesystem error code (e.g., ENOENT for not found, EACCES for access denied)
1781
- * @param context - Additional contextual information (e.g., file path, operation attempted)
1782
- * @returns Structured error instance tagged with type 'fs'
1783
- */
1784
- function createFsError(message, code, context) {
1785
- return createStructuredError(message, code, { ...context, type: 'fs' });
1786
- }
1787
- /**
1788
- * Create a parsing-related error.
1789
- *
1790
- * @param message - The human-readable error message
1791
- * @param code - The machine-readable error code for programmatic handling
1792
- * @param context - Additional contextual information (e.g., file path, line/column numbers, expected format)
1793
- * @returns Structured error instance tagged with type 'parse'
1794
- */
1795
- function createParseError(message, code, context) {
1796
- return createStructuredError(message, code, { ...context, type: 'parse' });
1797
- }
1798
- /**
1799
- * Create a validation-related error.
1800
- *
1801
- * @param message - The human-readable error message
1802
- * @param code - The machine-readable error code for programmatic handling
1803
- * @param context - Additional contextual information (e.g., field name, actual vs expected values)
1804
- * @returns Structured error instance tagged with type 'validation'
1805
- */
1806
- function createValidationError(message, code, context) {
1807
- return createStructuredError(message, code, { ...context, type: 'validation' });
1808
- }
1809
-
1810
- /**
1811
- * Match path against glob pattern using safe character iteration.
1812
- * Avoids regex to prevent ReDoS attacks.
1813
- *
1814
- * Supported patterns:
1815
- * - * matches any characters except /
1816
- * - ** matches any characters including /
1817
- * - ? matches exactly one character except /
1818
- * - {a,b,c} matches any of the alternatives
1819
- *
1820
- * @param path - The filesystem path to test against the pattern
1821
- * @param pattern - The glob pattern to match against
1822
- * @returns True if path matches pattern
890
+ * @param dirPath - Directory path to ensure exists
1823
891
  *
1824
- * @example
892
+ * @example Ensuring directory exists
1825
893
  * ```typescript
1826
- * import { matchGlobPattern } from '@hyperfrontend/project-scope'
1827
- *
1828
- * matchGlobPattern('src/utils/helper.ts', '\*\*\/*.ts') // true
1829
- * matchGlobPattern('test.spec.ts', '\*.spec.ts') // true
1830
- * matchGlobPattern('config.json', '\*.{json,yaml}') // true
1831
- * matchGlobPattern('src/index.ts', 'src/\*.ts') // true
894
+ * ensureDir('./output/reports')
895
+ * // Directory now exists (created if missing)
1832
896
  * ```
1833
897
  */
1834
- function matchGlobPattern(path, pattern) {
1835
- return matchSegments(path.split('/'), pattern.split('/'), 0, 0);
1836
- }
1837
- /**
1838
- * Internal recursive function to match path segments against pattern segments.
1839
- *
1840
- * @param pathParts - Array of path segments split by '/'
1841
- * @param patternParts - Array of pattern segments split by '/'
1842
- * @param pathIdx - Current index in pathParts being examined
1843
- * @param patternIdx - Current index in patternParts being examined
1844
- * @returns True if remaining segments match
1845
- */
1846
- function matchSegments(pathParts, patternParts, pathIdx, patternIdx) {
1847
- if (pathIdx === pathParts.length && patternIdx === patternParts.length) {
1848
- return true;
1849
- }
1850
- if (patternIdx >= patternParts.length) {
1851
- return false;
1852
- }
1853
- const patternPart = patternParts[patternIdx];
1854
- if (patternPart === '**') {
1855
- for (let i = pathIdx; i <= pathParts.length; i++) {
1856
- if (matchSegments(pathParts, patternParts, i, patternIdx + 1)) {
1857
- return true;
1858
- }
1859
- }
1860
- return false;
1861
- }
1862
- if (pathIdx >= pathParts.length) {
1863
- return false;
1864
- }
1865
- const pathPart = pathParts[pathIdx];
1866
- if (matchSegment(pathPart, patternPart)) {
1867
- return matchSegments(pathParts, patternParts, pathIdx + 1, patternIdx + 1);
1868
- }
1869
- return false;
1870
- }
1871
- /**
1872
- * Match a single path segment against a pattern segment.
1873
- * Handles *, ?, and {a,b,c} patterns.
1874
- *
1875
- * @param text - The path segment text to match
1876
- * @param pattern - The pattern segment to match against
1877
- * @returns True if the text matches the pattern
1878
- */
1879
- function matchSegment(text, pattern) {
1880
- let textIdx = 0;
1881
- let patternIdx = 0;
1882
- while (patternIdx < pattern.length) {
1883
- const char = pattern[patternIdx];
1884
- if (char === '*') {
1885
- patternIdx++;
1886
- if (patternIdx === pattern.length) {
1887
- return true;
1888
- }
1889
- for (let i = textIdx; i <= text.length; i++) {
1890
- if (matchSegmentFrom(text, i, pattern, patternIdx)) {
1891
- return true;
1892
- }
1893
- }
1894
- return false;
1895
- }
1896
- else if (char === '?') {
1897
- if (textIdx >= text.length) {
1898
- return false;
1899
- }
1900
- textIdx++;
1901
- patternIdx++;
1902
- }
1903
- else if (char === '{') {
1904
- const closeIdx = findClosingBrace(pattern, patternIdx);
1905
- if (closeIdx === -1) {
1906
- if (textIdx >= text.length || text[textIdx] !== char) {
1907
- return false;
1908
- }
1909
- textIdx++;
1910
- patternIdx++;
1911
- }
1912
- else {
1913
- const alternatives = extractAlternatives(pattern.slice(patternIdx + 1, closeIdx));
1914
- for (const alt of alternatives) {
1915
- if (matchSegmentFrom(text, textIdx, text.slice(0, textIdx) + alt + pattern.slice(closeIdx + 1), textIdx)) {
1916
- return true;
1917
- }
1918
- }
1919
- return false;
1920
- }
1921
- }
1922
- else {
1923
- if (textIdx >= text.length || text[textIdx] !== char) {
1924
- return false;
1925
- }
1926
- textIdx++;
1927
- patternIdx++;
1928
- }
1929
- }
1930
- return textIdx === text.length;
1931
- }
1932
- /**
1933
- * Helper to match from a specific position.
1934
- *
1935
- * @param text - The full text being matched
1936
- * @param textIdx - The starting index in text to match from
1937
- * @param pattern - The full pattern being matched
1938
- * @param patternIdx - The starting index in pattern to match from
1939
- * @returns True if the text matches the pattern from the given positions
1940
- */
1941
- function matchSegmentFrom(text, textIdx, pattern, patternIdx) {
1942
- const remainingText = text.slice(textIdx);
1943
- const remainingPattern = pattern.slice(patternIdx);
1944
- return matchSegment(remainingText, remainingPattern);
1945
- }
1946
- /**
1947
- * Find closing brace for {a,b,c} pattern.
1948
- *
1949
- * @param pattern - The pattern string to search within
1950
- * @param startIdx - The index of the opening brace
1951
- * @returns The index of the matching closing brace, or -1 if not found
1952
- */
1953
- function findClosingBrace(pattern, startIdx) {
1954
- let depth = 0;
1955
- for (let i = startIdx; i < pattern.length; i++) {
1956
- if (pattern[i] === '{') {
1957
- depth++;
1958
- }
1959
- else if (pattern[i] === '}') {
1960
- depth--;
1961
- if (depth === 0) {
1962
- return i;
1963
- }
1964
- }
1965
- }
1966
- return -1;
1967
- }
1968
- /**
1969
- * Extract alternatives from {a,b,c} pattern content.
1970
- *
1971
- * @param content - The content between braces (without the braces themselves)
1972
- * @returns Array of alternative strings split by commas at depth 0
1973
- */
1974
- function extractAlternatives(content) {
1975
- const alternatives = [];
1976
- let current = '';
1977
- let depth = 0;
1978
- for (let i = 0; i < content.length; i++) {
1979
- const char = content[i];
1980
- if (char === '{') {
1981
- depth++;
1982
- current += char;
1983
- }
1984
- else if (char === '}') {
1985
- depth--;
1986
- current += char;
1987
- }
1988
- else if (char === ',' && depth === 0) {
1989
- alternatives.push(current);
1990
- current = '';
1991
- }
1992
- else {
1993
- current += char;
1994
- }
1995
- }
1996
- if (current) {
1997
- alternatives.push(current);
898
+ function ensureDir(dirPath) {
899
+ if (!existsSync(dirPath)) {
900
+ fsWriteLogger.debug('Creating directory recursively', { path: dirPath });
901
+ mkdirSync(dirPath, { recursive: true });
1998
902
  }
1999
- return alternatives;
2000
- }
2001
- /**
2002
- * Test if path matches any of the patterns.
2003
- *
2004
- * @param path - Path to test
2005
- * @param patterns - Array of glob patterns
2006
- * @returns True if path matches any pattern
2007
- */
2008
- function matchesAnyPattern(path, patterns) {
2009
- return patterns.some((pattern) => matchGlobPattern(path, pattern));
2010
903
  }
2011
904
  /**
2012
- * Test if path exactly matches the pattern (no glob).
905
+ * Write string content to file.
906
+ * Creates parent directories if needed.
2013
907
  *
2014
- * @param path - Path to test
2015
- * @param pattern - Exact pattern to match
2016
- * @returns True if path equals pattern
2017
- */
2018
- function matchesExact(path, pattern) {
2019
- return path === pattern;
2020
- }
2021
-
2022
- /**
2023
- * Global registry of all caches for bulk operations.
2024
- */
2025
- const cacheRegistry = createSet();
2026
- /**
2027
- * Create a cache with optional TTL and size limits.
908
+ * @param filePath - Absolute or relative path to the target file
909
+ * @param content - String content to write to the file
910
+ * @param options - Optional write configuration (encoding, mode)
911
+ * @throws {Error} If write fails
2028
912
  *
2029
- * The cache provides a simple key-value store with:
2030
- * - Optional TTL (time-to-live) for automatic expiration
2031
- * - Optional maxSize for limiting cache size with FIFO eviction
2032
- * - Lazy expiration (entries are checked on access)
913
+ * @example Writing text content to file
914
+ * ```typescript
915
+ * import { writeFileContent } from '@hyperfrontend/project-scope'
2033
916
  *
2034
- * @param options - Cache configuration options
2035
- * @returns Cache instance
917
+ * // Write a simple text file
918
+ * writeFileContent('./output/data.txt', 'Hello, World!')
2036
919
  *
2037
- * @example
2038
- * ```typescript
2039
- * // Basic cache
2040
- * const cache = createCache<string, number>()
2041
- * cache.set('answer', 42)
2042
- * cache.get('answer') // 42
2043
- *
2044
- * // Cache with TTL (expires after 60 seconds)
2045
- * const ttlCache = createCache<string, object>({ ttl: 60000 })
2046
- *
2047
- * // Cache with max size (evicts oldest when full)
2048
- * const lruCache = createCache<string, object>({ maxSize: 100 })
2049
- *
2050
- * // Combined options
2051
- * const configCache = createCache<string, object>({
2052
- * ttl: 30000,
2053
- * maxSize: 50
2054
- * })
920
+ * // Write with custom encoding
921
+ * writeFileContent('./output/data.txt', 'Content', { encoding: 'utf-8' })
2055
922
  * ```
2056
923
  */
2057
- function createCache(options) {
2058
- const { ttl, maxSize } = options ?? {};
2059
- const store = createMap();
2060
- const insertionOrder = [];
2061
- /**
2062
- * Check if an entry is expired.
2063
- *
2064
- * @param entry - Cache entry to check
2065
- * @returns True if entry is expired
2066
- */
2067
- function isExpired(entry) {
2068
- if (ttl === undefined)
2069
- return false;
2070
- // eslint-disable-next-line workspace/no-unsafe-builtin-methods -- Date.now() is needed for Jest fake timers compatibility
2071
- return Date.now() - entry.timestamp > ttl;
2072
- }
2073
- /**
2074
- * Evict oldest entries to make room for new ones.
2075
- */
2076
- function evictIfNeeded() {
2077
- if (maxSize === undefined)
2078
- return;
2079
- while (store.size >= maxSize && insertionOrder.length > 0) {
2080
- const oldestKey = insertionOrder.shift();
2081
- if (oldestKey !== undefined) {
2082
- store.delete(oldestKey);
2083
- }
2084
- }
924
+ function writeFileContent(filePath, content, options) {
925
+ try {
926
+ fsWriteLogger.debug('Writing file content', { path: filePath, size: content.length, encoding: options?.encoding ?? 'utf-8' });
927
+ ensureDir(dirname(filePath));
928
+ writeFileSync(filePath, content, {
929
+ encoding: options?.encoding ?? 'utf-8',
930
+ mode: options?.mode,
931
+ });
932
+ fsWriteLogger.debug('File written successfully', { path: filePath });
2085
933
  }
2086
- /**
2087
- * Remove key from insertion order tracking.
2088
- *
2089
- * @param key - Key to remove from order tracking
2090
- */
2091
- function removeFromOrder(key) {
2092
- const index = insertionOrder.indexOf(key);
2093
- if (index !== -1) {
2094
- insertionOrder.splice(index, 1);
2095
- }
934
+ catch (error) {
935
+ fsWriteLogger.warn('Failed to write file', { path: filePath, error: error instanceof Error ? error.message : String(error) });
936
+ throw createFileSystemError(`Failed to write file: ${filePath}`, 'FS_WRITE_ERROR', { path: filePath, operation: 'write', cause: error });
2096
937
  }
2097
- const cache = {
2098
- get(key) {
2099
- const entry = store.get(key);
2100
- if (!entry)
2101
- return undefined;
2102
- if (isExpired(entry)) {
2103
- store.delete(key);
2104
- removeFromOrder(key);
2105
- return undefined;
2106
- }
2107
- return entry.value;
2108
- },
2109
- set(key, value) {
2110
- if (store.has(key)) {
2111
- removeFromOrder(key);
2112
- }
2113
- else {
2114
- evictIfNeeded();
2115
- }
2116
- // eslint-disable-next-line workspace/no-unsafe-builtin-methods -- Date.now() is needed for Jest fake timers compatibility
2117
- store.set(key, { value, timestamp: Date.now() });
2118
- insertionOrder.push(key);
2119
- },
2120
- has(key) {
2121
- const entry = store.get(key);
2122
- if (!entry)
2123
- return false;
2124
- if (isExpired(entry)) {
2125
- store.delete(key);
2126
- removeFromOrder(key);
2127
- return false;
2128
- }
2129
- return true;
2130
- },
2131
- delete(key) {
2132
- removeFromOrder(key);
2133
- return store.delete(key);
2134
- },
2135
- clear() {
2136
- store.clear();
2137
- insertionOrder.length = 0;
2138
- },
2139
- size() {
2140
- return store.size;
2141
- },
2142
- keys() {
2143
- return [...insertionOrder];
2144
- },
2145
- };
2146
- cacheRegistry.add(cache);
2147
- return freeze(cache);
2148
938
  }
2149
939
  /**
2150
- * Clear all registered caches.
940
+ * Write Buffer to file.
941
+ * Creates parent directories if needed.
2151
942
  *
2152
- * Useful for testing or when a global state reset is needed.
2153
- * This clears all caches created via `createCache()`.
943
+ * @param filePath - Absolute or relative path to the target file
944
+ * @param content - Buffer containing binary data to write
945
+ * @param options - Optional write configuration (mode)
946
+ * @throws {Error} If write fails
2154
947
  *
2155
- * @example
948
+ * @example Writing binary buffer to file
2156
949
  * ```typescript
2157
- * // In tests
2158
- * afterEach(() => {
2159
- * clearAllCaches()
2160
- * })
950
+ * const imageBuffer = Buffer.from([0x89, 0x50, 0x4e, 0x47])
951
+ * writeFileBuffer('./output/image.png', imageBuffer)
2161
952
  * ```
2162
953
  */
2163
- function clearAllCaches() {
2164
- for (const cache of cacheRegistry) {
2165
- cache.clear();
954
+ function writeFileBuffer(filePath, content, options) {
955
+ try {
956
+ fsWriteLogger.debug('Writing file buffer', { path: filePath, size: content.length });
957
+ ensureDir(dirname(filePath));
958
+ writeFileSync(filePath, content, { mode: options?.mode });
959
+ fsWriteLogger.debug('Buffer written successfully', { path: filePath });
960
+ }
961
+ catch (error) {
962
+ fsWriteLogger.warn('Failed to write buffer', { path: filePath, error: error instanceof Error ? error.message : String(error) });
963
+ throw createFileSystemError(`Failed to write file: ${filePath}`, 'FS_WRITE_ERROR', { path: filePath, operation: 'write', cause: error });
2166
964
  }
2167
965
  }
2168
966
  /**
2169
- * Get the number of registered caches.
2170
- *
2171
- * Primarily used for testing.
2172
- *
2173
- * @returns Number of registered caches
2174
- */
2175
- function getCacheCount() {
2176
- return cacheRegistry.size;
2177
- }
2178
- /**
2179
- * Unregister a cache from the global registry.
2180
- *
2181
- * Useful for cleanup in tests or when a cache is no longer needed.
2182
- *
2183
- * @param cache - Cache to unregister
2184
- * @returns True if cache was unregistered
2185
- */
2186
- function unregisterCache(cache) {
2187
- return cacheRegistry.delete(cache);
2188
- }
2189
- /**
2190
- * Create a memoized version of a function with caching.
2191
- *
2192
- * The memoized function caches results based on the first argument (key).
2193
- * If additional arguments are needed, use the options.keyFn parameter.
967
+ * Write JSON data to file with formatting.
968
+ * Creates parent directories if needed.
2194
969
  *
2195
- * @param fn - Function to memoize
2196
- * @param options - Cache options for the underlying cache
2197
- * @returns Memoized function with cache control methods
970
+ * @param filePath - Absolute or relative path to the target JSON file
971
+ * @param data - Object or value to serialize as JSON
972
+ * @param options - Optional write configuration (indent, encoding, mode)
973
+ * @throws {Error} If write fails
2198
974
  *
2199
- * @example
975
+ * @example Writing JSON data to file
2200
976
  * ```typescript
2201
- * // Memoize a detection function
2202
- * const detectTechStackMemo = memoize(
2203
- * (path: string) => expensiveDetection(path),
2204
- * { ttl: 60000 }
2205
- * )
977
+ * import { writeJsonFile } from '@hyperfrontend/project-scope'
2206
978
  *
2207
- * const result1 = detectTechStackMemo('/path/to/project')
2208
- * const result2 = detectTechStackMemo('/path/to/project') // Returns cached
979
+ * // Write object to JSON file
980
+ * writeJsonFile('./config.json', { port: 3000, debug: true })
2209
981
  *
2210
- * // Clear the cache
2211
- * detectTechStackMemo.cache.clear()
982
+ * // Write with custom indentation
983
+ * writeJsonFile('./config.json', data, { indent: 4 })
2212
984
  * ```
2213
985
  */
2214
- function memoize(fn, options) {
2215
- const cache = createCache(options);
2216
- const memoized = (key) => {
2217
- const cached = cache.get(key);
2218
- if (cached !== undefined) {
2219
- return cached;
986
+ function writeJsonFile(filePath, data, options) {
987
+ try {
988
+ fsWriteLogger.debug('Writing JSON file', { path: filePath, indent: options?.indent ?? 2 });
989
+ const indent = options?.indent ?? 2;
990
+ const content = stringify(data, null, indent) + '\n';
991
+ writeFileContent(filePath, content, options);
992
+ fsWriteLogger.debug('JSON file written successfully', { path: filePath });
993
+ }
994
+ catch (error) {
995
+ if (error?.code === 'FS_WRITE_ERROR') {
996
+ throw error;
2220
997
  }
2221
- const result = fn(key);
2222
- cache.set(key, result);
2223
- return result;
2224
- };
2225
- defineProperty(memoized, 'cache', {
2226
- value: cache,
2227
- writable: false,
2228
- enumerable: true,
2229
- });
2230
- return memoized;
998
+ fsWriteLogger.warn('Failed to write JSON file', { path: filePath, error: error instanceof Error ? error.message : String(error) });
999
+ throw createFileSystemError(`Failed to write JSON file: ${filePath}`, 'FS_WRITE_ERROR', {
1000
+ path: filePath,
1001
+ operation: 'write',
1002
+ cause: error,
1003
+ });
1004
+ }
2231
1005
  }
2232
1006
 
2233
- export { BINARY_SIGNATURES, CRLF, LF, UTF16_BE_BOM_BYTES, UTF16_LE_BOM_BYTES, UTF8_BOM, UTF8_BOM_BYTES, addBom, bufferToString, clearAllCaches, createCache, createConfigError, createDirectory, createFileSystemError, createFsError, createParseError, createScopedLogger, createStructuredError, createValidationError, detectCaseSensitivity, detectEncoding, detectEncodingInfo, detectLineEnding, detectPlatform, ensureDir, ensureTrailingSlash, exists, findUpwardWhere, getBasename, getCacheCount, getDirname, getExtension, getFileNameWithoutExtension, getFileStat, getGlobalLogLevel, getLineEnding, getPathSeparator, getPlatformInfo, hasBom, isAbsolute, isBinaryFile, isCaseSensitiveFs, isDirectory, isFile, isLinux, isMac, isSymlink, isTextFile, isWindows, join, joinPath, joinPosix, locateByMarkers, logger, matchGlobPattern, matchesAnyPattern, matchesExact, memoize, normalizeLineEndings, normalizePath, normalizeToForwardSlashes, normalizeToNative, offsetFromRoot, parsePath, pathSegments, pathsEqual, readDirectory, readDirectoryRecursive, readFileBuffer, readFileContent, readFileIfExists, readJsonFile, readJsonFileIfExists, relativePath, removeDirectory, removeTrailingSlash, resetGlobalLogLevel, resolveFromWorkspace, resolvePath, resolveRealPath, sanitize, setGlobalLogLevel, stripBom, toUtf8, traverseUpward, unregisterCache, writeFileBuffer, writeFileContent, writeJsonFile };
2234
- //# sourceMappingURL=index.esm.js.map
1007
+ export { BINARY_SIGNATURES, CRLF, LF, UTF16_BE_BOM_BYTES, UTF16_LE_BOM_BYTES, UTF8_BOM, UTF8_BOM_BYTES, addBom, bufferToString, clearAllCaches, createCache, createConfigError, createDirectory, createFileSystemError, createFsError, createParseError, createScopedLogger, createStructuredError, createValidationError, detectCaseSensitivity, detectEncoding, detectEncodingInfo, detectLineEnding, detectPlatform, ensureDir, ensureTrailingSlash, exists, findUpwardWhere, getBasename, getCacheCount, getDirname, getExtension, getFileNameWithoutExtension, getFileStat, getGlobalLogLevel, getLineEnding, getPathSeparator, getPlatformInfo, hasBom, isAbsolute, isCaseSensitiveFs, isDirectory, isFile, isSymlink, isTextFile, isWindows, join, joinPath, joinPosix, locateByMarkers, logger, matchGlobPattern, matchesAnyPattern, matchesExact, memoize, normalizeLineEndings, normalizePath, normalizeToForwardSlashes, normalizeToNative, offsetFromRoot, parsePath, pathSegments, pathsEqual, readDirectory, readDirectoryRecursive, readFileBuffer, readFileContent, readFileIfExists, readJsonFile, readJsonFileIfExists, relativePath, removeDirectory, removeTrailingSlash, resetGlobalLogLevel, resolveFromWorkspace, resolvePath, resolveRealPath, sanitize, setGlobalLogLevel, stripBom, toUtf8, traverseUpward, unregisterCache, writeFileBuffer, writeFileContent, writeJsonFile };