@stryke/path 0.12.5 → 0.13.1

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 (45) hide show
  1. package/README.md +17 -14
  2. package/dist/correct-path.cjs +8 -7
  3. package/dist/correct-path.mjs +1 -1
  4. package/dist/cwd.cjs +9 -0
  5. package/dist/cwd.d.ts +9 -0
  6. package/dist/cwd.mjs +1 -0
  7. package/dist/delimiter.cjs +6 -6
  8. package/dist/delimiter.d.ts +12 -2
  9. package/dist/delimiter.mjs +1 -1
  10. package/dist/file-path-fns.cjs +59 -36
  11. package/dist/file-path-fns.d.ts +13 -1
  12. package/dist/file-path-fns.mjs +1 -1
  13. package/dist/get-parent-path.cjs +14 -15
  14. package/dist/get-parent-path.d.ts +1 -1
  15. package/dist/get-parent-path.mjs +1 -1
  16. package/dist/index.cjs +8 -41
  17. package/dist/index.d.ts +1 -4
  18. package/dist/index.mjs +1 -1
  19. package/dist/is-root-dir.cjs +4 -3
  20. package/dist/is-root-dir.d.ts +1 -1
  21. package/dist/is-root-dir.mjs +1 -1
  22. package/dist/is-type.cjs +23 -0
  23. package/dist/is-type.d.ts +34 -0
  24. package/dist/is-type.mjs +1 -0
  25. package/dist/join-paths.cjs +44 -50
  26. package/dist/join-paths.d.ts +1 -2
  27. package/dist/join-paths.mjs +1 -1
  28. package/dist/regex.cjs +3 -2
  29. package/dist/regex.d.ts +1 -0
  30. package/dist/regex.mjs +1 -1
  31. package/dist/replace.cjs +2 -1
  32. package/dist/replace.mjs +1 -1
  33. package/package.json +23 -60
  34. package/dist/exists.cjs +0 -12
  35. package/dist/exists.d.ts +0 -14
  36. package/dist/exists.mjs +0 -1
  37. package/dist/get-workspace-root.cjs +0 -38
  38. package/dist/get-workspace-root.d.ts +0 -30
  39. package/dist/get-workspace-root.mjs +0 -1
  40. package/dist/is-file.cjs +0 -39
  41. package/dist/is-file.d.ts +0 -46
  42. package/dist/is-file.mjs +0 -1
  43. package/dist/resolve.cjs +0 -59
  44. package/dist/resolve.d.ts +0 -71
  45. package/dist/resolve.mjs +0 -1
@@ -3,62 +3,56 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.joinPaths = void 0;
7
- const g = /^[A-Z]:\//i;
8
- function u(e = "") {
9
- return e && e.replace(/\\/g, "/").replace(g, t => t.toUpperCase());
6
+ exports.joinPaths = joinPaths;
7
+ var _isType = require("./is-type.cjs");
8
+ var _regex = require("./regex.cjs");
9
+ function m(n = "") {
10
+ return n && n.replace(/\\/g, "/").replace(_regex.DRIVE_LETTER_START_REGEX, t => t.toUpperCase());
11
+ }
12
+ function R(n) {
13
+ if (!n || n.length === 0) return ".";
14
+ n = m(n);
15
+ const t = n.match(_regex.UNC_REGEX),
16
+ e = (0, _isType.isAbsolute)(n),
17
+ l = n[n.length - 1] === "/";
18
+ return n = a(n, !e), n.length === 0 ? e ? "/" : l ? "./" : "." : (l && (n += "/"), _regex.DRIVE_LETTER_REGEX.test(n) && (n += "/"), t ? e ? `//${n}` : `//./${n}` : e && !(0, _isType.isAbsolute)(n) ? `/${n}` : n);
10
19
  }
11
- const E = /^[/\\]{2}/,
12
- _ = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,
13
- a = /^[A-Z]:$/i,
14
- c = function (e) {
15
- return _.test(e);
16
- },
17
- h = function (e) {
18
- if (!e || e.length === 0) return ".";
19
- e = u(e);
20
- const t = e.match(E),
21
- n = c(e),
22
- s = e[e.length - 1] === "/";
23
- return e = R(e, !n), e.length === 0 ? n ? "/" : s ? "./" : "." : (s && (e += "/"), a.test(e) && (e += "/"), t ? n ? `//${e}` : `//./${e}` : n && !c(e) ? `/${e}` : e);
24
- };
25
- const joinPaths = function (...e) {
20
+ function joinPaths(...n) {
26
21
  let t = "";
27
- for (const n of e) if (n) if (t.length > 0) {
28
- const s = t[t.length - 1] === "/",
29
- i = n[0] === "/";
30
- s && i ? t += n.slice(1) : t += s || i ? n : `/${n}`;
31
- } else t += n;
32
- return h(t);
33
- };
34
- exports.joinPaths = joinPaths;
35
- function R(e, t) {
36
- let n = "",
37
- s = 0,
38
- i = -1,
39
- o = 0,
40
- r = null;
41
- for (let l = 0; l <= e.length; ++l) {
42
- if (l < e.length) r = e[l];else {
43
- if (r === "/") break;
44
- r = "/";
22
+ for (const e of n) if (e) if (t.length > 0) {
23
+ const l = t[t.length - 1] === "/",
24
+ s = e[0] === "/";
25
+ l && s ? t += e.slice(1) : t += l || s ? e : `/${e}`;
26
+ } else t += e;
27
+ return R(t);
28
+ }
29
+ function a(n, t) {
30
+ let e = "",
31
+ l = 0,
32
+ s = -1,
33
+ r = 0,
34
+ o = null;
35
+ for (let i = 0; i <= n.length; ++i) {
36
+ if (i < n.length) o = n[i];else {
37
+ if (o === "/") break;
38
+ o = "/";
45
39
  }
46
- if (r === "/") {
47
- if (!(i === l - 1 || o === 1)) if (o === 2) {
48
- if (n.length < 2 || s !== 2 || n[n.length - 1] !== "." || n[n.length - 2] !== ".") {
49
- if (n.length > 2) {
50
- const f = n.lastIndexOf("/");
51
- f === -1 ? (n = "", s = 0) : (n = n.slice(0, f), s = n.length - 1 - n.lastIndexOf("/")), i = l, o = 0;
40
+ if (o === "/") {
41
+ if (!(s === i - 1 || r === 1)) if (r === 2) {
42
+ if (e.length < 2 || l !== 2 || e[e.length - 1] !== "." || e[e.length - 2] !== ".") {
43
+ if (e.length > 2) {
44
+ const f = e.lastIndexOf("/");
45
+ f === -1 ? (e = "", l = 0) : (e = e.slice(0, f), l = e.length - 1 - e.lastIndexOf("/")), s = i, r = 0;
52
46
  continue;
53
- } else if (n.length > 0) {
54
- n = "", s = 0, i = l, o = 0;
47
+ } else if (e.length > 0) {
48
+ e = "", l = 0, s = i, r = 0;
55
49
  continue;
56
50
  }
57
51
  }
58
- t && (n += n.length > 0 ? "/.." : "..", s = 2);
59
- } else n.length > 0 ? n += `/${e.slice(i + 1, l)}` : n = e.slice(i + 1, l), s = l - i - 1;
60
- i = l, o = 0;
61
- } else r === "." && o !== -1 ? ++o : o = -1;
52
+ t && (e += e.length > 0 ? "/.." : "..", l = 2);
53
+ } else e.length > 0 ? e += `/${n.slice(s + 1, i)}` : e = n.slice(s + 1, i), l = i - s - 1;
54
+ s = i, r = 0;
55
+ } else o === "." && r !== -1 ? ++r : r = -1;
62
56
  }
63
- return n;
57
+ return e;
64
58
  }
@@ -1,4 +1,3 @@
1
- import type path from "node:path";
2
1
  /**
3
2
  * Joins all given path segments together using the platform-specific separator as a delimiter.
4
3
  * The resulting path is normalized to remove any redundant or unnecessary segments.
@@ -6,4 +5,4 @@ import type path from "node:path";
6
5
  * @param segments - The path segments to join.
7
6
  * @returns The joined and normalized path string.
8
7
  */
9
- export declare const joinPaths: typeof path.join;
8
+ export declare function joinPaths(...segments: string[]): string;
@@ -1 +1 @@
1
- const g=/^[A-Z]:\//i;function u(e=""){return e&&e.replace(/\\/g,"/").replace(g,t=>t.toUpperCase())}const E=/^[/\\]{2}/,_=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,a=/^[A-Z]:$/i,c=function(e){return _.test(e)},h=function(e){if(!e||e.length===0)return".";e=u(e);const t=e.match(E),n=c(e),s=e[e.length-1]==="/";return e=R(e,!n),e.length===0?n?"/":s?"./":".":(s&&(e+="/"),a.test(e)&&(e+="/"),t?n?`//${e}`:`//./${e}`:n&&!c(e)?`/${e}`:e)};export const joinPaths=function(...e){let t="";for(const n of e)if(n)if(t.length>0){const s=t[t.length-1]==="/",i=n[0]==="/";s&&i?t+=n.slice(1):t+=s||i?n:`/${n}`}else t+=n;return h(t)};function R(e,t){let n="",s=0,i=-1,o=0,r=null;for(let l=0;l<=e.length;++l){if(l<e.length)r=e[l];else{if(r==="/")break;r="/"}if(r==="/"){if(!(i===l-1||o===1))if(o===2){if(n.length<2||s!==2||n[n.length-1]!=="."||n[n.length-2]!=="."){if(n.length>2){const f=n.lastIndexOf("/");f===-1?(n="",s=0):(n=n.slice(0,f),s=n.length-1-n.lastIndexOf("/")),i=l,o=0;continue}else if(n.length>0){n="",s=0,i=l,o=0;continue}}t&&(n+=n.length>0?"/..":"..",s=2)}else n.length>0?n+=`/${e.slice(i+1,l)}`:n=e.slice(i+1,l),s=l-i-1;i=l,o=0}else r==="."&&o!==-1?++o:o=-1}return n}
1
+ import{isAbsolute as g}from"./is-type";import{DRIVE_LETTER_REGEX as c,DRIVE_LETTER_START_REGEX as u,UNC_REGEX as E}from"./regex";function m(n=""){return n&&n.replace(/\\/g,"/").replace(u,t=>t.toUpperCase())}function R(n){if(!n||n.length===0)return".";n=m(n);const t=n.match(E),e=g(n),l=n[n.length-1]==="/";return n=a(n,!e),n.length===0?e?"/":l?"./":".":(l&&(n+="/"),c.test(n)&&(n+="/"),t?e?`//${n}`:`//./${n}`:e&&!g(n)?`/${n}`:n)}export function joinPaths(...n){let t="";for(const e of n)if(e)if(t.length>0){const l=t[t.length-1]==="/",s=e[0]==="/";l&&s?t+=e.slice(1):t+=l||s?e:`/${e}`}else t+=e;return R(t)}function a(n,t){let e="",l=0,s=-1,r=0,o=null;for(let i=0;i<=n.length;++i){if(i<n.length)o=n[i];else{if(o==="/")break;o="/"}if(o==="/"){if(!(s===i-1||r===1))if(r===2){if(e.length<2||l!==2||e[e.length-1]!=="."||e[e.length-2]!=="."){if(e.length>2){const f=e.lastIndexOf("/");f===-1?(e="",l=0):(e=e.slice(0,f),l=e.length-1-e.lastIndexOf("/")),s=i,r=0;continue}else if(e.length>0){e="",l=0,s=i,r=0;continue}}t&&(e+=e.length>0?"/..":"..",l=2)}else e.length>0?e+=`/${n.slice(s+1,i)}`:e=n.slice(s+1,i),l=i-s-1;s=i,r=0}else o==="."&&r!==-1?++r:r=-1}return e}
package/dist/regex.cjs CHANGED
@@ -3,8 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.UNC_REGEX = exports.DRIVE_LETTER_START_REGEX = exports.DRIVE_LETTER_REGEX = exports.ABSOLUTE_PATH_REGEX = void 0;
6
+ exports.UNC_REGEX = exports.ROOT_FOLDER_REGEX = exports.DRIVE_LETTER_START_REGEX = exports.DRIVE_LETTER_REGEX = exports.ABSOLUTE_PATH_REGEX = void 0;
7
7
  const DRIVE_LETTER_START_REGEX = exports.DRIVE_LETTER_START_REGEX = /^[A-Z]:\//i,
8
8
  DRIVE_LETTER_REGEX = exports.DRIVE_LETTER_REGEX = /^[A-Z]:$/i,
9
9
  UNC_REGEX = exports.UNC_REGEX = /^[/\\]{2}/,
10
- ABSOLUTE_PATH_REGEX = exports.ABSOLUTE_PATH_REGEX = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^~[/\\]|^[A-Z]:[/\\]/i;
10
+ ABSOLUTE_PATH_REGEX = exports.ABSOLUTE_PATH_REGEX = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^~[/\\]|^[A-Z]:[/\\]/i,
11
+ ROOT_FOLDER_REGEX = exports.ROOT_FOLDER_REGEX = /^\/([A-Z]:)?$/i;
package/dist/regex.d.ts CHANGED
@@ -2,3 +2,4 @@ export declare const DRIVE_LETTER_START_REGEX: RegExp;
2
2
  export declare const DRIVE_LETTER_REGEX: RegExp;
3
3
  export declare const UNC_REGEX: RegExp;
4
4
  export declare const ABSOLUTE_PATH_REGEX: RegExp;
5
+ export declare const ROOT_FOLDER_REGEX: RegExp;
package/dist/regex.mjs CHANGED
@@ -1 +1 @@
1
- export const DRIVE_LETTER_START_REGEX=/^[A-Z]:\//i,DRIVE_LETTER_REGEX=/^[A-Z]:$/i,UNC_REGEX=/^[/\\]{2}/,ABSOLUTE_PATH_REGEX=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^~[/\\]|^[A-Z]:[/\\]/i;
1
+ export const DRIVE_LETTER_START_REGEX=/^[A-Z]:\//i,DRIVE_LETTER_REGEX=/^[A-Z]:$/i,UNC_REGEX=/^[/\\]{2}/,ABSOLUTE_PATH_REGEX=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^~[/\\]|^[A-Z]:[/\\]/i,ROOT_FOLDER_REGEX=/^\/([A-Z]:)?$/i;
package/dist/replace.cjs CHANGED
@@ -4,8 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.replacePath = replacePath;
7
+ var _cwd = require("./cwd.cjs");
7
8
  var _isParentPath = require("./is-parent-path.cjs");
8
9
  var _slash = require("./slash.cjs");
9
- function replacePath(r, e = process.cwd()) {
10
+ function replacePath(r, e = (0, _cwd.cwd)()) {
10
11
  return (0, _isParentPath.isParentPath)(r, e) ? (0, _slash.slash)(r).replace((0, _slash.slash)(e), "").replace(/^\//, "") : r;
11
12
  }
package/dist/replace.mjs CHANGED
@@ -1 +1 @@
1
- import{isParentPath as o}from"./is-parent-path";import{slash as s}from"./slash";export function replacePath(r,e=process.cwd()){return o(r,e)?s(r).replace(s(e),"").replace(/^\//,""):r}
1
+ import{cwd as t}from"./cwd";import{isParentPath as i}from"./is-parent-path";import{slash as o}from"./slash";export function replacePath(r,e=t()){return i(r,e)?o(r).replace(o(e),"").replace(/^\//,""):r}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/path",
3
- "version": "0.12.5",
3
+ "version": "0.13.1",
4
4
  "type": "module",
5
5
  "description": "A package containing various utilities that expand the functionality of NodeJs's built-in `path` module",
6
6
  "repository": {
@@ -9,9 +9,9 @@
9
9
  "directory": "packages/path"
10
10
  },
11
11
  "private": false,
12
- "dependencies": { "@storm-software/config-tools": "latest", "mlly": "1.7.4" },
13
- "devDependencies": { "@stryke/types": "^0.8.9", "@types/node": "^22.14.0" },
12
+ "devDependencies": { "@stryke/types": "^0.8.9" },
14
13
  "publishConfig": { "access": "public" },
14
+ "dependencies": {},
15
15
  "sideEffects": false,
16
16
  "files": ["dist/**/*"],
17
17
  "homepage": "https://stormsoftware.com",
@@ -63,20 +63,6 @@
63
63
  },
64
64
  "default": { "types": "./dist/slash.d.ts", "default": "./dist/slash.mjs" }
65
65
  },
66
- "./resolve": {
67
- "import": {
68
- "types": "./dist/resolve.d.ts",
69
- "default": "./dist/resolve.mjs"
70
- },
71
- "require": {
72
- "types": "./dist/resolve.d.ts",
73
- "default": "./dist/resolve.cjs"
74
- },
75
- "default": {
76
- "types": "./dist/resolve.d.ts",
77
- "default": "./dist/resolve.mjs"
78
- }
79
- },
80
66
  "./replace": {
81
67
  "import": {
82
68
  "types": "./dist/replace.d.ts",
@@ -113,6 +99,20 @@
113
99
  "default": "./dist/join-paths.mjs"
114
100
  }
115
101
  },
102
+ "./is-type": {
103
+ "import": {
104
+ "types": "./dist/is-type.d.ts",
105
+ "default": "./dist/is-type.mjs"
106
+ },
107
+ "require": {
108
+ "types": "./dist/is-type.d.ts",
109
+ "default": "./dist/is-type.cjs"
110
+ },
111
+ "default": {
112
+ "types": "./dist/is-type.d.ts",
113
+ "default": "./dist/is-type.mjs"
114
+ }
115
+ },
116
116
  "./is-root-dir": {
117
117
  "import": {
118
118
  "types": "./dist/is-root-dir.d.ts",
@@ -141,20 +141,6 @@
141
141
  "default": "./dist/is-parent-path.mjs"
142
142
  }
143
143
  },
144
- "./is-file": {
145
- "import": {
146
- "types": "./dist/is-file.d.ts",
147
- "default": "./dist/is-file.mjs"
148
- },
149
- "require": {
150
- "types": "./dist/is-file.d.ts",
151
- "default": "./dist/is-file.cjs"
152
- },
153
- "default": {
154
- "types": "./dist/is-file.d.ts",
155
- "default": "./dist/is-file.mjs"
156
- }
157
- },
158
144
  "./index": {
159
145
  "import": { "types": "./dist/index.d.ts", "default": "./dist/index.mjs" },
160
146
  "require": {
@@ -163,20 +149,6 @@
163
149
  },
164
150
  "default": { "types": "./dist/index.d.ts", "default": "./dist/index.mjs" }
165
151
  },
166
- "./get-workspace-root": {
167
- "import": {
168
- "types": "./dist/get-workspace-root.d.ts",
169
- "default": "./dist/get-workspace-root.mjs"
170
- },
171
- "require": {
172
- "types": "./dist/get-workspace-root.d.ts",
173
- "default": "./dist/get-workspace-root.cjs"
174
- },
175
- "default": {
176
- "types": "./dist/get-workspace-root.d.ts",
177
- "default": "./dist/get-workspace-root.mjs"
178
- }
179
- },
180
152
  "./get-parent-path": {
181
153
  "import": {
182
154
  "types": "./dist/get-parent-path.d.ts",
@@ -205,20 +177,6 @@
205
177
  "default": "./dist/file-path-fns.mjs"
206
178
  }
207
179
  },
208
- "./exists": {
209
- "import": {
210
- "types": "./dist/exists.d.ts",
211
- "default": "./dist/exists.mjs"
212
- },
213
- "require": {
214
- "types": "./dist/exists.d.ts",
215
- "default": "./dist/exists.cjs"
216
- },
217
- "default": {
218
- "types": "./dist/exists.d.ts",
219
- "default": "./dist/exists.mjs"
220
- }
221
- },
222
180
  "./delimiter": {
223
181
  "import": {
224
182
  "types": "./dist/delimiter.d.ts",
@@ -233,6 +191,11 @@
233
191
  "default": "./dist/delimiter.mjs"
234
192
  }
235
193
  },
194
+ "./cwd": {
195
+ "import": { "types": "./dist/cwd.d.ts", "default": "./dist/cwd.mjs" },
196
+ "require": { "types": "./dist/cwd.d.ts", "default": "./dist/cwd.cjs" },
197
+ "default": { "types": "./dist/cwd.d.ts", "default": "./dist/cwd.mjs" }
198
+ },
236
199
  "./correct-path": {
237
200
  "import": {
238
201
  "types": "./dist/correct-path.d.ts",
@@ -274,5 +237,5 @@
274
237
  "main": "./dist/index.cjs",
275
238
  "module": "./dist/index.mjs",
276
239
  "types": "./dist/index.d.ts",
277
- "gitHead": "f8abb224a6b6540e442cc664bbb2cf1273b2be2b"
240
+ "gitHead": "7ec1f888f4eb3038ac5316409189322fda2e5aa6"
278
241
  }
package/dist/exists.cjs DELETED
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.existsSync = exports.exists = void 0;
7
- var _nodeFs = require("node:fs");
8
- var _promises = require("node:fs/promises");
9
- const existsSync = s => (0, _nodeFs.existsSync)(s),
10
- exists = async s => (0, _promises.access)(s, _promises.constants.F_OK).then(() => !0).catch(() => !1);
11
- exports.exists = exists;
12
- exports.existsSync = existsSync;
package/dist/exists.d.ts DELETED
@@ -1,14 +0,0 @@
1
- /**
2
- * Check if a file exists
3
- *
4
- * @param filePath - The file path to check
5
- * @returns An indicator specifying if the file exists
6
- */
7
- export declare const existsSync: (filePath: string) => boolean;
8
- /**
9
- * Check if a file exists
10
- *
11
- * @param filePath - The file path to check
12
- * @returns An indicator specifying if the file exists
13
- */
14
- export declare const exists: (filePath: string) => Promise<boolean>;
package/dist/exists.mjs DELETED
@@ -1 +0,0 @@
1
- import{existsSync as t}from"node:fs";import{access as e,constants as n}from"node:fs/promises";export const existsSync=s=>t(s),exists=async s=>e(s,n.F_OK).then(()=>!0).catch(()=>!1);
@@ -1,38 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.WORKSPACE_ROOT_CONTENT = exports.PROJECT_ROOT_CONTENT = void 0;
7
- exports.getProjectRoot = getProjectRoot;
8
- exports.getWorkspaceRoot = getWorkspaceRoot;
9
- exports.isProjectRoot = isProjectRoot;
10
- exports.isWorkspaceRoot = isWorkspaceRoot;
11
- var _configTools = require("@storm-software/config-tools");
12
- var _getParentPath = require("./get-parent-path.cjs");
13
- var _isRootDir = require("./is-root-dir.cjs");
14
- const WORKSPACE_ROOT_CONTENT = exports.WORKSPACE_ROOT_CONTENT = ["package-lock.json", "yarn.lock", "pnpm-lock.yaml", "bun.lock", "nx.json", "knip.json", "pnpm-workspace.yaml", "LICENSE", ".all-contributorsrc", ".whitesource", "syncpack.config.js", "syncpack.json", "socket.yaml", "lefthook.yaml", ".npmrc", ".log4brains.yml", ".huskyrc", ".husky", ".lintstagedrc", ".commitlintrc", "lefthook.yml", ".github", ".nx", ".vscode", "patches"],
15
- PROJECT_ROOT_CONTENT = exports.PROJECT_ROOT_CONTENT = ["project.json", "package.json", ".storm"];
16
- function getWorkspaceRoot(o = process.cwd()) {
17
- if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) return process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH;
18
- const t = (0, _configTools.findWorkspaceRootSafe)(o);
19
- if (t) return t;
20
- let r = (0, _getParentPath.getParentPath)(WORKSPACE_ROOT_CONTENT, o);
21
- if (r) return r;
22
- for (r = o; r && !(0, _isRootDir.isSystemRoot)(r);) if (r = (0, _getParentPath.getParentPath)("storm-workspace.json", r, {
23
- skipCwd: !0
24
- }), r) return r;
25
- return o;
26
- }
27
- function isWorkspaceRoot(o = process.cwd()) {
28
- const t = getWorkspaceRoot(o);
29
- return t ? t === o : !1;
30
- }
31
- function getProjectRoot(o = process.cwd()) {
32
- const t = (0, _getParentPath.getParentPath)(PROJECT_ROOT_CONTENT, o);
33
- return t || o;
34
- }
35
- function isProjectRoot(o = process.cwd()) {
36
- const t = getProjectRoot(o);
37
- return t ? t === o : !1;
38
- }
@@ -1,30 +0,0 @@
1
- export declare const WORKSPACE_ROOT_CONTENT: string[];
2
- export declare const PROJECT_ROOT_CONTENT: string[];
3
- /**
4
- * Get the workspace root path
5
- *
6
- * @param dir - A directory to start the search from
7
- * @returns The workspace root path
8
- */
9
- export declare function getWorkspaceRoot(dir?: string): string;
10
- /**
11
- * Check if the given directory is the workspace root
12
- *
13
- * @param dir - A directory to check
14
- * @returns True if the directory is the workspace root, false otherwise
15
- */
16
- export declare function isWorkspaceRoot(dir?: string): boolean;
17
- /**
18
- * Get the project root path
19
- *
20
- * @param dir - A directory to start the search from
21
- * @returns The project root path
22
- */
23
- export declare function getProjectRoot(dir?: string): string;
24
- /**
25
- * Check if the given directory is the project root
26
- *
27
- * @param dir - A directory to check
28
- * @returns True if the directory is the project root, false otherwise
29
- */
30
- export declare function isProjectRoot(dir?: string): boolean;
@@ -1 +0,0 @@
1
- import{findWorkspaceRootSafe as e}from"@storm-software/config-tools";import{getParentPath as s}from"./get-parent-path";import{isSystemRoot as n}from"./is-root-dir";export const WORKSPACE_ROOT_CONTENT=["package-lock.json","yarn.lock","pnpm-lock.yaml","bun.lock","nx.json","knip.json","pnpm-workspace.yaml","LICENSE",".all-contributorsrc",".whitesource","syncpack.config.js","syncpack.json","socket.yaml","lefthook.yaml",".npmrc",".log4brains.yml",".huskyrc",".husky",".lintstagedrc",".commitlintrc","lefthook.yml",".github",".nx",".vscode","patches"],PROJECT_ROOT_CONTENT=["project.json","package.json",".storm"];export function getWorkspaceRoot(o=process.cwd()){if(process.env.STORM_WORKSPACE_ROOT||process.env.NX_WORKSPACE_ROOT_PATH)return process.env.STORM_WORKSPACE_ROOT||process.env.NX_WORKSPACE_ROOT_PATH;const t=e(o);if(t)return t;let r=s(WORKSPACE_ROOT_CONTENT,o);if(r)return r;for(r=o;r&&!n(r);)if(r=s("storm-workspace.json",r,{skipCwd:!0}),r)return r;return o}export function isWorkspaceRoot(o=process.cwd()){const t=getWorkspaceRoot(o);return t?t===o:!1}export function getProjectRoot(o=process.cwd()){const t=s(PROJECT_ROOT_CONTENT,o);return t||o}export function isProjectRoot(o=process.cwd()){const t=getProjectRoot(o);return t?t===o:!1}
package/dist/is-file.cjs DELETED
@@ -1,39 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isAbsolutePath = isAbsolutePath;
7
- exports.isDirectory = isDirectory;
8
- exports.isDirectorySymlink = void 0;
9
- exports.isFile = isFile;
10
- exports.isFileSymlink = void 0;
11
- exports.isRelativePath = isRelativePath;
12
- var _nodeFs = require("node:fs");
13
- var _joinPaths = require("./join-paths.cjs");
14
- var _regex = require("./regex.cjs");
15
- var _slash = require("./slash.cjs");
16
- function isFile(r, o) {
17
- return !!(0, _nodeFs.statSync)(o ? (0, _joinPaths.joinPaths)(o, r) : r, {
18
- throwIfNoEntry: !1
19
- })?.isFile();
20
- }
21
- function isDirectory(r, o) {
22
- return !!(0, _nodeFs.statSync)(o ? (0, _joinPaths.joinPaths)(o, r) : r, {
23
- throwIfNoEntry: !1
24
- })?.isDirectory();
25
- }
26
- const isFileSymlink = (r, o) => !!(0, _nodeFs.lstatSync)(o ? (0, _joinPaths.joinPaths)(o, r) : r, {
27
- throwIfNoEntry: !1
28
- })?.isFile(),
29
- isDirectorySymlink = (r, o) => !!(0, _nodeFs.lstatSync)(o ? (0, _joinPaths.joinPaths)(o, r) : r, {
30
- throwIfNoEntry: !1
31
- })?.isDirectory();
32
- exports.isDirectorySymlink = isDirectorySymlink;
33
- exports.isFileSymlink = isFileSymlink;
34
- function isAbsolutePath(r) {
35
- return _regex.ABSOLUTE_PATH_REGEX.test((0, _slash.slash)(r));
36
- }
37
- function isRelativePath(r) {
38
- return !isAbsolutePath(r);
39
- }
package/dist/is-file.d.ts DELETED
@@ -1,46 +0,0 @@
1
- /**
2
- * Check if the given path is a file.
3
- *
4
- * @param path - The location to check
5
- * @param additionalPath - An optional additional path to add to the start of the path
6
- * @returns An indicator specifying if the path is a file
7
- */
8
- export declare function isFile(path: string, additionalPath?: string): boolean;
9
- /**
10
- * Check if the given path is a directory.
11
- *
12
- * @param path - The location to check
13
- * @param additionalPath - An optional additional path to add to the start of the path
14
- * @returns An indicator specifying if the path is a directory
15
- */
16
- export declare function isDirectory(path: string, additionalPath?: string): boolean;
17
- /**
18
- * Check if the given path is a file . Does not dereference symbolic links.
19
- *
20
- * @param path - The location to check
21
- * @param additionalPath - An optional additional path to add to the start of the path
22
- * @returns An indicator specifying if the path is a file
23
- */
24
- export declare const isFileSymlink: (path: string, additionalPath?: string) => boolean;
25
- /**
26
- * Check if the given path is a directory. Does not dereference symbolic links.
27
- *
28
- * @param path - The location to check
29
- * @param additionalPath - An optional additional path to add to the start of the path
30
- * @returns An indicator specifying if the path is a directory
31
- */
32
- export declare const isDirectorySymlink: (path: string, additionalPath?: string) => boolean;
33
- /**
34
- * Check if the path is an absolute path.
35
- *
36
- * @param path - The path to check
37
- * @returns An indicator specifying if the path is an absolute path
38
- */
39
- export declare function isAbsolutePath(path: string): boolean;
40
- /**
41
- * Check if the path is a relative path.
42
- *
43
- * @param path - The path to check
44
- * @returns An indicator specifying if the path is a relative path
45
- */
46
- export declare function isRelativePath(path: string): boolean;
package/dist/is-file.mjs DELETED
@@ -1 +0,0 @@
1
- import{lstatSync as n,statSync as e}from"node:fs";import{joinPaths as t}from"./join-paths";import{ABSOLUTE_PATH_REGEX as s}from"./regex";import{slash as i}from"./slash";export function isFile(r,o){return!!e(o?t(o,r):r,{throwIfNoEntry:!1})?.isFile()}export function isDirectory(r,o){return!!e(o?t(o,r):r,{throwIfNoEntry:!1})?.isDirectory()}export const isFileSymlink=(r,o)=>!!n(o?t(o,r):r,{throwIfNoEntry:!1})?.isFile(),isDirectorySymlink=(r,o)=>!!n(o?t(o,r):r,{throwIfNoEntry:!1})?.isDirectory();export function isAbsolutePath(r){return s.test(i(r))}export function isRelativePath(r){return!isAbsolutePath(r)}
package/dist/resolve.cjs DELETED
@@ -1,59 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.importModule = importModule;
7
- exports.resolve = resolve;
8
- exports.resolvePackage = resolvePackage;
9
- exports.resolvePackageSync = resolvePackageSync;
10
- exports.resolveSafe = resolveSafe;
11
- exports.resolveSafeSync = resolveSafeSync;
12
- exports.resolveSync = resolveSync;
13
- var _mlly = require("mlly");
14
- var _correctPath = require("./correct-path.cjs");
15
- var _filePathFns = require("./file-path-fns.cjs");
16
- var _getWorkspaceRoot = require("./get-workspace-root.cjs");
17
- var _joinPaths = require("./join-paths.cjs");
18
- async function resolve(r, e = {}) {
19
- const t = e.paths ?? [];
20
- t.length === 0 && t.push(process.cwd());
21
- const n = (0, _getWorkspaceRoot.getWorkspaceRoot)();
22
- return t.includes(n) || t.push(n), (0, _correctPath.correctPath)(await (0, _mlly.resolvePath)(r, {
23
- url: t
24
- }));
25
- }
26
- function resolveSync(r, e = {}) {
27
- const t = e.paths ?? [];
28
- t.length === 0 && t.push(process.cwd());
29
- const n = (0, _getWorkspaceRoot.getWorkspaceRoot)();
30
- return t.includes(n) || t.push(n), (0, _correctPath.correctPath)((0, _mlly.resolvePathSync)(r, {
31
- url: e.paths
32
- }));
33
- }
34
- async function resolveSafe(r, e = {}) {
35
- try {
36
- return await resolve(r, e);
37
- } catch {
38
- return;
39
- }
40
- }
41
- function resolveSafeSync(r, e = {}) {
42
- try {
43
- return resolveSync(r, e);
44
- } catch {
45
- return;
46
- }
47
- }
48
- async function importModule(r) {
49
- const e = await Promise.resolve(`${r}`).then(s => require(s));
50
- return e && (0, _mlly.interopDefault)(e);
51
- }
52
- async function resolvePackage(r, e = {}) {
53
- let t = await resolveSafe((0, _joinPaths.joinPaths)(r, "package.json"), e);
54
- return t || (t = await resolveSafe((0, _joinPaths.joinPaths)(r, "index.js"), e), t || (t = await resolveSafe(r, e))), t ? (0, _filePathFns.findFilePath)(t) : void 0;
55
- }
56
- function resolvePackageSync(r, e = {}) {
57
- let t = resolveSafeSync((0, _joinPaths.joinPaths)(r, "package.json"), e);
58
- return t || (t = resolveSafeSync((0, _joinPaths.joinPaths)(r, "index.js"), e), t || (t = resolveSafeSync(r, e))), t ? (0, _filePathFns.findFilePath)(t) : void 0;
59
- }
package/dist/resolve.d.ts DELETED
@@ -1,71 +0,0 @@
1
- import type { Platform } from "@stryke/types/system";
2
- export interface PackageResolvingOptions {
3
- /**
4
- * Paths to resolve the package from
5
- */
6
- paths?: string[];
7
- /**
8
- * Resolve path as linux (stand-in for unix/posix) or win32
9
- */
10
- platform?: Platform;
11
- }
12
- /**
13
- * Resolve the path to a specified module
14
- *
15
- * @param path - The path to the module
16
- * @param options - The options to use when resolving the module
17
- * @returns A promise for the path to the module
18
- */
19
- export declare function resolve(path: string, options?: PackageResolvingOptions): Promise<string>;
20
- /**
21
- * Resolve the path to a specified module
22
- *
23
- * @param path - The path to the module
24
- * @param options - The options to use when resolving the module
25
- * @returns The path to the module or undefined
26
- */
27
- export declare function resolveSync(path: string, options?: PackageResolvingOptions): string;
28
- /**
29
- * Resolve the path to a specified module with error handling
30
- *
31
- * @param name - The name of the module
32
- * @param options - The options to use when resolving the module
33
- * @returns A promise for the path to the module
34
- */
35
- export declare function resolveSafe(name: string, options?: PackageResolvingOptions): Promise<string | undefined>;
36
- /**
37
- * Resolve the path to a specified module with error handling
38
- *
39
- * @param name - The name of the module
40
- * @param options - The options to use when resolving the module
41
- * @returns The path to the module or undefined
42
- */
43
- export declare function resolveSafeSync(name: string, options?: PackageResolvingOptions): string | undefined;
44
- /**
45
- * Import a module from a specified path
46
- *
47
- * @param path - The path to the module
48
- * @returns The module
49
- */
50
- export declare function importModule<T = any>(path: string): Promise<T>;
51
- /**
52
- * Resolve the path to a specified package asynchronously
53
- *
54
- * @remarks
55
- * 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.
56
- *
57
- * @param name - The name of the module
58
- * @returns A promise for the module or undefined
59
- */
60
- export declare function resolvePackage(name: string, options?: PackageResolvingOptions): Promise<string | undefined>;
61
- /**
62
- * Resolve the path to a specified package synchronously
63
- *
64
- * @remarks
65
- * 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.
66
- *
67
- * @param name - The name of the module
68
- * @param options - The options to use when resolving the module
69
- * @returns The module or undefined
70
- */
71
- export declare function resolvePackageSync(name: string, options?: PackageResolvingOptions): string | undefined;
package/dist/resolve.mjs DELETED
@@ -1 +0,0 @@
1
- import{interopDefault as c,resolvePath as p,resolvePathSync as f}from"mlly";import{correctPath as s}from"./correct-path";import{findFilePath as i}from"./file-path-fns";import{getWorkspaceRoot as a}from"./get-workspace-root";import{joinPaths as o}from"./join-paths";export async function resolve(r,e={}){const t=e.paths??[];t.length===0&&t.push(process.cwd());const n=a();return t.includes(n)||t.push(n),s(await p(r,{url:t}))}export function resolveSync(r,e={}){const t=e.paths??[];t.length===0&&t.push(process.cwd());const n=a();return t.includes(n)||t.push(n),s(f(r,{url:e.paths}))}export async function resolveSafe(r,e={}){try{return await resolve(r,e)}catch{return}}export function resolveSafeSync(r,e={}){try{return resolveSync(r,e)}catch{return}}export async function importModule(r){const e=await import(r);return e&&c(e)}export async function resolvePackage(r,e={}){let t=await resolveSafe(o(r,"package.json"),e);return t||(t=await resolveSafe(o(r,"index.js"),e),t||(t=await resolveSafe(r,e))),t?i(t):void 0}export function resolvePackageSync(r,e={}){let t=resolveSafeSync(o(r,"package.json"),e);return t||(t=resolveSafeSync(o(r,"index.js"),e),t||(t=resolveSafeSync(r,e))),t?i(t):void 0}