@stryke/fs 0.33.32 → 0.33.33

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 (191) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/_virtual/rolldown_runtime.cjs +29 -1
  3. package/dist/buffer.cjs +60 -1
  4. package/dist/buffer.mjs +56 -1
  5. package/dist/buffer.mjs.map +1 -1
  6. package/dist/chmod-x.cjs +93 -1
  7. package/dist/chmod-x.d.cts.map +1 -1
  8. package/dist/chmod-x.mjs +87 -1
  9. package/dist/chmod-x.mjs.map +1 -1
  10. package/dist/command-exists.cjs +102 -1
  11. package/dist/command-exists.mjs +100 -1
  12. package/dist/command-exists.mjs.map +1 -1
  13. package/dist/compress.cjs +29 -1
  14. package/dist/compress.mjs +28 -1
  15. package/dist/compress.mjs.map +1 -1
  16. package/dist/constants.mjs +1 -1
  17. package/dist/convert/src/array-buffer-to-string.cjs +19 -1
  18. package/dist/convert/src/array-buffer-to-string.mjs +18 -1
  19. package/dist/convert/src/array-buffer-to-string.mjs.map +1 -1
  20. package/dist/convert/src/to-array.cjs +15 -1
  21. package/dist/convert/src/to-array.mjs +14 -1
  22. package/dist/convert/src/to-array.mjs.map +1 -1
  23. package/dist/convert/src/uint8-array-to-string.cjs +15 -1
  24. package/dist/convert/src/uint8-array-to-string.mjs +15 -1
  25. package/dist/convert/src/uint8-array-to-string.mjs.map +1 -1
  26. package/dist/copy-file.cjs +87 -1
  27. package/dist/copy-file.mjs +83 -1
  28. package/dist/copy-file.mjs.map +1 -1
  29. package/dist/exists.cjs +27 -1
  30. package/dist/exists.mjs +25 -1
  31. package/dist/exists.mjs.map +1 -1
  32. package/dist/get-parent-path.cjs +35 -1
  33. package/dist/get-parent-path.mjs +34 -1
  34. package/dist/get-parent-path.mjs.map +1 -1
  35. package/dist/get-workspace-root.cjs +158 -1
  36. package/dist/get-workspace-root.mjs +150 -1
  37. package/dist/get-workspace-root.mjs.map +1 -1
  38. package/dist/helpers/src/get-unique.cjs +14 -1
  39. package/dist/helpers/src/get-unique.mjs +13 -1
  40. package/dist/helpers/src/get-unique.mjs.map +1 -1
  41. package/dist/helpers.cjs +83 -1
  42. package/dist/helpers.mjs +77 -1
  43. package/dist/helpers.mjs.map +1 -1
  44. package/dist/index.cjs +122 -1
  45. package/dist/index.mjs +25 -1
  46. package/dist/install.cjs +35 -1
  47. package/dist/install.mjs +33 -1
  48. package/dist/install.mjs.map +1 -1
  49. package/dist/is-file.cjs +51 -1
  50. package/dist/is-file.mjs +47 -1
  51. package/dist/is-file.mjs.map +1 -1
  52. package/dist/json/src/storm-json.cjs +117 -1
  53. package/dist/json/src/storm-json.mjs +115 -1
  54. package/dist/json/src/storm-json.mjs.map +1 -1
  55. package/dist/json/src/utils/code-frames.cjs +77 -3
  56. package/dist/json/src/utils/code-frames.mjs +76 -3
  57. package/dist/json/src/utils/code-frames.mjs.map +1 -1
  58. package/dist/json/src/utils/parse-error.cjs +34 -1
  59. package/dist/json/src/utils/parse-error.mjs +33 -1
  60. package/dist/json/src/utils/parse-error.mjs.map +1 -1
  61. package/dist/json/src/utils/parse.cjs +45 -1
  62. package/dist/json/src/utils/parse.mjs +45 -1
  63. package/dist/json/src/utils/parse.mjs.map +1 -1
  64. package/dist/json/src/utils/stringify.cjs +67 -1
  65. package/dist/json/src/utils/stringify.mjs +67 -1
  66. package/dist/json/src/utils/stringify.mjs.map +1 -1
  67. package/dist/json/src/utils/strip-comments.cjs +86 -4
  68. package/dist/json/src/utils/strip-comments.mjs +86 -4
  69. package/dist/json/src/utils/strip-comments.mjs.map +1 -1
  70. package/dist/json.cjs +74 -1
  71. package/dist/json.mjs +71 -1
  72. package/dist/json.mjs.map +1 -1
  73. package/dist/list-files.cjs +86 -1
  74. package/dist/list-files.mjs +79 -1
  75. package/dist/list-files.mjs.map +1 -1
  76. package/dist/package-fns.cjs +148 -1
  77. package/dist/package-fns.mjs +141 -1
  78. package/dist/package-fns.mjs.map +1 -1
  79. package/dist/path/src/append.cjs +57 -1
  80. package/dist/path/src/append.mjs +56 -1
  81. package/dist/path/src/append.mjs.map +1 -1
  82. package/dist/path/src/correct-path.cjs +138 -1
  83. package/dist/path/src/correct-path.mjs +134 -1
  84. package/dist/path/src/correct-path.mjs.map +1 -1
  85. package/dist/path/src/cwd.cjs +17 -1
  86. package/dist/path/src/cwd.mjs +16 -1
  87. package/dist/path/src/cwd.mjs.map +1 -1
  88. package/dist/path/src/file-path-fns.cjs +169 -1
  89. package/dist/path/src/file-path-fns.mjs +164 -1
  90. package/dist/path/src/file-path-fns.mjs.map +1 -1
  91. package/dist/path/src/is-parent-path.cjs +32 -1
  92. package/dist/path/src/is-parent-path.mjs +32 -1
  93. package/dist/path/src/is-parent-path.mjs.map +1 -1
  94. package/dist/path/src/is-root-dir.cjs +14 -1
  95. package/dist/path/src/is-root-dir.mjs +13 -1
  96. package/dist/path/src/is-root-dir.mjs.map +1 -1
  97. package/dist/path/src/is-type.cjs +68 -1
  98. package/dist/path/src/is-type.mjs +66 -1
  99. package/dist/path/src/is-type.mjs.map +1 -1
  100. package/dist/path/src/join-paths.cjs +106 -1
  101. package/dist/path/src/join-paths.mjs +106 -1
  102. package/dist/path/src/join-paths.mjs.map +1 -1
  103. package/dist/path/src/regex.cjs +18 -1
  104. package/dist/path/src/regex.mjs +11 -1
  105. package/dist/path/src/regex.mjs.map +1 -1
  106. package/dist/path/src/replace.cjs +24 -1
  107. package/dist/path/src/replace.mjs +24 -1
  108. package/dist/path/src/replace.mjs.map +1 -1
  109. package/dist/path/src/resolve-parent-path.cjs +18 -1
  110. package/dist/path/src/resolve-parent-path.mjs +18 -1
  111. package/dist/path/src/resolve-parent-path.mjs.map +1 -1
  112. package/dist/path/src/slash.cjs +15 -1
  113. package/dist/path/src/slash.mjs +14 -1
  114. package/dist/path/src/slash.mjs.map +1 -1
  115. package/dist/read-file.cjs +47 -1
  116. package/dist/read-file.mjs +43 -1
  117. package/dist/read-file.mjs.map +1 -1
  118. package/dist/registry.cjs +142 -1
  119. package/dist/registry.mjs +137 -1
  120. package/dist/registry.mjs.map +1 -1
  121. package/dist/remove-file.cjs +27 -1
  122. package/dist/remove-file.mjs +25 -1
  123. package/dist/remove-file.mjs.map +1 -1
  124. package/dist/resolve.cjs +228 -3
  125. package/dist/resolve.mjs +217 -3
  126. package/dist/resolve.mjs.map +1 -1
  127. package/dist/semver-fns.cjs +129 -1
  128. package/dist/semver-fns.mjs +119 -1
  129. package/dist/semver-fns.mjs.map +1 -1
  130. package/dist/string-format/src/package.cjs +92 -1
  131. package/dist/string-format/src/package.mjs +91 -1
  132. package/dist/string-format/src/package.mjs.map +1 -1
  133. package/dist/toml.cjs +66 -3
  134. package/dist/toml.mjs +61 -3
  135. package/dist/toml.mjs.map +1 -1
  136. package/dist/tsconfig.cjs +37 -1
  137. package/dist/tsconfig.mjs +35 -1
  138. package/dist/tsconfig.mjs.map +1 -1
  139. package/dist/type-checks/src/get-object-tag.cjs +15 -1
  140. package/dist/type-checks/src/get-object-tag.mjs +14 -1
  141. package/dist/type-checks/src/get-object-tag.mjs.map +1 -1
  142. package/dist/type-checks/src/index.cjs +14 -1
  143. package/dist/type-checks/src/index.mjs +16 -1
  144. package/dist/type-checks/src/is-buffer.cjs +12 -1
  145. package/dist/type-checks/src/is-buffer.mjs +11 -1
  146. package/dist/type-checks/src/is-buffer.mjs.map +1 -1
  147. package/dist/type-checks/src/is-collection.cjs +1 -1
  148. package/dist/type-checks/src/is-collection.mjs +3 -1
  149. package/dist/type-checks/src/is-empty.cjs +20 -1
  150. package/dist/type-checks/src/is-empty.mjs +20 -1
  151. package/dist/type-checks/src/is-empty.mjs.map +1 -1
  152. package/dist/type-checks/src/is-error.cjs +29 -1
  153. package/dist/type-checks/src/is-error.mjs +29 -1
  154. package/dist/type-checks/src/is-error.mjs.map +1 -1
  155. package/dist/type-checks/src/is-null.cjs +12 -1
  156. package/dist/type-checks/src/is-null.mjs +11 -1
  157. package/dist/type-checks/src/is-null.mjs.map +1 -1
  158. package/dist/type-checks/src/is-number.cjs +18 -1
  159. package/dist/type-checks/src/is-number.mjs +17 -1
  160. package/dist/type-checks/src/is-number.mjs.map +1 -1
  161. package/dist/type-checks/src/is-object.cjs +19 -1
  162. package/dist/type-checks/src/is-object.mjs +19 -1
  163. package/dist/type-checks/src/is-object.mjs.map +1 -1
  164. package/dist/type-checks/src/is-plain-object.cjs +64 -1
  165. package/dist/type-checks/src/is-plain-object.mjs +63 -1
  166. package/dist/type-checks/src/is-plain-object.mjs.map +1 -1
  167. package/dist/type-checks/src/is-set-string.cjs +20 -1
  168. package/dist/type-checks/src/is-set-string.mjs +20 -1
  169. package/dist/type-checks/src/is-set-string.mjs.map +1 -1
  170. package/dist/type-checks/src/is-set.cjs +19 -1
  171. package/dist/type-checks/src/is-set.mjs +19 -1
  172. package/dist/type-checks/src/is-set.mjs.map +1 -1
  173. package/dist/type-checks/src/is-string.cjs +12 -1
  174. package/dist/type-checks/src/is-string.mjs +11 -1
  175. package/dist/type-checks/src/is-string.mjs.map +1 -1
  176. package/dist/type-checks/src/is-undefined.cjs +8 -1
  177. package/dist/type-checks/src/is-undefined.mjs +7 -1
  178. package/dist/type-checks/src/is-undefined.mjs.map +1 -1
  179. package/dist/type-checks/src/type-detect.cjs +15 -1
  180. package/dist/type-checks/src/type-detect.mjs +16 -1
  181. package/dist/type-checks/src/type-detect.mjs.map +1 -1
  182. package/dist/types/src/base.cjs +6 -1
  183. package/dist/types/src/base.mjs +5 -1
  184. package/dist/types/src/base.mjs.map +1 -1
  185. package/dist/write-file.cjs +40 -1
  186. package/dist/write-file.mjs +38 -1
  187. package/dist/write-file.mjs.map +1 -1
  188. package/dist/yaml.cjs +29 -1
  189. package/dist/yaml.mjs +27 -1
  190. package/dist/yaml.mjs.map +1 -1
  191. package/package.json +6 -6
package/dist/helpers.mjs CHANGED
@@ -1,2 +1,78 @@
1
- import{exists as e,existsSync as t}from"./exists.mjs";import{createWriteStream as n,mkdirSync as r,rmSync as i}from"node:fs";import{mkdir as a,readFile as o,rm as s}from"node:fs/promises";import{parseTar as c,parseTarGzip as l}from"nanotar";function u(e){if(!t(e))return r(e,{recursive:!0})}async function d(t){if(!await e(t))return a(t,{recursive:!0})}function f(e){if(t(e))return i(e,{recursive:!0})}async function p(e){if(t(e))return s(e,{recursive:!0})}async function m(t,r,i){let s=c(await o(t)).find(e=>e.name===r);s?.data&&(await e(i)||await a(i,{recursive:!0}),n(i).write(s.data))}async function h(t,r,i){let s=(await l(await o(t))).find(e=>e.name===r);s?.data&&(await e(i)||await a(i,{recursive:!0}),n(i).write(s.data))}export{d as createDirectory,u as createDirectorySync,m as extractFileFromTar,h as extractFileFromTarGzip,p as removeDirectory,f as removeDirectorySync};
1
+ import { exists, existsSync as existsSync$1 } from "./exists.mjs";
2
+ import { createWriteStream, mkdirSync, rmSync } from "node:fs";
3
+ import { mkdir, readFile, rm } from "node:fs/promises";
4
+ import { parseTar, parseTarGzip } from "nanotar";
5
+
6
+ //#region src/helpers.ts
7
+ /**
8
+ * Create a directory if it does not exist.
9
+ *
10
+ * @param path - The directory path to check
11
+ * @returns An indicator specifying if the directory exists
12
+ */
13
+ function createDirectorySync(path) {
14
+ if (existsSync$1(path)) return;
15
+ return mkdirSync(path, { recursive: true });
16
+ }
17
+ /**
18
+ * Create a directory if it does not exist.
19
+ *
20
+ * @param path - The directory path to check
21
+ * @returns An indicator specifying if the directory exists
22
+ */
23
+ async function createDirectory(path) {
24
+ if (await exists(path)) return;
25
+ return mkdir(path, { recursive: true });
26
+ }
27
+ /**
28
+ * Remove a directory if it exists.
29
+ *
30
+ * @param path - The directory path to check
31
+ * @returns An indicator specifying if the directory exists
32
+ */
33
+ function removeDirectorySync(path) {
34
+ if (!existsSync$1(path)) return;
35
+ return rmSync(path, { recursive: true });
36
+ }
37
+ /**
38
+ * Remove a directory if it exists.
39
+ *
40
+ * @param path - The directory path to check
41
+ * @returns An indicator specifying if the directory exists
42
+ */
43
+ async function removeDirectory(path) {
44
+ if (!existsSync$1(path)) return;
45
+ return rm(path, { recursive: true });
46
+ }
47
+ /**
48
+ * Extracts a file from a given tarball to the specified destination.
49
+ *
50
+ * @param tarballPath - The path to the tarball from where the file should be extracted.
51
+ * @param file - The path to the file inside the tarball.
52
+ * @param destinationFilePath - The destination file path.
53
+ * @returns True if the file was extracted successfully, false otherwise.
54
+ */
55
+ async function extractFileFromTar(tarballPath, file, destinationFilePath) {
56
+ const entry = parseTar(await readFile(tarballPath)).find((e) => e.name === file);
57
+ if (!entry?.data) return;
58
+ if (!await exists(destinationFilePath)) await mkdir(destinationFilePath, { recursive: true });
59
+ createWriteStream(destinationFilePath).write(entry.data);
60
+ }
61
+ /**
62
+ * Extracts a file from a given TarGzip to the specified destination.
63
+ *
64
+ * @param tarballPath - The path to the tarball from where the file should be extracted.
65
+ * @param file - The path to the file inside the tarball.
66
+ * @param destinationFilePath - The destination file path.
67
+ * @returns True if the file was extracted successfully, false otherwise.
68
+ */
69
+ async function extractFileFromTarGzip(tarballPath, file, destinationFilePath) {
70
+ const entry = (await parseTarGzip(await readFile(tarballPath))).find((e) => e.name === file);
71
+ if (!entry?.data) return;
72
+ if (!await exists(destinationFilePath)) await mkdir(destinationFilePath, { recursive: true });
73
+ createWriteStream(destinationFilePath).write(entry.data);
74
+ }
75
+
76
+ //#endregion
77
+ export { createDirectory, createDirectorySync, extractFileFromTar, extractFileFromTarGzip, removeDirectory, removeDirectorySync };
2
78
  //# sourceMappingURL=helpers.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.mjs","names":["existsSync"],"sources":["../src/helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { parseTar, parseTarGzip } from \"nanotar\";\nimport { createWriteStream, mkdirSync, rmSync } from \"node:fs\";\nimport { mkdir, readFile, rm } from \"node:fs/promises\";\nimport { exists, existsSync } from \"./exists\";\n\n/**\n * Create a directory if it does not exist.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport function createDirectorySync(path: string) {\n if (existsSync(path)) {\n return;\n }\n\n return mkdirSync(path, { recursive: true });\n}\n\n/**\n * Create a directory if it does not exist.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport async function createDirectory(path: string) {\n if (await exists(path)) {\n return;\n }\n\n return mkdir(path, { recursive: true });\n}\n\n/**\n * Remove a directory if it exists.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport function removeDirectorySync(path: string) {\n if (!existsSync(path)) {\n return;\n }\n\n return rmSync(path, { recursive: true });\n}\n\n/**\n * Remove a directory if it exists.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport async function removeDirectory(path: string) {\n if (!existsSync(path)) {\n return;\n }\n\n return rm(path, { recursive: true });\n}\n\n/**\n * Extracts a file from a given tarball to the specified destination.\n *\n * @param tarballPath - The path to the tarball from where the file should be extracted.\n * @param file - The path to the file inside the tarball.\n * @param destinationFilePath - The destination file path.\n * @returns True if the file was extracted successfully, false otherwise.\n */\nexport async function extractFileFromTar(\n tarballPath: string,\n file: string,\n destinationFilePath: string\n) {\n const result = parseTar(await readFile(tarballPath));\n\n const entry = result.find(e => e.name === file);\n if (!entry?.data) {\n return;\n }\n\n if (!(await exists(destinationFilePath))) {\n await mkdir(destinationFilePath, { recursive: true });\n }\n\n const stream = createWriteStream(destinationFilePath);\n stream.write(entry.data);\n}\n\n/**\n * Extracts a file from a given TarGzip to the specified destination.\n *\n * @param tarballPath - The path to the tarball from where the file should be extracted.\n * @param file - The path to the file inside the tarball.\n * @param destinationFilePath - The destination file path.\n * @returns True if the file was extracted successfully, false otherwise.\n */\nexport async function extractFileFromTarGzip(\n tarballPath: string,\n file: string,\n destinationFilePath: string\n) {\n const result = await parseTarGzip(await readFile(tarballPath));\n\n const entry = result.find(e => e.name === file);\n if (!entry?.data) {\n return;\n }\n\n if (!(await exists(destinationFilePath))) {\n await mkdir(destinationFilePath, { recursive: true });\n }\n\n const stream = createWriteStream(destinationFilePath);\n stream.write(entry.data);\n}\n"],"mappings":"iPA6BA,SAAgB,EAAoB,EAAc,CAC5CA,MAAW,EAAK,CAIpB,OAAO,EAAU,EAAM,CAAE,UAAW,GAAM,CAAC,CAS7C,eAAsB,EAAgB,EAAc,CAC9C,UAAM,EAAO,EAAK,CAItB,OAAO,EAAM,EAAM,CAAE,UAAW,GAAM,CAAC,CASzC,SAAgB,EAAoB,EAAc,CAC3CA,KAAW,EAAK,CAIrB,OAAO,EAAO,EAAM,CAAE,UAAW,GAAM,CAAC,CAS1C,eAAsB,EAAgB,EAAc,CAC7CA,KAAW,EAAK,CAIrB,OAAO,EAAG,EAAM,CAAE,UAAW,GAAM,CAAC,CAWtC,eAAsB,EACpB,EACA,EACA,EACA,CAGA,IAAM,EAFS,EAAS,MAAM,EAAS,EAAY,CAAC,CAE/B,KAAK,GAAK,EAAE,OAAS,EAAK,CAC1C,GAAO,OAIN,MAAM,EAAO,EAAoB,EACrC,MAAM,EAAM,EAAqB,CAAE,UAAW,GAAM,CAAC,CAGxC,EAAkB,EAAoB,CAC9C,MAAM,EAAM,KAAK,EAW1B,eAAsB,EACpB,EACA,EACA,EACA,CAGA,IAAM,GAFS,MAAM,EAAa,MAAM,EAAS,EAAY,CAAC,EAEzC,KAAK,GAAK,EAAE,OAAS,EAAK,CAC1C,GAAO,OAIN,MAAM,EAAO,EAAoB,EACrC,MAAM,EAAM,EAAqB,CAAE,UAAW,GAAM,CAAC,CAGxC,EAAkB,EAAoB,CAC9C,MAAM,EAAM,KAAK"}
1
+ {"version":3,"file":"helpers.mjs","names":["existsSync"],"sources":["../src/helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { parseTar, parseTarGzip } from \"nanotar\";\nimport { createWriteStream, mkdirSync, rmSync } from \"node:fs\";\nimport { mkdir, readFile, rm } from \"node:fs/promises\";\nimport { exists, existsSync } from \"./exists\";\n\n/**\n * Create a directory if it does not exist.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport function createDirectorySync(path: string) {\n if (existsSync(path)) {\n return;\n }\n\n return mkdirSync(path, { recursive: true });\n}\n\n/**\n * Create a directory if it does not exist.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport async function createDirectory(path: string) {\n if (await exists(path)) {\n return;\n }\n\n return mkdir(path, { recursive: true });\n}\n\n/**\n * Remove a directory if it exists.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport function removeDirectorySync(path: string) {\n if (!existsSync(path)) {\n return;\n }\n\n return rmSync(path, { recursive: true });\n}\n\n/**\n * Remove a directory if it exists.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport async function removeDirectory(path: string) {\n if (!existsSync(path)) {\n return;\n }\n\n return rm(path, { recursive: true });\n}\n\n/**\n * Extracts a file from a given tarball to the specified destination.\n *\n * @param tarballPath - The path to the tarball from where the file should be extracted.\n * @param file - The path to the file inside the tarball.\n * @param destinationFilePath - The destination file path.\n * @returns True if the file was extracted successfully, false otherwise.\n */\nexport async function extractFileFromTar(\n tarballPath: string,\n file: string,\n destinationFilePath: string\n) {\n const result = parseTar(await readFile(tarballPath));\n\n const entry = result.find(e => e.name === file);\n if (!entry?.data) {\n return;\n }\n\n if (!(await exists(destinationFilePath))) {\n await mkdir(destinationFilePath, { recursive: true });\n }\n\n const stream = createWriteStream(destinationFilePath);\n stream.write(entry.data);\n}\n\n/**\n * Extracts a file from a given TarGzip to the specified destination.\n *\n * @param tarballPath - The path to the tarball from where the file should be extracted.\n * @param file - The path to the file inside the tarball.\n * @param destinationFilePath - The destination file path.\n * @returns True if the file was extracted successfully, false otherwise.\n */\nexport async function extractFileFromTarGzip(\n tarballPath: string,\n file: string,\n destinationFilePath: string\n) {\n const result = await parseTarGzip(await readFile(tarballPath));\n\n const entry = result.find(e => e.name === file);\n if (!entry?.data) {\n return;\n }\n\n if (!(await exists(destinationFilePath))) {\n await mkdir(destinationFilePath, { recursive: true });\n }\n\n const stream = createWriteStream(destinationFilePath);\n stream.write(entry.data);\n}\n"],"mappings":";;;;;;;;;;;;AA6BA,SAAgB,oBAAoB,MAAc;AAChD,KAAIA,aAAW,KAAK,CAClB;AAGF,QAAO,UAAU,MAAM,EAAE,WAAW,MAAM,CAAC;;;;;;;;AAS7C,eAAsB,gBAAgB,MAAc;AAClD,KAAI,MAAM,OAAO,KAAK,CACpB;AAGF,QAAO,MAAM,MAAM,EAAE,WAAW,MAAM,CAAC;;;;;;;;AASzC,SAAgB,oBAAoB,MAAc;AAChD,KAAI,CAACA,aAAW,KAAK,CACnB;AAGF,QAAO,OAAO,MAAM,EAAE,WAAW,MAAM,CAAC;;;;;;;;AAS1C,eAAsB,gBAAgB,MAAc;AAClD,KAAI,CAACA,aAAW,KAAK,CACnB;AAGF,QAAO,GAAG,MAAM,EAAE,WAAW,MAAM,CAAC;;;;;;;;;;AAWtC,eAAsB,mBACpB,aACA,MACA,qBACA;CAGA,MAAM,QAFS,SAAS,MAAM,SAAS,YAAY,CAAC,CAE/B,MAAK,MAAK,EAAE,SAAS,KAAK;AAC/C,KAAI,CAAC,OAAO,KACV;AAGF,KAAI,CAAE,MAAM,OAAO,oBAAoB,CACrC,OAAM,MAAM,qBAAqB,EAAE,WAAW,MAAM,CAAC;AAIvD,CADe,kBAAkB,oBAAoB,CAC9C,MAAM,MAAM,KAAK;;;;;;;;;;AAW1B,eAAsB,uBACpB,aACA,MACA,qBACA;CAGA,MAAM,SAFS,MAAM,aAAa,MAAM,SAAS,YAAY,CAAC,EAEzC,MAAK,MAAK,EAAE,SAAS,KAAK;AAC/C,KAAI,CAAC,OAAO,KACV;AAGF,KAAI,CAAE,MAAM,OAAO,oBAAoB,CACrC,OAAM,MAAM,qBAAqB,EAAE,WAAW,MAAM,CAAC;AAIvD,CADe,kBAAkB,oBAAoB,CAC9C,MAAM,MAAM,KAAK"}
package/dist/index.cjs CHANGED
@@ -1 +1,122 @@
1
- const e=require(`./exists.cjs`),t=require(`./helpers.cjs`),n=require(`./buffer.cjs`),r=require(`./chmod-x.cjs`),i=require(`./command-exists.cjs`),a=require(`./is-file.cjs`),o=require(`./list-files.cjs`),s=require(`./read-file.cjs`),c=require(`./write-file.cjs`),l=require(`./compress.cjs`),u=require(`./copy-file.cjs`),d=require(`./get-parent-path.cjs`),f=require(`./get-workspace-root.cjs`),p=require(`./resolve.cjs`),m=require(`./install.cjs`),h=require(`./json.cjs`),g=require(`./package-fns.cjs`),_=require(`./registry.cjs`),v=require(`./remove-file.cjs`),y=require(`./semver-fns.cjs`),b=require(`./toml.cjs`),x=require(`./tsconfig.cjs`),S=require(`./yaml.cjs`);exports.DEFAULT_EXTENSIONS=p.DEFAULT_EXTENSIONS,exports.PROJECT_ROOT_CONTENT=f.PROJECT_ROOT_CONTENT,exports.WORKSPACE_ROOT_CONTENT=f.WORKSPACE_ROOT_CONTENT,exports.chmodX=r.chmodX,exports.chmodXSync=r.chmodXSync,exports.coerceVersion=y.coerceVersion,exports.commandExists=i.commandExists,exports.commandExistsSync=i.commandExistsSync,exports.compressDirectory=l.compressDirectory,exports.copyFile=u.copyFile,exports.copyFileSync=u.copyFileSync,exports.copyFiles=u.copyFiles,exports.copyFilesSync=u.copyFilesSync,exports.createDirectory=t.createDirectory,exports.createDirectorySync=t.createDirectorySync,exports.deriveNewSemverVersion=y.deriveNewSemverVersion,exports.doesPackageMatch=g.doesPackageMatch,exports.exists=e.exists,exports.existsSync=e.existsSync,exports.extractFileFromTar=t.extractFileFromTar,exports.extractFileFromTarGzip=t.extractFileFromTarGzip,exports.formatNodeOptions=_.formatNodeOptions,exports.getFormattedNodeOptionsWithoutInspect=_.getFormattedNodeOptionsWithoutInspect,exports.getNodeModulesPaths=p.getNodeModulesPaths,exports.getPackageInfo=g.getPackageInfo,exports.getPackageListing=g.getPackageListing,exports.getPackageManager=g.getPackageManager,exports.getParentPath=d.getParentPath,exports.getParsedNodeOptionsWithoutInspect=_.getParsedNodeOptionsWithoutInspect,exports.getProjectRoot=f.getProjectRoot,exports.getRegistry=_.getRegistry,exports.getResolutionCombinations=p.getResolutionCombinations,exports.getResolutionPaths=p.getResolutionPaths,exports.getWorkspaceRoot=f.getWorkspaceRoot,exports.importModule=p.importModule,exports.install=m.install,exports.isDirectory=a.isDirectory,exports.isDirectorySymlink=a.isDirectorySymlink,exports.isExecutable=r.isExecutable,exports.isExecutableSync=r.isExecutableSync,exports.isFile=a.isFile,exports.isFileSymlink=a.isFileSymlink,exports.isPackageExists=g.isPackageExists,exports.isPackageListed=g.isPackageListed,exports.isProjectRoot=f.isProjectRoot,exports.isRange=y.isRange,exports.isRelativeVersionKeyword=y.isRelativeVersionKeyword,exports.isSemver=y.isSemver,exports.isValidRange=y.isValidRange,exports.isValidSemver=y.isValidSemver,exports.isValidVersion=y.isValidVersion,exports.isWorkspaceRoot=f.isWorkspaceRoot,exports.isWritable=r.isWritable,exports.isWritableSync=r.isWritableSync,exports.list=o.list,exports.listDirectories=o.listDirectories,exports.listDirectoriesSync=o.listDirectoriesSync,exports.listFiles=o.listFiles,exports.listFilesSync=o.listFilesSync,exports.listSync=o.listSync,exports.loadPackageJson=g.loadPackageJson,exports.loadTsConfig=x.loadTsConfig,exports.packageExists=m.packageExists,exports.parseVersion=y.parseVersion,exports.readFile=s.readFile,exports.readFileBuffer=n.readFileBuffer,exports.readFileBufferSync=n.readFileBufferSync,exports.readFileIfExisting=s.readFileIfExisting,exports.readFileIfExistingSync=s.readFileIfExistingSync,exports.readFileSync=s.readFileSync,exports.readJsonFile=h.readJsonFile,exports.readJsonFileSync=h.readJsonFileSync,exports.readTomlFile=b.readTomlFile,exports.readTomlFileSync=b.readTomlFileSync,exports.readYamlFile=S.readYamlFile,exports.readYamlFileSync=S.readYamlFileSync,exports.relativeToProjectRoot=f.relativeToProjectRoot,exports.relativeToWorkspaceRoot=f.relativeToWorkspaceRoot,exports.removeDirectory=t.removeDirectory,exports.removeDirectorySync=t.removeDirectorySync,exports.removeFile=v.removeFile,exports.removeFileSync=v.removeFileSync,exports.resolve=p.resolve,exports.resolvePackage=p.resolvePackage,exports.resolvePackageSync=p.resolvePackageSync,exports.resolveSafe=p.resolveSafe,exports.resolveSafeSync=p.resolveSafeSync,exports.resolveSync=p.resolveSync,exports.satisfiesVersion=y.satisfiesVersion,exports.tokenizeArgs=_.tokenizeArgs,exports.writeFile=c.writeFile,exports.writeFileBuffer=n.writeFileBuffer,exports.writeFileBufferSync=n.writeFileBufferSync,exports.writeFileSync=c.writeFileSync,exports.writeJsonFile=h.writeJsonFile,exports.writeJsonFileSync=h.writeJsonFileSync,exports.writeTomlFile=b.writeTomlFile,exports.writeTomlFileSync=b.writeTomlFileSync;
1
+ const require_exists = require('./exists.cjs');
2
+ const require_helpers = require('./helpers.cjs');
3
+ const require_buffer = require('./buffer.cjs');
4
+ const require_chmod_x = require('./chmod-x.cjs');
5
+ const require_command_exists = require('./command-exists.cjs');
6
+ const require_is_file = require('./is-file.cjs');
7
+ const require_list_files = require('./list-files.cjs');
8
+ const require_read_file = require('./read-file.cjs');
9
+ const require_write_file = require('./write-file.cjs');
10
+ const require_compress = require('./compress.cjs');
11
+ const require_copy_file = require('./copy-file.cjs');
12
+ const require_get_parent_path = require('./get-parent-path.cjs');
13
+ const require_get_workspace_root = require('./get-workspace-root.cjs');
14
+ const require_resolve = require('./resolve.cjs');
15
+ const require_install = require('./install.cjs');
16
+ const require_json = require('./json.cjs');
17
+ const require_package_fns = require('./package-fns.cjs');
18
+ const require_registry = require('./registry.cjs');
19
+ const require_remove_file = require('./remove-file.cjs');
20
+ const require_semver_fns = require('./semver-fns.cjs');
21
+ const require_toml = require('./toml.cjs');
22
+ const require_tsconfig = require('./tsconfig.cjs');
23
+ const require_yaml = require('./yaml.cjs');
24
+
25
+ exports.DEFAULT_EXTENSIONS = require_resolve.DEFAULT_EXTENSIONS;
26
+ exports.PROJECT_ROOT_CONTENT = require_get_workspace_root.PROJECT_ROOT_CONTENT;
27
+ exports.WORKSPACE_ROOT_CONTENT = require_get_workspace_root.WORKSPACE_ROOT_CONTENT;
28
+ exports.chmodX = require_chmod_x.chmodX;
29
+ exports.chmodXSync = require_chmod_x.chmodXSync;
30
+ exports.coerceVersion = require_semver_fns.coerceVersion;
31
+ exports.commandExists = require_command_exists.commandExists;
32
+ exports.commandExistsSync = require_command_exists.commandExistsSync;
33
+ exports.compressDirectory = require_compress.compressDirectory;
34
+ exports.copyFile = require_copy_file.copyFile;
35
+ exports.copyFileSync = require_copy_file.copyFileSync;
36
+ exports.copyFiles = require_copy_file.copyFiles;
37
+ exports.copyFilesSync = require_copy_file.copyFilesSync;
38
+ exports.createDirectory = require_helpers.createDirectory;
39
+ exports.createDirectorySync = require_helpers.createDirectorySync;
40
+ exports.deriveNewSemverVersion = require_semver_fns.deriveNewSemverVersion;
41
+ exports.doesPackageMatch = require_package_fns.doesPackageMatch;
42
+ exports.exists = require_exists.exists;
43
+ exports.existsSync = require_exists.existsSync;
44
+ exports.extractFileFromTar = require_helpers.extractFileFromTar;
45
+ exports.extractFileFromTarGzip = require_helpers.extractFileFromTarGzip;
46
+ exports.formatNodeOptions = require_registry.formatNodeOptions;
47
+ exports.getFormattedNodeOptionsWithoutInspect = require_registry.getFormattedNodeOptionsWithoutInspect;
48
+ exports.getNodeModulesPaths = require_resolve.getNodeModulesPaths;
49
+ exports.getPackageInfo = require_package_fns.getPackageInfo;
50
+ exports.getPackageListing = require_package_fns.getPackageListing;
51
+ exports.getPackageManager = require_package_fns.getPackageManager;
52
+ exports.getParentPath = require_get_parent_path.getParentPath;
53
+ exports.getParsedNodeOptionsWithoutInspect = require_registry.getParsedNodeOptionsWithoutInspect;
54
+ exports.getProjectRoot = require_get_workspace_root.getProjectRoot;
55
+ exports.getRegistry = require_registry.getRegistry;
56
+ exports.getResolutionCombinations = require_resolve.getResolutionCombinations;
57
+ exports.getResolutionPaths = require_resolve.getResolutionPaths;
58
+ exports.getWorkspaceRoot = require_get_workspace_root.getWorkspaceRoot;
59
+ exports.importModule = require_resolve.importModule;
60
+ exports.install = require_install.install;
61
+ exports.isDirectory = require_is_file.isDirectory;
62
+ exports.isDirectorySymlink = require_is_file.isDirectorySymlink;
63
+ exports.isExecutable = require_chmod_x.isExecutable;
64
+ exports.isExecutableSync = require_chmod_x.isExecutableSync;
65
+ exports.isFile = require_is_file.isFile;
66
+ exports.isFileSymlink = require_is_file.isFileSymlink;
67
+ exports.isPackageExists = require_package_fns.isPackageExists;
68
+ exports.isPackageListed = require_package_fns.isPackageListed;
69
+ exports.isProjectRoot = require_get_workspace_root.isProjectRoot;
70
+ exports.isRange = require_semver_fns.isRange;
71
+ exports.isRelativeVersionKeyword = require_semver_fns.isRelativeVersionKeyword;
72
+ exports.isSemver = require_semver_fns.isSemver;
73
+ exports.isValidRange = require_semver_fns.isValidRange;
74
+ exports.isValidSemver = require_semver_fns.isValidSemver;
75
+ exports.isValidVersion = require_semver_fns.isValidVersion;
76
+ exports.isWorkspaceRoot = require_get_workspace_root.isWorkspaceRoot;
77
+ exports.isWritable = require_chmod_x.isWritable;
78
+ exports.isWritableSync = require_chmod_x.isWritableSync;
79
+ exports.list = require_list_files.list;
80
+ exports.listDirectories = require_list_files.listDirectories;
81
+ exports.listDirectoriesSync = require_list_files.listDirectoriesSync;
82
+ exports.listFiles = require_list_files.listFiles;
83
+ exports.listFilesSync = require_list_files.listFilesSync;
84
+ exports.listSync = require_list_files.listSync;
85
+ exports.loadPackageJson = require_package_fns.loadPackageJson;
86
+ exports.loadTsConfig = require_tsconfig.loadTsConfig;
87
+ exports.packageExists = require_install.packageExists;
88
+ exports.parseVersion = require_semver_fns.parseVersion;
89
+ exports.readFile = require_read_file.readFile;
90
+ exports.readFileBuffer = require_buffer.readFileBuffer;
91
+ exports.readFileBufferSync = require_buffer.readFileBufferSync;
92
+ exports.readFileIfExisting = require_read_file.readFileIfExisting;
93
+ exports.readFileIfExistingSync = require_read_file.readFileIfExistingSync;
94
+ exports.readFileSync = require_read_file.readFileSync;
95
+ exports.readJsonFile = require_json.readJsonFile;
96
+ exports.readJsonFileSync = require_json.readJsonFileSync;
97
+ exports.readTomlFile = require_toml.readTomlFile;
98
+ exports.readTomlFileSync = require_toml.readTomlFileSync;
99
+ exports.readYamlFile = require_yaml.readYamlFile;
100
+ exports.readYamlFileSync = require_yaml.readYamlFileSync;
101
+ exports.relativeToProjectRoot = require_get_workspace_root.relativeToProjectRoot;
102
+ exports.relativeToWorkspaceRoot = require_get_workspace_root.relativeToWorkspaceRoot;
103
+ exports.removeDirectory = require_helpers.removeDirectory;
104
+ exports.removeDirectorySync = require_helpers.removeDirectorySync;
105
+ exports.removeFile = require_remove_file.removeFile;
106
+ exports.removeFileSync = require_remove_file.removeFileSync;
107
+ exports.resolve = require_resolve.resolve;
108
+ exports.resolvePackage = require_resolve.resolvePackage;
109
+ exports.resolvePackageSync = require_resolve.resolvePackageSync;
110
+ exports.resolveSafe = require_resolve.resolveSafe;
111
+ exports.resolveSafeSync = require_resolve.resolveSafeSync;
112
+ exports.resolveSync = require_resolve.resolveSync;
113
+ exports.satisfiesVersion = require_semver_fns.satisfiesVersion;
114
+ exports.tokenizeArgs = require_registry.tokenizeArgs;
115
+ exports.writeFile = require_write_file.writeFile;
116
+ exports.writeFileBuffer = require_buffer.writeFileBuffer;
117
+ exports.writeFileBufferSync = require_buffer.writeFileBufferSync;
118
+ exports.writeFileSync = require_write_file.writeFileSync;
119
+ exports.writeJsonFile = require_json.writeJsonFile;
120
+ exports.writeJsonFileSync = require_json.writeJsonFileSync;
121
+ exports.writeTomlFile = require_toml.writeTomlFile;
122
+ exports.writeTomlFileSync = require_toml.writeTomlFileSync;
package/dist/index.mjs CHANGED
@@ -1 +1,25 @@
1
- import{exists as e,existsSync as t}from"./exists.mjs";import{createDirectory as n,createDirectorySync as r,extractFileFromTar as i,extractFileFromTarGzip as a,removeDirectory as o,removeDirectorySync as s}from"./helpers.mjs";import{readFileBuffer as c,readFileBufferSync as l,writeFileBuffer as u,writeFileBufferSync as d}from"./buffer.mjs";import{chmodX as f,chmodXSync as p,isExecutable as m,isExecutableSync as h,isWritable as g,isWritableSync as _}from"./chmod-x.mjs";import{commandExists as v,commandExistsSync as y}from"./command-exists.mjs";import{isDirectory as b,isDirectorySymlink as x,isFile as S,isFileSymlink as C}from"./is-file.mjs";import{list as w,listDirectories as T,listDirectoriesSync as E,listFiles as D,listFilesSync as O,listSync as k}from"./list-files.mjs";import{readFile as A,readFileIfExisting as j,readFileIfExistingSync as M,readFileSync as N}from"./read-file.mjs";import{writeFile as P,writeFileSync as F}from"./write-file.mjs";import{compressDirectory as I}from"./compress.mjs";import{copyFile as L,copyFileSync as R,copyFiles as z,copyFilesSync as B}from"./copy-file.mjs";import{getParentPath as V}from"./get-parent-path.mjs";import{PROJECT_ROOT_CONTENT as H,WORKSPACE_ROOT_CONTENT as U,getProjectRoot as W,getWorkspaceRoot as G,isProjectRoot as K,isWorkspaceRoot as q,relativeToProjectRoot as J,relativeToWorkspaceRoot as Y}from"./get-workspace-root.mjs";import{DEFAULT_EXTENSIONS as X,getNodeModulesPaths as Z,getResolutionCombinations as Q,getResolutionPaths as $,importModule as ee,resolve as te,resolvePackage as ne,resolvePackageSync as re,resolveSafe as ie,resolveSafeSync as ae,resolveSync as oe}from"./resolve.mjs";import{install as se,packageExists as ce}from"./install.mjs";import{readJsonFile as le,readJsonFileSync as ue,writeJsonFile as de,writeJsonFileSync as fe}from"./json.mjs";import{doesPackageMatch as pe,getPackageInfo as me,getPackageListing as he,getPackageManager as ge,isPackageExists as _e,isPackageListed as ve,loadPackageJson as ye}from"./package-fns.mjs";import{formatNodeOptions as be,getFormattedNodeOptionsWithoutInspect as xe,getParsedNodeOptionsWithoutInspect as Se,getRegistry as Ce,tokenizeArgs as we}from"./registry.mjs";import{removeFile as Te,removeFileSync as Ee}from"./remove-file.mjs";import{coerceVersion as De,deriveNewSemverVersion as Oe,isRange as ke,isRelativeVersionKeyword as Ae,isSemver as je,isValidRange as Me,isValidSemver as Ne,isValidVersion as Pe,parseVersion as Fe,satisfiesVersion as Ie}from"./semver-fns.mjs";import{readTomlFile as Le,readTomlFileSync as Re,writeTomlFile as ze,writeTomlFileSync as Be}from"./toml.mjs";import{loadTsConfig as Ve}from"./tsconfig.mjs";import{readYamlFile as He,readYamlFileSync as Ue}from"./yaml.mjs";export{X as DEFAULT_EXTENSIONS,H as PROJECT_ROOT_CONTENT,U as WORKSPACE_ROOT_CONTENT,f as chmodX,p as chmodXSync,De as coerceVersion,v as commandExists,y as commandExistsSync,I as compressDirectory,L as copyFile,R as copyFileSync,z as copyFiles,B as copyFilesSync,n as createDirectory,r as createDirectorySync,Oe as deriveNewSemverVersion,pe as doesPackageMatch,e as exists,t as existsSync,i as extractFileFromTar,a as extractFileFromTarGzip,be as formatNodeOptions,xe as getFormattedNodeOptionsWithoutInspect,Z as getNodeModulesPaths,me as getPackageInfo,he as getPackageListing,ge as getPackageManager,V as getParentPath,Se as getParsedNodeOptionsWithoutInspect,W as getProjectRoot,Ce as getRegistry,Q as getResolutionCombinations,$ as getResolutionPaths,G as getWorkspaceRoot,ee as importModule,se as install,b as isDirectory,x as isDirectorySymlink,m as isExecutable,h as isExecutableSync,S as isFile,C as isFileSymlink,_e as isPackageExists,ve as isPackageListed,K as isProjectRoot,ke as isRange,Ae as isRelativeVersionKeyword,je as isSemver,Me as isValidRange,Ne as isValidSemver,Pe as isValidVersion,q as isWorkspaceRoot,g as isWritable,_ as isWritableSync,w as list,T as listDirectories,E as listDirectoriesSync,D as listFiles,O as listFilesSync,k as listSync,ye as loadPackageJson,Ve as loadTsConfig,ce as packageExists,Fe as parseVersion,A as readFile,c as readFileBuffer,l as readFileBufferSync,j as readFileIfExisting,M as readFileIfExistingSync,N as readFileSync,le as readJsonFile,ue as readJsonFileSync,Le as readTomlFile,Re as readTomlFileSync,He as readYamlFile,Ue as readYamlFileSync,J as relativeToProjectRoot,Y as relativeToWorkspaceRoot,o as removeDirectory,s as removeDirectorySync,Te as removeFile,Ee as removeFileSync,te as resolve,ne as resolvePackage,re as resolvePackageSync,ie as resolveSafe,ae as resolveSafeSync,oe as resolveSync,Ie as satisfiesVersion,we as tokenizeArgs,P as writeFile,u as writeFileBuffer,d as writeFileBufferSync,F as writeFileSync,de as writeJsonFile,fe as writeJsonFileSync,ze as writeTomlFile,Be as writeTomlFileSync};
1
+ import { exists, existsSync } from "./exists.mjs";
2
+ import { createDirectory, createDirectorySync, extractFileFromTar, extractFileFromTarGzip, removeDirectory, removeDirectorySync } from "./helpers.mjs";
3
+ import { readFileBuffer, readFileBufferSync, writeFileBuffer, writeFileBufferSync } from "./buffer.mjs";
4
+ import { chmodX, chmodXSync, isExecutable, isExecutableSync, isWritable, isWritableSync } from "./chmod-x.mjs";
5
+ import { commandExists, commandExistsSync } from "./command-exists.mjs";
6
+ import { isDirectory, isDirectorySymlink, isFile, isFileSymlink } from "./is-file.mjs";
7
+ import { list, listDirectories, listDirectoriesSync, listFiles, listFilesSync, listSync } from "./list-files.mjs";
8
+ import { readFile, readFileIfExisting, readFileIfExistingSync, readFileSync } from "./read-file.mjs";
9
+ import { writeFile, writeFileSync } from "./write-file.mjs";
10
+ import { compressDirectory } from "./compress.mjs";
11
+ import { copyFile, copyFileSync, copyFiles, copyFilesSync } from "./copy-file.mjs";
12
+ import { getParentPath } from "./get-parent-path.mjs";
13
+ import { PROJECT_ROOT_CONTENT, WORKSPACE_ROOT_CONTENT, getProjectRoot, getWorkspaceRoot, isProjectRoot, isWorkspaceRoot, relativeToProjectRoot, relativeToWorkspaceRoot } from "./get-workspace-root.mjs";
14
+ import { DEFAULT_EXTENSIONS, getNodeModulesPaths, getResolutionCombinations, getResolutionPaths, importModule, resolve, resolvePackage, resolvePackageSync, resolveSafe, resolveSafeSync, resolveSync } from "./resolve.mjs";
15
+ import { install, packageExists } from "./install.mjs";
16
+ import { readJsonFile, readJsonFileSync, writeJsonFile, writeJsonFileSync } from "./json.mjs";
17
+ import { doesPackageMatch, getPackageInfo, getPackageListing, getPackageManager, isPackageExists, isPackageListed, loadPackageJson } from "./package-fns.mjs";
18
+ import { formatNodeOptions, getFormattedNodeOptionsWithoutInspect, getParsedNodeOptionsWithoutInspect, getRegistry, tokenizeArgs } from "./registry.mjs";
19
+ import { removeFile, removeFileSync } from "./remove-file.mjs";
20
+ import { coerceVersion, deriveNewSemverVersion, isRange, isRelativeVersionKeyword, isSemver, isValidRange, isValidSemver, isValidVersion, parseVersion, satisfiesVersion } from "./semver-fns.mjs";
21
+ import { readTomlFile, readTomlFileSync, writeTomlFile, writeTomlFileSync } from "./toml.mjs";
22
+ import { loadTsConfig } from "./tsconfig.mjs";
23
+ import { readYamlFile, readYamlFileSync } from "./yaml.mjs";
24
+
25
+ export { DEFAULT_EXTENSIONS, PROJECT_ROOT_CONTENT, WORKSPACE_ROOT_CONTENT, chmodX, chmodXSync, coerceVersion, commandExists, commandExistsSync, compressDirectory, copyFile, copyFileSync, copyFiles, copyFilesSync, createDirectory, createDirectorySync, deriveNewSemverVersion, doesPackageMatch, exists, existsSync, extractFileFromTar, extractFileFromTarGzip, formatNodeOptions, getFormattedNodeOptionsWithoutInspect, getNodeModulesPaths, getPackageInfo, getPackageListing, getPackageManager, getParentPath, getParsedNodeOptionsWithoutInspect, getProjectRoot, getRegistry, getResolutionCombinations, getResolutionPaths, getWorkspaceRoot, importModule, install, isDirectory, isDirectorySymlink, isExecutable, isExecutableSync, isFile, isFileSymlink, isPackageExists, isPackageListed, isProjectRoot, isRange, isRelativeVersionKeyword, isSemver, isValidRange, isValidSemver, isValidVersion, isWorkspaceRoot, isWritable, isWritableSync, list, listDirectories, listDirectoriesSync, listFiles, listFilesSync, listSync, loadPackageJson, loadTsConfig, packageExists, parseVersion, readFile, readFileBuffer, readFileBufferSync, readFileIfExisting, readFileIfExistingSync, readFileSync, readJsonFile, readJsonFileSync, readTomlFile, readTomlFileSync, readYamlFile, readYamlFileSync, relativeToProjectRoot, relativeToWorkspaceRoot, removeDirectory, removeDirectorySync, removeFile, removeFileSync, resolve, resolvePackage, resolvePackageSync, resolveSafe, resolveSafeSync, resolveSync, satisfiesVersion, tokenizeArgs, writeFile, writeFileBuffer, writeFileBufferSync, writeFileSync, writeJsonFile, writeJsonFileSync, writeTomlFile, writeTomlFileSync };
package/dist/install.cjs CHANGED
@@ -1 +1,35 @@
1
- const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./path/src/cwd.cjs`),n=require(`./resolve.cjs`);let r=require(`@antfu/install-pkg`);require(`tinyexec`);async function i(e,t){return(0,r.installPackage)(e,t)}const a=async(e,r)=>{let a=await n.resolve(r?.cwd||t.cwd());try{await n.resolve(e,{paths:[a]})}catch{await i(e,r)}};exports.install=i,exports.packageExists=a;
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ const require_cwd = require('./path/src/cwd.cjs');
3
+ const require_resolve = require('./resolve.cjs');
4
+ let __antfu_install_pkg = require("@antfu/install-pkg");
5
+ require("tinyexec");
6
+
7
+ //#region src/install.ts
8
+ /**
9
+ * Install a specific or list of packages
10
+ *
11
+ * @param nameOrNames - The name or names of packages to install
12
+ * @param options - The options to use when installing the package
13
+ * @returns The result of the command or an exception
14
+ */
15
+ async function install(nameOrNames, options) {
16
+ return (0, __antfu_install_pkg.installPackage)(nameOrNames, options);
17
+ }
18
+ /**
19
+ * Check if a package exists and install it if it does not
20
+ *
21
+ * @param name - The name of the package to check
22
+ * @param options - The options to use when installing the package
23
+ */
24
+ const packageExists = async (name, options) => {
25
+ const resolvePath = await require_resolve.resolve(options?.cwd || require_cwd.cwd());
26
+ try {
27
+ await require_resolve.resolve(name, { paths: [resolvePath] });
28
+ } catch {
29
+ await install(name, options);
30
+ }
31
+ };
32
+
33
+ //#endregion
34
+ exports.install = install;
35
+ exports.packageExists = packageExists;
package/dist/install.mjs CHANGED
@@ -1,2 +1,34 @@
1
- import{cwd as e}from"./path/src/cwd.mjs";import{resolve as t}from"./resolve.mjs";import{installPackage as n}from"@antfu/install-pkg";import"tinyexec";async function r(e,t){return n(e,t)}const i=async(n,i)=>{let a=await t(i?.cwd||e());try{await t(n,{paths:[a]})}catch{await r(n,i)}};export{r as install,i as packageExists};
1
+ import { cwd } from "./path/src/cwd.mjs";
2
+ import { resolve } from "./resolve.mjs";
3
+ import { installPackage } from "@antfu/install-pkg";
4
+ import "tinyexec";
5
+
6
+ //#region src/install.ts
7
+ /**
8
+ * Install a specific or list of packages
9
+ *
10
+ * @param nameOrNames - The name or names of packages to install
11
+ * @param options - The options to use when installing the package
12
+ * @returns The result of the command or an exception
13
+ */
14
+ async function install(nameOrNames, options) {
15
+ return installPackage(nameOrNames, options);
16
+ }
17
+ /**
18
+ * Check if a package exists and install it if it does not
19
+ *
20
+ * @param name - The name of the package to check
21
+ * @param options - The options to use when installing the package
22
+ */
23
+ const packageExists = async (name, options) => {
24
+ const resolvePath = await resolve(options?.cwd || cwd());
25
+ try {
26
+ await resolve(name, { paths: [resolvePath] });
27
+ } catch {
28
+ await install(name, options);
29
+ }
30
+ };
31
+
32
+ //#endregion
33
+ export { install, packageExists };
2
34
  //# sourceMappingURL=install.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"install.mjs","names":[],"sources":["../src/install.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { InstallPackageOptions } from \"@antfu/install-pkg\";\nimport { installPackage } from \"@antfu/install-pkg\";\nimport { cwd } from \"@stryke/path/cwd\";\nimport \"tinyexec\";\nimport { resolve } from \"./resolve\";\n\n/**\n * Install a specific package\n *\n * @param name - The name of the package to install\n * @param options - The options to use when installing the package\n */\nexport async function install(\n name: string,\n options?: InstallPackageOptions\n): Promise<ReturnType<typeof installPackage>>;\n\n/**\n * Install a list of packages\n *\n * @param names - The list of package names to install\n * @param options - The options to use when installing the package\n */\nexport async function install(\n names: string[],\n options?: InstallPackageOptions\n): Promise<ReturnType<typeof installPackage>>;\n\n/**\n * Install a specific or list of packages\n *\n * @param nameOrNames - The name or names of packages to install\n * @param options - The options to use when installing the package\n * @returns The result of the command or an exception\n */\nexport async function install(\n nameOrNames: string | string[],\n options?: InstallPackageOptions\n): Promise<ReturnType<typeof installPackage>> {\n return installPackage(nameOrNames, options);\n}\n\n/**\n * Check if a package exists and install it if it does not\n *\n * @param name - The name of the package to check\n * @param options - The options to use when installing the package\n */\nexport const packageExists = async (\n name: string,\n options?: InstallPackageOptions\n) => {\n const resolvePath = await resolve(options?.cwd || cwd());\n try {\n await resolve(name, { paths: [resolvePath] });\n } catch {\n await install(name, options);\n }\n};\n"],"mappings":"sJAqDA,eAAsB,EACpB,EACA,EAC4C,CAC5C,OAAO,EAAe,EAAa,EAAQ,CAS7C,MAAa,EAAgB,MAC3B,EACA,IACG,CACH,IAAM,EAAc,MAAM,EAAQ,GAAS,KAAO,GAAK,CAAC,CACxD,GAAI,CACF,MAAM,EAAQ,EAAM,CAAE,MAAO,CAAC,EAAY,CAAE,CAAC,MACvC,CACN,MAAM,EAAQ,EAAM,EAAQ"}
1
+ {"version":3,"file":"install.mjs","names":[],"sources":["../src/install.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { InstallPackageOptions } from \"@antfu/install-pkg\";\nimport { installPackage } from \"@antfu/install-pkg\";\nimport { cwd } from \"@stryke/path/cwd\";\nimport \"tinyexec\";\nimport { resolve } from \"./resolve\";\n\n/**\n * Install a specific package\n *\n * @param name - The name of the package to install\n * @param options - The options to use when installing the package\n */\nexport async function install(\n name: string,\n options?: InstallPackageOptions\n): Promise<ReturnType<typeof installPackage>>;\n\n/**\n * Install a list of packages\n *\n * @param names - The list of package names to install\n * @param options - The options to use when installing the package\n */\nexport async function install(\n names: string[],\n options?: InstallPackageOptions\n): Promise<ReturnType<typeof installPackage>>;\n\n/**\n * Install a specific or list of packages\n *\n * @param nameOrNames - The name or names of packages to install\n * @param options - The options to use when installing the package\n * @returns The result of the command or an exception\n */\nexport async function install(\n nameOrNames: string | string[],\n options?: InstallPackageOptions\n): Promise<ReturnType<typeof installPackage>> {\n return installPackage(nameOrNames, options);\n}\n\n/**\n * Check if a package exists and install it if it does not\n *\n * @param name - The name of the package to check\n * @param options - The options to use when installing the package\n */\nexport const packageExists = async (\n name: string,\n options?: InstallPackageOptions\n) => {\n const resolvePath = await resolve(options?.cwd || cwd());\n try {\n await resolve(name, { paths: [resolvePath] });\n } catch {\n await install(name, options);\n }\n};\n"],"mappings":";;;;;;;;;;;;;AAqDA,eAAsB,QACpB,aACA,SAC4C;AAC5C,QAAO,eAAe,aAAa,QAAQ;;;;;;;;AAS7C,MAAa,gBAAgB,OAC3B,MACA,YACG;CACH,MAAM,cAAc,MAAM,QAAQ,SAAS,OAAO,KAAK,CAAC;AACxD,KAAI;AACF,QAAM,QAAQ,MAAM,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;SACvC;AACN,QAAM,QAAQ,MAAM,QAAQ"}
package/dist/is-file.cjs CHANGED
@@ -1 +1,51 @@
1
- const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./path/src/join-paths.cjs`);let n=require(`node:fs`);function r(e,r){return!!(0,n.statSync)(r?t.joinPaths(r,e):e,{throwIfNoEntry:!1})?.isFile()}function i(e,r){return!!(0,n.statSync)(r?t.joinPaths(r,e):e,{throwIfNoEntry:!1})?.isDirectory()}const a=(e,r)=>!!(0,n.lstatSync)(r?t.joinPaths(r,e):e,{throwIfNoEntry:!1})?.isFile(),o=(e,r)=>!!(0,n.lstatSync)(r?t.joinPaths(r,e):e,{throwIfNoEntry:!1})?.isDirectory();exports.isDirectory=i,exports.isDirectorySymlink=o,exports.isFile=r,exports.isFileSymlink=a;
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ const require_join_paths = require('./path/src/join-paths.cjs');
3
+ let node_fs = require("node:fs");
4
+
5
+ //#region src/is-file.ts
6
+ /**
7
+ * Check if the given path is a file.
8
+ *
9
+ * @param path - The location to check
10
+ * @param additionalPath - An optional additional path to add to the start of the path
11
+ * @returns An indicator specifying if the path is a file
12
+ */
13
+ function isFile(path, additionalPath) {
14
+ return Boolean((0, node_fs.statSync)(additionalPath ? require_join_paths.joinPaths(additionalPath, path) : path, { throwIfNoEntry: false })?.isFile());
15
+ }
16
+ /**
17
+ * Check if the given path is a directory.
18
+ *
19
+ * @param path - The location to check
20
+ * @param additionalPath - An optional additional path to add to the start of the path
21
+ * @returns An indicator specifying if the path is a directory
22
+ */
23
+ function isDirectory(path, additionalPath) {
24
+ return Boolean((0, node_fs.statSync)(additionalPath ? require_join_paths.joinPaths(additionalPath, path) : path, { throwIfNoEntry: false })?.isDirectory());
25
+ }
26
+ /**
27
+ * Check if the given path is a file . Does not dereference symbolic links.
28
+ *
29
+ * @param path - The location to check
30
+ * @param additionalPath - An optional additional path to add to the start of the path
31
+ * @returns An indicator specifying if the path is a file
32
+ */
33
+ const isFileSymlink = (path, additionalPath) => {
34
+ return Boolean((0, node_fs.lstatSync)(additionalPath ? require_join_paths.joinPaths(additionalPath, path) : path, { throwIfNoEntry: false })?.isFile());
35
+ };
36
+ /**
37
+ * Check if the given path is a directory. Does not dereference symbolic links.
38
+ *
39
+ * @param path - The location to check
40
+ * @param additionalPath - An optional additional path to add to the start of the path
41
+ * @returns An indicator specifying if the path is a directory
42
+ */
43
+ const isDirectorySymlink = (path, additionalPath) => {
44
+ return Boolean((0, node_fs.lstatSync)(additionalPath ? require_join_paths.joinPaths(additionalPath, path) : path, { throwIfNoEntry: false })?.isDirectory());
45
+ };
46
+
47
+ //#endregion
48
+ exports.isDirectory = isDirectory;
49
+ exports.isDirectorySymlink = isDirectorySymlink;
50
+ exports.isFile = isFile;
51
+ exports.isFileSymlink = isFileSymlink;
package/dist/is-file.mjs CHANGED
@@ -1,2 +1,48 @@
1
- import{joinPaths as e}from"./path/src/join-paths.mjs";import{lstatSync as t,statSync as n}from"node:fs";function r(t,r){return!!n(r?e(r,t):t,{throwIfNoEntry:!1})?.isFile()}function i(t,r){return!!n(r?e(r,t):t,{throwIfNoEntry:!1})?.isDirectory()}const a=(n,r)=>!!t(r?e(r,n):n,{throwIfNoEntry:!1})?.isFile(),o=(n,r)=>!!t(r?e(r,n):n,{throwIfNoEntry:!1})?.isDirectory();export{i as isDirectory,o as isDirectorySymlink,r as isFile,a as isFileSymlink};
1
+ import { joinPaths } from "./path/src/join-paths.mjs";
2
+ import { lstatSync, statSync } from "node:fs";
3
+
4
+ //#region src/is-file.ts
5
+ /**
6
+ * Check if the given path is a file.
7
+ *
8
+ * @param path - The location to check
9
+ * @param additionalPath - An optional additional path to add to the start of the path
10
+ * @returns An indicator specifying if the path is a file
11
+ */
12
+ function isFile(path, additionalPath) {
13
+ return Boolean(statSync(additionalPath ? joinPaths(additionalPath, path) : path, { throwIfNoEntry: false })?.isFile());
14
+ }
15
+ /**
16
+ * Check if the given path is a directory.
17
+ *
18
+ * @param path - The location to check
19
+ * @param additionalPath - An optional additional path to add to the start of the path
20
+ * @returns An indicator specifying if the path is a directory
21
+ */
22
+ function isDirectory(path, additionalPath) {
23
+ return Boolean(statSync(additionalPath ? joinPaths(additionalPath, path) : path, { throwIfNoEntry: false })?.isDirectory());
24
+ }
25
+ /**
26
+ * Check if the given path is a file . Does not dereference symbolic links.
27
+ *
28
+ * @param path - The location to check
29
+ * @param additionalPath - An optional additional path to add to the start of the path
30
+ * @returns An indicator specifying if the path is a file
31
+ */
32
+ const isFileSymlink = (path, additionalPath) => {
33
+ return Boolean(lstatSync(additionalPath ? joinPaths(additionalPath, path) : path, { throwIfNoEntry: false })?.isFile());
34
+ };
35
+ /**
36
+ * Check if the given path is a directory. Does not dereference symbolic links.
37
+ *
38
+ * @param path - The location to check
39
+ * @param additionalPath - An optional additional path to add to the start of the path
40
+ * @returns An indicator specifying if the path is a directory
41
+ */
42
+ const isDirectorySymlink = (path, additionalPath) => {
43
+ return Boolean(lstatSync(additionalPath ? joinPaths(additionalPath, path) : path, { throwIfNoEntry: false })?.isDirectory());
44
+ };
45
+
46
+ //#endregion
47
+ export { isDirectory, isDirectorySymlink, isFile, isFileSymlink };
2
48
  //# sourceMappingURL=is-file.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-file.mjs","names":[],"sources":["../src/is-file.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { lstatSync, statSync } from \"node:fs\";\n\n/**\n * Check if the given path is a file.\n *\n * @param path - The location to check\n * @param additionalPath - An optional additional path to add to the start of the path\n * @returns An indicator specifying if the path is a file\n */\nexport function isFile(path: string, additionalPath?: string): boolean {\n return Boolean(\n statSync(additionalPath ? joinPaths(additionalPath, path) : path, {\n throwIfNoEntry: false\n })?.isFile()\n );\n}\n\n/**\n * Check if the given path is a directory.\n *\n * @param path - The location to check\n * @param additionalPath - An optional additional path to add to the start of the path\n * @returns An indicator specifying if the path is a directory\n */\nexport function isDirectory(path: string, additionalPath?: string): boolean {\n return Boolean(\n statSync(additionalPath ? joinPaths(additionalPath, path) : path, {\n throwIfNoEntry: false\n })?.isDirectory()\n );\n}\n\n/**\n * Check if the given path is a file . Does not dereference symbolic links.\n *\n * @param path - The location to check\n * @param additionalPath - An optional additional path to add to the start of the path\n * @returns An indicator specifying if the path is a file\n */\nexport const isFileSymlink = (\n path: string,\n additionalPath?: string\n): boolean => {\n return Boolean(\n lstatSync(additionalPath ? joinPaths(additionalPath, path) : path, {\n throwIfNoEntry: false\n })?.isFile()\n );\n};\n\n/**\n * Check if the given path is a directory. Does not dereference symbolic links.\n *\n * @param path - The location to check\n * @param additionalPath - An optional additional path to add to the start of the path\n * @returns An indicator specifying if the path is a directory\n */\nexport const isDirectorySymlink = (\n path: string,\n additionalPath?: string\n): boolean => {\n return Boolean(\n lstatSync(additionalPath ? joinPaths(additionalPath, path) : path, {\n throwIfNoEntry: false\n })?.isDirectory()\n );\n};\n"],"mappings":"wGA4BA,SAAgB,EAAO,EAAc,EAAkC,CACrE,MAAO,EACL,EAAS,EAAiB,EAAU,EAAgB,EAAK,CAAG,EAAM,CAChE,eAAgB,GACjB,CAAC,EAAE,QAAQ,CAWhB,SAAgB,EAAY,EAAc,EAAkC,CAC1E,MAAO,EACL,EAAS,EAAiB,EAAU,EAAgB,EAAK,CAAG,EAAM,CAChE,eAAgB,GACjB,CAAC,EAAE,aAAa,CAWrB,MAAa,GACX,EACA,IAEO,EACL,EAAU,EAAiB,EAAU,EAAgB,EAAK,CAAG,EAAM,CACjE,eAAgB,GACjB,CAAC,EAAE,QAAQ,CAWH,GACX,EACA,IAEO,EACL,EAAU,EAAiB,EAAU,EAAgB,EAAK,CAAG,EAAM,CACjE,eAAgB,GACjB,CAAC,EAAE,aAAa"}
1
+ {"version":3,"file":"is-file.mjs","names":[],"sources":["../src/is-file.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { lstatSync, statSync } from \"node:fs\";\n\n/**\n * Check if the given path is a file.\n *\n * @param path - The location to check\n * @param additionalPath - An optional additional path to add to the start of the path\n * @returns An indicator specifying if the path is a file\n */\nexport function isFile(path: string, additionalPath?: string): boolean {\n return Boolean(\n statSync(additionalPath ? joinPaths(additionalPath, path) : path, {\n throwIfNoEntry: false\n })?.isFile()\n );\n}\n\n/**\n * Check if the given path is a directory.\n *\n * @param path - The location to check\n * @param additionalPath - An optional additional path to add to the start of the path\n * @returns An indicator specifying if the path is a directory\n */\nexport function isDirectory(path: string, additionalPath?: string): boolean {\n return Boolean(\n statSync(additionalPath ? joinPaths(additionalPath, path) : path, {\n throwIfNoEntry: false\n })?.isDirectory()\n );\n}\n\n/**\n * Check if the given path is a file . Does not dereference symbolic links.\n *\n * @param path - The location to check\n * @param additionalPath - An optional additional path to add to the start of the path\n * @returns An indicator specifying if the path is a file\n */\nexport const isFileSymlink = (\n path: string,\n additionalPath?: string\n): boolean => {\n return Boolean(\n lstatSync(additionalPath ? joinPaths(additionalPath, path) : path, {\n throwIfNoEntry: false\n })?.isFile()\n );\n};\n\n/**\n * Check if the given path is a directory. Does not dereference symbolic links.\n *\n * @param path - The location to check\n * @param additionalPath - An optional additional path to add to the start of the path\n * @returns An indicator specifying if the path is a directory\n */\nexport const isDirectorySymlink = (\n path: string,\n additionalPath?: string\n): boolean => {\n return Boolean(\n lstatSync(additionalPath ? joinPaths(additionalPath, path) : path, {\n throwIfNoEntry: false\n })?.isDirectory()\n );\n};\n"],"mappings":";;;;;;;;;;;AA4BA,SAAgB,OAAO,MAAc,gBAAkC;AACrE,QAAO,QACL,SAAS,iBAAiB,UAAU,gBAAgB,KAAK,GAAG,MAAM,EAChE,gBAAgB,OACjB,CAAC,EAAE,QAAQ,CACb;;;;;;;;;AAUH,SAAgB,YAAY,MAAc,gBAAkC;AAC1E,QAAO,QACL,SAAS,iBAAiB,UAAU,gBAAgB,KAAK,GAAG,MAAM,EAChE,gBAAgB,OACjB,CAAC,EAAE,aAAa,CAClB;;;;;;;;;AAUH,MAAa,iBACX,MACA,mBACY;AACZ,QAAO,QACL,UAAU,iBAAiB,UAAU,gBAAgB,KAAK,GAAG,MAAM,EACjE,gBAAgB,OACjB,CAAC,EAAE,QAAQ,CACb;;;;;;;;;AAUH,MAAa,sBACX,MACA,mBACY;AACZ,QAAO,QACL,UAAU,iBAAiB,UAAU,gBAAgB,KAAK,GAAG,MAAM,EACjE,gBAAgB,OACjB,CAAC,EAAE,aAAa,CAClB"}
@@ -1 +1,117 @@
1
- const e=require(`../../_virtual/rolldown_runtime.cjs`),t=require(`../../type-checks/src/is-string.cjs`),n=require(`../../type-checks/src/is-object.cjs`),r=require(`./utils/parse.cjs`),i=require(`./utils/parse-error.cjs`),a=require(`./utils/stringify.cjs`);let o=require(`node:buffer`),s=require(`jsonc-parser`),c=require(`superjson`);c=e.__toESM(c);var l=class e extends c.default{static#e;static get instance(){return e.#e||=new e,e.#e}static deserialize(t){return e.instance.deserialize(t)}static serialize(t){return e.instance.serialize(t)}static parse(e){return r.parse(e)}static stringify(t,n){let r=e.instance.customTransformerRegistry.findApplicable(t),i=t;return r&&r.isApplicable(t)&&(i=r.serialize(i)),a.stringify(i)}static parseJson(t,n){try{if(n?.expectComments===!1)return e.instance.parse(t)}catch{}let r=[],a=(0,s.parse)(t,r,{allowTrailingComma:!0,...n});if(r.length>0&&r[0])throw Error(i.formatParseError(t,r[0]));return a}static register(t,n,r,i){e.instance.registerCustom({isApplicable:i,serialize:n,deserialize:r},t)}static registerClass(r,i){e.instance.registerClass(r,{identifier:t.isString(i)?i:i?.identifier||r.name,allowProps:i&&n.isObject(i)&&i?.allowProps&&Array.isArray(i.allowProps)?i.allowProps:[`__typename`]})}constructor(){super({dedupe:!0})}};l.instance.registerCustom({isApplicable:e=>o.Buffer.isBuffer(e),serialize:e=>e.toString(`base64`),deserialize:e=>o.Buffer.from(e,`base64`)},`Bytes`),exports.StormJSON=l;
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+ const require_is_string = require('../../type-checks/src/is-string.cjs');
3
+ const require_is_object = require('../../type-checks/src/is-object.cjs');
4
+ const require_parse = require('./utils/parse.cjs');
5
+ const require_parse_error = require('./utils/parse-error.cjs');
6
+ const require_stringify = require('./utils/stringify.cjs');
7
+ let node_buffer = require("node:buffer");
8
+ let jsonc_parser = require("jsonc-parser");
9
+ let superjson = require("superjson");
10
+ superjson = require_rolldown_runtime.__toESM(superjson);
11
+
12
+ //#region ../json/src/storm-json.ts
13
+ /**
14
+ * A static JSON parser class used by Storm Software to serialize and deserialize JSON data
15
+ *
16
+ * @remarks
17
+ * This class uses the [SuperJSON](https://github.com/blitz-js/superjson) library under the hood.
18
+ */
19
+ var StormJSON = class StormJSON extends superjson.default {
20
+ static #instance;
21
+ static get instance() {
22
+ if (!StormJSON.#instance) StormJSON.#instance = new StormJSON();
23
+ return StormJSON.#instance;
24
+ }
25
+ /**
26
+ * Deserialize the given value with superjson using the given metadata
27
+ */
28
+ static deserialize(payload) {
29
+ return StormJSON.instance.deserialize(payload);
30
+ }
31
+ /**
32
+ * Serialize the given value with superjson
33
+ */
34
+ static serialize(object) {
35
+ return StormJSON.instance.serialize(object);
36
+ }
37
+ /**
38
+ * Parse the given string value with superjson using the given metadata
39
+ *
40
+ * @param value - The string value to parse
41
+ * @returns The parsed data
42
+ */
43
+ static parse(value) {
44
+ return require_parse.parse(value);
45
+ }
46
+ /**
47
+ * Serializes the given data to a JSON string.
48
+ * By default the JSON string is formatted with a 2 space indentation to be easy readable.
49
+ *
50
+ * @param value - Object which should be serialized to JSON
51
+ * @param _options - JSON serialize options
52
+ * @returns the formatted JSON representation of the object
53
+ */
54
+ static stringify(value, _options) {
55
+ const customTransformer = StormJSON.instance.customTransformerRegistry.findApplicable(value);
56
+ let result = value;
57
+ if (customTransformer && customTransformer.isApplicable(value)) result = customTransformer.serialize(result);
58
+ return require_stringify.stringify(result);
59
+ }
60
+ /**
61
+ * Parses the given JSON string and returns the object the JSON content represents.
62
+ * By default javascript-style comments and trailing commas are allowed.
63
+ *
64
+ * @param strData - JSON content as string
65
+ * @param options - JSON parse options
66
+ * @returns Object the JSON content represents
67
+ */
68
+ static parseJson(strData, options) {
69
+ try {
70
+ if (options?.expectComments === false) return StormJSON.instance.parse(strData);
71
+ } catch {}
72
+ const errors = [];
73
+ const result = (0, jsonc_parser.parse)(strData, errors, {
74
+ allowTrailingComma: true,
75
+ ...options
76
+ });
77
+ if (errors.length > 0 && errors[0]) throw new Error(require_parse_error.formatParseError(strData, errors[0]));
78
+ return result;
79
+ }
80
+ /**
81
+ * Register a custom schema with superjson
82
+ *
83
+ * @param name - The name of the schema
84
+ * @param serialize - The function to serialize the schema
85
+ * @param deserialize - The function to deserialize the schema
86
+ * @param isApplicable - The function to check if the schema is applicable
87
+ */
88
+ static register(name, serialize, deserialize, isApplicable) {
89
+ StormJSON.instance.registerCustom({
90
+ isApplicable,
91
+ serialize,
92
+ deserialize
93
+ }, name);
94
+ }
95
+ /**
96
+ * Register a class with superjson
97
+ *
98
+ * @param classConstructor - The class constructor to register
99
+ */
100
+ static registerClass(classConstructor, options) {
101
+ StormJSON.instance.registerClass(classConstructor, {
102
+ identifier: require_is_string.isString(options) ? options : options?.identifier || classConstructor.name,
103
+ allowProps: options && require_is_object.isObject(options) && options?.allowProps && Array.isArray(options.allowProps) ? options.allowProps : ["__typename"]
104
+ });
105
+ }
106
+ constructor() {
107
+ super({ dedupe: true });
108
+ }
109
+ };
110
+ StormJSON.instance.registerCustom({
111
+ isApplicable: (v) => node_buffer.Buffer.isBuffer(v),
112
+ serialize: (v) => v.toString("base64"),
113
+ deserialize: (v) => node_buffer.Buffer.from(v, "base64")
114
+ }, "Bytes");
115
+
116
+ //#endregion
117
+ exports.StormJSON = StormJSON;