@stryke/fs 0.33.32 → 0.33.34

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 (190) hide show
  1. package/CHANGELOG.md +18 -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.mjs +87 -1
  8. package/dist/chmod-x.mjs.map +1 -1
  9. package/dist/command-exists.cjs +102 -1
  10. package/dist/command-exists.mjs +100 -1
  11. package/dist/command-exists.mjs.map +1 -1
  12. package/dist/compress.cjs +29 -1
  13. package/dist/compress.mjs +28 -1
  14. package/dist/compress.mjs.map +1 -1
  15. package/dist/constants.mjs +1 -1
  16. package/dist/convert/src/array-buffer-to-string.cjs +19 -1
  17. package/dist/convert/src/array-buffer-to-string.mjs +18 -1
  18. package/dist/convert/src/array-buffer-to-string.mjs.map +1 -1
  19. package/dist/convert/src/to-array.cjs +15 -1
  20. package/dist/convert/src/to-array.mjs +14 -1
  21. package/dist/convert/src/to-array.mjs.map +1 -1
  22. package/dist/convert/src/uint8-array-to-string.cjs +15 -1
  23. package/dist/convert/src/uint8-array-to-string.mjs +15 -1
  24. package/dist/convert/src/uint8-array-to-string.mjs.map +1 -1
  25. package/dist/copy-file.cjs +87 -1
  26. package/dist/copy-file.mjs +83 -1
  27. package/dist/copy-file.mjs.map +1 -1
  28. package/dist/exists.cjs +27 -1
  29. package/dist/exists.mjs +25 -1
  30. package/dist/exists.mjs.map +1 -1
  31. package/dist/get-parent-path.cjs +35 -1
  32. package/dist/get-parent-path.mjs +34 -1
  33. package/dist/get-parent-path.mjs.map +1 -1
  34. package/dist/get-workspace-root.cjs +158 -1
  35. package/dist/get-workspace-root.mjs +150 -1
  36. package/dist/get-workspace-root.mjs.map +1 -1
  37. package/dist/helpers/src/get-unique.cjs +14 -1
  38. package/dist/helpers/src/get-unique.mjs +13 -1
  39. package/dist/helpers/src/get-unique.mjs.map +1 -1
  40. package/dist/helpers.cjs +83 -1
  41. package/dist/helpers.mjs +77 -1
  42. package/dist/helpers.mjs.map +1 -1
  43. package/dist/index.cjs +122 -1
  44. package/dist/index.mjs +25 -1
  45. package/dist/install.cjs +35 -1
  46. package/dist/install.mjs +33 -1
  47. package/dist/install.mjs.map +1 -1
  48. package/dist/is-file.cjs +51 -1
  49. package/dist/is-file.mjs +47 -1
  50. package/dist/is-file.mjs.map +1 -1
  51. package/dist/json/src/storm-json.cjs +117 -1
  52. package/dist/json/src/storm-json.mjs +115 -1
  53. package/dist/json/src/storm-json.mjs.map +1 -1
  54. package/dist/json/src/utils/code-frames.cjs +77 -3
  55. package/dist/json/src/utils/code-frames.mjs +76 -3
  56. package/dist/json/src/utils/code-frames.mjs.map +1 -1
  57. package/dist/json/src/utils/parse-error.cjs +34 -1
  58. package/dist/json/src/utils/parse-error.mjs +33 -1
  59. package/dist/json/src/utils/parse-error.mjs.map +1 -1
  60. package/dist/json/src/utils/parse.cjs +45 -1
  61. package/dist/json/src/utils/parse.mjs +45 -1
  62. package/dist/json/src/utils/parse.mjs.map +1 -1
  63. package/dist/json/src/utils/stringify.cjs +67 -1
  64. package/dist/json/src/utils/stringify.mjs +67 -1
  65. package/dist/json/src/utils/stringify.mjs.map +1 -1
  66. package/dist/json/src/utils/strip-comments.cjs +86 -4
  67. package/dist/json/src/utils/strip-comments.mjs +86 -4
  68. package/dist/json/src/utils/strip-comments.mjs.map +1 -1
  69. package/dist/json.cjs +74 -1
  70. package/dist/json.mjs +71 -1
  71. package/dist/json.mjs.map +1 -1
  72. package/dist/list-files.cjs +86 -1
  73. package/dist/list-files.mjs +79 -1
  74. package/dist/list-files.mjs.map +1 -1
  75. package/dist/package-fns.cjs +148 -1
  76. package/dist/package-fns.mjs +141 -1
  77. package/dist/package-fns.mjs.map +1 -1
  78. package/dist/path/src/append.cjs +57 -1
  79. package/dist/path/src/append.mjs +56 -1
  80. package/dist/path/src/append.mjs.map +1 -1
  81. package/dist/path/src/correct-path.cjs +138 -1
  82. package/dist/path/src/correct-path.mjs +134 -1
  83. package/dist/path/src/correct-path.mjs.map +1 -1
  84. package/dist/path/src/cwd.cjs +17 -1
  85. package/dist/path/src/cwd.mjs +16 -1
  86. package/dist/path/src/cwd.mjs.map +1 -1
  87. package/dist/path/src/file-path-fns.cjs +169 -1
  88. package/dist/path/src/file-path-fns.mjs +164 -1
  89. package/dist/path/src/file-path-fns.mjs.map +1 -1
  90. package/dist/path/src/is-parent-path.cjs +32 -1
  91. package/dist/path/src/is-parent-path.mjs +32 -1
  92. package/dist/path/src/is-parent-path.mjs.map +1 -1
  93. package/dist/path/src/is-root-dir.cjs +14 -1
  94. package/dist/path/src/is-root-dir.mjs +13 -1
  95. package/dist/path/src/is-root-dir.mjs.map +1 -1
  96. package/dist/path/src/is-type.cjs +68 -1
  97. package/dist/path/src/is-type.mjs +66 -1
  98. package/dist/path/src/is-type.mjs.map +1 -1
  99. package/dist/path/src/join-paths.cjs +106 -1
  100. package/dist/path/src/join-paths.mjs +106 -1
  101. package/dist/path/src/join-paths.mjs.map +1 -1
  102. package/dist/path/src/regex.cjs +18 -1
  103. package/dist/path/src/regex.mjs +11 -1
  104. package/dist/path/src/regex.mjs.map +1 -1
  105. package/dist/path/src/replace.cjs +24 -1
  106. package/dist/path/src/replace.mjs +24 -1
  107. package/dist/path/src/replace.mjs.map +1 -1
  108. package/dist/path/src/resolve-parent-path.cjs +18 -1
  109. package/dist/path/src/resolve-parent-path.mjs +18 -1
  110. package/dist/path/src/resolve-parent-path.mjs.map +1 -1
  111. package/dist/path/src/slash.cjs +15 -1
  112. package/dist/path/src/slash.mjs +14 -1
  113. package/dist/path/src/slash.mjs.map +1 -1
  114. package/dist/read-file.cjs +47 -1
  115. package/dist/read-file.mjs +43 -1
  116. package/dist/read-file.mjs.map +1 -1
  117. package/dist/registry.cjs +142 -1
  118. package/dist/registry.mjs +137 -1
  119. package/dist/registry.mjs.map +1 -1
  120. package/dist/remove-file.cjs +27 -1
  121. package/dist/remove-file.mjs +25 -1
  122. package/dist/remove-file.mjs.map +1 -1
  123. package/dist/resolve.cjs +228 -3
  124. package/dist/resolve.mjs +217 -3
  125. package/dist/resolve.mjs.map +1 -1
  126. package/dist/semver-fns.cjs +129 -1
  127. package/dist/semver-fns.mjs +119 -1
  128. package/dist/semver-fns.mjs.map +1 -1
  129. package/dist/string-format/src/package.cjs +92 -1
  130. package/dist/string-format/src/package.mjs +91 -1
  131. package/dist/string-format/src/package.mjs.map +1 -1
  132. package/dist/toml.cjs +66 -3
  133. package/dist/toml.mjs +61 -3
  134. package/dist/toml.mjs.map +1 -1
  135. package/dist/tsconfig.cjs +37 -1
  136. package/dist/tsconfig.mjs +35 -1
  137. package/dist/tsconfig.mjs.map +1 -1
  138. package/dist/type-checks/src/get-object-tag.cjs +15 -1
  139. package/dist/type-checks/src/get-object-tag.mjs +14 -1
  140. package/dist/type-checks/src/get-object-tag.mjs.map +1 -1
  141. package/dist/type-checks/src/index.cjs +14 -1
  142. package/dist/type-checks/src/index.mjs +16 -1
  143. package/dist/type-checks/src/is-buffer.cjs +12 -1
  144. package/dist/type-checks/src/is-buffer.mjs +11 -1
  145. package/dist/type-checks/src/is-buffer.mjs.map +1 -1
  146. package/dist/type-checks/src/is-collection.cjs +1 -1
  147. package/dist/type-checks/src/is-collection.mjs +3 -1
  148. package/dist/type-checks/src/is-empty.cjs +20 -1
  149. package/dist/type-checks/src/is-empty.mjs +20 -1
  150. package/dist/type-checks/src/is-empty.mjs.map +1 -1
  151. package/dist/type-checks/src/is-error.cjs +29 -1
  152. package/dist/type-checks/src/is-error.mjs +29 -1
  153. package/dist/type-checks/src/is-error.mjs.map +1 -1
  154. package/dist/type-checks/src/is-null.cjs +12 -1
  155. package/dist/type-checks/src/is-null.mjs +11 -1
  156. package/dist/type-checks/src/is-null.mjs.map +1 -1
  157. package/dist/type-checks/src/is-number.cjs +18 -1
  158. package/dist/type-checks/src/is-number.mjs +17 -1
  159. package/dist/type-checks/src/is-number.mjs.map +1 -1
  160. package/dist/type-checks/src/is-object.cjs +19 -1
  161. package/dist/type-checks/src/is-object.mjs +19 -1
  162. package/dist/type-checks/src/is-object.mjs.map +1 -1
  163. package/dist/type-checks/src/is-plain-object.cjs +64 -1
  164. package/dist/type-checks/src/is-plain-object.mjs +63 -1
  165. package/dist/type-checks/src/is-plain-object.mjs.map +1 -1
  166. package/dist/type-checks/src/is-set-string.cjs +20 -1
  167. package/dist/type-checks/src/is-set-string.mjs +20 -1
  168. package/dist/type-checks/src/is-set-string.mjs.map +1 -1
  169. package/dist/type-checks/src/is-set.cjs +19 -1
  170. package/dist/type-checks/src/is-set.mjs +19 -1
  171. package/dist/type-checks/src/is-set.mjs.map +1 -1
  172. package/dist/type-checks/src/is-string.cjs +12 -1
  173. package/dist/type-checks/src/is-string.mjs +11 -1
  174. package/dist/type-checks/src/is-string.mjs.map +1 -1
  175. package/dist/type-checks/src/is-undefined.cjs +8 -1
  176. package/dist/type-checks/src/is-undefined.mjs +7 -1
  177. package/dist/type-checks/src/is-undefined.mjs.map +1 -1
  178. package/dist/type-checks/src/type-detect.cjs +15 -1
  179. package/dist/type-checks/src/type-detect.mjs +16 -1
  180. package/dist/type-checks/src/type-detect.mjs.map +1 -1
  181. package/dist/types/src/base.cjs +6 -1
  182. package/dist/types/src/base.mjs +5 -1
  183. package/dist/types/src/base.mjs.map +1 -1
  184. package/dist/write-file.cjs +40 -1
  185. package/dist/write-file.mjs +38 -1
  186. package/dist/write-file.mjs.map +1 -1
  187. package/dist/yaml.cjs +29 -1
  188. package/dist/yaml.mjs +27 -1
  189. package/dist/yaml.mjs.map +1 -1
  190. package/package.json +6 -6
@@ -1 +1,35 @@
1
- const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./path/src/cwd.cjs`),n=require(`./path/src/join-paths.cjs`),r=require(`./path/src/resolve-parent-path.cjs`),i=require(`./is-file.cjs`),a=require(`./convert/src/to-array.cjs`);let o=require(`node:fs`);const s=(e,s=t.cwd(),c={})=>{let l=c?.ignoreCase??!0,u=c?.skipCwd??!1,d=c?.includeNameInResults??!1,f=s;u&&(f=r.resolveParentPath(s));let p=a.toArray(e);for(l&&(p=p.map(e=>e.toLowerCase()));;){let e=p.find(e=>(0,o.existsSync)(n.joinPaths(f,e)));if(e)return d||i.isDirectory(n.joinPaths(f,e))?n.joinPaths(f,e):f;let t=r.resolveParentPath(f);if(t===f)return;f=t}};exports.getParentPath=s;
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ const require_cwd = require('./path/src/cwd.cjs');
3
+ const require_join_paths = require('./path/src/join-paths.cjs');
4
+ const require_resolve_parent_path = require('./path/src/resolve-parent-path.cjs');
5
+ const require_is_file = require('./is-file.cjs');
6
+ const require_to_array = require('./convert/src/to-array.cjs');
7
+ let node_fs = require("node:fs");
8
+
9
+ //#region src/get-parent-path.ts
10
+ /**
11
+ * Get the first parent path that has a file or directory with the provided name.
12
+ *
13
+ * @param name - The name (or names) of the file to look for in the parent paths.
14
+ * @param cwd - The current working directory.
15
+ * @returns The first parent path that exists.
16
+ */
17
+ const getParentPath = (name, cwd$1 = require_cwd.cwd(), options = {}) => {
18
+ const ignoreCase = options?.ignoreCase ?? true;
19
+ const skipCwd = options?.skipCwd ?? false;
20
+ const includeNameInResults = options?.includeNameInResults ?? false;
21
+ let dir = cwd$1;
22
+ if (skipCwd) dir = require_resolve_parent_path.resolveParentPath(cwd$1);
23
+ let names = require_to_array.toArray(name);
24
+ if (ignoreCase) names = names.map((name$1) => name$1.toLowerCase());
25
+ while (true) {
26
+ const target = names.find((name$1) => (0, node_fs.existsSync)(require_join_paths.joinPaths(dir, name$1)));
27
+ if (target) return includeNameInResults || require_is_file.isDirectory(require_join_paths.joinPaths(dir, target)) ? require_join_paths.joinPaths(dir, target) : dir;
28
+ const parentDir = require_resolve_parent_path.resolveParentPath(dir);
29
+ if (parentDir === dir) return;
30
+ dir = parentDir;
31
+ }
32
+ };
33
+
34
+ //#endregion
35
+ exports.getParentPath = getParentPath;
@@ -1,2 +1,35 @@
1
- import{cwd as e}from"./path/src/cwd.mjs";import{joinPaths as t}from"./path/src/join-paths.mjs";import{resolveParentPath as n}from"./path/src/resolve-parent-path.mjs";import{isDirectory as r}from"./is-file.mjs";import{toArray as i}from"./convert/src/to-array.mjs";import{existsSync as a}from"node:fs";const o=(o,s=e(),c={})=>{let l=c?.ignoreCase??!0,u=c?.skipCwd??!1,d=c?.includeNameInResults??!1,f=s;u&&(f=n(s));let p=i(o);for(l&&(p=p.map(e=>e.toLowerCase()));;){let e=p.find(e=>a(t(f,e)));if(e)return d||r(t(f,e))?t(f,e):f;let i=n(f);if(i===f)return;f=i}};export{o as getParentPath};
1
+ import { cwd } from "./path/src/cwd.mjs";
2
+ import { joinPaths } from "./path/src/join-paths.mjs";
3
+ import { resolveParentPath } from "./path/src/resolve-parent-path.mjs";
4
+ import { isDirectory } from "./is-file.mjs";
5
+ import { toArray } from "./convert/src/to-array.mjs";
6
+ import { existsSync } from "node:fs";
7
+
8
+ //#region src/get-parent-path.ts
9
+ /**
10
+ * Get the first parent path that has a file or directory with the provided name.
11
+ *
12
+ * @param name - The name (or names) of the file to look for in the parent paths.
13
+ * @param cwd - The current working directory.
14
+ * @returns The first parent path that exists.
15
+ */
16
+ const getParentPath = (name, cwd$1 = cwd(), options = {}) => {
17
+ const ignoreCase = options?.ignoreCase ?? true;
18
+ const skipCwd = options?.skipCwd ?? false;
19
+ const includeNameInResults = options?.includeNameInResults ?? false;
20
+ let dir = cwd$1;
21
+ if (skipCwd) dir = resolveParentPath(cwd$1);
22
+ let names = toArray(name);
23
+ if (ignoreCase) names = names.map((name$1) => name$1.toLowerCase());
24
+ while (true) {
25
+ const target = names.find((name$1) => existsSync(joinPaths(dir, name$1)));
26
+ if (target) return includeNameInResults || isDirectory(joinPaths(dir, target)) ? joinPaths(dir, target) : dir;
27
+ const parentDir = resolveParentPath(dir);
28
+ if (parentDir === dir) return;
29
+ dir = parentDir;
30
+ }
31
+ };
32
+
33
+ //#endregion
34
+ export { getParentPath };
2
35
  //# sourceMappingURL=get-parent-path.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-parent-path.mjs","names":["currentDir","cwd","name"],"sources":["../src/get-parent-path.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 { toArray } from \"@stryke/convert/to-array\";\nimport { cwd as currentDir } from \"@stryke/path/cwd\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { existsSync } from \"node:fs\";\nimport { isDirectory } from \"./is-file\";\n\nexport interface GetParentPathOptions {\n /**\n * Whether to ignore the case of the file names when checking for existence.\n *\n * @defaultValue true\n */\n ignoreCase: boolean;\n\n /**\n * Whether to skip the current working directory when checking for the file.\n *\n * @defaultValue false\n */\n skipCwd: boolean;\n\n /**\n * Should we include the found file/directory name in the results.\n *\n * @defaultValue false\n */\n includeNameInResults?: boolean;\n}\n\n/**\n * Get the first parent path that has a file or directory with the provided name.\n *\n * @param name - The name (or names) of the file to look for in the parent paths.\n * @param cwd - The current working directory.\n * @returns The first parent path that exists.\n */\nexport const getParentPath = (\n name: string | string[],\n cwd = currentDir(),\n options: Partial<GetParentPathOptions> = {}\n): string | undefined => {\n const ignoreCase = options?.ignoreCase ?? true;\n const skipCwd = options?.skipCwd ?? false;\n const includeNameInResults = options?.includeNameInResults ?? false;\n\n let dir = cwd;\n if (skipCwd) {\n dir = resolveParentPath(cwd);\n }\n\n let names = toArray(name);\n if (ignoreCase) {\n names = names.map(name => name.toLowerCase());\n }\n\n while (true) {\n const target = names.find(name => existsSync(joinPaths(dir, name)));\n if (target) {\n return includeNameInResults || isDirectory(joinPaths(dir, target))\n ? joinPaths(dir, target)\n : dir;\n }\n\n const parentDir = resolveParentPath(dir);\n if (parentDir === dir) {\n // It'll fail anyway\n return undefined;\n }\n\n dir = parentDir;\n }\n};\n"],"mappings":"4SAuDA,MAAa,GACX,EACA,EAAMA,GAAY,CAClB,EAAyC,EAAE,GACpB,CACvB,IAAM,EAAa,GAAS,YAAc,GACpC,EAAU,GAAS,SAAW,GAC9B,EAAuB,GAAS,sBAAwB,GAE1D,EAAMC,EACN,IACF,EAAM,EAAkBA,EAAI,EAG9B,IAAI,EAAQ,EAAQ,EAAK,CAKzB,IAJI,IACF,EAAQ,EAAM,IAAI,GAAQC,EAAK,aAAa,CAAC,IAGlC,CACX,IAAM,EAAS,EAAM,KAAK,GAAQ,EAAW,EAAU,EAAKA,EAAK,CAAC,CAAC,CACnE,GAAI,EACF,OAAO,GAAwB,EAAY,EAAU,EAAK,EAAO,CAAC,CAC9D,EAAU,EAAK,EAAO,CACtB,EAGN,IAAM,EAAY,EAAkB,EAAI,CACxC,GAAI,IAAc,EAEhB,OAGF,EAAM"}
1
+ {"version":3,"file":"get-parent-path.mjs","names":["currentDir","cwd","name"],"sources":["../src/get-parent-path.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 { toArray } from \"@stryke/convert/to-array\";\nimport { cwd as currentDir } from \"@stryke/path/cwd\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { existsSync } from \"node:fs\";\nimport { isDirectory } from \"./is-file\";\n\nexport interface GetParentPathOptions {\n /**\n * Whether to ignore the case of the file names when checking for existence.\n *\n * @defaultValue true\n */\n ignoreCase: boolean;\n\n /**\n * Whether to skip the current working directory when checking for the file.\n *\n * @defaultValue false\n */\n skipCwd: boolean;\n\n /**\n * Should we include the found file/directory name in the results.\n *\n * @defaultValue false\n */\n includeNameInResults?: boolean;\n}\n\n/**\n * Get the first parent path that has a file or directory with the provided name.\n *\n * @param name - The name (or names) of the file to look for in the parent paths.\n * @param cwd - The current working directory.\n * @returns The first parent path that exists.\n */\nexport const getParentPath = (\n name: string | string[],\n cwd = currentDir(),\n options: Partial<GetParentPathOptions> = {}\n): string | undefined => {\n const ignoreCase = options?.ignoreCase ?? true;\n const skipCwd = options?.skipCwd ?? false;\n const includeNameInResults = options?.includeNameInResults ?? false;\n\n let dir = cwd;\n if (skipCwd) {\n dir = resolveParentPath(cwd);\n }\n\n let names = toArray(name);\n if (ignoreCase) {\n names = names.map(name => name.toLowerCase());\n }\n\n while (true) {\n const target = names.find(name => existsSync(joinPaths(dir, name)));\n if (target) {\n return includeNameInResults || isDirectory(joinPaths(dir, target))\n ? joinPaths(dir, target)\n : dir;\n }\n\n const parentDir = resolveParentPath(dir);\n if (parentDir === dir) {\n // It'll fail anyway\n return undefined;\n }\n\n dir = parentDir;\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;AAuDA,MAAa,iBACX,MACA,QAAMA,KAAY,EAClB,UAAyC,EAAE,KACpB;CACvB,MAAM,aAAa,SAAS,cAAc;CAC1C,MAAM,UAAU,SAAS,WAAW;CACpC,MAAM,uBAAuB,SAAS,wBAAwB;CAE9D,IAAI,MAAMC;AACV,KAAI,QACF,OAAM,kBAAkBA,MAAI;CAG9B,IAAI,QAAQ,QAAQ,KAAK;AACzB,KAAI,WACF,SAAQ,MAAM,KAAI,WAAQC,OAAK,aAAa,CAAC;AAG/C,QAAO,MAAM;EACX,MAAM,SAAS,MAAM,MAAK,WAAQ,WAAW,UAAU,KAAKA,OAAK,CAAC,CAAC;AACnE,MAAI,OACF,QAAO,wBAAwB,YAAY,UAAU,KAAK,OAAO,CAAC,GAC9D,UAAU,KAAK,OAAO,GACtB;EAGN,MAAM,YAAY,kBAAkB,IAAI;AACxC,MAAI,cAAc,IAEhB;AAGF,QAAM"}
@@ -1 +1,158 @@
1
- const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./path/src/cwd.cjs`),n=require(`./path/src/file-path-fns.cjs`),r=require(`./path/src/is-root-dir.cjs`),i=require(`./get-parent-path.cjs`);let a=require(`@storm-software/config-tools`);const o=`.all-contributorsrc,.commitlintrc,.github,.git,.husky,.huskyrc,.lintstagedrc,.log4brains.yml,.npmrc,.nx,.storm-workspace.js,.storm-workspace.json,.storm-workspace.ts,.storm-workspace.yaml,.storm-workspace.yml,.vscode,.whitesource,bun.lock,bun.lockb,lefthook.yaml,lefthook.yml,lerna.json,npm-lock.json,npm-lock.yaml,npm-lock.yml,npm-workspace.json,npm-workspace.yaml,npm-workspace.yml,nx.json,package-lock.json,patches,pnpm-lock.json,pnpm-lock.yaml,pnpm-lock.yml,pnpm-workspace.json,pnpm-workspace.yaml,pnpm-workspace.yml,socket.yaml,storm-workspace.js,storm-workspace.json,storm-workspace.ts,storm-workspace.yaml,storm-workspace.yml,syncpack.config.js,syncpack.json,turbo.json,yarn-lock.json,yarn-lock.yaml,yarn-lock.yml,yarn-workspace.json,yarn-workspace.yaml,yarn-workspace.yml,yarn.lock`.split(`,`),s=[`.powerlines`,`.storm`,`package.json`,`powerlines.json`,`powerlines.yaml`,`powerlines.yml`,`powerlines.toml`,`powerlines.config.js`,`powerlines.config.ts`,`project.json`];function c(e=t.cwd()){if(process.env.STORM_WORKSPACE_ROOT||process.env.NX_WORKSPACE_ROOT_PATH)return process.env.STORM_WORKSPACE_ROOT||process.env.NX_WORKSPACE_ROOT_PATH;let n=(0,a.findWorkspaceRootSafe)(e);if(n)return n;let s=i.getParentPath(o,e);if(s)return s;for(s=e;s&&!r.isSystemRoot(s);)if(s=i.getParentPath(`storm-workspace.json`,s,{skipCwd:!0,includeNameInResults:!1}),s)return s;return e}function l(e=t.cwd()){let n=c(e);return n?n===e:!1}function u(e=t.cwd()){return i.getParentPath(s,e)||e}function d(e=t.cwd()){let n=u(e);return n?n===e:!1}function f(e){return n.relativePath(e,c())}function p(e){return n.relativePath(e,u())}exports.PROJECT_ROOT_CONTENT=s,exports.WORKSPACE_ROOT_CONTENT=o,exports.getProjectRoot=u,exports.getWorkspaceRoot=c,exports.isProjectRoot=d,exports.isWorkspaceRoot=l,exports.relativeToProjectRoot=p,exports.relativeToWorkspaceRoot=f;
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ const require_cwd = require('./path/src/cwd.cjs');
3
+ const require_file_path_fns = require('./path/src/file-path-fns.cjs');
4
+ const require_is_root_dir = require('./path/src/is-root-dir.cjs');
5
+ const require_get_parent_path = require('./get-parent-path.cjs');
6
+ let __storm_software_config_tools = require("@storm-software/config-tools");
7
+
8
+ //#region src/get-workspace-root.ts
9
+ const WORKSPACE_ROOT_CONTENT = [
10
+ ".all-contributorsrc",
11
+ ".commitlintrc",
12
+ ".github",
13
+ ".git",
14
+ ".husky",
15
+ ".huskyrc",
16
+ ".lintstagedrc",
17
+ ".log4brains.yml",
18
+ ".npmrc",
19
+ ".nx",
20
+ ".storm-workspace.js",
21
+ ".storm-workspace.json",
22
+ ".storm-workspace.ts",
23
+ ".storm-workspace.yaml",
24
+ ".storm-workspace.yml",
25
+ ".vscode",
26
+ ".whitesource",
27
+ "bun.lock",
28
+ "bun.lockb",
29
+ "lefthook.yaml",
30
+ "lefthook.yml",
31
+ "lerna.json",
32
+ "npm-lock.json",
33
+ "npm-lock.yaml",
34
+ "npm-lock.yml",
35
+ "npm-workspace.json",
36
+ "npm-workspace.yaml",
37
+ "npm-workspace.yml",
38
+ "nx.json",
39
+ "package-lock.json",
40
+ "patches",
41
+ "pnpm-lock.json",
42
+ "pnpm-lock.yaml",
43
+ "pnpm-lock.yml",
44
+ "pnpm-workspace.json",
45
+ "pnpm-workspace.yaml",
46
+ "pnpm-workspace.yml",
47
+ "socket.yaml",
48
+ "storm-workspace.js",
49
+ "storm-workspace.json",
50
+ "storm-workspace.ts",
51
+ "storm-workspace.yaml",
52
+ "storm-workspace.yml",
53
+ "syncpack.config.js",
54
+ "syncpack.json",
55
+ "turbo.json",
56
+ "yarn-lock.json",
57
+ "yarn-lock.yaml",
58
+ "yarn-lock.yml",
59
+ "yarn-workspace.json",
60
+ "yarn-workspace.yaml",
61
+ "yarn-workspace.yml",
62
+ "yarn.lock"
63
+ ];
64
+ const PROJECT_ROOT_CONTENT = [
65
+ ".powerlines",
66
+ ".storm",
67
+ "package.json",
68
+ "powerlines.json",
69
+ "powerlines.yaml",
70
+ "powerlines.yml",
71
+ "powerlines.toml",
72
+ "powerlines.config.js",
73
+ "powerlines.config.ts",
74
+ "project.json"
75
+ ];
76
+ /**
77
+ * Get the workspace root path
78
+ *
79
+ * @param dir - A directory to start the search from
80
+ * @returns The workspace root path
81
+ */
82
+ function getWorkspaceRoot(dir = require_cwd.cwd()) {
83
+ if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) return process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH;
84
+ const root = (0, __storm_software_config_tools.findWorkspaceRootSafe)(dir);
85
+ if (root) return root;
86
+ let result = require_get_parent_path.getParentPath(WORKSPACE_ROOT_CONTENT, dir);
87
+ if (result) return result;
88
+ result = dir;
89
+ while (result && !require_is_root_dir.isSystemRoot(result)) {
90
+ result = require_get_parent_path.getParentPath("storm-workspace.json", result, {
91
+ skipCwd: true,
92
+ includeNameInResults: false
93
+ });
94
+ if (result) return result;
95
+ }
96
+ return dir;
97
+ }
98
+ /**
99
+ * Check if the given directory is the workspace root
100
+ *
101
+ * @param dir - A directory to check
102
+ * @returns True if the directory is the workspace root, false otherwise
103
+ */
104
+ function isWorkspaceRoot(dir = require_cwd.cwd()) {
105
+ const workspaceRoot = getWorkspaceRoot(dir);
106
+ if (workspaceRoot) return workspaceRoot === dir;
107
+ return false;
108
+ }
109
+ /**
110
+ * Get the project root path
111
+ *
112
+ * @param dir - A directory to start the search from
113
+ * @returns The project root path
114
+ */
115
+ function getProjectRoot(dir = require_cwd.cwd()) {
116
+ const result = require_get_parent_path.getParentPath(PROJECT_ROOT_CONTENT, dir);
117
+ if (result) return result;
118
+ return dir;
119
+ }
120
+ /**
121
+ * Check if the given directory is the project root
122
+ *
123
+ * @param dir - A directory to check
124
+ * @returns True if the directory is the project root, false otherwise
125
+ */
126
+ function isProjectRoot(dir = require_cwd.cwd()) {
127
+ const projectRoot = getProjectRoot(dir);
128
+ if (projectRoot) return projectRoot === dir;
129
+ return false;
130
+ }
131
+ /**
132
+ * Find the file path relative to the workspace root path.
133
+ *
134
+ * @param filePath - The file path to process
135
+ * @returns The file path relative to the workspace root
136
+ */
137
+ function relativeToWorkspaceRoot(filePath) {
138
+ return require_file_path_fns.relativePath(filePath, getWorkspaceRoot());
139
+ }
140
+ /**
141
+ * Find the file path relative to the project root path.
142
+ *
143
+ * @param filePath - The file path to process
144
+ * @returns The file path relative to the project root
145
+ */
146
+ function relativeToProjectRoot(filePath) {
147
+ return require_file_path_fns.relativePath(filePath, getProjectRoot());
148
+ }
149
+
150
+ //#endregion
151
+ exports.PROJECT_ROOT_CONTENT = PROJECT_ROOT_CONTENT;
152
+ exports.WORKSPACE_ROOT_CONTENT = WORKSPACE_ROOT_CONTENT;
153
+ exports.getProjectRoot = getProjectRoot;
154
+ exports.getWorkspaceRoot = getWorkspaceRoot;
155
+ exports.isProjectRoot = isProjectRoot;
156
+ exports.isWorkspaceRoot = isWorkspaceRoot;
157
+ exports.relativeToProjectRoot = relativeToProjectRoot;
158
+ exports.relativeToWorkspaceRoot = relativeToWorkspaceRoot;
@@ -1,2 +1,151 @@
1
- import{cwd as e}from"./path/src/cwd.mjs";import{relativePath as t}from"./path/src/file-path-fns.mjs";import{isSystemRoot as n}from"./path/src/is-root-dir.mjs";import{getParentPath as r}from"./get-parent-path.mjs";import{findWorkspaceRootSafe as i}from"@storm-software/config-tools";const a=`.all-contributorsrc,.commitlintrc,.github,.git,.husky,.huskyrc,.lintstagedrc,.log4brains.yml,.npmrc,.nx,.storm-workspace.js,.storm-workspace.json,.storm-workspace.ts,.storm-workspace.yaml,.storm-workspace.yml,.vscode,.whitesource,bun.lock,bun.lockb,lefthook.yaml,lefthook.yml,lerna.json,npm-lock.json,npm-lock.yaml,npm-lock.yml,npm-workspace.json,npm-workspace.yaml,npm-workspace.yml,nx.json,package-lock.json,patches,pnpm-lock.json,pnpm-lock.yaml,pnpm-lock.yml,pnpm-workspace.json,pnpm-workspace.yaml,pnpm-workspace.yml,socket.yaml,storm-workspace.js,storm-workspace.json,storm-workspace.ts,storm-workspace.yaml,storm-workspace.yml,syncpack.config.js,syncpack.json,turbo.json,yarn-lock.json,yarn-lock.yaml,yarn-lock.yml,yarn-workspace.json,yarn-workspace.yaml,yarn-workspace.yml,yarn.lock`.split(`,`),o=[`.powerlines`,`.storm`,`package.json`,`powerlines.json`,`powerlines.yaml`,`powerlines.yml`,`powerlines.toml`,`powerlines.config.js`,`powerlines.config.ts`,`project.json`];function s(t=e()){if(process.env.STORM_WORKSPACE_ROOT||process.env.NX_WORKSPACE_ROOT_PATH)return process.env.STORM_WORKSPACE_ROOT||process.env.NX_WORKSPACE_ROOT_PATH;let o=i(t);if(o)return o;let s=r(a,t);if(s)return s;for(s=t;s&&!n(s);)if(s=r(`storm-workspace.json`,s,{skipCwd:!0,includeNameInResults:!1}),s)return s;return t}function c(t=e()){let n=s(t);return n?n===t:!1}function l(t=e()){return r(o,t)||t}function u(t=e()){let n=l(t);return n?n===t:!1}function d(e){return t(e,s())}function f(e){return t(e,l())}export{o as PROJECT_ROOT_CONTENT,a as WORKSPACE_ROOT_CONTENT,l as getProjectRoot,s as getWorkspaceRoot,u as isProjectRoot,c as isWorkspaceRoot,f as relativeToProjectRoot,d as relativeToWorkspaceRoot};
1
+ import { cwd } from "./path/src/cwd.mjs";
2
+ import { relativePath } from "./path/src/file-path-fns.mjs";
3
+ import { isSystemRoot } from "./path/src/is-root-dir.mjs";
4
+ import { getParentPath } from "./get-parent-path.mjs";
5
+ import { findWorkspaceRootSafe } from "@storm-software/config-tools";
6
+
7
+ //#region src/get-workspace-root.ts
8
+ const WORKSPACE_ROOT_CONTENT = [
9
+ ".all-contributorsrc",
10
+ ".commitlintrc",
11
+ ".github",
12
+ ".git",
13
+ ".husky",
14
+ ".huskyrc",
15
+ ".lintstagedrc",
16
+ ".log4brains.yml",
17
+ ".npmrc",
18
+ ".nx",
19
+ ".storm-workspace.js",
20
+ ".storm-workspace.json",
21
+ ".storm-workspace.ts",
22
+ ".storm-workspace.yaml",
23
+ ".storm-workspace.yml",
24
+ ".vscode",
25
+ ".whitesource",
26
+ "bun.lock",
27
+ "bun.lockb",
28
+ "lefthook.yaml",
29
+ "lefthook.yml",
30
+ "lerna.json",
31
+ "npm-lock.json",
32
+ "npm-lock.yaml",
33
+ "npm-lock.yml",
34
+ "npm-workspace.json",
35
+ "npm-workspace.yaml",
36
+ "npm-workspace.yml",
37
+ "nx.json",
38
+ "package-lock.json",
39
+ "patches",
40
+ "pnpm-lock.json",
41
+ "pnpm-lock.yaml",
42
+ "pnpm-lock.yml",
43
+ "pnpm-workspace.json",
44
+ "pnpm-workspace.yaml",
45
+ "pnpm-workspace.yml",
46
+ "socket.yaml",
47
+ "storm-workspace.js",
48
+ "storm-workspace.json",
49
+ "storm-workspace.ts",
50
+ "storm-workspace.yaml",
51
+ "storm-workspace.yml",
52
+ "syncpack.config.js",
53
+ "syncpack.json",
54
+ "turbo.json",
55
+ "yarn-lock.json",
56
+ "yarn-lock.yaml",
57
+ "yarn-lock.yml",
58
+ "yarn-workspace.json",
59
+ "yarn-workspace.yaml",
60
+ "yarn-workspace.yml",
61
+ "yarn.lock"
62
+ ];
63
+ const PROJECT_ROOT_CONTENT = [
64
+ ".powerlines",
65
+ ".storm",
66
+ "package.json",
67
+ "powerlines.json",
68
+ "powerlines.yaml",
69
+ "powerlines.yml",
70
+ "powerlines.toml",
71
+ "powerlines.config.js",
72
+ "powerlines.config.ts",
73
+ "project.json"
74
+ ];
75
+ /**
76
+ * Get the workspace root path
77
+ *
78
+ * @param dir - A directory to start the search from
79
+ * @returns The workspace root path
80
+ */
81
+ function getWorkspaceRoot(dir = cwd()) {
82
+ if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) return process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH;
83
+ const root = findWorkspaceRootSafe(dir);
84
+ if (root) return root;
85
+ let result = getParentPath(WORKSPACE_ROOT_CONTENT, dir);
86
+ if (result) return result;
87
+ result = dir;
88
+ while (result && !isSystemRoot(result)) {
89
+ result = getParentPath("storm-workspace.json", result, {
90
+ skipCwd: true,
91
+ includeNameInResults: false
92
+ });
93
+ if (result) return result;
94
+ }
95
+ return dir;
96
+ }
97
+ /**
98
+ * Check if the given directory is the workspace root
99
+ *
100
+ * @param dir - A directory to check
101
+ * @returns True if the directory is the workspace root, false otherwise
102
+ */
103
+ function isWorkspaceRoot(dir = cwd()) {
104
+ const workspaceRoot = getWorkspaceRoot(dir);
105
+ if (workspaceRoot) return workspaceRoot === dir;
106
+ return false;
107
+ }
108
+ /**
109
+ * Get the project root path
110
+ *
111
+ * @param dir - A directory to start the search from
112
+ * @returns The project root path
113
+ */
114
+ function getProjectRoot(dir = cwd()) {
115
+ const result = getParentPath(PROJECT_ROOT_CONTENT, dir);
116
+ if (result) return result;
117
+ return dir;
118
+ }
119
+ /**
120
+ * Check if the given directory is the project root
121
+ *
122
+ * @param dir - A directory to check
123
+ * @returns True if the directory is the project root, false otherwise
124
+ */
125
+ function isProjectRoot(dir = cwd()) {
126
+ const projectRoot = getProjectRoot(dir);
127
+ if (projectRoot) return projectRoot === dir;
128
+ return false;
129
+ }
130
+ /**
131
+ * Find the file path relative to the workspace root path.
132
+ *
133
+ * @param filePath - The file path to process
134
+ * @returns The file path relative to the workspace root
135
+ */
136
+ function relativeToWorkspaceRoot(filePath) {
137
+ return relativePath(filePath, getWorkspaceRoot());
138
+ }
139
+ /**
140
+ * Find the file path relative to the project root path.
141
+ *
142
+ * @param filePath - The file path to process
143
+ * @returns The file path relative to the project root
144
+ */
145
+ function relativeToProjectRoot(filePath) {
146
+ return relativePath(filePath, getProjectRoot());
147
+ }
148
+
149
+ //#endregion
150
+ export { PROJECT_ROOT_CONTENT, WORKSPACE_ROOT_CONTENT, getProjectRoot, getWorkspaceRoot, isProjectRoot, isWorkspaceRoot, relativeToProjectRoot, relativeToWorkspaceRoot };
2
151
  //# sourceMappingURL=get-workspace-root.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-workspace-root.mjs","names":["WORKSPACE_ROOT_CONTENT: string[]","PROJECT_ROOT_CONTENT: string[]"],"sources":["../src/get-workspace-root.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 { findWorkspaceRootSafe } from \"@storm-software/config-tools\";\nimport { cwd } from \"@stryke/path/cwd\";\nimport { relativePath } from \"@stryke/path/file-path-fns\";\nimport { isSystemRoot } from \"@stryke/path/is-root-dir\";\nimport { getParentPath } from \"./get-parent-path\";\n\nexport const WORKSPACE_ROOT_CONTENT: string[] = [\n \".all-contributorsrc\",\n \".commitlintrc\",\n \".github\",\n \".git\",\n \".husky\",\n \".huskyrc\",\n \".lintstagedrc\",\n \".log4brains.yml\",\n \".npmrc\",\n \".nx\",\n \".storm-workspace.js\",\n \".storm-workspace.json\",\n \".storm-workspace.ts\",\n \".storm-workspace.yaml\",\n \".storm-workspace.yml\",\n \".vscode\",\n \".whitesource\",\n \"bun.lock\",\n \"bun.lockb\",\n \"lefthook.yaml\",\n \"lefthook.yml\",\n \"lerna.json\",\n \"npm-lock.json\",\n \"npm-lock.yaml\",\n \"npm-lock.yml\",\n \"npm-workspace.json\",\n \"npm-workspace.yaml\",\n \"npm-workspace.yml\",\n \"nx.json\",\n \"package-lock.json\",\n \"patches\",\n \"pnpm-lock.json\",\n \"pnpm-lock.yaml\",\n \"pnpm-lock.yml\",\n \"pnpm-workspace.json\",\n \"pnpm-workspace.yaml\",\n \"pnpm-workspace.yml\",\n \"socket.yaml\",\n \"storm-workspace.js\",\n \"storm-workspace.json\",\n \"storm-workspace.ts\",\n \"storm-workspace.yaml\",\n \"storm-workspace.yml\",\n \"syncpack.config.js\",\n \"syncpack.json\",\n \"turbo.json\",\n \"yarn-lock.json\",\n \"yarn-lock.yaml\",\n \"yarn-lock.yml\",\n \"yarn-workspace.json\",\n \"yarn-workspace.yaml\",\n \"yarn-workspace.yml\",\n \"yarn.lock\"\n] as const;\n\nexport const PROJECT_ROOT_CONTENT: string[] = [\n \".powerlines\",\n \".storm\",\n \"package.json\",\n \"powerlines.json\",\n \"powerlines.yaml\",\n \"powerlines.yml\",\n \"powerlines.toml\",\n \"powerlines.config.js\",\n \"powerlines.config.ts\",\n \"project.json\"\n] as const;\n\n/**\n * Get the workspace root path\n *\n * @param dir - A directory to start the search from\n * @returns The workspace root path\n */\nexport function getWorkspaceRoot(dir = cwd()) {\n if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {\n return (process.env.STORM_WORKSPACE_ROOT ||\n process.env.NX_WORKSPACE_ROOT_PATH)!;\n }\n\n const root = findWorkspaceRootSafe(dir);\n if (root) {\n return root;\n }\n\n let result = getParentPath(WORKSPACE_ROOT_CONTENT, dir);\n if (result) {\n return result;\n }\n\n result = dir;\n while (result && !isSystemRoot(result)) {\n result = getParentPath(\"storm-workspace.json\", result, {\n skipCwd: true,\n includeNameInResults: false\n });\n if (result) {\n return result;\n }\n }\n\n return dir;\n}\n\n/**\n * Check if the given directory is the workspace root\n *\n * @param dir - A directory to check\n * @returns True if the directory is the workspace root, false otherwise\n */\nexport function isWorkspaceRoot(dir = cwd()): boolean {\n const workspaceRoot = getWorkspaceRoot(dir);\n if (workspaceRoot) {\n return workspaceRoot === dir;\n }\n\n return false;\n}\n\n/**\n * Get the project root path\n *\n * @param dir - A directory to start the search from\n * @returns The project root path\n */\nexport function getProjectRoot(dir = cwd()) {\n const result = getParentPath(PROJECT_ROOT_CONTENT, dir);\n\n if (result) {\n return result;\n }\n\n return dir;\n}\n\n/**\n * Check if the given directory is the project root\n *\n * @param dir - A directory to check\n * @returns True if the directory is the project root, false otherwise\n */\nexport function isProjectRoot(dir = cwd()): boolean {\n const projectRoot = getProjectRoot(dir);\n if (projectRoot) {\n return projectRoot === dir;\n }\n\n return false;\n}\n\n/**\n * Find the file path relative to the workspace root path.\n *\n * @param filePath - The file path to process\n * @returns The file path relative to the workspace root\n */\nexport function relativeToWorkspaceRoot(filePath: string) {\n return relativePath(filePath, getWorkspaceRoot());\n}\n\n/**\n * Find the file path relative to the project root path.\n *\n * @param filePath - The file path to process\n * @returns The file path relative to the project root\n */\nexport function relativeToProjectRoot(filePath: string) {\n return relativePath(filePath, getProjectRoot());\n}\n"],"mappings":"0RAwBA,MAAaA,EAAmC,kyBAsD/C,CAEYC,EAAiC,CAC5C,cACA,SACA,eACA,kBACA,kBACA,iBACA,kBACA,uBACA,uBACA,eACD,CAQD,SAAgB,EAAiB,EAAM,GAAK,CAAE,CAC5C,GAAI,QAAQ,IAAI,sBAAwB,QAAQ,IAAI,uBAClD,OAAQ,QAAQ,IAAI,sBAClB,QAAQ,IAAI,uBAGhB,IAAM,EAAO,EAAsB,EAAI,CACvC,GAAI,EACF,OAAO,EAGT,IAAI,EAAS,EAAc,EAAwB,EAAI,CACvD,GAAI,EACF,OAAO,EAIT,IADA,EAAS,EACF,GAAU,CAAC,EAAa,EAAO,EAKpC,GAJA,EAAS,EAAc,uBAAwB,EAAQ,CACrD,QAAS,GACT,qBAAsB,GACvB,CAAC,CACE,EACF,OAAO,EAIX,OAAO,EAST,SAAgB,EAAgB,EAAM,GAAK,CAAW,CACpD,IAAM,EAAgB,EAAiB,EAAI,CAK3C,OAJI,EACK,IAAkB,EAGpB,GAST,SAAgB,EAAe,EAAM,GAAK,CAAE,CAO1C,OANe,EAAc,EAAsB,EAAI,EAMhD,EAST,SAAgB,EAAc,EAAM,GAAK,CAAW,CAClD,IAAM,EAAc,EAAe,EAAI,CAKvC,OAJI,EACK,IAAgB,EAGlB,GAST,SAAgB,EAAwB,EAAkB,CACxD,OAAO,EAAa,EAAU,GAAkB,CAAC,CASnD,SAAgB,EAAsB,EAAkB,CACtD,OAAO,EAAa,EAAU,GAAgB,CAAC"}
1
+ {"version":3,"file":"get-workspace-root.mjs","names":["WORKSPACE_ROOT_CONTENT: string[]","PROJECT_ROOT_CONTENT: string[]"],"sources":["../src/get-workspace-root.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 { findWorkspaceRootSafe } from \"@storm-software/config-tools\";\nimport { cwd } from \"@stryke/path/cwd\";\nimport { relativePath } from \"@stryke/path/file-path-fns\";\nimport { isSystemRoot } from \"@stryke/path/is-root-dir\";\nimport { getParentPath } from \"./get-parent-path\";\n\nexport const WORKSPACE_ROOT_CONTENT: string[] = [\n \".all-contributorsrc\",\n \".commitlintrc\",\n \".github\",\n \".git\",\n \".husky\",\n \".huskyrc\",\n \".lintstagedrc\",\n \".log4brains.yml\",\n \".npmrc\",\n \".nx\",\n \".storm-workspace.js\",\n \".storm-workspace.json\",\n \".storm-workspace.ts\",\n \".storm-workspace.yaml\",\n \".storm-workspace.yml\",\n \".vscode\",\n \".whitesource\",\n \"bun.lock\",\n \"bun.lockb\",\n \"lefthook.yaml\",\n \"lefthook.yml\",\n \"lerna.json\",\n \"npm-lock.json\",\n \"npm-lock.yaml\",\n \"npm-lock.yml\",\n \"npm-workspace.json\",\n \"npm-workspace.yaml\",\n \"npm-workspace.yml\",\n \"nx.json\",\n \"package-lock.json\",\n \"patches\",\n \"pnpm-lock.json\",\n \"pnpm-lock.yaml\",\n \"pnpm-lock.yml\",\n \"pnpm-workspace.json\",\n \"pnpm-workspace.yaml\",\n \"pnpm-workspace.yml\",\n \"socket.yaml\",\n \"storm-workspace.js\",\n \"storm-workspace.json\",\n \"storm-workspace.ts\",\n \"storm-workspace.yaml\",\n \"storm-workspace.yml\",\n \"syncpack.config.js\",\n \"syncpack.json\",\n \"turbo.json\",\n \"yarn-lock.json\",\n \"yarn-lock.yaml\",\n \"yarn-lock.yml\",\n \"yarn-workspace.json\",\n \"yarn-workspace.yaml\",\n \"yarn-workspace.yml\",\n \"yarn.lock\"\n] as const;\n\nexport const PROJECT_ROOT_CONTENT: string[] = [\n \".powerlines\",\n \".storm\",\n \"package.json\",\n \"powerlines.json\",\n \"powerlines.yaml\",\n \"powerlines.yml\",\n \"powerlines.toml\",\n \"powerlines.config.js\",\n \"powerlines.config.ts\",\n \"project.json\"\n] as const;\n\n/**\n * Get the workspace root path\n *\n * @param dir - A directory to start the search from\n * @returns The workspace root path\n */\nexport function getWorkspaceRoot(dir = cwd()) {\n if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {\n return (process.env.STORM_WORKSPACE_ROOT ||\n process.env.NX_WORKSPACE_ROOT_PATH)!;\n }\n\n const root = findWorkspaceRootSafe(dir);\n if (root) {\n return root;\n }\n\n let result = getParentPath(WORKSPACE_ROOT_CONTENT, dir);\n if (result) {\n return result;\n }\n\n result = dir;\n while (result && !isSystemRoot(result)) {\n result = getParentPath(\"storm-workspace.json\", result, {\n skipCwd: true,\n includeNameInResults: false\n });\n if (result) {\n return result;\n }\n }\n\n return dir;\n}\n\n/**\n * Check if the given directory is the workspace root\n *\n * @param dir - A directory to check\n * @returns True if the directory is the workspace root, false otherwise\n */\nexport function isWorkspaceRoot(dir = cwd()): boolean {\n const workspaceRoot = getWorkspaceRoot(dir);\n if (workspaceRoot) {\n return workspaceRoot === dir;\n }\n\n return false;\n}\n\n/**\n * Get the project root path\n *\n * @param dir - A directory to start the search from\n * @returns The project root path\n */\nexport function getProjectRoot(dir = cwd()) {\n const result = getParentPath(PROJECT_ROOT_CONTENT, dir);\n\n if (result) {\n return result;\n }\n\n return dir;\n}\n\n/**\n * Check if the given directory is the project root\n *\n * @param dir - A directory to check\n * @returns True if the directory is the project root, false otherwise\n */\nexport function isProjectRoot(dir = cwd()): boolean {\n const projectRoot = getProjectRoot(dir);\n if (projectRoot) {\n return projectRoot === dir;\n }\n\n return false;\n}\n\n/**\n * Find the file path relative to the workspace root path.\n *\n * @param filePath - The file path to process\n * @returns The file path relative to the workspace root\n */\nexport function relativeToWorkspaceRoot(filePath: string) {\n return relativePath(filePath, getWorkspaceRoot());\n}\n\n/**\n * Find the file path relative to the project root path.\n *\n * @param filePath - The file path to process\n * @returns The file path relative to the project root\n */\nexport function relativeToProjectRoot(filePath: string) {\n return relativePath(filePath, getProjectRoot());\n}\n"],"mappings":";;;;;;;AAwBA,MAAaA,yBAAmC;CAC9C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAaC,uBAAiC;CAC5C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;AAQD,SAAgB,iBAAiB,MAAM,KAAK,EAAE;AAC5C,KAAI,QAAQ,IAAI,wBAAwB,QAAQ,IAAI,uBAClD,QAAQ,QAAQ,IAAI,wBAClB,QAAQ,IAAI;CAGhB,MAAM,OAAO,sBAAsB,IAAI;AACvC,KAAI,KACF,QAAO;CAGT,IAAI,SAAS,cAAc,wBAAwB,IAAI;AACvD,KAAI,OACF,QAAO;AAGT,UAAS;AACT,QAAO,UAAU,CAAC,aAAa,OAAO,EAAE;AACtC,WAAS,cAAc,wBAAwB,QAAQ;GACrD,SAAS;GACT,sBAAsB;GACvB,CAAC;AACF,MAAI,OACF,QAAO;;AAIX,QAAO;;;;;;;;AAST,SAAgB,gBAAgB,MAAM,KAAK,EAAW;CACpD,MAAM,gBAAgB,iBAAiB,IAAI;AAC3C,KAAI,cACF,QAAO,kBAAkB;AAG3B,QAAO;;;;;;;;AAST,SAAgB,eAAe,MAAM,KAAK,EAAE;CAC1C,MAAM,SAAS,cAAc,sBAAsB,IAAI;AAEvD,KAAI,OACF,QAAO;AAGT,QAAO;;;;;;;;AAST,SAAgB,cAAc,MAAM,KAAK,EAAW;CAClD,MAAM,cAAc,eAAe,IAAI;AACvC,KAAI,YACF,QAAO,gBAAgB;AAGzB,QAAO;;;;;;;;AAST,SAAgB,wBAAwB,UAAkB;AACxD,QAAO,aAAa,UAAU,kBAAkB,CAAC;;;;;;;;AASnD,SAAgB,sBAAsB,UAAkB;AACtD,QAAO,aAAa,UAAU,gBAAgB,CAAC"}
@@ -1 +1,14 @@
1
- const e=e=>[...new Set(e)];exports.getUnique=e;
1
+
2
+ //#region ../helpers/src/get-unique.ts
3
+ /**
4
+ * Returns an array of unique values from the given array.
5
+ *
6
+ * @param arr - The array to get unique values from.
7
+ * @returns An array of unique values.
8
+ */
9
+ const getUnique = (arr) => {
10
+ return [...new Set(arr)];
11
+ };
12
+
13
+ //#endregion
14
+ exports.getUnique = getUnique;
@@ -1,2 +1,14 @@
1
- const e=e=>[...new Set(e)];export{e as getUnique};
1
+ //#region ../helpers/src/get-unique.ts
2
+ /**
3
+ * Returns an array of unique values from the given array.
4
+ *
5
+ * @param arr - The array to get unique values from.
6
+ * @returns An array of unique values.
7
+ */
8
+ const getUnique = (arr) => {
9
+ return [...new Set(arr)];
10
+ };
11
+
12
+ //#endregion
13
+ export { getUnique };
2
14
  //# sourceMappingURL=get-unique.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-unique.mjs","names":[],"sources":["../../../../helpers/src/get-unique.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\n/**\n * Returns an array of unique values from the given array.\n *\n * @param arr - The array to get unique values from.\n * @returns An array of unique values.\n */\nexport const getUnique = <T = any>(arr: T[]): T[] => {\n return [...new Set(arr)];\n};\n\n/**\n * Returns a new array containing only the unique elements from the original array,\n * based on the values returned by the mapper function.\n *\n * @example\n * ```ts\n * uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);\n * // [1.2, 2.1, 3.2, 5.7, 7.19]\n * ```\n *\n * @param arr - The array to process.\n * @param mapper - The function used to convert the array elements.\n * @returns A new array containing only the unique elements from the original array, based on the values returned by the mapper function.\n */\nexport function getUniqueBy<T, U>(\n arr: readonly T[],\n mapper: (item: T) => U = item => item as unknown as U\n): T[] {\n const map = new Map<U, T>();\n\n for (const item of arr) {\n const key = mapper(item);\n\n if (!map.has(key)) {\n map.set(key, item);\n }\n }\n\n return [...map.values()];\n}\n"],"mappings":"AAwBA,MAAa,EAAsB,GAC1B,CAAC,GAAG,IAAI,IAAI,EAAI,CAAC"}
1
+ {"version":3,"file":"get-unique.mjs","names":[],"sources":["../../../../helpers/src/get-unique.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\n/**\n * Returns an array of unique values from the given array.\n *\n * @param arr - The array to get unique values from.\n * @returns An array of unique values.\n */\nexport const getUnique = <T = any>(arr: T[]): T[] => {\n return [...new Set(arr)];\n};\n\n/**\n * Returns a new array containing only the unique elements from the original array,\n * based on the values returned by the mapper function.\n *\n * @example\n * ```ts\n * uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);\n * // [1.2, 2.1, 3.2, 5.7, 7.19]\n * ```\n *\n * @param arr - The array to process.\n * @param mapper - The function used to convert the array elements.\n * @returns A new array containing only the unique elements from the original array, based on the values returned by the mapper function.\n */\nexport function getUniqueBy<T, U>(\n arr: readonly T[],\n mapper: (item: T) => U = item => item as unknown as U\n): T[] {\n const map = new Map<U, T>();\n\n for (const item of arr) {\n const key = mapper(item);\n\n if (!map.has(key)) {\n map.set(key, item);\n }\n }\n\n return [...map.values()];\n}\n"],"mappings":";;;;;;;AAwBA,MAAa,aAAsB,QAAkB;AACnD,QAAO,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC"}
package/dist/helpers.cjs CHANGED
@@ -1 +1,83 @@
1
- const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./exists.cjs`);let n=require(`node:fs`),r=require(`node:fs/promises`),i=require(`nanotar`);function a(e){if(!t.existsSync(e))return(0,n.mkdirSync)(e,{recursive:!0})}async function o(e){if(!await t.exists(e))return(0,r.mkdir)(e,{recursive:!0})}function s(e){if(t.existsSync(e))return(0,n.rmSync)(e,{recursive:!0})}async function c(e){if(t.existsSync(e))return(0,r.rm)(e,{recursive:!0})}async function l(e,a,o){let s=(0,i.parseTar)(await(0,r.readFile)(e)).find(e=>e.name===a);s?.data&&(await t.exists(o)||await(0,r.mkdir)(o,{recursive:!0}),(0,n.createWriteStream)(o).write(s.data))}async function u(e,a,o){let s=(await(0,i.parseTarGzip)(await(0,r.readFile)(e))).find(e=>e.name===a);s?.data&&(await t.exists(o)||await(0,r.mkdir)(o,{recursive:!0}),(0,n.createWriteStream)(o).write(s.data))}exports.createDirectory=o,exports.createDirectorySync=a,exports.extractFileFromTar=l,exports.extractFileFromTarGzip=u,exports.removeDirectory=c,exports.removeDirectorySync=s;
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ const require_exists = require('./exists.cjs');
3
+ let node_fs = require("node:fs");
4
+ let node_fs_promises = require("node:fs/promises");
5
+ let nanotar = require("nanotar");
6
+
7
+ //#region src/helpers.ts
8
+ /**
9
+ * Create a directory if it does not exist.
10
+ *
11
+ * @param path - The directory path to check
12
+ * @returns An indicator specifying if the directory exists
13
+ */
14
+ function createDirectorySync(path) {
15
+ if (require_exists.existsSync(path)) return;
16
+ return (0, node_fs.mkdirSync)(path, { recursive: true });
17
+ }
18
+ /**
19
+ * Create a directory if it does not exist.
20
+ *
21
+ * @param path - The directory path to check
22
+ * @returns An indicator specifying if the directory exists
23
+ */
24
+ async function createDirectory(path) {
25
+ if (await require_exists.exists(path)) return;
26
+ return (0, node_fs_promises.mkdir)(path, { recursive: true });
27
+ }
28
+ /**
29
+ * Remove a directory if it exists.
30
+ *
31
+ * @param path - The directory path to check
32
+ * @returns An indicator specifying if the directory exists
33
+ */
34
+ function removeDirectorySync(path) {
35
+ if (!require_exists.existsSync(path)) return;
36
+ return (0, node_fs.rmSync)(path, { recursive: true });
37
+ }
38
+ /**
39
+ * Remove a directory if it exists.
40
+ *
41
+ * @param path - The directory path to check
42
+ * @returns An indicator specifying if the directory exists
43
+ */
44
+ async function removeDirectory(path) {
45
+ if (!require_exists.existsSync(path)) return;
46
+ return (0, node_fs_promises.rm)(path, { recursive: true });
47
+ }
48
+ /**
49
+ * Extracts a file from a given tarball to the specified destination.
50
+ *
51
+ * @param tarballPath - The path to the tarball from where the file should be extracted.
52
+ * @param file - The path to the file inside the tarball.
53
+ * @param destinationFilePath - The destination file path.
54
+ * @returns True if the file was extracted successfully, false otherwise.
55
+ */
56
+ async function extractFileFromTar(tarballPath, file, destinationFilePath) {
57
+ const entry = (0, nanotar.parseTar)(await (0, node_fs_promises.readFile)(tarballPath)).find((e) => e.name === file);
58
+ if (!entry?.data) return;
59
+ if (!await require_exists.exists(destinationFilePath)) await (0, node_fs_promises.mkdir)(destinationFilePath, { recursive: true });
60
+ (0, node_fs.createWriteStream)(destinationFilePath).write(entry.data);
61
+ }
62
+ /**
63
+ * Extracts a file from a given TarGzip to the specified destination.
64
+ *
65
+ * @param tarballPath - The path to the tarball from where the file should be extracted.
66
+ * @param file - The path to the file inside the tarball.
67
+ * @param destinationFilePath - The destination file path.
68
+ * @returns True if the file was extracted successfully, false otherwise.
69
+ */
70
+ async function extractFileFromTarGzip(tarballPath, file, destinationFilePath) {
71
+ const entry = (await (0, nanotar.parseTarGzip)(await (0, node_fs_promises.readFile)(tarballPath))).find((e) => e.name === file);
72
+ if (!entry?.data) return;
73
+ if (!await require_exists.exists(destinationFilePath)) await (0, node_fs_promises.mkdir)(destinationFilePath, { recursive: true });
74
+ (0, node_fs.createWriteStream)(destinationFilePath).write(entry.data);
75
+ }
76
+
77
+ //#endregion
78
+ exports.createDirectory = createDirectory;
79
+ exports.createDirectorySync = createDirectorySync;
80
+ exports.extractFileFromTar = extractFileFromTar;
81
+ exports.extractFileFromTarGzip = extractFileFromTarGzip;
82
+ exports.removeDirectory = removeDirectory;
83
+ exports.removeDirectorySync = removeDirectorySync;