@stryke/fs 0.33.70 → 0.33.71

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 (196) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +1 -1
  3. package/dist/buffer.cjs +5 -4
  4. package/dist/buffer.d.cts.map +1 -1
  5. package/dist/buffer.d.mts.map +1 -1
  6. package/dist/buffer.mjs +1 -1
  7. package/dist/chmod-x.cjs +2 -1
  8. package/dist/chmod-x.d.cts.map +1 -1
  9. package/dist/chmod-x.d.mts.map +1 -1
  10. package/dist/chmod-x.mjs.map +1 -1
  11. package/dist/command-exists.cjs +3 -2
  12. package/dist/command-exists.d.cts.map +1 -1
  13. package/dist/command-exists.d.mts.map +1 -1
  14. package/dist/command-exists.mjs +1 -1
  15. package/dist/command-exists.mjs.map +1 -1
  16. package/dist/compress.cjs +7 -7
  17. package/dist/compress.d.cts.map +1 -1
  18. package/dist/compress.d.mts.map +1 -1
  19. package/dist/compress.mjs +5 -6
  20. package/dist/compress.mjs.map +1 -1
  21. package/dist/constants.d.cts.map +1 -1
  22. package/dist/constants.d.mts.map +1 -1
  23. package/dist/copy-file.cjs +16 -15
  24. package/dist/copy-file.d.cts +0 -1
  25. package/dist/copy-file.d.cts.map +1 -1
  26. package/dist/copy-file.d.mts +0 -1
  27. package/dist/copy-file.d.mts.map +1 -1
  28. package/dist/copy-file.mjs +6 -6
  29. package/dist/exists.cjs +2 -1
  30. package/dist/exists.d.cts.map +1 -1
  31. package/dist/exists.d.mts.map +1 -1
  32. package/dist/get-parent-path.cjs +14 -13
  33. package/dist/get-parent-path.d.cts.map +1 -1
  34. package/dist/get-parent-path.d.mts.map +1 -1
  35. package/dist/get-parent-path.mjs +6 -6
  36. package/dist/get-parent-path.mjs.map +1 -1
  37. package/dist/get-workspace-root.cjs +14 -13
  38. package/dist/get-workspace-root.d.cts.map +1 -1
  39. package/dist/get-workspace-root.d.mts.map +1 -1
  40. package/dist/get-workspace-root.mjs +3 -3
  41. package/dist/get-workspace-root.mjs.map +1 -1
  42. package/dist/helpers.cjs +2 -1
  43. package/dist/helpers.d.cts.map +1 -1
  44. package/dist/helpers.d.mts.map +1 -1
  45. package/dist/helpers.mjs.map +1 -1
  46. package/dist/index.cjs +1 -0
  47. package/dist/install.cjs +6 -5
  48. package/dist/install.d.cts +0 -2
  49. package/dist/install.d.cts.map +1 -1
  50. package/dist/install.d.mts +0 -3
  51. package/dist/install.d.mts.map +1 -1
  52. package/dist/install.mjs +1 -1
  53. package/dist/is-file.cjs +7 -6
  54. package/dist/is-file.d.cts.map +1 -1
  55. package/dist/is-file.d.mts.map +1 -1
  56. package/dist/is-file.mjs +1 -1
  57. package/dist/json/src/storm-json.cjs +3 -3
  58. package/dist/json/src/storm-json.mjs +1 -1
  59. package/dist/json/src/storm-json.mjs.map +1 -1
  60. package/dist/json/src/types.d.cts +0 -1
  61. package/dist/json/src/types.d.cts.map +1 -1
  62. package/dist/json/src/types.d.mts +0 -1
  63. package/dist/json/src/types.d.mts.map +1 -1
  64. package/dist/json/src/utils/code-frames.mjs.map +1 -1
  65. package/dist/json/src/utils/parse-error.cjs +1 -1
  66. package/dist/json/src/utils/stringify.mjs.map +1 -1
  67. package/dist/json/src/utils/strip-comments.cjs +4 -5
  68. package/dist/json/src/utils/strip-comments.mjs +4 -6
  69. package/dist/json/src/utils/strip-comments.mjs.map +1 -1
  70. package/dist/json.cjs +6 -4
  71. package/dist/json.d.cts +0 -1
  72. package/dist/json.d.cts.map +1 -1
  73. package/dist/json.d.mts +0 -1
  74. package/dist/json.d.mts.map +1 -1
  75. package/dist/json.mjs +2 -2
  76. package/dist/list-files.cjs +6 -5
  77. package/dist/list-files.d.cts.map +1 -1
  78. package/dist/list-files.d.mts.map +1 -1
  79. package/dist/list-files.mjs +1 -1
  80. package/dist/list-files.mjs.map +1 -1
  81. package/dist/package-fns.cjs +12 -11
  82. package/dist/package-fns.d.cts +0 -1
  83. package/dist/package-fns.d.cts.map +1 -1
  84. package/dist/package-fns.d.mts +0 -1
  85. package/dist/package-fns.d.mts.map +1 -1
  86. package/dist/package-fns.mjs +4 -4
  87. package/dist/read-file.cjs +2 -1
  88. package/dist/read-file.d.cts.map +1 -1
  89. package/dist/read-file.d.mts.map +1 -1
  90. package/dist/registry.cjs +4 -3
  91. package/dist/registry.d.cts.map +1 -1
  92. package/dist/registry.d.mts.map +1 -1
  93. package/dist/registry.mjs.map +1 -1
  94. package/dist/remove-file.cjs +2 -1
  95. package/dist/remove-file.d.cts.map +1 -1
  96. package/dist/remove-file.d.mts.map +1 -1
  97. package/dist/resolve.cjs +38 -37
  98. package/dist/resolve.d.cts.map +1 -1
  99. package/dist/resolve.d.mts.map +1 -1
  100. package/dist/resolve.mjs +18 -18
  101. package/dist/resolve.mjs.map +1 -1
  102. package/dist/semver-fns.cjs +5 -4
  103. package/dist/semver-fns.d.cts.map +1 -1
  104. package/dist/semver-fns.d.mts.map +1 -1
  105. package/dist/semver-fns.mjs +1 -1
  106. package/dist/semver-fns.mjs.map +1 -1
  107. package/dist/toml.cjs +3 -2
  108. package/dist/toml.d.cts +3 -4
  109. package/dist/toml.d.cts.map +1 -1
  110. package/dist/toml.d.mts +3 -4
  111. package/dist/toml.d.mts.map +1 -1
  112. package/dist/tsconfig.cjs +13 -12
  113. package/dist/tsconfig.d.cts +0 -1
  114. package/dist/tsconfig.d.cts.map +1 -1
  115. package/dist/tsconfig.d.mts +0 -1
  116. package/dist/tsconfig.d.mts.map +1 -1
  117. package/dist/tsconfig.mjs +5 -5
  118. package/dist/type-checks/src/index.cjs +3 -3
  119. package/dist/type-checks/src/index.mjs +3 -3
  120. package/dist/type-checks/src/is-buffer.cjs +2 -2
  121. package/dist/type-checks/src/is-buffer.mjs +1 -1
  122. package/dist/type-checks/src/is-buffer.mjs.map +1 -1
  123. package/dist/type-checks/src/is-set-string.cjs +1 -1
  124. package/dist/type-checks/src/is-set-string.mjs +1 -1
  125. package/dist/types/src/file.d.cts +0 -1
  126. package/dist/types/src/file.d.cts.map +1 -1
  127. package/dist/types/src/file.d.mts +0 -1
  128. package/dist/types/src/file.d.mts.map +1 -1
  129. package/dist/types/src/package-json.d.cts.map +1 -1
  130. package/dist/types/src/package-json.d.mts.map +1 -1
  131. package/dist/types/src/package-manager.d.cts.map +1 -1
  132. package/dist/types/src/package-manager.d.mts.map +1 -1
  133. package/dist/types/src/tsconfig.d.cts.map +1 -1
  134. package/dist/types/src/tsconfig.d.mts.map +1 -1
  135. package/dist/write-file.cjs +6 -5
  136. package/dist/write-file.d.cts.map +1 -1
  137. package/dist/write-file.d.mts.map +1 -1
  138. package/dist/write-file.mjs +2 -2
  139. package/dist/yaml.cjs +2 -1
  140. package/dist/yaml.d.cts.map +1 -1
  141. package/dist/yaml.d.mts.map +1 -1
  142. package/package.json +139 -58
  143. package/dist/convert/src/array-buffer-to-string.cjs +0 -19
  144. package/dist/convert/src/array-buffer-to-string.mjs +0 -19
  145. package/dist/convert/src/array-buffer-to-string.mjs.map +0 -1
  146. package/dist/convert/src/to-array.cjs +0 -15
  147. package/dist/convert/src/to-array.mjs +0 -15
  148. package/dist/convert/src/to-array.mjs.map +0 -1
  149. package/dist/convert/src/uint8-array-to-string.cjs +0 -15
  150. package/dist/convert/src/uint8-array-to-string.mjs +0 -16
  151. package/dist/convert/src/uint8-array-to-string.mjs.map +0 -1
  152. package/dist/helpers/src/get-unique.cjs +0 -14
  153. package/dist/helpers/src/get-unique.mjs +0 -14
  154. package/dist/helpers/src/get-unique.mjs.map +0 -1
  155. package/dist/path/src/append.cjs +0 -57
  156. package/dist/path/src/append.mjs +0 -57
  157. package/dist/path/src/append.mjs.map +0 -1
  158. package/dist/path/src/correct-path.cjs +0 -138
  159. package/dist/path/src/correct-path.mjs +0 -135
  160. package/dist/path/src/correct-path.mjs.map +0 -1
  161. package/dist/path/src/cwd.cjs +0 -17
  162. package/dist/path/src/cwd.mjs +0 -17
  163. package/dist/path/src/cwd.mjs.map +0 -1
  164. package/dist/path/src/file-path-fns.cjs +0 -178
  165. package/dist/path/src/file-path-fns.mjs +0 -171
  166. package/dist/path/src/file-path-fns.mjs.map +0 -1
  167. package/dist/path/src/is-parent-path.cjs +0 -32
  168. package/dist/path/src/is-parent-path.mjs +0 -33
  169. package/dist/path/src/is-parent-path.mjs.map +0 -1
  170. package/dist/path/src/is-root-dir.cjs +0 -14
  171. package/dist/path/src/is-root-dir.mjs +0 -14
  172. package/dist/path/src/is-root-dir.mjs.map +0 -1
  173. package/dist/path/src/is-type.cjs +0 -68
  174. package/dist/path/src/is-type.mjs +0 -67
  175. package/dist/path/src/is-type.mjs.map +0 -1
  176. package/dist/path/src/join-paths.cjs +0 -122
  177. package/dist/path/src/join-paths.mjs +0 -123
  178. package/dist/path/src/join-paths.mjs.map +0 -1
  179. package/dist/path/src/regex.cjs +0 -20
  180. package/dist/path/src/regex.mjs +0 -13
  181. package/dist/path/src/regex.mjs.map +0 -1
  182. package/dist/path/src/replace.cjs +0 -24
  183. package/dist/path/src/replace.mjs +0 -25
  184. package/dist/path/src/replace.mjs.map +0 -1
  185. package/dist/path/src/resolve-parent-path.cjs +0 -18
  186. package/dist/path/src/resolve-parent-path.mjs +0 -19
  187. package/dist/path/src/resolve-parent-path.mjs.map +0 -1
  188. package/dist/path/src/slash.cjs +0 -15
  189. package/dist/path/src/slash.mjs +0 -15
  190. package/dist/path/src/slash.mjs.map +0 -1
  191. package/dist/string-format/src/package.cjs +0 -92
  192. package/dist/string-format/src/package.mjs +0 -92
  193. package/dist/string-format/src/package.mjs.map +0 -1
  194. package/dist/types/src/base.cjs +0 -6
  195. package/dist/types/src/base.mjs +0 -6
  196. package/dist/types/src/base.mjs.map +0 -1
package/dist/resolve.cjs CHANGED
@@ -1,14 +1,15 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
- const require_cwd = require('./path/src/cwd.cjs');
3
- const require_is_type = require('./path/src/is-type.cjs');
4
- const require_join_paths = require('./path/src/join-paths.cjs');
5
- const require_append = require('./path/src/append.cjs');
6
- const require_correct_path = require('./path/src/correct-path.cjs');
7
- const require_file_path_fns = require('./path/src/file-path-fns.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
8
3
  const require_exists = require('./exists.cjs');
9
4
  const require_get_workspace_root = require('./get-workspace-root.cjs');
10
- const require_get_unique = require('./helpers/src/get-unique.cjs');
5
+ let _stryke_path = require("@stryke/path");
6
+ let _stryke_path_join_paths = require("@stryke/path/join-paths");
7
+ let _stryke_path_correct_path = require("@stryke/path/correct-path");
8
+ let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
11
9
  let mlly = require("mlly");
10
+ let _stryke_path_cwd = require("@stryke/path/cwd");
11
+ let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
12
+ let _stryke_path_is_type = require("@stryke/path/is-type");
12
13
 
13
14
  //#region src/resolve.ts
14
15
  const DEFAULT_EXTENSIONS = [
@@ -33,16 +34,16 @@ const DEFAULT_EXTENSIONS = [
33
34
  */
34
35
  function getResolutionPaths(paths = []) {
35
36
  let resolutionPaths = paths;
36
- if (!resolutionPaths.includes(require_cwd.cwd())) resolutionPaths.push(require_cwd.cwd());
37
+ if (!resolutionPaths.includes((0, _stryke_path_cwd.cwd)())) resolutionPaths.push((0, _stryke_path_cwd.cwd)());
37
38
  const workspaceRoot = require_get_workspace_root.getWorkspaceRoot();
38
39
  if (!resolutionPaths.includes(workspaceRoot)) resolutionPaths.push(workspaceRoot);
39
- resolutionPaths = require_get_unique.getUnique(resolutionPaths.filter(Boolean).map((path) => require_correct_path.correctPath(path)).reduce((ret, path, _, arr) => {
40
+ resolutionPaths = (0, _stryke_helpers_get_unique.getUnique)(resolutionPaths.filter(Boolean).map((path) => (0, _stryke_path_correct_path.correctPath)(path)).reduce((ret, path, _, arr) => {
40
41
  ret.push(path);
41
- if (!require_is_type.isAbsolutePath(path)) {
42
- ret.push(require_correct_path.toAbsolutePath(path, require_cwd.cwd()));
43
- ret.push(require_correct_path.toAbsolutePath(path, workspaceRoot));
42
+ if (!(0, _stryke_path_is_type.isAbsolutePath)(path)) {
43
+ ret.push((0, _stryke_path_correct_path.toAbsolutePath)(path, (0, _stryke_path_cwd.cwd)()));
44
+ ret.push((0, _stryke_path_correct_path.toAbsolutePath)(path, workspaceRoot));
44
45
  arr.forEach((existing) => {
45
- ret.push(require_correct_path.toAbsolutePath(path, existing));
46
+ ret.push((0, _stryke_path_correct_path.toAbsolutePath)(path, existing));
46
47
  });
47
48
  }
48
49
  return ret;
@@ -56,9 +57,9 @@ function getResolutionPaths(paths = []) {
56
57
  * @returns An array of unique, corrected node_modules resolution paths.
57
58
  */
58
59
  function getNodeModulesPaths(paths = []) {
59
- return require_get_unique.getUnique(paths.reduce((ret, path) => {
60
- if (require_file_path_fns.findFolderName(path) === "node_modules") ret.push(require_correct_path.correctPath(path));
61
- if (require_exists.existsSync(require_join_paths.joinPaths(path, "node_modules"))) ret.push(require_correct_path.correctPath(require_join_paths.joinPaths(path, "node_modules")));
60
+ return (0, _stryke_helpers_get_unique.getUnique)(paths.reduce((ret, path) => {
61
+ if ((0, _stryke_path_file_path_fns.findFolderName)(path) === "node_modules") ret.push((0, _stryke_path_correct_path.correctPath)(path));
62
+ if (require_exists.existsSync((0, _stryke_path_join_paths.joinPaths)(path, "node_modules"))) ret.push((0, _stryke_path_correct_path.correctPath)((0, _stryke_path_join_paths.joinPaths)(path, "node_modules")));
62
63
  return ret;
63
64
  }, []));
64
65
  }
@@ -71,33 +72,33 @@ function getNodeModulesPaths(paths = []) {
71
72
  */
72
73
  function getResolutionCombinations(path, options = {}) {
73
74
  let paths = options.useAdditionalPaths ? getResolutionPaths(options.paths) : options.paths ?? [];
74
- if (require_is_type.isNpmScopedPackage(path)) paths = getNodeModulesPaths(paths);
75
+ if ((0, _stryke_path_is_type.isNpmScopedPackage)(path)) paths = getNodeModulesPaths(paths);
75
76
  else paths.push(...getNodeModulesPaths(paths));
76
- let combinations = paths.map((base) => require_join_paths.joinPaths(base, path));
77
- if (require_file_path_fns.findFileName(path, { withExtension: false }) !== "index") combinations = combinations.reduce((ret, combination) => {
77
+ let combinations = paths.map((base) => (0, _stryke_path_join_paths.joinPaths)(base, path));
78
+ if ((0, _stryke_path_file_path_fns.findFileName)(path, { withExtension: false }) !== "index") combinations = combinations.reduce((ret, combination) => {
78
79
  ret.push(combination);
79
- ret.push(require_join_paths.joinPaths(combination, "index"));
80
+ ret.push((0, _stryke_path_join_paths.joinPaths)(combination, "index"));
80
81
  return ret;
81
82
  }, []);
82
- if (!require_file_path_fns.hasFileExtension(path)) {
83
+ if (!(0, _stryke_path_file_path_fns.hasFileExtension)(path)) {
83
84
  const extensions = options.extensions ?? DEFAULT_EXTENSIONS;
84
85
  combinations = combinations.reduce((ret, combination) => {
85
86
  ret.push(combination);
86
87
  extensions.forEach((ext) => {
87
- ret.push(require_append.appendExtension(combination, ext));
88
+ ret.push((0, _stryke_path.appendExtension)(combination, ext));
88
89
  });
89
90
  return ret;
90
91
  }, []);
91
- combinations.push(...extensions.map((ext) => getResolutionCombinations(require_append.appendExtension(path, ext), options)).flat());
92
+ combinations.push(...extensions.map((ext) => getResolutionCombinations((0, _stryke_path.appendExtension)(path, ext), options)).flat());
92
93
  }
93
94
  paths.map((p) => {
94
- if (require_file_path_fns.hasFileExtension(p)) combinations.push(...getResolutionCombinations(path, {
95
+ if ((0, _stryke_path_file_path_fns.hasFileExtension)(p)) combinations.push(...getResolutionCombinations(path, {
95
96
  ...options,
96
97
  useAdditionalPaths: false,
97
- paths: [require_file_path_fns.findFilePath(p)]
98
+ paths: [(0, _stryke_path_file_path_fns.findFilePath)(p)]
98
99
  }));
99
100
  });
100
- return require_get_unique.getUnique(combinations.filter(Boolean)).map((p) => require_correct_path.correctPath(p));
101
+ return (0, _stryke_helpers_get_unique.getUnique)(combinations.filter(Boolean)).map((p) => (0, _stryke_path_correct_path.correctPath)(p));
101
102
  }
102
103
  /**
103
104
  * Resolve the path to a specified module
@@ -108,7 +109,7 @@ function getResolutionCombinations(path, options = {}) {
108
109
  */
109
110
  async function resolve(path, options = {}) {
110
111
  let paths = getResolutionPaths(options.paths);
111
- if (require_is_type.isNpmScopedPackage(path)) paths = getNodeModulesPaths(paths);
112
+ if ((0, _stryke_path_is_type.isNpmScopedPackage)(path)) paths = getNodeModulesPaths(paths);
112
113
  else paths.push(...getNodeModulesPaths(paths));
113
114
  let result;
114
115
  let error;
@@ -122,7 +123,7 @@ async function resolve(path, options = {}) {
122
123
  error = err;
123
124
  }
124
125
  if (!result) throw new Error(`Unable to resolve module "${path}". The following import paths were tried: \n${paths.join("\n")}`, { cause: error });
125
- return require_correct_path.correctPath(result);
126
+ return (0, _stryke_path_correct_path.correctPath)(result);
126
127
  }
127
128
  /**
128
129
  * Resolve the path to a specified module
@@ -133,7 +134,7 @@ async function resolve(path, options = {}) {
133
134
  */
134
135
  function resolveSync(path, options = {}) {
135
136
  let paths = getResolutionPaths(options.paths);
136
- if (require_is_type.isNpmScopedPackage(path)) paths = getNodeModulesPaths(paths);
137
+ if ((0, _stryke_path_is_type.isNpmScopedPackage)(path)) paths = getNodeModulesPaths(paths);
137
138
  else paths.push(...getNodeModulesPaths(paths));
138
139
  let result;
139
140
  let error;
@@ -147,7 +148,7 @@ function resolveSync(path, options = {}) {
147
148
  error = err;
148
149
  }
149
150
  if (!result) throw new Error(`Unable to resolve module "${path}". The following import paths were tried: \n${paths.join("\n")}`, { cause: error });
150
- return require_correct_path.correctPath(result);
151
+ return (0, _stryke_path_correct_path.correctPath)(result);
151
152
  }
152
153
  /**
153
154
  * Resolve the path to a specified module with error handling
@@ -198,12 +199,12 @@ async function importModule(path) {
198
199
  * @returns A promise for the module or undefined
199
200
  */
200
201
  async function resolvePackage(name, options = {}) {
201
- let result = await resolveSafe(require_join_paths.joinPaths(name, "package.json"), options);
202
+ let result = await resolveSafe((0, _stryke_path_join_paths.joinPaths)(name, "package.json"), options);
202
203
  if (!result) {
203
- result = await resolveSafe(require_join_paths.joinPaths(name, "index.js"), options);
204
+ result = await resolveSafe((0, _stryke_path_join_paths.joinPaths)(name, "index.js"), options);
204
205
  if (!result) result = await resolveSafe(name, options);
205
206
  }
206
- return result ? require_file_path_fns.findFilePath(result) : void 0;
207
+ return result ? (0, _stryke_path_file_path_fns.findFilePath)(result) : void 0;
207
208
  }
208
209
  /**
209
210
  * Resolve the path to a specified package synchronously
@@ -216,12 +217,12 @@ async function resolvePackage(name, options = {}) {
216
217
  * @returns The module or undefined
217
218
  */
218
219
  function resolvePackageSync(name, options = {}) {
219
- let result = resolveSafeSync(require_join_paths.joinPaths(name, "package.json"), options);
220
+ let result = resolveSafeSync((0, _stryke_path_join_paths.joinPaths)(name, "package.json"), options);
220
221
  if (!result) {
221
- result = resolveSafeSync(require_join_paths.joinPaths(name, "index.js"), options);
222
+ result = resolveSafeSync((0, _stryke_path_join_paths.joinPaths)(name, "index.js"), options);
222
223
  if (!result) result = resolveSafeSync(name, options);
223
224
  }
224
- return result ? require_file_path_fns.findFilePath(result) : void 0;
225
+ return result ? (0, _stryke_path_file_path_fns.findFilePath)(result) : void 0;
225
226
  }
226
227
 
227
228
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.d.cts","names":[],"sources":["../src/resolve.ts"],"sourcesContent":[],"mappings":";cAkCa;AAAA,UAeI,cAAA,CAFhB;EAEgB;AA4BjB;AAuCA;EAgBiB,KAAA,CAAA,EAAA,MAAA,EAAA;EAgBD;AAkEhB;AA2DA;AAuEA;AAeA;AAcA;AAmBA;AAyBA;;;;;;;;;;;;;iBApVgB,kBAAA;;;;;;;iBAuCA,mBAAA;UAgBC,4BAAA,SAAqC;;;;;;;;;;;;;;;iBAgBtC,yBAAA,yBAEL;;;;;;;;iBAgEW,OAAA,yBAEX,iBACR;;;;;;;;iBAwDa,WAAA,yBAAmC;;;;;;;;iBAuE7B,WAAA,yBAAmC,iBAAmB;;;;;;;;iBAe5D,eAAA,yBAAuC;;;;;;;iBAcjC,qCAAqC,QAAQ;;;;;;;;;;iBAmB7C,cAAA,yBAEX,iBAAmB;;;;;;;;;;;iBAuBd,kBAAA,yBAA0C"}
1
+ {"version":3,"file":"resolve.d.cts","names":[],"sources":["../src/resolve.ts"],"mappings":";cAkCa,kBAAA;AAAA,UAeI,cAAA;EAFhB;;;EAMC,KAAA;EAJe;;;;;;;;EAcf,UAAA;EAcc;;;EATd,UAAA;AAAA;AAgDF;;;;;AAgBA;AAhBA,iBAvCgB,kBAAA,CAAmB,KAAA;;;;AAuEnC;;;iBAhCgB,mBAAA,CAAoB,KAAA;AAAA,UAgBnB,4BAAA,SAAqC,cAAA;EAkB3C;;;;AAgEX;EA5EE,kBAAA;AAAA;;;;;;;;iBAUc,yBAAA,CACd,IAAA,UACA,OAAA,GAAS,4BAAA;;;;;;;;iBAgEW,OAAA,CACpB,IAAA,UACA,OAAA,GAAS,cAAA,GACR,OAAA;AA+HH;;;;;;;AAAA,iBAvEgB,WAAA,CAAY,IAAA,UAAc,OAAA,GAAS,cAAA;;;AAsFnD;;;;;iBAfsB,WAAA,CAAY,IAAA,UAAc,OAAA,GAAS,cAAA,GAAmB,OAAA;;;;AA6B5E;;;;iBAdgB,eAAA,CAAgB,IAAA,UAAc,OAAA,GAAS,cAAA;;;;;;AAiCvD;iBAnBsB,YAAA,SAAA,CAAsB,IAAA,WAAe,OAAA,CAAQ,CAAA;;;;;;;;;AA4CnE;iBAzBsB,cAAA,CACpB,IAAA,UACA,OAAA,GAAS,cAAA,GAAmB,OAAA;;;;;;;;;;;iBAuBd,kBAAA,CAAmB,IAAA,UAAc,OAAA,GAAS,cAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.d.mts","names":[],"sources":["../src/resolve.ts"],"sourcesContent":[],"mappings":";cAkCa;AAAA,UAeI,cAAA,CAFhB;EAEgB;AA4BjB;AAuCA;EAgBiB,KAAA,CAAA,EAAA,MAAA,E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A,UACA,OAAA,GAAS,cAAA,GAAmB,OAAA;;;;;;;;;;;iBAuBd,kBAAA,CAAmB,IAAA,UAAc,OAAA,GAAS,cAAA"}
package/dist/resolve.mjs CHANGED
@@ -1,13 +1,13 @@
1
- import { cwd } from "./path/src/cwd.mjs";
2
- import { isAbsolutePath, isNpmScopedPackage } from "./path/src/is-type.mjs";
3
- import { joinPaths } from "./path/src/join-paths.mjs";
4
- import { appendExtension } from "./path/src/append.mjs";
5
- import { correctPath, toAbsolutePath } from "./path/src/correct-path.mjs";
6
- import { findFileName, findFilePath, findFolderName, hasFileExtension } from "./path/src/file-path-fns.mjs";
7
1
  import { existsSync } from "./exists.mjs";
8
2
  import { getWorkspaceRoot } from "./get-workspace-root.mjs";
9
- import { getUnique } from "./helpers/src/get-unique.mjs";
3
+ import { appendExtension } from "@stryke/path";
4
+ import { joinPaths as joinPaths$1 } from "@stryke/path/join-paths";
5
+ import { correctPath, toAbsolutePath } from "@stryke/path/correct-path";
6
+ import { findFileName, findFilePath as findFilePath$1, findFolderName as findFolderName$1, hasFileExtension } from "@stryke/path/file-path-fns";
10
7
  import { interopDefault, resolvePath, resolvePathSync } from "mlly";
8
+ import { cwd } from "@stryke/path/cwd";
9
+ import { getUnique } from "@stryke/helpers/get-unique";
10
+ import { isAbsolutePath, isNpmScopedPackage } from "@stryke/path/is-type";
11
11
 
12
12
  //#region src/resolve.ts
13
13
  const DEFAULT_EXTENSIONS = [
@@ -56,8 +56,8 @@ function getResolutionPaths(paths = []) {
56
56
  */
57
57
  function getNodeModulesPaths(paths = []) {
58
58
  return getUnique(paths.reduce((ret, path) => {
59
- if (findFolderName(path) === "node_modules") ret.push(correctPath(path));
60
- if (existsSync(joinPaths(path, "node_modules"))) ret.push(correctPath(joinPaths(path, "node_modules")));
59
+ if (findFolderName$1(path) === "node_modules") ret.push(correctPath(path));
60
+ if (existsSync(joinPaths$1(path, "node_modules"))) ret.push(correctPath(joinPaths$1(path, "node_modules")));
61
61
  return ret;
62
62
  }, []));
63
63
  }
@@ -72,10 +72,10 @@ function getResolutionCombinations(path, options = {}) {
72
72
  let paths = options.useAdditionalPaths ? getResolutionPaths(options.paths) : options.paths ?? [];
73
73
  if (isNpmScopedPackage(path)) paths = getNodeModulesPaths(paths);
74
74
  else paths.push(...getNodeModulesPaths(paths));
75
- let combinations = paths.map((base) => joinPaths(base, path));
75
+ let combinations = paths.map((base) => joinPaths$1(base, path));
76
76
  if (findFileName(path, { withExtension: false }) !== "index") combinations = combinations.reduce((ret, combination) => {
77
77
  ret.push(combination);
78
- ret.push(joinPaths(combination, "index"));
78
+ ret.push(joinPaths$1(combination, "index"));
79
79
  return ret;
80
80
  }, []);
81
81
  if (!hasFileExtension(path)) {
@@ -93,7 +93,7 @@ function getResolutionCombinations(path, options = {}) {
93
93
  if (hasFileExtension(p)) combinations.push(...getResolutionCombinations(path, {
94
94
  ...options,
95
95
  useAdditionalPaths: false,
96
- paths: [findFilePath(p)]
96
+ paths: [findFilePath$1(p)]
97
97
  }));
98
98
  });
99
99
  return getUnique(combinations.filter(Boolean)).map((p) => correctPath(p));
@@ -197,12 +197,12 @@ async function importModule(path) {
197
197
  * @returns A promise for the module or undefined
198
198
  */
199
199
  async function resolvePackage(name, options = {}) {
200
- let result = await resolveSafe(joinPaths(name, "package.json"), options);
200
+ let result = await resolveSafe(joinPaths$1(name, "package.json"), options);
201
201
  if (!result) {
202
- result = await resolveSafe(joinPaths(name, "index.js"), options);
202
+ result = await resolveSafe(joinPaths$1(name, "index.js"), options);
203
203
  if (!result) result = await resolveSafe(name, options);
204
204
  }
205
- return result ? findFilePath(result) : void 0;
205
+ return result ? findFilePath$1(result) : void 0;
206
206
  }
207
207
  /**
208
208
  * Resolve the path to a specified package synchronously
@@ -215,12 +215,12 @@ async function resolvePackage(name, options = {}) {
215
215
  * @returns The module or undefined
216
216
  */
217
217
  function resolvePackageSync(name, options = {}) {
218
- let result = resolveSafeSync(joinPaths(name, "package.json"), options);
218
+ let result = resolveSafeSync(joinPaths$1(name, "package.json"), options);
219
219
  if (!result) {
220
- result = resolveSafeSync(joinPaths(name, "index.js"), options);
220
+ result = resolveSafeSync(joinPaths$1(name, "index.js"), options);
221
221
  if (!result) result = resolveSafeSync(name, options);
222
222
  }
223
- return result ? findFilePath(result) : void 0;
223
+ return result ? findFilePath$1(result) : void 0;
224
224
  }
225
225
 
226
226
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.mjs","names":["result: string | undefined","error: Error | undefined","result!: string"],"sources":["../src/resolve.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 { getUnique } from \"@stryke/helpers/get-unique\";\nimport { appendExtension } from \"@stryke/path\";\nimport { correctPath, toAbsolutePath } from \"@stryke/path/correct-path\";\nimport { cwd } from \"@stryke/path/cwd\";\nimport {\n findFileName,\n findFilePath,\n findFolderName,\n hasFileExtension\n} from \"@stryke/path/file-path-fns\";\nimport { isAbsolutePath, isNpmScopedPackage } from \"@stryke/path/is-type\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { interopDefault, resolvePath, resolvePathSync } from \"mlly\";\nimport { existsSync } from \"./exists\";\nimport { getWorkspaceRoot } from \"./get-workspace-root\";\n\nexport const DEFAULT_EXTENSIONS = [\n \"js\",\n \"jsx\",\n \"mjs\",\n \"cjs\",\n \"ts\",\n \"tsx\",\n \"mts\",\n \"cts\",\n \"json\",\n \"jsonc\",\n \"json5\",\n \"node\"\n];\n\nexport interface ResolveOptions {\n /**\n * Paths to resolve the package from\n */\n paths?: string[];\n\n /**\n * File extensions to consider when resolving the module\n *\n * @remarks\n * Extensions can be provided with or without the leading dot. The resolver utilities will handle both cases.\n *\n * @defaultValue [\"js\", \"jsx\", \"mjs\", \"cjs\", \"ts\", \"tsx\", \"mts\", \"cts\", \"json\", \"jsonc\", \"json5\", \"node\", \"wasm\"]\n */\n extensions?: string[];\n\n /**\n * Conditions to consider when resolving package exports.\n */\n conditions?: string[];\n}\n\n/**\n * Get the resolution paths based on the provided paths, current working directory, and workspace root.\n *\n * @param paths - An array of paths to include in the resolution.\n * @returns An array of unique, corrected resolution paths.\n */\nexport function getResolutionPaths(paths: string[] = []) {\n let resolutionPaths = paths;\n if (!resolutionPaths.includes(cwd())) {\n resolutionPaths.push(cwd());\n }\n\n const workspaceRoot = getWorkspaceRoot();\n if (!resolutionPaths.includes(workspaceRoot)) {\n resolutionPaths.push(workspaceRoot);\n }\n\n resolutionPaths = getUnique(\n resolutionPaths\n .filter(Boolean)\n .map(path => correctPath(path))\n .reduce((ret, path, _, arr) => {\n ret.push(path);\n if (!isAbsolutePath(path)) {\n ret.push(toAbsolutePath(path, cwd()));\n ret.push(toAbsolutePath(path, workspaceRoot));\n\n arr.forEach(existing => {\n ret.push(toAbsolutePath(path, existing));\n });\n }\n\n return ret;\n }, [] as string[])\n );\n\n return resolutionPaths;\n}\n\n/**\n * Get the node_modules resolution paths based on the provided paths.\n *\n * @param paths - An array of paths to include in the resolution.\n * @returns An array of unique, corrected node_modules resolution paths.\n */\nexport function getNodeModulesPaths(paths: string[] = []) {\n return getUnique(\n paths.reduce((ret, path) => {\n if (findFolderName(path) === \"node_modules\") {\n ret.push(correctPath(path));\n }\n\n if (existsSync(joinPaths(path, \"node_modules\"))) {\n ret.push(correctPath(joinPaths(path, \"node_modules\")));\n }\n\n return ret;\n }, [] as string[])\n );\n}\n\nexport interface ResolutionCombinationOptions extends ResolveOptions {\n /**\n * Whether to include additional paths (like node_modules) in the resolution combinations. If set to false, only the provided paths will be used for generating combinations. This can be useful for scenarios where you want to limit the resolution to specific directories without considering the default node_modules paths.\n *\n * @defaultValue true\n */\n useAdditionalPaths?: boolean;\n}\n\n/**\n * Get all combinations of resolution paths for a given path and options.\n *\n * @param path - The base path to combine with resolution paths.\n * @param options - The options containing resolution paths.\n * @returns An array of unique, corrected resolution paths.\n */\nexport function getResolutionCombinations(\n path: string,\n options: ResolutionCombinationOptions = {}\n) {\n let paths = options.useAdditionalPaths\n ? getResolutionPaths(options.paths)\n : (options.paths ?? []);\n if (isNpmScopedPackage(path)) {\n paths = getNodeModulesPaths(paths);\n } else {\n paths.push(...getNodeModulesPaths(paths));\n }\n\n let combinations = paths.map(base => joinPaths(base, path));\n if (findFileName(path, { withExtension: false }) !== \"index\") {\n combinations = combinations.reduce((ret, combination) => {\n ret.push(combination);\n ret.push(joinPaths(combination, \"index\"));\n\n return ret;\n }, [] as string[]);\n }\n\n if (!hasFileExtension(path)) {\n const extensions = options.extensions ?? DEFAULT_EXTENSIONS;\n\n combinations = combinations.reduce((ret, combination) => {\n ret.push(combination);\n extensions.forEach(ext => {\n ret.push(appendExtension(combination, ext));\n });\n\n return ret;\n }, [] as string[]);\n\n combinations.push(\n ...extensions\n .map(ext =>\n getResolutionCombinations(appendExtension(path, ext), options)\n )\n .flat()\n );\n }\n\n paths.map(p => {\n if (hasFileExtension(p)) {\n combinations.push(\n ...getResolutionCombinations(path, {\n ...options,\n useAdditionalPaths: false,\n paths: [findFilePath(p)]\n })\n );\n }\n });\n\n return getUnique(combinations.filter(Boolean)).map(p => correctPath(p));\n}\n\n/**\n * Resolve the path to a specified module\n *\n * @param path - The path to the module\n * @param options - The options to use when resolving the module\n * @returns A promise for the path to the module\n */\nexport async function resolve(\n path: string,\n options: ResolveOptions = {}\n): Promise<string> {\n let paths = getResolutionPaths(options.paths);\n if (isNpmScopedPackage(path)) {\n paths = getNodeModulesPaths(paths);\n } else {\n paths.push(...getNodeModulesPaths(paths));\n }\n\n let result: string | undefined;\n let error: Error | undefined;\n\n try {\n result = await resolvePath(path, {\n url: paths,\n extensions: options.extensions ?? DEFAULT_EXTENSIONS,\n conditions: options.conditions\n });\n } catch (err) {\n error = err as Error;\n }\n\n // if (!result) {\n // for (let i = 0; i < paths.length && !result; i++) {\n // try {\n // result = await resolvePath(replacePath(path, paths[i]), {\n // url: paths,\n // extensions: options.extensions ?? DEFAULT_EXTENSIONS,\n // conditions: options.conditions\n // });\n // } catch (err) {\n // error = err as Error;\n // }\n // }\n // }\n\n if (!result) {\n throw new Error(\n `Unable to resolve module \"${\n path\n }\". The following import paths were tried: \\n${paths.join(\"\\n\")}`,\n {\n cause: error\n }\n );\n }\n\n return correctPath(result);\n}\n\n/**\n * Resolve the path to a specified module\n *\n * @param path - The path to the module\n * @param options - The options to use when resolving the module\n * @returns The path to the module or undefined\n */\nexport function resolveSync(path: string, options: ResolveOptions = {}) {\n let paths = getResolutionPaths(options.paths);\n if (isNpmScopedPackage(path)) {\n paths = getNodeModulesPaths(paths);\n } else {\n paths.push(...getNodeModulesPaths(paths));\n }\n\n let result!: string;\n let error: Error | undefined;\n\n try {\n result = resolvePathSync(path, {\n url: paths,\n extensions: options.extensions ?? DEFAULT_EXTENSIONS,\n conditions: options.conditions\n });\n } catch (err) {\n error = err as Error;\n }\n\n // if (!result) {\n // for (let i = 0; i < paths.length && !result; i++) {\n // try {\n // result = resolvePathSync(replacePath(path, paths[i]), {\n // url: paths,\n // extensions: options.extensions ?? DEFAULT_EXTENSIONS,\n // conditions: options.conditions\n // });\n // } catch (err) {\n // error = err as Error;\n // }\n // }\n // }\n\n // if (!result && findFileName(path, { withExtension: false }) !== \"index\") {\n // try {\n // result = resolveSync(joinPaths(path, \"index\"), {\n // ...options,\n // paths\n // });\n // if (result) {\n // // Remove the previously added index file from the path\n // result = findFilePath(result);\n // }\n // } catch (err) {\n // error = err as Error;\n // }\n // }\n\n if (!result) {\n throw new Error(\n `Unable to resolve module \"${\n path\n }\". The following import paths were tried: \\n${paths.join(\"\\n\")}`,\n {\n cause: error\n }\n );\n }\n\n return correctPath(result);\n}\n\n/**\n * Resolve the path to a specified module with error handling\n *\n * @param name - The name of the module\n * @param options - The options to use when resolving the module\n * @returns A promise for the path to the module\n */\nexport async function resolveSafe(name: string, options: ResolveOptions = {}) {\n try {\n return await resolve(name, options);\n } catch {\n return undefined;\n }\n}\n\n/**\n * Resolve the path to a specified module with error handling\n *\n * @param name - The name of the module\n * @param options - The options to use when resolving the module\n * @returns The path to the module or undefined\n */\nexport function resolveSafeSync(name: string, options: ResolveOptions = {}) {\n try {\n return resolveSync(name, options);\n } catch {\n return undefined;\n }\n}\n\n/**\n * Import a module from a specified path\n *\n * @param path - The path to the module\n * @returns The module\n */\nexport async function importModule<T = any>(path: string): Promise<T> {\n const i = await import(path);\n\n if (i) {\n return interopDefault(i);\n }\n\n return i;\n}\n\n/**\n * Resolve the path to a specified package asynchronously\n *\n * @remarks\n * This path points to the root of the package, which is usually the directory containing the `package.json` file. Please note: this path does not include the `package.json` file itself.\n *\n * @param name - The name of the module\n * @returns A promise for the module or undefined\n */\nexport async function resolvePackage(\n name: string,\n options: ResolveOptions = {}\n) {\n let result = await resolveSafe(joinPaths(name, \"package.json\"), options);\n if (!result) {\n result = await resolveSafe(joinPaths(name, \"index.js\"), options);\n if (!result) {\n result = await resolveSafe(name, options);\n }\n }\n\n return result ? findFilePath(result) : undefined;\n}\n\n/**\n * Resolve the path to a specified package synchronously\n *\n * @remarks\n * This path points to the root of the package, which is usually the directory containing the `package.json` file. Please note: this path does not include the `package.json` file itself.\n *\n * @param name - The name of the module\n * @param options - The options to use when resolving the module\n * @returns The module or undefined\n */\nexport function resolvePackageSync(name: string, options: ResolveOptions = {}) {\n let result = resolveSafeSync(joinPaths(name, \"package.json\"), options);\n if (!result) {\n result = resolveSafeSync(joinPaths(name, \"index.js\"), options);\n if (!result) {\n result = resolveSafeSync(name, options);\n }\n }\n\n return result ? findFilePath(result) : undefined;\n}\n"],"mappings":";;;;;;;;;;;;AAkCA,MAAa,qBAAqB;CAChC;CACA;CAC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azC,SAAgB,mBAAmB,MAAc,UAA0B,EAAE,EAAE;CAC7E,IAAI,SAAS,gBAAgB,UAAU,MAAM,eAAe,EAAE,QAAQ;AACtE,KAAI,CAAC,QAAQ;AACX,WAAS,gBAAgB,UAAU,MAAM,WAAW,EAAE,QAAQ;AAC9D,MAAI,CAAC,OACH,UAAS,gBAAgB,MAAM,QAAQ;;AAI3C,QAAO,SAAS,aAAa,OAAO,GAAG"}
1
+ {"version":3,"file":"resolve.mjs","names":["findFolderName","joinPaths","findFilePath"],"sources":["../src/resolve.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 { getUnique } from \"@stryke/helpers/get-unique\";\nimport { appendExtension } from \"@stryke/path\";\nimport { correctPath, toAbsolutePath } from \"@stryke/path/correct-path\";\nimport { cwd } from \"@stryke/path/cwd\";\nimport {\n findFileName,\n findFilePath,\n findFolderName,\n hasFileExtension\n} from \"@stryke/path/file-path-fns\";\nimport { isAbsolutePath, isNpmScopedPackage } from \"@stryke/path/is-type\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { interopDefault, resolvePath, resolvePathSync } from \"mlly\";\nimport { existsSync } from \"./exists\";\nimport { getWorkspaceRoot } from \"./get-workspace-root\";\n\nexport const DEFAULT_EXTENSIONS = [\n \"js\",\n \"jsx\",\n \"mjs\",\n \"cjs\",\n \"ts\",\n \"tsx\",\n \"mts\",\n \"cts\",\n \"json\",\n \"jsonc\",\n \"json5\",\n \"node\"\n];\n\nexport interface ResolveOptions {\n /**\n * Paths to resolve the package from\n */\n paths?: string[];\n\n /**\n * File extensions to consider when resolving the module\n *\n * @remarks\n * Extensions can be provided with or without the leading dot. The resolver utilities will handle both cases.\n *\n * @defaultValue [\"js\", \"jsx\", \"mjs\", \"cjs\", \"ts\", \"tsx\", \"mts\", \"cts\", \"json\", \"jsonc\", \"json5\", \"node\", \"wasm\"]\n */\n extensions?: string[];\n\n /**\n * Conditions to consider when resolving package exports.\n */\n conditions?: string[];\n}\n\n/**\n * Get the resolution paths based on the provided paths, current working directory, and workspace root.\n *\n * @param paths - An array of paths to include in the resolution.\n * @returns An array of unique, corrected resolution paths.\n */\nexport function getResolutionPaths(paths: string[] = []) {\n let resolutionPaths = paths;\n if (!resolutionPaths.includes(cwd())) {\n resolutionPaths.push(cwd());\n }\n\n const workspaceRoot = getWorkspaceRoot();\n if (!resolutionPaths.includes(workspaceRoot)) {\n resolutionPaths.push(workspaceRoot);\n }\n\n resolutionPaths = getUnique(\n resolutionPaths\n .filter(Boolean)\n .map(path => correctPath(path))\n .reduce((ret, path, _, arr) => {\n ret.push(path);\n if (!isAbsolutePath(path)) {\n ret.push(toAbsolutePath(path, cwd()));\n ret.push(toAbsolutePath(path, workspaceRoot));\n\n arr.forEach(existing => {\n ret.push(toAbsolutePath(path, existing));\n });\n }\n\n return ret;\n }, [] as string[])\n );\n\n return resolutionPaths;\n}\n\n/**\n * Get the node_modules resolution paths based on the provided paths.\n *\n * @param paths - An array of paths to include in the resolution.\n * @returns An array of unique, corrected node_modules resolution paths.\n */\nexport function getNodeModulesPaths(paths: string[] = []) {\n return getUnique(\n paths.reduce((ret, path) => {\n if (findFolderName(path) === \"node_modules\") {\n ret.push(correctPath(path));\n }\n\n if (existsSync(joinPaths(path, \"node_modules\"))) {\n ret.push(correctPath(joinPaths(path, \"node_modules\")));\n }\n\n return ret;\n }, [] as string[])\n );\n}\n\nexport interface ResolutionCombinationOptions extends ResolveOptions {\n /**\n * Whether to include additional paths (like node_modules) in the resolution combinations. If set to false, only the provided paths will be used for generating combinations. This can be useful for scenarios where you want to limit the resolution to specific directories without considering the default node_modules paths.\n *\n * @defaultValue true\n */\n useAdditionalPaths?: boolean;\n}\n\n/**\n * Get all combinations of resolution paths for a given path and options.\n *\n * @param path - The base path to combine with resolution paths.\n * @param options - The options containing resolution paths.\n * @returns An array of unique, corrected resolution paths.\n */\nexport function getResolutionCombinations(\n path: string,\n options: ResolutionCombinationOptions = {}\n) {\n let paths = options.useAdditionalPaths\n ? getResolutionPaths(options.paths)\n : (options.paths ?? []);\n if (isNpmScopedPackage(path)) {\n paths = getNodeModulesPaths(paths);\n } else {\n paths.push(...getNodeModulesPaths(paths));\n }\n\n let combinations = paths.map(base => joinPaths(base, path));\n if (findFileName(path, { withExtension: false }) !== \"index\") {\n combinations = combinations.reduce((ret, combination) => {\n ret.push(combination);\n ret.push(joinPaths(combination, \"index\"));\n\n return ret;\n }, [] as string[]);\n }\n\n if (!hasFileExtension(path)) {\n const extensions = options.extensions ?? DEFAULT_EXTENSIONS;\n\n combinations = combinations.reduce((ret, combination) => {\n ret.push(combination);\n extensions.forEach(ext => {\n ret.push(appendExtension(combination, ext));\n });\n\n return ret;\n }, [] as string[]);\n\n combinations.push(\n ...extensions\n .map(ext =>\n getResolutionCombinations(appendExtension(path, ext), options)\n )\n .flat()\n );\n }\n\n paths.map(p => {\n if (hasFileExtension(p)) {\n combinations.push(\n ...getResolutionCombinations(path, {\n ...options,\n useAdditionalPaths: false,\n paths: [findFilePath(p)]\n })\n );\n }\n });\n\n return getUnique(combinations.filter(Boolean)).map(p => correctPath(p));\n}\n\n/**\n * Resolve the path to a specified module\n *\n * @param path - The path to the module\n * @param options - The options to use when resolving the module\n * @returns A promise for the path to the module\n */\nexport async function resolve(\n path: string,\n options: ResolveOptions = {}\n): Promise<string> {\n let paths = getResolutionPaths(options.paths);\n if (isNpmScopedPackage(path)) {\n paths = getNodeModulesPaths(paths);\n } else {\n paths.push(...getNodeModulesPaths(paths));\n }\n\n let result: string | undefined;\n let error: Error | undefined;\n\n try {\n result = await resolvePath(path, {\n url: paths,\n extensions: options.extensions ?? DEFAULT_EXTENSIONS,\n conditions: options.conditions\n });\n } catch (err) {\n error = err as Error;\n }\n\n // if (!result) {\n // for (let i = 0; i < paths.length && !result; i++) {\n // try {\n // result = await resolvePath(replacePath(path, paths[i]), {\n // url: paths,\n // extensions: options.extensions ?? DEFAULT_EXTENSIONS,\n // conditions: options.conditions\n // });\n // } catch (err) {\n // error = err as Error;\n // }\n // }\n // }\n\n if (!result) {\n throw new Error(\n `Unable to resolve module \"${\n path\n }\". The following import paths were tried: \\n${paths.join(\"\\n\")}`,\n {\n cause: error\n }\n );\n }\n\n return correctPath(result);\n}\n\n/**\n * Resolve the path to a specified module\n *\n * @param path - The path to the module\n * @param options - The options to use when resolving the module\n * @returns The path to the module or undefined\n */\nexport function resolveSync(path: string, options: ResolveOptions = {}) {\n let paths = getResolutionPaths(options.paths);\n if (isNpmScopedPackage(path)) {\n paths = getNodeModulesPaths(paths);\n } else {\n paths.push(...getNodeModulesPaths(paths));\n }\n\n let result!: string;\n let error: Error | undefined;\n\n try {\n result = resolvePathSync(path, {\n url: paths,\n extensions: options.extensions ?? DEFAULT_EXTENSIONS,\n conditions: options.conditions\n });\n } catch (err) {\n error = err as Error;\n }\n\n // if (!result) {\n // for (let i = 0; i < paths.length && !result; i++) {\n // try {\n // result = resolvePathSync(replacePath(path, paths[i]), {\n // url: paths,\n // extensions: options.extensions ?? DEFAULT_EXTENSIONS,\n // conditions: options.conditions\n // });\n // } catch (err) {\n // error = err as Error;\n // }\n // }\n // }\n\n // if (!result && findFileName(path, { withExtension: false }) !== \"index\") {\n // try {\n // result = resolveSync(joinPaths(path, \"index\"), {\n // ...options,\n // paths\n // });\n // if (result) {\n // // Remove the previously added index file from the path\n // result = findFilePath(result);\n // }\n // } catch (err) {\n // error = err as Error;\n // }\n // }\n\n if (!result) {\n throw new Error(\n `Unable to resolve module \"${\n path\n }\". The following import paths were tried: \\n${paths.join(\"\\n\")}`,\n {\n cause: error\n }\n );\n }\n\n return correctPath(result);\n}\n\n/**\n * Resolve the path to a specified module with error handling\n *\n * @param name - The name of the module\n * @param options - The options to use when resolving the module\n * @returns A promise for the path to the module\n */\nexport async function resolveSafe(name: string, options: ResolveOptions = {}) {\n try {\n return await resolve(name, options);\n } catch {\n return undefined;\n }\n}\n\n/**\n * Resolve the path to a specified module with error handling\n *\n * @param name - The name of the module\n * @param options - The options to use when resolving the module\n * @returns The path to the module or undefined\n */\nexport function resolveSafeSync(name: string, options: ResolveOptions = {}) {\n try {\n return resolveSync(name, options);\n } catch {\n return undefined;\n }\n}\n\n/**\n * Import a module from a specified path\n *\n * @param path - The path to the module\n * @returns The module\n */\nexport async function importModule<T = any>(path: string): Promise<T> {\n const i = await import(path);\n\n if (i) {\n return interopDefault(i);\n }\n\n return i;\n}\n\n/**\n * Resolve the path to a specified package asynchronously\n *\n * @remarks\n * This path points to the root of the package, which is usually the directory containing the `package.json` file. Please note: this path does not include the `package.json` file itself.\n *\n * @param name - The name of the module\n * @returns A promise for the module or undefined\n */\nexport async function resolvePackage(\n name: string,\n options: ResolveOptions = {}\n) {\n let result = await resolveSafe(joinPaths(name, \"package.json\"), options);\n if (!result) {\n result = await resolveSafe(joinPaths(name, \"index.js\"), options);\n if (!result) {\n result = await resolveSafe(name, options);\n }\n }\n\n return result ? findFilePath(result) : undefined;\n}\n\n/**\n * Resolve the path to a specified package synchronously\n *\n * @remarks\n * This path points to the root of the package, which is usually the directory containing the `package.json` file. Please note: this path does not include the `package.json` file itself.\n *\n * @param name - The name of the module\n * @param options - The options to use when resolving the module\n * @returns The module or undefined\n */\nexport function resolvePackageSync(name: string, options: ResolveOptions = {}) {\n let result = resolveSafeSync(joinPaths(name, \"package.json\"), options);\n if (!result) {\n result = resolveSafeSync(joinPaths(name, \"index.js\"), options);\n if (!result) {\n result = resolveSafeSync(name, options);\n }\n }\n\n return result ? findFilePath(result) : undefined;\n}\n"],"mappings":";;;;;;;;;;;;AAkCA,MAAa,qB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O,GAAG;;;;;;;;;;;;AAazC,SAAgB,mBAAmB,MAAc,UAA0B,EAAE,EAAE;CAC7E,IAAI,SAAS,gBAAgBD,YAAU,MAAM,eAAe,EAAE,QAAQ;AACtE,KAAI,CAAC,QAAQ;AACX,WAAS,gBAAgBA,YAAU,MAAM,WAAW,EAAE,QAAQ;AAC9D,MAAI,CAAC,OACH,UAAS,gBAAgB,MAAM,QAAQ;;AAI3C,QAAO,SAASC,eAAa,OAAO,GAAG"}
@@ -1,6 +1,7 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
- const require_is_string = require('./type-checks/src/is-string.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
3
  const require_is_object = require('./type-checks/src/is-object.cjs');
4
+ const require_is_string = require('./type-checks/src/is-string.cjs');
4
5
  let semver = require("semver");
5
6
 
6
7
  //#region src/semver-fns.ts
@@ -60,8 +61,8 @@ const isRange = (val) => {
60
61
  * @param loose - Whether to use loose parsing
61
62
  * @returns Whether the semver string is valid
62
63
  */
63
- const isValidSemver = (semver$1, loose = true) => {
64
- return (require_is_string.isString(semver$1) || isSemver(semver$1)) && (0, semver.valid)(semver$1, loose) !== null;
64
+ const isValidSemver = (semver$2, loose = true) => {
65
+ return (require_is_string.isString(semver$2) || isSemver(semver$2)) && (0, semver.valid)(semver$2, loose) !== null;
65
66
  };
66
67
  /**
67
68
  * Check if a {@link Range} string is valid
@@ -1 +1 @@
1
- {"version":3,"file":"semver-fns.d.cts","names":[],"sources":["../src/semver-fns.ts"],"sourcesContent":[],"mappings":";;;KAuBY,WAAA;cAUC,eAAe;AAV5B;AAUA;AAkBA;AAUA;;;;AAGS,cAbI,YAaJ,EAAA,CAAA,MAAA,EAAA,MAAA,EAAA,KAAA,CAAA,EAAA,OAAA,EAAA,GAbgD,MAahD,GAAA,IAAA;AAUT;AAUA;AAcA;AAgBA;AAaA;AAeA;AAu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AA,WAAkB,MAAA,qBAClB,KAAA,WAAgB,KAAA,qBAChB,KAAA;;;;AAHF;;;cAuBa,wBAAA,GAA4B,GAAA,aAAc,GAAA,IAAO,WAAA;;;;;;;;AAA9D;cAYa,sBAAA,GACX,oBAAA,UACA,eAAA,UACA,KAAA"}
@@ -1,5 +1,5 @@
1
- import { isString } from "./type-checks/src/is-string.mjs";
2
1
  import { isObject } from "./type-checks/src/is-object.mjs";
2
+ import { isString } from "./type-checks/src/is-string.mjs";
3
3
  import { coerce, inc, parse, satisfies, valid, validRange } from "semver";
4
4
 
5
5
  //#region src/semver-fns.ts
@@ -1 +1 @@
1
- {"version":3,"file":"semver-fns.mjs","names":["RELEASE_TYPES: ReleaseType[]"],"sources":["../src/semver-fns.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 { isObject } from \"@stryke/type-checks/is-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport type { CoerceOptions, Range, SemVer } from \"semver\";\nimport { coerce, inc, parse, satisfies, valid, validRange } from \"semver\";\n\nexport type ReleaseType =\n | \"major\"\n | \"premajor\"\n | \"minor\"\n | \"preminor\"\n | \"patch\"\n | \"prepatch\"\n | \"prerelease\"\n | \"release\";\n\nexport const RELEASE_TYPES: ReleaseType[] = [\n \"major\",\n \"premajor\",\n \"minor\",\n \"preminor\",\n \"patch\",\n \"prepatch\",\n \"prerelease\",\n \"release\"\n];\n\n/**\n * Parse a semver string into a SemVer object\n *\n * @param semver - The semver string to parse\n * @param loose - Whether to use loose parsing\n * @returns The parsed SemVer object\n */\nexport const parseVersion = (semver: string, loose = true) =>\n parse(semver, loose);\n\n/**\n * Coerce a version string into a valid SemVer string\n *\n * @param version - The version string or number or {@link SemVer} to coerce\n * @param options - Options to use when coercing the version\n * @returns The coerced SemVer string or null if invalid\n */\nexport const coerceVersion = (\n version: string | number | SemVer | null | undefined,\n options?: CoerceOptions\n): SemVer | null => {\n return coerce(version, options);\n};\n\n/**\n * Type check for {@link SemVer}\n *\n * @param val - The value to check\n * @returns Whether the value is a valid {@link SemVer}\n */\nexport const isSemver = (val: any): val is SemVer => {\n return isObject(val) && \"version\" in val;\n};\n\n/**\n * Type check for {@link Range}\n *\n * @param val - The value to check\n * @returns Whether the value is a valid {@link Range}\n */\nexport const isRange = (val: any): val is Range => {\n return isObject(val) && \"range\" in val;\n};\n\n/**\n * Check if a {@link SemVer} string is valid\n *\n * @remarks\n * If you're looking for type checking, please use the {@link isSemver} function.\n *\n * @param semver - The semver string to check\n * @param loose - Whether to use loose parsing\n * @returns Whether the semver string is valid\n */\nexport const isValidSemver = (semver: any, loose = true): boolean => {\n return (\n (isString(semver) || isSemver(semver)) && valid(semver, loose) !== null\n );\n};\n\n/**\n * Check if a {@link Range} string is valid\n *\n * @remarks\n * If you're looking for type checking, please use the {@link isRange} function.\n *\n * @param range - The range string to check\n * @param loose - Whether to use loose parsing\n * @returns Whether the range string is valid\n */\nexport const isValidRange = (range: any, loose = true): boolean => {\n return (\n (isString(range) || isRange(range)) && validRange(range, loose) !== null\n );\n};\n\n/**\n * Check if a {@link SemVer} or {@link Range} string is valid\n *\n * @param version - The semver string to check\n * @param loose - Whether to use loose parsing\n * @returns Whether the semver string is valid\n */\nexport const isValidVersion = (\n version: string | SemVer | Range | null | undefined,\n loose = true\n) => {\n return isValidSemver(version, loose) || isValidRange(version, loose);\n};\n\n/**\n * Check if a semver string satisfies a range\n *\n * @param version - The semver string to check\n * @param range - The range to check against\n * @param loose - Whether to use loose parsing\n * @returns Whether the semver string satisfies the range\n */\nexport const satisfiesVersion = (\n version: string | SemVer | null | undefined,\n range: string | Range | null | undefined,\n loose = true\n) => {\n if (\n !version ||\n !range ||\n !isValidSemver(version, loose) ||\n !isValidRange(range, loose)\n ) {\n return false;\n }\n\n return satisfies(version, range, { loose });\n};\n\n/**\n * Check if a string is a valid relative version keyword\n *\n * @param val - The string to check\n * @returns Whether the string is a valid relative version keyword\n */\nexport const isRelativeVersionKeyword = (val: string): val is ReleaseType => {\n return RELEASE_TYPES.includes(val as ReleaseType);\n};\n\n/**\n * Derive a new semver version from the current version and a version specifier\n *\n * @param currentSemverVersion - The current semver version\n * @param semverSpecifier - The semver specifier to use\n * @param preid - The pre-release identifier to use\n * @returns The derived new semver version\n */\nexport const deriveNewSemverVersion = (\n currentSemverVersion: string,\n semverSpecifier: string,\n preid?: string\n) => {\n if (!valid(currentSemverVersion)) {\n throw new Error(\n `Invalid semver version \"${currentSemverVersion}\" provided.`\n );\n }\n\n let newVersion = semverSpecifier;\n\n if (isRelativeVersionKeyword(semverSpecifier)) {\n // Derive the new version from the current version combined with the new version specifier.\n const derivedVersion = inc(currentSemverVersion, semverSpecifier, preid!);\n\n if (!derivedVersion) {\n throw new Error(\n `Unable to derive new version from current version \"${currentSemverVersion}\" and version specifier \"${semverSpecifier}\"`\n );\n }\n newVersion = derivedVersion;\n } else if (!valid(semverSpecifier)) {\n // Ensure the new version specifier is a valid semver version, given it is not a valid semver keyword\n throw new Error(\n `Invalid semver version specifier \"${semverSpecifier}\" provided. Please provide either a valid semver version or a valid semver version keyword.`\n );\n }\n\n return newVersion;\n};\n"],"mappings":";;;;;AAiCA,MAAaA,gBAA+B;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;;AASD,MAAa,gBAAgB,QAAgB,QAAQ,SACnD,MAAM,QAAQ,MAAM;;;;;;;;AAStB,MAAa,iBACX,SACA,YACkB;AAClB,QAAO,OAAO,SAAS,QAAQ;;;;;;;;AASjC,MAAa,YAAY,QAA4B;AACnD,QAAO,SAAS,IAAI,IAAI,aAAa;;;;;;;;AASvC,MAAa,WAAW,QAA2B;AACjD,QAAO,SAAS,IAAI,IAAI,WAAW;;;;;;;;;;;;AAarC,MAAa,iBAAiB,QAAa,QAAQ,SAAkB;AACnE,SACG,SAAS,OAAO,IAAI,SAAS,OAAO,KAAK,MAAM,QAAQ,MAAM,KAAK;;;;;;;;;;;;AAcvE,MAAa,gBAAgB,OAAY,QAAQ,SAAkB;AACjE,SACG,SAAS,MAAM,IAAI,QAAQ,MAAM,KAAK,WAAW,OAAO,MAAM,KAAK;;;;;;;;;AAWxE,MAAa,kBACX,SACA,QAAQ,SACL;AACH,QAAO,cAAc,SAAS,MAAM,IAAI,aAAa,SAAS,MAAM;;;;;;;;;;AAWtE,MAAa,oBACX,SACA,OACA,QAAQ,SACL;AACH,KACE,CAAC,WACD,CAAC,SACD,CAAC,cAAc,SAAS,MAAM,IAC9B,CAAC,aAAa,OAAO,MAAM,CAE3B,QAAO;AAGT,QAAO,UAAU,SAAS,OAAO,EAAE,OAAO,CAAC;;;;;;;;AAS7C,MAAa,4BAA4B,QAAoC;AAC3E,QAAO,cAAc,SAAS,IAAmB;;;;;;;;;;AAWnD,MAAa,0BACX,sBACA,iBACA,UACG;AACH,KAAI,CAAC,MAAM,qBAAqB,CAC9B,OAAM,IAAI,MACR,2BAA2B,qBAAqB,aACjD;CAGH,IAAI,aAAa;AAEjB,KAAI,yBAAyB,gBAAgB,EAAE;EAE7C,MAAM,iBAAiB,IAAI,sBAAsB,iBAAiB,MAAO;AAEzE,MAAI,CAAC,eACH,OAAM,IAAI,MACR,sDAAsD,qBAAqB,2BAA2B,gBAAgB,GACvH;AAEH,eAAa;YACJ,CAAC,MAAM,gBAAgB,CAEhC,OAAM,IAAI,MACR,qCAAqC,gBAAgB,6FACtD;AAGH,QAAO"}
1
+ {"version":3,"file":"semver-fns.mjs","names":[],"sources":["../src/semver-fns.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 { isObject } from \"@stryke/type-checks/is-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport type { CoerceOptions, Range, SemVer } from \"semver\";\nimport { coerce, inc, parse, satisfies, valid, validRange } from \"semver\";\n\nexport type ReleaseType =\n | \"major\"\n | \"premajor\"\n | \"minor\"\n | \"preminor\"\n | \"patch\"\n | \"prepatch\"\n | \"prerelease\"\n | \"release\";\n\nexport const RELEASE_TYPES: ReleaseType[] = [\n \"major\",\n \"premajor\",\n \"minor\",\n \"preminor\",\n \"patch\",\n \"prepatch\",\n \"prerelease\",\n \"release\"\n];\n\n/**\n * Parse a semver string into a SemVer object\n *\n * @param semver - The semver string to parse\n * @param loose - Whether to use loose parsing\n * @returns The parsed SemVer object\n */\nexport const parseVersion = (semver: string, loose = true) =>\n parse(semver, loose);\n\n/**\n * Coerce a version string into a valid SemVer string\n *\n * @param version - The version string or number or {@link SemVer} to coerce\n * @param options - Options to use when coercing the version\n * @returns The coerced SemVer string or null if invalid\n */\nexport const coerceVersion = (\n version: string | number | SemVer | null | undefined,\n options?: CoerceOptions\n): SemVer | null => {\n return coerce(version, options);\n};\n\n/**\n * Type check for {@link SemVer}\n *\n * @param val - The value to check\n * @returns Whether the value is a valid {@link SemVer}\n */\nexport const isSemver = (val: any): val is SemVer => {\n return isObject(val) && \"version\" in val;\n};\n\n/**\n * Type check for {@link Range}\n *\n * @param val - The value to check\n * @returns Whether the value is a valid {@link Range}\n */\nexport const isRange = (val: any): val is Range => {\n return isObject(val) && \"range\" in val;\n};\n\n/**\n * Check if a {@link SemVer} string is valid\n *\n * @remarks\n * If you're looking for type checking, please use the {@link isSemver} function.\n *\n * @param semver - The semver string to check\n * @param loose - Whether to use loose parsing\n * @returns Whether the semver string is valid\n */\nexport const isValidSemver = (semver: any, loose = true): boolean => {\n return (\n (isString(semver) || isSemver(semver)) && valid(semver, loose) !== null\n );\n};\n\n/**\n * Check if a {@link Range} string is valid\n *\n * @remarks\n * If you're looking for type checking, please use the {@link isRange} function.\n *\n * @param range - The range string to check\n * @param loose - Whether to use loose parsing\n * @returns Whether the range string is valid\n */\nexport const isValidRange = (range: any, loose = true): boolean => {\n return (\n (isString(range) || isRange(range)) && validRange(range, loose) !== null\n );\n};\n\n/**\n * Check if a {@link SemVer} or {@link Range} string is valid\n *\n * @param version - The semver string to check\n * @param loose - Whether to use loose parsing\n * @returns Whether the semver string is valid\n */\nexport const isValidVersion = (\n version: string | SemVer | Range | null | undefined,\n loose = true\n) => {\n return isValidSemver(version, loose) || isValidRange(version, loose);\n};\n\n/**\n * Check if a semver string satisfies a range\n *\n * @param version - The semver string to check\n * @param range - The range to check against\n * @param loose - Whether to use loose parsing\n * @returns Whether the semver string satisfies the range\n */\nexport const satisfiesVersion = (\n version: string | SemVer | null | undefined,\n range: string | Range | null | undefined,\n loose = true\n) => {\n if (\n !version ||\n !range ||\n !isValidSemver(version, loose) ||\n !isValidRange(range, loose)\n ) {\n return false;\n }\n\n return satisfies(version, range, { loose });\n};\n\n/**\n * Check if a string is a valid relative version keyword\n *\n * @param val - The string to check\n * @returns Whether the string is a valid relative version keyword\n */\nexport const isRelativeVersionKeyword = (val: string): val is ReleaseType => {\n return RELEASE_TYPES.includes(val as ReleaseType);\n};\n\n/**\n * Derive a new semver version from the current version and a version specifier\n *\n * @param currentSemverVersion - The current semver version\n * @param semverSpecifier - The semver specifier to use\n * @param preid - The pre-release identifier to use\n * @returns The derived new semver version\n */\nexport const deriveNewSemverVersion = (\n currentSemverVersion: string,\n semverSpecifier: string,\n preid?: string\n) => {\n if (!valid(currentSemverVersion)) {\n throw new Error(\n `Invalid semver version \"${currentSemverVersion}\" provided.`\n );\n }\n\n let newVersion = semverSpecifier;\n\n if (isRelativeVersionKeyword(semverSpecifier)) {\n // Derive the new version from the current version combined with the new version specifier.\n const derivedVersion = inc(currentSemverVersion, semverSpecifier, preid!);\n\n if (!derivedVersion) {\n throw new Error(\n `Unable to derive new version from current version \"${currentSemverVersion}\" and version specifier \"${semverSpecifier}\"`\n );\n }\n newVersion = derivedVersion;\n } else if (!valid(semverSpecifier)) {\n // Ensure the new version specifier is a valid semver version, given it is not a valid semver keyword\n throw new Error(\n `Invalid semver version specifier \"${semverSpecifier}\" provided. Please provide either a valid semver version or a valid semver version keyword.`\n );\n }\n\n return newVersion;\n};\n"],"mappings":";;;;;AAiCA,MAAa,gBAA+B;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;;AASD,MAAa,gBAAgB,QAAgB,QAAQ,SACnD,MAAM,QAAQ,MAAM;;;;;;;;AAStB,MAAa,iBACX,SACA,YACkB;AAClB,QAAO,OAAO,SAAS,QAAQ;;;;;;;;AASjC,MAAa,YAAY,QAA4B;AACnD,QAAO,SAAS,IAAI,IAAI,aAAa;;;;;;;;AASvC,MAAa,WAAW,QAA2B;AACjD,QAAO,SAAS,IAAI,IAAI,WAAW;;;;;;;;;;;;AAarC,MAAa,iBAAiB,QAAa,QAAQ,SAAkB;AACnE,SACG,SAAS,OAAO,IAAI,SAAS,OAAO,KAAK,MAAM,QAAQ,MAAM,KAAK;;;;;;;;;;;;AAcvE,MAAa,gBAAgB,OAAY,QAAQ,SAAkB;AACjE,SACG,SAAS,MAAM,IAAI,QAAQ,MAAM,KAAK,WAAW,OAAO,MAAM,KAAK;;;;;;;;;AAWxE,MAAa,kBACX,SACA,QAAQ,SACL;AACH,QAAO,cAAc,SAAS,MAAM,IAAI,aAAa,SAAS,MAAM;;;;;;;;;;AAWtE,MAAa,oBACX,SACA,OACA,QAAQ,SACL;AACH,KACE,CAAC,WACD,CAAC,SACD,CAAC,cAAc,SAAS,MAAM,IAC9B,CAAC,aAAa,OAAO,MAAM,CAE3B,QAAO;AAGT,QAAO,UAAU,SAAS,OAAO,EAAE,OAAO,CAAC;;;;;;;;AAS7C,MAAa,4BAA4B,QAAoC;AAC3E,QAAO,cAAc,SAAS,IAAmB;;;;;;;;;;AAWnD,MAAa,0BACX,sBACA,iBACA,UACG;AACH,KAAI,CAAC,MAAM,qBAAqB,CAC9B,OAAM,IAAI,MACR,2BAA2B,qBAAqB,aACjD;CAGH,IAAI,aAAa;AAEjB,KAAI,yBAAyB,gBAAgB,EAAE;EAE7C,MAAM,iBAAiB,IAAI,sBAAsB,iBAAiB,MAAO;AAEzE,MAAI,CAAC,eACH,OAAM,IAAI,MACR,sDAAsD,qBAAqB,2BAA2B,gBAAgB,GACvH;AAEH,eAAa;YACJ,CAAC,MAAM,gBAAgB,CAEhC,OAAM,IAAI,MACR,qCAAqC,gBAAgB,6FACtD;AAGH,QAAO"}
package/dist/toml.cjs CHANGED
@@ -1,8 +1,9 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
3
  const require_read_file = require('./read-file.cjs');
3
4
  const require_write_file = require('./write-file.cjs');
4
5
  let smol_toml = require("smol-toml");
5
- smol_toml = require_rolldown_runtime.__toESM(smol_toml);
6
+ smol_toml = require_runtime.__toESM(smol_toml, 1);
6
7
 
7
8
  //#region src/toml.ts
8
9
  /**
package/dist/toml.d.cts CHANGED
@@ -1,8 +1,7 @@
1
- import * as smol_toml0 from "smol-toml";
1
+ import * as _$smol_toml0 from "smol-toml";
2
2
  import TOML from "smol-toml";
3
3
 
4
4
  //#region src/toml.d.ts
5
-
6
5
  /**
7
6
  * Reads a TOML file and returns the object the TOML content represents.
8
7
  *
@@ -10,7 +9,7 @@ import TOML from "smol-toml";
10
9
  * @param options - TOML parse options
11
10
  * @returns Object the TOML content of the file represents
12
11
  */
13
- declare function readTomlFileSync(path: string, options?: Parameters<typeof TOML.parse>[1]): smol_toml0.TomlTableWithoutBigInt;
12
+ declare function readTomlFileSync(path: string, options?: Parameters<typeof TOML.parse>[1]): _$smol_toml0.TomlTableWithoutBigInt;
14
13
  /**
15
14
  * Reads a TOML file and returns the object the TOML content represents.
16
15
  *
@@ -18,7 +17,7 @@ declare function readTomlFileSync(path: string, options?: Parameters<typeof TOML
18
17
  * @param options - TOML parse options
19
18
  * @returns Object the TOML content of the file represents
20
19
  */
21
- declare function readTomlFile(path: string, options?: Parameters<typeof TOML.parse>[1]): Promise<smol_toml0.TomlTableWithoutBigInt>;
20
+ declare function readTomlFile(path: string, options?: Parameters<typeof TOML.parse>[1]): Promise<_$smol_toml0.TomlTableWithoutBigInt>;
22
21
  /**
23
22
  * Reads a TOML file and returns the object the TOML content represents.
24
23
  *
@@ -1 +1 @@
1
- {"version":3,"file":"toml.d.cts","names":[],"sources":["../src/toml.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA6BA;;;;AAE4C,iBAF5B,gBAAA,CAE4B,IAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAAhC,UAAgC,CAAA,OAAd,IAAA,CAAK,KAAS,CAAA,CAAA,CAAA,CAAA,CAAA,EAAtB,UAAA,CAAsB,sBAAA;AAc5C;;;;;;AAgBA;AAesB,iBA/BA,YAAA,CA+Ba,IAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EA7BvB,UA6BuB,CAAA,OA7BL,IAAA,CAAK,KA6BA,CAAA,CAAA,CAAA,CAAA,CAAA,EA7BS,OA6BT,CA7Bb,UAAA,CAAsB,sBAAA,CA6BT;;;;;;;;iBAfnB,iBAAA,uCAGJ,kBAAkB,IAAA,CAAK;;;;;;;;iBAYb,aAAA,uCAGV,kBAAkB,IAAA,CAAK,gBAChC"}
1
+ {"version":3,"file":"toml.d.cts","names":[],"sources":["../src/toml.ts"],"mappings":";;;;;;;AA6BA;;;;iBAAgB,gBAAA,CACd,IAAA,UACA,OAAA,GAAU,UAAA,QAAkB,IAAA,CAAK,KAAA,OAAb,YAAA,CAAsB,sBAAA;;;;;;;;iBActB,YAAA,CACpB,IAAA,UACA,OAAA,GAAU,UAAA,QAAkB,IAAA,CAAK,KAAA,OAAS,OAAA,CAAtB,YAAA,CAAsB,sBAAA;;;;AAF5C;;;;iBAgBgB,iBAAA,CACd,IAAA,UACA,IAAA,UACA,OAAA,GAAU,UAAA,QAAkB,IAAA,CAAK,SAAA;;;;;;;;iBAYb,aAAA,CACpB,IAAA,UACA,IAAA,UACA,OAAA,GAAU,UAAA,QAAkB,IAAA,CAAK,SAAA,OAChC,OAAA"}
package/dist/toml.d.mts CHANGED
@@ -1,8 +1,7 @@
1
- import * as smol_toml0 from "smol-toml";
1
+ import * as _$smol_toml0 from "smol-toml";
2
2
  import TOML from "smol-toml";
3
3
 
4
4
  //#region src/toml.d.ts
5
-
6
5
  /**
7
6
  * Reads a TOML file and returns the object the TOML content represents.
8
7
  *
@@ -10,7 +9,7 @@ import TOML from "smol-toml";
10
9
  * @param options - TOML parse options
11
10
  * @returns Object the TOML content of the file represents
12
11
  */
13
- declare function readTomlFileSync(path: string, options?: Parameters<typeof TOML.parse>[1]): smol_toml0.TomlTableWithoutBigInt;
12
+ declare function readTomlFileSync(path: string, options?: Parameters<typeof TOML.parse>[1]): _$smol_toml0.TomlTableWithoutBigInt;
14
13
  /**
15
14
  * Reads a TOML file and returns the object the TOML content represents.
16
15
  *
@@ -18,7 +17,7 @@ declare function readTomlFileSync(path: string, options?: Parameters<typeof TOML
18
17
  * @param options - TOML parse options
19
18
  * @returns Object the TOML content of the file represents
20
19
  */
21
- declare function readTomlFile(path: string, options?: Parameters<typeof TOML.parse>[1]): Promise<smol_toml0.TomlTableWithoutBigInt>;
20
+ declare function readTomlFile(path: string, options?: Parameters<typeof TOML.parse>[1]): Promise<_$smol_toml0.TomlTableWithoutBigInt>;
22
21
  /**
23
22
  * Reads a TOML file and returns the object the TOML content represents.
24
23
  *
@@ -1 +1 @@
1
- {"version":3,"file":"toml.d.mts","names":[],"sources":["../src/toml.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA6BA;;;;AAE4C,iBAF5B,gBAAA,CAE4B,IAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAAhC,UAAgC,CAAA,OAAd,IAAA,CAAK,KAAS,CAAA,CAAA,CAAA,CAAA,CAAA,EAAtB,UAAA,CAAsB,sBAAA;AAc5C;;;;;;AAgBA;AAesB,iBA/BA,YAAA,CA+Ba,IAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EA7BvB,UA6BuB,CAAA,OA7BL,IAAA,CAAK,KA6BA,CAAA,CAAA,CAAA,CAAA,CAAA,EA7BS,OA6BT,CA7Bb,UAAA,CAAsB,sBAAA,CA6BT;;;;;;;;iBAfnB,iBAAA,uCAGJ,kBAAkB,IAAA,CAAK;;;;;;;;iBAYb,aAAA,uCAGV,kBAAkB,IAAA,CAAK,gBAChC"}
1
+ {"version":3,"file":"toml.d.mts","names":[],"sources":["../src/toml.ts"],"mappings":";;;;;;;AA6BA;;;;iBAAgB,gBAAA,CACd,IAAA,UACA,OAAA,GAAU,UAAA,QAAkB,IAAA,CAAK,KAAA,OAAb,YAAA,CAAsB,sBAAA;;;;;;;;iBActB,YAAA,CACpB,IAAA,UACA,OAAA,GAAU,UAAA,QAAkB,IAAA,CAAK,KAAA,OAAS,OAAA,CAAtB,YAAA,CAAsB,sBAAA;;;;AAF5C;;;;iBAgBgB,iBAAA,CACd,IAAA,UACA,IAAA,UACA,OAAA,GAAU,UAAA,QAAkB,IAAA,CAAK,SAAA;;;;;;;;iBAYb,aAAA,CACpB,IAAA,UACA,IAAA,UACA,OAAA,GAAU,UAAA,QAAkB,IAAA,CAAK,SAAA,OAChC,OAAA"}
package/dist/tsconfig.cjs CHANGED
@@ -1,14 +1,15 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
- const require_cwd = require('./path/src/cwd.cjs');
3
- const require_is_type = require('./path/src/is-type.cjs');
4
- const require_join_paths = require('./path/src/join-paths.cjs');
5
- const require_file_path_fns = require('./path/src/file-path-fns.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
6
3
  const require_exists = require('./exists.cjs');
7
- const require_to_array = require('./convert/src/to-array.cjs');
8
4
  const require_resolve = require('./resolve.cjs');
9
5
  const require_json = require('./json.cjs');
6
+ let _stryke_path_join_paths = require("@stryke/path/join-paths");
10
7
  let defu = require("defu");
11
- defu = require_rolldown_runtime.__toESM(defu);
8
+ defu = require_runtime.__toESM(defu, 1);
9
+ let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
10
+ let _stryke_convert_to_array = require("@stryke/convert/to-array");
11
+ let _stryke_path_cwd = require("@stryke/path/cwd");
12
+ let _stryke_path_is_type = require("@stryke/path/is-type");
12
13
 
13
14
  //#region src/tsconfig.ts
14
15
  /**
@@ -17,16 +18,16 @@ defu = require_rolldown_runtime.__toESM(defu);
17
18
  * @param filePath - The directory to start searching for the tsconfig.json file.
18
19
  * @returns The parsed tsconfig.json object or null if not found.
19
20
  */
20
- async function loadTsConfig(filePath = require_cwd.cwd()) {
21
- let tsconfigFilePath = require_file_path_fns.findFileExtension(filePath) === "json" ? filePath : require_join_paths.joinPaths(filePath, "tsconfig.json");
21
+ async function loadTsConfig(filePath = (0, _stryke_path_cwd.cwd)()) {
22
+ let tsconfigFilePath = (0, _stryke_path_file_path_fns.findFileExtension)(filePath) === "json" ? filePath : (0, _stryke_path_join_paths.joinPaths)(filePath, "tsconfig.json");
22
23
  if (!require_exists.existsSync(tsconfigFilePath)) {
23
24
  tsconfigFilePath = await require_resolve.resolve(filePath, { extensions: ["json"] });
24
25
  if (!require_exists.existsSync(tsconfigFilePath)) throw new Error(`tsconfig.json not found at ${tsconfigFilePath}. Please ensure the file exists.`);
25
26
  }
26
27
  let config = await require_json.readJsonFile(tsconfigFilePath);
27
- if (config?.compilerOptions?.baseUrl) config.compilerOptions.baseUrl = require_join_paths.joinPaths(require_file_path_fns.findFilePath(tsconfigFilePath), config.compilerOptions.baseUrl);
28
- if (config?.extends) for (const extendsName of require_to_array.toArray(config.extends)) {
29
- const parentConfig = await loadTsConfig(require_is_type.isNpmScopedPackage(extendsName) ? extendsName : require_join_paths.joinPaths(require_file_path_fns.findFilePath(tsconfigFilePath), extendsName));
28
+ if (config?.compilerOptions?.baseUrl) config.compilerOptions.baseUrl = (0, _stryke_path_join_paths.joinPaths)((0, _stryke_path_file_path_fns.findFilePath)(tsconfigFilePath), config.compilerOptions.baseUrl);
29
+ if (config?.extends) for (const extendsName of (0, _stryke_convert_to_array.toArray)(config.extends)) {
30
+ const parentConfig = await loadTsConfig((0, _stryke_path_is_type.isNpmScopedPackage)(extendsName) ? extendsName : (0, _stryke_path_join_paths.joinPaths)((0, _stryke_path_file_path_fns.findFilePath)(tsconfigFilePath), extendsName));
30
31
  if (parentConfig) config = (0, defu.default)(config, parentConfig ?? {});
31
32
  }
32
33
  config.extends = void 0;
@@ -1,7 +1,6 @@
1
1
  import { TsConfigJson } from "./types/src/tsconfig.cjs";
2
2
 
3
3
  //#region src/tsconfig.d.ts
4
-
5
4
  /**
6
5
  * Loads a tsconfig.json file and returns the parsed JSON object.
7
6
  *
@@ -1 +1 @@
1
- {"version":3,"file":"tsconfig.d.cts","names":[],"sources":["../src/tsconfig.ts"],"sourcesContent":[],"mappings":";;;;;;AAmCA;;;;iBAAsB,YAAA,qBAEnB,QAAQ"}
1
+ {"version":3,"file":"tsconfig.d.cts","names":[],"sources":["../src/tsconfig.ts"],"mappings":";;;;;AAmCA;;;;iBAAsB,YAAA,CACpB,QAAA,YACC,OAAA,CAAQ,YAAA"}
@@ -1,7 +1,6 @@
1
1
  import { TsConfigJson } from "./types/src/tsconfig.mjs";
2
2
 
3
3
  //#region src/tsconfig.d.ts
4
-
5
4
  /**
6
5
  * Loads a tsconfig.json file and returns the parsed JSON object.
7
6
  *
@@ -1 +1 @@
1
- {"version":3,"file":"tsconfig.d.mts","names":[],"sources":["../src/tsconfig.ts"],"sourcesContent":[],"mappings":";;;;;;AAmCA;;;;iBAAsB,YAAA,qBAEnB,QAAQ"}
1
+ {"version":3,"file":"tsconfig.d.mts","names":[],"sources":["../src/tsconfig.ts"],"mappings":";;;;;AAmCA;;;;iBAAsB,YAAA,CACpB,QAAA,YACC,OAAA,CAAQ,YAAA"}