@stryke/path 0.3.2 → 0.4.0
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.
- package/dist/{utilities/file-path-fns.cjs → file-path-fns.cjs} +2 -2
- package/dist/{utilities/file-path-fns.d.ts → file-path-fns.d.ts} +1 -1
- package/dist/file-path-fns.mjs +1 -0
- package/dist/{workspace/get-workspace-root.cjs → get-workspace-root.cjs} +3 -3
- package/dist/get-workspace-root.mjs +1 -0
- package/dist/index.cjs +100 -12
- package/dist/index.d.ts +10 -2
- package/dist/index.mjs +1 -1
- package/dist/join-paths.cjs +17 -0
- package/dist/join-paths.d.ts +11 -0
- package/dist/join-paths.mjs +1 -0
- package/dist/{utilities/normalize-path.cjs → normalize-path.cjs} +23 -21
- package/dist/{utilities/normalize-path.d.ts → normalize-path.d.ts} +2 -17
- package/dist/normalize-path.mjs +1 -0
- package/dist/{resolve/resolve.cjs → resolve.cjs} +2 -2
- package/dist/{resolve/resolve.d.ts → resolve.d.ts} +7 -7
- package/package.json +84 -169
- package/dist/resolve/index.cjs +0 -16
- package/dist/resolve/index.d.ts +0 -1
- package/dist/resolve/index.mjs +0 -1
- package/dist/utilities/file-path-fns.mjs +0 -1
- package/dist/utilities/index.cjs +0 -93
- package/dist/utilities/index.d.ts +0 -8
- package/dist/utilities/index.mjs +0 -1
- package/dist/utilities/join-paths.cjs +0 -16
- package/dist/utilities/join-paths.d.ts +0 -7
- package/dist/utilities/join-paths.mjs +0 -1
- package/dist/utilities/normalize-path.mjs +0 -1
- package/dist/workspace/get-workspace-root.mjs +0 -1
- package/dist/workspace/index.cjs +0 -27
- package/dist/workspace/index.d.ts +0 -2
- package/dist/workspace/index.mjs +0 -1
- /package/dist/{workspace/asset-extensions.cjs → asset-extensions.cjs} +0 -0
- /package/dist/{workspace/asset-extensions.d.ts → asset-extensions.d.ts} +0 -0
- /package/dist/{workspace/asset-extensions.mjs → asset-extensions.mjs} +0 -0
- /package/dist/{utilities/delimiter.cjs → delimiter.cjs} +0 -0
- /package/dist/{utilities/delimiter.d.ts → delimiter.d.ts} +0 -0
- /package/dist/{utilities/delimiter.mjs → delimiter.mjs} +0 -0
- /package/dist/{utilities/exists.cjs → exists.cjs} +0 -0
- /package/dist/{utilities/exists.d.ts → exists.d.ts} +0 -0
- /package/dist/{utilities/exists.mjs → exists.mjs} +0 -0
- /package/dist/{utilities/get-parent-path.cjs → get-parent-path.cjs} +0 -0
- /package/dist/{utilities/get-parent-path.d.ts → get-parent-path.d.ts} +0 -0
- /package/dist/{utilities/get-parent-path.mjs → get-parent-path.mjs} +0 -0
- /package/dist/{workspace/get-workspace-root.d.ts → get-workspace-root.d.ts} +0 -0
- /package/dist/{utilities/is-file.cjs → is-file.cjs} +0 -0
- /package/dist/{utilities/is-file.d.ts → is-file.d.ts} +0 -0
- /package/dist/{utilities/is-file.mjs → is-file.mjs} +0 -0
- /package/dist/{utilities/is-root-dir.cjs → is-root-dir.cjs} +0 -0
- /package/dist/{utilities/is-root-dir.d.ts → is-root-dir.d.ts} +0 -0
- /package/dist/{utilities/is-root-dir.mjs → is-root-dir.mjs} +0 -0
- /package/dist/{resolve/resolve.mjs → resolve.mjs} +0 -0
|
@@ -15,8 +15,8 @@ exports.relativeToWorkspaceRoot = relativeToWorkspaceRoot;
|
|
|
15
15
|
exports.renameFile = renameFile;
|
|
16
16
|
exports.resolvePath = resolvePath;
|
|
17
17
|
exports.resolvePaths = resolvePaths;
|
|
18
|
-
var _base = require("@stryke/types/
|
|
19
|
-
var _getWorkspaceRoot = require("../workspace/get-workspace-root
|
|
18
|
+
var _base = require("@stryke/types/base");
|
|
19
|
+
var _getWorkspaceRoot = require("../workspace/get-workspace-root");
|
|
20
20
|
var _isFile = require("./is-file.cjs");
|
|
21
21
|
var _joinPaths = require("./join-paths.cjs");
|
|
22
22
|
var _normalizePath = require("./normalize-path.cjs");
|
|
@@ -83,7 +83,7 @@ export declare function hasFilePath(filePath: string): boolean;
|
|
|
83
83
|
* @param cwd - The current working directory
|
|
84
84
|
* @returns The resolved path
|
|
85
85
|
*/
|
|
86
|
-
export declare function resolvePath(path: string, cwd?:
|
|
86
|
+
export declare function resolvePath(path: string, cwd?: any): string;
|
|
87
87
|
/**
|
|
88
88
|
* Resolve the file path to an absolute path.
|
|
89
89
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{EMPTY_STRING as a}from"@stryke/types/base";import{getWorkspaceRoot as f}from"../workspace/get-workspace-root";import{isAbsolutePath as c}from"./is-file";import{joinPaths as u}from"./join-paths";import{normalizeString as p,normalizeWindowsPath as l}from"./normalize-path";export function findFileName(n,{requireExtension:e,withExtension:r}={}){const t=l(n)?.split(n?.includes("\\")?"\\":"/")?.pop()??"";return e===!0&&!t.includes(".")?a:r===!1&&t.includes(".")?t.split(".").slice(-1).join(".")||a:t}export function findFilePath(n){const e=l(n);return e.replace(findFileName(e,{requireExtension:!0}),"")}export function findFolderName(n){const e=findFilePath(n).split("/");let r="";for(let t=e.length-1;t>=0;t--){const i=e[t];if(i){r=i;break}}return r??a}export function findFileExtension(n){if(n==="..")return"";const e=/.(\.[^./]+|\.)$/.exec(l(n));return e&&e[1]||a}export function hasFileName(n){return!!findFileName(n)}export function hasFilePath(n){return!!findFilePath(n)}export function resolvePath(n,e=f()){const r=l(n).split("/");let t="",i=!1;for(let o=r.length-1;o>=-1&&!i;o--){const s=o>=0?r[o]:e;!s||s.length===0||(t=u(s,t),i=c(s))}return t=p(t,!i),i&&!c(t)?`/${t}`:t.length>0?t:"."}export function resolvePaths(...n){return resolvePath(u(...n.map(e=>l(e))))}export function relativePath(n,e){const r=resolvePath(n).replace(/^\/([A-Z]:)?$/i,"$1").split("/"),t=resolvePath(e).replace(/^\/([A-Z]:)?$/i,"$1").split("/");if(t[0][1]===":"&&r[0][1]===":"&&r[0]!==t[0])return t.join("/");const i=[...r];for(const o of i){if(t[0]!==o)break;r.shift(),t.shift()}return[...r.map(()=>".."),...t].join("/")}export function relativeToWorkspaceRoot(n){return relativePath(n,f())}export function parsePath(n){const e=/^[/\\]|^[a-z]:[/\\]/i.exec(n)?.[0]?.replace(/\\/g,"/")||"",r=l(n),t=r.replace(/\/$/,"").split("/").slice(0,-1);t.length===1&&/^[A-Z]:$/i.test(t[0])&&(t[0]+="/");const i=findFolderName(r),o=t.join("/")||(c(n)?"/":"."),s=findFileExtension(n);return{root:e,dir:o,base:i,ext:s,name:i.slice(0,i.length-s.length)}}export function renameFile(n,e){const r=parsePath(n);return u(r.dir,e.includes(".")?e:e+r.ext)}
|
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getWorkspaceRoot = exports.getProjectRoot = void 0;
|
|
7
7
|
var _configTools = require("@storm-software/config-tools");
|
|
8
|
-
var _packageManager = require("@stryke/types/
|
|
9
|
-
var _getParentPath = require("
|
|
10
|
-
var _isRootDir = require("
|
|
8
|
+
var _packageManager = require("@stryke/types/package-manager");
|
|
9
|
+
var _getParentPath = require("./get-parent-path.cjs");
|
|
10
|
+
var _isRootDir = require("./is-root-dir.cjs");
|
|
11
11
|
const getWorkspaceRoot = (r = process.cwd()) => {
|
|
12
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
13
|
const t = (0, _configTools.findWorkspaceRootSafe)(r);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{findWorkspaceRootSafe as c}from"@storm-software/config-tools";import{PackageManagerLockFiles as e}from"@stryke/types/package-manager";import{getParentPath as s}from"./get-parent-path";import{isSystemRoot as n}from"./is-root-dir";export const getWorkspaceRoot=(r=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=c(r);if(t)return t;let o=s([e.NPM,e.YARN,e.PNPM,e.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"],r);if(o)return o;for(o=r;o&&!n(o);)if(o=s("storm.json",o,{skipCwd:!0}),o)return o;return r},getProjectRoot=(r=process.cwd())=>{const t=s(["project.json","package.json",".storm"],r);return t||r};
|
package/dist/index.cjs
CHANGED
|
@@ -3,36 +3,124 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var
|
|
7
|
-
Object.keys(
|
|
6
|
+
var _assetExtensions = require("./asset-extensions.cjs");
|
|
7
|
+
Object.keys(_assetExtensions).forEach(function (key) {
|
|
8
8
|
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] ===
|
|
9
|
+
if (key in exports && exports[key] === _assetExtensions[key]) return;
|
|
10
10
|
Object.defineProperty(exports, key, {
|
|
11
11
|
enumerable: true,
|
|
12
12
|
get: function () {
|
|
13
|
-
return
|
|
13
|
+
return _assetExtensions[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _delimiter = require("./delimiter.cjs");
|
|
18
|
+
Object.keys(_delimiter).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _delimiter[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _delimiter[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _exists = require("./exists.cjs");
|
|
29
|
+
Object.keys(_exists).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _exists[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _exists[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _filePathFns = require("./file-path-fns.cjs");
|
|
40
|
+
Object.keys(_filePathFns).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _filePathFns[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _filePathFns[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var _getParentPath = require("./get-parent-path.cjs");
|
|
51
|
+
Object.keys(_getParentPath).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _getParentPath[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _getParentPath[key];
|
|
14
58
|
}
|
|
15
59
|
});
|
|
16
60
|
});
|
|
17
|
-
var
|
|
18
|
-
Object.keys(
|
|
61
|
+
var _getWorkspaceRoot = require("./get-workspace-root.cjs");
|
|
62
|
+
Object.keys(_getWorkspaceRoot).forEach(function (key) {
|
|
19
63
|
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] ===
|
|
64
|
+
if (key in exports && exports[key] === _getWorkspaceRoot[key]) return;
|
|
21
65
|
Object.defineProperty(exports, key, {
|
|
22
66
|
enumerable: true,
|
|
23
67
|
get: function () {
|
|
24
|
-
return
|
|
68
|
+
return _getWorkspaceRoot[key];
|
|
25
69
|
}
|
|
26
70
|
});
|
|
27
71
|
});
|
|
28
|
-
var
|
|
29
|
-
Object.keys(
|
|
72
|
+
var _isFile = require("./is-file.cjs");
|
|
73
|
+
Object.keys(_isFile).forEach(function (key) {
|
|
30
74
|
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] ===
|
|
75
|
+
if (key in exports && exports[key] === _isFile[key]) return;
|
|
32
76
|
Object.defineProperty(exports, key, {
|
|
33
77
|
enumerable: true,
|
|
34
78
|
get: function () {
|
|
35
|
-
return
|
|
79
|
+
return _isFile[key];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
var _isRootDir = require("./is-root-dir.cjs");
|
|
84
|
+
Object.keys(_isRootDir).forEach(function (key) {
|
|
85
|
+
if (key === "default" || key === "__esModule") return;
|
|
86
|
+
if (key in exports && exports[key] === _isRootDir[key]) return;
|
|
87
|
+
Object.defineProperty(exports, key, {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return _isRootDir[key];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
var _joinPaths = require("./join-paths.cjs");
|
|
95
|
+
Object.keys(_joinPaths).forEach(function (key) {
|
|
96
|
+
if (key === "default" || key === "__esModule") return;
|
|
97
|
+
if (key in exports && exports[key] === _joinPaths[key]) return;
|
|
98
|
+
Object.defineProperty(exports, key, {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () {
|
|
101
|
+
return _joinPaths[key];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
var _normalizePath = require("./normalize-path.cjs");
|
|
106
|
+
Object.keys(_normalizePath).forEach(function (key) {
|
|
107
|
+
if (key === "default" || key === "__esModule") return;
|
|
108
|
+
if (key in exports && exports[key] === _normalizePath[key]) return;
|
|
109
|
+
Object.defineProperty(exports, key, {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function () {
|
|
112
|
+
return _normalizePath[key];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
var _resolve = require("./resolve.cjs");
|
|
117
|
+
Object.keys(_resolve).forEach(function (key) {
|
|
118
|
+
if (key === "default" || key === "__esModule") return;
|
|
119
|
+
if (key in exports && exports[key] === _resolve[key]) return;
|
|
120
|
+
Object.defineProperty(exports, key, {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function () {
|
|
123
|
+
return _resolve[key];
|
|
36
124
|
}
|
|
37
125
|
});
|
|
38
126
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
|
+
export * from "./asset-extensions";
|
|
10
|
+
export * from "./delimiter";
|
|
11
|
+
export * from "./exists";
|
|
12
|
+
export * from "./file-path-fns";
|
|
13
|
+
export * from "./get-parent-path";
|
|
14
|
+
export * from "./get-workspace-root";
|
|
15
|
+
export * from "./is-file";
|
|
16
|
+
export * from "./is-root-dir";
|
|
17
|
+
export * from "./join-paths";
|
|
18
|
+
export * from "./normalize-path";
|
|
9
19
|
export * from "./resolve";
|
|
10
|
-
export * from "./utilities";
|
|
11
|
-
export * from "./workspace";
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./
|
|
1
|
+
export*from"./asset-extensions";export*from"./delimiter";export*from"./exists";export*from"./file-path-fns";export*from"./get-parent-path";export*from"./get-workspace-root";export*from"./is-file";export*from"./is-root-dir";export*from"./join-paths";export*from"./normalize-path";export*from"./resolve";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.joinPaths = void 0;
|
|
7
|
+
var _normalizePath = require("./normalize-path.cjs");
|
|
8
|
+
const joinPaths = (...i) => {
|
|
9
|
+
let t = "";
|
|
10
|
+
for (const o of i) if (o) if (t.length > 0) {
|
|
11
|
+
const e = t[t.length - 1] === "/",
|
|
12
|
+
n = o[0] === "/";
|
|
13
|
+
e && n ? t += o.slice(1) : t += e || n ? o : `/${o}`;
|
|
14
|
+
} else t += o;
|
|
15
|
+
return (0, _normalizePath.correctPaths)(t);
|
|
16
|
+
};
|
|
17
|
+
exports.joinPaths = joinPaths;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type path from "node:path";
|
|
2
|
+
/**
|
|
3
|
+
* Join multiple path segments together, resolving '.' and '..' segments, and normalizing the resulting path.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* This helper utility performs string joining similar to the `node:path` module's `join` function, and then normalizes the resulting path.
|
|
7
|
+
*
|
|
8
|
+
* @param segments - The path segments to join.
|
|
9
|
+
* @returns The joined path string.
|
|
10
|
+
*/
|
|
11
|
+
export declare const joinPaths: typeof path.join;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{correctPaths as s}from"./normalize-path";export const joinPaths=(...i)=>{let t="";for(const o of i)if(o)if(t.length>0){const e=t[t.length-1]==="/",n=o[0]==="/";e&&n?t+=o.slice(1):t+=e||n?o:`/${o}`}else t+=o;return s(t)};
|
|
@@ -3,23 +3,33 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.correctPaths = void 0;
|
|
7
7
|
exports.normalizeString = normalizeString;
|
|
8
8
|
exports.normalizeWindowsPath = normalizeWindowsPath;
|
|
9
|
-
exports.sep = void 0;
|
|
10
9
|
exports.slash = slash;
|
|
11
10
|
var _isFile = require("./is-file.cjs");
|
|
12
11
|
function slash(e) {
|
|
13
12
|
return e.replace(/\\/g, "/");
|
|
14
13
|
}
|
|
14
|
+
const c = /^[A-Z]:\//i;
|
|
15
15
|
function normalizeWindowsPath(e = "") {
|
|
16
|
-
return e && e.replace(/\\/g, "/").replace(
|
|
16
|
+
return e && e.replace(/\\/g, "/").replace(c, i => i.toUpperCase());
|
|
17
17
|
}
|
|
18
|
-
const
|
|
19
|
-
|
|
18
|
+
const u = /^[/\\]{2}/,
|
|
19
|
+
E = /^[A-Z]:$/i;
|
|
20
|
+
const correctPaths = e => {
|
|
21
|
+
if (!e || e.length === 0) return ".";
|
|
22
|
+
e = normalizeWindowsPath(e);
|
|
23
|
+
const i = e.match(u),
|
|
24
|
+
n = (0, _isFile.isAbsolutePath)(e),
|
|
25
|
+
t = e[e.length - 1] === "/";
|
|
26
|
+
return e = normalizeString(e, !n), e.length === 0 ? n ? "/" : t ? "./" : "." : (t && (e += "/"), E.test(e) && (e += "/"), i ? n ? `//${e}` : `//./${e}` : n && !(0, _isFile.isAbsolutePath)(e) ? `/${e}` : e);
|
|
27
|
+
};
|
|
28
|
+
exports.correctPaths = correctPaths;
|
|
29
|
+
function normalizeString(e, i) {
|
|
20
30
|
let n = "",
|
|
21
31
|
t = 0,
|
|
22
|
-
|
|
32
|
+
s = -1,
|
|
23
33
|
r = 0,
|
|
24
34
|
o = null;
|
|
25
35
|
for (let l = 0; l <= e.length; ++l) {
|
|
@@ -28,29 +38,21 @@ function normalizeString(e, s) {
|
|
|
28
38
|
o = "/";
|
|
29
39
|
}
|
|
30
40
|
if (o === "/") {
|
|
31
|
-
if (!(
|
|
32
|
-
if (n.length < 2 || t !== 2 || n.
|
|
41
|
+
if (!(s === l - 1 || r === 1)) if (r === 2) {
|
|
42
|
+
if (n.length < 2 || t !== 2 || n[n.length - 1] !== "." || n[n.length - 2] !== ".") {
|
|
33
43
|
if (n.length > 2) {
|
|
34
44
|
const f = n.lastIndexOf("/");
|
|
35
|
-
f === -1 ? (n = "", t = 0) : (n = n.slice(0, f), t = n.length - 1 - n.lastIndexOf("/")),
|
|
45
|
+
f === -1 ? (n = "", t = 0) : (n = n.slice(0, f), t = n.length - 1 - n.lastIndexOf("/")), s = l, r = 0;
|
|
36
46
|
continue;
|
|
37
47
|
} else if (n.length > 0) {
|
|
38
|
-
n = "", t = 0,
|
|
48
|
+
n = "", t = 0, s = l, r = 0;
|
|
39
49
|
continue;
|
|
40
50
|
}
|
|
41
51
|
}
|
|
42
|
-
|
|
43
|
-
} else n.length > 0 ? n += `/${e.slice(
|
|
44
|
-
|
|
52
|
+
i && (n += n.length > 0 ? "/.." : "..", t = 2);
|
|
53
|
+
} else n.length > 0 ? n += `/${e.slice(s + 1, l)}` : n = e.slice(s + 1, l), t = l - s - 1;
|
|
54
|
+
s = l, r = 0;
|
|
45
55
|
} else o === "." && r !== -1 ? ++r : r = -1;
|
|
46
56
|
}
|
|
47
57
|
return n;
|
|
48
|
-
}
|
|
49
|
-
function normalizePath(e) {
|
|
50
|
-
if (!e || e.length === 0) return ".";
|
|
51
|
-
e = normalizeWindowsPath(e);
|
|
52
|
-
const s = e.match(/^[/\\]{2}/),
|
|
53
|
-
n = (0, _isFile.isAbsolutePath)(e),
|
|
54
|
-
t = e.at(-1) === "/";
|
|
55
|
-
return e = normalizeString(e, !n), e.length === 0 ? n ? "/" : t ? "./" : "." : (t && (e += "/"), /^[A-Z]:$/i.test(e) && (e += "/"), s ? n ? `//${e}` : `//./${e}` : n && !(0, _isFile.isAbsolutePath)(e) ? `/${e}` : e);
|
|
56
58
|
}
|
|
@@ -6,27 +6,12 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export declare function slash(str: string): string;
|
|
8
8
|
export declare function normalizeWindowsPath(input?: string): string;
|
|
9
|
-
|
|
10
|
-
* Constant for path separator.
|
|
11
|
-
*
|
|
12
|
-
* Always equals to `"/"`.
|
|
13
|
-
*/
|
|
14
|
-
export declare const sep = "/";
|
|
9
|
+
export declare const correctPaths: (path?: string) => string;
|
|
15
10
|
/**
|
|
16
11
|
* Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
|
|
17
12
|
*
|
|
18
13
|
* @param path - The path to normalize.
|
|
19
14
|
* @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
|
|
20
|
-
* @returns the
|
|
15
|
+
* @returns the normalize path string.
|
|
21
16
|
*/
|
|
22
17
|
export declare function normalizeString(path: string, allowAboveRoot: boolean): string;
|
|
23
|
-
/**
|
|
24
|
-
* Normalizes the given path.
|
|
25
|
-
*
|
|
26
|
-
* @remarks
|
|
27
|
-
* Removes duplicate slashes, removes trailing slashes, adds a leading slash.
|
|
28
|
-
*
|
|
29
|
-
* @param path - The path to normalize
|
|
30
|
-
* @returns The normalized path
|
|
31
|
-
*/
|
|
32
|
-
export declare function normalizePath(path?: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isAbsolutePath as g}from"./is-file";export function slash(e){return e.replace(/\\/g,"/")}const c=/^[A-Z]:\//i;export function normalizeWindowsPath(e=""){return e&&e.replace(/\\/g,"/").replace(c,i=>i.toUpperCase())}const u=/^[/\\]{2}/,E=/^[A-Z]:$/i;export const correctPaths=e=>{if(!e||e.length===0)return".";e=normalizeWindowsPath(e);const i=e.match(u),n=g(e),t=e[e.length-1]==="/";return e=normalizeString(e,!n),e.length===0?n?"/":t?"./":".":(t&&(e+="/"),E.test(e)&&(e+="/"),i?n?`//${e}`:`//./${e}`:n&&!g(e)?`/${e}`:e)};export function normalizeString(e,i){let n="",t=0,s=-1,r=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(!(s===l-1||r===1))if(r===2){if(n.length<2||t!==2||n[n.length-1]!=="."||n[n.length-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("/")),s=l,r=0;continue}else if(n.length>0){n="",t=0,s=l,r=0;continue}}i&&(n+=n.length>0?"/..":"..",t=2)}else n.length>0?n+=`/${e.slice(s+1,l)}`:n=e.slice(s+1,l),t=l-s-1;s=l,r=0}else o==="."&&r!==-1?++r:r=-1}return n}
|
|
@@ -12,8 +12,8 @@ exports.resolveSafeSync = resolveSafeSync;
|
|
|
12
12
|
exports.resolveSync = resolveSync;
|
|
13
13
|
var _mlly = require("mlly");
|
|
14
14
|
var _nodeProcess = _interopRequireDefault(require("node:process"));
|
|
15
|
-
var _utilities = require("../utilities
|
|
16
|
-
var _getWorkspaceRoot = require("../workspace/get-workspace-root
|
|
15
|
+
var _utilities = require("../utilities");
|
|
16
|
+
var _getWorkspaceRoot = require("../workspace/get-workspace-root");
|
|
17
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
18
|
async function resolve(r, e = {}) {
|
|
19
19
|
const t = e.paths ?? [];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Platform } from "@stryke/types/
|
|
1
|
+
import type { Platform } from "@stryke/types/system";
|
|
2
2
|
export interface PackageResolvingOptions {
|
|
3
3
|
/**
|
|
4
4
|
* Paths to resolve the package from
|
|
@@ -16,7 +16,7 @@ export interface PackageResolvingOptions {
|
|
|
16
16
|
* @param options - The options to use when resolving the module
|
|
17
17
|
* @returns A promise for the path to the module
|
|
18
18
|
*/
|
|
19
|
-
export declare function resolve(path: string, options?: PackageResolvingOptions): Promise<
|
|
19
|
+
export declare function resolve(path: string, options?: PackageResolvingOptions): Promise<any>;
|
|
20
20
|
/**
|
|
21
21
|
* Resolve the path to a specified module
|
|
22
22
|
*
|
|
@@ -24,7 +24,7 @@ export declare function resolve(path: string, options?: PackageResolvingOptions)
|
|
|
24
24
|
* @param options - The options to use when resolving the module
|
|
25
25
|
* @returns The path to the module or undefined
|
|
26
26
|
*/
|
|
27
|
-
export declare function resolveSync(path: string, options?: PackageResolvingOptions):
|
|
27
|
+
export declare function resolveSync(path: string, options?: PackageResolvingOptions): any;
|
|
28
28
|
/**
|
|
29
29
|
* Resolve the path to a specified module with error handling
|
|
30
30
|
*
|
|
@@ -32,7 +32,7 @@ export declare function resolveSync(path: string, options?: PackageResolvingOpti
|
|
|
32
32
|
* @param options - The options to use when resolving the module
|
|
33
33
|
* @returns A promise for the path to the module
|
|
34
34
|
*/
|
|
35
|
-
export declare function resolveSafe(name: string, options?: PackageResolvingOptions): Promise<
|
|
35
|
+
export declare function resolveSafe(name: string, options?: PackageResolvingOptions): Promise<any> | undefined;
|
|
36
36
|
/**
|
|
37
37
|
* Resolve the path to a specified module with error handling
|
|
38
38
|
*
|
|
@@ -40,7 +40,7 @@ export declare function resolveSafe(name: string, options?: PackageResolvingOpti
|
|
|
40
40
|
* @param options - The options to use when resolving the module
|
|
41
41
|
* @returns The path to the module or undefined
|
|
42
42
|
*/
|
|
43
|
-
export declare function resolveSafeSync(name: string, options?: PackageResolvingOptions):
|
|
43
|
+
export declare function resolveSafeSync(name: string, options?: PackageResolvingOptions): any;
|
|
44
44
|
/**
|
|
45
45
|
* Import a module from a specified path
|
|
46
46
|
*
|
|
@@ -54,11 +54,11 @@ export declare function importModule<T = any>(path: string): Promise<T>;
|
|
|
54
54
|
* @param path - The path to the module
|
|
55
55
|
* @returns The module or undefined
|
|
56
56
|
*/
|
|
57
|
-
export declare function resolvePackage(name: string, options?: PackageResolvingOptions): Promise<
|
|
57
|
+
export declare function resolvePackage(name: string, options?: PackageResolvingOptions): Promise<any>;
|
|
58
58
|
/**
|
|
59
59
|
* Import a module from a specified path with error handling
|
|
60
60
|
*
|
|
61
61
|
* @param path - The path to the module
|
|
62
62
|
* @returns The module or undefined
|
|
63
63
|
*/
|
|
64
|
-
export declare function resolvePackageSync(name: string, options?: PackageResolvingOptions): Promise<
|
|
64
|
+
export declare function resolvePackageSync(name: string, options?: PackageResolvingOptions): Promise<any>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/path",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing various utilities that expand the functionality of NodeJs's `path` module",
|
|
6
6
|
"repository": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@storm-software/config-tools": "latest",
|
|
14
14
|
"mlly": "1.7.4",
|
|
15
|
-
"@stryke/types": ">=0.
|
|
15
|
+
"@stryke/types": ">=0.6.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": { "@types/node": "^22.13.1" },
|
|
18
18
|
"publishConfig": { "access": "public" },
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"stryke",
|
|
29
29
|
"typescript",
|
|
30
30
|
"utilities",
|
|
31
|
-
"storm-stack",
|
|
32
31
|
"storm-software",
|
|
33
32
|
"storm",
|
|
34
33
|
"storm-ops",
|
|
@@ -60,208 +59,166 @@
|
|
|
60
59
|
}
|
|
61
60
|
],
|
|
62
61
|
"exports": {
|
|
63
|
-
"./
|
|
64
|
-
"import": { "types": "./dist/index.d.ts", "default": "./dist/index.mjs" },
|
|
65
|
-
"require": {
|
|
66
|
-
"types": "./dist/index.d.ts",
|
|
67
|
-
"default": "./dist/index.cjs"
|
|
68
|
-
},
|
|
69
|
-
"default": { "types": "./dist/index.d.ts", "default": "./dist/index.mjs" }
|
|
70
|
-
},
|
|
71
|
-
"./workspace/index": {
|
|
72
|
-
"import": {
|
|
73
|
-
"types": "./dist/workspace/index.d.ts",
|
|
74
|
-
"default": "./dist/workspace/index.mjs"
|
|
75
|
-
},
|
|
76
|
-
"require": {
|
|
77
|
-
"types": "./dist/workspace/index.d.ts",
|
|
78
|
-
"default": "./dist/workspace/index.cjs"
|
|
79
|
-
},
|
|
80
|
-
"default": {
|
|
81
|
-
"types": "./dist/workspace/index.d.ts",
|
|
82
|
-
"default": "./dist/workspace/index.mjs"
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
"./workspace/get-workspace-root": {
|
|
86
|
-
"import": {
|
|
87
|
-
"types": "./dist/workspace/get-workspace-root.d.ts",
|
|
88
|
-
"default": "./dist/workspace/get-workspace-root.mjs"
|
|
89
|
-
},
|
|
90
|
-
"require": {
|
|
91
|
-
"types": "./dist/workspace/get-workspace-root.d.ts",
|
|
92
|
-
"default": "./dist/workspace/get-workspace-root.cjs"
|
|
93
|
-
},
|
|
94
|
-
"default": {
|
|
95
|
-
"types": "./dist/workspace/get-workspace-root.d.ts",
|
|
96
|
-
"default": "./dist/workspace/get-workspace-root.mjs"
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
"./workspace/asset-extensions": {
|
|
62
|
+
"./resolve": {
|
|
100
63
|
"import": {
|
|
101
|
-
"types": "./dist/
|
|
102
|
-
"default": "./dist/
|
|
64
|
+
"types": "./dist/resolve.d.ts",
|
|
65
|
+
"default": "./dist/resolve.mjs"
|
|
103
66
|
},
|
|
104
67
|
"require": {
|
|
105
|
-
"types": "./dist/
|
|
106
|
-
"default": "./dist/
|
|
68
|
+
"types": "./dist/resolve.d.ts",
|
|
69
|
+
"default": "./dist/resolve.cjs"
|
|
107
70
|
},
|
|
108
71
|
"default": {
|
|
109
|
-
"types": "./dist/
|
|
110
|
-
"default": "./dist/
|
|
72
|
+
"types": "./dist/resolve.d.ts",
|
|
73
|
+
"default": "./dist/resolve.mjs"
|
|
111
74
|
}
|
|
112
75
|
},
|
|
113
|
-
"./
|
|
76
|
+
"./normalize-path": {
|
|
114
77
|
"import": {
|
|
115
|
-
"types": "./dist/
|
|
116
|
-
"default": "./dist/
|
|
78
|
+
"types": "./dist/normalize-path.d.ts",
|
|
79
|
+
"default": "./dist/normalize-path.mjs"
|
|
117
80
|
},
|
|
118
81
|
"require": {
|
|
119
|
-
"types": "./dist/
|
|
120
|
-
"default": "./dist/
|
|
82
|
+
"types": "./dist/normalize-path.d.ts",
|
|
83
|
+
"default": "./dist/normalize-path.cjs"
|
|
121
84
|
},
|
|
122
85
|
"default": {
|
|
123
|
-
"types": "./dist/
|
|
124
|
-
"default": "./dist/
|
|
86
|
+
"types": "./dist/normalize-path.d.ts",
|
|
87
|
+
"default": "./dist/normalize-path.mjs"
|
|
125
88
|
}
|
|
126
89
|
},
|
|
127
|
-
"./
|
|
90
|
+
"./join-paths": {
|
|
128
91
|
"import": {
|
|
129
|
-
"types": "./dist/
|
|
130
|
-
"default": "./dist/
|
|
92
|
+
"types": "./dist/join-paths.d.ts",
|
|
93
|
+
"default": "./dist/join-paths.mjs"
|
|
131
94
|
},
|
|
132
95
|
"require": {
|
|
133
|
-
"types": "./dist/
|
|
134
|
-
"default": "./dist/
|
|
96
|
+
"types": "./dist/join-paths.d.ts",
|
|
97
|
+
"default": "./dist/join-paths.cjs"
|
|
135
98
|
},
|
|
136
99
|
"default": {
|
|
137
|
-
"types": "./dist/
|
|
138
|
-
"default": "./dist/
|
|
100
|
+
"types": "./dist/join-paths.d.ts",
|
|
101
|
+
"default": "./dist/join-paths.mjs"
|
|
139
102
|
}
|
|
140
103
|
},
|
|
141
|
-
"./
|
|
104
|
+
"./is-root-dir": {
|
|
142
105
|
"import": {
|
|
143
|
-
"types": "./dist/
|
|
144
|
-
"default": "./dist/
|
|
106
|
+
"types": "./dist/is-root-dir.d.ts",
|
|
107
|
+
"default": "./dist/is-root-dir.mjs"
|
|
145
108
|
},
|
|
146
109
|
"require": {
|
|
147
|
-
"types": "./dist/
|
|
148
|
-
"default": "./dist/
|
|
110
|
+
"types": "./dist/is-root-dir.d.ts",
|
|
111
|
+
"default": "./dist/is-root-dir.cjs"
|
|
149
112
|
},
|
|
150
113
|
"default": {
|
|
151
|
-
"types": "./dist/
|
|
152
|
-
"default": "./dist/
|
|
114
|
+
"types": "./dist/is-root-dir.d.ts",
|
|
115
|
+
"default": "./dist/is-root-dir.mjs"
|
|
153
116
|
}
|
|
154
117
|
},
|
|
155
|
-
"./
|
|
118
|
+
"./is-file": {
|
|
156
119
|
"import": {
|
|
157
|
-
"types": "./dist/
|
|
158
|
-
"default": "./dist/
|
|
120
|
+
"types": "./dist/is-file.d.ts",
|
|
121
|
+
"default": "./dist/is-file.mjs"
|
|
159
122
|
},
|
|
160
123
|
"require": {
|
|
161
|
-
"types": "./dist/
|
|
162
|
-
"default": "./dist/
|
|
124
|
+
"types": "./dist/is-file.d.ts",
|
|
125
|
+
"default": "./dist/is-file.cjs"
|
|
163
126
|
},
|
|
164
127
|
"default": {
|
|
165
|
-
"types": "./dist/
|
|
166
|
-
"default": "./dist/
|
|
128
|
+
"types": "./dist/is-file.d.ts",
|
|
129
|
+
"default": "./dist/is-file.mjs"
|
|
167
130
|
}
|
|
168
131
|
},
|
|
169
|
-
"./
|
|
170
|
-
"import": {
|
|
171
|
-
"types": "./dist/utilities/index.d.ts",
|
|
172
|
-
"default": "./dist/utilities/index.mjs"
|
|
173
|
-
},
|
|
132
|
+
"./index": {
|
|
133
|
+
"import": { "types": "./dist/index.d.ts", "default": "./dist/index.mjs" },
|
|
174
134
|
"require": {
|
|
175
|
-
"types": "./dist/
|
|
176
|
-
"default": "./dist/
|
|
135
|
+
"types": "./dist/index.d.ts",
|
|
136
|
+
"default": "./dist/index.cjs"
|
|
177
137
|
},
|
|
178
|
-
"default": {
|
|
179
|
-
"types": "./dist/utilities/index.d.ts",
|
|
180
|
-
"default": "./dist/utilities/index.mjs"
|
|
181
|
-
}
|
|
138
|
+
"default": { "types": "./dist/index.d.ts", "default": "./dist/index.mjs" }
|
|
182
139
|
},
|
|
183
|
-
"./
|
|
140
|
+
"./get-workspace-root": {
|
|
184
141
|
"import": {
|
|
185
|
-
"types": "./dist/
|
|
186
|
-
"default": "./dist/
|
|
142
|
+
"types": "./dist/get-workspace-root.d.ts",
|
|
143
|
+
"default": "./dist/get-workspace-root.mjs"
|
|
187
144
|
},
|
|
188
145
|
"require": {
|
|
189
|
-
"types": "./dist/
|
|
190
|
-
"default": "./dist/
|
|
146
|
+
"types": "./dist/get-workspace-root.d.ts",
|
|
147
|
+
"default": "./dist/get-workspace-root.cjs"
|
|
191
148
|
},
|
|
192
149
|
"default": {
|
|
193
|
-
"types": "./dist/
|
|
194
|
-
"default": "./dist/
|
|
150
|
+
"types": "./dist/get-workspace-root.d.ts",
|
|
151
|
+
"default": "./dist/get-workspace-root.mjs"
|
|
195
152
|
}
|
|
196
153
|
},
|
|
197
|
-
"./
|
|
154
|
+
"./get-parent-path": {
|
|
198
155
|
"import": {
|
|
199
|
-
"types": "./dist/
|
|
200
|
-
"default": "./dist/
|
|
156
|
+
"types": "./dist/get-parent-path.d.ts",
|
|
157
|
+
"default": "./dist/get-parent-path.mjs"
|
|
201
158
|
},
|
|
202
159
|
"require": {
|
|
203
|
-
"types": "./dist/
|
|
204
|
-
"default": "./dist/
|
|
160
|
+
"types": "./dist/get-parent-path.d.ts",
|
|
161
|
+
"default": "./dist/get-parent-path.cjs"
|
|
205
162
|
},
|
|
206
163
|
"default": {
|
|
207
|
-
"types": "./dist/
|
|
208
|
-
"default": "./dist/
|
|
164
|
+
"types": "./dist/get-parent-path.d.ts",
|
|
165
|
+
"default": "./dist/get-parent-path.mjs"
|
|
209
166
|
}
|
|
210
167
|
},
|
|
211
|
-
"./
|
|
168
|
+
"./file-path-fns": {
|
|
212
169
|
"import": {
|
|
213
|
-
"types": "./dist/
|
|
214
|
-
"default": "./dist/
|
|
170
|
+
"types": "./dist/file-path-fns.d.ts",
|
|
171
|
+
"default": "./dist/file-path-fns.mjs"
|
|
215
172
|
},
|
|
216
173
|
"require": {
|
|
217
|
-
"types": "./dist/
|
|
218
|
-
"default": "./dist/
|
|
174
|
+
"types": "./dist/file-path-fns.d.ts",
|
|
175
|
+
"default": "./dist/file-path-fns.cjs"
|
|
219
176
|
},
|
|
220
177
|
"default": {
|
|
221
|
-
"types": "./dist/
|
|
222
|
-
"default": "./dist/
|
|
178
|
+
"types": "./dist/file-path-fns.d.ts",
|
|
179
|
+
"default": "./dist/file-path-fns.mjs"
|
|
223
180
|
}
|
|
224
181
|
},
|
|
225
|
-
"./
|
|
182
|
+
"./exists": {
|
|
226
183
|
"import": {
|
|
227
|
-
"types": "./dist/
|
|
228
|
-
"default": "./dist/
|
|
184
|
+
"types": "./dist/exists.d.ts",
|
|
185
|
+
"default": "./dist/exists.mjs"
|
|
229
186
|
},
|
|
230
187
|
"require": {
|
|
231
|
-
"types": "./dist/
|
|
232
|
-
"default": "./dist/
|
|
188
|
+
"types": "./dist/exists.d.ts",
|
|
189
|
+
"default": "./dist/exists.cjs"
|
|
233
190
|
},
|
|
234
191
|
"default": {
|
|
235
|
-
"types": "./dist/
|
|
236
|
-
"default": "./dist/
|
|
192
|
+
"types": "./dist/exists.d.ts",
|
|
193
|
+
"default": "./dist/exists.mjs"
|
|
237
194
|
}
|
|
238
195
|
},
|
|
239
|
-
"./
|
|
196
|
+
"./delimiter": {
|
|
240
197
|
"import": {
|
|
241
|
-
"types": "./dist/
|
|
242
|
-
"default": "./dist/
|
|
198
|
+
"types": "./dist/delimiter.d.ts",
|
|
199
|
+
"default": "./dist/delimiter.mjs"
|
|
243
200
|
},
|
|
244
201
|
"require": {
|
|
245
|
-
"types": "./dist/
|
|
246
|
-
"default": "./dist/
|
|
202
|
+
"types": "./dist/delimiter.d.ts",
|
|
203
|
+
"default": "./dist/delimiter.cjs"
|
|
247
204
|
},
|
|
248
205
|
"default": {
|
|
249
|
-
"types": "./dist/
|
|
250
|
-
"default": "./dist/
|
|
206
|
+
"types": "./dist/delimiter.d.ts",
|
|
207
|
+
"default": "./dist/delimiter.mjs"
|
|
251
208
|
}
|
|
252
209
|
},
|
|
253
|
-
"./
|
|
210
|
+
"./asset-extensions": {
|
|
254
211
|
"import": {
|
|
255
|
-
"types": "./dist/
|
|
256
|
-
"default": "./dist/
|
|
212
|
+
"types": "./dist/asset-extensions.d.ts",
|
|
213
|
+
"default": "./dist/asset-extensions.mjs"
|
|
257
214
|
},
|
|
258
215
|
"require": {
|
|
259
|
-
"types": "./dist/
|
|
260
|
-
"default": "./dist/
|
|
216
|
+
"types": "./dist/asset-extensions.d.ts",
|
|
217
|
+
"default": "./dist/asset-extensions.cjs"
|
|
261
218
|
},
|
|
262
219
|
"default": {
|
|
263
|
-
"types": "./dist/
|
|
264
|
-
"default": "./dist/
|
|
220
|
+
"types": "./dist/asset-extensions.d.ts",
|
|
221
|
+
"default": "./dist/asset-extensions.mjs"
|
|
265
222
|
}
|
|
266
223
|
},
|
|
267
224
|
".": {
|
|
@@ -272,48 +229,6 @@
|
|
|
272
229
|
},
|
|
273
230
|
"default": { "types": "./dist/index.d.ts", "default": "./dist/index.mjs" }
|
|
274
231
|
},
|
|
275
|
-
"./workspace": {
|
|
276
|
-
"import": {
|
|
277
|
-
"types": "./dist/workspace/index.d.ts",
|
|
278
|
-
"default": "./dist/workspace/index.mjs"
|
|
279
|
-
},
|
|
280
|
-
"require": {
|
|
281
|
-
"types": "./dist/workspace/index.d.ts",
|
|
282
|
-
"default": "./dist/workspace/index.cjs"
|
|
283
|
-
},
|
|
284
|
-
"default": {
|
|
285
|
-
"types": "./dist/workspace/index.d.ts",
|
|
286
|
-
"default": "./dist/workspace/index.mjs"
|
|
287
|
-
}
|
|
288
|
-
},
|
|
289
|
-
"./utilities": {
|
|
290
|
-
"import": {
|
|
291
|
-
"types": "./dist/utilities/index.d.ts",
|
|
292
|
-
"default": "./dist/utilities/index.mjs"
|
|
293
|
-
},
|
|
294
|
-
"require": {
|
|
295
|
-
"types": "./dist/utilities/index.d.ts",
|
|
296
|
-
"default": "./dist/utilities/index.cjs"
|
|
297
|
-
},
|
|
298
|
-
"default": {
|
|
299
|
-
"types": "./dist/utilities/index.d.ts",
|
|
300
|
-
"default": "./dist/utilities/index.mjs"
|
|
301
|
-
}
|
|
302
|
-
},
|
|
303
|
-
"./resolve": {
|
|
304
|
-
"import": {
|
|
305
|
-
"types": "./dist/resolve/index.d.ts",
|
|
306
|
-
"default": "./dist/resolve/index.mjs"
|
|
307
|
-
},
|
|
308
|
-
"require": {
|
|
309
|
-
"types": "./dist/resolve/index.d.ts",
|
|
310
|
-
"default": "./dist/resolve/index.cjs"
|
|
311
|
-
},
|
|
312
|
-
"default": {
|
|
313
|
-
"types": "./dist/resolve/index.d.ts",
|
|
314
|
-
"default": "./dist/resolve/index.mjs"
|
|
315
|
-
}
|
|
316
|
-
},
|
|
317
232
|
"./package.json": "./package.json"
|
|
318
233
|
},
|
|
319
234
|
"main": "./dist/index.cjs",
|
package/dist/resolve/index.cjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _resolve = require("./resolve.cjs");
|
|
7
|
-
Object.keys(_resolve).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _resolve[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _resolve[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
package/dist/resolve/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./resolve";
|
package/dist/resolve/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export*from"./resolve";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{EMPTY_STRING as a}from"@stryke/types/utility-types/base";import{getWorkspaceRoot as f}from"../workspace/get-workspace-root";import{isAbsolutePath as c}from"./is-file";import{joinPaths as u}from"./join-paths";import{normalizeString as p,normalizeWindowsPath as l}from"./normalize-path";export function findFileName(n,{requireExtension:e,withExtension:r}={}){const t=l(n)?.split(n?.includes("\\")?"\\":"/")?.pop()??"";return e===!0&&!t.includes(".")?a:r===!1&&t.includes(".")?t.split(".").slice(-1).join(".")||a:t}export function findFilePath(n){const e=l(n);return e.replace(findFileName(e,{requireExtension:!0}),"")}export function findFolderName(n){const e=findFilePath(n).split("/");let r="";for(let t=e.length-1;t>=0;t--){const i=e[t];if(i){r=i;break}}return r??a}export function findFileExtension(n){if(n==="..")return"";const e=/.(\.[^./]+|\.)$/.exec(l(n));return e&&e[1]||a}export function hasFileName(n){return!!findFileName(n)}export function hasFilePath(n){return!!findFilePath(n)}export function resolvePath(n,e=f()){const r=l(n).split("/");let t="",i=!1;for(let o=r.length-1;o>=-1&&!i;o--){const s=o>=0?r[o]:e;!s||s.length===0||(t=u(s,t),i=c(s))}return t=p(t,!i),i&&!c(t)?`/${t}`:t.length>0?t:"."}export function resolvePaths(...n){return resolvePath(u(...n.map(e=>l(e))))}export function relativePath(n,e){const r=resolvePath(n).replace(/^\/([A-Z]:)?$/i,"$1").split("/"),t=resolvePath(e).replace(/^\/([A-Z]:)?$/i,"$1").split("/");if(t[0][1]===":"&&r[0][1]===":"&&r[0]!==t[0])return t.join("/");const i=[...r];for(const o of i){if(t[0]!==o)break;r.shift(),t.shift()}return[...r.map(()=>".."),...t].join("/")}export function relativeToWorkspaceRoot(n){return relativePath(n,f())}export function parsePath(n){const e=/^[/\\]|^[a-z]:[/\\]/i.exec(n)?.[0]?.replace(/\\/g,"/")||"",r=l(n),t=r.replace(/\/$/,"").split("/").slice(0,-1);t.length===1&&/^[A-Z]:$/i.test(t[0])&&(t[0]+="/");const i=findFolderName(r),o=t.join("/")||(c(n)?"/":"."),s=findFileExtension(n);return{root:e,dir:o,base:i,ext:s,name:i.slice(0,i.length-s.length)}}export function renameFile(n,e){const r=parsePath(n);return u(r.dir,e.includes(".")?e:e+r.ext)}
|
package/dist/utilities/index.cjs
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
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
|
-
});
|
package/dist/utilities/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
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";
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
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)}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{isAbsolutePath as g}from"./is-file";export function slash(e){return e.replace(/\\/g,"/")}export function normalizeWindowsPath(e=""){return e&&e.replace(/\\/g,"/").replace(/^[A-Z]:\//i,s=>s.toUpperCase())}export const sep="/";export function normalizeString(e,s){let n="",t=0,i=-1,r=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(!(i===l-1||r===1))if(r===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("/")),i=l,r=0;continue}else if(n.length>0){n="",t=0,i=l,r=0;continue}}s&&(n+=n.length>0?"/..":"..",t=2)}else n.length>0?n+=`/${e.slice(i+1,l)}`:n=e.slice(i+1,l),t=l-i-1;i=l,r=0}else o==="."&&r!==-1?++r:r=-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-Z]:$/i.test(e)&&(e+="/"),s?n?`//${e}`:`//./${e}`:n&&!g(e)?`/${e}`:e)}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{findWorkspaceRootSafe as c}from"@storm-software/config-tools";import{PackageManagerLockFiles as e}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=(r=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=c(r);if(t)return t;let o=s([e.NPM,e.YARN,e.PNPM,e.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"],r);if(o)return o;for(o=r;o&&!n(o);)if(o=s("storm.json",o,{skipCwd:!0}),o)return o;return r},getProjectRoot=(r=process.cwd())=>{const t=s(["project.json","package.json",".storm"],r);return t||r};
|
package/dist/workspace/index.cjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
});
|
package/dist/workspace/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export*from"./asset-extensions";export*from"./get-workspace-root";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|