@stryke/path 0.0.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 (48) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +63 -0
  3. package/dist/index.cjs +38 -0
  4. package/dist/index.d.ts +11 -0
  5. package/dist/index.mjs +1 -0
  6. package/dist/resolve/index.cjs +16 -0
  7. package/dist/resolve/index.d.ts +1 -0
  8. package/dist/resolve/index.mjs +1 -0
  9. package/dist/resolve/resolve.cjs +59 -0
  10. package/dist/resolve/resolve.d.ts +64 -0
  11. package/dist/resolve/resolve.mjs +1 -0
  12. package/dist/utilities/delimiter.cjs +18 -0
  13. package/dist/utilities/delimiter.d.ts +10 -0
  14. package/dist/utilities/delimiter.mjs +1 -0
  15. package/dist/utilities/exists.cjs +12 -0
  16. package/dist/utilities/exists.d.ts +14 -0
  17. package/dist/utilities/exists.mjs +1 -0
  18. package/dist/utilities/file-path-fns.cjs +105 -0
  19. package/dist/utilities/file-path-fns.d.ts +118 -0
  20. package/dist/utilities/file-path-fns.mjs +1 -0
  21. package/dist/utilities/get-parent-path.cjs +27 -0
  22. package/dist/utilities/get-parent-path.d.ts +38 -0
  23. package/dist/utilities/get-parent-path.mjs +1 -0
  24. package/dist/utilities/index.cjs +93 -0
  25. package/dist/utilities/index.d.ts +8 -0
  26. package/dist/utilities/index.mjs +1 -0
  27. package/dist/utilities/is-file.cjs +37 -0
  28. package/dist/utilities/is-file.d.ts +46 -0
  29. package/dist/utilities/is-file.mjs +1 -0
  30. package/dist/utilities/is-root-dir.cjs +8 -0
  31. package/dist/utilities/is-root-dir.d.ts +7 -0
  32. package/dist/utilities/is-root-dir.mjs +1 -0
  33. package/dist/utilities/join-paths.cjs +16 -0
  34. package/dist/utilities/join-paths.d.ts +7 -0
  35. package/dist/utilities/join-paths.mjs +1 -0
  36. package/dist/utilities/normalize-path.cjs +52 -0
  37. package/dist/utilities/normalize-path.d.ts +25 -0
  38. package/dist/utilities/normalize-path.mjs +1 -0
  39. package/dist/workspace/asset-extensions.cjs +7 -0
  40. package/dist/workspace/asset-extensions.d.ts +7 -0
  41. package/dist/workspace/asset-extensions.mjs +1 -0
  42. package/dist/workspace/get-workspace-root.cjs +27 -0
  43. package/dist/workspace/get-workspace-root.d.ts +14 -0
  44. package/dist/workspace/get-workspace-root.mjs +1 -0
  45. package/dist/workspace/index.cjs +27 -0
  46. package/dist/workspace/index.d.ts +2 -0
  47. package/dist/workspace/index.mjs +1 -0
  48. package/package.json +322 -0
@@ -0,0 +1,118 @@
1
+ export type FindFileNameOptions = {
2
+ /**
3
+ * Require the file extension to be present in the file name.
4
+ *
5
+ * @defaultValue false
6
+ */
7
+ requireExtension?: boolean;
8
+ /**
9
+ * Return the file extension as part of the full file name result.
10
+ *
11
+ * @defaultValue true
12
+ */
13
+ withExtension?: boolean;
14
+ };
15
+ /**
16
+ * Find the file name from a file path.
17
+ *
18
+ * @example
19
+ * const fileName = findFileName("C:\\Users\\user\\Documents\\file.txt");
20
+ * // fileName = "file.txt"
21
+ *
22
+ * @param filePath - The file path to process
23
+ * @param options - The options to use when processing the file name
24
+ * @returns The file name
25
+ */
26
+ export declare function findFileName(filePath: string, { requireExtension, withExtension }?: FindFileNameOptions): string;
27
+ /**
28
+ * Find the full file path's directories from a file path.
29
+ *
30
+ * @example
31
+ * const folderPath = findFilePath("C:\\Users\\user\\Documents\\file.txt");
32
+ * // folderPath = "C:\\Users\\user\\Documents"
33
+ *
34
+ * @param filePath - The file path to process
35
+ * @returns The full file path's directories
36
+ */
37
+ export declare function findFilePath(filePath: string): string;
38
+ /**
39
+ * Find the top most folder containing the file from a file path.
40
+ *
41
+ * @remarks
42
+ * If you're looking for the full path of the folder (for example: `C:\\Users\\user\\Documents` instead of just `Documents`) containing the file, use {@link findFilePath} instead.
43
+ *
44
+ * The functionality of this method is similar to the {@link path.basename} function in Node's path module.
45
+ *
46
+ * @example
47
+ * const folderPath = findFolderName("C:\\Users\\user\\Documents\\file.txt");
48
+ * // folderPath = "Documents"
49
+ *
50
+ * @param filePath - The file path to process
51
+ * @returns The folder containing the file
52
+ */
53
+ export declare function findFolderName(filePath: string): string;
54
+ /**
55
+ * Find the file extension from a file path.
56
+ *
57
+ * @param filePath - The file path to process
58
+ * @returns The file extension
59
+ */
60
+ export declare function findFileExtension(filePath: string): string;
61
+ /**
62
+ * Check if a file path has a file name.
63
+ *
64
+ * @param filePath - The file path to process
65
+ * @returns An indicator specifying if the file path has a file name
66
+ */
67
+ export declare function hasFileName(filePath: string): boolean;
68
+ /**
69
+ * Check if a file path has a file path.
70
+ *
71
+ * @param filePath - The file path to process
72
+ * @returns An indicator specifying if the file path has a file path
73
+ */
74
+ export declare function hasFilePath(filePath: string): boolean;
75
+ /**
76
+ * Resolve the file path to an absolute path.
77
+ *
78
+ * @param path - The path to resolve
79
+ * @param cwd - The current working directory
80
+ * @returns The resolved path
81
+ */
82
+ export declare function resolvePath(path: string, cwd?: string): string;
83
+ /**
84
+ * Resolve the file path to an absolute path.
85
+ *
86
+ * @param paths - The paths to resolve
87
+ * @returns The resolved path
88
+ */
89
+ export declare function resolvePaths(...paths: string[]): string;
90
+ export declare function relativePath(from: string, to: string): string;
91
+ /**
92
+ * Find the file path relative to the workspace root path.
93
+ *
94
+ * @param filePath - The file path to process
95
+ * @returns The resolved file path
96
+ */
97
+ export declare function relativeToWorkspaceRoot(filePath: string): string;
98
+ /**
99
+ * Check if the path is a relative path.
100
+ *
101
+ * @param path - The path to check
102
+ * @returns An indicator specifying if the path is a relative path
103
+ */
104
+ export declare function parsePath(path: string): {
105
+ root: string;
106
+ dir: string;
107
+ base: string;
108
+ ext: string;
109
+ name: string;
110
+ };
111
+ /**
112
+ * Rename the file name with a new name.
113
+ *
114
+ * @param filePath - The current file path being processed
115
+ * @param newFileName - The updated file name being processed
116
+ * @returns The modified or unmodified file path.
117
+ */
118
+ export declare function renameFile(filePath: string, newFileName: string): string;
@@ -0,0 +1 @@
1
+ import{EMPTY_STRING as a}from"@stryke/types/utility-types/base";import{getWorkspaceRoot as u}from"../workspace/get-workspace-root";import{isAbsolutePath as c}from"./is-file";import{joinPaths as p}from"./join-paths";import{normalizeString as g,normalizeWindowsPath as l,sep as f}from"./normalize-path";export function findFileName(t,{requireExtension:e,withExtension:r}={}){const n=l(t)?.split(t?.includes(f)?f:t?.includes("/")?"/":"\\")?.pop()??"";return e===!0&&!n.includes(".")?a:r===!1&&n.includes(".")?n.split(".").shift()??a:n}export function findFilePath(t){const e=l(t);return e.replace(findFileName(e,{requireExtension:!0}),"")}export function findFolderName(t){let e=findFilePath(t).split("/"),r="";for(let n=e.length-1;n>=0;n--){const i=e[n];if(i){r=i;break}}return r??a}export function findFileExtension(t){if(t==="..")return"";const e=/.(\.[^./]+|\.)$/.exec(l(t));return e&&e[1]||a}export function hasFileName(t){return!!findFileName(t)}export function hasFilePath(t){return!!findFilePath(t)}export function resolvePath(t,e=u()){const r=l(t).split("/");let n="",i=!1;for(let o=r.length-1;o>=-1&&!i;o--){const s=o>=0?r[o]:e;!s||s.length===0||(n=`${s}/${n}`,i=c(s))}return n=g(n,!i),i&&!c(n)?`/${n}`:n.length>0?n:"."}export function resolvePaths(...t){return resolvePath(p(...t.map(e=>l(e))))}export function relativePath(t,e){const r=resolvePath(t).replace(/^\/([A-Za-z]:)?$/,"$1").split("/"),n=resolvePath(e).replace(/^\/([A-Za-z]:)?$/,"$1").split("/");if(n[0][1]===":"&&r[0][1]===":"&&r[0]!==n[0])return n.join("/");const i=[...r];for(const o of i){if(n[0]!==o)break;r.shift(),n.shift()}return[...r.map(()=>".."),...n].join("/")}export function relativeToWorkspaceRoot(t){return relativePath(t,u())}export function parsePath(t){const e=/^[/\\]|^[a-zA-Z]:[/\\]/.exec(t)?.[0]?.replace(/\\/g,"/")||"",r=l(t),n=r.replace(/\/$/,"").split("/").slice(0,-1);n.length===1&&/^[A-Za-z]:$/.test(n[0])&&(n[0]+="/");const i=findFolderName(r),o=n.join("/")||(c(t)?"/":"."),s=findFileExtension(t);return{root:e,dir:o,base:i,ext:s,name:i.slice(0,i.length-s.length)}}export function renameFile(t,e){const r=parsePath(t);return p(r.dir,e.includes(".")?e:e+r.ext)}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.resolveParentPath = exports.getParentPath = void 0;
7
+ var _filePathFns = require("./file-path-fns.cjs");
8
+ var _isFile = require("./is-file.cjs");
9
+ var _joinPaths = require("./join-paths.cjs");
10
+ const resolveParentPath = r => (0, _filePathFns.resolvePaths)(r, ".."),
11
+ getParentPath = (r, a, o) => {
12
+ const p = o?.ignoreCase ?? !0,
13
+ l = o?.skipCwd ?? !1,
14
+ e = o?.targetType ?? "both";
15
+ let t = a;
16
+ l && (t = resolveParentPath(a));
17
+ let n = Array.isArray(r) ? r : [r];
18
+ for (p && (n = n.map(i => i.toLowerCase()));;) {
19
+ const i = n.find(g => (0, _isFile.isFile)((0, _joinPaths.joinPaths)(t, g)) && (e === "file" || e === "both") || (0, _isFile.isDirectory)((0, _joinPaths.joinPaths)(t, g)) && (e === "directory" || e === "both"));
20
+ if (i) return (0, _joinPaths.joinPaths)(t, i);
21
+ const f = resolveParentPath(t);
22
+ if (f === t) return;
23
+ t = f;
24
+ }
25
+ };
26
+ exports.getParentPath = getParentPath;
27
+ exports.resolveParentPath = resolveParentPath;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Resolve the parent path of the provided path.
3
+ *
4
+ * @param path - The path to resolve.
5
+ * @returns The parent path of the provided path.
6
+ */
7
+ export declare const resolveParentPath: (path: string) => string;
8
+ /**
9
+ * Options for the `getParentPath` function.
10
+ */
11
+ export interface GetParentPathOptions {
12
+ /**
13
+ * Whether to ignore the case of the file names when checking for existence.
14
+ *
15
+ * @defaultValue true
16
+ */
17
+ ignoreCase: boolean;
18
+ /**
19
+ * Whether to skip the current working directory when checking for the file.
20
+ *
21
+ * @defaultValue false
22
+ */
23
+ skipCwd: boolean;
24
+ /**
25
+ * The type of target to look for.
26
+ *
27
+ * @defaultValue "both"
28
+ */
29
+ targetType: "file" | "directory" | "both";
30
+ }
31
+ /**
32
+ * Get the first parent path that has a file or directory with the provided name.
33
+ *
34
+ * @param name - The name (or names) of the file to look for in the parent paths.
35
+ * @param cwd - The current working directory.
36
+ * @returns The first parent path that exists.
37
+ */
38
+ export declare const getParentPath: (name: string | string[], cwd: string, options?: Partial<GetParentPathOptions>) => string | undefined;
@@ -0,0 +1 @@
1
+ import{resolvePaths as h}from"./file-path-fns";import{isDirectory as P,isFile as c}from"./is-file";import{joinPaths as s}from"./join-paths";export const resolveParentPath=r=>h(r,".."),getParentPath=(r,a,o)=>{const p=o?.ignoreCase??!0,l=o?.skipCwd??!1,e=o?.targetType??"both";let t=a;l&&(t=resolveParentPath(a));let n=Array.isArray(r)?r:[r];for(p&&(n=n.map(i=>i.toLowerCase()));;){const i=n.find(g=>c(s(t,g))&&(e==="file"||e==="both")||P(s(t,g))&&(e==="directory"||e==="both"));if(i)return s(t,i);const f=resolveParentPath(t);if(f===t)return;t=f}};
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _delimiter = require("./delimiter.cjs");
7
+ Object.keys(_delimiter).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _delimiter[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _delimiter[key];
14
+ }
15
+ });
16
+ });
17
+ var _exists = require("./exists.cjs");
18
+ Object.keys(_exists).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _exists[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _exists[key];
25
+ }
26
+ });
27
+ });
28
+ var _filePathFns = require("./file-path-fns.cjs");
29
+ Object.keys(_filePathFns).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _filePathFns[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _filePathFns[key];
36
+ }
37
+ });
38
+ });
39
+ var _getParentPath = require("./get-parent-path.cjs");
40
+ Object.keys(_getParentPath).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _getParentPath[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _getParentPath[key];
47
+ }
48
+ });
49
+ });
50
+ var _isFile = require("./is-file.cjs");
51
+ Object.keys(_isFile).forEach(function (key) {
52
+ if (key === "default" || key === "__esModule") return;
53
+ if (key in exports && exports[key] === _isFile[key]) return;
54
+ Object.defineProperty(exports, key, {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _isFile[key];
58
+ }
59
+ });
60
+ });
61
+ var _isRootDir = require("./is-root-dir.cjs");
62
+ Object.keys(_isRootDir).forEach(function (key) {
63
+ if (key === "default" || key === "__esModule") return;
64
+ if (key in exports && exports[key] === _isRootDir[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function () {
68
+ return _isRootDir[key];
69
+ }
70
+ });
71
+ });
72
+ var _joinPaths = require("./join-paths.cjs");
73
+ Object.keys(_joinPaths).forEach(function (key) {
74
+ if (key === "default" || key === "__esModule") return;
75
+ if (key in exports && exports[key] === _joinPaths[key]) return;
76
+ Object.defineProperty(exports, key, {
77
+ enumerable: true,
78
+ get: function () {
79
+ return _joinPaths[key];
80
+ }
81
+ });
82
+ });
83
+ var _normalizePath = require("./normalize-path.cjs");
84
+ Object.keys(_normalizePath).forEach(function (key) {
85
+ if (key === "default" || key === "__esModule") return;
86
+ if (key in exports && exports[key] === _normalizePath[key]) return;
87
+ Object.defineProperty(exports, key, {
88
+ enumerable: true,
89
+ get: function () {
90
+ return _normalizePath[key];
91
+ }
92
+ });
93
+ });
@@ -0,0 +1,8 @@
1
+ export * from "./delimiter";
2
+ export * from "./exists";
3
+ export * from "./file-path-fns";
4
+ export * from "./get-parent-path";
5
+ export * from "./is-file";
6
+ export * from "./is-root-dir";
7
+ export * from "./join-paths";
8
+ export * from "./normalize-path";
@@ -0,0 +1 @@
1
+ export*from"./delimiter";export*from"./exists";export*from"./file-path-fns";export*from"./get-parent-path";export*from"./is-file";export*from"./is-root-dir";export*from"./join-paths";export*from"./normalize-path";
@@ -0,0 +1,37 @@
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
+ function isFile(r, o) {
15
+ return !!(0, _nodeFs.statSync)(o ? (0, _joinPaths.joinPaths)(o, r) : r, {
16
+ throwIfNoEntry: !1
17
+ })?.isFile();
18
+ }
19
+ function isDirectory(r, o) {
20
+ return !!(0, _nodeFs.statSync)(o ? (0, _joinPaths.joinPaths)(o, r) : r, {
21
+ throwIfNoEntry: !1
22
+ })?.isDirectory();
23
+ }
24
+ const isFileSymlink = (r, o) => !!(0, _nodeFs.lstatSync)(o ? (0, _joinPaths.joinPaths)(o, r) : r, {
25
+ throwIfNoEntry: !1
26
+ })?.isFile(),
27
+ isDirectorySymlink = (r, o) => !!(0, _nodeFs.lstatSync)(o ? (0, _joinPaths.joinPaths)(o, r) : r, {
28
+ throwIfNoEntry: !1
29
+ })?.isDirectory();
30
+ exports.isDirectorySymlink = isDirectorySymlink;
31
+ exports.isFileSymlink = isFileSymlink;
32
+ function isRelativePath(r) {
33
+ return r === "." || r === ".." || r.startsWith("./") || r.startsWith("../");
34
+ }
35
+ function isAbsolutePath(r) {
36
+ return !/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/.test(r);
37
+ }
@@ -0,0 +1,46 @@
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 a relative path.
35
+ *
36
+ * @param path - The path to check
37
+ * @returns An indicator specifying if the path is a relative path
38
+ */
39
+ export declare function isRelativePath(path: string): boolean;
40
+ /**
41
+ * Check if the path is an absolute path.
42
+ *
43
+ * @param path - The path to check
44
+ * @returns An indicator specifying if the path is an absolute path
45
+ */
46
+ export declare function isAbsolutePath(path: string): boolean;
@@ -0,0 +1 @@
1
+ import{lstatSync as n,statSync as e}from"node:fs";import{joinPaths as t}from"./join-paths";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 isRelativePath(r){return r==="."||r===".."||r.startsWith("./")||r.startsWith("../")}export function isAbsolutePath(r){return!/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/.test(r)}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isSystemRoot = void 0;
7
+ const isSystemRoot = o => o === "/" || o === "c:\\" || o === "C:\\";
8
+ exports.isSystemRoot = isSystemRoot;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Check if the directory is the current system's root directory.
3
+ *
4
+ * @param dir - The directory to check.
5
+ * @returns Returns true if the directory is the root directory.
6
+ */
7
+ export declare const isSystemRoot: (dir: string) => boolean;
@@ -0,0 +1 @@
1
+ export const isSystemRoot=o=>o==="/"||o==="c:\\"||o==="C:\\";
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.joinPaths = joinPaths;
7
+ var _normalizePath = require("./normalize-path.cjs");
8
+ function joinPaths(...i) {
9
+ let t = "";
10
+ for (const n of i) if (n) if (t.length > 0) {
11
+ const o = t.at(-1) === "/",
12
+ e = n[0] === "/";
13
+ o && e ? t += n.slice(1) : t += o || e ? n : `/${n}`;
14
+ } else t += n;
15
+ return (0, _normalizePath.normalizePath)(t);
16
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Join multiple paths together.
3
+ *
4
+ * @param paths - The paths to join
5
+ * @returns The joined path
6
+ */
7
+ export declare function joinPaths(...paths: string[]): string;
@@ -0,0 +1 @@
1
+ import{normalizePath as s}from"./normalize-path";export function joinPaths(...i){let t="";for(const n of i)if(n)if(t.length>0){const o=t.at(-1)==="/",e=n[0]==="/";o&&e?t+=n.slice(1):t+=o||e?n:`/${n}`}else t+=n;return s(t)}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.normalizePath = normalizePath;
7
+ exports.normalizeString = normalizeString;
8
+ exports.normalizeWindowsPath = normalizeWindowsPath;
9
+ exports.sep = void 0;
10
+ var _isFile = require("./is-file.cjs");
11
+ function normalizeWindowsPath(e = "") {
12
+ return e && e.replace(/\\/g, "/").replace(/^[A-Za-z]:\//, s => s.toUpperCase());
13
+ }
14
+ const sep = exports.sep = "/";
15
+ function normalizeString(e, s) {
16
+ let n = "",
17
+ t = 0,
18
+ r = -1,
19
+ i = 0,
20
+ o = null;
21
+ for (let l = 0; l <= e.length; ++l) {
22
+ if (l < e.length) o = e[l];else {
23
+ if (o === "/") break;
24
+ o = "/";
25
+ }
26
+ if (o === "/") {
27
+ if (!(r === l - 1 || i === 1)) if (i === 2) {
28
+ if (n.length < 2 || t !== 2 || n.at(-1) !== "." || n.at(-2) !== ".") {
29
+ if (n.length > 2) {
30
+ const f = n.lastIndexOf("/");
31
+ f === -1 ? (n = "", t = 0) : (n = n.slice(0, f), t = n.length - 1 - n.lastIndexOf("/")), r = l, i = 0;
32
+ continue;
33
+ } else if (n.length > 0) {
34
+ n = "", t = 0, r = l, i = 0;
35
+ continue;
36
+ }
37
+ }
38
+ s && (n += n.length > 0 ? "/.." : "..", t = 2);
39
+ } else n.length > 0 ? n += `/${e.slice(r + 1, l)}` : n = e.slice(r + 1, l), t = l - r - 1;
40
+ r = l, i = 0;
41
+ } else o === "." && i !== -1 ? ++i : i = -1;
42
+ }
43
+ return n;
44
+ }
45
+ function normalizePath(e) {
46
+ if (!e || e.length === 0) return ".";
47
+ e = normalizeWindowsPath(e);
48
+ const s = e.match(/^[/\\]{2}/),
49
+ n = (0, _isFile.isAbsolutePath)(e),
50
+ t = e.at(-1) === "/";
51
+ return e = normalizeString(e, !n), e.length === 0 ? n ? "/" : t ? "./" : "." : (t && (e += "/"), /^[A-Za-z]:$/.test(e) && (e += "/"), s ? n ? `//${e}` : `//./${e}` : n && !(0, _isFile.isAbsolutePath)(e) ? `/${e}` : e);
52
+ }
@@ -0,0 +1,25 @@
1
+ export declare function normalizeWindowsPath(input?: string): string;
2
+ /**
3
+ * Constant for path separator.
4
+ *
5
+ * Always equals to `"/"`.
6
+ */
7
+ export declare const sep = "/";
8
+ /**
9
+ * Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
10
+ *
11
+ * @param path - The path to normalize.
12
+ * @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
13
+ * @returns the normalized path string.
14
+ */
15
+ export declare function normalizeString(path: string, allowAboveRoot: boolean): string;
16
+ /**
17
+ * Normalizes the given path.
18
+ *
19
+ * @remarks
20
+ * Removes duplicate slashes, removes trailing slashes, adds a leading slash.
21
+ *
22
+ * @param path - The path to normalize
23
+ * @returns The normalized path
24
+ */
25
+ export declare function normalizePath(path?: string): string;
@@ -0,0 +1 @@
1
+ import{isAbsolutePath as g}from"./is-file";export function normalizeWindowsPath(e=""){return e&&e.replace(/\\/g,"/").replace(/^[A-Za-z]:\//,s=>s.toUpperCase())}export const sep="/";export function normalizeString(e,s){let n="",t=0,r=-1,i=0,o=null;for(let l=0;l<=e.length;++l){if(l<e.length)o=e[l];else{if(o==="/")break;o="/"}if(o==="/"){if(!(r===l-1||i===1))if(i===2){if(n.length<2||t!==2||n.at(-1)!=="."||n.at(-2)!=="."){if(n.length>2){const f=n.lastIndexOf("/");f===-1?(n="",t=0):(n=n.slice(0,f),t=n.length-1-n.lastIndexOf("/")),r=l,i=0;continue}else if(n.length>0){n="",t=0,r=l,i=0;continue}}s&&(n+=n.length>0?"/..":"..",t=2)}else n.length>0?n+=`/${e.slice(r+1,l)}`:n=e.slice(r+1,l),t=l-r-1;r=l,i=0}else o==="."&&i!==-1?++i:i=-1}return n}export function normalizePath(e){if(!e||e.length===0)return".";e=normalizeWindowsPath(e);const s=e.match(/^[/\\]{2}/),n=g(e),t=e.at(-1)==="/";return e=normalizeString(e,!n),e.length===0?n?"/":t?"./":".":(t&&(e+="/"),/^[A-Za-z]:$/.test(e)&&(e+="/"),s?n?`//${e}`:`//./${e}`:n&&!g(e)?`/${e}`:e)}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DEFAULT_ASSET_EXTS = void 0;
7
+ const DEFAULT_ASSET_EXTS = exports.DEFAULT_ASSET_EXTS = ["bmp", "gif", "jpg", "jpeg", "png", "psd", "svg", "webp", "m4v", "mov", "mp4", "mpeg", "mpg", "webm", "aac", "aiff", "caf", "m4a", "mp3", "wav", "html", "pdf", "yaml", "yml", "otf", "ttf", "zip"];
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Default asset extensions
3
+ *
4
+ * @remarks
5
+ * For more info please see the {@link https://github.com/facebook/metro/blob/v0.80.10/packages/metro-config/src/defaults/defaults.js#L18-L52 | Metro defaults}
6
+ */
7
+ export declare const DEFAULT_ASSET_EXTS: string[];
@@ -0,0 +1 @@
1
+ export const DEFAULT_ASSET_EXTS=["bmp","gif","jpg","jpeg","png","psd","svg","webp","m4v","mov","mp4","mpeg","mpg","webm","aac","aiff","caf","m4a","mp3","wav","html","pdf","yaml","yml","otf","ttf","zip"];
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getWorkspaceRoot = exports.getProjectRoot = void 0;
7
+ var _configTools = require("@storm-software/config-tools");
8
+ var _packageManager = require("@stryke/types/utility-types/package-manager");
9
+ var _getParentPath = require("../utilities/get-parent-path.cjs");
10
+ var _isRootDir = require("../utilities/is-root-dir.cjs");
11
+ const getWorkspaceRoot = (e = process.cwd()) => {
12
+ if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) return process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH;
13
+ const r = (0, _configTools.findWorkspaceRootSafe)(e);
14
+ if (r) return r;
15
+ let o = (0, _getParentPath.getParentPath)([_packageManager.PackageManagerLockFiles.NPM, _packageManager.PackageManagerLockFiles.YARN, _packageManager.PackageManagerLockFiles.PNPM, _packageManager.PackageManagerLockFiles.BUN, "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"], e);
16
+ if (o) return o;
17
+ for (o = e; o && !(0, _isRootDir.isSystemRoot)(o);) if (o = (0, _getParentPath.getParentPath)("storm.json", o, {
18
+ skipCwd: !0
19
+ }), o) return o;
20
+ return e;
21
+ },
22
+ getProjectRoot = (e = process.cwd()) => {
23
+ let r = (0, _getParentPath.getParentPath)(["project.json", "package.json", ".storm"], e);
24
+ return r || e;
25
+ };
26
+ exports.getProjectRoot = getProjectRoot;
27
+ exports.getWorkspaceRoot = getWorkspaceRoot;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Get the workspace root path
3
+ *
4
+ * @param dir - A directory to start the search from
5
+ * @returns The workspace root path
6
+ */
7
+ export declare const getWorkspaceRoot: (dir?: string) => string;
8
+ /**
9
+ * Get the project root path
10
+ *
11
+ * @param dir - A directory to start the search from
12
+ * @returns The project root path
13
+ */
14
+ export declare const getProjectRoot: (dir?: string) => string;
@@ -0,0 +1 @@
1
+ import{findWorkspaceRootSafe as c}from"@storm-software/config-tools";import{PackageManagerLockFiles as t}from"@stryke/types/utility-types/package-manager";import{getParentPath as s}from"../utilities/get-parent-path";import{isSystemRoot as n}from"../utilities/is-root-dir";export const getWorkspaceRoot=(e=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 r=c(e);if(r)return r;let o=s([t.NPM,t.YARN,t.PNPM,t.BUN,"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"],e);if(o)return o;for(o=e;o&&!n(o);)if(o=s("storm.json",o,{skipCwd:!0}),o)return o;return e},getProjectRoot=(e=process.cwd())=>{let r=s(["project.json","package.json",".storm"],e);return r||e};
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _assetExtensions = require("./asset-extensions.cjs");
7
+ Object.keys(_assetExtensions).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _assetExtensions[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _assetExtensions[key];
14
+ }
15
+ });
16
+ });
17
+ var _getWorkspaceRoot = require("./get-workspace-root.cjs");
18
+ Object.keys(_getWorkspaceRoot).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _getWorkspaceRoot[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _getWorkspaceRoot[key];
25
+ }
26
+ });
27
+ });
@@ -0,0 +1,2 @@
1
+ export * from "./asset-extensions";
2
+ export * from "./get-workspace-root";
@@ -0,0 +1 @@
1
+ export*from"./asset-extensions";export*from"./get-workspace-root";