@storm-software/eslint 0.170.156 → 0.170.158
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/README.md +1 -1
- package/dist/index.d.mts +43 -0
- package/dist/index.mjs +44 -0
- package/dist/plugins.d.mts +15 -0
- package/dist/plugins.mjs +16 -0
- package/dist/preset.d.mts +32 -0
- package/dist/preset.mjs +213 -0
- package/dist/{types.d.cts → typegen.d.mts} +8538 -11156
- package/dist/types.d.mts +735 -0
- package/dist/types.mjs +5 -0
- package/dist/utils/correct-paths.mjs +136 -0
- package/dist/utils/find-workspace-root.mjs +83 -0
- package/dist/utils/helpers.mjs +75 -0
- package/dist/utils/package-manager.mjs +20 -0
- package/dist/utils/tsconfig.mjs +48 -0
- package/package.json +58 -79
- package/dist/index.cjs +0 -24
- package/dist/index.d.cts +0 -127
- package/dist/index.d.ts +0 -127
- package/dist/index.js +0 -7
- package/dist/preset.cjs +0 -354
- package/dist/preset.d.cts +0 -34
- package/dist/preset.d.ts +0 -34
- package/dist/preset.js +0 -344
- package/dist/types.cjs +0 -12
- package/dist/types.d.ts +0 -19537
- package/dist/types.js +0 -1
- package/dist/utils/combine.cjs +0 -8
- package/dist/utils/combine.d.cts +0 -14
- package/dist/utils/combine.d.ts +0 -14
- package/dist/utils/combine.js +0 -6
- package/dist/utils/correct-paths.cjs +0 -231
- package/dist/utils/correct-paths.d.cts +0 -30
- package/dist/utils/correct-paths.d.ts +0 -30
- package/dist/utils/correct-paths.js +0 -216
- package/dist/utils/find-workspace-root.cjs +0 -96
- package/dist/utils/find-workspace-root.d.cts +0 -16
- package/dist/utils/find-workspace-root.d.ts +0 -16
- package/dist/utils/find-workspace-root.js +0 -93
- package/dist/utils/format-config.cjs +0 -19
- package/dist/utils/format-config.d.cts +0 -5
- package/dist/utils/format-config.d.ts +0 -5
- package/dist/utils/format-config.js +0 -17
- package/dist/utils/helpers.cjs +0 -86
- package/dist/utils/helpers.d.cts +0 -55
- package/dist/utils/helpers.d.ts +0 -55
- package/dist/utils/helpers.js +0 -72
- package/dist/utils/package-manager.cjs +0 -18
- package/dist/utils/package-manager.d.cts +0 -8
- package/dist/utils/package-manager.d.ts +0 -8
- package/dist/utils/package-manager.js +0 -16
- package/dist/utils/tsconfig.cjs +0 -43
- package/dist/utils/tsconfig.d.cts +0 -25
- package/dist/utils/tsconfig.d.ts +0 -25
- package/dist/utils/tsconfig.js +0 -40
package/dist/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './typegen.d';
|
package/dist/utils/combine.cjs
DELETED
package/dist/utils/combine.d.cts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Awaitable } from 'eslint-flat-config-utils';
|
|
2
|
-
import { TypedFlatConfigItem } from '../types.cjs';
|
|
3
|
-
import '@storm-software/eslint-plugin-banner/rules/banner';
|
|
4
|
-
import '@stylistic/eslint-plugin';
|
|
5
|
-
import '@typescript-eslint/parser';
|
|
6
|
-
import 'eslint';
|
|
7
|
-
import 'eslint-config-flat-gitignore';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Combine array and non-array configs into a single array.
|
|
11
|
-
*/
|
|
12
|
-
declare function combine(...configs: Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[]>[]): Promise<TypedFlatConfigItem[]>;
|
|
13
|
-
|
|
14
|
-
export { combine };
|
package/dist/utils/combine.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Awaitable } from 'eslint-flat-config-utils';
|
|
2
|
-
import { TypedFlatConfigItem } from '../types.js';
|
|
3
|
-
import '@storm-software/eslint-plugin-banner/rules/banner';
|
|
4
|
-
import '@stylistic/eslint-plugin';
|
|
5
|
-
import '@typescript-eslint/parser';
|
|
6
|
-
import 'eslint';
|
|
7
|
-
import 'eslint-config-flat-gitignore';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Combine array and non-array configs into a single array.
|
|
11
|
-
*/
|
|
12
|
-
declare function combine(...configs: Awaitable<TypedFlatConfigItem | TypedFlatConfigItem[]>[]): Promise<TypedFlatConfigItem[]>;
|
|
13
|
-
|
|
14
|
-
export { combine };
|
package/dist/utils/combine.js
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
4
|
-
function normalizeWindowsPath(input = "") {
|
|
5
|
-
if (!input) {
|
|
6
|
-
return input;
|
|
7
|
-
}
|
|
8
|
-
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
9
|
-
}
|
|
10
|
-
const _UNC_REGEX = /^[/\\]{2}/;
|
|
11
|
-
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
12
|
-
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
13
|
-
const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
|
|
14
|
-
const _EXTNAME_RE = /.(\.[^./]+|\.)$/;
|
|
15
|
-
const _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/;
|
|
16
|
-
const sep = "/";
|
|
17
|
-
const correctPaths = function(path) {
|
|
18
|
-
if (!path || path.length === 0) {
|
|
19
|
-
return ".";
|
|
20
|
-
}
|
|
21
|
-
path = normalizeWindowsPath(path);
|
|
22
|
-
const isUNCPath = path.match(_UNC_REGEX);
|
|
23
|
-
const isPathAbsolute = isAbsolute(path);
|
|
24
|
-
const trailingSeparator = path[path.length - 1] === "/";
|
|
25
|
-
path = normalizeString(path, !isPathAbsolute);
|
|
26
|
-
if (path.length === 0) {
|
|
27
|
-
if (isPathAbsolute) {
|
|
28
|
-
return "/";
|
|
29
|
-
}
|
|
30
|
-
return trailingSeparator ? "./" : ".";
|
|
31
|
-
}
|
|
32
|
-
if (trailingSeparator) {
|
|
33
|
-
path += "/";
|
|
34
|
-
}
|
|
35
|
-
if (_DRIVE_LETTER_RE.test(path)) {
|
|
36
|
-
path += "/";
|
|
37
|
-
}
|
|
38
|
-
if (isUNCPath) {
|
|
39
|
-
if (!isPathAbsolute) {
|
|
40
|
-
return `//./${path}`;
|
|
41
|
-
}
|
|
42
|
-
return `//${path}`;
|
|
43
|
-
}
|
|
44
|
-
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
45
|
-
};
|
|
46
|
-
const joinPaths = function(...segments) {
|
|
47
|
-
let path = "";
|
|
48
|
-
for (const seg of segments) {
|
|
49
|
-
if (!seg) {
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
if (path.length > 0) {
|
|
53
|
-
const pathTrailing = path[path.length - 1] === "/";
|
|
54
|
-
const segLeading = seg[0] === "/";
|
|
55
|
-
const both = pathTrailing && segLeading;
|
|
56
|
-
if (both) {
|
|
57
|
-
path += seg.slice(1);
|
|
58
|
-
} else {
|
|
59
|
-
path += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
60
|
-
}
|
|
61
|
-
} else {
|
|
62
|
-
path += seg;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return correctPaths(path);
|
|
66
|
-
};
|
|
67
|
-
function cwd() {
|
|
68
|
-
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
69
|
-
return process.cwd().replace(/\\/g, "/");
|
|
70
|
-
}
|
|
71
|
-
return "/";
|
|
72
|
-
}
|
|
73
|
-
const resolve = function(...arguments_) {
|
|
74
|
-
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
75
|
-
let resolvedPath = "";
|
|
76
|
-
let resolvedAbsolute = false;
|
|
77
|
-
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
78
|
-
const path = index >= 0 ? arguments_[index] : cwd();
|
|
79
|
-
if (!path || path.length === 0) {
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
resolvedPath = `${path}/${resolvedPath}`;
|
|
83
|
-
resolvedAbsolute = isAbsolute(path);
|
|
84
|
-
}
|
|
85
|
-
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
86
|
-
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
87
|
-
return `/${resolvedPath}`;
|
|
88
|
-
}
|
|
89
|
-
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
90
|
-
};
|
|
91
|
-
function normalizeString(path, allowAboveRoot) {
|
|
92
|
-
let res = "";
|
|
93
|
-
let lastSegmentLength = 0;
|
|
94
|
-
let lastSlash = -1;
|
|
95
|
-
let dots = 0;
|
|
96
|
-
let char = null;
|
|
97
|
-
for (let index = 0; index <= path.length; ++index) {
|
|
98
|
-
if (index < path.length) {
|
|
99
|
-
char = path[index];
|
|
100
|
-
} else if (char === "/") {
|
|
101
|
-
break;
|
|
102
|
-
} else {
|
|
103
|
-
char = "/";
|
|
104
|
-
}
|
|
105
|
-
if (char === "/") {
|
|
106
|
-
if (lastSlash === index - 1 || dots === 1) ; else if (dots === 2) {
|
|
107
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
108
|
-
if (res.length > 2) {
|
|
109
|
-
const lastSlashIndex = res.lastIndexOf("/");
|
|
110
|
-
if (lastSlashIndex === -1) {
|
|
111
|
-
res = "";
|
|
112
|
-
lastSegmentLength = 0;
|
|
113
|
-
} else {
|
|
114
|
-
res = res.slice(0, lastSlashIndex);
|
|
115
|
-
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
116
|
-
}
|
|
117
|
-
lastSlash = index;
|
|
118
|
-
dots = 0;
|
|
119
|
-
continue;
|
|
120
|
-
} else if (res.length > 0) {
|
|
121
|
-
res = "";
|
|
122
|
-
lastSegmentLength = 0;
|
|
123
|
-
lastSlash = index;
|
|
124
|
-
dots = 0;
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
if (allowAboveRoot) {
|
|
129
|
-
res += res.length > 0 ? "/.." : "..";
|
|
130
|
-
lastSegmentLength = 2;
|
|
131
|
-
}
|
|
132
|
-
} else {
|
|
133
|
-
if (res.length > 0) {
|
|
134
|
-
res += `/${path.slice(lastSlash + 1, index)}`;
|
|
135
|
-
} else {
|
|
136
|
-
res = path.slice(lastSlash + 1, index);
|
|
137
|
-
}
|
|
138
|
-
lastSegmentLength = index - lastSlash - 1;
|
|
139
|
-
}
|
|
140
|
-
lastSlash = index;
|
|
141
|
-
dots = 0;
|
|
142
|
-
} else if (char === "." && dots !== -1) {
|
|
143
|
-
++dots;
|
|
144
|
-
} else {
|
|
145
|
-
dots = -1;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return res;
|
|
149
|
-
}
|
|
150
|
-
const isAbsolute = function(p) {
|
|
151
|
-
return _IS_ABSOLUTE_RE.test(p);
|
|
152
|
-
};
|
|
153
|
-
const toNamespacedPath = function(p) {
|
|
154
|
-
return normalizeWindowsPath(p);
|
|
155
|
-
};
|
|
156
|
-
const extname = function(p) {
|
|
157
|
-
if (p === "..") return "";
|
|
158
|
-
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
159
|
-
return match && match[1] || "";
|
|
160
|
-
};
|
|
161
|
-
const relative = function(from, to) {
|
|
162
|
-
const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
163
|
-
const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
164
|
-
if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
|
|
165
|
-
return _to.join("/");
|
|
166
|
-
}
|
|
167
|
-
const _fromCopy = [..._from];
|
|
168
|
-
for (const segment of _fromCopy) {
|
|
169
|
-
if (_to[0] !== segment) {
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
_from.shift();
|
|
173
|
-
_to.shift();
|
|
174
|
-
}
|
|
175
|
-
return [..._from.map(() => ".."), ..._to].join("/");
|
|
176
|
-
};
|
|
177
|
-
const dirname = function(p) {
|
|
178
|
-
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
179
|
-
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
|
|
180
|
-
segments[0] += "/";
|
|
181
|
-
}
|
|
182
|
-
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
183
|
-
};
|
|
184
|
-
const format = function(p) {
|
|
185
|
-
const ext = p.ext ? p.ext.startsWith(".") ? p.ext : `.${p.ext}` : "";
|
|
186
|
-
const segments = [p.root, p.dir, p.base ?? (p.name ?? "") + ext].filter(
|
|
187
|
-
Boolean
|
|
188
|
-
);
|
|
189
|
-
return normalizeWindowsPath(
|
|
190
|
-
p.root ? resolve(...segments) : segments.join("/")
|
|
191
|
-
);
|
|
192
|
-
};
|
|
193
|
-
const basename = function(p, extension) {
|
|
194
|
-
const segments = normalizeWindowsPath(p).split("/");
|
|
195
|
-
let lastSegment = "";
|
|
196
|
-
for (let i = segments.length - 1; i >= 0; i--) {
|
|
197
|
-
const val = segments[i];
|
|
198
|
-
if (val) {
|
|
199
|
-
lastSegment = val;
|
|
200
|
-
break;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
204
|
-
};
|
|
205
|
-
const parse = function(p) {
|
|
206
|
-
const root = _PATH_ROOT_RE.exec(p)?.[0]?.replace(/\\/g, "/") || "";
|
|
207
|
-
const base = basename(p);
|
|
208
|
-
const extension = extname(base);
|
|
209
|
-
return {
|
|
210
|
-
root,
|
|
211
|
-
dir: dirname(p),
|
|
212
|
-
base,
|
|
213
|
-
ext: extension,
|
|
214
|
-
name: base.slice(0, base.length - extension.length)
|
|
215
|
-
};
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
exports.basename = basename;
|
|
219
|
-
exports.correctPaths = correctPaths;
|
|
220
|
-
exports.dirname = dirname;
|
|
221
|
-
exports.extname = extname;
|
|
222
|
-
exports.format = format;
|
|
223
|
-
exports.isAbsolute = isAbsolute;
|
|
224
|
-
exports.joinPaths = joinPaths;
|
|
225
|
-
exports.normalizeString = normalizeString;
|
|
226
|
-
exports.normalizeWindowsPath = normalizeWindowsPath;
|
|
227
|
-
exports.parse = parse;
|
|
228
|
-
exports.relative = relative;
|
|
229
|
-
exports.resolve = resolve;
|
|
230
|
-
exports.sep = sep;
|
|
231
|
-
exports.toNamespacedPath = toNamespacedPath;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
|
|
3
|
-
declare function normalizeWindowsPath(input?: string): string;
|
|
4
|
-
/**
|
|
5
|
-
* Constant for path separator.
|
|
6
|
-
*
|
|
7
|
-
* Always equals to `"/"`.
|
|
8
|
-
*/
|
|
9
|
-
declare const sep = "/";
|
|
10
|
-
declare const correctPaths: (path?: string) => string;
|
|
11
|
-
declare const joinPaths: typeof path.join;
|
|
12
|
-
declare const resolve: typeof path.resolve;
|
|
13
|
-
/**
|
|
14
|
-
* Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
|
|
15
|
-
*
|
|
16
|
-
* @param path - The path to normalise.
|
|
17
|
-
* @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
|
|
18
|
-
* @returns the normalised path string.
|
|
19
|
-
*/
|
|
20
|
-
declare function normalizeString(path: string, allowAboveRoot: boolean): string;
|
|
21
|
-
declare const isAbsolute: typeof path.isAbsolute;
|
|
22
|
-
declare const toNamespacedPath: typeof path.toNamespacedPath;
|
|
23
|
-
declare const extname: typeof path.extname;
|
|
24
|
-
declare const relative: typeof path.relative;
|
|
25
|
-
declare const dirname: typeof path.dirname;
|
|
26
|
-
declare const format: typeof path.format;
|
|
27
|
-
declare const basename: typeof path.basename;
|
|
28
|
-
declare const parse: typeof path.parse;
|
|
29
|
-
|
|
30
|
-
export { basename, correctPaths, dirname, extname, format, isAbsolute, joinPaths, normalizeString, normalizeWindowsPath, parse, relative, resolve, sep, toNamespacedPath };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
|
|
3
|
-
declare function normalizeWindowsPath(input?: string): string;
|
|
4
|
-
/**
|
|
5
|
-
* Constant for path separator.
|
|
6
|
-
*
|
|
7
|
-
* Always equals to `"/"`.
|
|
8
|
-
*/
|
|
9
|
-
declare const sep = "/";
|
|
10
|
-
declare const correctPaths: (path?: string) => string;
|
|
11
|
-
declare const joinPaths: typeof path.join;
|
|
12
|
-
declare const resolve: typeof path.resolve;
|
|
13
|
-
/**
|
|
14
|
-
* Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
|
|
15
|
-
*
|
|
16
|
-
* @param path - The path to normalise.
|
|
17
|
-
* @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
|
|
18
|
-
* @returns the normalised path string.
|
|
19
|
-
*/
|
|
20
|
-
declare function normalizeString(path: string, allowAboveRoot: boolean): string;
|
|
21
|
-
declare const isAbsolute: typeof path.isAbsolute;
|
|
22
|
-
declare const toNamespacedPath: typeof path.toNamespacedPath;
|
|
23
|
-
declare const extname: typeof path.extname;
|
|
24
|
-
declare const relative: typeof path.relative;
|
|
25
|
-
declare const dirname: typeof path.dirname;
|
|
26
|
-
declare const format: typeof path.format;
|
|
27
|
-
declare const basename: typeof path.basename;
|
|
28
|
-
declare const parse: typeof path.parse;
|
|
29
|
-
|
|
30
|
-
export { basename, correctPaths, dirname, extname, format, isAbsolute, joinPaths, normalizeString, normalizeWindowsPath, parse, relative, resolve, sep, toNamespacedPath };
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
2
|
-
function normalizeWindowsPath(input = "") {
|
|
3
|
-
if (!input) {
|
|
4
|
-
return input;
|
|
5
|
-
}
|
|
6
|
-
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
7
|
-
}
|
|
8
|
-
const _UNC_REGEX = /^[/\\]{2}/;
|
|
9
|
-
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
10
|
-
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
11
|
-
const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
|
|
12
|
-
const _EXTNAME_RE = /.(\.[^./]+|\.)$/;
|
|
13
|
-
const _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/;
|
|
14
|
-
const sep = "/";
|
|
15
|
-
const correctPaths = function(path) {
|
|
16
|
-
if (!path || path.length === 0) {
|
|
17
|
-
return ".";
|
|
18
|
-
}
|
|
19
|
-
path = normalizeWindowsPath(path);
|
|
20
|
-
const isUNCPath = path.match(_UNC_REGEX);
|
|
21
|
-
const isPathAbsolute = isAbsolute(path);
|
|
22
|
-
const trailingSeparator = path[path.length - 1] === "/";
|
|
23
|
-
path = normalizeString(path, !isPathAbsolute);
|
|
24
|
-
if (path.length === 0) {
|
|
25
|
-
if (isPathAbsolute) {
|
|
26
|
-
return "/";
|
|
27
|
-
}
|
|
28
|
-
return trailingSeparator ? "./" : ".";
|
|
29
|
-
}
|
|
30
|
-
if (trailingSeparator) {
|
|
31
|
-
path += "/";
|
|
32
|
-
}
|
|
33
|
-
if (_DRIVE_LETTER_RE.test(path)) {
|
|
34
|
-
path += "/";
|
|
35
|
-
}
|
|
36
|
-
if (isUNCPath) {
|
|
37
|
-
if (!isPathAbsolute) {
|
|
38
|
-
return `//./${path}`;
|
|
39
|
-
}
|
|
40
|
-
return `//${path}`;
|
|
41
|
-
}
|
|
42
|
-
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
43
|
-
};
|
|
44
|
-
const joinPaths = function(...segments) {
|
|
45
|
-
let path = "";
|
|
46
|
-
for (const seg of segments) {
|
|
47
|
-
if (!seg) {
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
if (path.length > 0) {
|
|
51
|
-
const pathTrailing = path[path.length - 1] === "/";
|
|
52
|
-
const segLeading = seg[0] === "/";
|
|
53
|
-
const both = pathTrailing && segLeading;
|
|
54
|
-
if (both) {
|
|
55
|
-
path += seg.slice(1);
|
|
56
|
-
} else {
|
|
57
|
-
path += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
58
|
-
}
|
|
59
|
-
} else {
|
|
60
|
-
path += seg;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return correctPaths(path);
|
|
64
|
-
};
|
|
65
|
-
function cwd() {
|
|
66
|
-
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
67
|
-
return process.cwd().replace(/\\/g, "/");
|
|
68
|
-
}
|
|
69
|
-
return "/";
|
|
70
|
-
}
|
|
71
|
-
const resolve = function(...arguments_) {
|
|
72
|
-
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
73
|
-
let resolvedPath = "";
|
|
74
|
-
let resolvedAbsolute = false;
|
|
75
|
-
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
76
|
-
const path = index >= 0 ? arguments_[index] : cwd();
|
|
77
|
-
if (!path || path.length === 0) {
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
resolvedPath = `${path}/${resolvedPath}`;
|
|
81
|
-
resolvedAbsolute = isAbsolute(path);
|
|
82
|
-
}
|
|
83
|
-
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
84
|
-
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
85
|
-
return `/${resolvedPath}`;
|
|
86
|
-
}
|
|
87
|
-
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
88
|
-
};
|
|
89
|
-
function normalizeString(path, allowAboveRoot) {
|
|
90
|
-
let res = "";
|
|
91
|
-
let lastSegmentLength = 0;
|
|
92
|
-
let lastSlash = -1;
|
|
93
|
-
let dots = 0;
|
|
94
|
-
let char = null;
|
|
95
|
-
for (let index = 0; index <= path.length; ++index) {
|
|
96
|
-
if (index < path.length) {
|
|
97
|
-
char = path[index];
|
|
98
|
-
} else if (char === "/") {
|
|
99
|
-
break;
|
|
100
|
-
} else {
|
|
101
|
-
char = "/";
|
|
102
|
-
}
|
|
103
|
-
if (char === "/") {
|
|
104
|
-
if (lastSlash === index - 1 || dots === 1) ; else if (dots === 2) {
|
|
105
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
106
|
-
if (res.length > 2) {
|
|
107
|
-
const lastSlashIndex = res.lastIndexOf("/");
|
|
108
|
-
if (lastSlashIndex === -1) {
|
|
109
|
-
res = "";
|
|
110
|
-
lastSegmentLength = 0;
|
|
111
|
-
} else {
|
|
112
|
-
res = res.slice(0, lastSlashIndex);
|
|
113
|
-
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
114
|
-
}
|
|
115
|
-
lastSlash = index;
|
|
116
|
-
dots = 0;
|
|
117
|
-
continue;
|
|
118
|
-
} else if (res.length > 0) {
|
|
119
|
-
res = "";
|
|
120
|
-
lastSegmentLength = 0;
|
|
121
|
-
lastSlash = index;
|
|
122
|
-
dots = 0;
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if (allowAboveRoot) {
|
|
127
|
-
res += res.length > 0 ? "/.." : "..";
|
|
128
|
-
lastSegmentLength = 2;
|
|
129
|
-
}
|
|
130
|
-
} else {
|
|
131
|
-
if (res.length > 0) {
|
|
132
|
-
res += `/${path.slice(lastSlash + 1, index)}`;
|
|
133
|
-
} else {
|
|
134
|
-
res = path.slice(lastSlash + 1, index);
|
|
135
|
-
}
|
|
136
|
-
lastSegmentLength = index - lastSlash - 1;
|
|
137
|
-
}
|
|
138
|
-
lastSlash = index;
|
|
139
|
-
dots = 0;
|
|
140
|
-
} else if (char === "." && dots !== -1) {
|
|
141
|
-
++dots;
|
|
142
|
-
} else {
|
|
143
|
-
dots = -1;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return res;
|
|
147
|
-
}
|
|
148
|
-
const isAbsolute = function(p) {
|
|
149
|
-
return _IS_ABSOLUTE_RE.test(p);
|
|
150
|
-
};
|
|
151
|
-
const toNamespacedPath = function(p) {
|
|
152
|
-
return normalizeWindowsPath(p);
|
|
153
|
-
};
|
|
154
|
-
const extname = function(p) {
|
|
155
|
-
if (p === "..") return "";
|
|
156
|
-
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
157
|
-
return match && match[1] || "";
|
|
158
|
-
};
|
|
159
|
-
const relative = function(from, to) {
|
|
160
|
-
const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
161
|
-
const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
162
|
-
if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
|
|
163
|
-
return _to.join("/");
|
|
164
|
-
}
|
|
165
|
-
const _fromCopy = [..._from];
|
|
166
|
-
for (const segment of _fromCopy) {
|
|
167
|
-
if (_to[0] !== segment) {
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
_from.shift();
|
|
171
|
-
_to.shift();
|
|
172
|
-
}
|
|
173
|
-
return [..._from.map(() => ".."), ..._to].join("/");
|
|
174
|
-
};
|
|
175
|
-
const dirname = function(p) {
|
|
176
|
-
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
177
|
-
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
|
|
178
|
-
segments[0] += "/";
|
|
179
|
-
}
|
|
180
|
-
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
181
|
-
};
|
|
182
|
-
const format = function(p) {
|
|
183
|
-
const ext = p.ext ? p.ext.startsWith(".") ? p.ext : `.${p.ext}` : "";
|
|
184
|
-
const segments = [p.root, p.dir, p.base ?? (p.name ?? "") + ext].filter(
|
|
185
|
-
Boolean
|
|
186
|
-
);
|
|
187
|
-
return normalizeWindowsPath(
|
|
188
|
-
p.root ? resolve(...segments) : segments.join("/")
|
|
189
|
-
);
|
|
190
|
-
};
|
|
191
|
-
const basename = function(p, extension) {
|
|
192
|
-
const segments = normalizeWindowsPath(p).split("/");
|
|
193
|
-
let lastSegment = "";
|
|
194
|
-
for (let i = segments.length - 1; i >= 0; i--) {
|
|
195
|
-
const val = segments[i];
|
|
196
|
-
if (val) {
|
|
197
|
-
lastSegment = val;
|
|
198
|
-
break;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
202
|
-
};
|
|
203
|
-
const parse = function(p) {
|
|
204
|
-
const root = _PATH_ROOT_RE.exec(p)?.[0]?.replace(/\\/g, "/") || "";
|
|
205
|
-
const base = basename(p);
|
|
206
|
-
const extension = extname(base);
|
|
207
|
-
return {
|
|
208
|
-
root,
|
|
209
|
-
dir: dirname(p),
|
|
210
|
-
base,
|
|
211
|
-
ext: extension,
|
|
212
|
-
name: base.slice(0, base.length - extension.length)
|
|
213
|
-
};
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
export { basename, correctPaths, dirname, extname, format, isAbsolute, joinPaths, normalizeString, normalizeWindowsPath, parse, relative, resolve, sep, toNamespacedPath };
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var node_fs = require('node:fs');
|
|
4
|
-
var node_path = require('node:path');
|
|
5
|
-
var correctPaths = require('./correct-paths');
|
|
6
|
-
|
|
7
|
-
const MAX_PATH_SEARCH_DEPTH = 30;
|
|
8
|
-
let depth = 0;
|
|
9
|
-
function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) {
|
|
10
|
-
const _startPath = startPath ?? process.cwd();
|
|
11
|
-
if (endDirectoryNames.some(
|
|
12
|
-
(endDirName) => node_fs.existsSync(node_path.join(_startPath, endDirName))
|
|
13
|
-
)) {
|
|
14
|
-
return _startPath;
|
|
15
|
-
}
|
|
16
|
-
if (endFileNames.some((endFileName) => node_fs.existsSync(node_path.join(_startPath, endFileName)))) {
|
|
17
|
-
return _startPath;
|
|
18
|
-
}
|
|
19
|
-
if (_startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) {
|
|
20
|
-
const parent = node_path.join(_startPath, "..");
|
|
21
|
-
return findFolderUp(parent, endFileNames, endDirectoryNames);
|
|
22
|
-
}
|
|
23
|
-
return void 0;
|
|
24
|
-
}
|
|
25
|
-
const rootFiles = [
|
|
26
|
-
"storm-workspace.json",
|
|
27
|
-
"storm-workspace.json",
|
|
28
|
-
"storm-workspace.yaml",
|
|
29
|
-
"storm-workspace.yml",
|
|
30
|
-
"storm-workspace.js",
|
|
31
|
-
"storm-workspace.ts",
|
|
32
|
-
".storm-workspace.json",
|
|
33
|
-
".storm-workspace.yaml",
|
|
34
|
-
".storm-workspace.yml",
|
|
35
|
-
".storm-workspace.js",
|
|
36
|
-
".storm-workspace.ts",
|
|
37
|
-
"lerna.json",
|
|
38
|
-
"nx.json",
|
|
39
|
-
"turbo.json",
|
|
40
|
-
"npm-workspace.json",
|
|
41
|
-
"yarn-workspace.json",
|
|
42
|
-
"pnpm-workspace.json",
|
|
43
|
-
"npm-workspace.yaml",
|
|
44
|
-
"yarn-workspace.yaml",
|
|
45
|
-
"pnpm-workspace.yaml",
|
|
46
|
-
"npm-workspace.yml",
|
|
47
|
-
"yarn-workspace.yml",
|
|
48
|
-
"pnpm-workspace.yml",
|
|
49
|
-
"npm-lock.json",
|
|
50
|
-
"yarn-lock.json",
|
|
51
|
-
"pnpm-lock.json",
|
|
52
|
-
"npm-lock.yaml",
|
|
53
|
-
"yarn-lock.yaml",
|
|
54
|
-
"pnpm-lock.yaml",
|
|
55
|
-
"npm-lock.yml",
|
|
56
|
-
"yarn-lock.yml",
|
|
57
|
-
"pnpm-lock.yml",
|
|
58
|
-
"bun.lockb"
|
|
59
|
-
];
|
|
60
|
-
const rootDirectories = [
|
|
61
|
-
".storm-workspace",
|
|
62
|
-
".nx",
|
|
63
|
-
".github",
|
|
64
|
-
".vscode",
|
|
65
|
-
".verdaccio"
|
|
66
|
-
];
|
|
67
|
-
function findWorkspaceRootSafe(pathInsideMonorepo) {
|
|
68
|
-
if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
|
|
69
|
-
return correctPaths.correctPaths(
|
|
70
|
-
process.env.STORM_WORKSPACE_ROOT ?? process.env.NX_WORKSPACE_ROOT_PATH
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
return correctPaths.correctPaths(
|
|
74
|
-
findFolderUp(
|
|
75
|
-
pathInsideMonorepo ?? process.cwd(),
|
|
76
|
-
rootFiles,
|
|
77
|
-
rootDirectories
|
|
78
|
-
)
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
function findWorkspaceRoot(pathInsideMonorepo) {
|
|
82
|
-
const result = findWorkspaceRootSafe(pathInsideMonorepo);
|
|
83
|
-
if (!result) {
|
|
84
|
-
throw new Error(
|
|
85
|
-
`Cannot find workspace root upwards from known path. Files search list includes:
|
|
86
|
-
${rootFiles.join(
|
|
87
|
-
"\n"
|
|
88
|
-
)}
|
|
89
|
-
Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
return result;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
exports.findWorkspaceRoot = findWorkspaceRoot;
|
|
96
|
-
exports.findWorkspaceRootSafe = findWorkspaceRootSafe;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Find the monorepo root directory, searching upwards from `path`.
|
|
3
|
-
*
|
|
4
|
-
* @param pathInsideMonorepo - The path inside the monorepo to start searching from
|
|
5
|
-
* @returns The monorepo root directory
|
|
6
|
-
*/
|
|
7
|
-
declare function findWorkspaceRootSafe(pathInsideMonorepo?: string): string | undefined;
|
|
8
|
-
/**
|
|
9
|
-
* Find the monorepo root directory, searching upwards from `path`.
|
|
10
|
-
*
|
|
11
|
-
* @param pathInsideMonorepo - The path inside the monorepo to start searching from
|
|
12
|
-
* @returns The monorepo root directory
|
|
13
|
-
*/
|
|
14
|
-
declare function findWorkspaceRoot(pathInsideMonorepo?: string): string;
|
|
15
|
-
|
|
16
|
-
export { findWorkspaceRoot, findWorkspaceRootSafe };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Find the monorepo root directory, searching upwards from `path`.
|
|
3
|
-
*
|
|
4
|
-
* @param pathInsideMonorepo - The path inside the monorepo to start searching from
|
|
5
|
-
* @returns The monorepo root directory
|
|
6
|
-
*/
|
|
7
|
-
declare function findWorkspaceRootSafe(pathInsideMonorepo?: string): string | undefined;
|
|
8
|
-
/**
|
|
9
|
-
* Find the monorepo root directory, searching upwards from `path`.
|
|
10
|
-
*
|
|
11
|
-
* @param pathInsideMonorepo - The path inside the monorepo to start searching from
|
|
12
|
-
* @returns The monorepo root directory
|
|
13
|
-
*/
|
|
14
|
-
declare function findWorkspaceRoot(pathInsideMonorepo?: string): string;
|
|
15
|
-
|
|
16
|
-
export { findWorkspaceRoot, findWorkspaceRootSafe };
|