@storm-software/config-tools 1.190.119 → 1.190.121

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 (211) hide show
  1. package/README.md +1 -1
  2. package/bin/config.cjs +1213 -1558
  3. package/bin/config.mjs +1271 -0
  4. package/dist/_virtual/_rolldown/runtime.cjs +23 -0
  5. package/dist/config-file/get-config-file.cjs +67 -28
  6. package/dist/config-file/get-config-file.d.cts +5 -5
  7. package/dist/config-file/{get-config-file.d.ts → get-config-file.d.mts} +7 -5
  8. package/dist/config-file/get-config-file.mjs +66 -0
  9. package/dist/config-file/index.cjs +4 -29
  10. package/dist/config-file/index.d.cts +2 -3
  11. package/dist/config-file/index.d.mts +4 -0
  12. package/dist/config-file/index.mjs +5 -0
  13. package/dist/create-storm-config.cjs +115 -34
  14. package/dist/create-storm-config.d.cts +5 -5
  15. package/dist/{create-storm-config.d.ts → create-storm-config.d.mts} +7 -5
  16. package/dist/create-storm-config.mjs +113 -0
  17. package/dist/env/get-env.cjs +202 -11
  18. package/dist/env/get-env.d.cts +5 -5
  19. package/dist/env/{get-env.d.ts → get-env.d.mts} +7 -5
  20. package/dist/env/get-env.mjs +203 -0
  21. package/dist/env/index.cjs +7 -18
  22. package/dist/env/index.d.cts +3 -4
  23. package/dist/env/index.d.mts +5 -0
  24. package/dist/env/index.mjs +6 -0
  25. package/dist/env/set-env.cjs +230 -11
  26. package/dist/env/set-env.d.cts +8 -8
  27. package/dist/env/{set-env.d.ts → set-env.d.mts} +10 -8
  28. package/dist/env/set-env.mjs +231 -0
  29. package/dist/get-config.cjs +46 -34
  30. package/dist/get-config.d.cts +18 -18
  31. package/dist/{get-config.d.ts → get-config.d.mts} +20 -18
  32. package/dist/get-config.mjs +46 -0
  33. package/dist/index.cjs +98 -201
  34. package/dist/index.d.cts +27 -28
  35. package/dist/index.d.mts +29 -0
  36. package/dist/index.mjs +26 -0
  37. package/dist/logger/chalk.cjs +43 -6
  38. package/dist/logger/chalk.d.cts +18 -17
  39. package/dist/logger/chalk.d.mts +37 -0
  40. package/dist/logger/chalk.mjs +43 -0
  41. package/dist/logger/console-icons.cjs +18 -8
  42. package/dist/logger/console-icons.d.cts +5 -8
  43. package/dist/logger/console-icons.d.mts +7 -0
  44. package/dist/logger/console-icons.mjs +20 -0
  45. package/dist/logger/console.cjs +195 -37
  46. package/dist/logger/console.d.cts +25 -25
  47. package/dist/logger/{console.d.ts → console.d.mts} +27 -25
  48. package/dist/logger/console.mjs +185 -0
  49. package/dist/logger/create-logger.cjs +34 -14
  50. package/dist/logger/create-logger.d.cts +5 -6
  51. package/dist/logger/{create-logger.d.ts → create-logger.d.mts} +7 -6
  52. package/dist/logger/create-logger.mjs +34 -0
  53. package/dist/logger/format-timestamp.cjs +14 -6
  54. package/dist/logger/format-timestamp.d.cts +3 -2
  55. package/dist/logger/{format-timestamp.d.ts → format-timestamp.d.mts} +5 -2
  56. package/dist/logger/format-timestamp.mjs +16 -0
  57. package/dist/logger/get-log-level.cjs +54 -11
  58. package/dist/logger/get-log-level.d.cts +4 -5
  59. package/dist/logger/{get-log-level.d.ts → get-log-level.d.mts} +6 -5
  60. package/dist/logger/get-log-level.mjs +54 -0
  61. package/dist/logger/index.cjs +29 -61
  62. package/dist/logger/index.d.cts +8 -10
  63. package/dist/logger/index.d.mts +10 -0
  64. package/dist/logger/index.mjs +11 -0
  65. package/dist/logger/is-unicode-supported.cjs +8 -6
  66. package/dist/logger/is-unicode-supported.d.cts +3 -2
  67. package/dist/logger/is-unicode-supported.d.mts +6 -0
  68. package/dist/logger/is-unicode-supported.mjs +10 -0
  69. package/dist/types.cjs +29 -8
  70. package/dist/types.d.cts +39 -41
  71. package/dist/types.d.mts +53 -0
  72. package/dist/types.mjs +30 -0
  73. package/dist/utilities/apply-workspace-tokens.cjs +37 -13
  74. package/dist/utilities/apply-workspace-tokens.d.cts +4 -5
  75. package/dist/utilities/{apply-workspace-tokens.d.ts → apply-workspace-tokens.d.mts} +6 -5
  76. package/dist/utilities/apply-workspace-tokens.mjs +37 -0
  77. package/dist/utilities/colors.cjs +98 -12
  78. package/dist/utilities/colors.d.cts +4 -4
  79. package/dist/utilities/{colors.d.ts → colors.d.mts} +6 -4
  80. package/dist/utilities/colors.mjs +97 -0
  81. package/dist/utilities/correct-paths.cjs +201 -32
  82. package/dist/utilities/correct-paths.d.cts +4 -4
  83. package/dist/utilities/{correct-paths.d.ts → correct-paths.d.mts} +6 -4
  84. package/dist/utilities/correct-paths.mjs +190 -0
  85. package/dist/utilities/file-path-utils.cjs +48 -11
  86. package/dist/utilities/file-path-utils.d.cts +15 -14
  87. package/dist/utilities/{file-path-utils.d.ts → file-path-utils.d.mts} +17 -14
  88. package/dist/utilities/file-path-utils.mjs +48 -0
  89. package/dist/utilities/find-up.cjs +17 -6
  90. package/dist/utilities/find-up.d.cts +3 -2
  91. package/dist/utilities/{find-up.d.ts → find-up.d.mts} +5 -2
  92. package/dist/utilities/find-up.mjs +19 -0
  93. package/dist/utilities/find-workspace-root.cjs +72 -10
  94. package/dist/utilities/find-workspace-root.d.cts +3 -2
  95. package/dist/utilities/{find-workspace-root.d.ts → find-workspace-root.d.mts} +5 -2
  96. package/dist/utilities/find-workspace-root.mjs +73 -0
  97. package/dist/utilities/get-default-config.cjs +73 -11
  98. package/dist/utilities/get-default-config.d.cts +4 -4
  99. package/dist/utilities/{get-default-config.d.ts → get-default-config.d.mts} +6 -4
  100. package/dist/utilities/get-default-config.mjs +74 -0
  101. package/dist/utilities/index.cjs +49 -109
  102. package/dist/utilities/index.d.cts +10 -14
  103. package/dist/utilities/index.d.mts +12 -0
  104. package/dist/utilities/index.mjs +13 -0
  105. package/dist/utilities/process-handler.cjs +38 -18
  106. package/dist/utilities/process-handler.d.cts +4 -4
  107. package/dist/utilities/process-handler.d.mts +9 -0
  108. package/dist/utilities/process-handler.mjs +38 -0
  109. package/dist/utilities/run.cjs +64 -10
  110. package/dist/utilities/run.d.cts +5 -6
  111. package/dist/utilities/{run.d.ts → run.d.mts} +7 -6
  112. package/dist/utilities/run.mjs +64 -0
  113. package/dist/utilities/toml.cjs +37 -24
  114. package/dist/utilities/toml.d.cts +148 -147
  115. package/dist/utilities/toml.d.mts +192 -0
  116. package/dist/utilities/toml.mjs +33 -0
  117. package/package.json +106 -158
  118. package/bin/config.js +0 -1616
  119. package/dist/chunk-24B36RDB.cjs +0 -81
  120. package/dist/chunk-27N3QEX5.js +0 -40
  121. package/dist/chunk-2AVLCXLT.js +0 -0
  122. package/dist/chunk-2RLMTBVZ.js +0 -233
  123. package/dist/chunk-2WBD2G3E.cjs +0 -38
  124. package/dist/chunk-3COHMHPU.cjs +0 -1
  125. package/dist/chunk-4Q45WJYQ.js +0 -165
  126. package/dist/chunk-5C7PIENF.js +0 -92
  127. package/dist/chunk-5J2SS4QU.js +0 -83
  128. package/dist/chunk-65SWKEHV.cjs +0 -1
  129. package/dist/chunk-6Y623TCS.cjs +0 -40
  130. package/dist/chunk-7PV6L7I7.cjs +0 -1
  131. package/dist/chunk-7QBTVNMR.cjs +0 -30
  132. package/dist/chunk-BDATZ3UB.cjs +0 -233
  133. package/dist/chunk-BZRTSWH4.cjs +0 -395
  134. package/dist/chunk-D3FRXXDE.js +0 -947
  135. package/dist/chunk-DTGT4OI3.cjs +0 -14
  136. package/dist/chunk-EC2KPWRG.cjs +0 -24
  137. package/dist/chunk-EENQN6N2.js +0 -40
  138. package/dist/chunk-ENI4UUSK.cjs +0 -35
  139. package/dist/chunk-FJNXECWU.js +0 -395
  140. package/dist/chunk-FMDVBSP6.cjs +0 -83
  141. package/dist/chunk-G2MK47WL.js +0 -14
  142. package/dist/chunk-HFS7WJVW.js +0 -81
  143. package/dist/chunk-HVVJHTFS.js +0 -36
  144. package/dist/chunk-IWD6YQKX.cjs +0 -1
  145. package/dist/chunk-IWQRXQ4N.cjs +0 -84
  146. package/dist/chunk-JK4TT5IV.js +0 -35
  147. package/dist/chunk-JWLDCEBZ.cjs +0 -70
  148. package/dist/chunk-JZAYHDV3.js +0 -8
  149. package/dist/chunk-KSMN3HSC.js +0 -38
  150. package/dist/chunk-L6UNTUC4.js +0 -0
  151. package/dist/chunk-LOY6ICHZ.cjs +0 -36
  152. package/dist/chunk-MBG2FTBL.cjs +0 -47
  153. package/dist/chunk-MQG74XF7.js +0 -102
  154. package/dist/chunk-MSAQEGBK.cjs +0 -92
  155. package/dist/chunk-NJFLUTGH.cjs +0 -25
  156. package/dist/chunk-PCYB64MB.cjs +0 -40
  157. package/dist/chunk-RALMUN5C.js +0 -30
  158. package/dist/chunk-RRKB32OH.js +0 -0
  159. package/dist/chunk-RUKM6FCF.js +0 -25
  160. package/dist/chunk-SIW7AXUG.js +0 -56
  161. package/dist/chunk-SLICWTO2.cjs +0 -165
  162. package/dist/chunk-SO3FWVXC.js +0 -84
  163. package/dist/chunk-SXPH7ILL.js +0 -70
  164. package/dist/chunk-T7YISGRS.cjs +0 -102
  165. package/dist/chunk-TZZRLM5J.cjs +0 -947
  166. package/dist/chunk-UJ77IBHD.cjs +0 -233
  167. package/dist/chunk-UKGRDKIH.js +0 -0
  168. package/dist/chunk-V3GMJ4TX.js +0 -233
  169. package/dist/chunk-WQJYIPSL.cjs +0 -8
  170. package/dist/chunk-YBVOKYAM.cjs +0 -56
  171. package/dist/chunk-YX4736HU.js +0 -47
  172. package/dist/chunk-ZFNAUMQS.js +0 -24
  173. package/dist/config-file/get-config-file.js +0 -28
  174. package/dist/config-file/index.d.ts +0 -3
  175. package/dist/config-file/index.js +0 -29
  176. package/dist/create-storm-config.js +0 -35
  177. package/dist/env/get-env.js +0 -11
  178. package/dist/env/index.d.ts +0 -4
  179. package/dist/env/index.js +0 -18
  180. package/dist/env/set-env.js +0 -11
  181. package/dist/get-config.js +0 -34
  182. package/dist/index.d.ts +0 -28
  183. package/dist/index.js +0 -201
  184. package/dist/logger/chalk.d.ts +0 -34
  185. package/dist/logger/chalk.js +0 -6
  186. package/dist/logger/console-icons.d.ts +0 -8
  187. package/dist/logger/console-icons.js +0 -8
  188. package/dist/logger/console.js +0 -37
  189. package/dist/logger/create-logger.js +0 -14
  190. package/dist/logger/format-timestamp.js +0 -6
  191. package/dist/logger/get-log-level.js +0 -11
  192. package/dist/logger/index.d.ts +0 -10
  193. package/dist/logger/index.js +0 -61
  194. package/dist/logger/is-unicode-supported.d.ts +0 -3
  195. package/dist/logger/is-unicode-supported.js +0 -6
  196. package/dist/types.d.ts +0 -53
  197. package/dist/types.js +0 -8
  198. package/dist/utilities/apply-workspace-tokens.js +0 -13
  199. package/dist/utilities/colors.js +0 -12
  200. package/dist/utilities/correct-paths.js +0 -32
  201. package/dist/utilities/file-path-utils.js +0 -11
  202. package/dist/utilities/find-up.js +0 -6
  203. package/dist/utilities/find-workspace-root.js +0 -10
  204. package/dist/utilities/get-default-config.js +0 -11
  205. package/dist/utilities/index.d.ts +0 -14
  206. package/dist/utilities/index.js +0 -109
  207. package/dist/utilities/process-handler.d.ts +0 -7
  208. package/dist/utilities/process-handler.js +0 -18
  209. package/dist/utilities/run.js +0 -10
  210. package/dist/utilities/toml.d.ts +0 -189
  211. package/dist/utilities/toml.js +0 -24
@@ -1,32 +1,201 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
- var _chunkBDATZ3UBcjs = require('../chunk-BDATZ3UB.cjs');
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
- exports.basename = _chunkBDATZ3UBcjs.basename; exports.correctPaths = _chunkBDATZ3UBcjs.correctPaths; exports.dirname = _chunkBDATZ3UBcjs.dirname; exports.extname = _chunkBDATZ3UBcjs.extname; exports.format = _chunkBDATZ3UBcjs.format; exports.isAbsolute = _chunkBDATZ3UBcjs.isAbsolute; exports.joinPaths = _chunkBDATZ3UBcjs.joinPaths; exports.normalizeString = _chunkBDATZ3UBcjs.normalizeString; exports.normalizeWindowsPath = _chunkBDATZ3UBcjs.normalizeWindowsPath; exports.parse = _chunkBDATZ3UBcjs.parse; exports.relative = _chunkBDATZ3UBcjs.relative; exports.resolve = _chunkBDATZ3UBcjs.resolve; exports.sep = _chunkBDATZ3UBcjs.sep; exports.toNamespacedPath = _chunkBDATZ3UBcjs.toNamespacedPath;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/utilities/correct-paths.ts
3
+ const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
4
+ function normalizeWindowsPath(input = "") {
5
+ if (!input) return input;
6
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
7
+ }
8
+ const _UNC_REGEX = /^[/\\]{2}/;
9
+ const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
10
+ const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
11
+ const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
12
+ const _EXTNAME_RE = /.(\.[^./]+|\.)$/;
13
+ const _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/;
14
+ /**
15
+ * Constant for path separator.
16
+ *
17
+ * Always equals to `"/"`.
18
+ */
19
+ const sep = "/";
20
+ const correctPaths = function(path) {
21
+ if (!path || path.length === 0) return ".";
22
+ path = normalizeWindowsPath(path);
23
+ const isUNCPath = path?.match(_UNC_REGEX);
24
+ const isPathAbsolute = isAbsolute(path);
25
+ const trailingSeparator = path[path.length - 1] === "/";
26
+ path = normalizeString(path, !isPathAbsolute);
27
+ if (path.length === 0) {
28
+ if (isPathAbsolute) return "/";
29
+ return trailingSeparator ? "./" : ".";
30
+ }
31
+ if (trailingSeparator) path += "/";
32
+ if (_DRIVE_LETTER_RE.test(path)) path += "/";
33
+ if (isUNCPath) {
34
+ if (!isPathAbsolute) return `//./${path}`;
35
+ return `//${path}`;
36
+ }
37
+ return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
38
+ };
39
+ const joinPaths = function(...segments) {
40
+ let path = "";
41
+ for (const seg of segments) {
42
+ if (!seg) continue;
43
+ if (path.length > 0) {
44
+ const pathTrailing = path[path.length - 1] === "/";
45
+ const segLeading = seg[0] === "/";
46
+ if (pathTrailing && segLeading) path += seg.slice(1);
47
+ else path += pathTrailing || segLeading ? seg : `/${seg}`;
48
+ } else path += seg;
49
+ }
50
+ return correctPaths(path);
51
+ };
52
+ function cwd() {
53
+ if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
54
+ return "/";
55
+ }
56
+ const resolve = function(...arguments_) {
57
+ arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
58
+ let resolvedPath = "";
59
+ let resolvedAbsolute = false;
60
+ for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
61
+ const path = index >= 0 ? arguments_[index] : cwd();
62
+ if (!path || path.length === 0) continue;
63
+ resolvedPath = `${path}/${resolvedPath}`;
64
+ resolvedAbsolute = isAbsolute(path);
65
+ }
66
+ resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
67
+ if (resolvedAbsolute && !isAbsolute(resolvedPath)) return `/${resolvedPath}`;
68
+ return resolvedPath.length > 0 ? resolvedPath : ".";
69
+ };
70
+ /**
71
+ * Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
72
+ *
73
+ * @param path - The path to normalise.
74
+ * @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
75
+ * @returns the normalised path string.
76
+ */
77
+ function normalizeString(path, allowAboveRoot) {
78
+ let res = "";
79
+ let lastSegmentLength = 0;
80
+ let lastSlash = -1;
81
+ let dots = 0;
82
+ let char = null;
83
+ for (let index = 0; index <= path.length; ++index) {
84
+ if (index < path.length) char = path[index];
85
+ else if (char === "/") break;
86
+ else char = "/";
87
+ if (char === "/") {
88
+ if (lastSlash === index - 1 || dots === 1) {} else if (dots === 2) {
89
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
90
+ if (res.length > 2) {
91
+ const lastSlashIndex = res.lastIndexOf("/");
92
+ if (lastSlashIndex === -1) {
93
+ res = "";
94
+ lastSegmentLength = 0;
95
+ } else {
96
+ res = res.slice(0, lastSlashIndex);
97
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
98
+ }
99
+ lastSlash = index;
100
+ dots = 0;
101
+ continue;
102
+ } else if (res.length > 0) {
103
+ res = "";
104
+ lastSegmentLength = 0;
105
+ lastSlash = index;
106
+ dots = 0;
107
+ continue;
108
+ }
109
+ }
110
+ if (allowAboveRoot) {
111
+ res += res.length > 0 ? "/.." : "..";
112
+ lastSegmentLength = 2;
113
+ }
114
+ } else {
115
+ if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
116
+ else res = path.slice(lastSlash + 1, index);
117
+ lastSegmentLength = index - lastSlash - 1;
118
+ }
119
+ lastSlash = index;
120
+ dots = 0;
121
+ } else if (char === "." && dots !== -1) ++dots;
122
+ else dots = -1;
123
+ }
124
+ return res;
125
+ }
126
+ const isAbsolute = function(p) {
127
+ return _IS_ABSOLUTE_RE.test(p);
128
+ };
129
+ const toNamespacedPath = function(p) {
130
+ return normalizeWindowsPath(p);
131
+ };
132
+ const extname = function(p) {
133
+ if (p === "..") return "";
134
+ const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
135
+ return match && match[1] || "";
136
+ };
137
+ const relative = function(from, to) {
138
+ const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
139
+ const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
140
+ if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) return _to.join("/");
141
+ const _fromCopy = [..._from];
142
+ for (const segment of _fromCopy) {
143
+ if (_to[0] !== segment) break;
144
+ _from.shift();
145
+ _to.shift();
146
+ }
147
+ return [..._from.map(() => ".."), ..._to].join("/");
148
+ };
149
+ const dirname = function(p) {
150
+ const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
151
+ if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
152
+ return segments.join("/") || (isAbsolute(p) ? "/" : ".");
153
+ };
154
+ const format = function(p) {
155
+ const ext = p.ext ? p.ext.startsWith(".") ? p.ext : `.${p.ext}` : "";
156
+ const segments = [
157
+ p.root,
158
+ p.dir,
159
+ p.base ?? (p.name ?? "") + ext
160
+ ].filter(Boolean);
161
+ return normalizeWindowsPath(p.root ? resolve(...segments) : segments.join("/"));
162
+ };
163
+ const basename = function(p, extension) {
164
+ const segments = normalizeWindowsPath(p).split("/");
165
+ let lastSegment = "";
166
+ for (let i = segments.length - 1; i >= 0; i--) {
167
+ const val = segments[i];
168
+ if (val) {
169
+ lastSegment = val;
170
+ break;
171
+ }
172
+ }
173
+ return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
174
+ };
175
+ const parse = function(p) {
176
+ const root = _PATH_ROOT_RE.exec(p)?.[0]?.replace(/\\/g, "/") || "";
177
+ const base = basename(p);
178
+ const extension = extname(base);
179
+ return {
180
+ root,
181
+ dir: dirname(p),
182
+ base,
183
+ ext: extension,
184
+ name: base.slice(0, base.length - extension.length)
185
+ };
186
+ };
187
+ //#endregion
188
+ exports.basename = basename;
189
+ exports.correctPaths = correctPaths;
190
+ exports.dirname = dirname;
191
+ exports.extname = extname;
192
+ exports.format = format;
193
+ exports.isAbsolute = isAbsolute;
194
+ exports.joinPaths = joinPaths;
195
+ exports.normalizeString = normalizeString;
196
+ exports.normalizeWindowsPath = normalizeWindowsPath;
197
+ exports.parse = parse;
198
+ exports.relative = relative;
199
+ exports.resolve = resolve;
200
+ exports.sep = sep;
201
+ exports.toNamespacedPath = toNamespacedPath;
@@ -1,5 +1,5 @@
1
- import path from 'node:path';
2
-
1
+ import path from "node:path";
2
+ //#region src/utilities/correct-paths.d.ts
3
3
  declare function normalizeWindowsPath(input?: string): string;
4
4
  /**
5
5
  * Constant for path separator.
@@ -26,5 +26,5 @@ declare const dirname: typeof path.dirname;
26
26
  declare const format: typeof path.format;
27
27
  declare const basename: typeof path.basename;
28
28
  declare const parse: typeof path.parse;
29
-
30
- export { basename, correctPaths, dirname, extname, format, isAbsolute, joinPaths, normalizeString, normalizeWindowsPath, parse, relative, resolve, sep, toNamespacedPath };
29
+ //#endregion
30
+ export { basename, correctPaths, dirname, extname, format, isAbsolute, joinPaths, normalizeString, normalizeWindowsPath, parse, relative, resolve, sep, toNamespacedPath };
@@ -1,5 +1,7 @@
1
- import path from 'node:path';
2
-
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
3
+ import path from "node:path";
4
+ //#region src/utilities/correct-paths.d.ts
3
5
  declare function normalizeWindowsPath(input?: string): string;
4
6
  /**
5
7
  * Constant for path separator.
@@ -26,5 +28,5 @@ declare const dirname: typeof path.dirname;
26
28
  declare const format: typeof path.format;
27
29
  declare const basename: typeof path.basename;
28
30
  declare const parse: typeof path.parse;
29
-
30
- export { basename, correctPaths, dirname, extname, format, isAbsolute, joinPaths, normalizeString, normalizeWindowsPath, parse, relative, resolve, sep, toNamespacedPath };
31
+ //#endregion
32
+ export { basename, correctPaths, dirname, extname, format, isAbsolute, joinPaths, normalizeString, normalizeWindowsPath, parse, relative, resolve, sep, toNamespacedPath };
@@ -0,0 +1,190 @@
1
+ import "node:path";
2
+ import "node:url";
3
+ import.meta.url;
4
+ //#region src/utilities/correct-paths.ts
5
+ const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
6
+ function normalizeWindowsPath(input = "") {
7
+ if (!input) return input;
8
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
9
+ }
10
+ const _UNC_REGEX = /^[/\\]{2}/;
11
+ const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
12
+ const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
13
+ const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
14
+ const _EXTNAME_RE = /.(\.[^./]+|\.)$/;
15
+ const _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/;
16
+ /**
17
+ * Constant for path separator.
18
+ *
19
+ * Always equals to `"/"`.
20
+ */
21
+ const sep = "/";
22
+ const correctPaths = function(path) {
23
+ if (!path || path.length === 0) return ".";
24
+ path = normalizeWindowsPath(path);
25
+ const isUNCPath = path?.match(_UNC_REGEX);
26
+ const isPathAbsolute = isAbsolute(path);
27
+ const trailingSeparator = path[path.length - 1] === "/";
28
+ path = normalizeString(path, !isPathAbsolute);
29
+ if (path.length === 0) {
30
+ if (isPathAbsolute) return "/";
31
+ return trailingSeparator ? "./" : ".";
32
+ }
33
+ if (trailingSeparator) path += "/";
34
+ if (_DRIVE_LETTER_RE.test(path)) path += "/";
35
+ if (isUNCPath) {
36
+ if (!isPathAbsolute) return `//./${path}`;
37
+ return `//${path}`;
38
+ }
39
+ return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
40
+ };
41
+ const joinPaths = function(...segments) {
42
+ let path = "";
43
+ for (const seg of segments) {
44
+ if (!seg) continue;
45
+ if (path.length > 0) {
46
+ const pathTrailing = path[path.length - 1] === "/";
47
+ const segLeading = seg[0] === "/";
48
+ if (pathTrailing && segLeading) path += seg.slice(1);
49
+ else path += pathTrailing || segLeading ? seg : `/${seg}`;
50
+ } else path += seg;
51
+ }
52
+ return correctPaths(path);
53
+ };
54
+ function cwd() {
55
+ if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
56
+ return "/";
57
+ }
58
+ const resolve = function(...arguments_) {
59
+ arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
60
+ let resolvedPath = "";
61
+ let resolvedAbsolute = false;
62
+ for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
63
+ const path = index >= 0 ? arguments_[index] : cwd();
64
+ if (!path || path.length === 0) continue;
65
+ resolvedPath = `${path}/${resolvedPath}`;
66
+ resolvedAbsolute = isAbsolute(path);
67
+ }
68
+ resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
69
+ if (resolvedAbsolute && !isAbsolute(resolvedPath)) return `/${resolvedPath}`;
70
+ return resolvedPath.length > 0 ? resolvedPath : ".";
71
+ };
72
+ /**
73
+ * Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
74
+ *
75
+ * @param path - The path to normalise.
76
+ * @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
77
+ * @returns the normalised path string.
78
+ */
79
+ function normalizeString(path, allowAboveRoot) {
80
+ let res = "";
81
+ let lastSegmentLength = 0;
82
+ let lastSlash = -1;
83
+ let dots = 0;
84
+ let char = null;
85
+ for (let index = 0; index <= path.length; ++index) {
86
+ if (index < path.length) char = path[index];
87
+ else if (char === "/") break;
88
+ else char = "/";
89
+ if (char === "/") {
90
+ if (lastSlash === index - 1 || dots === 1) {} else if (dots === 2) {
91
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
92
+ if (res.length > 2) {
93
+ const lastSlashIndex = res.lastIndexOf("/");
94
+ if (lastSlashIndex === -1) {
95
+ res = "";
96
+ lastSegmentLength = 0;
97
+ } else {
98
+ res = res.slice(0, lastSlashIndex);
99
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
100
+ }
101
+ lastSlash = index;
102
+ dots = 0;
103
+ continue;
104
+ } else if (res.length > 0) {
105
+ res = "";
106
+ lastSegmentLength = 0;
107
+ lastSlash = index;
108
+ dots = 0;
109
+ continue;
110
+ }
111
+ }
112
+ if (allowAboveRoot) {
113
+ res += res.length > 0 ? "/.." : "..";
114
+ lastSegmentLength = 2;
115
+ }
116
+ } else {
117
+ if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
118
+ else res = path.slice(lastSlash + 1, index);
119
+ lastSegmentLength = index - lastSlash - 1;
120
+ }
121
+ lastSlash = index;
122
+ dots = 0;
123
+ } else if (char === "." && dots !== -1) ++dots;
124
+ else dots = -1;
125
+ }
126
+ return res;
127
+ }
128
+ const isAbsolute = function(p) {
129
+ return _IS_ABSOLUTE_RE.test(p);
130
+ };
131
+ const toNamespacedPath = function(p) {
132
+ return normalizeWindowsPath(p);
133
+ };
134
+ const extname = function(p) {
135
+ if (p === "..") return "";
136
+ const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
137
+ return match && match[1] || "";
138
+ };
139
+ const relative = function(from, to) {
140
+ const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
141
+ const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
142
+ if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) return _to.join("/");
143
+ const _fromCopy = [..._from];
144
+ for (const segment of _fromCopy) {
145
+ if (_to[0] !== segment) break;
146
+ _from.shift();
147
+ _to.shift();
148
+ }
149
+ return [..._from.map(() => ".."), ..._to].join("/");
150
+ };
151
+ const dirname = function(p) {
152
+ const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
153
+ if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
154
+ return segments.join("/") || (isAbsolute(p) ? "/" : ".");
155
+ };
156
+ const format = function(p) {
157
+ const ext = p.ext ? p.ext.startsWith(".") ? p.ext : `.${p.ext}` : "";
158
+ const segments = [
159
+ p.root,
160
+ p.dir,
161
+ p.base ?? (p.name ?? "") + ext
162
+ ].filter(Boolean);
163
+ return normalizeWindowsPath(p.root ? resolve(...segments) : segments.join("/"));
164
+ };
165
+ const basename = function(p, extension) {
166
+ const segments = normalizeWindowsPath(p).split("/");
167
+ let lastSegment = "";
168
+ for (let i = segments.length - 1; i >= 0; i--) {
169
+ const val = segments[i];
170
+ if (val) {
171
+ lastSegment = val;
172
+ break;
173
+ }
174
+ }
175
+ return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
176
+ };
177
+ const parse = function(p) {
178
+ const root = _PATH_ROOT_RE.exec(p)?.[0]?.replace(/\\/g, "/") || "";
179
+ const base = basename(p);
180
+ const extension = extname(base);
181
+ return {
182
+ root,
183
+ dir: dirname(p),
184
+ base,
185
+ ext: extension,
186
+ name: base.slice(0, base.length - extension.length)
187
+ };
188
+ };
189
+ //#endregion
190
+ export { basename, correctPaths, dirname, extname, format, isAbsolute, joinPaths, normalizeString, normalizeWindowsPath, parse, relative, resolve, sep, toNamespacedPath };
@@ -1,11 +1,48 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
-
5
- var _chunk2WBD2G3Ecjs = require('../chunk-2WBD2G3E.cjs');
6
- require('../chunk-BDATZ3UB.cjs');
7
-
8
-
9
-
10
-
11
- exports.findFileName = _chunk2WBD2G3Ecjs.findFileName; exports.findFilePath = _chunk2WBD2G3Ecjs.findFilePath; exports.removeExtension = _chunk2WBD2G3Ecjs.removeExtension;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_utilities_correct_paths = require("./correct-paths.cjs");
3
+ //#region src/utilities/file-path-utils.ts
4
+ const removeExtension = (filePath) => {
5
+ const result = !filePath || (filePath?.match(/./g) || []).length <= 1 ? "." : filePath.lastIndexOf(".") ? filePath.substring(0, filePath.lastIndexOf(".")) : filePath;
6
+ if (result.startsWith("./")) return result.substring(2);
7
+ if (result.startsWith(".") || result.startsWith("/")) return result.substring(1);
8
+ return result;
9
+ };
10
+ /**
11
+ * Find the file name from a file path.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const fileName = findFileName("C:\\Users\\user\\Documents\\file.txt");
16
+ * // fileName = "file.txt"
17
+ * ```
18
+ *
19
+ * @param filePath - The file path to process
20
+ * @param options - The options to use when processing the file name
21
+ * @returns The file name
22
+ */
23
+ function findFileName(filePath, { requireExtension, withExtension } = {}) {
24
+ const result = require_utilities_correct_paths.normalizeWindowsPath(filePath)?.split(filePath?.includes("\\") ? "\\" : "/")?.pop() ?? "";
25
+ if (requireExtension === true && !result.includes(".")) return "";
26
+ if (withExtension === false && result.includes(".")) return result.split(".").slice(-1).join(".") || "";
27
+ return result;
28
+ }
29
+ /**
30
+ * Find the full file path's directories from a file path.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * const folderPath = findFilePath("C:\\Users\\user\\Documents\\file.txt");
35
+ * // folderPath = "C:\\Users\\user\\Documents"
36
+ * ```
37
+ *
38
+ * @param filePath - The file path to process
39
+ * @returns The full file path's directories
40
+ */
41
+ function findFilePath(filePath) {
42
+ const normalizedPath = require_utilities_correct_paths.normalizeWindowsPath(filePath);
43
+ return normalizedPath.replace(findFileName(normalizedPath, { requireExtension: true }), "");
44
+ }
45
+ //#endregion
46
+ exports.findFileName = findFileName;
47
+ exports.findFilePath = findFilePath;
48
+ exports.removeExtension = removeExtension;
@@ -1,17 +1,18 @@
1
+ //#region src/utilities/file-path-utils.d.ts
1
2
  declare const removeExtension: (filePath?: string) => string;
2
3
  interface FindFileNameOptions {
3
- /**
4
- * Require the file extension to be present in the file name.
5
- *
6
- * @defaultValue false
7
- */
8
- requireExtension?: boolean;
9
- /**
10
- * Return the file extension as part of the full file name result.
11
- *
12
- * @defaultValue true
13
- */
14
- withExtension?: boolean;
4
+ /**
5
+ * Require the file extension to be present in the file name.
6
+ *
7
+ * @defaultValue false
8
+ */
9
+ requireExtension?: boolean;
10
+ /**
11
+ * Return the file extension as part of the full file name result.
12
+ *
13
+ * @defaultValue true
14
+ */
15
+ withExtension?: boolean;
15
16
  }
16
17
  /**
17
18
  * Find the file name from a file path.
@@ -40,5 +41,5 @@ declare function findFileName(filePath: string, { requireExtension, withExtensio
40
41
  * @returns The full file path's directories
41
42
  */
42
43
  declare function findFilePath(filePath: string): string;
43
-
44
- export { type FindFileNameOptions, findFileName, findFilePath, removeExtension };
44
+ //#endregion
45
+ export { FindFileNameOptions, findFileName, findFilePath, removeExtension };
@@ -1,17 +1,20 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
3
+ //#region src/utilities/file-path-utils.d.ts
1
4
  declare const removeExtension: (filePath?: string) => string;
2
5
  interface FindFileNameOptions {
3
- /**
4
- * Require the file extension to be present in the file name.
5
- *
6
- * @defaultValue false
7
- */
8
- requireExtension?: boolean;
9
- /**
10
- * Return the file extension as part of the full file name result.
11
- *
12
- * @defaultValue true
13
- */
14
- withExtension?: boolean;
6
+ /**
7
+ * Require the file extension to be present in the file name.
8
+ *
9
+ * @defaultValue false
10
+ */
11
+ requireExtension?: boolean;
12
+ /**
13
+ * Return the file extension as part of the full file name result.
14
+ *
15
+ * @defaultValue true
16
+ */
17
+ withExtension?: boolean;
15
18
  }
16
19
  /**
17
20
  * Find the file name from a file path.
@@ -40,5 +43,5 @@ declare function findFileName(filePath: string, { requireExtension, withExtensio
40
43
  * @returns The full file path's directories
41
44
  */
42
45
  declare function findFilePath(filePath: string): string;
43
-
44
- export { type FindFileNameOptions, findFileName, findFilePath, removeExtension };
46
+ //#endregion
47
+ export { FindFileNameOptions, findFileName, findFilePath, removeExtension };
@@ -0,0 +1,48 @@
1
+ import "node:path";
2
+ import "node:url";
3
+ import.meta.url;
4
+ import { normalizeWindowsPath } from "./correct-paths.mjs";
5
+ //#region src/utilities/file-path-utils.ts
6
+ const removeExtension = (filePath) => {
7
+ const result = !filePath || (filePath?.match(/./g) || []).length <= 1 ? "." : filePath.lastIndexOf(".") ? filePath.substring(0, filePath.lastIndexOf(".")) : filePath;
8
+ if (result.startsWith("./")) return result.substring(2);
9
+ if (result.startsWith(".") || result.startsWith("/")) return result.substring(1);
10
+ return result;
11
+ };
12
+ /**
13
+ * Find the file name from a file path.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const fileName = findFileName("C:\\Users\\user\\Documents\\file.txt");
18
+ * // fileName = "file.txt"
19
+ * ```
20
+ *
21
+ * @param filePath - The file path to process
22
+ * @param options - The options to use when processing the file name
23
+ * @returns The file name
24
+ */
25
+ function findFileName(filePath, { requireExtension, withExtension } = {}) {
26
+ const result = normalizeWindowsPath(filePath)?.split(filePath?.includes("\\") ? "\\" : "/")?.pop() ?? "";
27
+ if (requireExtension === true && !result.includes(".")) return "";
28
+ if (withExtension === false && result.includes(".")) return result.split(".").slice(-1).join(".") || "";
29
+ return result;
30
+ }
31
+ /**
32
+ * Find the full file path's directories from a file path.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * const folderPath = findFilePath("C:\\Users\\user\\Documents\\file.txt");
37
+ * // folderPath = "C:\\Users\\user\\Documents"
38
+ * ```
39
+ *
40
+ * @param filePath - The file path to process
41
+ * @returns The full file path's directories
42
+ */
43
+ function findFilePath(filePath) {
44
+ const normalizedPath = normalizeWindowsPath(filePath);
45
+ return normalizedPath.replace(findFileName(normalizedPath, { requireExtension: true }), "");
46
+ }
47
+ //#endregion
48
+ export { findFileName, findFilePath, removeExtension };
@@ -1,6 +1,17 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunkNJFLUTGHcjs = require('../chunk-NJFLUTGH.cjs');
4
-
5
-
6
- exports.findFolderUp = _chunkNJFLUTGHcjs.findFolderUp;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let node_fs = require("node:fs");
3
+ let node_path = require("node:path");
4
+ //#region src/utilities/find-up.ts
5
+ const MAX_PATH_SEARCH_DEPTH = 30;
6
+ let depth = 0;
7
+ /**
8
+ * Gets the nearest "node_modules" folder by walking up from start path.
9
+ */
10
+ function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) {
11
+ const _startPath = startPath ?? process.cwd();
12
+ if (endDirectoryNames.some((endDirName) => (0, node_fs.existsSync)((0, node_path.join)(_startPath, endDirName)))) return _startPath;
13
+ if (endFileNames.some((endFileName) => (0, node_fs.existsSync)((0, node_path.join)(_startPath, endFileName)))) return _startPath;
14
+ if (_startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) return findFolderUp((0, node_path.join)(_startPath, ".."), endFileNames, endDirectoryNames);
15
+ }
16
+ //#endregion
17
+ exports.findFolderUp = findFolderUp;